Prompt specification
Build or customize the Three.js 3D scene "Three-Panel Rolling Ball Story" 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: Three-Panel Rolling Ball Story
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/three-panel-rolling-ball-story-x3349
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts visual story sequences and continuity. Arrange a ramp, a displaced cup, and a resting ball across three miniature panels. Preserve object identity and direction so the sequence can be reconstructed visually. Stylized solid forms.
Working Three.js Starter (three-panel-rolling-ball-story-x3349):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Roll, Displace, Rest — Three.js Story Panels</title>
<style>
:root {
--ink: #26312e;
--muted: #68716c;
--paper: #eee9df;
--ball: #ee6959;
--cup: #28998d;
--ramp: #e7b84f;
--panel: rgba(250, 248, 242, 0.9);
}
* { box-sizing: border-box; }
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
header {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
max-width: 520px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(27px, 3.3vw, 48px);
font-weight: 750;
letter-spacing: -0.045em;
line-height: 0.98;
}
header p {
max-width: 460px;
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.legend {
position: fixed;
z-index: 5;
top: 30px;
right: 30px;
display: flex;
gap: 7px;
flex-wrap: wrap;
justify-content: flex-end;
max-width: 380px;
pointer-events: none;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
border: 1px solid rgba(38, 49, 46, 0.11);
border-radius: 999px;
background: rgba(250, 248, 242, 0.76);
color: #53605b;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.swatch {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.swatch.ball { background: var(--ball); }
.swatch.cup { background: var(--cup); }
.swatch.ramp { background: var(--ramp); }
.stage-label {
position: fixed;
z-index: 4;
display: none;
align-items: center;
gap: 9px;
min-width: 132px;
padding: 8px 11px 8px 8px;
border: 1px solid rgba(38, 49, 46, 0.11);
border-radius: 12px;
background: rgba(250, 248, 242, 0.88);
box-shadow: 0 8px 24px rgba(41, 45, 42, 0.07);
pointer-events: none;
transform: translate(-50%, -50%);
backdrop-filter: blur(8px);
}
.stage-label .index {
display: grid;
width: 30px;
height: 30px;
place-items: center;
border-radius: 8px;
background: #29332f;
color: white;
font-size: 11px;
font-weight: 850;
}
.stage-label b,
.stage-label small {
display: block;
}
.stage-label b {
font-size: 10px;
letter-spacing: 0.12em;
}
.stage-label small {
margin-top: 2px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
}
nav {
position: fixed;
z-index: 8;
bottom: 24px;
left: 50%;
display: flex;
gap: 7px;
max-width: calc(100vw - 30px);
padding: 7px;
overflow-x: auto;
border: 1px solid rgba(38, 49, 46, 0.12);
border-radius: 16px;
background: rgba(248, 246, 239, 0.9);
box-shadow: 0 14px 38px rgba(40, 45, 41, 0.1);
transform: translateX(-50%);
backdrop-filter: blur(12px);
}
nav button {
display: flex;
align-items: center;
gap: 8px;
flex: 0 0 auto;
min-height: 39px;
padding: 0 13px;
border: 0;
border-radius: 10px;
background: transparent;
color: #65706a;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
transition: background 160ms ease, color 160ms ease;
}
nav button:hover {
background: rgba(38, 49, 46, 0.06);
color: var(--ink);
}
nav button.active {
background: #29332f;
color: white;
}
nav button .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #a3aaa5;
}
nav button[data-stage="0"] .dot { background: var(--ball); }
nav button[data-stage="1"] .dot { background: var(--ramp); }
nav button[data-stage="2"] .dot { background: var(--cup); }
.help {
position: fixed;
z-index: 5;
right: 30px;
bottom: 31px;
color: rgba(57, 68, 63, 0.58);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
pointer-events: none;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: var(--paper);
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
@media (max-width: 800px) {
header {
top: 18px;
left: 18px;
max-width: 75vw;
}
header p { display: none; }
.legend {
top: auto;
right: 12px;
bottom: 88px;
max-width: 190px;
}
.legend span {
padding: 6px 8px;
font-size: 8px;
}
.help { display: none; }
nav {
bottom: 12px;
}
nav button {
padding: 0 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header>
<div class="eyebrow">Motion study · three continuous moments</div>
<h1>Roll. Displace.<br />Rest.</h1>
<p>
The same coral ball, teal cup, and gold ramp are repeated across
three miniature panels. Their scale, colors, and left-to-right direction
remain constant so the action can be reconstructed frame by frame.
</p>
</header>
<div class="legend" aria-label="Object color key">
<span><i class="swatch ball"></i>Ball</span>
<span><i class="swatch cup"></i>Cup</span>
<span><i class="swatch ramp"></i>Ramp</span>
</div>
<div class="stage-label" id="label-0">
<span class="index">01</span>
<span><b>RELEASE</b><small>ball at the crest</small></span>
</div>
<div class="stage-label" id="label-1">
<span class="index">02</span>
<span><b>DISPLACE</b><small>contact shifts the cup</small></span>
</div>
<div class="stage-label" id="label-2">
<span class="index">03</span>
<span><b>REST</b><small>final positions</small></span>
</div>
<nav aria-label="Camera views">
<button id="overview" class="active">
<span class="dot"></span>Overview
</button>
<button data-stage="0">
<span class="dot"></span>01 Release
</button>
<button data-stage="1">
<span class="dot"></span>02 Displace
</button>
<button data-stage="2">
<span class="dot"></span>03 Rest
</button>
</nav>
<div class="help">Drag to orbit · scroll to zoom · keys 1–4</div>
<div id="loading">Building the sequence…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Scene and renderer
// ------------------------------------------------------------
const container = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee9df);
scene.fog = new THREE.Fog(0xeee9df, 24, 52);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
container.appendChild(renderer.domElement);
const clock = new THREE.Clock();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x7c8983, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff4df, 3.1);
keyLight.position.set(-7, 13, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 38;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc9e3e2, 1.25);
fillLight.position.set(10, 6, -7);
scene.add(fillLight);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const materials = {
ground: new THREE.MeshStandardMaterial({
color: 0xded9cf,
roughness: 0.92
}),
base: new THREE.MeshStandardMaterial({
color: 0xcfc8bb,
roughness: 0.82
}),
top: new THREE.MeshStandardMaterial({
color: 0xf7f2e8,
roughness: 0.76
}),
wall: new THREE.MeshStandardMaterial({
color: 0xf3eee4,
roughness: 0.8
}),
ramp: new THREE.MeshStandardMaterial({
color: 0xe7b84f,
roughness: 0.58
}),
rampDark: new THREE.MeshStandardMaterial({
color: 0xc79636,
roughness: 0.68
}),
rampArrow: new THREE.MeshStandardMaterial({
color: 0x775a20,
roughness: 0.72
}),
ball: new THREE.MeshStandardMaterial({
color: 0xee6959,
roughness: 0.42
}),
ballSpot: new THREE.MeshStandardMaterial({
color: 0xffefcf,
roughness: 0.5
}),
cup: new THREE.MeshStandardMaterial({
color: 0x28998d,
roughness: 0.52
}),
cupInside: new THREE.MeshStandardMaterial({
color: 0x17675f,
roughness: 0.8
}),
connector: new THREE.MeshStandardMaterial({
color: 0x8d9690,
roughness: 0.72
}),
path: new THREE.MeshStandardMaterial({
color: 0xc85c4e,
roughness: 0.8,
transparent: true,
opacity: 0.72,
depthWrite: false,
side: THREE.DoubleSide
}),
target: new THREE.MeshBasicMaterial({
color: 0x28998d,
transparent: true,
opacity: 0.42,
depthWrite: false
})
};
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
materials.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.235;
ground.receiveShadow = true;
scene.add(ground);
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function box(parent, width, height, depth, material, x, y, z) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function floorArrow(parent, x, y, z, scale = 1, material = materials.path) {
const shape = new THREE.Shape();
shape.moveTo(-0.28, -0.075);
shape.lineTo(0.06, -0.075);
shape.lineTo(0.06, -0.19);
shape.lineTo(0.34, 0);
shape.lineTo(0.06, 0.19);
shape.lineTo(0.06, 0.075);
shape.lineTo(-0.28, 0.075);
shape.closePath();
const mesh = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
material
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, y, z);
mesh.scale.setScalar(scale);
parent.add(mesh);
return mesh;
}
function createBall() {
const group = new THREE.Group();
const radius = 0.245;
const sphere = new THREE.Mesh(
new THREE.SphereGeometry(radius, 40, 28),
materials.ball
);
sphere.castShadow = true;
sphere.receiveShadow = true;
group.add(sphere);
// A tiny directional marker makes the ball's rotation readable.
const spot = new THREE.Mesh(
new THREE.SphereGeometry(0.052, 18, 12),
materials.ballSpot
);
spot.scale.z = 0.25;
spot.position.set(0, 0.075, 0.237);
group.add(spot);
return group;
}
function createCup() {
const pivot = new THREE.Group();
const cup = new THREE.Group();
// The pivot is at the cup's center so it can tip naturally.
cup.position.y = 0.34;
pivot.add(cup);
const profile = [
new THREE.Vector2(0.00, -0.34),
new THREE.Vector2(0.32, -0.34),
new THREE.Vector2(0.38, -0.29),
new THREE.Vector2(0.41, 0.26),
new THREE.Vector2(0.37, 0.34),
new THREE.Vector2(0.32, 0.28),
new THREE.Vector2(0.29, -0.24),
new THREE.Vector2(0.00, -0.24)
];
const body = new THREE.Mesh(
new THREE.LatheGeometry(profile, 48),
materials.cup
);
body.castShadow = true;
body.receiveShadow = true;
cup.add(body);
const lip = new THREE.Mesh(
new THREE.TorusGeometry(0.365, 0.033, 12, 48),
materials.cup
);
lip.rotation.x = Math.PI / 2;
lip.position.y = 0.32;
lip.castShadow = true;
cup.add(lip);
const inside = new THREE.Mesh(
new THREE.CylinderGeometry(0.305, 0.305, 0.025, 48),
materials.cupInside
);
inside.position.y = 0.275;
cup.add(inside);
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.17, 0.052, 12, 32),
materials.cup
);
handle.position.set(0.39, 0.005, 0);
handle.castShadow = true;
cup.add(handle);
return pivot;
}
function connectorArrow(x) {
const group = new THREE.Group();
group.position.set(x, 0.62, 0.35);
box(
group,
0.34, 0.045, 0.045,
materials.connector,
0, 0, 0
);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.115, 0.23, 3),
materials.connector
);
head.rotation.z = -Math.PI / 2;
head.position.x = 0.25;
head.castShadow = true;
group.add(head);
scene.add(group);
}
// ------------------------------------------------------------
// Three miniature panels
// ------------------------------------------------------------
const panelXs = [-5.2, 0, 5.2];
const floorY = 0.23;
const rampQuaternion = new THREE.Quaternion();
const rampNormal = new THREE.Vector3();
const rampSurface = new THREE.Vector3();
const rampPosition = new THREE.Vector3(-0.65, 0.73, -0.35);
const rampAngle = -0.26;
const rampQuaternionLocal = new THREE.Quaternion().setFromEuler(
new THREE.Euler(0, 0, rampAngle)
);
const rampSurfaceLocal = new THREE.Vector3(-0.88, 0.09, 0);
rampSurface.copy(rampSurfaceLocal)
.applyQuaternion(rampQuaternionLocal)
.add(rampPosition);
rampNormal.set(0, 1, 0).applyQuaternion(rampQuaternionLocal);
const crestBallPosition = rampSurface.clone()
.addScaledVector(rampNormal, 0.245);
const accentColors = [0xee6959, 0xe7b84f, 0x28998d];
panelXs.forEach((panelX, index) => {
const panel = new THREE.Group();
panel.position.x = panelX;
scene.add(panel);
// Pedestal and inset stage floor.
box(panel, 4.55, 0.34, 3.25, materials.base, 0, -0.05, 0);
box(panel, 4.38, 0.12, 3.08, materials.top, 0, 0.17, 0);
// Low back wall makes each object arrangement read as a miniature panel.
box(panel, 4.26, 1.28, 0.12, materials.wall, 0, 0.76, -1.48);
const accent = new THREE.MeshStandardMaterial({
color: accentColors[index],
roughness: 0.72
});
box(panel, 1.12, 0.075, 0.035, accent, -1.47, 0.02, 1.635);
box(panel, 4.20, 0.035, 0.035, accent, 0, 1.415, -1.405);
// Ramp supports.
box(panel, 0.22, 0.62, 1.10, materials.rampDark, -1.43, 0.54, -0.35);
box(panel, 0.22, 0.18, 1.10, materials.rampDark, 0.13, 0.32, -0.35);
// The identical sloped ramp in every panel.
const plank = box(
panel,
2.25, 0.18, 1.05,
materials.ramp,
rampPosition.x,
rampPosition.y,
rampPosition.z
);
plank.rotation.z = rampAngle;
// Raised side rails.
const railLeft = box(
plank,
2.25, 0.11, 0.07,
materials.rampDark,
0, 0.14, -0.49
);
const railRight = box(
plank,
2.25, 0.11, 0.07,
materials.rampDark,
0, 0.14, 0.49
);
railLeft.castShadow = true;
railRight.castShadow = true;
// Three arrows embedded in the ramp establish the shared direction.
[-0.60, 0, 0.60].forEach((arrowX) => {
floorArrow(
plank,
arrowX,
0.096,
0,
0.43,
materials.rampArrow
);
});
// The ring records the cup's original waiting position.
const targetRing = new THREE.Mesh(
new THREE.TorusGeometry(0.43, 0.017, 8, 48),
materials.target
);
targetRing.rotation.x = Math.PI / 2;
targetRing.position.set(1.00, floorY + 0.012, 0.35);
panel.add(targetRing);
// A common floor path continues rightward from the ramp.
floorArrow(panel, 0.28, floorY + 0.012, 0.25, 0.66);
floorArrow(panel, 0.66, floorY + 0.012, 0.25, 0.66);
const ball = createBall();
const cup = createCup();
if (index === 0) {
// 01 — Release: ball at the crest, cup waiting upright.
ball.position.copy(crestBallPosition);
ball.rotation.z = 0.12;
cup.position.set(1.00, floorY + 0.34, 0.35);
cup.rotation.z = 0;
} else if (index === 1) {
// 02 — Displace: ball reaches the cup and starts the push.
ball.position.set(0.56, floorY + 0.245, 0.20);
ball.rotation.z = 1.15;
cup.position.set(1.30, floorY + 0.35, 0.29);
cup.rotation.z = -0.29;
} else {
// 03 — Rest: cup is farther right; ball has settled.
ball.position.set(1.76, floorY + 0.245, 0.62);
ball.rotation.z = 2.35;
cup.position.set(1.58, floorY + 0.39, 0.08);
cup.rotation.z = -0.72;
// The final arrow points toward the ball's resting area.
floorArrow(panel, 1.92, floorY + 0.012, 0.62, 0.64);
}
panel.add(ball);
panel.add(cup);
});
// Directional connectors between the three physical panels.
connectorArrow(-2.60);
connectorArrow(2.60);
// ------------------------------------------------------------
// Camera controls implemented directly without add-ons
// ------------------------------------------------------------
const currentTarget = new THREE.Vector3(0, 0.50, 0);
const desiredTarget = currentTarget.clone();
let currentAzimuth = 0;
let desiredAzimuth = 0;
let currentPolar = 0.94;
let desiredPolar = 0.94;
let currentRadius = 18;
let desiredRadius = 18;
let currentMode = "overview";
const overviewButton = document.getElementById("overview");
const stageButtons = [...document.querySelectorAll("[data-stage]")];
function fitRadius() {
const aspect = innerWidth / innerHeight;
return THREE.MathUtils.clamp(
Math.max(17.5, 24 / aspect),
17.5,
42
);
}
function setActiveButton(active) {
stageButtons.forEach((button) => {
button.classList.toggle("active", button === active);
});
overviewButton.classList.toggle("active", active === overviewButton);
}
function showOverview() {
currentMode = "overview";
desiredTarget.set(0, 0.50, 0);
desiredRadius = fitRadius();
desiredAzimuth = 0;
desiredPolar = 0.94;
setActiveButton(overviewButton);
}
function showStage(index) {
currentMode = `stage-${index}`;
desiredTarget.set(panelXs[index], 0.48, 0);
desiredRadius = innerWidth / innerHeight < 0.8 ? 9 : 6.8;
desiredAzimuth = 0;
desiredPolar = 0.93;
setActiveButton(stageButtons[index]);
}
overviewButton.addEventListener("click", showOverview);
stageButtons.forEach((button) => {
button.addEventListener("click", () => {
showStage(Number(button.dataset.stage));
});
});
addEventListener("keydown", (event) => {
if (event.key === "0" || event.key.toLowerCase() === "o") {
showOverview();
} else if (["1", "2", "3"].includes(event.key)) {
showStage(Number(event.key) - 1);
}
});
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
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;
desiredAzimuth -= dx * 0.006;
desiredPolar = THREE.MathUtils.clamp(
desiredPolar + dy * 0.005,
0.52,
1.22
);
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();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
5.5,
42
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", showOverview);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
// ------------------------------------------------------------
// Projected HTML labels
// ------------------------------------------------------------
const labels = [
{
element: document.getElementById("label-0"),
anchor: new THREE.Vector3(-5.2, 1.72, -1.25)
},
{
element: document.getElementById("label-1"),
anchor: new THREE.Vector3(0, 1.72, -1.25)
},
{
element: document.getElementById("label-2"),
anchor: new THREE.Vector3(5.2, 1.72, -1.25)
}
];
function updateLabels() {
labels.forEach(({ element, anchor }) => {
const projected = anchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "flex" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
});
}
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
if (currentMode === "overview") {
desiredRadius = fitRadius();
}
}
addEventListener("resize", onResize);
desiredRadius = fitRadius();
currentRadius = desiredRadius;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-delta * 6);
currentTarget.lerp(desiredTarget, smoothing);
currentAzimuth = THREE.MathUtils.lerp(
currentAzimuth,
desiredAzimuth,
smoothing
);
currentPolar = THREE.MathUtils.lerp(
currentPolar,
desiredPolar,
smoothing
);
currentRadius = THREE.MathUtils.lerp(
currentRadius,
desiredRadius,
smoothing
);
const horizontal = currentRadius * Math.sin(currentPolar);
camera.position.set(
currentTarget.x + horizontal * Math.sin(currentAzimuth),
currentTarget.y + currentRadius * Math.cos(currentPolar),
currentTarget.z + horizontal * Math.cos(currentAzimuth)
);
camera.lookAt(currentTarget);
camera.updateMatrixWorld();
updateLabels();
renderer.render(scene, camera);
}
document.getElementById("loading").remove();
animate();
</script>
</body>
</html>
```