Prompt specification
Build or customize the Three.js 3D scene "Municipal service waiting room" 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: Municipal service waiting room
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/municipal-service-waiting-room-x0455
Scene Description Prompt:
Make a stylized municipal waiting room where seated visitors retain their ticket-queue positions before approaching counters. One HTML file using Three.js from cdnjs.
Working Three.js Starter (municipal-service-waiting-room-x0455):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Municipal Waiting Room</title>
<style>
:root {
--ink: #173f49;
--ink-soft: #42636a;
--paper: #fbf8ef;
--cream: #eee7d8;
--coral: #dc7258;
--gold: #e2b34f;
--mint: #91b7a7;
--shadow: 0 18px 45px rgba(23, 63, 73, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbd6cf;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.overlay {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: 24px;
left: 26px;
display: flex;
align-items: center;
gap: 13px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.crest {
position: relative;
display: grid;
place-items: center;
width: 46px;
height: 46px;
border: 2px solid var(--ink);
border-radius: 50%;
background: rgba(251, 248, 239, 0.75);
box-shadow: var(--shadow);
}
.crest::before {
content: "✦";
font-size: 24px;
line-height: 1;
}
.brand h1 {
margin: 0;
font-size: clamp(18px, 2vw, 27px);
font-weight: 780;
letter-spacing: -0.035em;
}
.brand p {
margin: 3px 0 0;
color: var(--ink-soft);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.card {
pointer-events: auto;
border: 1px solid rgba(255, 255, 255, 0.64);
border-radius: 18px;
background: rgba(251, 248, 239, 0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
.serving-card {
position: absolute;
top: 24px;
right: 26px;
width: 246px;
padding: 17px 18px 15px;
}
.eyebrow {
color: var(--ink-soft);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.serving-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
font-size: 18px;
font-weight: 790;
letter-spacing: -0.025em;
}
.live-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 5px rgba(220, 114, 88, 0.14);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 8px rgba(220, 114, 88, 0.04);
}
}
.serving-next {
display: flex;
justify-content: space-between;
margin-top: 13px;
padding-top: 11px;
border-top: 1px solid rgba(23, 63, 73, 0.13);
color: var(--ink-soft);
font-size: 12px;
}
.serving-next b {
color: var(--ink);
}
.service-track {
height: 4px;
margin-top: 13px;
overflow: hidden;
border-radius: 999px;
background: rgba(23, 63, 73, 0.1);
}
.service-track i {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--coral);
transition: width 0.15s linear;
}
.ticket-card {
position: absolute;
bottom: 26px;
left: 26px;
width: 294px;
padding: 18px;
}
.ticket-main {
display: flex;
align-items: baseline;
gap: 10px;
margin-top: 7px;
}
.ticket-number {
font-size: 32px;
font-weight: 850;
letter-spacing: -0.055em;
}
.ticket-position {
color: var(--ink-soft);
font-size: 12px;
font-weight: 700;
}
.ticket-status {
margin-top: 5px;
color: var(--ink-soft);
font-size: 12px;
line-height: 1.45;
}
.ticket-card::after {
content: "";
display: block;
width: 38px;
height: 4px;
margin-top: 14px;
border-radius: 10px;
background: var(--gold);
}
.controls {
position: absolute;
right: 26px;
bottom: 26px;
display: flex;
gap: 8px;
pointer-events: auto;
}
.controls button {
min-height: 42px;
padding: 0 15px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 12px;
background: rgba(251, 248, 239, 0.92);
color: var(--ink);
box-shadow: 0 8px 24px rgba(23, 63, 73, 0.13);
cursor: pointer;
font-size: 12px;
font-weight: 780;
transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.controls button:hover:not(:disabled) {
transform: translateY(-2px);
background: #fffdf7;
}
.controls button.primary {
border-color: var(--ink);
background: var(--ink);
color: var(--paper);
}
.controls button:disabled {
opacity: 0.45;
cursor: default;
}
.hint {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
padding: 8px 13px;
border-radius: 999px;
background: rgba(251, 248, 239, 0.72);
color: var(--ink-soft);
font-size: 11px;
font-weight: 650;
white-space: nowrap;
box-shadow: 0 8px 24px rgba(23, 63, 73, 0.09);
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #d7dfd8;
color: var(--ink);
font-size: 13px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 0.4s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.brand {
top: 15px;
left: 15px;
}
.brand p {
display: none;
}
.serving-card {
top: 15px;
right: 15px;
width: 188px;
padding: 13px;
}
.serving-row {
font-size: 14px;
}
.ticket-card {
bottom: 70px;
left: 15px;
width: 230px;
padding: 14px;
}
.ticket-number {
font-size: 25px;
}
.controls {
right: 15px;
bottom: 15px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="overlay">
<header class="brand">
<div class="crest" aria-hidden="true"></div>
<div>
<h1>Civic Service Hall</h1>
<p>Municipal waiting room</p>
</div>
</header>
<section class="card serving-card" aria-live="polite">
<div class="eyebrow">Now serving</div>
<div class="serving-row">
<span class="live-dot"></span>
<span id="nowText">Awaiting first call</span>
</div>
<div class="serving-next">
<span>Next ticket</span>
<b id="nextText">A042</b>
</div>
<div class="service-track"><i id="serviceProgress"></i></div>
</section>
<section class="card ticket-card">
<div class="eyebrow">Selected visitor</div>
<div class="ticket-main">
<span class="ticket-number" id="ticketNumber">A043</span>
<span class="ticket-position" id="queuePosition">Position 02 of 06</span>
</div>
<div class="ticket-status" id="visitorStatus">
Seated · ticket position retained
</div>
</section>
<div class="controls">
<button id="pauseButton" type="button">Pause</button>
<button id="callButton" class="primary" type="button">Advance queue</button>
<button id="resetButton" type="button">Reset</button>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Click a visitor</div>
</div>
<div id="loading">Building the service hall…</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, camera
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcbd6cf);
scene.fog = new THREE.Fog(0xcbd6cf, 27, 48);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.querySelector("#scene").appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
theta: 0.76,
phi: 0.91,
radius: 23,
target: new THREE.Vector3(0, 1, -0.7)
};
function updateCamera() {
const { theta, phi, radius, target } = controls;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xfff9e9, 0x718981, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff4dc, 3.4);
sun.position.set(-8, 14, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9e8ed, 1.1);
fill.position.set(12, 7, -4);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and helpers
// -------------------------------------------------------------------------
const standard = (color, roughness = 0.78, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const materials = {
floor: standard(0xd9d4c7),
floorEdge: standard(0xbbb8ae),
line: standard(0xc3bfb4),
wall: standard(0xf1ecdf),
wallGreen: standard(0x73998b),
trim: standard(0x294f57),
wood: standard(0xaa7650),
woodDark: standard(0x81563e),
metal: standard(0x3e5558, 0.45, 0.35),
cream: standard(0xf8f4e9),
dark: standard(0x183b43),
coral: standard(0xdc7258),
gold: standard(0xe2b34f),
mint: standard(0x92b8a8),
rug: standard(0xa7c1b4),
white: standard(0xfbfaf5),
black: standard(0x26383b),
plant: standard(0x477b5f),
plantLight: standard(0x6d9c6f),
soil: standard(0x5e493b),
screen: new THREE.MeshBasicMaterial({ color: 0x173f49 })
};
function box(w, h, d, material, x = 0, y = 0, z = 0, parent = scene) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(rTop, rBottom, h, material, x, y, z, parent = scene, segments = 24) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function sphere(radius, material, x, y, z, parent = scene, width = 16, height = 12) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, width, height),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, w, h, radius) {
const r = Math.min(radius, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function canvasTexture(width, height, painter) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
painter(ctx, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return { canvas, ctx, texture };
}
function wallLabel(text, width, height, x, y, z, options = {}) {
const {
background = "#173f49",
foreground = "#fbf8ef",
subtitle = "",
fontSize = 78
} = options;
const panel = canvasTexture(1024, 256, (ctx, w, h) => {
ctx.clearRect(0, 0, w, h);
roundedRect(ctx, 4, 4, w - 8, h - 8, 28);
ctx.fillStyle = background;
ctx.fill();
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `800 ${fontSize}px Arial, sans-serif`;
ctx.fillText(text, w / 2, subtitle ? h * 0.42 : h / 2);
if (subtitle) {
ctx.globalAlpha = 0.76;
ctx.font = "700 27px Arial, sans-serif";
ctx.fillText(subtitle, w / 2, h * 0.72);
ctx.globalAlpha = 1;
}
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: panel.texture,
transparent: true,
depthWrite: false
})
);
mesh.position.set(x, y, z);
scene.add(mesh);
return mesh;
}
function ticketSprite(ticket, position) {
const panel = canvasTexture(256, 128, (ctx, w, h) => {
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#f5cf67";
ctx.strokeStyle = "#173f49";
ctx.lineWidth = 6;
roundedRect(ctx, 10, 14, w - 20, h - 28, 14);
ctx.fill();
ctx.stroke();
ctx.fillStyle = "#173f49";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "900 44px Arial, sans-serif";
ctx.fillText(ticket, w / 2, h / 2);
ctx.setLineDash([5, 5]);
ctx.strokeStyle = "rgba(23,63,73,.35)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(18, h - 31);
ctx.lineTo(w - 18, h - 31);
ctx.stroke();
});
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: panel.texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(1.12, 0.56, 1);
sprite.position.copy(position);
sprite.renderOrder = 30;
return sprite;
}
// -------------------------------------------------------------------------
// Room shell and floor
// -------------------------------------------------------------------------
box(23, 0.5, 16.8, materials.floorEdge, 0, -0.31, 0);
box(22.7, 0.08, 16.4, materials.floor, 0, -0.02, 0);
for (let x = -10; x <= 10; x += 2) {
box(0.018, 0.012, 15.9, materials.line, x, 0.031, 0);
}
for (let z = -7; z <= 7; z += 2) {
box(22.2, 0.012, 0.018, materials.line, 0, 0.032, z);
}
box(23, 6.3, 0.28, materials.wall, 0, 3, -8.12);
box(23, 1.65, 0.32, materials.wallGreen, 0, 0.83, -8.04);
box(0.28, 6.3, 16.4, materials.wall, -11.43, 3, -0.1);
box(0.32, 1.65, 16.3, materials.wallGreen, -11.36, 0.83, -0.1);
box(22.7, 0.13, 0.08, materials.trim, 0, 0.12, -7.84);
box(0.08, 0.13, 16.1, materials.trim, -11.17, 0.12, -0.1);
box(9.6, 0.028, 7.25, materials.rug, -4, 0.055, 3.75);
// Left-side frosted windows.
for (const z of [-4.5, 0.1, 4.7]) {
box(0.06, 2.3, 3.35, materials.trim, -11.17, 3.2, z);
box(0.075, 2.08, 3.12, new THREE.MeshBasicMaterial({ color: 0xb9d7d5 }), -11.12, 3.2, z);
box(0.09, 0.07, 3.15, materials.trim, -11.08, 3.2, z);
}
// -------------------------------------------------------------------------
// Municipal identity, clock, notices
// -------------------------------------------------------------------------
const crest = cylinder(0.53, 0.53, 0.13, materials.gold, 0, 4.4, -7.86, scene, 32);
crest.rotation.x = Math.PI / 2;
const starShape = new THREE.Shape();
for (let i = 0; i < 10; i++) {
const radius = i % 2 === 0 ? 0.34 : 0.16;
const angle = -Math.PI / 2 + (i * Math.PI) / 5;
const x = Math.cos(angle) * radius;
const y = Math.sin(angle) * radius;
if (i === 0) starShape.moveTo(x, y);
else starShape.lineTo(x, y);
}
starShape.closePath();
const star = new THREE.Mesh(
new THREE.ShapeGeometry(starShape),
new THREE.MeshBasicMaterial({ color: 0x173f49 })
);
star.position.set(0, 4.4, -7.775);
scene.add(star);
wallLabel("CIVIC SERVICE HALL", 6.9, 0.92, 0, 3.38, -7.79, {
background: "#173f49",
foreground: "#fbf8ef",
subtitle: "PUBLIC COUNTERS • TICKET QUEUE",
fontSize: 68
});
const clockFace = cylinder(0.47, 0.47, 0.13, materials.cream, 9.4, 5.1, -7.84, scene, 32);
clockFace.rotation.x = Math.PI / 2;
const clockRim = new THREE.Mesh(
new THREE.TorusGeometry(0.43, 0.045, 10, 32),
materials.trim
);
clockRim.position.set(9.4, 5.1, -7.74);
scene.add(clockRim);
box(0.06, 0.28, 0.035, materials.trim, 9.4, 5.21, -7.67);
box(0.25, 0.055, 0.035, materials.trim, 9.47, 5.1, -7.66);
wallLabel("NOTICES", 1.55, 0.48, -9.65, 3.05, -7.79, {
background: "#e2b34f",
foreground: "#173f49",
fontSize: 65
});
box(1.75, 1.85, 0.1, materials.trim, -9.65, 2.15, -7.84);
box(1.56, 1.66, 0.045, materials.cream, -9.65, 2.15, -7.76);
for (let i = 0; i < 3; i++) {
const note = box(
0.62 + i * 0.08,
0.74,
0.025,
i === 1 ? materials.gold : materials.wallGreen,
-10.05 + i * 0.39,
2.18 + (i % 2) * 0.09,
-7.71
);
note.rotation.z = (i - 1) * 0.07;
}
// -------------------------------------------------------------------------
// Service counters
// -------------------------------------------------------------------------
const counters = [];
function createCounter(x, index) {
const group = new THREE.Group();
group.position.set(x, 0, -5.58);
scene.add(group);
box(3.55, 1.12, 1.2, materials.wallGreen, 0, 0.57, 0, group);
box(3.75, 0.15, 1.36, materials.woodDark, 0, 1.2, 0, group);
box(3.24, 0.68, 0.04, materials.cream, 0, 0.65, 0.62, group);
const numberDisc = cylinder(
0.35,
0.35,
0.08,
index === 1 ? materials.coral : materials.gold,
0,
0.7,
0.67,
group,
32
);
numberDisc.rotation.x = Math.PI / 2;
const numberPanel = canvasTexture(256, 256, (ctx, w, h) => {
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#173f49";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "900 120px Arial, sans-serif";
ctx.fillText(String(index + 1).padStart(2, "0"), w / 2, h / 2);
});
const number = new THREE.Mesh(
new THREE.PlaneGeometry(0.43, 0.43),
new THREE.MeshBasicMaterial({
map: numberPanel.texture,
transparent: true,
depthWrite: false
})
);
number.position.set(0, 0.7, 0.72);
group.add(number);
box(0.72, 0.5, 0.09, materials.dark, -0.75, 1.53, -0.12, group);
box(0.63, 0.41, 0.025, materials.screen, -0.75, 1.53, -0.06, group);
box(0.08, 0.22, 0.08, materials.metal, -0.75, 1.3, -0.12, group);
const display = canvasTexture(768, 320, (ctx, w, h) => {
ctx.fillStyle = "#173f49";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#e2b34f";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 49px Arial, sans-serif";
ctx.fillText(`WINDOW ${String(index + 1).padStart(2, "0")}`, w / 2, 75);
ctx.fillStyle = "#fbf8ef";
ctx.font = "900 102px Arial, sans-serif";
ctx.fillText("READY", w / 2, 190);
ctx.fillStyle = "rgba(251,248,239,.64)";
ctx.font = "700 27px Arial, sans-serif";
ctx.fillText("WAIT FOR YOUR NUMBER", w / 2, 266);
});
const displayMesh = new THREE.Mesh(
new THREE.PlaneGeometry(2.45, 1.02),
new THREE.MeshBasicMaterial({ map: display.texture })
);
displayMesh.position.set(x, 2.34, -7.78);
scene.add(displayMesh);
// Clerk behind the counter.
const agent = new THREE.Group();
agent.position.set(x, 0, -6.78);
scene.add(agent);
const cloth = standard(index === 1 ? 0x416d78 : 0x5c8077);
cylinder(0.28, 0.34, 0.8, cloth, 0, 0.98, 0, agent);
sphere(0.23, standard(0xd5a17f), 0, 1.57, 0, agent);
const hair = sphere(0.235, standard(0x4a3b34), 0, 1.69, -0.015, agent);
hair.scale.set(1, 0.58, 1);
box(0.12, 0.1, 0.09, standard(0xd5a17f), 0, 1.54, 0.22, agent);
box(0.56, 0.1, 0.05, materials.cream, 0, 1.18, 0.27, agent);
const counter = {
index,
x,
group,
agent,
display,
ticket: null
};
counters.push(counter);
return counter;
}
createCounter(-6, 0);
createCounter(0, 1);
createCounter(6, 2);
// -------------------------------------------------------------------------
// Waiting benches
// -------------------------------------------------------------------------
function createBench(x, z, width = 4) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(width, 0.18, 0.82, materials.wood, 0, 0.64, 0, group);
box(width, 0.75, 0.13, materials.woodDark, 0, 1.03, -0.37, group);
for (const dx of [-width / 2 + 0.25, width / 2 - 0.25]) {
box(0.13, 0.58, 0.55, materials.metal, dx, 0.29, 0, group);
box(0.12, 0.12, 0.62, materials.metal, dx, 0.68, 0, group);
}
const divider = box(0.08, 0.54, 0.08, materials.metal, 0, 0.92, -0.29, group);
divider.castShadow = false;
}
createBench(-6.1, 2.6);
createBench(-6.1, 5.1);
createBench(-1.2, 2.6);
createBench(-1.2, 5.1);
// -------------------------------------------------------------------------
// Ticket kiosk
// -------------------------------------------------------------------------
const kiosk = new THREE.Group();
kiosk.position.set(7.25, 0, 2.55);
scene.add(kiosk);
box(1.5, 0.18, 1.1, materials.trim, 0, 0.09, 0, kiosk);
box(1.05, 1.45, 0.72, materials.cream, 0, 0.87, 0, kiosk);
box(0.64, 0.09, 0.07, materials.dark, 0, 0.94, 0.39, kiosk);
box(0.28, 0.025, 0.18, materials.gold, 0, 0.9, 0.46, kiosk);
const screenAssembly = new THREE.Group();
screenAssembly.position.set(0, 1.62, 0.02);
screenAssembly.rotation.x = -0.22;
kiosk.add(screenAssembly);
box(1.22, 0.78, 0.16, materials.trim, 0, 0, 0, screenAssembly);
const kioskScreen = canvasTexture(640, 400, (ctx, w, h) => {
ctx.fillStyle = "#173f49";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#e2b34f";
ctx.textAlign = "center";
ctx.font = "900 68px Arial, sans-serif";
ctx.fillText("TICKETS", w / 2, 95);
ctx.fillStyle = "#fbf8ef";
ctx.font = "700 30px Arial, sans-serif";
ctx.fillText("Tap to take a number", w / 2, 175);
ctx.fillStyle = "#dc7258";
roundedRect(ctx, 145, 230, 350, 84, 18);
ctx.fill();
ctx.fillStyle = "#fff8ea";
ctx.font = "900 36px Arial, sans-serif";
ctx.fillText("TAKE NUMBER", w / 2, 284);
});
const kioskDisplay = new THREE.Mesh(
new THREE.PlaneGeometry(1.04, 0.63),
new THREE.MeshBasicMaterial({ map: kioskScreen.texture })
);
kioskDisplay.position.z = 0.09;
screenAssembly.add(kioskDisplay);
wallLabel("TAKE A NUMBER", 2.35, 0.63, 7.25, 2.48, 2.55, {
background: "#e2b34f",
foreground: "#173f49",
fontSize: 62
});
// -------------------------------------------------------------------------
// Queue position markers
// -------------------------------------------------------------------------
const queueMarkers = [];
for (let i = 0; i < 6; i++) {
const markerPanel = canvasTexture(256, 256, (ctx, w, h) => {
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#ffffff";
ctx.beginPath();
ctx.arc(w / 2, h / 2, 103, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = "#173f49";
ctx.lineWidth = 11;
ctx.stroke();
ctx.fillStyle = "#173f49";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "900 91px Arial, sans-serif";
ctx.fillText(String(i + 1).padStart(2, "0"), w / 2, h / 2 + 3);
});
const markerMaterial = new THREE.MeshBasicMaterial({
map: markerPanel.texture,
color: 0xffffff,
transparent: true,
depthWrite: false
});
const marker = new THREE.Mesh(
new THREE.PlaneGeometry(0.68, 0.68),
markerMaterial
);
marker.rotation.x = -Math.PI / 2;
marker.position.set(3.55, 0.075, 3.55 - i * 1.25);
scene.add(marker);
queueMarkers.push(marker);
}
for (let i = 0; i < 9; i++) {
box(0.11, 0.02, 0.42, materials.wallGreen, 3.55, 0.055, 3.05 - i * 0.75);
}
wallLabel("HOLD YOUR PLACE", 2.45, 0.55, 3.55, 0.035, -2.58, {
background: "#f8f4e9",
foreground: "#173f49",
fontSize: 61
}).rotation.x = -Math.PI / 2;
// -------------------------------------------------------------------------
// Plants, bins, small civic details
// -------------------------------------------------------------------------
function createPlant(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(0.37, 0.28, 0.62, materials.coral, 0, 0.31, 0, group);
cylinder(0.33, 0.33, 0.04, materials.soil, 0, 0.63, 0, group);
cylinder(0.055, 0.075, 1.1, materials.woodDark, 0, 1.08, 0, group);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const leaf = sphere(
0.34,
i % 2 ? materials.plant : materials.plantLight,
Math.cos(angle) * 0.28,
1.42 + (i % 3) * 0.18,
Math.sin(angle) * 0.28,
group
);
leaf.scale.set(0.55, 1.55, 0.45);
leaf.rotation.z = Math.cos(angle) * 0.55;
leaf.rotation.x = Math.sin(angle) * 0.55;
}
}
createPlant(-10.1, 6.55, 1.05);
createPlant(9.8, -5.9, 0.95);
createPlant(9.9, 6.55, 0.86);
function createBin(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
cylinder(0.27, 0.23, 0.75, materials.trim, 0, 0.38, 0, group);
cylinder(0.29, 0.29, 0.09, materials.metal, 0, 0.78, 0, group);
box(0.32, 0.1, 0.025, materials.black, 0, 0.62, 0.27, group);
}
createBin(4.85, 6.65);
createBin(-10.1, -6.2);
// -------------------------------------------------------------------------
// Dynamic wall queue board
// -------------------------------------------------------------------------
const queueBoard = canvasTexture(640, 900, (ctx, w, h) => {
ctx.fillStyle = "#173f49";
ctx.fillRect(0, 0, w, h);
});
const queueBoardMesh = new THREE.Mesh(
new THREE.PlaneGeometry(2.45, 3.45),
new THREE.MeshBasicMaterial({ map: queueBoard.texture })
);
queueBoardMesh.position.set(9.45, 3.12, -7.77);
scene.add(queueBoardMesh);
wallLabel("QUEUE BOARD", 2.45, 0.43, 9.45, 1.18, -7.77, {
background: "#e2b34f",
foreground: "#173f49",
fontSize: 63
});
// -------------------------------------------------------------------------
// Visitors
// -------------------------------------------------------------------------
const pickMeshes = [];
const visitors = [];
function createVisitor(data) {
const root = new THREE.Group();
root.position.copy(data.seat);
scene.add(root);
const body = new THREE.Group();
root.add(body);
const clothes = standard(data.color);
const skin = standard(data.skin);
const hairMaterial = standard(data.hair);
const torso = new THREE.Mesh(
new THREE.CapsuleGeometry(0.27, 0.5, 4, 10),
clothes
);
torso.position.y = 1.13;
torso.castShadow = true;
body.add(torso);
const head = sphere(0.235, skin, 0, 1.72, 0, body);
const hair = sphere(0.24, hairMaterial, 0, 1.85, -0.015, body);
hair.scale.set(1, 0.57, 1);
const nose = sphere(0.052, skin, 0, 1.7, 0.225, body, 10, 8);
nose.castShadow = false;
const arms = [];
for (const side of [-1, 1]) {
const pivot = new THREE.Group();
pivot.position.set(side * 0.34, 1.38, 0);
body.add(pivot);
const arm = cylinder(0.075, 0.075, 0.55, clothes, 0, -0.25, 0, pivot, 10);
arm.castShadow = true;
const hand = sphere(0.085, skin, 0, -0.54, 0, pivot, 10, 8);
arms.push(pivot);
}
const legs = [];
for (const side of [-1, 1]) {
const thighPivot = new THREE.Group();
thighPivot.position.set(side * 0.145, 0.73, 0);
root.add(thighPivot);
const thigh = cylinder(0.09, 0.095, 0.52, materials.dark, 0, -0.26, 0, thighPivot, 10);
const shinPivot = new THREE.Group();
shinPivot.position.y = -0.52;
thighPivot.add(shinPivot);
cylinder(0.075, 0.08, 0.5, materials.dark, 0, -0.25, 0, shinPivot, 10);
const shoe = box(0.19, 0.11, 0.3, materials.black, 0, -0.53, 0.055, shinPivot);
shoe.castShadow = true;
legs.push({ thighPivot, shinPivot });
}
// A few personal details: bags, folders, and scarves.
if (data.bag) {
const bag = box(
0.28,
0.35,
0.16,
standard(data.bagColor),
0.42,
0.68,
-0.04,
root
);
bag.rotation.z = -0.08;
}
if (data.folder) {
const folder = box(
0.32,
0.42,
0.055,
standard(0xe2b34f),
-0.39,
0.78,
0.16,
root
);
folder.rotation.z = 0.16;
}
const badge = ticketSprite(data.ticket, new THREE.Vector3(0, 2.03, 0));
root.add(badge);
const visitor = {
...data,
root,
body,
head,
hair,
arms,
legs,
badge,
status: "waiting",
counterIndex: null,
path: [],
pathIndex: 0,
walkPhase: 0,
serviceTimer: 0
};
root.traverse((object) => {
if (object.isMesh || object.isSprite) {
object.userData.visitor = visitor;
pickMeshes.push(object);
}
});
applyPose(visitor, true);
visitors.push(visitor);
return visitor;
}
function applyPose(visitor, seated) {
visitor.body.position.y = seated ? -0.42 : 0;
for (const leg of visitor.legs) {
leg.thighPivot.rotation.x = seated ? 1.34 : 0;
leg.shinPivot.rotation.x = seated ? -1.34 : 0;
}
for (const arm of visitor.arms) {
arm.rotation.x = seated ? -0.52 : 0;
arm.rotation.z = 0;
}
visitor.badge.position.y = seated ? 2.03 : 2.5;
}
const visitorData = [
{
name: "Elena",
ticket: "A042",
position: 1,
seat: new THREE.Vector3(-7.15, 0, 2.6),
color: 0xc56c58,
skin: 0xd8a17d,
hair: 0x3c302c,
bag: true,
bagColor: 0x315d63
},
{
name: "Maya",
ticket: "A043",
position: 2,
seat: new THREE.Vector3(-5.05, 0, 2.6),
color: 0x527e88,
skin: 0x9f6a4e,
hair: 0x272525,
folder: true
},
{
name: "Jonah",
ticket: "A044",
position: 3,
seat: new THREE.Vector3(-7.15, 0, 5.1),
color: 0xc9a047,
skin: 0xe0b38e,
hair: 0x6a4634,
bag: true,
bagColor: 0x8a5a43
},
{
name: "Amira",
ticket: "A045",
position: 4,
seat: new THREE.Vector3(-5.05, 0, 5.1),
color: 0x6d8f72,
skin: 0x8d5b42,
hair: 0x282322,
folder: true
},
{
name: "Theo",
ticket: "A046",
position: 5,
seat: new THREE.Vector3(-2.25, 0, 2.6),
color: 0x7b6f9b,
skin: 0xe2b48e,
hair: 0x73513b,
bag: true,
bagColor: 0xd7b05b
},
{
name: "Noor",
ticket: "A047",
position: 6,
seat: new THREE.Vector3(-0.15, 0, 5.1),
color: 0x478a86,
skin: 0xb87c5c,
hair: 0x342927,
folder: true
}
];
visitorData.forEach(createVisitor);
const selectionRing = new THREE.Mesh(
new THREE.RingGeometry(0.48, 0.56, 40),
new THREE.MeshBasicMaterial({
color: 0xe2b34f,
transparent: true,
opacity: 0.9,
side: THREE.DoubleSide,
depthWrite: false
})
);
selectionRing.rotation.x = -Math.PI / 2;
selectionRing.position.y = 0.085;
scene.add(selectionRing);
let selectedVisitor = visitors.find((visitor) => visitor.ticket === "A043");
// -------------------------------------------------------------------------
// Queue simulation
// -------------------------------------------------------------------------
let queueRunning = true;
let simulationTime = 0;
let nextCallTime = 3.5;
let callCounter = 0;
let activeVisitor = null;
const nowText = document.querySelector("#nowText");
const nextText = document.querySelector("#nextText");
const serviceProgress = document.querySelector("#serviceProgress");
const ticketNumber = document.querySelector("#ticketNumber");
const queuePosition = document.querySelector("#queuePosition");
const visitorStatus = document.querySelector("#visitorStatus");
const pauseButton = document.querySelector("#pauseButton");
const callButton = document.querySelector("#callButton");
const resetButton = document.querySelector("#resetButton");
function drawCounterDisplay(counter) {
const { ctx, canvas, texture } = counter.display;
const w = canvas.width;
const h = canvas.height;
ctx.fillStyle = "#173f49";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#e2b34f";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 49px Arial, sans-serif";
ctx.fillText(`WINDOW ${String(counter.index + 1).padStart(2, "0")}`, w / 2, 75);
ctx.fillStyle = "#fbf8ef";
ctx.font = "900 102px Arial, sans-serif";
ctx.fillText(counter.ticket || "READY", w / 2, 190);
ctx.fillStyle = "rgba(251,248,239,.64)";
ctx.font = "700 27px Arial, sans-serif";
ctx.fillText(
counter.ticket ? "PLEASE PROCEED TO WINDOW" : "WAIT FOR YOUR NUMBER",
w / 2,
266
);
texture.needsUpdate = true;
}
function drawQueueBoard() {
const { ctx, canvas, texture } = queueBoard;
const w = canvas.width;
const h = canvas.height;
ctx.fillStyle = "#173f49";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#e2b34f";
ctx.fillRect(0, 0, w, 118);
ctx.fillStyle = "#173f49";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.font = "900 46px Arial, sans-serif";
ctx.fillText("TICKET QUEUE", 34, 59);
ctx.fillStyle = "rgba(251,248,239,.58)";
ctx.font = "700 21px Arial, sans-serif";
ctx.fillText("POSITION", 38, 157);
ctx.fillText("TICKET", 235, 157);
ctx.fillText("STATUS", 405, 157);
visitors.forEach((visitor, index) => {
const y = 210 + index * 100;
ctx.fillStyle = index % 2 === 0 ? "rgba(255,255,255,.055)" : "rgba(255,255,255,.025)";
ctx.fillRect(22, y - 42, w - 44, 84);
ctx.fillStyle = "#fbf8ef";
ctx.font = "900 40px Arial, sans-serif";
ctx.fillText(String(visitor.position).padStart(2, "0"), 39, y);
ctx.fillStyle = "#e2b34f";
ctx.fillText(visitor.ticket, 232, y);
let status = "SEATED";
let statusColor = "#9cc4b2";
if (visitor.status === "walking") {
status = `WINDOW ${visitor.counterIndex + 1}`;
statusColor = "#f2b96a";
} else if (visitor.status === "serving") {
status = "SERVING";
statusColor = "#f08b70";
} else if (visitor.status === "leaving" || visitor.status === "done") {
status = "COMPLETE";
statusColor = "#91aaa8";
}
ctx.fillStyle = statusColor;
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText(status, 405, y);
});
texture.needsUpdate = true;
}
function refreshDisplays() {
const next = visitors
.filter((visitor) => visitor.status === "waiting")
.sort((a, b) => a.position - b.position)[0];
nextText.textContent = next ? next.ticket : "—";
if (activeVisitor && activeVisitor.status !== "done") {
if (activeVisitor.status === "serving") {
nowText.textContent = `Window ${activeVisitor.counterIndex + 1} · ${activeVisitor.ticket}`;
} else if (activeVisitor.status === "walking") {
nowText.textContent = `${activeVisitor.ticket} is approaching`;
} else {
nowText.textContent = `${activeVisitor.ticket} completed`;
}
} else {
nowText.textContent = next ? `Ready · ${next.ticket}` : "Queue complete";
}
for (const counter of counters) {
drawCounterDisplay(counter);
}
drawQueueBoard();
queueMarkers.forEach((marker, index) => {
const visitor = visitors.find((item) => item.position === index + 1);
let color = 0xffffff;
if (visitor?.status === "walking" || visitor?.status === "serving") {
color = 0xffad88;
} else if (visitor?.status === "leaving" || visitor?.status === "done") {
color = 0x9aa7a3;
}
marker.material.color.setHex(color);
});
if (selectedVisitor) {
ticketNumber.textContent = selectedVisitor.ticket;
queuePosition.textContent = `Position ${String(selectedVisitor.position).padStart(2, "0")} of 06`;
const labels = {
waiting: "Seated · ticket position retained",
walking: `Called · approaching Window ${selectedVisitor.counterIndex + 1}`,
serving: `At Window ${selectedVisitor.counterIndex + 1} · position retained`,
leaving: "Service complete · exiting the hall",
done: "Service complete"
};
visitorStatus.textContent = labels[selectedVisitor.status];
}
callButton.disabled = Boolean(activeVisitor && activeVisitor.status !== "done");
}
function callNextVisitor() {
if (activeVisitor && activeVisitor.status !== "done") return false;
const next = visitors
.filter((visitor) => visitor.status === "waiting")
.sort((a, b) => a.position - b.position)[0];
if (!next) return false;
const counter = counters[callCounter % counters.length];
callCounter++;
next.status = "walking";
next.counterIndex = counter.index;
next.path = [
new THREE.Vector3(next.seat.x, 0, next.seat.z + 0.9),
new THREE.Vector3(1.12, 0, next.seat.z + 0.9),
new THREE.Vector3(1.12, 0, -3.55),
new THREE.Vector3(counter.x, 0, -4.28)
];
next.pathIndex = 0;
next.walkPhase = 0;
next.serviceTimer = 0;
applyPose(next, false);
counter.ticket = next.ticket;
activeVisitor = next;
selectedVisitor = next;
nextCallTime = simulationTime + 8;
refreshDisplays();
return true;
}
function beginLeaving(visitor) {
visitor.status = "leaving";
visitor.path = [
new THREE.Vector3(visitor.root.position.x, 0, visitor.root.position.z),
new THREE.Vector3(1.12, 0, -3.55),
new THREE.Vector3(1.12, 0, 6.9),
new THREE.Vector3(11.9, 0, 7.3)
];
visitor.pathIndex = 0;
const counter = counters[visitor.counterIndex];
if (counter?.ticket === visitor.ticket) counter.ticket = null;
refreshDisplays();
}
function moveAlongPath(visitor, dt, speed = 3.15) {
if (!visitor.path.length) return false;
const target = visitor.path[visitor.pathIndex];
const direction = target.clone().sub(visitor.root.position);
direction.y = 0;
const distance = direction.length();
const step = speed * dt;
if (distance <= step) {
visitor.root.position.copy(target);
visitor.pathIndex++;
if (visitor.pathIndex >= visitor.path.length) {
return true;
}
} else {
direction.normalize();
visitor.root.position.addScaledVector(direction, step);
visitor.root.rotation.y = Math.atan2(direction.x, direction.z);
}
visitor.walkPhase += dt * 9;
const stride = Math.sin(visitor.walkPhase) * 0.52;
visitor.legs.forEach((leg, index) => {
const phase = index === 0 ? stride : -stride;
leg.thighPivot.rotation.x = phase;
leg.shinPivot.rotation.x = Math.max(0, -phase) * 0.65;
});
visitor.arms.forEach((arm, index) => {
arm.rotation.x = (index === 0 ? -stride : stride) * 0.72;
});
visitor.body.position.y = Math.abs(Math.sin(visitor.walkPhase)) * 0.035;
visitor.badge.position.y = 2.5;
return false;
}
function updateVisitors(dt) {
for (const visitor of visitors) {
if (visitor.status === "waiting") {
visitor.badge.position.y = 2.03 + Math.sin(simulationTime * 2 + visitor.position) * 0.025;
} else if (visitor.status === "walking") {
const arrived = moveAlongPath(visitor, dt);
if (arrived) {
visitor.status = "serving";
visitor.serviceTimer = 3.8;
applyPose(visitor, false);
refreshDisplays();
}
} else if (visitor.status === "serving") {
visitor.serviceTimer -= dt;
visitor.body.position.y = Math.sin(simulationTime * 2.5) * 0.012;
if (visitor.serviceTimer <= 0) {
beginLeaving(visitor);
}
} else if (visitor.status === "leaving") {
const exited = moveAlongPath(visitor, dt, 3.3);
if (exited) {
visitor.status = "done";
visitor.root.visible = false;
if (activeVisitor === visitor) activeVisitor = null;
refreshDisplays();
}
}
}
}
// -------------------------------------------------------------------------
// UI and reset
// -------------------------------------------------------------------------
pauseButton.addEventListener("click", () => {
queueRunning = !queueRunning;
pauseButton.textContent = queueRunning ? "Pause" : "Resume";
});
callButton.addEventListener("click", () => {
callNextVisitor();
});
resetButton.addEventListener("click", () => {
simulationTime = 0;
nextCallTime = 3.5;
callCounter = 0;
activeVisitor = null;
for (const visitor of visitors) {
visitor.status = "waiting";
visitor.counterIndex = null;
visitor.path = [];
visitor.pathIndex = 0;
visitor.serviceTimer = 0;
visitor.root.visible = true;
visitor.root.position.copy(visitor.seat);
visitor.root.rotation.set(0, 0, 0);
applyPose(visitor, true);
}
for (const counter of counters) {
counter.ticket = null;
}
selectedVisitor = visitors.find((visitor) => visitor.ticket === "A043");
refreshDisplays();
});
// -------------------------------------------------------------------------
// Direct camera controls and visitor selection
// -------------------------------------------------------------------------
let dragging = false;
let pointerStart = { x: 0, y: 0 };
let lastPointer = { x: 0, y: 0 };
let pointerMoved = false;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerMoved = false;
pointerStart = { x: event.clientX, y: event.clientY };
lastPointer = { ...pointerStart };
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
if (
Math.abs(event.clientX - pointerStart.x) +
Math.abs(event.clientY - pointerStart.y) > 5
) {
pointerMoved = true;
}
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.48, 1.34);
lastPointer = { x: event.clientX, y: event.clientY };
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (!pointerMoved) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickMeshes, false);
if (hits.length) {
selectedVisitor = hits[0].object.userData.visitor;
refreshDisplays();
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
13,
34
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
refreshDisplays();
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
if (queueRunning) {
simulationTime += dt;
updateVisitors(dt);
if (
(!activeVisitor || activeVisitor.status === "done") &&
simulationTime >= nextCallTime
) {
callNextVisitor();
nextCallTime = simulationTime + 8;
}
}
counters.forEach((counter, index) => {
const isServing =
activeVisitor &&
activeVisitor.counterIndex === index &&
activeVisitor.status === "serving";
counter.agent.position.y = isServing
? Math.sin(elapsed * 3.2) * 0.018
: Math.sin(elapsed * 1.2 + index) * 0.008;
});
if (selectedVisitor) {
selectionRing.visible = selectedVisitor.status !== "done";
selectionRing.position.x = selectedVisitor.root.position.x;
selectionRing.position.z = selectedVisitor.root.position.z;
selectionRing.material.opacity = 0.72 + Math.sin(elapsed * 3) * 0.18;
selectionRing.scale.setScalar(1 + Math.sin(elapsed * 3) * 0.035);
}
if (activeVisitor?.status === "serving") {
serviceProgress.style.width =
`${Math.max(0, Math.min(100, (1 - activeVisitor.serviceTimer / 3.8) * 100))}%`;
} else {
serviceProgress.style.width = "0%";
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
setTimeout(() => document.querySelector("#loading").remove(), 500);
});
</script>
</body>
</html>
```