Prompt specification
Build or customize the Three.js 3D scene "Ocean route with intermediate resupply stops" 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: Ocean route with intermediate resupply stops
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/ocean-route-with-intermediate-resupply-stops-x2579
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing maritime resupply around the Cape of Good Hope. Build a schematic maritime route around southern Africa with selected ports and supply intervals. Label the period and distinguish documented networks from illustrative voyage quantities. Voxel style.
Working Three.js Starter (ocean-route-with-intermediate-resupply-stops-x2579):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cape Resupply — Maritime Networks, 1652–1795</title>
<style>
:root {
--ink: #eaf7f4;
--muted: #94aaa8;
--panel: rgba(8, 23, 31, 0.88);
--panel-edge: rgba(148, 212, 203, 0.18);
--teal: #45dbc6;
--blue: #70a9ff;
--lime: #a8d66f;
--amber: #ffb85c;
--red: #ff766c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07151e;
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,
#scene canvas,
#labels {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
#scene canvas {
display: block;
cursor: grab;
outline: none;
}
#scene canvas:active {
cursor: grabbing;
}
#labels {
pointer-events: none;
overflow: hidden;
z-index: 3;
}
.hud {
position: absolute;
z-index: 10;
}
.panel {
border: 1px solid var(--panel-edge);
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.26);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.title-card {
top: 18px;
left: 18px;
width: min(465px, calc(100vw - 390px));
padding: 19px 20px 17px;
border-left: 3px solid var(--teal);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 7px;
height: 7px;
background: currentColor;
box-shadow: 0 0 14px currentColor;
}
h1 {
margin: 10px 0 4px;
font-size: clamp(27px, 3vw, 45px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 820;
}
.period {
color: #d8efeb;
font-size: 18px;
font-weight: 760;
letter-spacing: 0.08em;
}
.subtitle {
max-width: 410px;
margin: 11px 0 12px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.stamp-row {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.stamp {
border: 1px solid rgba(151, 205, 197, 0.18);
padding: 5px 7px;
color: #acc2bf;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.stamp.warning {
color: #ffd6a5;
border-color: rgba(255, 184, 92, 0.3);
}
.control-card {
top: 18px;
right: 18px;
width: 338px;
max-height: calc(100vh - 112px);
overflow: auto;
scrollbar-width: thin;
scrollbar-color: rgba(95, 211, 193, 0.3) transparent;
}
.control-section {
padding: 15px 16px;
border-bottom: 1px solid rgba(151, 205, 197, 0.11);
}
.control-section:last-child {
border-bottom: 0;
}
.section-title {
margin: 0 0 11px;
color: #aac1be;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 31px 1fr;
gap: 9px;
align-items: center;
margin: 8px 0;
color: #d5e5e2;
font-size: 11px;
line-height: 1.35;
}
.legend-line {
position: relative;
height: 3px;
background: var(--teal);
}
.legend-line.dashed {
height: 2px;
background: repeating-linear-gradient(
90deg,
var(--amber) 0 7px,
transparent 7px 11px
);
}
.legend-line.direction::after {
content: "";
position: absolute;
right: -2px;
top: -4px;
border-left: 7px solid var(--teal);
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
}
.legend-cube {
width: 11px;
height: 11px;
margin-left: 7px;
background: var(--amber);
box-shadow: 0 0 12px rgba(255, 184, 92, 0.55);
transform: rotate(45deg);
}
.legend-note {
margin: 7px 0 0 40px;
color: #78918e;
font-size: 9px;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin: 9px 0;
color: #d7e6e3;
font-size: 11px;
}
.switch {
position: relative;
width: 34px;
height: 18px;
flex: 0 0 auto;
}
.switch input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch span {
position: absolute;
inset: 0;
border: 1px solid rgba(151, 205, 197, 0.26);
background: #102b34;
cursor: pointer;
}
.switch span::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 10px;
height: 10px;
background: #79908d;
transition: 160ms ease;
}
.switch input:checked + span {
border-color: rgba(69, 219, 198, 0.45);
}
.switch input:checked + span::after {
left: 19px;
background: var(--teal);
box-shadow: 0 0 10px rgba(69, 219, 198, 0.55);
}
.view-buttons {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.view-button {
border: 1px solid rgba(151, 205, 197, 0.18);
background: rgba(21, 48, 55, 0.58);
padding: 8px 5px;
cursor: pointer;
color: #c9dcda;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.view-button:hover,
.view-button.active {
color: #eafffb;
border-color: rgba(69, 219, 198, 0.55);
background: rgba(40, 105, 103, 0.38);
}
.route-button {
width: 100%;
display: grid;
grid-template-columns: 10px 1fr;
gap: 9px;
align-items: start;
border: 0;
border-left: 1px solid transparent;
background: transparent;
padding: 8px 6px;
text-align: left;
cursor: pointer;
}
.route-button:hover,
.route-button.selected {
border-left-color: var(--teal);
background: rgba(69, 219, 198, 0.07);
}
.route-button.packet:hover,
.route-button.packet.selected {
border-left-color: var(--amber);
background: rgba(255, 184, 92, 0.07);
}
.route-swatch {
width: 8px;
height: 8px;
margin-top: 4px;
background: var(--teal);
box-shadow: 0 0 9px rgba(69, 219, 198, 0.45);
}
.route-button.packet .route-swatch {
background: var(--amber);
box-shadow: 0 0 9px rgba(255, 184, 92, 0.45);
transform: rotate(45deg);
}
.route-button strong {
display: block;
color: #dbeae7;
font-size: 10px;
line-height: 1.25;
}
.route-button small {
display: block;
margin-top: 3px;
color: #829a97;
font-size: 9px;
line-height: 1.35;
}
.quantity-note {
margin: 9px 0 0;
padding: 10px;
border: 1px solid rgba(255, 184, 92, 0.23);
background: rgba(255, 184, 92, 0.055);
color: #dfc6a4;
font-size: 9px;
line-height: 1.5;
}
.selection-card {
left: 18px;
bottom: 92px;
width: min(440px, calc(100vw - 390px));
padding: 15px 17px;
}
.selection-tag {
display: inline-flex;
align-items: center;
gap: 6px;
color: var(--teal);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.selection-tag::before {
content: "";
width: 6px;
height: 6px;
background: currentColor;
box-shadow: 0 0 10px currentColor;
}
.selection-card.packet .selection-tag {
color: var(--amber);
}
.selection-card h2 {
margin: 7px 0 5px;
font-size: 16px;
letter-spacing: -0.015em;
}
.selection-card p {
margin: 0;
color: #9db1ae;
font-size: 10px;
line-height: 1.55;
}
.selection-meta {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.meta-chip {
padding: 5px 7px;
border: 1px solid rgba(151, 205, 197, 0.14);
color: #b8ccca;
background: rgba(14, 39, 47, 0.62);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.timeline {
left: 50%;
bottom: 18px;
width: min(760px, calc(100vw - 36px));
transform: translateX(-50%);
display: grid;
grid-template-columns: auto 1fr auto;
gap: 13px;
align-items: center;
padding: 12px 17px;
}
.timeline-date {
color: #effbf9;
font-size: 14px;
font-weight: 800;
letter-spacing: 0.04em;
}
.timeline-event {
color: #91aaa7;
font-size: 9px;
line-height: 1.35;
}
.timeline-event:last-child {
text-align: right;
}
.timeline-track {
position: relative;
height: 2px;
background: linear-gradient(90deg, var(--teal), var(--amber));
}
.timeline-track::before,
.timeline-track::after {
content: "";
position: absolute;
top: -4px;
width: 10px;
height: 10px;
background: #d8efeb;
box-shadow: 0 0 11px rgba(69, 219, 198, 0.4);
transform: rotate(45deg);
}
.timeline-track::before {
left: 0;
}
.timeline-track::after {
right: 0;
background: var(--amber);
}
.port-label,
.map-label {
position: absolute;
left: 0;
top: 0;
white-space: nowrap;
will-change: transform;
}
.port-label {
display: flex;
align-items: center;
gap: 6px;
padding: 5px 7px;
border: 1px solid rgba(156, 213, 204, 0.18);
background: rgba(5, 19, 27, 0.76);
color: #e5f2ef;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.04em;
box-shadow: 0 5px 16px rgba(0, 0, 0, 0.25);
}
.port-label::before {
content: "";
width: 6px;
height: 6px;
flex: 0 0 auto;
background: var(--teal);
box-shadow: 0 0 9px rgba(69, 219, 198, 0.65);
}
.port-label.minor {
color: #bfd1ce;
font-size: 8px;
border-color: rgba(156, 213, 204, 0.12);
}
.port-label.minor::before {
background: var(--lime);
box-shadow: 0 0 8px rgba(168, 214, 111, 0.55);
}
.map-label {
color: rgba(160, 204, 200, 0.36);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.27em;
text-transform: uppercase;
text-shadow: 0 2px 10px #06151d;
}
.tooltip {
position: absolute;
z-index: 30;
display: none;
width: min(280px, calc(100vw - 24px));
padding: 12px 13px;
border: 1px solid rgba(129, 211, 199, 0.3);
background: rgba(6, 19, 27, 0.95);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
pointer-events: none;
}
.tooltip strong {
display: block;
margin-bottom: 5px;
color: #effbf9;
font-size: 12px;
}
.tooltip span {
display: block;
color: #91aaa7;
font-size: 9px;
line-height: 1.45;
}
.tooltip .tip-evidence {
margin: 7px 0 5px;
color: var(--teal);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.tooltip.packet .tip-evidence {
color: var(--amber);
}
.help {
right: 18px;
bottom: 18px;
color: rgba(166, 195, 191, 0.62);
font-size: 8px;
line-height: 1.4;
text-align: right;
pointer-events: none;
}
#loading {
position: absolute;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #07151e;
color: #9ab7b3;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
#loading::before {
content: "";
width: 18px;
height: 18px;
margin-right: 12px;
border: 2px solid rgba(69, 219, 198, 0.2);
border-top-color: var(--teal);
animation: spin 0.9s linear infinite;
}
#loading {
grid-auto-flow: column;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 980px) {
.title-card {
width: calc(100vw - 330px);
}
.selection-card {
width: calc(100vw - 330px);
}
.timeline-event {
display: none;
}
.timeline {
grid-template-columns: auto 1fr auto;
}
}
@media (max-width: 720px) {
.title-card {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 15px;
}
h1 {
font-size: 29px;
}
.period {
font-size: 14px;
}
.subtitle {
margin-bottom: 8px;
}
.control-card {
top: auto;
right: 10px;
bottom: 76px;
width: 255px;
max-height: 42vh;
}
.control-section {
padding: 11px 12px;
}
.selection-card {
display: none;
}
.timeline {
bottom: 10px;
width: calc(100vw - 20px);
padding: 10px 12px;
}
.help {
display: none;
}
.port-label {
font-size: 7px;
padding: 3px 5px;
}
.map-label {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="labels"></div>
<header class="hud panel title-card">
<div class="eyebrow">Maritime logistics / Cape of Good Hope</div>
<h1>CAPE<br />RESUPPLY</h1>
<div class="period">1652–1795</div>
<p class="subtitle">
A schematic of company shipping, refreshment stations, and relay supply
around southern Africa during the long eighteenth century.
</p>
<div class="stamp-row">
<span class="stamp">Voxel atlas</span>
<span class="stamp">Schematic geography</span>
<span class="stamp warning">Quantities are illustrative</span>
</div>
</header>
<aside class="hud panel control-card">
<section class="control-section">
<h2 class="section-title">Reading the map</h2>
<div class="legend-row">
<span class="legend-line direction"></span>
<span>
<strong>Documented network link</strong><br />
Route or station association; not a voyage count.
</span>
</div>
<div class="legend-row">
<span class="legend-line dashed"></span>
<span>
<strong>Illustrative supply interval</strong><br />
Scenario cadence only; not an archival sailing frequency.
</span>
</div>
<div class="legend-row">
<span class="legend-cube"></span>
<span>
<strong>One scenario packet</strong><br />
Animated cargo cube. It does not represent a measured total.
</span>
</div>
<p class="legend-note">
Solid vessels animate direction only; they are not counted sailings.
</p>
</section>
<section class="control-section">
<h2 class="section-title">Map layers</h2>
<label class="toggle-row">
<span>Documented corridors</span>
<span class="switch">
<input id="network-toggle" type="checkbox" checked />
<span></span>
</span>
</label>
<label class="toggle-row">
<span>Illustrative packets</span>
<span class="switch">
<input id="packet-toggle" type="checkbox" checked />
<span></span>
</span>
</label>
</section>
<section class="control-section">
<h2 class="section-title">Camera</h2>
<div class="view-buttons">
<button class="view-button active" data-view="cape">Cape</button>
<button class="view-button" data-view="network">Full network</button>
<button class="view-button" data-view="reset">Reset</button>
</div>
</section>
<section class="control-section">
<h2 class="section-title">Documented corridors</h2>
<div id="network-routes"></div>
</section>
<section class="control-section">
<h2 class="section-title">Illustrative quantities</h2>
<div id="packet-routes"></div>
<p class="quantity-note">
<strong>Evidence boundary:</strong> solid routes identify documented
network relationships. Amber intervals and annual packet ranges are a
deliberately hypothetical supply scenario, not reconstructed voyage
counts, cargo manifests, or claimed sailing schedules.
</p>
</section>
</aside>
<section id="selection-card" class="hud panel selection-card">
<div class="selection-tag">Documented network</div>
<h2 id="selection-title"></h2>
<p id="selection-copy"></p>
<div id="selection-meta" class="selection-meta"></div>
</section>
<footer class="hud panel timeline">
<div>
<div class="timeline-date">1652</div>
<div class="timeline-event">Dutch settlement at Table Bay</div>
</div>
<div class="timeline-track"></div>
<div>
<div class="timeline-date">1795</div>
<div class="timeline-event">British occupation of the Cape</div>
</div>
</footer>
<div class="hud help">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom<br />
Click a port or route for evidence notes
</div>
<div id="tooltip" class="tooltip"></div>
<div id="loading">Building voxel network</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneContainer = document.getElementById("scene");
const labelLayer = document.getElementById("labels");
const tooltip = document.getElementById("tooltip");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07151e);
scene.fog = new THREE.Fog(0x07151e, 190, 390);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.5,
650
);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneContainer.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xa7dcff, 0x182821, 1.65);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d1, 2.45);
sun.position.set(-85, 145, 70);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -190;
sun.shadow.camera.right = 190;
sun.shadow.camera.top = 170;
sun.shadow.camera.bottom = -170;
sun.shadow.camera.near = 10;
sun.shadow.camera.far = 380;
sun.shadow.bias = -0.00045;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x5edacf, 0.75);
rim.position.set(120, 50, -130);
scene.add(rim);
const SCALE = 1.35;
const ocean = new THREE.Mesh(
new THREE.PlaneGeometry(290, 235),
new THREE.MeshStandardMaterial({
color: 0x0a2631,
roughness: 0.92,
metalness: 0.08
})
);
ocean.rotation.x = -Math.PI / 2;
ocean.position.set(72, -0.35, -32);
ocean.receiveShadow = true;
scene.add(ocean);
const grid = new THREE.GridHelper(290, 58, 0x28515b, 0x173844);
grid.position.set(72, -0.22, -32);
grid.material.transparent = true;
grid.material.opacity = 0.38;
scene.add(grid);
function geo(lon, lat) {
return new THREE.Vector3(
(lon + 20) * SCALE,
0,
-(lat + 40) * SCALE
);
}
function fract(value) {
return value - Math.floor(value);
}
function hash2(x, y) {
return fract(Math.sin(x * 127.1 + y * 311.7) * 43758.5453123);
}
function pointInPolygon(x, y, polygon) {
let inside = false;
for (
let i = 0, j = polygon.length - 1;
i < polygon.length;
j = i++
) {
const xi = polygon[i][0];
const yi = polygon[i][1];
const xj = polygon[j][0];
const yj = polygon[j][1];
const intersects =
yi > y !== yj > y &&
x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
if (intersects) inside = !inside;
}
return inside;
}
const landPolygons = [
{
name: "africa",
polygon: [
[-17, 35], [-7, 37], [10, 37], [20, 33], [32, 31],
[36, 24], [40, 16], [45, 12], [51, 11], [48, 4],
[43, -2], [40, -10], [35, -20], [32, -27], [27, -34],
[18, -35], [13, -28], [9, -17], [2, -1], [-5, 5],
[-13, 12], [-17, 22]
]
},
{
name: "madagascar",
polygon: [
[43, -12], [49, -13], [50, -18], [48, -25],
[44, -26], [43, -21]
]
},
{
name: "europe",
polygon: [
[-10, 36], [-10, 58], [8, 61], [29, 58],
[41, 47], [30, 36], [12, 35]
]
},
{
name: "arabia",
polygon: [
[34, 30], [44, 32], [57, 25], [59, 17],
[51, 12], [42, 13], [35, 19]
]
},
{
name: "india",
polygon: [
[68, 24], [77, 30], [90, 29], [94, 21],
[88, 8], [80, 7], [74, 13], [69, 17]
]
},
{
name: "sri-lanka",
polygon: [
[79, 6], [82, 7], [82, 10], [79, 10]
]
},
{
name: "sumatra",
polygon: [
[95, 5], [102, 6], [106, 0], [100, -6], [96, -3]
]
},
{
name: "java",
polygon: [
[105, -6], [114, -6], [114, -8], [106, -8]
]
},
{
name: "borneo",
polygon: [
[109, 7], [118, 7], [119, -3], [110, -3]
]
}
];
function terrainHeight(lon, lat) {
const n = hash2(Math.round(lon * 10), Math.round(lat * 10));
let h = 1.05 + n * 0.75;
if (lat > 8 && lat < 28 && lon > -10 && lon < 31) {
h += 0.9;
}
if (lon > 22 && lon < 40 && lat > -18 && lat < 10) {
h += 2.25;
}
if (lon > 25 && lon < 32 && lat > -32 && lat < -21) {
h += 3.8;
}
if (lon > 16 && lon < 23 && lat > -37 && lat < -31) {
h += 2.0;
}
if (lat > 35) {
h += 0.65;
}
return h;
}
const landCells = [];
const step = 2.25;
for (let lon = -20; lon <= 54.001; lon += step) {
for (let lat = -36; lat <= 38.001; lat += step) {
for (const region of landPolygons) {
if (pointInPolygon(lon, lat, region.polygon)) {
landCells.push({ lon, lat, region: region.name });
break;
}
}
}
}
const terrainMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96,
metalness: 0.02,
flatShading: true
});
const terrain = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
terrainMaterial,
landCells.length
);
terrain.castShadow = true;
terrain.receiveShadow = true;
const dummy = new THREE.Object3D();
const landColor = new THREE.Color();
landCells.forEach((cell, index) => {
const x = geo(cell.lon, cell.lat).x;
const z = geo(cell.lon, cell.lat).z;
const height = terrainHeight(cell.lon, cell.lat);
dummy.position.set(x, height / 2, z);
dummy.scale.set(step * SCALE * 0.89, height, step * SCALE * 0.89);
dummy.rotation.y = 0;
dummy.updateMatrix();
terrain.setMatrixAt(index, dummy.matrix);
if (
cell.lat > 9 &&
cell.lat < 29 &&
cell.lon > -12 &&
cell.lon < 31
) {
landColor.set(0xb59a6c);
} else if (cell.lat < -16) {
landColor.set(0x496d5d);
} else if (cell.lon > 23 && cell.lon < 39 && cell.lat > -18) {
landColor.set(0x77806b);
} else if (cell.lat > 34) {
landColor.set(0x738276);
} else {
landColor.set(0x7e8968);
}
const variation = (hash2(cell.lon, cell.lat) - 0.5) * 0.15;
landColor.offsetHSL(0, 0, variation);
terrain.setColorAt(index, landColor);
});
terrain.instanceMatrix.needsUpdate = true;
if (terrain.instanceColor) terrain.instanceColor.needsUpdate = true;
scene.add(terrain);
for (const region of landPolygons) {
const outlinePoints = region.polygon.map(([lon, lat]) => {
const p = geo(lon, lat);
p.y = 0.15;
return p;
});
const outline = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(outlinePoints),
new THREE.LineBasicMaterial({
color: 0x8fc5bc,
transparent: true,
opacity: 0.18
})
);
scene.add(outline);
}
const portData = [
{
id: "amsterdam",
name: "Texel / Amsterdam",
lon: 4.9,
lat: 52.4,
period: "1602–1799",
role: "VOC network origin",
evidence:
"Origin point of the Dutch East India Company's Atlantic–Asian institutional network.",
offset: [-8, -18],
scale: 0.9
},
{
id: "table-bay",
name: "Table Bay",
lon: 18.4,
lat: -33.9,
period: "1652–1795",
role: "Dutch resupply station",
evidence:
"Documented settlement, refreshment, repair, and company-station association at the Cape.",
offset: [-42, 15],
scale: 1.05
},
{
id: "saldanha",
name: "Saldanha Bay",
lon: 17.5,
lat: -32.7,
period: "17th–18th c.",
role: "Roadstead / anchorage",
evidence:
"Documented anchorage and maritime use. The packet cadence shown here is illustrative only.",
offset: [43, -8],
scale: 0.7
},
{
id: "st-helena",
name: "St Helena",
lon: -5.9,
lat: -15.9,
period: "1659–1815",
role: "East India Company port of call",
evidence:
"Documented British East India Company maritime association and Atlantic way-station.",
offset: [-8, -12],
scale: 0.76
},
{
id: "mozambique",
name: "Mozambique Island",
lon: 32.6,
lat: -15.0,
period: "1650–1898",
role: "Indian Ocean entrepôt",
evidence:
"Documented regional port and Portuguese Indian Ocean trading connection.",
offset: [23, -14],
scale: 0.72
},
{
id: "batavia",
name: "Batavia",
lon: 106.8,
lat: -6.2,
period: "1619–1942",
role: "VOC Asian headquarters",
evidence:
"Documented VOC headquarters and Asian end of the Cape-centered company corridor.",
offset: [0, 17],
scale: 0.9
},
{
id: "coromandel",
name: "Coromandel",
lon: 79.8,
lat: 10.0,
period: "17th–18th c.",
role: "VOC Indian network",
evidence:
"Documented VOC coastal network associated with Coromandel ports and factories.",
offset: [0, -21],
scale: 0.74
}
];
const portMarkers = new Map();
const interactiveMeshes = [];
const labelItems = [];
function createPortMarker(port) {
const group = new THREE.Group();
const ground = port.id === "st-helena" ? 0.45 : terrainHeight(port.lon, port.lat);
group.position.copy(geo(port.lon, port.lat));
group.position.y = ground + 0.25;
group.scale.setScalar(port.scale || 0.8);
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0x16343d,
emissive: 0x0a5653,
emissiveIntensity: 0.45,
roughness: 0.65
});
const base = new THREE.Mesh(
new THREE.BoxGeometry(2.7, 0.8, 2.7),
baseMaterial
);
base.position.y = 0.4;
base.castShadow = true;
base.receiveShadow = true;
base.userData = { type: "port", id: port.id };
group.add(base);
interactiveMeshes.push(base);
const towerMaterial = new THREE.MeshStandardMaterial({
color: 0x5ce3d0,
emissive: 0x1b8f83,
emissiveIntensity: 0.75,
roughness: 0.45
});
const tower = new THREE.Mesh(
new THREE.BoxGeometry(1.05, 2.35, 1.05),
towerMaterial
);
tower.position.y = 1.85;
tower.castShadow = true;
tower.userData = { type: "port", id: port.id };
group.add(tower);
interactiveMeshes.push(tower);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0xffd18c,
emissive: 0xff9e43,
emissiveIntensity: 1.4,
roughness: 0.3
});
const beacon = new THREE.Mesh(
new THREE.BoxGeometry(0.68, 0.68, 0.68),
beaconMaterial
);
beacon.position.y = 3.25;
beacon.userData = { type: "port", id: port.id };
group.add(beacon);
interactiveMeshes.push(beacon);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(2.25, 0.13, 4, 28),
new THREE.MeshBasicMaterial({
color: 0x4be0cc,
transparent: true,
opacity: 0.75
})
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.18;
group.add(ring);
group.userData.ring = ring;
group.userData.beacon = beacon;
scene.add(group);
portMarkers.set(port.id, group);
const el = document.createElement("div");
el.className = `port-label${port.scale && port.scale < 0.8 ? " minor" : ""}`;
el.textContent = port.name;
labelLayer.appendChild(el);
labelItems.push({
el,
anchor: group.position.clone().add(new THREE.Vector3(0, 4.1, 0)),
offset: port.offset || [0, 0]
});
}
portData.forEach(createPortMarker);
const mapLabels = [
{ name: "Southern Africa", lon: 23, lat: -17, offset: [0, 0] },
{ name: "South Atlantic", lon: -12, lat: -31, offset: [0, 0] },
{ name: "Indian Ocean", lon: 63, lat: -26, offset: [0, 0] }
];
mapLabels.forEach((item) => {
const el = document.createElement("div");
el.className = "map-label";
el.textContent = item.name;
labelLayer.appendChild(el);
labelItems.push({
el,
anchor: geo(item.lon, item.lat).setY(1),
offset: item.offset
});
});
function makeCurve(waypoints, lift = 5, verticalOffset = 0) {
const points = waypoints.map(([lon, lat], index) => {
const p = geo(lon, lat);
const t = index / Math.max(1, waypoints.length - 1);
p.y = 3.4 + verticalOffset + Math.sin(Math.PI * t) * lift;
return p;
});
if (points.length === 2) {
const midpoint = points[0].clone().lerp(points[1], 0.5);
midpoint.y = 3.4 + verticalOffset + lift;
return new THREE.CatmullRomCurve3(
[points[0], midpoint, points[1]],
false,
"centripetal"
);
}
return new THREE.CatmullRomCurve3(points, false, "centripetal");
}
const solidGroup = new THREE.Group();
const packetGroup = new THREE.Group();
scene.add(solidGroup, packetGroup);
const solidRoutes = [
{
id: "voc-cape",
title: "VOC Atlantic–Cape corridor",
network: "VOC",
period: "1652–1795",
role: "European company shipping to the Cape",
copy:
"The solid line marks a documented institutional corridor between the Dutch Atlantic network and Table Bay. It does not assign a sailing count to the route.",
color: 0x45dbc6,
waypoints: [
[4.9, 52.4], [-2, 45], [-12, 30], [-18, 10],
[-14, -12], [-4, -27], [10, -34], [18.4, -33.9]
]
},
{
id: "voc-asia",
title: "Cape–Batavia company corridor",
network: "VOC",
period: "1652–1795",
role: "Refreshment and relay en route to Asia",
copy:
"Table Bay functioned as a documented refreshment point within the VOC's Cape-to-Asia system. The route shows network association rather than a reconstructed timetable.",
color: 0x45dbc6,
waypoints: [
[18.4, -33.9], [28, -38], [45, -37], [65, -31],
[83, -23], [97, -14], [106.8, -6.2]
]
},
{
id: "voc-india",
title: "Cape–Coromandel corridor",
network: "VOC",
period: "17th–18th c.",
role: "Western relay toward Coromandel factories",
copy:
"A schematic connection between the Cape-centered Atlantic leg and the VOC's documented Coromandel network.",
color: 0x45dbc6,
waypoints: [
[18.4, -33.9], [31, -38], [52, -34],
[70, -23], [82, -7], [79.8, 10]
]
},
{
id: "eic-cape",
title: "St Helena–Cape corridor",
network: "British EIC",
period: "1659–1795",
role: "Atlantic company way-station association",
copy:
"The solid route marks the documented maritime relationship between St Helena and the Cape within British East India Company networks.",
color: 0x70a9ff,
waypoints: [
[-5.9, -15.9], [-1, -24], [8, -31], [18.4, -33.9]
]
},
{
id: "regional-mozambique",
title: "Cape–Mozambique regional link",
network: "Regional",
period: "17th–18th c.",
role: "Indian Ocean port-to-port connection",
copy:
"A documented regional maritime association between the Cape and the Portuguese entrepôt at Mozambique Island. No voyage frequency is claimed.",
color: 0xa8d66f,
waypoints: [
[18.4, -33.9], [22, -30], [26, -23], [32.6, -15]
]
}
];
const packetRoutes = [
{
id: "local-saldanha",
title: "Table Bay–Saldanha Bay",
interval: [4, 6],
copy:
"A hypothetical local resupply packet for the nearby roadstead. It illustrates distance and relay logic, not a measured number of voyages.",
waypoints: [[18.4, -33.9], [17.5, -32.7]],
lift: 1.5
},
{
id: "atlantic-st-helena",
title: "Table Bay–St Helena packet",
interval: [3, 4],
copy:
"A hypothetical Atlantic relief packet. The cadence is intentionally modest and is not evidence of an actual packet service.",
waypoints: [[18.4, -33.9], [8, -31], [-1, -24], [-5.9, -15.9]],
lift: 4
},
{
id: "regional-packet",
title: "Table Bay–Mozambique packet",
interval: [4, 6],
copy:
"An illustrative regional cargo movement along a documented port-to-port maritime association. The packet count remains hypothetical.",
waypoints: [[18.4, -33.9], [22, -30], [26, -23], [32.6, -15]],
lift: 4
},
{
id: "asia-packet",
title: "Cape–Batavia stores packet",
interval: [6, 8],
copy:
"A scenario stores movement along the Cape–Batavia company corridor. It demonstrates a possible resupply interval without asserting an archival sailing rate.",
waypoints: [
[18.4, -33.9], [28, -38], [45, -37], [65, -31],
[83, -23], [97, -14], [106.8, -6.2]
],
lift: 7
}
];
const routeIndex = new Map();
const solidRouteObjects = [];
const packetRouteObjects = [];
const movingVessels = [];
const movingPackets = [];
function makeVoxelVessel(color) {
const group = new THREE.Group();
const hull = new THREE.Mesh(
new THREE.BoxGeometry(3.1, 0.75, 1.15),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.32,
roughness: 0.48
})
);
hull.castShadow = true;
group.add(hull);
const deck = new THREE.Mesh(
new THREE.BoxGeometry(1.65, 0.72, 0.88),
new THREE.MeshStandardMaterial({
color: 0xe7f8f3,
roughness: 0.5
})
);
deck.position.set(0.15, 0.68, 0);
deck.castShadow = true;
group.add(deck);
const mast = new THREE.Mesh(
new THREE.BoxGeometry(0.18, 1.7, 0.18),
new THREE.MeshStandardMaterial({ color: 0xe0f1ec })
);
mast.position.set(-0.5, 1.15, 0);
group.add(mast);
const stern = new THREE.Mesh(
new THREE.BoxGeometry(0.65, 1.0, 0.85),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.25
})
);
stern.position.set(-1.05, 0.75, 0);
group.add(stern);
group.scale.setScalar(0.72);
return group;
}
solidRoutes.forEach((route, index) => {
const curve = makeCurve(route.waypoints, route.id === "voc-asia" ? 7 : 5);
const geometry = new THREE.TubeGeometry(
curve,
190,
0.48,
4,
false
);
const material = new THREE.MeshStandardMaterial({
color: route.color,
emissive: route.color,
emissiveIntensity: 0.48,
roughness: 0.45,
metalness: 0.08,
flatShading: true,
transparent: true,
opacity: 0.92
});
const mesh = new THREE.Mesh(geometry, material);
mesh.userData = { type: "route", id: route.id };
solidGroup.add(mesh);
interactiveMeshes.push(mesh);
const vessel = makeVoxelVessel(route.color);
solidGroup.add(vessel);
movingVessels.push({
object: vessel,
curve,
offset: index * 0.19,
speed: 0.018 + index * 0.0015
});
const object = { ...route, curve, mesh };
solidRouteObjects.push(object);
routeIndex.set(route.id, { ...object, type: "network" });
});
packetRoutes.forEach((route, index) => {
const curve = makeCurve(route.waypoints, route.lift, 1.25);
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(240)
);
const material = new THREE.LineDashedMaterial({
color: 0xffb85c,
dashSize: 2.6,
gapSize: 1.65,
transparent: true,
opacity: 0.92,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.userData = { type: "route", id: route.id };
packetGroup.add(line);
interactiveMeshes.push(line);
const packet = new THREE.Mesh(
new THREE.BoxGeometry(1.35, 1.35, 1.35),
new THREE.MeshStandardMaterial({
color: 0xffc46f,
emissive: 0xff8b30,
emissiveIntensity: 0.85,
roughness: 0.35
})
);
packet.castShadow = true;
packetGroup.add(packet);
movingPackets.push({
object: packet,
curve,
offset: index * 0.23,
speed: 0.026 + index * 0.002
});
const object = { ...route, curve, line };
packetRouteObjects.push(object);
routeIndex.set(route.id, { ...object, type: "packet" });
});
function packetsPerYear(range) {
const low = Math.round(52 / range[1]);
const high = Math.round(52 / range[0]);
return `${low}–${high}`;
}
const networkRoutesElement = document.getElementById("network-routes");
const packetRoutesElement = document.getElementById("packet-routes");
networkRoutesElement.innerHTML = solidRoutes
.map(
(route) => `
<button class="route-button" data-route="${route.id}">
<span class="route-swatch" style="background:#${route.color.toString(16).padStart(6, "0")}"></span>
<span>
<strong>${route.title}</strong>
<small>${route.network} · ${route.role}</small>
</span>
</button>
`
)
.join("");
packetRoutesElement.innerHTML = packetRoutes
.map(
(route) => `
<button class="route-button packet" data-route="${route.id}">
<span class="route-swatch"></span>
<span>
<strong>${route.title}</strong>
<small>1 packet / ${route.interval[0]}–${route.interval[1]} weeks · illustrative</small>
</span>
</button>
`
)
.join("");
const selectionCard = document.getElementById("selection-card");
const selectionTitle = document.getElementById("selection-title");
const selectionCopy = document.getElementById("selection-copy");
const selectionMeta = document.getElementById("selection-meta");
function selectRoute(id) {
const route = routeIndex.get(id);
if (!route) return;
document.querySelectorAll(".route-button").forEach((button) => {
button.classList.toggle("selected", button.dataset.route === id);
});
solidRouteObjects.forEach((item) => {
item.mesh.material.emissiveIntensity =
item.id === id ? 1.45 : 0.48;
item.mesh.material.opacity = item.id === id ? 1 : 0.62;
});
packetRouteObjects.forEach((item) => {
item.line.material.opacity = item.id === id ? 1 : 0.28;
});
selectionCard.classList.toggle("packet", route.type === "packet");
if (route.type === "network") {
selectionTitle.textContent = route.title;
selectionCopy.textContent = route.copy;
selectionMeta.innerHTML = `
<span class="meta-chip">Documented network</span>
<span class="meta-chip">${route.network}</span>
<span class="meta-chip">${route.period}</span>
<span class="meta-chip">No voyage count asserted</span>
`;
} else {
selectionTitle.textContent = route.title;
selectionCopy.textContent = route.copy;
selectionMeta.innerHTML = `
<span class="meta-chip">Illustrative quantity</span>
<span class="meta-chip">1 packet / ${route.interval[0]}–${route.interval[1]} weeks</span>
<span class="meta-chip">~${packetsPerYear(route.interval)} packets / year if sustained</span>
<span class="meta-chip">Not archival evidence</span>
`;
}
}
document.querySelectorAll("[data-route]").forEach((button) => {
button.addEventListener("click", () => selectRoute(button.dataset.route));
});
function selectPort(port) {
selectionCard.classList.remove("packet");
selectionTitle.textContent = port.name;
selectionCopy.textContent = port.evidence;
selectionMeta.innerHTML = `
<span class="meta-chip">Documented port / station</span>
<span class="meta-chip">${port.period}</span>
<span class="meta-chip">${port.role}</span>
<span class="meta-chip">Network presence, not traffic total</span>
`;
document.querySelectorAll(".route-button").forEach((button) => {
button.classList.remove("selected");
});
}
selectRoute("voc-cape");
const desiredTarget = new THREE.Vector3(60, 0, -4);
const currentTarget = desiredTarget.clone();
let desiredTheta = 0.63;
let desiredPhi = 0.74;
let desiredRadius = 178;
let currentTheta = desiredTheta;
let currentPhi = desiredPhi;
let currentRadius = desiredRadius;
function setView(name) {
if (name === "cape") {
desiredTarget.set(59, 0, 0);
desiredTheta = 0.64;
desiredPhi = 0.72;
desiredRadius = 168;
} else {
desiredTarget.set(78, 0, -38);
desiredTheta = 0.57;
desiredPhi = 0.72;
desiredRadius = 235;
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle(
"active",
button.dataset.view === name || (name === "reset" && button.dataset.view === "cape")
);
});
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
const networkToggle = document.getElementById("network-toggle");
const packetToggle = document.getElementById("packet-toggle");
networkToggle.addEventListener("change", (event) => {
solidGroup.visible = event.target.checked;
});
packetToggle.addEventListener("change", (event) => {
packetGroup.visible = event.target.checked;
});
const raycaster = new THREE.Raycaster();
raycaster.params.Line.threshold = 2.2;
const pointer = new THREE.Vector2();
let dragging = false;
let panning = false;
let pointerMoved = false;
let lastX = 0;
let lastY = 0;
let downX = 0;
let downY = 0;
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function findIntersection(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(interactiveMeshes, false)[0] || null;
}
function positionTooltip(event, html, packet = false) {
tooltip.innerHTML = html;
tooltip.classList.toggle("packet", packet);
tooltip.style.display = "block";
const left = Math.min(
event.clientX + 15,
window.innerWidth - tooltip.offsetWidth - 12
);
const top = Math.min(
event.clientY + 15,
window.innerHeight - tooltip.offsetHeight - 12
);
tooltip.style.left = `${Math.max(12, left)}px`;
tooltip.style.top = `${Math.max(12, top)}px`;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.shiftKey || event.button === 2;
pointerMoved = false;
lastX = event.clientX;
lastY = event.clientY;
downX = event.clientX;
downY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(event.clientX - downX) + Math.abs(event.clientY - downY) > 5) {
pointerMoved = true;
}
if (panning) {
desiredTarget.x -= dx * 0.12;
desiredTarget.z += dy * 0.12;
} else {
desiredTheta -= dx * 0.0052;
desiredPhi = THREE.MathUtils.clamp(
desiredPhi - dy * 0.0042,
0.34,
1.43
);
}
lastX = event.clientX;
lastY = event.clientY;
return;
}
const hit = findIntersection(event);
if (!hit) {
tooltip.style.display = "none";
renderer.domElement.style.cursor = "grab";
return;
}
const data = hit.object.userData;
renderer.domElement.style.cursor = "pointer";
if (data.type === "port") {
const port = portData.find((item) => item.id === data.id);
positionTooltip(
event,
`
<strong>${port.name}</strong>
<div class="tip-evidence">Documented port / station</div>
<span>${port.role}</span>
<span>${port.period}</span>
<span>${port.evidence}</span>
`
);
} else {
const route = routeIndex.get(data.id);
const packet = route.type === "packet";
const details = packet
? `Scenario: 1 packet every ${route.interval[0]}–${route.interval[1]} weeks. Not an archival sailing frequency.`
: `${route.network} network association. This line does not assert a voyage count.`;
positionTooltip(
event,
`
<strong>${route.title}</strong>
<div class="tip-evidence">${packet ? "Illustrative quantity" : "Documented network"}</div>
<span>${details}</span>
`,
packet
);
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (dragging && !pointerMoved) {
const hit = findIntersection(event);
if (hit) {
const data = hit.object.userData;
if (data.type === "port") {
const port = portData.find((item) => item.id === data.id);
selectPort(port);
} else {
selectRoute(data.id);
}
}
}
dragging = false;
panning = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
panning = false;
});
renderer.domElement.addEventListener("pointerleave", () => {
if (!dragging) tooltip.style.display = "none";
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
68,
310
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const key = event.key;
if (key === "ArrowLeft") desiredTheta += 0.09;
if (key === "ArrowRight") desiredTheta -= 0.09;
if (key === "ArrowUp") desiredPhi = Math.max(0.34, desiredPhi - 0.07);
if (key === "ArrowDown") desiredPhi = Math.min(1.43, desiredPhi + 0.07);
if (key === "+" || key === "=") desiredRadius = Math.max(68, desiredRadius - 8);
if (key === "-") desiredRadius = Math.min(310, desiredRadius + 8);
});
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const item of labelItems) {
projected.copy(item.anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.12 &&
projected.x < 1.12 &&
projected.y > -1.12 &&
projected.y < 1.12;
item.el.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width + item.offset[0];
const y = (-projected.y * 0.5 + 0.5) * height + item.offset[1];
item.el.style.transform =
`translate(-50%, -50%) translate(${x}px, ${y}px)`;
}
}
}
const clock = new THREE.Clock();
const forward = new THREE.Vector3(0, 0, 1);
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
const smoothing = 1 - Math.exp(-delta * 6.5);
currentTarget.lerp(desiredTarget, smoothing);
currentTheta = THREE.MathUtils.lerp(currentTheta, desiredTheta, smoothing);
currentPhi = THREE.MathUtils.lerp(currentPhi, desiredPhi, smoothing);
currentRadius = THREE.MathUtils.lerp(currentRadius, desiredRadius, smoothing);
const offset = new THREE.Vector3().setFromSphericalCoords(
currentRadius,
currentPhi,
currentTheta
);
camera.position.copy(currentTarget).add(offset);
camera.lookAt(currentTarget);
camera.updateMatrixWorld();
movingVessels.forEach((item, index) => {
const t = (elapsed * item.speed + item.offset) % 1;
item.object.position.copy(item.curve.getPointAt(t));
const tangent = item.curve.getTangentAt(t).normalize();
item.object.quaternion.setFromUnitVectors(forward, tangent);
item.object.position.y += Math.sin(elapsed * 3 + index) * 0.13;
});
movingPackets.forEach((item, index) => {
const t = (elapsed * item.speed + item.offset) % 1;
item.object.position.copy(item.curve.getPointAt(t));
item.object.rotation.set(
elapsed * 1.6 + index,
elapsed * 2.1,
elapsed * 1.25
);
const pulse = 1 + Math.sin(elapsed * 4 + index) * 0.12;
item.object.scale.setScalar(pulse);
});
portMarkers.forEach((marker, id) => {
const pulse = 1 + Math.sin(elapsed * 2.6 + id.length) * 0.09;
marker.userData.ring.scale.setScalar(pulse);
marker.userData.ring.material.opacity = 0.52 + pulse * 0.16;
marker.userData.beacon.material.emissiveIntensity =
1.1 + Math.sin(elapsed * 3.2 + id.length) * 0.3;
});
updateLabels();
renderer.render(scene, camera);
}
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", onResize);
animate();
loading.remove();
</script>
</body>
</html>
```