Prompt specification
Build or customize the Three.js 3D scene "Bee pollen-carrying leg study" 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: Bee pollen-carrying leg study
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/bee-pollen-carrying-leg-study-x0653
Scene Description Prompt:
A stylized honeybee beside an enlarged hind-leg pollen basket and flower anthers, with distinct pollen clusters. Three.js from cdnjs, one HTML file.
Working Three.js Starter (bee-pollen-carrying-leg-study-x0653):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Honeybee Pollen Anatomy</title>
<style>
:root {
--ink: #30291f;
--muted: #756a58;
--paper: #f4ead7;
--gold: #e9a817;
--line: rgba(73, 58, 35, 0.25);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 72% 18%, #fffaf0 0%, transparent 42%),
linear-gradient(145deg, #f8f0df, #eadcc3);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.heading {
position: absolute;
top: clamp(24px, 4vw, 58px);
left: clamp(24px, 5vw, 78px);
max-width: 340px;
}
.eyebrow {
display: block;
margin-bottom: 10px;
color: #8b681d;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 4.4vw, 66px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
}
.heading p {
max-width: 280px;
margin: 18px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.scale {
position: absolute;
right: clamp(22px, 4vw, 60px);
top: clamp(24px, 4vw, 58px);
display: grid;
justify-items: end;
gap: 7px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.scale-line {
width: 76px;
height: 7px;
border-right: 1px solid var(--line);
border-left: 1px solid var(--line);
background: linear-gradient(
to right,
var(--gold) 0 33%,
transparent 33% 38%,
var(--gold) 38% 71%,
transparent 71% 76%,
var(--gold) 76% 100%
);
}
.pin {
position: absolute;
display: flex;
flex-direction: column;
gap: 3px;
padding: 9px 12px 10px;
border: 1px solid rgba(80, 61, 30, 0.2);
border-radius: 3px;
background: rgba(255, 250, 239, 0.82);
box-shadow: 0 8px 24px rgba(71, 49, 19, 0.08);
opacity: 0;
transform: translate(-50%, -115%);
transition: opacity 250ms ease;
backdrop-filter: blur(8px);
}
.pin::before {
position: absolute;
bottom: -27px;
left: 50%;
width: 1px;
height: 26px;
background: rgba(72, 54, 29, 0.42);
content: "";
}
.pin::after {
position: absolute;
bottom: -30px;
left: calc(50% - 3px);
width: 6px;
height: 6px;
border: 1px solid rgba(72, 54, 29, 0.55);
border-radius: 50%;
background: var(--paper);
content: "";
}
.pin strong {
color: #49391f;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.pin small {
color: #8b795d;
font-family: Georgia, "Times New Roman", serif;
font-size: 12px;
font-style: italic;
}
.hint {
position: absolute;
bottom: 24px;
left: 50%;
padding: 8px 13px;
border: 1px solid rgba(78, 59, 30, 0.14);
border-radius: 999px;
background: rgba(255, 250, 239, 0.68);
color: #796c58;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
transform: translateX(-50%);
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
background: var(--paper);
color: #8c681f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
@media (max-width: 700px) {
.heading {
top: 22px;
left: 22px;
}
.heading p,
.scale {
display: none;
}
h1 {
max-width: 240px;
font-size: 38px;
}
.pin {
padding: 7px 9px;
}
.hint {
bottom: 16px;
white-space: nowrap;
}
}
</style>
</head>
<body>
<div id="loading">Preparing pollen study</div>
<div class="ui">
<header class="heading">
<span class="eyebrow">Apis / Botanical detail</span>
<h1>Honeybee<br>pollen anatomy</h1>
<p>
A stylized honeybee, an enlarged hind-leg pollen basket, and
pollen-bearing flower anthers rendered as a warm botanical study.
</p>
</header>
<div class="scale">
<span>Enlarged specimen</span>
<span class="scale-line"></span>
<span>Corbicula / 6×</span>
</div>
<div class="pin" id="basketPin">
<strong>Corbicula</strong>
<small>enlarged pollen basket</small>
</div>
<div class="pin" id="antherPin">
<strong>Flower anther</strong>
<small>distinct pollen clusters</small>
</div>
<div class="hint">Drag to orbit · Scroll or pinch to zoom</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, camera, and direct camera controls
// -------------------------------------------------------------------------
const loading = document.querySelector("#loading");
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",
"Interactive three-dimensional honeybee pollen anatomy study"
);
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf4ead7);
scene.fog = new THREE.Fog(0xf4ead7, 10, 19);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
40
);
const target = new THREE.Vector3(-0.05, 1.12, 0);
const controls = {
theta: 0.31,
phi: 1.07,
radius: window.innerWidth < 700 ? 12.7 : 8.35,
desiredTheta: 0.31,
desiredPhi: 1.07,
desiredRadius: window.innerWidth < 700 ? 12.7 : 8.35
};
const pointers = new Map();
let previousPinchDistance = 0;
function updateCamera(dt) {
const damping = 1 - Math.pow(0.001, dt);
controls.theta = THREE.MathUtils.lerp(
controls.theta,
controls.desiredTheta,
damping
);
controls.phi = THREE.MathUtils.lerp(
controls.phi,
controls.desiredPhi,
damping
);
controls.radius = THREE.MathUtils.lerp(
controls.radius,
controls.desiredRadius,
damping
);
const sinPhi = Math.sin(controls.phi);
camera.position.set(
target.x + controls.radius * sinPhi * Math.sin(controls.theta),
target.y + controls.radius * Math.cos(controls.phi),
target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(target);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
controls.desiredTheta -= dx * 0.005;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - dy * 0.0045,
0.35,
1.48
);
} 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) {
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius *
(previousPinchDistance / Math.max(distance, 1)),
5.2,
17
);
}
previousPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius * Math.exp(event.deltaY * 0.001),
5.2,
17
);
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
// -------------------------------------------------------------------------
// Lighting and display surface
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x8d7657, 2.15));
const keyLight = new THREE.DirectionalLight(0xfff1d2, 4.2);
keyLight.position.set(-3.5, 7, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.bias = -0.00025;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xd8e8ff, 2.25);
rimLight.position.set(4, 4.5, -5);
scene.add(rimLight);
const fillLight = new THREE.DirectionalLight(0xffd889, 1.1);
fillLight.position.set(4, 1, 4);
scene.add(fillLight);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(5.15, 5.15, 0.1, 96),
new THREE.MeshStandardMaterial({
color: 0xeee2cb,
roughness: 0.94,
metalness: 0
})
);
platform.position.y = -0.07;
platform.receiveShadow = true;
scene.add(platform);
// -------------------------------------------------------------------------
// Shared materials and geometry helpers
// -------------------------------------------------------------------------
const materials = {
beeYellow: new THREE.MeshStandardMaterial({
color: 0xe9a51d,
roughness: 0.55
}),
beeDark: new THREE.MeshStandardMaterial({
color: 0x2d241d,
roughness: 0.52
}),
thorax: new THREE.MeshStandardMaterial({
color: 0xb66c20,
roughness: 0.92
}),
leg: new THREE.MeshStandardMaterial({
color: 0x3b2c20,
roughness: 0.66
}),
eye: new THREE.MeshPhysicalMaterial({
color: 0x11100f,
roughness: 0.08,
metalness: 0.05,
clearcoat: 1,
clearcoatRoughness: 0.05
}),
basket: new THREE.MeshStandardMaterial({
color: 0xd98d19,
roughness: 0.34,
metalness: 0.04
}),
basketInside: new THREE.MeshStandardMaterial({
color: 0x865015,
roughness: 0.78,
side: THREE.DoubleSide
}),
stem: new THREE.MeshStandardMaterial({
color: 0x607849,
roughness: 0.8
}),
leaf: new THREE.MeshStandardMaterial({
color: 0x789257,
roughness: 0.82
}),
anther: new THREE.MeshStandardMaterial({
color: 0xf0b51a,
roughness: 0.64
}),
antherOrange: new THREE.MeshStandardMaterial({
color: 0xe78612,
roughness: 0.68
}),
filament: new THREE.MeshStandardMaterial({
color: 0xe5dca3,
roughness: 0.72
}),
vein: new THREE.MeshBasicMaterial({
color: 0xf7f4df,
transparent: true,
opacity: 0.62,
depthWrite: false
})
};
const pollenMaterials = [
0xf7bf1f,
0xeaa313,
0xffd34a,
0xcf7a0d
].map(
(color) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.83
})
);
const pollenGeometry = new THREE.IcosahedronGeometry(1, 1);
const sphereGeometry = new THREE.SphereGeometry(1, 28, 18);
function addMesh(parent, geometry, material, position, scale) {
const object = new THREE.Mesh(geometry, material);
if (position) object.position.copy(position);
if (scale) object.scale.copy(scale);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function rodBetween(a, b, radius, material, radialSegments = 10) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius * 0.82,
radius,
length,
radialSegments
),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
let randomSeed = 92841;
function random() {
randomSeed |= 0;
randomSeed = (randomSeed + 0x6d2b79f5) | 0;
let t = Math.imul(randomSeed ^ (randomSeed >>> 15), 1 | randomSeed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
}
function randomBetween(min, max) {
return min + (max - min) * random();
}
function createPollenCluster(
parent,
center,
spread,
count,
minSize = 0.035,
maxSize = 0.075
) {
for (let i = 0; i < count; i++) {
const grain = new THREE.Mesh(
pollenGeometry,
pollenMaterials[Math.floor(random() * pollenMaterials.length)]
);
grain.position.set(
center.x + randomBetween(-spread.x, spread.x),
center.y + randomBetween(-spread.y, spread.y),
center.z + randomBetween(-spread.z, spread.z)
);
const size = randomBetween(minSize, maxSize);
grain.scale.set(
size * randomBetween(0.9, 1.35),
size * randomBetween(0.7, 1.05),
size * randomBetween(0.85, 1.2)
);
grain.rotation.set(
randomBetween(0, Math.PI),
randomBetween(0, Math.PI),
randomBetween(0, Math.PI)
);
grain.castShadow = true;
grain.receiveShadow = true;
parent.add(grain);
}
}
// -------------------------------------------------------------------------
// Stylized honeybee
// -------------------------------------------------------------------------
const bee = new THREE.Group();
bee.position.set(0.65, 1.72, 0.03);
bee.rotation.y = -0.13;
bee.rotation.z = -0.045;
scene.add(bee);
const abdomen = addMesh(
bee,
sphereGeometry,
materials.beeYellow,
new THREE.Vector3(0.72, 0, 0),
new THREE.Vector3(1.08, 0.66, 0.61)
);
abdomen.geometry.computeBoundingSphere();
const abdomenCenterX = 0.72;
const abdomenRadiusX = 1.08;
const abdomenRadiusY = 0.66;
[0.12, 0.46, 0.80, 1.14, 1.46].forEach((x) => {
const dx = (x - abdomenCenterX) / abdomenRadiusX;
const crossRadius = abdomenRadiusY * Math.sqrt(Math.max(0.04, 1 - dx * dx));
const stripe = new THREE.Mesh(
new THREE.TorusGeometry(crossRadius, 0.072, 12, 64),
materials.beeDark
);
stripe.rotation.y = Math.PI / 2;
stripe.scale.set(0.9, 1, 1);
stripe.position.x = x;
stripe.castShadow = true;
stripe.receiveShadow = true;
bee.add(stripe);
});
addMesh(
bee,
sphereGeometry,
materials.beeDark,
new THREE.Vector3(1.72, -0.02, 0),
new THREE.Vector3(0.38, 0.5, 0.47)
);
addMesh(
bee,
sphereGeometry,
materials.thorax,
new THREE.Vector3(-0.24, 0.06, 0),
new THREE.Vector3(0.75, 0.67, 0.66)
);
// Fine instanced fuzz gives the thorax a soft, granular silhouette.
const fuzzGeometry = new THREE.IcosahedronGeometry(1, 1);
const fuzzMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
});
const fuzz = new THREE.InstancedMesh(fuzzGeometry, fuzzMaterial, 120);
const fuzzTransform = new THREE.Object3D();
const fuzzColors = [0xc77a1f, 0xe4a72d, 0x9b541a, 0xf0bd42];
for (let i = 0; i < 120; i++) {
const u = randomBetween(-1, 1);
const angle = randomBetween(0, Math.PI * 2);
const radius = Math.sqrt(1 - u * u);
const size = randomBetween(0.027, 0.06);
fuzzTransform.position.set(
-0.24 + Math.cos(angle) * radius * 0.72,
0.06 + u * 0.64,
Math.sin(angle) * radius * 0.63
);
fuzzTransform.scale.set(size, size * randomBetween(1.0, 1.8), size);
fuzzTransform.rotation.set(
randomBetween(0, Math.PI),
randomBetween(0, Math.PI),
randomBetween(0, Math.PI)
);
fuzzTransform.updateMatrix();
fuzz.setMatrixAt(i, fuzzTransform.matrix);
fuzz.setColorAt(
i,
new THREE.Color(fuzzColors[Math.floor(random() * fuzzColors.length)])
);
}
fuzz.instanceMatrix.needsUpdate = true;
if (fuzz.instanceColor) fuzz.instanceColor.needsUpdate = true;
fuzz.castShadow = true;
bee.add(fuzz);
// Head, eyes, antennae, and proboscis.
addMesh(
bee,
sphereGeometry,
materials.beeDark,
new THREE.Vector3(-1.03, 0.02, 0),
new THREE.Vector3(0.55, 0.49, 0.47)
);
[-1, 1].forEach((side) => {
addMesh(
bee,
sphereGeometry,
materials.eye,
new THREE.Vector3(-1.25, 0.13, side * 0.38),
new THREE.Vector3(0.23, 0.29, 0.13)
);
addMesh(
bee,
new THREE.SphereGeometry(1, 16, 10),
new THREE.MeshBasicMaterial({ color: 0xffffff }),
new THREE.Vector3(-1.32, 0.22, side * 0.49),
new THREE.Vector3(0.045, 0.055, 0.025)
);
const antennaCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.32, 0.29, side * 0.18),
new THREE.Vector3(-1.54, 0.5, side * 0.29),
new THREE.Vector3(-1.78, 0.69, side * 0.43),
new THREE.Vector3(-1.94, 0.62, side * 0.5)
]);
const antenna = new THREE.Mesh(
new THREE.TubeGeometry(antennaCurve, 28, 0.024, 8, false),
materials.beeDark
);
antenna.castShadow = true;
bee.add(antenna);
});
const proboscisCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.42, -0.13, 0),
new THREE.Vector3(-1.61, -0.21, 0),
new THREE.Vector3(-1.78, -0.34, 0)
]);
bee.add(
new THREE.Mesh(
new THREE.TubeGeometry(proboscisCurve, 20, 0.055, 9, false),
materials.beeDark
)
);
// Six jointed legs.
function addLeg(root, knee, foot, thickness) {
bee.add(rodBetween(root, knee, thickness * 1.15, materials.leg));
bee.add(rodBetween(knee, foot, thickness, materials.leg));
[root, knee, foot].forEach((point) => {
addMesh(
bee,
sphereGeometry,
materials.leg,
point,
new THREE.Vector3(
thickness * 1.45,
thickness * 1.45,
thickness * 1.45
)
);
});
}
[-1, 1].forEach((side) => {
addLeg(
new THREE.Vector3(-0.52, -0.32, side * 0.34),
new THREE.Vector3(-0.73, -0.73, side * 0.47),
new THREE.Vector3(-0.98, -1.02, side * 0.53),
0.045
);
addLeg(
new THREE.Vector3(-0.04, -0.36, side * 0.45),
new THREE.Vector3(0.12, -0.77, side * 0.58),
new THREE.Vector3(0.02, -1.08, side * 0.68),
0.048
);
addLeg(
new THREE.Vector3(0.44, -0.34, side * 0.52),
new THREE.Vector3(0.75, -0.62, side * 0.75),
new THREE.Vector3(
side > 0 ? 0.91 : 1.1,
side > 0 ? -0.66 : -1.02,
side * 0.79
),
side > 0 ? 0.065 : 0.055
);
});
// Translucent wings with visible veins.
const wingMaterial = new THREE.MeshPhysicalMaterial({
color: 0xd9eff0,
transparent: true,
opacity: 0.32,
roughness: 0.18,
metalness: 0,
clearcoat: 0.35,
side: THREE.DoubleSide,
depthWrite: false
});
const wingPivots = [];
function createWing(side) {
const pivot = new THREE.Group();
pivot.position.set(-0.34, 0.48, side * 0.25);
bee.add(pivot);
const shape = new THREE.Shape();
const points = [
[0, 0],
[0.38, 0.17],
[1.13, 0.36],
[1.5, 0.15],
[1.39, -0.15],
[0.78, -0.28],
[0.15, -0.17]
];
points.forEach(([x, y], index) => {
const wingY = y + side * 0.37;
if (index === 0) shape.moveTo(x, wingY);
else shape.lineTo(x, wingY);
});
shape.closePath();
const membrane = new THREE.Mesh(
new THREE.ShapeGeometry(shape, 14),
wingMaterial
);
membrane.renderOrder = 2;
pivot.add(membrane);
const veins = [
[[0.05, side * 0.37], [1.34, side * 0.53]],
[[0.05, side * 0.37], [1.15, side * 0.25]],
[[0.04, side * 0.37], [0.82, side * 0.09]]
];
veins.forEach(([a, b]) => {
const vein = rodBetween(
new THREE.Vector3(...a),
new THREE.Vector3(...b),
0.008,
materials.vein,
5
);
vein.renderOrder = 3;
pivot.add(vein);
});
wingPivots.push({ pivot, side, phase: side > 0 ? 0 : 0.45 });
}
createWing(-1);
createWing(1);
// -------------------------------------------------------------------------
// Enlarged hind-leg pollen basket / corbicula
// -------------------------------------------------------------------------
const basket = new THREE.Group();
basket.position.set(1.62, -0.69, 0.78);
basket.rotation.z = -0.08;
basket.rotation.x = 0.06;
bee.add(basket);
const basketHemisphere = new THREE.SphereGeometry(
1,
48,
24,
0,
Math.PI * 2,
Math.PI / 2,
Math.PI / 2
);
addMesh(
basket,
basketHemisphere,
materials.basket,
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0.88, 0.46, 0.61)
);
const innerBasket = new THREE.Mesh(
basketHemisphere,
materials.basketInside
);
innerBasket.scale.set(0.81, 0.4, 0.55);
innerBasket.position.y = -0.015;
innerBasket.receiveShadow = true;
basket.add(innerBasket);
const basketRim = new THREE.Mesh(
new THREE.TorusGeometry(0.86, 0.035, 12, 72),
new THREE.MeshStandardMaterial({
color: 0xf0b12c,
roughness: 0.38
})
);
basketRim.rotation.x = Math.PI / 2;
basketRim.scale.set(1, 0.7, 1);
basketRim.castShadow = true;
basket.add(basketRim);
// Fine fringe around the enlarged basket.
for (let i = 0; i < 24; i++) {
const angle = (i / 24) * Math.PI * 2;
const start = new THREE.Vector3(
Math.cos(angle) * 0.85,
-0.02,
Math.sin(angle) * 0.59
);
const end = new THREE.Vector3(
Math.cos(angle) * 0.94,
-0.16,
Math.sin(angle) * 0.67
);
const hair = rodBetween(start, end, 0.008, materials.basket, 5);
basket.add(hair);
}
createPollenCluster(
basket,
new THREE.Vector3(0, 0.035, 0),
new THREE.Vector3(0.61, 0.13, 0.42),
72,
0.037,
0.078
);
// A second, looser fringe makes the pollen clusters visually distinct.
for (let i = 0; i < 34; i++) {
const angle = randomBetween(0, Math.PI * 2);
const grain = new THREE.Mesh(
pollenGeometry,
pollenMaterials[Math.floor(random() * pollenMaterials.length)]
);
const size = randomBetween(0.035, 0.072);
grain.position.set(
Math.cos(angle) * randomBetween(0.78, 0.91),
randomBetween(-0.06, 0.07),
Math.sin(angle) * randomBetween(0.52, 0.65)
);
grain.scale.setScalar(size);
grain.rotation.set(
randomBetween(0, Math.PI),
randomBetween(0, Math.PI),
randomBetween(0, Math.PI)
);
grain.castShadow = true;
basket.add(grain);
}
const basketAnchor = new THREE.Object3D();
basketAnchor.position.set(0.1, 0.2, 0.05);
basket.add(basketAnchor);
// -------------------------------------------------------------------------
// Flowers and prominent pollen-bearing anthers
// -------------------------------------------------------------------------
const petalMaterials = {
lavender: new THREE.MeshStandardMaterial({
color: 0xaa83b6,
roughness: 0.58
}),
coral: new THREE.MeshStandardMaterial({
color: 0xdc7767,
roughness: 0.62
}),
ivory: new THREE.MeshStandardMaterial({
color: 0xf6edda,
roughness: 0.72
})
};
const flowerCenters = new THREE.Vector3(0, 0.42, 0.08);
function createFlower({
base,
center,
radius,
petals,
petalMaterial,
antherScale = 1,
tilt = 0
}) {
const stemCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(base.x, 0, base.z),
new THREE.Vector3(
base.x + (center.x - base.x) * 0.18,
center.y * 0.35,
base.z + (center.z - base.z) * 0.25
),
new THREE.Vector3(
center.x + (base.x - center.x) * 0.12,
center.y * 0.72,
center.z + (base.z - center.z) * 0.12
),
new THREE.Vector3(center.x, center.y, center.z)
]);
const stem = new THREE.Mesh(
new THREE.TubeGeometry(stemCurve, 36, 0.048, 9, false),
materials.stem
);
stem.castShadow = true;
stem.receiveShadow = true;
scene.add(stem);
// Leaves on gently curved stems.
for (let i = 0; i < 2; i++) {
const y = center.y * (0.27 + i * 0.22);
const leaf = addMesh(
scene,
sphereGeometry,
materials.leaf,
new THREE.Vector3(
center.x + (i ? -0.25 : 0.2),
y,
center.z + (i ? -0.12 : 0.08)
),
new THREE.Vector3(0.38, 0.045, 0.16)
);
leaf.rotation.set(0.12, i ? 2.5 : -0.45, i ? 0.42 : -0.35);
}
const blossom = new THREE.Group();
blossom.position.copy(center);
blossom.rotation.z = tilt;
scene.add(blossom);
for (let i = 0; i < petals; i++) {
const angle = (i / petals) * Math.PI * 2;
const petal = addMesh(
blossom,
sphereGeometry,
petalMaterial,
new THREE.Vector3(
Math.cos(angle) * radius * 0.47,
0,
Math.sin(angle) * radius * 0.47
),
new THREE.Vector3(radius * 0.68, 0.075, radius * 0.26)
);
petal.rotation.y = -angle;
petal.rotation.z = Math.sin(angle * 2) * 0.05;
}
addMesh(
blossom,
sphereGeometry,
materials.antherOrange,
new THREE.Vector3(0, 0.035, 0),
new THREE.Vector3(radius * 0.27, 0.12, radius * 0.27)
);
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2 + 0.3;
const radial = new THREE.Vector3(
Math.cos(angle),
0,
Math.sin(angle)
);
const start = radial.clone().multiplyScalar(0.07);
start.y = 0.07;
const tip = radial.clone().multiplyScalar(0.16 * antherScale);
tip.y = (0.3 + (i % 2) * 0.07) * antherScale;
blossom.add(
rodBetween(start, tip, 0.018 * antherScale, materials.filament, 7)
);
const capsule = addMesh(
blossom,
sphereGeometry,
i % 2 ? materials.antherOrange : materials.anther,
tip,
new THREE.Vector3(
0.085 * antherScale,
0.22 * antherScale,
0.075 * antherScale
)
);
capsule.rotation.z = Math.sin(angle) * 0.2;
createPollenCluster(
blossom,
tip.clone().add(new THREE.Vector3(0, 0.15 * antherScale, 0)),
new THREE.Vector3(
0.055 * antherScale,
0.045 * antherScale,
0.055 * antherScale
),
15,
0.018 * antherScale,
0.038 * antherScale
);
}
return blossom;
}
const largeFlower = createFlower({
base: new THREE.Vector3(-1.85, 0, -0.25),
center: new THREE.Vector3(-1.85, 1.52, -0.25),
radius: 0.76,
petals: 8,
petalMaterial: petalMaterials.lavender,
antherScale: 1.12,
tilt: -0.08
});
createFlower({
base: new THREE.Vector3(-2.85, 0, -0.83),
center: new THREE.Vector3(-2.85, 1.04, -0.83),
radius: 0.55,
petals: 7,
petalMaterial: petalMaterials.coral,
antherScale: 0.95,
tilt: 0.12
});
const closeFlower = createFlower({
base: new THREE.Vector3(-1.18, 0, 1.12),
center: new THREE.Vector3(-1.18, 0.76, 1.12),
radius: 0.62,
petals: 8,
petalMaterial: petalMaterials.ivory,
antherScale: 1.38,
tilt: -0.18
});
const antherAnchor = new THREE.Object3D();
antherAnchor.position.set(0.02, 0.56, 0.14);
closeFlower.add(antherAnchor);
// -------------------------------------------------------------------------
// Labels, responsive layout, and animation
// -------------------------------------------------------------------------
const basketPin = document.querySelector("#basketPin");
const antherPin = document.querySelector("#antherPin");
const projected = new THREE.Vector3();
function positionPin(element, object) {
object.getWorldPosition(projected);
projected.project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.2 &&
Math.abs(projected.y) < 1.2;
element.style.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.fov = width < 700 ? 48 : 38;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
updateCamera(dt);
if (!reducedMotion) {
bee.position.y = 1.72 + Math.sin(time * 1.35) * 0.045;
bee.rotation.z = -0.045 + Math.sin(time * 0.8) * 0.012;
wingPivots.forEach(({ pivot, side, phase }) => {
pivot.rotation.x =
Math.PI / 2 +
side * 0.06 +
Math.sin(time * 11 + phase) * side * 0.14;
});
largeFlower.rotation.z = -0.08 + Math.sin(time * 0.65) * 0.012;
closeFlower.rotation.z = -0.18 + Math.sin(time * 0.72 + 1.3) * 0.014;
}
scene.updateMatrixWorld();
positionPin(basketPin, basketAnchor);
positionPin(antherPin, antherAnchor);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.style.opacity = "0";
setTimeout(() => loading.remove(), 450);
}
}
animate();
</script>
</body>
</html>
```