Prompt specification
Build or customize the Three.js 3D scene "Vacant shop becomes community studio" 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: Vacant shop becomes community studio
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/vacant-shop-becomes-community-studio-x0543
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts a vacant storefront reused as a community studio, using clean stylized solid forms. Keep the original broad display window and recessed street entrance, then furnish the interior with two craft tables, shared tool storage, and a public noticeboard. Show people arriving from the sidewalk, choosing a workspace, and returning tools to a common rack. Leave a continuous clear route from the doorway through the tables. Retain an old sign frame above the window and reuse the former sales counter for shared supplies.
Working Three.js Starter (vacant-shop-becomes-community-studio-x0543):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Corner Works — Community Studio</title>
<style>
:root {
color-scheme: light;
--ink: #263a3b;
--paper: #f7f0df;
--accent: #d77b5f;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9e3de;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.intro {
position: fixed;
top: 24px;
left: 24px;
width: min(330px, calc(100vw - 48px));
padding: 18px 20px;
color: var(--ink);
background: rgba(247, 240, 223, 0.91);
border: 1px solid rgba(38, 58, 59, 0.14);
border-radius: 14px;
box-shadow: 0 12px 35px rgba(38, 58, 59, 0.12);
backdrop-filter: blur(10px);
pointer-events: none;
}
.eyebrow {
margin: 0 0 6px;
color: #658275;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 25px;
line-height: 1.05;
letter-spacing: -0.035em;
}
.intro p {
margin: 9px 0 12px;
font-size: 13px;
line-height: 1.45;
color: #536766;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.legend span {
padding: 5px 8px;
border-radius: 999px;
background: rgba(102, 139, 121, 0.12);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.controls {
position: fixed;
right: 22px;
top: 22px;
display: flex;
align-items: center;
gap: 10px;
}
button {
border: 1px solid rgba(38, 58, 59, 0.17);
border-radius: 999px;
padding: 9px 14px;
color: var(--ink);
background: rgba(247, 240, 223, 0.94);
box-shadow: 0 7px 22px rgba(38, 58, 59, 0.11);
font: 750 12px/1 inherit;
cursor: pointer;
}
button:hover { background: #fff9ea; }
.hint {
position: fixed;
right: 22px;
bottom: 20px;
padding: 8px 11px;
color: rgba(38, 58, 59, 0.78);
background: rgba(247, 240, 223, 0.78);
border-radius: 8px;
font-size: 11px;
pointer-events: none;
}
@media (max-width: 650px) {
.intro {
top: 12px;
left: 12px;
width: 255px;
padding: 13px 15px;
}
h1 { font-size: 20px; }
.intro p { display: none; }
.controls { top: auto; right: 12px; bottom: 12px; }
.hint { display: none; }
}
</style>
</head>
<body>
<section class="intro">
<p class="eyebrow">Adaptive reuse · neighborhood studio</p>
<h1>Corner Works</h1>
<p>
The former shop keeps its broad display window and recessed doorway.
Inside, a clear central aisle connects shared tables, notices, supplies,
and the common tool rack.
</p>
<div class="legend">
<span>2 craft tables</span>
<span>Shared tools</span>
<span>Clear route</span>
</div>
</section>
<div class="controls">
<button id="resetView" type="button">Reset view</button>
</div>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, lighting, and camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d9e3de");
scene.fog = new THREE.Fog("#d9e3de", 31, 60);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 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",
"A former vacant storefront converted into a community craft studio"
);
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 1.45, -1.65);
let cameraTheta = 0.66;
let cameraPhi = 0.93;
let desiredTheta = cameraTheta;
let desiredPhi = cameraPhi;
let zoom = 1;
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const frustumHeight = Math.max(14.8, 15.2 / aspect);
camera.left = -frustumHeight * aspect / 2;
camera.right = frustumHeight * aspect / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
function updateCamera() {
cameraTheta += (desiredTheta - cameraTheta) * 0.09;
cameraPhi += (desiredPhi - cameraPhi) * 0.09;
const radius = 24;
camera.position.set(
cameraTarget.x + radius * Math.sin(cameraPhi) * Math.sin(cameraTheta),
cameraTarget.y + radius * Math.cos(cameraPhi),
cameraTarget.z + radius * Math.sin(cameraPhi) * Math.cos(cameraTheta)
);
camera.lookAt(cameraTarget);
camera.zoom = zoom;
camera.updateProjectionMatrix();
}
resize();
window.addEventListener("resize", resize);
const ambient = new THREE.AmbientLight("#fff4df", 0.68);
scene.add(ambient);
const hemi = new THREE.HemisphereLight("#eaf7ff", "#a98261", 1.75);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff0d4", 3.1);
sun.position.set(7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9d9e8", 0.8);
fill.position.set(-9, 7, 5);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and reusable geometry helpers
// -------------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...options
});
const M = {
ground: material("#d9e2dc", { roughness: 1 }),
road: material("#687778", { roughness: 1 }),
sidewalk: material("#c8c4b8", { roughness: 0.98 }),
curb: material("#a6a49b", { roughness: 0.95 }),
floor: material("#d6b487", { roughness: 0.9 }),
wall: material("#eee6d3", { roughness: 0.94 }),
facade: material("#b6c7b2", { roughness: 0.9 }),
trim: material("#f1e7cf", { roughness: 0.8 }),
frame: material("#4e6866", { roughness: 0.75 }),
oldMetal: material("#6b6658", { roughness: 0.88, metalness: 0.12 }),
wood: material("#986744", { roughness: 0.85 }),
woodLight: material("#c9905e", { roughness: 0.8 }),
dark: material("#304447", { roughness: 0.76 }),
cream: material("#fff6df", { roughness: 0.92 }),
sage: material("#719781", { roughness: 0.82 }),
coral: material("#d97c60", { roughness: 0.8 }),
blue: material("#6698ad", { roughness: 0.8 }),
mustard: material("#d5aa4e", { roughness: 0.8 }),
purple: material("#8977a4", { roughness: 0.8 }),
cork: material("#b48756", { roughness: 0.95 }),
route: material("#ecdfc6", { roughness: 0.95 }),
skin: material("#c98967", { roughness: 0.9 }),
skinLight: material("#e3ad87", { roughness: 0.9 }),
hair: material("#3e312e", { roughness: 0.95 }),
glass: new THREE.MeshPhysicalMaterial({
color: "#b6deda",
transparent: true,
opacity: 0.16,
roughness: 0.2,
metalness: 0,
depthWrite: false,
side: THREE.DoubleSide
})
};
function addBox(parent, w, h, d, x, y, z, mat, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent, rt, rb, h, x, y, z, mat, segments = 20
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSphere(parent, radius, x, y, z, mat, scale = null) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, 20, 14),
mat
);
mesh.position.set(x, y, z);
if (scale) mesh.scale.set(...scale);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addTorus(parent, radius, tube, x, y, z, mat) {
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 8, 20),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
// Canvas-generated labels keep the file fully standalone.
function makeTextTexture(text, background, foreground, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = options.width || 1024;
canvas.height = options.height ||
Math.max(128, Math.round(canvas.width * (options.aspect || 0.25)));
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (background) {
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
if (options.border) {
ctx.strokeStyle = options.border;
ctx.lineWidth = Math.max(4, canvas.height * 0.035);
ctx.strokeRect(
ctx.lineWidth / 2,
ctx.lineWidth / 2,
canvas.width - ctx.lineWidth,
canvas.height - ctx.lineWidth
);
}
const lines = text.split("\n");
const maxWidth = canvas.width * 0.84;
const maxHeight = canvas.height * 0.68;
let fontSize = Math.min(150, maxHeight / (lines.length * 1.15));
const setFont = () => {
ctx.font = `${options.weight || 800} ${fontSize}px Arial, sans-serif`;
};
setFont();
while (
fontSize > 12 &&
Math.max(...lines.map(line => ctx.measureText(line).width)) > maxWidth
) {
fontSize -= 2;
setFont();
}
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.globalAlpha = options.alpha ?? 1;
const lineHeight = fontSize * 1.16;
const startY = canvas.height / 2 -
(lines.length - 1) * lineHeight / 2;
lines.forEach((line, index) => {
ctx.fillText(line, canvas.width / 2, startY + index * lineHeight);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
return texture;
}
function addLabel(
parent,
text,
width,
height,
x,
y,
z,
background = "#f3e9d3",
foreground = "#34494a",
options = {}
) {
const texture = makeTextTexture(
text, background, foreground,
{
aspect: height / width,
alpha: options.alpha,
border: options.border,
weight: options.weight
}
);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
opacity: options.opacity ?? 1,
side: THREE.DoubleSide,
toneMapped: false
})
);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Ground, sidewalk, building shell, and the continuous clear route
// -------------------------------------------------------------------------
addBox(scene, 70, 0.18, 70, 0, -0.32, 0, M.ground, false);
addBox(scene, 28, 0.12, 9, 0, -0.13, 7.3, M.road, false);
addBox(scene, 15, 0.2, 3.15, 0, 0.03, 1.65, M.sidewalk, false);
addBox(scene, 15, 0.23, 0.18, 0, 0.015, 3.28, M.curb, false);
for (let x = -6; x <= 6; x += 1.5) {
addBox(scene, 0.018, 0.012, 3.05, x, 0.139, 1.65, M.curb, false);
}
// Interior floor and cutaway walls.
addBox(scene, 12.2, 0.24, 7.15, 0, 0, -3.45, M.floor);
addBox(scene, 12.2, 4.5, 0.22, 0, 2.25, -7.02, M.wall);
addBox(scene, 0.22, 4.5, 7.1, -6.08, 2.25, -3.5, M.wall);
// A low cut edge makes the open side read as an architectural model.
addBox(scene, 0.18, 0.3, 7.1, 6.08, 0.15, -3.5, M.trim);
// Flush floor inlay: doorway → turning space → central aisle → rear wall.
// The route stays physically clear of both craft tables and the counter.
addBox(scene, 1.25, 0.018, 2.65, 3.48, 0.131, -0.42, M.route, false);
addBox(scene, 4.75, 0.018, 1.25, 1.61, 0.131, -1.66, M.route, false);
addBox(scene, 1.25, 0.018, 4.05, 0, 0.131, -3.53, M.route, false);
const keepClear = addLabel(
scene, "KEEP\nCLEAR", 1.0, 1.55,
0, 0.148, -3.4,
"#eee2ca", "#8a765e",
{ weight: 800 }
);
keepClear.rotation.x = -Math.PI / 2;
// Small brass route studs.
for (let z = -2.1; z >= -5.25; z -= 0.75) {
const stud = addCylinder(
scene, 0.045, 0.045, 0.018,
0, 0.148, z, M.mustard, 14
);
stud.castShadow = false;
}
// -------------------------------------------------------------------------
// Original facade: broad display window and recessed street entrance
// -------------------------------------------------------------------------
// Window lower wall.
addBox(scene, 6.8, 0.65, 0.36, -2.7, 0.325, 0.08, M.facade);
// Facade piers between the window and doorway, and beside the doorway.
addBox(scene, 1.65, 3.2, 0.36, 1.47, 1.6, 0.08, M.facade);
addBox(scene, 1.45, 3.2, 0.36, 5.28, 1.6, 0.08, M.facade);
// Upper facade beam.
addBox(scene, 12.1, 0.58, 0.38, 0, 3.52, 0.08, M.facade);
// Broad display glazing and old window framing.
addBox(scene, 6.64, 2.47, 0.055, -2.7, 1.96, 0.13, M.glass, false);
addBox(scene, 6.88, 0.14, 0.18, -2.7, 3.31, 0.17, M.frame);
addBox(scene, 6.88, 0.14, 0.18, -2.7, 0.62, 0.17, M.frame);
addBox(scene, 0.14, 2.75, 0.18, -6.1, 1.96, 0.17, M.frame);
addBox(scene, 0.14, 2.75, 0.18, 0.7, 1.96, 0.17, M.frame);
addBox(scene, 0.11, 2.65, 0.18, -2.7, 1.96, 0.17, M.frame);
// Window sill.
addBox(scene, 7.05, 0.14, 0.48, -2.7, 0.58, 0.18, M.trim);
// Recessed entrance returns.
addBox(scene, 0.2, 3.15, 0.72, 2.38, 1.57, 0.37, M.trim);
addBox(scene, 0.2, 3.15, 0.72, 4.52, 1.57, 0.37, M.trim);
addBox(scene, 2.35, 0.2, 0.76, 3.45, 3.14, 0.38, M.trim);
addBox(scene, 2.3, 0.09, 0.75, 3.45, 0.14, 0.38, M.trim);
// Door frame, placed behind the street-facing wall plane.
addBox(scene, 0.13, 3.03, 0.16, 2.48, 1.58, 0.75, M.frame);
addBox(scene, 0.13, 3.03, 0.16, 4.42, 1.58, 0.75, M.frame);
addBox(scene, 2.08, 0.13, 0.16, 3.45, 3.06, 0.75, M.frame);
// Open glass door, hinged inward.
const door = new THREE.Group();
door.position.set(4.36, 0.15, 0.75);
door.rotation.y = -1.03;
scene.add(door);
addBox(door, 1.72, 2.78, 0.045, -0.86, 1.42, 0, M.glass, false);
addBox(door, 0.1, 2.88, 0.12, 0, 1.43, 0, M.frame);
addBox(door, 0.1, 2.88, 0.12, -1.72, 1.43, 0, M.frame);
addBox(door, 1.82, 0.1, 0.12, -0.86, 2.91, 0, M.frame);
addBox(door, 1.82, 0.1, 0.12, -0.86, 0.05, 0, M.frame);
addBox(door, 0.05, 0.38, 0.08, -1.46, 1.35, 0.08, M.mustard);
// Old empty sign frame retained above the broad window.
addBox(scene, 6.95, 0.11, 0.16, -2.7, 4.47, 0.3, M.oldMetal);
addBox(scene, 6.95, 0.11, 0.16, -2.7, 3.72, 0.3, M.oldMetal);
addBox(scene, 0.11, 0.86, 0.16, -6.18, 4.095, 0.3, M.oldMetal);
addBox(scene, 0.11, 0.86, 0.16, 0.78, 4.095, 0.3, M.oldMetal);
// Faded lettering remains inside the old frame.
addLabel(
scene, "VACANT", 3.9, 0.56,
-2.7, 4.08, 0.39,
null, "#ded8c1",
{ alpha: 0.46, weight: 800 }
);
// Contemporary sign at the entrance.
addLabel(
scene, "COMMUNITY\nSTUDIO", 2.2, 0.72,
3.45, 3.99, 0.4,
"#f3e8ce", "#3b5856",
{ border: "#718c7d", weight: 800 }
);
addLabel(
scene, "OPEN · CREATE TOGETHER", 2.4, 0.27,
3.45, 1.58, 0.84,
"#e8dfc8", "#526a66",
{ weight: 700 }
);
// -------------------------------------------------------------------------
// Two craft tables and their shared project materials
// -------------------------------------------------------------------------
function createTable(x, z, topMaterial) {
const table = new THREE.Group();
table.position.set(x, 0, z);
scene.add(table);
addBox(table, 2.95, 0.16, 1.48, 0, 1.42, 0, topMaterial);
addBox(table, 2.65, 0.19, 0.13, 0, 1.19, -0.56, M.wood);
addBox(table, 2.65, 0.19, 0.13, 0, 1.19, 0.56, M.wood);
[-1.28, 1.28].forEach(lx => {
[-0.55, 0.55].forEach(lz => {
addBox(table, 0.14, 1.25, 0.14, lx, 0.735, lz, M.wood);
});
});
return table;
}
const tableA = createTable(-3.1, -3.05, M.woodLight);
const tableB = createTable(3.25, -3.08, M.cream);
// Table A: cutting mat, papers, blocks, and thread.
addBox(tableA, 1.4, 0.025, 0.82, -0.45, 1.515, -0.05, M.sage, false);
const paperA = addBox(
tableA, 0.78, 0.025, 0.56, 0.72, 1.518, 0.24, M.cream, false
);
paperA.rotation.y = 0.13;
addBox(tableA, 0.24, 0.24, 0.24, -0.88, 1.64, 0.04, M.coral);
addBox(tableA, 0.19, 0.19, 0.19, -0.58, 1.625, 0.05, M.mustard);
addBox(tableA, 0.27, 0.15, 0.2, -0.22, 1.59, 0.02, M.blue);
addCylinder(tableA, 0.09, 0.09, 0.22, 1.05, 1.62, -0.32, M.purple);
addCylinder(tableA, 0.08, 0.08, 0.2, 1.22, 1.61, -0.22, M.coral);
// Table B: paper shapes, glue, scissors, and a shared tray.
const paperB = addBox(
tableB, 0.9, 0.025, 0.68, -0.48, 1.515, -0.02, M.cream, false
);
paperB.rotation.y = -0.18;
addBox(tableB, 0.22, 0.22, 0.22, -0.65, 1.64, -0.05, M.coral);
addBox(tableB, 0.22, 0.22, 0.22, -0.3, 1.64, 0.02, M.blue);
addCylinder(tableB, 0.09, 0.11, 0.3, 0.35, 1.66, -0.35, M.mustard);
addBox(tableB, 0.45, 0.06, 0.3, 0.91, 1.54, 0.22, M.sage);
// Simple scissors on the second table.
const scissors = new THREE.Group();
scissors.position.set(0.25, 1.54, 0.28);
scissors.rotation.y = -0.25;
tableB.add(scissors);
addBox(scissors, 0.38, 0.025, 0.055, 0, 0, 0, M.dark);
addBox(scissors, 0.34, 0.025, 0.055, 0.02, 0, 0, M.mustard);
addTorus(scissors, 0.09, 0.025, -0.23, 0, 0.055, M.coral);
addTorus(scissors, 0.09, 0.025, -0.05, 0, 0.055, M.coral);
// A pair of stools, tucked behind the working sides of the tables.
function createStool(x, z, mat) {
const stool = new THREE.Group();
stool.position.set(x, 0, z);
scene.add(stool);
addCylinder(stool, 0.38, 0.38, 0.14, 0, 0.87, 0, mat);
[-0.23, 0.23].forEach(lx => {
[-0.23, 0.23].forEach(lz => {
addBox(stool, 0.09, 0.73, 0.09, lx, 0.48, lz, M.wood);
});
});
}
createStool(-3.75, -4.25, M.sage);
createStool(3.8, -4.28, M.coral);
// -------------------------------------------------------------------------
// Shared tool storage / common return rack
// -------------------------------------------------------------------------
const rack = new THREE.Group();
rack.position.set(-4.25, 0, -6.72);
scene.add(rack);
addBox(rack, 2.55, 2.45, 0.14, 0, 1.46, 0, M.wood);
addBox(rack, 2.33, 2.23, 0.05, 0, 1.46, 0.09, M.woodLight);
addLabel(
rack, "COMMON TOOLS", 1.95, 0.35,
0, 2.44, 0.13,
"#405d59", "#f3e7cc",
{ weight: 800 }
);
const pegY = [0.92, 1.28, 1.66, 2.03];
pegY.forEach(y => {
const peg = addCylinder(
rack, 0.035, 0.035, 0.28, 0, y, 0.24, M.dark, 12
);
peg.rotation.x = Math.PI / 2;
});
// Hanging hammer.
const hammer = new THREE.Group();
hammer.position.set(-0.77, 1.65, 0.28);
rack.add(hammer);
addBox(hammer, 0.09, 0.52, 0.09, 0, 0, 0, M.coral);
addBox(hammer, 0.38, 0.12, 0.13, 0, 0.29, 0, M.dark);
// Hanging brush.
const brush = new THREE.Group();
brush.position.set(-0.25, 1.52, 0.28);
rack.add(brush);
addBox(brush, 0.08, 0.38, 0.08, 0, 0.05, 0, M.mustard);
addBox(brush, 0.13, 0.12, 0.1, 0, -0.18, 0, M.metal || M.dark);
addBox(brush, 0.17, 0.16, 0.1, 0, -0.33, 0, M.coral);
// Hanging scissors.
const rackScissors = new THREE.Group();
rackScissors.position.set(0.32, 1.63, 0.28);
rack.add(rackScissors);
addBox(rackScissors, 0.37, 0.045, 0.055, 0, 0.09, 0, M.dark);
addBox(rackScissors, 0.34, 0.045, 0.055, 0.02, 0.09, 0, M.blue);
addTorus(rackScissors, 0.08, 0.022, -0.2, -0.07, 0, M.blue);
addTorus(rackScissors, 0.08, 0.022, -0.04, -0.07, 0, M.blue);
// Square ruler.
addBox(rack, 0.16, 0.74, 0.07, 0.88, 1.48, 0.27, M.mustard);
addLabel(
rack, "RETURN HERE", 1.45, 0.25,
0, 0.47, 0.14,
"#ead9b9", "#745f48",
{ weight: 800 }
);
// -------------------------------------------------------------------------
// Public noticeboard
// -------------------------------------------------------------------------
const noticeboard = new THREE.Group();
noticeboard.position.set(-0.3, 0, -6.84);
scene.add(noticeboard);
addBox(noticeboard, 3.25, 1.86, 0.13, 0, 2.82, 0, M.wood);
addBox(noticeboard, 3.02, 1.63, 0.06, 0, 2.82, 0.09, M.cork);
addLabel(
noticeboard, "COMMUNITY NOTICEBOARD", 2.55, 0.31,
0, 3.56, 0.14,
"#f2e5ca", "#445e58",
{ weight: 800 }
);
const notices = [
{
x: -0.88, y: 3.05, w: 0.78, h: 0.58,
text: "SATURDAY\nMAKING", bg: "#fff6df", fg: "#526b67"
},
{
x: 0.04, y: 3.08, w: 0.85, h: 0.52,
text: "SKILL SHARE\n2 PM", bg: "#dce9dc", fg: "#456257"
},
{
x: 0.94, y: 3.01, w: 0.66, h: 0.66,
text: "NEIGHBOR\nHOURS", bg: "#f4dfcf", fg: "#805e4e"
},
{
x: -0.68, y: 2.28, w: 0.82, h: 0.46,
text: "FREE MATERIALS", bg: "#e3e5c9", fg: "#5d6748"
},
{
x: 0.31, y: 2.34, w: 0.92, h: 0.42,
text: "CHILDREN WELCOME", bg: "#f5edcf", fg: "#6c6546"
}
];
notices.forEach(note => {
const card = addLabel(
noticeboard, note.text, note.w, note.h,
note.x, note.y, 0.14,
note.bg, note.fg,
{ weight: 700 }
);
card.rotation.z = (note.x + note.y) * 0.12;
addSphere(
noticeboard, 0.045,
note.x, note.y + note.h * 0.42, 0.17,
note.bg === "#f4dfcf" ? M.coral : M.blue,
[1, 1, 0.45]
);
});
// -------------------------------------------------------------------------
// Former sales counter, reused for shared supplies
// -------------------------------------------------------------------------
const counter = new THREE.Group();
counter.position.set(3.65, 0, -5.9);
scene.add(counter);
addBox(counter, 3.65, 1.08, 1.18, 0, 0.66, 0, M.wood);
addBox(counter, 3.88, 0.15, 1.38, 0, 1.27, 0, M.woodLight);
// Old sales-counter drawer divisions remain visible.
for (let x = -1.15; x <= 1.2; x += 1.15) {
addBox(counter, 0.04, 0.92, 0.025, x, 0.68, 0.602, M.oldMetal);
addBox(counter, 0.34, 0.055, 0.06, x, 0.79, 0.64, M.dark);
}
addLabel(
counter, "SHARED SUPPLIES", 2.25, 0.39,
0.37, 0.67, 0.63,
"#ead9ba", "#684f3e",
{ weight: 800 }
);
addLabel(
counter, "REUSED SALES COUNTER", 1.65, 0.21,
-0.87, 0.29, 0.63,
"#ead9ba", "#846b52",
{ weight: 700 }
);
// Supply baskets on the old counter.
function addBasket(parent, x, z, color) {
const basket = new THREE.Group();
basket.position.set(x, 1.35, z);
parent.add(basket);
addBox(basket, 0.74, 0.08, 0.58, 0, 0.04, 0, color);
addBox(basket, 0.74, 0.3, 0.06, 0, 0.2, -0.27, color);
addBox(basket, 0.74, 0.3, 0.06, 0, 0.2, 0.27, color);
addBox(basket, 0.06, 0.3, 0.58, -0.35, 0.2, 0, color);
addBox(basket, 0.06, 0.3, 0.58, 0.35, 0.2, 0, color);
}
addBasket(counter, -1.2, 0.02, M.sage);
addBasket(counter, 0.2, -0.04, M.blue);
addBasket(counter, 1.25, 0.02, M.coral);
// Craft materials visible in the baskets.
addBox(counter, 0.08, 0.48, 0.09, -1.35, 1.59, -0.02, M.mustard);
addBox(counter, 0.08, 0.42, 0.09, -1.08, 1.56, 0.1, M.purple);
addBox(counter, 0.08, 0.44, 0.09, 0.1, 1.58, -0.06, M.coral);
addBox(counter, 0.08, 0.4, 0.09, 0.28, 1.56, 0.08, M.mustard);
// A small old register is kept as a recognizable reuse detail.
addBox(counter, 0.48, 0.12, 0.38, -1.5, 1.44, 0.2, M.dark);
addBox(counter, 0.34, 0.3, 0.08, -1.5, 1.62, 0.08, M.dark);
// -------------------------------------------------------------------------
// Stylized people
// -------------------------------------------------------------------------
function createPerson({
shirt,
pants = M.dark,
skin = M.skin,
hair = M.hair
}) {
const root = new THREE.Group();
// Torso.
addCylinder(root, 0.26, 0.31, 0.6, 0, 1.07, 0, shirt, 18);
// Neck and head.
addCylinder(root, 0.09, 0.1, 0.14, 0, 1.43, 0, skin, 14);
addSphere(root, 0.23, 0, 1.63, 0, skin);
addSphere(root, 0.235, 0, 1.74, -0.015, hair, [1, 0.56, 0.96]);
// Simple face, oriented toward local +Z.
addSphere(root, 0.025, -0.075, 1.66, 0.213, M.dark);
addSphere(root, 0.025, 0.075, 1.66, 0.213, M.dark);
addSphere(root, 0.042, 0, 1.6, 0.235, skin);
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.32, 1.3, 0);
rightArm.position.set(0.32, 1.3, 0);
root.add(leftArm, rightArm);
[leftArm, rightArm].forEach(arm => {
addCylinder(arm, 0.075, 0.07, 0.48, 0, -0.24, 0, shirt, 14);
addSphere(arm, 0.085, 0, -0.51, 0, skin);
});
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.13, 0.78, 0);
rightLeg.position.set(0.13, 0.78, 0);
root.add(leftLeg, rightLeg);
[leftLeg, rightLeg].forEach(leg => {
addCylinder(leg, 0.095, 0.085, 0.61, 0, -0.305, 0, pants, 14);
addBox(leg, 0.18, 0.12, 0.29, 0, -0.64, 0.06, M.dark);
});
scene.add(root);
return { root, leftArm, rightArm, leftLeg, rightLeg };
}
// Arriving from the sidewalk.
const arriver = createPerson({
shirt: M.mustard,
pants: M.dark,
skin: M.skinLight,
hair: M.dark
});
arriver.root.position.set(6.2, 0.13, 3.35);
// Choosing a workspace at the left table.
const chooser = createPerson({
shirt: M.coral,
pants: M.blue,
skin: M.skin,
hair: M.dark
});
chooser.root.position.set(-2.85, 0.13, -1.9);
chooser.root.rotation.y = Math.PI;
// Returning a tool to the common rack.
const returner = createPerson({
shirt: M.blue,
pants: M.dark,
skin: M.skinLight,
hair: M.hair
});
returner.root.position.set(-3.48, 0.13, -5.92);
returner.root.rotation.y = Math.PI;
// Tool held by the returning person.
const heldTool = new THREE.Group();
returner.root.add(heldTool);
addBox(heldTool, 0.08, 0.33, 0.08, 0, 0, 0, M.coral);
addBox(heldTool, 0.27, 0.1, 0.12, 0, 0.19, 0, M.dark);
heldTool.position.set(0.33, 1.1, 0.35);
// -------------------------------------------------------------------------
// Narrative animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
const walkPath = [
{ x: 6.2, z: 3.35, duration: 4.2 },
{ x: 4.75, z: 1.72, duration: 3.0 },
{ x: 3.55, z: 0.66, duration: 2.7 },
{ x: 3.43, z: -1.18, duration: 3.0 },
{ x: 4.22, z: -1.83, duration: 2.1 }
];
const walkDuration = walkPath.reduce(
(sum, point) => sum + point.duration, 0
);
function lerpAngle(a, b, amount) {
let difference = ((b - a + Math.PI) % (Math.PI * 2)) - Math.PI;
if (difference < -Math.PI) difference += Math.PI * 2;
return a + difference * amount;
}
function animateArriver(elapsed) {
if (elapsed >= walkDuration) {
arriver.root.position.x = walkPath.at(-1).x;
arriver.root.position.z = walkPath.at(-1).z;
arriver.root.position.y = 0.13;
arriver.leftLeg.rotation.x *= 0.85;
arriver.rightLeg.rotation.x *= 0.85;
arriver.rightArm.rotation.x = THREE.MathUtils.lerp(
arriver.rightArm.rotation.x, -0.7, 0.04
);
return;
}
let cursor = 0;
let from = walkPath[0];
let to = walkPath[1];
for (let i = 0; i < walkPath.length - 1; i++) {
const segment = walkPath[i];
const next = walkPath[i + 1];
if (elapsed <= cursor + segment.duration) {
from = segment;
to = next;
break;
}
cursor += segment.duration;
}
const amount = THREE.MathUtils.clamp(
(elapsed - cursor) / from.duration, 0, 1
);
const eased = amount * amount * (3 - 2 * amount);
arriver.root.position.x = THREE.MathUtils.lerp(from.x, to.x, eased);
arriver.root.position.z = THREE.MathUtils.lerp(from.z, to.z, eased);
arriver.root.position.y =
0.13 + Math.abs(Math.sin(elapsed * 8.5)) * 0.035;
const desiredYaw = Math.atan2(to.x - from.x, to.z - from.z);
arriver.root.rotation.y = lerpAngle(
arriver.root.rotation.y, desiredYaw, 0.12
);
const swing = Math.sin(elapsed * 8.5) * 0.52;
arriver.leftLeg.rotation.x = swing;
arriver.rightLeg.rotation.x = -swing;
arriver.leftArm.rotation.x = -swing * 0.75;
arriver.rightArm.rotation.x = swing * 0.75;
}
function animate() {
const elapsed = clock.getElapsedTime();
animateArriver(elapsed);
// The chooser tests or selects materials on the table.
chooser.rightArm.rotation.x =
-0.92 + Math.sin(elapsed * 1.25) * 0.075;
chooser.leftArm.rotation.x = -0.18;
chooser.root.rotation.y = Math.PI + Math.sin(elapsed * 0.45) * 0.025;
// The returning person lifts the tool toward the rack and places it.
const placement = THREE.MathUtils.clamp(elapsed / 5.5, 0, 1);
const smoothPlacement =
placement * placement * (3 - 2 * placement);
returner.rightArm.rotation.x =
-1.02 - smoothPlacement * 0.2 +
Math.sin(elapsed * 2.0) * 0.035;
returner.leftArm.rotation.x = -0.16;
heldTool.position.set(
0.33,
1.1 + smoothPlacement * 0.22,
0.35 + smoothPlacement * 0.14
);
heldTool.rotation.x = -0.25 - smoothPlacement * 0.2;
updateCamera();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
// -------------------------------------------------------------------------
// Custom pointer camera controls — no Three.js examples/addons
// -------------------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredTheta -= deltaX * 0.006;
desiredPhi = THREE.MathUtils.clamp(
desiredPhi + deltaY * 0.005,
0.48,
1.35
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.45
);
}, { passive: false });
document.getElementById("resetView").addEventListener("click", () => {
desiredTheta = 0.66;
desiredPhi = 0.93;
zoom = 1;
});
</script>
</body>
</html>
```