Prompt specification
Build or customize the Three.js 3D scene "Wind-rose accumulation exhibit" 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: Wind-rose accumulation exhibit
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/wind-rose-accumulation-exhibit-x1280
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing wind direction and speed. Generate synthetic directional observations and grow corresponding radial bins beside a miniature station; let users change the distribution and distinguish frequency from wind speed. Low-poly.
Working Three.js Starter (wind-rose-accumulation-exhibit-x1280):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Wind Field — Directional Observation Study</title>
<style>
:root {
--ink: #10262e;
--muted: #70838a;
--panel: rgba(10, 27, 35, 0.92);
--panel-soft: rgba(255, 255, 255, 0.08);
--line: rgba(255, 255, 255, 0.13);
--mint: #5ce1d0;
--yellow: #ffd166;
--coral: #ff735f;
--white: #f7fbfa;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9c8ce;
color: var(--white);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
select,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.brand {
position: absolute;
top: 22px;
left: 24px;
display: flex;
align-items: center;
gap: 12px;
color: var(--ink);
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brand-mark {
position: relative;
width: 38px;
height: 38px;
border: 2px solid var(--ink);
border-radius: 50%;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--ink);
transform-origin: left center;
}
.brand-mark::before {
width: 13px;
height: 2px;
left: 10px;
top: 17px;
transform: rotate(-35deg);
}
.brand-mark::after {
width: 8px;
height: 8px;
left: 10px;
top: 13px;
border-radius: 50%;
}
.brand h1 {
margin: 0;
font-size: 14px;
line-height: 1;
letter-spacing: 0.19em;
font-weight: 850;
}
.brand p {
margin: 5px 0 0;
color: rgba(16, 38, 46, 0.66);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.panel {
position: absolute;
top: 88px;
left: 22px;
width: 316px;
max-height: calc(100vh - 112px);
overflow: auto;
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 18px;
background: var(--panel);
box-shadow:
0 18px 60px rgba(12, 31, 39, 0.24),
inset 0 1px 0 rgba(255, 255, 255, 0.07);
backdrop-filter: blur(16px);
pointer-events: auto;
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.eyebrow {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 7px;
color: var(--mint);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.sample-id {
color: rgba(255, 255, 255, 0.45);
letter-spacing: 0.08em;
}
.panel h2 {
margin: 0 0 5px;
font-size: 21px;
line-height: 1.15;
letter-spacing: -0.025em;
}
.intro {
margin: 0 0 19px;
color: rgba(247, 251, 250, 0.62);
font-size: 12px;
line-height: 1.55;
}
.control {
margin-top: 15px;
}
.control-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 7px;
}
.control label,
.control-title {
color: rgba(247, 251, 250, 0.78);
font-size: 11px;
font-weight: 650;
letter-spacing: 0.02em;
}
.value {
color: var(--mint);
font-size: 10px;
font-variant-numeric: tabular-nums;
}
select {
width: 100%;
height: 39px;
padding: 0 34px 0 11px;
border: 1px solid var(--line);
border-radius: 9px;
outline: none;
color: var(--white);
background:
linear-gradient(45deg, transparent 50%, #8ca0a7 50%) calc(100% - 15px) 17px / 5px 5px no-repeat,
linear-gradient(135deg, #8ca0a7 50%, transparent 50%) calc(100% - 10px) 17px / 5px 5px no-repeat,
rgba(255, 255, 255, 0.055);
appearance: none;
font-size: 12px;
cursor: pointer;
}
select:focus {
border-color: rgba(92, 225, 208, 0.75);
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 6px 0 2px;
border-radius: 10px;
outline: none;
background: rgba(255, 255, 255, 0.13);
appearance: none;
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 15px;
height: 15px;
border: 3px solid #183640;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 0 1px rgba(92, 225, 208, 0.25);
appearance: none;
}
input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
border: 3px solid #183640;
border-radius: 50%;
background: var(--mint);
}
.range-ends {
display: flex;
justify-content: space-between;
color: rgba(255, 255, 255, 0.35);
font-size: 9px;
}
.buttons {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
margin-top: 18px;
}
button {
height: 39px;
border: 0;
border-radius: 9px;
color: #123039;
background: var(--mint);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.04em;
cursor: pointer;
transition:
transform 120ms ease,
background 120ms ease,
opacity 120ms ease;
}
button:hover {
transform: translateY(-1px);
background: #7cebdd;
}
button:active {
transform: translateY(0);
}
button.secondary {
width: 42px;
padding: 0;
color: var(--white);
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.06);
font-size: 15px;
}
button.secondary:hover {
background: rgba(255, 255, 255, 0.11);
}
.divider {
height: 1px;
margin: 18px 0 15px;
background: var(--line);
}
.legend-title {
margin-bottom: 12px;
color: rgba(255, 255, 255, 0.47);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.encoding {
display: grid;
grid-template-columns: 28px 1fr;
align-items: center;
gap: 9px;
margin: 10px 0;
}
.encoding-icon {
position: relative;
width: 27px;
height: 23px;
}
.encoding-icon.radial::before {
content: "";
position: absolute;
left: 2px;
bottom: 3px;
width: 23px;
height: 6px;
border-radius: 2px;
background: #92a8ae;
}
.encoding-icon.radial::after {
content: "";
position: absolute;
left: 2px;
bottom: 3px;
width: 15px;
height: 6px;
border-radius: 2px;
background: var(--mint);
}
.encoding-icon.height::before {
content: "";
position: absolute;
bottom: 2px;
left: 9px;
width: 10px;
height: 19px;
border-radius: 2px;
background: var(--yellow);
}
.encoding-copy strong {
display: block;
color: rgba(255, 255, 255, 0.88);
font-size: 11px;
font-weight: 700;
}
.encoding-copy span {
display: block;
margin-top: 2px;
color: rgba(255, 255, 255, 0.43);
font-size: 9px;
}
.speed-scale {
margin-top: 14px;
}
.speed-gradient {
height: 7px;
border-radius: 10px;
background: linear-gradient(90deg, #4dd6c6, #ffd166 55%, #ff6b5e);
}
.speed-labels {
display: flex;
justify-content: space-between;
margin-top: 5px;
color: rgba(255, 255, 255, 0.38);
font-size: 9px;
}
.status {
display: flex;
align-items: center;
gap: 8px;
margin-top: 15px;
color: rgba(255, 255, 255, 0.42);
font-size: 9px;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 0 4px rgba(92, 225, 208, 0.1);
}
.metrics {
position: absolute;
top: 22px;
right: 22px;
display: grid;
grid-template-columns: repeat(4, minmax(112px, 1fr));
gap: 8px;
pointer-events: auto;
}
.metric {
min-height: 76px;
padding: 13px 14px;
border: 1px solid rgba(255, 255, 255, 0.28);
border-radius: 13px;
background: rgba(250, 253, 252, 0.8);
box-shadow: 0 9px 30px rgba(24, 52, 60, 0.1);
backdrop-filter: blur(12px);
color: var(--ink);
}
.metric-label {
display: block;
margin-bottom: 7px;
color: rgba(16, 38, 46, 0.56);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.metric-value {
display: block;
font-size: 20px;
font-weight: 800;
line-height: 1;
letter-spacing: -0.04em;
font-variant-numeric: tabular-nums;
}
.metric-value small {
color: rgba(16, 38, 46, 0.55);
font-size: 10px;
font-weight: 650;
letter-spacing: 0;
}
.view-note {
position: absolute;
right: 24px;
bottom: 22px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 10px;
color: rgba(16, 38, 46, 0.65);
background: rgba(250, 253, 252, 0.7);
backdrop-filter: blur(10px);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.tooltip {
position: fixed;
z-index: 20;
display: none;
min-width: 170px;
padding: 11px 12px;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 10px;
color: var(--white);
background: rgba(9, 27, 35, 0.94);
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
pointer-events: none;
font-size: 10px;
line-height: 1.5;
}
.tooltip strong {
display: block;
margin-bottom: 5px;
color: var(--mint);
font-size: 12px;
}
.tooltip-grid {
display: grid;
grid-template-columns: 1fr auto;
gap: 3px 15px;
color: rgba(255, 255, 255, 0.62);
}
.tooltip-grid b {
color: var(--white);
font-weight: 700;
text-align: right;
}
@media (max-width: 900px) {
.metrics {
grid-template-columns: repeat(2, minmax(110px, 1fr));
}
.panel {
top: auto;
bottom: 16px;
left: 16px;
width: 292px;
max-height: 62vh;
}
.view-note {
top: 174px;
right: 16px;
bottom: auto;
}
.brand {
top: 16px;
left: 16px;
}
}
@media (max-width: 560px) {
.brand p {
display: none;
}
.brand h1 {
font-size: 12px;
}
.metrics {
top: 66px;
right: 12px;
grid-template-columns: repeat(2, 98px);
}
.metric {
min-height: 64px;
padding: 10px;
}
.metric-value {
font-size: 17px;
}
.panel {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
max-height: 47vh;
padding: 15px;
}
.panel h2 {
font-size: 18px;
}
.intro,
.divider,
.legend-title,
.encoding,
.speed-scale,
.status {
display: none;
}
.control {
margin-top: 11px;
}
.view-note {
display: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly wind observation visualization"></div>
<div class="ui">
<header class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<h1>WIND / FIELD</h1>
<p>Directional observation study</p>
</div>
</header>
<aside class="panel" aria-label="Synthetic wind data controls">
<div class="eyebrow">
<span>Live generator</span>
<span class="sample-id" id="sampleId">SYN-001</span>
</div>
<h2>Shape the wind field</h2>
<p class="intro">
Generate synthetic “from” directions and grow a 16-bin radial plot.
Each tower combines observation frequency with average wind speed.
</p>
<div class="control">
<div class="control-row">
<label for="distribution">Directional distribution</label>
</div>
<select id="distribution">
<option value="sw">Southwesterly monsoon</option>
<option value="west">Prevailing westerly</option>
<option value="twin">Twin directional corridors</option>
<option value="north">Northern flow</option>
<option value="variable">Broad and variable</option>
<option value="uniform">Uniform compass</option>
</select>
</div>
<div class="control">
<div class="control-row">
<label for="spread">Directional concentration</label>
<span class="value" id="spreadValue">78%</span>
</div>
<input
id="spread"
type="range"
min="0"
max="100"
value="78"
aria-label="Directional concentration"
/>
<div class="range-ends">
<span>Broad</span>
<span>Concentrated</span>
</div>
</div>
<div class="control">
<div class="control-row">
<label for="speedProfile">Wind-speed profile</label>
</div>
<select id="speedProfile">
<option value="steady">Steady breeze</option>
<option value="gusty">Gusty / bimodal</option>
<option value="fresh">Fresh wind</option>
<option value="light">Light air</option>
<option value="variable">Mixed speed classes</option>
</select>
</div>
<div class="control">
<div class="control-row">
<label for="sampleSize">Synthetic observations</label>
<span class="value" id="sampleValue">160</span>
</div>
<input
id="sampleSize"
type="range"
min="30"
max="320"
step="10"
value="160"
aria-label="Number of synthetic observations"
/>
</div>
<div class="buttons">
<button id="regenerate" type="button">↗ Grow new sample</button>
<button
id="pause"
class="secondary"
type="button"
aria-label="Pause wind flow"
title="Pause wind flow"
>
Ⅱ
</button>
</div>
<div class="divider"></div>
<div class="legend-title">Reading the radial plot</div>
<div class="encoding">
<div class="encoding-icon radial"></div>
<div class="encoding-copy">
<strong>Radial length = frequency</strong>
<span>Longer bins contain a larger share of observations.</span>
</div>
</div>
<div class="encoding">
<div class="encoding-icon height"></div>
<div class="encoding-copy">
<strong>Height + color = wind speed</strong>
<span>Tower height and hue show mean speed in m/s.</span>
</div>
</div>
<div class="speed-scale">
<div class="speed-gradient"></div>
<div class="speed-labels">
<span>0 m/s</span>
<span>12</span>
<span>25 m/s</span>
</div>
</div>
<div class="status">
<span class="status-dot"></span>
<span>Synthetic stream active</span>
</div>
</aside>
<section class="metrics" aria-label="Wind summary">
<div class="metric">
<span class="metric-label">Prevailing from</span>
<span class="metric-value" id="prevailingValue">SW <small>225°</small></span>
</div>
<div class="metric">
<span class="metric-label">Mean wind</span>
<span class="metric-value" id="meanValue">7.2 <small>m/s</small></span>
</div>
<div class="metric">
<span class="metric-label">Consistency</span>
<span class="metric-value" id="consistencyValue">74 <small>%</small></span>
</div>
<div class="metric">
<span class="metric-label">Observations</span>
<span class="metric-value" id="observationValue">160</span>
</div>
</section>
<div class="view-note">Drag to orbit · Wheel to zoom · Double-click to reset</div>
</div>
<div class="tooltip" id="tooltip">
<strong id="tooltipTitle">Directional bin</strong>
<div class="tooltip-grid">
<span>Frequency</span><b id="tooltipFrequency"></b>
<span>Mean speed</span><b id="tooltipSpeed"></b>
<span>Observations</span><b id="tooltipCount"></b>
</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 sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9c8ce);
scene.fog = new THREE.Fog(0xb9c8ce, 19, 38);
const camera = new THREE.PerspectiveCamera(
40,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneHost.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xf3fbff, 0x657765, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff5dc, 3.25);
sun.position.set(-9, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const rim = new THREE.DirectionalLight(0xb7e8ff, 1.2);
rim.position.set(10, 8, -12);
scene.add(rim);
const PLOT_X = 1.8;
const PLOT_Z = 0.25;
const BIN_COUNT = 16;
const BIN_ANGLE = 360 / BIN_COUNT;
const INNER_RADIUS = 1.05;
const MAX_RADIAL_LENGTH = 4.3;
const ui = {
distribution: document.getElementById("distribution"),
spread: document.getElementById("spread"),
spreadValue: document.getElementById("spreadValue"),
speedProfile: document.getElementById("speedProfile"),
sampleSize: document.getElementById("sampleSize"),
sampleValue: document.getElementById("sampleValue"),
regenerate: document.getElementById("regenerate"),
pause: document.getElementById("pause"),
sampleId: document.getElementById("sampleId"),
prevailing: document.getElementById("prevailingValue"),
mean: document.getElementById("meanValue"),
consistency: document.getElementById("consistencyValue"),
observations: document.getElementById("observationValue"),
tooltip: document.getElementById("tooltip"),
tooltipTitle: document.getElementById("tooltipTitle"),
tooltipFrequency: document.getElementById("tooltipFrequency"),
tooltipSpeed: document.getElementById("tooltipSpeed"),
tooltipCount: document.getElementById("tooltipCount")
};
const palette = {
terrain: new THREE.Color(0x829b76),
terrainSide: new THREE.Color(0x657d68),
plot: new THREE.Color(0xdce5e2),
dark: new THREE.Color(0x17313a),
mint: new THREE.Color(0x5ce1d0),
yellow: new THREE.Color(0xffd166),
coral: new THREE.Color(0xff735f)
};
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.78,
metalness: options.metalness ?? 0.03,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
side: options.side ?? THREE.FrontSide
});
}
function mesh(geometry, mat, parent = scene) {
const object = new THREE.Mesh(geometry, mat);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function makeTextSprite(text, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `${options.weight ?? 800} ${options.fontSize ?? 62}px system-ui`;
ctx.fillStyle = options.color ?? "#17313a";
if (options.background) {
ctx.fillStyle = options.background;
ctx.beginPath();
ctx.roundRect(34, 20, 188, 88, 30);
ctx.fill();
ctx.fillStyle = options.color ?? "#17313a";
}
ctx.fillText(text, 128, 65);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: options.depthTest ?? false
})
);
sprite.scale.set(options.width ?? 0.7, options.height ?? 0.35, 1);
sprite.renderOrder = 10;
return sprite;
}
// Miniature faceted terrain platform.
const terrain = mesh(
new THREE.CylinderGeometry(12.2, 12.8, 0.8, 12),
material(palette.terrainSide)
);
terrain.position.y = -0.55;
const terrainTop = mesh(
new THREE.CylinderGeometry(12.15, 12.2, 0.16, 12),
material(palette.terrain)
);
terrainTop.position.y = -0.08;
const plotBase = mesh(
new THREE.CylinderGeometry(5.95, 6.05, 0.13, 48),
material(palette.plot)
);
plotBase.position.set(PLOT_X, -0.025, PLOT_Z);
plotBase.receiveShadow = true;
// Concentric frequency guides.
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0x9aacad,
transparent: true,
opacity: 0.34,
side: THREE.DoubleSide
});
[3.15, 5.25].forEach((radius) => {
const ring = mesh(
new THREE.RingGeometry(radius - 0.025, radius + 0.025, 64),
ringMaterial
);
ring.rotation.x = -Math.PI / 2;
ring.position.set(PLOT_X, 0.052, PLOT_Z);
ring.castShadow = false;
});
// Radial sector guides.
const guidePositions = [];
for (let i = 0; i < BIN_COUNT; i++) {
const a = THREE.MathUtils.degToRad(i * BIN_ANGLE);
guidePositions.push(
PLOT_X + Math.sin(a) * INNER_RADIUS,
0.055,
PLOT_Z - Math.cos(a) * INNER_RADIUS,
PLOT_X + Math.sin(a) * 5.35,
0.055,
PLOT_Z - Math.cos(a) * 5.35
);
}
const guideGeometry = new THREE.BufferGeometry();
guideGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(guidePositions, 3)
);
scene.add(
new THREE.LineSegments(
guideGeometry,
new THREE.LineBasicMaterial({
color: 0x9aacad,
transparent: true,
opacity: 0.28
})
)
);
// Cardinal labels.
const cardinals = [
["N", 0, -5.72, 0.78],
["E", 5.72, 0, 0.66],
["S", 0, 5.72, 0.66],
["W", -5.72, 0, 0.66]
];
cardinals.forEach(([label, dx, dz, width]) => {
const sprite = makeTextSprite(label, {
width,
height: width * 0.5,
fontSize: label === "N" ? 78 : 62
});
sprite.position.set(PLOT_X + dx, 0.3, PLOT_Z + dz);
scene.add(sprite);
});
// Small compass hub and flow arrow.
const hub = mesh(
new THREE.CylinderGeometry(0.52, 0.58, 0.16, 12),
material(0x27464e)
);
hub.position.set(PLOT_X, 0.12, PLOT_Z);
const flowArrow = new THREE.ArrowHelper(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(PLOT_X, 0.32, PLOT_Z),
1.3,
0x17313a,
0.34,
0.2
);
scene.add(flowArrow);
// Radial bins.
const binGeometry = new THREE.BoxGeometry(1, 1, 1);
const slotGeometry = new THREE.BoxGeometry(1, 1, 1);
const slotMaterial = material(0xb6c4c3);
const bins = [];
for (let i = 0; i < BIN_COUNT; i++) {
const angle = i * BIN_ANGLE;
const radians = THREE.MathUtils.degToRad(angle);
const sin = Math.sin(radians);
const cos = Math.cos(radians);
const slot = mesh(slotGeometry, slotMaterial);
slot.scale.set(4.3, 0.045, 0.64);
slot.position.set(
PLOT_X + sin * (INNER_RADIUS + 2.15),
0.075,
PLOT_Z - cos * (INNER_RADIUS + 2.15)
);
slot.rotation.y = Math.PI / 2 - radians;
const binMaterial = material(0x4dd6c6);
const binMesh = mesh(binGeometry, binMaterial);
binMesh.userData.binIndex = i;
binMesh.scale.set(0.05, 0.08, 0.54);
bins.push({
index: i,
angle,
sin,
cos,
mesh: binMesh,
currentLength: 0.05,
currentHeight: 0.08,
targetLength: 0.05,
targetHeight: 0.08,
targetColor: new THREE.Color(0x4dd6c6),
count: 0,
share: 0,
meanSpeed: 0
});
}
// Miniature station.
const station = new THREE.Group();
station.position.set(-4.25, -0.13, 1.3);
scene.add(station);
const stationPad = mesh(
new THREE.CylinderGeometry(1.15, 1.25, 0.25, 8),
material(0xc8d1ca),
station
);
stationPad.position.y = 0.12;
const hut = mesh(
new THREE.BoxGeometry(1.35, 1.05, 1.1),
material(0xe8e4d6),
station
);
hut.position.set(-0.15, 0.76, 0);
const roof = mesh(
new THREE.ConeGeometry(1.04, 0.65, 4),
material(0x315d67),
station
);
roof.position.set(-0.15, 1.58, 0);
roof.rotation.y = Math.PI / 4;
roof.scale.z = 0.88;
const door = mesh(
new THREE.BoxGeometry(0.36, 0.7, 0.035),
material(0xd06b4d),
station
);
door.position.set(-0.18, 0.5, 0.567);
const windowFrame = mesh(
new THREE.BoxGeometry(0.48, 0.37, 0.045),
material(0x315d67),
station
);
windowFrame.position.set(0.3, 0.92, 0.57);
const windowGlass = mesh(
new THREE.BoxGeometry(0.37, 0.26, 0.055),
material(0x8bd9e8, { metalness: 0.12, roughness: 0.35 }),
station
);
windowGlass.position.set(0.3, 0.92, 0.585);
const mast = mesh(
new THREE.CylinderGeometry(0.055, 0.07, 2.85, 8),
material(0x506b70),
station
);
mast.position.set(0.75, 1.72, -0.28);
const mastFoot = mesh(
new THREE.CylinderGeometry(0.23, 0.29, 0.16, 8),
material(0x506b70),
station
);
mastFoot.position.set(0.75, 0.27, -0.28);
const anemometer = new THREE.Group();
anemometer.position.set(0.75, 3.15, -0.28);
station.add(anemometer);
mesh(
new THREE.CylinderGeometry(0.07, 0.07, 0.22, 8),
material(0x263f46),
anemometer
).position.y = -0.05;
for (let i = 0; i < 3; i++) {
const arm = new THREE.Group();
arm.rotation.y = (i / 3) * Math.PI * 2;
anemometer.add(arm);
const armMesh = mesh(
new THREE.BoxGeometry(0.54, 0.035, 0.035),
material(0x263f46),
arm
);
armMesh.position.x = 0.27;
const cup = mesh(
new THREE.DodecahedronGeometry(0.13, 0),
material(0xe8a84c),
arm
);
cup.position.x = 0.54;
cup.scale.set(1, 0.75, 0.75);
}
// Weather vane.
const vane = new THREE.Group();
vane.position.set(-0.7, 2.15, 0);
station.add(vane);
const vanePost = mesh(
new THREE.CylinderGeometry(0.035, 0.045, 1.5, 6),
material(0x506b70),
station
);
vanePost.position.set(-0.7, 1.05, 0);
const vaneArrow = mesh(
new THREE.ConeGeometry(0.13, 0.38, 4),
material(0xe8a84c),
vane
);
vaneArrow.rotation.z = -Math.PI / 2;
vaneArrow.position.x = 0.43;
const vaneShaft = mesh(
new THREE.BoxGeometry(0.95, 0.035, 0.035),
material(0x506b70),
vane
);
const tailGeometry = new THREE.BufferGeometry();
tailGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[-0.52, 0, 0, -0.27, 0.2, 0, -0.27, -0.2, 0],
3
)
);
tailGeometry.computeVertexNormals();
const tail = mesh(tailGeometry, material(0xff735f, { side: THREE.DoubleSide }), vane);
tail.castShadow = false;
// Solar panel.
const panel = mesh(
new THREE.BoxGeometry(0.75, 0.055, 0.5),
material(0x286b86, { metalness: 0.2, roughness: 0.38 }),
station
);
panel.position.set(-0.75, 0.7, 0.42);
panel.rotation.x = -0.4;
const panelStand = mesh(
new THREE.CylinderGeometry(0.035, 0.035, 0.8, 6),
material(0x506b70),
station
);
panelStand.position.set(-0.75, 0.4, 0.42);
panelStand.rotation.x = -0.4;
// Windsock.
const windsock = new THREE.Group();
windsock.position.set(0.75, 2.53, -0.28);
station.add(windsock);
const sock = mesh(
new THREE.ConeGeometry(0.14, 0.72, 6, 1, true),
material(0xff735f, { side: THREE.DoubleSide }),
windsock
);
sock.rotation.z = -Math.PI / 2;
sock.position.x = 0.3;
const sockRing = mesh(
new THREE.TorusGeometry(0.13, 0.025, 4, 8),
material(0xf4eee0),
windsock
);
sockRing.rotation.y = Math.PI / 2;
sockRing.position.x = -0.05;
const stationLabel = makeTextSprite("STATION 07", {
width: 1.25,
height: 0.34,
fontSize: 38,
color: "#17313a",
background: "rgba(242,247,244,0.86)"
});
stationLabel.position.set(-0.15, 3.55, 0);
station.add(stationLabel);
// Small low-poly trees around the miniature.
function addTree(x, z, scale) {
const tree = new THREE.Group();
tree.position.set(x, -0.02, z);
tree.scale.setScalar(scale);
scene.add(tree);
const trunk = mesh(
new THREE.CylinderGeometry(0.12, 0.17, 1.1, 6),
material(0x745c49),
tree
);
trunk.position.y = 0.55;
const crown = mesh(
new THREE.ConeGeometry(0.72, 1.65, 7),
material(0x355f57),
tree
);
crown.position.y = 1.55;
const upper = mesh(
new THREE.ConeGeometry(0.53, 1.2, 7),
material(0x477668),
tree
);
upper.position.y = 2.25;
}
addTree(-8.2, 3.4, 0.8);
addTree(-7.1, 5.0, 0.58);
addTree(-8.9, -2.8, 0.68);
addTree(7.6, 5.7, 0.72);
addTree(8.4, -4.1, 0.62);
// Low-poly rocks.
[
[-6.6, -1.7, 0.32],
[-2.3, 5.2, 0.26],
[7.2, 2.6, 0.35],
[5.2, -5.5, 0.24]
].forEach(([x, z, s]) => {
const rock = mesh(
new THREE.DodecahedronGeometry(s, 0),
material(0x899b91)
);
rock.position.set(x, 0.08, z);
rock.scale.y = 0.65;
rock.rotation.set(0.3, x * 0.2, 0.1);
});
// Distant low-poly clouds.
const clouds = [];
[
[-8, 7.4, -10, 1.2],
[3, 8.4, -14, 1.5],
[10, 6.8, -8, 0.9]
].forEach(([x, y, z, scale]) => {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
[
[-0.65, 0, 0, 0.8],
[0, 0.15, 0, 1.0],
[0.75, 0, 0, 0.72]
].forEach(([px, py, pz, size]) => {
const puff = mesh(
new THREE.DodecahedronGeometry(size, 0),
material(0xe6eeee, { flatShading: true }),
cloud
);
puff.position.set(px, py, pz);
puff.castShadow = false;
});
clouds.push(cloud);
});
// Moving wind streaks.
const FLOW_COUNT = 76;
const flowPositions = new Float32Array(FLOW_COUNT * 6);
const flowGeometry = new THREE.BufferGeometry();
flowGeometry.setAttribute(
"position",
new THREE.BufferAttribute(flowPositions, 3)
);
const flowMaterial = new THREE.LineBasicMaterial({
color: 0xf4ffff,
transparent: true,
opacity: 0.36
});
const flowLines = new THREE.LineSegments(flowGeometry, flowMaterial);
flowLines.frustumCulled = false;
scene.add(flowLines);
const flowParticles = [];
for (let i = 0; i < FLOW_COUNT; i++) {
flowParticles.push({
forward: Math.random() * 22 - 11,
cross: Math.random() * 17 - 8.5,
height: 0.55 + Math.random() * 3.2,
length: 0.22 + Math.random() * 0.55
});
}
const flowDirection = new THREE.Vector2(1, 0);
const targetFlowDirection = new THREE.Vector2(1, 0);
let flowSpeed = 7;
let targetFlowSpeed = 7;
// Synthetic data helpers.
const directionNames = [
"N", "NNE", "NE", "ENE",
"E", "ESE", "SE", "SSE",
"S", "SSW", "SW", "WSW",
"W", "WNW", "NW", "NNW"
];
function normalizeDegrees(value) {
return ((value % 360) + 360) % 360;
}
function directionName(degrees) {
return directionNames[Math.round(normalizeDegrees(degrees) / 22.5) % 16];
}
function createRandom(seed) {
let state = seed >>> 0;
return function () {
state += 0x6d2b79f5;
let t = state;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
function randomNormal(random) {
const u = Math.max(random(), 1e-8);
const v = random();
return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
}
function speedColor(speed, output) {
const t = THREE.MathUtils.clamp(speed / 25, 0, 1);
if (t < 0.52) {
output
.copy(palette.mint)
.lerp(palette.yellow, t / 0.52);
} else {
output
.copy(palette.yellow)
.lerp(palette.coral, (t - 0.52) / 0.48);
}
return output;
}
let seedCounter = 1;
let latestData = null;
function generateObservations() {
const random = createRandom(seedCounter * 9173 + 29);
const count = Number(ui.sampleSize.value);
const concentration = Number(ui.spread.value);
const distribution = ui.distribution.value;
const speedProfile = ui.speedProfile.value;
const observations = [];
const modeSets = {
sw: [{ direction: 225, weight: 1 }],
west: [{ direction: 270, weight: 1 }],
twin: [
{ direction: 65, weight: 0.53 },
{ direction: 245, weight: 0.47 }
],
north: [{ direction: 0, weight: 1 }],
variable: [{ direction: 145, weight: 1 }],
uniform: []
};
const modes = modeSets[distribution];
let sigma = THREE.MathUtils.degToRad(46 - concentration * 0.34);
if (distribution === "variable") {
sigma = THREE.MathUtils.degToRad(72 - concentration * 0.37);
}
for (let i = 0; i < count; i++) {
let direction;
if (distribution === "uniform") {
direction = random() * 360;
} else {
let roll = random();
let selected = modes[0];
for (const mode of modes) {
if (roll < mode.weight) {
selected = mode;
break;
}
roll -= mode.weight;
}
direction = normalizeDegrees(
selected.direction + randomNormal(random) * sigma
);
}
let speed;
switch (speedProfile) {
case "gusty": {
if (random() < 0.68) {
speed = 7.4 + randomNormal(random) * 1.8;
} else {
speed = 19.2 + randomNormal(random) * 3.8;
}
break;
}
case "fresh":
speed = 12.6 + randomNormal(random) * 2.7;
break;
case "light":
speed = 3.6 + randomNormal(random) * 1.15;
break;
case "variable": {
const band = random();
if (band < 0.22) {
speed = 2.8 + random() * 2.6;
} else if (band < 0.66) {
speed = 7.5 + random() * 4.2;
} else {
speed = 16 + random() * 7;
}
break;
}
default:
speed = 7.1 + randomNormal(random) * 1.55;
}
speed = THREE.MathUtils.clamp(speed, 0.4, 28);
observations.push({ direction, speed });
}
return observations;
}
function aggregateObservations(observations) {
const counts = new Array(BIN_COUNT).fill(0);
const speedSums = new Array(BIN_COUNT).fill(0);
let sinSum = 0;
let cosSum = 0;
let speedSum = 0;
observations.forEach((observation) => {
const direction = normalizeDegrees(observation.direction);
const radians = THREE.MathUtils.degToRad(direction);
const binIndex = Math.round(direction / BIN_ANGLE) % BIN_COUNT;
counts[binIndex]++;
speedSums[binIndex] += observation.speed;
sinSum += Math.sin(radians);
cosSum += Math.cos(radians);
speedSum += observation.speed;
});
const total = observations.length;
const resultantLength = Math.hypot(sinSum, cosSum);
const consistency = total ? resultantLength / total : 0;
const prevailing = normalizeDegrees(
Math.atan2(sinSum, cosSum) * THREE.MathUtils.RAD2DEG
);
const aggregated = bins.map((bin, index) => {
const count = counts[index];
const share = count / total;
const meanSpeed = count ? speedSums[index] / count : 0;
return { count, share, meanSpeed };
});
return {
total,
aggregated,
consistency,
prevailing,
meanSpeed: speedSum / total
};
}
function applyData(data) {
latestData = data;
bins.forEach((bin, index) => {
const values = data.aggregated[index];
bin.count = values.count;
bin.share = values.share;
bin.meanSpeed = values.meanSpeed;
bin.targetLength = values.count
? Math.max(0.08, Math.min(MAX_RADIAL_LENGTH, values.share * 8.5))
: 0.045;
bin.targetHeight = values.count
? 0.12 + (values.meanSpeed / 25) * 2.35
: 0.055;
if (values.count) {
speedColor(values.meanSpeed, bin.targetColor);
} else {
bin.targetColor.set(0xa4b5b3);
}
});
ui.sampleId.textContent = `SYN-${String(seedCounter).padStart(3, "0")}`;
ui.sampleValue.textContent = data.total;
ui.observations.textContent = data.total;
ui.mean.innerHTML = `${data.meanSpeed.toFixed(1)} <small>m/s</small>`;
ui.consistency.innerHTML = `${Math.round(data.consistency * 100)} <small>%</small>`;
const degrees = Math.round(data.prevailing) % 360;
ui.prevailing.innerHTML =
`${directionName(degrees)} <small>${degrees}°</small>`;
const radians = THREE.MathUtils.degToRad(data.prevailing);
// Air travels opposite the meteorological "from" direction.
targetFlowDirection.set(-Math.sin(radians), Math.cos(radians)).normalize();
targetFlowSpeed = 3.5 + data.meanSpeed * 0.75;
const sockAngle = Math.atan2(
-targetFlowDirection.y,
targetFlowDirection.x
);
windsock.rotation.y = sockAngle;
vane.rotation.y = sockAngle + Math.PI;
}
function regenerate() {
seedCounter++;
const observations = generateObservations();
applyData(aggregateObservations(observations));
}
// Direct camera controls: orbit, zoom and reset.
const controls = {
target: new THREE.Vector3(-0.15, 0.65, 0.45),
radius: innerWidth < 650 ? 21 : 17.5,
theta: 0.58,
phi: 0.94
};
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);
}
function resetCamera() {
controls.radius = innerWidth < 650 ? 21 : 17.5;
controls.theta = 0.58;
controls.phi = 0.94;
controls.target.set(-0.15, 0.65, 0.45);
}
let dragging = false;
let pointerId = null;
let previousX = 0;
let previousY = 0;
let dragDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
dragDistance = 0;
renderer.domElement.setPointerCapture(pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging && event.pointerId === pointerId) {
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
dragDistance += Math.abs(dx) + Math.abs(dy);
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.3,
1.42
);
} else {
updateTooltip(event);
}
});
function endDrag(event) {
if (!dragging || event.pointerId !== pointerId) return;
dragging = false;
renderer.domElement.style.cursor = "grab";
if (renderer.domElement.hasPointerCapture(pointerId)) {
renderer.domElement.releasePointerCapture(pointerId);
}
pointerId = null;
}
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),
10,
27
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.style.cursor = "grab";
// Hover tooltip.
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function updateTooltip(event) {
if (dragDistance > 4) {
ui.tooltip.style.display = "none";
return;
}
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;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(
bins.map((bin) => bin.mesh),
false
);
if (!hits.length || !latestData) {
ui.tooltip.style.display = "none";
renderer.domElement.style.cursor = dragging ? "grabbing" : "grab";
return;
}
const index = hits[0].object.userData.binIndex;
const bin = bins[index];
const values = latestData.aggregated[index];
ui.tooltipTitle.textContent =
`${directionName(bin.angle)} · ${Math.round(bin.angle)}° from`;
ui.tooltipFrequency.textContent = `${(values.share * 100).toFixed(1)}%`;
ui.tooltipSpeed.textContent = values.count
? `${values.meanSpeed.toFixed(1)} m/s`
: "—";
ui.tooltipCount.textContent = values.count;
ui.tooltip.style.display = "block";
ui.tooltip.style.left =
`${Math.min(event.clientX + 16, innerWidth - 195)}px`;
ui.tooltip.style.top =
`${Math.min(event.clientY + 16, innerHeight - 100)}px`;
renderer.domElement.style.cursor = "pointer";
}
renderer.domElement.addEventListener("pointerleave", () => {
ui.tooltip.style.display = "none";
});
// UI events.
ui.distribution.addEventListener("change", regenerate);
ui.speedProfile.addEventListener("change", regenerate);
ui.spread.addEventListener("input", () => {
ui.spreadValue.textContent = `${ui.spread.value}%`;
});
ui.spread.addEventListener("change", regenerate);
ui.sampleSize.addEventListener("input", () => {
ui.sampleValue.textContent = ui.sampleSize.value;
});
ui.sampleSize.addEventListener("change", regenerate);
ui.regenerate.addEventListener("click", regenerate);
let paused = false;
ui.pause.addEventListener("click", () => {
paused = !paused;
ui.pause.textContent = paused ? "▶" : "Ⅱ";
ui.pause.setAttribute(
"aria-label",
paused ? "Resume wind flow" : "Pause wind flow"
);
ui.pause.title = paused ? "Resume wind flow" : "Pause wind flow";
});
// Resize.
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", onResize);
// Animation.
const clock = new THREE.Clock();
const arrowDirection = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
// Smooth radial-bin growth.
const growth = 1 - Math.exp(-dt * 5.2);
bins.forEach((bin) => {
bin.currentLength = THREE.MathUtils.lerp(
bin.currentLength,
bin.targetLength,
growth
);
bin.currentHeight = THREE.MathUtils.lerp(
bin.currentHeight,
bin.targetHeight,
growth
);
const radius = INNER_RADIUS + bin.currentLength * 0.5;
bin.mesh.scale.set(
bin.currentLength,
bin.currentHeight,
0.54
);
bin.mesh.position.set(
PLOT_X + bin.sin * radius,
0.1 + bin.currentHeight * 0.5,
PLOT_Z - bin.cos * radius
);
bin.mesh.rotation.y = Math.PI / 2 - THREE.MathUtils.degToRad(bin.angle);
bin.mesh.material.color.lerp(bin.targetColor, growth);
});
// Wind direction and speed easing.
flowDirection.lerp(targetFlowDirection, 1 - Math.exp(-dt * 2.8));
flowDirection.normalize();
flowSpeed = THREE.MathUtils.lerp(
flowSpeed,
targetFlowSpeed,
1 - Math.exp(-dt * 2.2)
);
arrowDirection.set(flowDirection.x, 0, flowDirection.y);
flowArrow.setDirection(arrowDirection);
flowArrow.setLength(1.05 + Math.min(0.55, flowSpeed * 0.025), 0.34, 0.2);
if (!paused) {
anemometer.rotation.y += dt * (1.1 + flowSpeed * 0.16);
const tx = flowDirection.x;
const tz = flowDirection.y;
const px = -tz;
const pz = tx;
flowParticles.forEach((particle, index) => {
particle.forward += dt * flowSpeed * 0.75;
if (particle.forward > 11) particle.forward -= 22;
const x = tx * particle.forward + px * particle.cross;
const z = tz * particle.forward + pz * particle.cross;
const y = particle.height;
const offset = index * 6;
flowPositions[offset] = x;
flowPositions[offset + 1] = y;
flowPositions[offset + 2] = z;
flowPositions[offset + 3] = x - tx * particle.length;
flowPositions[offset + 4] = y;
flowPositions[offset + 5] = z - tz * particle.length;
});
flowGeometry.attributes.position.needsUpdate = true;
clouds.forEach((cloud, index) => {
cloud.position.x += dt * (0.08 + index * 0.018);
if (cloud.position.x > 13) cloud.position.x = -13;
});
}
// Gentle sock flutter.
sock.scale.z = 1 + Math.sin(performance.now() * 0.004) * 0.06;
updateCamera();
renderer.render(scene, camera);
}
// Initial sample and scene.
const initialObservations = generateObservations();
applyData(aggregateObservations(initialObservations));
updateCamera();
animate();
</script>
</body>
</html>
```