Prompt specification
Build or customize the Three.js 3D scene "Satellite sensor facing a ground swath" 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: Satellite sensor facing a ground swath
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/satellite-sensor-facing-a-ground-swath-x2489
Scene Description Prompt:
A stylized observation satellite over curved Earth, with a field-of-view cone and ground swath. Three.js from cdnjs, one HTML file.
Working Three.js Starter (satellite-sensor-facing-a-ground-swath-x2489):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>EO-07 Observation Satellite</title>
<style>
:root {
color-scheme: dark;
--cyan: #69e7ff;
--mint: #8dffd6;
--text: #e8f6ff;
--muted: #829ba9;
--line: rgba(117, 220, 255, 0.2);
--panel: rgba(5, 17, 28, 0.66);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #020711;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
color: var(--text);
}
.topbar {
position: absolute;
top: 28px;
left: 32px;
right: 32px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
}
.brand-mark {
position: relative;
width: 42px;
height: 42px;
border: 1px solid rgba(105, 231, 255, 0.55);
border-radius: 50%;
box-shadow:
inset 0 0 18px rgba(105, 231, 255, 0.12),
0 0 24px rgba(105, 231, 255, 0.08);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
inset: 8px;
border: 1px solid rgba(105, 231, 255, 0.6);
transform: rotate(45deg);
}
.brand-mark::after {
inset: 16px;
border-radius: 50%;
background: var(--cyan);
border: 0;
box-shadow: 0 0 12px var(--cyan);
}
.eyebrow {
display: block;
margin-bottom: 4px;
color: var(--cyan);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 26px;
font-weight: 550;
letter-spacing: 0.08em;
}
.telemetry {
min-width: 290px;
padding: 15px 17px;
border: 1px solid var(--line);
border-radius: 12px;
background:
linear-gradient(135deg, rgba(28, 78, 97, 0.16), transparent),
var(--panel);
backdrop-filter: blur(14px);
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.2);
}
.status-row {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 12px;
margin-bottom: 12px;
border-bottom: 1px solid var(--line);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.15em;
}
.live {
display: flex;
align-items: center;
gap: 7px;
color: var(--mint);
}
.live::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 10px var(--mint);
animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
50% {
opacity: 0.4;
transform: scale(0.8);
}
}
.telemetry-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
}
.metric span {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.15em;
}
.metric b {
font-size: 12px;
font-weight: 600;
letter-spacing: 0.03em;
white-space: nowrap;
}
.mission-card {
position: absolute;
left: 32px;
bottom: 30px;
width: 292px;
padding: 17px 18px;
border-left: 2px solid var(--mint);
background: linear-gradient(90deg, rgba(5, 19, 29, 0.85), transparent);
}
.mission-card .eyebrow {
color: var(--mint);
}
.mission-card h2 {
margin: 0 0 8px;
font-size: 15px;
font-weight: 550;
letter-spacing: 0.04em;
}
.mission-card p {
margin: 0;
color: #91a8b5;
font-size: 11px;
line-height: 1.55;
}
.legend {
position: absolute;
right: 32px;
bottom: 30px;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 9px;
color: var(--muted);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.13em;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 25px;
height: 2px;
background: var(--cyan);
box-shadow: 0 0 8px rgba(105, 231, 255, 0.7);
}
.swatch.mint {
background: var(--mint);
box-shadow: 0 0 8px rgba(141, 255, 214, 0.7);
}
.controls {
position: absolute;
left: 50%;
bottom: 29px;
transform: translateX(-50%);
color: rgba(174, 205, 220, 0.58);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.13em;
white-space: nowrap;
}
.marker {
position: absolute;
left: 0;
top: 0;
opacity: 0;
transform: translate(-50%, -50%);
transition: opacity 120ms linear;
white-space: nowrap;
}
.marker::before {
content: "";
position: absolute;
top: 50%;
left: -29px;
width: 21px;
height: 1px;
background: currentColor;
opacity: 0.7;
}
.marker::after {
content: "";
position: absolute;
top: 50%;
left: -34px;
width: 5px;
height: 5px;
border: 1px solid currentColor;
transform: translateY(-50%) rotate(45deg);
}
.marker-label {
display: inline-block;
padding: 6px 9px;
border: 1px solid currentColor;
background: rgba(2, 10, 18, 0.72);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.15em;
backdrop-filter: blur(8px);
}
#sat-marker {
color: var(--cyan);
}
#swath-marker {
color: var(--mint);
}
.corner {
position: absolute;
width: 28px;
height: 28px;
opacity: 0.45;
}
.corner.tl {
top: 15px;
left: 15px;
border-top: 1px solid var(--cyan);
border-left: 1px solid var(--cyan);
}
.corner.tr {
top: 15px;
right: 15px;
border-top: 1px solid var(--cyan);
border-right: 1px solid var(--cyan);
}
.corner.bl {
bottom: 15px;
left: 15px;
border-bottom: 1px solid var(--cyan);
border-left: 1px solid var(--cyan);
}
.corner.br {
bottom: 15px;
right: 15px;
border-bottom: 1px solid var(--cyan);
border-right: 1px solid var(--cyan);
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: var(--cyan);
background: #020711;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.25em;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.topbar {
top: 18px;
left: 18px;
right: 18px;
}
.telemetry {
display: none;
}
h1 {
font-size: 21px;
}
.mission-card {
left: 18px;
bottom: 20px;
width: 245px;
}
.legend {
right: 18px;
bottom: 20px;
}
.controls {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D observation satellite scene"></canvas>
<div id="hud">
<span class="corner tl"></span>
<span class="corner tr"></span>
<span class="corner bl"></span>
<span class="corner br"></span>
<div class="topbar">
<div class="brand">
<div class="brand-mark"></div>
<div>
<span class="eyebrow">Earth Observation / Active</span>
<h1>EO-07</h1>
</div>
</div>
<div class="telemetry">
<div class="status-row">
<span>Orbital payload</span>
<span class="live">Live link</span>
</div>
<div class="telemetry-grid">
<div class="metric">
<span>ALTITUDE</span>
<b>784 km</b>
</div>
<div class="metric">
<span>INCLINATION</span>
<b>98.4°</b>
</div>
<div class="metric">
<span>NADIR</span>
<b id="nadir">31.8° N</b>
</div>
</div>
</div>
</div>
<div class="mission-card">
<span class="eyebrow">Mission profile</span>
<h2>Multispectral imaging</h2>
<p>
Wide-area optical observation with an active 24° field of view.
The illuminated footprint is projected directly onto the curved
Earth surface.
</p>
</div>
<div class="legend">
<div class="legend-row">
<span class="swatch"></span>
<span>FIELD-OF-VIEW CONE</span>
</div>
<div class="legend-row">
<span class="swatch mint"></span>
<span>GROUND SWATH</span>
</div>
</div>
<div class="controls">
DRAG TO ORBIT · SCROLL TO ZOOM · SHIFT-DRAG TO PAN · DOUBLE-CLICK TO RESET
</div>
<div class="marker" id="sat-marker">
<span class="marker-label">EO-07 / ACTIVE PAYLOAD</span>
</div>
<div class="marker" id="swath-marker">
<span class="marker-label">GROUND SWATH / 1,920 KM</span>
</div>
</div>
<div id="loading">INITIALIZING ORBITAL PAYLOAD</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: 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();
scene.background = new THREE.Color(0x020711);
scene.fog = new THREE.FogExp2(0x020711, 0.012);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.05,
120
);
camera.position.set(13, 7.5, 15);
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(
new THREE.HemisphereLight(0xb9ddff, 0x07101b, 1.45)
);
const sun = new THREE.DirectionalLight(0xffffff, 3.2);
sun.position.set(7, 9, 11);
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0x2da9ff, 1.4);
rimLight.position.set(-9, 1, -7);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Deterministic random helper
// -------------------------------------------------------------------------
function mulberry32(seed) {
return function () {
let t = (seed += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const random = mulberry32(7417);
// -------------------------------------------------------------------------
// Procedural Earth texture
// -------------------------------------------------------------------------
function makeEarthTexture() {
const width = 2048;
const height = 1024;
const textureCanvas = document.createElement("canvas");
textureCanvas.width = width;
textureCanvas.height = height;
const ctx = textureCanvas.getContext("2d");
const ocean = ctx.createLinearGradient(0, 0, width, height);
ocean.addColorStop(0, "#071d35");
ocean.addColorStop(0.42, "#0a3151");
ocean.addColorStop(0.72, "#082640");
ocean.addColorStop(1, "#06192d");
ctx.fillStyle = ocean;
ctx.fillRect(0, 0, width, height);
// Subtle ocean variation.
for (let i = 0; i < 500; i++) {
const x = random() * width;
const y = random() * height;
const radius = 5 + random() * 35;
ctx.fillStyle = `rgba(74, 174, 204, ${0.008 + random() * 0.018})`;
ctx.beginPath();
ctx.ellipse(x, y, radius, radius * 0.35, random() * Math.PI, 0, Math.PI * 2);
ctx.fill();
}
// Longitude / latitude grid.
ctx.strokeStyle = "rgba(117, 210, 236, 0.075)";
ctx.lineWidth = 1;
for (let lon = -180; lon <= 180; lon += 30) {
const x = ((lon + 180) / 360) * width;
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, height);
ctx.stroke();
}
for (let lat = -60; lat <= 60; lat += 30) {
const y = ((90 - lat) / 180) * height;
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(width, y);
ctx.stroke();
}
const mapX = (lon) => ((lon + 180) / 360) * width;
const mapY = (lat) => ((90 - lat) / 180) * height;
function drawLand(points, fill = "#397f68", stroke = "#75b89c") {
ctx.beginPath();
points.forEach(([lon, lat], index) => {
const x = mapX(lon);
const y = mapY(lat);
if (index === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.closePath();
ctx.fillStyle = fill;
ctx.fill();
ctx.strokeStyle = stroke;
ctx.lineWidth = 2.2;
ctx.stroke();
// Soft inland tint.
ctx.save();
ctx.clip();
ctx.fillStyle = "rgba(150, 190, 125, 0.11)";
ctx.fillRect(0, 0, width, height);
ctx.restore();
}
drawLand([
[-168, 71], [-148, 72], [-128, 62], [-115, 53], [-101, 52],
[-83, 47], [-67, 46], [-54, 35], [-69, 29], [-81, 25],
[-97, 18], [-107, 24], [-117, 32], [-124, 42], [-143, 58]
], "#3e8069", "#85c3a4");
drawLand([
[-82, 12], [-69, 11], [-54, 5], [-42, 1], [-35, -8],
[-42, -22], [-53, -34], [-67, -55], [-75, -42], [-79, -19]
], "#438268", "#83bc9d");
drawLand([
[-73, 60], [-48, 61], [-20, 76], [-42, 83], [-62, 78]
], "#a5b2a2", "#d3dac8");
drawLand([
[-10, 36], [-10, 58], [0, 71], [30, 71], [60, 76],
[100, 78], [145, 70], [179, 60], [160, 48], [142, 42],
[130, 32], [122, 21], [110, 15], [106, 2], [96, 6],
[88, 22], [78, 7], [70, 24], [52, 25], [42, 39],
[28, 42], [15, 36], [3, 43]
], "#4f8064", "#91bd8f");
drawLand([
[-17, 36], [10, 37], [35, 31], [50, 12], [42, -12],
[32, -34], [18, -35], [8, -15], [-8, 5], [-17, 20]
], "#527e5c", "#91b782");
drawLand([
[112, -11], [133, -10], [154, -25], [146, -39],
[127, -43], [113, -30]
], "#9d8052", "#d0af74");
drawLand([
[47, -13], [51, -17], [49, -26], [44, -25]
], "#4c805d", "#8eb680");
drawLand([
[130, 32], [142, 45], [146, 43], [137, 31]
], "#638468", "#9bb993");
drawLand([
[-8, 50], [-3, 59], [1, 51], [-5, 49]
], "#668267", "#a4b995");
drawLand([
[-180, -65], [-150, -72], [-120, -68], [-90, -75],
[-60, -68], [-30, -73], [0, -69], [30, -72], [60, -66],
[90, -70], [120, -67], [150, -73], [180, -65],
[180, -90], [-180, -90]
], "#8fa6a4", "#c5d2cb");
// Coastal highlights.
ctx.fillStyle = "rgba(174, 226, 219, 0.16)";
for (let i = 0; i < 180; i++) {
const x = random() * width;
const y = random() * height;
ctx.beginPath();
ctx.arc(x, y, 1 + random() * 2, 0, Math.PI * 2);
ctx.fill();
}
const texture = new THREE.CanvasTexture(textureCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
// -------------------------------------------------------------------------
// Procedural cloud texture
// -------------------------------------------------------------------------
function makeCloudTexture() {
const width = 1024;
const height = 512;
const c = document.createElement("canvas");
c.width = width;
c.height = height;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, width, height);
for (let i = 0; i < 145; i++) {
const x = random() * width;
const y = random() * height;
const radius = 12 + random() * 45;
ctx.save();
ctx.translate(x, y);
ctx.scale(1.8 + random(), 0.45 + random() * 0.65);
const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, radius);
gradient.addColorStop(0, "rgba(255,255,255,0.48)");
gradient.addColorStop(0.45, "rgba(239,250,255,0.20)");
gradient.addColorStop(1, "rgba(255,255,255,0)");
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(0, 0, radius, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
// -------------------------------------------------------------------------
// Earth
// -------------------------------------------------------------------------
const EARTH_RADIUS = 3.2;
const earthTexture = makeEarthTexture();
const earthMaterial = new THREE.MeshStandardMaterial({
map: earthTexture,
roughness: 0.86,
metalness: 0.04,
emissive: 0x031421,
emissiveIntensity: 0.32
});
const earth = new THREE.Mesh(
new THREE.SphereGeometry(EARTH_RADIUS, 96, 64),
earthMaterial
);
earth.rotation.y = -0.18;
scene.add(earth);
const clouds = new THREE.Mesh(
new THREE.SphereGeometry(EARTH_RADIUS + 0.045, 72, 48),
new THREE.MeshPhongMaterial({
map: makeCloudTexture(),
transparent: true,
opacity: 0.42,
depthWrite: false,
shininess: 8
})
);
clouds.rotation.y = -0.18;
scene.add(clouds);
const earthGrid = new THREE.Mesh(
new THREE.SphereGeometry(EARTH_RADIUS + 0.008, 30, 18),
new THREE.MeshBasicMaterial({
color: 0x71dfff,
wireframe: true,
transparent: true,
opacity: 0.025,
depthWrite: false
})
);
earthGrid.rotation.y = -0.18;
scene.add(earthGrid);
const atmosphere = new THREE.Mesh(
new THREE.SphereGeometry(EARTH_RADIUS + 0.13, 96, 64),
new THREE.ShaderMaterial({
uniforms: {
glowColor: { value: new THREE.Color(0x2c9eff) }
},
vertexShader: `
varying vec3 vWorldNormal;
varying vec3 vWorldPosition;
void main() {
vWorldNormal = normalize(mat3(modelMatrix) * normal);
vec4 worldPosition = modelMatrix * vec4(position, 1.0);
vWorldPosition = worldPosition.xyz;
gl_Position = projectionMatrix * viewMatrix * worldPosition;
}
`,
fragmentShader: `
uniform vec3 glowColor;
varying vec3 vWorldNormal;
varying vec3 vWorldPosition;
void main() {
vec3 viewDirection = normalize(cameraPosition - vWorldPosition);
float fresnel = pow(
1.0 - max(dot(vWorldNormal, viewDirection), 0.0),
3.0
);
float alpha = smoothstep(0.0, 1.0, fresnel) * 0.72;
gl_FragColor = vec4(glowColor, alpha);
}
`,
transparent: true,
depthWrite: false,
blending: THREE.AdditiveBlending,
side: THREE.FrontSide
})
);
scene.add(atmosphere);
// -------------------------------------------------------------------------
// Stars
// -------------------------------------------------------------------------
const starCount = 1400;
const starPositions = new Float32Array(starCount * 3);
for (let i = 0; i < starCount; i++) {
const radius = 38 + random() * 35;
const theta = random() * Math.PI * 2;
const phi = Math.acos(2 * random() - 1);
starPositions[i * 3] = radius * Math.sin(phi) * Math.cos(theta);
starPositions[i * 3 + 1] = radius * Math.cos(phi);
starPositions[i * 3 + 2] = radius * Math.sin(phi) * Math.sin(theta);
}
const starGeometry = new THREE.BufferGeometry();
starGeometry.setAttribute(
"position",
new THREE.BufferAttribute(starPositions, 3)
);
const stars = new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0xb8dcff,
size: 0.075,
transparent: true,
opacity: 0.72,
depthWrite: false,
sizeAttenuation: true
})
);
scene.add(stars);
// -------------------------------------------------------------------------
// Satellite materials and textures
// -------------------------------------------------------------------------
function makeFoilTexture() {
const c = document.createElement("canvas");
c.width = 512;
c.height = 512;
const ctx = c.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 512, 512);
gradient.addColorStop(0, "#d59a2e");
gradient.addColorStop(0.3, "#f3cc66");
gradient.addColorStop(0.58, "#9a641e");
gradient.addColorStop(1, "#e0ae3f");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 512, 512);
for (let i = 0; i < 90; i++) {
const x = random() * 512;
const y = random() * 512;
const size = 18 + random() * 80;
ctx.fillStyle = random() > 0.5
? `rgba(255,238,162,${0.04 + random() * 0.13})`
: `rgba(78,40,9,${0.04 + random() * 0.14})`;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + size, y + random() * size * 0.4);
ctx.lineTo(x + random() * size, y + size);
ctx.closePath();
ctx.fill();
ctx.strokeStyle = "rgba(255,245,192,0.14)";
ctx.stroke();
}
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function makeSolarTexture() {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 512;
const ctx = c.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 0, 512);
gradient.addColorStop(0, "#102b59");
gradient.addColorStop(1, "#06162f");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1024, 512);
const columns = 8;
const rows = 4;
const cellWidth = 1024 / columns;
const cellHeight = 512 / rows;
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const x = column * cellWidth;
const y = row * cellHeight;
ctx.fillStyle = (row + column) % 3 === 0
? "#173c72"
: "#102f61";
ctx.fillRect(
x + 4,
y + 4,
cellWidth - 8,
cellHeight - 8
);
ctx.strokeStyle = "rgba(93,168,255,0.38)";
ctx.lineWidth = 2;
ctx.strokeRect(x + 4, y + 4, cellWidth - 8, cellHeight - 8);
ctx.strokeStyle = "rgba(111,186,255,0.15)";
ctx.lineWidth = 1;
for (let k = 1; k < 5; k++) {
ctx.beginPath();
ctx.moveTo(x + (cellWidth / 5) * k, y + 5);
ctx.lineTo(x + (cellWidth / 5) * k, y + cellHeight - 5);
ctx.stroke();
}
}
}
ctx.strokeStyle = "#b4c4ca";
ctx.lineWidth = 9;
ctx.strokeRect(4, 4, 1016, 504);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const foilMaterial = new THREE.MeshStandardMaterial({
map: makeFoilTexture(),
metalness: 0.62,
roughness: 0.34
});
const silverMaterial = new THREE.MeshStandardMaterial({
color: 0xb9c7d0,
metalness: 0.72,
roughness: 0.28
});
const darkMetalMaterial = new THREE.MeshStandardMaterial({
color: 0x17212b,
metalness: 0.75,
roughness: 0.32
});
const solarMaterial = new THREE.MeshStandardMaterial({
map: makeSolarTexture(),
metalness: 0.42,
roughness: 0.28,
emissive: 0x06172d,
emissiveIntensity: 0.5
});
const lensMaterial = new THREE.MeshPhysicalMaterial({
color: 0x0c4166,
emissive: 0x0b78aa,
emissiveIntensity: 0.7,
metalness: 0.25,
roughness: 0.08,
transmission: 0.15,
clearcoat: 1
});
// -------------------------------------------------------------------------
// Satellite model
// -------------------------------------------------------------------------
const SATELLITE_DISTANCE = 8.8;
const LENS_Y = -0.96;
const FOV_HALF_ANGLE = THREE.MathUtils.degToRad(12);
const APEX_DISTANCE = SATELLITE_DISTANCE + LENS_Y;
const CONE_LENGTH = APEX_DISTANCE - EARTH_RADIUS * 0.76;
const CONE_RADIUS = CONE_LENGTH * Math.tan(FOV_HALF_ANGLE);
const satellite = new THREE.Group();
scene.add(satellite);
const bus = new THREE.Mesh(
new THREE.BoxGeometry(1.22, 1.18, 0.98),
foilMaterial
);
satellite.add(bus);
const busEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(bus.geometry),
new THREE.LineBasicMaterial({
color: 0xffd978,
transparent: true,
opacity: 0.55
})
);
satellite.add(busEdges);
const upperCap = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.52, 0.18, 32),
silverMaterial
);
upperCap.position.y = 0.66;
satellite.add(upperCap);
const sensorHousing = new THREE.Mesh(
new THREE.CylinderGeometry(0.28, 0.34, 0.29, 32),
darkMetalMaterial
);
sensorHousing.position.y = -0.72;
satellite.add(sensorHousing);
const lens = new THREE.Mesh(
new THREE.CylinderGeometry(0.235, 0.255, 0.10, 32),
lensMaterial
);
lens.position.y = -0.91;
satellite.add(lens);
const lensRing = new THREE.Mesh(
new THREE.TorusGeometry(0.255, 0.035, 12, 40),
silverMaterial
);
lensRing.rotation.x = Math.PI / 2;
lensRing.position.y = -0.965;
satellite.add(lensRing);
const sideModule = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.56, 0.22),
darkMetalMaterial
);
sideModule.position.set(0, 0.02, 0.59);
satellite.add(sideModule);
// Solar-panel booms.
for (const side of [-1, 1]) {
const boom = new THREE.Mesh(
new THREE.BoxGeometry(0.72, 0.075, 0.12),
silverMaterial
);
boom.position.x = side * 0.95;
satellite.add(boom);
const panel = new THREE.Mesh(
new THREE.BoxGeometry(2.82, 0.065, 1.38),
solarMaterial
);
panel.position.x = side * 2.24;
satellite.add(panel);
const panelEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(panel.geometry),
new THREE.LineBasicMaterial({
color: 0x8ebbd4,
transparent: true,
opacity: 0.62
})
);
panelEdges.position.copy(panel.position);
satellite.add(panelEdges);
}
// Small high-gain antenna.
const dishGroup = new THREE.Group();
dishGroup.position.set(0, 0.73, 0.16);
const dishProfile = [
new THREE.Vector2(0.025, 0),
new THREE.Vector2(0.09, 0.025),
new THREE.Vector2(0.19, 0.08),
new THREE.Vector2(0.31, 0.18),
new THREE.Vector2(0.42, 0.30)
];
const dish = new THREE.Mesh(
new THREE.LatheGeometry(dishProfile, 40),
new THREE.MeshStandardMaterial({
color: 0xd8e0df,
metalness: 0.58,
roughness: 0.3,
side: THREE.DoubleSide
})
);
dishGroup.add(dish);
const dishRim = new THREE.Mesh(
new THREE.TorusGeometry(0.42, 0.025, 10, 40),
silverMaterial
);
dishRim.rotation.x = Math.PI / 2;
dishRim.position.y = 0.30;
dishGroup.add(dishRim);
const feedRod = new THREE.Mesh(
new THREE.CylinderGeometry(0.012, 0.012, 0.42, 8),
silverMaterial
);
feedRod.position.y = 0.48;
dishGroup.add(feedRod);
const feed = new THREE.Mesh(
new THREE.SphereGeometry(0.045, 12, 8),
darkMetalMaterial
);
feed.position.y = 0.70;
dishGroup.add(feed);
satellite.add(dishGroup);
// -------------------------------------------------------------------------
// Field-of-view cone, attached to the satellite's local -Y axis
// -------------------------------------------------------------------------
const coneMaterial = new THREE.MeshBasicMaterial({
color: 0x43dcff,
transparent: true,
opacity: 0.075,
side: THREE.DoubleSide,
depthWrite: false,
blending: THREE.AdditiveBlending
});
const fovCone = new THREE.Mesh(
new THREE.ConeGeometry(
CONE_RADIUS,
CONE_LENGTH,
48,
1,
true
),
coneMaterial
);
fovCone.position.y = LENS_Y - CONE_LENGTH / 2;
satellite.add(fovCone);
const coneWirePositions = [];
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
coneWirePositions.push(
0, LENS_Y, 0,
Math.cos(angle) * CONE_RADIUS,
LENS_Y - CONE_LENGTH,
Math.sin(angle) * CONE_RADIUS
);
}
const coneWireGeometry = new THREE.BufferGeometry();
coneWireGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(coneWirePositions, 3)
);
const coneWire = new THREE.LineSegments(
coneWireGeometry,
new THREE.LineBasicMaterial({
color: 0x70e7ff,
transparent: true,
opacity: 0.32,
depthWrite: false
})
);
satellite.add(coneWire);
const baseRingPoints = [];
for (let i = 0; i <= 64; i++) {
const angle = (i / 64) * Math.PI * 2;
baseRingPoints.push(
new THREE.Vector3(
Math.cos(angle) * CONE_RADIUS,
LENS_Y - CONE_LENGTH,
Math.sin(angle) * CONE_RADIUS
)
);
}
const baseRing = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(baseRingPoints),
new THREE.LineBasicMaterial({
color: 0x6ce8ff,
transparent: true,
opacity: 0.38
})
);
satellite.add(baseRing);
// -------------------------------------------------------------------------
// Orbit path
// -------------------------------------------------------------------------
const orbitBasisA = new THREE.Vector3(1, 0, 0);
const orbitBasisB = new THREE.Vector3(0, 0.8, 0.6).normalize();
function orbitNormal(u) {
return orbitBasisA
.clone()
.multiplyScalar(Math.cos(u))
.add(orbitBasisB.clone().multiplyScalar(Math.sin(u)))
.normalize();
}
const orbitPoints = [];
for (let i = 0; i <= 256; i++) {
const u = (i / 256) * Math.PI * 2;
orbitPoints.push(orbitNormal(u).multiplyScalar(SATELLITE_DISTANCE));
}
const orbitLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(orbitPoints),
new THREE.LineDashedMaterial({
color: 0x66c9e9,
transparent: true,
opacity: 0.28,
dashSize: 0.12,
gapSize: 0.13,
depthWrite: false
})
);
orbitLine.computeLineDistances();
scene.add(orbitLine);
// -------------------------------------------------------------------------
// Spherical ground-swath geometry
// -------------------------------------------------------------------------
const SWATH_SEGMENTS = 96;
const swathPositions = new Float32Array((SWATH_SEGMENTS + 2) * 3);
const swathIndices = [];
for (let i = 0; i < SWATH_SEGMENTS; i++) {
swathIndices.push(0, i + 1, i + 2);
}
const swathGeometry = new THREE.BufferGeometry();
swathGeometry.setAttribute(
"position",
new THREE.BufferAttribute(swathPositions, 3)
);
swathGeometry.setIndex(swathIndices);
const swath = new THREE.Mesh(
swathGeometry,
new THREE.MeshBasicMaterial({
color: 0x72ffd0,
transparent: true,
opacity: 0.23,
side: THREE.DoubleSide,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
swath.frustumCulled = false;
scene.add(swath);
const borderPositions = new Float32Array((SWATH_SEGMENTS + 1) * 3);
const borderGeometry = new THREE.BufferGeometry();
borderGeometry.setAttribute(
"position",
new THREE.BufferAttribute(borderPositions, 3)
);
const swathBorder = new THREE.Line(
borderGeometry,
new THREE.LineBasicMaterial({
color: 0xa2ffdd,
transparent: true,
opacity: 0.82,
depthWrite: false
})
);
swathBorder.frustumCulled = false;
scene.add(swathBorder);
// Several projected scan chords on the spherical footprint.
const SCAN_LINES = 7;
const scanPositions = new Float32Array(SCAN_LINES * 2 * 3);
const scanGeometry = new THREE.BufferGeometry();
scanGeometry.setAttribute(
"position",
new THREE.BufferAttribute(scanPositions, 3)
);
const scanLines = new THREE.LineSegments(
scanGeometry,
new THREE.LineBasicMaterial({
color: 0xc6ffe9,
transparent: true,
opacity: 0.25,
depthWrite: false
})
);
scanLines.frustumCulled = false;
scene.add(scanLines);
const movingScanPositions = new Float32Array(6);
const movingScanGeometry = new THREE.BufferGeometry();
movingScanGeometry.setAttribute(
"position",
new THREE.BufferAttribute(movingScanPositions, 3)
);
const movingScan = new THREE.Line(
movingScanGeometry,
new THREE.LineBasicMaterial({
color: 0xe0fff3,
transparent: true,
opacity: 0.9,
depthWrite: false
})
);
movingScan.frustumCulled = false;
scene.add(movingScan);
let currentSwathCenter = new THREE.Vector3();
let currentSwathNormal = new THREE.Vector3(0, 1, 0);
let currentSwathU = new THREE.Vector3();
let currentSwathV = new THREE.Vector3();
let currentSwathC = 0.95;
let currentSwathS = 0.31;
function updateSwath(normal) {
const k = Math.tan(FOV_HALF_ANGLE) ** 2;
// Intersection of the observation cone with the spherical Earth.
const discriminant =
(k + 1) * EARTH_RADIUS * EARTH_RADIUS -
k * APEX_DISTANCE * APEX_DISTANCE;
const c =
(
k * APEX_DISTANCE * EARTH_RADIUS +
EARTH_RADIUS * Math.sqrt(Math.max(0, discriminant))
) /
((k + 1) * EARTH_RADIUS * EARTH_RADIUS);
const s = Math.sqrt(Math.max(0, 1 - c * c));
const helper =
Math.abs(normal.y) < 0.9
? new THREE.Vector3(0, 1, 0)
: new THREE.Vector3(1, 0, 0);
const u = new THREE.Vector3()
.crossVectors(normal, helper)
.normalize();
const v = new THREE.Vector3()
.crossVectors(normal, u)
.normalize();
currentSwathNormal.copy(normal);
currentSwathU.copy(u);
currentSwathV.copy(v);
currentSwathC = c;
currentSwathS = s;
const surfaceRadius = EARTH_RADIUS + 0.032;
const center = normal.clone().multiplyScalar(surfaceRadius);
currentSwathCenter.copy(center);
swathPositions[0] = center.x;
swathPositions[1] = center.y;
swathPositions[2] = center.z;
for (let i = 0; i <= SWATH_SEGMENTS; i++) {
const angle = (i / SWATH_SEGMENTS) * Math.PI * 2;
const tangentOffset = u
.clone()
.multiplyScalar(Math.cos(angle) * s)
.add(v.clone().multiplyScalar(Math.sin(angle) * s));
const point = normal
.clone()
.multiplyScalar(c)
.add(tangentOffset)
.multiplyScalar(surfaceRadius);
const pointIndex = (i + 1) * 3;
swathPositions[pointIndex] = point.x;
swathPositions[pointIndex + 1] = point.y;
swathPositions[pointIndex + 2] = point.z;
if (i < SWATH_SEGMENTS) {
const borderIndex = i * 3;
borderPositions[borderIndex] = point.x;
borderPositions[borderIndex + 1] = point.y;
borderPositions[borderIndex + 2] = point.z;
}
}
swathGeometry.attributes.position.needsUpdate = true;
borderGeometry.attributes.position.needsUpdate = true;
// Projected scan chords.
for (let i = 0; i < SCAN_LINES; i++) {
const x = THREE.MathUtils.lerp(-0.78 * s, 0.78 * s, i / (SCAN_LINES - 1));
const y = Math.sqrt(Math.max(0, s * s - x * x));
const p1 = normal
.clone()
.multiplyScalar(c)
.add(u.clone().multiplyScalar(x))
.add(v.clone().multiplyScalar(y))
.multiplyScalar(EARTH_RADIUS + 0.042);
const p2 = normal
.clone()
.multiplyScalar(c)
.add(u.clone().multiplyScalar(x))
.add(v.clone().multiplyScalar(-y))
.multiplyScalar(EARTH_RADIUS + 0.042);
const index = i * 6;
scanPositions[index] = p1.x;
scanPositions[index + 1] = p1.y;
scanPositions[index + 2] = p1.z;
scanPositions[index + 3] = p2.x;
scanPositions[index + 4] = p2.y;
scanPositions[index + 5] = p2.z;
}
scanGeometry.attributes.position.needsUpdate = true;
}
function updateMovingScan(time) {
const x = Math.sin(time * 0.72) * currentSwathS * 0.76;
const y = Math.sqrt(
Math.max(0, currentSwathS * currentSwathS - x * x)
);
const p1 = currentSwathNormal
.clone()
.multiplyScalar(currentSwathC)
.add(currentSwathU.clone().multiplyScalar(x))
.add(currentSwathV.clone().multiplyScalar(y))
.multiplyScalar(EARTH_RADIUS + 0.05);
const p2 = currentSwathNormal
.clone()
.multiplyScalar(currentSwathC)
.add(currentSwathU.clone().multiplyScalar(x))
.add(currentSwathV.clone().multiplyScalar(-y))
.multiplyScalar(EARTH_RADIUS + 0.05);
movingScanPositions.set([
p1.x, p1.y, p1.z,
p2.x, p2.y, p2.z
]);
movingScanGeometry.attributes.position.needsUpdate = true;
movingScan.material.opacity = 0.6 + Math.sin(time * 4) * 0.25;
}
// -------------------------------------------------------------------------
// Custom camera controls: orbit, zoom, pan, pinch
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(1.3, 0.15, 0),
theta: 0,
phi: 0,
radius: 0,
pointers: new Map(),
mode: "orbit",
lastX: 0,
lastY: 0,
pinchDistance: 0
};
const initialTarget = controls.target.clone();
const initialSpherical = new THREE.Spherical().setFromVector3(
camera.position.clone().sub(controls.target)
);
controls.theta = initialSpherical.theta;
controls.phi = initialSpherical.phi;
controls.radius = initialSpherical.radius;
function updateCamera() {
controls.phi = THREE.MathUtils.clamp(
controls.phi,
0.08,
Math.PI - 0.08
);
controls.radius = THREE.MathUtils.clamp(
controls.radius,
7.5,
30
);
const offset = new THREE.Vector3().setFromSpherical(
new THREE.Spherical(
controls.radius,
controls.phi,
controls.theta
)
);
camera.position.copy(controls.target).add(offset);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.target.copy(initialTarget);
controls.theta = initialSpherical.theta;
controls.phi = initialSpherical.phi;
controls.radius = initialSpherical.radius;
updateCamera();
}
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
controls.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (controls.pointers.size === 1) {
controls.mode =
event.shiftKey || event.button === 2 ? "pan" : "orbit";
controls.lastX = event.clientX;
controls.lastY = event.clientY;
} else if (controls.pointers.size === 2) {
controls.mode = "pinch";
const [a, b] = [...controls.pointers.values()];
controls.pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.pointers.has(event.pointerId)) return;
const old = controls.pointers.get(event.pointerId);
controls.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (controls.pointers.size === 1 && controls.mode === "orbit") {
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.theta -= dx * 0.005;
controls.phi -= dy * 0.005;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
}
if (controls.pointers.size === 1 && controls.mode === "pan") {
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
const right = new THREE.Vector3()
.crossVectors(forward, camera.up)
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, forward)
.normalize();
const panScale = controls.radius * 0.0015;
controls.target
.addScaledVector(right, -dx * panScale)
.addScaledVector(up, dy * panScale);
controls.lastX = event.clientX;
controls.lastY = event.clientY;
}
if (controls.pointers.size === 2) {
const [a, b] = [...controls.pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (controls.pinchDistance > 0) {
controls.radius *=
controls.pinchDistance / Math.max(1, distance);
}
controls.pinchDistance = distance;
}
});
function endPointer(event) {
controls.pointers.delete(event.pointerId);
if (controls.pointers.size === 1) {
const remaining = [...controls.pointers.values()][0];
controls.mode = "orbit";
controls.lastX = remaining.x;
controls.lastY = remaining.y;
} else {
controls.mode = "orbit";
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius *= Math.exp(event.deltaY * 0.001);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
});
// -------------------------------------------------------------------------
// Screen-space labels
// -------------------------------------------------------------------------
const satelliteMarker = document.querySelector("#sat-marker");
const swathMarker = document.querySelector("#swath-marker");
const nadirElement = document.querySelector("#nadir");
function placeMarker(element, worldPosition, visible = true) {
const projected = worldPosition.clone().project(camera);
const onScreen =
visible &&
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.08 &&
Math.abs(projected.y) < 1.08;
element.style.opacity = onScreen ? "1" : "0";
if (!onScreen) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function updateNadir(normal) {
const latitude = THREE.MathUtils.radToDeg(
Math.asin(THREE.MathUtils.clamp(normal.y, -1, 1))
);
const longitude = THREE.MathUtils.radToDeg(
Math.atan2(normal.z, normal.x)
);
const latText = `${Math.abs(latitude).toFixed(1)}° ${
latitude >= 0 ? "N" : "S"
}`;
const lonText = `${Math.abs(longitude).toFixed(1)}° ${
longitude >= 0 ? "E" : "W"
}`;
nadirElement.textContent = `${latText} / ${lonText}`;
}
// -------------------------------------------------------------------------
// Resize
// -------------------------------------------------------------------------
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", onResize);
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
const yAxis = new THREE.Vector3(0, 1, 0);
const baseQuaternion = new THREE.Quaternion();
const rollQuaternion = new THREE.Quaternion();
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const orbitAngle = 0.72 + elapsed * 0.045;
const normal = orbitNormal(orbitAngle);
satellite.position.copy(normal).multiplyScalar(SATELLITE_DISTANCE);
baseQuaternion.setFromUnitVectors(yAxis, normal);
rollQuaternion.setFromAxisAngle(yAxis, elapsed * 0.10);
satellite.quaternion.copy(baseQuaternion).multiply(rollQuaternion);
updateSwath(normal);
updateMovingScan(elapsed);
updateNadir(normal);
clouds.rotation.y = -0.18 + elapsed * 0.008;
stars.rotation.y = elapsed * 0.0015;
updateCamera();
camera.updateMatrixWorld();
const cameraToEarth = camera.position.clone().normalize();
const swathVisible = cameraToEarth.dot(currentSwathNormal) > 0.08;
placeMarker(
satelliteMarker,
satellite.position.clone().addScaledVector(normal, 0.85)
);
placeMarker(
swathMarker,
currentSwathCenter.clone().addScaledVector(currentSwathNormal, 0.16),
swathVisible
);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
document.querySelector("#loading").classList.add("hidden");
}
}
updateCamera();
animate();
</script>
</body>
</html>
```