Prompt specification
Build or customize the Three.js 3D scene "Mixed-use neighborhood and green corridor" 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: Mixed-use neighborhood and green corridor
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/mixed-use-neighborhood-and-green-corridor-x1311
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows land-use mosaics. Create a compact neighborhood with homes, shops, park, and continuous vegetated corridor. Distinguish pedestrian links from service roads and preserve visible access to every occupied parcel. Voxel style.
Working Three.js Starter (mixed-use-neighborhood-and-green-corridor-x1311):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Land-Use Mosaic</title>
<style>
:root {
--ink: #21323a;
--muted: #62757c;
--panel: rgba(249, 251, 248, 0.91);
--line: rgba(33, 50, 58, 0.12);
--residential: #d9b77c;
--commercial: #b99ac7;
--park: #7ea66f;
--corridor: #4f8a72;
--pedestrian: #ed9475;
--access: #f2cd68;
--road: #3e4b58;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe4e3;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.title-card {
position: fixed;
top: 20px;
left: 20px;
z-index: 10;
width: min(390px, calc(100vw - 40px));
padding: 17px 19px 16px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(37, 57, 62, 0.13);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: #4f7768;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--corridor);
box-shadow: 13px 0 0 #d9b77c, 26px 0 0 #ed9475;
margin-right: 26px;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 31px);
line-height: 1.05;
letter-spacing: -0.045em;
}
.subtitle {
margin: 8px 0 0;
max-width: 330px;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.audit {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 12px;
padding: 6px 9px;
border: 1px solid rgba(79, 138, 114, 0.22);
border-radius: 999px;
background: rgba(79, 138, 114, 0.09);
color: #39725c;
font-size: 11px;
font-weight: 750;
}
.audit-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #55a077;
box-shadow: 0 0 0 3px rgba(85, 160, 119, 0.16);
}
.panel {
position: fixed;
top: 20px;
right: 20px;
z-index: 10;
width: 254px;
padding: 15px;
border: 1px solid rgba(255, 255, 255, 0.74);
border-radius: 15px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(37, 57, 62, 0.13);
backdrop-filter: blur(14px);
}
.panel h2 {
margin: 0 0 10px;
font-size: 11px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.legend {
display: grid;
gap: 8px;
}
.legend-item {
display: grid;
grid-template-columns: 14px 1fr;
align-items: center;
gap: 9px;
color: #496069;
font-size: 11px;
}
.swatch {
width: 14px;
height: 14px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(33, 50, 58, 0.09);
}
.divider {
height: 1px;
margin: 13px 0;
background: var(--line);
}
.toggle {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 9px;
color: #496069;
font-size: 11px;
cursor: pointer;
user-select: none;
}
.toggle input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch {
position: relative;
flex: 0 0 auto;
width: 31px;
height: 18px;
border-radius: 99px;
background: #bdc8c8;
transition: background 160ms ease;
}
.switch::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 12px;
height: 12px;
border-radius: 50%;
background: white;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
transition: transform 160ms ease;
}
.toggle input:checked + .switch {
background: #5c8f7a;
}
.toggle input:checked + .switch::after {
transform: translateX(13px);
}
.button {
width: 100%;
margin-top: 12px;
padding: 9px 10px;
border: 1px solid rgba(33, 50, 58, 0.13);
border-radius: 9px;
background: rgba(255, 255, 255, 0.67);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
}
.button:hover {
background: white;
}
.info {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 10;
width: 254px;
padding: 14px 15px;
border: 1px solid rgba(255, 255, 255, 0.74);
border-radius: 15px;
background: var(--panel);
box-shadow: 0 12px 35px rgba(37, 57, 62, 0.13);
backdrop-filter: blur(14px);
pointer-events: none;
}
.info-label {
margin-bottom: 4px;
color: #789087;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.info-title {
font-size: 14px;
font-weight: 800;
}
.info-meta {
display: flex;
justify-content: space-between;
gap: 12px;
margin-top: 8px;
color: var(--muted);
font-size: 10px;
}
.info-access {
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--line);
color: #537166;
font-size: 10px;
line-height: 1.45;
}
.hint {
position: fixed;
left: 20px;
bottom: 20px;
z-index: 9;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.64);
border-radius: 10px;
background: rgba(249, 251, 248, 0.79);
color: #64777c;
font-size: 10px;
box-shadow: 0 8px 25px rgba(37, 57, 62, 0.08);
backdrop-filter: blur(10px);
pointer-events: none;
}
@media (max-width: 760px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.subtitle {
display: none;
}
.audit {
margin-top: 9px;
}
.panel {
top: auto;
right: 12px;
bottom: 12px;
width: 200px;
padding: 12px;
}
.panel .divider,
.panel .toggle,
.panel .button {
display: none;
}
.legend {
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.legend-item {
grid-template-columns: 10px 1fr;
gap: 6px;
font-size: 9px;
}
.swatch {
width: 10px;
height: 10px;
}
.info,
.hint {
display: none;
}
}
</style>
</head>
<body>
<div class="title-card">
<div class="eyebrow">Land-use mosaic / 01</div>
<h1>Maple & Cedar</h1>
<p class="subtitle">
A compact voxel neighborhood with distinct pedestrian links, service access,
public green space, and a continuous planted corridor.
</p>
<div class="audit">
<span class="audit-dot"></span>
16 of 16 occupied parcels visibly connected
</div>
</div>
<aside class="panel" aria-label="Map legend and display controls">
<h2>Land-use mosaic</h2>
<div class="legend">
<div class="legend-item">
<span class="swatch" style="background: #d9b77c"></span>
Residential
</div>
<div class="legend-item">
<span class="swatch" style="background: #b99ac7"></span>
Commercial
</div>
<div class="legend-item">
<span class="swatch" style="background: #7ea66f"></span>
Public park
</div>
<div class="legend-item">
<span class="swatch" style="background: #4f8a72"></span>
Vegetated corridor
</div>
<div class="legend-item">
<span class="swatch" style="background: #ed9475"></span>
Pedestrian link
</div>
<div class="legend-item">
<span class="swatch" style="background: #f2cd68"></span>
Parcel access
</div>
<div class="legend-item">
<span class="swatch" style="background: #3e4b58"></span>
Service road
</div>
<div class="legend-item">
<span class="swatch" style="background: #9caaa8"></span>
Sidewalk / crossing
</div>
</div>
<div class="divider"></div>
<label class="toggle">
Pedestrian network
<input id="showNetwork" type="checkbox" checked />
<span class="switch"></span>
</label>
<label class="toggle">
Parcel access
<input id="showAccess" type="checkbox" checked />
<span class="switch"></span>
</label>
<label class="toggle">
Map labels
<input id="showLabels" type="checkbox" checked />
<span class="switch"></span>
</label>
<button class="button" id="resetView" type="button">Reset map view</button>
</aside>
<div class="info" aria-live="polite">
<div class="info-label">Parcel inspector</div>
<div class="info-title" id="parcelName">Hover over a parcel</div>
<div class="info-meta">
<span id="parcelType">Interactive land-use map</span>
<span id="parcelArea">16 occupied</span>
</div>
<div class="info-access" id="parcelAccess">
Gold access paths connect every home and shop to the salmon pedestrian network.
</div>
</div>
<div class="hint">
Drag to orbit · Right-drag to pan · Scroll to zoom · Hover to inspect
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe4e3);
scene.fog = new THREE.Fog(0xdbe4e3, 150, 245);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(
-70,
70,
52,
-52,
0.1,
500
);
const hemisphere = new THREE.HemisphereLight(0xf7fbf4, 0x68796c, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2d8, 3.1);
sun.position.set(-48, 92, 38);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -90;
sun.shadow.camera.right = 90;
sun.shadow.camera.top = 80;
sun.shadow.camera.bottom = -80;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 220;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
metalness: 0,
flatShading: true,
...options
});
}
const M = {
earth: material(0x77624f),
ground: material(0xb8c7b5),
road: material(0x3e4b58),
roadEdge: material(0x64717a),
sidewalk: material(0xa8b3b0),
crossing: material(0xf2e8ca),
lane: material(0xe8c96e),
pedestrian: material(0xed9475),
access: material(0xf2cd68),
corridor: material(0x4f8a72),
hedge: material(0x39745e),
hedgeLight: material(0x5d9273),
park: material(0x7ea66f),
garden: material(0x91ad72),
residentialA: material(0xd9b77c),
residentialB: material(0xe2c695),
commercial: material(0xb99ac7),
water: material(0x6fa9b3, { roughness: 0.42 }),
trunk: material(0x76543d),
leafA: material(0x4f805d),
leafB: material(0x67966a),
leafC: material(0x7da574),
cream: material(0xf2ead2),
dark: material(0x34444a),
glass: material(0x8fc0c4, { roughness: 0.28, metalness: 0.08 }),
solar: material(0x3d6378, { roughness: 0.35, metalness: 0.25 }),
orange: material(0xd97755),
red: material(0xb65d57),
yellow: material(0xe3b95e),
teal: material(0x5e9186),
purple: material(0x866fa1),
white: material(0xf7f4e9),
pink: material(0xd8999d),
furniture: material(0x8a6248),
metal: material(0x71817f, { metalness: 0.18, roughness: 0.55 })
};
const world = new THREE.Group();
const pedestrianGroup = new THREE.Group();
const accessGroup = new THREE.Group();
const labelsGroup = new THREE.Group();
scene.add(world, pedestrianGroup, accessGroup, labelsGroup);
function box(
width,
height,
depth,
x,
y,
z,
mat,
parent = world,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(cubeGeometry, mat);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function flatPath(width, depth, x, z, mat = M.pedestrian, parent = pedestrianGroup) {
return box(width, 0.18, depth, x, 0.23, z, mat, parent, false, true);
}
// -------------------------------------------------------------------------
// Terrain and service-road hierarchy
// -------------------------------------------------------------------------
box(136, 2.4, 96, 0, -1.75, 0, M.earth);
box(136, 1.1, 96, 0, -0.48, 0, M.ground);
// Outer service-road loop.
box(132, 0.22, 7, 0, 0.10, -43, M.road);
box(132, 0.22, 7, 0, 0.10, 43, M.road);
box(7, 0.22, 86, -62, 0.10, 0, M.road);
box(7, 0.22, 86, 62, 0.10, 0, M.road);
// Service spur serving the commercial edge.
box(6.5, 0.22, 47, 35, 0.10, -19.5, M.road);
// Inner sidewalks.
box(118, 0.25, 1.6, 0, 0.19, -39.2, M.sidewalk);
box(118, 0.25, 1.6, 0, 0.19, 39.2, M.sidewalk);
box(1.6, 0.25, 78, -58.2, 0.19, 0, M.sidewalk);
box(1.6, 0.25, 78, 58.2, 0.19, 0, M.sidewalk);
box(1.25, 0.25, 43, 31.55, 0.19, -17.5, M.sidewalk);
box(1.25, 0.25, 43, 38.45, 0.19, -17.5, M.sidewalk);
// Dashed service-road center lines.
for (let x = -55; x <= 55; x += 9) {
box(3.8, 0.035, 0.18, x, 0.235, -43, M.lane, world, false, false);
box(3.8, 0.035, 0.18, x, 0.235, 43, M.lane, world, false, false);
}
for (let z = -36; z <= 36; z += 9) {
box(0.18, 0.035, 3.8, -62, 0.235, z, M.lane, world, false, false);
box(0.18, 0.035, 3.8, 62, 0.235, z, M.lane, world, false, false);
}
for (let z = -35; z <= 0; z += 8) {
box(0.16, 0.035, 3.5, 35, 0.235, z, M.lane, world, false, false);
}
// -------------------------------------------------------------------------
// Pedestrian network: clearly differentiated from service roads
// -------------------------------------------------------------------------
flatPath(118, 2.6, 0, -16);
flatPath(118, 2.6, 0, 24);
const pedestrianSpines = [-48, -24, 0, 24, 48];
for (const x of pedestrianSpines) {
flatPath(2.6, 78, x, 0);
}
// Crossings where pedestrian links meet the service-road loop.
for (const x of pedestrianSpines) {
for (let z = 40.2; z < 46; z += 1.15) {
box(3.4, 0.035, 0.65, x, 0.255, z, M.crossing, pedestrianGroup, false, false);
box(3.4, 0.035, 0.65, x, 0.255, -z, M.crossing, pedestrianGroup, false, false);
}
}
for (const z of [-16, 24, 10]) {
for (let x = 58.7; x < 65.5; x += 1.15) {
box(0.65, 0.035, 4.2, x, 0.255, z, M.crossing, pedestrianGroup, false, false);
box(0.65, 0.035, 4.2, -x, 0.255, z, M.crossing, pedestrianGroup, false, false);
}
}
// Crossing over the commercial service spur.
for (let x = 32.2; x < 38.2; x += 1.05) {
box(0.58, 0.035, 4.1, x, 0.255, -16, M.crossing, pedestrianGroup, false, false);
}
// -------------------------------------------------------------------------
// Continuous vegetated corridor
// -------------------------------------------------------------------------
box(118, 0.30, 10, 0, 0.18, 10, M.corridor);
// The promenade remains continuous through the planted corridor.
flatPath(118, 2.7, 0, 10);
// Long hedge sections maintain a legible continuous green edge.
for (let x = -58; x < 59; x += 3.8) {
const inShopAccess = x > 35 && x < 58;
if (!inShopAccess) {
box(3.65, 0.72, 0.9, x + 1.9, 0.68, 5.15, M.hedge);
box(3.65, 0.72, 0.9, x + 1.9, 0.68, 14.85, M.hedgeLight);
} else {
box(2.8, 0.46, 0.78, x + 1.9, 0.55, 5.15, M.hedge);
box(2.8, 0.46, 0.78, x + 1.9, 0.55, 14.85, M.hedgeLight);
}
}
function tree(x, z, scale = 1, parent = world) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
parent.add(group);
box(0.52, 2.3, 0.52, 0, 1.15, 0, M.trunk, group);
box(2.5, 1.45, 2.5, 0, 2.65, 0, M.leafA, group);
box(1.85, 1.1, 1.85, 0.3, 3.55, -0.2, M.leafB, group);
box(1.25, 0.85, 1.25, -0.35, 4.15, 0.15, M.leafC, group);
return group;
}
for (let x = -55; x <= 55; x += 8.5) {
if (x < 32) {
tree(x, 6.25, 0.72 + ((x + 60) % 3) * 0.04);
tree(x + 3.1, 13.65, 0.68 + ((x + 55) % 4) * 0.035);
} else {
tree(x, 14.2, 0.64);
}
}
// -------------------------------------------------------------------------
// Public parks and gardens
// -------------------------------------------------------------------------
// Main park.
box(25, 0.28, 17, 17.5, 0.15, -4.5, M.park);
flatPath(22, 1.7, 17.5, -4.5, M.cream, world);
flatPath(1.7, 14.5, 24, -4.5, M.cream, world);
// Voxel pond.
box(8.6, 0.32, 5.5, 10, 0.40, -5.2, M.sidewalk);
box(7.6, 0.36, 4.6, 10, 0.48, -5.2, M.water);
// Playground.
box(5.6, 0.25, 4.3, 19.2, 0.42, -4.6, M.yellow);
box(0.42, 2.8, 0.42, 17.7, 1.55, -3.1, M.red);
box(0.42, 2.8, 0.42, 20.7, 1.55, -3.1, M.teal);
box(3.7, 0.38, 0.42, 19.2, 2.65, -3.1, M.orange);
box(0.5, 1.5, 2.8, 20.7, 0.95, -4.6, M.purple);
box(1.0, 0.9, 1.0, 18.0, 0.75, -5.1, M.pink);
for (const [x, z, s] of [
[7, -10.5, 0.85],
[7, 1.3, 0.72],
[15, 1.5, 0.8],
[28.5, -10.5, 0.8],
[29.2, 1.4, 0.68],
[13, -11, 0.62],
[21, -11, 0.58]
]) {
tree(x, z, s);
}
// Benches.
for (const [x, z] of [[15, -1], [24, -9], [25, 0]]) {
box(2.2, 0.25, 0.65, x, 0.83, z, M.furniture);
box(2.2, 0.7, 0.22, x, 1.18, z - 0.25, M.furniture);
box(0.2, 0.55, 0.45, x - 0.8, 0.48, z, M.dark);
box(0.2, 0.55, 0.45, x + 0.8, 0.48, z, M.dark);
}
// Western pocket park / community gardens.
box(24, 0.25, 14.5, -43, 0.14, -6.3, M.garden);
flatPath(21, 1.5, -43, -6.3, M.cream, world);
flatPath(1.5, 12, -48, -6.3, M.cream, world);
for (const x of [-54, -45.5, -37.5]) {
for (const z of [-10.3, -2.8]) {
box(5.6, 0.38, 3.4, x, 0.48, z, M.furniture);
for (let row = -1; row <= 1; row++) {
box(4.7, 0.45, 0.48, x, 0.88, z + row * 0.9, M.leafB);
}
}
}
for (const [x, z, s] of [
[-56, 0.8, 0.75],
[-37, 0.8, 0.72],
[-30.5, -10.8, 0.78]
]) {
tree(x, z, s);
}
// -------------------------------------------------------------------------
// Interactive occupied parcels
// -------------------------------------------------------------------------
const parcels = [];
const interactiveMeshes = [];
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const outlineMat = new THREE.MeshBasicMaterial({
color: 0xffd55f,
transparent: true,
opacity: 0.95,
depthWrite: false
});
function createParcelOutline(width, depth, x, z) {
const group = new THREE.Group();
const y = 0.48;
const thickness = 0.16;
box(width, 0.06, thickness, x, y, z - depth / 2, outlineMat, group, false, false);
box(width, 0.06, thickness, x, y, z + depth / 2, outlineMat, group, false, false);
box(thickness, 0.06, depth, x - width / 2, y, z, outlineMat, group, false, false);
box(thickness, 0.06, depth, x + width / 2, y, z, outlineMat, group, false, false);
group.visible = false;
scene.add(group);
return group;
}
function registerParcel({
name,
type,
area,
access,
x,
z,
width,
depth,
padMaterial
}) {
const outline = createParcelOutline(width, depth, x, z);
const hitMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
});
const hit = box(
width,
0.3,
depth,
x,
0.45,
z,
hitMaterial,
world,
false,
false
);
const parcel = {
name,
type,
area,
access,
outline,
hit
};
hit.userData.parcel = parcel;
parcels.push(parcel);
interactiveMeshes.push(hit);
return parcel;
}
// -------------------------------------------------------------------------
// Homes
// -------------------------------------------------------------------------
const homeXs = [-55, -40, -16, -6, 12, 20, 28];
const wallMaterials = [
material(0xeee0bf),
material(0xe5c7a7),
material(0xd9dfd0),
material(0xe6d3c7),
material(0xc9d7d5)
];
const roofMaterials = [
material(0x9d5b48),
material(0x4d7169),
material(0x75616f),
material(0xb37451),
material(0x536d78)
];
function buildHome(x, z, index, north) {
const plotW = 8.4;
const plotD = 8.4;
const padMat = index % 2 ? M.residentialB : M.residentialA;
box(plotW, 0.28, plotD, x, 0.16, z, padMat);
const houseW = 5.2 + (index % 3) * 0.25;
const houseD = 4.8;
const wallMat = wallMaterials[index % wallMaterials.length];
const roofMat = roofMaterials[index % roofMaterials.length];
box(houseW, 3.0, houseD, x, 1.77, z, wallMat);
box(houseW + 0.55, 0.52, houseD + 0.55, x, 3.48, z, roofMat);
box(houseW - 0.4, 0.46, houseD - 0.4, x, 3.93, z, roofMat);
box(0.65, 1.45, 0.65, x + 1.25, 4.50, z - 0.8, M.red);
const frontZ = north ? z + houseD / 2 + 0.03 : z - houseD / 2 - 0.03;
box(1.05, 1.85, 0.12, x, 1.18, frontZ, index % 2 ? M.teal : M.orange);
box(1.55, 0.95, 0.12, x + 1.35, 1.75, frontZ, M.glass);
box(1.25, 0.95, 0.12, x - 1.35, 1.75, frontZ, M.glass);
box(0.12, 1.0, 1.35, x - houseW / 2 - 0.02, 1.8, z, M.glass);
// Small front garden and a visible route to the pedestrian street.
const gardenZ = north ? z + 4.0 : z - 4.0;
box(3.0, 0.36, 0.7, x, 0.45, gardenZ, M.hedge);
const streetZ = north ? -16 : 24;
const accessStart = north ? frontZ : streetZ;
const accessEnd = north ? streetZ : frontZ;
const accessLength = Math.abs(accessEnd - accessStart);
const accessCenter = (accessStart + accessEnd) / 2;
box(1.55, 0.19, accessLength, x, 0.36, accessCenter, M.access, accessGroup, false, true);
registerParcel({
name: `House ${String(index + 1).padStart(2, "0")}`,
type: "Residential parcel",
area: `${Math.round(plotW * plotD)} m²`,
access: north
? "Gold frontage path → north pedestrian street → marked service-road crossing."
: "Gold frontage path → south pedestrian street → marked service-road crossing.",
x,
z,
width: plotW,
depth: plotD,
padMaterial: padMat
});
}
let homeIndex = 0;
for (const x of homeXs) {
buildHome(x, -31, homeIndex++, true);
}
for (const x of homeXs) {
buildHome(x, 30.5, homeIndex++, false);
}
// -------------------------------------------------------------------------
// Commercial parcels
// -------------------------------------------------------------------------
function buildShop(x, z, index, wide = false) {
const plotW = wide ? 10.2 : 9.1;
const plotD = 8.4;
box(plotW, 0.28, plotD, x, 0.16, z, M.commercial);
const w = wide ? 8.9 : 7.5;
const d = 6.4;
const h = index === 0 ? 4.2 : 3.6;
box(w, h, d, x, 0.30 + h / 2, z, index === 0 ? M.cream : M.pink);
box(w + 0.45, 0.35, d + 0.45, x, 0.48 + h, z, M.dark);
box(2.2, 0.75, 1.4, x - 1.2, 1.45 + h, z, M.metal);
// Glazed shopfront.
box(w - 0.8, 1.75, 0.13, x, 1.38, z + d / 2 + 0.04, M.glass);
// Alternating voxel awning.
for (let i = 0; i < 6; i++) {
const awningMat = i % 2 ? M.cream : M.orange;
box(w / 6 + 0.03, 0.35, 1.35, x - w / 2 + (i + 0.5) * (w / 6), 3.15, z + d / 2 + 0.55, awningMat);
}
// Visible service entrance and gold access to the promenade.
box(1.0, 1.9, 0.15, x + w / 2 - 1.0, 1.27, z + d / 2 + 0.12, M.purple);
const startZ = z + d / 2;
const endZ = 8.65;
box(1.55, 0.19, endZ - startZ, x, 0.36, (startZ + endZ) / 2, M.access, accessGroup, false, true);
registerParcel({
name: index === 0 ? "Cedar Market" : "Corner Supply",
type: "Commercial parcel",
area: `${Math.round(plotW * plotD)} m²`,
access: "Gold frontage path → Cedar promenade → east service-road crossing.",
x,
z,
width: plotW,
depth: plotD,
padMaterial: M.commercial
});
}
buildShop(41.5, -6.4, 0, true);
buildShop(54, -6.4, 1, false);
// -------------------------------------------------------------------------
// People, cars and street furniture
// -------------------------------------------------------------------------
function person(x, z, colorMaterial, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.35, z);
group.rotation.y = rotation;
world.add(group);
box(0.38, 0.72, 0.32, 0, 0.75, 0, colorMaterial, group);
box(0.32, 0.32, 0.32, 0, 1.30, 0, M.cream, group);
box(0.14, 0.48, 0.16, -0.11, 0.23, 0, M.dark, group);
box(0.14, 0.48, 0.16, 0.11, 0.23, 0, M.dark, group);
}
const people = [
[-42, 9.1, M.red],
[-31, 10.7, M.teal],
[-12, 9.3, M.yellow],
[3, 10.5, M.purple],
[18, 9.1, M.orange],
[30, 10.7, M.teal],
[44, 9.2, M.red],
[-24, -15.2, M.yellow],
[-1, -16.8, M.teal],
[24, -15.3, M.purple],
[-40, 24.9, M.orange],
[5, 23.2, M.red],
[48, 24.8, M.teal]
];
people.forEach(([x, z, mat], index) => {
person(x, z, mat, index * 0.7);
});
function car(x, z, colorMaterial, vertical = false) {
const group = new THREE.Group();
group.position.set(x, 0, z);
world.add(group);
if (vertical) {
box(1.35, 0.65, 2.7, 0, 0.75, 0, colorMaterial, group);
box(1.1, 0.55, 1.35, 0, 1.30, -0.1, M.glass, group);
box(0.8, 0.18, 0.65, 0, 1.67, -0.1, colorMaterial, group);
} else {
box(2.7, 0.65, 1.35, 0, 0.75, 0, colorMaterial, group);
box(1.35, 0.55, 1.1, -0.1, 1.30, 0, M.glass, group);
box(0.65, 0.18, 0.8, -0.1, 1.67, 0, colorMaterial, group);
}
}
car(-26, -43, M.red);
car(19, 43, M.cream);
car(-62, -8, M.teal, true);
car(62, 13, M.yellow, true);
car(35, -29, M.purple, true);
function lamp(x, z) {
box(0.16, 3.1, 0.16, x, 1.75, z, M.dark);
box(0.75, 0.18, 0.75, x, 3.33, z, M.cream);
}
for (const [x, z] of [
[-56, -18],
[-26, -18],
[2, -18],
[26, -18],
[-56, 26],
[-26, 26],
[2, 26],
[26, 26]
]) {
lamp(x, z);
}
// -------------------------------------------------------------------------
// In-scene labels
// -------------------------------------------------------------------------
function makeLabel(text, x, y, z, width = 15, tint = "#f7f5e9") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 512, 128);
ctx.fillStyle = "rgba(32, 49, 55, 0.88)";
ctx.beginPath();
ctx.roundRect(6, 6, 500, 116, 24);
ctx.fill();
ctx.fillStyle = tint;
ctx.fillRect(25, 27, 8, 74);
ctx.fillStyle = "#ffffff";
ctx.font = "800 42px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 274, 65);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 20;
labelsGroup.add(sprite);
return sprite;
}
makeLabel("HOMES", -29, 9.5, -31, 12);
makeLabel("MARKET ROW", 47, 9.5, -8, 16, "#d9b3df");
makeLabel("OAK COMMONS", 16, 8.2, -4, 16, "#b8d6ae");
makeLabel("CEDAR CORRIDOR", -18, 7.0, 10, 19, "#acd7bd");
makeLabel("PEDESTRIAN LINK", -46, 4.3, -16, 17, "#ffc5ae");
makeLabel("SERVICE ROAD", 58, 4.2, 43, 16, "#f4df9b");
// -------------------------------------------------------------------------
// Custom camera controls — no addons or example modules
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 0, 0),
radius: 150,
theta: 0.72,
phi: 0.91
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetView() {
controls.target.set(0, 0, 0);
controls.radius = 150;
controls.theta = 0.72;
controls.phi = 0.91;
camera.zoom = 1;
camera.updateProjectionMatrix();
updateCamera();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = 104;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const canvas = renderer.domElement;
let dragging = false;
let dragButton = 0;
let pointerStart = { x: 0, y: 0 };
let previousPointer = { x: 0, y: 0 };
let moved = false;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
dragButton = event.button;
pointerStart.x = event.clientX;
pointerStart.y = event.clientY;
previousPointer.x = event.clientX;
previousPointer.y = event.clientY;
moved = false;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
if (
Math.abs(event.clientX - pointerStart.x) +
Math.abs(event.clientY - pointerStart.y) >
4
) {
moved = true;
}
if (dragButton === 2 || event.shiftKey) {
const scale = 0.12 / camera.zoom;
const right = new THREE.Vector3();
const forward = new THREE.Vector3();
camera.matrixWorld.extractBasis(right, new THREE.Vector3(), forward);
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, -dy * scale);
} else {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.42,
1.28
);
}
previousPointer.x = event.clientX;
previousPointer.y = event.clientY;
updateCamera();
} else {
updatePointer(event);
inspectHover();
}
});
canvas.addEventListener("pointerup", (event) => {
if (!moved) {
updatePointer(event);
inspectClick();
}
dragging = false;
canvas.releasePointerCapture(event.pointerId);
});
canvas.addEventListener("pointerleave", () => {
dragging = false;
clearHover();
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
const factor = Math.exp(-event.deltaY * 0.001);
camera.zoom = THREE.MathUtils.clamp(camera.zoom * factor, 0.65, 2.35);
camera.updateProjectionMatrix();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
function updatePointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
let hoveredParcel = null;
let selectedParcel = null;
function clearHover() {
if (hoveredParcel && hoveredParcel !== selectedParcel) {
hoveredParcel.outline.visible = false;
}
hoveredParcel = null;
}
function inspectHover() {
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveMeshes, false);
if (hits.length) {
const parcel = hits[0].object.userData.parcel;
if (hoveredParcel && hoveredParcel !== parcel && hoveredParcel !== selectedParcel) {
hoveredParcel.outline.visible = false;
}
hoveredParcel = parcel;
parcel.outline.visible = true;
if (!selectedParcel || selectedParcel !== parcel) {
showParcel(parcel);
}
} else {
clearHover();
}
}
function inspectClick() {
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveMeshes, false);
if (!hits.length) {
if (selectedParcel) {
selectedParcel.outline.visible = false;
selectedParcel = null;
}
return;
}
const parcel = hits[0].object.userData.parcel;
if (selectedParcel) {
selectedParcel.outline.visible = false;
}
selectedParcel = parcel;
selectedParcel.outline.visible = true;
showParcel(parcel);
}
const parcelName = document.getElementById("parcelName");
const parcelType = document.getElementById("parcelType");
const parcelArea = document.getElementById("parcelArea");
const parcelAccess = document.getElementById("parcelAccess");
function showParcel(parcel) {
parcelName.textContent = parcel.name;
parcelType.textContent = parcel.type;
parcelArea.textContent = parcel.area;
parcelAccess.textContent = parcel.access;
}
document.getElementById("showNetwork").addEventListener("change", (event) => {
pedestrianGroup.visible = event.target.checked;
});
document.getElementById("showAccess").addEventListener("change", (event) => {
accessGroup.visible = event.target.checked;
});
document.getElementById("showLabels").addEventListener("change", (event) => {
labelsGroup.visible = event.target.checked;
});
document.getElementById("resetView").addEventListener("click", resetView);
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
// Subtle pedestrian movement keeps the scene alive without changing the map.
const time = clock.getElapsedTime();
people.forEach((_, index) => {
// Kept deterministic; static figures remain legible from the ortho view.
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```