Prompt specification
Build or customize the Three.js 3D scene "Craft seller beside an Oaxaca pedestrian plaza" 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: Craft seller beside an Oaxaca pedestrian plaza
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/craft-seller-beside-an-oaxaca-pedestrian-plaza-x2774
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Santo Domingo's plaza in Oaxaca. Create a compact referenced plaza vignette with an original craft table, shaded seating, and pedestrians. Keep the doorway approach and main walking path open. Voxel style.
Working Three.js Starter (craft-seller-beside-an-oaxaca-pedestrian-plaza-x2774):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Plaza Santo Domingo — Oaxaca Voxel Vignette</title>
<style>
:root {
--ink: #24312f;
--paper: #fff8e8;
--terracotta: #b9563c;
--jade: #39766a;
--sun: #e4aa43;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #a9cfd0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
width: min(370px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 18px;
background: rgba(255, 248, 232, 0.88);
box-shadow: 0 16px 45px rgba(50, 58, 48, 0.17);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--terracotta);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
width: 18px;
height: 3px;
border-radius: 3px;
background: var(--sun);
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 39px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 0;
color: #58635e;
font-size: 13px;
line-height: 1.5;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 13px;
}
.chip {
padding: 5px 9px;
border-radius: 999px;
background: rgba(57, 118, 106, 0.1);
color: #315d54;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
}
.help {
position: fixed;
left: 24px;
bottom: 24px;
z-index: 10;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 12px;
background: rgba(36, 49, 47, 0.76);
color: #fff9eb;
box-shadow: 0 10px 30px rgba(30, 40, 38, 0.14);
font-size: 11px;
line-height: 1.35;
pointer-events: none;
backdrop-filter: blur(9px);
}
.help strong {
color: #f3c763;
}
.controls {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 20;
display: flex;
gap: 7px;
}
.controls button {
width: 40px;
height: 40px;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: 12px;
background: rgba(255, 248, 232, 0.9);
color: var(--ink);
box-shadow: 0 8px 25px rgba(40, 50, 45, 0.15);
font: 700 17px/1 system-ui, sans-serif;
cursor: pointer;
backdrop-filter: blur(8px);
transition: transform 120ms ease, background 120ms ease;
}
.controls button:hover {
background: #fffdf5;
transform: translateY(-2px);
}
.controls button:active {
transform: translateY(0);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #a9cfd0;
color: #315d54;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
transition: opacity 450ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 640px) {
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
.chips {
margin-top: 10px;
}
.help {
left: 14px;
bottom: 14px;
max-width: 230px;
}
.controls {
right: 14px;
bottom: 14px;
flex-direction: column;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive voxel-style miniature of Plaza Santo Domingo in Oaxaca"
></canvas>
<section class="title-card" aria-label="Scene title">
<div class="eyebrow">Voxel miniature · Oaxaca, México</div>
<h1>Plaza Santo Domingo</h1>
<p class="subtitle">
A compact afternoon study of cantera stone, market craft, shaded seating,
and the open approach to the basilica doorway.
</p>
<div class="chips">
<span class="chip">SANTO DOMINGO</span>
<span class="chip">AFTERNOON MARKET</span>
<span class="chip">OPEN CENTRAL WALK</span>
</div>
</section>
<div class="help">
<strong>Drag</strong> to orbit · <strong>Shift/right-drag</strong> to pan ·
<strong>Scroll</strong> to zoom
</div>
<div class="controls" aria-label="Camera controls">
<button id="zoomIn" title="Zoom in" aria-label="Zoom in">+</button>
<button id="zoomOut" title="Zoom out" aria-label="Zoom out">−</button>
<button id="reset" title="Reset camera" aria-label="Reset camera">↺</button>
</div>
<div id="loading">Building the plaza…</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.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xa9cfd0);
scene.fog = new THREE.Fog(0xa9cfd0, 25, 48);
const camera = new THREE.OrthographicCamera(-12, 12, 8, -8, 0.1, 100);
const orbit = {
theta: 0.61,
phi: 1.03,
radius: 21,
zoom: 1,
target: new THREE.Vector3(0, 2.05, -1.45)
};
const home = {
theta: 0.61,
phi: 1.03,
radius: 21,
zoom: 1,
target: new THREE.Vector3(0, 2.05, -1.45)
};
const hemisphere = new THREE.HemisphereLight(0xfff4d8, 0x6f594b, 2.05);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedc6, 3.15);
sun.position.set(-9, 16, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00045;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x88c8cf, 0.7);
fill.position.set(9, 7, -8);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (color && color.isMaterial) return color;
const key = String(color);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0
})
);
}
return materialCache.get(key);
}
function box(
parent,
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
options = {}
) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
if (options.rotation) {
mesh.rotation.set(
options.rotation.x || 0,
options.rotation.y || 0,
options.rotation.z || 0
);
}
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function group(parent, x = 0, y = 0, z = 0) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
let randomSeed = 48173;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
function randomBetween(min, max) {
return min + (max - min) * random();
}
// ---------------------------------------------------------------------
// Diorama base and individually colored voxel paving
// ---------------------------------------------------------------------
const world = group(scene);
box(
world,
120,
0.12,
120,
0x8dbab5,
0,
-0.68,
0,
{ castShadow: false }
);
box(world, 16.65, 0.55, 20.65, 0x765447, 0, -0.39, 0);
box(world, 16.35, 0.16, 20.35, 0xb87950, 0, -0.08, 0);
const tileCount = 32 * 40;
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
});
const tiles = new THREE.InstancedMesh(unitBox, tileMaterial, tileCount);
tiles.receiveShadow = true;
tiles.castShadow = false;
const dummy = new THREE.Object3D();
const tileColor = new THREE.Color();
const pavingPalette = [0xc28d62, 0xd0a071, 0xb97e58, 0xd8aa7c, 0xc79568];
let tileIndex = 0;
for (let row = 0; row < 40; row++) {
for (let col = 0; col < 32; col++) {
const x = -7.75 + col * 0.5;
const z = -9.75 + row * 0.5;
dummy.position.set(x, -0.025, z);
dummy.scale.set(0.47, 0.1, 0.47);
dummy.updateMatrix();
tiles.setMatrixAt(tileIndex, dummy.matrix);
if (Math.abs(x) < 1.25) {
tileColor.setHex(0xe3c48f);
} else if (Math.abs(x) < 1.75) {
tileColor.setHex(0xae6048);
} else {
tileColor.setHex(
pavingPalette[Math.floor(random() * pavingPalette.length)]
);
tileColor.offsetHSL(
randomBetween(-0.018, 0.018),
randomBetween(-0.035, 0.035),
randomBetween(-0.035, 0.035)
);
}
tiles.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
tiles.instanceMatrix.needsUpdate = true;
if (tiles.instanceColor) tiles.instanceColor.needsUpdate = true;
world.add(tiles);
// Low boundary blocks keep the center completely clear.
for (const side of [-1, 1]) {
box(world, 0.38, 0.46, 17.6, 0xbd8057, side * 7.95, 0.22, -0.1);
for (let z = -7.5; z <= 7.6; z += 2.5) {
box(world, 0.64, 0.76, 0.64, 0xc89160, side * 7.93, 0.37, z);
box(world, 0.76, 0.14, 0.76, 0xd9aa75, side * 7.93, 0.8, z);
}
}
// ---------------------------------------------------------------------
// Santo Domingo-inspired cantera church facade
// ---------------------------------------------------------------------
function addStatue(parent, x, y, z, color = 0xeee0bc) {
box(parent, 0.19, 0.28, 0.12, color, x, y + 0.36, z);
box(parent, 0.38, 0.54, 0.18, color, x, y, z);
box(parent, 0.11, 0.36, 0.13, color, x - 0.23, y + 0.08, z + 0.02);
box(parent, 0.11, 0.36, 0.13, color, x + 0.23, y + 0.08, z + 0.02);
box(parent, 0.29, 0.08, 0.17, 0xa45a3d, x, y - 0.26, z);
}
function addDoorPanel(parent, side) {
const hinge = group(parent, side * 1.01, 0, -5.13);
hinge.rotation.y = side * -0.42;
const center = -side * 0.46;
box(hinge, 0.86, 2.8, 0.12, 0x315a50, center, 1.42, 0);
for (let i = 0; i < 4; i++) {
box(
hinge,
0.035,
2.55,
0.025,
0x6c3e2e,
center - 0.3 + i * 0.2,
1.42,
0.075
);
}
box(hinge, 0.08, 0.08, 0.08, 0xe2b24e, center - side * 0.28, 1.35, 0.11);
}
function buildChurch() {
const church = group(world);
// Nave and terracotta roof.
box(church, 10.3, 6.65, 4.8, 0xc98c52, 0, 3.32, -8);
box(church, 10.65, 0.46, 5.05, 0xa94f36, 0, 6.86, -8);
box(church, 10.1, 0.25, 4.65, 0xc05b3a, 0, 7.12, -8);
for (let x = -4.6; x <= 4.7; x += 0.7) {
box(church, 0.14, 0.11, 4.8, 0x7c382d, x, 7.34, -8);
}
// Side facade bays.
for (const side of [-1, 1]) {
const x = side * 3.45;
box(church, 2.18, 5.75, 0.55, 0xd39b5e, x, 2.87, -5.37);
box(church, 2.42, 0.28, 0.72, 0xe0ad6e, x, 5.88, -5.32);
box(church, 2.48, 0.18, 0.78, 0xaa673e, x, 0.11, -5.27);
// Niche and miniature figure.
box(church, 0.78, 1.65, 0.07, 0x644431, x, 3.65, -5.06);
box(church, 0.94, 0.14, 0.17, 0xe3b172, x, 4.56, -5.02);
box(church, 0.94, 0.14, 0.17, 0xe3b172, x, 2.77, -5.02);
addStatue(church, x, 3.52, -4.98);
// Voxel pilasters.
for (const offset of [-0.86, 0.86]) {
box(church, 0.28, 4.85, 0.25, 0xe5b173, x + offset, 2.65, -4.98);
box(church, 0.43, 0.18, 0.34, 0xf0c58a, x + offset, 5.13, -4.95);
box(church, 0.42, 0.16, 0.34, 0xb87143, x + offset, 0.34, -4.95);
}
// Small carved square reliefs.
for (const y of [1.55, 2.1]) {
box(church, 0.42, 0.34, 0.08, 0xb97848, x, y, -5.03);
box(church, 0.19, 0.13, 0.05, 0xe8bc78, x, y, -4.97);
}
}
// Central facade assembled around a genuinely open central doorway.
box(church, 1.15, 4.05, 0.58, 0xd9a462, -1.625, 2.025, -5.34);
box(church, 1.15, 4.05, 0.58, 0xd9a462, 1.625, 2.025, -5.34);
box(church, 2.1, 0.82, 0.62, 0xd29a58, 0, 3.6, -5.34);
box(church, 4.5, 2.72, 0.62, 0xd9a462, 0, 5.36, -5.34);
// Rich cornices and stepped upper silhouette.
box(church, 4.88, 0.25, 0.8, 0xefbf7b, 0, 6.86, -5.29);
box(church, 3.25, 0.5, 0.72, 0xd19a58, 0, 7.22, -5.3);
box(church, 2.15, 0.46, 0.65, 0xe5b170, 0, 7.68, -5.31);
box(church, 1.25, 0.36, 0.56, 0xc2854d, 0, 8.04, -5.32);
// Dark recess behind the open doors.
box(church, 2.05, 3.12, 0.08, 0x271d19, 0, 1.56, -5.56);
box(church, 1.8, 0.09, 0.34, 0x956140, 0, 0.08, -5.4);
addDoorPanel(church, -1);
addDoorPanel(church, 1);
// Portal frame and capitals.
for (const side of [-1, 1]) {
box(church, 0.28, 3.38, 0.28, 0xf0c486, side * 1.11, 1.68, -4.98);
box(church, 0.48, 0.2, 0.42, 0xe8b874, side * 1.11, 3.37, -4.94);
box(church, 0.46, 0.17, 0.4, 0xb36f43, side * 1.11, 0.28, -4.94);
}
// Voxel rose window.
box(church, 0.94, 0.94, 0.09, 0x76503c, 0, 5.42, -4.98);
box(church, 0.48, 0.48, 0.09, 0x497d74, 0, 5.42, -4.91);
box(church, 0.12, 0.76, 0.08, 0xe5bd7c, 0, 5.42, -4.85);
box(church, 0.76, 0.12, 0.08, 0xe5bd7c, 0, 5.42, -4.85);
box(church, 0.72, 0.72, 0.09, 0xe6bb75, 0, 5.42, -4.9);
// Central upper reliefs and tiny figures.
for (const x of [-1.62, 1.62]) {
box(church, 0.62, 1.1, 0.07, 0x80563c, x, 4.92, -4.99);
addStatue(church, x, 4.64, -4.91, 0xd8b77f);
}
// Small asymmetric bell tower behind the left side.
box(church, 1.55, 8.0, 1.7, 0xc88b51, -4.67, 4, -7.55);
box(church, 1.85, 0.3, 1.95, 0xe0aa68, -4.67, 8.08, -7.55);
box(church, 1.25, 1.15, 0.12, 0x3b3830, -4.67, 6.92, -6.67);
box(church, 0.56, 0.67, 0.5, 0xb9843f, -4.67, 6.7, -6.84);
box(church, 1.9, 0.38, 2, 0xa84e35, -4.67, 8.33, -7.55);
}
buildChurch();
// ---------------------------------------------------------------------
// Side arcades
// ---------------------------------------------------------------------
function buildArcade(side) {
const x = side * 7.1;
for (let z = -4.5; z <= 1.4; z += 1.9) {
box(world, 0.62, 2.2, 0.62, 0xc9925e, x, 1.1, z);
box(world, 0.82, 0.18, 0.82, 0xe0ae72, x, 2.3, z);
box(world, 0.78, 0.16, 0.78, 0xb77349, x, 0.12, z);
}
box(world, 0.76, 0.42, 7.4, 0xd5a067, x, 2.62, -1.55);
box(world, 0.94, 0.18, 7.7, 0xe7b878, x, 2.88, -1.55);
}
buildArcade(-1);
buildArcade(1);
// ---------------------------------------------------------------------
// Small voxel fountain, offset from the open central walk
// ---------------------------------------------------------------------
const fountain = group(world, -4.75, 0, -3.65);
box(fountain, 2.65, 0.28, 2.65, 0xa76f4d, 0, 0.15, 0);
box(fountain, 2.2, 0.18, 2.2, 0x4e8b86, 0, 0.37, 0);
box(fountain, 2.62, 0.36, 0.34, 0xd29b62, 0, 0.4, 1.17);
box(fountain, 2.62, 0.36, 0.34, 0xd29b62, 0, 0.4, -1.17);
box(fountain, 0.34, 0.36, 2.2, 0xd29b62, 1.17, 0.4, 0);
box(fountain, 0.34, 0.36, 2.2, 0xd29b62, -1.17, 0.4, 0);
box(fountain, 0.58, 0.78, 0.58, 0xc88b54, 0, 0.78, 0);
box(fountain, 1.15, 0.16, 1.15, 0xe0ac6c, 0, 1.2, 0);
box(fountain, 0.28, 0.52, 0.28, 0x679d91, 0, 1.52, 0);
box(fountain, 0.66, 0.15, 0.66, 0x8fc2ae, 0, 1.83, 0);
// ---------------------------------------------------------------------
// Shaded seating area on the left
// ---------------------------------------------------------------------
const seating = group(world, -4.65, 0, 1.25);
// Canopy poles stay outside the central walk.
for (const x of [-1.88, 1.88]) {
for (const z of [-1.35, 1.35]) {
box(seating, 0.12, 2.9, 0.12, 0x76503a, x, 1.45, z);
}
}
// Stepped fabric strips give the canopy a handmade voxel shape.
const canopyColors = [0xf5e6c7, 0xb85642, 0xf5e6c7, 0x4e8275, 0xf5e6c7, 0xb85642];
for (let i = 0; i < 6; i++) {
box(
seating,
0.64,
0.13,
3.12,
canopyColors[i],
-1.62 + i * 0.65,
2.93 + (i % 2) * 0.025,
0
);
}
box(seating, 4.2, 0.18, 0.16, 0x75513a, 0, 2.79, -1.58);
// Benches.
function bench(parent, x, z, rotation = 0) {
const b = group(parent, x, 0, z);
b.rotation.y = rotation;
box(b, 2.2, 0.18, 0.52, 0xa66b3f, 0, 0.55, 0);
box(b, 2.2, 0.62, 0.14, 0x815236, 0, 0.93, -0.22);
for (const legX of [-0.86, 0.86]) {
box(b, 0.17, 0.48, 0.42, 0x5d4937, legX, 0.27, 0);
}
return b;
}
bench(seating, 0, 0.72);
bench(seating, -1.18, -0.6, Math.PI / 2);
bench(seating, 1.18, -0.6, -Math.PI / 2);
// Small café table, still outside the main path.
box(seating, 0.12, 0.72, 0.12, 0x654936, 0.28, 0.38, -0.68);
box(seating, 0.74, 0.12, 0.74, 0xe2b36e, 0.28, 0.78, -0.68);
box(seating, 0.12, 0.16, 0.12, 0xf2dec0, 0.28, 0.91, -0.68);
// ---------------------------------------------------------------------
// Original craft table: asymmetric jade top, sun carving, textiles and
// miniature hand-built objects.
// ---------------------------------------------------------------------
const craft = group(world, 4.72, 0, -0.35);
// Legs and stretcher.
for (const x of [-1.18, 1.18]) {
for (const z of [-0.48, 0.48]) {
box(craft, 0.16, 0.92, 0.16, 0x8b5237, x, 0.46, z);
}
}
box(craft, 2.45, 0.13, 0.14, 0x8b5237, 0, 0.32, 0);
// Main top plus stepped extension gives the table its original profile.
box(craft, 2.7, 0.19, 1.18, 0x39766a, 0, 1.02, 0);
box(craft, 0.42, 0.19, 0.84, 0x39766a, 1.55, 1.02, 0.17);
box(craft, 0.25, 0.19, 0.46, 0x39766a, 1.83, 1.02, 0.35);
box(craft, 2.82, 0.11, 0.18, 0xe6b34f, -0.03, 1.16, -0.45);
// Woven runner.
box(craft, 0.78, 0.035, 1.12, 0xe5c481, -0.72, 1.135, 0);
for (let i = 0; i < 5; i++) {
box(craft, 0.055, 0.04, 1.13, 0xb95240, -1.03 + i * 0.15, 1.16, 0);
}
// Hanging textile strips.
for (let i = 0; i < 4; i++) {
box(
craft,
0.12,
0.66,
0.035,
i % 2 ? 0xe1a23f : 0xb94e42,
-1.05 + i * 0.2,
0.67,
0.61
);
}
// Sun carving on the front apron.
box(craft, 0.78, 0.51, 0.08, 0x345f57, 0.55, 0.74, 0.61);
box(craft, 0.19, 0.19, 0.06, 0xf0bd50, 0.55, 0.74, 0.67);
for (let i = 0; i < 8; i++) {
const angle = (Math.PI * 2 * i) / 8;
box(
craft,
0.08,
0.15,
0.06,
0xf0bd50,
0.55 + Math.cos(angle) * 0.23,
0.74 + Math.sin(angle) * 0.23,
0.67,
{ rotation: { z: angle } }
);
}
// Miniature pots assembled from voxel pieces.
function miniPot(parent, x, z, color, scale = 1) {
box(parent, 0.34 * scale, 0.25 * scale, 0.34 * scale, color, x, 1.23 * scale, z);
box(parent, 0.23 * scale, 0.18 * scale, 0.23 * scale, color, x, 1.43 * scale, z);
box(parent, 0.29 * scale, 0.07 * scale, 0.29 * scale, 0xe1a45b, x, 1.54 * scale, z);
}
miniPot(craft, 0.92, -0.13, 0xb8543d, 0.9);
miniPot(craft, 1.35, 0.1, 0xe0a03c, 0.68);
miniPot(craft, 0.28, 0.19, 0x4b8477, 0.58);
// Tiny original bird sculpture.
box(craft, 0.42, 0.25, 0.22, 0x8d5134, 0.15, 1.31, -0.08);
box(craft, 0.23, 0.23, 0.2, 0x8d5134, 0.42, 1.46, -0.08);
box(craft, 0.15, 0.07, 0.08, 0xe0a642, 0.59, 1.46, -0.08);
box(craft, 0.32, 0.08, 0.12, 0xd87b43, 0.07, 1.49, -0.08);
// Small upright display blocks.
box(craft, 0.17, 0.5, 0.17, 0x6c4935, -1.18, 1.36, -0.29);
box(craft, 0.38, 0.28, 0.16, 0xcc6444, -1.18, 1.69, -0.29);
// ---------------------------------------------------------------------
// Trees and planters
// ---------------------------------------------------------------------
function buildTree(x, z, scale = 1, seedOffset = 0) {
const tree = group(world, x, 0, z);
tree.scale.setScalar(scale);
box(tree, 1.55, 0.5, 1.55, 0xb06f4d, 0, 0.24, 0);
box(tree, 1.25, 0.14, 1.25, 0x6d5940, 0, 0.54, 0);
box(tree, 0.31, 2.65, 0.31, 0x755039, 0, 1.72, 0);
const leafColors = [0x537b4e, 0x66894f, 0x789a52, 0x426d4b];
for (let i = 0; i < 22; i++) {
const angle = randomBetween(0, Math.PI * 2) + seedOffset;
const radius = randomBetween(0.3, 1.15);
const leaf = box(
tree,
randomBetween(0.48, 0.9),
randomBetween(0.45, 0.78),
randomBetween(0.48, 0.9),
leafColors[Math.floor(random() * leafColors.length)],
Math.cos(angle) * radius,
randomBetween(2.65, 4.05),
Math.sin(angle) * radius
);
leaf.rotation.y = randomBetween(-0.35, 0.35);
}
}
buildTree(-6.65, 4.7, 1.05, 0.4);
buildTree(6.55, 4.85, 1.1, 1.2);
buildTree(-6.7, -4.65, 0.92, 2.1);
buildTree(6.7, -4.7, 0.87, 2.8);
// Foreground planters frame the diorama.
for (const x of [-6.6, 6.6]) {
box(world, 1.15, 0.64, 1.15, 0xb6744e, x, 0.32, 7.45);
box(world, 0.9, 0.12, 0.9, 0x79553b, x, 0.68, 7.45);
box(world, 0.58, 0.65, 0.58, 0x527d4e, x, 1.0, 7.45);
box(world, 0.83, 0.62, 0.83, 0x688e50, x, 1.36, 7.45);
box(world, 0.54, 0.52, 0.54, 0x799c55, x + 0.12, 1.82, 7.38);
}
// ---------------------------------------------------------------------
// Voxel people
// ---------------------------------------------------------------------
function createPerson(options = {}) {
const {
shirt = 0xb65440,
pants = 0x384d53,
skin = 0xb87850,
hat = true,
skirt = false,
scale = 1
} = options;
const root = group(world);
root.scale.setScalar(scale);
box(root, 0.46, 0.65, 0.3, shirt, 0, 0.96, 0);
box(root, 0.33, 0.34, 0.31, skin, 0, 1.48, 0);
box(root, 0.12, 0.09, 0.09, 0x3a2a25, 0, 1.48, -0.18);
if (hat) {
box(root, 0.7, 0.08, 0.55, 0xd4b274, 0, 1.68, 0);
box(root, 0.38, 0.18, 0.35, 0xc39b5e, 0, 1.77, 0);
}
if (skirt) {
box(root, 0.64, 0.43, 0.43, shirt, 0, 0.57, 0);
}
const leftLeg = group(root, -0.13, 0.62, 0);
const rightLeg = group(root, 0.13, 0.62, 0);
box(leftLeg, 0.17, 0.54, 0.19, skirt ? skin : pants, 0, -0.26, 0);
box(rightLeg, 0.17, 0.54, 0.19, skirt ? skin : pants, 0, -0.26, 0);
const leftArm = group(root, -0.3, 1.17, 0);
const rightArm = group(root, 0.3, 1.17, 0);
box(leftArm, 0.14, 0.48, 0.17, shirt, 0, -0.22, 0);
box(rightArm, 0.14, 0.48, 0.17, shirt, 0, -0.22, 0);
box(leftArm, 0.14, 0.12, 0.17, skin, 0, -0.49, 0);
box(rightArm, 0.14, 0.12, 0.17, skin, 0, -0.49, 0);
return {
root,
leftLeg,
rightLeg,
leftArm,
rightArm,
baseScale: scale
};
}
const walkers = [];
function addWalker(options) {
const person = createPerson(options);
person.root.position.x = options.x;
person.root.position.z = options.min;
walkers.push({
...person,
x: options.x,
min: options.min,
max: options.max,
speed: options.speed,
phase: options.phase || 0,
direction: 1
});
}
// Walkers use the side lanes, leaving the central doorway approach clear.
addWalker({
x: -2.65,
min: -4.5,
max: 4.7,
speed: 0.34,
shirt: 0x497d78,
pants: 0x45404a,
skin: 0x9e603e,
phase: 0.4
});
addWalker({
x: 2.62,
min: 4.7,
max: -4.5,
speed: 0.29,
shirt: 0xc36246,
pants: 0x334c5a,
skin: 0xc18b62,
phase: 2.1
});
addWalker({
x: -5.4,
min: 5.8,
max: -1.9,
speed: 0.25,
shirt: 0xd8a544,
pants: 0x536248,
skin: 0x7e4d34,
skirt: true,
scale: 0.92,
phase: 1.2
});
addWalker({
x: 5.65,
min: -4.3,
max: 3.4,
speed: 0.32,
shirt: 0x586b8e,
pants: 0x7d4c39,
skin: 0xb97850,
hat: false,
scale: 1.04,
phase: 3.4
});
addWalker({
x: 3.35,
min: -3.9,
max: 2.9,
speed: 0.23,
shirt: 0x879b52,
pants: 0x3f5555,
skin: 0x945c3b,
hat: true,
scale: 0.87,
phase: 4.2
});
// Craft vendor behind the table.
const vendor = createPerson({
shirt: 0x7d3f4a,
pants: 0x395b55,
skin: 0x9f6444,
hat: false,
scale: 0.96
});
vendor.root.position.set(4.55, 0, -1.35);
vendor.root.rotation.y = Math.PI;
vendor.leftArm.rotation.x = -0.65;
vendor.rightArm.rotation.x = -0.75;
// Seated visitors under the canopy.
function createSeatedPerson(x, z, shirtColor, pantsColor, skinColor) {
const person = group(world, x, 0, z);
box(person, 0.45, 0.6, 0.3, shirtColor, 0, 1.0, 0);
box(person, 0.34, 0.34, 0.31, skinColor, 0, 1.48, 0);
box(person, 0.7, 0.08, 0.52, 0xd1aa6d, 0, 1.66, 0);
box(person, 0.38, 0.17, 0.34, 0xbe9258, 0, 1.74, 0);
box(person, 0.17, 0.17, 0.65, pantsColor, -0.13, 0.6, 0.31);
box(person, 0.17, 0.17, 0.65, pantsColor, 0.13, 0.6, 0.31);
box(person, 0.17, 0.48, 0.17, pantsColor, -0.13, 0.31, 0.56);
box(person, 0.17, 0.48, 0.17, pantsColor, 0.13, 0.31, 0.56);
}
createSeatedPerson(-5.0, 1.97, 0xb95649, 0x405967, 0xb77851);
createSeatedPerson(-4.2, 1.97, 0x527e78, 0x655044, 0x86513a);
// A small voxel dog.
const dog = group(world, -5.15, 0, 5.35);
box(dog, 0.52, 0.36, 0.82, 0xb77948, 0, 0.4, 0);
box(dog, 0.42, 0.4, 0.4, 0xb77948, 0, 0.55, 0.53);
box(dog, 0.3, 0.2, 0.18, 0x8f5839, 0, 0.54, 0.82);
box(dog, 0.12, 0.31, 0.14, 0x855138, -0.18, 0.76, 0.48);
box(dog, 0.12, 0.31, 0.14, 0x855138, 0.18, 0.76, 0.48);
box(dog, 0.13, 0.35, 0.13, 0x855138, -0.19, 0.18, -0.2);
box(dog, 0.13, 0.35, 0.13, 0x855138, 0.19, 0.18, -0.2);
// ---------------------------------------------------------------------
// Small lights and decorative details
// ---------------------------------------------------------------------
function lantern(x, z) {
const lamp = group(world, x, 0, z);
box(lamp, 0.11, 2.45, 0.11, 0x4d5146, 0, 1.22, 0);
box(lamp, 0.34, 0.08, 0.34, 0x4d5146, 0, 2.48, 0);
box(lamp, 0.29, 0.38, 0.29, 0xf1c66d, 0, 2.24, 0);
box(lamp, 0.38, 0.09, 0.38, 0x4d5146, 0, 1.99, 0);
}
lantern(-6.9, 2.9);
lantern(6.9, 2.9);
// String lights above the craft display only, clear of the central axis.
box(world, 3.25, 0.035, 0.035, 0x5f5544, 4.65, 3.35, -0.35);
const bulbColors = [0xf4c662, 0xd96b4d, 0x6e9b84];
for (let i = 0; i < 7; i++) {
box(
world,
0.1,
0.13,
0.1,
bulbColors[i % bulbColors.length],
3.25 + i * 0.46,
3.22 - Math.sin((i / 6) * Math.PI) * 0.16,
-0.35
);
}
// ---------------------------------------------------------------------
// Custom camera controls
// ---------------------------------------------------------------------
function updateCamera() {
const position = new THREE.Vector3().setFromSphericalCoords(
orbit.radius,
orbit.phi,
orbit.theta
);
camera.position.copy(position).add(orbit.target);
camera.lookAt(orbit.target);
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(14.5, 18.5 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
let pointerId = null;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.button === 2 || event.shiftKey;
previousX = event.clientX;
previousY = event.clientY;
pointerId = event.pointerId;
canvas.setPointerCapture(pointerId);
canvas.focus();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
const scale = 0.012 / orbit.zoom;
const right = new THREE.Vector3(
Math.cos(orbit.theta),
0,
-Math.sin(orbit.theta)
);
const forward = new THREE.Vector3(
-Math.sin(orbit.theta),
0,
-Math.cos(orbit.theta)
);
orbit.target.addScaledVector(right, -dx * scale);
orbit.target.addScaledVector(forward, dy * scale);
orbit.target.x = THREE.MathUtils.clamp(orbit.target.x, -5, 5);
orbit.target.z = THREE.MathUtils.clamp(orbit.target.z, -6, 6);
orbit.target.y = THREE.MathUtils.clamp(orbit.target.y, 0.8, 3.6);
} else {
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.55, 1.38);
}
updateCamera();
});
function stopDragging(event) {
dragging = false;
panning = false;
if (pointerId !== null && canvas.hasPointerCapture(pointerId)) {
canvas.releasePointerCapture(pointerId);
}
pointerId = null;
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.8
);
updateCamera();
},
{ passive: false }
);
document.querySelector("#zoomIn").addEventListener("click", () => {
orbit.zoom = THREE.MathUtils.clamp(orbit.zoom * 1.13, 0.72, 1.8);
updateCamera();
});
document.querySelector("#zoomOut").addEventListener("click", () => {
orbit.zoom = THREE.MathUtils.clamp(orbit.zoom / 1.13, 0.72, 1.8);
updateCamera();
});
document.querySelector("#reset").addEventListener("click", () => {
orbit.theta = home.theta;
orbit.phi = home.phi;
orbit.radius = home.radius;
orbit.zoom = home.zoom;
orbit.target.copy(home.target);
updateCamera();
});
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") orbit.theta += 0.08;
else if (key === "arrowright") orbit.theta -= 0.08;
else if (key === "arrowup") orbit.phi = Math.max(0.55, orbit.phi - 0.06);
else if (key === "arrowdown") orbit.phi = Math.min(1.38, orbit.phi + 0.06);
else if (key === "+" || key === "=") orbit.zoom = Math.min(1.8, orbit.zoom * 1.1);
else if (key === "-") orbit.zoom = Math.max(0.72, orbit.zoom / 1.1);
else if (key === "r") {
orbit.theta = home.theta;
orbit.phi = home.phi;
orbit.radius = home.radius;
orbit.zoom = home.zoom;
orbit.target.copy(home.target);
} else {
return;
}
updateCamera();
});
window.addEventListener("resize", resize);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
walkers.forEach((walker, index) => {
walker.phase += delta * walker.speed;
const cycle = walker.phase / (walker.max - walker.min);
const saw = cycle % 2;
const t = saw <= 1 ? saw : 2 - saw;
const z = THREE.MathUtils.lerp(walker.min, walker.max, t);
walker.direction = saw <= 1 ? 1 : -1;
walker.root.position.z = z;
walker.root.position.y = 0.035 + Math.abs(Math.sin(walker.phase * 7.5)) * 0.035;
walker.root.rotation.y = walker.direction > 0 ? 0 : Math.PI;
const stride = Math.sin(walker.phase * 7.5) * 0.58;
walker.leftLeg.rotation.x = stride;
walker.rightLeg.rotation.x = -stride;
walker.leftArm.rotation.x = -stride * 0.72;
walker.rightArm.rotation.x = stride * 0.72;
});
// Gentle canopy and foliage movement, kept deliberately subtle.
seating.children.forEach((child, index) => {
if (index >= 6) {
child.rotation.z = Math.sin(elapsed * 0.7 + index) * 0.002;
}
});
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
resize();
updateCamera();
renderer.render(scene, camera);
requestAnimationFrame(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
});
</script>
</body>
</html>
```