Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(home): pose animation module, favicon refresh, and api/nav tweaks

nirholasef76e21b9fad
diff --git a/pages/bounties.html b/pages/bounties.html
index a1e4d2207..c78e2a7ce 100644
--- a/pages/bounties.html
+++ b/pages/bounties.html
@@ -23,7 +23,14 @@
content="Live pump.fun GO bounties — rewards, submissions, on-chain escrow."
/>
<meta property="og:url" content="https://three.ws/bounties" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta property="og:image:width" content="1200" />
+ <meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:site" content="@trythreews" />
+ <meta name="twitter:title" content="Bounties · three.ws" />
+ <meta name="twitter:description" content="Live pump.fun GO bounties — rewards, submissions, on-chain escrow." />
+ <meta name="twitter:image" content="https://three.ws/og-image.png" />
<link rel="stylesheet" href="/pump-bounties.css" />
</head>
<body>
diff --git a/pages/go.html b/pages/go.html
index 420ba2a4f..db4b75374 100644
--- a/pages/go.html
+++ b/pages/go.html
@@ -23,7 +23,14 @@
content="Post bounties, submit proof, earn rewards on-chain."
/>
<meta property="og:url" content="https://three.ws/go" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta property="og:image:width" content="1200" />
+ <meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:site" content="@trythreews" />
+ <meta name="twitter:title" content="GO · Bounties · three.ws" />
+ <meta name="twitter:description" content="Post bounties, submit proof, earn rewards on-chain." />
+ <meta name="twitter:image" content="https://three.ws/og-image.png" />
<style>
* {
margin: 0;
diff --git a/pages/home.html b/pages/home.html
index 4968cb7f4..d8856f1b8 100644
--- a/pages/home.html
+++ b/pages/home.html
@@ -3196,6 +3196,100 @@
</div>
</section>
+<!-- ── POSE STUDIO — LITE DEMO ────────────────────────────────────── -->
+<style>
+ #home-pose .hp-wrap { display: grid; grid-template-columns: 1.35fr 0.9fr; gap: 28px; align-items: stretch; }
+ #home-pose .hp-stage-card {
+ position: relative; border: 1px solid var(--hairline); border-radius: 16px; overflow: hidden;
+ background: radial-gradient(120% 100% at 50% 0%, #121214 0%, #09090a 70%); min-height: 460px;
+ }
+ #home-pose [data-pose-stage] { position: absolute; inset: 0; cursor: grab; }
+ #home-pose [data-pose-stage]:active { cursor: grabbing; }
+ #home-pose .hp-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
+ #home-pose .hp-stage-hud {
+ position: absolute; left: 16px; top: 16px; display: flex; gap: 8px; align-items: center;
+ font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
+ color: var(--text-3); pointer-events: none;
+ }
+ #home-pose .hp-stage-hud .dot { width: 6px; height: 6px; border-radius: 50%; background: #4fc3ff; box-shadow: 0 0 8px #4fc3ff; }
+ #home-pose .hp-hint {
+ position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
+ font-size: 12.5px; color: var(--text-3); background: rgba(0,0,0,0.45); border: 1px solid var(--hairline);
+ padding: 7px 14px; border-radius: 999px; pointer-events: none; backdrop-filter: blur(6px);
+ }
+ #home-pose .hp-chips {
+ position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 14px;
+ overflow-x: auto; scrollbar-width: none; -webkit-mask: linear-gradient(90deg, transparent, #000 18px, #000 calc(100% - 18px), transparent);
+ }
+ #home-pose .hp-chips::-webkit-scrollbar { display: none; }
+ #home-pose .hp-chip {
+ flex: 0 0 auto; font-family: var(--font-mono); font-size: 12px; color: var(--text-2);
+ background: rgba(20,20,22,0.82); border: 1px solid var(--hairline); border-radius: 999px;
+ padding: 7px 14px; cursor: pointer; white-space: nowrap; transition: border-color .16s, color .16s, background .16s, transform .16s;
+ backdrop-filter: blur(8px);
+ }
+ #home-pose .hp-chip:hover { color: var(--text); border-color: var(--hairline-strong); transform: translateY(-1px); }
+ #home-pose .hp-chip:focus-visible { outline: 2px solid #4fc3ff; outline-offset: 2px; }
+ #home-pose .hp-chip.is-active { color: #061015; background: #4fc3ff; border-color: #4fc3ff; }
+ #home-pose .hp-panel { display: flex; flex-direction: column; gap: 18px; }
+ #home-pose .hp-panel-card { border: 1px solid var(--hairline); border-radius: 16px; background: var(--surface-1); padding: 22px; }
+ #home-pose .hp-panel-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3); margin: 0 0 4px; }
+ #home-pose .hp-panel-sel { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); margin: 0 0 16px; }
+ #home-pose .hp-sliders { display: flex; flex-direction: column; gap: 16px; }
+ #home-pose .hp-sliders-empty { font-size: 13.5px; color: var(--text-3); margin: 0; line-height: 1.5; }
+ #home-pose .hp-slider-row { display: flex; flex-direction: column; gap: 7px; }
+ #home-pose .hp-slider-head { display: flex; justify-content: space-between; align-items: baseline; }
+ #home-pose .hp-slider-axis { font-size: 12px; color: var(--text-2); font-weight: 500; }
+ #home-pose .hp-slider-val { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
+ #home-pose .hp-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; border-radius: 2px; background: var(--hairline-strong); outline: none; cursor: pointer; }
+ #home-pose .hp-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--text); border: 2px solid #09090a; box-shadow: 0 0 0 1px var(--hairline-strong); cursor: grab; transition: transform .12s; }
+ #home-pose .hp-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
+ #home-pose .hp-slider::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--text); border: 2px solid #09090a; cursor: grab; }
+ #home-pose .hp-actions { display: flex; gap: 10px; margin-top: 4px; }
+ #home-pose .hp-btn {
+ flex: 1; text-align: center; font-family: var(--font-mono); font-size: 12.5px; padding: 11px 14px;
+ border-radius: 10px; border: 1px solid var(--hairline); background: transparent; color: var(--text-2);
+ cursor: pointer; text-decoration: none; transition: border-color .16s, color .16s, background .16s;
+ }
+ #home-pose .hp-btn:hover { color: var(--text); border-color: var(--hairline-strong); }
+ #home-pose .hp-btn-primary { background: var(--text); color: #09090a; border-color: var(--text); font-weight: 600; }
+ #home-pose .hp-btn-primary:hover { color: #09090a; background: #e2e2e2; }
+ @media (max-width: 880px) {
+ #home-pose .hp-wrap { grid-template-columns: 1fr; }
+ #home-pose .hp-stage-card { min-height: 400px; }
+ }
+</style>
+<section class="block" id="home-pose">
+ <div class="wrap-1280">
+ <div class="block-head reveal">
+ <p class="block-eyebrow"><span class="num">&bull;</span>Pose Studio</p>
+ <h2 class="block-h">Pose it. <em>Right here.</em></h2>
+ <p class="block-lede">
+ A live slice of <a href="/pose">Pose Studio</a> — the same rig, presets, and joint controls. Orbit the figure, click a body part to pose it, or tap a preset to morph the whole pose. Then take the full studio for keyframes, your own avatars, and PNG/GLB export.
+ </p>
+ </div>
+ <div class="hp-wrap reveal reveal-d1">
+ <div class="hp-stage-card">
+ <div data-pose-stage></div>
+ <div class="hp-stage-hud"><span class="dot"></span>Live rig</div>
+ <p class="hp-hint" data-pose-hint>Drag to orbit &middot; click a body part to pose it</p>
+ <div class="hp-chips" data-pose-chips role="group" aria-label="Preset poses"></div>
+ </div>
+ <div class="hp-panel">
+ <div class="hp-panel-card">
+ <p class="hp-panel-label">Selected joint</p>
+ <p class="hp-panel-sel" data-pose-selected>&mdash;</p>
+ <div class="hp-sliders" data-pose-sliders></div>
+ </div>
+ <div class="hp-actions">
+ <button type="button" class="hp-btn" data-pose-reset>Reset pose</button>
+ <a class="hp-btn hp-btn-primary" href="/pose">Open full studio &rarr;</a>
+ </div>
+ </div>
+ </div>
+ </div>
+</section>
+
<!-- ── FEATURE BENTO ─────────────────────────────────────────────── -->
<section class="block">
<div class="wrap-1280">
@@ -5248,6 +5342,7 @@
})();
</script>
<script type="module" src="/src/api-playground.js"></script>
+<script type="module" src="/src/home-pose.js"></script>
<script type="module" src="/dragon-section.js"></script>
<script>
// ── Interactive Bento Features ─────────────────────────────────────
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
index 81fd1da90..44645b466 100644
Binary files a/public/apple-touch-icon.png and b/public/apple-touch-icon.png differ
diff --git a/public/favicon-16x16.png b/public/favicon-16x16.png
index c77420793..c7c11cea3 100644
Binary files a/public/favicon-16x16.png and b/public/favicon-16x16.png differ
diff --git a/public/favicon-32x32.png b/public/favicon-32x32.png
index 5fbb97a41..aec2af217 100644
Binary files a/public/favicon-32x32.png and b/public/favicon-32x32.png differ
diff --git a/public/favicon.ico b/public/favicon.ico
index 4acd0a57e..59f1bea5d 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ
diff --git a/public/pwa-192x192.png b/public/pwa-192x192.png
index dbef07da6..376f01401 100644
Binary files a/public/pwa-192x192.png and b/public/pwa-192x192.png differ
diff --git a/public/pwa-512x512.png b/public/pwa-512x512.png
index e90b75852..272ed5515 100644
Binary files a/public/pwa-512x512.png and b/public/pwa-512x512.png differ
diff --git a/src/dashboard-next/pages/api.js b/src/dashboard-next/pages/api.js
index 74068a5b4..53dc1a035 100644
--- a/src/dashboard-next/pages/api.js
+++ b/src/dashboard-next/pages/api.js
@@ -718,24 +718,17 @@ async function runMcpTest(host, key) {
result.innerHTML = '<span class="dn-tag">Testing…</span>';
btn.disabled = true;
try {
- // We can't ship the user's plaintext key (it's hashed server-side after
- // creation), so we exercise the MCP endpoint with the session cookie
- // — same auth path the dashboard's own MCP integration uses.
- const res = await fetch('/api/mcp', {
+ const res = await fetch('/api/developer/mcp-test', {
method: 'POST',
credentials: 'include',
- headers: {
- accept: 'application/json',
- 'content-type': 'application/json',
- },
- body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' }),
+ headers: { accept: 'application/json' },
});
const data = await res.json().catch(() => null);
- if (res.ok && data && (data.result || Array.isArray(data))) {
- const tools = data.result?.tools || [];
+ if (res.ok && data?.result?.tools) {
+ const tools = data.result.tools;
result.innerHTML = `<span class="dn-tag success">OK · ${tools.length} tool${tools.length === 1 ? '' : 's'}</span>`;
} else {
- const msg = data?.error?.message || `HTTP ${res.status}`;
+ const msg = data?.error?.message || data?.error_description || `HTTP ${res.status}`;
result.innerHTML = `<span class="dn-tag danger">Failed: ${esc(msg)}</span>`;
}
} catch (err) {
diff --git a/src/home-pose.js b/src/home-pose.js
new file mode 100644
index 000000000..b75a54560
--- /dev/null
+++ b/src/home-pose.js
@@ -0,0 +1,446 @@
+// Homepage "Pose it here" demo — a lite, embeddable slice of /pose.
+// Reuses the exact same primitive Mannequin and preset library the full Pose
+// Studio runs on, wrapped in a self-contained Three.js stage: orbit the camera,
+// click a body part to select it, drag the X/Y/Z sliders to pose that joint, or
+// tap a preset to morph the whole figure. No fake data — this is the real rig.
+//
+// The render loop is gated on visibility (IntersectionObserver) so the homepage
+// stays smooth: the WebGL context idles whenever the section is off-screen.
+
+import {
+ AmbientLight,
+ CircleGeometry,
+ Color,
+ DirectionalLight,
+ HemisphereLight,
+ Mesh,
+ MeshBasicMaterial,
+ PCFSoftShadowMap,
+ PerspectiveCamera,
+ Raycaster,
+ Scene,
+ ShadowMaterial,
+ SphereGeometry,
+ Vector2,
+ Vector3,
+ WebGLRenderer,
+} from 'three';
+import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
+
+import {
+ Mannequin,
+ JOINT_LABELS,
+ JOINT_AXIS_LABELS,
+} from './pose-mannequin.js';
+import { getPresetById } from './pose-presets.js';
+
+// Curated spread of presets for the lite demo — one or two from each group so
+// the chip row reads like a tour without overwhelming the homepage.
+const DEMO_PRESET_IDS = [
+ 'relaxed',
+ 'tpose',
+ 'wave',
+ 'hands-on-hips',
+ 'run',
+ 'jump',
+ 'superhero-landing',
+ 'sit-chair',
+ 'thinker',
+ 'warrior2',
+ 'flex',
+ 'meditate',
+];
+
+const DEG = 180 / Math.PI;
+const RAD = Math.PI / 180;
+const prefersReducedMotion =
+ typeof matchMedia === 'function' &&
+ matchMedia('(prefers-reduced-motion: reduce)').matches;
+
+const el = (tag, attrs = {}, children = []) => {
+ const node = document.createElement(tag);
+ for (const [k, v] of Object.entries(attrs)) {
+ if (k === 'class') node.className = v;
+ else if (k === 'text') node.textContent = v;
+ else if (k === 'html') node.innerHTML = v;
+ else if (k.startsWith('on') && typeof v === 'function') node.addEventListener(k.slice(2), v);
+ else if (v !== false && v != null) node.setAttribute(k, v);
+ }
+ for (const child of [].concat(children)) {
+ if (child == null) continue;
+ node.appendChild(typeof child === 'string' ? document.createTextNode(child) : child);
+ }
+ return node;
+};
+
+const easeInOutCubic = (t) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);
+
+export function initHomePose(root) {
+ const stage = root.querySelector('[data-pose-stage]');
+ const chipRow = root.querySelector('[data-pose-chips]');
+ const sliderHost = root.querySelector('[data-pose-sliders]');
+ const selLabel = root.querySelector('[data-pose-selected]');
+ const hint = root.querySelector('[data-pose-hint]');
+ const resetBtn = root.querySelector('[data-pose-reset]');
+ if (!stage || !chipRow || !sliderHost) return;
+
+ // ── Scene ───────────────────────────────────────────────────────────
+ const canvas = el('canvas', { class: 'hp-canvas' });
+ stage.appendChild(canvas);
+
+ const renderer = new WebGLRenderer({
+ canvas,
+ antialias: true,
+ alpha: true,
+ powerPreference: 'high-performance',
+ });
+ renderer.setPixelRatio(Math.min(2, window.devicePixelRatio || 1));
+ renderer.shadowMap.enabled = true;
+ renderer.shadowMap.type = PCFSoftShadowMap;
+
+ const scene = new Scene();
+ const camera = new PerspectiveCamera(42, 1, 0.05, 100);
+ camera.position.set(1.7, 1.45, 3.1);
+
+ const controls = new OrbitControls(camera, renderer.domElement);
+ controls.target.set(0, 0.95, 0);
+ controls.enableDamping = true;
+ controls.dampingFactor = 0.08;
+ controls.enablePan = false;
+ controls.minDistance = 2.0;
+ controls.maxDistance = 5.5;
+ controls.minPolarAngle = 0.35;
+ controls.maxPolarAngle = Math.PI * 0.52;
+ controls.rotateSpeed = 0.85;
+
+ // ── Lighting ────────────────────────────────────────────────────────
+ scene.add(new AmbientLight(0xffffff, 0.55));
+ const hemi = new HemisphereLight(0xffffff, 0x202024, 0.6);
+ scene.add(hemi);
+ const key = new DirectionalLight(0xffffff, 1.5);
+ key.position.set(2.6, 4.2, 2.4);
+ key.castShadow = true;
+ key.shadow.mapSize.set(1024, 1024);
+ key.shadow.camera.near = 0.5;
+ key.shadow.camera.far = 14;
+ key.shadow.camera.left = -3;
+ key.shadow.camera.right = 3;
+ key.shadow.camera.top = 4;
+ key.shadow.camera.bottom = -2;
+ key.shadow.bias = -0.0006;
+ key.shadow.radius = 4;
+ scene.add(key);
+ const rim = new DirectionalLight(0xffffff, 0.35);
+ rim.position.set(-3, 2, -2.5);
+ scene.add(rim);
+
+ // ── Ground (shadow catcher + faint disc) ────────────────────────────
+ const disc = new Mesh(
+ new CircleGeometry(3.4, 64),
+ new MeshBasicMaterial({ color: new Color(0x0c0c0d) }),
+ );
+ disc.rotation.x = -Math.PI / 2;
+ disc.position.y = -0.001;
+ scene.add(disc);
+
+ const shadowCatcher = new Mesh(
+ new CircleGeometry(3.4, 64),
+ new ShadowMaterial({ opacity: 0.42 }),
+ );
+ shadowCatcher.rotation.x = -Math.PI / 2;
+ shadowCatcher.receiveShadow = true;
+ scene.add(shadowCatcher);
+
+ // ── Mannequin ───────────────────────────────────────────────────────
+ const mannequin = new Mannequin({ build: 'male', color: '#e6e6ea' });
+ mannequin.setConstraintsEnabled(true);
+ scene.add(mannequin.root);
+
+ // Selection marker — a soft glowing orb pinned to the active joint.
+ // (The mannequin shares materials across the body, so we can't tint one
+ // joint via emissive; an overlay marker selects without side effects.)
+ const marker = new Mesh(
+ new SphereGeometry(0.05, 20, 16),
+ new MeshBasicMaterial({ color: 0x4fc3ff, transparent: true, opacity: 0.9 }),
+ );
+ marker.visible = false;
+ scene.add(marker);
+ const markerHalo = new Mesh(
+ new SphereGeometry(0.085, 20, 16),
+ new MeshBasicMaterial({ color: 0x4fc3ff, transparent: true, opacity: 0.18 }),
+ );
+ marker.add(markerHalo);
+
+ // ── State ───────────────────────────────────────────────────────────
+ let selected = null;
+ const raycaster = new Raycaster();
+ const pointer = new Vector2();
+ const tmpVec = new Vector3();
+
+ // Pose tween (preset morph). Captures start/target euler per joint + root.
+ let tween = null;
+
+ function captureEuler() {
+ const pose = {};
+ for (const name of Object.keys(mannequin.joints)) {
+ const r = mannequin.joints[name].rotation;
+ pose[name] = { x: r.x, y: r.y, z: r.z };
+ }
+ pose.rootPosition = {
+ x: mannequin.root.position.x,
+ y: mannequin.root.position.y,
+ z: mannequin.root.position.z,
+ };
+ return pose;
+ }
+
+ function targetFromPreset(preset) {
+ const target = {};
+ for (const name of Object.keys(mannequin.joints)) {
+ const r = preset.pose[name];
+ target[name] = { x: r?.x || 0, y: r?.y || 0, z: r?.z || 0 };
+ }
+ const rp = preset.pose.rootPosition;
+ target.rootPosition = { x: rp?.x || 0, y: rp?.y || 0, z: rp?.z || 0 };
+ return target;
+ }
+
+ function applyEuler(pose) {
+ for (const name of Object.keys(mannequin.joints)) {
+ const r = pose[name];
+ if (!r) continue;
+ mannequin.joints[name].rotation.set(r.x, r.y, r.z);
+ }
+ if (pose.rootPosition) {
+ mannequin.root.position.set(
+ pose.rootPosition.x,
+ pose.rootPosition.y,
+ pose.rootPosition.z,
+ );
+ }
+ }
+
+ function morphToPreset(preset) {
+ const target = targetFromPreset(preset);
+ if (prefersReducedMotion) {
+ applyEuler(target);
+ refreshSliders();
+ return;
+ }
+ tween = { from: captureEuler(), to: target, t: 0, dur: 0.55 };
+ }
+
+ function advanceTween(dt) {
+ if (!tween) return;
+ tween.t = Math.min(1, tween.t + dt / tween.dur);
+ const k = easeInOutCubic(tween.t);
+ const { from, to } = tween;
+ for (const name of Object.keys(mannequin.joints)) {
+ const a = from[name];
+ const b = to[name];
+ if (!a || !b) continue;
+ mannequin.joints[name].rotation.set(
+ a.x + (b.x - a.x) * k,
+ a.y + (b.y - a.y) * k,
+ a.z + (b.z - a.z) * k,
+ );
+ }
+ mannequin.root.position.set(
+ from.rootPosition.x + (to.rootPosition.x - from.rootPosition.x) * k,
+ from.rootPosition.y + (to.rootPosition.y - from.rootPosition.y) * k,
+ from.rootPosition.z + (to.rootPosition.z - from.rootPosition.z) * k,
+ );
+ if (tween.t >= 1) {
+ tween = null;
+ refreshSliders();
+ }
+ }
+
+ // ── Selection ───────────────────────────────────────────────────────
+ function selectJoint(name) {
+ selected = name;
+ if (selLabel) selLabel.textContent = name ? JOINT_LABELS[name] || name : '—';
+ if (hint) hint.hidden = !!name;
+ marker.visible = !!name;
+ buildSliders(name);
+ }
+
+ function pickFromEvent(e) {
+ const rect = canvas.getBoundingClientRect();
+ pointer.x = ((e.clientX - rect.left) / rect.width) * 2 - 1;
+ pointer.y = -((e.clientY - rect.top) / rect.height) * 2 + 1;
+ raycaster.setFromCamera(pointer, camera);
+ const hits = raycaster.intersectObjects(mannequin.selectableMeshes, false);
+ if (!hits.length) return;
+ const name = mannequin.jointFromHit(hits[0].object);
+ if (name) selectJoint(name);
+ }
+
+ // Distinguish a click (select) from an orbit drag.
+ let downPos = null;
+ canvas.addEventListener('pointerdown', (e) => {
+ downPos = { x: e.clientX, y: e.clientY };
+ });
+ canvas.addEventListener('pointerup', (e) => {
+ if (!downPos) return;
+ const moved = Math.hypot(e.clientX - downPos.x, e.clientY - downPos.y);
+ downPos = null;
+ if (moved < 5) pickFromEvent(e);
+ });
+
+ // ── Sliders ─────────────────────────────────────────────────────────
+ const sliderRefs = {};
+ function buildSliders(name) {
+ sliderHost.replaceChildren();
+ for (const k of Object.keys(sliderRefs)) delete sliderRefs[k];
+ if (!name) {
+ sliderHost.appendChild(
+ el('p', { class: 'hp-sliders-empty', text: 'Select a joint to reveal its controls.' }),
+ );
+ return;
+ }
+ const axisLabels = JOINT_AXIS_LABELS[name] || JOINT_AXIS_LABELS.default;
+ for (const axis of ['x', 'y', 'z']) {
+ const value = el('span', { class: 'hp-slider-val' });
+ const input = el('input', {
+ type: 'range',
+ min: '-180',
+ max: '180',
+ step: '1',
+ class: 'hp-slider',
+ 'aria-label': `${JOINT_LABELS[name] || name} ${axisLabels[axis]}`,
+ oninput: () => {
+ const rad = Number(input.value) * RAD;
+ mannequin.setJointRotation(name, axis, rad);
+ value.textContent = `${Math.round(mannequin.getJointRotation(name)[axis] * DEG)}°`;
+ },
+ });
+ sliderRefs[axis] = { input, value };
+ sliderHost.appendChild(
+ el('div', { class: 'hp-slider-row' }, [
+ el('div', { class: 'hp-slider-head' }, [
+ el('span', { class: 'hp-slider-axis', text: axisLabels[axis] }),
+ value,
+ ]),
+ input,
+ ]),
+ );
+ }
+ refreshSliders();
+ }
+
+ function refreshSliders() {
+ if (!selected) return;
+ const rot = mannequin.getJointRotation(selected);
+ for (const axis of ['x', 'y', 'z']) {
+ const ref = sliderRefs[axis];
+ if (!ref) continue;
+ ref.input.value = String(Math.round(rot[axis] * DEG));
+ ref.value.textContent = `${Math.round(rot[axis] * DEG)}°`;
+ }
+ }
+
+ // ── Preset chips ────────────────────────────────────────────────────
+ let activeChip = null;
+ for (const id of DEMO_PRESET_IDS) {
+ const preset = getPresetById(id);
+ if (!preset) continue;
+ const chip = el('button', {
+ type: 'button',
+ class: 'hp-chip',
+ text: preset.label,
+ onclick: () => {
+ morphToPreset(preset);
+ if (activeChip) activeChip.classList.remove('is-active');
+ chip.classList.add('is-active');
+ activeChip = chip;
+ },
+ });
+ chipRow.appendChild(chip);
+ }
+
+ if (resetBtn) {
+ resetBtn.addEventListener('click', () => {
+ const relaxed = getPresetById('relaxed');
+ if (relaxed) morphToPreset(relaxed);
+ if (activeChip) {
+ activeChip.classList.remove('is-active');
+ activeChip = null;
+ }
+ });
+ }
+
+ // ── Render loop (visibility-gated) ──────────────────────────────────
+ let running = false;
+ let last = 0;
+ let rafId = 0;
+
+ function resize() {
+ const w = stage.clientWidth;
+ const h = stage.clientHeight;
+ if (!w || !h) return;
+ renderer.setSize(w, h, false);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ }
+
+ function frame(now) {
+ if (!running) return;
+ rafId = requestAnimationFrame(frame);
+ const dt = last ? Math.min(0.05, (now - last) / 1000) : 0.016;
+ last = now;
+ advanceTween(dt);
+ if (selected && mannequin.joints[selected]) {
+ mannequin.joints[selected].getWorldPosition(tmpVec);
+ marker.position.copy(tmpVec);
+ }
+ const pulse = 0.9 + Math.sin(now / 320) * 0.12;
+ markerHalo.scale.setScalar(pulse);
+ controls.update();
+ renderer.render(scene, camera);
+ }
+
+ function start() {
+ if (running) return;
+ running = true;
+ last = 0;
+ resize();
+ rafId = requestAnimationFrame(frame);
+ }
+ function stop() {
+ running = false;
+ if (rafId) cancelAnimationFrame(rafId);
+ rafId = 0;
+ }
+
+ const ro = new ResizeObserver(resize);
+ ro.observe(stage);
+
+ const io = new IntersectionObserver(
+ (entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting) start();
+ else stop();
+ }
+ },
+ { threshold: 0.08 },
+ );
+ io.observe(stage);
+
+ // ── First pose ──────────────────────────────────────────────────────
+ const initial = getPresetById('relaxed');
+ if (initial) applyEuler(targetFromPreset(initial));
+ buildSliders(null);
+ resize();
+}
+
+function boot() {
+ const root = document.getElementById('home-pose');
+ if (root) initHomePose(root);
+}
+
+if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', boot, { once: true });
+} else {
+ boot();
+}