ShaderParticleEngine icon indicating copy to clipboard operation
ShaderParticleEngine copied to clipboard

Changing values at runtime

Open weiserhei opened this issue 8 years ago • 6 comments

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:

weiserhei avatar Apr 19 '16 23:04 weiserhei

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;

squarefeet avatar May 02 '16 19:05 squarefeet

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.

mixn avatar Jun 04 '17 19:06 mixn

+1 for the ability to re-position emitters at runtime. This would be SUPER cool.

titansoftime avatar Oct 11 '17 01:10 titansoftime

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:

JasXSL avatar Oct 17 '17 16:10 JasXSL

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!

squarefeet avatar Oct 26 '17 22:10 squarefeet

@JasXSL I've managed to reproduce this, so give me a bit of time to see what's going on :)

squarefeet avatar Oct 27 '17 11:10 squarefeet