Prompt specification
Build or customize the Three.js 3D scene "Layer-property concept explorer" 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: Layer-property concept explorer
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/layer-property-concept-explorer-x1140
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Earth's layered interior. Allow toggling solid and liquid layer labels on a schematic Earth section; show which simplified wave types propagate through each region while separating illustration from measured travel times. Low-poly.
Working Three.js Starter (layer-property-concept-explorer-x1140):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Inside Earth — Layered Seismic Wave Scene</title>
<style>
:root {
color-scheme: dark;
--bg: #060a10;
--panel: #0c121c;
--panel-2: #111a27;
--line: rgba(163, 195, 222, 0.15);
--text: #eaf3fb;
--muted: #8fa3b7;
--cyan: #59d7ff;
--pink: #ff72b7;
--gold: #ffc857;
--green: #62a995;
--orange: #f07843;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
height: 100dvh;
display: grid;
grid-template-rows: 72px minmax(0, 1fr);
}
header {
z-index: 20;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid var(--line);
background: rgba(7, 11, 17, 0.94);
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 36px;
height: 36px;
flex: 0 0 auto;
border: 1px solid rgba(89, 215, 255, 0.7);
border-radius: 50%;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
inset: 6px;
border: 1px solid rgba(255, 200, 87, 0.65);
border-radius: 50%;
}
.brand-mark::after {
inset: 13px;
background: var(--gold);
border: 0;
box-shadow: 0 0 12px rgba(255, 200, 87, 0.8);
}
.eyebrow {
margin: 0 0 3px;
color: var(--cyan);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 19px;
font-weight: 650;
letter-spacing: -0.025em;
}
.header-note {
display: flex;
align-items: center;
gap: 9px;
color: var(--muted);
font-size: 12px;
white-space: nowrap;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #74dfad;
box-shadow: 0 0 10px rgba(116, 223, 173, 0.7);
}
main {
min-height: 0;
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
}
#stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 53% 45%, rgba(27, 55, 75, 0.26), transparent 42%),
radial-gradient(circle at 65% 52%, rgba(37, 66, 83, 0.12), transparent 62%),
#060a10;
}
#canvas-host,
#label-layer {
position: absolute;
inset: 0;
}
#canvas-host {
z-index: 0;
}
#canvas-host canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#canvas-host canvas:active {
cursor: grabbing;
}
#label-layer {
z-index: 4;
pointer-events: none;
}
.floating-card {
border: 1px solid var(--line);
background: rgba(10, 16, 25, 0.84);
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
}
#controls {
position: absolute;
z-index: 8;
top: 18px;
left: 18px;
width: 266px;
padding: 15px;
border-radius: 14px;
}
.control-section + .control-section {
margin-top: 15px;
padding-top: 14px;
border-top: 1px solid var(--line);
}
.control-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 9px;
color: #c7d7e5;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.control-title span:last-child {
color: var(--muted);
font-size: 9px;
font-weight: 550;
letter-spacing: 0.04em;
text-transform: none;
}
.wave-buttons {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.wave-button {
position: relative;
min-height: 49px;
padding: 7px 4px 6px;
border: 1px solid rgba(161, 194, 219, 0.16);
border-radius: 9px;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.wave-button:hover {
transform: translateY(-1px);
border-color: rgba(161, 194, 219, 0.35);
}
.wave-button.active {
border-color: var(--wave-color);
background: color-mix(in srgb, var(--wave-color) 12%, transparent);
box-shadow: inset 0 0 20px color-mix(in srgb, var(--wave-color) 6%, transparent);
}
.wave-symbol {
display: block;
margin-bottom: 3px;
color: var(--wave-color);
font-size: 16px;
font-weight: 750;
}
.wave-name {
display: block;
color: #c4d3df;
font-size: 9px;
line-height: 1.15;
}
#route-description {
min-height: 42px;
margin: 10px 1px 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
min-height: 28px;
color: #c8d6e2;
font-size: 11px;
cursor: pointer;
}
.toggle-row + .toggle-row {
margin-top: 5px;
}
.toggle-copy {
display: flex;
align-items: center;
gap: 8px;
}
.layer-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--dot-color);
box-shadow: 0 0 8px color-mix(in srgb, var(--dot-color) 45%, transparent);
}
.toggle-row input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch {
position: relative;
width: 31px;
height: 18px;
flex: 0 0 auto;
border: 1px solid rgba(170, 199, 221, 0.2);
border-radius: 999px;
background: #182331;
transition: 160ms ease;
}
.switch::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 10px;
height: 10px;
border-radius: 50%;
background: #708397;
transition: 160ms ease;
}
.toggle-row input:checked + .switch {
border-color: rgba(89, 215, 255, 0.55);
background: rgba(89, 215, 255, 0.17);
}
.toggle-row input:checked + .switch::after {
left: 16px;
background: var(--cyan);
box-shadow: 0 0 8px rgba(89, 215, 255, 0.6);
}
.mini-legend {
display: grid;
gap: 7px;
margin-top: 11px;
}
.legend-item {
display: grid;
grid-template-columns: 22px 1fr;
gap: 7px;
align-items: start;
color: var(--muted);
font-size: 10px;
line-height: 1.35;
}
.legend-symbol {
color: var(--legend-color);
font-weight: 800;
text-align: center;
}
#reset-camera {
position: absolute;
z-index: 8;
top: 18px;
right: 18px;
padding: 9px 12px;
border-radius: 9px;
color: #bdcedd;
font-size: 10px;
cursor: pointer;
}
#reset-camera:hover {
color: white;
border-color: rgba(89, 215, 255, 0.35);
}
.stage-badge {
position: absolute;
z-index: 7;
top: 65px;
right: 18px;
display: flex;
align-items: center;
gap: 7px;
color: #8297aa;
font-size: 9px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.stage-badge::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--gold);
}
#timeline {
position: absolute;
z-index: 8;
left: 50%;
bottom: 20px;
width: min(530px, calc(100% - 36px));
transform: translateX(-50%);
padding: 11px 13px 10px;
border-radius: 13px;
}
.timeline-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
margin-bottom: 8px;
}
.timeline-title {
color: #d8e5ee;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.timeline-warning {
color: #8fa3b7;
font-size: 9px;
}
.timeline-controls {
display: grid;
grid-template-columns: 34px minmax(0, 1fr) 34px;
align-items: center;
gap: 9px;
}
.icon-button {
width: 34px;
height: 28px;
padding: 0;
border: 1px solid rgba(166, 197, 220, 0.17);
border-radius: 7px;
background: rgba(255, 255, 255, 0.03);
color: #c7d8e6;
cursor: pointer;
}
.icon-button:hover {
border-color: rgba(89, 215, 255, 0.4);
color: white;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
appearance: none;
border-radius: 99px;
background: linear-gradient(
to right,
var(--cyan) 0%,
var(--cyan) var(--range-progress, 0%),
#273544 var(--range-progress, 0%),
#273544 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 13px;
height: 13px;
appearance: none;
border: 2px solid #07101a;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 9px rgba(89, 215, 255, 0.55);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid #07101a;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 9px rgba(89, 215, 255, 0.55);
}
.gesture-hint {
position: absolute;
z-index: 6;
left: 18px;
bottom: 20px;
color: rgba(164, 185, 203, 0.62);
font-size: 9px;
pointer-events: none;
}
.scene-label {
position: absolute;
z-index: 5;
min-width: 112px;
max-width: 145px;
padding: 7px 9px;
border: 1px solid rgba(165, 195, 220, 0.18);
border-left: 2px solid var(--label-color);
border-radius: 7px;
background: rgba(7, 13, 21, 0.82);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
transform: translateY(-50%);
transition: opacity 140ms ease;
backdrop-filter: blur(8px);
}
.scene-label.is-hidden,
.leader-line.is-hidden {
display: none;
}
.label-name {
color: #eef6fb;
font-size: 10px;
font-weight: 700;
}
.label-meta {
margin-top: 2px;
color: #8398aa;
font-size: 8px;
}
.label-chips {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 5px;
}
.wave-chip {
min-width: 17px;
padding: 2px 4px;
border: 1px solid rgba(160, 190, 214, 0.15);
border-radius: 4px;
color: #71879a;
font-size: 8px;
font-weight: 800;
line-height: 1;
text-align: center;
}
.wave-chip.pass {
color: #9fb0bf;
}
.wave-chip.blocked {
color: #ff8179;
border-color: rgba(255, 106, 96, 0.22);
}
.wave-chip.selected {
border-color: var(--chip-color);
color: var(--chip-color);
background: color-mix(in srgb, var(--chip-color) 9%, transparent);
}
.leader-line {
position: absolute;
z-index: 3;
height: 1px;
transform-origin: left center;
background: linear-gradient(
to right,
rgba(161, 193, 216, 0.12),
rgba(161, 193, 216, 0.45)
);
pointer-events: none;
}
#loading {
position: absolute;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
color: var(--muted);
background: #060a10;
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
aside {
min-height: 0;
overflow-y: auto;
border-left: 1px solid var(--line);
background: linear-gradient(180deg, #0c121c, #090e16);
scrollbar-color: #283849 #0b111a;
}
.panel-section {
padding: 21px 20px;
border-bottom: 1px solid var(--line);
}
.panel-section:last-child {
border-bottom: 0;
}
.panel-kicker {
margin-bottom: 7px;
color: var(--cyan);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.panel-title {
margin: 0;
color: #edf5fa;
font-size: 17px;
font-weight: 650;
letter-spacing: -0.02em;
}
.panel-intro {
margin: 8px 0 15px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.matrix {
width: 100%;
border-collapse: collapse;
font-size: 10px;
}
.matrix th {
padding: 0 0 9px;
color: #6f8498;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.1em;
text-align: center;
text-transform: uppercase;
}
.matrix th:first-child {
text-align: left;
}
.matrix td {
padding: 10px 5px;
border-top: 1px solid rgba(166, 195, 218, 0.09);
text-align: center;
}
.matrix td:first-child {
text-align: left;
}
.matrix-layer {
display: flex;
align-items: center;
gap: 8px;
color: #cbd9e5;
font-weight: 600;
}
.matrix-layer::before {
content: "";
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--layer-color);
}
.matrix-type {
color: #91a7ba;
font-weight: 800;
}
.matrix-type.yes {
color: #d6e5ef;
}
.matrix-type.no {
color: #e36b66;
font-size: 8px;
}
.matrix-note {
display: flex;
align-items: flex-start;
gap: 8px;
margin-top: 13px;
padding: 10px;
border: 1px solid rgba(255, 200, 87, 0.13);
border-radius: 8px;
background: rgba(255, 200, 87, 0.035);
color: #a6b5c1;
font-size: 9px;
line-height: 1.5;
}
.matrix-note strong {
color: var(--gold);
}
.reference-list {
display: grid;
gap: 14px;
margin-top: 17px;
}
.reference-row {
display: grid;
gap: 6px;
}
.reference-top {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
}
.reference-phase {
color: #c9d7e2;
font-size: 10px;
font-weight: 650;
}
.reference-time {
color: white;
font-size: 12px;
font-weight: 750;
white-space: nowrap;
}
.reference-route {
color: #73899d;
font-size: 9px;
}
.bar-track {
height: 4px;
overflow: hidden;
border-radius: 99px;
background: #202c39;
}
.bar-fill {
height: 100%;
width: var(--bar-width);
border-radius: inherit;
background: var(--bar-color);
box-shadow: 0 0 10px color-mix(in srgb, var(--bar-color) 28%, transparent);
}
.reference-axis {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: #566b7e;
font-size: 8px;
}
.data-note {
margin: 15px 0 0;
padding-top: 13px;
border-top: 1px solid var(--line);
color: #70869a;
font-size: 9px;
line-height: 1.55;
}
.data-note strong {
color: #a7bacb;
}
.concept-note {
margin-top: 12px;
padding: 11px;
border: 1px solid rgba(89, 215, 255, 0.12);
border-radius: 8px;
background: rgba(89, 215, 255, 0.035);
color: #8298ab;
font-size: 9px;
line-height: 1.55;
}
.concept-note strong {
color: var(--cyan);
}
@media (max-width: 980px) {
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100dvh;
grid-template-rows: 68px auto;
}
main {
display: block;
}
#stage {
height: 70dvh;
min-height: 520px;
}
aside {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.panel-section {
padding: 22px max(20px, calc((100vw - 720px) / 2));
}
.header-note {
display: none;
}
}
@media (max-width: 600px) {
header {
padding: 0 16px;
}
h1 {
font-size: 16px;
}
#controls {
top: 12px;
left: 12px;
width: 230px;
padding: 12px;
}
#reset-camera {
top: 12px;
right: 12px;
}
.stage-badge {
top: 55px;
right: 12px;
}
.gesture-hint {
display: none;
}
#timeline {
bottom: 12px;
width: calc(100% - 24px);
}
.timeline-warning {
font-size: 8px;
}
.scene-label {
min-width: 90px;
max-width: 112px;
padding: 5px 7px;
}
.label-meta {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Planetary Seismology</p>
<h1>Inside Earth: Layered Wave Paths</h1>
</div>
</div>
<div class="header-note">
<span class="status-dot"></span>
Interactive low-poly cutaway · simplified propagation model
</div>
</header>
<main>
<section id="stage" aria-label="Interactive cutaway of Earth's interior">
<div id="canvas-host"></div>
<div id="label-layer" aria-hidden="true"></div>
<section id="controls" class="floating-card" aria-label="Scene controls">
<div class="control-section">
<div class="control-title">
<span>Trace a wave</span>
<span>schematic overlay</span>
</div>
<div class="wave-buttons">
<button
class="wave-button active"
data-wave="P"
style="--wave-color: var(--cyan)"
aria-pressed="true"
>
<span class="wave-symbol">P</span>
<span class="wave-name">Compressional</span>
</button>
<button
class="wave-button"
data-wave="S"
style="--wave-color: var(--pink)"
aria-pressed="false"
>
<span class="wave-symbol">S</span>
<span class="wave-name">Shear</span>
</button>
<button
class="wave-button"
data-wave="R"
style="--wave-color: var(--gold)"
aria-pressed="false"
>
<span class="wave-symbol">R</span>
<span class="wave-name">Rayleigh</span>
</button>
</div>
<p id="route-description" aria-live="polite">
Travels through both solids and liquids, including the liquid outer core.
</p>
</div>
<div class="control-section">
<div class="control-title">
<span>Layer labels</span>
<span>independent groups</span>
</div>
<label class="toggle-row">
<span class="toggle-copy">
<span class="layer-dot" style="--dot-color: var(--green)"></span>
Solid layers
</span>
<input id="toggle-solid" type="checkbox" checked />
<span class="switch" aria-hidden="true"></span>
</label>
<label class="toggle-row">
<span class="toggle-copy">
<span class="layer-dot" style="--dot-color: var(--orange)"></span>
Liquid layers
</span>
<input id="toggle-liquid" type="checkbox" checked />
<span class="switch" aria-hidden="true"></span>
</label>
<label class="toggle-row">
<span class="toggle-copy">
<span class="layer-dot" style="--dot-color: #8999a8"></span>
Wave route
</span>
<input id="toggle-route" type="checkbox" checked />
<span class="switch" aria-hidden="true"></span>
</label>
</div>
<div class="control-section">
<div class="control-title">
<span>Wave key</span>
</div>
<div class="mini-legend">
<div class="legend-item">
<span class="legend-symbol" style="--legend-color: var(--cyan)">P</span>
<span>Compression: travels through solids and liquids.</span>
</div>
<div class="legend-item">
<span class="legend-symbol" style="--legend-color: var(--pink)">S</span>
<span>Shear: travels through solids, but not liquids.</span>
</div>
<div class="legend-item">
<span class="legend-symbol" style="--legend-color: var(--gold)">R</span>
<span>Rayleigh surface wave: follows the surface.</span>
</div>
</div>
</div>
</section>
<button id="reset-camera" class="floating-card">Reset view</button>
<div class="stage-badge">Low-poly geometry</div>
<section id="timeline" class="floating-card" aria-label="Illustrative wave playback">
<div class="timeline-top">
<span class="timeline-title">Illustrative sequence</span>
<span class="timeline-warning">Playback is not a measured clock</span>
</div>
<div class="timeline-controls">
<button id="play-pause" class="icon-button" aria-label="Pause wave animation">Ⅱ</button>
<input
id="progress"
type="range"
min="0"
max="1000"
value="0"
aria-label="Illustrative wave progress"
/>
<button id="replay" class="icon-button" aria-label="Replay wave animation">↺</button>
</div>
</section>
<div class="gesture-hint">Drag to orbit · scroll to zoom · double-click to reset</div>
<div id="loading">Building planetary section…</div>
</section>
<aside aria-label="Propagation reference">
<section class="panel-section">
<div class="panel-kicker">Propagation Map</div>
<h2 class="panel-title">Which waves cross each layer?</h2>
<p class="panel-intro">
A simplified view of how seismic-wave type constrains the internal
structure of Earth.
</p>
<table class="matrix">
<thead>
<tr>
<th>Region</th>
<th>P</th>
<th>S</th>
<th>R</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="matrix-layer" style="--layer-color: #91a6ad">Crust</span>
</td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type yes">✓</span></td>
</tr>
<tr>
<td>
<span class="matrix-layer" style="--layer-color: #4f8a79">Upper mantle</span>
</td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type no">—</span></td>
</tr>
<tr>
<td>
<span class="matrix-layer" style="--layer-color: #9b6b4a">Lower mantle</span>
</td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type no">—</span></td>
</tr>
<tr>
<td>
<span class="matrix-layer" style="--layer-color: #ef7040">Outer core</span>
</td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type no">BLOCKED</span></td>
<td><span class="matrix-type no">—</span></td>
</tr>
<tr>
<td>
<span class="matrix-layer" style="--layer-color: #ffd36a">Inner core</span>
</td>
<td><span class="matrix-type yes">✓</span></td>
<td><span class="matrix-type no">BLOCKED</span></td>
<td><span class="matrix-type no">—</span></td>
</tr>
</tbody>
</table>
<div class="matrix-note">
<strong>Key inference:</strong>
<span>
S waves cannot pass through the liquid outer core. Their shadow zone
helped reveal that core is liquid.
</span>
</div>
</section>
<section class="panel-section">
<div class="panel-kicker">Separate Data Layer</div>
<h2 class="panel-title">Reference travel times</h2>
<p class="panel-intro">
Representative durations from standard Earth-model travel-time tables
fitted to seismic observations. These values are independent of the
animation above.
</p>
<div class="reference-list">
<div class="reference-row">
<div class="reference-top">
<span class="reference-phase">P · surface to antipode</span>
<span class="reference-time">≈ 20 min</span>
</div>
<span class="reference-route">Direct path through the full diameter</span>
<div class="bar-track">
<div
class="bar-fill"
style="--bar-width: 100%; --bar-color: var(--cyan)"
></div>
</div>
</div>
<div class="reference-row">
<div class="reference-top">
<span class="reference-phase">P · outer core</span>
<span class="reference-time">≈ 2 min</span>
</div>
<span class="reference-route">For a 1,000 km path in fast core material</span>
<div class="bar-track">
<div
class="bar-fill"
style="--bar-width: 10%; --bar-color: var(--cyan)"
></div>
</div>
</div>
<div class="reference-row">
<div class="reference-top">
<span class="reference-phase">S · solid mantle</span>
<span class="reference-time">≈ 4 min</span>
</div>
<span class="reference-route">For a 1,000 km path</span>
<div class="bar-track">
<div
class="bar-fill"
style="--bar-width: 20%; --bar-color: var(--pink)"
></div>
</div>
</div>
<div class="reference-row">
<div class="reference-top">
<span class="reference-phase">R · surface</span>
<span class="reference-time">≈ 5 min</span>
</div>
<span class="reference-route">For a typical 1,000 km Rayleigh path</span>
<div class="bar-track">
<div
class="bar-fill"
style="--bar-width: 25%; --bar-color: var(--gold)"
></div>
</div>
</div>
</div>
<div class="reference-axis">
<span>0 min</span>
<span>5</span>
<span>10</span>
<span>15</span>
<span>20 min</span>
</div>
<p class="data-note">
<strong>Important:</strong> rows use different path lengths and compare
duration, not phase speed. Actual first-arrival times depend on distance,
depth, velocity structure, and the particular seismic phase.
</p>
<div class="concept-note">
<strong>Illustration ≠ measurement.</strong>
The moving pulse is a visual explanation of propagation rules. It is
not synchronized to the reference travel times shown here.
</div>
</section>
</aside>
</main>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const canvasHost = document.getElementById("canvas-host");
const labelLayer = document.getElementById("label-layer");
const loading = document.getElementById("loading");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL is required to display this scene.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.setClearColor(0x060a10, 0);
canvasHost.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly cutaway of Earth with animated seismic-wave paths"
);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(0xa8d8ef, 0x1a120e, 1.55);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xd9f0ff, 3.0);
keyLight.position.set(-4, 7, 5);
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5ea8ff, 1.5);
rimLight.position.set(5, -2, -4);
scene.add(rimLight);
const coreLight = new THREE.PointLight(0xff873b, 8, 7, 2);
coreLight.position.set(0.2, 0, 0.2);
scene.add(coreLight);
const earth = new THREE.Group();
scene.add(earth);
const waveRoute = new THREE.Group();
scene.add(waveRoute);
const layerVisuals = [];
const labelConfigs = [];
const pulseMeshes = [];
const WAVE = {
P: {
color: 0x59d7ff,
css: "#59d7ff",
duration: 6.2,
description:
"Travels through both solids and liquids, including the liquid outer core."
},
S: {
color: 0xff72b7,
css: "#ff72b7",
duration: 5.8,
description:
"Travels through solids, but cannot enter the liquid outer core; the path turns at the core boundary."
},
R: {
color: 0xffc857,
css: "#ffc857",
duration: 4.2,
description:
"A surface wave follows the curved crust and does not travel through the interior."
}
};
const CUT_CENTER = 0.82;
const CUT_HALF = 0.62;
const boundaryPhi = CUT_CENTER - CUT_HALF;
const radii = {
surface: 3.0,
crustBottom: 2.91,
upperMantleBottom: 2.22,
coreMantleBoundary: 1.18,
innerCoreBoundary: 0.48
};
function radial(phi, theta, radius = 1) {
return new THREE.Vector3(
-radius * Math.cos(phi) * Math.sin(theta),
radius * Math.cos(theta),
radius * Math.sin(phi) * Math.sin(theta)
);
}
function makePatch(radius, material, widthSegments = 36, heightSegments = 18) {
const geometry = new THREE.SphereGeometry(
radius,
widthSegments,
heightSegments,
CUT_CENTER + CUT_HALF,
Math.PI * 2 - CUT_HALF * 2,
0,
Math.PI
);
const mesh = new THREE.Mesh(geometry, material);
earth.add(mesh);
return mesh;
}
function makeHalfAnnulus(phi, innerRadius, outerRadius, material) {
const positions = [];
const indices = [];
const segments = 28;
if (innerRadius === 0) {
positions.push(0, 0, 0);
for (let i = 0; i <= segments; i++) {
const theta = (i / segments) * Math.PI;
const point = radial(phi, theta, outerRadius);
positions.push(point.x, point.y, point.z);
}
for (let i = 1; i <= segments; i++) {
indices.push(0, i, i + 1);
}
} else {
for (let i = 0; i <= segments; i++) {
const theta = (i / segments) * Math.PI;
const inner = radial(phi, theta, innerRadius);
const outer = radial(phi, theta, outerRadius);
positions.push(inner.x, inner.y, inner.z);
positions.push(outer.x, outer.y, outer.z);
}
for (let i = 0; i < segments; i++) {
const a = i * 2;
const b = a + 1;
const c = a + 2;
const d = a + 3;
indices.push(a, c, b, b, c, d);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
earth.add(mesh);
return mesh;
}
function addBoundaryLines() {
const lineMaterial = new THREE.LineBasicMaterial({
color: 0x111923,
transparent: true,
opacity: 0.55,
depthWrite: false
});
const boundaryRadii = [
radii.surface,
radii.crustBottom,
radii.upperMantleBottom,
radii.coreMantleBoundary,
radii.innerCoreBoundary
];
for (const phi of [CUT_CENTER - CUT_HALF, CUT_CENTER + CUT_HALF]) {
for (const radius of boundaryRadii) {
const points = [];
for (let i = 0; i <= 32; i++) {
points.push(radial(phi, (i / 32) * Math.PI, radius));
}
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
lineMaterial
);
earth.add(line);
}
}
}
const landRegions = [
{ lon: -102, lat: 46, lonRadius: 34, latRadius: 24 },
{ lon: -61, lat: -16, lonRadius: 19, latRadius: 31 },
{ lon: 17, lat: 52, lonRadius: 23, latRadius: 15 },
{ lon: 20, lat: 4, lonRadius: 25, latRadius: 32 },
{ lon: 87, lat: 43, lonRadius: 54, latRadius: 27 },
{ lon: 135, lat: -26, lonRadius: 22, latRadius: 13 },
{ lon: -42, lat: 72, lonRadius: 15, latRadius: 11 },
{ lon: 47, lat: -20, lonRadius: 6, latRadius: 11 }
];
function wrapDegrees(value) {
return ((value + 540) % 360) - 180;
}
function isLand(lon, lat) {
for (const region of landRegions) {
const dLon = wrapDegrees(lon - region.lon);
const dLat = lat - region.lat;
const metric =
(dLon * dLon) / (region.lonRadius * region.lonRadius) +
(dLat * dLat) / (region.latRadius * region.latRadius);
const coastNoise =
0.09 *
Math.sin(lon * 0.17 + lat * 0.11) +
0.055 * Math.sin(lon * 0.39 - lat * 0.23);
if (metric < 1 + coastNoise) return true;
}
return false;
}
function makeEarthSurfaceMaterial() {
const original = new THREE.SphereGeometry(
radii.surface,
36,
18,
CUT_CENTER + CUT_HALF,
Math.PI * 2 - CUT_HALF * 2,
0,
Math.PI
);
const geometry = original.index
? original.toNonIndexed()
: original;
if (original !== geometry) original.dispose();
const positions = geometry.getAttribute("position");
const colors = [];
const ocean = new THREE.Color(0x163c59);
const deepOcean = new THREE.Color(0x102d46);
const land = new THREE.Color(0x4d9279);
const landLight = new THREE.Color(0x73a987);
for (let i = 0; i < positions.count; i += 3) {
const cx =
(positions.getX(i) +
positions.getX(i + 1) +
positions.getX(i + 2)) /
3;
const cy =
(positions.getY(i) +
positions.getY(i + 1) +
positions.getY(i + 2)) /
3;
const cz =
(positions.getZ(i) +
positions.getZ(i + 1) +
positions.getZ(i + 2)) /
3;
const length = Math.hypot(cx, cy, cz);
const lat = (Math.asin(cy / length) * 180) / Math.PI;
const lon = (Math.atan2(cz, -cx) * 180) / Math.PI;
const triangleIndex = i / 3;
const variation = 0.035 * Math.sin(triangleIndex * 1.713);
let color;
if (isLand(lon, lat)) {
color = land.clone().lerp(landLight, 0.35 + variation);
} else {
color = ocean.clone().lerp(deepOcean, 0.4 + variation);
}
for (let vertex = 0; vertex < 3; vertex++) {
colors.push(color.r, color.g, color.b);
}
}
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.computeVertexNormals();
return new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.9,
metalness: 0.02,
flatShading: true,
side: THREE.DoubleSide,
emissive: 0x000000,
emissiveIntensity: 0
});
}
function createLayerVisual({
id,
inner,
outer,
color,
emissiveIntensity = 0.04,
customSurfaceMaterial = null
}) {
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.04,
emissive: color,
emissiveIntensity,
flatShading: true,
side: THREE.DoubleSide
});
const surfaceMaterial = customSurfaceMaterial || material;
makePatch(outer, surfaceMaterial);
makeHalfAnnulus(
CUT_CENTER - CUT_HALF,
inner,
outer,
material
);
makeHalfAnnulus(
CUT_CENTER + CUT_HALF,
inner,
outer,
material
);
layerVisuals.push({
id,
inner,
outer,
materials:
customSurfaceMaterial && customSurfaceMaterial !== material
? [customSurfaceMaterial, material]
: [material],
baseEmissive: color,
baseIntensity: emissiveIntensity
});
}
createLayerVisual({
id: "crust",
inner: radii.crustBottom,
outer: radii.surface,
color: 0x81969a,
emissiveIntensity: 0.025,
customSurfaceMaterial: makeEarthSurfaceMaterial()
});
createLayerVisual({
id: "upperMantle",
inner: radii.upperMantleBottom,
outer: radii.crustBottom,
color: 0x4f8a79,
emissiveIntensity: 0.035
});
createLayerVisual({
id: "lowerMantle",
inner: radii.coreMantleBoundary,
outer: radii.upperMantleBottom,
color: 0x9b6b4a,
emissiveIntensity: 0.04
});
createLayerVisual({
id: "outerCore",
inner: radii.innerCoreBoundary,
outer: radii.coreMantleBoundary,
color: 0xef7040,
emissiveIntensity: 0.16
});
createLayerVisual({
id: "innerCore",
inner: 0,
outer: radii.innerCoreBoundary,
color: 0xffd36a,
emissiveIntensity: 0.18
});
addBoundaryLines();
let randomSeed = 90421;
function seededRandom() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const starPositions = [];
for (let i = 0; i < 420; i++) {
const theta = Math.acos(2 * seededRandom() - 1);
const phi = seededRandom() * Math.PI * 2;
const radius = 15 + seededRandom() * 16;
const point = radial(phi, theta, radius);
starPositions.push(point.x, point.y, point.z);
}
const starsGeometry = new THREE.BufferGeometry();
starsGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
const stars = new THREE.Points(
starsGeometry,
new THREE.PointsMaterial({
color: 0x8eb8cf,
size: 0.028,
transparent: true,
opacity: 0.43,
depthWrite: false,
sizeAttenuation: true
})
);
scene.add(stars);
const chipDefinitions = {
P: { className: "pass", css: "#59d7ff" },
S: { className: "pass", css: "#ff72b7" },
R: { className: "pass", css: "#ffc857" }
};
function addLabel(config) {
const element = document.createElement("div");
element.className = "scene-label";
element.style.setProperty("--label-color", config.color);
const name = document.createElement("div");
name.className = "label-name";
name.textContent = config.title;
const meta = document.createElement("div");
meta.className = "label-meta";
meta.textContent = config.meta;
const chips = document.createElement("div");
chips.className = "label-chips";
for (const type of config.chips) {
const chip = document.createElement("span");
const blocked = type.endsWith("×");
const waveType = blocked ? type.slice(0, -1) : type;
chip.className = `wave-chip ${
blocked ? "blocked" : chipDefinitions[waveType].className
}`;
chip.style.setProperty(
"--chip-color",
chipDefinitions[waveType].css
);
chip.textContent = type;
chip.dataset.wave = waveType;
chips.appendChild(chip);
}
element.append(name, meta, chips);
const leader = document.createElement("div");
leader.className = "leader-line";
labelLayer.append(leader, element);
labelConfigs.push({
...config,
element,
leader,
anchor: config.anchor.clone(),
chips: [...chips.querySelectorAll(".wave-chip")]
});
}
addLabel({
id: "crust",
group: "solid",
title: "Crust",
meta: "solid · thin outer shell",
color: "#91a6ad",
anchor: radial(boundaryPhi, 0.30, radii.surface),
offset: [27, -7],
chips: ["P", "S", "R"]
});
addLabel({
id: "upperMantle",
group: "solid",
title: "Upper mantle",
meta: "solid · convecting rock",
color: "#5aa08c",
anchor: radial(
boundaryPhi,
0.72,
(radii.crustBottom + radii.upperMantleBottom) / 2
),
offset: [44, -4],
chips: ["P", "S"]
});
addLabel({
id: "lowerMantle",
group: "solid",
title: "Lower mantle",
meta: "solid · high pressure",
color: "#b17a54",
anchor: radial(
boundaryPhi,
1.06,
(radii.upperMantleBottom + radii.coreMantleBoundary) / 2
),
offset: [53, 1],
chips: ["P", "S"]
});
addLabel({
id: "outerCore",
group: "liquid",
title: "Outer core",
meta: "liquid · molten iron alloy",
color: "#f07843",
anchor: radial(
boundaryPhi,
1.32,
(radii.coreMantleBoundary + radii.innerCoreBoundary) / 2
),
offset: [44, 7],
chips: ["P", "S×"]
});
addLabel({
id: "innerCore",
group: "solid",
title: "Inner core",
meta: "solid · crystalline iron alloy",
color: "#ffd36a",
anchor: radial(boundaryPhi, Math.PI / 2, 0.25),
offset: [20, 9],
chips: ["P"]
});
function setLabelGroup(group, visible) {
for (const config of labelConfigs) {
if (config.group !== group) continue;
config.element.classList.toggle("is-hidden", !visible);
config.leader.classList.toggle("is-hidden", !visible);
}
}
document
.getElementById("toggle-solid")
.addEventListener("change", (event) => {
setLabelGroup("solid", event.target.checked);
});
document
.getElementById("toggle-liquid")
.addEventListener("change", (event) => {
setLabelGroup("liquid", event.target.checked);
});
document
.getElementById("toggle-route")
.addEventListener("change", (event) => {
waveRoute.visible = event.target.checked;
});
const cameraState = {
yaw: CUT_CENTER,
polar: 1.16,
distance: 9.4,
target: new THREE.Vector3(0, 0, 0)
};
let cameraTouched = false;
function updateCamera() {
const sinPolar = Math.sin(cameraState.polar);
camera.position.set(
cameraState.target.x -
cameraState.distance * sinPolar * Math.cos(cameraState.yaw),
cameraState.target.y + cameraState.distance * Math.cos(cameraState.polar),
cameraState.target.z +
cameraState.distance * sinPolar * Math.sin(cameraState.yaw)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
const rect = stage.getBoundingClientRect();
const aspect = rect.width / Math.max(rect.height, 1);
cameraState.yaw = CUT_CENTER;
cameraState.polar = 1.16;
cameraState.distance = aspect < 0.9 ? 14 : 9.4;
cameraTouched = false;
updateCamera();
}
document.getElementById("reset-camera").addEventListener("click", resetCamera);
let dragging = false;
let previousPointer = { x: 0, y: 0 };
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointer = { x: event.clientX, y: event.clientY };
cameraTouched = true;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
cameraState.yaw -= dx * 0.006;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + dy * 0.005,
0.42,
2.55
);
previousPointer = { x: event.clientX, y: event.clientY };
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTouched = true;
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance * Math.exp(event.deltaY * 0.001),
5.4,
19
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("keydown", (event) => {
let handled = true;
if (event.key === "ArrowLeft") cameraState.yaw -= 0.08;
else if (event.key === "ArrowRight") cameraState.yaw += 0.08;
else if (event.key === "ArrowUp") {
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar - 0.06,
0.42,
2.55
);
} else if (event.key === "ArrowDown") {
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + 0.06,
0.42,
2.55
);
} else if (event.key === "+" || event.key === "=") {
cameraState.distance = Math.max(5.4, cameraState.distance - 0.5);
} else if (event.key === "-") {
cameraState.distance = Math.min(19, cameraState.distance + 0.5);
} else if (event.key.toLowerCase() === "r") {
resetCamera();
} else {
handled = false;
}
if (handled) {
event.preventDefault();
cameraTouched = true;
updateCamera();
}
});
let selectedWave = "P";
let routeCurve = null;
let routeProgress = 0;
let playing = true;
function disposeWaveRoute() {
for (const child of [...waveRoute.children]) {
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
const materials = Array.isArray(object.material)
? object.material
: [object.material];
for (const material of materials) material.dispose();
}
});
waveRoute.remove(child);
}
pulseMeshes.length = 0;
}
function createWaveRoute(type) {
disposeWaveRoute();
const color = WAVE[type].color;
if (type === "P") {
const direction = radial(CUT_CENTER, 0.64, 1).normalize();
const curve = new THREE.CurvePath();
curve.add(
new THREE.LineCurve3(
direction.clone().multiplyScalar(3.035),
direction.clone().multiplyScalar(-3.035)
)
);
routeCurve = curve;
} else if (type === "S") {
const firstDirection = radial(CUT_CENTER - 0.18, 0.72, 1).normalize();
const secondDirection = radial(CUT_CENTER + 0.25, 1.34, 1).normalize();
const curve = new THREE.CurvePath();
curve.add(
new THREE.LineCurve3(
firstDirection.clone().multiplyScalar(3.035),
firstDirection.clone().multiplyScalar(1.205)
)
);
curve.add(
new THREE.LineCurve3(
firstDirection.clone().multiplyScalar(1.205),
secondDirection.clone().multiplyScalar(1.205)
)
);
curve.add(
new THREE.LineCurve3(
secondDirection.clone().multiplyScalar(1.205),
secondDirection.clone().multiplyScalar(3.035)
)
);
routeCurve = curve;
const bounceMaterial = new THREE.MeshBasicMaterial({
color: 0xff6f67,
transparent: true,
opacity: 0.88,
depthTest: false,
depthWrite: false
});
const bounce = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.025, 6, 24),
bounceMaterial
);
bounce.position.copy(
firstDirection.clone().multiplyScalar(1.205)
);
bounce.renderOrder = 80;
waveRoute.add(bounce);
} else {
const points = [];
const routeRadius = 3.065;
const y = 0.58;
const horizontalRadius = Math.sqrt(
routeRadius * routeRadius - y * y
);
for (let i = 0; i <= 28; i++) {
const phi = CUT_CENTER - 0.56 + (i / 28) * 1.12;
points.push(
new THREE.Vector3(
-horizontalRadius * Math.cos(phi),
y,
horizontalRadius * Math.sin(phi)
)
);
}
routeCurve = new THREE.CatmullRomCurve3(
points,
false,
"centripetal"
);
}
const linePoints = routeCurve.getPoints(180);
const lineMaterial = new THREE.LineDashedMaterial({
color,
dashSize: type === "S" ? 0.1 : 0.15,
gapSize: type === "S" ? 0.055 : 0.075,
transparent: true,
opacity: 0.78,
depthTest: false,
depthWrite: false
});
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(linePoints),
lineMaterial
);
line.computeLineDistances();
line.renderOrder = 60;
waveRoute.add(line);
const pulseGeometry = new THREE.IcosahedronGeometry(0.07, 1);
for (let i = 0; i < 9; i++) {
const pulseMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 1 - i * 0.09,
depthTest: false,
depthWrite: false
});
const pulse = new THREE.Mesh(pulseGeometry, pulseMaterial);
pulse.renderOrder = 70 + i;
pulse.visible = false;
waveRoute.add(pulse);
pulseMeshes.push(pulse);
}
const pulseLight = new THREE.PointLight(color, 1.5, 1.7, 2);
pulseLight.renderOrder = 90;
waveRoute.add(pulseLight);
waveRoute.userData.pulseLight = pulseLight;
}
function setWave(type) {
selectedWave = type;
document.querySelectorAll(".wave-button").forEach((button) => {
const active = button.dataset.wave === type;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
document.getElementById("route-description").textContent =
WAVE[type].description;
for (const config of labelConfigs) {
for (const chip of config.chips) {
chip.classList.toggle("selected", chip.dataset.wave === type);
}
}
routeProgress = 0;
createWaveRoute(type);
}
document.querySelectorAll(".wave-button").forEach((button) => {
button.addEventListener("click", () => {
setWave(button.dataset.wave);
});
});
const progressInput = document.getElementById("progress");
const playPause = document.getElementById("play-pause");
progressInput.addEventListener("input", () => {
routeProgress = Number(progressInput.value) / 1000;
playing = false;
playPause.textContent = "▶";
playPause.setAttribute("aria-label", "Play wave animation");
});
playPause.addEventListener("click", () => {
playing = !playing;
playPause.textContent = playing ? "Ⅱ" : "▶";
playPause.setAttribute(
"aria-label",
playing ? "Pause wave animation" : "Play wave animation"
);
});
document.getElementById("replay").addEventListener("click", () => {
routeProgress = 0;
playing = true;
playPause.textContent = "Ⅱ";
playPause.setAttribute("aria-label", "Pause wave animation");
});
function layerForRadius(radius) {
if (radius >= radii.crustBottom) return "crust";
if (radius >= radii.upperMantleBottom) return "upperMantle";
if (radius >= radii.coreMantleBoundary) return "lowerMantle";
if (radius >= radii.innerCoreBoundary) return "outerCore";
return "innerCore";
}
function updateRoute() {
if (!routeCurve) return;
const point = routeCurve.getPointAt(routeProgress);
const radius = point.length();
for (let i = 0; i < pulseMeshes.length; i++) {
const trailProgress = routeProgress - i * 0.032;
const pulse = pulseMeshes[i];
if (trailProgress < 0) {
pulse.visible = false;
continue;
}
pulse.visible = true;
pulse.position.copy(routeCurve.getPointAt(trailProgress));
const scale = 1 - i * 0.065;
pulse.scale.setScalar(scale);
}
const pulseLight = waveRoute.userData.pulseLight;
if (pulseLight) pulseLight.position.copy(point);
const activeLayer = layerForRadius(radius);
for (const visual of layerVisuals) {
let active = false;
if (selectedWave === "P") {
active = visual.id === activeLayer;
} else if (selectedWave === "S") {
active =
radius >= radii.coreMantleBoundary &&
visual.id === activeLayer;
} else if (selectedWave === "R") {
active = visual.id === "crust";
}
for (const material of visual.materials) {
material.emissive.setHex(
active ? WAVE[selectedWave].color : visual.baseEmissive
);
material.emissiveIntensity = active
? 0.48
: visual.baseIntensity;
}
}
if (selectedWave === "S") {
const outerCore = layerVisuals.find(
(visual) => visual.id === "outerCore"
);
const proximity = Math.max(
0,
1 - Math.abs(radius - radii.coreMantleBoundary) / 0.2
);
for (const material of outerCore.materials) {
material.emissive.setHex(0xff4b3f);
material.emissiveIntensity = 0.13 + proximity * 0.22;
}
}
progressInput.value = String(Math.round(routeProgress * 1000));
progressInput.style.setProperty(
"--range-progress",
`${routeProgress * 100}%`
);
}
function updateLabels() {
const rect = stage.getBoundingClientRect();
const compact = rect.width < 600;
for (const config of labelConfigs) {
const projected = config.anchor.clone().project(camera);
if (projected.z < -1 || projected.z > 1) {
config.element.style.visibility = "hidden";
config.leader.style.visibility = "hidden";
continue;
}
config.element.style.visibility = "visible";
config.leader.style.visibility = "visible";
const anchorX = (projected.x * 0.5 + 0.5) * rect.width;
const anchorY = (-projected.y * 0.5 + 0.5) * rect.height;
const offsetScale = compact ? 0.45 : 1;
let labelX = anchorX + config.offset[0] * offsetScale;
let labelY = anchorY + config.offset[1] * offsetScale;
labelX = THREE.MathUtils.clamp(labelX, 10, rect.width - 145);
labelY = THREE.MathUtils.clamp(labelY, 45, rect.height - 45);
config.element.style.left = `${labelX}px`;
config.element.style.top = `${labelY}px`;
const dx = labelX - anchorX;
const dy = labelY - anchorY;
const distance = Math.hypot(dx, dy);
config.leader.style.left = `${anchorX}px`;
config.leader.style.top = `${anchorY}px`;
config.leader.style.width = `${distance}px`;
config.leader.style.transform = `rotate(${Math.atan2(dy, dx)}rad)`;
}
}
function resize() {
const rect = stage.getBoundingClientRect();
const width = Math.max(1, rect.width);
const height = Math.max(1, rect.height);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
if (!cameraTouched) {
cameraState.distance = camera.aspect < 0.9 ? 14 : 9.4;
}
updateCamera();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
resetCamera();
setWave("P");
let previousTime = performance.now();
function animate(time) {
const delta = THREE.MathUtils.clamp((time - previousTime) / 1000, 0, 0.05);
previousTime = time;
if (playing) {
routeProgress += delta / WAVE[selectedWave].duration;
if (routeProgress >= 1) {
routeProgress %= 1;
}
}
stars.rotation.y += delta * 0.0025;
stars.rotation.x = Math.sin(time * 0.00008) * 0.04;
updateRoute();
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
loading.style.display = "none";
requestAnimationFrame(animate);
</script>
</body>
</html>
```