Prompt specification
Build or customize the Three.js 3D scene "Oar through a ship-side opening" 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: Oar through a ship-side opening
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/oar-through-a-ship-side-opening-x2261
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring an oar and pivot from an Athenian trireme. Build one long oar pivoting through a stylized hull-side fitting. Show the inboard handle and outboard blade as connected parts rotating around the same support. Stylized solid forms.
Working Three.js Starter (oar-through-a-ship-side-opening-x2261):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Athenian Trireme — Oar and Pivot</title>
<style>
:root {
color-scheme: light;
--ink: #25211c;
--muted: #746b60;
--paper: rgba(246, 240, 226, 0.9);
--line: rgba(61, 49, 35, 0.18);
--accent: #9a3828;
--gold: #a97832;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d0bf;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(360px, calc(100vw - 60px));
pointer-events: none;
color: var(--ink);
text-shadow: 0 1px 12px rgba(255, 255, 255, 0.4);
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
width: 30px;
height: 2px;
background: var(--accent);
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(31px, 4vw, 54px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 320px;
margin: 12px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.control-panel {
position: fixed;
z-index: 10;
left: 50%;
bottom: 24px;
width: min(620px, calc(100vw - 32px));
padding: 14px 16px;
transform: translateX(-50%);
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 16px;
background: var(--paper);
box-shadow:
0 18px 50px rgba(47, 35, 21, 0.16),
inset 0 1px 0 rgba(255, 255, 255, 0.8);
backdrop-filter: blur(14px) saturate(1.1);
}
.panel-row {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 14px;
}
.button {
min-height: 36px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.55);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition:
background 160ms ease,
transform 160ms ease;
}
.button:hover {
background: #fffdf8;
transform: translateY(-1px);
}
.button.active {
border-color: rgba(154, 56, 40, 0.22);
background: rgba(154, 56, 40, 0.1);
color: var(--accent);
}
.angle-control {
min-width: 0;
}
.angle-label {
display: flex;
justify-content: space-between;
margin-bottom: 6px;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
#angle-value {
color: var(--accent);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 5px;
margin: 0;
border-radius: 999px;
outline: none;
appearance: none;
background:
linear-gradient(
90deg,
rgba(154, 56, 40, 0.82),
rgba(154, 56, 40, 0.82)
) 0 / var(--fill, 43%) 100% no-repeat,
rgba(62, 49, 34, 0.12);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
border: 3px solid #fff8e9;
border-radius: 50%;
appearance: none;
background: var(--accent);
box-shadow: 0 2px 7px rgba(54, 31, 18, 0.3);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 3px solid #fff8e9;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 2px 7px rgba(54, 31, 18, 0.3);
}
.help {
margin-top: 10px;
color: var(--muted);
font-size: 10px;
text-align: center;
letter-spacing: 0.025em;
}
.legend {
position: fixed;
right: 25px;
bottom: 27px;
z-index: 4;
display: grid;
gap: 7px;
color: rgba(45, 39, 31, 0.68);
font-size: 10px;
pointer-events: none;
}
.legend div {
display: flex;
align-items: center;
gap: 8px;
}
.dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 3px rgba(169, 120, 50, 0.12);
}
@media (max-width: 720px) {
.title-card {
top: 19px;
left: 20px;
}
.subtitle {
display: none;
}
.control-panel {
bottom: 15px;
padding: 12px;
}
.panel-row {
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.angle-control {
grid-column: 1 / -1;
grid-row: 1;
}
.button {
width: 100%;
}
.legend {
display: none;
}
.help {
margin-top: 8px;
font-size: 9px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D Athenian trireme oar and pivot"></canvas>
<header class="title-card">
<div class="eyebrow">Athenian Trireme</div>
<h1>The Oar & Pivot</h1>
<p class="subtitle">
One continuous wooden oar pivots through a bronze hull-side fitting:
the inboard grip and outboard blade move around the same support.
</p>
</header>
<section class="control-panel" aria-label="Scene controls">
<div class="panel-row">
<button class="button active" id="auto" type="button" aria-pressed="true">
Pause sweep
</button>
<div class="angle-control">
<div class="angle-label">
<span>Oar angle</span>
<span id="angle-value">22°</span>
</div>
<input
id="angle"
type="range"
min="-12"
max="42"
value="22"
step="1"
aria-label="Oar pivot angle"
>
</div>
<button class="button" id="reset-view" type="button">
Reset view
</button>
</div>
<div class="help">
Drag to orbit · Right-drag or Shift-drag to pan · Scroll to zoom
</div>
</section>
<aside class="legend" aria-hidden="true">
<div><span class="dot"></span> Bronze pivot fitting</div>
<div><span class="dot" style="background:#784127"></span> Continuous wooden oar</div>
</aside>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera, and lighting
// -------------------------------------------------------------------------
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.06;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d0bf);
scene.fog = new THREE.Fog(0xd8d0bf, 20, 42);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
const view = {
theta: 0.54,
phi: 1.12,
radius: 15.7,
target: new THREE.Vector3(0, 0.8, 1.35)
};
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xfff4dc, 0x455b60, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe2b0, 3.2);
sun.position.set(-5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0003;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xa7cbd0, 1.0);
fill.position.set(8, 4, -7);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const material = {
hull: new THREE.MeshStandardMaterial({
color: 0x74282a,
roughness: 0.82,
metalness: 0.03,
flatShading: true
}),
black: new THREE.MeshStandardMaterial({
color: 0x171817,
roughness: 0.75,
metalness: 0.08,
flatShading: true
}),
cream: new THREE.MeshStandardMaterial({
color: 0xe5d5af,
roughness: 0.76,
flatShading: true
}),
deck: new THREE.MeshStandardMaterial({
color: 0xa77a48,
roughness: 0.88,
flatShading: true
}),
plank: new THREE.MeshStandardMaterial({
color: 0x5f3b25,
roughness: 0.92,
flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: 0x9a5b30,
roughness: 0.72,
metalness: 0.02,
flatShading: true
}),
blade: new THREE.MeshStandardMaterial({
color: 0xb77738,
roughness: 0.7,
flatShading: true
}),
grip: new THREE.MeshStandardMaterial({
color: 0x4e2d20,
roughness: 0.9,
flatShading: true
}),
leather: new THREE.MeshStandardMaterial({
color: 0x34221b,
roughness: 0.92,
flatShading: true
}),
bronze: new THREE.MeshStandardMaterial({
color: 0xa77935,
roughness: 0.36,
metalness: 0.64,
flatShading: true
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x4d4230,
roughness: 0.42,
metalness: 0.6
}),
blue: new THREE.MeshStandardMaterial({
color: 0x26749a,
roughness: 0.56,
flatShading: true
}),
white: new THREE.MeshStandardMaterial({
color: 0xf2ead7,
roughness: 0.68,
flatShading: true
}),
water: new THREE.MeshStandardMaterial({
color: 0x416b72,
roughness: 0.58,
metalness: 0.08,
transparent: true,
opacity: 0.94
})
};
function addMesh(geometry, mat, position, rotation, castShadow = true) {
const mesh = new THREE.Mesh(geometry, mat);
if (position) mesh.position.copy(position);
if (rotation) mesh.rotation.set(rotation.x, rotation.y, rotation.z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Stylized hull construction
// -------------------------------------------------------------------------
const stations = [
{ x: -6.10, w: 0.75, top: 1.55, bottom: -0.25 },
{ x: -5.45, w: 1.20, top: 1.68, bottom: -0.72 },
{ x: -4.40, w: 1.58, top: 1.72, bottom: -1.18 },
{ x: -2.80, w: 1.74, top: 1.68, bottom: -1.38 },
{ x: -0.60, w: 1.80, top: 1.62, bottom: -1.42 },
{ x: 1.60, w: 1.78, top: 1.62, bottom: -1.40 },
{ x: 3.50, w: 1.55, top: 1.68, bottom: -1.18 },
{ x: 4.90, w: 1.18, top: 1.76, bottom: -0.68 },
{ x: 5.80, w: 0.58, top: 1.82, bottom: -0.08 },
{ x: 6.25, w: 0.06, top: 1.70, bottom: 0.35 }
];
function stationAt(x) {
if (x <= stations[0].x) return { ...stations[0] };
if (x >= stations.at(-1).x) return { ...stations.at(-1) };
for (let i = 0; i < stations.length - 1; i++) {
const a = stations[i];
const b = stations[i + 1];
if (x >= a.x && x <= b.x) {
const t = (x - a.x) / (b.x - a.x);
return {
x,
w: THREE.MathUtils.lerp(a.w, b.w, t),
top: THREE.MathUtils.lerp(a.top, b.top, t),
bottom: THREE.MathUtils.lerp(a.bottom, b.bottom, t)
};
}
}
return { ...stations[0] };
}
function sideSurfaceZ(station, y) {
const upperRatio = THREE.MathUtils.clamp(
(y - 0.55) / (station.top - 0.55),
0,
1
);
return station.w * THREE.MathUtils.lerp(0.88, 1.0, upperRatio);
}
function createHullGeometry() {
const positions = [];
const indices = [];
const ringSize = 7;
for (const s of stations) {
const profile = [
[-s.w, s.top],
[-s.w * 0.90, 0.55],
[-s.w * 0.55, s.bottom + 0.18],
[0, s.bottom],
[s.w * 0.55, s.bottom + 0.18],
[s.w * 0.90, 0.55],
[s.w, s.top]
];
for (const [z, y] of profile) {
positions.push(s.x, y, z);
}
}
for (let i = 0; i < stations.length - 1; i++) {
for (let j = 0; j < ringSize - 1; j++) {
const a = i * ringSize + j;
const b = (i + 1) * ringSize + j;
const c = (i + 1) * ringSize + j + 1;
const d = i * ringSize + j + 1;
indices.push(a, b, c, a, c, d);
}
}
// Bow cap.
const bowCenter = positions.length / 3;
const end = stations.at(-1);
positions.push(end.x, (end.top + end.bottom) * 0.5, 0);
const bowStart = (stations.length - 1) * ringSize;
for (let j = 0; j < ringSize; j++) {
indices.push(
bowCenter,
bowStart + j,
bowStart + ((j + 1) % ringSize)
);
}
// Stern cap.
const sternCenter = positions.length / 3;
positions.push(
stations[0].x,
(stations[0].top + stations[0].bottom) * 0.5,
0
);
for (let j = 0; j < ringSize; j++) {
indices.push(
sternCenter,
(j + 1) % ringSize,
j
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const hullMaterial = material.hull.clone();
hullMaterial.side = THREE.DoubleSide;
const hull = addMesh(
createHullGeometry(),
hullMaterial,
null,
null
);
hull.name = "Trireme hull";
// Deck.
const deckPositions = [];
const deckIndices = [];
for (const s of stations) {
deckPositions.push(s.x, s.top, -s.w);
deckPositions.push(s.x, s.top, s.w);
}
for (let i = 0; i < stations.length - 1; i++) {
const a = i * 2;
const b = (i + 1) * 2;
const c = b + 1;
const d = a + 1;
deckIndices.push(a, d, c, a, c, b);
}
const deckGeometry = new THREE.BufferGeometry();
deckGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(deckPositions, 3)
);
deckGeometry.setIndex(deckIndices);
deckGeometry.computeVertexNormals();
const deckMaterial = material.deck.clone();
deckMaterial.side = THREE.DoubleSide;
addMesh(deckGeometry, deckMaterial);
// Narrow deck planks.
for (let x = -5.0; x <= 5.0; x += 0.72) {
const s = stationAt(x);
const length = s.w * 1.72;
addMesh(
new THREE.BoxGeometry(0.035, 0.025, length),
material.plank,
new THREE.Vector3(x, s.top + 0.018, 0)
);
}
function createSideRibbon(yLow, yHigh, side, offset = 0.035) {
const positions = [];
const indices = [];
for (const s of stations) {
const low = typeof yLow === "function" ? yLow(s) : yLow;
const high = typeof yHigh === "function" ? yHigh(s) : yHigh;
positions.push(
s.x,
low,
side * sideSurfaceZ(s, low) + side * offset
);
positions.push(
s.x,
high,
side * sideSurfaceZ(s, high) + side * offset
);
}
for (let i = 0; i < stations.length - 1; i++) {
const a = i * 2;
const b = a + 1;
const c = a + 3;
const d = a + 2;
indices.push(a, b, c, a, c, d);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mat = material.black.clone();
mat.side = THREE.DoubleSide;
return geometry;
}
// Broad black upper wale on both sides.
for (const side of [-1, 1]) {
addMesh(
createSideRibbon(1.16, 1.47, side, 0.045),
material.black
);
// Fine gold line beneath the wale.
addMesh(
createSideRibbon(1.055, 1.105, side, 0.055),
material.bronze
);
// Pale upper trim.
addMesh(
createSideRibbon(
s => s.top - 0.105,
s => s.top - 0.025,
side,
0.04
),
material.cream
);
}
// Oar ports along the visible side.
const portXs = [-4.65, -3.15, -1.55, 1.30, 2.75];
for (const x of portXs) {
const s = stationAt(x);
const y = 1.03;
const z = sideSurfaceZ(s, y) + 0.035;
const port = addMesh(
new THREE.CylinderGeometry(0.205, 0.205, 0.085, 24),
material.black,
new THREE.Vector3(x, y, z),
new THREE.Euler(0, 0, Math.PI / 2)
);
port.name = "Oar port";
addMesh(
new THREE.TorusGeometry(0.215, 0.035, 8, 28),
material.cream,
new THREE.Vector3(x, y, z + 0.025),
new THREE.Euler(0, Math.PI / 2, 0)
);
}
// Visible rowing benches.
for (const x of [-4.15, -2.65, -1.15, 1.45, 3.05]) {
const s = stationAt(x);
addMesh(
new THREE.BoxGeometry(0.36, 0.17, s.w * 1.48),
material.wood,
new THREE.Vector3(x, s.top + 0.13, 0)
);
addMesh(
new THREE.BoxGeometry(0.19, 0.27, s.w * 1.24),
material.plank,
new THREE.Vector3(x, s.top - 0.02, 0)
);
}
// Stylized painted eye near the bow.
const eyeShape = new THREE.Shape();
eyeShape.moveTo(-0.43, 0);
eyeShape.bezierCurveTo(-0.25, 0.23, 0.22, 0.23, 0.43, 0);
eyeShape.bezierCurveTo(0.22, -0.20, -0.25, -0.20, -0.43, 0);
const eyeStation = stationAt(4.45);
const eyeY = 0.82;
const eyeZ = sideSurfaceZ(eyeStation, eyeY) + 0.075;
addMesh(
new THREE.ExtrudeGeometry(eyeShape, {
depth: 0.032,
bevelEnabled: false,
curveSegments: 18
}),
material.white,
new THREE.Vector3(4.45, eyeY, eyeZ)
);
addMesh(
new THREE.CircleGeometry(0.12, 24),
material.blue,
new THREE.Vector3(4.45, eyeY, eyeZ + 0.041)
);
addMesh(
new THREE.CircleGeometry(0.048, 20),
material.black,
new THREE.Vector3(4.45, eyeY, eyeZ + 0.047)
);
// Bronze ram at the bow.
addMesh(
new THREE.ConeGeometry(0.25, 1.35, 12),
material.bronze,
new THREE.Vector3(6.67, 0.38, 0),
new THREE.Euler(0, 0, -Math.PI / 2)
);
addMesh(
new THREE.CylinderGeometry(0.30, 0.30, 0.16, 12),
material.wood,
new THREE.Vector3(6.02, 0.38, 0),
new THREE.Euler(0, 0, Math.PI / 2)
);
// Raised stern ornament.
const sternCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-5.83, 1.62, 0),
new THREE.Vector3(-6.02, 1.90, 0),
new THREE.Vector3(-5.94, 2.18, 0),
new THREE.Vector3(-5.68, 2.30, 0)
]);
addMesh(
new THREE.TubeGeometry(sternCurve, 20, 0.105, 8, false),
material.wood
);
addMesh(
new THREE.SphereGeometry(0.19, 12, 8),
material.cream,
new THREE.Vector3(-5.65, 2.31, 0)
);
// -------------------------------------------------------------------------
// Water
// -------------------------------------------------------------------------
const water = addMesh(
new THREE.PlaneGeometry(70, 70),
material.water,
new THREE.Vector3(0, -0.79, 0),
new THREE.Euler(-Math.PI / 2, 0, 0),
false
);
water.receiveShadow = true;
// Minimal solid wave strokes.
const waveMaterial = new THREE.MeshStandardMaterial({
color: 0xaec5c2,
roughness: 0.65,
transparent: true,
opacity: 0.32
});
const waveData = [
[-5.2, 5.2, 0.9],
[-2.0, 6.0, 1.2],
[ 3.7, 5.5, 1.0],
[ 5.6, 3.4, 0.7],
[-6.0, 2.8, 0.8]
];
for (const [x, z, length] of waveData) {
addMesh(
new THREE.BoxGeometry(length, 0.018, 0.035),
waveMaterial,
new THREE.Vector3(x, -0.775, z),
new THREE.Euler(0, 0.12, 0),
false
);
}
// -------------------------------------------------------------------------
// Hull-side pivot fitting
// -------------------------------------------------------------------------
const pivotX = 0.15;
const pivotY = 1.75;
const pivotZ = 1.90;
const fittingBase = addMesh(
new THREE.BoxGeometry(0.76, 0.65, 0.18),
material.bronze,
new THREE.Vector3(pivotX, 1.47, 1.80)
);
fittingBase.name = "Pivot fitting base";
addMesh(
new THREE.BoxGeometry(0.48, 0.38, 0.20),
material.darkMetal,
new THREE.Vector3(pivotX, 1.64, 1.84)
);
// Two open bronze cheeks show the fixed pivot axis.
for (const offset of [-0.25, 0.25]) {
addMesh(
new THREE.TorusGeometry(0.225, 0.065, 10, 28),
material.bronze,
new THREE.Vector3(pivotX + offset, pivotY, pivotZ),
new THREE.Euler(0, Math.PI / 2, 0)
);
addMesh(
new THREE.BoxGeometry(0.12, 0.38, 0.16),
material.bronze,
new THREE.Vector3(pivotX + offset, 1.48, 1.86)
);
}
// Fixed axle through the support.
addMesh(
new THREE.CylinderGeometry(0.055, 0.055, 0.68, 16),
material.darkMetal,
new THREE.Vector3(pivotX, pivotY, pivotZ),
new THREE.Euler(0, 0, Math.PI / 2)
);
// Decorative bolts on the fitting plate.
for (const dx of [-0.26, 0.26]) {
for (const y of [1.25, 1.58]) {
addMesh(
new THREE.SphereGeometry(0.055, 10, 8),
material.darkMetal,
new THREE.Vector3(pivotX + dx, y, 1.91)
);
}
}
// -------------------------------------------------------------------------
// One continuous oar, all parts inside the same rotating group
// -------------------------------------------------------------------------
const oar = new THREE.Group();
oar.position.set(pivotX, pivotY, pivotZ);
oar.rotation.x = THREE.MathUtils.degToRad(22);
scene.add(oar);
function addOarMesh(geometry, mat, position, rotation) {
const mesh = new THREE.Mesh(geometry, mat);
if (position) mesh.position.copy(position);
if (rotation) mesh.rotation.set(rotation.x, rotation.y, rotation.z);
mesh.castShadow = true;
mesh.receiveShadow = true;
oar.add(mesh);
return mesh;
}
// Central rotating hub.
addOarMesh(
new THREE.SphereGeometry(0.17, 16, 10),
material.bronze,
new THREE.Vector3(0, 0, 0)
);
addOarMesh(
new THREE.CylinderGeometry(0.145, 0.145, 0.32, 16),
material.bronze,
new THREE.Vector3(0, 0, 0),
new THREE.Euler(Math.PI / 2, 0, 0)
);
// Main outboard shaft, tapered toward the blade.
addOarMesh(
new THREE.CylinderGeometry(0.065, 0.098, 3.80, 12),
material.wood,
new THREE.Vector3(0, 0, 1.78),
new THREE.Euler(Math.PI / 2, 0, 0)
);
// Tapered transition into the inboard grip.
addOarMesh(
new THREE.CylinderGeometry(0.08, 0.125, 0.55, 12),
material.wood,
new THREE.Vector3(0, 0, -0.38),
new THREE.Euler(Math.PI / 2, 0, 0)
);
// Inboard handle.
addOarMesh(
new THREE.CylinderGeometry(0.125, 0.125, 1.25, 12),
material.grip,
new THREE.Vector3(0, 0, -1.28),
new THREE.Euler(Math.PI / 2, 0, 0)
);
addOarMesh(
new THREE.SphereGeometry(0.145, 12, 8),
material.leather,
new THREE.Vector3(0, 0, -1.93)
);
// Leather wraps around the inboard grip.
for (const z of [-1.64, -1.39, -1.14, -0.89]) {
addOarMesh(
new THREE.TorusGeometry(0.126, 0.016, 7, 24),
material.leather,
new THREE.Vector3(0, 0, z)
);
}
// Flattened, solid leaf-shaped outboard blade.
function createBladeGeometry() {
const sections = [
{ z: 3.53, width: 0.09 },
{ z: 3.88, width: 0.28 },
{ z: 4.66, width: 0.46 },
{ z: 5.34, width: 0.37 },
{ z: 5.62, width: 0.055 }
];
const thickness = 0.12;
const positions = [];
const indices = [];
for (const section of sections) {
positions.push(
-thickness / 2, -section.width, section.z,
thickness / 2, -section.width, section.z,
thickness / 2, section.width, section.z,
-thickness / 2, section.width, section.z
);
}
for (let i = 0; i < sections.length - 1; i++) {
for (let j = 0; j < 4; j++) {
const next = (j + 1) % 4;
const a = i * 4 + j;
const b = (i + 1) * 4 + j;
const c = (i + 1) * 4 + next;
const d = i * 4 + next;
indices.push(a, b, c, a, c, d);
}
}
indices.push(
0, 2, 1,
0, 3, 2
);
const end = (sections.length - 1) * 4;
indices.push(
end, end + 1, end + 2,
end, end + 2, end + 3
);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const bladeGeometry = createBladeGeometry();
addOarMesh(
bladeGeometry,
material.blade
);
// A raised red painted panel follows the blade silhouette.
const inlay = addOarMesh(
bladeGeometry.clone(),
material.hull
);
inlay.scale.x = 0.16;
inlay.position.x = 0.073;
// Brass blade fasteners.
for (const x of [-0.075, 0.075]) {
addOarMesh(
new THREE.SphereGeometry(0.045, 10, 8),
material.bronze,
new THREE.Vector3(x, 0, 3.73)
);
}
// -------------------------------------------------------------------------
// Oar angle controls
// -------------------------------------------------------------------------
const angleInput = document.querySelector("#angle");
const angleValue = document.querySelector("#angle-value");
const autoButton = document.querySelector("#auto");
const resetButton = document.querySelector("#reset-view");
let currentAngle = THREE.MathUtils.degToRad(22);
let desiredAngle = currentAngle;
let automatic = true;
function updateRangeFill() {
const min = Number(angleInput.min);
const max = Number(angleInput.max);
const value = Number(angleInput.value);
const percentage = ((value - min) / (max - min)) * 100;
angleInput.style.setProperty("--fill", `${percentage}%`);
}
function setAutomatic(enabled) {
automatic = enabled;
autoButton.classList.toggle("active", enabled);
autoButton.setAttribute("aria-pressed", String(enabled));
autoButton.textContent = enabled ? "Pause sweep" : "Resume sweep";
}
angleInput.addEventListener("input", () => {
setAutomatic(false);
desiredAngle = THREE.MathUtils.degToRad(Number(angleInput.value));
updateRangeFill();
});
autoButton.addEventListener("click", () => {
setAutomatic(!automatic);
});
resetButton.addEventListener("click", () => {
view.theta = 0.54;
view.phi = 1.12;
view.radius = window.innerWidth < 720 ? 17.8 : 15.7;
view.target.set(0, 0.8, 1.35);
updateCamera();
});
updateRangeFill();
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, and zoom
// -------------------------------------------------------------------------
let pointer = null;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointer = {
id: event.pointerId,
x: event.clientX,
y: event.clientY,
mode: event.button === 2 || event.shiftKey ? "pan" : "orbit"
};
});
canvas.addEventListener("pointermove", event => {
if (!pointer || pointer.id !== event.pointerId) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (pointer.mode === "orbit") {
view.theta -= dx * 0.005;
view.phi = THREE.MathUtils.clamp(
view.phi - dy * 0.005,
0.32,
1.48
);
} else {
const direction = new THREE.Vector3();
camera.getWorldDirection(direction);
const right = new THREE.Vector3()
.crossVectors(direction, camera.up)
.normalize();
const up = new THREE.Vector3()
.crossVectors(right, direction)
.normalize();
const scale = view.radius * 0.00135;
view.target
.addScaledVector(right, -dx * scale)
.addScaledVector(up, dy * scale);
}
updateCamera();
});
function endPointer(event) {
if (pointer && pointer.id === event.pointerId) {
pointer = null;
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
view.radius = THREE.MathUtils.clamp(
view.radius * Math.exp(event.deltaY * 0.001),
8,
29
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
view.theta = 0.54;
view.phi = 1.12;
view.radius = window.innerWidth < 720 ? 17.8 : 15.7;
view.target.set(0, 0.8, 1.35);
updateCamera();
});
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
if (automatic) {
desiredAngle = THREE.MathUtils.degToRad(
22 + 7 * Math.sin(elapsed * 0.62)
);
}
currentAngle = THREE.MathUtils.lerp(
currentAngle,
desiredAngle,
0.065
);
oar.rotation.x = currentAngle;
const displayAngle = Math.round(THREE.MathUtils.radToDeg(currentAngle));
if (document.activeElement !== angleInput) {
angleInput.value = String(displayAngle);
updateRangeFill();
}
angleValue.textContent = `${displayAngle}°`;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```