@hackbuild/motion-views 0.1.0 → 0.1.2
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 +161 -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 +599 -1
- package/dist/stage.d.ts +104 -0
- package/dist/stage.js +256 -0
- package/dist/vanilla.d.ts +1 -0
- package/dist/vanilla.js +3 -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,181 @@
|
|
|
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
|
+
| [`threeStage`](../../docs/api/motion-views/vanilla.md#threestage) | a lit stage that fills an element, ticks and frees itself |
|
|
98
|
+
| [`meshTurntable`](../../docs/api/motion-views/vanilla.md#meshturntable) | one object on a stage you drag to turn, for a relief or a surface |
|
|
99
|
+
| [`stageOrbit`](../../docs/api/motion-views/vanilla.md#stageorbit) | drag to turn a camera round a target, the wheel moves in and out |
|
|
100
|
+
| [`boxDog`](../../docs/api/motion-views/vanilla.md#boxdog) | a dog of bones and boxes with the bone names in `BOX_DOG_BONES` |
|
|
101
|
+
| [`walkBvh`](../../docs/api/motion-views/vanilla.md#walkbvh) | a walk loop as bvh text for another rig, to retarget |
|
|
102
|
+
| [`freeMeshes`](../../docs/api/motion-views/vanilla.md#freemeshes) | free the geometry and materials under an object |
|
|
103
|
+
| [`CharacterStage`](../../docs/api/motion-views/vue.md#characterstage) | the stage as a Vue component |
|
|
104
|
+
| [`AvatarDrop`](../../docs/api/motion-views/vue.md#avatardrop) | the drop card as a Vue component |
|
|
105
|
+
| [`ClipStrip`](../../docs/api/motion-views/vue.md#clipstrip) | the strip as a Vue component |
|
|
106
|
+
| [`rigCheck`](../../docs/api/motion-views/index.md#rigcheck) | what a body can do, in plain words |
|
|
107
|
+
| [`sizeLine`](../../docs/api/motion-views/index.md#sizeline) | the size line of the avatar card |
|
|
108
|
+
| [`clipsFromPack`](../../docs/api/motion-views/index.md#clipsfrompack) | clip items from a baked pack |
|
|
109
|
+
| [`speechEvents`](../../docs/api/motion-views/index.md#speechevents) | what a speech becomes on the mouth clock |
|
|
110
|
+
|
|
111
|
+
The full reference is in [docs/api/motion-views](../../docs/api/motion-views/README.md).
|
|
112
|
+
|
|
113
|
+
## Browser support
|
|
114
|
+
|
|
115
|
+
| feature | needs | notes |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| main entry | any JavaScript runtime | no DOM, no three.js, runs in Node |
|
|
118
|
+
| the views | WebGL through three.js, custom elements | the stage pauses while hidden or off screen |
|
|
119
|
+
| real speech | Web Audio | an AudioContext is made on the first audio unless you pass `audioContext` |
|
|
120
|
+
| avatar stills | WebGL | `report.thumb` is null with no WebGL |
|
|
121
|
+
| single file build | `dist/motion-views.iife.js` | the vanilla entry as one classic script, `THREE` read from the page, runs from file:// |
|
|
122
|
+
|
|
123
|
+
The views ran in headless Chrome on macOS; Safari, Firefox and phones are unknown.
|
|
124
|
+
|
|
125
|
+
## Errors and troubleshooting
|
|
126
|
+
|
|
127
|
+
The views throw nothing to your code; a failure becomes an event and a plain line on screen.
|
|
128
|
+
|
|
129
|
+
| message | cause | what to do |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| 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 |
|
|
132
|
+
| 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 |
|
|
133
|
+
| `-1` from `play` | the clip cannot play on this body | check the body has the bones the clip moves |
|
|
134
|
+
| `false` from `gesture` | the body lacks the bones the gesture needs | check the rig check lines of the body |
|
|
135
|
+
|
|
136
|
+
## Works with
|
|
137
|
+
|
|
138
|
+
- [@hackbuild/avatar-host](../avatar-host/README.md) is the stage under CharacterStage and draws the clip stills.
|
|
139
|
+
- [@hackbuild/avatar](../avatar/README.md) loads the VRM, GLB and FBX files.
|
|
140
|
+
- [@hackbuild/presence](../presence/README.md) and [@hackbuild/lipsync](../lipsync/README.md) give idle, gaze, blinks and lips.
|
|
141
|
+
- [@hackbuild/bake](../bake/README.md) and [@hackbuild/retarget](../retarget/README.md) make the clips the strip lists.
|
|
142
|
+
|
|
143
|
+
## Changelog and licences
|
|
144
|
+
|
|
145
|
+
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
146
|
|
|
71
147
|
## What is verified, and what is not
|
|
72
148
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
149
|
+
### Verified on this machine
|
|
150
|
+
|
|
151
|
+
| check | result |
|
|
152
|
+
|---|---|
|
|
153
|
+
| `node tools/smoke-views.mjs` in headless Chrome on macOS 12 | pass |
|
|
154
|
+
| the stand-in shows and a frame is drawn | pass |
|
|
155
|
+
| the full body shot stands further back than the bust | 2.78 m to 4.03 m (measured) |
|
|
156
|
+
| say hello plays audio written in code with word timings and the level reaches the lips | peak 0.215 (measured) |
|
|
157
|
+
| audio with no timings moves the lips by level; text alone falls back to estimated timings; quiet when the audio ends | pass |
|
|
158
|
+
| wave plays on the upper body; turn around turns the body half a circle | pass |
|
|
159
|
+
| the stand-in written as a .glb loads, maps 24 bones, gets a still and reads "no licence in the file" | pass (measured) |
|
|
160
|
+
| a text file is refused in plain words | pass |
|
|
161
|
+
| 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 |
|
|
162
|
+
| the three demo pages at 1440 and 390 px against the suite's screen gate | pass |
|
|
163
|
+
| unit tests over the words and the clip items | pass |
|
|
164
|
+
|
|
165
|
+
### Not verified by anything
|
|
166
|
+
|
|
167
|
+
- Speech from a real speech engine; the smoke's voice is a hum written in code with word timings in an engine's shape.
|
|
168
|
+
- 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.
|
|
169
|
+
- The Vue components in a running Vue app; they typecheck, and no page mounts them yet.
|
|
170
|
+
- Frame rate on a real GPU, since the smoke runs headless.
|
|
171
|
+
- AvatarDrop loads the file once and the stage loads it again, so a large file is read twice.
|
|
96
172
|
|
|
97
173
|
## Size budget
|
|
98
174
|
|
|
99
175
|
| file | gzip (measured) | ceiling |
|
|
100
176
|
|---|---|---|
|
|
101
177
|
| `dist/index.js` (main entry, imports external) | 3,266 bytes | 3,429 bytes |
|
|
102
|
-
| `dist/motion-views.iife.js` (single file build) |
|
|
178
|
+
| `dist/motion-views.iife.js` (single file build) | 215,543 bytes | 226,320 bytes |
|
|
103
179
|
|
|
104
180
|
Measured 2026-11-25 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
|
|
105
181
|
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 = {
|