Prompt specification
Build or customize the Three.js 3D scene "Find a route through a constrained karst corridor" 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: Find a route through a constrained karst corridor
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/find-a-route-through-a-constrained-karst-corridor-x3088
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Madagascar's Tsingy limestone karst. Let users trace a schematic visitor path along designated walkways and gaps. Keep fragile vegetation and unsupported rock surfaces excluded, distinguishing the puzzle from real hiking guidance. Low-poly.
Working Three.js Starter (find-a-route-through-a-constrained-karst-corridor-x3088):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tsingy — Schematic Visitor Path</title>
<style>
:root {
--ink: #183431;
--muted: #63736c;
--paper: rgba(250, 248, 238, 0.91);
--line: rgba(31, 63, 56, 0.16);
--teal: #287873;
--teal-light: #8fc2b5;
--gold: #d89524;
--gap: #4f7f91;
--danger: #c95e4d;
--shadow: 0 16px 50px rgba(31, 53, 45, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dfe6dc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
z-index: 5;
pointer-events: none;
}
.hud button,
.hud a {
pointer-events: auto;
}
#intro {
top: 28px;
left: 30px;
max-width: 430px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 11px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 2px;
content: "";
background: var(--gold);
}
h1 {
max-width: 420px;
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(32px, 4.2vw, 60px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.04em;
text-wrap: balance;
}
#intro p {
max-width: 370px;
margin: 15px 0 0;
color: #435a53;
font-size: 14px;
line-height: 1.55;
}
#panel {
top: 24px;
right: 24px;
width: 342px;
padding: 18px;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.68);
border-radius: 20px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
pointer-events: auto;
}
.panel-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.panel-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.schematic-badge {
padding: 6px 8px;
border-radius: 999px;
background: rgba(201, 94, 77, 0.12);
color: #a74739;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.12em;
white-space: nowrap;
}
#panel h2 {
margin: 0 0 6px;
font-family: Georgia, "Times New Roman", serif;
font-size: 24px;
font-weight: 500;
letter-spacing: -0.02em;
}
.panel-copy {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.notice {
margin: 14px 0;
padding: 11px 12px;
border-left: 3px solid var(--danger);
border-radius: 0 9px 9px 0;
background: rgba(201, 94, 77, 0.08);
color: #74483f;
font-size: 11px;
line-height: 1.45;
}
.notice strong {
color: #a74739;
}
.progress-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
font-size: 11px;
}
#next-label {
color: var(--ink);
font-weight: 800;
}
#link-count {
color: var(--muted);
white-space: nowrap;
}
.progress-track {
height: 7px;
overflow: hidden;
border-radius: 99px;
background: rgba(40, 120, 115, 0.12);
}
#progress-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--teal), var(--gold));
transition: width 350ms ease;
}
#route-list {
display: grid;
grid-template-columns: repeat(10, 1fr);
gap: 5px;
margin: 14px 0 10px;
}
.route-point {
display: grid;
width: 100%;
aspect-ratio: 1;
padding: 0;
place-items: center;
border: 1px solid rgba(40, 120, 115, 0.2);
border-radius: 8px;
background: rgba(255, 255, 255, 0.48);
color: #6d7b75;
cursor: pointer;
font-size: 10px;
font-weight: 800;
transition: 160ms ease;
}
.route-point:hover {
transform: translateY(-2px);
border-color: var(--teal);
color: var(--teal);
}
.route-point.current {
border-color: var(--gold);
background: rgba(216, 149, 36, 0.14);
color: #9b6414;
box-shadow: 0 0 0 3px rgba(216, 149, 36, 0.08);
}
.route-point.done {
border-color: var(--teal);
background: var(--teal);
color: white;
}
.panel-actions {
display: flex;
gap: 8px;
}
.panel-actions button {
flex: 1;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.62);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 800;
transition: 150ms ease;
}
.panel-actions button:hover {
border-color: var(--teal);
background: white;
transform: translateY(-1px);
}
#complete-note {
display: none;
margin-top: 12px;
padding: 11px 12px;
border-radius: 10px;
background: rgba(216, 149, 36, 0.14);
color: #865714;
font-size: 12px;
font-weight: 700;
line-height: 1.45;
}
#panel.complete #complete-note {
display: block;
}
#legend {
bottom: 25px;
left: 30px;
display: flex;
flex-wrap: wrap;
gap: 9px 17px;
max-width: 560px;
padding: 11px 14px;
border: 1px solid rgba(255, 255, 255, 0.66);
border-radius: 13px;
background: rgba(250, 248, 238, 0.83);
box-shadow: 0 8px 28px rgba(31, 53, 45, 0.1);
backdrop-filter: blur(12px);
color: #50625b;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
width: 21px;
height: 8px;
border-radius: 3px;
}
.swatch.boardwalk {
background: repeating-linear-gradient(
90deg,
#8a5c39 0 5px,
#5f402b 5px 7px
);
}
.swatch.gap {
background: repeating-linear-gradient(
90deg,
transparent 0 4px,
#4f7f91 4px 6px,
transparent 6px 10px
);
border-bottom: 1px solid #4f7f91;
}
.swatch.trace {
background: var(--gold);
box-shadow: 0 0 0 2px rgba(216, 149, 36, 0.13);
}
.swatch.excluded {
background: repeating-linear-gradient(
-45deg,
#c95e4d 0 3px,
#f4d6ca 3px 7px
);
}
#view-controls {
right: 25px;
bottom: 25px;
display: flex;
gap: 7px;
pointer-events: auto;
}
.view-button {
min-width: 39px;
height: 39px;
padding: 0 11px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 11px;
background: rgba(250, 248, 238, 0.88);
box-shadow: 0 7px 22px rgba(31, 53, 45, 0.1);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 800;
backdrop-filter: blur(10px);
transition: 150ms ease;
}
.view-button:hover {
transform: translateY(-2px);
background: white;
color: var(--teal);
}
#toast {
top: 25px;
left: 50%;
max-width: min(440px, calc(100vw - 32px));
padding: 11px 16px;
border-radius: 999px;
background: rgba(24, 52, 49, 0.91);
box-shadow: 0 10px 32px rgba(24, 52, 49, 0.2);
color: white;
font-size: 12px;
font-weight: 700;
opacity: 0;
transform: translate(-50%, -15px);
transition: 220ms ease;
pointer-events: none;
text-align: center;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#toast.error {
background: rgba(158, 66, 52, 0.94);
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #dfe6dc;
color: var(--teal);
font-size: 12px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 820px) {
#intro {
top: 18px;
left: 18px;
max-width: calc(100vw - 36px);
}
h1 {
max-width: 310px;
font-size: 36px;
}
#intro p {
display: none;
}
#panel {
top: auto;
right: 12px;
bottom: 70px;
width: min(340px, calc(100vw - 24px));
max-height: 48vh;
padding: 14px;
overflow-y: auto;
border-radius: 16px;
}
.panel-copy,
.notice {
display: none;
}
#route-list {
margin-top: 10px;
}
#legend {
right: 12px;
bottom: 12px;
left: 12px;
max-width: none;
gap: 7px 12px;
padding: 9px 10px;
font-size: 9px;
}
#view-controls {
top: 16px;
right: 14px;
bottom: auto;
}
.view-button {
min-width: 35px;
height: 35px;
padding: 0 9px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly model of Madagascar's Tsingy limestone karst"></div>
<header id="intro" class="hud">
<div class="eyebrow">Madagascar · Tsingy karst</div>
<h1>Between the limestone knives</h1>
<p>
Trace the schematic visitor route through designated boardwalks and gap
crossings. Click the numbered checkpoints in sequence.
</p>
</header>
<aside id="panel" class="hud" aria-label="Route puzzle controls">
<div class="panel-top">
<div class="panel-kicker">Schematic field puzzle</div>
<div class="schematic-badge">NOT A TRAIL MAP</div>
</div>
<h2>Trace the visitor path</h2>
<p class="panel-copy">
Select checkpoint 01, then continue in numerical order. The gold trace
records each designated link you uncover.
</p>
<div class="notice">
<strong>Not hiking guidance.</strong> This fictional puzzle does not
represent an actual route, trail condition, closure, distance, or safety
recommendation. Use official local guidance for real travel.
</div>
<div class="progress-head">
<span id="next-label">Start at checkpoint 01</span>
<span id="link-count">0 / 9 links</span>
</div>
<div class="progress-track" aria-hidden="true">
<div id="progress-fill"></div>
</div>
<div id="route-list" aria-label="Select a numbered checkpoint"></div>
<div class="panel-actions">
<button id="reset-route" type="button">Reset trace</button>
<button id="reset-view" type="button">Reset camera</button>
</div>
<div id="complete-note">
Schematic route complete. All designated links are shown in gold.
</div>
</aside>
<div id="legend" class="hud" aria-label="Scene legend">
<div class="legend-item">
<span class="swatch boardwalk"></span>
Designated boardwalk
</div>
<div class="legend-item">
<span class="swatch gap"></span>
Designated gap crossing
</div>
<div class="legend-item">
<span class="swatch trace"></span>
Your traced route
</div>
<div class="legend-item">
<span class="swatch excluded"></span>
Excluded habitat / rock
</div>
</div>
<div id="view-controls" class="hud" aria-label="Camera controls">
<button id="zoom-out" class="view-button" type="button" aria-label="Zoom out">−</button>
<button id="zoom-in" class="view-button" type="button" aria-label="Zoom in">+</button>
<button id="top-view" class="view-button" type="button">Top</button>
</div>
<div id="toast" class="hud" role="status" aria-live="polite"></div>
<div id="loading">Building limestone diorama…</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 sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdfe6dc);
scene.fog = new THREE.Fog(0xdfe6dc, 48, 92);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Tsingy karst route puzzle");
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
0.1,
150
);
const ambient = new THREE.HemisphereLight(0xf6f4df, 0x637567, 2.2);
scene.add(ambient);
const sunlight = new THREE.DirectionalLight(0xfff4d6, 3.1);
sunlight.position.set(-16, 30, 18);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -28;
sunlight.shadow.camera.right = 28;
sunlight.shadow.camera.top = 28;
sunlight.shadow.camera.bottom = -28;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 75;
sunlight.shadow.bias = -0.00035;
scene.add(sunlight);
const fillLight = new THREE.DirectionalLight(0xb8d7d7, 0.7);
fillLight.position.set(18, 12, -18);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Deterministic helpers
// -------------------------------------------------------------------------
let randomSeed = 38127;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const clamp = THREE.MathUtils.clamp;
const V3 = THREE.Vector3;
const UP = new V3(0, 1, 0);
const materials = {
ground: new THREE.MeshStandardMaterial({
color: 0xc8bea0,
roughness: 1,
flatShading: true
}),
groundSide: new THREE.MeshStandardMaterial({
color: 0x777a68,
roughness: 1,
flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: 0x8c5d38,
roughness: 0.9,
flatShading: true
}),
darkWood: new THREE.MeshStandardMaterial({
color: 0x503b2c,
roughness: 1,
flatShading: true
}),
gap: new THREE.MeshStandardMaterial({
color: 0x4f7f91,
roughness: 0.75,
metalShading: false,
flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x287873,
roughness: 0.7,
flatShading: true
}),
gold: new THREE.MeshStandardMaterial({
color: 0xd89524,
emissive: 0x6b3904,
emissiveIntensity: 0.28,
roughness: 0.55
}),
void: new THREE.MeshStandardMaterial({
color: 0x455348,
roughness: 1,
transparent: true,
opacity: 0.82,
depthWrite: false
}),
shrub: new THREE.MeshStandardMaterial({
color: 0x6f8152,
roughness: 1,
flatShading: true
}),
shrubLight: new THREE.MeshStandardMaterial({
color: 0x8c9560,
roughness: 1,
flatShading: true
}),
trunk: new THREE.MeshStandardMaterial({
color: 0x65503b,
roughness: 1,
flatShading: true
}),
rock: new THREE.MeshStandardMaterial({
color: 0xb5b5a0,
roughness: 1,
flatShading: true
})
};
function cylinderBetween(a, b, radius, material, radialSegments = 7) {
const direction = new V3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(UP, direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(text, accent = "#287873", width = 5.2) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 160;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 12, 16, 744, 126, 34);
ctx.fillStyle = "rgba(250,248,238,0.94)";
ctx.fill();
ctx.lineWidth = 8;
ctx.strokeStyle = accent;
ctx.stroke();
ctx.fillStyle = accent;
ctx.font = "800 34px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 384, 81);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * (160 / 768), 1);
sprite.renderOrder = 12;
return sprite;
}
function makeNumberSprite(number) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 256, 256);
ctx.shadowColor = "rgba(20,40,35,0.25)";
ctx.shadowBlur = 18;
ctx.shadowOffsetY = 7;
ctx.beginPath();
ctx.arc(128, 128, 91, 0, Math.PI * 2);
ctx.fillStyle = "#f7f4e8";
ctx.fill();
ctx.shadowColor = "transparent";
ctx.lineWidth = 15;
ctx.strokeStyle = "#287873";
ctx.stroke();
ctx.fillStyle = "#183431";
ctx.font = "900 76px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(String(number).padStart(2, "0"), 128, 133);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(1.55, 1.55, 1);
sprite.renderOrder = 20;
return sprite;
}
// -------------------------------------------------------------------------
// Low-poly island and limestone towers
// -------------------------------------------------------------------------
const islandShape = new THREE.Shape();
const islandPoints = [
[-21, -15],
[21, -15],
[22, 8],
[16, 16],
[4, 18],
[-9, 17],
[-19, 10]
];
islandPoints.forEach(([x, y], index) => {
if (index === 0) islandShape.moveTo(x, y);
else islandShape.lineTo(x, y);
});
islandShape.closePath();
const islandGeometry = new THREE.ExtrudeGeometry(islandShape, {
depth: 1.45,
bevelEnabled: true,
bevelSize: 0.25,
bevelThickness: 0.2,
bevelSegments: 1,
curveSegments: 1
});
islandGeometry.rotateX(Math.PI / 2);
const island = new THREE.Mesh(
islandGeometry,
[materials.ground, materials.groundSide]
);
island.receiveShadow = true;
island.castShadow = true;
scene.add(island);
const backdrop = new THREE.Mesh(
new THREE.PlaneGeometry(120, 120),
new THREE.MeshStandardMaterial({
color: 0xd8dfd4,
roughness: 1
})
);
backdrop.rotation.x = -Math.PI / 2;
backdrop.position.y = -1.62;
backdrop.receiveShadow = true;
scene.add(backdrop);
function createKarstTower(x, z, radius, height, sides = 7) {
const levels = [0, 0.17, 0.39, 0.65, 0.86, 1];
const radiusFactors = [1, 0.96, 0.81, 0.62, 0.34, 0.07];
const rings = [];
const leanX = (random() - 0.5) * radius * 0.25;
const leanZ = (random() - 0.5) * radius * 0.25;
for (let level = 0; level < levels.length; level++) {
const ring = [];
const levelFactor = levels[level];
for (let side = 0; side < sides; side++) {
const angle =
(side / sides) * Math.PI * 2 +
(level % 2) * 0.075 +
(random() - 0.5) * 0.06;
const ridge = 0.82 + random() * 0.29;
const r = radius * radiusFactors[level] * ridge;
ring.push(
new V3(
x + Math.cos(angle) * r + leanX * levelFactor,
height * levelFactor + (random() - 0.5) * 0.15,
z + Math.sin(angle) * r + leanZ * levelFactor
)
);
}
rings.push(ring);
}
const positions = [];
const colors = [];
const limestone = [0xd8d5c1, 0xcac8b6, 0xe2dfcb, 0xbdbdab];
function addTriangle(a, b, c, color) {
positions.push(a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z);
for (let i = 0; i < 3; i++) colors.push(color.r, color.g, color.b);
}
for (let level = 0; level < rings.length - 1; level++) {
for (let side = 0; side < sides; side++) {
const next = (side + 1) % sides;
const a = rings[level][side];
const b = rings[level][next];
const c = rings[level + 1][side];
const d = rings[level + 1][next];
const color = new THREE.Color(
limestone[Math.floor(random() * limestone.length)]
);
color.offsetHSL(0, 0, (random() - 0.5) * 0.035);
addTriangle(a, c, b, color);
addTriangle(c, d, b, color.clone().offsetHSL(0, 0, 0.015));
}
}
const top = rings[rings.length - 1];
const capColor = new THREE.Color(0xe5e1ce);
for (let side = 0; side < sides; side++) {
const next = (side + 1) % sides;
addTriangle(
new V3(x + leanX, height, z + leanZ),
top[next],
top[side],
capColor
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true
});
const tower = new THREE.Mesh(geometry, material);
tower.castShadow = true;
tower.receiveShadow = true;
scene.add(tower);
// Small angular talus pieces make the tower bases less uniform.
for (let i = 0; i < 4; i++) {
const angle = random() * Math.PI * 2;
const distance = radius * (0.75 + random() * 0.35);
const stone = new THREE.Mesh(
new THREE.DodecahedronGeometry(
0.35 + random() * 0.65,
0
),
materials.rock
);
stone.position.set(
x + Math.cos(angle) * distance,
0.28 + random() * 0.25,
z + Math.sin(angle) * distance
);
stone.scale.set(
0.8 + random(),
0.55 + random() * 0.7,
0.8 + random()
);
stone.rotation.set(random(), random(), random());
stone.castShadow = true;
stone.receiveShadow = true;
scene.add(stone);
}
}
const towers = [
[-14, -2, 3.7, 9],
[-8, -7, 3.6, 10],
[-2, -9, 4.3, 12],
[4, -8, 4.0, 11],
[10, -6, 3.8, 10],
[16, -8, 3.4, 9],
[-17, 4, 3.0, 8],
[-10, 12, 2.6, 6.5],
[-2, 11, 3.1, 7.2],
[6, 10, 2.8, 6.5],
[13, 9, 3.0, 7],
[18, 5, 2.7, 7.5],
[-18, -8, 2.7, 7]
];
towers.forEach((tower) => createKarstTower(...tower));
// -------------------------------------------------------------------------
// Excluded fragile vegetation
// -------------------------------------------------------------------------
function makeShrub(x, z, scale = 1) {
const group = new THREE.Group();
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.17, 1.15, 5),
materials.trunk
);
trunk.position.y = 0.55;
trunk.castShadow = true;
group.add(trunk);
const canopy = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.72, 0),
random() > 0.5 ? materials.shrub : materials.shrubLight
);
canopy.position.set(
(random() - 0.5) * 0.18,
1.15 + random() * 0.2,
(random() - 0.5) * 0.18
);
canopy.scale.set(1.05, 0.72, 1.0);
canopy.castShadow = true;
group.add(canopy);
const branch = cylinderBetween(
new V3(0, 0.7, 0),
new V3(0.45, 1.25, 0.1),
0.055,
materials.trunk,
5
);
group.add(branch);
group.position.set(x, 0.04, z);
group.scale.setScalar(scale);
scene.add(group);
}
function protectedVegetation(x, z, scale = 1) {
const patch = new THREE.Group();
const fill = new THREE.Mesh(
new THREE.CircleGeometry(2.25 * scale, 28),
new THREE.MeshBasicMaterial({
color: 0x728856,
transparent: true,
opacity: 0.17,
depthWrite: false,
side: THREE.DoubleSide
})
);
fill.rotation.x = -Math.PI / 2;
fill.position.y = 0.035;
patch.add(fill);
const boundary = new THREE.Mesh(
new THREE.RingGeometry(2.03 * scale, 2.17 * scale, 36),
new THREE.MeshBasicMaterial({
color: 0xc95e4d,
transparent: true,
opacity: 0.82,
depthWrite: false,
side: THREE.DoubleSide
})
);
boundary.rotation.x = -Math.PI / 2;
boundary.position.y = 0.055;
patch.add(boundary);
makeShrub(x - 0.65 * scale, z - 0.1 * scale, 0.8 * scale);
makeShrub(x + 0.55 * scale, z + 0.2 * scale, 0.95 * scale);
makeShrub(x + 0.05 * scale, z + 0.8 * scale, 0.65 * scale);
const label = makeLabel("FRAGILE VEGETATION — EXCLUDED", "#c95e4d", 6.5);
label.position.set(x, 2.5 * scale, z);
patch.add(label);
scene.add(patch);
}
protectedVegetation(-9.0, 1.7, 1.0);
protectedVegetation(6.0, -5.7, 0.95);
protectedVegetation(15.0, 2.0, 0.85);
// -------------------------------------------------------------------------
// Excluded, unsupported rock shelves
// -------------------------------------------------------------------------
function createHatchTexture() {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(242,226,207,0.88)";
ctx.fillRect(0, 0, 256, 256);
ctx.strokeStyle = "#c95e4d";
ctx.lineWidth = 15;
for (let offset = -256; offset < 512; offset += 48) {
ctx.beginPath();
ctx.moveTo(offset, 256);
ctx.lineTo(offset + 256, 0);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(1.4, 1.4);
return texture;
}
const hatchTexture = createHatchTexture();
const hatchMaterial = new THREE.MeshStandardMaterial({
map: hatchTexture,
roughness: 1,
side: THREE.DoubleSide
});
function unsupportedShelf(x, y, z, rotation) {
const group = new THREE.Group();
const shelfGeometry = new THREE.BoxGeometry(4.1, 0.55, 2.5);
const shelf = new THREE.Mesh(shelfGeometry, [
materials.rock,
materials.rock,
hatchMaterial,
materials.rock,
materials.rock,
materials.rock
]);
shelf.castShadow = true;
shelf.receiveShadow = true;
group.add(shelf);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(shelfGeometry),
new THREE.LineBasicMaterial({ color: 0xc95e4d })
);
group.add(edges);
const neck = new THREE.Mesh(
new THREE.CylinderGeometry(0.7, 1.55, y - 0.2, 5),
materials.rock
);
neck.position.y = -(y - 0.2) / 2;
neck.rotation.y = rotation * 0.4;
neck.castShadow = true;
neck.receiveShadow = true;
group.add(neck);
const label = makeLabel("UNSUPPORTED ROCK — EXCLUDED", "#c95e4d", 6.2);
label.position.set(0, 1.65, 0);
group.add(label);
group.position.set(x, y, z);
group.rotation.y = rotation;
scene.add(group);
}
unsupportedShelf(-5.5, 3.65, 2.1, -0.28);
unsupportedShelf(11.7, 3.2, 1.2, 0.45);
// -------------------------------------------------------------------------
// Schematic route: boardwalks and narrow gap crossings
// -------------------------------------------------------------------------
const nodePositions = [
new V3(-15, 2.45, 9),
new V3(-11, 2.45, 8),
new V3(-8, 3.0, 5),
new V3(-4, 3.0, 5),
new V3(-1, 3.8, 2),
new V3(3, 3.8, 2),
new V3(6, 3.0, -2),
new V3(10, 3.0, -2),
new V3(13, 2.65, -4),
new V3(16, 2.65, -2)
];
const segmentKinds = [
"boardwalk",
"gap",
"boardwalk",
"gap",
"boardwalk",
"gap",
"boardwalk",
"gap",
"boardwalk"
];
function pointOnSegment(a, b, t) {
return new V3().lerpVectors(a, b, t);
}
function buildWalkway(a, b, kind) {
const group = new THREE.Group();
const horizontal = new V3(b.x - a.x, 0, b.z - a.z);
const length = horizontal.length();
const direction = horizontal.clone().normalize();
const side = new V3(-direction.z, 0, direction.x);
const angle = Math.atan2(direction.x, direction.z);
const deckY = (t) => THREE.MathUtils.lerp(a.y, b.y, t);
if (kind === "boardwalk") {
const plankCount = Math.max(5, Math.ceil(length / 0.38));
const plankGeometry = new THREE.BoxGeometry(1.55, 0.15, 0.29);
for (let i = 0; i < plankCount; i++) {
const t = (i + 0.5) / plankCount;
const plank = new THREE.Mesh(plankGeometry, materials.wood);
plank.position.copy(pointOnSegment(a, b, t));
plank.position.y = deckY(t) - 0.08;
plank.rotation.y = angle;
plank.castShadow = true;
plank.receiveShadow = true;
group.add(plank);
}
for (const sideSign of [-1, 1]) {
const offset = side.clone().multiplyScalar(sideSign * 0.68);
const railStart = a.clone().add(offset);
const railEnd = b.clone().add(offset);
railStart.y += 0.92;
railEnd.y += 0.92;
group.add(cylinderBetween(railStart, railEnd, 0.055, materials.darkWood));
const supportCount = Math.max(1, Math.ceil(length / 2.4));
for (let i = 0; i <= supportCount; i++) {
const t = i / supportCount;
const p = pointOnSegment(a, b, t).add(offset);
const top = p.clone();
top.y = deckY(t) + 0.9;
const bottom = p.clone();
bottom.y = deckY(t) - 0.12;
group.add(cylinderBetween(bottom, top, 0.055, materials.darkWood));
}
}
const supportCount = Math.max(1, Math.ceil(length / 3.4));
for (let i = 0; i <= supportCount; i++) {
const t = i / supportCount;
const top = pointOnSegment(a, b, t);
top.y -= 0.15;
const bottom = new V3(top.x, 0.08, top.z);
group.add(cylinderBetween(bottom, top, 0.12, materials.darkWood));
}
} else {
// A narrow open lattice crossing makes the gap type visually distinct.
const slatCount = Math.max(6, Math.ceil(length / 0.48));
const slatGeometry = new THREE.BoxGeometry(1.22, 0.12, 0.14);
for (let i = 0; i < slatCount; i++) {
const t = (i + 0.5) / slatCount;
const slat = new THREE.Mesh(slatGeometry, materials.gap);
slat.position.copy(pointOnSegment(a, b, t));
slat.position.y = deckY(t) - 0.07;
slat.rotation.y = angle;
slat.castShadow = true;
group.add(slat);
}
for (const sideSign of [-1, 1]) {
const offset = side.clone().multiplyScalar(sideSign * 0.57);
const lowerStart = a.clone().add(offset);
const lowerEnd = b.clone().add(offset);
lowerStart.y -= 0.12;
lowerEnd.y -= 0.12;
group.add(cylinderBetween(lowerStart, lowerEnd, 0.07, materials.gap));
const railStart = a.clone().add(offset);
const railEnd = b.clone().add(offset);
railStart.y += 0.82;
railEnd.y += 0.82;
group.add(cylinderBetween(railStart, railEnd, 0.045, materials.gap));
const postCount = Math.max(2, Math.ceil(length / 2.1));
for (let i = 0; i <= postCount; i++) {
const t = i / postCount;
const p = pointOnSegment(a, b, t).add(offset);
const top = p.clone();
top.y = deckY(t) + 0.82;
const bottom = p.clone();
bottom.y = deckY(t) - 0.1;
group.add(cylinderBetween(bottom, top, 0.045, materials.gap));
}
}
const voidGroup = new THREE.Group();
const voidPatch = new THREE.Mesh(
new THREE.CircleGeometry(2.15, 12),
materials.void
);
voidPatch.rotation.x = -Math.PI / 2;
voidPatch.position.y = 0.045;
voidPatch.scale.set(1.2, 1, 1);
voidGroup.add(voidPatch);
voidGroup.position.set(
(a.x + b.x) / 2,
0,
(a.z + b.z) / 2
);
voidGroup.rotation.y = angle;
scene.add(voidGroup);
}
scene.add(group);
}
for (let i = 0; i < segmentKinds.length; i++) {
buildWalkway(
nodePositions[i],
nodePositions[i + 1],
segmentKinds[i]
);
}
// Route highlights are revealed as the puzzle is solved.
const routeHighlights = [];
for (let i = 0; i < segmentKinds.length; i++) {
const a = nodePositions[i];
const b = nodePositions[i + 1];
const midpoint = a.clone().lerp(b, 0.5);
midpoint.y += 0.14;
const highlight = cylinderBetween(
midpoint,
midpoint.clone(),
0.075,
materials.gold,
8
);
// Recreate with actual endpoints because cylinderBetween expects two ends.
highlight.geometry.dispose();
const direction = new V3().subVectors(b, a);
const length = direction.length();
highlight.geometry = new THREE.CylinderGeometry(0.075, 0.075, length, 8);
highlight.position.copy(a).lerp(b, 0.5);
highlight.position.y += 0.14;
highlight.quaternion.setFromUnitVectors(UP, direction.normalize());
highlight.visible = false;
highlight.renderOrder = 5;
scene.add(highlight);
routeHighlights.push(highlight);
}
// -------------------------------------------------------------------------
// Checkpoint markers
// -------------------------------------------------------------------------
const markerStates = [];
const pickers = [];
nodePositions.forEach((position, index) => {
const visual = new THREE.Group();
visual.position.copy(position);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(1.12, 1.12, 0.18, 10),
index === 0 || index === nodePositions.length - 1
? materials.darkWood
: materials.wood
);
platform.position.y = -0.08;
platform.castShadow = true;
platform.receiveShadow = true;
visual.add(platform);
const diskMaterial = new THREE.MeshStandardMaterial({
color: 0x287873,
roughness: 0.65,
flatShading: true
});
const disk = new THREE.Mesh(
new THREE.CylinderGeometry(0.42, 0.48, 0.16, 10),
diskMaterial
);
disk.position.y = 0.1;
disk.castShadow = true;
visual.add(disk);
const ring = new THREE.Mesh(
new THREE.RingGeometry(0.61, 0.72, 24),
new THREE.MeshBasicMaterial({
color: 0xd89524,
transparent: true,
opacity: 0.85,
side: THREE.DoubleSide,
depthWrite: false
})
);
ring.rotation.x = -Math.PI / 2;
ring.position.y = 0.025;
visual.add(ring);
const post = cylinderBetween(
new V3(0, 0.1, 0),
new V3(0, 1.1, 0),
0.055,
materials.darkWood,
6
);
visual.add(post);
const number = makeNumberSprite(index + 1);
number.position.y = 1.38;
visual.add(number);
const pickMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
});
const picker = new THREE.Mesh(
new THREE.SphereGeometry(0.85, 10, 8),
pickMaterial
);
picker.position.y = 1.2;
picker.userData.checkpointIndex = index;
visual.add(picker);
pickers.push(picker);
scene.add(visual);
markerStates.push({
visual,
disk,
diskMaterial,
ring,
number,
done: false,
wrongUntil: 0
});
});
const startLabel = makeLabel("SCHEMATIC TRAILHEAD", "#287873", 5.2);
startLabel.position.copy(nodePositions[0]).add(new V3(0, 2.65, 0));
scene.add(startLabel);
const endLabel = makeLabel("SCHEMATIC LOOKOUT", "#d89524", 5.2);
endLabel.position.copy(nodePositions[nodePositions.length - 1]).add(
new V3(0, 2.65, 0)
);
scene.add(endLabel);
// -------------------------------------------------------------------------
// Puzzle UI and state
// -------------------------------------------------------------------------
const routeList = document.getElementById("route-list");
const routeButtons = [];
let nextIndex = 0;
let hoveredIndex = -1;
let toastTimer = null;
nodePositions.forEach((_, index) => {
const button = document.createElement("button");
button.type = "button";
button.className = "route-point";
button.textContent = String(index + 1).padStart(2, "0");
button.setAttribute(
"aria-label",
`Select checkpoint ${String(index + 1).padStart(2, "0")}`
);
button.addEventListener("click", () => selectCheckpoint(index));
routeList.appendChild(button);
routeButtons.push(button);
});
function showToast(message, error = false) {
const toast = document.getElementById("toast");
toast.textContent = message;
toast.classList.toggle("error", error);
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2600);
}
function updateUI() {
const panel = document.getElementById("panel");
const nextLabel = document.getElementById("next-label");
const linkCount = document.getElementById("link-count");
const progressFill = document.getElementById("progress-fill");
const completedLinks = Math.max(0, nextIndex - 1);
const totalLinks = nodePositions.length - 1;
linkCount.textContent = `${completedLinks} / ${totalLinks} links`;
progressFill.style.width = `${(nextIndex / nodePositions.length) * 100}%`;
if (nextIndex === 0) {
nextLabel.textContent = "Start at checkpoint 01";
} else if (nextIndex === nodePositions.length) {
nextLabel.textContent = "Schematic route complete";
} else {
nextLabel.textContent = `Next: checkpoint ${String(nextIndex + 1).padStart(2, "0")}`;
}
panel.classList.toggle("complete", nextIndex === nodePositions.length);
routeButtons.forEach((button, index) => {
button.classList.toggle("done", index < nextIndex);
button.classList.toggle("current", index === nextIndex);
button.setAttribute(
"aria-current",
index === nextIndex ? "step" : "false"
);
});
markerStates.forEach((state, index) => {
state.done = index < nextIndex;
state.ring.visible = index === nextIndex && nextIndex < nodePositions.length;
if (state.done) {
state.diskMaterial.color.set(0xd89524);
state.diskMaterial.emissive.set(0x5a3004);
state.diskMaterial.emissiveIntensity = 0.22;
} else {
state.diskMaterial.color.set(0x287873);
state.diskMaterial.emissive.set(0x000000);
state.diskMaterial.emissiveIntensity = 0;
}
});
}
function selectCheckpoint(index) {
if (nextIndex >= nodePositions.length) {
showToast("The schematic route is already complete.");
return;
}
if (index === nextIndex) {
if (index > 0) {
routeHighlights[index - 1].visible = true;
}
nextIndex++;
updateUI();
if (nextIndex === nodePositions.length) {
showToast("Schematic route complete — nine designated links traced.");
}
return;
}
if (index < nextIndex) {
showToast("That checkpoint is already part of your trace.");
} else {
markerStates[index].wrongUntil = performance.now() + 900;
showToast(
`Checkpoint ${String(index + 1).padStart(2, "0")} is not next. Follow the numbered sequence.`,
true
);
}
}
function resetRoute() {
nextIndex = 0;
routeHighlights.forEach((highlight) => {
highlight.visible = false;
});
updateUI();
showToast("Trace cleared. Start again at checkpoint 01.");
}
document.getElementById("reset-route").addEventListener("click", resetRoute);
updateUI();
// -------------------------------------------------------------------------
// Direct camera controls — no examples or addons
// -------------------------------------------------------------------------
const defaultView = {
azimuth: 0.66,
polar: 0.92,
distance: 40,
target: new V3(0, 3.0, 1.5)
};
const orbit = {
azimuth: defaultView.azimuth,
polar: defaultView.polar,
distance: defaultView.distance,
target: defaultView.target.clone()
};
let userAdjustedCamera = false;
let topViewActive = false;
let savedNormalView = null;
function updateCamera() {
orbit.polar = clamp(orbit.polar, 0.055, 1.38);
orbit.distance = clamp(orbit.distance, 17, 70);
const sinPolar = Math.sin(orbit.polar);
camera.position.set(
orbit.target.x + orbit.distance * sinPolar * Math.sin(orbit.azimuth),
orbit.target.y + orbit.distance * Math.cos(orbit.polar),
orbit.target.z + orbit.distance * sinPolar * Math.cos(orbit.azimuth)
);
camera.lookAt(orbit.target);
}
function resetView() {
topViewActive = false;
savedNormalView = null;
orbit.azimuth = defaultView.azimuth;
orbit.polar = defaultView.polar;
orbit.distance =
window.innerWidth / window.innerHeight < 0.8 ? 55 : defaultView.distance;
orbit.target.copy(defaultView.target);
userAdjustedCamera = false;
document.getElementById("top-view").textContent = "Top";
updateCamera();
}
function toggleTopView() {
if (!topViewActive) {
savedNormalView = {
azimuth: orbit.azimuth,
polar: orbit.polar,
distance: orbit.distance,
target: orbit.target.clone()
};
topViewActive = true;
orbit.azimuth = 0;
orbit.polar = 0.055;
orbit.distance =
window.innerWidth / window.innerHeight < 0.8 ? 55 : 43;
orbit.target.set(0, 2.4, 1.3);
document.getElementById("top-view").textContent = "Exit";
} else {
orbit.azimuth = savedNormalView.azimuth;
orbit.polar = savedNormalView.polar;
orbit.distance = savedNormalView.distance;
orbit.target.copy(savedNormalView.target);
savedNormalView = null;
topViewActive = false;
document.getElementById("top-view").textContent = "Top";
}
userAdjustedCamera = true;
updateCamera();
}
document.getElementById("reset-view").addEventListener("click", resetView);
document.getElementById("top-view").addEventListener("click", toggleTopView);
document.getElementById("zoom-in").addEventListener("click", () => {
orbit.distance *= 0.86;
userAdjustedCamera = true;
updateCamera();
});
document.getElementById("zoom-out").addEventListener("click", () => {
orbit.distance *= 1.16;
userAdjustedCamera = true;
updateCamera();
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let drag = null;
function pickCheckpoint(clientX, clientY) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(pickers, false);
return intersections.length
? intersections[0].object.userData.checkpointIndex
: -1;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
drag = {
pointerId: event.pointerId,
x: event.clientX,
y: event.clientY,
moved: false
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (drag && event.pointerId === drag.pointerId) {
const dx = event.clientX - drag.x;
const dy = event.clientY - drag.y;
if (Math.abs(dx) + Math.abs(dy) > 5) drag.moved = true;
orbit.azimuth -= dx * 0.006;
orbit.polar -= dy * 0.005;
drag.x = event.clientX;
drag.y = event.clientY;
userAdjustedCamera = true;
updateCamera();
return;
}
const index = pickCheckpoint(event.clientX, event.clientY);
if (index !== hoveredIndex) {
hoveredIndex = index;
renderer.domElement.style.cursor = index >= 0 ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!drag || event.pointerId !== drag.pointerId) return;
if (!drag.moved) {
const index = pickCheckpoint(event.clientX, event.clientY);
if (index >= 0) selectCheckpoint(index);
}
drag = null;
renderer.domElement.style.cursor = hoveredIndex >= 0 ? "pointer" : "grab";
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.distance *= Math.exp(event.deltaY * 0.001);
userAdjustedCamera = true;
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLInputElement) return;
if (event.key.toLowerCase() === "r") resetRoute();
if (event.key.toLowerCase() === "t") toggleTopView();
if (event.key === "ArrowLeft") {
orbit.azimuth += 0.08;
updateCamera();
}
if (event.key === "ArrowRight") {
orbit.azimuth -= 0.08;
updateCamera();
}
if (event.key === "+" || event.key === "=") {
orbit.distance *= 0.9;
updateCamera();
}
if (event.key === "-" || event.key === "_") {
orbit.distance *= 1.1;
updateCamera();
}
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
if (!userAdjustedCamera) {
orbit.distance = width / height < 0.8 ? 55 : defaultView.distance;
}
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const now = performance.now();
markerStates.forEach((state, index) => {
const hoverScale = index === hoveredIndex ? 1.11 : 1;
state.visual.scale.lerp(
new V3(hoverScale, hoverScale, hoverScale),
0.14
);
if (index === nextIndex && nextIndex < nodePositions.length) {
const pulse = 1 + Math.sin(elapsed * 4.2) * 0.13;
state.ring.scale.setScalar(pulse);
state.ring.material.opacity = 0.72 + Math.sin(elapsed * 4.2) * 0.18;
}
if (now < state.wrongUntil) {
state.diskMaterial.color.set(0xc95e4d);
state.diskMaterial.emissive.set(0x64170e);
state.diskMaterial.emissiveIntensity = 0.4;
} else if (state.done) {
state.diskMaterial.color.set(0xd89524);
state.diskMaterial.emissive.set(0x5a3004);
state.diskMaterial.emissiveIntensity = 0.22;
} else {
state.diskMaterial.color.set(0x287873);
state.diskMaterial.emissive.set(0x000000);
state.diskMaterial.emissiveIntensity = 0;
}
});
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
setTimeout(() => document.getElementById("loading").remove(), 500);
});
</script>
</body>
</html>
```