Prompt specification
Build or customize the Three.js 3D scene "Bundle tightening sequence" 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: Bundle tightening sequence
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/bundle-tightening-sequence-x0246
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows locking cable ties. Pull the strap through its head around three parallel cables; the loop shrinks while the tail length grows, keeping the cables separate and visibly contained. Low-poly.
Working Three.js Starter (bundle-tightening-sequence-x0246):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Locking Cable Ties — Three.js</title>
<style>
:root {
color-scheme: dark;
--ink: #edf7ff;
--muted: #93a8bb;
--panel: rgba(13, 22, 35, 0.82);
--line: rgba(164, 207, 236, 0.18);
--accent: #ff8a32;
--accent-light: #ffc06b;
--cyan: #40d8cf;
--blue: #5794ff;
--violet: #b47aff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #0b1220;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.info {
position: absolute;
top: 24px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 18px 18px 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--accent-light);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 14px var(--accent);
content: "";
}
h1 {
margin: 0;
font-size: clamp(21px, 3vw, 29px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.subtitle {
margin: 9px 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.readout {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 13px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.readout strong {
color: var(--ink);
font-size: 13px;
letter-spacing: 0;
}
.track {
height: 5px;
margin-top: 7px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.08);
}
.fill {
width: 0%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--accent), var(--accent-light));
box-shadow: 0 0 14px rgba(255, 138, 50, 0.55);
}
.status {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 15px;
padding: 6px 9px;
border: 1px solid rgba(255, 138, 50, 0.26);
border-radius: 999px;
background: rgba(255, 138, 50, 0.09);
color: var(--accent-light);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.status::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
content: "";
animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink {
50% { opacity: 0.35; }
}
.legend {
position: absolute;
left: 24px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 13px;
padding: 11px 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(13, 22, 35, 0.72);
backdrop-filter: blur(10px);
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 2px;
box-shadow: 0 0 9px currentColor;
}
.controls {
position: absolute;
right: 24px;
bottom: 24px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(13, 22, 35, 0.82);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
button:hover {
border-color: rgba(255, 138, 50, 0.55);
background: rgba(255, 138, 50, 0.13);
transform: translateY(-1px);
}
button.primary {
border-color: rgba(255, 138, 50, 0.45);
background: rgba(255, 138, 50, 0.16);
color: var(--accent-light);
}
.hint {
position: absolute;
top: 25px;
right: 25px;
color: rgba(220, 237, 248, 0.5);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
}
@media (max-width: 680px) {
.info {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
}
.subtitle {
margin-bottom: 10px;
}
.hint {
display: none;
}
.legend {
left: 14px;
bottom: 70px;
}
.controls {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<div class="hud">
<section class="info">
<div class="eyebrow">Low-poly mechanism</div>
<h1>Locking cable tie</h1>
<p class="subtitle">
The ratchet head draws the orange strap through itself, shrinking the
containment loop while the free tail extends.
</p>
<div class="readout">
<span>Tail extension</span>
<strong id="tailValue">0.34 m</strong>
</div>
<div class="track"><div class="fill" id="tailFill"></div></div>
<div class="readout">
<span>Loop tension</span>
<strong id="loopValue">Loose</strong>
</div>
<div class="track"><div class="fill" id="loopFill"></div></div>
<div class="status" id="status">Pulling strap</div>
</section>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<div class="legend">
<span><i class="dot" style="color:#40d8cf;background:#40d8cf"></i> Cable 01</span>
<span><i class="dot" style="color:#5794ff;background:#5794ff"></i> Cable 02</span>
<span><i class="dot" style="color:#b47aff;background:#b47aff"></i> Cable 03</span>
</div>
<div class="controls">
<button class="primary" id="replay">Replay pull</button>
<button id="resetCamera">Reset camera</button>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b1220);
scene.fog = new THREE.Fog(0x0b1220, 9, 19);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
50
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xc5eaff, 0x172033, 2.15);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xffffff, 3.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 = 6;
key.shadow.camera.bottom = -6;
key.shadow.camera.near = 1;
key.shadow.camera.far = 18;
key.shadow.bias = -0.0005;
scene.add(key);
const rim = new THREE.DirectionalLight(0x4ccfff, 1.7);
rim.position.set(-5, 2.5, -4);
scene.add(rim);
const warmFill = new THREE.PointLight(0xff9a4a, 15, 9, 2);
warmFill.position.set(1, 2.5, 3.5);
scene.add(warmFill);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
new THREE.MeshStandardMaterial({
color: 0x121d2d,
roughness: 0.94,
metalness: 0.02
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.5;
ground.receiveShadow = true;
scene.add(ground);
// A subtle polygonal platform beneath the assembly.
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(4.9, 5.15, 0.12, 24),
new THREE.MeshStandardMaterial({
color: 0x182638,
roughness: 0.82,
metalness: 0.08,
flatShading: true
})
);
platform.position.y = -1.55;
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
// -------------------------------------------------------------------------
// Three parallel, visibly separated cables
// -------------------------------------------------------------------------
const cableLength = 6.8;
const cableRadius = 0.24;
// Coordinates in the tie's cross-section: x = world Z, y = world Y.
const bundle = [
new THREE.Vector2(-0.42, -0.34),
new THREE.Vector2( 0.42, -0.34),
new THREE.Vector2( 0.00, 0.38)
];
const cableColors = [0x40d8cf, 0x5794ff, 0xb47aff];
bundle.forEach((position, index) => {
const sideMaterial = new THREE.MeshStandardMaterial({
color: cableColors[index],
roughness: 0.48,
metalness: 0.08,
flatShading: true
});
const endMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(cableColors[index]).multiplyScalar(0.58),
roughness: 0.64,
metalness: 0.04,
flatShading: true
});
const cable = new THREE.Mesh(
new THREE.CylinderGeometry(
cableRadius,
cableRadius,
cableLength,
12,
1,
false
),
[sideMaterial, endMaterial, endMaterial]
);
cable.rotation.z = Math.PI / 2;
cable.position.set(0, position.y, position.x);
cable.castShadow = true;
cable.receiveShadow = true;
scene.add(cable);
});
// -------------------------------------------------------------------------
// Dynamic flat ribbon geometry
// -------------------------------------------------------------------------
class Ribbon {
constructor(maxSegments, width, material) {
this.maxSegments = maxSegments;
this.width = width;
this.positions = new Float32Array(maxSegments * 6 * 3);
this.geometry = new THREE.BufferGeometry();
this.geometry.setAttribute(
"position",
new THREE.BufferAttribute(this.positions, 3).setUsage(
THREE.DynamicDrawUsage
)
);
this.geometry.computeVertexNormals();
this.geometry.setDrawRange(0, 0);
this.mesh = new THREE.Mesh(this.geometry, material);
this.mesh.castShadow = true;
this.mesh.receiveShadow = true;
this.mesh.frustumCulled = false;
scene.add(this.mesh);
}
update(path) {
const halfWidth = this.width * 0.5;
let offset = 0;
const vertex = (x, y, z) => {
this.positions[offset++] = x;
this.positions[offset++] = y;
this.positions[offset++] = z;
};
const segments = Math.min(path.length - 1, this.maxSegments);
for (let i = 0; i < segments; i++) {
const p0 = path[i];
const p1 = path[i + 1];
// Path Vector2.x represents world Z; path Vector2.y is world Y.
vertex(-halfWidth, p0.y, p0.x);
vertex(-halfWidth, p1.y, p1.x);
vertex( halfWidth, p0.y, p0.x);
vertex( halfWidth, p0.y, p0.x);
vertex(-halfWidth, p1.y, p1.x);
vertex( halfWidth, p1.y, p1.x);
}
this.geometry.attributes.position.needsUpdate = true;
this.geometry.setDrawRange(0, segments * 6);
this.geometry.computeVertexNormals();
this.geometry.attributes.normal.needsUpdate = true;
}
}
const strapMaterial = new THREE.MeshStandardMaterial({
color: 0xff762b,
roughness: 0.55,
metalness: 0.06,
side: THREE.DoubleSide,
flatShading: true
});
const tailMaterial = new THREE.MeshStandardMaterial({
color: 0xff812f,
roughness: 0.5,
metalness: 0.05,
side: THREE.DoubleSide,
flatShading: true
});
const mainRibbon = new Ribbon(40, 0.52, strapMaterial);
const tailRibbon = new Ribbon(30, 0.50, tailMaterial);
// -------------------------------------------------------------------------
// Faceted locking head
// -------------------------------------------------------------------------
const head = new THREE.Group();
scene.add(head);
const headMaterial = new THREE.MeshStandardMaterial({
color: 0xff762b,
roughness: 0.48,
metalness: 0.08,
flatShading: true
});
const headHighlight = new THREE.MeshStandardMaterial({
color: 0xffa14f,
roughness: 0.44,
metalness: 0.06,
flatShading: true
});
const slotMaterial = new THREE.MeshStandardMaterial({
color: 0x25150f,
roughness: 0.72,
metalness: 0.04
});
const shell = new THREE.Mesh(
new THREE.BoxGeometry(0.68, 0.44, 0.56),
headMaterial
);
shell.castShadow = true;
shell.receiveShadow = true;
head.add(shell);
const rearCap = new THREE.Mesh(
new THREE.BoxGeometry(0.60, 0.13, 0.48),
headHighlight
);
rearCap.position.y = -0.17;
rearCap.castShadow = true;
head.add(rearCap);
const slot = new THREE.Mesh(
new THREE.BoxGeometry(0.43, 0.035, 0.22),
slotMaterial
);
slot.position.y = 0.232;
head.add(slot);
const lockRamp = new THREE.Mesh(
new THREE.BoxGeometry(0.34, 0.11, 0.13),
headHighlight
);
lockRamp.position.set(0, 0.245, 0);
lockRamp.rotation.x = -0.12;
lockRamp.castShadow = true;
head.add(lockRamp);
// Raised grip ribs on the visible side of the housing.
for (let i = 0; i < 3; i++) {
const rib = new THREE.Mesh(
new THREE.BoxGeometry(0.45, 0.025, 0.025),
headHighlight
);
rib.position.set(0, -0.08 + i * 0.09, 0.29);
rib.castShadow = true;
head.add(rib);
}
// Small raised ratchet teeth along the free tail.
const toothGeometry = new THREE.BoxGeometry(0.43, 0.025, 0.035);
const toothMaterial = new THREE.MeshStandardMaterial({
color: 0xffa653,
roughness: 0.5,
metalness: 0.04,
flatShading: true
});
const teeth = [];
for (let i = 0; i < 25; i++) {
const tooth = new THREE.Mesh(toothGeometry, toothMaterial);
tooth.castShadow = true;
tooth.visible = false;
scene.add(tooth);
teeth.push(tooth);
}
// -------------------------------------------------------------------------
// Convex, rounded-triangle loop around the three cable cross-sections
// -------------------------------------------------------------------------
const outwardNormal = (a, b) => {
const dx = b.x - a.x;
const dy = b.y - a.y;
return new THREE.Vector2(dy, -dx).normalize();
};
function createContour(clearance, subdivisions = 4) {
const radius = cableRadius + clearance;
const arcs = [];
for (let i = 0; i < bundle.length; i++) {
const previous = bundle[(i + bundle.length - 1) % bundle.length];
const current = bundle[i];
const next = bundle[(i + 1) % bundle.length];
const previousNormal = outwardNormal(previous, current);
const nextNormal = outwardNormal(current, next);
let startAngle = Math.atan2(
previousNormal.y,
previousNormal.x
);
let endAngle = Math.atan2(
nextNormal.y,
nextNormal.x
);
while (endAngle <= startAngle) {
endAngle += Math.PI * 2;
}
const arc = [];
for (let j = 0; j <= subdivisions; j++) {
const t = j / subdivisions;
const angle = THREE.MathUtils.lerp(
startAngle,
endAngle,
t
);
arc.push(
new THREE.Vector2(
current.x + Math.cos(angle) * radius,
current.y + Math.sin(angle) * radius
)
);
}
arcs.push(arc);
}
return arcs;
}
// Direction of the free tail in the tie's Y/Z cross-section.
const pullDirection = new THREE.Vector2(0.58, -0.815).normalize();
// Perpendicular to the pull direction; corresponds to the head's local Z.
const headCrossAxis = new THREE.Vector2(
pullDirection.y,
-pullDirection.x
);
const headAngle = Math.atan2(
pullDirection.x,
pullDirection.y
);
const TAIL_SEGMENTS = 26;
function makeTailPath(root, length) {
const path = [root.clone()];
for (let i = 1; i <= TAIL_SEGMENTS; i++) {
const t = i / TAIL_SEGMENTS;
const distance = length * t;
// A very small curve prevents the tail from looking like a rigid bar.
const bend = headCrossAxis.clone().multiplyScalar(
0.055 * Math.sin(Math.PI * t)
);
path.push(
root.clone()
.addScaledVector(pullDirection, distance)
.add(bend)
);
}
return path;
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const duration = 6500;
let animationStart = performance.now();
const tailValue = document.querySelector("#tailValue");
const tailFill = document.querySelector("#tailFill");
const loopValue = document.querySelector("#loopValue");
const loopFill = document.querySelector("#loopFill");
const status = document.querySelector("#status");
const replayButton = document.querySelector("#replay");
const resetCameraButton = document.querySelector("#resetCamera");
const clamp01 = (value) => THREE.MathUtils.clamp(value, 0, 1);
const smoothstep = (value) => {
const t = clamp01(value);
return t * t * (3 - 2 * t);
};
function updateAssembly(progress) {
const eased = smoothstep(progress);
const looseClearance = 0.62;
const tightClearance = 0.075;
const clearance = THREE.MathUtils.lerp(
looseClearance,
tightClearance,
eased
);
const tailLength = THREE.MathUtils.lerp(0.34, 2.25, eased);
const arcs = createContour(clearance);
// The top of the bundle plus clearance, followed by the head thickness.
const headY = bundle[2].y + cableRadius + clearance + 0.25;
const headPosition = new THREE.Vector2(0, headY);
const leftHeadEntry = headPosition.clone()
.addScaledVector(headCrossAxis, -0.18);
const rightHeadEntry = headPosition.clone()
.addScaledVector(headCrossAxis, 0.18);
// The upper cable's arc is replaced by the two sections entering the head.
// The remaining contour wraps underneath and around both lower cables.
const loopPath = [
leftHeadEntry,
arcs[2][arcs[2].length - 1],
...arcs[0],
...arcs[1],
arcs[2][0],
rightHeadEntry
];
mainRibbon.update(loopPath);
head.position.set(0, headPosition.y, headPosition.x);
head.rotation.x = headAngle;
const tailRoot = headPosition.clone()
.addScaledVector(pullDirection, 0.255);
const tailPath = makeTailPath(tailRoot, tailLength);
tailRibbon.update(tailPath);
// Teeth are aligned to the tail, facing the camera side.
const toothNormal = headCrossAxis.clone().multiplyScalar(-1);
teeth.forEach((tooth, index) => {
const t = (index + 1) / (teeth.length + 2);
const distance = tailLength * t;
if (distance >= tailLength - 0.08) {
tooth.visible = false;
return;
}
const point = tailRoot.clone()
.addScaledVector(pullDirection, distance)
.addScaledVector(
headCrossAxis,
0.055 * Math.sin(Math.PI * t)
)
.addScaledVector(toothNormal, 0.021);
tooth.visible = true;
tooth.position.set(0, point.y, point.x);
tooth.rotation.x = headAngle + Math.PI;
});
// Interface readout.
tailValue.textContent = `${tailLength.toFixed(2)} m`;
tailFill.style.width = `${eased * 100}%`;
loopFill.style.width = `${eased * 100}%`;
if (progress >= 0.995) {
loopValue.textContent = "Locked";
status.textContent = "Locked in place";
} else if (progress < 0.015) {
loopValue.textContent = "Loose";
status.textContent = "Ready to pull";
} else {
loopValue.textContent = `${Math.round(eased * 100)}%`;
status.textContent = "Pulling strap";
}
}
// -------------------------------------------------------------------------
// Custom orbit controls — no external control modules
// -------------------------------------------------------------------------
const defaultCamera = {
theta: 0.55,
phi: 1.18,
radius: 7.4
};
const cameraTarget = {
theta: defaultCamera.theta,
phi: defaultCamera.phi,
radius: defaultCamera.radius
};
const desiredCamera = {
theta: defaultCamera.theta,
phi: defaultCamera.phi,
radius: defaultCamera.radius
};
const cameraLookAt = new THREE.Vector3(0, -0.06, 0.15);
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
desiredCamera.theta -= dx * 0.005;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi - dy * 0.0045,
0.48,
1.43
);
});
function endDrag(event) {
dragging = false;
if (
event.pointerType !== "mouse" &&
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 = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
4.5,
11
);
},
{ passive: false }
);
function updateCamera(delta) {
const damping = 1 - Math.exp(-delta * 9);
cameraTarget.theta = THREE.MathUtils.lerp(
cameraTarget.theta,
desiredCamera.theta,
damping
);
cameraTarget.phi = THREE.MathUtils.lerp(
cameraTarget.phi,
desiredCamera.phi,
damping
);
cameraTarget.radius = THREE.MathUtils.lerp(
cameraTarget.radius,
desiredCamera.radius,
damping
);
const { theta, phi, radius } = cameraTarget;
camera.position.set(
cameraLookAt.x + radius * Math.sin(phi) * Math.sin(theta),
cameraLookAt.y + radius * Math.cos(phi),
cameraLookAt.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraLookAt);
}
replayButton.addEventListener("click", () => {
animationStart = performance.now();
});
resetCameraButton.addEventListener("click", () => {
desiredCamera.theta = defaultCamera.theta;
desiredCamera.phi = defaultCamera.phi;
desiredCamera.radius = defaultCamera.radius;
});
addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
animationStart = performance.now();
}
if (event.key.toLowerCase() === "r") {
desiredCamera.theta = defaultCamera.theta;
desiredCamera.phi = defaultCamera.phi;
desiredCamera.radius = defaultCamera.radius;
}
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
const progress = clamp01((now - animationStart) / duration);
updateAssembly(progress);
updateCamera(delta);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```