Prompt specification
Build or customize the Three.js 3D scene "Commuter entering Federation Square from a crossing" 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: Commuter entering Federation Square from a crossing
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/commuter-entering-federation-square-from-a-crossing-x3006
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Federation Square in Melbourne. Create a compact referenced Melbourne vignette with crossing, plaza edge, and cultural-building entrance. Show a continuous route from transit-facing street to open public space. Voxel style.
Working Three.js Starter (commuter-entering-federation-square-from-a-crossing-x3006):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Federation Square — Melbourne Voxel Vignette</title>
<style>
:root {
--ink: #233039;
--paper: rgba(247, 244, 235, 0.94);
--line: rgba(35, 48, 57, 0.16);
--copper: #b85d3e;
--yellow: #e4b82d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbd4d8;
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;
cursor: grab;
}
canvas.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.title-card {
position: absolute;
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 19px 21px 17px;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 5px;
box-shadow: 0 12px 35px rgba(31, 45, 52, 0.16);
backdrop-filter: blur(9px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: #67727a;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
background: var(--copper);
border-radius: 1px;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 39px);
line-height: 0.98;
letter-spacing: -0.045em;
text-transform: uppercase;
}
.subtitle {
margin: 10px 0 0;
max-width: 320px;
color: #59666e;
font-size: 13px;
line-height: 1.45;
}
.route-card {
position: absolute;
left: 22px;
bottom: 22px;
width: min(370px, calc(100vw - 44px));
padding: 15px 17px;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: 5px;
box-shadow: 0 10px 28px rgba(31, 45, 52, 0.13);
backdrop-filter: blur(8px);
}
.route-heading {
margin-bottom: 12px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.route-row {
display: grid;
grid-template-columns: 24px 1fr;
gap: 9px;
align-items: start;
color: #526068;
font-size: 11px;
line-height: 1.45;
}
.route-row + .route-row {
margin-top: 8px;
}
.route-number {
display: grid;
width: 21px;
height: 21px;
place-items: center;
background: var(--ink);
color: white;
border-radius: 2px;
font-size: 9px;
font-weight: 800;
}
.route-number.copper {
background: var(--copper);
}
.route-number.yellow {
background: var(--yellow);
color: var(--ink);
}
.controls {
position: absolute;
right: 22px;
top: 22px;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
}
.control-note {
padding: 9px 11px;
background: rgba(247, 244, 235, 0.86);
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 4px;
color: #536169;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
box-shadow: 0 6px 18px rgba(31, 45, 52, 0.09);
}
button {
pointer-events: auto;
cursor: pointer;
padding: 10px 13px;
border: 1px solid rgba(35, 48, 57, 0.2);
border-radius: 4px;
background: var(--ink);
color: white;
font: 700 10px/1 Inter, ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.1em;
text-transform: uppercase;
}
button:hover {
background: #34444d;
}
button:focus-visible {
outline: 3px solid rgba(184, 93, 62, 0.45);
outline-offset: 3px;
}
.pin {
position: absolute;
z-index: 4;
display: flex;
align-items: center;
gap: 7px;
transform: translate(-50%, calc(-100% - 11px));
white-space: nowrap;
pointer-events: none;
opacity: 0;
transition: opacity 150ms ease;
}
.pin.visible {
opacity: 1;
}
.pin-dot {
width: 7px;
height: 7px;
flex: 0 0 auto;
background: var(--copper);
border: 2px solid white;
border-radius: 50%;
box-shadow: 0 2px 8px rgba(20, 30, 35, 0.35);
}
.pin-label {
padding: 5px 7px;
background: rgba(247, 244, 235, 0.9);
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 3px;
color: #344149;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.045em;
text-transform: uppercase;
box-shadow: 0 4px 12px rgba(31, 45, 52, 0.12);
}
.pin::after {
content: "";
position: absolute;
top: 100%;
left: 3px;
width: 1px;
height: 11px;
background: rgba(35, 48, 57, 0.55);
}
@media (max-width: 700px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.subtitle {
max-width: none;
font-size: 11px;
}
.route-card {
left: 12px;
bottom: 12px;
width: calc(100vw - 24px);
}
.route-row:nth-of-type(4),
.route-row:nth-of-type(5) {
display: none;
}
.controls {
top: auto;
right: 12px;
bottom: 135px;
}
.control-note {
display: none;
}
.pin-label {
font-size: 8px;
}
}
</style>
</head>
<body>
<div class="hud">
<section class="title-card">
<div class="eyebrow">Melbourne · Voxel field note 01</div>
<h1>Federation<br />Square</h1>
<p class="subtitle">
A compact reference to the civic threshold between Flinders Street Station,
the tram corridor and the open arts precinct.
</p>
</section>
<section class="route-card">
<div class="route-heading">Continuous pedestrian route</div>
<div class="route-row">
<span class="route-number yellow">01</span>
<span><strong>Transit forecourt</strong><br />Flinders Street Station entrance</span>
</div>
<div class="route-row">
<span class="route-number copper">02</span>
<span><strong>Signalised crossing</strong><br />Across the paired tram tracks</span>
</div>
<div class="route-row">
<span class="route-number">03</span>
<span><strong>Arts entrance</strong><br />ACMI doorway and civic frontage</span>
</div>
<div class="route-row">
<span class="route-number">04</span>
<span><strong>Open public square</strong><br />Terrace edge, seating and gathering space</span>
</div>
</section>
<div class="controls">
<div class="control-note">Drag to orbit · Wheel to zoom</div>
<button id="reset" type="button">Reset view</button>
</div>
</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 renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcbd4d8);
scene.fog = new THREE.Fog(0xcbd4d8, 86, 150);
const camera = new THREE.OrthographicCamera(-40, 40, 30, -30, 0.1, 220);
const cameraTarget = new THREE.Vector3(0, 2.1, 0.5);
const initialView = {
theta: 0.72,
phi: 0.93,
zoom: 0.98
};
const view = { ...initialView };
const cameraRadius = 76;
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
cameraTarget.x + cameraRadius * sinPhi * Math.sin(view.theta),
cameraTarget.y + cameraRadius * Math.cos(view.phi),
cameraTarget.z + cameraRadius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(cameraTarget);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const frustumHeight = Math.max(44, 74 / aspect);
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
resize();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xf4f6ed, 0x746958, 2.25));
const sun = new THREE.DirectionalLight(0xfff0d2, 3.15);
sun.position.set(-28, 42, 31);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -45;
sun.shadow.camera.right = 45;
sun.shadow.camera.top = 40;
sun.shadow.camera.bottom = -40;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 110;
sun.shadow.bias = -0.0006;
sun.shadow.normalBias = 0.025;
scene.add(sun);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.9,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
}
const mat = {
base: material(0x303c43),
ground: material(0xb8b5aa),
asphalt: material(0x41494c, { roughness: 0.96 }),
sidewalk: material(0xbdb9ae),
curb: material(0xd4d0c4),
plaza: material(0xccc8bd),
paverLight: material(0xffffff),
paverWarm: material(0xffffff),
paverDark: material(0xffffff),
white: material(0xf5f0df),
crossing: material(0xf4f0df),
yellow: material(0xe8bd28),
copper: material(0xb65d3e),
copperLight: material(0xcf7652),
charcoal: material(0x27343b),
steel: material(0x485359, { metalness: 0.65, roughness: 0.38 }),
rail: material(0x8b9292, { metalness: 0.8, roughness: 0.3 }),
sandstone: material(0xc6a67a),
sandstoneLight: material(0xdfc397),
sandstoneDark: material(0xa9875e),
sandstoneGrey: material(0xb8a68d),
glass: material(0x365966, { roughness: 0.28, metalness: 0.3 }),
glassLight: material(0x6d8990, { roughness: 0.32, metalness: 0.22 }),
interior: material(0xd79b4f, {
emissive: 0x7f4619,
emissiveIntensity: 0.28
}),
wood: material(0x93613e),
green: material(0x175b49),
greenLight: material(0x43806a),
tramCream: material(0xe8dfbd),
tramWindow: material(0x253f48, { roughness: 0.25, metalness: 0.12 }),
leaf: material(0x526d49),
leafLight: material(0x74835b),
leafDark: material(0x3f5a42),
skin: material(0xc89571),
blueCloth: material(0x466b80),
redCloth: material(0x9b4b3d),
ochreCloth: material(0xba8542),
purpleCloth: material(0x625270)
};
function box(w, h, d, x, y, z, m, parent = scene, cast = true) {
const mesh = new THREE.Mesh(unitBox, m);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 47021;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function makeSign(text, x, y, z, width, height, background = null, foreground = "#ffffff") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
if (background) {
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
} else {
context.clearRect(0, 0, canvas.width, canvas.height);
}
context.fillStyle = foreground;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = "700 58px Arial, Helvetica, sans-serif";
context.fillText(text, canvas.width / 2, canvas.height / 2, canvas.width - 55);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false,
side: THREE.DoubleSide
})
);
mesh.position.set(x, y, z);
mesh.renderOrder = 3;
scene.add(mesh);
return mesh;
}
function makeGroundText(text, x, y, z, width, height, foreground = "#737875") {
const sign = makeSign(text, x, y, z, width, height, null, foreground);
sign.rotation.x = -Math.PI / 2;
return sign;
}
// -------------------------------------------------------------------------
// Diorama base, Flinders Street, tram corridor and station frontage
// -------------------------------------------------------------------------
box(58, 1.1, 44, 0, -0.62, 0, mat.base);
box(57.5, 0.16, 43.5, 0, -0.03, 0, mat.ground);
// Flinders Street roadway.
box(57.5, 0.16, 8.2, 0, 0.07, 12.9, mat.asphalt);
// Raised footpaths.
box(57.5, 0.26, 2.9, 0, 0.15, 7.25, mat.sidewalk);
box(57.5, 0.26, 3.25, 0, 0.15, 18.65, mat.sidewalk);
// Kerbs.
box(57.5, 0.18, 0.2, 0, 0.18, 8.85, mat.curb);
box(57.5, 0.18, 0.2, 0, 0.18, 16.95, mat.curb);
// Four tram rails: two opposed tracks.
[10.25, 11.35, 13.45, 14.55].forEach((z) => {
box(56.5, 0.045, 0.085, 0, 0.175, z, mat.rail, scene, false);
box(56.5, 0.025, 0.16, 0, 0.155, z, mat.charcoal, scene, false);
});
// Zebra crossing across the tram corridor.
[-2.7, -1.8, -0.9, 0, 0.9, 1.8, 2.7].forEach((x) => {
box(0.48, 0.045, 7.7, x, 0.19, 12.9, mat.crossing, scene, false);
});
// Yellow tactile paving at both kerbs.
box(7.8, 0.055, 0.7, 0, 0.32, 8.55, mat.yellow, scene, false);
box(7.8, 0.055, 0.7, 0, 0.32, 17.3, mat.yellow, scene, false);
// Station frontage on the south side of Flinders Street.
box(57.5, 4.7, 1.35, 0, 2.36, 20.75, mat.sandstoneDark);
box(57.8, 0.45, 1.6, 0, 4.85, 20.72, mat.sandstoneLight);
box(57.5, 0.28, 1.55, 0, 0.18, 20.7, mat.charcoal);
// Repeated station windows.
for (let x = -25; x <= 25; x += 5) {
if (Math.abs(x) < 4) continue;
box(3.5, 1.55, 0.12, x, 2.75, 20.03, mat.glass);
box(0.13, 1.7, 0.17, x - 1.8, 2.75, 19.96, mat.charcoal);
box(0.13, 1.7, 0.17, x + 1.8, 2.75, 19.96, mat.charcoal);
}
// Station entrance aligned with the route.
box(5.6, 3.35, 0.18, 0, 1.72, 20.01, mat.charcoal);
box(4.7, 2.9, 0.15, 0, 1.53, 19.89, mat.glass);
box(0.12, 2.9, 0.18, 0, 1.53, 19.79, mat.steel);
box(6.4, 0.35, 1.3, 0, 3.57, 20.16, mat.sandstoneLight);
makeSign(
"FLINDERS STREET STATION",
0,
4.28,
19.99,
15.5,
1.0,
"#e7bb23",
"#26333a"
);
// -------------------------------------------------------------------------
// Federation Square plaza and paving
// -------------------------------------------------------------------------
box(45, 0.38, 13.6, 0, 0.18, -1.25, mat.plaza);
// Instanced square pavers create the voxel plaza texture.
const columns = 25;
const rows = 7;
const paverMesh = new THREE.InstancedMesh(unitBox, mat.paverLight, columns * rows);
paverMesh.receiveShadow = true;
const dummy = new THREE.Object3D();
let paverIndex = 0;
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const x = -21 + column * 1.75;
const z = -6.55 + row * 1.72;
const nearRoute = Math.abs(x) < 2.2;
const darkAccent = random() > 0.91;
const edgeAccent = row === 0 || row === rows - 1;
dummy.position.set(x, 0.385, z);
dummy.scale.set(1.63, 0.035, 1.58);
dummy.updateMatrix();
paverMesh.setMatrixAt(paverIndex, dummy.matrix);
const color = new THREE.Color();
if (nearRoute) color.set(0xc1aa94);
else if (darkAccent) color.set(0x8b908d);
else if (edgeAccent) color.set(0xb8b7af);
else color.set(random() > 0.5 ? 0xe0dcd1 : 0xd1cec3);
paverMesh.setColorAt(paverIndex, color);
paverIndex++;
}
}
paverMesh.instanceMatrix.needsUpdate = true;
if (paverMesh.instanceColor) paverMesh.instanceColor.needsUpdate = true;
scene.add(paverMesh);
// A stepped plaza edge on the western side, separate from the accessible route.
box(11.7, 0.38, 5.6, -15.8, 0.56, 1.15, mat.sandstoneGrey);
box(11.7, 0.16, 0.75, -15.8, 0.32, 4.23, mat.curb);
box(11.7, 0.13, 0.7, -15.8, 0.40, 3.52, mat.curb);
box(11.7, 0.10, 0.65, -15.8, 0.45, 2.88, mat.curb);
makeGroundText("FEDERATION SQUARE", 12.3, 0.415, -1.7, 12.8, 2.25, "#7d817e");
// -------------------------------------------------------------------------
// Continuous terracotta pedestrian route
// -------------------------------------------------------------------------
// Station forecourt to kerb.
box(0.72, 0.045, 3.5, 0, 0.405, 18.15, mat.copper, scene, false);
// Square route markers preserve the voxel language through the crossing.
for (let z = 9.35; z <= 16.85; z += 1.05) {
box(0.34, 0.055, 0.34, 0, 0.245, z, mat.copper, scene, false);
}
// Kerb to plaza and onward into the open square.
box(0.72, 0.045, 3.25, 0, 0.405, 7.15, mat.copper, scene, false);
box(0.78, 0.045, 7.8, 0, 0.425, 1.55, mat.copper, scene, false);
// Brass wayfinding cubes.
[18.2, 12.7, 5.2, 0.1].forEach((z, index) => {
box(0.82, 0.07, 0.82, 0, 0.475, z, mat.yellow, scene, false);
box(0.22, 0.26, 0.22, 0, 0.64, z, mat.charcoal, scene, false);
});
// -------------------------------------------------------------------------
// Cultural-building frontage and ACMI entrance
// -------------------------------------------------------------------------
// West sandstone mass.
box(19.2, 8.4, 10, -14.15, 4.55, -13, mat.sandstone);
// Central lower entrance block.
box(10.2, 6.9, 11.0, 0, 3.8, -13, mat.sandstoneLight);
// East cultural wing.
box(18.2, 9.1, 9.3, 14.1, 4.9, -13.65, mat.sandstoneDark);
// Irregular projecting sandstone panels on the west frontage.
for (let x = -22.5; x <= -6; x += 2.05) {
const height = 6.2 + random() * 2.0;
box(
1.65,
height,
0.58,
x,
0.37 + height / 2,
-7.74,
random() > 0.5 ? mat.sandstoneLight : mat.sandstone
);
}
// East wing horizontal window bands.
[2.6, 4.9, 7.2].forEach((y) => {
box(15.7, 1.15, 0.22, 14.1, y, -8.88, mat.glass);
box(16.1, 0.17, 0.35, 14.1, y - 0.62, -8.73, mat.sandstoneLight);
});
// East wing vertical fins.
for (let x = 6.4; x <= 22; x += 2.15) {
box(0.48, 8.7, 0.9, x, 4.75, -8.55, mat.sandstoneLight);
}
// Recessed entrance, warm interior and glass doors.
box(7.7, 5.55, 0.42, 0, 3.12, -7.43, mat.charcoal);
box(5.1, 4.55, 0.16, 0, 2.65, -7.17, mat.interior);
box(3.8, 3.95, 0.2, 0, 2.4, -6.96, mat.glass);
box(0.12, 4.0, 0.27, 0, 2.4, -6.8, mat.steel);
box(0.72, 0.09, 0.15, 0.66, 2.05, -6.73, mat.steel);
// Entrance threshold and projecting canopy.
box(7.9, 0.18, 1.55, 0, 0.47, -7.0, mat.curb);
box(8.4, 0.48, 2.25, 0, 5.35, -6.75, mat.charcoal);
box(7.7, 0.18, 1.8, 0, 5.68, -6.68, mat.sandstoneLight);
// Square structural piers.
box(0.62, 5.15, 0.7, -4.3, 2.93, -6.87, mat.sandstoneLight);
box(0.62, 5.15, 0.7, 4.3, 2.93, -6.87, mat.sandstoneLight);
makeSign("ACMI", 0, 6.77, -7.39, 4.7, 1.12, "#26333a", "#f5f0df");
// Small banner panels add scale to the central facade.
box(1.2, 3.1, 0.13, -3.3, 3.2, -7.36, mat.copper);
box(1.2, 3.1, 0.13, 3.3, 3.2, -7.36, mat.glassLight);
// -------------------------------------------------------------------------
// Voxel tram
// -------------------------------------------------------------------------
const tram = new THREE.Group();
tram.position.set(-16.2, 0, 13.45);
scene.add(tram);
box(11.6, 1.65, 2.28, 0, 1.05, 0, mat.green, tram);
box(11.35, 1.3, 2.34, 0, 2.13, 0, mat.tramCream, tram);
box(11.7, 0.22, 2.42, 0, 2.86, 0, mat.steel, tram);
box(11.65, 0.22, 2.45, 0, 0.39, 0, mat.charcoal, tram);
box(11.5, 0.17, 2.4, 0, 1.47, 0, mat.yellow, tram);
for (let x = -4.55; x <= 4.6; x += 1.5) {
box(1.16, 0.84, 0.1, x, 2.25, 1.18, mat.tramWindow, tram);
box(1.16, 0.84, 0.1, x, 2.25, -1.18, mat.tramWindow, tram);
}
box(0.16, 1.1, 1.85, 5.85, 2.14, 0, mat.tramWindow, tram);
box(0.65, 0.4, 0.12, 4.1, 2.55, 1.21, mat.charcoal, tram);
box(0.55, 0.2, 0.14, 4.1, 2.55, 1.3, mat.yellow, tram);
[-3.8, 3.8].forEach((x) => {
box(0.18, 1.35, 0.18, x, 3.46, 0, mat.charcoal, tram);
box(2.1, 0.12, 0.12, x, 4.1, 0, mat.charcoal, tram);
box(0.12, 0.12, 1.35, x, 4.1, 0, mat.charcoal, tram);
});
[-3.7, 3.7].forEach((x) => {
box(1.1, 0.5, 0.48, x, 0.33, 1.0, mat.charcoal, tram);
box(1.1, 0.5, 0.48, x, 0.33, -1.0, mat.charcoal, tram);
});
// -------------------------------------------------------------------------
// Street furniture, signals and overhead wire
// -------------------------------------------------------------------------
function makeStreetLight(x, z, south = false) {
box(0.16, 4.3, 0.16, x, 2.15, z, mat.charcoal);
box(0.65, 0.16, 0.5, x + 0.2, 4.3, z, mat.charcoal);
box(0.42, 0.12, 0.3, x + 0.2, 4.2, z, mat.white);
}
[-24, -10, 10, 24].forEach((x) => makeStreetLight(x, 8.15));
[-23, -11, 11, 23].forEach((x) => makeStreetLight(x, 18.95, true));
// Pedestrian signals at the crossing.
[-4.1, 4.1].forEach((x) => {
box(0.16, 3.25, 0.16, x, 1.63, 8.1, mat.charcoal);
box(0.54, 1.08, 0.42, x, 2.86, 8.1, mat.charcoal);
box(0.18, 0.18, 0.08, x, 3.06, 7.86, material(0x66c693, {
emissive: 0x2b8d58,
emissiveIntensity: 0.8
}));
box(0.18, 0.18, 0.08, x, 2.67, 7.86, mat.copper);
});
// Overhead tram wire.
box(56.5, 0.035, 0.035, 0, 5.15, 13.45, mat.charcoal, scene, false);
[-22, -10, 10, 22].forEach((x) => {
box(0.08, 5.1, 0.08, x, 2.55, 13.45, mat.charcoal, scene, false);
});
// -------------------------------------------------------------------------
// Plaza furniture, trees, sculpture and people
// -------------------------------------------------------------------------
function makeBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.42, z);
group.rotation.y = rotation;
scene.add(group);
box(2.8, 0.16, 0.62, 0, 0.62, 0, mat.wood, group);
box(2.8, 0.48, 0.14, 0, 1.03, -0.25, mat.wood, group);
box(0.18, 0.65, 0.52, -1.05, 0.3, 0, mat.charcoal, group);
box(0.18, 0.65, 0.52, 1.05, 0.3, 0, mat.charcoal, group);
}
makeBench(-8.2, 3.25, 0);
makeBench(7.5, 3.3, 0);
makeBench(-21.1, -2.4, Math.PI / 2);
makeBench(20.9, 2.7, Math.PI / 2);
makeBench(17.8, -0.4, Math.PI);
function makeTree(x, z, size = 1) {
const group = new THREE.Group();
group.position.set(x, 0.03, z);
group.scale.setScalar(size);
scene.add(group);
box(2.4, 0.45, 2.4, 0, 0.23, 0, mat.sandstoneGrey, group);
box(0.52, 2.8, 0.52, 0, 1.75, 0, mat.wood, group);
box(2.8, 2.2, 2.8, 0, 4.0, 0, mat.leaf, group);
box(2.0, 1.5, 2.0, 0.65, 5.15, 0.15, mat.leafLight, group);
box(1.7, 1.2, 1.7, -0.65, 4.8, -0.35, mat.leafDark, group);
box(1.45, 1.0, 1.45, 0.15, 5.95, -0.2, mat.leaf, group);
}
makeTree(-25.1, -4.5, 1.05);
makeTree(-25.0, 2.2, 0.9);
makeTree(25.1, -2.5, 1.0);
makeTree(24.9, 5.0, 0.82);
// Abstract stepped "cloud" sculpture near the eastern edge of the plaza.
const sculpture = new THREE.Group();
sculpture.position.set(12.2, 0.4, -4.55);
scene.add(sculpture);
for (let i = 0; i < 6; i++) {
const x = i * 1.18;
const height = 2.55 + Math.sin(i * 0.9) * 0.65;
box(0.14, height, 0.14, x, height / 2, 0, mat.steel, sculpture);
box(1.35, 0.13, 0.13, x + 0.55, height * 0.72, 0, mat.steel, sculpture);
box(1.05, 0.9, 0.9, x, height + 0.3, 0, mat.white, sculpture);
}
box(7.4, 0.13, 0.13, 3.0, 2.25, 0, mat.steel, sculpture);
box(0.13, 0.13, 2.6, 3.0, 2.25, 0, mat.steel, sculpture);
// Small civic clock at the plaza edge.
box(0.52, 3.8, 0.52, 22.7, 2.2, 4.1, mat.sandstoneGrey);
box(2.2, 2.2, 0.42, 22.7, 4.65, 4.1, mat.charcoal);
box(0.13, 0.72, 0.12, 22.7, 4.91, 3.84, mat.white);
box(0.58, 0.13, 0.12, 22.94, 4.65, 3.83, mat.white);
box(0.15, 0.15, 0.1, 22.7, 4.65, 3.8, mat.copper);
function makeCafeTable(x, z) {
box(0.15, 1.12, 0.15, x, 0.95, z, mat.charcoal);
box(1.55, 0.12, 1.55, x, 1.52, z, mat.wood);
box(0.65, 0.48, 0.65, x, 0.68, z, mat.charcoal);
[-1.12, 1.12].forEach((offset) => {
box(0.62, 0.12, 0.62, x + offset, 0.95, z, mat.copper);
box(0.12, 0.55, 0.12, x + offset, 0.63, z, mat.charcoal);
});
}
[-21, -18.4].forEach((x) => {
makeCafeTable(x, -4.8);
box(0.14, 3.35, 0.14, x, 2.05, -4.8, mat.charcoal);
box(3.1, 0.2, 3.1, x, 3.75, -4.8, mat.copperLight);
box(2.2, 0.18, 2.2, x, 3.98, -4.8, mat.copper);
box(1.2, 0.16, 1.2, x, 4.18, -4.8, mat.sandstoneLight);
});
function makePerson(x, z, clothing, rotation = 0, baseY = 0.42, scale = 1) {
const group = new THREE.Group();
group.position.set(x, baseY, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
box(0.2, 0.65, 0.22, -0.13, 0.32, 0, mat.charcoal, group);
box(0.2, 0.65, 0.22, 0.13, 0.32, 0, mat.charcoal, group);
box(0.55, 0.7, 0.32, 0, 0.98, 0, clothing, group);
box(0.15, 0.55, 0.17, -0.36, 0.93, 0, clothing, group);
box(0.15, 0.55, 0.17, 0.36, 0.93, 0, clothing, group);
box(0.37, 0.37, 0.37, 0, 1.52, 0, mat.skin, group);
box(0.42, 0.13, 0.42, 0, 1.73, 0, mat.charcoal, group);
}
// People on the route.
makePerson(0.18, 14.3, mat.redCloth, Math.PI, 0.24, 0.96);
makePerson(-0.25, 10.65, mat.blueCloth, Math.PI, 0.24, 1.02);
makePerson(0.7, 3.45, mat.ochreCloth, 0.4, 0.42, 0.98);
// People gathering in the public square.
makePerson(-4.1, -1.6, mat.purpleCloth, -0.6);
makePerson(-3.1, -2.4, mat.blueCloth, 0.8);
makePerson(-2.1, -1.3, mat.redCloth, 2.1, 0.42, 0.88);
makePerson(6.2, 0.3, mat.ochreCloth, -1.3);
makePerson(7.4, -0.5, mat.purpleCloth, 0.4);
makePerson(18.7, -0.8, mat.blueCloth, 1.1);
makePerson(20.0, -0.1, mat.redCloth, -0.6);
makePerson(-16.8, 1.8, mat.blueCloth, 1.5, 0.78);
makePerson(-14.6, 1.3, mat.ochreCloth, -0.4, 0.78);
makePerson(3.9, -6.0, mat.purpleCloth, 0.2, 0.42, 0.9);
// -------------------------------------------------------------------------
// Bollards and small plaza details
// -------------------------------------------------------------------------
[-21, -18, -15, -12, -9, 9, 12, 15, 18, 21].forEach((x) => {
box(0.22, 0.75, 0.22, x, 0.78, 5.0, mat.charcoal);
box(0.25, 0.1, 0.25, x, 1.15, 5.0, mat.steel);
});
// Square planters at the plaza corners.
[[-22, -6.8], [22, -6.8], [-22, 4.8], [22, 4.8]].forEach(([x, z]) => {
box(1.7, 0.65, 1.7, x, 0.7, z, mat.sandstoneGrey);
box(0.38, 1.8, 0.38, x, 1.55, z, mat.wood);
box(1.55, 1.2, 1.55, x, 2.7, z, mat.leafLight);
box(1.05, 0.9, 1.05, x + 0.2, 3.45, z, mat.leaf);
});
// -------------------------------------------------------------------------
// Screen-space reference pins
// -------------------------------------------------------------------------
const pinDefinitions = [
{ text: "Flinders Street Station", position: new THREE.Vector3(0, 5.3, 20.0) },
{ text: "Signalised crossing", position: new THREE.Vector3(3.4, 1.0, 12.9) },
{ text: "ACMI entrance", position: new THREE.Vector3(0, 7.7, -7.2) },
{ text: "Open public square", position: new THREE.Vector3(9.2, 0.9, 1.6) }
];
const pins = pinDefinitions.map((definition) => {
const element = document.createElement("div");
element.className = "pin";
element.innerHTML = `
<span class="pin-dot"></span>
<span class="pin-label">${definition.text}</span>
`;
document.querySelector(".hud").appendChild(element);
return { ...definition, element };
});
const projected = new THREE.Vector3();
function updatePins() {
pins.forEach((pin) => {
projected.copy(pin.position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
pin.element.classList.toggle("visible", visible);
if (visible) {
pin.element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
pin.element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
});
}
// -------------------------------------------------------------------------
// Direct camera controls — no addons
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let activePointer = null;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
activePointer = event.pointerId;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
view.theta -= dx * 0.006;
view.phi = THREE.MathUtils.clamp(view.phi + dy * 0.005, 0.48, 1.38);
updateCamera();
});
function stopDragging(event) {
if (event && activePointer !== null && event.pointerId !== activePointer) return;
dragging = false;
activePointer = null;
renderer.domElement.classList.remove("dragging");
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(
view.zoom * (event.deltaY > 0 ? 0.92 : 1.08),
0.62,
1.55
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset").addEventListener("click", () => {
view.theta = initialView.theta;
view.phi = initialView.phi;
view.zoom = initialView.zoom;
updateCamera();
});
renderer.domElement.addEventListener("dblclick", () => {
view.theta = initialView.theta;
view.phi = initialView.phi;
view.zoom = initialView.zoom;
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") view.theta -= 0.08;
if (event.key === "ArrowRight") view.theta += 0.08;
if (event.key === "ArrowUp") view.phi = Math.max(0.48, view.phi - 0.06);
if (event.key === "ArrowDown") view.phi = Math.min(1.38, view.phi + 0.06);
if (event.key === "+" || event.key === "=") view.zoom = Math.min(1.55, view.zoom + 0.08);
if (event.key === "-") view.zoom = Math.max(0.62, view.zoom - 0.08);
updateCamera();
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
updateCamera();
renderer.setAnimationLoop(() => {
updatePins();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```