babylon.quarks 0.20.0 → 0.23.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 +105 -0
- package/README.md +2 -0
- 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 +523 -43
- package/package.json +1 -1
- package/src/BatchedRenderer.ts +59 -2
- package/src/ParticleSystem.ts +388 -59
- package/src/QuarksLoader.ts +381 -56
- package/src/SpriteBatch.ts +388 -111
- package/src/TrailBatch.ts +79 -63
- package/src/VFXBatch.ts +101 -0
- package/src/index.ts +9 -3
- package/src/shaders/particle_physics_frag.glsl.ts +26 -1
- package/src/shaders/particle_physics_frag.wgsl.ts +26 -1
package/package.json
CHANGED
package/src/BatchedRenderer.ts
CHANGED
|
@@ -6,7 +6,16 @@ import {EmitSubParticleSystem, IParticleSystem, Vector3} from 'quarks.core';
|
|
|
6
6
|
import {ParticleSystem} from './ParticleSystem';
|
|
7
7
|
import {SpriteBatch} from './SpriteBatch';
|
|
8
8
|
import {TrailBatch} from './TrailBatch';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
defaultMeshLighting,
|
|
11
|
+
MeshLighting,
|
|
12
|
+
MeshLightingSettings,
|
|
13
|
+
MeshRim,
|
|
14
|
+
meshRimEqual,
|
|
15
|
+
RenderMode,
|
|
16
|
+
StoredBatchSettings,
|
|
17
|
+
VFXBatch,
|
|
18
|
+
} from './VFXBatch';
|
|
10
19
|
|
|
11
20
|
export interface VFXBatchSettings {
|
|
12
21
|
instancingGeometry: Float32Array;
|
|
@@ -55,6 +64,13 @@ export interface VFXBatchSettings {
|
|
|
55
64
|
* y across, and z is unused. Absent or zero: no offset. Meshes ignore it.
|
|
56
65
|
*/
|
|
57
66
|
pivot?: Vector3;
|
|
67
|
+
/**
|
|
68
|
+
* How mesh particles are lit (`'unlit'`, `'fixed'` or `'scene'`); unset is
|
|
69
|
+
* `'fixed'`. See {@link MeshLighting}. Other render modes ignore it.
|
|
70
|
+
*/
|
|
71
|
+
lighting?: MeshLighting;
|
|
72
|
+
/** Rim (Fresnel) term on mesh particles; unset draws none. See {@link MeshRim}. */
|
|
73
|
+
rim?: MeshRim;
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
export interface AdaptivePerformanceOptions {
|
|
@@ -130,6 +146,7 @@ export class BatchedRenderer extends TransformNode {
|
|
|
130
146
|
lastFrameCpuMs: 0,
|
|
131
147
|
};
|
|
132
148
|
private lastAppliedQuality = Number.NaN;
|
|
149
|
+
private meshLighting: MeshLightingSettings = defaultMeshLighting();
|
|
133
150
|
|
|
134
151
|
constructor(name: string, scene: Scene) {
|
|
135
152
|
super(name, scene);
|
|
@@ -161,7 +178,9 @@ export class BatchedRenderer extends TransformNode {
|
|
|
161
178
|
a.instancingGeometry === b.instancingGeometry &&
|
|
162
179
|
a.renderOrder === b.renderOrder &&
|
|
163
180
|
a.layerMask === b.layerMask &&
|
|
164
|
-
pivotEqual(a.pivot, b.pivot)
|
|
181
|
+
pivotEqual(a.pivot, b.pivot) &&
|
|
182
|
+
(a.lighting ?? 'fixed') === (b.lighting ?? 'fixed') &&
|
|
183
|
+
meshRimEqual(a.rim, b.rim)
|
|
165
184
|
);
|
|
166
185
|
}
|
|
167
186
|
|
|
@@ -209,6 +228,7 @@ export class BatchedRenderer extends TransformNode {
|
|
|
209
228
|
if (this.depthTexture) {
|
|
210
229
|
batch.applyDepthTexture(this.depthTexture);
|
|
211
230
|
}
|
|
231
|
+
batch.applyMeshLighting(this.meshLighting);
|
|
212
232
|
batch.addSystem(system);
|
|
213
233
|
this.batches.push(batch);
|
|
214
234
|
this.batchEmptyFrames.push(0);
|
|
@@ -259,6 +279,43 @@ export class BatchedRenderer extends TransformNode {
|
|
|
259
279
|
}
|
|
260
280
|
}
|
|
261
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Sets the light mesh particles with `lighting: 'fixed'` (the default) are
|
|
284
|
+
* lit by, for every mesh batch of this renderer, including ones created
|
|
285
|
+
* later. Fields left out keep their current value. Also the fallback for
|
|
286
|
+
* `'scene'` lighting when the scene has no directional or hemispheric light.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* renderer.setMeshLighting({direction: new Vector3(-0.3, -1, 0.2), color: new Color3(1, 0.9, 0.75)});
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
setMeshLighting(lighting: Partial<MeshLightingSettings>): void {
|
|
294
|
+
const current = this.meshLighting;
|
|
295
|
+
if (lighting.direction) {
|
|
296
|
+
current.direction = lighting.direction.clone();
|
|
297
|
+
}
|
|
298
|
+
if (lighting.color) {
|
|
299
|
+
current.color = lighting.color.clone();
|
|
300
|
+
}
|
|
301
|
+
if (lighting.ambient) {
|
|
302
|
+
current.ambient = lighting.ambient.clone();
|
|
303
|
+
}
|
|
304
|
+
for (const batch of this.batches) {
|
|
305
|
+
batch.applyMeshLighting(current);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** A copy of the light set with {@link setMeshLighting}. */
|
|
310
|
+
getMeshLighting(): MeshLightingSettings {
|
|
311
|
+
const current = this.meshLighting;
|
|
312
|
+
return {
|
|
313
|
+
direction: current.direction.clone(),
|
|
314
|
+
color: current.color.clone(),
|
|
315
|
+
ambient: current.ambient.clone(),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
262
319
|
configureAdaptivePerformance(options: Partial<AdaptivePerformanceOptions> = {}) {
|
|
263
320
|
const state = this.adaptivePerformanceState;
|
|
264
321
|
const minQuality = BatchedRenderer.clamp(options.minQuality ?? state.minQuality, 0.05, 1);
|