Why is there no attribute or method for Capacity set in ParticleSystem?which can only be set during initialization
I think it’s for optimization purpose and ease of implementation. Also, you generally don’t need to change the capacity over the lifetime of a particle system. What would be your use case?
1 Like
I have a scenario where I need to dynamically set the capacity of the particle system
labris
November 23, 2024, 2:36am
4
You may either extend thinParticleSystem
) {
this._vertexBufferSize += 3;
}
if (this._useRampGradients) {
this._vertexBufferSize += 4;
}
const engine = this._engine;
const vertexSize = this._vertexBufferSize * (this._useInstancing ? 1 : 4);
this._vertexData = new Float32Array(this._capacity * vertexSize);
this._vertexBuffer = new Buffer(engine, this._vertexData, true, vertexSize);
let dataOffset = 0;
const positions = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers[VertexBuffer.PositionKind] = positions;
dataOffset += 3;
const colors = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
this._vertexBuffers[VertexBuffer.ColorKind] = colors;
dataOffset += 4;
or just create another ParticleSystem to replace existing one.
1 Like