Prompt specification
Build or customize the Three.js 3D scene "Induction-loop signal pathway model" 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: Induction-loop signal pathway model
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/induction-loop-signal-pathway-model-x0437
Scene Description Prompt:
Show a stylized hearing-loop signal path around a room, linking transmitter and receiver schematically. Create standalone HTML using Three.js from cdnjs.
Working Three.js Starter (induction-loop-signal-pathway-model-x0437):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hearing Loop Signal Path</title>
<style>
:root {
--ink: #15283a;
--muted: #617386;
--panel: rgba(250, 249, 244, 0.9);
--teal: #00a9a5;
--cyan: #29c7e8;
--amber: #ffb84d;
--coral: #f36f61;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e5da;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
z-index: 10;
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 20px 22px;
border: 1px solid rgba(21, 40, 58, 0.12);
border-radius: 20px;
background: var(--panel);
box-shadow:
0 18px 50px rgba(21, 40, 58, 0.12),
inset 0 1px 0 rgba(255, 255, 255, 0.9);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 0 rgba(0, 169, 165, 0.45);
animation: pulse 1.8s infinite;
}
body.is-paused .live-dot {
background: #94a1ad;
animation: none;
}
@keyframes pulse {
70% {
box-shadow: 0 0 0 8px rgba(0, 169, 165, 0);
}
100% {
box-shadow: 0 0 0 0 rgba(0, 169, 165, 0);
}
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 35px);
line-height: 1.03;
letter-spacing: -0.045em;
}
.subtitle {
margin: 11px 0 18px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.signal-chain {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
align-items: center;
margin: 17px 0;
}
.chain-step {
min-width: 0;
text-align: center;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.chain-step::before {
content: "";
display: block;
width: 9px;
height: 9px;
margin: 0 auto 7px;
border-radius: 50%;
background: var(--step-color);
box-shadow: 0 0 0 4px color-mix(in srgb, var(--step-color) 15%, transparent);
}
.chain-arrow {
height: 1px;
margin-top: -17px;
background: linear-gradient(90deg, #bac3c8, #7d8e99);
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 9px 15px;
padding-top: 14px;
border-top: 1px solid rgba(21, 40, 58, 0.1);
color: var(--muted);
font-size: 11px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend i {
display: block;
width: 17px;
height: 3px;
border-radius: 4px;
background: var(--color);
}
.controls {
position: fixed;
z-index: 20;
right: 22px;
bottom: 22px;
display: flex;
gap: 8px;
padding: 8px;
border: 1px solid rgba(21, 40, 58, 0.12);
border-radius: 15px;
background: var(--panel);
box-shadow: 0 12px 32px rgba(21, 40, 58, 0.13);
backdrop-filter: blur(14px);
}
button {
border: 0;
border-radius: 10px;
padding: 10px 13px;
background: #e7ecee;
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: #dce5e7;
}
button.primary {
background: var(--ink);
color: white;
}
button.primary:hover {
background: #243d52;
}
.hint {
position: fixed;
z-index: 10;
left: 50%;
bottom: 25px;
transform: translateX(-50%);
padding: 8px 12px;
border-radius: 999px;
background: rgba(21, 40, 58, 0.78);
color: rgba(255, 255, 255, 0.9);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
pointer-events: none;
white-space: nowrap;
}
.status {
position: fixed;
z-index: 10;
top: 22px;
right: 22px;
padding: 9px 12px;
border: 1px solid rgba(21, 40, 58, 0.11);
border-radius: 999px;
background: rgba(250, 249, 244, 0.85);
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
@media (max-width: 700px) {
.hud {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
.subtitle,
.legend {
display: none;
}
.signal-chain {
margin-bottom: 0;
}
.status {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.hint {
left: 12px;
bottom: 66px;
transform: none;
}
button {
padding: 9px 10px;
}
}
</style>
</head>
<body>
<div class="hud">
<div class="eyebrow">
<span class="live-dot"></span>
<span>Accessible audio schematic</span>
</div>
<h1>Hearing-loop<br>signal path</h1>
<p class="subtitle">
Room audio enters a transmitter, travels around the perimeter loop,
and is picked up wirelessly by a receiver and telecoil.
</p>
<div class="signal-chain" aria-label="Signal path">
<div class="chain-step" style="--step-color: var(--amber)">Room mic</div>
<div class="chain-arrow"></div>
<div class="chain-step" style="--step-color: var(--coral)">Transmitter</div>
<div class="chain-arrow"></div>
<div class="chain-step" style="--step-color: var(--teal)">Loop</div>
<div class="chain-arrow"></div>
<div class="chain-step" style="--step-color: var(--cyan)">Receiver</div>
</div>
<div class="legend">
<span><i style="--color: var(--amber)"></i>Audio input</span>
<span><i style="--color: var(--teal)"></i>Loop current</span>
<span><i style="--color: var(--cyan)"></i>Wireless coupling</span>
</div>
</div>
<div class="status" id="status">Signal live</div>
<div class="controls">
<button class="primary" id="pauseButton" type="button">Pause signal</button>
<button id="replayButton" type="button">Replay</button>
<button id="cameraButton" type="button">Reset view</button>
</div>
<div class="hint">Drag to orbit · Scroll or pinch to zoom</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, camera
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e5da);
scene.fog = new THREE.Fog(0xe9e5da, 19, 34);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional hearing-loop signal diagram"
);
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xfffbef, 0x8ba0aa, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff3dc, 3.5);
sun.position.set(7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8ee8ff, 1.1);
fill.position.set(-7, 6, -4);
scene.add(fill);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const standard = (color, roughness = 0.68, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const materials = {
floor: standard(0xdedbd0, 0.92),
wall: standard(0xeeeae0, 0.94),
wallInset: standard(0xe4dfd3, 0.95),
navy: standard(0x173047, 0.54),
dark: standard(0x0d1b28, 0.46),
teal: standard(0x087f83, 0.5),
tealLight: standard(0x43c8c3, 0.45),
coral: standard(0xe9695c, 0.5),
amber: standard(0xffb547, 0.5),
cyan: standard(0x27c3e4, 0.35),
wood: standard(0xba8c61, 0.72),
woodDark: standard(0x75543e, 0.8),
sofa: standard(0x708c8d, 0.94),
sofaLight: standard(0x8ca7a5, 0.94),
skin: standard(0xd59b73, 0.82),
hair: standard(0x25313a, 0.92),
shirt: standard(0x315b69, 0.85),
pants: standard(0x263847, 0.9),
white: standard(0xf4f0e7, 0.78)
};
function addBox(
width,
height,
depth,
x,
y,
z,
material,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
scene.add(mesh);
return mesh;
}
function addSphere(
radius,
x,
y,
z,
material,
widthSegments = 20,
heightSegments = 14
) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, widthSegments, heightSegments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, material, radialSegments = 12) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function roundedRectPath(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.arcTo(x + width, y, x + width, y + height, radius);
ctx.arcTo(x + width, y + height, x, y + height, radius);
ctx.arcTo(x, y + height, x, y, radius);
ctx.arcTo(x, y, x + width, y, radius);
ctx.closePath();
}
function createLabel(title, subtitle, accent, width = 2.7) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 150;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRectPath(ctx, 6, 6, 756, 138, 24);
ctx.fillStyle = "rgba(13, 27, 40, 0.91)";
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,0.13)";
ctx.lineWidth = 2;
ctx.stroke();
ctx.fillStyle = accent;
roundedRectPath(ctx, 23, 27, 8, 96, 4);
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.font = "800 31px system-ui, sans-serif";
ctx.fillText(title, 51, 61);
ctx.fillStyle = "rgba(255,255,255,0.63)";
ctx.font = "500 22px system-ui, sans-serif";
ctx.fillText(subtitle, 51, 104);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
sprite.scale.set(width, width * 150 / 768, 1);
sprite.renderOrder = 20;
scene.add(sprite);
return sprite;
}
// ------------------------------------------------------------
// Cutaway room
// ------------------------------------------------------------
addBox(13.4, 0.18, 9.4, 0, -0.12, 0, materials.floor, false, true);
addBox(13.3, 4.4, 0.16, 0, 2.12, -4.58, materials.wall);
addBox(0.16, 4.4, 9.1, -6.58, 2.12, 0, materials.wall);
// Back-wall acoustic panels.
for (let i = 0; i < 5; i++) {
const x = -4.25 + i * 2.05;
addBox(1.35, 1.45, 0.08, x, 2.55, -4.46, materials.wallInset);
addBox(1.05, 1.15, 0.03, x, 2.55, -4.405, materials.tealLight, false);
}
// Left-wall inset panel.
addBox(0.08, 1.65, 2.65, -6.465, 2.45, -0.35, materials.navy);
addBox(0.035, 1.35, 2.35, -6.405, 2.45, -0.35, materials.cyan, false);
// Subtle floor grid.
const gridPoints = [];
for (let x = -6; x <= 6; x++) {
gridPoints.push(
new THREE.Vector3(x, 0.004, -4.25),
new THREE.Vector3(x, 0.004, 4.25)
);
}
for (let z = -4; z <= 4; z++) {
gridPoints.push(
new THREE.Vector3(-6.25, 0.004, z),
new THREE.Vector3(6.25, 0.004, z)
);
}
const grid = new THREE.LineSegments(
new THREE.BufferGeometry().setFromPoints(gridPoints),
new THREE.LineBasicMaterial({
color: 0x6d7b80,
transparent: true,
opacity: 0.12
})
);
scene.add(grid);
// Translucent magnetic-field footprint.
const fieldShape = new THREE.Shape();
const fw = 10.85;
const fd = 7.45;
const fr = 0.9;
fieldShape.moveTo(-fw / 2 + fr, -fd / 2);
fieldShape.lineTo(fw / 2 - fr, -fd / 2);
fieldShape.quadraticCurveTo(fw / 2, -fd / 2, fw / 2, -fd / 2 + fr);
fieldShape.lineTo(fw / 2, fd / 2 - fr);
fieldShape.quadraticCurveTo(fw / 2, fd / 2, fw / 2 - fr, fd / 2);
fieldShape.lineTo(-fw / 2 + fr, fd / 2);
fieldShape.quadraticCurveTo(-fw / 2, fd / 2, -fw / 2, fd / 2 - fr);
fieldShape.lineTo(-fw / 2, -fd / 2 + fr);
fieldShape.quadraticCurveTo(-fw / 2, -fd / 2, -fw / 2 + fr, -fd / 2);
const fieldFootprint = new THREE.Mesh(
new THREE.ShapeGeometry(fieldShape),
new THREE.MeshBasicMaterial({
color: 0x27c3e4,
transparent: true,
opacity: 0.07,
depthWrite: false,
side: THREE.DoubleSide
})
);
fieldFootprint.rotation.x = -Math.PI / 2;
fieldFootprint.position.y = 0.008;
scene.add(fieldFootprint);
// ------------------------------------------------------------
// Rounded perimeter-loop curve
// ------------------------------------------------------------
class RoundedRectCurve extends THREE.Curve {
constructor(width, depth, radius) {
super();
this.width = width;
this.depth = depth;
this.radius = radius;
}
getPoint(t, target = new THREE.Vector3()) {
const w = this.width;
const d = this.depth;
const r = this.radius;
const straightX = w - 2 * r;
const straightZ = d - 2 * r;
const arcLength = (Math.PI * r) / 2;
const total =
2 * straightX +
2 * straightZ +
4 * arcLength;
let s = t * total;
if (s <= straightX) {
const u = s / straightX;
return target.set(
THREE.MathUtils.lerp(-w / 2 + r, w / 2 - r, u),
0,
-d / 2
);
}
s -= straightX;
if (s <= arcLength) {
const a = -Math.PI / 2 + (s / arcLength) * Math.PI / 2;
return target.set(
w / 2 - r + Math.cos(a) * r,
0,
-d / 2 + r + Math.sin(a) * r
);
}
s -= arcLength;
if (s <= straightZ) {
const u = s / straightZ;
return target.set(
w / 2,
0,
THREE.MathUtils.lerp(-d / 2 + r, d / 2 - r, u)
);
}
s -= straightZ;
if (s <= arcLength) {
const a = (s / arcLength) * Math.PI / 2;
return target.set(
w / 2 - r + Math.cos(a) * r,
0,
d / 2 - r + Math.sin(a) * r
);
}
s -= arcLength;
if (s <= straightX) {
const u = s / straightX;
return target.set(
THREE.MathUtils.lerp(w / 2 - r, -w / 2 + r, u),
0,
d / 2
);
}
s -= straightX;
if (s <= arcLength) {
const a = Math.PI / 2 + (s / arcLength) * Math.PI / 2;
return target.set(
-w / 2 + r + Math.cos(a) * r,
0,
d / 2 - r + Math.sin(a) * r
);
}
s -= arcLength;
if (s <= straightZ) {
const u = s / straightZ;
return target.set(
-w / 2,
0,
THREE.MathUtils.lerp(d / 2 - r, -d / 2 + r, u)
);
}
s -= straightZ;
const a = Math.PI + (s / arcLength) * Math.PI / 2;
return target.set(
-w / 2 + r + Math.cos(a) * r,
0,
-d / 2 + r + Math.sin(a) * r
);
}
}
const loopCurve = new RoundedRectCurve(11.2, 7.8, 0.62);
const loopPoints = [];
for (let i = 0; i <= 240; i++) {
const p = loopCurve.getPointAt(i / 240);
p.y = 0.17;
loopPoints.push(p);
}
const loopCoreMaterial = new THREE.MeshStandardMaterial({
color: 0x00b7ad,
emissive: 0x00aaa4,
emissiveIntensity: 1.25,
roughness: 0.34,
metalness: 0.18
});
const loopCore = new THREE.Mesh(
new THREE.TubeGeometry(loopCurve, 320, 0.045, 8, true),
loopCoreMaterial
);
loopCore.position.y = 0.17;
loopCore.castShadow = true;
scene.add(loopCore);
const loopGlow = new THREE.Mesh(
new THREE.TubeGeometry(loopCurve, 320, 0.13, 8, true),
new THREE.MeshBasicMaterial({
color: 0x21d9d0,
transparent: true,
opacity: 0.13,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
loopGlow.position.y = 0.17;
scene.add(loopGlow);
// ------------------------------------------------------------
// Sofa and room furniture
// ------------------------------------------------------------
addBox(3.8, 0.34, 1.05, -0.65, 0.31, -3.42, materials.sofa);
addBox(3.8, 0.95, 0.24, -0.65, 0.86, -3.88, materials.sofa);
addBox(0.24, 0.64, 1.05, -2.68, 0.57, -3.42, materials.sofaLight);
addBox(0.24, 0.64, 1.05, 1.38, 0.57, -3.42, materials.sofaLight);
addBox(1.73, 0.17, 0.78, -1.31, 0.57, -3.3, materials.sofaLight);
addBox(1.73, 0.17, 0.78, 0.32, 0.57, -3.3, materials.sofaLight);
for (const x of [-2.25, 0.95]) {
for (const z of [-3.72, -3.08]) {
cylinderBetween(
new THREE.Vector3(x, 0, z),
new THREE.Vector3(x, 0.24, z),
0.045,
materials.woodDark
);
}
}
// ------------------------------------------------------------
// Transmitter and table
// ------------------------------------------------------------
addBox(2.25, 0.14, 1.4, -4.2, 0.88, 2.45, materials.wood);
addBox(2.05, 0.08, 1.25, -4.2, 0.77, 2.45, materials.woodDark);
for (const x of [-5.12, -3.28]) {
for (const z of [1.95, 2.95]) {
cylinderBetween(
new THREE.Vector3(x, 0.03, z),
new THREE.Vector3(x, 0.83, z),
0.045,
materials.navy
);
}
}
addBox(1.3, 0.9, 0.72, -4.2, 1.43, 2.45, materials.navy);
addBox(1.38, 0.08, 0.8, -4.2, 1.92, 2.45, materials.dark);
// Front display texture.
const panelCanvas = document.createElement("canvas");
panelCanvas.width = 640;
panelCanvas.height = 360;
const panelCtx = panelCanvas.getContext("2d");
panelCtx.fillStyle = "#091824";
panelCtx.fillRect(0, 0, 640, 360);
panelCtx.fillStyle = "#25d1c7";
panelCtx.fillRect(0, 0, 14, 360);
panelCtx.fillStyle = "#ffffff";
panelCtx.font = "800 51px system-ui, sans-serif";
panelCtx.fillText("LOOP TX", 48, 72);
panelCtx.fillStyle = "#8ea4b4";
panelCtx.font = "600 24px system-ui, sans-serif";
panelCtx.fillText("AUX / MIC", 48, 122);
panelCtx.strokeStyle = "#284050";
panelCtx.lineWidth = 4;
panelCtx.beginPath();
panelCtx.moveTo(48, 160);
panelCtx.lineTo(565, 160);
panelCtx.stroke();
const barHeights = [36, 72, 108, 58, 94, 128, 78, 112, 64, 98, 45, 82];
barHeights.forEach((height, i) => {
panelCtx.fillStyle = i > 8 ? "#25d1c7" : "#38a99f";
panelCtx.fillRect(49 + i * 42, 292 - height, 23, height);
});
const panelTexture = new THREE.CanvasTexture(panelCanvas);
panelTexture.colorSpace = THREE.SRGBColorSpace;
const transmitterPanel = new THREE.Mesh(
new THREE.PlaneGeometry(1.13, 0.62),
new THREE.MeshBasicMaterial({
map: panelTexture,
toneMapped: false
})
);
transmitterPanel.position.set(-4.2, 1.42, 2.815);
scene.add(transmitterPanel);
// Antenna and status lamp.
cylinderBetween(
new THREE.Vector3(-4.72, 1.95, 2.42),
new THREE.Vector3(-4.72, 2.46, 2.42),
0.018,
materials.dark
);
addSphere(0.065, -4.72, 2.48, 2.42, materials.cyan, 12, 8);
addSphere(0.055, -3.72, 1.52, 2.82, materials.amber, 12, 8);
// ------------------------------------------------------------
// Room microphone and input cable
// ------------------------------------------------------------
const micBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0.25, 0.08, 24),
materials.dark
);
micBase.position.set(-2.45, 0.07, 3.05);
micBase.castShadow = true;
scene.add(micBase);
cylinderBetween(
new THREE.Vector3(-2.45, 0.1, 3.05),
new THREE.Vector3(-2.45, 1.52, 3.05),
0.025,
materials.navy
);
const micHead = addSphere(
0.17,
-2.45,
1.63,
3.05,
materials.coral,
20,
14
);
micHead.scale.set(0.9, 1.25, 0.9);
const inputCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-2.45, 0.09, 3.05),
new THREE.Vector3(-2.82, 0.08, 2.77),
new THREE.Vector3(-3.65, 0.16, 2.28),
new THREE.Vector3(-4.12, 0.82, 2.22)
]);
const inputTube = new THREE.Mesh(
new THREE.TubeGeometry(inputCurve, 72, 0.025, 8, false),
new THREE.MeshStandardMaterial({
color: 0xb97a2f,
emissive: 0x9d5d18,
emissiveIntensity: 0.45,
roughness: 0.55
})
);
inputTube.castShadow = true;
scene.add(inputTube);
// Transmitter output connection to the perimeter loop.
const outputCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-4.84, 1.27, 2.56),
new THREE.Vector3(-5.05, 0.76, 2.69),
new THREE.Vector3(-5.35, 0.28, 2.76),
new THREE.Vector3(-5.6, 0.17, 2.8)
]);
const outputTube = new THREE.Mesh(
new THREE.TubeGeometry(outputCurve, 64, 0.035, 8, false),
new THREE.MeshStandardMaterial({
color: 0x009d99,
emissive: 0x008f8b,
emissiveIntensity: 0.75,
roughness: 0.38
})
);
outputTube.castShadow = true;
scene.add(outputTube);
// ------------------------------------------------------------
// Receiver wearer
// ------------------------------------------------------------
const personX = 3.55;
const personZ = 0.85;
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.34, 0.43, 0.92, 18),
materials.shirt
);
torso.position.set(personX, 1.12, personZ);
torso.castShadow = true;
scene.add(torso);
cylinderBetween(
new THREE.Vector3(personX, 1.55, personZ),
new THREE.Vector3(personX, 1.79, personZ),
0.105,
materials.skin
);
addSphere(0.27, personX, 1.99, personZ, materials.skin, 24, 18);
const hair = new THREE.Mesh(
new THREE.SphereGeometry(
0.278,
22,
14,
0,
Math.PI * 2,
0,
Math.PI * 0.49
),
materials.hair
);
hair.position.set(personX, 2.015, personZ);
hair.castShadow = true;
scene.add(hair);
cylinderBetween(
new THREE.Vector3(personX - 0.18, 0.72, personZ),
new THREE.Vector3(personX - 0.2, 0.12, personZ + 0.02),
0.105,
materials.pants
);
cylinderBetween(
new THREE.Vector3(personX + 0.18, 0.72, personZ),
new THREE.Vector3(personX + 0.2, 0.12, personZ + 0.02),
0.105,
materials.pants
);
addBox(0.25, 0.13, 0.42, personX - 0.2, 0.08, personZ + 0.1, materials.dark);
addBox(0.25, 0.13, 0.42, personX + 0.2, 0.08, personZ + 0.1, materials.dark);
cylinderBetween(
new THREE.Vector3(personX - 0.34, 1.42, personZ),
new THREE.Vector3(personX - 0.55, 0.98, personZ + 0.08),
0.085,
materials.shirt
);
cylinderBetween(
new THREE.Vector3(personX + 0.34, 1.42, personZ),
new THREE.Vector3(personX + 0.55, 1.02, personZ + 0.08),
0.085,
materials.shirt
);
addSphere(0.095, personX - 0.55, 0.91, personZ + 0.08, materials.skin);
addSphere(0.095, personX + 0.55, 0.95, personZ + 0.08, materials.skin);
// Stylized ear-level telecoil.
const earCoil = new THREE.Mesh(
new THREE.TorusGeometry(0.095, 0.025, 10, 28),
new THREE.MeshStandardMaterial({
color: 0xffbd55,
emissive: 0xa85b11,
emissiveIntensity: 0.7,
roughness: 0.4
})
);
earCoil.position.set(personX + 0.265, 2.0, personZ);
earCoil.rotation.y = Math.PI / 2;
earCoil.castShadow = true;
scene.add(earCoil);
// Neck loop suggests the receiver's inductive coil.
const neckCoil = new THREE.Mesh(
new THREE.TorusGeometry(0.25, 0.018, 8, 30),
materials.amber
);
neckCoil.position.set(personX, 1.68, personZ);
neckCoil.rotation.x = Math.PI / 2;
scene.add(neckCoil);
// Clipped receiver body.
addBox(0.34, 0.49, 0.13, personX, 1.38, personZ + 0.39, materials.dark);
addBox(
0.23,
0.13,
0.02,
personX,
1.49,
personZ + 0.465,
materials.cyan,
false
);
const receiverLed = addSphere(
0.035,
personX + 0.1,
1.28,
personZ + 0.465,
materials.cyan,
12,
8
);
// ------------------------------------------------------------
// Wireless field paths from loop to receiver
// ------------------------------------------------------------
const receiverPoint = new THREE.Vector3(
personX + 0.265,
2.0,
personZ
);
const fieldCurves = [];
const fieldStarts = [
new THREE.Vector3(5.6, 0.17, 2.1),
new THREE.Vector3(5.6, 0.17, 0.9),
new THREE.Vector3(5.6, 0.17, -0.3)
];
const fieldMaterial = new THREE.MeshBasicMaterial({
color: 0x36d5f0,
transparent: true,
opacity: 0.62,
depthWrite: false
});
for (const start of fieldStarts) {
const control = new THREE.Vector3(
4.78,
1.25,
THREE.MathUtils.lerp(start.z, personZ, 0.35)
);
const curve = new THREE.QuadraticBezierCurve3(
start,
control,
receiverPoint
);
fieldCurves.push(curve);
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 64, 0.018, 7, false),
fieldMaterial
);
scene.add(line);
const glow = new THREE.Mesh(
new THREE.TubeGeometry(curve, 64, 0.06, 7, false),
new THREE.MeshBasicMaterial({
color: 0x36d5f0,
transparent: true,
opacity: 0.09,
depthWrite: false,
blending: THREE.AdditiveBlending
})
);
scene.add(glow);
}
// ------------------------------------------------------------
// Labels
// ------------------------------------------------------------
const txLabel = createLabel(
"Hearing-loop transmitter",
"Audio input → loop current",
"#f36f61",
3.15
);
txLabel.position.set(-4.2, 2.87, 2.45);
const micLabel = createLabel(
"Room microphone",
"Original audio source",
"#ffb84d",
2.55
);
micLabel.position.set(-2.45, 2.33, 3.05);
const loopLabel = createLabel(
"Perimeter hearing loop",
"Continuous current around the room",
"#00a9a5",
3.45
);
loopLabel.position.set(-0.45, 0.88, -3.92);
const receiverLabel = createLabel(
"Receiver + telecoil",
"Wireless pickup at the ear",
"#29c7e8",
3.0
);
receiverLabel.position.set(personX + 0.1, 2.86, personZ);
const fieldLabel = createLabel(
"Magnetic field",
"Inductive wireless coupling",
"#29c7e8",
2.7
);
fieldLabel.position.set(5.05, 1.35, 2.35);
// ------------------------------------------------------------
// Animated signal packets
// ------------------------------------------------------------
const pulseGeometry = new THREE.SphereGeometry(0.075, 12, 8);
const inputPulseMaterial = new THREE.MeshBasicMaterial({
color: 0xffbd50,
toneMapped: false
});
const loopPulseMaterial = new THREE.MeshBasicMaterial({
color: 0x47fff0,
toneMapped: false
});
const fieldPulseMaterial = new THREE.MeshBasicMaterial({
color: 0x67e8ff,
toneMapped: false
});
function makePulseSet(curve, count, material, speed) {
const meshes = [];
for (let i = 0; i < count; i++) {
const pulse = new THREE.Mesh(pulseGeometry, material);
pulse.castShadow = false;
scene.add(pulse);
meshes.push(pulse);
}
return { curve, count, material, speed, meshes };
}
const pulseSets = [
makePulseSet(inputCurve, 3, inputPulseMaterial, 0.24),
makePulseSet(outputCurve, 4, loopPulseMaterial, 0.28),
makePulseSet(loopCurve, 14, loopPulseMaterial, 0.065)
];
fieldCurves.forEach((curve) => {
pulseSets.push(
makePulseSet(curve, 2, fieldPulseMaterial, 0.27)
);
});
// Direction arrows around the perimeter.
const loopArrows = [];
const arrowGeometry = new THREE.ConeGeometry(0.09, 0.26, 10);
for (let i = 0; i < 4; i++) {
const arrow = new THREE.Mesh(arrowGeometry, loopPulseMaterial);
scene.add(arrow);
loopArrows.push(arrow);
}
// ------------------------------------------------------------
// Custom orbit controls
// ------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 0.75, 0);
const defaultCamera = {
radius: 15.7,
theta: 0.72,
phi: 1.04
};
let cameraRadius = defaultCamera.radius;
let cameraTheta = defaultCamera.theta;
let cameraPhi = defaultCamera.phi;
let dragging = false;
let previousX = 0;
let previousY = 0;
let pinchDistance = 0;
function updateCamera() {
const sinPhi = Math.sin(cameraPhi);
camera.position.set(
cameraTarget.x + cameraRadius * sinPhi * Math.sin(cameraTheta),
cameraTarget.y + cameraRadius * Math.cos(cameraPhi),
cameraTarget.z + cameraRadius * sinPhi * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraRadius = defaultCamera.radius;
cameraTheta = defaultCamera.theta;
cameraPhi = defaultCamera.phi;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.pointerType === "touch" && event.isPrimary === false) return;
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraTheta -= dx * 0.006;
cameraPhi = THREE.MathUtils.clamp(
cameraPhi - dy * 0.005,
0.45,
1.35
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
8.5,
22
);
updateCamera();
},
{ passive: false }
);
// Touch pinch.
renderer.domElement.addEventListener(
"touchstart",
(event) => {
if (event.touches.length === 2) {
pinchDistance = Math.hypot(
event.touches[0].clientX - event.touches[1].clientX,
event.touches[0].clientY - event.touches[1].clientY
);
}
},
{ passive: true }
);
renderer.domElement.addEventListener(
"touchmove",
(event) => {
if (event.touches.length === 2 && pinchDistance > 0) {
event.preventDefault();
const distance = Math.hypot(
event.touches[0].clientX - event.touches[1].clientX,
event.touches[0].clientY - event.touches[1].clientY
);
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * (pinchDistance / distance),
8.5,
22
);
pinchDistance = distance;
updateCamera();
}
},
{ passive: false }
);
renderer.domElement.addEventListener(
"touchend",
() => {
pinchDistance = 0;
},
{ passive: true }
);
renderer.domElement.addEventListener(
"contextmenu",
(event) => event.preventDefault()
);
// ------------------------------------------------------------
// UI and animation
// ------------------------------------------------------------
const pauseButton = document.getElementById("pauseButton");
const replayButton = document.getElementById("replayButton");
const cameraButton = document.getElementById("cameraButton");
const status = document.getElementById("status");
let running = true;
let signalTime = 0;
pauseButton.addEventListener("click", () => {
running = !running;
pauseButton.textContent = running ? "Pause signal" : "Resume signal";
status.textContent = running ? "Signal live" : "Signal paused";
document.body.classList.toggle("is-paused", !running);
});
replayButton.addEventListener("click", () => {
signalTime = 0;
if (!running) {
running = true;
pauseButton.textContent = "Pause signal";
status.textContent = "Signal live";
document.body.classList.remove("is-paused");
}
});
cameraButton.addEventListener("click", resetCamera);
const clock = new THREE.Clock();
const yAxis = new THREE.Vector3(0, 1, 0);
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (running) {
signalTime += delta;
}
pulseSets.forEach((set) => {
set.meshes.forEach((mesh, index) => {
const t = (signalTime * set.speed + index / set.count) % 1;
const point = set.curve.getPointAt(t);
if (set.curve === loopCurve) {
point.y = 0.17;
}
mesh.position.copy(point);
const pulseScale =
0.9 + Math.sin((t + signalTime) * Math.PI * 2) * 0.12;
mesh.scale.setScalar(pulseScale);
});
});
loopArrows.forEach((arrow, index) => {
const t = (signalTime * 0.065 + index / loopArrows.length) % 1;
const point = loopCurve.getPointAt(t);
const tangent = loopCurve.getTangentAt(t);
point.y = 0.22;
arrow.position.copy(point);
arrow.quaternion.setFromUnitVectors(yAxis, tangent.normalize());
});
const pulse = 1.15 + Math.sin(signalTime * 4.2) * 0.18;
loopCoreMaterial.emissiveIntensity = pulse;
loopGlow.material.opacity = 0.12 + Math.sin(signalTime * 3.4) * 0.025;
fieldMaterial.opacity = 0.56 + Math.sin(signalTime * 4) * 0.1;
receiverLed.scale.setScalar(0.9 + Math.sin(signalTime * 6) * 0.12);
renderer.render(scene, camera);
}
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", onResize);
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```