Prompt specification
Build or customize the Three.js 3D scene "Wynyard waterfront bollard and timber-seat module" 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: Wynyard waterfront bollard and timber-seat module
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/wynyard-waterfront-bollard-and-timber-seat-module-x2961
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: Wynyard waterfront bollard and timber-seat module. Build a referenced Auckland waterfront fragment with retained mooring detail and contemporary seating. Show the distinction between working maritime infrastructure and added public-space furniture.
Working Three.js Starter (wynyard-waterfront-bollard-and-timber-seat-module-x2961):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Wynyard Waterfront — Bollard & Timber Seat</title>
<style>
:root {
--ink: #253334;
--muted: #647271;
--paper: rgba(249, 250, 246, 0.94);
--line: rgba(37, 51, 52, 0.16);
--retained: #914b36;
--added: #b98447;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce6e3;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.68);
box-shadow:
0 18px 50px rgba(31, 48, 48, 0.12),
0 2px 8px rgba(31, 48, 48, 0.08);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.title-card {
top: 22px;
left: 22px;
width: min(380px, calc(100vw - 44px));
padding: 20px 22px 18px;
border-radius: 16px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 9px;
color: #6f817e;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 38px);
font-weight: 660;
line-height: 1.03;
letter-spacing: -0.045em;
}
.subtitle {
margin: 12px 0 0;
max-width: 320px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.legend {
top: 22px;
right: 22px;
width: 250px;
padding: 15px 16px;
border-radius: 14px;
pointer-events: none;
}
.legend-title {
margin-bottom: 11px;
color: #788684;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.legend-item {
display: grid;
grid-template-columns: 10px 1fr;
gap: 10px;
align-items: start;
padding: 9px 0;
border-top: 1px solid var(--line);
}
.legend-item:first-of-type {
border-top: 0;
}
.swatch {
width: 10px;
height: 10px;
margin-top: 3px;
border-radius: 2px;
}
.swatch.retained {
background: var(--retained);
}
.swatch.added {
background: var(--added);
}
.legend-label {
margin: 0 0 2px;
font-size: 11px;
font-weight: 760;
letter-spacing: 0.045em;
text-transform: uppercase;
}
.legend-copy {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.callout {
position: fixed;
z-index: 6;
display: none;
pointer-events: none;
}
.callout .dot {
position: absolute;
top: -5px;
left: -5px;
width: 10px;
height: 10px;
border: 2px solid rgba(255, 255, 255, 0.9);
border-radius: 50%;
box-shadow: 0 2px 7px rgba(0, 0, 0, 0.22);
}
.callout.retained .dot {
background: var(--retained);
}
.callout.added .dot {
background: var(--added);
}
.callout .leader {
position: absolute;
top: 0;
left: 0;
width: 27px;
height: 1px;
background: rgba(37, 51, 52, 0.55);
}
.callout.right .leader {
right: 0;
left: auto;
}
.callout .box {
position: absolute;
top: 0;
min-width: 190px;
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 9px;
background: rgba(250, 251, 247, 0.93);
box-shadow: 0 9px 28px rgba(31, 48, 48, 0.14);
white-space: nowrap;
}
.callout.left .box {
transform: translate(18px, -50%);
}
.callout.right .box {
right: 18px;
transform: translateY(-50%);
}
.callout .tag {
display: block;
margin-bottom: 4px;
color: #6e7d7b;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.callout.retained .tag {
color: var(--retained);
}
.callout.added .tag {
color: #8b612f;
}
.callout strong {
display: block;
font-size: 11px;
letter-spacing: 0.01em;
}
.callout small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.footer {
position: fixed;
z-index: 11;
right: 22px;
bottom: 20px;
display: flex;
gap: 12px;
align-items: center;
padding: 9px 10px 9px 14px;
border-radius: 999px;
color: #64716f;
font-size: 10px;
}
.footer kbd {
padding: 2px 5px;
border: 1px solid var(--line);
border-radius: 4px;
background: rgba(255, 255, 255, 0.55);
color: #3e4d4c;
font: inherit;
font-weight: 700;
}
#reset {
border: 0;
border-radius: 999px;
padding: 7px 12px;
background: #314443;
color: #fff;
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 700;
}
#reset:hover {
background: #1d3030;
}
#reset:focus-visible {
outline: 2px solid #b98447;
outline-offset: 2px;
}
.site-note {
position: fixed;
z-index: 8;
left: 22px;
bottom: 22px;
color: rgba(37, 51, 52, 0.68);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 820px) {
.legend,
.callout {
display: none !important;
}
.title-card {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 15px 17px;
}
.subtitle {
max-width: none;
}
.site-note {
left: 15px;
bottom: 70px;
}
.footer {
right: 14px;
bottom: 14px;
}
.footer .hint {
display: none;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive three-dimensional Wynyard waterfront model"></main>
<section class="panel title-card">
<p class="eyebrow">Wynyard Quarter · Auckland</p>
<h1>Waterfront bollard<br>& timber-seat module</h1>
<p class="subtitle">
An interpretive fragment showing retained maritime infrastructure
separated from a newly added layer of public-space furniture.
</p>
</section>
<aside class="panel legend" aria-label design legend>
<div class="legend-title">Two layers of waterfront</div>
<div class="legend-item">
<span class="swatch retained"></span>
<div>
<p class="legend-label">Retained · working</p>
<p class="legend-copy">
Weathered cast-iron wharf bollard, original concrete apron and
active mooring point.
</p>
</div>
</div>
<div class="legend-item">
<span class="swatch added"></span>
<div>
<p class="legend-label">Added · public</p>
<p class="legend-copy">
Contemporary iroko slats, blackened steel frame and a new
paved public-realm zone.
</p>
</div>
</div>
</aside>
<div id="bollard-callout" class="callout retained left">
<span class="dot"></span>
<span class="leader"></span>
<div class="box">
<span class="tag">Retained · working infrastructure</span>
<strong>Wharf mooring bollard B-07</strong>
<small>Weathered oxide-red cast iron on original concrete</small>
</div>
</div>
<div id="bench-callout" class="callout added right">
<span class="dot"></span>
<span class="leader"></span>
<div class="box">
<span class="tag">Added · public-space furniture</span>
<strong>Timber-seat module</strong>
<small>Iroko slats / blackened steel / set behind edge</small>
</div>
</div>
<div class="site-note">Interpretive design model · not a surveyed record</div>
<div class="panel footer">
<span class="hint">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom ·
<kbd>R</kbd> reset
</span>
<button id="reset" type="button">Reset view</button>
</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 sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Voxel model of a Wynyard Quarter waterfront fragment"
);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9e5e2);
scene.fog = new THREE.Fog(0xd9e5e2, 35, 78);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
140
);
const hemisphere = new THREE.HemisphereLight(
0xf4fbf7,
0x73807a,
2.15
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff4da, 3.2);
sun.position.set(-11, 20, -12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcce3eb, 0.75);
fill.position.set(12, 8, 13);
scene.add(fill);
// -------------------------------------------------------------------------
// Procedural textures: no external image assets
// -------------------------------------------------------------------------
function makeWoodTexture() {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#b77c40";
ctx.fillRect(0, 0, canvas.width, canvas.height);
const colors = [
"rgba(83, 44, 20, 0.22)",
"rgba(255, 210, 133, 0.20)",
"rgba(100, 55, 25, 0.14)"
];
for (let i = 0; i < 74; i++) {
const y = Math.random() * canvas.height;
ctx.strokeStyle = colors[i % colors.length];
ctx.lineWidth = Math.random() * 2 + 0.4;
ctx.beginPath();
ctx.moveTo(0, y);
ctx.bezierCurveTo(
130,
y + Math.random() * 8 - 4,
330,
y + Math.random() * 8 - 4,
canvas.width,
y + Math.random() * 5 - 2.5
);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(2.2, 1);
return texture;
}
function makeBrickTexture() {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#8f8173";
ctx.fillRect(0, 0, 256, 256);
const colors = ["#794b3c", "#87503e", "#70473b", "#915442"];
for (let row = 0; row < 10; row++) {
for (let col = -1; col < 5; col++) {
const x = col * 64 + (row % 2) * 32;
const y = row * 26;
ctx.fillStyle = colors[(row + col + 8) % colors.length];
ctx.fillRect(x + 2, y + 2, 60, 22);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(3.2, 2.2);
return texture;
}
function makeTextTexture(text, background = "#314443", foreground = "#f4f1e7") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.globalAlpha = 0.5;
ctx.lineWidth = 5;
ctx.strokeRect(8, 8, canvas.width - 16, canvas.height - 16);
ctx.globalAlpha = 1;
ctx.fillStyle = foreground;
ctx.font = "700 54px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
// -------------------------------------------------------------------------
// Materials and voxel geometry helpers
// -------------------------------------------------------------------------
const material = (color, roughness = 0.78, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const M = {
concrete: material(0xaaa99e),
coping: material(0xc3c0b2),
paving: material(0x8d9690),
paverLight: material(0xa8ada4),
paverWarm: material(0xb1aa99),
quay: material(0x777d76),
iron: material(0x713d31, 0.82, 0.32),
ironDark: material(0x393a34, 0.7, 0.48),
rust: material(0xa85736, 0.94, 0.12),
steel: material(0x26302f, 0.58, 0.62),
timber: new THREE.MeshStandardMaterial({
map: makeWoodTexture(),
roughness: 0.72,
metalness: 0
}),
timberEnd: material(0x8d5f31),
rope: material(0xb6a080, 0.98),
water: new THREE.MeshStandardMaterial({
color: 0x4f8d91,
roughness: 0.3,
metalness: 0.08
}),
rippleLight: new THREE.MeshBasicMaterial({
color: 0x9ac7c3,
transparent: true,
opacity: 0.32
}),
rippleDark: new THREE.MeshBasicMaterial({
color: 0x376f78,
transparent: true,
opacity: 0.3
}),
brick: new THREE.MeshStandardMaterial({
map: makeBrickTexture(),
roughness: 0.92
}),
cream: material(0xc9c3b2),
roof: material(0x4c5553, 0.72, 0.15),
window: material(0x334f53, 0.3, 0.32),
windowFrame: material(0xc4bca8),
crane: material(0xc39a43, 0.68, 0.22),
boatHull: material(0x263a3e, 0.72, 0.24),
boatDeck: material(0xb9b6a7),
boatCabin: material(0xe0ddca),
orange: material(0xc66a38),
leaf: material(0x547956),
leafLight: material(0x6e8d62),
trunk: material(0x8f7957),
person: material(0x3e5c63),
skin: material(0xb98061)
};
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function lowPolyCylinder(
topRadius,
bottomRadius,
height,
mat,
x = 0,
y = 0,
z = 0,
segments = 8,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beamBetween(a, b, thickness, mat, parent = scene) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(a, b)
.multiplyScalar(0.5);
const mesh = box(
thickness,
length,
thickness,
mat,
midpoint.x,
midpoint.y,
midpoint.z,
parent
);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function createRope(points, thickness = 0.045) {
const curve = new THREE.CatmullRomCurve3(points);
const samples = curve.getPoints(38);
for (let i = 0; i < samples.length - 1; i++) {
const a = samples[i];
const b = samples[i + 1];
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const midpoint = new THREE.Vector3()
.addVectors(a, b)
.multiplyScalar(0.5);
const segment = box(
length + thickness,
thickness,
thickness,
M.rope,
midpoint.x,
midpoint.y,
midpoint.z,
scene,
false
);
segment.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
}
}
// -------------------------------------------------------------------------
// Water and quay
// -------------------------------------------------------------------------
const water = new THREE.Mesh(
new THREE.PlaneGeometry(74, 54),
M.water
);
water.rotation.x = -Math.PI / 2;
water.position.set(0, -1.55, -25);
water.receiveShadow = true;
scene.add(water);
const ripples = [];
for (let i = 0; i < 88; i++) {
const ripple = box(
0.25 + Math.random() * 1.65,
0.012,
0.07 + Math.random() * 0.15,
i % 3 === 0 ? M.rippleDark : M.rippleLight,
-27 + Math.random() * 54,
-1.525,
-30 + Math.random() * 28.5,
scene,
false
);
ripple.userData.speed = 0.025 + Math.random() * 0.06;
ripple.userData.phase = Math.random() * Math.PI * 2;
ripples.push(ripple);
}
// Main land platform.
box(32, 0.72, 20, M.concrete, 0, -0.32, 10);
box(32, 0.1, 20, M.paving, 0, 0.045, 10, scene, false);
// Historic wharf wall and coping.
box(32, 2.8, 0.76, M.quay, 0, -1.34, 0.1);
box(32, 0.18, 0.9, M.coping, 0, 0.13, 0.04);
// Vertical expansion joints in the old quay wall.
for (let x = -15; x <= 15; x += 2) {
box(
0.035,
2.55,
0.025,
M.ironDark,
x,
-1.34,
-0.295,
scene,
false
);
}
// Timber fender piles retain the working edge character.
for (const x of [-13, -9.5, -5.8, 7.6, 11.7]) {
box(0.34, 2.6, 0.34, M.timberEnd, x, -1.42, -0.43);
box(0.42, 0.16, 0.42, M.ironDark, x, -0.35, -0.43);
}
// Existing mooring eye at the edge.
const mooringEye = new THREE.Mesh(
new THREE.TorusGeometry(0.19, 0.045, 5, 12),
M.ironDark
);
mooringEye.position.set(-4.9, -0.46, -0.43);
scene.add(mooringEye);
// -------------------------------------------------------------------------
// Retained working infrastructure: original apron and cast-iron bollard
// -------------------------------------------------------------------------
const bollardX = -3;
const bollardZ = 0.9;
// Larger, rougher slabs distinguish the retained wharf apron.
box(
2.45,
0.18,
2.05,
M.concrete,
bollardX,
0.15,
bollardZ
);
box(
2.45,
0.025,
0.035,
M.quay,
bollardX,
0.249,
bollardZ + 0.45,
scene,
false
);
// Stepped cast-iron base.
lowPolyCylinder(
0.64,
0.7,
0.2,
M.ironDark,
bollardX,
0.34,
bollardZ
);
lowPolyCylinder(
0.33,
0.4,
0.78,
M.iron,
bollardX,
0.81,
bollardZ
);
// Broad mushroom cap and upper wear plate.
lowPolyCylinder(
0.58,
0.47,
0.18,
M.iron,
bollardX,
1.27,
bollardZ
);
lowPolyCylinder(
0.47,
0.47,
0.075,
M.ironDark,
bollardX,
1.39,
bollardZ
);
// Dark band around the shaft.
lowPolyCylinder(
0.397,
0.397,
0.095,
M.ironDark,
bollardX,
0.58,
bollardZ
);
// Small side lugs reinforce the old cast form.
box(0.27, 0.14, 0.18, M.ironDark, bollardX - 0.42, 1.15, bollardZ);
box(0.27, 0.14, 0.18, M.ironDark, bollardX + 0.42, 1.15, bollardZ);
// Irregular oxidation patches.
box(
0.13,
0.16,
0.025,
M.rust,
bollardX - 0.12,
0.86,
bollardZ - 0.37,
scene,
false
);
box(
0.1,
0.1,
0.025,
M.rust,
bollardX + 0.18,
0.72,
bollardZ - 0.36,
scene,
false
);
box(
0.08,
0.11,
0.025,
M.rust,
bollardX - 0.22,
0.45,
bollardZ - 0.38,
scene,
false
);
// Functional identification plate.
const bollardPlate = new THREE.Mesh(
new THREE.PlaneGeometry(0.42, 0.2),
new THREE.MeshBasicMaterial({
map: makeTextTexture("B-07", "#d5c49c", "#39352f"),
side: THREE.DoubleSide
})
);
bollardPlate.position.set(bollardX, 0.9, bollardZ - 0.405);
bollardPlate.rotation.y = Math.PI;
scene.add(bollardPlate);
// Coiled working rope on the original apron.
const coilOne = new THREE.Mesh(
new THREE.TorusGeometry(0.24, 0.055, 4, 18),
M.rope
);
coilOne.rotation.x = Math.PI / 2;
coilOne.position.set(-3.76, 0.29, 1.15);
coilOne.castShadow = true;
scene.add(coilOne);
const coilTwo = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.052, 4, 16),
M.rope
);
coilTwo.rotation.x = Math.PI / 2;
coilTwo.position.set(-3.69, 0.35, 1.12);
coilTwo.castShadow = true;
scene.add(coilTwo);
// -------------------------------------------------------------------------
// Added public-space layer: new pavers and timber-seat module
// -------------------------------------------------------------------------
const paverMaterials = [M.paverLight, M.paverWarm, M.paving];
for (let row = 0; row < 6; row++) {
for (let col = 0; col < 8; col++) {
const paver = box(
0.76,
0.08,
0.67,
paverMaterials[(row + col * 2) % paverMaterials.length],
0.02 + col * 0.8,
0.12,
0.72 + row * 0.7,
scene,
false
);
paver.receiveShadow = true;
}
}
// Edge datum: a narrow public-realm safety strip.
for (let x = 0; x < 6.4; x += 0.8) {
box(
0.62,
0.018,
0.065,
M.crane,
x + 0.18,
0.176,
0.46,
scene,
false
);
}
const benchX = 2.5;
const benchZ = 1.78;
// Blackened steel understructure.
for (const xOffset of [-1.27, 1.27]) {
for (const zOffset of [-0.29, 0.29]) {
box(
0.09,
0.48,
0.09,
M.steel,
benchX + xOffset,
0.4,
benchZ + zOffset
);
}
// Angled back support.
const backSupport = box(
0.085,
0.96,
0.085,
M.steel,
benchX + xOffset,
0.87,
benchZ + 0.39
);
backSupport.rotation.x = -0.1;
}
// Longitudinal seat frame.
for (const zOffset of [-0.3, 0.3]) {
box(
2.95,
0.075,
0.075,
M.steel,
benchX,
0.54,
benchZ + zOffset
);
}
// Five timber seat slats.
for (let i = 0; i < 5; i++) {
box(
3.42,
0.095,
0.145,
M.timber,
benchX,
0.625,
benchZ - 0.34 + i * 0.17
);
}
// Three horizontal backrest slats.
for (let i = 0; i < 3; i++) {
const backSlat = box(
3.42,
0.13,
0.09,
M.timber,
benchX,
0.86 + i * 0.19,
benchZ + 0.43
);
backSlat.rotation.x = -0.1;
}
// Slim end armrests.
for (const xOffset of [-1.7, 1.7]) {
box(
0.07,
0.07,
0.78,
M.steel,
benchX + xOffset,
0.84,
benchZ + 0.12
);
box(
0.07,
0.28,
0.07,
M.steel,
benchX + xOffset,
0.71,
benchZ - 0.22
);
}
// Small public-space identification plate.
const seatPlate = new THREE.Mesh(
new THREE.PlaneGeometry(0.57, 0.14),
new THREE.MeshBasicMaterial({
map: makeTextTexture("PUBLIC SEAT", "#26302f", "#ede9dc"),
side: THREE.DoubleSide
})
);
seatPlate.position.set(benchX + 1.0, 0.54, benchZ - 0.415);
seatPlate.rotation.y = Math.PI;
scene.add(seatPlate);
// -------------------------------------------------------------------------
// Working context: small harbour service launch and active mooring line
// -------------------------------------------------------------------------
const boatX = -7.2;
const boatZ = -5.8;
box(4.6, 0.34, 1.78, M.boatHull, boatX, -1.15, boatZ);
box(3.95, 0.27, 1.42, M.boatHull, boatX, -1.43, boatZ);
box(4.35, 0.1, 1.62, M.boatDeck, boatX, -0.94, boatZ);
box(1.45, 0.94, 1.25, M.boatCabin, boatX + 0.65, -0.48, boatZ);
box(1.54, 0.1, 1.34, M.boatDeck, boatX + 0.65, 0.03, boatZ);
// Cabin windows.
box(1.12, 0.4, 0.055, M.window, boatX + 0.65, -0.39, boatZ - 0.65);
box(0.055, 0.4, 0.93, M.window, boatX - 0.1, -0.39, boatZ);
// Workboat mast and navigation light.
box(0.07, 1.75, 0.07, M.steel, boatX - 1.2, 0.16, boatZ);
box(0.12, 0.12, 0.12, M.orange, boatX - 1.2, 1.09, boatZ);
box(0.12, 0.16, 0.12, M.ironDark, boatX + 1.8, -0.72, boatZ);
// Utility label on the cabin.
const boatLabel = new THREE.Mesh(
new THREE.PlaneGeometry(0.72, 0.2),
new THREE.MeshBasicMaterial({
map: makeTextTexture("HARBOUR", "#dfd9c7", "#344244"),
side: THREE.DoubleSide
})
);
boatLabel.position.set(boatX + 0.65, -0.69, boatZ - 0.66);
boatLabel.rotation.y = Math.PI;
scene.add(boatLabel);
createRope([
new THREE.Vector3(boatX + 2.02, -0.7, boatZ),
new THREE.Vector3(-4.45, -0.54, -3.55),
new THREE.Vector3(-3.72, 0.08, -1.35),
new THREE.Vector3(bollardX - 0.34, 0.72, bollardZ - 0.34)
]);
// -------------------------------------------------------------------------
// Wynyard Quarter industrial context
// -------------------------------------------------------------------------
// Main brick warehouse.
box(14, 7, 8, M.brick, -7, 3.5, 13);
box(14.3, 0.35, 8.25, M.roof, -7, 7.12, 13);
box(14.2, 0.8, 8.1, M.quay, -7, 0.45, 13);
// Voxel sawtooth roof monitors.
for (let i = 0; i < 4; i++) {
box(2.3, 0.75, 5.9, M.roof, -11.8 + i * 3.2, 7.58, 13);
box(0.24, 1.1, 6, M.window, -12.8 + i * 3.2, 7.62, 13);
}
// Front windows with pale masonry frames.
for (const y of [1.65, 3.35, 5.05]) {
for (const x of [-12.3, -9.2, -6.1, -3]) {
box(1.55, 1.45, 0.08, M.windowFrame, x, y, 8.94);
box(1.3, 1.2, 0.06, M.window, x, y, 8.88);
box(0.055, 1.2, 0.075, M.windowFrame, x, y, 8.84);
}
}
// Wynyard sign.
const wynyardSign = new THREE.Mesh(
new THREE.PlaneGeometry(4.8, 1.05),
new THREE.MeshBasicMaterial({
map: makeTextTexture("WYN YARD", "#26302f", "#eee8d8"),
side: THREE.DoubleSide
})
);
wynyardSign.position.set(-6.7, 5.6, 8.81);
wynyardSign.rotation.y = Math.PI;
scene.add(wynyardSign);
// Secondary light industrial building.
box(10, 4.7, 6, M.cream, 8.8, 2.35, 14);
box(10.3, 0.28, 6.25, M.roof, 8.8, 4.78, 14);
box(10.2, 0.55, 6.1, M.quay, 8.8, 0.32, 14);
for (const x of [5.3, 7.2, 9.1, 11, 12.9]) {
box(1.05, 1.35, 0.08, M.windowFrame, x, 2.5, 10.94);
box(0.82, 1.12, 0.06, M.window, x, 2.5, 10.88);
}
// Retained crane silhouette.
box(0.36, 7.4, 0.36, M.crane, -13.2, 3.7, 7.25);
box(6.1, 0.25, 0.3, M.crane, -10.15, 7.25, 7.25);
box(1.4, 0.45, 0.7, M.crane, -14.05, 7.2, 7.25);
beamBetween(
new THREE.Vector3(-13.2, 4.7, 7.25),
new THREE.Vector3(-10.9, 7.2, 7.25),
0.18,
M.crane
);
box(0.035, 3.1, 0.035, M.steel, -8.4, 5.63, 7.25);
box(0.3, 0.3, 0.3, M.ironDark, -8.4, 4.0, 7.25);
// -------------------------------------------------------------------------
// Public-realm planting and scale figure
// -------------------------------------------------------------------------
// Voxel palm tree.
const palmX = 6.6;
const palmZ = 4.3;
for (let i = 0; i < 8; i++) {
box(
0.32,
0.62,
0.32,
M.trunk,
palmX + i * 0.035,
0.46 + i * 0.59,
palmZ,
scene,
true
);
}
const palmTopY = 5.12;
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const leaf = box(
2.25,
0.18,
0.4,
i % 2 ? M.leaf : M.leafLight,
palmX + Math.sin(angle) * 0.82,
palmTopY + (i % 2 ? 0.08 : -0.03),
palmZ + Math.cos(angle) * 0.82
);
leaf.rotation.y = angle;
leaf.rotation.z = i % 2 ? 0.13 : -0.13;
}
// Stylized standing visitor for scale.
const personX = 4.75;
const personZ = 3.35;
box(0.16, 0.14, 0.32, M.ironDark, personX - 0.12, 0.22, personZ);
box(0.16, 0.14, 0.32, M.ironDark, personX + 0.12, 0.22, personZ);
box(0.14, 0.68, 0.16, M.person, personX - 0.12, 0.62, personZ);
box(0.14, 0.68, 0.16, M.person, personX + 0.12, 0.62, personZ);
box(0.48, 0.57, 0.26, M.person, personX, 1.24, personZ);
box(0.12, 0.52, 0.14, M.person, personX - 0.3, 1.2, personZ);
box(0.12, 0.52, 0.14, M.person, personX + 0.3, 1.2, personZ);
box(0.31, 0.32, 0.3, M.skin, personX, 1.67, personZ);
// -------------------------------------------------------------------------
// Custom orbit, pan and zoom controls — no Three.js addons
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0, 1.1, 2);
const spherical = new THREE.Spherical(25, 1.08, 2.53);
const defaultTarget = target.clone();
const defaultSpherical = spherical.clone();
let dragging = false;
let pointerButton = 0;
let lastX = 0;
let lastY = 0;
const pointerMap = new Map();
let pinchDistance = 0;
function updateCamera() {
const offset = new THREE.Vector3().setFromSpherical(spherical);
camera.position.copy(target).add(offset);
camera.lookAt(target);
}
function resetView() {
target.copy(defaultTarget);
spherical.copy(defaultSpherical);
updateCamera();
}
renderer.domElement.addEventListener("contextmenu", event => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", event => {
pointerMap.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerMap.size === 2) {
const points = [...pointerMap.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
dragging = true;
pointerButton = event.button;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerMap.has(event.pointerId)) return;
pointerMap.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerMap.size === 2) {
const points = [...pointerMap.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0 && distance > 0) {
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * (pinchDistance / distance),
9,
42
);
pinchDistance = distance;
}
return;
}
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
const wantsPan = event.shiftKey || pointerButton === 2;
if (wantsPan) {
const right = new THREE.Vector3();
camera.getWorldDirection(right);
right.y = 0;
right.normalize();
const forward = new THREE.Vector3()
.subVectors(target, camera.position);
forward.y = 0;
forward.normalize();
const panScale = spherical.radius * 0.0011;
target.addScaledVector(right, -dx * panScale);
target.addScaledVector(forward, -dy * panScale);
target.x = THREE.MathUtils.clamp(target.x, -12, 12);
target.z = THREE.MathUtils.clamp(target.z, -5, 12);
} else {
spherical.theta -= dx * 0.005;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - dy * 0.004,
0.28,
1.46
);
}
});
function endPointer(event) {
pointerMap.delete(event.pointerId);
if (pointerMap.size < 2) {
pinchDistance = 0;
}
if (pointerMap.size === 0) {
dragging = false;
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * Math.exp(event.deltaY * 0.001),
9,
42
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") {
resetView();
}
});
// -------------------------------------------------------------------------
// Projected scene labels
// -------------------------------------------------------------------------
const bollardCallout = document.getElementById("bollard-callout");
const benchCallout = document.getElementById("bench-callout");
const bollardLabelPoint = new THREE.Vector3(
bollardX,
1.36,
bollardZ
);
const benchLabelPoint = new THREE.Vector3(
benchX,
1.12,
benchZ
);
const projected = new THREE.Vector3();
function updateCallout(element, worldPoint) {
projected.copy(worldPoint).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.25 &&
Math.abs(projected.y) < 1.25;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
let previousTime = performance.now();
function animate(time) {
requestAnimationFrame(animate);
const delta = Math.min((time - previousTime) / 1000, 0.05);
previousTime = time;
updateCamera();
for (const ripple of ripples) {
ripple.position.z += ripple.userData.speed * delta;
if (ripple.position.z > -0.8) {
ripple.position.z = -30;
ripple.position.x = -27 + Math.random() * 54;
}
ripple.position.y =
-1.525 + Math.sin(time * 0.0008 + ripple.userData.phase) * 0.006;
}
updateCallout(bollardCallout, bollardLabelPoint);
updateCallout(benchCallout, benchLabelPoint);
renderer.render(scene, camera);
}
resetView();
requestAnimationFrame(animate);
</script>
</body>
</html>
```