Prompt specification
Build or customize the Three.js 3D scene "Volcanic island observation scene" 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: Volcanic island observation scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/volcanic-island-observation-scene-x1191
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: volcanic island observation scene. Build a bounded island cone, old lava fields, coast, and distant observation point; show an illustrative plume with restrained particles and no invented hazard prediction.
Working Three.js Starter (volcanic-island-observation-scene-x1191):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Caldera — Voxel Island Observation</title>
<style>
:root {
color-scheme: dark;
--ink: #edf1e9;
--muted: #9caeae;
--panel: rgba(8, 22, 28, 0.78);
--edge: rgba(165, 205, 199, 0.18);
--accent: #91c6bd;
--warm: #c5a36f;
--lava: #4a3b35;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07141c;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
canvas {
-webkit-tap-highlight-color: transparent;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
outline: none;
touch-action: none;
}
#scene canvas.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
z-index: 5;
pointer-events: none;
}
.panel {
background: var(--panel);
border: 1px solid var(--edge);
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(13px);
-webkit-backdrop-filter: blur(13px);
}
#intro {
top: 22px;
left: 22px;
width: min(420px, calc(100vw - 44px));
padding: 19px 21px 18px;
border-radius: 4px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--accent);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 21px;
height: 1px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 4vw, 43px);
font-weight: 400;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 360px;
margin: 12px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.status-row {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 15px;
}
.tag {
padding: 6px 8px;
border: 1px solid var(--edge);
border-radius: 2px;
color: #c8d4d1;
background: rgba(255, 255, 255, 0.025);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#legend {
top: 22px;
right: 22px;
width: 250px;
padding: 17px;
border-radius: 4px;
}
.section-title {
margin: 0 0 13px;
color: #dce6e2;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.legend-item {
display: grid;
grid-template-columns: 13px 1fr;
align-items: center;
gap: 10px;
margin: 9px 0;
color: #b7c5c2;
font-size: 11px;
}
.swatch {
width: 12px;
height: 12px;
border: 1px solid rgba(255, 255, 255, 0.14);
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.12);
}
.swatch.cone { background: #747368; }
.swatch.lava { background: #332e2a; }
.swatch.coast { background: #9b8d70; }
.swatch.water { background: #0d3440; }
.swatch.plume { background: #aab2af; }
.model-note {
margin: 14px 0 0;
padding-top: 13px;
border-top: 1px solid var(--edge);
color: #879c9b;
font-size: 10px;
line-height: 1.55;
}
#labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.annotation {
position: absolute;
min-width: max-content;
padding: 7px 9px;
border: 1px solid rgba(178, 211, 205, 0.2);
border-radius: 2px;
background: rgba(5, 17, 22, 0.72);
color: #d5dfdc;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.09em;
text-transform: uppercase;
transform: translate(-50%, -100%);
transition: opacity 120ms linear;
white-space: nowrap;
}
.annotation::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 17px;
content: "";
background: rgba(178, 211, 205, 0.42);
}
.annotation::before {
position: absolute;
top: calc(100% + 15px);
left: calc(50% - 2px);
width: 5px;
height: 5px;
border: 1px solid rgba(178, 211, 205, 0.7);
border-radius: 50%;
content: "";
background: #07141c;
}
.annotation.secondary {
color: #a8b8b5;
font-size: 8px;
}
.annotation.plume {
color: #d0d6d2;
}
#disclaimer {
bottom: 22px;
left: 22px;
max-width: 510px;
padding: 12px 14px;
border-left: 2px solid var(--warm);
border-radius: 2px;
background: rgba(8, 22, 28, 0.77);
color: #c3ceca;
font-size: 10px;
line-height: 1.55;
backdrop-filter: blur(10px);
}
#disclaimer strong {
color: #e5d3ad;
font-size: 9px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#controls {
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--edge);
border-radius: 3px;
background: rgba(8, 22, 28, 0.86);
color: #d7e0dd;
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
transition:
border-color 140ms ease,
background 140ms ease,
transform 140ms ease;
}
button:hover,
button:focus-visible {
border-color: rgba(145, 198, 189, 0.55);
background: rgba(19, 46, 52, 0.92);
outline: none;
}
button:active {
transform: translateY(1px);
}
#help {
margin-left: 4px;
color: #78908f;
font-size: 9px;
letter-spacing: 0.04em;
text-transform: none;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #07141c;
color: #a9bcba;
font-size: 11px;
letter-spacing: 0.13em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
#intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 16px;
}
#intro .subtitle {
display: none;
}
#legend {
top: auto;
right: 12px;
bottom: 68px;
width: 205px;
padding: 13px;
}
#legend .model-note {
display: none;
}
#disclaimer {
right: 12px;
bottom: 12px;
left: 12px;
max-width: none;
padding: 9px 11px;
}
#controls {
top: 127px;
right: 12px;
bottom: auto;
}
#help {
display: none;
}
.annotation {
font-size: 8px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive voxel volcanic island observation scene"></main>
<div id="labels" aria-hidden="true">
<div class="annotation" id="label-crater">Bounded volcanic cone</div>
<div class="annotation secondary" id="label-lava">Old / cooled lava field</div>
<div class="annotation" id="label-station">Distant observation point</div>
<div class="annotation plume" id="label-plume">Illustrative plume · not to scale</div>
</div>
<header class="hud panel" id="intro">
<div class="eyebrow">Field study / volcanic island</div>
<h1>Caldera</h1>
<p class="subtitle">
A bounded voxel observation of a volcanic cone, cooled lava channels,
an eroded coast, and a small offshore monitoring post.
</p>
<div class="status-row">
<span class="tag">Schematic terrain</span>
<span class="tag">No forecast data</span>
</div>
</header>
<aside class="hud panel" id="legend">
<h2 class="section-title">Surface key</h2>
<div class="legend-item">
<span class="swatch cone"></span><span>Volcanic cone</span>
</div>
<div class="legend-item">
<span class="swatch lava"></span><span>Old / cooled lava field</span>
</div>
<div class="legend-item">
<span class="swatch coast"></span><span>Coastal shelf</span>
</div>
<div class="legend-item">
<span class="swatch water"></span><span>Survey water</span>
</div>
<div class="legend-item">
<span class="swatch plume"></span><span>Illustrative plume</span>
</div>
<p class="model-note">
The plume is a restrained visual motif, not a plume-height estimate,
ashfall model, gas forecast, or operational hazard assessment.
</p>
</aside>
<div class="hud" id="disclaimer">
<strong>Illustrative only</strong><br>
Geometry, distances, and plume motion are schematic. No hazard prediction
or real-time volcanic activity is represented.
</div>
<nav class="hud" id="controls" aria-label="Scene controls">
<button id="reset" type="button" title="Reset camera">Reset view</button>
<button id="toggle-plume" type="button" title="Toggle illustrative plume">
Hide plume
</button>
<span id="help">Drag to orbit · scroll to zoom · R to reset</span>
</nav>
<div id="loading">Loading voxel observation…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const mount = document.getElementById("scene");
const loading = document.getElementById("loading");
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
"aria-label",
"Voxel volcanic island. Drag to orbit and scroll to zoom."
);
mount.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07141c);
scene.fog = new THREE.FogExp2(0x07141c, 0.0105);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
260
);
const hemisphere = new THREE.HemisphereLight(0xa4c0cc, 0x1a2420, 1.75);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe0b8, 3.25);
sun.position.set(-26, 42, 29);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -48;
sun.shadow.camera.right = 48;
sun.shadow.camera.top = 38;
sun.shadow.camera.bottom = -38;
sun.shadow.camera.near = 2;
sun.shadow.camera.far = 120;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x6f9baa, 0.65);
fill.position.set(30, 14, -28);
scene.add(fill);
// ------------------------------------------------------------
// Utilities
// ------------------------------------------------------------
const clamp = THREE.MathUtils.clamp;
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function seededRandom(seed) {
return function () {
seed |= 0;
seed = (seed + 0x6d2b79f5) | 0;
let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const random = seededRandom(73219);
function hash2(x, z) {
const value = Math.sin(x * 127.1 + z * 311.7) * 43758.5453123;
return value - Math.floor(value);
}
function segmentDistance(px, pz, ax, az, bx, bz) {
const vx = bx - ax;
const vz = bz - az;
const wx = px - ax;
const wz = pz - az;
const lengthSquared = vx * vx + vz * vz;
const t = lengthSquared === 0
? 0
: clamp((wx * vx + wz * vz) / lengthSquared, 0, 1);
const dx = px - (ax + t * vx);
const dz = pz - (az + t * vz);
return Math.hypot(dx, dz);
}
function addBox(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Survey water and visible model boundary
// ------------------------------------------------------------
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x0b303b,
roughness: 0.82,
metalness: 0.12
});
const water = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
waterMaterial
);
water.rotation.x = -Math.PI / 2;
water.position.y = 0;
water.receiveShadow = true;
scene.add(water);
const boundaryMaterial = new THREE.LineBasicMaterial({
color: 0x76aaa7,
transparent: true,
opacity: 0.26
});
const boundaryPoints = [
new THREE.Vector3(-19, 0.12, -19),
new THREE.Vector3(19, 0.12, -19),
new THREE.Vector3(19, 0.12, 19),
new THREE.Vector3(-19, 0.12, 19)
];
scene.add(
new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(boundaryPoints),
boundaryMaterial
)
);
const boundaryPostMaterial = new THREE.MeshBasicMaterial({
color: 0x7fb6b1,
transparent: true,
opacity: 0.45
});
for (const x of [-19, 19]) {
for (const z of [-19, 19]) {
addBox(
scene,
[0.09, 0.42, 0.09],
[x, 0.22, z],
boundaryPostMaterial,
false
);
}
}
// ------------------------------------------------------------
// Bounded voxel island, cone, coast, and old lava channels
// ------------------------------------------------------------
const gridSize = 37;
const halfGrid = (gridSize - 1) / 2;
const lavaPaths = [
[[0, 1], [1, 4], [3, 6], [5, 9], [8, 11]],
[[-1, 1], [-2, 4], [-4, 6], [-6, 8], [-9, 10]],
[[1, 0], [3, 1], [6, 2], [9, 4], [12, 6]]
];
function lavaDistanceAt(x, z) {
let closest = Infinity;
for (const path of lavaPaths) {
for (let i = 0; i < path.length - 1; i++) {
const a = path[i];
const b = path[i + 1];
closest = Math.min(
closest,
segmentDistance(x, z, a[0], a[1], b[0], b[1])
);
}
}
return closest;
}
function surfaceColor(rr, height, lavaDistance, x, z) {
const color = new THREE.Color();
if (lavaDistance < 0.72) {
if (lavaDistance < 0.39) {
color.set(0x282a28);
} else if (hash2(x * 3, z * 5) > 0.79) {
color.set(0x674838);
} else {
color.set(0x3d352f);
}
} else if (rr > 0.84) {
color.set(0x9b8d70);
} else if (rr < 0.3) {
color.set(0x696860);
} else {
const elevation = clamp((height - 2) / 7, 0, 1);
color
.set(0x4e5949)
.lerp(new THREE.Color(0x79766a), elevation);
}
const jitter = (hash2(x, z) - 0.5) * 0.065;
color.offsetHSL(0, 0, jitter);
return color;
}
const terrainInfo = new Map();
const terrainInstances = [];
const terrainColors = [];
for (let iz = 0; iz < gridSize; iz++) {
for (let ix = 0; ix < gridSize; ix++) {
const x = ix - halfGrid;
const z = iz - halfGrid;
const edgeVariation =
1 +
0.045 * Math.sin(x * 0.78 + z * 0.21) +
0.035 * Math.cos(z * 0.63 - x * 0.17);
const rr =
Math.hypot(x / 13.8, z / 12.2) / edgeVariation;
if (rr > 1.08) continue;
let height =
1 +
Math.floor(
8.4 *
Math.pow(Math.max(0, 1 - Math.min(rr, 0.96)), 1.13) +
hash2(x * 2.1, z * 1.7) * 0.45
);
if (rr > 0.84) {
height = 1;
} else if (rr > 0.76) {
height = Math.min(height, 2);
}
const lavaDistance = lavaDistanceAt(x, z);
if (lavaDistance < 0.72 && rr < 0.98) {
height = Math.max(1, height - 1);
}
// A square, recessed crater remains within the cone's upper block.
if (rr < 0.17) {
height = 2;
} else if (rr < 0.28) {
height = Math.max(height, 8);
}
const topColor = surfaceColor(rr, height, lavaDistance, x, z);
terrainInfo.set(`${x},${z}`, {
x,
z,
height,
rr,
lavaDistance
});
for (let level = 0; level < height; level++) {
const matrix = new THREE.Matrix4();
const position = new THREE.Vector3(x, level + 0.5, z);
const quaternion = new THREE.Quaternion();
const scale = new THREE.Vector3(1, 1, 1);
matrix.compose(position, quaternion, scale);
terrainInstances.push(matrix);
const color = topColor.clone();
if (level < height - 1) {
const depth = level / Math.max(1, height - 1);
color.multiplyScalar(0.56 + depth * 0.14);
}
terrainColors.push(color);
}
}
}
const terrainMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.95,
metalness: 0
});
const terrain = new THREE.InstancedMesh(
unitBox,
terrainMaterial,
terrainInstances.length
);
terrain.castShadow = true;
terrain.receiveShadow = true;
for (let i = 0; i < terrainInstances.length; i++) {
terrain.setMatrixAt(i, terrainInstances[i]);
terrain.setColorAt(i, terrainColors[i]);
}
terrain.instanceMatrix.needsUpdate = true;
if (terrain.instanceColor) terrain.instanceColor.needsUpdate = true;
terrain.computeBoundingSphere();
scene.add(terrain);
// ------------------------------------------------------------
// Sparse voxel rocks and coastal vegetation
// ------------------------------------------------------------
const rockMatrices = [];
const rockColors = [];
for (let attempt = 0; attempt < 240 && rockMatrices.length < 85; attempt++) {
const x = Math.round((random() - 0.5) * 27);
const z = Math.round((random() - 0.5) * 24);
const info = terrainInfo.get(`${x},${z}`);
if (!info || info.lavaDistance < 0.85 || info.rr > 0.92) continue;
const size = 0.18 + random() * 0.43;
const matrix = new THREE.Matrix4();
matrix.compose(
new THREE.Vector3(
x + (random() - 0.5) * 0.42,
info.height + size * 0.42,
z + (random() - 0.5) * 0.42
),
new THREE.Quaternion(),
new THREE.Vector3(size, size * 0.72, size)
);
rockMatrices.push(matrix);
rockColors.push(
new THREE.Color(0x55564d).offsetHSL(
0,
0,
(random() - 0.5) * 0.06
)
);
}
const rocks = new THREE.InstancedMesh(
unitBox,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
}),
rockMatrices.length
);
rockMatrices.forEach((matrix, index) => {
rocks.setMatrixAt(index, matrix);
rocks.setColorAt(index, rockColors[index]);
});
rocks.instanceMatrix.needsUpdate = true;
if (rocks.instanceColor) rocks.instanceColor.needsUpdate = true;
rocks.castShadow = true;
rocks.receiveShadow = true;
scene.add(rocks);
const plantMatrices = [];
const plantColors = [];
for (let attempt = 0; attempt < 180 && plantMatrices.length < 32; attempt++) {
const x = Math.round((random() - 0.5) * 27);
const z = Math.round((random() - 0.5) * 24);
const info = terrainInfo.get(`${x},${z}`);
if (!info || info.height > 2 || info.lavaDistance < 0.95) continue;
const width = 0.3 + random() * 0.36;
const height = 0.18 + random() * 0.25;
const matrix = new THREE.Matrix4();
matrix.compose(
new THREE.Vector3(x, info.height + height * 0.5, z),
new THREE.Quaternion(),
new THREE.Vector3(width, height, width * 0.75)
);
plantMatrices.push(matrix);
plantColors.push(
new THREE.Color(0x465b47).offsetHSL(
0,
0,
(random() - 0.5) * 0.045
)
);
}
const plants = new THREE.InstancedMesh(
unitBox,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
}),
plantMatrices.length
);
plantMatrices.forEach((matrix, index) => {
plants.setMatrixAt(index, matrix);
plants.setColorAt(index, plantColors[index]);
});
plants.instanceMatrix.needsUpdate = true;
if (plants.instanceColor) plants.instanceColor.needsUpdate = true;
plants.castShadow = true;
scene.add(plants);
// ------------------------------------------------------------
// Distant offshore observation point
// ------------------------------------------------------------
const outpost = new THREE.Group();
scene.add(outpost);
const outpostGround = new THREE.MeshStandardMaterial({
color: 0x55594d,
roughness: 0.96
});
for (let x = -25; x <= -19; x++) {
for (let z = -21; z <= -16; z++) {
const edge = Math.hypot((x + 22) / 3.5, (z + 18.5) / 3.0);
if (edge > 1.08) continue;
const height =
edge > 0.76 ? 1 : edge > 0.48 ? 2 : 2 + (hash2(x, z) > 0.7 ? 1 : 0);
for (let level = 0; level < height; level++) {
addBox(
outpost,
[1, 1, 1],
[x, level + 0.5, z],
outpostGround
);
}
}
}
const platformMaterial = new THREE.MeshStandardMaterial({
color: 0x454e4e,
roughness: 0.8,
metalness: 0.18
});
const cabinMaterial = new THREE.MeshStandardMaterial({
color: 0xb8ad91,
roughness: 0.86
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: 0x293538,
roughness: 0.75,
metalness: 0.15
});
const mastMaterial = new THREE.MeshStandardMaterial({
color: 0x77817d,
roughness: 0.65,
metalness: 0.35
});
const windowMaterial = new THREE.MeshStandardMaterial({
color: 0x365b65,
roughness: 0.28,
metalness: 0.32,
emissive: 0x10252b,
emissiveIntensity: 0.45
});
addBox(
outpost,
[4.6, 0.24, 3.7],
[-22, 2.22, -18.5],
platformMaterial
);
addBox(
outpost,
[2.5, 1.45, 1.8],
[-22.3, 3.06, -18.7],
cabinMaterial
);
addBox(
outpost,
[2.85, 0.24, 2.12],
[-22.3, 3.9, -18.7],
roofMaterial
);
addBox(
outpost,
[1.05, 0.5, 0.07],
[-22.25, 3.17, -17.77],
windowMaterial,
false
);
addBox(
outpost,
[0.07, 0.5, 1.05],
[-21.01, 3.17, -18.7],
windowMaterial,
false
);
addBox(
outpost,
[0.16, 3.7, 0.16],
[-24.15, 4.1, -18.7],
mastMaterial
);
addBox(
outpost,
[1.2, 0.11, 0.11],
[-24.15, 5.25, -18.7],
mastMaterial
);
addBox(
outpost,
[0.65, 0.45, 0.65],
[-23.25, 2.7, -17.55],
platformMaterial
);
const lampMaterial = new THREE.MeshStandardMaterial({
color: 0xd7ad68,
emissive: 0xd18b36,
emissiveIntensity: 1.8,
roughness: 0.5
});
addBox(
outpost,
[0.3, 0.3, 0.3],
[-24.15, 6.05, -18.7],
lampMaterial,
false
);
const lampLight = new THREE.PointLight(0xe5a653, 5, 7, 2);
lampLight.position.set(-24.15, 6.05, -18.7);
outpost.add(lampLight);
// Simple voxel railing.
for (let x = -24; x <= -20; x += 2) {
addBox(
outpost,
[0.1, 0.65, 0.1],
[x, 2.64, -16.7],
mastMaterial
);
}
addBox(
outpost,
[4.4, 0.08, 0.08],
[-22, 2.95, -16.7],
mastMaterial
);
// ------------------------------------------------------------
// Restrained illustrative plume: low count, muted, non-eruptive
// ------------------------------------------------------------
const plumeGroup = new THREE.Group();
scene.add(plumeGroup);
const plumeParticles = [];
for (let i = 0; i < 46; i++) {
const material = new THREE.MeshBasicMaterial({
color: i % 3 === 0 ? 0xb2b8b4 : 0x969f9d,
transparent: true,
opacity: 0,
depthWrite: false
});
const particle = new THREE.Mesh(unitBox, material);
particle.renderOrder = 2;
plumeGroup.add(particle);
plumeParticles.push({
mesh: particle,
offset: random(),
speed: 0.026 + random() * 0.024,
baseX: (random() - 0.5) * 0.8,
baseZ: (random() - 0.5) * 0.8,
driftX: (random() - 0.5) * 2.8,
driftZ: (random() - 0.5) * 2.4,
size: 0.26 + random() * 0.48,
phase: random() * Math.PI * 2,
opacity: 0.075 + random() * 0.075
});
}
// ------------------------------------------------------------
// Direct camera controls: orbit, zoom, touch, keyboard
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 4.2, 0),
yaw: 0.62,
pitch: 0.48,
distance: 57
};
const defaultControls = {
yaw: controls.yaw,
pitch: controls.pitch,
distance: controls.distance
};
function updateCamera() {
const horizontal = Math.cos(controls.pitch) * controls.distance;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * controls.distance,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetCamera() {
controls.yaw = defaultControls.yaw;
controls.pitch = defaultControls.pitch;
controls.distance = defaultControls.distance;
updateCamera();
}
let dragging = false;
let activePointer = null;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
activePointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
controls.yaw -= dx * 0.006;
controls.pitch = clamp(controls.pitch + dy * 0.0045, 0.16, 1.22);
updateCamera();
});
function endDrag(event) {
if (event.pointerId !== activePointer) return;
dragging = false;
activePointer = null;
renderer.domElement.classList.remove("dragging");
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.distance = clamp(
controls.distance * Math.exp(event.deltaY * 0.001),
28,
92
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLButtonElement) return;
const key = event.key.toLowerCase();
if (key === "r") {
resetCamera();
} else if (key === "arrowleft") {
controls.yaw += 0.08;
} else if (key === "arrowright") {
controls.yaw -= 0.08;
} else if (key === "arrowup") {
controls.pitch = clamp(controls.pitch + 0.06, 0.16, 1.22);
} else if (key === "arrowdown") {
controls.pitch = clamp(controls.pitch - 0.06, 0.16, 1.22);
} else if (key === "+" || key === "=") {
controls.distance = clamp(controls.distance - 3, 28, 92);
} else if (key === "-") {
controls.distance = clamp(controls.distance + 3, 28, 92);
} else {
return;
}
updateCamera();
});
document.getElementById("reset").addEventListener("click", resetCamera);
const plumeButton = document.getElementById("toggle-plume");
let plumeVisible = true;
plumeButton.addEventListener("click", () => {
plumeVisible = !plumeVisible;
plumeGroup.visible = plumeVisible;
plumeButton.textContent = plumeVisible ? "Hide plume" : "Show plume";
});
// ------------------------------------------------------------
// Screen-space annotation projection
// ------------------------------------------------------------
const annotations = [
{
element: document.getElementById("label-crater"),
position: new THREE.Vector3(-2.4, 9.5, -0.6)
},
{
element: document.getElementById("label-lava"),
position: new THREE.Vector3(5.2, 4.9, 8.2)
},
{
element: document.getElementById("label-station"),
position: new THREE.Vector3(-24.1, 6.6, -18.7)
},
{
element: document.getElementById("label-plume"),
position: new THREE.Vector3(3.3, 14.7, 0.4)
}
];
const projected = new THREE.Vector3();
function updateAnnotations() {
for (const annotation of annotations) {
projected.copy(annotation.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.08 &&
Math.abs(projected.y) < 1.08;
annotation.element.style.opacity = visible ? "1" : "0";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
annotation.element.style.left = `${x}px`;
annotation.element.style.top = `${y}px`;
}
}
}
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
let firstFrame = true;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
for (const particle of plumeParticles) {
const life = (elapsed * particle.speed + particle.offset) % 1;
const fade = Math.sin(Math.PI * life);
const spread = life * life;
particle.mesh.position.set(
particle.baseX +
particle.driftX * spread +
Math.sin(elapsed * 0.55 + particle.phase) * 0.28 * life,
6.5 + life * 10.6,
particle.baseZ +
particle.driftZ * spread +
Math.cos(elapsed * 0.43 + particle.phase) * 0.23 * life
);
const size = particle.size * (0.42 + life * 1.42);
particle.mesh.scale.set(size, size * 0.82, size);
particle.mesh.material.opacity = particle.opacity * Math.pow(fade, 0.72);
}
updateAnnotations();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
}
requestAnimationFrame(animate);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
animate();
</script>
</body>
</html>
```