Prompt specification
Build or customize the Three.js 3D scene "Small boat delivering supplies to a Bangkok canal house" 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: Small boat delivering supplies to a Bangkok canal house
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/small-boat-delivering-supplies-to-a-bangkok-canal-hous-x2966
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Khlong Bang Luang's canal neighborhood in Bangkok. Create a compact referenced vignette with boat, landing, and resident receiving goods. Show a short transfer path without blocking the narrow public walkway. Voxel style.
Working Three.js Starter (small-boat-delivering-supplies-to-a-bangkok-canal-hous-x2966):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Khlong Bang Luang — Canal-Side Transfer Vignette</title>
<style>
:root {
--ink: #183b3b;
--muted: #5c7470;
--paper: rgba(249, 246, 235, 0.93);
--line: rgba(24, 59, 59, 0.16);
--green: #248f77;
--orange: #e56f35;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e4;
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:active {
cursor: grabbing;
}
#hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 3;
}
.card {
position: absolute;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow: 0 14px 40px rgba(39, 69, 64, 0.13);
backdrop-filter: blur(12px);
}
#title-card {
top: 26px;
left: 28px;
width: min(430px, calc(100vw - 56px));
padding: 20px 22px 18px;
border-radius: 4px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--green);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 18px;
height: 3px;
content: "";
background: var(--orange);
}
h1 {
margin: 0;
font-size: clamp(27px, 3vw, 40px);
font-weight: 760;
line-height: 0.98;
letter-spacing: -0.045em;
}
#title-card p {
max-width: 350px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
#study-card {
top: 26px;
right: 28px;
width: 270px;
padding: 17px 18px;
border-radius: 4px;
}
#study-card h2 {
margin: 0 0 12px;
font-size: 10px;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.study-row {
display: grid;
grid-template-columns: 24px 1fr;
gap: 10px;
align-items: start;
padding: 8px 0;
border-top: 1px solid var(--line);
}
.study-row:first-of-type {
border-top: 0;
}
.study-index {
display: grid;
width: 22px;
height: 22px;
place-items: center;
border: 1px solid rgba(36, 143, 119, 0.35);
color: var(--green);
font-size: 9px;
font-weight: 800;
}
.study-row strong {
display: block;
margin-bottom: 2px;
font-size: 11px;
}
.study-row span {
display: block;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
}
.note {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 9px;
line-height: 1.45;
}
#legend {
left: 28px;
bottom: 26px;
display: flex;
gap: 18px;
align-items: center;
padding: 11px 14px;
border-radius: 4px;
font-size: 10px;
font-weight: 700;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 21px;
height: 7px;
border-radius: 1px;
}
.swatch.public {
background: var(--green);
}
.swatch.goods {
background: var(--orange);
}
.swatch.buildings {
background: #d08a67;
}
#controls {
position: absolute;
right: 28px;
bottom: 26px;
display: flex;
gap: 8px;
align-items: center;
pointer-events: auto;
}
.hint {
margin-right: 5px;
color: rgba(24, 59, 59, 0.66);
font-size: 9px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
button {
border: 1px solid rgba(24, 59, 59, 0.22);
border-radius: 3px;
padding: 9px 12px;
background: rgba(249, 246, 235, 0.92);
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 750;
cursor: pointer;
box-shadow: 0 7px 20px rgba(39, 69, 64, 0.1);
}
button:hover {
border-color: var(--green);
color: var(--green);
}
#labels {
position: fixed;
inset: 0;
z-index: 2;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 2px;
background: rgba(249, 246, 235, 0.88);
box-shadow: 0 5px 18px rgba(39, 69, 64, 0.12);
color: var(--ink);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.scene-label::before {
width: 7px;
height: 7px;
content: "";
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 3px rgba(36, 143, 119, 0.14);
}
.scene-label.goods::before {
background: var(--orange);
box-shadow: 0 0 0 3px rgba(229, 111, 53, 0.14);
}
.scene-label.resident::before {
background: #b95646;
box-shadow: 0 0 0 3px rgba(185, 86, 70, 0.14);
}
#scale {
position: absolute;
left: 50%;
bottom: 29px;
transform: translateX(-50%);
color: rgba(24, 59, 59, 0.72);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
}
#scale-line {
display: flex;
align-items: flex-end;
width: 92px;
height: 10px;
margin-bottom: 4px;
border-right: 1px solid currentColor;
border-bottom: 1px solid currentColor;
border-left: 1px solid currentColor;
}
#scale-line::after {
width: 50%;
height: 4px;
content: "";
align-self: flex-end;
border-right: 1px solid currentColor;
border-left: 1px solid currentColor;
}
@media (max-width: 760px) {
#study-card {
display: none;
}
#title-card {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
padding: 16px 18px;
}
#title-card p {
font-size: 11px;
}
#legend {
left: 16px;
bottom: 16px;
gap: 10px;
padding: 9px 10px;
}
.legend-item.buildings {
display: none;
}
#controls {
right: 16px;
bottom: 16px;
}
.hint,
#scale {
display: none;
}
.scene-label {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="labels" aria-hidden="true">
<div class="scene-label" id="label-public">Public edge · 1.2 m clear</div>
<div class="scene-label goods" id="label-goods">Short goods transfer</div>
<div class="scene-label resident" id="label-resident">Resident receiving</div>
</div>
<div id="hud">
<section class="card" id="title-card">
<div class="eyebrow">Bangkok · Canal-edge study</div>
<h1>Khlong Bang Luang</h1>
<p>
A compact voxel vignette of a working canal landing: a moored boat,
a raised timber transfer point, and a resident receiving goods beside
the clear public walking edge.
</p>
</section>
<aside class="card" id="study-card">
<h2>Spatial reference</h2>
<div class="study-row">
<div class="study-index">01</div>
<div>
<strong>Canal edge</strong>
<span>Long-tail boat and floating access point.</span>
</div>
</div>
<div class="study-row">
<div class="study-index">02</div>
<div>
<strong>Raised landing</strong>
<span>Goods remain on the timber apron and low transfer shelf.</span>
</div>
</div>
<div class="study-row">
<div class="study-index">03</div>
<div>
<strong>Clear public edge</strong>
<span>The 1.2 m neighborhood walkway remains unobstructed.</span>
</div>
</div>
<div class="note">
Schematic reference vignette, not a surveyed site plan. Dimensions
describe the spatial logic shown in the model.
</div>
</aside>
<div class="card" id="legend">
<div class="legend-item">
<span class="swatch public"></span>
Public walkway
</div>
<div class="legend-item">
<span class="swatch goods"></span>
Goods transfer
</div>
<div class="legend-item buildings">
<span class="swatch buildings"></span>
Canal neighborhood
</div>
</div>
<div id="scale">
<div id="scale-line"></div>
0 — 4 M
</div>
<div id="controls">
<span class="hint">Drag to orbit · wheel to zoom</span>
<button id="focus" type="button">Focus landing</button>
<button id="reset" type="button">Reset</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 camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9e4);
scene.fog = new THREE.Fog(0xdce9e4, 27, 55);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(
-10,
10,
7,
-7,
0.1,
100
);
const view = {
theta: 2.60,
phi: 0.93,
radius: 25,
zoom: 1,
target: new THREE.Vector3(0, 1.0, 2.4)
};
const defaultView = {
theta: 2.60,
phi: 0.93,
zoom: 1,
target: new THREE.Vector3(0, 1.0, 2.4)
};
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const frustumHeight = 13.6;
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
renderer.setSize(width, height);
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// Direct camera interaction implemented without addons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) 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.0045,
0.48,
1.25
);
});
function stopDragging() {
dragging = false;
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(
view.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.75
);
},
{ passive: false }
);
document.getElementById("focus").addEventListener("click", () => {
view.target.set(2.2, 0.7, 1.7);
view.zoom = 1.42;
view.theta = 2.48;
view.phi = 0.98;
});
document.getElementById("reset").addEventListener("click", () => {
view.theta = defaultView.theta;
view.phi = defaultView.phi;
view.zoom = defaultView.zoom;
view.target.copy(defaultView.target);
});
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xeaf7f4, 0x806754, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2d5, 3.2);
sun.position.set(-9, 17, -11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8ec7cf, 0.7);
fill.position.set(12, 7, 10);
scene.add(fill);
// -------------------------------------------------------------------------
// Voxel construction helpers
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02
})
);
}
return materialCache.get(color);
}
function box(
parent,
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
castShadow = true
) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addPlant(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
box(group, 0.32, 0.28, 0.32, 0xb86643, 0, 0.14, 0);
box(group, 0.10, 0.38, 0.10, 0x5c7d3d, 0, 0.42, 0);
box(group, 0.34, 0.20, 0.16, 0x477a3c, 0.12, 0.52, 0);
box(group, 0.26, 0.18, 0.25, 0x67924b, -0.12, 0.66, 0.02);
box(group, 0.22, 0.19, 0.20, 0x5b883f, 0.02, 0.83, 0);
return group;
}
function addUtilityPole(x, z, height = 4.6) {
box(scene, 0.16, height, 0.16, 0x655a49, x, height / 2, z);
box(scene, 1.35, 0.10, 0.10, 0x514d45, x, height - 0.35, z);
box(scene, 0.32, 0.45, 0.26, 0xd9cba8, x + 0.25, height - 0.72, z);
box(scene, 0.18, 0.18, 0.18, 0x465d5a, x - 0.48, height - 0.62, z);
}
function dashedRoute(points, color, size = 0.16) {
const markers = [];
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const dx = b[0] - a[0];
const dz = b[2] - a[2];
const length = Math.hypot(dx, dz);
const count = Math.max(1, Math.floor(length / 0.34));
for (let j = 0; j < count; j++) {
const t = (j + 0.5) / count;
const marker = box(
scene,
0.27,
0.045,
size,
color,
a[0] + dx * t,
a[1] + (b[1] - a[1]) * t + 0.025,
a[2] + dz * t,
false
);
marker.rotation.y = -Math.atan2(dz, dx);
markers.push(marker);
}
}
return markers;
}
// -------------------------------------------------------------------------
// Canal, banks, and public walkway
// -------------------------------------------------------------------------
// Water occupies the foreground and middle of the scene.
box(scene, 31, 0.20, 8.1, 0x3f9caa, 0, -0.56, -1.0, false);
// Neighborhood bank.
box(scene, 31, 1.0, 8.3, 0xb9a783, 0, -0.5, 7.15, false);
box(scene, 31, 0.95, 0.28, 0x9c856b, 0, -0.04, 3.08, false);
// Narrow opposite bank gives the canal a framed foreground.
box(scene, 31, 0.45, 1.1, 0xa99b80, 0, -0.56, -5.45, false);
box(scene, 31, 0.14, 0.15, 0x7f765e, 0, -0.27, -5.00, false);
// The public edge is deliberately empty and visibly distinct.
box(scene, 29.5, 0.16, 1.2, 0xd8d1c0, 0, 0.08, 4.78);
box(scene, 29.5, 0.07, 0.10, 0x7db9a5, 0, 0.19, 4.22, false);
// Green public-path markers.
for (let x = -13.8; x < 14; x += 0.78) {
box(scene, 0.34, 0.025, 0.11, 0x248f77, x, 0.19, 4.79, false);
}
// Canal-edge bollards.
for (const x of [-12, -8.5, -5, 8.6, 11.5, 13.6]) {
box(scene, 0.18, 0.58, 0.18, 0x6f7668, x, 0.32, 3.34);
box(scene, 0.24, 0.10, 0.24, 0xe0b55b, x, 0.64, 3.34);
}
// -------------------------------------------------------------------------
// Canal houses and neighborhood details
// -------------------------------------------------------------------------
function makeHouse({
x,
z,
width,
depth,
height,
wall,
roof,
accent,
balcony = false
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(group, width, height, depth, wall, 0, height / 2, 0);
box(group, width + 0.35, 0.20, depth + 0.35, roof, 0, height + 0.10, 0);
box(group, width + 0.10, 0.14, depth + 0.10, accent, 0, 0.16, 0);
const front = -depth / 2 - 0.045;
// Front windows.
const windowXs = [-width * 0.25, width * 0.25];
for (const wx of windowXs) {
box(group, 0.82, 0.86, 0.10, 0x304f55, wx, 1.92, front);
box(group, 0.64, 0.66, 0.12, 0x79aeb8, wx, 1.92, front - 0.04);
box(group, 0.055, 0.70, 0.14, 0xe8dcc0, wx, 1.92, front - 0.08);
box(group, 0.66, 0.055, 0.14, 0xe8dcc0, wx, 1.92, front - 0.08);
}
// Door and threshold.
box(group, 0.72, 1.48, 0.12, 0x674b38, 0, 0.90, front);
box(group, 0.54, 1.30, 0.14, 0x8f6243, 0, 0.85, front - 0.07);
box(group, 0.12, 0.08, 0.10, 0xd6b26a, 0.22, 0.83, front - 0.15);
box(group, 1.05, 0.16, 0.62, 0x9b8a73, 0, 0.08, front - 0.28);
// Striped awning.
const awningY = 2.72;
const awningZ = front - 0.42;
const slatCount = 8;
const slatWidth = (width + 0.5) / slatCount;
for (let i = 0; i < slatCount; i++) {
const slat = box(
group,
slatWidth - 0.025,
0.10,
0.92,
i % 2 === 0 ? accent : 0xf1e4c7,
-width / 2 - 0.25 + slatWidth * (i + 0.5),
awningY,
awningZ
);
slat.rotation.x = -0.12;
}
if (balcony) {
box(group, width * 0.62, 0.12, 0.72, 0xd1b783, 0, 1.06, front - 0.35);
box(group, width * 0.62, 0.07, 0.07, 0x735e45, 0, 1.53, front - 0.68);
for (let i = 0; i < 6; i++) {
box(
group,
0.055,
0.48,
0.055,
0x735e45,
-width * 0.27 + i * (width * 0.108),
1.30,
front - 0.68
);
}
}
// Rooftop utility box.
box(group, 0.70, 0.44, 0.58, 0xbfc4ba, width * 0.24, height + 0.42, 0.35);
box(group, 0.52, 0.25, 0.03, 0x707d78, width * 0.24, height + 0.42, 0.035);
// Small sign made from voxel-like blocks.
box(group, 1.18, 0.34, 0.10, 0xf3d878, 0, 3.30, front - 0.08);
box(group, 0.72, 0.09, 0.12, 0x3e675e, -0.08, 3.30, front - 0.13);
box(group, 0.43, 0.08, 0.12, 0x3e675e, 0.30, 3.20, front - 0.13);
return group;
}
makeHouse({
x: -8.2,
z: 7.5,
width: 4.1,
depth: 3.1,
height: 3.15,
wall: 0xd99572,
roof: 0x5b6763,
accent: 0x4e8c81,
balcony: true
});
makeHouse({
x: -3.0,
z: 8.0,
width: 4.5,
depth: 3.2,
height: 3.85,
wall: 0xe0bd72,
roof: 0x56625f,
accent: 0xb95e48,
balcony: false
});
makeHouse({
x: 7.2,
z: 7.5,
width: 4.7,
depth: 3.25,
height: 3.45,
wall: 0x8eb9a2,
roof: 0x5d6660,
accent: 0xe0c68a,
balcony: true
});
// Narrow waterside annex associated with the resident.
box(scene, 2.25, 2.65, 2.65, 0xd7c2a0, 5.05, 1.325, 7.1);
box(scene, 2.48, 0.18, 2.85, 0x6d7064, 5.05, 2.72, 7.1);
box(scene, 0.68, 1.45, 0.12, 0x795b43, 5.0, 0.86, 5.75);
box(scene, 0.55, 0.73, 0.12, 0x74a4ad, 4.15, 1.80, 5.74);
box(scene, 0.95, 0.14, 0.72, 0xa99980, 5.0, 0.08, 5.38);
// Plants, pots, stools, and everyday canal-edge objects.
addPlant(scene, -6.1, 0.05, 5.72, 0.85);
addPlant(scene, 5.98, 0.05, 5.55, 0.92);
addPlant(scene, -1.72, 0.05, 5.62, 0.78);
addPlant(scene, 8.75, 0.05, 5.55, 1.0);
box(scene, 0.62, 0.38, 0.62, 0x9a6644, -5.35, 0.20, 5.75);
box(scene, 0.68, 0.08, 0.68, 0xd3ad6e, -5.35, 0.42, 5.75);
// Utility poles and simple overhead wires.
addUtilityPole(-11.4, 9.1, 4.9);
addUtilityPole(-1.2, 9.4, 5.2);
addUtilityPole(9.7, 9.0, 4.8);
box(scene, 21.5, 0.035, 0.035, 0x3e4542, -0.8, 4.55, 9.25, false);
box(scene, 21.5, 0.035, 0.035, 0x3e4542, -0.8, 4.25, 9.25, false);
// Laundry line between two poles.
box(scene, 3.9, 0.025, 0.025, 0x6e6a5b, -6.2, 3.10, 5.75, false);
box(scene, 0.56, 0.70, 0.04, 0xf3dfc1, -7.0, 2.72, 5.75, false);
box(scene, 0.43, 0.58, 0.04, 0x6fa1a6, -6.2, 2.77, 5.75, false);
box(scene, 0.48, 0.63, 0.04, 0xd8795f, -5.45, 2.74, 5.75, false);
// -------------------------------------------------------------------------
// Raised timber landing and transfer apron
// -------------------------------------------------------------------------
const landing = new THREE.Group();
scene.add(landing);
// Individual deck planks.
for (let i = 0; i < 10; i++) {
const plank = box(
landing,
2.75,
0.14,
0.245,
i % 3 === 0 ? 0x9a7047 : 0xb18555,
2.1,
0.40,
0.22 + i * 0.28
);
plank.castShadow = true;
}
// Supports.
for (const x of [0.92, 3.28]) {
for (const z of [0.40, 2.84]) {
box(landing, 0.17, 1.05, 0.17, 0x68503b, x, 0.02, z);
box(landing, 0.24, 0.10, 0.24, 0xc49a60, x, 0.58, z);
}
}
// A few fixed planks under the deck.
box(landing, 0.20, 0.20, 2.85, 0x76573d, 1.20, 0.20, 1.52);
box(landing, 0.20, 0.20, 2.85, 0x76573d, 3.00, 0.20, 1.52);
// Low receiving apron beside, rather than within, the public walkway.
box(scene, 2.75, 0.15, 1.55, 0xc3b497, 4.12, 0.075, 3.34, false);
box(scene, 2.85, 0.08, 0.10, 0xe2d5b9, 4.12, 0.17, 2.58, false);
// Step from the landing to the apron.
box(scene, 0.88, 0.13, 0.38, 0x9a7047, 3.22, 0.34, 2.92);
box(scene, 0.88, 0.11, 0.38, 0xa77b4e, 3.22, 0.23, 3.20);
// Crates remain on the landing side.
box(scene, 0.58, 0.42, 0.50, 0xc47a3e, 1.15, 0.68, 1.78);
box(scene, 0.63, 0.08, 0.55, 0x744c34, 1.15, 0.92, 1.78);
box(scene, 0.46, 0.34, 0.42, 0xe0b35b, 2.76, 0.64, 0.88);
// Short, orange goods-transfer route: boat → landing → receiving apron.
const goodsMarkers = dashedRoute(
[
[0.88, 0.54, 0.08],
[1.45, 0.54, 0.50],
[2.10, 0.54, 1.12],
[2.68, 0.54, 1.70],
[3.05, 0.52, 2.35],
[3.32, 0.40, 2.90],
[3.83, 0.21, 3.22],
[4.42, 0.20, 3.48]
],
0xe56f35,
0.14
);
// -------------------------------------------------------------------------
// Long-tail voxel boat
// -------------------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(-0.65, -0.20, -0.58);
scene.add(boat);
// Stepped hull.
box(boat, 3.65, 0.55, 1.16, 0x704735, 0, 0.18, 0);
box(boat, 0.72, 0.48, 0.92, 0x704735, 2.00, 0.23, 0);
box(boat, 0.42, 0.38, 0.60, 0x704735, 2.55, 0.28, 0);
box(boat, 0.60, 0.43, 0.86, 0x704735, -2.02, 0.20, 0);
// Deck and gunwales.
box(boat, 3.42, 0.11, 0.88, 0xa56e43, -0.05, 0.47, 0);
box(boat, 3.48, 0.20, 0.12, 0x3f8e8e, -0.05, 0.58, 0.53);
box(boat, 3.48, 0.20, 0.12, 0x3f8e8e, -0.05, 0.58, -0.53);
// Upright prow.
box(boat, 0.18, 0.92, 0.55, 0x3f8e8e, 2.76, 0.72, 0);
box(boat, 0.23, 0.13, 0.60, 0xe2b34e, 2.76, 1.20, 0);
// Stern, motor, and long-tail drive shaft.
box(boat, 0.46, 0.64, 0.54, 0x44515a, -2.18, 0.64, 0);
box(boat, 0.15, 0.15, 0.15, 0x2e3d42, -2.18, 1.02, 0);
box(boat, 1.45, 0.12, 0.12, 0x38484b, -2.86, 0.18, 0);
box(boat, 0.16, 0.50, 0.12, 0x38484b, -3.52, 0.04, 0);
// Bright bench seats.
for (const x of [-1.20, -0.18, 0.85, 1.62]) {
box(boat, 0.31, 0.16, 1.03, 0xe1b74e, x, 0.65, 0);
box(boat, 0.12, 0.39, 1.03, 0xddad42, x, 0.43, 0);
}
// Small canopy over the middle section.
box(boat, 1.38, 0.10, 1.13, 0x3f8e8e, -0.42, 1.67, 0);
for (const x of [-1.00, 0.16]) {
box(boat, 0.07, 1.10, 0.07, 0x40585b, x, 1.10, 0.47);
box(boat, 0.07, 1.10, 0.07, 0x40585b, x, 1.10, -0.47);
}
box(boat, 1.42, 0.12, 0.06, 0xe2b34e, -0.42, 1.75, 0.50);
// Boat vendor, seated near the stern.
const operator = new THREE.Group();
operator.position.set(-1.22, 0.53, 0);
boat.add(operator);
box(operator, 0.37, 0.50, 0.38, 0xe4e0c7, 0, 0.68, 0);
box(operator, 0.33, 0.34, 0.34, 0xc28a63, 0, 1.08, 0);
box(operator, 0.39, 0.13, 0.37, 0x3f3e38, 0, 1.28, 0);
box(operator, 0.47, 0.13, 0.14, 0xe8c36e, 0, 0.84, 0.22);
box(operator, 0.47, 0.13, 0.14, 0xe8c36e, 0, 0.84, -0.22);
box(operator, 0.42, 0.13, 0.13, 0xc28a63, 0.25, 0.82, 0.22);
box(operator, 0.42, 0.13, 0.13, 0xc28a63, 0.25, 0.82, -0.22);
// Parcel offered from the boat.
box(boat, 0.48, 0.35, 0.38, 0xcf8950, 0.95, 0.91, 0.39);
box(boat, 0.51, 0.055, 0.41, 0xf0d69a, 0.95, 1.10, 0.39);
// Mooring rope from boat to landing post.
const rope = box(
scene,
0.045,
0.045,
1.42,
0xc8b98d,
0.88,
0.59,
0.06,
false
);
rope.rotation.x = -0.12;
// -------------------------------------------------------------------------
// Resident receiving a parcel
// -------------------------------------------------------------------------
const resident = new THREE.Group();
resident.position.set(4.78, 0.20, 3.54);
resident.rotation.y = 2.54;
scene.add(resident);
// Shoes and legs.
box(resident, 0.30, 0.13, 0.19, 0x354642, 0.06, 0.07, 0.17);
box(resident, 0.30, 0.13, 0.19, 0x354642, 0.06, 0.07, -0.17);
box(resident, 0.19, 0.58, 0.18, 0x455b68, 0, 0.39, 0.17);
box(resident, 0.19, 0.58, 0.18, 0x455b68, 0, 0.39, -0.17);
// Torso.
box(resident, 0.50, 0.64, 0.43, 0x3b9185, 0, 1.00, 0);
box(resident, 0.55, 0.10, 0.46, 0x2f706a, 0, 0.76, 0);
// Neck and head.
box(resident, 0.15, 0.17, 0.16, 0xc98e68, 0, 1.41, 0);
box(resident, 0.39, 0.41, 0.37, 0xd49a72, 0, 1.66, 0);
box(resident, 0.41, 0.15, 0.39, 0x343e3b, 0, 1.87, 0);
box(resident, 0.12, 0.08, 0.39, 0x343e3b, -0.20, 1.78, 0);
// Arms extended toward the incoming parcel.
box(resident, 0.65, 0.15, 0.15, 0x3b9185, 0.34, 1.19, 0.22);
box(resident, 0.65, 0.15, 0.15, 0x3b9185, 0.34, 1.19, -0.22);
box(resident, 0.18, 0.16, 0.16, 0xd49a72, 0.69, 1.19, 0.22);
box(resident, 0.18, 0.16, 0.16, 0xd49a72, 0.69, 1.19, -0.22);
// Received parcel.
box(resident, 0.50, 0.36, 0.42, 0xd79a58, 0.88, 1.21, 0);
box(resident, 0.53, 0.055, 0.45, 0xf0d79a, 0.88, 1.42, 0);
box(resident, 0.09, 0.37, 0.46, 0x8f6041, 0.88, 1.21, 0);
// A small stool remains outside the clear public walkway.
box(scene, 0.48, 0.12, 0.48, 0xb77a46, 5.72, 0.27, 3.45);
for (const dx of [-0.17, 0.17]) {
for (const dz of [-0.17, 0.17]) {
box(scene, 0.08, 0.25, 0.08, 0x76513a, 5.72 + dx, 0.13, 3.45 + dz);
}
}
// -------------------------------------------------------------------------
// Pixel-like water reflections
// -------------------------------------------------------------------------
const waterPatches = [];
const patchColors = [0x8ccbd0, 0x6db7c1, 0xb0d9d6];
for (let i = 0; i < 58; i++) {
const x = -14.2 + Math.random() * 28.4;
const z = -4.75 + Math.random() * 7.35;
// Keep most reflections away from the landing and boat.
const nearDock = x > 0.3 && x < 4.7 && z > -0.4 && z < 3.2;
if (nearDock && Math.random() < 0.78) continue;
const patch = box(
scene,
0.25 + Math.random() * 0.55,
0.018,
0.07 + Math.random() * 0.12,
patchColors[i % patchColors.length],
x,
-0.445,
z,
false
);
waterPatches.push({
mesh: patch,
baseX: x,
baseY: -0.445,
phase: Math.random() * Math.PI * 2,
speed: 0.35 + Math.random() * 0.35
});
}
// -------------------------------------------------------------------------
// Screen-space scene labels
// -------------------------------------------------------------------------
const labelData = [
{
element: document.getElementById("label-public"),
position: new THREE.Vector3(-3.6, 0.85, 4.78)
},
{
element: document.getElementById("label-goods"),
position: new THREE.Vector3(2.35, 1.15, 1.65)
},
{
element: document.getElementById("label-resident"),
position: new THREE.Vector3(5.00, 2.55, 3.50)
}
];
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labelData) {
const projected = label.position.clone().project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.transform =
`translate(${x}px, ${y}px) translate(-50%, -50%)`;
label.element.style.display =
projected.z > 1 || projected.z < -1 ? "none" : "flex";
}
}
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
boat.position.y = -0.20 + Math.sin(elapsed * 1.25) * 0.025;
boat.rotation.z = Math.sin(elapsed * 0.9) * 0.009;
boat.rotation.x = Math.sin(elapsed * 0.72 + 1.4) * 0.006;
for (const patch of waterPatches) {
patch.mesh.position.x = patch.baseX + Math.sin(elapsed * patch.speed + patch.phase) * 0.10;
patch.mesh.position.y = patch.baseY + Math.sin(elapsed * 0.75 + patch.phase) * 0.008;
}
for (let i = 0; i < goodsMarkers.length; i++) {
const marker = goodsMarkers[i];
const pulse = 0.88 + Math.sin(elapsed * 2.4 - i * 0.42) * 0.12;
marker.scale.y = 0.045 * pulse;
}
// A very small receiving gesture.
resident.rotation.z = Math.sin(elapsed * 1.15) * 0.008;
updateCamera();
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```