Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding & Removing emitters ad hoc causes particles to get stuck #130

Open
JasXSL opened this issue Dec 9, 2018 · 0 comments
Open

Adding & Removing emitters ad hoc causes particles to get stuck #130

JasXSL opened this issue Dec 9, 2018 · 0 comments

Comments

@JasXSL
Copy link

JasXSL commented Dec 9, 2018

The sparkles on the keys in this pic get stuck after emitter.remove() is called:

Stuck

The following is executed when the page loads:

this.sparkleParticles = new SPE.Group({
	texture: {
		value: this.textureLoader.load('./media/sparkle.png')
	},
	blending : THREE.AdditiveBlending,
	maxParticleCount:10000
});
this.scene.add(this.sparkleParticles.mesh);

And the following when a key is pressed:

// Spawn particles
const sparkles = new SPE.Emitter({
	maxAge: {
		value: 0.3
	},
	rotation : {
		//angleSpread : 0.3,
		//axisSpread : Math.PI*2
	},
	opacity : {
		value : [1]
	},
	position: {
		value: new THREE.Vector3(raycastObj.point.x, raycastObj.point.y, raycastObj.point.z+0.1),
		spread: new THREE.Vector3( 0.1, 0.1, 0 ),
		randomise : true,
		radius : 1
	},
	acceleration: {
		value: new THREE.Vector3(0, 0, -0.1),
		spread: new THREE.Vector3( 0, 0, 0 ),
		randomise : true,
	},
	velocity: {
		value: new THREE.Vector3(1, 1, 1),
		spread: new THREE.Vector3(2, 2, 0),
		randomise : true,
		distribution: SPE.distributions.SPHERE,
	},
	angle : {
		spread : Math.PI*2,
		randomise : true,
	},
	color: {
		value: [ new THREE.Color(1.0,1.0,0.0), new THREE.Color(0xFFFFFF) ]
	},
	size: {
		value: [0.3,0.1]
	},
	particleCount: 100
});
this.sparkleParticles.addEmitter(sparkles);
setTimeout(() => {
	sparkles.remove();
}, 1000);
setTimeout(() => {
	sparkles.disable();
}, 100);
console.log(this.sparkleParticles.emitters);

For now I can make a pool of emitters when the page loads and use those. But being able to add and remove emitters ad-hoc would be neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant