open-bot-avatar 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +126 -2
- package/dist/animator.d.ts +32 -0
- package/dist/animator.d.ts.map +1 -0
- package/dist/animator.js +43 -0
- package/dist/animator.js.map +1 -0
- package/dist/color.d.ts +19 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +50 -0
- package/dist/color.js.map +1 -0
- package/dist/contour.d.ts +22 -0
- package/dist/contour.d.ts.map +1 -0
- package/dist/contour.js +133 -0
- package/dist/contour.js.map +1 -0
- package/dist/dom/clock.d.ts +26 -0
- package/dist/dom/clock.d.ts.map +1 -0
- package/dist/dom/clock.js +47 -0
- package/dist/dom/clock.js.map +1 -0
- package/dist/dom/index.d.ts +7 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +5 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/mount.d.ts +38 -0
- package/dist/dom/mount.d.ts.map +1 -0
- package/dist/dom/mount.js +198 -0
- package/dist/dom/mount.js.map +1 -0
- package/dist/dom/pointer.d.ts +3 -0
- package/dist/dom/pointer.d.ts.map +1 -0
- package/dist/dom/pointer.js +52 -0
- package/dist/dom/pointer.js.map +1 -0
- package/dist/dom/reduced.d.ts +2 -0
- package/dist/dom/reduced.d.ts.map +1 -0
- package/dist/dom/reduced.js +16 -0
- package/dist/dom/reduced.js.map +1 -0
- package/dist/examples.d.ts +13 -0
- package/dist/examples.d.ts.map +1 -0
- package/dist/examples.js +103 -0
- package/dist/examples.js.map +1 -0
- package/dist/follow.d.ts +60 -0
- package/dist/follow.d.ts.map +1 -0
- package/dist/follow.js +67 -0
- package/dist/follow.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mood.d.ts +23 -0
- package/dist/mood.d.ts.map +1 -0
- package/dist/mood.js +26 -0
- package/dist/mood.js.map +1 -0
- package/dist/motion.d.ts +72 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +162 -0
- package/dist/motion.js.map +1 -0
- package/dist/path.d.ts +77 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +406 -0
- package/dist/path.js.map +1 -0
- package/dist/render.d.ts +115 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +324 -0
- package/dist/render.js.map +1 -0
- package/dist/seams.d.ts +16 -0
- package/dist/seams.d.ts.map +1 -0
- package/dist/seams.js +109 -0
- package/dist/seams.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.d.ts +73 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +266 -0
- package/dist/validate.js.map +1 -0
- package/dist/volume.d.ts +113 -0
- package/dist/volume.d.ts.map +1 -0
- package/dist/volume.js +582 -0
- package/dist/volume.js.map +1 -0
- package/package.json +43 -3
- package/src/animator.ts +69 -0
- package/src/color.ts +57 -0
- package/src/contour.ts +126 -0
- package/src/dom/clock.ts +63 -0
- package/src/dom/index.ts +6 -0
- package/src/dom/mount.ts +245 -0
- package/src/dom/pointer.ts +51 -0
- package/src/dom/reduced.ts +18 -0
- package/src/examples.ts +112 -0
- package/src/follow.ts +81 -0
- package/src/index.ts +21 -0
- package/src/mood.ts +39 -0
- package/src/motion.ts +209 -0
- package/src/path.ts +319 -0
- package/src/render.ts +461 -0
- package/src/seams.ts +111 -0
- package/src/types.ts +74 -0
- package/src/validate.ts +282 -0
- package/src/volume.ts +640 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/dom/mount.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAKjF,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,IAAI,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,iFAAiF;IACjF,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC,mEAAmE;IACnE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IAC9C,OAAO,IAAI,IAAI,CAAC;CACjB;AAsED,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CA4HpF"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A live avatar in any DOM element, without a framework.
|
|
3
|
+
*
|
|
4
|
+
* const avatar = mountAvatar(el, { definition, color: '#1f7cf2', followPointer: true });
|
|
5
|
+
* avatar.update({ mood: 'happy' });
|
|
6
|
+
* avatar.destroy();
|
|
7
|
+
*
|
|
8
|
+
* Live avatars are a CSS 3D scene: every cross-section of the inferred volume
|
|
9
|
+
* is mounted once as its own small SVG, and each frame only writes a few CSS
|
|
10
|
+
* transforms (view, hop/roll/squash, the eyes' gaze and blink). Changing the
|
|
11
|
+
* color only changes CSS `color`. `still` avatars are a single static SVG and
|
|
12
|
+
* never animate. Every avatar on the page shares one animation loop.
|
|
13
|
+
*/
|
|
14
|
+
import { createAnimator } from '../animator.js';
|
|
15
|
+
import { pointerGaze } from '../follow.js';
|
|
16
|
+
import { DEFAULT_COLOR, DEFAULT_EYE_COLOR, renderAvatarScene, renderAvatarSvg, sceneFrame } from '../render.js';
|
|
17
|
+
import { requestFrame, subscribeFrames } from './clock.js';
|
|
18
|
+
import { trackPointer } from './pointer.js';
|
|
19
|
+
import { prefersReducedMotion } from './reduced.js';
|
|
20
|
+
function mountScene(el, definition, depth) {
|
|
21
|
+
el.innerHTML = renderAvatarScene(definition, { depth });
|
|
22
|
+
const q = (s) => el.querySelector(s);
|
|
23
|
+
return {
|
|
24
|
+
key: q('[data-avatar-scene]').dataset.avatarScene ?? '',
|
|
25
|
+
geometry: geometryKey(definition),
|
|
26
|
+
motion: q('[data-motion]'),
|
|
27
|
+
view: q('[data-view]'),
|
|
28
|
+
stacks: { z: q('[data-stack="z"]'), x: q('[data-stack="x"]') },
|
|
29
|
+
eyes: [0, 1].map((i) => {
|
|
30
|
+
const root = q(`[data-eye="${i}"]`);
|
|
31
|
+
return { root, pill: root.querySelector('i'), arc: root.querySelector('svg') };
|
|
32
|
+
}),
|
|
33
|
+
last: {},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Write a style property only when its value changed since the last frame. */
|
|
37
|
+
function put(m, key, el, prop, value) {
|
|
38
|
+
if (m.last[key] === value)
|
|
39
|
+
return;
|
|
40
|
+
m.last[key] = value;
|
|
41
|
+
el.style[prop] = value;
|
|
42
|
+
}
|
|
43
|
+
function apply(m, frame) {
|
|
44
|
+
put(m, 'motion', m.motion, 'transform', frame.motion);
|
|
45
|
+
put(m, 'view', m.view, 'transform', frame.view);
|
|
46
|
+
put(m, 'z', m.stacks.z, 'visibility', frame.stack === 'z' ? 'visible' : 'hidden');
|
|
47
|
+
put(m, 'x', m.stacks.x, 'visibility', frame.stack === 'x' ? 'visible' : 'hidden');
|
|
48
|
+
frame.eyes.forEach((eye, i) => {
|
|
49
|
+
const e = m.eyes[i];
|
|
50
|
+
put(m, `e${i}`, e.root, 'transform', eye.transform);
|
|
51
|
+
put(m, `v${i}`, e.root, 'visibility', eye.visible ? 'visible' : 'hidden');
|
|
52
|
+
put(m, `p${i}`, e.pill, 'transform', eye.pill);
|
|
53
|
+
put(m, `ph${i}`, e.pill, 'display', eye.happy ? 'none' : 'block');
|
|
54
|
+
put(m, `a${i}`, e.arc, 'display', eye.happy ? 'block' : 'none');
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const keys = new WeakMap();
|
|
58
|
+
/** Everything in a definition the static scene markup depends on. */
|
|
59
|
+
function geometryKey(definition) {
|
|
60
|
+
let key = keys.get(definition);
|
|
61
|
+
if (key === undefined) {
|
|
62
|
+
key = JSON.stringify([definition?.id, definition?.name, definition?.body?.path, definition?.eyes]);
|
|
63
|
+
keys.set(definition, key);
|
|
64
|
+
}
|
|
65
|
+
return key;
|
|
66
|
+
}
|
|
67
|
+
/** Midpoint between the eyes as a fraction of the (square, 100-unit) box: the look starts there. */
|
|
68
|
+
function eyesOrigin(definition) {
|
|
69
|
+
const { x, y } = definition.eyes ?? {};
|
|
70
|
+
const at = (v) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(1, Math.max(0, v / 100)) : 0.5);
|
|
71
|
+
return { x: at(x), y: at(y) };
|
|
72
|
+
}
|
|
73
|
+
export function mountAvatar(host, initial) {
|
|
74
|
+
let opts = { ...initial };
|
|
75
|
+
const animator = createAnimator();
|
|
76
|
+
let rect = null;
|
|
77
|
+
let scene = null;
|
|
78
|
+
let lastStill = '';
|
|
79
|
+
let failed = false;
|
|
80
|
+
let dirty = true;
|
|
81
|
+
let releasePointer = null;
|
|
82
|
+
if (getComputedStyle(host).position === 'static')
|
|
83
|
+
host.style.position = 'relative';
|
|
84
|
+
const syncHost = () => {
|
|
85
|
+
host.style.color = opts.color ?? DEFAULT_COLOR;
|
|
86
|
+
host.style.setProperty('--avatar-ink', opts.eyeColor ?? DEFAULT_EYE_COLOR);
|
|
87
|
+
const decorative = opts.label === '';
|
|
88
|
+
if (decorative) {
|
|
89
|
+
host.removeAttribute('role');
|
|
90
|
+
host.removeAttribute('aria-label');
|
|
91
|
+
host.setAttribute('aria-hidden', 'true');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
host.setAttribute('role', 'img');
|
|
95
|
+
host.setAttribute('aria-label', opts.label ?? opts.definition?.name ?? 'Avatar');
|
|
96
|
+
host.removeAttribute('aria-hidden');
|
|
97
|
+
}
|
|
98
|
+
const wantsPointer = !!opts.followPointer && !opts.still;
|
|
99
|
+
if (wantsPointer && !releasePointer)
|
|
100
|
+
releasePointer = trackPointer();
|
|
101
|
+
else if (!wantsPointer && releasePointer) {
|
|
102
|
+
releasePointer();
|
|
103
|
+
releasePointer = null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const clear = () => {
|
|
107
|
+
host.textContent = '';
|
|
108
|
+
scene = null;
|
|
109
|
+
lastStill = '';
|
|
110
|
+
};
|
|
111
|
+
const draw = (time, pointer) => {
|
|
112
|
+
const p = opts;
|
|
113
|
+
const reducedMotion = p.reducedMotion === 'system' || p.reducedMotion === undefined ? prefersReducedMotion() : p.reducedMotion;
|
|
114
|
+
const now = performance.now();
|
|
115
|
+
try {
|
|
116
|
+
if (p.still) {
|
|
117
|
+
if (scene)
|
|
118
|
+
clear();
|
|
119
|
+
const svg = renderAvatarSvg(p.definition, {
|
|
120
|
+
color: p.color,
|
|
121
|
+
eyeColor: p.eyeColor,
|
|
122
|
+
depth: p.depth,
|
|
123
|
+
motion: p.mood,
|
|
124
|
+
view: p.view,
|
|
125
|
+
gaze: p.lookAt ?? undefined,
|
|
126
|
+
reducedMotion: true,
|
|
127
|
+
});
|
|
128
|
+
// The engine derives SVG ids from geometry, so repeated avatars can share them safely.
|
|
129
|
+
if (svg !== lastStill) {
|
|
130
|
+
host.innerHTML = svg;
|
|
131
|
+
lastStill = svg;
|
|
132
|
+
}
|
|
133
|
+
failed = false;
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (lastStill)
|
|
137
|
+
clear();
|
|
138
|
+
const target = p.lookAt
|
|
139
|
+
? p.lookAt
|
|
140
|
+
: p.followPointer && pointer && rect && rect.width > 0
|
|
141
|
+
? pointerGaze(pointer, rect, eyesOrigin(p.definition))
|
|
142
|
+
: null;
|
|
143
|
+
const step = animator.step({ now, motion: p.mood ?? 'idle', target, hold: p.holdGaze, reducedMotion });
|
|
144
|
+
const options = {
|
|
145
|
+
depth: p.depth,
|
|
146
|
+
motion: p.mood ?? 'idle',
|
|
147
|
+
motionBlend: step.motionBlend,
|
|
148
|
+
time,
|
|
149
|
+
gaze: step.gaze,
|
|
150
|
+
view: p.view,
|
|
151
|
+
reducedMotion,
|
|
152
|
+
};
|
|
153
|
+
const frame = sceneFrame(p.definition, options);
|
|
154
|
+
if (!scene || scene.key !== frame.scene || scene.geometry !== geometryKey(p.definition) || !host.contains(scene.view)) {
|
|
155
|
+
scene = mountScene(host, p.definition, p.depth);
|
|
156
|
+
}
|
|
157
|
+
apply(scene, frame);
|
|
158
|
+
failed = false;
|
|
159
|
+
return !reducedMotion || step.moving;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
if (!failed) {
|
|
163
|
+
clear();
|
|
164
|
+
console.error('open-bot-avatar: render failed', error);
|
|
165
|
+
failed = true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
syncHost();
|
|
171
|
+
const unsubscribe = subscribeFrames({
|
|
172
|
+
measure: () => {
|
|
173
|
+
rect = opts.followPointer && !opts.still && !opts.holdGaze && !opts.lookAt ? host.getBoundingClientRect() : null;
|
|
174
|
+
},
|
|
175
|
+
draw: (time, pointer) => {
|
|
176
|
+
// Stills only redraw after a change; live avatars every frame they ask for.
|
|
177
|
+
if (opts.still && !dirty)
|
|
178
|
+
return false;
|
|
179
|
+
dirty = false;
|
|
180
|
+
return draw(time, pointer);
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
update(next) {
|
|
185
|
+
opts = { ...opts, ...next };
|
|
186
|
+
syncHost();
|
|
187
|
+
dirty = true;
|
|
188
|
+
requestFrame();
|
|
189
|
+
},
|
|
190
|
+
destroy() {
|
|
191
|
+
unsubscribe();
|
|
192
|
+
releasePointer?.();
|
|
193
|
+
releasePointer = null;
|
|
194
|
+
clear();
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=mount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/dom/mount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAEjI,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA4CpD,SAAS,UAAU,CAAC,EAAe,EAAE,UAA4B,EAAE,KAAyB;IAC1F,EAAE,CAAC,SAAS,GAAG,iBAAiB,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxD,MAAM,CAAC,GAAG,CAAC,CAAS,E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O;YACL,WAAW,EAAE,CAAC;YACd,cAAc,EAAE,EAAE,CAAC;YACnB,cAAc,GAAG,IAAI,CAAC;YACtB,KAAK,EAAE,CAAC;QACV,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/dom/pointer.ts"],"names":[],"mappings":"AAqCA,+FAA+F;AAC/F,wBAAgB,YAAY,IAAI,MAAM,IAAI,CAYzC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Window-wide pointer tracking for avatars that follow the cursor. Listeners
|
|
3
|
+
* are installed while at least one avatar asks for them and removed after the
|
|
4
|
+
* last one lets go.
|
|
5
|
+
*/
|
|
6
|
+
import { setPointer } from './clock.js';
|
|
7
|
+
let users = 0;
|
|
8
|
+
let detach = null;
|
|
9
|
+
function attach() {
|
|
10
|
+
const move = (e) => setPointer({ x: e.clientX, y: e.clientY });
|
|
11
|
+
const leave = () => setPointer(null);
|
|
12
|
+
// Leaving the window shows up as an `out` with no related target.
|
|
13
|
+
const out = (e) => !e.relatedTarget && leave();
|
|
14
|
+
// A lifted finger or pen has no position any more.
|
|
15
|
+
const lift = (e) => e.pointerType !== 'mouse' && leave();
|
|
16
|
+
const hidden = () => document.hidden && leave();
|
|
17
|
+
window.addEventListener('pointermove', move, { passive: true });
|
|
18
|
+
window.addEventListener('pointerdown', move, { passive: true });
|
|
19
|
+
window.addEventListener('pointerout', out);
|
|
20
|
+
window.addEventListener('pointerup', lift);
|
|
21
|
+
window.addEventListener('pointercancel', lift);
|
|
22
|
+
window.addEventListener('blur', leave);
|
|
23
|
+
document.addEventListener('visibilitychange', hidden);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener('pointermove', move);
|
|
26
|
+
window.removeEventListener('pointerdown', move);
|
|
27
|
+
window.removeEventListener('pointerout', out);
|
|
28
|
+
window.removeEventListener('pointerup', lift);
|
|
29
|
+
window.removeEventListener('pointercancel', lift);
|
|
30
|
+
window.removeEventListener('blur', leave);
|
|
31
|
+
document.removeEventListener('visibilitychange', hidden);
|
|
32
|
+
setPointer(null);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Start tracking the pointer; call the returned function to stop. Safe to call many times. */
|
|
36
|
+
export function trackPointer() {
|
|
37
|
+
if (typeof window === 'undefined')
|
|
38
|
+
return () => { };
|
|
39
|
+
if (users++ === 0)
|
|
40
|
+
detach = attach();
|
|
41
|
+
let released = false;
|
|
42
|
+
return () => {
|
|
43
|
+
if (released)
|
|
44
|
+
return;
|
|
45
|
+
released = true;
|
|
46
|
+
if (--users === 0) {
|
|
47
|
+
detach?.();
|
|
48
|
+
detach = null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=pointer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../src/dom/pointer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,IAAI,KAAK,GAAG,CAAC,CAAC;AACd,IAAI,MAAM,GAAwB,IAAI,CAAC;AAEvC,SAAS,MAAM;IACb,MAAM,IAAI,GAAG,CAAC,CAAe,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACrC,kEAAkE;IAClE,MAAM,GAAG,GAAG,CAAC,CAAe,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,KAAK,EAAE,CAAC;IAC7D,mDAAmD;IACnD,MAAM,IAAI,GAAG,CAAC,CAAe,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KA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M,KAAK,WAAW;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IACnD,IAAI,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO,GAAG,EAAE;QACV,IAAI,QAAQ;YAAE,OAAO;QACrB,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;YAClB,MAAM,EAAE,EAAE,CAAC;YACX,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduced.d.ts","sourceRoot":"","sources":["../../src/dom/reduced.ts"],"names":[],"mappings":"AAeA,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The system's prefers-reduced-motion setting, watched once for the whole page. */
|
|
2
|
+
import { requestFrame } from './clock.js';
|
|
3
|
+
const QUERY = '(prefers-reduced-motion: reduce)';
|
|
4
|
+
let mql;
|
|
5
|
+
function media() {
|
|
6
|
+
if (mql === undefined) {
|
|
7
|
+
mql = typeof matchMedia === 'undefined' ? null : matchMedia(QUERY);
|
|
8
|
+
// Live avatars pick up a change on their next frame; wake the loop so they get one.
|
|
9
|
+
mql?.addEventListener('change', requestFrame);
|
|
10
|
+
}
|
|
11
|
+
return mql;
|
|
12
|
+
}
|
|
13
|
+
export function prefersReducedMotion() {
|
|
14
|
+
return media()?.matches ?? false;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=reduced.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reduced.js","sourceRoot":"","sources":["../../src/dom/reduced.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,KAAK,GAAG,kCAAkC,CAAC;AACjD,IAAI,GAAsC,CAAC;AAE3C,SAAS,KAAK;IACZ,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,GAAG,GAAG,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACnE,oFAAoF;QACpF,GAAG,EAAE,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,OAAO,KAAK,EAAE,EAAE,OAAO,IAAI,KAAK,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AvatarDefinition } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Starter avatars, produced with the generate-avatar design prompt. The
|
|
4
|
+
* face-bearing part is always the dominant mass, so the enlarged runtime eyes
|
|
5
|
+
* keep visible room (see faceRoom in volume.ts), and accessories stay small by
|
|
6
|
+
* their outer extent, hollow loops included. Outlines wind clockwise;
|
|
7
|
+
* holes (handles, loops) wind counter-clockwise so the nonzero fill rule cuts
|
|
8
|
+
* them. Tests keep these equal to the skill's example run and the examples in
|
|
9
|
+
* skills/generate-avatar/references/system-prompt.md.
|
|
10
|
+
*/
|
|
11
|
+
export declare const examples: AvatarDefinition[];
|
|
12
|
+
export declare function getExample(id: string): AvatarDefinition | undefined;
|
|
13
|
+
//# sourceMappingURL=examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAAgB,EAgGtC,CAAC;AAEF,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAEnE"}
|
package/dist/examples.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starter avatars, produced with the generate-avatar design prompt. The
|
|
3
|
+
* face-bearing part is always the dominant mass, so the enlarged runtime eyes
|
|
4
|
+
* keep visible room (see faceRoom in volume.ts), and accessories stay small by
|
|
5
|
+
* their outer extent, hollow loops included. Outlines wind clockwise;
|
|
6
|
+
* holes (handles, loops) wind counter-clockwise so the nonzero fill rule cuts
|
|
7
|
+
* them. Tests keep these equal to the skill's example run and the examples in
|
|
8
|
+
* skills/generate-avatar/references/system-prompt.md.
|
|
9
|
+
*/
|
|
10
|
+
export const examples = [
|
|
11
|
+
// Front view: one squat body; the face sits on the wide center above the grips.
|
|
12
|
+
{
|
|
13
|
+
version: 1,
|
|
14
|
+
id: 'controller',
|
|
15
|
+
name: 'Controller',
|
|
16
|
+
body: {
|
|
17
|
+
path: 'M28 22C38 20 44 23 50 23C56 23 62 20 72 22C84 24 90 34 91 48C92 62 91 76 82 80C75 83 69 78 66 72C63 67 58 66 50 66C42 66 37 67 34 72C31 78 25 83 18 80C9 76 8 62 9 48C10 34 16 24 28 22Z',
|
|
18
|
+
},
|
|
19
|
+
eyes: { x: 50, y: 42, spacing: 16, scale: 1.05 },
|
|
20
|
+
},
|
|
21
|
+
// Side view, mirror-symmetric about y 50 so it turns as a bar with round plates: two weight tiers a side and a soft bar end.
|
|
22
|
+
{
|
|
23
|
+
version: 1,
|
|
24
|
+
id: 'barbell',
|
|
25
|
+
name: 'Barbell',
|
|
26
|
+
body: {
|
|
27
|
+
path: 'M12 41H12A4 4 0 0 1 16 45V55A4 4 0 0 1 12 59H12A4 4 0 0 1 8 55V45A4 4 0 0 1 12 41Z' +
|
|
28
|
+
'M18 29H18A4 4 0 0 1 22 33V67A4 4 0 0 1 18 71H18A4 4 0 0 1 14 67V33A4 4 0 0 1 18 29Z' +
|
|
29
|
+
'M26 17H26A5 5 0 0 1 31 22V78A5 5 0 0 1 26 83H26A5 5 0 0 1 21 78V22A5 5 0 0 1 26 17Z' +
|
|
30
|
+
'M38 33H62A10 10 0 0 1 72 43V57A10 10 0 0 1 62 67H38A10 10 0 0 1 28 57V43A10 10 0 0 1 38 33Z' +
|
|
31
|
+
'M74 17H74A5 5 0 0 1 79 22V78A5 5 0 0 1 74 83H74A5 5 0 0 1 69 78V22A5 5 0 0 1 74 17Z' +
|
|
32
|
+
'M82 29H82A4 4 0 0 1 86 33V67A4 4 0 0 1 82 71H82A4 4 0 0 1 78 67V33A4 4 0 0 1 82 29Z' +
|
|
33
|
+
'M88 41H88A4 4 0 0 1 92 45V55A4 4 0 0 1 88 59H88A4 4 0 0 1 84 55V45A4 4 0 0 1 88 41Z',
|
|
34
|
+
},
|
|
35
|
+
eyes: { x: 50, y: 50, spacing: 15, scale: 1.05 },
|
|
36
|
+
},
|
|
37
|
+
// Side view: the cup carries the face and dominates; a compact handle loop stays a see-through cut-out.
|
|
38
|
+
{
|
|
39
|
+
version: 1,
|
|
40
|
+
id: 'mug',
|
|
41
|
+
name: 'Mug',
|
|
42
|
+
body: {
|
|
43
|
+
path: 'M22 20H62C67 20 70 23 70 28V72C70 80 64 86 56 86H28C20 86 14 80 14 72V28C14 23 17 20 22 20Z' +
|
|
44
|
+
'M68 36C80 34 87 42 87 53C87 64 80 72 68 70Z' +
|
|
45
|
+
'M69 45L69 61C75.5 62 79 58.5 79 53C79 47.5 76 44 69 45Z',
|
|
46
|
+
},
|
|
47
|
+
eyes: { x: 42, y: 49, spacing: 16, scale: 1.15 },
|
|
48
|
+
},
|
|
49
|
+
// Front view: a big round globe for the face; its neck runs flush into a straight base (one smooth outline), then a clear step down to the contact cap.
|
|
50
|
+
{
|
|
51
|
+
version: 1,
|
|
52
|
+
id: 'lightbulb',
|
|
53
|
+
name: 'Lightbulb',
|
|
54
|
+
body: {
|
|
55
|
+
path: 'M36 72V66C36 60 18 55 18 40A32 32 0 0 1 82 40C82 55 64 60 64 66V72Z' +
|
|
56
|
+
'M36 68H64V77A4 4 0 0 1 60 81H40A4 4 0 0 1 36 77Z' +
|
|
57
|
+
'M43 78H57V84A4 4 0 0 1 53 88H47A4 4 0 0 1 43 84Z',
|
|
58
|
+
},
|
|
59
|
+
eyes: { x: 50, y: 40, spacing: 17, scale: 1.2 },
|
|
60
|
+
},
|
|
61
|
+
// A wide speech bubble with a small tail.
|
|
62
|
+
{
|
|
63
|
+
version: 1,
|
|
64
|
+
id: 'chat',
|
|
65
|
+
name: 'Chat',
|
|
66
|
+
body: {
|
|
67
|
+
path: 'M28 14H72C82 14 90 22 90 32V54C90 64 82 72 72 72H42L25 86C23.5 87.3 21.5 86 22.3 84L27 71.5C17 70 10 63 10 54V32C10 22 18 14 28 14Z',
|
|
68
|
+
},
|
|
69
|
+
eyes: { x: 50, y: 42, spacing: 18, scale: 1.25 },
|
|
70
|
+
},
|
|
71
|
+
// Side view: a big pot (rim + tapered body) hosts the face; a stem with a small bud and two curving leaf blades that taper to soft tips.
|
|
72
|
+
{
|
|
73
|
+
version: 1,
|
|
74
|
+
id: 'sprout',
|
|
75
|
+
name: 'Sprout',
|
|
76
|
+
body: {
|
|
77
|
+
path: 'M49.5 19H50.5A3 3 0 0 1 53.5 22V46H46.5V22A3 3 0 0 1 49.5 19Z' +
|
|
78
|
+
'M49 38C36 41 22.5 36 17.6 23.4A1.4 1.4 0 0 1 18.4 21.6C29 17.5 41.5 21.5 49 34Z' +
|
|
79
|
+
'M51 30C57 14.5 72 8.5 82.6 11.8A1.4 1.4 0 0 1 83.5 13.4C80.5 27.5 66 35.5 51 34Z' +
|
|
80
|
+
'M24 44H76A4 4 0 0 1 80 48V54A4 4 0 0 1 76 58H24A4 4 0 0 1 20 54V48A4 4 0 0 1 24 44Z' +
|
|
81
|
+
'M24 56H76L71 84C70.4 87.5 68 90 64.5 90H35.5C32 90 29.6 87.5 29 84Z',
|
|
82
|
+
},
|
|
83
|
+
eyes: { x: 50, y: 71, spacing: 16, scale: 1.05 },
|
|
84
|
+
},
|
|
85
|
+
// Side view: a big can body hosts the face; a small rear handle loop, joined to the body at both ends, and a short spout name it.
|
|
86
|
+
{
|
|
87
|
+
version: 1,
|
|
88
|
+
id: 'watering-can',
|
|
89
|
+
name: 'Watering Can',
|
|
90
|
+
body: {
|
|
91
|
+
path: 'M32 38H62C68 38 71 41 72 47L74 76C74.5 82 70 86 64 86H30C24 86 19.5 82 20 76L22 47C23 41 26 38 32 38Z' +
|
|
92
|
+
'M23 63C14 63 8.5 57 8.5 48C8.5 37 13 30.5 19 30.5C25 30.5 28.5 34 30 39.5L26 52Z' +
|
|
93
|
+
'M23.5 42C22 38 20 36 17.5 36C15 36 14 41 14 48C14 54 16 57.5 22 58L23.5 47Z' +
|
|
94
|
+
'M69 66C75 61 78 55 80 46.5L88 49.5C85 62 80 73 72 81Z' +
|
|
95
|
+
'M78.7 43A7 4.5 25 0 1 91.3 49A7 4.5 25 0 1 78.7 43Z',
|
|
96
|
+
},
|
|
97
|
+
eyes: { x: 47, y: 61, spacing: 16, scale: 1.15 },
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
export function getExample(id) {
|
|
101
|
+
return examples.find((e) => e.id === id);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,gFAAgF;IAChF;QACE,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,IAAI,EACF,0LAA0L;SAC7L;QACD,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACjD;IACD,6HAA6H;IAC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CAAC;QACV,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,IAAI,EACF,+DAA+D;gBAC/D,iFAAiF;gBACjF,kFAAkF;gBAClF,qFAAqF;gBACrF,qEAAqE;SACxE;QACD,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACjD;IACD,kIAAkI;IAClI;QACE,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,cAAc;QAClB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE;YACJ,IAAI,EACF,uGAAuG;gBACvG,kFAAkF;gBAClF,6EAA6E;gBAC7E,uDAAuD;gBACvD,qDAAqD;SACxD;QACD,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE;KACjD;CACF,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/follow.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor following, as pure functions the frame loop steps once per frame.
|
|
3
|
+
*
|
|
4
|
+
* The pointer is mapped to a look direction from the avatar's eyes (not its
|
|
5
|
+
* box center, so a pointer level with the eyes reads as level): radial
|
|
6
|
+
* (diagonals are no stronger than straight lines) and soft, so it uses most of
|
|
7
|
+
* the (small) range across the stage around the avatar and saturates gently
|
|
8
|
+
* beyond it. `attention` fades the whole response in and out, so the eyes and
|
|
9
|
+
* the body's turn hand over to idle motion without a jump.
|
|
10
|
+
*/
|
|
11
|
+
export interface FollowState {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
/** 0 = at rest (idle wander, resting turn), 1 = fully following the pointer. */
|
|
15
|
+
attention: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const REST: FollowState;
|
|
18
|
+
/**
|
|
19
|
+
* Look direction (-1..1, x right, y down) toward a viewport point, from the
|
|
20
|
+
* avatar's bounding box. `origin` is where the look starts, as a fraction of
|
|
21
|
+
* the box (the eyes; default the center).
|
|
22
|
+
*/
|
|
23
|
+
export declare function pointerGaze(pointer: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}, box: {
|
|
27
|
+
left: number;
|
|
28
|
+
top: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
}, origin?: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
}): {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* One easing step toward `target` (null = not following: back to rest).
|
|
40
|
+
* Frame-rate independent; reduced motion snaps. Returns the next state and
|
|
41
|
+
* whether it still needs frames.
|
|
42
|
+
*/
|
|
43
|
+
export declare function followStep(state: FollowState, target: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
} | null, dt: number, reduced: boolean): {
|
|
47
|
+
state: FollowState;
|
|
48
|
+
moving: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The pose's look target for a follow state, nothing at all once at rest.
|
|
52
|
+
* Attention eased through a smoothstep is the weight, so the turn starts and
|
|
53
|
+
* ends gently rather than at full speed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function followGaze(state: FollowState): {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
weight: number;
|
|
59
|
+
} | undefined;
|
|
60
|
+
//# sourceMappingURL=follow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../src/follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,IAAI,EAAE,WAA0C,CAAC;AAe9D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACjC,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACjE,MAAM,GAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAuB;;;EAStD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAa7J;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAGnG"}
|
package/dist/follow.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor following, as pure functions the frame loop steps once per frame.
|
|
3
|
+
*
|
|
4
|
+
* The pointer is mapped to a look direction from the avatar's eyes (not its
|
|
5
|
+
* box center, so a pointer level with the eyes reads as level): radial
|
|
6
|
+
* (diagonals are no stronger than straight lines) and soft, so it uses most of
|
|
7
|
+
* the (small) range across the stage around the avatar and saturates gently
|
|
8
|
+
* beyond it. `attention` fades the whole response in and out, so the eyes and
|
|
9
|
+
* the body's turn hand over to idle motion without a jump.
|
|
10
|
+
*/
|
|
11
|
+
export const REST = { x: 0, y: 0, attention: 0 };
|
|
12
|
+
/** Time constant of the look easing, seconds: quick enough to track a moving pointer. */
|
|
13
|
+
const TAU = 0.12;
|
|
14
|
+
/**
|
|
15
|
+
* Attention fades in and out more slowly, so taking up a target, losing it
|
|
16
|
+
* (pointer leaves, follow toggled off) or settling back into the resting turn
|
|
17
|
+
* is an unhurried turn rather than a snap.
|
|
18
|
+
*/
|
|
19
|
+
const ATTEND_TAU = 0.3;
|
|
20
|
+
/** Pointer distance, in avatar sizes, at which the look is at tanh(1) ≈ 76% of full. */
|
|
21
|
+
const REACH = 1;
|
|
22
|
+
/** Small avatars still get a usable reach, CSS px. */
|
|
23
|
+
const MIN_SIZE = 160;
|
|
24
|
+
/**
|
|
25
|
+
* Look direction (-1..1, x right, y down) toward a viewport point, from the
|
|
26
|
+
* avatar's bounding box. `origin` is where the look starts, as a fraction of
|
|
27
|
+
* the box (the eyes; default the center).
|
|
28
|
+
*/
|
|
29
|
+
export function pointerGaze(pointer, box, origin = { x: 0.5, y: 0.5 }) {
|
|
30
|
+
const reach = Math.max(box.width, box.height, MIN_SIZE) * REACH;
|
|
31
|
+
const dx = (pointer.x - (box.left + box.width * origin.x)) / reach;
|
|
32
|
+
const dy = (pointer.y - (box.top + box.height * origin.y)) / reach;
|
|
33
|
+
const m = Math.hypot(dx, dy);
|
|
34
|
+
if (!Number.isFinite(m) || m < 1e-9)
|
|
35
|
+
return { x: 0, y: 0 };
|
|
36
|
+
const k = Math.tanh(m) / m;
|
|
37
|
+
return { x: dx * k, y: dy * k };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One easing step toward `target` (null = not following: back to rest).
|
|
41
|
+
* Frame-rate independent; reduced motion snaps. Returns the next state and
|
|
42
|
+
* whether it still needs frames.
|
|
43
|
+
*/
|
|
44
|
+
export function followStep(state, target, dt, reduced) {
|
|
45
|
+
const goal = target ? { x: target.x, y: target.y, attention: 1 } : REST;
|
|
46
|
+
const step = Math.max(0, Math.min(dt, 0.1));
|
|
47
|
+
const ease = (tau) => (reduced ? 1 : 1 - Math.exp(-step / tau));
|
|
48
|
+
// Losing the target relaxes the look at the unhurried attention rate, as one movement.
|
|
49
|
+
const k = ease(target ? TAU : ATTEND_TAU);
|
|
50
|
+
const next = {
|
|
51
|
+
x: state.x + (goal.x - state.x) * k,
|
|
52
|
+
y: state.y + (goal.y - state.y) * k,
|
|
53
|
+
attention: state.attention + (goal.attention - state.attention) * ease(ATTEND_TAU),
|
|
54
|
+
};
|
|
55
|
+
const moving = Math.abs(goal.x - next.x) > 0.002 || Math.abs(goal.y - next.y) > 0.002 || Math.abs(goal.attention - next.attention) > 0.002;
|
|
56
|
+
return { state: moving ? next : goal, moving };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The pose's look target for a follow state, nothing at all once at rest.
|
|
60
|
+
* Attention eased through a smoothstep is the weight, so the turn starts and
|
|
61
|
+
* ends gently rather than at full speed.
|
|
62
|
+
*/
|
|
63
|
+
export function followGaze(state) {
|
|
64
|
+
const a = Math.min(1, Math.max(0, state.attention));
|
|
65
|
+
return a > 0 ? { x: state.x, y: state.y, weight: a * a * (3 - 2 * a) } : undefined;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=follow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"follow.js","sourceRoot":"","sources":["../src/follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,CAAC,MAAM,IAAI,GAAgB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;AAE9D,yFAAyF;AACzF,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AI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;IAC3I,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAkB;IAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { AvatarDefinition, AvatarEyes, AvatarMotion, AvatarMotionBlend, RenderOptions, ValidationResult } from './types.ts';
|
|
2
|
+
export { validateAvatar } from './validate.ts';
|
|
3
|
+
export { avatarFrame, renderAvatarSvg, renderAvatarScene, sceneFrame, DEFAULT_COLOR, DEFAULT_DEPTH, DEFAULT_EYE_COLOR, } from './render.ts';
|
|
4
|
+
export type { AvatarFrame, EyeMark, FrameShape, Matrix, SceneFrame } from './render.ts';
|
|
5
|
+
export { BASE_PITCH, BASE_YAW, blendPoses, computePose } from './motion.ts';
|
|
6
|
+
export type { Pose, PoseInput } from './motion.ts';
|
|
7
|
+
export { MOOD_MS, moodProgress, settleMood } from './mood.ts';
|
|
8
|
+
export type { MoodState } from './mood.ts';
|
|
9
|
+
export { REST, followGaze, followStep, pointerGaze } from './follow.ts';
|
|
10
|
+
export type { FollowState } from './follow.ts';
|
|
11
|
+
export { createAnimator } from './animator.ts';
|
|
12
|
+
export type { Animator, AnimatorInput, AnimatorStep } from './animator.ts';
|
|
13
|
+
export { examples, getExample } from './examples.ts';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjI,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5E,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { validateAvatar } from './validate.js';
|
|
2
|
+
export { avatarFrame, renderAvatarSvg, renderAvatarScene, sceneFrame, DEFAULT_COLOR, DEFAULT_DEPTH, DEFAULT_EYE_COLOR, } from './render.js';
|
|
3
|
+
export { BASE_PITCH, BASE_YAW, blendPoses, computePose } from './motion.js';
|
|
4
|
+
export { MOOD_MS, moodProgress, settleMood } from './mood.js';
|
|
5
|
+
export { REST, followGaze, followStep, pointerGaze } from './follow.js';
|
|
6
|
+
export { createAnimator } from './animator.js';
|
|
7
|
+
export { examples, getExample } from './examples.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE9D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/mood.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mood changes (idle, thinking, happy) as pure functions a frame loop steps:
|
|
3
|
+
* the pose eases from the mood on screen into the new one (see blendPoses in
|
|
4
|
+
* motion.ts), and a change during a change continues from where it is.
|
|
5
|
+
*/
|
|
6
|
+
import type { AvatarMotion, AvatarMotionBlend } from './types.ts';
|
|
7
|
+
/** Length of a mood change, ms. */
|
|
8
|
+
export declare const MOOD_MS = 420;
|
|
9
|
+
/** Eased progress of a mood change from elapsed time (smoothstep, clamped). */
|
|
10
|
+
export declare function moodProgress(elapsedMs: number): number;
|
|
11
|
+
/** A mood on screen, possibly still easing in over what came before. */
|
|
12
|
+
export interface MoodState {
|
|
13
|
+
motion: AvatarMotion;
|
|
14
|
+
blend?: AvatarMotionBlend;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What a new mood change eases in from: the mood on screen with any change
|
|
18
|
+
* still under way frozen at its progress, so the pose continues from exactly
|
|
19
|
+
* where it is. Older changes whose share has all but faded (or beyond a few
|
|
20
|
+
* levels) are dropped, so rapid clicking never grows the chain.
|
|
21
|
+
*/
|
|
22
|
+
export declare function settleMood(state: MoodState, share?: number, depth?: number): MoodState;
|
|
23
|
+
//# sourceMappingURL=mood.d.ts.map
|