@hackbuild/motion-views 0.1.0 → 0.1.1
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 +155 -85
- package/dist/avatar-drop.d.ts +4 -0
- package/dist/character-stage.d.ts +5 -1
- package/dist/clip-strip.d.ts +3 -0
- package/dist/clips.d.ts +2 -0
- package/dist/elements.d.ts +4 -0
- package/dist/gestures.d.ts +2 -0
- package/dist/gestures.js +1 -0
- package/dist/motion-views.iife.js +25 -1
- package/dist/words.d.ts +3 -0
- package/llms.md +581 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,105 +1,175 @@
|
|
|
1
1
|
# @hackbuild/motion-views
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
hackbuild-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- `
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
("168 kb glb, 5.5 k triangles"), the licence the file states and the
|
|
32
|
-
rig check in plain words ("no mouth shapes. the lips stay still while it
|
|
33
|
-
talks."); pressing it sends `use`. The files go out on `picked`, the
|
|
34
|
-
report on `checked`.
|
|
35
|
-
- `ClipStrip`: the hackbuild-ui clip strip (`.hb-clipstrip`): each clip's
|
|
36
|
-
still, name and length, the picked one pressed and the playing one
|
|
37
|
-
marked, and one play button that plays or stops the picked clip. Stills come from the item, or are drawn
|
|
38
|
-
in the background on a clay figure by the avatar-host thumb queue.
|
|
39
|
-
|
|
40
|
-
## Entries
|
|
41
|
-
|
|
42
|
-
- `.`: the words and the clip items, no three.js and no DOM.
|
|
43
|
-
`rigCheck`, `sizeLine`, `licenceLine`, `secondsWord`; `clipsFromPack`
|
|
44
|
-
`speechEvents`, `estimateSeconds` (what a speech becomes on the mouth
|
|
45
|
-
clock); `clipsFromPack` (a `@hackbuild/bake` pack and report, with a warning on a loop that does
|
|
46
|
-
not close), `clipFromFindings` (a `@hackbuild/retarget` motion),
|
|
47
|
-
`clipsFromBody`, `clipMeta`, `nextClip`.
|
|
48
|
-
- `/vanilla`: `characterStage(host, opts)`, `avatarDrop(host, opts)`,
|
|
49
|
-
`clipStrip(host, opts)`, `gestureClip`, `animationClipOf`, and
|
|
50
|
-
`defineMotionViews(opts)`, which defines `hb-character-stage`,
|
|
51
|
-
`hb-avatar-drop` and `hb-clip-strip`. Importing defines nothing.
|
|
52
|
-
- `/vue`: `CharacterStage` (props `name`, `src`, `framing`, `verbs`,
|
|
53
|
-
`drop`, `options`; slot `inset`), `AvatarDrop` (`go`, `label`,
|
|
54
|
-
`options`) and `ClipStrip` (`items`, `current`, `playing`, `go`).
|
|
55
|
-
Events are the view's events by type.
|
|
56
|
-
- `/iife`: the vanilla entry as one classic script; three.js comes from
|
|
57
|
-
the page as `THREE`.
|
|
3
|
+
Put a character stage, an avatar drop card and a clip strip on your page, drawn with the hackbuild-ui stylesheet, as custom elements or Vue components.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@hackbuild/motion-views) [](../../LICENSE)  
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
- `CharacterStage`: a body on a lit stage with idle, gaze, blinks and lips, a corner plate, turn around and framing tools, a verb row and an inset slot. It speaks real audio with word timings, or text alone on estimated timings.
|
|
10
|
+
- `AvatarDrop`: a drop zone and pick button that loads a VRM, GLB or FBX once, checks its rig in plain words, draws a still and shows the avatar card.
|
|
11
|
+
- `ClipStrip`: each clip's still, name and length, the picked one pressed and one play button.
|
|
12
|
+
- Ships every view as a mount function, a custom element and a Vue 3 component, on one code path.
|
|
13
|
+
- Carries no styles of its own; every class is hackbuild-ui's.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @hackbuild/motion-views three @virgilvox/hackbuild-ui
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@virgilvox/hackbuild-ui` 0.10 is a required peer, and the page loads its stylesheet (`@virgilvox/hackbuild-ui/styles.css`). three.js is needed by the views; Vue only by `/vue`. It depends on `@hackbuild/avatar`, `@hackbuild/avatar-host`, `@hackbuild/presence`, `@hackbuild/lipsync` and `@hackbuild/organic`, which install with it.
|
|
22
|
+
|
|
23
|
+
| subpath | needs | pin |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `@hackbuild/motion-views` | nothing; the words, clip items and speech timings | none |
|
|
26
|
+
| `@hackbuild/motion-views/vanilla` | `three` (optional peer), `@virgilvox/hackbuild-ui` (peer) | three 0.186.1 or later, hackbuild-ui `>=0.10.0 <0.11.0` |
|
|
27
|
+
| `@hackbuild/motion-views/vue` | `vue` (optional peer) and the above | vue 3.5.0 or later |
|
|
28
|
+
| `@hackbuild/motion-views/iife` | `THREE` on the page | one classic script |
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
58
31
|
|
|
59
32
|
```ts
|
|
60
|
-
import {
|
|
33
|
+
import { avatarDrop, characterStage } from "@hackbuild/motion-views/vanilla";
|
|
34
|
+
|
|
35
|
+
// the stage shows a placeholder body built in code until you give it one
|
|
36
|
+
const host = document.createElement("div");
|
|
37
|
+
host.style.height = "480px";
|
|
38
|
+
document.body.append(host);
|
|
39
|
+
const stage = characterStage(host, { name: "stand-in", hello: "hello. drop a vrm, glb or fbx on me." });
|
|
40
|
+
stage.on((e) => e.type === "doing" && console.log("doing", e.word));
|
|
41
|
+
|
|
42
|
+
// a drop card: press the card of a checked avatar to put it on the stage
|
|
43
|
+
const card = document.body.appendChild(document.createElement("div"));
|
|
44
|
+
avatarDrop(card).on((e) => {
|
|
45
|
+
if (e.type === "checked") console.log(e.report.check.head, e.report.size);
|
|
46
|
+
if (e.type === "use") void stage.show(e.files);
|
|
47
|
+
});
|
|
61
48
|
|
|
49
|
+
// text alone moves the lips on estimated word timings, with no sound
|
|
50
|
+
await stage.say("you can drop a model on me");
|
|
51
|
+
stage.gesture("wave");
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Live example
|
|
55
|
+
|
|
56
|
+
The demo pages run each view on the placeholder body built in code: [character stage](https://hackbuild.github.io/hackbuild-motion/character-stage/), [avatar drop](https://hackbuild.github.io/hackbuild-motion/avatar-drop/) and [clip strip](https://hackbuild.github.io/hackbuild-motion/clip-strip/). The package page is [hackbuild-motion/motion-views](https://hackbuild.github.io/hackbuild-motion/motion-views/), and the suite's character screen runs on it: [hackbuild-suite character](https://hackbuild.github.io/hackbuild-suite/#/character).
|
|
57
|
+
|
|
58
|
+
## Concepts
|
|
59
|
+
|
|
60
|
+
### one view, three ways to mount it
|
|
61
|
+
|
|
62
|
+
`characterStage(host, opts)`, `avatarDrop(host, opts)` and `clipStrip(host, opts)` mount into an element and return a handle with `on(fn)` and `dispose()`. `defineMotionViews(opts)` defines `hb-character-stage`, `hb-avatar-drop` and `hb-clip-strip`, which dispatch the view's events as DOM events with the event as `detail` and keep the handle on `.handle`; importing defines nothing. The Vue components take the same options as props and emit the same events by type.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
62
65
|
defineMotionViews({ stage: { vrm: () => import("@hackbuild/avatar/vrm").then((m) => m.vrmHook()) } });
|
|
63
|
-
const stage = document.querySelector("hb-character-stage")!;
|
|
64
|
-
document.querySelector("hb-avatar-drop")!.addEventListener("picked", (e) => stage.handle?.show(e.detail.files));
|
|
66
|
+
const stage = document.querySelector<CharacterStageElement>("hb-character-stage")!;
|
|
67
|
+
document.querySelector("hb-avatar-drop")!.addEventListener("picked", (e) => stage.handle?.show((e as CustomEvent).detail.files));
|
|
65
68
|
```
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
### speech on the stage
|
|
71
|
+
|
|
72
|
+
`say(speech)` plays an AudioBuffer or an audio element through an analyser whose level and bands open the mouth, with the word or phoneme timings a speech engine reports. Text alone moves the lips on estimated word timings with no sound. `speechSource` says where the last timings came from. `gesture("wave" | "nod" | "shake" | "bow")` plays a gesture written in code over the body's own bones, and `play(clip)` plays a presence clip or a three.js AnimationClip.
|
|
73
|
+
|
|
74
|
+
### the rig check in plain words
|
|
75
|
+
|
|
76
|
+
`rigCheck(facts)` turns what a loaded body can do into a headline ("ready to act", "ready, with limits", "cannot act") and lines worst first, such as "no mouth shapes. the lips stay still while it talks." `sizeLine` and `licenceLine` give the card's other lines; the licence is the one the file states.
|
|
77
|
+
|
|
78
|
+
### clip items from any source
|
|
79
|
+
|
|
80
|
+
`clipsFromPack` (a `@hackbuild/bake` pack and report, with a warning on a loop that does not close), `clipFromFindings` (a `@hackbuild/retarget` motion) and `clipsFromBody` all give one `ClipItem` shape for the strip. They read structural types, so the main entry needs neither wasm package.
|
|
81
|
+
|
|
82
|
+
### hackbuild-ui classes only
|
|
83
|
+
|
|
84
|
+
The stage writes a `.hb-lay-stage`, the card is `.hb-avcard`, the strip `.hb-clipstrip`. A view adds no style of its own, so it looks like the rest of a page that loads the hackbuild-ui stylesheet.
|
|
85
|
+
|
|
86
|
+
## API overview
|
|
87
|
+
|
|
88
|
+
| export | what it does |
|
|
89
|
+
|---|---|
|
|
90
|
+
| [`characterStage`](../../docs/api/motion-views/vanilla.md#characterstage) | mount the character stage |
|
|
91
|
+
| [`CharacterStageHandle`](../../docs/api/motion-views/vanilla.md#characterstagehandle) | show a body, say, gesture, play, frame and listen |
|
|
92
|
+
| [`avatarDrop`](../../docs/api/motion-views/vanilla.md#avatardrop) | mount the drop zone and avatar card |
|
|
93
|
+
| [`AvatarReport`](../../docs/api/motion-views/vanilla.md#avatarreport) | what the drop learned about an avatar |
|
|
94
|
+
| [`clipStrip`](../../docs/api/motion-views/vanilla.md#clipstrip) | mount the clip strip |
|
|
95
|
+
| [`defineMotionViews`](../../docs/api/motion-views/vanilla.md#definemotionviews) | define the three custom elements |
|
|
96
|
+
| [`gestureClip`](../../docs/api/motion-views/vanilla.md#gestureclip) | a gesture written in code as a clip |
|
|
97
|
+
| [`CharacterStage`](../../docs/api/motion-views/vue.md#characterstage) | the stage as a Vue component |
|
|
98
|
+
| [`AvatarDrop`](../../docs/api/motion-views/vue.md#avatardrop) | the drop card as a Vue component |
|
|
99
|
+
| [`ClipStrip`](../../docs/api/motion-views/vue.md#clipstrip) | the strip as a Vue component |
|
|
100
|
+
| [`rigCheck`](../../docs/api/motion-views/index.md#rigcheck) | what a body can do, in plain words |
|
|
101
|
+
| [`sizeLine`](../../docs/api/motion-views/index.md#sizeline) | the size line of the avatar card |
|
|
102
|
+
| [`clipsFromPack`](../../docs/api/motion-views/index.md#clipsfrompack) | clip items from a baked pack |
|
|
103
|
+
| [`speechEvents`](../../docs/api/motion-views/index.md#speechevents) | what a speech becomes on the mouth clock |
|
|
104
|
+
|
|
105
|
+
The full reference is in [docs/api/motion-views](../../docs/api/motion-views/README.md).
|
|
106
|
+
|
|
107
|
+
## Browser support
|
|
108
|
+
|
|
109
|
+
| feature | needs | notes |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| main entry | any JavaScript runtime | no DOM, no three.js, runs in Node |
|
|
112
|
+
| the views | WebGL through three.js, custom elements | the stage pauses while hidden or off screen |
|
|
113
|
+
| real speech | Web Audio | an AudioContext is made on the first audio unless you pass `audioContext` |
|
|
114
|
+
| avatar stills | WebGL | `report.thumb` is null with no WebGL |
|
|
115
|
+
| single file build | `dist/motion-views.iife.js` | the vanilla entry as one classic script, `THREE` read from the page, runs from file:// |
|
|
116
|
+
|
|
117
|
+
The views ran in headless Chrome on macOS; Safari, Firefox and phones are unknown.
|
|
118
|
+
|
|
119
|
+
## Errors and troubleshooting
|
|
120
|
+
|
|
121
|
+
The views throw nothing to your code; a failure becomes an event and a plain line on screen.
|
|
122
|
+
|
|
123
|
+
| message | cause | what to do |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| a `failed` event from CharacterStage | the body could not load from the URL or files | read `e.message`; give the model with its textures, or a VRM, GLB or FBX |
|
|
126
|
+
| a `failed` event from AvatarDrop | the dropped files held no body it could read | drop a .vrm, .glb, .gltf with its .bin and textures, or .fbx |
|
|
127
|
+
| `-1` from `play` | the clip cannot play on this body | check the body has the bones the clip moves |
|
|
128
|
+
| `false` from `gesture` | the body lacks the bones the gesture needs | check the rig check lines of the body |
|
|
129
|
+
|
|
130
|
+
## Works with
|
|
131
|
+
|
|
132
|
+
- [@hackbuild/avatar-host](../avatar-host/README.md) is the stage under CharacterStage and draws the clip stills.
|
|
133
|
+
- [@hackbuild/avatar](../avatar/README.md) loads the VRM, GLB and FBX files.
|
|
134
|
+
- [@hackbuild/presence](../presence/README.md) and [@hackbuild/lipsync](../lipsync/README.md) give idle, gaze, blinks and lips.
|
|
135
|
+
- [@hackbuild/bake](../bake/README.md) and [@hackbuild/retarget](../retarget/README.md) make the clips the strip lists.
|
|
136
|
+
|
|
137
|
+
## Changelog and licences
|
|
138
|
+
|
|
139
|
+
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 model or weight file ships here; an avatar keeps the licence its file states, which the card shows.
|
|
70
140
|
|
|
71
141
|
## What is verified, and what is not
|
|
72
142
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
143
|
+
### Verified on this machine
|
|
144
|
+
|
|
145
|
+
| check | result |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `node tools/smoke-views.mjs` in headless Chrome on macOS 12 | pass |
|
|
148
|
+
| the stand-in shows and a frame is drawn | pass |
|
|
149
|
+
| the full body shot stands further back than the bust | 2.78 m to 4.03 m (measured) |
|
|
150
|
+
| say hello plays audio written in code with word timings and the level reaches the lips | peak 0.215 (measured) |
|
|
151
|
+
| audio with no timings moves the lips by level; text alone falls back to estimated timings; quiet when the audio ends | pass |
|
|
152
|
+
| wave plays on the upper body; turn around turns the body half a circle | pass |
|
|
153
|
+
| the stand-in written as a .glb loads, maps 24 bones, gets a still and reads "no licence in the file" | pass (measured) |
|
|
154
|
+
| a text file is refused in plain words | pass |
|
|
155
|
+
| a bvh walk retargets onto the stand-in; six clips bake into one pack and read back; a loop cut short is flagged at its seam | pass |
|
|
156
|
+
| the three demo pages at 1440 and 390 px against the suite's screen gate | pass |
|
|
157
|
+
| unit tests over the words and the clip items | pass |
|
|
158
|
+
|
|
159
|
+
### Not verified by anything
|
|
160
|
+
|
|
161
|
+
- Speech from a real speech engine; the smoke's voice is a hum written in code with word timings in an engine's shape.
|
|
162
|
+
- A real VRM, GLB or FBX avatar with a face; the smoke uses the stand-in built in code, which has no mouth or blink shapes.
|
|
163
|
+
- The Vue components in a running Vue app; they typecheck, and no page mounts them yet.
|
|
164
|
+
- Frame rate on a real GPU, since the smoke runs headless.
|
|
165
|
+
- AvatarDrop loads the file once and the stage loads it again, so a large file is read twice.
|
|
96
166
|
|
|
97
167
|
## Size budget
|
|
98
168
|
|
|
99
169
|
| file | gzip (measured) | ceiling |
|
|
100
170
|
|---|---|---|
|
|
101
171
|
| `dist/index.js` (main entry, imports external) | 3,266 bytes | 3,429 bytes |
|
|
102
|
-
| `dist/motion-views.iife.js` (single file build) |
|
|
172
|
+
| `dist/motion-views.iife.js` (single file build) | 215,543 bytes | 226,320 bytes |
|
|
103
173
|
|
|
104
174
|
Measured 2026-11-25 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
|
|
105
175
|
tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
|
package/dist/avatar-drop.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type DroppedFile } from "@hackbuild/avatar-host";
|
|
2
2
|
import { type BodyCaps, type BodyLoadOptions } from "@hackbuild/avatar-host/three";
|
|
3
3
|
import { type RigCheck, type RigLine } from "./words.js";
|
|
4
|
+
/** What AvatarDrop learned about a dropped avatar: name, format, size, rig check, licence and still. */
|
|
4
5
|
export interface AvatarReport {
|
|
5
6
|
name: string;
|
|
6
7
|
format: string;
|
|
@@ -14,6 +15,7 @@ export interface AvatarReport {
|
|
|
14
15
|
/** The still, a PNG, or null when there is no webgl. */
|
|
15
16
|
thumb: Blob | null;
|
|
16
17
|
}
|
|
18
|
+
/** Options of `avatarDrop`: the load options of a body plus the pick button and hint words. */
|
|
17
19
|
export interface AvatarDropOptions extends BodyLoadOptions {
|
|
18
20
|
/** The pick button is the one pink action of the screen. Default false. */
|
|
19
21
|
go?: boolean;
|
|
@@ -22,6 +24,7 @@ export interface AvatarDropOptions extends BodyLoadOptions {
|
|
|
22
24
|
/** The line in the empty zone. */
|
|
23
25
|
hint?: string;
|
|
24
26
|
}
|
|
27
|
+
/** Events of AvatarDrop: files picked, the report checked, a failure, or the card pressed to use the avatar. */
|
|
25
28
|
export type AvatarDropEvent = {
|
|
26
29
|
type: "picked";
|
|
27
30
|
files: readonly DroppedFile[];
|
|
@@ -39,6 +42,7 @@ export type AvatarDropEvent = {
|
|
|
39
42
|
report: AvatarReport;
|
|
40
43
|
files: readonly DroppedFile[];
|
|
41
44
|
};
|
|
45
|
+
/** The handle `avatarDrop` returns: the last report, take files, open the picker, listen, dispose. */
|
|
42
46
|
export interface AvatarDropHandle {
|
|
43
47
|
readonly report: AvatarReport | null;
|
|
44
48
|
/** Reads files as a drop would. Resolves to the report, or null when the files held no body it could read. */
|
|
@@ -4,6 +4,7 @@ import { type Speech, type SpeechSource } from "./speech.js";
|
|
|
4
4
|
import type { BodySource, DroppedFile } from "@hackbuild/avatar-host";
|
|
5
5
|
import { AvatarStage, type Body, type BodyCaps, type StageOptions } from "@hackbuild/avatar-host/three";
|
|
6
6
|
import { type Gesture } from "./gestures.js";
|
|
7
|
+
/** The stage shot: bust, or the full body. */
|
|
7
8
|
export type Framing = "bust" | "full";
|
|
8
9
|
/** One verb on the stage. `go` makes it the one pink action; give it to one verb at most. */
|
|
9
10
|
export interface Verb {
|
|
@@ -13,13 +14,14 @@ export interface Verb {
|
|
|
13
14
|
}
|
|
14
15
|
/** The verbs a stage shows by default: say hello is the next thing to do. */
|
|
15
16
|
export declare const DEFAULT_VERBS: readonly Verb[];
|
|
17
|
+
/** Options of `characterStage`: stage options plus name, model URL, verbs, framing, drop and the hello speech. */
|
|
16
18
|
export interface CharacterStageOptions extends StageOptions {
|
|
17
19
|
/** The name on the corner plate. Default the body's name. */
|
|
18
20
|
name?: string;
|
|
19
21
|
/** A model URL to show; the placeholder body shows until it loads, and without one. */
|
|
20
22
|
src?: string;
|
|
21
23
|
verbs?: readonly Verb[];
|
|
22
|
-
/** Bust
|
|
24
|
+
/** Bust frames from the knees to just over the head; full shows the whole body. Default bust. */
|
|
23
25
|
framing?: Framing;
|
|
24
26
|
/** Take files dropped on the stage. Default true. */
|
|
25
27
|
drop?: boolean;
|
|
@@ -28,6 +30,7 @@ export interface CharacterStageOptions extends StageOptions {
|
|
|
28
30
|
/** The context real speech plays through; default one made on the first audio. */
|
|
29
31
|
audioContext?: AudioContext;
|
|
30
32
|
}
|
|
33
|
+
/** Events of CharacterStage: a body loaded or failed, what it is doing, a verb pressed, the framing changed. */
|
|
31
34
|
export type CharacterStageEvent = {
|
|
32
35
|
type: "loaded";
|
|
33
36
|
name: string;
|
|
@@ -47,6 +50,7 @@ export type CharacterStageEvent = {
|
|
|
47
50
|
type: "framing";
|
|
48
51
|
framing: Framing;
|
|
49
52
|
};
|
|
53
|
+
/** The handle `characterStage` returns: show a body, speak, gesture, play clips, frame and listen. */
|
|
50
54
|
export interface CharacterStageHandle {
|
|
51
55
|
readonly stage: AvatarStage;
|
|
52
56
|
readonly body: Body | null;
|
package/dist/clip-strip.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type ClipItem } from "./clips.js";
|
|
|
4
4
|
export interface StripItem extends ClipItem {
|
|
5
5
|
animation?: () => AnimationClip | Promise<AnimationClip>;
|
|
6
6
|
}
|
|
7
|
+
/** Options of `clipStrip`: the items, the picked clip, the play button and stills. */
|
|
7
8
|
export interface ClipStripOptions {
|
|
8
9
|
items?: readonly StripItem[];
|
|
9
10
|
/** The picked clip; default the first. */
|
|
@@ -15,6 +16,7 @@ export interface ClipStripOptions {
|
|
|
15
16
|
/** Draw missing stills from `animation`. Default true. */
|
|
16
17
|
thumbs?: boolean;
|
|
17
18
|
}
|
|
19
|
+
/** Events of ClipStrip: a clip picked, play or stop pressed, a still drawn or failed. */
|
|
18
20
|
export type ClipStripEvent = {
|
|
19
21
|
type: "pick";
|
|
20
22
|
item: StripItem;
|
|
@@ -29,6 +31,7 @@ export type ClipStripEvent = {
|
|
|
29
31
|
id: string;
|
|
30
32
|
ok: boolean;
|
|
31
33
|
};
|
|
34
|
+
/** The handle `clipStrip` returns: set items, pick, set the play state, wait for stills, listen. */
|
|
32
35
|
export interface ClipStripHandle {
|
|
33
36
|
readonly current: StripItem | null;
|
|
34
37
|
readonly playing: boolean;
|
package/dist/clips.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** Where a clip came from: a baked pack, a retarget, the body's own file, or code. */
|
|
1
2
|
export type ClipFrom = "bake" | "retarget" | "body" | "code";
|
|
3
|
+
/** One clip as the strip shows it: id, name, length, loop, source, tags, warning and still. */
|
|
2
4
|
export interface ClipItem {
|
|
3
5
|
id: string;
|
|
4
6
|
name: string;
|
package/dist/elements.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { type CharacterStageHandle, type CharacterStageOptions } from "./character-stage.js";
|
|
2
2
|
import { type AvatarDropHandle, type AvatarDropOptions } from "./avatar-drop.js";
|
|
3
3
|
import { type ClipStripHandle, type StripItem } from "./clip-strip.js";
|
|
4
|
+
/** Options `defineMotionViews` shares with every element it defines. */
|
|
4
5
|
export interface MotionViewsOptions {
|
|
5
6
|
/** Options every hb-character-stage shares: the vrm hook, lights, follow. */
|
|
6
7
|
stage?: CharacterStageOptions;
|
|
7
8
|
/** Options every hb-avatar-drop shares: the vrm hook. */
|
|
8
9
|
drop?: AvatarDropOptions;
|
|
9
10
|
}
|
|
11
|
+
/** The hb-character-stage element, with its view handle once connected. */
|
|
10
12
|
export interface CharacterStageElement extends HTMLElement {
|
|
11
13
|
readonly handle: CharacterStageHandle | null;
|
|
12
14
|
}
|
|
15
|
+
/** The hb-avatar-drop element, with its view handle once connected. */
|
|
13
16
|
export interface AvatarDropElement extends HTMLElement {
|
|
14
17
|
readonly handle: AvatarDropHandle | null;
|
|
15
18
|
}
|
|
19
|
+
/** The hb-clip-strip element, with its view handle and the items and picked clip as properties. */
|
|
16
20
|
export interface ClipStripElement extends HTMLElement {
|
|
17
21
|
readonly handle: ClipStripHandle | null;
|
|
18
22
|
items: readonly StripItem[];
|
package/dist/gestures.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AnimationClip } from "three";
|
|
2
2
|
import type { Clip } from "@hackbuild/presence";
|
|
3
|
+
/** A gesture written in code over the body's own bones. */
|
|
3
4
|
export type Gesture = "wave" | "nod" | "shake" | "bow";
|
|
5
|
+
/** Every gesture `gestureClip` can make. */
|
|
4
6
|
export declare const GESTURES: readonly Gesture[];
|
|
5
7
|
/**
|
|
6
8
|
* A gesture as a presence clip over `names`, starting from `base` (bones
|
package/dist/gestures.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// does not touch keep the pose they had when it was built, so an upper
|
|
5
5
|
// layer wave leaves the relaxed left arm where it was.
|
|
6
6
|
import { AnimationClip, Quaternion, QuaternionKeyframeTrack, Vector3 } from "three";
|
|
7
|
+
/** Every gesture `gestureClip` can make. */
|
|
7
8
|
export const GESTURES = ["wave", "nod", "shake", "bow"];
|
|
8
9
|
// shapes in the normalized humanoid space: identity rest, +Z forward, left on +X
|
|
9
10
|
const MOVES = {
|
|
@@ -848,6 +848,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
848
848
|
if (x >= 1) return 1;
|
|
849
849
|
return .5 - .5 * Math.cos(Math.PI * x);
|
|
850
850
|
}
|
|
851
|
+
/** Timed visemes built from speech events and sampled with coarticulation. */
|
|
851
852
|
var VisemeTimeline = class {
|
|
852
853
|
keys = [];
|
|
853
854
|
/** Keys of the last word that came without an end, open to rescaling. */
|
|
@@ -1040,6 +1041,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
1040
1041
|
ih: .3,
|
|
1041
1042
|
ou: .25
|
|
1042
1043
|
};
|
|
1044
|
+
/** The viseme driver: timed events first, the audio level when no timings cover the moment. */
|
|
1043
1045
|
var LipSync = class {
|
|
1044
1046
|
timeline = new VisemeTimeline();
|
|
1045
1047
|
opts;
|
|
@@ -1071,6 +1073,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
1071
1073
|
...opts
|
|
1072
1074
|
};
|
|
1073
1075
|
}
|
|
1076
|
+
/** Adds speech events to the timeline. */
|
|
1074
1077
|
push(events) {
|
|
1075
1078
|
this.timeline.push(events);
|
|
1076
1079
|
}
|
|
@@ -9600,13 +9603,16 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
9600
9603
|
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
9601
9604
|
};
|
|
9602
9605
|
}
|
|
9606
|
+
/** A spring state at rest at `x` (default 0). */
|
|
9603
9607
|
const springState = (x = 0) => ({
|
|
9604
9608
|
x,
|
|
9605
9609
|
v: 0,
|
|
9606
9610
|
a: 0
|
|
9607
9611
|
});
|
|
9608
9612
|
const EPS = 1e-5;
|
|
9613
|
+
/** The damping constant for a half life in seconds, the time the spring takes to cover half the distance to its goal. */
|
|
9609
9614
|
const halflifeToDamping = (halflife) => 4 * Math.LN2 / (halflife + EPS);
|
|
9615
|
+
/** A rational approximation of `exp(-x)` for x of 0 or more, used when `exact` is false. */
|
|
9610
9616
|
const fastNegexp = (x) => 1 / (1 + x + .48 * x * x + .235 * x * x * x);
|
|
9611
9617
|
const negexp = (x, exact) => exact ? Math.exp(-x) : fastNegexp(x);
|
|
9612
9618
|
/** Critically damped spring toward `goal`. `exact` false uses the fast exp. */
|
|
@@ -9693,6 +9699,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
9693
9699
|
}
|
|
9694
9700
|
};
|
|
9695
9701
|
// ../avatar-host/dist/host.js
|
|
9702
|
+
/** 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. */
|
|
9696
9703
|
var AvatarHost = class {
|
|
9697
9704
|
opts;
|
|
9698
9705
|
slots = /* @__PURE__ */ new Map();
|
|
@@ -9770,6 +9777,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
9770
9777
|
}
|
|
9771
9778
|
};
|
|
9772
9779
|
// ../avatar-host/dist/loop.js
|
|
9780
|
+
/** 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. */
|
|
9773
9781
|
var StageLoop = class {
|
|
9774
9782
|
opts;
|
|
9775
9783
|
/** Frames drawn since the loop was made. */
|
|
@@ -9969,8 +9977,11 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
9969
9977
|
return "the model did not load. its file may be damaged or of a kind the stage does not read.";
|
|
9970
9978
|
}
|
|
9971
9979
|
// ../presence/dist/angles.js
|
|
9980
|
+
/** Radians per degree. */
|
|
9972
9981
|
const DEG = Math.PI / 180;
|
|
9982
|
+
/** Two pi, one full turn in radians. */
|
|
9973
9983
|
const TAU = Math.PI * 2;
|
|
9984
|
+
/** Clamps a number to the range lo to hi. */
|
|
9974
9985
|
const clamp = (x, lo, hi) => x < lo ? lo : x > hi ? hi : x;
|
|
9975
9986
|
/** Wraps to (-pi, pi]. */
|
|
9976
9987
|
function wrapAngle(a) {
|
|
@@ -10145,6 +10156,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10145
10156
|
]
|
|
10146
10157
|
}
|
|
10147
10158
|
};
|
|
10159
|
+
/** 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. */
|
|
10148
10160
|
var GazeController = class {
|
|
10149
10161
|
blinker;
|
|
10150
10162
|
rng;
|
|
@@ -10372,7 +10384,9 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10372
10384
|
const a = face.weights[i];
|
|
10373
10385
|
return a + (face.weights[Math.min(n - 1, i + 1)] - a) * (f - i);
|
|
10374
10386
|
}
|
|
10387
|
+
/** Length of a clip in seconds, from its frame count and rate. */
|
|
10375
10388
|
const clipDuration = (c) => Math.max(0, c.frames - 1) / c.fps;
|
|
10389
|
+
/** A pose of the given bone count with every rotation at identity and the root at the origin. */
|
|
10376
10390
|
function createPose(bones) {
|
|
10377
10391
|
const rotations = new Float32Array(bones * 4);
|
|
10378
10392
|
for (let i = 0; i < bones; i++) rotations[i * 4 + 3] = 1;
|
|
@@ -10381,6 +10395,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10381
10395
|
root: /* @__PURE__ */ new Float32Array(3)
|
|
10382
10396
|
};
|
|
10383
10397
|
}
|
|
10398
|
+
/** Copies the rotations and root of one pose into another of the same size. */
|
|
10384
10399
|
function copyPose(from, to) {
|
|
10385
10400
|
to.rotations.set(from.rotations);
|
|
10386
10401
|
to.root.set(from.root);
|
|
@@ -10405,6 +10420,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10405
10420
|
}
|
|
10406
10421
|
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;
|
|
10407
10422
|
}
|
|
10423
|
+
/** How a loop wraps: the seam width in degrees, the blend window and the restart time. */
|
|
10408
10424
|
function planLoop(c, opts = {}) {
|
|
10409
10425
|
const seamDeg = seamDegrees(c);
|
|
10410
10426
|
const d = clipDuration(c);
|
|
@@ -10467,6 +10483,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10467
10483
|
}
|
|
10468
10484
|
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);
|
|
10469
10485
|
}
|
|
10486
|
+
/** 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. */
|
|
10470
10487
|
var ClipPlayer = class {
|
|
10471
10488
|
pose;
|
|
10472
10489
|
/** This frame's expression weights from the clips' face tracks, each weighted by its layer weight; read after `update`. */
|
|
@@ -10740,12 +10757,13 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10740
10757
|
}
|
|
10741
10758
|
};
|
|
10742
10759
|
// ../presence/dist/face.js
|
|
10743
|
-
/** The weights a quiet face rests at (vendor
|
|
10760
|
+
/** The weights a quiet face rests at (vendor). */
|
|
10744
10761
|
const RESTING_FACE = {
|
|
10745
10762
|
happy: .25,
|
|
10746
10763
|
relaxed: .3
|
|
10747
10764
|
};
|
|
10748
10765
|
const clamp01 = (x) => x < 0 ? 0 : x > 1 ? 1 : x;
|
|
10766
|
+
/** 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. */
|
|
10749
10767
|
var Face = class {
|
|
10750
10768
|
sink;
|
|
10751
10769
|
/** Mouth shapes from speech for this frame; call lipsync's `drive` on it before `update`. */
|
|
@@ -10974,6 +10992,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
10974
10992
|
init_bones();
|
|
10975
10993
|
const UPPER = /^(spine|chest|upperChest|neck|head|left|right)(?!.*(Leg|Foot|Toes))/;
|
|
10976
10994
|
const aligned = (o) => !o || o.getWorldQuaternion(new three.Quaternion()).angleTo(new three.Quaternion()) < .17;
|
|
10995
|
+
/** A loaded character driven in the presence frame order: clip player, gaze, lip sync and face, written to its bones each frame. */
|
|
10977
10996
|
var Body = class {
|
|
10978
10997
|
avatar;
|
|
10979
10998
|
names = [];
|
|
@@ -11163,6 +11182,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
11163
11182
|
}
|
|
11164
11183
|
};
|
|
11165
11184
|
// ../avatar-host/dist/follow.js
|
|
11185
|
+
/** Keeps a body framed: eases toward a new framing with a dead zone, and leaves a distance or pan the person picked alone. */
|
|
11166
11186
|
var FollowCamera = class {
|
|
11167
11187
|
camera;
|
|
11168
11188
|
target;
|
|
@@ -13140,6 +13160,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
13140
13160
|
const { loadEnvironment } = await Promise.resolve().then(() => (init_three(), three_exports));
|
|
13141
13161
|
return loadEnvironment(req.preset, target.scene, target.renderer, req.resolve ? { resolve: req.resolve } : {});
|
|
13142
13162
|
};
|
|
13163
|
+
/** Shows one lit scene at a time on a stage; a later request overtakes one still loading. */
|
|
13143
13164
|
var EnvironmentSlot = class {
|
|
13144
13165
|
target;
|
|
13145
13166
|
load;
|
|
@@ -13196,9 +13217,11 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
13196
13217
|
init_three$1();
|
|
13197
13218
|
init_load();
|
|
13198
13219
|
init_placeholder();
|
|
13220
|
+
/** The line a stage shows when the browser drops its 3D context. */
|
|
13199
13221
|
const LOST_COPY = "the 3d view was lost. press to restore.";
|
|
13200
13222
|
/** Pointer moves count as attention for this long, seconds (vendor). */
|
|
13201
13223
|
const POINTER_WINDOW = 2;
|
|
13224
|
+
/** A three.js stage in a container: renderer, camera, orbit controls, follow camera, loop, environment slot and the body it shows. */
|
|
13202
13225
|
var AvatarStage = class {
|
|
13203
13226
|
container;
|
|
13204
13227
|
opts;
|
|
@@ -13934,6 +13957,7 @@ var HackbuildMotionViews = (function(exports, three) {
|
|
|
13934
13957
|
};
|
|
13935
13958
|
}
|
|
13936
13959
|
// src/gestures.ts
|
|
13960
|
+
/** Every gesture `gestureClip` can make. */
|
|
13937
13961
|
const GESTURES = [
|
|
13938
13962
|
"wave",
|
|
13939
13963
|
"nod",
|
package/dist/words.d.ts
CHANGED
|
@@ -12,12 +12,14 @@ export interface RigFacts {
|
|
|
12
12
|
/** Load warnings from the avatar package, already in plain words. */
|
|
13
13
|
warnings?: readonly string[];
|
|
14
14
|
}
|
|
15
|
+
/** How a rig check line reads: fine, a limit, or a blocker. */
|
|
15
16
|
export type RigTone = "ok" | "warn" | "bad";
|
|
16
17
|
/** One line of the rig check: what works or what does not, and why. */
|
|
17
18
|
export interface RigLine {
|
|
18
19
|
tone: RigTone;
|
|
19
20
|
text: string;
|
|
20
21
|
}
|
|
22
|
+
/** The rig check: overall tone, a headline and the lines worst first. */
|
|
21
23
|
export interface RigCheck {
|
|
22
24
|
tone: RigTone;
|
|
23
25
|
/** The headline: "ready to act", "ready, with limits", "cannot act". */
|
|
@@ -28,6 +30,7 @@ export interface RigCheck {
|
|
|
28
30
|
export declare function rigCheck(f: RigFacts): RigCheck;
|
|
29
31
|
/** Bytes as "820 kb" or "12.4 mb". */
|
|
30
32
|
export declare function bytesWord(n: number): string;
|
|
33
|
+
/** The facts the size line reads: bytes, format, file and triangle counts. */
|
|
31
34
|
export interface SizeFacts {
|
|
32
35
|
/** Every file of the drop, model and textures. */
|
|
33
36
|
bytes: number;
|
package/llms.md
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
# @hackbuild/motion-views
|
|
2
|
+
|
|
3
|
+
> Put a character stage, an avatar drop card and a clip strip on your page, drawn with the hackbuild-ui stylesheet, as custom elements or Vue components.
|
|
4
|
+
|
|
5
|
+
Generated by tools/llms.mjs from the TypeDoc JSON, the README and the examples of hackbuild-motion. Human docs: https://hackbuild.github.io/hackbuild-motion/docs/motion-views/
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
- `CharacterStage`: a body on a lit stage with idle, gaze, blinks and lips, a corner plate, turn around and framing tools, a verb row and an inset slot. It speaks real audio with word timings, or text alone on estimated timings.
|
|
10
|
+
- `AvatarDrop`: a drop zone and pick button that loads a VRM, GLB or FBX once, checks its rig in plain words, draws a still and shows the avatar card.
|
|
11
|
+
- `ClipStrip`: each clip's still, name and length, the picked one pressed and one play button.
|
|
12
|
+
- Ships every view as a mount function, a custom element and a Vue 3 component, on one code path.
|
|
13
|
+
- Carries no styles of its own; every class is hackbuild-ui's.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install @hackbuild/motion-views three @virgilvox/hackbuild-ui
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@virgilvox/hackbuild-ui` 0.10 is a required peer, and the page loads its stylesheet (`@virgilvox/hackbuild-ui/styles.css`). three.js is needed by the views; Vue only by `/vue`. It depends on `@hackbuild/avatar`, `@hackbuild/avatar-host`, `@hackbuild/presence`, `@hackbuild/lipsync` and `@hackbuild/organic`, which install with it.
|
|
22
|
+
|
|
23
|
+
| subpath | needs | pin |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `@hackbuild/motion-views` | nothing; the words, clip items and speech timings | none |
|
|
26
|
+
| `@hackbuild/motion-views/vanilla` | `three` (optional peer), `@virgilvox/hackbuild-ui` (peer) | three 0.186.1 or later, hackbuild-ui `>=0.10.0 <0.11.0` |
|
|
27
|
+
| `@hackbuild/motion-views/vue` | `vue` (optional peer) and the above | vue 3.5.0 or later |
|
|
28
|
+
| `@hackbuild/motion-views/iife` | `THREE` on the page | one classic script |
|
|
29
|
+
|
|
30
|
+
## Exports
|
|
31
|
+
|
|
32
|
+
### @hackbuild/motion-views
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
function bytesWord(n: number): string
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Bytes as "820 kb" or "12.4 mb".
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
type ClipFrom = "bake" | "retarget" | "body" | "code"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Where a clip came from: a baked pack, a retarget, the body's own file, or code.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
function clipFromFindings(id: string, name: string, f: FindingsLike): ClipItem
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
An item from a retargeted motion and its findings.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
interface ClipItem {
|
|
54
|
+
from: ClipFrom;
|
|
55
|
+
id: string;
|
|
56
|
+
loop: boolean;
|
|
57
|
+
name: string;
|
|
58
|
+
seconds: number;
|
|
59
|
+
tags?: string[];
|
|
60
|
+
thumb?: string | Blob;
|
|
61
|
+
warn?: string;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
One clip as the strip shows it: id, name, length, loop, source, tags, warning and still.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
function clipMeta(c: Pick<ClipItem, "seconds" | "loop" | "tags">): string
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The strip's second line: "2.4 s, loops" or "walk, 2.4 s, loops".
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
function clipsFromBody(clips: readonly { duration: number; name: string }[], prefix?: string): ClipItem[]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Items for the clips a loaded file carries, by name and length.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
function clipsFromPack(pack: PackLike, report?: readonly PackReportLike[], prefix?: string): ClipItem[]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Items from a clip pack, with the bake report's seam check as a warning.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
function estimateSeconds(text: string): number
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Seconds text takes on estimated timings: about 0.34 s a word (inferred), at least 0.8 s.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
interface FindingsLike {
|
|
93
|
+
duration: number;
|
|
94
|
+
looping: boolean;
|
|
95
|
+
tags: readonly string[];
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
What retarget's analyzeMotion returns, in the fields the strip reads.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
function licenceLine(format: string, meta: LicenceMeta | null | undefined): RigLine
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The licence line.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
interface LicenceMeta {
|
|
109
|
+
allowRedistribution?: boolean;
|
|
110
|
+
commercialUsage?: string;
|
|
111
|
+
licenseName?: string;
|
|
112
|
+
licenseUrl?: string;
|
|
113
|
+
metaVersion?: string;
|
|
114
|
+
modification?: string;
|
|
115
|
+
otherLicenseUrl?: string;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
VRM metadata fields the licence line reads (VRM 1.0 and 0.x).
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
function nextClip(items: readonly ClipItem[], id: string | null, step?: number): string | null
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The next id after `id` in the strip, wrapping, for a key or a play all.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
interface PackLike {
|
|
129
|
+
clips: Record<string, { dur: number; loop: boolean; n: number; name: string }>;
|
|
130
|
+
fps: number;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
What bake's decodePack returns, in the fields the strip reads.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
interface PackReportLike {
|
|
138
|
+
maxAngleErrorDeg: number;
|
|
139
|
+
name: string;
|
|
140
|
+
seamAngleDeg: number | null;
|
|
141
|
+
seamOk: boolean | null;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
What bake's bakeClips reports per clip, in the fields the strip reads.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
function rigCheck(f: RigFacts): RigCheck
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The rig check in plain words, worst first.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
interface RigCheck {
|
|
155
|
+
head: string;
|
|
156
|
+
lines: RigLine[];
|
|
157
|
+
tone: RigTone;
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The rig check: overall tone, a headline and the lines worst first.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
interface RigFacts {
|
|
165
|
+
blink: boolean;
|
|
166
|
+
bones: readonly string[];
|
|
167
|
+
clips: readonly string[];
|
|
168
|
+
expressions: readonly string[];
|
|
169
|
+
gaze: boolean;
|
|
170
|
+
mouth: boolean;
|
|
171
|
+
warnings?: readonly string[];
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
What a loaded body can do, as @hackbuild/avatar-host reports it in BodyCaps.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
interface RigLine {
|
|
179
|
+
text: string;
|
|
180
|
+
tone: RigTone;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
One line of the rig check: what works or what does not, and why.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
type RigTone = "ok" | "warn" | "bad"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
How a rig check line reads: fine, a limit, or a blocker.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
function secondsWord(s: number): string
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
A clip's length: "2.4 s", "0.5 s", "1 min 12 s".
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
interface SizeFacts {
|
|
200
|
+
bytes: number;
|
|
201
|
+
files?: number;
|
|
202
|
+
format: string;
|
|
203
|
+
triangles?: number;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The facts the size line reads: bytes, format, file and triangle counts.
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
function sizeLine(s: SizeFacts): string
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The size line: "12.4 mb vrm, 3 files, 38 k triangles".
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
interface Speech {
|
|
217
|
+
audio?: AudioBuffer | HTMLMediaElement;
|
|
218
|
+
events?: readonly SpeechEvent[];
|
|
219
|
+
phonemes?: readonly SpeechTiming[];
|
|
220
|
+
text?: string;
|
|
221
|
+
words?: readonly SpeechTiming[];
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Something to say.
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
function speechEvents(s: Speech, t0: number, seconds: number): { events: SpeechEvent[]; source: SpeechSource }
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The mouth events for a speech starting at `t0` on the mouth clock and lasting `seconds`, closed by an end event, and where they came from.
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
type SpeechSource = "events" | "phonemes" | "words" | "estimate" | "audio level"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Where the mouth timings come from, for the readout and the tests.
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
interface SpeechTiming {
|
|
241
|
+
end?: number;
|
|
242
|
+
phoneme?: string;
|
|
243
|
+
start?: number;
|
|
244
|
+
t0: number;
|
|
245
|
+
t1: number;
|
|
246
|
+
text?: string;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
A word or phoneme with its time from the start of the audio, as @hackbuild/speak reports it.
|
|
251
|
+
|
|
252
|
+
### @hackbuild/motion-views/vanilla
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
function animationClipOf(clip: Clip, names: readonly string[]): AnimationClip
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
A presence clip as a three.js AnimationClip with one quaternion track per bone object name.
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
function avatarDrop(host: HTMLElement, opts?: AvatarDropOptions): AvatarDropHandle
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Mounts the drop card into `host`.
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
interface AvatarDropElement extends HTMLElement {
|
|
268
|
+
readonly handle: AvatarDropHandle | null;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The hb-avatar-drop element, with its view handle once connected.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
type AvatarDropEvent = { files: readonly DroppedFile[]; type: "picked" } | { files: readonly DroppedFile[]; report: AvatarReport; type: "checked" } | { message: string; type: "failed" } | { files: readonly DroppedFile[]; report: AvatarReport; type: "use" }
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Events of AvatarDrop: files picked, the report checked, a failure, or the card pressed to use the avatar.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
interface AvatarDropHandle {
|
|
282
|
+
readonly report: AvatarReport | null;
|
|
283
|
+
dispose(): void;
|
|
284
|
+
on(fn: (e: AvatarDropEvent) => void): () => void;
|
|
285
|
+
pick(): void;
|
|
286
|
+
take(files: readonly DroppedFile[]): Promise<AvatarReport | null>;
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The handle `avatarDrop` returns: the last report, take files, open the picker, listen, dispose.
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
interface AvatarDropOptions extends BodyLoadOptions {
|
|
294
|
+
go?: boolean;
|
|
295
|
+
hint?: string;
|
|
296
|
+
label?: string;
|
|
297
|
+
normalize?: NormalizeOptions;
|
|
298
|
+
repair?: false | RepairOptions;
|
|
299
|
+
vrm?: () => Promise<VrmHook>;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Options of `avatarDrop`: the load options of a body plus the pick button and hint words.
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
interface AvatarReport {
|
|
307
|
+
bytes: number;
|
|
308
|
+
caps: BodyCaps;
|
|
309
|
+
check: RigCheck;
|
|
310
|
+
files: number;
|
|
311
|
+
format: string;
|
|
312
|
+
licence: RigLine;
|
|
313
|
+
name: string;
|
|
314
|
+
size: string;
|
|
315
|
+
thumb: Blob | null;
|
|
316
|
+
triangles: number;
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
What AvatarDrop learned about a dropped avatar: name, format, size, rig check, licence and still.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
function characterStage(host: HTMLElement, opts?: CharacterStageOptions): CharacterStageHandle
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Mounts a character stage into `host`, which becomes the `.hb-lay-stage`.
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
interface CharacterStageElement extends HTMLElement {
|
|
330
|
+
readonly handle: CharacterStageHandle | null;
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
The hb-character-stage element, with its view handle once connected.
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
type CharacterStageEvent = { caps: BodyCaps; name: string; placeholder: boolean; type: "loaded"; warnings: string[] } | { message: string; type: "failed" } | { type: "doing"; word: string } | { id: string; type: "verb" } | { framing: Framing; type: "framing" }
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Events of CharacterStage: a body loaded or failed, what it is doing, a verb pressed, the framing changed.
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
interface CharacterStageHandle {
|
|
344
|
+
readonly body: Body | null;
|
|
345
|
+
readonly doing: string;
|
|
346
|
+
readonly framing: Framing;
|
|
347
|
+
readonly inset: HTMLElement;
|
|
348
|
+
readonly speechSource: SpeechSource | null;
|
|
349
|
+
readonly stage: AvatarStage;
|
|
350
|
+
readonly subject: HTMLElement;
|
|
351
|
+
readonly verbsEl: HTMLElement;
|
|
352
|
+
dispose(): void;
|
|
353
|
+
frame(mode: Framing): void;
|
|
354
|
+
gesture(id: Gesture): boolean;
|
|
355
|
+
on(fn: (e: CharacterStageEvent) => void): () => void;
|
|
356
|
+
play(clip: string | Clip | AnimationClip, opts?: PlayOptions): number;
|
|
357
|
+
say(speech: string | Speech, seconds?: number): Promise<void>;
|
|
358
|
+
setVerbs(verbs: readonly Verb[]): void;
|
|
359
|
+
show(source: string | BodySource | readonly DroppedFile[]): Promise<Body | null>;
|
|
360
|
+
showPlaceholder(): void;
|
|
361
|
+
stop(): void;
|
|
362
|
+
turn(): void;
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The handle `characterStage` returns: show a body, speak, gesture, play clips, frame and listen.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
interface CharacterStageOptions extends StageOptions {
|
|
370
|
+
audioContext?: AudioContext;
|
|
371
|
+
background?: number | null;
|
|
372
|
+
body?: Omit<BodyOptions, "rng">;
|
|
373
|
+
canvas?: HTMLCanvasElement;
|
|
374
|
+
drop?: boolean;
|
|
375
|
+
environment?: string | EnvironmentRequest;
|
|
376
|
+
follow?: FollowOptions;
|
|
377
|
+
framing?: Framing;
|
|
378
|
+
hello?: string | Speech | () => Speech | Promise<Speech>;
|
|
379
|
+
lights?: boolean;
|
|
380
|
+
maxPixelRatio?: number;
|
|
381
|
+
name?: string;
|
|
382
|
+
normalize?: NormalizeOptions;
|
|
383
|
+
repair?: false | RepairOptions;
|
|
384
|
+
restoreButton?: boolean;
|
|
385
|
+
rng?: Rng;
|
|
386
|
+
src?: string;
|
|
387
|
+
statsEvery?: number;
|
|
388
|
+
verbs?: readonly Verb[];
|
|
389
|
+
vrm?: () => Promise<VrmHook>;
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Options of `characterStage`: stage options plus name, model URL, verbs, framing, drop and the hello speech.
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
function clipStrip(host: HTMLElement, opts?: ClipStripOptions): ClipStripHandle
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Mounts a clip strip into `host`.
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
interface ClipStripElement extends HTMLElement {
|
|
403
|
+
current: string | null;
|
|
404
|
+
readonly handle: ClipStripHandle | null;
|
|
405
|
+
items: readonly StripItem[];
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
The hb-clip-strip element, with its view handle and the items and picked clip as properties.
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
type ClipStripEvent = { item: StripItem; type: "pick" } | { item: StripItem; type: "play" } | { item: StripItem; type: "stop" } | { id: string; ok: boolean; type: "thumb" }
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Events of ClipStrip: a clip picked, play or stop pressed, a still drawn or failed.
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
interface ClipStripHandle {
|
|
419
|
+
readonly current: StripItem | null;
|
|
420
|
+
readonly playing: boolean;
|
|
421
|
+
dispose(): void;
|
|
422
|
+
on(fn: (e: ClipStripEvent) => void): () => void;
|
|
423
|
+
pick(id: string): void;
|
|
424
|
+
setItems(items: readonly StripItem[], current?: string | null): void;
|
|
425
|
+
setPlaying(on: boolean): void;
|
|
426
|
+
thumbsIdle(): Promise<void>;
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
The handle `clipStrip` returns: set items, pick, set the play state, wait for stills, listen.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
interface ClipStripOptions {
|
|
434
|
+
current?: string | null;
|
|
435
|
+
go?: boolean;
|
|
436
|
+
items?: readonly StripItem[];
|
|
437
|
+
label?: string;
|
|
438
|
+
thumbs?: boolean;
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Options of `clipStrip`: the items, the picked clip, the play button and stills.
|
|
443
|
+
|
|
444
|
+
```ts
|
|
445
|
+
const DEFAULT_VERBS: readonly Verb[]
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
The verbs a stage shows by default: say hello is the next thing to do.
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
function defineMotionViews(opts?: MotionViewsOptions): void
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Defines hb-character-stage, hb-avatar-drop and hb-clip-strip once.
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
type Framing = "bust" | "full"
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
The stage shot: bust, or the full body.
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
type Gesture = "wave" | "nod" | "shake" | "bow"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
A gesture written in code over the body's own bones.
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
function gestureClip(id: Gesture, names: readonly string[], base: ArrayLike<number>, fps?: number): Clip | null
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
A gesture as a presence clip over `names`, starting from `base` (bones times 4 local rotations, the pose when it was built).
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
const GESTURES: readonly Gesture[]
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Every gesture `gestureClip` can make.
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
interface MotionViewsOptions {
|
|
482
|
+
drop?: AvatarDropOptions;
|
|
483
|
+
stage?: CharacterStageOptions;
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Options `defineMotionViews` shares with every element it defines.
|
|
488
|
+
|
|
489
|
+
```ts
|
|
490
|
+
interface StripItem extends ClipItem {
|
|
491
|
+
animation?: () => AnimationClip | Promise<AnimationClip>;
|
|
492
|
+
from: ClipFrom;
|
|
493
|
+
id: string;
|
|
494
|
+
loop: boolean;
|
|
495
|
+
name: string;
|
|
496
|
+
seconds: number;
|
|
497
|
+
tags?: string[];
|
|
498
|
+
thumb?: string | Blob;
|
|
499
|
+
warn?: string;
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
A clip in the strip; `animation` lets the strip draw its still.
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
interface Verb {
|
|
507
|
+
go?: boolean;
|
|
508
|
+
id: string;
|
|
509
|
+
label: string;
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
One verb on the stage.
|
|
514
|
+
|
|
515
|
+
### @hackbuild/motion-views/vue
|
|
516
|
+
|
|
517
|
+
```ts
|
|
518
|
+
const AvatarDrop: DefineComponent<ExtractPropTypes<{ go: { default: boolean; type: BooleanConstructor }; label: { default: undefined; type: StringConstructor }; options: { default: () => {}; type: PropType<AvatarDropOptions> } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("failed" | "picked" | "checked" | "use")[], "failed" | "picked" | "checked" | "use", PublicProps, ToResolvedProps<ExtractPropTypes<{ go: { default: boolean; type: BooleanConstructor }; label: { default: undefined; type: StringConstructor }; options: { default: () => {}; type: PropType<AvatarDropOptions> } }>, ("failed" | "picked" | "checked" | "use")[]>, { go: boolean; label: string; options: AvatarDropOptions }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
The avatar drop card: zone, still, size, licence and rig check.
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
const CharacterStage: DefineComponent<ExtractPropTypes<{ drop: { default: boolean; type: BooleanConstructor }; framing: { default: string; type: PropType<Framing> }; name: { default: undefined; type: StringConstructor }; options: { default: () => {}; type: PropType<CharacterStageOptions> }; src: { default: undefined; type: StringConstructor }; verbs: { default: () => readonly Verb[]; type: PropType<readonly Verb[]> } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("loaded" | "failed" | "doing" | "verb" | "framing")[], "loaded" | "failed" | "doing" | "verb" | "framing", PublicProps, ToResolvedProps<ExtractPropTypes<{ drop: { default: boolean; type: BooleanConstructor }; framing: { default: string; type: PropType<Framing> }; name: { default: undefined; type: StringConstructor }; options: { default: () => {}; type: PropType<CharacterStageOptions> }; src: { default: undefined; type: StringConstructor }; verbs: { default: () => readonly Verb[]; type: PropType<readonly Verb[]> } }>, ("loaded" | "failed" | "doing" | "verb" | "framing")[]>, { drop: boolean; framing: Framing; name: string; options: CharacterStageOptions; src: string; verbs: readonly Verb[] }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
The character stage.
|
|
528
|
+
|
|
529
|
+
```ts
|
|
530
|
+
const ClipStrip: DefineComponent<ExtractPropTypes<{ current: { default: null; type: PropType<string | null> }; go: { default: boolean; type: BooleanConstructor }; items: { default: () => never[]; type: PropType<readonly StripItem[]> }; label: { default: string; type: StringConstructor }; playing: { default: boolean; type: BooleanConstructor } }>, () => VNode<RendererNode, RendererElement, { [key: string]: any }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("play" | "pick" | "stop" | "thumb")[], "play" | "pick" | "stop" | "thumb", PublicProps, ToResolvedProps<ExtractPropTypes<{ current: { default: null; type: PropType<string | null> }; go: { default: boolean; type: BooleanConstructor }; items: { default: () => never[]; type: PropType<readonly StripItem[]> }; label: { default: string; type: StringConstructor }; playing: { default: boolean; type: BooleanConstructor } }>, ("play" | "pick" | "stop" | "thumb")[]>, { current: string | null; go: boolean; items: readonly StripItem[]; label: string; playing: boolean }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
The clip strip: stills to pick from and one play button.
|
|
534
|
+
|
|
535
|
+
## Examples
|
|
536
|
+
|
|
537
|
+
### quick start
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
import { avatarDrop, characterStage } from "@hackbuild/motion-views/vanilla";
|
|
541
|
+
|
|
542
|
+
// the stage shows a placeholder body built in code until you give it one
|
|
543
|
+
const host = document.createElement("div");
|
|
544
|
+
host.style.height = "480px";
|
|
545
|
+
document.body.append(host);
|
|
546
|
+
const stage = characterStage(host, { name: "stand-in", hello: "hello. drop a vrm, glb or fbx on me." });
|
|
547
|
+
stage.on((e) => e.type === "doing" && console.log("doing", e.word));
|
|
548
|
+
|
|
549
|
+
// a drop card: press the card of a checked avatar to put it on the stage
|
|
550
|
+
const card = document.body.appendChild(document.createElement("div"));
|
|
551
|
+
avatarDrop(card).on((e) => {
|
|
552
|
+
if (e.type === "checked") console.log(e.report.check.head, e.report.size);
|
|
553
|
+
if (e.type === "use") void stage.show(e.files);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
// text alone moves the lips on estimated word timings, with no sound
|
|
557
|
+
await stage.say("you can drop a model on me");
|
|
558
|
+
stage.gesture("wave");
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### from the concepts
|
|
562
|
+
|
|
563
|
+
```ts
|
|
564
|
+
defineMotionViews({ stage: { vrm: () => import("@hackbuild/avatar/vrm").then((m) => m.vrmHook()) } });
|
|
565
|
+
const stage = document.querySelector<CharacterStageElement>("hb-character-stage")!;
|
|
566
|
+
document.querySelector("hb-avatar-drop")!.addEventListener("picked", (e) => stage.handle?.show((e as CustomEvent).detail.files));
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Mistakes to avoid
|
|
570
|
+
|
|
571
|
+
- Load the hackbuild-ui stylesheet on the page; the views add no styles and look broken without it.
|
|
572
|
+
- Call `defineMotionViews()` once before using the elements; importing `/vanilla` defines nothing.
|
|
573
|
+
- Pass the VRM hook (`vrm: () => import("@hackbuild/avatar/vrm").then((m) => m.vrmHook())`) to read VRM files as VRM; without it a .vrm loads as plain glTF.
|
|
574
|
+
- Call `dispose()` on a handle you mount yourself; it stops the audio and frees the stage.
|
|
575
|
+
|
|
576
|
+
## Errors this package throws
|
|
577
|
+
|
|
578
|
+
- a `failed` event from CharacterStage (the body could not load from the URL or files): read `e.message`; give the model with its textures, or a VRM, GLB or FBX
|
|
579
|
+
- a `failed` event from AvatarDrop (the dropped files held no body it could read): drop a .vrm, .glb, .gltf with its .bin and textures, or .fbx
|
|
580
|
+
- `-1` from `play` (the clip cannot play on this body): check the body has the bones the clip moves
|
|
581
|
+
- `false` from `gesture` (the body lacks the bones the gesture needs): check the rig check lines of the body
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/motion-views",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The motion views: CharacterStage, AvatarDrop and ClipStrip, binding the motion packages to hackbuild-ui, each as a Vue component and a custom element.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|
|
36
36
|
"README.md",
|
|
37
|
+
"llms.md",
|
|
37
38
|
"LICENSE",
|
|
38
39
|
"how.ts"
|
|
39
40
|
],
|
|
@@ -41,11 +42,11 @@
|
|
|
41
42
|
"build": "node ../../tools/build-package.mjs motion-views"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@hackbuild/avatar": "0.1.
|
|
45
|
-
"@hackbuild/avatar-host": "0.1.
|
|
46
|
-
"@hackbuild/lipsync": "0.1.
|
|
47
|
-
"@hackbuild/organic": "0.1.
|
|
48
|
-
"@hackbuild/presence": "0.1.
|
|
45
|
+
"@hackbuild/avatar": "0.1.4",
|
|
46
|
+
"@hackbuild/avatar-host": "0.1.6",
|
|
47
|
+
"@hackbuild/lipsync": "0.1.2",
|
|
48
|
+
"@hackbuild/organic": "0.1.2",
|
|
49
|
+
"@hackbuild/presence": "0.1.2"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"@virgilvox/hackbuild-ui": ">=0.10.0 <0.11.0",
|