Prompt specification
Build or customize the Three.js 3D scene "Marco Zero pavement motif fragment" 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: Marco Zero pavement motif fragment
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/marco-zero-pavement-motif-fragment-x2693
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a small voxel pavement fragment associated with Recife's Marco Zero. Use a selected reference to establish the pavement's visual character, then simplify it into a bounded arrangement of contrasting stone-colored blocks. Show the surface thickness, edge border, and a small adjoining strip of ordinary paving so it reads as part of a public square. Keep the camera close and oblique, with an overhead view available to inspect the pattern. Treat the motif as a selective stylization, not an exact reproduction of the artwork. The scene should remain focused on the pavement piece rather than expand into the whole waterfront.
Working Three.js Starter (marco-zero-pavement-motif-fragment-x2693):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Marco Zero — Recife Voxel Pavement</title>
<style>
:root {
--ink: #242621;
--paper: #e7dfd0;
--muted: rgba(36, 38, 33, 0.62);
--line: rgba(36, 38, 33, 0.18);
--glass: rgba(239, 233, 220, 0.82);
--accent: #8b6335;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9c1b3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
a {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
outline: none;
}
#scene:active {
cursor: grabbing;
}
.atmosphere {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(90deg, rgba(20, 22, 19, 0.13), transparent 27%),
linear-gradient(180deg, rgba(20, 22, 19, 0.12), transparent 22%);
mix-blend-mode: multiply;
}
.chrome {
position: fixed;
inset: 0;
pointer-events: none;
}
.intro {
position: absolute;
top: clamp(22px, 4vw, 52px);
left: clamp(22px, 4.5vw, 72px);
width: min(430px, calc(100vw - 44px));
text-shadow: 0 1px 12px rgba(239, 233, 220, 0.45);
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 13px;
color: rgba(36, 38, 33, 0.7);
font-size: 10px;
font-weight: 760;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 1px;
content: "";
background: currentColor;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(38px, 5.6vw, 72px);
font-weight: 400;
line-height: 0.92;
letter-spacing: -0.045em;
}
h1 em {
display: block;
margin-top: 8px;
color: rgba(36, 38, 33, 0.66);
font-size: 0.42em;
font-style: italic;
letter-spacing: -0.015em;
}
.lede {
max-width: 350px;
margin: 22px 0 0;
color: rgba(36, 38, 33, 0.73);
font-size: 13px;
line-height: 1.65;
}
.view-switch {
position: absolute;
top: clamp(20px, 3vw, 38px);
right: clamp(20px, 3.5vw, 52px);
display: flex;
gap: 4px;
padding: 4px;
border: 1px solid rgba(36, 38, 33, 0.16);
border-radius: 999px;
background: rgba(239, 233, 220, 0.72);
box-shadow: 0 12px 35px rgba(35, 33, 27, 0.09);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.view-switch button {
min-height: 36px;
padding: 0 15px;
border: 0;
border-radius: 999px;
color: rgba(36, 38, 33, 0.68);
background: transparent;
cursor: pointer;
font-size: 10px;
font-weight: 720;
letter-spacing: 0.11em;
text-transform: uppercase;
transition:
color 180ms ease,
background 180ms ease,
box-shadow 180ms ease;
}
.view-switch button:hover {
color: var(--ink);
}
.view-switch button.active {
color: #f0e9db;
background: #30322d;
box-shadow: 0 5px 15px rgba(36, 38, 33, 0.18);
}
.spec-card {
position: absolute;
left: clamp(22px, 4.5vw, 72px);
bottom: clamp(22px, 4vw, 48px);
width: min(370px, calc(100vw - 44px));
padding: 17px 18px 16px;
border: 1px solid rgba(36, 38, 33, 0.15);
border-radius: 13px;
background: var(--glass);
box-shadow: 0 20px 55px rgba(41, 37, 29, 0.13);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.spec-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
padding-bottom: 12px;
border-bottom: 1px solid var(--line);
}
.spec-head strong {
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.spec-head span {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.swatches {
display: flex;
gap: 9px;
margin: 14px 0 12px;
}
.swatch {
display: flex;
align-items: center;
gap: 6px;
color: rgba(36, 38, 33, 0.72);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.04em;
}
.swatch i {
display: block;
width: 13px;
height: 13px;
border: 1px solid rgba(36, 38, 33, 0.18);
border-radius: 3px;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.reference {
margin: 0;
color: rgba(36, 38, 33, 0.66);
font-size: 10px;
line-height: 1.55;
}
.reference a {
color: var(--ink);
text-decoration-color: rgba(36, 38, 33, 0.34);
text-underline-offset: 3px;
}
.reference a:hover {
text-decoration-color: currentColor;
}
.hint {
position: absolute;
right: clamp(20px, 3.5vw, 52px);
bottom: clamp(22px, 3.5vw, 42px);
color: rgba(36, 38, 33, 0.58);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.1em;
text-align: right;
text-transform: uppercase;
}
.hint kbd {
display: inline-block;
min-width: 21px;
padding: 3px 5px;
margin-left: 4px;
border: 1px solid rgba(36, 38, 33, 0.2);
border-bottom-width: 2px;
border-radius: 4px;
color: rgba(36, 38, 33, 0.8);
background: rgba(239, 233, 220, 0.48);
font: inherit;
text-align: center;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #c9c1b3;
transition: opacity 450ms ease, visibility 450ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loader {
width: 42px;
height: 42px;
border: 1px solid rgba(36, 38, 33, 0.18);
border-top-color: rgba(36, 38, 33, 0.75);
border-radius: 50%;
animation: spin 900ms linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.error {
max-width: 430px;
padding: 24px;
border-radius: 12px;
background: #eee7da;
color: #33342f;
font-size: 14px;
line-height: 1.6;
}
@media (max-width: 700px) {
.intro {
top: 22px;
}
.lede {
display: none;
}
h1 {
font-size: clamp(35px, 11vw, 54px);
}
.view-switch {
top: auto;
right: 16px;
bottom: 18px;
}
.spec-card {
bottom: 72px;
width: calc(100vw - 32px);
left: 16px;
padding: 13px 14px;
}
.spec-card .swatches,
.spec-card .reference {
display: none;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D view of a stylized voxel pavement fragment inspired by Marco Zero, Recife"></canvas>
<div class="atmosphere"></div>
<main class="chrome">
<header class="intro">
<div class="eyebrow">Recife · Public Square Study</div>
<h1>
Marco Zero
<em>in limestone voxels</em>
</h1>
<p class="lede">
A selective interpretation of Recife’s stepped black-and-cream public-square
paving, reduced to a bounded fragment of raised stone blocks.
</p>
</header>
<nav class="view-switch" aria-label="Camera view">
<button id="oblique" class="active" type="button" aria-pressed="true">Oblique</button>
<button id="overhead" type="button" aria-pressed="false">Overhead</button>
</nav>
<section class="spec-card" aria-label="Material and reference notes">
<div class="spec-head">
<strong>Material palette</strong>
<span id="view-status">Oblique view</span>
</div>
<div class="swatches" aria-hidden="true">
<span class="swatch"><i style="background:#ddd0b5"></i>Limestone</span>
<span class="swatch"><i style="background:#373a35"></i>Basalt</span>
<span class="swatch"><i style="background:#a7834e"></i>Ochre</span>
</div>
<p class="reference">
Visual cue selected from the geometric limestone pavement of Marco Zero,
Recife. This is an artistic simplification, not an archaeological
reconstruction.
<a href="https://commons.wikimedia.org/w/index.php?search=Marco+Zero+Recife&title=Special:MediaSearch&type=image"
target="_blank"
rel="noopener">Reference survey ↗</a>
</p>
</section>
<div class="hint" aria-hidden="true">
Drag to orbit · Scroll to zoom
<br><kbd>O</kbd> overhead <kbd>1</kbd> oblique <kbd>R</kbd> reset
</div>
</main>
<div id="loading" aria-live="polite">
<div class="loader" aria-label="Loading Three.js scene"></div>
</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 loading = document.querySelector("#loading");
const status = document.querySelector("#view-status");
const obliqueButton = document.querySelector("#oblique");
const overheadButton = document.querySelector("#overhead");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.innerHTML = `
<div class="error">
<strong>WebGL is unavailable.</strong><br>
Please open this file in a browser with hardware-accelerated WebGL enabled.
</div>
`;
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#c9c1b3");
scene.fog = new THREE.Fog("#c9c1b3", 27, 62);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(1.45, 0.15, 0);
const actualOrbit = {
azimuth: 0.66,
polar: 0.91,
radius: 17.5
};
const desiredOrbit = {
azimuth: 0.66,
polar: 0.91,
radius: 17.5
};
const views = {
oblique: { azimuth: 0.66, polar: 0.91, radius: 17.5 },
overhead: { azimuth: 0.0, polar: 0.035, radius: 18.5 }
};
function setView(name) {
const view = views[name];
desiredOrbit.azimuth = view.azimuth;
desiredOrbit.polar = view.polar;
desiredOrbit.radius = view.radius;
obliqueButton.classList.toggle("active", name === "oblique");
overheadButton.classList.toggle("active", name === "overhead");
obliqueButton.setAttribute("aria-pressed", String(name === "oblique"));
overheadButton.setAttribute("aria-pressed", String(name === "overhead"));
status.textContent = name === "overhead" ? "Overhead view" : "Oblique view";
}
obliqueButton.addEventListener("click", () => setView("oblique"));
overheadButton.addEventListener("click", () => setView("overhead"));
// Lighting is deliberately restrained so the material and block relief stay legible.
const hemisphere = new THREE.HemisphereLight("#fff5df", "#77756b", 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0d6", 3.1);
sun.position.set(-6, 13, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#c8d0c4", 0.65);
fill.position.set(9, 7, -8);
scene.add(fill);
// A procedural grain map keeps the file entirely self-contained.
function createGrainTexture() {
const size = 128;
const grainCanvas = document.createElement("canvas");
grainCanvas.width = size;
grainCanvas.height = size;
const context = grainCanvas.getContext("2d");
const image = context.createImageData(size, size);
let seed = 83127;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < image.data.length; i += 4) {
const value = 150 + Math.floor(random() * 65);
image.data[i] = value;
image.data[i + 1] = value;
image.data[i + 2] = value;
image.data[i + 3] = 255;
}
context.putImageData(image, 0, 0);
const texture = new THREE.CanvasTexture(grainCanvas);
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(2.5, 2.5);
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const grainTexture = createGrainTexture();
function buildStonePalette(name, hex) {
const base = new THREE.Color(hex);
const variants = [];
for (const adjustment of [-0.022, 0, 0.024]) {
const color = base.clone().offsetHSL(0, 0, adjustment);
const side = color.clone().offsetHSL(0, 0, -0.075);
const top = color.clone().offsetHSL(0, 0, 0.065);
const makeMaterial = (stoneColor) =>
new THREE.MeshStandardMaterial({
color: stoneColor,
roughness: 0.91,
metalness: 0,
bumpMap: grainTexture,
bumpScale: 0.018
});
variants.push([
makeMaterial(side), // +X
makeMaterial(side), // -X
makeMaterial(top), // +Y
makeMaterial(side), // -Y
makeMaterial(side), // +Z
makeMaterial(side) // -Z
]);
}
return { name, variants };
}
const palettes = {
limestone: buildStonePalette("limestone", "#d8ccb0"),
basalt: buildStonePalette("basalt", "#373a35"),
ochre: buildStonePalette("ochre", "#a7834e"),
slate: buildStonePalette("slate", "#777970"),
paver: buildStonePalette("paver", "#aaa79d"),
border: buildStonePalette("border", "#292b27")
};
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function hash(x, z, salt = 0) {
const value = Math.sin(x * 127.1 + z * 311.7 + salt * 74.7) * 43758.5453;
return value - Math.floor(value);
}
function makeStoneMesh(paletteName, width, height, depth, x, y, z, variant = 0) {
const palette = palettes[paletteName];
const mesh = new THREE.Mesh(
unitBox,
palette.variants[variant % palette.variants.length]
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
// Public-square ground: intentionally quiet and without waterfront scenery.
const groundMaterial = new THREE.MeshStandardMaterial({
color: "#bcb5a8",
roughness: 1,
bumpMap: grainTexture,
bumpScale: 0.014
});
const ground = new THREE.Mesh(new THREE.PlaneGeometry(80, 80), groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.045;
ground.receiveShadow = true;
scene.add(ground);
// A soft contact shadow supplements the real-time directional shadow.
function createContactShadow() {
const shadowCanvas = document.createElement("canvas");
shadowCanvas.width = 256;
shadowCanvas.height = 256;
const context = shadowCanvas.getContext("2d");
const gradient = context.createRadialGradient(128, 128, 28, 128, 128, 124);
gradient.addColorStop(0, "rgba(30,30,25,0.48)");
gradient.addColorStop(0.64, "rgba(30,30,25,0.23)");
gradient.addColorStop(1, "rgba(30,30,25,0)");
context.fillStyle = gradient;
context.fillRect(0, 0, 256, 256);
const texture = new THREE.CanvasTexture(shadowCanvas);
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
opacity: 0.68
});
const shadow = new THREE.Mesh(new THREE.PlaneGeometry(18, 12), material);
shadow.rotation.x = -Math.PI / 2;
shadow.position.set(1.4, -0.031, 0);
scene.add(shadow);
}
createContactShadow();
const pavement = new THREE.Group();
scene.add(pavement);
const motifBed = makeStoneMesh(
"border",
11.74,
0.30,
7.98,
0,
0.15,
0
);
pavement.add(motifBed);
// The stepped border exposes the thickness of the fragment.
const borderTop = 0.485;
const borderHeight = borderTop - 0.30;
pavement.add(
makeStoneMesh("border", 0.36, borderHeight, 7.92, -5.61, 0.30 + borderHeight / 2, 0),
makeStoneMesh("border", 0.36, borderHeight, 7.92, 5.61, 0.30 + borderHeight / 2, 0),
makeStoneMesh("border", 11.58, borderHeight, 0.36, 0, 0.30 + borderHeight / 2, -3.78),
makeStoneMesh("border", 11.58, borderHeight, 0.36, 0, 0.30 + borderHeight / 2, 3.78)
);
const columns = 15;
const rows = 10;
const cell = 0.72;
const tileSize = cell - 0.035;
const tileBase = 0.30;
/*
Visual character selected from Marco Zero:
dark stone ground, pale limestone lozenges, and a restrained ochre center.
Manhattan distance creates concentric diamonds whose edges appear stepped
in the square grid. It is intentionally a stylization rather than a copy.
*/
function motifMaterialAt(column, row) {
const distance = Math.abs(column - 7) + Math.abs(row - 4.5);
if (distance <= 1.25) return "ochre";
if (distance <= 3.25) return "limestone";
if (distance <= 5.25) return "basalt";
if (distance <= 7.35) return "limestone";
return "basalt";
}
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const paletteName = motifMaterialAt(column, row);
const variation = Math.floor(hash(column, row, 3) * 3);
const height = 0.135 + hash(column, row, 7) * 0.038;
const x = (column - (columns - 1) / 2) * cell;
const z = (row - (rows - 1) / 2) * cell;
pavement.add(
makeStoneMesh(
paletteName,
tileSize,
height,
tileSize,
x,
tileBase + height / 2,
z,
variation
)
);
}
}
// A narrow adjoining strip of ordinary paving establishes the square context.
const stripStart = 5.86;
const stripWidth = 3.78;
const stripCenter = stripStart + stripWidth / 2;
const stripBed = makeStoneMesh(
"border",
stripWidth,
0.30,
7.98,
stripCenter,
0.15,
0
);
pavement.add(stripBed);
const ordinaryColumns = 4;
const ordinaryRows = 10;
const ordinaryWidth = stripWidth / ordinaryColumns;
const ordinaryDepth = 7.92 / ordinaryRows;
for (let row = 0; row < ordinaryRows; row++) {
for (let column = 0; column < ordinaryColumns; column++) {
const isSlate = hash(column, row, 19) > 0.78;
const paletteName = isSlate ? "slate" : "paver";
const variation = Math.floor(hash(column, row, 23) * 3);
const height = 0.105 + hash(column, row, 29) * 0.026;
const x = stripStart + ordinaryWidth * (column + 0.5);
const z = (row - (ordinaryRows - 1) / 2) * ordinaryDepth;
pavement.add(
makeStoneMesh(
paletteName,
ordinaryWidth - 0.028,
height,
ordinaryDepth - 0.028,
x,
0.30 + height / 2,
z,
variation
)
);
}
}
// Camera controls are implemented directly, without addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
let pointerId = null;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerId = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== pointerId) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredOrbit.azimuth -= deltaX * 0.0055;
desiredOrbit.polar = THREE.MathUtils.clamp(
desiredOrbit.polar + deltaY * 0.004,
0.035,
1.25
);
obliqueButton.classList.remove("active");
overheadButton.classList.remove("active");
status.textContent = "Free inspection";
});
function endDrag(event) {
if (!dragging) return;
dragging = false;
if (pointerId !== null && canvas.hasPointerCapture(pointerId)) {
canvas.releasePointerCapture(pointerId);
}
pointerId = null;
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredOrbit.radius = THREE.MathUtils.clamp(
desiredOrbit.radius * Math.exp(event.deltaY * 0.001),
11.5,
27
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => setView("oblique"));
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "o") setView("overhead");
if (event.key === "1") setView("oblique");
if (event.key.toLowerCase() === "r") setView("oblique");
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const damping = 5.6;
actualOrbit.azimuth = THREE.MathUtils.damp(
actualOrbit.azimuth,
desiredOrbit.azimuth,
damping,
delta
);
actualOrbit.polar = THREE.MathUtils.damp(
actualOrbit.polar,
desiredOrbit.polar,
damping,
delta
);
actualOrbit.radius = THREE.MathUtils.damp(
actualOrbit.radius,
desiredOrbit.radius,
damping,
delta
);
// Preserve the entire fragment on narrow portrait screens.
const narrowScreenCompensation = Math.max(1, 0.96 / camera.aspect);
const radius = actualOrbit.radius * narrowScreenCompensation;
const horizontalRadius = Math.sin(actualOrbit.polar) * radius;
camera.position.set(
target.x + horizontalRadius * Math.sin(actualOrbit.azimuth),
target.y + Math.cos(actualOrbit.polar) * radius,
target.z + horizontalRadius * Math.cos(actualOrbit.azimuth)
);
camera.lookAt(target);
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
requestAnimationFrame(() => loading.classList.add("hidden"));
}
}
animate();
</script>
</body>
</html>
```