Prompt specification
Build or customize the Three.js 3D scene "Craft stall beside an Olinda viewpoint" 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: Craft stall beside an Olinda viewpoint
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/craft-stall-beside-an-olinda-viewpoint-x2678
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Alto da Sé in Olinda. Create a compact hilltop vignette with a small original craft stall, shaded seating, and a framed distant view. Keep public access open along the viewing edge. Voxel style.
Working Three.js Starter (craft-stall-beside-an-olinda-viewpoint-x2678):
```html
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#cde9df">
<title>Alto da Sé — Olinda</title>
<style>
:root {
--ink: #24463f;
--paper: rgba(255, 248, 226, 0.9);
--accent: #d96850;
--line: rgba(36, 70, 63, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cde9df;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
background:
radial-gradient(circle at 72% 18%, rgba(255, 247, 204, 0.8), transparent 25%),
linear-gradient(180deg, #d7efe5 0%, #b7d9d1 100%);
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background: radial-gradient(
ellipse at center,
transparent 48%,
rgba(33, 67, 60, 0.08) 100%
);
}
.placard {
position: fixed;
top: clamp(18px, 3vw, 34px);
left: clamp(18px, 3vw, 38px);
max-width: min(390px, calc(100vw - 36px));
padding: 18px 21px 17px;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 18px;
background: var(--paper);
box-shadow:
0 18px 50px rgba(35, 69, 60, 0.13),
inset 0 1px 0 rgba(255, 255, 255, 0.72);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: #b44f3d;
font-size: 0.7rem;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(1.65rem, 4vw, 2.75rem);
font-weight: 760;
line-height: 0.98;
letter-spacing: -0.045em;
}
.placard p {
margin: 10px 0 0;
color: rgba(36, 70, 63, 0.73);
font-size: 0.88rem;
line-height: 1.45;
}
.tools {
position: fixed;
top: clamp(18px, 3vw, 34px);
right: clamp(18px, 3vw, 38px);
display: flex;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 13px;
padding: 11px 14px;
background: rgba(255, 248, 226, 0.9);
color: var(--ink);
font: inherit;
font-size: 0.78rem;
font-weight: 750;
cursor: pointer;
box-shadow: 0 8px 28px rgba(35, 69, 60, 0.1);
backdrop-filter: blur(10px);
transition: transform 160ms ease, background 160ms ease;
}
button:hover {
transform: translateY(-2px);
background: #fff9e9;
}
button:focus-visible {
outline: 3px solid rgba(217, 104, 80, 0.36);
outline-offset: 3px;
}
.hint {
position: fixed;
left: 50%;
bottom: clamp(16px, 3vw, 28px);
transform: translateX(-50%);
max-width: calc(100vw - 30px);
padding: 10px 15px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 999px;
background: rgba(255, 248, 226, 0.78);
color: rgba(36, 70, 63, 0.78);
font-size: 0.73rem;
font-weight: 650;
text-align: center;
white-space: nowrap;
box-shadow: 0 8px 28px rgba(35, 69, 60, 0.09);
backdrop-filter: blur(10px);
pointer-events: none;
}
.loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #cde9df;
color: var(--ink);
font-weight: 750;
letter-spacing: 0.04em;
transition: opacity 500ms ease, visibility 500ms ease;
}
.loading.hidden {
opacity: 0;
visibility: hidden;
}
@media (max-width: 640px) {
.placard {
padding: 14px 16px;
border-radius: 15px;
}
.placard p { display: none; }
.tools { top: auto; bottom: 66px; }
.hint { font-size: 0.66rem; }
}
</style>
</head>
<body>
<main id="stage" aria-label=" Diorama interativo do Alto da Sé, em Olinda"></main>
<div class="vignette"></div>
<header class="placard">
<div class="eyebrow">PERNAMBUCO · BRASIL</div>
<h1>Alto da Sé</h1>
<p>Um mirante voxel entre a catedral, a arte local e o horizonte de Olinda.</p>
</header>
<nav class="tools" aria-label="Controles da cena">
<button id="reset" type="button" title="Recentrar a câmera">Recentrar</button>
<button id="viewpoint" type="button" title="Ver o mirante de frente">Vista do mirante</button>
</nav>
<div class="hint">Arraste para girar · Role para aproximar · Duplo clique para recentrar</div>
<div class="loading" id="loading">Construindo o mirante…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute(
"aria-label",
"Cena tridimensional voxel do Alto da Sé em Olinda"
);
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcde9df);
scene.fog = new THREE.Fog(0xcde9df, 24, 48);
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, 0.1, 100);
const target = new THREE.Vector3(0, 1.55, -0.75);
const orbit = {
azimuth: 0.40,
elevation: 0.64,
zoom: 1,
dragging: false,
pointerX: 0,
pointerY: 0
};
function updateCamera() {
const radius = 24;
const horizontal = Math.cos(orbit.elevation) * radius;
const x = target.x + Math.sin(orbit.azimuth) * horizontal;
const y = target.y + Math.sin(orbit.elevation) * radius;
const z = target.z + Math.cos(orbit.azimuth) * horizontal;
camera.position.set(x, y, z);
camera.lookAt(target);
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(15.5, 22.5 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// Soft, warm light with a single large shadow source.
scene.add(new THREE.HemisphereLight(0xfff7dc, 0x789487, 2.15));
const sun = new THREE.DirectionalLight(0xfff0c8, 3.2);
sun.position.set(-9, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -16;
sun.shadow.camera.right = 16;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 42;
sun.shadow.bias = -0.00045;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb6ddeb, 0.65);
fill.position.set(12, 7, -10);
scene.add(fill);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color, options = {}) {
const key = [
color,
options.roughness ?? 0.86,
options.metalness ?? 0,
options.emissive ?? 0x000000
].join(":");
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.86,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 1,
flatShading: true
}));
}
return materialCache.get(key);
}
function box(
parent,
width,
height,
depth,
x,
y,
z,
color,
options = {}
) {
const mesh = new THREE.Mesh(
unitBox,
options.material || material(color, options)
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function makeSign(text, width, height, background, foreground, parent, x, y, z) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.lineWidth = 10;
ctx.strokeRect(15, 15, canvas.width - 30, canvas.height - 30);
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 92px system-ui, sans-serif";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 4, canvas.width - 80);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
sign.position.set(x, y, z);
parent.add(sign);
return sign;
}
function addPerson(x, z, shirt, skin = 0xb97855, pose = "stand", rotation = 0) {
const person = new THREE.Group();
person.position.set(x, 0.64, z);
person.rotation.y = rotation;
const dark = 0x304d56;
const hair = 0x3c302d;
if (pose === "seated") {
box(person, 0.16, 0.48, 0.18, -0.14, 0.25, 0.22, dark);
box(person, 0.16, 0.48, 0.18, 0.14, 0.25, 0.22, dark);
box(person, 0.16, 0.16, 0.58, -0.14, 0.05, 0.42, dark);
box(person, 0.16, 0.16, 0.58, 0.14, 0.05, 0.42, dark);
} else {
const stride = pose === "walk" ? 0.08 : 0;
box(person, 0.17, 0.58, 0.19, -0.14, 0.29, stride, dark);
box(person, 0.17, 0.58, 0.19, 0.14, 0.29, -stride, dark);
}
box(person, 0.54, 0.68, 0.32, 0, 0.83, 0, shirt);
box(person, 0.38, 0.38, 0.38, 0, 1.38, 0, skin);
box(person, 0.40, 0.12, 0.40, 0, 1.57, -0.015, hair);
box(person, 0.16, 0.57, 0.17, -0.36, 0.82, 0, skin);
box(person, 0.16, 0.57, 0.17, 0.36, 0.82, 0, skin);
scene.add(person);
return person;
}
// ------------------------------------------------------------------
// Distant coast, sea, and the small city seen through the viewpoint.
// ------------------------------------------------------------------
const distance = new THREE.Group();
scene.add(distance);
box(
distance,
70,
0.25,
70,
0,
-2.7,
-18,
0x74b9bd,
{ roughness: 0.72, castShadow: false }
);
box(
distance,
30,
0.8,
7.5,
0,
-2.25,
-11.2,
0xc9b887,
{ castShadow: false }
);
let seed = 8137;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
const distantColors = [
0xe6c9a4,
0xd99378,
0xe9d9b7,
0x9eb8aa,
0xd4ad7e,
0xbdc8ae
];
for (let i = 0; i < 54; i++) {
const x = -13 + random() * 26;
const z = -8.8 - random() * 4.2;
const w = 0.55 + random() * 1.25;
const d = 0.65 + random() * 1.4;
const h = 0.65 + random() * 2.7;
const color = distantColors[Math.floor(random() * distantColors.length)];
box(distance, w, h, d, x, -1.84 + h / 2, z, color, {
castShadow: false,
roughness: 0.94
});
if (random() > 0.45) {
box(
distance,
w + 0.12,
0.25,
d + 0.12,
x,
-1.84 + h + 0.10,
z,
0xb96850,
{ castShadow: false }
);
}
}
// A small landmark deliberately centered in the open view.
box(distance, 0.78, 3.8, 0.78, 0.65, 0.05, -9.2, 0xf0d7a5, {
castShadow: false
});
box(distance, 1.05, 0.28, 1.05, 0.65, 2.08, -9.2, 0xc86d52, {
castShadow: false
});
box(distance, 0.12, 0.65, 0.12, 0.65, 2.52, -9.2, 0xe8d6b1, {
castShadow: false
});
box(distance, 0.48, 0.11, 0.11, 0.65, 2.73, -9.2, 0xe8d6b1, {
castShadow: false
});
// ------------------------------------------------------------------
// Hilltop plinth and open public promenade.
// ------------------------------------------------------------------
const hill = new THREE.Group();
scene.add(hill);
box(hill, 18.6, 0.82, 12.7, 0, 0, 0, 0xb99570);
box(hill, 17.6, 0.86, 11.8, 0, -0.79, 0, 0xa77f62);
box(hill, 16.5, 1.25, 10.8, 0, -1.82, 0, 0x8f745f);
box(hill, 17.9, 0.18, 12.0, 0, 0.49, 0, 0xd9c6a3);
// Rear garden strips.
box(hill, 17.8, 0.12, 3.3, 0, 0.62, -4.32, 0x91aa7b);
box(hill, 4.1, 0.13, 2.0, 0, 0.64, -2.85, 0xa4b886);
// Broad, unobstructed viewing promenade.
box(hill, 17.6, 0.13, 2.45, 0, 0.65, 3.90, 0xead9b8);
box(hill, 17.6, 0.035, 0.12, 0, 0.735, 5.03, 0xc97859);
box(hill, 17.6, 0.035, 0.10, 0, 0.735, 2.73, 0xbdad8c);
// Subtle voxel paving joints.
for (let x = -8; x <= 8; x += 2) {
box(hill, 0.035, 0.025, 2.25, x, 0.735, 3.91, 0xd0bea0, {
castShadow: false
});
}
// Central stairs keep the edge accessible.
box(hill, 4.5, 0.28, 0.82, 0, 0.34, 5.82, 0xd5bd96);
box(hill, 4.1, 0.27, 0.82, 0, 0.12, 6.32, 0xc9ae87);
box(hill, 3.7, 0.27, 0.82, 0, -0.10, 6.82, 0xb99b76);
box(hill, 3.3, 0.27, 0.82, 0, -0.32, 7.32, 0xa98768);
// Small pixel arrow pointing toward the public stair.
box(hill, 0.23, 0.035, 0.70, 0, 0.755, 4.55, 0x4c7a6b, {
castShadow: false
});
box(hill, 0.55, 0.035, 0.22, 0, 0.755, 4.16, 0x4c7a6b, {
castShadow: false
});
box(hill, 0.28, 0.035, 0.28, 0, 0.755, 3.98, 0x4c7a6b, {
castShadow: false
});
// Retaining-wall blocks along the lower hill.
for (let i = 0; i < 10; i++) {
const x = -7.4 + i * 1.65;
box(
hill,
1.48,
0.52,
0.30,
x,
-1.05,
5.62,
i % 2 ? 0xb59473 : 0xc2a27e
);
}
// ------------------------------------------------------------------
// Stylized cathedral of Alto da Sé.
// ------------------------------------------------------------------
const cathedral = new THREE.Group();
scene.add(cathedral);
const cream = 0xf0dfb8;
const creamLight = 0xfaedca;
const stone = 0xd3bd91;
const terracotta = 0xb65f48;
const teal = 0x47766d;
box(cathedral, 6.0, 4.1, 2.8, -5.0, 2.65, -4.35, cream);
box(cathedral, 6.25, 0.34, 3.05, -5.0, 0.82, -4.30, stone);
box(cathedral, 6.18, 0.24, 2.95, -5.0, 4.68, -4.35, creamLight);
// Twin square bell towers.
for (const x of [-7.42, -2.58]) {
box(cathedral, 1.66, 5.35, 2.18, x, 3.25, -4.15, creamLight);
box(cathedral, 1.88, 0.28, 2.38, x, 5.96, -4.15, stone);
box(cathedral, 1.50, 0.20, 2.0, x, 6.18, -4.15, terracotta);
box(cathedral, 0.48, 0.70, 0.05, x, 4.88, -3.045, teal);
box(cathedral, 0.26, 0.10, 0.06, x, 4.48, -3.01, cream);
box(cathedral, 0.64, 1.22, 0.05, x, 2.92, -3.035, teal);
box(cathedral, 0.15, 0.16, 0.07, x, 3.43, -2.99, cream);
}
// Stepped voxel pediment.
box(cathedral, 3.15, 0.45, 3.05, -5.0, 4.93, -4.30, creamLight);
box(cathedral, 2.55, 0.40, 2.82, -5.0, 5.30, -4.32, creamLight);
box(cathedral, 1.85, 0.37, 2.55, -5.0, 5.65, -4.35, creamLight);
box(cathedral, 1.15, 0.35, 2.25, -5.0, 5.98, -4.38, creamLight);
// Cross.
box(cathedral, 0.12, 0.76, 0.12, -5.0, 6.47, -4.38, teal);
box(cathedral, 0.48, 0.12, 0.12, -5.0, 6.54, -4.38, teal);
// Central doorway and stepped arch.
box(cathedral, 1.38, 1.90, 0.08, -5.0, 1.62, -2.92, teal);
box(cathedral, 1.72, 0.38, 0.08, -5.0, 2.56, -2.90, teal);
box(cathedral, 1.35, 0.35, 0.08, -5.0, 2.91, -2.90, teal);
box(cathedral, 0.92, 0.28, 0.08, -5.0, 3.23, -2.90, teal);
box(cathedral, 0.09, 2.05, 0.10, -5.69, 1.67, -2.85, stone);
box(cathedral, 0.09, 2.05, 0.10, -4.31, 1.67, -2.85, stone);
box(cathedral, 1.48, 0.16, 0.10, -5.0, 2.70, -2.85, stone);
// Upper windows and façade trim.
for (const x of [-6.36, -3.64]) {
box(cathedral, 0.52, 1.0, 0.06, x, 3.35, -2.91, teal);
box(cathedral, 0.12, 1.08, 0.08, x, 3.35, -2.86, creamLight);
}
box(cathedral, 6.08, 0.12, 0.12, -5.0, 1.02, -2.88, terracotta);
box(cathedral, 6.08, 0.10, 0.12, -5.0, 4.33, -2.88, terracotta);
// ------------------------------------------------------------------
// Open scenic frame: the distant city is literally visible through it.
// ------------------------------------------------------------------
const viewpoint = new THREE.Group();
viewpoint.position.set(0.45, 0, -4.46);
scene.add(viewpoint);
for (const x of [-2.15, 2.15]) {
box(viewpoint, 0.40, 3.55, 0.42, x, 2.38, 0, terracotta);
box(viewpoint, 0.16, 3.12, 0.46, x + (x < 0 ? 0.27 : -0.27), 2.37, 0.03, 0xf5d6ae);
box(viewpoint, 0.62, 0.30, 0.62, x, 4.27, 0, stone);
}
box(viewpoint, 4.85, 0.48, 0.50, 0, 4.13, 0, terracotta);
box(viewpoint, 4.42, 0.15, 0.53, 0, 3.82, 0.02, 0xf5d6ae);
box(viewpoint, 4.85, 0.18, 0.50, 0, 0.75, 0, stone);
makeSign(
"HORIZONTE DE OLINDA",
3.65,
0.48,
"#d96850",
"#fff1cf",
viewpoint,
0,
4.18,
0.27
);
// Decorative pixel crest.
box(viewpoint, 0.48, 0.32, 0.28, 0, 4.55, 0, teal);
box(viewpoint, 0.24, 0.48, 0.24, 0, 4.65, 0, 0xf0d9ac);
// ------------------------------------------------------------------
// Original craft stall.
// ------------------------------------------------------------------
const stall = new THREE.Group();
stall.position.set(4.75, 0, -0.95);
scene.add(stall);
// Canopy posts.
for (const x of [-1.48, 1.48]) {
for (const z of [-0.76, 0.76]) {
box(stall, 0.16, 2.65, 0.16, x, 1.94, z, 0x795744);
}
}
// Striped fabric canopy.
for (let i = 0; i < 8; i++) {
box(
stall,
0.39,
0.13,
1.78,
-1.365 + i * 0.39,
3.28,
0,
i % 2 ? 0xf5d9ab : 0xd96850
);
}
// Front valance.
for (let i = 0; i < 8; i++) {
box(
stall,
0.39,
0.32,
0.12,
-1.365 + i * 0.39,
3.08,
0.90,
i % 2 ? 0xf5d9ab : 0xd96850
);
}
// Counter and back shelving.
box(stall, 3.15, 0.92, 0.48, 0, 1.12, 0.72, 0x8e6249);
box(stall, 3.42, 0.16, 0.72, 0, 1.64, 0.70, 0x6f4938);
box(stall, 3.12, 0.13, 0.34, 0, 1.55, -0.75, 0x795744);
box(stall, 3.12, 0.13, 0.34, 0, 2.12, -0.75, 0x795744);
makeSign(
"OFICINA DE OLINDA",
2.70,
0.44,
"#47766d",
"#fff1cf",
stall,
0,
2.93,
0.98
);
// Small original ceramic vessels, assembled from cubes.
const pottery = [0xd96850, 0x47766d, 0xe0ad4f, 0x6d9277];
for (let i = 0; i < 4; i++) {
const x = -1.08 + i * 0.72;
const color = pottery[i % pottery.length];
box(stall, 0.22, 0.17, 0.22, x, 1.78, 0.68, color);
box(stall, 0.30, 0.28, 0.30, x, 1.98, 0.68, color);
box(stall, 0.18, 0.13, 0.18, x, 2.18, 0.68, color);
}
// Tiny abstract sun sculpture.
box(stall, 0.26, 0.26, 0.26, 0.92, 1.88, -0.70, 0xe8b84d);
box(stall, 0.12, 0.48, 0.12, 0.92, 1.88, -0.70, 0xe8b84d);
box(stall, 0.48, 0.12, 0.12, 0.92, 1.88, -0.70, 0xe8b84d);
// Woven wall hanging.
for (let i = 0; i < 7; i++) {
box(
stall,
0.13,
0.72 + (i % 2) * 0.18,
0.08,
-0.88 + i * 0.20,
1.96,
-0.91,
pottery[i % pottery.length]
);
}
// ------------------------------------------------------------------
// Shaded seating under a compact striped pergola.
// ------------------------------------------------------------------
const seating = new THREE.Group();
seating.position.set(-4.65, 0, 0.15);
scene.add(seating);
for (const x of [-1.95, 1.95]) {
for (const z of [-1.38, 1.38]) {
box(seating, 0.19, 3.0, 0.19, x, 2.12, z, 0x795744);
}
}
// Canopy slats and cloth panels.
for (let i = 0; i < 9; i++) {
box(
seating,
0.50,
0.14,
3.26,
-2.0 + i * 0.50,
3.68,
0,
i % 2 ? 0xe8c899 : 0xcb7358
);
}
for (const z of [-1.52, 1.52]) {
box(seating, 4.35, 0.22, 0.20, 0, 3.48, z, 0x684a39);
}
// Table and benches.
const seeting = seating; // Name used by the bench and table-detail calls below.
box(seating, 2.05, 0.16, 1.00, 0, 1.28, 0, 0xb78055);
box(seating, 0.22, 0.72, 0.78, -0.72, 0.92, 0, 0x795744);
box(seating, 0.22, 0.72, 0.78, 0.72, 0.92, 0, 0x795744);
box(seeting, 2.35, 0.16, 0.48, 0, 0.78, -1.12, 0x9e6848);
box(seeting, 2.35, 0.16, 0.48, 0, 0.78, 1.12, 0x9e6848);
box(seeting, 0.18, 0.58, 0.42, -0.94, 0.46, -1.12, 0x6e4b39);
box(seeting, 0.18, 0.58, 0.42, 0.94, 0.46, -1.12, 0x6e4b39);
box(seeting, 0.18, 0.58, 0.42, -0.94, 0.46, 1.12, 0x6e4b39);
box(seeting, 0.18, 0.58, 0.42, 0.94, 0.46, 1.12, 0x6e4b39);
// Cups and a tiny book on the table.
box(seating, 0.18, 0.22, 0.18, -0.42, 1.47, 0.10, 0xf1dfb8);
box(seeting, 0.18, 0.22, 0.18, 0.37, 1.47, -0.08, 0xd96850);
box(seeting, 0.55, 0.08, 0.38, 0, 1.40, 0.08, 0x47766d);
// ------------------------------------------------------------------
// Planters and blocky palms, placed away from the open viewing edge.
// ------------------------------------------------------------------
function addPalm(x, z, scale = 1) {
const palm = new THREE.Group();
palm.position.set(x, 0.64, z);
palm.scale.setScalar(scale);
box(palm, 1.05, 0.70, 1.05, 0, 0.35, 0, 0xc97a56);
box(palm, 1.25, 0.18, 1.25, 0, 0.72, 0, 0xe1a477);
for (let i = 0; i < 5; i++) {
box(
palm,
0.22,
0.58,
0.22,
Math.sin(i * 0.9) * 0.08,
1.15 + i * 0.48,
0,
i % 2 ? 0x8d7251 : 0x9c805c
);
}
const crownY = 3.55;
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const leaf = box(
palm,
0.50,
0.18,
1.85,
Math.sin(angle) * 0.66,
crownY,
Math.cos(angle) * 0.66,
i % 2 ? 0x527f5b : 0x689561
);
leaf.rotation.y = angle;
leaf.rotation.x = 0.08;
}
box(palm, 0.34, 0.34, 0.34, 0, crownY - 0.05, 0, 0x77905a);
scene.add(palm);
}
addPalm(-8.0, 2.45, 0.90);
addPalm(8.0, 1.55, 0.82);
// Low shrubs beside the rear lawn.
for (const [x, z] of [[-1.55, -4.95], [2.65, -4.95], [7.65, -3.8]]) {
box(hill, 1.20, 0.40, 0.82, x, 0.91, z, 0x6f8f61);
box(hill, 0.76, 0.40, 0.66, x - 0.16, 1.18, z + 0.05, 0x7da16b);
box(hill, 0.62, 0.31, 0.58, x + 0.32, 1.11, z - 0.08, 0x5e8258);
}
// A small public-access sign at the side, not on the promenade.
box(hill, 0.13, 1.30, 0.13, 7.45, 1.32, 2.45, 0x795744);
makeSign(
"ACESSO LIVRE",
1.75,
0.44,
"#47766d",
"#fff1cf",
hill,
7.45,
2.08,
2.54
);
// ------------------------------------------------------------------
// Visitors: voxel people establish scale and keep the plaza lively.
// ------------------------------------------------------------------
addPerson(4.72, -1.78, 0x47766d, 0x8f563d, "stand", 0);
addPerson(3.95, 0.60, 0xd96850, 0xc88b61, "stand", -0.25);
addPerson(0.48, -2.95, 0xe4b44f, 0x9d6548, "stand", Math.PI);
addPerson(-4.75, 0.25, 0x6d9277, 0xb97855, "seated", 0);
addPerson(-2.15, 3.75, 0x47766d, 0x7d4b38, "walk", 0.15);
addPerson(5.55, 3.55, 0xd96850, 0xc98c63, "walk", -0.45);
// ------------------------------------------------------------------
// A few soft, cubic clouds in the distance.
// ------------------------------------------------------------------
const clouds = [];
function addCloud(x, y, z, scale = 1) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
box(cloud, 2.5, 0.62, 0.86, 0, 0, 0, 0xf7f1d8, { castShadow: false });
box(cloud, 1.30, 0.84, 0.78, -0.70, 0.30, 0, 0xfff7e1, { castShadow: false });
box(cloud, 1.55, 1.02, 0.82, 0.55, 0.35, 0, 0xfff8e6, { castShadow: false });
box(cloud, 0.90, 0.65, 0.70, 1.45, 0.05, 0, 0xf6efd9, { castShadow: false });
scene.add(cloud);
clouds.push(cloud);
}
addCloud(-8.5, 7.8, -13, 1.05);
addCloud(4.8, 8.8, -17, 0.78);
addCloud(10.0, 6.8, -11, 0.62);
// ------------------------------------------------------------------
// Direct camera controls: no addons or external control libraries.
// ------------------------------------------------------------------
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const dx = event.clientX - orbit.pointerX;
const dy = event.clientY - orbit.pointerY;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
orbit.azimuth = THREE.MathUtils.clamp(
orbit.azimuth - dx * 0.005,
-0.82,
0.92
);
orbit.elevation = THREE.MathUtils.clamp(
orbit.elevation + dy * 0.004,
0.36,
0.96
);
updateCamera();
});
function endDrag(event) {
orbit.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.65
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
function resetView() {
orbit.azimuth = 0.40;
orbit.elevation = 0.64;
orbit.zoom = 1;
updateCamera();
}
document.querySelector("#reset").addEventListener("click", resetView);
document.querySelector("#viewpoint").addEventListener("click", () => {
orbit.azimuth = 0.02;
orbit.elevation = 0.48;
orbit.zoom = 1.12;
updateCamera();
});
// Lightweight animation for the distant clouds.
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
if (!reducedMotion) {
clouds[0].position.x = -8.5 + Math.sin(time * 0.045) * 0.45;
clouds[1].position.x = 4.8 + Math.sin(time * 0.035 + 1.3) * 0.30;
clouds[2].position.x = 10.0 + Math.sin(time * 0.055 + 2.1) * 0.22;
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```