ShaderParticleEngine
ShaderParticleEngine copied to clipboard
Changing values at runtime
I wanted to trigger a pool emitter using a position, documented here:
triggerPoolEmitter(numEmitters, position)
The position is updated, but I get strange particle culling. It seems the position value checked for culling is still at the old position. Looking at the source there is this: https://github.com/squarefeet/ShaderParticleEngine/blob/master/build/SPE.js#L2365-L2373
// TODO:
// - Make sure buffers are update with thus new position.
Is there still something todo? What does work for me is doing this:
particleGroup.mesh.position.copy( otherMesh.position );
, then trigger the emitter.
Everything going as expected.
How would i change the position: radius
at runtime? Im doing it like this for a pool:
for ( var i = 0; i < particleGroup.emitters.length; i ++ ) {
particleGroup.emitters[ i ].position._radius = size;
}
But i dont feel comfortable accessing _
-properties :smile:
About pool emitters and positions: I'll look into this!
For runtime changing of radius:
You should just be able to do the following, assuming emitter
is an instance of SPE.Emitter
:
emitter.position.radius = 100;
Is there a way to update the position of a particular emitter
by now? Would be awesome!
I’d love to display them all in the very center and make them spread further out after some interaction.
+1 for the ability to re-position emitters at runtime. This would be SUPER cool.
I have the same issue. I'd like for the emitter to follow a moving object (but have the particles relative to world), so I'm updating the position at each frame. However, when I update the emitter position it gets screwed up, even if I'm updating to the same position.
Emitter start settings: { type: SPE.distributions.DISC, maxAge: { value: 1 }, position: { radius: 1, value : new THREE.Vector3(0,1,0) }, velocity: { value: new THREE.Vector3( 1, 1, 1 ), }, color: { value: [ new THREE.Color('white'), new THREE.Color('red') ] }, size: { value: 1 }, particleCount: 250 }
Result:
Console command:
emitter.position.value = new THREE.Vector3(0,1,0);
Result:
Interesting, @JasXSL, thanks for the screenshots, super helpful.
I'll see if I can find the cause for it getting all out-of-alignment, and maybe find a way to fix this issue. It should currently be possible to change the position of an emitter by doing what you're doing, but it certainly shouldn't cause that weirdness!
It's on my list!
@JasXSL I've managed to reproduce this, so give me a bit of time to see what's going on :)