@silentstatestudio/perseon 0.1.0 → 0.1.1
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 +31 -4
- package/LICENSE.md +61 -18
- package/README.md +9 -8
- package/dist/authoring/index.cjs +7 -2
- package/dist/authoring/index.d.cts +102 -4
- package/dist/authoring/index.d.ts +102 -4
- package/dist/authoring/index.js +6 -1
- package/dist/authoring/index.js.map +1 -1
- package/dist/{chunk-PT7F7TTB.cjs → chunk-443SQYAB.cjs} +216 -179
- package/dist/{chunk-ON4JV4BI.js → chunk-AVYXWDFD.js} +39 -2
- package/dist/chunk-AVYXWDFD.js.map +1 -0
- package/dist/{chunk-GDXCMDJ6.js → chunk-BEDH7OYG.js} +25 -3
- package/dist/chunk-BEDH7OYG.js.map +1 -0
- package/dist/{chunk-Q2HLLGJ7.cjs → chunk-WEQPSGPS.cjs} +23 -2
- package/dist/chunk-ZIMCQTYK.cjs +5 -0
- package/dist/chunk-ZTG42LPX.js +6 -0
- package/dist/{colors-CUEeQ78V.d.cts → colors-CCeWL9q4.d.cts} +362 -12
- package/dist/{colors-pshUJaKB.d.ts → colors-CGWrMf4V.d.ts} +362 -12
- package/dist/core/index.cjs +8 -3
- package/dist/core/index.d.cts +4 -3
- package/dist/core/index.d.ts +4 -3
- package/dist/core/index.js +8 -3
- package/dist/index.cjs +8 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -3
- package/dist/pixi-v7/index.cjs +79 -5
- package/dist/pixi-v7/index.d.cts +106 -7
- package/dist/pixi-v7/index.d.ts +106 -7
- package/dist/pixi-v7/index.js +77 -3
- package/dist/pixi-v7/index.js.map +1 -1
- package/dist/pixi-v8/index.cjs +78 -7
- package/dist/pixi-v8/index.d.cts +81 -9
- package/dist/pixi-v8/index.d.ts +81 -9
- package/dist/pixi-v8/index.js +76 -5
- package/dist/pixi-v8/index.js.map +1 -1
- package/dist/{rendering-DeUo1BsK.d.cts → rendering-dYQXmGTV.d.cts} +29 -2
- package/dist/{rendering-DeUo1BsK.d.ts → rendering-dYQXmGTV.d.ts} +29 -2
- package/dist/testing/index.cjs +23 -0
- package/dist/testing/index.d.cts +19 -1
- package/dist/testing/index.d.ts +19 -1
- package/dist/testing/index.js +24 -0
- package/dist/testing/index.js.map +1 -1
- package/package.json +145 -148
- package/dist/chunk-GDXCMDJ6.js.map +0 -1
- package/dist/chunk-ON4JV4BI.js.map +0 -1
- package/dist/chunk-SVI6WUOB.js +0 -1
- /package/dist/{chunk-SVI6WUOB.js.map → chunk-ZTG42LPX.js.map} +0 -0
|
@@ -1,58 +1,112 @@
|
|
|
1
|
-
import { b as IParticleVisualState, g as ITextureRef, i as IShape, f as IRenderer, P as ParticleBlendMode, e as ITicker } from './rendering-
|
|
1
|
+
import { b as IParticleVisualState, g as ITextureRef, i as IShape, f as IRenderer, P as ParticleBlendMode, e as ITicker } from './rendering-dYQXmGTV.js';
|
|
2
2
|
|
|
3
|
+
/** A point, in pixels. */
|
|
3
4
|
type PointValue = {
|
|
5
|
+
/** Horizontal coordinate, in pixels. */
|
|
4
6
|
x: number;
|
|
7
|
+
/** Vertical coordinate, in pixels. It grows downward on screen. */
|
|
5
8
|
y: number;
|
|
6
9
|
};
|
|
10
|
+
/** A direction and a size. */
|
|
7
11
|
interface VectorValue {
|
|
12
|
+
/** In radians: 0 points along +x, and a positive angle turns toward +y (down, on screen). */
|
|
8
13
|
angle: number;
|
|
14
|
+
/** The size of the vector, in the unit of the field that holds it (for example pixels per second for a velocity). */
|
|
9
15
|
magnitude: number;
|
|
10
16
|
}
|
|
17
|
+
/** A rectangle given by its center, its size and an optional rotation about the center. */
|
|
11
18
|
interface RectangleArea {
|
|
19
|
+
/** Center of the rectangle, in pixels. */
|
|
12
20
|
center: PointValue;
|
|
21
|
+
/** Size along the rectangle's own x axis, in pixels. */
|
|
13
22
|
width: number;
|
|
23
|
+
/** Size along the rectangle's own y axis, in pixels. */
|
|
14
24
|
height: number;
|
|
25
|
+
/** In radians. */
|
|
15
26
|
rotation?: number;
|
|
16
27
|
}
|
|
28
|
+
/** A filled circle. */
|
|
17
29
|
interface CircleArea {
|
|
30
|
+
/** Center of the circle, in pixels. */
|
|
18
31
|
center: PointValue;
|
|
32
|
+
/** Radius, in pixels, 0 or more. In a config a negative radius is a `PerseonConfigError`; through `option().set` it is clipped to 0. */
|
|
19
33
|
radius: number;
|
|
20
34
|
}
|
|
35
|
+
/** A ring: the band between two concentric circles. */
|
|
21
36
|
interface RingArea {
|
|
37
|
+
/** Center of the ring, in pixels. */
|
|
22
38
|
center: PointValue;
|
|
39
|
+
/** Radius of the empty middle, in pixels, 0 or more. It must not exceed `outerRadius`. */
|
|
23
40
|
innerRadius: number;
|
|
41
|
+
/** Radius of the outer edge, in pixels. It must be at least `innerRadius`. */
|
|
24
42
|
outerRadius: number;
|
|
25
43
|
}
|
|
44
|
+
/** A capsule (pill): a segment widened by `radius`, with a round cap at each end. */
|
|
26
45
|
interface CapsuleArea {
|
|
46
|
+
/** Center of the capsule, in pixels. */
|
|
27
47
|
center: PointValue;
|
|
48
|
+
/** Radius of the round ends and half the width of the body, in pixels. */
|
|
28
49
|
radius: number;
|
|
50
|
+
/** Total length from end to end, caps included, in pixels. At `2 * radius` or less it is a circle. */
|
|
29
51
|
length: number;
|
|
52
|
+
/** In radians. */
|
|
30
53
|
rotation?: number;
|
|
31
54
|
}
|
|
55
|
+
/** A closed polygon of at least 3 points. */
|
|
32
56
|
interface PolygonArea {
|
|
57
|
+
/** The vertices, in pixels, in order around the outline. */
|
|
33
58
|
points: PointValue[];
|
|
34
59
|
}
|
|
60
|
+
/** An area: a rectangle, a circle, a ring, a capsule or a polygon, told apart by their fields. */
|
|
35
61
|
type ShapeArea = RectangleArea | CircleArea | RingArea | CapsuleArea | PolygonArea;
|
|
36
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A curve through points: for an x, it gives a y. What x and y measure depends
|
|
65
|
+
* on where the curve is used (a transfer function, a probability, a waveform).
|
|
66
|
+
*/
|
|
37
67
|
interface CurveDefinition {
|
|
68
|
+
/** The points the curve passes through. Read in order of x. */
|
|
38
69
|
points: {
|
|
70
|
+
/** Position along the curve's horizontal axis: the input. */
|
|
39
71
|
x: number;
|
|
72
|
+
/** The curve's value at `x`: the output. */
|
|
40
73
|
y: number;
|
|
41
74
|
}[];
|
|
75
|
+
/**
|
|
76
|
+
* One number per segment between two consecutive points, from -1 to 1: 0 is
|
|
77
|
+
* a straight line, and the sign says to which side the segment bends.
|
|
78
|
+
*/
|
|
42
79
|
segmentBends: number[];
|
|
43
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* The built-in probability curves, from the range's `min` side (x = 0) to its
|
|
83
|
+
* `max` side (x = 1): `'uniform'` (equal everywhere), `'lowBias'` (likelier near
|
|
84
|
+
* `min`), `'highBias'` (likelier near `max`), `'centerBias'` (likelier in the
|
|
85
|
+
* middle), `'edgeBias'` (likelier near both ends), `'bell'` (a narrow central
|
|
86
|
+
* bell) and `'doublePeak'` (two peaks).
|
|
87
|
+
*/
|
|
44
88
|
type ProbabilityCurvePresetId = 'uniform' | 'lowBias' | 'highBias' | 'centerBias' | 'edgeBias' | 'bell' | 'doublePeak';
|
|
89
|
+
/** Which probability curve a distribution is: one of the built-in presets, or a custom curve. */
|
|
45
90
|
type ProbabilityCurveKind = {
|
|
91
|
+
/** `'preset'`: the curve is the built-in one named by `presetId`. */
|
|
46
92
|
type: 'preset';
|
|
93
|
+
/** Which built-in curve, by its id in `PROBABILITY_CURVE_PRESETS`. */
|
|
47
94
|
presetId: ProbabilityCurvePresetId;
|
|
48
95
|
} | {
|
|
96
|
+
/** `'custom'`: the curve was drawn by hand rather than taken from a preset. */
|
|
49
97
|
type: 'custom';
|
|
50
98
|
};
|
|
99
|
+
/** A built-in probability curve, with the text and icon a tool shows for it. */
|
|
51
100
|
interface ProbabilityCurvePreset {
|
|
101
|
+
/** Which preset this is. */
|
|
52
102
|
id: ProbabilityCurvePresetId;
|
|
103
|
+
/** Short display name, in English. */
|
|
53
104
|
label: string;
|
|
105
|
+
/** One-line explanation of the shape, in English. */
|
|
54
106
|
description: string;
|
|
107
|
+
/** The curve itself, with x from 0 to 1 across the range and y the relative probability. */
|
|
55
108
|
curve: CurveDefinition;
|
|
109
|
+
/** Name of the icon a tool draws for the preset. */
|
|
56
110
|
iconKey?: string;
|
|
57
111
|
}
|
|
58
112
|
|
|
@@ -82,12 +136,19 @@ declare const PARTICLE_EVENT_TRIGGERS: readonly ["onSpawn", "onDeath", "onRegion
|
|
|
82
136
|
* are still on screen — so neither of them says "this emitter is done".
|
|
83
137
|
*/
|
|
84
138
|
declare const EMITTER_EVENT_TRIGGERS: readonly ["onEmitStart", "onEmitStop", "onFinished"];
|
|
139
|
+
/** A lifecycle moment a particle can bind an event to: one of `PARTICLE_EVENT_TRIGGERS`. */
|
|
85
140
|
type ParticleEventTrigger = (typeof PARTICLE_EVENT_TRIGGERS)[number];
|
|
141
|
+
/** A lifecycle moment an emitter can bind an event to: one of `EMITTER_EVENT_TRIGGERS`. */
|
|
86
142
|
type EmitterEventTrigger = (typeof EMITTER_EVENT_TRIGGERS)[number];
|
|
143
|
+
/** Any lifecycle moment an event can be bound to, on a particle or on an emitter. */
|
|
87
144
|
type EventTrigger = ParticleEventTrigger | EmitterEventTrigger;
|
|
145
|
+
/** Whether `value` can be an event name: a string with at least one non-whitespace character. */
|
|
88
146
|
declare function isValidEventName(value: unknown): value is string;
|
|
147
|
+
/** Whether `value` is one of the particle triggers in `PARTICLE_EVENT_TRIGGERS`. */
|
|
89
148
|
declare function isParticleEventTrigger(value: unknown): value is ParticleEventTrigger;
|
|
149
|
+
/** Whether `value` is one of the emitter triggers in `EMITTER_EVENT_TRIGGERS`. */
|
|
90
150
|
declare function isEmitterEventTrigger(value: unknown): value is EmitterEventTrigger;
|
|
151
|
+
/** Whether `value` is a particle trigger or an emitter trigger. */
|
|
91
152
|
declare function isEventTrigger(value: unknown): value is EventTrigger;
|
|
92
153
|
|
|
93
154
|
/**
|
|
@@ -167,7 +228,9 @@ declare class ParticleItem implements IParticleVisualState {
|
|
|
167
228
|
* context at it without going through the layer.
|
|
168
229
|
*/
|
|
169
230
|
protected _listState: RandomListState;
|
|
231
|
+
/** The random value drawn at birth; read through `seed`. */
|
|
170
232
|
protected _seed: number;
|
|
233
|
+
/** The state of the particle's texture-frame animation, or `null` when it has none or it has ended. */
|
|
171
234
|
protected _spriteAnimation: ParticleSpriteAnimationParameters | null;
|
|
172
235
|
/**
|
|
173
236
|
* The state the layer's program keeps per particle: frozen
|
|
@@ -383,7 +446,7 @@ declare class LocalDefaultHandle {
|
|
|
383
446
|
* format, relative to the scope; `<id>` stands for the one open
|
|
384
447
|
* segment a point force, a region or a point force factor has.
|
|
385
448
|
*
|
|
386
|
-
* Left out, each for
|
|
449
|
+
* Left out, each for its own reason: identities (`id`), structure the
|
|
387
450
|
* editor rebuilds (`emitters`, `particles`), the lists changed by
|
|
388
451
|
* their own methods (`pointForces`, `regions`, `events`), the parameters
|
|
389
452
|
* (`param()`), functions and constructors, the animation's
|
|
@@ -397,10 +460,16 @@ type OptionNodeKind = 'value' | 'composite' | 'record' | 'constant';
|
|
|
397
460
|
type OptionStage = 'construction' | 'session' | 'cycle' | 'birth' | 'tick' | 'immediate';
|
|
398
461
|
/** A value's strategy; `ParameterDescription.strategy`. */
|
|
399
462
|
type OptionStrategy = 'fixed' | 'range' | 'list' | 'linked' | 'modulated';
|
|
463
|
+
/**
|
|
464
|
+
* One addressable node of a scope: its path, what kind of node it is, when the engine reads it,
|
|
465
|
+
* and the functions that check and clip a value for it.
|
|
466
|
+
*/
|
|
400
467
|
interface OptionPathEntry {
|
|
401
468
|
/** As the dev writes it, with `<id>` for an open segment. */
|
|
402
469
|
readonly path: string;
|
|
470
|
+
/** What kind of node it is: a value, a composite, a record or a constant. */
|
|
403
471
|
readonly kind: OptionNodeKind;
|
|
472
|
+
/** When the engine reads the node. */
|
|
404
473
|
readonly stage: OptionStage;
|
|
405
474
|
/**
|
|
406
475
|
* The strategies read at another stage than `stage`: a Fixed or Linked
|
|
@@ -432,6 +501,7 @@ interface OptionPathEntry {
|
|
|
432
501
|
/** The same for each number of a node that is a pair of them (the wind). */
|
|
433
502
|
readonly pairDomains?: Readonly<Record<string, NumericDomain>>;
|
|
434
503
|
}
|
|
504
|
+
/** The addressable nodes of each scope (`playback`, `emitter`, `layer`), as `OptionPathEntry` lists. */
|
|
435
505
|
declare const OPTION_PATH_CATALOG: Readonly<Record<OptionScope, readonly OptionPathEntry[]>>;
|
|
436
506
|
/**
|
|
437
507
|
* The entry of a concrete path (`'pointForces.toCounter.position'`), or
|
|
@@ -527,6 +597,7 @@ declare class LocalParameterHandle {
|
|
|
527
597
|
type PlaybackFinishedReason = 'completed' | 'stopped' | 'released' | 'destroyed' | 'hostDestroyed';
|
|
528
598
|
/** How a play session ended, handed to `finished` and to the `onFinished` listeners alike. */
|
|
529
599
|
interface PlaybackFinishedResult {
|
|
600
|
+
/** Why it ended: `'completed'` (it ran its course), `'stopped'`, `'released'` or `'destroyed'` (the host's call), or `'hostDestroyed'` (its container was destroyed). */
|
|
530
601
|
readonly reason: PlaybackFinishedReason;
|
|
531
602
|
}
|
|
532
603
|
|
|
@@ -616,7 +687,9 @@ declare class ParameterHandle<T> {
|
|
|
616
687
|
|
|
617
688
|
/** Translation of the emission coordinates. */
|
|
618
689
|
interface EmissionTransform {
|
|
690
|
+
/** Offset added to the horizontal origin of what is born afterwards. */
|
|
619
691
|
x: number;
|
|
692
|
+
/** Offset added to the vertical origin of what is born afterwards. */
|
|
620
693
|
y: number;
|
|
621
694
|
}
|
|
622
695
|
|
|
@@ -639,6 +712,7 @@ declare class ParticleLayerView {
|
|
|
639
712
|
private constructor();
|
|
640
713
|
/** Draw order among the layers of its emitter; higher draws on top. */
|
|
641
714
|
get zIndex(): number;
|
|
715
|
+
/** Set the draw order among the layers of its emitter. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
642
716
|
set zIndex(value: number);
|
|
643
717
|
/**
|
|
644
718
|
* Whether this layer is drawn; drawn only while its emitter is drawn too.
|
|
@@ -646,6 +720,7 @@ declare class ParticleLayerView {
|
|
|
646
720
|
* Starts as `ParticleLayerOptions.visible` and goes back to it in the pool.
|
|
647
721
|
*/
|
|
648
722
|
get visible(): boolean;
|
|
723
|
+
/** Show or hide this layer; a hidden layer still spawns and simulates. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
649
724
|
set visible(value: boolean);
|
|
650
725
|
/** Live particles spawned from this layer; 0 once its playback is over. */
|
|
651
726
|
get aliveCount(): number;
|
|
@@ -686,39 +761,51 @@ declare class EmitterView {
|
|
|
686
761
|
get playback(): PerseonPlayback;
|
|
687
762
|
/** Whether the emission is open. Setting it opens or closes it; set from inside an update, it applies when that tick ends. */
|
|
688
763
|
get spawn(): boolean;
|
|
764
|
+
/** Open or close the emission. Called from inside an update, it takes effect when that tick ends. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
689
765
|
set spawn(value: boolean);
|
|
690
766
|
/** Particles of a burst, born in one frame. 0 when the emitter emits at a rate instead. Read at the next cycle. */
|
|
691
767
|
get spawnCount(): number;
|
|
768
|
+
/** Set the number of particles of a burst. Read at the next cycle. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
692
769
|
set spawnCount(value: number);
|
|
693
770
|
/** Particles per second while a rate emission runs. 0 means no rate emission. */
|
|
694
771
|
get spawnRate(): number;
|
|
772
|
+
/** Set the particles per second of a rate emission; 0 means no rate emission. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
695
773
|
set spawnRate(value: number);
|
|
696
774
|
/** Seconds a rate emission lasts per cycle; 0 means it never ends. */
|
|
697
775
|
get spawnDuration(): number;
|
|
776
|
+
/** Set the seconds a rate emission lasts per cycle; 0 means it never ends. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
698
777
|
set spawnDuration(value: number);
|
|
699
778
|
/** Seconds the emitter waits after a session starts before it begins to emit. */
|
|
700
779
|
get startDelay(): number;
|
|
780
|
+
/** Set the seconds the emitter waits after a session starts before it begins to emit. Read when the next session starts. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
701
781
|
set startDelay(value: number);
|
|
702
782
|
/** How many times the emission cycle repeats after the first. The highest value allowed means forever. */
|
|
703
783
|
get repeat(): number;
|
|
784
|
+
/** Set how many times the emission cycle repeats after the first; the highest value allowed means forever. Read when the next session starts. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
704
785
|
set repeat(value: number);
|
|
705
786
|
/** Seconds between the end of one emission cycle and the start of the next. */
|
|
706
787
|
get repeatInterval(): number;
|
|
788
|
+
/** Set the seconds between the end of one emission cycle and the start of the next. Read when the next cycle is armed. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
707
789
|
set repeatInterval(value: number);
|
|
708
790
|
/** Seconds of simulation run when a session starts (warm-up), so the emitter begins already populated. Capped by `effectiveWarmUpMaxTicks`. */
|
|
709
791
|
get simulateTime(): number;
|
|
792
|
+
/** Set the seconds of simulation run as warm-up when a session starts. Read when the next session starts. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
710
793
|
set simulateTime(value: number);
|
|
711
794
|
/** Minimum number of live particles to have once the warm-up ends; the emitter spawns up to it, within `maxPoolSize`. */
|
|
712
795
|
get ensureAliveCount(): number;
|
|
796
|
+
/** Set the minimum number of live particles the emitter spawns up to once the warm-up ends. Read when the next session starts. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
713
797
|
set ensureAliveCount(value: number);
|
|
714
798
|
/** Shortcut of `option('capacity.maxAlive')`, read at the next birth. */
|
|
715
799
|
get maxPoolSize(): number;
|
|
800
|
+
/** Set the maximum number of live particles of the emitter; read at the next birth. A value that is not a finite number throws a `PerseonConfigError`; one out of its domain is clipped, with a warning. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
716
801
|
set maxPoolSize(value: number);
|
|
717
802
|
/** Shortcut of `option('capacity.limitStrategy')`, read at the next birth. */
|
|
718
803
|
get particleLimitStrategy(): ParticleLimitStrategy;
|
|
804
|
+
/** Set what happens when the emitter is at its particle limit; read at the next birth. A value that is not one of the strategies throws a `PerseonConfigError`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
719
805
|
set particleLimitStrategy(value: ParticleLimitStrategy);
|
|
720
806
|
/** Shortcut of `option('emission.spawnStrategy')`, read at the next birth. */
|
|
721
807
|
get particleSpawnStrategy(): ParticleSpawnStrategy;
|
|
808
|
+
/** Set where a new particle is drawn among the live ones of its layer; read at the next birth. A value that is not one of the strategies throws a `PerseonConfigError`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
722
809
|
set particleSpawnStrategy(value: ParticleSpawnStrategy);
|
|
723
810
|
/**
|
|
724
811
|
* Warm-up tick budget: the animation's is the default and the ceiling.
|
|
@@ -728,11 +815,13 @@ declare class EmitterView {
|
|
|
728
815
|
get warmUpMaxTicks(): number | undefined;
|
|
729
816
|
/** The warm-up tick budget in force: the lower of this emitter's and the animation's. */
|
|
730
817
|
get effectiveWarmUpMaxTicks(): number;
|
|
818
|
+
/** Set this emitter's warm-up tick budget, capped by the animation's. `undefined` inherits the animation's; any other value that is not a positive number is not applied and is reported by the diagnostics policy. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
731
819
|
set warmUpMaxTicks(value: number | undefined);
|
|
732
820
|
/** Simulation rate, like `warmUpMaxTicks`: the animation's is the default and the ceiling. */
|
|
733
821
|
get maxUpdateRate(): number | undefined;
|
|
734
822
|
/** The simulation rate in force: the lower of this emitter's and the animation's. */
|
|
735
823
|
get effectiveMaxUpdateRate(): number;
|
|
824
|
+
/** Set this emitter's simulation rate in steps per second, capped by the animation's. `undefined` inherits the animation's; any other value that is not a positive number is not applied and is reported by the diagnostics policy. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
736
825
|
set maxUpdateRate(value: number | undefined);
|
|
737
826
|
/** Whether the emission is open (`spawn`) while the playback is running; false once the playback is over. */
|
|
738
827
|
get isEmitting(): boolean;
|
|
@@ -761,6 +850,7 @@ declare class EmitterView {
|
|
|
761
850
|
option<P extends EmitterOptionPath>(path: P): ParameterHandle<EmitterOptionType<P>>;
|
|
762
851
|
/** Whether this emitter (and its layers) are drawn. */
|
|
763
852
|
get visible(): boolean;
|
|
853
|
+
/** Show or hide this emitter and its layers. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
764
854
|
set visible(value: boolean);
|
|
765
855
|
/**
|
|
766
856
|
* This emitter's emission transform: added, with its layer's and the
|
|
@@ -799,6 +889,8 @@ declare class PerseonIntegration<TParent = unknown> {
|
|
|
799
889
|
*/
|
|
800
890
|
readonly renderer: IRenderer<TParent>;
|
|
801
891
|
/**
|
|
892
|
+
* Build an integration over a renderer. Backends call this from their own constructor; a host rarely does.
|
|
893
|
+
*
|
|
802
894
|
* @param renderer the backend, built by the integration from its host's own
|
|
803
895
|
* objects.
|
|
804
896
|
* @param ticker the host's frame source. Optional because the renderer
|
|
@@ -922,6 +1014,8 @@ interface PlaybackHost {
|
|
|
922
1014
|
*/
|
|
923
1015
|
declare class PerseonPlayback {
|
|
924
1016
|
/**
|
|
1017
|
+
* Build a playback of its own, with no pool: it is `alive` until it is destroyed, by `destroy()` or by `release()`.
|
|
1018
|
+
*
|
|
925
1019
|
* @param config the animation — pure configuration, straight from a scene
|
|
926
1020
|
* file. Holds no live object.
|
|
927
1021
|
* @param renderer the host's renderer, which the animation cannot carry
|
|
@@ -973,6 +1067,7 @@ declare class PerseonPlayback {
|
|
|
973
1067
|
get elapsedTotal(): number;
|
|
974
1068
|
/** Simulation rate of the whole animation, and the ceiling of every emitter's. */
|
|
975
1069
|
get maxUpdateRate(): number;
|
|
1070
|
+
/** Set the animation's simulation rate, in steps per second. A value that is not a positive number is not applied and is reported by the diagnostics policy; use `Infinity` for no limit. Positive values are clipped to 1–1,000,000, so `Infinity` reads back as 1,000,000. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
976
1071
|
set maxUpdateRate(value: number);
|
|
977
1072
|
/**
|
|
978
1073
|
* The factor of this playback's simulated step, 1 by
|
|
@@ -981,9 +1076,11 @@ declare class PerseonPlayback {
|
|
|
981
1076
|
* negative or non-finite value, also in `play`/`prepare`.
|
|
982
1077
|
*/
|
|
983
1078
|
get timeScale(): number;
|
|
1079
|
+
/** Set the factor of the simulated step: 1 is real time, 0 freezes the simulation without pausing it. Throws a `PerseonConfigError` for a negative or non-finite value. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
984
1080
|
set timeScale(value: number);
|
|
985
1081
|
/** Warm-up tick budget of the animation: the default and the ceiling of every emitter's. */
|
|
986
1082
|
get warmUpMaxTicks(): number;
|
|
1083
|
+
/** Set the animation's warm-up tick budget. A value that is not a positive number is not applied and is reported by the diagnostics policy. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
987
1084
|
set warmUpMaxTicks(value: number);
|
|
988
1085
|
/**
|
|
989
1086
|
* Whether its instance goes back to the pool at its natural end. `play()` brings it at `true`: fire and forget. `prepare()` at
|
|
@@ -996,6 +1093,7 @@ declare class PerseonPlayback {
|
|
|
996
1093
|
* it is `false`, and its natural end always leaves it stopped.
|
|
997
1094
|
*/
|
|
998
1095
|
get autoRelease(): boolean;
|
|
1096
|
+
/** Choose whether the instance goes back to the pool at its natural end. Setting `true` on a playback already stopped at its natural end gives it back immediately. A playback with no pool (built with `new PerseonPlayback`) has nowhere to go back to. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
999
1097
|
set autoRelease(value: boolean);
|
|
1000
1098
|
/** Whether its session is running; `false` once the playback is over. */
|
|
1001
1099
|
get isRunning(): boolean;
|
|
@@ -1010,9 +1108,11 @@ declare class PerseonPlayback {
|
|
|
1010
1108
|
unmount(): void;
|
|
1011
1109
|
/** Position of the whole animation within its parent. */
|
|
1012
1110
|
get x(): number;
|
|
1111
|
+
/** Move the whole animation horizontally within its parent. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1013
1112
|
set x(value: number);
|
|
1014
1113
|
/** Vertical position of the whole animation within its parent, like `x`. */
|
|
1015
1114
|
get y(): number;
|
|
1115
|
+
/** Move the whole animation vertically within its parent. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1016
1116
|
set y(value: number);
|
|
1017
1117
|
/**
|
|
1018
1118
|
* The playback's emission transform: added to where every
|
|
@@ -1024,6 +1124,7 @@ declare class PerseonPlayback {
|
|
|
1024
1124
|
get transform(): EmissionTransform;
|
|
1025
1125
|
/** Hide or show the whole animation. Hiding does not pause the simulation. */
|
|
1026
1126
|
get visible(): boolean;
|
|
1127
|
+
/** Hide or show the whole animation; hiding does not pause the simulation. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1027
1128
|
set visible(value: boolean);
|
|
1028
1129
|
/** Whether `destroy()` has run on its instance. */
|
|
1029
1130
|
get isDestroyed(): boolean;
|
|
@@ -1055,17 +1156,21 @@ declare class PerseonPlayback {
|
|
|
1055
1156
|
get finished(): Promise<PlaybackFinishedResult>;
|
|
1056
1157
|
/** Gravitational acceleration applied to the particles whose layer declares a gravity factor. */
|
|
1057
1158
|
get gravity(): number;
|
|
1159
|
+
/** Set the gravitational acceleration; a shortcut of `option('externalForces.gravity').set`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1058
1160
|
set gravity(value: number);
|
|
1059
1161
|
/** Movement damping that opposes the particles' velocity, for the layers that declare a damping factor. */
|
|
1060
1162
|
get damping(): number;
|
|
1163
|
+
/** Set the movement damping; a shortcut of `option('externalForces.damping').set`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1061
1164
|
set damping(value: number);
|
|
1062
1165
|
/** `damping` scaled to the constant the physics step integrates with; read-only. */
|
|
1063
1166
|
get dampingCoefficient(): number;
|
|
1064
1167
|
/** A copy: writing to it does not change the wind. */
|
|
1065
1168
|
get wind(): PointValue;
|
|
1169
|
+
/** Set the wind from a point; a shortcut of `option('externalForces.wind').set`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1066
1170
|
set wind(value: PointValue);
|
|
1067
1171
|
/** A copy, like `wind`. */
|
|
1068
1172
|
get windVector(): VectorValue;
|
|
1173
|
+
/** Set the wind from a vector (angle and magnitude); a shortcut of `option('externalForces.wind').set`. Once the playback is over (`alive` is false), it does nothing and is reported by the diagnostics policy. */
|
|
1069
1174
|
set windVector(value: VectorValue);
|
|
1070
1175
|
/** Strength of the wind, the `magnitude` of `windVector`; read-only, set it through `windVector`. */
|
|
1071
1176
|
get windMagnitude(): number;
|
|
@@ -1154,19 +1259,28 @@ declare class PerseonPlayback {
|
|
|
1154
1259
|
|
|
1155
1260
|
/** What an animation tells of itself; each list is a copy. */
|
|
1156
1261
|
interface AnimationDescription {
|
|
1262
|
+
/** The global parameters the animation declares. */
|
|
1157
1263
|
globalParameters: GlobalParameterOption[];
|
|
1158
1264
|
/** The locals as declared, with the `sampleScope` resolved and the template's default as `value`. */
|
|
1159
1265
|
localParameters: (CustomParameterOption & {
|
|
1266
|
+
/** Where the local is sampled; `'playback'` when the declaration leaves it out. */
|
|
1160
1267
|
sampleScope: CustomParameterSampleScope;
|
|
1161
1268
|
})[];
|
|
1269
|
+
/** The event names the animation declares. */
|
|
1162
1270
|
events: string[];
|
|
1271
|
+
/** The emitters in declaration order. */
|
|
1163
1272
|
emitters: {
|
|
1273
|
+
/** Host-supplied id of the emitter; `undefined` when not given. */
|
|
1164
1274
|
id: string | undefined;
|
|
1275
|
+
/** The emitter's layers, in declaration order. */
|
|
1165
1276
|
layers: {
|
|
1277
|
+
/** Host-supplied id of the layer; `undefined` when not given. */
|
|
1166
1278
|
id: string | undefined;
|
|
1167
1279
|
}[];
|
|
1168
1280
|
}[];
|
|
1281
|
+
/** The ids of the point forces the animation declares. */
|
|
1169
1282
|
pointForces: string[];
|
|
1283
|
+
/** The ids of the regions the animation declares. */
|
|
1170
1284
|
regions: string[];
|
|
1171
1285
|
}
|
|
1172
1286
|
|
|
@@ -1374,10 +1488,12 @@ declare class PerseonAnimation<TParent = unknown> {
|
|
|
1374
1488
|
|
|
1375
1489
|
/** A particle's binding of one registered event name to one of its triggers. */
|
|
1376
1490
|
interface ParticleEventBinding {
|
|
1491
|
+
/** The particle lifecycle moment that fires the event. */
|
|
1377
1492
|
particleTrigger: ParticleEventTrigger;
|
|
1378
1493
|
}
|
|
1379
1494
|
/** An emitter's binding of one registered event name to one of its triggers. */
|
|
1380
1495
|
interface EmitterEventBinding {
|
|
1496
|
+
/** The emitter lifecycle moment that fires the event: `'onEmitStart'`, `'onEmitStop'` or `'onFinished'`. */
|
|
1381
1497
|
emitterTrigger: EmitterEventTrigger;
|
|
1382
1498
|
}
|
|
1383
1499
|
/** `ParticleLayerOptions.events` — registered event name → the trigger that fires it. */
|
|
@@ -1405,12 +1521,16 @@ interface PerseonEvent {
|
|
|
1405
1521
|
readonly animation: PerseonAnimation | undefined;
|
|
1406
1522
|
/** The emitter, by its id and its declaration index. */
|
|
1407
1523
|
readonly emitter: {
|
|
1524
|
+
/** The emitter's `id`; `undefined` if it declares none. */
|
|
1408
1525
|
readonly id: string | undefined;
|
|
1526
|
+
/** Position of the emitter in the playback's declaration order, from 0. */
|
|
1409
1527
|
readonly index: number;
|
|
1410
1528
|
};
|
|
1411
1529
|
/** The layer of the particle, by its id and its index in the emitter, in a particle trigger; `undefined` in an emitter trigger. */
|
|
1412
1530
|
readonly layer: {
|
|
1531
|
+
/** The layer's `id`; `undefined` if it declares none. */
|
|
1413
1532
|
readonly id: string | undefined;
|
|
1533
|
+
/** Position of the layer in its emitter, from 0. */
|
|
1414
1534
|
readonly index: number;
|
|
1415
1535
|
} | undefined;
|
|
1416
1536
|
/** The region crossed, in `onRegionEnter` / `onRegionExit`; `undefined` otherwise. */
|
|
@@ -1433,18 +1553,29 @@ interface PerseonEvent {
|
|
|
1433
1553
|
interface ParticleSnapshot {
|
|
1434
1554
|
/** Position in the space of the animation. */
|
|
1435
1555
|
readonly x: number;
|
|
1556
|
+
/** Vertical position, in the same space as `x`. */
|
|
1436
1557
|
readonly y: number;
|
|
1437
1558
|
/** Position in the space of the playback's parent: `x + pb.x`, `y + pb.y`. */
|
|
1438
1559
|
readonly parentX: number;
|
|
1560
|
+
/** Vertical position in the space of the playback's parent. */
|
|
1439
1561
|
readonly parentY: number;
|
|
1562
|
+
/** Horizontal velocity, in pixels per second. */
|
|
1440
1563
|
readonly velocityX: number;
|
|
1564
|
+
/** Vertical velocity, in pixels per second. */
|
|
1441
1565
|
readonly velocityY: number;
|
|
1566
|
+
/** Rotation, in radians. */
|
|
1442
1567
|
readonly rotation: number;
|
|
1568
|
+
/** Horizontal scale factor: 1 draws the texture at its own width. */
|
|
1443
1569
|
readonly scaleX: number;
|
|
1570
|
+
/** Vertical scale factor: 1 draws the texture at its own height. */
|
|
1444
1571
|
readonly scaleY: number;
|
|
1572
|
+
/** Opacity, from 0 (invisible) to 1 (opaque). */
|
|
1445
1573
|
readonly alpha: number;
|
|
1574
|
+
/** Color multiplied over the texture, as a `0xRRGGBB` number. */
|
|
1446
1575
|
readonly tint: number;
|
|
1576
|
+
/** How long the particle lives, in seconds. `Infinity` when none was set. */
|
|
1447
1577
|
readonly lifetime: number;
|
|
1578
|
+
/** Seconds elapsed since the particle was born. */
|
|
1448
1579
|
readonly currentLife: number;
|
|
1449
1580
|
/** A new plain object with every field: a mutable copy, the caller's. */
|
|
1450
1581
|
toObject(): ParticleSnapshotObject;
|
|
@@ -1463,8 +1594,14 @@ type Unsubscribe = () => void;
|
|
|
1463
1594
|
* branching on a trigger string.
|
|
1464
1595
|
*/
|
|
1465
1596
|
type ParticleEventsByTrigger = Record<ParticleEventTrigger, string[]>;
|
|
1597
|
+
/** Event names grouped by the emitter trigger that fires them, as `ParticleEventsByTrigger` does for particles. */
|
|
1466
1598
|
type EmitterEventsByTrigger = Record<EmitterEventTrigger, string[]>;
|
|
1467
1599
|
|
|
1600
|
+
/**
|
|
1601
|
+
* The uniform forces of a playback: gravity, damping and wind. A particle feels
|
|
1602
|
+
* each one only through the matching factor of its layer
|
|
1603
|
+
* (`ExternalForcesFactorOptions`).
|
|
1604
|
+
*/
|
|
1468
1605
|
interface ExternalForcesOptions {
|
|
1469
1606
|
/** Global gravitational acceleration */
|
|
1470
1607
|
gravity?: number;
|
|
@@ -1473,15 +1610,13 @@ interface ExternalForcesOptions {
|
|
|
1473
1610
|
/** Global wind force applied to particles */
|
|
1474
1611
|
wind?: VectorValue;
|
|
1475
1612
|
}
|
|
1476
|
-
|
|
1477
|
-
/** Global gravitational acceleration */
|
|
1478
|
-
gravity: number;
|
|
1479
|
-
/** Global movement damping coefficient (opposes movement) */
|
|
1480
|
-
damping: number;
|
|
1481
|
-
/** Global wind force applied to particles */
|
|
1482
|
-
wind: PointValue;
|
|
1483
|
-
}
|
|
1613
|
+
/** What a point force does to a particle in reach: `'attract'` pulls it toward the force, `'repel'` pushes it away. */
|
|
1484
1614
|
type PointForceMode = 'attract' | 'repel';
|
|
1615
|
+
/**
|
|
1616
|
+
* How a point force's strength changes with distance inside its radius:
|
|
1617
|
+
* `'none'` keeps it constant, `'linear'` fades it from full at the center to
|
|
1618
|
+
* zero at the edge, `'smooth'` does the same along a smoothstep curve.
|
|
1619
|
+
*/
|
|
1485
1620
|
type PointForceFalloff = 'none' | 'linear' | 'smooth';
|
|
1486
1621
|
/**
|
|
1487
1622
|
* A reusable positional external force (attractor / repeller). Declared at
|
|
@@ -1496,15 +1631,30 @@ type PointForceFalloff = 'none' | 'linear' | 'smooth';
|
|
|
1496
1631
|
* - `enabled`: when false the force is inert.
|
|
1497
1632
|
*/
|
|
1498
1633
|
interface PointForceConfig {
|
|
1634
|
+
/** What a layer's `externalForces.pointForceFactors` names it by. */
|
|
1499
1635
|
id: string;
|
|
1636
|
+
/** The name a tool shows for it. */
|
|
1500
1637
|
name: string;
|
|
1638
|
+
/** Where it is, in the space of the animation. */
|
|
1501
1639
|
position: PointValue;
|
|
1640
|
+
/** `'attract'` pulls particles toward `position`; `'repel'` pushes them away. */
|
|
1502
1641
|
mode: PointForceMode;
|
|
1642
|
+
/** Acceleration at full influence. */
|
|
1503
1643
|
strength: number;
|
|
1644
|
+
/** Reach, in pixels. Beyond it the force does nothing. */
|
|
1504
1645
|
radius: number;
|
|
1646
|
+
/**
|
|
1647
|
+
* How the strength fades from `position` to the edge of `radius`:
|
|
1648
|
+
* `'none'` (the same everywhere inside), `'linear'` or `'smooth'`.
|
|
1649
|
+
*/
|
|
1505
1650
|
falloff: PointForceFalloff;
|
|
1651
|
+
/** `false` switches the force off. */
|
|
1506
1652
|
enabled: boolean;
|
|
1507
1653
|
}
|
|
1654
|
+
/**
|
|
1655
|
+
* How strongly the particles of a layer feel each external force: a multiplier
|
|
1656
|
+
* per force, each in the value system of any other numeric parameter.
|
|
1657
|
+
*/
|
|
1508
1658
|
interface ExternalForcesFactorOptions {
|
|
1509
1659
|
/** Global gravitational acceleration factor. Without it, 0: the gravity does not reach the particle */
|
|
1510
1660
|
gravityFactor?: ModulatableNumber;
|
|
@@ -1520,6 +1670,7 @@ interface ExternalForcesFactorOptions {
|
|
|
1520
1670
|
*/
|
|
1521
1671
|
pointForceFactors?: Record<string, ModulatableNumber>;
|
|
1522
1672
|
}
|
|
1673
|
+
/** The names of the uniform forces: `'gravity'`, `'damping'` and `'wind'`. */
|
|
1523
1674
|
type ExternalForcesTypes = keyof ExternalForcesOptions;
|
|
1524
1675
|
|
|
1525
1676
|
/**
|
|
@@ -1534,12 +1685,16 @@ type RegionBehavior = 'killInside' | 'killOutside';
|
|
|
1534
1685
|
* one by referencing its `id` through `ParticleLayerOptions.region`.
|
|
1535
1686
|
*/
|
|
1536
1687
|
interface RegionOptions {
|
|
1688
|
+
/** What a layer's `region.regionId` names it by. */
|
|
1537
1689
|
id: string;
|
|
1690
|
+
/** Its shape, in the space of the animation. */
|
|
1538
1691
|
area: ShapeArea;
|
|
1539
1692
|
}
|
|
1540
1693
|
/** Per-particle assignment to a single region plus the kill behavior to apply. */
|
|
1541
1694
|
interface ParticleRegionRef {
|
|
1695
|
+
/** The `id` of one of the animation's `regions`. */
|
|
1542
1696
|
regionId: string;
|
|
1697
|
+
/** Whether the particles die inside the region or outside it. */
|
|
1543
1698
|
behavior: RegionBehavior;
|
|
1544
1699
|
}
|
|
1545
1700
|
|
|
@@ -1548,9 +1703,13 @@ interface ParticleRegionRef {
|
|
|
1548
1703
|
* The renderer's `resolveTexture(source)` turns this into an `ITextureRef`.
|
|
1549
1704
|
*/
|
|
1550
1705
|
type SingleTextureOption = string;
|
|
1706
|
+
/** A texture that changes while the particle lives: a list of frames shown one after another. */
|
|
1551
1707
|
interface SpriteAnimationOptions {
|
|
1708
|
+
/** The frames, in order, each a texture id. */
|
|
1552
1709
|
textures: SingleTextureOption[];
|
|
1710
|
+
/** Frames per second. Defaults to 12. */
|
|
1553
1711
|
animationFPS?: number;
|
|
1712
|
+
/** Whether it starts again after the last frame. Defaults to `true`. */
|
|
1554
1713
|
animationLoop?: boolean;
|
|
1555
1714
|
/**
|
|
1556
1715
|
* Starting frame for the animation. Undefined means it will start from the first frame.
|
|
@@ -1558,9 +1717,12 @@ interface SpriteAnimationOptions {
|
|
|
1558
1717
|
*/
|
|
1559
1718
|
startFrame?: number;
|
|
1560
1719
|
}
|
|
1720
|
+
/** The same fields as `SpriteAnimationOptions`, with `textures` declared as `string[]`. */
|
|
1561
1721
|
interface SpriteAnimationTexturesOptions extends Omit<SpriteAnimationOptions, 'textures'> {
|
|
1722
|
+
/** The frames, in order, each a texture id. */
|
|
1562
1723
|
textures: string[];
|
|
1563
1724
|
}
|
|
1725
|
+
/** What a particle draws: a single texture id, or a sprite animation. */
|
|
1564
1726
|
type TextureElement = SingleTextureOption | SpriteAnimationOptions;
|
|
1565
1727
|
/**
|
|
1566
1728
|
* Runtime state of a sprite-sheet animation on a live particle. Textures are
|
|
@@ -1568,32 +1730,63 @@ type TextureElement = SingleTextureOption | SpriteAnimationOptions;
|
|
|
1568
1730
|
* touch any string-keyed cache.
|
|
1569
1731
|
*/
|
|
1570
1732
|
interface ParticleSpriteAnimationParameters {
|
|
1733
|
+
/** The frames, in order, as resolved textures. */
|
|
1571
1734
|
textures: ITextureRef[];
|
|
1735
|
+
/** Seconds accumulated toward the next frame change. */
|
|
1572
1736
|
elapsedTime: number;
|
|
1737
|
+
/** Seconds each frame is shown: 1 divided by the frames per second. */
|
|
1573
1738
|
intervalSec: number;
|
|
1739
|
+
/** Index of the frame shown now. */
|
|
1574
1740
|
currentIndex: number;
|
|
1741
|
+
/** Whether the animation starts again after the last frame. If not, it stops on the last frame. */
|
|
1575
1742
|
loop: boolean;
|
|
1576
1743
|
}
|
|
1744
|
+
/** Where a particle is born and how it moves. Distances are pixels in the space of the animation; angles are radians. */
|
|
1577
1745
|
interface KineticsOptions {
|
|
1746
|
+
/** Where the particle is born: a point, a point of a list, or anywhere inside an area. */
|
|
1578
1747
|
position?: SpawnPosition;
|
|
1748
|
+
/** Its velocity, as an angle and a magnitude in pixels per second. */
|
|
1579
1749
|
velocity?: SpawnVector;
|
|
1750
|
+
/** Its acceleration, as an angle and a magnitude in pixels per second squared. */
|
|
1580
1751
|
acceleration?: SpawnVector;
|
|
1752
|
+
/** Cap on the speed along each axis, in pixels per second. Absent, no cap. */
|
|
1581
1753
|
maxVelocity?: number;
|
|
1582
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* The size of a particle, as a factor of its texture: 1 draws it at its own
|
|
1757
|
+
* size. A single number scales both axes; `{ x, y }` scales each one.
|
|
1758
|
+
*/
|
|
1583
1759
|
interface ScaleOptions {
|
|
1760
|
+
/** The scale. */
|
|
1584
1761
|
value: ModulatableNumber | SpawnPoint;
|
|
1762
|
+
/** Its rate of change, per second. */
|
|
1585
1763
|
velocity?: ModulatableNumber | SpawnPoint;
|
|
1764
|
+
/** The rate of change of `velocity`, per second. */
|
|
1586
1765
|
acceleration?: ModulatableNumber | SpawnPoint;
|
|
1587
1766
|
/** Maximum speed cap applied equally to both X and Y scale velocity components. */
|
|
1588
1767
|
maxVelocity?: number;
|
|
1589
1768
|
}
|
|
1769
|
+
/**
|
|
1770
|
+
* A number that moves: `rotation` (radians) and `alpha` (0 transparent, 1
|
|
1771
|
+
* opaque) are both written this way.
|
|
1772
|
+
*/
|
|
1590
1773
|
interface NumberOptions {
|
|
1774
|
+
/** The value. */
|
|
1591
1775
|
value: ModulatableNumber;
|
|
1776
|
+
/** Its rate of change, per second. */
|
|
1592
1777
|
velocity?: ModulatableNumber;
|
|
1778
|
+
/** The rate of change of `velocity`, per second. */
|
|
1593
1779
|
acceleration?: ModulatableNumber;
|
|
1780
|
+
/** Cap on `velocity`, in either direction. Absent, no cap. */
|
|
1594
1781
|
maxVelocity?: number;
|
|
1595
1782
|
}
|
|
1783
|
+
/** The color of a particle. */
|
|
1596
1784
|
interface ColorOptions {
|
|
1785
|
+
/**
|
|
1786
|
+
* The tint, multiplied with the texture: a `0xRRGGBB` number, one of a
|
|
1787
|
+
* list, a random color of a gradient frozen at birth, or a gradient that
|
|
1788
|
+
* follows a parameter such as `lifeProgress`.
|
|
1789
|
+
*/
|
|
1597
1790
|
value: SpawnColor;
|
|
1598
1791
|
}
|
|
1599
1792
|
/**
|
|
@@ -1615,6 +1808,10 @@ interface ParticleLayerOptions {
|
|
|
1615
1808
|
* Live: `ParticleLayer.visible`.
|
|
1616
1809
|
*/
|
|
1617
1810
|
visible?: boolean;
|
|
1811
|
+
/**
|
|
1812
|
+
* What the particle draws: a texture id, a sprite animation, or a list of
|
|
1813
|
+
* either from which each particle takes one. Mandatory.
|
|
1814
|
+
*/
|
|
1618
1815
|
texture: TextureElement | RandomValueList<TextureElement>;
|
|
1619
1816
|
/** Particle lifetime in seconds */
|
|
1620
1817
|
lifetime?: ModulatableNumber;
|
|
@@ -1721,7 +1918,14 @@ interface ParameterUpdateOptions extends ParameterInitOptions {
|
|
|
1721
1918
|
elapsedSec: number;
|
|
1722
1919
|
}
|
|
1723
1920
|
|
|
1921
|
+
/**
|
|
1922
|
+
* What an emitter does with a spawn when `maxAlive` particles are already alive:
|
|
1923
|
+
* - `'preventNew'` (default): the new particle is not born.
|
|
1924
|
+
* - `'killOldest'`: the particle that has lived longest dies to make room.
|
|
1925
|
+
* - `'killRandom'`: a random live particle dies to make room.
|
|
1926
|
+
*/
|
|
1724
1927
|
type ParticleLimitStrategy = 'preventNew' | 'killOldest' | 'killRandom';
|
|
1928
|
+
/** How many particles an emitter may have alive at once, and what happens when it reaches the limit. */
|
|
1725
1929
|
interface CapacityOptions {
|
|
1726
1930
|
/** Maximum number of particles that can exist simultaneously */
|
|
1727
1931
|
maxAlive: number;
|
|
@@ -1730,20 +1934,43 @@ interface CapacityOptions {
|
|
|
1730
1934
|
/** Initial number of particles to create in the pool */
|
|
1731
1935
|
initialPoolSize?: number;
|
|
1732
1936
|
}
|
|
1937
|
+
/**
|
|
1938
|
+
* Where a new particle is drawn among the live ones of its layer: `'front'` of
|
|
1939
|
+
* them, at the `'back'` (default) or at a `'random'` depth.
|
|
1940
|
+
*/
|
|
1733
1941
|
type ParticleSpawnStrategy = 'front' | 'back' | 'random';
|
|
1942
|
+
/**
|
|
1943
|
+
* One emission cycle. Two shapes: a burst (`count` above 0) spawns `count`
|
|
1944
|
+
* particles at once and ends; a rate spawns `rate` particles per second for
|
|
1945
|
+
* `duration` seconds. Each number is drawn again when a cycle starts.
|
|
1946
|
+
*/
|
|
1734
1947
|
interface EmissionOptions {
|
|
1948
|
+
/** Seconds a rate cycle lasts. Absent or 0, it never ends by itself. Not read by a burst. */
|
|
1735
1949
|
duration?: SpawnNumber;
|
|
1950
|
+
/** Particles of a burst, all born in the same step. Above 0, the cycle is a burst and `rate` is not read. */
|
|
1736
1951
|
count?: SpawnNumber;
|
|
1952
|
+
/** Particles born per second. */
|
|
1737
1953
|
rate?: SpawnNumber;
|
|
1954
|
+
/** Where a new particle is drawn among the live ones of its layer. Defaults to `'back'`. */
|
|
1738
1955
|
spawnStrategy?: ParticleSpawnStrategy;
|
|
1739
1956
|
}
|
|
1957
|
+
/** What an emitter has already done by the time it is first shown. */
|
|
1740
1958
|
interface InitialStateOptions {
|
|
1959
|
+
/** Seconds simulated inside `start()`, before the first frame is shown: the warm-up. */
|
|
1741
1960
|
simulateTime?: SpawnNumber;
|
|
1961
|
+
/** Least number of live particles after the warm-up: what is missing is spawned at once, up to `maxAlive`. */
|
|
1742
1962
|
ensureAliveCount?: SpawnNumber;
|
|
1743
1963
|
}
|
|
1964
|
+
/** When an emission cycle starts and how it repeats. Only a cycle that ends (a burst, or a rate with `duration`) repeats. */
|
|
1744
1965
|
interface PlaybackOptions {
|
|
1966
|
+
/** Seconds the emitter waits, once started, before its first cycle. */
|
|
1745
1967
|
startDelay?: SpawnNumber;
|
|
1968
|
+
/** Seconds between the end of a cycle and the start of the next. */
|
|
1746
1969
|
interval?: SpawnNumber;
|
|
1970
|
+
/**
|
|
1971
|
+
* How many more times the cycle runs after the first. Absent or 0, once.
|
|
1972
|
+
* At the top of its domain (`EMITTER_OPTION_DOMAINS.repeat.max`), forever.
|
|
1973
|
+
*/
|
|
1747
1974
|
repeat?: SpawnNumber;
|
|
1748
1975
|
}
|
|
1749
1976
|
/**
|
|
@@ -1754,6 +1981,7 @@ interface PlaybackOptions {
|
|
|
1754
1981
|
* even inside a seeded animation.
|
|
1755
1982
|
*/
|
|
1756
1983
|
type RandomnessSeedMode = 'fixed' | 'auto';
|
|
1984
|
+
/** The random seed of an emitter. */
|
|
1757
1985
|
interface RandomnessOptions {
|
|
1758
1986
|
/**
|
|
1759
1987
|
* Absent → inherit the animation's seeding: a seed derived from
|
|
@@ -1765,8 +1993,14 @@ interface RandomnessOptions {
|
|
|
1765
1993
|
/** Only read with `seedMode: 'fixed'`. */
|
|
1766
1994
|
seed?: number;
|
|
1767
1995
|
}
|
|
1996
|
+
/** Limits on simulation work, for the whole animation (`ParticleAnimationOptions.performance`) or for one emitter, capped by the animation's. */
|
|
1768
1997
|
interface PerformanceOptions {
|
|
1998
|
+
/**
|
|
1999
|
+
* Most simulation steps per second. The time of the frames in between
|
|
2000
|
+
* accumulates and is simulated in the next step. Defaults to 60.
|
|
2001
|
+
*/
|
|
1769
2002
|
maxUpdateRate?: number;
|
|
2003
|
+
/** Most steps the warm-up (`initialState.simulateTime`) may take. */
|
|
1770
2004
|
warmUpMaxTicks?: number;
|
|
1771
2005
|
}
|
|
1772
2006
|
/**
|
|
@@ -1813,7 +2047,7 @@ interface EmitterOptions {
|
|
|
1813
2047
|
particles: RandomValueList<ParticleLayerOptions> | ParticleLayerOptions;
|
|
1814
2048
|
/**
|
|
1815
2049
|
* This emitter's bindings: registered event name → the emitter trigger that
|
|
1816
|
-
* fires it (`onEmitStart`
|
|
2050
|
+
* fires it (`onEmitStart`, `onEmitStop` or `onFinished`). The names themselves are
|
|
1817
2051
|
* registered on the engine (`ParticleAnimationOptions.events`).
|
|
1818
2052
|
*/
|
|
1819
2053
|
eventBindings?: EmitterEventBindings;
|
|
@@ -1860,7 +2094,9 @@ type PointForceField = Exclude<keyof PointForceConfig, 'id'>;
|
|
|
1860
2094
|
type PointForceFieldOf<P extends string> = {
|
|
1861
2095
|
[F in PointForceField]: P extends `pointForces.${string}.${F}` ? F : never;
|
|
1862
2096
|
}[PointForceField];
|
|
2097
|
+
/** The option paths a playback takes: its external forces and performance limits, and its point forces and regions by id (`'pointForces.<id>'`, `'regions.<id>'`) and their fields. */
|
|
1863
2098
|
type PlaybackOptionPath = keyof PlaybackOptionTypes | `pointForces.${string}` | `pointForces.${string}.${PointForceField}` | `regions.${string}` | `regions.${string}.area`;
|
|
2099
|
+
/** The type of the value at the playback option path `P`. */
|
|
1864
2100
|
type PlaybackOptionType<P extends PlaybackOptionPath> = P extends keyof PlaybackOptionTypes ? PlaybackOptionTypes[P] : P extends `pointForces.${string}` ? [PointForceFieldOf<P>] extends [never] ? PointForceConfig : PointForceConfig[PointForceFieldOf<P>] : P extends `regions.${string}.area` ? RegionOptions['area'] : RegionOptions;
|
|
1865
2101
|
type EmitterOptionTypes = {
|
|
1866
2102
|
'emission.rate': NonNullable<EmissionOptions['rate']>;
|
|
@@ -1881,7 +2117,9 @@ type EmitterOptionTypes = {
|
|
|
1881
2117
|
'performance.warmUpMaxTicks': NonNullable<PerformanceOptions['warmUpMaxTicks']>;
|
|
1882
2118
|
eventBindings: NonNullable<EmitterOptions['eventBindings']>;
|
|
1883
2119
|
};
|
|
2120
|
+
/** The option paths an emitter takes: its emission, playback, initial state, capacity, randomness and performance fields, and its event bindings. */
|
|
1884
2121
|
type EmitterOptionPath = keyof EmitterOptionTypes;
|
|
2122
|
+
/** The type of the value at the emitter option path `P`. */
|
|
1885
2123
|
type EmitterOptionType<P extends EmitterOptionPath> = EmitterOptionTypes[P];
|
|
1886
2124
|
/** One axis of a composite in its split mode: `{x, y}` or `{angle, magnitude}`. */
|
|
1887
2125
|
type Axis = ModulatableNumber;
|
|
@@ -1930,7 +2168,9 @@ type LayerOptionTypes = {
|
|
|
1930
2168
|
'externalForces.pointForceFactors': NonNullable<ExternalForcesFactorOptions['pointForceFactors']>;
|
|
1931
2169
|
};
|
|
1932
2170
|
type PointForceFactors = NonNullable<ExternalForcesFactorOptions['pointForceFactors']>;
|
|
2171
|
+
/** The option paths a particle layer takes: its lifetime, texture, region, events, blend mode, kinetics, scale, rotation, alpha, color and external-force factor fields, including each axis of a split position, velocity, acceleration or scale. */
|
|
1933
2172
|
type LayerOptionPath = keyof LayerOptionTypes | `externalForces.pointForceFactors.${string}`;
|
|
2173
|
+
/** The type of the value at the layer option path `P`. */
|
|
1934
2174
|
type LayerOptionType<P extends LayerOptionPath> = P extends keyof LayerOptionTypes ? LayerOptionTypes[P] : PointForceFactors[string];
|
|
1935
2175
|
|
|
1936
2176
|
/**
|
|
@@ -2045,9 +2285,13 @@ type CustomParameterSampleScope = 'playback' | 'emitter' | 'particle';
|
|
|
2045
2285
|
* decimals the engine declares for it.
|
|
2046
2286
|
*/
|
|
2047
2287
|
type NumericDomain = {
|
|
2288
|
+
/** Lowest valid value, inclusive. In a config a value below it is a `PerseonConfigError`; through `option().set` it is clipped to it. */
|
|
2048
2289
|
min: number;
|
|
2290
|
+
/** Highest valid value, inclusive. In a config a value above it is a `PerseonConfigError`; through `option().set` it is clipped to it. */
|
|
2049
2291
|
max: number;
|
|
2292
|
+
/** Increment a control for this value should move by. The engine does not enforce it. */
|
|
2050
2293
|
step?: number;
|
|
2294
|
+
/** Number of decimals a control for this value should show. The engine does not round to it. */
|
|
2051
2295
|
decimals?: number;
|
|
2052
2296
|
};
|
|
2053
2297
|
/**
|
|
@@ -2058,30 +2302,65 @@ type NumericDomain = {
|
|
|
2058
2302
|
* and sanitizing, so " Fire " and "Fire" are treated as the same name.
|
|
2059
2303
|
*/
|
|
2060
2304
|
type TextDomain = {
|
|
2305
|
+
/** Fewest characters allowed, measured after trimming when `trim` is on. */
|
|
2061
2306
|
minLength: number;
|
|
2307
|
+
/** Most characters allowed, measured after trimming when `trim` is on. */
|
|
2062
2308
|
maxLength: number;
|
|
2309
|
+
/** Whether leading and trailing whitespace is ignored when measuring. */
|
|
2063
2310
|
trim: boolean;
|
|
2064
2311
|
};
|
|
2065
2312
|
|
|
2313
|
+
/** Range: a number drawn between `min` and `max` each time the value is sampled. */
|
|
2066
2314
|
interface RandomValueRange {
|
|
2315
|
+
/** Lower end of the range, inclusive. */
|
|
2067
2316
|
min: number;
|
|
2317
|
+
/** Upper end of the range; a uniform draw stays below it. */
|
|
2068
2318
|
max: number;
|
|
2319
|
+
/**
|
|
2320
|
+
* How likely each part of the range is: a curve whose x runs from `min` (0)
|
|
2321
|
+
* to `max` (1) and whose y is the relative probability. Absent, every value
|
|
2322
|
+
* is as likely as any other.
|
|
2323
|
+
*/
|
|
2069
2324
|
distribution?: CurveDefinition;
|
|
2325
|
+
/** Which preset `distribution` is, or `custom`. For the tool that wrote the file: the engine reads `distribution`. */
|
|
2070
2326
|
distributionKind?: ProbabilityCurveKind;
|
|
2071
2327
|
}
|
|
2328
|
+
/**
|
|
2329
|
+
* How a list hands out its values:
|
|
2330
|
+
* - `'ordered'`: one after another, starting again after the last.
|
|
2331
|
+
* - `'shuffle'`: in a random order, each value once before any repeats.
|
|
2332
|
+
* - `'random'`: any value each time, by `weight`.
|
|
2333
|
+
*/
|
|
2072
2334
|
type RandomValueListMode = 'ordered' | 'shuffle' | 'random';
|
|
2335
|
+
/** One entry of a list. `weight` (1 when absent) is its share of the draws in `'random'` mode. */
|
|
2073
2336
|
type ValueProbability<T> = {
|
|
2337
|
+
/** The value the entry hands out. */
|
|
2074
2338
|
value: T;
|
|
2339
|
+
/** Relative share of the draws in `'random'` mode: an entry of weight 2 comes up twice as often as one of weight 1. In `'shuffle'` mode it only makes an entry likelier to come out earlier in each round; `'ordered'` ignores it. At least 1. */
|
|
2075
2340
|
weight?: number;
|
|
2076
2341
|
};
|
|
2342
|
+
/** List: one of `values`, picked by `selectionMode` each time the value is sampled. */
|
|
2077
2343
|
interface RandomValueList<T> {
|
|
2344
|
+
/** The entries to pick from. */
|
|
2078
2345
|
values: ValueProbability<T>[];
|
|
2346
|
+
/** How the next entry is chosen. */
|
|
2079
2347
|
selectionMode: RandomValueListMode;
|
|
2080
2348
|
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Linked: the value follows another parameter. The live value of the source is
|
|
2351
|
+
* passed through `transferFunction` and what comes out is the value.
|
|
2352
|
+
*/
|
|
2081
2353
|
interface ParameterLinkRelation {
|
|
2354
|
+
/** The source: a built-in parameter of the scope (`lifeProgress`, `spawnRate`…) or the id of a local or a global. */
|
|
2082
2355
|
sourceParameterId: string;
|
|
2356
|
+
/**
|
|
2357
|
+
* A curve from source values (x) to values of this parameter (y), both in
|
|
2358
|
+
* their own units. A source below the first point or above the last one
|
|
2359
|
+
* gives the y of that point.
|
|
2360
|
+
*/
|
|
2083
2361
|
transferFunction: CurveDefinition;
|
|
2084
2362
|
}
|
|
2363
|
+
/** A number in any of its four modes: Fixed, Range, List or Linked. */
|
|
2085
2364
|
type SpawnNumber = number | RandomValueRange | RandomValueList<number> | ParameterLinkRelation;
|
|
2086
2365
|
/**
|
|
2087
2366
|
* Blend operations a modifier applies to the running parameter value `v`
|
|
@@ -2102,10 +2381,14 @@ type ModifierBlendMode = 'add' | 'multiply';
|
|
|
2102
2381
|
* - `modulator`: a waveform owned by this modifier, declared inline.
|
|
2103
2382
|
*/
|
|
2104
2383
|
type ParameterModifierSource = {
|
|
2384
|
+
/** `'paramRef'`: the source is another parameter. */
|
|
2105
2385
|
type: 'paramRef';
|
|
2386
|
+
/** The parameter to read: a built-in parameter of the scope (`lifeProgress`, `spawnRate`...) or the id of a local or a global. */
|
|
2106
2387
|
sourceParameterId: string;
|
|
2107
2388
|
} | {
|
|
2389
|
+
/** `'modulator'`: the source is a waveform declared inline. */
|
|
2108
2390
|
type: 'modulator';
|
|
2391
|
+
/** The waveform. */
|
|
2109
2392
|
modulator: ModulatorOptions;
|
|
2110
2393
|
};
|
|
2111
2394
|
/**
|
|
@@ -2114,8 +2397,11 @@ type ParameterModifierSource = {
|
|
|
2114
2397
|
* blends them by `strength` (`k`), whose range is `MODIFIER_DOMAINS.strength`.
|
|
2115
2398
|
*/
|
|
2116
2399
|
interface ParameterModifier {
|
|
2400
|
+
/** Where the modifier reads its value from, every tick. */
|
|
2117
2401
|
source: ParameterModifierSource;
|
|
2402
|
+
/** How the source is combined with the running value: `'add'` or `'multiply'`. */
|
|
2118
2403
|
blend: ModifierBlendMode;
|
|
2404
|
+
/** How much the source counts, from -10 to 10. 0 means no effect in both blends; a negative value inverts its direction. */
|
|
2119
2405
|
strength: number;
|
|
2120
2406
|
}
|
|
2121
2407
|
/**
|
|
@@ -2125,23 +2411,49 @@ interface ParameterModifier {
|
|
|
2125
2411
|
* spawn, Fixed/Linked as before); the modifiers run every tick.
|
|
2126
2412
|
*/
|
|
2127
2413
|
interface ModulatedValue {
|
|
2414
|
+
/** The value before any modifier: a fixed number, a range, a list or a linked parameter. */
|
|
2128
2415
|
base: SpawnNumber;
|
|
2416
|
+
/** The modifiers, applied in order: each one takes the value the previous one left. */
|
|
2129
2417
|
modifiers: ParameterModifier[];
|
|
2130
2418
|
}
|
|
2131
2419
|
/** A numeric slot that may optionally carry a modifier stack. */
|
|
2132
2420
|
type ModulatableNumber = SpawnNumber | ModulatedValue;
|
|
2421
|
+
/**
|
|
2422
|
+
* Where a particle is born: a point given by `x` and `y`, a random point inside
|
|
2423
|
+
* an area, or a point drawn from a list of points. Coordinates are in pixels.
|
|
2424
|
+
*/
|
|
2133
2425
|
type SpawnPosition = {
|
|
2426
|
+
/** Horizontal coordinate, in pixels. */
|
|
2134
2427
|
x: ModulatableNumber;
|
|
2428
|
+
/** Vertical coordinate, in pixels. */
|
|
2135
2429
|
y: ModulatableNumber;
|
|
2136
2430
|
} | ShapeArea | RandomValueList<PointValue>;
|
|
2431
|
+
/**
|
|
2432
|
+
* A pair of numbers: `x` and `y` each given as a number in any of its modes, or
|
|
2433
|
+
* a point drawn from a list. The unit is that of the field that holds it.
|
|
2434
|
+
*/
|
|
2137
2435
|
type SpawnPoint = {
|
|
2436
|
+
/** The horizontal component. */
|
|
2138
2437
|
x: ModulatableNumber;
|
|
2438
|
+
/** The vertical component. */
|
|
2139
2439
|
y: ModulatableNumber;
|
|
2140
2440
|
} | RandomValueList<PointValue>;
|
|
2441
|
+
/**
|
|
2442
|
+
* A direction and a size: `angle` and `magnitude` each given as a number in any
|
|
2443
|
+
* of its modes, or a vector drawn from a list.
|
|
2444
|
+
*/
|
|
2141
2445
|
type SpawnVector = {
|
|
2446
|
+
/** Direction, in radians: 0 points along +x, and a positive angle turns toward +y (down, on screen). */
|
|
2142
2447
|
angle: ModulatableNumber;
|
|
2448
|
+
/** The size of the vector, in the unit of the field that holds it (for example pixels per second for a velocity). */
|
|
2143
2449
|
magnitude: ModulatableNumber;
|
|
2144
2450
|
} | RandomValueList<VectorValue>;
|
|
2451
|
+
/**
|
|
2452
|
+
* The waveform of a modulator, each normalized to run from -1 to 1 over one
|
|
2453
|
+
* cycle: `'sine'`, `'square'` (1 for the first half of the cycle, -1 for the
|
|
2454
|
+
* second), `'sawtooth'` (a ramp from -1 to 1), `'triangle'`, `'noise'` (smooth
|
|
2455
|
+
* random values) or `'custom'` (drawn with `curve`).
|
|
2456
|
+
*/
|
|
2145
2457
|
type ModulatorShape = 'sine' | 'square' | 'sawtooth' | 'triangle' | 'noise' | 'custom';
|
|
2146
2458
|
/**
|
|
2147
2459
|
* A cyclic value source: a waveform owned by a single parameter modifier and
|
|
@@ -2158,6 +2470,7 @@ type ModulatorShape = 'sine' | 'square' | 'sawtooth' | 'triangle' | 'noise' | 'c
|
|
|
2158
2470
|
* from its own point within the cycle, and stays in `offset ± |amplitude|`.
|
|
2159
2471
|
*/
|
|
2160
2472
|
interface ModulatorOptions {
|
|
2473
|
+
/** The waveform, normalized to run from -1 to 1 before `amplitude` and `offset` apply. */
|
|
2161
2474
|
shape: ModulatorShape;
|
|
2162
2475
|
/**
|
|
2163
2476
|
* What drives the waveform's `t`:
|
|
@@ -2171,6 +2484,7 @@ interface ModulatorOptions {
|
|
|
2171
2484
|
timeSource?: string;
|
|
2172
2485
|
/** Cycles per unit of `timeSource` (per second for `'timeElapsed'`). */
|
|
2173
2486
|
frequency: number;
|
|
2487
|
+
/** How far the output swings from `offset`: it stays within `offset ± |amplitude|`. A negative value flips the wave. */
|
|
2174
2488
|
amplitude: number;
|
|
2175
2489
|
/** Centre value of the oscillation. */
|
|
2176
2490
|
offset: number;
|
|
@@ -2183,6 +2497,10 @@ interface ModulatorOptions {
|
|
|
2183
2497
|
*/
|
|
2184
2498
|
curve?: CurveDefinition;
|
|
2185
2499
|
}
|
|
2500
|
+
/**
|
|
2501
|
+
* What a custom parameter holds: `'continuous'` (any number of its domain),
|
|
2502
|
+
* `'discrete'` (whole numbers) or `'label'` (one of a list of names).
|
|
2503
|
+
*/
|
|
2186
2504
|
type CustomParameterType = 'continuous' | 'discrete' | 'label';
|
|
2187
2505
|
/**
|
|
2188
2506
|
* A value the game sets (`setGlobalParameter`). Just one value, without modes:
|
|
@@ -2191,8 +2509,11 @@ type CustomParameterType = 'continuous' | 'discrete' | 'label';
|
|
|
2191
2509
|
type GlobalParameterOption = {
|
|
2192
2510
|
/** Public name: what the game and every `sourceParameterId` address it by. */
|
|
2193
2511
|
id: string;
|
|
2512
|
+
/** `'continuous'` (any number of the domain), `'discrete'` (whole numbers) or `'label'` (one of a list of names). */
|
|
2194
2513
|
type: CustomParameterType;
|
|
2514
|
+
/** The name a tool shows for it. */
|
|
2195
2515
|
label: string;
|
|
2516
|
+
/** The range of a number, or the names of a `'label'` parameter. */
|
|
2196
2517
|
domain: NumericDomain | string[];
|
|
2197
2518
|
/** Default value; the label index for a `'label'` global. */
|
|
2198
2519
|
value: number;
|
|
@@ -2214,20 +2535,39 @@ type GlobalParameterOption = {
|
|
|
2214
2535
|
* Evaluated per frame against the live source.
|
|
2215
2536
|
*/
|
|
2216
2537
|
type CustomParameterValue = number | RandomValueRange | RandomValueList<number> | ParameterLinkRelation;
|
|
2538
|
+
/** A local parameter: a value declared by the animation that other values can follow. */
|
|
2217
2539
|
type CustomParameterOption = {
|
|
2218
2540
|
/** Public name, unique among the animation's globals and locals. */
|
|
2219
2541
|
id: string;
|
|
2542
|
+
/** `'continuous'` (any number of the domain), `'discrete'` (whole numbers) or `'label'` (one of a list of names). */
|
|
2220
2543
|
type: CustomParameterType;
|
|
2544
|
+
/** The name a tool shows for it. */
|
|
2221
2545
|
label: string;
|
|
2546
|
+
/** The range of a number, or the names of a `'label'` parameter. */
|
|
2222
2547
|
domain: NumericDomain | string[];
|
|
2548
|
+
/** The value, in any of the four modes: Fixed, Range, List or Linked. */
|
|
2223
2549
|
value: CustomParameterValue;
|
|
2224
2550
|
/** Sampling scope for Range / Random list values. Default `'playback'`. */
|
|
2225
2551
|
sampleScope?: CustomParameterSampleScope;
|
|
2226
2552
|
};
|
|
2227
2553
|
|
|
2554
|
+
/**
|
|
2555
|
+
* One stop of a gradient: `[position, color]`. The color is a `0xRRGGBB` number. The position is from 0 to 1
|
|
2556
|
+
* in a `ColorRandomRange`, and in the source parameter's own units in a `ColorGradientDefinition`. Stops go in
|
|
2557
|
+
* non-decreasing order of position.
|
|
2558
|
+
*/
|
|
2228
2559
|
type ColorStop = [number, number];
|
|
2560
|
+
/**
|
|
2561
|
+
* A color that follows a parameter: the live value of the source picks a
|
|
2562
|
+
* position on the gradient, on every frame.
|
|
2563
|
+
*/
|
|
2229
2564
|
interface ColorGradientDefinition {
|
|
2565
|
+
/**
|
|
2566
|
+
* The gradient, as `[position, color]` pairs in non-decreasing order of position: the position is a value
|
|
2567
|
+
* of the source, in its own units, and the color a `0xRRGGBB` number.
|
|
2568
|
+
*/
|
|
2230
2569
|
stops: ColorStop[];
|
|
2570
|
+
/** The source whose value is the position: `lifeProgress` for a color over the particle's life. */
|
|
2231
2571
|
sourceParameterId: string;
|
|
2232
2572
|
}
|
|
2233
2573
|
/**
|
|
@@ -2238,10 +2578,20 @@ interface ColorGradientDefinition {
|
|
|
2238
2578
|
* `sourceParameterId` (that one re-samples every frame against a live source).
|
|
2239
2579
|
*/
|
|
2240
2580
|
interface ColorRandomRange {
|
|
2581
|
+
/** The gradient to pick from, as `[position, color]` pairs. */
|
|
2241
2582
|
stops: ColorStop[];
|
|
2583
|
+
/** How likely each position of the gradient is to be picked: x is the position (0 to 1), y the relative probability. Absent, every position is as likely as any other. */
|
|
2242
2584
|
distribution?: CurveDefinition;
|
|
2585
|
+
/** Which preset `distribution` is, or `custom`. The engine reads `distribution`, not this. */
|
|
2243
2586
|
distributionKind?: ProbabilityCurveKind;
|
|
2244
2587
|
}
|
|
2588
|
+
/**
|
|
2589
|
+
* A color in any of its modes; every color in it is a `0xRRGGBB` number:
|
|
2590
|
+
* - a number: that color, fixed.
|
|
2591
|
+
* - `ColorGradientDefinition`: a gradient that follows a parameter.
|
|
2592
|
+
* - `ColorRandomRange`: a random color of a gradient, frozen at birth.
|
|
2593
|
+
* - `RandomValueList<number>`: one color of a list.
|
|
2594
|
+
*/
|
|
2245
2595
|
type SpawnColor = number | ColorGradientDefinition | ColorRandomRange | RandomValueList<number>;
|
|
2246
2596
|
|
|
2247
|
-
export { type
|
|
2597
|
+
export { type ParameterModifierSource as $, type AnimationDescription as A, type LayerOptionType as B, type CapacityOptions as C, type DiagnosticsPolicy as D, type EmissionOptions as E, LocalDefaultHandle as F, type GlobalParameterOption as G, LocalParameterHandle as H, type InitialStateOptions as I, type ModulatableNumber as J, type KineticsOptions as K, type LayerOptionPath as L, type ModifierBlendMode as M, type ModulatedValue as N, type ModulatorOptions as O, PerseonIntegration as P, type ModulatorShape as Q, type NumberOptions as R, type NumericDomain as S, type OptionNodeKind as T, type OptionStage as U, type OptionStrategy as V, type ParameterDescription as W, ParameterHandle as X, type ParameterInitOptions as Y, type ParameterLinkRelation as Z, type ParameterModifier as _, type AnimationPlayOptions as a, type OptionPathEntry as a$, type ParameterUpdateOptions as a0, type ParticleAnimationOptions as a1, type ParticleEventBinding as a2, type ParticleEventBindings as a3, type ParticleEventTrigger as a4, type ParticleEventsByTrigger as a5, type ParticleHookEmitter as a6, type ParticleHookPlayback as a7, type ParticleHookRandom as a8, ParticleItem as a9, type RandomListState as aA, type RandomValueList as aB, type RandomValueListMode as aC, type RandomValueRange as aD, type RandomnessOptions as aE, type RandomnessSeedMode as aF, type RectangleArea as aG, type RegionBehavior as aH, type RegionOptions as aI, type RingArea as aJ, type ScaleOptions as aK, type ShapeArea as aL, type SingleTextureOption as aM, type SpawnColor as aN, type SpawnNumber as aO, type SpawnPoint as aP, type SpawnPosition as aQ, type SpawnVector as aR, type SpriteAnimationOptions as aS, type SpriteAnimationTexturesOptions as aT, type TextDomain as aU, type TextureElement as aV, type Unsubscribe as aW, type ValueProbability as aX, type VectorValue as aY, EMITTER_EVENT_TRIGGERS as aZ, OPTION_PATH_CATALOG as a_, ParticleLayerView as aa, type ParticleLayerOptions as ab, type ParticleLimitStrategy as ac, type ParticleRegionRef as ad, type ParticleSnapshot as ae, type ParticleSnapshotObject as af, type ParticleSpawnStrategy as ag, type ParticleSpriteAnimationParameters as ah, type PerformanceOptions as ai, PerseonAnimation as aj, type PerseonEvent as ak, PerseonPlayback as al, type PlaybackFinishedReason as am, type PlaybackFinishedResult as an, type PlaybackHost as ao, type PlaybackOptionPath as ap, type PlaybackOptionType as aq, type PlaybackOptions as ar, type PointForceConfig as as, type PointForceFalloff as at, type PointForceMode as au, type PointValue as av, type PolygonArea as aw, type ProbabilityCurveKind as ax, type ProbabilityCurvePreset as ay, type ProbabilityCurvePresetId as az, type AnimationRandomnessOptions as b, type OptionScope as b0, PARTICLE_EVENT_TRIGGERS as b1, findOptionPathEntry as b2, isEmitterEventTrigger as b3, isEventTrigger as b4, isParticleEventTrigger as b5, isValidEventName as b6, type CapsuleArea as c, type CircleArea as d, type ColorGradientDefinition as e, type ColorOptions as f, type ColorRandomRange as g, type ColorStop as h, type CurveDefinition as i, type CustomParameterOption as j, type CustomParameterSampleScope as k, type CustomParameterType as l, type CustomParameterValue as m, type EmissionTransform as n, EmitterView as o, type EmitterEventBinding as p, type EmitterEventBindings as q, type EmitterEventTrigger as r, type EmitterEventsByTrigger as s, type EmitterOptionPath as t, type EmitterOptionType as u, type EmitterOptions as v, type EventTrigger as w, type ExternalForcesFactorOptions as x, type ExternalForcesOptions as y, type ExternalForcesTypes as z };
|