Prompt specification
Build or customize the Three.js 3D scene "Push Pull and Carry Demonstration" 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: Push Pull and Carry Demonstration
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/push-pull-and-carry-demonstration-x3434
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows verbs grounded in object actions and state changes. Animate an original figure moving the same crate by pushing, pulling, and carrying. Distinguish contact positions and whether the crate remains supported by the floor. Stylized solid forms.
Working Three.js Starter (push-pull-and-carry-demonstration-x3434):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Object Verbs — Push, Pull, Carry</title>
<style>
:root {
--ink: #173431;
--muted: #617572;
--paper: rgba(250, 252, 248, 0.88);
--line: rgba(23, 52, 49, 0.13);
--teal: #167d78;
--amber: #f0a52e;
--orange: #e6653f;
--green: #2da66f;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe7e3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(23,52,49,.06), transparent 24%),
radial-gradient(circle at 50% 45%, transparent 45%, rgba(23,52,49,.10) 120%);
}
header {
position: fixed;
top: 24px;
left: 28px;
z-index: 5;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
font-size: 11px;
font-weight: 800;
letter-spacing: .18em;
text-transform: uppercase;
color: var(--teal);
}
.eyebrow::before {
content: "";
width: 22px;
height: 3px;
border-radius: 99px;
background: var(--teal);
}
h1 {
margin: 0;
max-width: 480px;
font-size: clamp(27px, 3vw, 48px);
line-height: .96;
letter-spacing: -.045em;
font-weight: 820;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
letter-spacing: .01em;
}
#readout {
position: fixed;
z-index: 6;
top: 24px;
right: 24px;
width: min(330px, calc(100vw - 48px));
padding: 18px;
border: 1px solid rgba(255,255,255,.58);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(33,67,62,.12);
backdrop-filter: blur(16px);
}
.readout-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 13px;
}
#phase-number {
font-size: 10px;
font-weight: 850;
letter-spacing: .14em;
text-transform: uppercase;
color: var(--muted);
}
#phase-name {
margin: 0;
font-size: 34px;
line-height: 1;
letter-spacing: -.04em;
color: var(--teal);
}
#phase-definition {
min-height: 36px;
margin: 9px 0 15px;
font-size: 13px;
line-height: 1.45;
color: var(--muted);
}
.datum {
display: grid;
grid-template-columns: 92px 1fr;
gap: 10px;
align-items: start;
padding: 10px 0;
border-top: 1px solid var(--line);
font-size: 12px;
line-height: 1.35;
}
.datum-label {
color: var(--muted);
font-weight: 750;
text-transform: uppercase;
letter-spacing: .08em;
font-size: 9px;
padding-top: 2px;
}
.datum-value {
font-weight: 720;
}
#support-value.supported { color: var(--green); }
#support-value.unsupported { color: var(--orange); }
.legend {
display: flex;
flex-wrap: wrap;
gap: 13px;
margin-top: 14px;
padding-top: 13px;
border-top: 1px solid var(--line);
font-size: 10px;
font-weight: 750;
color: var(--muted);
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--amber);
box-shadow: 0 0 0 3px rgba(240,165,46,.16);
}
.dot.green {
background: var(--green);
box-shadow: 0 0 0 3px rgba(45,166,111,.15);
}
#controls {
position: fixed;
z-index: 8;
left: 50%;
bottom: 24px;
transform: translateX(-50%);
width: min(680px, calc(100vw - 40px));
padding: 12px;
border: 1px solid rgba(255,255,255,.62);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 16px 45px rgba(33,67,62,.13);
backdrop-filter: blur(16px);
}
.timeline {
position: relative;
height: 4px;
margin: 0 4px 13px;
overflow: hidden;
border-radius: 99px;
background: rgba(23,52,49,.10);
}
#progress {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--teal), #42a78f);
}
.button-row {
display: grid;
grid-template-columns: repeat(3, 1fr) auto auto;
align-items: center;
gap: 8px;
}
button {
appearance: none;
border: 0;
border-radius: 12px;
padding: 11px 13px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 850;
letter-spacing: .08em;
text-transform: uppercase;
cursor: pointer;
transition: background .18s ease, color .18s ease, transform .18s ease;
}
button:hover { background: rgba(22,125,120,.08); }
button:active { transform: translateY(1px); }
button.active {
background: var(--teal);
color: white;
}
.divider {
width: 1px;
height: 25px;
background: var(--line);
}
.icon-button {
min-width: 42px;
padding-inline: 12px;
font-size: 15px;
letter-spacing: 0;
}
.hint {
position: fixed;
z-index: 5;
left: 28px;
bottom: 31px;
max-width: 230px;
color: rgba(23,52,49,.58);
font-size: 10px;
line-height: 1.45;
pointer-events: none;
}
#fade {
position: fixed;
inset: 0;
z-index: 20;
pointer-events: none;
opacity: 0;
background: #e3ece8;
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #dbe7e3;
color: var(--teal);
font-size: 12px;
font-weight: 850;
letter-spacing: .18em;
text-transform: uppercase;
transition: opacity .35s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 850px) {
header { top: 16px; left: 18px; }
.subtitle { display: none; }
#readout {
top: auto;
right: 14px;
bottom: 112px;
width: 235px;
padding: 13px;
border-radius: 16px;
}
#phase-name { font-size: 25px; }
#phase-definition { min-height: 0; font-size: 11px; margin-bottom: 8px; }
.datum { padding: 7px 0; grid-template-columns: 76px 1fr; font-size: 10px; }
.legend { display: none; }
#controls { bottom: 12px; width: calc(100vw - 24px); padding: 9px; }
.button-row { gap: 4px; }
button { padding: 10px 6px; font-size: 9px; }
.icon-button { min-width: 34px; padding-inline: 8px; }
.hint { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Animated 3D demonstration of pushing, pulling, and carrying a crate"></canvas>
<div class="vignette"></div>
<header>
<div class="eyebrow">Object–action study</div>
<h1>One crate.<br>Three relationships.</h1>
<p class="subtitle">Contact changes. Support changes. The object remains the same.</p>
</header>
<section id="readout" aria-live="polite">
<div class="readout-head">
<div>
<div id="phase-number">01 / preparing</div>
<h2 id="phase-name">READY</h2>
</div>
<div id="phase-dot" style="width:13px;height:13px;border-radius:50%;background:#2da66f"></div>
</div>
<p id="phase-definition">The figure approaches the same crate before changing the action.</p>
<div class="datum">
<div class="datum-label">Contact</div>
<div class="datum-value" id="contact-value">Not yet applied</div>
</div>
<div class="datum">
<div class="datum-label">Floor support</div>
<div class="datum-value supported" id="support-value">Supported</div>
</div>
<div class="datum">
<div class="datum-label">Crate state</div>
<div class="datum-value" id="state-value">Resting on floor</div>
</div>
<div class="legend">
<span><i class="dot"></i> hand contact</span>
<span><i class="dot green"></i> floor support</span>
</div>
</section>
<nav id="controls" aria-label="Animation controls">
<div class="timeline"><div id="progress"></div></div>
<div class="button-row">
<button data-time="0.8" data-action="push">Push</button>
<button data-time="6.8" data-action="pull">Pull</button>
<button data-time="13" data-action="carry">Carry</button>
<div class="divider"></div>
<button id="pause" class="icon-button" title="Pause or play">Ⅱ</button>
<button id="replay" class="icon-button" title="Replay animation">↻</button>
</div>
</nav>
<div class="hint">Drag to orbit · Scroll to zoom<br>Space: pause · Keys 1–3: jump to a verb</div>
<div id="fade"></div>
<div id="loading">Building the action study…</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.getElementById("scene");
const loading = document.getElementById("loading");
const fade = document.getElementById("fade");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dbe7e3");
scene.fog = new THREE.Fog("#dbe7e3", 20, 39);
const camera = new THREE.PerspectiveCamera(43, innerWidth / innerHeight, 0.1, 80);
// Camera orbit is implemented directly, without addons.
const orbit = {
target: new THREE.Vector3(0.45, 1.0, 0),
azimuth: 0.60,
elevation: 0.43,
distance: 16.4
};
function updateCamera() {
const horizontal = Math.sin(orbit.elevation) * orbit.distance;
camera.position.set(
orbit.target.x + Math.sin(orbit.azimuth) * horizontal,
orbit.target.y + Math.cos(orbit.elevation) * orbit.distance,
orbit.target.z + Math.cos(orbit.azimuth) * horizontal
);
camera.lookAt(orbit.target);
}
updateCamera();
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
orbit.azimuth -= (event.clientX - pointerX) * 0.005;
orbit.elevation = THREE.MathUtils.clamp(
orbit.elevation + (event.clientY - pointerY) * 0.004,
0.18,
1.05
);
pointerX = event.clientX;
pointerY = event.clientY;
updateCamera();
});
function stopDrag() { dragging = false; }
canvas.addEventListener("pointerup", stopDrag);
canvas.addEventListener("pointercancel", stopDrag);
canvas.addEventListener("pointerleave", stopDrag);
canvas.addEventListener("wheel", event => {
event.preventDefault();
orbit.distance = THREE.MathUtils.clamp(
orbit.distance + event.deltaY * 0.008,
9.5,
24
);
updateCamera();
}, { passive: false });
const hemi = new THREE.HemisphereLight("#f8fffb", "#6a756d", 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff2d9", 3.2);
sun.position.set(-4, 11, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -8;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.00035;
scene.add(sun);
const rim = new THREE.DirectionalLight("#a9dcd3", 1.0);
rim.position.set(8, 5, -7);
scene.add(rim);
const palette = {
floor: new THREE.MeshStandardMaterial({ color: "#cfdbd5", roughness: 0.92 }),
wall: new THREE.MeshStandardMaterial({ color: "#c5d5cf", roughness: 0.94 }),
lane: new THREE.MeshStandardMaterial({ color: "#dce4df", roughness: 0.95 }),
crate: new THREE.MeshStandardMaterial({ color: "#c98138", roughness: 0.78 }),
crateDark: new THREE.MeshStandardMaterial({ color: "#7f4829", roughness: 0.86 }),
crateLight: new THREE.MeshStandardMaterial({ color: "#e4a44d", roughness: 0.76 }),
teal: new THREE.MeshStandardMaterial({ color: "#167d78", roughness: 0.72 }),
tealDark: new THREE.MeshStandardMaterial({ color: "#115a59", roughness: 0.8 }),
coral: new THREE.MeshStandardMaterial({ color: "#e56b4d", roughness: 0.74 }),
skin: new THREE.MeshStandardMaterial({ color: "#d9a278", roughness: 0.82 }),
navy: new THREE.MeshStandardMaterial({ color: "#263f4c", roughness: 0.84 }),
shoe: new THREE.MeshStandardMaterial({ color: "#ef7655", roughness: 0.8 }),
hair: new THREE.MeshStandardMaterial({ color: "#293633", roughness: 0.88 })
};
function box(parent, size, position, material, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(...position);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function sphere(parent, radius, position, material, segments = 16) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, segments, Math.max(8, segments / 2)),
material
);
mesh.position.set(...position);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, radiusTop, radiusBottom, height, position, material, segments = 12) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
material
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function textTexture(text, color = "#173431", background = "rgba(250,252,248,.94)") {
const c = document.createElement("canvas");
c.width = 768;
c.height = 160;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
roundedRect(ctx, 8, 8, 752, 144, 28);
ctx.fillStyle = background;
ctx.fill();
ctx.strokeStyle = "rgba(23,52,49,.12)";
ctx.lineWidth = 4;
ctx.stroke();
ctx.fillStyle = color;
ctx.font = "800 42px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 384, 82);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function textSprite(text, color, scale = 2.4, background) {
const material = new THREE.SpriteMaterial({
map: textTexture(text, color, background),
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(scale, scale * 160 / 768, 1);
sprite.renderOrder = 20;
return sprite;
}
function floorDecal(text, color, x, width = 2.6) {
const c = document.createElement("canvas");
c.width = 768;
c.height = 192;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
roundedRect(ctx, 10, 12, 748, 168, 28);
ctx.fillStyle = "rgba(250,252,248,.62)";
ctx.fill();
ctx.strokeStyle = color;
ctx.lineWidth = 7;
ctx.stroke();
ctx.fillStyle = color;
ctx.font = "850 54px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 384, 99);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, width * 192 / 768),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
})
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, 0.014, 0.15);
scene.add(mesh);
return mesh;
}
// Ground and backdrop.
const floor = new THREE.Mesh(new THREE.PlaneGeometry(32, 22), palette.floor);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const lane = box(scene, [17.5, 0.025, 2.55], [0.15, 0.012, 0], palette.lane, false);
lane.receiveShadow = true;
const grid = new THREE.GridHelper(30, 30, "#aebfba", "#bdcbc6");
grid.position.y = 0.028;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
box(scene, [31, 5, 0.3], [0, 2.45, -5.8], palette.wall, false);
box(scene, [31, 0.16, 0.42], [0, 4.84, -5.77], palette.tealDark, false);
box(scene, [3.1, 2.2, 0.18], [-8.5, 1.08, -5.58], palette.coral, false);
box(scene, [2.4, 1.65, 0.18], [8.9, 0.81, -5.58], palette.crateLight, false);
box(scene, [1.6, 3.1, 0.18], [5.6, 1.53, -5.57], palette.teal, false);
floorDecal("01 PUSH", "#167d78", -3.3, 2.6);
floorDecal("02 PULL", "#d36a38", 0.3, 2.6);
floorDecal("03 CARRY", "#8c5b33", 4.75, 2.8);
// A single crate is reused for all three actions.
const crate = new THREE.Group();
scene.add(crate);
const crateBody = box(crate, [1.45, 1.15, 1.2], [0, 0, 0], palette.crate);
crateBody.receiveShadow = true;
for (const x of [-0.68, 0.68]) {
for (const z of [-0.55, 0.55]) {
box(crate, [0.11, 1.18, 0.11], [x, 0, z], palette.crateDark);
}
}
for (const y of [-0.52, 0.52]) {
box(crate, [1.46, 0.11, 0.1], [0, y, -0.56], palette.crateDark);
box(crate, [1.46, 0.11, 0.1], [0, y, 0.56], palette.crateDark);
box(crate, [0.1, 0.11, 1.2], [-0.68, y, 0], palette.crateDark);
box(crate, [0.1, 0.11, 1.2], [0.68, y, 0], palette.crateDark);
}
box(crate, [0.07, 0.82, 0.08], [0.70, 0, -0.36], palette.crateLight);
box(crate, [0.07, 0.82, 0.08], [0.70, 0, 0.36], palette.crateLight);
// Front handle: the pull contact is visibly different from palm-on-face contact.
box(crate, [0.14, 0.12, 0.12], [0.77, 0.68, -0.30], palette.crateDark);
box(crate, [0.14, 0.12, 0.12], [0.77, 0.68, 0.30], palette.crateDark);
const handle = cylinder(crate, 0.055, 0.055, 0.72, [0.82, 0.68, 0], palette.crateDark, 10);
handle.rotation.x = Math.PI / 2;
// Printed crate ID.
const idCanvas = document.createElement("canvas");
idCanvas.width = 512;
idCanvas.height = 180;
const idCtx = idCanvas.getContext("2d");
idCtx.fillStyle = "#f2dcae";
idCtx.fillRect(0, 0, 512, 180);
idCtx.strokeStyle = "#7f4829";
idCtx.lineWidth = 16;
idCtx.strokeRect(8, 8, 496, 164);
idCtx.fillStyle = "#5e3824";
idCtx.font = "900 66px system-ui, sans-serif";
idCtx.textAlign = "center";
idCtx.textBaseline = "middle";
idCtx.fillText("CRATE 01", 256, 92);
const idTexture = new THREE.CanvasTexture(idCanvas);
idTexture.colorSpace = THREE.SRGBColorSpace;
const idPlate = new THREE.Mesh(
new THREE.PlaneGeometry(0.77, 0.27),
new THREE.MeshStandardMaterial({ map: idTexture, roughness: 0.85 })
);
idPlate.position.set(0.05, 0.08, 0.606);
crate.add(idPlate);
// Original stylized figure, facing local +X.
const figure = new THREE.Group();
scene.add(figure);
const body = new THREE.Group();
figure.add(body);
cylinder(body, 0.34, 0.43, 0.78, [0, 1.13, 0], palette.teal, 10);
box(body, [0.47, 0.14, 0.65], [0, 0.81, 0], palette.tealDark);
cylinder(body, 0.12, 0.13, 0.18, [0.02, 1.57, 0], palette.skin, 10);
sphere(body, 0.29, [0.035, 1.82, 0], palette.skin, 18);
const hair = sphere(body, 0.295, [0.005, 1.91, -0.015], palette.hair, 18);
hair.scale.set(0.94, 0.72, 1.01);
// Nose and eyes make the facing direction unambiguous.
sphere(body, 0.075, [0.29, 1.80, 0], palette.skin, 10);
sphere(body, 0.025, [0.275, 1.89, -0.105], palette.hair, 8);
sphere(body, 0.025, [0.275, 1.89, 0.105], palette.hair, 8);
box(body, [0.15, 0.07, 0.48], [-0.04, 1.53, 0], palette.coral);
const arms = [];
const legs = [];
for (const side of [-1, 1]) {
const upperArm = cylinder(figure, 0.105, 0.11, 1, [0, 1.2, side * 0.38], palette.teal, 10);
const foreArm = cylinder(figure, 0.082, 0.09, 1, [0, 1.1, side * 0.4], palette.skin, 10);
const elbow = sphere(figure, 0.095, [0, 1.2, side * 0.39], palette.skin, 10);
const hand = sphere(figure, 0.105, [0.3, 1, side * 0.4], palette.skin, 10);
arms.push({ side, upperArm, foreArm, elbow, hand });
const thigh = cylinder(figure, 0.12, 0.14, 1, [0, 0.55, side * 0.18], palette.navy, 10);
const shin = cylinder(figure, 0.095, 0.11, 1, [0, 0.3, side * 0.18], palette.navy, 10);
const knee = sphere(figure, 0.11, [0, 0.42, side * 0.18], palette.navy, 10);
const shoe = box(figure, [0.38, 0.16, 0.22], [0.12, 0.08, side * 0.18], palette.shoe);
legs.push({ side, thigh, shin, knee, shoe });
}
const up = new THREE.Vector3(0, 1, 0);
function setSegment(mesh, a, b) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.scale.set(1, length, 1);
mesh.quaternion.setFromUnitVectors(up, direction.normalize());
}
// Hand-contact markers.
function createContactMarker() {
const group = new THREE.Group();
const dotMaterial = new THREE.MeshBasicMaterial({
color: "#ffc452",
depthTest: false,
depthWrite: false
});
const ringMaterial = new THREE.MeshBasicMaterial({
color: "#f0a52e",
transparent: true,
opacity: 0.72,
depthTest: false,
depthWrite: false,
side: THREE.DoubleSide
});
const dot = new THREE.Mesh(new THREE.SphereGeometry(0.065, 12, 8), dotMaterial);
const ring = new THREE.Mesh(new THREE.TorusGeometry(0.16, 0.025, 8, 28), ringMaterial);
group.add(dot, ring);
group.renderOrder = 30;
dot.renderOrder = 30;
ring.renderOrder = 30;
scene.add(group);
return { group, ring };
}
const markers = [createContactMarker(), createContactMarker()];
// Projected footprint: bright when supported, faint when the crate is airborne.
const footprint = new THREE.Group();
scene.add(footprint);
const footprintMaterial = new THREE.MeshBasicMaterial({
color: "#2da66f",
transparent: true,
opacity: 0.85,
depthWrite: false
});
const fx = 0.79;
const fz = 0.65;
const armX = 0.32;
const armZ = 0.055;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
const x = sx * fx;
const z = sz * fz;
box(footprint, [armX, 0.025, armZ], [x - sx * armX / 2, 0.035, z], footprintMaterial, false);
box(footprint, [armX, 0.025, armZ], [x + sx * armX / 2, 0.035, z], footprintMaterial, false);
box(footprint, [armZ, 0.025, armZ * 3], [x, 0.035, z - sz * armZ * 1.5], footprintMaterial, false);
box(footprint, [armZ, 0.025, armZ * 3], [x, 0.035, z + sz * armZ * 1.5], footprintMaterial, false);
}
}
const supportLabel = textSprite("FLOOR SUPPORT", "#167b4f", 2.15, "rgba(240,255,246,.94)");
scene.add(supportLabel);
const airborneLabel = textSprite("NO FLOOR CONTACT", "#b6532f", 2.35, "rgba(255,244,235,.95)");
scene.add(airborneLabel);
const gapLineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 1, 0)
]);
const gapLine = new THREE.Line(
gapLineGeometry,
new THREE.LineDashedMaterial({
color: "#d46a3e",
dashSize: 0.08,
gapSize: 0.055,
transparent: true,
opacity: 0.8
})
);
gapLine.computeLineDistances();
scene.add(gapLine);
const pushCaption = textSprite("PALMS / REAR FACE", "#8a531c", 2.65);
const pullCaption = textSprite("HANDS / FRONT HANDLE", "#8a531c", 2.75);
const carryCaption = textSprite("HANDS / UNDER-EDGES", "#8a531c", 2.75);
scene.add(pushCaption, pullCaption, carryCaption);
// Timeline values.
const T = {
pushStart: 0.8,
pushEnd: 5.6,
turnEnd: 6.8,
pullEnd: 11.6,
liftEnd: 13.0,
carryEnd: 18.2,
cycle: 20.0
};
const clamp01 = v => THREE.MathUtils.clamp(v, 0, 1);
const lerp = THREE.MathUtils.lerp;
const smooth = v => {
const x = clamp01(v);
return x * x * (3 - 2 * x);
};
function bezier3(p0, p1, p2, p3, t) {
const u = 1 - t;
return [
u*u*u*p0[0] + 3*u*u*t*p1[0] + 3*u*t*t*p2[0] + t*t*t*p3[0],
u*u*u*p0[1] + 3*u*u*t*p1[1] + 3*u*t*t*p2[1] + t*t*t*p3[1],
u*u*u*p0[2] + 3*u*u*t*p1[2] + 3*u*t*t*p2[2] + t*t*t*p3[2]
];
}
function samplePose(t) {
const pose = {
crate: new THREE.Vector3(-4.4, 0.575, 0),
figure: new THREE.Vector3(-5.75, 0, 0),
yaw: 0,
action: "ready",
contact: null,
floor: true,
gait: 0,
stride: 0
};
if (t < T.pushStart) {
pose.action = "ready";
} else if (t < T.pushEnd) {
const u = (t - T.pushStart) / (T.pushEnd - T.pushStart);
pose.crate.x = lerp(-4.4, -1.2, u);
pose.figure.x = pose.crate.x - 1.35;
pose.action = "push";
pose.contact = "push";
pose.gait = t * 7.2;
pose.stride = 1;
} else if (t < T.turnEnd) {
const u = (t - T.pushEnd) / (T.turnEnd - T.pushEnd);
const p = bezier3(
[-2.55, 0, 0],
[-2.7, 0, 1.85],
[-0.05, 0, 1.85],
[0.15, 0, 0],
smooth(u)
);
pose.crate.x = -1.2;
pose.figure.set(p[0], 0, p[2]);
pose.yaw = Math.PI * smooth(u);
pose.action = "turn";
pose.gait = t * 6.4;
pose.stride = 0.55;
} else if (t < T.pullEnd) {
const u = (t - T.turnEnd) / (T.pullEnd - T.turnEnd);
pose.crate.x = lerp(-1.2, 1.8, u);
pose.figure.x = pose.crate.x + 1.35;
pose.yaw = Math.PI;
pose.action = "pull";
pose.contact = "pull";
pose.gait = t * 7.0;
pose.stride = 1;
} else if (t < T.liftEnd) {
const u = (t - T.pullEnd) / (T.liftEnd - T.pullEnd);
const e = smooth(u);
const c = bezier3(
[1.8, 0.575, 0],
[2.05, 0.88, 1.25],
[3.48, 1.38, 0.92],
[4.13, 1.595, 0],
e
);
pose.crate.set(c[0], c[1], c[2]);
pose.figure.x = lerp(3.15, 3.35, e);
pose.figure.z = lerp(0, 0.28, e);
pose.yaw = Math.PI * (1 - smooth(u));
pose.action = "lift";
pose.floor = pose.crate.y - 0.575 < 0.025;
pose.gait = t * 5.5;
pose.stride = 0.35;
} else {
const u = clamp01((t - T.liftEnd) / (T.carryEnd - T.liftEnd));
pose.figure.x = lerp(3.35, 4.75, u);
pose.crate.x = pose.figure.x + 0.78;
pose.crate.y = 1.595;
pose.action = "carry";
pose.contact = "carry";
pose.floor = false;
pose.gait = t * 7.2;
pose.stride = 1;
}
return pose;
}
function updateFigure(pose) {
figure.position.set(pose.figure.x, 0, pose.figure.z);
figure.rotation.y = pose.yaw;
const bob = Math.abs(Math.sin(pose.gait)) * 0.035 * pose.stride;
body.position.y = bob;
body.rotation.z = pose.action === "pull" ? -0.035 : 0;
for (const arm of arms) {
const side = arm.side;
const shoulder = new THREE.Vector3(0, 1.42 + bob, side * 0.38);
let hand;
if (pose.contact === "push") {
hand = new THREE.Vector3(0.635, 0.80, side * 0.33);
} else if (pose.contact === "pull") {
hand = new THREE.Vector3(0.645, 0.68, side * 0.28);
} else if (pose.contact === "carry") {
hand = new THREE.Vector3(1.38, 1.05, side * 0.47);
} else if (pose.action === "lift") {
hand = new THREE.Vector3(
lerp(0.25, 1.38, smooth((pose.crate.x - 1.8) / 2.35)),
lerp(1.02, 1.05, smooth((pose.crate.x - 1.8) / 2.35)),
side * lerp(0.41, 0.47, smooth((pose.crate.x - 1.8) / 2.35))
);
} else {
hand = new THREE.Vector3(
0.25 + Math.sin(pose.gait + (side > 0 ? Math.PI : 0)) * 0.26 * pose.stride,
1.02 + bob,
side * 0.41
);
}
const elbow = new THREE.Vector3().lerpVectors(shoulder, hand, 0.52);
elbow.y -= 0.12;
elbow.z += side * 0.09;
setSegment(arm.upperArm, shoulder, elbow);
setSegment(arm.foreArm, elbow, hand);
arm.elbow.position.copy(elbow);
arm.hand.position.copy(hand);
}
for (const leg of legs) {
const side = leg.side;
const phase = pose.gait + (side > 0 ? Math.PI : 0);
const footX = 0.09 + Math.sin(phase) * 0.27 * pose.stride;
const lift = Math.max(0, Math.cos(phase)) * 0.10 * pose.stride;
const hip = new THREE.Vector3(0, 0.76 + bob, side * 0.18);
const foot = new THREE.Vector3(footX, 0.10 + lift, side * 0.18);
const knee = new THREE.Vector3(
footX * 0.42 + 0.025,
0.41 + lift * 0.42,
side * 0.18
);
setSegment(leg.thigh, hip, knee);
setSegment(leg.shin, knee, foot);
leg.knee.position.copy(knee);
leg.shoe.position.set(footX + 0.07, 0.08, side * 0.18);
leg.shoe.rotation.y = side * 0.035;
}
figure.updateMatrixWorld(true);
}
function updateContact(pose) {
pushCaption.visible = pose.contact === "push";
pullCaption.visible = pose.contact === "pull";
carryCaption.visible = pose.contact === "carry";
for (let i = 0; i < markers.length; i++) {
const marker = markers[i];
marker.group.visible = Boolean(pose.contact);
if (!pose.contact) continue;
const local = new THREE.Vector3();
arms[i].hand.getWorldPosition(local);
marker.group.position.copy(local);
if (pose.contact === "carry") {
marker.group.rotation.set(Math.PI / 2, 0, 0);
} else {
marker.group.rotation.set(0, Math.PI / 2, 0);
}
const pulse = 1 + Math.sin(performance.now() * 0.006 + i) * 0.08;
marker.group.scale.setScalar(pulse);
}
const captionY = pose.contact === "carry" ? 2.32 : 1.75;
pushCaption.position.set(pose.crate.x, captionY, pose.crate.z);
pullCaption.position.set(pose.crate.x, captionY, pose.crate.z);
carryCaption.position.set(pose.crate.x, captionY, pose.crate.z);
}
function updateSupport(pose) {
const gap = Math.max(0, pose.crate.y - 0.575);
footprint.position.set(pose.crate.x, 0, pose.crate.z);
footprintMaterial.color.set(pose.floor ? "#2da66f" : "#8b9994");
footprintMaterial.opacity = pose.floor ? 0.88 : 0.23;
supportLabel.visible = pose.floor;
airborneLabel.visible = !pose.floor;
supportLabel.position.set(pose.crate.x, 0.15, pose.crate.z + 1.02);
airborneLabel.position.set(pose.crate.x, 0.66, pose.crate.z + 1.02);
gapLine.visible = gap > 0.045;
gapLine.position.set(pose.crate.x + 0.80, 0.03, pose.crate.z + 0.72);
gapLine.scale.y = gap;
}
const phaseNumber = document.getElementById("phase-number");
const phaseName = document.getElementById("phase-name");
const phaseDefinition = document.getElementById("phase-definition");
const contactValue = document.getElementById("contact-value");
const supportValue = document.getElementById("support-value");
const stateValue = document.getElementById("state-value");
const phaseDot = document.getElementById("phase-dot");
const progress = document.getElementById("progress");
const actionButtons = [...document.querySelectorAll("[data-action]")];
function updateHUD(pose, t) {
let number = "00 / preparing";
let name = "READY";
let definition = "The figure approaches the same crate before changing the action.";
let contact = "Not yet applied";
let color = "#2da66f";
let active = null;
if (pose.action === "push") {
number = "01 / sliding";
name = "PUSH";
definition = "The figure applies force through both palms while the crate stays on the floor.";
contact = "Both palms on the rear face";
color = "#167d78";
active = "push";
} else if (pose.action === "turn") {
number = "01 / transition";
name = "REPOSITION";
definition = "Contact is released so the figure can move to the crate’s front side.";
contact = "No contact during repositioning";
color = "#d38b34";
} else if (pose.action === "pull") {
number = "02 / dragging";
name = "PULL";
definition = "The figure walks backward while both hands remain attached to the front handle.";
contact = "Both hands on the front handle";
color = "#d36a38";
active = "pull";
} else if (pose.action === "lift") {
number = "02 → 03 / lifting";
name = "LIFT";
definition = "The crate is raised around the figure’s side; its floor support disappears.";
contact = "Hands move toward the under-edges";
color = "#d36a38";
} else if (pose.action === "carry") {
number = "03 / suspended";
name = "CARRY";
definition = "The same crate is held above the floor with both hands under its edges.";
contact = "Both hands under the lower edges";
color = "#8d5a31";
active = "carry";
}
phaseNumber.textContent = number;
phaseName.textContent = name;
phaseName.style.color = color;
phaseDefinition.textContent = definition;
contactValue.textContent = contact;
phaseDot.style.background = color;
supportValue.textContent = pose.floor ? "Yes — base is flush" : "No — crate is lifted";
supportValue.className = "datum-value " + (pose.floor ? "supported" : "unsupported");
stateValue.textContent = pose.floor
? "Supported by the floor"
: "Suspended above the floor";
progress.style.width = `${clamp01(t / T.cycle) * 100}%`;
actionButtons.forEach(button => {
button.classList.toggle("active", button.dataset.action === active);
});
}
let elapsed = 0;
let paused = false;
let last = performance.now();
const pauseButton = document.getElementById("pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "▶" : "Ⅱ";
pauseButton.setAttribute("aria-label", paused ? "Play animation" : "Pause animation");
});
document.getElementById("replay").addEventListener("click", () => {
elapsed = 0;
paused = false;
pauseButton.textContent = "Ⅱ";
});
actionButtons.forEach(button => {
button.addEventListener("click", () => {
elapsed = Number(button.dataset.time);
paused = false;
pauseButton.textContent = "Ⅱ";
});
});
addEventListener("keydown", event => {
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
if (event.key === "1") actionButtons[0].click();
if (event.key === "2") actionButtons[1].click();
if (event.key === "3") actionButtons[2].click();
});
function animate(now) {
const dt = Math.min(0.05, (now - last) / 1000);
last = now;
if (!paused) elapsed = (elapsed + dt) % T.cycle;
const raw = elapsed;
let t = raw;
if (raw >= 19.0) {
if (raw < 19.5) {
fade.style.opacity = smooth((raw - 19.0) / 0.5);
t = raw;
} else {
fade.style.opacity = 1 - smooth((raw - 19.5) / 0.5);
t = 0;
}
} else {
fade.style.opacity = 0;
}
const pose = samplePose(t);
crate.position.copy(pose.crate);
updateFigure(pose);
updateContact(pose);
updateSupport(pose);
updateHUD(pose, t);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
updateCamera();
});
requestAnimationFrame(animate);
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```