Prompt specification
Build or customize the Three.js 3D scene "Two satellite passes over the same coast" 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: Two satellite passes over the same coast
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-satellite-passes-over-the-same-coast-x2490
Scene Description Prompt:
Please make a low-poly Three.js scene in one standalone HTML file using cdnjs. Create a coastal tile viewed during two labeled passes. Keep sensor geometry fixed and show how the observed position changes with the satellite's path.
Working Three.js Starter (two-satellite-passes-over-the-same-coast-x2490):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coastal Observation — Two Passes</title>
<style>
:root {
--cyan: #64f4df;
--amber: #ffc16d;
--ink: #07131d;
--panel: rgba(7, 20, 29, 0.82);
--line: rgba(160, 224, 230, 0.18);
--muted: #91a9b0;
--white: #eefbfb;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--white);
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;
}
#ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.brand {
position: absolute;
top: 28px;
left: 30px;
max-width: 440px;
text-shadow: 0 2px 20px rgba(0, 0, 0, 0.55);
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 26px;
height: 1px;
background: currentColor;
box-shadow: 0 0 8px currentColor;
}
h1 {
margin: 10px 0 7px;
font-size: clamp(25px, 3vw, 43px);
font-weight: 650;
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 0;
color: #aec1c5;
font-size: 12px;
line-height: 1.6;
letter-spacing: 0.04em;
}
.telemetry {
position: absolute;
top: 28px;
right: 30px;
width: 270px;
padding: 16px 17px;
border: 1px solid var(--line);
border-radius: 4px;
background:
linear-gradient(135deg, rgba(255,255,255,0.035), transparent 45%),
var(--panel);
backdrop-filter: blur(15px);
box-shadow: 0 16px 60px rgba(0, 0, 0, 0.24);
}
.telemetry-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 12px;
margin-bottom: 12px;
border-bottom: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.live-dot {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
animation: blink 1.8s infinite;
}
@keyframes blink {
50% { opacity: 0.38; }
}
.readout {
display: grid;
grid-template-columns: 1fr auto;
gap: 12px;
align-items: baseline;
margin: 8px 0;
font-size: 10px;
color: var(--muted);
}
.readout strong {
color: var(--white);
font-size: 12px;
font-weight: 600;
letter-spacing: 0.025em;
font-variant-numeric: tabular-nums;
}
.sensor-tag {
display: flex;
align-items: center;
gap: 8px;
margin-top: 14px;
padding-top: 13px;
border-top: 1px solid var(--line);
color: #a7bec2;
font-size: 9px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.sensor-tag i {
width: 8px;
height: 8px;
border: 1px solid var(--cyan);
border-radius: 50%;
box-shadow: inset 0 0 0 2px rgba(100, 244, 223, 0.18);
}
.legend {
position: absolute;
left: 30px;
bottom: 174px;
padding: 13px 15px;
border-left: 1px solid var(--line);
background: linear-gradient(90deg, rgba(7, 19, 29, 0.78), transparent);
color: var(--muted);
font-size: 9px;
line-height: 1.9;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
display: inline-block;
width: 19px;
height: 2px;
background: var(--cyan);
box-shadow: 0 0 8px rgba(100,244,223,0.5);
}
.swatch.amber {
background: var(--amber);
box-shadow: 0 0 8px rgba(255,193,109,0.45);
}
.swatch.target {
width: 9px;
height: 9px;
border: 1px solid var(--cyan);
border-radius: 50%;
background: transparent;
box-shadow: none;
}
.controls {
position: absolute;
right: 30px;
bottom: 174px;
display: flex;
gap: 6px;
pointer-events: auto;
}
.small-button {
min-width: 40px;
height: 34px;
padding: 0 11px;
border: 1px solid var(--line);
border-radius: 3px;
color: #b7cbce;
background: rgba(7, 20, 29, 0.75);
font: inherit;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
transition: border-color 160ms, color 160ms, background 160ms;
}
.small-button:hover,
.small-button.active {
border-color: rgba(100, 244, 223, 0.5);
color: var(--cyan);
background: rgba(21, 51, 59, 0.86);
}
.bottom-panel {
position: absolute;
left: 50%;
bottom: 25px;
width: min(900px, calc(100% - 60px));
transform: translateX(-50%);
padding: 14px 16px 12px;
border: 1px solid var(--line);
border-radius: 5px;
background:
linear-gradient(120deg, rgba(255,255,255,0.035), transparent 42%),
rgba(6, 18, 27, 0.89);
backdrop-filter: blur(18px);
box-shadow: 0 18px 70px rgba(0, 0, 0, 0.3);
pointer-events: auto;
}
.pass-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
margin-bottom: 12px;
}
.pass-title {
display: flex;
align-items: baseline;
gap: 12px;
min-width: 0;
}
#passLabel {
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
white-space: nowrap;
}
#passDescription {
overflow: hidden;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.05em;
text-overflow: ellipsis;
white-space: nowrap;
}
.transport {
display: flex;
gap: 6px;
flex-shrink: 0;
}
.pass-buttons {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.pass-button {
position: relative;
overflow: hidden;
display: grid;
grid-template-columns: auto 1fr auto;
gap: 11px;
align-items: center;
padding: 10px 12px 12px;
border: 1px solid rgba(160, 224, 230, 0.12);
border-radius: 3px;
color: #8fa7ac;
background: rgba(255, 255, 255, 0.018);
text-align: left;
cursor: pointer;
transition: border-color 180ms, background 180ms;
}
.pass-button:hover {
background: rgba(255,255,255,0.035);
}
.pass-button.active {
border-color: rgba(100, 244, 223, 0.42);
background: rgba(100, 244, 223, 0.055);
}
.pass-button[data-pass="1"].active {
border-color: rgba(255, 193, 109, 0.42);
background: rgba(255, 193, 109, 0.055);
}
.pass-index {
color: #61777d;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
}
.pass-name {
color: #d8e8e9;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.pass-time {
color: #779096;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.pass-progress {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 2px;
background: rgba(255,255,255,0.05);
}
.pass-progress span {
display: block;
width: 0;
height: 100%;
background: var(--cyan);
box-shadow: 0 0 9px rgba(100,244,223,0.55);
}
.pass-button[data-pass="1"] .pass-progress span {
background: var(--amber);
box-shadow: 0 0 9px rgba(255,193,109,0.5);
}
.help {
position: absolute;
right: 30px;
top: 236px;
color: rgba(181, 207, 210, 0.55);
font-size: 9px;
line-height: 1.7;
letter-spacing: 0.08em;
text-align: right;
text-transform: uppercase;
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #07131d;
color: var(--cyan);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 500ms;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
#loading span::before {
content: "";
display: inline-block;
width: 22px;
height: 1px;
margin: 0 10px 3px 0;
background: var(--cyan);
animation: scan 1s infinite alternate;
}
@keyframes scan {
to { width: 42px; }
}
@media (max-width: 760px) {
.brand { top: 18px; left: 18px; max-width: 55%; }
.telemetry { top: 18px; right: 18px; width: 205px; padding: 12px; }
.telemetry .secondary { display: none; }
.subtitle { font-size: 10px; }
.legend, .help { display: none; }
.controls { right: 18px; bottom: 178px; }
.bottom-panel { bottom: 14px; width: calc(100% - 28px); padding: 11px; }
.pass-header { align-items: flex-start; }
#passDescription { display: none; }
.pass-button { grid-template-columns: auto 1fr; gap: 7px; }
.pass-time { display: none; }
}
</style>
</head>
<body>
<div id="loading"><span>Building coastal tile</span></div>
<div id="ui">
<header class="brand">
<div class="eyebrow">Orbital observation study</div>
<h1>Coastal Tile /<br>Two-Pass Survey</h1>
<p class="subtitle">
Fixed nadir sensor geometry. Moving observation position.<br>
Pacific test segment · low-poly terrain reconstruction
</p>
</header>
<aside class="telemetry">
<div class="telemetry-head">
<span><i class="live-dot"></i>Live telemetry</span>
<span id="passState">Acquiring</span>
</div>
<div class="readout">
<span>Observed position</span>
<strong id="positionReadout">—</strong>
</div>
<div class="readout">
<span>Longitude</span>
<strong id="longitudeReadout">—</strong>
</div>
<div class="readout">
<span>Latitude</span>
<strong id="latitudeReadout">—</strong>
</div>
<div class="readout secondary">
<span>Altitude</span>
<strong>638.4 km</strong>
</div>
<div class="readout secondary">
<span>Payload</span>
<strong>4-band multispectral</strong>
</div>
<div class="sensor-tag"><i></i>Sensor geometry locked</div>
</aside>
<div class="legend">
<div class="legend-row"><i class="swatch"></i>Active orbital path</div>
<div class="legend-row"><i class="swatch amber"></i>Return pass</div>
<div class="legend-row"><i class="swatch target"></i>Observed footprint</div>
</div>
<div class="help">
Drag to orbit · Scroll to zoom<br>
Fixed sensor / moving footprint
</div>
<div class="controls">
<button class="small-button active" id="isoButton" title="Isometric camera">ISO</button>
<button class="small-button" id="topButton" title="Top-down camera">TOP</button>
<button class="small-button" id="resetButton" title="Reset camera">RESET</button>
</div>
<section class="bottom-panel">
<div class="pass-header">
<div class="pass-title">
<span id="passLabel">Pass 01</span>
<span id="passDescription">Northern coastal track · west to east</span>
</div>
<div class="transport">
<button class="small-button" id="pauseButton">Pause</button>
<button class="small-button" id="replayButton">Replay</button>
<button class="small-button" id="speedButton">1.0×</button>
</div>
</div>
<div class="pass-buttons">
<button class="pass-button active" data-pass="0">
<span class="pass-index">01</span>
<span class="pass-name">Northern track</span>
<span class="pass-time">00:00</span>
<span class="pass-progress"><span id="progress0"></span></span>
</button>
<button class="pass-button" data-pass="1">
<span class="pass-index">02</span>
<span class="pass-name">Southern track</span>
<span class="pass-time">00:00</span>
<span class="pass-progress"><span id="progress1"></span></span>
</button>
</div>
</section>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
// -------------------------------------------------------------------------
// Renderer, scene, camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07131d);
scene.fog = new THREE.Fog(0x07131d, 49, 100);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
160
);
const cameraTarget = new THREE.Vector3(0, 1.8, 0);
const cameraState = {
theta: 0.76,
phi: 1.02,
radius: 49
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xaeefff, 0x17323b, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d2, 3.1);
sun.position.set(16, 30, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 28;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.bias = -0.0005;
scene.add(sun);
const cyanRim = new THREE.PointLight(0x50e8dc, 16, 34, 2);
cyanRim.position.set(-16, 9, -12);
scene.add(cyanRim);
const amberRim = new THREE.PointLight(0xffb45f, 12, 30, 2);
amberRim.position.set(16, 7, 11);
scene.add(amberRim);
// -------------------------------------------------------------------------
// Utilities and deterministic random
// -------------------------------------------------------------------------
let randomSeed = 4217;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
function hash(x, z = 0) {
const n = Math.sin(x * 127.1 + z * 311.7) * 43758.5453;
return n - Math.floor(n);
}
function coastX(z) {
return 2.1
+ Math.sin(z * 0.31) * 1.25
+ Math.sin(z * 0.13 + 1.4) * 0.72;
}
function landHeight(x, z) {
const distanceFromCoast = Math.max(0, coastX(z) - x);
return 0.25
+ Math.min(2.45, distanceFromCoast * 0.105)
+ hash(Math.round(x * 2), Math.round(z * 2)) * 0.27;
}
function pushTriangle(positionArray, colorArray, a, b, c, baseColor) {
const variation = 0.93 + random() * 0.12;
for (const vertex of [a, b, c]) {
positionArray.push(vertex.x, vertex.y, vertex.z);
const color = baseColor.clone().multiplyScalar(variation);
colorArray.push(color.r, color.g, color.b);
}
}
function terrainColor(x, z, y) {
const color = new THREE.Color();
if (y < 0.62) {
color.set(0xc7b47b);
} else {
const n = hash(Math.round(x * 1.4), Math.round(z * 1.4));
color.set(0x557b53).lerp(new THREE.Color(0x789263), n * 0.68);
}
color.offsetHSL(0, 0, (random() - 0.5) * 0.035);
return color;
}
function oceanColor(x, z) {
const color = new THREE.Color(0x1c7182);
color.lerp(new THREE.Color(0x0e455a), random() * 0.7);
color.offsetHSL(0, 0, (random() - 0.5) * 0.025);
return color;
}
// -------------------------------------------------------------------------
// Tile base, low-poly land and ocean
// -------------------------------------------------------------------------
const tile = new THREE.Group();
scene.add(tile);
const base = new THREE.Mesh(
new THREE.BoxGeometry(36, 1.2, 26),
new THREE.MeshStandardMaterial({
color: 0x102b37,
roughness: 0.82,
metalness: 0.08
})
);
base.position.y = -0.66;
base.receiveShadow = true;
tile.add(base);
const lowerBase = new THREE.Mesh(
new THREE.BoxGeometry(35.2, 0.38, 25.2),
new THREE.MeshStandardMaterial({
color: 0x071820,
roughness: 0.9
})
);
lowerBase.position.y = -1.34;
tile.add(lowerBase);
const baseEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(base.geometry),
new THREE.LineBasicMaterial({
color: 0x315563,
transparent: true,
opacity: 0.45
})
);
baseEdges.position.copy(base.position);
tile.add(baseEdges);
const zRows = [-13, -9, -5, -1, 3, 7, 10, 13];
const landPositions = [];
const landColors = [];
for (let r = 0; r < zRows.length - 1; r++) {
const z0 = zRows[r];
const z1 = zRows[r + 1];
for (let c = 0; c < 5; c++) {
const x0 = THREE.MathUtils.lerp(-18, coastX(z0), c / 5);
const x1 = THREE.MathUtils.lerp(-18, coastX(z0), (c + 1) / 5);
const x2 = THREE.MathUtils.lerp(-18, coastX(z1), c / 5);
const x3 = THREE.MathUtils.lerp(-18, coastX(z1), (c + 1) / 5);
const a = new THREE.Vector3(x0, landHeight(x0, z0), z0);
const b = new THREE.Vector3(x1, landHeight(x1, z0), z0);
const cVec = new THREE.Vector3(x2, landHeight(x2, z1), z1);
const d = new THREE.Vector3(x3, landHeight(x3, z1), z1);
pushTriangle(
landPositions,
landColors,
a, d, b,
terrainColor((x0 + x1 + x2) / 3, (z0 + z1) / 2, (a.y + b.y + d.y) / 3)
);
pushTriangle(
landPositions,
landColors,
b, d, cVec,
terrainColor((x1 + x2 + x3) / 3, (z0 + z1) / 2, (b.y + cVec.y + d.y) / 3)
);
}
}
const landGeometry = new THREE.BufferGeometry();
landGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(landPositions, 3)
);
landGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(landColors, 3)
);
landGeometry.computeVertexNormals();
const land = new THREE.Mesh(
landGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 0.94,
metalness: 0
})
);
land.castShadow = true;
land.receiveShadow = true;
tile.add(land);
// Faceted ocean surface.
const oceanPositions = [];
const oceanColors = [];
for (let r = 0; r < zRows.length - 1; r++) {
const z0 = zRows[r];
const z1 = zRows[r + 1];
for (let c = 0; c < 5; c++) {
const x0 = THREE.MathUtils.lerp(coastX(z0), 18, c / 5);
const x1 = THREE.MathUtils.lerp(coastX(z0), 18, (c + 1) / 5);
const x2 = THREE.MathUtils.lerp(coastX(z1), 18, c / 5);
const x3 = THREE.MathUtils.lerp(coastX(z1), 18, (c + 1) / 5);
const a = new THREE.Vector3(x0, 0.015, z0);
const b = new THREE.Vector3(x1, 0.015, z0);
const cVec = new THREE.Vector3(x2, 0.015, z1);
const d = new THREE.Vector3(x3, 0.015, z1);
pushTriangle(
oceanPositions,
oceanColors,
a, d, b,
oceanColor((x0 + x1 + x2) / 3, (z0 + z1) / 2)
);
pushTriangle(
oceanPositions,
oceanColors,
b, d, cVec,
oceanColor((x1 + x2 + x3) / 3, (z0 + z1) / 2)
);
}
}
const oceanGeometry = new THREE.BufferGeometry();
oceanGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(oceanPositions, 3)
);
oceanGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(oceanColors, 3)
);
oceanGeometry.computeVertexNormals();
const ocean = new THREE.Mesh(
oceanGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 0.47,
metalness: 0.08
})
);
ocean.receiveShadow = true;
tile.add(ocean);
// Ochre coastal cliff faces.
const cliffPositions = [];
const cliffColors = [];
for (let i = 0; i < zRows.length - 1; i++) {
const z0 = zRows[i];
const z1 = zRows[i + 1];
const x0 = coastX(z0);
const x1 = coastX(z1);
const a = new THREE.Vector3(x0, landHeight(x0, z0), z0);
const b = new THREE.Vector3(x1, landHeight(x1, z1), z1);
const c = new THREE.Vector3(x1, -0.08, z1);
const d = new THREE.Vector3(x0, -0.08, z0);
pushTriangle(cliffPositions, cliffColors, a, d, b, new THREE.Color(0x9f875e));
pushTriangle(cliffPositions, cliffColors, b, d, c, new THREE.Color(0x806d50));
}
const cliffGeometry = new THREE.BufferGeometry();
cliffGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(cliffPositions, 3)
);
cliffGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(cliffColors, 3)
);
cliffGeometry.computeVertexNormals();
const cliffs = new THREE.Mesh(
cliffGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 0.96,
side: THREE.DoubleSide
})
);
cliffs.castShadow = true;
cliffs.receiveShadow = true;
tile.add(cliffs);
// Soft shadow receiver below the floating tile.
const shadowFloor = new THREE.Mesh(
new THREE.PlaneGeometry(120, 120),
new THREE.ShadowMaterial({
color: 0x000000,
opacity: 0.28
})
);
shadowFloor.rotation.x = -Math.PI / 2;
shadowFloor.position.y = -1.56;
shadowFloor.receiveShadow = true;
scene.add(shadowFloor);
// -------------------------------------------------------------------------
// Small environmental details
// -------------------------------------------------------------------------
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x5b4933,
roughness: 1,
flatShading: true
});
const foliageMaterials = [
new THREE.MeshStandardMaterial({ color: 0x315f49, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x477452, roughness: 1, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x6f895b, roughness: 1, flatShading: true })
];
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, landHeight(x, z), z);
tree.scale.setScalar(scale);
tree.rotation.y = random() * Math.PI * 2;
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.16, 0.72, 5),
trunkMaterial
);
trunk.position.y = 0.36;
trunk.castShadow = true;
tree.add(trunk);
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.64, 1.45, 6),
foliageMaterials[Math.floor(random() * foliageMaterials.length)]
);
crown.position.y = 1.2;
crown.castShadow = true;
tree.add(crown);
tile.add(tree);
}
for (let i = 0; i < 34; i++) {
let x = -16 + random() * 13;
const z = -11.5 + random() * 23;
if (coastX(z) - x < 1.3) {
x = coastX(z) - 1.7 - random() * 2;
}
addTree(x, z, 0.7 + random() * 0.65);
}
const wallMaterials = [
new THREE.MeshStandardMaterial({ color: 0xd9d1b7, roughness: 0.9, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x9cb0ad, roughness: 0.9, flatShading: true })
];
const roofMaterials = [
new THREE.MeshStandardMaterial({ color: 0x9c4939, roughness: 0.9, flatShading: true }),
new THREE.MeshStandardMaterial({ color: 0x3d5c69, roughness: 0.9, flatShading: true })
];
function addHouse(x, z, scale = 1) {
const house = new THREE.Group();
house.position.set(x, landHeight(x, z), z);
house.scale.setScalar(scale);
house.rotation.y = (random() - 0.5) * 0.3;
const body = new THREE.Mesh(
new THREE.BoxGeometry(1.05, 0.72, 0.85),
wallMaterials[Math.floor(random() * wallMaterials.length)]
);
body.position.y = 0.36;
body.castShadow = true;
body.receiveShadow = true;
house.add(body);
const roof = new THREE.Mesh(
new THREE.ConeGeometry(0.82, 0.68, 4),
roofMaterials[Math.floor(random() * roofMaterials.length)]
);
roof.position.y = 1.03;
roof.rotation.y = Math.PI / 4;
roof.castShadow = true;
house.add(roof);
tile.add(house);
}
[
[-11.4, -8.0, 1.0],
[-7.3, 0.2, 0.8],
[-12.4, 5.7, 1.1],
[-4.6, -7.1, 0.8],
[-9.3, 9.2, 0.9]
].forEach((entry) => addHouse(...entry));
// Coastal beacon.
const beacon = new THREE.Group();
const beaconX = coastX(-2.3) - 0.65;
const beaconZ = -2.3;
beacon.position.set(beaconX, landHeight(beaconX, beaconZ), beaconZ);
const tower = new THREE.Mesh(
new THREE.CylinderGeometry(0.32, 0.46, 2.35, 10),
new THREE.MeshStandardMaterial({
color: 0xe5dfcd,
roughness: 0.85,
flatShading: true
})
);
tower.position.y = 1.175;
tower.castShadow = true;
beacon.add(tower);
const beaconBand = new THREE.Mesh(
new THREE.CylinderGeometry(0.385, 0.405, 0.38, 10),
new THREE.MeshStandardMaterial({
color: 0xb94a3f,
roughness: 0.82,
flatShading: true
})
);
beaconBand.position.y = 1.45;
beacon.add(beaconBand);
const lantern = new THREE.Mesh(
new THREE.CylinderGeometry(0.4, 0.4, 0.45, 10),
new THREE.MeshStandardMaterial({
color: 0xffd98a,
emissive: 0xff9d42,
emissiveIntensity: 1.4,
roughness: 0.4
})
);
lantern.position.y = 2.55;
beacon.add(lantern);
const beaconRoof = new THREE.Mesh(
new THREE.ConeGeometry(0.52, 0.46, 10),
new THREE.MeshStandardMaterial({
color: 0x344852,
roughness: 0.8,
flatShading: true
})
);
beaconRoof.position.y = 2.98;
beacon.add(beaconRoof);
tile.add(beacon);
// Ocean buoys.
const buoyMaterial = new THREE.MeshStandardMaterial({
color: 0xf3b34f,
emissive: 0x7b3b0a,
emissiveIntensity: 0.25,
roughness: 0.7,
flatShading: true
});
const buoyGeometry = new THREE.CylinderGeometry(0.12, 0.22, 0.52, 6);
[
[6.6, -7.5],
[10.5, 2.2],
[5.8, 7.1],
[13.8, -9.2]
].forEach(([x, z]) => {
const buoy = new THREE.Mesh(buoyGeometry, buoyMaterial);
buoy.position.set(x, 0.23, z);
buoy.castShadow = true;
tile.add(buoy);
});
// Low-poly white wave marks.
const waves = [];
const waveGeometry = new THREE.BufferGeometry();
waveGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-0.56, 0, 0,
0.00, 0, -0.16,
0.56, 0, 0,
0.00, 0, -0.16,
0.22, 0, 0.18,
-0.18, 0, 0.18
], 3)
);
waveGeometry.computeVertexNormals();
for (let i = 0; i < 22; i++) {
const z = -11.5 + random() * 23;
const x = coastX(z) + 1 + random() * (17 - coastX(z));
const wave = new THREE.Mesh(
waveGeometry,
new THREE.MeshBasicMaterial({
color: 0xbde9e7,
transparent: true,
opacity: 0.26,
depthWrite: false,
side: THREE.DoubleSide
})
);
wave.position.set(x, 0.055, z);
wave.rotation.y = random() * Math.PI;
wave.userData.speed = 0.15 + random() * 0.22;
wave.userData.z = z;
waves.push(wave);
tile.add(wave);
}
// -------------------------------------------------------------------------
// Canvas sprite labels
// -------------------------------------------------------------------------
function createSprite(title, subtitle, accent = "#64f4df") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 144;
const context = canvas.getContext("2d");
context.fillStyle = "rgba(7, 20, 29, 0.88)";
context.strokeStyle = accent;
context.lineWidth = 3;
const x = 5;
const y = 5;
const w = 502;
const h = 134;
const r = 12;
context.beginPath();
context.moveTo(x + r, y);
context.lineTo(x + w - r, y);
context.quadraticCurveTo(x + w, y, x + w, y + r);
context.lineTo(x + w, y + h - r);
context.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
context.lineTo(x + r, y + h);
context.quadraticCurveTo(x, y + h, x, y + h - r);
context.lineTo(x, y + r);
context.quadraticCurveTo(x, y, x + r, y);
context.closePath();
context.fill();
context.stroke();
context.fillStyle = accent;
context.fillRect(26, 31, 6, 80);
context.textBaseline = "middle";
context.font = "700 39px system-ui, sans-serif";
context.fillText(title, 52, 54);
context.fillStyle = "#a6bdc0";
context.font = "600 21px system-ui, sans-serif";
context.fillText(subtitle, 52, 101);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(6.2, 1.74, 1);
return sprite;
}
const beaconLabel = createSprite("COASTAL BEACON", "FIXED LANDMARK");
beaconLabel.position.set(beaconX, 5.0, beaconZ);
beaconLabel.scale.set(4.6, 1.29, 1);
scene.add(beaconLabel);
// -------------------------------------------------------------------------
// Pass definitions and paths
// -------------------------------------------------------------------------
const passes = [
{
name: "Pass 01",
description: "Northern coastal track · west to east",
color: 0x64f4df,
cssColor: "#64f4df",
points: [
new THREE.Vector3(-23, 10, -7.6),
new THREE.Vector3(-15, 10, -7.1),
new THREE.Vector3(-5, 10, -6.2),
new THREE.Vector3(5, 10, -4.7),
new THREE.Vector3(14, 10, -2.8),
new THREE.Vector3(24, 10, -1.4)
]
},
{
name: "Pass 02",
description: "Southern coastal track · east to west",
color: 0xffc16d,
cssColor: "#ffc16d",
points: [
new THREE.Vector3(24, 10, 6.7),
new THREE.Vector3(16, 10, 5.9),
new THREE.Vector3(7, 10, 4.9),
new THREE.Vector3(-2, 10, 3.8),
new THREE.Vector3(-12, 10, 2.5),
new THREE.Vector3(-24, 10, 1.5)
]
}
];
passes.forEach((pass, index) => {
pass.curve = new THREE.CatmullRomCurve3(
pass.points,
false,
"catmullrom",
0.35
);
const pathMaterial = new THREE.MeshBasicMaterial({
color: pass.color,
transparent: true,
opacity: index === 0 ? 0.95 : 0.27
});
pass.pathMesh = new THREE.Mesh(
new THREE.TubeGeometry(pass.curve, 120, 0.055, 5, false),
pathMaterial
);
scene.add(pass.pathMesh);
const groundPoints = pass.curve.getPoints(180).map(
(point) => new THREE.Vector3(point.x, 0.36, point.z)
);
pass.groundMaterial = new THREE.LineDashedMaterial({
color: pass.color,
dashSize: 0.55,
gapSize: 0.38,
transparent: true,
opacity: index === 0 ? 0.75 : 0.2
});
pass.groundLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(groundPoints),
pass.groundMaterial
);
pass.groundLine.computeLineDistances();
scene.add(pass.groundLine);
const label = createSprite(
pass.name,
index === 0 ? "NORTHERN TRACK" : "SOUTHERN TRACK",
pass.cssColor
);
label.position.set(
index === 0 ? -17.4 : 17.4,
11.7,
index === 0 ? -7.3 : 5.9
);
scene.add(label);
});
// -------------------------------------------------------------------------
// Satellite with fixed local sensor geometry
// -------------------------------------------------------------------------
const satellite = new THREE.Group();
scene.add(satellite);
const satelliteMetal = new THREE.MeshStandardMaterial({
color: 0xb8c4c3,
metalness: 0.72,
roughness: 0.3,
flatShading: true
});
const darkMetal = new THREE.MeshStandardMaterial({
color: 0x26363d,
metalness: 0.7,
roughness: 0.42,
flatShading: true
});
const goldMaterial = new THREE.MeshStandardMaterial({
color: 0xd39b38,
metalness: 0.66,
roughness: 0.38,
flatShading: true
});
const panelMaterial = new THREE.MeshStandardMaterial({
color: 0x123c69,
metalness: 0.54,
roughness: 0.32,
flatShading: true
});
const body = new THREE.Mesh(
new THREE.BoxGeometry(1.65, 0.95, 1.08),
satelliteMetal
);
body.castShadow = true;
satellite.add(body);
const core = new THREE.Mesh(
new THREE.BoxGeometry(1.72, 0.28, 1.14),
goldMaterial
);
core.position.y = 0.24;
satellite.add(core);
for (const side of [-1, 1]) {
const panel = new THREE.Mesh(
new THREE.BoxGeometry(2.45, 0.075, 1.18),
panelMaterial
);
panel.position.x = side * 2.02;
panel.castShadow = true;
satellite.add(panel);
const boom = new THREE.Mesh(
new THREE.BoxGeometry(1.15, 0.075, 0.09),
goldMaterial
);
boom.position.x = side * 1.2;
satellite.add(boom);
for (let i = -2; i <= 2; i++) {
const grid = new THREE.Mesh(
new THREE.BoxGeometry(0.025, 0.085, 1.2),
darkMetal
);
grid.position.set(side * 2.02 + i * 0.45, 0, 0);
satellite.add(grid);
}
}
// Sensor assembly remains rigid and identically oriented on both passes.
const sensor = new THREE.Group();
satellite.add(sensor);
const sensorHousing = new THREE.Mesh(
new THREE.CylinderGeometry(0.27, 0.31, 0.58, 12),
darkMetal
);
sensorHousing.position.y = -0.76;
sensorHousing.castShadow = true;
sensor.add(sensorHousing);
const sensorRing = new THREE.Mesh(
new THREE.CylinderGeometry(0.34, 0.34, 0.12, 12),
goldMaterial
);
sensorRing.position.y = -1.04;
sensor.add(sensorRing);
const lensMaterial = new THREE.MeshStandardMaterial({
color: 0x9cfff0,
emissive: 0x3de8d5,
emissiveIntensity: 2.2,
metalness: 0.25,
roughness: 0.2
});
const lens = new THREE.Mesh(
new THREE.CylinderGeometry(0.255, 0.255, 0.035, 24),
lensMaterial
);
lens.position.y = -1.115;
sensor.add(lens);
const antenna = new THREE.Mesh(
new THREE.CylinderGeometry(0.025, 0.025, 0.75, 5),
satelliteMetal
);
antenna.position.set(0.45, 0.82, 0.25);
antenna.rotation.z = -0.25;
sensor.add(antenna);
// Fixed sensor footprint cone. Altitude is constant, so this never scales.
const beamMaterial = new THREE.MeshBasicMaterial({
color: 0x64f4df,
transparent: true,
opacity: 0.095,
side: THREE.DoubleSide,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const beam = new THREE.Mesh(
new THREE.CylinderGeometry(0.16, 2.25, 8.65, 24, 1, true),
beamMaterial
);
beam.position.y = -5.525;
sensor.add(beam);
const nadirLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, -1.13, 0),
new THREE.Vector3(0, -9.82, 0)
]),
new THREE.LineBasicMaterial({
color: 0xa5fff2,
transparent: true,
opacity: 0.5
})
);
sensor.add(nadirLine);
// -------------------------------------------------------------------------
// Moving observation footprint
// -------------------------------------------------------------------------
const footprint = new THREE.Group();
scene.add(footprint);
const footprintFill = new THREE.Mesh(
new THREE.CircleGeometry(2.25, 48),
new THREE.MeshBasicMaterial({
color: 0x64f4df,
transparent: true,
opacity: 0.12,
depthWrite: false,
side: THREE.DoubleSide
})
);
footprintFill.rotation.x = -Math.PI / 2;
footprintFill.position.y = 0.025;
footprint.add(footprintFill);
const footprintRing = new THREE.Mesh(
new THREE.RingGeometry(1.95, 2.05, 48),
new THREE.MeshBasicMaterial({
color: 0x64f4df,
transparent: true,
opacity: 0.95,
depthWrite: false,
side: THREE.DoubleSide
})
);
footprintRing.rotation.x = -Math.PI / 2;
footprintRing.position.y = 0.39;
footprint.add(footprintRing);
const crossGeometry = new THREE.BufferGeometry();
crossGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-2.55, 0, 0, 2.55, 0, 0,
0, 0, -2.55, 0, 0, 2.55,
-0.7, 0, 2.75, 0.7, 0, 2.75,
-0.7, 0, -2.75, 0.7, 0, -2.75
], 3)
);
const footprintCross = new THREE.LineSegments(
crossGeometry,
new THREE.LineBasicMaterial({
color: 0x64f4df,
transparent: true,
opacity: 0.9,
depthWrite: false
})
);
footprintCross.position.y = 0.4;
footprint.add(footprintCross);
// -------------------------------------------------------------------------
// Playback state
// -------------------------------------------------------------------------
const PASS_DURATION = 12.5;
let activePass = 0;
let passTime = 0;
let transitionTime = 0;
let playing = true;
let playbackSpeed = 1;
const passButtons = [...document.querySelectorAll(".pass-button")];
const progressElements = [$("progress0"), $("progress1")];
function selectPass(index, reset = true) {
activePass = index;
transitionTime = 0;
if (reset) {
passTime = 0;
}
playing = true;
$("pauseButton").textContent = "Pause";
updatePassUI();
}
function updatePassUI() {
const pass = passes[activePass];
$("passLabel").textContent = pass.name;
$("passLabel").style.color = pass.cssColor;
$("passDescription").textContent = pass.description;
passButtons.forEach((button, index) => {
button.classList.toggle("active", index === activePass);
});
passes.forEach((item, index) => {
const active = index === activePass;
item.pathMesh.material.opacity = active ? 0.95 : 0.25;
item.groundMaterial.opacity = active ? 0.75 : 0.18;
});
const accent = new THREE.Color(pass.color);
beamMaterial.color.copy(accent);
footprintFill.material.color.copy(accent);
footprintRing.material.color.copy(accent);
footprintCross.material.color.copy(accent);
}
passButtons.forEach((button) => {
button.addEventListener("click", () => {
selectPass(Number(button.dataset.pass));
});
});
$("pauseButton").addEventListener("click", () => {
playing = !playing;
$("pauseButton").textContent = playing ? "Pause" : "Resume";
});
$("replayButton").addEventListener("click", () => {
passTime = 0;
transitionTime = 0;
playing = true;
$("pauseButton").textContent = "Pause";
});
$("speedButton").addEventListener("click", () => {
const speeds = [0.5, 1, 1.5, 2];
const index = speeds.indexOf(playbackSpeed);
playbackSpeed = speeds[(index + 1) % speeds.length];
$("speedButton").textContent = `${playbackSpeed.toFixed(1)}×`;
});
updatePassUI();
// -------------------------------------------------------------------------
// Custom camera controls, implemented directly without addons
// -------------------------------------------------------------------------
const activePointers = new Map();
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
let pinchDistance = 0;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
canvas.setPointerCapture(event.pointerId);
if (activePointers.size === 1) {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
} else if (activePointers.size === 2) {
const points = [...activePointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 1 && dragging) {
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
cameraState.theta -= deltaX * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - deltaY * 0.005,
0.16,
1.42
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
} else if (activePointers.size === 2) {
const points = [...activePointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (pinchDistance / distance),
22,
75
);
}
pinchDistance = distance;
}
});
function releasePointer(event) {
activePointers.delete(event.pointerId);
if (activePointers.size === 0) {
dragging = false;
pinchDistance = 0;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
22,
75
);
}, { passive: false });
function setCameraPreset(preset) {
$("isoButton").classList.toggle("active", preset === "iso");
$("topButton").classList.toggle("active", preset === "top");
if (preset === "top") {
cameraState.theta = 0;
cameraState.phi = 0.09;
cameraState.radius = 47;
} else {
cameraState.theta = 0.76;
cameraState.phi = 1.02;
cameraState.radius = 49;
}
}
$("isoButton").addEventListener("click", () => setCameraPreset("iso"));
$("topButton").addEventListener("click", () => setCameraPreset("top"));
$("resetButton").addEventListener("click", () => setCameraPreset("iso"));
// -------------------------------------------------------------------------
// Animation and telemetry
// -------------------------------------------------------------------------
let previousTime = performance.now();
let animationTime = 0;
function formatClock(seconds) {
const minutes = Math.floor(seconds / 60).toString().padStart(2, "0");
const remainder = Math.floor(seconds % 60).toString().padStart(2, "0");
return `${minutes}:${remainder}`;
}
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min(0.05, (now - previousTime) / 1000);
previousTime = now;
animationTime += delta;
if (playing) {
if (passTime < PASS_DURATION) {
passTime = Math.min(PASS_DURATION, passTime + delta * playbackSpeed);
} else {
transitionTime += delta;
if (transitionTime > 1.35) {
selectPass((activePass + 1) % passes.length, true);
}
}
}
const pass = passes[activePass];
const progress = THREE.MathUtils.clamp(passTime / PASS_DURATION, 0, 1);
const satellitePosition = pass.curve.getPointAt(progress);
// The whole satellite/sensor assembly translates along the path.
// Its local geometry and orientation do not change.
satellite.position.copy(satellitePosition);
// The observed position is directly below the fixed nadir sensor.
footprint.position.set(satellitePosition.x, 0, satellitePosition.z);
const pulse = 1 + Math.sin(animationTime * 3.2) * 0.055;
footprintRing.scale.set(pulse, pulse, pulse);
// Gentle wave drift.
for (const wave of waves) {
wave.position.x += wave.userData.speed * delta;
if (wave.position.x > 17.5) {
wave.position.x = coastX(wave.userData.z) + 0.8;
}
}
// Telemetry.
const localX = satellitePosition.x;
const localZ = satellitePosition.z;
const longitude = -122.418 + localX * 0.0061;
const latitude = 37.704 - localZ * 0.0042;
$("positionReadout").textContent =
`${localX >= 0 ? "+" : ""}${localX.toFixed(1)} / ` +
`${localZ >= 0 ? "+" : ""}${localZ.toFixed(1)}`;
$("longitudeReadout").textContent =
`${Math.abs(longitude).toFixed(4)}° ${longitude >= 0 ? "E" : "W"}`;
$("latitudeReadout").textContent =
`${Math.abs(latitude).toFixed(4)}° ${latitude >= 0 ? "N" : "S"}`;
$("passState").textContent = playing
? (passTime >= PASS_DURATION ? "Standby" : "Tracking")
: "Paused";
progressElements.forEach((element, index) => {
const amount = index === activePass
? progress * 100
: (passTime >= PASS_DURATION ? 100 : 0);
element.style.width = `${amount}%`;
});
const currentClock = formatClock(passTime);
passButtons.forEach((button, index) => {
button.querySelector(".pass-time").textContent =
index === activePass ? currentClock : "00:00";
});
updateCamera();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
requestAnimationFrame(animate);
requestAnimationFrame(() => {
$("loading").classList.add("hidden");
setTimeout(() => $("loading").remove(), 600);
});
</script>
</body>
</html>
```