babylon.quarks 0.26.0 → 0.28.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +1194 -8
  2. package/README.md +13 -9
  3. package/dist/babylon.quarks.cjs +1 -1
  4. package/dist/babylon.quarks.cjs.map +1 -1
  5. package/dist/babylon.quarks.esm.js +1 -1
  6. package/dist/babylon.quarks.esm.js.map +1 -1
  7. package/dist/babylon.quarks.umd.min.js +1 -1
  8. package/dist/babylon.quarks.umd.min.js.map +1 -1
  9. package/dist/types/index.d.cts +10108 -0
  10. package/dist/types/index.d.ts +5794 -998
  11. package/package.json +18 -7
  12. package/src/BatchedRenderer.ts +274 -156
  13. package/src/EffectPool.ts +94 -12
  14. package/src/MeshSurfaceEmitter.ts +50 -14
  15. package/src/ParticleEmitter.ts +75 -17
  16. package/src/ParticleSystem.ts +981 -2066
  17. package/src/QuarksLoader.ts +666 -194
  18. package/src/QuarksPrefab.ts +367 -73
  19. package/src/QuarksSerializer.ts +512 -0
  20. package/src/QuarksUtil.ts +77 -7
  21. package/src/SpriteBatch.ts +127 -252
  22. package/src/TrailBatch.ts +545 -348
  23. package/src/VFXBatch.ts +238 -596
  24. package/src/batchKey.ts +239 -0
  25. package/src/batchSettings.ts +546 -0
  26. package/src/effectDocumentJSON.ts +261 -0
  27. package/src/effectResources.ts +76 -0
  28. package/src/envAtlas.ts +126 -18
  29. package/src/geometryUtil.ts +1 -1
  30. package/src/index.ts +69 -35
  31. package/src/nodeId.ts +36 -0
  32. package/src/shaderProgram.ts +419 -0
  33. package/src/shaderVariants.ts +245 -0
  34. package/src/shaders/chunks/blend.ts +31 -0
  35. package/src/shaders/chunks/fog.ts +12 -5
  36. package/src/shaders/chunks/sheet.ts +111 -0
  37. package/src/shaders/chunks/soft.ts +85 -0
  38. package/src/shaders/chunks/surface.ts +12 -2
  39. package/src/shaders/local_particle_physics_vert.glsl.ts +14 -28
  40. package/src/shaders/local_particle_physics_vert.wgsl.ts +16 -29
  41. package/src/shaders/particle_frag.glsl.ts +5 -22
  42. package/src/shaders/particle_frag.wgsl.ts +5 -23
  43. package/src/shaders/particle_physics_frag.glsl.ts +16 -26
  44. package/src/shaders/particle_physics_frag.wgsl.ts +14 -26
  45. package/src/shaders/particle_vert.glsl.ts +5 -27
  46. package/src/shaders/particle_vert.wgsl.ts +5 -26
  47. package/src/shaders/stretched_bb_particle_vert.glsl.ts +7 -33
  48. package/src/shaders/stretched_bb_particle_vert.wgsl.ts +7 -33
  49. package/src/shaders/trail_frag.glsl.ts +13 -0
  50. package/src/shaders/trail_frag.wgsl.ts +13 -0
  51. package/src/shaders/trail_vert.glsl.ts +45 -36
  52. package/src/shaders/trail_vert.wgsl.ts +46 -40
  53. package/src/softDepth.ts +136 -0
  54. package/src/system/BehaviorPlan.ts +85 -0
  55. package/src/system/BoundsTracker.ts +181 -0
  56. package/src/system/EmissionController.ts +358 -0
  57. package/src/system/EventDispatcher.ts +60 -0
  58. package/src/system/ParticleSpawner.ts +274 -0
  59. package/src/system/SimulationClock.ts +130 -0
  60. package/src/system/geometry.ts +104 -0
  61. package/src/system/integrate.ts +428 -0
  62. package/src/system/materialResolve.ts +165 -0
  63. package/src/system/normalize.ts +100 -0
  64. package/src/system/serialization.ts +422 -0
  65. package/src/system/settingsSchema.ts +339 -0
  66. package/src/system/types.ts +449 -0
  67. package/src/textureSource.ts +30 -0
  68. package/src/trailSettings.ts +54 -0
  69. package/src/BatchedParticleRenderer.ts +0 -3
  70. package/src/materials/ParticleMaterials.ts +0 -23
  71. package/src/materials/index.ts +0 -1
  72. package/src/shaders/chunks/index.ts +0 -1
  73. package/src/shaders/chunks/register-shader-chunks.ts +0 -32
  74. package/src/shaders/chunks/soft_fragment.glsl.ts +0 -13
  75. package/src/shaders/chunks/soft_pars_fragment.glsl.ts +0 -20
  76. package/src/shaders/chunks/soft_pars_vertex.glsl.ts +0 -6
  77. package/src/shaders/chunks/soft_vertex.glsl.ts +0 -6
  78. package/src/shaders/chunks/tile_fragment.glsl.ts +0 -9
  79. package/src/shaders/chunks/tile_pars_fragment.glsl.ts +0 -9
  80. package/src/shaders/chunks/tile_pars_vertex.glsl.ts +0 -28
  81. package/src/shaders/chunks/tile_vertex.glsl.ts +0 -18
  82. package/src/shaders/index.ts +0 -9
  83. package/src/shaders/local_particle_vert.glsl.ts +0 -50
