Prompt specification
Build or customize the Three.js 3D scene "Matched seedlings under contrasting light" 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: Matched seedlings under contrasting light
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/matched-seedlings-under-contrasting-light-x0941
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring phenotypic plasticity. Place two genetically identical fictional seedlings beneath different light conditions; display schematic differences in form and explicitly separate environmental response from genetic change. Low-poly.
Working Three.js Starter (matched-seedlings-under-contrasting-light-x0941):
```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 — Same Genes, Different Forms</title>
<style>
:root {
--ink: #18362d;
--muted: #64776d;
--paper: #f7f8f2;
--line: #dce4da;
--green: #2f6c4e;
--green-dark: #214c3a;
--sun: #e9ad38;
--sun-soft: #fff1c8;
--shade: #397f91;
--shade-soft: #dff2f5;
--panel: #fbfcf7;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
.topbar {
height: 74px;
padding: 0 22px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
border-bottom: 1px solid var(--line);
background: rgba(251, 252, 247, 0.96);
position: relative;
z-index: 20;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.brand-mark {
width: 42px;
height: 42px;
flex: 0 0 auto;
border-radius: 13px;
background: var(--green-dark);
position: relative;
box-shadow: 0 6px 18px rgba(33, 76, 58, 0.18);
}
.brand-mark::before {
content: "";
position: absolute;
width: 14px;
height: 20px;
left: 13px;
top: 8px;
border-radius: 14px 2px 14px 2px;
background: #a8d47d;
transform: rotate(-16deg);
}
.brand-mark::after {
content: "";
position: absolute;
width: 2px;
height: 19px;
left: 20px;
top: 19px;
border-radius: 2px;
background: #eff8dc;
transform: rotate(23deg);
transform-origin: top;
}
.brand-copy {
display: grid;
gap: 1px;
min-width: 0;
}
.brand-copy strong {
font-size: 14px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.brand-copy span {
color: var(--muted);
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.experiment-id {
display: flex;
align-items: center;
gap: 9px;
padding: 8px 12px;
border: 1px solid #d9e4d8;
border-radius: 999px;
background: #f1f6ed;
color: var(--green-dark);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.experiment-id i {
width: 7px;
height: 7px;
border-radius: 50%;
background: #6aa561;
box-shadow: 0 0 0 4px rgba(106, 165, 97, 0.13);
}
.top-actions {
display: flex;
gap: 8px;
}
.tool-button {
border: 1px solid #d7e0d6;
background: #fff;
color: var(--ink);
border-radius: 10px;
padding: 9px 12px;
cursor: pointer;
font-size: 12px;
font-weight: 700;
transition:
transform 120ms ease,
border-color 120ms ease,
background 120ms ease;
}
.tool-button:hover {
transform: translateY(-1px);
border-color: #9fb6a6;
background: #f8fbf5;
}
.tool-button:focus-visible,
canvas:focus-visible {
outline: 3px solid rgba(47, 108, 78, 0.28);
outline-offset: 2px;
}
.layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 380px;
height: calc(100vh - 74px);
min-height: 0;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 27% 20%, rgba(255, 232, 159, 0.27), transparent 27%),
radial-gradient(circle at 76% 18%, rgba(161, 214, 223, 0.27), transparent 31%),
linear-gradient(180deg, #f0f4eb 0%, #e6ede1 100%);
}
#scene {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene.dragging {
cursor: grabbing;
}
.scene-heading {
position: absolute;
top: 22px;
left: 24px;
pointer-events: none;
z-index: 4;
}
.scene-heading span {
display: block;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
margin-bottom: 5px;
}
.scene-heading strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(19px, 2vw, 29px);
font-weight: 500;
letter-spacing: -0.02em;
}
.control-lock {
position: absolute;
top: 22px;
left: 50%;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border: 1px solid rgba(47, 108, 78, 0.2);
border-radius: 999px;
background: rgba(250, 252, 246, 0.86);
backdrop-filter: blur(8px);
color: var(--green-dark);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
z-index: 4;
}
.control-lock b {
display: grid;
place-items: center;
width: 18px;
height: 18px;
border-radius: 50%;
color: #fff;
background: var(--green);
font-size: 10px;
}
.stage-hint {
position: absolute;
right: 20px;
bottom: 18px;
color: #6f8076;
background: rgba(249, 251, 246, 0.76);
border: 1px solid rgba(207, 218, 205, 0.85);
border-radius: 9px;
padding: 7px 10px;
font-size: 10px;
pointer-events: none;
z-index: 4;
}
.scene-legend {
position: absolute;
left: 22px;
bottom: 18px;
display: flex;
flex-wrap: wrap;
gap: 8px;
z-index: 4;
pointer-events: none;
}
.scene-legend span {
padding: 6px 9px;
border-radius: 999px;
background: rgba(249, 251, 246, 0.8);
border: 1px solid rgba(207, 218, 205, 0.9);
color: #65786c;
font-size: 10px;
font-weight: 700;
}
.scene-legend .sun-dot {
color: #9b6811;
}
.scene-legend .sun-dot::before {
content: "";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 6px;
border-radius: 50%;
background: var(--sun);
}
.scene-legend .shade-dot {
color: #2e7182;
}
.scene-legend .shade-dot::before {
content: "";
display: inline-block;
width: 7px;
height: 7px;
margin-right: 6px;
border-radius: 50%;
background: var(--shade);
}
.scene-label,
.genotype-tag,
.equal-sign {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
z-index: 5;
will-change: transform;
}
.scene-label {
min-width: 142px;
padding: 10px 12px;
border-radius: 12px;
background: rgba(255, 255, 252, 0.92);
box-shadow: 0 10px 28px rgba(34, 54, 42, 0.11);
border-top: 3px solid var(--sun);
}
.scene-label.low {
border-top-color: var(--shade);
}
.scene-label span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
margin-bottom: 3px;
}
.scene-label strong {
display: block;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
font-weight: 500;
}
.scene-label small {
display: block;
margin-top: 3px;
color: #738178;
font-size: 10px;
}
.genotype-tag {
padding: 5px 9px;
border-radius: 8px;
border: 1px solid rgba(47, 108, 78, 0.32);
background: rgba(239, 247, 235, 0.95);
color: var(--green-dark);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.08em;
box-shadow: 0 5px 14px rgba(37, 68, 49, 0.1);
}
.equal-sign {
width: 27px;
height: 27px;
display: grid;
place-items: center;
border-radius: 50%;
border: 1px solid rgba(47, 108, 78, 0.32);
background: rgba(247, 251, 243, 0.96);
color: var(--green-dark);
font-weight: 850;
box-shadow: 0 5px 14px rgba(37, 68, 49, 0.1);
}
.panel {
min-width: 0;
overflow-y: auto;
padding: 28px 26px 24px;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(247, 249, 242, 0.96)),
var(--panel);
scrollbar-width: thin;
scrollbar-color: #bdcbbd transparent;
}
.eyebrow {
color: var(--green);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel h1 {
margin: 9px 0 11px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 3vw, 39px);
line-height: 1.03;
letter-spacing: -0.035em;
font-weight: 500;
}
.panel h1 em {
color: var(--green);
font-weight: 500;
}
.intro {
margin: 0;
color: #63766a;
font-size: 13px;
line-height: 1.62;
}
.causal-chain {
margin-top: 21px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 15px;
background: rgba(255, 255, 255, 0.72);
}
.chain-node {
padding: 10px 11px;
border-radius: 10px;
}
.chain-node.fixed {
border: 1px solid #c8ddca;
background: #edf6e9;
}
.chain-node.variable {
border: 1px solid #d9e2e5;
background: #eff4f4;
}
.node-label {
display: block;
color: #718178;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.chain-node strong {
display: block;
margin-top: 4px;
font-family: Georgia, "Times New Roman", serif;
font-size: 22px;
font-weight: 500;
}
.chain-node small {
display: block;
margin-top: 2px;
color: #6e7e74;
font-size: 10px;
}
.chain-arrow,
.down-arrow {
color: #8da094;
text-align: center;
font-size: 16px;
line-height: 1.4;
}
.chain-arrow {
padding: 5px 0;
}
.env-split {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 8px;
}
.env-split span {
padding: 7px 4px;
border-radius: 7px;
text-align: center;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.env-split span:first-child {
color: #8e6419;
background: var(--sun-soft);
}
.env-split span:last-child {
color: #2e7182;
background: var(--shade-soft);
}
.outcome {
display: grid;
grid-template-columns: 1fr auto 1fr;
gap: 7px;
align-items: center;
}
.outcome > div:not(.vs) {
padding: 9px 8px;
border-radius: 9px;
background: #f0f3ec;
text-align: center;
}
.outcome b {
display: block;
font-size: 12px;
}
.outcome small {
display: block;
margin-top: 3px;
color: #77857c;
font-size: 9px;
line-height: 1.3;
}
.outcome .vs {
color: #8c9990;
font-family: Georgia, serif;
font-style: italic;
font-size: 12px;
}
.definition {
margin-top: 16px;
padding: 14px 15px;
border-left: 3px solid var(--green);
border-radius: 0 12px 12px 0;
background: #eaf3e5;
}
.definition strong {
display: block;
color: var(--green-dark);
font-size: 13px;
}
.definition p {
margin: 5px 0 0;
color: #5d7265;
font-size: 11px;
line-height: 1.5;
}
.section-title {
display: flex;
align-items: center;
gap: 8px;
margin: 22px 0 10px;
color: #728178;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.section-title::after {
content: "";
height: 1px;
flex: 1;
background: var(--line);
}
.trait-list {
display: grid;
gap: 8px;
}
.trait-card {
display: grid;
grid-template-columns: 32px 1fr;
gap: 10px;
align-items: start;
padding: 11px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.7);
}
.trait-icon {
width: 32px;
height: 32px;
display: grid;
place-items: center;
border-radius: 9px;
font-size: 17px;
}
.trait-card.sun .trait-icon {
color: #9b6811;
background: var(--sun-soft);
}
.trait-card.shade .trait-icon {
color: #2e7182;
background: var(--shade-soft);
}
.trait-card strong {
display: block;
margin-bottom: 3px;
font-size: 12px;
}
.trait-card p {
margin: 0;
color: #687a70;
font-size: 10px;
line-height: 1.45;
}
.boundary {
display: grid;
grid-template-columns: 36px 1fr;
gap: 11px;
margin-top: 17px;
padding: 13px;
border: 1px solid #ead9c7;
border-radius: 12px;
background: #fff7eb;
}
.boundary-icon {
width: 36px;
height: 36px;
display: grid;
place-items: center;
border-radius: 50%;
background: #f1dfc6;
color: #8c6334;
font-family: Georgia, serif;
font-size: 21px;
font-weight: 700;
}
.boundary strong {
display: block;
color: #674a2d;
font-size: 12px;
}
.boundary p {
margin: 4px 0 0;
color: #806b52;
font-size: 10px;
line-height: 1.5;
}
.footnote {
margin: 16px 2px 0;
color: #8a978f;
font-size: 9px;
line-height: 1.5;
}
@media (max-width: 1050px) {
body {
overflow: auto;
}
.layout {
grid-template-columns: 1fr;
height: auto;
}
.stage {
height: 66vh;
min-height: 540px;
}
.panel {
overflow: visible;
border-left: 0;
border-top: 1px solid var(--line);
padding: 28px max(24px, calc((100vw - 700px) / 2));
}
.experiment-id {
display: none;
}
}
@media (max-width: 650px) {
.topbar {
height: 66px;
padding: 0 13px;
}
.brand-copy span,
#labelsButton {
display: none;
}
.brand-copy strong {
font-size: 11px;
}
.brand-mark {
width: 37px;
height: 37px;
}
.stage {
height: 64vh;
min-height: 490px;
}
.scene-heading {
top: 17px;
left: 16px;
}
.scene-heading strong {
font-size: 19px;
}
.control-lock {
top: 72px;
left: 16px;
transform: none;
font-size: 8px;
}
.scene-label {
min-width: 115px;
padding: 8px 9px;
}
.scene-label strong {
font-size: 14px;
}
.scene-label small {
font-size: 8px;
}
.stage-hint {
display: none;
}
.scene-legend {
left: 14px;
bottom: 13px;
}
.scene-legend span {
font-size: 8px;
}
.panel {
padding: 25px 18px;
}
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<strong>Phenotype Lab</strong>
<span>Environmental response / interactive field study</span>
</div>
</div>
<div class="experiment-id">
<i></i>
Experiment 01 · controlled identity
</div>
<div class="top-actions">
<button class="tool-button" id="labelsButton" type="button" aria-pressed="true">
Labels on
</button>
<button class="tool-button" id="resetButton" type="button">
Reset view
</button>
</div>
</header>
<main class="layout">
<section class="stage" id="stage" aria-label="Interactive three-dimensional seedling comparison">
<canvas
id="scene"
tabindex="0"
aria-label="Two genetically identical seedlings under high and low light. Drag to orbit and scroll to zoom."
></canvas>
<div class="scene-heading">
<span>Interactive scene 01</span>
<strong>Light-dependent development</strong>
</div>
<div class="control-lock">
<b>=</b>
Same age · same genotype · light varies
</div>
<div class="scene-label high" id="highLabel">
<span>Environment A</span>
<strong>High light</strong>
<small>compact growth form</small>
</div>
<div class="scene-label low" id="lowLabel">
<span>Environment B</span>
<strong>Low light</strong>
<small>elongated growth form</small>
</div>
<div class="genotype-tag" id="leftGenotype">G•01</div>
<div class="genotype-tag" id="rightGenotype">G•01</div>
<div class="equal-sign" id="equalSign">=</div>
<div class="scene-legend">
<span class="sun-dot">High irradiance</span>
<span class="shade-dot">Filtered light</span>
<span>Genotype fixed</span>
</div>
<div class="stage-hint">Drag to orbit · Scroll to zoom · Arrow keys supported</div>
</section>
<aside class="panel">
<div class="eyebrow">Phenotypic plasticity</div>
<h1>Same genotype.<br /><em>Different phenotype.</em></h1>
<p class="intro">
Two genetically identical seedlings develop different forms under
different light conditions. The visible difference comes from the
environment changing development—not from the seedlings acquiring
different genes.
</p>
<div class="causal-chain" aria-label="Causal chain comparing genotype, environment, and phenotype">
<div class="chain-node fixed">
<span class="node-label">Genotype · fixed</span>
<strong>G•01 = G•01</strong>
<small>Same starting genetic identity</small>
</div>
<div class="chain-arrow">↓</div>
<div class="chain-node variable">
<span class="node-label">Environment · varies</span>
<div class="env-split">
<span>High light</span>
<span>Low light</span>
</div>
<small>Light is the response variable</small>
</div>
<div class="chain-arrow">↓</div>
<div class="outcome">
<div>
<b>Compact form</b>
<small>shorter · thicker · smaller leaves</small>
</div>
<div class="vs">vs</div>
<div>
<b>Elongated form</b>
<small>taller · thinner · larger leaves</small>
</div>
</div>
</div>
<div class="definition">
<strong>Phenotypic plasticity</strong>
<p>
One genotype produces different phenotypes when placed in different
environments.
</p>
</div>
<div class="section-title">Schematic differences</div>
<div class="trait-list">
<article class="trait-card sun">
<div class="trait-icon" aria-hidden="true">☀</div>
<div>
<strong>High-light seedling</strong>
<p>
Shorter main axis, thicker stem, and smaller, more angled leaves.
A compact form under stronger irradiance.
</p>
</div>
</article>
<article class="trait-card shade">
<div class="trait-icon" aria-hidden="true">◐</div>
<div>
<strong>Low-light seedling</strong>
<p>
Taller main axis, thinner stem, and larger, more horizontal
leaves. An elongated form under filtered light.
</p>
</div>
</article>
</div>
<div class="boundary">
<div class="boundary-icon" aria-hidden="true">≠</div>
<div>
<strong>Not a depicted genetic change</strong>
<p>
No mutation, recombination, or genetic divergence is shown. The
seedlings retain the same genotype; only their developmental
response changes.
</p>
</div>
</div>
<p class="footnote">
Teaching schematic, not a quantitative growth model. Trait differences
are deliberately exaggerated, and real seedlings may also respond to
water, nutrients, temperature, and neighboring plants.
</p>
</aside>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const stage = document.querySelector("#stage");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xe8eee2, 15, 30);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 80);
// -------------------------------------------------------------------------
// Palette and materials
// -------------------------------------------------------------------------
const palette = {
ground: 0xdce5d7,
platform: 0xc6b797,
platformTop: 0xd7c9a8,
soil: 0x665044,
stem: 0x466d39,
leaf: 0x4f9149,
leafDark: 0x3e7d42,
pebble: 0x8c7562,
wood: 0x8f765b,
sun: 0xf1bd48,
sunGlow: 0xffd96b,
shade: 0x4b91a1
};
const makeMaterial = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...options
});
const materials = {
ground: makeMaterial(palette.ground),
platform: makeMaterial(palette.platform),
platformTop: makeMaterial(palette.platformTop),
soil: makeMaterial(palette.soil),
stem: makeMaterial(palette.stem),
leaf: makeMaterial(palette.leaf, { side: THREE.DoubleSide }),
leafDark: makeMaterial(palette.leafDark, { side: THREE.DoubleSide }),
pebble: makeMaterial(palette.pebble),
wood: makeMaterial(palette.wood),
sun: new THREE.MeshBasicMaterial({ color: palette.sun }),
sunGlow: new THREE.MeshBasicMaterial({
color: palette.sunGlow,
transparent: true,
opacity: 0.55
}),
shadeCloth: new THREE.MeshBasicMaterial({
color: palette.shade,
transparent: true,
opacity: 0.18,
side: THREE.DoubleSide,
depthWrite: false
})
};
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf7fff0, 0x788777, 1.45);
scene.add(hemisphere);
const sunlight = new THREE.DirectionalLight(0xffedbd, 2.7);
sunlight.position.set(-3.5, 8, 5);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -8;
sunlight.shadow.camera.right = 8;
sunlight.shadow.camera.top = 8;
sunlight.shadow.camera.bottom = -6;
sunlight.shadow.camera.near = 0.5;
sunlight.shadow.camera.far = 24;
sunlight.shadow.bias = -0.0004;
scene.add(sunlight);
const fill = new THREE.DirectionalLight(0xb9e4ed, 0.75);
fill.position.set(6, 5, 2);
scene.add(fill);
const warmSpot = new THREE.SpotLight(
0xffd067,
48,
15,
Math.PI / 5,
0.45,
1.25
);
warmSpot.position.set(-3.2, 7, 2.5);
warmSpot.target.position.set(-3, 0.5, 0);
scene.add(warmSpot, warmSpot.target);
const coolLight = new THREE.PointLight(0x8fd5df, 7, 8, 2);
coolLight.position.set(3, 5.2, 0.5);
scene.add(coolLight);
// -------------------------------------------------------------------------
// Ground and experimental platforms
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
materials.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.23;
ground.receiveShadow = true;
scene.add(ground);
const platforms = [];
function createPlatform(x, ringColor) {
const group = new THREE.Group();
group.position.x = x;
const base = new THREE.Mesh(
new THREE.CylinderGeometry(2.18, 2.3, 0.42, 12, 1),
materials.platform
);
base.position.y = 0;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const top = new THREE.Mesh(
new THREE.CylinderGeometry(2.08, 2.13, 0.12, 12, 1),
materials.platformTop
);
top.position.y = 0.25;
top.castShadow = true;
top.receiveShadow = true;
group.add(top);
const soil = new THREE.Mesh(
new THREE.CylinderGeometry(1.38, 1.44, 0.09, 12, 1),
materials.soil
);
soil.position.y = 0.35;
soil.castShadow = true;
soil.receiveShadow = true;
group.add(soil);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(2.2, 0.025, 4, 28),
new THREE.MeshBasicMaterial({ color: ringColor })
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.34;
group.add(ring);
scene.add(group);
platforms.push(group);
return group;
}
const highPlatform = createPlatform(-3, palette.sun);
const lowPlatform = createPlatform(3, palette.shade);
// Deterministic low-poly pebbles.
let randomSeed = 2718;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const pebbleGeometry = new THREE.IcosahedronGeometry(0.09, 0);
for (const platform of platforms) {
for (let i = 0; i < 21; i++) {
const angle = random() * Math.PI * 2;
const radius = 0.75 + random() * 0.7;
const pebble = new THREE.Mesh(pebbleGeometry, materials.pebble);
pebble.position.set(
Math.cos(angle) * radius,
0.42 + random() * 0.035,
Math.sin(angle) * radius
);
const scale = 0.55 + random() * 1.05;
pebble.scale.set(
scale * (0.8 + random() * 0.4),
scale * (0.45 + random() * 0.3),
scale * (0.75 + random() * 0.4)
);
pebble.rotation.set(random() * 2, random() * 2, random() * 2);
pebble.castShadow = true;
platform.add(pebble);
}
}
// -------------------------------------------------------------------------
// Low-poly plant construction
// -------------------------------------------------------------------------
function createLeafGeometry(length, width) {
const positions = new Float32Array([
0, 0, 0, // base
-width * 0.50, length * 0.25, 0, // left near
-width * 0.34, length * 0.68, 0, // left far
0, length, 0, // tip
width * 0.34, length * 0.68, 0, // right far
width * 0.50, length * 0.25, 0, // right near
0, length * 0.42, width * 0.12 // raised central ridge
]);
const indices = [
0, 1, 6,
1, 2, 6,
2, 3, 6,
3, 4, 6,
4, 5, 6,
5, 0, 6
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const up = new THREE.Vector3(0, 1, 0);
function createStemSegment(a, b, bottomRadius, topRadius, material) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
topRadius,
bottomRadius,
length,
6,
1,
false
);
const stem = new THREE.Mesh(geometry, material);
stem.position.copy(a).add(b).multiplyScalar(0.5);
stem.quaternion.setFromUnitVectors(up, direction.normalize());
stem.castShadow = true;
stem.receiveShadow = true;
return stem;
}
function createSeedling({
points,
radii,
leafLengths,
leafWidths,
leafPitch,
leafMaterial
}) {
const plant = new THREE.Group();
for (let i = 0; i < points.length - 1; i++) {
plant.add(
createStemSegment(
points[i],
points[i + 1],
radii[i],
radii[i + 1],
materials.stem
)
);
}
for (let i = 1; i < points.length - 1; i++) {
const node = points[i];
const length = leafLengths[i - 1];
const width = leafWidths[i - 1];
const geometry = createLeafGeometry(length, width);
const baseAngle = 0.18 + (i - 1) * 0.31;
for (const side of [0, 1]) {
const leaf = new THREE.Mesh(geometry, leafMaterial);
leaf.position.copy(node);
leaf.rotation.order = "YXZ";
leaf.rotation.y =
side === 0 ? baseAngle : Math.PI - baseAngle + 0.08;
leaf.rotation.x = -leafPitch - (side === 0 ? 0 : 0.04);
leaf.castShadow = true;
leaf.receiveShadow = true;
plant.add(leaf);
}
}
const bud = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.12, 0),
leafMaterial
);
bud.position.copy(points[points.length - 1]);
bud.scale.set(0.72, 1.25, 0.72);
bud.castShadow = true;
plant.add(bud);
return plant;
}
const highPlant = createSeedling({
points: [
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0.025, 0.76, 0),
new THREE.Vector3(0.07, 1.50, 0.015),
new THREE.Vector3(0.10, 2.18, 0),
new THREE.Vector3(0.045, 2.72, 0)
],
radii: [0.125, 0.102, 0.081, 0.058, 0.036],
leafLengths: [0.95, 0.86, 0.72],
leafWidths: [0.52, 0.48, 0.41],
leafPitch: 0.40,
leafMaterial: materials.leaf
});
highPlant.position.set(-3, 0.40, 0);
highPlant.rotation.y = -0.08;
scene.add(highPlant);
const lowPlant = createSeedling({
points: [
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(-0.045, 1.03, 0),
new THREE.Vector3(-0.11, 2.05, 0.02),
new THREE.Vector3(-0.15, 3.05, 0),
new THREE.Vector3(-0.10, 3.87, 0)
],
radii: [0.078, 0.062, 0.049, 0.036, 0.024],
leafLengths: [1.42, 1.30, 1.10],
leafWidths: [0.79, 0.72, 0.59],
leafPitch: 0.23,
leafMaterial: materials.leaf
});
lowPlant.position.set(3, 0.40, 0);
lowPlant.rotation.y = 0.05;
scene.add(lowPlant);
// -------------------------------------------------------------------------
// High-light icon and low-light shade canopy
// -------------------------------------------------------------------------
const sunGroup = new THREE.Group();
sunGroup.position.set(-3.35, 5.20, -1.65);
const sunCore = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.38, 1),
materials.sun
);
sunCore.castShadow = true;
sunGroup.add(sunCore);
const sunHalo = new THREE.Mesh(
new THREE.TorusGeometry(0.61, 0.025, 4, 24),
materials.sunGlow
);
sunHalo.rotation.x = 0.18;
sunGroup.add(sunHalo);
const sunRayPoints = [];
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const inner = 0.54;
const outer = 0.76;
sunRayPoints.push(
Math.cos(angle) * inner,
Math.sin(angle) * inner,
0,
Math.cos(angle) * outer,
Math.sin(angle) * outer,
0
);
}
const sunRayGeometry = new THREE.BufferGeometry();
sunRayGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(sunRayPoints, 3)
);
const sunRays = new THREE.LineSegments(
sunRayGeometry,
new THREE.LineBasicMaterial({
color: palette.sun,
transparent: true,
opacity: 0.9
})
);
sunGroup.add(sunRays);
scene.add(sunGroup);
// Fine directional light lines reinforce the high-light treatment.
const beamPoints = [];
const beamOrigins = [
[-3.8, 5.0, -1.5],
[-3.4, 4.8, -1.5],
[-2.9, 5.0, -1.5]
];
const beamTargets = [
[-4.0, 0.4, -0.3],
[-3.0, 0.4, -0.1],
[-2.2, 0.4, -0.2]
];
beamOrigins.forEach((origin, index) => {
beamPoints.push(...origin, ...beamTargets[index]);
});
const beamGeometry = new THREE.BufferGeometry();
beamGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(beamPoints, 3)
);
const beams = new THREE.LineSegments(
beamGeometry,
new THREE.LineBasicMaterial({
color: palette.sun,
transparent: true,
opacity: 0.26
})
);
scene.add(beams);
const canopyGroup = new THREE.Group();
canopyGroup.position.set(3, 0, 0);
const canopy = new THREE.Mesh(
new THREE.PlaneGeometry(3.5, 2.6),
materials.shadeCloth
);
canopy.rotation.x = -Math.PI / 2;
canopy.position.y = 5.35;
canopyGroup.add(canopy);
const gridPositions = [];
for (let x = -1.55; x <= 1.56; x += 0.39) {
gridPositions.push(x, 5.37, -1.12, x, 5.37, 1.12);
}
for (let z = -1.05; z <= 1.06; z += 0.42) {
gridPositions.push(-1.58, 5.37, z, 1.58, 5.37, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
const grid = new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: palette.shade,
transparent: true,
opacity: 0.48
})
);
canopyGroup.add(grid);
for (const x of [-1.58, 1.58]) {
for (const z of [-1.12, 1.12]) {
const post = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.045, 5.0, 6),
materials.wood
);
post.position.set(x, 2.82, z);
post.castShadow = true;
canopyGroup.add(post);
}
}
scene.add(canopyGroup);
const filteredBeamPoints = [];
for (let i = 0; i < 4; i++) {
const x = 2.15 + i * 0.57;
filteredBeamPoints.push(x, 5.32, 0, x, 0.42, 0);
}
const filteredBeamGeometry = new THREE.BufferGeometry();
filteredBeamGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(filteredBeamPoints, 3)
);
const filteredBeams = new THREE.LineSegments(
filteredBeamGeometry,
new THREE.LineBasicMaterial({
color: palette.shade,
transparent: true,
opacity: 0.18
})
);
scene.add(filteredBeams);
// A dashed visual link emphasizes that the genotype remains identical.
const identityGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-3, 0.52, 1.58),
new THREE.Vector3(3, 0.52, 1.58)
]);
const identityLine = new THREE.Line(
identityGeometry,
new THREE.LineDashedMaterial({
color: palette.stem,
dashSize: 0.13,
gapSize: 0.10,
transparent: true,
opacity: 0.55
})
);
identityLine.computeLineDistances();
scene.add(identityLine);
// -------------------------------------------------------------------------
// Direct camera controls — no external controls addon
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 2.15, 0),
theta: 0.17,
desiredTheta: 0.17,
phi: 1.22,
desiredPhi: 1.22,
radius: 12.8,
desiredRadius: 12.8
};
function fittedRadius() {
const aspect = stage.clientWidth / Math.max(stage.clientHeight, 1);
return aspect < 1 ? 17.4 : aspect < 1.25 ? 14.2 : 12.8;
}
function resetCamera() {
controls.desiredTheta = 0.17;
controls.desiredPhi = 1.22;
controls.desiredRadius = fittedRadius();
}
function updateCamera() {
const smoothing = 0.12;
controls.theta +=
(controls.desiredTheta - controls.theta) * smoothing;
controls.phi +=
(controls.desiredPhi - controls.phi) * smoothing;
controls.radius +=
(controls.desiredRadius - controls.radius) * smoothing;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x +
controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z +
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
const activePointers = new Map();
let previousPinchDistance = 0;
function pointerDistance() {
const points = [...activePointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
previousPinchDistance = pointerDistance();
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
const previous = activePointers.get(event.pointerId);
if (activePointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
controls.desiredTheta -= dx * 0.006;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - dy * 0.005,
0.86,
1.43
);
} else if (activePointers.size === 2) {
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius *
(previousPinchDistance / distance),
8.2,
22
);
}
previousPinchDistance = distance;
return;
}
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
});
function releasePointer(event) {
activePointers.delete(event.pointerId);
previousPinchDistance = pointerDistance();
if (activePointers.size === 0) {
canvas.classList.remove("dragging");
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius * Math.exp(event.deltaY * 0.001),
8.2,
22
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
controls.desiredTheta += 0.12;
break;
case "ArrowRight":
controls.desiredTheta -= 0.12;
break;
case "ArrowUp":
controls.desiredPhi = Math.max(
0.86,
controls.desiredPhi - 0.08
);
break;
case "ArrowDown":
controls.desiredPhi = Math.min(
1.43,
controls.desiredPhi + 0.08
);
break;
case "+":
case "=":
controls.desiredRadius = Math.max(
8.2,
controls.desiredRadius - 0.6
);
break;
case "-":
controls.desiredRadius = Math.min(
22,
controls.desiredRadius + 0.6
);
break;
case "r":
case "R":
resetCamera();
break;
default:
handled = false;
}
if (handled) event.preventDefault();
});
document.querySelector("#resetButton").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Projected HTML labels
// -------------------------------------------------------------------------
const labelElements = [
document.querySelector("#highLabel"),
document.querySelector("#lowLabel"),
document.querySelector("#leftGenotype"),
document.querySelector("#rightGenotype"),
document.querySelector("#equalSign")
];
const labelAnchors = [
new THREE.Vector3(-3.35, 6.05, -1.65),
new THREE.Vector3(3, 6.05, 0),
new THREE.Vector3(-3, 0.64, 1.62),
new THREE.Vector3(3, 0.64, 1.62),
new THREE.Vector3(0, 0.66, 1.62)
];
let labelsVisible = true;
document.querySelector("#labelsButton").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
labelElements.forEach((element) => {
element.style.display = labelsVisible ? "" : "none";
});
event.currentTarget.textContent = labelsVisible ? "Labels on" : "Labels off";
event.currentTarget.setAttribute("aria-pressed", String(labelsVisible));
});
const projected = new THREE.Vector3();
function updateLabels() {
if (!labelsVisible) return;
const width = stage.clientWidth;
const height = stage.clientHeight;
labelElements.forEach((element, index) => {
projected.copy(labelAnchors[index]).project(camera);
let x = (projected.x * 0.5 + 0.5) * width;
let y = (-projected.y * 0.5 + 0.5) * height;
x = THREE.MathUtils.clamp(x, 68, width - 68);
y = THREE.MathUtils.clamp(y, 70, height - 42);
const offset = index < 2 ? "-100%" : "-50%";
element.style.transform =
`translate(${x}px, ${y}px) translate(-50%, ${offset})`;
});
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(height, 1);
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
resetCamera();
controls.radius = controls.desiredRadius;
controls.theta = controls.desiredTheta;
controls.phi = controls.desiredPhi;
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
// Very subtle living movement without changing the schematic comparison.
highPlant.rotation.z = Math.sin(elapsed * 0.55) * 0.004;
lowPlant.rotation.z = Math.sin(elapsed * 0.55 + 1.4) * 0.006;
sunGroup.rotation.z = Math.sin(elapsed * 0.3) * 0.015;
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```