Prompt specification
Build or customize the Three.js 3D scene "Entryway hanging gesture" 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: Entryway hanging gesture
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/entryway-hanging-gesture-x0006
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a coat-hook rail. Place a jacket beside a wall hook and animate a simple arm lifting its collar loop onto the hook; clothing must settle below the support. Voxel style.
Working Three.js Starter (entryway-hanging-gesture-x0006):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Coat Hook</title>
<style>
:root {
color-scheme: light;
--ink: #183042;
--paper: rgba(255, 252, 244, 0.88);
--accent: #e98652;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e0d1;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
#scene {
position: fixed;
inset: 0;
touch-action: none;
}
canvas {
display: block;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
top: 22px;
left: 22px;
width: min(330px, calc(100vw - 44px));
padding: 17px 18px 16px;
color: var(--ink);
background: var(--paper);
border: 2px solid rgba(24, 48, 66, 0.14);
box-shadow: 0 12px 35px rgba(37, 42, 43, 0.13);
backdrop-filter: blur(9px);
user-select: none;
}
.eyebrow {
margin-bottom: 7px;
color: #9a5b3f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0 0 9px;
font-size: clamp(20px, 4vw, 29px);
line-height: 0.98;
letter-spacing: -0.055em;
text-transform: uppercase;
}
.subtitle {
margin: 0;
color: #65727a;
font-size: 11px;
line-height: 1.5;
}
.status-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 15px;
padding-top: 13px;
border-top: 1px solid rgba(24, 48, 66, 0.12);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
}
.status-dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(233, 134, 82, 0.15);
}
.progress {
height: 5px;
margin-top: 11px;
overflow: hidden;
background: rgba(24, 48, 66, 0.1);
}
#progress-fill {
width: 0;
height: 100%;
background: var(--accent);
transform-origin: left;
}
.controls {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 13px;
}
button {
appearance: none;
border: 0;
padding: 9px 13px;
color: #fffaf0;
background: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
transition: transform 120ms ease, background 120ms ease;
}
button:hover {
background: #29485e;
transform: translateY(-1px);
}
button:active {
transform: translateY(1px);
}
.hint {
color: #788087;
font-size: 9px;
line-height: 1.4;
text-align: right;
}
@media (max-width: 600px) {
.panel {
top: 12px;
left: 12px;
width: min(300px, calc(100vw - 24px));
padding: 14px;
}
.subtitle {
display: none;
}
.status-row {
margin-top: 11px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Animated voxel coat hook scene"></div>
<section class="panel">
<div class="eyebrow">Voxel study / 01</div>
<h1>Hook & Settle</h1>
<p class="subtitle">A tiny arm lifts the collar loop, places it on the wall hook, and lets the jacket settle naturally below the support.</p>
<div class="status-row">
<span class="status-dot"></span>
<span id="status">01 / REACHING FOR THE LOOP</span>
</div>
<div class="progress"><div id="progress-fill"></div></div>
<div class="controls">
<button id="replay" type="button">Replay</button>
<span class="hint">Drag to orbit<br>Scroll to zoom</span>
</div>
</section>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const mount = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e0d1);
scene.fog = new THREE.Fog(0xe8e0d1, 11, 19);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.BasicShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
mount.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
40
);
const cameraTarget = new THREE.Vector3(0.05, 2.0, 0.15);
const cameraState = {
theta: 0.25,
phi: 1.18,
radius: 8.4
};
function updateCamera() {
const s = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x + cameraState.radius * s * Math.sin(cameraState.theta),
cameraTarget.y + cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z + cameraState.radius * s * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct, dependency-free camera controls.
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.005,
0.72,
1.43
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
5.7,
11
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
cameraState.theta = 0.25;
cameraState.phi = 1.18;
cameraState.radius = 8.4;
updateCamera();
});
// -------------------------------------------------------------------------
// Voxel material and geometry helpers
// -------------------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.86,
metalness: options.metalness ?? 0,
flatShading: true,
...options
});
}
const mat = {
wall: material(0xe8dfce),
wallPanel: material(0xf1e9da),
wallLine: material(0xd6cbb8),
floor: material(0xc9b99f),
floorLine: material(0xb9a88d),
baseboard: material(0xf4ecdc),
rail: material(0x6f4a35),
railEdge: material(0x9a6846),
hook: material(0x303e46, { metalness: 0.2, roughness: 0.48 }),
hookHighlight: material(0xd39a55, { metalness: 0.12, roughness: 0.55 }),
jacket: material(0x1e405b),
jacketLight: material(0x2b5878),
jacketDark: material(0x132c42),
lining: material(0xd88755),
loop: material(0xf0b65d),
zipper: material(0xf1cd7b, { metalness: 0.42, roughness: 0.4 }),
sleeve: material(0xcc694f),
skin: material(0xe6b68b),
joint: material(0xd99a76)
};
function box(parent, width, height, depth, x, y, z, boxMaterial, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
boxMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Room: everything is assembled from rectangular voxel blocks.
// -------------------------------------------------------------------------
const room = new THREE.Group();
scene.add(room);
box(room, 12, 7.5, 0.28, 0, 3.45, -0.52, mat.wall);
box(room, 5.35, 2.65, 0.08, 0.2, 2.05, -0.335, mat.wallPanel);
box(room, 12, 0.28, 8.4, 0, -0.14, 1.55, mat.floor);
box(room, 12, 0.32, 0.16, 0, 0.16, -0.31, mat.baseboard);
// Subtle block seams in the wall panel.
for (let x = -2.0; x <= 2.5; x += 1.0) {
box(room, 0.018, 2.5, 0.012, x, 2.05, -0.29, mat.wallLine, false);
}
for (let y = 0.9; y <= 3.2; y += 0.75) {
box(room, 5.18, 0.018, 0.012, 0.2, y, -0.29, mat.wallLine, false);
}
// Floor seams.
for (let x = -5; x <= 5; x += 1.5) {
box(room, 0.025, 0.012, 7.7, x, 0.008, 1.7, mat.floorLine, false);
}
for (let z = -1.0; z <= 6; z += 1.5) {
box(room, 11.8, 0.012, 0.025, 0, 0.009, z, mat.floorLine, false);
}
// -------------------------------------------------------------------------
// Coat-hook rail
// -------------------------------------------------------------------------
const rail = new THREE.Group();
scene.add(rail);
box(rail, 4.85, 0.34, 0.24, 0.2, 2.57, -0.18, mat.rail);
box(rail, 4.6, 0.09, 0.10, 0.2, 2.73, -0.055, mat.railEdge);
const hookXs = [-1.65, -0.45, 0.75, 1.95];
const targetHookX = -0.45;
const sideHookX = 1.95;
function createHook(x, highlighted = false) {
const hook = new THREE.Group();
hook.position.x = x;
rail.add(hook);
box(hook, 0.25, 0.34, 0.20, 0, 2.58, -0.01, mat.hook);
box(hook, 0.17, 0.14, 0.38, 0, 2.62, 0.20, mat.hook);
box(hook, 0.17, 0.24, 0.14, 0, 2.73, 0.32, highlighted ? mat.hookHighlight : mat.hook);
box(hook, 0.21, 0.055, 0.19, 0, 2.43, -0.005, mat.hook);
return hook;
}
hookXs.forEach((x) => createHook(x, x === targetHookX));
// Small square marker identifies the destination hook.
box(rail, 0.075, 0.075, 0.035, targetHookX, 2.98, -0.035, mat.hookHighlight);
// -------------------------------------------------------------------------
// Jacket, built as stacked voxel blocks
// -------------------------------------------------------------------------
const jacket = new THREE.Group();
scene.add(jacket);
// Main torso.
box(jacket, 0.82, 0.72, 0.34, 0, -0.48, 0, mat.jacket);
box(jacket, 0.88, 0.35, 0.37, 0, -0.96, 0, mat.jacketDark);
box(jacket, 0.86, 0.10, 0.39, 0, -1.08, 0, mat.jacketLight);
box(jacket, 0.42, 0.47, 0.38, 0, -0.70, 0, mat.jacketLight);
// Shoulders and stepped sleeves.
box(jacket, 0.30, 0.38, 0.38, -0.51, -0.20, 0, mat.jacketLight);
box(jacket, 0.30, 0.38, 0.38, 0.51, -0.20, 0, mat.jacketLight);
box(jacket, 0.27, 0.52, 0.34, -0.64, -0.50, 0, mat.jacket);
box(jacket, 0.25, 0.43, 0.32, -0.74, -0.91, 0.015, mat.jacketLight);
box(jacket, 0.27, 0.13, 0.34, -0.75, -1.13, 0.015, mat.jacketDark);
box(jacket, 0.27, 0.52, 0.34, 0.64, -0.50, 0, mat.jacket);
box(jacket, 0.25, 0.43, 0.32, 0.74, -0.91, 0.015, mat.jacketLight);
box(jacket, 0.27, 0.13, 0.34, 0.75, -1.13, 0.015, mat.jacketDark);
// Collar, lining, and loop attachment tabs.
box(jacket, 0.28, 0.22, 0.18, -0.19, 0.015, 0.16, mat.jacketLight);
box(jacket, 0.28, 0.22, 0.18, 0.19, 0.015, 0.16, mat.jacketLight);
box(jacket, 0.25, 0.25, 0.12, 0, 0.015, 0.23, mat.lining);
box(jacket, 0.075, 0.24, 0.13, -0.16, 0.12, 0.20, mat.loop);
box(jacket, 0.075, 0.24, 0.13, 0.16, 0.12, 0.20, mat.loop);
// Zipper and pocket blocks.
box(jacket, 0.045, 0.78, 0.035, 0, -0.46, 0.205, mat.zipper);
box(jacket, 0.075, 0.075, 0.045, 0, -0.22, 0.23, mat.zipper);
box(jacket, 0.25, 0.055, 0.04, -0.26, -0.79, 0.205, mat.jacketDark);
box(jacket, 0.25, 0.055, 0.04, 0.26, -0.79, 0.205, mat.jacketDark);
// A few raised seams emphasize the block construction.
box(jacket, 0.025, 0.52, 0.025, -0.39, -0.47, 0.19, mat.jacketDark);
box(jacket, 0.025, 0.52, 0.025, 0.39, -0.47, 0.19, mat.jacketDark);
// -------------------------------------------------------------------------
// Collar loop: an open, block-built inverted U.
// -------------------------------------------------------------------------
const collarLoop = new THREE.Group();
scene.add(collarLoop);
box(collarLoop, 0.08, 0.28, 0.11, -0.16, -0.06, 0, mat.loop);
box(collarLoop, 0.08, 0.28, 0.11, 0.16, -0.06, 0, mat.loop);
box(collarLoop, 0.40, 0.10, 0.11, 0, 0.11, 0, mat.loop);
box(collarLoop, 0.11, 0.13, 0.12, -0.16, -0.18, 0, mat.zipper);
box(collarLoop, 0.11, 0.13, 0.12, 0.16, -0.18, 0, mat.zipper);
// -------------------------------------------------------------------------
// Articulated voxel arm
// -------------------------------------------------------------------------
const arm = new THREE.Group();
scene.add(arm);
const upperArm = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
mat.sleeve
);
const forearm = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
mat.skin
);
upperArm.castShadow = true;
forearm.castShadow = true;
upperArm.receiveShadow = true;
forearm.receiveShadow = true;
arm.add(upperArm, forearm);
const elbowJoint = box(arm, 0.34, 0.34, 0.34, 0, 0, 0, mat.joint);
const shoulderJoint = box(arm, 0.39, 0.39, 0.39, 0, 0, 0, mat.sleeve);
const hand = new THREE.Group();
arm.add(hand);
box(hand, 0.31, 0.30, 0.27, 0, 0, 0, mat.skin);
box(hand, 0.065, 0.14, 0.22, -0.085, -0.07, -0.18, mat.skin);
box(hand, 0.065, 0.14, 0.22, 0, -0.08, -0.20, mat.skin);
box(hand, 0.065, 0.14, 0.22, 0.085, -0.07, -0.18, mat.skin);
box(hand, 0.09, 0.09, 0.17, -0.18, 0.01, -0.08, mat.joint);
const yAxis = new THREE.Vector3(0, 1, 0);
function placeSegment(mesh, start, end, width) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(yAxis, direction.normalize());
mesh.scale.set(width, length, width);
}
function updateArm(shoulder, handPosition) {
const upperLength = 1.62;
const lowerLength = 1.52;
const direction = new THREE.Vector3().subVectors(handPosition, shoulder);
const distance = Math.min(direction.length(), upperLength + lowerLength - 0.01);
direction.normalize();
const along = (
upperLength * upperLength -
lowerLength * lowerLength +
distance * distance
) / (2 * distance);
const height = Math.sqrt(Math.max(0, upperLength * upperLength - along * along));
const bend = new THREE.Vector3(0, -1, 0);
bend.addScaledVector(direction, -bend.dot(direction)).normalize();
const elbow = shoulder.clone()
.addScaledVector(direction, along)
.addScaledVector(bend, height);
placeSegment(upperArm, shoulder, elbow, 0.34);
placeSegment(forearm, elbow, handPosition, 0.27);
elbowJoint.position.copy(elbow);
shoulderJoint.position.copy(shoulder);
hand.position.copy(handPosition);
}
// -------------------------------------------------------------------------
// Animation helpers
// -------------------------------------------------------------------------
const duration = 8.4;
let startTime = performance.now() / 1000;
const sideLoopPosition = new THREE.Vector3(sideHookX, 2.82, 0.46);
const targetLoopPosition = new THREE.Vector3(targetHookX, 2.82, 0.46);
const highPosition = new THREE.Vector3(0, 0, 0);
const restShoulder = new THREE.Vector3(4.35, 3.02, 1.18);
const grabShoulder = new THREE.Vector3(3.10, 3.05, 1.12);
const carryShoulder = new THREE.Vector3(2.18, 3.30, 1.13);
const restHand = new THREE.Vector3(3.82, 2.55, 1.04);
function clamp01(value) {
return Math.max(0, Math.min(1, value));
}
function smooth(value) {
const t = clamp01(value);
return t * t * (3 - 2 * t);
}
function smoother(value) {
const t = clamp01(value);
return t * t * t * (t * (t * 6 - 15) + 10);
}
function interpolateKeyframes(time, frames, output) {
if (time <= frames[0].time) {
output.copy(frames[0].value);
return output;
}
for (let i = 0; i < frames.length - 1; i++) {
const a = frames[i];
const b = frames[i + 1];
if (time <= b.time) {
const amount = smoother((time - a.time) / (b.time - a.time));
output.copy(a.value).lerp(b.value, amount);
return output;
}
}
output.copy(frames[frames.length - 1].value);
return output;
}
const loopFrames = [
{ time: 0.00, value: sideLoopPosition.clone() },
{ time: 0.18, value: sideLoopPosition.clone() },
{ time: 0.40, value: new THREE.Vector3(sideHookX, 3.28, 0.52) },
{ time: 0.60, value: new THREE.Vector3(targetHookX, 3.28, 0.52) },
{ time: 0.72, value: targetLoopPosition.clone() },
{ time: 1.00, value: targetLoopPosition.clone() }
];
const currentLoopPosition = new THREE.Vector3();
const currentHand = new THREE.Vector3();
const currentShoulder = new THREE.Vector3();
function updateScene(t) {
interpolateKeyframes(t, loopFrames, currentLoopPosition);
collarLoop.position.copy(currentLoopPosition);
// The jacket follows the lifted loop, then settles below the hook.
if (t < 0.18) {
jacket.position.set(sideHookX, 2.62, 0.31);
jacket.rotation.set(0, 0, 0);
} else if (t < 0.72) {
jacket.position.set(
currentLoopPosition.x,
currentLoopPosition.y - 0.20,
0.31
);
const travel = smooth((t - 0.18) / 0.54);
jacket.rotation.z = Math.sin(travel * Math.PI) * -0.035;
jacket.rotation.y = Math.sin(travel * Math.PI) * 0.045;
} else {
const settle = smooth((t - 0.72) / 0.22);
const settleTime = t - 0.72;
jacket.position.set(
targetHookX + Math.sin(settleTime * 28) * 0.045 * (1 - settle),
2.62 - 0.10 * settle,
0.31
);
jacket.rotation.z = Math.sin(settleTime * 24) * 0.055 * (1 - settle);
jacket.rotation.y = Math.sin(settleTime * 19) * 0.035 * (1 - settle);
}
// Arm reaches, grips, carries, releases, and retracts.
if (t < 0.18) {
const amount = smooth(t / 0.18);
currentHand.copy(restHand).lerp(
sideLoopPosition.clone().add(new THREE.Vector3(0, 0.20, 0.16)),
amount
);
currentShoulder.copy(restShoulder).lerp(grabShoulder, amount);
} else if (t < 0.72) {
currentHand.copy(currentLoopPosition).add(new THREE.Vector3(0, 0.20, 0.16));
const carryAmount = smooth((t - 0.18) / 0.54);
currentShoulder.copy(grabShoulder).lerp(carryShoulder, carryAmount);
} else if (t < 0.84) {
const amount = smooth((t - 0.72) / 0.12);
const releaseHand = targetLoopPosition.clone().add(
new THREE.Vector3(0.08, 0.23, 0.17)
);
currentHand.copy(releaseHand).lerp(restHand, amount);
currentShoulder.copy(carryShoulder).lerp(restShoulder, amount);
} else {
currentHand.copy(restHand);
currentShoulder.copy(restShoulder);
}
updateArm(currentShoulder, currentHand);
// UI state.
const progressFill = document.getElementById("progress-fill");
const status = document.getElementById("status");
progressFill.style.width = `${t * 100}%`;
if (t < 0.18) {
status.textContent = "01 / REACHING FOR THE LOOP";
} else if (t < 0.40) {
status.textContent = "02 / LIFTING THE COLLAR";
} else if (t < 0.72) {
status.textContent = "03 / PLACING ON THE HOOK";
} else if (t < 0.94) {
status.textContent = "04 / LETTING THE JACKET SETTLE";
} else {
status.textContent = "05 / HANGING BELOW THE SUPPORT";
}
}
document.getElementById("replay").addEventListener("click", () => {
startTime = performance.now() / 1000;
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function render() {
requestAnimationFrame(render);
const t = clamp01((clock.getElapsedTime() - startTime) / duration);
updateScene(t);
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
updateCamera();
});
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff6df, 0x78808a, 2.0));
const keyLight = new THREE.DirectionalLight(0xfff2d4, 3.25);
keyLight.position.set(4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -2;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 20;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb8d5ed, 1.05);
fillLight.position.set(-5, 4, 3);
scene.add(fillLight);
const warmLight = new THREE.PointLight(0xffbd78, 10, 8, 2);
warmLight.position.set(-2.2, 3.8, 2.4);
scene.add(warmLight);
render();
</script>
</body>
</html>
```