Prompt specification
Build or customize the Three.js 3D scene "Compare aisle capacity under different display depths" 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: Compare aisle capacity under different display depths
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/compare-aisle-capacity-under-different-display-depths-x2880
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Vienna's Naschmarkt. Let users extend fictional stall displays into a shared corridor. Show the remaining passage width and route conflicts while keeping the market's permanent module spacing fixed. Voxel style.
Working Three.js Starter (compare-aisle-capacity-under-different-display-depths-x2880):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Naschmarkt Corridor Lab</title>
<style>
:root {
--ink: #26322f;
--muted: #718079;
--paper: #f5f0e6;
--panel: #fbf7ef;
--line: #ded8cb;
--teal: #287f78;
--teal-dark: #195e59;
--orange: #d96a43;
--gold: #e2ae48;
--red: #c94e3d;
--green: #3f936b;
--blue: #4f94bd;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #d9ded7;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input,
select {
font: inherit;
}
button,
select {
color: inherit;
}
#viewport {
position: fixed;
inset: 0 390px 0 0;
overflow: hidden;
background: #d9ded7;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
#panel {
position: fixed;
z-index: 10;
top: 0;
right: 0;
bottom: 0;
width: 390px;
overflow-y: auto;
padding: 26px 24px 30px;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 180px),
var(--panel);
border-left: 1px solid rgba(63, 72, 68, 0.14);
box-shadow: -12px 0 40px rgba(42, 52, 47, 0.09);
}
.brand {
position: absolute;
z-index: 3;
top: 24px;
left: 26px;
max-width: 390px;
pointer-events: none;
}
.brand-kicker {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid rgba(38, 50, 47, 0.14);
border-radius: 999px;
background: rgba(250, 247, 239, 0.82);
backdrop-filter: blur(8px);
color: var(--teal-dark);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.brand-kicker::before {
width: 7px;
height: 7px;
border-radius: 2px;
background: var(--orange);
content: "";
}
.brand h1 {
margin: 12px 0 4px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 52px);
font-weight: 500;
letter-spacing: -0.04em;
line-height: 0.98;
}
.brand p {
max-width: 340px;
margin: 9px 0 0;
color: #53635c;
font-size: 13px;
line-height: 1.5;
text-shadow: 0 1px rgba(255, 255, 255, 0.7);
}
.scene-hint {
position: absolute;
z-index: 3;
bottom: 20px;
left: 26px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid rgba(38, 50, 47, 0.13);
border-radius: 9px;
background: rgba(250, 247, 239, 0.82);
backdrop-filter: blur(8px);
color: #56645f;
font-size: 11px;
pointer-events: none;
}
.scene-hint kbd {
padding: 2px 5px;
border: 1px solid #c9c6ba;
border-bottom-width: 2px;
border-radius: 4px;
background: #fffdf7;
color: var(--ink);
font-size: 10px;
}
#toast {
position: absolute;
z-index: 6;
top: 24px;
right: 24px;
max-width: 330px;
padding: 12px 15px;
border-radius: 10px;
background: #26322f;
color: white;
box-shadow: 0 10px 30px rgba(31, 41, 38, 0.22);
font-size: 12px;
line-height: 1.45;
opacity: 0;
transform: translateY(-8px);
transition: 180ms ease;
pointer-events: none;
}
#toast.show {
opacity: 1;
transform: translateY(0);
}
#toast.warning {
background: var(--red);
}
.panel-kicker {
margin: 0 0 7px;
color: var(--orange);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.panel h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 30px;
font-weight: 500;
letter-spacing: -0.03em;
}
.intro {
margin: 10px 0 20px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.locked-note {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 18px;
padding: 10px 11px;
border: 1px solid #d9d5ca;
border-radius: 9px;
background: #f2eee4;
color: #5d6964;
font-size: 11px;
line-height: 1.4;
}
.lock-icon {
display: grid;
flex: 0 0 auto;
width: 24px;
height: 24px;
place-items: center;
border-radius: 7px;
background: #ded9cd;
color: #48534f;
font-size: 12px;
font-weight: 900;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-bottom: 20px;
}
.metric {
min-height: 96px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fffdf8;
}
.metric span {
display: block;
margin-bottom: 7px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.metric strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 29px;
font-weight: 500;
letter-spacing: -0.04em;
}
.metric small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
.metric.alert {
border-color: #e2aaa0;
background: #fff5f1;
}
.metric.alert strong {
color: var(--red);
}
.section {
padding: 18px 0;
border-top: 1px solid var(--line);
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
}
.section-title h3 {
margin: 0;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.02em;
}
.section-title span {
color: var(--muted);
font-size: 10px;
}
select {
width: 100%;
height: 40px;
padding: 0 34px 0 11px;
border: 1px solid #d6d1c5;
border-radius: 8px;
outline: none;
background: #fffdf8;
font-size: 12px;
font-weight: 650;
}
select:focus {
border-color: var(--teal);
box-shadow: 0 0 0 3px rgba(40, 127, 120, 0.1);
}
.selected-meta {
display: flex;
justify-content: space-between;
gap: 10px;
margin: 10px 1px 14px;
color: var(--muted);
font-size: 10px;
}
.slider-label {
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 7px;
font-size: 11px;
font-weight: 700;
}
output {
color: var(--teal-dark);
font-family: Georgia, "Times New Roman", serif;
font-size: 19px;
font-weight: 500;
}
input[type="range"] {
width: 100%;
height: 5px;
margin: 6px 0 13px;
border-radius: 999px;
outline: none;
background: linear-gradient(
90deg,
var(--teal) 0%,
var(--teal) var(--range-progress, 0%),
#ddd8cc var(--range-progress, 0%),
#ddd8cc 100%
);
appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
width: 18px;
height: 18px;
border: 3px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 1px 5px rgba(26, 55, 50, 0.3);
appearance: none;
}
input[type="range"]::-moz-range-thumb {
width: 14px;
height: 14px;
border: 3px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 1px 5px rgba(26, 55, 50, 0.3);
}
.button-row {
display: flex;
gap: 7px;
}
button {
min-height: 36px;
padding: 0 11px;
border: 1px solid #d2cdc0;
border-radius: 8px;
background: #fffdf8;
cursor: pointer;
font-size: 11px;
font-weight: 700;
transition:
transform 100ms ease,
border-color 100ms ease,
background 100ms ease;
}
button:hover {
border-color: #aaa79c;
background: white;
}
button:active {
transform: translateY(1px);
}
button.primary {
flex: 1;
border-color: var(--teal);
background: var(--teal);
color: white;
}
button.primary:hover {
border-color: var(--teal-dark);
background: var(--teal-dark);
}
button.danger {
color: var(--red);
}
.status-box {
margin-top: 12px;
padding: 10px 11px;
border-left: 3px solid var(--green);
border-radius: 0 7px 7px 0;
background: #eef4ec;
color: #476052;
font-size: 10px;
line-height: 1.45;
}
.status-box.warning {
border-color: var(--red);
background: #fff0ec;
color: #854a41;
}
.status-box.amber {
border-color: var(--gold);
background: #fff6df;
color: #77602c;
}
.route-note {
margin: 9px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.legend {
display: grid;
gap: 7px;
margin-top: 13px;
color: #5d6964;
font-size: 10px;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
}
.swatch {
width: 14px;
height: 8px;
border-radius: 2px;
}
#pairRows {
display: grid;
gap: 5px;
}
.pair-row {
display: grid;
grid-template-columns: 62px 1fr 70px;
align-items: center;
min-height: 34px;
padding: 0 9px;
border-color: #e0dbd0;
background: #fffdf8;
text-align: left;
}
.pair-row > span:first-child {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
}
.pair-width {
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
}
.pair-state {
justify-self: end;
color: var(--green);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.05em;
}
.pair-row.conflict {
border-color: #e5b0a7;
background: #fff3ef;
}
.pair-row.conflict .pair-state {
color: var(--red);
}
.pair-row.selected {
box-shadow: inset 3px 0 var(--teal);
}
.disclaimer {
margin: 2px 0 0;
padding-top: 15px;
border-top: 1px solid var(--line);
color: #89928e;
font-size: 9px;
line-height: 1.5;
}
@media (max-width: 850px) {
#viewport {
inset: 0 0 47vh 0;
}
#panel {
top: 53vh;
width: 100%;
padding: 20px;
border-top: 1px solid rgba(63, 72, 68, 0.14);
border-left: 0;
}
.brand {
top: 15px;
left: 16px;
}
.brand h1 {
font-size: 31px;
}
.brand p {
display: none;
}
.scene-hint {
bottom: 12px;
left: 16px;
}
#toast {
top: 12px;
right: 12px;
left: 12px;
max-width: none;
}
}
</style>
</head>
<body>
<main id="viewport" aria-label="Interactive voxel model of Vienna's Naschmarkt"></main>
<div class="brand">
<div class="brand-kicker">Vienna · Spatial concept model</div>
<h1>Naschmarkt</h1>
<p>
Extend fictional stall displays into the shared corridor and test a fixed
central visitor route.
</p>
</div>
<div class="scene-hint">
<span>Drag to orbit</span>
<span>·</span>
<span>Scroll to zoom</span>
<span>·</span>
<span>Shift-drag to pan</span>
<span>·</span>
<span>Click a stall</span>
</div>
<div id="toast" role="status" aria-live="polite"></div>
<aside id="panel">
<p class="panel-kicker">Shared corridor planner</p>
<h2>Display encroachment study</h2>
<p class="intro">
The permanent market modules stay locked in place. Only the temporary,
fictional display depth changes.
</p>
<div class="locked-note">
<span class="lock-icon">▣</span>
<span>
Permanent module centers are fixed at <strong>8.0 m</strong> spacing.
Extensions move only toward the shared passage.
</span>
</div>
<section class="metrics" aria-label="Corridor metrics">
<div class="metric" id="passageMetric">
<span>Minimum passage</span>
<strong id="passageValue">—</strong>
<small id="passageNote">Across all module pairs</small>
</div>
<div class="metric" id="conflictMetric">
<span>Route conflicts</span>
<strong id="conflictValue">—</strong>
<small id="conflictNote">2.4 m protected route</small>
</div>
</section>
<section class="section">
<div class="section-title">
<h3>Fictional stall display</h3>
<span id="selectedCode">R03</span>
</div>
<select id="stallSelect" aria-label="Select a market stall"></select>
<div class="selected-meta">
<span id="selectedSide">Right side</span>
<span id="selectedName">—</span>
</div>
<label class="slider-label" for="extensionRange">
<span>Extension into corridor</span>
<output id="extensionValue" for="extensionRange">0.0 m</output>
</label>
<input
id="extensionRange"
type="range"
min="0"
max="3.2"
step="0.1"
value="0"
/>
<div class="button-row">
<button type="button" data-delta="-0.5">−0.5 m</button>
<button type="button" data-delta="0.5">+0.5 m</button>
<button type="button" id="fillExtension">To center</button>
<button type="button" id="clearExtension" class="danger">Clear</button>
</div>
<div id="selectedStatus" class="status-box"></div>
</section>
<section class="section">
<div class="section-title">
<h3>Route test</h3>
<span>Fixed central envelope</span>
</div>
<div class="button-row">
<button type="button" id="runRoute" class="primary">Run route test</button>
<button type="button" id="resetAll" class="danger">Reset all</button>
</div>
<p class="route-note">
The blue strip is a protected <strong>2.4 m wide</strong> central route.
A conflict occurs when a display enters that envelope or the actual gap
between opposing displays falls below 2.4 m.
</p>
<div class="legend">
<div class="legend-item">
<span class="swatch" style="background:#8db5d0"></span>
Protected route envelope
</div>
<div class="legend-item">
<span class="swatch" style="background:#8dbb93"></span>
Adequate passage and clear route
</div>
<div class="legend-item">
<span class="swatch" style="background:#dfa94c"></span>
Reduced passage margin
</div>
<div class="legend-item">
<span class="swatch" style="background:#d76552"></span>
Route conflict or overlapping displays
</div>
</div>
</section>
<section class="section">
<div class="section-title">
<h3>Module pair check</h3>
<span>Click a row to select</span>
</div>
<div id="pairRows"></div>
</section>
<p class="disclaimer">
Concept visualization only. The module layout, display designs, route
envelope, and dimensions are illustrative rather than a survey or an
official proposal for Naschmarkt.
</p>
</aside>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.querySelector("#viewport");
const stallSelect = document.querySelector("#stallSelect");
const extensionRange = document.querySelector("#extensionRange");
const extensionValue = document.querySelector("#extensionValue");
const selectedCode = document.querySelector("#selectedCode");
const selectedSide = document.querySelector("#selectedSide");
const selectedName = document.querySelector("#selectedName");
const selectedStatus = document.querySelector("#selectedStatus");
const passageValue = document.querySelector("#passageValue");
const passageNote = document.querySelector("#passageNote");
const passageMetric = document.querySelector("#passageMetric");
const conflictValue = document.querySelector("#conflictValue");
const conflictNote = document.querySelector("#conflictNote");
const conflictMetric = document.querySelector("#conflictMetric");
const pairRows = document.querySelector("#pairRows");
const runRouteButton = document.querySelector("#runRoute");
const toast = document.querySelector("#toast");
const CORRIDOR_WIDTH = 6.4;
const HALF_CORRIDOR = CORRIDOR_WIDTH / 2;
const ROUTE_WIDTH = 2.4;
const ROUTE_HALF = ROUTE_WIDTH / 2;
const MODULE_DEPTH = 3.2;
const MODULE_LENGTH = 5.4;
const EXTENSION_LENGTH = 4.4;
const MODULE_PITCH = 8;
const MODULE_POSITIONS = [-16, -8, 0, 8, 16];
const state = {
selectedId: "R03",
route: {
running: false,
blocked: false,
completed: false,
z: -22.4
},
camera: {
azimuth: 0.68,
elevation: 0.88,
zoom: 1,
target: new THREE.Vector3(0, 0, 0)
}
};
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9ded7);
scene.fog = new THREE.Fog(0xd9ded7, 55, 95);
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.08;
viewport.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-20, 20, 20, -20, 0.1, 180);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const clock = new THREE.Clock();
const hemisphere = new THREE.HemisphereLight(0xfff8e8, 0x76867c, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d6, 3.1);
sun.position.set(13, 22, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d9e6, 0.8);
fill.position.set(-15, 10, -12);
scene.add(fill);
function makeMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
...options
});
}
function addBox(parent, width, height, depth, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeLabel(width = 4.2, height = 0.9) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 150;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, height, 1);
sprite.renderOrder = 20;
scene.add(sprite);
const label = {
sprite,
canvas,
ctx,
texture,
draw(text, background = "#29433f", foreground = "#ffffff", accent = null) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.shadowColor = "rgba(25,35,32,0.22)";
ctx.shadowBlur = 12;
ctx.shadowOffsetY = 4;
roundedRectPath(ctx, 8, 8, 624, 134, 22);
ctx.fillStyle = background;
ctx.fill();
ctx.shadowColor = "transparent";
if (accent) {
roundedRectPath(ctx, 24, 27, 10, 96, 5);
ctx.fillStyle = accent;
ctx.fill();
}
let fontSize = 48;
ctx.font = `700 ${fontSize}px Inter, system-ui, sans-serif`;
while (ctx.measureText(text).width > 558 && fontSize > 22) {
fontSize -= 2;
ctx.font = `700 ${fontSize}px Inter, system-ui, sans-serif`;
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
ctx.fillText(text, 320, 76);
texture.needsUpdate = true;
}
};
return label;
}
// Ground, corridor, and permanent streetscape.
const groundMaterial = makeMaterial(0xcac5b8);
addBox(scene, 28, 0.45, 52, groundMaterial, 0, -0.28, 0);
const corridorMaterial = makeMaterial(0xe9dfc9);
addBox(scene, CORRIDOR_WIDTH, 0.12, 48, corridorMaterial, 0, 0.02, 0);
const pavementMaterial = makeMaterial(0xbeb9ac);
addBox(scene, 9, 0.12, 48, pavementMaterial, -7.1, 0.035, 0);
addBox(scene, 9, 0.12, 48, pavementMaterial, 7.1, 0.035, 0);
const curbMaterial = makeMaterial(0xd8d2c4);
addBox(scene, 0.18, 0.2, 48, curbMaterial, -3.28, 0.1, 0);
addBox(scene, 0.18, 0.2, 48, curbMaterial, 3.28, 0.1, 0);
// Central visitor route.
const routeMaterial = new THREE.MeshBasicMaterial({
color: 0x4f94bd,
transparent: true,
opacity: 0.2,
depthWrite: false
});
const routeStrip = addBox(
scene,
ROUTE_WIDTH,
0.025,
47.4,
routeMaterial,
0,
0.105,
0
);
routeStrip.castShadow = false;
const routeEdgeMaterial = new THREE.LineDashedMaterial({
color: 0x3d7fa8,
dashSize: 0.65,
gapSize: 0.45,
transparent: true,
opacity: 0.75
});
for (const x of [-ROUTE_HALF, ROUTE_HALF]) {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x, 0.135, -23.5),
new THREE.Vector3(x, 0.135, 23.5)
]);
const line = new THREE.Line(geometry, routeEdgeMaterial);
line.computeLineDistances();
scene.add(line);
}
const routeLabel = makeLabel(4.1, 0.85);
routeLabel.draw("2.4 m ROUTE", "#315f78", "#ffffff", "#83bad8");
routeLabel.sprite.position.set(0, 0.65, -21.8);
// Voxel buildings beyond the market modules.
const buildingPalette = [0xd8c5ac, 0xc6d1c4, 0xd6b5a6, 0xc8c2d5, 0xd8cfb7];
for (const side of [-1, 1]) {
MODULE_POSITIONS.forEach((z, index) => {
const height = 5.4 + ((index * 3 + (side > 0 ? 1 : 0)) % 4) * 0.65;
const building = new THREE.Group();
building.position.set(side * 11.25, 0, z);
scene.add(building);
const bodyMaterial = makeMaterial(
buildingPalette[(index + (side > 0 ? 2 : 0)) % buildingPalette.length]
);
addBox(building, 3.5, height, 6.75, bodyMaterial, 0, height / 2, 0);
const roofMaterial = makeMaterial(0x7e7168);
addBox(building, 3.8, 0.28, 7.05, roofMaterial, 0, height + 0.14, 0);
const windowMaterial = makeMaterial(0x56717a, {
roughness: 0.35,
metalness: 0.08
});
const innerFace = -side * 1.77;
for (const windowZ of [-2.1, 0, 2.1]) {
addBox(
building,
0.08,
1.2,
0.95,
windowMaterial,
innerFace,
2.65,
windowZ
);
}
});
}
// Fixed-spacing ruler.
const rulerVertices = [];
for (const z of MODULE_POSITIONS) {
rulerVertices.push(
-8.65, 0.17, z,
-8.25, 0.17, z
);
}
rulerVertices.push(
-8.45, 0.17, MODULE_POSITIONS[0],
-8.45, 0.17, MODULE_POSITIONS[MODULE_POSITIONS.length - 1]
);
const rulerGeometry = new THREE.BufferGeometry();
rulerGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(rulerVertices, 3)
);
const ruler = new THREE.LineSegments(
rulerGeometry,
new THREE.LineBasicMaterial({ color: 0x9b7948 })
);
scene.add(ruler);
const pitchLabel = makeLabel(4.3, 0.85);
pitchLabel.draw("8.0 m FIXED PITCH", "#67543c", "#fffaf0", "#d4aa59");
pitchLabel.sprite.position.set(-8.45, 0.65, 0);
// End marker.
const endPostMaterial = makeMaterial(0x356f68);
addBox(scene, 0.22, 3.8, 0.22, endPostMaterial, -3.65, 1.9, 23.2);
addBox(scene, 0.22, 3.8, 0.22, endPostMaterial, 3.65, 1.9, 23.2);
addBox(scene, 7.5, 0.28, 0.3, endPostMaterial, 0, 3.75, 23.2);
const naschmarktLabel = makeLabel(5.8, 1.05);
naschmarktLabel.draw("NASCHMARKT", "#2f665f", "#fff9eb", "#e06e48");
naschmarktLabel.sprite.position.set(0, 4.55, 23.15);
const stalls = [
{
id: "L01", side: -1, z: -16, name: "Kaffee & Kuchen",
accent: 0xc75d48, extension: 0
},
{
id: "L02", side: -1, z: -8, name: "Pickles & Preserves",
accent: 0x548a6c, extension: 0
},
{
id: "L03", side: -1, z: 0, name: "Austrian Cheese",
accent: 0xd5a13e, extension: 0.6
},
{
id: "L04", side: -1, z: 8, name: "Street Food",
accent: 0xb85f78, extension: 0
},
{
id: "L05", side: -1, z: 16, name: "Market Flowers",
accent: 0x786ca9, extension: 0
},
{
id: "R01", side: 1, z: -16, name: "Viennese Wine",
accent: 0x8b4e4d, extension: 0
},
{
id: "R02", side: 1, z: -8, name: "Bread & Pastries",
accent: 0xd17c42, extension: 0
},
{
id: "R03", side: 1, z: 0, name: "Coffee & Cake",
accent: 0x3e8d88, extension: 0.9
},
{
id: "R04", side: 1, z: 8, name: "Herbs & Produce",
accent: 0x6f9853, extension: 0
},
{
id: "R05", side: 1, z: 16, name: "Craft & Souvenirs",
accent: 0x667b9e, extension: 0
}
];
const woodMaterial = makeMaterial(0x956544);
const darkWoodMaterial = makeMaterial(0x664633);
const creamMaterial = makeMaterial(0xf0e2c5);
const metalMaterial = makeMaterial(0x4b5551, {
roughness: 0.55,
metalness: 0.18
});
const pickMeshes = [];
function createStall(stall) {
const group = new THREE.Group();
const worldX = stall.side * (HALF_CORRIDOR + MODULE_DEPTH / 2);
group.position.set(worldX, 0, stall.z);
scene.add(group);
const accentMaterial = makeMaterial(stall.accent);
const innerLocal = -stall.side * MODULE_DEPTH / 2;
// Permanent module body.
addBox(group, MODULE_DEPTH, 0.42, MODULE_LENGTH, woodMaterial, 0, 0.22, 0);
addBox(group, MODULE_DEPTH - 0.2, 0.16, MODULE_LENGTH - 0.15,
darkWoodMaterial, 0, 0.48, 0);
const counterX = innerLocal - stall.side * 0.38;
addBox(group, 0.72, 1.15, 4.85, creamMaterial, counterX, 1.07, 0);
addBox(group, 0.88, 0.14, 5.0, darkWoodMaterial, counterX, 1.7, 0);
const backX = stall.side * (MODULE_DEPTH / 2 - 0.12);
addBox(group, 0.16, 2.45, 4.9, woodMaterial, backX, 1.5, 0);
for (const x of [-1.42, 1.42]) {
for (const z of [-2.43, 2.43]) {
addBox(group, 0.12, 2.75, 0.12, metalMaterial, x, 1.5, z);
}
}
// Striped voxel awning.
const stripeCount = 8;
for (let i = 0; i < stripeCount; i++) {
const material = i % 2 === 0 ? accentMaterial : creamMaterial;
addBox(
group,
MODULE_DEPTH + 0.58,
0.22,
0.66,
material,
0,
3.02,
-2.63 + i * 0.75
);
}
// Small voxel goods on the counter.
const productColors = [0xe4b447, 0xcb654d, 0x6f9b5b, 0xf0d9a2];
for (let i = 0; i < 5; i++) {
const productMaterial = makeMaterial(
productColors[(i + Math.abs(stall.side)) % productColors.length]
);
addBox(
group,
0.48,
0.34,
0.48,
productMaterial,
counterX,
1.94,
-1.8 + i * 0.9
);
}
// Small code label.
const codeLabel = makeLabel(1.25, 0.37);
codeLabel.draw(stall.id, "#34443f", "#ffffff", "#e7a349");
codeLabel.sprite.position.set(
worldX + innerLocal - stall.side * 0.45,
3.68,
stall.z
);
// Selection frame.
const frameGeometry = new THREE.EdgesGeometry(
new THREE.BoxGeometry(MODULE_DEPTH + 0.55, 3.65, MODULE_LENGTH + 0.55)
);
const frameMaterial = new THREE.LineBasicMaterial({
color: 0xf2b646,
transparent: true,
opacity: 0.9
});
const frame = new THREE.LineSegments(frameGeometry, frameMaterial);
frame.position.y = 1.72;
frame.visible = false;
group.add(frame);
// Extension platform.
const extensionMaterial = makeMaterial(stall.accent, {
emissive: stall.accent,
emissiveIntensity: 0.12,
transparent: true,
opacity: 0.94
});
const platform = addBox(
group,
1,
1,
1,
extensionMaterial,
0,
0.14,
0
);
const edge = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(1, 1, 1)),
new THREE.LineBasicMaterial({
color: 0xfff1cf,
transparent: true,
opacity: 0.8
})
);
group.add(edge);
const extensionProducts = [];
const extensionProductColors = [0xf2c45f, 0xe88458, 0x8eb77a];
for (let i = 0; i < 3; i++) {
const product = addBox(
group,
0.42,
0.48,
0.56,
makeMaterial(extensionProductColors[i]),
0,
0.52,
-1.35 + i * 1.35
);
extensionProducts.push(product);
}
// Invisible but raycastable selection volume.
const pickMesh = new THREE.Mesh(
new THREE.BoxGeometry(MODULE_DEPTH + 0.9, 4, MODULE_LENGTH + 0.7),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
})
);
pickMesh.position.set(0, 1.8, 0);
pickMesh.userData.stallId = stall.id;
group.add(pickMesh);
pickMeshes.push(pickMesh);
Object.assign(stall, {
group,
frame,
innerLocal,
extensionMaterial,
platform,
edge,
extensionProducts
});
}
stalls.forEach(createStall);
const pairs = MODULE_POSITIONS.map((z, index) => {
const left = stalls.find((s) => s.side === -1 && s.z === z);
const right = stalls.find((s) => s.side === 1 && s.z === z);
const segmentMaterial = new THREE.MeshBasicMaterial({
color: 0x81b58c,
transparent: true,
opacity: 0.15,
depthWrite: false
});
const segment = addBox(
scene,
CORRIDOR_WIDTH,
0.035,
6.8,
segmentMaterial,
0,
0.14,
z
);
segment.castShadow = false;
const dimensionGeometry = new THREE.BufferGeometry();
dimensionGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(new Float32Array(18), 3)
);
const dimension = new THREE.LineSegments(
dimensionGeometry,
new THREE.LineBasicMaterial({ color: 0x3f936b })
);
scene.add(dimension);
const label = makeLabel(3.65, 0.78);
label.sprite.position.set(0, 0.75, z + 3.0);
const marker = makeLabel(4.4, 0.95);
marker.sprite.position.set(0, 4.75, z);
return {
index,
z,
left,
right,
segment,
dimension,
label,
marker,
metrics: null
};
});
const selectedExtensionLabel = makeLabel(3.3, 0.75);
// Voxel delivery trolley used by the route test.
const trolley = new THREE.Group();
scene.add(trolley);
const cartBodyMaterial = makeMaterial(0x2c7c76, {
emissive: 0x2c7c76,
emissiveIntensity: 0.08
});
const cartCrateMaterial = makeMaterial(0xd9a34c);
const wheelMaterial = makeMaterial(0x343b39);
addBox(trolley, 1.1, 0.4, 1.55, cartBodyMaterial, 0, 0.48, 0);
addBox(trolley, 0.78, 0.7, 1.05, cartCrateMaterial, 0, 1.0, -0.05);
addBox(trolley, 0.62, 0.12, 0.88, creamMaterial, 0, 1.41, -0.05);
for (const x of [-0.58, 0.58]) {
for (const z of [-0.48, 0.48]) {
addBox(trolley, 0.2, 0.34, 0.34, wheelMaterial, x, 0.28, z);
}
}
// Populate the controls.
stallSelect.innerHTML = stalls
.map(
(s) =>
`<option value="${s.id}">${s.id} · ${s.name} · ${
s.side < 0 ? "Left" : "Right"
}</option>`
)
.join("");
pairRows.innerHTML = pairs
.map(
(p) => `
<button type="button" class="pair-row" data-pair="${p.index}">
<span>PAIR ${String(p.index + 1).padStart(2, "0")}</span>
<span class="pair-width">—</span>
<span class="pair-state">CLEAR</span>
</button>
`
)
.join("");
let toastTimeout;
function showToast(message, warning = false) {
toast.textContent = message;
toast.classList.toggle("warning", warning);
toast.classList.add("show");
clearTimeout(toastTimeout);
toastTimeout = setTimeout(() => toast.classList.remove("show"), 3400);
}
function getSelectedStall() {
return stalls.find((s) => s.id === state.selectedId);
}
function getSelectedPair() {
const selected = getSelectedStall();
return pairs.find((p) => p.left.id === selected.id || p.right.id === selected.id);
}
function selectStall(id) {
if (!stalls.some((s) => s.id === id)) return;
state.selectedId = id;
stallSelect.value = id;
updateSceneAndUI();
}
function updateExtension(stall) {
const amount = Math.max(0, stall.extension);
const visible = amount > 0.01;
const inner = stall.innerLocal;
stall.platform.visible = visible;
stall.edge.visible = visible;
const platformX = inner + stall.side * amount / 2;
stall.platform.position.set(platformX, 0.14, 0);
stall.platform.scale.set(Math.max(amount, 0.001), 0.24, EXTENSION_LENGTH);
stall.edge.position.copy(stall.platform.position);
stall.edge.scale.copy(stall.platform.scale);
stall.extensionProducts.forEach((product, i) => {
const fraction = 0.24 + i * 0.26;
product.visible = visible;
product.position.set(
inner + stall.side * amount * fraction,
0.52,
-1.35 + i * 1.35
);
});
const selected = state.selectedId === stall.id;
stall.extensionMaterial.emissiveIntensity = selected ? 0.36 : 0.12;
stall.frame.visible = selected;
}
function setDimension(p, clear, color) {
const x1 = -HALF_CORRIDOR + p.left.extension;
const x2 = HALF_CORRIDOR - p.right.extension;
const y = 0.2;
const z = p.z + 3.0;
const positions = p.dimension.geometry.attributes.position.array;
positions.set([
x1, y, z, x2, y, z,
x1, y, z - 0.34, x1, y, z + 0.34,
x2, y, z - 0.34, x2, y, z + 0.34
]);
p.dimension.geometry.attributes.position.needsUpdate = true;
p.dimension.geometry.computeBoundingSphere();
p.dimension.material.color.set(color);
}
function updateRouteButton() {
if (state.route.running) {
runRouteButton.textContent = "Pause route test";
} else if (state.route.blocked) {
runRouteButton.textContent = "Retry route test";
} else if (state.route.completed) {
runRouteButton.textContent = "Run again";
} else {
runRouteButton.textContent = "Run route test";
}
}
function updateSceneAndUI() {
let minimumClearance = Infinity;
let minimumPair = null;
let conflictCount = 0;
for (const stall of stalls) {
updateExtension(stall);
}
for (const p of pairs) {
const leftExtension = p.left.extension;
const rightExtension = p.right.extension;
const clear = CORRIDOR_WIDTH - leftExtension - rightExtension;
const entersRoute =
leftExtension > HALF_CORRIDOR - ROUTE_HALF + 0.001 ||
rightExtension > HALF_CORRIDOR - ROUTE_HALF + 0.001;
const conflict = clear < ROUTE_WIDTH - 0.001 || entersRoute;
const warning = !conflict && clear < 3.2;
p.metrics = {
clear,
conflict,
warning,
entersRoute,
overlap: Math.max(0, -clear)
};
if (clear < minimumClearance) {
minimumClearance = clear;
minimumPair = p;
}
if (conflict) conflictCount += 1;
const color = conflict ? 0xd76552 : warning ? 0xdfa94c : 0x8dbb93;
p.segment.material.color.set(color);
p.segment.material.opacity = conflict ? 0.46 : warning ? 0.28 : 0.16;
setDimension(p, clear, color);
const selectedPair = getSelectedPair() === p;
p.label.sprite.visible = selectedPair || conflict;
p.label.draw(
`${clear.toFixed(2)} m · ${conflict ? "CONFLICT" : warning ? "TIGHT" : "CLEAR"}`,
conflict ? "#a94437" : warning ? "#9b742b" : "#39785d",
"#ffffff",
conflict ? "#f4a18d" : warning ? "#f4cf72" : "#96d0a7"
);
p.marker.sprite.visible = conflict;
p.marker.draw(
"ROUTE CONFLICT",
"#b6483b",
"#fff8ed",
"#f1a58f"
);
const row = pairRows.querySelector(`[data-pair="${p.index}"]`);
row.classList.toggle("conflict", conflict);
row.classList.toggle("selected", selectedPair);
row.querySelector(".pair-width").textContent = `${clear.toFixed(2)} m`;
row.querySelector(".pair-state").textContent = conflict
? "CONFLICT"
: warning
? "TIGHT"
: "CLEAR";
}
const selected = getSelectedStall();
const selectedPair = getSelectedPair();
const selectedMetrics = selectedPair.metrics;
selectedCode.textContent = selected.id;
selectedSide.textContent = `${selected.side < 0 ? "Left" : "Right"} side · fixed module`;
selectedName.textContent = selected.name;
extensionRange.value = selected.extension.toFixed(1);
extensionValue.textContent = `${selected.extension.toFixed(1)} m`;
const progress = (selected.extension / Number(extensionRange.max)) * 100;
extensionRange.style.setProperty("--range-progress", `${progress}%`);
const selectedEntersRoute =
selected.extension > HALF_CORRIDOR - ROUTE_HALF + 0.001;
selectedStatus.className = "status-box";
if (selectedMetrics.overlap > 0.001) {
selectedStatus.classList.add("warning");
selectedStatus.textContent =
`The opposing displays overlap by ${selectedMetrics.overlap.toFixed(2)} m. ` +
"The passage is physically blocked at this module pair.";
} else if (selectedEntersRoute) {
selectedStatus.classList.add("warning");
selectedStatus.textContent =
`This display enters the protected central route envelope. ` +
`Only ${selectedMetrics.clear.toFixed(2)} m remains between the opposing display edges.`;
} else if (selectedMetrics.conflict) {
selectedStatus.classList.add("warning");
selectedStatus.textContent =
`This module pair has ${selectedMetrics.clear.toFixed(2)} m of passage, ` +
"below the required 2.4 m route width.";
} else if (selectedMetrics.warning) {
selectedStatus.classList.add("amber");
selectedStatus.textContent =
`Route is currently clear, but the ${selectedMetrics.clear.toFixed(2)} m passage ` +
"has limited spare clearance.";
} else {
selectedStatus.textContent =
`Route is clear. This pair retains ${selectedMetrics.clear.toFixed(2)} m ` +
"of passage around the temporary display.";
}
passageValue.textContent = `${minimumClearance.toFixed(2)} m`;
passageNote.textContent = minimumPair
? `Tightest pair: ${minimumPair.left.id} / ${minimumPair.right.id}`
: "Across all module pairs";
passageMetric.classList.toggle(
"alert",
minimumClearance < ROUTE_WIDTH || minimumClearance < 0
);
conflictValue.textContent = String(conflictCount);
conflictNote.textContent = conflictCount
? "Module pairs requiring adjustment"
: "No protected-route conflicts";
conflictMetric.classList.toggle("alert", conflictCount > 0);
const selectedInnerWorld =
selected.group.position.x +
selected.innerLocal +
selected.side * selected.extension / 2;
selectedExtensionLabel.sprite.position.set(
selectedInnerWorld,
4.25,
selected.z
);
selectedExtensionLabel.draw(
`${selected.id} +${selected.extension.toFixed(1)} m`,
"#75512f",
"#fff7e9",
"#e9ae54"
);
updateRouteButton();
}
stallSelect.addEventListener("change", (event) => {
selectStall(event.target.value);
});
extensionRange.addEventListener("input", (event) => {
const selected = getSelectedStall();
selected.extension = Number(event.target.value);
updateSceneAndUI();
});
document.querySelectorAll("[data-delta]").forEach((button) => {
button.addEventListener("click", () => {
const selected = getSelectedStall();
const delta = Number(button.dataset.delta);
selected.extension = THREE.MathUtils.clamp(
Number((selected.extension + delta).toFixed(1)),
0,
3.2
);
updateSceneAndUI();
});
});
document.querySelector("#fillExtension").addEventListener("click", () => {
getSelectedStall().extension = 3.2;
updateSceneAndUI();
});
document.querySelector("#clearExtension").addEventListener("click", () => {
getSelectedStall().extension = 0;
updateSceneAndUI();
});
document.querySelector("#resetAll").addEventListener("click", () => {
stalls.forEach((stall) => {
stall.extension = 0;
});
state.route.running = false;
state.route.blocked = false;
state.route.completed = false;
state.route.z = -22.4;
updateSceneAndUI();
showToast("All temporary displays have been cleared.");
});
pairRows.addEventListener("click", (event) => {
const row = event.target.closest("[data-pair]");
if (!row) return;
const pair = pairs[Number(row.dataset.pair)];
selectStall(pair.left.id);
});
function nextRouteConflict() {
return pairs.find(
(p) =>
p.metrics.conflict &&
p.z - 3.35 > state.route.z + 0.02
);
}
runRouteButton.addEventListener("click", () => {
if (state.route.running) {
state.route.running = false;
updateRouteButton();
return;
}
if (
state.route.blocked ||
state.route.completed ||
state.route.z > 22
) {
state.route.z = -22.4;
state.route.blocked = false;
state.route.completed = false;
}
state.route.running = true;
updateRouteButton();
showToast("Testing the fixed 2.4 m central route envelope…");
});
function updateRoute(delta) {
if (state.route.running) {
const nextZ = state.route.z + 3.8 * delta;
const conflict = nextRouteConflict();
if (conflict) {
const stopZ = conflict.z - 3.35;
if (nextZ >= stopZ) {
state.route.z = stopZ;
state.route.running = false;
state.route.blocked = true;
updateRouteButton();
showToast(
`Route test stopped at ${conflict.left.id} / ${conflict.right.id}: ` +
"the protected route envelope is obstructed.",
true
);
} else {
state.route.z = nextZ;
}
} else if (nextZ >= 22.1) {
state.route.z = 22.1;
state.route.running = false;
state.route.completed = true;
updateRouteButton();
showToast("Route test passed: all module pairs are clear.");
} else {
state.route.z = nextZ;
}
}
trolley.position.set(0, 0, state.route.z);
trolley.position.y = state.route.running
? Math.sin(performance.now() * 0.012) * 0.025
: 0;
cartBodyMaterial.color.set(state.route.blocked ? 0xb8493c : 0x2c7c76);
cartBodyMaterial.emissive.set(state.route.blocked ? 0xb8493c : 0x2c7c76);
cartBodyMaterial.emissiveIntensity = state.route.blocked ? 0.3 : 0.08;
}
// Direct camera controls: orbit, pan, zoom, and keyboard support.
const drag = {
active: false,
pointerId: null,
startX: 0,
startY: 0,
lastX: 0,
lastY: 0,
moved: false,
shift: false
};
function updateCamera() {
const aspect = viewport.clientWidth / Math.max(viewport.clientHeight, 1);
const halfHeight = 19 / state.camera.zoom;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
const { azimuth, elevation, target } = state.camera;
const radius = 48;
camera.position.set(
target.x + Math.sin(azimuth) * Math.cos(elevation) * radius,
target.y + Math.sin(elevation) * radius,
target.z + Math.cos(azimuth) * Math.cos(elevation) * radius
);
camera.lookAt(target);
camera.updateProjectionMatrix();
camera.updateMatrixWorld();
}
function resize() {
renderer.setSize(viewport.clientWidth, viewport.clientHeight, false);
updateCamera();
}
new ResizeObserver(resize).observe(viewport);
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
drag.active = true;
drag.pointerId = event.pointerId;
drag.startX = event.clientX;
drag.startY = event.clientY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
drag.moved = false;
drag.shift = event.shiftKey;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!drag.active) return;
const dx = event.clientX - drag.lastX;
const dy = event.clientY - drag.lastY;
drag.lastX = event.clientX;
drag.lastY = event.clientY;
if (
Math.abs(event.clientX - drag.startX) +
Math.abs(event.clientY - drag.startY) >
5
) {
drag.moved = true;
}
if (drag.shift || event.shiftKey) {
const scale = 38 / state.camera.zoom / viewport.clientHeight;
const azimuth = state.camera.azimuth;
state.camera.target.x -= dx * scale * Math.cos(azimuth);
state.camera.target.z += dx * scale * Math.sin(azimuth);
state.camera.target.x += dy * scale * Math.sin(azimuth);
state.camera.target.z += dy * scale * Math.cos(azimuth);
} else {
state.camera.azimuth -= dx * 0.006;
state.camera.elevation = THREE.MathUtils.clamp(
state.camera.elevation + dy * 0.004,
0.38,
1.38
);
}
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!drag.active) return;
drag.active = false;
renderer.domElement.releasePointerCapture(event.pointerId);
if (!drag.moved) {
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 hit = raycaster.intersectObjects(pickMeshes, false)[0];
if (hit) {
selectStall(hit.object.userData.stallId);
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
drag.active = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
state.camera.zoom = THREE.MathUtils.clamp(
state.camera.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.8
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
state.camera.azimuth = 0.68;
state.camera.elevation = 0.88;
state.camera.zoom = 1;
state.camera.target.set(0, 0, 0);
updateCamera();
});
window.addEventListener("keydown", (event) => {
if (["INPUT", "SELECT", "TEXTAREA"].includes(document.activeElement.tagName)) {
return;
}
switch (event.key) {
case "ArrowLeft":
state.camera.azimuth += 0.08;
break;
case "ArrowRight":
state.camera.azimuth -= 0.08;
break;
case "ArrowUp":
state.camera.elevation = Math.min(
1.38,
state.camera.elevation + 0.05
);
break;
case "ArrowDown":
state.camera.elevation = Math.max(
0.38,
state.camera.elevation - 0.05
);
break;
case "+":
case "=":
state.camera.zoom = Math.min(1.8, state.camera.zoom + 0.08);
break;
case "-":
state.camera.zoom = Math.max(0.65, state.camera.zoom - 0.08);
break;
default:
return;
}
event.preventDefault();
updateCamera();
});
resize();
updateSceneAndUI();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
updateRoute(delta);
const selected = getSelectedStall();
selected.frame.material.opacity =
0.72 + Math.sin(performance.now() * 0.004) * 0.18;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```