Prompt specification
Build or customize the Three.js 3D scene "Island voyage with environmental navigation cues" 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: Island voyage with environmental navigation cues
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/island-voyage-with-environmental-navigation-cues-x2611
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Polynesian ocean voyaging and island navigation. Build a schematic ocean scene linking departure island, vessel, star bearings, and swell direction. Clearly label cues as selected examples rather than a complete navigation method. Low-poly.
Working Three.js Starter (island-voyage-with-environmental-navigation-cues-x2611):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Polynesian Ocean Voyaging — Schematic Navigation Scene</title>
<style>
:root {
--ink: #edf6f4;
--muted: #a9c0c6;
--panel: rgba(8, 24, 36, 0.82);
--panel-border: rgba(173, 221, 220, 0.22);
--gold: #ffd38a;
--aqua: #77e1dd;
--coral: #ff9a76;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #081827;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#stage,
#labels {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
#labels {
pointer-events: none;
z-index: 4;
overflow: hidden;
}
#labels.labels-off .scene-label {
opacity: 0;
}
.panel {
position: fixed;
z-index: 8;
background: var(--panel);
border: 1px solid var(--panel-border);
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.title-panel {
top: 22px;
left: 22px;
width: min(430px, calc(100vw - 44px));
padding: 20px 22px 18px;
border-radius: 4px 18px 18px 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--aqua);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
content: "";
background: var(--aqua);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(26px, 3vw, 39px);
font-weight: 500;
line-height: 1.05;
letter-spacing: -0.025em;
}
.subtitle {
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.badge {
display: inline-flex;
margin-top: 15px;
padding: 6px 9px;
border: 1px solid rgba(255, 211, 138, 0.34);
border-radius: 999px;
color: var(--gold);
background: rgba(255, 211, 138, 0.07);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.legend-panel {
top: 22px;
right: 22px;
width: min(325px, calc(100vw - 44px));
padding: 17px 18px;
border-radius: 18px 4px 18px 18px;
}
.legend-panel h2 {
margin: 0 0 13px;
color: var(--ink);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-item {
display: grid;
grid-template-columns: 29px 1fr;
gap: 9px;
margin: 10px 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.legend-item strong {
display: block;
margin-bottom: 2px;
color: var(--ink);
font-size: 11px;
font-weight: 700;
}
.legend-number {
display: grid;
width: 27px;
height: 27px;
place-items: center;
border: 1px solid rgba(119, 225, 221, 0.35);
border-radius: 50%;
color: var(--aqua);
font-family: ui-monospace, monospace;
font-size: 9px;
}
.legend-note {
margin: 14px 0 0;
padding-top: 13px;
border-top: 1px solid rgba(255, 255, 255, 0.11);
color: #c7d6d7;
font-size: 10px;
line-height: 1.55;
}
.legend-note strong {
color: var(--gold);
}
.scene-label {
position: absolute;
width: max-content;
max-width: 210px;
padding: 7px 9px;
transform: translate(-50%, -50%);
border-left: 2px solid var(--aqua);
border-radius: 2px 7px 7px 2px;
background: rgba(6, 20, 31, 0.78);
box-shadow: 0 7px 24px rgba(0, 0, 0, 0.18);
color: #f3f8f5;
font-size: 10px;
font-weight: 700;
line-height: 1.35;
letter-spacing: 0.025em;
white-space: nowrap;
transition: opacity 180ms ease;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.scene-label.star {
border-left-color: var(--gold);
color: #ffe3ad;
}
.scene-label.swell {
border-left-color: var(--coral);
color: #ffd0bd;
}
.scene-label.island {
border-left-color: #b7e493;
}
.scene-label.compass {
padding: 3px 6px;
border: 0;
border-radius: 50%;
background: rgba(5, 18, 29, 0.64);
color: rgba(225, 241, 238, 0.78);
font-family: ui-monospace, monospace;
font-size: 9px;
box-shadow: none;
}
.controls {
position: fixed;
right: 22px;
bottom: 74px;
z-index: 9;
display: flex;
gap: 8px;
}
button {
border: 1px solid rgba(173, 221, 220, 0.28);
border-radius: 8px;
padding: 9px 12px;
background: rgba(8, 24, 36, 0.86);
box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover {
border-color: var(--aqua);
color: var(--aqua);
}
.hint {
position: fixed;
left: 22px;
bottom: 74px;
z-index: 8;
color: rgba(226, 240, 239, 0.7);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
text-shadow: 0 2px 8px #000;
}
.disclaimer {
position: fixed;
right: 22px;
bottom: 20px;
left: 22px;
z-index: 9;
padding: 11px 15px;
border: 1px solid rgba(255, 211, 138, 0.24);
border-radius: 9px;
background: rgba(8, 22, 32, 0.88);
color: #bdcdce;
font-size: 10px;
line-height: 1.5;
text-align: center;
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.disclaimer strong {
color: var(--gold);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #081827;
color: var(--aqua);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 16px;
}
.title-panel h1 {
max-width: 75%;
font-size: 26px;
}
.subtitle {
max-width: 85%;
font-size: 10px;
}
.legend-panel {
top: auto;
right: 12px;
bottom: 112px;
width: 245px;
padding: 12px 13px;
}
.legend-panel h2 {
margin-bottom: 7px;
}
.legend-item {
margin: 7px 0;
font-size: 9px;
}
.legend-item strong {
font-size: 9px;
}
.legend-note {
display: none;
}
.controls {
right: 12px;
bottom: 73px;
}
.hint {
left: 12px;
bottom: 80px;
max-width: 110px;
line-height: 1.5;
}
.disclaimer {
right: 12px;
bottom: 12px;
left: 12px;
font-size: 9px;
}
.scene-label {
max-width: 155px;
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div id="labels" aria-hidden="true"></div>
<header class="panel title-panel">
<div class="eyebrow">Ocean voyaging study</div>
<h1>Reading the Open Ocean</h1>
<p class="subtitle">
A low-poly schematic linking a departure island, a voyaging canoe,
illustrative stellar bearing rays, and a selected swell pattern.
</p>
<span class="badge">Schematic · selected examples only</span>
</header>
<aside class="panel legend-panel">
<h2>Selected cue examples</h2>
<div class="legend-item">
<span class="legend-number">01</span>
<div>
<strong>Departure landmark</strong>
Shoreline profile and nearby land provide context.
</div>
</div>
<div class="legend-item">
<span class="legend-number">02</span>
<div>
<strong>Voyaging canoe</strong>
Links the departure point with open-ocean observations.
</div>
</div>
<div class="legend-item">
<span class="legend-number">03</span>
<div>
<strong>Selected stellar bearings</strong>
Two example sight rays; not calibrated to a real sky.
</div>
</div>
<div class="legend-item">
<span class="legend-number">04</span>
<div>
<strong>Selected swell cue</strong>
An illustrative SW → NE pattern bending near land.
</div>
</div>
<p class="legend-note">
<strong>These are visual examples only.</strong>
They are not a complete navigation method and do not describe one
specific historical voyage, season, island chain, or celestial sky.
</p>
</aside>
<div class="hint">Drag to orbit · scroll to zoom · arrows to move</div>
<div class="controls">
<button id="reset-view" type="button">Reset view</button>
<button id="toggle-labels" type="button">Hide labels</button>
</div>
<div class="disclaimer">
<strong>Selected examples only — not a complete navigation method.</strong>
Real wayfinding can combine stars, swell, wind, island profiles, and learned
patterns; this scene intentionally presents only a few illustrative cues.
</div>
<div id="loading">Charting the scene…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const stage = document.querySelector("#stage");
const labelRoot = document.querySelector("#labels");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x081827);
scene.fog = new THREE.FogExp2(0x173247, 0.012);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
180
);
const hemiLight = new THREE.HemisphereLight(0x8fc9df, 0x10292d, 1.7);
scene.add(hemiLight);
const sunLight = new THREE.DirectionalLight(0xffd2a0, 2.5);
sunLight.position.set(-18, 30, 16);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(1024, 1024);
sunLight.shadow.camera.left = -35;
sunLight.shadow.camera.right = 35;
sunLight.shadow.camera.top = 35;
sunLight.shadow.camera.bottom = -35;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 90;
sunLight.shadow.bias = -0.0004;
scene.add(sunLight);
const rimLight = new THREE.DirectionalLight(0x58d8d5, 0.9);
rimLight.position.set(22, 12, -25);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Deterministic helpers
// -------------------------------------------------------------------------
function mulberry32(seed) {
return function () {
let t = seed += 0x6D2B79F5;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const rand = mulberry32(73421);
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
// -------------------------------------------------------------------------
// Faceted twilight sky
// -------------------------------------------------------------------------
function createSky() {
const geometry = new THREE.SphereGeometry(90, 32, 16);
const positions = geometry.attributes.position;
const colors = [];
const horizon = new THREE.Color(0xc66f62);
const zenith = new THREE.Color(0x10233f);
const deep = new THREE.Color(0x071622);
const color = new THREE.Color();
for (let i = 0; i < positions.count; i++) {
const y = positions.getY(i);
const h = clamp(y / 58, -1, 1);
if (h >= 0) {
color.copy(horizon).lerp(zenith, Math.pow(h, 0.56));
} else {
color.copy(horizon).lerp(deep, Math.pow(-h, 0.42));
}
colors.push(color.r, color.g, color.b);
}
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
const material = new THREE.MeshBasicMaterial({
vertexColors: true,
side: THREE.BackSide,
fog: false,
flatShading: true
});
const sky = new THREE.Mesh(geometry, material);
sky.renderOrder = -10;
scene.add(sky);
}
createSky();
// Background stars are decorative; highlighted stars are the selected cues.
{
const positions = [];
const starRandom = mulberry32(1894);
for (let i = 0; i < 260; i++) {
const radius = 58 + starRandom() * 16;
const angle = starRandom() * Math.PI * 2;
const y = 9 + starRandom() * 47;
positions.push(
Math.cos(angle) * radius,
y,
Math.sin(angle) * radius
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
const material = new THREE.PointsMaterial({
color: 0xcde6ef,
size: 0.24,
transparent: true,
opacity: 0.75,
depthWrite: false,
fog: false,
sizeAttenuation: true
});
scene.add(new THREE.Points(geometry, material));
}
// -------------------------------------------------------------------------
// Faceted ocean
// -------------------------------------------------------------------------
const oceanSize = 90;
const oceanSegments = 32;
const oceanPlane = new THREE.PlaneGeometry(
oceanSize,
oceanSize,
oceanSegments,
oceanSegments
);
oceanPlane.rotateX(-Math.PI / 2);
const oceanGeometry = oceanPlane.toNonIndexed();
const oceanPositions = oceanGeometry.attributes.position;
const oceanBase = new Float32Array(oceanPositions.count * 2);
const oceanColors = [];
for (let i = 0; i < oceanPositions.count; i++) {
oceanBase[i * 2] = oceanPositions.getX(i);
oceanBase[i * 2 + 1] = oceanPositions.getZ(i);
const color = new THREE.Color();
color.setHSL(
0.525 + rand() * 0.025,
0.42 + rand() * 0.14,
0.19 + rand() * 0.075
);
// Give every triangular face one color for a strong low-poly read.
for (let vertex = 0; vertex < 3; vertex++) {
oceanColors.push(color.r, color.g, color.b);
}
}
oceanGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(oceanColors, 3)
);
const oceanMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.88,
metalness: 0.08,
flatShading: true
});
const ocean = new THREE.Mesh(oceanGeometry, oceanMaterial);
ocean.receiveShadow = true;
scene.add(ocean);
function waveHeight(x, z, time) {
return (
0.09 * Math.sin(x * 0.42 + z * 0.22 + time * 0.55) +
0.12 * Math.sin((x - z) * 0.31 - time * 0.43) +
0.045 * Math.sin(z * 0.87 + time * 0.72)
);
}
// -------------------------------------------------------------------------
// Low-poly islands and palms
// -------------------------------------------------------------------------
function createIsland(radius, x, z, seed, withPalms = true) {
const group = new THREE.Group();
group.position.set(x, 0, z);
const segments = 14;
const rings = [
{ r: 1.05, y: 0.02, color: 0xc8b779 },
{ r: 0.83, y: 0.38, color: 0x786b58 },
{ r: 0.58, y: 0.98, color: 0x6f9357 },
{ r: 0.25, y: 1.52, color: 0x789c5d }
];
const positions = [];
const colors = [];
function ringPoint(ringIndex, angle) {
const ring = rings[ringIndex];
return new THREE.Vector3(
Math.cos(angle) * ring.r * radius,
ring.y,
Math.sin(angle) * ring.r * radius
);
}
function addTriangle(a, b, c, colorValue) {
positions.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
const color = new THREE.Color(colorValue);
for (let i = 0; i < 3; i++) {
colors.push(color.r, color.g, color.b);
}
}
for (let ring = 0; ring < rings.length - 1; ring++) {
for (let i = 0; i < segments; i++) {
const a = (i / segments) * Math.PI * 2;
const b = ((i + 1) / segments) * Math.PI * 2;
const p00 = ringPoint(ring, a);
const p01 = ringPoint(ring, b);
const p10 = ringPoint(ring + 1, a);
const p11 = ringPoint(ring + 1, b);
const color = new THREE.Color(rings[ring].color);
color.offsetHSL((rand() - 0.5) * 0.025, 0, (rand() - 0.5) * 0.06);
addTriangle(p00, p01, p11, color);
addTriangle(p00, p11, p10, color);
}
}
const top = new THREE.Vector3(0, 1.67, 0);
const topColor = new THREE.Color(0x789c5d);
for (let i = 0; i < segments; i++) {
const a = (i / segments) * Math.PI * 2;
const b = ((i + 1) / segments) * Math.PI * 2;
addTriangle(ringPoint(rings.length - 1, a), ringPoint(rings.length - 1, b), top, topColor);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.computeVertexNormals();
const land = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
})
);
land.castShadow = true;
land.receiveShadow = true;
group.add(land);
// Irregular surf around the shore.
const foamPoints = [];
for (let i = 0; i <= 64; i++) {
const angle = (i / 64) * Math.PI * 2;
const wobble = 1.09 + 0.07 * Math.sin(angle * 5 + seed);
foamPoints.push(
new THREE.Vector3(
Math.cos(angle) * radius * wobble,
0.16,
Math.sin(angle) * radius * wobble
)
);
}
const foam = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(foamPoints),
new THREE.LineBasicMaterial({
color: 0xc8f1e8,
transparent: true,
opacity: 0.72,
depthWrite: false
})
);
group.add(foam);
// Faceted shoreline rocks.
const rockMaterial = new THREE.MeshStandardMaterial({
color: 0x6d675a,
roughness: 1,
flatShading: true
});
for (let i = 0; i < 7; i++) {
const angle = rand() * Math.PI * 2;
const r = radius * (0.69 + rand() * 0.23);
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.25 + rand() * 0.32, 0),
rockMaterial
);
rock.position.set(
Math.cos(angle) * r,
0.35 + rand() * 0.15,
Math.sin(angle) * r
);
rock.scale.set(1, 0.7 + rand() * 0.45, 0.8 + rand() * 0.5);
rock.rotation.set(rand(), rand(), rand());
rock.castShadow = true;
group.add(rock);
}
if (withPalms) {
for (let i = 0; i < 5; i++) {
const angle = rand() * Math.PI * 2;
const r = radius * (0.16 + rand() * 0.36);
const palm = createPalm(0.75 + rand() * 0.3);
palm.position.set(
Math.cos(angle) * r,
0.48 + rand() * 0.24,
Math.sin(angle) * r
);
group.add(palm);
}
}
scene.add(group);
return group;
}
function createPalm(scale = 1) {
const palm = new THREE.Group();
palm.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.11, 1.45, 5),
new THREE.MeshStandardMaterial({
color: 0x75563b,
roughness: 1,
flatShading: true
})
);
trunk.position.y = 0.72;
trunk.rotation.z = -0.08;
trunk.castShadow = true;
palm.add(trunk);
const frondMaterial = new THREE.MeshStandardMaterial({
color: 0x4f8a57,
roughness: 0.9,
flatShading: true,
side: THREE.DoubleSide
});
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2 + 0.15;
const radial = new THREE.Vector3(Math.cos(angle), 0, Math.sin(angle));
const side = new THREE.Vector3(-radial.z, 0, radial.x);
const root = new THREE.Vector3(0, 1.43, 0);
const tip = radial.clone().multiplyScalar(0.86);
tip.y = 1.05;
const a = tip.clone().addScaledVector(side, 0.15);
const b = tip.clone().addScaledVector(side, -0.15);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
root.x, root.y, root.z,
a.x, a.y, a.z,
b.x, b.y, b.z
], 3)
);
geometry.computeVertexNormals();
const frond = new THREE.Mesh(geometry, frondMaterial);
frond.castShadow = true;
palm.add(frond);
}
return palm;
}
const departureIsland = createIsland(4.1, -8, 6, 2, true);
const contextIsland = createIsland(2.6, 16, -17, 9, false);
// -------------------------------------------------------------------------
// Polynesian-style double-hulled voyaging canoe
// -------------------------------------------------------------------------
function createHull() {
const stations = [
{ z: -2.4, width: 0.12 },
{ z: -1.65, width: 0.48 },
{ z: 1.55, width: 0.50 },
{ z: 3.15, width: 0.025 }
];
const positions = [];
function point(station, side) {
if (side === "left") {
return new THREE.Vector3(-station.width, 0.35, station.z);
}
if (side === "right") {
return new THREE.Vector3(station.width, 0.35, station.z);
}
return new THREE.Vector3(0, -0.16, station.z);
}
function tri(a, b, c) {
positions.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
}
for (let i = 0; i < stations.length - 1; i++) {
const a = stations[i];
const b = stations[i + 1];
const al = point(a, "left");
const ar = point(a, "right");
const ab = point(a, "bottom");
const bl = point(b, "left");
const br = point(b, "right");
const bb = point(b, "bottom");
tri(al, bl, br);
tri(al, br, ar);
tri(ab, bb, bl);
tri(ab, bl, al);
tri(ab, ar, br);
tri(ab, br, bb);
}
const first = stations[0];
const last = stations[stations.length - 1];
tri(point(first, "left"), point(first, "bottom"), point(first, "right"));
tri(point(last, "left"), point(last, "right"), point(last, "bottom"));
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
color: 0x4b2d24,
roughness: 0.76,
flatShading: true,
side: THREE.DoubleSide
})
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function createCanoe() {
const canoe = new THREE.Group();
canoe.position.set(0, 0.16, 0);
canoe.rotation.y = 2.33;
const hullMaterialTrim = new THREE.MeshStandardMaterial({
color: 0xc08b54,
roughness: 0.8,
flatShading: true
});
const portHull = createHull();
const starboardHull = createHull();
portHull.position.x = -0.75;
starboardHull.position.x = 0.75;
canoe.add(portHull, starboardHull);
const beamGeometry = new THREE.BoxGeometry(2.05, 0.13, 0.24);
for (const z of [-1.15, 0.65, 1.45]) {
const beam = new THREE.Mesh(beamGeometry, hullMaterialTrim);
beam.position.set(0, 0.38, z);
beam.castShadow = true;
canoe.add(beam);
}
const platform = new THREE.Mesh(
new THREE.BoxGeometry(1.35, 0.12, 2.0),
new THREE.MeshStandardMaterial({
color: 0x785038,
roughness: 0.88,
flatShading: true
})
);
platform.position.set(0, 0.44, -0.05);
platform.castShadow = true;
canoe.add(platform);
const mast = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.065, 4.05, 6),
new THREE.MeshStandardMaterial({
color: 0x5a3a2a,
roughness: 0.9,
flatShading: true
})
);
mast.position.set(0, 2.32, 0.35);
mast.castShadow = true;
canoe.add(mast);
// Asymmetric, triangular crab-claw-style sail.
const sailGeometry = new THREE.BufferGeometry();
sailGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0.00, 4.15, 0.37,
-0.62, 0.94, 0.37,
1.33, 0.82, 0.37
], 3)
);
sailGeometry.computeVertexNormals();
const sail = new THREE.Mesh(
sailGeometry,
new THREE.MeshStandardMaterial({
color: 0xc98247,
roughness: 0.93,
flatShading: true,
side: THREE.DoubleSide
})
);
sail.castShadow = true;
canoe.add(sail);
// Woven sail marking.
const markingGeometry = new THREE.BufferGeometry();
markingGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
0.10, 2.65, 0.385,
0.02, 1.52, 0.385,
0.58, 1.40, 0.385
], 3)
);
markingGeometry.computeVertexNormals();
const marking = new THREE.Mesh(
markingGeometry,
new THREE.MeshStandardMaterial({
color: 0x3e3028,
roughness: 1,
side: THREE.DoubleSide
})
);
canoe.add(marking);
const riggingMaterial = new THREE.LineBasicMaterial({
color: 0x3b2a23,
transparent: true,
opacity: 0.8
});
const riggingPoints = [
new THREE.Vector3(0, 4.15, 0.35),
new THREE.Vector3(0, 0.48, 3.15),
new THREE.Vector3(0, 4.15, 0.35),
new THREE.Vector3(0, 0.48, -2.4)
];
canoe.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(riggingPoints),
riggingMaterial
)
);
scene.add(canoe);
return canoe;
}
const canoe = createCanoe();
// -------------------------------------------------------------------------
// Selected swell cue: SW to NE, with schematic shore interaction
// -------------------------------------------------------------------------
const swellDirection = new THREE.Vector3(0.76, 0, -0.65).normalize();
const swellPerpendicular = new THREE.Vector3(
-swellDirection.z,
0,
swellDirection.x
);
const islandCenter = new THREE.Vector3(-8, 0, 6);
const swellGroup = new THREE.Group();
scene.add(swellGroup);
const swellArrowMaterial = new THREE.LineBasicMaterial({
color: 0x9af3eb,
transparent: true,
opacity: 0.78,
depthWrite: false
});
for (const distance of [-12, -8, -4, 4, 8, 12]) {
const origin = islandCenter.clone()
.addScaledVector(swellDirection, distance);
origin.y = 0.48;
const arrow = new THREE.ArrowHelper(
swellDirection,
origin,
2.55,
0x9af3eb,
0.58,
0.34
);
arrow.line.material = swellArrowMaterial;
arrow.cone.material.transparent = true;
arrow.cone.material.opacity = 0.82;
arrow.cone.material.depthWrite = false;
swellGroup.add(arrow);
}
// Parallel wave fronts.
for (const distance of [-15, -11, -6.5, 6.5, 11, 15]) {
const points = [];
const center = islandCenter.clone()
.addScaledVector(swellDirection, distance);
center.y = 0.34;
for (let i = 0; i <= 30; i++) {
const offset = -10 + (i / 30) * 20;
const point = center.clone().addScaledVector(swellPerpendicular, offset);
point.y += Math.sin(offset * 0.55 + distance) * 0.035;
points.push(point);
}
const crest = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0xb8f4ea,
transparent: true,
opacity: distance === -6.5 || distance === 6.5 ? 0.48 : 0.28,
depthWrite: false
})
);
swellGroup.add(crest);
}
// Curved wave fronts wrapping around the departure island.
for (const radius of [4.8, 6.1]) {
for (const angleRange of [
[-0.15, 1.55],
[2.05, 3.75]
]) {
const points = [];
for (let i = 0; i <= 24; i++) {
const t = i / 24;
const angle = THREE.MathUtils.lerp(
angleRange[0],
angleRange[1],
t
);
points.push(new THREE.Vector3(
islandCenter.x + Math.cos(angle) * radius,
0.4,
islandCenter.z + Math.sin(angle) * radius
));
}
swellGroup.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0xc3fff1,
transparent: true,
opacity: 0.42,
depthWrite: false
})
)
);
}
}
// -------------------------------------------------------------------------
// Selected stellar bearing rays
// -------------------------------------------------------------------------
function createGlowTexture() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const context = canvas.getContext("2d");
const gradient = context.createRadialGradient(
64, 64, 0,
64, 64, 64
);
gradient.addColorStop(0, "rgba(255,239,185,1)");
gradient.addColorStop(0.12, "rgba(255,214,120,.8)");
gradient.addColorStop(0.42, "rgba(255,185,70,.18)");
gradient.addColorStop(1, "rgba(255,170,60,0)");
context.fillStyle = gradient;
context.fillRect(0, 0, 128, 128);
return new THREE.CanvasTexture(canvas);
}
const glowTexture = createGlowTexture();
function createHighlightedStar(position) {
const group = new THREE.Group();
group.position.copy(position);
const core = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.25, 1),
new THREE.MeshStandardMaterial({
color: 0xffedb0,
emissive: 0xffbd58,
emissiveIntensity: 2.2,
roughness: 0.45,
flatShading: true
})
);
group.add(core);
const glow = new THREE.Sprite(
new THREE.SpriteMaterial({
map: glowTexture,
color: 0xffd482,
transparent: true,
opacity: 0.72,
blending: THREE.AdditiveBlending,
depthWrite: false,
fog: false
})
);
glow.scale.set(3.1, 3.1, 3.1);
group.add(glow);
scene.add(group);
return group;
}
const starPositions = [
new THREE.Vector3(-6.5, 13.5, -10),
new THREE.Vector3(8.5, 11.5, -8)
];
starPositions.forEach((position) => createHighlightedStar(position));
const bearingStart = new THREE.Vector3(0, 0.47, 0);
starPositions.forEach((starPosition) => {
const projected = new THREE.Vector3(
starPosition.x,
0.47,
starPosition.z
);
const bearingRay = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
bearingStart,
projected
]),
new THREE.LineDashedMaterial({
color: 0xffd38a,
dashSize: 0.46,
gapSize: 0.3,
transparent: true,
opacity: 0.82,
depthWrite: false
})
);
bearingRay.computeLineDistances();
scene.add(bearingRay);
// A faint vertical guide connects the stellar marker to its bearing point.
const verticalGuide = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
projected,
starPosition
]),
new THREE.LineDashedMaterial({
color: 0xffd38a,
dashSize: 0.22,
gapSize: 0.34,
transparent: true,
opacity: 0.24,
depthWrite: false
})
);
verticalGuide.computeLineDistances();
scene.add(verticalGuide);
const horizontalDirection = projected.clone().sub(bearingStart);
horizontalDirection.y = 0;
horizontalDirection.normalize();
scene.add(
new THREE.ArrowHelper(
horizontalDirection,
projected.clone().addScaledVector(horizontalDirection, -1.0),
0.8,
0xffd38a,
0.28,
0.18
)
);
});
// A small arc between the two example bearing directions.
{
const directionA = starPositions[0].clone().setY(0).normalize();
const directionB = starPositions[1].clone().setY(0).normalize();
const angleA = Math.atan2(directionA.x, directionA.z);
const angleB = Math.atan2(directionB.x, directionB.z);
let difference = angleB - angleA;
while (difference > Math.PI) difference -= Math.PI * 2;
while (difference < -Math.PI) difference += Math.PI * 2;
const points = [];
for (let i = 0; i <= 36; i++) {
const angle = angleA + difference * (i / 36);
points.push(new THREE.Vector3(
Math.sin(angle) * 4.1,
0.46,
Math.cos(angle) * 4.1
));
}
scene.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0xffd38a,
transparent: true,
opacity: 0.48,
depthWrite: false
})
)
);
}
// -------------------------------------------------------------------------
// World-space labels, projected without an external label renderer
// -------------------------------------------------------------------------
const labels = [];
function addLabel(text, position, className = "", offset = [0, 0]) {
const element = document.createElement("div");
element.className = `scene-label ${className}`;
element.innerHTML = text;
labelRoot.appendChild(element);
labels.push({
element,
position,
getPosition: null,
offset
});
}
addLabel(
"Departure island",
new THREE.Vector3(-8, 3.35, 6),
"island",
[0, -12]
);
addLabel(
"Landmass cue<br><span style='font-weight:500;opacity:.72'>context only</span>",
new THREE.Vector3(16, 2.5, -17),
"island",
[0, -7]
);
addLabel(
"Voyaging canoe<br><span style='font-weight:500;opacity:.72'>Polynesian-style double hull</span>",
null,
"island",
[0, -12]
);
labels[labels.length - 1].getPosition = () =>
canoe.localToWorld(new THREE.Vector3(0, 5.15, 0));
addLabel(
"Selected star bearing A<br><span style='font-weight:500;opacity:.72'>illustrative sight ray</span>",
starPositions[0].clone().add(new THREE.Vector3(0, 1.0, 0)),
"star",
[14, -8]
);
addLabel(
"Selected star bearing B<br><span style='font-weight:500;opacity:.72'>illustrative sight ray</span>",
starPositions[1].clone().add(new THREE.Vector3(0, 0.9, 0)),
"star",
[15, -4]
);
addLabel(
"Selected stellar bearings<br><span style='font-weight:500;opacity:.72'>examples, not calibrated</span>",
new THREE.Vector3(1.2, 1.2, -6.2),
"star",
[0, 0]
);
addLabel(
"Selected swell cue<br><span style='font-weight:500;opacity:.72'>SW → NE · schematic</span>",
new THREE.Vector3(4.8, 1.1, 3.5),
"swell",
[0, 0]
);
addLabel(
"Swell bends near land<br><span style='font-weight:500;opacity:.72'>selected example</span>",
new THREE.Vector3(-11.2, 0.9, 3.1),
"swell",
[-5, 3]
);
// Small world-space orientation markers.
const compassMarkers = [
["N", new THREE.Vector3(0, 0.5, -17)],
["E", new THREE.Vector3(17, 0.5, 0)],
["S", new THREE.Vector3(0, 0.5, 17)],
["W", new THREE.Vector3(-17, 0.5, 0)]
];
compassMarkers.forEach(([letter, position]) => {
addLabel(letter, position, "compass");
});
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const worldPosition = label.getPosition
? label.getPosition()
: label.position;
const projected = worldPosition.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "block" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width + label.offset[0];
const y = (-projected.y * 0.5 + 0.5) * height + label.offset[1];
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
// -------------------------------------------------------------------------
// Direct camera controls — no external controls addon
// -------------------------------------------------------------------------
const defaultView = {
theta: 0.68,
phi: 0.94,
radius: 30,
target: new THREE.Vector3(-1, 1.1, -2)
};
const desired = {
theta: defaultView.theta,
phi: defaultView.phi,
radius: defaultView.radius
};
const current = {
theta: defaultView.theta,
phi: defaultView.phi,
radius: defaultView.radius
};
let dragging = false;
let pointerId = null;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const deltaX = event.clientX - lastX;
const deltaY = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
desired.theta -= deltaX * 0.006;
desired.phi = clamp(desired.phi - deltaY * 0.005, 0.36, 1.36);
});
function stopDragging(event) {
if (event.pointerId !== pointerId) return;
dragging = false;
pointerId = null;
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
15,
55
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") desired.theta += 0.08;
if (event.key === "ArrowRight") desired.theta -= 0.08;
if (event.key === "ArrowUp") {
desired.phi = clamp(desired.phi - 0.06, 0.36, 1.36);
}
if (event.key === "ArrowDown") {
desired.phi = clamp(desired.phi + 0.06, 0.36, 1.36);
}
if (event.key === "Home") resetView();
});
function resetView() {
desired.theta = defaultView.theta;
desired.phi = defaultView.phi;
desired.radius = defaultView.radius;
}
function updateCamera() {
current.theta += (desired.theta - current.theta) * 0.12;
current.phi += (desired.phi - current.phi) * 0.12;
current.radius += (desired.radius - current.radius) * 0.12;
const sinPhi = Math.sin(current.phi);
camera.position.set(
defaultView.target.x +
current.radius * sinPhi * Math.sin(current.theta),
defaultView.target.y +
current.radius * Math.cos(current.phi),
defaultView.target.z +
current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(defaultView.target);
}
document.querySelector("#reset-view").addEventListener("click", resetView);
const toggleButton = document.querySelector("#toggle-labels");
toggleButton.addEventListener("click", () => {
const hidden = labelRoot.classList.toggle("labels-off");
toggleButton.textContent = hidden ? "Show labels" : "Hide labels";
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
// Update faceted ocean heights.
for (let i = 0; i < oceanPositions.count; i++) {
const x = oceanBase[i * 2];
const z = oceanBase[i * 2 + 1];
oceanPositions.setY(i, waveHeight(x, z, time));
}
oceanPositions.needsUpdate = true;
// Gentle motion of the canoe.
canoe.position.y = 0.16 + Math.sin(time * 0.78) * 0.055;
canoe.rotation.z = Math.sin(time * 0.61) * 0.015;
canoe.rotation.x = Math.cos(time * 0.54) * 0.01;
updateCamera();
renderer.render(scene, camera);
updateLabels();
}
updateCamera();
renderer.render(scene, camera);
updateLabels();
loading.classList.add("hidden");
animate();
</script>
</body>
</html>
```