@lovelace_lol/embody 0.0.13 → 0.0.15
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 +123 -23
- package/dist/index.js +1644 -5876
- package/dist/index.js.map +1 -1
- package/dist/three/annotations/DOMControls.d.ts +5 -1
- package/dist/three/annotations/HtmlAnnotationMarkers.d.ts +5 -0
- package/dist/three/annotations/OverlayAnnotationMarkers.d.ts +1 -0
- package/dist/three/annotations/ThreeAnnotationController.d.ts +145 -0
- package/dist/three/annotations/ThreeAnnotationControls.d.ts +42 -0
- package/dist/three/annotations/ThreeAnnotationMarkers.d.ts +42 -0
- package/dist/three/annotations/ThreeAnnotationRenderer.d.ts +35 -0
- package/dist/three/annotations/{DPthree.d.ts → ThreeAnnotations.d.ts} +18 -27
- package/dist/three/annotations/adapter.d.ts +2 -8
- package/dist/three/annotations/annotationAnchorModel.d.ts +0 -4
- package/dist/three/annotations/index.d.ts +9 -8
- package/dist/three/annotations/lifecycleBridge.d.ts +26 -0
- package/dist/three/annotations/markerVisibilityLifecycle.d.ts +8 -7
- package/dist/three/annotations/modelObservation.d.ts +44 -0
- package/dist/three/annotations/runtime.d.ts +46 -0
- package/dist/three/annotations/runtimeAnnotationPreview.d.ts +2 -2
- package/dist/three/annotations/runtimeAnnotationPreviewSide.d.ts +0 -4
- package/dist/three/annotations/runtimeAnnotationSidePreview.d.ts +2 -1
- package/dist/three/annotations/types.d.ts +7 -8
- package/dist/three/authoring.d.ts +4 -0
- package/dist/three/authoringTypes.d.ts +7 -0
- package/dist/three/characterHost.d.ts +5 -5
- package/dist/three/editor/morphVertexPreview.d.ts +3 -2
- package/dist/three.js +1644 -5876
- package/dist/three.js.map +1 -1
- package/dist/wasm/README.md +123 -23
- package/dist/wasm/embody_wasm.d.ts +183 -77
- package/dist/wasm/embody_wasm.js +455 -2
- package/dist/wasm/embody_wasm_bg.wasm +0 -0
- package/dist/wasm/embody_wasm_bg.wasm.d.ts +108 -75
- package/dist/wasm/index.d.ts +1 -1
- package/dist/wasm.js.map +1 -1
- package/package.json +2 -2
- package/dist/three/annotations/DPthree3DMarkers.d.ts +0 -320
- package/dist/three/annotations/DPthreeCameraController.d.ts +0 -415
- package/dist/three/annotations/DPthreeHTMLMarkers.d.ts +0 -131
- package/dist/three/annotations/DPthreeMarkers.d.ts +0 -52
- package/dist/three/annotations/animationFrameTaskScheduler.d.ts +0 -18
package/README.md
CHANGED
|
@@ -33,10 +33,31 @@ The Rust core owns:
|
|
|
33
33
|
(`morphTarget` / `boneTransform` tracks) for the host mixer to schedule
|
|
34
34
|
- mesh-category routing and material profile data
|
|
35
35
|
- hair curves, hair physics, and appearance normalization
|
|
36
|
-
- annotation camera/marker
|
|
36
|
+
- annotation regions, camera gestures/flights/orbits, marker placement and visibility,
|
|
37
|
+
preview/reveal lifecycles, and humanoid template fitting
|
|
37
38
|
- profile-aware screen-space gaze geometry for eye/head AU trajectories
|
|
38
39
|
- renderer-neutral model analysis and packed live frame generation
|
|
39
40
|
|
|
41
|
+
`resolveMorphMeshSelections(profile, categories, availableNames)` resolves editor
|
|
42
|
+
mesh selections in one Rust request. It returns each requested category's effective
|
|
43
|
+
category, `hasSelection` (including explicit empty arrays), resolved loaded names,
|
|
44
|
+
and unresolved configured names. Request `viseme` for speech routing. Facial
|
|
45
|
+
categories share an authored `face` selection; body and hair stay independent.
|
|
46
|
+
Exact names take precedence over legacy mesh aliases. Consumers save concrete
|
|
47
|
+
resolved names plus unresolved names when editing, so deselecting one mesh does
|
|
48
|
+
not reactivate it through a legacy alias. This query does not change the profile.
|
|
49
|
+
|
|
50
|
+
`getAUBoneBindingStates(profile, auIds)` resolves a panel's AU bone links in one
|
|
51
|
+
Rust request and returns an object keyed by AU ID. It uses the existing
|
|
52
|
+
`getAUBoneBindingState` semantics, including custom bone names, axis/range,
|
|
53
|
+
continuum opposites and explicitly cleared bindings. Its profile input contains
|
|
54
|
+
only `auToBones`, `boneNodes`, `bonePrefix`, `boneSuffix`, `suffixPattern`,
|
|
55
|
+
`compositeRotations`, `continuumPairs` and `humanoidCharacterization`.
|
|
56
|
+
The adapter omits unrelated morph/mesh configuration, authored vertices and saved
|
|
57
|
+
clips before serialization. Mesh selection edits do not invalidate these bone
|
|
58
|
+
links; hosts can cache by those bone inputs and the requested AU IDs. This is a
|
|
59
|
+
read-only authoring query, with no rig replacement or playback effects.
|
|
60
|
+
|
|
40
61
|
The host animation library (Three `AnimationMixer`, Unity Animator, etc.) owns
|
|
41
62
|
clip playback, lerping, blending, looping, seeking, and crossfades. Rust must
|
|
42
63
|
not sample or lerp clips on the hot path.
|
|
@@ -53,45 +74,118 @@ disable the AU's mapped morphs or the viseme shapes.
|
|
|
53
74
|
The TypeScript adapter is intentionally limited to operations that require
|
|
54
75
|
Three.js objects: scene traversal, ClipIR ↔ `AnimationClip` conversion, frame
|
|
55
76
|
application, material writes, model loading/disposal, and default scene
|
|
56
|
-
construction.
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
construction. Annotation adapters capture DOM input, observe native geometry,
|
|
78
|
+
apply Rust camera/marker frames, render labels and release native resources.
|
|
79
|
+
Camera integration, region selection and marker state belong to Rust.
|
|
59
80
|
|
|
60
81
|
`ThreeFrameApplier.applyMeshMaterialConfigs(model, profile.meshes)` replays named
|
|
61
82
|
mesh visibility and material overrides when a host binds or replaces a profile.
|
|
62
83
|
It applies explicit `visible: false` and `visible: true` even without a material
|
|
63
84
|
entry, and restores render order, opacity, transparency, depth flags and blending
|
|
64
85
|
from `material`. Omitted fields leave the model's current values unchanged.
|
|
86
|
+
Replaying identical material values during a mapping edit leaves the material
|
|
87
|
+
version unchanged; render-order-only edits also avoid invalidating material programs.
|
|
65
88
|
Polymer calls this adapter during model binding and profile replacement; hosts
|
|
66
89
|
do not need a separate mesh-visibility replay loop.
|
|
67
90
|
|
|
91
|
+
`MorphVertexPreview` owns the editor's affected-vertex overlay and updates from
|
|
92
|
+
the existing Three scene render callback. It reuses position/color frame arrays,
|
|
93
|
+
retains samples only for the active hover, and releases old GPU attributes before
|
|
94
|
+
replacing differently sized geometry. Hiding or changing the hover clears its
|
|
95
|
+
sample cache; an explicitly empty mesh selection produces no preview. Applications
|
|
96
|
+
forward hover/show/hide events and dispose the overlay when its scene is released.
|
|
97
|
+
|
|
68
98
|
### Annotation runtime
|
|
69
99
|
|
|
70
|
-
`
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
`AnnotationRuntime` in `src/annotation_runtime/` owns the annotation behavior
|
|
101
|
+
and mutable state in Rust/Wasm: camera input and damping, framing and intro
|
|
102
|
+
transitions, authored/runtime regions, AU/bone target selection, laterality,
|
|
103
|
+
anchors, surface-query planning, expansion, solo, styles, visibility and layout.
|
|
104
|
+
`AnnotationLifecycle` owns preview/reveal deadlines and the effects they emit.
|
|
105
|
+
There is no TypeScript annotation state machine or OrbitControls dependency.
|
|
106
|
+
|
|
107
|
+
`ThreeAnnotationController` and the `ThreeAnnotations` convenience facade from
|
|
108
|
+
`@lovelace_lol/embody/three` provide native adapters. `ThreeAnnotationMarkers`,
|
|
109
|
+
`HtmlAnnotationMarkers`, and its `OverlayAnnotationMarkers` alias provide
|
|
110
|
+
marker-only views of the same Rust runtime. Their TypeScript code captures input,
|
|
111
|
+
serializes model observations, calls native raycasts and skinned-vertex evaluation,
|
|
112
|
+
applies packed Rust frames, creates labels, and owns renderer resources. Three
|
|
113
|
+
continues to own scene objects and GPU operations; those APIs cannot be replaced
|
|
114
|
+
by renderer-neutral Rust. Both marker styles share the same state and selection
|
|
115
|
+
rules. HTML occlusion uses Rust-planned rays evaluated by Three.
|
|
116
|
+
|
|
117
|
+
Rust fits marker endpoints before marker loading returns and on each update,
|
|
118
|
+
including additions, endpoint separation and reveal overshoot. Clipping uses
|
|
119
|
+
the displayed label dimensions and preserves the minimum leader-line length;
|
|
120
|
+
temporary overshoot clipping does not restart the reveal. Sphere sizing retains
|
|
121
|
+
the close-up scale and clamped distance scaling outside that range. Explicit
|
|
122
|
+
`markerAnchor.projectToSurface: false` also applies to `objects: ['*']` anchors.
|
|
123
|
+
HTML overlays align with the canvas rectangle inside its container, update on
|
|
124
|
+
resize/rebind, and restore borrowed parent positioning when the final view is
|
|
125
|
+
disposed. These coordinates assume axis-aligned CSS boxes without transforms.
|
|
126
|
+
|
|
127
|
+
AU morph anchors currently sample native deformed vertices during marker
|
|
128
|
+
preparation, then follow the selected object's transform. They do not yet
|
|
129
|
+
resample morph weights or skinning on subsequent frames. Animated surface
|
|
130
|
+
tracking requires cached vertex candidates and per-frame pose observations;
|
|
131
|
+
ordinary object-transform tracking does not provide that behavior.
|
|
132
|
+
|
|
133
|
+
This is a breaking replacement of the DPthree exports. Use
|
|
134
|
+
`ThreeAnnotationController.create(options)` or `ThreeAnnotations.create(options)`
|
|
135
|
+
to await Wasm initialization; synchronous constructors require an already initialized
|
|
136
|
+
core. Replace DPthree-prefixed types with `AnnotationCharacterConfig`,
|
|
137
|
+
`AnnotationRegion`, `AnnotationRegistry`, and the corresponding callback types.
|
|
138
|
+
The `controls` bridge retains `target`, `enabled`, damping/distance settings,
|
|
139
|
+
`update()`, and `change`/`start`/`end` listeners, but is not a Three `OrbitControls`
|
|
140
|
+
instance. Region and camera snapshots are observations; mutate through controller
|
|
141
|
+
methods. Explicit `undefined` fields in `updateAnnotationRegion` remove overrides.
|
|
142
|
+
`getCharacterConfig()` retains snapshot identity until configuration content or
|
|
143
|
+
the model changes; selection, visibility and camera input do not replace it.
|
|
144
|
+
Call `clearModel()` before releasing a removed model's native resources. The
|
|
145
|
+
controller retains renderer rebinding, canvas input reconnect and resource-drain
|
|
146
|
+
support through the scene's rendering controller.
|
|
147
|
+
Runtime preview region IDs retain the `runtime:annotation:` namespace.
|
|
148
|
+
|
|
149
|
+
When the annotation controller owns the renderer loop, it advances registered
|
|
150
|
+
native character mixers before observing annotation transforms and drawing the
|
|
151
|
+
scene. The first frame establishes the timer origin; skipped asynchronous draws
|
|
152
|
+
do not accumulate playback time. External render loops use the existing
|
|
153
|
+
`createScenePlaybackFrame` integration to advance character playback.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { ThreeAnnotations } from '@lovelace_lol/embody/three';
|
|
157
|
+
|
|
158
|
+
const annotations = await ThreeAnnotations.create({ scene, camera, domElement: canvas });
|
|
159
|
+
annotations.setModel(model);
|
|
160
|
+
await annotations.loadCharacter({ characterId: 'character', profilePresetId: 'cc4' });
|
|
161
|
+
// Host-owned render loop: call annotations.update() before renderer.render(...).
|
|
162
|
+
```
|
|
77
163
|
|
|
78
164
|
Applications pass `AnnotationCharacterConfig`; storage, agency, editor and
|
|
79
165
|
character-asset metadata remain host concerns. `loadRegions` defaults to
|
|
80
166
|
`resolveAnnotationCharacterConfig`, which resolves annotation and AU mapping
|
|
81
167
|
fields from an Embody preset without serializing unrelated host metadata.
|
|
82
168
|
An optional `resolveCharacterConfig` callback supports host profile intake.
|
|
169
|
+
`prepareRegionsForReveal` defers native marker construction until the first
|
|
170
|
+
`setMarkersVisible(true)` call. Later visibility changes reuse those resources;
|
|
171
|
+
Rust's loaded state resets when the model or configuration is replaced.
|
|
83
172
|
`prepareRegionsAndMarkersForReveal` accepts an already-resolved profile and
|
|
84
173
|
prepares native surface queries while the model pose is still stable.
|
|
85
174
|
Initial queries yield to a browser paint between meshes once a 4 ms slice is
|
|
86
|
-
spent. Each native mesh raycast is indivisible;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
175
|
+
spent. Each native mesh raycast is indivisible; slicing does not reduce total
|
|
176
|
+
raycast CPU time. Interactive edits retain synchronous queries so a marker samples
|
|
177
|
+
one pose. Rust generations reject stale profile, surface and reveal completions
|
|
178
|
+
after replacement, clearing, region edits or disposal. Camera requests settle when
|
|
179
|
+
completed or cancelled, including controller disposal.
|
|
180
|
+
|
|
181
|
+
The direct Wasm boundary uses JSON commands/snapshots for configuration and
|
|
182
|
+
primitive model observations with stable object IDs. Frames, vertex candidates,
|
|
183
|
+
transform observations and ray results use packed typed arrays; coordinates are
|
|
184
|
+
world-space, camera/visibility angles are degrees, durations are milliseconds,
|
|
185
|
+
and viewport dimensions are CSS pixels. The layouts and operations are maintained
|
|
186
|
+
in [the Rust runtime](src/annotation_runtime/mod.rs) and
|
|
187
|
+
[marker frames](src/annotation_runtime/markers.rs); generated Wasm declarations
|
|
188
|
+
remain the ABI type source. IDs are scoped to one model lifetime.
|
|
95
189
|
|
|
96
190
|
For first reveal, call `controller.prepareModelForRender(model, { signal })`
|
|
97
191
|
from the existing `beforeReveal` callback (or directly before attaching the
|
|
@@ -103,8 +197,14 @@ it settles, even after `controller.dispose()`. This prepares visible variants,
|
|
|
103
197
|
not every future hidden material or animation state. See the
|
|
104
198
|
[model readiness contract](docs/SCENE_READINESS.md#model-readiness).
|
|
105
199
|
|
|
106
|
-
`createMarkerVisibilityLifecycle`
|
|
107
|
-
`
|
|
200
|
+
`createMarkerVisibilityLifecycle` and `createRuntimeAnnotationPreviewLifecycle`
|
|
201
|
+
transport host events to `AnnotationLifecycle`; browser timers only wake Rust at
|
|
202
|
+
its next deadline. Factories can queue input while Wasm initializes; `ready`
|
|
203
|
+
reports the current initialization attempt. After an initialization failure,
|
|
204
|
+
the next command retries or adopts a core initialized by another scene. Failed
|
|
205
|
+
attempts discard their queued input. `dispose()` also discards pending input,
|
|
206
|
+
cancels timers and frees the runtime, so cleanup before readiness cannot replay
|
|
207
|
+
callbacks. Later calls create a fresh runtime, preserving host effect-replay cleanup.
|
|
108
208
|
React hosts forward user events and subscribe to controller state. They do not
|
|
109
209
|
need local copies of the camera, marker, placement or timer algorithms.
|
|
110
210
|
The convenience facade delegates to one controller-owned marker layer.
|
|
@@ -177,7 +277,7 @@ controller immediately. `ready` reports the initial attempt; failure retains the
|
|
|
177
277
|
controller for recovery through `setSettings`. `getSettings`, `getSnapshot` and
|
|
178
278
|
`subscribe` expose the requested preference, actual backend, status and errors.
|
|
179
279
|
Live changes prepare and replace only backend resources, preserving the character,
|
|
180
|
-
scene, camera, lighting and marker state. `
|
|
280
|
+
scene, camera, lighting and marker state. `ThreeAnnotationController({ rendering,
|
|
181
281
|
scene, camera, domElement: container })` retargets its existing loop and controls;
|
|
182
282
|
hosts persist settings and display status without recreating the scene.
|
|
183
283
|
|