babylon.quarks 0.18.1 → 0.20.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 +57 -0
- package/README.md +38 -16
- 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.ts +2121 -1157
- package/package.json +67 -67
- package/src/BatchedRenderer.ts +228 -15
- package/src/MeshSurfaceEmitter.ts +34 -23
- package/src/ParticleEmitter.ts +34 -10
- package/src/ParticleSystem.ts +558 -197
- package/src/QuarksLoader.ts +204 -18
- package/src/QuarksPrefab.ts +8 -11
- package/src/QuarksUtil.ts +1 -3
- package/src/SpriteBatch.ts +520 -98
- package/src/TrailBatch.ts +374 -166
- package/src/VFXBatch.ts +24 -5
- package/src/envAtlas.ts +136 -0
- package/src/index.ts +34 -29
- package/src/materials/ParticleMaterials.ts +1 -1
- package/src/shaders/index.ts +4 -4
- package/src/shaders/local_particle_physics_vert.wgsl.ts +81 -0
- package/src/shaders/particle_frag.wgsl.ts +64 -0
- package/src/shaders/particle_physics_frag.glsl.ts +56 -1
- package/src/shaders/particle_physics_frag.wgsl.ts +125 -0
- package/src/shaders/particle_vert.glsl.ts +20 -0
- package/src/shaders/particle_vert.wgsl.ts +107 -0
- package/src/shaders/shaderLanguageSupport.ts +54 -0
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +18 -5
- package/src/shaders/stretched_bb_particle_vert.wgsl.ts +101 -0
- package/src/shaders/trail_frag.wgsl.ts +23 -0
- package/src/shaders/trail_vert.wgsl.ts +63 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,63 @@ All notable changes to the `babylon.quarks` package are documented here.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
5
|
and the project follows the `quarks.core` 0.x version line.
|
|
6
6
|
|
|
7
|
+
## [0.20.0] — 2026-10-16
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `ParticleSystem.maxParticles` (optional, no limit when unset) caps how many particles a system
|
|
12
|
+
keeps alive, like Unity's Max Particles: emission past the cap is dropped rather than queued.
|
|
13
|
+
Saved in the effect JSON only when set.
|
|
14
|
+
- quarks.core `BoxEmitter` (`box`) emits from the volume, faces or edges of a box, with an
|
|
15
|
+
optional per-axis thickness, moving particles along +Z; a box with no depth is a flat rectangle.
|
|
16
|
+
`EdgeEmitter` (`edge`) emits from a line along X, moving particles along +Y. Both match the
|
|
17
|
+
Unity shapes of the same name.
|
|
18
|
+
|
|
19
|
+
- Trail settings `uvFromHead`, `colorFromParticle`, `dieWithParticle` and `recordWorldSpace`
|
|
20
|
+
(all optional, off by default) for trails that behave like Unity's: the texture runs from the
|
|
21
|
+
particle back to the tail, the whole trail takes the particle's current color, the trail
|
|
22
|
+
disappears the moment its particle dies, and a local-space system lays its trail points down in
|
|
23
|
+
world space so they streak behind a moving emitter. Saved in the effect JSON only when switched
|
|
24
|
+
on.
|
|
25
|
+
- Emitter shapes take an optional local `transform` (`ShapeTransform`: position, rotation
|
|
26
|
+
quaternion, scale) like the Position / Rotation / Scale of Unity's Shape module. The spawn point
|
|
27
|
+
goes through scale, rotation and offset, and the start direction through scale and rotation
|
|
28
|
+
without changing the start speed. Every `quarks.core` shape and `MeshSurfaceEmitter` support
|
|
29
|
+
it; the shape JSON gets a `transform` entry only when one is set.
|
|
30
|
+
- `ParticleSystem.pivot` (Unity's renderer Pivot): offsets billboard and stretched billboard quads
|
|
31
|
+
from their particle, in particle-size units. Billboards turn the offset with the particle and
|
|
32
|
+
move it toward the camera by z (up, for horizontal billboards); stretched billboards measure x
|
|
33
|
+
from head to tail and y across. Systems with different pivots batch separately; the shaders
|
|
34
|
+
only compile it in (`PIVOT`) when a pivot is set.
|
|
35
|
+
- `ParticleSystem.flip` (Unity's renderer Flip): the fraction of billboard and stretched billboard
|
|
36
|
+
particles whose texture is mirrored along U and V, picked per particle at birth.
|
|
37
|
+
- Both are saved in the effect JSON (`pivot: [x, y, z]`, `flip: [u, v]`) only when non-zero, and
|
|
38
|
+
carried by `clone()`.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- `QuarksLoader` shares one `Texture` per scene between every effect that uses the same image with
|
|
43
|
+
the same sampling, and one copy of identical mesh geometry. The renderer only batches systems
|
|
44
|
+
that share these objects, so each loaded effect used to get batches of its own: 661 Epic Toon
|
|
45
|
+
FX combat effects loaded together drew 2,577 batches, and draw 180 now. Turn it off per loader
|
|
46
|
+
with `shareResources: false`; `QuarksLoader.clearSharedResources(scene)` forgets the shared set.
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- `PiecewiseBezier` and `Gradient` (`quarks.core`) resampled their 257-point lookup tables on
|
|
51
|
+
every refresh, which runs every simulation step for every behavior using them. The "unchanged"
|
|
52
|
+
check compared the control points against a `Float32Array` copy, and any value float32 can't
|
|
53
|
+
hold exactly (0.2, 0.3, …) never compared equal. With such curves, 1,000 systems took 22.9 ms
|
|
54
|
+
per frame and now take 12.7 ms.
|
|
55
|
+
- An idle sprite batch uploaded its cleared instance (five or six vertex buffer updates) on every
|
|
56
|
+
frame; it now does so once each time it goes empty. Systems with no particles are skipped when
|
|
57
|
+
the batch is filled, and the emitter's matrix is only fully decomposed for local-space mesh
|
|
58
|
+
particles.
|
|
59
|
+
- A trail texture now reaches the end of the ribbon on frames that draw no live tip (with
|
|
60
|
+
`followLocalOrigin`, while paused, or exactly on a simulation step). The newest recorded sample
|
|
61
|
+
stopped one segment short of the texture's end, which cut the end of the texture off and made
|
|
62
|
+
it pop in and out as the tip came and went.
|
|
63
|
+
|
|
7
64
|
## [0.17.9] — 2026-07-14
|
|
8
65
|
|
|
9
66
|
### Fixed
|
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ High-performance particle system for [Babylon.js](https://www.babylonjs.com/). B
|
|
|
8
8
|
|
|
9
9
|
[**Live demos**](https://soullnik.github.io/babylon.quarks-standalone/)
|
|
10
10
|
|
|
11
|
-
|
|
|
12
|
-
|
|
13
|
-
| [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#MuzzleFlashDemo)
|
|
14
|
-
| [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#ElectricBallDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#BlackHoleDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#SoftParticleDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#LevelUpDemo)
|
|
11
|
+
| | | | |
|
|
12
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#MuzzleFlashDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#ExplosionDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#TrailDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#SubEmitterDemo) |
|
|
14
|
+
| [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#ElectricBallDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#BlackHoleDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#SoftParticleDemo) | [](https://soullnik.github.io/babylon.quarks-standalone/babylonDemo.html#LevelUpDemo) |
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
@@ -35,7 +35,7 @@ Peer dependency: `@babylonjs/core` >= 9.
|
|
|
35
35
|
## Quick start
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
|
-
import {Constants} from
|
|
38
|
+
import {Constants} from '@babylonjs/core/Engines/constants';
|
|
39
39
|
import {
|
|
40
40
|
BatchedRenderer,
|
|
41
41
|
ParticleSystem,
|
|
@@ -45,10 +45,10 @@ import {
|
|
|
45
45
|
IntervalValue,
|
|
46
46
|
ConstantColor,
|
|
47
47
|
Vector4,
|
|
48
|
-
} from
|
|
48
|
+
} from 'babylon.quarks';
|
|
49
49
|
|
|
50
50
|
// One renderer per scene; it batches all systems added to it.
|
|
51
|
-
const batchRenderer = new BatchedRenderer(
|
|
51
|
+
const batchRenderer = new BatchedRenderer('particles', scene);
|
|
52
52
|
|
|
53
53
|
const system = new ParticleSystem({
|
|
54
54
|
scene,
|
|
@@ -80,13 +80,13 @@ The package ships a UMD bundle (`dist/babylon.quarks.umd.min.js`, exposed as the
|
|
|
80
80
|
```js
|
|
81
81
|
var createScene = async function () {
|
|
82
82
|
var scene = new BABYLON.Scene(engine);
|
|
83
|
-
var camera = new BABYLON.ArcRotateCamera(
|
|
83
|
+
var camera = new BABYLON.ArcRotateCamera('cam', -Math.PI / 2, 1.2, 10, BABYLON.Vector3.Zero(), scene);
|
|
84
84
|
camera.attachControl(canvas, true);
|
|
85
85
|
|
|
86
|
-
await BABYLON.Tools.LoadScriptAsync(
|
|
86
|
+
await BABYLON.Tools.LoadScriptAsync('https://cdn.jsdelivr.net/npm/babylon.quarks/dist/babylon.quarks.umd.min.js');
|
|
87
87
|
const Q = BabylonQuarks;
|
|
88
88
|
|
|
89
|
-
const batchRenderer = new Q.BatchedRenderer(
|
|
89
|
+
const batchRenderer = new Q.BatchedRenderer('particles', scene);
|
|
90
90
|
const system = new Q.ParticleSystem({
|
|
91
91
|
scene,
|
|
92
92
|
duration: 5,
|
|
@@ -98,7 +98,7 @@ var createScene = async function () {
|
|
|
98
98
|
emissionOverTime: new Q.ConstantValue(60),
|
|
99
99
|
shape: new Q.ConeEmitter({radius: 0.3, angle: 0.4}),
|
|
100
100
|
renderMode: Q.RenderMode.BillBoard,
|
|
101
|
-
texture: new BABYLON.Texture(
|
|
101
|
+
texture: new BABYLON.Texture('textures/flare.png', scene),
|
|
102
102
|
transparent: true,
|
|
103
103
|
blendMode: BABYLON.Constants.ALPHA_ADD,
|
|
104
104
|
});
|
|
@@ -124,8 +124,8 @@ The same bundle works in any plain `<script>` setup alongside the global `babylo
|
|
|
124
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:
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
|
-
import {WebGPUEngine} from
|
|
128
|
-
import
|
|
127
|
+
import {WebGPUEngine} from '@babylonjs/core/Engines/webgpuEngine';
|
|
128
|
+
import '@babylonjs/core/Engines/WebGPU/Extensions/index';
|
|
129
129
|
|
|
130
130
|
const engine = new WebGPUEngine(canvas, {antialias: true});
|
|
131
131
|
await engine.initAsync();
|
|
@@ -134,6 +134,28 @@ await engine.initAsync();
|
|
|
134
134
|
|
|
135
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.
|
|
136
136
|
|
|
137
|
+
## Unity-style emitter options
|
|
138
|
+
|
|
139
|
+
A few optional settings mirror Shuriken so Unity exports look the same; all are off by default and
|
|
140
|
+
only written to the effect JSON when set.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import {ConeEmitter, Quaternion, ShapeTransform, Vector2, Vector3} from 'quarks.core';
|
|
144
|
+
|
|
145
|
+
const system = new ParticleSystem({
|
|
146
|
+
// Shape module Position / Rotation / Scale: spawn points and start directions go through it.
|
|
147
|
+
shape: new ConeEmitter({
|
|
148
|
+
radius: 0.5,
|
|
149
|
+
transform: new ShapeTransform(new Vector3(0, 1, 0), new Quaternion(), new Vector3(2, 1, 1)),
|
|
150
|
+
}),
|
|
151
|
+
// Renderer Pivot, in particle-size units (billboards and stretched billboards).
|
|
152
|
+
pivot: new Vector3(0, 0.5, 0),
|
|
153
|
+
// Renderer Flip: mirror the texture of 50% of particles along U.
|
|
154
|
+
flip: new Vector2(0.5, 0),
|
|
155
|
+
// ...
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
137
159
|
## Author & load effects
|
|
138
160
|
|
|
139
161
|
Design an effect with one of these tools, then load the exported JSON with `QuarksLoader`:
|
|
@@ -143,11 +165,11 @@ Design an effect with one of these tools, then load the exported JSON with `Quar
|
|
|
143
165
|
- **quarks.art** — effects exported from the [quarks.art](https://quarks.art/) editor also load fine, since it's the same JSON envelope.
|
|
144
166
|
|
|
145
167
|
```ts
|
|
146
|
-
import {BatchedRenderer, QuarksLoader, QuarksUtil} from
|
|
168
|
+
import {BatchedRenderer, QuarksLoader, QuarksUtil} from 'babylon.quarks';
|
|
147
169
|
|
|
148
|
-
const batchRenderer = new BatchedRenderer(
|
|
170
|
+
const batchRenderer = new BatchedRenderer('particles', scene);
|
|
149
171
|
const loader = new QuarksLoader(scene);
|
|
150
|
-
const effect = await loader.load(
|
|
172
|
+
const effect = await loader.load('effects/explosion.json');
|
|
151
173
|
QuarksUtil.addToBatchRenderer(effect, batchRenderer);
|
|
152
174
|
QuarksUtil.play(effect);
|
|
153
175
|
```
|