babylon.quarks 0.18.1 → 0.19.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/README.md +16 -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 +1834 -1181
- package/package.json +67 -67
- package/src/BatchedRenderer.ts +213 -14
- package/src/MeshSurfaceEmitter.ts +25 -20
- package/src/ParticleEmitter.ts +34 -10
- package/src/ParticleSystem.ts +436 -198
- package/src/QuarksLoader.ts +54 -14
- package/src/QuarksPrefab.ts +8 -11
- package/src/QuarksUtil.ts +1 -3
- package/src/SpriteBatch.ts +447 -96
- package/src/TrailBatch.ts +361 -164
- package/src/VFXBatch.ts +20 -4
- 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.wgsl.ts +87 -0
- package/src/shaders/shaderLanguageSupport.ts +54 -0
- package/src/shaders/stretched_bb_particle_vert.wgsl.ts +88 -0
- package/src/shaders/trail_frag.wgsl.ts +23 -0
- package/src/shaders/trail_vert.wgsl.ts +63 -0
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();
|
|
@@ -143,11 +143,11 @@ Design an effect with one of these tools, then load the exported JSON with `Quar
|
|
|
143
143
|
- **quarks.art** — effects exported from the [quarks.art](https://quarks.art/) editor also load fine, since it's the same JSON envelope.
|
|
144
144
|
|
|
145
145
|
```ts
|
|
146
|
-
import {BatchedRenderer, QuarksLoader, QuarksUtil} from
|
|
146
|
+
import {BatchedRenderer, QuarksLoader, QuarksUtil} from 'babylon.quarks';
|
|
147
147
|
|
|
148
|
-
const batchRenderer = new BatchedRenderer(
|
|
148
|
+
const batchRenderer = new BatchedRenderer('particles', scene);
|
|
149
149
|
const loader = new QuarksLoader(scene);
|
|
150
|
-
const effect = await loader.load(
|
|
150
|
+
const effect = await loader.load('effects/explosion.json');
|
|
151
151
|
QuarksUtil.addToBatchRenderer(effect, batchRenderer);
|
|
152
152
|
QuarksUtil.play(effect);
|
|
153
153
|
```
|