Prompt specification
Build or customize the Three.js 3D scene "Beach vendor beside a Ponta Negra access point" 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: Beach vendor beside a Ponta Negra access point
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/beach-vendor-beside-a-ponta-negra-access-point-x2674
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Ponta Negra beach in Natal. Create a compact coastal vignette with an original vendor cart, beach access, and distant Morro do Careca silhouette. Keep the landmark background geographically suggestive rather than exact. Voxel style.
Working Three.js Starter (beach-vendor-beside-a-ponta-negra-access-point-x2674):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#b9dfe4" />
<title>Ponta Negra — Voxel Coastal Vignette</title>
<style>
:root {
color-scheme: light;
--ink: #163b46;
--paper: rgba(255, 250, 232, 0.9);
--accent: #df654e;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9dfe4;
}
body {
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.title-card {
position: absolute;
top: 22px;
left: 24px;
max-width: min(420px, calc(100vw - 48px));
padding: 17px 20px 16px;
background: var(--paper);
border: 1px solid rgba(22, 59, 70, 0.13);
border-left: 5px solid var(--accent);
box-shadow: 0 12px 35px rgba(22, 59, 70, 0.12);
backdrop-filter: blur(8px);
}
.eyebrow {
margin: 0 0 5px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
color: #56808a;
}
h1 {
margin: 0;
font-size: clamp(24px, 4vw, 38px);
line-height: 0.98;
letter-spacing: -0.045em;
text-transform: uppercase;
}
.subtitle {
margin: 8px 0 0;
font-size: 12px;
line-height: 1.45;
color: #51717a;
}
.landmark {
position: absolute;
top: 24px;
right: 24px;
padding: 10px 13px;
border: 1px solid rgba(22, 59, 70, 0.14);
background: rgba(255, 250, 232, 0.74);
color: #496b75;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-align: right;
text-transform: uppercase;
backdrop-filter: blur(6px);
}
.controls {
position: absolute;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
width: max-content;
max-width: calc(100vw - 28px);
padding: 10px 15px;
border: 1px solid rgba(22, 59, 70, 0.14);
background: rgba(255, 250, 232, 0.82);
box-shadow: 0 8px 25px rgba(22, 59, 70, 0.11);
color: #4e6d75;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.055em;
text-align: center;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.controls span {
margin: 0 7px;
color: #d45f4b;
}
.loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
background: #b9dfe4;
color: #24515c;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 0.45s ease, visibility 0.45s ease;
}
.loading.done {
opacity: 0;
visibility: hidden;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
padding: 13px 15px 12px;
}
.subtitle {
max-width: 240px;
}
.landmark {
display: none;
}
.controls {
bottom: 14px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div class="hud">
<section class="title-card">
<p class="eyebrow">Natal · Rio Grande do Norte</p>
<h1>Ponta Negra</h1>
<p class="subtitle">
A compact voxel coastal vignette with an original snack cart,
beach access, and a suggested silhouette of Morro do Careca.
</p>
</section>
<div class="landmark">
Morro do Careca<br />
suggested silhouette
</div>
<div class="controls">
Drag to orbit <span>•</span> Scroll to zoom <span>•</span>
Double-click to reset
</div>
</div>
<div class="loading" id="loading">Building the shoreline…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9dfe4);
scene.fog = new THREE.Fog(0xb9dfe4, 50, 115);
const camera = new THREE.PerspectiveCamera(
37,
innerWidth / innerHeight,
0.1,
180
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xe9fbff, 0x8f775c, 2.15);
scene.add(hemisphere);
const sunLight = new THREE.DirectionalLight(0xfff0ce, 3.0);
sunLight.position.set(-16, 30, 18);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -29;
sunLight.shadow.camera.right = 29;
sunLight.shadow.camera.top = 27;
sunLight.shadow.camera.bottom = -27;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 80;
sunLight.shadow.bias = -0.00035;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0x9bd6e2, 0.55);
fillLight.position.set(18, 12, -18);
scene.add(fillLight);
// -------------------------------------------------------------------------
// Helpers and palette
// -------------------------------------------------------------------------
const standardMaterial = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
...options
});
const M = {
base: standardMaterial(0x8c806c),
farLand: standardMaterial(0xa4ad8a),
sand: standardMaterial(0xe5bf78),
lightSand: standardMaterial(0xf0d397),
wetSand: standardMaterial(0xd2aa68),
dune: standardMaterial(0xdbb86f),
promenade: standardMaterial(0xd9ccb1),
promenadeLine: standardMaterial(0xc4b69d),
curb: standardMaterial(0xf0e6cf),
ocean: standardMaterial(0x287f9b, { roughness: 0.48 }),
shallow: standardMaterial(0x42b5bd, { roughness: 0.5 }),
waveLight: standardMaterial(0x84d4d1, { roughness: 0.58 }),
waveDark: standardMaterial(0x338fa7, { roughness: 0.6 }),
foam: standardMaterial(0xe7f4dd, { roughness: 0.75 }),
wood: standardMaterial(0x9b6844),
woodLight: standardMaterial(0xbc8555),
woodDark: standardMaterial(0x654838),
teal: standardMaterial(0x267b79),
tealLight: standardMaterial(0x58a5a0),
coral: standardMaterial(0xdf654e),
yellow: standardMaterial(0xf0c85b),
cream: standardMaterial(0xfff0cf),
dark: standardMaterial(0x29444a),
skin: standardMaterial(0xc78a60),
skinLight: standardMaterial(0xe1aa7f),
hair: standardMaterial(0x3b302d),
green: standardMaterial(0x587f55),
greenLight: standardMaterial(0x7fa365),
morro: standardMaterial(0x688796),
buildingA: standardMaterial(0xd7b6a0),
buildingB: standardMaterial(0xc5c1ad),
buildingC: standardMaterial(0xb7c2bb),
window: standardMaterial(0x70949a),
white: new THREE.MeshBasicMaterial({ color: 0xf8fbf1 }),
sun: new THREE.MeshBasicMaterial({ color: 0xffd36d })
};
function box(
parent,
size,
position,
material,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function seededRandom(seed) {
let value = seed % 2147483647;
return () => {
value = (value * 16807) % 2147483647;
return (value - 1) / 2147483646;
};
}
const random = seededRandom(20240517);
// -------------------------------------------------------------------------
// Diorama base, ocean, promenade, and beach
// -------------------------------------------------------------------------
box(scene, [40, 1.1, 33], [0, -1, -1], M.base);
box(scene, [70, 0.8, 19], [0, -0.08, -25], M.farLand, false, true);
box(scene, [40, 1, 19], [0, -0.05, -7.3], M.sand);
box(scene, [40, 0.3, 8.8], [0, 0.36, 0.1], M.lightSand);
box(scene, [40, 0.18, 1.15], [0, 0.48, 3.93], M.wetSand);
box(scene, [40, 0.48, 5.2], [0, 0.69, -7], M.promenade);
box(scene, [40, 0.65, 11], [0, -0.06, 9.9], M.ocean);
box(scene, [40, 0.11, 2.25], [0, 0.275, 5.05], M.shallow);
// Promenade paving seams.
for (let x = -18; x <= 18; x += 3) {
box(
scene,
[0.035, 0.025, 4.8],
[x, 0.946, -7],
M.promenadeLine,
false,
true
);
}
// Low curb, leaving a gap for the beach access.
box(scene, [16.5, 0.28, 0.3], [-11.75, 0.77, -4.37], M.curb);
box(scene, [19, 0.28, 0.3], [10.5, 0.77, -4.37], M.curb);
// Voxel foam along the shoreline.
for (let i = 0; i < 27; i++) {
const x = -19 + i * 1.46 + (random() - 0.5) * 0.55;
const foam = box(
scene,
[0.65 + random() * 1.05, 0.045, 0.13 + random() * 0.12],
[x, 0.365, 4.52 + (random() - 0.5) * 0.16],
i % 4 === 0 ? M.shallow : M.foam,
false,
true
);
foam.rotation.y = (random() - 0.5) * 0.08;
}
// -------------------------------------------------------------------------
// Ocean wave tiles
// -------------------------------------------------------------------------
const waves = [];
for (let i = 0; i < 44; i++) {
const material = i % 5 === 0 ? M.foam : i % 2 ? M.waveLight : M.waveDark;
const wave = box(
scene,
[0.8 + random() * 2.2, 0.035, 0.08 + random() * 0.16],
[
-18.5 + random() * 37,
0.34 + random() * 0.035,
5.8 + random() * 8.2
],
material,
false,
true
);
wave.rotation.y = (random() - 0.5) * 0.1;
waves.push({
mesh: wave,
baseX: wave.position.x,
baseZ: wave.position.z,
phase: random() * Math.PI * 2,
speed: 0.35 + random() * 0.45
});
}
// -------------------------------------------------------------------------
// Distant suggested Morro do Careca silhouette
// -------------------------------------------------------------------------
const moundBlocks = [];
const moundPosition = new THREE.Vector3(-12, 0, -19.5);
for (let x = -10; x <= 10; x++) {
for (let z = -3; z <= 3; z++) {
const normalizedX = (x + 1.5) / 11.5;
const profile = Math.max(0, 1 - normalizedX * normalizedX);
const crossSection = Math.max(0, 1 - Math.pow(z / 3.55, 2));
const height = Math.floor(
Math.pow(profile, 1.18) * 9.7 * crossSection
);
for (let layer = 0; layer < height; layer++) {
moundBlocks.push({
x: x * 1.02,
y: 0.48 + layer * 0.79 + 0.395,
z: z * 1.02
});
}
}
}
const mound = new THREE.InstancedMesh(
new THREE.BoxGeometry(1.02, 0.79, 1.02),
M.morro,
moundBlocks.length
);
const moundMatrix = new THREE.Matrix4();
moundBlocks.forEach((block, index) => {
moundMatrix.makeTranslation(
block.x,
block.y,
block.z
);
mound.setMatrixAt(index, moundMatrix);
});
mound.position.copy(moundPosition);
mound.castShadow = true;
mound.receiveShadow = true;
mound.instanceMatrix.needsUpdate = true;
scene.add(mound);
// Low vegetation on the distant dune.
for (let i = 0; i < 24; i++) {
const x = -19 + random() * 13;
const z = -15.5 - random() * 4;
box(
scene,
[0.3 + random() * 0.55, 0.18 + random() * 0.4, 0.3],
[x, 0.54, z],
i % 2 ? M.green : M.greenLight
);
}
// -------------------------------------------------------------------------
// Vague distant skyline, deliberately less specific than the landmark
// -------------------------------------------------------------------------
const buildingMaterials = [M.buildingA, M.buildingB, M.buildingC];
const buildingXs = [-3.2, -1.4, 0.5, 2.3, 4.2, 6.0, 8.1, 10.0, 12.2, 14.1];
buildingXs.forEach((x, index) => {
const width = 1.15 + random() * 0.65;
const depth = 1.3 + random() * 0.7;
const height = 2.2 + random() * 4.7;
const z = -13.1 + (random() - 0.5) * 1.2;
box(
scene,
[width, height, depth],
[x, 0.45 + height / 2, z],
buildingMaterials[index % buildingMaterials.length]
);
box(
scene,
[width * 0.72, 0.18, depth * 0.75],
[x, 0.55 + height, z],
M.promenadeLine
);
const floors = Math.max(1, Math.floor(height / 1.05));
for (let floor = 0; floor < floors; floor++) {
box(
scene,
[width * 0.2, 0.24, 0.035],
[x - width * 0.23, 1.05 + floor * 0.9, z + depth / 2 + 0.025],
M.window,
false,
false
);
box(
scene,
[width * 0.2, 0.24, 0.035],
[x + width * 0.23, 1.05 + floor * 0.9, z + depth / 2 + 0.025],
M.window,
false,
false
);
}
});
// -------------------------------------------------------------------------
// Low dunes and shrubs behind the promenade
// -------------------------------------------------------------------------
const duneClusters = [
[-11, -10.2, 4.8, 1.6],
[-6.5, -10.8, 5.2, 1.2],
[4.8, -10.3, 4.0, 1.0],
[11.8, -10.1, 5.1, 1.4]
];
duneClusters.forEach(([x, z, width, height]) => {
box(scene, [width, height, 2.2], [x, 0.45 + height / 2, z], M.dune);
box(
scene,
[width * 0.68, 0.45, 1.65],
[x - 0.25, 0.45 + height + 0.225, z],
M.lightSand
);
});
for (let i = 0; i < 35; i++) {
const x = -17 + random() * 34;
const z = -10.6 - random() * 4.8;
if (x > -16 && x < -7 && z < -15) continue;
box(
scene,
[0.25 + random() * 0.5, 0.25 + random() * 0.55, 0.25],
[x, 0.58, z],
i % 3 ? M.green : M.greenLight
);
}
// -------------------------------------------------------------------------
// Beach access: wooden stairs, inclined ramp, rails, and wayfinding sign
// -------------------------------------------------------------------------
const access = new THREE.Group();
scene.add(access);
for (let i = 0; i < 6; i++) {
const top = 0.93 - i * 0.07;
const bottom = 0.43;
box(
access,
[3.45, top - bottom, 0.39],
[-1.55, (top + bottom) / 2, -4.18 + i * 0.36],
i % 2 ? M.wood : M.woodLight
);
}
// Inset boardwalk across the promenade marks the access route.
for (let i = 0; i < 10; i++) {
box(
access,
[3.4, 0.11, 0.43],
[-1.55, 0.965, -9.35 + i * 0.48],
i % 2 ? M.wood : M.woodLight
);
}
// Sloped ramp alongside the stairs.
const rampAngle = Math.atan2(0.44, 2.8);
const ramp = box(
access,
[1.25, 0.14, 2.87],
[1.05, 0.76, -2.8],
M.woodLight
);
ramp.rotation.x = rampAngle;
for (let i = 0; i < 6; i++) {
const t = i / 5;
const z = -4.12 + t * 2.8;
const y = 0.98 - t * 0.44;
box(
access,
[0.11, 0.95, 0.11],
[0.37, y + 0.42, z],
M.woodDark
);
box(
access,
[0.11, 0.95, 0.11],
[1.73, y + 0.42, z],
M.woodDark
);
const rail = box(
access,
[0.09, 0.09, 2.9],
[0.37, y + 0.86, z],
M.woodDark
);
rail.rotation.x = rampAngle;
const otherRail = box(
access,
[0.09, 0.09, 2.9],
[1.73, y + 0.86, z],
M.woodDark
);
otherRail.rotation.x = rampAngle;
}
// Voxel wayfinding sign.
box(access, [0.15, 2.0, 0.15], [-3.75, 1.93, -7.4], M.woodDark);
box(access, [1.55, 0.75, 0.16], [-3.75, 2.78, -7.4], M.teal);
// White pixel arrow.
box(access, [0.68, 0.12, 0.05], [-3.48, 2.88, -7.3], M.cream, false, false);
box(access, [0.12, 0.12, 0.05], [-3.15, 2.88, -7.3], M.cream, false, false);
box(access, [0.12, 0.35, 0.05], [-3.02, 2.76, -7.3], M.cream, false, false);
box(access, [0.12, 0.35, 0.05], [-3.02, 2.56, -7.3], M.cream, false, false);
box(access, [0.12, 0.12, 0.05], [-3.15, 2.44, -7.3], M.cream, false, false);
// -------------------------------------------------------------------------
// Original vendor cart: "MAR & SOL", built entirely from voxel-like boxes
// -------------------------------------------------------------------------
const cart = new THREE.Group();
cart.position.set(8.1, 0.94, -6.55);
cart.rotation.y = -0.12;
scene.add(cart);
// Chassis and body.
box(cart, [3.7, 0.18, 1.45], [0, 0.72, 0], M.woodDark);
box(cart, [3.55, 0.95, 1.45], [0, 1.28, 0], M.teal);
box(cart, [4.05, 0.18, 1.75], [0, 1.83, 0], M.woodLight);
box(cart, [3.55, 0.82, 0.14], [0, 2.4, -0.7], M.tealLight);
// Lower coral panels.
for (let i = -1; i <= 1; i++) {
box(cart, [0.93, 0.58, 0.06], [i * 1.02, 1.28, 0.75], M.coral);
}
// Wheels.
for (const x of [-1.25, 1.25]) {
for (const z of [-0.66, 0.66]) {
box(cart, [0.46, 0.7, 0.24], [x, 0.48, z], M.dark);
box(cart, [0.18, 0.18, 0.26], [x, 0.48, z], M.woodLight);
}
}
// Awning posts.
for (const x of [-1.82, 1.82]) {
for (const z of [-0.75, 0.75]) {
box(cart, [0.12, 1.45, 0.12], [x, 2.55, z], M.woodDark);
}
}
// Striped flat canopy and front fringe.
for (let i = 0; i < 10; i++) {
const x = -2.16 + i * 0.48;
const material = i % 2 ? M.cream : M.coral;
box(cart, [0.48, 0.14, 2.05], [x, 3.28, 0], material);
box(cart, [0.48, 0.28, 0.12], [x, 3.12, 1.03], material);
}
// Sign and support.
box(cart, [0.12, 0.65, 0.12], [0, 3.57, 0], M.woodDark);
box(cart, [1.7, 0.76, 0.18], [0, 3.91, 0], M.yellow);
// Pixel sun on the sign.
box(cart, [0.25, 0.25, 0.04], [-0.42, 4.03, 0.11], M.coral, false, false);
box(cart, [0.25, 0.25, 0.04], [-0.17, 4.03, 0.11], M.coral, false, false);
box(cart, [0.25, 0.25, 0.04], [-0.42, 3.78, 0.11], M.coral, false, false);
box(cart, [0.25, 0.25, 0.04], [-0.17, 3.78, 0.11], M.coral, false, false);
box(cart, [0.25, 0.25, 0.04], [-0.295, 3.905, 0.11], M.yellow, false, false);
// Pixel wave.
box(cart, [0.35, 0.1, 0.04], [-0.42, 3.62, 0.11], M.teal, false, false);
box(cart, [0.35, 0.1, 0.04], [-0.08, 3.62, 0.11], M.teal, false, false);
box(cart, [0.18, 0.1, 0.04], [0.15, 3.69, 0.11], M.teal, false, false);
// Small produce crate.
box(cart, [0.9, 0.58, 0.86], [2.28, 0.48, 0], M.wood);
box(cart, [0.94, 0.1, 0.9], [2.28, 0.78, 0], M.woodLight);
const fruitMaterials = [M.coral, M.yellow, M.greenLight];
for (let i = 0; i < 6; i++) {
box(
cart,
[0.2, 0.2, 0.2],
[
2.02 + (i % 3) * 0.25,
0.92,
-0.18 + Math.floor(i / 3) * 0.34
],
fruitMaterials[i % fruitMaterials.length]
);
}
// Counter objects.
box(cart, [0.42, 0.28, 0.42], [-1.1, 2.06, 0.12], M.yellow);
box(cart, [0.34, 0.34, 0.34], [-0.48, 2.08, -0.12], M.coral);
box(cart, [0.4, 0.12, 0.4], [0.08, 2.0, 0.08], M.cream);
// -------------------------------------------------------------------------
// Palm trees made from stacked blocks
// -------------------------------------------------------------------------
function createPalm(x, z, scale = 1) {
const palm = new THREE.Group();
palm.position.set(x, 0.94, z);
palm.scale.setScalar(scale);
scene.add(palm);
for (let i = 0; i < 6; i++) {
box(
palm,
[0.34, 0.72, 0.34],
[i * 0.075, 0.34 + i * 0.61, 0],
i % 2 ? M.wood : M.woodLight
);
}
const topY = 3.78;
const topX = 0.375;
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const leaf = box(
palm,
[2.65, 0.2, 0.48],
[
topX + Math.cos(angle) * 1.03,
topY + Math.sin(i * 1.7) * 0.08,
Math.sin(angle) * 1.03
],
i % 2 ? M.green : M.greenLight
);
leaf.rotation.y = -angle;
leaf.rotation.z = (i % 2 ? 1 : -1) * 0.08;
}
box(palm, [0.28, 0.28, 0.28], [topX - 0.24, topY - 0.18, 0], M.woodDark);
box(palm, [0.28, 0.28, 0.28], [topX + 0.24, topY - 0.18, 0], M.woodDark);
}
createPalm(-14.4, -8.2, 1.12);
createPalm(15.8, -8.1, 1.0);
createPalm(16.7, -12.4, 0.78);
// -------------------------------------------------------------------------
// Beach umbrellas
// -------------------------------------------------------------------------
function createUmbrella(x, z, lowerColor, upperColor) {
const umbrella = new THREE.Group();
umbrella.position.set(x, 0.52, z);
scene.add(umbrella);
box(umbrella, [0.12, 2.65, 0.12], [0, 1.32, 0], M.woodDark);
box(umbrella, [0.46, 0.12, 0.46], [0, 0.06, 0], M.sand);
box(umbrella, [3.0, 0.24, 3.0], [0, 2.6, 0], lowerColor);
box(umbrella, [2.05, 0.24, 2.05], [0, 2.84, 0], upperColor);
box(umbrella, [1.05, 0.25, 1.05], [0, 3.08, 0], lowerColor);
box(umbrella, [0.18, 0.3, 0.18], [0, 3.31, 0], M.yellow);
// Four hanging edge blocks.
box(umbrella, [0.38, 0.28, 0.13], [0, 2.43, 1.48], upperColor);
box(umbrella, [0.38, 0.28, 0.13], [0, 2.43, -1.48], upperColor);
box(umbrella, [0.13, 0.28, 0.38], [1.48, 2.43, 0], upperColor);
box(umbrella, [0.13, 0.28, 0.38], [-1.48, 2.43, 0], upperColor);
}
createUmbrella(-8.1, 0.1, M.coral, M.cream);
createUmbrella(-5.9, 1.6, M.teal, M.yellow);
createUmbrella(11.6, -0.5, M.yellow, M.coral);
// -------------------------------------------------------------------------
// Beach towels, chairs, and voxel visitors
// -------------------------------------------------------------------------
box(scene, [2.4, 0.055, 1.1], [-7.4, 0.535, 1.65], M.teal);
box(scene, [2.4, 0.06, 0.2], [-7.4, 0.57, 1.65], M.cream, false, true);
box(scene, [2.2, 0.055, 1.05], [12.1, 0.535, 1.1], M.coral);
box(scene, [2.2, 0.06, 0.18], [12.1, 0.57, 1.1], M.yellow, false, true);
function createPerson(x, z, shirtColor, skinColor, rotation = 0, scale = 1) {
const person = new THREE.Group();
person.position.set(x, 0.52, z);
person.rotation.y = rotation;
person.scale.setScalar(scale);
scene.add(person);
box(person, [0.22, 0.62, 0.25], [-0.18, 0.31, 0], M.teal);
box(person, [0.22, 0.62, 0.25], [0.18, 0.31, 0], M.teal);
box(person, [0.6, 0.72, 0.34], [0, 0.96, 0], shirtColor);
box(person, [0.19, 0.66, 0.22], [-0.4, 0.95, 0], skinColor);
box(person, [0.19, 0.66, 0.22], [0.4, 0.95, 0], skinColor);
box(person, [0.42, 0.42, 0.4], [0, 1.56, 0], skinColor);
box(person, [0.44, 0.18, 0.42], [0, 1.76, 0], M.hair);
box(person, [0.62, 0.09, 0.56], [0, 1.87, 0], M.cream);
box(person, [0.34, 0.2, 0.34], [0, 1.78, 0], M.cream);
return person;
}
createPerson(-6.4, 0.2, M.coral, M.skinLight, 0.4);
createPerson(-5.7, 0.55, M.teal, M.skin, -0.7, 0.94);
createPerson(-9.0, 1.95, M.yellow, M.skinLight, 1.2, 0.78);
createPerson(3.8, 2.5, M.tealLight, M.skin, -0.25, 0.96);
createPerson(4.45, 2.2, M.coral, M.skinLight, 0.25, 0.9);
createPerson(12.8, 0.25, M.yellow, M.skin, -1.0, 0.82);
createPerson(-1.8, -1.1, M.coral, M.skinLight, 0.15, 0.95);
// Simple beach chair.
const chair = new THREE.Group();
chair.position.set(9.8, 0.52, 1.7);
chair.rotation.y = -0.55;
scene.add(chair);
box(chair, [0.85, 0.12, 0.8], [0, 0.48, 0], M.teal);
const chairBack = box(
chair,
[0.85, 0.85, 0.12],
[0, 0.86, -0.34],
M.teal
);
chairBack.rotation.x = -0.18;
for (const x of [-0.32, 0.32]) {
for (const z of [-0.27, 0.27]) {
box(chair, [0.09, 0.48, 0.09], [x, 0.24, z], M.woodDark);
}
}
// -------------------------------------------------------------------------
// Pixel sun and cubic clouds
// -------------------------------------------------------------------------
const sun = new THREE.Group();
sun.position.set(-21, 19, -31);
scene.add(sun);
box(sun, [3.1, 3.1, 0.55], [0, 0, 0], M.sun, false, false);
box(sun, [2.1, 4.2, 0.55], [0, 0, 0], M.sun, false, false);
box(sun, [4.2, 2.1, 0.55], [0, 0, 0], M.sun, false, false);
const clouds = [];
function createCloud(x, y, z, scale = 1) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
box(cloud, [3.3, 1.0, 1.1], [0, 0, 0], M.white, false, false);
box(cloud, [1.6, 1.5, 1.2], [-1.0, 0.35, 0], M.white, false, false);
box(cloud, [1.8, 1.8, 1.25], [0.65, 0.48, 0], M.white, false, false);
box(cloud, [2.4, 0.8, 1.0], [2.0, -0.05, 0], M.white, false, false);
clouds.push({ group: cloud, speed: 0.08 + random() * 0.08 });
}
createCloud(-12, 15.2, -28, 1.1);
createCloud(10, 17.2, -35, 1.35);
createCloud(21, 12.7, -29, 0.8);
// -------------------------------------------------------------------------
// Direct camera controls: orbit, wheel zoom, pinch zoom, keyboard, reset
// -------------------------------------------------------------------------
const focus = new THREE.Vector3(-0.8, 1.0, -2.7);
const controlState = {
yaw: 0.72,
targetYaw: 0.72,
pitch: 0.59,
targetPitch: 0.59,
radius: innerWidth < 700 ? 68 : 40,
targetRadius: innerWidth < 700 ? 68 : 40
};
const canvas = renderer.domElement;
const pointers = new Map();
let lastPointer = null;
let lastPinchDistance = 0;
function updatePointerMap(event) {
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
}
canvas.addEventListener("pointerdown", (event) => {
updatePointerMap(event);
canvas.setPointerCapture(event.pointerId);
if (pointers.size === 1) {
lastPointer = { x: event.clientX, y: event.clientY };
} else if (pointers.size === 2) {
const points = [...pointers.values()];
lastPinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
updatePointerMap(event);
if (pointers.size === 1 && lastPointer) {
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
controlState.targetYaw -= dx * 0.006;
controlState.targetPitch = THREE.MathUtils.clamp(
controlState.targetPitch + dy * 0.004,
0.25,
1.18
);
lastPointer = { x: event.clientX, y: event.clientY };
} else if (pointers.size === 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (lastPinchDistance > 0) {
controlState.targetRadius = THREE.MathUtils.clamp(
controlState.targetRadius *
(lastPinchDistance / Math.max(distance, 1)),
22,
82
);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = 0;
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
lastPointer = { x: remaining.x, y: remaining.y };
} else {
lastPointer = null;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controlState.targetRadius = THREE.MathUtils.clamp(
controlState.targetRadius * Math.exp(event.deltaY * 0.001),
22,
82
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
controlState.targetYaw = 0.72;
controlState.targetPitch = 0.59;
controlState.targetRadius = innerWidth < 700 ? 68 : 40;
});
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") controlState.targetYaw -= 0.12;
if (key === "arrowright") controlState.targetYaw += 0.12;
if (key === "arrowup") {
controlState.targetPitch = THREE.MathUtils.clamp(
controlState.targetPitch + 0.08,
0.25,
1.18
);
}
if (key === "arrowdown") {
controlState.targetPitch = THREE.MathUtils.clamp(
controlState.targetPitch - 0.08,
0.25,
1.18
);
}
if (key === "+" || key === "=") {
controlState.targetRadius = Math.max(22, controlState.targetRadius - 3);
}
if (key === "-") {
controlState.targetRadius = Math.min(82, controlState.targetRadius + 3);
}
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const smoothing = 1 - Math.exp(-8 * delta);
controlState.yaw = THREE.MathUtils.lerp(
controlState.yaw,
controlState.targetYaw,
smoothing
);
controlState.pitch = THREE.MathUtils.lerp(
controlState.pitch,
controlState.targetPitch,
smoothing
);
controlState.radius = THREE.MathUtils.lerp(
controlState.radius,
controlState.targetRadius,
smoothing
);
const horizontalRadius =
controlState.radius * Math.cos(controlState.pitch);
camera.position.set(
focus.x + Math.sin(controlState.yaw) * horizontalRadius,
focus.y + Math.sin(controlState.pitch) * controlState.radius,
focus.z + Math.cos(controlState.yaw) * horizontalRadius
);
camera.lookAt(focus);
if (!reducedMotion) {
waves.forEach((wave) => {
wave.mesh.position.x =
wave.baseX + Math.sin(elapsed * wave.speed + wave.phase) * 0.32;
wave.mesh.position.y =
0.34 + Math.sin(elapsed * wave.speed * 1.7 + wave.phase) * 0.018;
});
clouds.forEach((cloud, index) => {
cloud.group.position.x =
cloud.group.position.x + cloud.speed * delta;
if (cloud.group.position.x > 31) {
cloud.group.position.x = -31;
}
});
}
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
document.getElementById("loading").classList.add("done");
}
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```