Prompt specification
Build or customize the Three.js 3D scene "Harbor training scene with rowing crew" 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: Harbor training scene with rowing crew
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/harbor-training-scene-with-rowing-crew-x2263
Scene Description Prompt:
A low-poly ancient Athenian harbor training scene with a trireme-inspired vessel, coordinated boarding, and rowing crew. Three.js from cdnjs, one HTML file.
Working Three.js Starter (harbor-training-scene-with-rowing-crew-x2263):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Piraeus — Trireme Boarding Drill</title>
<style>
:root {
--ivory: #f4ead2;
--muted: #cfc2a7;
--red: #a63d2c;
--gold: #d3a74e;
--ink: #171b1b;
--glass: rgba(21, 26, 26, 0.72);
--line: rgba(244, 234, 210, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c8b997;
color: var(--ivory);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(12, 16, 17, 0.22), transparent 25%),
linear-gradient(0deg, rgba(12, 16, 17, 0.32), transparent 38%),
radial-gradient(circle at center, transparent 55%, rgba(11, 16, 16, 0.2));
z-index: 2;
}
.topbar {
position: fixed;
top: 28px;
left: 30px;
right: 30px;
z-index: 4;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
color: var(--gold);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.25em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 25px;
height: 1px;
background: var(--gold);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 5vw, 62px);
font-weight: 400;
line-height: 0.9;
letter-spacing: -0.045em;
text-shadow: 0 3px 20px rgba(0, 0, 0, 0.3);
}
.subtitle {
margin-top: 11px;
color: rgba(244, 234, 210, 0.78);
font-size: 11px;
font-weight: 650;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.seal {
width: 76px;
height: 76px;
display: grid;
place-items: center;
border: 1px solid rgba(244, 234, 210, 0.45);
border-radius: 50%;
background: rgba(24, 30, 30, 0.22);
backdrop-filter: blur(8px);
box-shadow: inset 0 0 0 5px rgba(244, 234, 210, 0.04);
}
.seal svg {
width: 39px;
height: 39px;
fill: none;
stroke: var(--ivory);
stroke-width: 1.5;
}
.briefing {
position: fixed;
left: 30px;
bottom: 29px;
z-index: 4;
width: min(330px, calc(100vw - 60px));
padding: 18px 20px 17px;
border: 1px solid var(--line);
background: var(--glass);
backdrop-filter: blur(14px);
box-shadow: 0 16px 50px rgba(0, 0, 0, 0.18);
}
.briefing-head {
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
margin-bottom: 10px;
color: var(--gold);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.status-dot {
width: 6px;
height: 6px;
display: inline-block;
margin-right: 7px;
border-radius: 50%;
background: #b8ca79;
box-shadow: 0 0 10px rgba(184, 202, 121, 0.8);
vertical-align: 1px;
}
.briefing h2 {
margin: 0 0 7px;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
font-weight: 400;
}
.briefing p {
margin: 0;
color: rgba(244, 234, 210, 0.7);
font-size: 12px;
line-height: 1.6;
}
.progress {
height: 2px;
margin-top: 16px;
overflow: hidden;
background: rgba(244, 234, 210, 0.13);
}
.progress > div {
width: 0;
height: 100%;
background: var(--gold);
box-shadow: 0 0 8px rgba(211, 167, 78, 0.5);
}
.controls {
position: fixed;
right: 30px;
bottom: 29px;
z-index: 4;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 10px;
}
.control-row {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
}
.control-button {
min-height: 37px;
padding: 0 14px;
border: 1px solid var(--line);
color: var(--ivory);
background: rgba(24, 30, 30, 0.72);
backdrop-filter: blur(12px);
cursor: pointer;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
.control-button:hover,
.control-button.active {
border-color: rgba(211, 167, 78, 0.75);
background: rgba(77, 56, 31, 0.8);
transform: translateY(-1px);
}
.control-button.primary {
min-width: 118px;
border-color: rgba(211, 167, 78, 0.55);
color: #211b13;
background: var(--gold);
}
.speed {
display: flex;
align-items: center;
gap: 11px;
padding: 10px 13px;
border: 1px solid var(--line);
background: rgba(24, 30, 30, 0.65);
backdrop-filter: blur(12px);
color: rgba(244, 234, 210, 0.65);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.speed input {
width: 100px;
accent-color: var(--gold);
}
.hint {
position: fixed;
right: 30px;
top: 31px;
z-index: 4;
color: rgba(244, 234, 210, 0.68);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
text-align: right;
line-height: 1.8;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #1b2020;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
.loading-mark {
text-align: center;
color: var(--ivory);
font-family: Georgia, serif;
font-size: 24px;
letter-spacing: 0.04em;
}
.loading-mark::after {
content: "";
display: block;
width: 90px;
height: 1px;
margin: 17px auto 0;
background: var(--gold);
animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse {
from {
transform: scaleX(0.2);
opacity: 0.4;
}
to {
transform: scaleX(1);
opacity: 1;
}
}
@media (max-width: 760px) {
.topbar {
top: 20px;
left: 20px;
right: 20px;
}
.seal,
.hint {
display: none;
}
.briefing {
left: 20px;
bottom: 20px;
width: calc(100vw - 40px);
padding: 14px 16px;
}
.briefing p {
display: none;
}
.controls {
right: 20px;
bottom: 125px;
}
.speed {
display: none;
}
.control-button {
min-height: 34px;
padding: 0 10px;
font-size: 8px;
}
}
</style>
</head>
<body>
<canvas id="scene"></canvas>
<div class="vignette"></div>
<header class="topbar">
<div>
<div class="eyebrow">Piraeus · 430 BC</div>
<h1>Harbor Drill</h1>
<div class="subtitle">Athenian trireme · coordinated boarding</div>
</div>
<div class="seal" aria-hidden="true">
<svg viewBox="0 0 48 48">
<path d="M8 31h32M13 31l7 10M35 31l-7 10M24 7v31M17 12l7-5 7 5M11 25h26" />
<path d="M4 25c5 0 8-3 8-8 0 5 3 8 8 8 5 0 8-3 8-8 0 5 3 8 8 8 5 0 8-3 8-8" />
</svg>
</div>
</header>
<div class="hint">
Drag to orbit · Scroll to zoom<br />
Touch controls supported
</div>
<section class="briefing">
<div class="briefing-head">
<span><span class="status-dot"></span>Training exercise 03</span>
<span id="clock">00:00</span>
</div>
<h2>Board the enemy vessel</h2>
<p>
Maintain the rowing cadence while the assault section crosses the gangway
in staggered formation. Camera controls are rendered directly in this page.
</p>
<div class="progress"><div id="progress"></div></div>
</section>
<div class="controls">
<div class="speed">
<span>Drill speed</span>
<input id="speed" type="range" min="0.25" max="1.75" step="0.05" value="1" />
<span id="speedValue">1.0×</span>
</div>
<div class="control-row">
<button class="control-button" data-camera="harbor">Harbor</button>
<button class="control-button" data-camera="deck">Deck</button>
<button class="control-button" data-camera="boarding">Boarding</button>
<button class="control-button" data-camera="overhead">Overhead</button>
<button class="control-button" id="reset">Reset</button>
<button class="control-button primary" id="pause">Pause drill</button>
</div>
</div>
<div id="loading">
<div class="loading-mark">Preparing the Piraeus</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 scene
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd7c8aa);
scene.fog = new THREE.Fog(0xd7c8aa, 55, 165);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
280
);
const hemi = new THREE.HemisphereLight(0xe9e0c5, 0x53686a, 1.9);
scene.add(hemi);
const sunLight = new THREE.DirectionalLight(0xffd59a, 3.4);
sunLight.position.set(-38, 55, 28);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -55;
sunLight.shadow.camera.right = 55;
sunLight.shadow.camera.top = 45;
sunLight.shadow.camera.bottom = -45;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 130;
sunLight.shadow.bias = -0.00025;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0x91b8c2, 0.65);
fillLight.position.set(25, 15, -35);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Shared materials and geometry helpers
// -------------------------------------------------------------------------
const standard = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
flatShading: true,
roughness: 0.86,
metalness: 0,
...extra
});
const M = {
wood: standard(0x805038),
woodLight: standard(0xa56b42),
woodDark: standard(0x3c2a24),
hull: standard(0x70432e),
black: standard(0x202526),
bronze: standard(0xa87938, { metalness: 0.72, roughness: 0.38 }),
gold: standard(0xd3a64b, { metalness: 0.55, roughness: 0.4 }),
rope: standard(0x9b8257),
stone: standard(0xb8aa8f),
stoneDark: standard(0x8e826e),
stoneLight: standard(0xd0c3a5),
sand: standard(0xc9b38c),
red: standard(0x9f382e),
redDark: standard(0x662825),
blue: standard(0x263f4b),
cloth: standard(0xd5c4a1),
skin: standard(0xc88f67),
terracotta: standard(0xa9583d),
roof: standard(0x8b4d39),
leaf: standard(0x536b4a),
leafLight: standard(0x71815a),
target: standard(0xc5a66d)
};
const UP = new THREE.Vector3(0, 1, 0);
const dummy = new THREE.Object3D();
const tempDirection = new THREE.Vector3();
function addMesh(geometry, material, x = 0, y = 0, z = 0, parent = scene, cast = true) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(w, h, d, material, x = 0, y = 0, z = 0, parent = scene, cast = true) {
return addMesh(
new THREE.BoxGeometry(w, h, d),
material,
x,
y,
z,
parent,
cast
);
}
function addCylinder(rt, rb, h, segments, material, x = 0, y = 0, z = 0, parent = scene) {
return addMesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
material,
x,
y,
z,
parent
);
}
function setBeamMatrix(instancedMesh, index, a, b, radius) {
tempDirection.subVectors(b, a);
const length = tempDirection.length();
dummy.position.copy(a).add(b).multiplyScalar(0.5);
dummy.quaternion.setFromUnitVectors(UP, tempDirection.normalize());
dummy.scale.set(radius, length, radius);
dummy.updateMatrix();
instancedMesh.setMatrixAt(index, dummy.matrix);
}
function randomGenerator(seed) {
return function () {
let t = (seed += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const rand = randomGenerator(430);
// -------------------------------------------------------------------------
// Low-poly water
// -------------------------------------------------------------------------
const waterGeometry = new THREE.PlaneGeometry(180, 150, 36, 30);
waterGeometry.rotateX(-Math.PI / 2);
const waterPosition = waterGeometry.attributes.position;
const waterBase = new Float32Array(waterPosition.count * 2);
const waterColors = [];
for (let i = 0; i < waterPosition.count; i++) {
const x = waterPosition.getX(i);
const z = waterPosition.getZ(i);
waterBase[i * 2] = x;
waterBase[i * 2 + 1] = z;
const shade = 0.38 + rand() * 0.1;
const color = new THREE.Color().setHSL(
0.49 + rand() * 0.018,
0.28 + rand() * 0.12,
shade
);
waterColors.push(color.r, color.g, color.b);
}
waterGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(waterColors, 3)
);
const waterMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 0.46,
metalness: 0.08,
transparent: true,
opacity: 0.94
});
const water = addMesh(
waterGeometry,
waterMaterial,
0,
0,
-20,
scene,
false
);
water.receiveShadow = true;
// Small translucent water facets catch the sunlight.
for (let i = 0; i < 48; i++) {
const patch = addMesh(
new THREE.CircleGeometry(0.35 + rand() * 1.1, 5),
new THREE.MeshBasicMaterial({
color: 0xc5e0d6,
transparent: true,
opacity: 0.055 + rand() * 0.055,
depthWrite: false,
side: THREE.DoubleSide
}),
(rand() - 0.5) * 115,
0.025,
-12 + (rand() - 0.5) * 95,
scene,
false
);
patch.rotation.x = -Math.PI / 2;
patch.rotation.z = rand() * Math.PI;
}
// -------------------------------------------------------------------------
// Terrain and far Athens
// -------------------------------------------------------------------------
addBox(170, 3, 32, M.sand, 0, -0.5, -53);
// Quay wall along the far shore.
for (let i = 0; i < 34; i++) {
const x = -76 + i * 4.6;
const height = 1.6 + (i % 3) * 0.16;
addBox(4.45, height, 2.1, i % 2 ? M.stone : M.stoneDark, x, height / 2, -37.2);
}
// Low city blocks.
const cityMats = [M.stoneLight, M.stone, M.sand, M.cloth];
for (let i = 0; i < 46; i++) {
const x = -74 + rand() * 148;
const z = -42 - rand() * 19;
const w = 2.5 + rand() * 5.5;
const d = 2.5 + rand() * 4;
const h = 2.3 + rand() * 5.5;
const building = addBox(
w,
h,
d,
cityMats[Math.floor(rand() * cityMats.length)],
x,
1 + h / 2,
z
);
building.rotation.y = (rand() - 0.5) * 0.18;
if (rand() > 0.5) {
addBox(
w * 0.78,
0.22,
d * 0.8,
M.roof,
x,
1 + h + 0.1,
z
);
}
}
// Acropolis hill.
const hill = new THREE.Group();
scene.add(hill);
for (let i = 0; i < 15; i++) {
const rock = addMesh(
new THREE.IcosahedronGeometry(5 + rand() * 4, 1),
i % 3 ? M.stoneDark : M.stone,
-28 + (rand() - 0.5) * 17,
3.2 + rand() * 3.5,
-66 + (rand() - 0.5) * 11,
hill
);
rock.scale.set(1.3 + rand(), 0.75 + rand() * 0.6, 1.1 + rand());
rock.rotation.set(rand(), rand(), rand());
}
function makeGableGeometry(width, height, depth) {
const w = width / 2;
const d = depth / 2;
const positions = [
-w, 0, d, w, 0, d, 0, height, d,
-w, 0, -d, 0, height, -d, w, 0, -d,
-w, 0, d, 0, height, d, 0, height, -d,
-w, 0, d, 0, height, -d, -w, 0, -d,
w, 0, d, w, 0, -d, 0, height, d,
w, 0, d, 0, height, -d, 0, height, -d
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.computeVertexNormals();
return geometry;
}
function makeParthenon() {
const temple = new THREE.Group();
temple.position.set(-27, 11.1, -67);
temple.scale.setScalar(1.28);
scene.add(temple);
addBox(13.2, 0.45, 7.2, M.stoneLight, 0, 0.2, 0, temple);
addBox(12.1, 0.4, 6.3, M.stoneLight, 0, 0.6, 0, temple);
addBox(11.3, 0.36, 5.7, M.stone, 0, 0.96, 0, temple);
const columnPositions = [];
for (let i = 0; i < 8; i++) {
const x = -5.25 + i * 1.5;
columnPositions.push([x, 2.8, 2.45]);
columnPositions.push([x, 2.8, -2.45]);
}
for (let i = 1; i < 7; i++) {
const z = -2.45 + i * (4.9 / 7);
columnPositions.push([-5.25, 2.8, z]);
columnPositions.push([5.25, 2.8, z]);
}
for (const [x, y, z] of columnPositions) {
addCylinder(0.34, 0.4, 3.25, 8, M.stoneLight, x, y, z, temple);
addBox(0.83, 0.2, 0.83, M.stone, x, 1.25, z, temple);
}
addBox(12.1, 0.72, 6.15, M.stoneLight, 0, 4.62, 0, temple);
addMesh(makeGableGeometry(12.2, 3.3, 6.2), M.roof, 0, 4.98, 0, temple);
return temple;
}
makeParthenon();
// Trees and olive groves.
function addOliveTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 1, z);
group.scale.setScalar(scale);
scene.add(group);
addCylinder(0.13, 0.2, 2.4, 6, M.woodDark, 0, 1.2, 0, group);
const crown = addMesh(
new THREE.IcosahedronGeometry(1.45, 1),
M.leaf,
0,
2.75,
0,
group
);
crown.scale.set(1.2, 0.78, 1);
}
for (let i = 0; i < 28; i++) {
addOliveTree(
-70 + rand() * 140,
-61 - rand() * 8,
0.65 + rand() * 0.65
);
}
// -------------------------------------------------------------------------
// Main trireme
// -------------------------------------------------------------------------
const ship = new THREE.Group();
ship.position.x = -3;
scene.add(ship);
const hullSections = [
{ x: -15, w: 0.28 },
{ x: -13.1, w: 1.25 },
{ x: -9.2, w: 2.35 },
{ x: 7.8, w: 2.35 },
{ x: 12, w: 1.42 },
{ x: 15, w: 0.3 }
];
function makeHullGeometry() {
const positions = [];
const colors = [];
const indices = [];
const vertexFor = (sectionIndex, pointIndex) => {
const section = hullSections[sectionIndex];
const w = section.w;
const cross = [
{ z: -w, y: 2.55 },
{ z: w, y: 2.55 },
{ z: w * 0.73, y: 0.62 },
{ z: 0, y: 0.02 },
{ z: -w * 0.73, y: 0.62 }
];
const p = cross[pointIndex];
return [section.x, p.y, p.z];
};
const addTriangle = (a, b, c, color) => {
const start = positions.length / 3;
positions.push(...a, ...b, ...c);
for (let i = 0; i < 3; i++) colors.push(color.r, color.g, color.b);
indices.push(start, start + 1, start + 2);
};
const upper = new THREE.Color(0x795038);
const lower = new THREE.Color(0x3b2b27);
for (let s = 0; s < hullSections.length - 1; s++) {
for (let p = 0; p < 5; p++) {
const nextP = (p + 1) % 5;
const a = vertexFor(s, p);
const b = vertexFor(s + 1, p);
const c = vertexFor(s + 1, nextP);
const d = vertexFor(s, nextP);
const color = p === 0 || p === 4 ? upper : lower;
addTriangle(a, b, c, color);
addTriangle(a, c, d, color);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
addMesh(
makeHullGeometry(),
new THREE.MeshStandardMaterial({
vertexColors: true,
flatShading: true,
roughness: 0.83
}),
0,
0,
0,
ship
);
const deckShape = new THREE.Shape();
deckShape.moveTo(-14.4, 0);
deckShape.lineTo(-11.8, -1.55);
deckShape.lineTo(-8.5, -2.25);
deckShape.lineTo(8, -2.25);
deckShape.lineTo(11.7, -1.55);
deckShape.lineTo(14.4, 0);
deckShape.lineTo(11.7, 1.55);
deckShape.lineTo(8, 2.25);
deckShape.lineTo(-8.5, 2.25);
deckShape.lineTo(-11.8, 1.55);
deckShape.closePath();
const deckGeometry = new THREE.ShapeGeometry(deckShape);
deckGeometry.rotateX(-Math.PI / 2);
addMesh(deckGeometry, M.woodLight, 0, 2.56, 0, ship);
// Deck planks.
for (let z = -1.9; z <= 1.9; z += 0.38) {
addBox(22.6, 0.035, 0.035, M.rope, -0.4, 2.59, z, ship, false);
}
// Protective wales.
addBox(19.8, 0.22, 0.16, M.woodDark, 0, 2.48, 2.34, ship);
addBox(19.8, 0.22, 0.16, M.woodDark, 0, 2.48, -2.34, ship);
addBox(19.8, 0.08, 0.08, M.redDark, 0, 2.68, 2.35, ship, false);
addBox(19.8, 0.08, 0.08, M.redDark, 0, 2.68, -2.35, ship, false);
// Bronze ram.
const ram = addMesh(
new THREE.ConeGeometry(0.65, 2.1, 6),
M.bronze,
-15.1,
0.42,
0,
ship
);
ram.rotation.z = Math.PI / 2;
const ramBase = addCylinder(0.7, 0.7, 1.2, 6, M.bronze, -14.4, 0.48, 0, ship);
ramBase.rotation.z = Math.PI / 2;
// Raised bow and stern.
addBox(4.4, 0.72, 2.75, M.wood, -10.3, 2.9, 0, ship);
addBox(4.4, 0.72, 2.75, M.wood, 10.1, 2.9, 0, ship);
addBox(3.2, 0.62, 2.45, M.woodDark, 11.2, 3.53, 0, ship);
// Mast and furled sail.
addCylinder(0.12, 0.17, 9.1, 8, M.woodDark, -0.8, 6.45, 0, ship);
addBox(7.1, 0.16, 0.16, M.woodDark, -0.8, 8.35, 0, ship);
addBox(0.45, 2.2, 0.4, M.cloth, -0.8, 7.9, 0, ship);
// Steering oars.
for (const side of [-1, 1]) {
const steering = addCylinder(0.09, 0.12, 5.1, 6, M.woodDark, 11.4, 0.8, side * 2.7, ship);
steering.rotation.x = side * 0.42;
steering.rotation.z = 0.1;
}
// Side shields.
for (let i = 0; i < 6; i++) {
const x = -7.5 + i * 3;
const shield = addMesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.08, 12),
i % 2 ? M.red : M.blue,
x,
3.03,
2.48,
ship
);
shield.rotation.x = Math.PI / 2;
const boss = addMesh(
new THREE.CylinderGeometry(0.12, 0.12, 0.09, 10),
M.bronze,
x,
3.03,
2.54,
ship
);
boss.rotation.x = Math.PI / 2;
}
// -------------------------------------------------------------------------
// Oar banks and rowing crew
// -------------------------------------------------------------------------
const oarData = [];
for (let tier = 0; tier < 3; tier++) {
for (const side of [-1, 1]) {
for (let i = 0; i < 11; i++) {
oarData.push({
tier,
side,
x: -8.5 + i * 1.7,
pivot: new THREE.Vector3(
-8.5 + i * 1.7,
0.55 + tier * 0.62,
side * (1.83 - tier * 0.11)
)
});
}
}
}
const oarShaftMaterial = standard(0x46352b);
const oarMesh = new THREE.InstancedMesh(
new THREE.CylinderGeometry(1, 1, 1, 6),
oarShaftMaterial,
oarData.length
);
oarMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
oarMesh.castShadow = true;
ship.add(oarMesh);
const oarBladeMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
M.woodLight,
oarData.length
);
oarBladeMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
oarBladeMesh.castShadow = true;
ship.add(oarBladeMesh);
const apertureMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.34, 0.22, 0.06),
M.black,
oarData.length
);
for (let i = 0; i < oarData.length; i++) {
const data = oarData[i];
dummy.position.copy(data.pivot);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
apertureMesh.setMatrixAt(i, dummy.matrix);
}
ship.add(apertureMesh);
const rowerData = [];
for (const side of [-1, 1]) {
for (let i = 0; i < 11; i++) {
rowerData.push({
x: -8.5 + i * 1.7,
z: side * 1.23,
side
});
}
}
const rowerTorso = new THREE.InstancedMesh(
new THREE.CylinderGeometry(0.22, 0.27, 0.58, 6),
M.blue,
rowerData.length
);
const rowerHead = new THREE.InstancedMesh(
new THREE.IcosahedronGeometry(0.18, 0),
M.skin,
rowerData.length
);
const rowerArms = new THREE.InstancedMesh(
new THREE.CylinderGeometry(1, 1, 1, 6),
M.skin,
rowerData.length * 2
);
const benches = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.78, 0.09, 0.36),
M.woodDark,
rowerData.length
);
for (const mesh of [rowerTorso, rowerHead, rowerArms, benches]) {
mesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
mesh.castShadow = true;
ship.add(mesh);
}
for (let i = 0; i < rowerData.length; i++) {
rowerTorso.setColorAt(i, i % 5 === 0 ? new THREE.Color(0x8b3e30) : new THREE.Color(0x293e48));
}
rowerTorso.instanceColor.needsUpdate = true;
for (let i = 0; i < rowerData.length; i++) {
const data = rowerData[i];
dummy.position.set(data.x, 2.59, data.z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
benches.setMatrixAt(i, dummy.matrix);
}
function updateOars(time) {
const phase = time * 2.45;
for (let i = 0; i < oarData.length; i++) {
const data = oarData[i];
const sweep = Math.sin(phase + data.x * 0.025);
const end = data.pivot.clone().add(
new THREE.Vector3(
sweep * 3.0,
-0.55 - data.tier * 0.15,
data.side * (3.75 - data.tier * 0.35)
)
);
setBeamMatrix(oarMesh, i, data.pivot, end, 0.055);
const horizontalAngle = Math.atan2(end.x - data.pivot.x, end.z - data.pivot.z);
dummy.position.copy(end);
dummy.rotation.set(0, horizontalAngle, 0);
dummy.scale.set(0.37, 0.08, 0.82);
dummy.updateMatrix();
oarBladeMesh.setMatrixAt(i, dummy.matrix);
}
oarMesh.instanceMatrix.needsUpdate = true;
oarBladeMesh.instanceMatrix.needsUpdate = true;
}
function updateRowers(time) {
const phase = time * 2.45;
for (let i = 0; i < rowerData.length; i++) {
const data = rowerData[i];
const lean = Math.sin(phase + data.x * 0.025) * 0.18;
dummy.position.set(data.x, 2.94, data.z);
dummy.rotation.set(0, 0, lean);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
rowerTorso.setMatrixAt(i, dummy.matrix);
const headX = data.x + Math.sin(lean) * 0.29;
dummy.position.set(headX, 3.36, data.z);
dummy.rotation.set(0, 0, 0);
dummy.updateMatrix();
rowerHead.setMatrixAt(i, dummy.matrix);
for (let arm = 0; arm < 2; arm++) {
const zOffset = arm === 0 ? -0.2 : 0.2;
const shoulder = new THREE.Vector3(data.x, 3.12, data.z + zOffset);
const hand = new THREE.Vector3(
data.x + 0.44 + Math.cos(phase + data.x * 0.025) * 0.12,
3.0,
data.z + zOffset * 1.2
);
setBeamMatrix(rowerArms, i * 2 + arm, shoulder, hand, 0.055);
}
}
rowerTorso.instanceMatrix.needsUpdate = true;
rowerHead.instanceMatrix.needsUpdate = true;
rowerArms.instanceMatrix.needsUpdate = true;
}
// -------------------------------------------------------------------------
// Pier and boarding gangway
// -------------------------------------------------------------------------
const pier = new THREE.Group();
scene.add(pier);
addBox(4.7, 0.42, 14.2, M.wood, 7, 0.95, 20.6, pier);
for (let z = 14.1; z <= 27; z += 1.05) {
addBox(4.45, 0.025, 0.045, M.woodDark, 7, 1.17, z, pier, false);
}
for (const x of [5.1, 8.9]) {
for (const z of [14.2, 17.4, 20.7, 24, 27]) {
addCylinder(0.17, 0.21, 3.3, 7, M.woodDark, x, 0.05, z, pier);
addCylinder(0.21, 0.21, 0.15, 7, M.woodLight, x, 1.26, z, pier);
}
}
// Small landing quay.
addBox(11, 1.9, 6.5, M.stone, 7, 0.1, 30.1);
addBox(11.2, 0.18, 6.7, M.stoneLight, 7, 1.13, 30.1);
// Gangway from ship deck to pier.
const gangwayStart = new THREE.Vector3(7, 2.57, 2.38);
const gangwayEnd = new THREE.Vector3(7, 1.16, 13.65);
const gangwayVector = gangwayEnd.clone().sub(gangwayStart);
const gangwayLength = gangwayVector.length();
const gangway = addBox(
2.25,
0.16,
gangwayLength,
M.wood,
7,
1.86,
8.0,
scene
);
gangway.rotation.x = Math.atan2(-gangwayVector.y, gangwayVector.z);
for (let i = 0; i < 13; i++) {
const t = i / 12;
const point = gangwayStart.clone().lerp(gangwayEnd, t);
const slat = addBox(2.34, 0.09, 0.16, M.woodLight, point.x, point.y + 0.12, point.z, scene);
slat.rotation.x = gangway.rotation.x;
}
// Gangway rope rails.
for (const x of [5.94, 8.06]) {
for (let i = 0; i < 7; i++) {
const t = i / 6;
const point = gangwayStart.clone().lerp(gangwayEnd, t);
addCylinder(0.025, 0.025, 0.9, 5, M.rope, x, point.y + 0.48, point.z);
}
}
// Pier targets.
for (let i = 0; i < 3; i++) {
const target = addMesh(
new THREE.CylinderGeometry(0.47, 0.47, 0.1, 12),
M.target,
10.5,
1.72,
20.3 + i * 1.65
);
target.rotation.x = Math.PI / 2;
const bullseye = addMesh(
new THREE.CylinderGeometry(0.15, 0.15, 0.11, 10),
M.redDark,
10.5,
1.72,
20.3 + i * 1.65
);
bullseye.rotation.x = Math.PI / 2;
}
// -------------------------------------------------------------------------
// Low-poly warriors
// -------------------------------------------------------------------------
function createWarrior(colorMaterial = M.red, scale = 1) {
const root = new THREE.Group();
root.scale.setScalar(scale);
addBox(0.43, 0.59, 0.31, colorMaterial, 0, 0.97, 0, root);
addBox(0.46, 0.13, 0.34, M.bronze, 0, 0.73, 0, root);
addMesh(new THREE.IcosahedronGeometry(0.19, 0), M.skin, 0, 1.39, 0, root);
addMesh(new THREE.ConeGeometry(0.225, 0.2, 8), M.bronze, 0, 1.54, 0, root);
addBox(0.055, 0.13, 0.42, M.redDark, 0, 1.68, 0, root);
const legL = new THREE.Group();
const legR = new THREE.Group();
legL.position.set(-0.13, 0.68, 0);
legR.position.set(0.13, 0.68, 0);
root.add(legL, legR);
addBox(0.14, 0.55, 0.15, M.blue, 0, -0.28, 0, legL);
addBox(0.14, 0.55, 0.15, M.blue, 0, -0.28, 0, legR);
addBox(0.17, 0.12, 0.26, M.woodDark, 0, -0.57, 0.055, legL);
addBox(0.17, 0.12, 0.26, M.woodDark, 0, -0.57, 0.055, legR);
const armL = new THREE.Group();
const armR = new THREE.Group();
armL.position.set(-0.27, 1.18, 0);
armR.position.set(0.27, 1.18, 0);
root.add(armL, armR);
addBox(0.12, 0.48, 0.13, M.skin, 0, -0.23, 0, armL);
addBox(0.12, 0.48, 0.13, M.skin, 0, -0.23, 0, armR);
const shield = addMesh(
new THREE.CylinderGeometry(0.34, 0.34, 0.075, 12),
M.blue,
-0.35,
0.96,
0.16,
root
);
shield.rotation.x = Math.PI / 2;
const shieldBoss = addMesh(
new THREE.CylinderGeometry(0.1, 0.1, 0.085, 10),
M.bronze,
-0.35,
0.96,
0.21,
root
);
shieldBoss.rotation.x = Math.PI / 2;
addCylinder(0.024, 0.024, 1.65, 6, M.woodDark, 0.4, 1.05, 0.02, root);
addMesh(
new THREE.ConeGeometry(0.075, 0.28, 6),
M.bronze,
0.4,
1.98,
0.02,
root
);
return { root, legL, legR, armL, armR };
}
// Static crew on the trireme.
const shipCommander = createWarrior(M.red, 0.9);
shipCommander.root.position.set(6.2, 2.58, -0.45);
shipCommander.root.rotation.y = Math.PI / 2;
scene.add(shipCommander.root);
const helmsman = createWarrior(M.blue, 0.82);
helmsman.root.position.set(10.8, 2.6, 0.8);
scene.add(helmsman.root);
// Instructor on the pier.
const instructor = createWarrior(M.red, 0.88);
instructor.root.position.set(9.8, 1.18, 24.1);
instructor.root.rotation.y = -0.4;
scene.add(instructor.root);
// -------------------------------------------------------------------------
// Coordinated boarding sequence
// -------------------------------------------------------------------------
const boarders = [];
for (let i = 0; i < 6; i++) {
const warrior = createWarrior(i % 2 ? M.red : M.blue, 0.82);
scene.add(warrior.root);
boarders.push({
...warrior,
index: i,
start: 2.0 + i * 0.72,
duration: 9.3
});
}
function boardingPath(index, progress) {
const p = THREE.MathUtils.clamp(progress, 0, 1);
const lane = (index - 2.5) * 0.23;
if (p < 0.18) {
const t = p / 0.18;
return {
x: 6.25 + lane + t * 0.75,
y: 2.58,
z: 1.15 + t * 1.23
};
}
if (p < 0.78) {
const t = (p - 0.18) / 0.6;
return {
x: 7 + lane,
y: 2.58 + (1.18 - 2.58) * t,
z: 2.38 + (13.65 - 2.38) * t
};
}
const t = (p - 0.78) / 0.22;
return {
x: 7 + (index - 2.5) * 0.62,
y: 1.18,
z: 13.65 + t * 4.5
};
}
function updateBoarders(drillTime) {
const cycle = drillTime % 22;
for (const warrior of boarders) {
const raw = (cycle - warrior.start) / warrior.duration;
const progress = THREE.MathUtils.clamp(raw, 0, 1);
const point = boardingPath(warrior.index, progress);
const moving = raw > 0 && raw < 1;
const runPhase = drillTime * 8.2 + warrior.index * 0.55;
warrior.root.position.set(point.x, point.y, point.z);
warrior.root.rotation.y = progress > 0.78 ? (warrior.index - 2.5) * -0.06 : 0;
const stride = moving ? 0.58 : 0;
warrior.legL.rotation.x = Math.sin(runPhase) * stride;
warrior.legR.rotation.x = -Math.sin(runPhase) * stride;
warrior.armL.rotation.x = -Math.sin(runPhase) * stride * 0.72;
warrior.armR.rotation.x = Math.sin(runPhase) * stride * 0.72;
if (moving) {
warrior.root.position.y += Math.abs(Math.sin(runPhase)) * 0.035;
}
}
}
// -------------------------------------------------------------------------
// Flags and harbor props
// -------------------------------------------------------------------------
const flags = [];
function createFlag(x, y, z, scale = 1, color = M.red) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
scene.add(group);
addCylinder(0.035, 0.045, 3.1, 6, M.woodDark, 0, 0, 0, group);
const geometry = new THREE.PlaneGeometry(2.5, 1.15, 8, 4);
const position = geometry.attributes.position;
const original = new Float32Array(position.count * 3);
for (let i = 0; i < position.count; i++) {
original[i * 3] = position.getX(i);
original[i * 3 + 1] = position.getY(i);
original[i * 3 + 2] = position.getZ(i);
}
const material = new THREE.MeshStandardMaterial({
color,
side: THREE.DoubleSide,
flatShading: true,
roughness: 0.9
});
const cloth = addMesh(geometry, material, 1.2, 0.8, 0, group);
flags.push({ cloth, original });
}
createFlag(11.8, 6.5, 0, 0.9, M.red);
createFlag(7, 2.35, 26.5, 0.85, M.blue);
// Amphorae and supply crates.
function addAmphora(x, y, z) {
const body = addMesh(
new THREE.SphereGeometry(0.42, 8, 6),
M.terracotta,
x,
y + 0.48,
z
);
body.scale.set(1, 1.25, 1);
addCylinder(0.14, 0.2, 0.45, 8, M.terracotta, x, y + 1.03, z);
addBox(0.55, 0.4, 0.55, M.woodLight, x + 0.85, y + 0.2, z + 0.25);
}
addAmphora(6.2, 1.18, 25.1);
addAmphora(6.8, 1.18, 26.2);
addAmphora(8.4, 1.18, 25.8);
addBox(0.9, 0.55, 0.75, M.wood, 5.5, 1.48, 21.2);
// Distant merchant vessel.
const distantBoat = new THREE.Group();
distantBoat.position.set(37, 0, -25);
distantBoat.rotation.y = -0.38;
scene.add(distantBoat);
const distantHull = addMesh(
new THREE.SphereGeometry(1, 8, 5),
M.woodDark,
0,
0.3,
0,
distantBoat
);
distantHull.scale.set(5, 1.05, 1.45);
addCylinder(0.08, 0.12, 8.4, 6, M.woodDark, 0, 4.2, 0, distantBoat);
const sailShape = new THREE.Shape();
sailShape.moveTo(0, 0);
sailShape.lineTo(0, 4.1);
sailShape.lineTo(3.4, 0.35);
sailShape.closePath();
const sailGeo = new THREE.ShapeGeometry(sailShape);
addMesh(sailGeo, M.cloth, 0.12, 3.8, 0, distantBoat);
// Low-poly clouds.
for (let i = 0; i < 13; i++) {
const cloud = new THREE.Group();
cloud.position.set(-75 + rand() * 150, 24 + rand() * 13, -70 - rand() * 30);
scene.add(cloud);
for (let j = 0; j < 4; j++) {
const puff = addMesh(
new THREE.IcosahedronGeometry(1.7 + rand(), 1),
new THREE.MeshStandardMaterial({
color: 0xf1e6cb,
flatShading: true,
roughness: 1
}),
j * 1.8 + rand(),
rand() * 0.6,
rand(),
cloud,
false
);
puff.scale.y = 0.52;
}
}
// Sun disc.
const sun = addMesh(
new THREE.CircleGeometry(5.5, 32),
new THREE.MeshBasicMaterial({ color: 0xffe0a0, fog: false }),
-52,
42,
-94,
scene,
false
);
sun.quaternion.copy(camera.quaternion);
// -------------------------------------------------------------------------
// Custom camera controls — no addons
// -------------------------------------------------------------------------
const desiredCamera = {
target: new THREE.Vector3(-2, 2.6, 0),
radius: 53,
theta: 0.75,
phi: 1.16
};
const actualCamera = {
target: desiredCamera.target.clone(),
radius: desiredCamera.radius,
theta: desiredCamera.theta,
phi: desiredCamera.phi
};
const cameraPresets = {
harbor: {
target: new THREE.Vector3(-2, 2.6, 0),
radius: 53,
theta: 0.75,
phi: 1.16
},
deck: {
target: new THREE.Vector3(-1, 3.3, 0),
radius: 28,
theta: 0.64,
phi: 1.13
},
boarding: {
target: new THREE.Vector3(7, 2, 8.2),
radius: 24,
theta: 0.86,
phi: 1.17
},
overhead: {
target: new THREE.Vector3(-2, 0, -2),
radius: 50,
theta: 0.03,
phi: 0.43
}
};
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
desiredCamera.theta -= dx * 0.005;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi + dy * 0.004,
0.22,
1.46
);
});
function stopDragging(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
13,
85
);
},
{ passive: false }
);
function setCameraPreset(name) {
const preset = cameraPresets[name];
if (!preset) return;
desiredCamera.target.copy(preset.target);
desiredCamera.radius = preset.radius;
desiredCamera.theta = preset.theta;
desiredCamera.phi = preset.phi;
document.querySelectorAll("[data-camera]").forEach((button) => {
button.classList.toggle("active", button.dataset.camera === name);
});
}
document.querySelectorAll("[data-camera]").forEach((button) => {
button.addEventListener("click", () => {
setCameraPreset(button.dataset.camera);
});
});
document.querySelector('[data-camera="harbor"]').classList.add("active");
// -------------------------------------------------------------------------
// UI and animation
// -------------------------------------------------------------------------
let drillTime = 0;
let playing = true;
let speed = 1;
const pauseButton = document.querySelector("#pause");
const resetButton = document.querySelector("#reset");
const speedInput = document.querySelector("#speed");
const speedValue = document.querySelector("#speedValue");
const progressElement = document.querySelector("#progress");
const clockElement = document.querySelector("#clock");
pauseButton.addEventListener("click", () => {
playing = !playing;
pauseButton.textContent = playing ? "Pause drill" : "Resume drill";
});
resetButton.addEventListener("click", () => {
drillTime = 0;
playing = true;
pauseButton.textContent = "Pause drill";
});
speedInput.addEventListener("input", () => {
speed = Number(speedInput.value);
speedValue.textContent = `${speed.toFixed(2).replace(/0$/, "")}×`;
});
const clock = new THREE.Clock();
let ambientTime = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
ambientTime += delta;
if (playing) {
drillTime += delta * speed;
}
updateOars(drillTime);
updateRowers(drillTime);
updateBoarders(drillTime);
// Gentle low-poly wave motion.
const position = waterGeometry.attributes.position;
for (let i = 0; i < position.count; i++) {
const x = waterBase[i * 2];
const z = waterBase[i * 2 + 1];
const wave =
Math.sin(x * 0.21 + ambientTime * 0.75) * 0.055 +
Math.sin(z * 0.32 - ambientTime * 0.58) * 0.035;
position.setY(i, wave);
}
position.needsUpdate = true;
waterGeometry.computeVertexNormals();
// Flag flutter.
for (const flag of flags) {
const attribute = flag.cloth.geometry.attributes.position;
for (let i = 0; i < attribute.count; i++) {
const x = flag.original[i * 3];
const y = flag.original[i * 3 + 1];
const edge = (x + 1.25) / 2.5;
attribute.setZ(
i,
Math.sin(ambientTime * 3.2 + x * 2.7 + y) * 0.12 * edge
);
}
attribute.needsUpdate = true;
}
// Smoothly follow the requested camera.
const cameraEase = 1 - Math.exp(-delta * 4.5);
actualCamera.target.lerp(desiredCamera.target, cameraEase);
actualCamera.radius = THREE.MathUtils.lerp(
actualCamera.radius,
desiredCamera.radius,
cameraEase
);
actualCamera.theta = THREE.MathUtils.lerp(
actualCamera.theta,
desiredCamera.theta,
cameraEase
);
actualCamera.phi = THREE.MathUtils.lerp(
actualCamera.phi,
desiredCamera.phi,
cameraEase
);
const sinPhi = Math.sin(actualCamera.phi);
camera.position.set(
actualCamera.target.x +
actualCamera.radius * sinPhi * Math.sin(actualCamera.theta),
actualCamera.target.y + actualCamera.radius * Math.cos(actualCamera.phi),
actualCamera.target.z +
actualCamera.radius * sinPhi * Math.cos(actualCamera.theta)
);
camera.lookAt(actualCamera.target);
sun.quaternion.copy(camera.quaternion);
// Progress and clock.
const cycle = drillTime % 22;
const progress = THREE.MathUtils.clamp((cycle - 2) / 10.2, 0, 1);
progressElement.style.width = `${progress * 100}%`;
const totalSeconds = Math.floor(drillTime);
const minutes = String(Math.floor(totalSeconds / 60)).padStart(2, "0");
const seconds = String(totalSeconds % 60).padStart(2, "0");
clockElement.textContent = `${minutes}:${seconds}`;
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateOars(0);
updateRowers(0);
updateBoarders(0);
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```