Prompt specification
Build or customize the Three.js 3D scene "Carbon and support relationship" 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: Carbon and support relationship
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/carbon-and-support-relationship-x0746
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring lichen partnerships. Animate symbolic carbon products moving from photosynthetic cells while the surrounding fungal structure retains moisture and provides form; explain the diagram as an incomplete relationship model. Low-poly.
Working Three.js Starter (carbon-and-support-relationship-x0746):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lichen Partnership — Partial Relationship Model</title>
<style>
:root {
--ink: #25312c;
--muted: #5f6b63;
--paper: #e9e6dc;
--panel: rgba(247, 244, 235, 0.9);
--line: rgba(48, 62, 53, 0.16);
--green: #4e9b5c;
--tan: #b9794d;
--gold: #e6a62d;
--blue: #3f9fbd;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app {
position: fixed;
inset: 0;
isolation: isolate;
}
#scene {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
outline: none;
}
#scene:active { cursor: grabbing; }
.panel {
position: absolute;
z-index: 10;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 18px 50px rgba(50, 55, 45, 0.1);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.title-panel {
top: 22px;
left: 24px;
width: min(410px, calc(100vw - 48px));
padding: 20px 22px 18px;
border-radius: 4px 20px 4px 4px;
}
.eyebrow {
margin-bottom: 9px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 350px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.model-panel {
top: 22px;
right: 24px;
width: 350px;
padding: 20px;
border-radius: 20px 4px 4px 4px;
}
.status {
display: inline-flex;
align-items: center;
gap: 7px;
margin-bottom: 10px;
padding: 5px 8px;
border: 1px solid rgba(72, 85, 74, 0.18);
border-radius: 999px;
color: #536258;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.status::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 4px rgba(230, 166, 45, 0.15);
content: "";
}
.model-panel h2 {
margin: 0 0 10px;
font-family: Georgia, "Times New Roman", serif;
font-size: 24px;
font-weight: 500;
line-height: 1.05;
}
.model-panel p {
margin: 0 0 13px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.list-label {
margin: 15px 0 7px;
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.model-list {
display: grid;
gap: 8px;
margin: 0;
padding: 0;
list-style: none;
}
.model-list li {
display: grid;
grid-template-columns: 10px 1fr;
gap: 9px;
align-items: start;
color: #4c5b52;
font-size: 11.5px;
line-height: 1.42;
}
.swatch {
display: inline-block;
width: 9px;
height: 9px;
margin-top: 3px;
border-radius: 2px;
}
.swatch.green { background: var(--green); }
.swatch.tan { background: var(--tan); }
.swatch.gold { background: var(--gold); }
.swatch.blue { background: var(--blue); }
.swatch.gray { background: #969d98; }
.model-note {
margin-top: 15px !important;
padding-top: 12px;
border-top: 1px solid var(--line);
font-size: 10.5px !important;
}
.legend {
left: 24px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 10px 16px;
max-width: 530px;
padding: 12px 15px;
border-radius: 4px 4px 16px 4px;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.controls {
right: 24px;
bottom: 24px;
display: flex;
gap: 8px;
padding: 8px;
border-radius: 16px 4px 4px 4px;
}
button {
border: 1px solid var(--line);
border-radius: 9px;
padding: 9px 12px;
background: rgba(255, 255, 255, 0.55);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.04em;
}
button:hover { background: #fffdf8; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hint {
position: absolute;
z-index: 5;
left: 50%;
bottom: 27px;
transform: translateX(-50%);
color: rgba(43, 57, 49, 0.6);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.05em;
pointer-events: none;
white-space: nowrap;
}
#labels {
position: absolute;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
display: flex;
gap: 8px;
align-items: flex-start;
min-width: 135px;
padding: 8px 10px;
transform: translate(-50%, -50%);
border: 1px solid rgba(58, 70, 61, 0.13);
border-radius: 8px;
background: rgba(246, 243, 234, 0.88);
box-shadow: 0 8px 22px rgba(48, 54, 45, 0.08);
backdrop-filter: blur(9px);
-webkit-backdrop-filter: blur(9px);
white-space: nowrap;
}
.scene-label .marker {
flex: 0 0 auto;
width: 7px;
height: 7px;
margin-top: 4px;
border-radius: 50%;
}
.scene-label b {
display: block;
color: #35443b;
font-size: 8.5px;
font-weight: 900;
letter-spacing: 0.12em;
}
.scene-label small {
display: block;
margin-top: 3px;
color: #6a756e;
font-size: 9px;
font-weight: 550;
}
#loading {
position: absolute;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: var(--paper);
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
@media (max-width: 850px) {
.title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
.title-panel h1 { font-size: 30px; }
.subtitle { display: none; }
.model-panel {
top: auto;
right: 12px;
bottom: 72px;
width: min(320px, calc(100vw - 24px));
max-height: 39vh;
overflow: auto;
padding: 15px;
}
.model-panel h2 { font-size: 20px; }
.model-panel p { font-size: 11px; }
.list-label { margin-top: 10px; }
.model-list li { font-size: 10.5px; }
.legend {
left: 12px;
bottom: 12px;
max-width: calc(100vw - 24px);
gap: 7px 11px;
padding: 9px 11px;
font-size: 8px;
}
.controls {
right: 12px;
bottom: 12px;
}
.hint { display: none; }
.scene-label { transform: translate(-50%, -50%) scale(0.85); }
}
</style>
</head>
<body>
<main id="app">
<canvas id="scene" aria-label="Interactive low-poly diagram of a lichen partnership"></canvas>
<header class="panel title-panel">
<div class="eyebrow">Symbiotic ecology / relationship map</div>
<h1>Lichen partnership</h1>
<p class="subtitle">
A partial, three-dimensional exchange model: photosynthetic cells
produce carbon-bearing compounds while fungal hyphae retain moisture
and form a supporting matrix.
</p>
</header>
<aside class="panel model-panel" aria-labelledby="model-heading">
<div class="status">Incomplete relationship model</div>
<h2 id="model-heading">Selected processes, not the whole system</h2>
<p>
This diagram isolates three visible relationships. It is not a complete
life cycle, metabolic budget, or universal account of lichen ecology.
</p>
<div class="list-label">Shown here</div>
<ul class="model-list">
<li>
<span class="swatch gold"></span>
<span>Symbolic carbon-bearing products move from photosynthetic cells into fungal hyphae.</span>
</li>
<li>
<span class="swatch blue"></span>
<span>Moisture is held at hyphal junctions and within the fungal matrix.</span>
</li>
<li>
<span class="swatch tan"></span>
<span>Interwoven fungal hyphae provide form, enclosure, and mechanical support.</span>
</li>
</ul>
<div class="list-label">Not represented</div>
<ul class="model-list">
<li>
<span class="swatch gray"></span>
<span>Mineral transfer, other metabolites, growth, mortality, environmental limits, and net ecological outcomes remain unspecified.</span>
</li>
</ul>
<p class="model-note">
The C₆ icons are symbolic, not measured molecules. Sizes, paths,
quantities, and flow rates are not to scale.
</p>
</aside>
<div id="labels" aria-hidden="true">
<div id="label-cells" class="scene-label">
<span class="marker" style="background: var(--green)"></span>
<span>
<b>PHOTOSYNTHETIC PARTNER</b>
<small>alga or cyanobacterium</small>
</span>
</div>
<div id="label-form" class="scene-label">
<span class="marker" style="background: var(--tan)"></span>
<span>
<b>FORM / SCAFFOLD</b>
<small>interwoven fungal hyphae</small>
</span>
</div>
<div id="label-moisture" class="scene-label">
<span class="marker" style="background: var(--blue)"></span>
<span>
<b>RETAINED MOISTURE</b>
<small>held at fungal junctions</small>
</span>
</div>
<div id="label-carbon" class="scene-label">
<span class="marker" style="background: var(--gold)"></span>
<span>
<b>CARBON PRODUCT</b>
<small>symbolic transfer</small>
</span>
</div>
<div id="label-unknown" class="scene-label">
<span class="marker" style="background: #8c9690"></span>
<span>
<b>UNSPECIFIED EXCHANGES</b>
<small>outside this partial model</small>
</span>
</div>
</div>
<section class="panel legend" aria-label="Diagram legend">
<span class="legend-item"><i class="swatch green"></i> Photosynthetic cells</span>
<span class="legend-item"><i class="swatch tan"></i> Fungal hyphae</span>
<span class="legend-item"><i class="swatch gold"></i> Carbon products</span>
<span class="legend-item"><i class="swatch blue"></i> Retained water</span>
<span class="legend-item"><i class="swatch gray"></i> Not specified</span>
</section>
<div class="panel controls">
<button id="toggle-motion" type="button" aria-pressed="false">Pause motion</button>
<button id="reset-view" type="button">Reset view</button>
</div>
<div class="hint">Drag to orbit · Scroll or pinch to zoom</div>
<div id="loading">Building the relationship model…</div>
</main>
<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 loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e6dc);
scene.fog = new THREE.Fog(0xe9e6dc, 15, 29);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
60
);
const V = (x, y, z) => new THREE.Vector3(x, y, z);
// ---------------------------------------------------------------------
// Lighting and material palette
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff7df, 0x687466, 2.15));
const sun = new THREE.DirectionalLight(0xffedca, 3.4);
sun.position.set(-5, 9, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 24;
sun.shadow.bias = -0.0007;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x8fc9d6, 1.15);
rim.position.set(7, 4, -6);
scene.add(rim);
const material = {
ground: new THREE.MeshStandardMaterial({
color: 0xc9c4b5,
roughness: 1,
flatShading: true
}),
substrate: new THREE.MeshStandardMaterial({
color: 0x8a6749,
roughness: 1,
flatShading: true
}),
hypha: new THREE.MeshStandardMaterial({
color: 0xb7794f,
roughness: 0.92,
flatShading: true
}),
hyphaLight: new THREE.MeshStandardMaterial({
color: 0xc99463,
roughness: 0.9,
flatShading: true
}),
hyphaDark: new THREE.MeshStandardMaterial({
color: 0x85563c,
roughness: 1,
flatShading: true
}),
cellA: new THREE.MeshStandardMaterial({
color: 0x4d9a5a,
roughness: 0.78,
flatShading: true
}),
cellB: new THREE.MeshStandardMaterial({
color: 0x68ad69,
roughness: 0.8,
flatShading: true
}),
cellC: new THREE.MeshStandardMaterial({
color: 0x3d8550,
roughness: 0.82,
flatShading: true
}),
gold: new THREE.MeshStandardMaterial({
color: 0xe5a52b,
emissive: 0x8a4f05,
emissiveIntensity: 0.22,
roughness: 0.5,
metalness: 0.12,
flatShading: true
}),
water: new THREE.MeshStandardMaterial({
color: 0x48a8c5,
emissive: 0x123e4a,
emissiveIntensity: 0.16,
roughness: 0.22,
metalness: 0.08,
transparent: true,
opacity: 0.78,
flatShading: true
}),
unknown: new THREE.MeshStandardMaterial({
color: 0x8e9891,
roughness: 1,
flatShading: true
})
};
const cellEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x285b36,
transparent: true,
opacity: 0.56
});
// ---------------------------------------------------------------------
// Low-poly ground
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.CylinderGeometry(8.5, 9.1, 0.45, 14),
material.ground
);
ground.position.y = -0.47;
ground.receiveShadow = true;
scene.add(ground);
const groundRing = new THREE.Mesh(
new THREE.TorusGeometry(8.25, 0.018, 3, 72),
new THREE.MeshBasicMaterial({ color: 0xaaa493 })
);
groundRing.rotation.x = Math.PI / 2;
groundRing.position.y = -0.235;
scene.add(groundRing);
// A few faceted substrate fragments establish scale.
const pebbleGeometry = new THREE.IcosahedronGeometry(1, 0);
const pebbleData = [
[-6.2, -0.12, 1.4, 0.34],
[-5.1, -0.15, -2.3, 0.27],
[5.6, -0.12, 1.9, 0.32],
[6.4, -0.14, -0.8, 0.24],
[-3.9, -0.14, 4.1, 0.22],
[2.1, -0.13, -4.4, 0.28]
];
for (const [x, y, z, size] of pebbleData) {
const pebble = new THREE.Mesh(pebbleGeometry, material.substrate);
pebble.position.set(x, y, z);
pebble.scale.set(size * 1.4, size * 0.65, size);
pebble.rotation.set(0.2, x * 0.17, -0.1);
pebble.castShadow = true;
pebble.receiveShadow = true;
scene.add(pebble);
}
// ---------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------
function addTube(points, radius, mat, tubularSegments = 28) {
const curve = new THREE.CatmullRomCurve3(
points.map(p => (p.isVector3 ? p.clone() : V(...p))),
false,
"centripetal"
);
const mesh = new THREE.Mesh(
new THREE.TubeGeometry(curve, tubularSegments, radius, 5, false),
mat
);
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.curve = curve;
scene.add(mesh);
return mesh;
}
function addNode(position, radius = 0.13, mat = material.hyphaLight) {
const node = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, 0),
mat
);
node.position.copy(position);
node.scale.y = 0.86;
node.castShadow = true;
scene.add(node);
return node;
}
// ---------------------------------------------------------------------
// Irregular fungal mat at the base
// ---------------------------------------------------------------------
const leftMat = new THREE.Mesh(
new THREE.DodecahedronGeometry(1, 0),
material.substrate
);
leftMat.position.set(-1.15, -0.05, 0);
leftMat.scale.set(3.2, 0.32, 1.7);
leftMat.rotation.y = -0.18;
leftMat.castShadow = true;
leftMat.receiveShadow = true;
scene.add(leftMat);
const rightMat = new THREE.Mesh(
new THREE.DodecahedronGeometry(1, 0),
material.hyphaDark
);
rightMat.position.set(2.95, -0.02, 0.1);
rightMat.scale.set(1.75, 0.28, 1.45);
rightMat.castShadow = true;
rightMat.receiveShadow = true;
scene.add(rightMat);
// ---------------------------------------------------------------------
// Photosynthetic partner cells
// ---------------------------------------------------------------------
const cellGeometry = new THREE.IcosahedronGeometry(1, 0);
const cellMaterials = [
material.cellA,
material.cellB,
material.cellC
];
const cellData = [
[-2.90, 0.96, 0.10, 0.44],
[-2.55, 1.57, -0.42, 0.48],
[-2.05, 1.06, 0.48, 0.46],
[-1.73, 1.72, 0.12, 0.45],
[-1.22, 1.23, -0.36, 0.48],
[-1.36, 0.72, 0.76, 0.44],
[-2.43, 0.55, 0.76, 0.43],
[-2.92, 0.44, -0.57, 0.42],
[-1.80, 0.49, -0.83, 0.40],
[-0.92, 0.65, 0.08, 0.43],
[-0.55, 1.46, 0.63, 0.40],
[-0.56, 1.05, -0.76, 0.41]
];
cellData.forEach(([x, y, z, radius], index) => {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.set(
0.18 * Math.sin(index * 1.7),
index * 0.63,
0.13 * Math.cos(index * 1.2)
);
const cell = new THREE.Mesh(
cellGeometry,
cellMaterials[index % cellMaterials.length]
);
cell.scale.set(radius, radius * 1.08, radius * 0.92);
cell.castShadow = true;
cell.receiveShadow = true;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(cellGeometry),
cellEdgeMaterial
);
cell.add(edges);
group.add(cell);
scene.add(group);
});
// ---------------------------------------------------------------------
// Fungal hyphal lattice surrounding the cells
// ---------------------------------------------------------------------
const domeBack = addTube([
[-3.62, 0.02, -0.88],
[-3.50, 1.50, -0.98],
[-2.72, 2.73, -0.72],
[-1.18, 3.20, -0.36],
[0.62, 3.10, -0.06],
[2.42, 2.27, 0.02],
[3.76, 0.18, 0.12]
], 0.075, material.hyphaLight, 44);
const domeFront = addTube([
[-3.48, 0.03, 0.96],
[-3.35, 1.38, 1.03],
[-2.55, 2.46, 0.91],
[-0.72, 2.87, 0.63],
[1.20, 2.43, 0.43],
[2.64, 1.45, 0.22],
[3.66, 0.16, 0.18]
], 0.062, material.hypha, 42);
const domeMiddle = addTube([
[-3.30, 0.00, 0.06],
[-3.20, 1.22, 0.05],
[-2.60, 2.28, 0.02],
[-1.10, 2.92, 0.02],
[0.52, 2.86, 0.00],
[2.08, 2.08, 0.03],
[3.48, 0.12, 0.12]
], 0.052, material.hyphaDark, 42);
// Cross-members turn the arches into a surrounding supporting mesh.
for (const x of [-2.72, -1.30, 0.45, 2.05]) {
const y = 2.50 - Math.max(0, x) * 0.12;
addTube([
[x, y + 0.10, -0.78],
[x + 0.03, y + 0.19, 0.05],
[x, y + 0.08, 0.88]
], 0.043, material.hypha, 18);
}
// Upright and diagonal strands visually support the cell cluster.
addTube([
[-2.93, -0.05, 0.82],
[-2.90, 0.45, 0.80],
[-2.72, 1.04, 0.77]
], 0.105, material.hyphaDark, 18);
addTube([
[-0.66, -0.04, 0.84],
[-0.72, 0.44, 0.80],
[-0.72, 0.94, 0.72]
], 0.105, material.hyphaDark, 18);
addTube([
[-2.92, -0.03, -0.82],
[-2.85, 0.44, -0.82],
[-2.70, 1.00, -0.76]
], 0.095, material.hypha, 18);
// Branching fungal "cradle" at the carbon receiving end.
addTube([
[1.88, -0.03, -0.91],
[2.18, 0.63, -1.05],
[3.02, 1.03, -0.77],
[3.84, 0.27, -0.48]
], 0.135, material.hypha, 28);
addTube([
[1.88, -0.02, 0.88],
[2.18, 0.62, 1.04],
[3.02, 1.01, 0.80],
[3.85, 0.24, 0.48]
], 0.135, material.hypha, 28);
addTube([
[2.35, 0.99, -0.90],
[2.66, 1.24, -0.18],
[2.37, 1.02, 0.90]
], 0.092, material.hyphaLight, 20);
addTube([
[3.03, 1.00, -0.72],
[3.25, 1.72, -0.58],
[3.05, 2.27, -0.76],
[2.78, 2.58, -1.02]
], 0.080, material.hyphaLight, 25);
addTube([
[3.03, 1.00, 0.72],
[3.38, 1.54, 0.66],
[3.52, 2.15, 0.31]
], 0.075, material.hypha, 24);
const junctionPositions = [
V(-2.72, 2.49, 0.86),
V(-1.25, 2.87, 0.62),
V(0.48, 2.85, 0.00),
V(2.10, 2.05, 0.04),
V(2.66, 1.22, -0.18),
V(3.03, 1.01, 0.00),
V(3.22, 1.58, 0.61),
V(-3.24, 1.38, 1.02),
V(-2.60, 0.55, 0.78)
];
junctionPositions.forEach((p, index) => {
addNode(p, index % 3 === 0 ? 0.145 : 0.115);
});
// ---------------------------------------------------------------------
// Retained moisture
// ---------------------------------------------------------------------
const waterPool = new THREE.Mesh(
new THREE.CircleGeometry(0.57, 10),
material.water
);
waterPool.rotation.x = -Math.PI / 2;
waterPool.position.set(2.95, 0.17, 0.20);
waterPool.scale.set(1.35, 0.72, 1);
scene.add(waterPool);
const waterRing = new THREE.Mesh(
new THREE.TorusGeometry(0.45, 0.015, 4, 20),
new THREE.MeshBasicMaterial({
color: 0x8bd7e5,
transparent: true,
opacity: 0.7
})
);
waterRing.rotation.x = Math.PI / 2;
waterRing.position.set(2.95, 0.18, 0.20);
waterRing.scale.set(1.35, 0.72, 1);
scene.add(waterRing);
const dropletPositions = [
V(-3.18, 1.53, 1.01),
V(-2.57, 2.48, 0.88),
V(-1.27, 2.93, 0.65),
V(0.45, 2.91, 0.02),
V(2.18, 2.12, 0.05),
V(2.70, 1.29, 0.20),
V(3.33, 1.63, 0.62),
V(2.96, 0.50, 0.56),
V(1.95, 0.38, -0.91)
];
const droplets = dropletPositions.map((position, index) => {
const drop = new THREE.Mesh(
new THREE.OctahedronGeometry(index === 6 ? 0.20 : 0.135, 0),
material.water
);
drop.position.copy(position);
drop.scale.set(0.82, 1.42, 0.82);
drop.rotation.y = index * 0.47;
drop.castShadow = true;
drop.userData.baseScale = drop.scale.clone();
drop.userData.phase = index * 0.71;
scene.add(drop);
return drop;
});
// ---------------------------------------------------------------------
// Symbolic carbon-product texture and transfer paths
// ---------------------------------------------------------------------
function makeCarbonTexture() {
const c = document.createElement("canvas");
c.width = 256;
c.height = 256;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, 256, 256);
ctx.beginPath();
for (let i = 0; i < 6; i++) {
const angle = Math.PI / 3 * i - Math.PI / 6;
const x = 128 + Math.cos(angle) * 92;
const y = 128 + Math.sin(angle) * 92;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.closePath();
ctx.fillStyle = "#f0b43b";
ctx.fill();
ctx.lineWidth = 11;
ctx.strokeStyle = "#77501f";
ctx.stroke();
ctx.fillStyle = "#4f371b";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 66px system-ui";
ctx.fillText("C₆", 128, 121);
ctx.font = "800 20px system-ui";
ctx.letterSpacing = "3px";
ctx.fillText("PRODUCT", 128, 174);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
return texture;
}
const carbonTexture = makeCarbonTexture();
const carbonPaths = [
new THREE.CatmullRomCurve3([
V(-2.55, 1.88, -0.35),
V(-1.73, 2.35, 0.05),
V(-0.70, 2.25, 0.43),
V(0.58, 1.78, 0.34),
V(2.43, 1.03, 0.16)
], false, "centripetal"),
new THREE.CatmullRomCurve3([
V(-2.02, 1.37, 0.73),
V(-1.22, 2.04, 0.88),
V(-0.18, 2.04, 0.64),
V(1.02, 1.39, 0.52),
V(2.57, 0.71, 0.36)
], false, "centripetal"),
new THREE.CatmullRomCurve3([
V(-1.35, 1.96, 0.14),
V(-0.58, 2.54, 0.05),
V(0.51, 2.32, -0.13),
V(1.50, 1.67, -0.09),
V(2.82, 1.11, -0.26)
], false, "centripetal"),
new THREE.CatmullRomCurve3([
V(-1.64, 0.97, -0.73),
V(-0.78, 1.74, -0.80),
V(0.20, 1.83, -0.53),
V(1.42, 1.13, -0.44),
V(2.70, 0.60, -0.48)
], false, "centripetal")
];
const carbonTokens = [];
carbonPaths.forEach((curve, pathIndex) => {
const lineGeometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(90)
);
const line = new THREE.Line(
lineGeometry,
new THREE.LineDashedMaterial({
color: 0xd89922,
dashSize: 0.12,
gapSize: 0.09,
transparent: true,
opacity: 0.72,
depthWrite: false
})
);
line.computeLineDistances();
scene.add(line);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.25, 5),
material.gold
);
const arrowPosition = curve.getPointAt(0.70);
const arrowTangent = curve.getTangentAt(0.70).normalize();
arrow.position.copy(arrowPosition);
arrow.quaternion.setFromUnitVectors(V(0, 1, 0), arrowTangent);
arrow.castShadow = true;
scene.add(arrow);
for (let i = 0; i < 3; i++) {
const spriteMaterial = new THREE.SpriteMaterial({
map: carbonTexture,
transparent: true,
depthWrite: false,
depthTest: true
});
const token = new THREE.Sprite(spriteMaterial);
token.scale.set(0.44, 0.44, 0.44);
scene.add(token);
carbonTokens.push({
sprite: token,
curve,
phase: i / 3 + pathIndex * 0.11,
speed: 0.105 + pathIndex * 0.008,
pathIndex
});
}
});
// ---------------------------------------------------------------------
// Visual cue for processes omitted from the partial model
// ---------------------------------------------------------------------
const unknownCurve = new THREE.CatmullRomCurve3([
V(3.05, 1.08, -0.64),
V(3.75, 2.05, -1.22),
V(4.50, 3.10, -1.58),
V(5.05, 3.72, -1.72)
], false, "centripetal");
const unknownLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(unknownCurve.getPoints(60)),
new THREE.LineDashedMaterial({
color: 0x8d9790,
dashSize: 0.11,
gapSize: 0.13,
transparent: true,
opacity: 0.66
})
);
unknownLine.computeLineDistances();
scene.add(unknownLine);
function makeQuestionTexture() {
const c = document.createElement("canvas");
c.width = 128;
c.height = 128;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, 128, 128);
ctx.beginPath();
ctx.arc(64, 64, 48, 0, Math.PI * 2);
ctx.fillStyle = "rgba(115, 126, 118, 0.18)";
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = "#7f8b83";
ctx.stroke();
ctx.fillStyle = "#6c7870";
ctx.font = "800 68px system-ui";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("?", 64, 61);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
const questionSprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: makeQuestionTexture(),
transparent: true,
depthWrite: false
})
);
questionSprite.position.copy(unknownCurve.getPointAt(1));
questionSprite.scale.set(0.72, 0.72, 0.72);
scene.add(questionSprite);
// ---------------------------------------------------------------------
// Labels projected from world-space anchors
// ---------------------------------------------------------------------
const labels = [
{
element: document.querySelector("#label-cells"),
anchor: V(-2.25, 2.73, 0.12),
offset: [-8, -4]
},
{
element: document.querySelector("#label-form"),
anchor: V(0.30, 3.06, -0.15),
offset: [5, -19]
},
{
element: document.querySelector("#label-moisture"),
anchor: V(2.88, 0.76, 0.73),
offset: [58, 14]
},
{
element: document.querySelector("#label-carbon"),
anchor: V(-0.25, 2.24, 0.49),
offset: [0, -33]
},
{
element: document.querySelector("#label-unknown"),
anchor: V(5.00, 3.76, -1.72),
offset: [17, -3]
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const projected = label.anchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "flex" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width + label.offset[0];
const y = (-projected.y * 0.5 + 0.5) * height + label.offset[1];
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
// ---------------------------------------------------------------------
// Direct camera controls — no OrbitControls or addons
// ---------------------------------------------------------------------
const cameraState = {
target: V(0.25, 1.18, 0),
radius: 13.7,
azimuth: 0.49,
polar: 1.13
};
const initialCamera = { ...cameraState, target: cameraState.target.clone() };
function updateCamera() {
const sinPolar = Math.sin(cameraState.polar);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPolar * Math.sin(cameraState.azimuth),
cameraState.target.y +
cameraState.radius * Math.cos(cameraState.polar),
cameraState.target.z +
cameraState.radius * sinPolar * Math.cos(cameraState.azimuth)
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.radius = initialCamera.radius;
cameraState.azimuth = initialCamera.azimuth;
cameraState.polar = initialCamera.polar;
cameraState.target.copy(initialCamera.target);
updateCamera();
}
const pointers = new Map();
let pinchDistance = 0;
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const current = { x: event.clientX, y: event.clientY };
pointers.set(event.pointerId, current);
if (pointers.size === 1) {
const dx = current.x - previous.x;
const dy = current.y - previous.y;
cameraState.azimuth -= dx * 0.005;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + dy * 0.005,
0.48,
1.43
);
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pinchDistance > 0 && distance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (pinchDistance / distance),
8.3,
20
);
}
pinchDistance = distance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
8.3,
20
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("contextmenu", event => event.preventDefault());
document.querySelector("#reset-view").addEventListener("click", resetCamera);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
let playing = true;
let simulationTime = 0;
const motionButton = document.querySelector("#toggle-motion");
motionButton.addEventListener("click", () => {
playing = !playing;
motionButton.textContent = playing ? "Pause motion" : "Resume motion";
motionButton.setAttribute("aria-pressed", String(!playing));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) simulationTime += delta;
for (const token of carbonTokens) {
const u = (simulationTime * token.speed + token.phase) % 1;
const position = token.curve.getPointAt(u);
token.sprite.position.copy(position);
const pulse = 0.94 + Math.sin(
simulationTime * 4.2 + token.phase * Math.PI * 2
) * 0.07;
token.sprite.scale.set(0.44 * pulse, 0.44 * pulse, 0.44 * pulse);
const fade = Math.min(1, u * 10, (1 - u) * 10);
token.sprite.material.opacity = 0.35 + fade * 0.65;
}
for (const drop of droplets) {
const pulse = 1 + Math.sin(
simulationTime * 1.9 + drop.userData.phase
) * 0.07;
drop.scale.copy(drop.userData.baseScale).multiplyScalar(pulse);
drop.position.y += Math.sin(
simulationTime * 1.25 + drop.userData.phase
) * 0.00045;
}
waterRing.material.opacity = 0.58 + Math.sin(simulationTime * 1.7) * 0.12;
questionSprite.position.y = 3.72 + Math.sin(simulationTime * 1.15) * 0.09;
updateLabels();
renderer.render(scene, camera);
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
updateCamera();
updateLabels();
loading.remove();
animate();
</script>
</body>
</html>
```