Prompt specification
Build or customize the Three.js 3D scene "Radio tuning dial and antenna 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: Radio tuning dial and antenna model
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/radio-tuning-dial-and-antenna-model-x2521
Scene Description Prompt:
Build a period radio cabinet with tuning dial, antenna, and speaker grille. Show the physical control moving a separate schematic frequency-selection marker. Use Three.js from cdnjs in a single HTML file, with stylized solid shapes.
Working Three.js Starter (radio-tuning-dial-and-antenna-model-x2521):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Period Radio — Mechanical Tuning</title>
<style>
:root {
--ink: #101827;
--cream: #f2e5c8;
--orange: #ff7043;
--cyan: #6dd6d0;
--muted: #9aabc2;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
color: var(--cream);
}
.title {
position: absolute;
top: 24px;
left: 26px;
max-width: 320px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--orange);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3vw, 46px);
font-weight: 500;
letter-spacing: -0.025em;
line-height: 1;
}
.subtitle {
margin-top: 10px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.frequency-card {
position: absolute;
top: 24px;
right: 26px;
min-width: 194px;
padding: 15px 18px 14px;
border: 1px solid rgba(242, 229, 200, 0.14);
border-radius: 14px;
background: rgba(16, 24, 39, 0.78);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(12px);
}
.frequency-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.frequency-value {
margin-top: 3px;
color: var(--orange);
font-family: Georgia, "Times New Roman", serif;
font-size: 35px;
font-variant-numeric: tabular-nums;
line-height: 1.1;
}
.live {
display: flex;
align-items: center;
gap: 8px;
margin-top: 8px;
color: var(--cyan);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.live::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 12px var(--cyan);
content: "";
}
.instructions {
position: absolute;
left: 50%;
bottom: 22px;
display: flex;
align-items: center;
gap: 18px;
max-width: calc(100% - 32px);
padding: 11px 14px 11px 17px;
border: 1px solid rgba(242, 229, 200, 0.12);
border-radius: 999px;
background: rgba(16, 24, 39, 0.78);
color: var(--muted);
font-size: 11px;
white-space: nowrap;
transform: translateX(-50%);
backdrop-filter: blur(12px);
}
.instructions strong {
color: var(--cream);
font-weight: 700;
}
.separator {
width: 1px;
height: 14px;
background: rgba(242, 229, 200, 0.16);
}
button {
pointer-events: auto;
border: 0;
border-radius: 999px;
padding: 8px 12px;
background: rgba(109, 214, 208, 0.12);
color: var(--cyan);
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
transition: background 150ms ease, transform 150ms ease;
}
button:hover {
background: rgba(109, 214, 208, 0.22);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--orange);
outline-offset: 2px;
}
.link-note {
position: absolute;
top: 47%;
left: 50%;
padding: 7px 10px;
border: 1px solid rgba(255, 112, 67, 0.28);
border-radius: 999px;
background: rgba(16, 24, 39, 0.82);
color: #ffb29c;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
transform: translate(-50%, -50%);
white-space: nowrap;
}
@media (max-width: 700px) {
.title {
top: 18px;
left: 18px;
}
.subtitle,
.link-note {
display: none;
}
.frequency-card {
top: 16px;
right: 16px;
min-width: 142px;
padding: 11px 13px;
}
.frequency-value {
font-size: 28px;
}
.instructions {
bottom: 14px;
gap: 10px;
width: calc(100% - 28px);
justify-content: center;
white-space: normal;
text-align: center;
}
.instructions .optional,
.separator {
display: none;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive vintage radio and schematic tuning display"></main>
<div class="hud">
<section class="title">
<div class="eyebrow">Mechanical control study · 1948</div>
<h1>Broadcast Cabinet</h1>
<div class="subtitle">
Turn the physical tuning control to move the independent schematic
frequency-selection marker.
</div>
</section>
<section class="frequency-card" aria-live="polite">
<div class="frequency-label">Selected frequency</div>
<div class="frequency-value" id="frequencyValue">98.4 MHz</div>
<div class="live">Control linked</div>
</section>
<div class="link-note">Physical knob → schematic marker</div>
<div class="instructions">
<span><strong>Drag knob</strong> to tune</span>
<span class="separator"></span>
<span class="optional"><strong>Drag scene</strong> to orbit</span>
<span class="separator optional"></span>
<span class="optional"><strong>Scroll</strong> to zoom</span>
<button id="resetView" type="button">Reset view</button>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.querySelector("#scene");
const frequencyValue = document.querySelector("#frequencyValue");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x101827);
scene.fog = new THREE.Fog(0x101827, 18, 34);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
container.appendChild(renderer.domElement);
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"3D period radio. Drag the tuning knob vertically, or use the left and right arrow keys."
);
const camera = new THREE.OrthographicCamera(-7, 7, 4.25, -4.25, 0.1, 80);
const cameraTarget = new THREE.Vector3(0, 3.45, 0);
const spherical = new THREE.Spherical(15, 1.23, 0.24);
const clock = new THREE.Clock();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xb9d7ff, 0x3a241c, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe2b8, 3.2);
keyLight.position.set(-5, 10, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x6dd6d0, 1.65);
rimLight.position.set(7, 5, -4);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xff8a55, 14, 11, 2);
warmLight.position.set(-2.4, 4.5, 4.5);
scene.add(warmLight);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const materials = {
cabinet: new THREE.MeshStandardMaterial({
color: 0x9d542d,
roughness: 0.56,
metalness: 0.03
}),
cabinetEdge: new THREE.MeshStandardMaterial({
color: 0xc27740,
roughness: 0.48
}),
inset: new THREE.MeshStandardMaterial({
color: 0x6f3924,
roughness: 0.7
}),
dark: new THREE.MeshStandardMaterial({
color: 0x111925,
roughness: 0.72
}),
darker: new THREE.MeshStandardMaterial({
color: 0x09111c,
roughness: 0.9
}),
brass: new THREE.MeshStandardMaterial({
color: 0xd5a85e,
roughness: 0.32,
metalness: 0.72
}),
brassDark: new THREE.MeshStandardMaterial({
color: 0x876235,
roughness: 0.4,
metalness: 0.65
}),
cream: new THREE.MeshStandardMaterial({
color: 0xe8d8b6,
roughness: 0.84
}),
orange: new THREE.MeshStandardMaterial({
color: 0xff7043,
emissive: 0x7b1f08,
emissiveIntensity: 0.45,
roughness: 0.4
}),
cyan: new THREE.MeshStandardMaterial({
color: 0x6dd6d0,
emissive: 0x123e42,
emissiveIntensity: 0.3,
roughness: 0.5
}),
panel: new THREE.MeshStandardMaterial({
color: 0x172538,
roughness: 0.72,
metalness: 0.08
}),
block: new THREE.MeshStandardMaterial({
color: 0x29445a,
roughness: 0.6,
metalness: 0.1
}),
stage: new THREE.MeshStandardMaterial({
color: 0x0a1321,
roughness: 0.86,
metalness: 0.08
})
};
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function roundedRectShape(width, height, radius) {
const x = -width / 2;
const y = -height / 2;
const r = Math.min(radius, width / 2, height / 2);
const shape = new THREE.Shape();
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
return shape;
}
function roundedSlab(
width,
height,
radius,
depth,
material,
bevel = 0.035
) {
const geometry = new THREE.ExtrudeGeometry(
roundedRectShape(width, height, radius),
{
depth,
steps: 1,
curveSegments: 14,
bevelEnabled: bevel > 0,
bevelSegments: 3,
bevelSize: Math.min(bevel, radius * 0.35),
bevelThickness: Math.min(bevel, depth * 0.3)
}
);
geometry.center();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function box(width, height, depth, material) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
material,
radialSegments = 48
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
radialSegments
),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function createTextPlane(
text,
width,
height,
color = "#f2e5c8",
fontSize = 64,
fontWeight = 700
) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
mesh.renderOrder = 4;
function draw(value) {
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = color;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = `${fontWeight} ${fontSize}px Arial, sans-serif`;
context.fillText(value, 256, 66, 490);
texture.needsUpdate = true;
}
draw(text);
return { mesh, canvas, context, texture, draw };
}
function createDynamicFrequencyLabel() {
const label = createTextPlane("98.4 MHz", 1.42, 0.35, "#ff8a66", 58, 800);
return label;
}
// ------------------------------------------------------------
// Ground and stage
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 30),
materials.stage
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.09;
ground.receiveShadow = true;
scene.add(ground);
const plinth = box(10.6, 0.13, 3.5, materials.dark);
plinth.position.set(0, -0.015, 0.1);
plinth.receiveShadow = true;
scene.add(plinth);
const plinthInset = box(9.9, 0.018, 2.9, materials.panel);
plinthInset.position.set(0, 0.058, 0.12);
plinthInset.receiveShadow = true;
scene.add(plinthInset);
// ------------------------------------------------------------
// Period radio cabinet
// ------------------------------------------------------------
const radio = new THREE.Group();
radio.position.set(-2.35, 2.54, 0.15);
radio.rotation.y = -0.075;
scene.add(radio);
const cabinet = roundedSlab(
3.55,
4.75,
0.3,
0.82,
materials.cabinet,
0.08
);
radio.add(cabinet);
const face = roundedSlab(
3.25,
4.44,
0.24,
0.1,
materials.cabinetEdge,
0.035
);
face.position.z = 0.445;
radio.add(face);
const centerBand = roundedSlab(
2.95,
4.12,
0.2,
0.055,
materials.inset,
0.02
);
centerBand.position.z = 0.51;
radio.add(centerBand);
// Brand plate
const brand = createTextPlane(
"A U R O R A",
1.42,
0.25,
"#e9c581",
54,
800
);
brand.mesh.position.set(0, 1.93, 0.57);
radio.add(brand.mesh);
// Speaker recess and cone
const grilleRecess = roundedSlab(
2.67,
1.45,
0.25,
0.07,
materials.darker,
0.025
);
grilleRecess.position.set(0, 0.91, 0.56);
radio.add(grilleRecess);
const speakerCone = cylinder(0.6, 0.6, 0.055, materials.dark, 64);
speakerCone.rotation.x = Math.PI / 2;
speakerCone.position.set(0, 0.91, 0.61);
radio.add(speakerCone);
const speakerInner = cylinder(0.37, 0.37, 0.025, materials.darker, 64);
speakerInner.rotation.x = Math.PI / 2;
speakerInner.position.set(0, 0.91, 0.65);
radio.add(speakerInner);
// Solid brass grille bars
for (let i = 0; i < 13; i++) {
const x = -1.15 + i * (2.3 / 12);
const bar = box(0.045, 1.15, 0.07, materials.brassDark);
bar.position.set(x, 0.91, 0.665);
radio.add(bar);
}
for (const y of [0.38, 1.44]) {
const rail = box(2.42, 0.07, 0.09, materials.brass);
rail.position.set(0, y, 0.68);
radio.add(rail);
}
// Radio tuning dial
const dialFrame = roundedSlab(
2.38,
0.84,
0.17,
0.13,
materials.dark,
0.045
);
dialFrame.position.set(-0.35, -0.79, 0.59);
radio.add(dialFrame);
const dialGlass = roundedSlab(
2.17,
0.62,
0.12,
0.045,
materials.cream,
0.014
);
dialGlass.position.set(-0.35, -0.79, 0.68);
radio.add(dialGlass);
const dialBaseline = box(1.96, 0.018, 0.018, materials.inset);
dialBaseline.position.set(-0.35, -0.84, 0.715);
radio.add(dialBaseline);
const radioDialMin = -1.3;
const radioDialMax = 0.6;
for (let i = 0; i <= 20; i++) {
const major = i % 4 === 0;
const tick = box(
major ? 0.025 : 0.015,
major ? 0.19 : 0.1,
0.018,
materials.inset
);
const x = radioDialMin + (i / 20) * (radioDialMax - radioDialMin);
tick.position.set(x, -0.765, 0.716);
radio.add(tick);
}
for (const [value, x] of [
["88", -1.28],
["92", -0.76],
["96", -0.24],
["100", 0.28],
["108", 0.61]
]) {
const number = createTextPlane(value, 0.3, 0.16, "#48372c", 48, 700);
number.mesh.position.set(x, -1.01, 0.72);
radio.add(number.mesh);
}
const bandLabel = createTextPlane(
"FM · MHz",
0.75,
0.16,
"#59402e",
46,
800
);
bandLabel.mesh.position.set(-0.35, -0.57, 0.72);
radio.add(bandLabel.mesh);
// Radio dial pointer
const radioPointer = new THREE.Group();
radioPointer.position.set(-0.35, -0.76, 0.735);
radio.add(radioPointer);
const pointerStem = box(0.025, 0.28, 0.025, materials.orange);
pointerStem.position.y = 0.035;
radioPointer.add(pointerStem);
const pointerShape = new THREE.Shape();
pointerShape.moveTo(-0.075, 0);
pointerShape.lineTo(0.075, 0);
pointerShape.lineTo(0, -0.13);
pointerShape.closePath();
const pointerHead = new THREE.Mesh(
new THREE.ShapeGeometry(pointerShape),
materials.orange
);
pointerHead.position.y = -0.095;
radioPointer.add(pointerHead);
// Physical tuning knob
const knobPivot = new THREE.Group();
knobPivot.position.set(1.15, -0.8, 0.77);
radio.add(knobPivot);
const knobBase = cylinder(0.34, 0.36, 0.15, materials.brassDark, 64);
knobBase.rotation.x = Math.PI / 2;
knobBase.position.z = -0.04;
knobPivot.add(knobBase);
const knobBody = cylinder(0.31, 0.33, 0.28, materials.brass, 64);
knobBody.rotation.x = Math.PI / 2;
knobBody.position.z = 0.08;
knobPivot.add(knobBody);
const knobCap = cylinder(0.24, 0.26, 0.035, materials.cabinetEdge, 64);
knobCap.rotation.x = Math.PI / 2;
knobCap.position.z = 0.245;
knobPivot.add(knobCap);
const knobRing = new THREE.Mesh(
new THREE.TorusGeometry(0.34, 0.027, 12, 64),
materials.brassDark
);
knobRing.position.z = 0.12;
knobPivot.add(knobRing);
const knobIndicator = box(0.05, 0.15, 0.035, materials.cream);
knobIndicator.position.set(0, 0.155, 0.27);
knobPivot.add(knobIndicator);
const knobLabel = createTextPlane(
"TUNING",
0.48,
0.14,
"#efd8b6",
40,
800
);
knobLabel.mesh.position.set(1.15, -1.29, 0.6);
radio.add(knobLabel.mesh);
const interactiveMeshes = [knobBase, knobBody, knobCap, knobRing, knobIndicator];
interactiveMeshes.forEach((mesh) => {
mesh.userData.isTuningKnob = true;
});
// Cabinet feet
for (const x of [-1.2, 1.2]) {
const foot = roundedSlab(
0.46,
0.25,
0.08,
0.44,
materials.dark,
0.025
);
foot.position.set(x, -2.47, -0.02);
radio.add(foot);
}
// Antenna assembly
const antenna = new THREE.Group();
antenna.position.set(1.08, 2.42, -0.13);
antenna.rotation.z = -0.135;
radio.add(antenna);
const antennaBase = cylinder(0.16, 0.19, 0.2, materials.brassDark, 40);
antennaBase.position.y = 0.03;
antenna.add(antennaBase);
const antennaLower = cylinder(0.048, 0.058, 1.55, materials.brass, 32);
antennaLower.position.y = 0.82;
antenna.add(antennaLower);
const antennaCollar = cylinder(0.073, 0.073, 0.12, materials.brassDark, 32);
antennaCollar.position.y = 1.52;
antenna.add(antennaCollar);
const antennaUpper = cylinder(0.026, 0.038, 1.36, materials.brass, 32);
antennaUpper.position.y = 2.02;
antenna.add(antennaUpper);
const antennaTip = new THREE.Mesh(
new THREE.SphereGeometry(0.07, 20, 12),
materials.brass
);
antennaTip.position.y = 2.72;
antenna.add(antennaTip);
// ------------------------------------------------------------
// Separate schematic panel
// ------------------------------------------------------------
const schematic = new THREE.Group();
schematic.position.set(2.72, 2.38, -0.32);
schematic.rotation.y = 0.035;
scene.add(schematic);
const schematicBoard = roundedSlab(
3.72,
3.57,
0.24,
0.22,
materials.panel,
0.06
);
schematic.add(schematicBoard);
const schematicFace = roundedSlab(
3.42,
3.27,
0.18,
0.045,
materials.dark,
0.018
);
schematicFace.position.z = 0.135;
schematic.add(schematicFace);
const schematicTitle = createTextPlane(
"FREQUENCY SELECT",
2.55,
0.31,
"#6dd6d0",
52,
800
);
schematicTitle.mesh.position.set(-0.27, 1.32, 0.19);
schematic.add(schematicTitle.mesh);
const dynamicFrequencyLabel = createDynamicFrequencyLabel();
dynamicFrequencyLabel.mesh.position.set(1.0, 0.91, 0.2);
schematic.add(dynamicFrequencyLabel.mesh);
// Schematic signal blocks
const oscillator = roundedSlab(
0.78,
0.48,
0.08,
0.055,
materials.block,
0.02
);
oscillator.position.set(-1.08, 0.21, 0.2);
schematic.add(oscillator);
const filter = roundedSlab(
0.91,
0.48,
0.08,
0.055,
materials.block,
0.02
);
filter.position.set(0, 0.21, 0.2);
schematic.add(filter);
const antennaBlock = roundedSlab(
0.78,
0.48,
0.08,
0.055,
materials.block,
0.02
);
antennaBlock.position.set(1.08, 0.21, 0.2);
schematic.add(antennaBlock);
const oscillatorLabel = createTextPlane(
"OSC",
0.46,
0.15,
"#bce9e6",
50,
800
);
oscillatorLabel.mesh.position.set(-1.08, 0.21, 0.25);
schematic.add(oscillatorLabel.mesh);
const filterLabel = createTextPlane(
"FILTER",
0.65,
0.15,
"#bce9e6",
45,
800
);
filterLabel.mesh.position.set(0, 0.21, 0.25);
schematic.add(filterLabel.mesh);
const antennaLabel = createTextPlane(
"ANT",
0.46,
0.15,
"#bce9e6",
50,
800
);
antennaLabel.mesh.position.set(1.08, 0.21, 0.25);
schematic.add(antennaLabel.mesh);
for (const x of [-0.59, 0.59]) {
const connection = box(0.34, 0.025, 0.02, materials.cyan);
connection.position.set(x, 0.21, 0.225);
schematic.add(connection);
}
const schematicScale = box(2.95, 0.018, 0.018, materials.cyan);
schematicScale.position.set(0, -0.69, 0.205);
schematic.add(schematicScale);
const schematicMin = -1.42;
const schematicMax = 1.42;
for (let i = 0; i <= 20; i++) {
const major = i % 4 === 0;
const tick = box(
major ? 0.025 : 0.014,
major ? 0.22 : 0.12,
0.018,
materials.cyan
);
const x = schematicMin + (i / 20) * (schematicMax - schematicMin);
tick.position.set(x, -0.59, 0.21);
schematic.add(tick);
}
for (const [value, x] of [
["88", -1.39],
["92", -0.72],
["96", -0.02],
["100", 0.68],
["108", 1.39]
]) {
const number = createTextPlane(value, 0.34, 0.17, "#9ddbd7", 47, 700);
number.mesh.position.set(x, -1.13, 0.22);
schematic.add(number.mesh);
}
const scaleCaption = createTextPlane(
"MHz",
0.45,
0.16,
"#5c747f",
45,
800
);
scaleCaption.mesh.position.set(0, -1.39, 0.22);
schematic.add(scaleCaption.mesh);
// Independent schematic marker
const schematicMarker = new THREE.Group();
schematicMarker.position.set(0, -0.61, 0.25);
schematic.add(schematicMarker);
const markerStem = box(0.035, 0.47, 0.03, materials.orange);
markerStem.position.y = 0.1;
schematicMarker.add(markerStem);
const markerShape = new THREE.Shape();
markerShape.moveTo(-0.095, 0);
markerShape.lineTo(0.095, 0);
markerShape.lineTo(0, -0.16);
markerShape.closePath();
const markerHead = new THREE.Mesh(
new THREE.ShapeGeometry(markerShape),
materials.orange
);
markerHead.position.y = -0.26;
schematicMarker.add(markerHead);
const markerGlow = new THREE.Mesh(
new THREE.SphereGeometry(0.065, 20, 12),
new THREE.MeshStandardMaterial({
color: 0xffb08e,
emissive: 0xff552b,
emissiveIntensity: 2,
roughness: 0.35
})
);
markerGlow.position.y = -0.03;
schematicMarker.add(markerGlow);
// Schematic stand
const schematicPost = box(2.8, 0.65, 0.13, materials.panel);
schematicPost.position.set(0, -2.02, -0.08);
schematic.add(schematicPost);
const schematicFoot = box(3.35, 0.12, 1.0, materials.dark);
schematicFoot.position.set(0, -2.29, -0.04);
schematic.add(schematicFoot);
// ------------------------------------------------------------
// Mechanical-to-schematic connection line
// ------------------------------------------------------------
const linkMaterial = new THREE.LineDashedMaterial({
color: 0xff8058,
dashSize: 0.11,
gapSize: 0.075,
transparent: true,
opacity: 0.58,
depthWrite: false
});
let linkLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
new THREE.Vector3()
]),
linkMaterial
);
linkLine.renderOrder = 2;
scene.add(linkLine);
function updateConnectionLine() {
scene.updateMatrixWorld(true);
const start = knobPivot.getWorldPosition(new THREE.Vector3());
start.z += 0.18;
const end = schematicMarker.getWorldPosition(new THREE.Vector3());
end.y += 0.08;
end.z += 0.08;
const midpoint = start
.clone()
.lerp(end, 0.5)
.add(new THREE.Vector3(0, 0.95, 0.85));
const curve = new THREE.QuadraticBezierCurve3(start, midpoint, end);
const points = curve.getPoints(48);
linkLine.geometry.dispose();
linkLine.geometry = new THREE.BufferGeometry().setFromPoints(points);
linkLine.computeLineDistances();
}
// ------------------------------------------------------------
// Frequency state and mechanical linkage
// ------------------------------------------------------------
const minFrequency = 88;
const maxFrequency = 108;
let frequency = 98.4;
function setFrequency(value) {
frequency = Math.round(
Math.max(minFrequency, Math.min(maxFrequency, value)) * 10
) / 10;
const normalized =
(frequency - minFrequency) / (maxFrequency - minFrequency);
knobPivot.rotation.z = -2.25 + normalized * 4.5;
radioPointer.position.x =
radioDialMin + normalized * (radioDialMax - radioDialMin);
schematicMarker.position.x =
schematicMin + normalized * (schematicMax - schematicMin);
dynamicFrequencyLabel.draw(`${frequency.toFixed(1)} MHz`);
frequencyValue.textContent = `${frequency.toFixed(1)} MHz`;
updateConnectionLine();
}
setFrequency(frequency);
// ------------------------------------------------------------
// Custom camera controls
// ------------------------------------------------------------
let zoom = 1;
let viewportHeight = 8.5;
function updateProjection() {
const aspect = window.innerWidth / window.innerHeight;
viewportHeight = Math.max(8.5, 8.8 / aspect);
camera.left = (-viewportHeight * aspect) / 2;
camera.right = (viewportHeight * aspect) / 2;
camera.top = viewportHeight / 2;
camera.bottom = -viewportHeight / 2;
camera.zoom = zoom;
camera.updateProjectionMatrix();
}
function updateCamera() {
const offset = new THREE.Vector3().setFromSpherical(spherical);
camera.position.copy(cameraTarget).add(offset);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraTarget.set(0, 3.45, 0);
spherical.set(15, 1.23, 0.24);
zoom = 1;
updateProjection();
updateCamera();
}
updateProjection();
updateCamera();
window.addEventListener("resize", () => {
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateProjection();
});
document.querySelector("#resetView").addEventListener("click", resetCamera);
renderer.domElement.addEventListener("dblclick", resetCamera);
// ------------------------------------------------------------
// Knob interaction and camera orbit
// ------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const drag = {
active: false,
mode: null,
lastX: 0,
lastY: 0,
totalX: 0,
totalY: 0
};
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function isKnobHit(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(interactiveMeshes, false).length > 0;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.focus({ preventScroll: true });
renderer.domElement.setPointerCapture(event.pointerId);
drag.active = true;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.totalX = 0;
drag.totalY = 0;
if (event.button === 0 && isKnobHit(event)) {
drag.mode = "knob";
renderer.domElement.style.cursor = "ns-resize";
} else {
drag.mode = "orbit";
renderer.domElement.style.cursor = "grabbing";
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!drag.active) {
renderer.domElement.style.cursor = isKnobHit(event)
? "ns-resize"
: "grab";
return;
}
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.totalX += dx;
drag.totalY += dy;
if (drag.mode === "knob") {
setFrequency(frequency - dy * 0.045 + dx * 0.018);
} else if (drag.mode === "orbit") {
spherical.theta -= dx * 0.006;
spherical.phi -= dy * 0.005;
spherical.phi = THREE.MathUtils.clamp(spherical.phi, 0.48, 1.48);
spherical.theta = THREE.MathUtils.clamp(spherical.theta, -1.05, 1.05);
updateCamera();
}
});
function endDrag(event) {
drag.active = false;
drag.mode = null;
renderer.domElement.style.cursor = isKnobHit(event) ? "ns-resize" : "grab";
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("pointerleave", (event) => {
if (!drag.active) {
renderer.domElement.style.cursor = "grab";
}
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.9
);
updateProjection();
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("keydown", (event) => {
if (event.key === "ArrowUp" || event.key === "ArrowRight") {
event.preventDefault();
setFrequency(frequency + 0.1);
}
if (event.key === "ArrowDown" || event.key === "ArrowLeft") {
event.preventDefault();
setFrequency(frequency - 0.1);
}
if (event.key === "Home") {
event.preventDefault();
resetCamera();
}
});
renderer.domElement.style.cursor = "grab";
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
function animate() {
const elapsed = clock.getElapsedTime();
markerGlow.material.emissiveIntensity =
1.7 + Math.sin(elapsed * 3.2) * 0.35;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```