Prompt specification
Build or customize the Three.js 3D scene "Food-web intervention classroom 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: Food-web intervention classroom model
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/food-web-intervention-classroom-model-x0708
Scene Description Prompt:
Create a standalone low-poly scene in one HTML file using Three.js from cdnjs. Create a toy kelp-system simulation with explicitly fictional rates; users vary one population and inspect linked responses while captions explain that real ecosystems contain additional interactions.
Working Three.js Starter (food-web-intervention-classroom-model-x0708):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Toy Kelp Forest — Fictional Rate Model</title>
<style>
:root {
color-scheme: dark;
--ink: #ecf8f4;
--muted: #9cb8b4;
--panel: rgba(6, 30, 38, 0.86);
--panel-border: rgba(174, 232, 214, 0.15);
--mint: #80e0bc;
--kelp: #a8d35b;
--fish: #ff9b73;
--water: #70d9ed;
--urchin: #cf94ff;
--shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #062f3d;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 35% 38%, transparent 35%, rgba(0, 15, 23, 0.23) 100%),
linear-gradient(180deg, rgba(2, 18, 27, 0.12), transparent 35%, rgba(1, 13, 20, 0.24));
}
.intro {
position: fixed;
top: 24px;
left: 26px;
z-index: 3;
max-width: 580px;
pointer-events: none;
text-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
padding: 6px 10px;
border: 1px solid rgba(128, 224, 188, 0.3);
border-radius: 999px;
background: rgba(4, 33, 40, 0.62);
color: #b9f5db;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
.eyebrow::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 13px var(--mint);
content: "";
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 54px);
font-weight: 720;
line-height: 0.98;
letter-spacing: -0.055em;
}
.intro p {
max-width: 530px;
margin: 12px 0 0;
color: #c1d7d3;
font-size: 14px;
line-height: 1.55;
}
.panel {
position: fixed;
z-index: 5;
top: 18px;
right: 18px;
bottom: 18px;
width: 350px;
overflow: auto;
padding: 18px;
border: 1px solid var(--panel-border);
border-radius: 20px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(20px) saturate(125%);
scrollbar-width: thin;
scrollbar-color: rgba(128, 224, 188, 0.35) transparent;
}
.panel-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 17px;
}
.panel h2 {
margin: 0 0 4px;
font-size: 18px;
letter-spacing: -0.025em;
}
.panel-subtitle {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.day-pill {
flex: 0 0 auto;
padding: 7px 9px;
border-radius: 10px;
background: rgba(128, 224, 188, 0.1);
color: #b9f5db;
font-size: 11px;
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.control-block {
padding: 15px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 15px;
background: rgba(255, 255, 255, 0.035);
}
.control-label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
font-size: 13px;
font-weight: 700;
}
.control-value {
color: var(--urchin);
font-size: 18px;
font-variant-numeric: tabular-nums;
}
.range-wrap {
position: relative;
}
input[type="range"] {
width: 100%;
height: 7px;
margin: 4px 0 8px;
border-radius: 999px;
outline: none;
appearance: none;
background:
linear-gradient(
90deg,
var(--urchin) 0%,
var(--urchin) var(--fill, 28%),
rgba(255, 255, 255, 0.11) var(--fill, 28%),
rgba(255, 255, 255, 0.11) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 19px;
height: 19px;
border: 3px solid #e8c6ff;
border-radius: 50%;
appearance: none;
background: #7f4ca6;
box-shadow: 0 0 0 5px rgba(207, 148, 255, 0.12);
}
input[type="range"]::-moz-range-thumb {
width: 14px;
height: 14px;
border: 3px solid #e8c6ff;
border-radius: 50%;
background: #7f4ca6;
box-shadow: 0 0 0 5px rgba(207, 148, 255, 0.12);
}
.range-notes {
display: flex;
justify-content: space-between;
color: #829f9b;
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-top: 12px;
}
.action {
min-height: 39px;
border: 1px solid rgba(255, 255, 255, 0.11);
border-radius: 11px;
background: rgba(255, 255, 255, 0.06);
cursor: pointer;
transition:
transform 120ms ease,
background 120ms ease,
border-color 120ms ease;
}
.action:hover {
transform: translateY(-1px);
border-color: rgba(128, 224, 188, 0.35);
background: rgba(128, 224, 188, 0.1);
}
.action:active {
transform: translateY(0);
}
.action.primary {
border-color: rgba(128, 224, 188, 0.35);
background: rgba(128, 224, 188, 0.15);
color: #d9fff0;
font-weight: 750;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 18px 0 9px;
color: #d6e7e3;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.section-title span:last-child {
color: var(--muted);
font-size: 10px;
font-weight: 550;
letter-spacing: 0;
text-transform: none;
}
.metrics {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.metric {
position: relative;
overflow: hidden;
min-width: 0;
padding: 11px 9px 10px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
background: rgba(255, 255, 255, 0.035);
text-align: left;
cursor: pointer;
}
.metric::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 2px;
background: var(--metric-color);
opacity: 0.75;
content: "";
}
.metric:hover,
.metric[aria-pressed="true"] {
border-color: color-mix(in srgb, var(--metric-color) 50%, transparent);
background: color-mix(in srgb, var(--metric-color) 9%, transparent);
}
.metric-name {
display: block;
overflow: hidden;
color: #9eb8b4;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.07em;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
}
.metric-value {
display: block;
margin: 5px 0 3px;
color: var(--metric-color);
font-size: 22px;
font-weight: 750;
line-height: 1;
font-variant-numeric: tabular-nums;
}
.metric-status {
display: block;
overflow: hidden;
color: #789590;
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.chart-wrap {
position: relative;
height: 145px;
padding: 8px 5px 3px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 13px;
background: rgba(0, 10, 15, 0.19);
}
#chart {
display: block;
width: 100%;
height: 100%;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 11px;
margin-top: 8px;
color: #90aaa6;
font-size: 10px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 5px;
}
.legend-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--dot);
}
.chain {
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: center;
gap: 7px;
padding: 12px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 13px;
background: rgba(255, 255, 255, 0.025);
}
.chain-step {
text-align: center;
}
.chain-step strong {
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.chain-step small {
color: #789590;
font-size: 9px;
}
.chain-arrow {
color: #64817c;
font-size: 16px;
}
.chain.urgent .chain-arrow {
color: var(--fish);
}
.info-box {
min-height: 112px;
padding: 13px;
border-left: 3px solid var(--mint);
border-radius: 4px 12px 12px 4px;
background: rgba(128, 224, 188, 0.07);
}
.info-box h3 {
margin: 0 0 6px;
font-size: 13px;
}
.info-box p {
margin: 0;
color: #a9c0bc;
font-size: 11px;
line-height: 1.55;
}
.info-rate {
display: inline-block;
margin-top: 8px;
color: #d2eee4;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
}
details {
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 12px;
background: rgba(0, 0, 0, 0.12);
}
summary {
padding: 12px;
color: #c0d5d1;
font-size: 11px;
font-weight: 750;
cursor: pointer;
}
.equation-box {
padding: 0 12px 12px;
color: #9db5b1;
font-size: 10px;
line-height: 1.6;
}
.equation {
margin: 7px 0;
padding: 8px;
border-radius: 8px;
background: rgba(255, 255, 255, 0.035);
color: #d6e9e4;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
overflow-x: auto;
white-space: nowrap;
}
.fictional-note {
margin: 8px 0 0;
padding: 9px;
border-radius: 8px;
background: rgba(207, 148, 255, 0.1);
color: #d9c0eb;
font-size: 10px;
line-height: 1.5;
}
.caption-stack {
position: fixed;
z-index: 3;
left: 26px;
bottom: 24px;
display: grid;
grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr);
gap: 10px;
width: min(720px, calc(100vw - 430px));
pointer-events: none;
}
.caption {
padding: 12px 14px;
border: 1px solid rgba(184, 231, 218, 0.15);
border-radius: 13px;
background: rgba(3, 27, 35, 0.76);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(14px);
}
.caption strong {
display: block;
margin-bottom: 4px;
color: #d5eee7;
font-size: 10px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.caption p {
margin: 0;
color: #9fb8b4;
font-size: 10px;
line-height: 1.5;
}
.caption p + p {
margin-top: 6px;
}
.scene-label {
position: fixed;
z-index: 2;
display: flex;
align-items: center;
gap: 6px;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 999px;
background: rgba(4, 29, 37, 0.78);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
color: #e0efeb;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
cursor: pointer;
transform: translate(-50%, -50%);
backdrop-filter: blur(10px);
transition: opacity 160ms ease;
}
.scene-label::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--label-color);
box-shadow: 0 0 9px var(--label-color);
content: "";
}
.scene-label:hover {
border-color: var(--label-color);
}
.hint {
position: fixed;
z-index: 2;
top: 28px;
right: 388px;
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.11);
border-radius: 9px;
background: rgba(4, 26, 34, 0.52);
color: rgba(213, 235, 231, 0.72);
font-size: 9px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(8px);
}
@media (max-width: 900px) {
.intro {
top: 14px;
left: 14px;
max-width: calc(100vw - 28px);
}
.intro p {
display: none;
}
h1 {
font-size: 30px;
}
.eyebrow {
margin-bottom: 7px;
}
.panel {
top: 103px;
right: 10px;
bottom: 10px;
width: min(340px, calc(100vw - 20px));
padding: 14px;
}
.caption-stack {
left: 10px;
bottom: 10px;
grid-template-columns: 1fr;
width: min(440px, calc(100vw - 370px));
}
.caption:nth-child(2) {
display: none;
}
.hint {
display: none;
}
}
@media (max-width: 620px) {
.panel {
top: 94px;
right: 8px;
bottom: 8px;
width: calc(100vw - 16px);
max-height: 49vh;
}
.caption-stack {
right: 8px;
bottom: 8px;
width: auto;
}
.caption {
padding: 9px 11px;
}
.caption p {
font-size: 9px;
}
.scene-label {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive low-poly underwater kelp ecosystem"></div>
<div class="vignette"></div>
<header class="intro">
<div class="eyebrow">Fictional rate model</div>
<h1>Toy Kelp Forest</h1>
<p>
Raise or lower the urchin population, then watch kelp, fish habitat, and
water clarity respond. Select a population in the scene or panel to inspect it.
</p>
</header>
<div class="hint">Drag to orbit · Scroll to zoom · Click a population</div>
<button class="scene-label" id="label-kelp" data-population="kelp"
style="--label-color: var(--kelp)">Kelp</button>
<button class="scene-label" id="label-urchin" data-population="urchin"
style="--label-color: var(--urchin)">Urchins</button>
<button class="scene-label" id="label-fish" data-population="fish"
style="--label-color: var(--fish)">Fish</button>
<aside class="panel" aria-label="Simulation controls and population readouts">
<div class="panel-heading">
<div>
<h2>One input, linked responses</h2>
<p class="panel-subtitle">
Urchins are held constant. The other populations update continuously.
</p>
</div>
<div class="day-pill">Day <strong id="day">0.0</strong></div>
</div>
<section class="control-block" aria-labelledby="urchin-label">
<div class="control-label">
<span id="urchin-label">Urchin population</span>
<output class="control-value" id="urchin-value" for="urchin-slider">28</output>
</div>
<div class="range-wrap">
<input
id="urchin-slider"
type="range"
min="0"
max="100"
step="1"
value="28"
aria-describedby="urchin-help"
/>
<div class="range-notes">
<span>Absent</span>
<span>Dense</span>
</div>
</div>
<div class="button-row">
<button class="action primary" id="play-button" type="button">Pause model</button>
<button class="action" id="reset-button" type="button">Reset model</button>
</div>
</section>
<div class="section-title">
<span>Linked populations</span>
<span>Select to inspect</span>
</div>
<div class="metrics">
<button
class="metric"
type="button"
data-population="kelp"
aria-pressed="false"
style="--metric-color: var(--kelp)"
>
<span class="metric-name">Kelp</span>
<span class="metric-value" id="kelp-value">68%</span>
<span class="metric-status" id="kelp-status">holding</span>
</button>
<button
class="metric"
type="button"
data-population="fish"
aria-pressed="false"
style="--metric-color: var(--fish)"
>
<span class="metric-name">Fish</span>
<span class="metric-value" id="fish-value">62%</span>
<span class="metric-status" id="fish-status">habitat linked</span>
</button>
<button
class="metric"
type="button"
data-population="clarity"
aria-pressed="false"
style="--metric-color: var(--water)"
>
<span class="metric-name">Clarity</span>
<span class="metric-value" id="clarity-value">62%</span>
<span class="metric-status" id="clarity-status">settling</span>
</button>
</div>
<div class="section-title">
<span>Recent model output</span>
<span>Last ~50 model days</span>
</div>
<div class="chart-wrap">
<canvas id="chart" aria-label="Line chart of kelp, fish, and clarity over model time"></canvas>
</div>
<div class="legend" aria-hidden="true">
<span class="legend-item"><i class="legend-dot" style="--dot: var(--kelp)"></i>Kelp</span>
<span class="legend-item"><i class="legend-dot" style="--dot: var(--fish)"></i>Fish</span>
<span class="legend-item"><i class="legend-dot" style="--dot: var(--water)"></i>Clarity</span>
</div>
<div class="section-title">
<span>Response chain</span>
<span id="chain-state">Balanced</span>
</div>
<div class="chain" id="chain">
<div class="chain-step">
<strong style="color: var(--urchin)">Urchins ↑</strong>
<small>more grazing</small>
</div>
<div class="chain-arrow">→</div>
<div class="chain-step">
<strong style="color: var(--kelp)">Kelp ↓</strong>
<small>less habitat</small>
</div>
<div class="chain-arrow">→</div>
<div class="chain-step">
<strong style="color: var(--fish)">Fish ↓</strong>
<small>less clarity</small>
</div>
</div>
<div class="section-title"><span>Population inspector</span></div>
<section class="info-box" id="info-box" aria-live="polite">
<h3 id="info-title">Whole-system view</h3>
<p id="info-body">
Move the urchin slider and compare the chart with the scene. Responses
lag because the model updates gradually.
</p>
<span class="info-rate" id="info-rate">U → K → F and C</span>
</section>
<div class="section-title"><span>Toy equations</span></div>
<details>
<summary>Show invented rates and assumptions</summary>
<div class="equation-box">
<div class="equation">K̇ = 0.055K(1−K) − 0.045UK + 0.010FK</div>
<div class="equation">Ḟ = 0.040F(1−F) + 0.020K − 0.004</div>
<div class="equation">Ċ = 0.015(1−C) + 0.022K − 0.020U</div>
<p>
K = kelp, F = fish, C = clarity, and U = the user-controlled urchin
index. Values are normalized model units.
</p>
<p class="fictional-note">
Every coefficient above is fictional. They are not estimates,
measurements, predictions, or calibrated values from a real kelp forest.
</p>
</div>
</details>
<div class="section-title"><span>Camera</span></div>
<button class="action" id="camera-button" type="button" style="width: 100%">
Reset camera view
</button>
</aside>
<section class="caption-stack" aria-label="Model and real-world context captions">
<div class="caption">
<strong>Toy model</strong>
<p>
More urchins increase fictional kelp grazing. Less kelp then reduces
fish habitat and the kelp-linked clarity benefit. The rates exist only
to make those linked responses easy to see.
</p>
</div>
<div class="caption">
<strong>Real ecosystems contain additional interactions</strong>
<p>
Real kelp forests also involve storms, predators, disease, warming,
nutrients, competitors, sedimentation, and people. This scene omits
those interactions and should not be used to predict a real forest.
</p>
</div>
</section>
<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.querySelector("#scene");
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.12;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly underwater kelp forest. Drag to orbit, scroll to zoom, and click populations."
);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const murkyWater = new THREE.Color(0x24453f);
const clearWater = new THREE.Color(0x07536a);
scene.background = murkyWater.clone();
scene.fog = new THREE.FogExp2(murkyWater.clone(), 0.045);
const camera = new THREE.PerspectiveCamera(
48,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 2.35, 0);
const cameraState = {
yaw: 0.48,
pitch: 0.28,
radius: 15.5
};
function updateCamera() {
const horizontal = cameraState.radius * Math.cos(cameraState.pitch);
camera.position.set(
cameraTarget.x + horizontal * Math.sin(cameraState.yaw),
cameraTarget.y + cameraState.radius * Math.sin(cameraState.pitch),
cameraTarget.z + horizontal * Math.cos(cameraState.yaw)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0x8dd9ed, 0x173126, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xbdf4ed, 2.4);
sun.position.set(-7, 13, 5);
scene.add(sun);
const rim = new THREE.DirectionalLight(0x397c9f, 1.15);
rim.position.set(8, 4, -8);
scene.add(rim);
// Deterministic pseudo-randomness keeps the scene stable between reloads.
let seed = 7319;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function randomRange(min, max) {
return min + (max - min) * random();
}
// Seabed.
const floorGeometry = new THREE.PlaneGeometry(30, 24, 18, 14);
const floorPosition = floorGeometry.attributes.position;
const floorColors = [];
const sandLow = new THREE.Color(0x68765b);
const sandHigh = new THREE.Color(0x9a9771);
for (let i = 0; i < floorPosition.count; i++) {
const x = floorPosition.getX(i);
const y = floorPosition.getY(i);
const height =
Math.sin(x * 0.42) * 0.11 +
Math.cos(y * 0.51) * 0.09 +
randomRange(-0.06, 0.06);
floorPosition.setZ(i, height);
const color = sandLow.clone().lerp(sandHigh, randomRange(0.12, 0.78));
floorColors.push(color.r, color.g, color.b);
}
floorGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(floorColors, 3)
);
floorGeometry.computeVertexNormals();
const floorMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.96,
metalness: 0,
flatShading: true
});
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.28;
scene.add(floor);
// Low-poly rocks.
const rockGeometry = new THREE.DodecahedronGeometry(1, 0);
const rockMaterial = new THREE.MeshStandardMaterial({
color: 0x56645b,
roughness: 1,
flatShading: true
});
for (let i = 0; i < 22; i++) {
const rock = new THREE.Mesh(rockGeometry, rockMaterial);
const side = i % 2 === 0 ? -1 : 1;
const radius = randomRange(6, 12);
rock.position.set(
side * radius + randomRange(-1.2, 1.2),
randomRange(-0.08, 0.22),
randomRange(-9, 9)
);
rock.scale.set(
randomRange(0.35, 1.05),
randomRange(0.25, 0.72),
randomRange(0.4, 1.25)
);
rock.rotation.set(
randomRange(-0.3, 0.3),
randomRange(0, Math.PI),
randomRange(-0.25, 0.25)
);
scene.add(rock);
}
// A transparent surface and polygonal shafts of light.
const surfaceMaterial = new THREE.MeshStandardMaterial({
color: 0x8ddce8,
transparent: true,
opacity: 0.13,
roughness: 0.7,
side: THREE.DoubleSide,
depthWrite: false
});
const surface = new THREE.Mesh(
new THREE.PlaneGeometry(38, 38, 1, 1),
surfaceMaterial
);
surface.rotation.x = Math.PI / 2;
surface.position.y = 9.2;
scene.add(surface);
const shaftMaterial = new THREE.MeshBasicMaterial({
color: 0xb4f5e5,
transparent: true,
opacity: 0.035,
side: THREE.DoubleSide,
depthWrite: false
});
for (let i = 0; i < 6; i++) {
const shaft = new THREE.Mesh(
new THREE.ConeGeometry(randomRange(1.4, 2.8), 11, 6, 1, true),
shaftMaterial
);
shaft.position.set(
randomRange(-8, 8),
randomRange(3.6, 5.4),
randomRange(-7, 7)
);
shaft.rotation.z = randomRange(-0.22, 0.22);
scene.add(shaft);
}
// Suspended particles.
const particleCount = 220;
const particlePositions = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount; i++) {
particlePositions[i * 3] = randomRange(-13, 13);
particlePositions[i * 3 + 1] = randomRange(0.2, 8.7);
particlePositions[i * 3 + 2] = randomRange(-11, 11);
}
const particleGeometry = new THREE.BufferGeometry();
particleGeometry.setAttribute(
"position",
new THREE.BufferAttribute(particlePositions, 3)
);
const particles = new THREE.Points(
particleGeometry,
new THREE.PointsMaterial({
color: 0xc6eee4,
size: 0.055,
transparent: true,
opacity: 0.46,
depthWrite: false
})
);
scene.add(particles);
const clickTargets = [];
function registerSelectable(root, population) {
root.traverse((object) => {
if (object.isMesh) {
object.userData.population = population;
clickTargets.push(object);
}
});
}
// Shared low-poly leaf geometry.
const leafGeometry = new THREE.BufferGeometry();
leafGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[
0, 0, 0,
-0.16, 0.38, 0,
0, 1, 0,
0.16, 0.38, 0
],
3
)
);
leafGeometry.setIndex([0, 1, 2, 0, 2, 3]);
leafGeometry.computeVertexNormals();
const kelpPlants = [];
const maxKelp = 24;
for (let i = 0; i < maxKelp; i++) {
const plant = new THREE.Group();
const angle = randomRange(0, Math.PI * 2);
const radius = Math.sqrt(random()) * 7.4;
plant.position.set(
Math.cos(angle) * radius,
-0.1,
Math.sin(angle) * radius * 0.72
);
plant.rotation.y = randomRange(0, Math.PI * 2);
const stemMaterial = new THREE.MeshStandardMaterial({
color: 0x6c7b31,
roughness: 0.92,
flatShading: true
});
const leafMaterial = new THREE.MeshStandardMaterial({
color: 0x619b47,
roughness: 0.9,
side: THREE.DoubleSide,
flatShading: true
});
const stem = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.08, 1, 6),
stemMaterial
);
stem.position.y = 0.5;
plant.add(stem);
for (let leafIndex = 0; leafIndex < 6; leafIndex++) {
const leaf = new THREE.Mesh(leafGeometry, leafMaterial);
leaf.position.y = 0.12 + leafIndex * 0.135;
leaf.rotation.y = leafIndex * 2.37 + randomRange(-0.25, 0.25);
leaf.rotation.z = (leafIndex % 2 === 0 ? 1 : -1) * randomRange(0.28, 0.72);
leaf.scale.set(
randomRange(0.7, 1.12),
randomRange(0.62, 1.0),
1
);
plant.add(leaf);
}
plant.userData.phase = randomRange(0, Math.PI * 2);
plant.userData.leafMaterial = leafMaterial;
plant.userData.stemMaterial = stemMaterial;
plant.userData.baseRotation = plant.rotation.z;
registerSelectable(plant, "kelp");
kelpPlants.push(plant);
scene.add(plant);
}
// Urchins: low-poly sphere with radial cone spines.
const urchins = [];
const maxUrchins = 18;
const urchinBodyGeometry = new THREE.IcosahedronGeometry(0.22, 1);
const urchinSpineGeometry = new THREE.ConeGeometry(0.04, 0.23, 5);
const urchinMaterial = new THREE.MeshStandardMaterial({
color: 0x49345b,
roughness: 0.82,
flatShading: true
});
const spineMaterial = new THREE.MeshStandardMaterial({
color: 0x8263a0,
roughness: 0.78,
flatShading: true
});
const up = new THREE.Vector3(0, 1, 0);
for (let i = 0; i < maxUrchins; i++) {
const urchin = new THREE.Group();
const angle = randomRange(0, Math.PI * 2);
const radius = randomRange(1.2, 6.2);
urchin.position.set(
Math.cos(angle) * radius,
0.06,
Math.sin(angle) * radius * 0.7
);
const body = new THREE.Mesh(urchinBodyGeometry, urchinMaterial);
body.scale.set(1, 0.68, 1);
urchin.add(body);
for (let spineIndex = 0; spineIndex < 12; spineIndex++) {
const phi = Math.acos(1 - (2 * (spineIndex + 0.5)) / 12);
const theta = Math.PI * (1 + Math.sqrt(5)) * spineIndex;
const direction = new THREE.Vector3(
Math.cos(theta) * Math.sin(phi),
Math.cos(phi),
Math.sin(theta) * Math.sin(phi)
);
const spine = new THREE.Mesh(urchinSpineGeometry, spineMaterial);
spine.position.copy(direction).multiplyScalar(0.23);
spine.quaternion.setFromUnitVectors(up, direction);
urchin.add(spine);
}
urchin.userData.phase = randomRange(0, Math.PI * 2);
urchin.userData.baseY = urchin.position.y;
registerSelectable(urchin, "urchin");
urchins.push(urchin);
scene.add(urchin);
}
// Fish: faceted bodies and simple triangular tails.
const fish = [];
const maxFish = 24;
const fishBodyGeometry = new THREE.OctahedronGeometry(1, 0);
const fishTailGeometry = new THREE.ConeGeometry(0.19, 0.3, 3);
const fishMaterial = new THREE.MeshStandardMaterial({
color: 0xf39a69,
roughness: 0.68,
flatShading: true
});
const fishTailMaterial = new THREE.MeshStandardMaterial({
color: 0xffc084,
roughness: 0.7,
flatShading: true
});
const eyeMaterial = new THREE.MeshBasicMaterial({ color: 0x15202a });
for (let i = 0; i < maxFish; i++) {
const fishGroup = new THREE.Group();
const centerAngle = randomRange(0, Math.PI * 2);
const orbitRadius = randomRange(2.5, 8.2);
fishGroup.userData.angle = centerAngle;
fishGroup.userData.orbitRadius = orbitRadius;
fishGroup.userData.height = randomRange(1.2, 5.8);
fishGroup.userData.phase = randomRange(0, Math.PI * 2);
fishGroup.userData.speed = randomRange(0.09, 0.17);
const body = new THREE.Mesh(fishBodyGeometry, fishMaterial);
body.scale.set(0.36, 0.14, 0.13);
fishGroup.add(body);
const tail = new THREE.Mesh(fishTailGeometry, fishTailMaterial);
tail.rotation.z = Math.PI / 2;
tail.position.x = -0.32;
tail.scale.set(0.75, 1, 0.75);
fishGroup.add(tail);
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.035, 6, 4),
eyeMaterial
);
eye.position.set(0.22, 0.06, 0.105);
fishGroup.add(eye);
fishGroup.userData.tail = tail;
registerSelectable(fishGroup, "fish");
fish.push(fishGroup);
scene.add(fishGroup);
}
// Toy model state. All coefficients below are deliberately fictional.
const initialState = Object.freeze({
kelp: 0.68,
fish: 0.62,
clarity: 0.62,
urchin: 0.28
});
const state = { ...initialState };
const history = [];
let simulationDay = 0;
let simulationRunning = !window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let simulationAccumulator = 0;
let historyAccumulator = 0;
const dayElement = document.querySelector("#day");
const urchinSlider = document.querySelector("#urchin-slider");
const urchinValue = document.querySelector("#urchin-value");
const playButton = document.querySelector("#play-button");
const kelpValue = document.querySelector("#kelp-value");
const fishValue = document.querySelector("#fish-value");
const clarityValue = document.querySelector("#clarity-value");
const kelpStatus = document.querySelector("#kelp-status");
const fishStatus = document.querySelector("#fish-status");
const clarityStatus = document.querySelector("#clarity-status");
const chain = document.querySelector("#chain");
const chainState = document.querySelector("#chain-state");
function integrateModel(step) {
const K = state.kelp;
const F = state.fish;
const C = state.clarity;
const U = state.urchin;
// FICTIONAL toy rates, in normalized model units per model day.
const dK =
0.055 * K * (1 - K) -
0.045 * U * K +
0.010 * F * K;
const dF =
0.040 * F * (1 - F) +
0.020 * K -
0.004;
const dC =
0.015 * (1 - C) +
0.022 * K -
0.020 * U;
state.kelp = THREE.MathUtils.clamp(K + dK * step, 0.01, 1);
state.fish = THREE.MathUtils.clamp(F + dF * step, 0.01, 1);
state.clarity = THREE.MathUtils.clamp(C + dC * step, 0.01, 1);
simulationDay += step;
}
function pushHistory() {
history.push({
kelp: state.kelp,
fish: state.fish,
clarity: state.clarity
});
if (history.length > 180) {
history.shift();
}
}
function updateSlider() {
const value = Number(urchinSlider.value);
state.urchin = value / 100;
urchinValue.textContent = value;
urchinSlider.style.setProperty("--fill", `${value}%`);
urchinSlider.setAttribute("aria-valuetext", `${value} out of 100`);
}
urchinSlider.addEventListener("input", updateSlider);
updateSlider();
function resetModel() {
Object.assign(state, initialState);
simulationDay = 0;
simulationAccumulator = 0;
historyAccumulator = 0;
history.length = 0;
pushHistory();
updateInterface();
}
function updatePlayButton() {
playButton.textContent = simulationRunning ? "Pause model" : "Resume model";
}
playButton.addEventListener("click", () => {
simulationRunning = !simulationRunning;
updatePlayButton();
});
document.querySelector("#reset-button").addEventListener("click", resetModel);
document.querySelector("#camera-button").addEventListener("click", () => {
cameraState.yaw = 0.48;
cameraState.pitch = 0.28;
cameraState.radius = 15.5;
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
simulationRunning = !simulationRunning;
updatePlayButton();
}
});
// Population inspector.
const inspector = {
system: {
title: "Whole-system view",
body:
"Move the urchin slider and compare the chart with the scene. Responses lag because the model updates gradually.",
rate: "U → K → F and C"
},
kelp: {
title: "Kelp biomass",
body:
"Urchins remove kelp through an invented grazing term. With the other coefficients fixed, a higher urchin index lowers kelp biomass.",
rate: "grazing term: −0.045 U K"
},
urchin: {
title: "Urchin population",
body:
"This is the only population the user controls. It stays constant: urchins do not reproduce, starve, or move between habitats in this toy.",
rate: "input: U = 0…1"
},
fish: {
title: "Fish abundance",
body:
"Fish receive an invented habitat benefit from kelp, so their response appears after kelp begins changing. Fish do not directly control the scene.",
rate: "habitat term: +0.020 K"
},
clarity: {
title: "Water clarity",
body:
"Clarity rises with the fictional kelp benefit and falls with fictional urchin disturbance. The water color responds to the same model value.",
rate: "+0.022 K − 0.020 U"
}
};
let selectedPopulation = "system";
const infoTitle = document.querySelector("#info-title");
const infoBody = document.querySelector("#info-body");
const infoRate = document.querySelector("#info-rate");
const metricButtons = [...document.querySelectorAll(".metric[data-population]")];
const sceneLabels = [...document.querySelectorAll(".scene-label[data-population]")];
function selectPopulation(population) {
selectedPopulation = population;
const entry = inspector[population];
infoTitle.textContent = entry.title;
infoBody.textContent = entry.body;
infoRate.textContent = entry.rate;
metricButtons.forEach((button) => {
button.setAttribute(
"aria-pressed",
String(button.dataset.population === population)
);
});
sceneLabels.forEach((label) => {
label.style.borderColor =
label.dataset.population === population
? "var(--label-color)"
: "rgba(255,255,255,0.2)";
});
}
metricButtons.forEach((button) => {
button.addEventListener("click", () => {
selectPopulation(button.dataset.population);
});
});
sceneLabels.forEach((label) => {
label.addEventListener("click", () => {
selectPopulation(label.dataset.population);
});
});
// Camera controls implemented directly without addons.
const pointer = {
down: false,
x: 0,
y: 0,
moved: 0
};
renderer.domElement.addEventListener("pointerdown", (event) => {
pointer.down = true;
pointer.x = event.clientX;
pointer.y = event.clientY;
pointer.moved = 0;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointer.down) return;
const deltaX = event.clientX - pointer.x;
const deltaY = event.clientY - pointer.y;
pointer.moved += Math.abs(deltaX) + Math.abs(deltaY);
pointer.x = event.clientX;
pointer.y = event.clientY;
cameraState.yaw -= deltaX * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + deltaY * 0.0045,
0.04,
1.05
);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
pointer.down = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (pointer.moved < 7) {
inspectSceneObject(event.clientX, event.clientY);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointer.down = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
8.5,
25
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
cameraState.yaw = 0.48;
cameraState.pitch = 0.28;
cameraState.radius = 15.5;
updateCamera();
});
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function inspectSceneObject(clientX, clientY) {
pointerNDC.x = (clientX / window.innerWidth) * 2 - 1;
pointerNDC.y = -(clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const intersections = raycaster.intersectObjects(clickTargets, false);
if (intersections.length > 0) {
selectPopulation(intersections[0].object.userData.population);
}
}
// Responsive chart.
const chart = document.querySelector("#chart");
const chartContext = chart.getContext("2d");
function drawChart() {
const rect = chart.getBoundingClientRect();
const dpr = Math.min(window.devicePixelRatio, 2);
const width = Math.max(1, rect.width);
const height = Math.max(1, rect.height);
if (
chart.width !== Math.round(width * dpr) ||
chart.height !== Math.round(height * dpr)
) {
chart.width = Math.round(width * dpr);
chart.height = Math.round(height * dpr);
}
chartContext.setTransform(dpr, 0, 0, dpr, 0, 0);
chartContext.clearRect(0, 0, width, height);
const padding = {
left: 25,
right: 7,
top: 9,
bottom: 18
};
const plotWidth = width - padding.left - padding.right;
const plotHeight = height - padding.top - padding.bottom;
chartContext.font = "9px system-ui";
chartContext.textBaseline = "middle";
for (const value of [0, 0.5, 1]) {
const y = padding.top + (1 - value) * plotHeight;
chartContext.strokeStyle = "rgba(190, 230, 220, 0.09)";
chartContext.lineWidth = 1;
chartContext.beginPath();
chartContext.moveTo(padding.left, y);
chartContext.lineTo(width - padding.right, y);
chartContext.stroke();
chartContext.fillStyle = "rgba(170, 199, 194, 0.55)";
chartContext.textAlign = "right";
chartContext.fillText(value.toFixed(1), padding.left - 5, y);
}
chartContext.fillStyle = "rgba(170, 199, 194, 0.5)";
chartContext.textAlign = "left";
chartContext.fillText("older", padding.left, height - 5);
chartContext.textAlign = "right";
chartContext.fillText("now", width - padding.right, height - 5);
if (history.length < 2) return;
const series = [
{ key: "kelp", color: "#a8d35b" },
{ key: "fish", color: "#ff9b73" },
{ key: "clarity", color: "#70d9ed" }
];
for (const entry of series) {
chartContext.strokeStyle = entry.color;
chartContext.lineWidth = 2;
chartContext.lineJoin = "round";
chartContext.lineCap = "round";
chartContext.beginPath();
history.forEach((sample, index) => {
const x =
padding.left +
(index / Math.max(1, history.length - 1)) * plotWidth;
const y =
padding.top +
(1 - sample[entry.key]) * plotHeight;
if (index === 0) chartContext.moveTo(x, y);
else chartContext.lineTo(x, y);
});
chartContext.stroke();
const last = history[history.length - 1];
const lastX = width - padding.right;
const lastY = padding.top + (1 - last[entry.key]) * plotHeight;
chartContext.fillStyle = entry.color;
chartContext.beginPath();
chartContext.arc(lastX, lastY, 2.5, 0, Math.PI * 2);
chartContext.fill();
}
}
function approximateTrend(key) {
if (history.length < 8) return 0;
const first = history[Math.max(0, history.length - 20)][key];
const last = history[history.length - 1][key];
return last - first;
}
function updateInterface() {
dayElement.textContent = simulationDay.toFixed(1);
kelpValue.textContent = `${Math.round(state.kelp * 100)}%`;
fishValue.textContent = `${Math.round(state.fish * 100)}%`;
clarityValue.textContent = `${Math.round(state.clarity * 100)}%`;
const kelpTrend = approximateTrend("kelp");
const fishTrend = approximateTrend("fish");
const clarityTrend = approximateTrend("clarity");
kelpStatus.textContent =
state.urchin > 0.55
? "grazing pressure"
: kelpTrend < -0.015
? "declining"
: kelpTrend > 0.015
? "recovering"
: "holding";
fishStatus.textContent =
state.kelp < 0.38
? "habitat falling"
: fishTrend < -0.012
? "lagging decline"
: fishTrend > 0.012
? "responding"
: "habitat linked";
clarityStatus.textContent =
state.urchin > 0.58 && clarityTrend < 0
? "sediment rising"
: clarityTrend > 0.012
? "improving"
: "settling";
const urgent = state.urchin > 0.55 || state.kelp < 0.35;
chain.classList.toggle("urgent", urgent);
chainState.textContent = urgent ? "Pressure rising" : "Balanced";
}
const dryKelp = new THREE.Color(0x8e6b2f);
const lushKelp = new THREE.Color(0x579d4a);
const dryStem = new THREE.Color(0x76552c);
const lushStem = new THREE.Color(0x5e7d31);
const murkyFloor = new THREE.Color(0x656a58);
const clearFloor = new THREE.Color(0x8a8c68);
function updateVisuals(time, delta) {
const visibleKelp = Math.round(state.kelp * maxKelp);
const visibleUrchins = Math.round(state.urchin * maxUrchins);
const visibleFish = Math.round(state.fish * maxFish);
kelpPlants.forEach((plant, index) => {
plant.visible = index < visibleKelp;
const horizontalScale = 0.68 + state.kelp * 0.42;
plant.scale.set(
horizontalScale,
0.34 + state.kelp * 0.95,
horizontalScale
);
plant.userData.leafMaterial.color
.copy(dryKelp)
.lerp(lushKelp, THREE.MathUtils.clamp(state.kelp * 1.15, 0, 1));
plant.userData.stemMaterial.color
.copy(dryStem)
.lerp(lushStem, THREE.MathUtils.clamp(state.kelp * 1.1, 0, 1));
plant.rotation.z =
plant.userData.baseRotation +
Math.sin(time * 0.72 + plant.userData.phase) * 0.045;
});
urchins.forEach((urchin, index) => {
urchin.visible = index < visibleUrchins;
const scale = 0.74 + state.urchin * 0.38;
urchin.scale.setScalar(scale);
urchin.position.y =
urchin.userData.baseY +
Math.sin(time * 0.7 + urchin.userData.phase) * 0.015;
urchin.rotation.y += delta * 0.08;
});
fish.forEach((fishGroup, index) => {
fishGroup.visible = index < visibleFish;
const orbitAngle =
fishGroup.userData.angle +
time * fishGroup.userData.speed * (0.65 + state.fish * 0.6);
const radius = fishGroup.userData.orbitRadius;
fishGroup.position.x = Math.cos(orbitAngle) * radius;
fishGroup.position.z = Math.sin(orbitAngle) * radius * 0.72;
fishGroup.position.y =
fishGroup.userData.height +
Math.sin(time * 0.9 + fishGroup.userData.phase) * 0.24;
fishGroup.rotation.y = -orbitAngle + Math.PI / 2;
fishGroup.userData.tail.rotation.y =
Math.sin(time * 6 + fishGroup.userData.phase) * 0.28;
});
scene.background
.copy(murkyWater)
.lerp(clearWater, state.clarity);
scene.fog.color.copy(scene.background);
scene.fog.density = 0.054 - state.clarity * 0.019;
floorMaterial.color
.copy(murkyFloor)
.lerp(clearFloor, state.clarity);
sun.intensity = 1.55 + state.clarity * 1.15;
shaftMaterial.opacity = 0.018 + state.clarity * 0.028;
particles.rotation.y = time * 0.008;
particles.position.y = Math.sin(time * 0.11) * 0.12;
}
// Screen-space labels for direct inspection.
const labelAnchors = {
kelp: {
element: document.querySelector("#label-kelp"),
point: new THREE.Vector3(-1.4, 4.0, -0.4),
visible: () => state.kelp > 0.08
},
urchin: {
element: document.querySelector("#label-urchin"),
point: new THREE.Vector3(-4.4, 0.55, 3.0),
visible: () => state.urchin > 0.05
},
fish: {
element: document.querySelector("#label-fish"),
point: new THREE.Vector3(4.0, 3.6, -2.0),
visible: () => state.fish > 0.08
}
};
const projectedPoint = new THREE.Vector3();
function updateLabels() {
Object.values(labelAnchors).forEach((label) => {
projectedPoint.copy(label.point).project(camera);
const x = (projectedPoint.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projectedPoint.y * 0.5 + 0.5) * window.innerHeight;
const inView =
projectedPoint.z > -1 &&
projectedPoint.z < 1 &&
x > -100 &&
x < window.innerWidth + 100 &&
y > -50 &&
y < window.innerHeight + 50;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
label.element.style.opacity =
label.visible() && inView ? "1" : "0";
label.element.style.pointerEvents =
label.visible() && inView ? "auto" : "none";
});
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
drawChart();
});
const clock = new THREE.Clock();
const fixedStep = 0.05;
const simulatedDaysPerSecond = 2.7;
pushHistory();
updatePlayButton();
updateInterface();
drawChart();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (simulationRunning) {
simulationAccumulator += delta * simulatedDaysPerSecond;
while (simulationAccumulator >= fixedStep) {
integrateModel(fixedStep);
simulationAccumulator -= fixedStep;
historyAccumulator += fixedStep;
if (historyAccumulator >= 0.1) {
pushHistory();
historyAccumulator -= 0.1;
}
}
}
updateVisuals(elapsed, delta);
updateInterface();
updateLabels();
drawChart();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```