Prompt specification
Build or customize the Three.js 3D scene "Dressing-room costume preparation" 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: Dressing-room costume preparation
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/dressing-room-costume-preparation-x0627
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing suspenders and shared strap loads. Compose a performer mannequin, trousers, suspenders, mirror, and accessory table; an assistant adjusts straps before adding the outer costume layer in a coherent sequence. Stylized solid forms.
Working Three.js Starter (dressing-room-costume-preparation-x0627):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Suspenders — Shared Strap Load Study</title>
<style>
:root {
--ink: #24252a;
--muted: #6d6b68;
--paper: rgba(247, 243, 235, 0.91);
--line: rgba(36, 37, 42, 0.16);
--gold: #c58a2a;
--coral: #d65d49;
--burgundy: #742b39;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e2d8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#overlay {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.62);
box-shadow:
0 18px 50px rgba(55, 42, 30, 0.12),
inset 0 0 0 1px var(--line);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#title-card {
position: absolute;
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border-radius: 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--burgundy);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 22px;
height: 2px;
background: var(--burgundy);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(26px, 3vw, 38px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
#phase-title {
margin: 16px 0 5px;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#phase-copy {
min-height: 38px;
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
#load-card {
position: absolute;
top: 24px;
right: 24px;
width: 242px;
padding: 16px;
border-radius: 16px;
}
.card-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.toggle {
position: relative;
width: 34px;
height: 19px;
flex: 0 0 auto;
}
.toggle input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.toggle span {
position: absolute;
inset: 0;
border-radius: 20px;
background: #bbb7b0;
transition: background 160ms ease;
cursor: pointer;
}
.toggle span::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 13px;
height: 13px;
border-radius: 50%;
background: white;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
transition: transform 160ms ease;
}
.toggle input:checked + span {
background: var(--burgundy);
}
.toggle input:checked + span::after {
transform: translateX(15px);
}
.load-diagram {
display: grid;
grid-template-columns: 1fr 22px 1fr;
align-items: center;
gap: 5px;
margin: 12px 0 11px;
}
.load-node {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
color: #55514e;
font-size: 9px;
font-weight: 700;
text-align: center;
}
.load-node b {
display: grid;
width: 34px;
height: 34px;
place-items: center;
border: 2px solid var(--gold);
border-radius: 50%;
color: #8d6019;
background: rgba(197, 138, 42, 0.1);
font-size: 14px;
}
.load-yoke {
color: var(--gold);
font-size: 28px;
text-align: center;
transform: rotate(90deg);
}
.load-legend {
display: flex;
justify-content: space-between;
gap: 10px;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
line-height: 1.4;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 15px;
height: 3px;
border-radius: 3px;
background: var(--gold);
}
.swatch.coral {
background: var(--coral);
}
#timeline-card {
position: absolute;
left: 50%;
bottom: 22px;
width: min(850px, calc(100vw - 32px));
padding: 12px 14px 11px;
border-radius: 18px;
transform: translateX(-50%);
pointer-events: auto;
}
.timeline-top {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 12px;
margin-bottom: 8px;
}
button {
border: 0;
color: inherit;
font: inherit;
cursor: pointer;
}
#play,
#restart {
display: inline-flex;
min-width: 38px;
height: 34px;
align-items: center;
justify-content: center;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.55);
font-size: 13px;
font-weight: 800;
transition: transform 140ms ease, background 140ms ease;
}
#play {
min-width: 104px;
padding: 0 14px;
color: white;
border-color: var(--burgundy);
background: var(--burgundy);
}
#play:hover,
#restart:hover {
transform: translateY(-1px);
}
#restart {
font-size: 18px;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 4px;
outline: none;
appearance: none;
-webkit-appearance: none;
background:
linear-gradient(
to right,
var(--burgundy) 0%,
var(--burgundy) var(--progress, 50%),
rgba(36, 37, 42, 0.13) var(--progress, 50%),
rgba(36, 37, 42, 0.13) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 15px;
height: 15px;
border: 3px solid white;
border-radius: 50%;
appearance: none;
-webkit-appearance: none;
background: var(--burgundy);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.28);
}
input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
border: 3px solid white;
border-radius: 50%;
background: var(--burgundy);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.28);
}
#steps {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.step {
padding: 8px 7px;
border-top: 1px solid var(--line);
color: #88837d;
background: transparent;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-align: left;
text-transform: uppercase;
transition: color 150ms ease, border-color 150ms ease;
}
.step.active {
color: var(--burgundy);
border-color: var(--burgundy);
}
#help {
position: absolute;
right: 24px;
bottom: 24px;
color: rgba(36, 37, 42, 0.58);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.05em;
text-align: right;
}
#time-readout {
min-width: 66px;
color: var(--muted);
font-variant-numeric: tabular-nums;
font-size: 10px;
text-align: right;
}
@media (max-width: 760px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
}
#load-card {
top: auto;
right: 12px;
bottom: 142px;
width: 190px;
padding: 12px;
}
.load-diagram {
display: none;
}
#timeline-card {
bottom: 10px;
width: calc(100vw - 20px);
}
.step {
font-size: 8px;
letter-spacing: 0.03em;
}
#help {
display: none;
}
#phase-copy {
min-height: 0;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div id="overlay">
<section id="title-card" class="panel">
<div class="eyebrow">Costume engineering study</div>
<h1>Shared Strap<br />Load</h1>
<div id="phase-title">03 · Assistant adjustment</div>
<p id="phase-copy">
The assistant checks the front adjusters before the outer costume layer
is added.
</p>
</section>
<aside id="load-card" class="panel">
<div class="card-heading">
Load path
<label class="toggle" aria-label="Toggle load visualization">
<input id="load-toggle" type="checkbox" checked />
<span></span>
</label>
</div>
<div class="load-diagram">
<div class="load-node">
<b>↓</b>
Shoulder
</div>
<div class="load-yoke">→</div>
<div class="load-node">
<b>↓</b>
Waistband
</div>
</div>
<div class="load-legend">
<span class="legend-item">
<i class="swatch"></i>
Tension path
</span>
<span class="legend-item">
<i class="swatch coral"></i>
Load transfer
</span>
</div>
</aside>
<section id="timeline-card" class="panel">
<div class="timeline-top">
<button id="play" type="button" aria-label="Play sequence">▶ Play</button>
<input
id="timeline"
type="range"
min="0"
max="25"
step="0.01"
value="12.5"
aria-label="Sequence timeline"
/>
<div id="time-readout">12.5 / 25 s</div>
</div>
<div id="steps">
<button class="step" type="button" data-time="0">01 · Trousers</button>
<button class="step" type="button" data-time="4">02 · Suspenders</button>
<button class="step" type="button" data-time="10">03 · Adjust</button>
<button class="step" type="button" data-time="18.4">04 · Outer layer</button>
</div>
</section>
<div id="help">Drag to orbit · Scroll to zoom</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.querySelector("#app");
const timelineInput = document.querySelector("#timeline");
const playButton = document.querySelector("#play");
const restartButton = document.querySelector("#restart");
const loadToggle = document.querySelector("#load-toggle");
const phaseTitle = document.querySelector("#phase-title");
const phaseCopy = document.querySelector("#phase-copy");
const timeReadout = document.querySelector("#time-readout");
const stepButtons = [...document.querySelectorAll(".step")];
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e2d8);
scene.fog = new THREE.Fog(0xe9e2d8, 11, 23);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
40
);
const renderer = new THREE.WebGLRenderer({
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;
app.appendChild(renderer.domElement);
const clock = new THREE.Clock();
const UP = new THREE.Vector3(0, 1, 0);
const FORWARD = new THREE.Vector3(0, 0, 1);
const DURATION = 25;
let timeline = 12.5;
let playing = false;
let showLoads = true;
const smooth = (lo, hi, time) => THREE.MathUtils.smoothstep(time, lo, hi);
const lerp = THREE.MathUtils.lerp;
const clamp = THREE.MathUtils.clamp;
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0,
...options
});
}
const materials = {
floor: material(0xd8cec0, { roughness: 0.96 }),
wall: material(0xeee8df, { roughness: 1 }),
platform: material(0xb9aa98, { roughness: 0.88 }),
mannequin: material(0xd5b89a, { roughness: 0.82 }),
mannequinJoint: material(0xc3a486, { roughness: 0.85 }),
trousers: material(0x29394d, { roughness: 0.9 }),
shoe: material(0x25292e, { roughness: 0.78 }),
strap: material(0x742b39, {
roughness: 0.72,
side: THREE.DoubleSide,
emissive: 0x2c0c0d,
emissiveIntensity: 0.35
}),
gold: material(0xc18b37, {
metalness: 0.68,
roughness: 0.28
}),
jacket: material(0x722d3b, {
roughness: 0.76,
side: THREE.DoubleSide,
transparent: true
}),
jacketDark: material(0x4f202c, {
roughness: 0.84,
side: THREE.DoubleSide,
transparent: true
}),
jacketButton: material(0xc59b4d, {
metalness: 0.6,
roughness: 0.3,
transparent: true
}),
assistantTop: material(0x377d78, { roughness: 0.84 }),
assistantPants: material(0x2c3941, { roughness: 0.9 }),
assistantSkin: material(0xb98261, { roughness: 0.88 }),
assistantShoe: material(0x20282d, { roughness: 0.8 }),
wood: material(0x76503b, { roughness: 0.82 }),
foldedCloth: material(0x74313d, { roughness: 0.94 })
};
function roundedBox(width, height, depth, radius, mat) {
const x = -width / 2;
const y = -height / 2;
const r = Math.min(radius, width / 2, height / 2);
const shape = new THREE.Shape();
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: false,
curveSegments: 6
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, mat);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function mesh(geometry, mat, parent, position = [0, 0, 0]) {
const object = new THREE.Mesh(geometry, mat);
object.position.set(...position);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function cylinderBetween(object, a, b) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
object.position.copy(a).add(b).multiplyScalar(0.5);
object.quaternion.setFromUnitVectors(UP, direction.normalize());
object.scale.set(1, length, 1);
}
function createLimb(radius, mat, parent) {
const object = mesh(
new THREE.CylinderGeometry(radius, radius * 0.92, 1, 12),
mat,
parent
);
return object;
}
function createRibbon(points, width, mat) {
const curve = new THREE.CatmullRomCurve3(
points.map((point) => new THREE.Vector3(...point))
);
const samples = curve.getPoints(46);
const positions = [];
const indices = [];
for (let i = 0; i < samples.length; i++) {
const previous = samples[Math.max(0, i - 1)];
const next = samples[Math.min(samples.length - 1, i + 1)];
const tangent = new THREE.Vector3().subVectors(next, previous).normalize();
const side = new THREE.Vector3().crossVectors(tangent, FORWARD);
if (side.lengthSq() < 0.0001) {
side.set(1, 0, 0);
} else {
side.normalize();
}
const left = samples[i].clone().addScaledVector(side, width / 2);
const right = samples[i].clone().addScaledVector(side, -width / 2);
positions.push(left.x, left.y, left.z, right.x, right.y, right.z);
if (i < samples.length - 1) {
const a = i * 2;
indices.push(a, a + 1, a + 2, a + 1, a + 3, a + 2);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const object = new THREE.Mesh(geometry, mat);
object.castShadow = true;
object.receiveShadow = true;
return object;
}
function createOpenJacketGeometry() {
const rings = [
{ y: 1.72, rx: 0.62, rz: 0.39 },
{ y: 2.0, rx: 0.7, rz: 0.44 },
{ y: 2.55, rx: 0.72, rz: 0.45 },
{ y: 3.08, rx: 0.62, rz: 0.38 },
{ y: 3.21, rx: 0.36, rz: 0.3 }
];
const start = 0.72;
const end = Math.PI * 2 - 0.72;
const segments = 38;
const positions = [];
const indices = [];
rings.forEach((ring) => {
for (let i = 0; i <= segments; i++) {
const theta = lerp(start, end, i / segments);
positions.push(
ring.rx * Math.sin(theta),
ring.y,
ring.rz * Math.cos(theta)
);
}
});
for (let row = 0; row < rings.length - 1; row++) {
for (let column = 0; column < segments; column++) {
const a = row * (segments + 1) + column;
const b = a + segments + 1;
indices.push(a, b, a + 1, b, b + 1, a + 1);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
// Lighting and room -------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff8eb, 0x6c7180, 2.05));
const key = new THREE.DirectionalLight(0xfff2dc, 4.2);
key.position.set(-4.5, 7, 5.5);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -6;
key.shadow.camera.right = 6;
key.shadow.camera.top = 7;
key.shadow.camera.bottom = -3;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 20;
key.shadow.normalBias = 0.025;
scene.add(key);
const fill = new THREE.DirectionalLight(0xc7dcff, 1.35);
fill.position.set(5, 4, -1);
scene.add(fill);
const warmPoint = new THREE.PointLight(0xffbd7a, 18, 9, 2);
warmPoint.position.set(2.4, 3.5, 1.2);
scene.add(warmPoint);
const floor = mesh(
new THREE.PlaneGeometry(18, 14),
materials.floor,
scene,
[0, 0, 0]
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
const wall = mesh(
new THREE.PlaneGeometry(16, 8),
materials.wall,
scene,
[0, 4, -3.22]
);
wall.castShadow = false;
const sideWall = mesh(
new THREE.PlaneGeometry(12, 8),
materials.wall,
scene,
[-6.4, 4, 0]
);
sideWall.rotation.y = Math.PI / 2;
sideWall.castShadow = false;
const wallBand = mesh(
new THREE.BoxGeometry(15.9, 0.08, 0.04),
material(0x8d6d59, { roughness: 0.9 }),
scene,
[0, 0.6, -3.17]
);
wallBand.castShadow = false;
// Performer and platform ---------------------------------------------------
const performer = new THREE.Group();
performer.position.set(-0.72, 0, 0.05);
scene.add(performer);
const platform = mesh(
new THREE.CylinderGeometry(1.2, 1.28, 0.1, 48),
materials.platform,
scene,
[-0.72, 0.05, 0.05]
);
platform.castShadow = false;
const torso = mesh(
new THREE.SphereGeometry(1, 32, 20),
materials.mannequin,
performer,
[0, 2.48, 0]
);
torso.scale.set(0.62, 0.82, 0.38);
const waist = mesh(
new THREE.CylinderGeometry(0.43, 0.47, 0.42, 24),
materials.mannequin,
performer,
[0, 1.8, 0]
);
waist.scale.z = 0.78;
const neck = mesh(
new THREE.CylinderGeometry(0.14, 0.16, 0.31, 16),
materials.mannequin,
performer,
[0, 3.24, 0]
);
const head = mesh(
new THREE.SphereGeometry(0.33, 28, 20),
materials.mannequin,
performer,
[0, 3.61, 0.01]
);
head.scale.set(0.95, 1.08, 0.95);
const mannequinArms = [];
[-1, 1].forEach((side) => {
const shoulder = new THREE.Vector3(side * 0.55, 3.0, 0);
const elbow = new THREE.Vector3(side * 0.73, 2.55, 0.02);
const wrist = new THREE.Vector3(side * 0.77, 2.12, 0.08);
const upper = createLimb(0.12, materials.mannequin, performer);
const lower = createLimb(0.105, materials.mannequin, performer);
cylinderBetween(upper, shoulder, elbow);
cylinderBetween(lower, elbow, wrist);
mesh(
new THREE.SphereGeometry(0.11, 16, 12),
materials.mannequin,
performer,
wrist.toArray()
);
mannequinArms.push({ upper, lower });
});
const trousers = new THREE.Group();
performer.add(trousers);
const trouserMats = [materials.trousers, materials.shoe];
trouserMats.forEach((mat) => {
mat.transparent = true;
});
const pelvis = mesh(
new THREE.SphereGeometry(1, 24, 16),
materials.trousers,
trousers,
[0, 1.73, 0]
);
pelvis.scale.set(0.54, 0.3, 0.36);
const waistband = roundedBox(1.08, 0.23, 0.67, 0.08, materials.trousers);
waistband.position.set(0, 1.88, 0);
trousers.add(waistband);
[-1, 1].forEach((side) => {
const leg = mesh(
new THREE.CylinderGeometry(0.235, 0.17, 1.48, 16),
materials.trousers,
trousers,
[side * 0.27, 0.9, 0]
);
leg.scale.z = 0.92;
const knee = mesh(
new THREE.SphereGeometry(0.2, 18, 12),
materials.trousers,
trousers,
[side * 0.27, 0.91, 0.01]
);
knee.scale.set(0.93, 1.05, 0.9);
const shoe = roundedBox(0.39, 0.2, 0.68, 0.09, materials.shoe);
shoe.position.set(side * 0.27, 0.16, 0.14);
trousers.add(shoe);
});
// Suspenders and shared rear yoke -----------------------------------------
const suspenders = new THREE.Group();
performer.add(suspenders);
const leftStrapPoints = [
[-0.34, 1.95, 0.35],
[-0.35, 2.42, 0.39],
[-0.43, 2.84, 0.36],
[-0.5, 3.12, 0.15],
[-0.45, 3.24, -0.01],
[-0.33, 3.17, -0.24],
[-0.17, 2.84, -0.37],
[0, 2.07, -0.4]
];
const rightStrapPoints = [
[0, 2.07, -0.4],
[0.17, 2.84, -0.37],
[0.33, 3.17, -0.24],
[0.45, 3.24, -0.01],
[0.5, 3.12, 0.15],
[0.43, 2.84, 0.36],
[0.35, 2.42, 0.39],
[0.34, 1.95, 0.35]
];
suspenders.add(createRibbon(leftStrapPoints, 0.115, materials.strap));
suspenders.add(createRibbon(rightStrapPoints, 0.115, materials.strap));
const rearYoke = roundedBox(
0.93,
0.14,
0.09,
0.035,
materials.strap
);
rearYoke.position.set(0, 2.04, -0.42);
suspenders.add(rearYoke);
const yokePatch = mesh(
new THREE.CircleGeometry(0.17, 24),
materials.strap,
suspenders,
[0, 2.08, -0.48]
);
yokePatch.rotation.y = Math.PI;
[-0.075, 0.075].forEach((x) => {
mesh(
new THREE.SphereGeometry(0.025, 12, 8),
materials.gold,
suspenders,
[x, 2.08, -0.5]
);
});
[-1, 1].forEach((side) => {
const adjuster = roundedBox(
0.18,
0.13,
0.065,
0.025,
materials.gold
);
adjuster.position.set(side * 0.35, 2.32, 0.43);
adjuster.rotation.z = side * 0.05;
suspenders.add(adjuster);
const clip = roundedBox(
0.14,
0.18,
0.07,
0.025,
materials.gold
);
clip.position.set(side * 0.34, 1.96, 0.39);
suspenders.add(clip);
const anchor = mesh(
new THREE.TorusGeometry(0.072, 0.017, 8, 24),
materials.gold,
suspenders,
[side * 0.34, 1.87, 0.42]
);
});
// Load visualization ------------------------------------------------------
const loadGroup = new THREE.Group();
performer.add(loadGroup);
const loadArrows = [];
[-1, 1].forEach((side) => {
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(side * 0.35, 2.02, 0.53),
0.47,
0xd65d49,
0.15,
0.11
);
arrow.line.material.transparent = true;
arrow.cone.material.transparent = true;
arrow.line.material.depthWrite = false;
arrow.cone.material.depthWrite = false;
loadGroup.add(arrow);
loadArrows.push(arrow);
});
const rearArrow = new THREE.ArrowHelper(
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 2.02, -0.52),
0.39,
0xd65d49,
0.13,
0.1
);
rearArrow.line.material.transparent = true;
rearArrow.cone.material.transparent = true;
rearArrow.line.material.depthWrite = false;
rearArrow.cone.material.depthWrite = false;
loadGroup.add(rearArrow);
loadArrows.push(rearArrow);
const loadDots = [];
const dotPositions = [
[-0.35, 2.5, 0.4],
[-0.44, 2.86, 0.36],
[0, 2.08, -0.49],
[0.35, 2.5, 0.4],
[0.44, 2.86, 0.36]
];
dotPositions.forEach((position) => {
const dot = mesh(
new THREE.SphereGeometry(0.047, 16, 10),
material(0xe0aa3f, {
metalness: 0.48,
roughness: 0.26,
emissive: 0x9b5b08,
emissiveIntensity: 0.5
}),
loadGroup,
position
);
loadDots.push(dot);
});
// Outer costume layer ----------------------------------------------------
const jacket = new THREE.Group();
performer.add(jacket);
const jacketShell = mesh(
createOpenJacketGeometry(),
materials.jacket,
jacket
);
[-1, 1].forEach((side) => {
const shape = new THREE.Shape();
shape.moveTo(side * 0.46, 3.03);
shape.lineTo(side * 0.12, 3.18);
shape.lineTo(side * 0.27, 2.58);
shape.lineTo(side * 0.5, 2.4);
shape.closePath();
const lapel = mesh(
new THREE.ShapeGeometry(shape),
materials.jacketDark,
jacket
);
lapel.position.z = 0.45;
const tail = roundedBox(
0.53,
0.68,
0.1,
0.06,
materials.jacket
);
tail.position.set(side * 0.27, 1.49, -0.34);
tail.rotation.z = side * 0.09;
jacket.add(tail);
const sleeve = mesh(
new THREE.CapsuleGeometry(0.17, 0.48, 6, 14),
materials.jacket,
jacket,
[side * 0.69, 2.72, 0]
);
sleeve.rotation.z = side * 0.12;
const button = mesh(
new THREE.SphereGeometry(0.045, 14, 10),
materials.jacketButton,
jacket,
[side * 0.27, 2.35 - (side > 0 ? 0.3 : 0), 0.47]
);
button.scale.z = 0.5;
});
const collar = mesh(
new THREE.TorusGeometry(0.3, 0.075, 10, 32, Math.PI * 1.5),
materials.jacketDark,
jacket,
[0, 3.18, 0.01]
);
collar.rotation.x = Math.PI / 2;
collar.rotation.z = Math.PI * 0.25;
// Accessory table ---------------------------------------------------------
const table = new THREE.Group();
table.position.set(2.25, 0, -0.25);
scene.add(table);
const tabletop = roundedBox(1.65, 0.13, 0.78, 0.09, materials.wood);
tabletop.position.y = 1.12;
table.add(tabletop);
[-0.66, 0.66].forEach((x) => {
[-0.25, 0.25].forEach((z) => {
const leg = mesh(
new THREE.CylinderGeometry(0.055, 0.075, 1.03, 12),
materials.wood,
table,
[x, 0.52, z]
);
leg.rotation.z = x * 0.035;
});
});
const lowerShelf = roundedBox(1.45, 0.08, 0.62, 0.05, materials.wood);
lowerShelf.position.y = 0.42;
table.add(lowerShelf);
const tableJacket = new THREE.Group();
table.add(tableJacket);
for (let i = 0; i < 3; i++) {
const folded = roundedBox(
0.62 - i * 0.025,
0.075,
0.42,
0.04,
materials.foldedCloth
);
folded.position.set(-0.36, 1.225 + i * 0.07, 0);
folded.rotation.y = -0.08 + i * 0.035;
tableJacket.add(folded);
}
[-0.08, 0.18].forEach((x, index) => {
const spool = mesh(
new THREE.CylinderGeometry(0.105, 0.105, 0.3, 20),
index === 0 ? materials.gold : materials.trousers,
table,
[x, 1.33, -0.12]
);
spool.rotation.z = 0.12;
});
const tray = mesh(
new THREE.CylinderGeometry(0.24, 0.22, 0.055, 28),
materials.wood,
table,
[0.55, 1.22, 0.08]
);
const looseBuckle = mesh(
new THREE.TorusGeometry(0.13, 0.025, 10, 28),
materials.gold,
table,
[0.55, 1.26, 0.08]
);
looseBuckle.rotation.x = Math.PI / 2;
// Assistant ---------------------------------------------------------------
const assistant = new THREE.Group();
scene.add(assistant);
const assistantTorso = mesh(
new THREE.CapsuleGeometry(0.27, 0.48, 7, 16),
materials.assistantTop,
assistant,
[0, 1.43, 0]
);
assistantTorso.scale.z = 0.84;
mesh(
new THREE.CylinderGeometry(0.1, 0.11, 0.18, 14),
materials.assistantSkin,
assistant,
[0, 1.93, 0]
);
const assistantHead = mesh(
new THREE.SphereGeometry(0.245, 24, 18),
materials.assistantSkin,
assistant,
[0, 2.13, 0]
);
assistantHead.scale.set(0.95, 1.05, 0.95);
const nose = mesh(
new THREE.SphereGeometry(0.055, 12, 10),
materials.assistantSkin,
assistant,
[0, 2.11, 0.235]
);
nose.scale.set(0.8, 1, 0.75);
const assistantArms = [];
const assistantLegs = [];
[-1, 1].forEach((side) => {
const arm = {
side,
shoulderLocal: new THREE.Vector3(side * 0.31, 1.67, 0),
upper: createLimb(0.085, materials.assistantTop, assistant),
lower: createLimb(0.072, materials.assistantTop, assistant),
hand: mesh(
new THREE.SphereGeometry(0.09, 14, 10),
materials.assistantSkin,
assistant
)
};
assistantArms.push(arm);
const leg = {
side,
upper: createLimb(0.11, materials.assistantPants, assistant),
lower: createLimb(0.09, materials.assistantPants, assistant),
shoe: roundedBox(0.25, 0.15, 0.42, 0.06, materials.assistantShoe)
};
assistant.add(leg.shoe);
assistantLegs.push(leg);
});
function updateArm(arm, targetWorld, poleLocal) {
assistant.updateMatrixWorld(true);
const shoulder = assistant.localToWorld(arm.shoulderLocal.clone());
const pole = assistant.localToWorld(poleLocal.clone());
const direction = new THREE.Vector3().subVectors(targetWorld, shoulder);
const totalLength = 1.16;
if (direction.lengthSq() < 0.0001) {
direction.set(0, -1, 0);
}
direction.normalize();
const actualLength = clamp(
shoulder.distanceTo(targetWorld),
0.12,
totalLength - 0.005
);
const target = shoulder.clone().addScaledVector(direction, actualLength);
const upperLength = 0.58;
const lowerLength = 0.58;
const distance = clamp(actualLength, 0.05, upperLength + lowerLength - 0.002);
const along =
(upperLength * upperLength -
lowerLength * lowerLength +
distance * distance) /
(2 * distance);
const height = Math.sqrt(Math.max(0, upperLength * upperLength - along * along));
const bend = pole.clone().sub(shoulder);
bend.addScaledVector(direction, -bend.dot(direction));
if (bend.lengthSq() < 0.0001) {
bend.set(arm.side, 0, 0);
}
bend.normalize();
const elbow = shoulder
.clone()
.addScaledVector(direction, along)
.addScaledVector(bend, height);
[shoulder, elbow, target].forEach((point) => assistant.worldToLocal(point));
cylinderBetween(arm.upper, shoulder, elbow);
cylinderBetween(arm.lower, elbow, target);
arm.hand.position.copy(target);
}
function updateLeg(leg, swing) {
const hip = new THREE.Vector3(leg.side * 0.15, 1.03, 0);
const knee = new THREE.Vector3(leg.side * 0.16, 0.58, swing * 0.45);
const ankle = new THREE.Vector3(leg.side * 0.17, 0.14, swing);
cylinderBetween(leg.upper, hip, knee);
cylinderBetween(leg.lower, knee, ankle);
leg.shoe.position.set(ankle.x, 0.1, ankle.z + 0.11);
leg.shoe.rotation.y = leg.side * 0.035;
}
// Planar mirror using only core Three.js ----------------------------------
const mirrorGroup = new THREE.Group();
mirrorGroup.position.set(2.48, 2.05, -2.55);
scene.add(mirrorGroup);
const mirrorFrameMat = material(0x56392f, { roughness: 0.76 });
const frameTop = roundedBox(2.12, 0.14, 0.18, 0.045, mirrorFrameMat);
frameTop.position.set(0, 1.42, 0);
mirrorGroup.add(frameTop);
const frameBottom = frameTop.clone();
frameBottom.position.y = -1.42;
mirrorGroup.add(frameBottom);
const frameLeft = roundedBox(0.14, 2.98, 0.18, 0.045, mirrorFrameMat);
frameLeft.position.set(-0.99, 0, 0);
mirrorGroup.add(frameLeft);
const frameRight = frameLeft.clone();
frameRight.position.x = 0.99;
mirrorGroup.add(frameRight);
const reflectionTarget = new THREE.WebGLRenderTarget(1024, 600, {
minFilter: THREE.LinearFilter,
magFilter: THREE.LinearFilter,
format: THREE.RGBAFormat,
depthBuffer: true
});
const mirrorTextureMatrix = new THREE.Matrix4();
const virtualCamera = new THREE.PerspectiveCamera();
virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
virtualCamera.projectionMatrixInverse.copy(camera.projectionMatrixInverse);
const mirrorMaterial = new THREE.ShaderMaterial({
uniforms: {
tDiffuse: { value: reflectionTarget.texture },
textureMatrix: { value: mirrorTextureMatrix },
tint: { value: new THREE.Color(0xdce8e8) }
},
vertexShader: `
uniform mat4 textureMatrix;
varying vec4 vMirrorCoord;
void main() {
vMirrorCoord = textureMatrix * vec4(position, 1.0);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform sampler2D tDiffuse;
uniform vec3 tint;
varying vec4 vMirrorCoord;
void main() {
vec4 reflected = texture2DProj(tDiffuse, vMirrorCoord);
float edge = smoothstep(0.0, 0.035, reflected.a);
gl_FragColor = vec4(reflected.rgb * tint, edge);
#include <tonemapping_fragment>
#include <colorspace_fragment>
}
`,
transparent: true,
depthWrite: true
});
const mirrorGlass = mesh(
new THREE.PlaneGeometry(1.84, 2.7),
mirrorMaterial,
mirrorGroup,
[0, 0, 0.015]
);
mirrorGlass.castShadow = false;
mirrorGlass.receiveShadow = false;
function renderReflection() {
scene.updateMatrixWorld(true);
const mirrorPosition = new THREE.Vector3();
mirrorGroup.getWorldPosition(mirrorPosition);
const normal = new THREE.Vector3(0, 0, 1).transformDirection(
mirrorGroup.matrixWorld
);
const view = mirrorPosition.clone().sub(camera.position);
if (view.dot(normal) > 0) return;
view.reflect(normal).negate().add(mirrorPosition);
const rotation = new THREE.Matrix4().extractRotation(camera.matrixWorld);
const lookAt = new THREE.Vector3(0, 0, -1)
.applyMatrix4(rotation)
.add(camera.position);
const target = mirrorPosition.clone().sub(lookAt);
target.reflect(normal).negate().add(mirrorPosition);
virtualCamera.position.copy(view);
virtualCamera.up.set(0, 1, 0)
.applyMatrix4(rotation)
.reflect(normal);
virtualCamera.lookAt(target);
virtualCamera.near = camera.near;
virtualCamera.far = camera.far;
virtualCamera.projectionMatrix.copy(camera.projectionMatrix);
virtualCamera.projectionMatrixInverse.copy(
camera.projectionMatrixInverse
);
virtualCamera.updateMatrixWorld(true);
mirrorTextureMatrix.set(
0.5, 0, 0, 0.5,
0, 0.5, 0, 0.5,
0, 0, 0.5, 0.5,
0, 0, 0, 1
);
mirrorTextureMatrix.multiply(virtualCamera.projectionMatrix);
mirrorTextureMatrix.multiply(virtualCamera.matrixWorldInverse);
mirrorTextureMatrix.multiply(mirrorGlass.matrixWorld);
const previousVisibility = mirrorGroup.visible;
mirrorGroup.visible = false;
renderer.setRenderTarget(reflectionTarget);
renderer.render(scene, virtualCamera);
renderer.setRenderTarget(null);
mirrorGroup.visible = previousVisibility;
}
// Direct camera controls --------------------------------------------------
const cameraTarget = new THREE.Vector3(-0.05, 1.75, -0.02);
const desiredCamera = {
theta: 0.52,
phi: 1.22,
radius: 9.2
};
const currentCamera = { ...desiredCamera };
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
desiredCamera.theta -= dx * 0.006;
desiredCamera.phi = clamp(desiredCamera.phi - dy * 0.005, 0.72, 1.49);
pointerX = event.clientX;
pointerY = event.clientY;
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredCamera.radius = clamp(
desiredCamera.radius + event.deltaY * 0.007,
5.6,
13
);
},
{ passive: false }
);
function updateCamera() {
currentCamera.theta = lerp(
currentCamera.theta,
desiredCamera.theta,
0.09
);
currentCamera.phi = lerp(
currentCamera.phi,
desiredCamera.phi,
0.09
);
currentCamera.radius = lerp(
currentCamera.radius,
desiredCamera.radius,
0.09
);
const { theta, phi, radius } = currentCamera;
camera.position.set(
cameraTarget.x + radius * Math.sin(phi) * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld(true);
}
// Timeline and character animation ---------------------------------------
function pathPosition(time) {
const start = new THREE.Vector3(2.62, 0, 0.52);
const adjust = new THREE.Vector3(-0.12, 0, 1.12);
const tablePoint = new THREE.Vector3(2.45, 0, 0.45);
const side = new THREE.Vector3(1.02, 0, 0.78);
const end = new THREE.Vector3(2.6, 0, 0.55);
let position;
if (time < 5.5) {
position = start.clone();
} else if (time < 9.6) {
position = start.clone().lerp(adjust, smooth(5.5, 9.6, time));
} else if (time < 16.1) {
position = adjust.clone();
} else if (time < 18.4) {
position = adjust.clone().lerp(
tablePoint,
smooth(16.1, 18.4, time)
);
} else if (time < 21.6) {
position = tablePoint.clone().lerp(
side,
smooth(18.4, 21.6, time)
);
} else {
position = side.clone().lerp(end, smooth(21.6, 25, time));
}
const moving =
(time >= 5.5 && time <= 9.6) ||
(time >= 16.1 && time <= 18.4) ||
(time >= 18.4 && time <= 21.6) ||
(time >= 21.6 && time <= 25);
const stride = moving ? Math.sin(time * 8.3) * 0.24 : 0;
position.y = moving ? Math.abs(Math.sin(time * 8.3)) * 0.025 : 0;
return { position, moving, stride };
}
function updateAssistant(time) {
assistant.visible = time >= 5.25;
const { position, moving, stride } = pathPosition(time);
assistant.position.copy(position);
let lookTarget = performer.position.clone();
if (time >= 16.1 && time <= 18.8) {
lookTarget = new THREE.Vector3(2.2, 1.25, -0.25);
}
const direction = lookTarget.clone().sub(assistant.position);
assistant.rotation.y = Math.atan2(direction.x, direction.z);
assistant.updateMatrixWorld(true);
assistantLegs.forEach((leg, index) => {
const swing = moving ? stride * (index === 0 ? 1 : -1) : 0;
updateLeg(leg, swing);
});
const rightBuckle = performer.localToWorld(
new THREE.Vector3(0.35, 2.32, 0.45)
);
const leftBuckle = performer.localToWorld(
new THREE.Vector3(-0.35, 2.32, 0.45)
);
const rightShoulder = performer.localToWorld(
new THREE.Vector3(0.43, 2.56, 0.38)
);
const leftShoulder = performer.localToWorld(
new THREE.Vector3(-0.43, 2.56, 0.38)
);
const neutralRight = assistant.localToWorld(
new THREE.Vector3(0.38, 1.12, moving ? stride * 0.45 : 0.05)
);
const neutralLeft = assistant.localToWorld(
new THREE.Vector3(-0.38, 1.12, moving ? -stride * 0.45 : 0.05)
);
let rightTarget = neutralRight.clone();
let leftTarget = neutralLeft.clone();
if (time >= 10.1 && time < 16.1) {
const rightBlend = smooth(10.1, 11.5, time);
const leftBlend = smooth(11.8, 13.2, time);
rightTarget.lerp(rightBuckle, rightBlend);
leftTarget.lerp(leftBuckle, leftBlend);
const lift = smooth(13.2, 14.5, time) *
(1 - smooth(15.25, 16.1, time));
rightTarget.lerp(rightShoulder, lift * 0.72);
leftTarget.lerp(leftShoulder, lift * 0.72);
}
if (time >= 17.2 && time < 19.2) {
const tableTarget = new THREE.Vector3(2.15, 1.3, -0.3);
const blend = smooth(17.2, 18.2, time) *
(1 - smooth(18.5, 19.2, time));
rightTarget.lerp(tableTarget, blend);
leftTarget.lerp(
tableTarget.clone().add(new THREE.Vector3(-0.15, 0, 0.04)),
blend
);
}
if (time >= 19.1 && time < 21.7) {
const carry = smooth(19.1, 20.2, time) *
(1 - smooth(20.8, 21.7, time));
const carryTarget = new THREE.Vector3(0.75, 1.65, 0.45);
rightTarget.lerp(carryTarget, carry);
leftTarget.lerp(
carryTarget.clone().add(new THREE.Vector3(-0.2, 0, 0)),
carry
);
}
updateArm(
assistantArms[1],
rightTarget,
new THREE.Vector3(0.8, 1.9, 0.75)
);
updateArm(
assistantArms[0],
leftTarget,
new THREE.Vector3(-0.8, 1.9, 0.75)
);
}
const phases = [
{
start: 0,
title: "01 · Trousers & baseline",
copy:
"The tailored trousers settle onto the mannequin, establishing the waistband and two lower load anchors."
},
{
start: 3,
title: "02 · Shared-load suspenders",
copy:
"Two continuous shoulder loops meet at one padded rear yoke before dividing to the waistband."
},
{
start: 8,
title: "03 · Assistant adjustment",
copy:
"The assistant checks each front adjuster, then gently tensions the straps through the shared rear yoke."
},
{
start: 18.4,
title: "04 · Outer costume layer",
copy:
"The open-front outer layer is added while the central load path remains visible for inspection."
}
];
let currentPhase = -1;
function updatePhase(time) {
let phaseIndex = 0;
for (let i = 0; i < phases.length; i++) {
if (time >= phases[i].start) phaseIndex = i;
}
if (phaseIndex !== currentPhase) {
currentPhase = phaseIndex;
phaseTitle.textContent = phases[phaseIndex].title;
phaseCopy.textContent = phases[phaseIndex].copy;
}
stepButtons.forEach((button, index) => {
const active =
(index === 0 && time < 3) ||
(index === 1 && time >= 3 && time < 8) ||
(index === 2 && time >= 8 && time < 18.4) ||
(index === 3 && time >= 18.4);
button.classList.toggle("active", active);
});
}
function applyScene(time) {
const trouserAmount = smooth(0.1, 2.5, time);
const suspenderAmount = smooth(3, 6.3, time);
const jacketAmount = smooth(18.4, 21.7, time);
materials.trousers.opacity = trouserAmount;
materials.shoe.opacity = trouserAmount;
materials.trousers.depthWrite = trouserAmount > 0.96;
materials.shoe.depthWrite = trouserAmount > 0.96;
trousers.position.y = 0.38 * (1 - smooth(0, 3, time));
materials.strap.opacity = suspenderAmount;
materials.strap.depthWrite = suspenderAmount > 0.96;
suspenders.position.y = -0.18 * (1 - suspenderAmount);
materials.jacket.opacity = jacketAmount;
materials.jacketDark.opacity = jacketAmount;
materials.jacketButton.opacity = jacketAmount;
materials.jacket.depthWrite = jacketAmount > 0.96;
materials.jacketDark.depthWrite = jacketAmount > 0.96;
materials.jacketButton.depthWrite = jacketAmount > 0.96;
jacket.visible = jacketAmount > 0.001;
jacket.position.set(
1.32 * (1 - jacketAmount),
0.95 * (1 - jacketAmount),
0.28 * (1 - jacketAmount)
);
jacket.rotation.set(
0,
0.14 * (1 - jacketAmount),
-0.18 * (1 - jacketAmount)
);
tableJacket.visible = time < 18.45;
const loadOpacity = showLoads
? clamp(suspenderAmount * (0.7 + 0.3 * Math.sin(time * 2.1)), 0, 1)
: 0;
loadGroup.visible = loadOpacity > 0.01;
loadArrows.forEach((arrow) => {
arrow.line.material.opacity = loadOpacity;
arrow.cone.material.opacity = loadOpacity;
});
loadDots.forEach((dot, index) => {
dot.scale.setScalar(
1 + Math.sin(time * 3.2 + index * 1.7) * 0.12
);
});
materials.strap.color.setHex(showLoads ? 0x8a3945 : 0x742b39);
materials.strap.emissive.setHex(showLoads ? 0x3b120e : 0x120608);
materials.strap.emissiveIntensity = showLoads ? 0.38 : 0.08;
updateAssistant(time);
updatePhase(time);
timelineInput.value = time.toFixed(2);
timelineInput.style.setProperty(
"--progress",
`${(time / DURATION) * 100}%`
);
timeReadout.textContent = `${time.toFixed(1)} / ${DURATION} s`;
}
// UI ----------------------------------------------------------------------
playButton.addEventListener("click", () => {
if (timeline >= DURATION - 0.01) timeline = 0;
playing = !playing;
updatePlayButton();
});
function updatePlayButton() {
playButton.textContent = playing ? "Ⅱ Pause" : "▶ Play";
playButton.setAttribute(
"aria-label",
playing ? "Pause sequence" : "Play sequence"
);
}
restartButton?.addEventListener("click", () => {
timeline = 0;
playing = true;
updatePlayButton();
});
timelineInput.addEventListener("input", (event) => {
timeline = Number(event.target.value);
playing = false;
updatePlayButton();
});
stepButtons.forEach((button) => {
button.addEventListener("click", () => {
timeline = Number(button.dataset.time);
playing = false;
updatePlayButton();
});
});
loadToggle.addEventListener("change", (event) => {
showLoads = event.target.checked;
});
function resize() {
const width = innerWidth;
const height = innerHeight;
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
const reflectionWidth = Math.min(
1200,
Math.floor(width * Math.min(devicePixelRatio, 1.4))
);
const reflectionHeight = Math.max(
1,
Math.floor(reflectionWidth * height / width)
);
reflectionTarget.setSize(reflectionWidth, reflectionHeight);
}
addEventListener("resize", resize);
resize();
// The scene opens on the strap-adjustment beat so the load system is
// immediately visible. Play or scrub to review the complete sequence.
updatePlayButton();
applyScene(timeline);
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) {
timeline = Math.min(DURATION, timeline + delta);
if (timeline >= DURATION) {
playing = false;
updatePlayButton();
}
}
updateCamera();
applyScene(timeline);
renderReflection();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```