Prompt specification
Build or customize the Three.js 3D scene "Four Orbital Positions One Fixed Axial Direction" 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: Four Orbital Positions One Fixed Axial Direction
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/four-orbital-positions-one-fixed-axial-direction-x3766
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts axial tilt, seasons, and hemispheric sunlight. Animate a globe at four positions around a star while maintaining a consistent axial direction. Explain seasons through tilt and illumination, not a misleading eccentricity exaggeration. A 3D cutaway view.
Working Three.js Starter (four-orbital-positions-one-fixed-axial-direction-x3766):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Axial Tilt, Seasons & Hemispheric Sunlight</title>
<style>
:root {
color-scheme: dark;
--bg: #030816;
--panel: rgba(8, 16, 34, 0.82);
--panel-border: rgba(153, 190, 235, 0.16);
--text: #eef5ff;
--muted: #9eb0c9;
--cyan: #62e8ff;
--sun: #ffd071;
--blue: #78a9ff;
--green: #7de1b5;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 42% 48%, #10254b 0, #071126 34%, var(--bg) 72%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.ui {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
header {
position: absolute;
top: 22px;
left: 26px;
width: min(560px, calc(100vw - 410px));
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.eyebrow {
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
margin-bottom: 8px;
}
h1 {
margin: 0;
font-size: clamp(28px, 3.2vw, 48px);
line-height: 1.02;
letter-spacing: -0.045em;
font-weight: 780;
}
h1 em {
color: var(--sun);
font-style: normal;
}
header p {
max-width: 540px;
margin: 11px 0 0;
color: #b9c8dd;
font-size: 14px;
line-height: 1.5;
}
.toolbar {
position: absolute;
top: 142px;
left: 26px;
display: flex;
flex-wrap: wrap;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(162, 195, 233, 0.2);
border-radius: 9px;
background: rgba(12, 23, 44, 0.78);
color: var(--text);
padding: 9px 12px;
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
button:hover {
border-color: rgba(98, 232, 255, 0.6);
background: rgba(18, 40, 68, 0.9);
transform: translateY(-1px);
}
button.active {
border-color: rgba(98, 232, 255, 0.8);
color: #dffaff;
background: rgba(24, 67, 89, 0.75);
}
.panel {
position: absolute;
top: 22px;
right: 22px;
width: 348px;
padding: 19px;
border: 1px solid var(--panel-border);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
backdrop-filter: blur(18px);
pointer-events: auto;
}
.panel-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.phase-pill {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 12px;
padding: 6px 9px;
border-radius: 999px;
background: rgba(255, 208, 113, 0.11);
border: 1px solid rgba(255, 208, 113, 0.22);
color: var(--sun);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.phase-pill::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
#phaseTitle {
margin: 13px 0 8px;
font-size: 25px;
line-height: 1.1;
letter-spacing: -0.035em;
}
#phaseCopy {
min-height: 94px;
margin: 0;
color: #b8c7da;
font-size: 13px;
line-height: 1.55;
}
.facing {
margin: 15px 0;
padding: 10px 11px;
border-left: 2px solid var(--cyan);
background: rgba(98, 232, 255, 0.065);
color: #d7f7ff;
font-size: 12px;
font-weight: 700;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.metric {
min-height: 64px;
padding: 10px;
border: 1px solid rgba(156, 190, 230, 0.12);
border-radius: 10px;
background: rgba(255, 255, 255, 0.025);
}
.metric span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
line-height: 1.3;
text-transform: uppercase;
}
.metric strong {
display: block;
margin-top: 6px;
color: white;
font-size: 17px;
letter-spacing: -0.02em;
}
.distance-note {
margin-top: 13px;
padding: 12px;
border-radius: 11px;
background: rgba(125, 225, 181, 0.07);
border: 1px solid rgba(125, 225, 181, 0.17);
color: #c8f4e1;
font-size: 11px;
line-height: 1.45;
}
.distance-note strong {
display: block;
margin-bottom: 3px;
color: var(--green);
font-size: 12px;
}
.phase-strip {
position: absolute;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
gap: 7px;
padding: 7px;
border: 1px solid var(--panel-border);
border-radius: 13px;
background: rgba(6, 14, 30, 0.82);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.phase-strip button {
min-width: 126px;
text-align: left;
line-height: 1.25;
}
.phase-strip button small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.speed-control {
position: absolute;
left: 26px;
bottom: 24px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 11px;
border: 1px solid var(--panel-border);
border-radius: 10px;
background: rgba(6, 14, 30, 0.75);
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: auto;
}
input[type="range"] {
width: 90px;
accent-color: var(--cyan);
}
.legend {
position: absolute;
right: 24px;
bottom: 24px;
display: grid;
gap: 7px;
padding: 12px 14px;
border: 1px solid var(--panel-border);
border-radius: 12px;
background: rgba(6, 14, 30, 0.72);
backdrop-filter: blur(12px);
color: var(--muted);
font-size: 10px;
}
.legend div {
display: flex;
align-items: center;
gap: 8px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 50%;
box-shadow: 0 0 9px currentColor;
}
.hint {
position: absolute;
left: 50%;
top: 20px;
transform: translateX(-50%);
color: rgba(204, 220, 240, 0.58);
font-size: 10px;
letter-spacing: 0.05em;
text-align: center;
}
#labels {
position: fixed;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
left: 0;
top: 0;
display: none;
white-space: nowrap;
padding: 4px 7px;
border: 1px solid rgba(173, 204, 237, 0.2);
border-radius: 6px;
background: rgba(3, 10, 24, 0.78);
color: #dbeaff;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
box-shadow: 0 4px 18px rgba(0, 0, 0, 0.26);
}
.world-label.sun {
color: var(--sun);
border-color: rgba(255, 208, 113, 0.35);
}
.world-label.axis {
color: var(--cyan);
border-color: rgba(98, 232, 255, 0.35);
}
.world-label.day {
color: #ffe09a;
border-color: rgba(255, 224, 154, 0.35);
}
.world-label.night {
color: #a7b8ff;
border-color: rgba(167, 184, 255, 0.35);
}
.world-label.crust { color: #8de0ff; }
.world-label.mantle { color: #ffad68; }
.world-label.core { color: #ffda78; }
.world-label.phase-june { color: #ffd071; }
.world-label.phase-march,
.world-label.phase-september { color: #7de1b5; }
.world-label.phase-december { color: #78a9ff; }
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #030816;
color: #b9d9ef;
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
@media (max-width: 980px) {
header {
width: calc(100vw - 380px);
}
.hint, .legend { display: none; }
.phase-strip {
bottom: 14px;
}
.phase-strip button {
min-width: 104px;
}
.speed-control {
bottom: 78px;
}
}
@media (max-width: 720px) {
header {
left: 14px;
top: 14px;
width: calc(100vw - 28px);
}
header p { display: none; }
h1 { font-size: 30px; }
.toolbar {
left: 14px;
top: 82px;
max-width: calc(100vw - 28px);
}
.toolbar button {
padding: 7px 9px;
font-size: 10px;
}
.panel {
top: auto;
right: 10px;
bottom: 73px;
left: 10px;
width: auto;
max-height: 39vh;
overflow: auto;
padding: 14px;
}
#phaseCopy { min-height: 0; }
#phaseTitle { font-size: 20px; }
.metrics { grid-template-columns: repeat(4, 1fr); }
.metric { min-height: 58px; padding: 7px; }
.metric strong { font-size: 13px; }
.phase-strip {
right: 10px;
left: 10px;
bottom: 10px;
transform: none;
overflow-x: auto;
}
.phase-strip button { min-width: 105px; }
.speed-control { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D Earth orbit showing axial tilt and seasons"></canvas>
<div id="labels" aria-hidden="true">
<div id="labelSun" class="world-label sun">Sun</div>
<div id="labelJune" class="world-label phase-june">Jun · N summer</div>
<div id="labelMarch" class="world-label phase-march">Mar · equinox</div>
<div id="labelDecember" class="world-label phase-december">Dec · N winter</div>
<div id="labelSeptember" class="world-label phase-september">Sep · equinox</div>
<div id="labelAxis" class="world-label axis">Axial direction</div>
<div id="labelNormal" class="world-label">Orbital normal</div>
<div id="labelNorth" class="world-label axis">N pole</div>
<div id="labelSouth" class="world-label axis">S pole</div>
<div id="labelDay" class="world-label day">Sunlit hemisphere</div>
<div id="labelNight" class="world-label night">Night hemisphere</div>
<div id="labelCrust" class="world-label crust">Crust</div>
<div id="labelMantle" class="world-label mantle">Mantle</div>
<div id="labelCore" class="world-label core">Core</div>
</div>
<div class="ui">
<header>
<div class="eyebrow">Earth–Sun geometry · 3D cutaway</div>
<h1>Seasons come from <em>tilt</em>.</h1>
<p>
The axis keeps pointing in the same direction in space. As Earth orbits,
each hemisphere alternates between more direct, longer-day sunlight and
less direct, shorter-day sunlight.
</p>
</header>
<nav class="toolbar" aria-label="Scene controls">
<button id="playButton">Pause</button>
<button id="followButton">Close-up Earth</button>
<button id="guidesButton" class="active">Axis guides</button>
<button id="resetButton">Reset view</button>
</nav>
<aside class="panel" aria-live="polite">
<div class="panel-kicker">Live illumination geometry</div>
<div id="phasePill" class="phase-pill">June solstice</div>
<h2 id="phaseTitle">The North Pole leans toward the Sun</h2>
<p id="phaseCopy"></p>
<div id="facing" class="facing"></div>
<div class="metrics">
<div class="metric">
<span>Subsolar latitude</span>
<strong id="subsolar">+23.4°</strong>
</div>
<div class="metric">
<span>Earth–Sun distance</span>
<strong id="distance">1.00 AU</strong>
</div>
<div class="metric">
<span>Day length at 45°N</span>
<strong id="dayNorth">15.4 h</strong>
</div>
<div class="metric">
<span>Day length at 45°S</span>
<strong id="daySouth">8.6 h</strong>
</div>
</div>
<div class="distance-note">
<strong>Distance stays constant in this idealized circular orbit.</strong>
The seasonal driver is changing solar elevation and daylight duration—not
a large change in Earth–Sun distance. Real orbital eccentricity is small.
</div>
</aside>
<div class="phase-strip" aria-label="Jump to a seasonal position">
<button data-phase="summer">June solstice<small>North tilted sunward</small></button>
<button data-phase="march">March equinox<small>Neither pole tilted sunward</small></button>
<button data-phase="winter">December solstice<small>North tilted away</small></button>
<button data-phase="september">September equinox<small>Neither pole tilted sunward</small></button>
</div>
<label class="speed-control">
Speed
<input id="speed" type="range" min="0.35" max="1.8" step="0.05" value="1" />
<span id="speedValue">1.0×</span>
</label>
<div class="legend">
<div><span class="swatch" style="color:#62e8ff;background:#62e8ff"></span>Fixed axial direction</div>
<div><span class="swatch" style="color:#ffd071;background:#ffd071"></span>Parallel sunlight</div>
<div><span class="swatch" style="color:#ff754a;background:#ff754a"></span>Interior layers</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Click a season to inspect</div>
</div>
<div id="loading">Building the 3D scene…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: 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.12;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.08,
150
);
const TAU = Math.PI * 2;
const OBLIQUITY = THREE.MathUtils.degToRad(23.44);
const ORBIT_RADIUS = 7.6;
const EARTH_RADIUS = 1.3;
const SUN_RADIUS = 1.55;
const Y_AXIS = new THREE.Vector3(0, 1, 0);
const AXIS = new THREE.Vector3(
Math.sin(OBLIQUITY),
Math.cos(OBLIQUITY),
0
).normalize();
const axisQuaternion = new THREE.Quaternion().setFromUnitVectors(Y_AXIS, AXIS);
scene.add(new THREE.AmbientLight(0x7188bd, 0.18));
// Deterministic background stars.
let randomSeed = 90210;
function random() {
randomSeed |= 0;
randomSeed = randomSeed + 0x6D2B79F5 | 0;
let t = Math.imul(randomSeed ^ randomSeed >>> 15, 1 | randomSeed);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
const starPositions = [];
for (let i = 0; i < 850; i++) {
const radius = 35 + random() * 55;
const theta = random() * TAU;
const phi = Math.acos(2 * random() - 1);
starPositions.push(
radius * Math.sin(phi) * Math.cos(theta),
radius * Math.cos(phi),
radius * Math.sin(phi) * Math.sin(theta)
);
}
const starGeometry = new THREE.BufferGeometry();
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
scene.add(new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0xa9c7ef,
size: 0.07,
transparent: true,
opacity: 0.65,
sizeAttenuation: true
})
));
// Sun and physically positioned point light.
const sun = new THREE.Mesh(
new THREE.SphereGeometry(SUN_RADIUS, 64, 48),
new THREE.MeshBasicMaterial({ color: 0xffc04d })
);
scene.add(sun);
const corona = new THREE.Mesh(
new THREE.SphereGeometry(SUN_RADIUS * 1.08, 48, 32),
new THREE.MeshBasicMaterial({
color: 0xffa52f,
transparent: true,
opacity: 0.18,
depthWrite: false
})
);
scene.add(corona);
const glowCanvas = document.createElement("canvas");
glowCanvas.width = glowCanvas.height = 256;
const glowContext = glowCanvas.getContext("2d");
const glowGradient = glowContext.createRadialGradient(
128, 128, 6,
128, 128, 128
);
glowGradient.addColorStop(0, "rgba(255,225,145,0.95)");
glowGradient.addColorStop(0.18, "rgba(255,178,62,0.46)");
glowGradient.addColorStop(0.5, "rgba(255,137,28,0.12)");
glowGradient.addColorStop(1, "rgba(255,120,20,0)");
glowContext.fillStyle = glowGradient;
glowContext.fillRect(0, 0, 256, 256);
const glowTexture = new THREE.CanvasTexture(glowCanvas);
glowTexture.colorSpace = THREE.SRGBColorSpace;
const glowSprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: glowTexture,
transparent: true,
blending: THREE.AdditiveBlending,
depthWrite: false
}));
glowSprite.scale.set(6.3, 6.3, 1);
scene.add(glowSprite);
const sunlight = new THREE.PointLight(0xffe4b2, 1150, 0, 2);
scene.add(sunlight);
// Perfect circular orbit: no exaggerated eccentricity.
const orbitPoints = [];
for (let i = 0; i <= 220; i++) {
const a = (i / 220) * TAU;
orbitPoints.push(
new THREE.Vector3(
Math.cos(a) * ORBIT_RADIUS,
0,
Math.sin(a) * ORBIT_RADIUS
)
);
}
const orbit = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(orbitPoints),
new THREE.LineDashedMaterial({
color: 0x6085b6,
dashSize: 0.16,
gapSize: 0.11,
transparent: true,
opacity: 0.68
})
);
orbit.computeLineDistances();
scene.add(orbit);
const orbitDisk = new THREE.Mesh(
new THREE.CircleGeometry(ORBIT_RADIUS, 160),
new THREE.MeshBasicMaterial({
color: 0x2a5b89,
transparent: true,
opacity: 0.025,
side: THREE.DoubleSide,
depthWrite: false
})
);
orbitDisk.rotation.x = -Math.PI / 2;
scene.add(orbitDisk);
// Procedural equirectangular Earth texture.
function makeEarthTexture() {
const textureCanvas = document.createElement("canvas");
textureCanvas.width = 1024;
textureCanvas.height = 512;
const ctx = textureCanvas.getContext("2d");
const ocean = ctx.createLinearGradient(0, 0, 0, 512);
ocean.addColorStop(0, "#124f78");
ocean.addColorStop(0.5, "#08729c");
ocean.addColorStop(1, "#123e68");
ctx.fillStyle = ocean;
ctx.fillRect(0, 0, 1024, 512);
const land = "#6e9a59";
const landLight = "#9ab56b";
const desert = "#b7a36d";
function polygon(points, color) {
ctx.beginPath();
points.forEach(([x, y], index) => {
if (index === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.closePath();
ctx.fillStyle = color;
ctx.fill();
}
polygon([
[105,145],[150,105],[215,93],[275,120],[304,160],
[286,200],[320,220],[288,260],[245,250],[225,292],
[193,280],[170,240],[132,228],[118,190]
], land);
polygon([[255,275],[310,286],[347,333],[329,390],[300,450],
[272,414],[266,366],[236,327]], landLight);
polygon([[445,126],[490,93],[542,105],[568,139],[545,172],
[503,176],[479,206],[445,185]], landLight);
polygon([[478,188],[531,174],[578,209],[595,275],[565,345],
[525,378],[485,323],[463,258]], land);
polygon([[535,98],[618,72],[723,92],[817,125],[872,172],
[824,208],[762,198],[718,225],[655,207],[615,245],
[570,207],[548,157]], land);
polygon([[565,223],[620,218],[660,244],[641,288],[592,277]], desert);
polygon([[756,325],[819,315],[862,344],[839,391],[781,399],[745,366]], desert);
polygon([[920,205],[949,185],[963,215],[946,250],[919,238]], land);
polygon([
[0,463],[120,455],[235,460],[360,452],[510,459],[650,453],
[800,460],[930,451],[1024,463],[1024,512],[0,512]
], "#d7e4e3");
// Subtle latitude/longitude grid.
ctx.strokeStyle = "rgba(220,245,255,0.10)";
ctx.lineWidth = 1;
for (let x = 0; x <= 1024; x += 64) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, 512);
ctx.stroke();
}
for (let y = 0; y <= 512; y += 64) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(1024, y);
ctx.stroke();
}
// A few soft cloud strokes.
ctx.strokeStyle = "rgba(255,255,255,0.16)";
ctx.lineWidth = 10;
ctx.lineCap = "round";
for (let i = 0; i < 18; i++) {
const x = random() * 1024;
const y = random() * 512;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.bezierCurveTo(
x + 20, y - 9,
x + 40, y + 9,
x + 65, y - 2
);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(textureCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const earthTexture = makeEarthTexture();
// Earth rig: only its orbital position changes. Its quaternion stays fixed,
// so the axial direction remains constant throughout the orbit.
const earthRig = new THREE.Group();
earthRig.quaternion.copy(axisQuaternion);
scene.add(earthRig);
const gapAngle = 1.16;
const phiStart = Math.PI / 2 + gapAngle / 2;
const phiLength = TAU - gapAngle;
function cutSphere(radius, material, gap = gapAngle) {
const start = Math.PI / 2 + gap / 2;
const length = TAU - gap;
return new THREE.Mesh(
new THREE.SphereGeometry(radius, 72, 48, start, length),
material
);
}
const crust = cutSphere(
EARTH_RADIUS,
new THREE.MeshStandardMaterial({
map: earthTexture,
roughness: 0.88,
metalness: 0,
emissive: 0x061423,
emissiveIntensity: 0.18,
side: THREE.DoubleSide
})
);
earthRig.add(crust);
const innerCrust = cutSphere(
EARTH_RADIUS * 0.93,
new THREE.MeshStandardMaterial({
color: 0x8d3f29,
roughness: 0.9,
side: THREE.DoubleSide
})
);
earthRig.add(innerCrust);
const mantle = cutSphere(
EARTH_RADIUS * 0.72,
new THREE.MeshStandardMaterial({
color: 0xe65f28,
roughness: 0.72,
emissive: 0x321006,
emissiveIntensity: 0.22,
side: THREE.DoubleSide
})
);
earthRig.add(mantle);
const outerCore = cutSphere(
EARTH_RADIUS * 0.47,
new THREE.MeshStandardMaterial({
color: 0xffc247,
roughness: 0.5,
emissive: 0x7a3900,
emissiveIntensity: 0.34,
side: THREE.DoubleSide
})
);
earthRig.add(outerCore);
const innerCore = new THREE.Mesh(
new THREE.SphereGeometry(EARTH_RADIUS * 0.24, 48, 32),
new THREE.MeshStandardMaterial({
color: 0xff6742,
roughness: 0.35,
emissive: 0xb32400,
emissiveIntensity: 0.8
})
);
earthRig.add(innerCore);
const atmosphere = cutSphere(
EARTH_RADIUS * 1.035,
new THREE.MeshBasicMaterial({
color: 0x60cfff,
transparent: true,
opacity: 0.08,
side: THREE.BackSide,
depthWrite: false
})
);
earthRig.add(atmosphere);
// Bright edges around the cutaway wedge.
function meridianGeometry(phi) {
const points = [];
for (let i = 0; i <= 80; i++) {
const theta = (i / 80) * Math.PI;
points.push(new THREE.Vector3(
-EARTH_RADIUS * Math.cos(phi) * Math.sin(theta),
EARTH_RADIUS * Math.cos(theta),
EARTH_RADIUS * Math.sin(phi) * Math.sin(theta)
));
}
return new THREE.BufferGeometry().setFromPoints(points);
}
const cutEdgeMaterial = new THREE.LineBasicMaterial({
color: 0xbdeeff,
transparent: true,
opacity: 0.62
});
earthRig.add(new THREE.Line(
meridianGeometry(phiStart),
cutEdgeMaterial
));
earthRig.add(new THREE.Line(
meridianGeometry(phiStart + phiLength),
cutEdgeMaterial
));
const equatorPoints = [];
for (let i = 0; i < 100; i++) {
const a = (i / 100) * TAU;
equatorPoints.push(new THREE.Vector3(
EARTH_RADIUS * 1.006 * Math.cos(a),
0,
EARTH_RADIUS * 1.006 * Math.sin(a)
));
}
earthRig.add(new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(equatorPoints),
new THREE.LineBasicMaterial({
color: 0xeaf7ff,
transparent: true,
opacity: 0.28
})
));
// Axial direction arrow, drawn through the cutaway.
const axisMaterial = new THREE.MeshBasicMaterial({
color: 0x62e8ff,
depthTest: false,
transparent: true,
opacity: 0.95
});
const axisShaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.014, 0.014, 3.45, 12),
axisMaterial
);
axisShaft.renderOrder = 8;
earthRig.add(axisShaft);
const axisHead = new THREE.Mesh(
new THREE.ConeGeometry(0.075, 0.28, 18),
axisMaterial
);
axisHead.position.y = 1.85;
axisHead.renderOrder = 8;
earthRig.add(axisHead);
const southHead = new THREE.Mesh(
new THREE.ConeGeometry(0.052, 0.2, 16),
axisMaterial
);
southHead.position.y = -1.82;
southHead.rotation.z = Math.PI;
southHead.renderOrder = 8;
earthRig.add(southHead);
for (const y of [-EARTH_RADIUS, EARTH_RADIUS]) {
const pole = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 16, 12),
axisMaterial
);
pole.position.y = y;
pole.renderOrder = 8;
earthRig.add(pole);
}
// The four seasonal positions.
const phases = [
{
key: "summer",
angle: Math.PI,
title: "June solstice",
short: "June solstice",
color: 0xffd071,
heading: "The North Pole leans toward the Sun",
copy: "The Northern Hemisphere receives more direct sunlight and has longer days. The Southern Hemisphere receives lower-angle sunlight and has shorter days."
},
{
key: "march",
angle: Math.PI * 1.5,
title: "March equinox",
short: "March equinox",
color: 0x7de1b5,
heading: "Neither hemisphere leans toward the Sun",
copy: "The axis is sideways to the Sun. The terminator passes through both poles, and both hemispheres receive roughly 12 hours of daylight, ignoring atmospheric refraction."
},
{
key: "winter",
angle: 0,
title: "December solstice",
short: "December solstice",
color: 0x78a9ff,
heading: "The North Pole leans away from the Sun",
copy: "The Northern Hemisphere receives lower-angle sunlight and has shorter days. The Southern Hemisphere receives more direct sunlight and has longer days."
},
{
key: "september",
angle: Math.PI * 0.5,
title: "September equinox",
short: "September equinox",
color: 0x7de1b5,
heading: "Neither hemisphere leans toward the Sun",
copy: "The axis is sideways to the Sun. The terminator passes through both poles, and both hemispheres receive roughly 12 hours of daylight, ignoring atmospheric refraction."
}
];
const phaseMarkers = new Map();
const axisGuides = new THREE.Group();
scene.add(axisGuides);
for (const phase of phases) {
const position = new THREE.Vector3(
Math.cos(phase.angle) * ORBIT_RADIUS,
0,
Math.sin(phase.angle) * ORBIT_RADIUS
);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.28, 0.032, 12, 64),
new THREE.MeshBasicMaterial({
color: phase.color,
transparent: true,
opacity: 0.8
})
);
ring.position.copy(position);
ring.rotation.x = Math.PI / 2;
scene.add(ring);
const dot = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 16, 12),
new THREE.MeshBasicMaterial({ color: phase.color })
);
dot.position.copy(position);
scene.add(dot);
const guide = new THREE.ArrowHelper(
AXIS,
position,
1.42,
0x62e8ff,
0.19,
0.11
);
guide.line.material.transparent = true;
guide.line.material.opacity = 0.28;
guide.cone.material.transparent = true;
guide.cone.material.opacity = 0.35;
axisGuides.add(guide);
phaseMarkers.set(phase.key, { ring, dot, position });
}
// Parallel sunlight arrows.
const sunlightArrows = [];
for (const offset of [-0.65, 0, 0.65]) {
const arrow = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(),
4,
0xffd47c,
0.24,
0.14
);
arrow.line.material.transparent = true;
arrow.line.material.opacity = 0.7;
arrow.cone.material.transparent = true;
arrow.cone.material.opacity = 0.82;
scene.add(arrow);
sunlightArrows.push({ arrow, offset });
}
// Geometric terminator: the great circle separating day and night.
const terminatorGeometry = new THREE.BufferGeometry();
const terminatorPositions = new Float32Array(121 * 3);
terminatorGeometry.setAttribute(
"position",
new THREE.BufferAttribute(terminatorPositions, 3)
);
const terminator = new THREE.Line(
terminatorGeometry,
new THREE.LineDashedMaterial({
color: 0xe7f3ff,
dashSize: 0.10,
gapSize: 0.065,
transparent: true,
opacity: 0.82,
depthTest: false
})
);
terminator.renderOrder = 9;
scene.add(terminator);
// Reference orbital normal and a 23.4-degree angle arc.
const normalGeometry = new THREE.BufferGeometry();
normalGeometry.setAttribute(
"position",
new THREE.BufferAttribute(new Float32Array(6), 3)
);
const normalGuide = new THREE.Line(
normalGeometry,
new THREE.LineDashedMaterial({
color: 0xb7c8dd,
dashSize: 0.09,
gapSize: 0.065,
transparent: true,
opacity: 0.4,
depthTest: false
})
);
normalGuide.renderOrder = 8;
scene.add(normalGuide);
const tiltArcGeometry = new THREE.BufferGeometry();
tiltArcGeometry.setAttribute(
"position",
new THREE.BufferAttribute(new Float32Array(33 * 3), 3)
);
const tiltArc = new THREE.Line(
tiltArcGeometry,
new THREE.LineBasicMaterial({
color: 0x62e8ff,
transparent: true,
opacity: 0.72,
depthTest: false
})
);
tiltArc.renderOrder = 8;
scene.add(tiltArc);
// Camera controls implemented directly, without addons.
const cameraState = {
target: new THREE.Vector3(),
desiredTarget: new THREE.Vector3(),
radius: 20.5,
desiredRadius: 20.5,
theta: 0.92,
phi: 1.03,
mode: "system"
};
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.006,
0.2,
Math.PI - 0.2
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.desiredRadius = THREE.MathUtils.clamp(
cameraState.desiredRadius * Math.exp(event.deltaY * 0.001),
3.8,
32
);
}, { passive: false });
function setCameraMode(mode) {
cameraState.mode = mode;
cameraState.desiredRadius = mode === "follow" ? 6.2 : 20.5;
followButton.classList.toggle("active", mode === "follow");
followButton.textContent = mode === "follow" ? "Whole system" : "Close-up Earth";
}
const followButton = document.querySelector("#followButton");
followButton.addEventListener("click", () => {
setCameraMode(cameraState.mode === "system" ? "follow" : "system");
});
document.querySelector("#resetButton").addEventListener("click", () => {
cameraState.theta = 0.92;
cameraState.phi = 1.03;
cameraState.desiredRadius = cameraState.mode === "follow" ? 6.2 : 20.5;
});
let guidesVisible = true;
const guidesButton = document.querySelector("#guidesButton");
guidesButton.addEventListener("click", () => {
guidesVisible = !guidesVisible;
axisGuides.visible = guidesVisible;
guidesButton.classList.toggle("active", guidesVisible);
});
let playing = true;
let orbitSpeed = 1;
let orbitAngle = Math.PI;
const playButton = document.querySelector("#playButton");
playButton.addEventListener("click", () => {
playing = !playing;
playButton.textContent = playing ? "Pause" : "Play";
});
const speedInput = document.querySelector("#speed");
const speedValue = document.querySelector("#speedValue");
speedInput.addEventListener("input", () => {
orbitSpeed = Number(speedInput.value);
speedValue.textContent = `${orbitSpeed.toFixed(1)}×`;
});
document.querySelectorAll("[data-phase]").forEach((button) => {
button.addEventListener("click", () => {
const phase = phases.find(item => item.key === button.dataset.phase);
orbitAngle = phase.angle;
playing = false;
playButton.textContent = "Play";
});
});
// World-space labels projected without CSS2DRenderer.
const labelElements = {
sun: document.querySelector("#labelSun"),
june: document.querySelector("#labelJune"),
march: document.querySelector("#labelMarch"),
december: document.querySelector("#labelDecember"),
september: document.querySelector("#labelSeptember"),
axis: document.querySelector("#labelAxis"),
normal: document.querySelector("#labelNormal"),
north: document.querySelector("#labelNorth"),
south: document.querySelector("#labelSouth"),
day: document.querySelector("#labelDay"),
night: document.querySelector("#labelNight"),
crust: document.querySelector("#labelCrust"),
mantle: document.querySelector("#labelMantle"),
core: document.querySelector("#labelCore")
};
const projected = new THREE.Vector3();
function positionLabel(element, worldPosition, visible = true, dx = 0, dy = 0) {
projected.copy(worldPosition).project(camera);
const onScreen =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.15 &&
projected.x < 1.15 &&
projected.y > -1.15 &&
projected.y < 1.15;
if (!visible || !onScreen) {
element.style.display = "none";
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth + dx;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight + dy;
element.style.display = "block";
element.style.transform = `translate(${x}px, ${y}px) translate(-50%, -50%)`;
}
function localToWorld(localPoint) {
return localPoint.clone().applyQuaternion(earthRig.quaternion).add(earthRig.position);
}
function angularDistance(a, b) {
return Math.abs(Math.atan2(Math.sin(a - b), Math.cos(a - b)));
}
function dayLength(latitude, declination) {
const value = -Math.tan(THREE.MathUtils.degToRad(latitude)) *
Math.tan(THREE.MathUtils.degToRad(declination));
const clamped = THREE.MathUtils.clamp(value, -1, 1);
return Math.acos(clamped) / Math.PI * 24;
}
const phasePill = document.querySelector("#phasePill");
const phaseTitle = document.querySelector("#phaseTitle");
const phaseCopy = document.querySelector("#phaseCopy");
const facing = document.querySelector("#facing");
const subsolar = document.querySelector("#subsolar");
const distance = document.querySelector("#distance");
const dayNorth = document.querySelector("#dayNorth");
const daySouth = document.querySelector("#daySouth");
function updateLesson(declination) {
let nearest = phases[0];
let nearestDistance = Infinity;
for (const phase of phases) {
const distance = angularDistance(orbitAngle, phase.angle);
if (distance < nearestDistance) {
nearestDistance = distance;
nearest = phase;
}
}
const isAtMarker = nearestDistance < 0.025;
const signed = `${declination >= 0 ? "+" : ""}${declination.toFixed(1)}°`;
phasePill.textContent = isAtMarker
? nearest.short
: `Moving · nearest ${nearest.short}`;
phasePill.style.color = `#${new THREE.Color(nearest.color).getHexString()}`;
phasePill.style.borderColor = `#${new THREE.Color(nearest.color).getHexString()}55`;
phasePill.style.background = `#${new THREE.Color(nearest.color).getHexString()}18`;
if (isAtMarker) {
phaseTitle.textContent = nearest.heading;
phaseCopy.textContent = nearest.copy;
} else {
phaseTitle.textContent = "The axis still points the same way";
phaseCopy.textContent =
"The orbit carries Earth around the Sun, but its axis does not follow the orbit. " +
"The changing angle between the axis and the sunlight redistributes heat and daylight between the hemispheres.";
}
if (declination > 1.5) {
facing.textContent = "North Pole: tilted sunward · Southern winter conditions";
} else if (declination < -1.5) {
facing.textContent = "North Pole: tilted away · Southern summer conditions";
} else {
facing.textContent = "Equinox geometry: neither pole tilts sunward";
}
subsolar.textContent = signed;
distance.textContent = "1.00 AU";
dayNorth.textContent = `${dayLength(45, declination).toFixed(1)} h`;
daySouth.textContent = `${dayLength(-45, declination).toFixed(1)} h`;
}
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
if (playing) {
orbitAngle = (orbitAngle + delta * orbitSpeed * 0.105) % TAU;
}
const radial = new THREE.Vector3(
Math.cos(orbitAngle),
0,
Math.sin(orbitAngle)
);
earthRig.position.copy(radial).multiplyScalar(ORBIT_RADIUS);
earthRig.quaternion.copy(axisQuaternion);
earthRig.updateMatrixWorld(true);
const toSun = radial.clone().negate();
const declination = THREE.MathUtils.radToDeg(
Math.asin(THREE.MathUtils.clamp(toSun.dot(AXIS), -1, 1))
);
// Update parallel sunlight arrows.
const rayLength = ORBIT_RADIUS - EARTH_RADIUS - SUN_RADIUS - 0.25;
for (const { arrow, offset } of sunlightArrows) {
arrow.position.copy(radial).multiplyScalar(SUN_RADIUS + 0.25);
arrow.position.addScaledVector(Y_AXIS, offset);
arrow.setDirection(radial);
arrow.setLength(rayLength, 0.23, 0.13);
}
// Update the terminator circle.
const tangent = new THREE.Vector3(-radial.z, 0, radial.x);
for (let i = 0; i <= 120; i++) {
const a = (i / 120) * TAU;
const point = earthRig.position.clone()
.addScaledVector(Y_AXIS, Math.cos(a) * EARTH_RADIUS * 1.012)
.addScaledVector(tangent, Math.sin(a) * EARTH_RADIUS * 1.012);
terminatorPositions[i * 3] = point.x;
terminatorPositions[i * 3 + 1] = point.y;
terminatorPositions[i * 3 + 2] = point.z;
}
terminatorGeometry.attributes.position.needsUpdate = true;
terminator.computeLineDistances();
// Orbital-normal reference.
const normalArray = normalGeometry.attributes.position.array;
normalArray[0] = earthRig.position.x;
normalArray[1] = earthRig.position.y;
normalArray[2] = earthRig.position.z;
normalArray[3] = earthRig.position.x;
normalArray[4] = earthRig.position.y + 2.05;
normalArray[5] = earthRig.position.z;
normalGeometry.attributes.position.needsUpdate = true;
normalGuide.computeLineDistances();
// 23.4-degree arc between orbital normal and Earth's axis.
const arcArray = tiltArcGeometry.attributes.position.array;
const arcQuaternion = new THREE.Quaternion().setFromUnitVectors(Y_AXIS, AXIS);
for (let i = 0; i <= 32; i++) {
const t = i / 32;
const direction = Y_AXIS.clone()
.applyQuaternion(new THREE.Quaternion().slerpQuaternions(
new THREE.Quaternion(),
arcQuaternion,
t
))
.normalize();
const point = earthRig.position.clone().addScaledVector(direction, 0.66);
arcArray[i * 3] = point.x;
arcArray[i * 3 + 1] = point.y;
arcArray[i * 3 + 2] = point.z;
}
tiltArcGeometry.attributes.position.needsUpdate = true;
// Smooth camera target and radius.
if (cameraState.mode === "follow") {
cameraState.desiredTarget.copy(earthRig.position);
} else {
cameraState.desiredTarget.set(0, 0, 0);
}
cameraState.target.lerp(
cameraState.desiredTarget,
1 - Math.exp(-delta * 4.5)
);
cameraState.radius +=
(cameraState.desiredRadius - cameraState.radius) *
(1 - Math.exp(-delta * 6));
const offset = new THREE.Vector3(
Math.sin(cameraState.phi) * Math.cos(cameraState.theta),
Math.cos(cameraState.phi),
Math.sin(cameraState.phi) * Math.sin(cameraState.theta)
).multiplyScalar(cameraState.radius);
camera.position.copy(cameraState.target).add(offset);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
// Highlight the nearest seasonal marker.
let nearestKey = "";
let nearestDistance = Infinity;
for (const phase of phases) {
const d = angularDistance(orbitAngle, phase.angle);
if (d < nearestDistance) {
nearestDistance = d;
nearestKey = phase.key;
}
}
for (const phase of phases) {
const marker = phaseMarkers.get(phase.key);
const isNearest = phase.key === nearestKey;
const pulse = isNearest ? 1 + Math.sin(elapsed * 3.4) * 0.08 : 1;
marker.ring.scale.setScalar(pulse);
marker.ring.material.opacity = isNearest ? 1 : 0.42;
marker.dot.scale.setScalar(isNearest ? 1.35 : 1);
}
updateLesson(declination);
// Labels.
const closeUp = cameraState.mode === "follow";
positionLabel(labelElements.sun, new THREE.Vector3(0, SUN_RADIUS + 0.55, 0));
positionLabel(labelElements.june, phaseMarkers.get("summer").position.clone().add(new THREE.Vector3(0, 0.62, 0)), !closeUp);
positionLabel(labelElements.march, phaseMarkers.get("march").position.clone().add(new THREE.Vector3(0, 0.62, 0)), !closeUp);
positionLabel(labelElements.december, phaseMarkers.get("winter").position.clone().add(new THREE.Vector3(0, 0.62, 0)), !closeUp);
positionLabel(labelElements.september, phaseMarkers.get("september").position.clone().add(new THREE.Vector3(0, 0.62, 0)), !closeUp);
positionLabel(
labelElements.axis,
earthRig.position.clone().addScaledVector(AXIS, 2.02),
true
);
positionLabel(
labelElements.normal,
earthRig.position.clone().add(new THREE.Vector3(0, 2.18, 0)),
true
);
positionLabel(
labelElements.north,
earthRig.position.clone().addScaledVector(AXIS, EARTH_RADIUS + 0.24),
true
);
positionLabel(
labelElements.south,
earthRig.position.clone().addScaledVector(AXIS, -(EARTH_RADIUS + 0.24)),
true
);
positionLabel(
labelElements.day,
earthRig.position.clone()
.addScaledVector(toSun, EARTH_RADIUS * 0.73)
.add(new THREE.Vector3(0, 0.36, 0)),
true,
0,
-4
);
positionLabel(
labelElements.night,
earthRig.position.clone()
.addScaledVector(radial, EARTH_RADIUS * 0.73)
.add(new THREE.Vector3(0, 0.36, 0)),
true,
0,
-4
);
positionLabel(
labelElements.crust,
localToWorld(new THREE.Vector3(0.08, 0.82, 0.96)),
closeUp,
31,
-4
);
positionLabel(
labelElements.mantle,
localToWorld(new THREE.Vector3(0, 0.43, 0.56)),
closeUp,
31,
-4
);
positionLabel(
labelElements.core,
localToWorld(new THREE.Vector3(0.02, -0.04, 0.3)),
closeUp,
31,
-4
);
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);
});
animate();
requestAnimationFrame(() => {
const loading = document.querySelector("#loading");
loading.style.opacity = "0";
setTimeout(() => loading.remove(), 320);
});
</script>
</body>
</html>
```