Prompt specification
Build or customize the Three.js 3D scene "Craftsperson arranging a Cairo market display" 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: Craftsperson arranging a Cairo market display
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/craftsperson-arranging-a-cairo-market-display-x2898
Scene Description Prompt:
Craftsperson arranging a Cairo market display. Create a compact Khan el-Khalili vignette with an original craftsperson, workbench, and customer. Show fabrication and exchange as separate activities within the small shop space. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (craftsperson-arranging-a-cairo-market-display-x2898):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rami’s Copper Corner — Khan el-Khalili</title>
<style>
:root {
--ink: #241a16;
--cream: #f7e9ce;
--gold: #d9a441;
--teal: #4f9a91;
--panel: rgba(37, 25, 20, 0.88);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9a577;
color: var(--cream);
font-family: Georgia, "Times New Roman", serif;
}
button {
font: inherit;
}
#app,
#app canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#app canvas {
display: block;
cursor: grab;
touch-action: none;
}
#app canvas.dragging {
cursor: grabbing;
}
.story {
position: fixed;
top: 24px;
left: 24px;
z-index: 10;
width: min(360px, calc(100vw - 48px));
padding: 20px 22px 18px;
border: 1px solid rgba(255, 224, 172, 0.22);
border-radius: 4px;
background:
linear-gradient(135deg, rgba(70, 45, 32, 0.94), rgba(31, 23, 20, 0.9));
box-shadow: 0 18px 50px rgba(50, 27, 13, 0.22);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--gold);
font: 700 10px/1.2 system-ui, sans-serif;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.arabic {
margin-bottom: 7px;
color: #efd39b;
font-size: 20px;
direction: rtl;
}
h1 {
margin: 0;
color: #fff3dc;
font-size: clamp(27px, 4vw, 39px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.story p {
margin: 12px 0 0;
color: rgba(255, 239, 211, 0.74);
font: 13px/1.55 system-ui, sans-serif;
}
.zones {
position: fixed;
z-index: 20;
bottom: 24px;
left: 50%;
display: flex;
gap: 8px;
padding: 7px;
transform: translateX(-50%);
border: 1px solid rgba(255, 232, 194, 0.2);
border-radius: 7px;
background: var(--panel);
box-shadow: 0 16px 40px rgba(40, 23, 14, 0.24);
backdrop-filter: blur(12px);
}
.zones button {
min-width: 106px;
padding: 10px 14px;
border: 1px solid transparent;
border-radius: 4px;
background: transparent;
color: #d9c8ae;
cursor: pointer;
font: 700 11px/1 system-ui, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: 160ms ease;
}
.zones button:hover,
.zones button.active {
border-color: rgba(217, 164, 65, 0.35);
background: rgba(217, 164, 65, 0.13);
color: #ffe6b3;
}
.zones .fabrication.active {
border-color: rgba(211, 131, 71, 0.5);
background: rgba(211, 131, 71, 0.16);
}
.zones .exchange.active {
border-color: rgba(79, 154, 145, 0.5);
background: rgba(79, 154, 145, 0.16);
}
.hint {
position: fixed;
right: 24px;
bottom: 26px;
z-index: 10;
color: rgba(255, 239, 212, 0.76);
font: 11px/1.45 system-ui, sans-serif;
text-align: right;
text-shadow: 0 2px 7px rgba(30, 18, 10, 0.45);
pointer-events: none;
}
.scene-pin {
position: fixed;
top: 0;
left: 0;
z-index: 15;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
transform: translate(-1000px, -1000px);
border: 1px solid rgba(255, 231, 188, 0.28);
border-radius: 3px;
background: rgba(34, 24, 19, 0.83);
color: #ffe5b3;
cursor: pointer;
font: 700 9px/1 system-ui, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
box-shadow: 0 7px 22px rgba(25, 14, 8, 0.2);
backdrop-filter: blur(8px);
}
.scene-pin::before {
width: 6px;
height: 6px;
content: "";
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 9px var(--gold);
}
.scene-pin.exchange::before {
background: var(--teal);
box-shadow: 0 0 9px var(--teal);
}
.loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #c9a577;
color: #4b3022;
font: 700 12px/1 system-ui, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
.loading.done {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.story {
top: 14px;
left: 14px;
width: min(310px, calc(100vw - 28px));
padding: 15px 17px;
}
.story p,
.arabic {
display: none;
}
.zones {
bottom: 14px;
width: calc(100vw - 28px);
}
.zones button {
flex: 1;
min-width: 0;
padding: 11px 7px;
font-size: 9px;
}
.hint {
display: none;
}
.scene-pin {
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<header class="story">
<div class="eyebrow">Khan el-Khalili · Cairo</div>
<div class="arabic" dir="rtl">خان الخليلي</div>
<h1>Rami’s<br>Copper Corner</h1>
<p>
Rami fashions copper in the workshop bay while a customer exchanges
a finished tray and coins at the neighboring sales counter.
</p>
</header>
<nav class="zones" aria-label="Scene views">
<button class="fabrication active" data-zone="fabrication">Fabrication</button>
<button class="exchange" data-zone="exchange">Exchange</button>
<button data-zone="overview">Overview</button>
</nav>
<button class="scene-pin" id="pinFabrication" data-zone="fabrication">
01 · Fabrication
</button>
<button class="scene-pin exchange" id="pinExchange" data-zone="exchange">
02 · Exchange
</button>
<div class="hint">
Drag to orbit · Scroll to zoom<br>
Double-click to return · Click a sign
</div>
<div class="loading" id="loading">Building the market stall…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const app = document.getElementById("app");
const loading = document.getElementById("loading");
const reduceMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel market scene in Khan el-Khalili"
);
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd2b184);
scene.fog = new THREE.Fog(0xd2b184, 15, 31);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
60
);
const clock = new THREE.Clock();
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function getMaterial(
color,
metalness = 0,
roughness = 0.82,
emissive = 0x000000,
emissiveIntensity = 1
) {
const key = [
color,
metalness,
roughness,
emissive,
emissiveIntensity
].join("|");
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
metalness,
roughness,
emissive,
emissiveIntensity,
flatShading: true
})
);
}
return materialCache.get(key);
}
function block(
parent,
width,
height,
depth,
x,
y,
z,
color,
options = {}
) {
const mesh = new THREE.Mesh(
cubeGeometry,
options.material ||
getMaterial(
color,
options.metalness ?? 0,
options.roughness ?? 0.82,
options.emissive ?? 0x000000,
options.emissiveIntensity ?? 1
)
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.rotation.set(
options.rx ?? 0,
options.ry ?? 0,
options.rz ?? 0
);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function batchBlocks(items, parent = scene) {
const groups = new Map();
for (const item of items) {
const metalness = item.metalness ?? 0;
const roughness = item.roughness ?? 0.86;
const key = `${item.color}|${metalness}|${roughness}`;
if (!groups.has(key)) {
groups.set(key, {
items: [],
metalness,
roughness
});
}
groups.get(key).items.push(item);
}
for (const group of groups.values()) {
const material = getMaterial(
group.items[0].color,
group.metalness,
group.roughness
);
const mesh = new THREE.InstancedMesh(
cubeGeometry,
material,
group.items.length
);
const helper = new THREE.Object3D();
group.items.forEach((item, index) => {
helper.position.fromArray(item.pos);
helper.scale.fromArray(item.size);
helper.rotation.set(
item.rx ?? 0,
item.ry ?? 0,
item.rz ?? 0
);
helper.updateMatrix();
mesh.setMatrixAt(index, helper.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.frustumCulled = false;
parent.add(mesh);
}
}
// Deterministic random values keep the market composition stable.
let randomSeed = 1937;
function random() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function choose(items) {
return items[Math.floor(random() * items.length)];
}
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xffedcf, 0x684633, 2.15));
const sun = new THREE.DirectionalLight(0xffd49a, 3.4);
sun.position.set(-7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0004;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const warmFill = new THREE.PointLight(0xff9b54, 24, 8, 2);
warmFill.position.set(0, 3.6, 1.4);
scene.add(warmFill);
// ------------------------------------------------------------
// Voxel architecture
// ------------------------------------------------------------
const floorColors = [
"#a87b51",
"#b68a5e",
"#9e714c",
"#c09568",
"#a87850",
"#b98c5d"
];
const wallColors = [
"#c9a579",
"#d0ad80",
"#bf9870",
"#d7b88c",
"#c3a075",
"#caa77c"
];
const floorBlocks = [];
for (let x = 0; x < 18; x++) {
for (let z = 0; z < 18; z++) {
floorBlocks.push({
pos: [(x - 8.5) * 0.55, -0.08, (z - 8.5) * 0.55],
size: [0.51, 0.14, 0.51],
color: choose(floorColors)
});
}
}
batchBlocks(floorBlocks);
const wallBlocks = [];
// Back wall.
for (let x = 0; x < 18; x++) {
for (let y = 0; y < 16; y++) {
wallBlocks.push({
pos: [
(x - 8.5) * 0.55,
0.14 + y * 0.28,
-5.02
],
size: [0.535, 0.265, 0.32],
color: choose(wallColors)
});
}
}
// Left wall, facing into the shop.
for (let z = 0; z < 18; z++) {
for (let y = 0; y < 16; y++) {
wallBlocks.push({
pos: [
-4.84,
0.14 + y * 0.28,
(z - 8.5) * 0.55
],
size: [0.32, 0.265, 0.535],
color: choose(wallColors)
});
}
}
batchBlocks(wallBlocks);
// Rear-right wall stub.
for (let z = 0; z < 6; z++) {
for (let y = 0; y < 16; y++) {
block(
scene,
0.32,
0.265,
0.535,
4.84,
0.14 + y * 0.28,
-4.7 + z * 0.55,
choose(wallColors)
);
}
}
// Top wooden beam.
block(scene, 9.5, 0.24, 0.42, 0, 4.65, -4.93, "#65422e");
block(scene, 0.42, 0.24, 9.4, -4.79, 4.65, 0, "#65422e");
// Broad stepped market arch in the foreground.
const archBlocks = [];
for (let y = 0; y < 7; y++) {
for (const side of [-1, 1]) {
archBlocks.push({
pos: [side * 4.35, 0.23 + y * 0.44, 2.55],
size: [0.48, 0.42, 0.52],
color: choose(["#c49a6b", "#ba8d60", "#d0a878"])
});
}
}
for (let i = 0; i <= 22; i++) {
const angle = (i / 22) * Math.PI;
archBlocks.push({
pos: [
4.35 * Math.cos(angle),
3.05 + 1.75 * Math.sin(angle),
2.55
],
size: [0.43, 0.43, 0.52],
color: choose(["#c49a6b", "#ba8d60", "#d0a878"])
});
}
batchBlocks(archBlocks);
// Teal mosaic dots tracing the inner arch.
for (let i = 1; i < 22; i += 2) {
const angle = (i / 22) * Math.PI;
block(
scene,
0.13,
0.13,
0.09,
4.02 * Math.cos(angle),
3.05 + 1.45 * Math.sin(angle),
2.83,
i % 4 === 1 ? "#3c847e" : "#d7b35c"
);
}
block(scene, 0.56, 0.56, 0.56, 0, 4.98, 2.55, "#d2ad79");
block(scene, 0.25, 0.25, 0.11, 0, 4.98, 2.86, "#3e8c83");
// ------------------------------------------------------------
// Rugs: two clearly separated activity zones
// ------------------------------------------------------------
block(scene, 3.3, 0.045, 2.25, -2.2, 0.015, -0.25, "#314c58");
block(scene, 2.95, 0.05, 1.9, -2.2, 0.04, -0.25, "#3c5963");
for (let i = 0; i < 10; i++) {
block(
scene,
0.16,
0.055,
0.8,
-3.54 + i * 0.3,
0.075,
-0.25,
i % 2 ? "#c47b4e" : "#d5a44e"
);
}
block(scene, 3.45, 0.045, 2.3, 2.05, 0.015, -0.2, "#7d4032");
block(scene, 3.08, 0.05, 1.96, 2.05, 0.04, -0.2, "#914c39");
for (let i = 0; i < 10; i++) {
block(
scene,
0.15,
0.055,
0.65,
0.83 + i * 0.27,
0.075,
-0.2,
i % 2 ? "#d4b15b" : "#4d8c83"
);
}
// ------------------------------------------------------------
// Pixel-block signs
// ------------------------------------------------------------
const pixelFont = {
A: ["010", "101", "111", "101", "101"],
B: ["110", "101", "110", "101", "110"],
C: ["111", "100", "100", "100", "111"],
D: ["110", "101", "101", "101", "110"],
E: ["111", "100", "110", "100", "111"],
F: ["111", "100", "110", "100", "100"],
G: ["111", "100", "101", "101", "111"],
H: ["101", "101", "111", "101", "101"],
I: ["111", "010", "010", "010", "111"],
N: ["101", "111", "111", "111", "101"],
O: ["111", "101", "101", "101", "111"],
R: ["110", "101", "110", "101", "101"],
S: ["111", "100", "111", "001", "111"],
T: ["111", "010", "010", "010", "010"],
X: ["101", "101", "010", "101", "101"]
};
const signMeshes = [];
function pixelSign(text, x, y, z, width, letterColor) {
const board = block(
scene,
width,
0.62,
0.12,
x,
y,
z,
"#30231d"
);
board.userData.zone = text === "FABRICATION"
? "fabrication"
: "exchange";
signMeshes.push(board);
const pixel = 0.083;
const spacing = 4;
const textWidth = (text.length * spacing - 1) * pixel;
const startX = x - textWidth / 2;
const topY = y + 2 * pixel;
[...text].forEach((letter, letterIndex) => {
const pattern = pixelFont[letter];
pattern.forEach((row, rowIndex) => {
[...row].forEach((cell, columnIndex) => {
if (cell !== "1") return;
block(
scene,
pixel * 0.88,
pixel * 0.88,
0.055,
startX + (letterIndex * spacing + columnIndex) * pixel,
topY - rowIndex * pixel,
z + 0.087,
letterColor,
{ emissive: letterColor, emissiveIntensity: 0.22 }
);
});
});
});
block(
scene,
width - 0.18,
0.055,
0.04,
x,
y - 0.27,
z + 0.085,
letterColor
);
}
pixelSign("FABRICATION", -2.1, 4.04, -4.70, 3.82, "#e0a24a");
pixelSign("EXCHANGE", 2.05, 4.04, -4.70, 2.82, "#65b1a4");
// ------------------------------------------------------------
// Back-wall shelves and workshop dressing
// ------------------------------------------------------------
// Central display niche.
block(scene, 1.75, 0.13, 0.56, 0, 1.62, -4.52, "#714a31");
block(scene, 1.75, 0.13, 0.56, 0, 2.38, -4.52, "#714a31");
block(scene, 1.75, 0.13, 0.56, 0, 3.14, -4.52, "#714a31");
// Jars and folded cloth.
const jarColors = ["#477b75", "#a65f43", "#d1a24e", "#705052"];
for (let i = 0; i < 4; i++) {
block(
scene,
0.23,
0.34,
0.23,
-0.55 + i * 0.37,
1.86,
-4.46,
jarColors[i]
);
block(
scene,
0.26,
0.08,
0.26,
-0.55 + i * 0.37,
2.06,
-4.46,
"#b98a50"
);
}
block(scene, 0.75, 0.16, 0.36, -0.26, 2.58, -4.44, "#496d78");
block(scene, 0.68, 0.14, 0.34, -0.28, 2.75, -4.44, "#bd684b");
block(scene, 0.8, 0.18, 0.37, 0.05, 3.3, -4.42, "#d1aa62");
// Tool board above the workbench.
block(scene, 2.8, 1.55, 0.13, -2.2, 2.85, -4.72, "#4c3426");
for (let i = 0; i < 5; i++) {
const x = -3.18 + i * 0.49;
block(scene, 0.075, 0.58, 0.075, x, 2.77, -4.60, "#aa7743");
block(scene, 0.24, 0.16, 0.11, x, 3.08, -4.60, "#8e9290", {
metalness: 0.55,
roughness: 0.48
});
}
block(scene, 1.0, 0.13, 0.13, -2.75, 2.31, -4.58, "#9c6d3f");
block(scene, 0.45, 0.15, 0.12, -2.18, 2.31, -4.58, "#9b9e98", {
metalness: 0.5
});
// Shelves above the exchange counter.
block(scene, 3.0, 0.13, 0.5, 2.18, 2.62, -4.53, "#69452f");
const shelfCloth = [
"#d7a448",
"#3d7773",
"#a64d3d",
"#d5c29b",
"#5a6683"
];
for (let i = 0; i < 6; i++) {
block(
scene,
0.34,
0.34 + (i % 3) * 0.09,
0.35,
0.96 + i * 0.46,
2.87,
-4.47,
shelfCloth[i % shelfCloth.length]
);
}
// ------------------------------------------------------------
// Fabrication workbench
// ------------------------------------------------------------
const bench = new THREE.Group();
bench.position.set(-2.2, 0, -0.45);
scene.add(bench);
for (const x of [-1.05, 1.05]) {
for (const z of [-0.43, 0.43]) {
block(bench, 0.22, 1.27, 0.22, x, 0.635, z, "#65442e");
}
}
block(bench, 2.4, 0.18, 0.12, 0, 0.45, 0, "#765035");
block(bench, 2.55, 0.2, 1.15, 0, 1.33, 0, "#845a3a");
for (let i = 0; i < 4; i++) {
block(
bench,
2.58,
0.17,
0.26,
0,
1.35,
(i - 1.5) * 0.285,
i % 2 ? "#8c603d" : "#7b5134"
);
}
block(bench, 2.3, 0.35, 0.13, 0, 1.1, 0.54, "#68442f");
for (const x of [-0.58, 0.58]) {
block(bench, 0.48, 0.22, 0.08, x, 1.1, 0.62, "#9b6b3e");
block(bench, 0.08, 0.08, 0.08, x, 1.1, 0.68, "#c79a52", {
metalness: 0.5
});
}
// Anvil and copper blank.
block(bench, 0.72, 0.12, 0.52, 0, 1.49, 0.04, "#4c5150");
block(bench, 0.34, 0.22, 0.34, 0, 1.65, 0.04, "#5d625f");
block(bench, 0.9, 0.14, 0.43, 0, 1.81, 0.04, "#686d68", {
metalness: 0.45,
roughness: 0.48
});
block(bench, 0.57, 0.06, 0.43, 0, 1.91, 0.04, "#b76c38", {
metalness: 0.68,
roughness: 0.36
});
// Small vise and hand tools.
block(bench, 0.36, 0.28, 0.28, 1.0, 1.57, 0.03, "#4f5754", {
metalness: 0.45
});
block(bench, 0.13, 0.36, 0.34, 1.28, 1.58, 0.03, "#656b67", {
metalness: 0.45
});
block(bench, 0.33, 0.07, 0.07, 1.43, 1.58, 0.03, "#9a713f");
for (let i = 0; i < 3; i++) {
block(
bench,
0.62,
0.055,
0.13,
-0.87,
1.47 + i * 0.06,
-0.24 + i * 0.12,
"#bc7840",
{ metalness: 0.65, roughness: 0.38 }
);
}
// ------------------------------------------------------------
// Craftsperson Rami
// ------------------------------------------------------------
const rami = new THREE.Group();
rami.position.set(-2.2, 0, -1.65);
scene.add(rami);
// Shoes and trousers.
block(rami, 0.4, 0.22, 0.62, -0.3, 0.13, 0.08, "#372820");
block(rami, 0.4, 0.22, 0.62, 0.3, 0.13, 0.08, "#372820");
block(rami, 0.4, 0.87, 0.43, -0.3, 0.67, 0, "#514235");
block(rami, 0.4, 0.87, 0.43, 0.3, 0.67, 0, "#514235");
// Shirt, apron and belt.
block(rami, 0.98, 1.12, 0.58, 0, 1.68, 0, "#d9c9a5");
block(rami, 0.77, 0.92, 0.09, 0, 1.63, 0.33, "#357e78");
block(rami, 1.01, 0.14, 0.62, 0, 1.37, 0, "#5a3c29");
block(rami, 0.16, 0.13, 0.09, 0, 1.37, 0.35, "#d7a64c", {
metalness: 0.55
});
// Neck and head.
block(rami, 0.31, 0.24, 0.32, 0, 2.3, 0, "#a96845");
block(rami, 0.62, 0.62, 0.56, 0, 2.76, 0, "#ad7049");
// Rust-colored head wrap.
block(rami, 0.69, 0.19, 0.61, 0, 3.07, 0, "#a5503e");
block(rami, 0.68, 0.31, 0.16, 0, 2.98, 0.23, "#bb5c44");
block(rami, 0.16, 0.42, 0.16, -0.29, 2.91, -0.05, "#984735");
// Eyes, nose, and blocky beard.
block(rami, 0.08, 0.08, 0.04, -0.15, 2.82, 0.3, "#211914");
block(rami, 0.08, 0.08, 0.04, 0.15, 2.82, 0.3, "#211914");
block(rami, 0.13, 0.15, 0.11, 0, 2.7, 0.34, "#b97850");
block(rami, 0.49, 0.14, 0.1, 0, 2.5, 0.29, "#382820");
block(rami, 0.13, 0.31, 0.1, -0.16, 2.64, 0.29, "#382820");
block(rami, 0.13, 0.31, 0.1, 0.16, 2.64, 0.29, "#382820");
// Distinctive square brass spectacles.
for (const x of [-0.15, 0.15]) {
block(rami, 0.19, 0.18, 0.035, x, 2.82, 0.345, "#d0a04d", {
metalness: 0.7,
roughness: 0.35
});
block(rami, 0.19, 0.035, 0.035, x, 2.89, 0.365, "#d0a04d", {
metalness: 0.7
});
block(rami, 0.19, 0.035, 0.035, x, 2.75, 0.365, "#d0a04d", {
metalness: 0.7
});
block(rami, 0.035, 0.18, 0.035, x + (x < 0 ? -0.085 : 0.085), 2.82, 0.365, "#d0a04d", {
metalness: 0.7
});
}
block(rami, 0.08, 0.035, 0.035, 0, 2.82, 0.37, "#d0a04d", {
metalness: 0.7
});
// Left arm rests near the workbench.
block(rami, 0.3, 0.58, 0.34, -0.58, 1.94, 0.05, "#d9c9a5");
block(rami, 0.28, 0.28, 0.7, -0.61, 1.61, 0.37, "#aa6b47");
block(rami, 0.28, 0.25, 0.28, -0.61, 1.59, 0.79, "#ad7049");
block(rami, 0.3, 0.08, 0.3, -0.61, 1.47, 0.79, "#c58a43", {
metalness: 0.45
});
// Animated hammering arm.
const hammerArm = new THREE.Group();
hammerArm.position.set(0.56, 2.15, 0.02);
rami.add(hammerArm);
block(hammerArm, 0.3, 0.55, 0.34, 0, -0.18, 0.12, "#d9c9a5");
block(hammerArm, 0.28, 0.28, 0.68, 0, -0.25, 0.48, "#aa6b47");
block(hammerArm, 0.29, 0.25, 0.28, 0, -0.25, 0.85, "#ad7049");
block(hammerArm, 0.33, 0.07, 0.33, 0, -0.2, 0.85, "#bc8240", {
metalness: 0.45
});
block(hammerArm, 0.1, 0.1, 0.44, 0, -0.25, 1.08, "#9e6b3d");
block(hammerArm, 0.4, 0.22, 0.22, 0, -0.25, 1.32, "#747a75", {
metalness: 0.65,
roughness: 0.38
});
// ------------------------------------------------------------
// Exchange counter
// ------------------------------------------------------------
const counter = new THREE.Group();
counter.position.set(2.05, 0, -0.35);
scene.add(counter);
block(counter, 3.55, 0.2, 1.15, 0, 1.28, 0, "#754a30");
for (let i = 0; i < 5; i++) {
block(
counter,
3.58,
0.16,
0.215,
0,
1.31,
(i - 2) * 0.225,
i % 2 ? "#875a39" : "#75492f"
);
}
block(counter, 3.3, 1.02, 0.12, 0, 0.72, 0.48, "#356f69");
block(counter, 3.45, 0.12, 0.17, 0, 1.17, 0.51, "#d1a34c");
for (const x of [-1.52, 1.52]) {
block(counter, 0.2, 1.22, 0.88, x, 0.61, 0, "#543a2b");
}
// Recessed geometric panels.
for (let i = 0; i < 6; i++) {
block(
counter,
0.32,
0.49,
0.035,
-1.27 + i * 0.5,
0.72,
0.56,
i % 2 ? "#d0a34c" : "#2f5f5b"
);
}
function makeTray(parent, x, y, z, size = 0.7, color = "#b96d38") {
block(parent, size, 0.065, size, x, y, z, color, {
metalness: 0.65,
roughness: 0.38
});
const rim = 0.075;
block(parent, size, rim, rim, x, y + 0.065, z - size / 2 + rim / 2, color, {
metalness: 0.65,
roughness: 0.38
});
block(parent, size, rim, rim, x, y + 0.065, z + size / 2 - rim / 2, color, {
metalness: 0.65,
roughness: 0.38
});
block(parent, rim, rim, size, x - size / 2 + rim / 2, y + 0.065, z, color, {
metalness: 0.65,
roughness: 0.38
});
block(parent, rim, rim, size, x + size / 2 - rim / 2, y + 0.065, z, color, {
metalness: 0.65,
roughness: 0.38
});
}
makeTray(counter, -0.95, 1.44, -0.05, 0.65);
makeTray(counter, -0.13, 1.44, -0.05, 0.82, "#c88743");
// Folded cloth stack.
block(counter, 0.82, 0.13, 0.58, 0.9, 1.48, -0.08, "#3f7376");
block(counter, 0.76, 0.12, 0.55, 0.88, 1.61, -0.08, "#d5b55d");
block(counter, 0.69, 0.11, 0.51, 0.86, 1.73, -0.08, "#a14c3e");
// Coin balance made entirely from blocks.
block(counter, 0.52, 0.09, 0.45, 1.42, 1.45, -0.12, "#65432e");
block(counter, 0.1, 0.78, 0.1, 1.42, 1.82, -0.12, "#b18745", {
metalness: 0.45
});
block(counter, 0.9, 0.075, 0.075, 1.42, 2.19, -0.12, "#c29a50", {
metalness: 0.5
});
for (const x of [1.03, 1.81]) {
block(counter, 0.03, 0.31, 0.03, x, 2.01, -0.12, "#b18745");
block(counter, 0.36, 0.06, 0.36, x, 1.84, -0.12, "#b98243", {
metalness: 0.5
});
block(counter, 0.36, 0.12, 0.045, x, 1.9, -0.285, "#b98243", {
metalness: 0.5
});
block(counter, 0.36, 0.12, 0.045, x, 1.9, 0.045, "#b98243", {
metalness: 0.5
});
block(counter, 0.045, 0.12, 0.29, x - 0.16, 1.9, -0.12, "#b98243", {
metalness: 0.5
});
block(counter, 0.045, 0.12, 0.29, x + 0.16, 1.9, -0.12, "#b98243", {
metalness: 0.5
});
}
// Payment coins.
for (let i = 0; i < 5; i++) {
block(
counter,
0.15,
0.045,
0.15,
0.2 + (i % 3) * 0.16,
1.44,
0.32 + Math.floor(i / 3) * 0.17,
"#d9ae4d",
{ metalness: 0.72, roughness: 0.3 }
);
}
// ------------------------------------------------------------
// Customer
// ------------------------------------------------------------
const customer = new THREE.Group();
customer.position.set(2.15, 0, 0.95);
customer.rotation.y = Math.PI;
scene.add(customer);
block(customer, 0.4, 0.22, 0.6, -0.29, 0.13, 0.02, "#302722");
block(customer, 0.4, 0.22, 0.6, 0.29, 0.13, 0.02, "#302722");
block(customer, 0.4, 0.9, 0.42, -0.29, 0.69, 0, "#765143");
block(customer, 0.4, 0.9, 0.42, 0.29, 0.69, 0, "#765143");
block(customer, 0.92, 1.05, 0.56, 0, 1.65, 0, "#e0d1ae");
block(customer, 0.72, 0.83, 0.1, 0, 1.66, 0.31, "#425c77");
block(customer, 0.76, 0.1, 0.12, 0, 1.3, 0.32, "#354c67");
// Head turns toward Rami.
const customerHead = new THREE.Group();
customerHead.position.set(0, 2.56, 0);
customerHead.rotation.y = Math.PI / 2;
customer.add(customerHead);
block(customerHead, 0.58, 0.59, 0.54, 0, 0, 0, "#b97b53");
block(customerHead, 0.65, 0.18, 0.6, 0, 0.3, 0, "#e9dcc0");
block(customerHead, 0.62, 0.2, 0.17, 0, 0.25, 0.24, "#f1e5cb");
block(customerHead, 0.14, 0.36, 0.16, -0.28, 0.16, 0, "#d6c6a9");
block(customerHead, 0.08, 0.08, 0.04, -0.13, 0.08, 0.29, "#2c211b");
block(customerHead, 0.11, 0.13, 0.1, 0, 0, 0.33, "#bd7d55");
// Arm offering a small textile.
const offerArm = new THREE.Group();
offerArm.position.set(-0.49, 2.02, 0.02);
customer.add(offerArm);
block(offerArm, 0.28, 0.57, 0.31, 0, -0.23, 0.09, "#dfd0ad");
block(offerArm, 0.26, 0.26, 0.67, 0, -0.28, 0.43, "#b77b53");
block(offerArm, 0.27, 0.24, 0.26, 0, -0.28, 0.79, "#b77b53");
block(offerArm, 0.55, 0.1, 0.38, 0, -0.31, 0.94, "#4a8a83");
block(offerArm, 0.5, 0.07, 0.34, 0, -0.23, 0.95, "#d4aa4f");
// Other arm and payment coins.
block(customer, 0.28, 0.58, 0.31, 0.49, 1.95, 0.04, "#dfd0ad");
block(customer, 0.26, 0.27, 0.65, 0.5, 1.65, 0.34, "#b77b53");
block(customer, 0.25, 0.22, 0.25, 0.5, 1.59, 0.7, "#b77b53");
for (let i = 0; i < 2; i++) {
block(
customer,
0.14,
0.04,
0.14,
0.46 + i * 0.13,
1.73,
0.82,
"#d6aa4d",
{ metalness: 0.7 }
);
}
// A woven shoulder bag.
block(customer, 0.52, 0.56, 0.24, 0.58, 1.35, -0.22, "#9a6845");
block(customer, 0.29, 0.08, 0.27, 0.58, 1.66, -0.22, "#b88753");
block(customer, 0.08, 0.65, 0.07, 0.3, 1.7, -0.2, "#b88753", {
ry: -0.18
});
// ------------------------------------------------------------
// Hanging textiles, pottery and small props
// ------------------------------------------------------------
// Pixel-pattern rug hanging on the left wall.
const textilePattern = [
"#9d483a",
"#d1a84f",
"#397b75",
"#d7c293",
"#9d483a"
];
for (let row = 0; row < 8; row++) {
for (let col = 0; col < 5; col++) {
block(
scene,
0.08,
0.22,
0.22,
-4.62,
1.72 + row * 0.24,
0.1 + col * 0.24,
textilePattern[(row + col) % textilePattern.length]
);
}
}
block(scene, 0.09, 0.1, 1.3, -4.61, 3.73, 0.64, "#6a4630");
block(scene, 0.09, 0.1, 1.3, -4.61, 1.52, 0.64, "#6a4630");
function voxelPot(x, z, color, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.05, z);
group.scale.setScalar(scale);
scene.add(group);
block(group, 0.48, 0.12, 0.48, 0, 0.06, 0, "#6d4933");
block(group, 0.63, 0.4, 0.63, 0, 0.32, 0, color);
block(group, 0.73, 0.14, 0.73, 0, 0.57, 0, color);
block(group, 0.56, 0.12, 0.56, 0, 0.7, 0, "#7c5137");
return group;
}
voxelPot(4.15, -2.3, "#b36a42", 0.8);
voxelPot(4.25, -3.25, "#527b74", 0.62);
voxelPot(-4.0, -3.9, "#b27746", 0.68);
// Stack of wooden boxes in the workshop corner.
for (let i = 0; i < 3; i++) {
block(
scene,
0.72,
0.35,
0.65,
-4.05,
0.18 + i * 0.36,
-2.35,
i % 2 ? "#805537" : "#6c472f"
);
}
// ------------------------------------------------------------
// Voxel lanterns
// ------------------------------------------------------------
const lanternLights = [];
function makeLantern(x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
scene.add(group);
for (let i = 0; i < 5; i++) {
block(group, 0.045, 0.09, 0.045, 0, 0.42 + i * 0.1, 0, "#72523a");
}
block(group, 0.31, 0.08, 0.31, 0, 0.39, 0, "#8b6036");
block(group, 0.26, 0.46, 0.26, 0, 0.11, 0, "#ffb75e", {
emissive: "#ff8d32",
emissiveIntensity: 2.3
});
for (const px of [-0.15, 0.15]) {
for (const pz of [-0.15, 0.15]) {
block(group, 0.045, 0.64, 0.045, px, 0.1, pz, "#795036");
}
}
block(group, 0.38, 0.1, 0.38, 0, -0.25, 0, "#795036");
block(group, 0.22, 0.15, 0.22, 0, -0.38, 0, "#a1703f");
const light = new THREE.PointLight(0xff9b4b, 17, 5.5, 2);
light.position.set(x, y, z);
scene.add(light);
lanternLights.push(light);
}
makeLantern(-3.6, 3.55, 1.75, 0.86);
makeLantern(3.55, 3.52, 1.72, 0.86);
makeLantern(0.2, 3.86, -4.25, 0.75);
// ------------------------------------------------------------
// Hammer sparks
// ------------------------------------------------------------
const sparkGroup = new THREE.Group();
sparkGroup.position.set(-2.2, 1.94, -0.41);
scene.add(sparkGroup);
const sparks = [];
for (let i = 0; i < 9; i++) {
const spark = block(
sparkGroup,
0.055,
0.055,
0.055,
0,
0,
0,
i % 2 ? "#ffe49a" : "#ff9c38",
{
emissive: i % 2 ? "#ffd26a" : "#ff792d",
emissiveIntensity: 3,
cast: false
}
);
sparks.push(spark);
}
// ------------------------------------------------------------
// Direct camera controls and animated focus views
// ------------------------------------------------------------
const view = {
target: new THREE.Vector3(0, 1.75, -0.5),
radius: 13.3,
theta: 0.46,
phi: 1.03
};
let cameraTween = null;
const views = {
overview: {
target: new THREE.Vector3(0, 1.75, -0.5),
radius: 13.3,
theta: 0.46,
phi: 1.03
},
fabrication: {
target: new THREE.Vector3(-2.15, 1.95, -0.8),
radius: 7.25,
theta: 0.34,
phi: 1.08
},
exchange: {
target: new THREE.Vector3(2.05, 1.75, -0.25),
radius: 7.15,
theta: 0.12,
phi: 1.08
}
};
function updateCamera() {
const sinPhi = Math.sin(view.phi);
camera.position.set(
view.target.x + view.radius * sinPhi * Math.sin(view.theta),
view.target.y + view.radius * Math.cos(view.phi),
view.target.z + view.radius * sinPhi * Math.cos(view.theta)
);
camera.lookAt(view.target);
}
function focusZone(zone) {
const destination = views[zone];
if (!destination) return;
cameraTween = {
start: performance.now(),
duration: 950,
from: {
target: view.target.clone(),
radius: view.radius,
theta: view.theta,
phi: view.phi
},
to: destination
};
document.querySelectorAll(".zones button").forEach((button) => {
button.classList.toggle("active", button.dataset.zone === zone);
});
}
function easeInOut(t) {
return t < 0.5
? 4 * t * t * t
: 1 - Math.pow(-2 * t + 2, 3) / 2;
}
document.querySelectorAll("[data-zone]").forEach((button) => {
button.addEventListener("click", () => focusZone(button.dataset.zone));
});
const canvas = renderer.domElement;
let dragging = false;
let lastX = 0;
let lastY = 0;
let downX = 0;
let downY = 0;
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
cameraTween = null;
lastX = downX = event.clientX;
lastY = downY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - lastX;
const deltaY = event.clientY - lastY;
view.theta -= deltaX * 0.0055;
view.phi = THREE.MathUtils.clamp(
view.phi - deltaY * 0.0042,
0.5,
1.38
);
lastX = event.clientX;
lastY = event.clientY;
});
canvas.addEventListener("pointerup", (event) => {
dragging = false;
canvas.classList.remove("dragging");
if (Math.hypot(event.clientX - downX, event.clientY - downY) < 5) {
const pointer = new THREE.Vector2(
(event.clientX / innerWidth) * 2 - 1,
-(event.clientY / innerHeight) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(signMeshes, false)[0];
if (hit) focusZone(hit.object.userData.zone);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
canvas.classList.remove("dragging");
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
view.radius = THREE.MathUtils.clamp(
view.radius * Math.exp(event.deltaY * 0.001),
5.3,
19.5
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => focusZone("overview"));
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") view.theta -= 0.08;
if (event.key === "ArrowRight") view.theta += 0.08;
if (event.key === "ArrowUp") {
view.phi = Math.max(0.5, view.phi - 0.06);
}
if (event.key === "ArrowDown") {
view.phi = Math.min(1.38, view.phi + 0.06);
}
if (event.key === "+" || event.key === "=") {
view.radius = Math.max(5.3, view.radius - 0.6);
}
if (event.key === "-" || event.key === "_") {
view.radius = Math.min(19.5, view.radius + 0.6);
}
if (event.key === "Escape") focusZone("overview");
});
// Projected interface pins.
const pinFabrication = document.getElementById("pinFabrication");
const pinExchange = document.getElementById("pinExchange");
const projected = new THREE.Vector3();
function placePin(element, position) {
projected.copy(position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.opacity = visible ? "1" : "0";
element.style.pointerEvents = visible ? "auto" : "none";
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.transform =
`translate(${x}px, ${y}px) translate(-50%, -50%)`;
}
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
function animate(now) {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
if (cameraTween) {
const t = Math.min(
1,
(now - cameraTween.start) / cameraTween.duration
);
const eased = easeInOut(t);
view.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
view.radius = THREE.MathUtils.lerp(
cameraTween.from.radius,
cameraTween.to.radius,
eased
);
view.theta = THREE.MathUtils.lerp(
cameraTween.from.theta,
cameraTween.to.theta,
eased
);
view.phi = THREE.MathUtils.lerp(
cameraTween.from.phi,
cameraTween.to.phi,
eased
);
if (t >= 1) cameraTween = null;
}
if (!reduceMotion) {
// Repeated hammer strike with a quick downstroke and slower return.
const cycle = (time * 1.85) % 1;
let strike;
if (cycle < 0.22) {
strike = THREE.MathUtils.lerp(
-0.45,
0.07,
easeInOut(cycle / 0.22)
);
} else {
strike = THREE.MathUtils.lerp(
0.07,
-0.45,
easeInOut((cycle - 0.22) / 0.78)
);
}
hammerArm.rotation.x = strike;
offerArm.rotation.x = Math.sin(time * 0.85) * 0.025;
// Tiny voxel sparks during the impact.
sparkGroup.visible = cycle < 0.22;
if (sparkGroup.visible) {
const impact = cycle / 0.22;
sparks.forEach((spark, i) => {
const u = (impact + i * 0.137) % 1;
const spread = 0.16 + i * 0.012;
spark.position.set(
Math.sin(i * 2.7) * spread * u,
u * 0.5,
Math.cos(i * 1.9) * spread * u
);
const scale = 0.065 * (1 - u);
spark.scale.set(scale, scale, scale);
});
}
lanternLights.forEach((light, i) => {
light.intensity =
17 + Math.sin(time * 3.4 + i * 2.1) * 1.2 +
Math.sin(time * 7.1 + i) * 0.45;
});
}
updateCamera();
placePin(pinFabrication, new THREE.Vector3(-2.1, 4.55, -4.55));
placePin(pinExchange, new THREE.Vector3(2.05, 4.55, -4.55));
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
});
updateCamera();
requestAnimationFrame(animate);
requestAnimationFrame(() => {
loading.classList.add("done");
setTimeout(() => loading.remove(), 550);
});
</script>
</body>
</html>
```