Prompt specification
Build or customize the Three.js 3D scene "Indoor Climbing Route Planning Diorama" 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: Indoor Climbing Route Planning Diorama
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/indoor-climbing-route-planning-diorama-x3611
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: indoor climbing route planning diorama. Build a fictional climbing wall with clearly marked holds and a schematic avatar. Focus on geometric sequencing, with no claim that the route is safe or physically feasible.
Working Three.js Starter (indoor-climbing-route-planning-diorama-x3611):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Route Lab</title>
<style>
:root {
--ink: #15282b;
--paper: rgba(250, 249, 240, 0.92);
--orange: #ff8a24;
--cyan: #28c7b1;
--line: rgba(21, 40, 43, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7ebe1;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
cursor: pointer;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-block {
position: absolute;
top: 24px;
left: 26px;
max-width: 430px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.eyebrow {
margin-bottom: 7px;
font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.16em;
text-transform: uppercase;
color: #466064;
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 54px);
line-height: 0.94;
letter-spacing: -0.055em;
}
.subtitle {
margin: 11px 0 0;
max-width: 370px;
font-size: 14px;
line-height: 1.45;
color: #40585c;
}
.warning {
position: absolute;
top: 24px;
right: 24px;
width: min(330px, calc(100vw - 48px));
padding: 12px 14px;
border: 1px solid rgba(175, 86, 24, 0.35);
border-left: 5px solid var(--orange);
border-radius: 10px;
background: rgba(255, 249, 234, 0.94);
box-shadow: 0 10px 30px rgba(31, 45, 42, 0.12);
font-size: 12px;
line-height: 1.42;
}
.warning strong {
display: block;
margin-bottom: 3px;
font: 800 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #9d4d11;
}
.route-panel,
.legend {
pointer-events: auto;
border: 1px solid rgba(255, 255, 255, 0.68);
background: var(--paper);
box-shadow:
0 18px 50px rgba(34, 50, 46, 0.16),
inset 0 0 0 1px rgba(21, 40, 43, 0.06);
backdrop-filter: blur(12px);
}
.route-panel {
position: absolute;
left: 22px;
bottom: 22px;
width: 354px;
padding: 17px;
border-radius: 16px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 13px;
}
.panel-heading h2 {
margin: 0;
font-size: 17px;
letter-spacing: -0.025em;
}
.live-dot {
display: inline-flex;
align-items: center;
gap: 7px;
color: #4f686b;
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.live-dot::before {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--orange);
content: "";
box-shadow: 0 0 0 3px rgba(255, 138, 36, 0.15);
}
.presets {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-bottom: 12px;
}
.preset,
.utility {
min-height: 35px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.64);
color: var(--ink);
font-size: 12px;
font-weight: 750;
transition:
background 120ms ease,
border-color 120ms ease,
transform 120ms ease;
}
.preset:hover,
.utility:hover {
border-color: rgba(255, 138, 36, 0.6);
background: #fff;
}
.preset:active,
.utility:active {
transform: translateY(1px);
}
.preset.active {
border-color: var(--orange);
background: rgba(255, 138, 36, 0.12);
color: #8f420c;
}
.sequence {
display: flex;
min-height: 86px;
max-height: 145px;
overflow-y: auto;
align-content: flex-start;
flex-wrap: wrap;
gap: 7px;
padding: 11px;
border: 1px dashed rgba(21, 40, 43, 0.23);
border-radius: 12px;
background:
linear-gradient(rgba(255, 255, 255, 0.6),
rgba(255, 255, 255, 0.6)),
repeating-linear-gradient(
0deg,
transparent,
transparent 15px,
rgba(21, 40, 43, 0.035) 16px
);
}
.sequence-empty {
width: 100%;
padding: 20px 10px;
color: #64787b;
text-align: center;
font-size: 12px;
line-height: 1.45;
}
.chip {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 30px;
padding: 0 9px;
border: 0;
border-radius: 8px;
background: var(--orange);
color: #fff;
box-shadow: 0 3px 8px rgba(125, 64, 18, 0.16);
font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chip-index {
opacity: 0.72;
font-size: 9px;
}
.chip-remove {
opacity: 0.72;
font-size: 14px;
}
.chip:hover .chip-remove {
opacity: 1;
}
.utility-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 10px;
}
.utility {
background: rgba(21, 40, 43, 0.055);
}
.utility.danger:hover {
border-color: rgba(180, 57, 45, 0.55);
color: #9e3027;
}
.options {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 11px;
color: #52696c;
font-size: 11px;
}
.options label {
display: inline-flex;
align-items: center;
gap: 7px;
cursor: pointer;
}
.options input {
accent-color: var(--orange);
}
.stats {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
margin-top: 12px;
}
.stat {
padding: 9px 10px;
border-radius: 9px;
background: rgba(21, 40, 43, 0.055);
}
.stat span {
display: block;
margin-bottom: 3px;
color: #688083;
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.stat strong {
font-size: 16px;
}
.disclaimer {
margin: 12px 0 0;
padding-top: 11px;
border-top: 1px solid var(--line);
color: #65797b;
font-size: 10.5px;
line-height: 1.45;
}
.legend {
position: absolute;
right: 24px;
bottom: 24px;
width: 214px;
padding: 15px;
border-radius: 14px;
}
.legend h2 {
margin: 0 0 10px;
font-size: 13px;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
color: #52686b;
font-size: 11px;
}
.swatch {
width: 17px;
height: 11px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--orange);
box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.13);
}
.swatch.route {
height: 0;
border-top: 3px dashed var(--orange);
border-radius: 0;
background: transparent;
box-shadow: none;
}
.swatch.avatar {
width: 10px;
height: 10px;
margin: 0 4px;
border-radius: 2px;
background: #1e4650;
box-shadow: 5px 6px 0 -2px #28c7b1;
}
.camera-help {
position: absolute;
right: 24px;
bottom: 210px;
padding: 8px 11px;
border-radius: 9px;
background: rgba(250, 249, 240, 0.72);
color: #62777a;
font: 700 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
text-align: right;
}
#tooltip {
position: fixed;
z-index: 20;
display: none;
pointer-events: none;
padding: 6px 9px;
border-radius: 7px;
background: var(--ink);
color: #fff;
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.18);
}
#status {
position: absolute;
left: 50%;
bottom: 24px;
transform: translateX(-50%);
max-width: calc(100vw - 760px);
padding: 9px 13px;
border-radius: 999px;
background: rgba(21, 40, 43, 0.84);
color: #fff;
font-size: 11px;
text-align: center;
opacity: 0;
transition: opacity 160ms ease;
}
#status.visible {
opacity: 1;
}
@media (max-width: 900px) {
.legend,
.camera-help {
display: none;
}
.route-panel {
width: min(340px, calc(100vw - 32px));
left: 16px;
bottom: 16px;
}
.title-block {
top: 18px;
left: 18px;
}
.warning {
top: auto;
right: 16px;
bottom: 16px;
width: min(300px, calc(100vw - 380px));
}
#status {
display: none;
}
}
@media (max-width: 650px) {
.subtitle {
max-width: 240px;
}
.warning {
top: 135px;
right: 16px;
bottom: auto;
width: 250px;
}
.route-panel {
max-height: 54vh;
overflow-y: auto;
}
.sequence {
min-height: 70px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div class="hud">
<header class="title-block">
<div class="eyebrow">Indoor climbing wall / plan 07</div>
<h1>Voxel Route Lab</h1>
<p class="subtitle">
Select marked holds to sketch an abstract geometric sequence through
the fictional wall.
</p>
</header>
<aside class="warning">
<strong>Abstract planner — not a safety plan</strong>
Links are geometric annotations only. This scene makes no assessment of
safety, difficulty, hold quality, reachability, or physical feasibility.
</aside>
<section class="route-panel" aria-label="Route sequence planner">
<div class="panel-heading">
<h2>Sequence board</h2>
<span class="live-dot">Editable</span>
</div>
<div class="presets">
<button class="preset" data-preset="a">Diagonal A</button>
<button class="preset" data-preset="b">Offset B</button>
<button class="preset" data-preset="c">High C</button>
</div>
<div id="sequence" class="sequence" aria-live="polite"></div>
<div class="utility-row">
<button id="undo" class="utility">Undo last</button>
<button id="clear" class="utility danger">Clear sequence</button>
</div>
<div class="options">
<label>
<input id="labelsToggle" type="checkbox" checked>
Show hold labels
</label>
<span>Click a hold to add or remove it</span>
</div>
<div class="stats">
<div class="stat">
<span>Diagram links</span>
<strong id="segmentCount">0</strong>
</div>
<div class="stat">
<span>Abstract span</span>
<strong id="diagramSpan">0.0 u</strong>
</div>
</div>
<p class="disclaimer">
The dashed connection is a visual ordering device, not an instruction
for movement. The avatar is schematic and does not represent a person
executing the sequence.
</p>
</section>
<aside class="legend" aria-label="Scene legend">
<h2>Scene key</h2>
<div class="legend-row">
<span class="swatch"></span>
Selected hold
</div>
<div class="legend-row">
<span class="swatch route"></span>
Abstract geometric link
</div>
<div class="legend-row">
<span class="swatch avatar"></span>
Schematic avatar
</div>
<div class="legend-row">
<span class="swatch" style="background:#55b8d8"></span>
Alternative hold families
</div>
</aside>
<div class="camera-help">
DRAG TO ORBIT<br>
SCROLL TO ZOOM · CLICK HOLDS TO EDIT
</div>
<div id="status" role="status"></div>
</div>
<div id="tooltip"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, camera, and lighting
// ---------------------------------------------------------------------
const viewport = document.querySelector("#viewport");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7ebe1);
scene.fog = new THREE.Fog(0xe7ebe1, 38, 68);
const camera = new THREE.PerspectiveCamera(
34,
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.08;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel climbing-wall route planner"
);
viewport.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0xf6f1db, 0x65807b, 2.2));
const sun = new THREE.DirectionalLight(0xfff0d2, 4.1);
sun.position.set(9, 19, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 23;
sun.shadow.camera.bottom = -5;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ed9df, 1.25);
fill.position.set(-12, 9, 10);
scene.add(fill);
const standardMaterial = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
...extra
});
function addBox(
size,
position,
material,
parent = scene,
rotation = [0, 0, 0]
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Voxel room and climbing-wall structure
// ---------------------------------------------------------------------
const darkStructure = standardMaterial(0x29464a);
const frameMaterial = standardMaterial(0x18383e, { metalness: 0.32 });
const paleWall = standardMaterial(0xe7dfc8);
const orangeMaterial = standardMaterial(0xe97e32);
const cyanMaterial = standardMaterial(0x28bda8);
const creamMaterial = standardMaterial(0xf2ead5);
const charcoalMaterial = standardMaterial(0x263b3d);
// Raised floor base.
addBox(
[28, 0.55, 18],
[0, -0.34, 4.5],
standardMaterial(0xb8c1b5)
);
// Modular floor tiles.
const floorMaterials = [
standardMaterial(0xd8d8c7),
standardMaterial(0xcfd2c3),
standardMaterial(0xe1ddc9)
];
for (let column = 0; column < 14; column++) {
for (let row = 0; row < 8; row++) {
addBox(
[1.94, 0.11, 1.94],
[-13 + column * 2, -0.015, -2.5 + row * 2],
floorMaterials[(column + row) % floorMaterials.length]
);
}
}
// Room shell: left wall, back wall, and sparse structural columns.
addBox(
[0.55, 10, 18],
[-13.65, 4.9, 4.5],
standardMaterial(0xd7ddcf)
);
addBox(
[20.5, 16, 0.45],
[0, 7.7, -0.5],
standardMaterial(0xc9d0c3)
);
for (const x of [-12.7, 12.7]) {
addBox(
[0.55, 12.5, 0.7],
[x, 6.1, -0.2],
frameMaterial
);
}
// Main climbing panel.
addBox(
[18.8, 15, 0.5],
[0, 7.65, 0.02],
standardMaterial(0xa8b9ae)
);
const tileMaterials = [
standardMaterial(0xd7c7a8),
standardMaterial(0xc9b897),
standardMaterial(0xe0d2b4),
standardMaterial(0xb9c7b4),
standardMaterial(0xcbb99c)
];
// A grid of chunky wall voxels.
for (let column = 0; column < 6; column++) {
for (let row = 0; row < 5; row++) {
const index = (column * 2 + row) % tileMaterials.length;
addBox(
[2.93, 2.67, 0.36],
[-7.5 + column * 3, 2.4 + row * 2.75, 0.43],
tileMaterials[index]
);
}
}
// Dark perimeter frame.
addBox([0.38, 15.6, 0.88], [-9.5, 7.7, 0.25], frameMaterial);
addBox([0.38, 15.6, 0.88], [9.5, 7.7, 0.25], frameMaterial);
addBox([19.35, 0.38, 0.88], [0, 0.22, 0.25], frameMaterial);
addBox([19.35, 0.38, 0.88], [0, 15.2, 0.25], frameMaterial);
// Start mat, finish ledge, bench, and utility blocks.
addBox(
[3.1, 0.14, 3.0],
[-7.45, 0.11, 2.1],
cyanMaterial
);
addBox(
[2.6, 0.18, 1.05],
[5.7, 15.42, 1.15],
orangeMaterial
);
addBox(
[3.3, 0.32, 1.15],
[-10.35, 0.85, 6.15],
paleWall
);
for (const x of [-11.5, -9.2]) {
addBox(
[0.28, 0.7, 0.9],
[x, 0.36, 6.15],
frameMaterial
);
}
addBox(
[1.4, 1.1, 1.4],
[10.8, 0.58, 5.5],
standardMaterial(0xd0ad76)
);
addBox(
[1.15, 0.75, 1.15],
[10.8, 1.5, 5.5],
standardMaterial(0x7ca8a4)
);
// ---------------------------------------------------------------------
// Canvas-based scene labels
// ---------------------------------------------------------------------
function roundedRect(context, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
context.beginPath();
context.moveTo(x + r, y);
context.arcTo(x + width, y, x + width, y + height, r);
context.arcTo(x + width, y + height, x, y + height, r);
context.arcTo(x, y + height, x, y, r);
context.arcTo(x, y, x + width, y, r);
context.closePath();
}
function makeHoldLabel() {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 96;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(1.28, 0.48, 1);
sprite.renderOrder = 20;
sprite.userData.canvas = canvas;
sprite.userData.texture = texture;
return sprite;
}
function drawHoldLabel(sprite, text, selected) {
const canvas = sprite.userData.canvas;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(
context,
4,
8,
248,
78,
18
);
context.fillStyle = selected ? "#ff8a24" : "rgba(20, 40, 43, 0.90)";
context.fill();
context.lineWidth = selected ? 5 : 2;
context.strokeStyle = selected ? "#ffe0bd" : "rgba(255,255,255,0.35)";
context.stroke();
context.fillStyle = "#ffffff";
context.font = "800 38px ui-monospace, SFMono-Regular, Menlo, monospace";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 128, 47);
sprite.userData.texture.needsUpdate = true;
}
function makeSign(text, subtitle, width = 4.8) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
roundedRect(context, 8, 8, 1008, 240, 28);
context.fillStyle = "rgba(20, 40, 43, 0.92)";
context.fill();
context.lineWidth = 8;
context.strokeStyle = "rgba(255,255,255,0.24)";
context.stroke();
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = "#ffffff";
context.font = "800 74px ui-monospace, SFMono-Regular, Menlo, monospace";
context.fillText(text, 512, 103);
context.fillStyle = "#ffb46c";
context.font = "700 30px ui-monospace, SFMono-Regular, Menlo, monospace";
context.fillText(subtitle, 512, 174);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 15;
return sprite;
}
const wallSign = makeSign(
"PLAN 07",
"ABSTRACT GEOMETRIC ROUTE BOARD",
5.4
);
wallSign.position.set(-0.2, 15.85, 1.0);
scene.add(wallSign);
// ---------------------------------------------------------------------
// Marked climbing holds
// ---------------------------------------------------------------------
const holdDefinitions = [
{ id: "S1", x: -7.4, y: 2.5, family: "start", w: 1.00, h: 0.34, rot: -0.10 },
{ id: "A1", x: -6.2, y: 3.9, family: "A", w: 0.82, h: 0.38, rot: 0.16 },
{ id: "A2", x: -4.7, y: 5.5, family: "A", w: 0.72, h: 0.48, rot: -0.18 },
{ id: "A3", x: -3.0, y: 7.2, family: "A", w: 0.94, h: 0.32, rot: 0.08 },
{ id: "A4", x: -1.4, y: 9.0, family: "A", w: 0.74, h: 0.45, rot: -0.22 },
{ id: "B1", x: 0.5, y: 4.2, family: "B", w: 0.90, h: 0.34, rot: 0.12 },
{ id: "B2", x: 2.0, y: 6.0, family: "B", w: 0.68, h: 0.50, rot: -0.10 },
{ id: "B3", x: 3.6, y: 7.8, family: "B", w: 0.92, h: 0.33, rot: 0.18 },
{ id: "B4", x: 5.0, y: 9.6, family: "B", w: 0.75, h: 0.42, rot: -0.12 },
{ id: "C1", x: -7.1, y: 7.0, family: "C", w: 0.76, h: 0.43, rot: 0.19 },
{ id: "C2", x: -5.5, y: 8.8, family: "C", w: 0.95, h: 0.31, rot: -0.08 },
{ id: "C3", x: -3.9, y: 10.6, family: "C", w: 0.71, h: 0.47, rot: 0.16 },
{ id: "C4", x: -2.3, y: 12.5, family: "C", w: 0.90, h: 0.35, rot: -0.14 },
{ id: "D1", x: 1.0, y: 11.4, family: "D", w: 0.73, h: 0.46, rot: 0.09 },
{ id: "D2", x: 2.8, y: 13.2, family: "D", w: 0.91, h: 0.33, rot: -0.17 },
{ id: "D3", x: 4.6, y: 14.4, family: "D", w: 0.76, h: 0.42, rot: 0.13 },
{ id: "E1", x: 7.4, y: 3.4, family: "E", w: 0.96, h: 0.32, rot: -0.11 },
{ id: "E2", x: 7.8, y: 5.5, family: "E", w: 0.70, h: 0.49, rot: 0.17 },
{ id: "E3", x: 8.1, y: 7.6, family: "E", w: 0.88, h: 0.34, rot: -0.09 },
{ id: "E4", x: 8.0, y: 9.8, family: "E", w: 0.72, h: 0.44, rot: 0.16 },
{ id: "T1", x: 5.7, y: 13.8, family: "T", w: 1.00, h: 0.36, rot: -0.10 },
{ id: "T2", x: -0.3, y: 14.7, family: "T", w: 0.92, h: 0.36, rot: 0.12 }
];
const familyColors = {
start: 0x25c7a5,
A: 0x55b8d8,
B: 0xf58f6c,
C: 0x9d8bd8,
D: 0xe8b84b,
E: 0x7ebd76,
T: 0xef6b62
};
const holds = [];
const holdMeshes = [];
for (const definition of holdDefinitions) {
const group = new THREE.Group();
group.position.set(definition.x, definition.y, 0.86);
group.rotation.z = definition.rot;
scene.add(group);
const color = familyColors[definition.family];
const bodyMaterial = standardMaterial(color, {
roughness: 0.68,
emissive: 0x000000,
emissiveIntensity: 0
});
const body = addBox(
[definition.w, definition.h, 0.42],
[0, 0, 0],
bodyMaterial,
group
);
body.userData.holdId = definition.id;
holdMeshes.push(body);
// A contrasting inset makes each geometric hold easy to identify.
addBox(
[definition.w * 0.54, 0.07, 0.035],
[0, 0, 0.23],
standardMaterial(0xf8f1da),
group
);
const label = makeHoldLabel();
label.position.set(definition.x, definition.y + 0.72, 1.28);
drawHoldLabel(label, definition.id, false);
scene.add(label);
holds.push({
...definition,
group,
body,
bodyMaterial,
label,
baseColor: color
});
}
const holdById = new Map(holds.map((hold) => [hold.id, hold]));
// ---------------------------------------------------------------------
// Schematic voxel avatar
// ---------------------------------------------------------------------
const avatar = new THREE.Group();
avatar.position.set(-10.45, 0.17, 1.35);
scene.add(avatar);
const avatarDark = standardMaterial(0x1e3e47);
const avatarCyan = standardMaterial(0x39d5c1);
addBox([0.65, 0.95, 0.42], [0, 1.75, 0], avatarDark, avatar);
addBox([0.58, 0.58, 0.52], [0, 2.76, 0], avatarDark, avatar);
addBox([0.28, 0.11, 0.03], [0, 2.8, 0.28], avatarCyan, avatar);
addBox(
[0.22, 0.9, 0.22],
[-0.2, 0.82, 0],
avatarDark,
avatar,
[0, 0, -0.08]
);
addBox(
[0.22, 0.9, 0.22],
[0.2, 0.82, 0],
avatarDark,
avatar,
[0, 0, 0.08]
);
addBox(
[0.21, 0.82, 0.21],
[-0.47, 1.82, 0],
avatarDark,
avatar,
[0, 0, -0.23]
);
addBox(
[0.21, 0.82, 0.21],
[0.47, 1.82, 0],
avatarDark,
avatar,
[0, 0, 0.23]
);
addBox([0.33, 0.16, 0.48], [-0.24, 0.23, 0.08], avatarCyan, avatar);
addBox([0.33, 0.16, 0.48], [0.24, 0.23, 0.08], avatarCyan, avatar);
const avatarSign = makeSign(
"AVATAR",
"SCHEMATIC / NON-EXECUTING",
2.9
);
avatarSign.position.set(-10.45, 3.95, 1.45);
scene.add(avatarSign);
// ---------------------------------------------------------------------
// Route state and UI
// ---------------------------------------------------------------------
const presets = {
a: ["S1", "A1", "A2", "A3", "A4", "D1", "D2"],
b: ["S1", "B1", "B2", "B3", "B4", "D3", "T1"],
c: ["S1", "C1", "C2", "C3", "C4", "D2", "T2"]
};
let sequence = [];
const routeGroup = new THREE.Group();
scene.add(routeGroup);
const sequenceElement = document.querySelector("#sequence");
const segmentCountElement = document.querySelector("#segmentCount");
const diagramSpanElement = document.querySelector("#diagramSpan");
const tooltip = document.querySelector("#tooltip");
const statusElement = document.querySelector("#status");
let statusTimer;
function showStatus(message) {
statusElement.textContent = message;
statusElement.classList.add("visible");
clearTimeout(statusTimer);
statusTimer = setTimeout(() => {
statusElement.classList.remove("visible");
}, 1500);
}
function disposeRouteGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
if (Array.isArray(object.material)) {
object.material.forEach((material) => material.dispose());
} else {
object.material.dispose();
}
}
});
}
}
function updateRouteGraphic() {
disposeRouteGroup(routeGroup);
if (sequence.length < 2) return;
const points = sequence.map((id) => {
const hold = holdById.get(id);
return new THREE.Vector3(
hold.x,
hold.y,
1.19
);
});
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const underlay = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color: 0x7a3c12,
transparent: true,
opacity: 0.35,
depthTest: false,
depthWrite: false
})
);
underlay.renderOrder = 8;
routeGroup.add(underlay);
const dashed = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color: 0xff8a24,
dashSize: 0.27,
gapSize: 0.16,
transparent: true,
opacity: 0.96,
depthTest: false,
depthWrite: false
})
);
dashed.computeLineDistances();
dashed.renderOrder = 9;
routeGroup.add(dashed);
// Small square checkpoints emphasize the geometric, diagram-like nature.
points.forEach((point, index) => {
const marker = addBox(
[0.15, 0.15, 0.15],
[point.x, point.y, point.z],
standardMaterial(index === 0 ? 0x25c7a5 : 0xff8a24),
routeGroup
);
marker.castShadow = false;
marker.receiveShadow = false;
marker.renderOrder = 10;
});
}
function updateHoldVisuals() {
for (const hold of holds) {
const selectedIndex = sequence.indexOf(hold.id);
const selected = selectedIndex !== -1;
hold.bodyMaterial.color.set(
selected ? 0xff8a24 : hold.baseColor
);
hold.bodyMaterial.emissive.set(
selected ? 0x7a2c00 : 0x000000
);
hold.bodyMaterial.emissiveIntensity = selected ? 0.28 : 0;
hold.group.scale.setScalar(selected ? 1.08 : 1);
const labelText = selected
? `${String(selectedIndex + 1).padStart(2, "0")} · ${hold.id}`
: hold.id;
drawHoldLabel(hold.label, labelText, selected);
}
}
function updateStats() {
let span = 0;
for (let index = 1; index < sequence.length; index++) {
const previous = holdById.get(sequence[index - 1]);
const current = holdById.get(sequence[index]);
span += Math.hypot(current.x - previous.x, current.y - previous.y);
}
segmentCountElement.textContent = String(
Math.max(0, sequence.length - 1)
);
diagramSpanElement.textContent = `${span.toFixed(1)} u`;
}
function updateSequenceUI() {
sequenceElement.replaceChildren();
if (sequence.length === 0) {
const empty = document.createElement("div");
empty.className = "sequence-empty";
empty.textContent =
"No holds selected. Click a labeled hold, or load a preset.";
sequenceElement.appendChild(empty);
} else {
sequence.forEach((id, index) => {
const chip = document.createElement("button");
chip.className = "chip";
chip.type = "button";
chip.title = `Remove ${id} from the sequence`;
const number = document.createElement("span");
number.className = "chip-index";
number.textContent = String(index + 1).padStart(2, "0");
const name = document.createElement("span");
name.textContent = id;
const remove = document.createElement("span");
remove.className = "chip-remove";
remove.textContent = "×";
chip.append(number, name, remove);
chip.addEventListener("click", () => {
sequence = sequence.filter((holdId) => holdId !== id);
refresh();
showStatus(`${id} removed`);
});
sequenceElement.appendChild(chip);
});
}
for (const button of document.querySelectorAll(".preset")) {
const preset = presets[button.dataset.preset];
const active =
preset.length === sequence.length &&
preset.every((id, index) => id === sequence[index]);
button.classList.toggle("active", active);
}
}
function refresh() {
updateHoldVisuals();
updateRouteGraphic();
updateSequenceUI();
updateStats();
}
function toggleHold(id) {
if (sequence.includes(id)) {
sequence = sequence.filter((holdId) => holdId !== id);
showStatus(`${id} removed from the abstract sequence`);
} else {
sequence.push(id);
showStatus(`${id} added at position ${sequence.length}`);
}
refresh();
}
function loadPreset(name) {
sequence = [...presets[name]];
refresh();
showStatus(`Loaded ${name.toUpperCase()} preset`);
}
document.querySelectorAll(".preset").forEach((button) => {
button.addEventListener("click", () => {
loadPreset(button.dataset.preset);
});
});
document.querySelector("#undo").addEventListener("click", () => {
if (sequence.length === 0) {
showStatus("The sequence is already empty");
return;
}
const removed = sequence.pop();
refresh();
showStatus(`Removed ${removed}`);
});
document.querySelector("#clear").addEventListener("click", () => {
sequence = [];
refresh();
showStatus("Abstract sequence cleared");
});
document.querySelector("#labelsToggle").addEventListener("change", (event) => {
for (const hold of holds) {
hold.label.visible = event.target.checked;
}
});
// ---------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and reset
// ---------------------------------------------------------------------
const target = new THREE.Vector3(0, 7.3, 1.0);
const initialCamera = {
radius: 31,
phi: 1.17,
theta: 0.30
};
const cameraState = {
radius: initialCamera.radius,
phi: initialCamera.phi,
theta: initialCamera.theta
};
const cameraGoal = { ...cameraState };
function resetCamera() {
cameraGoal.radius = initialCamera.radius;
cameraGoal.phi = initialCamera.phi;
cameraGoal.theta = initialCamera.theta;
}
function updateCamera() {
cameraState.radius +=
(cameraGoal.radius - cameraState.radius) * 0.12;
cameraState.phi +=
(cameraGoal.phi - cameraState.phi) * 0.12;
cameraState.theta +=
(cameraGoal.theta - cameraState.theta) * 0.12;
const spherical = new THREE.Spherical(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
}
// ---------------------------------------------------------------------
// Hold picking and pointer interaction
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let pointerIsDown = false;
let pointerMoved = false;
let previousPointerX = 0;
let previousPointerY = 0;
let downPointerX = 0;
let downPointerY = 0;
function setPointerFromEvent(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickHold(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(
holdMeshes,
false
);
return intersections.length
? intersections[0].object.userData.holdId
: null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
pointerIsDown = true;
pointerMoved = false;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
downPointerX = event.clientX;
downPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
tooltip.style.display = "none";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointerIsDown) {
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
if (
Math.hypot(
event.clientX - downPointerX,
event.clientY - downPointerY
) > 5
) {
pointerMoved = true;
}
cameraGoal.theta -= deltaX * 0.006;
cameraGoal.phi = THREE.MathUtils.clamp(
cameraGoal.phi - deltaY * 0.006,
0.52,
1.46
);
previousPointerX = event.clientX;
previousPointerY = event.clientY;
return;
}
const holdId = pickHold(event);
if (holdId) {
tooltip.textContent =
`${holdId} — click to ${sequence.includes(holdId) ? "remove" : "add"}`;
tooltip.style.display = "block";
tooltip.style.left = `${event.clientX + 14}px`;
tooltip.style.top = `${event.clientY + 14}px`;
renderer.domElement.style.cursor = "pointer";
} else {
tooltip.style.display = "none";
renderer.domElement.style.cursor = "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!pointerIsDown) return;
pointerIsDown = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (!pointerMoved) {
const holdId = pickHold(event);
if (holdId) toggleHold(holdId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerIsDown = false;
pointerMoved = false;
});
renderer.domElement.addEventListener("pointerleave", () => {
tooltip.style.display = "none";
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius * Math.exp(event.deltaY * 0.001),
16,
44
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "Home") {
resetCamera();
}
if (event.key === "1") loadPreset("a");
if (event.key === "2") loadPreset("b");
if (event.key === "3") loadPreset("c");
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// ---------------------------------------------------------------------
// Start with a small example sequence and render loop
// ---------------------------------------------------------------------
sequence = [...presets.a];
refresh();
updateCamera();
renderer.setAnimationLoop(() => {
updateCamera();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```