Prompt specification
Build or customize the Three.js 3D scene "Canopy opening linkage 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: Canopy opening linkage sequence
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/canopy-opening-linkage-sequence-x0630
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing umbrella ribs and linkages. Animate the slider traveling upward as ribs spread radially and fabric sectors widen; maintain shared pivots and stop the canopy at a stable open configuration. Low-poly.
Working Three.js Starter (canopy-opening-linkage-sequence-x0630):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Low-Poly Umbrella Ribs & Linkages</title>
<style>
:root {
color-scheme: dark;
--panel: rgba(10, 22, 31, 0.82);
--line: rgba(185, 221, 226, 0.16);
--text: #eaf7f5;
--muted: #91a9ad;
--accent: #f08a5d;
--accent-2: #5cc8be;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 35%, #18313d 0%, #0a1721 48%, #050b11 100%);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--text);
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#controls {
position: fixed;
top: 22px;
left: 22px;
width: min(340px, calc(100vw - 44px));
padding: 20px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
user-select: none;
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent-2);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 23px;
line-height: 1.16;
letter-spacing: -0.025em;
}
.description {
margin: 10px 0 18px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.label-row,
.readout-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.label-row {
margin-bottom: 8px;
color: var(--muted);
font-size: 12px;
font-weight: 700;
}
#travel {
width: 100%;
height: 24px;
margin: 0;
cursor: pointer;
accent-color: var(--accent);
}
.readout-row {
margin-top: 9px;
color: var(--muted);
font-size: 11px;
}
#state {
color: var(--accent-2);
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
button {
width: 100%;
margin-top: 17px;
padding: 11px 14px;
border: 1px solid rgba(240, 138, 93, 0.35);
border-radius: 10px;
background: rgba(240, 138, 93, 0.12);
color: #ffd1bd;
font: inherit;
font-size: 13px;
font-weight: 750;
cursor: pointer;
transition:
background 150ms ease,
border-color 150ms ease,
transform 150ms ease;
}
button:hover {
border-color: rgba(240, 138, 93, 0.7);
background: rgba(240, 138, 93, 0.2);
}
button:active {
transform: translateY(1px);
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 3px;
}
#hint {
position: fixed;
right: 20px;
bottom: 18px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(6, 14, 20, 0.55);
color: rgba(220, 237, 238, 0.64);
font-size: 11px;
pointer-events: none;
backdrop-filter: blur(8px);
}
@media (max-width: 600px) {
#controls {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 16px;
}
h1 {
font-size: 20px;
}
.description {
margin-bottom: 13px;
}
#hint {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<section id="controls">
<div class="eyebrow">Mechanical Study</div>
<h1>Umbrella Ribs & Linkages</h1>
<p class="description">
The common slider rises along the shaft, driving every radial rib outward.
Each stretcher keeps a constant length and remains connected to its rib pivot.
</p>
<div class="label-row">
<span>Slider travel</span>
<span id="travelValue">0%</span>
</div>
<input
id="travel"
type="range"
min="0"
max="100"
value="0"
step="0.1"
aria-label="Umbrella slider travel"
>
<div class="readout-row">
<span>Slider elevation</span>
<span id="elevation">0.000</span>
</div>
<div class="readout-row">
<span>Mechanism</span>
<span id="state">Opening</span>
</div>
<button id="motion" type="button">Pause motion</button>
<div class="legend" aria-label="Component colors">
<span>
<i class="swatch" style="background:#253943"></i>
Ribs
</span>
<span>
<i class="swatch" style="background:#e39555"></i>
Stretchers
</span>
<span>
<i class="swatch" style="background:#2d9e96"></i>
Fabric sectors
</span>
</div>
</section>
<div id="hint">Drag to orbit · Scroll to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly umbrella mechanism"
);
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x08141d, 7.5, 13.5);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xc8f4ff, 0x17232c, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.4);
keyLight.position.set(4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -4;
keyLight.shadow.camera.right = 4;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -2;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5cc8be, 1.7);
rimLight.position.set(-4, 3.5, -5);
scene.add(rimLight);
const warmFill = new THREE.PointLight(0xf08a5d, 9, 9, 2);
warmFill.position.set(-2.5, 2.4, 3.5);
scene.add(warmFill);
// Ground and grid.
const ground = new THREE.Mesh(
new THREE.CylinderGeometry(4.6, 4.6, 0.08, 48),
new THREE.MeshStandardMaterial({
color: 0x0d1d27,
roughness: 0.95,
metalness: 0.02
})
);
ground.position.y = -0.86;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(10, 20, 0x31505a, 0x1a303a);
grid.position.y = -0.812;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const shaftMaterial = new THREE.MeshStandardMaterial({
color: 0xbfcbd0,
metalness: 0.85,
roughness: 0.28
});
const darkMetal = new THREE.MeshStandardMaterial({
color: 0x253943,
metalness: 0.72,
roughness: 0.38,
flatShading: true
});
const copperMaterial = new THREE.MeshStandardMaterial({
color: 0xe39555,
metalness: 0.72,
roughness: 0.3,
flatShading: true
});
const pivotMaterial = new THREE.MeshStandardMaterial({
color: 0xd7e2df,
metalness: 0.9,
roughness: 0.24,
flatShading: true
});
const handleMaterial = new THREE.MeshStandardMaterial({
color: 0xd76b4d,
metalness: 0.08,
roughness: 0.78,
flatShading: true
});
// -------------------------------------------------------------------------
// Fixed shaft and handle
// -------------------------------------------------------------------------
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.052, 0.064, 3.9, 10),
shaftMaterial
);
shaft.position.y = 1.95;
shaft.castShadow = true;
scene.add(shaft);
const handle = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.13, 0.8, 10),
handleMaterial
);
handle.position.y = -0.32;
handle.castShadow = true;
scene.add(handle);
const handleCap = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.132, 0),
handleMaterial
);
handleCap.position.y = -0.72;
handleCap.castShadow = true;
scene.add(handleCap);
const collar = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.12, 0.11, 12),
darkMetal
);
collar.position.y = 0.13;
scene.add(collar);
// -------------------------------------------------------------------------
// Mechanism dimensions
//
// Every rib shares:
// ROOT: the common canopy pivot at the top of the shaft.
// S: the common slider point.
//
// Each rib also has B, its individual pivot shared by:
// inner rib + outer rib + constant-length stretcher.
// -------------------------------------------------------------------------
const SECTORS = 10;
const ROOT_Y = 3.55;
const ROOT = new THREE.Vector3(0, ROOT_Y, 0);
const PIVOT_DISTANCE = 0.75; // Root to rib pivot.
const OUTER_RIB_LENGTH = 1.9; // Pivot to canopy tip.
const LINK_LENGTH = 1.25; // Constant stretcher length.
const PHI_CLOSED = THREE.MathUtils.degToRad(5);
const PHI_OPEN = THREE.MathUtils.degToRad(70);
const SLIDER_CLOSED_Y =
ROOT_Y - (PIVOT_DISTANCE + LINK_LENGTH);
const rootHub = new THREE.Mesh(
new THREE.CylinderGeometry(0.16, 0.19, 0.22, 12),
darkMetal
);
rootHub.position.copy(ROOT);
rootHub.castShadow = true;
scene.add(rootHub);
const topCap = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.145, 0),
pivotMaterial
);
topCap.position.set(0, ROOT_Y + 0.2, 0);
topCap.castShadow = true;
scene.add(topCap);
const sliderCollar = new THREE.Mesh(
new THREE.CylinderGeometry(0.145, 0.145, 0.14, 12),
copperMaterial
);
sliderCollar.castShadow = true;
scene.add(sliderCollar);
const sliderHub = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 0),
pivotMaterial
);
sliderHub.castShadow = true;
scene.add(sliderHub);
const ribInnerGeometry = new THREE.CylinderGeometry(
0.028,
0.036,
1,
6
);
const ribOuterGeometry = new THREE.CylinderGeometry(
0.018,
0.029,
1,
6
);
const linkGeometry = new THREE.CylinderGeometry(
0.021,
0.021,
1,
6
);
const pivotGeometry = new THREE.CylinderGeometry(
0.075,
0.075,
0.16,
8
);
const tipGeometry = new THREE.IcosahedronGeometry(0.067, 0);
const ribAssemblies = [];
for (let i = 0; i < SECTORS; i++) {
const innerRib = new THREE.Mesh(ribInnerGeometry, darkMetal);
const outerRib = new THREE.Mesh(ribOuterGeometry, darkMetal);
const stretcher = new THREE.Mesh(linkGeometry, copperMaterial);
const pivot = new THREE.Mesh(pivotGeometry, pivotMaterial);
const tip = new THREE.Mesh(tipGeometry, copperMaterial);
innerRib.castShadow = true;
outerRib.castShadow = true;
stretcher.castShadow = true;
pivot.castShadow = true;
tip.castShadow = true;
scene.add(innerRib, outerRib, stretcher, pivot, tip);
ribAssemblies.push({
innerRib,
outerRib,
stretcher,
pivot,
tip,
angle: (i / SECTORS) * Math.PI * 2
});
}
// -------------------------------------------------------------------------
// Low-poly fabric
//
// Each sector is split into five triangles. All sector boundaries use the
// exact rib positions, so they widen continuously as the ribs spread.
// -------------------------------------------------------------------------
const TRIANGLES_PER_SECTOR = 5;
const vertexCount = SECTORS * TRIANGLES_PER_SECTOR * 3;
const canopyPositions = new Float32Array(vertexCount * 3);
const canopyColors = new Float32Array(vertexCount * 3);
const canopyGeometry = new THREE.BufferGeometry();
canopyGeometry.setAttribute(
"position",
new THREE.BufferAttribute(canopyPositions, 3).setUsage(
THREE.DynamicDrawUsage
)
);
canopyGeometry.setAttribute(
"color",
new THREE.BufferAttribute(canopyColors, 3)
);
const palette = [
new THREE.Color(0x238f88),
new THREE.Color(0xd86b50),
new THREE.Color(0x2b7188),
new THREE.Color(0xe5a154)
];
const workingColor = new THREE.Color();
for (let sector = 0; sector < SECTORS; sector++) {
const base = palette[sector % palette.length];
const shades = [1.0, 0.79, 1.08, 0.86, 1.05];
for (let triangle = 0; triangle < TRIANGLES_PER_SECTOR; triangle++) {
workingColor.copy(base).multiplyScalar(shades[triangle]);
for (let vertex = 0; vertex < 3; vertex++) {
const index =
(sector * TRIANGLES_PER_SECTOR + triangle) * 3 + vertex;
canopyColors[index * 3] = workingColor.r;
canopyColors[index * 3 + 1] = workingColor.g;
canopyColors[index * 3 + 2] = workingColor.b;
}
}
}
const canopyMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
side: THREE.DoubleSide,
transparent: true,
opacity: 0.79,
roughness: 0.9,
metalness: 0.01,
flatShading: true,
depthWrite: true
});
const canopy = new THREE.Mesh(canopyGeometry, canopyMaterial);
canopy.castShadow = true;
canopy.receiveShadow = true;
scene.add(canopy);
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
const upAxis = new THREE.Vector3(0, 1, 0);
const barDirection = new THREE.Vector3();
function placeBar(mesh, start, end) {
barDirection.subVectors(end, start);
const length = barDirection.length();
if (length < 0.000001) return;
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.scale.set(1, length, 1);
mesh.quaternion.setFromUnitVectors(
upAxis,
barDirection.normalize()
);
}
const ribB = [];
const ribM = [];
const ribT = [];
for (let i = 0; i < SECTORS; i++) {
ribB.push(new THREE.Vector3());
ribM.push(new THREE.Vector3());
ribT.push(new THREE.Vector3());
}
const sliderPoint = new THREE.Vector3();
function updateMechanism(progress) {
const eased = progress * progress * (3 - 2 * progress);
const phi = THREE.MathUtils.lerp(
PHI_CLOSED,
PHI_OPEN,
eased
);
const sinPhi = Math.sin(phi);
const cosPhi = Math.cos(phi);
/*
* Exact slider-crank geometry.
*
* The pivot B is constrained to a circle of radius PIVOT_DISTANCE
* around ROOT. The stretcher from B to S has constant LINK_LENGTH.
*
* Solving the two-circle constraint gives:
*
* d = a cos(phi) + sqrt(L² - a² sin²(phi))
*
* where d is the vertical distance from ROOT to the slider.
*/
const distanceRootToSlider =
PIVOT_DISTANCE * cosPhi +
Math.sqrt(
Math.max(
0,
LINK_LENGTH * LINK_LENGTH -
PIVOT_DISTANCE * PIVOT_DISTANCE * sinPhi * sinPhi
)
);
const sliderY = ROOT_Y - distanceRootToSlider;
sliderPoint.set(0, sliderY, 0);
sliderCollar.position.set(0, sliderY, 0);
sliderHub.position.set(0, sliderY, 0);
for (let i = 0; i < SECTORS; i++) {
const assembly = ribAssemblies[i];
const theta = assembly.angle;
const cosTheta = Math.cos(theta);
const sinTheta = Math.sin(theta);
// Individual rib pivot, shared by all three linked members.
const pivotRadius = PIVOT_DISTANCE * sinPhi;
const pivotY = ROOT_Y - PIVOT_DISTANCE * cosPhi;
const B = ribB[i];
B.set(
pivotRadius * cosTheta,
pivotY,
pivotRadius * sinTheta
);
// The outer rib continues along the same radial plane.
const tipRadius =
(PIVOT_DISTANCE + OUTER_RIB_LENGTH) * sinPhi;
const tipY =
ROOT_Y -
(PIVOT_DISTANCE + OUTER_RIB_LENGTH) * cosPhi;
const T = ribT[i];
T.set(
tipRadius * cosTheta,
tipY,
tipRadius * sinTheta
);
const M = ribM[i];
M.lerpVectors(B, T, 0.56);
placeBar(assembly.innerRib, ROOT, B);
placeBar(assembly.outerRib, B, T);
placeBar(assembly.stretcher, sliderPoint, B);
assembly.pivot.position.copy(B);
// Pivot axis is tangential to each radial rib plane.
const tangent = new THREE.Vector3(-sinTheta, 0, cosTheta);
assembly.pivot.quaternion.setFromUnitVectors(upAxis, tangent);
assembly.tip.position.copy(T);
}
updateCanopy();
}
function writeTriangle(array, offset, a, b, c) {
array[offset] = a.x;
array[offset + 1] = a.y;
array[offset + 2] = a.z;
array[offset + 3] = b.x;
array[offset + 4] = b.y;
array[offset + 5] = b.z;
array[offset + 6] = c.x;
array[offset + 7] = c.y;
array[offset + 8] = c.z;
}
function updateCanopy() {
let offset = 0;
for (let i = 0; i < SECTORS; i++) {
const next = (i + 1) % SECTORS;
const Bi = ribB[i];
const Bj = ribB[next];
const Mi = ribM[i];
const Mj = ribM[next];
const Ti = ribT[i];
const Tj = ribT[next];
// Inner conical fan.
writeTriangle(
canopyPositions,
offset,
ROOT,
Bj,
Bi
);
offset += 9;
// Middle fabric band.
writeTriangle(
canopyPositions,
offset,
Bi,
Bj,
Mj
);
offset += 9;
writeTriangle(
canopyPositions,
offset,
Bi,
Mj,
Mi
);
offset += 9;
// Outer fabric band.
writeTriangle(
canopyPositions,
offset,
Mi,
Mj,
Tj
);
offset += 9;
writeTriangle(
canopyPositions,
offset,
Mi,
Tj,
Ti
);
offset += 9;
}
canopyGeometry.attributes.position.needsUpdate = true;
canopyGeometry.computeVertexNormals();
canopyGeometry.computeBoundingSphere();
}
// -------------------------------------------------------------------------
// Camera controls implemented directly, without Three.js addons
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 1.9, 0);
let cameraYaw = 0.66;
let cameraPitch = 0.3;
let cameraDistance = 7.25;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
const horizontalDistance =
cameraDistance * Math.cos(cameraPitch);
camera.position.set(
cameraTarget.x +
horizontalDistance * Math.sin(cameraYaw),
cameraTarget.y +
cameraDistance * Math.sin(cameraPitch),
cameraTarget.z +
horizontalDistance * Math.cos(cameraYaw)
);
camera.lookAt(cameraTarget);
}
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 deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraYaw -= deltaX * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + deltaY * 0.0045,
0.04,
1.08
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerType !== "mouse" &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraDistance = THREE.MathUtils.clamp(
cameraDistance * Math.exp(event.deltaY * 0.001),
4.6,
10.5
);
updateCamera();
},
{ passive: false }
);
updateCamera();
// -------------------------------------------------------------------------
// Animation and UI
// -------------------------------------------------------------------------
const travel = document.getElementById("travel");
const travelValue = document.getElementById("travelValue");
const elevation = document.getElementById("elevation");
const state = document.getElementById("state");
const motionButton = document.getElementById("motion");
const DURATION = 3400;
const INITIAL_DELAY = 450;
let progress = 0;
let elapsed = -INITIAL_DELAY;
let playing = true;
function updateInterface() {
travel.value = (progress * 100).toFixed(1);
travelValue.textContent = `${Math.round(progress * 100)}%`;
const sliderY = sliderCollar.position.y;
const rise = sliderY - SLIDER_CLOSED_Y;
elevation.textContent = `${rise >= 0 ? "+" : ""}${rise.toFixed(3)}`;
if (progress >= 0.9999) {
state.textContent = "Stable open";
state.style.color = "#5cc8be";
} else if (playing) {
state.textContent = "Opening";
state.style.color = "#f08a5d";
} else {
state.textContent = "Manual";
state.style.color = "#e4b968";
}
motionButton.textContent = playing
? "Pause motion"
: progress >= 0.9999
? "Replay opening"
: "Resume motion";
}
travel.addEventListener("input", () => {
progress = Number(travel.value) / 100;
elapsed = progress * DURATION;
playing = false;
updateMechanism(progress);
updateInterface();
});
motionButton.addEventListener("click", () => {
if (playing) {
playing = false;
} else if (progress >= 0.9999) {
progress = 0;
elapsed = -INITIAL_DELAY;
playing = true;
} else {
if (elapsed < 0) elapsed = -INITIAL_DELAY;
playing = true;
}
updateMechanism(progress);
updateInterface();
});
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (playing) {
elapsed += delta * 1000;
if (elapsed >= 0) {
const raw = THREE.MathUtils.clamp(
elapsed / DURATION,
0,
1
);
// Smooth opening with no overshoot or oscillation.
progress = raw * raw * (3 - 2 * raw);
if (raw >= 1) {
progress = 1;
playing = false;
}
}
updateMechanism(progress);
updateInterface();
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateMechanism(0);
updateInterface();
requestAnimationFrame(animate);
// -------------------------------------------------------------------------
// Resize handling
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(
Math.min(window.devicePixelRatio, 2)
);
renderer.setSize(
window.innerWidth,
window.innerHeight
);
});
</script>
</body>
</html>
```