Skip to content

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

@JasXSL

Description

@JasXSL

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions