Prompt specification
Build or customize the Three.js 3D scene "Stepped Object With Separate Layer Slices" 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: Stepped Object With Separate Layer Slices
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/stepped-object-with-separate-layer-slices-x2001
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: stepped object with separate layer slices. Model a simple stepped object beside its horizontal slices stacked in order. Keep each slice aligned so the final volume can be reconstructed without missing layers. Return one self-contained HTML file.
Working Three.js Starter (stepped-object-with-separate-layer-slices-x2001):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Layer Study — Three.js</title>
<style>
:root {
color-scheme: dark;
--ink: #edf8f7;
--muted: #91a7ad;
--line: rgba(184, 225, 226, 0.16);
--panel: rgba(8, 20, 28, 0.72);
--base: #56e2cf;
--middle: #a897ff;
--top: #ff9c8f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 72% 38%, rgba(42, 91, 99, 0.22), transparent 36%),
radial-gradient(circle at 22% 70%, rgba(91, 61, 137, 0.13), transparent 34%),
linear-gradient(145deg, #08131b 0%, #061018 55%, #03090e 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.masthead {
position: absolute;
top: clamp(22px, 4vw, 48px);
left: clamp(22px, 4vw, 54px);
max-width: 340px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 17px;
color: #9db2b7;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 1px;
content: "";
background: var(--base);
box-shadow: 0 0 12px rgba(86, 226, 207, 0.55);
}
h1 {
margin: 0;
font-size: clamp(36px, 5.3vw, 72px);
font-weight: 560;
line-height: 0.92;
letter-spacing: -0.055em;
}
.intro {
max-width: 285px;
margin: 20px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.65;
}
.status {
position: absolute;
top: clamp(22px, 4vw, 48px);
right: clamp(22px, 4vw, 54px);
min-width: 190px;
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(7, 18, 25, 0.5);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.status-row {
display: flex;
align-items: center;
gap: 9px;
color: #d9e9e8;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--base);
box-shadow: 0 0 12px rgba(86, 226, 207, 0.85);
}
.status-sub {
margin-top: 7px;
color: #728b92;
font-size: 10px;
letter-spacing: 0.04em;
}
.control-panel {
position: absolute;
bottom: clamp(22px, 4vw, 42px);
left: clamp(22px, 4vw, 54px);
width: min(330px, calc(100vw - 44px));
padding: 17px 18px 15px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
pointer-events: auto;
}
.control-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
color: #c7d9da;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
}
output {
color: var(--base);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 4px 0 15px;
border-radius: 999px;
outline: none;
appearance: none;
-webkit-appearance: none;
background: linear-gradient(
90deg,
var(--base) 0%,
var(--base) var(--range-fill, 100%),
rgba(255, 255, 255, 0.12) var(--range-fill, 100%)
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
border: 3px solid #0a1b22;
border-radius: 50%;
appearance: none;
-webkit-appearance: none;
background: #d9fff8;
box-shadow: 0 0 0 1px rgba(86, 226, 207, 0.8), 0 0 14px rgba(86, 226, 207, 0.45);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 3px solid #0a1b22;
border-radius: 50%;
background: #d9fff8;
box-shadow: 0 0 0 1px rgba(86, 226, 207, 0.8), 0 0 14px rgba(86, 226, 207, 0.45);
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
button {
padding: 9px 11px;
border: 1px solid rgba(191, 222, 223, 0.14);
border-radius: 9px;
background: rgba(255, 255, 255, 0.035);
color: #91a7ad;
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
cursor: pointer;
transition:
color 160ms ease,
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
button:hover {
color: #e8f5f4;
border-color: rgba(191, 222, 223, 0.28);
transform: translateY(-1px);
}
button.active {
border-color: rgba(86, 226, 207, 0.45);
background: rgba(86, 226, 207, 0.09);
color: #bafff3;
}
.instructions {
position: absolute;
right: clamp(22px, 4vw, 54px);
bottom: clamp(24px, 4vw, 45px);
color: #71888f;
font-size: 10px;
letter-spacing: 0.09em;
text-align: right;
line-height: 1.7;
}
.instructions strong {
color: #a9bcbf;
font-weight: 600;
}
#labels {
position: fixed;
inset: 0;
z-index: 2;
overflow: hidden;
pointer-events: none;
}
.slice-label {
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 9px;
min-width: 112px;
padding: 7px 9px;
border: 1px solid rgba(198, 230, 230, 0.12);
border-radius: 8px;
background: rgba(4, 13, 18, 0.66);
color: #d5e4e3;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
white-space: nowrap;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
will-change: transform;
}
.slice-label::before {
width: 6px;
height: 6px;
flex: 0 0 auto;
border-radius: 50%;
content: "";
background: var(--slice-color);
box-shadow: 0 0 10px var(--slice-color);
}
.slice-label small {
margin-left: auto;
color: #718a91;
font-size: 8px;
font-weight: 500;
letter-spacing: 0.06em;
}
@media (max-width: 800px) {
.masthead {
max-width: 240px;
}
.intro {
display: none;
}
.status {
top: auto;
right: 18px;
bottom: 112px;
min-width: 0;
}
.status-sub {
display: none;
}
.control-panel {
right: 18px;
bottom: 18px;
left: 18px;
width: auto;
}
.instructions {
display: none;
}
.slice-label {
min-width: 0;
padding: 6px 8px;
}
.slice-label small {
display: none;
}
}
@media (max-height: 620px) {
.intro,
.status-sub {
display: none;
}
.masthead {
top: 18px;
}
h1 {
font-size: 38px;
}
.control-panel {
bottom: 16px;
}
}
</style>
</head>
<body>
<div id="labels" aria-hidden="true"></div>
<div class="hud">
<header class="masthead">
<div class="eyebrow">Volume study · 03 layers</div>
<h1>Stepped<br />in layers.</h1>
<p class="intro">
A stepped solid beside its ordered horizontal sections. Every layer remains
registered on the same axis.
</p>
</header>
<aside class="status" aria-live="polite">
<div class="status-row">
<span class="status-dot"></span>
<span id="stateWord">Exploded view</span>
</div>
<div class="status-sub">3 of 3 sections indexed</div>
</aside>
<section class="control-panel" aria-label="Slice separation control">
<div class="control-heading">
<span>Layer separation</span>
<output id="spreadValue" for="spread">100%</output>
</div>
<input
id="spread"
type="range"
min="0"
max="100"
value="100"
step="1"
aria-label="Layer separation"
/>
<div class="button-row">
<button id="assembleButton" type="button">Assemble</button>
<button id="explodeButton" class="active" type="button">Explode</button>
</div>
</section>
<div class="instructions">
<strong>Drag</strong> to orbit · <strong>Scroll</strong> to zoom<br />
<strong>Double-click</strong> to reset the view
</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 scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x061018, 0.027);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 80);
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.setClearColor(0x000000, 0);
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 3D view of a stepped object and its separated horizontal layers"
);
renderer.domElement.tabIndex = 0;
document.body.prepend(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
const hemisphere = new THREE.HemisphereLight(0xc9f5ff, 0x071018, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.4);
keyLight.position.set(-4.5, 8.5, 6.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 24;
keyLight.shadow.bias = -0.00025;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x8797ff, 1.8);
fillLight.position.set(5, 4, -6);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xff8179, 30, 11, 2);
rimLight.position.set(3.5, 4.5, 3.5);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
new THREE.MeshStandardMaterial({
color: 0x07141b,
roughness: 0.95,
metalness: 0.02,
transparent: true,
opacity: 0.86
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.012;
floor.receiveShadow = true;
world.add(floor);
const grid = new THREE.GridHelper(22, 44, 0x31505a, 0x18323a);
grid.position.y = 0.002;
grid.material.transparent = true;
grid.material.opacity = 0.22;
grid.material.depthWrite = false;
world.add(grid);
const assembledGroup = new THREE.Group();
const explodedGroup = new THREE.Group();
const explodedX = 2.35;
const assembledX = -2.35;
assembledGroup.position.x = assembledX;
explodedGroup.position.x = explodedX;
world.add(assembledGroup, explodedGroup);
function roundedRectangleShape(width, depth, radius) {
const x = -width / 2;
const y = -depth / 2;
const r = Math.min(radius, width / 2, depth / 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 + depth - r);
shape.quadraticCurveTo(x + width, y + depth, x + width - r, y + depth);
shape.lineTo(x + r, y + depth);
shape.quadraticCurveTo(x, y + depth, x, y + depth - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
return shape;
}
function createLayerGeometry(width, depth, height, radius) {
const shape = roundedRectangleShape(width, depth, radius);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
steps: 1,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.055,
bevelThickness: 0.055,
curveSegments: 10
});
geometry.rotateX(-Math.PI / 2);
geometry.computeBoundingBox();
const originalHeight =
geometry.boundingBox.max.y - geometry.boundingBox.min.y;
geometry.scale(1, height / originalHeight, 1);
geometry.computeBoundingBox();
geometry.translate(0, -geometry.boundingBox.min.y, 0);
geometry.computeVertexNormals();
geometry.computeBoundingBox();
return geometry;
}
const layerDefinitions = [
{
name: "Foot",
label: "01 / Foot",
width: 3.1,
depth: 3.1,
height: 0.76,
radius: 0.18,
side: 0x11a9a4,
top: 0x56e2cf,
css: "#56e2cf"
},
{
name: "Body",
label: "02 / Body",
width: 2.15,
depth: 2.15,
height: 0.68,
radius: 0.15,
side: 0x6858d7,
top: 0xa897ff,
css: "#a897ff"
},
{
name: "Cap",
label: "03 / Cap",
width: 1.2,
depth: 1.2,
height: 0.62,
radius: 0.12,
side: 0xe85f68,
top: 0xff9c8f,
css: "#ff9c8f"
}
];
function createLayer(definition) {
const geometry = createLayerGeometry(
definition.width,
definition.depth,
definition.height,
definition.radius
);
const sideMaterial = new THREE.MeshStandardMaterial({
color: definition.side,
roughness: 0.39,
metalness: 0.07
});
const topMaterial = new THREE.MeshStandardMaterial({
color: definition.top,
roughness: 0.31,
metalness: 0.08
});
const mesh = new THREE.Mesh(geometry, [topMaterial, sideMaterial]);
mesh.castShadow = true;
mesh.receiveShadow = true;
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x031016,
transparent: true,
opacity: 0.36
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 24),
edgeMaterial
);
const group = new THREE.Group();
group.add(mesh, edges);
return {
group,
height: definition.height,
definition
};
}
const layers = layerDefinitions.map(createLayer);
const assembledBottoms = [];
let assembledCursor = 0.04;
layers.forEach((layer) => {
assembledBottoms.push(assembledCursor);
assembledCursor += layer.height;
});
const explodedBottoms = [
assembledBottoms[0],
assembledBottoms[0] + layers[0].height + 0.42,
assembledBottoms[0] + layers[0].height + 0.42 + layers[1].height + 0.48
];
layers.forEach((layer, index) => {
assembledGroup.add(layer.group);
explodedGroup.add(layer.group.clone(true));
layer.group.position.y = assembledBottoms[index];
const explodedLayer = explodedGroup.children[index];
explodedLayer.position.y = explodedBottoms[index];
});
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(2.05, 2.08, 0.055, 64),
new THREE.MeshStandardMaterial({
color: 0x0b2029,
roughness: 0.7,
metalness: 0.12
})
);
pedestal.position.set(assembledX, 0.01, 0);
pedestal.receiveShadow = true;
world.add(pedestal);
const registrationRing = new THREE.Mesh(
new THREE.RingGeometry(1.91, 1.925, 64),
new THREE.MeshBasicMaterial({
color: 0x62d8d0,
transparent: true,
opacity: 0.24,
side: THREE.DoubleSide,
depthWrite: false
})
);
registrationRing.rotation.x = -Math.PI / 2;
registrationRing.position.set(explodedX, 0.006, 0);
world.add(registrationRing);
const alignmentMaterial = new THREE.LineDashedMaterial({
color: 0x8fe9df,
dashSize: 0.1,
gapSize: 0.095,
transparent: true,
opacity: 0.42,
depthWrite: false
});
const alignmentLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(explodedX, 0.01, 0),
new THREE.Vector3(explodedX, 3.28, 0)
]),
alignmentMaterial
);
alignmentLine.computeLineDistances();
world.add(alignmentLine);
const labelContainer = document.getElementById("labels");
const sliceLabels = layers.map((layer) => {
const element = document.createElement("div");
element.className = "slice-label";
element.style.setProperty("--slice-color", layer.definition.css);
element.innerHTML = `
<span>${layer.definition.label}</span>
<small>${layer.definition.width.toFixed(1)} × ${layer.definition.depth.toFixed(1)}</small>
`;
labelContainer.appendChild(element);
return element;
});
const cameraTarget = new THREE.Vector3(0, 1.36, 0);
const controls = {
theta: 0.53,
phi: 1.03,
distance: 12.4,
desiredTheta: 0.53,
desiredPhi: 1.03,
desiredDistance: 12.4,
target: cameraTarget
};
let hasInteracted = false;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let activePointerId = null;
const canvas = renderer.domElement;
function markInteraction() {
hasInteracted = true;
}
function resetCamera() {
controls.desiredTheta = 0.53;
controls.desiredPhi = 1.03;
controls.desiredDistance = fittedDistance();
markInteraction();
}
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
activePointerId = event.pointerId;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
markInteraction();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointerId) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
controls.desiredTheta -= deltaX * 0.006;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - deltaY * 0.005,
0.48,
1.38
);
});
function endDrag(event) {
if (event.pointerId !== activePointerId) return;
dragging = false;
activePointerId = null;
canvas.style.cursor = "grab";
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("lostpointercapture", () => {
dragging = false;
activePointerId = null;
canvas.style.cursor = "grab";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.desiredDistance = THREE.MathUtils.clamp(
controls.desiredDistance * Math.exp(event.deltaY * 0.001),
7.5,
25
);
markInteraction();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("keydown", (event) => {
const step = 0.09;
if (event.key === "ArrowLeft") {
controls.desiredTheta += step;
} else if (event.key === "ArrowRight") {
controls.desiredTheta -= step;
} else if (event.key === "ArrowUp") {
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - step,
0.48,
1.38
);
} else if (event.key === "ArrowDown") {
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi + step,
0.48,
1.38
);
} else if (event.key === "+" || event.key === "=") {
controls.desiredDistance = Math.max(7.5, controls.desiredDistance - 0.7);
} else if (event.key === "-" || event.key === "_") {
controls.desiredDistance = Math.min(25, controls.desiredDistance + 0.7);
} else {
return;
}
event.preventDefault();
markInteraction();
});
canvas.style.cursor = "grab";
const spreadInput = document.getElementById("spread");
const spreadValue = document.getElementById("spreadValue");
const stateWord = document.getElementById("stateWord");
const assembleButton = document.getElementById("assembleButton");
const explodeButton = document.getElementById("explodeButton");
let targetSpread = 1;
let currentSpread = 1;
function updateControlUI(value) {
const percentage = Math.round(value);
spreadValue.value = `${percentage}%`;
spreadValue.textContent = `${percentage}%`;
spreadInput.style.setProperty("--range-fill", `${percentage}%`);
if (percentage === 0) {
stateWord.textContent = "Reconstructed";
} else if (percentage === 100) {
stateWord.textContent = "Exploded view";
} else {
stateWord.textContent = "Partial separation";
}
assembleButton.classList.toggle("active", percentage === 0);
explodeButton.classList.toggle("active", percentage === 100);
}
spreadInput.addEventListener("input", () => {
targetSpread = Number(spreadInput.value) / 100;
updateControlUI(targetSpread * 100);
});
assembleButton.addEventListener("click", () => {
targetSpread = 0;
spreadInput.value = "0";
updateControlUI(0);
});
explodeButton.addEventListener("click", () => {
targetSpread = 1;
spreadInput.value = "100";
updateControlUI(100);
});
updateControlUI(100);
function fittedDistance() {
const aspect = window.innerWidth / window.innerHeight;
if (aspect < 0.75) return 22;
if (aspect < 1.1) return 16.5;
return 12.4;
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
if (!hasInteracted) {
controls.desiredDistance = fittedDistance();
controls.distance = controls.desiredDistance;
}
}
window.addEventListener("resize", resize);
resize();
const labelPosition = new THREE.Vector3();
const projectedPosition = new THREE.Vector3();
function updateWorldLabels() {
layers.forEach((layer, index) => {
const explodedLayer = explodedGroup.children[index];
const centerY = explodedLayer.position.y + layer.height / 2;
labelPosition.set(explodedX + 2.08, centerY, 0);
projectedPosition.copy(labelPosition).project(camera);
const x = (projectedPosition.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projectedPosition.y * 0.5 + 0.5) * window.innerHeight;
const visible =
projectedPosition.z > -1 &&
projectedPosition.z < 1 &&
x > -80 &&
x < window.innerWidth + 80 &&
y > -40 &&
y < window.innerHeight + 40;
sliceLabels[index].style.opacity = visible ? "1" : "0";
sliceLabels[index].style.transform = `
translate3d(${x}px, ${y}px, 0)
translate(-50%, -50%)
`;
});
}
const spherical = new THREE.Spherical();
let previousTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const deltaTime = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
const cameraEase = 1 - Math.exp(-deltaTime * 10);
const spreadEase = 1 - Math.exp(-deltaTime * 8);
controls.theta +=
(controls.desiredTheta - controls.theta) * cameraEase;
controls.phi +=
(controls.desiredPhi - controls.phi) * cameraEase;
controls.distance +=
(controls.desiredDistance - controls.distance) * cameraEase;
currentSpread +=
(targetSpread - currentSpread) * spreadEase;
layers.forEach((layer, index) => {
const bottom = THREE.MathUtils.lerp(
assembledBottoms[index],
explodedBottoms[index],
currentSpread
);
explodedGroup.children[index].position.y = bottom;
});
spherical.set(
controls.distance,
controls.phi,
controls.theta
);
camera.position.setFromSpherical(spherical).add(controls.target);
camera.lookAt(controls.target);
renderer.render(scene, camera);
updateWorldLabels();
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```