Prompt specification
Build or customize the Three.js 3D scene "Volcanic Flow and Impact Depression Comparison" 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 Flow and Impact Depression Comparison
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/volcanic-flow-and-impact-depression-comparison-x3810
Scene Description Prompt:
Create a standalone voxel scene in one HTML file using Three.js from cdnjs. Create two small terrain models illustrating different formation processes. Show flow direction or impact origin cues and keep uncertain process details explicitly schematic.
Working Three.js Starter (volcanic-flow-and-impact-depression-comparison-x3810):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Process Studies</title>
<style>
:root {
color-scheme: dark;
--bg: #07111c;
--panel: rgba(9, 19, 31, 0.86);
--border: rgba(166, 202, 224, 0.18);
--text: #eaf4fb;
--muted: #91a7b8;
--lava: #ff8a3d;
--impact: #62d9ef;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.intro {
position: fixed;
top: 24px;
left: 28px;
z-index: 2;
width: min(430px, calc(100vw - 56px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #b8cedd;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
background: linear-gradient(90deg, var(--lava), var(--impact));
content: "";
}
h1 {
margin: 0;
font-size: clamp(26px, 3vw, 43px);
font-weight: 650;
letter-spacing: -0.045em;
line-height: 1.02;
}
.intro p {
max-width: 410px;
margin: 11px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.schematic-badge {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 13px;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 999px;
background: rgba(255, 255, 255, 0.045);
color: #c8d8e3;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.schematic-badge::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: #e8c778;
box-shadow: 0 0 12px rgba(232, 199, 120, 0.6);
content: "";
}
.controls {
position: fixed;
top: 24px;
right: 26px;
z-index: 3;
display: flex;
align-items: center;
gap: 10px;
}
.hint {
padding: 8px 11px;
border: 1px solid var(--border);
border-radius: 9px;
background: rgba(7, 17, 28, 0.64);
color: #91a7b8;
font-size: 10px;
letter-spacing: 0.05em;
backdrop-filter: blur(10px);
}
button {
border: 1px solid var(--border);
border-radius: 9px;
padding: 9px 12px;
background: rgba(7, 17, 28, 0.78);
color: #dceaf3;
font: inherit;
font-size: 11px;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover {
border-color: rgba(166, 202, 224, 0.38);
background: rgba(20, 37, 52, 0.9);
}
.cards {
position: fixed;
right: 26px;
bottom: 24px;
left: 26px;
z-index: 2;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
pointer-events: none;
}
.card {
position: relative;
overflow: hidden;
padding: 15px 17px 15px 19px;
border: 1px solid var(--border);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(14px);
}
.card::before {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
background: var(--accent);
content: "";
}
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.card h2 {
margin: 0;
font-size: 14px;
font-weight: 680;
letter-spacing: -0.01em;
}
.card .uncertain {
flex: 0 0 auto;
padding: 4px 6px;
border: 1px solid rgba(232, 199, 120, 0.25);
border-radius: 5px;
color: #ddc98f;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.card p {
margin: 8px 0 0;
color: #9db0bf;
font-size: 11px;
line-height: 1.5;
}
.card strong {
color: #dce8f0;
font-weight: 650;
}
.lava-card {
--accent: var(--lava);
}
.impact-card {
--accent: var(--impact);
}
@media (max-width: 700px) {
.intro {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
}
.intro p {
display: none;
}
.schematic-badge {
margin-top: 9px;
}
.controls {
top: auto;
right: 14px;
bottom: 178px;
}
.hint {
display: none;
}
.cards {
right: 12px;
bottom: 12px;
left: 12px;
gap: 8px;
}
.card {
padding: 12px;
}
.card-top {
align-items: flex-start;
flex-direction: column;
gap: 5px;
}
.card h2 {
font-size: 12px;
}
.card p {
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="intro">
<div class="eyebrow">Comparative process studies</div>
<h1>Two ways a landscape changes</h1>
<p>
Small voxel dioramas contrast a directional volcanic flow with a
sudden impact basin. Analytical cues are intentionally diagrammatic.
</p>
<div class="schematic-badge">Schematic · not survey-grade</div>
</header>
<div class="controls">
<div class="hint">Drag to orbit · Scroll / pinch to zoom</div>
<button id="reset" type="button">Reset view</button>
</div>
<section class="cards" aria-label="Process explanations">
<article class="card lava-card">
<div class="card-top">
<h2>A — Directed lava flow</h2>
<span class="uncertain">Uncertain details</span>
</div>
<p>
<strong>Orange arrows indicate a source-to-front route.</strong>
Vent position, channel width, cooling sequence, and erupted volume
are inferred and simplified.
</p>
</article>
<article class="card impact-card">
<div class="card-top">
<h2>B — Sudden impact basin</h2>
<span class="uncertain">Uncertain details</span>
</div>
<p>
<strong>The descending marker is an assumed impact origin.</strong>
Crater proportions, ejecta distribution, impact angle, and chronology
are exaggerated or unresolved.
</p>
</article>
</section>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive comparison of a schematic lava-flow terrain and a schematic impact basin"
);
renderer.domElement.tabIndex = 0;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111c);
scene.fog = new THREE.Fog(0x07111c, 17, 34);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
target: new THREE.Vector3(0, 0.75, 0),
theta: 0.52,
phi: 0.91,
radius: 14.7
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
scene.add(new THREE.HemisphereLight(0xc5e3ff, 0x18202a, 1.8));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(5.5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x6cb9e8, 1.35);
rimLight.position.set(-7, 5, -8);
scene.add(rimLight);
const grid = new THREE.GridHelper(32, 32, 0x203a4d, 0x102436);
grid.position.y = -0.72;
grid.material.transparent = true;
grid.material.opacity = 0.45;
scene.add(grid);
const CELL = 0.34;
const GRID = 15;
const HALF = (GRID - 1) * 0.5;
function randomGenerator(seed) {
let state = seed >>> 0;
return () => {
state = (state * 1664525 + 1013904223) >>> 0;
return state / 4294967296;
};
}
function gridCoordinate(index) {
return (index - HALF) * CELL;
}
function makePedestal(group, accent) {
const lower = new THREE.Mesh(
new THREE.BoxGeometry(5.55, 0.18, 5.55),
new THREE.MeshStandardMaterial({
color: 0x101b27,
roughness: 0.72,
metalness: 0.25
})
);
lower.position.y = -0.57;
lower.receiveShadow = true;
group.add(lower);
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(5.35, 0.34, 5.35),
new THREE.MeshStandardMaterial({
color: 0x1b2a37,
roughness: 0.86,
metalness: 0.08
})
);
pedestal.position.y = -0.31;
pedestal.castShadow = true;
pedestal.receiveShadow = true;
group.add(pedestal);
const inset = new THREE.Mesh(
new THREE.BoxGeometry(5.05, 0.035, 5.05),
new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.16,
roughness: 0.7
})
);
inset.position.y = -0.12;
group.add(inset);
}
function createVoxelTerrain(group, heightAt, colorAt) {
const count = GRID * GRID;
const geometry = new THREE.BoxGeometry(1, 1, 1);
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
metalness: 0.015
});
const mesh = new THREE.InstancedMesh(geometry, material, count);
mesh.castShadow = true;
mesh.receiveShadow = true;
const matrix = new THREE.Matrix4();
const position = new THREE.Vector3();
const quaternion = new THREE.Quaternion();
const scale = new THREE.Vector3();
const color = new THREE.Color();
let instance = 0;
for (let iz = 0; iz < GRID; iz++) {
for (let ix = 0; ix < GRID; ix++) {
const x = gridCoordinate(ix);
const z = gridCoordinate(iz);
const height = Math.max(1, heightAt(x, z));
position.set(x, height * CELL * 0.5, z);
scale.set(CELL * 0.965, height * CELL, CELL * 0.965);
matrix.compose(position, quaternion, scale);
mesh.setMatrixAt(instance, matrix);
color.set(colorAt(x, z, height, ix, iz));
mesh.setColorAt(instance, color);
instance++;
}
}
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
group.add(mesh);
return mesh;
}
function createBoxInstances(group, boxes, material) {
if (!boxes.length) return null;
const geometry = new THREE.BoxGeometry(1, 1, 1);
const mesh = new THREE.InstancedMesh(
geometry,
material,
boxes.length
);
const matrix = new THREE.Matrix4();
const position = new THREE.Vector3();
const quaternion = new THREE.Quaternion();
const scale = new THREE.Vector3();
const color = new THREE.Color();
boxes.forEach((box, index) => {
position.set(box.x, box.y, box.z);
scale.set(box.sx, box.sy, box.sz);
matrix.compose(position, quaternion, scale);
mesh.setMatrixAt(index, matrix);
if (box.color !== undefined) {
color.set(box.color);
mesh.setColorAt(index, color);
}
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width * 0.5, height * 0.5);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makePlaque(title, subtitle, accent) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 240;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 8, 1008, 224, 30);
ctx.fillStyle = "rgba(7, 17, 28, 0.91)";
ctx.fill();
ctx.lineWidth = 3;
ctx.strokeStyle = "rgba(182, 209, 226, 0.25)";
ctx.stroke();
ctx.fillStyle = accent;
roundedRect(ctx, 30, 35, 12, 170, 6);
ctx.fill();
ctx.fillStyle = "#edf6fb";
ctx.font = "700 58px system-ui, sans-serif";
ctx.fillText(title, 72, 102);
ctx.fillStyle = "#9fb5c5";
ctx.font = "600 30px system-ui, sans-serif";
ctx.fillText(subtitle, 72, 165);
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(4.6, 1.08, 1);
sprite.renderOrder = 20;
return sprite;
}
function closestPathInfo(x, z, points) {
let closestDistance = Infinity;
let closestT = 0;
let closestPoint = points[0].clone();
let closestDirection = new THREE.Vector3(1, 0, 0);
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const ab = b.clone().sub(a);
const lengthSquared = ab.lengthSq();
const t = THREE.MathUtils.clamp(
new THREE.Vector2(x - a.x, z - a.z).dot(
new THREE.Vector2(ab.x, ab.z)
) / lengthSquared,
0,
1
);
const point = a.clone().addScaledVector(ab, t);
const distance = Math.hypot(x - point.x, z - point.z);
const globalT = (i + t) / (points.length - 1);
if (distance < closestDistance) {
closestDistance = distance;
closestT = globalT;
closestPoint = point;
closestDirection = ab.normalize();
}
}
return {
distance: closestDistance,
t: closestT,
point: closestPoint,
direction: closestDirection
};
}
function samplePath(points, t) {
const scaled = THREE.MathUtils.clamp(t, 0, 1) * (points.length - 1);
const index = Math.min(points.length - 2, Math.floor(scaled));
const localT = scaled - index;
const point = points[index].clone().lerp(points[index + 1], localT);
const direction = points[index + 1].clone().sub(points[index]).normalize();
return { point, direction };
}
const flowPath = [
new THREE.Vector3(-3.8, 0, -3.6),
new THREE.Vector3(-2.5, 0, -2.2),
new THREE.Vector3(-0.9, 0, -1.0),
new THREE.Vector3(0.25, 0, 0.75),
new THREE.Vector3(2.1, 0, 2.35),
new THREE.Vector3(3.75, 0, 3.55)
];
function lavaHeight(x, z) {
const info = closestPathInfo(x, z, flowPath);
const broadNoise =
Math.sin(x * 0.85 + z * 0.33) * 0.28 +
Math.cos(z * 1.15 - x * 0.2) * 0.22;
const slope = 3.25 - 2.15 * info.t;
const channel = -0.62 * Math.exp(-Math.pow(info.distance / 0.62, 2));
const flanks = 0.42 * Math.exp(-Math.pow((info.distance - 1.15) / 0.9, 2));
return Math.max(1, Math.round(slope + broadNoise + channel + flanks));
}
function lavaColor(x, z, height) {
const palette = [0x4e5a53, 0x5b6254, 0x424e4d, 0x686b57, 0x3e4949];
const index = Math.abs(
Math.round(x * 8 + z * 13 + height * 2)
) % palette.length;
return palette[index];
}
function buildLavaModel() {
const group = new THREE.Group();
group.position.x = -3.18;
scene.add(group);
makePedestal(group, 0xff7a32);
createVoxelTerrain(group, lavaHeight, lavaColor);
const crustBoxes = [];
const hotBoxes = [];
for (let iz = 0; iz < GRID; iz++) {
for (let ix = 0; ix < GRID; ix++) {
const x = gridCoordinate(ix);
const z = gridCoordinate(iz);
const info = closestPathInfo(x, z, flowPath);
const width = 0.34 + info.t * 0.31;
if (info.distance < width) {
const h = lavaHeight(x, z);
const top = h * CELL;
crustBoxes.push({
x,
y: top + 0.035,
z,
sx: CELL * 0.97,
sy: 0.07,
sz: CELL * 0.97
});
if (info.distance < 0.16 + info.t * 0.1) {
hotBoxes.push({
x,
y: top + 0.082,
z,
sx: CELL * 0.49,
sy: 0.045,
sz: CELL * 0.49
});
}
}
}
}
const crustMaterial = new THREE.MeshStandardMaterial({
color: 0x251d1b,
roughness: 0.72,
metalness: 0.12
});
const hotMaterial = new THREE.MeshStandardMaterial({
color: 0xff6b18,
emissive: 0xff3b06,
emissiveIntensity: 1.6,
roughness: 0.42,
metalness: 0
});
createBoxInstances(group, crustBoxes, crustMaterial);
createBoxInstances(group, hotBoxes, hotMaterial);
// Source marker: a compact vent and a warm analytical ring.
const source = flowPath[0];
const sourceTop = lavaHeight(source.x, source.z) * CELL;
const vent = new THREE.Mesh(
new THREE.BoxGeometry(0.48, 0.32, 0.48),
new THREE.MeshStandardMaterial({
color: 0x302824,
roughness: 0.72
})
);
vent.position.set(source.x, sourceTop + 0.16, source.z);
vent.castShadow = true;
group.add(vent);
const sourceCore = new THREE.Mesh(
new THREE.BoxGeometry(0.23, 0.13, 0.23),
new THREE.MeshStandardMaterial({
color: 0xffa044,
emissive: 0xff4b08,
emissiveIntensity: 2.1
})
);
sourceCore.position.set(source.x, sourceTop + 0.37, source.z);
group.add(sourceCore);
const sourceRing = new THREE.Mesh(
new THREE.TorusGeometry(0.31, 0.035, 6, 28),
new THREE.MeshBasicMaterial({
color: 0xffa04c,
transparent: true,
opacity: 0.9
})
);
sourceRing.rotation.x = Math.PI * 0.5;
sourceRing.position.set(source.x, sourceTop + 0.08, source.z);
group.add(sourceRing);
// Flow-direction arrows.
const arrows = [];
[0.23, 0.43, 0.64, 0.83].forEach((t) => {
const sample = samplePath(flowPath, t);
const h = lavaHeight(sample.point.x, sample.point.z);
const arrow = new THREE.ArrowHelper(
sample.direction,
new THREE.Vector3(
sample.point.x,
h * CELL + 0.43,
sample.point.z
),
0.72,
0xff9a45,
0.22,
0.13
);
arrow.line.material.transparent = true;
arrow.line.material.opacity = 0.92;
group.add(arrow);
arrows.push(arrow);
});
const sourceLight = new THREE.PointLight(0xff5a16, 15, 4.5, 2);
sourceLight.position.set(source.x, sourceTop + 0.55, source.z);
group.add(sourceLight);
const mid = samplePath(flowPath, 0.62);
const flowLight = new THREE.PointLight(0xff5a16, 7, 3.4, 2);
flowLight.position.set(
mid.point.x,
lavaHeight(mid.point.x, mid.point.z) * CELL + 0.35,
mid.point.z
);
group.add(flowLight);
const plaque = makePlaque(
"A / LAVA FLOW",
"SCHEMATIC • inferred source-to-front route",
"#ff8a3d"
);
plaque.position.set(0, 2.95, -2.42);
group.add(plaque);
return { hotMaterial, sourceLight, flowLight, arrows };
}
function impactHeight(x, z) {
const r = Math.hypot(x, z);
const noise =
Math.sin(x * 1.4 + z * 0.6) * 0.17 +
Math.cos(z * 1.2 - x * 0.8) * 0.14;
if (r < 0.46) return 1;
if (r < 1.22) return 0.34;
if (r < 2.02) {
return THREE.MathUtils.lerp(0.34, 1.65, (r - 1.22) / 0.8);
}
if (r < 2.52) {
return THREE.MathUtils.lerp(3.25, 2.05, (r - 2.02) / 0.5);
}
return 1.8 + noise;
}
function impactColor(x, z, height) {
const r = Math.hypot(x, z);
if (r < 0.5) return 0x687582;
if (r < 1.45) return 0x303a47;
if (r < 2.1) return 0x4b5359;
if (r < 2.55) return 0x8a8170;
return 0x59625d;
}
function buildImpactModel() {
const group = new THREE.Group();
group.position.x = 3.18;
scene.add(group);
makePedestal(group, 0x62d9ef);
createVoxelTerrain(group, impactHeight, impactColor);
// Scattered ejecta blocks are deliberately irregular and schematic.
const random = randomGenerator(42891);
const ejecta = [];
for (let i = 0; i < 58; i++) {
const angle = random() * Math.PI * 2;
const radius = 1.55 + random() * 0.76;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius;
const size = 0.09 + random() * 0.18;
const y = impactHeight(x, z) * CELL + size * 0.5;
ejecta.push({
x,
y,
z,
sx: size,
sy: size * (0.55 + random() * 0.65),
sz: size,
color: random() > 0.5 ? 0x887b66 : 0x5f5d58
});
}
createBoxInstances(
group,
ejecta,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.98
})
);
// Target ring around the crater floor.
const targetRing = new THREE.Mesh(
new THREE.TorusGeometry(1.15, 0.025, 8, 48),
new THREE.MeshBasicMaterial({
color: 0x62d9ef,
transparent: true,
opacity: 0.66
})
);
targetRing.rotation.x = Math.PI * 0.5;
targetRing.position.y = 0.58;
group.add(targetRing);
// Assumed impact origin: marker, crosshair, and descending cue.
const origin = new THREE.Group();
origin.position.y = 5.8;
group.add(origin);
const marker = new THREE.Mesh(
new THREE.SphereGeometry(0.13, 16, 12),
new THREE.MeshBasicMaterial({
color: 0xa7f1ff
})
);
origin.add(marker);
const halo = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.028, 8, 40),
new THREE.MeshBasicMaterial({
color: 0x62d9ef,
transparent: true,
opacity: 0.82
})
);
origin.add(halo);
const crossGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.58, 0, 0),
new THREE.Vector3(0.58, 0, 0),
new THREE.Vector3(0, -0.58, 0),
new THREE.Vector3(0, 0.58, 0)
]);
const cross = new THREE.Line(
crossGeometry,
new THREE.LineBasicMaterial({
color: 0x62d9ef,
transparent: true,
opacity: 0.62
})
);
origin.add(cross);
const descentGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 5.42, 0),
new THREE.Vector3(0, 1.25, 0)
]);
const descent = new THREE.Line(
descentGeometry,
new THREE.LineDashedMaterial({
color: 0x62d9ef,
dashSize: 0.15,
gapSize: 0.11,
transparent: true,
opacity: 0.76
})
);
descent.computeLineDistances();
group.add(descent);
const downwardArrow = new THREE.ArrowHelper(
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 5.25, 0),
0.78,
0x8ce9f8,
0.22,
0.13
);
group.add(downwardArrow);
const originLight = new THREE.PointLight(0x54d7f2, 7, 4, 2);
originLight.position.set(0, 4.6, 0);
group.add(originLight);
const plaque = makePlaque(
"B / IMPACT BASIN",
"SCHEMATIC • assumed origin, not to scale",
"#62d9ef"
);
plaque.position.set(0, 2.75, -2.42);
group.add(plaque);
return { halo, marker, targetRing, descent };
}
const lava = buildLavaModel();
const impact = buildImpactModel();
// Direct camera controls: no examples, addons, or controls library.
const pointers = new Map();
let previousPinchDistance = 0;
const canvas = renderer.domElement;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
previousPinchDistance = pointerDistance();
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.36,
1.34
);
} else {
const distance = pointerDistance();
if (distance > 0 && previousPinchDistance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (previousPinchDistance / distance),
10,
22
);
}
previousPinchDistance = distance;
}
updateCamera();
});
function removePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = pointerDistance();
}
canvas.addEventListener("pointerup", removePointer);
canvas.addEventListener("pointercancel", removePointer);
canvas.addEventListener("lostpointercapture", removePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
10,
22
);
updateCamera();
},
{ passive: false }
);
function resetView() {
controls.target.set(0, 0.75, 0);
controls.theta = 0.52;
controls.phi = 0.91;
controls.radius = 14.7;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
let handled = true;
switch (event.key) {
case "ArrowLeft":
controls.theta += step;
break;
case "ArrowRight":
controls.theta -= step;
break;
case "ArrowUp":
controls.phi = Math.max(0.36, controls.phi - step);
break;
case "ArrowDown":
controls.phi = Math.min(1.34, controls.phi + step);
break;
case "+":
case "=":
controls.radius = Math.max(10, controls.radius - 0.7);
break;
case "-":
controls.radius = Math.min(22, controls.radius + 0.7);
break;
case "r":
case "R":
resetView();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
const pulse = reducedMotion ? 0 : Math.sin(elapsed * 2.1);
lava.hotMaterial.emissiveIntensity = 1.55 + pulse * 0.28;
lava.sourceLight.intensity = 14 + pulse * 2.5;
lava.flowLight.intensity = 7 + pulse * 1.2;
impact.halo.rotation.z = elapsed * 0.22;
impact.halo.rotation.y = elapsed * 0.12;
const markerScale = 1 + (reducedMotion ? 0 : Math.sin(elapsed * 2.4) * 0.12);
impact.marker.scale.setScalar(markerScale);
impact.targetRing.material.opacity = 0.58 + pulse * 0.1;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```