Prompt specification
Build or customize the Three.js 3D scene "Coastal navigator matching a horizon bearing" 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: Coastal navigator matching a horizon bearing
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/coastal-navigator-matching-a-horizon-bearing-x2246
Scene Description Prompt:
Show an ancient coastal navigator comparing sky and headland bearings in a cutaway exhibit, explicitly using modern geometric simplifications. Three.js from cdnjs; standalone HTML.
Working Three.js Starter (coastal-navigator-matching-a-horizon-bearing-x2246):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ancient Coastal Navigator — Cutaway Exhibit</title>
<style>
:root {
color-scheme: light;
--ink: #17323a;
--muted: #526a70;
--sky: #ef8a32;
--headland: #18aec4;
--paper: rgba(248, 247, 240, 0.91);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe7e7;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
color: var(--ink);
}
#title-card {
top: 22px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid rgba(23, 50, 58, 0.13);
border-radius: 15px;
background: var(--paper);
box-shadow: 0 14px 40px rgba(25, 50, 54, 0.13);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 7px;
color: #9a4e21;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(24px, 3vw, 34px);
font-weight: 600;
line-height: 1.08;
}
#title-card p {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.48;
}
#simplification-card {
left: 24px;
bottom: 24px;
width: min(390px, calc(100vw - 48px));
padding: 16px 18px;
border: 1px solid rgba(23, 50, 58, 0.12);
border-radius: 14px;
background: rgba(248, 247, 240, 0.94);
box-shadow: 0 12px 36px rgba(25, 50, 54, 0.12);
backdrop-filter: blur(12px);
}
#simplification-card h2 {
margin: 0 0 9px;
font-size: 12px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#simplification-card ol {
margin: 0;
padding-left: 19px;
color: #52676d;
font-size: 12px;
line-height: 1.55;
}
#simplification-card li + li {
margin-top: 5px;
}
.disclaimer {
margin-top: 10px !important;
padding-top: 9px;
border-top: 1px solid rgba(23, 50, 58, 0.12);
color: #7c5a45 !important;
font-size: 11px !important;
line-height: 1.4 !important;
}
#legend {
top: 24px;
right: 24px;
min-width: 205px;
padding: 14px 16px;
border: 1px solid rgba(23, 50, 58, 0.12);
border-radius: 13px;
background: rgba(248, 247, 240, 0.91);
box-shadow: 0 12px 34px rgba(25, 50, 54, 0.11);
backdrop-filter: blur(10px);
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
margin: 7px 0;
color: #4c6268;
font-size: 12px;
}
.swatch {
width: 27px;
height: 4px;
border-radius: 5px;
background: currentColor;
}
.swatch.dashed {
height: 0;
border-top: 3px dashed currentColor;
background: transparent;
}
.sky-color { color: var(--sky); }
.headland-color { color: var(--headland); }
.reference-color { color: #9eabad; }
#comparison {
margin-top: 11px;
padding-top: 10px;
border-top: 1px solid rgba(23, 50, 58, 0.12);
color: var(--ink);
font-size: 13px;
font-weight: 750;
}
#controls {
right: 24px;
bottom: 24px;
max-width: 240px;
color: rgba(23, 50, 58, 0.7);
font-size: 11px;
line-height: 1.5;
text-align: right;
}
#reset {
pointer-events: auto;
margin-top: 8px;
padding: 7px 11px;
border: 1px solid rgba(23, 50, 58, 0.18);
border-radius: 9px;
background: rgba(248, 247, 240, 0.92);
color: var(--ink);
font: inherit;
font-weight: 700;
cursor: pointer;
}
#reset:hover {
background: white;
}
@media (max-width: 800px) {
#title-card {
top: 12px;
left: 12px;
width: min(330px, calc(100vw - 24px));
padding: 13px 15px;
}
#title-card p,
#legend,
#controls {
display: none;
}
#simplification-card {
left: 12px;
bottom: 12px;
width: calc(100vw - 24px);
padding: 12px 14px;
}
#simplification-card ol {
font-size: 11px;
}
}
</style>
</head>
<body>
<div id="title-card" class="hud">
<div class="eyebrow">Cutaway concept exhibit</div>
<h1>Reading Sky and Shore</h1>
<p>
An ancient coastal observer compares the projected direction of a celestial
object with the bearing to a headland beacon.
</p>
</div>
<div id="legend" class="hud">
<div class="legend-row sky-color">
<span class="swatch dashed"></span>
<span>Projected sky sight line</span>
</div>
<div class="legend-row headland-color">
<span class="swatch"></span>
<span>Headland sight line</span>
</div>
<div class="legend-row reference-color">
<span class="swatch"></span>
<span>Horizontal reference</span>
</div>
<div id="comparison">β sky = β headland = 252°</div>
</div>
<div id="simplification-card" class="hud">
<h2>Modern geometric simplifications</h2>
<ol>
<li>The local sea horizon is treated as a flat horizontal plane.</li>
<li>
The sky bearing is the azimuth of the sun’s sight line after vertical
projection onto that plane.
</li>
<li>
The sky and headland bearings are copied to concentric arcs so their
angular sweeps can be compared directly.
</li>
<li>
One celestial object and one landmark are shown; refraction, parallax,
horizon curvature, and orbital corrections are omitted.
</li>
</ol>
<p class="disclaimer">
This is an explanatory geometric reconstruction, not a claim that the
ancient navigator used this exact instrument or projection method.
</p>
</div>
<div id="controls" class="hud">
Drag to orbit · Shift-drag or right-drag to pan<br>
Scroll to zoom · Double-click to reset
<br><button id="reset" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe7e7);
scene.fog = new THREE.Fog(0xdbe7e7, 27, 58);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xeaf6f7, 0x756650, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2d8, 3.4);
keyLight.position.set(7, 15, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -15;
keyLight.shadow.camera.right = 15;
keyLight.shadow.camera.top = 15;
keyLight.shadow.camera.bottom = -15;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 40;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x83c8d3, 0.85);
fillLight.position.set(-10, 7, -8);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Shared helpers and materials
// -------------------------------------------------------------------------
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
...options
});
const M = {
base: standard(0xcac1b2),
baseEdge: standard(0xa79d90),
rock: standard(0x81766a),
rockLight: standard(0xa08f79),
rockDark: standard(0x655e58),
soil: standard(0x84684d),
subsoil: standard(0xa17b56),
grass: standard(0x768d62),
grassLight: standard(0x8e9d70),
stone: standard(0xc7bda8),
stoneDark: standard(0x9d927f),
wood: standard(0x684631),
robe: standard(0xb55f36),
robeDark: standard(0x7c3e2d),
linen: standard(0xe3d2aa),
skin: standard(0xb77b56),
hair: standard(0x3d312a),
beard: standard(0x554239),
terracotta: standard(0xa85d3c),
sea: standard(0x3c9da9, {
transparent: true,
opacity: 0.48,
roughness: 0.24,
metalness: 0.08,
depthWrite: false,
side: THREE.DoubleSide
}),
seaSide: standard(0x4aa9b2, {
transparent: true,
opacity: 0.28,
roughness: 0.35,
depthWrite: false
}),
skyLine: new THREE.MeshBasicMaterial({ color: 0xef8a32 }),
headlandLine: new THREE.MeshBasicMaterial({ color: 0x19b6ca }),
referenceLine: new THREE.MeshBasicMaterial({
color: 0xdbe8e9,
transparent: true,
opacity: 0.9
}),
softReference: new THREE.MeshBasicMaterial({
color: 0x91aeb3,
transparent: true,
opacity: 0.72
})
};
const up = new THREE.Vector3(0, 1, 0);
function rod(a, b, radius, material, parent = scene) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 8),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(up, direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(w, h, d, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function dashedRod(a, b, material, dash = 0.18, gap = 0.13, radius = 0.023) {
const vector = new THREE.Vector3().subVectors(b, a);
const length = vector.length();
const direction = vector.clone().normalize();
const step = dash + gap;
const count = Math.floor(length / step);
for (let i = 0; i < count; i++) {
const start = a.clone().addScaledVector(direction, i * step);
const end = start.clone().addScaledVector(direction, dash);
rod(start, end, radius, material);
}
}
function makeGlowTexture() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
const gradient = ctx.createRadialGradient(64, 64, 4, 64, 64, 64);
gradient.addColorStop(0, "rgba(255,241,174,1)");
gradient.addColorStop(0.22, "rgba(255,205,99,0.8)");
gradient.addColorStop(0.55, "rgba(255,175,69,0.25)");
gradient.addColorStop(1, "rgba(255,160,50,0)");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 128, 128);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
// -------------------------------------------------------------------------
// Canvas text labels
// -------------------------------------------------------------------------
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(
text,
position,
{
height = 0.5,
textColor = "#f7f4e9",
background = "rgba(22, 43, 49, 0.88)",
accent = "#ffffff",
fontSize = 28,
maxWidth = 720
} = {}
) {
const measuring = document.createElement("canvas").getContext("2d");
const font = `700 ${fontSize}px system-ui, sans-serif`;
measuring.font = font;
const logicalWidth = Math.min(
maxWidth,
Math.ceil(measuring.measureText(text).width + 54)
);
const logicalHeight = 66;
const canvas = document.createElement("canvas");
canvas.width = logicalWidth * 2;
canvas.height = logicalHeight * 2;
const ctx = canvas.getContext("2d");
ctx.scale(2, 2);
roundedRect(ctx, 1, 1, logicalWidth - 2, logicalHeight - 2, 12);
ctx.fillStyle = background;
ctx.fill();
ctx.fillStyle = accent;
ctx.fillRect(0, 12, 6, logicalHeight - 24);
ctx.font = font;
ctx.textBaseline = "middle";
ctx.textAlign = "left";
ctx.fillStyle = textColor;
ctx.fillText(text, 21, logicalHeight / 2 + 1, logicalWidth - 34);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.position.copy(position);
sprite.scale.set(
(logicalWidth / logicalHeight) * height,
height,
1
);
sprite.renderOrder = 30;
scene.add(sprite);
return sprite;
}
// -------------------------------------------------------------------------
// Cutaway plinth, land, strata, and sea
// -------------------------------------------------------------------------
const backdrop = new THREE.Mesh(
new THREE.PlaneGeometry(100, 100),
standard(0xd4dfdf)
);
backdrop.rotation.x = -Math.PI / 2;
backdrop.position.y = -0.9;
backdrop.receiveShadow = true;
scene.add(backdrop);
box(17.7, 0.55, 10.25, M.base, 0, -0.57, 0);
box(17.85, 0.14, 10.4, M.baseEdge, 0, -0.86, 0);
// World-space footprint of the land, including an irregular coast.
const footprint = [
[0.8, -4.7],
[8.0, -4.7],
[8.0, 4.7],
[1.05, 3.4],
[0.38, 2.2],
[0.88, 1.0],
[0.34, 0.2],
[0.88, -1.0],
[0.42, -2.3]
];
const landShape = new THREE.Shape();
footprint.forEach(([x, z], i) => {
if (i === 0) landShape.moveTo(x, -z);
else landShape.lineTo(x, -z);
});
landShape.closePath();
const landGeometry = new THREE.ExtrudeGeometry(landShape, {
depth: 1.8,
bevelEnabled: false,
steps: 1,
curveSegments: 1
});
landGeometry.rotateX(-Math.PI / 2);
const land = new THREE.Mesh(landGeometry, [M.grass, M.rock]);
land.position.y = -0.2;
land.castShadow = true;
land.receiveShadow = true;
scene.add(land);
// Visible geological layers on the front cut face.
box(6.95, 0.24, 0.07, M.rockDark, 4.45, 0.02, 4.72);
box(6.92, 0.31, 0.075, M.soil, 4.45, 0.29, 4.725);
box(6.9, 0.26, 0.08, M.subsoil, 4.45, 0.57, 4.73);
box(6.88, 0.22, 0.085, M.rockLight, 4.45, 0.81, 4.735);
box(6.85, 0.18, 0.09, M.soil, 4.45, 1.01, 4.74);
box(6.82, 0.30, 0.095, M.grass, 4.45, 1.25, 4.745);
// Transparent water block makes the exhibit read as a cutaway.
const seaBlock = box(9.2, 1.28, 9.4, M.seaSide, -3.8, 0.39, 0);
seaBlock.castShadow = false;
const seaSurface = new THREE.Mesh(
new THREE.PlaneGeometry(9.2, 9.4),
M.sea
);
seaSurface.rotation.x = -Math.PI / 2;
seaSurface.position.set(-3.8, 1.045, 0);
seaSurface.receiveShadow = true;
scene.add(seaSurface);
// Front water section.
const seaSection = new THREE.Mesh(
new THREE.PlaneGeometry(9.18, 1.28),
M.seaSide
);
seaSection.position.set(-3.8, 0.39, 4.705);
scene.add(seaSection);
// Small wave marks.
let seed = 19;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
const waveGroup = new THREE.Group();
scene.add(waveGroup);
for (let i = 0; i < 34; i++) {
const x = -7.9 + random() * 7.9;
const z = -4.4 + random() * 8.8;
const length = 0.25 + random() * 0.85;
const points = [];
for (let j = 0; j < 6; j++) {
points.push(new THREE.Vector3(
x + length * (j / 5),
1.06 + Math.sin(j * 1.7) * 0.012,
z + Math.sin(j * 1.2) * 0.035
));
}
const wave = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0xd9f6f4,
transparent: true,
opacity: 0.22 + random() * 0.18
})
);
wave.userData.phase = random() * Math.PI * 2;
waveGroup.add(wave);
}
// -------------------------------------------------------------------------
// Coastal ruins and small artifacts
// -------------------------------------------------------------------------
function addColumn(x, z, height) {
box(0.75, 0.18, 0.75, M.stoneDark, x, 1.7, z);
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.29, height, 12),
M.stone
);
shaft.position.set(x, 1.82 + height / 2, z);
shaft.castShadow = true;
shaft.receiveShadow = true;
scene.add(shaft);
const capital = new THREE.Mesh(
new THREE.CylinderGeometry(0.37, 0.29, 0.2, 12),
M.stone
);
capital.position.set(x, 1.9 + height, z);
capital.castShadow = true;
scene.add(capital);
}
addColumn(4.15, -2.15, 1.55);
addColumn(5.65, -2.15, 0.95);
const fallenColumn = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.26, 1.15, 12),
M.stone
);
fallenColumn.rotation.z = Math.PI / 2;
fallenColumn.rotation.y = 0.24;
fallenColumn.position.set(3.15, 1.83, -1.05);
fallenColumn.castShadow = true;
scene.add(fallenColumn);
for (let i = 0; i < 12; i++) {
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(
0.10 + random() * 0.18,
0
),
i % 3 === 0 ? M.rockLight : M.stoneDark
);
rock.position.set(
2.0 + random() * 5.2,
1.68,
-4.0 + random() * 7.8
);
rock.rotation.set(random(), random(), random());
rock.scale.y = 0.65 + random() * 0.45;
rock.castShadow = true;
rock.receiveShadow = true;
scene.add(rock);
}
function addGrassTuft(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 1.61, z);
group.scale.setScalar(scale);
for (let i = 0; i < 4; i++) {
const blade = new THREE.Mesh(
new THREE.ConeGeometry(0.035, 0.25 + random() * 0.16, 3),
M.grassLight
);
blade.position.set((random() - 0.5) * 0.15, 0.12, (random() - 0.5) * 0.15);
blade.rotation.z = (random() - 0.5) * 0.5;
blade.castShadow = true;
group.add(blade);
}
scene.add(group);
}
[
[2.0, -3.7], [2.6, -3.4], [6.6, 3.2],
[6.0, 3.8], [4.8, -4.0], [1.7, 2.9]
].forEach(([x, z]) => addGrassTuft(x, z, 0.8 + random() * 0.7));
// Amphora.
const amphoraProfile = [
new THREE.Vector2(0.0, 0.0),
new THREE.Vector2(0.16, 0.03),
new THREE.Vector2(0.25, 0.22),
new THREE.Vector2(0.27, 0.43),
new THREE.Vector2(0.20, 0.65),
new THREE.Vector2(0.11, 0.79),
new THREE.Vector2(0.11, 0.92),
new THREE.Vector2(0.19, 1.0)
];
const amphora = new THREE.Mesh(
new THREE.LatheGeometry(amphoraProfile, 16),
M.terracotta
);
amphora.position.set(2.35, 1.61, 1.85);
amphora.castShadow = true;
scene.add(amphora);
const amphoraHandle = new THREE.Mesh(
new THREE.TorusGeometry(0.15, 0.035, 6, 14, Math.PI),
M.terracotta
);
amphoraHandle.position.set(2.35, 2.4, 1.85);
amphoraHandle.rotation.y = Math.PI / 2;
amphoraHandle.castShadow = true;
scene.add(amphoraHandle);
// Rope coil.
for (let i = 0; i < 3; i++) {
const rope = new THREE.Mesh(
new THREE.TorusGeometry(0.29 - i * 0.045, 0.025, 6, 28),
M.wood
);
rope.rotation.x = Math.PI / 2;
rope.position.set(6.3, 1.64 + i * 0.02, 1.3);
rope.castShadow = true;
scene.add(rope);
}
// -------------------------------------------------------------------------
// Ancient navigator
// -------------------------------------------------------------------------
const navigator = new THREE.Group();
navigator.position.set(0.98, 1.61, 0);
scene.add(navigator);
const robe = new THREE.Mesh(
new THREE.CylinderGeometry(0.30, 0.50, 1.34, 10),
M.robe
);
robe.position.y = 0.84;
robe.castShadow = true;
robe.receiveShadow = true;
navigator.add(robe);
const sash = new THREE.Mesh(
new THREE.CylinderGeometry(0.315, 0.35, 0.13, 10),
M.robeDark
);
sash.position.y = 1.03;
sash.castShadow = true;
navigator.add(sash);
const sashTail = box(0.13, 0.68, 0.06, M.robeDark, 0.27, 0.76, 0.12, navigator);
sashTail.rotation.z = -0.12;
// Sandals.
const footA = box(0.35, 0.10, 0.20, M.wood, -0.08, 0.06, 0.22, navigator);
const footB = box(0.35, 0.10, 0.20, M.wood, -0.08, 0.06, -0.22, navigator);
footA.castShadow = footB.castShadow = true;
const headGroup = new THREE.Group();
headGroup.position.set(-0.08, 1.91, 0);
headGroup.rotation.z = -0.12;
navigator.add(headGroup);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.29, 16, 12),
M.skin
);
head.scale.set(0.9, 1.08, 0.88);
head.castShadow = true;
headGroup.add(head);
const nose = new THREE.Mesh(
new THREE.ConeGeometry(0.075, 0.18, 6),
M.skin
);
nose.rotation.z = -Math.PI / 2;
nose.position.set(-0.28, 0.035, 0);
nose.castShadow = true;
headGroup.add(nose);
const hairCap = new THREE.Mesh(
new THREE.SphereGeometry(
0.305, 14, 8,
0, Math.PI * 2, 0, Math.PI * 0.53
),
M.hair
);
hairCap.position.y = 0.025;
hairCap.castShadow = true;
headGroup.add(hairCap);
const beard = new THREE.Mesh(
new THREE.ConeGeometry(0.23, 0.48, 8),
M.beard
);
beard.rotation.z = Math.PI / 2;
beard.position.set(-0.16, -0.19, 0);
beard.castShadow = true;
headGroup.add(beard);
// Tiny eyes on the west-facing side.
for (const z of [-0.115, 0.115]) {
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.025, 8, 6),
M.hair
);
eye.position.set(-0.225, 0.085, z);
headGroup.add(eye);
}
// Arms: one raised toward the sky, the other supporting a sighting tablet.
const shoulderSky = new THREE.Vector3(0.02, 1.43, 0.31);
const elbowSky = new THREE.Vector3(-0.38, 1.75, 0.39);
const handSky = new THREE.Vector3(-0.78, 2.25, 0.25);
const shoulderLand = new THREE.Vector3(0.02, 1.43, -0.31);
const elbowLand = new THREE.Vector3(-0.34, 1.58, -0.43);
const handLand = new THREE.Vector3(-0.73, 1.90, -0.19);
rod(shoulderSky, elbowSky, 0.095, M.skin, navigator);
rod(elbowSky, handSky, 0.082, M.skin, navigator);
rod(shoulderLand, elbowLand, 0.095, M.skin, navigator);
rod(elbowLand, handLand, 0.082, M.skin, navigator);
const handA = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 10, 8), M.skin
);
handA.position.copy(handSky);
navigator.add(handA);
const handB = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 10, 8), M.skin
);
handB.position.copy(handLand);
navigator.add(handB);
const tablet = box(0.10, 0.67, 0.54, M.wood, -0.76, 2.08, 0.03, navigator);
tablet.rotation.y = 0.11;
tablet.rotation.z = -0.11;
const tabletInset = box(
0.025, 0.50, 0.37, M.linen,
-0.825, 2.08, 0.03, navigator
);
tabletInset.rotation.copy(tablet.rotation);
// A short sighting staff and plumb line.
rod(
new THREE.Vector3(-0.67, 1.43, 0.02),
new THREE.Vector3(-1.14, 2.85, 0.13),
0.031,
M.wood,
navigator
);
const plumb = rod(
new THREE.Vector3(-0.81, 1.80, 0.10),
new THREE.Vector3(-0.82, 1.18, 0.11),
0.009,
M.referenceLine,
navigator
);
plumb.castShadow = false;
const plumbBob = new THREE.Mesh(
new THREE.ConeGeometry(0.055, 0.16, 8),
M.stoneDark
);
plumbBob.position.set(-0.82, 1.12, 0.11);
plumbBob.rotation.z = Math.PI;
navigator.add(plumbBob);
// -------------------------------------------------------------------------
// Headland island and ancient beacon
// -------------------------------------------------------------------------
const azimuth = THREE.MathUtils.degToRad(252);
const bearingDirection = new THREE.Vector3(
Math.sin(azimuth),
0,
-Math.cos(azimuth)
);
const observerEye = new THREE.Vector3(0.88, 3.72, 0);
const headlandHorizontal = observerEye.clone()
.addScaledVector(bearingDirection, 8.3);
headlandHorizontal.y = 3.72;
const islandCenter = new THREE.Vector3(
headlandHorizontal.x,
1.06,
headlandHorizontal.z
);
const island = new THREE.Mesh(
new THREE.ConeGeometry(1.48, 1.42, 8),
M.rock
);
island.position.copy(islandCenter).add(new THREE.Vector3(0, 0.70, 0));
island.rotation.y = 0.23;
island.castShadow = true;
island.receiveShadow = true;
scene.add(island);
for (let i = 0; i < 8; i++) {
const angle = random() * Math.PI * 2;
const radius = 0.7 + random() * 0.65;
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.16 + random() * 0.22, 0),
i % 2 ? M.rockLight : M.rockDark
);
rock.position.set(
islandCenter.x + Math.cos(angle) * radius,
1.10 + random() * 0.35,
islandCenter.z + Math.sin(angle) * radius
);
rock.rotation.set(random(), random(), random());
rock.castShadow = true;
scene.add(rock);
}
const beaconBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.49, 0.57, 0.25, 8),
M.stoneDark
);
beaconBase.position.set(headlandHorizontal.x, 2.43, headlandHorizontal.z);
beaconBase.castShadow = true;
scene.add(beaconBase);
const beaconShaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.27, 0.36, 1.02, 8),
M.stone
);
beaconShaft.position.set(headlandHorizontal.x, 3.03, headlandHorizontal.z);
beaconShaft.castShadow = true;
scene.add(beaconShaft);
const beaconTop = new THREE.Mesh(
new THREE.CylinderGeometry(0.38, 0.28, 0.18, 8),
M.stone
);
beaconTop.position.set(headlandHorizontal.x, 3.63, headlandHorizontal.z);
beaconTop.castShadow = true;
scene.add(beaconTop);
const beaconFlag = new THREE.Mesh(
new THREE.ConeGeometry(0.22, 0.56, 3),
M.robe
);
beaconFlag.rotation.z = -Math.PI / 2;
beaconFlag.position.set(
headlandHorizontal.x + 0.40,
3.54,
headlandHorizontal.z
);
beaconFlag.castShadow = true;
scene.add(beaconFlag);
// -------------------------------------------------------------------------
// Sky object and modern geometric construction
// -------------------------------------------------------------------------
const skyDistance = 10;
const skyRise = 9;
const skyPosition = observerEye.clone()
.addScaledVector(bearingDirection, skyDistance)
.add(new THREE.Vector3(0, skyRise, 0));
const skyProjection = observerEye.clone()
.addScaledVector(bearingDirection, skyDistance);
skyProjection.y = observerEye.y;
const sun = new THREE.Mesh(
new THREE.SphereGeometry(0.48, 24, 16),
new THREE.MeshBasicMaterial({ color: 0xffd16d })
);
sun.position.copy(skyPosition);
scene.add(sun);
const sunGlow = new THREE.Sprite(
new THREE.SpriteMaterial({
map: makeGlowTexture(),
transparent: true,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
sunGlow.position.copy(skyPosition);
sunGlow.scale.set(4.4, 4.4, 1);
scene.add(sunGlow);
const sunLight = new THREE.PointLight(0xffc45f, 2.2, 24, 2);
sunLight.position.copy(skyPosition);
scene.add(sunLight);
// Main sky and headland sight lines.
dashedRod(observerEye, skyPosition, M.skyLine, 0.20, 0.14, 0.027);
dashedRod(observerEye, skyProjection, M.skyLine, 0.18, 0.13, 0.021);
dashedRod(skyProjection, skyPosition, M.skyLine, 0.18, 0.13, 0.021);
rod(observerEye, headlandHorizontal, 0.027, M.headlandLine);
// North reference.
const northEnd = observerEye.clone().add(new THREE.Vector3(0, 0, -4.2));
dashedRod(observerEye, northEnd, M.softReference, 0.16, 0.12, 0.014);
// Compass/protractor ring on the horizontal plane through the observer.
const compassRing = new THREE.Mesh(
new THREE.TorusGeometry(1.88, 0.009, 6, 128),
new THREE.MeshBasicMaterial({
color: 0xc8d9da,
transparent: true,
opacity: 0.70
})
);
compassRing.rotation.x = Math.PI / 2;
compassRing.position.copy(observerEye);
scene.add(compassRing);
// Thirty-degree ticks.
for (let degrees = 0; degrees < 360; degrees += 30) {
const angle = THREE.MathUtils.degToRad(degrees);
const direction = new THREE.Vector3(
Math.sin(angle),
0,
-Math.cos(angle)
);
const a = observerEye.clone().addScaledVector(direction, 1.77);
const b = observerEye.clone().addScaledVector(direction, 1.88);
rod(a, b, 0.009, M.softReference);
}
// Thick torus arcs: the copied sky and headland angular sweeps.
function bearingArc(radius, tube, material) {
const geometry = new THREE.TorusGeometry(
radius,
tube,
8,
128,
azimuth
);
geometry.rotateX(Math.PI / 2);
geometry.rotateY(Math.PI / 2);
const arc = new THREE.Mesh(geometry, material);
arc.position.copy(observerEye);
scene.add(arc);
return arc;
}
bearingArc(1.72, 0.020, M.skyLine);
bearingArc(1.55, 0.021, M.headlandLine);
// Connect equal-angle arc endpoints.
const arcStartOuter = observerEye.clone()
.add(new THREE.Vector3(0, 0, -1.72));
const arcStartInner = observerEye.clone()
.add(new THREE.Vector3(0, 0, -1.55));
const arcEndOuter = observerEye.clone()
.addScaledVector(bearingDirection, 1.72);
const arcEndInner = observerEye.clone()
.addScaledVector(bearingDirection, 1.55);
rod(arcStartOuter, arcStartInner, 0.011, M.softReference);
rod(arcEndOuter, arcEndInner, 0.011, M.softReference);
// Vertical altitude arc.
const altitude = Math.atan2(skyRise, skyDistance);
const altitudeArcGeometry = new THREE.TorusGeometry(
1.52,
0.020,
8,
96,
altitude
);
const planeBasis = new THREE.Matrix4().makeBasis(
bearingDirection,
up,
new THREE.Vector3().crossVectors(bearingDirection, up).normalize()
);
const altitudeArc = new THREE.Mesh(
altitudeArcGeometry,
M.skyLine
);
altitudeArc.quaternion.setFromRotationMatrix(planeBasis);
altitudeArc.position.copy(observerEye);
scene.add(altitudeArc);
// Altitude baseline and small ticks.
const altitudeBaselineEnd = observerEye.clone()
.addScaledVector(bearingDirection, 1.72);
dashedRod(
observerEye,
altitudeBaselineEnd,
M.softReference,
0.10,
0.08,
0.010
);
for (let degrees = 0; degrees <= 40; degrees += 10) {
const angle = THREE.MathUtils.degToRad(degrees);
const radial = bearingDirection.clone().multiplyScalar(Math.cos(angle))
.addScaledVector(up, Math.sin(angle));
const a = observerEye.clone().addScaledVector(radial, 1.43);
const b = observerEye.clone().addScaledVector(radial, 1.61);
rod(a, b, 0.009, M.skyLine);
}
// -------------------------------------------------------------------------
// Exhibit labels
// -------------------------------------------------------------------------
makeLabel(
"SUN / CELESTIAL OBJECT",
skyPosition.clone().add(new THREE.Vector3(-0.1, 0.85, 0)),
{
height: 0.55,
accent: "#ef8a32",
background: "rgba(32, 44, 47, 0.91)"
}
);
makeLabel(
"HEADLAND BEACON",
headlandHorizontal.clone().add(new THREE.Vector3(0, 0.95, 0)),
{
height: 0.54,
accent: "#19b6ca",
background: "rgba(25, 52, 58, 0.92)"
}
);
makeLabel(
"ANCIENT OBSERVER",
new THREE.Vector3(1.02, 4.85, -0.05),
{
height: 0.55,
accent: "#b55f36",
background: "rgba(39, 47, 45, 0.91)"
}
);
makeLabel(
"β SKY = 252°",
observerEye.clone()
.addScaledVector(bearingDirection, 2.05)
.add(new THREE.Vector3(0, 0.35, 0)),
{
height: 0.48,
accent: "#ef8a32",
background: "rgba(44, 43, 38, 0.92)"
}
);
makeLabel(
"β HEADLAND = 252°",
observerEye.clone()
.addScaledVector(bearingDirection, 1.72)
.add(new THREE.Vector3(0, -0.38, 0.12)),
{
height: 0.48,
accent: "#19b6ca",
background: "rgba(25, 48, 52, 0.92)"
}
);
const altitudeLabelPosition = observerEye.clone()
.addScaledVector(bearingDirection, 1.95 * Math.cos(altitude * 0.72))
.addScaledVector(up, 1.95 * Math.sin(altitude * 0.72))
.add(new THREE.Vector3(0, 0.28, 0));
makeLabel(
"α ≈ 42° · APPARENT ALTITUDE",
altitudeLabelPosition,
{
height: 0.50,
accent: "#ef8a32",
background: "rgba(44, 43, 38, 0.92)"
}
);
makeLabel(
"FLAT HORIZON PROJECTION",
observerEye.clone()
.addScaledVector(bearingDirection, 4.25)
.add(new THREE.Vector3(0, -0.54, 0.40)),
{
height: 0.43,
accent: "#91aeb3",
background: "rgba(32, 48, 51, 0.89)",
fontSize: 25
}
);
makeLabel(
"N",
observerEye.clone().add(new THREE.Vector3(0, 0.23, -2.16)),
{
height: 0.40,
accent: "#dbe8e9",
background: "rgba(32, 48, 51, 0.88)"
}
);
// A few distant seabirds provide scale without external assets.
function addBird(x, y, z, scale = 1) {
const points = [
new THREE.Vector3(x - 0.20 * scale, y, z),
new THREE.Vector3(x, y + 0.07 * scale, z),
new THREE.Vector3(x + 0.20 * scale, y, z)
];
const bird = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0x557176,
transparent: true,
opacity: 0.75
})
);
scene.add(bird);
}
addBird(-3.2, 8.8, -2.0, 1.0);
addBird(-2.7, 9.1, -2.4, 0.75);
addBird(-3.7, 9.4, -1.6, 0.58);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, and reset
// -------------------------------------------------------------------------
const cameraHome = {
target: new THREE.Vector3(-1.25, 3.15, 0.30),
radius: 21.0,
theta: 0.72,
phi: 1.13
};
const cameraState = {
target: cameraHome.target.clone(),
radius: cameraHome.radius,
theta: cameraHome.theta,
phi: cameraHome.phi
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.target.copy(cameraHome.target);
cameraState.radius = cameraHome.radius;
cameraState.theta = cameraHome.theta;
cameraState.phi = cameraHome.phi;
updateCamera();
}
updateCamera();
const canvas = renderer.domElement;
let drag = null;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
drag = {
id: event.pointerId,
x: event.clientX,
y: event.clientY,
button: event.button,
pan: event.shiftKey || event.button === 2
};
});
canvas.addEventListener("pointermove", event => {
if (!drag || drag.id !== event.pointerId) return;
const dx = event.clientX - drag.x;
const dy = event.clientY - drag.y;
drag.x = event.clientX;
drag.y = event.clientY;
if (drag.pan || event.shiftKey) {
const forward = new THREE.Vector3()
.subVectors(cameraState.target, camera.position)
.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, up)
.normalize();
const panScale = cameraState.radius * 0.0014;
cameraState.target.addScaledVector(right, -dx * panScale);
cameraState.target.addScaledVector(up, dy * panScale);
} else {
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.34,
1.46
);
}
updateCamera();
});
function endDrag(event) {
if (drag && drag.id === event.pointerId) drag = null;
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
10,
31
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
document.getElementById("reset").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", resize);
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
if (!reducedMotion) {
sunGlow.material.opacity = 0.78 + Math.sin(elapsed * 1.5) * 0.10;
beaconFlag.rotation.y = Math.sin(elapsed * 1.8) * 0.12;
waveGroup.position.y = Math.sin(elapsed * 0.7) * 0.012;
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```