Prompt specification
Build or customize the Three.js 3D scene "Two telephone rooms joined by a wire" 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: Two telephone rooms joined by a wire
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-telephone-rooms-joined-by-a-wire-x2546
Scene Description Prompt:
Two telephone rooms joined by a wire. Create two small room vignettes connected by a schematic line. Synchronize voice-wave animation, electrical signal display, and receiver motion without presenting the waveforms as measured audio. Please build this with Three.js from cdnjs in one self-contained HTML file, using a 3D cutaway.
Working Three.js Starter (two-telephone-rooms-joined-by-a-wire-x2546):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Two Telephone Rooms — Phase-Locked Schematic</title>
<style>
:root {
color-scheme: dark;
--bg: #071018;
--panel: rgba(10, 21, 31, 0.78);
--border: rgba(166, 207, 224, 0.2);
--text: #eef7fb;
--muted: #9eb4c0;
--amber: #f3a75f;
--cyan: #63d9e8;
--wire: #f4d27d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--text);
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 24px;
left: 28px;
right: 28px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--wire);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3.3vw, 44px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 650;
}
.subtitle {
max-width: 570px;
margin: 11px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.status {
min-width: 210px;
padding: 12px 15px;
border: 1px solid var(--border);
border-radius: 12px;
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 12px 38px rgba(0, 0, 0, 0.2);
}
.status-row {
display: flex;
align-items: center;
gap: 9px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #80e5af;
box-shadow: 0 0 12px #80e5af;
animation: breathe 1.6s ease-in-out infinite;
}
.status-dot.paused {
background: #8b9ba4;
box-shadow: none;
animation: none;
}
.status-detail {
margin-top: 7px;
color: var(--muted);
font-size: 11px;
line-height: 1.4;
}
@keyframes breathe {
50% {
opacity: 0.4;
transform: scale(0.75);
}
}
.legend {
position: absolute;
left: 28px;
bottom: 26px;
width: min(430px, calc(100vw - 56px));
padding: 15px 17px;
border: 1px solid var(--border);
border-radius: 14px;
background: var(--panel);
backdrop-filter: blur(12px);
box-shadow: 0 14px 42px rgba(0, 0, 0, 0.24);
}
.legend-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 13px;
}
.legend-item {
min-width: 0;
}
.legend-label {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 5px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.swatch {
width: 15px;
height: 3px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--wire);
box-shadow: 0 0 8px currentColor;
}
.swatch.voice {
background: linear-gradient(90deg, var(--amber), var(--cyan));
}
.swatch.signal {
background: #80e5af;
}
.swatch.receiver {
background: #d7e6ed;
}
.legend-copy {
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.disclaimer {
margin-top: 13px;
padding-top: 11px;
border-top: 1px solid rgba(166, 207, 224, 0.12);
color: #b7c8d1;
font-size: 10px;
line-height: 1.5;
}
.disclaimer strong {
color: var(--wire);
font-weight: 750;
}
.controls {
position: absolute;
right: 28px;
bottom: 26px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid var(--border);
border-radius: 10px;
padding: 10px 13px;
background: rgba(12, 25, 36, 0.86);
color: var(--text);
font: inherit;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
background: rgba(25, 47, 61, 0.94);
border-color: rgba(166, 207, 224, 0.42);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--wire);
outline-offset: 3px;
}
.hint {
position: absolute;
top: 50%;
right: 18px;
transform: translateY(-50%);
writing-mode: vertical-rl;
color: rgba(185, 207, 217, 0.55);
font-size: 9px;
letter-spacing: 0.16em;
text-transform: uppercase;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #071018;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.topbar {
top: 17px;
left: 18px;
right: 18px;
}
.status {
display: none;
}
.subtitle {
max-width: 92vw;
}
.legend {
left: 18px;
bottom: 18px;
width: calc(100vw - 36px);
}
.legend-grid {
grid-template-columns: 1fr 1fr;
}
.legend-item:last-child {
display: none;
}
.controls {
right: 18px;
bottom: 176px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="ui">
<header class="topbar">
<div>
<div class="eyebrow">Phase-locked communication study</div>
<h1>Two telephone rooms,<br />one shared signal.</h1>
<p class="subtitle">
A 3D cutaway of two separated telephone spaces, joined by a
schematic wire. Voice cues, electrical displays, and receiver motion
share one animation phase.
</p>
</div>
<aside class="status">
<div class="status-row">
<span id="statusDot" class="status-dot"></span>
<span id="statusText">System running</span>
</div>
<div class="status-detail">
Voice · electrical trace · receiver motion are synchronized.
</div>
</aside>
</header>
<section class="legend">
<div class="legend-grid">
<div class="legend-item">
<div class="legend-label">
<span class="swatch voice"></span>
Voice cue
</div>
<div class="legend-copy">Abstract, phase-driven room waveform.</div>
</div>
<div class="legend-item">
<div class="legend-label">
<span class="swatch signal"></span>
Electrical
</div>
<div class="legend-copy">Simulated pulse display on both scopes.</div>
</div>
<div class="legend-item">
<div class="legend-label">
<span class="swatch receiver"></span>
Receiver
</div>
<div class="legend-copy">Shared lift, tilt, and pulse motion.</div>
</div>
</div>
<div class="disclaimer">
<strong>Conceptual visualization only.</strong>
No microphone, recording, or measured audio waveform is represented.
The traces and moving elements are illustrative signals.
</div>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="pauseButton" type="button">Pause motion</button>
<button id="resetButton" type="button">Reset view</button>
</nav>
<div class="hint">Drag to orbit · wheel to zoom · double-click to reset</div>
</div>
<div id="loading">Assembling telephone rooms…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const pauseButton = document.getElementById("pauseButton");
const resetButton = document.getElementById("resetButton");
const statusText = document.getElementById("statusText");
const statusDot = document.getElementById("statusDot");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071018);
scene.fog = new THREE.FogExp2(0x071018, 0.027);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.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 3D cutaway showing two telephone rooms linked by a schematic wire"
);
stage.appendChild(renderer.domElement);
const AMBER = 0xf3a75f;
const CYAN = 0x63d9e8;
const WIRE = 0xf4d27d;
const GREEN = 0x80e5af;
const standard = (color, roughness = 0.68, metalness = 0.08) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const basic = (color, opacity = 1) =>
new THREE.MeshBasicMaterial({
color,
transparent: opacity < 1,
opacity,
toneMapped: false
});
const materials = {
ground: standard(0x08121a, 0.94, 0.02),
floorA: standard(0x18242d, 0.82, 0.08),
floorB: standard(0x14242d, 0.82, 0.08),
wallA: standard(0x273038, 0.9, 0.02),
wallB: standard(0x213039, 0.9, 0.02),
trim: standard(0x63757f, 0.46, 0.42),
desk: standard(0x5e4534, 0.72, 0.05),
deskEdge: standard(0x87654c, 0.6, 0.08),
phone: standard(0x171a1d, 0.42, 0.2),
phoneHighlight: standard(0x282b2e, 0.5, 0.22),
brass: standard(0xc69b5d, 0.35, 0.72),
rubber: standard(0x090b0d, 0.86, 0.02),
scope: standard(0x172128, 0.52, 0.3),
seat: standard(0x33474f, 0.88, 0.02),
glass: new THREE.MeshPhysicalMaterial({
color: 0x9ed6e2,
roughness: 0.18,
metalness: 0,
transparent: true,
opacity: 0.09,
depthWrite: false,
side: THREE.DoubleSide
})
};
function addBox(
width,
height,
depth,
material,
x,
y,
z,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
radius,
height,
material,
x,
y,
z,
parent = scene,
radialSegments = 20
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, height, radialSegments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function tubeFromPoints(points, radius, material, parent = scene, segments = 64) {
const curve = new THREE.CatmullRomCurve3(
points.map((point) => new THREE.Vector3(...point)),
false,
"catmullrom",
0.25
);
const mesh = new THREE.Mesh(
new THREE.TubeGeometry(curve, segments, radius, 8, false),
material
);
mesh.castShadow = true;
parent.add(mesh);
return { mesh, curve };
}
function makeLabel(text, accentHex, width = 2.4) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(7, 16, 24, 0.88)";
ctx.fillRect(6, 6, 1012, 244);
ctx.strokeStyle = accentHex;
ctx.lineWidth = 5;
ctx.strokeRect(7, 7, 1010, 242);
ctx.fillStyle = accentHex;
ctx.fillRect(30, 30, 12, 196);
ctx.fillStyle = "#f1f8fb";
ctx.font = "700 54px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 535, 132);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 20;
return sprite;
}
function createScope(code, accentHex) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 256;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
});
const plane = new THREE.Mesh(new THREE.PlaneGeometry(0.74, 0.37), material);
plane.renderOrder = 2;
return {
code,
accentHex,
canvas,
ctx: canvas.getContext("2d"),
texture,
plane
};
}
function drawScope(scope, phase) {
const { ctx, canvas, accentHex, code } = scope;
const width = canvas.width;
const height = canvas.height;
ctx.fillStyle = "#06120f";
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = "rgba(112, 191, 143, 0.11)";
ctx.lineWidth = 1;
for (let x = 38; x < width - 24; x += 32) {
ctx.beginPath();
ctx.moveTo(x, 62);
ctx.lineTo(x, 202);
ctx.stroke();
}
for (let y = 62; y <= 202; y += 28) {
ctx.beginPath();
ctx.moveTo(38, y);
ctx.lineTo(width - 24, y);
ctx.stroke();
}
ctx.fillStyle = accentHex;
ctx.font = "700 20px ui-monospace, SFMono-Regular, monospace";
ctx.textAlign = "left";
ctx.fillText(`ELECTRICAL / ${code}`, 24, 31);
ctx.fillStyle = "#8eb49f";
ctx.font = "14px ui-monospace, SFMono-Regular, monospace";
ctx.textAlign = "right";
ctx.fillText("SIMULATED", width - 24, 31);
const left = 38;
const right = width - 24;
const centerY = 132;
const plotWidth = right - left;
const steps = 64;
ctx.strokeStyle = accentHex;
ctx.lineWidth = 3;
ctx.lineJoin = "round";
ctx.beginPath();
for (let i = 0; i <= steps; i++) {
const u = i / steps;
const carrier = Math.sin(phase * 1.55 + u * Math.PI * 14);
const pulse = Math.tanh(carrier * 5);
const envelope = 0.56 + 0.44 * Math.sin(phase * 0.72 + u * 3.0);
const y = centerY - pulse * 27 * envelope;
const x = left + u * plotWidth;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
const cursorU = (phase / (Math.PI * 2)) % 1;
const cursorX = left + cursorU * plotWidth;
ctx.strokeStyle = "rgba(255, 255, 255, 0.28)";
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(cursorX, 61);
ctx.lineTo(cursorX, 203);
ctx.stroke();
ctx.fillStyle = "#a6c4b2";
ctx.font = "14px ui-monospace, SFMono-Regular, monospace";
ctx.textAlign = "left";
ctx.fillText("ILLUSTRATIVE TRACE — NOT MEASURED AUDIO", 24, 231);
scope.texture.needsUpdate = true;
}
// Ground and grid.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
materials.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.2;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(50, 50, 0x294252, 0x142733);
grid.position.y = -0.185;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// Lighting.
scene.add(new THREE.HemisphereLight(0xbadce8, 0x182029, 1.35));
const key = new THREE.DirectionalLight(0xd9efff, 3.0);
key.position.set(5, 11, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 11;
key.shadow.camera.bottom = -7;
key.shadow.camera.near = 1;
key.shadow.camera.far = 30;
key.shadow.bias = -0.0005;
scene.add(key);
const rim = new THREE.DirectionalLight(0xffb26d, 1.5);
rim.position.set(-10, 6, -5);
scene.add(rim);
const coolRim = new THREE.DirectionalLight(0x69d9ff, 1.1);
coolRim.position.set(10, 4, -4);
scene.add(coolRim);
const rooms = [];
const scopes = [];
const phones = [];
const waves = [];
function buildRoom(centerX, index) {
const isLeft = index === 0;
const accent = isLeft ? AMBER : CYAN;
const accentHex = isLeft ? "#f3a75f" : "#63d9e8";
const wallMaterial = isLeft ? materials.wallA : materials.wallB;
const floorMaterial = isLeft ? materials.floorA : materials.floorB;
const room = {
centerX,
accent,
accentHex,
innerX: centerX + (isLeft ? 2.08 : -2.08),
outerX: centerX + (isLeft ? -2.08 : 2.08)
};
// Raised room slab.
addBox(
4.38,
0.25,
3.65,
standard(isLeft ? 0x111c24 : 0x102029, 0.8, 0.06),
centerX,
0.01,
0
);
addBox(4.2, 0.16, 3.45, floorMaterial, centerX, 0.21, 0);
// Full back wall, absent ceiling and front wall create the cutaway.
addBox(4.2, 3.0, 0.14, wallMaterial, centerX, 1.79, -1.65);
// Outer wall is solid below and ghosted above.
addBox(
0.13,
0.95,
3.42,
wallMaterial,
room.outerX,
0.765,
0
);
const upperOuter = addBox(
0.09,
2.08,
3.42,
materials.glass,
room.outerX,
2.26,
0,
scene,
false
);
upperOuter.renderOrder = 1;
// Bright cut edges.
const edgeMaterial = basic(accent, 0.55);
addBox(0.045, 3.05, 0.055, edgeMaterial, room.innerX, 1.79, 1.71, scene, false);
addBox(4.2, 0.035, 0.045, edgeMaterial, centerX, 3.29, -1.56, scene, false);
addBox(4.2, 0.035, 0.045, edgeMaterial, centerX, 0.31, 1.71, scene, false);
// Back-wall framing.
addBox(0.08, 3.02, 0.08, materials.trim, centerX - 2.06, 1.79, -1.54);
addBox(0.08, 3.02, 0.08, materials.trim, centerX + 2.06, 1.79, -1.54);
addBox(4.12, 0.08, 0.08, materials.trim, centerX, 3.28, -1.54);
// Acoustic slats.
const slatMaterial = standard(
isLeft ? 0x4a4038 : 0x304851,
0.9,
0.03
);
for (let i = 0; i < 7; i++) {
addBox(
0.075,
1.05,
0.065,
slatMaterial,
centerX - 1.62 + i * 0.17,
2.22,
-1.53
);
}
// Desk.
addBox(
2.5,
0.14,
0.9,
materials.desk,
centerX - 0.08,
1.12,
-0.15
);
addBox(
2.52,
0.055,
0.92,
materials.deskEdge,
centerX - 0.08,
1.205,
-0.15
);
addBox(
0.13,
0.85,
0.64,
materials.desk,
centerX - 1.05,
0.66,
-0.19
);
addBox(
0.13,
0.85,
0.13,
materials.trim,
centerX + 0.85,
0.66,
-0.42
);
addBox(
0.13,
0.85,
0.13,
materials.trim,
centerX + 0.85,
0.66,
0.12
);
// Drawer details.
addBox(
0.02,
0.02,
0.23,
materials.brass,
centerX - 0.98,
0.89,
-0.12
);
addBox(
0.02,
0.02,
0.23,
materials.brass,
centerX - 0.98,
0.57,
-0.12
);
// Stool.
addCylinder(0.31, 0.13, materials.seat, centerX - 1.17, 0.72, 0.63);
addCylinder(0.055, 0.47, materials.trim, centerX - 1.17, 0.43, 0.63);
addCylinder(0.24, 0.05, materials.trim, centerX - 1.17, 0.19, 0.63);
// Wall lamp.
const lamp = new THREE.Mesh(
new THREE.SphereGeometry(0.12, 20, 12),
basic(accent, 0.9)
);
lamp.position.set(centerX + 1.77, 2.8, -1.43);
scene.add(lamp);
const lampLight = new THREE.PointLight(accent, 14, 4.2, 2);
lampLight.position.copy(lamp.position);
scene.add(lampLight);
const label = makeLabel(
isLeft ? "ROOM A / LOCAL" : "ROOM B / REMOTE",
accentHex,
2.65
);
label.position.set(centerX, 3.56, -1.38);
scene.add(label);
// Wall-mounted signal scope.
addBox(
0.9,
0.64,
0.2,
materials.scope,
centerX + 1.14,
1.82,
-1.48
);
addCylinder(
0.055,
0.06,
materials.brass,
centerX + 1.45,
1.61,
-1.34,
scene,
16
).rotation.x = Math.PI / 2;
const scope = createScope(isLeft ? "TX" : "RX", accentHex);
scope.plane.position.set(centerX + 1.14, 1.84, -1.372);
scene.add(scope.plane);
scopes.push(scope);
// Wall jack, with the connecting wire routed from it.
const jackX = isLeft ? -2.55 : 2.55;
room.jackX = jackX;
addBox(
0.3,
0.38,
0.12,
materials.scope,
jackX,
1.17,
-1.49
);
addCylinder(
0.075,
0.04,
materials.brass,
jackX,
1.17,
-1.415,
scene,
20
).rotation.x = Math.PI / 2;
rooms.push(room);
return room;
}
const roomA = buildRoom(-4.25, 0);
const roomB = buildRoom(4.25, 1);
function buildPhone(room) {
const phone = {
room,
group: new THREE.Group(),
receiver: null,
x: room.centerX - 0.25,
z: -0.16,
baseY: 2.02
};
phone.group.position.set(phone.x, 0, phone.z);
scene.add(phone.group);
// Rounded Bakelite base.
const base = new THREE.Mesh(
new THREE.SphereGeometry(1, 36, 20),
materials.phone
);
base.scale.set(0.56, 0.21, 0.4);
base.position.y = 1.36;
base.castShadow = true;
base.receiveShadow = true;
phone.group.add(base);
const baseHighlight = new THREE.Mesh(
new THREE.SphereGeometry(1, 28, 16),
materials.phoneHighlight
);
baseHighlight.scale.set(0.48, 0.12, 0.34);
baseHighlight.position.set(0, 1.43, 0.01);
phone.group.add(baseHighlight);
// Upright.
const upright = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 18),
materials.phone
);
upright.scale.set(0.25, 0.48, 0.2);
upright.position.set(0, 1.72, -0.12);
upright.castShadow = true;
phone.group.add(upright);
// Rotary dial.
const dial = addCylinder(
0.235,
0.055,
materials.phoneHighlight,
0,
1.36,
0.39,
phone.group,
40
);
dial.rotation.x = Math.PI / 2;
const dialRing = new THREE.Mesh(
new THREE.TorusGeometry(0.195, 0.018, 10, 42),
materials.brass
);
dialRing.position.set(0, 1.36, 0.423);
phone.group.add(dialRing);
for (let i = 0; i < 10; i++) {
const angle = -Math.PI * 0.78 + (i / 9) * Math.PI * 1.55;
const hole = new THREE.Mesh(
new THREE.SphereGeometry(0.025, 12, 8),
materials.rubber
);
hole.position.set(
Math.cos(angle) * 0.145,
1.36 + Math.sin(angle) * 0.145,
0.438
);
hole.scale.z = 0.35;
phone.group.add(hole);
}
// Cradle supports.
addBox(
0.11,
0.08,
0.18,
materials.brass,
-0.34,
1.93,
0.02,
phone.group
);
addBox(
0.11,
0.08,
0.18,
materials.brass,
0.34,
1.93,
0.02,
phone.group
);
// Receiver group: curved handle and two earpieces.
const receiver = new THREE.Group();
receiver.position.set(0, phone.baseY, 0.02);
phone.group.add(receiver);
const handleCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-0.34, 0, 0),
new THREE.Vector3(-0.25, 0.13, 0),
new THREE.Vector3(0, 0.19, 0),
new THREE.Vector3(0.25, 0.13, 0),
new THREE.Vector3(0.34, 0, 0)
]);
const handle = new THREE.Mesh(
new THREE.TubeGeometry(handleCurve, 28, 0.055, 10, false),
materials.phoneHighlight
);
handle.castShadow = true;
receiver.add(handle);
for (const x of [-0.36, 0.36]) {
const earpiece = addCylinder(
0.12,
0.22,
materials.phone,
x,
0,
0,
receiver,
24
);
earpiece.rotation.z = Math.PI / 2;
const cap = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 20, 12),
materials.rubber
);
cap.scale.x = 0.55;
cap.position.set(x + Math.sign(x) * 0.11, 0, 0);
receiver.add(cap);
}
phone.receiver = receiver;
// A visible cord from phone to the wall jack.
const midpoint = (phone.x + room.jackX) * 0.5;
tubeFromPoints(
[
[phone.x + 0.51, 1.36, phone.z - 0.05],
[phone.x + 0.86, 1.1, phone.z - 0.2],
[midpoint, 0.98, -1.08],
[room.jackX, 1.17, -1.41]
],
0.026,
materials.rubber,
scene,
48
);
phones.push(phone);
return phone;
}
const phoneA = buildPhone(roomA);
const phoneB = buildPhone(roomB);
// The central schematic wire.
const wirePoints = [
[-2.55, 1.17, -1.41],
[-2.52, 0.58, -1.41],
[-1.65, 0.43, -1.12],
[0, 0.39, -0.82],
[1.65, 0.43, -1.12],
[2.52, 0.58, -1.41],
[2.55, 1.17, -1.41]
];
const wireCurve = new THREE.CatmullRomCurve3(
wirePoints.map((p) => new THREE.Vector3(...p)),
false,
"catmullrom",
0.18
);
const wireGlow = new THREE.Mesh(
new THREE.TubeGeometry(wireCurve, 100, 0.09, 10, false),
basic(WIRE, 0.08)
);
wireGlow.renderOrder = 1;
scene.add(wireGlow);
const wire = new THREE.Mesh(
new THREE.TubeGeometry(wireCurve, 100, 0.025, 8, false),
basic(WIRE, 0.95)
);
scene.add(wire);
// Junction nodes.
const nodeGeometry = new THREE.SphereGeometry(0.065, 14, 10);
const nodeMaterial = basic(WIRE, 0.92);
for (const u of [0, 0.25, 0.5, 0.75, 1]) {
const node = new THREE.Mesh(nodeGeometry, nodeMaterial);
node.position.copy(wireCurve.getPoint(u));
scene.add(node);
}
// Moving schematic packets.
const packets = [];
const packetGeometry = new THREE.SphereGeometry(0.055, 12, 8);
for (let i = 0; i < 16; i++) {
const packet = new THREE.Mesh(
packetGeometry,
basic(i % 3 === 0 ? 0xffffff : WIRE, 0.95)
);
packets.push(packet);
scene.add(packet);
}
const wireLabel = makeLabel("SCHEMATIC CONNECTION", "#f4d27d", 2.15);
wireLabel.position.set(0, 0.78, -0.48);
scene.add(wireLabel);
function buildWave(phone, accentHex) {
const segments = 58;
const positions = new Float32Array((segments + 1) * 3);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color: accentHex,
transparent: true,
opacity: 0.95,
toneMapped: false
})
);
line.frustumCulled = false;
line.renderOrder = 5;
scene.add(line);
const beads = [];
const beadGeometry = new THREE.SphereGeometry(0.032, 10, 8);
for (let i = 0; i < 7; i++) {
const bead = new THREE.Mesh(beadGeometry, basic(accentHex, 0.95));
beads.push(bead);
scene.add(bead);
}
const rings = [];
const ringGeometry = new THREE.TorusGeometry(0.15, 0.009, 8, 40);
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
ringGeometry,
basic(accentHex, 0.4 - i * 0.08)
);
ring.rotation.x = Math.PI / 2;
scene.add(ring);
rings.push(ring);
}
const wave = {
phone,
accentHex,
segments,
positions,
geometry,
line,
beads,
rings
};
waves.push(wave);
return wave;
}
buildWave(phoneA, "#f3a75f");
buildWave(phoneB, "#63d9e8");
const tempPoint = new THREE.Vector3();
function sampleWave(wave, u, phase, out) {
const envelope = Math.sin(Math.PI * u);
out.set(
wave.phone.x +
Math.sin(u * 10.0 + phase) * 0.17 * envelope,
wave.phone.baseY +
u * 1.13 +
Math.sin(u * 12.0 - phase) * 0.07 * envelope,
wave.phone.z +
0.33 +
Math.cos(u * 8.0 + phase) * 0.13 * envelope
);
return out;
}
function updateWave(wave, phase) {
const receiver = wave.phone.receiver;
const receiverY = wave.phone.baseY + Math.sin(phase) * 0.095;
for (let i = 0; i <= wave.segments; i++) {
const u = i / wave.segments;
sampleWave(wave, u, phase, tempPoint);
const offset = i * 3;
wave.positions[offset] = tempPoint.x;
wave.positions[offset + 1] =
tempPoint.y - (receiverY - wave.phone.baseY);
wave.positions[offset + 2] = tempPoint.z;
}
wave.geometry.attributes.position.needsUpdate = true;
for (let i = 0; i < wave.beads.length; i++) {
const u = (i + 1) / (wave.beads.length + 1);
sampleWave(wave, u, phase, tempPoint);
tempPoint.y -= receiverY - wave.phone.baseY;
wave.beads[i].position.copy(tempPoint);
}
for (let i = 0; i < wave.rings.length; i++) {
const cycle = (phase / (Math.PI * 2) + i / wave.rings.length) % 1;
const scale = 0.8 + cycle * 3.1;
wave.rings[i].position.set(
wave.phone.x,
receiverY + cycle * 0.4,
wave.phone.z + 0.37
);
wave.rings[i].scale.setScalar(scale);
wave.rings[i].material.opacity = 0.36 * (1 - cycle);
}
}
// Custom orbit camera implemented without external controls.
const target = new THREE.Vector3(0, 1.2, 0);
const defaultCamera = {
azimuth: 0.46,
polar: 1.03,
radius: 15.8
};
let azimuth = defaultCamera.azimuth;
let polar = defaultCamera.polar;
let radius = defaultCamera.radius;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
polar = THREE.MathUtils.clamp(polar, 0.48, 1.43);
radius = THREE.MathUtils.clamp(radius, 9.5, 23);
const sinPolar = Math.sin(polar);
camera.position.set(
target.x + radius * sinPolar * Math.sin(azimuth),
target.y + radius * Math.cos(polar),
target.z + radius * sinPolar * Math.cos(azimuth)
);
camera.lookAt(target);
}
function resetCamera() {
azimuth = defaultCamera.azimuth;
polar = defaultCamera.polar;
radius = defaultCamera.radius;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
azimuth -= dx * 0.006;
polar -= dy * 0.005;
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch {
// Pointer may already have been released.
}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius *= Math.exp(event.deltaY * 0.001);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
let paused = false;
function setPaused(value) {
paused = value;
pauseButton.textContent = paused ? "Resume motion" : "Pause motion";
statusText.textContent = paused ? "Motion paused" : "System running";
statusDot.classList.toggle("paused", paused);
}
pauseButton.addEventListener("click", () => setPaused(!paused));
resetButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
setPaused(!paused);
}
if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
let elapsed = 0;
let previousTime = performance.now();
let frame = 0;
function animate(now) {
const delta = THREE.MathUtils.clamp((now - previousTime) / 1000, 0, 0.05);
previousTime = now;
if (!paused) elapsed += delta;
// One phase drives every animated subsystem.
const phase = elapsed * 2.0;
for (const phone of phones) {
const lift = Math.sin(phase);
const tilt = Math.cos(phase * 0.5);
phone.receiver.position.y = phone.baseY + lift * 0.095;
phone.receiver.rotation.z = tilt * 0.035;
phone.receiver.rotation.x = Math.sin(phase * 0.72) * 0.018;
}
for (const wave of waves) {
updateWave(wave, phase);
}
for (const scope of scopes) {
drawScope(scope, phase);
}
const cycle = phase / (Math.PI * 2);
for (let i = 0; i < packets.length; i++) {
const u = (i / packets.length + cycle * 0.35) % 1;
packets[i].position.copy(wireCurve.getPoint(u));
const pulse = 0.72 + 0.28 * Math.sin(phase * 2 + i * 0.9);
packets[i].scale.setScalar(pulse);
}
wireGlow.material.opacity = 0.055 + 0.035 * (0.5 + 0.5 * Math.sin(phase));
renderer.render(scene, camera);
frame++;
if (frame === 2) {
loading.classList.add("hidden");
window.setTimeout(() => loading.remove(), 400);
}
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```