Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Alchemist0823 committed Jul 26, 2024
1 parent 229dc9e commit 666d766
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ loader.load(jsonURL, (obj) => {
scene.add(batchSystem);
```

#### Play multiple instances of loaded effect

```javascript
const effect = obj.clone(true);
scene.add(effect);
QuarksUtil.setAutoDestroy(effect, true);
QuarksUtil.addToBatchRenderer(effect, batchSystem);
QuarksUtil.play(effect);

```

Note: the texture url reference is defined by the texture's name field.
you may need to modify the texture url in json as needed.

Expand Down
2 changes: 1 addition & 1 deletion packages/quarks.core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quarks.core",
"version": "0.15.0",
"version": "0.15.2",
"description": "Core library for Quarks VFX / Particle System Library",
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down
6 changes: 6 additions & 0 deletions packages/quarks.core/src/IParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export interface IEmitter {


export interface IParticleSystem {

/**
* Whether the ParticleSystem should be automatically disposed when it finishes emitting particles.
* @type {string}
*/
autoDestroy: boolean;
/**
* Whether the system is in world space.
* @type {boolean}
Expand Down
4 changes: 2 additions & 2 deletions packages/quarks.nodes/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "quarks.nodes",
"version": "0.15.0",
"version": "0.15.2",
"description": "node based behavior and render system for quarks engine",
"type": "module",
"dependencies": {
"three.quarks": "^0.15.0"
"three.quarks": "^0.15.2"
},
"devDependencies": {
"@types/three": "^0.165.0",
Expand Down
4 changes: 2 additions & 2 deletions 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.1",
"version": "0.15.2",
"description": "A General-Purpose Particle System for three.js",
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down Expand Up @@ -60,7 +60,7 @@
"three": ">=0.165.0"
},
"dependencies": {
"quarks.core": "^0.15.0"
"quarks.core": "^0.15.2"
},
"devDependencies": {
"@types/jest": "^29.5.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/three.quarks/src/ParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const DEFAULT_GEOMETRY = new PlaneGeometry(1, 1, 1, 1);
*/
export class ParticleSystem implements IParticleSystem {
/**
* Determines whether the ParticleSystem should be automatically disposed when it finishes emitting particles.
* whether the ParticleSystem should be automatically disposed when it finishes emitting particles.
*
* @type {boolean}
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/three.quarks/src/QuarksUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Object3D} from 'three';
import {ParticleEmitter} from './ParticleEmitter';
import {BatchedRenderer} from './BatchedRenderer';
import {ParticleSystem} from './ParticleSystem';


export class QuarksUtil {
Expand Down Expand Up @@ -52,6 +53,12 @@ export class QuarksUtil {
});
}

static setAutoDestroy(obj: Object3D, value: boolean) {
QuarksUtil.runOnAllParticleEmitters(obj, (ps) => {
ps.system.autoDestroy = value;
});
}

/**
* Stop emit new particles from all particle systems and
* keep simulating the existing particles in the object and the object's children.
Expand Down

0 comments on commit 666d766

Please sign in to comment.