Prompt specification
Build or customize the Three.js 3D scene "Footstep Pair and Direction Markers" 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: Footstep Pair and Direction Markers
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/footstep-pair-and-direction-markers-x3297
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: footstep pair and direction markers. Model a pair of simplified feet beside left-right movement markers. Show orientation and support contact without claiming to teach a named traditional dance. Return one self-contained HTML file.
Working Three.js Starter (footstep-pair-and-direction-markers-x3297):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Footstep — Orientation & Support Study</title>
<style>
:root {
color-scheme: dark;
--ink: #eef8f8;
--muted: #91aeb5;
--left: #ff7968;
--right: #49dac8;
--contact: #ffd27d;
--panel: rgba(7, 20, 29, 0.78);
--line: rgba(170, 226, 230, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07141d;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.overlay {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.info-panel {
position: absolute;
top: 24px;
left: 24px;
width: min(350px, calc(100vw - 48px));
padding: 20px 22px 18px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.26);
backdrop-filter: blur(14px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 1px;
content: "";
background: var(--right);
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 36px);
font-weight: 680;
line-height: 0.98;
letter-spacing: -0.045em;
}
h1 span {
color: var(--right);
}
.subtitle {
max-width: 285px;
margin: 14px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.legend {
display: grid;
gap: 9px;
margin-top: 17px;
padding-top: 15px;
border-top: 1px solid var(--line);
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
color: #c7d9dc;
font-size: 11px;
letter-spacing: 0.025em;
}
.swatch {
display: inline-block;
flex: 0 0 auto;
width: 18px;
height: 8px;
border-radius: 99px;
background: var(--contact);
box-shadow: 0 0 13px rgba(255, 210, 125, 0.35);
}
.swatch.forward {
width: 22px;
height: 3px;
background: #fff0d8;
box-shadow: none;
position: relative;
}
.swatch.forward::after {
position: absolute;
top: -3px;
right: -1px;
width: 0;
height: 0;
content: "";
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 6px solid #fff0d8;
}
.swatch.lateral {
width: 25px;
height: 3px;
background: linear-gradient(
90deg,
var(--left) 0 35%,
#526d74 35% 65%,
var(--right) 65% 100%
);
box-shadow: none;
}
.controls {
position: absolute;
right: 22px;
top: 22px;
display: flex;
align-items: center;
gap: 10px;
}
.hint {
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 99px;
color: var(--muted);
background: rgba(7, 20, 29, 0.64);
font-size: 10px;
letter-spacing: 0.05em;
backdrop-filter: blur(10px);
}
button {
pointer-events: auto;
padding: 9px 13px;
border: 1px solid var(--line);
border-radius: 99px;
color: var(--ink);
background: rgba(7, 20, 29, 0.78);
font: inherit;
font-size: 10px;
letter-spacing: 0.06em;
cursor: pointer;
backdrop-filter: blur(10px);
transition: border-color 160ms ease, background 160ms ease;
}
button:hover {
border-color: rgba(73, 218, 200, 0.6);
background: rgba(18, 49, 59, 0.9);
}
.index {
position: absolute;
right: 24px;
bottom: 22px;
color: rgba(200, 224, 227, 0.42);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
color: var(--muted);
background: #07141d;
font-size: 11px;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.info-panel {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 16px 18px;
}
.subtitle {
display: none;
}
.legend {
grid-template-columns: repeat(3, auto);
gap: 13px;
margin-top: 13px;
padding-top: 12px;
}
.legend-row {
gap: 6px;
font-size: 9px;
}
.controls {
top: auto;
right: 14px;
bottom: 14px;
}
.hint {
display: none;
}
.index {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="overlay">
<section class="info-panel" aria-label="Scene key">
<div class="eyebrow">Movement anatomy / 01</div>
<h1>Footstep<br /><span>direction study</span></h1>
<p class="subtitle">
A neutral visualization of foot orientation, left–right travel,
and the contact area beneath each simplified foot.
</p>
<div class="legend">
<div class="legend-row">
<span class="swatch forward"></span>
<span>Forward orientation</span>
</div>
<div class="legend-row">
<span class="swatch"></span>
<span>Support contact</span>
</div>
<div class="legend-row">
<span class="swatch lateral"></span>
<span>Lateral movement</span>
</div>
</div>
</section>
<div class="controls">
<div class="hint">Drag to orbit · Scroll to zoom</div>
<button id="reset" type="button" aria-label="Reset camera">RESET VIEW</button>
</div>
<div class="index">Orientation / contact / lateral axis</div>
</div>
<div id="loading">Preparing movement study…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07141d);
scene.fog = new THREE.Fog(0x07141d, 10, 20);
const camera = new THREE.PerspectiveCamera(38, innerWidth / innerHeight, 0.1, 40);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional scene with two stylized feet, forward orientation arrows, support-contact zones, and left-right movement markers."
);
renderer.domElement.tabIndex = 0;
container.appendChild(renderer.domElement);
const COLORS = {
background: 0x07141d,
platform: 0x0d2832,
platformSide: 0x081b24,
grid: 0x38636d,
left: 0xff7968,
right: 0x49dac8,
cream: 0xffefd7,
contact: 0xffd27d,
muted: 0x6f929b
};
const target = new THREE.Vector3(0, 0.2, 0.12);
let theta = 0.32;
let phi = 1.03;
let defaultRadius = innerWidth < 700 ? 14.5 : 8.8;
let radius = defaultRadius;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const horizontal = radius * Math.sin(phi);
camera.position.set(
target.x + horizontal * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + horizontal * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight(0xc8f5ff, 0x15202a, 1.65));
const keyLight = new THREE.DirectionalLight(0xfff1d7, 3.1);
keyLight.position.set(-3.8, 7.2, 4.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -5.5;
keyLight.shadow.camera.right = 5.5;
keyLight.shadow.camera.top = 5.5;
keyLight.shadow.camera.bottom = -5.5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const leftRim = new THREE.PointLight(COLORS.left, 12, 8, 2);
leftRim.position.set(-3.2, 1.7, -1.8);
scene.add(leftRim);
const rightRim = new THREE.PointLight(COLORS.right, 12, 8, 2);
rightRim.position.set(3.2, 1.7, -0.6);
scene.add(rightRim);
// Stage
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: COLORS.background,
roughness: 1,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.255;
floor.receiveShadow = true;
scene.add(floor);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(4.25, 4.35, 0.22, 96),
[
new THREE.MeshStandardMaterial({
color: COLORS.platformSide,
roughness: 0.78,
metalness: 0.05
}),
new THREE.MeshStandardMaterial({
color: COLORS.platform,
roughness: 0.72,
metalness: 0.08
}),
new THREE.MeshStandardMaterial({
color: COLORS.platformSide,
roughness: 0.82
})
]
);
platform.position.y = -0.13;
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
const grid = new THREE.GridHelper(8, 20, COLORS.grid, 0x24454f);
grid.position.y = -0.014;
grid.material.transparent = true;
grid.material.opacity = 0.16;
grid.material.depthWrite = false;
scene.add(grid);
const outerRing = new THREE.Mesh(
new THREE.TorusGeometry(4.03, 0.014, 8, 160),
new THREE.MeshBasicMaterial({
color: 0x4f8991,
transparent: true,
opacity: 0.42
})
);
outerRing.rotation.x = Math.PI / 2;
outerRing.position.y = -0.004;
scene.add(outerRing);
// Canvas sprite labels
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(text, color, width = 1.3) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 144;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 14, 14, 484, 116, 28);
ctx.fillStyle = "rgba(6, 19, 27, 0.88)";
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = color;
ctx.stroke();
ctx.fillStyle = color;
ctx.font = "700 48px Inter, system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 73);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * (144 / 512), 1);
sprite.renderOrder = 20;
return sprite;
}
// Simplified foot outline, with the toes pointing toward local +Z.
const footShape = new THREE.Shape();
footShape.moveTo(-0.35, -1.04);
footShape.bezierCurveTo(-0.55, -1.01, -0.62, -0.85, -0.58, -0.62);
footShape.bezierCurveTo(-0.49, -0.26, -0.45, 0.03, -0.57, 0.34);
footShape.bezierCurveTo(-0.7, 0.61, -0.77, 0.87, -0.59, 1.05);
footShape.bezierCurveTo(-0.43, 1.2, -0.12, 1.23, 0.23, 1.17);
footShape.bezierCurveTo(0.54, 1.11, 0.68, 0.94, 0.62, 0.71);
footShape.bezierCurveTo(0.57, 0.53, 0.45, 0.35, 0.43, 0.1);
footShape.bezierCurveTo(0.4, -0.29, 0.42, -0.73, 0.25, -1.0);
footShape.quadraticCurveTo(0.04, -1.13, -0.35, -1.04);
footShape.closePath();
const contactHalos = [];
const contactPads = [];
function makeFoot({ x, mirrored, color, label }) {
const root = new THREE.Group();
root.position.set(x, 0.22, 0.05);
root.rotation.y = mirrored ? -0.07 : 0.07;
root.scale.x = mirrored ? -1 : 1;
// Main simplified foot form
const bodyGeometry = new THREE.ExtrudeGeometry(footShape, {
depth: 0.2,
steps: 1,
bevelEnabled: true,
bevelSegments: 4,
bevelSize: 0.055,
bevelThickness: 0.045,
curveSegments: 28
});
bodyGeometry.rotateX(Math.PI / 2);
const body = new THREE.Mesh(
bodyGeometry,
new THREE.MeshStandardMaterial({
color,
roughness: 0.4,
metalness: 0.04
})
);
body.castShadow = true;
body.receiveShadow = true;
root.add(body);
// Lighter top surface makes the simplified sole easy to read.
const insoleGeometry = new THREE.ExtrudeGeometry(footShape, {
depth: 0.025,
steps: 1,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.025,
bevelThickness: 0.018,
curveSegments: 28
});
insoleGeometry.scale(0.78, 0.84, 0.8);
insoleGeometry.rotateX(Math.PI / 2);
const insole = new THREE.Mesh(
insoleGeometry,
new THREE.MeshStandardMaterial({
color: COLORS.cream,
roughness: 0.52,
metalness: 0.02
})
);
insole.position.y = 0.036;
insole.castShadow = true;
root.add(insole);
// Forward orientation arrow inset along the top of each foot.
const arrowMaterial = new THREE.MeshBasicMaterial({ color: COLORS.cream });
const arrowShaft = new THREE.Mesh(
new THREE.BoxGeometry(0.075, 0.022, 0.55),
arrowMaterial
);
arrowShaft.position.set(0, 0.073, 0.13);
root.add(arrowShaft);
const arrowHead = new THREE.Mesh(
new THREE.ConeGeometry(0.16, 0.29, 3),
arrowMaterial
);
arrowHead.rotation.x = Math.PI / 2;
arrowHead.position.set(0, 0.073, 0.56);
arrowHead.scale.x = 0.82;
root.add(arrowHead);
// Floor-level dashed guide extending in the forward direction.
const guideMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.56
});
for (let z = 1.01; z <= 1.42; z += 0.19) {
const dash = new THREE.Mesh(
new THREE.BoxGeometry(0.035, 0.014, 0.105),
guideMaterial
);
dash.position.set(0, -0.225, z);
root.add(dash);
}
const guideTriangleShape = new THREE.Shape();
guideTriangleShape.moveTo(0, 0.16);
guideTriangleShape.lineTo(-0.13, -0.11);
guideTriangleShape.lineTo(0.13, -0.11);
guideTriangleShape.closePath();
const guideTriangle = new THREE.Mesh(
new THREE.ShapeGeometry(guideTriangleShape),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.68,
side: THREE.DoubleSide
})
);
guideTriangle.rotation.x = Math.PI / 2;
guideTriangle.position.set(0, -0.218, 1.59);
root.add(guideTriangle);
// Glowing contact footprint on the stage.
const footprintGeometry = new THREE.ShapeGeometry(footShape, 28);
footprintGeometry.rotateX(Math.PI / 2);
const footprint = new THREE.Mesh(
footprintGeometry,
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.14,
side: THREE.DoubleSide,
depthWrite: false
})
);
footprint.scale.set(1.1, 1.1, 1.1);
footprint.position.y = -0.224;
root.add(footprint);
// Heel and forefoot contact patches.
const padGeometry = new THREE.SphereGeometry(1, 32, 16);
const padMaterial = new THREE.MeshBasicMaterial({
color: COLORS.contact,
transparent: true,
opacity: 0.66,
depthWrite: false
});
const heelPad = new THREE.Mesh(padGeometry, padMaterial);
heelPad.scale.set(0.53, 0.026, 0.29);
heelPad.position.set(0, -0.207, -0.73);
root.add(heelPad);
const forefootPad = new THREE.Mesh(padGeometry, padMaterial.clone());
forefootPad.scale.set(0.72, 0.028, 0.37);
forefootPad.position.set(0, -0.207, 0.72);
root.add(forefootPad);
const sidePadMaterial = new THREE.MeshBasicMaterial({
color: COLORS.contact,
transparent: true,
opacity: 0.43,
depthWrite: false
});
const sidePadA = new THREE.Mesh(padGeometry, sidePadMaterial);
sidePadA.scale.set(0.22, 0.025, 0.25);
sidePadA.position.set(-0.48, -0.203, 0.69);
root.add(sidePadA);
const sidePadB = new THREE.Mesh(padGeometry, sidePadMaterial.clone());
sidePadB.scale.set(0.22, 0.025, 0.25);
sidePadB.position.set(0.48, -0.203, 0.69);
root.add(sidePadB);
contactPads.push(heelPad.material, forefootPad.material, sidePadA.material, sidePadB.material);
// Fine outline surrounding the contact area.
const outlinePoints = footShape.getPoints(90).map(
(point) => new THREE.Vector3(point.x * 1.13, -0.211, point.y * 1.13)
);
const outlineGeometry = new THREE.BufferGeometry().setFromPoints(outlinePoints);
const outlineMaterial = new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.7
});
const contactOutline = new THREE.LineLoop(outlineGeometry, outlineMaterial);
root.add(contactOutline);
contactHalos.push(contactOutline);
scene.add(root);
const footLabel = makeLabel(label, `#${new THREE.Color(color).getHexString()}`, 1.18);
footLabel.position.set(x, 0.37, -1.48);
scene.add(footLabel);
return root;
}
makeFoot({
x: -0.86,
mirrored: false,
color: COLORS.left,
label: "LEFT FOOT"
});
makeFoot({
x: 0.86,
mirrored: true,
color: COLORS.right,
label: "RIGHT FOOT"
});
// Subtle colored zones beneath the feet.
function makeFootZone(x, color) {
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.075,
depthWrite: false
});
const zone = new THREE.Mesh(new THREE.CircleGeometry(1, 64), material);
zone.rotation.x = -Math.PI / 2;
zone.scale.set(0.94, 1.22, 1);
zone.position.set(x, -0.008, 0.05);
scene.add(zone);
}
makeFootZone(-0.86, COLORS.left);
makeFootZone(0.86, COLORS.right);
// Bilateral left/right movement axis.
const movementAxis = new THREE.Mesh(
new THREE.BoxGeometry(5.05, 0.035, 0.055),
new THREE.MeshBasicMaterial({ color: 0x77969d })
);
movementAxis.position.set(0, 0.012, 1.72);
scene.add(movementAxis);
const leftArrowHead = new THREE.Mesh(
new THREE.ConeGeometry(0.22, 0.43, 3),
new THREE.MeshBasicMaterial({ color: COLORS.left })
);
leftArrowHead.rotation.z = Math.PI / 2;
leftArrowHead.position.set(-2.53, 0.055, 1.72);
scene.add(leftArrowHead);
const rightArrowHead = new THREE.Mesh(
new THREE.ConeGeometry(0.22, 0.43, 3),
new THREE.MeshBasicMaterial({ color: COLORS.right })
);
rightArrowHead.rotation.z = -Math.PI / 2;
rightArrowHead.position.set(2.53, 0.055, 1.72);
scene.add(rightArrowHead);
const leftMovementLabel = makeLabel("← LEFT", "#ff7968", 1.18);
leftMovementLabel.position.set(-2.56, 0.43, 1.72);
scene.add(leftMovementLabel);
const rightMovementLabel = makeLabel("RIGHT →", "#49dac8", 1.18);
rightMovementLabel.position.set(2.56, 0.43, 1.72);
scene.add(rightMovementLabel);
const orientationLabel = makeLabel("FORWARD / ORIENTATION", "#ffefd7", 1.8);
orientationLabel.position.set(0, 0.39, 2.18);
scene.add(orientationLabel);
// Moving signals reinforce the two lateral directions.
const leftSignal = new THREE.Mesh(
new THREE.SphereGeometry(0.065, 20, 12),
new THREE.MeshBasicMaterial({ color: COLORS.left })
);
const rightSignal = new THREE.Mesh(
new THREE.SphereGeometry(0.065, 20, 12),
new THREE.MeshBasicMaterial({ color: COLORS.right })
);
leftSignal.position.set(0, 0.09, 1.72);
rightSignal.position.set(0, 0.09, 1.72);
scene.add(leftSignal, rightSignal);
// Camera controls implemented directly, without external controls modules.
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
theta -= deltaX * 0.006;
phi = THREE.MathUtils.clamp(phi + deltaY * 0.005, 0.35, 1.42);
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("pointerleave", endDrag);
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(radius + event.deltaY * 0.005, 6.2, 17);
updateCamera();
},
{ passive: false }
);
function resetView() {
theta = 0.32;
phi = 1.03;
radius = innerWidth < 700 ? 14.5 : 8.8;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
theta += 0.08;
break;
case "ArrowRight":
theta -= 0.08;
break;
case "ArrowUp":
phi = Math.max(0.35, phi - 0.05);
break;
case "ArrowDown":
phi = Math.min(1.42, phi + 0.05);
break;
case "+":
case "=":
radius = Math.max(6.2, radius - 0.4);
break;
case "-":
radius = Math.min(17, radius + 0.4);
break;
case "r":
case "R":
resetView();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const pulse = 0.5 + 0.5 * Math.sin(elapsed * 2.1);
contactHalos.forEach((halo, index) => {
const phase = pulse + index * 0.25;
halo.scale.setScalar(1 + phase * 0.018);
halo.material.opacity = 0.5 + phase * 0.28;
});
contactPads.forEach((material, index) => {
material.opacity = 0.46 + pulse * (index % 2 === 0 ? 0.24 : 0.14);
});
const travel = 0.5 - 0.5 * Math.cos(elapsed * 0.9);
leftSignal.position.x = -2.18 * travel;
rightSignal.position.x = 2.18 * travel;
leftSignal.scale.setScalar(0.88 + pulse * 0.22);
rightSignal.scale.setScalar(0.88 + (1 - pulse) * 0.22);
renderer.render(scene, camera);
}
renderer.render(scene, camera);
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
animate();
</script>
</body>
</html>
```