Prompt specification
Build or customize the Three.js 3D scene "Patio de la Acequia: garden and productive water" 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: Patio de la Acequia: garden and productive water
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/patio-de-la-acequia-garden-and-productive-water-x2322
Scene Description Prompt:
Create one standalone low-poly Three.js scene based on the Generalife’s Patio de la Acequia, Granada. Anchor the straight central channel, planting strips and portico in the Patronato’s Patio de la Acequia record (https://www.alhambra-patronato.es/edificios-lugares/patio-de-la-acequia) and its illustrated guide (https://www.alhambra-patronato.es/wp-content/uploads/2020/04/La-Naturaleza-2020-web.pdf). Contrast the planted ornamental court and a separately labeled schematic productive orchard strip beyond it. Use a toggle to trace a simple irrigation path; explicitly label the relation to the orchard as a teaching overlay, without claiming the modeled junction or route existed in this form. Give clear views of the channel, planted strips and shaded arcade.
Return one complete HTML document. Use procedural geometry and the cdnjs Three.js r160 module; runtime network requests, native form submissions and pointer lock are unavailable in the gallery.
Working Three.js Starter (patio-de-la-acequia-garden-and-productive-water-x2322):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#e7dfcc">
<title>Generalife — Patio de la Acequia: Low-Poly Spatial Study</title>
<style>
:root {
--ink: #292b27;
--muted: #64675f;
--paper: rgba(250, 247, 237, 0.94);
--paper-solid: #f7f2e6;
--line: rgba(50, 55, 47, 0.18);
--green: #4e6d50;
--green-dark: #304b39;
--water: #4f9fb3;
--amber: #d9892f;
--amber-dark: #87511f;
--shadow: 0 12px 35px rgba(42, 42, 35, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #d8d2bf;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, a { -webkit-tap-highlight-color: transparent; }
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.58);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#intro {
top: max(18px, env(safe-area-inset-top));
left: max(18px, env(safe-area-inset-left));
width: min(440px, calc(100vw - 36px));
padding: 18px 20px 16px;
border-radius: 3px 18px 18px 18px;
}
.eyebrow {
margin: 0 0 7px;
color: var(--green-dark);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(1.55rem, 3vw, 2.35rem);
font-weight: 500;
line-height: 1.03;
letter-spacing: -0.025em;
}
#intro .subtitle {
margin: 10px 0 0;
max-width: 390px;
color: var(--muted);
font-size: 0.84rem;
line-height: 1.5;
}
#controls {
top: max(18px, env(safe-area-inset-top));
right: max(18px, env(safe-area-inset-right));
width: min(320px, calc(100vw - 36px));
padding: 13px;
border-radius: 18px 3px 18px 18px;
}
.control-label {
display: block;
margin: 0 2px 8px;
color: var(--muted);
font-size: 0.66rem;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#pathToggle {
width: 100%;
display: flex;
align-items: center;
gap: 11px;
padding: 11px 12px;
color: var(--ink);
background: rgba(255, 255, 255, 0.55);
border: 1px solid var(--line);
border-radius: 11px;
cursor: pointer;
text-align: left;
transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
#pathToggle:hover {
transform: translateY(-1px);
border-color: rgba(217, 137, 47, 0.58);
}
#pathToggle:focus-visible,
.view-button:focus-visible,
summary:focus-visible,
a:focus-visible {
outline: 3px solid rgba(217, 137, 47, 0.45);
outline-offset: 2px;
}
#pathToggle.active {
background: #fff0d7;
border-color: rgba(217, 137, 47, 0.75);
}
.toggle-icon {
position: relative;
width: 38px;
height: 22px;
flex: 0 0 auto;
border-radius: 20px;
background: #c9c7bd;
transition: background 160ms ease;
}
.toggle-icon::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 16px;
height: 16px;
border-radius: 50%;
background: white;
box-shadow: 0 2px 5px rgba(0,0,0,.18);
transition: transform 180ms ease;
}
#pathToggle.active .toggle-icon { background: var(--amber); }
#pathToggle.active .toggle-icon::after { transform: translateX(16px); }
.toggle-copy strong {
display: block;
font-size: 0.82rem;
}
.toggle-copy small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 0.68rem;
line-height: 1.35;
}
#reading {
left: max(18px, env(safe-area-inset-left));
bottom: max(18px, env(safe-area-inset-bottom));
width: min(385px, calc(100vw - 36px));
padding: 0;
overflow: hidden;
border-radius: 16px 16px 16px 3px;
}
#reading summary {
padding: 13px 16px;
cursor: pointer;
font-size: 0.78rem;
font-weight: 800;
list-style: none;
}
#reading summary::-webkit-details-marker { display: none; }
#reading summary::after {
content: "+";
float: right;
color: var(--green);
font-size: 1rem;
line-height: 1;
}
#reading[open] summary::after { content: "–"; }
.reading-body {
padding: 0 16px 15px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 0.73rem;
line-height: 1.5;
}
.reading-body p { margin: 11px 0; }
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px 12px;
margin: 13px 0;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
color: #4e514b;
font-size: 0.7rem;
}
.swatch {
width: 18px;
height: 8px;
flex: 0 0 auto;
border-radius: 5px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.swatch.water { background: var(--water); }
.swatch.plant { background: #6f8555; }
.swatch.orchard { background: #9ca676; }
.swatch.overlay { background: var(--amber); }
.source-links {
display: flex;
flex-wrap: wrap;
gap: 7px 14px;
padding-top: 10px;
border-top: 1px solid var(--line);
}
.source-links a {
color: var(--green-dark);
font-weight: 700;
text-underline-offset: 3px;
}
#caveat {
right: max(18px, env(safe-area-inset-right));
bottom: max(18px, env(safe-area-inset-bottom));
width: min(330px, calc(100vw - 36px));
padding: 13px 15px;
color: #68431f;
background: rgba(255, 240, 215, 0.95);
border: 1px solid rgba(217, 137, 47, 0.34);
border-radius: 3px 16px 16px 16px;
box-shadow: var(--shadow);
font-size: 0.71rem;
line-height: 1.45;
}
#caveat strong {
display: block;
margin-bottom: 4px;
color: var(--amber-dark);
font-size: 0.7rem;
letter-spacing: 0.07em;
text-transform: uppercase;
}
#viewbar {
position: fixed;
z-index: 12;
left: 50%;
bottom: max(18px, env(safe-area-inset-bottom));
transform: translateX(-50%);
display: flex;
gap: 5px;
padding: 6px;
background: rgba(249, 246, 236, 0.92);
border: 1px solid rgba(255,255,255,.7);
border-radius: 15px;
box-shadow: var(--shadow);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
.view-button {
min-width: 58px;
padding: 8px 10px;
color: #53564f;
background: transparent;
border: 0;
border-radius: 10px;
cursor: pointer;
font-size: 0.68rem;
font-weight: 750;
white-space: nowrap;
transition: background 140ms ease, color 140ms ease;
}
.view-button:hover,
.view-button.active {
color: white;
background: var(--green-dark);
}
#worldLabels {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
overflow: hidden;
}
.world-label {
position: absolute;
left: 0;
top: 0;
max-width: 230px;
padding: 8px 10px;
color: #343630;
background: rgba(250, 247, 237, 0.91);
border: 1px solid rgba(255,255,255,.7);
border-left: 3px solid var(--green);
border-radius: 2px 9px 9px 9px;
box-shadow: 0 7px 18px rgba(42,42,35,.12);
transform: translate(-50%, -100%);
opacity: 0;
transition: opacity 120ms ease;
will-change: transform;
}
.world-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 18px;
background: linear-gradient(rgba(48,75,57,.65), transparent);
}
.world-label strong {
display: block;
font-size: 0.68rem;
line-height: 1.22;
letter-spacing: 0.015em;
}
.world-label small {
display: block;
margin-top: 2px;
color: #74766f;
font-size: 0.6rem;
line-height: 1.3;
}
#labelOverlay {
display: none;
color: #6c431d;
background: rgba(255, 240, 215, 0.95);
border-left-color: var(--amber);
}
#labelOverlay::after {
background: linear-gradient(rgba(217,137,47,.8), transparent);
}
body.path-on #labelOverlay { display: block; }
#labelOrchard {
border-left-color: #8f9c67;
background: rgba(244, 244, 225, 0.94);
}
#labelBreak {
border-left-color: #999a91;
background: rgba(245, 242, 232, .9);
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
color: var(--green-dark);
background: #e7dfcc;
transition: opacity 350ms ease, visibility 350ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-mark {
display: grid;
place-items: center;
gap: 12px;
font-family: Georgia, serif;
font-size: 1.1rem;
}
.loading-line {
width: 82px;
height: 3px;
overflow: hidden;
background: rgba(48,75,57,.14);
border-radius: 4px;
}
.loading-line::after {
content: "";
display: block;
width: 40%;
height: 100%;
background: var(--green);
animation: load 1s ease-in-out infinite alternate;
}
@keyframes load {
from { transform: translateX(-20%); }
to { transform: translateX(170%); }
}
#status {
position: fixed;
z-index: 30;
top: 12px;
left: 50%;
transform: translateX(-50%);
padding: 7px 12px;
color: white;
background: rgba(42, 43, 39, .82);
border-radius: 20px;
font-size: .68rem;
opacity: 0;
pointer-events: none;
transition: opacity 160ms ease;
}
#status.show { opacity: 1; }
@media (max-width: 900px) {
#intro { width: min(370px, calc(100vw - 36px)); }
#reading { display: none; }
#caveat { width: 285px; }
#viewbar { bottom: 14px; }
.view-button { min-width: 52px; padding-inline: 8px; }
}
@media (max-width: 650px) {
#intro {
padding: 13px 15px 12px;
width: calc(100vw - 28px);
top: 14px;
left: 14px;
}
#intro .subtitle { font-size: .74rem; }
#controls {
top: auto;
right: 14px;
bottom: 74px;
width: calc(100vw - 28px);
}
#caveat {
display: none;
}
#viewbar {
width: calc(100vw - 20px);
justify-content: center;
bottom: 10px;
}
.view-button {
min-width: 0;
flex: 1;
padding: 8px 4px;
font-size: .61rem;
}
.world-label {
max-width: 155px;
padding: 6px 7px;
}
.world-label strong { font-size: .59rem; }
.world-label small { font-size: .52rem; }
.world-label.secondary { display: none; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
}
}
</style>
</head>
<body>
<canvas id="scene" tabindex="0" aria-label="Interactive low-poly model of the Patio de la Acequia, with ornamental planting, a shaded portico, and a separately labeled schematic orchard."></canvas>
<section id="intro" class="panel" aria-labelledby="page-title">
<p class="eyebrow">Generalife · Granada · Interpretive model</p>
<h1 id="page-title">Patio de la Acequia</h1>
<p class="subtitle">A low-poly spatial study anchored to the Patronato record’s straight central channel, ornamental planting strips, and shaded portico. Dimensions and details are interpretive rather than surveyed.</p>
</section>
<section id="controls" class="panel" aria-label="Scene controls">
<span class="control-label">Teaching overlay</span>
<button id="pathToggle" type="button" aria-pressed="false">
<span class="toggle-icon" aria-hidden="true"></span>
<span class="toggle-copy">
<strong>Trace irrigation relation</strong>
<small>Conceptual path toward the schematic orchard</small>
</span>
</button>
</section>
<details id="reading" class="panel">
<summary>Reading this model</summary>
<div class="reading-body">
<p><strong>Anchored priorities:</strong> the straight acequia, planted ornamental banks, and the shaded arcade/portico follow the spatial emphasis identified in the Patronato record and supplied illustrated guide.</p>
<p><strong>Schematic zone:</strong> the productive orchard is a separately labeled teaching diagram beyond the ornamental court, not a reconstruction of a surveyed orchard plan.</p>
<p><strong>Overlay limit:</strong> the toggle draws an explanatory relation only. It does not assert that a modeled junction, transfer point, alignment, or historical irrigation route existed in this form.</p>
<div class="legend" aria-label="Scene legend">
<div class="legend-item"><span class="swatch water"></span> Acequia</div>
<div class="legend-item"><span class="swatch plant"></span> Ornamental court</div>
<div class="legend-item"><span class="swatch orchard"></span> Schematic orchard</div>
<div class="legend-item"><span class="swatch overlay"></span> Teaching overlay</div>
</div>
<div class="source-links">
<a href="https://www.alhambra-patronato.es/edificios-lugares/patio-de-la-acequia" target="_blank" rel="noopener noreferrer">Patronato record</a>
<a href="https://www.alhambra-patronato.es/wp-content/uploads/2020/04/La-Naturaleza-2020-web.pdf" target="_blank" rel="noopener noreferrer">Illustrated guide (PDF)</a>
</div>
</div>
</details>
<aside id="caveat" role="note">
<strong>Teaching overlay—not an evidenced route</strong>
The amber path is an explanatory relation between the acequia and the schematic orchard. No historic junction, measured alignment, or route in this precise form is claimed.
</aside>
<nav id="viewbar" class="panel" aria-label="Preset camera views">
<button class="view-button active" type="button" data-view="overview">Overview</button>
<button class="view-button" type="button" data-view="channel">Channel</button>
<button class="view-button" type="button" data-view="planting">Planting</button>
<button class="view-button" type="button" data-view="arcade">Arcade</button>
<button class="view-button" type="button" data-view="orchard">Orchard</button>
</nav>
<div id="worldLabels" aria-hidden="true">
<div id="labelChannel" class="world-label">
<strong>Straight central acequia</strong>
<small>Primary spatial anchor</small>
</div>
<div id="labelPlanting" class="world-label secondary">
<strong>Ornamental planting strips</strong>
<small>Interpretive low-poly planting</small>
</div>
<div id="labelArcade" class="world-label">
<strong>Shaded arcade / portico</strong>
<small>Arcaded north edge</small>
</div>
<div id="labelOrchard" class="world-label">
<strong>Schematic productive orchard</strong>
<small>Beyond the modeled court</small>
</div>
<div id="labelBreak" class="world-label secondary">
<strong>Diagram boundary</strong>
<small>No historic junction modeled</small>
</div>
<div id="labelOverlay" class="world-label">
<strong>Teaching overlay</strong>
<small>Illustrative relation, not a historic route</small>
</div>
</div>
<div id="status" role="status" aria-live="polite"></div>
<div id="loading" aria-live="polite">
<div class="loading-mark">
<span>Preparing the Patio de la Acequia</span>
<span class="loading-line" aria-hidden="true"></span>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const loading = document.getElementById("loading");
const status = document.getElementById("status");
const pathToggle = document.getElementById("pathToggle");
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9d3c2);
scene.fog = new THREE.Fog(0xd9d3c2, 48, 105);
const camera = new THREE.PerspectiveCamera(42, innerWidth / innerHeight, 0.1, 160);
let renderer;
try {
renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: false });
} catch (error) {
loading.innerHTML = "<div class='loading-mark'><span>WebGL could not start in this gallery.</span></div>";
throw error;
}
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const hemi = new THREE.HemisphereLight(0xf5efe1, 0x687052, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d1, 3.35);
sun.position.set(-16, 26, 17);
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 = 75;
sun.shadow.normalBias = 0.025;
sun.target.position.set(1, 0, -2);
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0xaac6d1, 0.48);
fill.position.set(18, 10, -20);
scene.add(fill);
const mat = {
ground: new THREE.MeshStandardMaterial({ color: 0xc8bfa8, roughness: 1 }),
court: new THREE.MeshStandardMaterial({ color: 0xded5bd, roughness: 0.96 }),
gravel: new THREE.MeshStandardMaterial({ color: 0xe4dcc7, roughness: 1 }),
soil: new THREE.MeshStandardMaterial({ color: 0x75624d, roughness: 1 }),
orchardSoil: new THREE.MeshStandardMaterial({ color: 0x8c8064, roughness: 1 }),
stone: new THREE.MeshStandardMaterial({ color: 0xbab29d, roughness: 0.92 }),
stoneLight: new THREE.MeshStandardMaterial({ color: 0xd0c7b1, roughness: 0.9 }),
stoneDark: new THREE.MeshStandardMaterial({ color: 0x77786c, roughness: 1 }),
plaster: new THREE.MeshStandardMaterial({ color: 0xd9cfb7, roughness: 0.95 }),
roof: new THREE.MeshStandardMaterial({ color: 0x9d5f3d, roughness: 0.92 }),
roofLight: new THREE.MeshStandardMaterial({ color: 0xb8744a, roughness: 0.9 }),
shadowBay: new THREE.MeshStandardMaterial({ color: 0x464940, roughness: 1 }),
leaf: new THREE.MeshStandardMaterial({ color: 0x64784e, roughness: 1, flatShading: true }),
leafLight: new THREE.MeshStandardMaterial({ color: 0x829064, roughness: 1, flatShading: true }),
leafDark: new THREE.MeshStandardMaterial({ color: 0x4f6845, roughness: 1, flatShading: true }),
stem: new THREE.MeshStandardMaterial({ color: 0x4d6c43, roughness: 1 }),
flowerA: new THREE.MeshStandardMaterial({ color: 0xcf735c, roughness: 0.8, flatShading: true }),
flowerB: new THREE.MeshStandardMaterial({ color: 0xe2b44d, roughness: 0.8, flatShading: true }),
flowerC: new THREE.MeshStandardMaterial({ color: 0xb8a4c7, roughness: 0.8, flatShading: true }),
flowerD: new THREE.MeshStandardMaterial({ color: 0xe4ddd0, roughness: 0.8, flatShading: true }),
trunk: new THREE.MeshStandardMaterial({ color: 0x795b3e, roughness: 1, flatShading: true }),
fruit: new THREE.MeshStandardMaterial({ color: 0xd9823c, roughness: 0.85, flatShading: true }),
water: new THREE.MeshStandardMaterial({
color: 0x579ead,
roughness: 0.22,
metalness: 0.04,
transparent: true,
opacity: 0.84
}),
glint: new THREE.MeshBasicMaterial({ color: 0xd9f1ec, transparent: true, opacity: 0.56 }),
separator: new THREE.MeshStandardMaterial({ color: 0xaaa797, roughness: 1 })
};
function box(parent, size, position, material, cast = true, receive = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(...size), material);
mesh.position.set(...position);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
function cylinder(parent, top, bottom, height, position, material, segments = 8) {
const mesh = new THREE.Mesh(new THREE.CylinderGeometry(top, bottom, height, segments), material);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 41873;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function choose(list) {
return list[Math.floor(random() * list.length)];
}
// Broad neutral ground and the differently surfaced interpretive zones.
box(scene, [76, 0.2, 64], [5, -0.34, 0], mat.ground, false, true);
box(scene, [18.4, 0.2, 25.2], [0, -0.08, 0], mat.court, false, true);
box(scene, [15.4, 0.12, 25.2], [18.3, -0.08, 0], mat.orchardSoil, false, true);
box(scene, [2.2, 0.12, 25.2], [10.1, -0.08, 0], mat.gravel, false, true);
// Low coping defines the ornamental court without implying a surveyed enclosure.
box(scene, [18.4, 0.34, 0.22], [0, 0.18, 12.45], mat.stoneLight);
box(scene, [0.22, 0.34, 25], [-8.9, 0.18, 0], mat.stoneLight);
box(scene, [0.22, 0.34, 25], [8.9, 0.18, 0], mat.stoneLight);
// A deliberately quiet diagram boundary between court and schematic orchard.
for (let z = -11.8; z <= 11.8; z += 0.95) {
box(scene, [0.11, 0.06, 0.46], [9.72, 0.035, z], mat.separator, false, true);
}
// Straight central acequia.
box(scene, [1.52, 0.16, 22.4], [0, 0.06, 0], mat.stoneDark, false, true);
box(scene, [1.02, 0.035, 22.15], [0, 0.165, 0], mat.water, false, false);
const borderGeometry = new THREE.BoxGeometry(0.23, 0.19, 0.72);
const borderCount = 64;
const borders = new THREE.InstancedMesh(borderGeometry, mat.stoneLight, borderCount);
borders.castShadow = true;
borders.receiveShadow = true;
const dummy = new THREE.Object3D();
let borderIndex = 0;
for (let z = -10.65; z <= 10.7 && borderIndex < borderCount; z += 0.72) {
for (const x of [-0.68, 0.68]) {
dummy.position.set(x, 0.19, z);
dummy.rotation.y = (random() - 0.5) * 0.025;
dummy.updateMatrix();
borders.setMatrixAt(borderIndex++, dummy.matrix);
}
}
borders.count = borderIndex;
scene.add(borders);
// A few pale moving facets suggest water without using textures.
const waterGlints = [];
for (let i = 0; i < 18; i++) {
const glint = new THREE.Mesh(new THREE.PlaneGeometry(0.18 + random() * 0.18, 0.035), mat.glint);
glint.rotation.x = -Math.PI / 2;
glint.position.set((random() - 0.5) * 0.56, 0.194, -10.5 + random() * 21);
glint.userData.offset = random() * 21;
glint.userData.speed = 0.45 + random() * 0.28;
scene.add(glint);
waterGlints.push(glint);
}
// Ornamental beds are broken at a transverse court path.
const beds = [
{ x: -3.25, z: -5.45, length: 8.1 },
{ x: -3.25, z: 5.45, length: 8.1 },
{ x: 3.25, z: -5.45, length: 8.1 },
{ x: 3.25, z: 5.45, length: 8.1 }
];
const flowerMaterials = [mat.flowerA, mat.flowerB, mat.flowerC, mat.flowerD];
for (const bed of beds) {
box(scene, [1.78, 0.14, bed.length], [bed.x, 0.08, bed.z], mat.soil, false, true);
box(scene, [0.12, 0.19, bed.length + 0.12], [bed.x - 0.95, 0.16, bed.z], mat.stone);
box(scene, [0.12, 0.19, bed.length + 0.12], [bed.x + 0.95, 0.16, bed.z], mat.stone);
box(scene, [1.9, 0.19, 0.12], [bed.x, 0.16, bed.z - bed.length / 2], mat.stone);
box(scene, [1.9, 0.19, 0.12], [bed.x, 0.16, bed.z + bed.length / 2], mat.stone);
const plantCount = 14;
for (let i = 0; i < plantCount; i++) {
const plant = new THREE.Group();
const px = bed.x + (random() - 0.5) * 1.18;
const pz = bed.z + (random() - 0.5) * (bed.length - 0.6);
plant.position.set(px, 0.15, pz);
const height = 0.3 + random() * 0.22;
cylinder(plant, 0.025, 0.035, height, [0, height * 0.5, 0], mat.stem, 5);
const leaf = new THREE.Mesh(new THREE.ConeGeometry(0.11, 0.22, 5), random() > 0.5 ? mat.leaf : mat.leafLight);
leaf.position.set(0.07, height * 0.42, 0);
leaf.rotation.z = -0.65;
leaf.castShadow = true;
plant.add(leaf);
const bloom = new THREE.Mesh(new THREE.IcosahedronGeometry(0.105 + random() * 0.04, 0), choose(flowerMaterials));
bloom.position.y = height + 0.045;
bloom.scale.y = 0.7;
bloom.castShadow = true;
plant.add(bloom);
const scale = 0.78 + random() * 0.42;
plant.scale.setScalar(scale);
scene.add(plant);
}
}
// A transverse path emphasizes the court’s axial and cross-axis organization.
box(scene, [17.4, 0.035, 1.25], [0, 0.025, 0], mat.gravel, false, true);
// North portico: low-poly columns, faceted arches, shaded bays and a tiled roof.
box(scene, [16.5, 4.25, 0.42], [0, 2.12, -12.65], mat.plaster);
box(scene, [16.8, 0.24, 3.25], [0, 0.12, -11.55], mat.stoneLight);
function makeArch(axis, fixed, center, radius, spring, parent = scene) {
const segments = 7;
for (let i = 0; i < segments; i++) {
const theta = i / (segments - 1) * Math.PI;
const radial = radius;
const along = center + Math.cos(theta) * radial;
const height = spring + Math.sin(theta) * radial;
if (axis === "x") {
const block = box(
parent,
[radius * 0.43, 0.43, 0.62],
[along, height, fixed],
mat.stoneLight
);
block.rotation.z = theta - Math.PI / 2;
} else {
const block = box(
parent,
[0.62, 0.43, radius * 0.43],
[fixed, height, along],
mat.stoneLight
);
block.rotation.x = Math.PI / 2 - theta;
}
}
}
const porticoX = [-7, -5.25, -3.5, -1.75, 0, 1.75, 3.5, 5.25, 7];
for (const x of porticoX) {
box(scene, [0.62, 0.22, 0.62], [x, 0.25, -11.15], mat.stone);
cylinder(scene, 0.23, 0.28, 2.55, [x, 1.62, -11.15], mat.stoneLight, 8);
box(scene, [0.66, 0.22, 0.66], [x, 3.0, -11.15], mat.stoneLight);
}
for (let i = 0; i < porticoX.length - 1; i++) {
makeArch("x", -11.15, (porticoX[i] + porticoX[i + 1]) / 2, 0.81, 3.08);
}
function niche(x) {
const shape = new THREE.Shape();
shape.moveTo(-0.72, 0);
shape.lineTo(0.72, 0);
shape.lineTo(0.72, 1.52);
shape.absarc(0, 1.52, 0.72, 0, Math.PI, false);
shape.lineTo(-0.72, 0);
const geometry = new THREE.ShapeGeometry(shape);
const nicheMesh = new THREE.Mesh(geometry, mat.shadowBay);
nicheMesh.position.set(x, 0.22, -12.425);
scene.add(nicheMesh);
}
niche(-4.8);
niche(0);
niche(4.8);
box(scene, [17.1, 0.24, 3.75], [0, 4.23, -11.75], mat.roof);
for (let x = -7.8; x <= 7.8; x += 0.86) {
box(scene, [0.54, 0.14, 3.55], [x, 4.43, -11.78], mat.roofLight);
}
box(scene, [17.4, 0.22, 0.3], [0, 4.48, -9.91], mat.roofLight);
// A short western return makes the arcade's shaded depth legible from oblique views.
const returnZ = [-9.8, -7.9, -6.0];
for (const z of returnZ) {
box(scene, [0.58, 0.2, 0.58], [-7.55, 0.23, z], mat.stone);
cylinder(scene, 0.21, 0.25, 2.5, [-7.55, 1.6, z], mat.stoneLight, 8);
box(scene, [0.62, 0.2, 0.62], [-7.55, 2.94, z], mat.stoneLight);
}
for (let i = 0; i < returnZ.length - 1; i++) {
makeArch("z", -7.55, (returnZ[i] + returnZ[i + 1]) / 2, 0.82, 3.02);
}
box(scene, [2.55, 0.23, 5.2], [-7.8, 4.17, -8.25], mat.roof);
box(scene, [2.7, 0.16, 5.0], [-7.8, 4.36, -8.25], mat.roofLight);
// The orchard is intentionally diagrammatic: rows, repeated trees and simple productive beds.
for (const x of [12.0, 16.0, 20.0, 24.0]) {
box(scene, [1.15, 0.09, 20.5], [x, 0.02, 0], mat.orchardSoil, false, true);
for (let z = -9.6; z < 10; z += 1.15) {
const crop = new THREE.Mesh(new THREE.ConeGeometry(0.14, 0.38, 5), mat.leafLight);
crop.position.set(x + (random() - 0.5) * 0.28, 0.24, z);
crop.castShadow = true;
scene.add(crop);
}
}
const orchardCrowns = [];
for (const x of [14, 18, 22]) {
for (const z of [-8.1, -3.4, 1.3, 6]) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
const treeHeight = 1.15 + random() * 0.35;
cylinder(tree, 0.12, 0.19, treeHeight, [0, treeHeight / 2, 0], mat.trunk, 6);
const crown = new THREE.Mesh(new THREE.IcosahedronGeometry(0.9 + random() * 0.16, 0), random() > 0.5 ? mat.leaf : mat.leafLight);
crown.position.y = treeHeight + 0.62;
crown.scale.set(1, 0.9 + random() * 0.2, 0.95);
crown.rotation.set(random(), random(), random());
crown.castShadow = true;
crown.receiveShadow = true;
tree.add(crown);
orchardCrowns.push(crown);
for (let i = 0; i < 3; i++) {
const fruit = new THREE.Mesh(new THREE.IcosahedronGeometry(0.075, 0), mat.fruit);
const angle = random() * Math.PI * 2;
fruit.position.set(
Math.cos(angle) * 0.63,
treeHeight + 0.45 + random() * 0.52,
Math.sin(angle) * 0.55
);
fruit.castShadow = true;
tree.add(fruit);
}
scene.add(tree);
}
}
// In-scene sign generated locally; no external image is used.
function createSign(title, subtitle, x, z) {
const c = document.createElement("canvas");
c.width = 768;
c.height = 320;
const ctx = c.getContext("2d");
ctx.fillStyle = "#eee6cf";
ctx.fillRect(0, 0, c.width, c.height);
ctx.strokeStyle = "#6e7659";
ctx.lineWidth = 14;
ctx.strokeRect(16, 16, c.width - 32, c.height - 32);
ctx.fillStyle = "#344936";
ctx.font = "700 55px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText(title, c.width / 2, 126);
ctx.fillStyle = "#62675b";
ctx.font = "30px system-ui, sans-serif";
ctx.fillText(subtitle, c.width / 2, 198);
ctx.fillStyle = "#8b6337";
ctx.font = "italic 25px Georgia, serif";
ctx.fillText("Teaching diagram — not a surveyed plan", c.width / 2, 257);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
const board = new THREE.Mesh(
new THREE.PlaneGeometry(3.8, 1.58),
new THREE.MeshStandardMaterial({ map: texture, roughness: 0.92, side: THREE.DoubleSide })
);
board.position.set(x, 1.35, z);
board.castShadow = true;
scene.add(board);
cylinder(scene, 0.07, 0.08, 1.05, [x - 1.45, 0.52, z], mat.trunk, 6);
cylinder(scene, 0.07, 0.08, 1.05, [x + 1.45, 0.52, z], mat.trunk, 6);
}
createSign("SCHEMATIC ORCHARD", "Productive strip beyond the court", 13.5, 10.6);
// Conceptual irrigation relation. It floats above the model and is explicitly amber.
const overlayGroup = new THREE.Group();
overlayGroup.visible = false;
scene.add(overlayGroup);
const overlayCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0.0, 0.48, 7.35),
new THREE.Vector3(2.1, 0.48, 7.55),
new THREE.Vector3(5.6, 0.48, 7.7),
new THREE.Vector3(9.7, 0.49, 7.75),
new THREE.Vector3(12.2, 0.49, 7.4),
new THREE.Vector3(14.4, 0.49, 5.5),
new THREE.Vector3(16.2, 0.49, 2.0),
new THREE.Vector3(18.2, 0.49, -1.4),
new THREE.Vector3(20.1, 0.49, -4.6)
], false, "catmullrom", 0.28);
const overlayMaterial = new THREE.MeshBasicMaterial({
color: 0xf0a23d,
transparent: true,
opacity: 0.96,
depthTest: false,
depthWrite: false
});
const overlayGeometry = new THREE.TubeGeometry(overlayCurve, 120, 0.075, 6, false);
overlayGeometry.setDrawRange(0, 0);
const overlayTube = new THREE.Mesh(overlayGeometry, overlayMaterial);
overlayTube.renderOrder = 20;
overlayGroup.add(overlayTube);
const arrowMaterial = new THREE.MeshBasicMaterial({
color: 0xffc46f,
transparent: true,
opacity: 0.98,
depthTest: false,
depthWrite: false
});
const arrowGeometry = new THREE.ConeGeometry(0.2, 0.55, 5);
const overlayArrows = [];
for (const t of [0.13, 0.26, 0.39, 0.52, 0.65, 0.78, 0.9]) {
const arrow = new THREE.Mesh(arrowGeometry, arrowMaterial);
arrow.position.copy(overlayCurve.getPointAt(t));
arrow.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), overlayCurve.getTangentAt(t).normalize());
arrow.renderOrder = 21;
overlayGroup.add(arrow);
overlayArrows.push({ mesh: arrow, t });
}
const markerMaterial = new THREE.MeshBasicMaterial({
color: 0xffd494,
depthTest: false,
depthWrite: false
});
const overlayMarker = new THREE.Mesh(new THREE.IcosahedronGeometry(0.22, 0), markerMaterial);
overlayMarker.renderOrder = 22;
overlayGroup.add(overlayMarker);
let pathEnabled = false;
let pathProgress = 0;
function setPath(enabled) {
pathEnabled = enabled;
pathToggle.classList.toggle("active", enabled);
pathToggle.setAttribute("aria-pressed", String(enabled));
document.body.classList.toggle("path-on", enabled);
overlayGroup.visible = enabled;
if (enabled) {
pathProgress = reducedMotion ? 1 : 0;
}
showStatus(enabled ? "Teaching overlay shown — not an evidenced route" : "Teaching overlay hidden");
}
pathToggle.addEventListener("click", () => setPath(!pathEnabled));
let statusTimer;
function showStatus(message) {
status.textContent = message;
status.classList.add("show");
clearTimeout(statusTimer);
statusTimer = setTimeout(() => status.classList.remove("show"), 2400);
}
// Camera controls are implemented directly without addons.
const controls = {
target: new THREE.Vector3(2, 0.2, -1),
spherical: new THREE.Spherical(),
cameraTween: null
};
const initialPosition = new THREE.Vector3(-27, 22, 30);
camera.position.copy(initialPosition);
camera.lookAt(controls.target);
controls.spherical.setFromVector3(camera.position.clone().sub(controls.target));
function applySpherical() {
controls.spherical.phi = THREE.MathUtils.clamp(controls.spherical.phi, 0.2, 1.42);
controls.spherical.radius = THREE.MathUtils.clamp(controls.spherical.radius, 7, 70);
const offset = new THREE.Vector3().setFromSpherical(controls.spherical);
camera.position.copy(controls.target).add(offset);
camera.lookAt(controls.target);
}
const presets = {
overview: { position: new THREE.Vector3(-27, 22, 30), target: new THREE.Vector3(2, 0.2, -1) },
channel: { position: new THREE.Vector3(-8.5, 7.2, 17), target: new THREE.Vector3(0, 0.35, 0) },
planting: { position: new THREE.Vector3(-13, 8.5, 5.5), target: new THREE.Vector3(-3.2, 0.55, 0) },
arcade: { position: new THREE.Vector3(-14, 8, -23), target: new THREE.Vector3(0, 2, -11) },
orchard: { position: new THREE.Vector3(29, 13.5, 20), target: new THREE.Vector3(18, 1, 0) }
};
function animateCamera(view, immediate = false) {
const preset = presets[view];
if (!preset) return;
document.querySelectorAll(".view-button").forEach(button => {
button.classList.toggle("active", button.dataset.view === view);
});
if (immediate || reducedMotion) {
camera.position.copy(preset.position);
controls.target.copy(preset.target);
controls.spherical.setFromVector3(camera.position.clone().sub(controls.target));
camera.lookAt(controls.target);
return;
}
controls.cameraTween = {
start: performance.now(),
duration: 1050,
fromPosition: camera.position.clone(),
fromTarget: controls.target.clone(),
toPosition: preset.position.clone(),
toTarget: preset.target.clone()
};
}
document.querySelectorAll(".view-button").forEach(button => {
button.addEventListener("click", () => animateCamera(button.dataset.view));
});
const pointers = new Map();
let dragMode = "orbit";
let pinchDistance = 0;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.focus({ preventScroll: true });
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
controls.cameraTween = null;
if (event.button === 2 || event.button === 1) {
dragMode = "pan";
} else {
dragMode = "orbit";
}
if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
dragMode = "pinch";
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const values = [...pointers.values()];
const distance = Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
if (pinchDistance > 0 && distance > 0) {
controls.spherical.radius *= pinchDistance / distance;
applySpherical();
}
pinchDistance = distance;
return;
}
if (dragMode === "orbit") {
controls.spherical.theta -= dx * 0.0052;
controls.spherical.phi -= dy * 0.0045;
applySpherical();
} else if (dragMode === "pan") {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const scale = controls.spherical.radius * 0.0014;
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(camera.up, dy * scale);
applySpherical();
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
pinchDistance = 0;
if (pointers.size === 1) dragMode = "orbit";
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
controls.cameraTween = null;
controls.spherical.radius *= Math.exp(event.deltaY * 0.001);
applySpherical();
}, { passive: false });
window.addEventListener("keydown", event => {
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) return;
const key = event.key.toLowerCase();
if (["1", "2", "3", "4", "5"].includes(key)) {
animateCamera(["overview", "channel", "planting", "arcade", "orchard"][Number(key) - 1]);
} else if (key === "o") {
setPath(!pathEnabled);
} else if (key === "r") {
animateCamera("overview");
} else if (key === "arrowleft") {
controls.spherical.theta += 0.08;
applySpherical();
} else if (key === "arrowright") {
controls.spherical.theta -= 0.08;
applySpherical();
} else if (key === "arrowup") {
controls.spherical.phi -= 0.06;
applySpherical();
} else if (key === "arrowdown") {
controls.spherical.phi += 0.06;
applySpherical();
} else if (key === "+" || key === "=") {
controls.spherical.radius *= 0.9;
applySpherical();
} else if (key === "-") {
controls.spherical.radius *= 1.1;
applySpherical();
} else {
return;
}
event.preventDefault();
});
// Screen-space callouts are positioned manually, avoiding any addon renderer.
const labels = [
{ id: "labelChannel", point: new THREE.Vector3(0, 0.7, -0.6), dx: 0, dy: -8 },
{ id: "labelPlanting", point: new THREE.Vector3(-3.25, 1.15, -5.4), dx: -24, dy: -8 },
{ id: "labelArcade", point: new THREE.Vector3(-1.7, 4.55, -11.3), dx: 0, dy: -5 },
{ id: "labelOrchard", point: new THREE.Vector3(18, 4.1, 0.5), dx: 12, dy: -4 },
{ id: "labelBreak", point: new THREE.Vector3(9.72, 0.6, 6.7), dx: 30, dy: -5 },
{ id: "labelOverlay", point: new THREE.Vector3(10.1, 1.0, 7.7), dx: 8, dy: -3 }
].map(label => ({ ...label, element: document.getElementById(label.id) }));
const projected = new THREE.Vector3();
function updateLabels() {
const width = innerWidth;
const height = innerHeight;
for (const label of labels) {
projected.copy(label.point).project(camera);
const visible = projected.z > -1 && projected.z < 1 && Math.abs(projected.x) < 1.3 && Math.abs(projected.y) < 1.3;
label.element.style.opacity = visible ? "1" : "0";
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width + label.dx;
const y = (-projected.y * 0.5 + 0.5) * height + label.dy;
label.element.style.transform = `translate(-50%, -100%) translate(${x}px, ${y}px)`;
}
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let elapsed = 0;
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
if (controls.cameraTween) {
const tween = controls.cameraTween;
const t = Math.min(1, (performance.now() - tween.start) / tween.duration);
const eased = t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
camera.position.lerpVectors(tween.fromPosition, tween.toPosition, eased);
controls.target.lerpVectors(tween.fromTarget, tween.toTarget, eased);
camera.lookAt(controls.target);
if (t >= 1) {
controls.spherical.setFromVector3(camera.position.clone().sub(controls.target));
controls.cameraTween = null;
}
}
for (const glint of waterGlints) {
glint.position.z += dt * glint.userData.speed;
if (glint.position.z > 10.8) glint.position.z = -10.8;
}
for (let i = 0; i < orchardCrowns.length; i++) {
const crown = orchardCrowns[i];
crown.rotation.z = Math.sin(elapsed * 0.42 + i * 0.71) * 0.012;
}
if (pathEnabled) {
pathProgress = Math.min(1, pathProgress + dt / 1.8);
const indexCount = overlayGeometry.index ? overlayGeometry.index.count : overlayGeometry.attributes.position.count;
overlayGeometry.setDrawRange(0, Math.floor(indexCount * pathProgress / 3) * 3);
for (const arrow of overlayArrows) {
arrow.mesh.visible = arrow.t <= pathProgress;
}
const markerPoint = overlayCurve.getPointAt(pathProgress);
overlayMarker.position.copy(markerPoint);
overlayMarker.rotation.y += dt * 2.2;
}
renderer.render(scene, camera);
updateLabels();
if (firstFrame) {
firstFrame = false;
loading.classList.add("hidden");
}
}
animate();
</script>
</body>
</html>
```