Prompt specification
Build or customize the Three.js 3D scene "Rescue Boat Seats and Dock Tokens" 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: Rescue Boat Seats and Dock Tokens
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/rescue-boat-seats-and-dock-tokens-x3561
Scene Description Prompt:
A stylized fictional rescue boat with clearly counted seats beside a calm dock queue, showing capacity as physical spaces. One HTML file, Three.js from cdnjs.
Working Three.js Starter (rescue-boat-seats-and-dock-tokens-x3561):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Harbor Eight — Stylized Rescue Boat</title>
<style>
:root {
--ink: #173946;
--muted: #607981;
--cream: #fffaf0;
--orange: #f36b3f;
--teal: #17677b;
--glass: rgba(255, 250, 240, 0.82);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dcecef;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 28px;
left: 28px;
width: min(390px, calc(100vw - 56px));
padding: 20px 22px 21px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 22px;
background: var(--glass);
box-shadow: 0 16px 50px rgba(29, 71, 80, 0.13);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--orange);
box-shadow: 0 0 0 5px rgba(243, 107, 63, 0.14);
content: "";
}
h1 {
margin: 0;
font-size: clamp(30px, 4vw, 48px);
font-weight: 750;
letter-spacing: -0.055em;
line-height: 0.98;
}
.description {
max-width: 330px;
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.capacity-card {
position: fixed;
top: 28px;
right: 28px;
width: 220px;
padding: 17px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 20px;
background: var(--glass);
box-shadow: 0 16px 50px rgba(29, 71, 80, 0.13);
backdrop-filter: blur(14px);
pointer-events: none;
}
.capacity-label {
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.capacity-number {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin: 3px 0 12px;
}
.capacity-number strong {
font-size: 48px;
font-weight: 780;
letter-spacing: -0.07em;
line-height: 1;
}
.capacity-number span {
padding-bottom: 6px;
color: var(--muted);
font-size: 11px;
font-weight: 700;
}
.seat-pips {
display: grid;
grid-template-columns: repeat(8, 1fr);
gap: 5px;
}
.seat-pips i {
display: grid;
aspect-ratio: 1;
place-items: center;
border-radius: 6px;
background: var(--orange);
color: white;
font-size: 10px;
font-style: normal;
font-weight: 800;
box-shadow: inset 0 -2px 0 rgba(104, 38, 22, 0.16);
}
.legend {
position: fixed;
left: 28px;
bottom: 26px;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 999px;
background: rgba(255, 250, 240, 0.76);
color: var(--muted);
font-size: 11px;
font-weight: 650;
backdrop-filter: blur(10px);
pointer-events: none;
}
.legend .dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #4baa83;
box-shadow: 0 0 0 4px rgba(75, 170, 131, 0.15);
}
.controls {
position: fixed;
right: 28px;
bottom: 26px;
display: flex;
align-items: center;
gap: 10px;
pointer-events: none;
}
.controls span {
padding: 9px 12px;
border-radius: 999px;
background: rgba(255, 250, 240, 0.7);
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
backdrop-filter: blur(10px);
}
button {
width: 40px;
height: 40px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 50%;
background: var(--cream);
color: var(--ink);
box-shadow: 0 8px 25px rgba(29, 71, 80, 0.14);
cursor: pointer;
pointer-events: auto;
transition: transform 160ms ease, background 160ms ease;
}
button:hover {
transform: translateY(-2px);
background: white;
}
button svg {
width: 18px;
height: 18px;
vertical-align: middle;
}
@media (max-width: 760px) {
.title-card {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
padding: 16px 18px;
}
.description {
display: none;
}
.capacity-card {
top: auto;
right: 16px;
bottom: 72px;
width: 185px;
padding: 14px;
}
.capacity-number {
margin-bottom: 9px;
}
.capacity-number strong {
font-size: 38px;
}
.legend {
left: 16px;
bottom: 16px;
}
.controls {
right: 16px;
bottom: 16px;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive 3D scene of an eight-seat rescue boat beside a calm dock queue"></main>
<section class="title-card">
<div class="eyebrow">Harbor Eight · fictional rescue launch</div>
<h1>Eight places.<br>One calm crossing.</h1>
<p class="description">
A compact rescue boat with eight clearly numbered onboard seats,
paired with an orderly dock queue and a low-capacity boarding area.
</p>
</section>
<aside class="capacity-card" aria-label="Boarding capacity: eight seats">
<div class="capacity-label">Onboard capacity</div>
<div class="capacity-number">
<strong>08</strong>
<span>PHYSICAL SEATS</span>
</div>
<div class="seat-pips" aria-label="Seats numbered 1 through 8">
<i>1</i><i>2</i><i>3</i><i>4</i>
<i>5</i><i>6</i><i>7</i><i>8</i>
</div>
</aside>
<div class="legend">
<span class="dot"></span>
<span>Calm queue · 4 waiting boarders</span>
</div>
<div class="controls">
<span>DRAG TO ORBIT · SCROLL TO ZOOM</span>
<button id="reset" type="button" aria-label="Reset camera view" title="Reset camera">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M4 4v6h6M5.2 15a8 8 0 1 0 1.7-8.6L4 10"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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;
renderer.domElement.setAttribute(
"aria-label",
"Eight numbered rescue boat seats beside a dock queue. Drag to orbit and scroll to zoom."
);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdcecef);
scene.fog = new THREE.Fog(0xdcecef, 19, 42);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(-0.05, 0.85, 0);
const initialView = {
theta: 2.42,
phi: 0.96,
radius: 14.7,
target: cameraTarget.clone()
};
let desiredTheta = initialView.theta;
let desiredPhi = initialView.phi;
let desiredRadius = initialView.radius;
let currentTheta = desiredTheta;
let currentPhi = desiredPhi;
let currentRadius = desiredRadius;
const desiredTarget = initialView.target.clone();
const currentTarget = desiredTarget.clone();
const palette = {
hull: 0x12647a,
hullDark: 0x0c4b5e,
deck: 0xf2ead9,
cream: 0xfff9eb,
orange: 0xf36b3f,
orangeDark: 0xb7432a,
teal: 0x17677b,
glass: 0x244d58,
dark: 0x183640,
rope: 0xe4d9be,
wood: 0xa9754f,
green: 0x69a995
};
const standard = (color, roughness = 0.75, metalness = 0.0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: false
});
const materials = {
hull: standard(palette.hull, 0.62, 0.03),
hullDark: standard(palette.hullDark, 0.68),
deck: standard(palette.deck, 0.86),
cream: standard(palette.cream, 0.78),
orange: standard(palette.orange, 0.67),
orangeDark: standard(palette.orangeDark, 0.75),
teal: standard(palette.teal, 0.68),
glass: new THREE.MeshStandardMaterial({
color: palette.glass,
roughness: 0.24,
metalness: 0.12
}),
dark: standard(palette.dark, 0.82),
rope: standard(palette.rope, 0.95),
wood: standard(palette.wood, 0.92),
green: standard(palette.green, 0.9),
water: new THREE.MeshStandardMaterial({
color: 0x78b7c1,
roughness: 0.4,
metalness: 0.06
})
};
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function createLabelTexture(text, background = "#fff9eb", foreground = "#173946") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 5, 5, 502, 246, 42);
ctx.fillStyle = background;
ctx.fill();
const lines = text.split("\n");
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
if (lines.length === 1) {
ctx.font = "800 104px system-ui, sans-serif";
ctx.fillText(lines[0], 256, 132);
} else {
ctx.font = "800 70px system-ui, sans-serif";
ctx.fillText(lines[0], 256, 94);
ctx.font = "800 50px system-ui, sans-serif";
ctx.fillText(lines[1], 256, 174);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function makeTextPlane(
text,
width,
height,
background = "#fff9eb",
foreground = "#173946"
) {
const texture = createLabelTexture(text, background, foreground);
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
side: THREE.DoubleSide,
toneMapped: false
});
return new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
}
function cylinderBetween(a, b, radius, material, radialSegments = 10) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
return mesh;
}
// Lighting
const hemisphere = new THREE.HemisphereLight(0xf5fbfa, 0x527681, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d8, 3.25);
sun.position.set(-8, 13, -7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9dd9e1, 1.1);
fill.position.set(10, 6, 10);
scene.add(fill);
// Water
const water = new THREE.Mesh(new THREE.PlaneGeometry(80, 80), materials.water);
water.rotation.x = -Math.PI / 2;
water.position.y = -0.025;
water.receiveShadow = true;
scene.add(water);
// Soft, graphic water rings
const rippleLines = [];
let seed = 37;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 26; i++) {
const x = (random() - 0.5) * 27;
const z = (random() - 0.5) * 25;
if (Math.abs(x) < 4.4 && Math.abs(z) < 6.3) continue;
const radiusX = 0.35 + random() * 1.05;
const radiusZ = 0.12 + random() * 0.32;
const points = [];
for (let j = 0; j <= 48; j++) {
const angle = (j / 48) * Math.PI * 2;
points.push(
new THREE.Vector3(
x + Math.cos(angle) * radiusX,
0.012,
z + Math.sin(angle) * radiusZ
)
);
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineBasicMaterial({
color: 0xd8f1ef,
transparent: true,
opacity: 0.14 + random() * 0.17
});
const line = new THREE.LineLoop(geometry, material);
line.userData.phase = random() * Math.PI * 2;
line.userData.baseOpacity = material.opacity;
scene.add(line);
rippleLines.push(line);
}
// Distant low-poly shoreline
const shorelineMaterial = standard(0x8cb59c, 1);
[
[-10, -0.55, 15, 4.2, 1.4],
[9, -0.65, 18, 5.2, 1.6],
[1, -0.8, 22, 3.5, 1.2]
].forEach(([x, y, z, sx, sy]) => {
const island = new THREE.Mesh(
new THREE.IcosahedronGeometry(1, 2),
shorelineMaterial
);
island.position.set(x, y, z);
island.scale.set(sx, sy, sx * 0.65);
island.receiveShadow = true;
scene.add(island);
});
// Dock structure
const dock = new THREE.Group();
scene.add(dock);
const dockX = 1.05;
const dockWidth = 2.7;
const dockLength = 12;
const beam = new THREE.Mesh(
new THREE.BoxGeometry(dockWidth + 0.12, 0.25, dockLength),
materials.wood
);
beam.position.set(dockX, 0.36, 0);
beam.castShadow = true;
beam.receiveShadow = true;
dock.add(beam);
const plankMaterials = [
standard(0xc99568, 0.92),
standard(0xd1a575, 0.92),
standard(0xbd895f, 0.92)
];
const plankCount = 29;
const plankLength = dockLength / plankCount;
for (let i = 0; i < plankCount; i++) {
const plank = new THREE.Mesh(
new THREE.BoxGeometry(dockWidth, 0.17, plankLength * 0.91),
plankMaterials[i % plankMaterials.length]
);
plank.position.set(
dockX,
0.56,
-dockLength / 2 + plankLength * (i + 0.5)
);
plank.castShadow = true;
plank.receiveShadow = true;
dock.add(plank);
}
[-5.65, -2.9, 0, 2.9, 5.65].forEach((z) => {
[-0.18, 2.28].forEach((x) => {
const pile = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.15, 1.45, 10),
materials.wood
);
pile.position.set(x, 0.12, z);
pile.castShadow = true;
dock.add(pile);
});
});
// Physical capacity sign at the boarding end
const signPost = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.065, 1.55, 10),
materials.dark
);
signPost.position.set(2.15, 1.25, 3.85);
signPost.castShadow = true;
dock.add(signPost);
const signBoard = new THREE.Mesh(
new THREE.BoxGeometry(1.42, 0.9, 0.11),
materials.cream
);
signBoard.position.set(2.15, 2.0, 3.85);
signBoard.castShadow = true;
dock.add(signBoard);
const capacitySign = makeTextPlane(
"CAPACITY\n8 SEATS",
1.28,
0.76,
"#fff9eb",
"#17677b"
);
capacitySign.position.set(2.15, 2.0, 3.788);
capacitySign.rotation.y = Math.PI;
dock.add(capacitySign);
// Calm queue: a single orderly line with rope stanchions
const stanchionPositions = [
new THREE.Vector3(2.0, 0, -4.55),
new THREE.Vector3(2.0, 0, -2.75),
new THREE.Vector3(2.0, 0, -0.95),
new THREE.Vector3(2.0, 0, 0.85)
];
const stanchionMaterial = standard(0xd8d4c7, 0.42, 0.28);
const ropeMaterial = standard(palette.rope, 0.92);
function addRope(a, b, sag = 0.15) {
const midpoint = a.clone().add(b).multiplyScalar(0.5);
midpoint.y -= sag;
const curve = new THREE.CatmullRomCurve3([
a.clone(),
midpoint,
b.clone()
]);
const rope = new THREE.Mesh(
new THREE.TubeGeometry(curve, 24, 0.035, 7, false),
ropeMaterial
);
rope.castShadow = true;
dock.add(rope);
}
stanchionPositions.forEach((position, index) => {
const base = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.16, 0.07, 18),
materials.dark
);
base.position.set(position.x, 0.66, position.z);
base.castShadow = true;
dock.add(base);
const post = new THREE.Mesh(
new THREE.CylinderGeometry(0.04, 0.055, 0.78, 10),
stanchionMaterial
);
post.position.set(position.x, 1.06, position.z);
post.castShadow = true;
dock.add(post);
const cap = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 12, 8),
stanchionMaterial
);
cap.position.set(position.x, 1.46, position.z);
cap.castShadow = true;
dock.add(cap);
if (index < stanchionPositions.length - 1) {
const next = stanchionPositions[index + 1];
addRope(
new THREE.Vector3(position.x, 1.38, position.z),
new THREE.Vector3(next.x, 1.38, next.z),
0.16
);
}
});
// Queue position marks on the dock
[-3.9, -2.65, -1.4, -0.15].forEach((z, index) => {
const marker = new THREE.Mesh(
new THREE.CircleGeometry(0.2, 24),
new THREE.MeshBasicMaterial({
color: 0xd8eee7,
transparent: true,
opacity: 0.65,
side: THREE.DoubleSide
})
);
marker.rotation.x = -Math.PI / 2;
marker.position.set(0.58, 0.652, z);
dock.add(marker);
});
function createPerson(coatColor, x, z, rotation = 0) {
const person = new THREE.Group();
const coat = standard(coatColor, 0.95);
const skin = standard(0xc98f6b, 0.95);
const trousers = standard(0x344f59, 0.95);
const torso = new THREE.Mesh(
new THREE.CapsuleGeometry(0.22, 0.55, 5, 12),
coat
);
torso.position.y = 1.35;
torso.castShadow = true;
person.add(torso);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.22, 16, 12),
skin
);
head.position.y = 1.98;
head.castShadow = true;
person.add(head);
const hair = new THREE.Mesh(
new THREE.SphereGeometry(0.225, 16, 10, 0, Math.PI * 2, 0, Math.PI * 0.52),
standard(0x3f3532, 1)
);
hair.position.y = 2.025;
hair.castShadow = true;
person.add(hair);
[-0.12, 0.12].forEach((legX) => {
const leg = cylinderBetween(
new THREE.Vector3(legX, 0.69, 0),
new THREE.Vector3(legX, 1.12, 0),
0.075,
trousers,
8
);
person.add(leg);
const shoe = new THREE.Mesh(
new THREE.BoxGeometry(0.17, 0.1, 0.28),
materials.dark
);
shoe.position.set(legX, 0.66, 0.055);
shoe.castShadow = true;
person.add(shoe);
});
[-1, 1].forEach((side) => {
const arm = cylinderBetween(
new THREE.Vector3(side * 0.22, 1.59, 0),
new THREE.Vector3(side * 0.3, 1.12, 0.02),
0.065,
coat,
8
);
person.add(arm);
});
person.position.set(x, 0.62, z);
person.rotation.y = rotation;
dock.add(person);
return person;
}
createPerson(0x6f9c91, 0.58, -3.9, -0.2);
createPerson(0xd9945d, 0.58, -2.65, -0.1);
createPerson(0x67869b, 0.58, -1.4, 0.12);
createPerson(0xb87b71, 0.58, -0.15, 0.05);
// Boat
const boat = new THREE.Group();
boat.position.set(-1.85, 0, 0);
scene.add(boat);
const sections = [
{ z: -4.0, w: 1.2 },
{ z: -3.72, w: 1.48 },
{ z: 2.18, w: 1.48 },
{ z: 3.0, w: 1.27 },
{ z: 3.78, w: 0.72 },
{ z: 4.22, w: 0.17 }
];
function createHullGeometry() {
const vertices = [];
const indices = [];
sections.forEach((section) => {
const w = section.w;
vertices.push(
-w, 0.48, section.z,
w, 0.48, section.z,
w * 0.82, -0.19, section.z,
w * 0.45, -0.58, section.z,
-w * 0.45, -0.58, section.z,
-w * 0.82, -0.19, section.z
);
});
for (let s = 0; s < sections.length - 1; s++) {
for (let j = 0; j < 6; j++) {
const a = s * 6 + j;
const b = s * 6 + ((j + 1) % 6);
const c = (s + 1) * 6 + ((j + 1) % 6);
const d = (s + 1) * 6 + j;
indices.push(a, b, d, b, c, d);
}
}
const sternCenter = vertices.length / 3;
vertices.push(0, -0.04, sections[0].z);
for (let j = 0; j < 6; j++) {
indices.push(sternCenter, (j + 1) % 6, j);
}
const bowCenter = vertices.length / 3;
vertices.push(0, -0.02, sections[sections.length - 1].z);
const lastOffset = (sections.length - 1) * 6;
for (let j = 0; j < 6; j++) {
indices.push(
bowCenter,
lastOffset + j,
lastOffset + ((j + 1) % 6)
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const hullMaterial = materials.hull.clone();
hullMaterial.side = THREE.DoubleSide;
const hull = new THREE.Mesh(createHullGeometry(), hullMaterial);
hull.castShadow = true;
hull.receiveShadow = true;
boat.add(hull);
// Flat deck follows the hull outline
const deckContour = [
new THREE.Vector2(-1.34, -3.78),
new THREE.Vector2(1.34, -3.78),
new THREE.Vector2(1.34, 2.2),
new THREE.Vector2(1.18, 3.0),
new THREE.Vector2(0.68, 3.8),
new THREE.Vector2(0, 4.08),
new THREE.Vector2(-0.68, 3.8),
new THREE.Vector2(-1.18, 3.0),
new THREE.Vector2(-1.34, 2.2)
];
const deckIndices = THREE.ShapeUtils.triangulateShape(deckContour, []);
const deckPositions = [];
deckIndices.flat().forEach((index) => {
const p = deckContour[index];
deckPositions.push(p.x, 0.525, p.y);
});
const deckGeometry = new THREE.BufferGeometry();
deckGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(deckPositions, 3)
);
deckGeometry.computeVertexNormals();
const deckMaterial = materials.deck.clone();
deckMaterial.side = THREE.DoubleSide;
const deck = new THREE.Mesh(deckGeometry, deckMaterial);
deck.castShadow = true;
deck.receiveShadow = true;
boat.add(deck);
// White gunwale
const railPoints = [
new THREE.Vector3(-1.4, 0.44, -3.72),
new THREE.Vector3(1.4, 0.44, -3.72),
new THREE.Vector3(1.4, 0.44, 2.2),
new THREE.Vector3(1.2, 0.44, 3.0),
new THREE.Vector3(0.68, 0.44, 3.8),
new THREE.Vector3(0, 0.44, 4.1),
new THREE.Vector3(-0.68, 0.44, 3.8),
new THREE.Vector3(-1.2, 0.44, 3.0),
new THREE.Vector3(-1.4, 0.44, 2.2)
];
const railCurve = new THREE.CatmullRomCurve3(
railPoints,
true,
"centripetal"
);
const rail = new THREE.Mesh(
new THREE.TubeGeometry(railCurve, 160, 0.065, 8, true),
materials.cream
);
rail.castShadow = true;
boat.add(rail);
// Exactly eight physical seats: two columns by four rows
const seatNumberTextures = [];
const seatRows = [-2.78, -1.73, -0.68, 0.37];
const seatColumns = [-0.7, 0.7];
let seatCount = 0;
seatRows.forEach((rowZ) => {
seatColumns.forEach((columnX) => {
seatCount += 1;
const number = String(seatCount).padStart(2, "0");
const seatGroup = new THREE.Group();
seatGroup.position.set(columnX, 0, rowZ);
const cushion = new THREE.Mesh(
new THREE.BoxGeometry(0.78, 0.14, 0.62),
materials.orange
);
cushion.position.y = 0.9;
cushion.castShadow = true;
cushion.receiveShadow = true;
seatGroup.add(cushion);
const back = new THREE.Mesh(
new THREE.BoxGeometry(0.78, 0.68, 0.13),
materials.orange
);
back.position.set(0, 1.28, -0.28);
back.castShadow = true;
seatGroup.add(back);
const lowerBack = new THREE.Mesh(
new THREE.BoxGeometry(0.8, 0.08, 0.15),
materials.orangeDark
);
lowerBack.position.set(0, 0.97, -0.28);
seatGroup.add(lowerBack);
[-0.28, 0.28].forEach((legX) => {
const leg = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.045, 0.31, 8),
materials.dark
);
leg.position.set(legX, 0.69, -0.08);
leg.castShadow = true;
seatGroup.add(leg);
});
const labelTexture = createLabelTexture(number, "#fff6e5", "#173946");
seatNumberTextures.push(labelTexture);
const labelMaterial = new THREE.MeshBasicMaterial({
map: labelTexture,
transparent: true,
side: THREE.DoubleSide,
toneMapped: false
});
const rearLabel = new THREE.Mesh(
new THREE.PlaneGeometry(0.34, 0.23),
labelMaterial
);
rearLabel.position.set(0, 1.31, -0.348);
rearLabel.rotation.y = Math.PI;
seatGroup.add(rearLabel);
const frontLabel = new THREE.Mesh(
new THREE.PlaneGeometry(0.34, 0.23),
labelMaterial
);
frontLabel.position.set(0, 1.31, -0.212);
seatGroup.add(frontLabel);
boat.add(seatGroup);
});
});
// Cabin
const cabin = new THREE.Mesh(
new THREE.BoxGeometry(2.25, 1.28, 1.68),
materials.cream
);
cabin.position.set(0, 1.25, 2.22);
cabin.castShadow = true;
cabin.receiveShadow = true;
boat.add(cabin);
const roof = new THREE.Mesh(
new THREE.BoxGeometry(2.46, 0.18, 1.9),
materials.orange
);
roof.position.set(0, 1.98, 2.2);
roof.castShadow = true;
boat.add(roof);
const windshield = new THREE.Mesh(
new THREE.BoxGeometry(1.92, 0.58, 0.055),
materials.glass
);
windshield.position.set(0, 1.53, 3.08);
windshield.castShadow = true;
boat.add(windshield);
const windshieldDivider = new THREE.Mesh(
new THREE.BoxGeometry(0.045, 0.61, 0.07),
materials.cream
);
windshieldDivider.position.set(0, 1.53, 3.115);
boat.add(windshieldDivider);
[-1, 1].forEach((side) => {
const window = new THREE.Mesh(
new THREE.BoxGeometry(0.045, 0.58, 1.18),
materials.glass
);
window.position.set(side * 1.14, 1.53, 2.12);
window.castShadow = true;
boat.add(window);
});
const rescueText = makeTextPlane(
"RESCUE 08",
1.25,
0.39,
"#17677b",
"#fff9eb"
);
rescueText.position.set(1.144, 1.11, 2.3);
rescueText.rotation.y = Math.PI / 2;
boat.add(rescueText);
// Life ring on the dock-facing cabin side
const lifeRing = new THREE.Mesh(
new THREE.TorusGeometry(0.23, 0.07, 10, 24),
materials.orange
);
lifeRing.position.set(1.17, 1.48, 1.78);
lifeRing.rotation.y = Math.PI / 2;
lifeRing.castShadow = true;
boat.add(lifeRing);
// Small emergency beacon
const beaconBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.15, 0.1, 16),
materials.dark
);
beaconBase.position.set(0, 2.12, 2.17);
boat.add(beaconBase);
const redBeaconMaterial = new THREE.MeshStandardMaterial({
color: 0xff493b,
emissive: 0xff2015,
emissiveIntensity: 0.8,
roughness: 0.25
});
const blueBeaconMaterial = new THREE.MeshStandardMaterial({
color: 0x4bbce8,
emissive: 0x168bd0,
emissiveIntensity: 0.6,
roughness: 0.25
});
const redBeacon = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 14, 10),
redBeaconMaterial
);
redBeacon.position.set(-0.11, 2.22, 2.17);
boat.add(redBeacon);
const blueBeacon = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 14, 10),
blueBeaconMaterial
);
blueBeacon.position.set(0.11, 2.22, 2.17);
boat.add(blueBeacon);
// Fenders between hull and dock
[-2.6, -0.9, 0.95].forEach((z) => {
const fender = new THREE.Mesh(
new THREE.TorusGeometry(0.21, 0.065, 9, 20),
standard(0x56666a, 0.9)
);
fender.position.set(1.46, 0.17, z);
fender.rotation.y = Math.PI / 2;
fender.castShadow = true;
boat.add(fender);
});
// Small boarding step at the open edge
const step = new THREE.Mesh(
new THREE.BoxGeometry(0.43, 0.12, 0.86),
materials.cream
);
step.position.set(1.46, 0.45, 0.87);
step.castShadow = true;
boat.add(step);
// A few low dock-edge bumpers
[-4.7, -1.8, 1.2, 4.4].forEach((z) => {
const bumper = new THREE.Mesh(
new THREE.CylinderGeometry(0.1, 0.12, 0.35, 10),
materials.dark
);
bumper.rotation.z = Math.PI / 2;
bumper.position.set(-0.31, 0.37, z);
bumper.castShadow = true;
dock.add(bumper);
});
// Custom camera controls: orbit, zoom, touch pinch, double-click reset
const pointers = new Map();
let dragPointer = null;
let previousX = 0;
let previousY = 0;
let previousPinchDistance = 0;
function resetCamera() {
desiredTheta = initialView.theta;
desiredPhi = initialView.phi;
desiredRadius = initialView.radius;
desiredTarget.copy(initialView.target);
}
function pointerDistance() {
const points = [...pointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
dragPointer = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
} else if (pointers.size === 2) {
previousPinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size >= 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * (previousPinchDistance / distance),
8.5,
24
);
}
previousPinchDistance = distance;
return;
}
if (event.pointerId !== dragPointer) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredTheta -= dx * 0.0052;
desiredPhi = THREE.MathUtils.clamp(desiredPhi - dy * 0.0045, 0.42, 1.38);
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) {
previousPinchDistance = 0;
}
if (dragPointer === event.pointerId) {
dragPointer = pointers.size ? [...pointers.keys()][0] : null;
const remaining = pointers.get(dragPointer);
if (remaining) {
previousX = remaining.x;
previousY = remaining.y;
}
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
8.5,
24
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
document.querySelector("#reset").addEventListener("click", resetCamera);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
const delta = clock.getDelta();
currentTheta = THREE.MathUtils.lerp(
currentTheta,
desiredTheta,
1 - Math.pow(0.001, delta)
);
currentPhi = THREE.MathUtils.lerp(
currentPhi,
desiredPhi,
1 - Math.pow(0.001, delta)
);
currentRadius = THREE.MathUtils.lerp(
currentRadius,
desiredRadius,
1 - Math.pow(0.001, delta)
);
currentTarget.lerp(desiredTarget, 1 - Math.pow(0.001, delta));
const spherical = new THREE.Spherical(
currentRadius,
currentPhi,
currentTheta
);
const offset = new THREE.Vector3().setFromSpherical(spherical);
camera.position.copy(currentTarget).add(offset);
camera.lookAt(currentTarget);
// Gentle mooring motion
boat.position.y = 0.025 + Math.sin(elapsed * 0.72) * 0.025;
boat.rotation.z = Math.sin(elapsed * 0.56) * 0.006;
boat.rotation.x = Math.sin(elapsed * 0.48 + 1.3) * 0.003;
redBeaconMaterial.emissiveIntensity =
0.55 + Math.pow(Math.max(0, Math.sin(elapsed * 3.2)), 5) * 2.4;
blueBeaconMaterial.emissiveIntensity =
0.45 + Math.pow(Math.max(0, Math.sin(elapsed * 3.2 + Math.PI)), 5) * 2.1;
rippleLines.forEach((line) => {
line.material.opacity =
line.userData.baseOpacity *
(0.82 + Math.sin(elapsed * 0.7 + line.userData.phase) * 0.18);
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```