Prompt specification
Build or customize the Three.js 3D scene "Workshop lower-shelf organization" 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: Workshop lower-shelf organization
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/workshop-lower-shelf-organization-x0227
Scene Description Prompt:
A stylized workshop rearranges heavy tools into lower compartments of an anchored shelf, with lighter supplies above. One HTML file, Three.js from cdnjs.
Working Three.js Starter (workshop-lower-shelf-organization-x0227):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Workshop Shelf Organization</title>
<style>
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #eee8dd;
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; }
.hud {
position: fixed;
z-index: 10;
pointer-events: none;
color: #25383d;
}
.title {
top: 24px;
left: 28px;
}
.title strong {
display: block;
font-size: 13px;
letter-spacing: .18em;
text-transform: uppercase;
}
.title span {
display: block;
margin-top: 5px;
color: #65777a;
font-size: 12px;
}
.hint {
right: 26px;
bottom: 22px;
padding: 9px 13px;
border: 1px solid rgba(37, 56, 61, .13);
border-radius: 999px;
background: rgba(255, 255, 255, .67);
backdrop-filter: blur(8px);
color: #5a6e71;
font-size: 11px;
letter-spacing: .04em;
}
.badge {
top: 24px;
right: 26px;
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border-radius: 999px;
background: rgba(255, 255, 255, .7);
border: 1px solid rgba(37, 56, 61, .1);
color: #4f6467;
font-size: 11px;
letter-spacing: .08em;
text-transform: uppercase;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #e49a45;
box-shadow: 0 0 0 4px rgba(228, 154, 69, .16);
}
</style>
</head>
<body>
<div class="hud title">
<strong>Workshop / Bay 04</strong>
<span>Heavy tools below · light supplies above</span>
</div>
<div class="hud badge">
<span class="dot"></span>
Rearranging
</div>
<div class="hud hint">Drag to orbit · Scroll to zoom · Double-click to reset</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 scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee8dd);
scene.fog = new THREE.Fog(0xeee8dd, 13, 22);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-5, 5, 4, -4, 0.1, 100);
const controls = {
target: new THREE.Vector3(0.35, 1.55, -0.55),
yaw: 0.34,
pitch: 0.25,
radius: 8.7,
dragging: false,
previousX: 0,
previousY: 0
};
function resetControls() {
controls.target.set(0.35, 1.55, -0.55);
controls.yaw = 0.34;
controls.pitch = 0.25;
controls.radius = 8.7;
}
function updateCamera() {
const horizontal = Math.cos(controls.pitch) * controls.radius;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * controls.radius,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
camera.zoom = controls.radius / 8.7;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = 6.7;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.previousX;
const dy = event.clientY - controls.previousY;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(controls.pitch + dy * 0.004, 0.03, 0.72);
});
renderer.domElement.addEventListener("pointerup", (event) => {
controls.dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
controls.dragging = false;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
6.2,
13.5
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetControls);
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff7e8, 0x697b7b, 2.1));
const keyLight = new THREE.DirectionalLight(0xffedcf, 4.4);
keyLight.position.set(-4.5, 8.5, 6.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 24;
keyLight.shadow.bias = -0.00035;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x8ec8cf, 1.4);
fillLight.position.set(6, 4, 4);
scene.add(fillLight);
const shelfLight = new THREE.PointLight(0xffd99b, 8, 7, 2);
shelfLight.position.set(1.1, 2.9, -0.5);
scene.add(shelfLight);
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const material = (color, roughness = 0.7, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const mat = {
wall: material(0xc8d7d2, 0.95),
wallInset: material(0xb8cbc6, 0.95),
floor: material(0xd7c8b1, 0.92),
floorDark: material(0xb5a58f, 0.95),
wood: material(0xb77945, 0.72),
woodLight: material(0xd59b5e, 0.73),
woodDark: material(0x70492f, 0.8),
teal: material(0x2e7779, 0.58, 0.16),
tealDark: material(0x1f555a, 0.62, 0.18),
steel: material(0x4b5960, 0.42, 0.68),
steelLight: material(0x98a6a9, 0.32, 0.72),
darkSteel: material(0x27363b, 0.5, 0.55),
orange: material(0xdc783d, 0.66),
orangeLight: material(0xf1a15a, 0.67),
yellow: material(0xe9b24f, 0.66),
navy: material(0x304a62, 0.82),
cream: material(0xf4e6c8, 0.8),
white: material(0xf8f4e9, 0.82),
black: material(0x20292c, 0.7),
green: material(0x698c68, 0.8),
blue: material(0x4c8395, 0.7),
red: material(0xb95242, 0.65),
skin: material(0xc98f68, 0.85),
glass: new THREE.MeshStandardMaterial({
color: 0x9dd2dc,
roughness: 0.18,
metalness: 0.05,
emissive: 0x376d78,
emissiveIntensity: 0.18
})
};
// ---------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------
function box(parent, w, h, d, x, y, z, m, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), m);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, rTop, rBottom, h, x, y, z, m, segments = 24) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
m
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function sphere(parent, r, x, y, z, m, widthSegments = 20) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(r, widthSegments, Math.max(12, widthSegments / 2)),
m
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function torus(parent, r, tube, x, y, z, m, arc = Math.PI * 2) {
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(r, tube, 10, 28, arc),
m
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
parent.add(mesh);
return mesh;
}
function rod(parent, start, end, radius, m) {
const geometry = new THREE.CylinderGeometry(radius, radius, 1, 14);
const mesh = new THREE.Mesh(geometry, m);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
updateRod(mesh, start, end);
return mesh;
}
function updateRod(mesh, start, end) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = new THREE.Vector3().subVectors(b, a);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.scale.y = direction.length();
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
}
function makePlaque(title, subtitle, background, foreground = "#f8f0dc") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 180;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.beginPath();
ctx.roundRect(8, 8, 624, 164, 22);
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,.28)";
ctx.lineWidth = 5;
ctx.stroke();
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 49px system-ui, sans-serif";
ctx.fillText(title, 320, 67);
ctx.globalAlpha = 0.72;
ctx.font = "700 22px system-ui, sans-serif";
ctx.letterSpacing = "4px";
ctx.fillText(subtitle, 320, 119);
ctx.globalAlpha = 1;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(1.35, 0.38),
new THREE.MeshBasicMaterial({ map: texture, toneMapped: false })
);
return mesh;
}
// ---------------------------------------------------------------------
// Room
// ---------------------------------------------------------------------
const room = new THREE.Group();
scene.add(room);
box(room, 12, 0.16, 12, 0, -0.08, 0, mat.floor, false);
// Floor seams.
for (let x = -5; x <= 5; x += 1.5) {
box(room, 0.012, 0.006, 11, x, 0.006, 0, mat.floorDark, false);
}
for (let z = -5; z <= 5; z += 1.5) {
box(room, 11, 0.006, 0.012, 0, 0.007, z, mat.floorDark, false);
}
box(room, 12, 6.5, 0.18, 0, 3.25, -2.45, mat.wall, false);
box(room, 12, 0.18, 0.12, 0, 0.09, -2.32, mat.wallInset, false);
// Wall panel seams.
for (let x = -5.5; x <= 5.5; x += 1.1) {
box(room, 0.012, 6.1, 0.015, x, 3.1, -2.35, mat.wallInset, false);
}
// Window above the bench.
const windowGroup = new THREE.Group();
room.add(windowGroup);
box(windowGroup, 2.45, 1.55, 0.09, -3.45, 3.52, -2.31, mat.cream);
box(windowGroup, 2.19, 1.29, 0.04, -3.45, 3.52, -2.245, mat.glass, false);
box(windowGroup, 0.075, 1.32, 0.07, -3.45, 3.52, -2.20, mat.cream);
box(windowGroup, 2.22, 0.075, 0.07, -3.45, 3.52, -2.20, mat.cream);
box(windowGroup, 2.62, 0.12, 0.31, -3.45, 2.72, -2.18, mat.woodLight);
// ---------------------------------------------------------------------
// Workbench and pegboard
// ---------------------------------------------------------------------
const bench = new THREE.Group();
room.add(bench);
box(bench, 2.75, 0.18, 1.13, -3.35, 1.32, -1.65, mat.woodLight);
box(bench, 2.54, 0.32, 0.09, -3.35, 1.07, -2.12, mat.woodDark);
for (const x of [-4.48, -2.22]) {
for (const z of [-2.02, -1.25]) {
box(bench, 0.14, 1.25, 0.14, x, 0.63, z, mat.steel);
}
}
box(bench, 2.28, 0.10, 0.76, -3.35, 0.40, -1.65, mat.woodDark);
// Pegboard.
box(bench, 2.6, 1.65, 0.08, -3.4, 2.48, -2.30, mat.wood);
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 8; col++) {
const hole = cylinder(
bench,
0.025,
0.025,
0.012,
-4.48 + col * 0.31,
1.92 + row * 0.28,
-2.247,
mat.darkSteel,
10
);
hole.rotation.x = Math.PI / 2;
}
}
// Pegboard tools.
rod(bench, [-4.42, 2.89, -2.19], [-4.10, 2.44, -2.19], 0.045, mat.steelLight);
torus(bench, 0.095, 0.035, -4.42, 2.91, -2.19, mat.steelLight, Math.PI * 1.55)
.rotation.z = Math.PI / 2;
rod(bench, [-3.73, 2.93, -2.18], [-3.73, 2.48, -2.18], 0.035, mat.orange);
box(bench, 0.36, 0.13, 0.12, -3.73, 2.94, -2.18, mat.steel);
// Hanging saw.
const saw = new THREE.Group();
saw.position.set(-2.68, 2.56, -2.18);
saw.rotation.z = -0.12;
bench.add(saw);
box(saw, 0.08, 0.75, 0.055, 0, 0, 0, mat.orange);
box(saw, 0.52, 0.08, 0.055, 0.25, -0.35, 0, mat.orange);
box(saw, 0.40, 0.28, 0.025, 0.35, -0.12, 0.015, mat.steelLight);
// Desk lamp.
cylinder(bench, 0.20, 0.23, 0.07, -4.38, 1.43, -1.62, mat.tealDark);
rod(bench, [-4.38, 1.46, -1.62], [-4.35, 2.04, -1.62], 0.035, mat.tealDark);
rod(bench, [-4.35, 2.04, -1.62], [-4.00, 2.18, -1.61], 0.035, mat.tealDark);
const lampShade = new THREE.Mesh(
new THREE.ConeGeometry(0.28, 0.32, 24, 1, true),
mat.teal
);
lampShade.position.set(-3.91, 2.12, -1.61);
lampShade.rotation.z = -0.35;
lampShade.castShadow = true;
bench.add(lampShade);
// Small parts tray on the bench.
box(bench, 0.68, 0.18, 0.48, -2.70, 1.50, -1.53, mat.wood);
box(bench, 0.54, 0.08, 0.34, -2.70, 1.61, -1.53, mat.steelLight);
// Pencil cup.
cylinder(bench, 0.12, 0.10, 0.32, -2.11, 1.57, -1.72, mat.orange);
for (let i = 0; i < 4; i++) {
const pencil = rod(
bench,
[-2.18 + i * 0.04, 1.68, -1.72],
[-2.20 + i * 0.05, 2.02 + (i % 2) * 0.08, -1.72],
0.014,
i % 2 ? mat.yellow : mat.tealDark
);
pencil.rotation.z = (i - 1.5) * 0.09;
}
// ---------------------------------------------------------------------
// Anchored storage shelf
// ---------------------------------------------------------------------
const shelf = new THREE.Group();
shelf.position.set(0, 0, 0);
room.add(shelf);
const shelfLeft = -1.35;
const shelfRight = 3.75;
const shelfCenter = (shelfLeft + shelfRight) / 2;
const shelfZ = -1.72;
// Horizontal wood shelves.
box(shelf, 5.25, 0.14, 0.88, shelfCenter, 0.16, shelfZ, mat.wood);
box(shelf, 5.25, 0.15, 0.88, shelfCenter, 1.43, shelfZ, mat.woodLight);
box(shelf, 5.25, 0.15, 0.88, shelfCenter, 2.68, shelfZ, mat.wood);
// Steel uprights.
for (const x of [shelfLeft, shelfRight]) {
box(shelf, 0.13, 2.66, 0.16, x, 1.39, shelfZ - 0.43, mat.tealDark);
box(shelf, 0.13, 2.66, 0.16, x, 1.39, shelfZ + 0.43, mat.tealDark);
box(shelf, 0.12, 0.12, 0.93, x, 2.66, shelfZ, mat.tealDark);
box(shelf, 0.12, 0.12, 0.93, x, 0.16, shelfZ, mat.tealDark);
}
// Lower cubby dividers.
for (const x of [0.35, 2.05]) {
box(shelf, 0.11, 1.20, 0.79, x, 0.80, shelfZ, mat.woodDark);
}
// Rear diagonal support.
rod(
shelf,
[shelfLeft + 0.10, 0.24, shelfZ - 0.48],
[shelfRight - 0.10, 2.57, shelfZ - 0.48],
0.035,
mat.steel
);
// Anti-tip wall anchors.
for (const x of [-1.10, 3.50]) {
box(shelf, 0.18, 0.67, 0.08, x, 2.24, -2.30, mat.steel);
box(shelf, 0.16, 0.12, 0.91, x, 2.55, -1.87, mat.steel);
rod(
shelf,
[x, 2.02, -2.25],
[x, 2.53, -1.49],
0.045,
mat.steel
);
for (const y of [2.02, 2.44]) {
const bolt = cylinder(shelf, 0.052, 0.052, 0.035, x, y, -2.245, mat.steelLight, 14);
bolt.rotation.x = Math.PI / 2;
}
}
// Shelf identification plaques.
const heavyPlaque = makePlaque("HEAVY", "LOWER COMPARTMENTS", "#314b50");
heavyPlaque.position.set(-0.76, 0.18, shelfZ + 0.446);
shelf.add(heavyPlaque);
const lightPlaque = makePlaque("LIGHT", "UPPER SHELF", "#c7783f");
lightPlaque.position.set(-0.76, 1.43, shelfZ + 0.446);
shelf.add(lightPlaque);
// Small status light.
cylinder(shelf, 0.055, 0.055, 0.05, 3.49, 2.48, shelfZ + 0.47, mat.green, 14)
.rotation.x = Math.PI / 2;
// Safety mat in front of the shelf.
box(room, 5.55, 0.025, 1.35, 1.15, 0.018, -0.48, mat.tealDark, false);
for (let i = 0; i < 9; i++) {
const stripe = box(
room,
0.11,
0.008,
0.42,
-1.30 + i * 0.60,
0.036,
0.05,
mat.yellow,
false
);
stripe.rotation.y = -0.32;
}
// ---------------------------------------------------------------------
// Heavy lower-shelf tools
// ---------------------------------------------------------------------
const anvil = new THREE.Group();
anvil.position.set(-0.65, 0.235, -1.70);
shelf.add(anvil);
box(anvil, 0.72, 0.13, 0.45, 0, 0.065, 0, mat.darkSteel);
box(anvil, 0.34, 0.25, 0.32, -0.05, 0.22, 0, mat.steel);
box(anvil, 0.94, 0.20, 0.42, -0.06, 0.39, 0, mat.steelLight);
const horn = new THREE.Mesh(
new THREE.ConeGeometry(0.18, 0.67, 18),
mat.steelLight
);
horn.rotation.z = -Math.PI / 2;
horn.position.set(0.69, 0.39, 0);
horn.castShadow = true;
anvil.add(horn);
const vise = new THREE.Group();
vise.position.set(1.03, 0.235, -1.64);
shelf.add(vise);
box(vise, 0.82, 0.12, 0.57, 0, 0.06, 0, mat.orange);
box(vise, 0.43, 0.30, 0.40, -0.05, 0.25, 0, mat.red);
box(vise, 0.16, 0.40, 0.52, -0.31, 0.29, 0, mat.darkSteel);
box(vise, 0.16, 0.40, 0.52, 0.22, 0.29, 0, mat.darkSteel);
box(vise, 0.09, 0.25, 0.30, -0.16, 0.30, 0, mat.steelLight);
box(vise, 0.09, 0.25, 0.30, 0.08, 0.30, 0, mat.steelLight);
const viseScrew = cylinder(vise, 0.055, 0.055, 0.78, 0.56, 0.23, 0, mat.steelLight, 16);
viseScrew.rotation.z = Math.PI / 2;
rod(vise, [0.78, 0.23, -0.16], [0.78, 0.23, 0.16], 0.035, mat.darkSteel);
// Heavy toolbox, animated into the lower right compartment.
const toolbox = new THREE.Group();
toolbox.position.set(2.68, 0.235, -0.55);
shelf.add(toolbox);
box(toolbox, 1.07, 0.45, 0.58, 0, 0.225, 0, mat.teal);
box(toolbox, 1.10, 0.075, 0.61, 0, 0.485, 0, mat.tealDark);
box(toolbox, 0.95, 0.035, 0.64, 0, 0.385, 0, mat.steel);
for (const x of [-0.35, 0.35]) {
box(toolbox, 0.10, 0.13, 0.035, x, 0.39, 0.307, mat.yellow);
}
box(toolbox, 0.10, 0.11, 0.10, -0.18, 0.59, 0, mat.darkSteel);
box(toolbox, 0.10, 0.11, 0.10, 0.18, 0.59, 0, mat.darkSteel);
box(toolbox, 0.46, 0.075, 0.10, 0, 0.65, 0, mat.darkSteel);
// ---------------------------------------------------------------------
// Lighter supplies on the upper shelf
// ---------------------------------------------------------------------
const supplies = new THREE.Group();
supplies.position.y = 1.508;
shelf.add(supplies);
function paintCan(x, z, color, height = 0.42) {
const group = new THREE.Group();
group.position.set(x, 0, z);
supplies.add(group);
cylinder(group, 0.22, 0.20, height, 0, height / 2, 0, color);
cylinder(group, 0.23, 0.23, 0.035, 0, height + 0.018, 0, mat.steelLight);
torus(group, 0.16, 0.018, 0, height + 0.055, 0, mat.steelLight);
box(group, 0.20, 0.13, 0.015, 0, height * 0.48, 0.208, mat.cream, false);
return group;
}
paintCan(-0.91, -1.72, mat.cream, 0.44);
paintCan(-0.48, -1.74, mat.teal, 0.34);
// Small cartons.
box(supplies, 0.53, 0.34, 0.43, -0.02, 0.17, -1.72, mat.cream);
box(supplies, 0.55, 0.035, 0.45, -0.02, 0.35, -1.72, mat.woodLight);
box(supplies, 0.17, 0.09, 0.015, -0.02, 0.21, -1.495, mat.orange, false);
box(supplies, 0.46, 0.27, 0.39, 0.57, 0.135, -1.71, mat.blue);
box(supplies, 0.48, 0.03, 0.41, 0.57, 0.282, -1.71, mat.cream);
// Folded cloths.
box(supplies, 0.62, 0.12, 0.43, 1.20, 0.06, -1.72, mat.green);
box(supplies, 0.58, 0.11, 0.40, 1.18, 0.17, -1.71, mat.cream);
box(supplies, 0.55, 0.10, 0.39, 1.17, 0.27, -1.70, mat.orangeLight);
// Small tool caddy.
box(supplies, 0.65, 0.34, 0.45, 1.93, 0.17, -1.72, mat.yellow);
for (let i = 0; i < 4; i++) {
rod(
supplies,
[1.72 + i * 0.14, 0.32, -1.71],
[1.70 + i * 0.15, 0.66 + (i % 2) * 0.09, -1.71],
0.022,
i % 2 ? mat.tealDark : mat.orange
);
}
// Spray bottles.
for (let i = 0; i < 3; i++) {
const x = 2.57 + i * 0.25;
cylinder(supplies, 0.09, 0.10, 0.38, x, 0.19, -1.70, i === 1 ? mat.orange : mat.cream);
cylinder(supplies, 0.045, 0.045, 0.12, x, 0.43, -1.70, mat.tealDark, 14);
box(supplies, 0.13, 0.045, 0.075, x + 0.025, 0.50, -1.70, mat.tealDark);
}
// ---------------------------------------------------------------------
// Stylized worker
// ---------------------------------------------------------------------
const worker = new THREE.Group();
worker.position.set(2.68, 0, 0.12);
room.add(worker);
// Kneeling legs and boots.
rod(worker, [-0.18, 0.73, 0.03], [-0.42, 0.40, -0.15], 0.14, mat.navy);
rod(worker, [-0.42, 0.40, -0.15], [-0.42, 0.14, 0.24], 0.12, mat.navy);
box(worker, 0.28, 0.16, 0.43, -0.43, 0.10, 0.30, mat.black);
rod(worker, [0.18, 0.73, 0.03], [0.42, 0.43, 0.02], 0.14, mat.navy);
rod(worker, [0.42, 0.43, 0.02], [0.50, 0.14, 0.29], 0.12, mat.navy);
box(worker, 0.28, 0.16, 0.43, 0.50, 0.10, 0.35, mat.black);
const upperBody = new THREE.Group();
worker.add(upperBody);
box(upperBody, 0.58, 0.64, 0.36, 0, 1.03, 0.03, mat.navy);
box(upperBody, 0.52, 0.48, 0.055, 0, 1.01, 0.225, mat.orange);
box(upperBody, 0.52, 0.48, 0.055, 0, 1.01, -0.165, mat.orange);
box(upperBody, 0.42, 0.055, 0.02, 0, 1.04, 0.258, mat.cream, false);
box(upperBody, 0.42, 0.055, 0.02, 0, 0.89, 0.258, mat.cream, false);
cylinder(upperBody, 0.10, 0.11, 0.15, 0, 1.43, 0.01, mat.skin, 18);
sphere(upperBody, 0.235, 0, 1.61, 0.005, mat.skin, 24);
// Ear protection and hard hat.
sphere(upperBody, 0.073, -0.225, 1.61, 0.005, mat.yellow, 14);
sphere(upperBody, 0.073, 0.225, 1.61, 0.005, mat.yellow, 14);
const hardHat = sphere(upperBody, 0.255, 0, 1.73, 0.005, mat.yellow, 24);
hardHat.scale.y = 0.66;
cylinder(upperBody, 0.31, 0.31, 0.045, 0, 1.635, 0.005, mat.yellow);
box(upperBody, 0.065, 0.18, 0.30, 0, 1.79, 0.005, mat.orangeLight);
// Dynamic arms.
const armData = [];
for (const side of [-1, 1]) {
const upperArm = rod(
worker,
[side * 0.32, 1.25, 0.02],
[side * 0.43, 0.98, -0.40],
0.09,
mat.navy
);
const forearm = rod(
worker,
[side * 0.43, 0.98, -0.40],
[side * 0.21, 0.62, -0.58],
0.075,
mat.skin
);
const hand = sphere(worker, 0.095, side * 0.21, 0.62, -0.58, mat.skin, 16);
armData.push({ side, upperArm, forearm, hand });
}
// ---------------------------------------------------------------------
// Additional wall details
// ---------------------------------------------------------------------
// Clock.
const clock = new THREE.Group();
clock.position.set(4.63, 2.78, -2.27);
room.add(clock);
cylinder(clock, 0.36, 0.36, 0.09, 0, 0, 0, mat.cream, 40).rotation.x = Math.PI / 2;
torus(clock, 0.32, 0.028, 0, 0, 0.057, mat.tealDark);
rod(clock, [0, 0, 0.065], [0.13, 0.10, 0.065], 0.018, mat.tealDark);
rod(clock, [0, 0, 0.068], [-0.08, 0.19, 0.068], 0.013, mat.tealDark);
sphere(clock, 0.034, 0, 0, 0.085, mat.orange, 12);
// Waste bin.
const bin = new THREE.Group();
bin.position.set(-5.10, 0, -1.78);
room.add(bin);
cylinder(bin, 0.33, 0.27, 0.65, 0, 0.33, 0, mat.tealDark);
torus(bin, 0.32, 0.025, 0, 0.66, 0, mat.steel);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clockStart = performance.now();
function smooth01(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
function animate(now) {
const elapsed = (now - clockStart) / 1000;
// A one-time push places the heavy toolbox into the lower compartment.
const placement = smooth01((elapsed - 0.25) / 3.2);
toolbox.position.z = THREE.MathUtils.lerp(-0.55, -1.29, placement);
// Arms follow the moving handle.
const handZ = toolbox.position.z + 0.16 - worker.position.z;
const breathing = Math.sin(elapsed * 2.2) * 0.012;
for (const arm of armData) {
const shoulder = [arm.side * 0.32, 1.25 + breathing, 0.02];
const elbow = [arm.side * 0.43, 0.96 + breathing, handZ * 0.52];
const hand = [arm.side * 0.21, 0.61 + breathing, handZ];
updateRod(arm.upperArm, shoulder, elbow);
updateRod(arm.forearm, elbow, hand);
arm.hand.position.set(...hand);
}
upperBody.rotation.x = -0.035 * placement;
upperBody.position.y = breathing;
// Gentle environmental motion.
shelfLight.intensity = 7.6 + Math.sin(elapsed * 1.7) * 0.35;
updateCamera();
renderer.render(scene, camera);
}
resize();
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```