Prompt specification
Build or customize the Three.js 3D scene "Apollo lunar module footpad on regolith" 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: Apollo lunar module footpad on regolith
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/apollo-lunar-module-footpad-on-regolith-x2401
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts the Apollo 11 lunar landing in 1969. Model one referenced lunar module landing leg and footpad resting on a small regolith tile. Show joints and contact geometry without recreating an entire spacecraft. Stylized solid forms.
Working Three.js Starter (apollo-lunar-module-footpad-on-regolith-x2401):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apollo 11 — Lunar Landing Gear</title>
<style>
:root {
--white: #f1eee6;
--muted: #aaa79f;
--accent: #d5b66e;
--line: rgba(255, 255, 255, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #020409;
color: var(--white);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
cursor: grab;
touch-action: none;
}
canvas.dragging {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 45%, transparent 35%, rgba(0, 0, 0, 0.48) 100%),
linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 28%);
}
.title-card {
position: fixed;
top: 30px;
left: 34px;
z-index: 3;
pointer-events: none;
max-width: 360px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
color: var(--accent);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.23em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 30px;
height: 1px;
background: var(--accent);
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 56px);
font-weight: 450;
line-height: 0.98;
letter-spacing: -0.045em;
text-transform: uppercase;
}
.subtitle {
margin: 13px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.spec-card {
position: fixed;
top: 32px;
right: 32px;
z-index: 3;
width: 208px;
padding: 16px 17px;
border: 1px solid var(--line);
background: rgba(5, 8, 12, 0.52);
backdrop-filter: blur(10px);
pointer-events: none;
}
.spec-card strong {
display: block;
margin-bottom: 10px;
color: var(--accent);
font-size: 10px;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.spec-card p {
margin: 0;
color: #c2bfb6;
font-size: 11px;
line-height: 1.65;
}
.spec-row {
display: flex;
justify-content: space-between;
gap: 16px;
padding-top: 7px;
margin-top: 7px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
color: #dedbd2;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.spec-row span:first-child {
color: #777b82;
}
#annotations {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.annotation {
position: absolute;
display: flex;
align-items: center;
gap: 8px;
opacity: 0;
transition: opacity 180ms ease;
white-space: nowrap;
transform: translate(14px, -50%);
}
.annotation.visible {
opacity: 1;
}
.annotation::before {
content: "";
width: 22px;
height: 1px;
background: rgba(232, 229, 217, 0.58);
}
.annotation b {
display: grid;
place-items: center;
width: 21px;
height: 21px;
border: 1px solid rgba(232, 229, 217, 0.45);
border-radius: 50%;
color: var(--accent);
font-size: 9px;
font-weight: 650;
}
.annotation span {
padding: 5px 7px;
background: rgba(2, 4, 9, 0.62);
color: #ddd9ce;
font-size: 9px;
font-weight: 650;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.footer {
position: fixed;
right: 32px;
bottom: 28px;
left: 34px;
z-index: 4;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 20px;
pointer-events: none;
}
.hint {
color: #85878a;
font-size: 10px;
font-weight: 600;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.hint span {
color: #d1cdc2;
}
#reset {
padding: 9px 12px;
border: 1px solid var(--line);
background: rgba(5, 8, 12, 0.58);
color: #d6d2c8;
font: inherit;
font-size: 9px;
font-weight: 650;
letter-spacing: 0.14em;
text-transform: uppercase;
cursor: pointer;
pointer-events: auto;
}
#reset:hover {
border-color: var(--accent);
color: var(--accent);
}
@media (max-width: 720px) {
.title-card {
top: 20px;
left: 20px;
}
.spec-card {
top: auto;
right: 20px;
bottom: 70px;
width: 175px;
}
.spec-row {
display: none;
}
.footer {
right: 20px;
bottom: 18px;
left: 20px;
}
.annotation {
display: none;
}
}
</style>
</head>
<body>
<div class="vignette"></div>
<header class="title-card">
<div class="eyebrow">Apollo 11 · 1969</div>
<h1>Lunar landing gear</h1>
<p class="subtitle">
LM “Eagle” / Tranquility Base<br>
One landing-leg study, 20 July 1969
</p>
</header>
<aside class="spec-card">
<strong>Reference detail</strong>
<p>
Stylized solid-form reconstruction of the Apollo lunar module landing gear,
including the articulated primary strut, deployment truss, dished footpad,
contact probe, and compressed regolith.
</p>
<div class="spec-row">
<span>Assembly</span>
<span>LM-5</span>
</div>
<div class="spec-row">
<span>Surface</span>
<span>Regolith</span>
</div>
<div class="spec-row">
<span>Study</span>
<span>Single leg</span>
</div>
</aside>
<div id="annotations" aria-hidden="true">
<div class="annotation" id="label-truss">
<b>01</b><span>Deployment truss</span>
</div>
<div class="annotation" id="label-strut">
<b>02</b><span>Primary strut</span>
</div>
<div class="annotation" id="label-pad">
<b>03</b><span>Dished footpad</span>
</div>
<div class="annotation" id="label-contact">
<b>04</b><span>Regolith contact</span>
</div>
</div>
<footer class="footer">
<div class="hint">
<span>Drag</span> to orbit · <span>Scroll</span> to zoom
</div>
<button id="reset" type="button">Reset view</button>
</footer>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, and camera
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x020409);
scene.fog = new THREE.Fog(0x020409, 15, 39);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.05,
100
);
const controls = {
target: new THREE.Vector3(-0.08, 1.43, 0),
radius: 6.3,
theta: 0.63,
phi: 1.19,
dragging: false,
lastX: 0,
lastY: 0
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x +
controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z +
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xb8cbe0,
0x29241e,
1.7
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4df, 4.1);
keyLight.position.set(-4.5, 8.0, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 20;
keyLight.shadow.bias = -0.00025;
keyLight.shadow.normalBias = 0.025;
keyLight.target.position.set(0, 1.1, 0);
scene.add(keyLight, keyLight.target);
const rimLight = new THREE.DirectionalLight(0x7898c8, 1.3);
rimLight.position.set(5, 3, -6);
scene.add(rimLight);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const materials = {
tileTop: new THREE.MeshStandardMaterial({
color: 0x77746d,
roughness: 0.98,
metalness: 0.0,
flatShading: true
}),
tileSide: new THREE.MeshStandardMaterial({
color: 0x4d4b47,
roughness: 1.0,
metalness: 0.0,
flatShading: true
}),
ground: new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 1.0,
metalness: 0.0
}),
strut: new THREE.MeshStandardMaterial({
color: 0xb9a065,
roughness: 0.36,
metalness: 0.72
}),
strutDark: new THREE.MeshStandardMaterial({
color: 0x6c604a,
roughness: 0.43,
metalness: 0.65
}),
silver: new THREE.MeshStandardMaterial({
color: 0xbfc3c1,
roughness: 0.3,
metalness: 0.82
}),
footpad: new THREE.MeshStandardMaterial({
color: 0x969b9b,
roughness: 0.38,
metalness: 0.72,
side: THREE.DoubleSide
}),
joint: new THREE.MeshStandardMaterial({
color: 0x5d6264,
roughness: 0.38,
metalness: 0.78,
flatShading: true
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x252a2c,
roughness: 0.48,
metalness: 0.68
}),
regolithA: new THREE.MeshStandardMaterial({
color: 0x6d6963,
roughness: 1,
flatShading: true
}),
regolithB: new THREE.MeshStandardMaterial({
color: 0x858078,
roughness: 1,
flatShading: true
}),
regolithC: new THREE.MeshStandardMaterial({
color: 0x55534f,
roughness: 1,
flatShading: true
}),
contact: new THREE.MeshStandardMaterial({
color: 0x484640,
roughness: 1,
transparent: true,
opacity: 0.82,
depthWrite: false
})
};
// ------------------------------------------------------------
// Utility functions
// ------------------------------------------------------------
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(11071969);
const Y_AXIS = new THREE.Vector3(0, 1, 0);
const Z_AXIS = new THREE.Vector3(0, 0, 1);
function cylinderBetween(start, end, radius, material, radialSegments = 12) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(Y_AXIS, direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function ringBetween(point, axis, radius, tube, material) {
const geometry = new THREE.TorusGeometry(
radius,
tube,
7,
18
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(point);
mesh.quaternion.setFromUnitVectors(Z_AXIS, axis.clone().normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function sphereAt(position, radius, material, detail = 1) {
const geometry = new THREE.IcosahedronGeometry(radius, detail);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(position);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function boxAt(position, size, material, rotation = null) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, size.z),
material
);
mesh.position.copy(position);
if (rotation) mesh.rotation.set(rotation.x, rotation.y, rotation.z);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
// ------------------------------------------------------------
// Lunar ground
// ------------------------------------------------------------
const groundGeometry = new THREE.PlaneGeometry(50, 50, 70, 70);
groundGeometry.rotateX(-Math.PI / 2);
const groundPositions = groundGeometry.attributes.position;
const groundColors = [];
const lowColor = new THREE.Color(0x555450);
const highColor = new THREE.Color(0x77746e);
const color = new THREE.Color();
for (let i = 0; i < groundPositions.count; i++) {
const x = groundPositions.getX(i);
const z = groundPositions.getZ(i);
const distance = Math.hypot(x, z);
const ripple =
Math.sin(x * 1.17 + z * 0.31) * 0.035 +
Math.sin(z * 1.83 - x * 0.44) * 0.025 +
Math.cos((x + z) * 0.72) * 0.018;
const fade = THREE.MathUtils.smoothstep(distance, 2.0, 5.0);
const y = -0.225 + ripple * fade;
groundPositions.setY(i, y);
color.lerpColors(lowColor, highColor, 0.52 + ripple * 2.5);
groundColors.push(color.r, color.g, color.b);
}
groundGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(groundColors, 3)
);
groundGeometry.computeVertexNormals();
const ground = new THREE.Mesh(groundGeometry, materials.ground);
ground.receiveShadow = true;
scene.add(ground);
// ------------------------------------------------------------
// Small irregular regolith tile
// ------------------------------------------------------------
const tileShape = new THREE.Shape();
tileShape.moveTo(-1.78, -1.20);
tileShape.lineTo(-0.72, -1.43);
tileShape.lineTo(1.54, -1.29);
tileShape.lineTo(1.86, -0.22);
tileShape.lineTo(1.55, 1.28);
tileShape.lineTo(-0.42, 1.46);
tileShape.lineTo(-1.68, 0.77);
tileShape.closePath();
const tileGeometry = new THREE.ExtrudeGeometry(tileShape, {
depth: 0.22,
bevelEnabled: true,
bevelSegments: 1,
bevelSize: 0.035,
bevelThickness: 0.025,
curveSegments: 1,
steps: 1
});
tileGeometry.rotateX(-Math.PI / 2);
const tile = new THREE.Mesh(
tileGeometry,
[materials.tileTop, materials.tileSide]
);
tile.position.y = -0.22;
tile.castShadow = true;
tile.receiveShadow = true;
scene.add(tile);
// ------------------------------------------------------------
// Regolith grains over the tile
// ------------------------------------------------------------
const grainGeometry = new THREE.DodecahedronGeometry(0.065, 0);
const grainMaterials = [
materials.regolithA,
materials.regolithB,
materials.regolithC
];
for (let i = 0; i < 105; i++) {
const x = random() * 3.35 - 1.68;
const z = random() * 2.62 - 1.31;
// Keep the immediate footpad contact zone readable.
if (Math.hypot(x - 0.18, z - 0.08) < 0.72) continue;
const grain = new THREE.Mesh(
grainGeometry,
grainMaterials[Math.floor(random() * grainMaterials.length)]
);
const scale = 0.38 + random() * 0.95;
grain.position.set(x, 0.012, z);
grain.scale.set(
scale * (0.7 + random() * 0.6),
scale * (0.25 + random() * 0.35),
scale * (0.7 + random() * 0.6)
);
grain.rotation.set(random() * 3, random() * 3, random() * 3);
grain.castShadow = true;
grain.receiveShadow = true;
scene.add(grain);
}
// Distant low-poly lunar rocks.
const boulderGeometry = new THREE.DodecahedronGeometry(0.42, 1);
for (let i = 0; i < 15; i++) {
const angle = random() * Math.PI * 2;
const radius = 3.6 + random() * 9.5;
const boulder = new THREE.Mesh(
boulderGeometry,
grainMaterials[Math.floor(random() * grainMaterials.length)]
);
boulder.position.set(
Math.cos(angle) * radius,
-0.14,
Math.sin(angle) * radius
);
boulder.scale.set(
0.5 + random() * 1.7,
0.25 + random() * 0.65,
0.6 + random() * 1.5
);
boulder.rotation.set(random() * 2, random() * 6, random() * 2);
boulder.castShadow = true;
boulder.receiveShadow = true;
scene.add(boulder);
}
// ------------------------------------------------------------
// Apollo landing gear reference points
// ------------------------------------------------------------
const footCenter = new THREE.Vector3(0.18, 0, 0.08);
const footJoint = new THREE.Vector3(0.18, 0.39, 0.08);
const kneeJoint = new THREE.Vector3(-0.65, 1.48, 0.08);
const upperJoint = new THREE.Vector3(-0.28, 2.63, -0.06);
const trussMount = new THREE.Vector3(-1.48, 3.02, -0.12);
// Cropped mounting structure only — no complete spacecraft.
scene.add(
boxAt(
new THREE.Vector3(-0.90, 2.87, -0.20),
new THREE.Vector3(1.12, 0.22, 0.43),
materials.strut,
new THREE.Euler(0.06, 0.02, -0.17)
)
);
// ------------------------------------------------------------
// Dished footpad
// ------------------------------------------------------------
const padProfile = [
new THREE.Vector2(0.00, -0.045),
new THREE.Vector2(0.28, -0.040),
new THREE.Vector2(0.48, -0.005),
new THREE.Vector2(0.57, 0.055),
new THREE.Vector2(0.56, 0.095),
new THREE.Vector2(0.50, 0.120),
new THREE.Vector2(0.40, 0.075),
new THREE.Vector2(0.22, 0.025),
new THREE.Vector2(0.00, 0.018)
];
const footpad = new THREE.Mesh(
new THREE.LatheGeometry(padProfile, 48),
materials.footpad
);
footpad.position.set(footCenter.x, 0.045, footCenter.z);
footpad.castShadow = true;
footpad.receiveShadow = true;
scene.add(footpad);
// Reinforcing ring and radial ribs on the upper face.
const padRing = ringBetween(
new THREE.Vector3(footCenter.x, 0.162, footCenter.z),
Y_AXIS,
0.49,
0.012,
materials.silver
);
scene.add(padRing);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const inner = new THREE.Vector3(
footCenter.x + Math.cos(angle) * 0.11,
0.073,
footCenter.z + Math.sin(angle) * 0.11
);
const outer = new THREE.Vector3(
footCenter.x + Math.cos(angle) * 0.48,
0.154,
footCenter.z + Math.sin(angle) * 0.48
);
scene.add(cylinderBetween(inner, outer, 0.012, materials.silver, 8));
}
// Tapered socket and foot-joint axle.
scene.add(
cylinderBetween(
new THREE.Vector3(footCenter.x, 0.155, footCenter.z),
new THREE.Vector3(footCenter.x, 0.31, footCenter.z),
0.13,
materials.footpad,
16
)
);
scene.add(
cylinderBetween(
footJoint.clone().add(new THREE.Vector3(-0.18, 0, 0)),
footJoint.clone().add(new THREE.Vector3(0.18, 0, 0)),
0.068,
materials.darkMetal,
14
)
);
scene.add(sphereAt(footJoint, 0.125, materials.joint, 1));
// ------------------------------------------------------------
// Primary telescoping strut
// ------------------------------------------------------------
scene.add(
cylinderBetween(
footJoint,
kneeJoint,
0.105,
materials.strut,
14
)
);
scene.add(
cylinderBetween(
kneeJoint,
upperJoint,
0.148,
materials.strut,
14
)
);
const upperAxis = new THREE.Vector3()
.subVectors(upperJoint, kneeJoint)
.normalize();
// Stylized crushable-sleeve ribs.
for (let i = 0; i < 7; i++) {
const t = 0.1 + (i / 6) * 0.78;
const point = kneeJoint.clone().lerp(upperJoint, t);
scene.add(
ringBetween(
point,
upperAxis,
0.15,
0.016,
i % 2 === 0 ? materials.strutDark : materials.silver
)
);
}
// Joint collars.
scene.add(
cylinderBetween(
kneeJoint.clone().addScaledVector(upperAxis, -0.04),
kneeJoint.clone().addScaledVector(upperAxis, 0.10),
0.17,
materials.silver,
14
)
);
scene.add(
cylinderBetween(
upperJoint.clone().addScaledVector(upperAxis, -0.09),
upperJoint.clone().addScaledVector(upperAxis, 0.06),
0.16,
materials.silver,
14
)
);
// Knee and upper pivots.
scene.add(sphereAt(kneeJoint, 0.185, materials.joint, 1));
scene.add(
cylinderBetween(
kneeJoint.clone().add(new THREE.Vector3(-0.22, 0, 0)),
kneeJoint.clone().add(new THREE.Vector3(0.22, 0, 0)),
0.068,
materials.darkMetal,
12
)
);
scene.add(sphereAt(upperJoint, 0.17, materials.joint, 1));
scene.add(
cylinderBetween(
upperJoint.clone().add(new THREE.Vector3(-0.19, 0, 0)),
upperJoint.clone().add(new THREE.Vector3(0.19, 0, 0)),
0.062,
materials.darkMetal,
12
)
);
// ------------------------------------------------------------
// Deployment truss and secondary brace
// ------------------------------------------------------------
for (const offset of [-0.105, 0.105]) {
const top = trussMount.clone().add(new THREE.Vector3(0, 0, offset));
const bottom = kneeJoint.clone().add(new THREE.Vector3(0, 0, offset));
scene.add(
cylinderBetween(top, bottom, 0.047, materials.silver, 10)
);
// Small cross members between the paired truss rods.
for (const t of [0.32, 0.66]) {
const p = top.clone().lerp(bottom, t);
scene.add(
cylinderBetween(
p.clone().add(new THREE.Vector3(0, 0, -0.105)),
p.clone().add(new THREE.Vector3(0, 0, 0.105)),
0.027,
materials.darkMetal,
8
)
);
}
}
// Long triangular secondary brace.
scene.add(
cylinderBetween(
trussMount.clone().add(new THREE.Vector3(0.07, -0.02, 0.11)),
footJoint.clone().add(new THREE.Vector3(-0.03, 0.02, 0.11)),
0.042,
materials.silver,
10
)
);
scene.add(sphereAt(trussMount, 0.15, materials.joint, 1));
scene.add(
cylinderBetween(
trussMount.clone().add(new THREE.Vector3(-0.17, 0, 0)),
trussMount.clone().add(new THREE.Vector3(0.17, 0, 0)),
0.055,
materials.darkMetal,
12
)
);
// ------------------------------------------------------------
// Lunar contact probe
// ------------------------------------------------------------
const probeStart = new THREE.Vector3(-0.02, 0.64, 0.31);
const probeTip = new THREE.Vector3(0.12, 0.025, 1.42);
scene.add(
cylinderBetween(
probeStart,
probeTip,
0.012,
materials.silver,
8
)
);
const probeEnd = new THREE.Mesh(
new THREE.SphereGeometry(0.028, 10, 8),
materials.darkMetal
);
probeEnd.position.copy(probeTip);
probeEnd.castShadow = true;
scene.add(probeEnd);
const probeDimple = new THREE.Mesh(
new THREE.CircleGeometry(0.075, 24),
materials.contact
);
probeDimple.rotation.x = -Math.PI / 2;
probeDimple.position.set(probeTip.x, 0.005, probeTip.z);
scene.add(probeDimple);
// ------------------------------------------------------------
// Compressed regolith and raised contact ridge
// ------------------------------------------------------------
const compression = new THREE.Mesh(
new THREE.CircleGeometry(0.62, 48),
materials.contact
);
compression.rotation.x = -Math.PI / 2;
compression.position.set(footCenter.x, 0.004, footCenter.z);
compression.receiveShadow = true;
scene.add(compression);
function createContactRidge() {
const segments = 48;
const positions = [];
const indices = [];
for (let i = 0; i <= segments; i++) {
const angle = (i / segments) * Math.PI * 2;
const variation = Math.sin(angle * 5.0) * 0.025 +
Math.sin(angle * 11.0) * 0.012;
const innerRadius = 0.555 + variation;
const outerRadius = 0.76 + Math.sin(angle * 7.0) * 0.025;
positions.push(
footCenter.x + Math.cos(angle) * innerRadius,
0.004,
footCenter.z + Math.sin(angle) * innerRadius
);
positions.push(
footCenter.x + Math.cos(angle) * outerRadius,
0.024 + (0.5 + 0.5 * Math.sin(angle * 9.0)) * 0.045,
footCenter.z + Math.sin(angle) * outerRadius
);
}
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 ridge = new THREE.Mesh(geometry, materials.regolithA);
ridge.castShadow = true;
ridge.receiveShadow = true;
scene.add(ridge);
}
createContactRidge();
// Irregular chunks thrown up at the footpad perimeter.
for (let i = 0; i < 20; i++) {
const angle = (i / 20) * Math.PI * 2 + random() * 0.16;
const radius = 0.61 + random() * 0.15;
const chunk = new THREE.Mesh(
grainGeometry,
grainMaterials[i % grainMaterials.length]
);
chunk.position.set(
footCenter.x + Math.cos(angle) * radius,
0.025,
footCenter.z + Math.sin(angle) * radius
);
chunk.scale.set(
0.65 + random() * 1.1,
0.28 + random() * 0.45,
0.55 + random() * 0.9
);
chunk.rotation.set(random() * 3, random() * 3, random() * 3);
chunk.castShadow = true;
chunk.receiveShadow = true;
scene.add(chunk);
}
// ------------------------------------------------------------
// Stars and a stylized Earth in the lunar sky
// ------------------------------------------------------------
const starPositions = [];
for (let i = 0; i < 1150; i++) {
const theta = random() * Math.PI * 2;
const phi = Math.acos(2 * random() - 1);
const radius = 28 + random() * 18;
starPositions.push(
radius * Math.sin(phi) * Math.cos(theta),
radius * Math.cos(phi),
radius * Math.sin(phi) * Math.sin(theta)
);
}
const starGeometry = new THREE.BufferGeometry();
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
const stars = new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0xdbe4ee,
size: 0.045,
sizeAttenuation: true,
transparent: true,
opacity: 0.82,
depthWrite: false,
fog: false
})
);
scene.add(stars);
const earth = new THREE.Mesh(
new THREE.SphereGeometry(1.18, 32, 24),
new THREE.MeshStandardMaterial({
color: 0x285d88,
emissive: 0x071522,
emissiveIntensity: 0.65,
roughness: 0.92,
metalness: 0,
fog: false
})
);
earth.position.set(-6.8, 6.6, -13.5);
scene.add(earth);
const earthHalo = new THREE.Mesh(
new THREE.SphereGeometry(1.27, 24, 18),
new THREE.MeshBasicMaterial({
color: 0x6aa9dc,
transparent: true,
opacity: 0.08,
side: THREE.BackSide,
depthWrite: false,
fog: false
})
);
earthHalo.position.copy(earth.position);
scene.add(earthHalo);
// ------------------------------------------------------------
// Screen-space technical labels
// ------------------------------------------------------------
const annotations = [
{
element: document.getElementById("label-truss"),
point: new THREE.Vector3(-1.15, 2.28, -0.02)
},
{
element: document.getElementById("label-strut"),
point: new THREE.Vector3(-0.39, 1.87, 0.12)
},
{
element: document.getElementById("label-pad"),
point: new THREE.Vector3(0.42, 0.16, 0.43)
},
{
element: document.getElementById("label-contact"),
point: new THREE.Vector3(0.53, 0.04, 0.71)
}
];
const projected = new THREE.Vector3();
function updateAnnotations() {
for (const annotation of annotations) {
projected.copy(annotation.point).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.1 &&
Math.abs(projected.y) < 1.1;
annotation.element.classList.toggle("visible", visible);
if (visible) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
annotation.element.style.left = `${x}px`;
annotation.element.style.top = `${y}px`;
}
}
}
// ------------------------------------------------------------
// Direct camera controls — no examples/addons used
// ------------------------------------------------------------
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.26,
1.52
);
updateCamera();
});
function stopDragging(event) {
controls.dragging = false;
canvas.classList.remove("dragging");
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.004,
3.5,
10.0
);
updateCamera();
},
{ passive: false }
);
function resetView() {
controls.target.set(-0.08, 1.43, 0);
controls.radius = 6.3;
controls.theta = 0.63;
controls.phi = 1.19;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
renderer.setAnimationLoop(() => {
updateAnnotations();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```