Prompt specification
Build or customize the Three.js 3D scene "Recife waterfront edge and boat boarding step" 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: Recife waterfront edge and boat boarding step
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/recife-waterfront-edge-and-boat-boarding-step-x2694
Scene Description Prompt:
A voxel Recife waterfront fragment with railing, small boat, and a readable boarding step. One HTML file using Three.js from cdnjs.
Working Three.js Starter (recife-waterfront-edge-and-boat-boarding-step-x2694):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Recife Waterfront — Voxel Fragment</title>
<style>
:root {
color-scheme: light;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9e7e8;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 24px;
left: 24px;
z-index: 5;
width: min(340px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 16px;
color: #153d47;
background: rgba(245, 251, 246, 0.82);
box-shadow: 0 16px 40px rgba(30, 70, 75, 0.14);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 6px;
color: #e05c42;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 4vw, 34px);
line-height: 1;
letter-spacing: -0.04em;
}
.subtitle {
margin: 9px 0 0;
color: #4c6c70;
font-size: 13px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 22px;
bottom: 20px;
z-index: 5;
display: flex;
align-items: center;
gap: 10px;
color: #244f56;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
.hint {
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.48);
border-radius: 999px;
background: rgba(245, 251, 246, 0.76);
box-shadow: 0 8px 24px rgba(30, 70, 75, 0.12);
backdrop-filter: blur(10px);
}
button {
padding: 10px 14px;
border: 0;
border-radius: 999px;
color: #f8fff9;
background: #173f48;
box-shadow: 0 8px 22px rgba(23, 63, 72, 0.2);
font: inherit;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: #e05c42;
}
.vignette {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
background: radial-gradient(
circle at 50% 45%,
transparent 48%,
rgba(30, 70, 75, 0.09) 100%
);
}
@media (max-width: 600px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 16px;
}
.subtitle {
display: none;
}
.controls {
right: 14px;
bottom: 14px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
aria-label="Interactive voxel scene of the Recife waterfront with a railing, small boat, and boarding step"
></canvas>
<header class="title-card">
<div class="eyebrow">Brasil · Pernambuco</div>
<h1>Recife Waterfront</h1>
<p class="subtitle">
A small voxel fragment of the quay: warm stone, painted railings,
tidal blue, and a little working boat.
</p>
</header>
<div class="controls">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</div>
<div class="vignette"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const resetButton = document.querySelector("#reset");
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.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9e7e8);
scene.fog = new THREE.Fog(0xc9e7e8, 17, 31);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(-0.45, 0.65, 0.15);
const defaultView = {
yaw: 0.75,
pitch: 0.48,
radius: 14.8
};
let currentYaw = defaultView.yaw;
let currentPitch = defaultView.pitch;
let currentRadius = defaultView.radius;
let desiredYaw = defaultView.yaw;
let desiredPitch = defaultView.pitch;
let desiredRadius = defaultView.radius;
const clock = new THREE.Clock();
let seed = 82417;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function material(color, roughness = 0.82, metalness = 0.02) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
});
}
const materials = {
navy: material(0x173f48),
darkNavy: material(0x102f37),
teal: material(0x26727a),
paleTeal: material(0x75b6ad),
coral: material(0xe05c42),
brick: material(0xa94437),
yellow: material(0xf4c44f),
cream: material(0xf2e7cb),
sand: material(0xd4b985),
stone: material(0xcab88f),
stoneDark: material(0xa89270),
white: material(0xfff9e9),
window: material(0x244e5b, 0.32, 0.15),
wood: material(0x93613c),
leaf: material(0x4e8c5a),
leafLight: material(0x76aa65),
rope: material(0xc6aa73)
};
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
// Lighting
const hemisphere = new THREE.HemisphereLight(0xe8fbff, 0x9a7858, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1c9, 3.2);
sun.position.set(-5, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 32;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8bcbd2, 0.75);
fill.position.set(9, 5, -6);
scene.add(fill);
// Water: a solid voxel grid with gently animated surface blocks.
const waterPalette = [
0x4e9fa8,
0x5aaab0,
0x438f9b,
0x65b6b6,
0x3f8795,
0x72bfba
].map((color) => material(color, 0.46, 0.08));
box(
18.3,
0.34,
13.2,
material(0x286c78, 0.58, 0.08),
0,
-0.38,
0,
scene,
false,
true
);
const waterTiles = [];
const tilePitch = 0.82;
const tileSize = 0.79;
for (let x = 0; x < 21; x++) {
for (let z = 0; z < 15; z++) {
const px = (x - 10) * tilePitch;
const pz = (z - 7) * tilePitch;
const baseY = -0.08 + random() * 0.035;
const tile = box(
tileSize,
0.19 + random() * 0.035,
tileSize,
waterPalette[Math.floor(random() * waterPalette.length)],
px,
baseY,
pz,
scene,
false,
true
);
waterTiles.push({
mesh: tile,
baseY,
phase: random() * Math.PI * 2
});
}
}
// Small square highlights on the water.
const glints = [];
const glintMaterial = material(0xbde4d5, 0.4, 0.05);
for (let i = 0; i < 30; i++) {
const px = -7.5 + random() * 15.5;
const pz = -5.5 + random() * 11;
const size = 0.055 + random() * 0.085;
const glint = box(
size,
0.025,
size * (1 + random()),
glintMaterial,
px,
0.04,
pz,
scene,
false,
false
);
glints.push({
mesh: glint,
phase: random() * Math.PI * 2
});
}
// Quay foundation and individual paving voxels.
box(
4.2,
1.05,
9.8,
materials.stoneDark,
-5.65,
0.43,
0.15,
scene
);
const paverMaterials = [
materials.cream,
materials.sand,
materials.stone,
material(0xdecba0),
material(0xc7b182)
];
for (let col = 0; col < 6; col++) {
for (let row = 0; row < 14; row++) {
const px = -7.35 + col * 0.7;
const pz = -4.35 + row * 0.67;
const paver = box(
0.66,
0.13,
0.62,
paverMaterials[Math.floor(random() * paverMaterials.length)],
px,
0.99,
pz
);
paver.rotation.y = (random() - 0.5) * 0.018;
}
}
// Exposed stone courses on the quay wall.
for (let course = 0; course < 3; course++) {
for (let row = 0; row < 14; row++) {
box(
0.13,
0.25,
0.61,
course === 1 ? materials.stone : materials.stoneDark,
-3.51,
0.22 + course * 0.28,
-4.35 + row * 0.67
);
}
}
// Railing, with a deliberate gap for the boarding step.
const railX = -3.56;
const railPostZ = [-4.05, -3.05, -2.05, -1.05, 0.08, 2.0, 3.0, 4.05];
railPostZ.forEach((z) => {
box(0.13, 1.13, 0.13, materials.navy, railX, 1.61, z);
box(0.22, 0.09, 0.22, materials.yellow, railX, 1.12, z);
});
function railSection(z1, z2) {
const length = z2 - z1;
const center = (z1 + z2) * 0.5;
box(0.11, 0.11, length, materials.teal, railX, 2.12, center);
box(0.09, 0.09, length, materials.paleTeal, railX, 1.62, center);
}
railSection(-4.05, 0.08);
railSection(2.0, 4.05);
// Readable boarding step descending from the quay into the water.
const steps = [
{ x: -3.28, top: 1.01, width: 0.75 },
{ x: -2.55, top: 0.69, width: 0.70 },
{ x: -1.90, top: 0.37, width: 0.70 }
];
steps.forEach((step, index) => {
box(
step.width,
0.42,
1.28,
index === 0 ? materials.cream : materials.stone,
step.x,
step.top - 0.21,
1.02
);
// Bright nosing makes the step edges easy to read.
box(
0.09,
0.035,
1.25,
materials.yellow,
step.x + step.width * 0.5 - 0.05,
step.top + 0.025,
1.02,
scene,
false,
true
);
});
// Mooring bollard.
box(0.38, 0.13, 0.38, materials.navy, -3.25, 1.1, 2.13);
box(0.20, 0.35, 0.20, materials.navy, -3.25, 1.30, 2.13);
box(0.36, 0.12, 0.22, materials.navy, -3.25, 1.50, 2.13);
// A small pastel waterfront wall and its readable place sign.
box(3.4, 1.55, 0.48, materials.cream, -5.78, 1.82, -4.54);
box(3.55, 0.17, 0.62, materials.coral, -5.78, 2.65, -4.54);
box(0.12, 1.75, 0.64, materials.paleTeal, -7.42, 1.91, -4.54);
function createCanvasTexture(width, height, draw) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = width;
labelCanvas.height = height;
const context = labelCanvas.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function makeBoardingTexture() {
return createCanvasTexture(1024, 420, (ctx, width, height) => {
ctx.fillStyle = "#153f48";
ctx.fillRect(0, 0, width, height);
ctx.strokeStyle = "#f4c44f";
ctx.lineWidth = 18;
ctx.strokeRect(18, 18, width - 36, height - 36);
ctx.fillStyle = "#fff9e9";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.font = "900 112px Arial, sans-serif";
ctx.fillText("BOARDING", 66, 135);
ctx.fillText("STEP", 66, 275);
ctx.fillStyle = "#f4c44f";
ctx.beginPath();
ctx.moveTo(770, 210);
ctx.lineTo(930, 210);
ctx.lineTo(930, 135);
ctx.lineTo(985, 220);
ctx.lineTo(930, 305);
ctx.lineTo(930, 235);
ctx.lineTo(770, 235);
ctx.closePath();
ctx.fill();
});
}
function makeRecifeTexture() {
return createCanvasTexture(1024, 320, (ctx, width, height) => {
ctx.fillStyle = "#26727a";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "#fff9e9";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.font = "900 116px Arial, sans-serif";
ctx.fillText("RECIFE", 62, 118);
ctx.fillStyle = "#f4c44f";
ctx.font = "700 48px Arial, sans-serif";
ctx.fillText("PORTO · BRASIL", 66, 232);
ctx.strokeStyle = "#fff9e9";
ctx.lineWidth = 11;
ctx.beginPath();
for (let x = 620; x <= 955; x += 8) {
const y = 195 + Math.sin((x - 620) * 0.045) * 18;
if (x === 620) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
});
}
function addSign({
texture,
width,
height,
position,
rotationY = 0,
backingMaterial = materials.darkNavy
}) {
const group = new THREE.Group();
group.position.copy(position);
group.rotation.y = rotationY;
box(
width,
height,
0.10,
backingMaterial,
0,
0,
0,
group
);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(width - 0.06, height - 0.06),
new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
toneMapped: false
})
);
face.position.z = 0.056;
group.add(face);
scene.add(group);
return group;
}
addSign({
texture: makeBoardingTexture(),
width: 2.20,
height: 0.90,
position: new THREE.Vector3(-3.61, 2.40, 0.27),
rotationY: Math.PI / 3
});
box(0.12, 1.48, 0.12, materials.navy, -3.65, 1.70, 0.27);
addSign({
texture: makeRecifeTexture(),
width: 2.55,
height: 0.80,
position: new THREE.Vector3(-5.70, 2.02, -4.27),
rotationY: 0
});
// Small voxel fishing boat.
const boat = new THREE.Group();
boat.position.set(-0.18, 0, 1.02);
boat.rotation.y = -0.055;
scene.add(boat);
const hullRows = [
{ z: -1.62, width: 0.74 },
{ z: -1.22, width: 1.30 },
{ z: -0.82, width: 1.68 },
{ z: -0.42, width: 1.88 },
{ z: -0.02, width: 1.90 },
{ z: 0.38, width: 1.80 },
{ z: 0.78, width: 1.56 },
{ z: 1.18, width: 1.24 },
{ z: 1.58, width: 0.76 }
];
hullRows.forEach((row, index) => {
const hullMaterial = index < 2 ? materials.brick : materials.coral;
box(
row.width,
0.48,
0.43,
hullMaterial,
0,
0.25,
row.z,
boat
);
// Raised rim around the dark interior.
box(
row.width * 0.94,
0.20,
0.42,
index === 8 ? materials.yellow : materials.coral,
0,
0.54,
row.z,
boat
);
box(
row.width * 0.73,
0.045,
0.34,
materials.teal,
0,
0.655,
row.z,
boat,
false,
true
);
});
// Cabin and roof.
box(1.02, 0.64, 0.94, materials.white, 0, 0.98, -0.34, boat);
box(1.20, 0.13, 1.10, materials.teal, 0, 1.36, -0.34, boat);
// Windows.
box(0.035, 0.29, 0.56, materials.window, 0.525, 1.04, -0.34, boat);
box(0.035, 0.29, 0.56, materials.window, -0.525, 1.04, -0.34, boat);
box(0.68, 0.28, 0.035, materials.window, 0, 1.04, 0.145, boat);
// Roof detail and mast.
box(0.30, 0.10, 0.32, materials.yellow, 0, 1.47, -0.38, boat);
box(0.07, 0.92, 0.07, materials.wood, 0, 1.78, -0.64, boat);
box(0.42, 0.23, 0.035, materials.coral, 0.19, 2.08, -0.64, boat);
// Bench and bow fittings.
box(1.10, 0.12, 0.24, materials.wood, 0, 0.77, 0.73, boat);
box(0.18, 0.18, 0.18, materials.yellow, 0, 0.77, 1.43, boat);
// A voxel life ring on the near side of the cabin.
const ringCenter = new THREE.Vector3(0.88, 0.95, -0.31);
box(0.10, 0.34, 0.12, materials.coral, ringCenter.x, ringCenter.y + 0.14, ringCenter.z, boat);
box(0.10, 0.34, 0.12, materials.coral, ringCenter.x, ringCenter.y - 0.14, ringCenter.z, boat);
box(0.10, 0.12, 0.12, materials.coral, ringCenter.x, ringCenter.y, ringCenter.z + 0.14, boat);
box(0.10, 0.12, 0.12, materials.coral, ringCenter.x, ringCenter.y, ringCenter.z - 0.14, boat);
// Segmented, sagging mooring rope.
function beamBetween(start, end, thickness, mat, parent = scene) {
const direction = end.clone().sub(start);
const length = direction.length();
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const beam = box(
thickness,
thickness,
length,
mat,
midpoint.x,
midpoint.y,
midpoint.z,
parent,
false,
false
);
beam.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.normalize()
);
return beam;
}
const ropeStart = new THREE.Vector3(-0.12, 0.69, 2.42);
const ropeEnd = new THREE.Vector3(-3.25, 1.49, 2.13);
let previous = ropeStart.clone();
for (let i = 1; i <= 12; i++) {
const t = i / 12;
const point = ropeStart.clone().lerp(ropeEnd, t);
point.y -= Math.sin(Math.PI * t) * 0.22;
beamBetween(previous, point, 0.045, materials.rope);
previous = point;
}
// A modest voxel planter adds scale to the quay.
box(0.72, 0.44, 0.72, materials.coral, -6.65, 1.25, 2.65);
box(0.58, 0.10, 0.58, materials.wood, -6.65, 1.49, 2.65);
box(0.16, 0.64, 0.16, materials.wood, -6.65, 1.73, 2.65);
box(0.55, 0.44, 0.50, materials.leaf, -6.65, 2.12, 2.65);
box(0.38, 0.36, 0.38, materials.leafLight, -6.44, 2.27, 2.56);
box(0.35, 0.30, 0.34, materials.leaf, -6.84, 2.32, 2.75);
// Custom orbit controls implemented directly in this file.
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredYaw -= dx * 0.006;
desiredPitch = THREE.MathUtils.clamp(
desiredPitch + dy * 0.005,
0.20,
1.08
);
});
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();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
8.2,
21
);
},
{ passive: false }
);
function resetView() {
desiredYaw = defaultView.yaw;
desiredPitch = defaultView.pitch;
desiredRadius = defaultView.radius;
}
resetButton.addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
function updateCamera() {
currentYaw = THREE.MathUtils.lerp(currentYaw, desiredYaw, 0.11);
currentPitch = THREE.MathUtils.lerp(currentPitch, desiredPitch, 0.11);
currentRadius = THREE.MathUtils.lerp(
currentRadius,
desiredRadius,
0.10
);
const horizontal = Math.cos(currentPitch) * currentRadius;
camera.position.set(
target.x + Math.sin(currentYaw) * horizontal,
target.y + Math.sin(currentPitch) * currentRadius,
target.z + Math.cos(currentYaw) * horizontal
);
camera.lookAt(target);
}
function animate() {
const elapsed = clock.getElapsedTime();
waterTiles.forEach((tile) => {
tile.mesh.position.y =
tile.baseY + Math.sin(elapsed * 1.15 + tile.phase) * 0.025;
});
glints.forEach((glint) => {
glint.mesh.position.y =
0.04 + Math.sin(elapsed * 1.7 + glint.phase) * 0.012;
});
boat.position.y = Math.sin(elapsed * 0.85) * 0.018;
boat.rotation.z = Math.sin(elapsed * 0.72 + 0.4) * 0.008;
updateCamera();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```