Prompt specification
Build or customize the Three.js 3D scene "Corner repair kiosk workday" 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: Corner repair kiosk workday
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/corner-repair-kiosk-workday-x0531
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring repair kiosks and parts matching. Compose an open repair counter, waiting shelf, tool wall, and completed-items rack; tagged objects move through intake, diagnosis, repair, and collection in visible order. Voxel style.
Working Three.js Starter (corner-repair-kiosk-workday-x0531):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fix & Match — Voxel Repair Workshop</title>
<style>
:root {
--ink: #173c38;
--paper: #f3efe4;
--coral: #ff6b4a;
--blue: #3f8cff;
--yellow: #f5b942;
--green: #37b58c;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #dce6df;
color: var(--paper);
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
touch-action: none;
cursor: grab;
}
canvas.dragging { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
background: rgba(20, 55, 51, 0.93);
border: 1px solid rgba(255,255,255,0.18);
box-shadow: 0 12px 32px rgba(19, 47, 42, 0.18);
backdrop-filter: blur(10px);
}
#hud {
top: 20px;
left: 20px;
width: min(360px, calc(100vw - 40px));
padding: 17px 18px 16px;
border-radius: 4px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
color: #a8cec4;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
background: #66e2a8;
box-shadow: 0 0 12px #66e2a8;
}
h1 {
margin: 9px 0 7px;
font-size: clamp(25px, 4vw, 38px);
line-height: 0.95;
letter-spacing: -0.08em;
text-transform: uppercase;
}
#hud p {
margin: 0;
max-width: 315px;
color: #bcd2cc;
font-size: 11px;
line-height: 1.55;
}
#readout {
top: 20px;
right: 20px;
min-width: 210px;
padding: 14px 16px;
border-radius: 4px;
}
#activeStage {
display: block;
color: #fff4ce;
font-size: 16px;
font-weight: 900;
letter-spacing: 0.06em;
}
#readoutText {
display: block;
margin-top: 5px;
color: #a8cec4;
font-size: 10px;
line-height: 1.4;
}
#stages {
left: 50%;
bottom: 20px;
transform: translateX(-50%);
display: flex;
gap: 5px;
padding: 6px;
border-radius: 4px;
white-space: nowrap;
}
.stage-chip {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 11px;
border: 1px solid transparent;
color: #9fbbb4;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
transition: 160ms ease;
}
.stage-chip b {
display: grid;
place-items: center;
width: 21px;
height: 21px;
color: #173c38;
background: var(--stage-color);
font-size: 10px;
}
.stage-chip.active {
color: #fff;
border-color: var(--stage-color);
background: rgba(255,255,255,0.05);
box-shadow: inset 0 -2px 0 var(--stage-color);
}
#controls {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 11;
display: flex;
gap: 6px;
}
button {
border: 1px solid rgba(255,255,255,0.2);
border-radius: 3px;
padding: 10px 12px;
background: #173c38;
color: #eff7f2;
font: 800 9px/1 ui-monospace, monospace;
letter-spacing: 0.08em;
cursor: pointer;
box-shadow: 0 8px 22px rgba(19, 47, 42, 0.15);
}
button:hover { background: #24554e; }
button:active { transform: translateY(1px); }
button.accent { color: #173c38; background: #f5d26c; }
#help {
position: fixed;
left: 20px;
bottom: 20px;
z-index: 9;
padding: 9px 11px;
border-radius: 3px;
color: #315a53;
background: rgba(244, 241, 229, 0.82);
border: 1px solid rgba(23,60,56,0.1);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.03em;
}
@media (max-width: 900px) {
#readout { display: none; }
#hud { width: 270px; }
#hud p { display: none; }
#stages { bottom: 70px; }
.stage-chip { padding: 8px; }
.stage-chip span { display: none; }
#help { display: none; }
#controls { left: 20px; right: auto; }
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="hud" class="panel">
<div class="eyebrow"><i class="live-dot"></i> Live repair workflow</div>
<h1>Fix & Match</h1>
<p>
Open workshop with color-coded parts matching. Follow each tagged device
from intake through diagnosis, repair, and collection.
</p>
</section>
<aside id="readout" class="panel">
<span id="activeStage">INTAKE</span>
<span id="readoutText">Waiting for ticket</span>
</aside>
<nav id="stages" class="panel" aria-label="Repair stages">
<div class="stage-chip" data-stage="0" style="--stage-color:var(--coral)"><b>1</b><span>INTAKE</span></div>
<div class="stage-chip" data-stage="1" style="--stage-color:var(--blue)"><b>2</b><span>DIAGNOSIS</span></div>
<div class="stage-chip" data-stage="2" style="--stage-color:var(--yellow)"><b>3</b><span>REPAIR</span></div>
<div class="stage-chip" data-stage="3" style="--stage-color:var(--green)"><b>4</b><span>COLLECTION</span></div>
</nav>
<div id="help">DRAG TO ORBIT · SHIFT+DRAG TO PAN · WHEEL TO ZOOM</div>
<div id="controls">
<button id="pause">PAUSE FLOW</button>
<button id="top">TOP VIEW</button>
<button id="reset" class="accent">RESET VIEW</button>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce6df);
scene.fog = new THREE.Fog(0xdce6df, 24, 42);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
container.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xffffff, 0x71877b, 2.1);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.3);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8fc9ff, 0.8);
fill.position.set(10, 6, -8);
scene.add(fill);
const stageMeta = [
{ name: "INTAKE", color: 0xff6b4a, css: "#ff6b4a" },
{ name: "DIAGNOSIS", color: 0x3f8cff, css: "#3f8cff" },
{ name: "REPAIR", color: 0xf5b942, css: "#f5b942" },
{ name: "COLLECTION", color: 0x37b58c, css: "#37b58c" }
];
const stagePositions = [
new THREE.Vector3(-4.8, 1.15, 2.25),
new THREE.Vector3(-2.7, 1.15, 0.20),
new THREE.Vector3( 0.55, 1.15, 0.20),
new THREE.Vector3( 3.95, 1.15, 2.25)
];
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
...options
});
}
function box(parent, size, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
color?.isMaterial ? color : material(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function paintLabel(sprite, title, subtitle, accent) {
const { canvas, texture } = sprite.userData;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(18, 49, 45, 0.94)";
ctx.fillRect(3, 3, 506, 122);
ctx.fillStyle = accent;
ctx.fillRect(3, 3, 506, 9);
ctx.fillRect(3, 116, 506, 9);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#ffffff";
ctx.font = `800 ${subtitle ? 36 : 40}px monospace`;
ctx.fillText(title, 256, subtitle ? 52 : 70, 475);
if (subtitle) {
ctx.fillStyle = accent;
ctx.font = "700 21px monospace";
ctx.fillText(subtitle, 256, 91, 475);
}
texture.needsUpdate = true;
}
function makeLabel(title, subtitle, accent, width = 2.5) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
}));
sprite.scale.set(width, width * 128 / 512, 1);
sprite.userData = { canvas, texture };
paintLabel(sprite, title, subtitle, accent);
sprite.renderOrder = 20;
return sprite;
}
function makeWorldLabel(parent, title, subtitle, accent, position, width) {
const label = makeLabel(title, subtitle, accent, width);
label.position.set(position[0], position[1], position[2]);
parent.add(label);
return label;
}
// Raised voxel floor and tile grid.
box(scene, [18, 0.3, 13], [0, -0.15, 0], 0xe4dccd);
box(scene, [17.7, 0.08, 12.7], [0, 0.02, 0], 0xeee8da);
const gridVertices = [];
for (let x = -8.5; x <= 8.5; x += 0.85) {
gridVertices.push(x, 0.065, -6.15, x, 0.065, 6.15);
}
for (let z = -6.15; z <= 6.15; z += 0.85) {
gridVertices.push(-8.5, 0.065, z, 8.5, 0.065, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute("position", new THREE.Float32BufferAttribute(gridVertices, 3));
scene.add(new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({ color: 0x81948b, transparent: true, opacity: 0.18 })
));
// Floor station pads.
stagePositions.forEach((position, index) => {
const color = stageMeta[index].color;
box(scene, [3.0, 0.07, 2.35], [position.x, 0.105, position.z], 0x536b63, {
transparent: true,
opacity: 0.22
});
const padMaterial = material(color, {
transparent: true,
opacity: 0.2,
emissive: color,
emissiveIntensity: 0.12
});
box(scene, [2.8, 0.08, 2.14], [position.x, 0.13, position.z], padMaterial);
makeWorldLabel(
scene,
`0${index + 1}`,
"",
stageMeta[index].css,
[position.x, 0.24, position.z + 1.22],
0.48
);
});
// Tool wall.
const toolWall = new THREE.Group();
toolWall.position.set(-3.65, 0, -4.08);
scene.add(toolWall);
box(toolWall, [4.0, 2.65, 0.18], [0, 2.18, 0], 0xc88e61);
box(toolWall, [4.18, 0.16, 0.28], [0, 3.58, 0], 0x284e47);
box(toolWall, [0.16, 3.5, 0.22], [-1.9, 1.75, -0.03], 0x284e47);
box(toolWall, [0.16, 3.5, 0.22], [1.9, 1.75, -0.03], 0x284e47);
for (let x = -1.65; x <= 1.65; x += 0.33) {
for (let y = 1.15; y <= 3.15; y += 0.34) {
box(toolWall, [0.055, 0.055, 0.025], [x, y, 0.105], 0x7b513a);
}
}
// Hammer.
box(toolWall, [0.13, 1.05, 0.12], [-1.25, 2.0, 0.25], 0x8b5a37);
box(toolWall, [0.62, 0.24, 0.18], [-1.25, 2.57, 0.25], 0x47555a);
// Wrench.
box(toolWall, [0.13, 1.0, 0.12], [-0.48, 2.03, 0.25], 0xbac7c7, { metalness: 0.45 });
box(toolWall, [0.37, 0.15, 0.13], [-0.48, 2.56, 0.25], 0xbac7c7, { metalness: 0.45 });
box(toolWall, [0.12, 0.32, 0.13], [-0.66, 2.47, 0.25], 0xbac7c7, { metalness: 0.45 });
box(toolWall, [0.12, 0.32, 0.13], [-0.30, 2.47, 0.25], 0xbac7c7, { metalness: 0.45 });
// Screwdriver.
box(toolWall, [0.2, 0.48, 0.16], [0.30, 2.35, 0.25], 0xf0b83f);
box(toolWall, [0.08, 0.72, 0.08], [0.30, 1.72, 0.25], 0xb7c1c2, { metalness: 0.5 });
box(toolWall, [0.09, 0.12, 0.09], [0.30, 2.66, 0.25], 0xb7c1c2, { metalness: 0.5 });
// Pliers.
const plierA = box(toolWall, [0.13, 0.8, 0.13], [1.15, 2.02, 0.25], 0x52676d);
plierA.rotation.z = 0.32;
const plierB = box(toolWall, [0.13, 0.8, 0.13], [1.42, 2.02, 0.25], 0x52676d);
plierB.rotation.z = -0.32;
box(toolWall, [0.18, 0.18, 0.16], [1.28, 2.40, 0.26], 0xd4644c);
makeWorldLabel(toolWall, "TOOL WALL", "SHARED EQUIPMENT", "#f5b942", [0, 3.94, 0.1], 3.25);
// Parts matching board.
const partsBoard = new THREE.Group();
partsBoard.position.set(0.65, 0, -4.08);
scene.add(partsBoard);
box(partsBoard, [4.85, 2.65, 0.18], [0, 2.18, 0], 0x315b54);
box(partsBoard, [4.98, 0.16, 0.28], [0, 3.58, 0], 0xf0c66d);
box(partsBoard, [0.16, 3.5, 0.22], [-2.32, 1.75, -0.03], 0x1c423d);
box(partsBoard, [0.16, 3.5, 0.22], [2.32, 1.75, -0.03], 0x1c423d);
const partDefinitions = [
{ name: "HEATER", code: "C-01", color: 0xff6b4a, css: "#ff6b4a" },
{ name: "PCB", code: "B-02", color: 0x3f8cff, css: "#3f8cff" },
{ name: "SWITCH", code: "Y-03", color: 0xf5b942, css: "#f5b942" },
{ name: "MOTOR", code: "G-04", color: 0x37b58c, css: "#37b58c" }
];
function buildPart(type, color) {
const group = new THREE.Group();
if (type === "heater") {
box(group, [0.42, 0.11, 0.24], [0, 0.03, 0], 0x7d493c);
for (let i = -1; i <= 1; i++) {
box(group, [0.055, 0.25, 0.055], [i * 0.11, 0.16, 0], color);
}
} else if (type === "pcb") {
box(group, [0.43, 0.07, 0.3], [0, 0.03, 0], color);
box(group, [0.15, 0.08, 0.13], [0, 0.10, 0], 0x26343a);
box(group, [0.07, 0.06, 0.07], [-0.14, 0.09, 0.08], 0xe4d17b);
} else if (type === "switch") {
box(group, [0.23, 0.22, 0.18], [0, 0.12, 0], color);
box(group, [0.08, 0.10, 0.08], [0, 0.28, 0], 0x48575b);
} else {
box(group, [0.26, 0.24, 0.25], [0, 0.15, 0], color);
box(group, [0.35, 0.08, 0.08], [0, 0.15, 0], 0x53666a, { metalness: 0.45 });
}
return group;
}
const bins = [];
partDefinitions.forEach((part, index) => {
const bin = new THREE.Group();
bin.position.set(-1.8 + index * 1.2, 1.82, 0.20);
partsBoard.add(bin);
const binMaterial = material(part.color, {
emissive: part.color,
emissiveIntensity: 0.04,
transparent: true,
opacity: 0.82
});
box(bin, [0.94, 0.88, 0.15], [0, 0, 0], binMaterial);
box(bin, [0.74, 0.68, 0.08], [0, 0, 0.11], 0x244640);
const partMesh = buildPart(
["heater", "pcb", "switch", "motor"][index],
part.color
);
partMesh.position.set(0, 0, 0.2);
bin.add(partMesh);
makeWorldLabel(
bin,
part.name,
part.code,
part.css,
[0, -0.61, 0.15],
1.08
);
bins.push({ group: bin, material: binMaterial, index });
});
makeWorldLabel(
partsBoard,
"PARTS MATCHING",
"COLOR + TICKET CODE",
"#f5d26c",
[0, 3.96, 0.1],
4.25
);
// Waiting shelf.
const waitingShelf = new THREE.Group();
waitingShelf.position.set(-6.65, 0, -2.55);
scene.add(waitingShelf);
[-1.35, 1.35].forEach(x => {
box(waitingShelf, [0.14, 3.0, 0.14], [x, 1.5, -0.45], 0x365b52);
box(waitingShelf, [0.14, 3.0, 0.14], [x, 1.5, 0.45], 0x365b52);
});
[0.5, 1.25, 2.0].forEach((y, shelfIndex) => {
box(waitingShelf, [2.9, 0.13, 1.05], [0, y, 0], 0xa8754f);
for (let i = 0; i < 3; i++) {
if (shelfIndex === 1 && i === 2) continue;
const x = -0.9 + i * 0.9;
const color = [0xd8a460, 0x729e91, 0xcb765b][(i + shelfIndex) % 3];
box(waitingShelf, [0.65, 0.48, 0.68], [x, y + 0.31, 0], color);
box(waitingShelf, [0.26, 0.035, 0.3], [x, y + 0.57, 0], 0xf0e6cf);
}
});
makeWorldLabel(
waitingShelf,
"WAITING SHELF",
"QUEUE / PRIORITY TAGS",
"#b7d7cd",
[0, 3.35, 0],
2.9
);
// Completed-items rack.
const completedRack = new THREE.Group();
completedRack.position.set(5.8, 0, -2.65);
scene.add(completedRack);
[-1.35, 1.35].forEach(x => {
box(completedRack, [0.13, 3.05, 0.13], [x, 1.53, -0.45], 0x365b52);
box(completedRack, [0.13, 3.05, 0.13], [x, 1.53, 0.45], 0x365b52);
});
[0.45, 1.25, 2.05].forEach((y, shelfIndex) => {
box(completedRack, [2.9, 0.12, 1.05], [0, y, 0], 0x57766d);
for (let i = 0; i < 3; i++) {
const x = -0.9 + i * 0.9;
box(completedRack, [0.62, 0.38, 0.58], [x, y + 0.26, 0], [0xe0a55f, 0x6fa6c6, 0x73b28c][i]);
box(completedRack, [0.28, 0.12, 0.28], [x, y + 0.51, 0], 0x254a43);
box(completedRack, [0.12, 0.12, 0.05], [x + 0.24, y + 0.35, 0.31], 0x59d69e);
}
});
makeWorldLabel(
completedRack,
"COMPLETED ITEMS",
"READY FOR PICKUP",
"#66d9a6",
[0, 3.38, 0],
3.2
);
// Open-front service kiosks.
function buildKiosk(stageIndex) {
const meta = stageMeta[stageIndex];
const position = stagePositions[stageIndex];
const group = new THREE.Group();
group.position.set(position.x, 0, position.z);
scene.add(group);
// Counter top, side panels, back panel, and open front shelf.
box(group, [2.25, 0.16, 1.35], [0, 1.05, 0], 0xf3eddd);
box(group, [2.25, 0.16, 0.12], [0, 0.98, 0.64], meta.color);
box(group, [0.14, 0.88, 1.15], [-1.02, 0.53, -0.02], 0x315b53);
box(group, [0.14, 0.88, 1.15], [ 1.02, 0.53, -0.02], 0x315b53);
box(group, [1.95, 0.74, 0.12], [0, 0.52, -0.53], 0x315b53);
box(group, [1.9, 0.11, 1.0], [0, 0.40, -0.02], 0xb9a886);
// Small props make each station distinct.
box(group, [0.34, 0.18, 0.42], [0.76, 1.21, 0.12], 0x304b48);
box(group, [0.24, 0.035, 0.28], [0.76, 1.32, 0.12], 0x76dca8, {
emissive: 0x76dca8,
emissiveIntensity: 0.25
});
box(group, [0.5, 0.06, 0.36], [-0.70, 1.16, 0.15], 0xe3d6bb);
// Screen frame and canvas display.
box(group, [0.12, 0.78, 0.12], [0, 1.45, -0.42], 0x365b53);
box(group, [1.46, 0.88, 0.16], [0, 1.91, -0.42], 0x173c38);
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 256;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const screenMaterial = new THREE.MeshBasicMaterial({ map: texture });
const screen = new THREE.Mesh(new THREE.PlaneGeometry(1.28, 0.70), screenMaterial);
screen.position.set(0, 1.91, -0.332);
group.add(screen);
const label = makeWorldLabel(
group,
meta.name,
`BAY 0${stageIndex + 1}`,
meta.css,
[0, 2.72, -0.18],
2.55
);
const padMaterial = material(meta.color, {
transparent: true,
opacity: 0.2,
emissive: meta.color,
emissiveIntensity: 0.14
});
const pad = box(
scene,
[2.8, 0.09, 2.14],
[position.x, 0.14, position.z],
padMaterial
);
return { group, screen, canvas, texture, padMaterial, label, stageIndex };
}
const kiosks = stageMeta.map((_, index) => buildKiosk(index));
// Floor route and voxel arrows.
const routePoints = stagePositions.map(p => new THREE.Vector3(p.x, 0.205, p.z));
const routeGeometry = new THREE.BufferGeometry().setFromPoints(routePoints);
const route = new THREE.Line(
routeGeometry,
new THREE.LineDashedMaterial({
color: 0x58756c,
dashSize: 0.22,
gapSize: 0.14,
transparent: true,
opacity: 0.5
})
);
route.computeLineDistances();
scene.add(route);
function addArrow(from, to, t, color) {
const arrow = new THREE.Group();
const p = new THREE.Vector3().lerpVectors(from, to, t);
arrow.position.set(p.x, 0.225, p.z);
const angle = -Math.atan2(to.z - from.z, to.x - from.x);
arrow.rotation.y = angle;
scene.add(arrow);
box(arrow, [0.62, 0.035, 0.13], [-0.10, 0, 0], color);
const wingA = box(arrow, [0.30, 0.035, 0.14], [0.18, 0, 0.16], color);
wingA.rotation.y = -Math.PI / 4;
const wingB = box(arrow, [0.30, 0.035, 0.14], [0.18, 0, -0.16], color);
wingB.rotation.y = Math.PI / 4;
}
for (let i = 0; i < 3; i++) {
addArrow(stagePositions[i], stagePositions[i + 1], 0.48, stageMeta[i + 1].color);
addArrow(stagePositions[i], stagePositions[i + 1], 0.73, stageMeta[i + 1].color);
}
// Voxel devices.
function buildDevice(type, color) {
const group = new THREE.Group();
if (type === "toaster") {
box(group, [0.74, 0.62, 0.54], [0, 0.34, 0], color);
box(group, [0.48, 0.07, 0.035], [0, 0.48, 0.282], 0x333d3d);
box(group, [0.12, 0.32, 0.09], [0.43, 0.37, 0], 0x3f5052);
box(group, [0.17, 0.08, 0.12], [0.49, 0.49, 0], 0xe3ddd0);
[-0.23, 0.23].forEach(x => {
box(group, [0.11, 0.08, 0.11], [x, 0.04, 0], 0x3d4947);
});
} else if (type === "radio") {
box(group, [0.78, 0.53, 0.43], [0, 0.30, 0], 0x3c5866);
box(group, [0.48, 0.31, 0.04], [-0.10, 0.31, 0.232], 0xe1d7bb);
for (let i = 0; i < 5; i++) {
box(group, [0.025, 0.25, 0.02], [-0.28 + i * 0.09, 0.31, 0.258], 0x768b8b);
}
box(group, [0.13, 0.13, 0.08], [0.26, 0.32, 0.25], color);
box(group, [0.05, 0.55, 0.05], [0.28, 0.67, -0.05], 0xc1c9c8, { metalness: 0.5 });
} else if (type === "kettle") {
box(group, [0.55, 0.48, 0.46], [0, 0.30, 0], color);
box(group, [0.42, 0.07, 0.36], [0, 0.57, 0], 0xd7d0bd);
box(group, [0.10, 0.10, 0.26], [-0.31, 0.42, 0], 0x3b4c4c);
box(group, [0.10, 0.38, 0.10], [0.38, 0.38, 0], 0x3b4c4c);
box(group, [0.10, 0.38, 0.10], [0.38, 0.38, 0.23], 0x3b4c4c);
box(group, [0.10, 0.10, 0.34], [0.38, 0.57, 0.115], 0x3b4c4c);
box(group, [0.06, 0.08, 0.05], [0.27, 0.32, 0.24], 0x4b5b59);
} else {
box(group, [0.72, 0.30, 0.62], [0, 0.19, 0], color);
box(group, [0.48, 0.32, 0.45], [0, 0.50, 0], 0x5f9e7d);
box(group, [0.10, 0.48, 0.10], [-0.22, 0.82, 0], 0x294a43);
box(group, [0.10, 0.48, 0.10], [0.22, 0.82, 0], 0x294a43);
box(group, [0.48, 0.10, 0.10], [0, 1.04, 0], 0x294a43);
box(group, [0.19, 0.19, 0.19], [0.40, 0.57, 0], 0x344c4b);
}
return group;
}
const itemDefinitions = [
{ id: "104", device: "TOASTER", type: "toaster", part: "HEATER", partType: "heater", partIndex: 0, color: 0xff6b4a, css: "#ff6b4a" },
{ id: "117", device: "RADIO", type: "radio", part: "PCB", partType: "pcb", partIndex: 1, color: 0x3f8cff, css: "#3f8cff" },
{ id: "128", device: "KETTLE", type: "kettle", part: "SWITCH", partType: "switch", partIndex: 2, color: 0xf5b942, css: "#f5b942" },
{ id: "131", device: "VACUUM", type: "vacuum", part: "MOTOR", partType: "motor", partIndex: 3, color: 0x37b58c, css: "#37b58c" }
];
const items = itemDefinitions.map((definition, index) => {
const group = new THREE.Group();
scene.add(group);
group.add(buildDevice(definition.type, definition.color));
const tag = makeLabel(
`#${definition.id} ${definition.device}`,
`${definition.part} / ${partDefinitions[definition.partIndex].code}`,
definition.css,
1.78
);
tag.position.set(0, 1.26, 0);
group.add(tag);
const preview = buildPart(definition.partType, definition.color);
preview.scale.setScalar(0.82);
preview.position.set(0.63, 0.12, 0.02);
group.add(preview);
const initialStage = index;
group.position.copy(stagePositions[initialStage]);
return {
...definition,
group,
tag,
preview,
stage: initialStage,
phase: "hold",
phaseTime: 0,
holdTime: [1.0, 0.55, 1.2, 0.7][index],
scale: 1
};
});
// Dynamic matching line from the active service item to its matching bin.
const matchLineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
new THREE.Vector3()
]);
const matchLine = new THREE.Line(
matchLineGeometry,
new THREE.LineBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.52,
depthTest: false
})
);
matchLine.renderOrder = 8;
scene.add(matchLine);
function drawKiosk(kiosk, item) {
const ctx = kiosk.canvas.getContext("2d");
const meta = stageMeta[kiosk.stageIndex];
const css = meta.css;
ctx.fillStyle = "#102d2a";
ctx.fillRect(0, 0, 512, 256);
ctx.fillStyle = css;
ctx.fillRect(0, 0, 512, 55);
ctx.fillStyle = "#102d2a";
ctx.font = "900 28px monospace";
ctx.textAlign = "left";
ctx.fillText(`0${kiosk.stageIndex + 1} ${meta.name}`, 24, 37);
ctx.textAlign = "center";
if (item) {
ctx.fillStyle = "#ffffff";
ctx.font = "900 54px monospace";
ctx.fillText(`#${item.id}`, 256, 119);
ctx.fillStyle = "#9fc0b7";
ctx.font = "800 22px monospace";
ctx.fillText(item.device, 256, 153);
ctx.fillStyle = css;
ctx.font = "900 22px monospace";
ctx.fillText(`MATCH: ${item.part}`, 256, 194);
partDefinitions.forEach((part, index) => {
const x = 98 + index * 105;
ctx.fillStyle = part.css;
ctx.fillRect(x - 27, 217, 54, 25);
if (index === item.partIndex) {
ctx.strokeStyle = "#ffffff";
ctx.lineWidth = 4;
ctx.strokeRect(x - 31, 213, 62, 33);
}
});
} else {
ctx.fillStyle = "#d9ebe4";
ctx.font = "900 43px monospace";
ctx.fillText("READY", 256, 132);
ctx.fillStyle = "#789b92";
ctx.font = "800 20px monospace";
ctx.fillText("WAITING FOR TICKET", 256, 174);
}
kiosk.texture.needsUpdate = true;
}
// A small voxel plant and floor sign complete the workshop.
const plant = new THREE.Group();
plant.position.set(-7.25, 0, 3.65);
scene.add(plant);
box(plant, [0.68, 0.62, 0.68], [0, 0.31, 0], 0xb96548);
box(plant, [0.14, 1.10, 0.14], [0, 1.10, 0], 0x355e49);
box(plant, [0.68, 0.18, 0.40], [-0.25, 1.35, 0], 0x4c8a62);
box(plant, [0.50, 0.18, 0.42], [0.27, 1.62, 0], 0x63a572);
box(plant, [0.42, 0.18, 0.38], [-0.12, 1.82, 0], 0x3f7957);
makeWorldLabel(
scene,
"OPEN REPAIR COUNTER",
"SCAN • DIAGNOSE • MATCH • FIX",
"#f4d16b",
[-0.8, 3.55, -2.35],
4.65
);
// Camera controls implemented without external controls or addons.
const cameraTarget = new THREE.Vector3(0, 1.15, -0.15);
let cameraYaw = 0.63;
let cameraPitch = 0.62;
let cameraZoom = 1;
let dragging = false;
let dragMoved = false;
let lastPointerX = 0;
let lastPointerY = 0;
function updateCamera() {
const radius = 19;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * Math.cos(cameraPitch) * radius,
cameraTarget.y + Math.sin(cameraPitch) * radius,
cameraTarget.z + Math.cos(cameraYaw) * Math.cos(cameraPitch) * radius
);
camera.lookAt(cameraTarget);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resetView() {
cameraYaw = 0.63;
cameraPitch = 0.62;
cameraZoom = 1;
cameraTarget.set(0, 1.15, -0.15);
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
dragMoved = false;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
if (Math.abs(dx) + Math.abs(dy) > 2) dragMoved = true;
if (event.shiftKey) {
const scale = 0.012 / cameraZoom;
const right = new THREE.Vector3(Math.cos(cameraYaw), 0, -Math.sin(cameraYaw));
const forward = new THREE.Vector3(-Math.sin(cameraYaw), 0, -Math.cos(cameraYaw));
cameraTarget.addScaledVector(right, -dx * scale);
cameraTarget.addScaledVector(forward, dy * scale);
cameraTarget.x = THREE.MathUtils.clamp(cameraTarget.x, -6, 6);
cameraTarget.z = THREE.MathUtils.clamp(cameraTarget.z, -5, 5);
} else {
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(cameraPitch + dy * 0.004, 0.32, 1.30);
}
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
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("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(cameraZoom * Math.exp(-event.deltaY * 0.001), 0.62, 2.25);
updateCamera();
}, { passive: false });
document.querySelector("#reset").addEventListener("click", resetView);
document.querySelector("#top").addEventListener("click", () => {
cameraYaw = 0;
cameraPitch = 1.28;
cameraZoom = 1;
cameraTarget.set(0, 0.8, -0.15);
updateCamera();
});
let paused = false;
const pauseButton = document.querySelector("#pause");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "RESUME FLOW" : "PAUSE FLOW";
pauseButton.classList.toggle("accent", paused);
});
function resize() {
const width = container.clientWidth;
const height = container.clientHeight;
const aspect = width / height;
const viewHeight = Math.max(11.8, 17.5 / aspect);
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const chips = [...document.querySelectorAll(".stage-chip")];
const activeStageEl = document.querySelector("#activeStage");
const readoutText = document.querySelector("#readoutText");
const clock = new THREE.Clock();
let elapsed = 0;
let displayTimer = 0;
function easeInOut(t) {
return t * t * (3 - 2 * t);
}
function updateItems(dt) {
for (const item of items) {
if (item.phase === "hold") {
item.phaseTime += dt;
const base = stagePositions[item.stage];
item.group.position.set(
base.x,
base.y + Math.sin(elapsed * 2.2 + item.id) * 0.012,
base.z
);
const collectionTimeout = item.stage === 3 ? 3.7 : item.holdTime;
if (item.phaseTime >= collectionTimeout) {
if (item.stage === 3) {
item.phase = "shrink";
item.phaseTime = 0;
} else {
item.phase = "move";
item.phaseTime = 0;
}
}
} else if (item.phase === "move") {
item.phaseTime += dt / 2.65;
const t = Math.min(item.phaseTime, 1);
const eased = easeInOut(t);
const from = stagePositions[item.stage];
const to = stagePositions[item.stage + 1];
item.group.position.x = THREE.MathUtils.lerp(from.x, to.x, eased);
item.group.position.z = THREE.MathUtils.lerp(from.z, to.z, eased);
item.group.position.y = THREE.MathUtils.lerp(from.y, to.y, eased) + Math.sin(t * Math.PI) * 0.20;
if (t >= 1) {
item.stage += 1;
item.phase = "hold";
item.phaseTime = 0;
}
} else if (item.phase === "shrink") {
item.phaseTime += dt / 0.65;
const t = Math.min(item.phaseTime, 1);
item.scale = 1 - easeInOut(t);
item.group.scale.setScalar(item.scale);
if (t >= 1) {
item.stage = 0;
item.group.position.copy(stagePositions[0]);
item.group.scale.setScalar(0.001);
item.phase = "spawn";
item.phaseTime = 0;
}
} else if (item.phase === "spawn") {
item.phaseTime += dt / 0.65;
const t = Math.min(item.phaseTime, 1);
item.scale = easeInOut(t);
item.group.scale.setScalar(item.scale);
if (t >= 1) {
item.scale = 1;
item.group.scale.setScalar(1);
item.phase = "hold";
item.phaseTime = 0;
}
}
item.preview.visible = item.stage === 1 || item.stage === 2;
}
}
function updateDisplays() {
const activeBins = new Set();
kiosks.forEach(kiosk => {
const item = items.find(candidate => candidate.stage === kiosk.stageIndex);
drawKiosk(kiosk, item);
const isActive = items.some(candidate => candidate.stage === kiosk.stageIndex);
kiosk.padMaterial.emissiveIntensity = isActive ? 0.52 : 0.12;
kiosk.padMaterial.opacity = isActive ? 0.34 : 0.18;
if (item && (item.stage === 1 || item.stage === 2)) {
activeBins.add(item.partIndex);
}
});
bins.forEach(bin => {
const active = activeBins.has(bin.index);
bin.material.emissiveIntensity = active ? 0.75 : 0.04;
bin.material.opacity = active ? 1 : 0.78;
});
const matchingItem = items.find(item => item.stage === 1) ||
items.find(item => item.stage === 2);
if (matchingItem) {
const itemPosition = new THREE.Vector3();
matchingItem.group.getWorldPosition(itemPosition);
itemPosition.y += 0.42;
const binPosition = new THREE.Vector3();
bins[matchingItem.partIndex].group.getWorldPosition(binPosition);
binPosition.z += 0.28;
const positions = matchLine.geometry.attributes.position;
positions.setXYZ(0, itemPosition.x, itemPosition.y, itemPosition.z);
positions.setXYZ(1, binPosition.x, binPosition.y, binPosition.z);
positions.needsUpdate = true;
matchLine.geometry.computeBoundingSphere();
matchLine.material.color.setHex(matchingItem.color);
matchLine.visible = true;
} else {
matchLine.visible = false;
}
chips.forEach(chip => {
chip.classList.toggle("active", items.some(item => item.stage === Number(chip.dataset.stage)));
});
const displayItem =
items.find(item => item.stage === 1) ||
items.find(item => item.stage === 2) ||
items.find(item => item.stage === 0) ||
items[0];
const displayStage = stageMeta[displayItem.stage];
activeStageEl.textContent = displayStage.name;
activeStageEl.style.color = displayStage.css;
readoutText.textContent = `#${displayItem.id} • ${displayItem.device} / ${displayItem.part}`;
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) {
elapsed += dt;
updateItems(dt);
}
displayTimer += dt;
if (displayTimer >= 0.14) {
updateDisplays();
displayTimer = 0;
}
renderer.render(scene, camera);
}
updateDisplays();
animate();
</script>
</body>
</html>
```