@hackbuild/avatar-host 0.1.5 → 0.1.7
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 +173 -206
- package/dist/avatar-host.iife.js +29 -1
- package/dist/body.d.ts +2 -0
- package/dist/body.js +1 -0
- package/dist/drop.d.ts +1 -0
- package/dist/element.d.ts +1 -0
- package/dist/environment.d.ts +4 -0
- package/dist/environment.js +1 -0
- package/dist/follow.d.ts +2 -0
- package/dist/follow.js +1 -0
- package/dist/host.d.ts +4 -0
- package/dist/host.js +1 -0
- package/dist/load.d.ts +1 -0
- package/dist/loop.d.ts +3 -0
- package/dist/loop.js +1 -0
- package/dist/placeholder.d.ts +1 -0
- package/dist/portrait.d.ts +3 -0
- package/dist/source.d.ts +3 -0
- package/dist/stage.d.ts +5 -0
- package/dist/stage.js +2 -0
- package/dist/thumb-queue.d.ts +2 -0
- package/dist/thumb-queue.js +1 -0
- package/dist/thumbs.d.ts +2 -0
- package/llms.md +742 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,239 +1,206 @@
|
|
|
1
1
|
# @hackbuild/avatar-host
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
discarded and never shown. One runtime per adapter key, made on first
|
|
17
|
-
use (the import for a format happens once); a failed create is
|
|
18
|
-
forgotten so the next show tries again; `exclusive` destroys the other
|
|
19
|
-
runtimes on a switch; a source's `release` runs once whether its load
|
|
20
|
-
wins, loses or throws.
|
|
21
|
-
- `sourceFromFiles(files)`: the first `.vrm`, `.glb`, `.gltf` or `.fbx` of
|
|
22
|
-
a drop, with a resolver that finds referenced files by path below the
|
|
23
|
-
model's folder, then by file name anywhere in the drop, ignoring case.
|
|
24
|
-
Misses are listed; object URLs are freed by `release`. A `.pmx` drop
|
|
25
|
-
reads "this file is a pmx. open it with the mmd loader of the avatar package."
|
|
26
|
-
- `droppedFiles(dataTransfer)`: walks dropped folders and keeps each
|
|
27
|
-
file's relative path.
|
|
28
|
-
- `StageLoop`: the pause reasons (`hidden`, `offscreen`, `inactive`,
|
|
29
|
-
`covered`, `lost`, `paused`), one fixed step (1/60 s, proposed) as the
|
|
30
|
-
first delta after any stop, and draw on change only under reduced
|
|
31
|
-
motion, while a clip, a mouth or a finger on the camera still runs it.
|
|
32
|
-
- `bodyError(e)`: copy for the person from a load failure ("this model has
|
|
33
|
-
no humanoid rig the stage can map. missing bones: hips.").
|
|
34
|
-
|
|
35
|
-
`/three`:
|
|
36
|
-
|
|
37
|
-
- `AvatarStage(container, opts)`: renderer sized to its container by a
|
|
38
|
-
`ResizeObserver` (never the window), pixel ratio capped at 2 (proposed),
|
|
39
|
-
an `IntersectionObserver` and `visibilitychange` for the pause rules,
|
|
40
|
-
orbit controls (one finger orbits, two pinch and pan), plain lights.
|
|
41
|
-
`show`, `showPlaceholder`, `showAvatar`; `play`, `pause`, `setActive`,
|
|
42
|
-
`setCovered`; `zoomBy`, `resetView`, `lookAtView`, `resize`, `snapshot`
|
|
43
|
-
(one frame stepped, rendered and read in the same task, so no
|
|
44
|
-
`preserveDrawingBuffer`); `dispose` frees the body, calls
|
|
45
|
-
`renderer.dispose()` and loses the context. A lost context shows a
|
|
46
|
-
button with "the 3d view was lost. press to restore." Events through
|
|
47
|
-
`on(type, fn)`: `loaded` (the body and its capability list), `failed`
|
|
48
|
-
(copy and cause), `stats` (fps from the loop clock, draw calls,
|
|
49
|
-
triangles, buffer size, pixel ratio), `state`, `lost`, `restored`.
|
|
50
|
-
- `EnvironmentSlot` as `stage.environment`, and `stage.showEnvironment(id
|
|
51
|
-
| { preset, resolve } | null)`: a lit scene from `@hackbuild/environment`
|
|
52
|
-
around the body, imported on first use. Requests are ticketed: a slow
|
|
53
|
-
load a newer one overtook is disposed and never attached; the same id
|
|
54
|
-
again does nothing. The swap disposes the old scene first, turns on the
|
|
55
|
-
shadow map with the body casting, hides the plain lights and caps the
|
|
56
|
-
pixel ratio at 1.5 (vendor) while a scene shows. A missing file emits
|
|
57
|
-
`failed` with the environment copy and keeps the current scene. The
|
|
58
|
-
studio needs no file; the element takes it as the `environment`
|
|
59
|
-
attribute.
|
|
60
|
-
- `Body`: the body surface and the frame order. Each frame the presence
|
|
61
|
-
`ClipPlayer` writes every bone (an idle of the rest pose, a body layer
|
|
62
|
-
and an upper layer), `HeadLevel` lifts a low clip head, `applyPose`,
|
|
63
|
-
`GazeController` through `applyGaze`, then the presence `Face` writes
|
|
64
|
-
every expression weight in one pass (moods eased, clip face tracks, the
|
|
65
|
-
gaze controller's lid, `LipSync` mouth shapes through `drive` on
|
|
66
|
-
`face.mouth`), then `avatar.update(dt)`. With no idle clip the base
|
|
67
|
-
layer is the rest stance, arms relaxed at the sides (`stance: "rest"`
|
|
68
|
-
keeps the loaded pose); a quiet face rests at a slight smile
|
|
69
|
-
(`restingFace: false` for neutral). `play(clip | animation | name)`,
|
|
70
|
-
`stop`, `clipOf`, `setExpression`, `setGazeMode`, `setPartVisible`,
|
|
71
|
-
`lip` for speech events. Gaze turns on by itself when the head rests
|
|
72
|
-
upright and facing +Z (VRM bodies and the placeholder); for VRM the eyes
|
|
73
|
-
go through three-vrm's look at.
|
|
74
|
-
- `FollowCamera`: the target eases after the body's centre plus the
|
|
75
|
-
person's pan, with a dead zone of 6 percent of the body's height; the
|
|
76
|
-
distance eases to fit the pose, pulls back from the first frame a pose
|
|
77
|
-
outgrows the view and comes closer only once 12 percent too far; a hand
|
|
78
|
-
zoom is left alone (rate 3, dead zone 0.06, slack 0.12, margin 1.12,
|
|
79
|
-
vendor, all options). `follow: { follow: false }` in the stage options,
|
|
80
|
-
or `stage.setFollow(false)` at any time, turns following off; the
|
|
81
|
-
camera then moves only by hand or `resetView`.
|
|
82
|
-
- `loadBody` and `bodyAdapters`: the scene level loader. A dropped
|
|
83
|
-
model's references go through the source's resolver, and the load waits
|
|
84
|
-
for every texture the loader started before it resolves. The rig wasm
|
|
85
|
-
loads once, on the first body.
|
|
86
|
-
- `placeholderBody()`: a mannequin of capsules on a humanoid skeleton,
|
|
87
|
-
built in code, head top near 1.74 m (computed). No asset file.
|
|
88
|
-
- `/thumbs`: previews drawn in the background. `clipThumbs({ save })`
|
|
89
|
-
poses one clay figure (the placeholder body, or a figure you pass) at
|
|
90
|
-
each clip's most telling frame, the sampled frame between 10 and 90
|
|
91
|
-
percent of the clip furthest from rest by the limbs and trunk
|
|
92
|
-
(`tellingTime`), into a 192 px square. `avatarThumbs({ save })` loads
|
|
93
|
-
each body source and draws it at rest, 240 by 320 px. Both run on
|
|
94
|
-
`ThumbQueue`: one item at a time on one renderer, urgent items first,
|
|
95
|
-
each item tried once per session, a rest between items as long as the
|
|
96
|
-
last render within 40 to 400 ms, one task yield instead in a hidden tab,
|
|
97
|
-
a lost context rebuilds the renderer, and the renderer lingers 20 s after
|
|
98
|
-
the queue empties (vendor figures, all options). `save(id, blob)` gets a
|
|
99
|
-
PNG Blob; `failed(id, reason)` names why an item gave none.
|
|
100
|
-
- `defineAvatarHost(tag?, opts?)`: defines `hb-avatar-host`. Attributes
|
|
101
|
-
`src` (a model URL; the placeholder shows without one), `environment`
|
|
102
|
-
(a scene id), `paused`,
|
|
103
|
-
`inactive`, `covered`. Stage events arrive as DOM events of the same
|
|
104
|
-
name with the stage event as `detail`. Nothing is defined on import.
|
|
105
|
-
|
|
106
|
-
Every random draw comes from an injected `Rng` (default
|
|
107
|
-
`seededRng("avatar-host")`); the package reads no wall clock.
|
|
3
|
+
Host a character on a three.js stage in any container, with a follow camera, the presence frame order and a loop that pauses when nobody can see it.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hackbuild/avatar-host) [](../../LICENSE)  
|
|
6
|
+
|
|
7
|
+
Browser status: no real VRM, GLB or FBX file has been shown on this stage in a browser yet; the browser checks ran on the placeholder body built in code.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
- Gives you a stage in any element: a renderer sized to its container, orbit controls, plain lights or a lit scene, and a `hb-avatar-host` custom element for pages with no framework.
|
|
12
|
+
- Loads bodies through `@hackbuild/avatar` with ticketed loads, so a slow load that a newer one overtook is freed and never shown.
|
|
13
|
+
- Runs one frame order for every body: clip player, head level, pose, gaze, face with lid and mouth, then the avatar update.
|
|
14
|
+
- Frames the posed body with a camera that eases, holds still inside a dead zone and leaves a hand zoom alone.
|
|
15
|
+
- Stops the loop while the page is hidden, the stage is off screen, inactive or covered, or the 3D context is lost, and draws previews of clips and avatars in the background.
|
|
108
16
|
|
|
109
17
|
## Install
|
|
110
18
|
|
|
111
|
-
|
|
19
|
+
```sh
|
|
20
|
+
npm install @hackbuild/avatar-host @hackbuild/avatar three @pixiv/three-vrm
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
It depends on `@hackbuild/avatar`, `@hackbuild/presence`, `@hackbuild/lipsync`, `@hackbuild/environment`, `@hackbuild/organic` and `@hackbuild/rig`, which install with it. `three` is an optional peer needed by `/three` and `/thumbs`. `@pixiv/three-vrm` is needed only to show VRM files, and is imported on the first `.vrm` through the hook you pass.
|
|
112
24
|
|
|
113
|
-
|
|
25
|
+
| subpath | needs | pin |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `@hackbuild/avatar-host` | nothing; the ticketed host, drop sources, the stage loop and failure copy | none |
|
|
28
|
+
| `@hackbuild/avatar-host/three` | `three` (optional peer), WebGL | 0.186.1 or later |
|
|
29
|
+
| `@hackbuild/avatar-host/thumbs` | `three`, WebGL | 0.186.1 or later |
|
|
30
|
+
| `@hackbuild/avatar-host/iife` | a page with a `THREE` global; leaves out three-vrm | none |
|
|
114
31
|
|
|
115
|
-
##
|
|
32
|
+
## Quick start
|
|
116
33
|
|
|
117
34
|
```ts
|
|
118
|
-
import {
|
|
119
|
-
import { droppedFiles } from "@hackbuild/avatar-host";
|
|
35
|
+
import { AvatarStage } from "@hackbuild/avatar-host/three";
|
|
120
36
|
|
|
121
|
-
|
|
122
|
-
|
|
37
|
+
// the stage sizes itself to its container and pauses while hidden or off screen
|
|
38
|
+
const box = Object.assign(document.createElement("div"), { style: "height: 70vh" });
|
|
39
|
+
const input = Object.assign(document.createElement("input"), { type: "file", multiple: true });
|
|
40
|
+
document.body.append(input, box);
|
|
41
|
+
const stage = new AvatarStage(box, {
|
|
42
|
+
// three-vrm is imported on the first .vrm only
|
|
123
43
|
vrm: () => import("@hackbuild/avatar/vrm").then((m) => m.vrmHook()),
|
|
124
44
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
45
|
+
stage.on("failed", (e) => console.warn(e.message));
|
|
46
|
+
stage.on("stats", (e) => console.log(e.stats.fps.toFixed(0), "fps"));
|
|
47
|
+
|
|
48
|
+
// the placeholder body is built in code; pick a .vrm, .glb or .fbx (and its textures) to swap it
|
|
49
|
+
stage.showPlaceholder().setExpression("happy", 0.5);
|
|
50
|
+
input.onchange = async () => {
|
|
51
|
+
const body = await stage.show([...(input.files ?? [])]);
|
|
52
|
+
body?.setGazeMode("listen");
|
|
53
|
+
};
|
|
129
54
|
```
|
|
130
55
|
|
|
131
|
-
|
|
56
|
+
## Live example
|
|
132
57
|
|
|
133
|
-
|
|
134
|
-
|
|
58
|
+
The demo page shows the placeholder or a VRM, GLB or FBX you drop, with the follow camera and the pause rules: [hackbuild-motion/avatar-host](https://hackbuild.github.io/hackbuild-motion/avatar-host/). The suite's avatar screen runs on this stage: [hackbuild-suite avatar](https://hackbuild.github.io/hackbuild-suite/#/motion/avatar).
|
|
59
|
+
|
|
60
|
+
## Concepts
|
|
61
|
+
|
|
62
|
+
### the stage and its loop
|
|
135
63
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
body.lip.push(speechEvents);
|
|
64
|
+
`AvatarStage(container, opts)` sizes the renderer to its container with a `ResizeObserver`, never the window, and caps the pixel ratio at 2. One `setAnimationLoop` runs the frame. It stops for each pause reason (`hidden`, `offscreen`, `inactive`, `covered`, `lost`, `paused`) and takes one fixed step of 1/60 s as the first delta after a stop. Under reduced motion it draws only while something moves: a clip, a mouth, or a finger on the camera. Tell the stage when your route is inactive or a sheet covers it:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
stage.setActive(routeIsShown);
|
|
141
68
|
stage.setCovered(sheetOpen);
|
|
142
|
-
stage.dispose();
|
|
143
69
|
```
|
|
144
70
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
a
|
|
71
|
+
### ticketed loads
|
|
72
|
+
|
|
73
|
+
`stage.show(source)` resolves to the body, or to null when a later show overtook it; the overtaken body is freed and never shown. A source is a URL, a list of dropped files or a `BodySource`. Files a model references resolve by path below the model's folder, then by file name anywhere in the drop, ignoring case. `droppedFiles(dataTransfer)` walks dropped folders and keeps each file's relative path.
|
|
74
|
+
|
|
75
|
+
### the frame order
|
|
76
|
+
|
|
77
|
+
Each frame the presence `ClipPlayer` writes every bone, `HeadLevel` lifts a head a clip holds low, the pose goes onto the bones, gaze goes onto neck, head and eyes, the presence `Face` writes every expression weight (mood, clip face tracks, the lid, `LipSync` mouth shapes), and then `avatar.update(dt)` runs. With no idle clip the base is the rest stance with the arms down. Gaze turns on by itself when the head rests upright and facing +Z.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const body = stage.showPlaceholder();
|
|
81
|
+
body.play(waveClip, { layer: "upper" });
|
|
82
|
+
body.lip.push(speechEvents); // timed words or visemes from a speech engine
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### the follow camera
|
|
86
|
+
|
|
87
|
+
The camera target eases after the body's centre plus your pan, holds still while the body moves less than 6 percent of its height, pulls back on the first frame a pose outgrows the view and comes closer only once 12 percent too far. A zoom the person picked is left alone. `stage.setFollow(false)` stops following.
|
|
88
|
+
|
|
89
|
+
### lit scenes
|
|
148
90
|
|
|
149
|
-
|
|
91
|
+
`stage.showEnvironment("studio")` puts a scene from `@hackbuild/environment` around the body, imported on first use. Requests are ticketed like bodies; a missing file emits `failed` and keeps the current scene. The studio needs no file; other presets take a `resolve` for their files. While a scene shows, the shadow map is on and the pixel ratio caps at 1.5.
|
|
150
92
|
|
|
151
|
-
|
|
152
|
-
npx vitest run packages/avatar-host
|
|
93
|
+
### the custom element
|
|
153
94
|
|
|
154
|
-
|
|
95
|
+
`defineAvatarHost(tag?, opts?)` defines `hb-avatar-host` with the attributes `src`, `environment`, `paused`, `inactive` and `covered`. Stage events arrive as DOM events of the same name with the stage event as `detail`. Nothing is defined on import.
|
|
96
|
+
|
|
97
|
+
### previews in the background
|
|
98
|
+
|
|
99
|
+
`clipThumbs({ save })` poses one clay figure at each clip's most telling frame into a 192 px square, and `avatarThumbs({ save })` draws each body at rest at 240 by 320 px. Both run one item at a time on one renderer, urgent items first, each item tried once per session, with a rest between items as long as the last render.
|
|
100
|
+
|
|
101
|
+
## API overview
|
|
102
|
+
|
|
103
|
+
| export | what it does |
|
|
104
|
+
|---|---|
|
|
105
|
+
| [`AvatarStage`](../../docs/api/avatar-host/three.md#avatarstage) | the stage: renderer, camera, loop, environment and the body it shows |
|
|
106
|
+
| [`Body`](../../docs/api/avatar-host/three.md#body) | a shown character driven in the presence frame order |
|
|
107
|
+
| [`FollowCamera`](../../docs/api/avatar-host/three.md#followcamera) | keeps the posed body framed |
|
|
108
|
+
| [`EnvironmentSlot`](../../docs/api/avatar-host/three.md#environmentslot) | one lit scene at a time, ticketed |
|
|
109
|
+
| [`defineAvatarHost`](../../docs/api/avatar-host/three.md#defineavatarhost) | define the `hb-avatar-host` element |
|
|
110
|
+
| [`placeholderBody`](../../docs/api/avatar-host/three.md#placeholderbody) | a mannequin built in code, no asset file |
|
|
111
|
+
| [`loadBody`](../../docs/api/avatar-host/three.md#loadbody) | load a body source through `@hackbuild/avatar` |
|
|
112
|
+
| [`StageEvent`](../../docs/api/avatar-host/three.md#stageevent) | loaded, failed, stats, state, lost and restored |
|
|
113
|
+
| [`AvatarHost`](../../docs/api/avatar-host/index.md#avatarhost) | ticketed loads through adapters, with no three.js |
|
|
114
|
+
| [`StageLoop`](../../docs/api/avatar-host/index.md#stageloop) | the loop and its pause reasons |
|
|
115
|
+
| [`sourceFromFiles`](../../docs/api/avatar-host/index.md#sourcefromfiles) | the model of a drop and a resolver for its files |
|
|
116
|
+
| [`droppedFiles`](../../docs/api/avatar-host/index.md#droppedfiles) | walk a drop's folders, keeping relative paths |
|
|
117
|
+
| [`bodyError`](../../docs/api/avatar-host/index.md#bodyerror) | a line for the person from a load failure |
|
|
118
|
+
| [`clipThumbs`](../../docs/api/avatar-host/thumbs.md#clipthumbs) | clip previews on a clay figure |
|
|
119
|
+
| [`avatarThumbs`](../../docs/api/avatar-host/thumbs.md#avatarthumbs) | avatar previews at rest |
|
|
120
|
+
|
|
121
|
+
The full reference is in [docs/api/avatar-host](../../docs/api/avatar-host/README.md).
|
|
122
|
+
|
|
123
|
+
## Models and weights
|
|
124
|
+
|
|
125
|
+
No models ship with this package. The placeholder body is built in code. Any other body is a URL or a file you give, loaded through `@hackbuild/avatar`, and keeps its own licence; for a VRM, `@hackbuild/avatar` reads it from the file's metadata.
|
|
126
|
+
|
|
127
|
+
| source | id | size | licence | loads from |
|
|
128
|
+
|---|---|---|---|---|
|
|
129
|
+
| placeholder body | `placeholderBody()` | built in code, head top near 1.74 m (computed) | MIT, part of this package | code |
|
|
130
|
+
| a VRM, GLB, glTF or FBX you give | none | unknown | the file's own; VRM metadata when present | the URL or files you pass |
|
|
131
|
+
| studio scene | `studio` | built in code | MIT | code |
|
|
132
|
+
| room, cafe and outdoors scenes | preset ids | unknown | the files' own | the files your `resolve` gives |
|
|
133
|
+
|
|
134
|
+
## Browser support
|
|
135
|
+
|
|
136
|
+
| part | needs | Chrome | Safari | Firefox | phone |
|
|
137
|
+
|---|---|---|---|---|---|
|
|
138
|
+
| main entry | ES2022 | yes (measured in tests) | yes (inferred) | yes (inferred) | yes (inferred) |
|
|
139
|
+
| stage, body, camera | WebGL, `ResizeObserver`, `IntersectionObserver` | yes (measured, headless) | unknown | unknown | unknown |
|
|
140
|
+
| previews | WebGL | unknown | unknown | unknown | unknown |
|
|
141
|
+
| single file build | a classic script, rig wasm inlined, file:// included | yes (inferred) | unknown | unknown | unknown |
|
|
142
|
+
|
|
143
|
+
Without WebGL the stage cannot start, and the `failed` event carries `no webgl here. the 3d view cannot start on this device.` A lost 3D context shows a button with `LOST_COPY` and restores on a press.
|
|
144
|
+
|
|
145
|
+
## Errors and troubleshooting
|
|
146
|
+
|
|
147
|
+
Load failures do not throw from `show`: the stage emits `failed` with a line for the person (from `bodyError`) and the raw error as `cause`. These are thrown:
|
|
148
|
+
|
|
149
|
+
| message | cause | what to do |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `this file is a pmx. open it with the mmd loader of the avatar package.` | `sourceFromFiles` got a PMX or PMD | load it with `loadMmd` from `@hackbuild/avatar/mmd`, then `stage.showAvatar` |
|
|
152
|
+
| `a <ext> file is an animation. drop a body: a .vrm, .glb, .gltf or .fbx.` | the drop held only a clip file | drop a model file |
|
|
153
|
+
| `this drop has no model. drop a .vrm, .glb, .gltf or .fbx file.` | no model file in the drop | drop a model file |
|
|
154
|
+
| `no adapter for <kind> files.` | `AvatarHost.show` got a kind with no adapter | add an adapter for that kind |
|
|
155
|
+
| `this clip has <n> bones and the body <m>. build it with clipOf or over body.names.` | `body.play` got a clip built over another bone list | build the clip with `body.clipOf` |
|
|
156
|
+
| `the clip moves no bone of this figure.` | a clip preview had no track for the figure's bones | check the clip's bone names; it reaches `failed(id, reason)` |
|
|
157
|
+
|
|
158
|
+
The `failed` event lines include `this model has no humanoid rig the stage can map. missing bones: <bones>.`, `the model did not download (http <status>). check the url.` and `the model did not load. its file may be damaged or of a kind the stage does not read.`
|
|
159
|
+
|
|
160
|
+
## Works with
|
|
161
|
+
|
|
162
|
+
- [@hackbuild/avatar](../avatar/README.md) loads and repairs the bodies the stage shows.
|
|
163
|
+
- [@hackbuild/presence](../presence/README.md) gives the clip player, gaze and face of the frame order.
|
|
164
|
+
- [@hackbuild/lipsync](../lipsync/README.md) turns speech timing into the mouth shapes behind `body.lip`.
|
|
165
|
+
- [@hackbuild/environment](../environment/README.md) builds the lit scenes of `showEnvironment`.
|
|
166
|
+
- [@hackbuild/motion-views](../motion-views/README.md) wraps this stage as the character stage view for Vue and custom elements.
|
|
167
|
+
|
|
168
|
+
## Changelog and licences
|
|
169
|
+
|
|
170
|
+
Changes are in the repository [CHANGELOG](../../CHANGELOG.md). Code is MIT ([LICENSE](../../LICENSE)); this README is CC-BY-4.0 with its code samples also MIT. No models ship here; each body you load keeps its own licence. `@pixiv/three-vrm` is MIT.
|
|
155
171
|
|
|
156
172
|
## What is verified, and what is not
|
|
157
173
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
ratio caps at 1.5 with a scene.
|
|
181
|
-
- 2026-11-24, headless Chrome on the example page: the studio scene under
|
|
182
|
-
the placeholder turns on the shadow map with 24 meshes casting and the
|
|
183
|
-
ground taking it, 49 draw calls against 24 plain, and the plain lights
|
|
184
|
-
come back after it (measured). The screenshot was looked at by the
|
|
185
|
-
builder: a shadow falls on the ground beside the body.
|
|
186
|
-
- 2026-11-24: `npx vitest run packages/avatar-host` passed 28 of 28
|
|
187
|
-
tests (counted): two overlapping shows resolve null for the first and
|
|
188
|
-
never show it; a failed create is retried on the next show; `exclusive`
|
|
189
|
-
destroys the other runtime; `release` runs once when a load wins, loses
|
|
190
|
-
or throws; the two step texture lookup by path, then by name in another
|
|
191
|
-
case, and a miss; a nested folder walk keeps relative paths; the loop
|
|
192
|
-
draws 0 frames while hidden, takes one fixed step after a pause of 89 s,
|
|
193
|
-
and draws on change only under reduced motion; the follow camera stays
|
|
194
|
-
still under the dead zone, pulls back on the first frame, comes closer
|
|
195
|
-
only past the slack and leaves a hand zoom alone; the placeholder stands
|
|
196
|
-
in the normalized space; a clip plays over rest and hands back; gaze
|
|
197
|
-
turns the head toward a target on the left; a generated GLB loads
|
|
198
|
-
through the host into the normalized space and is freed on dispose.
|
|
199
|
-
- 2026-11-24, headless Chrome on the example page: 0 frames drawn in 1 s
|
|
200
|
-
with the page hidden (hidden simulated by overriding `document.hidden`),
|
|
201
|
-
the canvas 320 css px in a 320 px host, 24 geometries before and after
|
|
202
|
-
two swaps, a superseded show resolved null, a lost context showed the
|
|
203
|
-
restore line and came back on a press, 60 fps with a wave playing on the
|
|
204
|
-
placeholder (measured).
|
|
205
|
-
|
|
206
|
-
### Not verified by anything
|
|
207
|
-
|
|
208
|
-
- No real VRM, GLB or FBX file has been shown on this stage in a browser.
|
|
209
|
-
The VRM eye path through three-vrm's look at (yaw and pitch signs) is
|
|
210
|
-
unchecked.
|
|
211
|
-
- Gaze on a model whose head does not rest upright is left off; such a
|
|
212
|
-
body gets clips, mouth and camera only.
|
|
213
|
-
- A real tab switch, a real GPU reset, a pixel ratio 2 screen and reduced
|
|
214
|
-
motion in a browser have not been run.
|
|
215
|
-
- Nobody has looked at the follow camera or gaze at frame rate on a
|
|
216
|
-
loaded model.
|
|
217
|
-
- The room, cafe and outdoors scenes have not been shown on this stage;
|
|
218
|
-
their files are not in the repository. The pixel ratio cap was measured
|
|
219
|
-
at a device ratio of 1 only.
|
|
220
|
-
- No thumbnail has been drawn in a browser: `ClipPortrait` and
|
|
221
|
-
`AvatarPortrait` need WebGL and have not rendered an image yet. The
|
|
222
|
-
face
|
|
223
|
-
driver has not run on a real face in a browser.
|
|
174
|
+
| check | result |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `npx vitest run packages/avatar-host` | 42 of 42 tests pass (counted) |
|
|
177
|
+
| ticketed host | two overlapping shows resolve null for the first and never show it; a failed create is retried; `exclusive` destroys the other runtime; `release` runs once when a load wins, loses or throws |
|
|
178
|
+
| drop sources | path then name lookup in another case, and a miss; a nested folder walk keeps relative paths |
|
|
179
|
+
| stage loop | 0 frames while hidden; one fixed step after a pause of 89 s; draw on change only under reduced motion |
|
|
180
|
+
| follow camera | still under the dead zone; pulls back on the first frame; closer only past the slack; a hand zoom is left alone |
|
|
181
|
+
| body | the placeholder stands in the normalized space; a clip plays over rest and hands back to the rest stance; gaze turns the head toward a target; a held mood reaches 0.63 in 1/8 s (computed) |
|
|
182
|
+
| a GLB built in the test | loads through the host into the normalized space and is freed on dispose |
|
|
183
|
+
| environment slot | an overtaken scene load is disposed and never attached; the same id loads once; a failed load keeps the scene; the pixel ratio caps at 1.5 with a scene |
|
|
184
|
+
| previews, with a stand in renderer | urgent items jump the queue; each item is tried once; the renderer is freed 20 s after the queue empties; a lost context rebuilds; the rest after a 250 ms render is 250 ms; the telling frame of a wave lands within half a sample of 0.6 s (computed) |
|
|
185
|
+
| headless Chrome, the demo page | 0 frames in 1 s with the page hidden (simulated); canvas 320 css px in a 320 px host; 24 geometries before and after two swaps; a lost context showed the restore line and came back; 60 fps with a wave on the placeholder (measured) |
|
|
186
|
+
| headless Chrome, studio scene | shadow map on with 24 meshes casting, 49 draw calls against 24 plain, plain lights back after it (measured); a shadow falls beside the body in the screenshot |
|
|
187
|
+
|
|
188
|
+
Not verified by anything:
|
|
189
|
+
|
|
190
|
+
- No real VRM, GLB or FBX file has been shown on this stage in a browser. The VRM eye path through three-vrm's look at is unchecked.
|
|
191
|
+
- Gaze stays off on a model whose head does not rest upright; such a body gets clips, mouth and camera only.
|
|
192
|
+
- A real tab switch, a real GPU reset, a pixel ratio 2 screen and reduced motion have not been run in a browser; the pixel ratio cap was measured at a device ratio of 1 only.
|
|
193
|
+
- Nobody has looked at the follow camera or gaze at frame rate on a loaded model, or the face driver on a real face.
|
|
194
|
+
- The room, cafe and outdoors scenes have not been shown on this stage; their files are not in the repository.
|
|
195
|
+
- No preview has been drawn in a browser: `ClipPortrait` and `AvatarPortrait` need WebGL and have not rendered an image yet.
|
|
224
196
|
|
|
225
197
|
## Size budget
|
|
226
198
|
|
|
227
199
|
| file | gzip (measured) | ceiling |
|
|
228
200
|
|---|---|---|
|
|
229
|
-
| `dist/index.js` (main entry, imports external) | 3,
|
|
230
|
-
| `dist/avatar-host.iife.js` (single file build) |
|
|
201
|
+
| `dist/index.js` (main entry, imports external) | 3,840 bytes | 4,032 bytes |
|
|
202
|
+
| `dist/avatar-host.iife.js` (single file build) | 196,986 bytes | 206,835 bytes |
|
|
231
203
|
|
|
232
|
-
Measured 2026-11-
|
|
204
|
+
Measured 2026-11-26 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
|
|
233
205
|
tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
|
|
234
206
|
5 percent from its row.
|
|
235
|
-
|
|
236
|
-
## Licence
|
|
237
|
-
|
|
238
|
-
Code MIT (`LICENSE` in this package and at the repository root). This
|
|
239
|
-
README is CC-BY-4.0, its code samples also MIT.
|
package/dist/avatar-host.iife.js
CHANGED
|
@@ -20,6 +20,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
20
20
|
return target;
|
|
21
21
|
};
|
|
22
22
|
// src/host.ts
|
|
23
|
+
/** Shows one source at a time through adapters: each show takes a ticket, a load that a later show overtook is discarded, and runtimes are shared or destroyed by key. */
|
|
23
24
|
var AvatarHost = class {
|
|
24
25
|
opts;
|
|
25
26
|
slots = /* @__PURE__ */ new Map();
|
|
@@ -223,6 +224,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
223
224
|
return filesFromEntries(entries);
|
|
224
225
|
}
|
|
225
226
|
// src/loop.ts
|
|
227
|
+
/** The render loop of a stage: runs frames on the renderer's animation loop and stops while the page is hidden, off screen, covered, lost or paused. */
|
|
226
228
|
var StageLoop = class {
|
|
227
229
|
opts;
|
|
228
230
|
/** Frames drawn since the loop was made. */
|
|
@@ -1468,13 +1470,16 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
1468
1470
|
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1469
1471
|
};
|
|
1470
1472
|
}
|
|
1473
|
+
/** A spring state at rest at `x` (default 0). */
|
|
1471
1474
|
const springState = (x = 0) => ({
|
|
1472
1475
|
x,
|
|
1473
1476
|
v: 0,
|
|
1474
1477
|
a: 0
|
|
1475
1478
|
});
|
|
1476
1479
|
const EPS = 1e-5;
|
|
1480
|
+
/** The damping constant for a half life in seconds, the time the spring takes to cover half the distance to its goal. */
|
|
1477
1481
|
const halflifeToDamping = (halflife) => 4 * Math.LN2 / (halflife + EPS);
|
|
1482
|
+
/** A rational approximation of `exp(-x)` for x of 0 or more, used when `exact` is false. */
|
|
1478
1483
|
const fastNegexp = (x) => 1 / (1 + x + .48 * x * x + .235 * x * x * x);
|
|
1479
1484
|
const negexp = (x, exact) => exact ? Math.exp(-x) : fastNegexp(x);
|
|
1480
1485
|
/** Critically damped spring toward `goal`. `exact` false uses the fast exp. */
|
|
@@ -7000,6 +7005,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
7000
7005
|
return a;
|
|
7001
7006
|
}
|
|
7002
7007
|
// ../rig/dist/expressions.js
|
|
7008
|
+
/** The VRM 1.0 expression presets. */
|
|
7003
7009
|
const VRM_EXPRESSIONS = [
|
|
7004
7010
|
"happy",
|
|
7005
7011
|
"angry",
|
|
@@ -7020,6 +7026,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
7020
7026
|
"lookRight",
|
|
7021
7027
|
"neutral"
|
|
7022
7028
|
];
|
|
7029
|
+
/** The five VRM mouth vowel presets. */
|
|
7023
7030
|
const VRM_VOWELS = [
|
|
7024
7031
|
"aa",
|
|
7025
7032
|
"ih",
|
|
@@ -7027,6 +7034,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
7027
7034
|
"ee",
|
|
7028
7035
|
"oh"
|
|
7029
7036
|
];
|
|
7037
|
+
/** The 15 Oculus visemes, silence first. */
|
|
7030
7038
|
const OCULUS_VISEMES = [
|
|
7031
7039
|
"sil",
|
|
7032
7040
|
"PP",
|
|
@@ -7356,6 +7364,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
7356
7364
|
return out;
|
|
7357
7365
|
}
|
|
7358
7366
|
// ../rig/dist/bones.js
|
|
7367
|
+
/** The VRM 1.0 humanoid bone names, in the order the wasm core numbers them. */
|
|
7359
7368
|
const HUMAN_BONES = [
|
|
7360
7369
|
"hips",
|
|
7361
7370
|
"spine",
|
|
@@ -8320,6 +8329,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
8320
8329
|
return out;
|
|
8321
8330
|
}
|
|
8322
8331
|
// ../avatar/dist/wardrobe.js
|
|
8332
|
+
/** Every wardrobe slot a part can be sorted into, accessories first and the base body last. */
|
|
8323
8333
|
const SLOT_LABELS = [
|
|
8324
8334
|
"eyewear",
|
|
8325
8335
|
"headwear",
|
|
@@ -9163,8 +9173,11 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9163
9173
|
};
|
|
9164
9174
|
}
|
|
9165
9175
|
// ../presence/dist/angles.js
|
|
9176
|
+
/** Radians per degree. */
|
|
9166
9177
|
const DEG = Math.PI / 180;
|
|
9178
|
+
/** Two pi, one full turn in radians. */
|
|
9167
9179
|
const TAU = Math.PI * 2;
|
|
9180
|
+
/** Clamps a number to the range lo to hi. */
|
|
9168
9181
|
const clamp = (x, lo, hi) => x < lo ? lo : x > hi ? hi : x;
|
|
9169
9182
|
/** Wraps to (-pi, pi]. */
|
|
9170
9183
|
function wrapAngle(a) {
|
|
@@ -9339,6 +9352,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9339
9352
|
]
|
|
9340
9353
|
}
|
|
9341
9354
|
};
|
|
9355
|
+
/** Where the eyes and head point each frame, with aversion episodes, saccades, head recruitment, clamped eye aim, blinks and a seam hold behind the body. */
|
|
9342
9356
|
var GazeController = class {
|
|
9343
9357
|
blinker;
|
|
9344
9358
|
rng;
|
|
@@ -9566,7 +9580,9 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9566
9580
|
const a = face.weights[i];
|
|
9567
9581
|
return a + (face.weights[Math.min(n - 1, i + 1)] - a) * (f - i);
|
|
9568
9582
|
}
|
|
9583
|
+
/** Length of a clip in seconds, from its frame count and rate. */
|
|
9569
9584
|
const clipDuration = (c) => Math.max(0, c.frames - 1) / c.fps;
|
|
9585
|
+
/** A pose of the given bone count with every rotation at identity and the root at the origin. */
|
|
9570
9586
|
function createPose(bones) {
|
|
9571
9587
|
const rotations = new Float32Array(bones * 4);
|
|
9572
9588
|
for (let i = 0; i < bones; i++) rotations[i * 4 + 3] = 1;
|
|
@@ -9575,6 +9591,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9575
9591
|
root: /* @__PURE__ */ new Float32Array(3)
|
|
9576
9592
|
};
|
|
9577
9593
|
}
|
|
9594
|
+
/** Copies the rotations and root of one pose into another of the same size. */
|
|
9578
9595
|
function copyPose(from, to) {
|
|
9579
9596
|
to.rotations.set(from.rotations);
|
|
9580
9597
|
to.root.set(from.root);
|
|
@@ -9599,6 +9616,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9599
9616
|
}
|
|
9600
9617
|
if (c.root) for (let k = 0; k < 3; k++) out.root[k] = c.root[i0 * 3 + k] * (1 - u) + c.root[i1 * 3 + k] * u;
|
|
9601
9618
|
}
|
|
9619
|
+
/** How a loop wraps: the seam width in degrees, the blend window and the restart time. */
|
|
9602
9620
|
function planLoop(c, opts = {}) {
|
|
9603
9621
|
const seamDeg = seamDegrees(c);
|
|
9604
9622
|
const d = clipDuration(c);
|
|
@@ -9661,6 +9679,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9661
9679
|
}
|
|
9662
9680
|
if (!mask) for (let k = 0; k < 3; k++) out.root[k] = a.root[k] + (b.root[k] - a.root[k]) * Math.min(1, w);
|
|
9663
9681
|
}
|
|
9682
|
+
/** Layered clip player that writes every bone each frame: a base of idle and speed matched locomotion, a body layer and a masked upper body layer, with loop seams and idle handback. */
|
|
9664
9683
|
var ClipPlayer = class {
|
|
9665
9684
|
pose;
|
|
9666
9685
|
/** This frame's expression weights from the clips' face tracks, each weighted by its layer weight; read after `update`. */
|
|
@@ -9934,12 +9953,13 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
9934
9953
|
}
|
|
9935
9954
|
};
|
|
9936
9955
|
// ../presence/dist/face.js
|
|
9937
|
-
/** The weights a quiet face rests at (vendor
|
|
9956
|
+
/** The weights a quiet face rests at (vendor). */
|
|
9938
9957
|
const RESTING_FACE = {
|
|
9939
9958
|
happy: .25,
|
|
9940
9959
|
relaxed: .3
|
|
9941
9960
|
};
|
|
9942
9961
|
const clamp01 = (x) => x < 0 ? 0 : x > 1 ? 1 : x;
|
|
9962
|
+
/** The face driver: eases moods toward their targets, rests at a slight smile, and writes lid, mouth and clip face weights to one expression sink. */
|
|
9943
9963
|
var Face = class {
|
|
9944
9964
|
sink;
|
|
9945
9965
|
/** Mouth shapes from speech for this frame; call lipsync's `drive` on it before `update`. */
|
|
@@ -10456,6 +10476,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
10456
10476
|
if (x >= 1) return 1;
|
|
10457
10477
|
return .5 - .5 * Math.cos(Math.PI * x);
|
|
10458
10478
|
}
|
|
10479
|
+
/** Timed visemes built from speech events and sampled with coarticulation. */
|
|
10459
10480
|
var VisemeTimeline = class {
|
|
10460
10481
|
keys = [];
|
|
10461
10482
|
/** Keys of the last word that came without an end, open to rescaling. */
|
|
@@ -10619,6 +10640,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
10619
10640
|
ih: .3,
|
|
10620
10641
|
ou: .25
|
|
10621
10642
|
};
|
|
10643
|
+
/** The viseme driver: timed events first, the audio level when no timings cover the moment. */
|
|
10622
10644
|
var LipSync = class {
|
|
10623
10645
|
timeline = new VisemeTimeline();
|
|
10624
10646
|
opts;
|
|
@@ -10650,6 +10672,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
10650
10672
|
...opts
|
|
10651
10673
|
};
|
|
10652
10674
|
}
|
|
10675
|
+
/** Adds speech events to the timeline. */
|
|
10653
10676
|
push(events) {
|
|
10654
10677
|
this.timeline.push(events);
|
|
10655
10678
|
}
|
|
@@ -10742,6 +10765,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
10742
10765
|
// src/body.ts
|
|
10743
10766
|
const UPPER = /^(spine|chest|upperChest|neck|head|left|right)(?!.*(Leg|Foot|Toes))/;
|
|
10744
10767
|
const aligned = (o) => !o || o.getWorldQuaternion(new three.Quaternion()).angleTo(new three.Quaternion()) < .17;
|
|
10768
|
+
/** A loaded character driven in the presence frame order: clip player, gaze, lip sync and face, written to its bones each frame. */
|
|
10745
10769
|
var Body = class {
|
|
10746
10770
|
avatar;
|
|
10747
10771
|
names = [];
|
|
@@ -10931,6 +10955,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
10931
10955
|
}
|
|
10932
10956
|
};
|
|
10933
10957
|
// src/follow.ts
|
|
10958
|
+
/** Keeps a body framed: eases toward a new framing with a dead zone, and leaves a distance or pan the person picked alone. */
|
|
10934
10959
|
var FollowCamera = class {
|
|
10935
10960
|
camera;
|
|
10936
10961
|
target;
|
|
@@ -12891,6 +12916,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
12891
12916
|
const { loadEnvironment } = await Promise.resolve().then(() => (init_three(), three_exports));
|
|
12892
12917
|
return loadEnvironment(req.preset, target.scene, target.renderer, req.resolve ? { resolve: req.resolve } : {});
|
|
12893
12918
|
};
|
|
12919
|
+
/** Shows one lit scene at a time on a stage; a later request overtakes one still loading. */
|
|
12894
12920
|
var EnvironmentSlot = class {
|
|
12895
12921
|
target;
|
|
12896
12922
|
load;
|
|
@@ -12944,9 +12970,11 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
12944
12970
|
return Math.min(device || 1, max, scene ? 1.5 : Infinity);
|
|
12945
12971
|
}
|
|
12946
12972
|
// src/stage.ts
|
|
12973
|
+
/** The line a stage shows when the browser drops its 3D context. */
|
|
12947
12974
|
const LOST_COPY = "the 3d view was lost. press to restore.";
|
|
12948
12975
|
/** Pointer moves count as attention for this long, seconds (vendor). */
|
|
12949
12976
|
const POINTER_WINDOW = 2;
|
|
12977
|
+
/** A three.js stage in a container: renderer, camera, orbit controls, follow camera, loop, environment slot and the body it shows. */
|
|
12950
12978
|
var AvatarStage = class {
|
|
12951
12979
|
container;
|
|
12952
12980
|
opts;
|
package/dist/body.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type Clip, ClipPlayer, Face, GazeController, type GazeMode, type PlayOp
|
|
|
5
5
|
import { LipSync, type MouthTarget } from "@hackbuild/lipsync";
|
|
6
6
|
import { type HumanBone } from "@hackbuild/rig/bones";
|
|
7
7
|
import type { Avatar, Part } from "@hackbuild/avatar/three";
|
|
8
|
+
/** Random source, gaze, head levelling, mouth target and clip options of a `Body`. */
|
|
8
9
|
export interface BodyOptions {
|
|
9
10
|
rng: Rng;
|
|
10
11
|
/** Gaze on neck, head and eyes. auto turns it on when the head's rest frame is upright and facing +Z. Default auto. */
|
|
@@ -28,6 +29,7 @@ export interface BodyCaps {
|
|
|
28
29
|
blink: boolean;
|
|
29
30
|
gaze: boolean;
|
|
30
31
|
}
|
|
32
|
+
/** A loaded character driven in the presence frame order: clip player, gaze, lip sync and face, written to its bones each frame. */
|
|
31
33
|
export declare class Body {
|
|
32
34
|
readonly avatar: Avatar;
|
|
33
35
|
readonly names: HumanBone[];
|
package/dist/body.js
CHANGED
|
@@ -6,6 +6,7 @@ import { HUMAN_BONES } from "@hackbuild/rig/bones";
|
|
|
6
6
|
const UPPER = /^(spine|chest|upperChest|neck|head|left|right)(?!.*(Leg|Foot|Toes))/;
|
|
7
7
|
// the rest frame is upright and faces +Z within about 10 degrees (proposed)
|
|
8
8
|
const aligned = (o) => !o || o.getWorldQuaternion(new Quaternion()).angleTo(new Quaternion()) < 0.17;
|
|
9
|
+
/** A loaded character driven in the presence frame order: clip player, gaze, lip sync and face, written to its bones each frame. */
|
|
9
10
|
export class Body {
|
|
10
11
|
avatar;
|
|
11
12
|
names = [];
|