Prompt specification
Build or customize the Three.js 3D scene "Ground-level play panel connections" 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: Ground-level play panel connections
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/ground-level-play-panel-connections-x0441
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: ground-level play panel connections. Build a tactile play panel with gears, sliders, and openings at varied heights; show clear front access and keep all moving parts within a visible frame. Return one self-contained HTML file.
Working Three.js Starter (ground-level-play-panel-connections-x0441):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Connection Lab — Tactile Play Panel</title>
<style>
:root {
color-scheme: light;
--ink: #27363d;
--cream: #fff8e9;
--coral: #f26f61;
--teal: #36ad9d;
--yellow: #f2c755;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e1d5;
font-family: Inter, ui-rounded, "Avenir Next", system-ui, -apple-system, sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 42%, transparent 48%, rgba(50, 38, 25, 0.09) 100%);
z-index: 2;
}
.title-card {
position: fixed;
top: 22px;
left: 24px;
z-index: 3;
pointer-events: none;
max-width: min(430px, calc(100vw - 48px));
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
padding: 7px 11px;
border-radius: 999px;
background: rgba(255, 248, 233, 0.86);
border: 1px solid rgba(39, 54, 61, 0.12);
box-shadow: 0 8px 30px rgba(61, 45, 28, 0.08);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 4px rgba(242, 111, 97, 0.16);
}
h1 {
margin: 0;
font-size: clamp(30px, 5vw, 58px);
line-height: 0.94;
letter-spacing: -0.055em;
font-weight: 850;
color: #2c3b40;
text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
}
.subtitle {
margin: 10px 0 0;
max-width: 360px;
font-size: 13px;
line-height: 1.45;
font-weight: 550;
color: rgba(39, 54, 61, 0.67);
}
.legend {
position: fixed;
right: 22px;
top: 22px;
z-index: 3;
display: flex;
flex-direction: column;
gap: 8px;
pointer-events: none;
}
.chip {
display: flex;
align-items: center;
gap: 9px;
padding: 8px 12px 8px 9px;
border-radius: 999px;
background: rgba(255, 248, 233, 0.78);
border: 1px solid rgba(39, 54, 61, 0.11);
box-shadow: 0 8px 30px rgba(61, 45, 28, 0.06);
backdrop-filter: blur(10px);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.dot {
width: 18px;
height: 18px;
border-radius: 6px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.dot.coral { background: var(--coral); }
.dot.teal { background: var(--teal); }
.dot.yellow { background: var(--yellow); }
.hint {
position: fixed;
z-index: 3;
left: 50%;
bottom: 18px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 12px;
max-width: calc(100vw - 28px);
padding: 10px 15px;
border-radius: 999px;
background: rgba(255, 248, 233, 0.82);
border: 1px solid rgba(39, 54, 61, 0.12);
box-shadow: 0 10px 35px rgba(61, 45, 28, 0.09);
backdrop-filter: blur(12px);
pointer-events: none;
white-space: nowrap;
font-size: 12px;
font-weight: 650;
color: rgba(39, 54, 61, 0.72);
}
.hint b {
color: var(--ink);
font-weight: 850;
}
.mouse {
width: 19px;
height: 25px;
border: 2px solid #43545b;
border-radius: 10px;
position: relative;
flex: 0 0 auto;
}
.mouse::after {
content: "";
position: absolute;
width: 2px;
height: 6px;
top: 4px;
left: 50%;
transform: translateX(-50%);
border-radius: 2px;
background: #43545b;
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #e8e1d5;
color: #34464d;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
transition: opacity .45s ease, visibility .45s ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
@media (max-width: 700px) {
.title-card { top: 16px; left: 16px; }
.subtitle { display: none; }
.legend { top: auto; bottom: 72px; right: 14px; }
.chip { padding: 7px 10px 7px 8px; font-size: 9px; }
.hint { bottom: 12px; font-size: 10px; gap: 8px; padding: 9px 12px; }
.hint .optional { display: none; }
}
</style>
</head>
<body>
<div id="loading">Building the play panel…</div>
<div class="vignette"></div>
<header class="title-card">
<div class="eyebrow">Connection Lab · 01</div>
<h1>Turn. Slide.<br />Discover.</h1>
<p class="subtitle">A low, front-access activity panel where colorful mechanisms reveal how moving parts connect.</p>
</header>
<aside class="legend" aria-hidden="true">
<div class="chip"><span class="dot coral"></span>Turn</div>
<div class="chip"><span class="dot teal"></span>Slide</div>
<div class="chip"><span class="dot yellow"></span>Peek through</div>
</aside>
<div class="hint">
<span class="mouse" aria-hidden="true"></span>
<span><b>Drag</b> to look around</span>
<span>·</span>
<span><b>Scroll</b> to zoom</span>
<span class="optional">·</span>
<span class="optional"><b>Tap</b> a moving part</span>
</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();
scene.background = new THREE.Color(0xe8e1d5);
scene.fog = new THREE.Fog(0xe8e1d5, 17, 31);
const camera = new THREE.PerspectiveCamera(38, innerWidth / innerHeight, 0.1, 60);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute("aria-label", "Interactive three-dimensional tactile play panel");
renderer.domElement.tabIndex = 0;
document.body.prepend(renderer.domElement);
const COLORS = {
wood: 0xd7a36e,
frame: 0x93603f,
frameDark: 0x6e4935,
cream: 0xfff4dc,
coral: 0xf26f61,
coralDark: 0xc84f47,
teal: 0x36ad9d,
tealDark: 0x237e77,
yellow: 0xf2c755,
yellowDark: 0xc6942f,
blue: 0x5b8def,
purple: 0xa77bc1,
ink: 0x34444b,
metal: 0xa9b2b3,
wall: 0xe5ddd0,
floor: 0xd7cebf,
rug: 0xc7b7c9
};
const mats = {};
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.68,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0
});
}
Object.assign(mats, {
wood: standard(COLORS.wood, { roughness: 0.78 }),
frame: standard(COLORS.frame, { roughness: 0.72 }),
frameDark: standard(COLORS.frameDark, { roughness: 0.78 }),
cream: standard(COLORS.cream, { roughness: 0.62 }),
coral: standard(COLORS.coral),
coralDark: standard(COLORS.coralDark),
teal: standard(COLORS.teal),
tealDark: standard(COLORS.tealDark),
yellow: standard(COLORS.yellow),
yellowDark: standard(COLORS.yellowDark),
blue: standard(COLORS.blue),
purple: standard(COLORS.purple),
ink: standard(COLORS.ink, { roughness: 0.58 }),
metal: standard(COLORS.metal, { roughness: 0.32, metalness: 0.55 }),
wall: standard(COLORS.wall, { roughness: 1 }),
floor: standard(COLORS.floor, { roughness: 0.95 }),
rug: standard(COLORS.rug, { roughness: 1 })
});
const interactive = [];
const animated = [];
function roundedRectShape(w, h, r) {
const s = new THREE.Shape();
const x = -w / 2;
const y = -h / 2;
r = Math.min(r, w / 2, h / 2);
s.moveTo(x + r, y);
s.lineTo(x + w - r, y);
s.quadraticCurveTo(x + w, y, x + w, y + r);
s.lineTo(x + w, y + h - r);
s.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
s.lineTo(x + r, y + h);
s.quadraticCurveTo(x, y + h, x, y + h - r);
s.lineTo(x, y + r);
s.quadraticCurveTo(x, y, x + r, y);
s.closePath();
return s;
}
function roundedPath(w, h, r, offsetX = 0, offsetY = 0) {
const source = roundedRectShape(w, h, r);
const points = source.getPoints(18);
if (!THREE.ShapeUtils.isClockWise(points)) points.reverse();
return new THREE.Path(points.map(point => new THREE.Vector2(point.x + offsetX, point.y + offsetY)));
}
function roundedBox(w, h, d, r, material, parent = scene) {
const geometry = new THREE.ExtrudeGeometry(roundedRectShape(w, h, r), {
depth: d,
bevelEnabled: false,
curveSegments: 10
});
geometry.translate(0, 0, -d / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderZ(radius, depth, material, parent = scene, segments = 40) {
const geometry = new THREE.CylinderGeometry(radius, radius, depth, segments);
geometry.rotateX(Math.PI / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function torus(radius, tube, material, parent = scene) {
const mesh = new THREE.Mesh(new THREE.TorusGeometry(radius, tube, 12, 56), material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, material, parent = scene) {
const direction = new THREE.Vector3().subVectors(b, a);
const geometry = new THREE.CylinderGeometry(radius, radius, direction.length(), 16);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeGear(radius, teeth, toothDepth, holeRadius, material) {
const shape = new THREE.Shape();
const step = (Math.PI * 2) / teeth;
for (let i = 0; i < teeth; i++) {
const a = i * step;
const points = [
[radius - toothDepth, a],
[radius, a + step * 0.18],
[radius, a + step * 0.32],
[radius - toothDepth, a + step * 0.5]
];
points.forEach(([r, angle], j) => {
const x = Math.cos(angle) * r;
const y = Math.sin(angle) * r;
if (i === 0 && j === 0) shape.moveTo(x, y);
else shape.lineTo(x, y);
});
}
shape.closePath();
const hole = new THREE.Path();
hole.absarc(0, 0, holeRadius, 0, Math.PI * 2, true);
shape.holes.push(hole);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.18,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.025,
bevelThickness: 0.025,
curveSegments: 18
});
geometry.translate(0, 0, -0.09);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function addScrew(x, y, z = 0.32, size = 0.075) {
const screw = cylinderZ(size, 0.065, mats.metal);
screw.position.set(x, y, z);
const slot = roundedBox(size * 1.35, size * 0.24, 0.022, 0.006, mats.ink);
slot.position.set(x, y, z + 0.042);
slot.rotation.z = x * 2.1 + y * 0.8;
}
function makeLabel(text, x, y, width = 1.25, bg = "#fff4dc", fg = "#34444b") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 512, 128);
ctx.fillStyle = bg;
ctx.beginPath();
ctx.roundRect(8, 8, 496, 112, 34);
ctx.fill();
ctx.fillStyle = fg;
ctx.font = "800 47px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 67);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
});
const label = new THREE.Mesh(
new THREE.PlaneGeometry(width, width * 0.25),
material
);
label.position.set(x, y, 0.205);
scene.add(label);
return label;
}
// Room and ground.
const wall = new THREE.Mesh(new THREE.PlaneGeometry(30, 13), mats.wall);
wall.position.set(0, 5.2, -1.8);
wall.receiveShadow = true;
scene.add(wall);
const wallCircle = new THREE.Mesh(
new THREE.CircleGeometry(5.1, 72),
standard(0xded5c7, { roughness: 1 })
);
wallCircle.position.set(0, 3.0, -1.76);
scene.add(wallCircle);
const floor = new THREE.Mesh(new THREE.PlaneGeometry(30, 30), mats.floor);
floor.rotation.x = -Math.PI / 2;
floor.position.y = 0;
floor.receiveShadow = true;
scene.add(floor);
const rug = roundedBox(9.3, 0.055, 3.15, 0.025, mats.rug);
rug.rotation.x = -Math.PI / 2;
rug.position.set(0, 0.028, -0.28);
rug.receiveShadow = true;
// Lighting.
scene.add(new THREE.HemisphereLight(0xfff7e6, 0x827565, 2.1));
const key = new THREE.DirectionalLight(0xfff4dd, 3.0);
key.position.set(-5.5, 9, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -8;
key.shadow.camera.right = 8;
key.shadow.camera.top = 9;
key.shadow.camera.bottom = -2;
key.shadow.camera.near = 1;
key.shadow.camera.far = 25;
key.shadow.bias = -0.00025;
scene.add(key);
const fill = new THREE.DirectionalLight(0xaed9ff, 1.15);
fill.position.set(7, 5, 6);
scene.add(fill);
const rim = new THREE.PointLight(0xffb78e, 18, 14, 2);
rim.position.set(-4, 5, -0.2);
scene.add(rim);
// Board silhouette with true cut-out openings.
const boardCenterY = 2.72;
const boardShape = roundedRectShape(8, 4.8, 0.24);
const leftHole = new THREE.Path();
leftHole.absarc(-3.05, 1.18 - boardCenterY, 0.47, 0, Math.PI * 2, true);
boardShape.holes.push(leftHole);
boardShape.holes.push(
roundedPath(1.25, 0.82, 0.19, -1.55, 1.45 - boardCenterY)
);
const rightHole = new THREE.Path();
rightHole.absarc(2.66, 1.17 - boardCenterY, 0.55, 0, Math.PI * 2, true);
boardShape.holes.push(rightHole);
const topHole = new THREE.Path();
topHole.absarc(0.15, 3.95 - boardCenterY, 0.39, 0, Math.PI * 2, true);
boardShape.holes.push(topHole);
const boardGeometry = new THREE.ExtrudeGeometry(boardShape, {
depth: 0.26,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.045,
bevelThickness: 0.045,
curveSegments: 24
});
boardGeometry.translate(0, 0, -0.13);
const board = new THREE.Mesh(boardGeometry, mats.wood);
board.position.y = boardCenterY;
board.castShadow = true;
board.receiveShadow = true;
scene.add(board);
// Strong perimeter frame keeps every mechanism visibly contained.
const sideFrame = roundedBox(0.31, 5.24, 0.46, 0.10, mats.frame);
sideFrame.position.set(-4.08, 2.72, 0.015);
const sideFrame2 = sideFrame.clone();
sideFrame2.position.x = 4.08;
const topFrame = roundedBox(8.47, 0.31, 0.46, 0.10, mats.frame);
topFrame.position.set(0, 5.23, 0.015);
const bottomFrame = roundedBox(8.47, 0.31, 0.46, 0.10, mats.frame);
bottomFrame.position.set(0, 0.21, 0.015);
// Rear support structure.
cylinderBetween(
new THREE.Vector3(-3.55, 0.52, -0.12),
new THREE.Vector3(-3.72, 0.12, -1.13),
0.13,
mats.frameDark
);
cylinderBetween(
new THREE.Vector3(3.55, 0.52, -0.12),
new THREE.Vector3(3.72, 0.12, -1.13),
0.13,
mats.frameDark
);
const footL = roundedBox(1.45, 0.14, 0.76, 0.07, mats.frameDark);
footL.position.set(-3.70, 0.09, -0.92);
const footR = footL.clone();
footR.position.x = 3.70;
cylinderBetween(
new THREE.Vector3(-3.68, 1.05, -0.95),
new THREE.Vector3(3.68, 1.05, -0.95),
0.09,
mats.frameDark
);
// Gear train.
const gear1 = makeGear(0.68, 14, 0.14, 0.13, mats.coral);
gear1.position.set(-2.66, 3.70, 0.39);
scene.add(gear1);
const gear2 = makeGear(0.44, 10, 0.10, 0.095, mats.teal);
gear2.position.set(-1.55, 3.70, 0.40);
scene.add(gear2);
const gear3 = makeGear(0.42, 10, 0.10, 0.095, mats.yellow);
gear3.position.set(-1.55, 2.87, 0.41);
scene.add(gear3);
function mountAxle(x, y, z = 0.38, radius = 0.15) {
const axle = cylinderZ(radius, 0.22, mats.frameDark);
axle.position.set(x, y, z);
const cap = cylinderZ(radius * 0.55, 0.07, mats.metal);
cap.position.set(x, y, z + 0.14);
return cap;
}
mountAxle(-2.66, 3.70);
mountAxle(-1.55, 3.70);
mountAxle(-1.55, 2.87);
gear1.userData.action = "gear";
gear2.userData.action = "gear";
gear3.userData.action = "gear";
interactive.push(gear1, gear2, gear3);
animated.push((t, dt) => {
const impulse = gear1.userData.impulse || 0;
gear1.rotation.z += dt * (0.43 + impulse);
gear2.rotation.z -= dt * (0.67 + impulse * 1.25);
gear3.rotation.z += dt * (0.70 + impulse * 1.3);
gear1.userData.impulse = impulse * Math.exp(-dt * 2.2);
});
// Horizontal slider.
const hTrack = roundedBox(2.55, 0.18, 0.18, 0.085, mats.frameDark);
hTrack.position.set(2.12, 4.31, 0.34);
hTrack.userData.action = "hSlider";
interactive.push(hTrack);
const hGroove = roundedBox(2.32, 0.065, 0.055, 0.03, mats.ink);
hGroove.position.set(2.12, 4.31, 0.45);
for (let i = 0; i < 11; i++) {
const notch = roundedBox(0.045, 0.10, 0.035, 0.018, mats.yellowDark);
notch.position.set(1.08 + i * 0.208, 4.31, 0.48);
}
const hKnob = new THREE.Group();
hKnob.position.set(1.65, 4.31, 0.52);
scene.add(hKnob);
const hKnobBody = cylinderZ(0.285, 0.24, mats.blue);
hKnob.add(hKnobBody);
const hKnobCap = cylinderZ(0.14, 0.06, mats.cream);
hKnobCap.position.z = 0.15;
hKnob.add(hKnobCap);
hKnob.userData.action = "hSlider";
interactive.push(hKnobBody);
// Vertical slider.
const vTrack = roundedBox(0.18, 2.00, 0.18, 0.085, mats.frameDark);
vTrack.position.set(3.40, 2.52, 0.34);
vTrack.userData.action = "vSlider";
interactive.push(vTrack);
const vGroove = roundedBox(0.065, 1.78, 0.055, 0.03, mats.ink);
vGroove.position.set(3.40, 2.52, 0.45);
for (let i = 0; i < 9; i++) {
const notch = roundedBox(0.10, 0.045, 0.035, 0.018, mats.tealDark);
notch.position.set(3.40, 1.73 + i * 0.198, 0.48);
}
const vKnob = new THREE.Group();
vKnob.position.set(3.40, 2.36, 0.52);
scene.add(vKnob);
const vKnobBody = cylinderZ(0.275, 0.24, mats.purple);
vKnob.add(vKnobBody);
const vKnobCap = cylinderZ(0.14, 0.06, mats.cream);
vKnobCap.position.z = 0.15;
vKnob.add(vKnobCap);
vKnob.userData.action = "vSlider";
interactive.push(vKnobBody);
// Large rotary dial.
const dialBase = cylinderZ(0.49, 0.15, mats.frameDark);
dialBase.position.set(0.35, 2.72, 0.32);
const dial = new THREE.Group();
dial.position.set(0.35, 2.72, 0.46);
scene.add(dial);
const dialBody = cylinderZ(0.40, 0.20, mats.coral);
dial.add(dialBody);
const dialPointer = roundedBox(0.10, 0.30, 0.055, 0.04, mats.cream);
dialPointer.position.set(0, 0.16, 0.13);
dial.add(dialPointer);
const dialCap = cylinderZ(0.115, 0.065, mats.yellow);
dialCap.position.z = 0.14;
dial.add(dialCap);
dialBody.userData.action = "dial";
interactive.push(dialBody);
// Opening 1: a colorful three-petal spinner.
const leftRing = torus(0.48, 0.075, mats.coral);
leftRing.position.set(-3.05, 1.18, 0.19);
const leftRotor = new THREE.Group();
leftRotor.position.set(-3.05, 1.18, 0.015);
scene.add(leftRotor);
const leftDisc = new THREE.Mesh(
new THREE.CircleGeometry(0.36, 40),
mats.cream
);
leftDisc.castShadow = true;
leftRotor.add(leftDisc);
for (let i = 0; i < 3; i++) {
const petal = roundedBox(0.45, 0.15, 0.07, 0.07, i === 0 ? mats.teal : i === 1 ? mats.yellow : mats.purple);
const a = i * Math.PI * 2 / 3;
petal.position.set(Math.cos(a) * 0.16, Math.sin(a) * 0.16, 0.06);
petal.rotation.z = a;
leftRotor.add(petal);
}
const leftHub = cylinderZ(0.10, 0.08, mats.frameDark);
leftHub.position.z = 0.10;
leftRotor.add(leftHub);
leftDisc.userData.action = "rotor";
interactive.push(leftDisc);
animated.push((t, dt) => {
leftRotor.rotation.z -= dt * (0.8 + (leftRotor.userData.impulse || 0));
leftRotor.userData.impulse = (leftRotor.userData.impulse || 0) * Math.exp(-dt * 2.2);
});
// Opening 2: a recessed rectangular module with a small moving peg.
const middleBack = roundedBox(1.13, 0.70, 0.08, 0.14, mats.yellow);
middleBack.position.set(-1.55, 1.45, -0.08);
const middleTop = roundedBox(1.44, 0.12, 0.16, 0.055, mats.teal);
middleTop.position.set(-1.55, 1.91, 0.19);
const middleBottom = middleTop.clone();
middleBottom.position.y = 0.99;
const middleLeft = roundedBox(0.12, 0.87, 0.16, 0.055, mats.teal);
middleLeft.position.set(-2.24, 1.45, 0.19);
const middleRight = middleLeft.clone();
middleRight.position.x = -0.86;
const middleButton = roundedBox(0.36, 0.30, 0.16, 0.09, mats.coral);
middleButton.position.set(-1.72, 1.45, 0.08);
middleButton.userData.action = "rotor";
interactive.push(middleButton);
animated.push((t) => {
middleButton.position.y = 1.45 + Math.sin(t * 1.25) * 0.13;
});
// Opening 3: a spoked wheel.
const rightRing = torus(0.56, 0.08, mats.teal);
rightRing.position.set(2.66, 1.17, 0.19);
const rightRotor = new THREE.Group();
rightRotor.position.set(2.66, 1.17, 0.01);
scene.add(rightRotor);
const rightHub = cylinderZ(0.16, 0.11, mats.frameDark);
rightHub.position.z = 0.075;
rightRotor.add(rightHub);
for (let i = 0; i < 6; i++) {
const spoke = roundedBox(0.78, 0.095, 0.07, 0.04, i % 2 ? mats.yellow : mats.coral);
spoke.rotation.z = i * Math.PI / 3;
spoke.position.z = 0.04;
rightRotor.add(spoke);
}
rightHub.userData.action = "rotor";
interactive.push(rightHub);
animated.push((t, dt) => {
rightRotor.rotation.z += dt * (0.55 + (rightRotor.userData.impulse || 0));
rightRotor.userData.impulse = (rightRotor.userData.impulse || 0) * Math.exp(-dt * 2.2);
});
// Opening 4: a high sun-like wheel.
const topRing = torus(0.40, 0.065, mats.purple);
topRing.position.set(0.15, 3.95, 0.19);
const topRotor = new THREE.Group();
topRotor.position.set(0.15, 3.95, 0.015);
scene.add(topRotor);
const topDisc = new THREE.Mesh(new THREE.CircleGeometry(0.30, 40), mats.yellow);
topRotor.add(topDisc);
for (let i = 0; i < 6; i++) {
const a = i * Math.PI / 3;
const dot = new THREE.Mesh(new THREE.CircleGeometry(0.073, 24), i % 2 ? mats.coral : mats.teal);
dot.position.set(Math.cos(a) * 0.17, Math.sin(a) * 0.17, 0.04);
topRotor.add(dot);
}
topDisc.userData.action = "rotor";
interactive.push(topDisc);
animated.push((t, dt) => {
topRotor.rotation.z -= dt * 0.62;
});
// Raised tactile bumps and frame fasteners.
const bumpPositions = [
[-3.55, 4.50], [-3.15, 4.77], [-2.72, 4.62],
[3.66, 0.62], [3.20, 0.63], [2.75, 0.65],
[-0.35, 0.72], [0.25, 0.72], [0.85, 0.72]
];
bumpPositions.forEach(([x, y], i) => {
const bump = new THREE.Mesh(
new THREE.SphereGeometry(0.10, 24, 16),
i % 3 === 0 ? mats.coral : i % 3 === 1 ? mats.teal : mats.yellow
);
bump.scale.z = 0.55;
bump.position.set(x, y, 0.23);
bump.castShadow = true;
scene.add(bump);
});
addScrew(-3.82, 5.00);
addScrew(3.82, 5.00);
addScrew(-3.82, 0.44);
addScrew(3.82, 0.44);
addScrew(0, 5.00);
makeLabel("01 TURN", -2.30, 4.62, 1.38, "#fff4dc");
makeLabel("02 SLIDE", 2.16, 4.74, 1.42, "#fff4dc");
makeLabel("03 CONNECT", 0.30, 2.05, 1.56, "#34444b", "#fff4dc");
makeLabel("PEEK", -2.46, 0.69, 0.98, "#fff4dc");
// Front-facing colored connection tubes.
const connectionCurves = [];
function makeConnection(points, color, casingColor = 0x3e4b50) {
const curve = new THREE.CatmullRomCurve3(
points.map(p => new THREE.Vector3(...p)),
false,
"catmullrom",
0.28
);
const casing = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.078, 10, false),
standard(casingColor, { roughness: 0.8 })
);
casing.castShadow = true;
scene.add(casing);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.050, 10, false),
standard(color, { roughness: 0.48 })
);
tube.castShadow = true;
scene.add(tube);
connectionCurves.push(curve);
return curve;
}
makeConnection([
[-2.66, 3.70, 0.255],
[-2.16, 3.48, 0.25],
[-1.35, 3.05, 0.25],
[-0.45, 2.78, 0.25],
[0.35, 2.72, 0.29]
], COLORS.coral);
makeConnection([
[0.35, 2.72, 0.27],
[0.95, 2.93, 0.25],
[1.43, 3.62, 0.25],
[2.34, 4.31, 0.25],
[3.10, 4.31, 0.29]
], COLORS.yellow);
makeConnection([
[3.40, 2.52, 0.27],
[3.48, 2.14, 0.25],
[3.25, 1.55, 0.25],
[2.66, 1.17, 0.29]
], COLORS.blue);
makeConnection([
[-3.05, 1.18, 0.27],
[-2.58, 1.08, 0.25],
[-2.12, 1.43, 0.25],
[-1.55, 1.45, 0.29]
], COLORS.teal);
// Small energy beads travel along the connections.
const beadColors = [COLORS.coral, COLORS.yellow, COLORS.blue, COLORS.teal];
const beads = [];
connectionCurves.forEach((curve, curveIndex) => {
for (let i = 0; i < 2; i++) {
const bead = new THREE.Mesh(
new THREE.SphereGeometry(0.068, 20, 14),
new THREE.MeshStandardMaterial({
color: beadColors[curveIndex],
roughness: 0.35,
emissive: beadColors[curveIndex],
emissiveIntensity: 0.18
})
);
bead.castShadow = true;
scene.add(bead);
beads.push({ mesh: bead, curve, offset: i * 0.5, speed: 0.12 + curveIndex * 0.018 });
}
});
// Slider states.
let horizontalManual = false;
let verticalManual = false;
let horizontalTarget = 1.65;
let verticalTarget = 2.36;
let dialDirection = 1;
animated.push((t, dt) => {
if (!horizontalManual) {
horizontalTarget = 2.12 + Math.sin(t * 0.72) * 0.91;
}
if (!verticalManual) {
verticalTarget = 2.52 + Math.sin(t * 0.63 + 1.2) * 0.70;
}
const smoothing = 1 - Math.exp(-dt * 4.2);
hKnob.position.x += (horizontalTarget - hKnob.position.x) * smoothing;
vKnob.position.y += (verticalTarget - vKnob.position.y) * smoothing;
dial.rotation.z += dt * dialDirection * 0.28;
dial.userData.impulse = (dial.userData.impulse || 0) * Math.exp(-dt * 2.1);
beads.forEach(({ mesh, curve, offset, speed }) => {
const progress = (t * speed + offset) % 1;
mesh.position.copy(curve.getPointAt(progress));
});
});
// Custom front-access orbit controls; no external control add-ons.
const orbit = {
azimuth: 0.075,
elevation: 0.105,
zoom: 1,
target: new THREE.Vector3(0, 2.62, 0.02)
};
function updateCamera() {
const aspectCompensation = Math.max(1, 1.14 / camera.aspect);
const distance = THREE.MathUtils.clamp(
10.25 * aspectCompensation * orbit.zoom,
8.2,
19
);
const cosElevation = Math.cos(orbit.elevation);
camera.position.set(
orbit.target.x + Math.sin(orbit.azimuth) * cosElevation * distance,
orbit.target.y + Math.sin(orbit.elevation) * distance,
orbit.target.z + Math.cos(orbit.azimuth) * cosElevation * distance
);
camera.lookAt(orbit.target);
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
updateCamera();
}
addEventListener("resize", resize);
resize();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointerState = {
down: false,
moved: false,
startX: 0,
startY: 0,
lastX: 0,
lastY: 0
};
function setPointer(event) {
pointer.x = (event.clientX / innerWidth) * 2 - 1;
pointer.y = -(event.clientY / innerHeight) * 2 + 1;
}
function pick(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(interactive, false)[0] || null;
}
renderer.domElement.addEventListener("pointerdown", event => {
pointerState.down = true;
pointerState.moved = false;
pointerState.startX = pointerState.lastX = event.clientX;
pointerState.startY = pointerState.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (pointerState.down) {
const dx = event.clientX - pointerState.lastX;
const dy = event.clientY - pointerState.lastY;
if (Math.hypot(
event.clientX - pointerState.startX,
event.clientY - pointerState.startY
) > 5) {
pointerState.moved = true;
}
orbit.azimuth = THREE.MathUtils.clamp(
orbit.azimuth - dx * 0.0042,
-0.72,
0.72
);
orbit.elevation = THREE.MathUtils.clamp(
orbit.elevation + dy * 0.0028,
-0.08,
0.42
);
updateCamera();
} else {
const hit = pick(event);
renderer.domElement.style.cursor = hit ? "pointer" : "grab";
}
pointerState.lastX = event.clientX;
pointerState.lastY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", event => {
if (!pointerState.moved) {
const hit = pick(event);
if (hit) {
const action = hit.object.userData.action;
const point = hit.point;
if (action === "gear") {
hit.object.userData.impulse = 2.8;
} else if (action === "dial") {
dialDirection *= -1;
dial.userData.impulse = 1.8;
} else if (action === "rotor") {
if (hit.object.parent) hit.object.parent.userData.impulse = 2.2;
} else if (action === "hSlider") {
horizontalManual = true;
horizontalTarget = THREE.MathUtils.clamp(point.x, 1.02, 3.22);
} else if (action === "vSlider") {
verticalManual = true;
verticalTarget = THREE.MathUtils.clamp(point.y, 1.72, 3.32);
}
}
}
pointerState.down = false;
renderer.domElement.releasePointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerState.down = false;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom + event.deltaY * 0.00075,
0.78,
1.36
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
orbit.azimuth = 0.075;
orbit.elevation = 0.105;
orbit.zoom = 1;
updateCamera();
});
renderer.domElement.style.cursor = "grab";
const clock = new THREE.Clock();
function render() {
requestAnimationFrame(render);
const dt = Math.min(clock.getDelta(), 0.05);
const t = clock.elapsedTime;
animated.forEach(fn => fn(t, dt));
renderer.render(scene, camera);
}
render();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```