Prompt specification
Build or customize the Three.js 3D scene "Lagos ferry pontoon and gangway fragment" 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: Lagos ferry pontoon and gangway fragment
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/lagos-ferry-pontoon-and-gangway-fragment-x2929
Scene Description Prompt:
Model a low-poly Lagos ferry pontoon connected to fixed shore by a hinged gangway with boarding rails. Three.js from cdnjs, one HTML file.
Working Three.js Starter (lagos-ferry-pontoon-and-gangway-fragment-x2929):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lagos Ferry Pontoon</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9dce1;
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
canvas:active {
cursor: grabbing;
}
.info {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
max-width: min(420px, calc(100vw - 48px));
padding: 16px 18px;
color: #f6fbfa;
background: rgba(7, 43, 52, 0.86);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 12px;
box-shadow: 0 12px 35px rgba(0, 30, 40, 0.22);
backdrop-filter: blur(10px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 6px;
color: #75e3d3;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(20px, 3vw, 30px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.subtitle {
margin-top: 8px;
color: #c4d9da;
font-size: 13px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 20px;
bottom: 18px;
z-index: 10;
padding: 9px 13px;
color: #eaf5f4;
background: rgba(7, 43, 52, 0.78);
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 9px;
font-size: 11px;
letter-spacing: 0.025em;
pointer-events: none;
}
.badge {
position: fixed;
left: 24px;
bottom: 20px;
z-index: 10;
display: flex;
gap: 8px;
align-items: center;
padding: 8px 11px;
color: #154d55;
background: rgba(239, 251, 248, 0.9);
border-radius: 8px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
pointer-events: none;
}
.badge::before {
content: "";
width: 8px;
height: 8px;
background: #19aa8a;
border-radius: 50%;
box-shadow: 0 0 0 4px rgba(25, 170, 138, 0.15);
}
@media (max-width: 640px) {
.info {
top: 14px;
left: 14px;
padding: 13px 15px;
}
.controls {
right: 12px;
bottom: 12px;
}
.badge {
display: none;
}
}
</style>
</head>
<body>
<div class="info">
<div class="eyebrow">Lagos Waterfront · Low Poly Study</div>
<h1>Ferry Pontoon</h1>
<div class="subtitle">
A floating passenger landing stage linked to the fixed quay by a
hinged, railed boarding gangway.
</div>
</div>
<div class="badge">Interactive 3D scene</div>
<div class="controls">Drag: orbit · Wheel: zoom · Shift-drag: pan · Double-click: reset</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, and camera
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc8e7ea);
scene.fog = new THREE.Fog(0xc8e7ea, 42, 105);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
250
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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", "Interactive Lagos ferry pontoon scene");
document.body.prepend(renderer.domElement);
const target = new THREE.Vector3(0.5, 0.8, -1.2);
const desiredCamera = {
radius: 31,
theta: 0.69,
phi: 1.03
};
const currentCamera = {
radius: desiredCamera.radius,
theta: desiredCamera.theta,
phi: desiredCamera.phi
};
const defaultCamera = {
radius: 31,
theta: 0.69,
phi: 1.03
};
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xe9ffff, 0x496f63, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d5, 3.2);
sun.position.set(-18, 30, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -35;
sun.shadow.camera.right = 35;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 90;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x91d8e3, 0.8);
fill.position.set(22, 12, -18);
scene.add(fill);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const materials = {
water: new THREE.MeshPhongMaterial({
color: 0x2d8992,
specular: 0x7ed2d2,
shininess: 42,
flatShading: true
}),
concrete: new THREE.MeshStandardMaterial({
color: 0x9b9e91,
roughness: 0.94,
flatShading: true
}),
concreteLight: new THREE.MeshStandardMaterial({
color: 0xc4c1ae,
roughness: 0.9,
flatShading: true
}),
concreteDark: new THREE.MeshStandardMaterial({
color: 0x656d67,
roughness: 1,
flatShading: true
}),
pontoonDeck: new THREE.MeshStandardMaterial({
color: 0xc8c2aa,
roughness: 0.9,
flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x087d7a,
roughness: 0.72,
flatShading: true
}),
tealLight: new THREE.MeshStandardMaterial({
color: 0x26aaa0,
roughness: 0.68,
flatShading: true
}),
orange: new THREE.MeshStandardMaterial({
color: 0xf28b38,
roughness: 0.74,
flatShading: true
}),
cream: new THREE.MeshStandardMaterial({
color: 0xf0e9d0,
roughness: 0.78,
flatShading: true
}),
glass: new THREE.MeshStandardMaterial({
color: 0x153f51,
roughness: 0.22,
metalness: 0.15,
flatShading: true
}),
metal: new THREE.MeshStandardMaterial({
color: 0xaab9b7,
roughness: 0.48,
metalness: 0.48,
flatShading: true
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x263e42,
roughness: 0.6,
metalness: 0.35,
flatShading: true
}),
rubber: new THREE.MeshStandardMaterial({
color: 0x18282b,
roughness: 0.98,
flatShading: true
}),
yellow: new THREE.MeshStandardMaterial({
color: 0xf2c54d,
roughness: 0.72,
flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: 0x9b7350,
roughness: 0.95,
flatShading: true
}),
rope: new THREE.MeshStandardMaterial({
color: 0xbba77d,
roughness: 1,
flatShading: true
}),
leaf: new THREE.MeshStandardMaterial({
color: 0x2e8c52,
roughness: 0.92,
flatShading: true
}),
leafLight: new THREE.MeshStandardMaterial({
color: 0x57a957,
roughness: 0.92,
flatShading: true
}),
trunk: new THREE.MeshStandardMaterial({
color: 0x97704b,
roughness: 1,
flatShading: true
}),
white: new THREE.MeshStandardMaterial({
color: 0xf8fbf4,
roughness: 0.78,
flatShading: true
}),
green: new THREE.MeshStandardMaterial({
color: 0x168447,
roughness: 0.78,
flatShading: true
})
};
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function addBox(
width,
height,
depth,
material,
x,
y,
z,
parent = scene,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
const up = new THREE.Vector3(0, 1, 0);
function cylinderBetween(
start,
end,
radius,
material,
parent = scene,
radialSegments = 8
) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments,
1,
false
),
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(up, direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addRailing(
start,
end,
height,
parent = scene,
topMaterial = materials.metal,
spacing = 1.15
) {
const distance = start.distanceTo(end);
const sections = Math.max(1, Math.ceil(distance / spacing));
for (let i = 0; i <= sections; i++) {
const t = i / sections;
const base = new THREE.Vector3().lerpVectors(start, end, t);
const top = base.clone();
top.y += height;
cylinderBetween(
base,
top,
0.035,
materials.darkMetal,
parent,
6
);
}
const topStart = start.clone();
topStart.y += height;
const topEnd = end.clone();
topEnd.y += height;
cylinderBetween(topStart, topEnd, 0.04, topMaterial, parent, 8);
const middleStart = start.clone();
middleStart.y += height * 0.52;
const middleEnd = end.clone();
middleEnd.y += height * 0.52;
cylinderBetween(
middleStart,
middleEnd,
0.028,
materials.metal,
parent,
6
);
}
function addBollard(x, z, y = 1.47) {
const base = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.28, 0.12, 8),
materials.darkMetal
);
base.position.set(x, y + 0.06, z);
base.castShadow = true;
scene.add(base);
const body = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.18, 0.48, 8),
materials.darkMetal
);
body.position.set(x, y + 0.32, z);
body.castShadow = true;
scene.add(body);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(0.21, 0.15, 0.13, 8),
materials.darkMetal
);
cap.position.set(x, y + 0.6, z);
cap.castShadow = true;
scene.add(cap);
}
// ------------------------------------------------------------
// Animated low-poly water
// ------------------------------------------------------------
const waterGeometry = new THREE.PlaneGeometry(120, 120, 28, 28);
waterGeometry.rotateX(-Math.PI / 2);
const water = new THREE.Mesh(waterGeometry, materials.water);
water.position.y = 0;
water.receiveShadow = true;
scene.add(water);
const waterPositions = waterGeometry.attributes.position;
// Small polygonal highlights on the water.
const highlightMaterial = new THREE.MeshBasicMaterial({
color: 0x9dd7d5,
transparent: true,
opacity: 0.35,
side: THREE.DoubleSide,
depthWrite: false
});
for (let i = 0; i < 42; i++) {
const length = 0.35 + Math.random() * 1.2;
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-length * 0.5, 0, -0.05,
length * 0.5, 0, 0,
-length * 0.25, 0, 0.09
], 3)
);
const highlight = new THREE.Mesh(geometry, highlightMaterial);
highlight.position.set(
(Math.random() - 0.5) * 54,
0.065,
(Math.random() - 0.5) * 48
);
highlight.rotation.y = Math.random() * Math.PI;
scene.add(highlight);
}
// ------------------------------------------------------------
// Fixed shore and quay
// ------------------------------------------------------------
addBox(
16,
2.65,
22,
materials.concrete,
13,
0.125,
0
);
// Pale coping along the quay edge.
addBox(
0.42,
0.18,
22,
materials.concreteLight,
5.12,
1.46,
0
);
// Vertical seawall ribs.
for (let z = -10; z <= 10; z += 2) {
addBox(
0.2,
2.2,
0.28,
materials.concreteDark,
4.93,
0.12,
z
);
}
// Rubber quay fenders.
for (const z of [-8, -4, 4, 8]) {
const fender = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.28, 1.2, 8),
materials.rubber
);
fender.position.set(4.72, 0.5, z);
fender.rotation.z = Math.PI / 2;
fender.castShadow = true;
scene.add(fender);
}
for (const z of [-8, 4, 8]) {
addBollard(5.65, z);
}
// Painted quay edge.
for (let z = -10; z <= 10; z += 1.25) {
addBox(
0.55,
0.025,
0.72,
materials.yellow,
4.85,
1.565,
z,
scene,
false
);
}
// ------------------------------------------------------------
// Floating boarding pontoon
// ------------------------------------------------------------
const pontoon = new THREE.Group();
scene.add(pontoon);
// flotation drums
for (const x of [-4.25, -1.5, 1.25]) {
addBox(
1.05,
0.58,
4.75,
materials.rubber,
x,
0.19,
0,
pontoon
);
}
addBox(
7.2,
0.34,
5.6,
materials.pontoonDeck,
-1.5,
0.64,
0,
pontoon
);
// Dark perimeter edge.
addBox(
7.3,
0.12,
5.7,
materials.concreteDark,
-1.5,
0.46,
0,
pontoon
);
// Painted safety strip along the gangway approach.
addBox(
0.65,
0.025,
1.55,
materials.yellow,
1.53,
0.825,
0,
pontoon,
false
);
const deckY = 0.82;
// Pontoon perimeter railings, with openings for the gangway and ferry.
addRailing(
new THREE.Vector3(-5.0, deckY, -2.65),
new THREE.Vector3(-5.0, deckY, 2.65),
1.0,
pontoon,
materials.metal
);
addRailing(
new THREE.Vector3(-5.0, deckY, 2.65),
new THREE.Vector3(1.95, deckY, 2.65),
1.0,
pontoon,
materials.metal
);
addRailing(
new THREE.Vector3(-5.0, deckY, -2.65),
new THREE.Vector3(-4.4, deckY, -2.65),
1.0,
pontoon,
materials.metal
);
addRailing(
new THREE.Vector3(0.3, deckY, -2.65),
new THREE.Vector3(1.95, deckY, -2.65),
1.0,
pontoon,
materials.metal
);
addRailing(
new THREE.Vector3(1.95, deckY, -2.65),
new THREE.Vector3(1.95, deckY, -0.85),
1.0,
pontoon,
materials.metal
);
addRailing(
new THREE.Vector3(1.95, deckY, 0.85),
new THREE.Vector3(1.95, deckY, 2.65),
1.0,
pontoon,
materials.metal
);
// Small pontoon safety cabinet.
addBox(
0.8,
1.1,
0.65,
materials.orange,
-3.7,
1.39,
1.7,
pontoon
);
addBox(
0.58,
0.58,
0.03,
materials.white,
-3.7,
1.42,
2.035,
pontoon,
false
);
// ------------------------------------------------------------
// Hinged gangway
// ------------------------------------------------------------
const gangwayStart = new THREE.Vector3(1.95, 0.86, 0);
const gangwayEnd = new THREE.Vector3(5.05, 1.54, 0);
const gangwayVector = new THREE.Vector3().subVectors(
gangwayEnd,
gangwayStart
);
const gangwayLength = gangwayVector.length();
const gangwayAngle = Math.atan2(
gangwayVector.y,
gangwayVector.x
);
const gangwayMid = new THREE.Vector3().addVectors(
gangwayStart,
gangwayEnd
).multiplyScalar(0.5);
const gangwayDeck = addBox(
gangwayLength,
0.12,
1.45,
materials.darkMetal,
gangwayMid.x,
gangwayMid.y,
gangwayMid.z
);
gangwayDeck.rotation.z = gangwayAngle;
// Raised yellow tread slats.
const slatCount = Math.floor(gangwayLength / 0.29);
for (let i = 0; i <= slatCount; i++) {
const t = i / slatCount;
const point = new THREE.Vector3().lerpVectors(
gangwayStart,
gangwayEnd,
t
);
point.y += 0.085;
const slat = addBox(
0.085,
0.035,
1.28,
materials.yellow,
point.x,
point.y,
point.z
);
slat.rotation.z = gangwayAngle;
}
// Hinged vertical rails on both sides.
for (const side of [-1, 1]) {
const start = gangwayStart.clone();
const end = gangwayEnd.clone();
start.z += side * 0.7;
end.z += side * 0.7;
const railSections = 5;
for (let i = 0; i <= railSections; i++) {
const t = i / railSections;
const base = new THREE.Vector3().lerpVectors(start, end, t);
const top = base.clone();
top.y += 1.03;
cylinderBetween(
base,
top,
0.035,
materials.darkMetal,
scene,
6
);
}
const topStart = start.clone();
topStart.y += 1.03;
const topEnd = end.clone();
topEnd.y += 1.03;
cylinderBetween(
topStart,
topEnd,
0.045,
materials.yellow,
scene,
8
);
const midStart = start.clone();
midStart.y += 0.51;
const midEnd = end.clone();
midEnd.y += 0.51;
cylinderBetween(
midStart,
midEnd,
0.028,
materials.metal,
scene,
6
);
}
// Large hinge barrels at both ends.
for (const point of [gangwayStart, gangwayEnd]) {
const hinge = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.14, 1.7, 12),
materials.darkMetal
);
hinge.position.copy(point);
hinge.rotation.x = Math.PI / 2;
hinge.castShadow = true;
scene.add(hinge);
const hingeCap = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.19, 0.08, 12),
materials.yellow
);
hingeCap.position.copy(point);
hingeCap.rotation.x = Math.PI / 2;
hingeCap.castShadow = true;
scene.add(hingeCap);
}
// ------------------------------------------------------------
// Low-poly ferry
// ------------------------------------------------------------
const ferry = new THREE.Group();
ferry.position.set(-1.8, 0, -7.2);
scene.add(ferry);
function createHullGeometry() {
const vertices = [
// top perimeter
-5.0, 0.55, -1.75,
5.7, 0.55, -1.75,
6.0, 0.55, 0.0,
5.7, 0.55, 1.75,
-5.0, 0.55, 1.75,
// bottom perimeter
-4.6, -0.55, -1.25,
5.1, -0.55, -1.25,
5.45, -0.55, 0.0,
5.1, -0.55, 1.25,
-4.6, -0.55, 1.25
];
const indices = [];
for (let i = 0; i < 5; i++) {
const j = (i + 1) % 5;
const a = i;
const b = j;
const c = 5 + i;
const d = 5 + j;
indices.push(a, c, b, b, c, d);
}
// Bottom center and fan.
vertices.push(0, -0.55, 0);
const bottomCenter = 10;
for (let i = 0; i < 5; i++) {
const j = (i + 1) % 5;
indices.push(bottomCenter, 5 + j, 5 + i);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const hullMaterial = new THREE.MeshStandardMaterial({
color: 0x087b79,
roughness: 0.68,
flatShading: true,
side: THREE.DoubleSide
});
const hull = new THREE.Mesh(createHullGeometry(), hullMaterial);
hull.castShadow = true;
hull.receiveShadow = true;
ferry.add(hull);
// Orange rubbing strake.
const rubRail = new THREE.Mesh(
new THREE.BoxGeometry(10.1, 0.16, 3.55),
materials.orange
);
rubRail.position.set(0.35, 0.43, 0);
rubRail.castShadow = true;
ferry.add(rubRail);
// Flat deck shape with pointed bow.
const deckShape = new THREE.Shape();
deckShape.moveTo(-5, -1.75);
deckShape.lineTo(5.7, -1.75);
deckShape.lineTo(6, 0);
deckShape.lineTo(5.7, 1.75);
deckShape.lineTo(-5, 1.75);
deckShape.closePath();
const ferryDeck = new THREE.Mesh(
new THREE.ShapeGeometry(deckShape),
materials.cream
);
ferryDeck.rotation.x = -Math.PI / 2;
ferryDeck.position.y = 0.59;
ferryDeck.receiveShadow = true;
ferry.add(ferryDeck);
// Cabin.
addBox(
4.2,
1.55,
2.72,
materials.cream,
-1.4,
1.36,
0,
ferry
);
// Teal lower cabin stripe.
addBox(
4.24,
0.38,
2.76,
materials.tealLight,
-1.4,
0.89,
0,
ferry
);
// Roof and orange fascia.
addBox(
4.6,
0.18,
3.08,
materials.orange,
-1.4,
2.23,
0,
ferry
);
addBox(
4.32,
0.12,
2.86,
materials.white,
-1.4,
2.36,
0,
ferry
);
// Side windows.
for (const side of [-1, 1]) {
for (const x of [-2.75, -1.65, -0.55]) {
addBox(
0.82,
0.57,
0.045,
materials.glass,
x,
1.57,
side * 1.385,
ferry,
false
);
}
}
// Front windshield.
addBox(
0.045,
0.65,
2.18,
materials.glass,
0.72,
1.56,
0,
ferry,
false
);
// Side door.
addBox(
0.58,
1.12,
0.05,
materials.teal,
-3.05,
1.22,
-1.39,
ferry
);
// Bench seats on the open bow.
for (const z of [-0.72, 0.72]) {
addBox(
1.75,
0.15,
0.46,
materials.tealLight,
2.5,
0.94,
z,
ferry
);
for (const x of [1.85, 3.15]) {
addBox(
0.1,
0.36,
0.1,
materials.darkMetal,
x,
0.75,
z,
ferry
);
}
}
// Bow safety rails.
addRailing(
new THREE.Vector3(0.75, 0.62, -1.58),
new THREE.Vector3(5.55, 0.62, -1.12),
0.82,
ferry,
materials.white
);
addRailing(
new THREE.Vector3(0.75, 0.62, 1.58),
new THREE.Vector3(5.55, 0.62, 1.12),
0.82,
ferry,
materials.white
);
addRailing(
new THREE.Vector3(5.55, 0.62, -1.12),
new THREE.Vector3(5.82, 0.62, 0),
0.82,
ferry,
materials.white
);
addRailing(
new THREE.Vector3(5.55, 0.62, 1.12),
new THREE.Vector3(5.82, 0.62, 0),
0.82,
ferry,
materials.white
);
// Life rings on the cabin sides.
for (const side of [-1, 1]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.28, 0.085, 6, 12),
materials.orange
);
ring.position.set(-2.8, 1.22, side * 1.43);
ring.castShadow = true;
ferry.add(ring);
}
// Roof mast and navigation light.
cylinderBetween(
new THREE.Vector3(-1.4, 2.42, 0),
new THREE.Vector3(-1.4, 3.35, 0),
0.035,
materials.metal,
ferry,
6
);
const navigationLight = new THREE.Mesh(
new THREE.SphereGeometry(0.11, 8, 6),
new THREE.MeshStandardMaterial({
color: 0xff5545,
emissive: 0x8a1208,
emissiveIntensity: 0.5
})
);
navigationLight.position.set(-1.4, 3.38, 0);
ferry.add(navigationLight);
// Small Nigerian color flag.
addBox(
0.8,
0.25,
0.025,
materials.green,
-1.0,
3.05,
0.025,
ferry
);
addBox(
0.8,
0.25,
0.025,
materials.white,
-1.0,
2.8,
0.025,
ferry
);
addBox(
0.8,
0.25,
0.025,
materials.green,
-1.0,
2.55,
0.025,
ferry
);
// Mooring ropes between ferry and pontoon.
cylinderBetween(
new THREE.Vector3(-5.2, 0.55, -5.55),
new THREE.Vector3(-4.25, 0.88, -2.7),
0.025,
materials.rope,
scene,
6
);
cylinderBetween(
new THREE.Vector3(2.8, 0.55, -5.55),
new THREE.Vector3(0.3, 0.88, -2.7),
0.025,
materials.rope,
scene,
6
);
// ------------------------------------------------------------
// Shore terminal, shelter, and signage
// ------------------------------------------------------------
function makeSignTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = "#073d48";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#26aaa0";
context.fillRect(0, 0, 18, canvas.height);
context.fillRect(canvas.width - 18, 0, 18, canvas.height);
context.fillStyle = "#f6f2df";
context.textAlign = "center";
context.font = "700 78px Arial, sans-serif";
context.fillText("LAGOS WATERFRONT", 512, 112);
context.fillStyle = "#72e3d3";
context.font = "700 31px Arial, sans-serif";
context.fillText("FERRY TERMINAL", 512, 169);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const terminalGroup = new THREE.Group();
terminalGroup.position.set(10.2, 1.47, 3.8);
scene.add(terminalGroup);
// Terminal platform.
addBox(
5.8,
0.16,
5.3,
materials.concreteLight,
0,
0.08,
0,
terminalGroup
);
// Four posts.
for (const x of [-2.45, 2.45]) {
for (const z of [-2.15, 2.15]) {
addBox(
0.18,
2.5,
0.18,
materials.teal,
x,
1.34,
z,
terminalGroup
);
}
}
// Flat angular roof.
const roof = addBox(
6.4,
0.25,
5.9,
materials.orange,
0,
2.66,
0,
terminalGroup
);
roof.rotation.z = -0.025;
// Sign on the front fascia.
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(4.8, 1.2),
new THREE.MeshBasicMaterial({
map: makeSignTexture(),
side: THREE.DoubleSide
})
);
sign.position.set(0, 2.1, 2.83);
terminalGroup.add(sign);
// Terminal bench.
addBox(
2.1,
0.14,
0.48,
materials.wood,
12.0,
2.03,
1.7
);
for (const x of [11.25, 12.75]) {
addBox(
0.12,
0.52,
0.36,
materials.darkMetal,
x,
1.74,
1.7
);
}
// ------------------------------------------------------------
// Low-poly shore buildings
// ------------------------------------------------------------
addBox(
6.8,
3.2,
5.4,
materials.cream,
14.0,
3.05,
-5.7
);
const warehouseRoof = addBox(
7.2,
0.28,
5.8,
materials.teal,
14.0,
4.78,
-5.7
);
warehouseRoof.rotation.z = -0.035;
addBox(
2.4,
2.0,
0.08,
materials.glass,
13.0,
2.55,
-2.98,
scene,
false
);
addBox(
1.5,
2.35,
0.1,
materials.orange,
15.4,
2.64,
-2.96
);
// Cargo stack.
addBox(
2.0,
1.4,
1.8,
materials.tealLight,
8.8,
2.18,
-8.0
);
addBox(
1.8,
1.2,
1.6,
materials.orange,
8.8,
3.48,
-8.0
);
// ------------------------------------------------------------
// Stylized palm trees
// ------------------------------------------------------------
function addPalmTree(x, z, height = 4.4) {
const base = new THREE.Vector3(x, 1.47, z);
const crown = new THREE.Vector3(
x + 0.35,
1.47 + height,
z + 0.1
);
cylinderBetween(
base,
crown,
0.19,
materials.trunk,
scene,
7
);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2 + 0.2;
const length = 1.7 + (i % 2) * 0.35;
const direction = new THREE.Vector3(
Math.cos(angle),
-0.28 - (i % 3) * 0.08,
Math.sin(angle)
).normalize();
const end = crown.clone().addScaledVector(direction, length);
const middle = crown.clone().addScaledVector(direction, length * 0.5);
const leaf = new THREE.Mesh(
new THREE.ConeGeometry(0.38, length, 3),
i % 2 === 0 ? materials.leaf : materials.leafLight
);
leaf.position.copy(middle);
leaf.quaternion.setFromUnitVectors(up, direction);
leaf.castShadow = true;
scene.add(leaf);
}
const coconut = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.25, 0),
materials.trunk
);
coconut.position.copy(crown).add(new THREE.Vector3(0, -0.2, 0));
coconut.castShadow = true;
scene.add(coconut);
}
addPalmTree(17.2, 7.2, 4.8);
addPalmTree(18.1, -8.3, 4.2);
// ------------------------------------------------------------
// Additional waterfront details
// ------------------------------------------------------------
// Painted boarding arrows on the quay.
const arrowShape = new THREE.Shape();
arrowShape.moveTo(-0.55, -0.2);
arrowShape.lineTo(0.05, -0.2);
arrowShape.lineTo(0.05, -0.48);
arrowShape.lineTo(0.65, 0);
arrowShape.lineTo(0.05, 0.48);
arrowShape.lineTo(0.05, 0.2);
arrowShape.lineTo(-0.55, 0.2);
arrowShape.closePath();
const arrow = new THREE.Mesh(
new THREE.ShapeGeometry(arrowShape),
new THREE.MeshBasicMaterial({
color: 0xf5c94e,
side: THREE.DoubleSide
})
);
arrow.rotation.x = -Math.PI / 2;
arrow.rotation.z = Math.PI;
arrow.position.set(6.6, 1.575, 0);
scene.add(arrow);
// Small bollards and safety posts around the terminal.
for (const z of [0.8, 6.8]) {
addBollard(6.6, z);
}
// A few low crates on the shore.
addBox(
0.85,
0.8,
0.85,
materials.wood,
16.2,
1.87,
0.6
);
addBox(
0.7,
0.65,
0.7,
materials.yellow,
16.25,
2.58,
0.6
);
// ------------------------------------------------------------
// Direct camera controls — no external controls addon
// ------------------------------------------------------------
const canvas = renderer.domElement;
let dragging = false;
let panning = false;
let previousX = 0;
let previousY = 0;
const cameraRight = new THREE.Vector3();
const cameraUp = new THREE.Vector3();
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.shiftKey || event.button === 2;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
event.preventDefault();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
if (panning) {
cameraRight.set(1, 0, 0).applyQuaternion(camera.quaternion);
cameraUp.set(0, 1, 0).applyQuaternion(camera.quaternion);
const scale = currentCamera.radius * 0.0014;
target.addScaledVector(cameraRight, -deltaX * scale);
target.addScaledVector(cameraUp, deltaY * scale);
} else {
desiredCamera.theta -= deltaX * 0.006;
desiredCamera.phi -= deltaY * 0.005;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi,
0.28,
1.42
);
}
});
function stopDragging(event) {
dragging = false;
panning = false;
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredCamera.radius *= Math.exp(event.deltaY * 0.001);
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius,
12,
65
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
desiredCamera.radius = defaultCamera.radius;
desiredCamera.theta = defaultCamera.theta;
desiredCamera.phi = defaultCamera.phi;
target.set(0.5, 0.8, -1.2);
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
let frame = 0;
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.05);
// Gentle water deformation.
for (let i = 0; i < waterPositions.count; i++) {
const x = waterPositions.getX(i);
const z = waterPositions.getZ(i);
const wave =
Math.sin(x * 0.42 + elapsed * 0.75) * 0.045 +
Math.sin(z * 0.56 - elapsed * 0.52) * 0.035 +
Math.sin((x + z) * 0.25 + elapsed * 0.4) * 0.025;
waterPositions.setY(i, wave);
}
waterPositions.needsUpdate = true;
// Gentle ferry motion.
ferry.position.y = Math.sin(elapsed * 0.82) * 0.035;
ferry.rotation.z = Math.sin(elapsed * 0.61) * 0.006;
ferry.rotation.x = Math.sin(elapsed * 0.47 + 1.2) * 0.003;
// Navigation light pulse.
navigationLight.material.emissiveIntensity =
0.35 + Math.max(0, Math.sin(elapsed * 3)) * 0.65;
// Smooth camera movement.
const damping = 1 - Math.pow(0.001, delta);
currentCamera.radius +=
(desiredCamera.radius - currentCamera.radius) * damping;
currentCamera.theta +=
(desiredCamera.theta - currentCamera.theta) * damping;
currentCamera.phi +=
(desiredCamera.phi - currentCamera.phi) * damping;
const radius = currentCamera.radius;
const theta = currentCamera.theta;
const phi = currentCamera.phi;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
frame++;
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```