Prompt specification
Build or customize the Three.js 3D scene "Environmental response botanical courtyard" 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: Environmental response botanical courtyard
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/environmental-response-botanical-courtyard-x0943
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts phenotypic plasticity. Compose identical-source plants along a light gradient beneath a pergola; show an illustrative response curve beside them and distinguish plasticity from evolution across generations. Voxel style.
Working Three.js Starter (environmental-response-botanical-courtyard-x0943):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Phenotypic Plasticity — Voxel Scene</title>
<style>
:root {
--ink: #102a31;
--paper: #f5f0dc;
--sun: #f5c45c;
--mint: #85d0aa;
--coral: #f2876d;
--panel: rgba(13, 34, 40, 0.94);
--line: rgba(245, 240, 220, 0.24);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #78989a;
color: var(--paper);
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.title-card {
position: absolute;
top: 24px;
left: 24px;
width: min(440px, calc(100vw - 48px));
padding: 18px 20px 17px;
background: rgba(14, 36, 42, 0.91);
border: 2px solid rgba(245, 240, 220, 0.82);
box-shadow: 7px 7px 0 rgba(8, 24, 29, 0.28);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--mint);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
background: var(--mint);
box-shadow: 3px 3px 0 #326b68;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 42px);
line-height: 0.96;
letter-spacing: -0.055em;
text-transform: uppercase;
}
.title-card p {
max-width: 390px;
margin: 12px 0 0;
color: #d2ded5;
font-size: 12px;
line-height: 1.55;
}
.source-chip {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 13px;
padding: 6px 8px;
color: #142c31;
background: var(--sun);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.05em;
}
.source-chip i {
width: 7px;
height: 7px;
background: #143137;
box-shadow: 4px 0 0 #e36f58, 8px 0 0 #69b49b;
}
.toolbar {
position: absolute;
top: 24px;
right: 24px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
border: 2px solid rgba(245, 240, 220, 0.8);
border-radius: 0;
padding: 10px 12px;
color: var(--paper);
background: rgba(14, 36, 42, 0.91);
font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 4px 4px 0 rgba(8, 24, 29, 0.25);
}
button:hover {
color: var(--ink);
background: var(--sun);
}
button:focus-visible {
outline: 3px solid var(--coral);
outline-offset: 3px;
}
.info-panel {
position: absolute;
top: 78px;
right: 24px;
width: 342px;
max-height: calc(100vh - 102px);
overflow: auto;
padding: 18px;
background: var(--panel);
border: 2px solid rgba(245, 240, 220, 0.78);
box-shadow: 8px 8px 0 rgba(8, 24, 29, 0.28);
pointer-events: auto;
scrollbar-width: thin;
scrollbar-color: #628680 transparent;
transition:
opacity 180ms ease,
transform 180ms ease;
}
.info-panel.collapsed {
opacity: 0;
transform: translateX(calc(100% + 34px));
pointer-events: none;
}
.panel-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.panel-kicker {
margin-bottom: 5px;
color: var(--sun);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.panel-head h2 {
margin: 0;
font-size: 18px;
letter-spacing: -0.04em;
text-transform: uppercase;
}
.tiny-tag {
flex: 0 0 auto;
padding: 5px 6px;
color: #a9c9bd;
border: 1px solid #456961;
font-size: 8px;
line-height: 1;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.chart-wrap {
position: relative;
margin: 14px 0 6px;
padding: 10px 8px 6px;
background:
linear-gradient(rgba(133, 208, 170, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(133, 208, 170, 0.05) 1px, transparent 1px),
#102b31;
background-size: 24px 24px;
border: 1px solid #36565a;
}
.chart-wrap svg {
display: block;
width: 100%;
height: auto;
overflow: visible;
}
.chart-note {
margin: 8px 0 15px;
color: #9eb5ae;
font-size: 9px;
line-height: 1.45;
}
.chart-note strong {
color: var(--paper);
}
.comparison {
display: grid;
gap: 10px;
}
.concept {
position: relative;
padding: 13px 13px 12px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.035);
}
.concept.plasticity {
border-left: 5px solid var(--mint);
}
.concept.evolution {
border-left: 5px solid var(--coral);
}
.concept h3 {
margin: 0 0 3px;
font-size: 13px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.concept .when {
color: #9fb6af;
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.concept p {
margin: 10px 0 0;
color: #d7e0d8;
font-size: 10px;
line-height: 1.5;
}
.concept strong {
color: var(--paper);
}
.diagram {
display: flex;
align-items: center;
gap: 9px;
min-height: 43px;
margin-top: 11px;
padding: 8px;
background: #102b31;
border: 1px solid #29494e;
}
.dna {
display: grid;
grid-template-columns: repeat(4, 6px);
grid-template-rows: repeat(2, 6px);
gap: 3px;
flex: 0 0 auto;
}
.dna i {
display: block;
width: 6px;
height: 6px;
background: var(--sun);
}
.dna i:nth-child(2n) {
background: var(--coral);
}
.dna i:nth-child(3n) {
background: var(--mint);
}
.arrow {
color: #789a91;
font-size: 16px;
font-weight: 900;
}
.mini-plants {
display: flex;
align-items: flex-end;
gap: 9px;
}
.mini-plant {
position: relative;
width: 28px;
height: 34px;
}
.mini-plant::before {
content: "";
position: absolute;
left: 12px;
bottom: 0;
width: 4px;
height: 25px;
background: #5f9e62;
}
.mini-plant::after {
content: "";
position: absolute;
left: 2px;
top: 9px;
width: 24px;
height: 9px;
background: var(--mint);
box-shadow: 0 10px 0 #4c9162;
}
.mini-plant.sunny::after {
left: 8px;
width: 12px;
height: 13px;
background: #a7bd62;
box-shadow: none;
}
.mini-plant.sunny::before {
height: 31px;
background: #79a95d;
}
.mini-label {
color: #8fa9a1;
font-size: 8px;
line-height: 1.35;
text-transform: uppercase;
}
.sequence-set {
display: flex;
align-items: center;
gap: 7px;
}
.sequence {
padding: 4px;
border: 1px solid #35565a;
background: #0d262c;
}
.sequence .dna {
transform: scale(0.85);
}
.sequence.changed .dna i:nth-child(3) {
background: var(--coral);
}
.sequence.changed .dna i:nth-child(6) {
background: #a2c4ff;
}
.not-equal {
margin-top: 14px;
padding: 10px;
color: var(--ink);
background: var(--sun);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.06em;
text-align: center;
text-transform: uppercase;
}
.light-key {
position: absolute;
left: 24px;
bottom: 24px;
width: min(430px, calc(100vw - 48px));
padding: 12px 14px;
background: rgba(14, 36, 42, 0.91);
border: 2px solid rgba(245, 240, 220, 0.72);
box-shadow: 6px 6px 0 rgba(8, 24, 29, 0.25);
}
.gradient-labels {
display: flex;
justify-content: space-between;
margin-bottom: 7px;
color: #d8e3da;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.gradient-bar {
height: 10px;
background: linear-gradient(
90deg,
#263d4a 0%,
#37645f 34%,
#819b62 66%,
#d3b557 100%
);
border: 1px solid rgba(245, 240, 220, 0.4);
}
.control-hint {
margin-top: 8px;
color: #92aaa2;
font-size: 8px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.corner-note {
position: absolute;
right: 24px;
bottom: 24px;
padding: 8px 10px;
color: #dbe5dc;
background: rgba(14, 36, 42, 0.78);
border-left: 4px solid var(--mint);
font-size: 9px;
line-height: 1.45;
text-align: right;
text-transform: uppercase;
letter-spacing: 0.04em;
}
@media (max-width: 860px) {
.title-card {
top: 14px;
left: 14px;
width: min(370px, calc(100vw - 28px));
padding: 14px;
}
.title-card p {
display: none;
}
.toolbar {
top: 14px;
right: 14px;
}
.info-panel {
top: auto;
right: 14px;
bottom: 14px;
width: min(342px, calc(100vw - 28px));
max-height: 47vh;
}
.info-panel.collapsed {
transform: translateY(calc(100% + 24px));
}
.light-key {
left: 14px;
bottom: 14px;
width: min(300px, calc(100vw - 28px));
}
.corner-note {
display: none;
}
}
@media (max-width: 520px) {
h1 {
font-size: 25px;
}
.eyebrow {
font-size: 8px;
}
.source-chip {
font-size: 8px;
}
.toolbar button {
padding: 9px;
font-size: 8px;
}
.light-key {
width: 210px;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive voxel scene showing genetically identical plants with different phenotypes along a light gradient."
></canvas>
<div class="hud">
<section class="title-card" aria-labelledby="page-title">
<div class="eyebrow">One genotype · many forms</div>
<h1 id="page-title">Phenotypic<br />Plasticity</h1>
<p>
Seven clones from the same source track a light gradient beneath a
pergola. Leaf area and growth allocation change; the source DNA does not.
</p>
<div class="source-chip">
<i aria-hidden="true"></i>
Identical source · genotype A
</div>
</section>
<div class="toolbar">
<button id="resetView" type="button">Reset view</button>
<button id="toggleInfo" type="button" aria-expanded="true">Hide info</button>
</div>
<aside class="info-panel" id="infoPanel" aria-label="Response curve and plasticity versus evolution">
<div class="panel-head">
<div>
<div class="panel-kicker">Environment → phenotype</div>
<h2>Illustrative response curve</h2>
</div>
<span class="tiny-tag">Not species data</span>
</div>
<div class="chart-wrap">
<svg
viewBox="0 0 320 190"
role="img"
aria-label="Relative leaf area decreases as light exposure increases"
>
<g stroke="#315158" stroke-width="1">
<line x1="30" y1="34" x2="288" y2="34" />
<line x1="30" y1="60" x2="288" y2="60" />
<line x1="30" y1="87" x2="288" y2="87" />
<line x1="30" y1="113" x2="288" y2="113" />
<line x1="30" y1="140" x2="288" y2="140" />
</g>
<g stroke="#53736e" stroke-width="1">
<line x1="30" y1="24" x2="30" y2="150" />
<line x1="80" y1="24" x2="80" y2="150" />
<line x1="130" y1="24" x2="130" y2="150" />
<line x1="180" y1="24" x2="180" y2="150" />
<line x1="230" y1="24" x2="230" y2="150" />
<line x1="288" y1="24" x2="288" y2="150" />
</g>
<path
d="M30 34 C72 43 104 59 130 77 C166 102 204 123 288 136"
fill="none"
stroke="#f5c45c"
stroke-width="5"
stroke-linecap="square"
/>
<g stroke="#102b31" stroke-width="2">
<circle cx="30" cy="34" r="6" fill="#31525c" />
<circle cx="70" cy="46" r="6" fill="#3c6261" />
<circle cx="110" cy="64" r="6" fill="#52766a" />
<circle cx="150" cy="84" r="6" fill="#708b67" />
<circle cx="190" cy="105" r="6" fill="#929d5e" />
<circle cx="230" cy="122" r="6" fill="#b1aa5b" />
<circle cx="270" cy="134" r="6" fill="#d2b35a" />
</g>
<text x="8" y="91" fill="#8fa9a1" font-size="9" transform="rotate(-90 8 91)">
RELATIVE LEAF AREA
</text>
<text x="215" y="176" fill="#8fa9a1" font-size="9">LIGHT EXPOSURE →</text>
<text x="25" y="164" fill="#8fa9a1" font-size="8">SHADE</text>
<text x="254" y="164" fill="#8fa9a1" font-size="8">SUN</text>
</svg>
</div>
<p class="chart-note">
<strong>Same source genotype.</strong> Each dot represents the visible
phenotype of a clone in a different light environment.
</p>
<div class="comparison">
<section class="concept plasticity">
<h3>Plasticity</h3>
<div class="when">Within one genotype · during one lifetime</div>
<div class="diagram">
<div class="dna" aria-label="One unchanged DNA sequence">
<i></i><i></i><i></i><i></i>
<i></i><i></i><i></i><i></i>
</div>
<span class="arrow">→</span>
<div class="mini-plants" aria-hidden="true">
<div class="mini-plant"></div>
<div class="mini-plant sunny"></div>
</div>
<div class="mini-label">shade<br />or sun</div>
</div>
<p>
<strong>Environment changes the expressed form.</strong> The plant
responds without changing its inherited genotype.
</p>
</section>
<section class="concept evolution">
<h3>Evolution</h3>
<div class="when">Across generations · in a population</div>
<div class="diagram">
<div class="sequence-set" aria-label="Three generations with changing DNA sequences">
<div class="sequence">
<div class="dna">
<i></i><i></i><i></i><i></i>
<i></i><i></i><i></i><i></i>
</div>
</div>
<span class="arrow">→</span>
<div class="sequence changed">
<div class="dna">
<i></i><i></i><i></i><i></i>
<i></i><i></i><i></i><i></i>
</div>
</div>
<span class="arrow">→</span>
<div class="sequence changed">
<div class="dna">
<i></i><i></i><i></i><i></i>
<i></i><i></i><i></i><i></i>
</div>
</div>
</div>
</div>
<p>
<strong>Inherited variation changes across generations.</strong>
Descendants differ because the population's genotype has changed.
</p>
</section>
</div>
<div class="not-equal">Plasticity ≠ evolution</div>
</aside>
<div class="light-key" aria-label="Light gradient legend">
<div class="gradient-labels">
<span>More shade</span>
<span>More sun</span>
</div>
<div class="gradient-bar"></div>
<div class="control-hint">Drag to orbit · scroll / pinch to zoom · double-click to reset</div>
</div>
<div class="corner-note">
Environmental response<br />≠ genetic change
</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 canvas = document.querySelector("#scene");
const infoPanel = document.querySelector("#infoPanel");
const toggleInfo = document.querySelector("#toggleInfo");
const resetButton = document.querySelector("#resetView");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x86a3a2);
scene.fog = new THREE.Fog(0x86a3a2, 25, 48);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const desired = {
yaw: 0.34,
pitch: 0.48,
radius: 20.5,
target: new THREE.Vector3(-0.4, 2.35, 0)
};
const current = {
yaw: desired.yaw,
pitch: desired.pitch,
radius: desired.radius,
target: desired.target.clone()
};
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const plants = [];
const lightMotes = [];
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
...options
});
}
function box(w, h, d, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLabel(text, color = "#f5f0dc", width = 3.6) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 640;
labelCanvas.height = 112;
const ctx = labelCanvas.getContext("2d");
ctx.fillStyle = "rgba(12, 34, 40, 0.92)";
ctx.fillRect(0, 0, 640, 112);
ctx.fillStyle = color;
ctx.fillRect(0, 0, 10, 112);
ctx.fillRect(0, 102, 640, 10);
ctx.fillStyle = color;
ctx.font = "900 42px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 320, 52);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(width, width * 112 / 640, 1);
return sprite;
}
// Lighting: a warm right-side sun and a cooler, dimmer shade side.
scene.add(new THREE.HemisphereLight(0xc7e1dc, 0x263a35, 1.65));
const sunLight = new THREE.DirectionalLight(0xffe0a0, 3.1);
sunLight.position.set(8, 13, 7);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -14;
sunLight.shadow.camera.right = 14;
sunLight.shadow.camera.top = 13;
sunLight.shadow.camera.bottom = -10;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 35;
sunLight.shadow.bias = -0.0006;
scene.add(sunLight);
const shadeLight = new THREE.PointLight(0x83c4d5, 10, 13, 2);
shadeLight.position.set(-7, 3.8, 2);
scene.add(shadeLight);
const sunnyLight = new THREE.PointLight(0xffc964, 22, 15, 2);
sunnyLight.position.set(5.5, 5.2, 2.5);
scene.add(sunnyLight);
// Ground and diorama base.
const groundMat = material(0x6d8882);
const ground = new THREE.Mesh(new THREE.PlaneGeometry(70, 70), groundMat);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.82;
ground.receiveShadow = true;
scene.add(ground);
const baseMat = material(0x203c43);
const base = box(16.4, 0.58, 10.15, baseMat, -1.45, -0.42, 0);
base.castShadow = true;
const baseEdgeMat = material(0x102b31);
box(16.7, 0.16, 10.4, baseEdgeMat, -1.45, -0.75, 0);
// Floor tiles visually encode the light gradient.
const shadeColor = new THREE.Color(0x294650);
const middleColor = new THREE.Color(0x718b61);
const sunColor = new THREE.Color(0xd0b05b);
const tileMaterials = [];
const columns = 24;
for (let i = 0; i < columns; i++) {
const t = i / (columns - 1);
const color = new THREE.Color();
if (t < 0.5) {
color.copy(shadeColor).lerp(middleColor, t * 2);
} else {
color.copy(middleColor).lerp(sunColor, (t - 0.5) * 2);
}
tileMaterials.push(
material(color, {
roughness: 0.98,
emissive: color.clone().multiplyScalar(0.035)
})
);
}
const tileW = 0.64;
const tileD = 0.68;
const pitchX = 0.67;
const pitchZ = 0.72;
const totalW = columns * pitchX;
const startX = -1.45 - totalW / 2 + tileW / 2;
for (let col = 0; col < columns; col++) {
for (let row = 0; row < 13; row++) {
const tile = box(
tileW,
0.12,
tileD,
tileMaterials[col],
startX + col * pitchX,
-0.07,
-4.32 + tileD / 2 + row * pitchZ
);
tile.castShadow = false;
tile.receiveShadow = true;
}
}
// Pergola: densely spaced rafters create stronger shade on the left.
const wood = material(0x674939);
const woodLight = material(0x876248);
const woodDark = material(0x49362d);
const postXs = [-8.35, 5.45];
const postZs = [-4.15, 4.15];
for (const x of postXs) {
for (const z of postZs) {
box(0.34, 5.35, 0.34, woodDark, x, 2.62, z);
box(0.48, 0.18, 0.48, wood, x, 0.02, z);
}
}
for (const z of postZs) {
box(14.2, 0.38, 0.42, wood, -1.45, 5.18, z);
}
const leftRafters = [-8.0, -7.15, -6.3, -5.45, -4.6, -3.75, -2.9, -2.05, -1.2];
const rightRafters = [0.25, 1.85, 3.45, 5.05];
for (const x of [...leftRafters, ...rightRafters]) {
box(0.19, 0.24, 8.75, woodLight, x, 5.47, 0);
}
// Two upper longitudinal braces stabilize the voxel structure.
box(14.0, 0.20, 0.20, wood, -1.45, 5.69, -2.65);
box(14.0, 0.20, 0.20, wood, -1.45, 5.69, 2.65);
const plantXs = [-6.75, -4.70, -2.65, -0.60, 1.45, 3.50, 5.55];
const soilMat = material(0x4b3a2e);
const markerMats = [
material(0xf5c45c),
material(0xf2876d),
material(0x85d0aa)
];
function createPlant(x, lightLevel, index) {
const t = THREE.MathUtils.clamp(lightLevel, 0, 1);
const plant = new THREE.Group();
plant.position.set(x, 0.12, 0);
scene.add(plant);
const soil = box(1.28, 0.16, 1.18, soilMat, x, 0.08, 0);
soil.castShadow = false;
// Identical colored genotype markers at every plant.
box(0.62, 0.07, 0.20, material(0x15333a), x, 0.19, 0.78);
for (let m = 0; m < 3; m++) {
box(
0.075,
0.075,
0.075,
markerMats[m],
x - 0.15 + m * 0.15,
0.255,
0.80
);
}
const leafBase = new THREE.Color(0x2d754a).lerp(
new THREE.Color(0x9eb052),
t * 0.58
);
const leafMats = [
material(leafBase.clone().multiplyScalar(0.72)),
material(leafBase.clone()),
material(leafBase.clone().lerp(new THREE.Color(0xd6d471), 0.28))
];
const stemMat = material(
new THREE.Color(0x446d3d).lerp(new THREE.Color(0x718246), t * 0.4)
);
const height = 2.15 + t * 0.95;
const stemWidth = 0.16 + t * 0.08;
const segments = Math.ceil(height / 0.19);
const segmentHeight = height / segments;
for (let i = 0; i < segments; i++) {
box(
stemWidth,
segmentHeight * 0.92,
stemWidth,
stemMat,
0,
(i + 0.5) * segmentHeight,
0,
plant
);
}
// Low-light plants make wider leaves; high-light plants make
// smaller, thicker leaves and allocate more height to the stem.
const leafWidth = 0.43 + 0.72 * (1 - t);
const leafDepth = 0.34 + 0.52 * (1 - t);
const leafThickness = 0.10 + 0.09 * t;
const levels = [0.28, 0.43, 0.58, 0.73, 0.87];
levels.forEach((fraction, level) => {
const y = height * fraction;
const reach = 0.43 + leafWidth * 0.34;
for (const side of [-1, 1]) {
box(
0.49,
0.075,
0.075,
stemMat,
side * 0.28,
y,
0,
plant
);
box(
leafWidth,
leafThickness,
leafDepth,
leafMats[(level + (side > 0 ? 1 : 0)) % 3],
side * reach,
y + 0.03,
0,
plant
);
}
if (level > 1) {
for (const side of [-1, 1]) {
box(
leafDepth,
leafThickness,
leafWidth * 0.72,
leafMats[(level + 1) % 3],
0,
y + 0.08,
side * (0.30 + leafDepth * 0.34),
plant
);
}
}
});
// A small terminal bud.
box(
leafWidth * 0.42,
0.18,
leafWidth * 0.42,
leafMats[2],
0,
height + 0.05,
0,
plant
);
plant.userData.phase = index * 0.83;
plant.userData.light = t;
plants.push(plant);
}
plantXs.forEach((x, index) => {
const lightLevel = index / (plantXs.length - 1);
createPlant(x, lightLevel, index);
});
// Front light meter and arrow.
const meterMat = material(0xf4e0a4, {
emissive: 0x70521d,
emissiveIntensity: 0.35
});
for (let i = 0; i < 23; i++) {
const t = i / 22;
const x = -6.8 + t * 12.4;
box(
0.15,
0.055,
0.15,
i % 3 === 0 ? meterMat : material(0xd9c57b),
x,
0.055,
4.72
);
}
box(0.44, 0.07, 0.44, meterMat, 6.02, 0.055, 4.72);
box(0.30, 0.07, 0.30, meterMat, 5.82, 0.055, 4.98);
box(0.30, 0.07, 0.30, meterMat, 5.82, 0.055, 4.46);
// Voxel sun above the bright end.
const sunGroup = new THREE.Group();
sunGroup.position.set(6.35, 6.2, -2.55);
scene.add(sunGroup);
const sunMat = material(0xffd867, {
emissive: 0xffb52f,
emissiveIntensity: 1.2
});
box(0.78, 0.78, 0.30, sunMat, 0, 0, 0, sunGroup);
box(0.30, 0.78, 0.30, sunMat, -0.24, 0, 0, sunGroup);
box(0.30, 0.78, 0.30, sunMat, 0.24, 0, 0, sunGroup);
const rayOffsets = [
[-0.76, 0], [0.76, 0], [0, -0.76], [0, 0.76],
[-0.58, -0.58], [0.58, -0.58], [-0.58, 0.58], [0.58, 0.58]
];
for (const [x, y] of rayOffsets) {
box(0.22, 0.22, 0.22, sunMat, x, y, 0, sunGroup);
}
// Floating voxel light particles near the sunny side.
const moteMat = new THREE.MeshBasicMaterial({
color: 0xffe28a,
transparent: true,
opacity: 0.65
});
for (let i = 0; i < 22; i++) {
const mote = box(
0.055,
0.055,
0.055,
moteMat,
1.5 + (i * 1.73) % 5.5,
0.7 + (i * 0.91) % 4.2,
-3.4 + (i * 1.17) % 6.8
);
mote.castShadow = false;
lightMotes.push({
mesh: mote,
baseY: mote.position.y,
phase: i * 0.73
});
}
// World-space labels.
const lowLabel = makeLabel("LOW LIGHT", "#b9d9df", 2.25);
lowLabel.position.set(-6.55, 0.50, 5.35);
scene.add(lowLabel);
const highLabel = makeLabel("HIGH LIGHT", "#ffd56b", 2.45);
highLabel.position.set(4.65, 0.50, 5.35);
scene.add(highLabel);
const genotypeLabel = makeLabel("SAME SOURCE • SAME DNA", "#f5f0dc", 4.25);
genotypeLabel.position.set(-0.85, 0.58, 5.50);
scene.add(genotypeLabel);
// A few simple voxel stones make the base feel like a constructed habitat.
const stoneMat = material(0x71857b);
const stonePositions = [
[-8.7, 3.0, 0.35, 0.24],
[6.8, -2.9, 0.48, 0.30],
[-7.4, -3.4, 0.28, 0.18],
[6.4, 3.2, 0.34, 0.22]
];
for (const [x, z, w, h] of stonePositions) {
box(w, h, w * 0.8, stoneMat, x, 0.08 + h / 2, z);
}
// Custom camera controls — no OrbitControls or other addons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.focus();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desired.yaw -= dx * 0.006;
desired.pitch = THREE.MathUtils.clamp(
desired.pitch + dy * 0.0045,
0.18,
1.02
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && 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.012,
11,
29
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") desired.yaw += step;
if (event.key === "ArrowRight") desired.yaw -= step;
if (event.key === "ArrowUp") desired.pitch -= step;
if (event.key === "ArrowDown") desired.pitch += step;
if (event.key.toLowerCase() === "r") resetView();
});
function resetView() {
desired.yaw = 0.34;
desired.pitch = 0.48;
desired.radius = window.innerWidth < 700 ? 23 : 20.5;
desired.target.set(window.innerWidth < 700 ? -0.2 : -0.4, 2.35, 0);
}
resetButton.addEventListener("click", resetView);
toggleInfo.addEventListener("click", () => {
const collapsed = infoPanel.classList.toggle("collapsed");
toggleInfo.textContent = collapsed ? "Show info" : "Hide info";
toggleInfo.setAttribute("aria-expanded", String(!collapsed));
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.fov = width < 700 ? 49 : 40;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function animate() {
const elapsed = clock.getElapsedTime();
current.yaw += (desired.yaw - current.yaw) * 0.075;
current.pitch += (desired.pitch - current.pitch) * 0.075;
current.radius += (desired.radius - current.radius) * 0.075;
current.target.lerp(desired.target, 0.075);
const horizontal = Math.cos(current.pitch) * current.radius;
camera.position.set(
current.target.x + Math.sin(current.yaw) * horizontal,
current.target.y + Math.sin(current.pitch) * current.radius,
current.target.z + Math.cos(current.yaw) * horizontal
);
camera.lookAt(current.target);
if (!reducedMotion) {
for (const plant of plants) {
const amplitude = 0.008 + plant.userData.light * 0.009;
plant.rotation.z = Math.sin(elapsed * 0.9 + plant.userData.phase) * amplitude;
plant.rotation.x = Math.cos(elapsed * 0.68 + plant.userData.phase) * amplitude * 0.55;
}
sunGroup.position.y = 6.2 + Math.sin(elapsed * 0.75) * 0.08;
sunGroup.rotation.z = Math.sin(elapsed * 0.35) * 0.035;
for (const mote of lightMotes) {
mote.mesh.position.y =
mote.baseY + Math.sin(elapsed * 0.9 + mote.phase) * 0.16;
}
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```