@holtjs/stage 0.6.0 → 0.8.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 +24 -0
- package/dist/anims-ClNi6zZQ.d.ts +391 -0
- package/dist/anims.d.ts +2 -0
- package/dist/anims.js +436 -0
- package/dist/{game-Blm49zGH.d.ts → game-CEa0m4eX.d.ts} +154 -203
- package/dist/{game-Ds-cn2YI.js → game-D46nY-B2.js} +187 -5
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +18 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +5 -3
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +1 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/{renderer-webgpu-DJVQHR70.js → renderer-webgpu-BXU-ZDIp.js} +507 -32
- package/dist/renderer-webgpu.d.ts +1 -1
- package/dist/renderer-webgpu.js +1 -1
- package/dist/rig2d.d.ts +2 -1
- package/dist/tilemap.d.ts +14 -3
- package/dist/tilemap.js +84 -10
- package/dist/trace.d.ts +1 -1
- package/dist/trace.js +7 -1
- package/package.json +5 -1
- package/skills/stage/SKILL.md +24 -7
- package/skills/stage/references/subpaths.md +11 -7
|
@@ -1,202 +1,5 @@
|
|
|
1
|
+
import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-ClNi6zZQ.js";
|
|
1
2
|
import { c as TweenManager, u as TweenStats } from "./tween-BiF1FUvc.js";
|
|
2
|
-
declare const AUTO = 0;
|
|
3
|
-
declare const CANVAS = 1;
|
|
4
|
-
declare const WEBGL = 2;
|
|
5
|
-
declare const WEBGPU = 3;
|
|
6
|
-
declare const BlendModes: {
|
|
7
|
-
readonly NORMAL: 0;
|
|
8
|
-
readonly ADD: 1;
|
|
9
|
-
readonly MULTIPLY: 2;
|
|
10
|
-
readonly SCREEN: 3;
|
|
11
|
-
};
|
|
12
|
-
type BlendMode = (typeof BlendModes)[keyof typeof BlendModes];
|
|
13
|
-
declare const TintModes: {
|
|
14
|
-
readonly MULTIPLY: 0;
|
|
15
|
-
readonly FILL: 1;
|
|
16
|
-
};
|
|
17
|
-
type TintMode = (typeof TintModes)[keyof typeof TintModes];
|
|
18
|
-
declare const FilterMode: {
|
|
19
|
-
readonly LINEAR: 0;
|
|
20
|
-
readonly NEAREST: 1;
|
|
21
|
-
};
|
|
22
|
-
type FilterModeValue = (typeof FilterMode)[keyof typeof FilterMode];
|
|
23
|
-
declare const Scale: {
|
|
24
|
-
readonly NONE: 0;
|
|
25
|
-
readonly FIT: 1;
|
|
26
|
-
readonly RESIZE: 2;
|
|
27
|
-
};
|
|
28
|
-
type ScaleMode = (typeof Scale)[keyof typeof Scale];
|
|
29
|
-
declare const Scenes: {
|
|
30
|
-
readonly PENDING: 0;
|
|
31
|
-
readonly INIT: 1;
|
|
32
|
-
readonly START: 2;
|
|
33
|
-
readonly LOADING: 3;
|
|
34
|
-
readonly CREATING: 4;
|
|
35
|
-
readonly RUNNING: 5;
|
|
36
|
-
readonly PAUSED: 6;
|
|
37
|
-
readonly SLEEPING: 7;
|
|
38
|
-
readonly SHUTDOWN: 8;
|
|
39
|
-
readonly DESTROYED: 9;
|
|
40
|
-
};
|
|
41
|
-
/** Canonical neutral white & black integers (kept here once for color-check cleanliness). */
|
|
42
|
-
declare const WHITE_RGB = 16777215;
|
|
43
|
-
declare const BLACK_RGB = 0;
|
|
44
|
-
declare const HEX_MASK = 16777215;
|
|
45
|
-
interface Rect2D {
|
|
46
|
-
x: number;
|
|
47
|
-
y: number;
|
|
48
|
-
width: number;
|
|
49
|
-
height: number;
|
|
50
|
-
left: number;
|
|
51
|
-
right: number;
|
|
52
|
-
top: number;
|
|
53
|
-
bottom: number;
|
|
54
|
-
}
|
|
55
|
-
interface WorldView2D {
|
|
56
|
-
x: number;
|
|
57
|
-
y: number;
|
|
58
|
-
width: number;
|
|
59
|
-
height: number;
|
|
60
|
-
right: number;
|
|
61
|
-
bottom: number;
|
|
62
|
-
}
|
|
63
|
-
interface Matrix2D {
|
|
64
|
-
a: number;
|
|
65
|
-
b: number;
|
|
66
|
-
c: number;
|
|
67
|
-
d: number;
|
|
68
|
-
tx: number;
|
|
69
|
-
ty: number;
|
|
70
|
-
scaleX: number;
|
|
71
|
-
scaleY: number;
|
|
72
|
-
}
|
|
73
|
-
interface RgbaColor {
|
|
74
|
-
r: number;
|
|
75
|
-
g: number;
|
|
76
|
-
b: number;
|
|
77
|
-
a: number;
|
|
78
|
-
}
|
|
79
|
-
declare function createMatrix2D(): Matrix2D;
|
|
80
|
-
/** Parse a CSS hex/rgb(a) string or 0xRRGGBB number into normalized [0..1] RGBA. */
|
|
81
|
-
declare function parseColor(input: string | number | null | undefined, fallbackAlpha?: number): RgbaColor;
|
|
82
|
-
/** Convert 0xRRGGBB + alpha [0..1] into a CSS rgba(...) string. */
|
|
83
|
-
declare function rgbToCss(color: number, alpha?: number): string;
|
|
84
|
-
/** Pack 0xRRGGBB + alpha [0..1] into little-endian ABGR Uint32 (matches GL UNSIGNED_BYTE vec4 r,g,b,a). */
|
|
85
|
-
declare function packColorAbgr(rgb: number, alpha: number): number;
|
|
86
|
-
/** Lightweight, allocation-conscious event emitter compatible with Phaser's EventEmitter surface. */
|
|
87
|
-
declare class EventEmitter {
|
|
88
|
-
private readonly map;
|
|
89
|
-
on(event: string, fn: (...args: any[]) => void, ctx?: unknown): this;
|
|
90
|
-
once(event: string, fn: (...args: any[]) => void, ctx?: unknown): this;
|
|
91
|
-
off(event: string, fn?: (...args: any[]) => void, ctx?: unknown): this;
|
|
92
|
-
emit(event: string, ...args: any[]): boolean;
|
|
93
|
-
removeAllListeners(event?: string): this;
|
|
94
|
-
}
|
|
95
|
-
type TextureImageSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap;
|
|
96
|
-
interface SpriteSheetConfig {
|
|
97
|
-
frameWidth: number;
|
|
98
|
-
frameHeight: number;
|
|
99
|
-
margin?: number;
|
|
100
|
-
spacing?: number;
|
|
101
|
-
}
|
|
102
|
-
interface TextureImageOptions {
|
|
103
|
-
filterMode?: FilterModeValue;
|
|
104
|
-
/** Default `true` for standard premultiplied sprites; set `false` for raw data textures such as MTSDF atlases. */
|
|
105
|
-
premultiplyAlpha?: boolean;
|
|
106
|
-
/** Internal flag for offscreen FBO render targets whose GPU storage is allocated via 9-arg `texImage2D(..., null)`. */
|
|
107
|
-
isRenderTarget?: boolean;
|
|
108
|
-
}
|
|
109
|
-
interface GlTextureHost {
|
|
110
|
-
readonly gl: WebGL2RenderingContext | WebGLRenderingContext | null;
|
|
111
|
-
readonly contextLost: boolean;
|
|
112
|
-
uploadTextureSource(src: TextureSource): void;
|
|
113
|
-
deleteTextureSource(src: TextureSource): void;
|
|
114
|
-
setTextureFilter(src: TextureSource): void;
|
|
115
|
-
}
|
|
116
|
-
declare class TextureSource {
|
|
117
|
-
private static nextId;
|
|
118
|
-
readonly id: number;
|
|
119
|
-
version: number;
|
|
120
|
-
readonly texture: Texture;
|
|
121
|
-
image: TextureImageSource;
|
|
122
|
-
width: number;
|
|
123
|
-
height: number;
|
|
124
|
-
resolution: number;
|
|
125
|
-
filterMode: FilterModeValue;
|
|
126
|
-
premultiplyAlpha: boolean;
|
|
127
|
-
glPremultiplyAlpha: boolean;
|
|
128
|
-
repeat: boolean;
|
|
129
|
-
glRepeat: boolean;
|
|
130
|
-
glTexture: WebGLTexture | null;
|
|
131
|
-
glWidth: number;
|
|
132
|
-
glHeight: number;
|
|
133
|
-
dirty: boolean;
|
|
134
|
-
readonly isRenderTarget: boolean;
|
|
135
|
-
private host;
|
|
136
|
-
constructor(texture: Texture, image: TextureImageSource, filterMode: FilterModeValue, host: GlTextureHost | null, premultiplyAlpha?: boolean, isRenderTarget?: boolean);
|
|
137
|
-
setFilter(mode: FilterModeValue): void;
|
|
138
|
-
setPremultiplyAlpha(on: boolean): void;
|
|
139
|
-
update(): void;
|
|
140
|
-
destroy(): void;
|
|
141
|
-
}
|
|
142
|
-
declare class Frame {
|
|
143
|
-
readonly texture: Texture;
|
|
144
|
-
readonly name: string | number;
|
|
145
|
-
readonly sourceIndex: number;
|
|
146
|
-
readonly source: TextureSource;
|
|
147
|
-
cutX: number;
|
|
148
|
-
cutY: number;
|
|
149
|
-
cutWidth: number;
|
|
150
|
-
cutHeight: number;
|
|
151
|
-
width: number;
|
|
152
|
-
height: number;
|
|
153
|
-
u0: number;
|
|
154
|
-
v0: number;
|
|
155
|
-
u1: number;
|
|
156
|
-
v1: number;
|
|
157
|
-
constructor(texture: Texture, name: string | number, sourceIndex: number, x: number, y: number, w: number, h: number);
|
|
158
|
-
setSize(width: number, height: number, x?: number, y?: number): this;
|
|
159
|
-
updateUVs(): void;
|
|
160
|
-
}
|
|
161
|
-
declare class Texture {
|
|
162
|
-
readonly manager: TextureManager;
|
|
163
|
-
readonly key: string;
|
|
164
|
-
readonly source: TextureSource[];
|
|
165
|
-
readonly frames: Record<string, Frame>;
|
|
166
|
-
constructor(manager: TextureManager, key: string, image: TextureImageSource, filterMode: FilterModeValue, host: GlTextureHost | null, premultiplyAlpha?: boolean, isRenderTarget?: boolean);
|
|
167
|
-
add(name: string | number, sourceIndex: number, x: number, y: number, width: number, height: number): Frame;
|
|
168
|
-
has(name: string | number): boolean;
|
|
169
|
-
get(name?: string | number): Frame;
|
|
170
|
-
remove(name: string | number): boolean;
|
|
171
|
-
setFilter(mode: FilterModeValue): this;
|
|
172
|
-
setPremultiplyAlpha(on: boolean): this;
|
|
173
|
-
getSourceImage(sourceIndex?: number): TextureImageSource;
|
|
174
|
-
destroy(): void;
|
|
175
|
-
}
|
|
176
|
-
declare class CanvasTexture extends Texture {
|
|
177
|
-
readonly canvas: HTMLCanvasElement;
|
|
178
|
-
readonly context: CanvasRenderingContext2D;
|
|
179
|
-
constructor(manager: TextureManager, key: string, canvas: HTMLCanvasElement, filterMode: FilterModeValue, host: GlTextureHost | null);
|
|
180
|
-
getContext(): CanvasRenderingContext2D;
|
|
181
|
-
refresh(): this;
|
|
182
|
-
}
|
|
183
|
-
declare class TextureManager {
|
|
184
|
-
readonly list: Record<string, Texture>;
|
|
185
|
-
private defaultFilter;
|
|
186
|
-
private host;
|
|
187
|
-
private readonly doc;
|
|
188
|
-
constructor(pixelArt: boolean, host: GlTextureHost | null, doc?: Document);
|
|
189
|
-
private initBuiltins;
|
|
190
|
-
exists(key: string): boolean;
|
|
191
|
-
get(key: string): Texture;
|
|
192
|
-
addImage(key: string, source: TextureImageSource, options?: TextureImageOptions): Texture | null;
|
|
193
|
-
addCanvas(key: string, canvas: HTMLCanvasElement): CanvasTexture | null;
|
|
194
|
-
createCanvas(key: string, width: number, height: number): CanvasTexture | null;
|
|
195
|
-
addSpriteSheet(key: string, source: TextureImageSource, config: SpriteSheetConfig): Texture | null;
|
|
196
|
-
remove(key: string): boolean;
|
|
197
|
-
invalidateAllGl(): void;
|
|
198
|
-
destroy(): void;
|
|
199
|
-
}
|
|
200
3
|
interface CameraFollowOptions {
|
|
201
4
|
/** Horizontal smoothing factor in `(0, 1]` (`1` = instant lock; default `1`). */
|
|
202
5
|
lerpX?: number;
|
|
@@ -353,7 +156,7 @@ declare class Camera {
|
|
|
353
156
|
/** Recompute `worldView` and world->canvas `matrixCombined`. */
|
|
354
157
|
syncMetrics(): void;
|
|
355
158
|
}
|
|
356
|
-
type DisplayObjectType = 'Image' | 'NineSlice' | 'TileSprite' | 'Rectangle' | 'Panel' | 'MsdfIcon' | 'Text' | 'Graphics' | 'Blitter' | 'InstancedBatch' | 'ShapeBatch' | 'Container' | 'CustomPass';
|
|
159
|
+
type DisplayObjectType = 'Image' | 'Sprite' | 'NineSlice' | 'TileSprite' | 'Rectangle' | 'Panel' | 'MsdfIcon' | 'Text' | 'Graphics' | 'Blitter' | 'InstancedBatch' | 'ShapeBatch' | 'Container' | 'CustomPass';
|
|
357
160
|
type SceneHostLike = Scene;
|
|
358
161
|
declare class DisplayList {
|
|
359
162
|
readonly list: DisplayObject[];
|
|
@@ -392,7 +195,7 @@ declare abstract class DisplayObject extends EventEmitter {
|
|
|
392
195
|
rotation: number;
|
|
393
196
|
alpha: number;
|
|
394
197
|
depth: number;
|
|
395
|
-
|
|
198
|
+
private _zIndex;
|
|
396
199
|
trackId: string | null;
|
|
397
200
|
alt: string | null;
|
|
398
201
|
role: string | null;
|
|
@@ -407,7 +210,7 @@ declare abstract class DisplayObject extends EventEmitter {
|
|
|
407
210
|
scrollFactorX: number;
|
|
408
211
|
scrollFactorY: number;
|
|
409
212
|
parentContainer: Container | null;
|
|
410
|
-
|
|
213
|
+
customOrigin: boolean;
|
|
411
214
|
protected _displayOriginX: number;
|
|
412
215
|
protected _displayOriginY: number;
|
|
413
216
|
private disposers;
|
|
@@ -430,6 +233,8 @@ declare abstract class DisplayObject extends EventEmitter {
|
|
|
430
233
|
setAngle(deg: number): this;
|
|
431
234
|
setAlpha(a: number): this;
|
|
432
235
|
setDepth(d: number): this;
|
|
236
|
+
get zIndex(): number;
|
|
237
|
+
set zIndex(z: number);
|
|
433
238
|
/** Native container-local stacking order (0 by default; sorted stably when any sibling has non-zero zIndex). */
|
|
434
239
|
setZIndex(z: number): this;
|
|
435
240
|
/** Attach a stable, privacy-safe telemetry/automation identifier (never user text or PII). */
|
|
@@ -472,15 +277,144 @@ declare class ImageObject extends DisplayObject {
|
|
|
472
277
|
cropW: number;
|
|
473
278
|
cropH: number;
|
|
474
279
|
readonly customRenderNodes: Record<string, any>;
|
|
475
|
-
constructor(scene: SceneHostLike, x: number, y: number, key: string, frame?: string | number);
|
|
280
|
+
constructor(scene: SceneHostLike, x: number, y: number, key: string, frame?: string | number, nodeType?: DisplayObjectType);
|
|
281
|
+
get displayOriginX(): number;
|
|
282
|
+
get displayOriginY(): number;
|
|
283
|
+
protected _syncFrameOrigin(): void;
|
|
284
|
+
/** Clear any manual `setOrigin()` override so per-frame baked pivots (`ax/ay` or `pivotX/pivotY`) drive alignment automatically. */
|
|
285
|
+
useFramePivot(): this;
|
|
476
286
|
setTexture(key: string, frame?: string | number): this;
|
|
477
287
|
setFrame(frame: string | number): this;
|
|
288
|
+
/**
|
|
289
|
+
* Compute the exact transformed coordinates of a named per-frame pixel socket (e.g. `'hand'`, `'head'`, `'emissive'`)
|
|
290
|
+
* accounting for trimmed `displayOrigin`, `flipX`/`flipY`, `scaleX`/`scaleY`, `rotation`, and ancestor `Container`s.
|
|
291
|
+
*/
|
|
292
|
+
getAnchor(name: string, space?: 'local' | 'parent' | 'world', out?: {
|
|
293
|
+
x: number;
|
|
294
|
+
y: number;
|
|
295
|
+
}): {
|
|
296
|
+
x: number;
|
|
297
|
+
y: number;
|
|
298
|
+
} | null;
|
|
299
|
+
/**
|
|
300
|
+
* Read the full transformed 2D pose (`x`, `y`, `rotation`, `zBias`, `hasAngle`) of an oriented socket
|
|
301
|
+
* (`[x, y, angleRad, zBias]` from `@holtjs/craft/three` `charKit.handSocket`), transforming the 2D grip
|
|
302
|
+
* tangent vector through the exact `flip -> scale -> rotate -> parentContainer` Jacobian!
|
|
303
|
+
*/
|
|
304
|
+
getAnchorPose(name: string, space?: 'local' | 'parent' | 'world', out?: AnchorPose2D): AnchorPose2D | null;
|
|
305
|
+
/**
|
|
306
|
+
* Align an equipped weapon/tool `DisplayObject` (`axe`, `spear`, `torch`, `shield`) to a named socket (`'hand'`) in one call:
|
|
307
|
+
* - Sets `child.x` & `child.y` to the transformed socket position
|
|
308
|
+
* - Rotates `child.rotation` so `restAngle` (default `-Math.PI / 2` = upright sprite) aligns with the socket's projected 2D shaft angle
|
|
309
|
+
* - Mirrors asymmetric blades (`mirrorBlade: true`) across the shaft axis via `O(2)` reflection when aiming left (`cos < 0`) so single-bladed axes never strike backwards!
|
|
310
|
+
* - Applies `zBias` (`+1` in front of body, `-1` behind body) via `child.setZIndex(baseZIndex + zBias)`
|
|
311
|
+
*/
|
|
312
|
+
syncAttachment(child: DisplayObject, anchorName: string, opts?: SyncAttachmentOptions): boolean;
|
|
478
313
|
setTint(color: number): this;
|
|
479
314
|
setTintMode(mode: TintMode): this;
|
|
480
315
|
clearTint(): this;
|
|
481
316
|
setPixelAA(on?: boolean): this;
|
|
482
317
|
setCrop(x?: number, y?: number, w?: number, h?: number): this;
|
|
483
318
|
}
|
|
319
|
+
interface AnchorPose2D {
|
|
320
|
+
x: number;
|
|
321
|
+
y: number;
|
|
322
|
+
/** Transformed 2D aim/shaft angle in radians (`[-PI, PI]`), accounting for `flipX`, `flipY`, `rotation`, and ancestor `Container`s. */
|
|
323
|
+
rotation: number;
|
|
324
|
+
/** Front/back occlusion hint (`+1` in front of body, `-1` behind body). */
|
|
325
|
+
zBias: number;
|
|
326
|
+
/** True when the baked frame socket included an explicit 3D->2D projected angle (`[x, y, angleRad, zBias]`). */
|
|
327
|
+
hasAngle: boolean;
|
|
328
|
+
}
|
|
329
|
+
interface SyncAttachmentOptions {
|
|
330
|
+
/**
|
|
331
|
+
* Screen-space angle (in radians) at which the attachment sprite's shaft points in its own unrotated frame.
|
|
332
|
+
* Default `-Math.PI / 2` (pointing straight UP `-Y`, matching upright weapons/tools baked along `+Y` in `@holtjs/craft/three`).
|
|
333
|
+
*/
|
|
334
|
+
readonly restAngle?: number;
|
|
335
|
+
/** Additional additive angle offset in radians (automatically negated when `mirrorBlade` mirrors leftward aims). */
|
|
336
|
+
readonly angleOffset?: number;
|
|
337
|
+
/** Mirror asymmetric blades (axes, scythes, pistols) across their shaft axis when aiming left (`cos < 0`). Default `true`. */
|
|
338
|
+
readonly mirrorBlade?: boolean;
|
|
339
|
+
/** Coordinate space used to align `child` (`'local' | 'parent' | 'world'`; default `'parent'`). */
|
|
340
|
+
readonly space?: 'local' | 'parent' | 'world';
|
|
341
|
+
/** Base `zIndex` around which `pose.zBias` (`+1` front / `-1` behind) is applied (`default = this.zIndex`; `false` skips `zIndex`). */
|
|
342
|
+
readonly baseZIndex?: number | false;
|
|
343
|
+
}
|
|
344
|
+
interface SpritePlayOptions {
|
|
345
|
+
/** Keep current animation running untouched when already playing the requested key (default `false`, or pass boolean shorthand `sprite.play(key, true)`). */
|
|
346
|
+
readonly ignoreIfPlaying?: boolean;
|
|
347
|
+
/** Zero-based frame index to start on (default `0`). */
|
|
348
|
+
readonly startFrame?: number;
|
|
349
|
+
/** Carry over normalized gait cycle progress `[0..1)` from the currently playing animation so direction turns never reset to frame 0! */
|
|
350
|
+
readonly preservePhase?: boolean;
|
|
351
|
+
/** Playback speed multiplier (default `1`). */
|
|
352
|
+
readonly timeScale?: number;
|
|
353
|
+
/** Optional override for `anim.repeat` (`-1` loop, `0` once, `N > 0` repeats). */
|
|
354
|
+
readonly repeat?: number;
|
|
355
|
+
}
|
|
356
|
+
interface DirectionalPlayOptions {
|
|
357
|
+
/** Active `Camera25D.yaw` in radians so character facing automatically compensates for rotatable 2.5D camera spin (`default = 0`). */
|
|
358
|
+
readonly cameraYaw?: number;
|
|
359
|
+
/** Override baked `atlasYaw` in radians (defaults to `group.atlasYaw`, e.g. `Math.PI / 4` from `@holtjs/craft/three`). */
|
|
360
|
+
readonly atlasYaw?: number;
|
|
361
|
+
/** Preserve walk-cycle phase when switching between directions of the same `baseKey` (default `true`). */
|
|
362
|
+
readonly preservePhase?: boolean;
|
|
363
|
+
/** Playback speed multiplier (default `1`). */
|
|
364
|
+
readonly timeScale?: number;
|
|
365
|
+
/** Optional override for `anim.repeat`. */
|
|
366
|
+
readonly repeat?: number;
|
|
367
|
+
}
|
|
368
|
+
type SpriteAnimEventListener = (eventName: string, animKey: string, frameIndex: number, frameName: string | number) => void;
|
|
369
|
+
/**
|
|
370
|
+
* First-class animated 2D / 2.5D sprite (`scene.add.sprite(x, y, key, frame)`).
|
|
371
|
+
* - Automatically aligns per-frame trimmed pivots (`ax/ay`) & transforms named sockets (`getAnchor('hand')`)
|
|
372
|
+
* - Deterministic simulation-stepped clip playback (`play`, `playDirectional`, `stop`, `pause`, `resume`)
|
|
373
|
+
* - Phase-preserving 4/8-directional locomotion (`playDirectional`) aligned with `Camera25D` & `@holtjs/craft`
|
|
374
|
+
* - Exact frame-crossing event callbacks (`onAnimEvent` for `footstep`, `hit`, etc.)
|
|
375
|
+
*/
|
|
376
|
+
declare class SpriteObject extends ImageObject {
|
|
377
|
+
private _anim;
|
|
378
|
+
private _frameIdx;
|
|
379
|
+
private _frameElapsedMs;
|
|
380
|
+
private _forward;
|
|
381
|
+
private _repeatsLeft;
|
|
382
|
+
private _playing;
|
|
383
|
+
private _paused;
|
|
384
|
+
private _timeScale;
|
|
385
|
+
private _activeDirBase;
|
|
386
|
+
private _activeDirIndex;
|
|
387
|
+
private readonly _animListeners;
|
|
388
|
+
constructor(scene: SceneHostLike, x: number, y: number, key: string, frame?: string | number);
|
|
389
|
+
get currentAnim(): StageAnimation | null;
|
|
390
|
+
get currentAnimKey(): string | null;
|
|
391
|
+
get currentFrameIndex(): number;
|
|
392
|
+
get currentDirection(): number;
|
|
393
|
+
get isPlaying(): boolean;
|
|
394
|
+
get timeScale(): number;
|
|
395
|
+
setTimeScale(scale: number): this;
|
|
396
|
+
onAnimEvent(fn: SpriteAnimEventListener): () => void;
|
|
397
|
+
/** Normalized progress `[0..1)` through the current forward pass of the active animation. */
|
|
398
|
+
get cycleProgress(): number;
|
|
399
|
+
/** Play a registered animation clip by key (or `StageAnimation` object). Fails fast if `key` does not exist! */
|
|
400
|
+
play(keyOrAnim: string | StageAnimation, opts?: SpritePlayOptions | boolean): this;
|
|
401
|
+
/**
|
|
402
|
+
* Play a 4- or 8-directional animation group (e.g. `'survivor/walk'` or `'zombie/attack'`) quantized by
|
|
403
|
+
* world movement angle `headingRad = Math.atan2(vy, vx)` and optional `Camera25D.yaw`!
|
|
404
|
+
*
|
|
405
|
+
* Automatically preserves stride phase when turning between directions of the same clip (`walk/d0 -> walk/d1`)
|
|
406
|
+
* so characters never freeze on frame 0 or stutter mid-step!
|
|
407
|
+
*/
|
|
408
|
+
playDirectional(baseKey: string, headingRad: number, opts?: DirectionalPlayOptions): this;
|
|
409
|
+
pause(): this;
|
|
410
|
+
resume(): this;
|
|
411
|
+
stop(): this;
|
|
412
|
+
/** Internal deterministic simulation step invoked by `Scene._stepAnimations(dt)`. */
|
|
413
|
+
_stepAnim(deltaMs: number): void;
|
|
414
|
+
private _applyAnimFrame;
|
|
415
|
+
private _finishAnim;
|
|
416
|
+
destroy(fromScene?: boolean): void;
|
|
417
|
+
}
|
|
484
418
|
declare class NineSliceObject extends DisplayObject {
|
|
485
419
|
texture: Texture;
|
|
486
420
|
frame: Frame;
|
|
@@ -1127,11 +1061,14 @@ declare class Renderer2D extends EventEmitter {
|
|
|
1127
1061
|
private tintCtx;
|
|
1128
1062
|
private readonly tintCache;
|
|
1129
1063
|
private readonly maskWorldMat;
|
|
1064
|
+
private readonly rootScrollMat;
|
|
1065
|
+
private readonly matPool;
|
|
1130
1066
|
private readonly pathCache;
|
|
1131
1067
|
private curDrawCalls;
|
|
1132
1068
|
private curFlushes;
|
|
1133
1069
|
private curQuads;
|
|
1134
1070
|
private curTris;
|
|
1071
|
+
private curCulled;
|
|
1135
1072
|
private curSdfPanels;
|
|
1136
1073
|
private curMsdfIcons;
|
|
1137
1074
|
private readonly lastStats;
|
|
@@ -1153,6 +1090,8 @@ declare class Renderer2D extends EventEmitter {
|
|
|
1153
1090
|
};
|
|
1154
1091
|
resize(width: number, height: number): void;
|
|
1155
1092
|
private getTintedSource;
|
|
1093
|
+
private isOffscreen;
|
|
1094
|
+
private mulMat;
|
|
1156
1095
|
private renderImage;
|
|
1157
1096
|
private renderNineSlice;
|
|
1158
1097
|
private renderTileSprite;
|
|
@@ -1399,6 +1338,10 @@ interface SceneDigestNode {
|
|
|
1399
1338
|
depth: number;
|
|
1400
1339
|
alpha: number;
|
|
1401
1340
|
bounds: [number, number, number, number];
|
|
1341
|
+
/** Active animation clip key when `type === 'Sprite'` (sanitized token). */
|
|
1342
|
+
anim?: string | null;
|
|
1343
|
+
/** Current texture frame name when `type === 'Sprite'` or `'Image'` (sanitized token). */
|
|
1344
|
+
frame?: string | null;
|
|
1402
1345
|
}
|
|
1403
1346
|
interface SceneDigestOverlayStats {
|
|
1404
1347
|
popovers: number;
|
|
@@ -1784,6 +1727,7 @@ declare class LoaderPlugin extends EventEmitter {
|
|
|
1784
1727
|
setCORS(value: string | null): this;
|
|
1785
1728
|
image(key: string, url: string, options?: TextureImageOptions): this;
|
|
1786
1729
|
spritesheet(key: string, url: string, config: SpriteSheetConfig): this;
|
|
1730
|
+
atlas(key: string, imageUrl: string, atlasData: AtlasJsonLike, options?: TextureImageOptions): this;
|
|
1787
1731
|
get hasQueued(): boolean;
|
|
1788
1732
|
pendingKeys(): string[];
|
|
1789
1733
|
cancel(): void;
|
|
@@ -1803,6 +1747,7 @@ declare class GameObjectFactory {
|
|
|
1803
1747
|
constructor(scene: Scene, addToList: boolean);
|
|
1804
1748
|
private register;
|
|
1805
1749
|
image(x: number, y: number, key: string, frame?: string | number): ImageObject;
|
|
1750
|
+
sprite(x: number, y: number, key: string, frame?: string | number): SpriteObject;
|
|
1806
1751
|
nineslice(x: number, y: number, key: string, frame: string | number | undefined, width: number, height: number, left: number, right: number, top: number, bottom: number): NineSliceObject;
|
|
1807
1752
|
tileSprite(x: number, y: number, width: number, height: number, key: string, frame?: string | number): TileSpriteObject;
|
|
1808
1753
|
rectangle(x: number, y: number, width: number, height: number, fillColor?: number, fillAlpha?: number): RectangleObject;
|
|
@@ -1863,6 +1808,7 @@ declare class Scene {
|
|
|
1863
1808
|
readonly events: EventEmitter;
|
|
1864
1809
|
/** Deterministic EngineClock-driven tween & spring manager (auto-stepped in `Game.step()`). */
|
|
1865
1810
|
readonly tweens: TweenManager;
|
|
1811
|
+
private readonly _animatedSprites;
|
|
1866
1812
|
private _nodesCreated;
|
|
1867
1813
|
private _nodesDestroyed;
|
|
1868
1814
|
private _disposersRan;
|
|
@@ -1883,6 +1829,7 @@ declare class Scene {
|
|
|
1883
1829
|
clock: EngineClock;
|
|
1884
1830
|
renderer: StageRenderer;
|
|
1885
1831
|
textures: TextureManager;
|
|
1832
|
+
anims: AnimationManager;
|
|
1886
1833
|
scale: ScaleManager;
|
|
1887
1834
|
input: InputPlugin;
|
|
1888
1835
|
load: LoaderPlugin;
|
|
@@ -1916,6 +1863,9 @@ declare class Scene {
|
|
|
1916
1863
|
lifecycleStats(): SceneLifecycleStats;
|
|
1917
1864
|
/** Lightweight active/completed/cancelled tween & spring counters for `sceneDigest()` and `perf()`. */
|
|
1918
1865
|
tweenStats(): TweenStats;
|
|
1866
|
+
_registerAnimatedSprite(sprite: SpriteObject): void;
|
|
1867
|
+
_unregisterAnimatedSprite(sprite: SpriteObject): void;
|
|
1868
|
+
_stepAnimations(deltaMs: number): void;
|
|
1919
1869
|
_invalidateTextGl(): void;
|
|
1920
1870
|
_destroy(): void;
|
|
1921
1871
|
}
|
|
@@ -1956,6 +1906,7 @@ declare class Game {
|
|
|
1956
1906
|
readonly canvas: HTMLCanvasElement;
|
|
1957
1907
|
readonly renderer: StageRenderer;
|
|
1958
1908
|
readonly textures: TextureManager;
|
|
1909
|
+
readonly anims: AnimationManager;
|
|
1959
1910
|
readonly scale: ScaleManager;
|
|
1960
1911
|
readonly input: InputPlugin;
|
|
1961
1912
|
readonly cache: {
|
|
@@ -1980,4 +1931,4 @@ declare class Game {
|
|
|
1980
1931
|
step(time: number, delta: number): void;
|
|
1981
1932
|
destroy(removeCanvas?: boolean): void;
|
|
1982
1933
|
}
|
|
1983
|
-
export { WebGpuBootstrapResult as $,
|
|
1934
|
+
export { WebGpuBootstrapResult as $, createInputRecorder as A, PanelOpenSide as At, SceneDigestSurfaceEntry as B, SpritePlayOptions as Bt, RecordedInputEntry as C, ImageObject as Ct, TimelineClickOptions as D, MsdfIconObject as Dt, StagePlugin as E, MsdfIconConfig as Et, SceneDigestEngineSandbox as F, ShapeBatchColumns as Ft, InputConfig as G, Camera as Gt, SceneDigestSurfaces as H, TextObject as Ht, SceneDigestNode as I, ShapeBatchObject as It, Pointer as J, HiDpiScaleLike as Jt, InputPlugin as K, CameraFollowOptions as Kt, SceneDigestOptions as L, ShapeBatchStyleDefaults as Lt, createInputTimeline as M, RectClipMask as Mt, SceneDigest as N, RectangleObject as Nt, TimelineDragOptions as O, NineSliceObject as Ot, SceneDigestActiveFocus as P, SceneHostLike as Pt, RequestWebGpuOptions as Q, SceneDigestOverlayStats as R, SpriteAnimEventListener as Rt, InputTimelinePlugin as S, Graphics as St, StageKernel as T, InstancedColumns as Tt, buildSceneDigest as U, TextStyleConfig as Ut, SceneDigestSurfaceSource as V, SyncAttachmentOptions as Vt, sanitizeTrackToken as W, TileSpriteObject as Wt, RendererWebGpu as X, PointerSample as Y, RendererWebGpuOptions as Z, ActionMap as _, DirectionalPlayOptions as _t, GameLoop as a, RendererGlOptions as at, InputTargetSpec as b, DisplayObjectType as bt, LoaderPlugin as c, StageRenderTarget as ct, SceneCtor as d, Bob as dt, WebGpuCanvasContextLike as et, SceneInput as f, Container as ft, ViewportFitResult as g, CustomPassOptions as gt, StageRenderer as h, CustomPassObject as ht, GameConfig as i, RendererGl as it, createInputReplay as j, PanelStyleConfig as jt, TimelineKeyOptions as k, PanelObject as kt, ScaleManager as l, AnchorPose2D as lt, SceneManager as m, CustomPassCallback as mt, EngineClockSnapshot as n, requestWebGpuDevice as nt, GameObjectFactory as o, RendererStats as ot, SceneLifecycleStats as p, ContainerFiltersShim as pt, KeyboardPlugin as q, HiDpiConfigureOptions as qt, Game as r, Renderer2D as rt, JsonCache as s, Stage2DCustomImageHandler as st, EngineClock as t, WebGpuDeviceLike as tt, Scene as u, BlitterObject as ut, InputProvider as v, DisplayList as vt, StageInputEvent as w, InstancedBatchObject as wt, InputTimelineOptions as x, DisplaySemantics as xt, InputRecorderPlugin as y, DisplayObject as yt, SceneDigestSandbox as z, SpriteObject as zt };
|