babylon.quarks 0.19.0 → 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 +22 -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 +324 -13
- package/package.json +1 -1
- package/src/BatchedRenderer.ts +16 -2
- package/src/MeshSurfaceEmitter.ts +10 -4
- package/src/ParticleSystem.ts +124 -1
- package/src/QuarksLoader.ts +150 -4
- package/src/SpriteBatch.ts +75 -4
- package/src/TrailBatch.ts +24 -13
- package/src/VFXBatch.ts +4 -1
- package/src/shaders/particle_vert.glsl.ts +20 -0
- package/src/shaders/particle_vert.wgsl.ts +21 -1
- package/src/shaders/stretched_bb_particle_vert.glsl.ts +18 -5
- package/src/shaders/stretched_bb_particle_vert.wgsl.ts +19 -6
package/dist/types/index.d.ts
CHANGED
|
@@ -640,7 +640,7 @@ declare class Gradient implements FunctionColorGenerator {
|
|
|
640
640
|
static readonly TABLE_SIZE = 257;
|
|
641
641
|
/** Sampled RGBA copy of the gradient, or null while none has been built. */
|
|
642
642
|
private table;
|
|
643
|
-
/** Keys the tables were built from, used to detect edits. */
|
|
643
|
+
/** Keys the tables were built from, used to detect edits. Float64 for the same reason as PiecewiseBezier's. */
|
|
644
644
|
private tableSignature;
|
|
645
645
|
/**
|
|
646
646
|
* Rebuilds the sampled table when the gradient changed, otherwise does
|
|
@@ -787,7 +787,11 @@ declare class PiecewiseBezier extends PiecewiseFunction<Bezier> implements Funct
|
|
|
787
787
|
* See {@link refreshTable}.
|
|
788
788
|
*/
|
|
789
789
|
private table;
|
|
790
|
-
/**
|
|
790
|
+
/**
|
|
791
|
+
* Control points the table was built from, used to detect edits. Float64 on purpose: the
|
|
792
|
+
* points are doubles, and a Float32Array rounds most of them (0.2, almost any exported value),
|
|
793
|
+
* so the comparison never matched and the table was resampled on every call.
|
|
794
|
+
*/
|
|
791
795
|
private tableSignature;
|
|
792
796
|
/**
|
|
793
797
|
* Rebuilds the sampled table when the curve changed, otherwise does nothing.
|
|
@@ -993,6 +997,31 @@ interface TrailSettings {
|
|
|
993
997
|
* @type {boolean}
|
|
994
998
|
*/
|
|
995
999
|
followLocalOrigin: boolean;
|
|
1000
|
+
/**
|
|
1001
|
+
* Run the texture's U from the particle (0) back to the tail (1), the way
|
|
1002
|
+
* Unity's stretched trails map it. Off, U runs from the tail to the particle.
|
|
1003
|
+
* @type {boolean}
|
|
1004
|
+
*/
|
|
1005
|
+
uvFromHead?: boolean;
|
|
1006
|
+
/**
|
|
1007
|
+
* Draw the whole trail in the particle's current color, as Unity's trails
|
|
1008
|
+
* do, instead of the color each sample had when it was recorded.
|
|
1009
|
+
* @type {boolean}
|
|
1010
|
+
*/
|
|
1011
|
+
colorFromParticle?: boolean;
|
|
1012
|
+
/**
|
|
1013
|
+
* Drop the trail the moment its particle dies, instead of letting it
|
|
1014
|
+
* shrink away one sample per step.
|
|
1015
|
+
* @type {boolean}
|
|
1016
|
+
*/
|
|
1017
|
+
dieWithParticle?: boolean;
|
|
1018
|
+
/**
|
|
1019
|
+
* Record trail points in world space even though the system simulates in
|
|
1020
|
+
* local space, so the trail streaks behind a moving emitter instead of
|
|
1021
|
+
* moving rigidly with it (Unity's Trails > World Space).
|
|
1022
|
+
* @type {boolean}
|
|
1023
|
+
*/
|
|
1024
|
+
recordWorldSpace?: boolean;
|
|
996
1025
|
}
|
|
997
1026
|
interface MeshSettings {
|
|
998
1027
|
/**
|
|
@@ -1105,6 +1134,12 @@ interface IParticleSystem {
|
|
|
1105
1134
|
* @type {BatchedRenderer}
|
|
1106
1135
|
*/
|
|
1107
1136
|
rendererEmitterSettings: RendererEmitterSettings;
|
|
1137
|
+
/**
|
|
1138
|
+
* Fraction of billboard particles mirrored along U (x) and V (y), each
|
|
1139
|
+
* picked at random when the particle is born — Unity's renderer Flip.
|
|
1140
|
+
* Absent: nothing is mirrored.
|
|
1141
|
+
*/
|
|
1142
|
+
flip?: Vector2;
|
|
1108
1143
|
emissionState: EmissionState;
|
|
1109
1144
|
paused: boolean;
|
|
1110
1145
|
/** True after `endEmit()` — emission window closed (non-looping duration elapsed). */
|
|
@@ -1431,6 +1466,12 @@ declare class SpriteParticle implements Particle {
|
|
|
1431
1466
|
* @type {number}
|
|
1432
1467
|
*/
|
|
1433
1468
|
uvTile: number;
|
|
1469
|
+
/**
|
|
1470
|
+
* Mirroring picked at birth from the system's `flip` fractions: bit 1
|
|
1471
|
+
* mirrors the sprite along U, bit 2 along V. 0 draws it as is.
|
|
1472
|
+
* @type {number}
|
|
1473
|
+
*/
|
|
1474
|
+
flip: number;
|
|
1434
1475
|
/**
|
|
1435
1476
|
* @param store - Column storage to bind to. A private single-row store is
|
|
1436
1477
|
* created when omitted, so a standalone `new SpriteParticle()` still works.
|
|
@@ -1890,13 +1931,13 @@ declare class ForceOverLife implements Behavior {
|
|
|
1890
1931
|
declare class FrameOverLife implements Behavior {
|
|
1891
1932
|
type: string;
|
|
1892
1933
|
private _frame;
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
set frame(frame: FunctionValueGenerator);
|
|
1934
|
+
constructor(frame: FunctionValueGenerator | ValueGenerator);
|
|
1935
|
+
get frame(): FunctionValueGenerator | ValueGenerator;
|
|
1936
|
+
set frame(frame: FunctionValueGenerator | ValueGenerator);
|
|
1897
1937
|
initialize(particle: Particle): void;
|
|
1898
1938
|
update(particle: Particle, delta: number): void;
|
|
1899
1939
|
updateAll(particles: Array<Particle>, count: number, delta: number): void;
|
|
1940
|
+
private sampleFrame;
|
|
1900
1941
|
frameUpdate(delta: number): void;
|
|
1901
1942
|
toJSON(): any;
|
|
1902
1943
|
static fromJSON(json: any): Behavior;
|
|
@@ -2261,6 +2302,44 @@ interface IPrefab {
|
|
|
2261
2302
|
animationData: IAnimationData[];
|
|
2262
2303
|
}
|
|
2263
2304
|
|
|
2305
|
+
interface ShapeTransformJSON {
|
|
2306
|
+
/** Offset of the shape, `[x, y, z]`. Omitted when zero. */
|
|
2307
|
+
position?: number[];
|
|
2308
|
+
/** Rotation of the shape as a quaternion, `[x, y, z, w]`. Omitted when identity. */
|
|
2309
|
+
rotation?: number[];
|
|
2310
|
+
/** Scale of the shape, `[x, y, z]`. Omitted when `[1, 1, 1]`. */
|
|
2311
|
+
scale?: number[];
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Local transform of an emitter shape inside its particle system, like the
|
|
2315
|
+
* Position / Rotation / Scale of Unity's Shape module.
|
|
2316
|
+
*
|
|
2317
|
+
* A spawn point `p` lands at `position + rotation * (scale * p)`. The start
|
|
2318
|
+
* direction goes through the same scale and rotation and is then brought back
|
|
2319
|
+
* to its old length, so a squashed shape bends directions without changing the
|
|
2320
|
+
* start speed — which is what Unity does.
|
|
2321
|
+
*/
|
|
2322
|
+
declare class ShapeTransform {
|
|
2323
|
+
position: Vector3;
|
|
2324
|
+
rotation: Quaternion;
|
|
2325
|
+
scale: Vector3;
|
|
2326
|
+
constructor(position?: Vector3, rotation?: Quaternion, scale?: Vector3);
|
|
2327
|
+
/** Moves a freshly initialized particle from shape space into system space. */
|
|
2328
|
+
apply(p: Particle): void;
|
|
2329
|
+
isIdentity(): boolean;
|
|
2330
|
+
toJSON(): ShapeTransformJSON;
|
|
2331
|
+
/** Returns undefined when there is no transform in the JSON. */
|
|
2332
|
+
static fromJSON(json: ShapeTransformJSON | undefined): ShapeTransform | undefined;
|
|
2333
|
+
/**
|
|
2334
|
+
* The `transform` entry of a shape's JSON: empty when the shape has no
|
|
2335
|
+
* transform or an identity one, so shapes without one serialize as before.
|
|
2336
|
+
*/
|
|
2337
|
+
static toShapeJSON(transform: ShapeTransform | undefined): {
|
|
2338
|
+
transform?: ShapeTransformJSON;
|
|
2339
|
+
};
|
|
2340
|
+
clone(): ShapeTransform;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2264
2343
|
interface ShapeJSON {
|
|
2265
2344
|
type: string;
|
|
2266
2345
|
radius?: number;
|
|
@@ -2270,6 +2349,9 @@ interface ShapeJSON {
|
|
|
2270
2349
|
angle?: number;
|
|
2271
2350
|
width?: number;
|
|
2272
2351
|
height?: number;
|
|
2352
|
+
depth?: number;
|
|
2353
|
+
emitFrom?: number;
|
|
2354
|
+
boxThickness?: number[];
|
|
2273
2355
|
column?: number;
|
|
2274
2356
|
row?: number;
|
|
2275
2357
|
mesh?: string;
|
|
@@ -2277,6 +2359,8 @@ interface ShapeJSON {
|
|
|
2277
2359
|
particleSystem?: string;
|
|
2278
2360
|
spread?: number;
|
|
2279
2361
|
speed?: any;
|
|
2362
|
+
/** Local offset / rotation / scale of the shape; omitted when there is none. */
|
|
2363
|
+
transform?: ShapeTransformJSON;
|
|
2280
2364
|
}
|
|
2281
2365
|
/**
|
|
2282
2366
|
* Enum representing the emitter modes for particles.
|
|
@@ -2306,6 +2390,66 @@ interface EmitterShape {
|
|
|
2306
2390
|
toJSON(): ShapeJSON;
|
|
2307
2391
|
update(system: IParticleSystem, delta: number): void;
|
|
2308
2392
|
clone(): EmitterShape;
|
|
2393
|
+
/**
|
|
2394
|
+
* Optional local transform of the shape inside its particle system, applied
|
|
2395
|
+
* by the shape itself at the end of {@link initialize}.
|
|
2396
|
+
*/
|
|
2397
|
+
transform?: ShapeTransform;
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
/**
|
|
2401
|
+
* Which part of the box particles start from.
|
|
2402
|
+
*/
|
|
2403
|
+
declare enum BoxEmitFrom {
|
|
2404
|
+
/** Anywhere inside the box. */
|
|
2405
|
+
Volume = 0,
|
|
2406
|
+
/** On the six faces. */
|
|
2407
|
+
Shell = 1,
|
|
2408
|
+
/** On the twelve edges. */
|
|
2409
|
+
Edge = 2
|
|
2410
|
+
}
|
|
2411
|
+
/**
|
|
2412
|
+
* Interface representing the parameters for a box emitter.
|
|
2413
|
+
*/
|
|
2414
|
+
interface BoxEmitterParameters {
|
|
2415
|
+
/** Size of the box along X. */
|
|
2416
|
+
width?: number;
|
|
2417
|
+
/** Size of the box along Y. */
|
|
2418
|
+
height?: number;
|
|
2419
|
+
/** Size of the box along Z. */
|
|
2420
|
+
depth?: number;
|
|
2421
|
+
/** Which part of the box particles start from. {@link BoxEmitFrom} */
|
|
2422
|
+
emitFrom?: BoxEmitFrom;
|
|
2423
|
+
/**
|
|
2424
|
+
* How far Shell and Edge particles may sink into the box on each axis, as a fraction of the
|
|
2425
|
+
* box size: 0 keeps them on the surface, 0.5 reaches the center.
|
|
2426
|
+
*/
|
|
2427
|
+
boxThickness?: [number, number, number];
|
|
2428
|
+
}
|
|
2429
|
+
/**
|
|
2430
|
+
* A particle emitter that emits particles from a box centered on the emitter, all moving along +Z
|
|
2431
|
+
* like Unity's Box shape. A box with no depth is a flat rectangle (Unity's Rectangle shape).
|
|
2432
|
+
*/
|
|
2433
|
+
declare class BoxEmitter implements EmitterShape {
|
|
2434
|
+
type: string;
|
|
2435
|
+
width: number;
|
|
2436
|
+
height: number;
|
|
2437
|
+
depth: number;
|
|
2438
|
+
emitFrom: BoxEmitFrom;
|
|
2439
|
+
boxThickness: [number, number, number];
|
|
2440
|
+
private readonly _point;
|
|
2441
|
+
constructor(parameters?: BoxEmitterParameters);
|
|
2442
|
+
update(_system: IParticleSystem, _delta: number): void;
|
|
2443
|
+
initialize(p: Particle, _emissionState: EmissionState): void;
|
|
2444
|
+
/**
|
|
2445
|
+
* A coordinate on one of the two faces across `axis`, in -1..1. As measured in Unity, a
|
|
2446
|
+
* thickness leaves half the particles on the face and sinks the rest evenly up to
|
|
2447
|
+
* 2 × thickness of the half-size into the box.
|
|
2448
|
+
*/
|
|
2449
|
+
private onSurface;
|
|
2450
|
+
toJSON(): ShapeJSON;
|
|
2451
|
+
static fromJSON(json: any): BoxEmitter;
|
|
2452
|
+
clone(): EmitterShape;
|
|
2309
2453
|
}
|
|
2310
2454
|
|
|
2311
2455
|
/**
|
|
@@ -2340,6 +2484,11 @@ interface CircleEmitterParameters {
|
|
|
2340
2484
|
* {@link EmitterMode}
|
|
2341
2485
|
*/
|
|
2342
2486
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2487
|
+
/**
|
|
2488
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2489
|
+
* {@link ShapeTransform}
|
|
2490
|
+
*/
|
|
2491
|
+
transform?: ShapeTransform;
|
|
2343
2492
|
}
|
|
2344
2493
|
/**
|
|
2345
2494
|
* a particle emitter that emits particles from a circle.
|
|
@@ -2353,6 +2502,7 @@ declare class CircleEmitter implements EmitterShape {
|
|
|
2353
2502
|
spread: number;
|
|
2354
2503
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2355
2504
|
memory: GeneratorMemory;
|
|
2505
|
+
transform?: ShapeTransform;
|
|
2356
2506
|
private currentValue;
|
|
2357
2507
|
constructor(parameters?: CircleEmitterParameters);
|
|
2358
2508
|
update(system: IParticleSystem, delta: number): void;
|
|
@@ -2397,6 +2547,11 @@ interface ConeEmitterParameters {
|
|
|
2397
2547
|
* {@link EmitterMode}
|
|
2398
2548
|
*/
|
|
2399
2549
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2550
|
+
/**
|
|
2551
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2552
|
+
* {@link ShapeTransform}
|
|
2553
|
+
*/
|
|
2554
|
+
transform?: ShapeTransform;
|
|
2400
2555
|
}
|
|
2401
2556
|
declare class ConeEmitter implements EmitterShape {
|
|
2402
2557
|
type: string;
|
|
@@ -2408,6 +2563,7 @@ declare class ConeEmitter implements EmitterShape {
|
|
|
2408
2563
|
spread: number;
|
|
2409
2564
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2410
2565
|
memory: GeneratorMemory;
|
|
2566
|
+
transform?: ShapeTransform;
|
|
2411
2567
|
private currentValue;
|
|
2412
2568
|
constructor(parameters?: ConeEmitterParameters);
|
|
2413
2569
|
update(system: IParticleSystem, delta: number): void;
|
|
@@ -2452,6 +2608,11 @@ interface DonutEmitterParameters {
|
|
|
2452
2608
|
* {@link EmitterMode}
|
|
2453
2609
|
*/
|
|
2454
2610
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2611
|
+
/**
|
|
2612
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2613
|
+
* {@link ShapeTransform}
|
|
2614
|
+
*/
|
|
2615
|
+
transform?: ShapeTransform;
|
|
2455
2616
|
}
|
|
2456
2617
|
declare class DonutEmitter implements EmitterShape {
|
|
2457
2618
|
type: string;
|
|
@@ -2463,6 +2624,7 @@ declare class DonutEmitter implements EmitterShape {
|
|
|
2463
2624
|
spread: number;
|
|
2464
2625
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2465
2626
|
memory: GeneratorMemory;
|
|
2627
|
+
transform?: ShapeTransform;
|
|
2466
2628
|
_m1: Matrix4;
|
|
2467
2629
|
constructor(parameters?: DonutEmitterParameters);
|
|
2468
2630
|
private currentValue;
|
|
@@ -2473,6 +2635,48 @@ declare class DonutEmitter implements EmitterShape {
|
|
|
2473
2635
|
clone(): EmitterShape;
|
|
2474
2636
|
}
|
|
2475
2637
|
|
|
2638
|
+
/**
|
|
2639
|
+
* Interface representing the parameters for an edge emitter.
|
|
2640
|
+
*/
|
|
2641
|
+
interface EdgeEmitterParameters {
|
|
2642
|
+
/** Half the length of the line: it runs from -radius to +radius along X. */
|
|
2643
|
+
radius?: number;
|
|
2644
|
+
/**
|
|
2645
|
+
* The mode of the emitter.
|
|
2646
|
+
* {@link EmitterMode}
|
|
2647
|
+
*/
|
|
2648
|
+
mode?: EmitterMode;
|
|
2649
|
+
/**
|
|
2650
|
+
* The length of the segment at which the emitter point converges at the start and end, when mode is EmitterMode.Loop or EmitterMode.PingPong.
|
|
2651
|
+
* {@link EmitterMode}
|
|
2652
|
+
*/
|
|
2653
|
+
spread?: number;
|
|
2654
|
+
/**
|
|
2655
|
+
* The speed of the emitter start point when mode is EmitterMode.Loop or EmitterMode.PingPong.
|
|
2656
|
+
* {@link EmitterMode}
|
|
2657
|
+
*/
|
|
2658
|
+
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2661
|
+
* A particle emitter that emits particles from a line along X, all moving along +Y like Unity's
|
|
2662
|
+
* single-sided Edge shape.
|
|
2663
|
+
*/
|
|
2664
|
+
declare class EdgeEmitter implements EmitterShape {
|
|
2665
|
+
type: string;
|
|
2666
|
+
radius: number;
|
|
2667
|
+
mode: EmitterMode;
|
|
2668
|
+
spread: number;
|
|
2669
|
+
speed: ValueGenerator | FunctionValueGenerator;
|
|
2670
|
+
memory: GeneratorMemory;
|
|
2671
|
+
private currentValue;
|
|
2672
|
+
constructor(parameters?: EdgeEmitterParameters);
|
|
2673
|
+
update(system: IParticleSystem, delta: number): void;
|
|
2674
|
+
initialize(p: Particle, emissionState: EmissionState): void;
|
|
2675
|
+
toJSON(): ShapeJSON;
|
|
2676
|
+
static fromJSON(json: any): EdgeEmitter;
|
|
2677
|
+
clone(): EmitterShape;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2476
2680
|
interface EmitterShapePlugin {
|
|
2477
2681
|
type: string;
|
|
2478
2682
|
constructor: Constructable<EmitterShape>;
|
|
@@ -2504,6 +2708,11 @@ interface GridEmitterParameters {
|
|
|
2504
2708
|
* The number of rows in the grid.
|
|
2505
2709
|
*/
|
|
2506
2710
|
row?: number;
|
|
2711
|
+
/**
|
|
2712
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2713
|
+
* {@link ShapeTransform}
|
|
2714
|
+
*/
|
|
2715
|
+
transform?: ShapeTransform;
|
|
2507
2716
|
}
|
|
2508
2717
|
declare class GridEmitter implements EmitterShape {
|
|
2509
2718
|
type: string;
|
|
@@ -2511,6 +2720,7 @@ declare class GridEmitter implements EmitterShape {
|
|
|
2511
2720
|
height: number;
|
|
2512
2721
|
column: number;
|
|
2513
2722
|
row: number;
|
|
2723
|
+
transform?: ShapeTransform;
|
|
2514
2724
|
constructor(parameters?: GridEmitterParameters);
|
|
2515
2725
|
initialize(p: Particle): void;
|
|
2516
2726
|
toJSON(): ShapeJSON;
|
|
@@ -2550,6 +2760,11 @@ interface HemisphereEmitterParameters {
|
|
|
2550
2760
|
* {@link EmitterMode}
|
|
2551
2761
|
*/
|
|
2552
2762
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2763
|
+
/**
|
|
2764
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2765
|
+
* {@link ShapeTransform}
|
|
2766
|
+
*/
|
|
2767
|
+
transform?: ShapeTransform;
|
|
2553
2768
|
}
|
|
2554
2769
|
declare class HemisphereEmitter implements EmitterShape {
|
|
2555
2770
|
type: string;
|
|
@@ -2560,6 +2775,7 @@ declare class HemisphereEmitter implements EmitterShape {
|
|
|
2560
2775
|
spread: number;
|
|
2561
2776
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2562
2777
|
memory: GeneratorMemory;
|
|
2778
|
+
transform?: ShapeTransform;
|
|
2563
2779
|
_m1: Matrix4;
|
|
2564
2780
|
constructor(parameters?: HemisphereEmitterParameters);
|
|
2565
2781
|
private currentValue;
|
|
@@ -2576,7 +2792,12 @@ declare class HemisphereEmitter implements EmitterShape {
|
|
|
2576
2792
|
declare class PointEmitter implements EmitterShape {
|
|
2577
2793
|
type: string;
|
|
2578
2794
|
_m1: Matrix4;
|
|
2579
|
-
|
|
2795
|
+
/**
|
|
2796
|
+
* Offset, rotation and scale of the point within the particle system.
|
|
2797
|
+
* {@link ShapeTransform}
|
|
2798
|
+
*/
|
|
2799
|
+
transform?: ShapeTransform;
|
|
2800
|
+
constructor(transform?: ShapeTransform);
|
|
2580
2801
|
update(system: IParticleSystem, delta: number): void;
|
|
2581
2802
|
initialize(p: Particle): void;
|
|
2582
2803
|
toJSON(): ShapeJSON;
|
|
@@ -2616,6 +2837,11 @@ interface RectangleEmitterParameters {
|
|
|
2616
2837
|
* {@link EmitterMode}
|
|
2617
2838
|
*/
|
|
2618
2839
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2840
|
+
/**
|
|
2841
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2842
|
+
* {@link ShapeTransform}
|
|
2843
|
+
*/
|
|
2844
|
+
transform?: ShapeTransform;
|
|
2619
2845
|
}
|
|
2620
2846
|
/**
|
|
2621
2847
|
* a particle emitter that emits particles from a rectangle.
|
|
@@ -2629,6 +2855,7 @@ declare class RectangleEmitter implements EmitterShape {
|
|
|
2629
2855
|
spread: number;
|
|
2630
2856
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2631
2857
|
memory: GeneratorMemory;
|
|
2858
|
+
transform?: ShapeTransform;
|
|
2632
2859
|
private currentValue;
|
|
2633
2860
|
private _m1;
|
|
2634
2861
|
constructor(parameters?: RectangleEmitterParameters);
|
|
@@ -2670,6 +2897,11 @@ interface SphereEmitterParameters {
|
|
|
2670
2897
|
* {@link EmitterMode}
|
|
2671
2898
|
*/
|
|
2672
2899
|
speed?: ValueGenerator | FunctionValueGenerator;
|
|
2900
|
+
/**
|
|
2901
|
+
* Offset, rotation and scale of the shape within the particle system.
|
|
2902
|
+
* {@link ShapeTransform}
|
|
2903
|
+
*/
|
|
2904
|
+
transform?: ShapeTransform;
|
|
2673
2905
|
}
|
|
2674
2906
|
declare class SphereEmitter implements EmitterShape {
|
|
2675
2907
|
type: string;
|
|
@@ -2680,6 +2912,7 @@ declare class SphereEmitter implements EmitterShape {
|
|
|
2680
2912
|
spread: number;
|
|
2681
2913
|
speed: ValueGenerator | FunctionValueGenerator;
|
|
2682
2914
|
memory: GeneratorMemory;
|
|
2915
|
+
transform?: ShapeTransform;
|
|
2683
2916
|
_m1: Matrix4;
|
|
2684
2917
|
constructor(parameters?: SphereEmitterParameters);
|
|
2685
2918
|
private currentValue;
|
|
@@ -2745,6 +2978,8 @@ interface StoredBatchSettings {
|
|
|
2745
2978
|
reflectionFaces: BaseTexture[] | null;
|
|
2746
2979
|
reflectionAtlas: BaseTexture | null;
|
|
2747
2980
|
layerMask: number;
|
|
2981
|
+
/** Billboard pivot in particle-size units, see {@link VFXBatchSettings.pivot}. */
|
|
2982
|
+
pivot?: Vector3;
|
|
2748
2983
|
}
|
|
2749
2984
|
declare abstract class VFXBatch {
|
|
2750
2985
|
mesh: Mesh;
|
|
@@ -2809,6 +3044,14 @@ interface VFXBatchSettings {
|
|
|
2809
3044
|
*/
|
|
2810
3045
|
reflectionAtlas: BaseTexture | null;
|
|
2811
3046
|
layerMask: number;
|
|
3047
|
+
/**
|
|
3048
|
+
* Offset of billboard quads from their particle, in particle-size units
|
|
3049
|
+
* (Unity's renderer Pivot). On billboards x/y move the quad in its own plane
|
|
3050
|
+
* before it is rotated and z moves it toward the camera (up for horizontal
|
|
3051
|
+
* billboards). On stretched billboards x runs from the head to the tail and
|
|
3052
|
+
* y across, and z is unused. Absent or zero: no offset. Meshes ignore it.
|
|
3053
|
+
*/
|
|
3054
|
+
pivot?: Vector3;
|
|
2812
3055
|
}
|
|
2813
3056
|
interface AdaptivePerformanceOptions {
|
|
2814
3057
|
targetFrameMs: number;
|
|
@@ -2934,9 +3177,11 @@ declare class MeshSurfaceEmitter implements EmitterShape {
|
|
|
2934
3177
|
private _positions?;
|
|
2935
3178
|
private _indices?;
|
|
2936
3179
|
private _meshReferenceId?;
|
|
3180
|
+
/** Offset, rotation and scale of the mesh within the particle system. */
|
|
3181
|
+
transform?: ShapeTransform;
|
|
2937
3182
|
get mesh(): Mesh | undefined;
|
|
2938
3183
|
set mesh(mesh: Mesh | undefined);
|
|
2939
|
-
constructor(mesh?: Mesh, meshReferenceId?: string);
|
|
3184
|
+
constructor(mesh?: Mesh, meshReferenceId?: string, transform?: ShapeTransform);
|
|
2940
3185
|
initialize(p: Particle): void;
|
|
2941
3186
|
toJSON(): ShapeJSON;
|
|
2942
3187
|
static fromJSON(json: any): MeshSurfaceEmitter;
|
|
@@ -2988,6 +3233,8 @@ interface ParticleSystemParameters {
|
|
|
2988
3233
|
emissionOverTime?: ValueGenerator | FunctionValueGenerator;
|
|
2989
3234
|
emissionOverDistance?: ValueGenerator | FunctionValueGenerator;
|
|
2990
3235
|
emissionBursts?: Array<BurstParameters>;
|
|
3236
|
+
/** Most particles alive at once; emission past it is dropped. Leave unset for no limit. */
|
|
3237
|
+
maxParticles?: number;
|
|
2991
3238
|
onlyUsedByOther?: boolean;
|
|
2992
3239
|
behaviors?: Array<Behavior>;
|
|
2993
3240
|
instancingGeometry?: Float32Array;
|
|
@@ -3014,6 +3261,10 @@ interface ParticleSystemParameters {
|
|
|
3014
3261
|
depthWrite?: boolean;
|
|
3015
3262
|
alphaTest?: number;
|
|
3016
3263
|
layerMask?: number;
|
|
3264
|
+
/** Billboard pivot in particle-size units, see {@link VFXBatchSettings.pivot}. */
|
|
3265
|
+
pivot?: Vector3;
|
|
3266
|
+
/** Fraction of billboard particles mirrored along U (x) and V (y), see {@link ParticleSystem.flip}. */
|
|
3267
|
+
flip?: Vector2;
|
|
3017
3268
|
scene?: Scene;
|
|
3018
3269
|
}
|
|
3019
3270
|
interface BurstParametersJSON {
|
|
@@ -3039,6 +3290,7 @@ interface ParticleSystemJSONParameters {
|
|
|
3039
3290
|
emissionOverTime: FunctionJSON;
|
|
3040
3291
|
emissionOverDistance: FunctionJSON;
|
|
3041
3292
|
emissionBursts?: Array<BurstParametersJSON>;
|
|
3293
|
+
maxParticles?: number;
|
|
3042
3294
|
onlyUsedByOther: boolean;
|
|
3043
3295
|
rendererEmitterSettings: RendererEmitterSettings;
|
|
3044
3296
|
instancingGeometry?: any;
|
|
@@ -3062,6 +3314,10 @@ interface ParticleSystemJSONParameters {
|
|
|
3062
3314
|
alphaTest?: number;
|
|
3063
3315
|
behaviors: Array<any>;
|
|
3064
3316
|
worldSpace: boolean;
|
|
3317
|
+
/** `[x, y, z]`; written only when non-zero. */
|
|
3318
|
+
pivot?: number[];
|
|
3319
|
+
/** `[u, v]`; written only when non-zero. */
|
|
3320
|
+
flip?: number[];
|
|
3065
3321
|
}
|
|
3066
3322
|
interface BabylonMetaData {
|
|
3067
3323
|
textures: {
|
|
@@ -3103,9 +3359,17 @@ declare class ParticleSystem implements IParticleSystem {
|
|
|
3103
3359
|
startColor: ColorGenerator | FunctionColorGenerator;
|
|
3104
3360
|
startTileIndex: ValueGenerator;
|
|
3105
3361
|
rendererEmitterSettings: RendererEmitterSettings;
|
|
3362
|
+
/**
|
|
3363
|
+
* Fraction of billboard particles mirrored along U (x) and V (y), each
|
|
3364
|
+
* picked at random when the particle is born — Unity's renderer Flip.
|
|
3365
|
+
* Undefined: nothing is mirrored. Meshes ignore it.
|
|
3366
|
+
*/
|
|
3367
|
+
flip?: Vector2;
|
|
3106
3368
|
emissionOverTime: ValueGenerator | FunctionValueGenerator;
|
|
3107
3369
|
emissionOverDistance: ValueGenerator | FunctionValueGenerator;
|
|
3108
3370
|
emissionBursts: Array<BurstParameters>;
|
|
3371
|
+
/** Most particles alive at once (Unity's Max Particles); emission past it is dropped. Undefined means no limit. */
|
|
3372
|
+
maxParticles?: number;
|
|
3109
3373
|
onlyUsedByOther: boolean;
|
|
3110
3374
|
worldSpace: boolean;
|
|
3111
3375
|
particleNum: number;
|
|
@@ -3164,6 +3428,15 @@ declare class ParticleSystem implements IParticleSystem {
|
|
|
3164
3428
|
set blendTiles(v: boolean);
|
|
3165
3429
|
get softParticles(): boolean;
|
|
3166
3430
|
set softParticles(v: boolean);
|
|
3431
|
+
/**
|
|
3432
|
+
* Billboard pivot in particle-size units (Unity's renderer Pivot), see
|
|
3433
|
+
* {@link VFXBatchSettings.pivot}. Assign a new vector to change it: editing
|
|
3434
|
+
* the returned one in place does not reach the renderer.
|
|
3435
|
+
*/
|
|
3436
|
+
get pivot(): Vector3 | undefined;
|
|
3437
|
+
set pivot(v: Vector3 | undefined);
|
|
3438
|
+
private static nonZeroPivot;
|
|
3439
|
+
private static nonZeroFlip;
|
|
3167
3440
|
get softNearFade(): number;
|
|
3168
3441
|
set softNearFade(v: number);
|
|
3169
3442
|
get softFarFade(): number;
|
|
@@ -3264,14 +3537,40 @@ declare class ParticleSystem implements IParticleSystem {
|
|
|
3264
3537
|
|
|
3265
3538
|
interface QuarksLoaderOptions {
|
|
3266
3539
|
baseUrl?: string;
|
|
3540
|
+
/**
|
|
3541
|
+
* Reuse one Texture per scene for every effect that references the same image with the same
|
|
3542
|
+
* sampling, and one copy of the data for identical mesh geometry. The renderer only batches
|
|
3543
|
+
* systems that share the texture (and geometry) object, so without this every loaded effect
|
|
3544
|
+
* gets batches — draw calls and buffer uploads — of its own even when its images are the same
|
|
3545
|
+
* as another effect's. Default true; turn off to give each effect private textures, e.g. to
|
|
3546
|
+
* change one effect's texture settings without touching the others.
|
|
3547
|
+
*/
|
|
3548
|
+
shareResources?: boolean;
|
|
3267
3549
|
}
|
|
3268
3550
|
declare class QuarksLoader {
|
|
3269
3551
|
private scene;
|
|
3270
3552
|
private options;
|
|
3271
3553
|
constructor(scene: Scene, options?: QuarksLoaderOptions);
|
|
3272
3554
|
load(url: string): Promise<TransformNode>;
|
|
3555
|
+
/**
|
|
3556
|
+
* Inlines geometries that an export wrote to their own file (`{uuid, type: 'QuarksGeometry',
|
|
3557
|
+
* url}` — e.g. the Unity exporter's "geometries as files"): each `url` is passed to
|
|
3558
|
+
* `loadGeometry`, and the `positions / indices / uvs / normals` it returns replace the url in
|
|
3559
|
+
* place, so `parse()` (which is synchronous) sees an ordinary inline geometry. `load()` does
|
|
3560
|
+
* this with `fetch`; call it yourself before `parse()` when the files come from elsewhere.
|
|
3561
|
+
* A geometry that fails to load is left as is and warned about.
|
|
3562
|
+
*/
|
|
3563
|
+
static resolveExternalGeometries(json: any, loadGeometry: (url: string) => Promise<any>): Promise<void>;
|
|
3273
3564
|
parse(json: any, baseUrl?: string): TransformNode;
|
|
3274
3565
|
private parseGeometries;
|
|
3566
|
+
/** The scene's copy of an identical geometry when resources are shared, else `geometry` itself. */
|
|
3567
|
+
private share;
|
|
3568
|
+
/**
|
|
3569
|
+
* Forgets the textures and geometries shared between loads into `scene` (see
|
|
3570
|
+
* {@link QuarksLoaderOptions.shareResources}). Effects already loaded keep theirs; the next
|
|
3571
|
+
* load creates new ones. Textures are not disposed — they may still be in use.
|
|
3572
|
+
*/
|
|
3573
|
+
static clearSharedResources(scene: Scene): void;
|
|
3275
3574
|
private parseSphereGeometry;
|
|
3276
3575
|
private parseBufferGeometry;
|
|
3277
3576
|
private extractInterleavedAttribute;
|
|
@@ -3293,7 +3592,7 @@ declare class QuarksLoader {
|
|
|
3293
3592
|
* babylon.quarks-editor). Prepending baseUrl to those turns e.g.
|
|
3294
3593
|
* "data:image/png;base64,AAAA" into an invalid path like "/some/dir/data:image/png;base64,AAAA".
|
|
3295
3594
|
*/
|
|
3296
|
-
private
|
|
3595
|
+
private static resolveUrl;
|
|
3297
3596
|
private parseTextures;
|
|
3298
3597
|
private mapWrapMode;
|
|
3299
3598
|
private parseMaterials;
|
|
@@ -3375,9 +3674,9 @@ declare const _default$5: "\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef T
|
|
|
3375
3674
|
|
|
3376
3675
|
declare const _default$4: "\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\nvarying vec3 vWorldPos;\n\nuniform vec3 lightDirection;\nuniform vec3 lightColor;\nuniform vec3 ambientColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n// One 3\u00D72 atlas (px py pz / nx ny nz). Avoids samplerCube and multi-face\n// sampler bindings that raise GL_INVALID_OPERATION on iOS WebKit.\n#ifdef USE_ENVMAP_ATLAS\nuniform sampler2D envAtlas;\nuniform vec3 eyePosition;\nuniform float reflectionLevel;\n\nvec3 sampleEnvAtlas(vec3 r) {\n vec3 a = abs(r);\n vec2 localUV;\n float cellX;\n float cellY;\n // Atlas layout: +X +Y +Z on row 0, -X -Y -Z on row 1.\n if (a.x >= a.y && a.x >= a.z) {\n cellX = 0.0;\n if (r.x >= 0.0) {\n cellY = 0.0;\n localUV = vec2(-r.z, -r.y) / a.x * 0.5 + 0.5;\n } else {\n cellY = 1.0;\n localUV = vec2(r.z, -r.y) / a.x * 0.5 + 0.5;\n }\n } else if (a.y >= a.z) {\n cellX = 1.0;\n if (r.y >= 0.0) {\n cellY = 0.0;\n localUV = vec2(r.x, r.z) / a.y * 0.5 + 0.5;\n } else {\n cellY = 1.0;\n localUV = vec2(r.x, -r.z) / a.y * 0.5 + 0.5;\n }\n } else {\n cellX = 2.0;\n if (r.z >= 0.0) {\n cellY = 0.0;\n localUV = vec2(r.x, -r.y) / a.z * 0.5 + 0.5;\n } else {\n cellY = 1.0;\n localUV = vec2(-r.x, -r.y) / a.z * 0.5 + 0.5;\n }\n }\n vec2 uv = (vec2(cellX, cellY) + clamp(localUV, 0.0, 1.0)) / vec2(3.0, 2.0);\n return texture2D(envAtlas, uv).rgb;\n}\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n vec3 N = normalize(vNormal);\n vec3 L = normalize(-lightDirection);\n float NdotL = max(dot(N, L), 0.0);\n vec3 litColor = ambientColor + lightColor * NdotL;\n\n vec3 color = baseColor.rgb * litColor;\n\n#ifdef USE_ENVMAP_ATLAS\n vec3 viewDir = normalize(vWorldPos - eyePosition);\n vec3 reflectionCoords = reflect(viewDir, N);\n color += sampleEnvAtlas(reflectionCoords) * reflectionLevel;\n#endif\n\n gl_FragColor = vec4(color, baseColor.a);\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n";
|
|
3377
3676
|
|
|
3378
|
-
declare const _default$3: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float c = cos(rotation);\n float s = sin(rotation);\n\n vec2 alignedPosition = position.xy * size.xy;\n vec2 rotatedPosition;\n rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;\n rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;\n\n#ifdef HORIZONTAL\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n mvPosition = view * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.y += rotatedPosition.y;\n mvPosition = view * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n mvPosition.xy += rotatedPosition;\n#endif\n\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n";
|
|
3677
|
+
declare const _default$3: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n#ifdef PIVOT\n// Quad offset in particle-size units: xy in the quad's plane, z toward the camera.\nuniform vec3 pivot;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float c = cos(rotation);\n float s = sin(rotation);\n\n // A negative size mirrors the quad, which is how flipped particles arrive.\n vec2 alignedPosition = position.xy * size.xy;\n#ifdef PIVOT\n // The pivot turns with the particle but is not mirrored with it.\n alignedPosition += pivot.xy * abs(size.xy);\n#endif\n vec2 rotatedPosition;\n rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;\n rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;\n\n#ifdef HORIZONTAL\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n#ifdef PIVOT\n mvPosition.y += pivot.z * abs(size.x);\n#endif\n mvPosition = view * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.y += rotatedPosition.y;\n mvPosition = view * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n mvPosition.xy += rotatedPosition;\n#endif\n#ifdef PIVOT\n#ifndef HORIZONTAL\n // Toward the camera along its view axis, whichever way the view space\n // faces: anything in front of the camera has the sign of the far side.\n mvPosition.z -= sign(mvPosition.z) * pivot.z * abs(size.x);\n#endif\n#endif\n\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n";
|
|
3379
3678
|
|
|
3380
|
-
declare const _default$2: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\nattribute vec4 velocity;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float speedFactor;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n vec3 viewVelocity = mat3(view * world) * velocity.xyz;\n float vlength = length(viewVelocity);\n // Stretch direction is the velocity direction; only a genuinely motionless particle has none.\n // Deriving it via normalize keeps the stretch aligned even when the speed contribution is ~0\n // (e.g. speedFactor 0), instead of collapsing the whole burst onto a fixed screen axis.\n vec3 vdir = vlength > 0.000001 ? viewVelocity / vlength : vec3(0.0, 0.0, 1.0);\n
|
|
3679
|
+
declare const _default$2: "\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\nattribute vec4 velocity;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float speedFactor;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n#ifdef PIVOT\n// Streak offset in particle-size units: x from head to tail, y across.\nuniform vec3 pivot;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float lengthFactor = velocity.w;\n // A flipped particle arrives with a negative size: the streak keeps its\n // extent and mirrors its texture instead (see quadUV below).\n float avgSize = (abs(size.x) + abs(size.y)) * 0.5;\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n vec3 viewVelocity = mat3(view * world) * velocity.xyz;\n float vlength = length(viewVelocity);\n // Stretch direction is the velocity direction; only a genuinely motionless particle has none.\n // Deriving it via normalize keeps the stretch aligned even when the speed contribution is ~0\n // (e.g. speedFactor 0), instead of collapsing the whole burst onto a fixed screen axis.\n vec3 vdir = vlength > 0.000001 ? viewVelocity / vlength : vec3(0.0, 0.0, 1.0);\n vec3 side = normalize(cross(mvPosition.xyz, vdir));\n mvPosition.xyz += position.y * side * avgSize;\n // Equivalent to viewVelocity * (1.0 + lengthFactor / vlength) for moving particles, but the\n // size-based term (vdir * lengthFactor) survives when the velocity contribution vanishes.\n mvPosition.xyz -= (position.x + 0.5) * (viewVelocity + vdir * lengthFactor) * avgSize;\n#ifdef PIVOT\n // In particle-size units along the quad's own axes: x from head to tail, y across.\n mvPosition.xyz += (pivot.y * side - pivot.x * vdir) * avgSize;\n#endif\n gl_Position = projection * mvPosition;\n vec2 quadUV = vec2(size.x < 0.0 ? 1.0 - uv.x : uv.x, size.y < 0.0 ? 1.0 - uv.y : uv.y);\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = quadUV / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = quadUV / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = quadUV;\n #endif\n\n vColor = color;\n}\n";
|
|
3381
3680
|
|
|
3382
3681
|
declare const _default$1: "\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n baseColor *= texColor;\n#endif\n\n if (baseColor.a < 0.01) discard;\n\n gl_FragColor = baseColor;\n}\n";
|
|
3383
3682
|
|
|
@@ -3419,6 +3718,8 @@ declare class SpriteBatch extends VFXBatch {
|
|
|
3419
3718
|
private rotationMat_;
|
|
3420
3719
|
private rotationMat2_;
|
|
3421
3720
|
private lastStretchedSpeedFactor;
|
|
3721
|
+
/** Slot 0 holds the zero-alpha instance since the batch last went empty. */
|
|
3722
|
+
private clearedInstanceUploaded;
|
|
3422
3723
|
update(): void;
|
|
3423
3724
|
/**
|
|
3424
3725
|
* Pushes the stretched-billboard speed factor to the shader when it changed.
|
|
@@ -3429,6 +3730,16 @@ declare class SpriteBatch extends VFXBatch {
|
|
|
3429
3730
|
* optimised code on every frame.
|
|
3430
3731
|
*/
|
|
3431
3732
|
private syncStretchedSpeedFactor;
|
|
3733
|
+
/** The quads that take a pivot and flip: every billboard kind, stretched included, but not meshes. */
|
|
3734
|
+
private static takesPivotAndFlip;
|
|
3735
|
+
/**
|
|
3736
|
+
* Negates the size of each flipped particle along the axes it flips on,
|
|
3737
|
+
* starting at `base` in `sizes`. The billboard shader scales the quad by
|
|
3738
|
+
* the size, so a negative one mirrors it — and with it the texture, the
|
|
3739
|
+
* quad being centred — the way Unity's renderer Flip mirrors U and V. The
|
|
3740
|
+
* stretched shader reads the sign and mirrors the texture coordinates.
|
|
3741
|
+
*/
|
|
3742
|
+
private static applyFlip;
|
|
3432
3743
|
/**
|
|
3433
3744
|
* The fraction `f` of a turn, as a normalised lerp from no rotation toward
|
|
3434
3745
|
* `step`, written into `out`.
|
|
@@ -3516,5 +3827,5 @@ declare class TrailBatch extends VFXBatch {
|
|
|
3516
3827
|
dispose(): void;
|
|
3517
3828
|
}
|
|
3518
3829
|
|
|
3519
|
-
export { ApplyCollision, ApplyForce, ApplySequences, AxisAngleGenerator, BatchedParticleRenderer, BatchedRenderer, BehaviorFromJSON, BehaviorTypes, Bezier, ChangeEmitDirection, CircleEmitter, ColorBySpeed, ColorGeneratorFromJSON, ColorOverLife, ColorRange, ConeEmitter, ConstantColor, ConstantValue, DEG2RAD, DonutEmitter, EmitSubParticleSystem, EmitterFromJSON, EmitterMode, EmitterShapes, Euler, EulerGenerator, ForceOverLife, FrameOverLife, GeneratorFromJSON, Gradient, GravityForce, GridEmitter, HemisphereEmitter, InheritVelocity, IntervalValue, LimitSpeedOverLife, MathUtils, Matrix3, Matrix4, MeshSurfaceEmitter, MeshSurfaceEmitterPlugin, NodeParticle, Noise, OrbitOverLife, ParticleEmitter, ParticleMeshPhysicsMaterial, ParticleMeshStandardMaterial, ParticleStore, ParticleSystem, PiecewiseBezier, PiecewiseFunction, Plugins, PointEmitter, QuarksLoader, QuarksPrefab, QuarksUtil, Quaternion, RAD2DEG, RandomColor, RandomColorBetweenGradient, RandomQuatGenerator, RecordState, RectangleEmitter, RenderMode, Rotation3DOverLife, RotationBySpeed, RotationGeneratorFromJSON, RotationOverLife, SequencerFromJSON, SizeBySpeed, SizeOverLife, SpeedOverLife, SphereEmitter, SpriteBatch, SpriteParticle, SubParticleEmitMode, TextureSequencer, TrailBatch, TrailParticle, TurbulenceField, VFXBatch, ValueGeneratorFromJSON, Vector2, Vector3, Vector3Function, Vector3GeneratorFromJSON, Vector3View, Vector4, Vector4View, VelocityOverLife, WebGLCoordinateSystem, WebGPUCoordinateSystem, WidthOverLength, cacheEnvAtlas, ceilPowerOfTwo, clamp, createEnvAtlasFromFaceUrls, cubeFaceUrls, damp, degToRad, denormalize, ensureEnvAtlasFromCube, euclideanModulo, floorPowerOfTwo, generateUUID, getCachedEnvAtlas, getPhysicsResolver, getRegisteredShaderChunks, getShaderChunk, getValueFromEmitterMode, inverseLerp, isPowerOfTwo, lerp, loadPlugin, _default$7 as localParticlePhysicsVertShader, _default$6 as localParticleVertShader, mapLinear, normalize, _default$5 as particleFragShader, _default$4 as particlePhysicsFragShader, _default$3 as particleVertShader, pingpong, planBehaviorFusion, radToDeg, randFloat, randFloatSpread, randInt, registerShaderChunks, seededRandom, setPhysicsResolver, setQuaternionFromProperEuler, smootherstep, smoothstep, _default$2 as stretchedBillboardVertShader, _default$1 as trailFragShader, _default as trailVertShader, unloadPlugin };
|
|
3520
|
-
export type { AdaptivePerformanceOptions, AdaptivePerformanceState, AnimationData, BabylonMetaData, BabylonParticleMaterialParameters, Behavior, BehaviorPlugin, BillBoardSettings, BurstParameters, BurstParametersJSON, CircleEmitterParameters, ColorGenerator, ConeEmitterParameters, Constructable, DonutEmitterParameters, EmissionState, EmitterShape, EmitterShapePlugin, EulerOrder, FieldType, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, FusedPass, FusionStep, GeneratorMemory, GridEmitterParameters, HemisphereEmitterParameters, IAnimationData, IEmitter, IParticle, IParticleSystem, IPrefab, InheritVelocityMode, JsonMetaData, MeshSettings, ParameterPair, ParameterType, Particle, ParticleSystemEvent, ParticleSystemEventType, ParticleSystemJSONParameters, ParticleSystemParameters, Plugin, QuarksLoaderOptions, QuarksTimelineClip, RectangleEmitterParameters, RendererEmitterSettings, Resource, RotationGenerator, Sequencer, SerializationOptions, ShapeJSON, SphereEmitterParameters, StoredBatchSettings, StretchedBillBoardSettings, TrailSettings, VFXBatchSettings, ValueGenerator, Vector3Generator, VelocityOverLifeSpace };
|
|
3830
|
+
export { ApplyCollision, ApplyForce, ApplySequences, AxisAngleGenerator, BatchedParticleRenderer, BatchedRenderer, BehaviorFromJSON, BehaviorTypes, Bezier, BoxEmitFrom, BoxEmitter, ChangeEmitDirection, CircleEmitter, ColorBySpeed, ColorGeneratorFromJSON, ColorOverLife, ColorRange, ConeEmitter, ConstantColor, ConstantValue, DEG2RAD, DonutEmitter, EdgeEmitter, EmitSubParticleSystem, EmitterFromJSON, EmitterMode, EmitterShapes, Euler, EulerGenerator, ForceOverLife, FrameOverLife, GeneratorFromJSON, Gradient, GravityForce, GridEmitter, HemisphereEmitter, InheritVelocity, IntervalValue, LimitSpeedOverLife, MathUtils, Matrix3, Matrix4, MeshSurfaceEmitter, MeshSurfaceEmitterPlugin, NodeParticle, Noise, OrbitOverLife, ParticleEmitter, ParticleMeshPhysicsMaterial, ParticleMeshStandardMaterial, ParticleStore, ParticleSystem, PiecewiseBezier, PiecewiseFunction, Plugins, PointEmitter, QuarksLoader, QuarksPrefab, QuarksUtil, Quaternion, RAD2DEG, RandomColor, RandomColorBetweenGradient, RandomQuatGenerator, RecordState, RectangleEmitter, RenderMode, Rotation3DOverLife, RotationBySpeed, RotationGeneratorFromJSON, RotationOverLife, SequencerFromJSON, ShapeTransform, SizeBySpeed, SizeOverLife, SpeedOverLife, SphereEmitter, SpriteBatch, SpriteParticle, SubParticleEmitMode, TextureSequencer, TrailBatch, TrailParticle, TurbulenceField, VFXBatch, ValueGeneratorFromJSON, Vector2, Vector3, Vector3Function, Vector3GeneratorFromJSON, Vector3View, Vector4, Vector4View, VelocityOverLife, WebGLCoordinateSystem, WebGPUCoordinateSystem, WidthOverLength, cacheEnvAtlas, ceilPowerOfTwo, clamp, createEnvAtlasFromFaceUrls, cubeFaceUrls, damp, degToRad, denormalize, ensureEnvAtlasFromCube, euclideanModulo, floorPowerOfTwo, generateUUID, getCachedEnvAtlas, getPhysicsResolver, getRegisteredShaderChunks, getShaderChunk, getValueFromEmitterMode, inverseLerp, isPowerOfTwo, lerp, loadPlugin, _default$7 as localParticlePhysicsVertShader, _default$6 as localParticleVertShader, mapLinear, normalize, _default$5 as particleFragShader, _default$4 as particlePhysicsFragShader, _default$3 as particleVertShader, pingpong, planBehaviorFusion, radToDeg, randFloat, randFloatSpread, randInt, registerShaderChunks, seededRandom, setPhysicsResolver, setQuaternionFromProperEuler, smootherstep, smoothstep, _default$2 as stretchedBillboardVertShader, _default$1 as trailFragShader, _default as trailVertShader, unloadPlugin };
|
|
3831
|
+
export type { AdaptivePerformanceOptions, AdaptivePerformanceState, AnimationData, BabylonMetaData, BabylonParticleMaterialParameters, Behavior, BehaviorPlugin, BillBoardSettings, BoxEmitterParameters, BurstParameters, BurstParametersJSON, CircleEmitterParameters, ColorGenerator, ConeEmitterParameters, Constructable, DonutEmitterParameters, EdgeEmitterParameters, EmissionState, EmitterShape, EmitterShapePlugin, EulerOrder, FieldType, FunctionColorGenerator, FunctionJSON, FunctionValueGenerator, FusedPass, FusionStep, GeneratorMemory, GridEmitterParameters, HemisphereEmitterParameters, IAnimationData, IEmitter, IParticle, IParticleSystem, IPrefab, InheritVelocityMode, JsonMetaData, MeshSettings, ParameterPair, ParameterType, Particle, ParticleSystemEvent, ParticleSystemEventType, ParticleSystemJSONParameters, ParticleSystemParameters, Plugin, QuarksLoaderOptions, QuarksTimelineClip, RectangleEmitterParameters, RendererEmitterSettings, Resource, RotationGenerator, Sequencer, SerializationOptions, ShapeJSON, ShapeTransformJSON, SphereEmitterParameters, StoredBatchSettings, StretchedBillBoardSettings, TrailSettings, VFXBatchSettings, ValueGenerator, Vector3Generator, VelocityOverLifeSpace };
|