babylon.quarks 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +769 -8
- package/README.md +10 -8
- package/dist/babylon.quarks.cjs +1 -1
- package/dist/babylon.quarks.cjs.map +1 -1
- package/dist/babylon.quarks.esm.js +1 -1
- package/dist/babylon.quarks.esm.js.map +1 -1
- package/dist/babylon.quarks.umd.min.js +1 -1
- package/dist/babylon.quarks.umd.min.js.map +1 -1
- package/dist/types/index.d.cts +6683 -0
- package/dist/types/index.d.ts +1959 -588
- package/package.json +12 -6
- package/src/BatchedRenderer.ts +204 -101
- package/src/EffectPool.ts +4 -1
- package/src/MeshSurfaceEmitter.ts +29 -4
- package/src/ParticleEmitter.ts +45 -15
- package/src/ParticleSystem.ts +909 -2061
- package/src/QuarksLoader.ts +421 -67
- package/src/QuarksPrefab.ts +91 -4
- package/src/QuarksSerializer.ts +484 -0
- package/src/QuarksUtil.ts +15 -0
- package/src/SpriteBatch.ts +106 -246
- package/src/TrailBatch.ts +533 -342
- package/src/VFXBatch.ts +236 -136
- package/src/batchKey.ts +237 -0
- package/src/effectResources.ts +79 -0
- package/src/envAtlas.ts +119 -17
- package/src/index.ts +32 -33
- package/src/nodeId.ts +13 -0
- package/src/shaderProgram.ts +325 -0
- package/src/shaderVariants.ts +225 -0
- package/src/shaders/chunks/fog.ts +4 -2
- package/src/shaders/chunks/sheet.ts +111 -0
- package/src/shaders/chunks/soft.ts +84 -0
- package/src/shaders/chunks/surface.ts +10 -0
- package/src/shaders/local_particle_physics_vert.glsl.ts +14 -28
- package/src/shaders/local_particle_physics_vert.wgsl.ts +16 -29
- package/src/shaders/particle_frag.glsl.ts +3 -22
- package/src/shaders/particle_frag.wgsl.ts +3 -23
- package/src/shaders/particle_physics_frag.glsl.ts +12 -25
- package/src/shaders/particle_physics_frag.wgsl.ts +12 -26
- package/src/shaders/particle_vert.glsl.ts +5 -27
- package/src/shaders/particle_vert.wgsl.ts +5 -26
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +7 -33
- package/src/shaders/stretched_bb_particle_vert.wgsl.ts +7 -33
- package/src/shaders/trail_frag.glsl.ts +11 -1
- package/src/shaders/trail_frag.wgsl.ts +11 -0
- package/src/shaders/trail_vert.glsl.ts +45 -36
- package/src/shaders/trail_vert.wgsl.ts +46 -40
- package/src/softDepth.ts +136 -0
- package/src/system/BehaviorPlan.ts +85 -0
- package/src/system/BoundsTracker.ts +181 -0
- package/src/system/EmissionController.ts +360 -0
- package/src/system/EventDispatcher.ts +44 -0
- package/src/system/ParticleSpawner.ts +274 -0
- package/src/system/SimulationClock.ts +130 -0
- package/src/system/geometry.ts +111 -0
- package/src/system/integrate.ts +428 -0
- package/src/system/materialResolve.ts +116 -0
- package/src/system/normalize.ts +95 -0
- package/src/system/serialization.ts +401 -0
- package/src/system/settingsSchema.ts +317 -0
- package/src/system/types.ts +410 -0
- package/src/textureSource.ts +30 -0
- package/src/trailSettings.ts +51 -0
- package/src/BatchedParticleRenderer.ts +0 -3
- package/src/materials/ParticleMaterials.ts +0 -23
- package/src/materials/index.ts +0 -1
- package/src/shaders/chunks/index.ts +0 -1
- package/src/shaders/chunks/register-shader-chunks.ts +0 -32
- package/src/shaders/chunks/soft_fragment.glsl.ts +0 -13
- package/src/shaders/chunks/soft_pars_fragment.glsl.ts +0 -20
- package/src/shaders/chunks/soft_pars_vertex.glsl.ts +0 -6
- package/src/shaders/chunks/soft_vertex.glsl.ts +0 -6
- package/src/shaders/chunks/tile_fragment.glsl.ts +0 -9
- package/src/shaders/chunks/tile_pars_fragment.glsl.ts +0 -9
- package/src/shaders/chunks/tile_pars_vertex.glsl.ts +0 -28
- package/src/shaders/chunks/tile_vertex.glsl.ts +0 -18
- package/src/shaders/index.ts +0 -9
- package/src/shaders/local_particle_vert.glsl.ts +0 -50
package/src/ParticleEmitter.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
import {TransformNode} from '@babylonjs/core/Meshes/transformNode';
|
|
2
2
|
import {Scene} from '@babylonjs/core/scene';
|
|
3
3
|
import {IParticleSystem, Matrix4, SerializationOptions} from 'quarks.core';
|
|
4
|
+
import {quarksNodeId} from './nodeId';
|
|
4
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Above 0 while a particle system disposes its own emitter (`ParticleSystem.dispose()`, which
|
|
8
|
+
* `autoDestroy` calls when the system finishes). Babylon then disposes the child nodes too, and
|
|
9
|
+
* child emitters keep their systems playing, so an effect's longer-lived children are not cut off
|
|
10
|
+
* when a short parent finishes. Disposing a node directly (`root.dispose()`) disposes its systems.
|
|
11
|
+
*/
|
|
12
|
+
let systemDisposeDepth = 0;
|
|
13
|
+
|
|
14
|
+
/** Disposes `emitter` for its own system without disposing the systems of child emitters. */
|
|
15
|
+
export function disposeEmitterForSystem(emitter: TransformNode): void {
|
|
16
|
+
systemDisposeDepth++;
|
|
17
|
+
try {
|
|
18
|
+
emitter.dispose();
|
|
19
|
+
} finally {
|
|
20
|
+
systemDisposeDepth--;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The Babylon node a particle system lives at: its position, rotation and scale place the system,
|
|
26
|
+
* parenting it moves the effect with another node, and disabling it freezes and hides the system.
|
|
27
|
+
* Every {@link ParticleSystem} makes its own, as `system.emitter`.
|
|
28
|
+
*/
|
|
5
29
|
export class ParticleEmitter extends TransformNode {
|
|
30
|
+
/** The particle system this node carries. */
|
|
6
31
|
system: IParticleSystem;
|
|
7
32
|
private _matrixWorld: Matrix4 = new Matrix4();
|
|
8
33
|
private _matrixWorldFlag = -1;
|
|
@@ -40,6 +65,7 @@ export class ParticleEmitter extends TransformNode {
|
|
|
40
65
|
return this._matrixWorld;
|
|
41
66
|
}
|
|
42
67
|
|
|
68
|
+
/** Whether the node and its parents are enabled; setting it is `setEnabled`. */
|
|
43
69
|
get visible(): boolean {
|
|
44
70
|
return this.isEnabled();
|
|
45
71
|
}
|
|
@@ -48,8 +74,9 @@ export class ParticleEmitter extends TransformNode {
|
|
|
48
74
|
this.setEnabled(value);
|
|
49
75
|
}
|
|
50
76
|
|
|
77
|
+
/** The id effect files know this emitter by; see {@link quarksNodeId}. */
|
|
51
78
|
get uuid(): string {
|
|
52
|
-
return this
|
|
79
|
+
return quarksNodeId(this);
|
|
53
80
|
}
|
|
54
81
|
|
|
55
82
|
constructor(system: IParticleSystem, scene?: Scene) {
|
|
@@ -57,20 +84,22 @@ export class ParticleEmitter extends TransformNode {
|
|
|
57
84
|
this.system = system;
|
|
58
85
|
}
|
|
59
86
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Disposes the node and the particle system it carries, so `root.dispose()` on an effect tree
|
|
89
|
+
* also removes its systems from their renderer. Safe to call more than once. When a system
|
|
90
|
+
* disposes its own emitter (`ParticleSystem.dispose()`, `autoDestroy`), the systems of child
|
|
91
|
+
* emitters keep playing until they finish or are disposed themselves.
|
|
92
|
+
*/
|
|
93
|
+
dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {
|
|
94
|
+
if (this.isDisposed()) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
super.dispose(doNotRecurse, disposeMaterialAndTextures);
|
|
98
|
+
if (systemDisposeDepth > 0) {
|
|
99
|
+
return;
|
|
72
100
|
}
|
|
73
|
-
|
|
101
|
+
// IParticleSystem (quarks.core) has no dispose(); ParticleSystem does.
|
|
102
|
+
(this.system as IParticleSystem & {dispose?: () => void}).dispose?.();
|
|
74
103
|
}
|
|
75
104
|
|
|
76
105
|
clone(name?: string): ParticleEmitter {
|
|
@@ -88,9 +117,10 @@ export class ParticleEmitter extends TransformNode {
|
|
|
88
117
|
return clonedEmitter;
|
|
89
118
|
}
|
|
90
119
|
|
|
120
|
+
/** The node and its system in effect-file form; `serializeEffect` writes whole effects. @internal */
|
|
91
121
|
toJSON(meta?: any, options: SerializationOptions = {}): any {
|
|
92
122
|
return {
|
|
93
|
-
uuid: (this
|
|
123
|
+
uuid: quarksNodeId(this),
|
|
94
124
|
type: 'ParticleEmitter',
|
|
95
125
|
name: this.name,
|
|
96
126
|
position: [this.position.x, this.position.y, this.position.z],
|