Prompt specification
Build or customize the Three.js 3D scene "Woodland edge seed journeys" 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: Woodland edge seed journeys
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/woodland-edge-seed-journeys-x0783
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing seed dispersal structures. Build a woodland edge with tree, path, animal silhouette, and open grass; follow two differently structured propagules to distinct resting places while preserving their identities. Stylized solid forms.
Working Three.js Starter (woodland-edge-seed-journeys-x0783):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Woodland Edge — Seed Dispersal</title>
<style>
:root {
--ink: #25342d;
--paper: rgba(248, 246, 235, 0.92);
--paper-strong: #f8f6eb;
--line: rgba(37, 52, 45, 0.18);
--samara: #efb642;
--burr: #c9683b;
--green: #557a57;
--shadow: 0 14px 38px rgba(31, 46, 37, 0.17);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8d3;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.62);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#title-card {
position: fixed;
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 19px 21px 17px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 7px;
color: #64766b;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 39px);
font-weight: 500;
letter-spacing: -0.035em;
line-height: 1.02;
}
.subtitle {
margin: 10px 0 0;
max-width: 330px;
color: #5d6e63;
font-size: 12px;
line-height: 1.5;
}
#identity-panel {
position: fixed;
top: 22px;
right: 22px;
width: 270px;
padding: 15px;
border-radius: 18px;
}
.panel-label {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 9px;
color: #66776c;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.focus-list {
display: grid;
gap: 7px;
}
.focus-chip {
display: grid;
grid-template-columns: 17px 1fr auto;
align-items: center;
gap: 9px;
width: 100%;
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.46);
cursor: pointer;
text-align: left;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
.focus-chip:hover {
transform: translateX(-2px);
background: rgba(255, 255, 255, 0.82);
}
.focus-chip.active {
border-color: rgba(37, 52, 45, 0.43);
background: var(--paper-strong);
}
.focus-swatch {
width: 12px;
height: 12px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.13);
}
.focus-swatch.samara {
background: var(--samara);
}
.focus-swatch.burr {
background: var(--burr);
}
.focus-swatch.both {
background: linear-gradient(135deg, var(--samara) 50%, var(--burr) 50%);
}
.focus-name {
font-size: 11px;
font-weight: 750;
}
.focus-destination {
color: #748178;
font-size: 9px;
white-space: nowrap;
}
#auto-button {
width: 100%;
margin-top: 8px;
padding: 9px;
border: 1px solid var(--line);
border-radius: 10px;
background: transparent;
color: #5e7064;
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#auto-button.active {
background: var(--ink);
border-color: var(--ink);
color: #fffdf1;
}
#instructions {
position: fixed;
right: 24px;
bottom: 122px;
color: rgba(37, 52, 45, 0.7);
font-size: 10px;
text-align: right;
pointer-events: none;
}
#transport {
position: fixed;
left: 50%;
bottom: 20px;
width: min(760px, calc(100vw - 40px));
padding: 14px 16px 13px;
border-radius: 17px;
transform: translateX(-50%);
}
.transport-top {
display: flex;
align-items: center;
gap: 13px;
}
#play-button,
#replay-button {
flex: 0 0 auto;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.58);
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
#play-button {
min-width: 82px;
padding: 9px 12px;
background: var(--ink);
border-color: var(--ink);
color: #fffdf2;
}
#replay-button {
padding: 9px 11px;
}
#timeline {
width: 100%;
height: 5px;
margin: 0;
accent-color: var(--green);
cursor: pointer;
}
#status {
margin: 9px 0 0;
color: #5e7065;
font-size: 10px;
letter-spacing: 0.035em;
}
.seed-label {
position: fixed;
z-index: 5;
display: none;
align-items: center;
gap: 8px;
padding: 8px 10px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 10px;
background: rgba(250, 248, 238, 0.91);
box-shadow: 0 8px 22px rgba(34, 48, 39, 0.16);
pointer-events: none;
transform: translate(-50%, -100%);
white-space: nowrap;
}
.seed-label::after {
position: absolute;
bottom: -6px;
left: 50%;
width: 10px;
height: 10px;
border-right: 1px solid rgba(255, 255, 255, 0.75);
border-bottom: 1px solid rgba(255, 255, 255, 0.75);
background: rgba(250, 248, 238, 0.91);
content: "";
transform: translateX(-50%) rotate(45deg);
}
.label-dot {
width: 9px;
height: 9px;
border-radius: 50%;
}
.label-dot.samara {
background: var(--samara);
}
.label-dot.burr {
background: var(--burr);
}
.seed-label strong {
display: block;
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.seed-label small {
display: block;
margin-top: 2px;
color: #6b786f;
font-size: 9px;
}
@media (max-width: 760px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
#identity-panel {
top: auto;
right: 12px;
bottom: 112px;
width: 220px;
padding: 10px;
}
.focus-chip {
grid-template-columns: 14px 1fr;
padding: 8px 9px;
}
.focus-destination {
display: none;
}
#instructions {
display: none;
}
#transport {
bottom: 12px;
width: calc(100vw - 24px);
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive woodland seed dispersal scene"></main>
<section id="title-card" class="panel">
<p class="eyebrow">Woodland edge / dispersal study</p>
<h1>Two ways to travel.</h1>
<p class="subtitle">
A winged samara glides to the path edge while a hooked burr tumbles into
open grass. Their colors, structures, and identities remain distinct.
</p>
</section>
<section id="identity-panel" class="panel" aria-label="Choose a propagule to follow">
<div class="panel-label">
<span>Identity lock</span>
<span>01 / 02</span>
</div>
<div class="focus-list">
<button class="focus-chip" data-focus="samara" type="button">
<span class="focus-swatch samara"></span>
<span class="focus-name">Winged samara</span>
<span class="focus-destination">→ path edge</span>
</button>
<button class="focus-chip" data-focus="burr" type="button">
<span class="focus-swatch burr"></span>
<span class="focus-name">Hooked burr</span>
<span class="focus-destination">→ open grass</span>
</button>
<button class="focus-chip" data-focus="both" type="button">
<span class="focus-swatch both"></span>
<span class="focus-name">View both</span>
<span class="focus-destination">→ overview</span>
</button>
</div>
<button id="auto-button" class="active" type="button">Auto tour</button>
</section>
<div id="instructions">
Drag to orbit · Scroll to zoom<br />
Space: pause · R: replay · 1 / 2: focus
</div>
<section id="transport" class="panel" aria-label="Animation controls">
<div class="transport-top">
<button id="play-button" type="button">Pause</button>
<button id="replay-button" type="button">Replay</button>
<input
id="timeline"
type="range"
min="0"
max="9"
step="0.01"
value="0"
aria-label="Animation timeline"
/>
</div>
<p id="status" aria-live="polite">Preparing the woodland scene…</p>
</section>
<div id="samara-label" class="seed-label">
<span class="label-dot samara"></span>
<div>
<strong>Winged samara</strong>
<small id="samara-state">Canopy</small>
</div>
</div>
<div id="burr-label" class="seed-label">
<span class="label-dot burr"></span>
<div>
<strong>Hooked burr</strong>
<small id="burr-state">Canopy</small>
</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 sceneHost = document.querySelector("#scene");
const timeline = document.querySelector("#timeline");
const playButton = document.querySelector("#play-button");
const replayButton = document.querySelector("#replay-button");
const autoButton = document.querySelector("#auto-button");
const statusElement = document.querySelector("#status");
const focusButtons = [...document.querySelectorAll("[data-focus]")];
const samaraLabel = document.querySelector("#samara-label");
const burrLabel = document.querySelector("#burr-label");
const samaraState = document.querySelector("#samara-state");
const burrState = document.querySelector("#burr-state");
const SAMARA_START = 0.25;
const SAMARA_DURATION = 4.05;
const BURR_START = 1.1;
const BURR_DURATION = 4.35;
const TOTAL_TIME = 9;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce8d3);
scene.fog = new THREE.Fog(0xdce8d3, 17, 42);
const camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
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;
renderer.domElement.setAttribute("aria-label", "Woodland seed dispersal animation");
renderer.domElement.tabIndex = 0;
sceneHost.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(
0xf5f3db,
0x42563d,
2.1
);
scene.add(hemisphere);
const sunLight = new THREE.DirectionalLight(0xfff2ce, 3.2);
sunLight.position.set(8, 15, 9);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -16;
sunLight.shadow.camera.right = 16;
sunLight.shadow.camera.top = 15;
sunLight.shadow.camera.bottom = -12;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 40;
sunLight.shadow.bias = -0.0005;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0xc9dce8, 0.7);
fillLight.position.set(-9, 6, -10);
scene.add(fillLight);
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...options
});
const solid = (color, options = {}) =>
new THREE.MeshBasicMaterial({
color,
...options
});
function addMesh(geometry, material, position, scale, parent = scene) {
const mesh = new THREE.Mesh(geometry, material);
if (position) mesh.position.copy(position);
if (scale) mesh.scale.copy(scale);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(
parent,
start,
end,
radiusTop,
radiusBottom,
material,
radialSegments = 8
) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
length,
radialSegments
),
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function seededRandom(seed) {
return function () {
seed |= 0;
seed = (seed + 0x6d2b79f5) | 0;
let value = Math.imul(seed ^ (seed >>> 15), 1 | seed);
value =
value +
Math.imul(value ^ (value >>> 7), 61 | value) ^
value;
return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
};
}
const random = seededRandom(48291);
// ---------------------------------------------------------------------
// Landscape
// ---------------------------------------------------------------------
const ground = addMesh(
new THREE.PlaneGeometry(32, 30),
standard(0x78965b),
new THREE.Vector3(0, -0.025, 0),
null
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
const meadow = addMesh(
new THREE.CircleGeometry(8.5, 48),
standard(0x87a662),
new THREE.Vector3(4.8, -0.012, -0.8),
new THREE.Vector3(1.3, 1, 0.86)
);
meadow.rotation.x = -Math.PI / 2;
meadow.castShadow = false;
const pathCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.1, 0.015, 11.5),
new THREE.Vector3(0.5, 0.015, 6.4),
new THREE.Vector3(0.05, 0.015, 2.3),
new THREE.Vector3(-1.9, 0.015, -2.4),
new THREE.Vector3(-4.7, 0.015, -8.5)
]);
const pathSegments = 90;
const pathPositions = [];
const pathIndices = [];
const pathHalfWidth = 1.08;
for (let i = 0; i <= pathSegments; i++) {
const t = i / pathSegments;
const point = pathCurve.getPointAt(t);
const tangent = pathCurve.getTangentAt(t).normalize();
const side = new THREE.Vector3(tangent.z, 0, -tangent.x).normalize();
const width = pathHalfWidth * (0.93 + Math.sin(t * Math.PI * 3) * 0.07);
const left = point.clone().addScaledVector(side, width);
const right = point.clone().addScaledVector(side, -width);
pathPositions.push(left.x, left.y, left.z);
pathPositions.push(right.x, right.y, right.z);
if (i < pathSegments) {
const a = i * 2;
pathIndices.push(a, a + 1, a + 2, a + 1, a + 3, a + 2);
}
}
const pathGeometry = new THREE.BufferGeometry();
pathGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(pathPositions, 3)
);
pathGeometry.setIndex(pathIndices);
pathGeometry.computeVertexNormals();
const pathMaterial = standard(0xc8a873, {
side: THREE.DoubleSide,
roughness: 1
});
const pathMesh = new THREE.Mesh(pathGeometry, pathMaterial);
pathMesh.receiveShadow = true;
scene.add(pathMesh);
// Path-edge stones.
const stoneMaterials = [
standard(0x9e8d70),
standard(0xb0a083),
standard(0x897b65)
];
for (let i = 0; i < 46; i++) {
const t = 0.04 + random() * 0.92;
const point = pathCurve.getPointAt(t);
const tangent = pathCurve.getTangentAt(t).normalize();
const side = new THREE.Vector3(tangent.z, 0, -tangent.x).normalize();
const sign = random() > 0.5 ? 1 : -1;
const offset = (0.72 + random() * 0.37) * sign;
point.addScaledVector(side, offset);
point.y = 0.055;
const stone = addMesh(
new THREE.DodecahedronGeometry(0.08 + random() * 0.09, 0),
stoneMaterials[i % stoneMaterials.length],
point,
new THREE.Vector3(1.3, 0.58, 0.9)
);
stone.rotation.set(random(), random(), random());
}
// Dense, stylized grass using one instanced solid mesh.
function distanceToPath(x, z) {
let minimum = Infinity;
for (let i = 0; i <= 70; i++) {
const point = pathCurve.getPointAt(i / 70);
minimum = Math.min(
minimum,
Math.hypot(x - point.x, z - point.z)
);
}
return minimum;
}
const grassGeometry = new THREE.ConeGeometry(0.055, 0.48, 3, 1);
const grassMaterial = standard(0x66894d, {
vertexColors: true
});
const grassCount = 520;
const grass = new THREE.InstancedMesh(
grassGeometry,
grassMaterial,
grassCount
);
grass.castShadow = true;
grass.receiveShadow = true;
const dummy = new THREE.Object3D();
const grassColor = new THREE.Color();
for (let i = 0; i < grassCount; i++) {
let x;
let z;
do {
x = -11 + random() * 23;
z = -10 + random() * 21;
} while (
distanceToPath(x, z) < 1.25 ||
(x < -1.8 && z > -4 && z < 2.4)
);
const height = 0.65 + random() * 0.85;
dummy.position.set(x, 0.19 * height, z);
dummy.rotation.set(
(random() - 0.5) * 0.28,
random() * Math.PI * 2,
(random() - 0.5) * 0.28
);
dummy.scale.set(0.7 + random() * 0.55, height, 0.7 + random() * 0.5);
dummy.updateMatrix();
grass.setMatrixAt(i, dummy.matrix);
grassColor.setHSL(
0.23 + random() * 0.035,
0.31 + random() * 0.13,
0.34 + random() * 0.16
);
grass.setColorAt(i, grassColor);
}
grass.instanceMatrix.needsUpdate = true;
grass.instanceColor.needsUpdate = true;
scene.add(grass);
// ---------------------------------------------------------------------
// Main tree
// ---------------------------------------------------------------------
const tree = new THREE.Group();
tree.position.set(-4.25, 0, -1.45);
scene.add(tree);
const trunkMaterial = standard(0x684837);
const branchMaterial = standard(0x71503a);
const trunk = addMesh(
new THREE.CylinderGeometry(0.38, 0.72, 4.35, 9),
trunkMaterial,
new THREE.Vector3(0, 2.1, 0),
null,
tree
);
trunk.rotation.z = -0.035;
cylinderBetween(
tree,
new THREE.Vector3(-0.25, 2.7, 0),
new THREE.Vector3(-1.55, 4.05, 0.35),
0.18,
0.32,
branchMaterial
);
cylinderBetween(
tree,
new THREE.Vector3(0.2, 2.95, 0),
new THREE.Vector3(1.45, 4.25, -0.25),
0.17,
0.3,
branchMaterial
);
cylinderBetween(
tree,
new THREE.Vector3(0, 3.4, 0),
new THREE.Vector3(0.3, 4.8, 0.4),
0.14,
0.24,
branchMaterial
);
const rootDirections = [
[-1.45, 0.05, 0.45],
[1.4, 0.05, 0.1],
[0.25, 0.05, 1.25],
[-0.2, 0.05, -1.3]
];
rootDirections.forEach((root) => {
cylinderBetween(
tree,
new THREE.Vector3(0, 0.55, 0),
new THREE.Vector3(...root),
0.08,
0.24,
trunkMaterial
);
});
const canopyMaterial = [
standard(0x416c45),
standard(0x507b4b),
standard(0x628653),
standard(0x365f3d)
];
const canopyData = [
[-1.25, 4.65, 0.25, 1.45, 1.25, 1.35],
[0.45, 4.85, -0.05, 1.55, 1.35, 1.4],
[1.45, 4.35, 0.35, 1.15, 1.05, 1.05],
[-0.35, 5.55, 0.25, 1.55, 1.35, 1.4],
[-1.75, 5.15, -0.25, 1.15, 1.1, 1.1],
[0.8, 5.35, 0.65, 1.25, 1.15, 1.15]
];
canopyData.forEach((data, index) => {
addMesh(
new THREE.DodecahedronGeometry(1, 0),
canopyMaterial[index % canopyMaterial.length],
new THREE.Vector3(data[0], data[1], data[2]),
new THREE.Vector3(data[3], data[4], data[5]),
tree
);
});
// Background woodland edge.
const distantTrunkMaterial = standard(0x5c4939);
const distantLeafMaterials = [
standard(0x476848),
standard(0x58764d),
standard(0x3f6144)
];
const distantTreeData = [
[-9.5, -7.4, 2.6],
[-7.1, -8.6, 3.2],
[-5.8, -9.6, 2.5],
[2.0, -9.0, 2.8],
[5.0, -8.4, 3.4],
[7.8, -8.0, 2.9],
[10.0, -7.0, 2.4]
];
distantTreeData.forEach((data, index) => {
const group = new THREE.Group();
group.position.set(data[0], 0, data[1]);
group.scale.setScalar(data[2] / 3);
addMesh(
new THREE.CylinderGeometry(0.16, 0.28, 1.65, 7),
distantTrunkMaterial,
new THREE.Vector3(0, 0.8, 0),
null,
group
);
addMesh(
new THREE.ConeGeometry(1.05, 2.1, 7),
distantLeafMaterials[index % distantLeafMaterials.length],
new THREE.Vector3(0, 2.25, 0),
null,
group
);
scene.add(group);
});
// Solid sun and clouds.
const sun = addMesh(
new THREE.SphereGeometry(1.4, 24, 16),
solid(0xffe2a0),
new THREE.Vector3(-11, 10, -17),
null
);
sun.castShadow = false;
sun.receiveShadow = false;
const cloudMaterial = solid(0xf5f1df);
[
[-7.5, 9.2, -13, 1.2],
[-5.8, 9.45, -13.2, 0.85],
[5.6, 8.7, -14, 1.05],
[7.0, 8.8, -14.1, 0.75]
].forEach((data) => {
const cloud = addMesh(
new THREE.DodecahedronGeometry(1, 1),
cloudMaterial,
new THREE.Vector3(data[0], data[1], data[2]),
new THREE.Vector3(data[3], data[3] * 0.55, data[3] * 0.65)
);
cloud.castShadow = false;
cloud.receiveShadow = false;
});
// ---------------------------------------------------------------------
// Animal silhouette: a stylized deer at the woodland edge
// ---------------------------------------------------------------------
const deer = new THREE.Group();
deer.position.set(3.15, 0, 5.25);
deer.rotation.y = -0.32;
deer.scale.setScalar(0.95);
scene.add(deer);
const deerMaterial = solid(0x26362d);
addMesh(
new THREE.SphereGeometry(1, 14, 10),
deerMaterial,
new THREE.Vector3(0, 1.28, 0),
new THREE.Vector3(0.83, 0.48, 0.4),
deer
);
cylinderBetween(
deer,
new THREE.Vector3(-0.48, 1.36, 0),
new THREE.Vector3(-0.78, 2.08, 0),
0.2,
0.34,
deerMaterial
);
addMesh(
new THREE.SphereGeometry(1, 12, 8),
deerMaterial,
new THREE.Vector3(-0.91, 2.16, 0),
new THREE.Vector3(0.34, 0.23, 0.22),
deer
);
addMesh(
new THREE.SphereGeometry(1, 10, 7),
deerMaterial,
new THREE.Vector3(-1.14, 2.11, 0),
new THREE.Vector3(0.26, 0.13, 0.14),
deer
);
const legPositions = [
[-0.48, 0.24],
[-0.48, -0.24],
[0.47, 0.24],
[0.47, -0.24]
];
legPositions.forEach(([x, z]) => {
cylinderBetween(
deer,
new THREE.Vector3(x, 1.03, z),
new THREE.Vector3(x + (x < 0 ? -0.08 : 0.05), 0.08, z),
0.075,
0.12,
deerMaterial,
7
);
});
const ears = [
[-0.8, 2.44, 0.13],
[-0.83, 2.43, -0.13]
];
ears.forEach((position) => {
const ear = addMesh(
new THREE.ConeGeometry(0.12, 0.38, 5),
deerMaterial,
new THREE.Vector3(...position),
null,
deer
);
ear.rotation.z = 0.4;
ear.rotation.x = position[2] > 0 ? -0.18 : 0.18;
});
cylinderBetween(
deer,
new THREE.Vector3(-0.83, 2.34, 0.1),
new THREE.Vector3(-1.03, 2.92, 0.24),
0.035,
0.055,
deerMaterial,
6
);
cylinderBetween(
deer,
deer.position.clone().set(-1.03, 2.92, 0.24),
deer.position.clone().set(-1.27, 3.13, 0.34),
0.025,
0.045,
deerMaterial,
6
);
cylinderBetween(
deer,
deer.position.clone().set(-0.83, 2.34, -0.1),
deer.position.clone().set(-0.98, 2.87, -0.23),
0.035,
0.055,
deerMaterial,
6
);
cylinderBetween(
deer,
deer.position.clone().set(-0.98, 2.87, -0.23),
deer.position.clone().set(-1.18, 3.04, -0.34),
0.025,
0.045,
deerMaterial,
6
);
// ---------------------------------------------------------------------
// Distinct propagule models
// ---------------------------------------------------------------------
function createSamara() {
const group = new THREE.Group();
const wingShape = new THREE.Shape();
wingShape.moveTo(0, 0.02);
wingShape.bezierCurveTo(0.2, 0.35, 0.31, 1.25, 0.25, 2.15);
wingShape.bezierCurveTo(0.22, 2.48, 0.08, 2.72, 0, 2.8);
wingShape.bezierCurveTo(-0.11, 2.62, -0.25, 2.28, -0.27, 1.82);
wingShape.bezierCurveTo(-0.28, 0.95, -0.19, 0.28, 0, 0.02);
const wingGeometry = new THREE.ExtrudeGeometry(wingShape, {
depth: 0.055,
steps: 1,
bevelEnabled: true,
bevelSegments: 1,
bevelSize: 0.025,
bevelThickness: 0.025
});
wingGeometry.center();
const wing = new THREE.Mesh(
wingGeometry,
standard(0xefb642, { roughness: 0.72 })
);
wing.position.z = -0.027;
wing.castShadow = true;
group.add(wing);
const seedBody = addMesh(
new THREE.SphereGeometry(0.19, 12, 8),
standard(0x593824),
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0.78, 1.12, 0.85),
group
);
const stem = addMesh(
new THREE.CylinderGeometry(0.028, 0.04, 0.34, 7),
standard(0x765038),
new THREE.Vector3(0, -0.22, 0),
null,
group
);
stem.rotation.z = -0.35;
group.scale.setScalar(0.83);
return group;
}
function createBurr() {
const group = new THREE.Group();
const body = addMesh(
new THREE.IcosahedronGeometry(0.24, 1),
standard(0xa66a3e),
new THREE.Vector3(0, 0, 0),
null,
group
);
const hookMaterial = standard(0x643a28);
for (let i = 0; i < 12; i++) {
const angle = i * 2.399963;
const radial = new THREE.Vector3(
Math.cos(angle),
0,
Math.sin(angle)
);
const heightOffset = ((i % 3) - 1) * 0.07;
const start = radial.clone().multiplyScalar(0.13);
start.y = heightOffset;
const control1 = radial.clone().multiplyScalar(0.39);
control1.y = 0.13 + heightOffset;
const control2 = radial.clone().multiplyScalar(0.49);
control2.y = 0.32 + heightOffset;
const end = radial.clone().multiplyScalar(0.27);
end.y = 0.43 + heightOffset;
const hookCurve = new THREE.CatmullRomCurve3([
start,
control1,
control2,
end
]);
const hook = new THREE.Mesh(
new THREE.TubeGeometry(hookCurve, 12, 0.035, 5, false),
hookMaterial
);
hook.castShadow = true;
group.add(hook);
}
group.scale.setScalar(0.9);
return group;
}
const samara = createSamara();
const burr = createBurr();
samara.visible = false;
burr.visible = false;
scene.add(samara, burr);
// ---------------------------------------------------------------------
// Distinct flight trajectories and resting places
// ---------------------------------------------------------------------
const samaraCurve = new THREE.CubicBezierCurve3(
new THREE.Vector3(-3.65, 4.72, -0.95),
new THREE.Vector3(-1.1, 5.25, 0.55),
new THREE.Vector3(2.35, 2.75, 3.4),
new THREE.Vector3(1.28, 0.18, 3.78)
);
const burrCurve = new THREE.CubicBezierCurve3(
new THREE.Vector3(-4.45, 4.48, -1.45),
new THREE.Vector3(-2.65, 5.75, -3.7),
new THREE.Vector3(2.8, 4.15, -4.15),
new THREE.Vector3(4.45, 0.34, -1.82)
);
function addTrajectory(curve, color) {
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.23,
depthWrite: false
});
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 70, 0.018, 5, false),
material
);
scene.add(tube);
return tube;
}
addTrajectory(samaraCurve, 0xefb642);
addTrajectory(burrCurve, 0xc9683b);
function addRestingMarker(position, color) {
const group = new THREE.Group();
group.position.copy(position);
group.position.y = 0.065;
const material = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.16,
roughness: 0.7
});
const ring = addMesh(
new THREE.TorusGeometry(0.43, 0.035, 7, 36),
material,
new THREE.Vector3(0, 0, 0),
null,
group
);
ring.rotation.x = Math.PI / 2;
const center = addMesh(
new THREE.CircleGeometry(0.18, 24),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.22,
depthWrite: false
}),
new THREE.Vector3(0, 0.008, 0),
null,
group
);
center.rotation.x = -Math.PI / 2;
scene.add(group);
return group;
}
const samaraMarker = addRestingMarker(
samaraCurve.getPoint(1),
0xefb642
);
const burrMarker = addRestingMarker(
burrCurve.getPoint(1),
0xc9683b
);
// ---------------------------------------------------------------------
// Animation and camera
// ---------------------------------------------------------------------
let time = 0;
let playing = true;
let focusMode = "auto";
let zoomFactor = 1;
const orbit = {
yaw: 0.69,
pitch: 0.43
};
const smoothTarget = new THREE.Vector3(-0.6, 1.55, 0.4);
const desiredTarget = new THREE.Vector3();
const desiredPosition = new THREE.Vector3();
const projected = new THREE.Vector3();
const up = new THREE.Vector3(0, 1, 0);
const samaraRestQuaternion = new THREE.Quaternion().setFromEuler(
new THREE.Euler(-Math.PI / 2, 0.2, 0.34)
);
function smoothstep(min, max, value) {
const x = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return x * x * (3 - 2 * x);
}
function updateSamara() {
if (time < SAMARA_START) {
samara.visible = false;
samaraState.textContent = "Canopy";
return;
}
samara.visible = true;
const u = THREE.MathUtils.clamp(
(time - SAMARA_START) / SAMARA_DURATION,
0,
1
);
samara.position.copy(samaraCurve.getPoint(u));
const tangent = samaraCurve
.getTangent(Math.min(u, 0.999))
.normalize();
const followQuaternion = new THREE.Quaternion().setFromUnitVectors(
up,
tangent.clone().negate()
);
const settle = smoothstep(0.78, 0.97, u);
followQuaternion.slerp(samaraRestQuaternion, settle);
samara.quaternion.copy(followQuaternion);
samara.rotateY(Math.sin(u * Math.PI) * 0.22);
if (u < 1) {
samaraState.textContent = "Gliding · wing extended";
} else {
samaraState.textContent = "Resting · path edge";
}
}
function updateBurr() {
if (time < BURR_START) {
burr.visible = false;
burrState.textContent = "Canopy";
return;
}
burr.visible = true;
const u = THREE.MathUtils.clamp(
(time - BURR_START) / BURR_DURATION,
0,
1
);
burr.position.copy(burrCurve.getPoint(u));
const settle = smoothstep(0.82, 1, u);
const spinX = u * Math.PI * 7.4;
const spinY = u * Math.PI * 4.1;
const spinZ = u * Math.PI * 10.3;
burr.rotation.set(
THREE.MathUtils.lerp(spinX, 1.18, settle),
THREE.MathUtils.lerp(spinY, 0.42, settle),
THREE.MathUtils.lerp(spinZ, 0.25, settle)
);
if (u < 1) {
burrState.textContent = "Tumbling · hooks exposed";
} else {
burrState.textContent = "Resting · open grass";
}
}
function isSamaraAutoFocus() {
return (
focusMode === "auto" &&
time >= 0.65 &&
time < 4.65
);
}
function isBurrAutoFocus() {
return (
focusMode === "auto" &&
time >= 4.65 &&
time < 7.15
);
}
function updateCamera(delta) {
let baseRadius = 15.4;
let pitch = orbit.pitch;
if (focusMode === "samara") {
desiredTarget.copy(samara.position).add(new THREE.Vector3(0, 0.42, 0));
baseRadius = 5.4;
pitch = Math.max(pitch, 0.25);
} else if (focusMode === "burr") {
desiredTarget.copy(burr.position).add(new THREE.Vector3(0, 0.35, 0));
baseRadius = 5.8;
pitch = Math.max(pitch, 0.25);
} else if (focusMode === "both") {
desiredTarget
.copy(samara.position)
.add(burr.position)
.multiplyScalar(0.5);
desiredTarget.y = 1.15;
baseRadius = 12.8;
} else if (isSamaraAutoFocus()) {
desiredTarget.copy(samara.position).add(new THREE.Vector3(0, 0.42, 0));
baseRadius = 5.4;
pitch = Math.max(pitch, 0.25);
} else if (isBurrAutoFocus()) {
desiredTarget.copy(burr.position).add(new THREE.Vector3(0, 0.35, 0));
baseRadius = 5.8;
pitch = Math.max(pitch, 0.25);
} else {
desiredTarget.set(-0.45, 1.55, 0.35);
baseRadius = 15.4;
}
const damping = 1 - Math.exp(-delta * 4.2);
smoothTarget.lerp(desiredTarget, damping);
const radius = baseRadius * zoomFactor;
const horizontal = Math.cos(pitch) * radius;
desiredPosition.set(
smoothTarget.x + Math.sin(orbit.yaw) * horizontal,
smoothTarget.y + Math.sin(pitch) * radius,
smoothTarget.z + Math.cos(orbit.yaw) * horizontal
);
camera.position.lerp(desiredPosition, damping);
camera.lookAt(smoothTarget);
camera.updateMatrixWorld();
}
function placeLabel(element, worldPosition, visible) {
if (!visible) {
element.style.display = "none";
return;
}
projected.copy(worldPosition).project(camera);
if (
projected.z < -1 ||
projected.z > 1 ||
projected.x < -1.15 ||
projected.x > 1.15 ||
projected.y < -1.15 ||
projected.y > 1.15
) {
element.style.display = "none";
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.display = "flex";
element.style.left = `${x}px`;
element.style.top = `${y - 13}px`;
}
function updateLabels() {
const samaraVisible =
samara.visible &&
(
focusMode === "samara" ||
focusMode === "both" ||
isSamaraAutoFocus() ||
(focusMode === "auto" && time >= 7.15)
);
const burrVisible =
burr.visible &&
(
focusMode === "burr" ||
focusMode === "both" ||
isBurrAutoFocus() ||
(focusMode === "auto" && time >= 7.15)
);
placeLabel(
samaraLabel,
samara.position.clone().add(new THREE.Vector3(0, 0.85, 0)),
samaraVisible
);
placeLabel(
burrLabel,
burr.position.clone().add(new THREE.Vector3(0, 0.7, 0)),
burrVisible
);
}
function updateStatus() {
let message;
if (!playing && time < TOTAL_TIME) {
message = `Paused · ${formatTime(time)} / ${formatTime(TOTAL_TIME)}`;
} else if (focusMode === "samara") {
message = `Manual focus · Winged samara · ${
time >= SAMARA_START + SAMARA_DURATION
? "resting at the path edge"
: "gliding toward the path edge"
}`;
} else if (focusMode === "burr") {
message = `Manual focus · Hooked burr · ${
time >= BURR_START + BURR_DURATION
? "resting in open grass"
: "tumbling toward open grass"
}`;
} else if (focusMode === "both") {
message = "Shared view · Both propagules retain their distinct structures";
} else if (time < 0.65) {
message = "Ready · The two propagules will separate from the canopy";
} else if (time < 4.65) {
message = "Auto tour 01/02 · Following the winged samara";
} else if (time < 7.15) {
message = "Auto tour 02/02 · Following the tumbling hooked burr";
} else if (time < TOTAL_TIME) {
message = "Final comparison · Path edge and open grass resting places";
} else {
message = "Complete · Two identities, two structures, two resting places";
}
statusElement.textContent = message;
timeline.value = String(time);
}
function formatTime(value) {
const seconds = Math.floor(value);
const tenths = Math.floor((value - seconds) * 10);
return `${String(seconds).padStart(2, "0")}.${tenths}s`;
}
function setFocus(mode) {
focusMode = mode;
focusButtons.forEach((button) => {
button.classList.toggle(
"active",
button.dataset.focus === mode
);
});
autoButton.classList.toggle("active", mode === "auto");
updateStatus();
}
focusButtons.forEach((button) => {
button.addEventListener("click", () => {
setFocus(button.dataset.focus);
});
});
autoButton.addEventListener("click", () => {
setFocus("auto");
});
function setPlaying(value) {
playing = value;
playButton.textContent = playing ? "Pause" : "Play";
updateStatus();
}
playButton.addEventListener("click", () => {
if (time >= TOTAL_TIME) {
time = 0;
}
setPlaying(!playing);
});
replayButton.addEventListener("click", () => {
time = 0;
zoomFactor = 1;
orbit.yaw = 0.69;
orbit.pitch = 0.43;
setFocus("auto");
setPlaying(true);
});
timeline.addEventListener("input", (event) => {
time = Number(event.target.value);
setPlaying(false);
updateStatus();
});
window.addEventListener("keydown", (event) => {
if (
event.target instanceof HTMLInputElement ||
event.target instanceof HTMLButtonElement
) {
return;
}
if (event.code === "Space") {
event.preventDefault();
if (time >= TOTAL_TIME) time = 0;
setPlaying(!playing);
} else if (event.key.toLowerCase() === "r") {
time = 0;
setFocus("auto");
setPlaying(true);
} else if (event.key === "1") {
setFocus("samara");
} else if (event.key === "2") {
setFocus("burr");
}
});
// ---------------------------------------------------------------------
// Direct camera controls, implemented without addons
// ---------------------------------------------------------------------
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
orbit.yaw -= deltaX * 0.006;
orbit.pitch = THREE.MathUtils.clamp(
orbit.pitch + deltaY * 0.004,
0.16,
1.12
);
previousPointerX = event.clientX;
previousPointerY = event.clientY;
});
function stopDragging(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoomFactor = THREE.MathUtils.clamp(
zoomFactor * Math.exp(event.deltaY * 0.001),
0.58,
1.55
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
orbit.yaw = 0.69;
orbit.pitch = 0.43;
zoomFactor = 1;
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (playing) {
time += delta;
if (time >= TOTAL_TIME) {
time = TOTAL_TIME;
setPlaying(false);
}
}
updateSamara();
updateBurr();
updateCamera(delta);
updateLabels();
updateStatus();
const pulse = 1 + Math.sin(time * 2.2) * 0.045;
samaraMarker.scale.setScalar(pulse);
burrMarker.scale.setScalar(2 - pulse);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```