Prompt specification
Build or customize the Three.js 3D scene "Transparent plant water-path exhibit" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Transparent plant water-path exhibit
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/transparent-plant-water-path-exhibit-x0799
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows plant vascular transport. Build a garden exhibit with soil, roots, stem, and leaves shown in partial cutaway; visitors select an organ and trace its connection to the others. Stylized solid forms.
Working Three.js Starter (transparent-plant-water-path-exhibit-x0799):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vascular Garden — Plant Transport Exhibit</title>
<style>
:root {
--ink: #20352d;
--muted: #627068;
--paper: rgba(250, 249, 238, 0.91);
--line: rgba(48, 73, 61, 0.17);
--accent: #c8993c;
--xylem: #28a9ba;
--phloem: #e46d4f;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9eadf;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; }
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 48% 44%, transparent 42%, rgba(54, 68, 55, 0.09) 100%),
linear-gradient(180deg, rgba(255,255,255,0.13), transparent 28%);
}
.exhibit-header {
position: fixed;
top: 27px;
left: 30px;
z-index: 5;
max-width: 470px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #557064;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 27px;
height: 2px;
background: var(--accent);
transition: background 250ms ease;
}
.exhibit-header h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 4.2vw, 62px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
}
.exhibit-header p {
max-width: 390px;
margin: 13px 0 0;
color: #52645c;
font-size: 14px;
line-height: 1.55;
}
#story {
position: fixed;
top: 25px;
right: 25px;
z-index: 6;
width: min(324px, calc(100vw - 34px));
padding: 20px;
border: 1px solid rgba(255,255,255,0.72);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 18px 55px rgba(40, 57, 46, 0.13);
backdrop-filter: blur(14px);
}
#story::before {
content: "";
position: absolute;
top: 20px;
left: 0;
width: 4px;
height: 45px;
border-radius: 0 4px 4px 0;
background: var(--accent);
transition: background 250ms ease;
}
.story-kicker {
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: color 250ms ease;
}
#story h2 {
margin: 7px 0 4px;
font-family: Georgia, "Times New Roman", serif;
font-size: 32px;
font-weight: 500;
letter-spacing: -0.035em;
}
.story-lead {
margin: 0 0 9px;
color: #344d42;
font-size: 13px;
font-weight: 750;
}
#storyBody {
margin: 0;
color: var(--muted);
font-size: 12.5px;
line-height: 1.55;
}
.legend {
display: grid;
gap: 7px;
margin: 16px 0;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255,255,255,0.44);
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.legend-swatch {
width: 18px;
height: 4px;
flex: 0 0 auto;
border-radius: 4px;
}
.legend-swatch.xylem {
background: var(--xylem);
box-shadow: 0 0 9px rgba(40, 169, 186, 0.42);
}
.legend-swatch.phloem {
background: var(--phloem);
box-shadow: 0 0 9px rgba(228, 109, 79, 0.36);
}
.legend b {
display: block;
font-size: 10.5px;
letter-spacing: 0.035em;
}
.legend small {
display: block;
margin-top: 1px;
color: var(--muted);
font-size: 9.5px;
}
.section-label {
margin: 15px 0 9px;
color: #738077;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.trace-list {
display: grid;
gap: 8px;
margin: 0;
padding: 0;
list-style: none;
}
.trace-list li {
display: grid;
grid-template-columns: 23px 1fr;
gap: 8px;
align-items: start;
color: #50645a;
font-size: 11.5px;
line-height: 1.35;
}
.step-number {
display: grid;
width: 22px;
height: 22px;
place-items: center;
border-radius: 50%;
color: white;
background: var(--accent);
font-size: 9px;
font-weight: 850;
transition: background 250ms ease;
}
.network {
display: flex;
align-items: center;
justify-content: space-between;
gap: 5px;
margin-top: 16px;
padding: 12px 9px;
border-radius: 12px;
background: #e9ece2;
}
.network-node {
min-width: 45px;
color: #879189;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.08em;
text-align: center;
text-transform: uppercase;
transition: color 220ms ease, transform 220ms ease;
}
.network-node.connected {
color: #3c5b4b;
}
.network-node.selected {
color: var(--accent);
transform: translateY(-2px);
}
.exchange {
display: flex;
flex-direction: column;
align-items: center;
color: var(--xylem);
font-size: 13px;
font-weight: 900;
line-height: 0.85;
}
.exchange .return { color: var(--phloem); }
#flowNote {
margin: 11px 0 0;
color: #748078;
font-size: 10.5px;
line-height: 1.45;
}
#organPicker {
position: fixed;
z-index: 7;
left: 50%;
bottom: 24px;
display: flex;
gap: 6px;
padding: 6px;
transform: translateX(-50%);
border: 1px solid rgba(255,255,255,0.8);
border-radius: 17px;
background: rgba(250, 249, 238, 0.91);
box-shadow: 0 12px 36px rgba(40, 57, 46, 0.16);
backdrop-filter: blur(12px);
}
.organ-button {
display: flex;
align-items: center;
gap: 8px;
min-width: 112px;
padding: 9px 13px;
border: 0;
border-radius: 12px;
color: #53665c;
background: transparent;
cursor: pointer;
transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}
.organ-button:hover {
color: var(--ink);
background: rgba(75, 103, 86, 0.08);
transform: translateY(-1px);
}
.organ-button.active {
color: #fff;
background: var(--accent);
box-shadow: 0 5px 14px rgba(45, 63, 52, 0.15);
}
.organ-button svg {
width: 20px;
height: 20px;
flex: 0 0 auto;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.7;
}
.organ-button span {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.02em;
}
#gestureHint {
position: fixed;
z-index: 4;
bottom: 30px;
left: 29px;
display: flex;
align-items: center;
gap: 8px;
color: rgba(48, 69, 58, 0.65);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
pointer-events: none;
}
#gestureHint svg {
width: 17px;
height: 17px;
fill: none;
stroke: currentColor;
stroke-width: 1.5;
}
.hotspot {
position: fixed;
z-index: 5;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 7px;
padding: 5px 9px 5px 6px;
border: 1px solid rgba(255,255,255,0.75);
border-radius: 999px;
color: #486055;
background: rgba(250, 249, 238, 0.78);
box-shadow: 0 5px 16px rgba(39, 55, 45, 0.09);
cursor: pointer;
pointer-events: auto;
backdrop-filter: blur(8px);
transform: translate(-50%, -50%);
transition: color 180ms ease, background 180ms ease, opacity 180ms ease;
}
.hotspot .dot {
width: 8px;
height: 8px;
border: 2px solid currentColor;
border-radius: 50%;
box-shadow: 0 0 0 3px rgba(255,255,255,0.55);
}
.hotspot span {
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.hotspot.active {
color: white;
background: var(--accent);
}
#loader {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #e9eadf;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loader.done {
visibility: hidden;
opacity: 0;
}
.loader-leaf {
width: 43px;
height: 43px;
border: 3px solid rgba(43, 91, 67, 0.18);
border-top-color: #2b5b43;
border-radius: 50% 4px 50% 4px;
animation: grow 1s ease-in-out infinite alternate;
}
@keyframes grow {
to { transform: rotate(135deg) scale(1.1); }
}
@media (max-width: 850px) {
.exhibit-header {
top: 18px;
left: 18px;
max-width: calc(100vw - 36px);
}
.exhibit-header h1 {
font-size: clamp(31px, 8vw, 44px);
}
.exhibit-header p {
max-width: 310px;
font-size: 12px;
}
#story {
top: auto;
right: 12px;
bottom: 98px;
left: 12px;
width: auto;
max-height: 33vh;
overflow: auto;
padding: 15px 17px;
border-radius: 16px;
}
#story h2 { font-size: 25px; }
.story-lead { font-size: 11.5px; }
#storyBody { font-size: 11px; }
.legend { margin: 11px 0; }
.section-label { margin-top: 11px; }
.network { margin-top: 11px; }
#organPicker {
bottom: 11px;
width: calc(100vw - 24px);
gap: 3px;
}
.organ-button {
min-width: 0;
flex: 1;
justify-content: center;
padding: 9px 7px;
}
.organ-button span { font-size: 10px; }
#gestureHint { display: none; }
.hotspot { padding: 4px 7px 4px 5px; }
.hotspot span { font-size: 8px; }
}
@media (max-height: 690px) and (min-width: 851px) {
#story { top: 15px; right: 15px; padding: 15px; }
#storyBody { font-size: 11.5px; }
.legend { margin: 10px 0; }
.section-label { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive cutaway model of a plant showing roots, stem, leaves, xylem, and phloem"></canvas>
<div class="vignette"></div>
<header class="exhibit-header">
<div class="eyebrow">Botany gallery · interactive specimen</div>
<h1>The vascular garden</h1>
<p>Select a root, stem, or leaf to reveal the two hidden routes that connect every part of the plant.</p>
</header>
<aside id="story" aria-live="polite">
<div class="story-kicker" id="storyKicker">Organ 01 · below the soil</div>
<h2 id="storyTitle">Roots</h2>
<p class="story-lead" id="storyLead">The quiet exchange.</p>
<p id="storyBody"></p>
<div class="legend" aria-label="Transport route legend">
<div class="legend-row">
<span class="legend-swatch xylem"></span>
<div><b>XYLEM</b><small>Water + minerals · upward</small></div>
</div>
<div class="legend-row">
<span class="legend-swatch phloem"></span>
<div><b>PHLOEM</b><small>Sugars + energy · downward</small></div>
</div>
</div>
<div class="section-label">Trace the connection</div>
<ol class="trace-list" id="traceSteps"></ol>
<div class="network" aria-label="Plant organ connection map">
<span class="network-node" data-node="roots">Roots</span>
<span class="exchange"><span>→</span><span class="return">←</span></span>
<span class="network-node" data-node="stem">Stem</span>
<span class="exchange"><span>→</span><span class="return">←</span></span>
<span class="network-node" data-node="leaves">Leaves</span>
</div>
<p id="flowNote"></p>
</aside>
<button class="hotspot" id="hotspot-roots" data-organ="roots" aria-label="Select roots">
<span class="dot"></span><span>Roots</span>
</button>
<button class="hotspot" id="hotspot-stem" data-organ="stem" aria-label="Select stem">
<span class="dot"></span><span>Stem</span>
</button>
<button class="hotspot" id="hotspot-leaves" data-organ="leaves" aria-label="Select leaves">
<span class="dot"></span><span>Leaves</span>
</button>
<nav id="organPicker" aria-label="Choose a plant organ">
<button class="organ-button active" data-organ="roots" aria-pressed="true">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 3v8M12 8c-4 0-6-2-6-5M12 10c4 0 6-2 6-5M12 11c-4 0-6 3-6 6M12 12c4 0 6 3 6 6M12 11v9"/>
</svg>
<span>Roots</span>
</button>
<button class="organ-button" data-organ="stem" aria-pressed="false">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M12 21V4M12 9c-4 0-6-2-6-5M12 13c4 0 6-2 6-5M12 15c-4 0-5-2-5-5"/>
</svg>
<span>Stem</span>
</button>
<button class="organ-button" data-organ="leaves" aria-pressed="false">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 18c0-8 5-13 14-14 1 9-4 15-12 15M6 19c2-5 6-9 11-12"/>
</svg>
<span>Leaves</span>
</button>
</nav>
<div id="gestureHint">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M8 12a4 4 0 1 1 8 0v4a4 4 0 0 1-8 0v-4ZM12 8V5M5 12H2M22 12h-3"/>
</svg>
Drag to orbit · Scroll to zoom · 1 / 2 / 3 to select
</div>
<div id="loader"><div class="loader-leaf"></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 reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eadf);
scene.fog = new THREE.Fog(0xe9eadf, 18, 32);
const camera = new THREE.PerspectiveCamera(38, innerWidth / innerHeight, 0.1, 60);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.04;
const hemi = new THREE.HemisphereLight(0xfff8df, 0x526857, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.3);
sun.position.set(-5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -7;
sun.shadow.camera.right = 7;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -7;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 28;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9eff0, 1.0);
fill.position.set(7, 5, -4);
scene.add(fill);
const materials = {
platform: new THREE.MeshStandardMaterial({ color: 0xc9c6b5, roughness: 0.95 }),
ground: new THREE.MeshStandardMaterial({ color: 0xe4e4d7, roughness: 1 }),
soil: new THREE.MeshStandardMaterial({ color: 0x513a2c, roughness: 1 }),
topsoil: new THREE.MeshStandardMaterial({ color: 0x4c372a, roughness: 1 }),
middleSoil: new THREE.MeshStandardMaterial({ color: 0x79533b, roughness: 1 }),
lowerSoil: new THREE.MeshStandardMaterial({ color: 0x9a7655, roughness: 1 }),
seam: new THREE.MeshStandardMaterial({ color: 0x3c2d24, roughness: 1 }),
pebble: new THREE.MeshStandardMaterial({ color: 0xa48e72, roughness: 1 }),
root: new THREE.MeshStandardMaterial({ color: 0xd2a36f, roughness: 0.83 }),
rootFine: new THREE.MeshStandardMaterial({ color: 0xe0b985, roughness: 0.86 }),
stem: new THREE.MeshStandardMaterial({ color: 0x587648, roughness: 0.76 }),
stemShell: new THREE.MeshStandardMaterial({
color: 0x789161,
roughness: 0.8,
side: THREE.DoubleSide
}),
leaf: new THREE.MeshStandardMaterial({ color: 0x6f9f52, roughness: 0.67 }),
leafLight: new THREE.MeshStandardMaterial({ color: 0x85ae5c, roughness: 0.68 }),
vein: new THREE.MeshStandardMaterial({ color: 0xb3c876, roughness: 0.72 }),
xylem: new THREE.MeshBasicMaterial({ color: 0x28a9ba }),
phloem: new THREE.MeshBasicMaterial({ color: 0xe46d4f })
};
const pickables = [];
const organGroups = {
roots: new THREE.Group(),
stem: new THREE.Group(),
leaves: new THREE.Group()
};
scene.add(organGroups.roots, organGroups.stem, organGroups.leaves);
function tagPickable(mesh, organ) {
mesh.userData.organ = organ;
pickables.push(mesh);
return mesh;
}
function tube(points, radius, material, segments = 30) {
const curve = new THREE.CatmullRomCurve3(
points.map(p => p.isVector3 ? p : new THREE.Vector3(...p)),
false,
"catmullrom",
0.35
);
const geometry = new THREE.TubeGeometry(curve, segments, radius, 8, false);
return { mesh: new THREE.Mesh(geometry, material), curve };
}
function cylinderBetween(start, end, radius, material, radialSegments = 12) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const geometry = new THREE.CylinderGeometry(
radius * 0.9,
radius,
direction.length(),
radialSegments
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
// Garden pedestal and cutaway soil block.
const ground = new THREE.Mesh(new THREE.PlaneGeometry(60, 60), materials.ground);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -3.08;
ground.receiveShadow = true;
scene.add(ground);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(5.1, 5.35, 0.28, 64),
materials.platform
);
platform.position.y = -2.94;
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
const soilBlock = new THREE.Mesh(
new THREE.BoxGeometry(7.4, 2.65, 2.7),
materials.soil
);
soilBlock.position.set(0, -1.325, -0.95);
soilBlock.castShadow = true;
soilBlock.receiveShadow = true;
scene.add(soilBlock);
const strata = [
{ y: -0.18, h: 0.36, mat: materials.topsoil },
{ y: -0.95, h: 1.18, mat: materials.middleSoil },
{ y: -2.12, h: 1.16, mat: materials.lowerSoil }
];
strata.forEach(layer => {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(7.42, layer.h, 0.08),
layer.mat
);
mesh.position.set(0, layer.y, 0.43);
mesh.receiveShadow = true;
scene.add(mesh);
});
[-0.37, -1.54].forEach(y => {
const seam = new THREE.Mesh(
new THREE.BoxGeometry(7.45, 0.035, 0.09),
materials.seam
);
seam.position.set(0, y, 0.45);
scene.add(seam);
});
// Small, solid mulch forms keep the exhibit garden-like.
for (let i = 0; i < 22; i++) {
const seed = i * 91.731;
const x = Math.sin(seed) * 3.1;
const z = -0.2 + (Math.cos(seed * 1.37) * 0.5 + 0.5) * 2.0;
const scale = 0.08 + (Math.sin(seed * 2.11) * 0.5 + 0.5) * 0.12;
const pebble = new THREE.Mesh(
new THREE.IcosahedronGeometry(scale, 1),
materials.pebble
);
pebble.position.set(x, 0.05 + scale * 0.25, z);
pebble.scale.set(1.25, 0.65, 1);
pebble.rotation.set(seed * 0.13, seed * 0.27, seed * 0.09);
pebble.castShadow = true;
pebble.receiveShadow = true;
scene.add(pebble);
}
// Roots displayed directly on the exposed soil face.
const rootCurves = [];
const rootPaths = [
[[0, -0.03, 0.34], [0, -0.42, 0.50], [0.04, -1.15, 0.52], [0, -2.52, 0.50]],
[[0, -0.35, 0.50], [-0.55, -0.55, 0.53], [-1.22, -0.78, 0.54], [-2.05, -1.02, 0.55], [-3.15, -1.32, 0.56]],
[[0, -0.52, 0.51], [0.65, -0.69, 0.54], [1.35, -0.91, 0.55], [2.15, -1.18, 0.55], [3.12, -1.50, 0.56]],
[[0, -0.78, 0.52], [-0.45, -1.04, 0.55], [-0.82, -1.47, 0.56], [-1.15, -2.18, 0.56]],
[[0, -0.95, 0.52], [0.45, -1.22, 0.55], [0.92, -1.68, 0.55], [1.18, -2.30, 0.56]],
[[0, -1.30, 0.52], [-0.72, -1.54, 0.55], [-1.55, -1.75, 0.56], [-2.55, -2.05, 0.56]],
[[0, -1.50, 0.52], [0.75, -1.74, 0.55], [1.52, -1.96, 0.56], [2.42, -2.23, 0.56]]
];
rootPaths.forEach((points, index) => {
const result = tube(points, index === 0 ? 0.105 : 0.066, materials.root, 40);
result.mesh.castShadow = true;
organGroups.roots.add(tagPickable(result.mesh, "roots"));
rootCurves.push(result.curve);
});
const fineRootPaths = [
[[-1.15, -0.76, 0.55], [-1.45, -0.96, 0.57], [-1.82, -1.08, 0.57]],
[[-1.95, -0.98, 0.56], [-2.25, -1.24, 0.58], [-2.62, -1.32, 0.58]],
[[-2.72, -1.24, 0.57], [-3.02, -1.46, 0.58], [-3.34, -1.55, 0.58]],
[[1.2, -0.86, 0.56], [1.52, -1.08, 0.58], [1.86, -1.18, 0.58]],
[[2.02, -1.14, 0.56], [2.35, -1.38, 0.58], [2.72, -1.46, 0.58]],
[[-0.75, -1.40, 0.57], [-0.96, -1.72, 0.58], [-1.30, -1.84, 0.58]],
[[0.83, -1.60, 0.57], [1.05, -1.90, 0.58], [1.40, -2.03, 0.58]],
[[-1.48, -1.71, 0.57], [-1.76, -2.02, 0.58], [-2.15, -2.17, 0.58]],
[[1.43, -1.91, 0.57], [1.72, -2.19, 0.58], [2.10, -2.34, 0.58]],
[[-0.18, -1.72, 0.56], [-0.28, -2.18, 0.58], [-0.16, -2.50, 0.58]]
];
fineRootPaths.forEach(points => {
const result = tube(points, 0.027, materials.rootFine, 22);
organGroups.roots.add(tagPickable(result.mesh, "roots"));
});
// Stem with an open front window exposing the vascular bundles.
const lowerStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.225, 0.25, 1.35, 24),
materials.stem
);
lowerStem.position.set(0, 0.675, 0.12);
lowerStem.castShadow = true;
organGroups.stem.add(tagPickable(lowerStem, "stem"));
const upperStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.15, 0.205, 2.15, 24),
materials.stem
);
upperStem.position.set(-0.02, 3.275, 0.12);
upperStem.castShadow = true;
organGroups.stem.add(tagPickable(upperStem, "stem"));
const cutawayShell = new THREE.Mesh(
new THREE.CylinderGeometry(
0.215, 0.22, 0.85, 32, 1, true,
Math.PI / 2, Math.PI
),
materials.stemShell
);
cutawayShell.position.set(0, 1.775, 0.12);
cutawayShell.castShadow = true;
organGroups.stem.add(tagPickable(cutawayShell, "stem"));
const xylemCore = cylinderBetween(
[-0.075, 1.31, 0.16], [-0.075, 2.25, 0.16],
0.046, materials.xylem, 12
);
organGroups.stem.add(tagPickable(xylemCore, "stem"));
const phloemCore = cylinderBetween(
[0.075, 1.31, 0.17], [0.075, 2.25, 0.17],
0.046, materials.phloem, 12
);
organGroups.stem.add(tagPickable(phloemCore, "stem"));
const crown = new THREE.Mesh(
new THREE.SphereGeometry(0.27, 20, 14),
materials.stem
);
crown.position.set(0, -0.04, 0.18);
crown.scale.set(1, 0.68, 1);
crown.castShadow = true;
organGroups.stem.add(tagPickable(crown, "stem"));
// Solid, beveled leaf silhouettes.
const leafShape = new THREE.Shape();
leafShape.moveTo(0, -0.85);
leafShape.bezierCurveTo(0.5, -0.62, 0.68, 0.04, 0.42, 0.52);
leafShape.bezierCurveTo(0.27, 0.79, 0.08, 1.0, 0, 1.05);
leafShape.bezierCurveTo(-0.08, 1.0, -0.27, 0.79, -0.42, 0.52);
leafShape.bezierCurveTo(-0.68, 0.04, -0.5, -0.62, 0, -0.85);
const leafGeometry = new THREE.ExtrudeGeometry(leafShape, {
depth: 0.1,
steps: 1,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.035,
bevelThickness: 0.03,
curveSegments: 20
});
leafGeometry.translate(0, 0, -0.05);
function createLeaf(position, rotation, scale, leafMaterial) {
const group = new THREE.Group();
group.position.copy(position);
group.rotation.set(-0.08, 0.06, rotation);
group.scale.setScalar(scale);
organGroups.leaves.add(group);
const blade = new THREE.Mesh(leafGeometry, leafMaterial);
blade.castShadow = true;
blade.receiveShadow = true;
group.add(tagPickable(blade, "leaves"));
const midrib = tube(
[[0, -0.76, 0.10], [0, 0, 0.13], [0, 0.88, 0.10]],
0.026,
materials.vein,
22
);
group.add(tagPickable(midrib.mesh, "leaves"));
[-1, 1].forEach(side => {
for (let i = 0; i < 3; i++) {
const y = -0.39 + i * 0.29;
const vein = tube(
[
[0, y, 0.105],
[side * 0.16, y + 0.08, 0.11],
[side * 0.38, y + 0.22, 0.105]
],
0.012,
materials.vein,
15
);
group.add(tagPickable(vein.mesh, "leaves"));
}
});
return group;
}
const leafSettings = [
{
position: new THREE.Vector3(-1.48, 2.62, 0.18),
rotation: 0.80,
scale: 1.0,
material: materials.leaf,
attach: new THREE.Vector3(0, 1.82, 0.14)
},
{
position: new THREE.Vector3(1.55, 2.96, 0.16),
rotation: -0.78,
scale: 0.96,
material: materials.leafLight,
attach: new THREE.Vector3(0, 2.25, 0.14)
},
{
position: new THREE.Vector3(-0.10, 4.00, 0.13),
rotation: 0.10,
scale: 0.93,
material: materials.leaf,
attach: new THREE.Vector3(-0.02, 3.15, 0.13)
}
];
const leafData = leafSettings.map(setting => {
const group = createLeaf(
setting.position,
setting.rotation,
setting.scale,
setting.material
);
return { group, attach: setting.attach };
});
scene.updateMatrixWorld(true);
leafData.forEach(data => {
const base = data.group.localToWorld(new THREE.Vector3(0, -0.86, 0));
const middle = data.attach.clone().lerp(base, 0.53);
middle.z += 0.035;
const branch = tube(
[data.attach, middle, base],
0.075,
materials.stem,
26
);
branch.mesh.castShadow = true;
organGroups.stem.add(tagPickable(branch.mesh, "stem"));
data.base = base;
data.center = data.group.getWorldPosition(new THREE.Vector3());
});
// Animated vascular routes. Xylem travels root → leaf; phloem travels leaf → root.
const routes = [];
const particleGeometry = new THREE.SphereGeometry(0.058, 10, 8);
function addRoute(kind, points) {
const curve = new THREE.CatmullRomCurve3(
points.map(p => p.isVector3 ? p : new THREE.Vector3(...p)),
false,
"catmullrom",
0.28
);
const color = kind === "xylem" ? 0x28a9ba : 0xe46d4f;
const routeMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.2,
depthWrite: false
});
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.026, 7, false),
routeMaterial
);
line.renderOrder = 4;
scene.add(line);
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.65,
depthWrite: false
});
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.22, 10),
arrowMaterial
);
const arrowT = kind === "xylem" ? 0.72 : 0.34;
arrow.position.copy(curve.getPoint(arrowT));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangent(arrowT).normalize()
);
arrow.renderOrder = 6;
scene.add(arrow);
const particles = [];
for (let i = 0; i < 2; i++) {
const particle = new THREE.Mesh(
particleGeometry,
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.98,
depthWrite: false
})
);
particle.renderOrder = 7;
particle.userData.offset = i * 0.5;
scene.add(particle);
particles.push(particle);
}
routes.push({
kind,
curve,
material: routeMaterial,
line,
arrow,
arrowMaterial,
particles,
phase: Math.random()
});
}
leafData.forEach(data => {
const center = data.center.clone();
center.z += 0.19;
const xylemPoints = [
new THREE.Vector3(-0.055, -2.43, 0.57),
new THREE.Vector3(-0.055, -1.25, 0.56),
new THREE.Vector3(-0.035, -0.08, 0.41),
new THREE.Vector3(-0.035, 0.63, 0.33),
new THREE.Vector3(0, data.attach.y, 0.31),
center
];
const phloemPoints = [
center,
new THREE.Vector3(0.12, data.attach.y + 0.08, 0.36),
new THREE.Vector3(0.055, data.attach.y, 0.35),
new THREE.Vector3(0.055, 1.20, 0.35),
new THREE.Vector3(0.045, -0.05, 0.42),
new THREE.Vector3(0.055, -2.40, 0.57)
];
addRoute("xylem", xylemPoints);
addRoute("phloem", phloemPoints);
});
// A soft selection ring, billboarded toward the camera.
const selectionMarker = new THREE.Mesh(
new THREE.TorusGeometry(0.39, 0.025, 10, 48),
new THREE.MeshBasicMaterial({
color: 0xc8993c,
transparent: true,
opacity: 0.65,
depthTest: false,
depthWrite: false
})
);
selectionMarker.renderOrder = 10;
scene.add(selectionMarker);
const organCopy = {
roots: {
kicker: "Organ 01 · below the soil",
title: "Roots",
lead: "The quiet exchange.",
body: "Fine roots anchor the plant and increase its contact with soil. Water and minerals enter here, while sugars arrive from the leaves to support growth.",
steps: [
"Water and minerals enter through the root surface.",
"Xylem carries the upward flow into the stem.",
"The stem delivers those minerals to active leaves."
],
note: "Return route: phloem carries sugars from the leaves down into the roots.",
accent: "#c8993c",
marker: new THREE.Vector3(-0.18, -1.16, 0.59)
},
stem: {
kicker: "Organ 02 · the connecting axis",
title: "Stem",
lead: "Two roads, one living structure.",
body: "Vascular bundles form a continuous transport network inside the stem. The front cutaway exposes the blue xylem and coral phloem carrying materials in opposite directions.",
steps: [
"Xylem moves water and minerals upward toward leaves.",
"Phloem moves sugars and energy downward toward roots.",
"Branches distribute both routes to every leaf."
],
note: "The open window is a cutaway view of bundles that normally run inside the stem.",
accent: "#568f68",
marker: new THREE.Vector3(0.02, 1.72, 0.34)
},
leaves: {
kicker: "Organ 03 · above the soil",
title: "Leaves",
lead: "Where sunlight becomes food.",
body: "Leaves use sunlight, water, and carbon dioxide to make sugars. Those sugars feed the plant and travel through phloem to growing or storage tissues.",
steps: [
"Sunlight powers sugar production in the leaf.",
"Phloem carries sugars away through the stem.",
"Roots and other tissues receive and store energy."
],
note: "Xylem supports this work by delivering water and minerals to the leaf.",
accent: "#73a657",
marker: new THREE.Vector3(0.08, 3.73, 0.34)
}
};
const materialGroups = {
roots: [materials.root, materials.rootFine],
stem: [materials.stem, materials.stemShell],
leaves: [materials.leaf, materials.leafLight, materials.vein]
};
let selectedOrgan = "roots";
function selectOrgan(organ) {
selectedOrgan = organ;
const data = organCopy[organ];
document.documentElement.style.setProperty("--accent", data.accent);
document.querySelector("#storyKicker").textContent = data.kicker;
document.querySelector("#storyTitle").textContent = data.title;
document.querySelector("#storyLead").textContent = data.lead;
document.querySelector("#storyBody").textContent = data.body;
document.querySelector("#flowNote").textContent = data.note;
document.querySelector("#traceSteps").innerHTML = data.steps.map((step, index) => `
<li>
<span class="step-number">${String(index + 1).padStart(2, "0")}</span>
<span>${step}</span>
</li>
`).join("");
document.querySelectorAll(".organ-button").forEach(button => {
const active = button.dataset.organ === organ;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
document.querySelectorAll(".hotspot").forEach(button => {
button.classList.toggle("active", button.dataset.organ === organ);
});
document.querySelectorAll(".network-node").forEach(node => {
node.classList.toggle("selected", node.dataset.node === organ);
node.classList.toggle("connected", node.dataset.node !== organ);
});
Object.entries(materialGroups).forEach(([key, list]) => {
list.forEach(material => {
if (key === organ) {
material.emissive.set(data.accent);
material.emissiveIntensity = 0.18;
} else {
material.emissive.set(0x000000);
material.emissiveIntensity = 0;
}
});
});
routes.forEach(route => {
const primary = organ === "stem" ||
(organ === "roots" && route.kind === "xylem") ||
(organ === "leaves" && route.kind === "phloem");
route.material.opacity = primary ? 0.96 : 0.19;
route.arrowMaterial.opacity = primary ? 0.88 : 0.28;
route.particles.forEach(particle => particle.visible = primary);
});
selectionMarker.material.color.set(data.accent);
selectionMarker.position.copy(data.marker);
}
document.querySelectorAll("[data-organ]").forEach(button => {
button.addEventListener("click", event => {
event.stopPropagation();
selectOrgan(button.dataset.organ);
});
});
// Camera controls implemented directly, without external control modules.
const controls = {
yaw: 0.27,
pitch: 0.26,
radius: innerWidth < 700 ? 15.5 : 13.0,
target: new THREE.Vector3(innerWidth > 850 ? 0.28 : 0, 0.78, 0)
};
function updateCamera() {
const cp = Math.cos(controls.pitch);
controls.radius = THREE.MathUtils.clamp(controls.radius, 8.8, 18.5);
controls.yaw = THREE.MathUtils.clamp(controls.yaw, -0.85, 0.85);
controls.pitch = THREE.MathUtils.clamp(controls.pitch, 0.07, 0.62);
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * cp * controls.radius,
controls.target.y + Math.sin(controls.pitch) * controls.radius,
controls.target.z + Math.cos(controls.yaw) * cp * controls.radius
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.yaw = 0.27;
controls.pitch = 0.26;
controls.radius = innerWidth < 700 ? 15.5 : 13.0;
controls.target.set(innerWidth > 850 ? 0.28 : 0, 0.78, 0);
updateCamera();
}
updateCamera();
const pointers = new Map();
let gestureMoved = 0;
let multiTouchGesture = false;
let previousPinchDistance = 0;
canvas.addEventListener("pointerdown", event => {
if (event.pointerType === "mouse" && event.button !== 0) return;
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
gestureMoved = 0;
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
multiTouchGesture = true;
}
});
canvas.addEventListener("pointermove", event => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
previous.x = event.clientX;
previous.y = event.clientY;
gestureMoved += Math.hypot(dx, dy);
if (pointers.size === 1) {
controls.yaw -= dx * 0.006;
controls.pitch += dy * 0.0045;
updateCamera();
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance > 0 && distance > 0) {
controls.radius *= previousPinchDistance / distance;
updateCamera();
}
previousPinchDistance = distance;
}
});
canvas.addEventListener("pointerup", event => {
const shouldPick = gestureMoved < 7 && !multiTouchGesture && pointers.size === 1;
pointers.delete(event.pointerId);
if (shouldPick) {
const rect = canvas.getBoundingClientRect();
const mouse = new THREE.Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);
const hit = raycaster.intersectObjects(pickables, false)[0];
if (hit) selectOrgan(hit.object.userData.organ);
}
if (pointers.size === 0) {
multiTouchGesture = false;
previousPinchDistance = 0;
}
});
canvas.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
if (!pointers.size) multiTouchGesture = false;
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
controls.radius *= 1 + Math.sign(event.deltaY) * 0.085;
updateCamera();
}, { passive: false });
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("dblclick", resetCamera);
addEventListener("keydown", event => {
if (event.key === "1") selectOrgan("roots");
if (event.key === "2") selectOrgan("stem");
if (event.key === "3") selectOrgan("leaves");
if (event.key.toLowerCase() === "r") resetCamera();
});
const hotspotDefinitions = {
roots: new THREE.Vector3(-0.58, -1.18, 0.58),
stem: new THREE.Vector3(0.42, 1.63, 0.38),
leaves: new THREE.Vector3(0.52, 3.73, 0.34)
};
const hotspotElements = {
roots: document.querySelector("#hotspot-roots"),
stem: document.querySelector("#hotspot-stem"),
leaves: document.querySelector("#hotspot-leaves")
};
function updateHotspots() {
Object.entries(hotspotDefinitions).forEach(([organ, world]) => {
const projected = world.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
const element = hotspotElements[organ];
element.style.opacity = visible ? "1" : "0";
element.style.pointerEvents = visible ? "auto" : "none";
element.style.transform =
`translate(-50%, -50%) translate(${x}px, ${y}px)`;
});
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.fov = innerWidth < 700 ? 44 : 38;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", resize);
resize();
selectOrgan("roots");
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
routes.forEach(route => {
route.phase = (route.phase + dt * (route.kind === "xylem" ? 0.13 : 0.105)) % 1;
route.particles.forEach(particle => {
if (!particle.visible) return;
const t = (route.phase + particle.userData.offset) % 1;
particle.position.copy(route.curve.getPoint(t));
const pulse = 1 + Math.sin(elapsed * 5 + t * Math.PI * 2) * 0.12;
particle.scale.setScalar(pulse);
});
});
if (!reducedMotion) {
selectionMarker.quaternion.copy(camera.quaternion);
selectionMarker.scale.setScalar(1 + Math.sin(elapsed * 3.2) * 0.055);
}
updateHotspots();
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
document.querySelector("#loader").classList.add("done");
});
</script>
</body>
</html>
```