Prompt specification
Build or customize the Three.js 3D scene "Handhold Grid and Reach Envelope" 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: Handhold Grid and Reach Envelope
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/handhold-grid-and-reach-envelope-x3609
Scene Description Prompt:
Create a standalone stylized scene in one HTML file using Three.js from cdnjs. Model a small artificial hold board with a schematic arm reach arc. Label the dimensions illustrative and avoid suggesting real climbing safety or training guidance.
Working Three.js Starter (handhold-grid-and-reach-envelope-x3609):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Arc / Artificial Hold Board</title>
<style>
:root {
color-scheme: light;
--ink: #24333a;
--muted: #627078;
--paper: rgba(255, 255, 255, 0.78);
--line: rgba(36, 51, 58, 0.14);
--teal: #2f8f83;
--coral: #ef6c61;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 72% 18%, rgba(255, 255, 255, 0.95), transparent 34%),
radial-gradient(circle at 20% 85%, rgba(213, 229, 225, 0.72), transparent 38%),
linear-gradient(145deg, #ece9e2 0%, #dfe5e2 100%);
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
canvas:active {
cursor: grabbing;
}
.overlay {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: clamp(22px, 4vw, 48px);
left: clamp(22px, 4vw, 52px);
max-width: 370px;
}
.brand__eyebrow,
.specs__eyebrow {
margin-bottom: 10px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
color: var(--teal);
}
.brand h1 {
margin: 0;
font-size: clamp(31px, 4.3vw, 64px);
font-weight: 760;
line-height: 0.94;
letter-spacing: -0.055em;
}
.brand p {
margin: 16px 0 0;
max-width: 330px;
font-size: 13px;
line-height: 1.55;
color: var(--muted);
}
.specs {
position: absolute;
top: clamp(22px, 4vw, 48px);
right: clamp(22px, 4vw, 52px);
width: 245px;
padding: 18px 19px 16px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(46, 61, 67, 0.1);
backdrop-filter: blur(14px);
}
.specs__row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 18px;
padding: 10px 0;
border-top: 1px solid var(--line);
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: var(--muted);
}
.specs__row strong {
color: var(--ink);
font-size: 12px;
letter-spacing: 0.035em;
white-space: nowrap;
}
.specs__note {
margin: 5px 0 0;
font-size: 10px;
line-height: 1.5;
color: var(--muted);
}
.legend {
position: absolute;
left: clamp(22px, 4vw, 52px);
bottom: clamp(24px, 4vw, 46px);
display: flex;
align-items: center;
gap: 10px;
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 255, 255, 0.66);
backdrop-filter: blur(10px);
font-size: 11px;
color: var(--muted);
}
.legend__swatch {
width: 24px;
height: 3px;
border-radius: 3px;
background: var(--teal);
}
.controls {
position: absolute;
right: clamp(22px, 4vw, 52px);
bottom: clamp(24px, 4vw, 46px);
font-size: 11px;
letter-spacing: 0.03em;
color: var(--muted);
text-align: right;
}
.disclaimer {
position: absolute;
left: 50%;
bottom: clamp(24px, 4vw, 46px);
width: min(430px, calc(100vw - 44px));
padding: 12px 17px;
transform: translateX(-50%);
border: 1px solid rgba(239, 108, 97, 0.26);
border-radius: 14px;
background: rgba(255, 248, 245, 0.84);
box-shadow: 0 12px 32px rgba(64, 51, 46, 0.07);
backdrop-filter: blur(12px);
color: #765a55;
font-size: 11px;
line-height: 1.5;
text-align: center;
}
@media (max-width: 760px) {
.brand p,
.legend,
.controls {
display: none;
}
.brand {
max-width: 230px;
}
.brand h1 {
font-size: 36px;
}
.specs {
top: auto;
right: 18px;
bottom: 88px;
width: 205px;
padding: 13px 15px;
}
.specs__row {
padding: 7px 0;
}
.disclaimer {
bottom: 18px;
}
}
</style>
</head>
<body>
<div class="overlay">
<header class="brand">
<div class="brand__eyebrow">Arc / Study 04</div>
<h1>Artificial<br />Hold Board</h1>
<p>
A stylized object study with an illustrative reach-envelope graphic
and schematic board dimensions.
</p>
</header>
<aside class="specs" aria-label="Illustrative dimensions">
<div class="specs__eyebrow">Illustrative dimensions</div>
<div class="specs__row">
<span>Board</span>
<strong>4.4 × 3.2 u</strong>
</div>
<div class="specs__row">
<span>Reach arc</span>
<strong>r ≈ 1.35 u</strong>
</div>
<div class="specs__row">
<span>Units</span>
<strong>Scene units</strong>
</div>
<p class="specs__note">
Proportions and measurements are diagrammatic, not scaled to a real product.
</p>
</aside>
<div class="legend">
<span class="legend__swatch"></span>
Schematic reach envelope
</div>
<div class="controls">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<div class="disclaimer">
Concept visualization only. This is not climbing safety, training, product,
or instructional guidance.
</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.Fog(0xe8e5de, 14, 28);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive stylized artificial climbing hold board"
);
document.body.prepend(renderer.domElement);
const target = new THREE.Vector3(0, 2.05, 0);
const spherical = new THREE.Spherical(9.2, 1.24, 0.37);
const initialSpherical = spherical.clone();
function updateCamera() {
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight(0xfff8ed, 0x53636c, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff2dd, 3.4);
keyLight.position.set(5.5, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -4;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 24;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x9dc7d0, 1.5);
rimLight.position.set(-6, 4, -3);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffc9a8, 18, 11, 2);
warmLight.position.set(-4.5, 3.4, 4.5);
scene.add(warmLight);
// Environment
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xe4e1d8,
roughness: 0.95,
metalness: 0
});
const floor = new THREE.Mesh(new THREE.PlaneGeometry(30, 30), floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const wall = new THREE.Mesh(
new THREE.PlaneGeometry(20, 11),
new THREE.MeshStandardMaterial({
color: 0xefebe3,
roughness: 1
})
);
wall.position.set(0, 4.5, -1.8);
wall.receiveShadow = true;
scene.add(wall);
const grid = new THREE.GridHelper(18, 18, 0x74858a, 0x74858a);
grid.position.y = 0.012;
grid.material.transparent = true;
grid.material.opacity = 0.09;
scene.add(grid);
const floorDisc = new THREE.Mesh(
new THREE.CircleGeometry(5.15, 96),
new THREE.MeshStandardMaterial({
color: 0xd8dfdc,
roughness: 0.92,
transparent: true,
opacity: 0.62
})
);
floorDisc.rotation.x = -Math.PI / 2;
floorDisc.position.y = 0.018;
floorDisc.receiveShadow = true;
scene.add(floorDisc);
// Board
const board = new THREE.Group();
scene.add(board);
const panelMaterial = new THREE.MeshStandardMaterial({
color: 0xd8d5cd,
roughness: 0.86,
metalness: 0.02
});
const panel = new THREE.Mesh(
new THREE.BoxGeometry(4.4, 3.2, 0.18),
panelMaterial
);
panel.position.set(0, 2.2, 0);
panel.castShadow = true;
panel.receiveShadow = true;
board.add(panel);
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x40515a,
roughness: 0.5,
metalness: 0.22
});
function addFramePart(width, height, depth, x, y, z = 0) {
const part = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
frameMaterial
);
part.position.set(x, y, z);
part.castShadow = true;
part.receiveShadow = true;
board.add(part);
return part;
}
addFramePart(0.18, 3.5, 0.3, -2.29, 2.2);
addFramePart(0.18, 3.5, 0.3, 2.29, 2.2);
addFramePart(4.76, 0.18, 0.3, 0, 3.89);
addFramePart(4.76, 0.18, 0.3, 0, 0.51);
// Rear supports and feet
const supportMaterial = new THREE.MeshStandardMaterial({
color: 0x607079,
roughness: 0.55,
metalness: 0.18
});
[-1.65, 1.65].forEach((x) => {
const support = new THREE.Mesh(
new THREE.BoxGeometry(0.16, 1.05, 0.18),
supportMaterial
);
support.position.set(x, 0.49, -0.48);
support.rotation.x = -0.13;
support.castShadow = true;
board.add(support);
const foot = new THREE.Mesh(
new THREE.BoxGeometry(0.78, 0.12, 1.35),
frameMaterial
);
foot.position.set(x, 0.08, -0.22);
foot.castShadow = true;
foot.receiveShadow = true;
board.add(foot);
const footPad = new THREE.Mesh(
new THREE.BoxGeometry(0.66, 0.035, 1.12),
new THREE.MeshStandardMaterial({
color: 0x27373e,
roughness: 0.95
})
);
footPad.position.set(x, 0.158, -0.22);
footPad.castShadow = true;
board.add(footPad);
});
// Subtle printed grid on the board face
const printedGridMaterial = new THREE.LineBasicMaterial({
color: 0x6d7b7e,
transparent: true,
opacity: 0.095,
depthWrite: false
});
const printedGridPoints = [];
for (let x = -1.6; x <= 1.61; x += 0.8) {
printedGridPoints.push(
new THREE.Vector3(x, 0.63, 0.101),
new THREE.Vector3(x, 3.77, 0.101)
);
}
for (let y = 0.8; y <= 3.61; y += 0.8) {
printedGridPoints.push(
new THREE.Vector3(-2.16, y, 0.101),
new THREE.Vector3(2.16, y, 0.101)
);
}
const printedGrid = new THREE.LineSegments(
new THREE.BufferGeometry().setFromPoints(printedGridPoints),
printedGridMaterial
);
board.add(printedGrid);
// Frame screws
const screwMaterial = new THREE.MeshStandardMaterial({
color: 0xaab1b2,
roughness: 0.3,
metalness: 0.75
});
[
[-2.29, 3.89], [2.29, 3.89], [-2.29, 0.51], [2.29, 0.51],
[-2.29, 2.2], [2.29, 2.2],
[-1.2, 3.89], [1.2, 3.89], [-1.2, 0.51], [1.2, 0.51]
].forEach(([x, y]) => {
const screw = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, 0.025, 16),
screwMaterial
);
screw.rotation.x = Math.PI / 2;
screw.position.set(x, y, 0.158);
board.add(screw);
});
// Artificial climbing holds
const holdGeometry = new THREE.SphereGeometry(1, 18, 12);
const boltGeometry = new THREE.CylinderGeometry(0.033, 0.033, 0.024, 16);
const holdColors = {
coral: 0xef6c61,
mint: 0x58bcae,
yellow: 0xf1be49,
violet: 0x8976d8,
orange: 0xf08a47,
blue: 0x4b91c4
};
function addHold(x, y, color, sx, sy, rotation = 0) {
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.02
});
const hold = new THREE.Mesh(holdGeometry, material);
hold.position.set(x, y, 0.205);
hold.scale.set(sx, sy, 0.095);
hold.rotation.z = rotation;
hold.castShadow = true;
hold.receiveShadow = true;
board.add(hold);
const bolt = new THREE.Mesh(boltGeometry, screwMaterial);
bolt.rotation.x = Math.PI / 2;
bolt.position.set(x, y, 0.302);
board.add(bolt);
}
addHold(-1.55, 3.02, holdColors.violet, 0.27, 0.20, -0.24);
addHold(-0.84, 3.10, holdColors.coral, 0.24, 0.18, 0.30);
addHold(-0.08, 2.92, holdColors.yellow, 0.22, 0.16, -0.12);
addHold(0.53, 3.10, holdColors.mint, 0.20, 0.16, 0.22);
addHold(-1.75, 2.17, holdColors.mint, 0.23, 0.17, 0.15);
addHold(-1.04, 2.18, holdColors.orange, 0.29, 0.19, -0.32);
addHold(-0.34, 2.25, holdColors.violet, 0.21, 0.18, 0.12);
addHold(0.32, 2.05, holdColors.coral, 0.19, 0.15, 0.40);
addHold(-1.72, 1.28, holdColors.yellow, 0.25, 0.18, 0.10);
addHold(-0.97, 1.24, holdColors.mint, 0.23, 0.18, -0.24);
addHold(-0.22, 1.38, holdColors.blue, 0.26, 0.19, 0.21);
addHold(0.50, 1.28, holdColors.orange, 0.22, 0.17, -0.10);
addHold(-1.58, 0.83, holdColors.coral, 0.21, 0.15, -0.18);
addHold(-0.86, 0.82, holdColors.violet, 0.24, 0.17, 0.18);
addHold(-0.14, 0.83, holdColors.yellow, 0.20, 0.15, -0.22);
addHold(0.58, 0.85, holdColors.mint, 0.24, 0.17, 0.30);
// Schematic reach-envelope arc
const pivot = new THREE.Vector3(0.75, 2.25, 0.39);
const reachRadius = 1.35;
const arcPoints = [];
for (let i = 0; i <= 100; i++) {
const angle = -0.08 + (Math.PI * 0.88 * i) / 100;
arcPoints.push(
new THREE.Vector3(
pivot.x + Math.cos(angle) * reachRadius,
pivot.y + Math.sin(angle) * reachRadius,
0.39
)
);
}
const arcMaterial = new THREE.LineDashedMaterial({
color: 0x278e82,
dashSize: 0.11,
gapSize: 0.065,
transparent: true,
opacity: 0.95,
depthTest: false
});
const arc = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(arcPoints),
arcMaterial
);
arc.computeLineDistances();
arc.renderOrder = 10;
board.add(arc);
// Pivot marker
const pivotRing = new THREE.Mesh(
new THREE.TorusGeometry(0.105, 0.024, 10, 36),
new THREE.MeshStandardMaterial({
color: 0xef6c61,
roughness: 0.42,
emissive: 0x38110e,
emissiveIntensity: 0.15
})
);
pivotRing.position.copy(pivot);
pivotRing.renderOrder = 12;
board.add(pivotRing);
const pivotDot = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 16, 12),
new THREE.MeshBasicMaterial({ color: 0xef6c61 })
);
pivotDot.position.copy(pivot);
board.add(pivotDot);
// Abstract two-segment arm/reach marker
const armCurve = new THREE.CatmullRomCurve3([
pivot.clone(),
new THREE.Vector3(1.42, 3.02, 0.43),
new THREE.Vector3(2.02, 2.66, 0.43)
]);
const armMesh = new THREE.Mesh(
new THREE.TubeGeometry(armCurve, 36, 0.027, 8, false),
new THREE.MeshBasicMaterial({
color: 0xef6c61,
transparent: true,
opacity: 0.68,
depthTest: false
})
);
armMesh.renderOrder = 11;
board.add(armMesh);
const elbow = new THREE.Mesh(
new THREE.SphereGeometry(0.064, 16, 12),
new THREE.MeshBasicMaterial({
color: 0xef6c61,
transparent: true,
opacity: 0.82,
depthTest: false
})
);
elbow.position.set(1.42, 3.02, 0.43);
elbow.renderOrder = 12;
board.add(elbow);
const reachEnd = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 18, 14),
new THREE.MeshBasicMaterial({
color: 0xef6c61,
transparent: true,
opacity: 0.9,
depthTest: false
})
);
reachEnd.position.set(2.02, 2.66, 0.43);
reachEnd.renderOrder = 12;
board.add(reachEnd);
// Dimensions
const dimensionMaterial = new THREE.LineBasicMaterial({
color: 0x62777c,
transparent: true,
opacity: 0.72,
depthTest: false
});
function addLine(points) {
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(
points.map((point) => new THREE.Vector3(...point))
),
dimensionMaterial
);
line.renderOrder = 8;
board.add(line);
return line;
}
// Horizontal dimension
addLine([[-2.2, 4.10, 0.28], [2.2, 4.10, 0.28]]);
addLine([[-2.2, 3.97, 0.28], [-2.2, 4.23, 0.28]]);
addLine([[2.2, 3.97, 0.28], [2.2, 4.23, 0.28]]);
addLine([[0, 4.10, 0.28], [0, 4.10, 0.28]]);
// Vertical dimension
addLine([[2.54, 0.60, 0.28], [2.54, 3.80, 0.28]]);
addLine([[2.41, 0.60, 0.28], [2.67, 0.60, 0.28]]);
addLine([[2.41, 3.80, 0.28], [2.67, 3.80, 0.28]]);
// Canvas-backed labels
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function createLabelSprite(title, subtitle, accent = "#2f8f83") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(250, 249, 244, 0.92)";
roundedRectPath(ctx, 8, 8, 1008, 240, 42);
ctx.fill();
ctx.strokeStyle = "rgba(36, 51, 58, 0.16)";
ctx.lineWidth = 4;
ctx.stroke();
ctx.fillStyle = accent;
roundedRectPath(ctx, 35, 43, 16, 170, 8);
ctx.fill();
ctx.fillStyle = "#24333a";
ctx.font = "800 56px system-ui, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText(title, 78, 91);
ctx.fillStyle = "#68767a";
ctx.font = "500 39px system-ui, sans-serif";
ctx.fillText(subtitle, 78, 164);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(2.42, 0.605, 1);
sprite.renderOrder = 20;
return sprite;
}
const spanLabel = createLabelSprite(
"ILLUSTRATIVE SPAN",
"4.4 scene units",
"#2f8f83"
);
spanLabel.position.set(0, 4.28, 0.55);
board.add(spanLabel);
const heightLabel = createLabelSprite(
"ILLUSTRATIVE HEIGHT",
"3.2 scene units",
"#ef6c61"
);
heightLabel.position.set(3.03, 2.24, 0.55);
heightLabel.scale.set(1.86, 0.465, 1);
board.add(heightLabel);
const arcLabel = createLabelSprite(
"REACH ENVELOPE",
"Illustrative arc · not a movement guide",
"#ef6c61"
);
arcLabel.position.set(0.83, 3.73, 0.66);
arcLabel.scale.set(2.18, 0.545, 1);
board.add(arcLabel);
// Small board plaque
function createPlaqueTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 256);
ctx.fillStyle = "#26363d";
roundedRectPath(ctx, 4, 4, 1016, 248, 36);
ctx.fill();
ctx.fillStyle = "#ef6c61";
roundedRectPath(ctx, 40, 46, 14, 164, 7);
ctx.fill();
ctx.fillStyle = "#f7f4eb";
ctx.font = "800 53px system-ui, sans-serif";
ctx.textBaseline = "middle";
ctx.fillText("HOLD / STUDY 04", 82, 91);
ctx.fillStyle = "#aebdc0";
ctx.font = "500 34px system-ui, sans-serif";
ctx.fillText("FORM · COLOR · PROPORTION", 82, 162);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(2.08, 0.52),
new THREE.MeshBasicMaterial({
map: createPlaqueTexture(),
transparent: true,
toneMapped: false
})
);
plaque.position.set(-0.70, 3.48, 0.18);
board.add(plaque);
// Custom orbit and zoom controls implemented without addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
spherical.theta -= dx * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - dy * 0.005,
0.58,
1.82
);
updateCamera();
});
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();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius + event.deltaY * 0.007,
6.2,
13.5
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
spherical.copy(initialSpherical);
updateCamera();
});
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", resize);
// Gentle entrance motion
const startTime = performance.now();
renderer.setAnimationLoop(() => {
const elapsed = (performance.now() - startTime) / 1000;
const intro = Math.min(elapsed / 1.2, 1);
const eased = 1 - Math.pow(1 - intro, 3);
board.position.y = THREE.MathUtils.lerp(-0.12, 0, eased);
board.scale.setScalar(THREE.MathUtils.lerp(0.985, 1, eased));
renderer.render(scene, camera);
});
</script>
</body>
</html>
```