Prompt specification
Build or customize the Three.js 3D scene "Opposite seasonal wind panels" 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: Opposite seasonal wind panels
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/opposite-seasonal-wind-panels-x1226
Scene Description Prompt:
Two stylized monsoon coast sections show opposite seasonal winds and contrasting rainfall zones. Use Three.js from cdnjs in one HTML file.
Working Three.js Starter (opposite-seasonal-wind-panels-x1226):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Monsoon Winds — Interactive Coast Diorama</title>
<style>
:root {
--ink: #eef8ff;
--muted: #a8bdca;
--panel: rgba(8, 22, 31, 0.78);
--border: rgba(176, 220, 238, 0.17);
--summer: #58d8ff;
--winter: #ff9c6a;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 38%, #183847 0%, #0b202c 42%, #06131c 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.topbar {
position: fixed;
z-index: 5;
top: 0;
left: 0;
right: 0;
padding: 24px 28px;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 24px;
pointer-events: none;
background: linear-gradient(180deg, rgba(3, 12, 18, 0.78), transparent);
}
.eyebrow {
margin-bottom: 8px;
color: #7fc8de;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3.2vw, 44px);
line-height: 1.05;
letter-spacing: -0.04em;
font-weight: 750;
}
.subtitle {
max-width: 630px;
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.controls {
display: flex;
align-items: center;
gap: 9px;
pointer-events: auto;
}
button {
border: 1px solid var(--border);
border-radius: 999px;
padding: 10px 15px;
color: var(--ink);
background: rgba(10, 30, 41, 0.78);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
transition: background 160ms ease, border-color 160ms ease;
}
button:hover {
background: rgba(24, 60, 76, 0.9);
border-color: rgba(176, 220, 238, 0.35);
}
.legend {
position: fixed;
z-index: 4;
left: 28px;
bottom: 24px;
width: min(720px, calc(100vw - 56px));
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
pointer-events: none;
}
.season-card {
position: relative;
overflow: hidden;
min-height: 132px;
padding: 16px 18px 15px;
border: 1px solid var(--border);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(15px);
}
.season-card::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
background: var(--accent);
}
.season-card.summer {
--accent: var(--summer);
}
.season-card.winter {
--accent: var(--winter);
}
.season-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.season-heading h2 {
margin: 0;
font-size: 15px;
letter-spacing: -0.01em;
}
.wind-badge {
flex: 0 0 auto;
border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
border-radius: 999px;
padding: 5px 9px;
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
}
.season-card p {
margin: 9px 0 12px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.chip {
border-radius: 7px;
padding: 5px 8px;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.chip.wet {
color: #8ee8ff;
background: rgba(64, 191, 232, 0.13);
}
.chip.dry {
color: #f0c68e;
background: rgba(224, 163, 82, 0.13);
}
.hint {
position: fixed;
z-index: 4;
right: 28px;
bottom: 28px;
max-width: 260px;
padding: 12px 15px;
border: 1px solid var(--border);
border-radius: 12px;
color: #bcd0da;
background: rgba(7, 20, 28, 0.64);
font-size: 11px;
line-height: 1.5;
backdrop-filter: blur(12px);
pointer-events: none;
}
.hint strong {
color: #f1fbff;
}
@media (max-width: 900px) {
.hint {
display: none;
}
.topbar {
padding: 18px;
}
.legend {
left: 18px;
bottom: 18px;
width: calc(100vw - 36px);
}
}
@media (max-width: 640px) {
.subtitle {
max-width: 270px;
font-size: 11px;
}
.controls button {
padding: 9px 11px;
font-size: 10px;
}
.legend {
grid-template-columns: 1fr;
}
.season-card {
min-height: 0;
padding: 12px 14px;
}
.season-card p {
margin: 7px 0 9px;
font-size: 10px;
}
.season-card:nth-child(2) {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D comparison of summer and winter monsoon winds"></canvas>
<header class="topbar">
<div>
<div class="eyebrow">Seasonal circulation / coastal rainfall</div>
<h1>When the winds reverse</h1>
<p class="subtitle">
Two stylized monsoon coasts reveal how reversing winds redistribute moisture:
a wet windward slope in summer and a dry coast with inland rainfall in winter.
</p>
</div>
<div class="controls">
<button id="reset" type="button">Reset view</button>
</div>
</header>
<section class="legend" aria-label="Season comparison">
<article class="season-card summer">
<div class="season-heading">
<h2>Summer monsoon</h2>
<span class="wind-badge">SW → NE</span>
</div>
<p>Moist ocean air advances inland and rises over the coastal mountains.</p>
<div class="chips">
<span class="chip wet">Wet · windward coast</span>
<span class="chip dry">Dry · rain-shadow interior</span>
</div>
</article>
<article class="season-card winter">
<div class="season-heading">
<h2>Winter monsoon</h2>
<span class="wind-badge">NE → SW</span>
</div>
<p>Dry continental air moves offshore; precipitation shifts to inland highlands.</p>
<div class="chips">
<span class="chip dry">Dry · exposed coast</span>
<span class="chip wet">Wet · inland highlands</span>
</div>
</article>
</section>
<aside class="hint">
<strong>Explore the diorama</strong><br>
Drag to orbit · Scroll to zoom<br>
Double-click to reset
</aside>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const resetButton = document.querySelector("#reset");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: 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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x0a1b25, 0.015);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 1.35, 0);
const desired = {
theta: 0.31,
phi: 0.79,
radius: window.innerWidth < 700 ? 29 : 25
};
const current = {
theta: desired.theta,
phi: desired.phi,
radius: desired.radius
};
const hemisphere = new THREE.HemisphereLight(0xc5ecff, 0x243024, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.2);
keyLight.position.set(7, 15, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -16;
keyLight.shadow.camera.right = 16;
keyLight.shadow.camera.top = 13;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 40;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x65d9ff, 1.5);
rimLight.position.set(-10, 8, -10);
scene.add(rimLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(34, 22),
new THREE.MeshStandardMaterial({
color: 0x0a2029,
roughness: 0.95,
metalness: 0.05,
transparent: true,
opacity: 0.9
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.23;
floor.receiveShadow = true;
scene.add(floor);
const animatedClouds = [];
const rainSystems = [];
const flowBeads = [];
const summerAccent = new THREE.Color(0x58d8ff);
const winterAccent = new THREE.Color(0xff9c6a);
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.arcTo(x + width, y, x + width, y + height, radius);
ctx.arcTo(x + width, y + height, x, y + height, radius);
ctx.arcTo(x, y + height, x, y, radius);
ctx.arcTo(x, y, x + width, y, radius);
ctx.closePath();
}
function makeTextSprite(title, subtitle, accentHex, width = 1024, height = 256) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = width;
labelCanvas.height = height;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, width, height);
roundedRect(ctx, 8, 8, width - 16, height - 16, 34);
ctx.fillStyle = "rgba(6, 18, 26, 0.9)";
ctx.fill();
ctx.strokeStyle = "rgba(190, 228, 241, 0.22)";
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = accentHex;
roundedRect(ctx, 34, 38, 9, height - 76, 5);
ctx.fill();
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = "#f2fbff";
ctx.font = "800 62px system-ui, sans-serif";
ctx.fillText(title, 72, height * 0.43);
ctx.fillStyle = accentHex;
ctx.font = "700 27px system-ui, sans-serif";
ctx.letterSpacing = "3px";
ctx.fillText(subtitle, 74, height * 0.75);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.renderOrder = 20;
return sprite;
}
function shoreX(z) {
return 0.18 + Math.sin(z * 2.15) * 0.13 + Math.sin(z * 4.7) * 0.045;
}
function terrainHeight(t, z) {
const coastalHill = 1.72 * Math.exp(-Math.pow((t - 0.24) / 0.18, 2));
const inlandHill = 0.94 * Math.exp(-Math.pow((t - 0.73) / 0.19, 2));
const texture = Math.sin(z * 2.2 + t * 5.0) * 0.035;
return 0.4 + coastalHill + inlandHill + texture;
}
function wetnessAt(t, mode) {
const center = mode === "summer" ? 0.23 : 0.73;
return Math.exp(-Math.pow((t - center) / 0.22, 2));
}
function createTerrain(mode) {
const nx = 28;
const nz = 22;
const positions = [];
const colors = [];
const indices = [];
const dry = new THREE.Color(mode === "summer" ? 0xb89a5b : 0xb98255);
const wet = new THREE.Color(mode === "summer" ? 0x287e54 : 0x397a58);
const highland = new THREE.Color(mode === "summer" ? 0x356847 : 0x42654d);
for (let iz = 0; iz <= nz; iz++) {
const z = -2.55 + (iz / nz) * 5.1;
for (let ix = 0; ix <= nx; ix++) {
const t = ix / nx;
const x = shoreX(z) + t * 3.9;
const y = terrainHeight(t, z);
positions.push(x, y, z);
const wetness = wetnessAt(t, mode);
const color = dry.clone().lerp(wet, wetness);
if (y > 1.3) {
color.lerp(highland, Math.min((y - 1.3) * 0.24, 0.3));
}
const variation = 0.92 + 0.08 * Math.sin(ix * 1.7 + iz * 0.8);
color.multiplyScalar(variation);
colors.push(color.r, color.g, color.b);
}
}
for (let iz = 0; iz < nz; iz++) {
for (let ix = 0; ix < nx; ix++) {
const a = iz * (nx + 1) + ix;
const b = a + 1;
const c = a + nx + 1;
const d = c + 1;
indices.push(a, c, b, b, c, d);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const terrain = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.96,
metalness: 0,
flatShading: true
})
);
terrain.castShadow = true;
terrain.receiveShadow = true;
return terrain;
}
function createTerrainSides() {
const perimeter = [];
for (let i = 0; i <= 28; i++) {
const t = i / 28;
perimeter.push({
x: shoreX(-2.55) + t * 3.9,
z: -2.55,
y: terrainHeight(t, -2.55)
});
}
for (let i = 28; i >= 0; i--) {
const t = i / 28;
perimeter.push({
x: shoreX(2.55) + t * 3.9,
z: 2.55,
y: terrainHeight(t, 2.55)
});
}
for (let i = 28; i >= 0; i--) {
const z = -2.55 + (i / 28) * 5.1;
perimeter.push({
x: shoreX(z),
z,
y: terrainHeight(0, z)
});
}
const positions = [];
const indices = [];
perimeter.forEach((point) => {
positions.push(point.x, point.y, point.z);
positions.push(point.x, 0.19, point.z);
});
for (let i = 0; i < perimeter.length - 1; i++) {
const a = i * 2;
const b = a + 1;
const c = a + 2;
const d = a + 3;
indices.push(a, b, c, c, b, d);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
color: 0x5d503b,
roughness: 1,
side: THREE.DoubleSide
})
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function createOceanWaves(mode) {
const group = new THREE.Group();
const material = new THREE.LineBasicMaterial({
color: mode === "summer" ? 0x9beaff : 0x8bb6c9,
transparent: true,
opacity: 0.38
});
for (let row = 0; row < 7; row++) {
const z = -2.1 + row * 0.66;
const points = [];
for (let i = 0; i <= 18; i++) {
const x = -3.85 + i * 0.18;
const y = 0.405 + Math.sin(i * 0.55 + row) * 0.012;
points.push(new THREE.Vector3(x, y, z + Math.sin(i * 0.3) * 0.025));
}
const curve = new THREE.CatmullRomCurve3(points);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(36));
const line = new THREE.Line(geometry, material);
group.add(line);
}
return group;
}
function createRainPatch(tCenter, zCenter, radius, color) {
const positions = [0, 0, 0];
const centerX = shoreX(zCenter) + tCenter * 3.9;
const centerY = terrainHeight(tCenter, zCenter);
for (let i = 0; i < 40; i++) {
const angle = (i / 40) * Math.PI * 2;
const localX = Math.cos(angle) * radius;
const localZ = Math.sin(angle) * radius * 0.68;
const approximateT = THREE.MathUtils.clamp(
tCenter + localX / 3.9,
0,
1
);
const y = terrainHeight(approximateT, zCenter + localZ) + 0.035;
positions.push(
centerX + localX,
y,
zCenter + localZ
);
}
const indices = [];
for (let i = 0; i < 40; i++) {
indices.push(0, i + 1, ((i + 1) % 40) + 1);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.17,
depthWrite: false,
side: THREE.DoubleSide,
polygonOffset: true,
polygonOffsetFactor: -1
})
);
}
function createTree(group, x, y, z, scale = 1) {
const tree = new THREE.Group();
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.045 * scale, 0.065 * scale, 0.36 * scale, 6),
new THREE.MeshStandardMaterial({ color: 0x614832, roughness: 1 })
);
trunk.position.y = 0.18 * scale;
trunk.castShadow = true;
const lower = new THREE.Mesh(
new THREE.ConeGeometry(0.27 * scale, 0.62 * scale, 7),
new THREE.MeshStandardMaterial({
color: 0x1e6845,
roughness: 0.95,
flatShading: true
})
);
lower.position.y = 0.58 * scale;
lower.castShadow = true;
const upper = new THREE.Mesh(
new THREE.ConeGeometry(0.19 * scale, 0.48 * scale, 7),
new THREE.MeshStandardMaterial({
color: 0x328259,
roughness: 0.95,
flatShading: true
})
);
upper.position.y = 0.91 * scale;
upper.castShadow = true;
tree.add(trunk, lower, upper);
tree.position.set(x, y, z);
group.add(tree);
}
function createCloud(group, x, y, z, scale, color) {
const cloud = new THREE.Group();
const puffs = [
[-0.56, -0.04, 0.02, 0.52],
[-0.18, 0.16, -0.03, 0.72],
[0.27, 0.12, 0.04, 0.65],
[0.66, -0.04, -0.02, 0.48],
[0.03, -0.12, 0.12, 0.76]
];
const material = new THREE.MeshStandardMaterial({
color,
roughness: 1,
metalness: 0,
flatShading: true
});
puffs.forEach(([px, py, pz, size]) => {
const puff = new THREE.Mesh(
new THREE.SphereGeometry(size, 14, 10),
material
);
puff.position.set(px, py, pz);
puff.scale.set(1.15, 0.68, 0.9);
puff.castShadow = true;
cloud.add(puff);
});
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
group.add(cloud);
animatedClouds.push({
object: cloud,
baseY: y,
phase: Math.random() * Math.PI * 2
});
return cloud;
}
function createRain(cx, cz, top, bottom, count, spreadX, spreadZ) {
const positions = new Float32Array(count * 6);
const phases = [];
const speeds = [];
for (let i = 0; i < count; i++) {
phases.push(Math.random());
speeds.push(0.7 + Math.random() * 0.5);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
const material = new THREE.LineBasicMaterial({
color: 0x7adfff,
transparent: true,
opacity: 0.78,
depthWrite: false
});
const lines = new THREE.LineSegments(geometry, material);
lines.renderOrder = 5;
rainSystems.push({
lines,
phases,
speeds,
cx,
cz,
top,
bottom,
count,
spreadX,
spreadZ
});
}
function createArrow(group, start, end, color, beadColor) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
direction.normalize();
const shaftLength = length - 0.52;
const shaftRadius = 0.065;
const headLength = 0.52;
const headRadius = 0.19;
const material = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.22,
roughness: 0.45,
metalness: 0.08
});
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(
shaftRadius,
shaftRadius,
shaftLength,
12
),
material
);
const shaftCenter = start.clone().addScaledVector(direction, shaftLength / 2);
shaft.position.copy(shaftCenter);
shaft.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
shaft.castShadow = true;
const head = new THREE.Mesh(
new THREE.ConeGeometry(headRadius, headLength, 14),
material
);
head.position.copy(end).addScaledVector(direction, -headLength / 2);
head.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction
);
head.castShadow = true;
group.add(shaft, head);
const bead = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 12, 8),
new THREE.MeshBasicMaterial({ color: beadColor })
);
group.add(bead);
flowBeads.push({
mesh: bead,
start,
end,
offset: Math.random()
});
}
function addFoam(group) {
const points = [];
for (let i = 0; i <= 70; i++) {
const z = -2.55 + (i / 70) * 5.1;
points.push(
new THREE.Vector3(
shoreX(z) - 0.08,
0.425,
z
)
);
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const foam = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color: 0xe7fbff,
transparent: true,
opacity: 0.85
})
);
group.add(foam);
}
function createPanel(mode, centerX) {
const group = new THREE.Group();
group.position.x = centerX;
scene.add(group);
const isSummer = mode === "summer";
const accent = isSummer ? summerAccent : winterAccent;
const base = new THREE.Mesh(
new THREE.BoxGeometry(9.15, 0.38, 6.1),
new THREE.MeshStandardMaterial({
color: 0x102a34,
roughness: 0.8,
metalness: 0.12
})
);
base.position.y = 0;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(base.geometry),
new THREE.LineBasicMaterial({
color: accent,
transparent: true,
opacity: 0.18
})
);
edges.position.copy(base.position);
group.add(edges);
const ocean = new THREE.Mesh(
new THREE.BoxGeometry(4.45, 0.24, 5.12),
new THREE.MeshStandardMaterial({
color: isSummer ? 0x17647d : 0x24596b,
roughness: 0.3,
metalness: 0.12,
transparent: true,
opacity: 0.94
})
);
ocean.position.set(-1.94, 0.26, 0);
ocean.castShadow = true;
ocean.receiveShadow = true;
group.add(ocean);
group.add(createOceanWaves(mode));
group.add(createTerrain(mode));
group.add(createTerrainSides());
addFoam(group);
if (isSummer) {
group.add(createRainPatch(0.23, -0.52, 1.05, 0x54d9ff));
} else {
group.add(createRainPatch(0.73, 0.48, 1.0, 0x74c9e6));
}
const treeCenter = isSummer ? 0.23 : 0.73;
const treeCount = isSummer ? 11 : 9;
for (let i = 0; i < treeCount; i++) {
const t = THREE.MathUtils.clamp(
treeCenter + (Math.random() - 0.5) * 0.28,
0.07,
0.92
);
const z = -1.85 + Math.random() * 3.7;
const x = shoreX(z) + t * 3.9;
const y = terrainHeight(t, z);
createTree(
group,
x,
y,
z,
0.7 + Math.random() * 0.35
);
}
if (isSummer) {
createCloud(
group,
shoreX(-0.52) + 0.23 * 3.9,
3.42,
-0.52,
1.1,
0xddebf0
);
createRain(
shoreX(-0.52) + 0.23 * 3.9,
-0.52,
3.05,
0.72,
80,
0.85,
0.72
);
} else {
createCloud(
group,
shoreX(0.48) + 0.73 * 3.9,
3.28,
0.48,
1.0,
0xbfccd2
);
createRain(
shoreX(0.48) + 0.73 * 3.9,
0.48,
2.92,
0.72,
72,
0.82,
0.68
);
}
if (isSummer) {
createArrow(
group,
new THREE.Vector3(-3.72, 1.72, 1.65),
new THREE.Vector3(1.86, 1.72, -0.72),
summerAccent,
0xe7fbff
);
createArrow(
group,
new THREE.Vector3(-3.7, 2.48, -0.02),
new THREE.Vector3(1.88, 2.48, -2.38),
summerAccent,
0xe7fbff
);
} else {
createArrow(
group,
new THREE.Vector3(3.65, 1.72, -1.55),
new THREE.Vector3(-1.9, 1.72, 0.83),
winterAccent,
0xfff0df
);
createArrow(
group,
new THREE.Vector3(3.62, 2.48, 0.05),
new THREE.Vector3(-1.93, 2.48, 2.4),
winterAccent,
0xfff0df
);
}
const title = isSummer
? "SUMMER MONSOON"
: "WINTER MONSOON";
const subtitle = isSummer
? "MOIST OCEAN AIR / SOUTHWEST WIND"
: "DRY CONTINENTAL AIR / NORTHEAST WIND";
const titleSprite = makeTextSprite(
title,
subtitle,
isSummer ? "#58d8ff" : "#ff9c6a"
);
titleSprite.position.set(0, 5.0, -0.1);
titleSprite.scale.set(4.6, 1.15, 1);
group.add(titleSprite);
const oceanLabel = makeTextSprite(
"OCEAN",
isSummer ? "MOISTURE SOURCE" : "DRY AIR RETURNS",
isSummer ? "#58d8ff" : "#ff9c6a",
512,
192
);
oceanLabel.position.set(-2.75, 0.68, 2.58);
oceanLabel.scale.set(1.7, 0.64, 1);
group.add(oceanLabel);
const landLabel = makeTextSprite(
"LAND",
isSummer ? "WINDWARD RAIN" : "INLAND HIGHLANDS",
isSummer ? "#58d8ff" : "#ff9c6a",
512,
192
);
landLabel.position.set(2.75, 0.68, 2.58);
landLabel.scale.set(1.7, 0.64, 1);
group.add(landLabel);
return group;
}
createPanel("summer", -5);
createPanel("winter", 5);
// Camera controls are implemented locally without Three.js add-ons.
let dragging = false;
let previousX = 0;
let previousY = 0;
function resetCamera() {
desired.theta = 0.31;
desired.phi = 0.79;
desired.radius = window.innerWidth < 700 ? 29 : 25;
}
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi + dy * 0.005,
0.38,
1.18
);
});
function endDrag(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius + event.deltaY * 0.014,
17,
36
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
resetButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") desired.theta -= 0.12;
if (event.key === "ArrowRight") desired.theta += 0.12;
if (event.key === "ArrowUp") desired.phi -= 0.08;
if (event.key === "ArrowDown") desired.phi += 0.08;
if (event.key === "r" || event.key === "R") resetCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function updateRain(time) {
rainSystems.forEach((system) => {
const attribute = system.lines.geometry.attributes.position;
for (let i = 0; i < system.count; i++) {
const progress =
(time * system.speeds[i] * 0.72 + system.phases[i]) % 1;
const y = system.top - progress * (system.top - system.bottom);
const x = system.cx + (Math.random() - 0.5) * system.spreadX;
const z = system.cz + (Math.random() - 0.5) * system.spreadZ;
const offset = i * 6;
attribute.array[offset] = x;
attribute.array[offset + 1] = y;
attribute.array[offset + 2] = z;
attribute.array[offset + 3] = x + 0.025;
attribute.array[offset + 4] = y - 0.26;
attribute.array[offset + 5] = z;
}
attribute.needsUpdate = true;
});
}
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const delta = clock.getDelta();
current.theta += (desired.theta - current.theta) * 0.075;
current.phi += (desired.phi - current.phi) * 0.075;
current.radius += (desired.radius - current.radius) * 0.075;
camera.position.set(
target.x +
current.radius *
Math.sin(current.phi) *
Math.sin(current.theta),
target.y + current.radius * Math.cos(current.phi),
target.z +
current.radius *
Math.sin(current.phi) *
Math.cos(current.theta)
);
camera.lookAt(target);
animatedClouds.forEach((cloud) => {
cloud.object.position.y =
cloud.baseY + Math.sin(elapsed * 0.7 + cloud.phase) * 0.065;
cloud.object.rotation.y =
Math.sin(elapsed * 0.12 + cloud.phase) * 0.025;
});
flowBeads.forEach((bead) => {
const progress = (elapsed * 0.16 + bead.offset) % 1;
bead.mesh.position.lerpVectors(
bead.start,
bead.end,
progress
);
});
updateRain(elapsed);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```