Prompt specification
Build or customize the Three.js 3D scene "Fantasy Orchard Creature Care Scene" 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: Fantasy Orchard Creature Care Scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/fantasy-orchard-creature-care-scene-x3723
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: fantasy orchard creature care scene. Build an original orchard with friendly invented creatures carrying fruit baskets. Preserve believable contact and movement while clearly separating fantasy biology from real ecological claims. Return one self-contained HTML file.
Working Three.js Starter (fantasy-orchard-creature-care-scene-x3723):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#9dd7df">
<title>Moonpear Orchard — Voxel Creature Care</title>
<style>
:root {
--ink: #173b38;
--paper: #fff9e9;
--paper-soft: rgba(255, 249, 233, 0.9);
--green: #2f7560;
--gold: #f4bc58;
--coral: #e98270;
--shadow: 0 12px 35px rgba(32, 66, 57, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #9dd7df;
color: var(--ink);
font-family: ui-rounded, "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
#scene:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.card {
pointer-events: auto;
background: var(--paper-soft);
border: 1px solid rgba(255, 255, 255, 0.75);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.brand {
position: absolute;
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 19px 21px 18px;
border-radius: 22px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: #4d796c;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 9px;
height: 9px;
content: "";
background: var(--gold);
border: 2px solid rgba(23, 59, 56, 0.2);
box-shadow: 3px 3px 0 rgba(23, 59, 56, 0.14);
}
h1 {
margin: 0;
font-size: clamp(28px, 4vw, 45px);
line-height: 0.96;
letter-spacing: -0.055em;
}
.brand p {
max-width: 330px;
margin: 10px 0 0;
color: #527269;
font-size: 13px;
line-height: 1.5;
}
.fiction {
position: absolute;
top: 22px;
right: 22px;
width: min(310px, calc(100vw - 44px));
padding: 15px 17px;
border-radius: 18px;
border-left: 5px solid var(--gold);
}
.fiction strong {
display: block;
margin-bottom: 5px;
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.fiction p {
margin: 0;
color: #5a746c;
font-size: 11px;
line-height: 1.5;
}
.controls {
position: absolute;
left: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 9px;
padding: 10px;
border-radius: 18px;
}
.controls button {
min-height: 38px;
padding: 0 14px;
border: 0;
border-radius: 12px;
background: #e7f2d8;
color: var(--ink);
font-size: 12px;
font-weight: 800;
cursor: pointer;
transition: transform 120ms ease, background 120ms ease;
}
.controls button:hover {
background: #d5e9c4;
transform: translateY(-1px);
}
.controls button:active {
transform: translateY(1px);
}
.controls button.primary {
background: var(--green);
color: #fffdf4;
}
.hint {
padding: 0 8px 0 4px;
color: #647b72;
font-size: 11px;
white-space: nowrap;
}
.inspector {
position: absolute;
right: 22px;
bottom: 22px;
width: min(330px, calc(100vw - 44px));
padding: 17px 18px;
border-radius: 20px;
}
.inspector .mini-label {
margin-bottom: 5px;
color: #789086;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.inspector h2 {
margin: 0;
font-size: 21px;
letter-spacing: -0.03em;
}
.inspector p {
margin: 7px 0 0;
color: #5a746c;
font-size: 12px;
line-height: 1.5;
}
#labels {
position: fixed;
inset: 0;
z-index: 4;
pointer-events: none;
overflow: hidden;
}
.creature-tag {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
min-width: max-content;
padding: 6px 10px 6px 7px;
border: 1px solid rgba(255, 255, 255, 0.85);
border-radius: 999px;
background: rgba(255, 249, 233, 0.91);
box-shadow: 0 5px 15px rgba(34, 68, 59, 0.16);
color: var(--ink);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.03em;
pointer-events: auto;
cursor: pointer;
transform: translate(-50%, -100%);
transition: background 150ms ease, transform 150ms ease;
}
.creature-tag:hover,
.creature-tag.selected {
background: #fffdf5;
transform: translate(-50%, -100%) scale(1.05);
}
.creature-tag .dot {
width: 10px;
height: 10px;
border: 2px solid rgba(23, 59, 56, 0.16);
border-radius: 3px;
background: var(--dot);
box-shadow: 2px 2px 0 rgba(23, 59, 56, 0.12);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #9dd7df;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-mark {
text-align: center;
color: var(--ink);
}
.loading-cube {
width: 28px;
height: 28px;
margin: 0 auto 16px;
background: var(--gold);
border: 3px solid var(--ink);
box-shadow: 7px 7px 0 rgba(23, 59, 56, 0.16);
animation: tumble 1.2s ease-in-out infinite;
}
.loading-mark strong {
display: block;
font-size: 14px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@keyframes tumble {
0%, 100% { transform: rotate(0deg) translateY(0); }
50% { transform: rotate(90deg) translateY(-5px); }
}
@media (max-width: 760px) {
.brand {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.brand p {
max-width: 270px;
font-size: 11px;
}
.fiction {
top: auto;
right: 12px;
bottom: 75px;
width: min(285px, calc(100vw - 24px));
padding: 11px 13px;
}
.inspector {
right: 12px;
bottom: 12px;
width: min(285px, calc(100vw - 24px));
padding: 12px 14px;
}
.controls {
left: 12px;
bottom: 12px;
padding: 7px;
}
.hint {
display: none;
}
.controls button {
padding: 0 10px;
}
.creature-tag {
font-size: 9px;
}
}
@media (max-width: 520px) {
.fiction {
display: none;
}
.inspector {
bottom: 68px;
}
.brand p {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel fantasy orchard scene"></canvas>
<div id="labels"></div>
<main class="hud">
<section class="brand card">
<div class="eyebrow">Original voxel story</div>
<h1>Moonpear<br>Orchard</h1>
<p>Three invented fruit keepers move between tended rows, balancing moonpears in woven voxel baskets.</p>
</section>
<aside class="fiction card">
<strong>Fiction boundary</strong>
<p>Mibbin, Ploverry, and Tink are fictional creatures. Their anatomy and behavior are fantasy design—not zoological facts or ecological guidance. The orchard is decorative.</p>
</aside>
<section class="controls card">
<button id="pauseButton" class="primary" type="button">Pause stroll</button>
<button id="resetButton" type="button">Reset view</button>
<span class="hint">Drag to orbit · Scroll to zoom · Select a keeper</span>
</section>
<section id="inspector" class="inspector card">
<div class="mini-label">Orchard field notes</div>
<h2 id="inspectorTitle">Meet the fruit keepers</h2>
<p id="inspectorText">Select a labeled keeper to read its field note and bring the camera closer.</p>
</section>
</main>
<div id="loading">
<div class="loading-mark">
<div class="loading-cube"></div>
<strong>Planting the orchard</strong>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera, lighting
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
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.1;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#a7dce3");
scene.fog = new THREE.Fog("#a7dce3", 22, 48);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight("#fff6d6", "#568263", 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff0c8", 3.1);
sun.position.set(-9, 17, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#8cc9df", 0.65);
fill.position.set(12, 7, -12);
scene.add(fill);
// -------------------------------------------------------------------------
// Shared materials and geometry
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.86,
metalness: options.metalness ?? 0,
flatShading: true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
}
const M = {
grass: material("#79b968"),
grassDark: material("#568f50"),
grassLight: material("#a0cd6b"),
soil: material("#745341"),
path: material("#c89d70"),
pathDark: material("#b8875e"),
mulch: material("#76513d"),
bark: material("#80573b"),
barkLight: material("#a16f47"),
leaf: material("#4d9856"),
leafLight: material("#69ae59"),
leafDark: material("#34774c"),
fruit: material("#ef8a58"),
fruitGold: material("#f5c45a"),
fruitPink: material("#e77a83"),
wood: material("#b97842"),
woodLight: material("#d69a59"),
woodDark: material("#75452f"),
cream: material("#fff2cf"),
cloud: material("#f8f4dc"),
stone: material("#a5aaa0"),
water: material("#70c8d7", { roughness: 0.35 }),
metal: material("#698c87", { metalness: 0.28, roughness: 0.5 }),
dark: material("#173b38")
};
function box(parent, sx, sy, sz, x, y, z, mat, rx = 0, ry = 0, rz = 0) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(sx, sy, sz);
mesh.position.set(x, y, z);
mesh.rotation.set(rx, ry, rz);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let randomSeed = 7419;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
// -------------------------------------------------------------------------
// Orchard ground
// -------------------------------------------------------------------------
const world = new THREE.Group();
scene.add(world);
box(world, 24, 1.25, 20, 0, -0.965, 0, M.soil);
box(world, 24, 0.6, 20, 0, -0.34, 0, M.grass);
// The top path is flush with y = 0 so the creatures' feet meet it cleanly.
box(world, 22.4, 0.08, 3.45, 0, -0.04, 3.05, M.path);
box(world, 2.05, 0.08, 19.4, -10.3, -0.04, 0, M.pathDark);
box(world, 1.8, 0.08, 18.8, 8.9, -0.04, 0, M.pathDark);
for (let i = 0; i < 19; i++) {
const x = -10.6 + i * 1.18;
box(world, 0.78, 0.014, 0.18, x, 0.006, 3.05 + (i % 2 ? 0.18 : -0.18), M.pathDark);
}
// Distant block hills.
const hillMaterials = [material("#6fa86d"), material("#79b473"), material("#88bd77")];
const hillData = [
[-14, 0.9, -11, 7, 2.2, 4],
[-6, 1.2, -13, 8, 2.8, 4],
[3, 1.5, -13.5, 10, 3.2, 4],
[12, 1.1, -11, 8, 2.6, 4],
[-14, 0.6, 8, 6, 1.6, 5],
[14, 0.8, 7, 7, 2.1, 5]
];
hillData.forEach((h, i) => {
box(world, h[3], h[4], h[5], h[0], h[1] - 1.2, h[2], hillMaterials[i % 3]);
});
// -------------------------------------------------------------------------
// Voxel trees
// -------------------------------------------------------------------------
const treePositions = [
[-8.2, -6.2], [-3.5, -6.2], [1.3, -6.2], [6.1, -6.2],
[-8.2, -0.1], [-3.5, -0.1], [1.3, -0.1], [6.1, -0.1],
[-8.2, 6.0], [-3.5, 6.0], [1.3, 6.0], [6.1, 6.0]
];
function makeTree(x, z, index) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.rotation.y = (random() - 0.5) * 0.5;
world.add(tree);
box(tree, 2.15, 0.06, 2.15, 0, -0.01, 0, M.mulch);
box(tree, 0.52, 2.35, 0.52, 0, 1.15, 0, M.bark);
box(tree, 0.64, 0.35, 0.64, 0, 0.16, 0, M.barkLight);
box(tree, 1.45, 0.28, 0.34, 0.48, 1.85, 0, M.bark, 0, 0, -0.22);
box(tree, 1.35, 0.26, 0.32, -0.48, 2.03, 0.08, M.bark, 0, 0, 0.25);
box(tree, 0.3, 1.45, 0.3, 0.52, 2.42, 0, M.bark, 0, 0, -0.17);
const canopy = [
[0.00, 3.10, 0.00, 2.50, 1.75, 2.10, M.leaf],
[-0.90, 2.77, 0.12, 1.65, 1.34, 1.64, M.leafLight],
[0.88, 2.92, -0.10, 1.72, 1.48, 1.70, M.leafDark],
[0.00, 3.78, -0.32, 1.95, 1.05, 1.63, M.leaf],
[0.12, 2.43, 0.75, 1.65, 1.13, 1.35, M.leafLight]
];
canopy.forEach((c, i) => {
box(tree, c[3], c[4], c[5], c[0], c[1], c[2], c[6], 0, (i % 2) * 0.12, 0);
});
const fruitMaterials = [M.fruit, M.fruitGold, M.fruitPink];
const fruitLocations = [
[-0.82, 2.52, 1.02], [0.62, 2.68, 1.05], [1.18, 3.12, 0.38],
[-1.17, 3.12, 0.35], [-0.32, 3.78, 0.55], [0.73, 3.55, 0.69],
[0.08, 2.25, 1.24], [-0.72, 3.34, 0.85]
];
fruitLocations.forEach((p, i) => {
const stem = box(tree, 0.045, 0.13, 0.045, p[0], p[1] + 0.16, p[2], M.bark);
stem.rotation.z = (i % 2 ? 1 : -1) * 0.25;
box(tree, 0.25, 0.25, 0.25, p[0], p[1], p[2], fruitMaterials[(i + index) % 3], 0, i * 0.21, 0);
});
}
treePositions.forEach((p, i) => makeTree(p[0], p[1], i));
// -------------------------------------------------------------------------
// Fence, grass tufts, small flowers
// -------------------------------------------------------------------------
function makeFence() {
const fence = new THREE.Group();
world.add(fence);
for (let x = -11; x <= 11; x += 2.2) {
box(fence, 0.2, 1.25, 0.2, x, 0.54, -9.45, M.wood);
box(fence, 0.28, 0.15, 0.28, x, 1.12, -9.45, M.woodLight);
}
box(fence, 22.5, 0.15, 0.14, 0, 0.55, -9.38, M.woodLight);
box(fence, 22.5, 0.15, 0.14, 0, 0.98, -9.38, M.woodLight);
for (let z = -8; z <= 8; z += 2.5) {
box(fence, 0.18, 1.1, 0.18, -10.7, 0.47, z, M.wood);
box(fence, 0.14, 0.14, 2.75, -10.62, 0.47, z + 1.1, M.woodLight);
box(fence, 0.14, 0.14, 2.75, -10.62, 0.87, z + 1.1, M.woodLight);
}
}
makeFence();
const grassColors = [M.grassDark, M.grassLight, material("#5b9d54")];
for (let i = 0; i < 95; i++) {
const x = random() * 21.4 - 10.7;
const z = random() * 18.4 - 9.2;
if (Math.abs(z - 3.05) < 1.83 || Math.abs(x + 10.3) < 1.1 || Math.abs(x - 8.9) < 1.0) {
continue;
}
const nearTree = treePositions.some(p => Math.abs(x - p[0]) < 1.2 && Math.abs(z - p[1]) < 1.2);
if (nearTree) continue;
const h = 0.16 + random() * 0.19;
box(world, 0.075, h, 0.075, x, -0.04 + h / 2, z, grassColors[i % grassColors.length], 0, random(), 0);
}
const flowerColors = [M.cream, M.fruitPink, M.fruitGold];
for (let i = 0; i < 24; i++) {
const x = random() * 20.5 - 10.25;
const z = random() * 18 - 9;
if (Math.abs(z - 3.05) < 2) continue;
const h = 0.17 + random() * 0.12;
box(world, 0.045, h, 0.045, x, h / 2 - 0.03, z, M.grassDark);
box(world, 0.14, 0.11, 0.14, x, h, z, flowerColors[i % 3]);
}
// -------------------------------------------------------------------------
// Care stations and harvest props
// -------------------------------------------------------------------------
function makeWateringCan(x, z, rotation = 0) {
const can = new THREE.Group();
can.position.set(x, 0, z);
can.rotation.y = rotation;
world.add(can);
box(can, 0.7, 0.55, 0.55, 0, 0.29, 0, M.metal);
box(can, 0.58, 0.08, 0.43, 0, 0.59, 0, M.water);
box(can, 0.85, 0.13, 0.14, 0.48, 0.39, 0, M.metal, 0, 0, -0.16);
box(can, 0.22, 0.22, 0.25, 0.89, 0.48, 0, M.metal, 0, 0, -0.16);
box(can, 0.12, 0.62, 0.12, -0.42, 0.38, 0, M.metal);
box(can, 0.12, 0.12, 0.48, -0.42, 0.62, 0, M.metal);
box(can, 0.12, 0.12, 0.48, -0.42, 0.16, 0, M.metal);
}
makeWateringCan(-4.6, -2.75, 0.35);
makeWateringCan(4.25, -2.5, -0.5);
// Supported young tree.
const sapling = new THREE.Group();
sapling.position.set(-5.55, 0, -2.55);
world.add(sapling);
box(sapling, 0.18, 1.35, 0.18, 0, 0.64, 0, M.bark);
box(sapling, 1.18, 0.72, 0.95, 0, 1.52, 0, M.leafLight);
box(sapling, 0.85, 0.56, 0.75, 0.25, 1.92, 0.05, M.leaf);
box(sapling, 0.1, 1.7, 0.1, -0.42, 0.82, 0, M.woodLight, 0, 0, -0.08);
box(sapling, 0.1, 1.7, 0.1, 0.42, 0.82, 0, M.woodLight, 0, 0, 0.08);
box(sapling, 1.02, 0.08, 0.08, 0, 1.24, 0, M.woodLight);
// Harvest crate.
function makeCrate(x, z, rotation = 0) {
const crate = new THREE.Group();
crate.position.set(x, 0, z);
crate.rotation.y = rotation;
world.add(crate);
box(crate, 1.7, 0.14, 1.25, 0, 0.08, 0, M.woodDark);
for (const side of [-1, 1]) {
box(crate, 0.12, 0.95, 1.25, side * 0.79, 0.48, 0, M.wood);
box(crate, 1.7, 0.95, 0.12, 0, 0.48, side * 0.565, M.wood);
for (let i = 0; i < 4; i++) {
box(crate, 0.08, 0.92, 0.08, -0.62 + i * 0.42, 0.49, side * 0.64, M.woodLight);
}
}
box(crate, 1.7, 0.12, 0.12, 0, 0.92, -0.565, M.woodLight);
box(crate, 1.7, 0.12, 0.12, 0, 0.92, 0.565, M.woodLight);
const fruits = [
[-0.47, 0.35, -0.25], [0, 0.4, -0.18], [0.45, 0.34, -0.28],
[-0.38, 0.34, 0.22], [0.13, 0.4, 0.27], [0.55, 0.32, 0.18]
];
fruits.forEach((p, i) => {
box(crate, 0.32, 0.32, 0.32, p[0], p[1], p[2], [M.fruit, M.fruitGold, M.fruitPink][i % 3], 0, i * 0.18, 0);
});
}
makeCrate(5.15, 5.18, -0.16);
makeCrate(3.8, 5.55, 0.14);
// A ladder leaning beside a tree.
const ladder = new THREE.Group();
ladder.position.set(2.55, 0, 0.82);
ladder.rotation.z = -0.18;
world.add(ladder);
box(ladder, 0.13, 2.65, 0.15, -0.37, 1.32, 0, M.woodLight);
box(ladder, 0.13, 2.65, 0.15, 0.37, 1.32, 0, M.woodLight);
for (let i = 0; i < 7; i++) {
box(ladder, 0.87, 0.11, 0.13, 0, 0.35 + i * 0.34, 0, M.wood);
}
// Painted orchard sign.
const signCanvas = document.createElement("canvas");
signCanvas.width = 1024;
signCanvas.height = 512;
const signContext = signCanvas.getContext("2d");
signContext.fillStyle = "#356f59";
signContext.fillRect(0, 0, 1024, 512);
signContext.fillStyle = "#fff2cf";
signContext.fillRect(38, 38, 948, 436);
signContext.strokeStyle = "#d8a557";
signContext.lineWidth = 18;
signContext.strokeRect(58, 58, 908, 396);
signContext.fillStyle = "#244e43";
signContext.textAlign = "center";
signContext.font = "900 76px Trebuchet MS, sans-serif";
signContext.fillText("MOONPEAR ORCHARD", 512, 180);
signContext.font = "700 38px Trebuchet MS, sans-serif";
signContext.fillText("A place for invented fruit keepers", 512, 260);
signContext.font = "600 28px Trebuchet MS, sans-serif";
signContext.fillStyle = "#6f806a";
signContext.fillText("STORY WORLD • NOT A HORTICULTURAL GUIDE", 512, 340);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
const sign = new THREE.Group();
sign.position.set(-4.9, 0, -8.35);
sign.rotation.y = 0.12;
world.add(sign);
box(sign, 0.22, 2.05, 0.22, -1.35, 1.02, 0, M.wood);
box(sign, 0.22, 2.05, 0.22, 1.35, 1.02, 0, M.wood);
box(sign, 3.6, 1.8, 0.18, 0, 1.83, 0, M.woodDark);
const signFace = new THREE.Mesh(
new THREE.PlaneGeometry(3.42, 1.62),
new THREE.MeshStandardMaterial({ map: signTexture, roughness: 0.9 })
);
signFace.position.set(0, 1.83, 0.101);
signFace.receiveShadow = true;
sign.add(signFace);
// Voxel clouds.
const clouds = [];
function makeCloud(x, y, z, scale, phase) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
world.add(cloud);
box(cloud, 3.2, 0.8, 1.25, 0, 0, 0, M.cloud).castShadow = false;
box(cloud, 1.5, 1.15, 1.05, -0.75, 0.5, 0, M.cloud).castShadow = false;
box(cloud, 1.8, 1.35, 1.12, 0.65, 0.58, 0, M.cloud).castShadow = false;
box(cloud, 1.0, 0.8, 0.95, 1.65, 0.05, 0, M.cloud).castShadow = false;
clouds.push({ group: cloud, baseX: x, phase });
}
makeCloud(-8, 8.2, -10, 1.15, 0.2);
makeCloud(5, 9.1, -12, 0.85, 2.1);
makeCloud(12, 7.5, -5, 0.65, 4.3);
// -------------------------------------------------------------------------
// Invented creatures
// -------------------------------------------------------------------------
const creatures = [];
const labelsRoot = document.querySelector("#labels");
function makeBasket(parent, width, fruitOffset = 0) {
const basket = new THREE.Group();
parent.add(basket);
const depth = 0.72;
const half = width / 2;
box(basket, width, 0.12, depth, 0, 0, 0, M.woodDark);
for (const side of [-1, 1]) {
for (let i = 0; i < 3; i++) {
box(basket, 0.09, 0.11, depth, side * half, 0.14 + i * 0.16, 0, M.woodLight);
box(basket, width, 0.11, 0.09, 0, 0.14 + i * 0.16, side * depth * 0.5, M.wood);
}
}
for (let i = 0; i < 4; i++) {
const x = -half * 0.72 + i * half * 0.48;
box(basket, 0.07, 0.43, 0.07, x, 0.25, depth * 0.5, M.woodLight);
box(basket, 0.07, 0.43, 0.07, x, 0.25, -depth * 0.5, M.woodLight);
}
// Upright handles are exactly where the creatures' hands rest.
box(basket, 0.10, 0.78, 0.10, -half, 0.40, -0.25, M.woodDark);
box(basket, 0.10, 0.78, 0.10, half, 0.40, -0.25, M.woodDark);
box(basket, width + 0.12, 0.10, 0.10, 0, 0.78, -0.25, M.woodLight);
const fruitColors = [M.fruit, M.fruitGold, M.fruitPink];
const fruitPositions = [
[-width * 0.25, 0.43, -0.17],
[0.02, 0.46, -0.13],
[width * 0.26, 0.42, -0.19],
[-width * 0.16, 0.49, 0.15],
[width * 0.19, 0.48, 0.13]
];
fruitPositions.forEach((p, i) => {
box(
basket,
0.24, 0.24, 0.24,
p[0], p[1], p[2],
fruitColors[(i + fruitOffset) % fruitColors.length],
0, i * 0.22, 0
);
});
return basket;
}
function makeCreature(config) {
const root = new THREE.Group();
root.position.set(0, 0, config.routeZ);
world.add(root);
const motion = new THREE.Group();
root.add(motion);
const bodyMat = material(config.color);
const bellyMat = material(config.belly);
const darkMat = material(config.dark);
const eyeMat = material("#fffcf1");
const pupilMat = material("#173b38");
const handMat = material(config.hand);
const bodyW = config.bodyW;
const bodyH = config.bodyH;
const bodyD = config.bodyD;
const bodyY = config.bodyY;
box(motion, bodyW, bodyH, bodyD, 0, bodyY, 0, bodyMat);
box(motion, bodyW * 0.63, bodyH * 0.66, 0.08, 0, bodyY - 0.04, bodyD * 0.5 + 0.015, bellyMat);
const head = new THREE.Group();
head.position.set(0, config.headY, 0.03);
motion.add(head);
box(head, config.headW, config.headH, config.headD, 0, 0, 0, bodyMat);
const eyeY = config.headH * 0.08;
const eyeX = config.headW * 0.21;
const eyeZ = config.headD * 0.5 + 0.025;
for (const side of [-1, 1]) {
box(head, 0.19, 0.21, 0.09, side * eyeX, eyeY, eyeZ, eyeMat);
box(head, 0.075, 0.095, 0.055, side * eyeX, eyeY, eyeZ + 0.065, pupilMat);
box(head, 0.12, 0.055, 0.035, side * eyeX * 1.35, eyeY - 0.18, eyeZ - 0.005, config.blush);
}
box(head, 0.25, 0.055, 0.055, 0, -config.headH * 0.22, eyeZ + 0.025, darkMat);
box(head, 0.065, 0.07, 0.04, -0.1, -config.headH * 0.18, eyeZ + 0.035, darkMat);
box(head, 0.065, 0.07, 0.04, 0.1, -config.headH * 0.18, eyeZ + 0.035, darkMat);
// Distinct, intentionally invented fantasy anatomy.
if (config.style === "leaf") {
box(head, 0.30, 0.58, 0.15, -0.39, 0.58, -0.02, M.leafLight, 0, 0, -0.48);
box(head, 0.30, 0.58, 0.15, 0.39, 0.58, -0.02, M.leaf, 0, 0, 0.48);
box(motion, 0.14, 0.55, 0.14, 0, bodyY - 0.12, -bodyD * 0.5 - 0.25, bodyMat, -0.55, 0, 0);
box(motion, 0.42, 0.26, 0.18, 0.13, bodyY - 0.38, -bodyD * 0.5 - 0.38, M.leafLight, 0.25, 0, -0.35);
}
if (config.style === "antenna") {
box(head, 0.10, 0.48, 0.10, -0.20, config.headH * 0.5 + 0.16, 0, darkMat, 0, 0, -0.15);
box(head, 0.10, 0.48, 0.10, 0.20, config.headH * 0.5 + 0.16, 0, darkMat, 0, 0, 0.15);
box(head, 0.26, 0.24, 0.26, -0.28, config.headH * 0.5 + 0.42, 0, M.fruitGold);
box(head, 0.26, 0.24, 0.26, 0.28, config.headH * 0.5 + 0.42, 0, M.fruitGold);
box(motion, 0.15, 0.48, 0.15, 0, bodyY - 0.18, -bodyD * 0.5 - 0.22, bodyMat, -0.35, 0, 0);
box(motion, 0.54, 0.32, 0.18, 0, bodyY - 0.39, -bodyD * 0.5 - 0.4, config.accent);
}
if (config.style === "petal") {
box(head, 0.42, 0.58, 0.17, -0.59, 0.28, -0.02, M.fruitPink, 0, 0, -0.45);
box(head, 0.42, 0.58, 0.17, 0.59, 0.28, -0.02, M.fruitGold, 0, 0, 0.45);
box(motion, 0.16, 0.62, 0.16, 0, bodyY - 0.2, -bodyD * 0.5 - 0.23, bodyMat, -0.5, 0, 0);
box(motion, 0.2, 0.2, 0.2, 0.08, bodyY - 0.48, -bodyD * 0.5 - 0.43, M.fruitGold);
}
// Legs remain on the ground while the upper body rises subtly with each step.
const legs = [];
for (const side of [-1, 1]) {
const leg = new THREE.Group();
leg.position.set(side * bodyW * 0.27, 0.72, 0);
root.add(leg);
box(leg, 0.23, 0.65, 0.25, 0, -0.325, 0, bodyMat);
box(leg, 0.34, 0.16, 0.43, 0, -0.65, 0.09, darkMat);
legs.push(leg);
}
// Bent arms hold the basket handles without releasing them.
const shoulderY = bodyY + bodyH * 0.44;
const armX = bodyW * 0.5 + 0.03;
for (const side of [-1, 1]) {
const arm = new THREE.Group();
arm.position.set(side * armX, shoulderY, 0.04);
motion.add(arm);
box(arm, 0.22, 0.42, 0.22, 0, -0.21, 0, bodyMat);
const forearm = new THREE.Group();
forearm.position.y = -0.42;
forearm.rotation.x = -1.83;
arm.add(forearm);
box(forearm, 0.19, 0.52, 0.19, 0, -0.26, 0, bodyMat);
box(forearm, 0.24, 0.22, 0.23, 0, -0.54, 0, handMat);
}
const basket = makeBasket(motion, bodyW + 0.12, config.fruitOffset);
basket.position.set(0, shoulderY - 0.61, 0.82);
const creature = {
root,
motion,
head,
legs,
basket,
config,
gait: config.phase,
lastDirection: 1,
currentYaw: Math.PI * 0.5,
label: null
};
root.userData.creature = creature;
creatures.push(creature);
const label = document.createElement("button");
label.className = "creature-tag";
label.type = "button";
label.style.setProperty("--dot", config.color);
label.innerHTML = `<span class="dot"></span>${config.name}`;
label.addEventListener("click", event => {
event.stopPropagation();
selectCreature(creature, true);
});
labelsRoot.appendChild(label);
creature.label = label;
return creature;
}
makeCreature({
name: "Mibbin",
style: "leaf",
color: "#e98572",
belly: "#f6c2a4",
hand: "#f3ad91",
blush: "#e98982",
dark: "#9e514f",
accent: "#f1b44f",
bodyW: 1.05,
bodyH: 1.05,
bodyD: 0.8,
bodyY: 1.22,
headW: 1.02,
headH: 0.92,
headD: 0.9,
headY: 2.08,
routeZ: 2.18,
phase: 0.35,
fruitOffset: 0,
note: "A round, leaf-eared courier. Mibbin’s springy square feet and oversized ears are storybook inventions, not animal adaptations."
});
makeCreature({
name: "Ploverry",
style: "antenna",
color: "#58b6aa",
belly: "#b9e3cf",
hand: "#83d0bd",
blush: "#e9a090",
dark: "#397c77",
accent: "#f1bb55",
bodyW: 0.84,
bodyH: 1.2,
bodyD: 0.69,
bodyY: 1.36,
headW: 0.92,
headH: 0.86,
headD: 0.84,
headY: 2.31,
routeZ: 3.12,
phase: 2.5,
fruitOffset: 1,
note: "A tall teal keeper with a lantern-like antenna tuft. The tuft is decorative fantasy biology and has no real-world animal analogue."
});
makeCreature({
name: "Tink",
style: "petal",
color: "#e4b957",
belly: "#fae2a1",
hand: "#f4cf79",
blush: "#e49a7b",
dark: "#8f7437",
accent: "#e68383",
bodyW: 0.92,
bodyH: 0.95,
bodyD: 0.76,
bodyY: 1.14,
headW: 0.92,
headH: 0.9,
headD: 0.84,
headY: 2.0,
routeZ: 4.08,
phase: 4.6,
fruitOffset: 2,
note: "A small golden helper with petal-shaped ears. Tink carries a lighter basket; every feature belongs only to this invented cast."
});
// -------------------------------------------------------------------------
// Custom camera controls: no examples or addons are loaded
// -------------------------------------------------------------------------
const orbit = {
theta: 0.69,
phi: 1.03,
radius: 19,
goalTheta: 0.69,
goalPhi: 1.03,
goalRadius: 19,
target: new THREE.Vector3(0, 1.45, 0),
homeTarget: new THREE.Vector3(0, 1.45, 0)
};
let focusedCreature = null;
const pointers = new Map();
let dragged = false;
function updateCamera(dt) {
if (focusedCreature) {
const desired = focusedCreature.root.position.clone();
desired.y = 1.55;
orbit.target.lerp(desired, 1 - Math.exp(-dt * 4.5));
}
const smoothing = 1 - Math.exp(-dt * 8);
orbit.theta += (orbit.goalTheta - orbit.theta) * smoothing;
orbit.phi += (orbit.goalPhi - orbit.phi) * smoothing;
orbit.radius += (orbit.goalRadius - orbit.radius) * smoothing;
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragged = false;
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const list = [...pointers.values()];
const distance = Math.hypot(list[0].x - list[1].x, list[0].y - list[1].y);
if (canvas.lastPinchDistance) {
orbit.goalRadius = THREE.MathUtils.clamp(
orbit.goalRadius * (canvas.lastPinchDistance / distance),
7.5,
30
);
}
canvas.lastPinchDistance = distance;
dragged = true;
return;
}
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
if (Math.abs(dx) + Math.abs(dy) > 2) dragged = true;
orbit.goalTheta -= dx * 0.006;
orbit.goalPhi = THREE.MathUtils.clamp(orbit.goalPhi + dy * 0.005, 0.34, 1.39);
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) canvas.lastPinchDistance = 0;
if (!dragged && event.type === "pointerup") pickCreature(event);
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
orbit.goalRadius = THREE.MathUtils.clamp(
orbit.goalRadius * Math.exp(event.deltaY * 0.001),
7.5,
30
);
}, { passive: false });
canvas.addEventListener("dblclick", resetView);
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function pickCreature(event) {
pointerNDC.x = (event.clientX / window.innerWidth) * 2 - 1;
pointerNDC.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const hits = raycaster.intersectObjects(creatures.map(c => c.root), true);
if (hits.length) {
let object = hits[0].object;
while (object && !object.userData.creature) object = object.parent;
if (object) {
selectCreature(object.userData.creature, false);
return;
}
}
}
function selectCreature(creature, focus) {
focusedCreature = focus ? creature : focusedCreature;
if (focus) orbit.goalRadius = 9.5;
document.querySelector("#inspectorTitle").textContent = creature.config.name;
document.querySelector("#inspectorText").textContent = creature.config.note;
creatures.forEach(c => c.label.classList.toggle("selected", c === creature));
}
function resetView() {
focusedCreature = null;
orbit.goalTheta = 0.69;
orbit.goalPhi = 1.03;
orbit.goalRadius = 19;
orbit.target.copy(orbit.homeTarget);
document.querySelector("#inspectorTitle").textContent = "Meet the fruit keepers";
document.querySelector("#inspectorText").textContent =
"Select a labeled keeper to read its field note and bring the camera closer.";
creatures.forEach(c => c.label.classList.remove("selected"));
}
document.querySelector("#resetButton").addEventListener("click", resetView);
// -------------------------------------------------------------------------
// Animation: planted feet, alternating gait, stable basket contact
// -------------------------------------------------------------------------
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
let paused = prefersReducedMotion;
let worldTime = 0;
const pauseButton = document.querySelector("#pauseButton");
function updatePauseButton() {
pauseButton.textContent = paused ? "Resume stroll" : "Pause stroll";
pauseButton.setAttribute("aria-pressed", String(paused));
}
updatePauseButton();
pauseButton.addEventListener("click", () => {
paused = !paused;
updatePauseButton();
});
function updateCreatures(dt) {
for (const creature of creatures) {
const c = creature.config;
const pathPhase = worldTime * 0.235 + c.phase;
const previousX = creature.root.position.x;
creature.root.position.x = Math.sin(pathPhase) * 6.65;
const velocityX = Math.cos(pathPhase) * 6.65 * 0.235;
const speed = Math.abs(velocityX);
const direction = velocityX >= 0 ? 1 : -1;
if (Math.abs(velocityX) > 0.015) creature.lastDirection = direction;
const desiredYaw = creature.lastDirection > 0 ? Math.PI * 0.5 : -Math.PI * 0.5;
const yawDelta = Math.atan2(
Math.sin(desiredYaw - creature.currentYaw),
Math.cos(desiredYaw - creature.currentYaw)
);
creature.currentYaw += yawDelta * (1 - Math.exp(-dt * 5.2));
creature.root.rotation.y = creature.currentYaw;
// Stride frequency is driven by actual distance traveled, reducing foot slip.
creature.gait += speed * dt * 2.75;
const gaitStrength = THREE.MathUtils.clamp(speed / 1.25, 0, 1);
creature.legs[0].rotation.x = Math.sin(creature.gait) * 0.34 * gaitStrength;
creature.legs[1].rotation.x = Math.sin(creature.gait + Math.PI) * 0.34 * gaitStrength;
const bob = Math.abs(Math.sin(creature.gait)) * 0.026 * gaitStrength;
creature.motion.position.y = bob;
creature.head.rotation.y = Math.sin(worldTime * 0.65 + c.phase) * 0.055;
creature.head.rotation.x = Math.sin(worldTime * 0.47 + c.phase) * 0.025;
// Tiny body lean comes from the gait, while the basket stays level.
creature.motion.rotation.z = Math.sin(creature.gait) * 0.012 * gaitStrength;
}
}
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const creature of creatures) {
projected.set(0, creature.config.headY + 1.08, 0);
creature.root.localToWorld(projected);
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
creature.label.style.display = visible ? "flex" : "none";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
creature.label.style.left = `${x}px`;
creature.label.style.top = `${y}px`;
}
}
// -------------------------------------------------------------------------
// Main loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) worldTime += dt;
updateCreatures(paused ? 0 : dt);
updateCamera(dt);
clouds.forEach(cloud => {
cloud.group.position.x = cloud.baseX + Math.sin(worldTime * 0.035 + cloud.phase) * 1.8;
});
updateLabels();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
});
renderer.render(scene, camera);
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
animate();
</script>
</body>
</html>
```