Skip to content

Commit

Permalink
fix clone bug on stretched billboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchemist0823 committed Sep 10, 2024
1 parent 0a4a7db commit 838c38c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Change Log
## Version 0.15.5
- Fix stretched billboard settings are not cloned in clone function

## Version 0.15.4
- Fix 1 frame lag bug when parent entity of a particle system is moved
Expand Down
36 changes: 26 additions & 10 deletions packages/three.quarks/examples/explosionDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,40 @@ import {Demo} from './demo.js';
export class ExplosionDemo extends Demo {
name = 'explosion (Unity Exported)';
refreshTime = 2;
loadedEffect = null;

newInstance() {
function listener(event) {
console.log(event.type);
}
const effect = this.loadedEffect.clone(true);
QuarksUtil.runOnAllParticleEmitters(effect, (emitter) => {
emitter.system.addEventListener("emitEnd", listener);
})
QuarksUtil.setAutoDestroy(effect, true);
QuarksUtil.addToBatchRenderer(effect, this.batchRenderer);
QuarksUtil.play(effect);
this.scene.add(effect);
}


render(delta) {
if (this.totalTime + delta > this.refreshTime) {
this.newInstance();
}
super.render(delta);
}

initScene() {
super.initScene();

this.batchRenderer = new BatchedParticleRenderer();
this.scene.add(this.batchRenderer);
function listener(event) {
console.log(event.type);
}

new QuarksLoader().load('ps.json', (obj) => {
QuarksUtil.addToBatchRenderer(obj, this.batchRenderer);
QuarksUtil.runOnAllParticleEmitters(obj, (emitter) => {
emitter.system.addEventListener("emitEnd", listener);
})
this.scene.add(obj);
this.groups.push(obj);
this.loadedEffect = obj;
this.newInstance();
});

return this.scene;
}
}
2 changes: 1 addition & 1 deletion packages/three.quarks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "three.quarks",
"version": "0.15.4",
"version": "0.15.5",
"description": "A General-Purpose Particle System for three.js",
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions packages/three.quarks/src/ParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,11 @@ export class ParticleSystem implements IParticleSystem {
startLength: (this.rendererEmitterSettings as TrailSettings).startLength.clone(),
followLocalOrigin: (this.rendererEmitterSettings as TrailSettings).followLocalOrigin,
};
} else if (this.renderMode === RenderMode.StretchedBillBoard) {
rendererEmitterSettings = {
lengthFactor: (this.rendererEmitterSettings as StretchedBillBoardSettings).lengthFactor,
speedFactor: (this.rendererEmitterSettings as StretchedBillBoardSettings).speedFactor,
};
} else {
rendererEmitterSettings = {};
}
Expand Down

0 comments on commit 838c38c

Please sign in to comment.