@silentstatestudio/perseon 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +192 -0
- package/LICENSE.md +30 -0
- package/README.md +848 -2
- package/dist/authoring/index.cjs +213 -0
- package/dist/authoring/index.d.cts +866 -0
- package/dist/authoring/index.d.ts +866 -0
- package/dist/authoring/index.js +214 -0
- package/dist/authoring/index.js.map +1 -0
- package/dist/chunk-GDXCMDJ6.js +5462 -0
- package/dist/chunk-GDXCMDJ6.js.map +1 -0
- package/dist/chunk-ON4JV4BI.js +8432 -0
- package/dist/chunk-ON4JV4BI.js.map +1 -0
- package/dist/chunk-PT7F7TTB.cjs +8431 -0
- package/dist/chunk-Q2HLLGJ7.cjs +5461 -0
- package/dist/chunk-SVI6WUOB.js +1 -0
- package/dist/chunk-SVI6WUOB.js.map +1 -0
- package/dist/chunk-ZIMCQTYK.cjs +1 -0
- package/dist/colors-CUEeQ78V.d.cts +2247 -0
- package/dist/colors-pshUJaKB.d.ts +2247 -0
- package/dist/core/index.cjs +29 -0
- package/dist/core/index.d.cts +39 -0
- package/dist/core/index.d.ts +39 -0
- package/dist/core/index.js +30 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +29 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/pixi-v7/index.cjs +513 -0
- package/dist/pixi-v7/index.d.cts +372 -0
- package/dist/pixi-v7/index.d.ts +372 -0
- package/dist/pixi-v7/index.js +514 -0
- package/dist/pixi-v7/index.js.map +1 -0
- package/dist/pixi-v8/index.cjs +608 -0
- package/dist/pixi-v8/index.d.cts +380 -0
- package/dist/pixi-v8/index.d.ts +380 -0
- package/dist/pixi-v8/index.js +609 -0
- package/dist/pixi-v8/index.js.map +1 -0
- package/dist/rendering-DeUo1BsK.d.cts +237 -0
- package/dist/rendering-DeUo1BsK.d.ts +237 -0
- package/dist/testing/index.cjs +159 -0
- package/dist/testing/index.d.cts +85 -0
- package/dist/testing/index.d.ts +85 -0
- package/dist/testing/index.js +160 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +148 -6
|
@@ -0,0 +1,372 @@
|
|
|
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-DeUo1BsK.cjs';
|
|
3
|
+
export { i as IShape } from '../rendering-DeUo1BsK.cjs';
|
|
4
|
+
import { P as PerseonIntegration } from '../colors-CUEeQ78V.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 ExternalForcesForEmitterUse, z as ExternalForcesOptions, B as ExternalForcesTypes, G as GlobalParameterOption, I as InitialStateOptions, K as KineticsOptions, L as LayerOptionPath, F as LayerOptionType, H as LocalDefaultHandle, J as LocalParameterHandle, M as ModifierBlendMode, N as ModulatableNumber, O as ModulatedValue, Q as ModulatorOptions, R as ModulatorShape, S as NumberOptions, T as NumericDomain, U as OptionNodeKind, V as OptionStage, W as OptionStrategy, X as ParameterDescription, Y as ParameterHandle, Z as ParameterInitOptions, _ as ParameterLinkRelation, $ as ParameterModifier, a0 as ParameterModifierSource, a1 as ParameterUpdateOptions, a2 as ParticleAnimationOptions, a3 as ParticleEventBinding, a4 as ParticleEventBindings, a5 as ParticleEventTrigger, a6 as ParticleEventsByTrigger, a7 as ParticleHookEmitter, a8 as ParticleHookPlayback, a9 as ParticleHookRandom, aa as ParticleItem, ab as ParticleLayer, ac as ParticleLayerOptions, ad as ParticleLimitStrategy, ae as ParticleRegionRef, af as ParticleSnapshot, ag as ParticleSnapshotObject, ah as ParticleSpawnStrategy, ai as ParticleSpriteAnimationParameters, aj as PerformanceOptions, ak as PerseonAnimation, al as PerseonEvent, am as PerseonPlayback, an as PlaybackFinishedReason, ao as PlaybackFinishedResult, ap as PlaybackHost, aq as PlaybackOptionPath, ar as PlaybackOptionType, as as PlaybackOptions, at as PointForceConfig, au as PointForceFalloff, av as PointForceMode, aw as PointValue, ax as PolygonArea, ay as ProbabilityCurveKind, az as ProbabilityCurvePreset, aA as ProbabilityCurvePresetId, aB as RandomListState, aC as RandomValueList, aD as RandomValueListMode, aE as RandomValueRange, aF as RandomnessOptions, aG as RandomnessSeedMode, aH as RectangleArea, aI as RegionBehavior, aJ as RegionOptions, aK as RingArea, aL as ScaleOptions, aM as ShapeArea, aN as SingleTextureOption, aO as SpawnColor, aP as SpawnNumber, aQ as SpawnPoint, aR as SpawnPosition, aS as SpawnVector, aT as SpriteAnimationOptions, aU as SpriteAnimationTexturesOptions, aV as TextDomain, aW as TextureElement, aX as Unsubscribe, aY as ValueProbability, aZ as VectorValue } from '../colors-CUEeQ78V.cjs';
|
|
6
|
+
export { PerseonConfigError, parseAnimationOptions } from '../core/index.cjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One render group per particle layer. Wraps a Pixi v7 `ParticleContainer` and keeps
|
|
10
|
+
* a mirror map between engine particles (`IParticleVisualState`) and the
|
|
11
|
+
* `Pixi.Sprite` instances inside the container.
|
|
12
|
+
*
|
|
13
|
+
* v7 differences from v8:
|
|
14
|
+
* - Children are `Sprite`s, not `Particle`s.
|
|
15
|
+
* - `position`, `scale`, `anchor` are `Point` objects (use `.set(x, y)`).
|
|
16
|
+
* - Alpha and tint are independent properties (no encoded color).
|
|
17
|
+
*/
|
|
18
|
+
declare class PixiV7ParticleGroup implements IParticleGroup {
|
|
19
|
+
readonly container: ParticleContainer;
|
|
20
|
+
protected _mirror: Map<IParticleVisualState, Sprite>;
|
|
21
|
+
get size(): number;
|
|
22
|
+
/** On the container: hidden, its sprites are not drawn and stay in it. */
|
|
23
|
+
get visible(): boolean;
|
|
24
|
+
set visible(value: boolean);
|
|
25
|
+
constructor(options: IParticleGroupOptions);
|
|
26
|
+
addParticle(particle: IParticleVisualState, index: number): void;
|
|
27
|
+
removeParticle(particle: IParticleVisualState): void;
|
|
28
|
+
removeAll(): void;
|
|
29
|
+
syncFrame(): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
protected _writeState(p: IParticleVisualState, sprite: Sprite): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* One emitter's node in the Pixi v7 scene graph: a plain `Container` whose
|
|
36
|
+
* children are that emitter's Particle Layer groups, in z-order.
|
|
37
|
+
*
|
|
38
|
+
* Destroying a node releases it from the renderer that created it, so a scene
|
|
39
|
+
* that adds and removes emitters leaves nothing behind. Destroy is idempotent —
|
|
40
|
+
* a renderer tearing down after the engine already did must be a no-op.
|
|
41
|
+
*/
|
|
42
|
+
declare class PixiV7RenderNode implements IRenderRootNode<Container> {
|
|
43
|
+
readonly container: Container;
|
|
44
|
+
protected _groups: PixiV7ParticleGroup[];
|
|
45
|
+
/** Child nodes (an emitter's, when this is a playback root). */
|
|
46
|
+
protected _children: PixiV7RenderNode[];
|
|
47
|
+
protected _release: (node: PixiV7RenderNode) => void;
|
|
48
|
+
protected _destroyed: boolean;
|
|
49
|
+
constructor(release: (node: PixiV7RenderNode) => void);
|
|
50
|
+
get hostDestroyed(): boolean;
|
|
51
|
+
get visible(): boolean;
|
|
52
|
+
set visible(value: boolean);
|
|
53
|
+
get x(): number;
|
|
54
|
+
set x(value: number);
|
|
55
|
+
get y(): number;
|
|
56
|
+
set y(value: number);
|
|
57
|
+
/**
|
|
58
|
+
* Attach under a host container, moving the node if it was mounted
|
|
59
|
+
* elsewhere — `addChild` already reparents, so a pooled playback replayed
|
|
60
|
+
* under a different container needs nothing more.
|
|
61
|
+
*
|
|
62
|
+
* Only a playback's root is ever mounted; an emitter's child node is
|
|
63
|
+
* parented by `createChildNode` and never leaves.
|
|
64
|
+
*/
|
|
65
|
+
mount(parent: Container): void;
|
|
66
|
+
unmount(): void;
|
|
67
|
+
createChildNode(): IRenderNode;
|
|
68
|
+
protected _releaseChild(node: PixiV7RenderNode): void;
|
|
69
|
+
createParticleGroup(options: IParticleGroupOptions): IParticleGroup;
|
|
70
|
+
setGroupIndex(group: IParticleGroup, index: number): void;
|
|
71
|
+
destroyParticleGroup(group: IParticleGroup): void;
|
|
72
|
+
destroy(): void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface PixiV7RendererOptions {
|
|
76
|
+
/** Optional Pixi v7 `Ticker`. Falls back to `Ticker.shared` when omitted. */
|
|
77
|
+
ticker?: Ticker;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* PixiJS v7 implementation of `IRenderer`. Same architecture as the v8
|
|
81
|
+
* adapter: one detached root `PixiV7RenderNode` per playback, which the host
|
|
82
|
+
* mounts; each emitter gets a child node holding its layer groups
|
|
83
|
+
* (`ParticleContainer`s of `Sprite`s).
|
|
84
|
+
*/
|
|
85
|
+
declare class PixiV7Renderer implements IRenderer<Container> {
|
|
86
|
+
/** An adapter over `options.ticker`, or over Pixi's shared one, that drives the engine's updates. */
|
|
87
|
+
readonly ticker: ITicker;
|
|
88
|
+
/** What this backend does with each blend mode — see `IRendererCapabilities`. */
|
|
89
|
+
readonly capabilities: IRendererCapabilities;
|
|
90
|
+
protected _textureCache: Map<unknown, ITextureRef>;
|
|
91
|
+
protected _nodes: PixiV7RenderNode[];
|
|
92
|
+
constructor(options?: PixiV7RendererOptions);
|
|
93
|
+
/** Detached: the caller mounts it where the animation should appear. */
|
|
94
|
+
createRootNode(): IRenderRootNode<Container>;
|
|
95
|
+
/** Called by a node when it is destroyed, so the renderer holds only live ones. */
|
|
96
|
+
protected _releaseNode(node: PixiV7RenderNode): void;
|
|
97
|
+
resolveTexture(source: unknown): ITextureRef;
|
|
98
|
+
/** See `IRenderer.clearTextureCache` — what a host calls after republishing an atlas. */
|
|
99
|
+
clearTextureCache(): void;
|
|
100
|
+
destroy(): void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface PerseonOptions {
|
|
104
|
+
/**
|
|
105
|
+
* What every animation runs off: the Pixi v7 `Ticker` — `app.ticker`,
|
|
106
|
+
* normally; defaults to `Ticker.shared` — or any `ITicker`, such as the
|
|
107
|
+
* `FakeTicker` of `@silentstatestudio/perseon/testing`, whose frames a test pumps by hand.
|
|
108
|
+
*/
|
|
109
|
+
ticker?: Ticker | ITicker;
|
|
110
|
+
/**
|
|
111
|
+
* What a recoverable misuse does — a Linked source that resolves to nothing,
|
|
112
|
+
* a number a `set` clips to its domain, a stale handle, a value of
|
|
113
|
+
* `setGlobalParameter` an animation that declares the global cannot take:
|
|
114
|
+
* `'warn'` prints it once per animation with the `Perseon - ` prefix,
|
|
115
|
+
* `'throw'` turns it into an error, `'silent'` drops it. Defaults to
|
|
116
|
+
* `'warn'`.
|
|
117
|
+
*/
|
|
118
|
+
diagnostics?: 'warn' | 'throw' | 'silent';
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Perseon on PixiJS v7 — the same class, the same name and the same API as the
|
|
122
|
+
* v8 one, an import path apart:
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { Perseon } from '@silentstatestudio/perseon/pixi-v7'
|
|
126
|
+
*
|
|
127
|
+
* const perseon = new Perseon({ ticker: app.ticker })
|
|
128
|
+
* const explosion = perseon.createAnimation(explosionConfig)
|
|
129
|
+
* explosion.play({ parent: world, x: hit.x, y: hit.y })
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* That is the point of the shape rather than a coincidence of it: everything
|
|
133
|
+
* above the renderer is `PerseonIntegration`, so the two backends cannot drift,
|
|
134
|
+
* and moving an app between Pixi majors is one line. What differs is only what
|
|
135
|
+
* this host hands over, which here happens to match v8 — a ticker — and will not
|
|
136
|
+
* for the next backend along.
|
|
137
|
+
*/
|
|
138
|
+
declare class Perseon extends PerseonIntegration<Container> {
|
|
139
|
+
/** Re-typed, not re-assigned — see the v8 integration. */
|
|
140
|
+
readonly renderer: PixiV7Renderer;
|
|
141
|
+
constructor(options?: PerseonOptions);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Adapts a PixiJS v7 `Ticker` to the engine-facing `ITicker` interface.
|
|
146
|
+
* In v7 the ticker callback receives `dt` (delta time in frames at 60fps),
|
|
147
|
+
* not milliseconds. We read `ticker.deltaMS` from the closure to feed the
|
|
148
|
+
* engine its expected ms-based delta.
|
|
149
|
+
*/
|
|
150
|
+
declare class PixiV7TickerAdapter implements ITicker {
|
|
151
|
+
protected _ticker: Ticker;
|
|
152
|
+
protected _wrapped: Map<(deltaMS: number) => void, () => void>;
|
|
153
|
+
constructor(ticker: Ticker);
|
|
154
|
+
add(fn: (deltaMS: number) => void): void;
|
|
155
|
+
remove(fn: (deltaMS: number) => void): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* What the PixiJS v7 adapter can do — see `IRendererCapabilities`.
|
|
160
|
+
*
|
|
161
|
+
* There is no filter path here to make the rest work: v7 renders particles
|
|
162
|
+
* through its own `ParticleContainer`, whose children never reach the advanced
|
|
163
|
+
* blend pipeline that arrived with v8. So the answer for those modes is
|
|
164
|
+
* `unsupported`, said out loud, rather than a promise the frame will not keep.
|
|
165
|
+
*/
|
|
166
|
+
declare class PixiV7RendererCapabilities implements IRendererCapabilities {
|
|
167
|
+
blendModeSupport(mode: ParticleBlendMode): BlendModeSupport;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Resolve the texture a scene names.
|
|
172
|
+
*
|
|
173
|
+
* Every string source is a **cache id**, with no exceptions: an animation names
|
|
174
|
+
* resources the host registered beforehand — `ParticleAnimationOptions` says as
|
|
175
|
+
* much, and this is where it holds — so a source resolves against `Assets.cache`
|
|
176
|
+
* and against nothing else. (`Assets` is part of PixiJS from 7.0 on, which is
|
|
177
|
+
* the whole of this adapter's peer range.) An id the cache does not know becomes
|
|
178
|
+
* `Texture.EMPTY`: one particle type pointing at a frame that is no longer
|
|
179
|
+
* published must not take an animation down, and a host that wants to report it
|
|
180
|
+
* asks ahead of time against the same cache.
|
|
181
|
+
*
|
|
182
|
+
* A URL is not a special case, and used to be treated as one. In v7 that did
|
|
183
|
+
* resolve — `Texture.from` takes a string it does not know for an image path —
|
|
184
|
+
* which is worse than it sounds: it starts a network request from inside the
|
|
185
|
+
* spawn path and hands back a texture that is not there yet. It also made the
|
|
186
|
+
* same scene file behave differently on each adapter, since v8's `Texture.from`
|
|
187
|
+
* reads the cache alone. What a host does instead is `await Assets.load(url)`,
|
|
188
|
+
* after which the URL *is* a cache id and resolves here like every other source.
|
|
189
|
+
*
|
|
190
|
+
* A source that is not a string is not an id, so it resolves to nothing.
|
|
191
|
+
*/
|
|
192
|
+
declare const textureFromSource: (source: unknown) => Texture;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The atlas `.json` `load` accepts, written out here because Pixi 7 names it
|
|
196
|
+
* `ISpritesheetData` and Pixi 8 `SpritesheetData`: importing either name would
|
|
197
|
+
* break the declarations for the other major. Structurally the same as both.
|
|
198
|
+
*/
|
|
199
|
+
interface PixiV7SpritesheetData {
|
|
200
|
+
frames: Record<string, {
|
|
201
|
+
frame: {
|
|
202
|
+
x: number;
|
|
203
|
+
y: number;
|
|
204
|
+
w: number;
|
|
205
|
+
h: number;
|
|
206
|
+
};
|
|
207
|
+
trimmed?: boolean;
|
|
208
|
+
rotated?: boolean;
|
|
209
|
+
sourceSize?: {
|
|
210
|
+
w: number;
|
|
211
|
+
h: number;
|
|
212
|
+
};
|
|
213
|
+
spriteSourceSize?: {
|
|
214
|
+
x: number;
|
|
215
|
+
y: number;
|
|
216
|
+
w?: number;
|
|
217
|
+
h?: number;
|
|
218
|
+
};
|
|
219
|
+
anchor?: {
|
|
220
|
+
x: number;
|
|
221
|
+
y: number;
|
|
222
|
+
};
|
|
223
|
+
borders?: {
|
|
224
|
+
left: number;
|
|
225
|
+
top: number;
|
|
226
|
+
right: number;
|
|
227
|
+
bottom: number;
|
|
228
|
+
};
|
|
229
|
+
}>;
|
|
230
|
+
animations?: Record<string, string[]>;
|
|
231
|
+
meta: {
|
|
232
|
+
app?: string;
|
|
233
|
+
format?: string;
|
|
234
|
+
frameTags?: {
|
|
235
|
+
from: number;
|
|
236
|
+
name: string;
|
|
237
|
+
to: number;
|
|
238
|
+
direction: string;
|
|
239
|
+
}[];
|
|
240
|
+
image?: string;
|
|
241
|
+
layers?: {
|
|
242
|
+
blendMode: string;
|
|
243
|
+
name: string;
|
|
244
|
+
opacity: number;
|
|
245
|
+
}[];
|
|
246
|
+
scale: number | string;
|
|
247
|
+
size?: {
|
|
248
|
+
w: number;
|
|
249
|
+
h: number;
|
|
250
|
+
};
|
|
251
|
+
slices?: {
|
|
252
|
+
color: string;
|
|
253
|
+
name: string;
|
|
254
|
+
keys: {
|
|
255
|
+
frame: number;
|
|
256
|
+
bounds: {
|
|
257
|
+
x: number;
|
|
258
|
+
y: number;
|
|
259
|
+
w: number;
|
|
260
|
+
h: number;
|
|
261
|
+
};
|
|
262
|
+
}[];
|
|
263
|
+
}[];
|
|
264
|
+
related_multi_packs?: string[];
|
|
265
|
+
version?: string;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/** Key the atlas is registered under in `Assets.cache` when none is given. */
|
|
269
|
+
declare const PARTICLE_ATLAS_CACHE_KEY = "perseon:particle-atlas";
|
|
270
|
+
/**
|
|
271
|
+
* Host-side loader for the atlas a scene's texture ids point at — the v7 half of
|
|
272
|
+
* `PixiV8ParticleAtlas`, with the same API and the same ownership rules.
|
|
273
|
+
*
|
|
274
|
+
* A serialized scene carries texture **ids**, not images: every
|
|
275
|
+
* `texture.source` names a frame the host is expected to have registered
|
|
276
|
+
* beforehand, which is what lets one atlas serve every particle in the scene
|
|
277
|
+
* 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 the editor exports
|
|
279
|
+
* and the ids in the scene file resolve.
|
|
280
|
+
*
|
|
281
|
+
* `Spritesheet.parse()` also adds every frame to Pixi's global texture cache,
|
|
282
|
+
* which `Texture.from` reads; what `textureFromSource` reads is `Assets.cache`, so
|
|
283
|
+
* registering the sheet there is what publishes the frames.
|
|
284
|
+
*
|
|
285
|
+
* Ownership is explicit, because getting it wrong corrupts Pixi's own cache:
|
|
286
|
+
* an image handed in as a `Texture` belongs to the caller, and one loaded here
|
|
287
|
+
* from a URL is released through `Assets.unload` rather than destroyed behind
|
|
288
|
+
* Assets' back (which would leave a dead entry for the next load of that URL).
|
|
289
|
+
* An image `Assets` already held before the load stays the host's and is never
|
|
290
|
+
* unloaded; one this class took is unloaded once no atlas holds it any more.
|
|
291
|
+
*
|
|
292
|
+
* Frame ids are global: each one becomes an unprefixed key in `Assets.cache`.
|
|
293
|
+
* Loading throws, before publishing anything, when an id is already cached by
|
|
294
|
+
* something no atlas published, so a host's own entries are never overwritten
|
|
295
|
+
* or deleted. Between atlases the last one to publish an id wins it, and
|
|
296
|
+
* destroying an atlas gives back only the ids it still owns. Each atlas needs
|
|
297
|
+
* its own `cacheKey`: loading throws when the key already holds an entry that
|
|
298
|
+
* is not this atlas's own sheet.
|
|
299
|
+
*
|
|
300
|
+
* Note on URLs: pass an `http(s):` or `data:` URL. Pixi's texture loader
|
|
301
|
+
* recognizes neither the extension nor the MIME type of a `blob:` URL, so an
|
|
302
|
+
* object URL must be read into a data URL (or a `Texture`) first.
|
|
303
|
+
*/
|
|
304
|
+
declare class PixiV7ParticleAtlas {
|
|
305
|
+
protected _cacheKey: string;
|
|
306
|
+
protected _spritesheet?: Spritesheet;
|
|
307
|
+
/** URL this instance acquired through `Assets`, so it releases exactly what it took. */
|
|
308
|
+
protected _loadedImageUrl?: string;
|
|
309
|
+
/**
|
|
310
|
+
* Generation counter. A host can call `load` again before the previous one
|
|
311
|
+
* settles (a user picking files quickly); without this the loser would
|
|
312
|
+
* publish its sheet over the winner's and leak the winner's.
|
|
313
|
+
*/
|
|
314
|
+
protected _loadToken: number;
|
|
315
|
+
/** @param cacheKey - The key the spritesheet is registered under in `Assets.cache`; give distinct keys to atlases that coexist. */
|
|
316
|
+
constructor(cacheKey?: string);
|
|
317
|
+
/** The spritesheet published by the last successful `load`, or `undefined` before one or after `destroy`. */
|
|
318
|
+
get spritesheet(): Spritesheet | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Frame ids of this atlas's sheet — the values a scene's `texture.source` may
|
|
321
|
+
* name. Another atlas may have published the same id since, and wins it.
|
|
322
|
+
*/
|
|
323
|
+
get frameIds(): string[];
|
|
324
|
+
/** Whether `frameId` is one of this atlas's frames (a later atlas may have published the same id since). */
|
|
325
|
+
hasFrame(frameId: string): boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Load an atlas and publish its frames. Replaces whatever this instance had
|
|
328
|
+
* loaded before, so a host can swap atlases as the user picks new files.
|
|
329
|
+
*
|
|
330
|
+
* @returns The parsed spritesheet. When a later `load` or `destroy` superseded
|
|
331
|
+
* this call before it finished, nothing was published and the sheet returned
|
|
332
|
+
* is one that never was and is already destroyed.
|
|
333
|
+
* @throws When the data lacks `frames` or `meta`; when a frame id is already
|
|
334
|
+
* cached by something no atlas published; or when this atlas's `cacheKey`
|
|
335
|
+
* already holds an entry that is not its own sheet. Nothing is published, the
|
|
336
|
+
* previous atlas stays loaded, and the image taken for this call is released.
|
|
337
|
+
*/
|
|
338
|
+
load(image: string | Texture, data: PixiV7SpritesheetData): Promise<Spritesheet>;
|
|
339
|
+
/** Unpublish the frames and release whatever this instance owns. */
|
|
340
|
+
destroy(): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Two atlases on one key would unpublish each other's frames without either
|
|
343
|
+
* knowing, and a key the host uses would be deleted. Throws instead, before
|
|
344
|
+
* anything is published. The sheet this instance already published is its own.
|
|
345
|
+
*/
|
|
346
|
+
protected _assertCacheKeyFree(): void;
|
|
347
|
+
/**
|
|
348
|
+
* Every frame becomes a global, unprefixed key in `Assets.cache`, so an id
|
|
349
|
+
* the host already uses would be overwritten and then deleted along with the
|
|
350
|
+
* atlas. Throws instead, before anything is published. An entry another atlas
|
|
351
|
+
* published is not the host's: the last atlas to publish an id wins it.
|
|
352
|
+
*/
|
|
353
|
+
protected _assertFrameIdsFree(data: PixiV7SpritesheetData): void;
|
|
354
|
+
/**
|
|
355
|
+
* Remove the entry published under this atlas's key, and with it the frames
|
|
356
|
+
* of `sheet`. Removing the key deletes every id the sheet published, so an id
|
|
357
|
+
* another atlas has since taken over is put back: it is not this one's to drop.
|
|
358
|
+
*/
|
|
359
|
+
protected _unpublish(sheet: Spritesheet | undefined): void;
|
|
360
|
+
/** Record that an atlas now holds `url`. */
|
|
361
|
+
protected _acquireUrl(url: string): void;
|
|
362
|
+
/** Give back a hold taken for a load that failed before anything was loaded. */
|
|
363
|
+
protected _returnUrl(url: string | undefined): void;
|
|
364
|
+
/**
|
|
365
|
+
* Let go of `url`, unloading it only once no atlas holds it any more.
|
|
366
|
+
* Unknown URLs are ignored, so a load still in flight when `destroy` lands
|
|
367
|
+
* releases its own acquisition without driving the count below zero.
|
|
368
|
+
*/
|
|
369
|
+
protected _releaseUrl(url: string | undefined): Promise<void>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export { BlendModeSupport, IParticleGroup, IParticleGroupOptions, IParticleVisualState, IRenderNode, IRenderRootNode, IRenderer, IRendererCapabilities, ITextureRef, ITicker, PARTICLE_ATLAS_CACHE_KEY, ParticleBlendMode, Perseon, type PerseonOptions, PixiV7ParticleAtlas, PixiV7ParticleGroup, PixiV7RenderNode, PixiV7Renderer, PixiV7RendererCapabilities, type PixiV7RendererOptions, type PixiV7SpritesheetData, PixiV7TickerAdapter, textureFromSource };
|