Prompt specification
Build or customize the Three.js 3D scene "Borrowing Desk Rule Cards" 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: Borrowing Desk Rule Cards
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/borrowing-desk-rule-cards-x3262
Scene Description Prompt:
Please make a voxel Three.js scene in one standalone HTML file using cdnjs. Create a fictional library lending desk with stated checkout conditions and an exception card. Apply rules consistently while distinguishing an authorized exception from a silent rule change.
Working Three.js Starter (borrowing-desk-rule-cards-x3262):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Brick & Quill — Voxel Lending Desk</title>
<style>
:root {
--ink: #303746;
--muted: #697181;
--paper: #f7f0df;
--paper-dark: #e9dfca;
--line: #cfc2a8;
--teal: #287d73;
--teal-light: #dceee8;
--gold: #e7b84b;
--gold-light: #fff2c7;
--red: #b84a45;
--red-light: #f8dfda;
--blue: #416c8d;
--shadow: 0 12px 32px rgba(49, 42, 32, 0.17);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e0cf;
color: var(--ink);
font-family: "Courier New", ui-monospace, SFMono-Regular, Consolas, monospace;
}
button, input { font: inherit; }
button {
color: inherit;
cursor: pointer;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.topbar {
position: fixed;
z-index: 20;
top: 18px;
left: 20px;
right: 20px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: none;
}
.brand,
.header-actions {
pointer-events: auto;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 15px;
border: 2px solid var(--ink);
background: rgba(247, 240, 223, 0.94);
box-shadow: 5px 5px 0 rgba(48, 55, 70, 0.2);
}
.brand-mark {
position: relative;
width: 36px;
height: 36px;
}
.brand-mark span {
position: absolute;
width: 17px;
height: 17px;
border: 2px solid var(--ink);
background: var(--gold);
box-shadow: inset -3px -3px 0 rgba(48, 55, 70, 0.15);
}
.brand-mark span:nth-child(1) { left: 0; top: 0; }
.brand-mark span:nth-child(2) { right: 0; top: 0; background: var(--teal); }
.brand-mark span:nth-child(3) { left: 0; bottom: 0; background: #d46b4f; }
.brand-mark span:nth-child(4) { right: 0; bottom: 0; background: var(--blue); }
.brand strong {
display: block;
font-size: 14px;
letter-spacing: 0.08em;
}
.brand small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.08em;
}
.header-actions {
display: flex;
align-items: center;
gap: 8px;
}
.fingerprint {
padding: 10px 12px;
border: 2px solid var(--ink);
background: var(--ink);
color: var(--paper);
font-size: 10px;
letter-spacing: 0.05em;
box-shadow: 5px 5px 0 rgba(48, 55, 70, 0.18);
}
.fingerprint b { color: #f5c85e; }
.mobile-toggle {
display: none;
padding: 9px 10px;
border: 2px solid var(--ink);
background: var(--paper);
font-size: 10px;
font-weight: bold;
}
.panel {
position: fixed;
z-index: 10;
border: 2px solid var(--ink);
background: rgba(247, 240, 223, 0.96);
box-shadow: var(--shadow);
backdrop-filter: blur(5px);
}
.panel-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 12px 14px;
border-bottom: 2px solid var(--ink);
background: var(--paper-dark);
}
.panel-header h2 {
margin: 0;
font-size: 13px;
letter-spacing: 0.08em;
}
.panel-kicker {
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
}
.policy-panel {
top: 96px;
left: 20px;
width: 326px;
max-height: calc(100vh - 280px);
overflow: auto;
}
.policy-content {
padding: 14px;
}
.conditions {
margin: 0;
padding: 0;
list-style: none;
counter-reset: rule;
}
.conditions li {
position: relative;
min-height: 28px;
padding: 6px 0 7px 34px;
border-bottom: 1px dashed var(--line);
font-size: 11px;
line-height: 1.45;
counter-increment: rule;
}
.conditions li::before {
content: "0" counter(rule);
position: absolute;
left: 0;
top: 7px;
width: 24px;
color: var(--teal);
font-size: 10px;
font-weight: bold;
}
.scope-note {
margin: 13px 0;
padding: 10px;
border-left: 5px solid var(--teal);
background: var(--teal-light);
font-size: 10px;
line-height: 1.5;
}
.scope-note strong {
display: block;
margin-bottom: 3px;
font-size: 10px;
letter-spacing: 0.04em;
}
.exception-card {
position: relative;
padding: 13px;
border: 2px solid #9b7319;
background:
linear-gradient(135deg, rgba(255,255,255,.35), transparent 45%),
var(--gold-light);
box-shadow: 3px 4px 0 rgba(155, 115, 25, 0.2);
}
.exception-card::after {
content: "E-17";
position: absolute;
top: 10px;
right: 9px;
padding: 3px 5px;
border: 2px solid #9b7319;
color: #9b7319;
font-size: 10px;
font-weight: bold;
transform: rotate(3deg);
}
.exception-card h3 {
max-width: 180px;
margin: 0 0 9px;
color: #765513;
font-size: 13px;
line-height: 1.25;
letter-spacing: 0.04em;
}
.exception-card p {
margin: 7px 0;
font-size: 10px;
line-height: 1.45;
}
.exception-card .card-name {
font-size: 12px;
font-weight: bold;
}
.exception-status {
display: inline-block;
margin-top: 6px;
padding: 4px 6px;
border: 1px solid #9b7319;
background: #fff8df;
color: #765513;
font-size: 9px;
font-weight: bold;
}
.contrast {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 12px;
}
.contrast > div {
padding: 8px;
border: 1px solid var(--line);
background: rgba(255,255,255,.38);
font-size: 9px;
line-height: 1.4;
}
.contrast strong {
display: block;
margin-bottom: 4px;
color: var(--teal);
font-size: 9px;
}
.contrast > div:last-child strong { color: var(--red); }
.checkout-panel {
top: 96px;
right: 20px;
width: 368px;
max-height: calc(100vh - 120px);
overflow: auto;
}
.checkout-content {
padding: 13px;
}
.step-label {
margin: 0 0 7px;
color: var(--muted);
font-size: 9px;
font-weight: bold;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.choice-list {
display: grid;
gap: 6px;
margin-bottom: 12px;
}
.member-button,
.book-button {
width: 100%;
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 9px;
padding: 8px;
border: 1px solid var(--line);
background: rgba(255,255,255,.38);
text-align: left;
transition: transform .12s, border-color .12s, background .12s;
}
.member-button:hover,
.book-button:hover {
transform: translateX(-2px);
border-color: var(--teal);
}
.member-button.active,
.book-button.active {
border: 2px solid var(--teal);
background: var(--teal-light);
padding: 7px;
}
.member-button.blocked { border-left: 5px solid var(--red); }
.member-button.exception { border-left: 5px solid var(--gold); }
.avatar {
display: grid;
place-items: center;
width: 29px;
height: 29px;
border: 2px solid var(--ink);
background: var(--blue);
color: white;
font-size: 9px;
font-weight: bold;
}
.member-button:nth-child(2) .avatar { background: #8d5a50; }
.member-button:nth-child(3) .avatar { background: var(--teal); }
.member-button:nth-child(4) .avatar { background: #9b7319; }
.member-button strong,
.book-button strong {
display: block;
font-size: 10px;
line-height: 1.25;
}
.member-button small,
.book-button small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 8px;
line-height: 1.3;
}
.tag {
padding: 3px 5px;
border: 1px solid currentColor;
color: var(--teal);
font-size: 7px;
font-weight: bold;
letter-spacing: 0.03em;
text-transform: uppercase;
white-space: nowrap;
}
.tag.warn { color: #9b7319; }
.tag.bad { color: var(--red); }
.tag.neutral { color: var(--muted); }
.book-button {
grid-template-columns: 30px 1fr auto;
}
.book-cover {
width: 25px;
height: 32px;
border: 2px solid var(--ink);
box-shadow: inset 4px 0 0 rgba(255,255,255,.22);
}
.summary {
margin: 4px 0 13px;
padding: 10px;
border: 1px dashed var(--line);
background: rgba(255,255,255,.34);
font-size: 9px;
line-height: 1.55;
}
.summary strong {
font-size: 10px;
}
.decision {
margin: 10px 0;
padding: 10px;
border: 2px solid var(--line);
background: rgba(255,255,255,.45);
}
.decision strong {
display: block;
margin-bottom: 5px;
font-size: 11px;
}
.decision p {
margin: 0 0 7px;
font-size: 9px;
line-height: 1.5;
}
.decision.approved {
border-color: var(--teal);
background: var(--teal-light);
}
.decision.denied {
border-color: var(--red);
background: var(--red-light);
}
.decision.exception-approved {
border-color: #9b7319;
background: var(--gold-light);
}
.trace {
margin: 8px 0 0;
padding: 0;
list-style: none;
}
.trace li {
position: relative;
padding: 4px 0 4px 19px;
border-bottom: 1px dotted rgba(105, 113, 129, 0.32);
font-size: 8px;
line-height: 1.4;
}
.trace li::before {
position: absolute;
left: 0;
font-weight: bold;
}
.trace li.pass::before { content: "✓"; color: var(--teal); }
.trace li.fail::before { content: "×"; color: var(--red); }
.trace li.exception::before { content: "E"; color: #9b7319; }
.actions {
display: grid;
grid-template-columns: 1fr auto;
gap: 7px;
}
.primary-button,
.reset-button {
padding: 10px;
border: 2px solid var(--ink);
font-size: 10px;
font-weight: bold;
letter-spacing: 0.03em;
}
.primary-button {
background: var(--teal);
color: white;
box-shadow: 3px 3px 0 rgba(48,55,70,.25);
}
.primary-button:hover { background: #226a62; }
.reset-button {
background: transparent;
}
.reset-button:hover { background: var(--paper-dark); }
.audit-panel {
left: 20px;
bottom: 20px;
width: 400px;
max-height: 170px;
overflow: hidden;
}
.audit-panel .panel-header { padding: 8px 12px; }
.audit-list {
max-height: 116px;
margin: 0;
padding: 6px 12px 10px 30px;
overflow: auto;
font-size: 8px;
line-height: 1.45;
}
.audit-list li {
padding: 4px 0;
border-bottom: 1px dotted var(--line);
}
.audit-list li.approved { color: var(--teal); }
.audit-list li.denied { color: var(--red); }
.audit-list li.exception { color: #8b6416; }
.world-label {
position: fixed;
z-index: 5;
pointer-events: none;
padding: 5px 7px;
border: 2px solid var(--ink);
background: rgba(247, 240, 223, 0.93);
box-shadow: 3px 3px 0 rgba(48,55,70,.2);
font-size: 8px;
font-weight: bold;
letter-spacing: 0.05em;
transform: translate(-50%, -50%);
white-space: nowrap;
}
.world-label.exception-label {
border-color: #9b7319;
background: var(--gold-light);
color: #765513;
}
.scene-hint {
position: fixed;
z-index: 4;
right: 24px;
bottom: 20px;
padding: 8px 10px;
border: 1px solid rgba(48,55,70,.35);
background: rgba(247,240,223,.8);
color: var(--muted);
font-size: 8px;
letter-spacing: 0.03em;
pointer-events: none;
}
.toast {
position: fixed;
z-index: 50;
top: 88px;
left: 50%;
max-width: 420px;
padding: 10px 14px;
border: 2px solid var(--ink);
background: var(--paper);
box-shadow: 5px 5px 0 rgba(48,55,70,.22);
font-size: 10px;
font-weight: bold;
transform: translate(-50%, -15px);
opacity: 0;
pointer-events: none;
transition: opacity .18s, transform .18s;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-height: 720px) and (min-width: 681px) {
.policy-panel {
max-height: calc(100vh - 215px);
}
.audit-panel {
width: 340px;
max-height: 135px;
}
.audit-list { max-height: 82px; }
}
@media (max-width: 680px) {
.topbar {
top: 10px;
left: 10px;
right: 10px;
}
.brand {
padding: 8px 10px;
}
.brand strong { font-size: 11px; }
.brand small { font-size: 8px; }
.fingerprint { display: none; }
.mobile-toggle { display: block; }
.policy-panel,
.checkout-panel {
top: auto;
right: 10px;
left: 10px;
width: auto;
max-height: 46vh;
}
.policy-panel { bottom: 10px; }
.checkout-panel { bottom: 10px; }
.policy-panel.is-collapsed,
.checkout-panel.is-collapsed {
display: none;
}
.audit-panel,
.scene-hint,
.world-label {
display: none;
}
.toast {
top: 70px;
width: calc(100% - 40px);
text-align: center;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive voxel library lending desk"></main>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span><span></span><span></span><span></span>
</div>
<div>
<strong>THE BRICK & QUILL</strong>
<small>LENDING DESK / BRANCH 07</small>
</div>
</div>
<div class="header-actions">
<div class="fingerprint">
GLOBAL CAP <b>3</b> · NAMED EXCEPTIONS <b>1</b>
</div>
<button class="mobile-toggle" id="togglePolicy" type="button">Rules</button>
<button class="mobile-toggle" id="toggleCheckout" type="button">Checkout</button>
</div>
</header>
<aside class="panel policy-panel" id="policyPanel" aria-labelledby="policyTitle">
<div class="panel-header">
<h2 id="policyTitle">CHECKOUT CONDITIONS</h2>
<span class="panel-kicker">VERSION 4.2</span>
</div>
<div class="policy-content">
<ol class="conditions">
<li>The member's library card must be current.</li>
<li>The account must have no overdue items.</li>
<li>The account must be in good standing.</li>
<li>A member may have at most <strong>3 open loans</strong>.</li>
<li>The requested item must be available.</li>
</ol>
<div class="scope-note">
<strong>GLOBAL POLICY SCOPE</strong>
The three-loan maximum applies to every member. It is never silently
increased. Only an active, named exception card can authorize a
different result, and it does not waive unrelated conditions.
</div>
<section class="exception-card" aria-label="Authorized exception card">
<h3>AUTHORIZED EXCEPTION</h3>
<p class="card-name">Mina Sol · Card M-204</p>
<p>
May borrow <strong>one additional eligible print book</strong> as a
fourth open loan. Current card, no overdue items, good standing,
and availability are still required.
</p>
<p>
No renewals or restricted items.<br>
One use only · valid through 31 Dec 2026.
</p>
<span class="exception-status" id="exceptionStatus">SLOT AVAILABLE</span>
</section>
<div class="contrast">
<div>
<strong>AUTHORIZED EXCEPTION</strong>
E-17 names Mina, states its scope, and is visible on the receipt
and audit log.
</div>
<div>
<strong>NOT A SILENT CHANGE</strong>
The global limit remains three for everybody else. No hidden
blanket override is applied.
</div>
</div>
</div>
</aside>
<aside class="panel checkout-panel" id="checkoutPanel" aria-labelledby="checkoutTitle">
<div class="panel-header">
<h2 id="checkoutTitle">CHECKOUT CONSOLE</h2>
<span class="panel-kicker">SCENARIO 14 OCT 2026</span>
</div>
<div class="checkout-content">
<p class="step-label">01 / Choose member</p>
<div class="choice-list" id="members"></div>
<div class="summary" id="memberSummary"></div>
<p class="step-label">02 / Choose title</p>
<div class="choice-list" id="books"></div>
<div class="decision" id="decision" aria-live="polite">
<strong>READY FOR EVALUATION</strong>
<p>Select a member and title, then run the checkout rules.</p>
</div>
<div class="actions">
<button class="primary-button" id="checkoutButton" type="button">
EVALUATE & CHECK OUT
</button>
<button class="reset-button" id="resetButton" type="button">RESET</button>
</div>
</div>
</aside>
<section class="panel audit-panel" aria-labelledby="auditTitle">
<div class="panel-header">
<h2 id="auditTitle">POLICY AUDIT TRAIL</h2>
<span class="panel-kicker">NEWEST FIRST</span>
</div>
<ol class="audit-list" id="auditList"></ol>
</section>
<div class="world-label exception-label" id="exceptionWorldLabel">
E-17 · MINA SOL ONLY
</div>
<div class="world-label" id="capWorldLabel">
GLOBAL MAX · 3 OPEN LOANS
</div>
<div class="scene-hint">DRAG TO ORBIT · WHEEL TO ZOOM · DOUBLE-CLICK TO RESET VIEW</div>
<div class="toast" id="toast" role="status"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup: Three.js core only. No examples, addons, or legacy scripts.
// -------------------------------------------------------------------------
const $ = (id) => document.getElementById(id);
const sceneHost = $("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e0cf);
scene.fog = new THREE.Fog(0xe8e0cf, 24, 42);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.1;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Voxel library scene. Drag to orbit and scroll to zoom.");
sceneHost.appendChild(renderer.domElement);
const FRUSTUM = 10.8;
const camera = new THREE.OrthographicCamera(-8, 8, 5.4, -5.4, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 1.75, 0);
const orbit = {
azimuth: 0.52,
polar: 0.91,
radius: 16,
targetAzimuth: 0.52,
targetPolar: 0.91,
targetRadius: 16
};
const hemisphere = new THREE.HemisphereLight(0xfff9e9, 0x786b5a, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedc9, 3.1);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0006;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d8e8, 1.1);
fill.position.set(8, 7, -4);
scene.add(fill);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(color, new THREE.MeshStandardMaterial({
color,
roughness: 0.83,
metalness: 0.02
}));
}
return materialCache.get(color);
}
function addBox(parent, width, height, depth, x, y, z, colorOrMaterial) {
const boxMaterial = colorOrMaterial && colorOrMaterial.isMaterial
? colorOrMaterial
: material(colorOrMaterial);
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
boxMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let randomSeed = 72519;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function createBoardTexture(
title,
rows,
options = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 640;
const ctx = canvas.getContext("2d");
const background = options.background || "#f7f0df";
const foreground = options.foreground || "#303746";
const accent = options.accent || "#287d73";
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 30, canvas.height);
ctx.strokeStyle = foreground;
ctx.lineWidth = 12;
ctx.strokeRect(18, 18, canvas.width - 36, canvas.height - 36);
ctx.fillStyle = foreground;
ctx.font = `bold ${options.titleSize || 56}px monospace`;
ctx.textBaseline = "top";
ctx.fillText(title, 78, 52, 860);
ctx.fillStyle = accent;
ctx.fillRect(78, 126, 850, 7);
const fontSize = options.rowSize || 31;
const startY = options.startY || 160;
const step = options.step || 86;
rows.forEach((row, index) => {
ctx.fillStyle = row.color || foreground;
ctx.font = `bold ${fontSize}px monospace`;
ctx.fillText(row, 82, startY + index * step, 850);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(renderer.capabilities.getMaxAnisotropy(), 8);
return texture;
}
function createLabelTexture(text, background = "#303746", foreground = "#f7f0df") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, 512, 128);
ctx.strokeStyle = foreground;
ctx.lineWidth = 8;
ctx.strokeRect(8, 8, 496, 112);
ctx.fillStyle = foreground;
ctx.font = "bold 52px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 66, 460);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function addBoard(parent, texture, width, height, x, y, z, frameColor = "#654b3b") {
addBox(parent, width + 0.18, height + 0.18, 0.18, x, y, z, frameColor);
const board = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
board.position.set(x, y, z + 0.101);
parent.add(board);
return board;
}
// -------------------------------------------------------------------------
// Voxel library architecture.
// -------------------------------------------------------------------------
const library = new THREE.Group();
scene.add(library);
// Raised diorama platform.
addBox(library, 14.5, 0.5, 10.5, 0, -0.35, 0, "#aaa18e");
const floorColors = ["#d8cfb9", "#d2c8b1", "#dfd6c2", "#c9bea7"];
for (let x = 0; x < 13; x++) {
for (let z = 0; z < 9; z++) {
const color = floorColors[(x + z * 2) % floorColors.length];
addBox(
library,
1.08,
0.08,
1.12,
-6.42 + x * 1.07,
-0.055,
-4.55 + z * 1.12,
color
);
}
}
// Back and left walls.
addBox(library, 14.2, 5.7, 0.34, 0, 2.72, -4.65, "#d9cdb6");
addBox(library, 0.34, 5.7, 7.1, -7.05, 2.72, -1.1, "#cfc1a8");
// Baseboards.
addBox(library, 14.0, 0.28, 0.22, 0, 0.03, -4.43, "#8b765d");
addBox(library, 0.22, 0.28, 6.9, -6.83, 0.03, -1.1, "#8b765d");
// Shelf frame.
addBox(library, 0.18, 4.1, 0.72, -4.82, 2.12, -4.08, "#6f513b");
addBox(library, 0.18, 4.1, 0.72, 1.82, 2.12, -4.08, "#6f513b");
const shelfHeights = [0.45, 1.67, 2.89, 4.11];
shelfHeights.forEach((height) => {
addBox(library, 6.82, 0.16, 0.78, -1.5, height, -4.06, "#7e5e43");
});
const bookColors = [
"#6d8ea0", "#c65f4a", "#4f897d", "#d6a843",
"#6f6b9b", "#a66e4b", "#6f965b", "#b65767"
];
// Voxel books on the shelves.
for (let row = 0; row < shelfHeights.length - 1; row++) {
let x = -4.58;
const baseY = shelfHeights[row] + 0.08;
while (x < 1.46) {
const width = 0.22 + random() * 0.16;
const height = 0.48 + random() * 0.42;
const depth = 0.42 + random() * 0.12;
const color = bookColors[Math.floor(random() * bookColors.length)];
addBox(library, width, height, depth, x + width / 2, baseY + height / 2, -3.94, color);
if (random() > 0.45) {
addBox(
library,
width + 0.01,
0.055,
0.02,
x + width / 2,
baseY + height * 0.72,
-3.94 + depth / 2 + 0.012,
"#e9d8aa"
);
}
x += width + 0.06 + random() * 0.08;
}
}
// Policy and brand boards on the wall.
const policyTexture = createBoardTexture(
"CHECKOUT CONDITIONS",
[
"01 CURRENT LIBRARY CARD",
"02 NO OVERDUE ITEMS",
"03 GOOD-STANDING ACCOUNT",
"04 3 OPEN LOANS MAXIMUM",
"05 REQUESTED ITEM AVAILABLE"
],
{
background: "#f7f0df",
accent: "#287d73",
titleSize: 51,
rowSize: 30,
startY: 160,
step: 78
}
);
addBoard(library, policyTexture, 4.8, 2.85, 3.75, 2.92, -4.4);
const brandTexture = createBoardTexture(
"BRICK & QUILL",
["LOANS / RETURNS / INFO"],
{
background: "#303746",
foreground: "#f7f0df",
accent: "#e7b84b",
titleSize: 62,
rowSize: 28,
startY: 170,
step: 90
}
);
addBoard(library, brandTexture, 4.8, 1.15, 3.75, 4.85, -4.4, "#1f2633");
const exceptionTexture = createBoardTexture(
"AUTHORIZED E-17",
[
"MEMBER: MINA SOL",
"SCOPE: 1 EXTRA PRINT LOAN",
"MAY BECOME HER 4TH LOAN",
"ALL OTHER RULES APPLY",
"ONE USE / 31 DEC 2026"
],
{
background: "#fff2c7",
foreground: "#654913",
accent: "#9b7319",
titleSize: 38,
rowSize: 24,
startY: 155,
step: 73
}
);
addBoard(library, exceptionTexture, 2.55, 3.25, -5.55, 3.15, -4.4, "#8c681f");
// Square voxel clock.
addBox(library, 1.05, 1.05, 0.18, 6.1, 4.62, -4.37, "#303746");
addBox(library, 0.83, 0.83, 0.04, 6.1, 4.62, -4.25, "#f7f0df");
addBox(library, 0.05, 0.31, 0.03, 6.1, 4.72, -4.21, "#303746");
addBox(library, 0.24, 0.05, 0.03, 6.19, 4.62, -4.20, "#303746");
// Lending counter.
addBox(library, 9.25, 1.55, 2.12, 0.35, 0.78, 1.35, "#a66f45");
addBox(library, 9.55, 0.23, 2.45, 0.35, 1.69, 1.35, "#5a4030");
addBox(library, 9.58, 0.08, 2.49, 0.35, 1.84, 1.35, "#d7b47d");
// Counter panel divisions.
for (let i = 0; i < 7; i++) {
addBox(
library,
0.055,
1.17,
0.025,
-3.58 + i * 1.31,
0.8,
2.422,
"#805538"
);
}
const checkoutLabelTexture = createLabelTexture("CHECKOUT");
const checkoutLabel = new THREE.Mesh(
new THREE.PlaneGeometry(3.1, 0.72),
new THREE.MeshBasicMaterial({ map: checkoutLabelTexture })
);
checkoutLabel.position.set(0.35, 1.02, 2.45);
library.add(checkoutLabel);
// Register and scanner.
addBox(library, 1.08, 0.18, 0.82, 2.72, 1.96, 0.95, "#333b44");
addBox(library, 0.88, 0.61, 0.12, 2.72, 2.29, 0.73, "#27313b");
addBox(library, 0.70, 0.42, 0.025, 2.72, 2.29, 0.808, "#9ec4c4");
const scannerMaterial = new THREE.MeshStandardMaterial({
color: 0xe7b84b,
emissive: 0x000000,
roughness: 0.55
});
const scannerLight = addBox(library, 0.24, 0.12, 0.24, 3.7, 2.02, 1.0, scannerMaterial);
// Three physical blocks represent the unchanged global loan cap.
const capColors = [0xd06a50, 0xe7b84b, 0x4f897d];
for (let i = 0; i < 3; i++) {
addBox(library, 0.34, 0.34, 0.34, -3.92 + i * 0.43, 2.05, 1.12, capColors[i]);
}
const capPlaqueTexture = createLabelTexture("MAX 3", "#f7f0df", "#303746");
const capPlaque = new THREE.Mesh(
new THREE.PlaneGeometry(1.35, 0.34),
new THREE.MeshBasicMaterial({ map: capPlaqueTexture })
);
capPlaque.rotation.x = -Math.PI / 2;
capPlaque.position.set(-3.49, 2.235, 1.12);
library.add(capPlaque);
// Physical named exception card, separate from the three cap blocks.
const physicalExceptionMaterial = new THREE.MeshStandardMaterial({
color: 0xf2c85c,
roughness: 0.7
});
addBox(library, 1.15, 0.075, 0.72, -2.32, 1.92, 1.12, physicalExceptionMaterial);
addBox(library, 0.10, 0.02, 0.70, -2.72, 1.97, 1.12, "#9b7319");
addBox(library, 0.53, 0.02, 0.08, -2.28, 1.97, 1.18, "#765513");
// Book stack and return slot.
addBox(library, 0.9, 0.12, 0.72, -0.48, 1.98, 1.12, "#557b8a");
addBox(library, 0.82, 0.10, 0.66, -0.43, 2.09, 1.08, "#e4c98e");
addBox(library, 0.75, 0.08, 0.60, -0.50, 2.18, 1.12, "#b85c4e");
addBox(library, 0.12, 0.75, 1.35, 4.7, 2.17, 0.8, "#303746");
addBox(library, 0.72, 0.12, 0.9, 4.7, 1.93, 0.8, "#5c4331");
// Voxel desk lamp.
addBox(library, 0.62, 0.12, 0.52, 3.62, 1.94, 0.25, "#303746");
addBox(library, 0.12, 0.86, 0.12, 3.62, 2.35, 0.25, "#303746");
addBox(library, 0.75, 0.28, 0.48, 3.47, 2.82, 0.25, "#e7b84b");
function createPerson(x, z, shirtColor, skinColor, hairColor, librarian = false) {
const group = new THREE.Group();
group.position.set(x, 0, z);
addBox(group, 0.27, 0.9, 0.3, -0.18, 0.58, 0, "#394452");
addBox(group, 0.27, 0.9, 0.3, 0.18, 0.58, 0, "#394452");
addBox(group, 0.31, 0.17, 0.46, -0.18, 0.12, 0.07, "#303746");
addBox(group, 0.31, 0.17, 0.46, 0.18, 0.12, 0.07, "#303746");
addBox(group, 0.88, 1.0, 0.48, 0, 1.52, 0, shirtColor);
addBox(group, 0.24, 0.83, 0.27, -0.56, 1.49, 0, shirtColor);
addBox(group, 0.24, 0.83, 0.27, 0.56, 1.49, 0, shirtColor);
addBox(group, 0.25, 0.25, 0.25, -0.56, 1.04, 0, skinColor);
addBox(group, 0.25, 0.25, 0.25, 0.56, 1.04, 0, skinColor);
addBox(group, 0.65, 0.65, 0.61, 0, 2.34, 0, skinColor);
addBox(group, 0.69, 0.25, 0.64, 0, 2.66, -0.01, hairColor);
addBox(group, 0.17, 0.42, 0.64, -0.29, 2.55, 0, hairColor);
addBox(group, 0.10, 0.10, 0.03, -0.15, 2.38, 0.316, "#303746");
addBox(group, 0.10, 0.10, 0.03, 0.15, 2.38, 0.316, "#303746");
if (librarian) {
addBox(group, 0.52, 0.15, 0.03, 0, 2.10, 0.255, "#f7f0df");
addBox(group, 0.18, 0.13, 0.025, -0.22, 1.72, 0.255, "#f7f0df");
addBox(group, 0.18, 0.13, 0.025, 0.22, 1.72, 0.255, "#f7f0df");
}
library.add(group);
return group;
}
const librarian = createPerson(2.55, -0.47, "#287d73", "#d99b72", "#5b3d32", true);
const patron = createPerson(-2.65, 3.42, "#c7644f", "#b87955", "#343746");
// Voxel plant.
addBox(library, 0.82, 0.72, 0.82, 5.65, 0.28, 0.0, "#b86748");
addBox(library, 0.18, 1.18, 0.18, 5.65, 1.14, 0.0, "#695a3f");
addBox(library, 0.72, 0.54, 0.65, 5.45, 1.67, 0.02, "#5f8d62");
addBox(library, 0.62, 0.52, 0.58, 5.96, 1.87, -0.02, "#78a16b");
addBox(library, 0.58, 0.48, 0.57, 5.54, 2.19, -0.02, "#4f7d5d");
// Small queue posts.
for (const x of [-4.55, 0.9]) {
addBox(library, 0.42, 0.08, 0.42, x, 0.02, 3.85, "#303746");
addBox(library, 0.09, 0.82, 0.09, x, 0.43, 3.85, "#303746");
addBox(library, 0.15, 0.15, 0.15, x, 0.88, 3.85, "#e7b84b");
}
const checkoutStack = new THREE.Group();
library.add(checkoutStack);
// -------------------------------------------------------------------------
// Custom camera controls, implemented without OrbitControls.
// -------------------------------------------------------------------------
const canvas = renderer.domElement;
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.targetAzimuth -= dx * 0.008;
orbit.targetPolar = THREE.MathUtils.clamp(
orbit.targetPolar + dy * 0.006,
0.48,
1.32
);
});
function stopDragging(event) {
dragging = false;
canvas.style.cursor = "grab";
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.style.cursor = "grab";
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
orbit.targetRadius = THREE.MathUtils.clamp(
orbit.targetRadius + event.deltaY * 0.012,
10.5,
23
);
}, { passive: false });
canvas.addEventListener("dblclick", () => {
orbit.targetAzimuth = 0.52;
orbit.targetPolar = 0.91;
orbit.targetRadius = 16;
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
camera.left = -FRUSTUM * aspect / 2;
camera.right = FRUSTUM * aspect / 2;
camera.top = FRUSTUM / 2;
camera.bottom = -FRUSTUM / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
const exceptionAnchor = new THREE.Vector3(-5.55, 4.9, -4.05);
const capAnchor = new THREE.Vector3(-3.48, 2.45, 1.12);
function positionWorldLabel(element, worldPoint) {
const projected = worldPoint.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1 &&
Math.abs(projected.x) < 1.1 && Math.abs(projected.y) < 1.1;
element.style.display = visible ? "block" : "none";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
// -------------------------------------------------------------------------
// Lending policy and deterministic checkout evaluation.
// -------------------------------------------------------------------------
const GLOBAL_LOAN_CAP = 3;
const SCENARIO_DATE = "2026-10-14";
function initialPatrons() {
return [
{
id: "maya",
name: "Maya Chen",
card: "L-104",
initials: "MC",
cardCurrent: true,
goodStanding: true,
overdue: 0,
loans: 1,
exception: null
},
{
id: "eli",
name: "Eli Novak",
card: "L-117",
initials: "EN",
cardCurrent: true,
goodStanding: true,
overdue: 0,
loans: 3,
exception: null
},
{
id: "mina",
name: "Mina Sol",
card: "M-204",
initials: "MS",
cardCurrent: true,
goodStanding: true,
overdue: 0,
loans: 3,
exception: {
id: "E-17",
memberId: "mina",
extraLoans: 1,
used: false,
validThrough: "2026-12-31",
scope: "One additional eligible print loan; other conditions remain in force."
}
},
{
id: "sasha",
name: "Sasha Reed",
card: "L-088",
initials: "SR",
cardCurrent: true,
goodStanding: false,
overdue: 1,
loans: 1,
exception: null
}
];
}
function initialBooks() {
return [
{
id: "tidebound",
title: "Tidebound",
author: "A. Meridian",
format: "print",
available: true,
cover: "#4f7f92"
},
{
id: "copper",
title: "The Copper Atlas",
author: "R. Bell",
format: "print",
available: true,
cover: "#b8654d"
},
{
id: "rain",
title: "A Field Guide to Rain",
author: "J. S. Vale",
format: "print",
available: true,
cover: "#5f8975"
},
{
id: "orchard",
title: "Night Orchard",
author: "M. North",
format: "print",
available: true,
cover: "#6e6894"
},
{
id: "lantern",
title: "Lantern Histories",
author: "E. Moss",
format: "print",
available: false,
checkedOutTo: "another branch",
cover: "#a9853d"
}
];
}
let patrons = initialPatrons();
let books = initialBooks();
let selectedMemberId = "mina";
let selectedBookId = "tidebound";
let auditEntries = [];
let toastTimer = null;
function selectedPatron() {
return patrons.find((patron) => patron.id === selectedMemberId);
}
function selectedBook() {
return books.find((book) => book.id === selectedBookId);
}
function exceptionIsUsable(patron, book) {
const exception = patron.exception;
return Boolean(
exception &&
exception.id === "E-17" &&
exception.memberId === patron.id &&
exception.extraLoans === 1 &&
!exception.used &&
exception.validThrough >= SCENARIO_DATE &&
book.format === "print"
);
}
// This is the only checkout decision function. Every UI outcome comes from
// this same evaluation, so the stated rules cannot drift between paths.
function evaluateCheckout(patron, book) {
const trace = [];
let firstFailure = null;
function addResult(passed, label) {
trace.push({ state: passed ? "pass" : "fail", label });
if (!passed && !firstFailure) firstFailure = label;
}
addResult(patron.cardCurrent, "Library card is current");
addResult(patron.overdue === 0, "No overdue items");
addResult(patron.goodStanding, "Account is in good standing");
addResult(book.available, "Requested print item is available");
let authorizedException = false;
if (patron.loans < GLOBAL_LOAN_CAP) {
trace.push({
state: "pass",
label: `Within the global limit: ${patron.loans} of ${GLOBAL_LOAN_CAP} open loans`
});
} else {
trace.push({
state: "fail",
label: `Global limit reached: ${patron.loans} of ${GLOBAL_LOAN_CAP} open loans`
});
if (exceptionIsUsable(patron, book)) {
authorizedException = true;
trace.push({
state: "exception",
label: `${patron.exception.id} authorizes one additional eligible print loan for ${patron.name}`
});
} else if (patron.exception && patron.exception.used) {
trace.push({
state: "fail",
label: `${patron.exception.id} has already been used`
});
}
}
return {
approved: !firstFailure && (patron.loans < GLOBAL_LOAN_CAP || authorizedException),
trace,
firstFailure,
authorizedException
};
}
function renderMembers() {
$("members").innerHTML = patrons.map((patron) => {
const active = patron.id === selectedMemberId;
let status = "CLEAR";
let statusClass = "";
let statusDetail = `${patron.loans} open · current card`;
if (patron.overdue > 0) {
status = "HOLD";
statusClass = "bad";
statusDetail = `${patron.overdue} overdue · account review`;
} else if (!patron.goodStanding) {
status = "HOLD";
statusClass = "bad";
statusDetail = `${patron.loans} open · standing review`;
} else if (patron.loans >= GLOBAL_LOAN_CAP) {
status = "AT CAP";
statusClass = "warn";
statusDetail = `${patron.loans} open · global maximum`;
}
const exceptionAvailable = patron.exception && !patron.exception.used;
if (exceptionAvailable) {
status = "E-17";
statusClass = "warn";
statusDetail = `${patron.loans} open · named exception available`;
} else if (patron.exception && patron.exception.used) {
status = "E-17 USED";
statusClass = "neutral";
statusDetail = `${patron.loans} open · exception already used`;
}
const classes = [
"member-button",
active ? "active" : "",
patron.exception ? "exception" : "",
patron.overdue || !patron.goodStanding ? "blocked" : ""
].join(" ");
return `
<button class="${classes}" type="button" data-member="${patron.id}" aria-pressed="${active}">
<span class="avatar">${patron.initials}</span>
<span>
<strong>${patron.name}</strong>
<small>${statusDetail}</small>
</span>
<span class="tag ${statusClass}">${status}</span>
</button>
`;
}).join("");
$("members").querySelectorAll("button").forEach((button) => {
button.addEventListener("click", () => {
selectedMemberId = button.dataset.member;
resetDecision();
renderAll();
});
});
}
function renderBooks() {
$("books").innerHTML = books.map((book) => {
const active = book.id === selectedBookId;
const status = book.available ? "AVAILABLE" : "ON LOAN";
const detail = book.available
? `${book.author} · print`
: `Checked out to ${book.checkedOutTo || "another member"}`;
return `
<button class="book-button ${active ? "active" : ""}" type="button"
data-book="${book.id}" aria-pressed="${active}">
<span class="book-cover" style="background:${book.cover}"></span>
<span>
<strong>${book.title}</strong>
<small>${detail}</small>
</span>
<span class="tag ${book.available ? "" : "bad"}">${status}</span>
</button>
`;
}).join("");
$("books").querySelectorAll("button").forEach((button) => {
button.addEventListener("click", () => {
selectedBookId = button.dataset.book;
resetDecision();
renderAll();
});
});
}
function renderSummary() {
const patron = selectedPatron();
const book = selectedBook();
const exceptionAvailable = patron.exception && !patron.exception.used;
const exceptionUsed = patron.exception && patron.exception.used;
let exceptionText = "No named exception on file.";
if (exceptionAvailable) {
exceptionText = "E-17 slot available: this member may take one additional eligible print title as loan 4.";
} else if (exceptionUsed) {
exceptionText = "E-17 has been used. This member is now above the global cap and receives no further exception.";
}
$("memberSummary").innerHTML = `
<strong>${patron.name}</strong> · card ${patron.card}<br>
Open loans: <strong>${patron.loans}</strong> ·
global limit: <strong>${GLOBAL_LOAN_CAP}</strong><br>
Overdue: ${patron.overdue} · standing: ${patron.goodStanding ? "clear" : "review"}<br>
Selected item: <strong>${book.title}</strong> (${book.format})<br>
<span style="color:${exceptionAvailable ? "#765513" : "#697181"}">${exceptionText}</span>
`;
}
function renderExceptionStatus() {
const mina = patrons.find((patron) => patron.id === "mina");
const available = mina.exception && !mina.exception.used;
$("exceptionStatus").textContent = available
? "SLOT AVAILABLE"
: "USED / NO LONGER AVAILABLE";
physicalExceptionMaterial.color.set(available ? 0xf2c85c : 0xa7a79d);
}
function resetDecision() {
$("decision").className = "decision";
$("decision").innerHTML = `
<strong>READY FOR EVALUATION</strong>
<p>All conditions will be checked in order. Any exception is named and recorded.</p>
`;
}
function renderDecision(result, patron, book) {
const decision = $("decision");
if (result.approved) {
if (result.authorizedException) {
decision.className = "decision exception-approved";
decision.innerHTML = `
<strong>APPROVED VIA AUTHORIZED EXCEPTION ${patron.exception.id}</strong>
<p>
${patron.name} may borrow <strong>${book.title}</strong> as loan 4.
The global maximum remains 3 for every other member.
This receipt records the exception explicitly.
</p>
<ul class="trace">
${result.trace.map((item) =>
`<li class="${item.state}">${item.label}</li>`
).join("")}
</ul>
`;
} else {
decision.className = "decision approved";
decision.innerHTML = `
<strong>APPROVED UNDER STANDARD POLICY</strong>
<p>
${patron.name} may borrow <strong>${book.title}</strong>.
No exception was needed.
</p>
<ul class="trace">
${result.trace.map((item) =>
`<li class="${item.state}">${item.label}</li>`
).join("")}
</ul>
`;
}
} else {
decision.className = "decision denied";
decision.innerHTML = `
<strong>NOT APPROVED</strong>
<p>Failed condition: ${result.firstFailure}. No loan or exception use was recorded.</p>
<ul class="trace">
${result.trace.map((item) =>
`<li class="${item.state}">${item.label}</li>`
).join("")}
</ul>
`;
}
}
function renderAudit() {
$("auditList").innerHTML = auditEntries.map((entry) => `
<li class="${entry.type}">
<strong>${entry.time} · ${entry.title}</strong><br>
${entry.detail}
</li>
`).join("");
}
function currentTime() {
return new Date().toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit"
});
}
function addAudit(type, title, detail) {
auditEntries.unshift({ type, title, detail, time: currentTime() });
renderAudit();
}
function showToast(message) {
const toast = $("toast");
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2800);
}
function addCheckedOutBook(book, index) {
const group = new THREE.Group();
group.position.set(-0.35 + index * 0.11, 2.28 + index * 0.10, 1.0);
group.rotation.y = -0.18 + index * 0.05;
addBox(group, 0.72, 0.08, 0.82, 0, 0, 0, book.cover);
addBox(group, 0.60, 0.10, 0.73, 0.025, 0.02, 0, "#f0dfb7");
addBox(group, 0.72, 0.11, 0.07, 0, 0.02, 0.39, book.cover);
checkoutStack.add(group);
}
function setScannerState(state) {
if (state === "approved") {
scannerMaterial.color.set(0x3a9d72);
scannerMaterial.emissive.set(0x164d37);
} else if (state === "denied") {
scannerMaterial.color.set(0xb84a45);
scannerMaterial.emissive.set(0x5a1815);
} else {
scannerMaterial.color.set(0xe7b84b);
scannerMaterial.emissive.set(0x000000);
}
}
function checkout() {
const patron = selectedPatron();
const book = selectedBook();
const result = evaluateCheckout(patron, book);
renderDecision(result, patron, book);
if (!result.approved) {
setScannerState("denied");
addAudit(
"denied",
`DENIED · ${patron.name} · ${book.title}`,
`Reason: ${result.firstFailure}. The global policy and named-exception scope were both evaluated.`
);
showToast(`Checkout denied: ${result.firstFailure}.`);
return;
}
patron.loans += 1;
book.available = false;
book.checkedOutTo = patron.name;
if (result.authorizedException) {
patron.exception.used = true;
addAudit(
"exception",
`APPROVED VIA E-17 · ${patron.name} · ${book.title}`,
"The standard 3-loan cap would have denied this checkout. Named exception E-17 supplied one additional print-loan slot. All unrelated conditions passed."
);
showToast("Approved via E-17 — exception recorded, not a policy change.");
} else {
addAudit(
"approved",
`APPROVED · ${patron.name} · ${book.title}`,
`Checked out under standard policy. Open loans: ${patron.loans} of ${GLOBAL_LOAN_CAP}.`
);
showToast("Approved under standard checkout policy.");
}
addCheckedOutBook(book, checkoutStack.children.length);
setScannerState("approved");
renderAll();
}
function resetScenario() {
patrons = initialPatrons();
books = initialBooks();
selectedMemberId = "mina";
selectedBookId = "tidebound";
checkoutStack.clear();
auditEntries = [{
type: "",
title: "POLICY LOADED · GLOBAL CAP 3",
detail: "One named exception is on file: E-17 for Mina Sol only. The global cap was not changed.",
time: currentTime()
}];
setScannerState("neutral");
resetDecision();
renderAll();
renderAudit();
showToast("Scenario reset. Global cap remains 3.");
}
function renderAll() {
renderMembers();
renderBooks();
renderSummary();
renderExceptionStatus();
}
$("checkoutButton").addEventListener("click", checkout);
$("resetButton").addEventListener("click", resetScenario);
$("togglePolicy").addEventListener("click", () => {
$("policyPanel").classList.toggle("is-collapsed");
$("checkoutPanel").classList.add("is-collapsed");
});
$("toggleCheckout").addEventListener("click", () => {
$("checkoutPanel").classList.toggle("is-collapsed");
$("policyPanel").classList.add("is-collapsed");
});
if (window.innerWidth <= 680) {
$("policyPanel").classList.add("is-collapsed");
}
resetScenario();
// -------------------------------------------------------------------------
// Render loop.
// -------------------------------------------------------------------------
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
orbit.azimuth = THREE.MathUtils.lerp(orbit.azimuth, orbit.targetAzimuth, 0.10);
orbit.polar = THREE.MathUtils.lerp(orbit.polar, orbit.targetPolar, 0.10);
orbit.radius = THREE.MathUtils.lerp(orbit.radius, orbit.targetRadius, 0.10);
const sinPolar = Math.sin(orbit.polar);
camera.position.set(
cameraTarget.x + orbit.radius * sinPolar * Math.sin(orbit.azimuth),
cameraTarget.y + orbit.radius * Math.cos(orbit.polar),
cameraTarget.z + orbit.radius * sinPolar * Math.cos(orbit.azimuth)
);
camera.zoom = 16 / orbit.radius;
camera.updateProjectionMatrix();
camera.lookAt(cameraTarget);
if (!reducedMotion) {
librarian.position.y = Math.sin(time * 1.7) * 0.018;
patron.position.y = Math.sin(time * 1.4 + 1.3) * 0.012;
}
positionWorldLabel($("exceptionWorldLabel"), exceptionAnchor);
positionWorldLabel($("capWorldLabel"), capAnchor);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```