Prompt specification
Build or customize the Three.js 3D scene "Delivery Bay With Cart Turning Space" 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: Delivery Bay With Cart Turning Space
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/delivery-bay-with-cart-turning-space-x2157
Scene Description Prompt:
A stylized delivery bay separates van unloading, a cart's turning footprint, and the public sidewalk. Three.js from cdnjs in one HTML file.
Working Three.js Starter (delivery-bay-with-cart-turning-space-x2157):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bayside — Delivery Bay Study</title>
<style>
:root {
--ink: #163033;
--muted: #627679;
--paper: rgba(249, 251, 247, 0.88);
--line: rgba(22, 48, 51, 0.12);
--teal: #168b95;
--amber: #e7a62f;
--coral: #df6d55;
--green: #5f8d68;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce7e5;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
z-index: 10;
pointer-events: none;
}
.brand {
top: 24px;
left: 26px;
display: flex;
align-items: flex-start;
gap: 14px;
}
.brand-mark {
position: relative;
width: 38px;
height: 38px;
margin-top: 2px;
border-radius: 12px;
background: var(--ink);
box-shadow: 0 9px 24px rgba(22, 48, 51, 0.18);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
left: 9px;
width: 20px;
height: 3px;
border-radius: 2px;
background: #f5faf4;
}
.brand-mark::before {
top: 12px;
transform: rotate(28deg);
}
.brand-mark::after {
top: 23px;
width: 13px;
background: #69c8c9;
}
.eyebrow {
margin: 0 0 5px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(23px, 3vw, 38px);
font-weight: 780;
letter-spacing: -0.045em;
line-height: 1;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
#zone-card {
top: 24px;
right: 24px;
width: min(320px, calc(100vw - 48px));
padding: 19px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 20px;
background: var(--paper);
box-shadow:
0 18px 55px rgba(30, 55, 56, 0.12),
inset 0 1px 0 rgba(255, 255, 255, 0.8);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
}
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.zone-index {
display: inline-flex;
align-items: center;
justify-content: center;
width: 33px;
height: 33px;
border-radius: 10px;
color: white;
background: var(--teal);
font-size: 11px;
font-weight: 800;
transition: background 180ms ease;
}
.status {
display: flex;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.status::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #59a66a;
box-shadow: 0 0 0 4px rgba(89, 166, 106, 0.13);
}
#zone-card h2 {
margin: 16px 0 7px;
font-size: 21px;
letter-spacing: -0.035em;
}
#zone-copy {
min-height: 54px;
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.metrics {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 15px;
}
.metric {
padding: 6px 9px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 255, 255, 0.6);
color: var(--ink);
font-size: 10px;
font-weight: 700;
}
.legend {
left: 26px;
bottom: 25px;
display: flex;
gap: 7px;
padding: 7px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 16px;
background: var(--paper);
box-shadow: 0 12px 36px rgba(30, 55, 56, 0.1);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
white-space: nowrap;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--teal);
}
.swatch.amber {
background: var(--amber);
}
.swatch.concrete {
background: #9da9a6;
}
.help {
left: 50%;
bottom: 27px;
transform: translateX(-50%);
color: rgba(22, 48, 51, 0.68);
font-size: 10px;
font-weight: 650;
letter-spacing: 0.025em;
white-space: nowrap;
}
.help span {
margin: 0 6px;
opacity: 0.42;
}
#reset {
position: fixed;
right: 25px;
bottom: 25px;
z-index: 20;
display: inline-flex;
align-items: center;
gap: 8px;
padding: 11px 14px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 13px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 10px 30px rgba(30, 55, 56, 0.11);
backdrop-filter: blur(14px);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
cursor: pointer;
transition:
transform 150ms ease,
box-shadow 150ms ease;
}
#reset:hover {
transform: translateY(-2px);
box-shadow: 0 14px 36px rgba(30, 55, 56, 0.16);
}
#reset svg {
width: 14px;
height: 14px;
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: #dce7e5;
color: var(--ink);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.brand {
top: 18px;
left: 18px;
}
.brand-mark {
width: 32px;
height: 32px;
border-radius: 10px;
}
.brand-mark::before {
top: 9px;
left: 7px;
width: 18px;
}
.brand-mark::after {
top: 20px;
left: 7px;
}
.subtitle {
display: none;
}
#zone-card {
top: auto;
right: 16px;
bottom: 74px;
width: min(290px, calc(100vw - 32px));
padding: 15px;
}
#zone-copy {
min-height: 0;
}
.legend {
left: 16px;
bottom: 16px;
}
.legend-item {
padding: 5px 7px;
font-size: 9px;
}
.help {
display: none;
}
#reset {
right: 16px;
bottom: 16px;
}
}
@media (max-height: 640px) {
#zone-card {
padding: 13px;
}
#zone-copy {
display: none;
}
.metrics {
margin-top: 9px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<header class="ui brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Bayside / Spatial study 07</p>
<h1>Delivery bay</h1>
<p class="subtitle">Unloading, maneuvering, and public access in one shared edge.</p>
</div>
</header>
<section id="zone-card" class="ui" aria-live="polite">
<div class="card-top">
<div id="zone-index" class="zone-index">01</div>
<div class="status">Zone selected</div>
</div>
<h2 id="zone-title">Van unloading</h2>
<p id="zone-copy">
A dedicated teal apron keeps parcel transfer clear of the cart sweep and
the raised public walkway.
</p>
<div id="metrics" class="metrics">
<span class="metric">4.8 × 5.2 m</span>
<span class="metric">6 min dwell</span>
</div>
</section>
<nav class="ui legend" aria-label="Zone legend">
<div class="legend-item">
<span class="swatch"></span>
Unloading
</div>
<div class="legend-item">
<span class="swatch amber"></span>
Turning
</div>
<div class="legend-item">
<span class="swatch concrete"></span>
Public walk
</div>
</nav>
<div class="ui help">
Drag to orbit <span>•</span> Scroll to zoom <span>•</span> Click a zone
</div>
<button id="reset" type="button" aria-label="Reset camera">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path
d="M4 9a8 8 0 1 1 1.8 8.1M4 9V4m0 5h5"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Reset view
</button>
<div id="loading">Building the bay…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce7e5);
const renderer = new THREE.WebGLRenderer({
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;
viewport.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(
-15,
15,
10,
-10,
0.1,
120,
);
const cameraState = {
target: new THREE.Vector3(0, 0.9, 0),
radius: 33,
theta: 0.66,
phi: 0.86,
zoom: 1,
};
const defaultCamera = { ...cameraState };
function updateCamera() {
const offset = new THREE.Vector3().setFromSphericalCoords(
cameraState.radius,
cameraState.phi,
cameraState.theta,
);
camera.position.copy(cameraState.target).add(offset);
camera.lookAt(cameraState.target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = Math.max(10.5, 15.3 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
updateCamera();
resize();
const hemisphere = new THREE.HemisphereLight(0xf7fbf7, 0x738a8c, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff5df, 3.1);
sun.position.set(-12, 22, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const rim = new THREE.DirectionalLight(0xb8dce3, 1.2);
rim.position.set(16, 10, -18);
scene.add(rim);
const material = (color, roughness = 0.72, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
});
const palette = {
asphalt: material(0x536164, 0.96),
asphaltEdge: material(0x3e4d50, 0.96),
concrete: material(0xc7ceca, 0.92),
concreteDark: material(0x9da9a6, 0.9),
curb: material(0xe4e6df, 0.86),
wall: material(0xd9d8ce, 0.92),
wallDark: material(0xb8bbb3, 0.9),
roof: material(0x637275, 0.8),
teal: material(0x168b95, 0.58),
tealDark: material(0x0c626c, 0.6),
amber: material(0xe7a62f, 0.62),
coral: material(0xdf6d55, 0.65),
green: material(0x5f8d68, 0.9),
foliage: material(0x71966c, 0.95),
foliageLight: material(0x8aab79, 0.95),
wood: material(0x9c7650, 0.86),
tire: material(0x263034, 0.95),
tireHub: material(0xbec8c6, 0.42, 0.45),
glass: material(0x31545c, 0.23, 0.42),
white: material(0xf3f2e9, 0.62),
box: material(0xba8b57, 0.94),
boxLight: material(0xd3ae76, 0.94),
tape: material(0xe7d7af, 0.9),
};
function addBox(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
castShadow = true,
receiveShadow = true,
) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), mat);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function addCylinder(
radiusTop,
radiusBottom,
height,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
segments = 24,
castShadow = true,
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat,
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addPlane(
width,
depth,
mat,
x,
y,
z,
parent = scene,
receiveShadow = false,
) {
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, depth), mat);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, y, z);
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function addSphere(radius, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(new THREE.SphereGeometry(radius, 20, 14), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function dashedSegment(
start,
end,
mat,
dash = 0.42,
gap = 0.28,
width = 0.075,
height = 0.035,
parent = scene,
) {
const dx = end.x - start.x;
const dz = end.z - start.z;
const length = Math.hypot(dx, dz);
const count = Math.max(1, Math.floor(length / (dash + gap)));
const segmentLength = length / count;
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
const segment = addBox(
Math.min(dash, segmentLength * 0.92),
height,
width,
mat,
THREE.MathUtils.lerp(start.x, end.x, t),
start.y,
THREE.MathUtils.lerp(start.z, end.z, t),
parent,
false,
true,
);
segment.rotation.y = -Math.atan2(dz, dx);
}
}
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeFloorText(text, color, x, z, width = 3.8) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = color;
ctx.font = "800 86px Arial, sans-serif";
ctx.fillText(text, 512, 135);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy(),
);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, width * 0.25),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
opacity: 0.9,
}),
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(x, 0.095, z);
scene.add(mesh);
return mesh;
}
function makeSpriteLabel(text, accent, x, y, z, scale = 3.2) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 180;
const ctx = canvas.getContext("2d");
roundedRectPath(ctx, 8, 8, 624, 164, 32);
ctx.fillStyle = "rgba(249,251,247,0.94)";
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = "rgba(22,48,51,0.12)";
ctx.stroke();
ctx.fillStyle = accent;
roundedRectPath(ctx, 26, 28, 120, 124, 24);
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.font = "800 62px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 86, 91);
ctx.fillStyle = "#163033";
ctx.font = "800 37px Arial, sans-serif";
ctx.textAlign = "left";
ctx.fillText("BAY ZONE", 176, 91);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
}),
);
sprite.position.set(x, y, z);
sprite.scale.set(scale, scale * 0.28125, 1);
scene.add(sprite);
return sprite;
}
function makeVanSideDecal(parent) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#147d86";
ctx.font = "800 94px Arial, sans-serif";
ctx.fillText("BAYSIDE", 32, 110);
ctx.fillStyle = "#df6d55";
ctx.fillRect(36, 145, 250, 12);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const decal = new THREE.Mesh(
new THREE.PlaneGeometry(2.7, 0.675),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
}),
);
decal.position.set(0.5, 1.8, 1.232);
parent.add(decal);
}
// ---------------------------------------------------------------------
// Ground, curb, sidewalk, and service building
// ---------------------------------------------------------------------
addBox(
26.2,
0.42,
18.2,
palette.asphaltEdge,
0,
-0.3,
0,
scene,
false,
true,
);
addBox(
20.2,
0.08,
17.6,
palette.asphalt,
-2.1,
-0.035,
0,
scene,
false,
true,
);
addBox(
4.65,
0.25,
17.6,
palette.concrete,
10.48,
0.055,
0,
scene,
false,
true,
);
// Raised curb separating the service apron from the public path.
addBox(0.34, 0.42, 17.6, palette.curb, 8.05, 0.16, 0);
addBox(0.08, 0.035, 17.4, material(0xf4f0dc), 7.86, 0.39, 0);
// Tactile warning strip.
const tactileMat = material(0xd9a642, 0.86);
addBox(0.66, 0.035, 17.1, tactileMat, 8.56, 0.205, 0, scene, false, true);
for (let z = -8; z <= 8; z += 0.48) {
for (let x = 8.37; x <= 8.75; x += 0.25) {
addCylinder(
0.035,
0.035,
0.028,
tactileMat,
x,
0.238,
z,
scene,
8,
false,
);
}
}
// Sidewalk slab joints.
const jointMat = material(0xaeb8b3, 0.95);
for (let z = -8; z <= 8; z += 2) {
addBox(4.35, 0.012, 0.025, jointMat, 10.45, 0.191, z, scene, false, false);
}
for (let x = 9.2; x <= 12.4; x += 1.6) {
addBox(0.025, 0.012, 17.2, jointMat, x, 0.192, 0, scene, false, false);
}
// Back-of-house building.
addBox(16.8, 6.1, 1.25, palette.wall, -2.6, 3.02, -7.35);
addBox(17.25, 0.25, 1.65, palette.roof, -2.6, 6.18, -7.35);
addBox(16.8, 0.52, 1.29, palette.wallDark, -2.6, 0.3, -7.34);
// Loading shutter.
addBox(4.3, 3.6, 0.12, material(0x899493, 0.78, 0.2), -6.7, 2.08, -6.68);
for (let y = 0.55; y < 3.8; y += 0.32) {
addBox(4.15, 0.035, 0.035, material(0x758180, 0.7, 0.2), -6.7, y, -6.605);
}
addBox(4.65, 0.18, 0.35, palette.tealDark, -6.7, 3.98, -6.54);
// Windows and service doors.
const windowMat = material(0x54777a, 0.28, 0.32);
for (const x of [-2.6, 0.2, 3.0]) {
addBox(1.8, 1.55, 0.08, windowMat, x, 3.7, -6.68);
addBox(0.07, 1.6, 0.11, palette.white, x - 0.92, 3.7, -6.62);
addBox(0.07, 1.6, 0.11, palette.white, x + 0.92, 3.7, -6.62);
addBox(1.85, 0.07, 0.11, palette.white, x, 3.7, -6.62);
}
addBox(1.3, 2.55, 0.1, material(0x6e8986, 0.7), 5.65, 1.55, -6.67);
addBox(0.05, 0.58, 0.07, palette.white, 6.08, 1.45, -6.58);
// Building sign.
const signCanvas = document.createElement("canvas");
signCanvas.width = 1024;
signCanvas.height = 220;
const signCtx = signCanvas.getContext("2d");
signCtx.fillStyle = "#163033";
roundedRectPath(signCtx, 8, 8, 1008, 204, 26);
signCtx.fill();
signCtx.fillStyle = "#f7f8f1";
signCtx.font = "800 70px Arial, sans-serif";
signCtx.textAlign = "center";
signCtx.textBaseline = "middle";
signCtx.fillText("PARCEL HUB / 04", 512, 112);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(5.8, 1.25),
new THREE.MeshBasicMaterial({ map: signTexture }),
);
sign.position.set(-2.5, 5.28, -6.64);
scene.add(sign);
// ---------------------------------------------------------------------
// Painted operating zones
// ---------------------------------------------------------------------
const zoneHitMeshes = [];
const unloadFill = new THREE.MeshBasicMaterial({
color: 0x168b95,
transparent: true,
opacity: 0.16,
depthWrite: false,
side: THREE.DoubleSide,
});
const unloadPaint = material(0x44bac1, 0.78);
const turnFill = new THREE.MeshBasicMaterial({
color: 0xe7a62f,
transparent: true,
opacity: 0.12,
depthWrite: false,
side: THREE.DoubleSide,
});
const turnPaint = material(0xf0b540, 0.75);
const unloadZone = addPlane(4.8, 5.2, unloadFill, -1.25, 0.026, 0.65);
const turnZone = new THREE.Mesh(
new THREE.CircleGeometry(2.68, 72),
turnFill,
);
turnZone.rotation.x = -Math.PI / 2;
turnZone.position.set(4.05, 0.028, 0.6);
scene.add(turnZone);
const unloadCorners = [
new THREE.Vector3(-3.65, 0.065, -1.95),
new THREE.Vector3(1.15, 0.065, -1.95),
new THREE.Vector3(1.15, 0.065, 3.25),
new THREE.Vector3(-3.65, 0.065, 3.25),
];
for (let i = 0; i < 4; i++) {
dashedSegment(
unloadCorners[i],
unloadCorners[(i + 1) % 4],
unloadPaint,
0.38,
0.22,
0.08,
);
}
// Loading approach chevrons.
for (let i = 0; i < 3; i++) {
const chevron = new THREE.Group();
chevron.position.set(-2.75 + i * 0.6, 0.085, 1.95);
const a = addBox(0.07, 0.025, 0.68, unloadPaint, -0.19, 0, 0, chevron, false);
const b = addBox(0.07, 0.025, 0.68, unloadPaint, 0.19, 0, 0, chevron, false);
a.rotation.y = -0.68;
b.rotation.y = 0.68;
scene.add(chevron);
}
// Dashed turning ring.
const turnRadius = 2.68;
const turnSegments = 34;
for (let i = 0; i < turnSegments; i++) {
if (i % 2 !== 0) continue;
const a1 = (i / turnSegments) * Math.PI * 2;
const a2 = ((i + 0.58) / turnSegments) * Math.PI * 2;
dashedSegment(
new THREE.Vector3(
4.05 + Math.cos(a1) * turnRadius,
0.065,
0.6 + Math.sin(a1) * turnRadius,
),
new THREE.Vector3(
4.05 + Math.cos(a2) * turnRadius,
0.065,
0.6 + Math.sin(a2) * turnRadius,
),
turnPaint,
0.46,
0,
0.09,
);
}
makeFloorText("01 UNLOAD", "#177d86", -1.15, -0.95, 3.8);
makeFloorText("02 TURN", "#bc7f13", 4.05, 2.02, 2.65);
makeSpriteLabel("01", "#168b95", -1.2, 1.05, -1.6, 2.45);
makeSpriteLabel("02", "#d79a27", 4.0, 1.05, -1.75, 2.45);
makeSpriteLabel("03", "#657b7b", 10.4, 1.05, -1.75, 2.45);
// Invisible interaction surfaces.
const unloadHit = new THREE.Mesh(
new THREE.PlaneGeometry(4.8, 5.2),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide,
}),
);
unloadHit.rotation.x = -Math.PI / 2;
unloadHit.position.set(-1.25, 0.2, 0.65);
unloadHit.userData.zone = "unloading";
scene.add(unloadHit);
zoneHitMeshes.push(unloadHit);
const turnHit = new THREE.Mesh(
new THREE.CircleGeometry(2.68, 48),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide,
}),
);
turnHit.rotation.x = -Math.PI / 2;
turnHit.position.set(4.05, 0.21, 0.6);
turnHit.userData.zone = "turning";
scene.add(turnHit);
zoneHitMeshes.push(turnHit);
const sidewalkHit = new THREE.Mesh(
new THREE.PlaneGeometry(4.6, 17.5),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide,
}),
);
sidewalkHit.rotation.x = -Math.PI / 2;
sidewalkHit.position.set(10.45, 0.23, 0);
sidewalkHit.userData.zone = "sidewalk";
scene.add(sidewalkHit);
zoneHitMeshes.push(sidewalkHit);
// Road lane dashes and a simple direction arrow.
const roadWhite = material(0xd8ded7, 0.86);
for (let x = -10.8; x < 7; x += 1.8) {
addBox(0.85, 0.025, 0.075, roadWhite, x, 0.035, 5.55, scene, false, false);
}
const roadArrow = new THREE.Group();
roadArrow.position.set(-7.2, 0.05, 5.55);
addBox(1.25, 0.025, 0.075, roadWhite, 0, 0, 0, roadArrow, false);
addBox(0.075, 0.025, 0.62, roadWhite, -0.58, 0, 0.2, roadArrow, false).rotation.y = -0.7;
addBox(0.075, 0.025, 0.62, roadWhite, -0.58, 0, -0.2, roadArrow, false).rotation.y = 0.7;
scene.add(roadArrow);
// ---------------------------------------------------------------------
// Delivery van
// ---------------------------------------------------------------------
const van = new THREE.Group();
van.position.set(-7.1, 0, 0.55);
scene.add(van);
// Cargo body.
addBox(3.65, 2.35, 2.4, palette.white, 0.55, 1.64, 0, van);
addBox(3.7, 0.55, 2.44, palette.teal, 0.55, 0.73, 0, van);
addBox(3.82, 0.14, 2.52, palette.tealDark, 0.55, 1.02, 0, van);
addBox(3.45, 0.13, 2.25, palette.white, 0.45, 2.9, 0, van);
// Cab.
addBox(2.35, 1.45, 2.32, palette.white, -2.0, 1.1, 0, van);
addBox(1.95, 1.02, 2.17, palette.white, -2.16, 2.2, 0, van);
addBox(2.38, 0.52, 2.35, palette.teal, -2.0, 0.66, 0, van);
// Front and side glazing.
addBox(0.06, 0.9, 1.88, palette.glass, -3.155, 2.17, 0, van);
addBox(1.48, 0.83, 0.055, palette.glass, -2.16, 2.24, 1.102, van);
addBox(1.48, 0.83, 0.055, palette.glass, -2.16, 2.24, -1.102, van);
addBox(0.06, 0.82, 0.85, palette.glass, -2.84, 2.14, 0.58, van);
addBox(0.06, 0.82, 0.85, palette.glass, -2.84, 2.14, -0.58, van);
// Bumpers, lights, mirrors.
addBox(0.22, 0.38, 2.42, palette.tealDark, -3.3, 0.54, 0, van);
addBox(0.24, 0.38, 2.42, material(0xaeb9b5, 0.6), 2.42, 0.56, 0, van);
for (const z of [-0.78, 0.78]) {
addBox(0.08, 0.24, 0.34, material(0xf7edbe, 0.38), -3.2, 1.02, z, van);
addBox(0.08, 0.22, 0.3, palette.coral, 2.38, 1.05, z, van);
}
addBox(0.18, 0.32, 0.12, palette.tealDark, -2.92, 2.18, 1.26, van);
addBox(0.18, 0.32, 0.12, palette.tealDark, -2.92, 2.18, -1.26, van);
// Wheels.
for (const x of [-2.62, 0.95]) {
for (const z of [-1.28, 1.28]) {
const tire = addCylinder(
0.53,
0.53,
0.32,
palette.tire,
x,
0.56,
z,
van,
28,
);
tire.rotation.x = Math.PI / 2;
const hub = addCylinder(
0.26,
0.26,
0.345,
palette.tireHub,
x,
0.56,
z,
van,
20,
);
hub.rotation.x = Math.PI / 2;
}
}
// Open rear doorway.
addBox(0.08, 1.82, 1.94, material(0x26383a, 0.88), 2.42, 1.72, 0, van);
addBox(0.13, 0.1, 2.18, palette.tealDark, 2.46, 2.66, 0, van);
addBox(0.13, 0.1, 2.18, palette.tealDark, 2.46, 0.78, 0, van);
// Visible cartons inside the van.
addBox(0.65, 0.68, 0.62, palette.box, 1.98, 1.22, -0.47, van);
addBox(0.58, 0.52, 0.58, palette.boxLight, 2.04, 1.79, 0.38, van);
addBox(0.05, 0.7, 0.64, palette.tape, 2.3, 1.25, -0.47, van);
// Ramp.
const ramp = addBox(2.15, 0.11, 1.72, material(0x7e8d8d, 0.62, 0.35), 3.37, 0.49, 0, van);
ramp.rotation.z = -0.22;
for (const z of [-0.79, 0.79]) {
const rail = addBox(2.12, 0.09, 0.08, palette.tealDark, 3.37, 0.59, z, van);
rail.rotation.z = -0.22;
}
makeVanSideDecal(van);
// Unloading cartons.
function addParcel(x, y, z, scale = 1, rotation = 0, parent = scene) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
addBox(0.82, 0.62, 0.72, palette.box, 0, 0.31, 0, group);
addBox(0.07, 0.64, 0.74, palette.tape, 0, 0.31, 0, group);
addBox(0.29, 0.035, 0.25, material(0xf0e7d0, 0.92), 0.19, 0.635, 0.05, group);
return group;
}
addParcel(-3.95, 0.04, -0.2, 1, -0.12);
addParcel(-3.0, 0.04, -0.85, 0.88, 0.18);
addParcel(-2.6, 0.66, -0.8, 0.82, -0.05).position.y = 0.04;
addParcel(-1.65, 0.04, -0.75, 0.95, 0.12);
// Safety cones.
function addCone(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.05, z);
scene.add(group);
addBox(0.5, 0.07, 0.5, material(0x394548, 0.9), 0, 0.035, 0, group);
const cone = addCylinder(
0.04,
0.19,
0.58,
palette.coral,
0,
0.33,
0,
group,
18,
);
const stripe = addCylinder(
0.085,
0.11,
0.11,
palette.white,
0,
0.38,
0,
group,
18,
);
stripe.renderOrder = 1;
}
addCone(-3.35, 3.05);
addCone(0.6, -1.72);
// ---------------------------------------------------------------------
// Turning cart
// ---------------------------------------------------------------------
const cart = new THREE.Group();
scene.add(cart);
addBox(1.8, 0.16, 1.02, palette.amber, 0, 0.52, 0, cart);
addBox(1.88, 0.08, 1.08, palette.tealDark, 0, 0.43, 0, cart);
for (const x of [-0.6, 0.6]) {
for (const z of [-0.57, 0.57]) {
const wheel = addCylinder(
0.15,
0.15,
0.12,
palette.tire,
x,
0.2,
z,
cart,
16,
);
wheel.rotation.x = Math.PI / 2;
}
}
for (const z of [-0.45, 0.45]) {
addBox(0.08, 1.12, 0.08, palette.tealDark, -0.8, 1.07, z, cart);
}
addBox(0.1, 0.1, 1.0, palette.tealDark, -0.8, 1.63, 0, cart);
addParcel(0.12, 0.61, 0, 0.88, 0.05, cart);
addParcel(0.12, 1.18, 0, 0.72, -0.08, cart);
// A subtle swept arrow on the ground.
for (let i = 0; i < 4; i++) {
const a = -1.9 + i * 0.2;
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.16, 0.42, 3),
turnPaint,
);
arrow.rotation.x = Math.PI / 2;
arrow.rotation.z = -a;
arrow.position.set(
4.05 + Math.cos(a) * 1.84,
0.09,
0.6 + Math.sin(a) * 1.84,
);
scene.add(arrow);
}
// ---------------------------------------------------------------------
// Public-side furniture, planting, and pedestrians
// ---------------------------------------------------------------------
// Bollards reinforce the edge without blocking the walkway.
for (const z of [-5.5, -1.8, 2.1, 6]) {
addCylinder(0.1, 0.12, 0.95, palette.tealDark, 8.2, 0.62, z);
addCylinder(0.105, 0.105, 0.11, material(0xd8dfd7, 0.7), 8.2, 0.91, z);
}
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
group.scale.setScalar(scale);
scene.add(group);
addBox(1.4, 0.5, 1.4, material(0xaab0a6, 0.95), 0, 0.25, 0, group);
addBox(1.18, 0.09, 1.18, material(0x77866b, 0.98), 0, 0.53, 0, group);
addCylinder(0.12, 0.16, 1.6, material(0x77604b, 0.95), 0, 1.2, 0, group, 12);
const crown = addSphere(0.8, palette.foliage, 0, 2.28, 0, group);
crown.scale.set(1, 1.12, 0.9);
const crown2 = addSphere(0.58, palette.foliageLight, 0.36, 2.62, 0.05, group);
crown2.scale.set(0.95, 1, 0.9);
const crown3 = addSphere(0.52, palette.foliage, -0.42, 2.24, -0.08, group);
crown3.scale.set(0.9, 1, 0.9);
}
addTree(11.65, -5.35, 0.95);
addTree(11.65, 5.65, 0.83);
// Bench.
const bench = new THREE.Group();
bench.position.set(9.45, 0.2, 0.5);
bench.rotation.y = Math.PI / 2;
scene.add(bench);
addBox(2.4, 0.12, 0.5, palette.wood, 0, 0.55, 0, bench);
addBox(2.4, 0.5, 0.11, palette.wood, 0, 0.88, -0.23, bench);
for (const x of [-0.88, 0.88]) {
addBox(0.1, 0.55, 0.42, palette.tealDark, x, 0.27, 0, bench);
}
// Simple pedestrians.
const pedestrians = [];
function addPerson(x, z, shirtColor, scale = 1, phase = 0) {
const group = new THREE.Group();
group.position.set(x, 0.22, z);
group.scale.setScalar(scale);
scene.add(group);
const shirt = material(shirtColor, 0.88);
const trousers = material(0x405158, 0.9);
const skin = material(0xd6a47c, 0.92);
addCylinder(0.2, 0.25, 0.72, shirt, 0, 1.03, 0, group, 14);
addSphere(0.2, skin, 0, 1.58, 0, group);
addCylinder(0.085, 0.075, 0.67, trousers, -0.12, 0.36, 0, group, 12);
addCylinder(0.085, 0.075, 0.67, trousers, 0.12, 0.36, 0, group, 12);
addCylinder(0.065, 0.065, 0.58, shirt, -0.27, 1.0, 0, group, 12).rotation.z = -0.12;
addCylinder(0.065, 0.065, 0.58, shirt, 0.27, 1.0, 0, group, 12).rotation.z = 0.12;
pedestrians.push({ group, phase });
return group;
}
addPerson(10.55, 2.8, 0xc65f4e, 0.96, 0);
addPerson(11.25, -1.7, 0x537c92, 0.9, 1.7);
addPerson(9.15, 5.25, 0x7a6d9a, 0.88, 3.2);
// Bike and compact shelter.
const bike = new THREE.Group();
bike.position.set(11.75, 0.23, 2.65);
bike.rotation.y = -0.15;
scene.add(bike);
for (const x of [-0.55, 0.55]) {
const wheel = new THREE.Mesh(
new THREE.TorusGeometry(0.34, 0.045, 10, 24),
palette.tire,
);
wheel.position.set(x, 0.36, 0);
bike.add(wheel);
}
addBox(0.9, 0.07, 0.07, palette.coral, 0, 0.43, 0, bike);
addBox(0.07, 0.6, 0.07, palette.coral, -0.18, 0.66, 0, bike).rotation.z = -0.2;
addBox(0.07, 0.58, 0.07, palette.coral, 0.22, 0.63, 0, bike).rotation.z = 0.25;
addBox(0.07, 0.08, 0.5, palette.tealDark, 0.32, 0.91, 0, bike);
// A compact waiting shelter.
const shelter = new THREE.Group();
shelter.position.set(10.65, 0.2, -3.25);
scene.add(shelter);
for (const x of [-1.05, 1.05]) {
addBox(0.09, 2.1, 0.09, palette.tealDark, x, 1.05, -0.55, shelter);
addBox(0.09, 2.1, 0.09, palette.tealDark, x, 1.05, 0.55, shelter);
}
addBox(2.45, 0.12, 1.55, material(0x8ea9a7, 0.28, 0.25), 0, 2.12, 0, shelter);
addBox(2.35, 1.5, 0.055, material(0x9bb5b3, 0.2, 0.3), 0, 1.08, -0.58, shelter);
addBox(2.3, 0.15, 0.48, palette.wood, 0, 0.5, 0.12, shelter);
// ---------------------------------------------------------------------
// Zone information and selection
// ---------------------------------------------------------------------
const zoneCard = document.getElementById("zone-card");
const zoneIndex = document.getElementById("zone-index");
const zoneTitle = document.getElementById("zone-title");
const zoneCopy = document.getElementById("zone-copy");
const metrics = document.getElementById("metrics");
const zoneData = {
unloading: {
index: "01",
accent: "#168b95",
title: "Van unloading",
copy:
"A dedicated teal apron keeps parcel transfer clear of the cart sweep and the raised public walkway.",
metrics: ["4.8 × 5.2 m", "6 min dwell", "Curb access"],
},
turning: {
index: "02",
accent: "#d79a27",
title: "Cart turning footprint",
copy:
"The amber swept path preserves a continuous turning envelope while keeping cargo movement visible and predictable.",
metrics: ["5.36 m dia.", "360° sweep", "Clear center"],
},
sidewalk: {
index: "03",
accent: "#657b7b",
title: "Public sidewalk",
copy:
"A raised concrete path, tactile edge, bollards, and planted buffers separate everyday pedestrian access from service traffic.",
metrics: ["4.6 m wide", "Step-free", "Tactile edge"],
},
};
function selectZone(zoneName) {
const data = zoneData[zoneName];
if (!data) return;
zoneIndex.textContent = data.index;
zoneIndex.style.background = data.accent;
zoneTitle.textContent = data.title;
zoneCopy.textContent = data.copy;
metrics.replaceChildren(
...data.metrics.map((text) => {
const item = document.createElement("span");
item.className = "metric";
item.textContent = text;
return item;
}),
);
unloadFill.opacity = zoneName === "unloading" ? 0.25 : 0.14;
turnFill.opacity = zoneName === "turning" ? 0.23 : 0.11;
zoneCard.animate(
[
{ transform: "translateY(-4px)", opacity: 0.72 },
{ transform: "translateY(0)", opacity: 1 },
],
{
duration: 240,
easing: "ease-out",
},
);
}
// ---------------------------------------------------------------------
// Custom pointer camera controls and picking
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointerDown = new THREE.Vector2();
let dragging = false;
let dragged = false;
let activePointer = null;
function pickZone(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(zoneHitMeshes, false);
return hits.length ? hits[0].object.userData.zone : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
activePointer = event.pointerId;
dragging = true;
dragged = false;
pointerDown.set(event.clientX, event.clientY);
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) {
renderer.domElement.style.cursor = pickZone(event) ? "pointer" : "grab";
return;
}
const dx = event.clientX - pointerDown.x;
const dy = event.clientY - pointerDown.y;
if (Math.abs(dx) + Math.abs(dy) > 4) dragged = true;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.005,
0.38,
1.35,
);
pointerDown.set(event.clientX, event.clientY);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (event.pointerId !== activePointer) return;
dragging = false;
if (!dragged) {
const zone = pickZone(event);
if (zone) selectZone(zone);
}
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
activePointer = null;
renderer.domElement.style.cursor = "grab";
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
activePointer = null;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(-event.deltaY * 0.001),
0.68,
2.2,
);
updateCamera();
},
{ passive: false },
);
renderer.domElement.addEventListener("dblclick", () => {
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
cameraState.zoom = defaultCamera.zoom;
cameraState.target.copy(defaultCamera.target);
updateCamera();
});
document.getElementById("reset").addEventListener("click", () => {
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
cameraState.zoom = defaultCamera.zoom;
cameraState.target.copy(defaultCamera.target);
updateCamera();
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
// Cart gently demonstrates its turning envelope.
const cartAngle = 0.55 + Math.sin(elapsed * 0.55) * 0.38;
const cartRadius = 1.35;
cart.position.set(
4.05 + Math.cos(cartAngle) * cartRadius,
0,
0.6 + Math.sin(cartAngle) * cartRadius,
);
cart.rotation.y = -cartAngle - 0.25;
// Pedestrian idle motion.
pedestrians.forEach(({ group, phase }, index) => {
group.position.y = 0.22 + Math.sin(elapsed * 1.7 + phase) * 0.012;
group.rotation.y =
Math.sin(elapsed * 0.25 + phase + index) * 0.05;
});
// Vehicle brake light pulse.
const brakeMaterial = palette.coral;
brakeMaterial.emissive.setHex(0x401008);
brakeMaterial.emissiveIntensity =
0.15 + (Math.sin(elapsed * 2.6) * 0.5 + 0.5) * 0.3;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
selectZone("unloading");
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
});
</script>
</body>
</html>
```