Prompt specification
Build or customize the Three.js 3D scene "San Blas stone step and plastered wall" 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: San Blas stone step and plastered wall
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/san-blas-stone-step-and-plastered-wall-x2733
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts San Blas in Cusco. Build a referenced Cusco street fragment with stone steps, plastered wall, and timber doorway. Show the transition between materials and keep each step's rise consistent. Voxel style.
Working Three.js Starter (san-blas-stone-step-and-plastered-wall-x2733):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>San Blas, Cusco — Voxel Street Fragment</title>
<style>
:root {
--ink: #302820;
--paper: #f4eddf;
--stone: #85847b;
--plaster: #e8dec8;
--timber: #503126;
--accent: #a4553e;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce4df;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
outline: none;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(
circle at 50% 42%,
transparent 42%,
rgba(55, 48, 39, 0.09) 100%
);
}
.panel {
position: fixed;
z-index: 3;
pointer-events: none;
background: rgba(247, 241, 229, 0.88);
border: 1px solid rgba(65, 52, 39, 0.16);
box-shadow: 0 12px 32px rgba(48, 40, 31, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.title-card {
top: 24px;
left: 24px;
width: min(360px, calc(100vw - 48px));
padding: 18px 20px 17px;
border-radius: 4px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 42px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 0;
color: rgba(48, 40, 32, 0.72);
font-size: 12px;
line-height: 1.5;
}
.coordinates {
position: fixed;
z-index: 3;
top: 25px;
right: 25px;
padding: 9px 11px;
border: 1px solid rgba(48, 40, 32, 0.17);
border-radius: 3px;
background: rgba(247, 241, 229, 0.72);
color: rgba(48, 40, 32, 0.72);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.1em;
pointer-events: none;
backdrop-filter: blur(8px);
}
.legend {
bottom: 24px;
left: 24px;
padding: 13px 15px;
border-radius: 4px;
}
.legend-title {
margin-bottom: 9px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.legend-row {
display: flex;
gap: 15px;
align-items: center;
flex-wrap: wrap;
}
.legend-item {
display: flex;
gap: 7px;
align-items: center;
color: rgba(48, 40, 32, 0.74);
font-size: 10px;
font-weight: 650;
}
.swatch {
width: 11px;
height: 11px;
border: 1px solid rgba(35, 29, 23, 0.18);
box-shadow: inset 0 -2px rgba(0, 0, 0, 0.08);
}
.riser {
bottom: 24px;
left: 50%;
display: flex;
gap: 13px;
align-items: center;
padding: 10px 14px;
border-radius: 4px;
transform: translateX(-50%);
}
.riser strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 500;
line-height: 1;
}
.riser small {
display: block;
margin-top: 3px;
color: rgba(48, 40, 32, 0.62);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.step-icon {
display: flex;
align-items: flex-end;
gap: 3px;
height: 24px;
}
.step-icon i {
display: block;
width: 8px;
border-top: 3px solid var(--accent);
border-right: 1px solid var(--accent);
border-left: 1px solid var(--accent);
background: rgba(164, 85, 62, 0.08);
}
.step-icon i:nth-child(1) { height: 8px; }
.step-icon i:nth-child(2) { height: 12px; }
.step-icon i:nth-child(3) { height: 16px; }
.step-icon i:nth-child(4) { height: 20px; }
.controls {
right: 24px;
bottom: 24px;
padding: 11px 13px;
border-radius: 4px;
color: rgba(48, 40, 32, 0.65);
font-size: 10px;
font-weight: 650;
line-height: 1.6;
text-align: right;
}
.controls button {
display: block;
margin: 6px 0 0 auto;
padding: 7px 10px;
border: 1px solid rgba(48, 40, 32, 0.2);
border-radius: 2px;
background: rgba(255, 255, 255, 0.4);
color: var(--ink);
font: inherit;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
pointer-events: auto;
}
.controls button:hover {
background: rgba(255, 255, 255, 0.8);
}
@media (max-width: 720px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 15px;
}
.coordinates {
display: none;
}
.legend {
bottom: 14px;
left: 14px;
}
.riser {
display: none;
}
.controls {
right: 14px;
bottom: 14px;
}
}
</style>
</head>
<body>
<canvas
id="scene"
aria-label="Interactive voxel scene of a stone stairway, plastered wall, and timber doorway in San Blas, Cusco"
></canvas>
<div class="vignette"></div>
<section class="panel title-card">
<div class="eyebrow">Cusco, Peru · Voxel study</div>
<h1>San Blas</h1>
<p class="subtitle">
A steep colonial street fragment: dressed stone steps meet lime plaster,
a recessed timber doorway, and small clay-roof details.
</p>
</section>
<div class="coordinates">13.5158° S / 71.9757° W</div>
<section class="panel legend" aria-label="Material legend">
<div class="legend-title">Material transitions</div>
<div class="legend-row">
<div class="legend-item">
<span class="swatch" style="background:#85847b"></span>
Stone
</div>
<div class="legend-item">
<span class="swatch" style="background:#e8dec8"></span>
Plaster
</div>
<div class="legend-item">
<span class="swatch" style="background:#503126"></span>
Timber
</div>
</div>
</section>
<section class="panel riser" aria-label="Uniform stair rise">
<div class="step-icon" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
<strong>0.38 m</strong>
<small>Uniform rise</small>
</div>
</section>
<section class="panel controls">
Drag to orbit<br>
Scroll to zoom · Shift-drag to pan
<button id="reset-view" type="button">Reset view</button>
</section>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, and orthographic camera
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.setClearColor(0xdce4df, 1);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xdce4df, 34, 78);
const world = new THREE.Group();
scene.add(world);
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, 0.1, 100);
const view = {
target: new THREE.Vector3(0.2, 3.0, -0.25),
theta: -0.72,
phi: 1.08,
zoom: 1,
radius: 30
};
let frustumSize = 15;
function updateCamera() {
const sinPhi = Math.sin(view.phi);
const cosPhi = Math.cos(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * cosPhi,
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
frustumSize = aspect < 0.8 ? 18 : 15;
camera.left = (-frustumSize * aspect) / 2;
camera.right = (frustumSize * aspect) / 2;
camera.top = frustumSize / 2;
camera.bottom = -frustumSize / 2;
renderer.setSize(width, height, false);
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf4eee0, 0x776e63, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedcf, 3.2);
sun.position.set(-9, 16, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 48;
sun.shadow.bias = -0.00025;
sun.shadow.normalBias = 0.025;
sun.target.position.set(0, 2.5, -1);
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0xb8d3dc, 0.65);
fill.position.set(8, 8, -8);
scene.add(fill);
// ------------------------------------------------------------
// Materials and voxel construction helpers
// ------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const dummy = new THREE.Object3D();
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
metalness: 0,
...options
});
}
const materials = {
ground: standard(0xb7ad9c),
platform: standard(0x9f9481),
stone: standard(0x77776f),
stoneDark: standard(0x5f625e),
stoneLight: standard(0x99968b),
curb: standard(0x858278),
plaster: standard(0xe8dec8),
plasterWarm: standard(0xdccfb3),
plasterLight: standard(0xf1e7d3),
adobe: standard(0xb17f59),
timber: standard(0x4a2c20),
timberLight: standard(0x70442e),
timberDark: standard(0x291a15),
recess: standard(0x211713),
brass: standard(0xb39248, { metalness: 0.55, roughness: 0.48 }),
roof: standard(0x9a4c39),
terracotta: standard(0xb86642),
soil: standard(0x3e3226),
leaf: standard(0x55744d),
leafLight: standard(0x71895b),
lamp: standard(0xffce73, {
emissive: 0xff9d37,
emissiveIntensity: 1.8,
roughness: 0.45
})
};
function cube(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function instanceBoxes(items, options = {}) {
if (!items.length) return null;
const material = standard(options.color ?? 0xffffff, {
roughness: options.roughness ?? 0.9,
metalness: options.metalness ?? 0
});
const mesh = new THREE.InstancedMesh(unitBox, material, items.length);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = true;
items.forEach((item, index) => {
dummy.position.set(
item.position[0],
item.position[1],
item.position[2]
);
dummy.scale.set(item.size[0], item.size[1], item.size[2]);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, new THREE.Color(item.color ?? 0xffffff));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.computeBoundingSphere();
world.add(mesh);
return mesh;
}
let seed = 4137;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function pick(colors) {
return colors[Math.floor(random() * colors.length)];
}
const stoneColors = [
0x85847b,
0x797a72,
0x929087,
0x817f75,
0x8b887d
];
const riserColors = [
0x666964,
0x73746c,
0x7e7c72,
0x5f625e
];
const plasterColors = [
0xe8dec8,
0xded2b8,
0xeee4d0,
0xe3d7bd
];
// ------------------------------------------------------------
// Diorama base and foreground street
// ------------------------------------------------------------
cube(
world,
[80, 0.2, 80],
[0, -0.45, 0],
standard(0xc9c4b7),
false
);
cube(
world,
[11, 0.36, 14],
[0, -0.18, 1.0],
materials.platform
);
const foregroundTiles = [];
const foregroundZ = 5.35;
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 6; col++) {
foregroundTiles.push({
position: [
-2.35 + col * 0.94,
-0.04,
foregroundZ + row * 0.78
],
size: [0.91, 0.08, 0.74],
color: pick([0xb4aa97, 0xaaa18f, 0xbdb2a0, 0xa79f90])
});
}
}
instanceBoxes(foregroundTiles, { roughness: 1 });
// ------------------------------------------------------------
// Stairs
//
// Every tread uses the same RISE and TREAD values. The first
// and upper flights are separated by a level landing in front
// of the doorway, while the vertical rise remains continuous.
// ------------------------------------------------------------
const RISE = 0.38;
const TREAD = 0.52;
const STAIR_WIDTH = 5.5;
const COLUMNS = 9;
const COLUMN_WIDTH = STAIR_WIDTH / COLUMNS;
const stairBases = [];
const stairTops = [];
const riserTiles = [];
const curbBlocks = [];
function buildFlight(frontZ, baseY, count) {
for (let i = 0; i < count; i++) {
const topY = baseY + (i + 1) * RISE;
const stepFrontZ = frontZ - i * TREAD;
const centerZ = stepFrontZ - TREAD / 2;
// Solid stepped masonry supports the individual tread.
stairBases.push({
position: [0, (topY - 0.08) / 2, centerZ],
size: [STAIR_WIDTH, topY - 0.08, TREAD - 0.012],
color: pick([0x74756e, 0x696b65, 0x7e7d73])
});
for (let col = 0; col < COLUMNS; col++) {
const x = -STAIR_WIDTH / 2 + (col + 0.5) * COLUMN_WIDTH;
// Top paver ends exactly at topY.
stairTops.push({
position: [x, topY - 0.04, centerZ],
size: [COLUMN_WIDTH - 0.026, 0.08, TREAD - 0.035],
color: pick(stoneColors)
});
// Equal-height masonry tiles make the riser rhythm legible.
riserTiles.push({
position: [
x,
topY - RISE * 0.52,
stepFrontZ + 0.012
],
size: [
COLUMN_WIDTH - 0.05,
RISE * 0.36,
0.022
],
color: pick(riserColors)
});
}
curbBlocks.push({
position: [2.88, topY - 0.08, centerZ],
size: [0.22, 0.16, TREAD - 0.012],
color: pick([0x87857b, 0x929087, 0x7c7b72])
});
}
}
buildFlight(5.0, 0, 8);
const lowerFlightEnd = 5.0 - 8 * TREAD;
const landingDepth = 1.70;
const landingBack = lowerFlightEnd - landingDepth;
const landingTop = 8 * RISE;
// Landing masonry.
stairBases.push({
position: [0, (landingTop - 0.08) / 2, lowerFlightEnd - landingDepth / 2],
size: [STAIR_WIDTH, landingTop - 0.08, landingDepth],
color: 0x74756e
});
const landingRows = 3;
const landingRowDepth = landingDepth / landingRows;
for (let row = 0; row < landingRows; row++) {
for (let col = 0; col < COLUMNS; col++) {
const x = -STAIR_WIDTH / 2 + (col + 0.5) * COLUMN_WIDTH;
const z = lowerFlightEnd - (row + 0.5) * landingRowDepth;
stairTops.push({
position: [x, landingTop - 0.04, z],
size: [COLUMN_WIDTH - 0.026, 0.08, landingRowDepth - 0.035],
color: pick(stoneColors)
});
}
}
curbBlocks.push({
position: [
2.88,
landingTop - 0.08,
lowerFlightEnd - landingDepth / 2
],
size: [0.22, 0.16, landingDepth],
color: 0x87857b
});
buildFlight(landingBack, landingTop, 7);
instanceBoxes(stairBases);
instanceBoxes(stairTops);
instanceBoxes(riserTiles);
instanceBoxes(curbBlocks);
// ------------------------------------------------------------
// Plastered wall and its stone/adobe foundations
// ------------------------------------------------------------
const wallFoundation = [];
const wallBaseCourse = [];
const wallPlaster = [];
const wallPatches = [];
const roofTiles = [];
const WALL_X = 3.62;
const WALL_THICKNESS = 1.20;
const BASE_COURSE_HEIGHT = 0.46;
const PLASTER_HEIGHT = 2.85;
const WALL_TOP = BASE_COURSE_HEIGHT + PLASTER_HEIGHT;
function buildRegularWallSegment(z, depth, baseY) {
wallFoundation.push({
position: [WALL_X, baseY / 2, z],
size: [WALL_THICKNESS, baseY, depth - 0.018],
color: pick([0x77766c, 0x6f7068, 0x817d70])
});
wallBaseCourse.push({
position: [
WALL_X,
baseY + BASE_COURSE_HEIGHT / 2,
z
],
size: [WALL_THICKNESS + 0.025, BASE_COURSE_HEIGHT, depth - 0.018],
color: pick([0xae7b57, 0xb88660, 0xa87453])
});
wallPlaster.push({
position: [
WALL_X,
baseY + BASE_COURSE_HEIGHT + PLASTER_HEIGHT / 2,
z
],
size: [WALL_THICKNESS, PLASTER_HEIGHT, depth - 0.018],
color: pick(plasterColors)
});
// Small voxel weathering patches on the street-facing plaster.
for (let p = 0; p < 2; p++) {
const patchHeight = 0.16 + random() * 0.24;
const patchDepth = 0.12 + random() * 0.16;
wallPatches.push({
position: [
WALL_X - WALL_THICKNESS / 2 - 0.011,
baseY + BASE_COURSE_HEIGHT + 0.35 + random() * 1.85,
z + (random() - 0.5) * Math.max(0.05, depth - patchDepth - 0.05)
],
size: [0.025, patchHeight, patchDepth],
color: pick([0xe0d3b8, 0xf0e5cf, 0xd7c7aa, 0xe6dbc4])
});
}
}
// Lower flight wall.
for (let i = 0; i < 8; i++) {
const z = 5.0 - (i + 0.5) * TREAD;
buildRegularWallSegment(z, TREAD, (i + 1) * RISE);
}
// Upper flight wall.
for (let i = 0; i < 7; i++) {
const z = landingBack - (i + 0.5) * TREAD;
const baseY = landingTop + (i + 1) * RISE;
buildRegularWallSegment(z, TREAD, baseY);
// Clay-colored voxel roof edge along the upper wall.
for (let tile = 0; tile < 2; tile++) {
roofTiles.push({
position: [
3.56,
baseY + WALL_TOP + 0.055,
z + (tile - 0.5) * 0.25
],
size: [0.84, 0.11, 0.235],
color: pick([0x9a4c39, 0xa7563d, 0x8e4435])
});
}
}
// Landing wall with a real doorway opening.
const landingFront = lowerFlightEnd;
const landingCenter = (landingFront + landingBack) / 2;
const doorZ = landingCenter;
const openingWidth = 1.35;
const openingHalf = openingWidth / 2;
const frontStripDepth = landingFront - (doorZ + openingHalf);
const backStripDepth = (doorZ - openingHalf) - landingBack;
wallFoundation.push({
position: [WALL_X, landingTop / 2, landingCenter],
size: [WALL_THICKNESS, landingTop, landingDepth],
color: 0x73736a
});
// Base course is split around the doorway.
wallBaseCourse.push({
position: [
WALL_X,
landingTop + BASE_COURSE_HEIGHT / 2,
(landingFront + doorZ + openingHalf) / 2
],
size: [
WALL_THICKNESS + 0.025,
BASE_COURSE_HEIGHT,
frontStripDepth
],
color: 0xae7b57
});
wallBaseCourse.push({
position: [
WALL_X,
landingTop + BASE_COURSE_HEIGHT / 2,
(doorZ - openingHalf + landingBack) / 2
],
size: [
WALL_THICKNESS + 0.025,
BASE_COURSE_HEIGHT,
backStripDepth
],
color: 0xb1815d
});
// Plaster strips flanking the doorway.
wallPlaster.push({
position: [
WALL_X,
landingTop + BASE_COURSE_HEIGHT + PLASTER_HEIGHT / 2,
(landingFront + doorZ + openingHalf) / 2
],
size: [
WALL_THICKNESS,
PLASTER_HEIGHT,
frontStripDepth
],
color: 0xe8dec8
});
wallPlaster.push({
position: [
WALL_X,
landingTop + BASE_COURSE_HEIGHT + PLASTER_HEIGHT / 2,
(doorZ - openingHalf + landingBack) / 2
],
size: [
WALL_THICKNESS,
PLASTER_HEIGHT,
backStripDepth
],
color: 0xdfd2b8
});
// Plaster lintel panel above the doorway.
const landingWallTop = landingTop + WALL_TOP;
const openingHeight = 2.62;
wallPlaster.push({
position: [
WALL_X,
landingTop + openingHeight + (WALL_TOP - openingHeight) / 2,
doorZ
],
size: [
WALL_THICKNESS,
WALL_TOP - openingHeight,
openingWidth
],
color: 0xeee4d0
});
instanceBoxes(wallFoundation);
instanceBoxes(wallBaseCourse);
instanceBoxes(wallPlaster);
instanceBoxes(wallPatches);
instanceBoxes(roofTiles);
// ------------------------------------------------------------
// Timber doorway set into a stone reveal
// ------------------------------------------------------------
const doorWidth = 1.22;
const doorHeight = 2.38;
const doorBottom = landingTop + 0.10;
const doorCenterY = doorBottom + doorHeight / 2;
const doorX = 3.30;
// Dark recess behind the leaf.
cube(
world,
[0.26, 2.56, 1.38],
[3.62, landingTop + 1.30, doorZ],
materials.recess
);
// Stone jambs and lintel emphasize the material transition.
cube(
world,
[0.22, 2.66, 0.16],
[3.02, landingTop + 1.33, doorZ - 0.76],
materials.stoneLight
);
cube(
world,
[0.22, 2.66, 0.16],
[3.02, landingTop + 1.33, doorZ + 0.76],
materials.stoneLight
);
cube(
world,
[0.24, 0.18, 1.68],
[3.01, landingTop + 2.62, doorZ],
materials.stoneLight
);
// Stone threshold.
cube(
world,
[0.90, 0.10, 1.52],
[3.28, landingTop + 0.05, doorZ],
materials.stone
);
// Vertical timber planks.
const plankCount = 5;
const plankWidth = doorWidth / plankCount;
for (let i = 0; i < plankCount; i++) {
const z = doorZ - doorWidth / 2 + (i + 0.5) * plankWidth;
cube(
world,
[0.12, doorHeight, plankWidth - 0.018],
[doorX, doorCenterY, z],
i % 2 === 0 ? materials.timber : materials.timberLight
);
}
// Heavy timber frame.
cube(
world,
[0.18, 2.55, 0.13],
[3.14, landingTop + 1.28, doorZ - 0.68],
materials.timberDark
);
cube(
world,
[0.18, 2.55, 0.13],
[3.14, landingTop + 1.28, doorZ + 0.68],
materials.timberDark
);
cube(
world,
[0.20, 0.17, 1.50],
[3.13, landingTop + 2.53, doorZ],
materials.timberDark
);
// Recessed decorative timber panels.
cube(
world,
[0.028, 1.76, 0.40],
[3.222, landingTop + 1.27, doorZ - 0.27],
materials.timberDark
);
cube(
world,
[0.028, 1.76, 0.40],
[3.222, landingTop + 1.27, doorZ + 0.27],
materials.timberDark
);
// Brass studs and a simple pull.
for (const y of [landingTop + 0.62, landingTop + 2.08]) {
for (const z of [doorZ - 0.43, doorZ + 0.43]) {
cube(
world,
[0.065, 0.075, 0.075],
[3.205, y, z],
materials.brass
);
}
}
cube(
world,
[0.085, 0.24, 0.075],
[3.16, landingTop + 1.10, doorZ + 0.47],
materials.brass
);
// ------------------------------------------------------------
// Small San Blas plaque, generated locally
// ------------------------------------------------------------
const plaqueCanvas = document.createElement("canvas");
plaqueCanvas.width = 512;
plaqueCanvas.height = 160;
const plaqueContext = plaqueCanvas.getContext("2d");
plaqueContext.fillStyle = "#4b3023";
plaqueContext.fillRect(0, 0, 512, 160);
plaqueContext.strokeStyle = "#c6a35d";
plaqueContext.lineWidth = 8;
plaqueContext.strokeRect(9, 9, 494, 142);
plaqueContext.fillStyle = "#ead5a0";
plaqueContext.textAlign = "center";
plaqueContext.font = "700 48px Georgia";
plaqueContext.fillText("SAN BLAS", 256, 72);
plaqueContext.font = "600 23px sans-serif";
plaqueContext.fillText("CUSCO · PERÚ", 256, 119);
const plaqueTexture = new THREE.CanvasTexture(plaqueCanvas);
plaqueTexture.colorSpace = THREE.SRGBColorSpace;
plaqueTexture.magFilter = THREE.NearestFilter;
plaqueTexture.minFilter = THREE.NearestFilter;
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(1.12, 0.35),
new THREE.MeshStandardMaterial({
map: plaqueTexture,
roughness: 0.88
})
);
plaque.rotation.y = -Math.PI / 2;
plaque.position.set(2.985, landingTop + 2.96, doorZ);
plaque.receiveShadow = true;
world.add(plaque);
// ------------------------------------------------------------
// Blocky wall lantern
// ------------------------------------------------------------
cube(
world,
[0.48, 0.065, 0.08],
[2.78, landingTop + 2.84, 0.69],
materials.timberDark
);
cube(
world,
[0.07, 0.32, 0.07],
[2.56, landingTop + 2.69, 0.69],
materials.timberDark
);
cube(
world,
[0.25, 0.32, 0.25],
[2.53, landingTop + 2.46, 0.69],
materials.lamp
);
cube(
world,
[0.34, 0.07, 0.34],
[2.53, landingTop + 2.66, 0.69],
materials.timberDark
);
cube(
world,
[0.34, 0.07, 0.34],
[2.53, landingTop + 2.26, 0.69],
materials.timberDark
);
const lampLight = new THREE.PointLight(0xffa94c, 6, 4, 2);
lampLight.position.set(2.28, landingTop + 2.44, 0.69);
world.add(lampLight);
// ------------------------------------------------------------
// Foreground terracotta planter with a voxel plant
// ------------------------------------------------------------
const planterX = -2.18;
const planterZ = 6.55;
cube(
world,
[0.54, 0.42, 0.54],
[planterX, 0.21, planterZ],
materials.terracotta
);
cube(
world,
[0.58, 0.10, 0.58],
[planterX, 0.42, planterZ],
materials.roof
);
cube(
world,
[0.40, 0.04, 0.40],
[planterX, 0.48, planterZ],
materials.soil
);
cube(
world,
[0.12, 0.52, 0.12],
[planterX, 0.73, planterZ],
materials.leaf
);
cube(
world,
[0.13, 0.42, 0.13],
[planterX - 0.17, 0.67, planterZ + 0.03],
materials.leafLight
);
cube(
world,
[0.13, 0.38, 0.13],
[planterX + 0.18, 0.63, planterZ],
materials.leaf
);
cube(
world,
[0.12, 0.34, 0.12],
[planterX + 0.02, 0.91, planterZ - 0.13],
materials.leafLight
);
cube(
world,
[0.12, 0.30, 0.12],
[planterX - 0.07, 0.82, planterZ + 0.17],
materials.leaf
);
// ------------------------------------------------------------
// Custom camera controls — no addons
// ------------------------------------------------------------
const pointers = new Map();
let lastPinchDistance = 0;
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function pan(dx, dy) {
const right = new THREE.Vector3();
const up = new THREE.Vector3();
camera.matrixWorld.extractBasis(right, up, new THREE.Vector3());
const scale = 0.012 / view.zoom;
view.target.addScaledVector(right, -dx * scale);
view.target.addScaledVector(up, dy * scale);
}
function resetView() {
view.target.set(0.2, 3.0, -0.25);
view.theta = -0.72;
view.phi = 1.08;
view.zoom = window.innerWidth / window.innerHeight < 0.8 ? 0.82 : 1;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
button: event.button
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
lastPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", (event) => {
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (lastPinchDistance > 0) {
view.zoom = clamp(
view.zoom * (distance / lastPinchDistance),
0.58,
2.6
);
}
lastPinchDistance = distance;
return;
}
if (event.shiftKey || pointer.button === 2) {
pan(dx, dy);
} else {
view.theta -= dx * 0.0055;
view.phi = clamp(view.phi - dy * 0.0045, 0.43, 1.40);
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = 0;
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.zoom = clamp(
view.zoom * Math.exp(-event.deltaY * 0.001),
0.58,
2.6
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
document.querySelector("#reset-view").addEventListener("click", resetView);
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
resetView();
renderer.setAnimationLoop(() => {
updateCamera();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```