Prompt specification
Build or customize the Three.js 3D scene "Puppet Maker's Joint Workshop" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Puppet Maker's Joint Workshop
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/puppet-maker-s-joint-workshop-x3735
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: puppet maker's joint workshop. Build a workshop with three original puppets using hinge, ball-like, and fixed joints. Let viewers compare allowed motion while keeping all attachments physically connected. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (puppet-maker-s-joint-workshop-x3735):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jointwright — A Voxel Puppet Workshop</title>
<style>
:root {
color-scheme: dark;
--ink: #f4ead8;
--muted: #b7b4aa;
--panel: rgba(24, 27, 30, 0.92);
--line: rgba(255, 255, 255, 0.13);
--hinge: #f1a35b;
--ball: #68d6cb;
--fixed: #a8cf83;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #171a1c;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button {
color: var(--ink);
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.055);
border-radius: 9px;
cursor: pointer;
transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
button:hover {
background: rgba(255, 255, 255, 0.11);
border-color: rgba(255, 255, 255, 0.25);
}
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible {
outline: 2px solid var(--ball);
outline-offset: 3px;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.hud button, .hud input, .control-deck { pointer-events: auto; }
.topbar {
position: absolute;
top: 18px;
left: 18px;
right: 18px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
padding: 12px 16px 12px 12px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(20, 23, 25, 0.78);
backdrop-filter: blur(12px);
box-shadow: 0 10px 35px rgba(0, 0, 0, 0.18);
}
.brand-mark {
width: 42px;
height: 42px;
display: grid;
place-items: center;
border-radius: 10px;
background: #e2ad68;
color: #262321;
font: 900 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.13);
}
.brand h1 {
margin: 0;
font: 800 17px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
letter-spacing: 0.02em;
}
.status {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(20, 23, 25, 0.78);
backdrop-filter: blur(12px);
color: var(--muted);
font-size: 12px;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #72d497;
box-shadow: 0 0 12px #72d497;
}
.station-label {
position: absolute;
left: 0;
top: 0;
min-width: 156px;
padding: 8px 11px;
transform: translate(-50%, -100%);
border: 1px solid rgba(255, 255, 255, 0.17);
border-radius: 10px;
background: rgba(18, 21, 23, 0.86);
backdrop-filter: blur(10px);
text-align: left;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.station-label strong {
display: block;
font: 800 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.station-label span {
display: flex;
align-items: center;
gap: 6px;
margin-top: 5px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.station-label i {
width: 7px;
height: 7px;
display: inline-block;
border-radius: 2px;
background: var(--accent);
}
.control-deck {
position: absolute;
left: 50%;
bottom: 17px;
width: min(880px, calc(100vw - 34px));
transform: translateX(-50%);
padding: 13px;
border: 1px solid var(--line);
border-radius: 15px;
background: var(--panel);
backdrop-filter: blur(18px);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}
.deck-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 1px 2px 10px;
border-bottom: 1px solid var(--line);
}
.selected-title {
min-width: 0;
}
.eyebrow {
display: block;
margin-bottom: 3px;
color: var(--muted);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.selected-title strong {
font: 800 14px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.deck-actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
}
.deck-actions button {
min-height: 34px;
padding: 7px 11px;
font-size: 11px;
font-weight: 700;
}
.deck-actions button.active {
border-color: rgba(104, 214, 203, 0.55);
color: #d9fff9;
background: rgba(104, 214, 203, 0.13);
}
.cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 9px;
margin-top: 10px;
}
.card {
min-width: 0;
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.09);
border-radius: 11px;
background: rgba(255, 255, 255, 0.035);
}
.card.selected {
border-color: color-mix(in srgb, var(--card-color) 58%, transparent);
background: color-mix(in srgb, var(--card-color) 9%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-color) 12%, transparent);
}
.card-head {
display: flex;
align-items: center;
gap: 9px;
width: 100%;
padding: 0;
border: 0;
background: transparent;
text-align: left;
}
.joint-icon {
position: relative;
flex: 0 0 auto;
width: 29px;
height: 29px;
display: grid;
place-items: center;
border-radius: 8px;
color: var(--card-color);
background: color-mix(in srgb, var(--card-color) 12%, transparent);
}
.joint-icon.hinge::before {
content: "";
width: 8px;
height: 19px;
border: 3px solid currentColor;
border-radius: 2px;
transform: rotate(-22deg);
}
.joint-icon.ball::before {
content: "";
width: 17px;
height: 17px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent);
}
.joint-icon.fixed::before {
content: "×";
font: 900 22px/1 ui-monospace, monospace;
}
.card-heading {
min-width: 0;
}
.card-heading strong {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font: 800 12px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.card-heading small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
.control-row {
display: none;
margin-top: 10px;
padding-top: 9px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.card.selected .control-row { display: block; }
.range-label {
display: flex;
justify-content: space-between;
gap: 8px;
margin: 7px 0 4px;
color: var(--muted);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.range-label output { color: var(--ink); }
input[type="range"] {
width: 100%;
height: 16px;
margin: 0;
accent-color: var(--card-color);
cursor: ew-resize;
}
.locked {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 32px;
padding: 7px 9px;
border-radius: 7px;
color: var(--muted);
background: rgba(0, 0, 0, 0.18);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.07em;
}
.locked strong { color: var(--fixed); }
.hint {
margin: 9px 2px 0;
color: #92958f;
text-align: center;
font-size: 10px;
letter-spacing: 0.02em;
}
.hint b { color: #d6d3c9; }
#toast {
position: absolute;
top: 88px;
left: 50%;
max-width: min(460px, calc(100vw - 40px));
padding: 10px 14px;
transform: translate(-50%, -10px);
opacity: 0;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 10px;
background: rgba(20, 23, 25, 0.94);
color: var(--ink);
text-align: center;
font-size: 12px;
box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3);
transition: opacity 180ms ease, transform 180ms ease;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #171a1c;
color: #e5c28f;
font: 800 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.12em;
transition: opacity 350ms ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 720px) {
.topbar { top: 10px; left: 10px; right: 10px; }
.brand { padding: 9px 11px 9px 9px; }
.brand-mark { width: 34px; height: 34px; font-size: 17px; }
.brand h1 { font-size: 13px; }
.brand p, .status { display: none; }
.control-deck {
width: calc(100vw - 20px);
bottom: 10px;
padding: 10px;
}
.deck-head { align-items: flex-start; }
.deck-actions { max-width: 62%; }
.deck-actions button { padding: 6px 8px; font-size: 9px; }
.cards {
grid-template-columns: repeat(3, minmax(220px, 1fr));
overflow-x: auto;
padding-bottom: 3px;
}
.station-label { min-width: 126px; padding: 7px 8px; }
.station-label strong { font-size: 10px; }
.station-label span { font-size: 8px; }
.hint { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel puppet workshop"></canvas>
<div class="hud">
<div class="topbar">
<div class="brand">
<div class="brand-mark">JW</div>
<div>
<h1>JOINTWRIGHT</h1>
<p>A voxel puppet-maker’s motion workshop</p>
</div>
</div>
<div class="status">
<span class="status-dot"></span>
<span id="statusText">Rigs connected · compare mode running</span>
</div>
</div>
<button class="station-label" data-select="hinge" style="--accent: var(--hinge)">
<strong>Rivet Rhea</strong>
<span><i></i> Single-axis hinge</span>
</button>
<button class="station-label" data-select="ball" style="--accent: var(--ball)">
<strong>Pebble Pip</strong>
<span><i></i> Ball socket</span>
</button>
<button class="station-label" data-select="fixed" style="--accent: var(--fixed)">
<strong>Oaklock</strong>
<span><i></i> Fixed peg</span>
</button>
<div id="toast" role="status" aria-live="polite"></div>
<section class="control-deck" aria-label="Puppet motion controls">
<div class="deck-head">
<div class="selected-title">
<span class="eyebrow">Selected workshop puppet</span>
<strong id="selectedName">Rivet Rhea · hinge</strong>
</div>
<div class="deck-actions">
<button id="playSelected" type="button">▶ Animate selected</button>
<button id="compareAll" class="active" type="button">Ⅱ Pause comparison</button>
<button id="resetAll" type="button">Reset</button>
</div>
</div>
<div class="cards">
<article class="card selected" data-card="hinge" style="--card-color: var(--hinge)">
<button class="card-head" type="button" data-select="hinge">
<span class="joint-icon hinge"></span>
<span class="card-heading">
<strong>Rivet Rhea</strong>
<small>Hinge · one planar axis</small>
</span>
</button>
<div class="control-row">
<label class="range-label" for="hingeAngle">
Shoulder swing <output id="hingeValue">0°</output>
</label>
<input id="hingeAngle" type="range" min="-70" max="70" value="0" step="1">
</div>
</article>
<article class="card" data-card="ball" style="--card-color: var(--ball)">
<button class="card-head" type="button" data-select="ball">
<span class="joint-icon ball"></span>
<span class="card-heading">
<strong>Pebble Pip</strong>
<small>Ball · two-axis socket</small>
</span>
</button>
<div class="control-row">
<label class="range-label" for="ballYaw">
Socket yaw <output id="yawValue">0°</output>
</label>
<input id="ballYaw" type="range" min="-70" max="70" value="0" step="1">
<label class="range-label" for="ballPitch">
Socket pitch <output id="pitchValue">0°</output>
</label>
<input id="ballPitch" type="range" min="-42" max="42" value="0" step="1">
</div>
</article>
<article class="card" data-card="fixed" style="--card-color: var(--fixed)">
<button class="card-head" type="button" data-select="fixed">
<span class="joint-icon fixed"></span>
<span class="card-heading">
<strong>Oaklock</strong>
<small>Fixed · rigidly pegged</small>
</span>
</button>
<div class="control-row">
<div class="locked">
<span>Allowed motion</span>
<strong>LOCKED · 0°</strong>
</div>
</div>
</article>
</div>
<p class="hint">
<b>Drag a puppet’s right arm</b> to test its joint ·
<b>Drag the room</b> to orbit · <b>Scroll</b> to zoom · every tool stays attached to its hand
</p>
</section>
</div>
<div id="loading">BUILDING THE WORKSHOP…</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const canvas = document.querySelector('#scene');
const loading = document.querySelector('#loading');
const toast = document.querySelector('#toast');
const statusText = document.querySelector('#statusText');
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: 'high-performance'
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x171c1e);
scene.fog = new THREE.Fog(0x171c1e, 16, 29);
const camera = new THREE.PerspectiveCamera(43, innerWidth / innerHeight, 0.1, 80);
const cameraState = {
azimuth: 0.055,
elevation: 0.285,
radius: 12.9,
target: new THREE.Vector3(0, 1.62, 0)
};
const clock = new THREE.Clock();
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const unitCylinder = new THREE.CylinderGeometry(0.5, 0.5, 1, 10);
const unitSphere = new THREE.SphereGeometry(1, 16, 12);
const materialCache = new Map();
function getMaterial(color, metalness = 0, roughness = 0.78, emissive = null, emissiveIntensity = 1) {
const key = `${color}|${metalness}|${roughness}|${emissive}|${emissiveIntensity}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
metalness,
roughness,
emissive: emissive ?? 0x000000,
emissiveIntensity
}));
}
return materialCache.get(key);
}
function box(parent, w, h, d, x, y, z, color, options = {}) {
const material = options.material || getMaterial(
color,
options.metalness ?? 0,
options.roughness ?? 0.78,
options.emissive ?? null,
options.emissiveIntensity ?? 1
);
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = options.shadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
if (options.rotation) mesh.rotation.set(...options.rotation);
parent.add(mesh);
return mesh;
}
function cylinder(parent, radius, height, x, y, z, color, options = {}) {
const mesh = new THREE.Mesh(
unitCylinder,
options.material || getMaterial(color, options.metalness ?? 0, options.roughness ?? 0.7)
);
mesh.scale.set(radius * 2, height, radius * 2);
mesh.position.set(x, y, z);
mesh.castShadow = options.shadow !== false;
mesh.receiveShadow = true;
if (options.rotation) mesh.rotation.set(...options.rotation);
parent.add(mesh);
return mesh;
}
function sphere(parent, radius, x, y, z, color, options = {}) {
const mesh = new THREE.Mesh(
unitSphere,
options.material || getMaterial(color, options.metalness ?? 0, options.roughness ?? 0.55)
);
mesh.scale.setScalar(radius);
mesh.position.set(x, y, z);
mesh.castShadow = options.shadow !== false;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(parent, x = 0, y = 0, z = 0) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
function makeSign(text, accent = '#e6bd7d', width = 512, height = 128) {
const c = document.createElement('canvas');
c.width = width;
c.height = height;
const ctx = c.getContext('2d');
ctx.fillStyle = '#252a29';
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = accent;
ctx.lineWidth = 7;
ctx.strokeRect(8, 8, width - 16, height - 16);
ctx.fillStyle = '#f4ead8';
ctx.font = `800 ${Math.floor(height * 0.31)}px monospace`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(text, width / 2, height / 2 + 2);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return new THREE.Mesh(
new THREE.PlaneGeometry(1, 0.25),
new THREE.MeshBasicMaterial({ map: texture })
);
}
// Lighting
scene.add(new THREE.HemisphereLight(0xc6d8d0, 0x4b3025, 1.65));
const keyLight = new THREE.DirectionalLight(0xffdfb1, 3.4);
keyLight.position.set(-4.5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x77cfd4, 1.1);
rimLight.position.set(6, 5, -3);
scene.add(rimLight);
// Workshop shell
box(scene, 18, 0.35, 10, 0, -0.22, 0, 0x76513e);
box(scene, 18, 5.5, 0.35, 0, 2.55, -4.75, 0x304346);
box(scene, 0.35, 5.5, 10, -8.85, 2.55, 0, 0x293a3e);
box(scene, 18, 0.22, 0.18, 0, 0.72, -4.52, 0x1f3032);
box(scene, 18, 0.13, 0.13, 0, 3.88, -4.51, 0x536364);
// Floor planks and seams
for (let i = 0; i < 18; i++) {
box(scene, 0.025, 0.012, 9.7, -8.2 + i, -0.035, 0, 0x4e352b, { shadow: false });
}
for (let z = -4; z <= 4; z += 1.25) {
box(scene, 17.6, 0.012, 0.025, 0, -0.033, z, 0x4e352b, { shadow: false });
}
// Window with glowing voxel panes
box(scene, 3.15, 2.35, 0.18, -6.45, 3.15, -4.5, 0x18282b);
box(scene, 2.78, 1.98, 0.12, -6.45, 3.15, -4.36, 0xe8bf72, {
emissive: 0xe9ad51,
emissiveIntensity: 0.65,
roughness: 0.45
});
box(scene, 0.13, 2.12, 0.18, -6.45, 3.15, -4.27, 0x273b3d);
box(scene, 2.95, 0.13, 0.18, -6.45, 3.15, -4.27, 0x273b3d);
box(scene, 3.42, 0.17, 0.42, -6.45, 2.04, -4.28, 0x8e6047);
box(scene, 3.42, 0.17, 0.42, -6.45, 4.26, -4.28, 0x8e6047);
// Main wall sign
const workshopSign = makeSign('JOINTWRIGHT WORKSHOP', '#e3b06e', 768, 160);
workshopSign.scale.set(5.4, 1.13, 1);
workshopSign.position.set(0, 4.48, -4.48);
scene.add(workshopSign);
// Shelves and parts
box(scene, 4.3, 0.14, 0.72, -1.7, 1.42, -4.16, 0x815940);
box(scene, 4.3, 0.14, 0.72, -1.7, 2.63, -4.16, 0x815940);
for (const x of [-3.65, -1.7, 0.25]) {
box(scene, 0.14, 2.35, 0.55, x, 2.08, -4.25, 0x684938);
}
const shelfColors = [0xd9824d, 0x5d99ae, 0x9bb66b, 0xbca574, 0x8670a0];
for (let row = 0; row < 2; row++) {
for (let i = 0; i < 7; i++) {
const x = -3.25 + i * 0.51;
const y = row === 0 ? 1.69 : 2.9;
box(scene, 0.31, 0.36 + (i % 3) * 0.07, 0.34, x, y, -4.03, shelfColors[(i + row) % shelfColors.length]);
if (i % 2 === 0) {
box(scene, 0.12, 0.1, 0.12, x, y + 0.24, -4.03, 0x394442);
}
}
}
// Pegboard and hand tools
box(scene, 4.2, 2.55, 0.15, 5.55, 2.65, -4.45, 0x59463b);
for (let x = 0; x < 12; x++) {
for (let y = 0; y < 7; y++) {
box(scene, 0.065, 0.065, 0.025, 3.72 + x * 0.33, 1.58 + y * 0.34, -4.35, 0x2b2926, { shadow: false });
}
}
box(scene, 0.12, 0.92, 0.11, 4.15, 2.74, -4.2, 0xc4a56d);
box(scene, 0.55, 0.18, 0.18, 4.15, 2.23, -4.2, 0x8d9692, { metalness: 0.45 });
box(scene, 0.11, 0.8, 0.1, 5.12, 2.66, -4.18, 0xb88b57);
box(scene, 0.38, 0.14, 0.13, 5.12, 3.02, -4.18, 0x8d9692, { metalness: 0.45 });
box(scene, 0.12, 0.72, 0.1, 6.0, 2.61, -4.18, 0x749ca0, { metalness: 0.5 });
box(scene, 0.3, 0.1, 0.11, 6.0, 2.95, -4.18, 0x749ca0, { metalness: 0.5 });
// Small workbench at right
box(scene, 3.4, 0.22, 1.15, 6.25, 1.08, 0.95, 0x986d4b);
for (const x of [4.82, 7.68]) {
box(scene, 0.23, 1.18, 0.9, x, 0.49, 0.95, 0x664735);
}
box(scene, 1.25, 0.52, 0.85, 6.5, 0.6, 0.95, 0x3f5753);
for (let i = 0; i < 3; i++) {
box(scene, 1.08, 0.03, 0.03, 6.5, 0.46 + i * 0.15, 1.385, 0xa67d55);
box(scene, 0.2, 0.045, 0.06, 6.5, 0.57 + i * 0.15, 1.41, 0xd3b17a);
}
box(scene, 0.5, 0.23, 0.38, 5.48, 1.32, 0.92, 0xd0804b);
box(scene, 0.62, 0.05, 0.12, 5.48, 1.47, 0.92, 0xe0b46f);
// Voxel pendant lamps
function addPendant(x, z) {
box(scene, 0.045, 1.05, 0.045, x, 4.25, z, 0x242827);
box(scene, 0.65, 0.12, 0.65, x, 3.73, z, 0x3d4c49);
box(scene, 0.44, 0.3, 0.44, x, 3.54, z, 0xe0a757, {
emissive: 0xe89736,
emissiveIntensity: 0.8,
roughness: 0.45
});
const light = new THREE.PointLight(0xffb85e, 12, 5.5, 2);
light.position.set(x, 3.38, z);
scene.add(light);
}
addPendant(-3.5, 0.1);
addPendant(0, 0.1);
addPendant(3.5, 0.1);
const stationData = [
{ id: 'hinge', x: -3.5, accent: 0xd8783f, sign: 'HINGE BENCH' },
{ id: 'ball', x: 0, accent: 0x4f8fbf, sign: 'BALL SOCKET' },
{ id: 'fixed', x: 3.5, accent: 0x5f8c62, sign: 'FIXED PEG' }
];
const rigs = {};
const stations = {};
function createStation(data) {
const baseMat = getMaterial(data.accent, 0.12, 0.76).clone();
const platform = box(scene, 2.45, 0.38, 1.75, data.x, 0.2, 0.15, 0x31383a);
const top = box(scene, 2.25, 0.09, 1.56, data.x, 0.435, 0.15, 0x5b5146);
const outline = group(scene, data.x, 0.51, 0.15);
box(outline, 2.32, 0.035, 0.04, 0, 0, -0.81, data.accent, { emissive: data.accent, emissiveIntensity: 0.55 });
box(outline, 2.32, 0.035, 0.04, 0, 0, 0.81, data.accent, { emissive: data.accent, emissiveIntensity: 0.55 });
box(outline, 0.04, 0.035, 1.62, -1.16, 0, 0, data.accent, { emissive: data.accent, emissiveIntensity: 0.55 });
box(outline, 0.04, 0.035, 1.62, 1.16, 0, 0, data.accent, { emissive: data.accent, emissiveIntensity: 0.55 });
outline.visible = false;
const sign = makeSign(data.sign, '#' + new THREE.Color(data.accent).getHexString());
sign.scale.set(1.65, 0.41, 1);
sign.position.set(data.x, 0.25, 1.035);
scene.add(sign);
stations[data.id] = { platform, top, outline, baseMat, x: data.x };
}
stationData.forEach(createStation);
function createArc(type, shoulder, color) {
const arcGroup = group(shoulder.parent, shoulder.x, shoulder.y, shoulder.z);
const points = [];
if (type === 'hinge') {
for (let i = 0; i <= 42; i++) {
const a = THREE.MathUtils.degToRad(-70 + 140 * i / 42);
points.push(new THREE.Vector3(Math.sin(a) * 0.96, -Math.cos(a) * 0.96, 0.38));
}
} else {
for (let i = 0; i <= 42; i++) {
const a = THREE.MathUtils.degToRad(-70 + 140 * i / 42);
points.push(new THREE.Vector3(Math.sin(a) * 0.9, 0, 0.38));
}
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.65 })
);
arcGroup.add(line);
points.length = 0;
for (let i = 0; i <= 42; i++) {
const a = THREE.MathUtils.degToRad(-42 + 84 * i / 42);
points.push(new THREE.Vector3(0, -Math.cos(a) * 0.9, 0.38));
}
}
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.72 })
);
arcGroup.add(line);
arcGroup.visible = false;
return arcGroup;
}
// Puppet 1: hinge-jointed fox maker's puppet
function buildHinge() {
const root = group(scene, -3.5, 0.49, 0.15);
const orange = 0xd8783f;
const cream = 0xf1d7a7;
const dark = 0x3b3030;
const brass = 0xd4ad69;
box(root, 0.32, 0.88, 0.38, -0.29, 0.46, 0, 0x754f3d);
box(root, 0.32, 0.88, 0.38, 0.29, 0.46, 0, 0x754f3d);
box(root, 0.39, 0.16, 0.57, -0.29, 0.1, 0.08, dark);
box(root, 0.39, 0.16, 0.57, 0.29, 0.1, 0.08, dark);
box(root, 1.02, 1.16, 0.58, 0, 1.45, 0, orange);
box(root, 0.72, 0.69, 0.07, 0, 1.51, 0.325, cream);
box(root, 1.08, 0.14, 0.64, 0, 1.0, 0, dark);
box(root, 0.18, 0.15, 0.08, 0, 1.02, 0.36, brass);
const head = group(root, 0, 2.34, 0.02);
box(head, 0.86, 0.72, 0.68, 0, 0, 0, orange);
box(head, 0.69, 0.46, 0.08, 0, -0.03, 0.37, cream);
box(head, 0.28, 0.2, 0.12, 0, -0.08, 0.44, 0xe7a84f);
box(head, 0.1, 0.13, 0.08, -0.2, 0.11, 0.42, dark);
box(head, 0.1, 0.13, 0.08, 0.2, 0.11, 0.42, dark);
box(head, 0.25, 0.34, 0.16, -0.31, 0.48, -0.02, orange, { rotation: [0, 0, -0.18] });
box(head, 0.25, 0.34, 0.16, 0.31, 0.48, -0.02, orange, { rotation: [0, 0, 0.18] });
box(head, 0.12, 0.08, 0.08, -0.32, 0.56, 0.08, cream);
box(head, 0.12, 0.08, 0.08, 0.32, 0.56, 0.08, cream);
const shoulders = [];
const elbows = [];
for (const side of [-1, 1]) {
const sx = side * 0.72;
const sy = 1.94;
box(root, 0.28, 0.3, 0.66, sx, sy, 0, 0x8f573c);
const shoulder = group(root, sx, sy, 0.02);
box(shoulder, 0.19, 0.22, 0.74, 0, 0, 0, brass, { metalness: 0.45 });
box(shoulder, 0.08, 0.28, 0.79, 0, 0, 0, dark);
const upper = box(shoulder, 0.24, 0.73, 0.27, 0, -0.43, 0, orange);
const elbow = group(shoulder, 0, -0.82, 0);
box(elbow, 0.27, 0.2, 0.31, 0, 0, 0, brass, { metalness: 0.45 });
box(elbow, 0.1, 0.24, 0.35, 0, 0, 0, dark);
const forearm = box(elbow, 0.22, 0.64, 0.25, 0, -0.38, 0, orange);
const hand = group(elbow, 0, -0.76, 0.02);
box(hand, 0.28, 0.25, 0.3, 0, 0, 0, cream);
if (side === 1) {
upper.userData.dragJoint = true;
forearm.userData.dragJoint = true;
// The mallet is parented to the hand, so it can never detach.
box(hand, 0.085, 0.57, 0.085, 0, -0.31, 0, 0x78513d);
box(hand, 0.42, 0.22, 0.28, 0, -0.64, 0, 0xaab0a5, { metalness: 0.3 });
}
shoulders.push(shoulder);
elbows.push(elbow);
}
const arc = createArc('hinge', { parent: root, x: 0.72, y: 1.94, z: 0 }, 0xf1a35b);
return {
root, type: 'hinge', shoulders, elbows, arc,
apply(angle) {
shoulders[1].rotation.z = angle;
shoulders[0].rotation.z = -angle;
elbows[1].rotation.z = angle * 0.5;
elbows[0].rotation.z = -angle * 0.5;
}
};
}
// Puppet 2: ball-jointed workshop robot
function buildBall() {
const root = group(scene, 0, 0.49, 0.15);
const blue = 0x4f8fbf;
const pale = 0xb9ded5;
const dark = 0x243a43;
const metal = 0x739da4;
box(root, 0.26, 0.85, 0.32, -0.25, 0.46, 0, dark);
box(root, 0.26, 0.85, 0.32, 0.25, 0.46, 0, dark);
box(root, 0.42, 0.16, 0.54, -0.25, 0.1, 0.08, 0x1c2e34);
box(root, 0.42, 0.16, 0.54, 0.25, 0.1, 0.08, 0x1c2e34);
box(root, 0.9, 1.06, 0.52, 0, 1.44, 0, blue);
box(root, 0.58, 0.63, 0.07, 0, 1.51, 0.3, pale);
box(root, 0.22, 0.22, 0.08, 0, 1.56, 0.36, 0x6de0d0, {
emissive: 0x42cdbd,
emissiveIntensity: 0.6
});
const head = group(root, 0, 2.31, 0.03);
box(head, 0.78, 0.67, 0.65, 0, 0, 0, blue);
box(head, 0.6, 0.39, 0.08, 0, -0.02, 0.36, dark);
box(head, 0.11, 0.11, 0.06, -0.15, 0, 0.42, 0x73e0d0, {
emissive: 0x43d5c1,
emissiveIntensity: 0.75
});
box(head, 0.11, 0.11, 0.06, 0.15, 0, 0.42, 0x73e0d0, {
emissive: 0x43d5c1,
emissiveIntensity: 0.75
});
box(head, 0.07, 0.36, 0.07, 0, 0.5, 0, metal, { metalness: 0.55 });
sphere(head, 0.11, 0, 0.71, 0, 0xf2b866, {
emissive: 0xe89e42,
emissiveIntensity: 0.55
});
const shoulders = [];
const elbows = [];
for (const side of [-1, 1]) {
const sx = side * 0.68;
const sy = 1.9;
sphere(root, 0.255, sx, sy, 0.03, metal, { metalness: 0.55, roughness: 0.38 });
const shoulder = group(root, sx, sy, 0.03);
sphere(shoulder, 0.215, 0, 0, 0, 0x8cb9bc, { metalness: 0.55, roughness: 0.35 });
const upper = box(shoulder, 0.22, 0.69, 0.25, 0, -0.42, 0, blue);
const elbow = group(shoulder, 0, -0.78, 0);
sphere(elbow, 0.185, 0, 0, 0, metal, { metalness: 0.55, roughness: 0.38 });
const forearm = box(elbow, 0.21, 0.58, 0.23, 0, -0.36, 0, pale);
const hand = group(elbow, 0, -0.7, 0.02);
box(hand, 0.27, 0.23, 0.28, 0, 0, 0, pale);
if (side === 1) {
upper.userData.dragJoint = true;
forearm.userData.dragJoint = true;
// A yarn spool remains rigidly attached to Pip's hand.
box(hand, 0.32, 0.18, 0.32, 0, -0.13, 0, 0xd48169);
box(hand, 0.08, 0.36, 0.08, 0, -0.13, 0, 0xe5b26d);
box(hand, 0.36, 0.08, 0.36, 0, -0.3, 0, 0xe5b26d);
}
shoulders.push(shoulder);
elbows.push(elbow);
}
const arc = createArc('ball', { parent: root, x: 0.68, y: 1.9, z: 0 }, 0x68d6cb);
return {
root, type: 'ball', shoulders, elbows, arc,
apply(yaw, pitch) {
shoulders[1].rotation.order = 'YXZ';
shoulders[0].rotation.order = 'YXZ';
shoulders[1].rotation.y = yaw;
shoulders[1].rotation.x = pitch;
shoulders[0].rotation.y = -yaw;
shoulders[0].rotation.x = pitch;
elbows[1].rotation.y = yaw * 0.32;
elbows[1].rotation.x = pitch * 0.42;
elbows[0].rotation.y = -yaw * 0.32;
elbows[0].rotation.x = pitch * 0.42;
}
};
}
// Puppet 3: completely rigid, peg-joined wooden figure
function buildFixed() {
const root = group(scene, 3.5, 0.49, 0.15);
const green = 0x5f8c62;
const wood = 0xb48b5d;
const dark = 0x35443a;
const peg = 0xd4bd8f;
box(root, 0.34, 0.86, 0.42, -0.28, 0.46, 0, wood);
box(root, 0.34, 0.86, 0.42, 0.28, 0.46, 0, wood);
box(root, 0.43, 0.16, 0.62, -0.28, 0.1, 0.08, dark);
box(root, 0.43, 0.16, 0.62, 0.28, 0.1, 0.08, dark);
box(root, 1.04, 1.18, 0.58, 0, 1.44, 0, green);
box(root, 0.66, 0.62, 0.07, 0, 1.49, 0.325, 0x8dab7d);
box(root, 1.09, 0.13, 0.65, 0, 0.98, 0, wood);
box(root, 0.16, 0.16, 0.08, 0, 1.0, 0.36, peg);
const head = group(root, 0, 2.34, 0);
box(head, 0.82, 0.7, 0.66, 0, 0, 0, wood);
box(head, 0.76, 0.24, 0.74, 0, 0.39, 0, green);
box(head, 0.1, 0.12, 0.07, -0.19, 0.05, 0.37, dark);
box(head, 0.1, 0.12, 0.07, 0.19, 0.05, 0.37, dark);
box(head, 0.23, 0.08, 0.07, 0, -0.16, 0.37, dark);
for (const side of [-1, 1]) {
const sx = side * 0.73;
const sy = 1.92;
box(root, 0.31, 0.31, 0.63, sx, sy, 0, peg);
box(root, 0.1, 0.1, 0.7, sx, sy, 0, dark);
const rigidArm = group(root, sx, sy - 0.13, 0);
rigidArm.rotation.z = side * 0.17;
box(rigidArm, 0.23, 0.85, 0.27, 0, -0.42, 0, green);
box(rigidArm, 0.28, 0.27, 0.3, 0, -0.88, 0.02, wood);
if (side === 1) {
// Rigid paintbrush attachment.
box(rigidArm, 0.075, 0.62, 0.075, 0, -1.18, 0.04, 0x694936);
box(rigidArm, 0.23, 0.25, 0.12, 0, -1.56, 0.04, 0x784a3d);
}
}
const arc = group(root, 0.73, 1.92, 0.05);
const lockMat = new THREE.LineBasicMaterial({ color: 0xa8cf83, transparent: true, opacity: 0.65 });
const lockPoints = [
new THREE.Vector3(-0.29, -0.29, 0.38),
new THREE.Vector3(0.29, -0.29, 0.38),
new THREE.Vector3(0.29, 0.29, 0.38),
new THREE.Vector3(-0.29, 0.29, 0.38),
new THREE.Vector3(-0.29, -0.29, 0.38)
];
arc.add(new THREE.Line(new THREE.BufferGeometry().setFromPoints(lockPoints), lockMat));
arc.visible = false;
return {
root, type: 'fixed', shoulders: [], elbows: [], arc,
apply() {}
};
}
rigs.hinge = buildHinge();
rigs.ball = buildBall();
rigs.fixed = buildFixed();
for (const [id, rig] of Object.entries(rigs)) {
rig.root.traverse(object => {
if (object.isMesh) object.userData.puppetId = id;
});
}
const motion = {
hinge: { current: 0, target: 0, animating: false },
ball: { currentYaw: 0, currentPitch: 0, targetYaw: 0, targetPitch: 0, animating: false },
fixed: { current: 0, target: 0, animating: false }
};
let selected = 'hinge';
let globalCompare = true;
let drag = null;
let orbit = null;
let toastTimer;
const hingeInput = document.querySelector('#hingeAngle');
const yawInput = document.querySelector('#ballYaw');
const pitchInput = document.querySelector('#ballPitch');
const hingeValue = document.querySelector('#hingeValue');
const yawValue = document.querySelector('#yawValue');
const pitchValue = document.querySelector('#pitchValue');
const compareButton = document.querySelector('#compareAll');
const playButton = document.querySelector('#playSelected');
const selectedName = document.querySelector('#selectedName');
const names = {
hinge: 'Rivet Rhea · hinge',
ball: 'Pebble Pip · ball socket',
fixed: 'Oaklock · fixed peg'
};
function showToast(message) {
toast.textContent = message;
toast.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove('show'), 2600);
}
function selectPuppet(id) {
selected = id;
document.querySelectorAll('[data-card]').forEach(card => {
card.classList.toggle('selected', card.dataset.card === id);
});
selectedName.textContent = names[id];
for (const [rigId, rig] of Object.entries(rigs)) {
rig.arc.visible = rigId === id;
stations[rigId].outline.visible = rigId === id;
}
if (id === 'fixed') {
statusText.textContent = 'Fixed rig selected · rotation deliberately locked';
} else {
statusText.textContent = globalCompare
? 'Rigs connected · compare mode running'
: 'Rigs connected · drag the right arm or use a slider';
}
syncInputs();
}
function syncInputs() {
const h = THREE.MathUtils.radToDeg(motion.hinge.target);
const y = THREE.MathUtils.radToDeg(motion.ball.targetYaw);
const p = THREE.MathUtils.radToDeg(motion.ball.targetPitch);
hingeInput.value = Math.round(h);
yawInput.value = Math.round(y);
pitchInput.value = Math.round(p);
hingeValue.value = `${Math.round(h)}°`;
yawValue.value = `${Math.round(y)}°`;
pitchValue.value = `${Math.round(p)}°`;
compareButton.textContent = globalCompare ? 'Ⅱ Pause comparison' : '⇄ Compare all';
compareButton.classList.toggle('active', globalCompare);
playButton.textContent = motion[selected].animating ? 'Ⅱ Stop selected' : '▶ Animate selected';
}
document.querySelectorAll('[data-select]').forEach(button => {
button.addEventListener('click', () => selectPuppet(button.dataset.select));
});
hingeInput.addEventListener('input', () => {
motion.hinge.target = THREE.MathUtils.degToRad(Number(hingeInput.value));
motion.hinge.animating = false;
globalCompare = false;
syncInputs();
});
yawInput.addEventListener('input', () => {
motion.ball.targetYaw = THREE.MathUtils.degToRad(Number(yawInput.value));
motion.ball.animating = false;
globalCompare = false;
syncInputs();
});
pitchInput.addEventListener('input', () => {
motion.ball.targetPitch = THREE.MathUtils.degToRad(Number(pitchInput.value));
motion.ball.animating = false;
globalCompare = false;
syncInputs();
});
compareButton.addEventListener('click', () => {
globalCompare = !globalCompare;
if (globalCompare) {
motion.hinge.animating = false;
motion.ball.animating = false;
}
syncInputs();
});
playButton.addEventListener('click', () => {
if (selected === 'fixed') {
showToast('Oaklock’s peg joints are fixed. No rotation is allowed.');
return;
}
globalCompare = false;
motion[selected].animating = !motion[selected].animating;
syncInputs();
});
document.querySelector('#resetAll').addEventListener('click', () => {
globalCompare = false;
motion.hinge.target = 0;
motion.hinge.animating = false;
motion.ball.targetYaw = 0;
motion.ball.targetPitch = 0;
motion.ball.animating = false;
syncInputs();
showToast('All articulated puppets returned to their neutral pose.');
});
// Direct camera controls; no examples or addons are used.
function updateCamera() {
const { azimuth, elevation, radius, target } = cameraState;
camera.position.set(
target.x + radius * Math.sin(azimuth) * Math.cos(elevation),
target.y + radius * Math.sin(elevation),
target.z + radius * Math.cos(azimuth) * Math.cos(elevation)
);
camera.lookAt(target);
}
updateCamera();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function setPointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
canvas.addEventListener('pointerdown', event => {
if (event.button !== 0) return;
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const roots = Object.values(rigs).map(rig => rig.root);
const hit = raycaster.intersectObjects(roots, true)
.find(intersection => intersection.object.isMesh && intersection.object.userData.puppetId);
if (hit) {
const id = hit.object.userData.puppetId;
selectPuppet(id);
if (id === 'fixed') {
showToast('Oaklock is a rigid peg puppet: its arm and brush are deliberately locked.');
return;
}
if (hit.object.userData.dragJoint) {
drag = {
id,
pointerId: event.pointerId,
startX: event.clientX,
startY: event.clientY,
startAngle: motion.hinge.target,
startYaw: motion.ball.targetYaw,
startPitch: motion.ball.targetPitch
};
canvas.setPointerCapture(event.pointerId);
event.preventDefault();
return;
}
}
orbit = {
pointerId: event.pointerId,
startX: event.clientX,
startY: event.clientY,
azimuth: cameraState.azimuth,
elevation: cameraState.elevation
};
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener('pointermove', event => {
if (drag && drag.pointerId === event.pointerId) {
const dx = event.clientX - drag.startX;
const dy = event.clientY - drag.startY;
globalCompare = false;
if (drag.id === 'hinge') {
motion.hinge.target = THREE.MathUtils.clamp(
drag.startAngle + dx * 0.009,
THREE.MathUtils.degToRad(-70),
THREE.MathUtils.degToRad(70)
);
motion.hinge.animating = false;
} else if (drag.id === 'ball') {
motion.ball.targetYaw = THREE.MathUtils.clamp(
drag.startYaw + dx * 0.0065,
THREE.MathUtils.degToRad(-70),
THREE.MathUtils.degToRad(70)
);
motion.ball.targetPitch = THREE.MathUtils.clamp(
drag.startPitch + dy * 0.006,
THREE.MathUtils.degToRad(-42),
THREE.MathUtils.degToRad(42)
);
motion.ball.animating = false;
}
syncInputs();
event.preventDefault();
return;
}
if (orbit && orbit.pointerId === event.pointerId) {
const dx = event.clientX - orbit.startX;
const dy = event.clientY - orbit.startY;
cameraState.azimuth = orbit.azimuth - dx * 0.005;
cameraState.elevation = THREE.MathUtils.clamp(
orbit.elevation + dy * 0.004,
0.12,
0.67
);
updateCamera();
event.preventDefault();
}
});
function endPointer(event) {
if (drag && drag.pointerId === event.pointerId) drag = null;
if (orbit && orbit.pointerId === event.pointerId) orbit = null;
}
canvas.addEventListener('pointerup', endPointer);
canvas.addEventListener('pointercancel', endPointer);
canvas.addEventListener('wheel', event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.009,
8.2,
17.5
);
updateCamera();
}, { passive: false });
canvas.addEventListener('contextmenu', event => event.preventDefault());
const labels = [...document.querySelectorAll('.station-label')];
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labels) {
const id = label.dataset.select;
projected.set(stations[id].x, 3.92, 0.18).project(camera);
const visible = projected.z < 1;
label.style.display = visible ? 'block' : 'none';
label.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
label.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener('resize', resize);
selectPuppet('hinge');
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
if (globalCompare) {
motion.hinge.target = Math.sin(time * 1.32) * THREE.MathUtils.degToRad(58);
motion.ball.targetYaw = Math.sin(time * 1.08) * THREE.MathUtils.degToRad(55);
motion.ball.targetPitch = Math.sin(time * 1.63 + 0.4) * THREE.MathUtils.degToRad(27);
} else {
if (motion.hinge.animating) {
motion.hinge.target = Math.sin(time * 1.45) * THREE.MathUtils.degToRad(62);
}
if (motion.ball.animating) {
motion.ball.targetYaw = Math.sin(time * 1.15) * THREE.MathUtils.degToRad(52);
motion.ball.targetPitch = Math.cos(time * 0.92) * THREE.MathUtils.degToRad(31);
}
}
const damping = 1 - Math.exp(-dt * 9);
motion.hinge.current += (motion.hinge.target - motion.hinge.current) * damping;
motion.ball.currentYaw += (motion.ball.targetYaw - motion.ball.currentYaw) * damping;
motion.ball.currentPitch += (motion.ball.targetPitch - motion.ball.currentPitch) * damping;
rigs.hinge.apply(motion.hinge.current);
rigs.ball.apply(motion.ball.currentYaw, motion.ball.currentPitch);
syncInputs();
updateLabels();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.classList.add('hidden');
setTimeout(() => loading.remove(), 450);
}
}
animate();
</script>
</body>
</html>
```