Prompt specification
Build or customize the Three.js 3D scene "Single Rower Stroke Sequence" 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: Single Rower Stroke Sequence
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/single-rower-stroke-sequence-x3642
Scene Description Prompt:
Animate a stylized rower through catch, drive, release, and recovery in a schematic cycle. Keep hands attached to the handle and label propulsion as illustrative. Build this with Three.js from cdnjs as a stylized scene in one self-contained HTML file.
Working Three.js Starter (single-rower-stroke-sequence-x3642):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Schematic Rowing Stroke</title>
<style>
:root {
--ink: #173a43;
--muted: #61777c;
--paper: rgba(250, 248, 239, 0.88);
--line: rgba(23, 58, 67, 0.14);
--accent: #ef6a4c;
--accent-soft: #f7c66b;
--teal: #167681;
}
* {
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;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
}
.brand {
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 7px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 42px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
max-width: 350px;
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.legend {
top: 24px;
right: 24px;
display: flex;
align-items: center;
gap: 11px;
padding: 11px 14px;
border: 1px solid rgba(23, 58, 67, 0.12);
border-radius: 12px;
background: var(--paper);
box-shadow: 0 10px 35px rgba(28, 65, 72, 0.08);
backdrop-filter: blur(12px);
}
.legend-icon {
position: relative;
width: 29px;
height: 12px;
}
.legend-icon::before {
position: absolute;
top: 5px;
left: 0;
width: 22px;
height: 2px;
content: "";
background: var(--accent);
}
.legend-icon::after {
position: absolute;
top: 2px;
left: 0;
width: 0;
height: 0;
content: "";
border-top: 4px solid transparent;
border-right: 7px solid var(--accent);
border-bottom: 4px solid transparent;
transform: rotate(180deg);
}
.legend b,
.legend small {
display: block;
}
.legend b {
font-size: 10px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend small {
margin-top: 2px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.phase-panel {
bottom: 24px;
left: 50%;
width: min(760px, calc(100vw - 32px));
padding: 13px;
border: 1px solid rgba(23, 58, 67, 0.12);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(28, 65, 72, 0.12);
backdrop-filter: blur(14px);
transform: translateX(-50%);
pointer-events: auto;
}
.phase-row {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 7px;
}
.phase {
position: relative;
min-width: 0;
overflow: hidden;
padding: 10px 12px 12px;
border: 1px solid transparent;
border-radius: 10px;
color: #789095;
transition:
color 180ms ease,
border-color 180ms ease,
background 180ms ease;
}
.phase.active {
border-color: rgba(239, 106, 76, 0.2);
background: rgba(239, 106, 76, 0.08);
color: var(--ink);
}
.phase-fill {
position: absolute;
inset: auto 0 0;
height: 3px;
background: var(--accent);
transform: scaleX(0);
transform-origin: left;
}
.phase-number {
display: block;
margin-bottom: 4px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
opacity: 0.68;
}
.phase-name {
display: block;
font-size: 13px;
font-weight: 800;
}
.phase-description {
display: block;
min-height: 29px;
margin-top: 4px;
font-size: 10px;
line-height: 1.35;
opacity: 0.75;
}
.toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid var(--line);
}
.controls {
display: flex;
gap: 7px;
}
.control {
padding: 7px 11px;
border: 1px solid rgba(23, 58, 67, 0.14);
border-radius: 8px;
background: rgba(255, 255, 255, 0.48);
color: var(--ink);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
cursor: pointer;
transition:
background 150ms ease,
transform 150ms ease;
}
.control:hover {
background: white;
transform: translateY(-1px);
}
.hint {
color: var(--muted);
font-size: 10px;
text-align: right;
}
#propulsion-tag {
position: fixed;
z-index: 12;
min-width: 150px;
padding: 9px 11px;
border: 1px solid rgba(239, 106, 76, 0.3);
border-radius: 9px;
background: rgba(255, 248, 237, 0.94);
box-shadow: 0 9px 28px rgba(43, 71, 75, 0.13);
opacity: 0;
pointer-events: none;
transform: translate(-50%, calc(-100% - 25px));
transition: opacity 120ms ease;
}
#propulsion-tag::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 24px;
content: "";
background: var(--accent);
}
#propulsion-tag b,
#propulsion-tag small {
display: block;
}
#propulsion-tag b {
color: var(--accent);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#propulsion-tag small {
margin-top: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 680px) {
.brand {
top: 16px;
left: 16px;
}
.subtitle {
display: none;
}
.legend {
top: auto;
right: 16px;
bottom: 166px;
padding: 8px 10px;
}
.phase-panel {
bottom: 12px;
padding: 9px;
}
.phase {
padding: 8px 6px 10px;
text-align: center;
}
.phase-description,
.hint {
display: none;
}
.phase-number {
font-size: 8px;
}
.phase-name {
font-size: 10px;
}
.toolbar {
justify-content: center;
margin-top: 7px;
padding-top: 7px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive schematic rowing animation"></canvas>
<header class="hud brand">
<div class="eyebrow">Biomechanics / 04</div>
<h1>Schematic<br />Rowing Stroke</h1>
<p class="subtitle">
A stylized sculling cycle showing seat travel, body pivot, leg drive,
and an oar handle tracked to both hands.
</p>
</header>
<aside class="hud legend" aria-label="Propulsion disclaimer">
<span class="legend-icon" aria-hidden="true"></span>
<span>
<b>Forward Force</b>
<small>Illustrative only</small>
</span>
</aside>
<section class="hud phase-panel" aria-label="Stroke phases and controls">
<div class="phase-row">
<div class="phase active" data-phase="catch">
<span class="phase-number">01</span>
<span class="phase-name">Catch</span>
<span class="phase-description">Compressed posture</span>
<span class="phase-fill"></span>
</div>
<div class="phase" data-phase="drive">
<span class="phase-number">02</span>
<span class="phase-name">Drive</span>
<span class="phase-description">Legs and body</span>
<span class="phase-fill"></span>
</div>
<div class="phase" data-phase="release">
<span class="phase-number">03</span>
<span class="phase-name">Release</span>
<span class="phase-description">Arms extended</span>
<span class="phase-fill"></span>
</div>
<div class="phase" data-phase="recovery">
<span class="phase-number">04</span>
<span class="phase-name">Recovery</span>
<span class="phase-description">Body pivots back</span>
<span class="phase-fill"></span>
</div>
</div>
<div class="toolbar">
<div class="controls">
<button class="control" id="pause" type="button">Pause</button>
<button class="control" id="restart" type="button">Restart</button>
<button class="control" id="camera-reset" type="button">Reset View</button>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</div>
</section>
<div id="propulsion-tag">
<b>Propulsion</b>
<small>Illustrative · Not to scale</small>
</div>
<div id="phase-announcer" class="sr-only" aria-live="polite"></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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdcecef);
scene.fog = new THREE.Fog(0xdcecef, 11, 25);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(-0.05, 0.92, 0);
const defaultCamera = {
theta: 0.87,
phi: 1.13,
radius: 8.4
};
const orbit = { ...defaultCamera };
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
cameraTarget.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
cameraTarget.y + orbit.radius * Math.cos(orbit.phi),
cameraTarget.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xf4fbfa, 0x4d7d83, 2.15);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xfff2d9, 3.1);
keyLight.position.set(-3.5, 8, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xb8edf1, 1.35);
rimLight.position.set(4, 3.5, -5);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Procedural water texture: no external image assets
// -------------------------------------------------------------------------
const textureCanvas = document.createElement("canvas");
textureCanvas.width = 512;
textureCanvas.height = 512;
const textureContext = textureCanvas.getContext("2d");
const gradient = textureContext.createLinearGradient(0, 0, 512, 512);
gradient.addColorStop(0, "#8bc8ca");
gradient.addColorStop(1, "#5aa8b0");
textureContext.fillStyle = gradient;
textureContext.fillRect(0, 0, 512, 512);
textureContext.strokeStyle = "rgba(244, 253, 250, 0.22)";
textureContext.lineWidth = 2;
for (let row = -1; row < 9; row++) {
for (let col = -1; col < 9; col++) {
const x = col * 76 + (row % 2) * 38;
const y = row * 64;
textureContext.beginPath();
textureContext.moveTo(x, y + 14);
textureContext.bezierCurveTo(
x + 17, y,
x + 38, y + 27,
x + 67, y + 9
);
textureContext.stroke();
}
}
const waterTexture = new THREE.CanvasTexture(textureCanvas);
waterTexture.colorSpace = THREE.SRGBColorSpace;
waterTexture.wrapS = waterTexture.wrapT = THREE.RepeatWrapping;
waterTexture.repeat.set(4.5, 4.5);
waterTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const water = new THREE.Mesh(
new THREE.PlaneGeometry(42, 42),
new THREE.MeshStandardMaterial({
map: waterTexture,
color: 0xffffff,
roughness: 0.68,
metalness: 0.03
})
);
water.rotation.x = -Math.PI / 2;
water.position.y = -0.075;
water.receiveShadow = true;
scene.add(water);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const materials = {
hull: new THREE.MeshStandardMaterial({
color: 0x116d78,
roughness: 0.38,
metalness: 0.08
}),
deck: new THREE.MeshStandardMaterial({
color: 0xf5efdc,
roughness: 0.62
}),
stripe: new THREE.MeshStandardMaterial({
color: 0xef6a4c,
roughness: 0.55
}),
rail: new THREE.MeshStandardMaterial({
color: 0x315b62,
roughness: 0.32,
metalness: 0.45
}),
jersey: new THREE.MeshStandardMaterial({
color: 0xef6a4c,
roughness: 0.7
}),
shorts: new THREE.MeshStandardMaterial({
color: 0x183e49,
roughness: 0.72
}),
skin: new THREE.MeshStandardMaterial({
color: 0xd59b74,
roughness: 0.78
}),
shoe: new THREE.MeshStandardMaterial({
color: 0xf4c45d,
roughness: 0.72
}),
cap: new THREE.MeshStandardMaterial({
color: 0x173f4a,
roughness: 0.74
}),
dark: new THREE.MeshStandardMaterial({
color: 0x18333a,
roughness: 0.7
}),
metal: new THREE.MeshStandardMaterial({
color: 0x8da5a5,
roughness: 0.24,
metalness: 0.8
}),
blade: new THREE.MeshStandardMaterial({
color: 0xf4c45d,
roughness: 0.45,
metalness: 0.06
})
};
const Y_AXIS = new THREE.Vector3(0, 1, 0);
const tempDirection = new THREE.Vector3();
function makeSegment(radius, material, radialSegments = 12) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, 1, radialSegments),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function setSegment(mesh, start, end) {
tempDirection.subVectors(end, start);
const length = Math.max(tempDirection.length(), 0.0001);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
Y_AXIS,
tempDirection.multiplyScalar(1 / length)
);
mesh.scale.set(1, length, 1);
}
function makeSphere(radius, material, widthSegments = 20) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, widthSegments, 14),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
// -------------------------------------------------------------------------
// Boat
// -------------------------------------------------------------------------
const boat = new THREE.Group();
scene.add(boat);
const hullShape = new THREE.Shape();
hullShape.moveTo(-2.75, 0.12);
hullShape.bezierCurveTo(-2.5, 0.35, -2.15, 0.43, -1.55, 0.43);
hullShape.lineTo(1.65, 0.43);
hullShape.bezierCurveTo(2.25, 0.41, 2.55, 0.31, 2.75, 0.12);
hullShape.lineTo(2.38, -0.04);
hullShape.lineTo(-2.38, -0.04);
hullShape.closePath();
const hullGeometry = new THREE.ExtrudeGeometry(hullShape, {
depth: 0.76,
bevelEnabled: true,
bevelSegments: 3,
steps: 1,
bevelSize: 0.075,
bevelThickness: 0.055
});
hullGeometry.translate(0, 0, -0.38);
const hull = new THREE.Mesh(hullGeometry, materials.hull);
hull.castShadow = true;
hull.receiveShadow = true;
boat.add(hull);
const deckShape = new THREE.Shape();
deckShape.moveTo(-2.55, 0);
deckShape.quadraticCurveTo(-1.8, 0.35, -0.6, 0.42);
deckShape.lineTo(1.55, 0.38);
deckShape.quadraticCurveTo(2.35, 0.28, 2.65, 0);
deckShape.quadraticCurveTo(2.35, -0.28, 1.55, -0.38);
deckShape.lineTo(-0.6, -0.42);
deckShape.quadraticCurveTo(-1.8, -0.35, -2.55, 0);
deckShape.closePath();
const deckGeometry = new THREE.ShapeGeometry(deckShape, 32);
deckGeometry.rotateX(Math.PI / 2);
const deck = new THREE.Mesh(deckGeometry, materials.deck);
deck.position.y = 0.465;
deck.receiveShadow = true;
boat.add(deck);
const centerStripe = new THREE.Mesh(
new THREE.BoxGeometry(3.65, 0.022, 0.065),
materials.stripe
);
centerStripe.position.set(0.16, 0.485, 0);
boat.add(centerStripe);
for (const z of [-0.22, 0.22]) {
const rail = new THREE.Mesh(
new THREE.BoxGeometry(1.75, 0.035, 0.035),
materials.rail
);
rail.position.set(-0.47, 0.51, z);
rail.castShadow = true;
boat.add(rail);
}
const seat = new THREE.Mesh(
new THREE.BoxGeometry(0.42, 0.085, 0.48),
materials.dark
);
seat.position.set(-0.42, 0.55, 0);
seat.castShadow = true;
boat.add(seat);
const footplate = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.29, 0.68),
materials.rail
);
footplate.position.set(-1.25, 0.45, 0);
footplate.rotation.z = -0.16;
footplate.castShadow = true;
boat.add(footplate);
const bowStripe = new THREE.Mesh(
new THREE.BoxGeometry(0.48, 0.025, 0.065),
materials.stripe
);
bowStripe.position.set(-1.95, 0.49, 0);
bowStripe.rotation.z = -0.14;
boat.add(bowStripe);
// -------------------------------------------------------------------------
// Rower
// -------------------------------------------------------------------------
const rower = new THREE.Group();
boat.add(rower);
const pelvis = makeSphere(0.27, materials.shorts);
pelvis.scale.set(0.95, 0.72, 1.12);
rower.add(pelvis);
const torsoGeometry = new THREE.CapsuleGeometry(0.23, 0.58, 6, 16);
const torso = new THREE.Mesh(torsoGeometry, materials.jersey);
torso.castShadow = true;
torso.receiveShadow = true;
rower.add(torso);
const neck = makeSegment(0.105, materials.skin);
rower.add(neck);
const head = makeSphere(0.215, materials.skin, 24);
rower.add(head);
const cap = new THREE.Mesh(
new THREE.SphereGeometry(0.222, 24, 14, 0, Math.PI * 2, 0, Math.PI / 2),
materials.cap
);
cap.castShadow = true;
rower.add(cap);
const capBrim = new THREE.Mesh(
new THREE.BoxGeometry(0.27, 0.035, 0.32),
materials.cap
);
capBrim.castShadow = true;
rower.add(capBrim);
const nose = makeSphere(0.055, materials.skin, 12);
rower.add(nose);
const eye = makeSphere(0.018, materials.dark, 10);
rower.add(eye);
const arms = [];
const legs = [];
for (const side of [-1, 1]) {
const shoulderCap = makeSphere(0.145, materials.jersey, 16);
const upperArm = makeSegment(0.083, materials.skin);
const forearm = makeSegment(0.068, materials.skin);
const elbow = makeSphere(0.083, materials.skin, 14);
const hand = makeSphere(0.09, materials.skin, 14);
rower.add(shoulderCap, upperArm, forearm, elbow, hand);
arms.push({
side,
shoulderCap,
upperArm,
forearm,
elbow,
hand
});
const upperLeg = makeSegment(0.13, materials.shorts);
const lowerLeg = makeSegment(0.092, materials.skin);
const knee = makeSphere(0.105, materials.skin, 14);
const shoe = new THREE.Mesh(
new THREE.BoxGeometry(0.3, 0.13, 0.17),
materials.shoe
);
shoe.castShadow = true;
shoe.receiveShadow = true;
rower.add(upperLeg, lowerLeg, knee, shoe);
legs.push({
side,
upperLeg,
lowerLeg,
knee,
shoe
});
}
// -------------------------------------------------------------------------
// Oar, handle, blade, and oarlock
// -------------------------------------------------------------------------
const oarPivot = new THREE.Vector3(-0.18, 0.57, -0.57);
const oarlock = new THREE.Mesh(
new THREE.TorusGeometry(0.105, 0.024, 10, 28),
materials.metal
);
oarlock.position.copy(oarPivot);
oarlock.castShadow = true;
boat.add(oarlock);
const oarlockStem = makeSegment(0.025, materials.metal);
setSegment(
oarlockStem,
new THREE.Vector3(-0.18, 0.48, -0.57),
oarPivot
);
boat.add(oarlockStem);
const handleGrip = new THREE.Mesh(
new THREE.CylinderGeometry(0.036, 0.036, 0.4, 12),
materials.dark
);
handleGrip.rotation.x = Math.PI / 2;
handleGrip.castShadow = true;
boat.add(handleGrip);
const innerShaft = makeSegment(0.026, materials.metal);
const outerShaft = makeSegment(0.027, materials.metal);
boat.add(innerShaft, outerShaft);
const blade = new THREE.Mesh(
new THREE.BoxGeometry(0.68, 0.035, 0.24),
materials.blade
);
blade.castShadow = true;
boat.add(blade);
const bladeNose = makeSphere(0.12, materials.blade, 16);
bladeNose.scale.set(0.55, 0.17, 1.0);
boat.add(bladeNose);
// -------------------------------------------------------------------------
// Two-bone inverse kinematics
// -------------------------------------------------------------------------
function solveIK(root, end, upperLength, lowerLength, bendHint) {
const direction = end.clone().sub(root);
const actualDistance = direction.length();
direction.normalize();
const distance = Math.min(actualDistance, upperLength + lowerLength - 0.001);
const along =
(upperLength * upperLength -
lowerLength * lowerLength +
distance * distance) /
(2 * distance);
const height = Math.sqrt(
Math.max(0, upperLength * upperLength - along * along)
);
const bend = bendHint
.clone()
.addScaledVector(direction, -bendHint.dot(direction));
if (bend.lengthSq() < 0.00001) {
bend.set(-direction.y, direction.x, 0);
}
bend.normalize();
const midpoint = root
.clone()
.addScaledVector(direction, along);
return midpoint.addScaledVector(bend, height);
}
// -------------------------------------------------------------------------
// Stroke animation
// -------------------------------------------------------------------------
const frames = [
{
t: 0.00,
seat: -0.42,
lean: 0.60,
handleX: -0.91,
handleY: 0.88
},
{
t: 0.14,
seat: -0.42,
lean: 0.60,
handleX: -0.91,
handleY: 0.88
},
{
t: 0.44,
seat: 0.03,
lean: 0.08,
handleX: 0.57,
handleY: 1.18
},
{
t: 0.58,
seat: 0.03,
lean: 0.08,
handleX: 0.57,
handleY: 1.18
},
{
t: 0.90,
seat: -0.42,
lean: 0.60,
handleX: -0.91,
handleY: 0.88
},
{
t: 1.00,
seat: -0.42,
lean: 0.60,
handleX: -0.91,
handleY: 0.88
}
];
function sampleStroke(t) {
for (let i = 0; i < frames.length - 1; i++) {
const a = frames[i];
const b = frames[i + 1];
if (t >= a.t && t <= b.t) {
const local = (t - a.t) / (b.t - a.t);
const eased = local * local * (3 - 2 * local);
return {
seat: THREE.MathUtils.lerp(a.seat, b.seat, eased),
lean: THREE.MathUtils.lerp(a.lean, b.lean, eased),
handleX: THREE.MathUtils.lerp(a.handleX, b.handleX, eased),
handleY: THREE.MathUtils.lerp(a.handleY, b.handleY, eased)
};
}
}
return frames[frames.length - 1];
}
function phaseForTime(t) {
if (t < 0.14) return "catch";
if (t < 0.44) return "drive";
if (t < 0.58) return "release";
return "recovery";
}
const phaseCopy = {
catch: "Catch — compressed posture",
drive: "Drive — legs and body extend",
release: "Release — arms reach fully",
recovery: "Recovery — body and handle return"
};
const phaseElements = [...document.querySelectorAll(".phase")];
const phaseFillElements = phaseElements.map((element) =>
element.querySelector(".phase-fill")
);
const phaseAnnouncer = document.querySelector("#phase-announcer");
let lastPhase = "";
function updatePhaseUI(t, phase) {
for (let i = 0; i < phaseElements.length; i++) {
phaseElements[i].classList.toggle(
"active",
phaseElements[i].dataset.phase === phase
);
}
const fills = [0, 0, 0, 0];
if (t <= 0.14) {
fills[0] = t / 0.14;
} else if (t <= 0.44) {
fills[0] = 1;
fills[1] = (t - 0.14) / 0.30;
} else if (t <= 0.58) {
fills[0] = 1;
fills[1] = 1;
fills[2] = (t - 0.44) / 0.14;
} else if (t <= 0.90) {
fills[0] = 1;
fills[1] = 1;
fills[2] = 1;
fills[3] = (t - 0.58) / 0.32;
} else {
fills.fill(1);
}
for (let i = 0; i < fills.length; i++) {
phaseFillElements[i].style.transform = `scaleX(${fills[i]})`;
}
if (phase !== lastPhase) {
phaseAnnouncer.textContent = phaseCopy[phase];
lastPhase = phase;
}
}
const hip = new THREE.Vector3();
const shoulderCenter = new THREE.Vector3();
const torsoDirection = new THREE.Vector3();
const handlePosition = new THREE.Vector3();
const bladeCenter = new THREE.Vector3();
const armShoulder = new THREE.Vector3();
const armHand = new THREE.Vector3();
let armElbow = new THREE.Vector3();
const armBend = new THREE.Vector3();
const legHip = new THREE.Vector3();
const legFoot = new THREE.Vector3();
let legKnee = new THREE.Vector3();
function updateRower(state) {
hip.set(state.seat, 0.78, 0);
torsoDirection.set(
-Math.sin(state.lean),
Math.cos(state.lean),
0
);
shoulderCenter
.copy(hip)
.addScaledVector(torsoDirection, 0.92);
// Torso.
pelvis.position.copy(hip);
const torsoStart = hip.clone().addScaledVector(torsoDirection, 0.10);
const torsoEnd = shoulderCenter.clone().addScaledVector(torsoDirection, -0.04);
const torsoLength = torsoStart.distanceTo(torsoEnd);
torso.position.copy(torsoStart).add(torsoEnd).multiplyScalar(0.5);
torso.quaternion.setFromUnitVectors(
Y_AXIS,
torsoEnd.clone().sub(torsoStart).normalize()
);
torso.scale.set(1, torsoLength / 1.04, 1);
// Neck and head.
const headPosition = shoulderCenter.clone().addScaledVector(torsoDirection, 0.27);
setSegment(
neck,
shoulderCenter.clone().addScaledVector(torsoDirection, -0.02),
headPosition.clone().add(new THREE.Vector3(0, -0.09, 0))
);
head.position.copy(headPosition);
cap.position.copy(headPosition).add(new THREE.Vector3(0, 0.015, 0));
capBrim.position.copy(headPosition).add(new THREE.Vector3(-0.19, 0.08, 0));
nose.position.copy(headPosition).add(new THREE.Vector3(-0.205, 0.005, 0.035));
eye.position.copy(headPosition).add(new THREE.Vector3(-0.145, 0.05, 0.185));
// Handle is the common target for both hands.
handlePosition.set(state.handleX, state.handleY, 0.12);
handleGrip.position.copy(handlePosition);
for (const arm of arms) {
armShoulder
.copy(shoulderCenter)
.add(new THREE.Vector3(0, 0, arm.side * 0.185));
armHand
.copy(handlePosition)
.add(new THREE.Vector3(0, 0, arm.side * 0.13));
armBend.set(0, 0, arm.side);
armElbow = solveIK(
armShoulder,
armHand,
0.47,
0.47,
armBend
);
arm.shoulderCap.position.copy(armShoulder);
arm.elbow.position.copy(armElbow);
arm.hand.position.copy(armHand);
setSegment(arm.upperArm, armShoulder, armElbow);
setSegment(arm.forearm, armElbow, armHand);
}
// Feet remain fixed to the foot stretcher.
for (const leg of legs) {
legHip.copy(hip).add(new THREE.Vector3(0, 0, leg.side * 0.135));
legFoot.set(-1.22, 0.47, leg.side * 0.185);
legKnee = solveIK(
legHip,
legFoot,
0.68,
0.68,
new THREE.Vector3(-0.35, 1, 0)
);
leg.knee.position.copy(legKnee);
leg.shoe.position.copy(legFoot).add(new THREE.Vector3(-0.065, -0.005, 0));
setSegment(leg.upperLeg, legHip, legKnee);
setSegment(leg.lowerLeg, legKnee, legFoot);
}
// Oar shaft runs from the held handle through the fixed oarlock.
setSegment(innerShaft, handlePosition, oarPivot);
const sweep = oarPivot.clone().sub(handlePosition);
const horizontalScale = 1.12 / Math.hypot(sweep.x, sweep.z);
bladeCenter.set(
oarPivot.x + sweep.x * horizontalScale,
0.075,
oarPivot.z + sweep.z * horizontalScale
);
setSegment(outerShaft, oarPivot, bladeCenter);
const bladeAngle = Math.atan2(
bladeCenter.z - oarPivot.z,
bladeCenter.x - oarPivot.x
);
blade.position.copy(bladeCenter);
blade.rotation.y = -bladeAngle;
bladeNose.position.copy(bladeCenter);
bladeNose.position.x += Math.cos(bladeAngle) * 0.31;
bladeNose.position.z += Math.sin(bladeAngle) * 0.31;
bladeNose.rotation.y = -bladeAngle;
}
// -------------------------------------------------------------------------
// Propulsion arrow and wake rings
// -------------------------------------------------------------------------
const propulsionArrow = new THREE.ArrowHelper(
new THREE.Vector3(-1, 0, 0),
new THREE.Vector3(),
0.8,
0xef6a4c,
0.18,
0.09
);
propulsionArrow.line.material.transparent = true;
propulsionArrow.cone.material.transparent = true;
propulsionArrow.line.material.depthTest = false;
propulsionArrow.cone.material.depthTest = false;
boat.add(propulsionArrow);
const wakeRings = [];
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
new THREE.RingGeometry(0.42, 0.445, 64),
new THREE.MeshBasicMaterial({
color: 0xeaf9f5,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
depthWrite: false
})
);
ring.rotation.x = -Math.PI / 2;
boat.add(ring);
wakeRings.push(ring);
}
const propulsionTag = document.querySelector("#propulsion-tag");
const projectedAnchor = new THREE.Vector3();
function updatePropulsion(force, elapsed) {
propulsionArrow.visible = force > 0.015;
if (propulsionArrow.visible) {
propulsionArrow.position
.copy(bladeCenter)
.add(new THREE.Vector3(0, 0.23, 0));
propulsionArrow.setLength(
0.42 + force * 0.65,
0.16,
0.085
);
propulsionArrow.line.material.opacity = 0.3 + force * 0.7;
propulsionArrow.cone.material.opacity = 0.3 + force * 0.7;
}
for (let i = 0; i < wakeRings.length; i++) {
const ringProgress = (elapsed * 0.75 + i / wakeRings.length) % 1;
const ringScale = 0.45 + ringProgress * 1.7;
wakeRings[i].position.set(
bladeCenter.x + ringProgress * 0.28,
-0.025,
bladeCenter.z
);
wakeRings[i].scale.setScalar(ringScale);
wakeRings[i].material.opacity =
force * (1 - ringProgress) * 0.34;
}
boat.updateMatrixWorld(true);
projectedAnchor
.copy(bladeCenter)
.add(new THREE.Vector3(-0.25, 0.48, 0));
boat.localToWorld(projectedAnchor);
projectedAnchor.project(camera);
const visible =
projectedAnchor.z > -1 &&
projectedAnchor.z < 1 &&
force > 0.015;
propulsionTag.style.opacity = visible
? String(0.35 + force * 0.65)
: "0";
if (visible) {
propulsionTag.style.left =
`${(projectedAnchor.x * 0.5 + 0.5) * window.innerWidth}px`;
propulsionTag.style.top =
`${(-projectedAnchor.y * 0.5 + 0.5) * window.innerHeight}px`;
}
}
// -------------------------------------------------------------------------
// Custom camera controls
// -------------------------------------------------------------------------
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + deltaY * 0.005,
0.38,
1.46
);
updateCamera();
});
canvas.addEventListener("pointerup", (event) => {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.006,
5.2,
13
);
updateCamera();
},
{ passive: false }
);
function resetCamera() {
Object.assign(orbit, defaultCamera);
updateCamera();
}
canvas.addEventListener("dblclick", resetCamera);
document.querySelector("#camera-reset").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Playback controls
// -------------------------------------------------------------------------
const cycleDuration = 7.4;
let cycleTime = 0;
let paused = false;
const pauseButton = document.querySelector("#pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Play" : "Pause";
});
document.querySelector("#restart").addEventListener("click", () => {
cycleTime = 0;
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
if (!paused) {
cycleTime = (cycleTime + delta / cycleDuration) % 1;
}
const state = sampleStroke(cycleTime);
const phase = phaseForTime(cycleTime);
updatePhaseUI(cycleTime, phase);
updateRower(state);
// Subtle boat motion keeps the scene alive without implying a physical
// displacement of the boat during each repeated cycle.
boat.position.y = Math.sin(elapsed * 0.95) * 0.012;
boat.rotation.z = Math.sin(elapsed * 0.58) * 0.006;
seat.position.x = state.seat;
let driveProgress = 0;
let force = 0;
if (cycleTime >= 0.14 && cycleTime <= 0.44) {
driveProgress = (cycleTime - 0.14) / 0.30;
force = Math.sin(Math.PI * driveProgress);
}
updatePropulsion(force, elapsed);
waterTexture.offset.x = elapsed * 0.006;
waterTexture.offset.y = elapsed * 0.0025;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
```