Prompt specification
Build or customize the Three.js 3D scene "One transmitter and two tuned receivers" 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: One transmitter and two tuned receivers
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/one-transmitter-and-two-tuned-receivers-x2522
Scene Description Prompt:
Create a schematic broadcast vignette with one transmitter and two receivers. Animate reception only when a receiver matches the selected channel in the idealized model. Use Three.js from cdnjs in a single HTML file, with a 3D cutaway.
Verify the behavior against the actual geometry and data in each relevant state. Use schematic labels for deliberately synthetic elements.
Technical checks: Initialize the scene with valid JavaScript color literals. Make the transmitter and both receivers visible and demonstrate the selective response of the tuned receiver.
Return one complete HTML document. The file must run in a sandbox allowing inline scripts and the cdnjs Three.js r160 module. Construct procedural assets, use local event handlers and avoid remote assets, runtime network requests besides Three.js, pointer lock and native form submission. Keep the main requested geometry visible in the initial view.
Working Three.js Starter (one-transmitter-and-two-tuned-receivers-x2522):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#eaf0f2">
<link rel="icon" href="data:,">
<title>Synthetic Broadcast Test Cell</title>
<style>
:root {
color-scheme: light;
--ink: #18313f;
--muted: #627681;
--panel: rgba(247, 250, 250, 0.92);
--line: rgba(24, 49, 63, 0.14);
--teal: #119f99;
--teal-soft: #d8f1ee;
--orange: #e88b48;
--orange-soft: #f8e8dc;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #eaf0f2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
#stage canvas:active { cursor: grabbing; }
#hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
position: absolute;
top: 16px;
left: 16px;
width: min(354px, calc(100vw - 32px));
padding: 17px;
border: 1px solid rgba(255, 255, 255, 0.78);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(36, 57, 66, 0.15);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(17, 159, 153, 0.12);
content: "";
}
h1 {
margin: 0;
font-size: clamp(20px, 3vw, 25px);
line-height: 1.08;
letter-spacing: -0.035em;
}
.intro {
margin: 8px 0 15px;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.section-label {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-bottom: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.section-label strong {
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 12px;
letter-spacing: 0;
}
.channels {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-bottom: 14px;
}
.channels button {
min-height: 39px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.76);
color: var(--ink);
font: 700 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
cursor: pointer;
transition: transform 120ms ease, color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.channels button:hover {
transform: translateY(-1px);
border-color: rgba(17, 159, 153, 0.45);
}
.channels button:focus-visible {
outline: 3px solid rgba(17, 159, 153, 0.24);
outline-offset: 2px;
}
.channels button.active {
border-color: var(--ink);
background: var(--ink);
color: white;
box-shadow: 0 7px 16px rgba(24, 49, 63, 0.18);
}
.states {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.62);
}
.state-row {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 12px;
align-items: center;
min-height: 47px;
padding: 9px 11px;
border-bottom: 1px solid var(--line);
}
.state-row:last-child { border-bottom: 0; }
.device-name {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
font-weight: 800;
}
.device-name small {
color: var(--muted);
font-size: 10px;
font-weight: 600;
}
.device-name code {
color: var(--ink);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--orange);
box-shadow: 0 0 0 3px rgba(232, 139, 72, 0.13);
}
.dot.match {
background: var(--teal);
box-shadow: 0 0 0 3px rgba(17, 159, 153, 0.14);
}
.relation {
padding: 4px 7px;
border-radius: 6px;
background: var(--orange-soft);
color: #a95a27;
font: 800 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: 0.03em;
white-space: nowrap;
}
.relation.match {
background: var(--teal-soft);
color: #087c78;
}
.rule {
display: grid;
gap: 5px;
margin-top: 12px;
padding: 10px 11px;
border-left: 3px solid var(--teal);
border-radius: 3px 9px 9px 3px;
background: rgba(17, 159, 153, 0.075);
}
.rule span {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
}
.rule code {
overflow-wrap: anywhere;
font: 600 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.legend {
position: absolute;
right: 16px;
bottom: 16px;
width: 245px;
padding: 12px 13px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 13px;
background: rgba(247, 250, 250, 0.88);
box-shadow: 0 12px 35px rgba(36, 57, 66, 0.12);
backdrop-filter: blur(12px);
font-size: 10px;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin: 7px 0;
color: #526873;
}
.swatch {
width: 27px;
height: 4px;
flex: 0 0 auto;
border-radius: 3px;
}
.swatch.emit { background: #aebbc0; }
.swatch.accept { background: var(--teal); }
.swatch.off { background: var(--orange); }
.gesture {
position: absolute;
left: 16px;
bottom: 16px;
padding: 9px 11px;
border-radius: 10px;
background: rgba(247, 250, 250, 0.78);
color: #627681;
font: 600 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
box-shadow: 0 8px 22px rgba(36, 57, 66, 0.08);
}
#loading {
position: fixed;
inset: 0;
display: grid;
place-items: center;
background: #eaf0f2;
color: var(--ink);
font: 700 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: 0.08em;
z-index: 20;
}
@media (max-width: 680px) {
.panel {
top: 10px;
left: 10px;
width: min(326px, calc(100vw - 20px));
padding: 13px;
}
.intro { display: none; }
.legend { right: 10px; bottom: 10px; width: 220px; }
.gesture { display: none; }
}
@media (max-height: 650px) {
.panel { padding: 12px; }
.intro, .rule { display: none; }
.channels { margin-bottom: 9px; }
.state-row { min-height: 40px; padding-block: 6px; }
.legend { display: none; }
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive 3D schematic showing one synthetic transmitter and two synthetic receivers"></div>
<main id="hud">
<section class="panel" aria-label="Broadcast model controls and state">
<div class="eyebrow">Synthetic schematic · not RF physics</div>
<h1>Broadcast test cell</h1>
<p class="intro">
Select the transmitter channel. Only a receiver whose tuned channel equals that selection may animate reception.
</p>
<div class="section-label">
<span>Selected channel</span>
<strong id="tx-readout">CH 02</strong>
</div>
<div class="channels" role="group" aria-label="Transmitter channel">
<button type="button" data-channel="1" aria-pressed="false">CH 01</button>
<button type="button" data-channel="2" aria-pressed="true" class="active">CH 02</button>
<button type="button" data-channel="3" aria-pressed="false">CH 03</button>
</div>
<div class="section-label"><span>Live model state</span><span>Geometry + readout</span></div>
<div class="states">
<div class="state-row">
<div class="device-name"><span class="dot"></span>TX-01 <small>selected</small></div>
<div class="relation" id="tx-relation">CH 02</div>
</div>
<div class="state-row">
<div class="device-name"><span class="dot" id="rx-a-dot"></span>RX-A <small>tune <code id="rx-a-tune">02</code></small></div>
<div class="relation" id="rx-a-relation">MATCH · RX ON</div>
</div>
<div class="state-row">
<div class="device-name"><span class="dot" id="rx-b-dot"></span>RX-B <small>tune <code id="rx-b-tune">03</code></small></div>
<div class="relation" id="rx-b-relation">NO MATCH · RX OFF</div>
</div>
</div>
<div class="rule">
<span>RECEPTION RULE</span>
<code>receiver.tune === transmitter.channel</code>
</div>
</section>
<aside class="legend" aria-label="Animation legend">
<div class="legend-row"><span class="swatch emit"></span>Pale rings: carrier emission</div>
<div class="legend-row"><span class="swatch accept"></span>Cyan packet + halo: reception</div>
<div class="legend-row"><span class="swatch off"></span>Amber receiver: reception disabled</div>
</aside>
<div class="gesture">DRAG TO ORBIT · WHEEL TO ZOOM · 1–3 CHANNEL · R RESET</div>
</main>
<div id="loading">INITIALIZING SYNTHETIC TEST CELL…</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 state = {
txChannel: 2,
rxTune: [2, 3]
};
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 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("tabindex", "0");
renderer.domElement.setAttribute("aria-label", "3D schematic. Drag to orbit and use the mouse wheel to zoom.");
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeaf0f2);
scene.fog = new THREE.Fog(0xeaf0f2, 24, 42);
const camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.1, 80);
const controls = {
target: new THREE.Vector3(0, 1.8, 0),
radius: window.innerWidth < 680 ? 27 : 20.5,
phi: 1.03,
theta: 0.58
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xf9ffff, 0x71818a, 2.0);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff4e6, 3.0);
key.position.set(7, 14, 9);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 12;
key.shadow.camera.bottom = -10;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.normalBias = 0.025;
scene.add(key);
const fill = new THREE.DirectionalLight(0xbde7ef, 1.25);
fill.position.set(-8, 6, -5);
scene.add(fill);
const materials = {
floor: new THREE.MeshStandardMaterial({ color: 0xdce4e5, roughness: 0.93, metalness: 0.02 }),
wall: new THREE.MeshStandardMaterial({ color: 0xe8eeed, roughness: 0.88 }),
wallInset: new THREE.MeshStandardMaterial({ color: 0xd2dee0, roughness: 0.9 }),
navy: new THREE.MeshStandardMaterial({ color: 0x233b49, roughness: 0.58, metalness: 0.12 }),
navySoft: new THREE.MeshStandardMaterial({ color: 0x49616e, roughness: 0.7 }),
pale: new THREE.MeshStandardMaterial({ color: 0xf6f8f6, roughness: 0.65 }),
teal: new THREE.MeshStandardMaterial({ color: 0x159f99, roughness: 0.38, metalness: 0.18 }),
tealDark: new THREE.MeshStandardMaterial({ color: 0x08736f, roughness: 0.5, metalness: 0.2 }),
orange: new THREE.MeshStandardMaterial({ color: 0xe99555, roughness: 0.62 }),
dark: new THREE.MeshStandardMaterial({ color: 0x102630, roughness: 0.42, metalness: 0.2 }),
glass: new THREE.MeshStandardMaterial({ color: 0x9fc7cc, roughness: 0.32, metalness: 0.18 })
};
function box(width, height, depth, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(radius, height, material, x, y, z, parent = scene, segments = 24) {
const mesh = new THREE.Mesh(new THREE.CylinderGeometry(radius, radius, height, segments), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function rod(a, b, radius, material, parent = scene) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 12),
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width * 0.5, height * 0.5);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeLabel(title, subtitle, worldWidth = 3.1) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 180;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 8, 624, 164, 24);
ctx.fillStyle = "rgba(20, 43, 55, 0.94)";
ctx.fill();
ctx.strokeStyle = "rgba(70, 211, 202, 0.65)";
ctx.lineWidth = 4;
ctx.stroke();
ctx.fillStyle = "#f7ffff";
ctx.font = "800 42px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(title, 320, 66);
ctx.fillStyle = "#8fd8d3";
ctx.font = "600 23px ui-monospace, monospace";
ctx.fillText(subtitle, 320, 122);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(worldWidth, worldWidth * 180 / 640, 1);
sprite.renderOrder = 20;
return sprite;
}
function makeDisplay() {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 320;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
return { canvas, ctx, texture };
}
function drawDisplay(display, title, line1, line2, line3, matched) {
const { ctx, texture } = display;
ctx.clearRect(0, 0, 512, 320);
ctx.fillStyle = "#0c2029";
ctx.fillRect(0, 0, 512, 320);
ctx.strokeStyle = matched ? "#27c7bc" : "#dc915c";
ctx.lineWidth = 8;
ctx.strokeRect(12, 12, 488, 296);
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = "#91aeb8";
ctx.font = "700 22px ui-monospace, monospace";
ctx.fillText(title, 34, 48);
ctx.fillStyle = "#eefbfa";
ctx.font = "800 35px ui-monospace, monospace";
ctx.fillText(line1, 34, 99);
ctx.fillStyle = matched ? "#39d7ca" : "#e6a06e";
ctx.font = "800 31px ui-monospace, monospace";
ctx.fillText(line2, 34, 157);
ctx.fillStyle = "#8faab4";
ctx.font = "600 20px ui-monospace, monospace";
ctx.fillText(line3, 34, 218);
ctx.fillStyle = matched ? "#123e40" : "#3a2a22";
roundedRect(ctx, 34, 253, 444, 34, 9);
ctx.fill();
ctx.fillStyle = matched ? "#8ce8df" : "#e8b28c";
ctx.font = "700 17px ui-monospace, monospace";
ctx.fillText(matched ? "RECEPTION ANIMATION ENABLED" : "RECEPTION ANIMATION DISABLED", 49, 270);
texture.needsUpdate = true;
}
// Cutaway room.
box(19, 0.36, 12, materials.floor, 0, -0.22, 0);
// Both GridHelper colors are valid numeric hexadecimal literals.
const grid = new THREE.GridHelper(18, 18, 0xb7c4c8, 0xd7e0e2);
grid.position.y = 0.012;
grid.scale.z = 0.64;
grid.material.transparent = true;
grid.material.opacity = 0.72;
scene.add(grid);
box(19, 4.25, 0.22, materials.wall, 0, 2.02, -5.88);
box(0.22, 3.45, 6.55, materials.wall, -9.39, 1.62, -2.58);
box(18.5, 0.09, 0.10, materials.orange, 0, 0.08, -5.73);
box(0.09, 0.09, 6.2, materials.orange, -9.24, 0.08, -2.55);
for (const x of [-6.7, -0.2, 6.4]) {
box(4.2, 2.25, 0.08, materials.wallInset, x, 2.36, -5.72);
box(3.65, 0.06, 0.10, materials.pale, x, 1.15, -5.65);
box(0.06, 1.7, 0.10, materials.pale, x, 2.36, -5.65);
}
for (const z of [-4.75, -2.25]) {
box(0.08, 2.1, 2.0, materials.wallInset, -9.24, 2.05, z);
box(0.10, 0.06, 1.6, materials.pale, -9.17, 1.0, z);
}
const wallLabel = makeLabel("IDEALIZED BROADCAST TEST CELL", "SCHEMATIC · SYNTHETIC · NOT RF PHYSICS", 6.2);
wallLabel.position.set(0.2, 3.55, -5.55);
scene.add(wallLabel);
// Synthetic transmitter.
const transmitter = new THREE.Group();
transmitter.position.set(-4.4, 0, -0.2);
scene.add(transmitter);
box(2.25, 0.30, 2.15, materials.navySoft, 0, 0.15, 0, transmitter);
box(1.42, 1.34, 1.16, materials.navy, 0, 0.96, 0, transmitter);
box(1.18, 0.72, 0.08, materials.tealDark, 0, 1.05, 0.62, transmitter);
box(1.48, 0.13, 1.22, materials.pale, 0, 1.69, 0, transmitter);
rod([-0.36, 1.72, -0.25], [-0.15, 4.30, -0.10], 0.085, materials.teal, transmitter);
rod([0.36, 1.72, -0.25], [0.15, 4.30, -0.10], 0.085, materials.teal, transmitter);
rod([-0.58, 2.12, 0.32], [0.58, 2.12, 0.32], 0.055, materials.navySoft, transmitter);
rod([-0.50, 2.82, 0.30], [0.50, 2.82, 0.30], 0.055, materials.navySoft, transmitter);
rod([-0.44, 2.12, 0.32], [0.40, 2.82, 0.30], 0.038, materials.orange, transmitter);
rod([0.44, 2.12, 0.32], [-0.40, 2.82, 0.30], 0.038, materials.orange, transmitter);
rod([0, 3.42, -0.08], [0, 4.73, -0.08], 0.07, materials.navy, transmitter);
rod([-0.86, 4.25, -0.08], [0.86, 4.25, -0.08], 0.045, materials.navySoft, transmitter);
rod([-0.62, 4.56, -0.08], [0.62, 4.56, -0.08], 0.04, materials.navySoft, transmitter);
const emitterCore = new THREE.Mesh(
new THREE.SphereGeometry(0.16, 24, 16),
new THREE.MeshStandardMaterial({
color: 0x45dfd3,
emissive: 0x0a8f89,
emissiveIntensity: 1.5,
roughness: 0.28
})
);
emitterCore.position.set(0, 4.73, -0.08);
transmitter.add(emitterCore);
const txDisplay = makeDisplay();
const txScreen = new THREE.Mesh(
new THREE.PlaneGeometry(1.02, 0.62),
new THREE.MeshBasicMaterial({ map: txDisplay.texture, toneMapped: false })
);
txScreen.position.set(0, 1.08, 0.665);
transmitter.add(txScreen);
const txLabel = makeLabel("TX-01 · SYNTHETIC SOURCE", "SELECTED BROADCAST CHANNEL", 3.3);
txLabel.position.set(-4.35, 5.35, -0.2);
scene.add(txLabel);
const txAntennaPosition = new THREE.Vector3(-4.4, 4.73, -0.28);
// Always-animated carrier rings belong to transmission, not reception.
const emissionRings = [];
for (let i = 0; i < 3; i++) {
const material = new THREE.MeshBasicMaterial({
color: 0xaab9be,
transparent: true,
opacity: 0.22,
depthWrite: false,
side: THREE.DoubleSide
});
const ring = new THREE.Mesh(new THREE.TorusGeometry(0.72, 0.018, 8, 72), material);
ring.rotation.x = Math.PI / 2;
ring.position.copy(txAntennaPosition);
scene.add(ring);
emissionRings.push(ring);
}
function createReceiver(id, tunedChannel, x, z, index) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(2.0, 0.28, 1.52, materials.navySoft, 0, 0.14, 0, group);
box(1.72, 1.36, 1.04, materials.navy, 0, 0.97, 0, group);
box(1.84, 0.12, 1.15, materials.pale, 0, 1.71, 0, group);
box(1.62, 0.09, 0.09, materials.teal, 0, 0.36, 0.56, group);
const display = makeDisplay();
const screen = new THREE.Mesh(
new THREE.PlaneGeometry(1.08, 0.76),
new THREE.MeshBasicMaterial({ map: display.texture, toneMapped: false })
);
screen.position.set(-0.27, 1.08, 0.526);
group.add(screen);
const waveformGeometry = new THREE.BufferGeometry();
const waveformPositions = new Float32Array(31 * 3);
for (let i = 0; i < 31; i++) {
waveformPositions[i * 3] = -0.73 + i * 0.03;
waveformPositions[i * 3 + 1] = 1.08;
waveformPositions[i * 3 + 2] = 0.542;
}
waveformGeometry.setAttribute("position", new THREE.BufferAttribute(waveformPositions, 3));
const waveform = new THREE.Line(
waveformGeometry,
new THREE.LineBasicMaterial({ color: 0x48e1d6, transparent: true, opacity: 0.95 })
);
waveform.visible = false;
group.add(waveform);
const knob = cylinder(0.16, 0.13, materials.orange, 0.51, 0.84, 0.57, group, 28);
knob.rotation.x = Math.PI / 2;
const ledMaterial = new THREE.MeshStandardMaterial({
color: 0xe99555,
emissive: 0x7f2f12,
emissiveIntensity: 0.25,
roughness: 0.35
});
const led = new THREE.Mesh(new THREE.SphereGeometry(0.105, 20, 14), ledMaterial);
led.position.set(0.51, 1.38, 0.59);
group.add(led);
const bars = [];
const barHeights = [0.16, 0.25, 0.35, 0.47, 0.59];
for (let j = 0; j < barHeights.length; j++) {
const barMaterial = new THREE.MeshStandardMaterial({
color: 0x38cfc4,
emissive: 0x087d77,
emissiveIntensity: 1.0,
roughness: 0.34
});
const bar = new THREE.Mesh(new THREE.BoxGeometry(0.065, 1, 0.05), barMaterial);
const baseHeight = barHeights[j];
bar.position.set(0.38 + j * 0.105, 0.43 + baseHeight / 2, 0.58);
bar.scale.y = baseHeight;
bar.visible = false;
group.add(bar);
bars.push({ mesh: bar, baseHeight });
}
rod([-0.58, 1.72, -0.10], [-0.58, 2.72, -0.10], 0.052, materials.navySoft, group);
rod([-0.88, 2.38, -0.10], [-0.28, 2.38, -0.10], 0.035, materials.navySoft, group);
const antennaTip = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 20, 14),
new THREE.MeshStandardMaterial({
color: 0xf4faf9,
emissive: 0x28666b,
emissiveIntensity: 0.45,
roughness: 0.32
})
);
antennaTip.position.set(-0.58, 2.78, -0.10);
group.add(antennaTip);
const label = makeLabel(`${id} · SIMULATED RECEIVER`, `TUNED CH ${String(tunedChannel).padStart(2, "0")}`, 3.0);
label.position.set(x + 0.05, 3.30, z);
scene.add(label);
return {
id,
index,
group,
display,
waveform,
waveformGeometry,
bars,
led,
ledMaterial,
antennaPosition: new THREE.Vector3(x - 0.58, 2.78, z - 0.10)
};
}
const receivers = [
createReceiver("RX-A", state.rxTune[0], 3.55, -2.45, 0),
createReceiver("RX-B", state.rxTune[1], 4.55, 2.45, 1)
];
const links = receivers.map((receiver) => {
const midpoint = txAntennaPosition.clone().add(receiver.antennaPosition).multiplyScalar(0.5);
midpoint.y += 2.65;
midpoint.z += receiver.index === 0 ? -0.35 : 0.30;
const curve = new THREE.QuadraticBezierCurve3(
txAntennaPosition.clone(),
midpoint,
receiver.antennaPosition.clone()
);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(90));
const material = new THREE.LineDashedMaterial({
color: 0x879aa2,
dashSize: 0.22,
gapSize: 0.16,
transparent: true,
opacity: 0.25
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
scene.add(line);
const pulseGroup = new THREE.Group();
const pulses = [];
for (let i = 0; i < 3; i++) {
const pulseMaterial = new THREE.MeshBasicMaterial({
color: 0x39d8cb,
transparent: true,
opacity: 0.95,
depthWrite: false
});
const pulse = new THREE.Mesh(new THREE.SphereGeometry(0.115 - i * 0.018, 18, 12), pulseMaterial);
pulseGroup.add(pulse);
pulses.push(pulse);
}
pulseGroup.visible = false;
scene.add(pulseGroup);
const haloMaterial = new THREE.MeshBasicMaterial({
color: 0x35d8ca,
transparent: true,
opacity: 0.65,
side: THREE.DoubleSide,
depthWrite: false
});
const halo = new THREE.Mesh(new THREE.TorusGeometry(0.40, 0.025, 8, 64), haloMaterial);
halo.position.copy(receiver.antennaPosition);
halo.visible = false;
scene.add(halo);
return { curve, line, material, pulseGroup, pulses, halo, haloMaterial };
});
const channelButtons = [...document.querySelectorAll("[data-channel]")];
const txReadout = document.getElementById("tx-readout");
const txRelation = document.getElementById("tx-relation");
function receiverStatus(index) {
const tune = state.rxTune[index];
return { tune, match: tune === state.txChannel };
}
function updateReceiverReadout(index) {
const receiver = receivers[index];
const status = receiverStatus(index);
const suffix = String(status.tune).padStart(2, "0");
const dot = document.getElementById(`rx-${index === 0 ? "a" : "b"}-dot`);
const relation = document.getElementById(`rx-${index === 0 ? "a" : "b"}-relation`);
const tune = document.getElementById(`rx-${index === 0 ? "a" : "b"}-tune`);
tune.textContent = suffix;
dot.classList.toggle("match", status.match);
relation.classList.toggle("match", status.match);
relation.textContent = status.match ? "MATCH · RX ON" : "NO MATCH · RX OFF";
}
function refreshState() {
const channelText = String(state.txChannel).padStart(2, "0");
txReadout.textContent = `CH ${channelText}`;
txRelation.textContent = `CH ${channelText}`;
channelButtons.forEach((button) => {
const active = Number(button.dataset.channel) === state.txChannel;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
drawDisplay(
txDisplay,
"TX-01 / SYNTHETIC",
`CHANNEL ${channelText}`,
"BROADCASTING",
"EMISSION ACTIVE",
true
);
receivers.forEach((receiver, index) => {
const status = receiverStatus(index);
const suffix = String(status.tune).padStart(2, "0");
const link = links[index];
drawDisplay(
receiver.display,
`${receiver.id} / SIMULATED`,
`TUNED CH ${suffix}`,
status.match ? "LOCK / MATCH" : "NO MATCH",
status.match ? "ACCEPTED SIGNAL" : "IGNORED SIGNAL",
status.match
);
receiver.waveform.visible = status.match;
receiver.bars.forEach(({ mesh }) => { mesh.visible = status.match; });
receiver.ledMaterial.color.setHex(status.match ? 0x42d9cb : 0xe99555);
receiver.ledMaterial.emissive.setHex(status.match ? 0x087c76 : 0x7f2f12);
receiver.ledMaterial.emissiveIntensity = status.match ? 1.4 : 0.25;
link.material.color.setHex(status.match ? 0x16b9ae : 0x879aa2);
link.material.opacity = status.match ? 0.78 : 0.22;
link.pulseGroup.visible = status.match;
link.halo.visible = status.match;
updateReceiverReadout(index);
});
}
channelButtons.forEach((button) => {
button.addEventListener("click", () => {
state.txChannel = Number(button.dataset.channel);
refreshState();
});
});
window.addEventListener("keydown", (event) => {
if (event.key === "1" || event.key === "2" || event.key === "3") {
state.txChannel = Number(event.key);
refreshState();
} else if (event.key.toLowerCase() === "r") {
resetView();
}
});
// Camera controls are implemented directly without Three.js addons.
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.52, 1.36);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
13,
31
);
updateCamera();
}, { passive: false });
function resetView() {
controls.radius = window.innerWidth < 680 ? 27 : 20.5;
controls.phi = 1.03;
controls.theta = 0.58;
controls.target.set(0, 1.8, 0);
updateCamera();
}
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
refreshState();
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
// Transmission animation: pale carrier rings always originate at TX.
emissionRings.forEach((ring, i) => {
const phase = (elapsed * 0.34 + i / emissionRings.length) % 1;
const scale = 0.65 + phase * 3.6;
ring.scale.setScalar(scale);
ring.material.opacity = 0.23 * (1 - phase);
});
emitterCore.material.emissiveIntensity = 1.25 + Math.sin(elapsed * 3.1) * 0.35;
receivers.forEach((receiver, index) => {
// This is the single source of truth used by both geometry and readouts.
const status = receiverStatus(index);
const link = links[index];
if (!status.match) {
link.pulseGroup.visible = false;
link.halo.visible = false;
receiver.waveform.visible = false;
receiver.bars.forEach(({ mesh }) => { mesh.visible = false; });
receiver.ledMaterial.emissiveIntensity = 0.25;
return;
}
link.pulseGroup.visible = true;
link.halo.visible = true;
receiver.waveform.visible = true;
receiver.bars.forEach(({ mesh }) => { mesh.visible = true; });
const travelPhase = (elapsed * 0.42 + index * 0.17) % 1;
link.pulses.forEach((pulse, pulseIndex) => {
const phase = (travelPhase - pulseIndex * 0.052 + 1) % 1;
pulse.position.copy(link.curve.getPoint(phase));
pulse.material.opacity = 0.95 * (1 - pulseIndex * 0.27);
const pulseScale = 1 + Math.sin(elapsed * 8 - pulseIndex) * 0.08;
pulse.scale.setScalar(pulseScale);
});
const haloPhase = (elapsed * 0.82 + index * 0.31) % 1;
link.halo.scale.setScalar(0.72 + haloPhase * 1.9);
link.haloMaterial.opacity = 0.72 * (1 - haloPhase);
link.halo.quaternion.copy(camera.quaternion);
const positions = receiver.waveformGeometry.attributes.position.array;
for (let i = 0; i < 31; i++) {
const wave = Math.sin(i * 0.72 - elapsed * 8.2) * 0.105
+ Math.sin(i * 0.27 + elapsed * 4.1) * 0.045;
positions[i * 3 + 1] = 1.08 + wave;
}
receiver.waveformGeometry.attributes.position.needsUpdate = true;
receiver.bars.forEach(({ mesh, baseHeight }, barIndex) => {
const activity = 0.38 + 0.62 * (0.5 + 0.5 * Math.sin(elapsed * 7.4 - barIndex * 0.8 + index));
const height = baseHeight * activity;
mesh.scale.y = height;
mesh.position.y = 0.43 + height * 0.5;
mesh.material.emissiveIntensity = 0.75 + activity * 0.8;
});
receiver.ledMaterial.emissiveIntensity = 1.15 + Math.sin(elapsed * 6.5) * 0.25;
});
renderer.render(scene, camera);
}
animate();
loading.remove();
// Read-only introspection for verifying all discrete model states.
Object.defineProperty(window, "broadcastModel", {
value: {
getState: () => ({
transmitterChannel: state.txChannel,
receivers: receivers.map((receiver, index) => ({
id: receiver.id,
tunedChannel: state.rxTune[index],
receptionEnabled: receiverStatus(index).match
}))
})
}
});
</script>
</body>
</html>
```