Prompt specification
Build or customize the Three.js 3D scene "Tune among competing illustrative broadcast channels" 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: Tune among competing illustrative broadcast channels
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/tune-among-competing-illustrative-broadcast-channels-x2524
Scene Description Prompt:
Create a standalone low-poly scene in one HTML file using Three.js from cdnjs. Let users select receiver frequency while several labeled fictional channels are present. Show selected content and interference as simplified signals rather than a full radio propagation model.
Working Three.js Starter (tune-among-competing-illustrative-broadcast-channels-x2524):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Frequency Grove</title>
<style>
:root {
--accent: #ff8066;
--panel: rgba(15, 31, 35, 0.84);
--panel-border: rgba(255, 255, 255, 0.13);
--text: #f3f7f3;
--muted: #a9bbb8;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9d5dc;
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(13, 31, 35, 0.12), transparent 24%),
linear-gradient(0deg, rgba(13, 31, 35, 0.25), transparent 38%);
z-index: 2;
}
.glass {
background: var(--panel);
border: 1px solid var(--panel-border);
box-shadow: 0 18px 50px rgba(6, 22, 26, 0.18);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.brand {
position: fixed;
z-index: 5;
top: 24px;
left: 24px;
max-width: 390px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #173b40;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 23px;
height: 3px;
border-radius: 99px;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}
.brand h1 {
margin: 0;
color: #15373c;
font-size: clamp(30px, 4vw, 54px);
line-height: 0.95;
letter-spacing: -0.055em;
}
.brand p {
max-width: 340px;
margin: 12px 0 0;
color: #31565a;
font-size: 13px;
line-height: 1.5;
}
.brand-actions {
display: flex;
align-items: center;
gap: 12px;
margin-top: 14px;
pointer-events: auto;
}
.ghost-button {
border: 1px solid rgba(23, 59, 64, 0.22);
border-radius: 999px;
padding: 7px 11px;
color: #264d51;
background: rgba(255, 255, 255, 0.42);
cursor: pointer;
font-size: 11px;
font-weight: 750;
}
.ghost-button:hover {
background: rgba(255, 255, 255, 0.72);
}
.camera-hint {
color: rgba(23, 59, 64, 0.68);
font-size: 11px;
}
.receiver-card {
position: fixed;
z-index: 5;
top: 24px;
right: 24px;
width: 310px;
padding: 18px;
border-radius: 20px;
}
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 18px;
}
.card-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
}
.lock-state {
padding: 5px 8px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 999px;
color: #9fe1bd;
background: rgba(91, 192, 137, 0.12);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.11em;
}
.lock-state[data-state="partial"] {
color: #ffd382;
background: rgba(255, 181, 77, 0.13);
}
.lock-state[data-state="none"] {
color: #ff9b91;
background: rgba(255, 104, 86, 0.13);
}
#contentName {
overflow: hidden;
margin-bottom: 5px;
color: var(--text);
font-size: 25px;
font-weight: 760;
letter-spacing: -0.035em;
text-overflow: ellipsis;
white-space: nowrap;
}
#contentGenre {
min-height: 34px;
margin-bottom: 18px;
color: var(--muted);
font-size: 12px;
line-height: 1.4;
}
.readout-row {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 7px;
}
#carrierFreq {
color: var(--accent);
font-variant-numeric: tabular-nums;
font-size: 20px;
font-weight: 800;
}
#carrierSignal {
color: var(--muted);
font-size: 11px;
font-variant-numeric: tabular-nums;
}
.signal-bars {
display: grid;
grid-template-columns: repeat(8, 1fr);
align-items: end;
gap: 4px;
height: 22px;
margin-bottom: 19px;
}
.signal-bars span {
height: 100%;
border-radius: 3px 3px 1px 1px;
background: rgba(255, 255, 255, 0.1);
transform-origin: bottom;
}
.signal-bars span.active {
background: var(--accent);
}
.interference-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.interference-head span:first-child {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#interferenceValue {
color: #ffae78;
font-size: 11px;
font-weight: 800;
font-variant-numeric: tabular-nums;
}
.interference-track {
height: 6px;
overflow: hidden;
border-radius: 99px;
background: rgba(255, 255, 255, 0.1);
}
#interferenceFill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #ffd166, #ff6f61);
transition: width 180ms ease;
}
#interferenceSources {
min-height: 34px;
margin-top: 9px;
color: #c6d2cf;
font-size: 10px;
line-height: 1.55;
}
.model-note {
margin-top: 12px;
padding-top: 11px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
color: #7f9996;
font-size: 9px;
line-height: 1.45;
}
.dock {
position: fixed;
z-index: 6;
left: 50%;
bottom: 22px;
width: min(760px, calc(100% - 36px));
padding: 16px 18px 14px;
border-radius: 22px;
transform: translateX(-50%);
}
.dock-main {
display: grid;
grid-template-columns: 125px 1fr;
align-items: center;
gap: 19px;
}
.frequency-readout small {
display: block;
margin-bottom: 4px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
}
#frequencyReadout {
color: var(--text);
font-size: 30px;
font-weight: 780;
font-variant-numeric: tabular-nums;
letter-spacing: -0.045em;
}
#frequencyReadout span {
margin-left: 3px;
color: var(--muted);
font-size: 12px;
font-weight: 650;
letter-spacing: 0;
}
.slider-wrap {
position: relative;
padding-top: 2px;
}
#frequencySlider {
--progress: 38%;
width: 100%;
height: 7px;
margin: 7px 0 12px;
border-radius: 99px;
outline: none;
appearance: none;
-webkit-appearance: none;
background: linear-gradient(
to right,
var(--accent) 0%,
var(--accent) var(--progress),
rgba(255, 255, 255, 0.13) var(--progress),
rgba(255, 255, 255, 0.13) 100%
);
cursor: ew-resize;
}
#frequencySlider::-webkit-slider-thumb {
width: 19px;
height: 19px;
border: 4px solid #f7faf6;
border-radius: 50%;
appearance: none;
-webkit-appearance: none;
background: var(--accent);
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}
#frequencySlider::-moz-range-thumb {
width: 12px;
height: 12px;
border: 4px solid #f7faf6;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}
.ticks {
display: flex;
justify-content: space-between;
color: #78928f;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.station-list {
display: flex;
gap: 7px;
margin-top: 13px;
overflow-x: auto;
padding-bottom: 2px;
scrollbar-width: thin;
}
.station-chip {
flex: 0 0 auto;
display: flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 999px;
color: #aec0bd;
background: rgba(255, 255, 255, 0.04);
cursor: pointer;
font-size: 10px;
transition: 150ms ease;
}
.station-chip:hover {
border-color: rgba(255, 255, 255, 0.24);
color: #fff;
transform: translateY(-1px);
}
.station-chip.selected {
border-color: color-mix(in srgb, var(--dot) 65%, transparent);
color: #fff;
background: color-mix(in srgb, var(--dot) 14%, transparent);
}
.station-chip .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--dot);
box-shadow: 0 0 9px var(--dot);
}
.station-chip strong {
color: #fff;
font-variant-numeric: tabular-nums;
}
.dock-footer {
display: flex;
justify-content: space-between;
gap: 12px;
margin-top: 10px;
color: #76918e;
font-size: 9px;
}
#labels {
position: fixed;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.station-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 9px 6px 7px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 999px;
color: #173c40;
background: rgba(250, 252, 246, 0.86);
box-shadow: 0 5px 15px rgba(22, 55, 58, 0.12);
font-size: 10px;
font-weight: 720;
white-space: nowrap;
transform: translate(-50%, -100%);
transition: opacity 120ms ease;
}
.station-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 13px;
background: rgba(23, 60, 64, 0.4);
}
.station-label .label-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--station-color);
}
.station-label .label-frequency {
color: #5e7876;
font-variant-numeric: tabular-nums;
}
.station-label.active {
border-color: var(--station-color);
box-shadow: 0 5px 18px color-mix(in srgb, var(--station-color) 30%, transparent);
}
@media (max-width: 760px) {
.brand {
top: 16px;
left: 16px;
}
.brand h1 {
font-size: 34px;
}
.brand p {
display: none;
}
.receiver-card {
top: 103px;
right: 12px;
width: 270px;
padding: 14px;
}
.dock {
bottom: 10px;
width: calc(100% - 20px);
padding: 13px;
}
.dock-main {
grid-template-columns: 100px 1fr;
gap: 10px;
}
#frequencyReadout {
font-size: 25px;
}
.dock-footer span:last-child {
display: none;
}
}
@media (max-width: 520px) {
.brand-actions .camera-hint {
display: none;
}
.receiver-card {
top: 87px;
right: 10px;
width: calc(100% - 20px);
}
.card-top {
margin-bottom: 10px;
}
#contentGenre {
min-height: 0;
margin-bottom: 12px;
}
.model-note {
display: none;
}
.station-label {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="vignette"></div>
<div id="labels" aria-hidden="true"></div>
<header class="brand">
<div class="eyebrow">Portable field receiver / 04</div>
<h1>Frequency<br>Grove</h1>
<p>
Tune a fictional FM landscape. Nearby stations remain visible while
colored signals overlap at the receiver.
</p>
<div class="brand-actions">
<button class="ghost-button" id="resetView" type="button">Reset view</button>
<span class="camera-hint">Drag to orbit · Scroll to zoom</span>
</div>
</header>
<aside class="receiver-card glass" aria-live="polite">
<div class="card-top">
<span class="card-kicker">Now receiving</span>
<span class="lock-state" id="lockState" data-state="locked">LOCKED</span>
</div>
<div id="contentName">Vector 91</div>
<div id="contentGenre">Jazz · Studio sessions</div>
<div class="readout-row">
<span id="carrierFreq">91.2 MHz</span>
<span id="carrierSignal">82% carrier</span>
</div>
<div class="signal-bars" id="signalBars" aria-label="Carrier strength">
<span></span><span></span><span></span><span></span>
<span></span><span></span><span></span><span></span>
</div>
<div class="interference-head">
<span>Interference sketch</span>
<span id="interferenceValue">0%</span>
</div>
<div class="interference-track">
<div id="interferenceFill"></div>
</div>
<div id="interferenceSources">Clean local band</div>
<div class="model-note">
Carrier strength and overlap are deliberately schematic.
This is not a radio-propagation or terrain simulation.
</div>
</aside>
<footer class="dock glass">
<div class="dock-main">
<div class="frequency-readout">
<small>Tuning</small>
<div id="frequencyReadout">91.2<span>MHz</span></div>
</div>
<div class="slider-wrap">
<input
id="frequencySlider"
type="range"
min="86"
max="104"
step="0.1"
value="91.2"
aria-label="Receiver frequency in megahertz"
>
<div class="ticks" aria-hidden="true">
<span>86</span><span>90</span><span>94</span>
<span>98</span><span>102</span><span>104</span>
</div>
</div>
</div>
<div class="station-list" id="stationList"></div>
<div class="dock-footer">
<span>Fictional channels · stylized spectrum overlap</span>
<span>Select a channel or tune the dial</span>
</div>
</footer>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const labelsHost = document.getElementById("labels");
const frequencySlider = document.getElementById("frequencySlider");
const frequencyReadout = document.getElementById("frequencyReadout");
const contentName = document.getElementById("contentName");
const contentGenre = document.getElementById("contentGenre");
const carrierFreq = document.getElementById("carrierFreq");
const carrierSignal = document.getElementById("carrierSignal");
const signalBars = [...document.querySelectorAll("#signalBars span")];
const lockState = document.getElementById("lockState");
const interferenceValue = document.getElementById("interferenceValue");
const interferenceFill = document.getElementById("interferenceFill");
const interferenceSources = document.getElementById("interferenceSources");
const stationList = document.getElementById("stationList");
const stations = [
{
id: "moss",
frequency: 88.4,
name: "Moss FM",
genre: "Ambient · field reports and gentle weather",
color: 0x65c6a3,
css: "#65c6a3",
power: 0.90,
x: -8.2,
z: -3.6
},
{
id: "vector",
frequency: 91.2,
name: "Vector 91",
genre: "Jazz · late-night studio sessions",
color: 0xff8066,
css: "#ff8066",
power: 0.96,
x: 7.3,
z: -5.2
},
{
id: "sparrow",
frequency: 93.0,
name: "Sparrow Lab",
genre: "Test loops · experimental calibration signals",
color: 0xf2c45f,
css: "#f2c45f",
power: 0.58,
x: -2.8,
z: -9.6
},
{
id: "harbor",
frequency: 96.6,
name: "Harbor 96",
genre: "Local news · coastal reports and interviews",
color: 0x63a9ed,
css: "#63a9ed",
power: 0.84,
x: 9.3,
z: 1.4
},
{
id: "neon",
frequency: 100.8,
name: "Neon 100",
genre: "Arcade mix · synths, chiptunes and game music",
color: 0xb58af4,
css: "#b58af4",
power: 0.74,
x: -8.8,
z: 5.4
}
];
let currentFrequency = 91.2;
let currentTuning = null;
const renderer = new THREE.WebGLRenderer({
antialias: true,
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",
"Low-poly radio landscape with selectable fictional stations"
);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xbad7de);
scene.fog = new THREE.Fog(0xbad7de, 22, 46);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 0.8, 0);
const defaultCamera = {
azimuth: 0.48,
polar: 0.90,
distance: 27
};
const cameraState = { ...defaultCamera };
function updateCamera() {
const { azimuth, polar, distance } = cameraState;
const horizontal = Math.sin(polar) * distance;
camera.position.set(
cameraTarget.x + horizontal * Math.sin(azimuth),
cameraTarget.y + Math.cos(polar) * distance,
cameraTarget.z + horizontal * Math.cos(azimuth)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xe8f6ff, 0x56684d, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d1, 2.8);
sun.position.set(9, 17, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0x9bc9df, 0.65);
fillLight.position.set(-10, 8, -8);
scene.add(fillLight);
let seed = 81573;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
function terrainHeight(x, z) {
const radius = Math.hypot(x, z);
const edgeFactor = THREE.MathUtils.clamp((radius - 4) / 8, 0, 1);
return (
edgeFactor *
(0.3 * Math.sin(x * 0.4) +
0.22 * Math.cos(z * 0.34) +
0.12 * Math.sin((x - z) * 0.27))
);
}
function buildTerrain() {
const positions = [];
const colors = [];
const ringCount = 5;
const segmentCount = 18;
const radius = 14;
function edgeScale(angle) {
return 1 + 0.035 * Math.sin(angle * 3) + 0.018 * Math.cos(angle * 5);
}
function point(ring, angle) {
const r = (ring / ringCount) * radius * edgeScale(angle);
const x = Math.cos(angle) * r;
const z = Math.sin(angle) * r;
return new THREE.Vector3(x, terrainHeight(x, z), z);
}
function triangle(a, b, c) {
positions.push(a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z);
const color = new THREE.Color(0x789a70);
color.offsetHSL(
(random() - 0.5) * 0.025,
(random() - 0.5) * 0.06,
(random() - 0.5) * 0.09
);
for (let i = 0; i < 3; i++) {
colors.push(color.r, color.g, color.b);
}
}
for (let segment = 0; segment < segmentCount; segment++) {
const a0 = (segment / segmentCount) * Math.PI * 2;
const a1 = ((segment + 1) / segmentCount) * Math.PI * 2;
const center = new THREE.Vector3(0, terrainHeight(0, 0), 0);
triangle(center, point(1, a1), point(1, a0));
}
for (let ring = 1; ring < ringCount; ring++) {
for (let segment = 0; segment < segmentCount; segment++) {
const a0 = (segment / segmentCount) * Math.PI * 2;
const a1 = ((segment + 1) / segmentCount) * Math.PI * 2;
const inner0 = point(ring, a0);
const inner1 = point(ring, a1);
const outer0 = point(ring + 1, a0);
const outer1 = point(ring + 1, a1);
triangle(inner0, inner1, outer0);
triangle(inner1, outer1, outer0);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.96,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const terrain = new THREE.Mesh(geometry, material);
terrain.receiveShadow = true;
scene.add(terrain);
const skirtPositions = [];
const skirtColors = [];
for (let segment = 0; segment < segmentCount; segment++) {
const a0 = (segment / segmentCount) * Math.PI * 2;
const a1 = ((segment + 1) / segmentCount) * Math.PI * 2;
const p0 = point(ringCount, a0);
const p1 = point(ringCount, a1);
const b0 = new THREE.Vector3(p0.x, -1.25, p0.z);
const b1 = new THREE.Vector3(p1.x, -1.25, p1.z);
skirtPositions.push(
p0.x, p0.y, p0.z,
b1.x, b1.y, b1.z,
p0.x, b0.y, p0.z,
p1.x, p1.y, p1.z,
b1.x, b1.y, b1.z,
b0.x, b0.y, b0.z
);
const sideColor = new THREE.Color(0x6e624e);
for (let i = 0; i < 6; i++) {
skirtColors.push(sideColor.r, sideColor.g, sideColor.b);
}
}
const skirtGeometry = new THREE.BufferGeometry();
skirtGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(skirtPositions, 3)
);
skirtGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(skirtColors, 3)
);
skirtGeometry.computeVertexNormals();
const skirt = new THREE.Mesh(
skirtGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
})
);
skirt.receiveShadow = true;
scene.add(skirt);
}
buildTerrain();
const pond = new THREE.Mesh(
new THREE.CircleGeometry(1.65, 18),
new THREE.MeshStandardMaterial({
color: 0x72b8b5,
roughness: 0.28,
metalness: 0.03,
transparent: true,
opacity: 0.88
})
);
pond.rotation.x = -Math.PI / 2;
pond.scale.set(1.45, 0.72, 1);
pond.position.set(-3.5, 0.035, -0.4);
pond.receiveShadow = true;
scene.add(pond);
function createMountain(x, z, radius, height, color) {
const group = new THREE.Group();
group.position.set(x, terrainHeight(x, z), z);
const mountain = new THREE.Mesh(
new THREE.ConeGeometry(radius, height, 5),
new THREE.MeshStandardMaterial({
color,
roughness: 1,
flatShading: true
})
);
mountain.position.y = height / 2;
mountain.rotation.y = random() * Math.PI;
mountain.castShadow = true;
mountain.receiveShadow = true;
group.add(mountain);
const capHeight = height * 0.29;
const cap = new THREE.Mesh(
new THREE.ConeGeometry(radius * 0.43, capHeight, 5),
new THREE.MeshStandardMaterial({
color: 0xe8efea,
roughness: 1,
flatShading: true
})
);
cap.position.y = height - capHeight * 0.48;
cap.rotation.y = mountain.rotation.y;
group.add(cap);
scene.add(group);
}
createMountain(-10.8, -10.8, 3.4, 5.4, 0x71858a);
createMountain(-5.4, -12.0, 3.0, 4.7, 0x80918d);
createMountain(1.0, -12.7, 3.6, 5.8, 0x687f84);
createMountain(7.4, -11.4, 3.8, 6.2, 0x7a8c88);
createMountain(12.0, -8.3, 2.8, 4.6, 0x6e8387);
function createTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, terrainHeight(x, z), z);
group.rotation.y = random() * Math.PI * 2;
group.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.17, 0.85, 5),
new THREE.MeshStandardMaterial({
color: 0x73543e,
roughness: 1,
flatShading: true
})
);
trunk.position.y = 0.42;
trunk.castShadow = true;
group.add(trunk);
const crownMaterial = new THREE.MeshStandardMaterial({
color: random() > 0.5 ? 0x356f58 : 0x3f795d,
roughness: 1,
flatShading: true
});
const lower = new THREE.Mesh(
new THREE.ConeGeometry(0.57, 1.45, 6),
crownMaterial
);
lower.position.y = 1.15;
lower.castShadow = true;
group.add(lower);
const upper = new THREE.Mesh(
new THREE.ConeGeometry(0.42, 1.12, 6),
crownMaterial
);
upper.position.y = 1.78;
upper.castShadow = true;
group.add(upper);
scene.add(group);
}
let treesPlaced = 0;
let attempts = 0;
while (treesPlaced < 25 && attempts < 500) {
attempts++;
const angle = random() * Math.PI * 2;
const radius = 4.1 + random() * 7.7;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius;
const nearStation = stations.some(
station => Math.hypot(x - station.x, z - station.z) < 2.1
);
const nearReceiver = Math.hypot(x, z - 3.2) < 3.4;
const nearPond = Math.hypot(x + 3.5, z + 0.4) < 2.6;
if (nearStation || nearReceiver || nearPond) continue;
createTree(x, z, 0.72 + random() * 0.55);
treesPlaced++;
}
for (let i = 0; i < 18; i++) {
const angle = random() * Math.PI * 2;
const radius = 7 + random() * 5.5;
const x = Math.cos(angle) * radius;
const z = Math.sin(angle) * radius;
if (stations.some(station => Math.hypot(x - station.x, z - station.z) < 1.7)) {
continue;
}
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.22 + random() * 0.28, 0),
new THREE.MeshStandardMaterial({
color: 0x8b9387,
roughness: 1,
flatShading: true
})
);
rock.position.set(x, terrainHeight(x, z) + 0.16, z);
rock.scale.y = 0.65 + random() * 0.4;
rock.rotation.set(random(), random(), random());
rock.castShadow = true;
scene.add(rock);
}
const clouds = [];
function createCloud(x, y, z, scale) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
const material = new THREE.MeshStandardMaterial({
color: 0xf2f4e9,
roughness: 1,
flatShading: true,
transparent: true,
opacity: 0.78
});
const pieces = [
[-0.8, 0, 0, 0.8],
[0, 0.15, 0, 1.0],
[0.85, -0.05, 0, 0.7]
];
for (const [px, py, pz, size] of pieces) {
const piece = new THREE.Mesh(
new THREE.IcosahedronGeometry(size, 1),
material
);
piece.position.set(px, py, pz);
piece.scale.y = 0.6;
group.add(piece);
}
scene.add(group);
clouds.push(group);
}
createCloud(-7, 8.5, -8, 1.15);
createCloud(6, 9.2, -6, 0.9);
createCloud(12, 7.7, 0, 0.72);
const receiver = new THREE.Group();
receiver.position.set(0, terrainHeight(0, 3.2), 3.2);
scene.add(receiver);
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0xe8dfc9,
roughness: 0.9,
flatShading: true
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: 0x35575a,
roughness: 0.88,
flatShading: true
});
const stationBody = new THREE.Mesh(
new THREE.BoxGeometry(3.1, 1.5, 2.1),
wallMaterial
);
stationBody.position.y = 0.75;
stationBody.castShadow = true;
stationBody.receiveShadow = true;
receiver.add(stationBody);
const roof = new THREE.Mesh(
new THREE.ConeGeometry(2.35, 0.95, 4),
roofMaterial
);
roof.position.y = 1.86;
roof.rotation.y = Math.PI / 4;
roof.scale.z = 0.78;
roof.castShadow = true;
receiver.add(roof);
const consoleBox = new THREE.Mesh(
new THREE.BoxGeometry(2.8, 1.08, 0.18),
new THREE.MeshStandardMaterial({
color: 0x18383c,
roughness: 0.7,
flatShading: true
})
);
consoleBox.position.set(0, 0.93, 1.13);
consoleBox.castShadow = true;
receiver.add(consoleBox);
const displayCanvas = document.createElement("canvas");
displayCanvas.width = 640;
displayCanvas.height = 280;
const displayContext = displayCanvas.getContext("2d");
const displayTexture = new THREE.CanvasTexture(displayCanvas);
displayTexture.colorSpace = THREE.SRGBColorSpace;
const display = new THREE.Mesh(
new THREE.PlaneGeometry(2.48, 0.95),
new THREE.MeshBasicMaterial({ map: displayTexture })
);
display.position.set(0, 1.0, 1.231);
receiver.add(display);
const door = new THREE.Mesh(
new THREE.BoxGeometry(0.52, 0.95, 0.08),
new THREE.MeshStandardMaterial({
color: 0xd06d55,
roughness: 0.9,
flatShading: true
})
);
door.position.set(-1.05, 0.48, 1.1);
receiver.add(door);
const antennaMast = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.065, 3.4, 6),
new THREE.MeshStandardMaterial({
color: 0x334c4e,
roughness: 0.8
})
);
antennaMast.position.set(-1.9, 1.7, -0.35);
antennaMast.castShadow = true;
receiver.add(antennaMast);
for (let i = 0; i < 4; i++) {
const arm = new THREE.Mesh(
new THREE.BoxGeometry(1.15 - i * 0.18, 0.045, 0.045),
new THREE.MeshStandardMaterial({ color: 0x334c4e })
);
arm.position.set(-1.9, 1.25 + i * 0.53, -0.35);
receiver.add(arm);
}
const dish = new THREE.Mesh(
new THREE.CylinderGeometry(0.48, 0.13, 0.18, 12),
new THREE.MeshStandardMaterial({
color: 0xe5dfcb,
roughness: 0.85,
flatShading: true,
side: THREE.DoubleSide
})
);
dish.position.set(1.65, 1.8, -0.1);
dish.rotation.z = -0.8;
dish.rotation.x = 0.25;
dish.castShadow = true;
receiver.add(dish);
const receiverSignalPoint = receiver.position.clone().add(
new THREE.Vector3(0, 2.62, 0.35)
);
const receiverRings = [];
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.54, 0.035, 4, 32),
new THREE.MeshBasicMaterial({
color: 0xff8066,
transparent: true,
opacity: 0,
depthWrite: false
})
);
ring.position.copy(receiverSignalPoint);
ring.rotation.x = Math.PI / 2;
ring.userData.phase = i / 3;
receiverRings.push(ring);
scene.add(ring);
}
const interferenceLines = [];
for (let lineIndex = 0; lineIndex < 3; lineIndex++) {
const points = [];
for (let pointIndex = 0; pointIndex < 26; pointIndex++) {
const x = -1.15 + (pointIndex / 25) * 2.3;
const jagged =
Math.sin(pointIndex * 2.3 + lineIndex) * 0.09 +
(random() - 0.5) * 0.13;
points.push(new THREE.Vector3(x, jagged, 0));
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineBasicMaterial({
color: lineIndex === 1 ? 0xff8066 : 0xf3c45f,
transparent: true,
opacity: 0,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.position.copy(receiver.position).add(
new THREE.Vector3((lineIndex - 1) * 0.12, 2.42, 0.72)
);
line.userData.baseY = line.position.y;
line.userData.phase = lineIndex * 1.7;
interferenceLines.push(line);
scene.add(line);
}
const spectrumGroup = new THREE.Group();
spectrumGroup.position.set(
2.75,
terrainHeight(2.75, 3.0),
3.0
);
spectrumGroup.rotation.y = -0.2;
scene.add(spectrumGroup);
const spectrumBase = new THREE.Mesh(
new THREE.BoxGeometry(2.55, 0.18, 0.48),
new THREE.MeshStandardMaterial({
color: 0x244247,
roughness: 0.82,
flatShading: true
})
);
spectrumBase.position.y = 0.09;
spectrumBase.castShadow = true;
spectrumGroup.add(spectrumBase);
const spectrumBars = [];
for (let i = 0; i < 11; i++) {
const bar = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.095, 1, 5),
new THREE.MeshBasicMaterial({ color: 0x5c8b87 })
);
bar.position.x = -1.02 + (i / 10) * 2.04;
bar.position.y = 0.65;
bar.scale.y = 0.2;
spectrumGroup.add(bar);
spectrumBars.push(bar);
}
const frequencyMarker = new THREE.Mesh(
new THREE.ConeGeometry(0.12, 0.32, 4),
new THREE.MeshBasicMaterial({ color: 0xffffff })
);
frequencyMarker.rotation.z = Math.PI;
frequencyMarker.position.y = 0.35;
spectrumGroup.add(frequencyMarker);
function createStation(station) {
const group = new THREE.Group();
group.position.set(
station.x,
terrainHeight(station.x, station.z),
station.z
);
scene.add(group);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(0.78, 0.9, 0.24, 6),
new THREE.MeshStandardMaterial({
color: 0x435555,
roughness: 0.95,
flatShading: true
})
);
platform.position.y = 0.12;
platform.castShadow = true;
platform.receiveShadow = true;
group.add(platform);
const mast = new THREE.Mesh(
new THREE.CylinderGeometry(0.065, 0.12, 2.9, 6),
new THREE.MeshStandardMaterial({
color: 0x3d5253,
roughness: 0.82
})
);
mast.position.y = 1.55;
mast.castShadow = true;
group.add(mast);
const accentMaterial = new THREE.MeshStandardMaterial({
color: station.color,
emissive: station.color,
emissiveIntensity: 0.28,
roughness: 0.62,
flatShading: true
});
for (let i = 0; i < 3; i++) {
const crossbar = new THREE.Mesh(
new THREE.BoxGeometry(1.25 - i * 0.25, 0.09, 0.1),
accentMaterial
);
crossbar.position.y = 1.85 + i * 0.42;
crossbar.castShadow = true;
group.add(crossbar);
}
const building = new THREE.Mesh(
new THREE.BoxGeometry(0.92, 0.62, 0.72),
new THREE.MeshStandardMaterial({
color: 0xe2dcc8,
roughness: 0.92,
flatShading: true
})
);
building.position.set(0.54, 0.48, 0.25);
building.castShadow = true;
group.add(building);
const accentPanel = new THREE.Mesh(
new THREE.BoxGeometry(0.52, 0.16, 0.04),
accentMaterial
);
accentPanel.position.set(0.54, 0.59, 0.63);
group.add(accentPanel);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: station.color,
emissive: station.color,
emissiveIntensity: 1.4,
roughness: 0.35
});
const beacon = new THREE.Mesh(
new THREE.OctahedronGeometry(0.18),
beaconMaterial
);
beacon.position.y = 3.13;
group.add(beacon);
const pulseRings = [];
for (let i = 0; i < 3; i++) {
const pulse = new THREE.Mesh(
new THREE.TorusGeometry(0.68, 0.026, 4, 20),
new THREE.MeshBasicMaterial({
color: station.color,
transparent: true,
opacity: 0,
depthWrite: false
})
);
pulse.position.y = 0.32;
pulse.userData.phase = i / 3;
pulseRings.push(pulse);
group.add(pulse);
}
const source = group.position.clone().add(new THREE.Vector3(0, 2.85, 0));
const target = receiver.position.clone().add(new THREE.Vector3(0, 2.45, 0.45));
const midpoint = source.clone().lerp(target, 0.52);
midpoint.y = Math.max(source.y, target.y) + 1.7;
const curve = new THREE.CatmullRomCurve3([source, midpoint, target]);
const pathGeometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(60)
);
const pathMaterial = new THREE.LineDashedMaterial({
color: station.color,
transparent: true,
opacity: 0.12,
dashSize: 0.35,
gapSize: 0.2,
depthWrite: false
});
const path = new THREE.Line(pathGeometry, pathMaterial);
path.computeLineDistances();
scene.add(path);
const packets = [];
for (let i = 0; i < 3; i++) {
const packet = new THREE.Mesh(
new THREE.TetrahedronGeometry(0.14),
new THREE.MeshBasicMaterial({
color: station.color,
transparent: true,
opacity: 0.35,
depthWrite: false
})
);
scene.add(packet);
packets.push(packet);
}
const label = document.createElement("div");
label.className = "station-label";
label.style.setProperty("--station-color", station.css);
label.innerHTML = `
<span class="label-dot"></span>
<span>${station.name}</span>
<span class="label-frequency">${station.frequency.toFixed(1)}</span>
`;
labelsHost.appendChild(label);
Object.assign(station, {
group,
beacon,
beaconMaterial,
pulseRings,
curve,
path,
pathMaterial,
packets,
label,
labelAnchor: group.position.clone().add(new THREE.Vector3(0, 3.8, 0))
});
}
stations.forEach(createStation);
const stationButtons = new Map();
for (const station of stations) {
const button = document.createElement("button");
button.className = "station-chip";
button.type = "button";
button.style.setProperty("--dot", station.css);
button.innerHTML = `
<span class="dot"></span>
<strong>${station.frequency.toFixed(1)}</strong>
<span>${station.name}</span>
`;
button.addEventListener("click", () => {
setFrequency(station.frequency);
});
stationList.appendChild(button);
stationButtons.set(station.id, button);
}
function gaussian(distance, spread) {
return Math.exp(-(distance * distance) / (2 * spread * spread));
}
function calculateTuning(frequency) {
const evaluated = stations.map(station => {
const distance = Math.abs(station.frequency - frequency);
const transmitterDistance = Math.hypot(
station.x - receiver.position.x,
station.z - receiver.position.z
);
const attenuation = 1 - Math.min(0.24, transmitterDistance / 85);
const carrier =
station.power * attenuation * gaussian(distance, 0.92);
return {
station,
distance,
carrier
};
});
const selected = evaluated.reduce((best, item) =>
item.carrier > best.carrier ? item : best
);
const sourceContributions = evaluated
.filter(item => item.station !== selected.station)
.map(item => ({
station: item.station,
amount:
item.station.power *
(1 - Math.min(0.24, Math.hypot(
item.station.x - receiver.position.x,
item.station.z - receiver.position.z
) / 85)) *
gaussian(item.distance, 2.12) *
0.28
}))
.filter(item => item.amount > 0.018)
.sort((a, b) => b.amount - a.amount);
const interference = THREE.MathUtils.clamp(
sourceContributions.reduce((sum, item) => sum + item.amount, 0),
0,
0.72
);
if (interference > 0) {
sourceContributions.forEach(item => {
item.share = item.amount / interference;
});
}
return {
selected,
interference,
sourceContributions
};
}
function updateTuning() {
currentTuning = calculateTuning(currentFrequency);
const { selected, interference, sourceContributions } = currentTuning;
const station = selected.station;
const carrier = selected.carrier;
const accent = station.css;
document.documentElement.style.setProperty("--accent", accent);
frequencyReadout.innerHTML = `${currentFrequency.toFixed(1)}<span>MHz</span>`;
carrierFreq.textContent = `${currentFrequency.toFixed(1)} MHz`;
carrierSignal.textContent = `${Math.round(carrier * 100)}% carrier`;
const progress =
((currentFrequency - Number(frequencySlider.min)) /
(Number(frequencySlider.max) - Number(frequencySlider.min))) *
100;
frequencySlider.style.setProperty("--progress", `${progress}%`);
const hasCarrier = carrier >= 0.08;
contentName.textContent = hasCarrier ? station.name : "No clear carrier";
contentGenre.textContent = hasCarrier
? station.genre
: "Move the receiver dial closer to a labeled channel.";
if (carrier >= 0.34) {
lockState.textContent = "LOCKED";
lockState.dataset.state = "locked";
} else if (carrier >= 0.08) {
lockState.textContent = "PARTIAL";
lockState.dataset.state = "partial";
} else {
lockState.textContent = "NO CARRIER";
lockState.dataset.state = "none";
}
signalBars.forEach((bar, index) => {
bar.classList.toggle(
"active",
index / signalBars.length < carrier * 1.08
);
});
interferenceValue.textContent = `${Math.round(interference * 100)}%`;
interferenceFill.style.width = `${interference * 100}%`;
if (sourceContributions.length) {
interferenceSources.textContent = sourceContributions
.slice(0, 3)
.map(
item =>
`${item.station.name} ${Math.round(item.share * 100)}% bleed`
)
.join(" · ");
} else {
interferenceSources.textContent = "Clean local band · no adjacent bleed";
}
for (const candidate of stations) {
stationButtons.get(candidate.id).classList.toggle(
"selected",
candidate.id === station.id
);
candidate.label.classList.toggle(
"active",
candidate.id === station.id
);
}
}
function setFrequency(value) {
currentFrequency = THREE.MathUtils.clamp(
Number(value),
Number(frequencySlider.min),
Number(frequencySlider.max)
);
frequencySlider.value = currentFrequency.toFixed(1);
updateTuning();
}
frequencySlider.addEventListener("input", event => {
setFrequency(event.target.value);
});
document.getElementById("resetView").addEventListener("click", () => {
Object.assign(cameraState, defaultCamera);
updateCamera();
});
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.azimuth -= deltaX * 0.006;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + deltaY * 0.004,
0.48,
1.24
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance + event.deltaY * 0.018,
16,
38
);
updateCamera();
},
{ passive: false }
);
function drawReceiverDisplay(time) {
const context = displayContext;
const tuning = currentTuning;
if (!tuning) return;
const station = tuning.selected.station;
const carrier = tuning.selected.carrier;
const interference = tuning.interference;
context.clearRect(0, 0, 640, 280);
context.fillStyle = "#10292d";
context.fillRect(0, 0, 640, 280);
context.fillStyle = "rgba(255,255,255,0.035)";
for (let x = 0; x < 640; x += 32) {
context.fillRect(x, 0, 1, 280);
}
for (let y = 0; y < 280; y += 32) {
context.fillRect(0, y, 640, 1);
}
context.fillStyle = station.css;
context.fillRect(20, 18, 7, 34);
context.font = "800 29px system-ui, sans-serif";
context.fillStyle = "#f4f8f3";
context.fillText(station.name.toUpperCase(), 40, 46);
context.font = "700 22px system-ui, sans-serif";
context.textAlign = "right";
context.fillStyle = station.css;
context.fillText(`${currentFrequency.toFixed(1)} MHz`, 618, 43);
context.textAlign = "left";
context.font = "600 15px system-ui, sans-serif";
context.fillStyle = "#8da8a5";
context.fillText(
carrier >= 0.08 ? "PROGRAM / SCHEMATIC CARRIER" : "SEARCHING FOR PROGRAM",
22,
79
);
context.strokeStyle = "rgba(255,255,255,0.08)";
context.lineWidth = 1;
context.beginPath();
context.moveTo(20, 96);
context.lineTo(620, 96);
context.stroke();
context.strokeStyle = station.css;
context.lineWidth = 3;
context.beginPath();
const amplitude = 8 + carrier * 22 + interference * 14;
for (let x = 20; x <= 620; x += 3) {
const normalized = (x - 20) / 600;
const wave =
Math.sin(normalized * 22 + time * 4.2) * amplitude * 0.45 +
Math.sin(normalized * 51 - time * 2.1) * amplitude * 0.2 +
Math.sin(normalized * 8 + time) * amplitude * 0.22;
const noise =
interference * Math.sin(x * 1.73 + time * 18) * 5;
const y = 157 + wave + noise;
if (x === 20) context.moveTo(x, y);
else context.lineTo(x, y);
}
context.stroke();
context.fillStyle = "rgba(255,255,255,0.06)";
context.fillRect(20, 219, 600, 31);
const binCount = 30;
for (let i = 0; i < binCount; i++) {
const x = 20 + (i / binCount) * 600;
const binWidth = 600 / binCount - 3;
const frequency = 86 + (i / (binCount - 1)) * 18;
let strength = 0;
for (const candidate of stations) {
strength +=
candidate.power *
gaussian(frequency - candidate.frequency, 1.25);
}
const height = 3 + Math.min(25, strength * 25);
context.fillStyle = station.css;
context.globalAlpha = 0.55;
context.fillRect(x, 247 - height, binWidth, height);
}
context.globalAlpha = 1;
displayTexture.needsUpdate = true;
}
const clock = new THREE.Clock();
let previousDisplayUpdate = -1;
function animate(now) {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
const tuning = currentTuning;
for (const station of stations) {
const distance = Math.abs(station.frequency - currentFrequency);
const relevance =
station.power * gaussian(distance, 1.65);
const selected = tuning.selected.station === station;
station.pathMaterial.opacity = 0.045 + relevance * 0.44;
station.pathMaterial.dashOffset = -time * 0.4;
station.packets.forEach((packet, index) => {
const t = (time * 0.12 + index / station.packets.length) % 1;
packet.position.copy(station.curve.getPointAt(t));
packet.rotation.set(time * 0.8 + index, time * 1.2, index * 0.8);
packet.material.opacity = 0.08 + relevance * 0.72;
const scale = selected ? 1.35 : 0.9;
packet.scale.setScalar(scale);
});
station.pulseRings.forEach((ring, index) => {
const phase = (time * 0.28 + ring.userData.phase) % 1;
const scale = 0.75 + phase * 1.55;
ring.scale.setScalar(scale);
ring.material.opacity = (1 - phase) * relevance * 0.34;
});
station.beacon.rotation.y = time * 0.8;
station.beaconMaterial.emissiveIntensity =
0.65 + relevance * 1.45 + Math.sin(time * 3) * 0.1;
}
const selectedStation = tuning.selected.station;
const selectedColor = new THREE.Color(selectedStation.color);
receiverRings.forEach((ring, index) => {
const phase = (time * 0.36 + ring.userData.phase) % 1;
ring.position.copy(receiverSignalPoint);
ring.scale.setScalar(0.65 + phase * 1.7);
ring.material.color.copy(selectedColor);
ring.material.opacity =
(1 - phase) * tuning.selected.carrier * 0.5;
});
interferenceLines.forEach((line, index) => {
line.visible = tuning.interference > 0.018;
line.material.opacity =
tuning.interference * (0.28 + index * 0.18);
line.position.y =
line.userData.baseY + Math.sin(time * 4 + line.userData.phase) * 0.025;
});
spectrumBars.forEach((bar, index) => {
const frequency = 86 + (index / (spectrumBars.length - 1)) * 18;
const weightedColor = new THREE.Color(0, 0, 0);
let total = 0;
for (const candidate of stations) {
const contribution =
candidate.power *
gaussian(frequency - candidate.frequency, 1.25);
total += contribution;
weightedColor.add(
new THREE.Color(candidate.color).multiplyScalar(contribution)
);
}
const height = 0.16 + Math.min(1.65, total * 0.78);
bar.scale.y = height;
bar.position.y = 0.18 + height / 2;
if (total > 0.001) {
weightedColor.multiplyScalar(1 / total);
bar.material.color.copy(weightedColor);
}
});
const markerProgress =
(currentFrequency - 86) / (104 - 86);
frequencyMarker.position.x = -1.02 + markerProgress * 2.04;
frequencyMarker.material.color.copy(selectedColor);
clouds.forEach((cloud, index) => {
cloud.position.x += 0.0008 * (index + 1);
if (cloud.position.x > 17) cloud.position.x = -17;
});
for (const station of stations) {
const projected = station.labelAnchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
station.label.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
station.label.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
station.label.style.opacity = visible ? "1" : "0";
}
if (now - previousDisplayUpdate > 75) {
drawReceiverDisplay(time);
previousDisplayUpdate = now;
}
renderer.render(scene, camera);
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
setFrequency(currentFrequency);
animate(0);
</script>
</body>
</html>
```