@dotcraft/avatar 0.6.3
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 +201 -0
- package/README.md +43 -0
- package/dist/AnimatedDecoration.d.ts +10 -0
- package/dist/AnimatedDecoration.d.ts.map +1 -0
- package/dist/AnimatedDecoration.js +43 -0
- package/dist/AnimatedDecoration.js.map +1 -0
- package/dist/AppearanceRig.d.ts +12 -0
- package/dist/AppearanceRig.d.ts.map +1 -0
- package/dist/AppearanceRig.js +9 -0
- package/dist/AppearanceRig.js.map +1 -0
- package/dist/Avatar.d.ts +22 -0
- package/dist/Avatar.d.ts.map +1 -0
- package/dist/Avatar.js +71 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/DecorationShapes.d.ts +10 -0
- package/dist/DecorationShapes.d.ts.map +1 -0
- package/dist/DecorationShapes.js +8 -0
- package/dist/DecorationShapes.js.map +1 -0
- package/dist/Decorations.d.ts +15 -0
- package/dist/Decorations.d.ts.map +1 -0
- package/dist/Decorations.js +26 -0
- package/dist/Decorations.js.map +1 -0
- package/dist/Faces.d.ts +7 -0
- package/dist/Faces.d.ts.map +1 -0
- package/dist/Faces.js +8 -0
- package/dist/Faces.js.map +1 -0
- package/dist/HatDecorations.d.ts +5 -0
- package/dist/HatDecorations.d.ts.map +1 -0
- package/dist/HatDecorations.js +20 -0
- package/dist/HatDecorations.js.map +1 -0
- package/dist/HeldDecorations.d.ts +5 -0
- package/dist/HeldDecorations.d.ts.map +1 -0
- package/dist/HeldDecorations.js +5 -0
- package/dist/HeldDecorations.js.map +1 -0
- package/dist/MascotRig.d.ts +25 -0
- package/dist/MascotRig.d.ts.map +1 -0
- package/dist/MascotRig.js +58 -0
- package/dist/MascotRig.js.map +1 -0
- package/dist/ObjectDecorations.d.ts +5 -0
- package/dist/ObjectDecorations.d.ts.map +1 -0
- package/dist/ObjectDecorations.js +16 -0
- package/dist/ObjectDecorations.js.map +1 -0
- package/dist/accessories.css +14 -0
- package/dist/appearanceModel.d.ts +28 -0
- package/dist/appearanceModel.d.ts.map +1 -0
- package/dist/appearanceModel.js +58 -0
- package/dist/appearanceModel.js.map +1 -0
- package/dist/avatar.css +62 -0
- package/dist/characters.d.ts +6 -0
- package/dist/characters.d.ts.map +1 -0
- package/dist/characters.js +2 -0
- package/dist/characters.js.map +1 -0
- package/dist/composer/ComposerMascot.d.ts +3 -0
- package/dist/composer/ComposerMascot.d.ts.map +1 -0
- package/dist/composer/ComposerMascot.js +433 -0
- package/dist/composer/ComposerMascot.js.map +1 -0
- package/dist/composer/ComposerMascotShadow.d.ts +4 -0
- package/dist/composer/ComposerMascotShadow.d.ts.map +1 -0
- package/dist/composer/ComposerMascotShadow.js +7 -0
- package/dist/composer/ComposerMascotShadow.js.map +1 -0
- package/dist/composer/constants.d.ts +32 -0
- package/dist/composer/constants.d.ts.map +1 -0
- package/dist/composer/constants.js +50 -0
- package/dist/composer/constants.js.map +1 -0
- package/dist/composer/mascotHandoff.d.ts +3 -0
- package/dist/composer/mascotHandoff.d.ts.map +1 -0
- package/dist/composer/mascotHandoff.js +15 -0
- package/dist/composer/mascotHandoff.js.map +1 -0
- package/dist/composer/styles/energy.css +99 -0
- package/dist/composer/styles/expressions.css +20 -0
- package/dist/composer/styles/feedback.css +188 -0
- package/dist/composer/styles/focus.css +72 -0
- package/dist/composer/styles/foundation.css +287 -0
- package/dist/composer/styles/idle.css +438 -0
- package/dist/composer/styles/overdrive.css +264 -0
- package/dist/composer/styles/props.css +21 -0
- package/dist/composer/types.d.ts +40 -0
- package/dist/composer/types.d.ts.map +1 -0
- package/dist/composer/types.js +2 -0
- package/dist/composer/types.js.map +1 -0
- package/dist/composer/useComposerAvatarBehavior.d.ts +24 -0
- package/dist/composer/useComposerAvatarBehavior.d.ts.map +1 -0
- package/dist/composer/useComposerAvatarBehavior.js +72 -0
- package/dist/composer/useComposerAvatarBehavior.js.map +1 -0
- package/dist/composer/useComposerMotion.d.ts +2 -0
- package/dist/composer/useComposerMotion.d.ts.map +1 -0
- package/dist/composer/useComposerMotion.js +16 -0
- package/dist/composer/useComposerMotion.js.map +1 -0
- package/dist/composer/useComposerProfile.d.ts +7 -0
- package/dist/composer/useComposerProfile.d.ts.map +1 -0
- package/dist/composer/useComposerProfile.js +46 -0
- package/dist/composer/useComposerProfile.js.map +1 -0
- package/dist/decorationCatalog.d.ts +14 -0
- package/dist/decorationCatalog.d.ts.map +1 -0
- package/dist/decorationCatalog.js +37 -0
- package/dist/decorationCatalog.js.map +1 -0
- package/dist/decorationMotion.d.ts +35 -0
- package/dist/decorationMotion.d.ts.map +1 -0
- package/dist/decorationMotion.js +73 -0
- package/dist/decorationMotion.js.map +1 -0
- package/dist/environment.d.ts +6 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +48 -0
- package/dist/environment.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/palette.d.ts +26 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +35 -0
- package/dist/palette.js.map +1 -0
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +5 -0
- package/dist/react.js.map +1 -0
- package/dist/rig.css +265 -0
- package/dist/styles.css +13 -0
- package/dist/useEventReplay.d.ts +3 -0
- package/dist/useEventReplay.d.ts.map +1 -0
- package/dist/useEventReplay.js +15 -0
- package/dist/useEventReplay.js.map +1 -0
- package/dist/useGesture.d.ts +4 -0
- package/dist/useGesture.d.ts.map +1 -0
- package/dist/useGesture.js +59 -0
- package/dist/useGesture.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
const durations = { blink: 520, 'look-left': 1100, 'look-right': 1100, 'antenna-bob': 720 };
|
|
3
|
+
function curve(points, progress) {
|
|
4
|
+
const next = points.findIndex(([at]) => at >= progress);
|
|
5
|
+
if (next <= 0)
|
|
6
|
+
return points[Math.max(0, next)][1];
|
|
7
|
+
const [from, a] = points[next - 1], [to, b] = points[next];
|
|
8
|
+
const t = (progress - from) / (to - from);
|
|
9
|
+
return a + (b - a) * t * t * (3 - 2 * t);
|
|
10
|
+
}
|
|
11
|
+
export function useGesture(ref, gesture, sequence, enabled, paused, onComplete) {
|
|
12
|
+
const clock = useRef(0);
|
|
13
|
+
const complete = useRef(onComplete);
|
|
14
|
+
const delivered = useRef(false);
|
|
15
|
+
complete.current = onComplete;
|
|
16
|
+
function paint(elapsed) {
|
|
17
|
+
const root = ref.current;
|
|
18
|
+
if (!root)
|
|
19
|
+
return;
|
|
20
|
+
const duration = gesture ? durations[gesture] : 1;
|
|
21
|
+
const t = Math.min(1, elapsed / duration);
|
|
22
|
+
const active = enabled && !!gesture && t < 1;
|
|
23
|
+
const eye = active && gesture === 'blink' && elapsed < 180 ? curve([[0, 1], [.35, .08], [.62, .08], [1, 1]], elapsed / 180) : 1;
|
|
24
|
+
root.querySelectorAll('.dca-part-eyes').forEach(e => { e.style.transform = `scaleY(${eye})`; });
|
|
25
|
+
root.querySelectorAll('.dca-part-caret').forEach(e => { e.style.opacity = active && gesture === 'blink' && Math.floor(elapsed / 130) % 2 ? '0' : ''; });
|
|
26
|
+
const hold = t > .22 && t < .78 ? 1 : t >= .78 ? Math.sin(Math.PI / 2 * (1 - t) / .22) : Math.sin(Math.PI / 2 * t / .22);
|
|
27
|
+
const x = active && gesture?.startsWith('look-') ? (gesture === 'look-left' ? -34 : 34) * hold : 0;
|
|
28
|
+
root.querySelector('.dca-face-motion')?.setAttribute('transform', `translate(${x} 0)`);
|
|
29
|
+
const bob = active && gesture === 'antenna-bob' ? curve([[0, 0], [.3, -52], [.55, 12], [.75, -16], [1, 0]], t) : 0;
|
|
30
|
+
root.querySelectorAll('.dca-part-antenna-w,.dca-part-glow,.dca-part-light').forEach(e => { e.style.transform = `translateY(${bob}px)`; });
|
|
31
|
+
}
|
|
32
|
+
useEffect(() => { clock.current = 0; delivered.current = false; paint(0); }, [gesture, sequence, enabled]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!gesture || delivered.current)
|
|
35
|
+
return;
|
|
36
|
+
const finish = () => { delivered.current = true; complete.current?.(sequence); };
|
|
37
|
+
if (!enabled) {
|
|
38
|
+
paint(durations[gesture]);
|
|
39
|
+
finish();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (paused)
|
|
43
|
+
return;
|
|
44
|
+
let last;
|
|
45
|
+
let frame = 0;
|
|
46
|
+
const tick = (now) => {
|
|
47
|
+
clock.current += last === undefined ? 0 : now - last;
|
|
48
|
+
last = now;
|
|
49
|
+
paint(clock.current);
|
|
50
|
+
if (clock.current < durations[gesture])
|
|
51
|
+
frame = requestAnimationFrame(tick);
|
|
52
|
+
else
|
|
53
|
+
finish();
|
|
54
|
+
};
|
|
55
|
+
frame = requestAnimationFrame(tick);
|
|
56
|
+
return () => cancelAnimationFrame(frame);
|
|
57
|
+
}, [gesture, sequence, enabled, paused]);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useGesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGesture.js","sourceRoot":"","sources":["../src/useGesture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAA;AAGzD,MAAM,SAAS,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,CAAA;AAC3F,SAAS,KAAK,CAAC,MAA8C,EAAE,QAAgB;IAC7E,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,QAAQ,CAAC,CAAA;IACvD,IAAI,IAAI,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,IAAI,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AS,CAAC,OAAO,CAAC,CAAC,CAAC;YAAC,MAAM,EAAE,CAAC;YAAC,OAAM;QAAC,CAAC;QAC7D,IAAI,MAAM;YAAE,OAAM;QAClB,IAAI,IAAwB,CAAA;QAC5B,IAAI,KAAK,GAAG,CAAC,CAAA;QACb,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;YAC3B,KAAK,CAAC,OAAO,IAAI,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAA;YACpD,IAAI,GAAG,GAAG,CAAA;YACV,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACpB,IAAI,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;gBAAE,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAA;;gBACtE,MAAM,EAAE,CAAA;QACf,CAAC,CAAA;QACD,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAA;QACnC,OAAO,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;AAC1C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dotcraft/avatar",
|
|
3
|
+
"version": "0.6.3",
|
|
4
|
+
"description": "Name-derived DotCraft avatars and React SVG animation components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react.d.ts",
|
|
15
|
+
"import": "./dist/react.js"
|
|
16
|
+
},
|
|
17
|
+
"./styles.css": "./dist/styles.css"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"**/*.css"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "node ../../scripts/clean-dist.mjs . && tsc -p tsconfig.json && node scripts/copy-styles.mjs",
|
|
27
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
"test": "npm run build && node --test tests/*.test.mjs"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": "^19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"react": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"react": "^19.0.0",
|
|
40
|
+
"react-dom": "^19.0.0",
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"typescript": "^5.7.0",
|
|
43
|
+
"jsdom": "^29.1.1"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"registry": "https://registry.npmjs.org"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/DotHarness/dotcraft.git",
|
|
52
|
+
"directory": "sdk/typescript/packages/avatar"
|
|
53
|
+
},
|
|
54
|
+
"license": "Apache-2.0"
|
|
55
|
+
}
|