Prompt specification
Build or customize the Three.js 3D scene "Seismic shadow-zone globe demonstration" 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: Seismic shadow-zone globe demonstration
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/seismic-shadow-zone-globe-demonstration-x1138
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Earth's layered interior. Place a source and simplified ray paths through a layered globe; distinguish refracted paths and shadowed regions with an explicit schematic label rather than numerical seismology. Stylized solid forms.
Working Three.js Starter (seismic-shadow-zone-globe-demonstration-x1138):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Earth Interior — Schematic Ray Paths</title>
<style>
:root {
color-scheme: dark;
--ink: #edf7f7;
--muted: #9db4b8;
--panel: rgba(7, 18, 25, 0.78);
--line: rgba(157, 218, 220, 0.2);
--direct: #ffe19a;
--refracted: #68e5ff;
--shadow: #ff7484;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 52% 44%, #15313a 0%, #091820 42%, #050c12 100%);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.title-block {
position: absolute;
top: 28px;
left: 30px;
width: min(390px, calc(100vw - 60px));
}
.eyebrow {
margin-bottom: 9px;
color: #73d6da;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3.3vw, 45px);
font-weight: 650;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
margin: 12px 0 0;
max-width: 350px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.legend {
position: absolute;
left: 28px;
bottom: 86px;
width: 224px;
padding: 15px 16px;
border: 1px solid var(--line);
border-radius: 13px;
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.legend-title {
margin-bottom: 11px;
color: #cce2e4;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 13px 1fr;
gap: 10px;
align-items: center;
margin-top: 8px;
color: #c8d9db;
font-size: 12px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.swatch.direct {
background: var(--direct);
border-radius: 50%;
box-shadow: 0 0 8px rgba(255, 225, 154, 0.45);
}
.swatch.refracted {
background: var(--refracted);
border-radius: 2px;
box-shadow: 0 0 8px rgba(104, 229, 255, 0.45);
}
.swatch.shadow {
background: rgba(255, 116, 132, 0.6);
border: 1px solid var(--shadow);
}
.schematic-note {
position: absolute;
left: 50%;
bottom: 24px;
width: min(720px, calc(100vw - 48px));
transform: translateX(-50%);
padding: 12px 18px;
border: 1px solid rgba(255, 225, 154, 0.28);
border-radius: 999px;
background: rgba(15, 24, 26, 0.82);
color: #e8e0c5;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.1em;
line-height: 1.45;
text-align: center;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
#reset {
position: absolute;
top: 27px;
right: 28px;
pointer-events: auto;
padding: 10px 14px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--panel);
color: #d8eeee;
font: inherit;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
border-color 150ms ease,
transform 150ms ease;
}
#reset:hover {
border-color: rgba(104, 229, 255, 0.55);
transform: translateY(-1px);
}
.hint {
position: absolute;
right: 29px;
bottom: 29px;
color: rgba(197, 220, 222, 0.58);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scene-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
transform: translate(-50%, -50%);
white-space: nowrap;
color: #dcebec;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.075em;
text-transform: uppercase;
text-shadow: 0 2px 8px #000;
opacity: 0;
transition: opacity 120ms ease;
}
.scene-label::before {
content: "";
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 10px currentColor;
}
.scene-label.direct {
color: var(--direct);
}
.scene-label.refracted {
color: var(--refracted);
}
.scene-label.shadow {
color: var(--shadow);
}
.scene-label.source {
color: #ffffff;
}
.scene-label.core {
padding: 6px 8px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 6px;
background: rgba(5, 13, 18, 0.62);
text-shadow: none;
backdrop-filter: blur(7px);
}
@media (max-width: 720px) {
.title-block {
top: 20px;
left: 20px;
}
.subtitle {
max-width: 260px;
font-size: 11px;
}
.legend {
left: 16px;
bottom: 78px;
width: 186px;
padding: 12px;
}
.legend-row {
font-size: 10px;
}
.hint {
display: none;
}
#reset {
top: 18px;
right: 16px;
}
.schematic-note {
bottom: 16px;
width: calc(100vw - 28px);
border-radius: 12px;
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="ui">
<header class="title-block">
<div class="eyebrow">Interior Atlas / Qualitative Cutaway</div>
<h1>Earth, opened.</h1>
<p class="subtitle">
A stylized solid cross-section showing simplified paths from a point source
through nested interior layers.
</p>
</header>
<section class="legend" aria-label="Scene legend">
<div class="legend-title">Path key</div>
<div class="legend-row">
<span class="swatch direct"></span>
<span>Simple transmitted path</span>
</div>
<div class="legend-row">
<span class="swatch refracted"></span>
<span>Refracted, segmented path</span>
</div>
<div class="legend-row">
<span class="swatch shadow"></span>
<span>Schematic shadow region</span>
</div>
</section>
<button id="reset" type="button">Reset view</button>
<div class="schematic-note">
Schematic only — qualitative bending and shadow placement; not numerical seismology
</div>
<div class="hint">Drag to orbit · Scroll to zoom</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const scene = new THREE.Scene();
const renderer = new THREE.WebGLRenderer({
alpha: true,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
document.body.prepend(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
// Custom camera controls: no addons are used.
const controls = {
azimuth: 0.86,
elevation: 1.17,
distance: 10.3,
targetAzimuth: 0.86,
targetElevation: 1.17,
targetDistance: 10.3,
dragging: false,
pointerX: 0,
pointerY: 0
};
function updateCamera() {
controls.azimuth +=
(controls.targetAzimuth - controls.azimuth) * 0.09;
controls.elevation +=
(controls.targetElevation - controls.elevation) * 0.09;
controls.distance +=
(controls.targetDistance - controls.distance) * 0.09;
const sinElevation = Math.sin(controls.elevation);
camera.position.set(
controls.distance *
sinElevation *
Math.cos(controls.azimuth),
controls.distance * Math.cos(controls.elevation),
controls.distance *
sinElevation *
Math.sin(controls.azimuth)
);
camera.lookAt(0, 0, 0);
camera.updateMatrixWorld();
}
function resetView() {
controls.targetAzimuth = 0.86;
controls.targetElevation = 1.17;
controls.targetDistance = 10.3;
}
document.querySelector("#reset").addEventListener("click", resetView);
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.pointerX;
const dy = event.clientY - controls.pointerY;
controls.targetAzimuth -= dx * 0.006;
controls.targetElevation = THREE.MathUtils.clamp(
controls.targetElevation + dy * 0.005,
0.42,
2.45
);
controls.pointerX = event.clientX;
controls.pointerY = event.clientY;
});
function endDrag(event) {
controls.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();
controls.targetDistance = THREE.MathUtils.clamp(
controls.targetDistance + event.deltaY * 0.008,
6.4,
16
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
// Lighting and materials.
scene.add(new THREE.HemisphereLight(0xbfefff, 0x182126, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff1d5, 3.6);
keyLight.position.set(5, 8, 7);
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5bd8ff, 2.3);
rimLight.position.set(-7, 2, -5);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xff7a50, 9, 12, 2);
warmLight.position.set(0, -2, 3);
scene.add(warmLight);
// A deterministic stylized star field.
let seed = 83621;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
const starPositions = [];
for (let i = 0; i < 720; i++) {
const radius = 18 + random() * 22;
const theta = random() * Math.PI * 2;
const z = random() * 2 - 1;
const planar = Math.sqrt(1 - z * z);
starPositions.push(
radius * planar * Math.cos(theta),
radius * z,
radius * planar * Math.sin(theta)
);
}
const starGeometry = new THREE.BufferGeometry();
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
const stars = new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0xbce8ed,
size: 0.035,
transparent: true,
opacity: 0.55,
sizeAttenuation: true
})
);
scene.add(stars);
const globe = new THREE.Group();
scene.add(globe);
const gapCenter = 0.86;
const gapWidth = 1.15;
const gapHalf = gapWidth * 0.5;
const sectorStart = gapCenter + gapHalf;
const sectorLength = Math.PI * 2 - gapWidth;
function spherical(radius, theta, phi) {
return new THREE.Vector3(
-radius * Math.cos(phi) * Math.sin(theta),
radius * Math.cos(theta),
radius * Math.sin(phi) * Math.sin(theta)
);
}
function createSectorGeometry(
radius,
phiStart = sectorStart,
phiLength = sectorLength,
phiSegments = 96,
thetaSegments = 48
) {
const positions = [];
const indices = [];
for (let j = 0; j <= thetaSegments; j++) {
const theta = (j / thetaSegments) * Math.PI;
for (let i = 0; i <= phiSegments; i++) {
const phi = phiStart + (i / phiSegments) * phiLength;
const p = spherical(radius, theta, phi);
positions.push(p.x, p.y, p.z);
}
}
for (let j = 0; j < thetaSegments; j++) {
for (let i = 0; i < phiSegments; i++) {
const a = j * (phiSegments + 1) + i;
const b = a + 1;
const c = a + phiSegments + 1;
const d = c + 1;
// Outward-facing winding.
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();
return geometry;
}
function createCutFaceGeometry(innerRadius, outerRadius) {
const shape = new THREE.Shape();
if (innerRadius <= 0) {
shape.moveTo(0, -outerRadius);
shape.absarc(
0,
0,
outerRadius,
-Math.PI * 0.5,
Math.PI * 0.5,
false
);
shape.closePath();
} else {
shape.moveTo(0, -outerRadius);
shape.absarc(
0,
0,
outerRadius,
-Math.PI * 0.5,
Math.PI * 0.5,
false
);
shape.lineTo(0, innerRadius);
shape.absarc(
0,
0,
innerRadius,
Math.PI * 0.5,
-Math.PI * 0.5,
true
);
shape.closePath();
}
return new THREE.ShapeGeometry(shape, 64);
}
const cutOrientation = new THREE.Matrix4();
const cutQuaternion = new THREE.Quaternion();
function orientCutFace(mesh, phi) {
const radial = new THREE.Vector3(
-Math.cos(phi),
0,
Math.sin(phi)
);
const up = new THREE.Vector3(0, 1, 0);
const normal = new THREE.Vector3().crossVectors(radial, up);
cutOrientation.makeBasis(radial, up, normal);
cutQuaternion.setFromRotationMatrix(cutOrientation);
mesh.quaternion.copy(cutQuaternion);
}
function addArc(radius, phi, color, opacity = 0.52) {
const points = [];
for (let i = 0; i <= 72; i++) {
const a = -Math.PI * 0.5 + (i / 72) * Math.PI;
const radial = new THREE.Vector3(
-Math.cos(phi),
0,
Math.sin(phi)
);
const up = new THREE.Vector3(0, 1, 0);
const point = radial
.multiplyScalar(radius * Math.cos(a))
.add(up.multiplyScalar(radius * Math.sin(a)));
points.push(point);
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
globe.add(line);
}
function addLayer(name, innerRadius, outerRadius, color, faceColor) {
const surfaceMaterial = new THREE.MeshStandardMaterial({
color,
roughness: 0.8,
metalness: 0.02,
flatShading: true,
side: THREE.DoubleSide
});
const faceMaterial = new THREE.MeshStandardMaterial({
color: faceColor,
roughness: 0.92,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const surface = new THREE.Mesh(
createSectorGeometry(outerRadius),
surfaceMaterial
);
surface.receiveShadow = true;
globe.add(surface);
const faceGeometry = createCutFaceGeometry(innerRadius, outerRadius);
for (const phi of [sectorStart, sectorStart + sectorLength]) {
const face = new THREE.Mesh(faceGeometry, faceMaterial);
orientCutFace(face, phi);
globe.add(face);
addArc(outerRadius, phi, faceColor, 0.5);
if (innerRadius > 0) {
addArc(innerRadius, phi, faceColor, 0.28);
}
}
return { name, innerRadius, outerRadius, color };
}
addLayer("Inner core", 0.0, 0.82, 0xe95758, 0xf47a6c);
addLayer("Outer core", 0.82, 1.55, 0xee9a47, 0xffb35c);
addLayer("Mantle", 1.55, 2.42, 0x318c83, 0x53aa91);
addLayer("Crust", 2.42, 2.65, 0x214c5b, 0x376b77);
// Subtle orbital guide.
const guidePoints = [];
for (let i = 0; i < 180; i++) {
const a = (i / 180) * Math.PI * 2;
guidePoints.push(
new THREE.Vector3(
Math.cos(a) * 3.18,
Math.sin(a) * 0.16,
Math.sin(a) * 3.18
)
);
}
const guide = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(guidePoints),
new THREE.LineBasicMaterial({
color: 0x70aeb4,
transparent: true,
opacity: 0.16
})
);
globe.add(guide);
// Point source.
const source = spherical(2.68, 1.32, 1.57);
const sourceGroup = new THREE.Group();
sourceGroup.position.copy(source);
globe.add(sourceGroup);
const sourceCore = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 2),
new THREE.MeshBasicMaterial({
color: 0xffffff,
depthTest: false
})
);
sourceCore.renderOrder = 20;
sourceGroup.add(sourceCore);
const pulseRings = [];
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.17 + i * 0.045, 0.009, 8, 48),
new THREE.MeshBasicMaterial({
color: 0xbff7ff,
transparent: true,
opacity: 0.55,
depthTest: false
})
);
ring.rotation.set(i * 0.8, i * 0.47, i * 0.3);
ring.renderOrder = 19;
pulseRings.push(ring);
sourceGroup.add(ring);
}
function addCylinderBetween(a, b, radius, material) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 12, 1, false),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.renderOrder = 12;
globe.add(mesh);
return mesh;
}
function addArrow(a, b, color, size = 1) {
const direction = new THREE.Vector3().subVectors(b, a).normalize();
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.07 * size, 0.2 * size, 12),
new THREE.MeshBasicMaterial({
color,
depthTest: false
})
);
arrow.position.copy(a).lerp(b, 0.72);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
arrow.renderOrder = 14;
globe.add(arrow);
}
// Smooth, pale transmitted path.
const directPoints = [
source.clone(),
spherical(2.38, 1.36, 1.42),
spherical(1.58, 1.39, 1.18),
spherical(0.86, 1.40, 0.92),
spherical(1.55, 1.37, 0.65),
spherical(2.68, 1.32, 0.42)
];
const directCurve = new THREE.CatmullRomCurve3(
directPoints,
false,
"catmullrom",
0.16
);
const directMaterial = new THREE.MeshBasicMaterial({
color: 0xffe19a,
depthTest: false
});
const directTube = new THREE.Mesh(
new THREE.TubeGeometry(directCurve, 120, 0.027, 8, false),
directMaterial
);
directTube.renderOrder = 11;
globe.add(directTube);
addArrow(directPoints[1], directPoints[2], 0xffe19a, 0.85);
addArrow(directPoints[3], directPoints[4], 0xffe19a, 0.85);
// Angular cyan path makes refraction visually explicit.
const refractedPoints = [
source.clone(),
spherical(2.35, 1.24, 1.40),
spherical(1.55, 1.05, 1.25),
spherical(0.84, 1.16, 1.05),
spherical(1.60, 1.27, 0.72),
spherical(2.68, 1.21, 0.40)
];
const refractedMaterial = new THREE.MeshBasicMaterial({
color: 0x68e5ff,
depthTest: false
});
for (let i = 0; i < refractedPoints.length - 1; i++) {
addCylinderBetween(
refractedPoints[i],
refractedPoints[i + 1],
0.034,
refractedMaterial
);
}
for (let i = 1; i < refractedPoints.length - 1; i++) {
const joint = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.056, 1),
refractedMaterial
);
joint.position.copy(refractedPoints[i]);
joint.renderOrder = 13;
globe.add(joint);
}
addArrow(refractedPoints[1], refractedPoints[2], 0x68e5ff, 1.05);
addArrow(refractedPoints[3], refractedPoints[4], 0x68e5ff, 1.05);
// Stylized excluded/shadow fan, kept qualitative.
const shadowOuterA = spherical(2.55, 1.72, 1.38);
const shadowInnerA = spherical(0.86, 1.83, 1.22);
const shadowInnerB = spherical(0.86, 2.00, 0.72);
const shadowOuterB = spherical(2.55, 1.93, 0.65);
const shadowTriangles = [
[source, shadowOuterA, shadowInnerA],
[source, shadowInnerA, shadowInnerB],
[source, shadowInnerB, shadowOuterB]
];
const shadowPositions = [];
for (const triangle of shadowTriangles) {
for (const point of triangle) {
shadowPositions.push(point.x, point.y, point.z);
}
}
const shadowGeometry = new THREE.BufferGeometry();
shadowGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(shadowPositions, 3)
);
shadowGeometry.computeVertexNormals();
const shadowMesh = new THREE.Mesh(
shadowGeometry,
new THREE.MeshBasicMaterial({
color: 0xff6177,
transparent: true,
opacity: 0.105,
side: THREE.DoubleSide,
depthWrite: false,
depthTest: false
})
);
shadowMesh.renderOrder = 5;
globe.add(shadowMesh);
const shadowOutlinePoints = [
source,
shadowOuterA,
shadowInnerA,
shadowInnerB,
shadowOuterB,
source
];
const shadowOutline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(shadowOutlinePoints),
new THREE.LineDashedMaterial({
color: 0xff7484,
transparent: true,
opacity: 0.48,
dashSize: 0.1,
gapSize: 0.065,
depthTest: false
})
);
shadowOutline.computeLineDistances();
shadowOutline.renderOrder = 9;
globe.add(shadowOutline);
// Screen-space labels anchored to scene positions.
const labels = [];
function addLabel(text, anchor, offset, className = "") {
const element = document.createElement("div");
element.className = `scene-label ${className}`.trim();
element.textContent = text;
document.querySelector("#ui").appendChild(element);
labels.push({
element,
anchor: anchor.clone(),
offset
});
}
addLabel(
"Crust",
spherical(2.535, 1.00, sectorStart),
{ x: 67, y: -23 },
"core"
);
addLabel(
"Mantle",
spherical(1.985, 1.30, sectorStart),
{ x: 87, y: -5 },
"core"
);
addLabel(
"Outer core",
spherical(1.185, 1.48, sectorStart),
{ x: 91, y: 31 },
"core"
);
addLabel(
"Inner core",
spherical(0.41, 1.58, sectorStart),
{ x: -75, y: 48 },
"core"
);
addLabel(
"Source",
source,
{ x: -8, y: -47 },
"source"
);
addLabel(
"Simple path",
directPoints[2],
{ x: -78, y: -30 },
"direct"
);
addLabel(
"Refracted path",
refractedPoints[2],
{ x: 80, y: -45 },
"refracted"
);
addLabel(
"Schematic shadow region",
spherical(1.18, 1.87, 0.98),
{ x: 68, y: 56 },
"shadow"
);
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
projected.copy(label.anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.25 &&
projected.x < 1.25 &&
projected.y > -1.25 &&
projected.y < 1.25;
label.element.style.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * width + label.offset.x;
const y = (-projected.y * 0.5 + 0.5) * height + label.offset.y;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
updateCamera();
stars.rotation.y = elapsed * 0.004;
stars.rotation.x = Math.sin(elapsed * 0.025) * 0.018;
pulseRings.forEach((ring, index) => {
const phase = (elapsed * 0.7 + index * 0.25) % 1;
const scale = 0.82 + phase * 0.65;
ring.scale.setScalar(scale);
ring.material.opacity = 0.48 * (1 - phase);
});
updateLabels();
renderer.render(scene, camera);
});
updateCamera();
resize();
</script>
</body>
</html>
```