Prompt specification
Build or customize the Three.js 3D scene "Suzhou Creek warehouse window and quay detail" 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: Suzhou Creek warehouse window and quay detail
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/suzhou-creek-warehouse-window-and-quay-detail-x3021
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: Suzhou Creek warehouse window and quay detail. Build a referenced warehouse facade bay beside a quay-edge railing. Show the industrial building's structural rhythm separately from the newer public walking surface. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (suzhou-creek-warehouse-window-and-quay-detail-x3021):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Suzhou Creek — Warehouse Bay & Public Quay</title>
<style>
:root {
color-scheme: light;
--ink: #172b2b;
--muted: #5d706e;
--paper: rgba(246, 242, 231, 0.92);
--line: rgba(23, 43, 43, 0.16);
--old: #8b4d3d;
--new: #71817d;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe5e1;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#app {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.title-block {
position: fixed;
top: 28px;
left: 30px;
z-index: 10;
pointer-events: none;
max-width: 430px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 9px;
color: #526765;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 2px;
background: var(--old);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3.6vw, 52px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
letter-spacing: 0.02em;
}
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid var(--line);
box-shadow: 0 12px 35px rgba(34, 49, 47, 0.09);
backdrop-filter: blur(12px);
}
.controls {
top: 28px;
right: 28px;
display: flex;
align-items: center;
gap: 8px;
padding: 7px;
border-radius: 10px;
}
button {
appearance: none;
border: 0;
border-radius: 6px;
padding: 9px 12px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.025em;
cursor: pointer;
transition: background 160ms ease, color 160ms ease;
}
button:hover {
background: rgba(23, 43, 43, 0.07);
}
button.active {
background: var(--ink);
color: #f6f2e7;
}
button:focus-visible {
outline: 2px solid #a65a46;
outline-offset: 2px;
}
.legend {
left: 28px;
bottom: 27px;
width: 270px;
padding: 16px 17px 14px;
border-radius: 10px;
}
.legend-title {
margin-bottom: 12px;
color: #6a7b78;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 22px 1fr;
gap: 10px;
align-items: start;
padding: 8px 0;
}
.legend-row + .legend-row {
border-top: 1px solid var(--line);
}
.swatch {
width: 20px;
height: 20px;
margin-top: 1px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch.old {
background:
linear-gradient(90deg, transparent 46%, #303f3c 47% 53%, transparent 54%),
#8b4d3d;
}
.swatch.new {
background:
linear-gradient(90deg, transparent 46%, #304a49 47% 53%, transparent 54%),
#b9b8ad;
}
.legend-name {
font-size: 11px;
font-weight: 750;
letter-spacing: 0.035em;
}
.legend-note {
margin-top: 3px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.hint {
position: fixed;
right: 29px;
bottom: 28px;
z-index: 10;
padding: 8px 11px;
border-radius: 7px;
background: rgba(246, 242, 231, 0.72);
color: #60716f;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 720px) {
.title-block {
top: 20px;
left: 20px;
max-width: calc(100% - 40px);
}
.subtitle { display: none; }
.controls {
top: auto;
right: 16px;
bottom: 67px;
}
.legend {
left: 16px;
bottom: 16px;
width: min(270px, calc(100% - 32px));
}
.hint { display: none; }
}
</style>
</head>
<body>
<main id="app" aria-label="Interactive voxel scene of a Suzhou Creek warehouse bay and public quay"></main>
<header class="title-block">
<div class="eyebrow">Suzhou Creek · East Bank</div>
<h1>Warehouse bay<br>at the water’s edge</h1>
<p class="subtitle">
A voxel study of the industrial facade rhythm beside a contemporary public quay.
</p>
</header>
<nav class="controls panel" aria-label="Scene controls">
<button id="separate" type="button">Separate layers</button>
<button id="reset" type="button">Reset view</button>
</nav>
<aside class="legend panel" aria-label="Architectural layer legend">
<div class="legend-title">Two waterfront layers</div>
<div class="legend-row">
<span class="swatch old" aria-hidden="true"></span>
<div>
<div class="legend-name">Industrial fabric</div>
<div class="legend-note">Brick piers, steel mullions and deep industrial windows.</div>
</div>
</div>
<div class="legend-row">
<span class="swatch new" aria-hidden="true"></span>
<div>
<div class="legend-name">New public surface</div>
<div class="legend-note">Light granite paving, a slender rail and a clear edge line.</div>
</div>
</div>
</aside>
<div class="hint">Drag to orbit · Shift-drag to pan · Scroll to zoom</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Voxel warehouse and quay scene");
renderer.domElement.tabIndex = 0;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe5e1);
scene.fog = new THREE.Fog(0xdbe5e1, 38, 76);
const environment = new THREE.Group();
const warehouse = new THREE.Group();
const publicQuay = new THREE.Group();
scene.add(environment, warehouse, publicQuay);
const camera = new THREE.OrthographicCamera(-20, 20, 12, -12, 0.1, 120);
const cameraTarget = new THREE.Vector3(0, 3.6, -0.4);
const spherical = new THREE.Spherical(36, 1.04, 0.46);
const hemi = new THREE.HemisphereLight(0xf4f0df, 0x637a78, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0d4, 3.25);
sun.position.set(-13, 22, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.0007;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fc1c1, 0.65);
fill.position.set(18, 8, -15);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.0,
...options
});
}
const M = {
water: material(0x527d83, { roughness: 0.32, metalness: 0.08 }),
ripple: material(0x8fb1b0, { roughness: 0.48 }),
rippleLight: material(0xb0c8c2, { roughness: 0.58 }),
quay: material(0x777b72),
quayDark: material(0x565f5b),
quayLight: material(0x929287),
coping: material(0xc7c5b9),
oldApron: material(0x70463c),
paver: material(0xb9b8ad),
paverAlt: material(0xc5c3b8),
paverDark: material(0xa6aaa3),
rail: material(0x2f4543, { roughness: 0.58, metalness: 0.38 }),
steel: material(0x344844, { roughness: 0.56, metalness: 0.42 }),
brickDark: material(0x69352f),
roof: material(0x454a45),
roofEdge: material(0x68635a),
stone: material(0xb8aa8c),
stoneDark: material(0x8e826c),
glass: material(0x769a98, { roughness: 0.28, metalness: 0.18 }),
glassAlt: material(0x567b7d, { roughness: 0.3, metalness: 0.16 }),
glassWarm: material(0xb19462, {
roughness: 0.38,
emissive: 0x4b2e13,
emissiveIntensity: 0.18
}),
black: material(0x172a29),
wood: material(0x80654b)
};
function box(size, position, mat, parent = scene, castShadow = true, receiveShadow = true) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
// Water plane and distant, quiet creek context.
box([90, 0.24, 70], [0, -0.18, 37.2], M.water, environment, false, true);
box([48, 0.12, 5], [0, -0.08, -12.5], M.quayDark, environment, false, true);
const ripples = [];
let seed = 17;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 34; i++) {
const width = 0.65 + random() * 2.4;
const ripple = box(
[width, 0.028, 0.055 + random() * 0.045],
[
-19 + random() * 38,
0.015,
2.9 + random() * 17
],
i % 3 === 0 ? M.rippleLight : M.ripple,
environment,
false,
false
);
ripple.userData.baseX = ripple.position.x;
ripple.userData.phase = random() * Math.PI * 2;
ripple.userData.speed = 0.18 + random() * 0.22;
ripples.push(ripple);
}
// Heavy historic quay wall and its newer stone walking surface.
box([34, 1.48, 4.65], [0, 0.65, -0.25], M.quay, publicQuay);
box([34.15, 0.18, 4.78], [0, 1.39, -0.25], M.quayDark, publicQuay);
for (let x = -15.75; x < 16; x += 2.1) {
box(
[2.02, 1.12, 0.11],
[x + 0.98, 0.65, 2.11],
random() > 0.5 ? M.quayLight : M.quay,
publicQuay
);
}
// A narrow old loading apron separates the warehouse from the new promenade.
box([33.8, 0.15, 1.12], [0, 1.48, -1.91], M.oldApron, publicQuay);
for (let x = -16.5; x < 17; x += 1.25) {
box([1.17, 0.025, 1.02], [x, 1.565, -1.91], M.brickDark, publicQuay);
}
// Contemporary granite pavers, visibly lighter and orthogonal to the old fabric.
for (let ix = 0; ix < 12; ix++) {
for (let iz = 0; iz < 2; iz++) {
const mat = (ix + iz) % 4 === 0 ? M.paverDark : (ix % 2 ? M.paver : M.paverAlt);
box(
[2.72, 0.16, 1.34],
[-15.35 + ix * 2.8, 1.57, -0.86 + iz * 1.39],
mat,
publicQuay
);
}
}
// Crisp coping blocks establish the new quay edge.
for (let x = -16.4; x < 17; x += 2.05) {
box(
[1.98, 0.24, 0.46],
[x + 0.98, 1.61, 1.78],
M.coping,
publicQuay
);
}
// Slender public railing: posts, top rail, mid rail and fine vertical infill.
const railZ = 1.83;
const railStart = -16;
const railEnd = 16;
for (let x = railStart; x <= railEnd; x += 1.5) {
box([0.12, 1.18, 0.12], [x, 2.28, railZ], M.rail, publicQuay);
box([0.28, 0.055, 0.28], [x, 1.7, railZ], M.steel, publicQuay);
}
box([32.15, 0.13, 0.13], [0, 2.88, railZ], M.rail, publicQuay);
box([32.15, 0.075, 0.075], [0, 2.36, railZ], M.rail, publicQuay);
box([32.15, 0.055, 0.055], [0, 1.88, railZ], M.rail, publicQuay);
for (let x = railStart + 0.38; x < railEnd; x += 0.5) {
box([0.035, 0.9, 0.035], [x, 2.35, railZ], M.rail, publicQuay);
}
// Historic mooring fittings contrast with the lighter public promenade.
for (const x of [-13.2, -6.4, 5.7, 12.4]) {
box([0.6, 0.14, 0.22], [x, 1.72, 2.24], M.black, publicQuay);
box([0.12, 0.5, 0.12], [x - 0.22, 1.96, 2.28], M.black, publicQuay);
box([0.12, 0.5, 0.12], [x + 0.22, 1.96, 2.28], M.black, publicQuay);
box([0.56, 0.12, 0.12], [x, 2.18, 2.28], M.black, publicQuay);
}
// Minimal modern furniture.
function bench(x, z) {
box([0.16, 0.7, 0.48], [x - 0.72, 1.95, z], M.rail, publicQuay);
box([0.16, 0.7, 0.48], [x + 0.72, 1.95, z], M.rail, publicQuay);
box([2.05, 0.13, 0.58], [x, 2.24, z], M.wood, publicQuay);
box([2.05, 0.36, 0.1], [x, 2.53, z - 0.25], M.wood, publicQuay);
}
bench(-8.8, -0.5);
bench(9.5, -0.55);
// A quiet wayfinding marker on the newer surface.
box([0.15, 1.65, 0.48], [5.5, 2.43, -0.58], M.rail, publicQuay);
box([0.035, 0.34, 0.32], [5.59, 2.88, -0.58], M.coping, publicQuay);
// Warehouse massing.
box([28.4, 7.65, 6.0], [0, 5.28, -5.65], M.brickDark, warehouse);
box([28.85, 0.38, 6.35], [0, 9.26, -5.72], M.roof, warehouse);
box([29.1, 0.17, 6.52], [0, 9.5, -5.72], M.roofEdge, warehouse);
box([28.9, 0.72, 0.72], [0, 1.88, -2.54], M.brickDark, warehouse);
// Repeated piers establish the warehouse's structural rhythm.
const boundaries = [-14, -10, -6, -2, 2, 6, 10, 14];
for (const x of boundaries) {
box([0.78, 7.38, 0.52], [x, 5.15, -2.47], M.brickDark, warehouse);
box([0.14, 7.02, 0.16], [x, 5.15, -2.15], M.steel, warehouse);
box([0.98, 0.24, 0.72], [x, 1.78, -2.43], M.stoneDark, warehouse);
}
// Horizontal masonry bands and cornice.
box([28.65, 0.4, 0.68], [0, 7.83, -2.39], M.stoneDark, warehouse);
box([28.45, 0.17, 0.79], [0, 8.08, -2.42], M.brickDark, warehouse);
box([28.85, 0.24, 0.84], [0, 8.83, -2.45], M.stoneDark, warehouse);
box([29.1, 0.19, 0.94], [0, 9.04, -2.48], M.stone, warehouse);
// Brick veneer is instanced for a crisp voxel bond.
const brickTransforms = [];
const brickColors = [
new THREE.Color(0x81463a),
new THREE.Color(0x914e3e),
new THREE.Color(0x743d34),
new THREE.Color(0x9a5542),
new THREE.Color(0x875044)
];
function openingFor(bayIndex) {
const center = bayIndex === 3 ? 0 : boundaries[bayIndex] + 2;
if (bayIndex === 3) {
return { center, left: -1.55, right: 1.55, bottom: 2.53, top: 6.65, width: 3.1, height: 4.12 };
}
const width = 2.62;
return {
center,
left: center - width / 2,
right: center + width / 2,
bottom: 2.76,
top: 6.18,
width,
height: 3.42
};
}
for (let bay = 0; bay < 7; bay++) {
const left = boundaries[bay] + 0.48;
const right = boundaries[bay + 1] - 0.48;
const opening = openingFor(bay);
box(
[right - left, 7.0, 0.12],
[(left + right) / 2, 5.04, -2.66],
M.brickDark,
warehouse
);
for (let row = 0; row < 18; row++) {
const y = 1.72 + row * 0.4;
let x = left - (row % 2 ? 0.36 : 0);
while (x + 0.36 < right) {
const cx = x + 0.36;
const overlapsOpening =
cx + 0.36 > opening.left &&
cx - 0.36 < opening.right &&
y + 0.16 > opening.bottom &&
y - 0.16 < opening.top;
if (!overlapsOpening) {
brickTransforms.push({
position: [cx, y, -2.5],
scale: [0.72, 0.32, 0.13],
color: brickColors[Math.floor(random() * brickColors.length)]
});
}
x += 0.72;
}
}
}
const brickMaterial = material(0xffffff, { vertexColors: true });
const bricks = new THREE.InstancedMesh(unitBox, brickMaterial, brickTransforms.length);
const matrix = new THREE.Matrix4();
const quaternion = new THREE.Quaternion();
brickTransforms.forEach((brick, index) => {
matrix.compose(
new THREE.Vector3(...brick.position),
quaternion,
new THREE.Vector3(...brick.scale)
);
bricks.setMatrixAt(index, matrix);
bricks.setColorAt(index, brick.color);
});
bricks.instanceMatrix.needsUpdate = true;
if (bricks.instanceColor) bricks.instanceColor.needsUpdate = true;
bricks.castShadow = true;
bricks.receiveShadow = true;
warehouse.add(bricks);
function industrialWindow(opening, detailed = false) {
const { center: cx, bottom, width, height } = opening;
const cols = detailed ? 3 : 2;
const rows = detailed ? 4 : 3;
const gap = detailed ? 0.075 : 0.065;
box(
[width + 0.34, height + 0.34, 0.18],
[cx, bottom + height / 2, -2.19],
M.black,
warehouse
);
const paneW = (width - gap * (cols - 1)) / cols;
const paneH = (height - gap * (rows - 1)) / rows;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
let paneMat = (row + col) % 3 === 0 ? M.glassAlt : M.glass;
if (detailed && row === 0 && col === 1) paneMat = M.glassWarm;
box(
[paneW, paneH, 0.065],
[
cx - width / 2 + paneW / 2 + col * (paneW + gap),
bottom + paneH / 2 + row * (paneH + gap),
-2.075
],
paneMat,
warehouse
);
}
}
for (let col = 1; col < cols; col++) {
const x = cx - width / 2 + col * (paneW + gap) - gap / 2;
box([0.055, height, 0.11], [x, bottom + height / 2, -2.02], M.steel, warehouse);
}
for (let row = 1; row < rows; row++) {
const y = bottom + row * (paneH + gap) - gap / 2;
box([width, 0.055, 0.11], [cx, y, -2.02], M.steel, warehouse);
}
box(
[width + 0.55, 0.17, 0.46],
[cx, bottom - 0.09, -2.08],
M.stoneDark,
warehouse
);
// Stepped stone voussoirs suggest a shallow segmental warehouse arch.
const steps = detailed ? 5 : 4;
for (const side of [-1, 1]) {
for (let step = 0; step < steps; step++) {
const x = cx + side * (width / 2 + 0.18 - step * (detailed ? 0.27 : 0.29));
const y = bottom + height + 0.1 + step * 0.19;
box(
[0.43, 0.3, 0.42],
[x, y, -2.19],
step % 2 ? M.stone : M.stoneDark,
warehouse
);
}
}
}
for (let bay = 0; bay < 7; bay++) {
industrialWindow(openingFor(bay), bay === 3);
}
// Side elevation: repeated loading-bay windows and pilasters.
for (const z of [-4.0, -6.15, -8.25]) {
box([0.16, 1.7, 1.3], [14.28, 4.35, z], M.black, warehouse);
box([0.06, 1.42, 1.05], [14.38, 4.35, z], M.glassAlt, warehouse);
box([0.09, 1.55, 0.07], [14.45, 4.35, z], M.steel, warehouse);
}
for (const z of [-3.45, -5.55, -7.65]) {
box([0.36, 7.1, 0.43], [14.22, 5.14, z], M.brickDark, warehouse);
}
// Voxel roof monitors and skylights.
for (const x of [-10, -5, 0, 5, 10]) {
box([2.5, 0.36, 2.0], [x, 9.64, -5.7], M.roofEdge, warehouse);
box([2.12, 0.08, 1.62], [x, 9.86, -5.7], M.glassAlt, warehouse);
box([0.09, 0.13, 1.67], [x, 9.93, -5.7], M.steel, warehouse);
}
// Small voxel utility stacks reinforce the industrial roofline.
for (const x of [-11.8, 8.8, 12.1]) {
box([0.75, 1.25, 0.8], [x, 10.05, -6.8], M.roofEdge, warehouse);
box([0.96, 0.16, 1.0], [x, 10.72, -6.8], M.roof, warehouse);
}
// Camera controls implemented directly, without Three.js addons.
let zoom = 1;
let separation = 0;
let separationTarget = 0;
const pointers = new Map();
let previousPinchDistance = 0;
const halfHeight = 11.5;
function updateCamera() {
spherical.phi = THREE.MathUtils.clamp(spherical.phi, 0.55, 1.43);
const offset = new THREE.Vector3().setFromSpherical(spherical);
camera.position.copy(cameraTarget).add(offset);
camera.lookAt(cameraTarget);
camera.updateProjectionMatrix();
}
function updateProjection(first = false) {
const aspect = window.innerWidth / window.innerHeight;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
if (first) zoom = Math.min(1, (halfHeight * 2 * aspect) / 31.5);
camera.zoom = zoom;
updateCamera();
}
function resetView() {
cameraTarget.set(0, 3.6, -0.4);
spherical.set(36, 1.04, 0.46);
zoom = Math.min(1, (halfHeight * 2 * (window.innerWidth / window.innerHeight)) / 31.5);
updateProjection();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
button: event.button,
shift: event.shiftKey
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
previous.x = event.clientX;
previous.y = event.clientY;
previous.shift = event.shiftKey;
if (pointers.size === 1) {
if (previous.shift || previous.button === 2) {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
const right = new THREE.Vector3().crossVectors(forward, camera.up).normalize();
const scale = 0.018 * zoom;
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.y += dy * scale;
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -12, 12);
cameraTarget.y = THREE.MathUtils.clamp(cameraTarget.y, 0.8, 8);
} else {
spherical.theta -= dx * 0.005;
spherical.phi -= dy * 0.004;
}
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance > 0 && distance > 0) {
zoom = THREE.MathUtils.clamp(zoom * distance / previousPinchDistance, 0.22, 2.4);
}
previousPinchDistance = distance;
}
updateProjection();
});
function endPointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(zoom * Math.exp(-event.deltaY * 0.001), 0.22, 2.4);
updateProjection();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
const separateButton = document.getElementById("separate");
const resetButton = document.getElementById("reset");
separateButton.addEventListener("click", () => {
separationTarget = separationTarget ? 0 : 1;
separateButton.classList.toggle("active", Boolean(separationTarget));
separateButton.textContent = separationTarget ? "Combine layers" : "Separate layers";
});
resetButton.addEventListener("click", resetView);
window.addEventListener("resize", () => {
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateProjection();
});
updateProjection(true);
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
if (!reducedMotion) {
for (const ripple of ripples) {
ripple.position.x =
ripple.userData.baseX +
Math.sin(elapsed * ripple.userData.speed + ripple.userData.phase) * 0.28;
}
separation += (separationTarget - separation) * 0.055;
} else {
separation = separationTarget;
}
warehouse.position.z = -separation * 1.65;
publicQuay.position.z = separation * 1.15;
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```