Prompt specification
Build or customize the Three.js 3D scene "Solar time beside civil-zone bands" 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: Solar time beside civil-zone bands
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/solar-time-beside-civil-zone-bands-x1351
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows time zones and local solar time. Show a globe with idealized longitude bands and a separate schematic civil-zone map. Use explicit legends to distinguish astronomical position from administrative timekeeping choices. Voxel style.
Working Three.js Starter (solar-time-beside-civil-zone-bands-x1351):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Solar / Civil — Voxel Time-Zone Atlas</title>
<style>
:root {
color-scheme: dark;
--bg: #050b12;
--panel: #0b1722;
--panel-2: #0e1c29;
--line: #22384a;
--text: #e8f1f5;
--muted: #90a7b5;
--cyan: #69e1e6;
--amber: #ffbf69;
--blue: #4da3d9;
--orange: #f07a52;
--shadow: #02060a;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-width: 320px;
background:
linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
var(--bg);
background-size: 32px 32px;
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
.app {
width: min(1680px, 100%);
margin: 0 auto;
padding: 22px;
}
header {
display: grid;
grid-template-columns: 1fr auto;
gap: 20px;
align-items: end;
margin-bottom: 18px;
}
.eyebrow {
color: var(--cyan);
font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: .18em;
text-transform: uppercase;
}
h1 {
margin: 7px 0 7px;
font-size: clamp(30px, 4vw, 58px);
line-height: .95;
letter-spacing: -.055em;
}
.intro {
max-width: 800px;
margin: 0;
color: var(--muted);
line-height: 1.5;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 9px;
align-items: end;
justify-content: flex-end;
}
.control {
display: grid;
gap: 5px;
}
.control label,
.control > span {
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: .12em;
text-transform: uppercase;
}
input[type="datetime-local"],
select,
button {
min-height: 40px;
border: 1px solid #365166;
border-radius: 0;
background: #0b1824;
color: var(--text);
padding: 8px 11px;
outline: none;
}
input[type="datetime-local"] { color-scheme: dark; }
input[type="range"] {
width: 125px;
accent-color: var(--cyan);
}
button {
cursor: pointer;
font-weight: 800;
box-shadow: 3px 3px 0 #03080d;
}
button:hover {
border-color: var(--cyan);
color: var(--cyan);
}
button:active {
transform: translate(2px, 2px);
box-shadow: 1px 1px 0 #03080d;
}
button.primary {
background: var(--cyan);
border-color: var(--cyan);
color: #071017;
}
.rate-value {
min-width: 83px;
color: var(--amber);
font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.distinction {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1px;
margin-bottom: 18px;
background: var(--line);
border: 1px solid var(--line);
box-shadow: 5px 5px 0 var(--shadow);
}
.distinction > div {
background: #09141e;
padding: 13px 16px;
}
.distinction strong {
display: block;
margin-bottom: 4px;
font-size: 13px;
}
.distinction p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.key-dot {
display: inline-block;
width: 9px;
height: 9px;
margin-right: 7px;
vertical-align: 1px;
}
.key-dot.astro { background: var(--amber); }
.key-dot.civil { background: var(--blue); }
.layout {
display: grid;
grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr);
gap: 18px;
}
.card {
min-width: 0;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 6px 6px 0 var(--shadow);
}
.card-head {
display: flex;
justify-content: space-between;
gap: 14px;
align-items: center;
min-height: 78px;
padding: 15px 17px;
border-bottom: 1px solid var(--line);
background: var(--panel-2);
}
.card-head h2 {
margin: 4px 0 0;
font-size: clamp(19px, 2vw, 27px);
letter-spacing: -.03em;
}
.card-head button {
min-height: 34px;
padding: 6px 9px;
font-size: 11px;
white-space: nowrap;
}
.stage {
position: relative;
height: clamp(490px, 65vh, 720px);
min-height: 490px;
overflow: hidden;
background: #07111a;
}
.stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.stage-tag {
position: absolute;
top: 14px;
left: 14px;
z-index: 2;
padding: 8px 10px;
border: 1px solid #3b5365;
background: rgba(5, 12, 18, .88);
color: var(--muted);
font: 700 10px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: .09em;
pointer-events: none;
}
.stage-tag b {
display: block;
margin-top: 3px;
color: var(--text);
font-size: 12px;
letter-spacing: .02em;
}
.stage-help {
position: absolute;
right: 14px;
bottom: 14px;
z-index: 2;
padding: 7px 9px;
background: rgba(5, 12, 18, .8);
border: 1px solid #294052;
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
pointer-events: none;
}
.corner-readout {
position: absolute;
left: 14px;
bottom: 14px;
z-index: 2;
min-width: 205px;
padding: 11px 12px;
border-left: 3px solid var(--amber);
background: rgba(5, 12, 18, .88);
pointer-events: none;
}
.corner-readout .label,
.readout .label {
color: var(--muted);
font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: .13em;
text-transform: uppercase;
}
.corner-readout .value {
margin-top: 4px;
font: 800 20px/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.corner-readout .sub {
margin-top: 4px;
color: var(--muted);
font-size: 11px;
}
.legend {
padding: 15px 17px 12px;
border-top: 1px solid var(--line);
}
.legend-head {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: baseline;
margin-bottom: 11px;
}
.legend-title {
font-weight: 900;
font-size: 13px;
}
.legend-note {
color: var(--muted);
font-size: 11px;
line-height: 1.4;
}
.solar-ramp {
height: 15px;
border: 1px solid #344b5e;
background: linear-gradient(90deg,
#18234f 0%, #18234f 16%,
#e56b6b 25%,
#f6bd60 36%,
#ffe3a3 52%,
#f39c5b 70%,
#b05a8f 83%,
#18234f 100%);
}
.ramp-labels {
display: flex;
justify-content: space-between;
margin-top: 6px;
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.civil-ramp {
height: 15px;
border: 1px solid #344b5e;
background: linear-gradient(90deg, #2777b9, #4fa3d9, #5fd0c5, #f3b04b, #ef6a45);
}
.readouts {
display: grid;
grid-template-columns: repeat(3, 1fr);
border-top: 1px solid var(--line);
}
.readout {
min-height: 78px;
padding: 13px 16px;
border-right: 1px solid var(--line);
}
.readout:last-child { border-right: 0; }
.readout .value {
margin-top: 7px;
font: 800 15px/1.25 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.map-controls {
display: grid;
grid-template-columns: 1fr auto;
gap: 12px;
align-items: end;
padding: 13px 17px;
border-top: 1px solid var(--line);
}
.map-controls .control { width: 100%; }
.map-controls select { width: 100%; }
.zone-panel {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1px;
background: var(--line);
border-top: 1px solid var(--line);
}
.zone-cell {
min-height: 95px;
padding: 14px 16px;
background: #09141e;
}
.zone-cell .value {
margin: 7px 0 4px;
color: var(--cyan);
font: 900 24px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.zone-cell .sub {
color: var(--muted);
font-size: 11px;
line-height: 1.4;
}
footer {
display: flex;
justify-content: space-between;
gap: 18px;
margin-top: 16px;
color: #6f8795;
font-size: 11px;
line-height: 1.5;
}
footer code {
color: #a8bbc5;
}
@media (max-width: 1050px) {
header { grid-template-columns: 1fr; }
.controls { justify-content: flex-start; }
.layout { grid-template-columns: 1fr; }
.stage { height: 610px; }
}
@media (max-width: 620px) {
.app { padding: 12px; }
.distinction { grid-template-columns: 1fr; }
.controls { display: grid; grid-template-columns: 1fr 1fr; }
.controls .wide { grid-column: 1 / -1; }
.stage { height: 480px; min-height: 480px; }
.readouts { grid-template-columns: 1fr; }
.readout { border-right: 0; border-bottom: 1px solid var(--line); }
.readout:last-child { border-bottom: 0; }
.zone-panel { grid-template-columns: 1fr; }
.card-head { align-items: flex-start; }
footer { flex-direction: column; }
}
</style>
</head>
<body>
<div class="app">
<header>
<div>
<div class="eyebrow">Voxel time atlas / UTC reference</div>
<h1>Solar / Civil</h1>
<p class="intro">
Two clocks, two truths: astronomical longitude determines the local solar clock;
civil authorities determine which UTC offset a place uses.
</p>
</div>
<div class="controls" aria-label="Time controls">
<div class="control wide">
<label for="utcInput">Reference time — interpreted as UTC</label>
<input id="utcInput" type="datetime-local" step="1" />
</div>
<div class="control">
<button id="nowButton" class="primary">Now</button>
</div>
<div class="control">
<button id="playButton">Pause</button>
</div>
<div class="control">
<label for="rateSlider">Simulation speed</label>
<div style="display:flex;align-items:center;gap:8px">
<input id="rateSlider" type="range" min="1" max="60" value="10" />
<span id="rateValue" class="rate-value">10 min/s</span>
</div>
</div>
</div>
</header>
<div class="distinction">
<div>
<strong><span class="key-dot astro"></span>Globe = astronomical position</strong>
<p>Voxel longitude is converted to local apparent solar time, including the equation of time. Its colors show clock phase—not civil UTC or exact sunrise.</p>
</div>
<div>
<strong><span class="key-dot civil"></span>Map = administrative timekeeping</strong>
<p>Blocks are schematic representative civil zones. Their colors and labels encode a chosen UTC offset, which need not follow a meridian.</p>
</div>
</div>
<main class="layout">
<section class="card">
<div class="card-head">
<div>
<div class="eyebrow">01 / astronomical</div>
<h2>Longitude bands / local solar clock</h2>
</div>
<button id="resetGlobe">Reset view</button>
</div>
<div class="stage" id="globeStage">
<canvas id="globeCanvas" aria-label="Voxel globe showing local solar time by longitude"></canvas>
<div class="stage-tag">
IDELALIZED EARTH GRID
<b>5° longitude × 5° latitude voxels</b>
</div>
<div class="corner-readout">
<div class="label">Selected meridian</div>
<div id="selectedLongitude" class="value">0°</div>
<div id="selectedSolarTime" class="sub">Local solar time</div>
</div>
<div class="stage-help">DRAG TO ORBIT · WHEEL TO ZOOM · CLICK A VOXEL</div>
</div>
<div class="legend">
<div class="legend-head">
<div class="legend-title">Astronomical dial legend</div>
<div class="legend-note">A color follows longitude around the Earth. It is not a civil time-zone color.</div>
</div>
<div class="solar-ramp"></div>
<div class="ramp-labels">
<span>00</span><span>04</span><span>06</span><span>09</span>
<span>12 / solar noon</span><span>15</span><span>18</span><span>20</span><span>24</span>
</div>
</div>
<div class="readouts">
<div class="readout">
<div class="label">Reference UTC</div>
<div id="utcReadout" class="value">—</div>
</div>
<div class="readout">
<div class="label">Equation of time</div>
<div id="eotReadout" class="value">—</div>
</div>
<div class="readout">
<div class="label">Subsolar meridian</div>
<div id="subsolarReadout" class="value">—</div>
</div>
</div>
</section>
<section class="card">
<div class="card-head">
<div>
<div class="eyebrow">02 / administrative</div>
<h2>Schematic civil-zone map</h2>
</div>
<button id="resetMap">Reset map</button>
</div>
<div class="stage" id="mapStage">
<canvas id="mapCanvas" aria-label="Schematic map of representative civil time zones"></canvas>
<div class="stage-tag">
CIVIL OFFSET TERRITORY
<b>Representative standard offsets / DST excluded</b>
</div>
<div class="stage-help">DRAG TO PAN · WHEEL TO ZOOM · CLICK A BLOCK</div>
</div>
<div class="map-controls">
<div class="control">
<label for="zoneSelect">Inspect a civil zone</label>
<select id="zoneSelect"></select>
</div>
<div class="control">
<span>Selected block</span>
<button id="clearSelection">Clear</button>
</div>
</div>
<div class="legend">
<div class="legend-head">
<div class="legend-title">Civil offset legend</div>
<div class="legend-note">Hue separates negative, zero, and positive UTC offsets. Exact offsets are printed on blocks.</div>
</div>
<div class="civil-ramp"></div>
<div class="ramp-labels">
<span>UTC−12</span><span>UTC−08</span><span>UTC−05</span>
<span>UTC 00</span><span>UTC+05:30</span><span>UTC+09</span><span>UTC+14</span>
</div>
</div>
<div class="zone-panel">
<div class="zone-cell">
<div class="label">Selected civil offset</div>
<div id="zoneOffset" class="value">UTC+00:00</div>
<div id="zoneName" class="sub">London / UTC</div>
</div>
<div class="zone-cell">
<div class="label">Local civil clock</div>
<div id="zoneClock" class="value">00:00</div>
<div id="zoneDate" class="sub">—</div>
</div>
</div>
</section>
</main>
<footer>
<div>
<strong>Interpretation:</strong> the globe is a geometric teaching model, not a terrain or eclipse simulation.
The map is schematic, not a legal or exhaustive time-zone boundary map.
</div>
<div><code>Three.js r160 · core ES module only</code></div>
</footer>
</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);
const state = {
timeMs: Date.now(),
playing: false,
rate: 10,
selectedLongitude: 0,
selectedZone: "z0",
mapZoom: 1,
mapPanX: 0,
mapPanY: 0
};
const pad = n => String(n).padStart(2, "0");
function utcDateString(ms) {
const d = new Date(ms);
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;
}
function utcClockString(ms) {
const d = new Date(ms);
return `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;
}
function utcInputValue(ms) {
const d = new Date(ms);
return `${utcDateString(ms)}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}`;
}
function formatOffset(offset, long = true) {
const sign = offset < 0 ? "−" : "+";
const absolute = Math.abs(offset);
const hours = Math.floor(absolute);
const minutes = Math.round((absolute - hours) * 60);
return `UTC${sign}${pad(hours)}${minutes ? `:${pad(minutes)}` : ""}${long ? ":00" : ""}`;
}
function offsetLabel(offset) {
return formatOffset(offset, false);
}
function clockAtOffset(ms, offset) {
return new Date(ms + offset * 3600000);
}
function localClockAtOffset(ms, offset) {
const d = clockAtOffset(ms, offset);
return `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;
}
function dateAtOffset(ms, offset) {
const d = clockAtOffset(ms, offset);
return `${utcDateString(d.getTime())} · UTC-based civil date`;
}
function dayOfYear(ms) {
const d = new Date(ms);
return Math.floor((Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()) -
Date.UTC(d.getUTCFullYear(), 0, 0)) / 86400000);
}
function equationOfTime(ms) {
const d = new Date(ms);
const utcHours = d.getUTCHours() + d.getUTCMinutes() / 60 + d.getUTCSeconds() / 3600;
const n = dayOfYear(ms);
const gamma = 2 * Math.PI / 365 * (n - 1 + (utcHours - 12) / 24);
return 229.18 * (
0.000075 +
0.001868 * Math.cos(gamma) -
0.032077 * Math.sin(gamma) -
0.014615 * Math.cos(2 * gamma) -
0.040849 * Math.sin(2 * gamma)
);
}
function declination(ms) {
const n = dayOfYear(ms);
return 23.44 * Math.sin(2 * Math.PI * (284 + n) / 365);
}
function subsolarLongitude(ms) {
const d = new Date(ms);
const utcHours = d.getUTCHours() + d.getUTCMinutes() / 60 + d.getUTCSeconds() / 3600;
let lon = 15 * (12 - utcHours - equationOfTime(ms) / 60);
lon = ((lon + 540) % 360) - 180;
return lon;
}
function localSolarMinutes(ms, longitude) {
const d = new Date(ms);
const utcMinutes = d.getUTCHours() * 60 + d.getUTCMinutes() + d.getUTCSeconds() / 60;
return ((utcMinutes + longitude * 4 + equationOfTime(ms)) % 1440 + 1440) % 1440;
}
function solarColor(minutes) {
const hour = minutes / 60;
if (hour < 4.3) return "#18234f";
if (hour < 6.0) return "#e56b6b";
if (hour < 9.0) return "#f6bd60";
if (hour < 15.0) return "#ffe3a3";
if (hour < 18.0) return "#f39c5b";
if (hour < 20.0) return "#b05a8f";
return "#18234f";
}
function longitudeText(lon) {
const value = Math.abs(lon) < 0.05 ? 0 : lon;
return `${Math.abs(value).toFixed(1)}° ${value === 0 ? "" : value > 0 ? "E" : "W"}`;
}
function makeLabelSprite(text, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = options.width || 512;
canvas.height = options.height || 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = options.background || "rgba(5, 12, 18, 0.88)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = options.border || "#4b6578";
ctx.lineWidth = 6;
ctx.strokeRect(3, 3, canvas.width - 6, canvas.height - 6);
ctx.fillStyle = options.color || "#e8f1f5";
ctx.font = `${options.weight || 700} ${options.fontSize || 48}px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: options.depthTest !== false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
const width = options.scale || 1.05;
sprite.scale.set(width, width * 0.25, 1);
sprite.userData.isLabel = true;
return sprite;
}
function civilColor(offset) {
let hue;
let saturation;
let lightness;
if (offset < 0) {
hue = 205 + ((offset + 12) / 12) * 35;
saturation = 67;
lightness = 43 + ((offset + 12) / 12) * 10;
} else if (offset === 0) {
hue = 166;
saturation = 48;
lightness = 51;
} else {
hue = 43 - (offset / 14) * 31;
saturation = 79;
lightness = 49 - (offset / 14) * 5;
}
return new THREE.Color().setHSL(hue / 360, saturation / 100, lightness / 100);
}
// ---------------------------------------------------------------------
// GLOBE
// ---------------------------------------------------------------------
const globeRenderer = new THREE.WebGLRenderer({
canvas: $("globeCanvas"),
antialias: true,
alpha: false
});
globeRenderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
globeRenderer.outputColorSpace = THREE.SRGBColorSpace;
const globeScene = new THREE.Scene();
globeScene.background = new THREE.Color("#07111a");
const globeCamera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const globeState = { yaw: 0.62, pitch: 0.28, radius: 6.55 };
const globeAmbient = new THREE.AmbientLight(0x8aa5b6, 1.35);
globeScene.add(globeAmbient);
const globeKey = new THREE.DirectionalLight(0xffffff, 2.2);
globeKey.position.set(-4, 5, 5);
globeScene.add(globeKey);
const globeFill = new THREE.DirectionalLight(0x3c6f8c, 1.1);
globeFill.position.set(4, -2, -3);
globeScene.add(globeFill);
const innerSphere = new THREE.Mesh(
new THREE.SphereGeometry(2.03, 48, 32),
new THREE.MeshStandardMaterial({ color: 0x07111a, roughness: 1, metalness: 0 })
);
globeScene.add(innerSphere);
const voxelGeometry = new THREE.BoxGeometry(0.079, 0.079, 0.052);
const voxelMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 0.76,
metalness: 0.04
});
const longitudeCount = 72;
const latitudeCount = 36;
const voxelCount = longitudeCount * latitudeCount;
const globeVoxels = new THREE.InstancedMesh(voxelGeometry, voxelMaterial, voxelCount);
globeVoxels.instanceMatrix.setUsage(THREE.StaticDrawUsage);
const dummy = new THREE.Object3D();
const normal = new THREE.Vector3();
const zAxis = new THREE.Vector3(0, 0, 1);
const globeRadius = 2.18;
let voxelIndex = 0;
for (let latIndex = 0; latIndex < latitudeCount; latIndex++) {
const latitude = 87.5 - latIndex * 5;
const phi = (90 - latitude) * Math.PI / 180;
for (let lonIndex = 0; lonIndex < longitudeCount; lonIndex++) {
const longitude = -180 + lonIndex * 5;
const theta = longitude * Math.PI / 180;
normal.set(
Math.sin(phi) * Math.cos(theta),
Math.cos(phi),
Math.sin(phi) * Math.sin(theta)
);
dummy.position.copy(normal).multiplyScalar(globeRadius);
dummy.quaternion.setFromUnitVectors(zAxis, normal);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
globeVoxels.setMatrixAt(voxelIndex, dummy.matrix);
globeVoxels.setColorAt(voxelIndex, new THREE.Color(solarColor(localSolarMinutes(state.timeMs, longitude))));
globeVoxels.userData.voxels = globeVoxels.userData.voxels || [];
globeVoxels.userData.voxels.push({ longitude, latitude });
voxelIndex++;
}
}
globeVoxels.instanceMatrix.needsUpdate = true;
globeVoxels.instanceColor.needsUpdate = true;
globeScene.add(globeVoxels);
function makeCircle(radius, latitude, segments = 160) {
const points = [];
const phi = (90 - latitude) * Math.PI / 180;
for (let i = 0; i <= segments; i++) {
const theta = i / segments * Math.PI * 2;
points.push(new THREE.Vector3(
radius * Math.sin(phi) * Math.cos(theta),
radius * Math.cos(phi),
radius * Math.sin(phi) * Math.sin(theta)
));
}
return new THREE.BufferGeometry().setFromPoints(points);
}
const equator = new THREE.Line(
makeCircle(2.245, 0),
new THREE.LineBasicMaterial({ color: 0x90a7b5, transparent: true, opacity: 0.28 })
);
globeScene.add(equator);
const selectedMeridianPositions = new Float32Array(65 * 3);
const selectedMeridianGeometry = new THREE.BufferGeometry();
selectedMeridianGeometry.setAttribute("position", new THREE.BufferAttribute(selectedMeridianPositions, 3));
const selectedMeridian = new THREE.Line(
selectedMeridianGeometry,
new THREE.LineBasicMaterial({ color: 0x69e1e6, transparent: true, opacity: 0.95 })
);
globeScene.add(selectedMeridian);
function updateSelectedMeridian(longitude) {
const theta = longitude * Math.PI / 180;
for (let i = 0; i <= 64; i++) {
const latitude = -90 + i / 64 * 180;
const phi = (90 - latitude) * Math.PI / 180;
selectedMeridianPositions[i * 3] = 2.265 * Math.sin(phi) * Math.cos(theta);
selectedMeridianPositions[i * 3 + 1] = 2.265 * Math.cos(phi);
selectedMeridianPositions[i * 3 + 2] = 2.265 * Math.sin(phi) * Math.sin(theta);
}
selectedMeridianGeometry.attributes.position.needsUpdate = true;
selectedMeridianGeometry.computeBoundingSphere();
}
updateSelectedMeridian(state.selectedLongitude);
const sunMarker = new THREE.Mesh(
new THREE.BoxGeometry(0.15, 0.15, 0.15),
new THREE.MeshStandardMaterial({
color: 0xffcf66,
emissive: 0xff8d28,
emissiveIntensity: 2.1,
roughness: 0.45
})
);
globeScene.add(sunMarker);
const sunHalo = new THREE.Mesh(
new THREE.BoxGeometry(0.26, 0.26, 0.26),
new THREE.MeshBasicMaterial({
color: 0xffb54d,
transparent: true,
opacity: 0.18,
depthWrite: false
})
);
globeScene.add(sunHalo);
const sunLabel = makeLabelSprite("SUN", {
scale: 0.5,
fontSize: 52,
background: "rgba(255, 174, 61, 0.88)",
border: "#ffd37d",
color: "#211304",
depthTest: false
});
globeScene.add(sunLabel);
const sunLight = new THREE.PointLight(0xffb24b, 2.5, 12);
globeScene.add(sunLight);
for (const longitude of [-180, -90, 0, 90, 180]) {
const label = makeLabelSprite(longitudeText(longitude), {
scale: 0.72,
fontSize: 44,
depthTest: false
});
const theta = longitude * Math.PI / 180;
label.position.set(2.48 * Math.cos(theta), 0.03, 2.48 * Math.sin(theta));
globeScene.add(label);
}
function updateGlobeCamera() {
const { yaw, pitch, radius } = globeState;
globeCamera.position.set(
radius * Math.cos(pitch) * Math.sin(yaw),
radius * Math.sin(pitch),
radius * Math.cos(pitch) * Math.cos(yaw)
);
globeCamera.lookAt(0, 0, 0);
}
updateGlobeCamera();
const globeRaycaster = new THREE.Raycaster();
const globePointer = new THREE.Vector2();
let globePointerDown = null;
$("globeCanvas").addEventListener("pointerdown", event => {
globePointerDown = { x: event.clientX, y: event.clientY, moved: 0 };
$("globeCanvas").setPointerCapture(event.pointerId);
});
$("globeCanvas").addEventListener("pointermove", event => {
if (!globePointerDown) return;
const dx = event.clientX - globePointerDown.x;
const dy = event.clientY - globePointerDown.y;
globePointerDown.moved += Math.abs(dx) + Math.abs(dy);
globePointerDown.x = event.clientX;
globePointerDown.y = event.clientY;
globeState.yaw -= dx * 0.006;
globeState.pitch = THREE.MathUtils.clamp(globeState.pitch + dy * 0.006, -1.3, 1.3);
updateGlobeCamera();
});
$("globeCanvas").addEventListener("pointerup", event => {
if (globePointerDown && globePointerDown.moved < 6) {
const rect = $("globeCanvas").getBoundingClientRect();
globePointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
globePointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
globeRaycaster.setFromCamera(globePointer, globeCamera);
const hit = globeRaycaster.intersectObject(globeVoxels)[0];
if (hit && hit.instanceId !== undefined) {
const voxel = globeVoxels.userData.voxels[hit.instanceId];
state.selectedLongitude = voxel.longitude;
updateSelectedMeridian(state.selectedLongitude);
updateReadouts();
}
}
globePointerDown = null;
});
$("globeCanvas").addEventListener("pointercancel", () => globePointerDown = null);
$("globeCanvas").addEventListener("wheel", event => {
event.preventDefault();
globeState.radius = THREE.MathUtils.clamp(
globeState.radius + event.deltaY * 0.004,
3.7,
9.0
);
updateGlobeCamera();
}, { passive: false });
$("resetGlobe").addEventListener("click", () => {
globeState.yaw = 0.62;
globeState.pitch = 0.28;
globeState.radius = 6.55;
updateGlobeCamera();
});
// ---------------------------------------------------------------------
// CIVIL ZONE DATA
// ---------------------------------------------------------------------
const zones = [
{ id: "z12", offset: -12, city: "Baker Island" },
{ id: "z11", offset: -11, city: "Pago Pago" },
{ id: "z10", offset: -10, city: "Honolulu" },
{ id: "z9", offset: -9, city: "Anchorage" },
{ id: "z8", offset: -8, city: "Los Angeles" },
{ id: "z7", offset: -7, city: "Denver" },
{ id: "z6", offset: -6, city: "Chicago" },
{ id: "z5", offset: -5, city: "New York" },
{ id: "z4", offset: -4, city: "Caracas" },
{ id: "z3", offset: -3, city: "São Paulo" },
{ id: "z2", offset: -2, city: "Nuuk" },
{ id: "z1", offset: -1, city: "Azores" },
{ id: "z0", offset: 0, city: "London" },
{ id: "p1", offset: 1, city: "Berlin / Paris" },
{ id: "p2", offset: 2, city: "Kyiv / Helsinki" },
{ id: "p3", offset: 3, city: "Moscow" },
{ id: "p4", offset: 4, city: "Dubai" },
{ id: "p5", offset: 5, city: "Karachi" },
{ id: "p55", offset: 5.5, city: "New Delhi" },
{ id: "p575", offset: 5.75, city: "Kathmandu" },
{ id: "p6", offset: 6, city: "Dhaka" },
{ id: "p65", offset: 6.5, city: "Yangon" },
{ id: "p7", offset: 7, city: "Bangkok / Jakarta" },
{ id: "p8", offset: 8, city: "Shanghai / Singapore" },
{ id: "p875", offset: 8.75, city: "Eucla" },
{ id: "p9", offset: 9, city: "Tokyo / Seoul" },
{ id: "p95", offset: 9.5, city: "Darwin" },
{ id: "p10", offset: 10, city: "Sydney" },
{ id: "p105", offset: 10.5, city: "Lord Howe Island" },
{ id: "p11", offset: 11, city: "Honiara" },
{ id: "p12", offset: 12, city: "Auckland / Fiji" },
{ id: "p1275", offset: 12.75, city: "Chatham Islands" },
{ id: "p13", offset: 13, city: "Apia" },
{ id: "p14", offset: 14, city: "Kiritimati" }
];
const zoneById = Object.fromEntries(zones.map(zone => [zone.id, zone]));
const zoneSelect = $("zoneSelect");
zones.forEach(zone => {
const option = document.createElement("option");
option.value = zone.id;
option.textContent = `${formatOffset(zone.offset)} · ${zone.city}`;
zoneSelect.appendChild(option);
});
zoneSelect.value = state.selectedZone;
// Coarse land silhouettes; civil assignment is intentionally schematic.
const landPolygons = [
[[-168,72],[-145,72],[-130,60],[-125,48],[-116,31],[-104,22],[-95,16],[-82,24],[-66,44],[-52,50],[-60,64],[-85,70],[-120,76]],
[[-81,12],[-67,10],[-50,2],[-35,-7],[-42,-23],[-54,-55],[-70,-50],[-78,-15]],
[[-10,36],[-10,58],[2,71],[28,71],[40,59],[29,44],[20,35],[5,36]],
[[-18,35],[9,37],[35,30],[52,12],[42,-12],[29,-35],[14,-35],[4,-9],[-16,15]],
[[30,40],[40,70],[80,75],[130,70],[180,60],[180,44],[145,35],[125,20],[104,0],[80,8],[64,25],[44,30]],
[[112,-11],[132,-10],[153,-25],[145,-42],[115,-35]],
[[-55,82],[-22,76],[-25,60],[-50,58]],
[[166,-34],[179,-37],[177,-47],[168,-46]]
];
function pointInPolygon(x, y, polygon) {
let inside = false;
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
const [xi, yi] = polygon[i];
const [xj, yj] = polygon[j];
const intersects = ((yi > y) !== (yj > y)) &&
(x < (xj - xi) * (y - yi) / ((yj - yi) || 1e-9) + xi);
if (intersects) inside = !inside;
}
return inside;
}
function assignZone(landIndex, longitude, latitude) {
if (landIndex === 0) {
if (longitude < -140 && latitude > 50) return "z9";
if (longitude < -125) return "z8";
if (longitude < -105) return "z7";
if (longitude < -87) return "z6";
if (longitude < -67) return "z5";
return "z4";
}
if (landIndex === 1) return longitude > -43 ? "z3" : "z4";
if (landIndex === 2) {
if (longitude < 0) return "z0";
if (longitude < 15) return "p1";
if (longitude < 30) return "p2";
return "p3";
}
if (landIndex === 3) {
if (latitude < -25) return "p2";
if (latitude < 28 && longitude > 32) return "p4";
if (longitude < 10) return "z0";
if (longitude < 35) return "p1";
return "p3";
}
if (landIndex === 4) {
if (latitude < 5) {
if (longitude < 100) return "p7";
if (longitude < 120) return "p8";
if (longitude < 145) return "p10";
if (longitude < 160) return "p11";
return "p12";
}
if (longitude < 45) return "p3";
if (longitude < 58) return "p4";
if (longitude < 68) return "p5";
if (longitude < 78) return "p5";
if (longitude < 84) return "p55";
if (longitude < 90) return "p575";
if (longitude < 94) return "p65";
if (longitude < 97) return "p6";
if (longitude < 107) return "p7";
if (longitude < 127) return "p8";
if (longitude < 145) return "p9";
if (longitude < 160) return "p10";
if (longitude < 170) return "p11";
return "p12";
}
if (landIndex === 5) {
return longitude < 129 ? "p95" : "p10";
}
if (landIndex === 6) return "z2";
if (landIndex === 7) return "p12";
return "p8";
}
const specialCells = [
[-177.5, 2.5, "z12"],
[-177.5, -17.5, "z11"],
[-172.5, -12.5, "p13"],
[-157.5, 2.5, "p14"],
[-157.5, 22.5, "z10"],
[-167.5, 57.5, "z9"],
[-27.5, 37.5, "z1"],
[77.5, 22.5, "p55"],
[82.5, 27.5, "p575"],
[92.5, 22.5, "p6"],
[97.5, 17.5, "p65"],
[127.5, -27.5, "p875"],
[137.5, 37.5, "p9"],
[132.5, -22.5, "p95"],
[157.5, -32.5, "p105"],
[162.5, -7.5, "p11"],
[172.5, -42.5, "p12"],
[-177.5, -42.5, "p1275"],
[177.5, -17.5, "p12"]
];
// ---------------------------------------------------------------------
// CIVIL MAP
// ---------------------------------------------------------------------
const mapRenderer = new THREE.WebGLRenderer({
canvas: $("mapCanvas"),
antialias: true,
alpha: false
});
mapRenderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
mapRenderer.outputColorSpace = THREE.SRGBColorSpace;
const mapScene = new THREE.Scene();
mapScene.background = new THREE.Color("#06111a");
const mapCamera = new THREE.OrthographicCamera(-6.4, 6.4, 4, -4, 0.1, 100);
mapCamera.position.set(0, 0, 10);
mapScene.add(new THREE.AmbientLight(0xffffff, 1.8));
const mapLight = new THREE.DirectionalLight(0xffffff, 2.2);
mapLight.position.set(-4, 6, 8);
mapScene.add(mapLight);
const ocean = new THREE.Mesh(
new THREE.BoxGeometry(13.1, 8.05, 0.18),
new THREE.MeshStandardMaterial({ color: 0x081824, roughness: 0.95, metalness: 0.02 })
);
ocean.position.z = -0.2;
mapScene.add(ocean);
function mapX(longitude) {
return (longitude + 180) / 360 * 12.8;
}
function mapY(latitude) {
return (latitude - 12.5) / 145 * 7.5;
}
const gridVertices = [];
for (let longitude = -180; longitude <= 180; longitude += 30) {
const x = mapX(longitude);
gridVertices.push(x, mapY(-60), -0.095, x, mapY(85), -0.095);
}
for (let latitude = -60; latitude <= 85; latitude += 30) {
const y = mapY(latitude);
gridVertices.push(mapX(-180), y, -0.095, mapX(180), y, -0.095);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute("position", new THREE.Float32BufferAttribute(gridVertices, 3));
mapScene.add(new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({ color: 0x244253, transparent: true, opacity: 0.42 })
));
const cellsByZone = Object.fromEntries(zones.map(zone => [zone.id, []]));
for (let yi = 0; yi < 29; yi++) {
const latitude = -57.5 + yi * 5;
for (let xi = 0; xi < 72; xi++) {
const longitude = -177.5 + xi * 5;
const special = specialCells.find(cell =>
Math.abs(cell[0] - longitude) < 0.1 && Math.abs(cell[1] - latitude) < 0.1
);
let zoneId = special ? special[2] : null;
if (!zoneId) {
const landIndex = landPolygons.findIndex(polygon =>
pointInPolygon(longitude, latitude, polygon)
);
if (landIndex !== -1) zoneId = assignZone(landIndex, longitude, latitude);
}
if (zoneId) cellsByZone[zoneId].push({ longitude, latitude });
}
}
const mapCellGeometry = new THREE.BoxGeometry(0.151, 0.225, 0.11);
const mapZoneMeshes = {};
for (const zone of zones) {
const cells = cellsByZone[zone.id];
const material = new THREE.MeshStandardMaterial({
color: civilColor(zone.offset),
roughness: 0.72,
metalness: 0.05,
emissive: 0x000000,
emissiveIntensity: 0.05
});
const mesh = new THREE.InstancedMesh(mapCellGeometry, material, cells.length);
mesh.userData.zoneId = zone.id;
mesh.instanceMatrix.setUsage(THREE.StaticDrawUsage);
let centerX = 0;
let centerY = 0;
cells.forEach((cell, index) => {
const x = mapX(cell.longitude);
const y = mapY(cell.latitude);
centerX += x;
centerY += y;
dummy.position.set(x, y, 0);
dummy.quaternion.identity();
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
if (cells.length) {
centerX /= cells.length;
centerY /= cells.length;
mapScene.add(mesh);
mapZoneMeshes[zone.id] = mesh;
const label = makeLabelSprite(offsetLabel(zone.offset), {
scale: zone.offset % 1 ? 1.03 : 0.92,
fontSize: 42,
background: "rgba(3, 9, 14, 0.90)",
border: "rgba(210, 230, 240, 0.42)",
depthTest: false
});
label.position.set(centerX, centerY + 0.06, 0.38);
mapScene.add(label);
}
}
function highlightZone(zoneId) {
for (const [id, mesh] of Object.entries(mapZoneMeshes)) {
const selected = id === zoneId;
mesh.material.emissive.set(selected ? 0x69e1e6 : 0x000000);
mesh.material.emissiveIntensity = selected ? 0.7 : 0.04;
mesh.material.opacity = selected ? 1 : 0.9;
}
}
highlightZone(state.selectedZone);
const mapRaycaster = new THREE.Raycaster();
const mapPointer = new THREE.Vector2();
let mapPointerDown = null;
$("mapCanvas").addEventListener("pointerdown", event => {
mapPointerDown = { x: event.clientX, y: event.clientY, moved: 0 };
$("mapCanvas").setPointerCapture(event.pointerId);
});
$("mapCanvas").addEventListener("pointermove", event => {
if (!mapPointerDown) return;
const dx = event.clientX - mapPointerDown.x;
const dy = event.clientY - mapPointerDown.y;
mapPointerDown.moved += Math.abs(dx) + Math.abs(dy);
mapPointerDown.x = event.clientX;
mapPointerDown.y = event.clientY;
const rect = $("mapCanvas").getBoundingClientRect();
const worldPerPixel = (mapCamera.right - mapCamera.left) / rect.width / state.mapZoom;
state.mapPanX -= dx * worldPerPixel;
state.mapPanY += dy * worldPerPixel;
mapCamera.position.x = state.mapPanX;
mapCamera.position.y = state.mapPanY;
});
$("mapCanvas").addEventListener("pointerup", event => {
if (mapPointerDown && mapPointerDown.moved < 6) {
const rect = $("mapCanvas").getBoundingClientRect();
mapPointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
mapPointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
mapRaycaster.setFromCamera(mapPointer, mapCamera);
const candidates = Object.values(mapZoneMeshes);
const hit = mapRaycaster.intersectObjects(candidates)[0];
if (hit && hit.object.userData.zoneId) {
selectZone(hit.object.userData.zoneId);
}
}
mapPointerDown = null;
});
$("mapCanvas").addEventListener("pointercancel", () => mapPointerDown = null);
$("mapCanvas").addEventListener("wheel", event => {
event.preventDefault();
state.mapZoom = THREE.MathUtils.clamp(
state.mapZoom * Math.exp(-event.deltaY * 0.001),
0.75,
3.6
);
mapCamera.zoom = state.mapZoom;
mapCamera.updateProjectionMatrix();
}, { passive: false });
$("resetMap").addEventListener("click", () => {
state.mapZoom = 1;
state.mapPanX = 0;
state.mapPanY = 0;
mapCamera.zoom = 1;
mapCamera.position.set(0, 0, 10);
mapCamera.updateProjectionMatrix();
});
function selectZone(zoneId) {
if (!zoneById[zoneId]) return;
state.selectedZone = zoneId;
zoneSelect.value = zoneId;
highlightZone(zoneId);
updateReadouts();
}
zoneSelect.addEventListener("change", () => selectZone(zoneSelect.value));
$("clearSelection").addEventListener("click", () => {
for (const mesh of Object.values(mapZoneMeshes)) {
mesh.material.emissive.set(0x000000);
mesh.material.emissiveIntensity = 0.04;
}
state.selectedZone = null;
zoneSelect.value = "";
$("zoneOffset").textContent = "—";
$("zoneName").textContent = "No civil block selected";
$("zoneClock").textContent = "—";
$("zoneDate").textContent = "";
});
// ---------------------------------------------------------------------
// TIME AND READOUTS
// ---------------------------------------------------------------------
function updateReadouts() {
$("utcInput").value = utcInputValue(state.timeMs);
$("utcReadout").textContent = `${utcDateString(state.timeMs)} ${utcClockString(state.timeMs)}`;
const eot = equationOfTime(state.timeMs);
$("eotReadout").textContent = `${eot >= 0 ? "+" : "−"}${Math.abs(eot).toFixed(1)} min`;
const subsolar = subsolarLongitude(state.timeMs);
$("subsolarReadout").textContent = longitudeText(subsolar);
$("selectedLongitude").textContent = longitudeText(state.selectedLongitude);
const solarMinutes = localSolarMinutes(state.timeMs, state.selectedLongitude);
const solarHours = Math.floor(solarMinutes / 60);
const solarMins = Math.floor(solarMinutes % 60);
$("selectedSolarTime").textContent =
`Local apparent solar time ${pad(solarHours)}:${pad(solarMins)}`;
const zone = zoneById[state.selectedZone];
if (zone) {
$("zoneOffset").textContent = formatOffset(zone.offset);
$("zoneName").textContent = `${zone.city} · standard offset`;
$("zoneClock").textContent = localClockAtOffset(state.timeMs, zone.offset);
$("zoneDate").textContent = dateAtOffset(state.timeMs, zone.offset);
}
}
function updateGlobeTimeColors() {
const eot = equationOfTime(state.timeMs);
const d = new Date(state.timeMs);
const utcMinutes = d.getUTCHours() * 60 + d.getUTCMinutes() + d.getUTCSeconds() / 60;
for (let i = 0; i < globeVoxels.userData.voxels.length; i++) {
const longitude = globeVoxels.userData.voxels[i].longitude;
const minutes = ((utcMinutes + longitude * 4 + eot) % 1440 + 1440) % 1440;
globeVoxels.setColorAt(i, new THREE.Color(solarColor(minutes)));
}
globeVoxels.instanceColor.needsUpdate = true;
const longitude = subsolarLongitude(state.timeMs);
const latitude = declination(state.timeMs);
const phi = (90 - latitude) * Math.PI / 180;
const theta = longitude * Math.PI / 180;
const position = new THREE.Vector3(
2.42 * Math.sin(phi) * Math.cos(theta),
2.42 * Math.cos(phi),
2.42 * Math.sin(phi) * Math.sin(theta)
);
sunMarker.position.copy(position);
sunHalo.position.copy(position);
sunLabel.position.copy(position).multiplyScalar(1.09);
sunLight.position.copy(position).multiplyScalar(1.12);
}
$("utcInput").addEventListener("change", () => {
const value = $("utcInput").value;
if (!value) return;
const parsed = Date.parse(`${value}Z`);
if (!Number.isNaN(parsed)) {
state.timeMs = parsed;
state.playing = false;
$("playButton").textContent = "Play";
updateReadouts();
updateGlobeTimeColors();
}
});
$("nowButton").addEventListener("click", () => {
state.timeMs = Date.now();
state.playing = false;
$("playButton").textContent = "Play";
updateReadouts();
updateGlobeTimeColors();
});
$("playButton").addEventListener("click", () => {
state.playing = !state.playing;
$("playButton").textContent = state.playing ? "Pause" : "Play";
});
$("rateSlider").addEventListener("input", () => {
state.rate = Number($("rateSlider").value);
$("rateValue").textContent = `${state.rate} min/s`;
});
// ---------------------------------------------------------------------
// RESIZE AND LOOP
// ---------------------------------------------------------------------
function resizeGlobe() {
const rect = $("globeStage").getBoundingClientRect();
const width = Math.max(1, Math.floor(rect.width));
const height = Math.max(1, Math.floor(rect.height));
globeRenderer.setSize(width, height, false);
globeCamera.aspect = width / height;
globeCamera.updateProjectionMatrix();
}
function resizeMap() {
const rect = $("mapStage").getBoundingClientRect();
const width = Math.max(1, Math.floor(rect.width));
const height = Math.max(1, Math.floor(rect.height));
mapRenderer.setSize(width, height, false);
const aspect = width / height;
const viewWidth = Math.max(12.8, 7.9 * aspect);
const viewHeight = viewWidth / aspect;
mapCamera.left = -viewWidth / 2;
mapCamera.right = viewWidth / 2;
mapCamera.top = viewHeight / 2;
mapCamera.bottom = -viewHeight / 2;
mapCamera.zoom = state.mapZoom;
mapCamera.updateProjectionMatrix();
}
const globeObserver = new ResizeObserver(resizeGlobe);
globeObserver.observe($("globeStage"));
const mapObserver = new ResizeObserver(resizeMap);
mapObserver.observe($("mapStage"));
resizeGlobe();
resizeMap();
updateReadouts();
updateGlobeTimeColors();
let previousFrame = performance.now();
let previousVisualUpdate = 0;
function animate(now) {
const deltaSeconds = Math.min((now - previousFrame) / 1000, 0.1);
previousFrame = now;
if (state.playing) {
state.timeMs += deltaSeconds * state.rate * 60000;
}
if (now - previousVisualUpdate > 180) {
previousVisualUpdate = now;
updateReadouts();
updateGlobeTimeColors();
}
globeRenderer.render(globeScene, globeCamera);
mapRenderer.render(mapScene, mapCamera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```