Prompt specification
Build or customize the Three.js 3D scene "Two pollen transport mechanisms" 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: Two pollen transport mechanisms
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-pollen-transport-mechanisms-x0766
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: two pollen transport mechanisms. Animate symbolic pollen moving through wind from one display and via an insect contact path in another; keep source and receiving structures visibly matched. Return one self-contained HTML file.
Working Three.js Starter (two-pollen-transport-mechanisms-x0766):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Two Pollen Transport Mechanisms</title>
<style>
:root {
color-scheme: dark;
--ink: #eef8f4;
--muted: #a7bbb5;
--glass: rgba(8, 23, 28, 0.76);
--line: rgba(214, 240, 229, 0.16);
--pollen: #ffb545;
--wind: #62d7ef;
--insect: #f49b63;
--receptacle: #79e5b2;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #07131a;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active { cursor: grabbing; }
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 42%, transparent 48%, rgba(2, 8, 12, 0.38) 100%),
linear-gradient(to bottom, rgba(2, 9, 13, 0.38), transparent 28%, transparent 72%, rgba(2, 9, 13, 0.46));
z-index: 1;
}
header {
position: fixed;
z-index: 5;
top: 0;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 24px;
padding: 26px 30px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: #9ebcb4;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 720px;
font-size: clamp(25px, 3.4vw, 48px);
line-height: 0.98;
font-weight: 680;
letter-spacing: -0.045em;
text-wrap: balance;
text-shadow: 0 3px 24px rgba(0, 0, 0, 0.35);
}
header p {
margin: 12px 0 0;
max-width: 650px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.view-tools {
display: flex;
align-items: center;
gap: 10px;
pointer-events: auto;
}
.hint {
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--glass);
backdrop-filter: blur(12px);
color: #b9cac5;
font-size: 10px;
letter-spacing: 0.04em;
white-space: nowrap;
}
button {
appearance: none;
border: 1px solid rgba(121, 229, 178, 0.34);
border-radius: 999px;
padding: 10px 13px;
background: rgba(17, 48, 43, 0.72);
color: #dff9ef;
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
cursor: pointer;
backdrop-filter: blur(12px);
}
button:hover {
border-color: rgba(121, 229, 178, 0.75);
background: rgba(23, 69, 58, 0.86);
}
#labels {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.tag {
position: absolute;
opacity: 0;
transform: translate(-50%, -50%);
display: flex;
align-items: center;
gap: 7px;
padding: 6px 8px;
border: 1px solid rgba(215, 239, 231, 0.2);
border-radius: 6px;
background: rgba(5, 18, 23, 0.82);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
color: #e5f2ed;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.09em;
line-height: 1;
text-transform: uppercase;
white-space: nowrap;
transition: opacity 160ms ease;
backdrop-filter: blur(8px);
}
.tag.route {
border-color: transparent;
background: transparent;
box-shadow: none;
color: #b9d4cd;
font-size: 8px;
letter-spacing: 0.15em;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--pollen);
box-shadow: 0 0 10px rgba(255, 181, 69, 0.75);
}
.dot.receiver {
background: var(--receptacle);
box-shadow: 0 0 10px rgba(121, 229, 178, 0.7);
}
.notes {
position: fixed;
z-index: 4;
left: 30px;
right: 30px;
bottom: 24px;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
pointer-events: none;
}
.note {
position: relative;
min-height: 112px;
padding: 17px 19px 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: linear-gradient(145deg, rgba(8, 27, 31, 0.9), rgba(7, 19, 25, 0.68));
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(16px);
overflow: hidden;
}
.note::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: var(--accent);
box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 70%, transparent);
}
.note.wind { --accent: var(--wind); }
.note.insect { --accent: var(--insect); }
.note-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
margin-bottom: 7px;
}
.note-kicker {
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.matched {
color: #90aaa2;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.note h2 {
margin: 0 0 5px;
font-size: 17px;
font-weight: 660;
letter-spacing: -0.02em;
}
.note p {
max-width: 560px;
margin: 0;
color: #a9bdb7;
font-size: 11px;
line-height: 1.45;
}
.legend {
position: fixed;
z-index: 4;
left: 50%;
bottom: 157px;
transform: translateX(-50%);
display: flex;
gap: 16px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(5, 18, 23, 0.72);
color: #a9bdb7;
font-size: 9px;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(10px);
}
.legend span {
display: flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.legend i {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 50%;
}
.legend .pollen { background: var(--pollen); }
.legend .receptacle { background: var(--receptacle); }
.legend .route { background: var(--wind); }
@media (max-width: 760px) {
header {
padding: 18px;
}
header p {
display: none;
}
.hint { display: none; }
.notes {
left: 12px;
right: 12px;
bottom: 12px;
gap: 8px;
}
.note {
min-height: 105px;
padding: 13px 12px;
}
.note h2 { font-size: 14px; }
.note p { font-size: 10px; }
.matched { display: none; }
.legend { display: none; }
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive 3D comparison of wind and insect pollen transport"></main>
<div class="vignette"></div>
<header>
<div>
<div class="eyebrow">Plant reproductive ecology · comparative exhibit</div>
<h1>Two pollen transport mechanisms</h1>
<p>
The same matched floral architecture is shown in both exhibits:
pollen leaves a source anther and reaches a receptive stigma.
</p>
</div>
<div class="view-tools">
<div class="hint">Drag to orbit · Scroll to zoom</div>
<button id="reset" type="button">Reset view</button>
</div>
</header>
<div id="labels" aria-hidden="true">
<div class="tag" id="tag-wind-source"><i class="dot"></i>Source · anther</div>
<div class="tag" id="tag-wind-target"><i class="dot receiver"></i>Receiver · stigma</div>
<div class="tag route" id="tag-wind-route">Wind-borne route</div>
<div class="tag" id="tag-insect-source"><i class="dot"></i>Source · anther</div>
<div class="tag" id="tag-insect-target"><i class="dot receiver"></i>Receiver · stigma</div>
<div class="tag route" id="tag-insect-route">Insect contact route</div>
</div>
<div class="legend" aria-hidden="true">
<span><i class="pollen"></i> pollen</span>
<span><i class="receptacle"></i> receptive stigma</span>
<span><i class="route"></i> transport path</span>
</div>
<div class="notes">
<section class="note wind">
<div class="note-top">
<div class="note-kicker">01 · Wind / anemophily</div>
<div class="matched">Matched floral pair</div>
</div>
<h2>Airborne transfer</h2>
<p>
Loose pollen is released from the source anther, drifts through the air,
and settles onto the matching receptive stigma.
</p>
</section>
<section class="note insect">
<div class="note-top">
<div class="note-kicker">02 · Insect / entomophily</div>
<div class="matched">Matched floral pair</div>
</div>
<h2>Contact-mediated transfer</h2>
<p>
The insect contacts the anther, carries adhering pollen to the second flower,
and deposits it directly onto the receptive stigma.
</p>
</section>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "3D pollen transport comparison");
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07131a);
scene.fog = new THREE.Fog(0x07131a, 18, 38);
const camera = new THREE.PerspectiveCamera(
47,
window.innerWidth / window.innerHeight,
0.1,
80
);
const hemisphere = new THREE.HemisphereLight(0xb8ecff, 0x16261d, 2.25);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xffe5b8, 3.1);
key.position.set(4, 11, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 10;
key.shadow.camera.bottom = -7;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.bias = -0.0004;
scene.add(key);
const rim = new THREE.DirectionalLight(0x6ad9ff, 1.6);
rim.position.set(-9, 6, -7);
scene.add(rim);
const warmPoint = new THREE.PointLight(0xffa95e, 13, 12, 2);
warmPoint.position.set(6, 5, 4);
scene.add(warmPoint);
const coolPoint = new THREE.PointLight(0x56d9ff, 11, 12, 2);
coolPoint.position.set(-6, 4, 2);
scene.add(coolPoint);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
new THREE.MeshStandardMaterial({
color: 0x0a181d,
roughness: 0.96,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.25;
floor.receiveShadow = true;
scene.add(floor);
const LEFT = -3.85;
const RIGHT = 3.85;
const FLOWER_OFFSET = 1.12;
const palette = {
stem: 0x3e7656,
stemLight: 0x5c9c68,
petalA: 0xf3d6c6,
petalB: 0xffeadf,
petalC: 0xeab8aa,
disk: 0xcf705e,
pollen: 0xffb545,
pollenDark: 0xd67a2d,
receptive: 0x79e5b2,
wind: 0x62d7ef,
insect: 0xf49b63,
base: 0x13272c,
baseTop: 0x1a3438
};
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.76,
metalness: options.metalness ?? 0.02,
flatShading: true,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
side: options.side ?? THREE.FrontSide,
depthWrite: options.depthWrite ?? true
});
}
function addMesh(parent, geometry, material, position, scale, rotation) {
const mesh = new THREE.Mesh(geometry, material);
if (position) mesh.position.set(...position);
if (scale) mesh.scale.set(...scale);
if (rotation) mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function rodBetween(parent, a, b, radius, material, segments = 5) {
const direction = new THREE.Vector3().subVectors(b, a);
const geometry = new THREE.CylinderGeometry(radius, radius, direction.length(), segments);
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.clone().normalize()
);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function createDisplay(x, accentColor) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const base = addMesh(
group,
new THREE.CylinderGeometry(3.08, 3.2, 0.4, 10),
standard(palette.base, { roughness: 0.9 }),
[0, 0, 0]
);
const top = addMesh(
group,
new THREE.CylinderGeometry(3.01, 3.03, 0.09, 10),
standard(palette.baseTop, { roughness: 0.84 }),
[0, 0.245, 0]
);
const rim = addMesh(
group,
new THREE.TorusGeometry(3.0, 0.035, 4, 10),
standard(accentColor, {
roughness: 0.4,
emissive: accentColor,
emissiveIntensity: 0.42
}),
[0, 0.295, 0],
null,
[Math.PI / 2, 0, 0]
);
const inset = addMesh(
group,
new THREE.CylinderGeometry(2.76, 2.76, 0.025, 10),
standard(0x102329, { roughness: 0.94 }),
[0, 0.305, 0]
);
base.castShadow = true;
top.castShadow = true;
rim.castShadow = false;
inset.castShadow = false;
return group;
}
createDisplay(LEFT, palette.wind);
createDisplay(RIGHT, palette.insect);
const sharedStemMat = standard(palette.stem, { roughness: 0.88 });
const sharedLeafMat = standard(palette.stemLight, { roughness: 0.88 });
const petalMaterials = [
standard(palette.petalA, { roughness: 0.84 }),
standard(palette.petalB, { roughness: 0.84 }),
standard(palette.petalC, { roughness: 0.84 })
];
const stemGeometry = new THREE.CylinderGeometry(0.075, 0.095, 1.43, 7);
const leafGeometry = new THREE.SphereGeometry(1, 5, 3);
const petalGeometry = new THREE.SphereGeometry(1, 6, 4);
const diskGeometry = new THREE.CylinderGeometry(0.32, 0.34, 0.14, 12);
const sepalGeometry = new THREE.ConeGeometry(0.31, 0.28, 8);
const stalkGeometry = new THREE.CylinderGeometry(0.022, 0.028, 0.15, 5);
const sourceTipGeometry = new THREE.IcosahedronGeometry(0.058, 0);
const targetTipGeometry = new THREE.IcosahedronGeometry(0.05, 0);
function createFlower(worldX, isSource, z = 0.1) {
const group = new THREE.Group();
group.position.set(worldX, 0, z);
scene.add(group);
addMesh(group, stemGeometry, sharedStemMat, [0, 0.98, 0]);
const leftLeaf = addMesh(
group,
leafGeometry,
sharedLeafMat,
[-0.22, 0.79, 0],
[0.22, 0.065, 0.51],
[0.1, -0.48, -0.42]
);
const rightLeaf = addMesh(
group,
leafGeometry,
sharedLeafMat,
[0.24, 1.18, 0.02],
[0.2, 0.06, 0.47],
[-0.08, 0.62, 0.4]
);
leftLeaf.castShadow = rightLeaf.castShadow = true;
addMesh(
group,
sepalGeometry,
sharedStemMat,
[0, 1.72, 0],
null,
[0, 0, Math.PI]
);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2 + Math.PI / 8;
addMesh(
group,
petalGeometry,
petalMaterials[i % petalMaterials.length],
[Math.sin(angle) * 0.48, 1.88, Math.cos(angle) * 0.48],
[0.27, 0.105, 0.64],
[0, angle, 0]
);
}
const centerMaterial = standard(palette.disk, {
roughness: 0.72,
emissive: isSource ? palette.pollenDark : 0x246d55,
emissiveIntensity: isSource ? 0.18 : 0.14
});
const center = addMesh(group, diskGeometry, centerMaterial, [0, 2.01, 0]);
const tipMaterial = standard(isSource ? palette.pollen : palette.receptive, {
roughness: 0.52,
emissive: isSource ? palette.pollenDark : palette.receptive,
emissiveIntensity: isSource ? 0.35 : 0.42
});
const tipGeometry = isSource ? sourceTipGeometry : targetTipGeometry;
const tips = [];
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const px = Math.sin(angle) * 0.16;
const pz = Math.cos(angle) * 0.16;
addMesh(
group,
stalkGeometry,
sharedStemMat,
[px, 2.135, pz]
);
const tip = addMesh(
group,
tipGeometry,
tipMaterial,
[px, 2.23, pz]
);
tips.push(tip);
}
const foot = addMesh(
group,
new THREE.CylinderGeometry(0.26, 0.31, 0.12, 8),
standard(0x29463e),
[0, 0.35, 0]
);
foot.receiveShadow = true;
return {
group,
center,
centerMaterial,
tipMaterial,
tips,
anchor: new THREE.Vector3(worldX, 2.25, z)
};
}
const leftSource = createFlower(LEFT - FLOWER_OFFSET, true);
const leftReceiver = createFlower(LEFT + FLOWER_OFFSET, false);
const rightSource = createFlower(RIGHT - FLOWER_OFFSET, true);
const rightReceiver = createFlower(RIGHT + FLOWER_OFFSET, false);
function makeRoute(curve, color) {
const group = new THREE.Group();
scene.add(group);
const line = new THREE.Mesh(
new THREE.TubeGeometry(curve, 72, 0.018, 4, false),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.26,
depthWrite: false
})
);
group.add(line);
const arrowMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.8,
depthWrite: false
});
for (const t of [0.28, 0.52, 0.76]) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.23, 5),
arrowMaterial
);
arrow.position.copy(curve.getPointAt(t));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangentAt(t).normalize()
);
group.add(arrow);
}
return group;
}
const windCurve = new THREE.CatmullRomCurve3([
leftSource.anchor.clone(),
leftSource.anchor.clone().add(new THREE.Vector3(0.16, 1.05, -0.2)),
leftReceiver.anchor.clone().add(new THREE.Vector3(-0.22, 1.28, -0.2)),
leftReceiver.anchor.clone()
]);
const insectCurve = new THREE.CatmullRomCurve3([
rightSource.anchor.clone().add(new THREE.Vector3(0, 0.05, 0.34)),
rightSource.anchor.clone().add(new THREE.Vector3(0.45, 0.82, 0.46)),
rightReceiver.anchor.clone().add(new THREE.Vector3(-0.56, 1.02, 0.46)),
rightReceiver.anchor.clone().add(new THREE.Vector3(0, 0.05, 0.34))
]);
makeRoute(windCurve, palette.wind);
makeRoute(insectCurve, palette.insect);
const pollenGeometry = new THREE.IcosahedronGeometry(0.057, 0);
const pollenMaterial = standard(palette.pollen, {
roughness: 0.5,
emissive: palette.pollenDark,
emissiveIntensity: 0.48
});
const windPollen = [];
for (let i = 0; i < 18; i++) {
const grain = new THREE.Mesh(pollenGeometry, pollenMaterial);
grain.castShadow = true;
scene.add(grain);
windPollen.push({
mesh: grain,
offset: i / 18,
scale: 0.68 + ((i * 7) % 5) * 0.08,
turn: i * 0.73
});
}
function makePollenCluster(anchor, count, spread, seedOffset) {
const group = new THREE.Group();
group.position.copy(anchor);
scene.add(group);
const grains = [];
for (let i = 0; i < count; i++) {
const angle = i * 2.399 + seedOffset;
const radius = spread * (0.35 + ((i * 3) % 5) / 7);
const grain = new THREE.Mesh(pollenGeometry, pollenMaterial);
grain.position.set(
Math.cos(angle) * radius,
0.045 + (i % 2) * 0.025,
Math.sin(angle) * radius
);
grain.scale.setScalar(0.72);
group.add(grain);
grains.push(grain);
}
return { group, grains };
}
const windDeposit = makePollenCluster(
leftReceiver.anchor.clone().add(new THREE.Vector3(0, 0.03, 0)),
7,
0.24,
0.4
);
const insectDeposit = makePollenCluster(
rightReceiver.anchor.clone().add(new THREE.Vector3(0, 0.03, 0)),
7,
0.24,
1.7
);
function makeContactRing(anchor, color) {
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.5,
depthWrite: false
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.018, 4, 18),
material
);
ring.position.copy(anchor);
ring.rotation.x = Math.PI / 2;
scene.add(ring);
return ring;
}
const sourceRing = makeContactRing(rightSource.anchor, palette.pollen);
const receiverRing = makeContactRing(rightReceiver.anchor, palette.receptive);
function createBee() {
const bee = new THREE.Group();
scene.add(bee);
const yellow = standard(0xe7a52d, { roughness: 0.62 });
const dark = standard(0x25231e, { roughness: 0.72 });
const wingMaterial = standard(0xdff7f0, {
roughness: 0.28,
transparent: true,
opacity: 0.78,
side: THREE.DoubleSide,
depthWrite: false
});
addMesh(
bee,
new THREE.SphereGeometry(1, 7, 5),
yellow,
[-0.2, 0, 0],
[0.42, 0.26, 0.27]
);
addMesh(
bee,
new THREE.SphereGeometry(1, 7, 5),
yellow,
[0.1, 0.015, 0],
[0.28, 0.27, 0.26]
);
addMesh(
bee,
new THREE.SphereGeometry(1, 7, 5),
dark,
[0.39, 0.01, 0],
[0.24, 0.23, 0.23]
);
for (const x of [-0.42, -0.24, -0.07]) {
const stripe = new THREE.Mesh(
new THREE.TorusGeometry(0.19, 0.035, 4, 10),
dark
);
stripe.position.set(x, 0, 0);
stripe.rotation.y = Math.PI / 2;
stripe.castShadow = true;
bee.add(stripe);
}
const eyeMaterial = standard(0x101416, { roughness: 0.25 });
addMesh(bee, new THREE.SphereGeometry(0.052, 6, 4), eyeMaterial, [0.47, 0.1, 0.12]);
addMesh(bee, new THREE.SphereGeometry(0.052, 6, 4), eyeMaterial, [0.47, 0.1, -0.12]);
rodBetween(
bee,
new THREE.Vector3(0.48, 0.12, 0.08),
new THREE.Vector3(0.68, 0.26, 0.17),
0.012,
dark
);
rodBetween(
bee,
new THREE.Vector3(0.48, 0.12, -0.08),
new THREE.Vector3(0.68, 0.26, -0.17),
0.012,
dark
);
const wingPivots = [];
for (const side of [-1, 1]) {
const pivot = new THREE.Group();
pivot.position.set(-0.03, 0.18, side * 0.12);
bee.add(pivot);
const wing = addMesh(
pivot,
new THREE.SphereGeometry(1, 6, 3),
wingMaterial,
[-0.16, 0, side * 0.08],
[0.34, 0.035, 0.16],
[0, side * 0.16, side * 0.15]
);
wing.castShadow = false;
wingPivots.push({ pivot, side });
}
const legMaterial = standard(0x3c3020, { roughness: 0.8 });
for (const x of [-0.27, 0.0, 0.22]) {
for (const side of [-1, 1]) {
rodBetween(
bee,
new THREE.Vector3(x, -0.12, side * 0.14),
new THREE.Vector3(x + 0.08, -0.36, side * 0.23),
0.012,
legMaterial
);
}
}
const attachedPollen = [];
const attachmentPositions = [
[-0.34, 0.18, 0.16],
[-0.22, 0.22, -0.14],
[-0.09, 0.2, 0.17],
[0.02, 0.17, -0.16],
[-0.28, -0.12, 0.18],
[-0.05, -0.15, -0.18]
];
for (const p of attachmentPositions) {
const grain = new THREE.Mesh(pollenGeometry, pollenMaterial);
grain.position.set(...p);
grain.scale.setScalar(0);
bee.add(grain);
attachedPollen.push(grain);
}
return { bee, wingPivots, attachedPollen };
}
const beeRig = createBee();
const returnCurve = new THREE.CatmullRomCurve3([
rightReceiver.anchor.clone().add(new THREE.Vector3(0, 0.05, 0.34)),
rightReceiver.anchor.clone().add(new THREE.Vector3(-0.25, 1.35, -0.35)),
rightSource.anchor.clone().add(new THREE.Vector3(0.3, 1.55, -0.4)),
rightSource.anchor.clone().add(new THREE.Vector3(0, 0.05, 0.34))
]);
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function smoothstep(min, max, value) {
const t = clamp((value - min) / (max - min), 0, 1);
return t * t * (3 - 2 * t);
}
const controls = {
theta: 0.04,
phi: 1.02,
radius: 15.5,
target: new THREE.Vector3(0, 1.25, 0),
dragging: false,
lastX: 0,
lastY: 0
};
function homeRadius() {
const aspect = window.innerWidth / window.innerHeight;
return aspect < 0.85 ? 28 : aspect < 1.25 ? 20 : 15.5;
}
function resetView() {
controls.theta = 0.04;
controls.phi = 1.02;
controls.radius = homeRadius();
}
controls.radius = homeRadius();
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
controls.theta -= dx * 0.006;
controls.phi = clamp(controls.phi - dy * 0.005, 0.52, 1.36);
});
function endDrag(event) {
controls.dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = clamp(controls.radius * Math.exp(event.deltaY * 0.001), 9, 34);
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", resetView);
function updateCamera() {
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);
}
const tagDefinitions = [
{
element: document.getElementById("tag-wind-source"),
anchor: leftSource.anchor.clone().add(new THREE.Vector3(0, 0.5, 0))
},
{
element: document.getElementById("tag-wind-target"),
anchor: leftReceiver.anchor.clone().add(new THREE.Vector3(0, 0.5, 0))
},
{
element: document.getElementById("tag-wind-route"),
anchor: windCurve.getPointAt(0.52).add(new THREE.Vector3(0, 0.38, 0))
},
{
element: document.getElementById("tag-insect-source"),
anchor: rightSource.anchor.clone().add(new THREE.Vector3(0, 0.52, 0))
},
{
element: document.getElementById("tag-insect-target"),
anchor: rightReceiver.anchor.clone().add(new THREE.Vector3(0, 0.52, 0))
},
{
element: document.getElementById("tag-insect-route"),
anchor: insectCurve.getPointAt(0.5).add(new THREE.Vector3(0, 0.42, 0))
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const tag of tagDefinitions) {
projected.copy(tag.anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
tag.element.style.opacity = visible ? "1" : "0";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
tag.element.style.left = `${x}px`;
tag.element.style.top = `${y}px`;
}
}
const clock = new THREE.Clock();
const up = new THREE.Vector3(0, 1, 0);
const forward = new THREE.Vector3(1, 0, 0);
const beeQuaternion = new THREE.Quaternion();
const beeTangent = new THREE.Vector3(1, 0, 0);
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateCamera();
for (const particle of windPollen) {
const t = (elapsed * 0.19 + particle.offset) % 1;
const position = windCurve.getPointAt(t);
const envelope = Math.sin(Math.PI * t);
position.x += Math.sin(elapsed * 2.4 + particle.turn) * 0.055 * envelope;
position.z += Math.cos(elapsed * 2.0 + particle.turn * 1.4) * 0.07 * envelope;
position.y += Math.sin(elapsed * 2.7 + particle.turn) * 0.035 * envelope;
particle.mesh.position.copy(position);
const visibility = smoothstep(0, 0.08, t) * (1 - smoothstep(0.9, 1, t));
particle.mesh.scale.setScalar(particle.scale * visibility);
particle.mesh.rotation.set(
elapsed * 0.8 + particle.turn,
elapsed * 1.1 + particle.turn,
elapsed * 0.6
);
}
const windArrivalPulse = 0.78 + Math.sin(elapsed * 2.8) * 0.14;
windDeposit.group.scale.setScalar(windArrivalPulse);
windDeposit.group.rotation.y = elapsed * 0.08;
leftReceiver.tipMaterial.emissiveIntensity = 0.42 + windArrivalPulse * 0.18;
const cycle = (elapsed % 12) / 12;
const collection = smoothstep(0.055, 0.16, cycle);
const deposition = smoothstep(0.71, 0.79, cycle);
const depositedFade = 1 - smoothstep(0.94, 0.995, cycle);
let beePosition;
let beeDirection = new THREE.Vector3(1, 0, 0);
if (cycle < 0.16) {
beePosition = insectCurve.getPointAt(0).clone();
beePosition.y += Math.sin(elapsed * 8) * 0.025;
} else if (cycle < 0.72) {
const t = (cycle - 0.16) / 0.56;
beePosition = insectCurve.getPointAt(t);
beeDirection = insectCurve.getTangentAt(t).normalize();
} else if (cycle < 0.80) {
beePosition = insectCurve.getPointAt(1).clone();
beePosition.y += Math.sin(elapsed * 9) * 0.02;
} else if (cycle < 0.98) {
const t = (cycle - 0.80) / 0.18;
beePosition = returnCurve.getPointAt(t);
beeDirection = returnCurve.getTangentAt(t).normalize();
} else {
beePosition = insectCurve.getPointAt(0).clone();
}
beeRig.bee.position.copy(beePosition);
beeTangent.copy(beeDirection).normalize();
beeQuaternion.setFromUnitVectors(forward, beeTangent);
beeRig.bee.quaternion.slerp(beeQuaternion, 0.14);
const wingBeat = Math.sin(elapsed * 29);
for (const { pivot, side } of beeRig.wingPivots) {
pivot.rotation.x = wingBeat * 0.34 * side;
pivot.rotation.z = 0.12 + wingBeat * 0.08 * side;
}
beeRig.attachedPollen.forEach((grain, index) => {
const stagger = clamp((collection - index * 0.025) / 0.55, 0, 1);
grain.scale.setScalar(stagger * (1 - deposition));
});
insectDeposit.group.scale.setScalar(deposition * depositedFade);
insectDeposit.group.rotation.y = -elapsed * 0.1;
const sourceContact = 1 - smoothstep(0.08, 0.2, cycle);
const receiverContact = smoothstep(0.68, 0.74, cycle) *
(1 - smoothstep(0.8, 0.88, cycle));
sourceRing.material.opacity = 0.18 + sourceContact * 0.65;
sourceRing.scale.setScalar(0.86 + sourceContact * 0.38);
sourceRing.rotation.z = elapsed * 0.35;
receiverRing.material.opacity = 0.18 + receiverContact * 0.65;
receiverRing.scale.setScalar(0.86 + receiverContact * 0.38);
receiverRing.rotation.z = -elapsed * 0.35;
rightSource.tipMaterial.emissiveIntensity = 0.35 + sourceContact * 0.75;
rightReceiver.tipMaterial.emissiveIntensity = 0.42 + receiverContact * 0.7;
leftSource.tipMaterial.emissiveIntensity = 0.35 + Math.sin(elapsed * 2.3) * 0.13;
updateLabels();
renderer.render(scene, camera);
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
animate();
</script>
</body>
</html>
```