Prompt specification
Build or customize the Three.js 3D scene "Abra passenger reaching a Dubai Creek lane" 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: Abra passenger reaching a Dubai Creek lane
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/abra-passenger-reaching-a-dubai-creek-lane-x2906
Scene Description Prompt:
Abra passenger reaching a Dubai Creek lane. Create a compact referenced vignette with abra landing, passenger, and shaded lane entrance. Keep the boat-to-shore transfer and street route visibly connected. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (abra-passenger-reaching-a-dubai-creek-lane-x2906):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Abra Passenger — Dubai Creek</title>
<style>
:root {
--ink: #153c3c;
--muted: #557271;
--paper: rgba(247, 241, 220, 0.9);
--line: rgba(21, 60, 60, 0.16);
--accent: #dc704d;
--water: #238c9b;
--route: #e2a83d;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
}
#title-card {
top: 22px;
left: 22px;
max-width: 330px;
padding: 17px 19px 16px;
border: 1px solid var(--line);
border-radius: 4px;
background: var(--paper);
box-shadow: 0 14px 35px rgba(37, 67, 64, 0.12);
backdrop-filter: blur(9px);
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 34px);
line-height: 0.98;
letter-spacing: -0.045em;
}
#title-card p {
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
#legend {
left: 22px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 13px;
padding: 10px 13px;
border: 1px solid var(--line);
border-radius: 4px;
background: rgba(247, 241, 220, 0.84);
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 8px;
height: 8px;
border-radius: 1px;
background: var(--water);
}
.swatch.route { background: var(--route); }
.swatch.arch { background: #b98c61; }
#controls {
top: 22px;
right: 22px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--paper);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition: transform 120ms ease, background 120ms ease;
}
button:hover {
background: #fff8e8;
transform: translateY(-1px);
}
#labels {
position: fixed;
z-index: 5;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.callout {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 5px 8px;
border: 1px solid rgba(21, 60, 60, 0.18);
border-radius: 2px;
background: rgba(249, 243, 222, 0.88);
color: var(--ink);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.09em;
line-height: 1;
text-transform: uppercase;
white-space: nowrap;
box-shadow: 0 5px 14px rgba(28, 57, 55, 0.09);
transform: translate(-50%, -50%);
backdrop-filter: blur(4px);
}
.callout::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--water);
content: "";
}
.callout.route::before { background: var(--route); }
.callout.lane::before { background: #b98c61; }
.callout.passenger::before { background: var(--accent); }
.edge-note {
position: fixed;
z-index: 4;
right: 22px;
bottom: 20px;
color: rgba(21, 60, 60, 0.58);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 700px) {
#title-card {
top: 12px;
left: 12px;
max-width: 260px;
padding: 13px 14px;
}
#title-card p { display: none; }
#controls { top: 12px; right: 12px; }
#legend { left: 12px; bottom: 12px; gap: 9px; }
.edge-note { display: none; }
.callout { font-size: 8px; }
.callout.route { display: none; }
}
</style>
</head>
<body>
<main id="app" aria-label="Interactive voxel scene of an abra passenger reaching a Dubai Creek lane"></main>
<section id="title-card" class="hud">
<div class="eyebrow">Dubai Creek · Voxel Vignette 01</div>
<h1>Abra passenger<br>reaching the lane</h1>
<p>A compact boat-to-shore study with a visible landing plank, passenger transfer, and continuous street route into a shaded creek arch.</p>
</section>
<section id="legend" class="hud">
<span class="legend-item"><i class="swatch"></i>Creek</span>
<span class="legend-item"><i class="swatch route"></i>Walking route</span>
<span class="legend-item"><i class="swatch arch"></i>Lane entrance</span>
</section>
<nav id="controls" class="hud" aria-label="Camera controls">
<button id="reset" type="button">Reset view</button>
</nav>
<div id="labels" aria-hidden="true">
<div class="callout">Abra landing</div>
<div class="callout passenger">Passenger transfer</div>
<div class="callout route">Connected route</div>
<div class="callout lane">Shaded creek lane</div>
</div>
<div class="edge-note">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";
// ------------------------------------------------------------
// Scene and renderer
// ------------------------------------------------------------
const app = document.querySelector("#app");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9e3);
scene.fog = new THREE.Fog(0xdce9e3, 25, 43);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
app.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const cameraTarget = new THREE.Vector3(-0.15, 0.85, 0.15);
const hemisphere = new THREE.HemisphereLight(0xe4f2ef, 0x806445, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffefd2, 4.2);
sun.position.set(-5, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(
window.innerWidth < 700 ? 1024 : 2048,
window.innerWidth < 700 ? 1024 : 2048
);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8bc9d0, 1.05);
fill.position.set(9, 6, -8);
scene.add(fill);
// ------------------------------------------------------------
// Voxel construction helpers
// ------------------------------------------------------------
const materialCache = new Map();
function material(color, options = {}) {
const key = `${color}|${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.86,
metalness: options.metalness ?? 0,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0
})
);
}
return materialCache.get(key);
}
function box(w, h, d, x, y, z, color, parent = scene, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
options.material || material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function seededRandom(seed) {
let value = seed >>> 0;
return () => {
value = (value * 1664525 + 1013904223) >>> 0;
return value / 4294967296;
};
}
const random = seededRandom(7341);
// ------------------------------------------------------------
// Water and stepped land mass
// ------------------------------------------------------------
box(7.6, 0.42, 10.8, -3.8, -0.23, 0, 0x176b79);
box(8.6, 0.96, 10.6, 4.3, 0.25, 0, 0xa77c55);
box(8.62, 0.18, 10.62, 4.3, -0.12, 0, 0x76583f);
const waterColors = [0x258f9c, 0x2c98a3, 0x218592, 0x319da7];
for (let ix = 0; ix < 9; ix++) {
for (let iz = 0; iz < 14; iz++) {
const x = -7.18 + ix * 0.8;
const z = -5.2 + iz * 0.8;
const color = waterColors[Math.floor(random() * waterColors.length)];
box(0.76, 0.08, 0.76, x, 0.015, z, color);
}
}
const pavingColors = [0xd8c69e, 0xd2be94, 0xdfcfaa, 0xcbb68c];
for (let ix = 0; ix < 13; ix++) {
for (let iz = 0; iz < 16; iz++) {
const x = 0.34 + ix * 0.64;
const z = -4.8 + iz * 0.64;
const color = pavingColors[Math.floor(random() * pavingColors.length)];
box(0.59, 0.12, 0.59, x, 0.79, z, color);
}
}
// Dark quay blocks emphasize the abrupt edge beside the creek.
for (let iz = 0; iz < 16; iz++) {
const z = -4.8 + iz * 0.64;
box(0.2, 0.62, 0.58, 0.08, 0.43, z, 0x9b714f);
}
// Small cubic water glints.
for (let i = 0; i < 36; i++) {
const x = -6.8 + random() * 6.2;
const z = -4.8 + random() * 9.6;
const w = 0.18 + random() * 0.42;
const d = 0.06 + random() * 0.1;
box(w, 0.025, d, x, 0.075, z, 0x8fd3cf, scene, {
roughness: 0.48,
castShadow: false
});
}
// ------------------------------------------------------------
// Connected walking route: landing → quay → arch → lane
// ------------------------------------------------------------
const routeX = 3.55;
const routeZ = 1.35;
// Route from the landing toward the lane.
for (let i = 0; i < 12; i++) {
const x = 0.22 + i * 0.3;
box(0.27, 0.08, 0.78, x, 0.89, routeZ, 0xf0d99f);
}
// Route turns into the lane and continues beyond the arch.
for (let i = 0; i < 22; i++) {
const z = 1.18 - i * 0.3;
box(0.78, 0.08, 0.27, routeX, 0.89, z, 0xf0d99f);
}
// Golden wayfinding studs make the route explicit.
for (let i = 0; i < 6; i++) {
box(0.1, 0.04, 0.1, 0.72 + i * 0.55, 0.96, routeZ, 0xe09a32);
}
for (let i = 0; i < 8; i++) {
box(0.1, 0.04, 0.1, routeX, 0.96, 0.55 - i * 0.55, 0xe09a32);
}
// Stepped voxel arrow pointing toward the arch.
box(0.32, 0.045, 0.1, 1.94, 0.96, routeZ, 0xd87846);
box(0.1, 0.045, 0.22, 2.12, 0.96, routeZ - 0.07, 0xd87846);
box(0.1, 0.045, 0.22, 2.12, 0.96, routeZ + 0.07, 0xd87846);
box(0.1, 0.045, 0.3, 2.2, 0.96, routeZ, 0xd87846);
// A second arrow turns down the lane.
box(0.1, 0.045, 0.32, routeX, 0.96, -0.36, 0xd87846);
box(0.22, 0.045, 0.1, routeX - 0.07, 0.96, -0.54, 0xd87846);
box(0.22, 0.045, 0.1, routeX + 0.07, 0.96, -0.54, 0xd87846);
box(0.3, 0.045, 0.1, routeX, 0.96, -0.62, 0xd87846);
// ------------------------------------------------------------
// Arched, shaded lane entrance
// ------------------------------------------------------------
const facadeZ = -1.65;
const facadeStartX = 1.27;
const cell = 0.38;
const sandstone = [0xcda879, 0xd5b184, 0xc49a6e, 0xdcbb91];
for (let row = 0; row < 8; row++) {
const y = 0.85 + (row + 0.5) * cell;
let openingHalfWidth = 0;
if (y < 2.05) openingHalfWidth = 1.03;
else if (y < 2.45) openingHalfWidth = 0.84;
else if (y < 2.85) openingHalfWidth = 0.64;
else if (y < 3.25) openingHalfWidth = 0.43;
for (let col = 0; col < 12; col++) {
const x = facadeStartX + (col + 0.5) * cell;
if (Math.abs(x - routeX) < openingHalfWidth) continue;
const color = sandstone[Math.floor(random() * sandstone.length)];
box(cell - 0.025, cell - 0.025, 0.62, x, y, facadeZ, color);
}
}
// Roof cap.
for (let col = 0; col < 12; col++) {
const x = facadeStartX + (col + 0.5) * cell;
box(cell - 0.025, 0.16, 0.76, x, 3.94, facadeZ, 0xb88c62);
}
// Dark lane floor continues directly under the opening.
box(2.25, 0.08, 3.85, routeX, 0.84, -3.43, 0x9a7654);
// Side buildings extend the lane into depth.
box(1.65, 3.0, 3.5, 1.62, 2.32, -3.42, 0xc39a70);
box(1.65, 3.0, 3.5, 5.48, 2.32, -3.42, 0xd0aa7d);
box(1.78, 0.18, 3.65, 1.62, 3.9, -3.42, 0xa87a56);
box(1.78, 0.18, 3.65, 5.48, 3.9, -3.42, 0xb88c62);
// Lane-facing windows and recessed niches.
for (const z of [-2.35, -3.45, -4.45]) {
box(0.055, 0.68, 0.48, 2.47, 1.85, z, 0x4e6660);
box(0.055, 0.68, 0.48, 4.63, 1.85, z, 0x526b65);
box(0.08, 0.08, 0.55, 2.49, 1.85, z, 0xe1bd83);
box(0.08, 0.08, 0.55, 4.61, 1.85, z, 0xe1bd83);
}
// Small upper roof blocks give the lane a stepped skyline.
box(0.8, 0.65, 0.85, 1.62, 4.27, -4.25, 0xd2aa7c);
box(0.72, 0.36, 0.78, 5.48, 4.2, -2.75, 0xc49a6e);
// Warm cube lanterns under the arch.
const lanternMaterial = new THREE.MeshStandardMaterial({
color: 0xffd68b,
roughness: 0.5,
emissive: 0xff9e32,
emissiveIntensity: 1.35
});
for (const x of [2.55, 4.55]) {
box(0.09, 0.32, 0.09, x, 2.66, -1.18, 0x5a4b38);
box(0.23, 0.27, 0.23, x, 2.4, -1.14, 0xffd38b, scene, {
material: lanternMaterial
});
box(0.29, 0.08, 0.29, x, 2.57, -1.14, 0x69503a);
}
const archLight = new THREE.PointLight(0xffb64d, 5, 3.2, 2);
archLight.position.set(routeX, 2.25, -0.95);
scene.add(archLight);
// ------------------------------------------------------------
// Pixel lettering, built entirely from small blocks
// ------------------------------------------------------------
const pixelFont = {
A: ["01110", "10001", "10001", "11111", "10001", "10001", "10001"],
B: ["11110", "10001", "10001", "11110", "10001", "10001", "11110"],
C: ["01111", "10000", "10000", "10000", "10000", "10000", "01111"],
E: ["11111", "10000", "10000", "11110", "10000", "10000", "11111"],
K: ["10001", "10010", "10100", "11000", "10100", "10010", "10001"],
L: ["10000", "10000", "10000", "10000", "10000", "10000", "11111"],
N: ["10001", "11001", "11001", "10101", "10011", "10011", "10001"],
R: ["11110", "10001", "10001", "11110", "10100", "10010", "10001"]
};
function pixelText(text, centerX, centerY, z, pixel = 0.05, color = 0xf8edca) {
const totalWidth = (text.length * 6 - 1) * pixel;
let cursor = centerX - totalWidth / 2;
for (const character of text) {
const glyph = pixelFont[character];
if (glyph) {
for (let row = 0; row < glyph.length; row++) {
for (let col = 0; col < glyph[row].length; col++) {
if (glyph[row][col] === "1") {
box(
pixel * 0.82,
pixel * 0.82,
0.035,
cursor + (col + 0.5) * pixel,
centerY + (3 - row) * pixel,
z,
color
);
}
}
}
}
cursor += 6 * pixel;
}
}
// Main lane plaque.
box(3.45, 0.56, 0.09, routeX, 3.47, -1.285, 0x22595a);
pixelText("CREEK LANE", routeX, 3.47, -1.225, 0.051, 0xfae8bb);
// Small ABRA sign by the landing.
box(0.13, 0.92, 0.13, 1.2, 1.31, 2.22, 0x65513c);
box(1.03, 0.45, 0.09, 1.2, 1.72, 2.22, 0x24676a);
pixelText("ABRA", 1.2, 1.72, 2.285, 0.036, 0xffedc4);
// ------------------------------------------------------------
// Shore landing and plank transfer
// ------------------------------------------------------------
// Teak landing platform attached to the quay.
for (let i = 0; i < 5; i++) {
const z = 0.83 + i * 0.26;
box(0.65, 0.16, 0.23, -0.22, 0.78, z, i % 2 ? 0xa56f3f : 0xb97c46);
}
// Stepped planks bridge the abra deck to the landing.
for (let i = 0; i < 5; i++) {
const x = -1.22 + i * 0.22;
const y = 0.69 + i * 0.04;
box(0.26, 0.09, 0.86, x, y, routeZ, i % 2 ? 0x9b6c43 : 0xb77c48);
}
// Short side curbs keep the transfer visually legible.
for (let i = 0; i < 5; i++) {
const x = -1.22 + i * 0.22;
const y = 0.72 + i * 0.04;
box(0.24, 0.08, 0.07, x, y, routeZ - 0.43, 0x6d523b);
box(0.24, 0.08, 0.07, x, y, routeZ + 0.43, 0x6d523b);
}
// ------------------------------------------------------------
// Voxel abra
// ------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(-2.25, 0, 0.45);
scene.add(boat);
const halfWidths = [
0.52, 0.69, 0.81, 0.89, 0.94, 0.96, 0.96,
0.95, 0.92, 0.86, 0.76, 0.63, 0.47
];
for (let i = 0; i < halfWidths.length; i++) {
const z = -2.18 + i * 0.36;
const half = halfWidths[i];
// Lower dark hull.
box(half * 1.48, 0.28, 0.37, 0, 0.19, z, 0x353f3d, boat);
box(0.28, 0.52, 0.37, -half + 0.14, 0.39, z, 0x263b3b, boat);
box(0.28, 0.52, 0.37, half - 0.14, 0.39, z, 0x263b3b, boat);
// Orange waterline and teak deck.
box(0.09, 0.1, 0.36, -half + 0.14, 0.48, z, 0xd36d42, boat);
box(0.09, 0.1, 0.36, half - 0.14, 0.48, z, 0xd36d42, boat);
box(half * 1.58, 0.1, 0.35, 0, 0.63, z, 0xa97043, boat);
// Warm gunwale blocks.
box(0.12, 0.12, 0.35, -half + 0.08, 0.72, z, 0xe0a05f, boat);
box(0.12, 0.12, 0.35, half - 0.08, 0.72, z, 0xe0a05f, boat);
}
// Interior floor and benches.
box(1.48, 0.08, 3.55, 0, 0.7, 0, 0xb77b47, boat);
box(1.35, 0.12, 0.3, 0, 0.83, -1.55, 0xd39a5c, boat);
box(1.28, 0.12, 0.3, 0, 0.83, 0.25, 0xd39a5c, boat);
// Canopy posts.
for (const x of [-0.72, 0.72]) {
for (const z of [-1.22, 0.63]) {
box(0.1, 1.14, 0.1, x, 1.26, z, 0xe7d3a2, boat);
}
}
// Roof assembled from visibly separate panels.
for (let i = 0; i < 3; i++) {
const x = -0.63 + i * 0.63;
box(0.59, 0.16, 2.06, x, 1.88, -0.3, i === 1 ? 0x247d83 : 0x2f8e91, boat);
box(0.59, 0.08, 2.06, x, 2.0, -0.3, 0xe8d6a5, boat);
}
box(1.9, 0.12, 0.14, 0, 1.83, 0.78, 0xd76e43, boat);
box(1.9, 0.12, 0.14, 0, 1.83, -1.38, 0xd76e43, boat);
// Stern blocks and motor-like end cap.
box(1.0, 0.2, 0.2, 0, 0.77, -2.35, 0x293e3d, boat);
box(0.35, 0.42, 0.28, 0, 0.38, -2.36, 0x304441, boat);
// Small seated abra driver.
const driver = new THREE.Group();
driver.position.set(-0.12, 0.78, -0.62);
boat.add(driver);
box(0.28, 0.38, 0.3, 0, 0.28, 0, 0x326d7b, driver);
box(0.25, 0.25, 0.25, 0, 0.6, 0, 0xb87850, driver);
box(0.28, 0.09, 0.28, 0, 0.76, 0, 0xf1dfad, driver);
box(0.12, 0.25, 0.12, 0.16, 0.35, 0, 0xb87850, driver);
box(0.32, 0.13, 0.26, 0.08, 0.08, 0.08, 0x344d4b, driver);
// Boat registration stripe, also block-built.
for (let i = 0; i < 4; i++) {
box(0.1, 0.1, 0.24, 0.97, 0.57, -0.65 + i * 0.48, 0xf0d18c, boat);
}
// ------------------------------------------------------------
// Passenger stepping onto the shore
// ------------------------------------------------------------
const passenger = new THREE.Group();
passenger.position.set(0.3, 0.94, routeZ);
scene.add(passenger);
// Legs, one slightly forward.
box(0.14, 0.34, 0.14, 0.1, 0.18, -0.13, 0x273c48, passenger);
box(0.14, 0.34, 0.14, 0.13, 0.18, 0.13, 0x304857, passenger);
box(0.25, 0.1, 0.15, 0.12, 0.05, -0.13, 0x263536, passenger);
box(0.25, 0.1, 0.15, 0.15, 0.05, 0.13, 0x263536, passenger);
// Shirt and arms.
box(0.3, 0.48, 0.35, 0, 0.59, 0, 0xf1e5c6, passenger);
box(0.15, 0.4, 0.13, 0.21, 0.59, -0.1, 0xe6d7b4, passenger);
box(0.15, 0.4, 0.13, -0.21, 0.59, 0.1, 0xe6d7b4, passenger);
box(0.14, 0.14, 0.14, 0.23, 0.39, -0.1, 0xb87955, passenger);
box(0.14, 0.14, 0.14, -0.23, 0.39, 0.1, 0xb87955, passenger);
// Head, hair, and small travel bag.
box(0.16, 0.13, 0.16, 0, 0.87, 0, 0xb87955, passenger);
box(0.28, 0.28, 0.28, 0, 1.06, 0, 0xc58b65, passenger);
box(0.3, 0.09, 0.3, 0, 1.22, 0, 0x39332f, passenger);
box(0.3, 0.18, 0.07, 0, 1.15, 0.12, 0x39332f, passenger);
box(0.3, 0.38, 0.18, -0.37, 0.24, 0.25, 0xb84f42, passenger);
box(0.22, 0.05, 0.06, -0.37, 0.47, 0.25, 0x3a3936, passenger);
box(0.05, 0.12, 0.05, -0.46, 0.5, 0.25, 0x3a3936, passenger);
box(0.05, 0.12, 0.05, -0.28, 0.5, 0.25, 0x3a3936, passenger);
// ------------------------------------------------------------
// Quay details and mooring rope
// ------------------------------------------------------------
function bollard(x, z) {
box(0.38, 0.1, 0.38, x, 0.9, z, 0x5c5144);
box(0.2, 0.42, 0.2, x, 1.14, z, 0x354744);
box(0.31, 0.12, 0.25, x, 1.36, z, 0x2c3e3d);
}
bollard(0.18, 2.25);
bollard(0.18, -0.35);
bollard(0.18, 4.45);
// Mooring rope represented by a chain of tiny blocks.
const ropeStart = new THREE.Vector3(-1.3, 0.83, 1.9);
const ropeEnd = new THREE.Vector3(0.18, 1.28, 2.25);
for (let i = 0; i <= 11; i++) {
const t = i / 11;
const p = ropeStart.clone().lerp(ropeEnd, t);
p.y -= Math.sin(t * Math.PI) * 0.16;
box(0.075, 0.075, 0.075, p.x, p.y, p.z, 0xc7a66d);
}
// A second short mooring line.
for (let i = 0; i <= 5; i++) {
const t = i / 5;
const x = -1.25 + t * 1.42;
const y = 0.78 + Math.sin(t * Math.PI) * 0.1;
const z = -1.55 - t * 0.14;
box(0.07, 0.07, 0.07, x, y, z, 0xc7a66d);
}
// Crates and a hand cart deeper in the lane.
box(0.48, 0.48, 0.48, 1.76, 1.09, -4.25, 0xa87546);
box(0.42, 0.42, 0.42, 1.77, 1.54, -4.25, 0xc08a51);
box(0.08, 0.46, 0.5, 1.76, 1.09, -4.25, 0x704f36);
box(0.08, 0.4, 0.44, 1.77, 1.54, -4.25, 0x704f36);
// ------------------------------------------------------------
// Voxel date palm for local context
// ------------------------------------------------------------
const palm = new THREE.Group();
palm.position.set(6.85, 0.84, 2.45);
scene.add(palm);
box(0.82, 0.22, 0.82, 0, 0.11, 0, 0xb18b62, palm);
for (let i = 0; i < 6; i++) {
box(0.23 - i * 0.015, 0.36, 0.23, i * 0.025, 0.25 + i * 0.34, 0,
i % 2 ? 0x8a643d : 0x9b7043, palm);
}
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const frond = box(
0.24, 0.15, 1.22,
Math.sin(angle) * 0.58,
2.38,
Math.cos(angle) * 0.58,
i % 2 ? 0x426f48 : 0x527f4c,
palm
);
frond.rotation.y = angle;
const tip = box(
0.18, 0.12, 0.52,
Math.sin(angle) * 1.12,
2.36,
Math.cos(angle) * 1.12,
0x648d53,
palm
);
tip.rotation.y = angle;
}
box(0.33, 0.25, 0.33, 0, 2.38, 0, 0x76583c, palm);
// Small foreground planter.
box(0.72, 0.52, 0.72, 5.4, 1.11, 3.65, 0xb98d63);
box(0.58, 0.08, 0.58, 5.4, 1.4, 3.65, 0x4d6748);
box(0.18, 0.7, 0.18, 5.4, 1.72, 3.65, 0x795b3d);
box(0.62, 0.22, 0.22, 5.24, 2.0, 3.65, 0x527b4c);
box(0.42, 0.2, 0.2, 5.62, 2.18, 3.65, 0x638b53);
// ------------------------------------------------------------
// Direct camera controls: orbit, shift-pan, wheel zoom
// ------------------------------------------------------------
const control = {
azimuth: 0.66,
targetAzimuth: 0.66,
polar: 0.86,
targetPolar: 0.86,
zoom: 1,
targetZoom: 1,
radius: 20
};
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
const activePointers = new Map();
renderer.domElement.addEventListener("pointerdown", (event) => {
activePointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragging = true;
panning = event.shiftKey || event.button === 2;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
activePointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (activePointers.size >= 2) {
const points = [...activePointers.values()];
const distance = Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
if (control.lastPinchDistance) {
control.targetZoom = THREE.MathUtils.clamp(
control.targetZoom * distance / control.lastPinchDistance,
0.72,
2
);
}
control.lastPinchDistance = distance;
return;
}
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const scale = 0.012 / control.zoom;
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.addScaledVector(up, dy * scale);
} else {
control.targetAzimuth -= dx * 0.006;
control.targetPolar = THREE.MathUtils.clamp(
control.targetPolar + dy * 0.005,
0.35,
1.35
);
}
});
function releasePointer(event) {
activePointers.delete(event.pointerId);
if (activePointers.size === 0) {
dragging = false;
control.lastPinchDistance = 0;
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
control.targetZoom = THREE.MathUtils.clamp(
control.targetZoom * Math.exp(-event.deltaY * 0.001),
0.72,
2
);
},
{ passive: false }
);
document.querySelector("#reset").addEventListener("click", () => {
control.targetAzimuth = 0.66;
control.targetPolar = 0.86;
control.targetZoom = 1;
cameraTarget.set(-0.15, 0.85, 0.15);
});
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") control.targetAzimuth += 0.08;
if (event.key === "ArrowRight") control.targetAzimuth -= 0.08;
if (event.key === "ArrowUp") control.targetPolar = Math.max(0.35, control.targetPolar - 0.06);
if (event.key === "ArrowDown") control.targetPolar = Math.min(1.35, control.targetPolar + 0.06);
if (event.key === "+" || event.key === "=") control.targetZoom = Math.min(2, control.targetZoom + 0.08);
if (event.key === "-") control.targetZoom = Math.max(0.72, control.targetZoom - 0.08);
});
// ------------------------------------------------------------
// Responsive camera and annotated callouts
// ------------------------------------------------------------
let viewportWidth = window.innerWidth;
let viewportHeight = window.innerHeight;
function resize() {
viewportWidth = window.innerWidth;
viewportHeight = window.innerHeight;
const aspect = viewportWidth / viewportHeight;
const halfHeight = Math.max(5.9, 8.25 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(viewportWidth, viewportHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
const calloutElements = [...document.querySelectorAll(".callout")];
const calloutData = [
{ element: calloutElements[0], position: new THREE.Vector3(-2.35, 2.42, 0.65), offset: [-12, -13] },
{ element: calloutElements[1], position: new THREE.Vector3(0.32, 1.62, 1.35), offset: [38, -6] },
{ element: calloutElements[2], position: new THREE.Vector3(2.1, 1.08, 1.35), offset: [0, 22] },
{ element: calloutElements[3], position: new THREE.Vector3(3.55, 4.1, -1.65), offset: [0, -23] }
];
const projected = new THREE.Vector3();
function updateCallouts() {
for (const item of calloutData) {
projected.copy(item.position).project(camera);
const x = (projected.x * 0.5 + 0.5) * viewportWidth + item.offset[0];
const y = (-projected.y * 0.5 + 0.5) * viewportHeight + item.offset[1];
const visible = projected.z > -1 && projected.z < 1 &&
x > 0 && x < viewportWidth && y > 0 && y < viewportHeight;
item.element.style.display = visible ? "flex" : "none";
item.element.style.left = `${x}px`;
item.element.style.top = `${y}px`;
}
}
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
function animate() {
requestAnimationFrame(animate);
control.azimuth += (control.targetAzimuth - control.azimuth) * 0.1;
control.polar += (control.targetPolar - control.polar) * 0.1;
control.zoom += (control.targetZoom - control.zoom) * 0.1;
const sinPolar = Math.sin(control.polar);
camera.position.set(
cameraTarget.x + control.radius * sinPolar * Math.sin(control.azimuth),
cameraTarget.y + control.radius * Math.cos(control.polar),
cameraTarget.z + control.radius * sinPolar * Math.cos(control.azimuth)
);
camera.lookAt(cameraTarget);
camera.zoom = control.zoom;
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
updateCallouts();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```