Prompt specification
Build or customize the Three.js 3D scene "Observatory Orrery With Explicit Assumptions" 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: Observatory Orrery With Explicit Assumptions
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/observatory-orrery-with-explicit-assumptions-x3803
Scene Description Prompt:
A voxel observatory orrery compares ideal circular and elliptical orbits, separating display scales from physical values. Build standalone HTML using Three.js from cdnjs.
Working Three.js Starter (observatory-orrery-with-explicit-assumptions-x3803):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Observatory Orrery</title>
<style>
:root {
--bg: #050914;
--panel: rgba(10, 18, 34, 0.86);
--panel-border: rgba(139, 191, 224, 0.18);
--text: #e9f4ff;
--muted: #8096aa;
--cyan: #56e1ff;
--orange: #ffad66;
--gold: #ffd477;
--green: #74e0a8;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 45%, transparent 35%, rgba(0, 4, 12, 0.54) 100%),
linear-gradient(180deg, rgba(0, 0, 0, 0.12), transparent 20%);
z-index: 1;
}
header {
position: fixed;
z-index: 5;
top: 20px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
position: relative;
width: 43px;
height: 43px;
border: 1px solid rgba(86, 225, 255, 0.55);
background: rgba(86, 225, 255, 0.07);
box-shadow: 0 0 28px rgba(86, 225, 255, 0.12);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--cyan);
}
.brand-mark::before {
width: 5px;
height: 5px;
top: 8px;
left: 8px;
box-shadow: 18px 18px 0 var(--gold), 0 18px 0 rgba(86, 225, 255, 0.35);
}
.brand-mark::after {
width: 24px;
height: 24px;
left: 8px;
top: 9px;
border: 1px solid rgba(86, 225, 255, 0.35);
background: transparent;
}
.eyebrow {
margin-bottom: 5px;
color: var(--cyan);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.23em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(18px, 2vw, 27px);
font-weight: 650;
letter-spacing: -0.035em;
}
.header-status {
display: flex;
align-items: center;
gap: 14px;
margin-top: 4px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
letter-spacing: 0.08em;
}
.live {
display: inline-flex;
align-items: center;
gap: 7px;
}
.live::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 10px var(--green);
}
.camera-tools {
display: flex;
gap: 6px;
pointer-events: auto;
}
.icon-button {
width: 38px;
height: 38px;
border: 1px solid var(--panel-border);
border-radius: 8px;
background: rgba(10, 18, 34, 0.78);
cursor: pointer;
transition: 160ms ease;
}
.icon-button:hover {
border-color: rgba(86, 225, 255, 0.55);
background: rgba(86, 225, 255, 0.1);
}
.panel {
position: fixed;
z-index: 4;
top: 104px;
width: 286px;
max-height: calc(100vh - 142px);
overflow: auto;
padding: 17px;
border: 1px solid var(--panel-border);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: rgba(86, 225, 255, 0.25) transparent;
}
.controls-panel {
left: 24px;
}
.data-panel {
right: 24px;
width: 306px;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(139, 191, 224, 0.12);
color: #bfd0df;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-title span:last-child {
color: var(--muted);
font-size: 9px;
font-weight: 500;
}
.section {
margin: 18px 0;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.section-label output {
color: var(--cyan);
font-size: 10px;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 33px;
color: #c8d7e4;
font-size: 12px;
cursor: pointer;
}
.toggle-row + .toggle-row {
border-top: 1px solid rgba(139, 191, 224, 0.08);
}
.toggle-row span:first-child {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 8px;
height: 8px;
border-radius: 2px;
box-shadow: 0 0 9px currentColor;
}
.swatch.cyan {
color: var(--cyan);
background: var(--cyan);
}
.swatch.orange {
color: var(--orange);
background: var(--orange);
}
.swatch.gold {
color: var(--gold);
background: var(--gold);
}
.swatch.gray {
color: #8fa7b9;
background: #8fa7b9;
}
.switch {
position: relative;
width: 33px;
height: 18px;
flex: 0 0 auto;
}
.switch input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch i {
position: absolute;
inset: 0;
border: 1px solid rgba(139, 191, 224, 0.28);
border-radius: 20px;
background: rgba(139, 191, 224, 0.08);
transition: 160ms ease;
}
.switch i::after {
content: "";
position: absolute;
width: 12px;
height: 12px;
top: 2px;
left: 2px;
border-radius: 50%;
background: #71889c;
transition: 160ms ease;
}
.switch input:checked + i {
border-color: rgba(86, 225, 255, 0.65);
background: rgba(86, 225, 255, 0.15);
}
.switch input:checked + i::after {
left: 17px;
background: var(--cyan);
box-shadow: 0 0 8px rgba(86, 225, 255, 0.7);
}
.range-wrap {
padding: 2px 1px;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 7px 0;
appearance: none;
border-radius: 8px;
outline: none;
background: linear-gradient(90deg, var(--cyan), rgba(86, 225, 255, 0.13));
}
input[type="range"]::-webkit-slider-thumb {
width: 14px;
height: 14px;
appearance: none;
border: 2px solid #b8f3ff;
border-radius: 3px;
background: #17435b;
box-shadow: 0 0 9px rgba(86, 225, 255, 0.55);
cursor: grab;
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 2px solid #b8f3ff;
border-radius: 3px;
background: #17435b;
box-shadow: 0 0 9px rgba(86, 225, 255, 0.55);
cursor: grab;
}
.range-ends {
display: flex;
justify-content: space-between;
color: #60768a;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
}
.note {
margin: 10px 0 0;
color: #71889c;
font-size: 10px;
line-height: 1.55;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.action-button {
min-height: 36px;
border: 1px solid rgba(139, 191, 224, 0.2);
border-radius: 8px;
background: rgba(139, 191, 224, 0.06);
cursor: pointer;
font-size: 11px;
transition: 160ms ease;
}
.action-button:hover {
border-color: rgba(86, 225, 255, 0.5);
background: rgba(86, 225, 255, 0.1);
}
.orbit-card {
padding: 13px;
border: 1px solid rgba(139, 191, 224, 0.13);
border-radius: 10px;
background: rgba(139, 191, 224, 0.035);
}
.orbit-card + .orbit-card {
margin-top: 10px;
}
.orbit-card.circular {
border-left: 2px solid var(--cyan);
}
.orbit-card.elliptical {
border-left: 2px solid var(--orange);
}
.orbit-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
font-size: 12px;
font-weight: 650;
}
.orbit-heading span:last-child {
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
letter-spacing: 0.12em;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px 14px;
}
.metric {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
padding-bottom: 5px;
border-bottom: 1px solid rgba(139, 191, 224, 0.08);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
}
.metric span {
color: #6f879b;
}
.metric strong {
color: #d7e8f4;
font-weight: 500;
white-space: nowrap;
}
.metric.physical strong {
color: #d3e2ed;
}
.metric.display strong {
color: var(--cyan);
}
.elliptical .metric.display strong {
color: var(--orange);
}
.subhead {
margin: 12px 0 7px;
color: #62798c;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.selected-card {
margin-top: 12px;
padding: 13px;
border: 1px solid rgba(255, 212, 119, 0.2);
border-radius: 10px;
background: rgba(255, 212, 119, 0.045);
}
.selected-card .eyebrow {
color: var(--gold);
font-size: 8px;
}
#selectedName {
margin: 5px 0 10px;
font-size: 13px;
font-weight: 650;
}
.selected-line {
display: flex;
justify-content: space-between;
margin-top: 6px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
}
.selected-line strong {
color: #d8e7f1;
font-weight: 500;
}
.scale-note {
position: fixed;
z-index: 4;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 12px;
max-width: calc(100vw - 660px);
padding: 10px 15px;
border: 1px solid rgba(86, 225, 255, 0.2);
border-radius: 9px;
background: rgba(8, 16, 29, 0.82);
color: #8ea5b7;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(15px);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
white-space: nowrap;
}
.scale-note b {
color: var(--cyan);
font-weight: 600;
}
.scale-note .divider {
width: 1px;
height: 16px;
background: rgba(139, 191, 224, 0.18);
}
.camera-hint {
position: fixed;
z-index: 3;
left: 50%;
bottom: 69px;
transform: translateX(-50%);
color: rgba(170, 192, 208, 0.48);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
letter-spacing: 0.09em;
pointer-events: none;
white-space: nowrap;
}
.world-label {
position: fixed;
z-index: 3;
left: 0;
top: 0;
pointer-events: none;
transform: translate(-50%, -50%);
padding: 5px 8px;
border: 1px solid rgba(139, 191, 224, 0.24);
border-radius: 5px;
background: rgba(5, 10, 21, 0.82);
color: #d5e5ef;
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 8px;
letter-spacing: 0.08em;
white-space: nowrap;
will-change: transform, left, top;
}
.world-label.cyan {
border-color: rgba(86, 225, 255, 0.5);
color: var(--cyan);
}
.world-label.orange {
border-color: rgba(255, 173, 102, 0.5);
color: var(--orange);
}
.world-label.gold {
border-color: rgba(255, 212, 119, 0.5);
color: var(--gold);
}
.world-label.scale {
border-color: rgba(86, 225, 255, 0.25);
color: #8bdff0;
}
@media (max-width: 900px) {
.panel {
width: 250px;
}
.data-panel {
width: 270px;
}
.scale-note {
max-width: calc(100vw - 570px);
font-size: 8px;
}
}
@media (max-width: 680px) {
header {
top: 12px;
left: 12px;
right: 12px;
}
.brand-mark {
width: 35px;
height: 35px;
}
.brand-mark::after {
width: 20px;
height: 20px;
}
.header-status {
display: none;
}
.camera-tools {
gap: 4px;
}
.icon-button {
width: 33px;
height: 33px;
}
.controls-panel {
top: auto;
left: 10px;
right: 10px;
bottom: 10px;
width: auto;
max-height: 31vh;
padding: 13px;
}
.data-panel {
top: 62px;
right: 10px;
left: 10px;
width: auto;
max-height: 33vh;
padding: 13px;
}
.panel-title {
margin-bottom: 10px;
}
.scale-note,
.camera-hint {
display: none;
}
.metric-grid {
grid-template-columns: repeat(4, 1fr);
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="vignette"></div>
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<div class="eyebrow">Orbital mechanics laboratory</div>
<h1>Voxel Observatory</h1>
<div class="header-status">
<span class="live">KEPLER SOLVER LIVE</span>
<span>1 M☉ REFERENCE STAR</span>
</div>
</div>
</div>
<div class="camera-tools" aria-label="Camera controls">
<button class="icon-button" id="zoomOut" title="Zoom out">−</button>
<button class="icon-button" id="zoomIn" title="Zoom in">+</button>
<button class="icon-button" id="topView" title="Top view">⊤</button>
<button class="icon-button" id="resetCamera" title="Reset camera">↺</button>
</div>
</header>
<aside class="panel controls-panel">
<div class="panel-title">
<span>Orrery controls</span>
<span>01 / LIVE</span>
</div>
<div class="section">
<div class="section-label">Visible objects</div>
<label class="toggle-row">
<span><i class="swatch cyan"></i>Circular reference</span>
<span class="switch">
<input id="showCircular" type="checkbox" checked><i></i>
</span>
</label>
<label class="toggle-row">
<span><i class="swatch orange"></i>Elliptical reference</span>
<span class="switch">
<input id="showEllipse" type="checkbox" checked><i></i>
</span>
</label>
<label class="toggle-row">
<span><i class="swatch gold"></i>Voxel orbit guides</span>
<span class="switch">
<input id="showGuides" type="checkbox" checked><i></i>
</span>
</label>
<label class="toggle-row">
<span><i class="swatch gray"></i>Remote observatory</span>
<span class="switch">
<input id="showObservatory" type="checkbox" checked><i></i>
</span>
</label>
</div>
<div class="section">
<div class="section-label">
Display scale
<output id="scaleOutput">1.00×</output>
</div>
<div class="range-wrap">
<input id="displayScale" type="range" min="0.70" max="1.40" step="0.01" value="1">
<div class="range-ends"><span>0.70×</span><span>1.40×</span></div>
</div>
<p class="note">
Changes orbital geometry in voxel units only. AU, eccentricity,
and period remain physically unchanged.
</p>
</div>
<div class="section">
<div class="section-label">
Time scale
<output id="speedOutput">1.00×</output>
</div>
<div class="range-wrap">
<input id="timeSpeed" type="range" min="0.25" max="4" step="0.25" value="1">
<div class="range-ends"><span>0.25×</span><span>4.00×</span></div>
</div>
<div class="button-row" style="margin-top:12px">
<button class="action-button" id="playButton">Ⅱ Pause</button>
<button class="action-button" id="phaseButton">⇄ Phase</button>
</div>
</div>
</aside>
<aside class="panel data-panel">
<div class="panel-title">
<span>Orbit comparison</span>
<span>02 / DATA</span>
</div>
<div class="orbit-card circular">
<div class="orbit-heading">
<span>Circular reference</span>
<span>e = 0.000</span>
</div>
<div class="subhead">Physical model</div>
<div class="metric-grid">
<div class="metric physical"><span>a</span><strong>1.000 AU</strong></div>
<div class="metric physical"><span>r</span><strong>1.000 AU</strong></div>
<div class="metric physical"><span>P</span><strong>1.000 yr</strong></div>
<div class="metric physical"><span>ν</span><strong>0.00°</strong></div>
</div>
<div class="subhead">Display mapping</div>
<div class="metric-grid">
<div class="metric display"><span>radius</span><strong id="circleDisplay">6.20 vx</strong></div>
<div class="metric display"><span>AU / vx</span><strong id="auPerVoxel">1 / 6.20</strong></div>
</div>
</div>
<div class="orbit-card elliptical">
<div class="orbit-heading">
<span>Elliptical reference</span>
<span>e = 0.400</span>
</div>
<div class="subhead">Physical model</div>
<div class="metric-grid">
<div class="metric physical"><span>a</span><strong>1.000 AU</strong></div>
<div class="metric physical"><span>e</span><strong>0.400</strong></div>
<div class="metric physical"><span>r</span><strong>0.600–1.400</strong></div>
<div class="metric physical"><span>P</span><strong>1.000 yr</strong></div>
</div>
<div class="subhead">Display mapping</div>
<div class="metric-grid">
<div class="metric display"><span>a</span><strong id="ellipseADisplay">6.20 vx</strong></div>
<div class="metric display"><span>b</span><strong id="ellipseBDisplay">5.68 vx</strong></div>
<div class="metric display"><span>focus</span><strong id="ellipseFocus">2.48 vx</strong></div>
<div class="metric display"><span>center</span><strong>−2.48 vx</strong></div>
</div>
</div>
<div class="selected-card">
<div class="eyebrow">Selected body · live telemetry</div>
<div id="selectedName">Elliptical reference</div>
<div class="selected-line">
<span>Physical radius</span>
<strong id="liveRadius">1.000 AU</strong>
</div>
<div class="selected-line">
<span>Mean anomaly</span>
<strong id="liveAnomaly">0.0°</strong>
</div>
<div class="selected-line">
<span>Display radius</span>
<strong id="liveDisplayRadius">6.20 vx</strong>
</div>
</div>
<p class="note">
Both bodies share a = 1 AU and therefore a 1-year ideal Keplerian period.
Ellipse eccentricity changes radial distance, not orbital period.
</p>
</aside>
<div class="scale-note">
<span>DISPLAY <b id="displayMapping">1 AU = 6.20 vx</b></span>
<i class="divider"></i>
<span>PHYSICAL <b>UNSCALED</b></span>
</div>
<div class="camera-hint">DRAG TO ORBIT · WHEEL / PINCH TO ZOOM · CLICK A BODY TO INSPECT</div>
<div class="world-label gold" id="starLabel">REFERENCE STAR · 1 M☉</div>
<div class="world-label cyan" id="circularLabel">CIRCULAR BODY</div>
<div class="world-label orange" id="ellipseLabel">ELLIPTICAL BODY</div>
<div class="world-label scale" id="scaleLabel">DISPLAY AXIS · 1 AU</div>
<div class="world-label" id="observatoryLabel">REMOTE OBSERVATORY</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Physical model. Display units are deliberately separate from these values.
// -------------------------------------------------------------------------
const PHYSICS = {
semiMajorAU: 1.0,
eccentricity: 0.4,
periodYears: 1.0,
starMassSolar: 1.0
};
const state = {
displayScale: 1,
timeScale: 1,
playing: true,
elapsed: 0,
showCircular: true,
showEllipse: true,
showGuides: true,
showObservatory: true,
selected: "ellipse"
};
const BASE_A_DISPLAY = 6.2;
const displayA = () => BASE_A_DISPLAY * state.displayScale;
const displayB = () => displayA() * Math.sqrt(1 - PHYSICS.eccentricity ** 2);
const ORBIT_Y = 0.12;
const sceneElement = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x050914);
scene.fog = new THREE.Fog(0x050914, 25, 70);
const camera = new THREE.PerspectiveCamera(
39,
innerWidth / innerHeight,
0.1,
140
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneElement.appendChild(renderer.domElement);
// -------------------------------------------------------------------------
// Direct camera controls: no addons.
// -------------------------------------------------------------------------
const desiredCamera = {
radius: 19,
theta: 0.58,
phi: 0.78,
target: new THREE.Vector3(0, 0, -0.8)
};
const currentCamera = {
radius: desiredCamera.radius,
theta: desiredCamera.theta,
phi: desiredCamera.phi,
target: desiredCamera.target.clone()
};
const pointers = new Map();
let pointerDown = null;
let dragMoved = false;
let previousPinchDistance = 0;
const canvas = renderer.domElement;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].clientX - values[1].clientX,
values[0].clientY - values[1].clientY
);
}
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
clientX: event.clientX,
clientY: event.clientY
});
if (pointers.size === 1) {
pointerDown = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY
};
dragMoved = false;
} else if (pointers.size === 2) {
previousPinchDistance = pointerDistance();
dragMoved = true;
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, {
clientX: event.clientX,
clientY: event.clientY
});
if (pointers.size >= 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
desiredCamera.radius *= previousPinchDistance / distance;
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius, 8, 38
);
}
previousPinchDistance = distance;
dragMoved = true;
return;
}
if (!pointerDown) return;
const dx = event.clientX - pointerDown.lastX;
const dy = event.clientY - pointerDown.lastY;
desiredCamera.theta -= dx * 0.006;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi - dy * 0.006,
0.08,
1.42
);
pointerDown.lastX = event.clientX;
pointerDown.lastY = event.clientY;
if (
Math.hypot(
event.clientX - pointerDown.x,
event.clientY - pointerDown.y
) > 5
) {
dragMoved = true;
}
});
canvas.addEventListener("pointerup", event => {
const wasSinglePointer = pointers.size === 1;
pointers.delete(event.pointerId);
if (wasSinglePointer && !dragMoved) {
inspectAtPointer(event.clientX, event.clientY);
}
if (pointers.size === 1) {
const remaining = [...pointers.entries()][0];
pointerDown = {
x: remaining[1].clientX,
y: remaining[1].clientY,
lastX: remaining[1].clientX,
lastY: remaining[1].clientY
};
} else {
pointerDown = null;
previousPinchDistance = 0;
}
});
canvas.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
pointerDown = null;
previousPinchDistance = 0;
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
desiredCamera.radius *= Math.exp(event.deltaY * 0.001);
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius, 8, 38
);
}, { passive: false });
canvas.addEventListener("contextmenu", event => event.preventDefault());
function updateCamera(dt) {
const ease = 1 - Math.exp(-9 * dt);
currentCamera.radius +=
(desiredCamera.radius - currentCamera.radius) * ease;
currentCamera.theta +=
(desiredCamera.theta - currentCamera.theta) * ease;
currentCamera.phi +=
(desiredCamera.phi - currentCamera.phi) * ease;
currentCamera.target.lerp(desiredCamera.target, ease);
const sinPhi = Math.sin(currentCamera.phi);
camera.position.set(
currentCamera.target.x +
currentCamera.radius * sinPhi * Math.sin(currentCamera.theta),
currentCamera.target.y +
currentCamera.radius * Math.cos(currentCamera.phi),
currentCamera.target.z +
currentCamera.radius * sinPhi * Math.cos(currentCamera.theta)
);
camera.lookAt(currentCamera.target);
}
document.getElementById("resetCamera").addEventListener("click", () => {
desiredCamera.radius = 19;
desiredCamera.theta = 0.58;
desiredCamera.phi = 0.78;
desiredCamera.target.set(0, 0, -0.8);
});
document.getElementById("topView").addEventListener("click", () => {
desiredCamera.radius = 18;
desiredCamera.theta = 0;
desiredCamera.phi = 0.08;
desiredCamera.target.set(0, 0, -0.8);
});
document.getElementById("zoomIn").addEventListener("click", () => {
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * 0.85, 8, 38
);
});
document.getElementById("zoomOut").addEventListener("click", () => {
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * 1.15, 8, 38
);
});
window.addEventListener("keydown", event => {
if (event.key === " ") {
event.preventDefault();
togglePlayback();
}
if (event.key.toLowerCase() === "r") {
desiredCamera.radius = 19;
desiredCamera.theta = 0.58;
desiredCamera.phi = 0.78;
desiredCamera.target.set(0, 0, -0.8);
}
});
// -------------------------------------------------------------------------
// Lighting and voxel geometry helpers.
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0x7bcaff, 0x10131e, 1.65);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xb8d8ff, 2.2);
keyLight.position.set(8, 15, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 18;
keyLight.shadow.camera.bottom = -18;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 45;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x426bff, 1.2);
rimLight.position.set(-12, 7, -12);
scene.add(rimLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function getMaterial(color, properties = {}) {
const key = `${color}-${JSON.stringify(properties)}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0.08,
...properties
}));
}
return materialCache.get(key);
}
function addBox(parent, width, height, depth, x, y, z, color, properties = {}) {
const mesh = new THREE.Mesh(
unitBox,
typeof color === "number"
? getMaterial(color, properties)
: color
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(140, 140),
getMaterial(0x070d18, { roughness: 0.96, metalness: 0 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.58;
floor.receiveShadow = true;
scene.add(floor);
// Subtle floor grid.
const gridMaterial = new THREE.LineBasicMaterial({
color: 0x1a3044,
transparent: true,
opacity: 0.22
});
const gridVertices = [];
for (let n = -40; n <= 40; n += 2) {
gridVertices.push(-40, -1.565, n, 40, -1.565, n);
gridVertices.push(n, -1.565, -40, n, -1.565, 40);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridVertices, 3)
);
scene.add(new THREE.LineSegments(gridGeometry, gridMaterial));
// Voxel star field.
const backgroundStarMaterial = new THREE.MeshBasicMaterial({
color: 0x9ccfff,
transparent: true,
opacity: 0.72
});
const starCount = 520;
const stars = new THREE.InstancedMesh(unitBox, backgroundStarMaterial, starCount);
const dummy = new THREE.Object3D();
for (let i = 0; i < starCount; i++) {
const radius = 27 + Math.random() * 38;
const theta = Math.random() * Math.PI * 2;
const y = 4 + Math.random() * 35;
dummy.position.set(
Math.cos(theta) * radius,
y,
Math.sin(theta) * radius
);
const size = 0.025 + Math.random() * 0.075;
dummy.scale.set(size, size, size);
dummy.rotation.set(Math.random(), Math.random(), Math.random());
dummy.updateMatrix();
stars.setMatrixAt(i, dummy.matrix);
}
stars.instanceMatrix.needsUpdate = true;
scene.add(stars);
// Stepped circular orrery platform.
const platform = new THREE.Group();
scene.add(platform);
const platformBlocks = [];
for (let x = -7; x <= 7; x++) {
for (let z = -7; z <= 7; z++) {
if (Math.hypot(x * 0.69, z * 0.69) > 4.85) continue;
platformBlocks.push({
x: x * 0.69,
z: z * 0.69,
shade: Math.random() > 0.76 ? 0x183346 : 0x102536
});
}
}
const platformMesh = new THREE.InstancedMesh(
unitBox,
getMaterial(0xffffff),
platformBlocks.length
);
platformBlocks.forEach((block, index) => {
dummy.position.set(block.x, -1.18, block.z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(0.67, 0.34, 0.67);
dummy.updateMatrix();
platformMesh.setMatrixAt(index, dummy.matrix);
platformMesh.setColorAt(index, new THREE.Color(block.shade));
});
platformMesh.instanceMatrix.needsUpdate = true;
platformMesh.instanceColor.needsUpdate = true;
platformMesh.receiveShadow = true;
platformMesh.castShadow = true;
platform.add(platformMesh);
// Platform rim.
const rimCount = 56;
const rim = new THREE.InstancedMesh(
unitBox,
getMaterial(0x29506a, { metalness: 0.25 }),
rimCount
);
for (let i = 0; i < rimCount; i++) {
const angle = i / rimCount * Math.PI * 2;
dummy.position.set(
Math.cos(angle) * 4.9,
-0.94,
Math.sin(angle) * 4.9
);
dummy.rotation.set(0, -angle, 0);
dummy.scale.set(0.34, 0.17, 0.16);
dummy.updateMatrix();
rim.setMatrixAt(i, dummy.matrix);
}
rim.instanceMatrix.needsUpdate = true;
rim.castShadow = true;
platform.add(rim);
// Central pedestal.
addBox(platform, 2.5, 0.24, 2.5, 0, -0.89, 0, 0x1b3344);
addBox(platform, 1.9, 0.25, 1.9, 0, -0.64, 0, 0x29485a);
addBox(platform, 1.25, 0.22, 1.25, 0, -0.4, 0, 0x365c70);
for (const x of [-0.72, 0.72]) {
for (const z of [-0.72, 0.72]) {
addBox(platform, 0.18, 0.58, 0.18, x, -0.02, z, 0x52798b);
}
}
// Voxel reference star.
const starGroup = new THREE.Group();
starGroup.position.y = 0.55;
scene.add(starGroup);
const starMaterial = getMaterial(0xffbd4d, {
emissive: 0xff8b1f,
emissiveIntensity: 1.55,
roughness: 0.4
});
addBox(starGroup, 1.12, 1.12, 1.12, 0, 0, 0, starMaterial);
addBox(starGroup, 0.48, 0.48, 0.48, 0.72, 0.18, 0.25, 0xffd67b, {
emissive: 0xffa52b,
emissiveIntensity: 1.3
});
addBox(starGroup, 0.42, 0.42, 0.42, -0.62, 0.34, -0.18, 0xff8f3f, {
emissive: 0xff761d,
emissiveIntensity: 1.3
});
addBox(starGroup, 0.34, 0.34, 0.34, -0.24, 0.73, 0.3, 0xffdf87, {
emissive: 0xffad31,
emissiveIntensity: 1.2
});
const starLight = new THREE.PointLight(0xffa43d, 55, 23, 2);
starLight.position.set(0, 1.25, 0);
scene.add(starLight);
// Voxel planets.
function createVoxelPlanet(kind) {
const group = new THREE.Group();
const isEarth = kind === "circular";
const baseColor = isEarth ? 0x247eb2 : 0xb85e3f;
const accentColor = isEarth ? 0x63b979 : 0xe09a5e;
const base = addBox(group, 0.62, 0.62, 0.62, 0, 0, 0, baseColor);
base.userData.orbit = kind;
const patches = [
[-0.19, 0.34, 0.12, 0.13],
[0.13, 0.34, -0.1, 0.16],
[0.34, 0.12, 0.05, 0.12],
[-0.12, -0.34, -0.17, 0.14],
[0.17, -0.34, 0.17, 0.1],
[-0.34, 0.08, 0.03, 0.12]
];
for (const [x, y, z, size] of patches) {
const patch = addBox(
group, size, size, size, x, y, z, accentColor
);
patch.userData.orbit = kind;
}
// Small beacon makes the planet readable in top view.
const beacon = addBox(
group, 0.11, 0.22, 0.11, 0, 0.43, 0,
isEarth ? 0x8ef0ff : 0xffd18c,
{ emissive: isEarth ? 0x2cc9ff : 0xff9f44, emissiveIntensity: 0.8 }
);
beacon.userData.orbit = kind;
group.position.y = 0.43;
scene.add(group);
return group;
}
const circularPlanet = createVoxelPlanet("circular");
const ellipticalPlanet = createVoxelPlanet("ellipse");
// Remote voxel observatory.
const observatory = new THREE.Group();
observatory.position.set(-7.5, -1.48, -6.4);
scene.add(observatory);
addBox(observatory, 4.2, 0.22, 4.2, 0, 0.05, 0, 0x142738);
addBox(observatory, 3.25, 0.24, 3.25, 0, 0.25, 0, 0x334c5c);
addBox(observatory, 2.65, 1.35, 2.65, 0, 0.98, 0, 0x8195a1);
// Dark observation slit.
addBox(observatory, 0.48, 1.02, 0.08, 0, 1.02, 1.36, 0x101b26);
addBox(observatory, 0.22, 0.62, 0.1, 0, 1.15, 1.41, 0xffb36f, {
emissive: 0xff7a32,
emissiveIntensity: 0.8
});
// Stepped dome.
addBox(observatory, 2.85, 0.32, 2.85, 0, 1.78, 0, 0x9aaab3);
addBox(observatory, 2.25, 0.34, 2.25, 0, 2.1, 0, 0x768d9c);
addBox(observatory, 1.6, 0.34, 1.6, 0, 2.42, 0, 0x5d7789);
addBox(observatory, 0.9, 0.34, 0.9, 0, 2.74, 0, 0x476477);
// Voxel telescope.
addBox(observatory, 0.42, 0.42, 1.7, 0, 2.52, 1.25, 0xb7c3c9);
addBox(observatory, 0.52, 0.52, 0.25, 0, 2.52, 2.12, 0x203a4e);
addBox(observatory, 0.14, 0.14, 0.14, 0, 3.03, 0, 0xffd36f, {
emissive: 0xff9d30,
emissiveIntensity: 1.1
});
// Small side blocks and antenna.
addBox(observatory, 0.65, 0.85, 0.65, -1.65, 0.72, 0.75, 0x425b6b);
addBox(observatory, 0.55, 0.55, 0.55, 1.65, 0.7, -0.6, 0x334b5d);
addBox(observatory, 0.1, 1.1, 0.1, 1.18, 2.55, -0.88, 0xa7b6bf);
addBox(observatory, 0.32, 0.12, 0.12, 1.18, 3.04, -0.88, 0xffbd62, {
emissive: 0xff842f,
emissiveIntensity: 0.9
});
// Orbital guide paths and display ruler.
const guidesGroup = new THREE.Group();
const rulerGroup = new THREE.Group();
scene.add(guidesGroup, rulerGroup);
const guideMaterials = {
circular: new THREE.MeshStandardMaterial({
color: 0x4bdcff,
emissive: 0x167b9c,
emissiveIntensity: 0.65,
roughness: 0.5,
transparent: true,
opacity: 0.88
}),
elliptical: new THREE.MeshStandardMaterial({
color: 0xffa65e,
emissive: 0xa34a17,
emissiveIntensity: 0.65,
roughness: 0.5,
transparent: true,
opacity: 0.88
})
};
function clearGeneratedGroup(group) {
while (group.children.length) {
const child = group.children.pop();
if (child.isInstancedMesh) child.dispose();
}
}
function createCircularGuide(a) {
const count = 86;
const mesh = new THREE.InstancedMesh(
unitBox, guideMaterials.circular, count
);
const transform = new THREE.Object3D();
for (let i = 0; i < count; i++) {
const angle = i / count * Math.PI * 2;
transform.position.set(
Math.cos(angle) * a,
ORBIT_Y,
Math.sin(angle) * a
);
transform.rotation.set(0, -angle, 0);
transform.scale.set(0.13, 0.09, 0.27);
transform.updateMatrix();
mesh.setMatrixAt(i, transform.matrix);
}
mesh.instanceMatrix.needsUpdate = true;
guidesGroup.add(mesh);
}
function createEllipticalGuide(a, b) {
const count = 112;
const mesh = new THREE.InstancedMesh(
unitBox, guideMaterials.elliptical, count
);
const transform = new THREE.Object3D();
for (let i = 0; i < count; i++) {
const angle = i / count * Math.PI * 2;
const x = a * (Math.cos(angle) - PHYSICS.eccentricity);
const z = b * Math.sin(angle);
const tangentX = -a * Math.sin(angle);
const tangentZ = b * Math.cos(angle);
const tangentAngle = Math.atan2(tangentX, tangentZ);
transform.position.set(x, ORBIT_Y, z);
transform.rotation.set(0, tangentAngle, 0);
transform.scale.set(0.13, 0.09, 0.27);
transform.updateMatrix();
mesh.setMatrixAt(i, transform.matrix);
}
mesh.instanceMatrix.needsUpdate = true;
guidesGroup.add(mesh);
}
function rebuildDisplayGeometry() {
clearGeneratedGroup(guidesGroup);
clearGeneratedGroup(rulerGroup);
const a = displayA();
const b = displayB();
createCircularGuide(a);
createEllipticalGuide(a, b);
// A voxel ruler explicitly maps one physical AU to arbitrary display units.
const segments = 24;
for (let i = 0; i < segments; i++) {
const x = ((i + 0.5) / segments) * a;
addBox(
rulerGroup,
a / segments * 0.72,
0.035,
i % 4 === 0 ? 0.38 : 0.16,
x,
-0.54,
1.85,
0x2b7890,
{ emissive: 0x123e4d, emissiveIntensity: 0.45 }
);
}
// Tick marks identify the star as the physical focus.
addBox(
rulerGroup, 0.09, 0.16, 0.55, 0, -0.49, 1.85, 0xffd477,
{ emissive: 0x6d4a0c, emissiveIntensity: 0.6 }
);
guidesGroup.visible = state.showGuides;
updateDataReadouts();
}
// -------------------------------------------------------------------------
// Keplerian orbit propagation.
// -------------------------------------------------------------------------
function solveKepler(meanAnomaly) {
let eccentricAnomaly = meanAnomaly;
for (let i = 0; i < 9; i++) {
eccentricAnomaly -=
(eccentricAnomaly -
PHYSICS.eccentricity * Math.sin(eccentricAnomaly) -
meanAnomaly) /
(1 - PHYSICS.eccentricity * Math.cos(eccentricAnomaly));
}
return eccentricAnomaly;
}
const orbitalState = {
circularMean: 0.52,
ellipticalMean: 1.42
};
function updateOrbits() {
const a = displayA();
const b = displayB();
const rate = Math.PI * 2 / 28;
const circularM = (
orbitalState.circularMean + state.elapsed * rate
) % (Math.PI * 2);
const ellipticalM = (
orbitalState.ellipticalMean + state.elapsed * rate
) % (Math.PI * 2);
circularPlanet.position.set(
Math.cos(circularM) * a,
0.43,
Math.sin(circularM) * a
);
const eccentricAnomaly = solveKepler(ellipticalM);
const ellipseX = a * (
Math.cos(eccentricAnomaly) - PHYSICS.eccentricity
);
const ellipseZ = b * Math.sin(eccentricAnomaly);
ellipticalPlanet.position.set(
ellipseX,
0.43,
ellipseZ
);
circularPlanet.rotation.y += 0.008;
ellipticalPlanet.rotation.y += 0.006;
const physicalRadius =
PHYSICS.semiMajorAU *
(1 - PHYSICS.eccentricity * Math.cos(eccentricAnomaly));
const displayRadius = Math.hypot(ellipseX, ellipseZ);
document.getElementById("liveRadius").textContent =
`${physicalRadius.toFixed(3)} AU`;
document.getElementById("liveAnomaly").textContent =
`${THREE.MathUtils.radToDeg(ellipticalM).toFixed(1)}°`;
document.getElementById("liveDisplayRadius").textContent =
`${displayRadius.toFixed(2)} vx`;
}
// -------------------------------------------------------------------------
// Picking and UI.
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function inspectAtPointer(clientX, clientY) {
const rect = canvas.getBoundingClientRect();
pointerNDC.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const hits = raycaster.intersectObjects(
[circularPlanet, ellipticalPlanet],
true
);
if (!hits.length) return;
const orbit = hits[0].object.userData.orbit;
if (!orbit) return;
state.selected = orbit;
updateSelectedCard();
}
function updateSelectedCard() {
const ellipseSelected = state.selected === "ellipse";
document.getElementById("selectedName").textContent =
ellipseSelected
? "Elliptical reference"
: "Circular reference";
if (!ellipseSelected) {
document.getElementById("liveRadius").textContent = "1.000 AU";
document.getElementById("liveDisplayRadius").textContent =
`${displayA().toFixed(2)} vx`;
}
}
function updateDataReadouts() {
const a = displayA();
const b = displayB();
const focus = a * PHYSICS.eccentricity;
document.getElementById("scaleOutput").textContent =
`${state.displayScale.toFixed(2)}×`;
document.getElementById("speedOutput").textContent =
`${state.timeScale.toFixed(2)}×`;
document.getElementById("circleDisplay").textContent =
`${a.toFixed(2)} vx`;
document.getElementById("auPerVoxel").textContent =
`1 / ${a.toFixed(2)}`;
document.getElementById("ellipseADisplay").textContent =
`${a.toFixed(2)} vx`;
document.getElementById("ellipseBDisplay").textContent =
`${b.toFixed(2)} vx`;
document.getElementById("ellipseFocus").textContent =
`${focus.toFixed(2)} vx`;
document.getElementById("displayMapping").textContent =
`1 AU = ${a.toFixed(2)} vx`;
updateSelectedCard();
}
function togglePlayback() {
state.playing = !state.playing;
document.getElementById("playButton").textContent =
state.playing ? "Ⅱ Pause" : "▶ Play";
}
document.getElementById("playButton").addEventListener(
"click", togglePlayback
);
document.getElementById("phaseButton").addEventListener("click", () => {
orbitalState.circularMean =
(orbitalState.circularMean + Math.PI) % (Math.PI * 2);
orbitalState.ellipticalMean =
(orbitalState.ellipticalMean + Math.PI) % (Math.PI * 2);
});
document.getElementById("displayScale").addEventListener("input", event => {
state.displayScale = Number(event.target.value);
rebuildDisplayGeometry();
});
document.getElementById("timeSpeed").addEventListener("input", event => {
state.timeScale = Number(event.target.value);
updateDataReadouts();
});
document.getElementById("showCircular").addEventListener("change", event => {
state.showCircular = event.target.checked;
circularPlanet.visible = state.showCircular;
document.getElementById("circularLabel").style.display =
state.showCircular ? "" : "none";
});
document.getElementById("showEllipse").addEventListener("change", event => {
state.showEllipse = event.target.checked;
ellipticalPlanet.visible = state.showEllipse;
document.getElementById("ellipseLabel").style.display =
state.showEllipse ? "" : "none";
});
document.getElementById("showGuides").addEventListener("change", event => {
state.showGuides = event.target.checked;
guidesGroup.visible = state.showGuides;
});
document.getElementById("showObservatory").addEventListener("change", event => {
state.showObservatory = event.target.checked;
observatory.visible = state.showObservatory;
document.getElementById("observatoryLabel").style.display =
state.showObservatory ? "" : "none";
});
// Project HTML labels without using CSS2DRenderer or any addon.
const projected = new THREE.Vector3();
function projectLabel(element, worldPosition, visible = true) {
if (!visible) {
element.style.display = "none";
return;
}
projected.copy(worldPosition).project(camera);
const inFront = projected.z > -1 && projected.z < 1;
if (!inFront) {
element.style.display = "none";
return;
}
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.display = "";
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
const starLabelPosition = new THREE.Vector3();
const circularLabelPosition = new THREE.Vector3();
const ellipticalLabelPosition = new THREE.Vector3();
const scaleLabelPosition = new THREE.Vector3();
const observatoryLabelPosition = new THREE.Vector3();
function updateLabels() {
starLabelPosition.set(0, 2.0, 0);
circularLabelPosition.copy(circularPlanet.position);
circularLabelPosition.y += 1.0;
ellipticalLabelPosition.copy(ellipticalPlanet.position);
ellipticalLabelPosition.y += 1.0;
scaleLabelPosition.set(displayA(), -0.15, 1.85);
observatoryLabelPosition.set(-7.5, 2.4, -6.4);
projectLabel(
document.getElementById("starLabel"),
starLabelPosition
);
projectLabel(
document.getElementById("circularLabel"),
circularLabelPosition,
state.showCircular
);
projectLabel(
document.getElementById("ellipseLabel"),
ellipticalLabelPosition,
state.showEllipse
);
projectLabel(
document.getElementById("scaleLabel"),
scaleLabelPosition,
state.showGuides
);
projectLabel(
document.getElementById("observatoryLabel"),
observatoryLabelPosition,
state.showObservatory
);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
// -------------------------------------------------------------------------
// Main loop.
// -------------------------------------------------------------------------
rebuildDisplayGeometry();
updateSelectedCard();
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
if (state.playing) {
state.elapsed += dt * state.timeScale;
}
updateCamera(dt);
updateOrbits();
const pulse = 1 + Math.sin(performance.now() * 0.0022) * 0.025;
starGroup.scale.setScalar(pulse);
starLight.intensity = 52 + Math.sin(performance.now() * 0.003) * 7;
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```