cute-cube 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/README.md +99 -0
- package/assets/sheets/neutral_celebrating_512.png +0 -0
- package/assets/sheets/neutral_click_512.png +0 -0
- package/assets/sheets/neutral_idle_512.png +0 -0
- package/assets/sheets/neutral_talk_512.png +0 -0
- package/assets/sheets/neutral_thinking_512.png +0 -0
- package/assets/sheets/neutral_to_sad.png +0 -0
- package/assets/sheets/sad_celebrating_512.png +0 -0
- package/assets/sheets/sad_click_512.png +0 -0
- package/assets/sheets/sad_idle_512.png +0 -0
- package/assets/sheets/sad_talk_512.png +0 -0
- package/assets/sheets/sad_thinking_512.png +0 -0
- package/assets/sheets/sad_to_neutral.png +0 -0
- package/dist/index.cjs +1001 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +264 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +983 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +865 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +21 -0
- package/dist/react.d.ts +21 -0
- package/dist/react.js +860 -0
- package/dist/react.js.map +1 -0
- package/dist/types-D7Q7Ycer.d.cts +105 -0
- package/dist/types-D7Q7Ycer.d.ts +105 -0
- package/dist/vue.cjs +855 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +43 -0
- package/dist/vue.d.ts +43 -0
- package/dist/vue.js +850 -0
- package/dist/vue.js.map +1 -0
- package/package.json +85 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { C as CharacterPlayerOptions, a as CharacterPose, L as LegacyCharacterManifest, b as LayeredCharacterManifest, A as AnimationStateConfig, c as CharacterManifest } from './types-D7Q7Ycer.js';
|
|
2
|
+
export { d as AnimationStateFramesConfig, e as AnimationStateGridSheetConfig, G as GridSheetConfig, f as GridSheetOrder, i as isGridSheetAnimation, g as isLayeredManifest } from './types-D7Q7Ycer.js';
|
|
3
|
+
|
|
4
|
+
declare class CharacterPlayer {
|
|
5
|
+
readonly container: HTMLElement;
|
|
6
|
+
private readonly manifest;
|
|
7
|
+
private readonly flatStates;
|
|
8
|
+
private readonly layered;
|
|
9
|
+
private readonly transitionMap;
|
|
10
|
+
private readonly baseUrl;
|
|
11
|
+
private readonly transitionMs;
|
|
12
|
+
private readonly fitPadding;
|
|
13
|
+
private characterWidth;
|
|
14
|
+
private characterHeight;
|
|
15
|
+
private readonly queueStateUntilCycleEnd;
|
|
16
|
+
private readonly debug;
|
|
17
|
+
private app;
|
|
18
|
+
private root;
|
|
19
|
+
private resizeObserver;
|
|
20
|
+
private currentSprite;
|
|
21
|
+
/** Current clip key: legacy `idle` / `talk`, layered `neutral/idle`, or internal `__tr__/a/b`. */
|
|
22
|
+
private currentFlatKey;
|
|
23
|
+
/** Logical pose when `layered`; unchanged while a transition clip plays. */
|
|
24
|
+
private currentPose;
|
|
25
|
+
private transitioning;
|
|
26
|
+
private fromSprite;
|
|
27
|
+
private toSprite;
|
|
28
|
+
private transitionProgress;
|
|
29
|
+
private transitionTargetFlatKey;
|
|
30
|
+
private pendingFlatKey;
|
|
31
|
+
private transitionUpdateBound;
|
|
32
|
+
private deferredTargetFlatKey;
|
|
33
|
+
private waitingForCycleEnd;
|
|
34
|
+
/** After a one-shot transition clip mounts, crossfade into this pose key. */
|
|
35
|
+
private pendingAfterTransitionClip;
|
|
36
|
+
private textureWidth;
|
|
37
|
+
private textureHeight;
|
|
38
|
+
/** Invalidates in-flight `playOneShotAction` completion handlers after a new one-shot or `destroy()`. */
|
|
39
|
+
private oneShotCompletionToken;
|
|
40
|
+
private destroyed;
|
|
41
|
+
constructor(options: CharacterPlayerOptions);
|
|
42
|
+
/** Create Pixi app, load first clip, append canvas. Call once. */
|
|
43
|
+
init(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Current clip key. Layered manifests use `characterState/action` (e.g. `neutral/idle`);
|
|
46
|
+
* during a character-state transition the internal `__tr__/from/to` key may be returned.
|
|
47
|
+
*/
|
|
48
|
+
getState(): string | null;
|
|
49
|
+
/** Logical pose for layered manifests; `null` for legacy flat manifests. */
|
|
50
|
+
getPose(): CharacterPose | null;
|
|
51
|
+
/**
|
|
52
|
+
* Set explicit character size in CSS pixels (see `CharacterPlayerOptions.characterWidth` /
|
|
53
|
+
* `characterHeight`). Pass no arguments or `undefined` for both dimensions to restore
|
|
54
|
+
* scaling that fits the container (still multiplied by `fitPadding`).
|
|
55
|
+
*/
|
|
56
|
+
setCharacterSize(width?: number, height?: number): void;
|
|
57
|
+
/** Switch pose (layered manifests only). */
|
|
58
|
+
setPose(pose: CharacterPose): Promise<void>;
|
|
59
|
+
/** Switch animation clip; crossfades when `transitionMs` > 0. */
|
|
60
|
+
setState(name: string): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Play a one-shot action clip immediately: aborts crossfades, cycle queues, and transition clips,
|
|
63
|
+
* then returns to `{ characterState, action: "idle" }` when the clip ends. Layered manifests only;
|
|
64
|
+
* requires a matching clip and playback context for that character state (including a
|
|
65
|
+
* `from`→… transition clip when `from` matches).
|
|
66
|
+
*/
|
|
67
|
+
playOneShotAction(pose: CharacterPose): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Play the neutral `click` clip (see {@link playOneShotAction}).
|
|
70
|
+
*/
|
|
71
|
+
playNeutralClick(): Promise<void>;
|
|
72
|
+
private resolveSetStateName;
|
|
73
|
+
/** True when the current clip is for `characterState` or a transition clip leaving that state. */
|
|
74
|
+
private isCharacterStatePlaybackContext;
|
|
75
|
+
/**
|
|
76
|
+
* Stops and tears down active playback so a one-shot (e.g. click) can start immediately.
|
|
77
|
+
* Clears crossfade ticker, transition sprites, cycle/queue state, and the current sprite.
|
|
78
|
+
*/
|
|
79
|
+
private abortImmediatePlayback;
|
|
80
|
+
private validatePose;
|
|
81
|
+
private logDebug;
|
|
82
|
+
private logWarn;
|
|
83
|
+
/** True while a one-shot character-state transition clip is playing (after crossfade onto it). */
|
|
84
|
+
private isPlayingTransitionClip;
|
|
85
|
+
private applySetFlatKey;
|
|
86
|
+
private syncPoseFromFlatKey;
|
|
87
|
+
private applyTransitionNow;
|
|
88
|
+
private applyCharacterStateChange;
|
|
89
|
+
private clearCycleWait;
|
|
90
|
+
private attachCycleEndListener;
|
|
91
|
+
private finishDeferredAndTransition;
|
|
92
|
+
/** Returns true if we scheduled waiting for a transition clip to finish (skip processing crossfade queue). */
|
|
93
|
+
private maybeAttachTransitionClipCompletion;
|
|
94
|
+
private attachTransitionClipCompletion;
|
|
95
|
+
private finishCharacterTransitionChain;
|
|
96
|
+
private swapInstant;
|
|
97
|
+
private beginCrossfade;
|
|
98
|
+
private onTransitionTick;
|
|
99
|
+
private finishCrossfade;
|
|
100
|
+
private mountState;
|
|
101
|
+
private attachSprite;
|
|
102
|
+
private createSpriteForState;
|
|
103
|
+
private layout;
|
|
104
|
+
destroy(): void;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Separator for flat keys: `characterState/action` (e.g. `neutral/idle`). */
|
|
108
|
+
declare const POSE_KEY_SEPARATOR = "/";
|
|
109
|
+
/** `frame_001.png` … `frame_181.png` */
|
|
110
|
+
declare function idleFrameNames(count?: number): string[];
|
|
111
|
+
/** `idle/frame_001.png` … when `subdir` is `idle`; use with `baseUrl` at the assets root. */
|
|
112
|
+
declare function framePaths(subdir: string, count: number): string[];
|
|
113
|
+
declare function poseToKey(pose: CharacterPose): string;
|
|
114
|
+
/** Parse `neutral/idle` into a pose; returns null if not a layered key. */
|
|
115
|
+
declare function keyToPose(key: string): CharacterPose | null;
|
|
116
|
+
/** Internal flat key for a one-shot character-state transition clip. */
|
|
117
|
+
declare function transitionFlatKey(fromCharacterState: string, toCharacterState: string): string;
|
|
118
|
+
declare function isTransitionFlatKey(key: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Merge layered character actions and transition clips into one flat `states` map for the player.
|
|
121
|
+
*/
|
|
122
|
+
declare function flattenLayeredManifest(manifest: LayeredCharacterManifest): Record<string, AnimationStateConfig>;
|
|
123
|
+
/** Resolve default pose for a layered manifest (deterministic: first entry keys). */
|
|
124
|
+
declare function defaultPoseForLayered(manifest: LayeredCharacterManifest): CharacterPose;
|
|
125
|
+
/** Build a single flat `states` map for CharacterPlayer from any manifest shape. */
|
|
126
|
+
declare function manifestToFlatStates(manifest: CharacterManifest): Record<string, AnimationStateConfig>;
|
|
127
|
+
/** Default manifest: `idle` and `talk` under distinct asset folders (legacy flat). */
|
|
128
|
+
declare function createDefaultManifest(): LegacyCharacterManifest;
|
|
129
|
+
/** Frame counts for packaged sad demo assets under `assets/sheets/` (must match PNG layout). */
|
|
130
|
+
declare const SAD_DEMO_FRAMES: {
|
|
131
|
+
/**
|
|
132
|
+
* `neutral_to_sad.png` is 5120×3830 → 10×10 cells @ 512×383; only **91** frames are drawn
|
|
133
|
+
* (9 full rows + 1 cell in row 10). The last 9 cells in the bottom row are empty—do not play them.
|
|
134
|
+
*/
|
|
135
|
+
readonly transitionNeutralToSad: 91;
|
|
136
|
+
/** `sad_to_neutral.png` is 4608×3064 → 9×8 cells @ 512×383 (66 frames; last row partial). */
|
|
137
|
+
readonly transitionSadToNeutral: 66;
|
|
138
|
+
readonly sadIdle: 149;
|
|
139
|
+
readonly sadTalk: 126;
|
|
140
|
+
/** `neutral_click_512.png` is 3072×2298 → 6×6 cells @ 512×383 (36 frames). */
|
|
141
|
+
readonly neutralClick: 36;
|
|
142
|
+
/**
|
|
143
|
+
* `sad_click_512.png` is 4608×3447 → 9×9 grid @ 512×383; only **75** frames have content
|
|
144
|
+
* (last 6 cells in row-major order are empty padding—do not play them).
|
|
145
|
+
*/
|
|
146
|
+
readonly sadClick: 75;
|
|
147
|
+
/**
|
|
148
|
+
* `sad_thinking_512.png` is 5632×3830 → 11×10 grid @ 512×383; **105** frames drawn
|
|
149
|
+
* (last 5 cells empty—avoids blink when looping).
|
|
150
|
+
*/
|
|
151
|
+
readonly sadThinking: 105;
|
|
152
|
+
/**
|
|
153
|
+
* `neutral_thinking_512.png` is 6144×4213 → 12×11 grid @ 512×383; **122** frames drawn
|
|
154
|
+
* (last 10 cells empty—avoids blink when looping).
|
|
155
|
+
*/
|
|
156
|
+
readonly neutralThinking: 122;
|
|
157
|
+
/**
|
|
158
|
+
* `sad_celebrating_512.png` is 6144×4213 → 12×11 grid @ 512×383; **122** frames drawn
|
|
159
|
+
* (last 10 cells empty).
|
|
160
|
+
*/
|
|
161
|
+
readonly sadCelebrating: 122;
|
|
162
|
+
/**
|
|
163
|
+
* `neutral_celebrating_512.png` is 6656×4596 → 13×12 grid @ 512×383; **150** frames drawn
|
|
164
|
+
* (last 6 cells empty).
|
|
165
|
+
*/
|
|
166
|
+
readonly neutralCelebrating: 150;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Uniform grid parameters per `assets/sheets/*.png`, derived from image pixel size and
|
|
170
|
+
* {@link SAD_DEMO_FRAMES} (row-major cells; unused trailing cells are allowed).
|
|
171
|
+
*/
|
|
172
|
+
declare const SAD_DEMO_GRID_SHEETS: {
|
|
173
|
+
readonly neutralIdle: {
|
|
174
|
+
readonly image: "sheets/neutral_idle_512.png";
|
|
175
|
+
readonly frameWidth: 512;
|
|
176
|
+
readonly frameHeight: 383;
|
|
177
|
+
readonly columns: 14;
|
|
178
|
+
readonly frameCount: 181;
|
|
179
|
+
};
|
|
180
|
+
readonly neutralTalk: {
|
|
181
|
+
readonly image: "sheets/neutral_talk_512.png";
|
|
182
|
+
readonly frameWidth: 512;
|
|
183
|
+
readonly frameHeight: 383;
|
|
184
|
+
readonly columns: 10;
|
|
185
|
+
readonly frameCount: 93;
|
|
186
|
+
};
|
|
187
|
+
readonly neutralClick: {
|
|
188
|
+
readonly image: "sheets/neutral_click_512.png";
|
|
189
|
+
readonly frameWidth: 512;
|
|
190
|
+
readonly frameHeight: 383;
|
|
191
|
+
readonly columns: 6;
|
|
192
|
+
readonly frameCount: 36;
|
|
193
|
+
};
|
|
194
|
+
readonly sadIdle: {
|
|
195
|
+
readonly image: "sheets/sad_idle_512.png";
|
|
196
|
+
readonly frameWidth: 512;
|
|
197
|
+
readonly frameHeight: 383;
|
|
198
|
+
readonly columns: 13;
|
|
199
|
+
readonly frameCount: 149;
|
|
200
|
+
};
|
|
201
|
+
readonly sadTalk: {
|
|
202
|
+
readonly image: "sheets/sad_talk_512.png";
|
|
203
|
+
readonly frameWidth: 512;
|
|
204
|
+
readonly frameHeight: 383;
|
|
205
|
+
readonly columns: 12;
|
|
206
|
+
readonly frameCount: 126;
|
|
207
|
+
};
|
|
208
|
+
readonly neutralToSad: {
|
|
209
|
+
readonly image: "sheets/neutral_to_sad.png";
|
|
210
|
+
readonly frameWidth: 512;
|
|
211
|
+
readonly frameHeight: 383;
|
|
212
|
+
readonly columns: 10;
|
|
213
|
+
readonly frameCount: 91;
|
|
214
|
+
};
|
|
215
|
+
readonly sadToNeutral: {
|
|
216
|
+
readonly image: "sheets/sad_to_neutral.png";
|
|
217
|
+
readonly frameWidth: 512;
|
|
218
|
+
readonly frameHeight: 383;
|
|
219
|
+
readonly columns: 9;
|
|
220
|
+
readonly frameCount: 66;
|
|
221
|
+
};
|
|
222
|
+
readonly sadClick: {
|
|
223
|
+
readonly image: "sheets/sad_click_512.png";
|
|
224
|
+
readonly frameWidth: 512;
|
|
225
|
+
readonly frameHeight: 383;
|
|
226
|
+
readonly columns: 9;
|
|
227
|
+
readonly frameCount: 75;
|
|
228
|
+
};
|
|
229
|
+
readonly sadThinking: {
|
|
230
|
+
readonly image: "sheets/sad_thinking_512.png";
|
|
231
|
+
readonly frameWidth: 512;
|
|
232
|
+
readonly frameHeight: 383;
|
|
233
|
+
readonly columns: 11;
|
|
234
|
+
readonly frameCount: 105;
|
|
235
|
+
};
|
|
236
|
+
readonly neutralThinking: {
|
|
237
|
+
readonly image: "sheets/neutral_thinking_512.png";
|
|
238
|
+
readonly frameWidth: 512;
|
|
239
|
+
readonly frameHeight: 383;
|
|
240
|
+
readonly columns: 12;
|
|
241
|
+
readonly frameCount: 122;
|
|
242
|
+
};
|
|
243
|
+
readonly sadCelebrating: {
|
|
244
|
+
readonly image: "sheets/sad_celebrating_512.png";
|
|
245
|
+
readonly frameWidth: 512;
|
|
246
|
+
readonly frameHeight: 383;
|
|
247
|
+
readonly columns: 12;
|
|
248
|
+
readonly frameCount: 122;
|
|
249
|
+
};
|
|
250
|
+
readonly neutralCelebrating: {
|
|
251
|
+
readonly image: "sheets/neutral_celebrating_512.png";
|
|
252
|
+
readonly frameWidth: 512;
|
|
253
|
+
readonly frameHeight: 383;
|
|
254
|
+
readonly columns: 13;
|
|
255
|
+
readonly frameCount: 150;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Layered manifest: neutral, sad, and one-shot transitions using one PNG grid sheet per clip
|
|
260
|
+
* under `assets/sheets/` (see {@link SAD_DEMO_GRID_SHEETS}).
|
|
261
|
+
*/
|
|
262
|
+
declare function createSadDemoManifest(): LayeredCharacterManifest;
|
|
263
|
+
|
|
264
|
+
export { AnimationStateConfig, CharacterManifest, CharacterPlayer, CharacterPlayerOptions, CharacterPose, LayeredCharacterManifest, LegacyCharacterManifest, POSE_KEY_SEPARATOR, SAD_DEMO_FRAMES, SAD_DEMO_GRID_SHEETS, createDefaultManifest, createSadDemoManifest, defaultPoseForLayered, flattenLayeredManifest, framePaths, idleFrameNames, isTransitionFlatKey, keyToPose, manifestToFlatStates, poseToKey, transitionFlatKey };
|