@lovelace_lol/embody 0.0.7 → 0.0.8
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 +541 -2394
- package/dist/index.d.ts +2 -100
- package/dist/index.js +7714 -12951
- package/dist/index.js.map +1 -1
- package/dist/three/annotations/DOMControls.d.ts +73 -0
- package/dist/three/annotations/DPthree.d.ts +113 -0
- package/dist/three/annotations/DPthree3DMarkers.d.ts +319 -0
- package/dist/three/annotations/DPthreeCameraController.d.ts +414 -0
- package/dist/three/annotations/DPthreeHTMLMarkers.d.ts +131 -0
- package/dist/three/annotations/DPthreeMarkers.d.ts +52 -0
- package/dist/three/annotations/adapter.d.ts +157 -0
- package/dist/three/annotations/animationFrameTaskScheduler.d.ts +18 -0
- package/dist/three/annotations/annotationAnchorModel.d.ts +16 -0
- package/dist/three/annotations/annotationCameraCore.d.ts +5 -0
- package/dist/three/annotations/boneResolutionProfile.d.ts +7 -0
- package/dist/three/annotations/index.d.ts +20 -0
- package/dist/three/annotations/loadFrame.d.ts +2 -0
- package/dist/three/annotations/markerSurfaceRaycast.d.ts +11 -0
- package/dist/three/annotations/markerVisibilityLifecycle.d.ts +21 -0
- package/dist/three/annotations/modelRenderPreparation.d.ts +6 -0
- package/dist/three/annotations/runtimeAnnotationPreview.d.ts +15 -0
- package/dist/three/annotations/runtimeAnnotationPreviewSide.d.ts +10 -0
- package/dist/three/annotations/runtimeAnnotationSidePreview.d.ts +5 -0
- package/dist/three/annotations/types.d.ts +262 -0
- package/dist/three/gaze.d.ts +122 -0
- package/dist/three/index.d.ts +147 -0
- package/dist/three/model.d.ts +31 -0
- package/dist/three/modelSkinning.d.ts +3 -0
- package/dist/three/reference-pose.d.ts +73 -0
- package/dist/three/scene.d.ts +253 -0
- package/dist/three/sceneRenderingBinding.d.ts +22 -0
- package/dist/three.js +7696 -8936
- package/dist/three.js.map +1 -1
- package/dist/wasm/README.md +551 -62
- package/dist/wasm/auto.d.ts +1 -0
- package/dist/wasm/embody_wasm.d.ts +388 -52
- package/dist/wasm/embody_wasm.js +1514 -119
- package/dist/wasm/embody_wasm_bg.wasm +0 -0
- package/dist/wasm/embody_wasm_bg.wasm.d.ts +115 -40
- package/dist/wasm/index.d.ts +126 -0
- package/dist/wasm.d.ts +1 -43
- package/dist/wasm.js +1043 -239
- package/dist/wasm.js.map +1 -1
- package/package.json +34 -39
- package/service-worker/character-asset-service-worker.js +295 -0
- package/dist/authoring/boneAuthoring.d.ts +0 -132
- package/dist/camera/annotationCameraAngles.d.ts +0 -28
- package/dist/camera/cameraRelativeGaze.d.ts +0 -15
- package/dist/camera/rustAnnotationCameraCore.d.ts +0 -136
- package/dist/cljs.cjs +0 -362
- package/dist/cljs.cjs.map +0 -1
- package/dist/cljs.d.ts +0 -5
- package/dist/cljs.js +0 -359
- package/dist/cljs.js.map +0 -1
- package/dist/core/TsClipCompiler.d.ts +0 -51
- package/dist/core/WasmRuntimeCore.d.ts +0 -41
- package/dist/core/compositeAxis.d.ts +0 -4
- package/dist/core/contracts/abi.d.ts +0 -70
- package/dist/core/contracts/clip.d.ts +0 -44
- package/dist/core/contracts/frame.d.ts +0 -27
- package/dist/core/contracts/host.d.ts +0 -28
- package/dist/core/contracts/ids.d.ts +0 -15
- package/dist/core/contracts/index.d.ts +0 -10
- package/dist/core/contracts/model.d.ts +0 -31
- package/dist/core/contracts/primitives.d.ts +0 -17
- package/dist/core/contracts/skeletonFit.d.ts +0 -41
- package/dist/core/index.d.ts +0 -6
- package/dist/core/types.d.ts +0 -472
- package/dist/core.cjs +0 -343
- package/dist/core.cjs.map +0 -1
- package/dist/core.js +0 -323
- package/dist/core.js.map +0 -1
- package/dist/engines/three/Embody.d.ts +0 -372
- package/dist/engines/three/ThreeAnimationRuntime.d.ts +0 -203
- package/dist/engines/three/ThreeClipAdapter.d.ts +0 -24
- package/dist/engines/three/ThreeFrameApplier.d.ts +0 -68
- package/dist/engines/three/ThreeModelInspector.d.ts +0 -54
- package/dist/engines/three/bakedClipPartitioning.d.ts +0 -16
- package/dist/engines/three/balanceUtils.d.ts +0 -3
- package/dist/engines/three/characterHost.d.ts +0 -80
- package/dist/engines/three/characterScene.d.ts +0 -98
- package/dist/engines/three/hair/HairPhysicsController.d.ts +0 -124
- package/dist/engines/three/index.d.ts +0 -20
- package/dist/engines/three/modelLoader.d.ts +0 -61
- package/dist/engines/three/profileTestScene.d.ts +0 -52
- package/dist/engines/three/types.d.ts +0 -20
- package/dist/hair/appearance.d.ts +0 -29
- package/dist/index.cjs +0 -14871
- package/dist/index.cjs.map +0 -1
- package/dist/interfaces/Animation.d.ts +0 -315
- package/dist/interfaces/EmbodyRuntime.d.ts +0 -90
- package/dist/interfaces/Hair.d.ts +0 -181
- package/dist/interfaces/HairPhysics.d.ts +0 -90
- package/dist/interfaces/index.d.ts +0 -11
- package/dist/mappings/extendPresetWithProfile.d.ts +0 -17
- package/dist/mappings/types.d.ts +0 -309
- package/dist/mappings/visemeSystem.d.ts +0 -26
- package/dist/physics/HairPhysics.d.ts +0 -86
- package/dist/physics/RustHairPhysics.d.ts +0 -18
- package/dist/physics/index.d.ts +0 -6
- package/dist/preset.cjs +0 -2005
- package/dist/preset.cjs.map +0 -1
- package/dist/preset.js +0 -2003
- package/dist/preset.js.map +0 -1
- package/dist/presets/bettaFish.d.ts +0 -328
- package/dist/presets/cc4.d.ts +0 -145
- package/dist/presets/index.d.ts +0 -30
- package/dist/presets/registry.d.ts +0 -57
- package/dist/profiles/resolveProfileConfig.d.ts +0 -36
- package/dist/profiles/rustResolvedProfile.d.ts +0 -31
- package/dist/profiles/types.d.ts +0 -118
- package/dist/regions/normalizeRegionTree.d.ts +0 -6
- package/dist/regions/regionMapping.d.ts +0 -17
- package/dist/regions/types.d.ts +0 -122
- package/dist/skeletonTemplates/humanoidSkeletonTemplates.d.ts +0 -32
- package/dist/test/setupWasm.d.ts +0 -1
- package/dist/three.cjs +0 -9550
- package/dist/three.cjs.map +0 -1
- package/dist/validation/analyzeModel.d.ts +0 -68
- package/dist/validation/extractModelData.d.ts +0 -90
- package/dist/validation/generateMappingCorrections.d.ts +0 -32
- package/dist/validation/geometryHelpers.d.ts +0 -66
- package/dist/validation/types.d.ts +0 -10
- package/dist/validation/validateMappings.d.ts +0 -77
- package/dist/wasm.cjs +0 -302
- package/dist/wasm.cjs.map +0 -1
- package/dist/wasmTypes.d.ts +0 -123
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
3
|
+
import type { DPthreeCameraControllerConfig, CharacterConfig, CameraState, RegionChangeCallback, MarkerStyle, AnnotationAnchoredRegion, RuntimeAnnotationOptions, RuntimeAnnotationRegionSummary } from './types';
|
|
4
|
+
export declare function resolveFocusCameraDirection(model: THREE.Object3D | null, effectiveAngle: number, cameraAngle: number | undefined, angleSpace?: 'model' | 'world'): THREE.Vector3;
|
|
5
|
+
export declare function resolveAutoCloseupAngle(horizontalOffset: number, focusSize: THREE.Vector3, modelSize: THREE.Vector3): number | undefined;
|
|
6
|
+
export type MarkerStateSnapshot = {
|
|
7
|
+
style: MarkerStyle;
|
|
8
|
+
visible: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* DPthreeCameraController - A unified camera controller for character viewers
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
* - OrbitControls wrapper for smooth camera interaction
|
|
15
|
+
* - Focus on specific bones, meshes, or named regions
|
|
16
|
+
* - Smart bounding box calculation with size-based padding
|
|
17
|
+
* - Smooth animated transitions between views
|
|
18
|
+
* - Self-contained DOM controls for region selection
|
|
19
|
+
*
|
|
20
|
+
* Designed for future NPM packaging - no React dependencies.
|
|
21
|
+
*/
|
|
22
|
+
export declare class DPthreeCameraController {
|
|
23
|
+
readonly camera: THREE.PerspectiveCamera;
|
|
24
|
+
readonly controls: OrbitControls;
|
|
25
|
+
readonly scene: THREE.Scene;
|
|
26
|
+
private readonly resolveCharacterConfig;
|
|
27
|
+
private readonly selectRegion;
|
|
28
|
+
private config;
|
|
29
|
+
private controlsContainer;
|
|
30
|
+
private model;
|
|
31
|
+
private regions;
|
|
32
|
+
private currentRegion;
|
|
33
|
+
private characterConfig;
|
|
34
|
+
private runtimeAnnotationRegionNames;
|
|
35
|
+
private timerAnimationFallbackToken;
|
|
36
|
+
private cameraRequestGeneration;
|
|
37
|
+
private regionLoadGeneration;
|
|
38
|
+
private disposed;
|
|
39
|
+
private pendingAnimation;
|
|
40
|
+
private domControls;
|
|
41
|
+
private markers;
|
|
42
|
+
private currentMarkerStyle;
|
|
43
|
+
private markersLoaded;
|
|
44
|
+
private markersVisible;
|
|
45
|
+
private markerStateListeners;
|
|
46
|
+
private domElement;
|
|
47
|
+
private renderer;
|
|
48
|
+
private renderFrame;
|
|
49
|
+
private resizeRenderer;
|
|
50
|
+
private onRenderError;
|
|
51
|
+
private renderingSuspended;
|
|
52
|
+
private unbindRendering;
|
|
53
|
+
private renderingFailure;
|
|
54
|
+
private framePending;
|
|
55
|
+
private frameCompletion;
|
|
56
|
+
private modelPreparation;
|
|
57
|
+
private renderFailed;
|
|
58
|
+
private resizeObserver;
|
|
59
|
+
private boundResizeHandler;
|
|
60
|
+
private laterality;
|
|
61
|
+
private onRegionChangeCallbacks;
|
|
62
|
+
constructor(inputConfig: DPthreeCameraControllerConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Start the render loop (only when renderer is provided)
|
|
65
|
+
*/
|
|
66
|
+
private startRenderLoop;
|
|
67
|
+
private handleRenderError;
|
|
68
|
+
/**
|
|
69
|
+
* Stop the render loop
|
|
70
|
+
*/
|
|
71
|
+
private stopRenderLoop;
|
|
72
|
+
private shouldDriveTimerAnimationFallback;
|
|
73
|
+
private getTimerAnimationFallbackDelay;
|
|
74
|
+
private scheduleTimerAnimationFallback;
|
|
75
|
+
/**
|
|
76
|
+
* Set up resize handling for the renderer
|
|
77
|
+
* Uses ResizeObserver for container size changes
|
|
78
|
+
*/
|
|
79
|
+
private setupResizeHandling;
|
|
80
|
+
/**
|
|
81
|
+
* Clean up resize handling
|
|
82
|
+
*/
|
|
83
|
+
private cleanupResizeHandling;
|
|
84
|
+
/**
|
|
85
|
+
* Prepare the currently visible material variants before first reveal.
|
|
86
|
+
* Borrows model/renderer; callers retain them until this promise settles,
|
|
87
|
+
* including after cancellation or controller disposal.
|
|
88
|
+
*/
|
|
89
|
+
prepareModelForRender(model: THREE.Object3D, options?: {
|
|
90
|
+
signal?: AbortSignal;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
private cancelModelPreparation;
|
|
93
|
+
/**
|
|
94
|
+
* Set the model to use for bone/mesh lookups
|
|
95
|
+
* Must be called after model loads
|
|
96
|
+
*/
|
|
97
|
+
setModel(model: THREE.Object3D): void;
|
|
98
|
+
/** Release model references before the host disposes it, under a rendering lease. */
|
|
99
|
+
clearModel(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Load region config for a character
|
|
102
|
+
*/
|
|
103
|
+
loadRegions(config: CharacterConfig): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Prime an already-resolved runtime config before the character becomes visible.
|
|
106
|
+
* Marker construction is intentionally separate so startup can defer the expensive
|
|
107
|
+
* per-region marker geometry/DOM work until after the first visible frame.
|
|
108
|
+
*/
|
|
109
|
+
prepareRegionsForReveal(config: CharacterConfig): void;
|
|
110
|
+
/**
|
|
111
|
+
* Prepare marker geometry while the character loading overlay is still up,
|
|
112
|
+
* then start the intro camera transition after that work has completed.
|
|
113
|
+
*/
|
|
114
|
+
prepareRegionsAndMarkersForReveal(config: CharacterConfig, beforeReveal?: () => Promise<boolean>): Promise<void>;
|
|
115
|
+
private prepareRegionState;
|
|
116
|
+
private startPreparedCameraTransition;
|
|
117
|
+
/**
|
|
118
|
+
* Build marker objects for the current character config.
|
|
119
|
+
* This is separated from prepareRegionsForReveal so callers can defer the
|
|
120
|
+
* expensive marker construction until after the first visible frame.
|
|
121
|
+
*/
|
|
122
|
+
loadMarkersForCurrentRegions(sliceSurfaceQueries?: boolean): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Focus on a named region from the loaded config
|
|
125
|
+
*/
|
|
126
|
+
focusRegion(name: string, duration?: number): Promise<void>;
|
|
127
|
+
private resolveRegionFocusPosition;
|
|
128
|
+
private resolveLegacyRegionFocusPosition;
|
|
129
|
+
private resolveFocusTargetObjects;
|
|
130
|
+
/**
|
|
131
|
+
* Focus on specific bones by name
|
|
132
|
+
*/
|
|
133
|
+
focusBones(boneNames: string[], duration?: number): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Focus on specific meshes by name
|
|
136
|
+
*/
|
|
137
|
+
focusMeshes(meshNames: string[], duration?: number): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Focus on the full body (entire model bounding box)
|
|
140
|
+
*/
|
|
141
|
+
focusFullBody(duration?: number): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Focus on arbitrary objects
|
|
144
|
+
*/
|
|
145
|
+
focusObjects(objects: THREE.Object3D[], duration?: number): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Play intro animation: orbit around the character, then settle into a tight
|
|
148
|
+
* left-eye hero closeup when the character provides a left-eye region.
|
|
149
|
+
* @param orbitDuration - Duration of the 360° orbit in ms (default: 3000)
|
|
150
|
+
* @param zoomDuration - Duration of the final zoom in ms (default: 1500)
|
|
151
|
+
*/
|
|
152
|
+
playIntroAnimation(orbitDuration?: number, zoomDuration?: number): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Animate a smooth 360° orbit around a center point
|
|
155
|
+
* Animation is driven by the update() method which is called from the render loop.
|
|
156
|
+
*/
|
|
157
|
+
private animateOrbit;
|
|
158
|
+
/**
|
|
159
|
+
* Get list of available region names
|
|
160
|
+
*/
|
|
161
|
+
getRegionNames(): string[];
|
|
162
|
+
/**
|
|
163
|
+
* Get current region name
|
|
164
|
+
*/
|
|
165
|
+
getCurrentRegion(): string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Get loaded character config
|
|
168
|
+
*/
|
|
169
|
+
getCharacterConfig(): CharacterConfig | null;
|
|
170
|
+
/**
|
|
171
|
+
* Get current camera state
|
|
172
|
+
*/
|
|
173
|
+
getCameraState(): CameraState;
|
|
174
|
+
/**
|
|
175
|
+
* Set camera state directly (no animation)
|
|
176
|
+
*/
|
|
177
|
+
setCameraState(state: CameraState): void;
|
|
178
|
+
/**
|
|
179
|
+
* Animate to camera state
|
|
180
|
+
*/
|
|
181
|
+
animateToCameraState(state: CameraState, duration?: number): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Show/hide region markers
|
|
184
|
+
*/
|
|
185
|
+
setMarkersVisible(visible: boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* Get current markers visibility state
|
|
188
|
+
*/
|
|
189
|
+
getMarkersVisible(): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Clear all markers and reset region state
|
|
192
|
+
*/
|
|
193
|
+
clearMarkers(): void;
|
|
194
|
+
/**
|
|
195
|
+
* Get current marker style
|
|
196
|
+
*/
|
|
197
|
+
getMarkerStyle(): MarkerStyle;
|
|
198
|
+
/**
|
|
199
|
+
* Set marker style (html or 3d) - recreates markers with new style
|
|
200
|
+
*/
|
|
201
|
+
setMarkerStyle(style: MarkerStyle): void;
|
|
202
|
+
private setMarkerStyleState;
|
|
203
|
+
private ensureMarkersForCurrentStyle;
|
|
204
|
+
subscribeMarkerState(listener: (state: MarkerStateSnapshot) => void): () => void;
|
|
205
|
+
private getMarkerState;
|
|
206
|
+
private emitMarkerState;
|
|
207
|
+
/**
|
|
208
|
+
* Solo a marker - show only this marker, hide all others
|
|
209
|
+
* @param regionName - Region to solo (null to unsolo all)
|
|
210
|
+
*/
|
|
211
|
+
soloMarker(regionName: string | null): void;
|
|
212
|
+
/**
|
|
213
|
+
* Get currently soloed marker name (or null)
|
|
214
|
+
*/
|
|
215
|
+
getSoloedMarker(): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* Expand a region to show its children
|
|
218
|
+
* @param regionName - Name of the parent region to expand
|
|
219
|
+
* @param duration - Animation duration in ms (default: 400)
|
|
220
|
+
*/
|
|
221
|
+
expandRegion(regionName: string, duration?: number): void;
|
|
222
|
+
/**
|
|
223
|
+
* Collapse a region to hide its children
|
|
224
|
+
* @param regionName - Name of the parent region to collapse
|
|
225
|
+
* @param duration - Animation duration in ms (default: 300)
|
|
226
|
+
*/
|
|
227
|
+
collapseRegion(regionName: string, duration?: number): void;
|
|
228
|
+
/**
|
|
229
|
+
* Toggle expand/collapse state of a region
|
|
230
|
+
* @param regionName - Name of the parent region to toggle
|
|
231
|
+
* @param animation - Animation style: 'outward' or 'staggered'
|
|
232
|
+
* @param duration - Animation duration in ms
|
|
233
|
+
*/
|
|
234
|
+
toggleRegion(regionName: string, animation?: 'outward' | 'staggered', duration?: number): void;
|
|
235
|
+
/**
|
|
236
|
+
* Get current expanded state of all regions
|
|
237
|
+
*/
|
|
238
|
+
getExpandedRegions(): {
|
|
239
|
+
regionName: string;
|
|
240
|
+
isExpanded: boolean;
|
|
241
|
+
children: string[];
|
|
242
|
+
}[];
|
|
243
|
+
/**
|
|
244
|
+
* Update line style for a specific region at runtime
|
|
245
|
+
*/
|
|
246
|
+
setRegionLineStyle(regionName: string, lineConfig: {
|
|
247
|
+
style?: 'solid' | 'dashed' | 'dotted';
|
|
248
|
+
curve?: 'straight' | 'bezier' | 'arc';
|
|
249
|
+
arrowHead?: boolean;
|
|
250
|
+
thickness?: number;
|
|
251
|
+
length?: number;
|
|
252
|
+
}): void;
|
|
253
|
+
/**
|
|
254
|
+
* Update marker style for a specific region at runtime
|
|
255
|
+
*/
|
|
256
|
+
setRegionStyle(regionName: string, style: {
|
|
257
|
+
markerColor?: number;
|
|
258
|
+
markerRadius?: number;
|
|
259
|
+
lineColor?: number;
|
|
260
|
+
labelColor?: string;
|
|
261
|
+
labelBackground?: string;
|
|
262
|
+
labelFontSize?: number;
|
|
263
|
+
opacity?: number;
|
|
264
|
+
}): void;
|
|
265
|
+
/**
|
|
266
|
+
* Update the face mesh configuration for a region and recalculate its position.
|
|
267
|
+
* This is called when the user selects a different face mesh in the wizard.
|
|
268
|
+
*
|
|
269
|
+
* @param regionName - Name of the region to update (e.g., 'face')
|
|
270
|
+
* @param meshNames - Array of mesh names to use for positioning
|
|
271
|
+
*/
|
|
272
|
+
updateRegionMeshes(regionName: string, meshNames: string[]): void;
|
|
273
|
+
/**
|
|
274
|
+
* Reposition an existing marker to a new position.
|
|
275
|
+
*
|
|
276
|
+
* @param regionName - Name of the region to reposition
|
|
277
|
+
* @param position - New world position { x, y, z }
|
|
278
|
+
*/
|
|
279
|
+
repositionMarker(regionName: string, position: {
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
z: number;
|
|
283
|
+
}): void;
|
|
284
|
+
/**
|
|
285
|
+
* Get the current position of a marker
|
|
286
|
+
*/
|
|
287
|
+
getMarkerPosition(regionName: string): {
|
|
288
|
+
x: number;
|
|
289
|
+
y: number;
|
|
290
|
+
z: number;
|
|
291
|
+
} | null;
|
|
292
|
+
/**
|
|
293
|
+
* Get the current model reference
|
|
294
|
+
*/
|
|
295
|
+
getModel(): THREE.Object3D | null;
|
|
296
|
+
/**
|
|
297
|
+
* Remove an annotation region from the active runtime config and marker set.
|
|
298
|
+
*
|
|
299
|
+
* Persistence still happens through the canonical profile annotation overrides
|
|
300
|
+
* saved by the authoring UI; this only keeps the live scene in sync.
|
|
301
|
+
*/
|
|
302
|
+
removeAnnotationRegion(regionName: string): void;
|
|
303
|
+
/**
|
|
304
|
+
* Update an annotation region's configuration without reloading the character.
|
|
305
|
+
* This updates the region's bones, meshes, or other properties and recalculates
|
|
306
|
+
* the marker position automatically.
|
|
307
|
+
*
|
|
308
|
+
* @param regionName - Name of the region to update (e.g., 'face', 'left_eye')
|
|
309
|
+
* @param update - Partial region config to merge with existing config
|
|
310
|
+
*/
|
|
311
|
+
updateAnnotationRegion(regionName: string, update: Partial<AnnotationAnchoredRegion>): void;
|
|
312
|
+
/**
|
|
313
|
+
* Get the current configuration for a specific region
|
|
314
|
+
*/
|
|
315
|
+
getAnnotationRegion(regionName: string): AnnotationAnchoredRegion | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Get all annotation regions
|
|
318
|
+
*/
|
|
319
|
+
getAnnotationRegions(): AnnotationAnchoredRegion[];
|
|
320
|
+
private buildRuntimeAnnotationRegionName;
|
|
321
|
+
private buildRuntimeBoneAnnotationRegion;
|
|
322
|
+
private buildRuntimeMeshAnnotationRegionName;
|
|
323
|
+
private buildRuntimeMeshAnnotationRegion;
|
|
324
|
+
private upsertRuntimeBoneAnnotationRegion;
|
|
325
|
+
private upsertRuntimeMeshAnnotationRegion;
|
|
326
|
+
private clearRuntimeAnnotationsForTarget;
|
|
327
|
+
private clearRuntimeAnnotationsExcept;
|
|
328
|
+
/**
|
|
329
|
+
* Show a temporary annotation marker for a bone. Runtime annotations are
|
|
330
|
+
* ordinary regions with explicit bone marker/focus anchors, tracked separately
|
|
331
|
+
* so they can be cleared without modifying saved character annotations.
|
|
332
|
+
*/
|
|
333
|
+
showRuntimeBoneAnnotation(boneName: string, options?: RuntimeAnnotationOptions): RuntimeAnnotationRegionSummary;
|
|
334
|
+
/**
|
|
335
|
+
* Show temporary annotation markers for every bone binding used by an AU.
|
|
336
|
+
* The optional profile override lets remote-control callers use the active
|
|
337
|
+
* Embody engine profile, while normal controller consumers can rely on the
|
|
338
|
+
* loaded character config.
|
|
339
|
+
*/
|
|
340
|
+
showRuntimeAUAnnotations(auId: string | number, profileOverride?: unknown, options?: RuntimeAnnotationOptions, morphTargetsByMesh?: unknown): RuntimeAnnotationRegionSummary[];
|
|
341
|
+
/**
|
|
342
|
+
* Remove all temporary runtime annotations created through the AU/bone API.
|
|
343
|
+
*/
|
|
344
|
+
clearRuntimeAnnotations(): string[];
|
|
345
|
+
/**
|
|
346
|
+
* Show/hide built-in DOM controls
|
|
347
|
+
*/
|
|
348
|
+
setDOMControlsVisible(visible: boolean): void;
|
|
349
|
+
/**
|
|
350
|
+
* Update DOM controls to reflect current regions
|
|
351
|
+
*/
|
|
352
|
+
updateDOMControls(): void;
|
|
353
|
+
/**
|
|
354
|
+
* Register callback for region changes
|
|
355
|
+
*/
|
|
356
|
+
onRegionChange(callback: RegionChangeCallback): () => void;
|
|
357
|
+
/**
|
|
358
|
+
* Update loop - call in animation frame (from render loop)
|
|
359
|
+
* This drives camera animations and marker updates
|
|
360
|
+
*/
|
|
361
|
+
update(): void;
|
|
362
|
+
/**
|
|
363
|
+
* Cleanup and dispose
|
|
364
|
+
*/
|
|
365
|
+
dispose(): void;
|
|
366
|
+
private initDOMControls;
|
|
367
|
+
private notifyRegionChange;
|
|
368
|
+
/**
|
|
369
|
+
* Resolve region definition to actual Object3D instances
|
|
370
|
+
*/
|
|
371
|
+
private resolveRegionObjects;
|
|
372
|
+
/**
|
|
373
|
+
* Find objects by name with optional type filter.
|
|
374
|
+
* Uses fuzzy matching to handle bone names with numeric suffixes
|
|
375
|
+
* (e.g., "CC_Base_Head_038" matches "CC_Base_Head").
|
|
376
|
+
*/
|
|
377
|
+
private findObjectsByNames;
|
|
378
|
+
/**
|
|
379
|
+
* Get bounding box of vertices influenced by a bone from skinned meshes
|
|
380
|
+
* This finds the actual geometry size around a bone for proper framing
|
|
381
|
+
*
|
|
382
|
+
* For skinned meshes, we need to compute the actual skinned vertex positions,
|
|
383
|
+
* not just the bind pose positions.
|
|
384
|
+
*/
|
|
385
|
+
private getBoneInfluencedBoundingBox;
|
|
386
|
+
/**
|
|
387
|
+
* Calculate optimal camera position to frame objects
|
|
388
|
+
* @param objects - Objects to focus on
|
|
389
|
+
* @param overridePadding - Optional padding factor override
|
|
390
|
+
* @param cameraAngle - Camera angle in degrees around Y axis (0 = front, 180 = back)
|
|
391
|
+
*/
|
|
392
|
+
private calculateFocusPosition;
|
|
393
|
+
private calculatePointFocusPosition;
|
|
394
|
+
private resolvePointFocusSize;
|
|
395
|
+
private getFallbackFocusPosition;
|
|
396
|
+
private isFullBodyRegion;
|
|
397
|
+
private isLeftEyeRegion;
|
|
398
|
+
private findIntroLeftEyeRegion;
|
|
399
|
+
private resolveIntroLeftEyePadding;
|
|
400
|
+
private calculateIntroLeftEyeFocusPosition;
|
|
401
|
+
private applyIntroLeftEyeCompositionBias;
|
|
402
|
+
private calculateFullBodyFocusPosition;
|
|
403
|
+
private refreshLaterality;
|
|
404
|
+
/** Resolver and paint continuations belong to one model/configuration load. */
|
|
405
|
+
private isRegionLoadCurrent;
|
|
406
|
+
/** Await Wasm once per request and abandon requests superseded during initialization. */
|
|
407
|
+
private beginCameraRequest;
|
|
408
|
+
private isCameraRequestCurrent;
|
|
409
|
+
private cancelCameraAnimation;
|
|
410
|
+
private applyCameraPose;
|
|
411
|
+
private runCameraAnimation;
|
|
412
|
+
/** Sample the shared Rust flight from update(), alongside the renderer. */
|
|
413
|
+
private animateCamera;
|
|
414
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Region, CharacterConfig, ExpandAnimation, ExpandedRegionState } from './types';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* HTML overlay markers with GPU-based occlusion via 3D proxy points.
|
|
5
|
+
*
|
|
6
|
+
* Architecture:
|
|
7
|
+
* 1. Each HTML marker has a corresponding invisible 3D mesh in the scene
|
|
8
|
+
* 2. The 3D mesh uses onBeforeRender callback to notify visibility
|
|
9
|
+
* 3. When the mesh renders (passes depth test), it updates the HTML marker position
|
|
10
|
+
* 4. When occluded, the callback doesn't fire, so we track "was rendered this frame"
|
|
11
|
+
*
|
|
12
|
+
* Performance: No per-frame visibility calculations - GPU depth testing determines
|
|
13
|
+
* visibility, and we only update HTML when the 3D proxy actually renders.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DPthreeHTMLMarkers {
|
|
16
|
+
private scene;
|
|
17
|
+
private camera;
|
|
18
|
+
private domElement;
|
|
19
|
+
private model;
|
|
20
|
+
private regions;
|
|
21
|
+
private currentRegion;
|
|
22
|
+
private onSelect;
|
|
23
|
+
private characterConfig;
|
|
24
|
+
private labelsContainer;
|
|
25
|
+
private markers;
|
|
26
|
+
private occlusionGroup;
|
|
27
|
+
private occlusionMeshes;
|
|
28
|
+
private renderedThisFrame;
|
|
29
|
+
private frameId;
|
|
30
|
+
private markerFrameIds;
|
|
31
|
+
private visibilityAnimationActive;
|
|
32
|
+
private readonly visibilityAnimationScheduler;
|
|
33
|
+
private visibilityAnimationToken;
|
|
34
|
+
private modelCenter;
|
|
35
|
+
private modelSize;
|
|
36
|
+
private autoCollapseThreshold;
|
|
37
|
+
private lastCameraDistance;
|
|
38
|
+
private viewportSize;
|
|
39
|
+
private resizeObserver;
|
|
40
|
+
private expandedRegions;
|
|
41
|
+
private parentChildIndex;
|
|
42
|
+
private childParentIndex;
|
|
43
|
+
private hiddenChildren;
|
|
44
|
+
private faceCenterCache;
|
|
45
|
+
private laterality;
|
|
46
|
+
constructor(config: {
|
|
47
|
+
scene: THREE.Scene;
|
|
48
|
+
camera: THREE.PerspectiveCamera;
|
|
49
|
+
domElement: HTMLElement;
|
|
50
|
+
onSelect: (name: string) => void;
|
|
51
|
+
});
|
|
52
|
+
/** Keep labels/selection while rebinding viewport observation to a new canvas. */
|
|
53
|
+
setDomElement(element: HTMLElement): void;
|
|
54
|
+
setModel(model: THREE.Object3D): void;
|
|
55
|
+
loadRegions(config: CharacterConfig): void;
|
|
56
|
+
setCurrentRegion(name: string | null): void;
|
|
57
|
+
/**
|
|
58
|
+
* Update a region's configuration and recreate its marker.
|
|
59
|
+
* This is the general method for updating any region properties.
|
|
60
|
+
*
|
|
61
|
+
* @param regionName - Name of the region to update
|
|
62
|
+
* @param update - Partial region config to merge with existing config
|
|
63
|
+
*/
|
|
64
|
+
updateRegion(regionName: string, update: Partial<Region>): void;
|
|
65
|
+
removeRegion(regionName: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Remove all marker components for a region
|
|
68
|
+
*/
|
|
69
|
+
private removeMarkerComponents;
|
|
70
|
+
updateRegionMeshes(regionName: string, meshNames: string[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Reposition an existing marker to a new position.
|
|
73
|
+
*/
|
|
74
|
+
repositionMarker(regionName: string, newPosition: THREE.Vector3): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the current position of a marker.
|
|
77
|
+
*/
|
|
78
|
+
getMarkerPosition(regionName: string): THREE.Vector3 | null;
|
|
79
|
+
private updateViewportSize;
|
|
80
|
+
private getViewportSize;
|
|
81
|
+
private setMarkerDisplay;
|
|
82
|
+
private setMarkerScale;
|
|
83
|
+
private setMarkerScreenPosition;
|
|
84
|
+
private createMarker;
|
|
85
|
+
/**
|
|
86
|
+
* Called when a 3D proxy mesh is about to render.
|
|
87
|
+
* This means it passed frustum culling and depth test - it's visible!
|
|
88
|
+
*/
|
|
89
|
+
private onProxyRendered;
|
|
90
|
+
private getSuffixPattern;
|
|
91
|
+
/**
|
|
92
|
+
* Get center point of a region's bones/meshes.
|
|
93
|
+
* Uses fuzzy matching to handle bone names with numeric suffixes.
|
|
94
|
+
* For face regions, uses resolveFaceCenter with auto-detection by morph count.
|
|
95
|
+
*/
|
|
96
|
+
private getRegionCenter;
|
|
97
|
+
private updateMarkerStyles;
|
|
98
|
+
/**
|
|
99
|
+
* Call at start of each frame to reset state and update positions.
|
|
100
|
+
* The onBeforeRender callbacks handle showing visible markers.
|
|
101
|
+
* This method hides markers that didn't render.
|
|
102
|
+
*/
|
|
103
|
+
update(): void;
|
|
104
|
+
setVisible(visible: boolean): void;
|
|
105
|
+
private stopVisibilityAnimation;
|
|
106
|
+
private animateVisibility;
|
|
107
|
+
clear(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Expand a parent region to show its children.
|
|
110
|
+
*/
|
|
111
|
+
expandRegion(regionName: string, animation?: ExpandAnimation, duration?: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Collapse a parent region to hide its children.
|
|
114
|
+
*/
|
|
115
|
+
collapseRegion(regionName: string, duration?: number): void;
|
|
116
|
+
/**
|
|
117
|
+
* Toggle expand/collapse state.
|
|
118
|
+
*/
|
|
119
|
+
toggleRegion(regionName: string, animation?: ExpandAnimation, duration?: number): void;
|
|
120
|
+
/**
|
|
121
|
+
* Get expanded state of all regions.
|
|
122
|
+
*/
|
|
123
|
+
getExpandedRegions(): ExpandedRegionState[];
|
|
124
|
+
/**
|
|
125
|
+
* Collapse all currently expanded regions.
|
|
126
|
+
* Called automatically when zooming out past threshold.
|
|
127
|
+
*/
|
|
128
|
+
private collapseAllRegions;
|
|
129
|
+
dispose(): void;
|
|
130
|
+
private refreshLaterality;
|
|
131
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import type { CharacterConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 3D visual markers for regions that can be clicked
|
|
5
|
+
*/
|
|
6
|
+
export declare class DPthreeMarkers {
|
|
7
|
+
private scene;
|
|
8
|
+
private camera;
|
|
9
|
+
private domElement;
|
|
10
|
+
private markers;
|
|
11
|
+
private labels;
|
|
12
|
+
private labelsContainer;
|
|
13
|
+
private raycaster;
|
|
14
|
+
private onSelect;
|
|
15
|
+
private model;
|
|
16
|
+
private regions;
|
|
17
|
+
private characterConfig;
|
|
18
|
+
private currentRegion;
|
|
19
|
+
constructor(config: {
|
|
20
|
+
scene: THREE.Scene;
|
|
21
|
+
camera: THREE.PerspectiveCamera;
|
|
22
|
+
domElement: HTMLElement;
|
|
23
|
+
onSelect: (name: string) => void;
|
|
24
|
+
});
|
|
25
|
+
setModel(model: THREE.Object3D): void;
|
|
26
|
+
loadRegions(config: CharacterConfig): void;
|
|
27
|
+
setCurrentRegion(name: string | null): void;
|
|
28
|
+
private createMarker;
|
|
29
|
+
private getRegionCenter;
|
|
30
|
+
private formatName;
|
|
31
|
+
private updateMarkerStyles;
|
|
32
|
+
private onClick;
|
|
33
|
+
/**
|
|
34
|
+
* Update label positions - call this in render loop
|
|
35
|
+
*
|
|
36
|
+
* Occlusion: Uses efficient dot product check - if marker is on opposite side
|
|
37
|
+
* of model from camera (dot product < 0), hide it. O(1) per marker.
|
|
38
|
+
*/
|
|
39
|
+
update(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Show/hide all markers
|
|
42
|
+
*/
|
|
43
|
+
setVisible(visible: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Clear all markers
|
|
46
|
+
*/
|
|
47
|
+
clear(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Dispose and cleanup
|
|
50
|
+
*/
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|