package/README.md CHANGED
@@ -16,13 +16,15 @@ High-performance particle system for [Babylon.js](https://www.babylonjs.com/). B
16
16
  ## Features
17
17
 
18
18
  - **Batched rendering** — heterogeneous particle systems share draw calls via `BatchedRenderer`.
19
- - **Render modes** — billboard, vertical/horizontal billboard, stretched billboard, mesh particles, and **trails** (not available in Babylon's built-in particle systems).
20
- - **Sub-emitters** and a rich set of composable behaviors (color/size/speed over life, noise turbulence, forces, and more from `quarks.core`).
21
- - **Soft particles**, texture tile animation with blending, custom blend functions.
19
+ - **Render modes** — billboard, vertical/horizontal billboard, stretched billboard, mesh particles, **trails** and **beams** (not available in Babylon's built-in particle systems).
20
+ - **Sub-emitters** and a rich set of composable behaviors (color/size/speed over life, noise turbulence, forces, attractors, collision, and more from `quarks.core`).
21
+ - **Texture effects** — per-texture UV layout (UV channel, tiling, offset, scroll), gradient maps, alpha erosion, UV distortion, flip, texture tile animation with blending, soft particles, custom blend functions, rim lighting on mesh particles, smoothed trails with curve tension.
22
+ - **Trails** — texture modes (stretch, tile, per segment) with a texture scale, a minimum vertex distance and a lifetime (Unity's TrailRenderer settings), swept weapon trails along an emitter axis, world-space recording behind a moving emitter, and `clearTrails()` for teleports.
23
+ - **Scene integration** — render order and rendering groups, layer masks, fog, bounds and frustum culling with Unity's culling modes, sort modes, screen-size limits, and an `EffectPool` that plays one-shot effects without allocating.
22
24
  - **Visual authoring** — design effects in our own [effect editor](https://soullnik.github.io/babylon.quarks-standalone/editor.html) or export them from Unity, then load with `QuarksLoader` (quarks.art-exported JSON also works — same format).
23
25
  - **Cross-engine format** — the same effect JSON runs in three.js (three.quarks) and Babylon.js.
24
26
  - **Adaptive performance** — optional frame-budget quality scaling built into `BatchedRenderer`.
25
- - **WebGL and WebGPU** — runs on both Babylon engines; shaders are transpiled to WGSL automatically.
27
+ - **WebGL and WebGPU** — runs on both Babylon engines with native GLSL and WGSL shaders; nothing is transpiled or downloaded at run time.
26
28
 
27
29
  ## Install
28
30
 
@@ -30,7 +32,9 @@ High-performance particle system for [Babylon.js](https://www.babylonjs.com/). B
30
32
  npm install babylon.quarks @babylonjs/core
31
33
  ```
32
34
 
33
- Peer dependency: `@babylonjs/core` >= 9.
35
+ Peer dependency: `@babylonjs/core` 9.x. The package ships ES module and CommonJS builds;
36
+ `@babylonjs/core` is ES modules only, so `require('babylon.quarks')` needs a Node that can
37
+ `require` ES modules (20.19 or 22.12 and later). Bundlers and `import` work everywhere.
34
38
 
35
39
  ## Quick start
36
40
 
@@ -121,7 +125,7 @@ The same bundle works in any plain `<script>` setup alongside the global `babylo
121
125
 
122
126
  ## WebGPU
123
127
 
124
- The library runs on Babylon's `WebGPUEngine` — its GLSL shaders are transpiled to WGSL automatically by Babylon (glslang/twgsl are fetched by Babylon on engine init). Everything except engine creation stays the same:
128
+ The library runs on Babylon's `WebGPUEngine` with its own WGSL shaders: every GLSL shader has a WGSL twin that is picked when the engine is WebGPU, so Babylon never fetches a GLSL-to-WGSL transpiler (glslang/twgsl) for it, and a Content-Security-Policy that blocks `cdn.babylonjs.com` is no obstacle. Everything except engine creation stays the same:
125
129
 
126
130
  ```ts
127
131
  import {WebGPUEngine} from '@babylonjs/core/Engines/webgpuEngine';
@@ -132,7 +136,7 @@ await engine.initAsync();
132
136
  // Scene + BatchedRenderer setup is identical to WebGL.
133
137
  ```
134
138
 
135
- All render modes (billboard, stretched billboard, mesh, trail) are validated to create WebGPU pipelines with zero validation errors. The [live demos](https://soullnik.github.io/babylon.quarks-standalone/) and the [benchmark page](https://soullnik.github.io/babylon.quarks-standalone/benchmark.html) accept `?engine=webgpu` in the URL to switch engines.
139
+ Every render mode (billboard, stretched billboard, mesh, trail, beam) and every shader variant (`shaderVariants()`) compiles under a real GLSL and a real WGSL compiler with zero errors (`npm run validate:shaders` in the monorepo, run in CI). The [live demos](https://soullnik.github.io/babylon.quarks-standalone/) and the [benchmark page](https://soullnik.github.io/babylon.quarks-standalone/benchmark.html) accept `?engine=webgpu` in the URL to switch engines.
136
140
 
137
141
  ## Unity-style emitter options
138
142
 
@@ -140,7 +144,7 @@ A few optional settings mirror Shuriken so Unity exports look the same; all are
140
144
  only written to the effect JSON when set.
141
145
 
142
146
  ```ts
143
- import {ConeEmitter, Quaternion, ShapeTransform, Vector2, Vector3} from 'quarks.core';
147
+ import {ConeEmitter, Quaternion, ShapeTransform, Vector2, Vector3} from 'babylon.quarks';
144
148
 
145
149
  const system = new ParticleSystem({
146
150
  // Shape module Position / Rotation / Scale: spawn points and start directions go through it.
@@ -176,7 +180,7 @@ QuarksUtil.addToBatchRenderer(effect, batchRenderer);
176
180
  QuarksUtil.play(effect);
177
181
  ```
178
182
 
179
- See the [examples app](https://github.com/Soullnik/babylon.quarks-standalone/tree/main/examples) in the monorepo for 18 interactive demos and usage patterns.
183
+ See the [examples app](https://github.com/Soullnik/babylon.quarks-standalone/tree/main/examples) in the monorepo for 24 interactive demos and usage patterns.
180
184
 
181
185
  ## Links
182
186