@lovelace_lol/embody 0.0.7 → 0.0.9

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.
Files changed (134) hide show
  1. package/README.md +541 -2394
  2. package/dist/index.d.ts +2 -100
  3. package/dist/index.js +9197 -13851
  4. package/dist/index.js.map +1 -1
  5. package/dist/three/annotations/DOMControls.d.ts +73 -0
  6. package/dist/three/annotations/DPthree.d.ts +113 -0
  7. package/dist/three/annotations/DPthree3DMarkers.d.ts +319 -0
  8. package/dist/three/annotations/DPthreeCameraController.d.ts +415 -0
  9. package/dist/three/annotations/DPthreeHTMLMarkers.d.ts +131 -0
  10. package/dist/three/annotations/DPthreeMarkers.d.ts +52 -0
  11. package/dist/three/annotations/adapter.d.ts +157 -0
  12. package/dist/three/annotations/animationFrameTaskScheduler.d.ts +18 -0
  13. package/dist/three/annotations/annotationAnchorModel.d.ts +16 -0
  14. package/dist/three/annotations/annotationCameraCore.d.ts +5 -0
  15. package/dist/three/annotations/boneResolutionProfile.d.ts +7 -0
  16. package/dist/three/annotations/index.d.ts +20 -0
  17. package/dist/three/annotations/loadFrame.d.ts +2 -0
  18. package/dist/three/annotations/markerSurfaceRaycast.d.ts +11 -0
  19. package/dist/three/annotations/markerVisibilityLifecycle.d.ts +21 -0
  20. package/dist/three/annotations/modelRenderPreparation.d.ts +6 -0
  21. package/dist/three/annotations/runtimeAnnotationPreview.d.ts +15 -0
  22. package/dist/three/annotations/runtimeAnnotationPreviewSide.d.ts +10 -0
  23. package/dist/three/annotations/runtimeAnnotationSidePreview.d.ts +5 -0
  24. package/dist/three/annotations/types.d.ts +262 -0
  25. package/dist/three/authoring.d.ts +95 -0
  26. package/dist/three/authoringTypes.d.ts +576 -0
  27. package/dist/three/character.d.ts +243 -0
  28. package/dist/three/characterHost.d.ts +48 -0
  29. package/dist/three/clipBindings.d.ts +6 -0
  30. package/dist/three/index.d.ts +171 -0
  31. package/dist/three/model.d.ts +31 -0
  32. package/dist/three/modelSkinning.d.ts +3 -0
  33. package/dist/three/nativePlayback.d.ts +121 -0
  34. package/dist/three/playbackRendering.d.ts +14 -0
  35. package/dist/three/reference-pose.d.ts +73 -0
  36. package/dist/three/scene.d.ts +253 -0
  37. package/dist/three/sceneRenderingBinding.d.ts +22 -0
  38. package/dist/three.js +9252 -8844
  39. package/dist/three.js.map +1 -1
  40. package/dist/wasm/README.md +551 -62
  41. package/dist/wasm/auto.d.ts +1 -0
  42. package/dist/wasm/compatibility.d.ts +14 -0
  43. package/dist/wasm/embody_wasm.d.ts +352 -71
  44. package/dist/wasm/embody_wasm.js +1266 -37
  45. package/dist/wasm/embody_wasm_bg.wasm +0 -0
  46. package/dist/wasm/embody_wasm_bg.wasm.d.ts +113 -54
  47. package/dist/wasm/index.d.ts +131 -0
  48. package/dist/wasm.d.ts +1 -43
  49. package/dist/wasm.js +1100 -239
  50. package/dist/wasm.js.map +1 -1
  51. package/package.json +35 -39
  52. package/service-worker/character-asset-service-worker.js +295 -0
  53. package/dist/authoring/boneAuthoring.d.ts +0 -132
  54. package/dist/camera/annotationCameraAngles.d.ts +0 -28
  55. package/dist/camera/cameraRelativeGaze.d.ts +0 -15
  56. package/dist/camera/rustAnnotationCameraCore.d.ts +0 -136
  57. package/dist/cljs.cjs +0 -362
  58. package/dist/cljs.cjs.map +0 -1
  59. package/dist/cljs.d.ts +0 -5
  60. package/dist/cljs.js +0 -359
  61. package/dist/cljs.js.map +0 -1
  62. package/dist/core/TsClipCompiler.d.ts +0 -51
  63. package/dist/core/WasmRuntimeCore.d.ts +0 -41
  64. package/dist/core/compositeAxis.d.ts +0 -4
  65. package/dist/core/contracts/abi.d.ts +0 -70
  66. package/dist/core/contracts/clip.d.ts +0 -44
  67. package/dist/core/contracts/frame.d.ts +0 -27
  68. package/dist/core/contracts/host.d.ts +0 -28
  69. package/dist/core/contracts/ids.d.ts +0 -15
  70. package/dist/core/contracts/index.d.ts +0 -10
  71. package/dist/core/contracts/model.d.ts +0 -31
  72. package/dist/core/contracts/primitives.d.ts +0 -17
  73. package/dist/core/contracts/skeletonFit.d.ts +0 -41
  74. package/dist/core/index.d.ts +0 -6
  75. package/dist/core/types.d.ts +0 -472
  76. package/dist/core.cjs +0 -343
  77. package/dist/core.cjs.map +0 -1
  78. package/dist/core.js +0 -323
  79. package/dist/core.js.map +0 -1
  80. package/dist/engines/three/Embody.d.ts +0 -372
  81. package/dist/engines/three/ThreeAnimationRuntime.d.ts +0 -203
  82. package/dist/engines/three/ThreeClipAdapter.d.ts +0 -24
  83. package/dist/engines/three/ThreeFrameApplier.d.ts +0 -68
  84. package/dist/engines/three/ThreeModelInspector.d.ts +0 -54
  85. package/dist/engines/three/bakedClipPartitioning.d.ts +0 -16
  86. package/dist/engines/three/balanceUtils.d.ts +0 -3
  87. package/dist/engines/three/characterHost.d.ts +0 -80
  88. package/dist/engines/three/characterScene.d.ts +0 -98
  89. package/dist/engines/three/hair/HairPhysicsController.d.ts +0 -124
  90. package/dist/engines/three/index.d.ts +0 -20
  91. package/dist/engines/three/modelLoader.d.ts +0 -61
  92. package/dist/engines/three/profileTestScene.d.ts +0 -52
  93. package/dist/engines/three/types.d.ts +0 -20
  94. package/dist/hair/appearance.d.ts +0 -29
  95. package/dist/index.cjs +0 -14871
  96. package/dist/index.cjs.map +0 -1
  97. package/dist/interfaces/Animation.d.ts +0 -315
  98. package/dist/interfaces/EmbodyRuntime.d.ts +0 -90
  99. package/dist/interfaces/Hair.d.ts +0 -181
  100. package/dist/interfaces/HairPhysics.d.ts +0 -90
  101. package/dist/interfaces/index.d.ts +0 -11
  102. package/dist/mappings/extendPresetWithProfile.d.ts +0 -17
  103. package/dist/mappings/types.d.ts +0 -309
  104. package/dist/mappings/visemeSystem.d.ts +0 -26
  105. package/dist/physics/HairPhysics.d.ts +0 -86
  106. package/dist/physics/RustHairPhysics.d.ts +0 -18
  107. package/dist/physics/index.d.ts +0 -6
  108. package/dist/preset.cjs +0 -2005
  109. package/dist/preset.cjs.map +0 -1
  110. package/dist/preset.js +0 -2003
  111. package/dist/preset.js.map +0 -1
  112. package/dist/presets/bettaFish.d.ts +0 -328
  113. package/dist/presets/cc4.d.ts +0 -145
  114. package/dist/presets/index.d.ts +0 -30
  115. package/dist/presets/registry.d.ts +0 -57
  116. package/dist/profiles/resolveProfileConfig.d.ts +0 -36
  117. package/dist/profiles/rustResolvedProfile.d.ts +0 -31
  118. package/dist/profiles/types.d.ts +0 -118
  119. package/dist/regions/normalizeRegionTree.d.ts +0 -6
  120. package/dist/regions/regionMapping.d.ts +0 -17
  121. package/dist/regions/types.d.ts +0 -122
  122. package/dist/skeletonTemplates/humanoidSkeletonTemplates.d.ts +0 -32
  123. package/dist/test/setupWasm.d.ts +0 -1
  124. package/dist/three.cjs +0 -9550
  125. package/dist/three.cjs.map +0 -1
  126. package/dist/validation/analyzeModel.d.ts +0 -68
  127. package/dist/validation/extractModelData.d.ts +0 -90
  128. package/dist/validation/generateMappingCorrections.d.ts +0 -32
  129. package/dist/validation/geometryHelpers.d.ts +0 -66
  130. package/dist/validation/types.d.ts +0 -10
  131. package/dist/validation/validateMappings.d.ts +0 -77
  132. package/dist/wasm.cjs +0 -302
  133. package/dist/wasm.cjs.map +0 -1
  134. package/dist/wasmTypes.d.ts +0 -123
