@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
package/dist/pixi-v7/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParticleContainer, Sprite, Container, Ticker, Texture, Spritesheet } from 'pixi.js';
|
|
2
|
-
import { I as IParticleGroup, b as IParticleVisualState, a as IParticleGroupOptions, c as IRenderRootNode, d as IRenderNode, f as IRenderer, e as ITicker, h as IRendererCapabilities, g as ITextureRef, P as ParticleBlendMode, B as BlendModeSupport } from '../rendering-
|
|
3
|
-
export { i as IShape } from '../rendering-
|
|
4
|
-
import { P as PerseonIntegration } from '../colors-
|
|
5
|
-
export { A as AnimationDescription, a as AnimationPlayOptions, b as AnimationRandomnessOptions, C as CapacityOptions, c as CapsuleArea, d as CircleArea, e as ColorGradientDefinition, f as ColorOptions, g as ColorRandomRange, h as ColorStop, i as CurveDefinition, j as CustomParameterOption, k as CustomParameterSampleScope, l as CustomParameterType, m as CustomParameterValue, D as DiagnosticsPolicy, E as EmissionOptions, n as EmissionTransform, o as Emitter, p as EmitterEventBinding, q as EmitterEventBindings, r as EmitterEventTrigger, s as EmitterEventsByTrigger, t as EmitterOptionPath, u as EmitterOptionType, v as EmitterOptions, w as EventTrigger, x as ExternalForcesFactorOptions, y as
|
|
2
|
+
import { I as IParticleGroup, b as IParticleVisualState, a as IParticleGroupOptions, c as IRenderRootNode, d as IRenderNode, f as IRenderer, e as ITicker, h as IRendererCapabilities, g as ITextureRef, P as ParticleBlendMode, B as BlendModeSupport } from '../rendering-dYQXmGTV.cjs';
|
|
3
|
+
export { i as IShape } from '../rendering-dYQXmGTV.cjs';
|
|
4
|
+
import { P as PerseonIntegration } from '../colors-CCeWL9q4.cjs';
|
|
5
|
+
export { A as AnimationDescription, a as AnimationPlayOptions, b as AnimationRandomnessOptions, C as CapacityOptions, c as CapsuleArea, d as CircleArea, e as ColorGradientDefinition, f as ColorOptions, g as ColorRandomRange, h as ColorStop, i as CurveDefinition, j as CustomParameterOption, k as CustomParameterSampleScope, l as CustomParameterType, m as CustomParameterValue, D as DiagnosticsPolicy, E as EmissionOptions, n as EmissionTransform, o as Emitter, p as EmitterEventBinding, q as EmitterEventBindings, r as EmitterEventTrigger, s as EmitterEventsByTrigger, t as EmitterOptionPath, u as EmitterOptionType, v as EmitterOptions, w as EventTrigger, x as ExternalForcesFactorOptions, y as ExternalForcesOptions, z as ExternalForcesTypes, G as GlobalParameterOption, I as InitialStateOptions, K as KineticsOptions, L as LayerOptionPath, B as LayerOptionType, F as LocalDefaultHandle, H as LocalParameterHandle, M as ModifierBlendMode, J as ModulatableNumber, N as ModulatedValue, O as ModulatorOptions, Q as ModulatorShape, R as NumberOptions, S as NumericDomain, T as OptionNodeKind, U as OptionStage, V as OptionStrategy, W as ParameterDescription, X as ParameterHandle, Y as ParameterInitOptions, Z as ParameterLinkRelation, _ as ParameterModifier, $ as ParameterModifierSource, a0 as ParameterUpdateOptions, a1 as ParticleAnimationOptions, a2 as ParticleEventBinding, a3 as ParticleEventBindings, a4 as ParticleEventTrigger, a5 as ParticleEventsByTrigger, a6 as ParticleHookEmitter, a7 as ParticleHookPlayback, a8 as ParticleHookRandom, a9 as ParticleItem, aa as ParticleLayer, ab as ParticleLayerOptions, ac as ParticleLimitStrategy, ad as ParticleRegionRef, ae as ParticleSnapshot, af as ParticleSnapshotObject, ag as ParticleSpawnStrategy, ah as ParticleSpriteAnimationParameters, ai as PerformanceOptions, aj as PerseonAnimation, ak as PerseonEvent, al as PerseonPlayback, am as PlaybackFinishedReason, an as PlaybackFinishedResult, ao as PlaybackHost, ap as PlaybackOptionPath, aq as PlaybackOptionType, ar as PlaybackOptions, as as PointForceConfig, at as PointForceFalloff, au as PointForceMode, av as PointValue, aw as PolygonArea, ax as ProbabilityCurveKind, ay as ProbabilityCurvePreset, az as ProbabilityCurvePresetId, aA as RandomListState, aB as RandomValueList, aC as RandomValueListMode, aD as RandomValueRange, aE as RandomnessOptions, aF as RandomnessSeedMode, aG as RectangleArea, aH as RegionBehavior, aI as RegionOptions, aJ as RingArea, aK as ScaleOptions, aL as ShapeArea, aM as SingleTextureOption, aN as SpawnColor, aO as SpawnNumber, aP as SpawnPoint, aQ as SpawnPosition, aR as SpawnVector, aS as SpriteAnimationOptions, aT as SpriteAnimationTexturesOptions, aU as TextDomain, aV as TextureElement, aW as Unsubscribe, aX as ValueProbability, aY as VectorValue } from '../colors-CCeWL9q4.cjs';
|
|
6
6
|
export { PerseonConfigError, parseAnimationOptions } from '../core/index.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,18 +16,28 @@ export { PerseonConfigError, parseAnimationOptions } from '../core/index.cjs';
|
|
|
16
16
|
* - Alpha and tint are independent properties (no encoded color).
|
|
17
17
|
*/
|
|
18
18
|
declare class PixiV7ParticleGroup implements IParticleGroup {
|
|
19
|
+
/**
|
|
20
|
+
* The Pixi `ParticleContainer` that draws this layer's sprites. The render node that created the group adds it to its own container; `destroy` destroys it.
|
|
21
|
+
*/
|
|
19
22
|
readonly container: ParticleContainer;
|
|
23
|
+
/** Pairs each engine particle with the `Sprite` that mirrors it inside the container. */
|
|
20
24
|
protected _mirror: Map<IParticleVisualState, Sprite>;
|
|
21
25
|
get size(): number;
|
|
22
26
|
/** On the container: hidden, its sprites are not drawn and stay in it. */
|
|
23
27
|
get visible(): boolean;
|
|
24
28
|
set visible(value: boolean);
|
|
29
|
+
/**
|
|
30
|
+
* Creates an auto-resizing `ParticleContainer`. Only the properties that `options.dynamicProperties` marks as changing (plus position, always) are re-uploaded each frame, and `options.blendMode` (`normal` when omitted) becomes the container's numeric blend mode. Modes v7 cannot blend on WebGL draw as `normal`; `PixiV7RendererCapabilities` reports them as `unsupported`.
|
|
31
|
+
*
|
|
32
|
+
* @param options - The layer's dynamic properties and blend mode.
|
|
33
|
+
*/
|
|
25
34
|
constructor(options: IParticleGroupOptions);
|
|
26
35
|
addParticle(particle: IParticleVisualState, index: number): void;
|
|
27
36
|
removeParticle(particle: IParticleVisualState): void;
|
|
28
37
|
removeAll(): void;
|
|
29
38
|
syncFrame(): void;
|
|
30
39
|
destroy(): void;
|
|
40
|
+
/** Copies the engine particle's position, scale, rotation, anchor, alpha, tint and texture onto its `Sprite`. */
|
|
31
41
|
protected _writeState(p: IParticleVisualState, sprite: Sprite): void;
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -40,18 +50,34 @@ declare class PixiV7ParticleGroup implements IParticleGroup {
|
|
|
40
50
|
* a renderer tearing down after the engine already did must be a no-op.
|
|
41
51
|
*/
|
|
42
52
|
declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
53
|
+
/**
|
|
54
|
+
* The Pixi `Container` this node wraps. It is created with the node and destroyed when the node is destroyed.
|
|
55
|
+
*/
|
|
43
56
|
readonly container: Container;
|
|
57
|
+
/** The particle groups created through this node and not yet removed with `destroyParticleGroup`. They are destroyed with it. */
|
|
44
58
|
protected _groups: PixiV7ParticleGroup[];
|
|
45
59
|
/** Child nodes (an emitter's, when this is a playback root). */
|
|
46
60
|
protected _children: PixiV7RenderNode[];
|
|
61
|
+
/**
|
|
62
|
+
* Callback run once, from `destroy`, so whoever created this node (the renderer for a root, the parent node for a child) stops tracking it.
|
|
63
|
+
*/
|
|
47
64
|
protected _release: (node: PixiV7RenderNode) => void;
|
|
65
|
+
/** Set by the first `destroy`, so that later calls do nothing. */
|
|
48
66
|
protected _destroyed: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Creates the node with an empty Pixi container.
|
|
69
|
+
*
|
|
70
|
+
* @param release - Called with this node when it is destroyed, so its creator can drop it.
|
|
71
|
+
*/
|
|
49
72
|
constructor(release: (node: PixiV7RenderNode) => void);
|
|
50
73
|
get hostDestroyed(): boolean;
|
|
74
|
+
/** Whether the node's container is shown. Hidden, Pixi draws neither it nor anything under it. */
|
|
51
75
|
get visible(): boolean;
|
|
52
76
|
set visible(value: boolean);
|
|
77
|
+
/** Horizontal position of the node's container, in its parent's local coordinates. */
|
|
53
78
|
get x(): number;
|
|
54
79
|
set x(value: number);
|
|
80
|
+
/** Vertical position of the node's container, in its parent's local coordinates. */
|
|
55
81
|
get y(): number;
|
|
56
82
|
set y(value: number);
|
|
57
83
|
/**
|
|
@@ -65,6 +91,9 @@ declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
|
65
91
|
mount(parent: Container): void;
|
|
66
92
|
unmount(): void;
|
|
67
93
|
createChildNode(): IRenderNode;
|
|
94
|
+
/**
|
|
95
|
+
* Drops a destroyed child node from this node's list. It is the release callback `createChildNode` hands to each child.
|
|
96
|
+
*/
|
|
68
97
|
protected _releaseChild(node: PixiV7RenderNode): void;
|
|
69
98
|
createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
|
|
70
99
|
setGroupIndex(group: IParticleGroup, index: number): void;
|
|
@@ -72,6 +101,7 @@ declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
|
72
101
|
destroy(): void;
|
|
73
102
|
}
|
|
74
103
|
|
|
104
|
+
/** Options for `PixiV7Renderer`. */
|
|
75
105
|
interface PixiV7RendererOptions {
|
|
76
106
|
/** Optional Pixi v7 `Ticker`. Falls back to `Ticker.shared` when omitted. */
|
|
77
107
|
ticker?: Ticker;
|
|
@@ -87,19 +117,38 @@ declare class PixiV7Renderer implements IRenderer<Container> {
|
|
|
87
117
|
readonly ticker: ITicker;
|
|
88
118
|
/** What this backend does with each blend mode — see `IRendererCapabilities`. */
|
|
89
119
|
readonly capabilities: IRendererCapabilities;
|
|
120
|
+
/**
|
|
121
|
+
* Textures already resolved, keyed by the `source` value given to `resolveTexture`. Emptied by `clearTextureCache` and `destroy`.
|
|
122
|
+
*/
|
|
90
123
|
protected _textureCache: Map<unknown, ITextureRef>;
|
|
124
|
+
/**
|
|
125
|
+
* The root nodes this renderer created and that are still alive, so `destroy` can tear them down. A node leaves the list when it is destroyed.
|
|
126
|
+
*/
|
|
91
127
|
protected _nodes: PixiV7RenderNode[];
|
|
128
|
+
/**
|
|
129
|
+
* Creates the renderer, wrapping `options.ticker` (or Pixi's shared ticker) in an adapter.
|
|
130
|
+
*
|
|
131
|
+
* @param options - Optional settings; see `PixiV7RendererOptions`.
|
|
132
|
+
*/
|
|
92
133
|
constructor(options?: PixiV7RendererOptions);
|
|
93
134
|
/** Detached: the caller mounts it where the animation should appear. */
|
|
94
135
|
createRootNode(): IRenderRootNode<Container>;
|
|
95
136
|
/** Called by a node when it is destroyed, so the renderer holds only live ones. */
|
|
96
137
|
protected _releaseNode(node: PixiV7RenderNode): void;
|
|
138
|
+
/**
|
|
139
|
+
* The texture a scene's `texture.source` names. The id must have been published to
|
|
140
|
+
* Pixi's `Assets.cache` beforehand (see `PixiV7ParticleAtlas`); an unknown id, or a
|
|
141
|
+
* source that is not a string, resolves to an empty texture. Answers are memoized
|
|
142
|
+
* until `clearTextureCache`, so an id resolved before it was published stays empty
|
|
143
|
+
* until then.
|
|
144
|
+
*/
|
|
97
145
|
resolveTexture(source: unknown): ITextureRef;
|
|
98
146
|
/** See `IRenderer.clearTextureCache` — what a host calls after republishing an atlas. */
|
|
99
147
|
clearTextureCache(): void;
|
|
100
148
|
destroy(): void;
|
|
101
149
|
}
|
|
102
150
|
|
|
151
|
+
/** Options for the `Perseon` constructor. Both are optional, so `new Perseon()` works with Pixi's shared ticker. */
|
|
103
152
|
interface PerseonOptions {
|
|
104
153
|
/**
|
|
105
154
|
* What every animation runs off: the Pixi v7 `Ticker` — `app.ticker`,
|
|
@@ -138,6 +187,12 @@ interface PerseonOptions {
|
|
|
138
187
|
declare class Perseon extends PerseonIntegration<Container> {
|
|
139
188
|
/** Re-typed, not re-assigned — see the v8 integration. */
|
|
140
189
|
readonly renderer: PixiV7Renderer;
|
|
190
|
+
/**
|
|
191
|
+
* Creates the integration for PixiJS v7. A Pixi `Ticker` is wrapped by the renderer this builds; any other
|
|
192
|
+
* `ITicker` is used as the frame source as it is.
|
|
193
|
+
*
|
|
194
|
+
* @param options - Optional settings; see `PerseonOptions`.
|
|
195
|
+
*/
|
|
141
196
|
constructor(options?: PerseonOptions);
|
|
142
197
|
}
|
|
143
198
|
|
|
@@ -148,8 +203,18 @@ declare class Perseon extends PerseonIntegration<Container> {
|
|
|
148
203
|
* engine its expected ms-based delta.
|
|
149
204
|
*/
|
|
150
205
|
declare class PixiV7TickerAdapter implements ITicker {
|
|
206
|
+
/** The Pixi ticker being wrapped. */
|
|
151
207
|
protected _ticker: Ticker;
|
|
208
|
+
/**
|
|
209
|
+
* Pairs each function given to `add` with the wrapper registered on the Pixi ticker, so `remove` can unregister that same wrapper.
|
|
210
|
+
*/
|
|
152
211
|
protected _wrapped: Map<(deltaMS: number) => void, () => void>;
|
|
212
|
+
/**
|
|
213
|
+
* Wraps a Pixi ticker. The constructor neither starts nor stops it, but Pixi starts a ticker whose
|
|
214
|
+
* `autoStart` is set (such as `Ticker.shared`) when `add` registers the first function.
|
|
215
|
+
*
|
|
216
|
+
* @param ticker - The Pixi `Ticker` whose frames drive the functions added to this adapter.
|
|
217
|
+
*/
|
|
153
218
|
constructor(ticker: Ticker);
|
|
154
219
|
add(fn: (deltaMS: number) => void): void;
|
|
155
220
|
remove(fn: (deltaMS: number) => void): void;
|
|
@@ -197,6 +262,15 @@ declare const textureFromSource: (source: unknown) => Texture;
|
|
|
197
262
|
* break the declarations for the other major. Structurally the same as both.
|
|
198
263
|
*/
|
|
199
264
|
interface PixiV7SpritesheetData {
|
|
265
|
+
/**
|
|
266
|
+
* The frames of the atlas, keyed by frame id: the ids a scene's `texture.source` names.
|
|
267
|
+
* Each entry is laid out as in Pixi's spritesheet JSON. `frame` is the frame's rectangle
|
|
268
|
+
* in the sheet image, with `x`, `y`, `w` and `h` in pixels. `sourceSize` is the sprite's
|
|
269
|
+
* size before trimming and `spriteSourceSize` the rectangle the frame occupies inside it.
|
|
270
|
+
* `trimmed` and `rotated` say whether the frame was trimmed or rotated when packed.
|
|
271
|
+
* `anchor` is the frame's default anchor (particles use their own anchor instead) and
|
|
272
|
+
* `borders` its 9-slice borders (`left`, `top`, `right`, `bottom`).
|
|
273
|
+
*/
|
|
200
274
|
frames: Record<string, {
|
|
201
275
|
frame: {
|
|
202
276
|
x: number;
|
|
@@ -227,27 +301,43 @@ interface PixiV7SpritesheetData {
|
|
|
227
301
|
bottom: number;
|
|
228
302
|
};
|
|
229
303
|
}>;
|
|
304
|
+
/** Named animations: each name maps to the ordered list of frame ids that make it up. */
|
|
230
305
|
animations?: Record<string, string[]>;
|
|
306
|
+
/**
|
|
307
|
+
* Metadata about the sheet and its image, as in Pixi's spritesheet format. Only `scale`
|
|
308
|
+
* is required.
|
|
309
|
+
*/
|
|
231
310
|
meta: {
|
|
311
|
+
/** Name of the tool that packed the sheet. */
|
|
232
312
|
app?: string;
|
|
313
|
+
/** Pixel format of the sheet image, as the packing tool reports it. */
|
|
233
314
|
format?: string;
|
|
315
|
+
/** Named frame ranges, each with a first (`from`) and last (`to`) frame number and a `direction`. */
|
|
234
316
|
frameTags?: {
|
|
235
317
|
from: number;
|
|
236
318
|
name: string;
|
|
237
319
|
to: number;
|
|
238
320
|
direction: string;
|
|
239
321
|
}[];
|
|
322
|
+
/** File name or URL of the sheet image. `load` does not read it: the image is its own argument. */
|
|
240
323
|
image?: string;
|
|
324
|
+
/** Layer information from the packing tool: a name, blend mode and opacity per layer. */
|
|
241
325
|
layers?: {
|
|
242
326
|
blendMode: string;
|
|
243
327
|
name: string;
|
|
244
328
|
opacity: number;
|
|
245
329
|
}[];
|
|
330
|
+
/** Resolution of the sheet image, as a number or a numeric string. Pixi reads it with `parseFloat`. */
|
|
246
331
|
scale: number | string;
|
|
332
|
+
/** Size of the sheet image in pixels. */
|
|
247
333
|
size?: {
|
|
248
334
|
w: number;
|
|
249
335
|
h: number;
|
|
250
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* Named slices defined in the packing tool, each with a `color` and a list of `keys`;
|
|
339
|
+
* each key has a `frame` number and a `bounds` rectangle (`x`, `y`, `w`, `h`).
|
|
340
|
+
*/
|
|
251
341
|
slices?: {
|
|
252
342
|
color: string;
|
|
253
343
|
name: string;
|
|
@@ -261,7 +351,9 @@ interface PixiV7SpritesheetData {
|
|
|
261
351
|
};
|
|
262
352
|
}[];
|
|
263
353
|
}[];
|
|
354
|
+
/** Other sheets of the same multi-pack set. `load` does not follow them; load each sheet into its own atlas. */
|
|
264
355
|
related_multi_packs?: string[];
|
|
356
|
+
/** Version of the packing tool or format that wrote the sheet. */
|
|
265
357
|
version?: string;
|
|
266
358
|
};
|
|
267
359
|
}
|
|
@@ -275,8 +367,9 @@ declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
|
275
367
|
* `texture.source` names a frame the host is expected to have registered
|
|
276
368
|
* beforehand, which is what lets one atlas serve every particle in the scene
|
|
277
369
|
* instead of embedding the same image once per use. This class is the other
|
|
278
|
-
* half of that contract — give it the `.png` + `.json` pair
|
|
279
|
-
* and the ids in the scene
|
|
370
|
+
* half of that contract — give it the `.png` + `.json` pair that Perseon
|
|
371
|
+
* Particle Studio exports, or any Pixi spritesheet, and the ids in the scene
|
|
372
|
+
* file resolve.
|
|
280
373
|
*
|
|
281
374
|
* `Spritesheet.parse()` also adds every frame to Pixi's global texture cache,
|
|
282
375
|
* which `Texture.from` reads; what `textureFromSource` reads is `Assets.cache`, so
|
|
@@ -302,7 +395,9 @@ declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
|
302
395
|
* object URL must be read into a data URL (or a `Texture`) first.
|
|
303
396
|
*/
|
|
304
397
|
declare class PixiV7ParticleAtlas {
|
|
398
|
+
/** The key the spritesheet is published under in `Assets.cache`. */
|
|
305
399
|
protected _cacheKey: string;
|
|
400
|
+
/** The sheet published by the last successful `load`; cleared by `destroy`. */
|
|
306
401
|
protected _spritesheet?: Spritesheet;
|
|
307
402
|
/** URL this instance acquired through `Assets`, so it releases exactly what it took. */
|
|
308
403
|
protected _loadedImageUrl?: string;
|
|
@@ -312,7 +407,11 @@ declare class PixiV7ParticleAtlas {
|
|
|
312
407
|
* publish its sheet over the winner's and leak the winner's.
|
|
313
408
|
*/
|
|
314
409
|
protected _loadToken: number;
|
|
315
|
-
/**
|
|
410
|
+
/**
|
|
411
|
+
* Creates an empty atlas; nothing is published until `load`.
|
|
412
|
+
*
|
|
413
|
+
* @param cacheKey - The key the spritesheet is registered under in `Assets.cache`; give distinct keys to atlases that coexist.
|
|
414
|
+
*/
|
|
316
415
|
constructor(cacheKey?: string);
|
|
317
416
|
/** The spritesheet published by the last successful `load`, or `undefined` before one or after `destroy`. */
|
|
318
417
|
get spritesheet(): Spritesheet | undefined;
|
package/dist/pixi-v7/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParticleContainer, Sprite, Container, Ticker, Texture, Spritesheet } from 'pixi.js';
|
|
2
|
-
import { I as IParticleGroup, b as IParticleVisualState, a as IParticleGroupOptions, c as IRenderRootNode, d as IRenderNode, f as IRenderer, e as ITicker, h as IRendererCapabilities, g as ITextureRef, P as ParticleBlendMode, B as BlendModeSupport } from '../rendering-
|
|
3
|
-
export { i as IShape } from '../rendering-
|
|
4
|
-
import { P as PerseonIntegration } from '../colors-
|
|
5
|
-
export { A as AnimationDescription, a as AnimationPlayOptions, b as AnimationRandomnessOptions, C as CapacityOptions, c as CapsuleArea, d as CircleArea, e as ColorGradientDefinition, f as ColorOptions, g as ColorRandomRange, h as ColorStop, i as CurveDefinition, j as CustomParameterOption, k as CustomParameterSampleScope, l as CustomParameterType, m as CustomParameterValue, D as DiagnosticsPolicy, E as EmissionOptions, n as EmissionTransform, o as Emitter, p as EmitterEventBinding, q as EmitterEventBindings, r as EmitterEventTrigger, s as EmitterEventsByTrigger, t as EmitterOptionPath, u as EmitterOptionType, v as EmitterOptions, w as EventTrigger, x as ExternalForcesFactorOptions, y as
|
|
2
|
+
import { I as IParticleGroup, b as IParticleVisualState, a as IParticleGroupOptions, c as IRenderRootNode, d as IRenderNode, f as IRenderer, e as ITicker, h as IRendererCapabilities, g as ITextureRef, P as ParticleBlendMode, B as BlendModeSupport } from '../rendering-dYQXmGTV.js';
|
|
3
|
+
export { i as IShape } from '../rendering-dYQXmGTV.js';
|
|
4
|
+
import { P as PerseonIntegration } from '../colors-CGWrMf4V.js';
|
|
5
|
+
export { A as AnimationDescription, a as AnimationPlayOptions, b as AnimationRandomnessOptions, C as CapacityOptions, c as CapsuleArea, d as CircleArea, e as ColorGradientDefinition, f as ColorOptions, g as ColorRandomRange, h as ColorStop, i as CurveDefinition, j as CustomParameterOption, k as CustomParameterSampleScope, l as CustomParameterType, m as CustomParameterValue, D as DiagnosticsPolicy, E as EmissionOptions, n as EmissionTransform, o as Emitter, p as EmitterEventBinding, q as EmitterEventBindings, r as EmitterEventTrigger, s as EmitterEventsByTrigger, t as EmitterOptionPath, u as EmitterOptionType, v as EmitterOptions, w as EventTrigger, x as ExternalForcesFactorOptions, y as ExternalForcesOptions, z as ExternalForcesTypes, G as GlobalParameterOption, I as InitialStateOptions, K as KineticsOptions, L as LayerOptionPath, B as LayerOptionType, F as LocalDefaultHandle, H as LocalParameterHandle, M as ModifierBlendMode, J as ModulatableNumber, N as ModulatedValue, O as ModulatorOptions, Q as ModulatorShape, R as NumberOptions, S as NumericDomain, T as OptionNodeKind, U as OptionStage, V as OptionStrategy, W as ParameterDescription, X as ParameterHandle, Y as ParameterInitOptions, Z as ParameterLinkRelation, _ as ParameterModifier, $ as ParameterModifierSource, a0 as ParameterUpdateOptions, a1 as ParticleAnimationOptions, a2 as ParticleEventBinding, a3 as ParticleEventBindings, a4 as ParticleEventTrigger, a5 as ParticleEventsByTrigger, a6 as ParticleHookEmitter, a7 as ParticleHookPlayback, a8 as ParticleHookRandom, a9 as ParticleItem, aa as ParticleLayer, ab as ParticleLayerOptions, ac as ParticleLimitStrategy, ad as ParticleRegionRef, ae as ParticleSnapshot, af as ParticleSnapshotObject, ag as ParticleSpawnStrategy, ah as ParticleSpriteAnimationParameters, ai as PerformanceOptions, aj as PerseonAnimation, ak as PerseonEvent, al as PerseonPlayback, am as PlaybackFinishedReason, an as PlaybackFinishedResult, ao as PlaybackHost, ap as PlaybackOptionPath, aq as PlaybackOptionType, ar as PlaybackOptions, as as PointForceConfig, at as PointForceFalloff, au as PointForceMode, av as PointValue, aw as PolygonArea, ax as ProbabilityCurveKind, ay as ProbabilityCurvePreset, az as ProbabilityCurvePresetId, aA as RandomListState, aB as RandomValueList, aC as RandomValueListMode, aD as RandomValueRange, aE as RandomnessOptions, aF as RandomnessSeedMode, aG as RectangleArea, aH as RegionBehavior, aI as RegionOptions, aJ as RingArea, aK as ScaleOptions, aL as ShapeArea, aM as SingleTextureOption, aN as SpawnColor, aO as SpawnNumber, aP as SpawnPoint, aQ as SpawnPosition, aR as SpawnVector, aS as SpriteAnimationOptions, aT as SpriteAnimationTexturesOptions, aU as TextDomain, aV as TextureElement, aW as Unsubscribe, aX as ValueProbability, aY as VectorValue } from '../colors-CGWrMf4V.js';
|
|
6
6
|
export { PerseonConfigError, parseAnimationOptions } from '../core/index.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,18 +16,28 @@ export { PerseonConfigError, parseAnimationOptions } from '../core/index.js';
|
|
|
16
16
|
* - Alpha and tint are independent properties (no encoded color).
|
|
17
17
|
*/
|
|
18
18
|
declare class PixiV7ParticleGroup implements IParticleGroup {
|
|
19
|
+
/**
|
|
20
|
+
* The Pixi `ParticleContainer` that draws this layer's sprites. The render node that created the group adds it to its own container; `destroy` destroys it.
|
|
21
|
+
*/
|
|
19
22
|
readonly container: ParticleContainer;
|
|
23
|
+
/** Pairs each engine particle with the `Sprite` that mirrors it inside the container. */
|
|
20
24
|
protected _mirror: Map<IParticleVisualState, Sprite>;
|
|
21
25
|
get size(): number;
|
|
22
26
|
/** On the container: hidden, its sprites are not drawn and stay in it. */
|
|
23
27
|
get visible(): boolean;
|
|
24
28
|
set visible(value: boolean);
|
|
29
|
+
/**
|
|
30
|
+
* Creates an auto-resizing `ParticleContainer`. Only the properties that `options.dynamicProperties` marks as changing (plus position, always) are re-uploaded each frame, and `options.blendMode` (`normal` when omitted) becomes the container's numeric blend mode. Modes v7 cannot blend on WebGL draw as `normal`; `PixiV7RendererCapabilities` reports them as `unsupported`.
|
|
31
|
+
*
|
|
32
|
+
* @param options - The layer's dynamic properties and blend mode.
|
|
33
|
+
*/
|
|
25
34
|
constructor(options: IParticleGroupOptions);
|
|
26
35
|
addParticle(particle: IParticleVisualState, index: number): void;
|
|
27
36
|
removeParticle(particle: IParticleVisualState): void;
|
|
28
37
|
removeAll(): void;
|
|
29
38
|
syncFrame(): void;
|
|
30
39
|
destroy(): void;
|
|
40
|
+
/** Copies the engine particle's position, scale, rotation, anchor, alpha, tint and texture onto its `Sprite`. */
|
|
31
41
|
protected _writeState(p: IParticleVisualState, sprite: Sprite): void;
|
|
32
42
|
}
|
|
33
43
|
|
|
@@ -40,18 +50,34 @@ declare class PixiV7ParticleGroup implements IParticleGroup {
|
|
|
40
50
|
* a renderer tearing down after the engine already did must be a no-op.
|
|
41
51
|
*/
|
|
42
52
|
declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
53
|
+
/**
|
|
54
|
+
* The Pixi `Container` this node wraps. It is created with the node and destroyed when the node is destroyed.
|
|
55
|
+
*/
|
|
43
56
|
readonly container: Container;
|
|
57
|
+
/** The particle groups created through this node and not yet removed with `destroyParticleGroup`. They are destroyed with it. */
|
|
44
58
|
protected _groups: PixiV7ParticleGroup[];
|
|
45
59
|
/** Child nodes (an emitter's, when this is a playback root). */
|
|
46
60
|
protected _children: PixiV7RenderNode[];
|
|
61
|
+
/**
|
|
62
|
+
* Callback run once, from `destroy`, so whoever created this node (the renderer for a root, the parent node for a child) stops tracking it.
|
|
63
|
+
*/
|
|
47
64
|
protected _release: (node: PixiV7RenderNode) => void;
|
|
65
|
+
/** Set by the first `destroy`, so that later calls do nothing. */
|
|
48
66
|
protected _destroyed: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Creates the node with an empty Pixi container.
|
|
69
|
+
*
|
|
70
|
+
* @param release - Called with this node when it is destroyed, so its creator can drop it.
|
|
71
|
+
*/
|
|
49
72
|
constructor(release: (node: PixiV7RenderNode) => void);
|
|
50
73
|
get hostDestroyed(): boolean;
|
|
74
|
+
/** Whether the node's container is shown. Hidden, Pixi draws neither it nor anything under it. */
|
|
51
75
|
get visible(): boolean;
|
|
52
76
|
set visible(value: boolean);
|
|
77
|
+
/** Horizontal position of the node's container, in its parent's local coordinates. */
|
|
53
78
|
get x(): number;
|
|
54
79
|
set x(value: number);
|
|
80
|
+
/** Vertical position of the node's container, in its parent's local coordinates. */
|
|
55
81
|
get y(): number;
|
|
56
82
|
set y(value: number);
|
|
57
83
|
/**
|
|
@@ -65,6 +91,9 @@ declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
|
65
91
|
mount(parent: Container): void;
|
|
66
92
|
unmount(): void;
|
|
67
93
|
createChildNode(): IRenderNode;
|
|
94
|
+
/**
|
|
95
|
+
* Drops a destroyed child node from this node's list. It is the release callback `createChildNode` hands to each child.
|
|
96
|
+
*/
|
|
68
97
|
protected _releaseChild(node: PixiV7RenderNode): void;
|
|
69
98
|
createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
|
|
70
99
|
setGroupIndex(group: IParticleGroup, index: number): void;
|
|
@@ -72,6 +101,7 @@ declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
|
72
101
|
destroy(): void;
|
|
73
102
|
}
|
|
74
103
|
|
|
104
|
+
/** Options for `PixiV7Renderer`. */
|
|
75
105
|
interface PixiV7RendererOptions {
|
|
76
106
|
/** Optional Pixi v7 `Ticker`. Falls back to `Ticker.shared` when omitted. */
|
|
77
107
|
ticker?: Ticker;
|
|
@@ -87,19 +117,38 @@ declare class PixiV7Renderer implements IRenderer<Container> {
|
|
|
87
117
|
readonly ticker: ITicker;
|
|
88
118
|
/** What this backend does with each blend mode — see `IRendererCapabilities`. */
|
|
89
119
|
readonly capabilities: IRendererCapabilities;
|
|
120
|
+
/**
|
|
121
|
+
* Textures already resolved, keyed by the `source` value given to `resolveTexture`. Emptied by `clearTextureCache` and `destroy`.
|
|
122
|
+
*/
|
|
90
123
|
protected _textureCache: Map<unknown, ITextureRef>;
|
|
124
|
+
/**
|
|
125
|
+
* The root nodes this renderer created and that are still alive, so `destroy` can tear them down. A node leaves the list when it is destroyed.
|
|
126
|
+
*/
|
|
91
127
|
protected _nodes: PixiV7RenderNode[];
|
|
128
|
+
/**
|
|
129
|
+
* Creates the renderer, wrapping `options.ticker` (or Pixi's shared ticker) in an adapter.
|
|
130
|
+
*
|
|
131
|
+
* @param options - Optional settings; see `PixiV7RendererOptions`.
|
|
132
|
+
*/
|
|
92
133
|
constructor(options?: PixiV7RendererOptions);
|
|
93
134
|
/** Detached: the caller mounts it where the animation should appear. */
|
|
94
135
|
createRootNode(): IRenderRootNode<Container>;
|
|
95
136
|
/** Called by a node when it is destroyed, so the renderer holds only live ones. */
|
|
96
137
|
protected _releaseNode(node: PixiV7RenderNode): void;
|
|
138
|
+
/**
|
|
139
|
+
* The texture a scene's `texture.source` names. The id must have been published to
|
|
140
|
+
* Pixi's `Assets.cache` beforehand (see `PixiV7ParticleAtlas`); an unknown id, or a
|
|
141
|
+
* source that is not a string, resolves to an empty texture. Answers are memoized
|
|
142
|
+
* until `clearTextureCache`, so an id resolved before it was published stays empty
|
|
143
|
+
* until then.
|
|
144
|
+
*/
|
|
97
145
|
resolveTexture(source: unknown): ITextureRef;
|
|
98
146
|
/** See `IRenderer.clearTextureCache` — what a host calls after republishing an atlas. */
|
|
99
147
|
clearTextureCache(): void;
|
|
100
148
|
destroy(): void;
|
|
101
149
|
}
|
|
102
150
|
|
|
151
|
+
/** Options for the `Perseon` constructor. Both are optional, so `new Perseon()` works with Pixi's shared ticker. */
|
|
103
152
|
interface PerseonOptions {
|
|
104
153
|
/**
|
|
105
154
|
* What every animation runs off: the Pixi v7 `Ticker` — `app.ticker`,
|
|
@@ -138,6 +187,12 @@ interface PerseonOptions {
|
|
|
138
187
|
declare class Perseon extends PerseonIntegration<Container> {
|
|
139
188
|
/** Re-typed, not re-assigned — see the v8 integration. */
|
|
140
189
|
readonly renderer: PixiV7Renderer;
|
|
190
|
+
/**
|
|
191
|
+
* Creates the integration for PixiJS v7. A Pixi `Ticker` is wrapped by the renderer this builds; any other
|
|
192
|
+
* `ITicker` is used as the frame source as it is.
|
|
193
|
+
*
|
|
194
|
+
* @param options - Optional settings; see `PerseonOptions`.
|
|
195
|
+
*/
|
|
141
196
|
constructor(options?: PerseonOptions);
|
|
142
197
|
}
|
|
143
198
|
|
|
@@ -148,8 +203,18 @@ declare class Perseon extends PerseonIntegration<Container> {
|
|
|
148
203
|
* engine its expected ms-based delta.
|
|
149
204
|
*/
|
|
150
205
|
declare class PixiV7TickerAdapter implements ITicker {
|
|
206
|
+
/** The Pixi ticker being wrapped. */
|
|
151
207
|
protected _ticker: Ticker;
|
|
208
|
+
/**
|
|
209
|
+
* Pairs each function given to `add` with the wrapper registered on the Pixi ticker, so `remove` can unregister that same wrapper.
|
|
210
|
+
*/
|
|
152
211
|
protected _wrapped: Map<(deltaMS: number) => void, () => void>;
|
|
212
|
+
/**
|
|
213
|
+
* Wraps a Pixi ticker. The constructor neither starts nor stops it, but Pixi starts a ticker whose
|
|
214
|
+
* `autoStart` is set (such as `Ticker.shared`) when `add` registers the first function.
|
|
215
|
+
*
|
|
216
|
+
* @param ticker - The Pixi `Ticker` whose frames drive the functions added to this adapter.
|
|
217
|
+
*/
|
|
153
218
|
constructor(ticker: Ticker);
|
|
154
219
|
add(fn: (deltaMS: number) => void): void;
|
|
155
220
|
remove(fn: (deltaMS: number) => void): void;
|
|
@@ -197,6 +262,15 @@ declare const textureFromSource: (source: unknown) => Texture;
|
|
|
197
262
|
* break the declarations for the other major. Structurally the same as both.
|
|
198
263
|
*/
|
|
199
264
|
interface PixiV7SpritesheetData {
|
|
265
|
+
/**
|
|
266
|
+
* The frames of the atlas, keyed by frame id: the ids a scene's `texture.source` names.
|
|
267
|
+
* Each entry is laid out as in Pixi's spritesheet JSON. `frame` is the frame's rectangle
|
|
268
|
+
* in the sheet image, with `x`, `y`, `w` and `h` in pixels. `sourceSize` is the sprite's
|
|
269
|
+
* size before trimming and `spriteSourceSize` the rectangle the frame occupies inside it.
|
|
270
|
+
* `trimmed` and `rotated` say whether the frame was trimmed or rotated when packed.
|
|
271
|
+
* `anchor` is the frame's default anchor (particles use their own anchor instead) and
|
|
272
|
+
* `borders` its 9-slice borders (`left`, `top`, `right`, `bottom`).
|
|
273
|
+
*/
|
|
200
274
|
frames: Record<string, {
|
|
201
275
|
frame: {
|
|
202
276
|
x: number;
|
|
@@ -227,27 +301,43 @@ interface PixiV7SpritesheetData {
|
|
|
227
301
|
bottom: number;
|
|
228
302
|
};
|
|
229
303
|
}>;
|
|
304
|
+
/** Named animations: each name maps to the ordered list of frame ids that make it up. */
|
|
230
305
|
animations?: Record<string, string[]>;
|
|
306
|
+
/**
|
|
307
|
+
* Metadata about the sheet and its image, as in Pixi's spritesheet format. Only `scale`
|
|
308
|
+
* is required.
|
|
309
|
+
*/
|
|
231
310
|
meta: {
|
|
311
|
+
/** Name of the tool that packed the sheet. */
|
|
232
312
|
app?: string;
|
|
313
|
+
/** Pixel format of the sheet image, as the packing tool reports it. */
|
|
233
314
|
format?: string;
|
|
315
|
+
/** Named frame ranges, each with a first (`from`) and last (`to`) frame number and a `direction`. */
|
|
234
316
|
frameTags?: {
|
|
235
317
|
from: number;
|
|
236
318
|
name: string;
|
|
237
319
|
to: number;
|
|
238
320
|
direction: string;
|
|
239
321
|
}[];
|
|
322
|
+
/** File name or URL of the sheet image. `load` does not read it: the image is its own argument. */
|
|
240
323
|
image?: string;
|
|
324
|
+
/** Layer information from the packing tool: a name, blend mode and opacity per layer. */
|
|
241
325
|
layers?: {
|
|
242
326
|
blendMode: string;
|
|
243
327
|
name: string;
|
|
244
328
|
opacity: number;
|
|
245
329
|
}[];
|
|
330
|
+
/** Resolution of the sheet image, as a number or a numeric string. Pixi reads it with `parseFloat`. */
|
|
246
331
|
scale: number | string;
|
|
332
|
+
/** Size of the sheet image in pixels. */
|
|
247
333
|
size?: {
|
|
248
334
|
w: number;
|
|
249
335
|
h: number;
|
|
250
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* Named slices defined in the packing tool, each with a `color` and a list of `keys`;
|
|
339
|
+
* each key has a `frame` number and a `bounds` rectangle (`x`, `y`, `w`, `h`).
|
|
340
|
+
*/
|
|
251
341
|
slices?: {
|
|
252
342
|
color: string;
|
|
253
343
|
name: string;
|
|
@@ -261,7 +351,9 @@ interface PixiV7SpritesheetData {
|
|
|
261
351
|
};
|
|
262
352
|
}[];
|
|
263
353
|
}[];
|
|
354
|
+
/** Other sheets of the same multi-pack set. `load` does not follow them; load each sheet into its own atlas. */
|
|
264
355
|
related_multi_packs?: string[];
|
|
356
|
+
/** Version of the packing tool or format that wrote the sheet. */
|
|
265
357
|
version?: string;
|
|
266
358
|
};
|
|
267
359
|
}
|
|
@@ -275,8 +367,9 @@ declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
|
275
367
|
* `texture.source` names a frame the host is expected to have registered
|
|
276
368
|
* beforehand, which is what lets one atlas serve every particle in the scene
|
|
277
369
|
* instead of embedding the same image once per use. This class is the other
|
|
278
|
-
* half of that contract — give it the `.png` + `.json` pair
|
|
279
|
-
* and the ids in the scene
|
|
370
|
+
* half of that contract — give it the `.png` + `.json` pair that Perseon
|
|
371
|
+
* Particle Studio exports, or any Pixi spritesheet, and the ids in the scene
|
|
372
|
+
* file resolve.
|
|
280
373
|
*
|
|
281
374
|
* `Spritesheet.parse()` also adds every frame to Pixi's global texture cache,
|
|
282
375
|
* which `Texture.from` reads; what `textureFromSource` reads is `Assets.cache`, so
|
|
@@ -302,7 +395,9 @@ declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
|
302
395
|
* object URL must be read into a data URL (or a `Texture`) first.
|
|
303
396
|
*/
|
|
304
397
|
declare class PixiV7ParticleAtlas {
|
|
398
|
+
/** The key the spritesheet is published under in `Assets.cache`. */
|
|
305
399
|
protected _cacheKey: string;
|
|
400
|
+
/** The sheet published by the last successful `load`; cleared by `destroy`. */
|
|
306
401
|
protected _spritesheet?: Spritesheet;
|
|
307
402
|
/** URL this instance acquired through `Assets`, so it releases exactly what it took. */
|
|
308
403
|
protected _loadedImageUrl?: string;
|
|
@@ -312,7 +407,11 @@ declare class PixiV7ParticleAtlas {
|
|
|
312
407
|
* publish its sheet over the winner's and leak the winner's.
|
|
313
408
|
*/
|
|
314
409
|
protected _loadToken: number;
|
|
315
|
-
/**
|
|
410
|
+
/**
|
|
411
|
+
* Creates an empty atlas; nothing is published until `load`.
|
|
412
|
+
*
|
|
413
|
+
* @param cacheKey - The key the spritesheet is registered under in `Assets.cache`; give distinct keys to atlases that coexist.
|
|
414
|
+
*/
|
|
316
415
|
constructor(cacheKey?: string);
|
|
317
416
|
/** The spritesheet published by the last successful `load`, or `undefined` before one or after `destroy`. */
|
|
318
417
|
get spritesheet(): Spritesheet | undefined;
|