Prompt specification
Build or customize the Three.js 3D scene "Tectonic boundary landscape gallery" 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: Tectonic boundary landscape gallery
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/tectonic-boundary-landscape-gallery-x1167
Scene Description Prompt:
Three voxel landscapes show spreading, converging, and sliding plate boundaries with corresponding motion arrows. One HTML file using Three.js from cdnjs.
Working Three.js Starter (tectonic-boundary-landscape-gallery-x1167):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Plate Boundaries</title>
<style>
:root {
color-scheme: dark;
--bg: #071019;
--panel: #0c1822;
--panel-light: #11232f;
--line: rgba(166, 205, 222, 0.16);
--text: #edf7fb;
--muted: #92aab7;
--cyan: #64d9ee;
--orange: #ff8657;
--green: #82c69b;
}
* {
box-sizing: border-box;
}
html {
min-width: 320px;
background: var(--bg);
}
body {
min-height: 100vh;
margin: 0;
overflow-x: hidden;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
background:
radial-gradient(circle at 14% 0%, rgba(39, 105, 128, 0.2), transparent 34rem),
radial-gradient(circle at 88% 12%, rgba(131, 71, 47, 0.13), transparent 30rem),
linear-gradient(180deg, #09141e 0%, #061018 100%);
}
body::before {
position: fixed;
inset: 0;
z-index: -1;
content: "";
pointer-events: none;
opacity: 0.22;
background-image:
linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
background-size: 48px 48px;
mask-image: linear-gradient(to bottom, black, transparent 80%);
}
main {
width: min(1540px, 100%);
margin: 0 auto;
padding: 42px 24px 36px;
}
header {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
align-items: end;
gap: 30px;
margin-bottom: 26px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin: 0 0 12px;
color: var(--cyan);
font-size: 0.72rem;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 1px;
content: "";
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
h1 {
max-width: 850px;
margin: 0;
font-size: clamp(2rem, 4.6vw, 4.5rem);
font-weight: 650;
line-height: 0.98;
letter-spacing: -0.055em;
}
.intro {
max-width: 470px;
margin: 18px 0 0;
color: var(--muted);
font-size: clamp(0.92rem, 1.4vw, 1.06rem);
line-height: 1.65;
}
.live {
display: flex;
align-items: center;
gap: 9px;
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 999px;
color: #b9cbd4;
background: rgba(9, 22, 30, 0.65);
font-size: 0.67rem;
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
white-space: nowrap;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 12px var(--green);
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
50% {
opacity: 0.45;
transform: scale(0.78);
}
}
.landscapes {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 18px;
}
.card {
position: relative;
min-width: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 20px;
background:
linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 45%),
var(--panel);
box-shadow:
0 20px 50px rgba(0, 0, 0, 0.24),
inset 0 1px rgba(255, 255, 255, 0.035);
}
.card::after {
position: absolute;
inset: 0;
z-index: 3;
border-radius: inherit;
content: "";
pointer-events: none;
box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.2);
}
.scene {
position: relative;
height: 460px;
overflow: hidden;
border-bottom: 1px solid var(--line);
background: #0a151e;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
.scene::before {
position: absolute;
inset: 0;
z-index: 1;
content: "";
pointer-events: none;
background:
linear-gradient(to bottom, rgba(4, 12, 18, 0.34), transparent 22%),
linear-gradient(to top, rgba(4, 12, 18, 0.55), transparent 30%);
}
.scene-tag {
position: absolute;
top: 17px;
left: 17px;
z-index: 2;
display: flex;
align-items: center;
gap: 9px;
color: #c8d9e0;
font-size: 0.66rem;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
pointer-events: none;
}
.scene-tag span {
display: grid;
width: 28px;
height: 28px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 8px;
color: white;
background: rgba(7, 16, 23, 0.58);
backdrop-filter: blur(8px);
font-size: 0.68rem;
letter-spacing: 0;
}
.motion-key {
position: absolute;
right: 16px;
bottom: 15px;
left: 16px;
z-index: 2;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
color: #9eb4bf;
font-size: 0.68rem;
font-weight: 650;
letter-spacing: 0.05em;
text-transform: uppercase;
pointer-events: none;
}
.direction-pair {
display: flex;
gap: 5px;
}
.direction-pair b {
display: grid;
width: 29px;
height: 25px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 7px;
color: var(--cyan);
background: rgba(7, 16, 23, 0.6);
font-size: 1rem;
line-height: 1;
}
.card-copy {
padding: 20px 21px 22px;
}
.card-copy h2 {
margin: 0 0 8px;
font-size: 1.32rem;
font-weight: 650;
letter-spacing: -0.025em;
}
.card-copy p {
min-height: 60px;
margin: 0;
color: var(--muted);
font-size: 0.87rem;
line-height: 1.58;
}
.card-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
margin-top: 17px;
padding-top: 15px;
border-top: 1px solid var(--line);
color: #77919e;
font-size: 0.67rem;
font-weight: 650;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.card-meta .type {
color: #b7c9d1;
}
.card:nth-child(1) .card-meta .type {
color: var(--orange);
}
.card:nth-child(2) .card-meta .type {
color: var(--cyan);
}
.card:nth-child(3) .card-meta .type {
color: var(--green);
}
footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
margin-top: 18px;
padding: 0 3px;
color: #6f8794;
font-size: 0.72rem;
line-height: 1.5;
}
.controls-hint {
display: flex;
flex-wrap: wrap;
gap: 15px;
}
.controls-hint span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.controls-hint kbd {
min-width: 22px;
padding: 3px 6px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 5px;
color: #adc1cb;
background: rgba(255, 255, 255, 0.035);
font-family: inherit;
font-size: 0.62rem;
text-align: center;
}
@media (max-width: 1080px) {
.landscapes {
grid-template-columns: 1fr;
}
.scene {
height: min(62vw, 520px);
min-height: 390px;
}
.card-copy p {
min-height: 0;
}
}
@media (max-width: 650px) {
main {
padding: 28px 14px 24px;
}
header {
grid-template-columns: 1fr;
gap: 18px;
}
.live {
width: max-content;
}
.scene {
height: 390px;
min-height: 0;
}
footer {
align-items: flex-start;
flex-direction: column;
}
}
@media (prefers-reduced-motion: reduce) {
.live-dot {
animation: none;
}
}
</style>
</head>
<body>
<main>
<header>
<div>
<p class="eyebrow">Earth systems / interactive geology</p>
<h1>Three ways the crust moves.</h1>
<p class="intro">
Explore procedural voxel landscapes of Earth’s three main plate
boundaries. Drag to orbit, scroll to zoom, and watch the arrows reveal
the direction of plate motion.
</p>
</div>
<div class="live">
<span class="live-dot"></span>
Live voxel models
</div>
</header>
<section class="landscapes" aria-label="Interactive plate boundary models">
<article class="card">
<div class="scene">
<canvas
id="spreading-canvas"
role="img"
aria-label="Interactive voxel landscape of a spreading plate boundary"
></canvas>
<div class="scene-tag"><span>01</span> Divergent boundary</div>
<div class="motion-key">
<span>Plates move apart</span>
<span class="direction-pair"><b>←</b><b>→</b></span>
</div>
</div>
<div class="card-copy">
<h2>Spreading ridge</h2>
<p>
Rising mantle material pushes two plates away from a central rift,
creating new crust as magma rises through the gap.
</p>
<div class="card-meta">
<span class="type">Constructive</span>
<span>New crust</span>
</div>
</div>
</article>
<article class="card">
<div class="scene">
<canvas
id="converging-canvas"
role="img"
aria-label="Interactive voxel landscape of a converging plate boundary"
></canvas>
<div class="scene-tag"><span>02</span> Convergent boundary</div>
<div class="motion-key">
<span>Plates move together</span>
<span class="direction-pair"><b>→</b><b>←</b></span>
</div>
</div>
<div class="card-copy">
<h2>Subduction zone</h2>
<p>
An oceanic plate descends beneath a continental plate, forming a deep
trench and feeding magma that builds volcanic mountains.
</p>
<div class="card-meta">
<span class="type">Destructive</span>
<span>Crust recycled</span>
</div>
</div>
</article>
<article class="card">
<div class="scene">
<canvas
id="sliding-canvas"
role="img"
aria-label="Interactive voxel landscape of a sliding transform plate boundary"
></canvas>
<div class="scene-tag"><span>03</span> Transform boundary</div>
<div class="motion-key">
<span>Plates slide past</span>
<span class="direction-pair"><b>→</b><b>←</b></span>
</div>
</div>
<div class="card-copy">
<h2>Transform fault</h2>
<p>
Neighboring plates grind past one another in opposite directions.
Their lateral movement creates earthquakes and offset landforms.
</p>
<div class="card-meta">
<span class="type">Conservative</span>
<span>Crust preserved</span>
</div>
</div>
</article>
</section>
<footer>
<span>Procedural voxel geology · built with the Three.js core</span>
<div class="controls-hint">
<span><kbd>Drag</kbd> orbit</span>
<span><kbd>Scroll</kbd> zoom</span>
<span><kbd>2× click</kbd> reset</span>
</div>
</footer>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const CUBE = 0.68;
const STEP = 0.72;
const NX = 27;
const NZ = 19;
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const clamp = THREE.MathUtils.clamp;
function hash2(x, z, seed = 0) {
let h =
Math.imul(x + 1013, 374761393) ^
Math.imul(z + 2027, 668265263) ^
Math.imul(seed + 17, 2246822519);
h = Math.imul(h ^ (h >>> 13), 1274126177);
return ((h ^ (h >>> 16)) >>> 0) / 4294967295;
}
function gridCoordinate(value, count) {
return Math.round(value / STEP + (count - 1) / 2);
}
function worldX(index) {
return (index - (NX - 1) / 2) * STEP;
}
function worldZ(index) {
return (index - (NZ - 1) / 2) * STEP;
}
function addBaseAndGrid(scene) {
const width = (NX - 1) * STEP;
const depth = (NZ - 1) * STEP;
const base = new THREE.Mesh(
new THREE.BoxGeometry(width + 0.9, 0.25, depth + 0.9),
new THREE.MeshStandardMaterial({
color: 0x111e27,
roughness: 0.92,
metalness: 0.02
})
);
base.position.y = -0.14;
base.receiveShadow = true;
scene.add(base);
const points = [];
const halfX = width / 2;
const halfZ = depth / 2;
for (let i = 0; i < NX; i++) {
const x = worldX(i);
points.push(x, 0.012, -halfZ, x, 0.012, halfZ);
}
for (let i = 0; i < NZ; i++) {
const z = worldZ(i);
points.push(-halfX, 0.012, z, halfX, 0.012, z);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(points, 3)
);
const grid = new THREE.LineSegments(
geometry,
new THREE.LineBasicMaterial({
color: 0x4b6b79,
transparent: true,
opacity: 0.2
})
);
scene.add(grid);
}
function makeTerrain(scene, config) {
const cubes = [];
const heights = Array.from({ length: NX }, () => Array(NZ).fill(0));
for (let ix = 0; ix < NX; ix++) {
const x = worldX(ix);
for (let iz = 0; iz < NZ; iz++) {
const z = worldZ(iz);
const levels = config.height(ix, iz, x, z);
heights[ix][iz] = levels;
for (let layer = 0; layer < levels; layer++) {
cubes.push({
x,
y: (layer + 0.5) * STEP,
z,
color: config.color(ix, iz, x, z, layer, levels)
});
}
}
}
const geometry = new THREE.BoxGeometry(CUBE, CUBE, CUBE);
const material = new THREE.MeshStandardMaterial({
roughness: 0.8,
metalness: 0.035,
vertexColors: true
});
const mesh = new THREE.InstancedMesh(
geometry,
material,
cubes.length
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
cubes.forEach((cube, index) => {
dummy.position.set(cube.x, cube.y, cube.z);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, color.setHex(cube.color));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) {
mesh.instanceColor.needsUpdate = true;
}
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return function heightAt(x, z) {
const ix = clamp(gridCoordinate(x, NX), 0, NX - 1);
const iz = clamp(gridCoordinate(z, NZ), 0, NZ - 1);
return heights[ix][iz] * STEP + 0.03;
};
}
function makeArrow(colorHex, length = 2.8) {
const group = new THREE.Group();
const headLength = 0.72;
const shaftLength = length - headLength;
const material = new THREE.MeshStandardMaterial({
color: colorHex,
emissive: colorHex,
emissiveIntensity: 0.55,
roughness: 0.32,
metalness: 0.08
});
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.085, 0.085, shaftLength, 10),
material
);
shaft.rotation.z = -Math.PI / 2;
shaft.position.x = shaftLength / 2;
shaft.castShadow = true;
group.add(shaft);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.29, headLength, 12),
material
);
head.rotation.z = -Math.PI / 2;
head.position.x = length - headLength / 2;
head.castShadow = true;
group.add(head);
return group;
}
function addFaultLine(scene, heightAt, axis, colorHex) {
const points = [];
const count = axis === "x" ? NX : NZ;
for (let i = 0; i < count; i++) {
if (axis === "x") {
const x = worldX(i);
points.push(
new THREE.Vector3(x, heightAt(x, 0) + 0.08, 0)
);
} else {
const z = worldZ(i);
points.push(
new THREE.Vector3(0, heightAt(0, z) + 0.08, z)
);
}
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color: colorHex,
dashSize: 0.28,
gapSize: 0.18,
transparent: true,
opacity: 0.8
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
scene.add(line);
}
function addLighting(scene, accent = 0x7ad9eb) {
const hemisphere = new THREE.HemisphereLight(
0xc5e8f4,
0x17232a,
1.85
);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xfff4df, 2.4);
key.position.set(9, 17, 8);
key.castShadow = true;
key.shadow.mapSize.set(1024, 1024);
key.shadow.camera.left = -15;
key.shadow.camera.right = 15;
key.shadow.camera.top = 15;
key.shadow.camera.bottom = -15;
key.shadow.camera.near = 1;
key.shadow.camera.far = 50;
key.shadow.normalBias = 0.035;
scene.add(key);
const rim = new THREE.DirectionalLight(accent, 0.75);
rim.position.set(-11, 8, -10);
scene.add(rim);
const fill = new THREE.DirectionalLight(0x7eb6d1, 0.55);
fill.position.set(-5, 4, 12);
scene.add(fill);
}
class CameraControls {
constructor(camera, element, target) {
this.camera = camera;
this.element = element;
this.target = target.clone();
this.defaultYaw = 0.58;
this.defaultPitch = 0.55;
this.defaultRadius = 35;
this.yaw = this.defaultYaw;
this.pitch = this.defaultPitch;
this.radius = this.defaultRadius;
this.targetYaw = this.yaw;
this.targetPitch = this.pitch;
this.targetRadius = this.radius;
this.dragging = false;
this.pointerX = 0;
this.pointerY = 0;
element.addEventListener("pointerdown", this.onPointerDown);
element.addEventListener("pointermove", this.onPointerMove);
element.addEventListener("pointerup", this.onPointerUp);
element.addEventListener("pointercancel", this.onPointerUp);
element.addEventListener("wheel", this.onWheel, { passive: false });
element.addEventListener("dblclick", this.reset);
}
onPointerDown = (event) => {
this.dragging = true;
this.pointerX = event.clientX;
this.pointerY = event.clientY;
this.element.setPointerCapture(event.pointerId);
};
onPointerMove = (event) => {
if (!this.dragging) return;
const dx = event.clientX - this.pointerX;
const dy = event.clientY - this.pointerY;
this.pointerX = event.clientX;
this.pointerY = event.clientY;
this.targetYaw -= dx * 0.007;
this.targetPitch = clamp(this.targetPitch + dy * 0.005, 0.25, 1.05);
};
onPointerUp = (event) => {
this.dragging = false;
if (this.element.hasPointerCapture(event.pointerId)) {
this.element.releasePointerCapture(event.pointerId);
}
};
onWheel = (event) => {
event.preventDefault();
this.targetRadius = clamp(
this.targetRadius * Math.exp(event.deltaY * 0.001),
23,
48
);
};
reset = () => {
this.targetYaw = this.defaultYaw;
this.targetPitch = this.defaultPitch;
this.targetRadius = this.defaultRadius;
};
update() {
const damping = 0.11;
this.yaw += (this.targetYaw - this.yaw) * damping;
this.pitch += (this.targetPitch - this.pitch) * damping;
this.radius += (this.targetRadius - this.radius) * damping;
const horizontal = Math.cos(this.pitch) * this.radius;
this.camera.position.set(
this.target.x + horizontal * Math.sin(this.yaw),
this.target.y + Math.sin(this.pitch) * this.radius,
this.target.z + horizontal * Math.cos(this.yaw)
);
this.camera.lookAt(this.target);
}
}
function createLandscape(canvas, config) {
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a151e);
scene.fog = new THREE.Fog(0x0a151e, 31, 57);
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
const controls = new CameraControls(
camera,
canvas,
new THREE.Vector3(0, 1.35, 0)
);
addBaseAndGrid(scene);
addLighting(scene, config.accent);
const heightAt = makeTerrain(scene, config);
if (config.fault) {
addFaultLine(
scene,
heightAt,
config.fault.axis,
config.fault.color
);
}
if (config.glow) {
const glow = new THREE.PointLight(
config.glow.color,
config.glow.intensity,
config.glow.distance,
2
);
glow.position.set(...config.glow.position);
scene.add(glow);
}
const arrows = config.arrows.map((arrow, index) => {
const direction = new THREE.Vector3(
arrow.direction[0],
0,
arrow.direction[1]
).normalize();
const group = makeArrow(arrow.color || 0x67e7f5);
group.rotation.y = -Math.atan2(direction.z, direction.x);
group.position.set(
arrow.x,
heightAt(arrow.x, arrow.z) + 0.62,
arrow.z
);
group.userData.base = group.position.clone();
group.userData.direction = direction;
group.userData.phase = index * 1.4;
scene.add(group);
return group;
});
function resize() {
const width = canvas.clientWidth || 450;
const height = canvas.clientHeight || 450;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const observer = new ResizeObserver(resize);
observer.observe(canvas);
resize();
function update(time) {
controls.update();
if (!reducedMotion) {
arrows.forEach((arrow) => {
const { base, direction, phase } = arrow.userData;
const travel = Math.sin(time * 1.7 + phase) * 0.34;
arrow.position.x = base.x + direction.x * travel;
arrow.position.z = base.z + direction.z * travel;
arrow.position.y =
base.y + Math.sin(time * 2.4 + phase) * 0.045;
});
}
renderer.render(scene, camera);
}
return { update };
}
const spreadingConfig = {
accent: 0xff7046,
height(ix, iz, x, z) {
const noise = hash2(ix, iz, 3);
const distance = Math.abs(x);
if (distance < 0.2) {
return 2 + Math.floor(hash2(ix, iz, 8) * 2);
}
const ridge = Math.max(
0,
4 - Math.round(distance / STEP)
);
return Math.min(
7,
2 +
Math.floor(noise * 2) +
Math.floor(ridge * 0.62)
);
},
color(ix, iz, x, z, layer, levels) {
if (Math.abs(x) < 0.2) {
if (layer === levels - 1) return 0xffa14a;
if (layer === levels - 2) return 0xef5c35;
return 0x9e302d;
}
const top = x < 0 ? 0x5ca37c : 0x789d60;
const upperRock = x < 0 ? 0x526b68 : 0x6d7057;
const deepRock = x < 0 ? 0x304b54 : 0x424d43;
if (layer === levels - 1) return top;
if (layer === levels - 2) return upperRock;
return deepRock;
},
glow: {
color: 0xff5b25,
intensity: 22,
distance: 9,
position: [0, 2.2, 0]
},
arrows: [
{ x: -6.3, z: -4.2, direction: [-1, 0], color: 0x73e9f7 },
{ x: -3.8, z: 4.1, direction: [-1, 0], color: 0x73e9f7 },
{ x: 6.3, z: -4.2, direction: [1, 0], color: 0xffad68 },
{ x: 3.8, z: 4.1, direction: [1, 0], color: 0xffad68 }
]
};
const convergingConfig = {
accent: 0x65cce6,
height(ix, iz, x, z) {
if (x < 0) {
return 1;
}
if (x < 0.2) {
return 0;
}
if (x < 2.3) {
return 1;
}
const noise = hash2(ix, iz, 13);
const hills = Math.floor(hash2(ix, iz, 21) * 2.3);
const volcanoDistance = Math.hypot(
x - 3.6,
(z - 0.4) * 0.82
);
const volcano = Math.max(
0,
Math.floor(6.2 - volcanoDistance * 1.45)
);
return Math.min(
9,
2 + noise * 2 + hills + volcano
);
},
color(ix, iz, x, z, layer, levels) {
if (x < 0) {
if (layer === levels - 1) return 0x2c86a5;
return 0x193c50;
}
const volcanoDistance = Math.hypot(
x - 3.6,
(z - 0.4) * 0.82
);
if (volcanoDistance < 0.85 && layer === levels - 1) {
return 0xff7046;
}
if (layer === levels - 1) {
return levels > 6 ? 0x879184 : 0x739d68;
}
if (layer === levels - 2) {
return 0x5d6654;
}
return 0x343c38;
},
fault: {
axis: "z",
color: 0x62cde3
},
glow: {
color: 0xff6338,
intensity: 14,
distance: 8,
position: [3.6, 5.4, 0.4]
},
arrows: [
{ x: -6.3, z: -4.1, direction: [1, 0], color: 0x70e7f4 },
{ x: -3.6, z: 4.0, direction: [1, 0], color: 0x70e7f4 },
{ x: 6.6, z: -4.1, direction: [-1, 0], color: 0xffa56f },
{ x: 8.1, z: 3.9, direction: [-1, 0], color: 0xffa56f }
]
};
const slidingConfig = {
accent: 0x82d79b,
height(ix, iz, x, z) {
if (Math.abs(z) < 0.2) {
return 0;
}
const noise = hash2(ix, iz, 31);
const scarp = Math.max(
0,
2 - Math.round(Math.abs(z) / STEP)
);
const ridge = Math.max(
0,
Math.floor(
2.4 -
Math.abs(
hash2(ix, iz, 47) * 2 - 1
) * 3
)
);
return Math.min(
6,
2 +
Math.floor(noise * 2) +
scarp +
ridge
);
},
color(ix, iz, x, z, layer, levels) {
const top = z < 0 ? 0x6b9b79 : 0x8ca361;
const upperRock = z < 0 ? 0x587063 : 0x737654;
const deepRock = z < 0 ? 0x304a4c : 0x474c39;
if (layer === levels - 1) return top;
if (layer === levels - 2) return upperRock;
return deepRock;
},
fault: {
axis: "x",
color: 0xffd18a
},
arrows: [
{ x: -6.2, z: -4.2, direction: [1, 0], color: 0x8ae8b2 },
{ x: 1.0, z: -4.2, direction: [1, 0], color: 0x8ae8b2 },
{ x: 6.2, z: 4.2, direction: [-1, 0], color: 0xffd18a },
{ x: -1.0, z: 4.2, direction: [-1, 0], color: 0xffd18a }
]
};
const landscapes = [
createLandscape(
document.querySelector("#spreading-canvas"),
spreadingConfig
),
createLandscape(
document.querySelector("#converging-canvas"),
convergingConfig
),
createLandscape(
document.querySelector("#sliding-canvas"),
slidingConfig
)
];
function frame(time) {
const seconds = time * 0.001;
landscapes.forEach((landscape) => {
landscape.update(seconds);
});
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
</script>
</body>
</html>
```