Prompt specification
Build or customize the Three.js 3D scene "Orchard calendar teaching table" 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: Orchard calendar teaching table
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/orchard-calendar-teaching-table-x1246
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring seasonal landscapes. Arrange four small tree plots showing bud, blossom, fruit, and dormant states; label them as a generalized cycle rather than a universal calendar. Stylized solid forms.
Working Three.js Starter (orchard-calendar-teaching-table-x1246):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Year in Four Gestures — Seasonal Tree Studies</title>
<style>
:root {
--ink: #18372e;
--muted: #64776f;
--paper: rgba(251, 250, 244, 0.88);
--line: rgba(24, 55, 46, 0.14);
--bud: #cf7181;
--blossom: #d95f91;
--fruit: #d66f35;
--dormant: #648096;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe8e4;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
canvas {
font: inherit;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
#scene {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#scene:active {
cursor: grabbing;
}
#scene:focus-visible {
outline: 3px solid rgba(216, 111, 53, 0.65);
outline-offset: -5px;
}
.intro {
position: fixed;
z-index: 5;
top: 28px;
left: 28px;
width: min(330px, calc(100vw - 56px));
padding: 22px 24px 21px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 20px;
background: var(--paper);
box-shadow:
0 18px 55px rgba(39, 65, 55, 0.11),
inset 0 1px 0 rgba(255, 255, 255, 0.72);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 13px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 2px;
border-radius: 99px;
background: var(--fruit);
content: "";
}
h1 {
max-width: 270px;
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 4vw, 48px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.045em;
}
.intro p {
margin: 15px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.not-calendar {
display: inline-flex;
align-items: center;
margin-top: 15px;
padding: 7px 9px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--ink);
background: rgba(255, 255, 255, 0.48);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.controls {
position: fixed;
z-index: 6;
top: 28px;
right: 28px;
display: flex;
align-items: center;
gap: 9px;
pointer-events: none;
}
.controls span,
.controls button {
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 999px;
background: var(--paper);
box-shadow: 0 10px 30px rgba(39, 65, 55, 0.09);
backdrop-filter: blur(12px);
}
.controls span {
padding: 10px 13px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.controls button {
padding: 9px 13px;
color: var(--ink);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
pointer-events: auto;
transition:
transform 160ms ease,
background 160ms ease;
}
.controls button:hover {
transform: translateY(-1px);
background: rgba(255, 255, 255, 0.96);
}
.plot-label {
--accent: var(--bud);
position: fixed;
z-index: 4;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 9px;
min-width: 138px;
padding: 9px 12px 9px 9px;
border: 1px solid rgba(255, 255, 255, 0.78);
border-radius: 13px;
background: rgba(251, 250, 244, 0.9);
box-shadow: 0 12px 30px rgba(32, 61, 50, 0.12);
backdrop-filter: blur(10px);
transform: translate(-50%, -100%);
pointer-events: none;
will-change: left, top;
}
.plot-label::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 19px;
background: linear-gradient(rgba(24, 55, 46, 0.38), transparent);
content: "";
}
.plot-label .number {
display: grid;
width: 30px;
height: 30px;
flex: 0 0 auto;
place-items: center;
border-radius: 9px;
color: white;
background: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
}
.plot-label .copy {
display: grid;
gap: 2px;
}
.plot-label strong {
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.plot-label small {
color: var(--muted);
font-family: Georgia, "Times New Roman", serif;
font-size: 11px;
font-style: italic;
}
.cycle-card {
position: fixed;
z-index: 5;
bottom: 26px;
left: 50%;
width: min(760px, calc(100vw - 48px));
padding: 15px 19px 14px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 55px rgba(39, 65, 55, 0.11);
backdrop-filter: blur(14px);
transform: translateX(-50%);
pointer-events: none;
}
.cycle-heading {
margin-bottom: 10px;
color: var(--muted);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.cycle-steps {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
.cycle-step {
position: relative;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 0;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.cycle-step:not(:last-child)::after {
position: absolute;
top: 50%;
right: -8px;
color: rgba(24, 55, 46, 0.3);
content: "→";
transform: translateY(-50%);
}
.cycle-step i {
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--step-color);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--step-color) 18%, transparent);
}
.cycle-note {
margin: 10px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
text-align: center;
}
@media (max-width: 760px) {
.intro {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 16px 17px;
border-radius: 16px;
}
h1 {
max-width: none;
font-size: 31px;
}
.intro p {
display: none;
}
.eyebrow {
margin-bottom: 9px;
}
.not-calendar {
margin-top: 10px;
}
.controls {
top: auto;
right: 14px;
bottom: 130px;
}
.controls span {
display: none;
}
.plot-label {
min-width: 0;
gap: 6px;
padding: 6px 8px 6px 6px;
border-radius: 10px;
}
.plot-label .number {
width: 24px;
height: 24px;
border-radius: 7px;
font-size: 8px;
}
.plot-label strong {
font-size: 8px;
}
.plot-label small {
display: none;
}
.cycle-card {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
padding: 12px 13px;
border-radius: 15px;
transform: none;
}
.cycle-steps {
gap: 4px;
}
.cycle-step {
gap: 5px;
font-size: 7px;
letter-spacing: 0.06em;
}
.cycle-step:not(:last-child)::after {
right: -4px;
font-size: 9px;
}
.cycle-note {
font-size: 9px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main id="app">
<canvas
id="scene"
tabindex="0"
aria-label="Interactive scene showing four stylized trees in generalized seasonal stages: bud, blossom, fruit, and dormant."
>
Your browser needs WebGL to display this scene.
</canvas>
<header class="intro">
<div class="eyebrow">Seasonal studies / 04</div>
<h1>A year in<br>four gestures.</h1>
<p>
Four small tree plots trace a generalized seasonal rhythm through
solid, low-poly forms.
</p>
<div class="not-calendar">Not a fixed calendar</div>
</header>
<div class="controls" aria-label="Scene controls">
<span>Drag to orbit · Scroll to zoom</span>
<button id="reset-view" type="button">Reset</button>
</div>
<div class="plot-label" id="label-bud" style="--accent: var(--bud)">
<span class="number">01</span>
<span class="copy">
<strong>Bud</strong>
<small>new growth gathers</small>
</span>
</div>
<div class="plot-label" id="label-blossom" style="--accent: var(--blossom)">
<span class="number">02</span>
<span class="copy">
<strong>Blossom</strong>
<small>flowers open</small>
</span>
</div>
<div class="plot-label" id="label-fruit" style="--accent: var(--fruit)">
<span class="number">03</span>
<span class="copy">
<strong>Fruit</strong>
<small>the harvest gathers</small>
</span>
</div>
<div class="plot-label" id="label-dormant" style="--accent: var(--dormant)">
<span class="number">04</span>
<span class="copy">
<strong>Dormant</strong>
<small>quiet, bare rest</small>
</span>
</div>
<section class="cycle-card" aria-label="Generalized seasonal cycle">
<div class="cycle-heading">A generalized cycle</div>
<div class="cycle-steps">
<div class="cycle-step" style="--step-color: var(--bud)">
<i></i><span>Bud</span>
</div>
<div class="cycle-step" style="--step-color: var(--blossom)">
<i></i><span>Blossom</span>
</div>
<div class="cycle-step" style="--step-color: var(--fruit)">
<i></i><span>Fruit</span>
</div>
<div class="cycle-step" style="--step-color: var(--dormant)">
<i></i><span>Dormant</span>
</div>
</div>
<p class="cycle-note">
These stages are a generalized cycle—not a universal calendar.
They often overlap, and their timing changes with climate, latitude,
and species.
</p>
</section>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const renderer = new THREE.WebGLRenderer({
canvas,
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.05;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe8e4);
scene.fog = new THREE.Fog(0xdbe8e4, 19, 37);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 0.85, 0);
const orbit = {
theta: 0.55,
phi: 0.96,
radius: 16.5,
targetTheta: 0.55,
targetPhi: 0.96,
targetRadius: 16.5,
userMoved: false
};
function fitDistance() {
const verticalTangent = Math.tan(
THREE.MathUtils.degToRad(camera.fov * 0.5)
);
const horizontalTangent = verticalTangent * camera.aspect;
const radiusForWidth = 16.5 / (2 * horizontalTangent);
const radiusForHeight = 11.2 / (2 * verticalTangent);
return THREE.MathUtils.clamp(
Math.max(radiusForWidth, radiusForHeight),
15.5,
40
);
}
const hemisphere = new THREE.HemisphereLight(
0xf4fbff,
0x718064,
2.0
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3dc, 3.2);
sun.position.set(-6, 11, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -11;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9e0f4, 0.8);
fill.position.set(8, 5, -7);
scene.add(fill);
const materials = {
islandSide: new THREE.MeshStandardMaterial({
color: 0x718267,
roughness: 1,
flatShading: true
}),
islandTop: new THREE.MeshStandardMaterial({
color: 0xa9bd91,
roughness: 1,
flatShading: true
}),
islandBottom: new THREE.MeshStandardMaterial({
color: 0x69745c,
roughness: 1,
flatShading: true
}),
shadowFloor: new THREE.MeshStandardMaterial({
color: 0xdbe8e4,
roughness: 1
}),
path: new THREE.MeshStandardMaterial({
color: 0xc9b68f,
roughness: 1
}),
soil: new THREE.MeshStandardMaterial({
color: 0x9e8060,
roughness: 1,
flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: 0x846244,
roughness: 1,
flatShading: true
}),
bark: new THREE.MeshStandardMaterial({
color: 0x6c4a36,
roughness: 1,
flatShading: true
}),
dormantBark: new THREE.MeshStandardMaterial({
color: 0x665d53,
roughness: 1,
flatShading: true
}),
bud: new THREE.MeshStandardMaterial({
color: 0xd98298,
roughness: 0.9,
flatShading: true
}),
budLeaf: new THREE.MeshStandardMaterial({
color: 0x8fa967,
roughness: 1,
flatShading: true
}),
blossomPink: new THREE.MeshStandardMaterial({
color: 0xe888a6,
roughness: 0.95,
flatShading: true
}),
blossomLight: new THREE.MeshStandardMaterial({
color: 0xf2afbd,
roughness: 0.95,
flatShading: true
}),
blossomDeep: new THREE.MeshStandardMaterial({
color: 0xd96f91,
roughness: 0.95,
flatShading: true
}),
flowerCenter: new THREE.MeshStandardMaterial({
color: 0xf2cc68,
roughness: 0.9,
flatShading: true
}),
leaf: new THREE.MeshStandardMaterial({
color: 0x4f7d4f,
roughness: 1,
flatShading: true
}),
leafDark: new THREE.MeshStandardMaterial({
color: 0x3f6946,
roughness: 1,
flatShading: true
}),
fruit: new THREE.MeshStandardMaterial({
color: 0xd75b3f,
roughness: 0.9,
flatShading: true
}),
fruitLight: new THREE.MeshStandardMaterial({
color: 0xe98b42,
roughness: 0.9,
flatShading: true
}),
snow: new THREE.MeshStandardMaterial({
color: 0xf0f5f2,
roughness: 1,
flatShading: true
}),
rock: new THREE.MeshStandardMaterial({
color: 0x8b9285,
roughness: 1,
flatShading: true
}),
rockLight: new THREE.MeshStandardMaterial({
color: 0xa9aa9c,
roughness: 1,
flatShading: true
}),
grass: new THREE.MeshStandardMaterial({
color: 0x78945f,
roughness: 1,
flatShading: true
}),
grassLight: new THREE.MeshStandardMaterial({
color: 0x93aa6e,
roughness: 1,
flatShading: true
})
};
const plotGroundMaterials = {
bud: new THREE.MeshStandardMaterial({
color: 0xa4bd80,
roughness: 1,
flatShading: true
}),
blossom: new THREE.MeshStandardMaterial({
color: 0xa8c58c,
roughness: 1,
flatShading: true
}),
fruit: new THREE.MeshStandardMaterial({
color: 0x789b63,
roughness: 1,
flatShading: true
}),
dormant: new THREE.MeshStandardMaterial({
color: 0xdbe7e3,
roughness: 1,
flatShading: true
})
};
const icoHigh = new THREE.IcosahedronGeometry(1, 1);
const icoLow = new THREE.IcosahedronGeometry(1, 0);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const grassBladeGeometry = new THREE.ConeGeometry(0.065, 0.42, 3);
const swayingBlobs = [];
const fallingPetals = [];
function mulberry32(seed) {
return function () {
let value = (seed += 0x6d2b79f5);
value = Math.imul(value ^ (value >>> 15), value | 1);
value ^=
value + Math.imul(value ^ (value >>> 7), value | 61);
return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
};
}
function range(random, min, max) {
return min + (max - min) * random();
}
function addBlob(parent, position, scale, material, detailed = true) {
const mesh = new THREE.Mesh(
detailed ? icoHigh : icoLow,
material
);
mesh.position.copy(position);
mesh.scale.set(scale[0], scale[1], scale[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSegment(parent, start, end, radiusBottom, radiusTop, material) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const geometry = new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
length,
7,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Soft floor beneath the floating diorama.
const shadowFloor = new THREE.Mesh(
new THREE.CircleGeometry(20, 64),
materials.shadowFloor
);
shadowFloor.rotation.x = -Math.PI * 0.5;
shadowFloor.position.y = -0.94;
shadowFloor.receiveShadow = true;
scene.add(shadowFloor);
// Faceted landscape island.
const island = new THREE.Mesh(
new THREE.CylinderGeometry(7.25, 6.85, 0.9, 32, 1, false),
[
materials.islandSide,
materials.islandTop,
materials.islandBottom
]
);
island.position.y = -0.45;
island.receiveShadow = true;
island.castShadow = true;
scene.add(island);
// Soft cross-shaped paths.
const pathA = new THREE.Mesh(unitBox, materials.path);
pathA.scale.set(0.62, 0.045, 11.4);
pathA.position.y = 0.035;
pathA.receiveShadow = true;
scene.add(pathA);
const pathB = new THREE.Mesh(unitBox, materials.path);
pathB.scale.set(11.4, 0.045, 0.62);
pathB.position.y = 0.036;
pathB.receiveShadow = true;
scene.add(pathB);
// Low-poly rocks around the perimeter.
for (let index = 0; index < 15; index++) {
const angle = (index / 15) * Math.PI * 2 + range(Math.random, -0.12, 0.12);
const radius = range(Math.random, 5.85, 6.65);
const size = range(Math.random, 0.12, 0.3);
const rock = addBlob(
scene,
new THREE.Vector3(
Math.cos(angle) * radius,
size * 0.55,
Math.sin(angle) * radius
),
[size * 1.2, size * 0.8, size],
index % 3 === 0 ? materials.rockLight : materials.rock
);
rock.rotation.set(
range(Math.random, -0.3, 0.3),
range(Math.random, 0, Math.PI),
range(Math.random, -0.25, 0.25)
);
}
// Small angular grass tufts.
for (let index = 0; index < 25; index++) {
const angle = (index / 25) * Math.PI * 2 + range(Math.random, -0.2, 0.2);
const radius = range(Math.random, 5.1, 6.6);
const tuft = new THREE.Group();
tuft.position.set(
Math.cos(angle) * radius,
0.02,
Math.sin(angle) * radius
);
for (let blade = 0; blade < 3; blade++) {
const grass = new THREE.Mesh(
grassBladeGeometry,
blade % 2 ? materials.grass : materials.grassLight
);
grass.position.set(
range(Math.random, -0.1, 0.1),
0.2,
range(Math.random, -0.1, 0.1)
);
grass.scale.setScalar(range(Math.random, 0.7, 1.25));
grass.rotation.z = range(Math.random, -0.3, 0.3);
grass.rotation.y = range(Math.random, 0, Math.PI);
grass.castShadow = true;
tuft.add(grass);
}
scene.add(tuft);
}
function createTree(stage, seed) {
const tree = new THREE.Group();
const random = mulberry32(seed);
const bark =
stage === "dormant" ? materials.dormantBark : materials.bark;
const tips = [];
addSegment(
tree,
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0.04, 1.18, 0.01),
0.22,
0.145,
bark
);
function grow(start, direction, length, radius, depth) {
const end = start
.clone()
.addScaledVector(direction, length);
addSegment(tree, start, end, radius, radius * 0.76, bark);
if (depth === 0) {
tips.push({ point: end, direction: direction.clone() });
return;
}
const childCount = depth === 3 ? 3 : 2;
for (let child = 0; child < childCount; child++) {
const angle =
(child / childCount) * Math.PI * 2 +
random() * 0.9 +
depth * 0.31;
const radial = new THREE.Vector3(
Math.cos(angle),
0,
Math.sin(angle)
);
const nextDirection = direction
.clone()
.multiplyScalar(0.48)
.addScaledVector(radial, 0.74);
nextDirection.y =
Math.max(0.2, direction.y * 0.5 + 0.24 + random() * 0.2);
nextDirection.normalize();
grow(
end,
nextDirection,
length * range(random, 0.66, 0.76),
radius * 0.66,
depth - 1
);
}
}
grow(
new THREE.Vector3(0.01, 0.68, 0),
new THREE.Vector3(0.02, 1, 0.02).normalize(),
0.82,
0.145,
3
);
if (stage === "bud") {
for (const tip of tips) {
const leafPosition = tip.point.clone().add(
new THREE.Vector3(
range(random, -0.1, 0.1),
0.03,
range(random, -0.1, 0.1)
)
);
const leaf = addBlob(
tree,
leafPosition,
[0.18, 0.25, 0.16],
materials.budLeaf
);
swayingBlobs.push({
mesh: leaf,
base: leaf.position.clone(),
phase: random() * Math.PI * 2
});
for (let bud = 0; bud < 3; bud++) {
addBlob(
tree,
tip.point.clone().add(
new THREE.Vector3(
range(random, -0.11, 0.11),
range(random, -0.02, 0.12),
range(random, -0.11, 0.11)
)
),
[0.065, 0.105, 0.065],
materials.bud,
false
);
}
}
}
if (stage === "blossom") {
const blossomMaterials = [
materials.blossomPink,
materials.blossomLight,
materials.blossomDeep
];
for (const tip of tips) {
for (let cluster = 0; cluster < 2; cluster++) {
const offset = new THREE.Vector3(
range(random, -0.24, 0.24),
range(random, -0.04, 0.22),
range(random, -0.24, 0.24)
);
const flower = addBlob(
tree,
tip.point.clone().add(offset),
[
range(random, 0.32, 0.46),
range(random, 0.28, 0.42),
range(random, 0.32, 0.46)
],
blossomMaterials[Math.floor(random() * blossomMaterials.length)]
);
swayingBlobs.push({
mesh: flower,
base: flower.position.clone(),
phase: random() * Math.PI * 2
});
}
const centerPosition = tip.point
.clone()
.add(
tip.direction
.clone()
.multiplyScalar(0.24)
.add(new THREE.Vector3(0, 0.12, 0))
);
addBlob(
tree,
centerPosition,
[0.075, 0.075, 0.075],
materials.flowerCenter,
false
);
}
}
if (stage === "fruit") {
for (let index = 0; index < tips.length; index++) {
const tip = tips[index];
for (let cluster = 0; cluster < 2; cluster++) {
const offset = new THREE.Vector3(
range(random, -0.3, 0.3),
range(random, -0.05, 0.24),
range(random, -0.3, 0.3)
);
const leafCluster = addBlob(
tree,
tip.point.clone().add(offset),
[
range(random, 0.43, 0.6),
range(random, 0.37, 0.52),
range(random, 0.43, 0.6)
],
index % 3 === 0 ? materials.leafDark : materials.leaf
);
swayingBlobs.push({
mesh: leafCluster,
base: leafCluster.position.clone(),
phase: random() * Math.PI * 2
});
}
if (index % 2 === 0) {
addBlob(
tree,
tip.point.clone().add(
new THREE.Vector3(
range(random, -0.26, 0.26),
range(random, -0.28, -0.08),
range(random, -0.26, 0.26)
)
),
[0.115, 0.13, 0.115],
index % 4 === 0 ? materials.fruitLight : materials.fruit,
false
);
}
}
}
if (stage === "dormant") {
for (let index = 0; index < tips.length; index += 2) {
const tip = tips[index];
addBlob(
tree,
tip.point.clone().add(new THREE.Vector3(0, 0.035, 0)),
[0.19, 0.065, 0.15],
materials.snow,
false
);
}
addBlob(
tree,
new THREE.Vector3(0.02, 1.19, 0.01),
[0.17, 0.055, 0.15],
materials.snow,
false
);
}
return tree;
}
function addPlotDetails(plot, stage, tree, seed) {
const random = mulberry32(seed + 900);
if (stage === "bud") {
for (let index = 0; index < 7; index++) {
const angle = random() * Math.PI * 2;
const radius = range(random, 0.8, 1.45);
const shoot = new THREE.Mesh(
grassBladeGeometry,
materials.budLeaf
);
shoot.position.set(
Math.cos(angle) * radius,
0.12,
Math.sin(angle) * radius
);
shoot.scale.setScalar(range(random, 0.5, 0.85));
shoot.rotation.z = range(random, -0.3, 0.3);
tree.add(shoot);
}
}
if (stage === "blossom") {
for (let index = 0; index < 18; index++) {
const angle = random() * Math.PI * 2;
const radius = range(random, 0.35, 1.5);
addBlob(
tree,
new THREE.Vector3(
Math.cos(angle) * radius,
0.025,
Math.sin(angle) * radius
),
[0.065, 0.018, 0.04],
index % 3 === 0
? materials.blossomLight
: materials.blossomPink,
false
);
}
for (let index = 0; index < 12; index++) {
const petal = addBlob(
tree,
new THREE.Vector3(
range(random, -1.25, 1.25),
range(random, 0.65, 3.0),
range(random, -1.25, 1.25)
),
[0.055, 0.012, 0.085],
index % 2
? materials.blossomLight
: materials.blossomPink,
false
);
fallingPetals.push({
mesh: petal,
speed: range(random, 0.16, 0.28),
phase: random() * Math.PI * 2,
resetY: range(random, 2.75, 3.25)
});
}
}
if (stage === "fruit") {
for (let index = 0; index < 6; index++) {
const angle = random() * Math.PI * 2;
const radius = range(random, 0.55, 1.45);
addBlob(
tree,
new THREE.Vector3(
Math.cos(angle) * radius,
0.08,
Math.sin(angle) * radius
),
[0.11, 0.12, 0.11],
index % 2 ? materials.fruit : materials.fruitLight,
false
);
}
}
if (stage === "dormant") {
for (let index = 0; index < 7; index++) {
const angle = random() * Math.PI * 2;
const radius = range(random, 0.45, 1.5);
const size = range(random, 0.18, 0.38);
addBlob(
tree,
new THREE.Vector3(
Math.cos(angle) * radius,
size * 0.14,
Math.sin(angle) * radius
),
[size, size * 0.24, size * 0.8],
materials.snow
);
}
}
}
const plots = [
{ stage: "bud", x: -2.45, z: -2.25 },
{ stage: "blossom", x: 2.35, z: -2.25 },
{ stage: "fruit", x: 2.35, z: 2.2 },
{ stage: "dormant", x: -2.45, z: 2.2 }
];
const labels = [
{
element: document.querySelector("#label-bud"),
anchor: new THREE.Vector3(-2.45, 3.25, -2.25)
},
{
element: document.querySelector("#label-blossom"),
anchor: new THREE.Vector3(2.35, 3.35, -2.25)
},
{
element: document.querySelector("#label-fruit"),
anchor: new THREE.Vector3(2.35, 3.35, 2.2)
},
{
element: document.querySelector("#label-dormant"),
anchor: new THREE.Vector3(-2.45, 3.15, 2.2)
}
];
plots.forEach((plot, index) => {
const plotGroup = new THREE.Group();
plotGroup.position.set(plot.x, 0, plot.z);
scene.add(plotGroup);
const soil = new THREE.Mesh(
new THREE.CylinderGeometry(1.88, 1.92, 0.18, 12),
materials.soil
);
soil.position.y = 0.11;
soil.receiveShadow = true;
soil.castShadow = true;
plotGroup.add(soil);
const ground = new THREE.Mesh(
new THREE.CylinderGeometry(1.75, 1.78, 0.1, 12),
plotGroundMaterials[plot.stage]
);
ground.position.y = 0.24;
ground.receiveShadow = true;
plotGroup.add(ground);
// Small wooden edging around each plot.
for (let side = 0; side < 12; side++) {
const angle = (side / 12) * Math.PI * 2;
const edge = new THREE.Mesh(unitBox, materials.wood);
edge.position.set(
Math.cos(angle) * 1.82,
0.31,
Math.sin(angle) * 1.82
);
edge.scale.set(0.75, 0.19, 0.11);
edge.rotation.y = -angle - Math.PI * 0.5;
edge.castShadow = true;
edge.receiveShadow = true;
plotGroup.add(edge);
}
const tree = createTree(plot.stage, 1200 + index * 311);
tree.position.y = 0.3;
plotGroup.add(tree);
addPlotDetails(plot, plot.stage, tree, 1200 + index * 311);
});
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
const cosPhi = Math.cos(orbit.phi);
camera.position.set(
cameraTarget.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
cameraTarget.y + orbit.radius * cosPhi,
cameraTarget.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
}
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const projected = label.anchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
}
function resetView() {
orbit.targetTheta = 0.55;
orbit.targetPhi = 0.96;
orbit.targetRadius = fitDistance();
orbit.userMoved = false;
}
document.querySelector("#reset-view").addEventListener("click", resetView);
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
orbit.userMoved = true;
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.targetTheta -= deltaX * 0.006;
orbit.targetPhi = THREE.MathUtils.clamp(
orbit.targetPhi + deltaY * 0.005,
0.42,
1.28
);
});
function endDrag(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.userMoved = true;
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius + event.deltaY * 0.012,
8.5,
42
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
orbit.targetTheta -= 0.09;
break;
case "ArrowRight":
orbit.targetTheta += 0.09;
break;
case "ArrowUp":
orbit.targetPhi = Math.max(0.42, orbit.targetPhi - 0.07);
break;
case "ArrowDown":
orbit.targetPhi = Math.min(1.28, orbit.targetPhi + 0.07);
break;
case "+":
case "=":
orbit.targetRadius = Math.max(8.5, orbit.targetRadius - 0.7);
break;
case "-":
case "_":
orbit.targetRadius = Math.min(42, orbit.targetRadius + 0.7);
break;
case "0":
resetView();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
orbit.userMoved = true;
}
});
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.updateProjectionMatrix();
if (!orbit.userMoved) {
orbit.targetRadius = fitDistance();
orbit.radius = orbit.targetRadius;
}
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const smoothing = reducedMotion ? 1 : 1 - Math.exp(-delta * 8);
orbit.theta += (orbit.targetTheta - orbit.theta) * smoothing;
orbit.phi += (orbit.targetPhi - orbit.phi) * smoothing;
orbit.radius += (orbit.targetRadius - orbit.radius) * smoothing;
updateCamera();
if (!reducedMotion) {
for (const entry of swayingBlobs) {
entry.mesh.position.x =
entry.base.x + Math.sin(elapsed * 0.75 + entry.phase) * 0.022;
entry.mesh.position.z =
entry.base.z + Math.cos(elapsed * 0.61 + entry.phase) * 0.018;
entry.mesh.rotation.z =
Math.sin(elapsed * 0.7 + entry.phase) * 0.018;
}
for (const petal of fallingPetals) {
petal.mesh.position.y -= delta * petal.speed;
petal.mesh.position.x +=
Math.sin(elapsed * 1.5 + petal.phase) * delta * 0.09;
petal.mesh.rotation.x += delta * 1.7;
petal.mesh.rotation.z += delta * 0.9;
if (petal.mesh.position.y < 0.025) {
petal.mesh.position.y = petal.resetY;
}
}
}
updateLabels();
renderer.render(scene, camera);
}
resetView();
resize();
updateCamera();
animate();
</script>
</body>
</html>
```