Prompt specification
Build or customize the Three.js 3D scene "Mixed farm annual calendar" 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: Mixed farm annual calendar
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/mixed-farm-annual-calendar-x1051
Scene Description Prompt:
Make one HTML scene with Three.js from cdnjs showing a voxel mixed farm’s seasonal crops, orchard, and storage shed while paths remain unchanged.
Working Three.js Starter (mixed-farm-annual-calendar-x1051):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Four Seasons Farm</title>
<style>
:root {
--accent: #77bd6d;
--panel: rgba(21, 35, 31, 0.86);
--panel-border: rgba(255, 255, 255, 0.14);
--text: #f6f4e9;
--muted: #b9c7bd;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c7e8f3;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--panel-border);
border-radius: 18px;
background: var(--panel);
box-shadow:
0 18px 55px rgba(20, 29, 24, 0.24),
inset 0 1px rgba(255, 255, 255, 0.05);
backdrop-filter: blur(16px) saturate(125%);
-webkit-backdrop-filter: blur(16px) saturate(125%);
}
.brand {
top: 18px;
left: 18px;
max-width: min(390px, calc(100vw - 36px));
padding: 17px 19px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
transition: color 250ms ease;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 2px;
background: currentColor;
box-shadow: 0 0 14px currentColor;
content: "";
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 37px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.subtitle {
margin: 9px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.controls {
top: 18px;
right: 18px;
width: 306px;
padding: 15px;
}
.control-title {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 2px 11px;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.season-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 7px;
}
.season-button {
min-width: 0;
padding: 10px 3px 9px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 11px;
background: rgba(255, 255, 255, 0.055);
color: var(--muted);
cursor: pointer;
transition:
transform 160ms ease,
background 160ms ease,
color 160ms ease,
border-color 160ms ease;
}
.season-button:hover {
transform: translateY(-2px);
background: rgba(255, 255, 255, 0.1);
color: #fff;
}
.season-button.active {
border-color: var(--accent);
background: color-mix(in srgb, var(--accent) 25%, transparent);
color: #fff;
box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent);
}
.season-icon {
display: block;
margin-bottom: 5px;
font-size: 20px;
line-height: 1;
}
.season-name {
display: block;
font-size: 11px;
font-weight: 750;
}
.control-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 10px;
}
.utility-button {
padding: 10px 9px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 10px;
background: rgba(255, 255, 255, 0.055);
color: var(--text);
cursor: pointer;
font-size: 12px;
font-weight: 700;
transition: background 160ms ease, transform 160ms ease;
}
.utility-button:hover {
transform: translateY(-1px);
background: rgba(255, 255, 255, 0.11);
}
.utility-button.active {
border-color: var(--accent);
color: var(--accent);
}
.season-info {
bottom: 18px;
left: 18px;
width: min(350px, calc(100vw - 36px));
padding: 17px 19px;
pointer-events: none;
}
.season-info h2 {
margin: 0 0 6px;
font-size: 20px;
letter-spacing: -0.025em;
}
.season-info p {
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.crop-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 12px;
}
.crop-tag {
padding: 5px 8px;
border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
border-radius: 999px;
background: color-mix(in srgb, var(--accent) 13%, transparent);
color: #f8fff7;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
}
.path-lock {
display: flex;
align-items: center;
gap: 8px;
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
color: #d6e6d5;
font-size: 11px;
font-weight: 700;
}
.path-dot {
position: relative;
width: 10px;
height: 10px;
border: 2px solid #9fd49b;
border-radius: 50%;
}
.path-dot::after {
position: absolute;
top: 50%;
left: 50%;
width: 8px;
height: 2px;
border-radius: 2px;
background: #9fd49b;
transform: translate(-50%, -50%);
content: "";
}
.hint {
right: 18px;
bottom: 18px;
padding: 11px 14px;
color: var(--muted);
font-size: 11px;
pointer-events: none;
}
.hint strong {
color: var(--text);
}
@media (max-width: 760px) {
.brand {
top: 10px;
left: 10px;
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls {
top: 92px;
right: 10px;
width: min(300px, calc(100vw - 20px));
}
.season-info {
bottom: 10px;
left: 10px;
width: min(340px, calc(100vw - 20px));
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel farm"></div>
<header class="brand panel">
<div class="eyebrow">Four Seasons Farm</div>
<h1>One farm.<br />Four harvests.</h1>
<p class="subtitle">
A mixed voxel farm with seasonal fields, a flowering orchard, and a
working storage shed.
</p>
</header>
<section class="controls panel" aria-label="Scene controls">
<div class="control-title">
<span>Season</span>
<span id="seasonBadge">Spring</span>
</div>
<div class="season-grid">
<button class="season-button active" data-season="spring" aria-pressed="true">
<span class="season-icon">🌱</span>
<span class="season-name">Spring</span>
</button>
<button class="season-button" data-season="summer" aria-pressed="false">
<span class="season-icon">☀️</span>
<span class="season-name">Summer</span>
</button>
<button class="season-button" data-season="autumn" aria-pressed="false">
<span class="season-icon">🍂</span>
<span class="season-name">Autumn</span>
</button>
<button class="season-button" data-season="winter" aria-pressed="false">
<span class="season-icon">❄️</span>
<span class="season-name">Winter</span>
</button>
</div>
<div class="control-row">
<button class="utility-button" id="autoButton">▶ Auto cycle</button>
<button class="utility-button" id="resetButton">↺ Reset view</button>
</div>
</section>
<section class="season-info panel" aria-live="polite">
<h2 id="seasonTitle">Seedlings & blossom</h2>
<p id="seasonDescription">
Young vegetables fill the fields while the orchard wakes with pale blossoms.
</p>
<div class="crop-tags" id="cropTags"></div>
<div class="path-lock">
<span class="path-dot"></span>
Fixed paths enabled — the route network never changes.
</div>
</section>
<div class="hint panel">
<strong>Drag</strong> to orbit · <strong>Scroll</strong> to zoom ·
<strong>Arrow keys</strong> to rotate
</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 lights
// -------------------------------------------------------------------------
const host = document.querySelector("#scene");
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;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#c8e9f5");
scene.fog = new THREE.Fog("#d7edf2", 62, 118);
const camera = new THREE.OrthographicCamera(-30, 30, 20, -20, 0.1, 220);
const cameraTarget = new THREE.Vector3(0, 1.2, 0);
let azimuth = -0.72;
let targetAzimuth = -0.72;
let elevation = 0.72;
let targetElevation = 0.72;
let zoom = 1;
let targetZoom = 1;
const hemisphere = new THREE.HemisphereLight("#f5fbff", "#52613b", 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff1cf", 3.2);
sun.position.set(-24, 38, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -34;
sun.shadow.camera.right = 34;
sun.shadow.camera.top = 34;
sun.shadow.camera.bottom = -34;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 100;
sun.shadow.bias = -0.0005;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9ddff", 0.55);
fill.position.set(25, 18, -25);
scene.add(fill);
// -------------------------------------------------------------------------
// Voxel helpers and materials
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function mat(color, roughness = 0.88, metalness = 0) {
const key = `${color}:${roughness}:${metalness}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
})
);
}
return materialCache.get(key);
}
function box(
parent,
sx,
sy,
sz,
x,
y,
z,
material,
castShadow = true
) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(sx, sy, sz);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const M = {
outerGrass: mat("#76934e"),
grass: mat("#7ca652"),
grassDark: mat("#64883f"),
soil: mat("#5f402c"),
soilLight: mat("#765039"),
path: mat("#c9ae78"),
pathPaver: mat("#ddc58f"),
pathEdge: mat("#a98d62"),
trunk: mat("#765035"),
branch: mat("#65452e"),
fence: mat("#a77c50"),
wall: mat("#c99c65"),
wallDark: mat("#ad7f4d"),
beam: mat("#694732"),
roof: mat("#91473d"),
roofDark: mat("#71362f"),
door: mat("#49352b"),
crate: mat("#a87542"),
crateDark: mat("#7c542f"),
pot: mat("#b06c43"),
window: mat("#91cad1", 0.25, 0.12),
snow: mat("#f4fbff"),
stone: mat("#8b8c77"),
hay: mat("#d5ad52"),
dark: mat("#27352f")
};
// -------------------------------------------------------------------------
// Ground and permanent path network
// -------------------------------------------------------------------------
box(scene, 110, 0.5, 90, 0, -1.65, 0, M.outerGrass, false);
box(scene, 44, 1.2, 34, 0, -0.6, 0, M.grass);
box(scene, 44.3, 0.22, 34.3, 0, -1.16, 0, M.grassDark);
// This group is created once and is never rebuilt or hidden.
// Seasonal changes are applied only to crops, foliage, produce, and weather.
const pathGroup = new THREE.Group();
pathGroup.name = "Permanent path network";
pathGroup.userData.permanent = true;
scene.add(pathGroup);
function pathStrip(x, z, width, depth) {
box(pathGroup, width + 0.34, 0.12, depth + 0.34, x, 0.055, z, M.pathEdge, false);
box(pathGroup, width, 0.16, depth, x, 0.12, z, M.path, false);
}
// Main cross path.
pathStrip(0, 3, 44, 2.8);
pathStrip(-3, 0, 2.8, 34);
// Orchard access path.
pathStrip(8, -6.5, 2.8, 19);
// Storage shed access paths.
pathStrip(11, 10, 2.8, 14);
pathStrip(15.7, 8, 9.4, 2.4);
// Voxel paving details.
for (let x = -20.5; x <= 21; x += 2.35) {
box(pathGroup, 2.02, 0.055, 2.28, x, 0.225, 3, M.pathPaver, false);
}
for (let z = -15.5; z <= 15.5; z += 2.35) {
box(pathGroup, 2.28, 0.055, 2.02, -3, 0.225, z, M.pathPaver, false);
}
for (let z = -15; z <= 2; z += 2.35) {
box(pathGroup, 2.28, 0.055, 2.02, 8, 0.225, z, M.pathPaver, false);
}
for (let z = 4; z <= 15.5; z += 2.35) {
box(pathGroup, 2.28, 0.055, 2.02, 11, 0.225, z, M.pathPaver, false);
}
for (let x = 12.5; x <= 19.5; x += 2.35) {
box(pathGroup, 2.02, 0.055, 1.92, x, 0.225, 8, M.pathPaver, false);
}
// -------------------------------------------------------------------------
// Fences and farm decorations
// -------------------------------------------------------------------------
const fenceGroup = new THREE.Group();
scene.add(fenceGroup);
function fenceLine(x1, z1, x2, z2, spacing = 3.5) {
const horizontal = z1 === z2;
const length = horizontal ? Math.abs(x2 - x1) : Math.abs(z2 - z1);
const count = Math.max(2, Math.floor(length / spacing));
for (let i = 0; i <= count; i++) {
const t = i / count;
const x = THREE.MathUtils.lerp(x1, x2, t);
const z = THREE.MathUtils.lerp(z1, z2, t);
box(fenceGroup, 0.28, 1.35, 0.28, x, 0.67, z, M.fence);
box(fenceGroup, 0.38, 0.18, 0.38, x, 1.36, z, M.crateDark);
}
const x = (x1 + x2) / 2;
const z = (z1 + z2) / 2;
if (horizontal) {
box(fenceGroup, length, 0.16, 0.16, x, 0.48, z, M.fence);
box(fenceGroup, length, 0.16, 0.16, x, 0.98, z, M.fence);
} else {
box(fenceGroup, 0.16, 0.16, length, x, 0.48, z, M.fence);
box(fenceGroup, 0.16, 0.16, length, x, 0.98, z, M.fence);
}
}
fenceLine(-21, -16, 21, -16);
fenceLine(-21, -16, -21, 16);
fenceLine(21, -16, 21, 16);
// Small entrance marker, deliberately outside the path.
box(scene, 0.24, 1.8, 0.24, -6.5, 0.9, 15.4, M.beam);
box(scene, 2.4, 0.95, 0.24, -6.5, 1.7, 15.4, M.crate);
const seasonSignMaterial = mat("#77bd6d");
box(scene, 1.8, 0.28, 0.28, -6.5, 1.72, 15.54, seasonSignMaterial);
// Hay bales beside the shed.
for (let i = 0; i < 3; i++) {
box(scene, 1.35, 0.9, 1.0, 19.2, 0.46 + i * 0.92, 15.0, M.hay);
box(scene, 0.08, 0.95, 1.04, 19.2, 0.46 + i * 0.92, 15.0, M.crateDark, false);
}
// -------------------------------------------------------------------------
// Crop fields
// -------------------------------------------------------------------------
const fields = [
{
x: -12.5,
z: -6.2,
width: 13.2,
depth: 9.2,
rows: [-9.4, -7.3, -5.2, -3.1]
},
{
x: -12.5,
z: 10.5,
width: 13.2,
depth: 10.2,
rows: [6.6, 8.7, 10.8, 12.9, 15.0]
}
];
const columns = [-18, -15.8, -13.6, -11.4, -9.2, -7];
const cropSeeds = [];
fields.forEach((field, fieldIndex) => {
box(
scene,
field.width,
0.12,
field.depth,
field.x,
0.06,
field.z,
M.soil,
false
);
field.rows.forEach((z, rowIndex) => {
box(
scene,
field.width - 0.6,
0.08,
0.34,
field.x,
0.15,
z,
M.soilLight,
false
);
columns.forEach((x, columnIndex) => {
cropSeeds.push({
x,
z,
fieldIndex,
rowIndex,
columnIndex
});
});
});
// Small field sign.
const signZ = fieldIndex === 0 ? -10.8 : 15.9;
box(scene, 0.16, 1.1, 0.16, -5.6, 0.55, signZ, M.beam);
box(scene, 1.3, 0.6, 0.16, -5.6, 1.05, signZ, M.crate);
});
const cropGroups = {
spring: new THREE.Group(),
summer: new THREE.Group(),
autumn: new THREE.Group(),
winter: new THREE.Group()
};
Object.values(cropGroups).forEach((group) => scene.add(group));
cropSeeds.forEach((seed, index) => {
const { x, z, fieldIndex, rowIndex, columnIndex } = seed;
const ground = 0.19;
const parity = (rowIndex + columnIndex + fieldIndex) % 3;
// Spring: lettuce and radishes.
if (parity === 0) {
box(cropGroups.spring, 0.32, 0.32, 0.32, x, ground + 0.16, z, mat("#e96c7a"));
box(cropGroups.spring, 0.14, 0.48, 0.14, x, ground + 0.46, z, M.grassDark);
const leafA = box(cropGroups.spring, 0.4, 0.1, 0.16, x - 0.12, ground + 0.52, z, M.grass);
leafA.rotation.z = 0.45;
const leafB = box(cropGroups.spring, 0.4, 0.1, 0.16, x + 0.12, ground + 0.52, z, M.grass);
leafB.rotation.z = -0.45;
} else {
box(cropGroups.spring, 0.84, 0.36, 0.84, x, ground + 0.18, z, mat("#3d803d"));
box(cropGroups.spring, 0.61, 0.25, 0.61, x, ground + 0.44, z, mat("#76b956"));
box(cropGroups.spring, 0.28, 0.12, 0.28, x, ground + 0.61, z, mat("#a1cf68"));
}
// Summer: corn and tomatoes.
if (parity === 0) {
box(cropGroups.summer, 0.14, 1.8, 0.14, x, ground + 0.9, z, mat("#4e8e3e"));
const leafA = box(cropGroups.summer, 0.64, 0.11, 0.22, x - 0.19, ground + 0.75, z, mat("#5b9d43"));
leafA.rotation.z = 0.38;
const leafB = box(cropGroups.summer, 0.64, 0.11, 0.22, x + 0.19, ground + 1.02, z, mat("#69aa4a"));
leafB.rotation.z = -0.38;
box(cropGroups.summer, 0.25, 0.55, 0.25, x + 0.13, ground + 1.18, z, mat("#f0c94f"));
} else {
box(cropGroups.summer, 0.76, 0.7, 0.76, x, ground + 0.35, z, mat("#3f8039"));
box(cropGroups.summer, 0.56, 0.48, 0.56, x, ground + 0.78, z, mat("#589947"));
box(cropGroups.summer, 0.28, 0.28, 0.28, x - 0.24, ground + 0.62, z, mat("#db493c"));
box(cropGroups.summer, 0.28, 0.28, 0.28, x + 0.24, ground + 0.82, z, mat("#e75542"));
}
// Autumn: pumpkins and squash.
if (parity === 0) {
box(cropGroups.autumn, 0.74, 0.54, 0.74, x, ground + 0.27, z, mat("#df7a27"));
box(cropGroups.autumn, 0.36, 0.43, 0.76, x - 0.25, ground + 0.22, z, mat("#ef9635"));
box(cropGroups.autumn, 0.36, 0.43, 0.76, x + 0.25, ground + 0.22, z, mat("#ef9635"));
box(cropGroups.autumn, 0.14, 0.2, 0.14, x, ground + 0.62, z, mat("#557036"));
box(cropGroups.autumn, 0.9, 0.08, 0.12, x + 0.18, ground + 0.05, z, mat("#617d39"), false);
} else {
box(cropGroups.autumn, 0.38, 0.38, 0.85, x - 0.18, ground + 0.19, z, mat("#d5a635"));
box(cropGroups.autumn, 0.38, 0.38, 0.85, x + 0.18, ground + 0.19, z, mat("#e1b842"));
box(cropGroups.autumn, 0.2, 0.16, 0.2, x, ground + 0.46, z, mat("#61783a"));
}
// Winter: hardy kale under light snow.
box(cropGroups.winter, 0.68, 0.35, 0.68, x, ground + 0.18, z, mat("#356c55"));
box(cropGroups.winter, 0.44, 0.22, 0.44, x, ground + 0.44, z, mat("#4f8868"));
box(cropGroups.winter, 0.38, 0.08, 0.38, x, ground + 0.59, z, M.snow, false);
});
// -------------------------------------------------------------------------
// Orchard: permanent trunks with seasonal canopy groups
// -------------------------------------------------------------------------
const orchardPositions = [];
[-13, -8, -3].forEach((z) => {
[1, 4.5, 11, 14.5, 18].forEach((x) => {
orchardPositions.push({ x, z });
});
});
const orchardStatic = new THREE.Group();
scene.add(orchardStatic);
const orchardSeasonGroups = {
spring: new THREE.Group(),
summer: new THREE.Group(),
autumn: new THREE.Group(),
winter: new THREE.Group()
};
Object.values(orchardSeasonGroups).forEach((group) => scene.add(group));
orchardPositions.forEach((tree, index) => {
const { x, z } = tree;
const dx = ((index % 3) - 1) * 0.12;
const dz = ((index % 5) - 2) * 0.07;
box(orchardStatic, 0.72, 2.5, 0.72, x, 1.25, z, M.trunk);
box(orchardStatic, 1.3, 0.32, 0.36, x - 0.25, 2.05, z, M.branch);
box(orchardStatic, 0.36, 0.32, 1.3, x, 2.32, z + 0.18, M.branch);
// Spring canopy and blossoms.
box(orchardSeasonGroups.spring, 2.7, 1.35, 2.7, x + dx, 2.85, z + dz, mat("#79ad59"));
box(orchardSeasonGroups.spring, 1.85, 0.95, 1.85, x + dx, 3.65, z + dz, mat("#94c46b"));
box(orchardSeasonGroups.spring, 0.35, 0.35, 0.35, x - 0.75, 3.05, z + 1.1, mat("#f2a9bd"));
box(orchardSeasonGroups.spring, 0.3, 0.3, 0.3, x + 0.65, 3.55, z + 0.85, mat("#f7bfd0"));
box(orchardSeasonGroups.spring, 0.3, 0.3, 0.3, x + 0.2, 2.75, z - 1.15, mat("#f2a9bd"));
// Summer canopy.
box(orchardSeasonGroups.summer, 2.8, 1.4, 2.8, x + dx, 2.9, z + dz, mat("#3f7f3e"));
box(orchardSeasonGroups.summer, 1.95, 1.0, 1.95, x + dx, 3.75, z + dz, mat("#57994b"));
box(orchardSeasonGroups.summer, 2.0, 0.7, 1.1, x - 0.35, 3.2, z + 0.75, mat("#67a752"));
// Autumn canopy and fruit.
box(orchardSeasonGroups.autumn, 2.75, 1.35, 2.75, x + dx, 2.9, z + dz, mat("#c57a30"));
box(orchardSeasonGroups.autumn, 1.9, 0.95, 1.9, x + dx, 3.7, z + dz, mat("#df963c"));
box(orchardSeasonGroups.autumn, 1.9, 0.72, 1.1, x - 0.45, 3.1, z + 0.72, mat("#b8662f"));
box(orchardSeasonGroups.autumn, 0.3, 0.3, 0.3, x - 0.75, 2.75, z + 1.1, mat("#d94332"));
box(orchardSeasonGroups.autumn, 0.3, 0.3, 0.3, x + 0.65, 3.3, z + 0.95, mat("#e05136"));
box(orchardSeasonGroups.autumn, 0.3, 0.3, 0.3, x + 0.15, 3.9, z - 0.85, mat("#d94332"));
// Winter: sparse crown and snow caps.
box(orchardSeasonGroups.winter, 0.8, 0.55, 0.8, x - 0.55, 2.85, z + 0.25, mat("#8a7655"));
box(orchardSeasonGroups.winter, 0.65, 0.48, 0.65, x + 0.55, 3.12, z - 0.25, mat("#9a8764"));
box(orchardSeasonGroups.winter, 1.0, 0.14, 1.0, x - 0.55, 3.15, z + 0.25, M.snow, false);
box(orchardSeasonGroups.winter, 0.82, 0.13, 0.82, x + 0.55, 3.38, z - 0.25, M.snow, false);
});
// -------------------------------------------------------------------------
// Storage shed
// -------------------------------------------------------------------------
const shed = new THREE.Group();
scene.add(shed);
box(shed, 6, 3.5, 5, 16, 1.75, 11, M.wall);
box(shed, 6.2, 0.32, 5.2, 16, 0.15, 11, M.wallDark);
// Corner timbers.
box(shed, 0.3, 3.65, 0.3, 13.05, 1.8, 8.55, M.beam);
box(shed, 0.3, 3.65, 0.3, 18.95, 1.8, 8.55, M.beam);
box(shed, 0.3, 3.65, 0.3, 13.05, 1.8, 13.45, M.beam);
box(shed, 0.3, 3.65, 0.3, 18.95, 1.8, 13.45, M.beam);
// Stepped voxel gable roof.
const roofPieces = [];
for (let i = 0; i < 5; i++) {
const z = 8.9 + i * 1.05;
const width = 4.7 + (2 - Math.abs(i - 2)) * 1.05;
const y = 3.68 + (2 - Math.abs(i - 2)) * 0.18;
box(shed, width, 0.32, 1.12, 16, y, z, i % 2 ? M.roof : M.roofDark);
roofPieces.push({ width, y, z });
}
// West-facing door.
box(shed, 0.16, 2.35, 1.9, 12.9, 1.18, 11, M.door);
box(shed, 0.2, 0.17, 2.05, 12.78, 1.18, 11, M.beam);
const doorBrace = box(shed, 0.2, 0.15, 2.2, 12.76, 1.18, 11, M.crate);
doorBrace.rotation.x = 0.48;
// South-facing window.
box(shed, 1.6, 1.05, 0.18, 17.4, 2.25, 13.55, M.window);
box(shed, 1.85, 0.13, 0.22, 17.4, 2.25, 13.63, M.beam);
box(shed, 0.13, 1.2, 0.22, 17.4, 2.25, 13.64, M.beam);
// Shed snow, shown only in winter.
const shedSnow = new THREE.Group();
scene.add(shedSnow);
roofPieces.forEach((piece) => {
box(
shedSnow,
piece.width - 0.15,
0.12,
1.0,
16,
piece.y + 0.22,
piece.z,
M.snow,
false
);
});
// Produce crates outside the shed.
function addCrate(x, z) {
box(shed, 1.55, 0.18, 1.25, x, 0.18, z, M.crateDark);
box(shed, 1.55, 0.75, 0.16, x, 0.56, z - 0.55, M.crate);
box(shed, 1.55, 0.75, 0.16, x, 0.56, z + 0.55, M.crate);
box(shed, 0.16, 0.75, 1.0, x - 0.68, 0.56, z, M.crate);
box(shed, 0.16, 0.75, 1.0, x + 0.68, 0.56, z, M.crate);
}
addCrate(13.8, 8.5);
addCrate(13.8, 13.4);
const produceGroups = {
spring: new THREE.Group(),
summer: new THREE.Group(),
autumn: new THREE.Group(),
winter: new THREE.Group()
};
Object.values(produceGroups).forEach((group) => scene.add(group));
[8.5, 13.4].forEach((z) => {
// Spring seedlings.
box(produceGroups.spring, 0.38, 0.34, 0.38, 13.8, 1.0, z, M.pot);
box(produceGroups.spring, 0.28, 0.38, 0.28, 13.8, 1.3, z, M.grassDark);
// Summer vegetables.
box(produceGroups.summer, 0.48, 0.42, 0.48, 13.55, 1.05, z - 0.28, mat("#d84c3f"));
box(produceGroups.summer, 0.45, 0.4, 0.45, 14.03, 1.02, z + 0.28, mat("#edc748"));
// Autumn pumpkins.
box(produceGroups.autumn, 0.62, 0.5, 0.62, 13.8, 1.05, z, mat("#df7a27"));
box(produceGroups.autumn, 0.32, 0.4, 0.65, 13.55, 1.0, z, mat("#ee9131"));
box(produceGroups.autumn, 0.32, 0.4, 0.65, 14.05, 1.0, z, mat("#ee9131"));
// Winter storage sacks.
box(produceGroups.winter, 0.55, 0.65, 0.5, 13.8, 1.1, z, mat("#c8b993"));
box(produceGroups.winter, 0.58, 0.12, 0.52, 13.8, 1.44, z, M.snow, false);
});
// -------------------------------------------------------------------------
// Clouds and winter voxel snow
// -------------------------------------------------------------------------
const clouds = [];
const cloudMaterial = mat("#f7fcff", 1);
function addCloud(x, y, z, scale) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
box(cloud, 2.4, 0.75, 1.1, 0, 0, 0, cloudMaterial, false);
box(cloud, 1.4, 1.0, 1.0, -1.35, 0.1, 0, cloudMaterial, false);
box(cloud, 1.7, 1.2, 1.05, 0.25, 0.2, 0, cloudMaterial, false);
box(cloud, 1.3, 0.8, 0.95, 1.55, 0, 0, cloudMaterial, false);
cloud.userData.speed = 0.18 + Math.random() * 0.12;
clouds.push(cloud);
scene.add(cloud);
}
addCloud(-13, 15.5, -19, 1.25);
addCloud(11, 17.5, -23, 1.6);
addCloud(22, 13.5, -17, 1.0);
const snowCount = 110;
const snowGeometry = new THREE.BoxGeometry(0.09, 0.09, 0.09);
const snowMaterial = mat("#ffffff", 1);
const snowMesh = new THREE.InstancedMesh(snowGeometry, snowMaterial, snowCount);
snowMesh.frustumCulled = false;
snowMesh.visible = false;
scene.add(snowMesh);
const snowData = [];
const snowDummy = new THREE.Object3D();
for (let i = 0; i < snowCount; i++) {
snowData.push({
x: (Math.random() - 0.5) * 48,
y: 1 + Math.random() * 15,
z: (Math.random() - 0.5) * 36,
speed: 0.8 + Math.random() * 1.1,
drift: Math.random() * Math.PI * 2
});
}
// -------------------------------------------------------------------------
// Seasons
// -------------------------------------------------------------------------
const seasons = {
spring: {
name: "Spring",
title: "Seedlings & blossom",
description:
"Young vegetables fill the fields while the orchard wakes with pale blossoms.",
crops: ["Lettuce", "Radish", "Apple blossom"],
sky: "#c8e9f5",
fog: "#d7edf2",
grass: "#7ca652",
accent: "#77bd6d",
sun: "#fff1d4"
},
summer: {
name: "Summer",
title: "Corn, tomatoes & full canopy",
description:
"Tall corn and bright tomatoes grow between deeply green orchard trees.",
crops: ["Corn", "Tomatoes", "Summer apples"],
sky: "#a9ddf2",
fog: "#c2e6ee",
grass: "#628d40",
accent: "#f1bd48",
sun: "#fff0bd"
},
autumn: {
name: "Autumn",
title: "Pumpkins & orchard gold",
description:
"Orange pumpkins roll into the furrows as the orchard turns copper and red.",
crops: ["Pumpkins", "Squash", "Red apples"],
sky: "#efd3a3",
fog: "#ead4ad",
grass: "#8b9149",
accent: "#df8734",
sun: "#ffd08b"
},
winter: {
name: "Winter",
title: "Snow, kale & stored harvest",
description:
"Hardy greens remain beneath the snow while the storage shed holds the harvest.",
crops: ["Winter kale", "Root crops", "Stored produce"],
sky: "#d7e5eb",
fog: "#dce7eb",
grass: "#718172",
accent: "#87b9d3",
sun: "#e4f1ff"
}
};
const seasonButtons = [...document.querySelectorAll(".season-button")];
const seasonBadge = document.querySelector("#seasonBadge");
const seasonTitle = document.querySelector("#seasonTitle");
const seasonDescription = document.querySelector("#seasonDescription");
const cropTags = document.querySelector("#cropTags");
const autoButton = document.querySelector("#autoButton");
let activeSeason = "spring";
let autoTimer = null;
function setSeason(seasonName) {
activeSeason = seasonName;
const data = seasons[seasonName];
Object.entries(cropGroups).forEach(([key, group]) => {
group.visible = key === seasonName;
});
Object.entries(orchardSeasonGroups).forEach(([key, group]) => {
group.visible = key === seasonName;
});
Object.entries(produceGroups).forEach(([key, group]) => {
group.visible = key === seasonName;
});
shedSnow.visible = seasonName === "winter";
snowMesh.visible = seasonName === "winter";
scene.background.set(data.sky);
scene.fog.color.set(data.fog);
M.grass.color.set(data.grass);
sun.color.set(data.sun);
seasonSignMaterial.color.set(data.accent);
document.documentElement.style.setProperty("--accent", data.accent);
seasonBadge.textContent = data.name;
seasonTitle.textContent = data.title;
seasonDescription.textContent = data.description;
cropTags.innerHTML = data.crops
.map((crop) => `<span class="crop-tag">${crop}</span>`)
.join("");
seasonButtons.forEach((button) => {
const active = button.dataset.season === seasonName;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
// The permanent path group is intentionally untouched here.
}
seasonButtons.forEach((button) => {
button.addEventListener("click", () => setSeason(button.dataset.season));
});
autoButton.addEventListener("click", () => {
if (autoTimer !== null) {
clearInterval(autoTimer);
autoTimer = null;
autoButton.classList.remove("active");
autoButton.textContent = "▶ Auto cycle";
} else {
autoTimer = setInterval(() => {
const names = Object.keys(seasons);
const next = names[(names.indexOf(activeSeason) + 1) % names.length];
setSeason(next);
}, 4200);
autoButton.classList.add("active");
autoButton.textContent = "Ⅱ Pause cycle";
}
});
// -------------------------------------------------------------------------
// Direct camera controls: pointer orbit, wheel zoom, keyboard orbit
// -------------------------------------------------------------------------
const canvas = renderer.domElement;
let dragging = false;
let lastX = 0;
let lastY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - lastX;
const deltaY = event.clientY - lastY;
targetAzimuth -= deltaX * 0.006;
targetElevation = THREE.MathUtils.clamp(
targetElevation + deltaY * 0.0045,
0.3,
1.28
);
lastX = event.clientX;
lastY = event.clientY;
});
function stopDragging(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
targetZoom = THREE.MathUtils.clamp(
targetZoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.75
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const step = 0.1;
if (event.key === "ArrowLeft") targetAzimuth += step;
if (event.key === "ArrowRight") targetAzimuth -= step;
if (event.key === "ArrowUp") targetElevation += step * 0.75;
if (event.key === "ArrowDown") targetElevation -= step * 0.75;
if (event.key === "+" || event.key === "=") targetZoom *= 1.08;
if (event.key === "-" || event.key === "_") targetZoom /= 1.08;
targetElevation = THREE.MathUtils.clamp(targetElevation, 0.3, 1.28);
targetZoom = THREE.MathUtils.clamp(targetZoom, 0.65, 1.75);
});
document.querySelector("#resetButton").addEventListener("click", () => {
targetAzimuth = -0.72;
targetElevation = 0.72;
targetZoom = 1;
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = aspect < 0.75 ? 72 : aspect < 1.2 ? 48 : 40;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
setSeason("spring");
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
// Smooth camera orbit and zoom.
azimuth += (targetAzimuth - azimuth) * 0.09;
elevation += (targetElevation - elevation) * 0.09;
zoom += (targetZoom - zoom) * 0.1;
camera.zoom = zoom;
camera.updateProjectionMatrix();
const horizontalDistance = 70 * Math.cos(elevation);
camera.position.set(
cameraTarget.x + Math.sin(azimuth) * horizontalDistance,
cameraTarget.y + Math.sin(elevation) * 70,
cameraTarget.z + Math.cos(azimuth) * horizontalDistance
);
camera.lookAt(cameraTarget);
// Gentle voxel cloud drift.
clouds.forEach((cloud) => {
cloud.position.x += cloud.userData.speed * delta;
if (cloud.position.x > 29) cloud.position.x = -29;
});
// Update only visible winter snow.
if (snowMesh.visible) {
snowData.forEach((flake, index) => {
flake.y -= flake.speed * delta;
flake.x += Math.sin(elapsed * 0.8 + flake.drift) * delta * 0.18;
if (flake.y < 0) {
flake.y = 15 + Math.random() * 3;
flake.x = (Math.random() - 0.5) * 48;
flake.z = (Math.random() - 0.5) * 36;
}
snowDummy.position.set(flake.x, flake.y, flake.z);
snowDummy.rotation.set(elapsed * 0.4, elapsed * 0.3, 0);
snowDummy.updateMatrix();
snowMesh.setMatrixAt(index, snowDummy.matrix);
});
snowMesh.instanceMatrix.needsUpdate = true;
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```