@silentstatestudio/perseon 0.0.0-stage → 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 +219 -0
- package/LICENSE.md +73 -0
- package/README.md +849 -2
- package/dist/authoring/index.cjs +218 -0
- package/dist/authoring/index.d.cts +964 -0
- package/dist/authoring/index.d.ts +964 -0
- package/dist/authoring/index.js +219 -0
- package/dist/authoring/index.js.map +1 -0
- package/dist/chunk-443SQYAB.cjs +8468 -0
- package/dist/chunk-AVYXWDFD.js +8469 -0
- package/dist/chunk-AVYXWDFD.js.map +1 -0
- package/dist/chunk-BEDH7OYG.js +5484 -0
- package/dist/chunk-BEDH7OYG.js.map +1 -0
- package/dist/chunk-WEQPSGPS.cjs +5482 -0
- package/dist/chunk-ZIMCQTYK.cjs +6 -0
- package/dist/chunk-ZTG42LPX.js +6 -0
- package/dist/chunk-ZTG42LPX.js.map +1 -0
- package/dist/colors-CCeWL9q4.d.cts +2597 -0
- package/dist/colors-CGWrMf4V.d.ts +2597 -0
- package/dist/core/index.cjs +34 -0
- package/dist/core/index.d.cts +40 -0
- package/dist/core/index.d.ts +40 -0
- package/dist/core/index.js +35 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +34 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/pixi-v7/index.cjs +587 -0
- package/dist/pixi-v7/index.d.cts +471 -0
- package/dist/pixi-v7/index.d.ts +471 -0
- package/dist/pixi-v7/index.js +588 -0
- package/dist/pixi-v7/index.js.map +1 -0
- package/dist/pixi-v8/index.cjs +679 -0
- package/dist/pixi-v8/index.d.cts +452 -0
- package/dist/pixi-v8/index.d.ts +452 -0
- package/dist/pixi-v8/index.js +680 -0
- package/dist/pixi-v8/index.js.map +1 -0
- package/dist/rendering-dYQXmGTV.d.cts +264 -0
- package/dist/rendering-dYQXmGTV.d.ts +264 -0
- package/dist/testing/index.cjs +182 -0
- package/dist/testing/index.d.cts +103 -0
- package/dist/testing/index.d.ts +103 -0
- package/dist/testing/index.js +184 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +144 -5
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import { ParticleContainer, Filter, Particle, Container, Ticker, ApplicationOptions, Application, Texture, Spritesheet, SpritesheetData } 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-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
|
+
export { PerseonConfigError, parseAnimationOptions } from '../core/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One render group per particle layer. Wraps a Pixi v8 `ParticleContainer`; each
|
|
10
|
+
* engine particle mirrors a `Pixi.Particle` stored in the container's buffer.
|
|
11
|
+
*
|
|
12
|
+
* The mirror `Pixi.Particle` is stashed on the engine particle's
|
|
13
|
+
* `renderHandle` slot (see `IParticleVisualState.renderHandle`), so the
|
|
14
|
+
* per-frame `syncFrame` reads a direct field instead of a per-particle map
|
|
15
|
+
* lookup in the hot loop. Copying ~10 fields per particle is a tight loop and
|
|
16
|
+
* is dominated by GPU rasterization at any realistic particle count.
|
|
17
|
+
*/
|
|
18
|
+
declare class PixiV8ParticleGroup implements IParticleGroup {
|
|
19
|
+
/**
|
|
20
|
+
* The Pixi `ParticleContainer` that draws this layer's particles. The render node that created the group adds it to its own container; `destroy` destroys it.
|
|
21
|
+
*/
|
|
22
|
+
readonly container: ParticleContainer;
|
|
23
|
+
/**
|
|
24
|
+
* Engine particles mirrored by this group, in the same order as the
|
|
25
|
+
* container's buffer. Kept so `syncFrame` iterates only this layer's
|
|
26
|
+
* particles and reads each one's `renderHandle` directly.
|
|
27
|
+
*/
|
|
28
|
+
protected _particles: IParticleVisualState[];
|
|
29
|
+
/** The advanced blend filter on `container`, if the mode needs one. */
|
|
30
|
+
protected _blendFilter: Filter | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* On the container, where the advanced blend filter also is: hidden, Pixi
|
|
33
|
+
* collects neither its particles nor the filter's pass.
|
|
34
|
+
*/
|
|
35
|
+
get visible(): boolean;
|
|
36
|
+
set visible(value: boolean);
|
|
37
|
+
/**
|
|
38
|
+
* Creates the `ParticleContainer` with `options.dynamicProperties` (position stays dynamic, Pixi's default) and applies `options.blendMode` (`normal` when omitted). Fixed-function modes are set as the container's blend mode; every other mode puts a blend filter on the container itself.
|
|
39
|
+
*
|
|
40
|
+
* @param options - The layer's dynamic properties and blend mode.
|
|
41
|
+
*/
|
|
42
|
+
constructor(options: IParticleGroupOptions);
|
|
43
|
+
get size(): number;
|
|
44
|
+
addParticle(particle: IParticleVisualState, index: number): void;
|
|
45
|
+
removeParticle(particle: IParticleVisualState): void;
|
|
46
|
+
removeAll(): void;
|
|
47
|
+
syncFrame(): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Pixi pins the container's texture to the first particle it draws and never
|
|
51
|
+
* lets go. An empty group drops it, so the next particles, whatever image
|
|
52
|
+
* they come from, set it again.
|
|
53
|
+
*/
|
|
54
|
+
protected _releaseTexture(): void;
|
|
55
|
+
/**
|
|
56
|
+
* The blend pass covers the whole screen whether or not the layer has
|
|
57
|
+
* anything to draw. A layer with no live particles turns it off, and Pixi
|
|
58
|
+
* skips a filter stack whose filters are all disabled.
|
|
59
|
+
*/
|
|
60
|
+
protected _syncBlendPass(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Copies the engine particle's position, scale, rotation, alpha, tint, anchor and texture onto its Pixi `Particle`.
|
|
63
|
+
*/
|
|
64
|
+
protected _writeState(p: IParticleVisualState, pixi: Particle): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* One emitter's node in the Pixi v8 scene graph: a plain `Container` whose
|
|
69
|
+
* children are that emitter's Particle Layer groups, in z-order.
|
|
70
|
+
*
|
|
71
|
+
* Destroying a node releases it from the renderer that created it, so a scene
|
|
72
|
+
* that adds and removes emitters leaves nothing behind. Destroy is idempotent —
|
|
73
|
+
* a renderer tearing down after the engine already did must be a no-op.
|
|
74
|
+
*/
|
|
75
|
+
declare class PixiV8RenderNode implements IRenderRootNode<Container> {
|
|
76
|
+
/**
|
|
77
|
+
* The Pixi `Container` this node wraps. It is created with the node and destroyed when the node is destroyed.
|
|
78
|
+
*/
|
|
79
|
+
readonly container: Container;
|
|
80
|
+
/** The particle groups created through this node and not yet removed with `destroyParticleGroup`. They are destroyed with it. */
|
|
81
|
+
protected _groups: PixiV8ParticleGroup[];
|
|
82
|
+
/** Child nodes (an emitter's, when this is a playback root). */
|
|
83
|
+
protected _children: PixiV8RenderNode[];
|
|
84
|
+
/**
|
|
85
|
+
* Callback run once, from `destroy`, so whoever created this node (the renderer for a root, the parent node for a child) stops tracking it.
|
|
86
|
+
*/
|
|
87
|
+
protected _release: (node: PixiV8RenderNode) => void;
|
|
88
|
+
/** Set by the first `destroy`, so that later calls do nothing. */
|
|
89
|
+
protected _destroyed: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Creates the node with an empty Pixi container.
|
|
92
|
+
*
|
|
93
|
+
* @param release - Called with this node when it is destroyed, so its creator can drop it.
|
|
94
|
+
*/
|
|
95
|
+
constructor(release: (node: PixiV8RenderNode) => void);
|
|
96
|
+
get hostDestroyed(): boolean;
|
|
97
|
+
/** Whether the node's container is shown. Hidden, Pixi draws neither it nor anything under it. */
|
|
98
|
+
get visible(): boolean;
|
|
99
|
+
set visible(value: boolean);
|
|
100
|
+
/** Horizontal position of the node's container, in its parent's local coordinates. */
|
|
101
|
+
get x(): number;
|
|
102
|
+
set x(value: number);
|
|
103
|
+
/** Vertical position of the node's container, in its parent's local coordinates. */
|
|
104
|
+
get y(): number;
|
|
105
|
+
set y(value: number);
|
|
106
|
+
/**
|
|
107
|
+
* Attach under a host container, moving the node if it was mounted
|
|
108
|
+
* elsewhere — `addChild` already reparents, so a pooled playback replayed
|
|
109
|
+
* under a different container needs nothing more.
|
|
110
|
+
*
|
|
111
|
+
* Only a playback's root is ever mounted; an emitter's child node is
|
|
112
|
+
* parented by `createChildNode` and never leaves.
|
|
113
|
+
*/
|
|
114
|
+
mount(parent: Container): void;
|
|
115
|
+
unmount(): void;
|
|
116
|
+
createChildNode(): IRenderNode;
|
|
117
|
+
/**
|
|
118
|
+
* Drops a destroyed child node from this node's list. It is the release callback `createChildNode` hands to each child.
|
|
119
|
+
*/
|
|
120
|
+
protected _releaseChild(node: PixiV8RenderNode): void;
|
|
121
|
+
createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
|
|
122
|
+
setGroupIndex(group: IParticleGroup, index: number): void;
|
|
123
|
+
destroyParticleGroup(group: IParticleGroup): void;
|
|
124
|
+
destroy(): void;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Options for `PixiV8Renderer`. */
|
|
128
|
+
interface PixiV8RendererOptions {
|
|
129
|
+
/**
|
|
130
|
+
* Optional Pixi v8 `Ticker` to drive engine updates. When omitted,
|
|
131
|
+
* `Ticker.shared` is used.
|
|
132
|
+
*/
|
|
133
|
+
ticker?: Ticker;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* PixiJS v8 implementation of `IRenderer`. Creates one detached root
|
|
137
|
+
* `PixiV8RenderNode` per playback, which the host mounts; each emitter gets a
|
|
138
|
+
* child node holding its layer groups (`ParticleContainer`s).
|
|
139
|
+
*/
|
|
140
|
+
declare class PixiV8Renderer implements IRenderer<Container> {
|
|
141
|
+
/** An adapter over `options.ticker`, or over Pixi's shared one, that drives the engine's updates. */
|
|
142
|
+
readonly ticker: ITicker;
|
|
143
|
+
/** What this backend does with each blend mode — see `IRendererCapabilities`. */
|
|
144
|
+
readonly capabilities: IRendererCapabilities;
|
|
145
|
+
/**
|
|
146
|
+
* Textures already resolved, keyed by the `source` value given to `resolveTexture`. Emptied by `clearTextureCache` and `destroy`.
|
|
147
|
+
*/
|
|
148
|
+
protected _textureCache: Map<unknown, ITextureRef>;
|
|
149
|
+
/**
|
|
150
|
+
* 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.
|
|
151
|
+
*/
|
|
152
|
+
protected _nodes: PixiV8RenderNode[];
|
|
153
|
+
/**
|
|
154
|
+
* Creates the renderer, wrapping `options.ticker` (or Pixi's shared ticker) in an adapter.
|
|
155
|
+
*
|
|
156
|
+
* @param options - Optional settings; see `PixiV8RendererOptions`.
|
|
157
|
+
*/
|
|
158
|
+
constructor(options?: PixiV8RendererOptions);
|
|
159
|
+
/** Detached: the caller mounts it where the animation should appear. */
|
|
160
|
+
createRootNode(): IRenderRootNode<Container>;
|
|
161
|
+
/** Called by a node when it is destroyed, so the renderer holds only live ones. */
|
|
162
|
+
protected _releaseNode(node: PixiV8RenderNode): void;
|
|
163
|
+
/**
|
|
164
|
+
* The texture a scene's `texture.source` names. The id must have been published to
|
|
165
|
+
* Pixi's `Assets.cache` beforehand (see `PixiV8ParticleAtlas`); an unknown id, or a
|
|
166
|
+
* source that is not a string, resolves to an empty texture. Answers are memoized
|
|
167
|
+
* until `clearTextureCache`, so an id resolved before it was published stays empty
|
|
168
|
+
* until then.
|
|
169
|
+
*/
|
|
170
|
+
resolveTexture(source: unknown): ITextureRef;
|
|
171
|
+
/** See `IRenderer.clearTextureCache` — what a host calls after republishing an atlas. */
|
|
172
|
+
clearTextureCache(): void;
|
|
173
|
+
/** Destroys every root node this renderer created and empties its texture cache. */
|
|
174
|
+
destroy(): void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Options for the `Perseon` constructor. Both are optional, so `new Perseon()` works with Pixi's shared ticker. */
|
|
178
|
+
interface PerseonOptions {
|
|
179
|
+
/**
|
|
180
|
+
* What every animation runs off: the Pixi v8 `Ticker` — `app.ticker`,
|
|
181
|
+
* normally; defaults to `Ticker.shared` — or any `ITicker`, such as the
|
|
182
|
+
* `FakeTicker` of `@silentstatestudio/perseon/testing`, whose frames a test pumps by hand.
|
|
183
|
+
*/
|
|
184
|
+
ticker?: Ticker | ITicker;
|
|
185
|
+
/**
|
|
186
|
+
* What a recoverable misuse does — a Linked source that resolves to nothing,
|
|
187
|
+
* a number a `set` clips to its domain, a stale handle, a value of
|
|
188
|
+
* `setGlobalParameter` an animation that declares the global cannot take:
|
|
189
|
+
* `'warn'` prints it once per animation with the `Perseon - ` prefix,
|
|
190
|
+
* `'throw'` turns it into an error, `'silent'` drops it. Defaults to
|
|
191
|
+
* `'warn'`.
|
|
192
|
+
*/
|
|
193
|
+
diagnostics?: 'warn' | 'throw' | 'silent';
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Perseon on PixiJS v8: the one object an app builds to use particle animations,
|
|
197
|
+
* and the only place the host's renderer and ticker are named.
|
|
198
|
+
*
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { Perseon } from '@silentstatestudio/perseon/pixi-v8'
|
|
201
|
+
*
|
|
202
|
+
* const perseon = new Perseon({ ticker: app.ticker }) // once, in the app
|
|
203
|
+
* const explosion = perseon.createAnimation(explosionConfig) // once per effect
|
|
204
|
+
*
|
|
205
|
+
* explosion.play({ parent: world, x: hit.x, y: hit.y }) // as often as you like
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* The three levels each cost something different, which is why they are three
|
|
209
|
+
* objects: this one is the integration (one per app, free), a `PerseonAnimation`
|
|
210
|
+
* is a compiled config (one per kind of effect, expensive, built at load time),
|
|
211
|
+
* and a playback is one showing of it (many, pooled, cheap).
|
|
212
|
+
*
|
|
213
|
+
* Every playback of every animation shares **one** callback on the host's
|
|
214
|
+
* ticker, so a scene with two hundred effects still registers a single frame
|
|
215
|
+
* subscriber, stepped in a defined order.
|
|
216
|
+
*
|
|
217
|
+
* Everything above the renderer lives in `PerseonIntegration`; what this class
|
|
218
|
+
* adds is the one thing that cannot be shared — what PixiJS v8 in particular
|
|
219
|
+
* has to hand over. `@silentstatestudio/perseon/pixi-v7` exports its own `Perseon` under the same
|
|
220
|
+
* name, so swapping backends is swapping the import.
|
|
221
|
+
*/
|
|
222
|
+
declare class Perseon extends PerseonIntegration<Container> {
|
|
223
|
+
/**
|
|
224
|
+
* Re-typed, not re-assigned: the base declares the renderer as an
|
|
225
|
+
* `IRenderer`, and a host reaching for this one wants the v8 adapter it
|
|
226
|
+
* actually is — its atlas-facing methods included.
|
|
227
|
+
*/
|
|
228
|
+
readonly renderer: PixiV8Renderer;
|
|
229
|
+
/**
|
|
230
|
+
* Creates the integration for PixiJS v8. A Pixi `Ticker` is wrapped by the renderer this builds; any other
|
|
231
|
+
* `ITicker` is used as the frame source as it is.
|
|
232
|
+
*
|
|
233
|
+
* @param options - Optional settings; see `PerseonOptions`.
|
|
234
|
+
*/
|
|
235
|
+
constructor(options?: PerseonOptions);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** The rendering backend Pixi resolved to. */
|
|
239
|
+
type RendererBackend = 'webgpu' | 'webgl';
|
|
240
|
+
/** Options for `createPixiApplication`: any Pixi `ApplicationOptions`, all optional, plus `preferWebGPU`. */
|
|
241
|
+
interface CreatePixiApplicationOptions extends Partial<ApplicationOptions> {
|
|
242
|
+
/**
|
|
243
|
+
* Prefer the WebGPU rendering backend. Defaults to `true`.
|
|
244
|
+
*
|
|
245
|
+
* This is a *preference*, not a hard requirement: when WebGPU is
|
|
246
|
+
* unavailable in the host browser Pixi falls back to WebGL on its own, so
|
|
247
|
+
* `true` never breaks a session — it just asks for the faster backend when
|
|
248
|
+
* it exists. Set `false` to force WebGL (e.g. to sidestep a driver bug or
|
|
249
|
+
* to compare backends).
|
|
250
|
+
*
|
|
251
|
+
* Named `preferWebGPU` rather than `webgpu` because Pixi's own
|
|
252
|
+
* `ApplicationOptions.webgpu` is the WebGPU adapter/device config object —
|
|
253
|
+
* a different concern this flag sits above.
|
|
254
|
+
*/
|
|
255
|
+
preferWebGPU?: boolean;
|
|
256
|
+
}
|
|
257
|
+
/** What `createPixiApplication` resolves to. */
|
|
258
|
+
interface CreatedPixiApplication {
|
|
259
|
+
/** The initialized Pixi `Application`. The caller owns it and is the one to destroy it. */
|
|
260
|
+
app: Application;
|
|
261
|
+
/**
|
|
262
|
+
* The backend Pixi actually resolved to after `init`. May differ from the
|
|
263
|
+
* request: asking for `webgpu` on a browser without it yields `'webgl'`.
|
|
264
|
+
*/
|
|
265
|
+
backend: RendererBackend;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Creates and initializes a Pixi v8 `Application`, defaulting to the WebGPU
|
|
269
|
+
* rendering backend with automatic fallback to WebGL. This is the single place
|
|
270
|
+
* the library expresses its backend preference, so a host can opt out with one
|
|
271
|
+
* flag rather than reconstructing the `init` call.
|
|
272
|
+
*
|
|
273
|
+
* An explicit Pixi `preference` takes precedence over `preferWebGPU`. Every
|
|
274
|
+
* other `Application` option is forwarded untouched — callers pass their
|
|
275
|
+
* usual `backgroundAlpha`, `antialias`, `resolution`, `width`, `height`, etc.
|
|
276
|
+
*/
|
|
277
|
+
declare function createPixiApplication(options?: CreatePixiApplicationOptions): Promise<CreatedPixiApplication>;
|
|
278
|
+
/** Reads back the backend a live `Application` is rendering with. */
|
|
279
|
+
declare function resolveRendererBackend(app: Application): RendererBackend;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Adapts a PixiJS v8 `Ticker` to the engine-facing `ITicker` interface.
|
|
283
|
+
* Maintains the function-to-wrapper mapping so `remove(fn)` finds the same
|
|
284
|
+
* wrapper that `add(fn)` previously registered with the Pixi ticker.
|
|
285
|
+
*/
|
|
286
|
+
declare class PixiV8TickerAdapter implements ITicker {
|
|
287
|
+
/** The Pixi ticker being wrapped. */
|
|
288
|
+
protected _ticker: Ticker;
|
|
289
|
+
/**
|
|
290
|
+
* Pairs each function given to `add` with the wrapper registered on the Pixi ticker, so `remove` can unregister that same wrapper.
|
|
291
|
+
*/
|
|
292
|
+
protected _wrapped: Map<(deltaMS: number) => void, (ticker: Ticker) => void>;
|
|
293
|
+
/**
|
|
294
|
+
* Wraps a Pixi ticker. The constructor neither starts nor stops it, but Pixi starts a ticker whose
|
|
295
|
+
* `autoStart` is set (such as `Ticker.shared`) when `add` registers the first function.
|
|
296
|
+
*
|
|
297
|
+
* @param ticker - The Pixi `Ticker` whose frames drive the functions added to this adapter.
|
|
298
|
+
*/
|
|
299
|
+
constructor(ticker: Ticker);
|
|
300
|
+
add(fn: (deltaMS: number) => void): void;
|
|
301
|
+
remove(fn: (deltaMS: number) => void): void;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* What the PixiJS v8 adapter can do — see `IRendererCapabilities`.
|
|
306
|
+
*
|
|
307
|
+
* Every mode in the catalog is honored here, the advanced ones by the filter
|
|
308
|
+
* each `PixiV8ParticleGroup` carries; what differs is the price, and that is
|
|
309
|
+
* what a host is told so it can say it.
|
|
310
|
+
*/
|
|
311
|
+
declare class PixiV8RendererCapabilities implements IRendererCapabilities {
|
|
312
|
+
/**
|
|
313
|
+
* Registers the advanced blend filters with Pixi the first time any instance is created; later instances reuse that registration.
|
|
314
|
+
*/
|
|
315
|
+
constructor();
|
|
316
|
+
blendModeSupport(mode: ParticleBlendMode): BlendModeSupport;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Resolve the texture a scene names.
|
|
321
|
+
*
|
|
322
|
+
* Every string source is a **cache id**, with no exceptions: an animation names
|
|
323
|
+
* resources the host registered beforehand — `ParticleAnimationOptions` says as
|
|
324
|
+
* much, and this is where it holds — so a source resolves against `Assets.cache`
|
|
325
|
+
* and against nothing else. An id the cache does not know becomes
|
|
326
|
+
* `Texture.EMPTY`: one particle type pointing at a frame that is no longer
|
|
327
|
+
* published must not take an animation down, and a host that wants to report it
|
|
328
|
+
* asks ahead of time against the same cache.
|
|
329
|
+
*
|
|
330
|
+
* A URL is not a special case, and used to be treated as one. Resolving it here
|
|
331
|
+
* cannot work: this runs in the spawn path, loading is asynchronous, and in
|
|
332
|
+
* PixiJS v8 `Texture.from(string)` reads the cache alone — so a URL that was
|
|
333
|
+
* never loaded returned `undefined` from a function typed to return a `Texture`,
|
|
334
|
+
* which then travelled into the renderer as if it were one. What a host does
|
|
335
|
+
* instead is `await Assets.load(url)`, after which the URL *is* a cache id and
|
|
336
|
+
* resolves here like every other source.
|
|
337
|
+
*
|
|
338
|
+
* A source that is not a string is not an id, so it resolves to nothing.
|
|
339
|
+
*/
|
|
340
|
+
declare const textureFromSource: (source: unknown) => Texture;
|
|
341
|
+
|
|
342
|
+
/** Key the atlas is registered under in `Assets.cache` when none is given. */
|
|
343
|
+
declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
344
|
+
/**
|
|
345
|
+
* Host-side loader for the atlas a scene's texture ids point at.
|
|
346
|
+
*
|
|
347
|
+
* A serialized scene carries texture **ids**, not images: every
|
|
348
|
+
* `texture.source` names a frame the host is expected to have registered
|
|
349
|
+
* beforehand, which is what lets one atlas serve every particle in the scene
|
|
350
|
+
* instead of embedding the same image once per use. This class is the other
|
|
351
|
+
* half of that contract — give it the `.png` + `.json` pair that Perseon
|
|
352
|
+
* Particle Studio exports, or any Pixi spritesheet, and the ids in the scene
|
|
353
|
+
* file resolve.
|
|
354
|
+
*
|
|
355
|
+
* Registering the spritesheet in `Assets.cache` is what publishes the frames:
|
|
356
|
+
* Pixi's cache parser for spritesheets adds one entry per frame name, which is
|
|
357
|
+
* what `textureFromSource` reads.
|
|
358
|
+
*
|
|
359
|
+
* Ownership is explicit, because getting it wrong corrupts Pixi's own cache:
|
|
360
|
+
* an image handed in as a `Texture` belongs to the caller, and one loaded here
|
|
361
|
+
* from a URL is released through `Assets.unload` rather than destroyed behind
|
|
362
|
+
* Assets' back (which would leave a dead entry for the next load of that URL).
|
|
363
|
+
* An image `Assets` already held before the load stays the host's and is never
|
|
364
|
+
* unloaded; one this class took is unloaded once no atlas holds it any more.
|
|
365
|
+
*
|
|
366
|
+
* Frame ids are global: each one becomes an unprefixed key in `Assets.cache`.
|
|
367
|
+
* Loading throws, before publishing anything, when an id is already cached by
|
|
368
|
+
* something no atlas published, so a host's own entries are never overwritten
|
|
369
|
+
* or deleted. Between atlases the last one to publish an id wins it, and
|
|
370
|
+
* destroying an atlas gives back only the ids it still owns. Each atlas needs
|
|
371
|
+
* its own `cacheKey`: loading throws when the key already holds an entry that
|
|
372
|
+
* is not this atlas's own sheet.
|
|
373
|
+
*
|
|
374
|
+
* Note on URLs: pass an `http(s):` or `data:` URL. Pixi's texture loader
|
|
375
|
+
* recognizes neither the extension nor the MIME type of a `blob:` URL, so an
|
|
376
|
+
* object URL must be read into a data URL (or a `Texture`) first.
|
|
377
|
+
*/
|
|
378
|
+
declare class PixiV8ParticleAtlas {
|
|
379
|
+
/** The key the spritesheet is published under in `Assets.cache`. */
|
|
380
|
+
protected _cacheKey: string;
|
|
381
|
+
/** The sheet published by the last successful `load`; cleared by `destroy`. */
|
|
382
|
+
protected _spritesheet?: Spritesheet;
|
|
383
|
+
/** URL this instance acquired through `Assets`, so it releases exactly what it took. */
|
|
384
|
+
protected _loadedImageUrl?: string;
|
|
385
|
+
/**
|
|
386
|
+
* Generation counter. A host can call `load` again before the previous one
|
|
387
|
+
* settles (a user picking files quickly); without this the loser would
|
|
388
|
+
* publish its sheet over the winner's and leak the winner's.
|
|
389
|
+
*/
|
|
390
|
+
protected _loadToken: number;
|
|
391
|
+
/**
|
|
392
|
+
* Creates an empty atlas; nothing is published until `load`.
|
|
393
|
+
*
|
|
394
|
+
* @param cacheKey - The key the spritesheet is registered under in `Assets.cache`; give distinct keys to atlases that coexist.
|
|
395
|
+
*/
|
|
396
|
+
constructor(cacheKey?: string);
|
|
397
|
+
/** The spritesheet published by the last successful `load`, or `undefined` before one or after `destroy`. */
|
|
398
|
+
get spritesheet(): Spritesheet | undefined;
|
|
399
|
+
/**
|
|
400
|
+
* Frame ids of this atlas's sheet — the values a scene's `texture.source` may
|
|
401
|
+
* name. Another atlas may have published the same id since, and wins it.
|
|
402
|
+
*/
|
|
403
|
+
get frameIds(): string[];
|
|
404
|
+
/** Whether `frameId` is one of this atlas's frames (a later atlas may have published the same id since). */
|
|
405
|
+
hasFrame(frameId: string): boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Load an atlas and publish its frames. Replaces whatever this instance had
|
|
408
|
+
* loaded before, so a host can swap atlases as the user picks new files.
|
|
409
|
+
*
|
|
410
|
+
* @returns The parsed spritesheet. When a later `load` or `destroy` superseded
|
|
411
|
+
* this call before it finished, nothing was published and the sheet returned
|
|
412
|
+
* is one that never was and is already destroyed.
|
|
413
|
+
* @throws When the data lacks `frames` or `meta`; when a frame id is already
|
|
414
|
+
* cached by something no atlas published; or when this atlas's `cacheKey`
|
|
415
|
+
* already holds an entry that is not its own sheet. Nothing is published, the
|
|
416
|
+
* previous atlas stays loaded, and the image taken for this call is released.
|
|
417
|
+
*/
|
|
418
|
+
load(image: string | Texture, data: SpritesheetData): Promise<Spritesheet>;
|
|
419
|
+
/** Unpublish the frames and release whatever this instance owns. */
|
|
420
|
+
destroy(): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Two atlases on one key would unpublish each other's frames without either
|
|
423
|
+
* knowing, and a key the host uses would be deleted. Throws instead, before
|
|
424
|
+
* anything is published. The sheet this instance already published is its own.
|
|
425
|
+
*/
|
|
426
|
+
protected _assertCacheKeyFree(): void;
|
|
427
|
+
/**
|
|
428
|
+
* Every frame becomes a global, unprefixed key in `Assets.cache`, so an id
|
|
429
|
+
* the host already uses would be overwritten and then deleted along with the
|
|
430
|
+
* atlas. Throws instead, before anything is published. An entry another atlas
|
|
431
|
+
* published is not the host's: the last atlas to publish an id wins it.
|
|
432
|
+
*/
|
|
433
|
+
protected _assertFrameIdsFree(data: SpritesheetData): void;
|
|
434
|
+
/**
|
|
435
|
+
* Remove the entry published under this atlas's key, and with it the frames
|
|
436
|
+
* of `sheet`. Removing the key deletes every id the sheet published, so an id
|
|
437
|
+
* another atlas has since taken over is put back: it is not this one's to drop.
|
|
438
|
+
*/
|
|
439
|
+
protected _unpublish(sheet: Spritesheet | undefined): void;
|
|
440
|
+
/** Record that an atlas now holds `url`. */
|
|
441
|
+
protected _acquireUrl(url: string): void;
|
|
442
|
+
/** Give back a hold taken for a load that failed before anything was loaded. */
|
|
443
|
+
protected _returnUrl(url: string | undefined): void;
|
|
444
|
+
/**
|
|
445
|
+
* Let go of `url`, unloading it only once no atlas holds it any more.
|
|
446
|
+
* Unknown URLs are ignored, so a load still in flight when `destroy` lands
|
|
447
|
+
* releases its own acquisition without driving the count below zero.
|
|
448
|
+
*/
|
|
449
|
+
protected _releaseUrl(url: string | undefined): Promise<void>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export { BlendModeSupport, type CreatePixiApplicationOptions, type CreatedPixiApplication, IParticleGroup, IParticleGroupOptions, IParticleVisualState, IRenderNode, IRenderRootNode, IRenderer, IRendererCapabilities, ITextureRef, ITicker, PARTICLE_ATLAS_CACHE_KEY, ParticleBlendMode, Perseon, type PerseonOptions, PixiV8ParticleAtlas, PixiV8ParticleGroup, PixiV8RenderNode, PixiV8Renderer, PixiV8RendererCapabilities, type PixiV8RendererOptions, PixiV8TickerAdapter, type RendererBackend, createPixiApplication, resolveRendererBackend, textureFromSource };
|