Prompt specification
Build or customize the Three.js 3D scene "French Market colonnade and stall canopy" 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: French Market colonnade and stall canopy
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/french-market-colonnade-and-stall-canopy-x2765
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing the French Market in New Orleans. Build a referenced market colonnade fragment with one canopy and counter. Keep the covered trading area distinct from the adjacent open pedestrian passage. Voxel style.
Working Three.js Starter (french-market-colonnade-and-stall-canopy-x2765):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>French Market — New Orleans</title>
<style>
:root {
--ink: #203e39;
--paper: #f5eddc;
--roof: #326c60;
--terracotta: #bc7953;
--stone: #d8d4c7;
--gold: #d2a247;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e1d3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: absolute;
z-index: 5;
top: 24px;
left: 24px;
max-width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid rgba(32, 62, 57, 0.17);
border-radius: 3px;
background: rgba(248, 242, 228, 0.93);
box-shadow: 0 12px 35px rgba(65, 52, 38, 0.12);
backdrop-filter: blur(8px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--terracotta);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 0;
color: rgba(32, 62, 57, 0.72);
font-size: 12px;
line-height: 1.45;
}
.title-card::after {
content: "";
display: block;
width: 46px;
height: 3px;
margin-top: 14px;
background: var(--gold);
}
.controls {
position: absolute;
z-index: 6;
top: 24px;
right: 24px;
display: flex;
gap: 7px;
}
.controls button {
display: grid;
place-items: center;
width: 40px;
height: 40px;
padding: 0;
border: 1px solid rgba(32, 62, 57, 0.2);
border-radius: 3px;
background: rgba(248, 242, 228, 0.93);
color: var(--ink);
box-shadow: 0 7px 20px rgba(65, 52, 38, 0.1);
font: 700 18px/1 system-ui, sans-serif;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
.controls button:hover {
transform: translateY(-2px);
background: #fffaf0;
}
.controls button:active {
transform: translateY(0);
}
.legend {
position: absolute;
z-index: 5;
bottom: 24px;
left: 24px;
display: grid;
gap: 9px;
padding: 13px 15px;
border: 1px solid rgba(32, 62, 57, 0.15);
border-radius: 3px;
background: rgba(248, 242, 228, 0.9);
box-shadow: 0 8px 25px rgba(65, 52, 38, 0.09);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.02em;
pointer-events: none;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 17px;
height: 17px;
border: 1px solid rgba(32, 62, 57, 0.18);
box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.13);
}
.swatch.covered {
background: var(--roof);
}
.swatch.passage {
background: var(--stone);
}
.hint {
position: absolute;
z-index: 5;
right: 24px;
bottom: 24px;
padding: 10px 13px;
border: 1px solid rgba(32, 62, 57, 0.13);
border-radius: 3px;
background: rgba(248, 242, 228, 0.86);
color: rgba(32, 62, 57, 0.76);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.035em;
pointer-events: none;
}
#loading {
position: absolute;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #e8e1d3;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
font-size: 18px;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 16px;
}
.controls {
top: 14px;
right: 14px;
}
.controls button {
width: 36px;
height: 36px;
}
.legend {
bottom: 14px;
left: 14px;
}
.hint {
display: none;
}
.subtitle {
max-width: 260px;
}
}
</style>
</head>
<body>
<main id="app">
<section class="title-card" aria-label="Scene description">
<div class="eyebrow">New Orleans · Voxel Architecture Study</div>
<h1>French Market</h1>
<p class="subtitle">
A referenced cast-iron colonnade fragment with one continuous market
canopy, one produce counter, and a clearly separate open pedestrian passage.
</p>
</section>
<nav class="controls" aria-label="Camera controls">
<button id="zoom-out" type="button" aria-label="Zoom out" title="Zoom out">−</button>
<button id="zoom-in" type="button" aria-label="Zoom in" title="Zoom in">+</button>
<button id="reset" type="button" aria-label="Reset camera" title="Reset camera">↺</button>
</nav>
<aside class="legend" aria-label="Scene legend">
<div class="legend-row">
<span class="swatch covered"></span>
Covered trading colonnade
</div>
<div class="legend-row">
<span class="swatch passage"></span>
Adjacent open pedestrian passage
</div>
</aside>
<div class="hint">DRAG TO ORBIT · SHIFT-DRAG TO PAN · SCROLL TO ZOOM</div>
<div id="loading">Building the French Market…</div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and orthographic camera
// -------------------------------------------------------------------------
const app = document.getElementById("app");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e1d3);
scene.fog = new THREE.Fog(0xe8e1d3, 24, 48);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel model of the French Market in New Orleans"
);
renderer.domElement.tabIndex = 0;
app.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const controlState = {
theta: 0.55,
phi: 1.10,
zoom: 1,
target: new THREE.Vector3(0, 1.55, 0)
};
const defaultState = {
theta: 0.55,
phi: 1.10,
zoom: 1,
target: new THREE.Vector3(0, 1.55, 0)
};
function updateCamera() {
const radius = 19;
const sinPhi = Math.sin(controlState.phi);
camera.position.set(
controlState.target.x + radius * sinPhi * Math.sin(controlState.theta),
controlState.target.y + radius * Math.cos(controlState.phi),
controlState.target.z + radius * sinPhi * Math.cos(controlState.theta)
);
camera.lookAt(controlState.target);
camera.updateMatrixWorld();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(11.5, 16.8 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = controlState.zoom;
camera.updateProjectionMatrix();
updateCamera();
}
window.addEventListener("resize", resize);
resize();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xfff5dc, 0x777c72, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d2, 3.5);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fc8c3, 0.75);
fill.position.set(9, 6, -7);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.84,
metalness: options.metalness ?? 0,
flatShading: true,
...options
});
}
const mat = {
ground: material(0xe8e1d3),
base: material(0xb8a68c),
baseEdge: material(0xefe5d1),
iron: material(0x24584f, { metalness: 0.16, roughness: 0.66 }),
ironLight: material(0x3f786a, { metalness: 0.12, roughness: 0.7 }),
ironDark: material(0x173f39, { metalness: 0.18, roughness: 0.65 }),
roof: material(0x326c60, { metalness: 0.18, roughness: 0.6 }),
roofAlt: material(0x3d796c, { metalness: 0.16, roughness: 0.62 }),
roofDark: material(0x25554e, { metalness: 0.18, roughness: 0.62 }),
cream: material(0xeee0be),
sign: material(0x214e46),
gold: material(0xd3a347, { metalness: 0.12, roughness: 0.62 }),
brick: material(0xb96d52),
brickDark: material(0x9e5744),
wood: material(0xa36e42),
woodDark: material(0x694832),
counter: material(0x2c7064),
counterPanel: material(0x3b8274),
stone: material(0xd8d4c7),
stoneAlt: material(0xcec9ba),
stoneDark: material(0xa9a397),
curb: material(0xe8dfcd),
terracotta: material(0xc68b5b),
terracottaAlt: material(0xd29a68),
terracottaDark: material(0xb7784f),
leaf: material(0x4e7950),
leafLight: material(0x73935e),
leafDark: material(0x345d3e),
glass: material(0x8cb5af, { metalness: 0.08, roughness: 0.35 }),
skin: material(0xc99068),
skinDark: material(0x996347),
hair: material(0x3a302a),
white: material(0xf3ead6),
black: material(0x29312f),
red: material(0xc44f3f),
orange: material(0xe39a3f),
green: material(0x6f963e),
purple: material(0x73506d)
};
function box(
width,
height,
depth,
x,
y,
z,
surface,
parent = scene,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
surface
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function makeTextTexture(
text,
color = "#f4ead4",
background = null,
subtitle = ""
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
if (background) {
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
}
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = color;
let fontSize = subtitle ? 82 : 92;
context.font = `700 ${fontSize}px Georgia, serif`;
const maximumWidth = 930;
const measuredWidth = context.measureText(text).width;
if (measuredWidth > maximumWidth) {
fontSize *= maximumWidth / measuredWidth;
context.font = `700 ${fontSize}px Georgia, serif`;
}
context.fillText(text, 512, subtitle ? 91 : 132);
if (subtitle) {
context.font = "700 31px Arial, sans-serif";
context.letterSpacing = "5px";
context.fillText(subtitle, 512, 181);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function addTextPlane(
text,
width,
height,
position,
options = {}
) {
const texture = makeTextTexture(
text,
options.color ?? "#f4ead4",
options.background ?? null,
options.subtitle ?? ""
);
const surface = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide,
toneMapped: false
});
const plane = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
surface
);
plane.position.set(position.x, position.y, position.z);
scene.add(plane);
return plane;
}
function addFloorLabel(text, x, z, width, color) {
const label = addTextPlane(text, width, width / 4, {
x,
y: 0.146,
z
}, { color });
label.rotation.x = -Math.PI / 2;
label.material.polygonOffset = true;
label.material.polygonOffsetFactor = -1;
return label;
}
// -------------------------------------------------------------------------
// Site base and distinct floor zones
// -------------------------------------------------------------------------
box(80, 0.12, 80, 0, -0.72, 0, mat.ground, scene, false, true);
box(15.8, 0.46, 10.2, 0, -0.4, 0, mat.base);
box(15.95, 0.12, 10.35, 0, -0.12, 0, mat.baseEdge);
// Warm terracotta floor: covered trading area.
box(9.35, 0.16, 7.05, -1.9, 0, 0, mat.terracottaDark);
const coveredFloorMaterials = [
mat.terracotta,
mat.terracottaAlt,
mat.terracotta
];
for (let ix = 0; ix < 7; ix++) {
for (let iz = 0; iz < 6; iz++) {
const x = -6.04 + ix * 1.22;
const z = -2.67 + iz * 1.06;
const tileMaterial =
coveredFloorMaterials[(ix + iz * 2) % coveredFloorMaterials.length];
box(
1.16,
0.035,
1.0,
x,
0.105,
z,
tileMaterial,
scene,
false,
true
);
}
}
// Cool stone floor: uncovered pedestrian passage.
box(4.35, 0.15, 7.75, 4.92, 0, 0, mat.stoneDark);
for (let ix = 0; ix < 4; ix++) {
for (let iz = 0; iz < 8; iz++) {
const tileMaterial = (ix + iz) % 3 === 0 ? mat.stoneAlt : mat.stone;
box(
0.95,
0.04,
0.88,
3.4 + ix * 1.02,
0.105,
-3.43 + iz * 0.97,
tileMaterial,
scene,
false,
true
);
}
}
// A continuous curb and bollards make the passage boundary legible.
box(0.18, 0.18, 7.8, 2.77, 0.06, 0, mat.curb);
box(9.55, 0.13, 0.18, -1.82, 0.04, -3.67, mat.curb);
box(4.55, 0.13, 0.18, 4.9, 0.04, 3.9, mat.curb);
for (const z of [-2.45, 0, 2.45]) {
box(0.17, 0.65, 0.17, 2.94, 0.43, z, mat.ironDark);
box(0.24, 0.09, 0.24, 2.94, 0.79, z, mat.gold);
}
addFloorLabel("COVERED MARKET", -0.55, -1.65, 3.7, "#70442f");
addFloorLabel("OPEN PASSAGE", 4.85, -2.68, 3.0, "#52615d");
// -------------------------------------------------------------------------
// Cast-iron colonnade: masonry fragments, columns, capitals, and arches
// -------------------------------------------------------------------------
const columnX = [-6.15, -3.1, -0.05, 2.45];
const columnZ = [-3.0, 0, 3.0];
// Low masonry fragments at the rear evoke the market's brick-and-iron fabric.
for (let bay = 0; bay < columnX.length - 1; bay++) {
const centerX = (columnX[bay] + columnX[bay + 1]) / 2;
box(
2.7,
0.72,
0.2,
centerX,
0.49,
-3.01,
bay % 2 === 0 ? mat.brick : mat.brickDark
);
box(2.78, 0.12, 0.3, centerX, 0.91, -3.01, mat.cream);
}
for (const x of columnX) {
for (const z of columnZ) {
box(0.53, 0.27, 0.53, x, 0.28, z, mat.ironDark);
box(0.25, 3.55, 0.25, x, 2.02, z, mat.iron);
box(0.42, 0.13, 0.42, x, 0.47, z, mat.ironLight);
box(0.48, 0.23, 0.48, x, 3.9, z, mat.ironLight);
box(0.57, 0.12, 0.57, x, 4.05, z, mat.ironDark);
}
}
// Voxelized semicircular arches on the front and rear elevations.
function makeArchBetween(x1, x2, z, depth = 0.18) {
const center = (x1 + x2) / 2;
const radius = (x2 - x1) / 2 - 0.19;
const springHeight = 2.55;
const segments = 11;
for (let i = 0; i <= segments; i++) {
const angle = (i / segments) * Math.PI;
const x = center + Math.cos(angle) * radius;
const y = springHeight + Math.sin(angle) * radius;
const block = box(
0.38,
0.22,
depth,
x,
y,
z,
i % 2 === 0 ? mat.ironLight : mat.iron
);
block.rotation.z = angle - Math.PI / 2;
}
}
for (const z of [-3.03, 3.03]) {
for (let i = 0; i < columnX.length - 1; i++) {
makeArchBetween(columnX[i], columnX[i + 1], z);
}
}
// A matching side elevation marks the edge of the covered floor.
function makeSideArchBetween(z1, z2, x) {
const center = (z1 + z2) / 2;
const radius = (z2 - z1) / 2 - 0.19;
const springHeight = 2.55;
const segments = 11;
for (let i = 0; i <= segments; i++) {
const angle = (i / segments) * Math.PI;
const z = center + Math.cos(angle) * radius;
const y = springHeight + Math.sin(angle) * radius;
const block = box(
0.18,
0.22,
0.38,
x,
y,
z,
i % 2 === 0 ? mat.ironLight : mat.iron
);
block.rotation.x = -angle - Math.PI / 2;
}
}
for (let i = 0; i < columnZ.length - 1; i++) {
makeSideArchBetween(columnZ[i], columnZ[i + 1], 2.48);
}
// Structural beams.
for (const z of columnZ) {
box(9.25, 0.2, 0.25, -1.85, 4.15, z, mat.ironDark);
}
for (const x of columnX) {
box(0.25, 0.2, 6.5, x, 4.15, 0, mat.ironDark);
}
// -------------------------------------------------------------------------
// One continuous, stepped metal market canopy
// -------------------------------------------------------------------------
const roofCenterX = -1.92;
const roofLength = 9.85;
for (let i = 0; i < 9; i++) {
const z = -3.2 + i * 0.8;
const normalizedDistance = Math.abs(z) / 3.2;
const y = 4.16 + (1 - normalizedDistance) * 1.25;
box(
roofLength,
0.26,
0.9,
roofCenterX,
y,
z,
i % 2 === 0 ? mat.roof : mat.roofAlt
);
}
// Ridge, eaves, and a raised ventilating monitor.
box(10.03, 0.25, 0.52, roofCenterX, 5.49, 0, mat.roofDark);
box(10.02, 0.19, 0.17, roofCenterX, 4.08, 3.25, mat.roofDark);
box(10.02, 0.19, 0.17, roofCenterX, 4.08, -3.25, mat.roofDark);
for (const x of [-5.6, -3.55, -1.5, 0.55]) {
box(1.22, 0.18, 0.58, x, 5.61, 0, mat.ironDark);
box(1.04, 0.12, 0.46, x, 5.73, 0, mat.glass);
}
// French Market fascia sign.
box(6.75, 0.7, 0.15, -2.0, 4.02, 3.38, mat.sign);
box(6.95, 0.12, 0.22, -2.0, 3.64, 3.4, mat.gold);
for (const x of [-5.2, 1.2]) {
box(0.22, 0.42, 0.08, x, 4.02, 3.48, mat.gold);
}
addTextPlane(
"FRENCH MARKET",
5.95,
0.48,
{ x: -2.0, y: 4.04, z: 3.475 },
{ subtitle: "NEW ORLEANS" }
);
// -------------------------------------------------------------------------
// Exactly one trading counter, beneath the canopy
// -------------------------------------------------------------------------
box(3.4, 1.06, 1.08, -3.5, 0.67, 1.48, mat.counter);
box(3.18, 0.72, 0.055, -3.5, 0.69, 2.045, mat.counterPanel);
box(3.66, 0.17, 1.32, -3.5, 1.285, 1.48, mat.wood);
box(3.7, 0.08, 1.36, -3.5, 1.39, 1.48, mat.woodDark);
addTextPlane(
"FRESH PRODUCE",
2.58,
0.32,
{ x: -3.5, y: 0.71, z: 2.084 },
{ color: "#f1dfb8" }
);
// Three shallow produce trays on the single counter.
const trayXs = [-4.52, -3.5, -2.48];
const produceColors = [
mat.red,
mat.orange,
mat.green,
mat.purple,
mat.red
];
trayXs.forEach((trayX, trayIndex) => {
box(
0.83,
0.13,
0.7,
trayX,
1.49,
1.48,
mat.woodDark
);
for (let i = 0; i < 8; i++) {
const px = trayX - 0.28 + (i % 4) * 0.19;
const pz = 1.48 - 0.15 + Math.floor(i / 4) * 0.28;
const size = 0.14 + ((i + trayIndex) % 3) * 0.025;
box(
size,
size,
size,
px,
1.63,
pz,
produceColors[(i + trayIndex) % produceColors.length]
);
}
});
// -------------------------------------------------------------------------
// Voxel people
// -------------------------------------------------------------------------
function createPerson({
x,
z,
rotation = 0,
shirt = mat.terracottaDark,
pants = mat.ironDark,
skin = mat.skin,
hat = false,
scale = 1,
bag = false
}) {
const group = new THREE.Group();
group.position.set(x, 0.13, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
box(0.19, 0.56, 0.23, -0.15, 0.31, 0, pants, group);
box(0.19, 0.56, 0.23, 0.15, 0.31, 0, pants, group);
box(0.22, 0.11, 0.32, -0.15, 0.055, 0.04, mat.black, group);
box(0.22, 0.11, 0.32, 0.15, 0.055, 0.04, mat.black, group);
box(0.56, 0.62, 0.34, 0, 0.91, 0, shirt, group);
box(0.15, 0.52, 0.18, -0.37, 0.88, 0, shirt, group);
box(0.15, 0.52, 0.18, 0.37, 0.88, 0, shirt, group);
box(0.15, 0.14, 0.18, -0.37, 0.58, 0, skin, group);
box(0.15, 0.14, 0.18, 0.37, 0.58, 0, skin, group);
box(0.16, 0.14, 0.16, 0, 1.27, 0, skin, group);
box(0.35, 0.36, 0.34, 0, 1.49, 0, skin, group);
box(0.37, 0.11, 0.36, 0, 1.68, -0.01, mat.hair, group);
if (hat) {
box(0.46, 0.09, 0.44, 0, 1.74, 0, mat.cream, group);
box(0.34, 0.18, 0.32, 0, 1.84, 0, mat.cream, group);
}
if (bag) {
box(0.3, 0.34, 0.19, 0.48, 0.47, 0.03, mat.gold, group);
box(0.07, 0.3, 0.07, 0.48, 0.72, 0.03, mat.woodDark, group);
}
scene.add(group);
return group;
}
// Vendor behind the counter.
createPerson({
x: -3.48,
z: 0.43,
rotation: 0,
shirt: mat.white,
pants: mat.ironDark,
skin: mat.skinDark,
hat: true,
scale: 0.98
});
// Pedestrians occupy only the open passage.
createPerson({
x: 4.02,
z: -1.55,
rotation: 0.22,
shirt: mat.gold,
pants: mat.iron,
skin: mat.skinDark,
bag: true,
scale: 0.98
});
createPerson({
x: 5.24,
z: 1.12,
rotation: -0.35,
shirt: mat.brickDark,
pants: mat.cream,
skin: mat.skin,
hat: false,
scale: 1.04
});
createPerson({
x: 5.92,
z: -0.15,
rotation: 2.75,
shirt: mat.roofAlt,
pants: mat.ironDark,
skin: mat.skinDark,
hat: true,
scale: 0.9
});
// -------------------------------------------------------------------------
// Edge planting and small passage details
// -------------------------------------------------------------------------
function createPlanter(x, z, variant = 0) {
box(0.72, 0.5, 0.96, x, 0.39, z, mat.brickDark);
box(0.8, 0.1, 1.04, x, 0.67, z, mat.brick);
box(0.12, 0.44, 0.12, x, 0.91, z, mat.woodDark);
box(
0.43,
0.4,
0.46,
x - 0.08,
1.18,
z + 0.08,
variant === 0 ? mat.leaf : mat.leafDark
);
box(
0.33,
0.35,
0.35,
x + 0.22,
1.11,
z - 0.17,
mat.leafLight
);
box(
0.28,
0.31,
0.3,
x - 0.21,
1.48,
z - 0.14,
mat.leaf
);
}
createPlanter(6.85, -2.72, 0);
createPlanter(6.85, 2.62, 1);
// A low wall closes the outer edge while preserving an open-air walkway.
box(0.2, 0.68, 8.0, 7.22, 0.47, 0, mat.brick);
box(0.3, 0.12, 8.1, 7.22, 0.87, 0, mat.cream);
// Small square paving accents in the passage.
for (const z of [-3.1, -1.05, 1.05, 3.1]) {
box(0.13, 0.055, 0.56, 3.05, 0.15, z, mat.stoneDark, scene, false, true);
}
// -------------------------------------------------------------------------
// Custom camera controls implemented without external examples or addons
// -------------------------------------------------------------------------
const pointers = new Map();
let dragPrevious = null;
let pinchStart = null;
const canvas = renderer.domElement;
function clamp(value, minimum, maximum) {
return Math.max(minimum, Math.min(maximum, value));
}
function panCamera(deltaX, deltaY) {
const worldPerPixel =
(camera.top - camera.bottom) / camera.zoom / window.innerHeight;
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrix, 0)
.setY(0)
.normalize();
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
controlState.target.addScaledVector(right, -deltaX * worldPerPixel);
controlState.target.addScaledVector(forward, -deltaY * worldPerPixel);
controlState.target.x = clamp(controlState.target.x, -3.5, 3.5);
controlState.target.z = clamp(controlState.target.z, -3.5, 3.5);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragPrevious = {
x: event.clientX,
y: event.clientY,
shift: event.shiftKey
};
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchStart = {
distance: Math.hypot(a.x - b.x, a.y - b.y),
zoom: controlState.zoom
};
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2 && pinchStart) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
controlState.zoom = clamp(
pinchStart.zoom * (distance / pinchStart.distance),
0.68,
1.65
);
updateCamera();
return;
}
if (!dragPrevious) return;
const deltaX = event.clientX - dragPrevious.x;
const deltaY = event.clientY - dragPrevious.y;
if (event.shiftKey || dragPrevious.shift) {
panCamera(deltaX, deltaY);
} else {
controlState.theta -= deltaX * 0.006;
controlState.phi = clamp(
controlState.phi + deltaY * 0.0045,
0.62,
1.35
);
}
dragPrevious = {
x: event.clientX,
y: event.clientY,
shift: event.shiftKey
};
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
dragPrevious = null;
pinchStart = null;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controlState.zoom = clamp(
controlState.zoom * (event.deltaY > 0 ? 0.9 : 1.1),
0.68,
1.65
);
updateCamera();
},
{ passive: false }
);
document.getElementById("zoom-in").addEventListener("click", () => {
controlState.zoom = clamp(controlState.zoom * 1.12, 0.68, 1.65);
updateCamera();
});
document.getElementById("zoom-out").addEventListener("click", () => {
controlState.zoom = clamp(controlState.zoom * 0.89, 0.68, 1.65);
updateCamera();
});
document.getElementById("reset").addEventListener("click", () => {
controlState.theta = defaultState.theta;
controlState.phi = defaultState.phi;
controlState.zoom = defaultState.zoom;
controlState.target.copy(defaultState.target);
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
controlState.theta += 0.08;
} else if (event.key === "ArrowRight") {
controlState.theta -= 0.08;
} else if (event.key === "ArrowUp") {
controlState.phi = clamp(controlState.phi - 0.055, 0.62, 1.35);
} else if (event.key === "ArrowDown") {
controlState.phi = clamp(controlState.phi + 0.055, 0.62, 1.35);
} else if (event.key === "+" || event.key === "=") {
controlState.zoom = clamp(controlState.zoom * 1.1, 0.68, 1.65);
} else if (event.key === "-") {
controlState.zoom = clamp(controlState.zoom * 0.9, 0.68, 1.65);
} else if (event.key.toLowerCase() === "r") {
controlState.theta = defaultState.theta;
controlState.phi = defaultState.phi;
controlState.zoom = defaultState.zoom;
controlState.target.copy(defaultState.target);
} else {
return;
}
event.preventDefault();
updateCamera();
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
updateCamera();
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```