babylon.quarks 0.24.1 → 0.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylon.quarks",
3
- "version": "0.24.1",
3
+ "version": "0.26.0",
4
4
  "description": "A High-Performance Particle System for Babylon.js",
5
5
  "type": "module",
6
6
  "types": "./dist/types/index.d.ts",
@@ -11,13 +11,22 @@ import {SpriteBatch} from './SpriteBatch';
11
11
  import {TrailBatch} from './TrailBatch';
12
12
  import {
13
13
  defaultMeshLighting,
14
+ erosionEqual,
15
+ gradientMapEqual,
16
+ mapUVEqual,
14
17
  MeshLighting,
15
18
  MeshLightingSettings,
16
19
  MeshRim,
17
20
  meshRimEqual,
21
+ ParticleErosion,
22
+ ParticleGradientMap,
23
+ ParticleUVDistortion,
24
+ readsUV1,
18
25
  RenderMode,
19
26
  SortMode,
20
27
  StoredBatchSettings,
28
+ TextureUV,
29
+ uvDistortionEqual,
21
30
  VFXBatch,
22
31
  } from './VFXBatch';
23
32
 
@@ -25,6 +34,8 @@ export interface VFXBatchSettings {
25
34
  instancingGeometry: Float32Array;
26
35
  instancingIndices: Uint32Array | Uint16Array;
27
36
  instancingUVs?: Float32Array;
37
+ /** The mesh's second UV set, see {@link UVChannel}. */
38
+ instancingUVs2?: Float32Array;
28
39
  instancingNormals?: Float32Array;
29
40
  renderMode: RenderMode;
30
41
  renderOrder: number;
@@ -100,6 +111,14 @@ export interface VFXBatchSettings {
100
111
  lighting?: MeshLighting;
101
112
  /** Rim (Fresnel) term on mesh particles; unset draws none. See {@link MeshRim}. */
102
113
  rim?: MeshRim;
114
+ /** How the main map is laid over the particle, see {@link TextureUV}. Unset: as drawn. Systems that differ are batched apart. */
115
+ mapUV?: TextureUV;
116
+ /** Colour ramp the map is recoloured through, see {@link ParticleGradientMap}. Unset: none. Systems that differ are batched apart. */
117
+ gradientMap?: ParticleGradientMap;
118
+ /** Map UV distortion by a noise texture, see {@link ParticleUVDistortion}. Unset: none. Systems that differ are batched apart. */
119
+ uvDistortion?: ParticleUVDistortion;
120
+ /** Alpha erosion (dissolve / wipe), see {@link ParticleErosion}. Unset: none. Systems that differ are batched apart. */
121
+ erosion?: ParticleErosion;
103
122
  }
104
123
 
105
124
  export interface AdaptivePerformanceOptions {
@@ -139,6 +158,8 @@ export interface AdaptivePerformanceState extends AdaptivePerformanceOptions {
139
158
 
140
159
  export class BatchedRenderer extends TransformNode {
141
160
  batches: Array<VFXBatch> = [];
161
+ /** Seconds this renderer has been updated for; the clock UV and erosion scrolling run on. */
162
+ private elapsed = 0;
142
163
  systemToBatchIndex: Map<IParticleSystem, number> = new Map<IParticleSystem, number>();
143
164
  depthTexture: BaseTexture | null = null;
144
165
  /** Systems in insertion order — iterated every frame, unlike the map. */
@@ -302,6 +323,11 @@ export class BatchedRenderer extends TransformNode {
302
323
  a.uTileCount === b.uTileCount &&
303
324
  a.vTileCount === b.vTileCount &&
304
325
  a.instancingGeometry === b.instancingGeometry &&
326
+ // Trails draw their own strip and read none of the instanced geometry's UVs.
327
+ (a.renderMode === RenderMode.Trail || a.instancingUVs === b.instancingUVs) &&
328
+ // Normals, and the second UV set when read, only matter to meshes.
329
+ (a.renderMode !== RenderMode.Mesh || a.instancingNormals === b.instancingNormals) &&
330
+ (a.renderMode !== RenderMode.Mesh || !readsUV1(a) || a.instancingUVs2 === b.instancingUVs2) &&
305
331
  a.renderOrder === b.renderOrder &&
306
332
  a.layerMask === b.layerMask &&
307
333
  a.renderingGroupId === b.renderingGroupId &&
@@ -311,7 +337,11 @@ export class BatchedRenderer extends TransformNode {
311
337
  a.minParticleSize === (b.minParticleSize ?? 0) &&
312
338
  a.maxParticleSize === (b.maxParticleSize ?? Infinity) &&
313
339
  (a.lighting ?? 'fixed') === (b.lighting ?? 'fixed') &&
314
- meshRimEqual(a.rim, b.rim)
340
+ meshRimEqual(a.rim, b.rim) &&
341
+ mapUVEqual(a.mapUV, b.mapUV) &&
342
+ uvDistortionEqual(a.uvDistortion, b.uvDistortion) &&
343
+ gradientMapEqual(a.gradientMap, b.gradientMap) &&
344
+ erosionEqual(a.erosion, b.erosion)
315
345
  );
316
346
  }
317
347
 
@@ -350,6 +380,7 @@ export class BatchedRenderer extends TransformNode {
350
380
  case RenderMode.VerticalBillBoard:
351
381
  case RenderMode.HorizontalBillBoard:
352
382
  case RenderMode.StretchedBillBoard:
383
+ case RenderMode.Beam:
353
384
  batch = new SpriteBatch(settings, scene);
354
385
  break;
355
386
  default:
@@ -543,6 +574,7 @@ export class BatchedRenderer extends TransformNode {
543
574
  }
544
575
 
545
576
  update(delta: number) {
577
+ this.elapsed += delta;
546
578
  const adaptiveState = this.adaptivePerformanceState;
547
579
  const frameStart = adaptiveState.enabled ? performance.now() : 0;
548
580
  if (adaptiveState.enabled) {
@@ -602,6 +634,7 @@ export class BatchedRenderer extends TransformNode {
602
634
  const emptyFrames = this.batchEmptyFrames;
603
635
  for (let i = 0; i < this.batches.length; i++) {
604
636
  const batch = this.batches[i];
637
+ batch.time = this.elapsed;
605
638
  if (batch.systems.size > 0) {
606
639
  emptyFrames[i] = 0;
607
640
  batch.update();