@@ -1,372 +0,0 @@
1
- /**
2
- * Embody - Three.js Implementation
3
- *
4
- * Default implementation of the Embody runtime interface for Three.js.
5
- * Controls 3D character facial animation using Action Units (AUs),
6
- * morph targets, visemes, and bone transformations.
7
- */
8
- import type { Mesh, Object3D, AnimationClip } from 'three';
9
- import type { EmbodyRuntime, ReadyPayload, EmbodyConfig } from '../../interfaces/EmbodyRuntime';
10
- import type { MeshInfo, Profile } from '../../mappings/types';
11
- import type { TransitionHandle, AnimationPlayOptions, AnimationClipInfo, AnimationState, AnimationActionHandle, CurvesMap, ClipOptions, ClipHandle, Snippet, SnippetChannel, TypedSnippet, CompositeRotation, AnimationBlendMode, MorphTargetDelta, AddMorphTargetOptions } from '../../core/types';
12
- import { ThreeModelInspector } from './ThreeModelInspector';
13
- import { type ThreeFrameApplierBindings, type ThreeMaterialConfig, type ThreeResolvedMaterialConfig } from './ThreeFrameApplier';
14
- import { HairPhysicsController, type HairPhysicsConfig, type HairPhysicsConfigUpdate } from './hair/HairPhysicsController';
15
- export declare class Embody implements EmbodyRuntime {
16
- onSnippetEnd?: (name: string) => void;
17
- /**
18
- * Create an engine with Rust-owned preset/profile resolution.
19
- *
20
- * Prefer this factory whenever a profile patch must be merged onto a preset.
21
- * The sync constructor accepts either a presetType with no patch, or an
22
- * already-resolved profile.
23
- */
24
- static create(config?: EmbodyConfig, animation?: {
25
- tick(dtSeconds: number): void;
26
- addTransition(key: string, from: number, to: number, durationMs: number, apply: (value: number) => void, easing?: (t: number) => number): TransitionHandle;
27
- clearTransitions(): void;
28
- getActiveTransitionCount(): number;
29
- }): Promise<Embody>;
30
- private config;
31
- private animation;
32
- private compositeRotations;
33
- private auToCompositeMap;
34
- private auValues;
35
- private auBalances;
36
- private rigReady;
37
- private missingBoneWarnings;
38
- private rotations;
39
- private pendingCompositeNodes;
40
- private isPaused;
41
- private translations;
42
- private faceMesh;
43
- private resolvedFaceMeshes;
44
- private meshes;
45
- private model;
46
- private meshByName;
47
- private morphKeyCache;
48
- private morphIndexCache;
49
- private resolvedAUMorphTargets;
50
- private resolvedVisemeTargets;
51
- private bones;
52
- private mixWeights;
53
- private visemeValues;
54
- private visemeJawScales;
55
- private static readonly VISEME_JAW_AMOUNTS;
56
- private animationController;
57
- private hairPhysics;
58
- private modelInspector;
59
- private frameApplier;
60
- private modelDescriptor;
61
- private wasmRuntimeCore;
62
- private framePathReady;
63
- private clock;
64
- private animationFrameId;
65
- private isRunning;
66
- constructor(config?: EmbodyConfig, animation?: {
67
- tick(dtSeconds: number): void;
68
- addTransition(key: string, from: number, to: number, durationMs: number, apply: (value: number) => void, easing?: (t: number) => number): TransitionHandle;
69
- clearTransitions(): void;
70
- getActiveTransitionCount(): number;
71
- });
72
- onReady(payload: ReadyPayload): void;
73
- private bindHostNeutralRuntime;
74
- private attachWasmCore;
75
- private syncRuntimeCoreState;
76
- /**
77
- * Re-inspect the current model and push a fresh ModelDescriptor into the
78
- * runtime cores and frame applier. Needed whenever host-side morph targets
79
- * or meshes change after onReady (e.g. addMorphTarget).
80
- */
81
- private refreshHostNeutralModelDescriptor;
82
- private applyLiveFrameDelta;
83
- private rebuildMorphTargetsCache;
84
- private resolveFaceMeshes;
85
- update(deltaSeconds: number): void;
86
- /** Start the internal animation loop using Three.js Clock */
87
- start(): void;
88
- /** Stop the internal animation loop */
89
- stop(): void;
90
- dispose(): void;
91
- setAU(id: number | string, v: number, balance?: number): void;
92
- transitionAU(id: number | string, to: number, durationMs?: number, balance?: number): TransitionHandle;
93
- getAU(id: number): number;
94
- getCompositeRotations(): CompositeRotation[];
95
- /**
96
- * Set a continuum AU pair immediately (no animation).
97
- *
98
- * Sign convention:
99
- * - Negative value (-1 to 0): activates negAU (e.g., head left, eyes left)
100
- * - Positive value (0 to +1): activates posAU (e.g., head right, eyes right)
101
- *
102
- * @param negAU - AU ID for negative direction (e.g., 61 for eyes left)
103
- * @param posAU - AU ID for positive direction (e.g., 62 for eyes right)
104
- * @param continuumValue - Value from -1 (full negative) to +1 (full positive)
105
- * @param balance - Optional L/R balance for bilateral morphs
106
- */
107
- setContinuum(negAU: number, posAU: number, continuumValue: number, balance?: number): void;
108
- /**
109
- * Smoothly transition a continuum AU pair (e.g., eyes left/right, head up/down).
110
- * Takes a continuum value from -1 to +1 and internally manages both AU values.
111
- *
112
- * @param negAU - AU ID for negative direction (e.g., 61 for eyes left)
113
- * @param posAU - AU ID for positive direction (e.g., 62 for eyes right)
114
- * @param continuumValue - Target value from -1 (full negative) to +1 (full positive)
115
- * @param durationMs - Transition duration in milliseconds
116
- * @param balance - Optional L/R balance for bilateral morphs
117
- */
118
- transitionContinuum(negAU: number, posAU: number, continuumValue: number, durationMs?: number, balance?: number): TransitionHandle;
119
- addMorphTarget(target: MorphTargetDelta, options?: AddMorphTargetOptions): number;
120
- addMorphTargets(targets: MorphTargetDelta[], options?: AddMorphTargetOptions): Record<string, number>;
121
- ensureMorphInfluence(meshName: string, morphName: string): number;
122
- refreshMorphTargets(_meshNames?: string[]): void;
123
- /**
124
- * Set a morph target value.
125
- *
126
- * Fast paths (in order of speed):
127
- * 1. Pass pre-resolved { infl, idx } array directly - zero lookups
128
- * 2. String key with cache hit - one Map lookup
129
- * 3. String key cache miss - dictionary lookup, then cached for next time
130
- */
131
- setMorph(key: string, v: number, meshNames?: string[]): void;
132
- setMorph(key: string, v: number, targets: {
133
- infl: number[];
134
- idx: number;
135
- }[]): void;
136
- setMorphInfluence(index: number, v: number, meshNames?: string[]): void;
137
- /**
138
- * Resolve morph key to direct targets for ultra-fast repeated access.
139
- * Use this when you need to set the same morph many times (e.g., in animation loops).
140
- */
141
- private resolveMorphTargetIndex;
142
- resolveMorphTargets(key: string, meshNames?: string[]): {
143
- infl: number[];
144
- idx: number;
145
- }[];
146
- resolveMorphTargetsByIndex(index: number, meshNames?: string[]): {
147
- infl: number[];
148
- idx: number;
149
- }[];
150
- transitionMorph(key: string, to: number, durationMs?: number, meshNames?: string[]): TransitionHandle;
151
- transitionMorphInfluence(index: number, to: number, durationMs?: number, meshNames?: string[]): TransitionHandle;
152
- setViseme(visemeIndex: number, value: number, jawScale?: number): void;
153
- transitionViseme(visemeIndex: number, to: number, durationMs?: number, jawScale?: number): TransitionHandle;
154
- setVisemeById(slotId: string, value: number, jawScale?: number): void;
155
- transitionVisemeById(slotId: string, to: number, durationMs?: number, jawScale?: number): TransitionHandle;
156
- setAUMixWeight(id: number, weight: number): void;
157
- getAUMixWeight(id: number): number;
158
- /**
159
- * Check if an AU has bilateral bone bindings (left + right side hints).
160
- * Used to determine if a balance slider should be shown for bone-only bilateral AUs.
161
- */
162
- hasLeftRightBones(auId: number): boolean;
163
- pause(): void;
164
- resume(): void;
165
- getPaused(): boolean;
166
- clearTransitions(): void;
167
- getActiveTransitionCount(): number;
168
- resetToNeutral(): void;
169
- private reinitializeRuntimeStateFromCurrentControls;
170
- private reapplyProceduralStateAfterBakedUpdate;
171
- getMeshList(): MeshInfo[];
172
- /** Get all morph targets grouped by mesh name */
173
- getMorphTargets(): Record<string, string[]>;
174
- /** Get morph target indices mapped to labels for each mesh */
175
- getMorphTargetIndices(): Record<string, {
176
- index: number;
177
- name: string;
178
- }[]>;
179
- /** Get all resolved bone names and their current transforms */
180
- getBones(): Record<string, {
181
- position: [number, number, number];
182
- rotation: [number, number, number];
183
- }>;
184
- setMeshVisible(meshName: string, visible: boolean): void;
185
- /**
186
- * Highlight a mesh with an emissive glow effect
187
- * @param meshName - Name of the mesh to highlight (null to clear all highlights)
188
- * @param color - Highlight color (default: cyan 0x00ffff)
189
- * @param intensity - Emissive intensity (default: 0.5)
190
- */
191
- highlightMesh(meshName: string | null, color?: number, intensity?: number): void;
192
- /** Get material config for a mesh */
193
- getMeshMaterialConfig(meshName: string): ThreeResolvedMaterialConfig | null;
194
- /** Set material config for a mesh */
195
- setMeshMaterialConfig(meshName: string, config: ThreeMaterialConfig): void;
196
- private applyHairPhysicsProfileConfig;
197
- setProfile(profile: Profile): void;
198
- getProfile(): Profile;
199
- /**
200
- * Get the mesh names that should receive morph influences for a given AU.
201
- * Routing is driven by `auFacePartToMeshCategory` in profile config.
202
- */
203
- getMeshNamesForAU(auId: number): string[];
204
- getMeshNamesForViseme(): string[];
205
- registerHairObjects(objects: Object3D[]): Array<{
206
- name: string;
207
- isMesh: boolean;
208
- isEyebrow: boolean;
209
- }>;
210
- getRegisteredHairObjects(): Mesh[];
211
- setHairPhysicsEnabled(enabled: boolean): void;
212
- isHairPhysicsEnabled(): boolean;
213
- setHairPhysicsConfig(config: HairPhysicsConfigUpdate): void;
214
- getHairPhysicsConfig(): HairPhysicsConfig;
215
- validateHairMorphTargets(): string[];
216
- /** Get head rotation values for hair physics (range -1 to 1) */
217
- getHeadRotation(): {
218
- yaw: number;
219
- pitch: number;
220
- roll: number;
221
- };
222
- updateHairPhysics(dt: number): void;
223
- getHairMorphTargets(meshName?: string): string[];
224
- setMorphOnMeshes(meshNames: string[], morphKey: string, value: number): void;
225
- applyHairStateToObject(objectName: string, state: {
226
- color?: {
227
- baseColor: string;
228
- emissive: string;
229
- emissiveIntensity: number;
230
- };
231
- outline?: {
232
- show: boolean;
233
- color: string;
234
- opacity: number;
235
- };
236
- visible?: boolean;
237
- scale?: {
238
- x: number;
239
- y: number;
240
- z: number;
241
- };
242
- position?: {
243
- x: number;
244
- y: number;
245
- z: number;
246
- };
247
- isEyebrow?: boolean;
248
- }): void;
249
- getHairAppearance(): import("../..").HairAppearanceState;
250
- setHairColor(color: Parameters<HairPhysicsController['setHairColor']>[0]): void;
251
- setEyebrowColor(color: Parameters<HairPhysicsController['setEyebrowColor']>[0]): void;
252
- setHairBaseColor(baseColor: string): void;
253
- setEyebrowBaseColor(baseColor: string): void;
254
- setHairGlow(emissive: string, intensity: number): void;
255
- setEyebrowGlow(emissive: string, intensity: number): void;
256
- setHairOutline(outline: {
257
- show: boolean;
258
- color?: string;
259
- opacity?: number;
260
- }): void;
261
- private computeSideValues;
262
- private getAUMorphsBySide;
263
- private applyMorphTargets;
264
- private applyVisemeRuntimeState;
265
- private getJawBoneNodeKey;
266
- private getHeadBoneNodeKey;
267
- private getActiveVisemeJawAmount;
268
- private getMorphValue;
269
- private getMorphValueForMeshes;
270
- private getMorphValueByIndex;
271
- private getMorphValueByIndexForMeshes;
272
- private validateMorphTargetDelta;
273
- private applyMorphTargetDelta;
274
- private requireNamedMesh;
275
- private getMeshMorphDictionary;
276
- private assertMorphAttributeDataLength;
277
- private assertCompatibleMorphTargetMode;
278
- private setMorphAttributeAtIndex;
279
- private setZeroMorphAttributeAtIndex;
280
- private addRuntimeMorphMesh;
281
- private getMorphKeyCacheKey;
282
- private getMorphIndexCacheKey;
283
- private syncVisemeRuntimeState;
284
- private getVisemeJawAmount;
285
- private collectResolvedExpressionMorphTargets;
286
- private resetMorphTargetHandles;
287
- private isMixedAU;
288
- private getEffectiveBoneAUValue;
289
- private getCompositeAxisValueForNode;
290
- private getCompositeAxisBindingForNode;
291
- private initBoneRotations;
292
- /** Update rotation state - just stores -1 to 1 value like stable version */
293
- private updateBoneRotation;
294
- private updateBoneTranslation;
295
- private transitionBoneRotation;
296
- private transitionBoneTranslation;
297
- private flushPendingComposites;
298
- /**
299
- * Apply composite rotation using quaternion composition like stable version.
300
- * Looks up maxDegrees and channel from BONE_AU_TO_BINDINGS.
301
- */
302
- private applyCompositeRotation;
303
- private resolveBones;
304
- private combineHandles;
305
- /**
306
- * Apply render order and material settings from CC4_MESHES to all meshes.
307
- * This ensures proper layering (e.g., hair renders on top of eyebrows).
308
- * Also auto-registers hair and eyebrow meshes for hair physics.
309
- */
310
- private applyMeshMaterialSettings;
311
- loadAnimationClips(clips: unknown[]): void;
312
- getAnimationClips(): AnimationClipInfo[];
313
- removeAnimationClip(clipName: string): boolean;
314
- playAnimation(clipName: string, options?: AnimationPlayOptions): AnimationActionHandle | null;
315
- stopAnimation(clipName: string): void;
316
- stopAllAnimations(): void;
317
- pauseAnimation(clipName: string): void;
318
- resumeAnimation(clipName: string): void;
319
- pauseAllAnimations(): void;
320
- resumeAllAnimations(): void;
321
- setAnimationSpeed(clipName: string, speed: number): void;
322
- setAnimationIntensity(clipName: string, intensity: number): void;
323
- setAnimationLoopMode(clipName: string, loopMode: 'repeat' | 'once' | 'pingpong'): void;
324
- setAnimationRepeatCount(clipName: string, repeatCount?: number): void;
325
- setAnimationReverse(clipName: string, reverse: boolean): void;
326
- setAnimationBlendMode(clipName: string, blendMode: AnimationBlendMode): void;
327
- seekAnimation(clipName: string, time: number): void;
328
- setAnimationTimeScale(timeScale: number): void;
329
- getAnimationState(clipName: string): AnimationState | null;
330
- getPlayingAnimations(): AnimationState[];
331
- crossfadeTo(clipName: string, duration?: number, options?: AnimationPlayOptions): AnimationActionHandle | null;
332
- snippetToClip(clipName: string, curves: CurvesMap, options?: ClipOptions): AnimationClip | null;
333
- playClip(clip: AnimationClip, options?: ClipOptions): ClipHandle | null;
334
- playSnippet(snippet: Snippet | {
335
- name: string;
336
- curves: CurvesMap;
337
- } | TypedSnippet | {
338
- name: string;
339
- channels: SnippetChannel[];
340
- }, options?: ClipOptions): ClipHandle | null;
341
- playTypedSnippet(snippet: TypedSnippet | {
342
- name: string;
343
- channels: SnippetChannel[];
344
- }, options?: ClipOptions): ClipHandle | null;
345
- buildClip(clipName: string, curves: CurvesMap, options?: ClipOptions): ClipHandle | null;
346
- buildTypedClip(clipName: string, channels: SnippetChannel[], options?: ClipOptions): ClipHandle | null;
347
- typedSnippetToClip(clipName: string, channels: SnippetChannel[], options?: ClipOptions): AnimationClip | null;
348
- cleanupSnippet(name: string): void;
349
- updateClipParams(name: string, params: {
350
- weight?: number;
351
- rate?: number;
352
- loop?: boolean;
353
- loopMode?: 'once' | 'repeat' | 'pingpong';
354
- repeatCount?: number;
355
- reverse?: boolean;
356
- actionId?: string;
357
- }): boolean;
358
- /**
359
- * Check if curves can be played through buildClip.
360
- * Returns false if curves contain data that cannot be converted to mixer tracks.
361
- */
362
- supportsClipCurves(curves: Record<string, Array<{
363
- time: number;
364
- intensity: number;
365
- inherit?: boolean;
366
- }>>): boolean;
367
- }
368
- /**
369
- * Helper function to collect meshes with morph targets from a scene.
370
- */
371
- export declare function collectMorphMeshes(root: Object3D): Mesh[];
372
- export declare function buildFrameApplierBindings(inspection: ReturnType<ThreeModelInspector['inspectModel']>): ThreeFrameApplierBindings;
@@ -1,203 +0,0 @@
1
- /**
2
- * ThreeAnimationRuntime - Lerp-based animation driver
3
- *
4
- * Internal driver for time-based interpolation with easing functions.
5
- */
6
- import { AnimationClip, Quaternion } from 'three';
7
- import type { Mesh, Object3D } from 'three';
8
- import type { TransitionHandle, AnimationPlayOptions, AnimationClipInfo, AnimationState, AnimationActionHandle, CurvesMap, ClipOptions, ClipHandle, Snippet, CompositeRotation, AnimationBlendMode, SnippetChannel, TypedSnippet, EmbodyAnimationRuntimeFactory } from '../../core/types';
9
- import type { Profile } from '../../mappings/types';
10
- import type { ResolvedBones } from './types';
11
- declare const easeInOutQuad: (t: number) => number;
12
- declare const easeInOutCubic: (t: number) => number;
13
- export { easeInOutQuad, easeInOutCubic };
14
- export declare class ThreeAnimationRuntime {
15
- private transitions;
16
- /**
17
- * Tick all active transitions by dt seconds.
18
- * Applies eased interpolation and removes completed transitions.
19
- * Respects individual transition pause state.
20
- */
21
- tick(dtSeconds: number): void;
22
- /**
23
- * Add or replace a transition for the given key.
24
- * If a transition with the same key exists, it is cancelled and replaced.
25
- * @returns TransitionHandle with { promise, pause, resume, cancel }
26
- */
27
- addTransition(key: string, from: number, to: number, durationMs: number, apply: (value: number) => void, easing?: (t: number) => number): TransitionHandle;
28
- /** Clear all running transitions. */
29
- clearTransitions(): void;
30
- /** Get count of active transitions. */
31
- getActiveTransitionCount(): number;
32
- }
33
- export interface ThreeAnimationSystemHost {
34
- getModel: () => Object3D | null;
35
- getMeshes: () => Mesh[];
36
- getMeshByName: (name: string) => Mesh | undefined;
37
- getMeshNamesForAU?: (auId: number) => string[];
38
- getMeshNamesForViseme?: () => string[];
39
- getCurrentAUValue?: (auId: number) => number;
40
- getCurrentVisemeValue?: (visemeIndex: number) => number;
41
- getCurrentMorphValue?: (morphKey: string, meshNames?: string[]) => number;
42
- getCurrentMorphIndexValue?: (morphIndex: number, meshNames?: string[]) => number;
43
- getCurrentBoneQuaternion?: (nodeKey: string) => Quaternion | null;
44
- getCurrentBonePositionValue?: (nodeKey: string, axis: 'x' | 'y' | 'z') => number | null;
45
- getBones: () => ResolvedBones;
46
- getConfig: () => Profile;
47
- getCompositeRotations: () => CompositeRotation[];
48
- computeSideValues: (base: number, balance?: number) => {
49
- left: number;
50
- right: number;
51
- };
52
- getAUMixWeight: (auId: number) => number;
53
- isMixedAU: (auId: number) => boolean;
54
- reapplyProceduralState?: () => void;
55
- }
56
- /** @deprecated Use ThreeAnimationSystemHost. */
57
- export type AnimationControllerHost = ThreeAnimationSystemHost;
58
- /** @deprecated Use ThreeAnimationSystemHost. */
59
- export type BakedAnimationHost = ThreeAnimationSystemHost;
60
- export type ThreeAnimationSystemOptions = {
61
- animationRuntimeFactory?: EmbodyAnimationRuntimeFactory;
62
- };
63
- type ClipParamsUpdate = {
64
- weight?: number;
65
- rate?: number;
66
- loop?: boolean;
67
- loopMode?: 'once' | 'repeat' | 'pingpong';
68
- repeatCount?: number;
69
- reverse?: boolean;
70
- actionId?: string;
71
- };
72
- export declare class ThreeAnimationSystem {
73
- private host;
74
- private animationMixer;
75
- private clipAnimationMixer;
76
- private mixerFinishedListenerAttached;
77
- private clipMixerFinishedListenerAttached;
78
- private animationClips;
79
- private bakedSourceClips;
80
- private bakedMixerActions;
81
- private bakedAdditiveMixerClips;
82
- private bakedActionGroups;
83
- private bakedMixerClipToSource;
84
- private animationActions;
85
- private animationFinishedCallbacks;
86
- private clipActions;
87
- private clipHandles;
88
- private rendererClipHandles;
89
- private clipSources;
90
- private playbackState;
91
- private actionIds;
92
- private actionIdToClip;
93
- private clipMonitors;
94
- private dynamicClipSources;
95
- private cljsAnimationRuntime;
96
- constructor(host: ThreeAnimationSystemHost, options?: ThreeAnimationSystemOptions);
97
- private shouldDebugClipLogs;
98
- private debugClipLog;
99
- private createRuntimeConnector;
100
- getRuntimeSnapshot(): Record<string, unknown> | null;
101
- private getActionId;
102
- private setActionId;
103
- private clearActionId;
104
- private uncacheClip;
105
- private uncacheAction;
106
- private releaseBakedMixerAction;
107
- private clearBakedAdditiveMixerClip;
108
- private clearAllBakedAdditiveMixerClips;
109
- private resolveTrackTarget;
110
- private getMorphTrackBaseValue;
111
- private canCreateFirstFrameReferenceTrack;
112
- private createFirstFrameReferenceTrack;
113
- private createAdditiveReferenceTrack;
114
- private createAdditiveMixerClip;
115
- private getOrCreateBakedAdditiveMixerClip;
116
- private setClipEventMetadata;
117
- private getClipEventMetadata;
118
- private curvesHaveInheritedStart;
119
- private channelsHaveInheritedStart;
120
- private rebuildDynamicClip;
121
- private resolveInheritedClipForPlayback;
122
- private getKeyframeIndex;
123
- private emitClipEvent;
124
- private emitKeyframesForRange;
125
- private resetClipMonitor;
126
- private syncClipMonitorTime;
127
- private cleanupClipMonitor;
128
- private advanceClipMonitor;
129
- private normalizePlaybackOptions;
130
- private applyPlaybackState;
131
- private setPlaybackState;
132
- private getPlaybackStateSnapshot;
133
- private mergePlaybackOptions;
134
- private isBakedSourceClip;
135
- private getBakedSourceClip;
136
- private getBakedChannelInfo;
137
- private getBakedAggregateBlendMode;
138
- private applyPlaybackStateToBakedAction;
139
- private resolveStartTime;
140
- private getOrCreateBakedMixerAction;
141
- private getRepresentativeBakedAction;
142
- private createBakedActionGroup;
143
- private getMeshNamesForAU;
144
- private getMeshNamesForViseme;
145
- private hasActiveAdditivePlayback;
146
- update(dtSeconds: number): void;
147
- dispose(): void;
148
- loadAnimationClips(clips: unknown[]): void;
149
- getAnimationClips(): AnimationClipInfo[];
150
- removeAnimationClip(clipName: string): boolean;
151
- playAnimation(clipName: string, options?: AnimationPlayOptions): AnimationActionHandle | null;
152
- stopAnimation(clipName: string): void;
153
- stopAllAnimations(): void;
154
- pauseAnimation(clipName: string): void;
155
- resumeAnimation(clipName: string): void;
156
- pauseAllAnimations(): void;
157
- resumeAllAnimations(): void;
158
- setAnimationSpeed(clipName: string, speed: number): void;
159
- setAnimationIntensity(clipName: string, intensity: number): void;
160
- setAnimationLoopMode(clipName: string, loopMode: 'repeat' | 'once' | 'pingpong'): void;
161
- setAnimationRepeatCount(clipName: string, repeatCount?: number): void;
162
- setAnimationReverse(clipName: string, reverse: boolean): void;
163
- setAnimationBlendMode(clipName: string, blendMode: AnimationBlendMode): void;
164
- seekAnimation(clipName: string, time: number): void;
165
- setAnimationTimeScale(timeScale: number): void;
166
- getAnimationState(clipName: string): AnimationState | null;
167
- getPlayingAnimations(): AnimationState[];
168
- crossfadeTo(clipName: string, duration?: number, options?: AnimationPlayOptions): AnimationActionHandle | null;
169
- snippetToClip(clipName: string, curves: CurvesMap, options?: ClipOptions): AnimationClip | null;
170
- typedSnippetToClip(clipName: string, channels: SnippetChannel[], options?: ClipOptions): AnimationClip | null;
171
- private playClipDirect;
172
- playClip(clip: AnimationClip, options?: ClipOptions): ClipHandle | null;
173
- playSnippet(snippet: Snippet | {
174
- name: string;
175
- curves: CurvesMap;
176
- } | TypedSnippet | {
177
- name: string;
178
- channels: SnippetChannel[];
179
- }, options?: ClipOptions): ClipHandle | null;
180
- playTypedSnippet(snippet: TypedSnippet | {
181
- name: string;
182
- channels: SnippetChannel[];
183
- }, options?: ClipOptions): ClipHandle | null;
184
- buildClip(clipName: string, curves: CurvesMap, options?: ClipOptions): ClipHandle | null;
185
- private buildClipDirect;
186
- buildTypedClip(clipName: string, channels: SnippetChannel[], options?: ClipOptions): ClipHandle | null;
187
- cleanupSnippet(name: string): void;
188
- private cleanupSnippetDirect;
189
- updateClipParams(name: string, params: ClipParamsUpdate): boolean;
190
- private updateClipParamsDirect;
191
- private addMorphTracks;
192
- private addMorphIndexTracks;
193
- private sampleFinalKeyframeValue;
194
- private ensureMixer;
195
- private ensureClipMixer;
196
- private handleMixerFinished;
197
- private createAnimationHandle;
198
- private createBakedAnimationHandle;
199
- }
200
- /** @deprecated Use ThreeAnimationSystem. */
201
- export { ThreeAnimationSystem as AnimationController };
202
- /** @deprecated Use ThreeAnimationSystem. */
203
- export { ThreeAnimationSystem as BakedAnimationController };
@@ -1,24 +0,0 @@
1
- import { AnimationClip } from 'three';
2
- import type { Object3D } from 'three';
3
- import type { BoneId, ClipIR, MeshId, MorphTargetId } from '../../core/contracts';
4
- export interface ThreeClipMeshBinding {
5
- readonly trackName: string;
6
- }
7
- export interface ThreeClipMorphTargetBinding {
8
- readonly meshId: MeshId;
9
- readonly index: number;
10
- }
11
- export interface ThreeClipAdapterBindings {
12
- readonly meshes?: ReadonlyMap<MeshId, Object3D | ThreeClipMeshBinding>;
13
- readonly morphTargets?: ReadonlyMap<MorphTargetId, ThreeClipMorphTargetBinding>;
14
- readonly bones?: ReadonlyMap<BoneId, Object3D | string>;
15
- }
16
- export declare class ThreeClipAdapter {
17
- private meshes;
18
- private morphTargets;
19
- private bones;
20
- constructor(bindings?: ThreeClipAdapterBindings);
21
- setBindings(bindings: ThreeClipAdapterBindings): void;
22
- toAnimationClip(clip: ClipIR): AnimationClip;
23
- private toKeyframeTrack;
24
- }
@@ -1,68 +0,0 @@
1
- import type { Mesh, Object3D } from 'three';
2
- import type { BoneId, FrameDelta, HostFrameApplier, MeshId, MorphTargetId, Transform } from '../../core/contracts';
3
- export interface ThreeMorphTargetBinding {
4
- readonly meshId: MeshId;
5
- readonly mesh: Mesh;
6
- readonly index: number;
7
- }
8
- export interface ThreeFrameApplierBindings {
9
- readonly meshes?: ReadonlyMap<MeshId, Mesh>;
10
- readonly morphTargets?: ReadonlyMap<MorphTargetId, ThreeMorphTargetBinding>;
11
- readonly bones?: ReadonlyMap<BoneId, Object3D>;
12
- }
13
- export interface ThreeMaterialConfig {
14
- renderOrder?: number;
15
- transparent?: boolean;
16
- opacity?: number;
17
- depthWrite?: boolean;
18
- depthTest?: boolean;
19
- blending?: keyof typeof THREE_BLENDING_MODES;
20
- }
21
- export interface ThreeResolvedMaterialConfig {
22
- renderOrder: number;
23
- transparent: boolean;
24
- opacity: number;
25
- depthWrite: boolean;
26
- depthTest: boolean;
27
- blending: keyof typeof THREE_BLENDING_MODES;
28
- }
29
- export interface ThreeMeshMaterialConfig {
30
- readonly material?: ThreeMaterialConfig;
31
- }
32
- export declare const THREE_BLENDING_MODES: {
33
- readonly Normal: 1;
34
- readonly Additive: 2;
35
- readonly Subtractive: 3;
36
- readonly Multiply: 4;
37
- readonly None: 0;
38
- };
39
- export declare class ThreeFrameApplier implements HostFrameApplier<Object3D> {
40
- private meshes;
41
- private morphTargets;
42
- private bones;
43
- private originalEmissive;
44
- constructor(bindings?: ThreeFrameApplierBindings);
45
- setBindings(bindings: ThreeFrameApplierBindings): void;
46
- applyFrameDelta(model: Object3D, frame: FrameDelta): void;
47
- applyPackedMorphFrameDelta(values: ArrayLike<number>, stride?: number): void;
48
- /** Rows: `[boneId, px, py, pz, qx, qy, qz, qw, flags]`; flags bit0=position, bit1=rotation. */
49
- applyPackedBoneFrameDelta(values: ArrayLike<number>, stride?: number): void;
50
- applyObjectTransform(target: Object3D, transform: Transform, mode?: 'absolute' | 'additive'): void;
51
- applyMorphTargets(targets: readonly {
52
- infl: number[];
53
- idx: number;
54
- }[], value: number): void;
55
- resetMorphTargets(targets: readonly {
56
- infl: number[];
57
- idx: number;
58
- }[]): void;
59
- setMeshVisible(root: Object3D, meshName: string, visible: boolean): void;
60
- highlightMesh(root: Object3D, meshName: string | null, color?: number, intensity?: number): void;
61
- getMeshMaterialConfig(root: Object3D, meshName: string): ThreeResolvedMaterialConfig | null;
62
- setMeshMaterialConfig(root: Object3D, meshName: string, config: ThreeMaterialConfig): void;
63
- applyMeshMaterialConfigs(root: Object3D, configs: Readonly<Record<string, ThreeMeshMaterialConfig>>): void;
64
- private applyMeshMaterialConfig;
65
- private setMorphTarget;
66
- private applyTransform;
67
- private visitNamedMesh;
68
- }