Prompt specification
Build or customize the Three.js 3D scene "Geological landscape interpretation kiosk" 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: Geological landscape interpretation kiosk
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/geological-landscape-interpretation-kiosk-x1128
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing columnar basalt. Create a rotating coast section with selectable column heights and tide level; reveal a cut face explaining column continuity while keeping geological labels visibly schematic. Low-poly.
Working Three.js Starter (geological-landscape-interpretation-kiosk-x1128):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Columnar Basalt — Interactive Coastal Section</title>
<style>
:root {
--ink: #10252e;
--muted: #62757b;
--paper: rgba(247, 248, 241, 0.92);
--line: rgba(16, 37, 46, 0.16);
--accent: #d76f47;
--accent-dark: #a84e32;
--teal: #28727a;
--shadow: 0 18px 50px rgba(22, 42, 48, 0.17);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce6e4;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
#interface {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.masthead {
position: absolute;
top: 24px;
left: 26px;
max-width: 360px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
width: 26px;
height: 2px;
background: var(--accent);
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 3.3vw, 51px);
font-weight: 500;
letter-spacing: -0.045em;
line-height: 0.94;
}
.masthead p {
max-width: 315px;
margin: 12px 0 0;
color: #526970;
font-size: 12px;
line-height: 1.55;
}
.schema-stamp {
position: absolute;
top: 27px;
left: 50%;
padding: 8px 12px;
transform: translateX(-50%);
border: 1px solid rgba(16, 37, 46, 0.25);
background: rgba(247, 248, 241, 0.73);
color: #40575e;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
white-space: nowrap;
backdrop-filter: blur(8px);
}
.panel {
pointer-events: auto;
border: 1px solid rgba(255, 255, 255, 0.65);
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.control-panel {
position: absolute;
top: 122px;
left: 24px;
width: 292px;
padding: 18px;
border-radius: 3px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 17px;
padding-bottom: 12px;
border-bottom: 1px solid var(--line);
}
.panel-heading strong {
font-size: 10px;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.panel-heading span {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.control-group {
margin-top: 18px;
}
.control-label {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 9px;
}
.control-label label,
.control-label > span:first-child {
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.control-note {
color: var(--muted);
font-size: 9px;
}
.segmented {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5px;
}
.segmented button {
min-height: 57px;
padding: 8px 5px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.35);
cursor: pointer;
transition:
background 160ms ease,
color 160ms ease,
transform 160ms ease;
}
.segmented button:hover {
transform: translateY(-1px);
border-color: rgba(16, 37, 46, 0.35);
}
.segmented button.active {
border-color: var(--ink);
background: var(--ink);
color: #f6f4e9;
}
.height-icon {
display: flex;
align-items: flex-end;
justify-content: center;
height: 22px;
margin-bottom: 6px;
}
.height-icon i {
display: block;
width: 7px;
border: 1px solid currentColor;
border-bottom: 0;
opacity: 0.9;
}
.height-icon i:nth-child(1) {
height: 8px;
}
.height-icon i:nth-child(2) {
height: 14px;
}
.height-icon i:nth-child(3) {
height: 21px;
}
.segmented button span:last-child {
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
}
.range-wrap {
padding: 10px 11px 8px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.3);
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 4px 0 9px;
accent-color: var(--teal);
cursor: pointer;
}
.range-labels {
display: flex;
justify-content: space-between;
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.primary-button {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
min-height: 44px;
padding: 0 13px;
border: 1px solid var(--ink);
background: transparent;
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: 160ms ease;
}
.primary-button:hover,
.primary-button.active {
background: var(--ink);
color: #f7f5e9;
}
.primary-button .button-icon {
display: grid;
width: 23px;
height: 23px;
place-items: center;
border: 1px solid currentColor;
border-radius: 50%;
font-size: 13px;
}
.switch-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 11px;
padding: 10px 0;
border-top: 1px solid var(--line);
border-bottom: 1px solid var(--line);
}
.switch-row > span {
font-size: 9px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.switch {
display: flex;
align-items: center;
gap: 7px;
padding: 0;
border: 0;
background: none;
cursor: pointer;
}
.switch-dot {
position: relative;
width: 28px;
height: 15px;
border: 1px solid #87979a;
border-radius: 10px;
background: #cbd4d1;
transition: 160ms ease;
}
.switch-dot::after {
position: absolute;
top: 2px;
left: 2px;
width: 9px;
height: 9px;
border-radius: 50%;
background: #ffffff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
content: "";
transition: 160ms ease;
}
.switch[aria-pressed="true"] .switch-dot {
border-color: var(--teal);
background: var(--teal);
}
.switch[aria-pressed="true"] .switch-dot::after {
left: 15px;
}
.text-button {
width: 100%;
margin-top: 11px;
padding: 9px;
border: 0;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.text-button:hover {
color: var(--ink);
}
.read-panel {
position: absolute;
top: 24px;
right: 24px;
width: 280px;
padding: 17px;
border-radius: 3px;
}
.read-panel h2 {
margin: 0 0 10px;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
font-weight: 500;
letter-spacing: -0.025em;
}
.read-panel > p {
margin: 0;
color: #526970;
font-size: 11px;
line-height: 1.6;
}
.explanation {
display: grid;
gap: 10px;
margin: 16px 0;
padding: 13px 0;
border-top: 1px solid var(--line);
border-bottom: 1px solid var(--line);
}
.explanation div {
display: grid;
grid-template-columns: 23px 1fr;
gap: 8px;
align-items: start;
}
.explanation b {
display: grid;
width: 21px;
height: 21px;
place-items: center;
border-radius: 50%;
background: #dde5df;
color: var(--teal);
font-size: 9px;
}
.explanation p {
margin: 0;
color: #526970;
font-size: 10px;
line-height: 1.5;
}
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px 12px;
margin-bottom: 14px;
}
.legend div {
display: flex;
align-items: center;
gap: 7px;
color: #526970;
font-size: 9px;
}
.swatch {
width: 12px;
height: 12px;
border: 1px solid rgba(16, 37, 46, 0.12);
}
.swatch.basalt {
background: #414b55;
}
.swatch.section {
background: #748087;
}
.swatch.water {
background: #4b9297;
}
.swatch.grass {
background: #7f9270;
}
.selection-readout {
padding: 10px;
border-left: 3px solid var(--accent);
background: rgba(215, 111, 71, 0.08);
color: #5a4b43;
font-size: 9px;
line-height: 1.5;
}
.selection-readout strong {
display: block;
margin-bottom: 2px;
color: var(--ink);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#leaders {
position: fixed;
inset: 0;
z-index: 3;
width: 100%;
height: 100%;
overflow: visible;
pointer-events: none;
}
#leaders line {
stroke: rgba(20, 48, 57, 0.68);
stroke-width: 1;
stroke-dasharray: 4 5;
vector-effect: non-scaling-stroke;
}
.callout {
position: absolute;
z-index: 4;
width: 188px;
padding: 9px 10px 10px;
transform: translateY(-50%);
border: 1px dashed rgba(16, 37, 46, 0.52);
background: rgba(247, 248, 241, 0.91);
box-shadow: 0 7px 22px rgba(22, 42, 48, 0.12);
opacity: 0;
pointer-events: none;
transition: opacity 160ms ease;
backdrop-filter: blur(7px);
}
.callout::before {
position: absolute;
top: 6px;
left: 7px;
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--accent);
content: "";
}
.callout .callout-index {
display: block;
margin-left: 12px;
color: var(--teal);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.callout strong {
display: block;
margin-top: 5px;
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
font-weight: 500;
line-height: 1.15;
}
.callout em {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
font-style: normal;
line-height: 1.35;
}
.interaction-hint {
position: absolute;
bottom: 21px;
left: 50%;
padding: 8px 12px;
transform: translateX(-50%);
border: 1px solid rgba(16, 37, 46, 0.15);
background: rgba(247, 248, 241, 0.72);
color: #526970;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
backdrop-filter: blur(7px);
}
.tooltip {
position: fixed;
z-index: 20;
max-width: 190px;
padding: 7px 9px;
transform: translate(12px, 12px);
background: var(--ink);
color: #f7f5e9;
font-size: 9px;
line-height: 1.4;
opacity: 0;
pointer-events: none;
transition: opacity 100ms ease;
}
.tooltip.visible {
opacity: 1;
}
.loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #dce6e4;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 400ms ease;
pointer-events: none;
}
body.ready .loading {
opacity: 0;
}
@media (max-width: 980px) {
.masthead p {
display: none;
}
.read-panel {
width: 240px;
}
.control-panel {
width: 270px;
}
.schema-stamp {
top: 83px;
}
}
@media (max-width: 720px) {
.masthead {
top: 17px;
left: 17px;
}
.masthead h1 {
font-size: 32px;
}
.schema-stamp {
top: 78px;
left: 17px;
transform: none;
font-size: 8px;
}
.control-panel {
top: auto;
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 43vh;
padding: 13px;
overflow: auto;
}
.control-panel .panel-heading {
margin-bottom: 10px;
padding-bottom: 9px;
}
.control-group {
margin-top: 12px;
}
.segmented button {
min-height: 47px;
}
.read-panel {
display: none;
}
.interaction-hint {
top: 117px;
bottom: auto;
font-size: 8px;
}
.callout {
width: 158px;
padding: 7px 8px 8px;
}
.callout strong {
font-size: 12px;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive three-dimensional columnar basalt coastal section. Drag to rotate, scroll to zoom, and click a basalt column to select it."
></canvas>
<svg id="leaders" aria-hidden="true">
<line id="cutLeader"></line>
<line id="jointLeader"></line>
<line id="tideLeader"></line>
</svg>
<div id="interface">
<header class="masthead">
<div class="eyebrow">Coastal forms / interactive study</div>
<h1>Columnar<br>Basalt</h1>
<p>
Rotate a stylized coastal cliff, alter relative column height and tide,
then peel back the front row to inspect column continuity.
</p>
</header>
<div class="schema-stamp">Schematic geology · not to scale</div>
<aside class="panel control-panel" aria-label="Model controls">
<div class="panel-heading">
<strong>Model controls</strong>
<span>01 / 03</span>
</div>
<div class="control-group">
<div class="control-label">
<span>Column height</span>
<span class="control-note">relative</span>
</div>
<div class="segmented" role="group" aria-label="Select column height profile">
<button type="button" data-profile="low" aria-pressed="false">
<span class="height-icon" aria-hidden="true"><i></i><i></i><i></i></span>
<span>Low</span>
</button>
<button type="button" data-profile="medium" class="active" aria-pressed="true">
<span class="height-icon" aria-hidden="true"><i></i><i></i><i></i></span>
<span>Medium</span>
</button>
<button type="button" data-profile="high" aria-pressed="false">
<span class="height-icon" aria-hidden="true"><i></i><i></i><i></i></span>
<span>Tall</span>
</button>
</div>
</div>
<div class="control-group">
<div class="control-label">
<label for="tide">Tide level</label>
<span id="tideOutput" class="control-note">Mid tide</span>
</div>
<div class="range-wrap">
<input
id="tide"
type="range"
min="0"
max="100"
value="48"
aria-label="Tide level"
>
<div class="range-labels">
<span>Low</span>
<span>High</span>
</div>
</div>
</div>
<div class="control-group">
<button
id="revealButton"
class="primary-button"
type="button"
aria-pressed="false"
>
<span>Reveal cut face</span>
<span class="button-icon" aria-hidden="true">+</span>
</button>
<div class="switch-row">
<span>Auto rotate</span>
<button
id="rotateToggle"
class="switch"
type="button"
aria-pressed="true"
aria-label="Toggle automatic rotation"
>
<span class="switch-dot" aria-hidden="true"></span>
</button>
</div>
<button id="resetButton" class="text-button" type="button">
Reset coastal view
</button>
</div>
</aside>
<aside class="panel read-panel" aria-label="Geological explanation">
<div class="panel-heading">
<strong>Read the section</strong>
<span>02 / 03</span>
</div>
<h2>Vertical order, local joints.</h2>
<p>
The cut face is an explanatory section, not a measured survey.
Column axes continue vertically while joints interrupt them at
different heights.
</p>
<div class="explanation">
<div>
<b>1</b>
<p>Cooling fractures organize the basalt into near-vertical columns.</p>
</div>
<div>
<b>2</b>
<p>Horizontal joints break individual columns without aligning across the whole stack.</p>
</div>
<div>
<b>3</b>
<p>The exposed section makes the column axes easier to follow from cap to base.</p>
</div>
</div>
<div class="legend" aria-label="Color legend">
<div><span class="swatch basalt"></span> Basalt</div>
<div><span class="swatch section"></span> Cut section</div>
<div><span class="swatch water"></span> Tide</div>
<div><span class="swatch grass"></span> Surface cap</div>
</div>
<div class="selection-readout" aria-live="polite">
<strong>Column inspection</strong>
<span id="selectionText">Click a basalt column to sample it.</span>
</div>
</aside>
<div id="cutLabel" class="callout">
<span class="callout-index">01 / schematic cut</span>
<strong>Continuous column axes</strong>
<em>Near-vertical cooling divisions are carried through the section.</em>
</div>
<div id="jointLabel" class="callout">
<span class="callout-index">02 / local joints</span>
<strong>Joints do not align</strong>
<em>Each vertical column can be interrupted at a different height.</em>
</div>
<div id="tideLabel" class="callout">
<span class="callout-index">03 / water level</span>
<strong id="tideLabelText">Mid tide</strong>
<em>Relative shoreline position, shown without metric scale.</em>
</div>
<div class="interaction-hint">Drag to rotate · scroll to zoom · click a column</div>
</div>
<div id="tooltip" class="tooltip"></div>
<div class="loading">Building coastal section…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce6e4);
scene.fog = new THREE.Fog(0xdce6e4, 16, 31);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const world = new THREE.Group();
scene.add(world);
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf4f1df, 0x536d73, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d5, 3.25);
sun.position.set(-6, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 32;
sun.shadow.bias = -0.00025;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x7fb7c1, 1.1);
rim.position.set(8, 5, -7);
scene.add(rim);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const basaltColors = [
0x3b4651,
0x424d58,
0x46515c,
0x353f49,
0x4b5560,
0x3e4853
];
const basaltMaterials = basaltColors.map(
(color) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.96,
metalness: 0.02,
flatShading: true
})
);
const darkCapMaterial = new THREE.MeshStandardMaterial({
color: 0x303942,
roughness: 1,
flatShading: true
});
const greenCapMaterial = new THREE.MeshStandardMaterial({
color: 0x829272,
roughness: 1,
flatShading: true
});
const soilCapMaterial = new THREE.MeshStandardMaterial({
color: 0x7e725f,
roughness: 1,
flatShading: true
});
const grassMaterial = new THREE.MeshStandardMaterial({
color: 0x647a60,
roughness: 1,
flatShading: true
});
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x263840,
roughness: 0.9,
flatShading: true
});
const pedestalTopMaterial = new THREE.MeshStandardMaterial({
color: 0x3a4b52,
roughness: 0.95,
flatShading: true
});
const seabedMaterial = new THREE.MeshStandardMaterial({
color: 0x8c8973,
roughness: 1,
flatShading: true
});
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4d969b,
roughness: 0.26,
metalness: 0.02,
transparent: true,
opacity: 0.86,
flatShading: true
});
const foamMaterial = new THREE.MeshBasicMaterial({
color: 0xd8eee7,
transparent: true,
opacity: 0.54
});
// -------------------------------------------------------------------------
// Base and coastal platform
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
new THREE.MeshStandardMaterial({
color: 0xdce6e4,
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.91;
ground.receiveShadow = true;
scene.add(ground);
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(11.25, 0.58, 8.7),
pedestalMaterial
);
pedestal.position.set(0, -0.58, 0);
pedestal.castShadow = true;
pedestal.receiveShadow = true;
world.add(pedestal);
const pedestalTop = new THREE.Mesh(
new THREE.BoxGeometry(10.95, 0.18, 8.4),
pedestalTopMaterial
);
pedestalTop.position.set(0, -0.21, 0);
pedestalTop.receiveShadow = true;
world.add(pedestalTop);
const pedestalEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(pedestal.geometry),
new THREE.LineBasicMaterial({
color: 0x789098,
transparent: true,
opacity: 0.27
})
);
pedestalEdges.position.copy(pedestal.position);
world.add(pedestalEdges);
const landFoundation = new THREE.Mesh(
new THREE.BoxGeometry(7.1, 0.34, 5.95),
basaltMaterials[0]
);
landFoundation.position.set(-1.62, -0.04, -1.64);
landFoundation.castShadow = true;
landFoundation.receiveShadow = true;
world.add(landFoundation);
const seabed = new THREE.Mesh(
new THREE.BoxGeometry(4.05, 0.26, 8.05),
seabedMaterial
);
seabed.position.set(3.43, -0.05, 0);
seabed.receiveShadow = true;
world.add(seabed);
// -------------------------------------------------------------------------
// Hexagonal basalt columns
// -------------------------------------------------------------------------
let seed = 83;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const columnBodyGeometry = new THREE.CylinderGeometry(
0.47,
0.50,
1,
6,
1,
false
);
const columnCapGeometry = new THREE.CylinderGeometry(
0.48,
0.48,
0.055,
6,
1,
false
);
const tuftGeometry = new THREE.ConeGeometry(0.075, 0.23, 3);
const columns = [];
const pickableMeshes = [];
for (let row = 0; row < 7; row++) {
const z = 0.65 - row * 0.83;
for (let index = 0; index < 8; index++) {
const stagger = row % 2 === 0 ? 0 : 0.415;
const x = -4.7 + index * 0.83 + stagger;
const group = new THREE.Group();
group.position.set(x, 0.055, z);
const bodyMaterial = basaltMaterials[
Math.floor(random() * basaltMaterials.length)
].clone();
const body = new THREE.Mesh(columnBodyGeometry, bodyMaterial);
body.position.y = 0.5;
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const surfaceType = random();
let capMaterial;
if (surfaceType < 0.28) {
capMaterial = greenCapMaterial;
} else if (surfaceType < 0.52) {
capMaterial = soilCapMaterial;
} else {
capMaterial = darkCapMaterial;
}
const cap = new THREE.Mesh(columnCapGeometry, capMaterial);
cap.position.y = 1.015;
cap.castShadow = true;
cap.receiveShadow = true;
group.add(cap);
if (surfaceType < 0.28 && random() > 0.28) {
const tuft = new THREE.Mesh(tuftGeometry, grassMaterial);
tuft.position.set(
(random() - 0.5) * 0.24,
1.13,
(random() - 0.5) * 0.24
);
tuft.rotation.y = random() * Math.PI;
tuft.castShadow = true;
group.add(tuft);
}
const baseHeight =
2.42 + (random() - 0.5) * 0.5 + Math.max(0, 1.6 - z) * 0.035;
const column = {
id: columns.length + 1,
group,
body,
cap,
baseHeight,
currentHeight: baseHeight,
front: row === 0,
selected: false
};
body.userData.column = column;
pickableMeshes.push(body);
columns.push(column);
world.add(group);
}
}
// -------------------------------------------------------------------------
// Low-poly shoreline rocks
// -------------------------------------------------------------------------
const shoreRockGeometry = new THREE.DodecahedronGeometry(0.42, 0);
const shoreRockMaterials = [
new THREE.MeshStandardMaterial({
color: 0x4c565a,
roughness: 1,
flatShading: true
}),
new THREE.MeshStandardMaterial({
color: 0x66716f,
roughness: 1,
flatShading: true
}),
new THREE.MeshStandardMaterial({
color: 0x3d484e,
roughness: 1,
flatShading: true
})
];
for (let i = 0; i < 19; i++) {
const rock = new THREE.Mesh(
shoreRockGeometry,
shoreRockMaterials[i % shoreRockMaterials.length]
);
const z = -4.1 + random() * 8.25;
const x = 1.57 + random() * 0.72;
rock.position.set(x, 0.12 + random() * 0.34, z);
rock.scale.set(
0.55 + random() * 0.8,
0.42 + random() * 0.8,
0.58 + random() * 0.85
);
rock.rotation.set(random(), random() * Math.PI, random());
rock.castShadow = true;
rock.receiveShadow = true;
world.add(rock);
}
// -------------------------------------------------------------------------
// Water, foam and schematic wave marks
// -------------------------------------------------------------------------
const water = new THREE.Mesh(
new THREE.BoxGeometry(4.05, 0.15, 8.05),
waterMaterial
);
water.position.set(3.43, 0.5, 0);
water.receiveShadow = true;
world.add(water);
const foamGroup = new THREE.Group();
world.add(foamGroup);
for (let i = 0; i < 12; i++) {
const foam = new THREE.Mesh(
new THREE.BoxGeometry(0.045, 0.015, 0.42 + random() * 0.55),
foamMaterial
);
foam.position.set(
1.55 + random() * 0.15,
0,
-3.85 + random() * 7.7
);
foam.rotation.y = (random() - 0.5) * 0.13;
foamGroup.add(foam);
}
const waveGroup = new THREE.Group();
world.add(waveGroup);
const waves = [];
for (let i = 0; i < 16; i++) {
const length = 0.25 + random() * 0.75;
const wave = new THREE.Mesh(
new THREE.BoxGeometry(length, 0.012, 0.025),
foamMaterial.clone()
);
wave.position.set(
2.0 + random() * 2.9,
0,
-3.8 + random() * 7.5
);
wave.rotation.y = (random() - 0.5) * 0.24;
wave.userData.phase = random() * Math.PI * 2;
wave.userData.baseX = wave.position.x;
waves.push(wave);
waveGroup.add(wave);
}
const tideMarkerMaterial = new THREE.LineDashedMaterial({
color: 0xd8eee7,
transparent: true,
opacity: 0.78,
dashSize: 0.14,
gapSize: 0.1
});
const tideMarker = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(1.63, 0, 3.05),
new THREE.Vector3(5.15, 0, 3.05)
]),
tideMarkerMaterial
);
tideMarker.computeLineDistances();
world.add(tideMarker);
// -------------------------------------------------------------------------
// Explanatory cut face
// -------------------------------------------------------------------------
const sectionGroup = new THREE.Group();
sectionGroup.position.set(0, 0.075, 0.365);
sectionGroup.visible = false;
world.add(sectionGroup);
const sectionMaterial = new THREE.MeshStandardMaterial({
color: 0x748087,
roughness: 1,
transparent: true,
opacity: 0,
flatShading: true,
depthWrite: false
});
const sectionFace = new THREE.Mesh(
new THREE.BoxGeometry(6.48, 1, 0.1),
sectionMaterial
);
sectionFace.position.set(-1.72, 0.5, 0);
sectionFace.renderOrder = 2;
sectionGroup.add(sectionFace);
const verticalJointMaterial = new THREE.LineBasicMaterial({
color: 0x26343c,
transparent: true,
opacity: 0
});
const horizontalJointMaterial = new THREE.LineBasicMaterial({
color: 0x35444b,
transparent: true,
opacity: 0
});
const sectionOutlineMaterial = new THREE.LineDashedMaterial({
color: 0xf0ead9,
transparent: true,
opacity: 0,
dashSize: 0.08,
gapSize: 0.05
});
const verticalStarts = [];
for (let x = -4.95; x <= 1.55; x += 0.83) {
verticalStarts.push(x);
}
verticalStarts.forEach((x) => {
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x, 0.025, 0.058),
new THREE.Vector3(x, 0.975, 0.058)
]),
verticalJointMaterial
);
line.renderOrder = 3;
sectionGroup.add(line);
});
// Offset horizontal joints emphasize that individual columns are
// interrupted independently rather than by a single continuous layer.
verticalStarts.slice(0, -1).forEach((x, i) => {
const jointCount = i % 3 === 0 ? 2 : 1;
for (let j = 0; j < jointCount; j++) {
const y = 0.22 + random() * 0.56;
const inset = 0.04 + random() * 0.13;
const length = 0.83 - inset * 2;
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x + inset, y, 0.061),
new THREE.Vector3(x + inset + length, y + (random() - 0.5) * 0.018, 0.061)
]),
horizontalJointMaterial
);
line.renderOrder = 3;
sectionGroup.add(line);
}
});
const sectionOutline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-4.96, 0.01, 0.065),
new THREE.Vector3(1.52, 0.01, 0.065),
new THREE.Vector3(1.52, 0.99, 0.065),
new THREE.Vector3(-4.96, 0.99, 0.065),
new THREE.Vector3(-4.96, 0.01, 0.065)
]),
sectionOutlineMaterial
);
sectionOutline.computeLineDistances();
sectionOutline.renderOrder = 4;
sectionGroup.add(sectionOutline);
// -------------------------------------------------------------------------
// Direct camera controls — no examples or addons
// -------------------------------------------------------------------------
const target = new THREE.Vector3(-0.15, 1.02, -0.35);
const defaultView = {
theta: 0.76,
phi: 1.03,
radius: 14.4
};
let theta = defaultView.theta;
let phi = defaultView.phi;
let radius = defaultView.radius;
let dragging = false;
let pointerMoved = false;
let autoRotate = true;
let previousPointer = { x: 0, y: 0 };
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerMoved = false;
previousPointer = { x: event.clientX, y: event.clientY };
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
if (Math.abs(dx) + Math.abs(dy) > 2) {
pointerMoved = true;
}
theta -= dx * 0.007;
phi = THREE.MathUtils.clamp(phi - dy * 0.005, 0.55, 1.37);
previousPointer = { x: event.clientX, y: event.clientY };
} else {
updateTooltip(event);
}
});
canvas.addEventListener("pointerup", (event) => {
dragging = false;
canvas.classList.remove("dragging");
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (!pointerMoved) {
const column = pickColumn(event);
if (column) {
selectColumn(column);
}
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
canvas.classList.remove("dragging");
});
canvas.addEventListener("pointerleave", () => {
tooltip.classList.remove("visible");
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius + event.deltaY * 0.008,
8.4,
20.5
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") theta += step;
if (event.key === "ArrowRight") theta -= step;
if (event.key === "ArrowUp") phi = THREE.MathUtils.clamp(phi - step, 0.55, 1.37);
if (event.key === "ArrowDown") phi = THREE.MathUtils.clamp(phi + step, 0.55, 1.37);
if (event.key === "+" || event.key === "=") radius = Math.max(8.4, radius - 0.6);
if (event.key === "-" || event.key === "_") radius = Math.min(20.5, radius + 0.6);
event.preventDefault();
});
// -------------------------------------------------------------------------
// Ray picking and column inspection
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const tooltip = document.getElementById("tooltip");
const selectionText = document.getElementById("selectionText");
let selectedColumn = null;
function setPointerFromEvent(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickColumn(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickableMeshes, false);
return hits.length ? hits[0].object.userData.column : null;
}
function updateTooltip(event) {
const column = pickColumn(event);
if (!column) {
tooltip.classList.remove("visible");
canvas.style.cursor = "grab";
return;
}
canvas.style.cursor = "pointer";
tooltip.textContent = `Column ${column.id} · click to inspect`;
tooltip.style.left = `${event.clientX}px`;
tooltip.style.top = `${event.clientY}px`;
tooltip.classList.add("visible");
}
function selectColumn(column) {
if (selectedColumn) {
selectedColumn.body.material.emissive.set(0x000000);
selectedColumn.body.material.emissiveIntensity = 0;
}
selectedColumn = column;
selectedColumn.body.material.emissive.set(0x245a66);
selectedColumn.body.material.emissiveIntensity = 0.55;
selectionText.textContent =
`Column ${column.id} sampled · ${profileLabel.toLowerCase()} relative height. ` +
`Column axes remain vertical through local joints.`;
}
// -------------------------------------------------------------------------
// UI state
// -------------------------------------------------------------------------
const heightButtons = [...document.querySelectorAll("[data-profile]")];
const revealButton = document.getElementById("revealButton");
const rotateToggle = document.getElementById("rotateToggle");
const resetButton = document.getElementById("resetButton");
const tideInput = document.getElementById("tide");
const tideOutput = document.getElementById("tideOutput");
const tideLabelText = document.getElementById("tideLabelText");
const profileFactors = {
low: 0.73,
medium: 1,
high: 1.28
};
let profileLabel = "Medium";
let targetProfileFactor = 1;
let currentProfileFactor = 1;
let revealTarget = 0;
let revealAmount = 0;
let tideTarget = 0.65;
let tideAmount = 0.65;
heightButtons.forEach((button) => {
button.addEventListener("click", () => {
const profile = button.dataset.profile;
targetProfileFactor = profileFactors[profile];
profileLabel =
profile.charAt(0).toUpperCase() + profile.slice(1);
heightButtons.forEach((item) => {
const active = item === button;
item.classList.toggle("active", active);
item.setAttribute("aria-pressed", String(active));
});
if (selectedColumn) {
selectionText.textContent =
`Column ${selectedColumn.id} sampled · ${profileLabel.toLowerCase()} relative height. ` +
`Column axes remain vertical through local joints.`;
}
});
});
function tideDescription(value) {
if (value < 34) return "Low tide";
if (value < 68) return "Mid tide";
return "High tide";
}
tideInput.addEventListener("input", () => {
const percent = Number(tideInput.value);
tideTarget = 0.18 + (percent / 100) * 1.27;
const description = tideDescription(percent);
tideOutput.textContent = description;
tideLabelText.textContent = description;
});
revealButton.addEventListener("click", () => {
revealTarget = revealTarget > 0.5 ? 0 : 1;
revealButton.classList.toggle("active", revealTarget > 0.5);
revealButton.setAttribute("aria-pressed", String(revealTarget > 0.5));
revealButton.querySelector("span:first-child").textContent =
revealTarget > 0.5 ? "Close cut face" : "Reveal cut face";
revealButton.querySelector(".button-icon").textContent =
revealTarget > 0.5 ? "−" : "+";
});
rotateToggle.addEventListener("click", () => {
autoRotate = !autoRotate;
rotateToggle.setAttribute("aria-pressed", String(autoRotate));
});
resetButton.addEventListener("click", () => {
theta = defaultView.theta;
phi = defaultView.phi;
radius = defaultView.radius;
target.set(-0.15, 1.02, -0.35);
updateCamera();
});
// -------------------------------------------------------------------------
// Projected schematic labels
// -------------------------------------------------------------------------
const cutAnchor = new THREE.Vector3(-2.35, 1.38, 0.49);
const jointAnchor = new THREE.Vector3(0.35, 0.78, 0.49);
const tideAnchor = new THREE.Vector3(3.45, 0.7, 2.85);
function placeCallout({
element,
line,
anchor,
dx,
dy,
opacity = 1,
visible = true
}) {
if (!visible || opacity <= 0.01) {
element.style.opacity = "0";
line.style.opacity = "0";
return;
}
const projected = anchor.clone().project(camera);
if (projected.z < -1 || projected.z > 1) {
element.style.opacity = "0";
line.style.opacity = "0";
return;
}
const screenX = (projected.x * 0.5 + 0.5) * window.innerWidth;
const screenY = (-projected.y * 0.5 + 0.5) * window.innerHeight;
const width = element.offsetWidth || 188;
const height = element.offsetHeight || 70;
const mobile = window.innerWidth < 720;
const offsetX = mobile ? dx * 0.62 : dx;
const offsetY = mobile ? dy * 0.62 : dy;
let labelX = screenX + offsetX;
let labelY = screenY + offsetY;
if (offsetX < 0) {
labelX -= width;
}
labelX = THREE.MathUtils.clamp(labelX, 10, window.innerWidth - width - 10);
labelY = THREE.MathUtils.clamp(labelY, 105, window.innerHeight - height - 55);
element.style.left = `${labelX}px`;
element.style.top = `${labelY}px`;
element.style.opacity = String(opacity);
const endpointX =
offsetX < 0 ? labelX + width : labelX;
const endpointY = labelY + height * 0.46;
line.setAttribute("x1", String(screenX));
line.setAttribute("y1", String(screenY));
line.setAttribute("x2", String(endpointX));
line.setAttribute("y2", String(endpointY));
line.style.opacity = String(opacity);
}
const cutLabel = document.getElementById("cutLabel");
const jointLabel = document.getElementById("jointLabel");
const tideLabel = document.getElementById("tideLabel");
const cutLeader = document.getElementById("cutLeader");
const jointLeader = document.getElementById("jointLeader");
const tideLeader = document.getElementById("tideLeader");
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-delta * 6);
if (autoRotate && !dragging && !window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
theta += delta * 0.105;
}
updateCamera();
currentProfileFactor = THREE.MathUtils.lerp(
currentProfileFactor,
targetProfileFactor,
smoothing
);
revealAmount = THREE.MathUtils.lerp(
revealAmount,
revealTarget,
smoothing
);
tideAmount = THREE.MathUtils.lerp(tideAmount, tideTarget, smoothing);
columns.forEach((column) => {
const desiredHeight = column.baseHeight * currentProfileFactor;
column.currentHeight = THREE.MathUtils.lerp(
column.currentHeight,
desiredHeight,
smoothing
);
const cutawayReduction = column.front ? 1 - revealAmount * 0.82 : 1;
column.group.scale.y = column.currentHeight * cutawayReduction;
});
const sectionHeight = 2.53 * currentProfileFactor;
sectionGroup.scale.y = sectionHeight;
sectionGroup.visible = revealAmount > 0.005;
sectionMaterial.opacity = revealAmount;
verticalJointMaterial.opacity = revealAmount * 0.7;
horizontalJointMaterial.opacity = revealAmount * 0.84;
sectionOutlineMaterial.opacity = revealAmount * 0.9;
water.position.y = tideAmount - 0.075;
foamGroup.position.y = tideAmount + 0.012;
waveGroup.position.y = tideAmount + 0.025;
tideMarker.position.y = tideAmount + 0.018;
waves.forEach((wave, index) => {
wave.position.x =
wave.userData.baseX +
Math.sin(clock.elapsedTime * 0.55 + wave.userData.phase) * 0.055;
wave.material.opacity = 0.32 + Math.sin(clock.elapsedTime + index) * 0.08;
});
renderer.render(scene, camera);
const sectionFacingCamera = camera.position.z > target.z - 0.15;
placeCallout({
element: cutLabel,
line: cutLeader,
anchor: cutAnchor,
dx: -220,
dy: -78,
opacity: revealAmount,
visible: sectionFacingCamera
});
placeCallout({
element: jointLabel,
line: jointLeader,
anchor: jointAnchor,
dx: 30,
dy: 60,
opacity: revealAmount,
visible: sectionFacingCamera
});
tideAnchor.y = tideAmount + 0.08;
placeCallout({
element: tideLabel,
line: tideLeader,
anchor: tideAnchor,
dx: 46,
dy: -56,
opacity: 1,
visible: true
});
requestAnimationFrame(animate);
}
// -------------------------------------------------------------------------
// Resize handling
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
requestAnimationFrame(() => {
document.body.classList.add("ready");
});
animate();
</script>
</body>
</html>
```