Prompt specification
Build or customize the Three.js 3D scene "Courtyard Light and Gathering Places" 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: Courtyard Light and Gathering Places
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/courtyard-light-and-gathering-places-x3282
Scene Description Prompt:
An original voxel courtyard where moving sunlight changes shaded seating and gathering areas. Use Three.js from cdnjs in one HTML file.
Working Three.js Starter (courtyard-light-and-gathering-places-x3282):
```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="#172426" />
<title>Sunward Court — Voxel Courtyard</title>
<style>
:root {
--ink: #172426;
--paper: #f5f0e7;
--muted: rgba(245, 240, 231, 0.68);
--line: rgba(245, 240, 231, 0.18);
--gold: #f3bd72;
--cool: #76c3c7;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--paper);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
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;
}
.ui {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.brand {
position: absolute;
top: 28px;
left: 30px;
display: flex;
align-items: center;
gap: 13px;
text-transform: uppercase;
letter-spacing: 0.17em;
font-size: 11px;
font-weight: 700;
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
.brand-mark {
display: grid;
grid-template-columns: repeat(2, 8px);
grid-template-rows: repeat(2, 8px);
gap: 3px;
transform: rotate(45deg);
}
.brand-mark i {
display: block;
background: var(--paper);
}
.brand-mark i:last-child {
background: var(--gold);
}
.brand small {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.14em;
font-weight: 500;
}
.panel {
position: absolute;
bottom: 26px;
left: 26px;
width: min(390px, calc(100vw - 52px));
padding: 22px;
border: 1px solid var(--line);
border-radius: 18px;
background:
linear-gradient(145deg, rgba(17, 31, 32, 0.91), rgba(20, 38, 39, 0.78));
box-shadow:
0 24px 70px rgba(0, 0, 0, 0.25),
inset 0 1px 0 rgba(255, 255, 255, 0.05);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
pointer-events: auto;
}
.eyebrow {
color: var(--gold);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 7px 0 7px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 42px);
line-height: 1;
font-weight: 400;
letter-spacing: -0.035em;
}
.description {
margin: 0;
max-width: 320px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.time-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 16px;
margin-top: 22px;
}
#time {
font-family: Georgia, "Times New Roman", serif;
font-size: 31px;
font-variant-numeric: tabular-nums;
letter-spacing: -0.04em;
}
#phase {
color: var(--gold);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
text-align: right;
}
input[type="range"] {
--p: 22%;
width: 100%;
height: 4px;
margin: 17px 0 20px;
appearance: none;
-webkit-appearance: none;
border-radius: 10px;
outline: none;
cursor: pointer;
background:
linear-gradient(
to right,
var(--gold) 0,
var(--gold) var(--p),
rgba(255, 255, 255, 0.17) var(--p),
rgba(255, 255, 255, 0.17) 100%
);
}
input[type="range"]::-webkit-slider-thumb {
width: 17px;
height: 17px;
appearance: none;
-webkit-appearance: none;
border: 3px solid var(--ink);
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45);
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 3px solid var(--ink);
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45);
}
.controls {
display: flex;
gap: 9px;
}
.controls button {
min-height: 38px;
padding: 0 15px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 10px;
color: var(--paper);
background: rgba(255, 255, 255, 0.07);
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.controls button:hover {
background: rgba(255, 255, 255, 0.13);
transform: translateY(-1px);
}
.controls #play {
min-width: 91px;
border-color: transparent;
color: var(--ink);
background: var(--gold);
}
.stats {
position: absolute;
top: 26px;
right: 26px;
width: 248px;
padding: 18px;
border: 1px solid var(--line);
border-radius: 16px;
background: rgba(18, 34, 35, 0.78);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.stats-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 4px rgba(243, 189, 114, 0.12);
}
.stat + .stat {
margin-top: 16px;
}
.stat-label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
color: var(--muted);
font-size: 11px;
}
.stat-label strong {
color: var(--paper);
font-size: 15px;
font-variant-numeric: tabular-nums;
}
.meter {
height: 4px;
margin-top: 8px;
overflow: hidden;
border-radius: 5px;
background: rgba(255, 255, 255, 0.11);
}
.meter span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--cool);
transition: width 350ms ease;
}
#zoneMeter {
background: var(--gold);
}
#liveNote {
margin: 16px 0 0;
padding-top: 13px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.hint {
position: absolute;
right: 28px;
bottom: 28px;
display: flex;
align-items: center;
gap: 12px;
color: rgba(255, 255, 255, 0.76);
font-size: 10px;
letter-spacing: 0.04em;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.mouse {
position: relative;
width: 18px;
height: 27px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 9px;
}
.mouse::before {
content: "";
position: absolute;
top: 5px;
left: 7px;
width: 2px;
height: 6px;
border-radius: 2px;
background: var(--gold);
}
#labels {
position: fixed;
inset: 0;
z-index: 4;
pointer-events: none;
overflow: hidden;
}
.zone-label {
position: absolute;
display: flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 6px;
color: #fff;
background: rgba(22, 34, 34, 0.73);
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(8px);
transform: translate(-50%, -100%);
white-space: nowrap;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
transition: background 250ms ease, border-color 250ms ease;
}
.zone-label.cool {
border-color: rgba(118, 195, 199, 0.75);
background: rgba(23, 65, 70, 0.82);
}
.zone-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 3px rgba(243, 189, 114, 0.12);
}
.zone-label.cool .zone-dot {
background: var(--cool);
box-shadow: 0 0 0 3px rgba(118, 195, 199, 0.12);
}
@media (max-width: 720px) {
.brand {
top: 18px;
left: 18px;
}
.stats {
top: 18px;
right: 18px;
width: 184px;
padding: 14px;
}
.stats .stats-heading,
#liveNote {
display: none;
}
.stat + .stat {
margin-top: 11px;
}
.panel {
left: 14px;
bottom: 14px;
width: calc(100vw - 28px);
padding: 17px;
}
.description {
display: none;
}
.time-row {
margin-top: 15px;
}
.hint {
display: none;
}
.zone-label {
font-size: 7px;
}
}
@media (max-width: 430px) {
.brand span {
display: none;
}
.stats {
top: 14px;
right: 14px;
width: 154px;
}
h1 {
font-size: 29px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive voxel courtyard"></main>
<div id="labels"></div>
<div class="ui">
<header class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
Sunward Court
<small>Voxel daylight study · No. 01</small>
</div>
</header>
<section class="panel" aria-label="Daylight controls">
<div class="eyebrow">A courtyard in changing light</div>
<h1>Sunward Court</h1>
<p class="description">
Follow the sun across the colonnade. Roof slats, walls, and trees
reshape the cool places to sit and gather.
</p>
<div class="time-row">
<span id="time">08:24</span>
<span id="phase">Morning light</span>
</div>
<input
id="timeSlider"
type="range"
min="6"
max="19"
step="0.01"
value="8.4"
aria-label="Time of day"
/>
<div class="controls">
<button id="play" type="button">Pause</button>
<button id="reset" type="button">Reset view</button>
</div>
</section>
<aside class="stats" aria-label="Courtyard light statistics">
<div class="stats-heading">
Live courtyard
<span class="live-dot"></span>
</div>
<div class="stat">
<div class="stat-label">
<span>Seats in shade</span>
<strong id="seatCount">0 / 0</strong>
</div>
<div class="meter"><span id="seatMeter"></span></div>
</div>
<div class="stat">
<div class="stat-label">
<span>Cool gathering zones</span>
<strong id="zoneCount">0 / 0</strong>
</div>
<div class="meter"><span id="zoneMeter"></span></div>
</div>
<p id="liveNote">Long shadows gather under the west colonnade.</p>
</aside>
<div class="hint">
<span class="mouse" aria-hidden="true"></span>
<span>Drag to orbit · Scroll to zoom</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 sceneHost = document.querySelector("#scene");
const timeSlider = document.querySelector("#timeSlider");
const timeDisplay = document.querySelector("#time");
const phaseDisplay = document.querySelector("#phase");
const playButton = document.querySelector("#play");
const resetButton = document.querySelector("#reset");
const seatCountDisplay = document.querySelector("#seatCount");
const zoneCountDisplay = document.querySelector("#zoneCount");
const seatMeter = document.querySelector("#seatMeter");
const zoneMeter = document.querySelector("#zoneMeter");
const liveNote = document.querySelector("#liveNote");
const labelsHost = document.querySelector("#labels");
const state = {
time: 8.4,
playing: true,
lastShadeCheck: 0,
lastTime: -1
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc8d9d5);
scene.fog = new THREE.Fog(0xc8d9d5, 63, 145);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
240
);
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.12;
sceneHost.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(
0xdff4f1,
0x6c5440,
1.25
);
scene.add(hemisphere);
const sunLight = new THREE.DirectionalLight(0xfff0cf, 3);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -24;
sunLight.shadow.camera.right = 24;
sunLight.shadow.camera.top = 24;
sunLight.shadow.camera.bottom = -24;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 150;
sunLight.shadow.bias = -0.00045;
sunLight.shadow.normalBias = 0.035;
scene.add(sunLight);
scene.add(sunLight.target);
const sunBlock = new THREE.Mesh(
new THREE.BoxGeometry(1, 1, 1),
new THREE.MeshBasicMaterial({ color: 0xffd98c })
);
sunBlock.scale.setScalar(4.2);
scene.add(sunBlock);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const occluders = [];
const seats = [];
const zoneSeats = {};
const zoneLabels = [];
const materials = {
foundation: new THREE.MeshStandardMaterial({
color: 0x6f756e,
roughness: 0.93
}),
outside: new THREE.MeshStandardMaterial({
color: 0xa9b2a5,
roughness: 1
}),
sandstone: new THREE.MeshStandardMaterial({
color: 0xd2b98e,
roughness: 0.9
}),
sandstoneLight: new THREE.MeshStandardMaterial({
color: 0xe2cda7,
roughness: 0.88
}),
sandstoneDark: new THREE.MeshStandardMaterial({
color: 0xb79b73,
roughness: 0.92
}),
wood: new THREE.MeshStandardMaterial({
color: 0x8f6040,
roughness: 0.82
}),
woodLight: new THREE.MeshStandardMaterial({
color: 0xb98557,
roughness: 0.78
}),
darkWood: new THREE.MeshStandardMaterial({
color: 0x503d31,
roughness: 0.92
}),
metal: new THREE.MeshStandardMaterial({
color: 0x384747,
roughness: 0.52,
metalness: 0.28
}),
glass: new THREE.MeshStandardMaterial({
color: 0x365d65,
roughness: 0.24,
metalness: 0.12
}),
foliage: new THREE.MeshStandardMaterial({
color: 0x54775a,
roughness: 0.96
}),
foliageLight: new THREE.MeshStandardMaterial({
color: 0x76916a,
roughness: 0.96
}),
foliageDark: new THREE.MeshStandardMaterial({
color: 0x395b4e,
roughness: 0.98
}),
soil: new THREE.MeshStandardMaterial({
color: 0x594538,
roughness: 1
}),
terra: new THREE.MeshStandardMaterial({
color: 0xc36f52,
roughness: 0.88
}),
cream: new THREE.MeshStandardMaterial({
color: 0xe9d8b7,
roughness: 0.88
}),
rug: new THREE.MeshStandardMaterial({
color: 0x738f88,
roughness: 1
}),
fruit: new THREE.MeshStandardMaterial({
color: 0xe99b43,
roughness: 0.85
}),
lantern: new THREE.MeshStandardMaterial({
color: 0xffd18c,
emissive: 0xe6953e,
emissiveIntensity: 1.4,
roughness: 0.6
})
};
function makeBox(
width,
height,
depth,
x,
y,
z,
material,
parent = scene,
options = {}
) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
if (options.occlude) {
occluders.push(mesh);
}
return mesh;
}
// The surrounding ground and raised courtyard foundation.
makeBox(
120,
0.3,
120,
0,
-1.3,
0,
materials.outside,
scene,
{ cast: false }
);
makeBox(
30.5,
1,
24.5,
0,
-0.62,
0,
materials.foundation
);
// Instanced paving: hundreds of individually colored voxel stones.
const pavingMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96
});
const tileCountX = 29;
const tileCountZ = 23;
const paving = new THREE.InstancedMesh(
unitBox,
pavingMaterial,
tileCountX * tileCountZ
);
paving.receiveShadow = true;
paving.castShadow = false;
const dummy = new THREE.Object3D();
const pavingColors = [
new THREE.Color(0xb8aa91),
new THREE.Color(0xc7b89c),
new THREE.Color(0xa99d87),
new THREE.Color(0xd1c2a4),
new THREE.Color(0xc0ad91)
];
let tileIndex = 0;
for (let z = -11; z <= 11; z++) {
for (let x = -14; x <= 14; x++) {
dummy.position.set(x, -0.045, z);
dummy.scale.set(1.94, 0.18, 1.94);
dummy.updateMatrix();
paving.setMatrixAt(tileIndex, dummy.matrix);
const checker = (x + z) & 1;
let color = pavingColors[(Math.abs(x * 7 + z * 11) + checker) % pavingColors.length];
if (x > -4 && x < 7 && z > -4 && z < 7) {
color = checker
? new THREE.Color(0xddc9a5)
: new THREE.Color(0xc98767);
}
paving.setColorAt(tileIndex, color);
tileIndex++;
}
}
paving.instanceMatrix.needsUpdate = true;
if (paving.instanceColor) paving.instanceColor.needsUpdate = true;
scene.add(paving);
// Low perimeter curb.
const curbMaterial = materials.sandstoneDark;
for (let x = -14; x <= 14; x++) {
makeBox(1.94, 0.27, 0.25, x, 0.13, -11.65, curbMaterial);
makeBox(1.94, 0.27, 0.25, x, 0.13, 11.65, curbMaterial);
}
for (let z = -11; z <= 11; z++) {
makeBox(0.25, 0.27, 1.94, -14.65, 0.13, z, curbMaterial);
makeBox(0.25, 0.27, 1.94, 14.65, 0.13, z, curbMaterial);
}
// North masonry wall with window openings.
for (let column = 0; column < 14; column++) {
const x = -13 + column * 2;
for (let row = 0; row < 5; row++) {
const isWindow = row === 2 && [2, 6, 10].includes(column);
if (!isWindow) {
const material = [
materials.sandstone,
materials.sandstoneLight,
materials.sandstoneDark
][(column + row * 2) % 3];
makeBox(
1.94,
1.52,
1.2,
x,
0.82 + row * 1.59,
-10.55,
material,
scene,
{ occlude: true }
);
}
}
if ([2, 6, 10].includes(column)) {
makeBox(
1.55,
1.46,
0.12,
x,
4.0,
-9.88,
materials.glass
);
makeBox(0.12, 1.55, 0.16, x, 4.0, -9.78, materials.darkWood);
makeBox(1.65, 0.12, 0.16, x, 4.0, -9.78, materials.darkWood);
}
}
// West masonry wall and recessed doorway.
for (let column = 0; column < 10; column++) {
const z = -9 + column * 2;
for (let row = 0; row < 5; row++) {
const doorway = column === 6 && row < 3;
const window = row === 2 && [2, 8].includes(column);
if (!doorway && !window) {
const material = [
materials.sandstoneLight,
materials.sandstone,
materials.sandstoneDark
][(column + row) % 3];
makeBox(
1.2,
1.52,
1.94,
-13.55,
0.82 + row * 1.59,
z,
material,
scene,
{ occlude: true }
);
}
}
if ([2, 8].includes(column)) {
makeBox(
0.12,
1.46,
1.55,
-12.88,
4.0,
z,
materials.glass
);
}
}
makeBox(
0.18,
3.05,
1.62,
-12.94,
1.6,
3,
materials.darkWood
);
makeBox(
0.12,
0.18,
1.83,
-12.78,
3.15,
3,
materials.woodLight
);
// Warm wall lanterns.
for (const x of [-9, 2, 9]) {
makeBox(0.25, 0.65, 0.25, x, 3.05, -9.55, materials.metal);
makeBox(0.38, 0.38, 0.38, x, 3.05, -9.34, materials.lantern);
}
// A simplified voxel skyline beyond the courtyard.
const skylineMaterials = [
new THREE.MeshStandardMaterial({ color: 0x8fa39c, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0xa7afa0, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x7f9691, roughness: 1 })
];
for (let i = 0; i < 16; i++) {
const x = -24 + i * 3.1;
const height = 2.5 + ((i * 7) % 6);
const z = -16 - ((i * 5) % 4);
makeBox(
2.4,
height,
2.8,
x,
height / 2 - 0.8,
z,
skylineMaterials[i % skylineMaterials.length],
scene,
{ cast: false }
);
}
// Pergola: slender posts and slatted roof create moving stripes of shade.
const pergolaX = -6.5;
const pergolaZ = -4.5;
for (const x of [-10.2, -2.8]) {
for (const z of [-7.2, -1.8]) {
makeBox(
0.34,
3.65,
0.34,
x,
1.88,
z,
materials.wood,
scene,
{ occlude: true }
);
makeBox(
0.48,
0.18,
0.48,
x,
0.16,
z,
materials.sandstoneDark
);
}
}
for (const z of [-7.2, -1.8]) {
makeBox(
8.05,
0.34,
0.38,
pergolaX,
3.67,
z,
materials.woodLight,
scene,
{ occlude: true }
);
}
for (let i = 0; i < 13; i++) {
makeBox(
0.28,
0.22,
6.25,
-10.15 + i * 0.61,
3.92,
pergolaZ,
materials.woodLight,
scene,
{ occlude: true }
);
}
// A woven lounge rug under the pergola.
makeBox(
7.35,
0.035,
5.25,
pergolaX,
0.09,
pergolaZ,
materials.rug,
scene,
{ cast: false }
);
// Central stepped gathering platform.
makeBox(8.35, 0.28, 8.35, 1.5, 0.19, 1.5, materials.sandstoneDark);
makeBox(7.55, 0.28, 7.55, 1.5, 0.45, 1.5, materials.sandstoneLight);
const mosaicMaterials = [
materials.cream,
materials.terra,
materials.sandstoneDark
];
for (let x = -3; x <= 3; x++) {
for (let z = -3; z <= 3; z++) {
const ring = Math.max(Math.abs(x), Math.abs(z));
if (ring === 3 || (x === 0 && z === 0)) {
makeBox(
0.76,
0.045,
0.76,
1.5 + x * 0.94,
0.615,
1.5 + z * 0.94,
mosaicMaterials[ring === 3 ? 2 : 0],
scene,
{ cast: false }
);
}
}
}
// Bench builder with independently shade-reactive cushions.
const warmCushion = new THREE.Color(0xe38a62);
const coolCushion = new THREE.Color(0x5d929b);
function addBench(x, z, rotation, zone, seatCount = 3, elevation = 0.05) {
const group = new THREE.Group();
group.position.set(x, elevation, z);
group.rotation.y = rotation;
scene.add(group);
const seatLength = Math.max(2.35, seatCount * 0.9 + 0.15);
makeBox(
seatLength,
0.28,
0.78,
0,
0.67,
0,
materials.wood,
group
);
makeBox(
seatLength,
0.67,
0.18,
0,
1.13,
0.38,
materials.woodLight,
group
);
for (const legX of [-seatLength * 0.36, seatLength * 0.36]) {
makeBox(
0.25,
0.58,
0.58,
legX,
0.3,
0,
materials.darkWood,
group
);
}
for (let i = 0; i < seatCount; i++) {
const localX = (i - (seatCount - 1) / 2) * 0.9;
const cushionMaterial = materials.terra.clone();
cushionMaterial.emissive.setHex(0x25140c);
cushionMaterial.emissiveIntensity = 0.12;
const cushion = makeBox(
0.78,
0.13,
0.65,
localX,
0.87,
-0.015,
cushionMaterial,
group
);
group.updateMatrixWorld(true);
const worldPosition = group.localToWorld(
new THREE.Vector3(localX, 0.95, 0)
);
seats.push({
cushion,
position: worldPosition,
shaded: false
});
if (!zoneSeats[zone]) zoneSeats[zone] = [];
zoneSeats[zone].push(seats[seats.length - 1]);
}
}
// Plaza seating.
addBench(1.5, -3.65, Math.PI, "plaza");
addBench(1.5, 6.65, 0, "plaza");
addBench(-3.15, 1.5, -Math.PI / 2, "plaza");
addBench(6.15, 1.5, Math.PI / 2, "plaza");
// Pergola lounge seating.
addBench(-6.5, -6.25, Math.PI, "lounge");
addBench(-6.5, -2.75, 0, "lounge");
// Garden and north nook seating.
addBench(11.25, -3.5, Math.PI / 2, "garden", 2);
addBench(4.5, -8.85, Math.PI, "north", 3);
// Voxel planter and tree builder.
function addPlanter(x, z, scale = 1, fruitTree = false) {
const s = 2.15 * scale;
const rim = 0.32 * scale;
makeBox(s, 0.55, rim, x, 0.31, z - s / 2 + rim / 2, materials.sandstoneDark);
makeBox(s, 0.55, rim, x, 0.31, z + s / 2 - rim / 2, materials.sandstoneDark);
makeBox(rim, 0.55, s - rim * 2, x - s / 2 + rim / 2, 0.31, z, materials.sandstoneDark);
makeBox(rim, 0.55, s - rim * 2, x + s / 2 - rim / 2, 0.31, z, materials.sandstoneDark);
makeBox(s - rim * 1.5, 0.12, s - rim * 1.5, x, 0.15, z, materials.soil);
const trunkHeight = 2.55 * scale;
makeBox(
0.42 * scale,
trunkHeight,
0.42 * scale,
x,
0.2 + trunkHeight / 2,
z,
materials.wood
);
makeBox(
1.75 * scale,
1.5 * scale,
1.65 * scale,
x,
3.1 * scale,
z,
fruitTree ? materials.foliageDark : materials.foliage,
scene,
{ occlude: true }
);
makeBox(
1.45 * scale,
1.25 * scale,
1.4 * scale,
x - 0.65 * scale,
3.95 * scale,
z + 0.25 * scale,
fruitTree ? materials.foliage : materials.foliageLight,
scene,
{ occlude: true }
);
makeBox(
1.25 * scale,
1.1 * scale,
1.3 * scale,
x + 0.7 * scale,
3.75 * scale,
z - 0.2 * scale,
materials.foliageDark,
scene,
{ occlude: true }
);
if (fruitTree) {
for (let i = 0; i < 7; i++) {
const fruit = makeBox(
0.2 * scale,
0.2 * scale,
0.2 * scale,
x + Math.sin(i * 2.1) * 0.85 * scale,
2.65 * scale + (i % 3) * 0.62 * scale,
z + Math.cos(i * 1.7) * 0.82 * scale,
materials.fruit
);
fruit.castShadow = false;
}
}
// Small flowering cubes.
for (let i = 0; i < 5; i++) {
const flower = makeBox(
0.16,
0.16,
0.16,
x - 0.65 * scale + i * 0.3 * scale,
0.29,
z + 0.35 * scale,
i % 2 ? materials.flower || materials.lantern : materials.terra
);
flower.castShadow = false;
}
}
addPlanter(-11, -7.8, 1.05, false);
addPlanter(-11.1, 7.2, 0.9, true);
addPlanter(10.7, 7.5, 1.05, false);
addPlanter(11.2, -7.9, 0.85, true);
// Small voxel shrubs.
const shrubPositions = [
[-12, 1], [-12, 4], [12.5, 1], [12.5, 4],
[-5, -9], [2, -9], [7, 9], [-3, 9]
];
shrubPositions.forEach(([x, z], i) => {
makeBox(
0.85,
0.75 + (i % 2) * 0.25,
0.85,
x,
0.43,
z,
i % 2 ? materials.foliageLight : materials.foliageDark
);
});
// Geometric square fountain.
makeBox(3.4, 0.32, 3.4, 9, 0.22, -5, materials.sandstoneDark);
makeBox(3.05, 0.38, 0.32, 9, 0.42, -6.35, materials.sandstone);
makeBox(3.05, 0.38, 0.32, 9, 0.42, -3.65, materials.sandstone);
makeBox(0.32, 0.38, 2.7, 7.65, 0.42, -5, materials.sandstone);
makeBox(0.32, 0.38, 2.7, 10.35, 0.42, -5, materials.sandstone);
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4fabb4,
roughness: 0.18,
metalness: 0.08,
transparent: true,
opacity: 0.9
});
const water = makeBox(
2.72,
0.1,
2.72,
9,
0.48,
-5,
waterMaterial,
scene,
{ cast: false }
);
makeBox(0.55, 1.1, 0.55, 9, 1.0, -5, materials.sandstoneLight);
makeBox(1.45, 0.2, 1.45, 9, 1.64, -5, materials.sandstone);
for (let i = 0; i < 3; i++) {
const ripple = makeBox(
0.8 + i * 0.35,
0.025,
0.13,
9,
0.56,
-5 + (i - 1) * 0.55,
materials.sandstoneLight,
scene,
{ cast: false }
);
ripple.castShadow = false;
}
// Simple voxel residents for scale.
function addPerson(x, y, z, shirtColor, rotation = 0, scale = 1, seated = false) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const shirt = new THREE.MeshStandardMaterial({
color: shirtColor,
roughness: 0.9
});
const skin = new THREE.MeshStandardMaterial({
color: 0xc9916b,
roughness: 0.9
});
const trousers = new THREE.MeshStandardMaterial({
color: 0x33474b,
roughness: 0.95
});
if (seated) {
makeBox(0.5, 0.67, 0.32, 0, 1.18, 0, shirt, group);
makeBox(0.38, 0.38, 0.38, 0, 1.72, 0, skin, group);
makeBox(0.16, 0.16, 0.58, -0.14, 0.91, -0.38, trousers, group);
makeBox(0.16, 0.16, 0.58, 0.14, 0.91, -0.38, trousers, group);
} else {
makeBox(0.52, 0.7, 0.32, 0, 1.28, 0, shirt, group);
makeBox(0.4, 0.4, 0.4, 0, 1.85, 0, skin, group);
makeBox(0.17, 0.68, 0.2, -0.14, 0.67, 0, trousers, group);
makeBox(0.17, 0.68, 0.2, 0.14, 0.67, 0, trousers, group);
makeBox(0.14, 0.62, 0.16, -0.35, 1.26, 0, shirt, group);
makeBox(0.14, 0.62, 0.16, 0.35, 1.26, 0, shirt, group);
}
}
addPerson(-0.1, 0.64, 0.6, 0xbd6b54, 0.3);
addPerson(2.4, 0.64, 2.1, 0x4f7c79, -0.5, 0.94);
addPerson(3.45, 0.64, 3.7, 0xd4a357, 0.7, 0.72);
addPerson(-5.2, 0.1, -4.7, 0x657c9a, 0.2);
addPerson(8.4, 0.1, -1.7, 0xa85f55, -0.4, 0.95);
addPerson(-6.5, 0.1, -6.25, 0x57776b, Math.PI, 0.92, true);
// Projected HTML labels for the main gathering areas.
const zoneDefinitions = {
plaza: {
name: "Central Plaza",
anchor: new THREE.Vector3(1.5, 2.05, 1.5)
},
lounge: {
name: "Pergola Lounge",
anchor: new THREE.Vector3(-6.5, 4.65, -4.5)
},
garden: {
name: "Water Garden",
anchor: new THREE.Vector3(9, 2.45, -5)
},
north: {
name: "North Nook",
anchor: new THREE.Vector3(4.5, 2.1, -8.85)
}
};
for (const [id, definition] of Object.entries(zoneDefinitions)) {
const element = document.createElement("div");
element.className = "zone-label";
element.innerHTML =
'<span class="zone-dot"></span><span class="zone-text"></span>';
labelsHost.appendChild(element);
zoneLabels.push({
id,
element,
text: element.querySelector(".zone-text"),
anchor: definition.anchor
});
}
// Custom orbit controls, implemented without external examples/addons.
const orbit = {
target: new THREE.Vector3(0, 1.15, 0),
radius: 42,
theta: 0.72,
phi: 1.04
};
function defaultRadius() {
return window.innerWidth / window.innerHeight < 0.8 ? 57 : 42;
}
function updateCamera() {
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);
}
function resetView() {
orbit.target.set(0, 1.15, 0);
orbit.radius = defaultRadius();
orbit.theta = 0.72;
orbit.phi = 1.04;
updateCamera();
}
const pointers = new Map();
let pinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const deltaX = event.clientX - previous.x;
const deltaY = event.clientY - previous.y;
previous.x = event.clientX;
previous.y = event.clientY;
if (pointers.size === 1) {
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - deltaY * 0.005,
0.46,
1.34
);
} else 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) {
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * (pinchDistance / distance),
25,
76
);
}
pinchDistance = distance;
}
updateCamera();
});
function removePointer(event) {
pointers.delete(event.pointerId);
pinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", removePointer);
renderer.domElement.addEventListener("pointercancel", removePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
25,
76
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
// Daylight palette and dynamic sun position.
const skyColors = {
dawn: new THREE.Color(0xe3ae8b),
morning: new THREE.Color(0xc9d9d5),
noon: new THREE.Color(0xaecfd2),
golden: new THREE.Color(0xe6b47d)
};
const warmSun = new THREE.Color(0xffbc72);
const noonSun = new THREE.Color(0xfff3d4);
const currentSky = new THREE.Color();
const currentSunColor = new THREE.Color();
const sunDirection = new THREE.Vector3();
function getPhase(time) {
if (time < 8) return "First light";
if (time < 11) return "Morning light";
if (time < 14) return "High sun";
if (time < 17) return "Afternoon light";
return "Golden hour";
}
function getLiveNote(time) {
if (time < 8.5) {
return "Long shadows gather under the west colonnade.";
}
if (time < 11.5) {
return "Morning light opens the central gathering plaza.";
}
if (time < 14.5) {
return "High sun shortens every shadow; shade retreats to the slats.";
}
if (time < 17) {
return "The sun shifts east, revealing the water garden.";
}
return "Amber light moves across the benches as evening arrives.";
}
function updateSun(time) {
const daylightProgress = THREE.MathUtils.clamp(
(time - 6) / 13,
0,
1
);
const altitude = Math.max(
0,
Math.sin(daylightProgress * Math.PI)
);
const x = (time - 12) * 3.05;
const y = Math.max(2.2, Math.sin(daylightProgress * Math.PI) * 44);
const z = -11.5;
sunDirection.set(x, y, z).normalize();
sunLight.position.copy(sunDirection).multiplyScalar(64);
sunLight.target.position.set(0, 0, 0);
sunLight.target.updateMatrixWorld();
sunBlock.position.copy(sunDirection).multiplyScalar(105);
sunBlock.rotation.y = daylightProgress * Math.PI * 0.3;
sunBlock.rotation.z = daylightProgress * 0.12;
sunLight.intensity = 0.18 + Math.pow(altitude, 0.68) * 3.0;
hemisphere.intensity = 0.62 + altitude * 0.54;
currentSunColor.copy(warmSun).lerp(noonSun, Math.pow(altitude, 0.55));
sunLight.color.copy(currentSunColor);
sunBlock.material.color.copy(currentSunColor);
if (time < 8.5) {
currentSky
.copy(skyColors.dawn)
.lerp(skyColors.morning, (time - 6) / 2.5);
} else if (time < 11.5) {
currentSky
.copy(skyColors.morning)
.lerp(skyColors.noon, (time - 8.5) / 3);
} else if (time < 15) {
currentSky
.copy(skyColors.noon)
.lerp(skyColors.golden, (time - 11.5) / 6.5);
} else {
currentSky
.copy(skyColors.golden)
.lerp(skyColors.dawn, (time - 15) / 4);
}
scene.background.copy(currentSky);
scene.fog.color.copy(currentSky);
materials.outside.color.copy(currentSky).multiplyScalar(0.78);
const hours = Math.floor(time);
const minutes = Math.floor((time - hours) * 60);
timeDisplay.textContent =
`${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}`;
phaseDisplay.textContent = getPhase(time);
liveNote.textContent = getLiveNote(time);
const percentage = ((time - 6) / 13) * 100;
timeSlider.style.setProperty("--p", `${percentage}%`);
}
// Direct ray checks determine which seat cushions are physically shaded.
const shadeRaycaster = new THREE.Raycaster();
const shadeDirection = new THREE.Vector3();
function updateShade() {
for (const seat of seats) {
shadeDirection
.copy(sunLight.position)
.sub(seat.position)
.normalize();
shadeRaycaster.set(seat.position, shadeDirection);
shadeRaycaster.near = 0.03;
shadeRaycaster.far = sunLight.position.distanceTo(seat.position);
const intersections = shadeRaycaster.intersectObjects(
occluders,
false
);
seat.shaded = intersections.length > 0;
}
let shadedSeatTotal = 0;
let coolZoneTotal = 0;
const zoneCount = Object.keys(zoneSeats).length;
for (const [zoneId, zoneSeatList] of Object.entries(zoneSeats)) {
const shaded = zoneSeatList.filter((seat) => seat.shaded).length;
shadedSeatTotal += shaded;
const isCool = zoneSeatList.length > 0 &&
shaded / zoneSeatList.length >= 0.5;
if (isCool) coolZoneTotal++;
const label = zoneLabels.find((item) => item.id === zoneId);
if (label) {
label.element.classList.toggle("cool", isCool);
label.text.textContent = isCool
? `${zoneDefinitions[zoneId].name} · Cool`
: `${zoneDefinitions[zoneId].name} · Sunlit`;
}
}
seatCountDisplay.textContent = `${shadedSeatTotal} / ${seats.length}`;
zoneCountDisplay.textContent = `${coolZoneTotal} / ${zoneCount}`;
seatMeter.style.width = `${(shadedSeatTotal / seats.length) * 100}%`;
zoneMeter.style.width = `${(coolZoneTotal / zoneCount) * 100}%`;
}
function updateZoneLabelPositions() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of zoneLabels) {
const projected = label.anchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
label.element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
label.element.style.opacity = visible ? "1" : "0";
}
}
playButton.addEventListener("click", () => {
state.playing = !state.playing;
playButton.textContent = state.playing ? "Pause" : "Play";
});
timeSlider.addEventListener("input", () => {
state.time = Number(timeSlider.value);
updateSun(state.time);
updateShade();
});
resetButton.addEventListener("click", resetView);
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
playButton.click();
}
if (event.key.toLowerCase() === "r") {
resetView();
}
});
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.fov = camera.aspect < 0.8 ? 48 : 38;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
if (camera.aspect < 0.8) {
orbit.radius = Math.max(orbit.radius, 53);
}
updateCamera();
}
window.addEventListener("resize", resize);
resize();
orbit.radius = defaultRadius();
updateCamera();
updateSun(state.time);
updateShade();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (state.playing) {
state.time += delta * 0.32;
if (state.time >= 19) {
state.time = 6;
}
timeSlider.value = state.time;
updateSun(state.time);
}
state.lastShadeCheck += delta;
if (state.lastShadeCheck > 0.12) {
updateShade();
state.lastShadeCheck = 0;
}
for (const seat of seats) {
const target = seat.shaded ? coolCushion : warmCushion;
seat.cushion.material.color.lerp(target, 0.09);
}
water.material.opacity = 0.88 + Math.sin(clock.elapsedTime * 1.8) * 0.035;
water.position.y = 0.48 + Math.sin(clock.elapsedTime * 1.4) * 0.012;
updateZoneLabelPositions();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```