Prompt specification
Build or customize the Three.js 3D scene "Reachable and Unreachable Notice Slots" 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: Reachable and Unreachable Notice Slots
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/reachable-and-unreachable-notice-slots-x3201
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring accessibility across different abilities and ways of moving. Build a notice stand with adjustable slot heights and seated and standing reach envelopes. Use schematic bodies and labeled assumptions rather than universal ergonomic measurements. Low-poly.
Working Three.js Starter (reachable-and-unreachable-notice-slots-x3201):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<title>Accessible Adjustable Notice Stand</title>
<style>
:root {
--bg: #edf2f4;
--panel: #ffffff;
--ink: #142832;
--muted: #4c626d;
--line: #b7c6cc;
--accent: #006d77;
--accent-ink: #ffffff;
--focus: #b54708;
--standing: #b84f00;
--seated: #006d77;
--wheelchair: #654ea3;
--good: #176b3a;
--shadow: 0 12px 34px rgba(20, 40, 50, 0.13);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--ink);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
line-height: 1.45;
}
body.large-text {
font-size: 118%;
}
body.high-contrast {
--bg: #ffffff;
--panel: #ffffff;
--ink: #000000;
--muted: #202020;
--line: #000000;
--accent: #003f8f;
--accent-ink: #ffffff;
--focus: #a00000;
--standing: #8a3200;
--seated: #004f66;
--wheelchair: #442b83;
--good: #005a25;
--shadow: none;
}
.skip-link {
position: fixed;
top: 0.5rem;
left: 0.5rem;
z-index: 1000;
transform: translateY(-180%);
padding: 0.65rem 0.9rem;
color: #fff;
background: #000;
border-radius: 0.35rem;
}
.skip-link:focus {
transform: translateY(0);
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.85rem 1.2rem;
background: var(--panel);
border-bottom: 1px solid var(--line);
}
header h1 {
margin: 0;
font-size: clamp(1.15rem, 2vw, 1.65rem);
line-height: 1.2;
}
header p {
margin: 0.2rem 0 0;
color: var(--muted);
font-size: 0.92rem;
}
.access-tools {
display: flex;
flex-wrap: wrap;
gap: 0.45rem;
}
button {
min-height: 2.55rem;
padding: 0.55rem 0.8rem;
border: 2px solid var(--line);
border-radius: 0.45rem;
background: var(--panel);
color: var(--ink);
font: inherit;
font-weight: 650;
cursor: pointer;
}
button:hover {
border-color: var(--accent);
}
button[aria-pressed="true"] {
border-color: var(--accent);
background: var(--accent);
color: var(--accent-ink);
}
button:focus-visible,
input:focus-visible,
summary:focus-visible,
canvas:focus-visible,
a:focus-visible {
outline: 4px solid var(--focus);
outline-offset: 3px;
}
.app {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
min-height: calc(100vh - 76px);
}
.scene-panel {
position: relative;
min-height: 680px;
overflow: hidden;
background: #e9eef0;
}
#sceneCanvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
}
#sceneCanvas.dragging {
cursor: grabbing;
}
.scene-overlay {
position: absolute;
z-index: 2;
pointer-events: none;
}
.scene-note {
top: 1rem;
left: 1rem;
max-width: min(440px, calc(100% - 2rem));
padding: 0.75rem 0.9rem;
border: 1px solid var(--line);
border-radius: 0.55rem;
background: rgba(255, 255, 255, 0.92);
box-shadow: var(--shadow);
}
.scene-note strong {
display: block;
margin-bottom: 0.2rem;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
margin-top: 0.55rem;
}
.legend span {
padding: 0.2rem 0.45rem;
border: 1px solid currentColor;
border-radius: 999px;
font-size: 0.8rem;
font-weight: 700;
}
.legend .standing {
color: var(--standing);
}
.legend .seated {
color: var(--seated);
}
.legend .wheelchair {
color: var(--wheelchair);
}
.scene-help {
bottom: 1rem;
left: 1rem;
max-width: 430px;
padding: 0.6rem 0.8rem;
border-radius: 0.45rem;
background: rgba(20, 40, 50, 0.88);
color: #fff;
font-size: 0.86rem;
}
.control-panel {
overflow-y: auto;
max-height: calc(100vh - 76px);
padding: 1rem;
background: var(--panel);
border-left: 1px solid var(--line);
}
.control-panel h2,
.control-panel h3 {
margin-top: 0;
}
.control-panel h2 {
font-size: 1.15rem;
}
.control-panel h3 {
margin-bottom: 0.55rem;
font-size: 1rem;
}
fieldset {
margin: 0 0 1rem;
padding: 0.8rem;
border: 1px solid var(--line);
border-radius: 0.55rem;
}
legend {
padding: 0 0.35rem;
font-weight: 750;
}
.control-row {
margin: 0 0 0.8rem;
}
.control-row:last-child {
margin-bottom: 0;
}
.control-label {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 0.7rem;
margin-bottom: 0.25rem;
font-weight: 650;
}
output {
flex: 0 0 auto;
color: var(--muted);
font-variant-numeric: tabular-nums;
font-weight: 700;
}
input[type="range"] {
width: 100%;
min-height: 1.8rem;
accent-color: var(--accent);
cursor: pointer;
}
.check-row {
display: flex;
align-items: center;
gap: 0.55rem;
margin: 0.55rem 0;
}
.check-row input {
width: 1.15rem;
height: 1.15rem;
accent-color: var(--accent);
}
.button-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.45rem;
}
.mode-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.45rem;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.88rem;
}
th,
td {
padding: 0.5rem;
border-bottom: 1px solid var(--line);
text-align: left;
vertical-align: top;
}
th {
background: #f0f4f5;
}
.within {
color: var(--good);
font-weight: 700;
}
.outside {
color: #8b3a00;
font-weight: 700;
}
.assumption {
padding: 0.75rem;
border-left: 5px solid var(--standing);
background: #f5f0e8;
font-size: 0.9rem;
}
.assumption p {
margin: 0.3rem 0;
}
details {
margin-top: 0.8rem;
}
summary {
cursor: pointer;
font-weight: 750;
}
#summaryText {
margin-bottom: 0;
}
.fallback {
position: absolute;
inset: 20% 10%;
z-index: 5;
padding: 1.2rem;
border: 2px solid var(--line);
background: #fff;
box-shadow: var(--shadow);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 920px) {
header {
align-items: flex-start;
flex-direction: column;
}
.app {
grid-template-columns: 1fr;
}
.scene-panel {
min-height: 58vh;
}
.control-panel {
max-height: none;
border-top: 1px solid var(--line);
border-left: 0;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition: none !important;
animation: none !important;
}
}
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
scroll-behavior: auto !important;
transition: none !important;
animation: none !important;
}
</style>
</head>
<body>
<a class="skip-link" href="#controls">Skip to adjustable controls</a>
<header>
<div>
<h1>Accessible adjustable notice stand</h1>
<p>
Interactive low-poly study with schematic standing, seated, and wheelchair
approaches. Dimensions are examples, not universal ergonomic rules.
</p>
</div>
<div class="access-tools" aria-label="Display accessibility options">
<button id="contrastButton" type="button" aria-pressed="false">
High contrast
</button>
<button id="textButton" type="button" aria-pressed="false">
Large text
</button>
<button id="motionButton" type="button" aria-pressed="false">
Reduce motion
</button>
</div>
</header>
<main class="app">
<section class="scene-panel" aria-labelledby="sceneHeading">
<h2 id="sceneHeading" class="sr-only">Interactive 3D notice stand</h2>
<canvas
id="sceneCanvas"
tabindex="0"
role="img"
aria-roledescription="interactive 3D scene"
aria-label="Low-poly adjustable notice stand with standing, seated, and wheelchair access examples"
aria-describedby="canvasInstructions sceneDescription"
aria-busy="true"
>
The scene shows an adjustable notice stand, three schematic notice slots,
a standing reach envelope, a seated reach envelope, and a wheelchair
approach area. Use the adjacent text controls for equivalent information.
</canvas>
<div id="fallback" class="fallback" hidden>
<h2>3D rendering is unavailable</h2>
<p>
The adjustable controls and text summary remain available. WebGL or the
Three.js CDN may be unavailable.
</p>
</div>
<div class="scene-overlay scene-note">
<strong>Example assumptions — not prescriptive measurements</strong>
<div>
“su” means schematic unit. Slot heights and assumed reach bounds can
be changed to match a local assessment.
</div>
<div class="legend" aria-label="Figure color legend">
<span class="standing">Standing envelope</span>
<span class="seated">Seated envelope</span>
<span class="wheelchair">Wheelchair approach</span>
</div>
</div>
<div id="canvasInstructions" class="scene-overlay scene-help">
Drag to orbit. Use the mouse wheel to zoom. With the canvas focused:
arrow keys orbit, + or − zooms, and 0 resets the view.
</div>
</section>
<aside id="controls" class="control-panel" aria-label="Scene controls and assumptions">
<h2>Controls</h2>
<fieldset>
<legend>Figure and zone visibility</legend>
<div class="mode-grid" aria-label="Select a figure view">
<button type="button" data-mode="all" aria-pressed="true">All figures</button>
<button type="button" data-mode="standing" aria-pressed="false">Standing</button>
<button type="button" data-mode="seated" aria-pressed="false">Seated</button>
<button type="button" data-mode="wheelchair" aria-pressed="false">Wheelchair</button>
</div>
<label class="check-row">
<input id="showBodies" type="checkbox" checked>
Show schematic bodies
</label>
<label class="check-row">
<input id="showZones" type="checkbox" checked>
Show reach and approach zones
</label>
</fieldset>
<fieldset>
<legend>Camera</legend>
<div class="button-grid">
<button id="rotateLeft" type="button">Rotate left</button>
<button id="rotateRight" type="button">Rotate right</button>
<button id="zoomIn" type="button">Zoom in</button>
<button id="zoomOut" type="button">Zoom out</button>
<button id="resetView" type="button" style="grid-column: 1 / -1;">
Reset camera
</button>
</div>
</fieldset>
<fieldset>
<legend>Notice slot heights from floor</legend>
<div class="control-row">
<label class="control-label" for="slot0">
<span>Slot 1 — low</span>
<output id="slot0Value" for="slot0"></output>
</label>
<input id="slot0" type="range" min="0.45" max="2.35" step="0.05" value="0.95">
</div>
<div class="control-row">
<label class="control-label" for="slot1">
<span>Slot 2 — middle</span>
<output id="slot1Value" for="slot1"></output>
</label>
<input id="slot1" type="range" min="0.45" max="2.35" step="0.05" value="1.5">
</div>
<div class="control-row">
<label class="control-label" for="slot2">
<span>Slot 3 — high</span>
<output id="slot2Value" for="slot2"></output>
</label>
<input id="slot2" type="range" min="0.45" max="2.35" step="0.05" value="2.05">
</div>
</fieldset>
<fieldset>
<legend>Assumed standing reach envelope</legend>
<div class="control-row">
<label class="control-label" for="standingMin">
<span>Lower bound</span>
<output id="standingMinValue" for="standingMin"></output>
</label>
<input id="standingMin" type="range" min="0.25" max="1.3" step="0.05" value="0.55">
</div>
<div class="control-row">
<label class="control-label" for="standingMax">
<span>Upper bound</span>
<output id="standingMaxValue" for="standingMax"></output>
</label>
<input id="standingMax" type="range" min="1.1" max="2.5" step="0.05" value="2.15">
</div>
</fieldset>
<fieldset>
<legend>Assumed seated reach envelope</legend>
<div class="control-row">
<label class="control-label" for="seatedMin">
<span>Lower bound</span>
<output id="seatedMinValue" for="seatedMin"></output>
</label>
<input id="seatedMin" type="range" min="0.25" max="1" step="0.05" value="0.55">
</div>
<div class="control-row">
<label class="control-label" for="seatedMax">
<span>Upper bound</span>
<output id="seatedMaxValue" for="seatedMax"></output>
</label>
<input id="seatedMax" type="range" min="0.8" max="1.6" step="0.05" value="1.35">
</div>
</fieldset>
<fieldset>
<legend>Assumed wheelchair approach area</legend>
<div class="control-row">
<label class="control-label" for="wheelWidth">
<span>Approach width</span>
<output id="wheelWidthValue" for="wheelWidth"></output>
</label>
<input id="wheelWidth" type="range" min="0.75" max="1.8" step="0.05" value="1.1">
</div>
<div class="control-row">
<label class="control-label" for="wheelDepth">
<span>Approach depth</span>
<output id="wheelDepthValue" for="wheelDepth"></output>
</label>
<input id="wheelDepth" type="range" min="0.8" max="1.8" step="0.05" value="1.6">
</div>
</fieldset>
<section aria-labelledby="relationHeading">
<h3 id="relationHeading">Example vertical relationships</h3>
<table>
<thead>
<tr>
<th scope="col">Slot</th>
<th scope="col">Standing</th>
<th scope="col">Seated</th>
</tr>
</thead>
<tbody id="relationRows"></tbody>
</table>
<p class="assumption">
“Within example” compares only the slot’s vertical height with the
editable envelope bounds. It does not account for distance, posture,
dexterity, fatigue, cognitive needs, or individual variation.
</p>
</section>
<section aria-labelledby="summaryHeading">
<h3 id="summaryHeading">Text summary</h3>
<p id="summaryText"></p>
</section>
<details>
<summary>Modeling assumptions and limitations</summary>
<div class="assumption">
<p>
<strong>1 su</strong> is an arbitrary schematic unit. It is not a
real-world dimension and should not be transferred directly to a
building or product.
</p>
<p>
Bodies are faceted symbols, not anatomical models. The standing and
seated envelopes are editable vertical assumptions.
</p>
<p>
The wheelchair rectangle illustrates a possible clear approach area.
A real assessment must consider the actual wheelchair, transfer
technique, maneuvering space, reach path, notice content, local
standards, and the preferences of the people who use it.
</p>
<p>
The table and labels provide the same essential relationships as
the colors in the 3D scene.
</p>
</div>
</details>
</aside>
</main>
<p id="sceneDescription" class="sr-only">
Use the adjacent controls to move the three notice slots and adjust example
standing and seated reach bounds. A wheelchair approach rectangle is also
adjustable.
</p>
<div id="announcer" class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>
<noscript>
<p style="padding: 1rem;">
JavaScript is required for the interactive 3D scene and adjustable controls.
</p>
</noscript>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const state = {
slots: [0.95, 1.50, 2.05],
standing: [0.55, 2.15],
seated: [0.55, 1.35],
wheel: { width: 1.10, depth: 1.60 },
mode: "all",
showBodies: true,
showZones: true,
highContrast: false
};
const canvas = document.getElementById("sceneCanvas");
const fallback = document.getElementById("fallback");
const announcer = document.getElementById("announcer");
const relationRows = document.getElementById("relationRows");
const summaryText = document.getElementById("summaryText");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false
});
} catch (error) {
canvas.hidden = true;
fallback.hidden = false;
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eef0);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 100);
const cameraState = {
radius: 10.8,
theta: 0.72,
phi: 1.04,
target: new THREE.Vector3(0, 1.12, 0.48)
};
let renderQueued = false;
function requestRender() {
if (renderQueued) return;
renderQueued = true;
requestAnimationFrame(() => {
renderQueued = false;
renderer.render(scene, camera);
});
}
function updateCamera() {
camera.position.setFromSphericalCoords(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.add(cameraState.target);
camera.lookAt(cameraState.target);
requestRender();
}
const ambient = new THREE.HemisphereLight(0xf7fbff, 0x74858b, 2.15);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xfff5df, 2.7);
keyLight.position.set(-4, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -4;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xcce8ff, 0.85);
fillLight.position.set(5, 4, -3);
scene.add(fillLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0xdce4e6,
roughness: 0.98,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(16, 32, 0x75878d, 0xaebbc0);
grid.position.y = 0.006;
grid.material.transparent = true;
grid.material.opacity = 0.25;
scene.add(grid);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
}
function box(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 cylinderBetween(parent, a, b, radius, material, radialSegments = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
radius,
direction.length(),
radialSegments
),
material
);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createLabel(text, worldWidth = 3.2) {
const measure = document.createElement("canvas").getContext("2d");
const font = "700 42px system-ui, sans-serif";
measure.font = font;
const textWidth = Math.ceil(measure.measureText(text).width);
const width = textWidth + 44;
const height = 72;
const labelCanvas = document.createElement("canvas");
labelCanvas.width = width;
labelCanvas.height = height;
const ctx = labelCanvas.getContext("2d");
ctx.fillStyle = "rgba(20, 40, 50, 0.94)";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "#ffffff";
ctx.font = font;
ctx.textBaseline = "middle";
ctx.textAlign = "center";
ctx.fillText(text, width / 2, height / 2 + 1);
const texture = new THREE.CanvasTexture(labelCanvas);
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(worldWidth, worldWidth * height / width, 1);
sprite.renderOrder = 20;
return sprite;
}
function clearGroup(group) {
while (group.children.length) {
const child = group.children.pop();
child.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
const materials = Array.isArray(object.material)
? object.material
: [object.material];
materials.forEach((material) => {
if (material.map) material.map.dispose();
material.dispose();
});
}
});
}
}
// Notice stand frame.
const stand = new THREE.Group();
scene.add(stand);
const frameMaterial = standardMaterial(0x244955);
const railMaterial = standardMaterial(0x51717c);
const baseMaterial = standardMaterial(0x203a44);
box(stand, 0.13, 2.65, 0.14, frameMaterial, -1.65, 1.325, 0);
box(stand, 0.13, 2.65, 0.14, frameMaterial, 1.65, 1.325, 0);
box(stand, 3.45, 0.10, 0.13, frameMaterial, 0, 2.58, 0);
box(stand, 0.72, 0.10, 0.90, baseMaterial, -1.35, 0.06, 0.04);
box(stand, 0.72, 0.10, 0.90, baseMaterial, 1.35, 0.06, 0.04);
function createNoticeTexture(index) {
const noticeCanvas = document.createElement("canvas");
noticeCanvas.width = 1024;
noticeCanvas.height = 192;
const ctx = noticeCanvas.getContext("2d");
ctx.fillStyle = "#fffdf6";
ctx.fillRect(0, 0, 1024, 192);
ctx.fillStyle = ["#b84f00", "#006d77", "#654ea3"][index];
ctx.fillRect(0, 0, 24, 192);
ctx.fillStyle = "#142832";
ctx.font = "800 58px system-ui, sans-serif";
ctx.fillText(`SLOT ${index + 1}`, 60, 76);
ctx.fillStyle = "#4c626d";
ctx.font = "500 31px system-ui, sans-serif";
ctx.fillText(
`SCHEMATIC NOTICE · ${state.slots[index].toFixed(2)} su`,
60,
132
);
const texture = new THREE.CanvasTexture(noticeCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(4, renderer.capabilities.getMaxAnisotropy());
return texture;
}
const slotGroups = [];
for (let i = 0; i < 3; i++) {
const group = new THREE.Group();
box(group, 2.72, 0.46, 0.09, standardMaterial(0xf7f3e9), 0, 0, 0.11);
box(group, 2.95, 0.065, 0.14, railMaterial, 0, -0.29, 0.13);
const notice = new THREE.Mesh(
new THREE.PlaneGeometry(2.66, 0.42),
new THREE.MeshStandardMaterial({
map: createNoticeTexture(i),
roughness: 0.92,
metalness: 0
})
);
notice.position.set(0, 0, 0.158);
notice.receiveShadow = true;
group.add(notice);
group.position.y = state.slots[i];
group.userData.notice = notice;
scene.add(group);
slotGroups.push(group);
}
function updateSlot(index) {
const group = slotGroups[index];
group.position.y = state.slots[index];
const oldTexture = group.userData.notice.material.map;
group.userData.notice.material.map = createNoticeTexture(index);
group.userData.notice.material.needsUpdate = true;
if (oldTexture) oldTexture.dispose();
}
// Height dimension line.
const dimensionMaterial = new THREE.LineBasicMaterial({
color: 0x3c5964
});
const dimensionPoints = [
new THREE.Vector3(-1.98, 0, 0.18),
new THREE.Vector3(-1.98, 2.35, 0.18),
new THREE.Vector3(-2.08, 0, 0.18),
new THREE.Vector3(-1.88, 0, 0.18),
new THREE.Vector3(-2.08, 2.35, 0.18),
new THREE.Vector3(-1.88, 2.35, 0.18)
];
scene.add(new THREE.LineSegments(
new THREE.BufferGeometry().setFromPoints(dimensionPoints),
dimensionMaterial
));
const dimensionLabel = createLabel("SLOT HEIGHT · su FROM FLOOR", 2.45);
dimensionLabel.position.set(-2.08, 2.47, 0.18);
scene.add(dimensionLabel);
// Low-poly schematic people.
const skinMaterial = standardMaterial(0xe7c8a8);
const standingClothing = standardMaterial(0xb84f00);
const seatedClothing = standardMaterial(0x006d77);
const wheelchairClothing = standardMaterial(0x654ea3);
const darkMaterial = standardMaterial(0x26383f);
const wheelMaterial = standardMaterial(0x15262c);
function makeStandingPerson() {
const group = new THREE.Group();
box(group, 0.48, 0.58, 0.28, standingClothing, 0, 1.18, 0);
box(group, 0.43, 0.18, 0.25, standingClothing, 0, 0.86, 0);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 8, 6),
skinMaterial
);
head.position.set(0, 1.64, 0);
head.castShadow = true;
group.add(head);
box(group, 0.07, 0.07, 0.09, skinMaterial, 0, 1.63, -0.17);
cylinderBetween(group, [-0.13, 0.81, 0], [-0.18, 0.12, 0], 0.105, darkMaterial);
cylinderBetween(group, [0.13, 0.81, 0], [0.18, 0.12, 0], 0.105, darkMaterial);
box(group, 0.23, 0.10, 0.34, darkMaterial, -0.18, 0.06, -0.05);
box(group, 0.23, 0.10, 0.34, darkMaterial, 0.18, 0.06, -0.05);
cylinderBetween(group, [-0.28, 1.38, 0], [-0.38, 1.05, -0.16], 0.085, standingClothing);
cylinderBetween(group, [-0.38, 1.05, -0.16], [-0.35, 0.92, -0.43], 0.075, skinMaterial);
cylinderBetween(group, [0.28, 1.38, 0], [0.38, 1.06, -0.05], 0.085, standingClothing);
cylinderBetween(group, [0.38, 1.06, -0.05], [0.40, 0.88, -0.10], 0.075, skinMaterial);
return group;
}
function makeSeatedPerson() {
const group = new THREE.Group();
box(group, 0.65, 0.10, 0.70, standardMaterial(0x7da8aa), 0, 0.47, 0.04);
box(group, 0.48, 0.57, 0.28, seatedClothing, 0, 0.89, 0);
box(group, 0.42, 0.18, 0.25, seatedClothing, 0, 0.60, 0);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 8, 6),
skinMaterial
);
head.position.set(0, 1.29, 0);
head.castShadow = true;
group.add(head);
box(group, 0.07, 0.07, 0.09, skinMaterial, 0, 1.28, -0.17);
cylinderBetween(group, [-0.13, 0.58, 0], [-0.13, 0.51, -0.43], 0.105, darkMaterial);
cylinderBetween(group, [-0.13, 0.51, -0.43], [-0.13, 0.12, -0.48], 0.095, darkMaterial);
cylinderBetween(group, [0.13, 0.58, 0], [0.13, 0.51, -0.43], 0.105, darkMaterial);
cylinderBetween(group, [0.13, 0.51, -0.43], [0.13, 0.12, -0.48], 0.095, darkMaterial);
box(group, 0.22, 0.10, 0.34, darkMaterial, -0.13, 0.06, -0.52);
box(group, 0.22, 0.10, 0.34, darkMaterial, 0.13, 0.06, -0.52);
cylinderBetween(group, [-0.27, 1.07, 0], [-0.34, 0.83, -0.14], 0.085, seatedClothing);
cylinderBetween(group, [-0.34, 0.83, -0.14], [-0.31, 0.73, -0.35], 0.075, skinMaterial);
cylinderBetween(group, [0.27, 1.07, 0], [0.34, 0.83, -0.14], 0.085, seatedClothing);
cylinderBetween(group, [0.34, 0.83, -0.14], [0.31, 0.73, -0.35], 0.075, skinMaterial);
return group;
}
function makeWheelchairPerson() {
const group = new THREE.Group();
const rearWheel = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.065, 6, 12),
wheelMaterial
);
rearWheel.position.set(-0.08, 0.40, 0.43);
rearWheel.castShadow = true;
group.add(rearWheel);
const rearWheelOther = rearWheel.clone();
rearWheelOther.position.z = -0.43;
group.add(rearWheelOther);
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(0.08, 0.08, 0.94, 8),
darkMaterial
);
hub.rotation.x = Math.PI / 2;
hub.position.set(-0.08, 0.40, 0);
group.add(hub);
for (const z of [-0.29, 0.29]) {
const caster = new THREE.Mesh(
new THREE.TorusGeometry(0.12, 0.035, 6, 10),
wheelMaterial
);
caster.rotation.y = Math.PI / 2;
caster.position.set(0.55, 0.16, z);
group.add(caster);
}
box(group, 0.75, 0.11, 0.72, wheelchairClothing, 0, 0.52, 0);
box(group, 0.10, 0.58, 0.72, wheelchairClothing, -0.34, 0.84, 0);
box(group, 0.78, 0.06, 0.08, darkMaterial, 0.04, 0.78, 0.38);
box(group, 0.78, 0.06, 0.08, darkMaterial, 0.04, 0.78, -0.38);
box(group, 0.29, 0.53, 0.45, wheelchairClothing, 0.02, 0.91, 0);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 8, 6),
skinMaterial
);
head.position.set(0.05, 1.29, 0);
head.castShadow = true;
group.add(head);
box(group, 0.09, 0.07, 0.07, skinMaterial, 0.22, 1.28, 0);
cylinderBetween(group, [-0.07, 0.66, 0.12], [0.42, 0.61, 0.12], 0.105, darkMaterial);
cylinderBetween(group, [0.42, 0.61, 0.12], [0.49, 0.13, 0.12], 0.095, darkMaterial);
cylinderBetween(group, [0.07, 0.66, -0.12], [0.42, 0.61, -0.12], 0.105, darkMaterial);
cylinderBetween(group, [0.42, 0.61, -0.12], [0.49, 0.13, -0.12], 0.095, darkMaterial);
cylinderBetween(group, [0.12, 1.07, 0.22], [0.34, 0.83, 0.18], 0.08, wheelchairClothing);
cylinderBetween(group, [0.34, 0.83, 0.18], [0.47, 0.70, 0.10], 0.07, skinMaterial);
return group;
}
const standingBody = makeStandingPerson();
standingBody.position.set(0, 0, 1.08);
scene.add(standingBody);
const seatedBody = makeSeatedPerson();
seatedBody.position.set(2.25, 0, 1.02);
scene.add(seatedBody);
const wheelchairBody = makeWheelchairPerson();
wheelchairBody.position.set(-2.42, 0, 1.02);
scene.add(wheelchairBody);
// Adjustable reach envelopes.
const standingEnvelope = new THREE.Group();
const seatedEnvelope = new THREE.Group();
scene.add(standingEnvelope, seatedEnvelope);
function buildEnvelope(group, bounds, radiusX, radiusZ, labelText, color) {
clearGroup(group);
const [min, max] = bounds;
const centerY = (min + max) / 2;
const radiusY = (max - min) / 2;
const shell = new THREE.Mesh(
new THREE.SphereGeometry(1, 12, 8),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.075,
depthWrite: false,
side: THREE.DoubleSide
})
);
shell.scale.set(radiusX, radiusY, radiusZ);
shell.position.y = centerY;
group.add(shell);
const wire = new THREE.Mesh(
new THREE.SphereGeometry(1, 12, 8),
new THREE.MeshBasicMaterial({
color,
wireframe: true,
transparent: true,
opacity: 0.23,
depthWrite: false
})
);
wire.scale.set(radiusX, radiusY, radiusZ);
wire.position.y = centerY;
group.add(wire);
const lineMaterial = new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.9
});
for (const y of [min, max]) {
const points = [];
for (let i = 0; i <= 40; i++) {
const angle = (i / 40) * Math.PI * 2;
points.push(new THREE.Vector3(
Math.cos(angle) * radiusX,
y,
Math.sin(angle) * radiusZ
));
}
group.add(new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
lineMaterial
));
}
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2;
const points = [
new THREE.Vector3(
Math.cos(angle) * radiusX,
min,
Math.sin(angle) * radiusZ
),
new THREE.Vector3(
Math.cos(angle) * radiusX,
max,
Math.sin(angle) * radiusZ
)
];
group.add(new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
lineMaterial
));
}
const label = createLabel(labelText, 3.15);
label.position.set(0, max + 0.26, 0);
group.add(label);
}
function updateStandingEnvelope() {
buildEnvelope(
standingEnvelope,
state.standing,
0.82,
0.78,
`STANDING EXAMPLE · ${state.standing[0].toFixed(2)}–${state.standing[1].toFixed(2)} su`,
0xb84f00
);
}
function updateSeatedEnvelope() {
buildEnvelope(
seatedEnvelope,
state.seated,
0.66,
0.60,
`SEATED EXAMPLE · ${state.seated[0].toFixed(2)}–${state.seated[1].toFixed(2)} su`,
0x006d77
);
}
standingEnvelope.position.set(0, 0, 1.08);
seatedEnvelope.position.set(2.25, 0, 1.02);
// Wheelchair approach zone.
const wheelchairZone = new THREE.Group();
scene.add(wheelchairZone);
function updateWheelchairZone() {
clearGroup(wheelchairZone);
const width = state.wheel.width;
const depth = state.wheel.depth;
const startX = wheelchairBody.position.x + 0.65;
const centerX = startX + depth / 2;
const centerZ = wheelchairBody.position.z;
const area = new THREE.Mesh(
new THREE.BoxGeometry(depth, 0.025, width),
new THREE.MeshBasicMaterial({
color: 0x654ea3,
transparent: true,
opacity: 0.16,
depthWrite: false
})
);
area.position.set(centerX, 0.025, centerZ);
wheelchairZone.add(area);
const outlinePoints = [
new THREE.Vector3(startX, 0.045, centerZ - width / 2),
new THREE.Vector3(startX + depth, 0.045, centerZ - width / 2),
new THREE.Vector3(startX + depth, 0.045, centerZ + width / 2),
new THREE.Vector3(startX, 0.045, centerZ + width / 2),
new THREE.Vector3(startX, 0.045, centerZ - width / 2)
];
const outline = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(outlinePoints),
new THREE.LineDashedMaterial({
color: 0x654ea3,
dashSize: 0.12,
gapSize: 0.08,
linewidth: 1
})
);
outline.computeLineDistances();
wheelchairZone.add(outline);
const label = createLabel(
`WHEELCHAIR APPROACH · ${depth.toFixed(2)} × ${width.toFixed(2)} su`,
3.45
);
label.position.set(centerX, 0.19, centerZ + width / 2 + 0.13);
wheelchairZone.add(label);
}
// Scene titles and assumption labels.
const title = createLabel("ADJUSTABLE NOTICE STAND", 4.25);
title.position.set(0, 2.83, 0.08);
scene.add(title);
const assumption = createLabel(
"SCHEMATIC ASSUMPTIONS · NOT UNIVERSAL ERGONOMIC MEASUREMENTS",
4.85
);
assumption.position.set(0, 0.22, 2.35);
scene.add(assumption);
const unitLabel = createLabel("1 su = schematic unit", 2.15);
unitLabel.position.set(1.75, 0.18, 2.35);
scene.add(unitLabel);
// UI state and accessibility updates.
const outputMap = {
slot0: document.getElementById("slot0Value"),
slot1: document.getElementById("slot1Value"),
slot2: document.getElementById("slot2Value"),
standingMin: document.getElementById("standingMinValue"),
standingMax: document.getElementById("standingMaxValue"),
seatedMin: document.getElementById("seatedMinValue"),
seatedMax: document.getElementById("seatedMaxValue"),
wheelWidth: document.getElementById("wheelWidthValue"),
wheelDepth: document.getElementById("wheelDepthValue")
};
const inputMap = {
slot0: document.getElementById("slot0"),
slot1: document.getElementById("slot1"),
slot2: document.getElementById("slot2"),
standingMin: document.getElementById("standingMin"),
standingMax: document.getElementById("standingMax"),
seatedMin: document.getElementById("seatedMin"),
seatedMax: document.getElementById("seatedMax"),
wheelWidth: document.getElementById("wheelWidth"),
wheelDepth: document.getElementById("wheelDepth")
};
function relation(height, bounds) {
if (height < bounds[0]) return "Below example";
if (height > bounds[1]) return "Above example";
return "Within example";
}
function updateReadouts() {
outputMap.slot0.value = `${state.slots[0].toFixed(2)} su`;
outputMap.slot1.value = `${state.slots[1].toFixed(2)} su`;
outputMap.slot2.value = `${state.slots[2].toFixed(2)} su`;
outputMap.standingMin.value = `${state.standing[0].toFixed(2)} su`;
outputMap.standingMax.value = `${state.standing[1].toFixed(2)} su`;
outputMap.seatedMin.value = `${state.seated[0].toFixed(2)} su`;
outputMap.seatedMax.value = `${state.seated[1].toFixed(2)} su`;
outputMap.wheelWidth.value = `${state.wheel.width.toFixed(2)} su`;
outputMap.wheelDepth.value = `${state.wheel.depth.toFixed(2)} su`;
Object.entries(inputMap).forEach(([key, input]) => {
const value = key.startsWith("slot")
? state.slots[Number(key.slice(-1))]
: key === "standingMin"
? state.standing[0]
: key === "standingMax"
? state.standing[1]
: key === "seatedMin"
? state.seated[0]
: key === "seatedMax"
? state.seated[1]
: key === "wheelWidth"
? state.wheel.width
: state.wheel.depth;
input.value = value;
input.setAttribute("aria-valuetext", `${value.toFixed(2)} schematic units`);
});
}
function updateTableAndSummary() {
relationRows.replaceChildren();
let standingCount = 0;
let seatedCount = 0;
state.slots.forEach((height, index) => {
const standingText = relation(height, state.standing);
const seatedText = relation(height, state.seated);
if (standingText === "Within example") standingCount++;
if (seatedText === "Within example") seatedCount++;
const row = document.createElement("tr");
const slotCell = document.createElement("th");
slotCell.scope = "row";
slotCell.textContent = `Slot ${index + 1} · ${height.toFixed(2)} su`;
const standingCell = document.createElement("td");
standingCell.textContent = standingText;
standingCell.className = standingText === "Within example" ? "within" : "outside";
const seatedCell = document.createElement("td");
seatedCell.textContent = seatedText;
seatedCell.className = seatedText === "Within example" ? "within" : "outside";
row.append(slotCell, standingCell, seatedCell);
relationRows.append(row);
});
summaryText.textContent =
`Slot heights are ${state.slots.map((v) => v.toFixed(2)).join(", ")} schematic units above the floor. ` +
`Using the editable vertical examples, ${standingCount} of 3 slots are within the standing envelope ` +
`and ${seatedCount} of 3 are within the seated envelope. ` +
`The wheelchair approach example is ${state.wheel.depth.toFixed(2)} schematic units deep ` +
`and ${state.wheel.width.toFixed(2)} schematic units wide. ` +
`These values are assumptions for exploration, not universal ergonomic measurements.`;
}
let announceTimer;
function announce(message) {
clearTimeout(announceTimer);
announceTimer = setTimeout(() => {
announcer.textContent = message;
}, 180);
}
function applyVisibility() {
const showMode = (mode) =>
state.mode === "all" || state.mode === mode;
standingBody.visible = state.showBodies && showMode("standing");
seatedBody.visible = state.showBodies && showMode("seated");
wheelchairBody.visible = state.showBodies && showMode("wheelchair");
standingEnvelope.visible = state.showZones && showMode("standing");
seatedEnvelope.visible = state.showZones && showMode("seated");
wheelchairZone.visible = state.showZones && showMode("wheelchair");
document.querySelectorAll("[data-mode]").forEach((button) => {
button.setAttribute("aria-pressed", String(button.dataset.mode === state.mode));
});
requestRender();
}
function updateScene() {
updateStandingEnvelope();
updateSeatedEnvelope();
updateWheelchairZone();
updateReadouts();
updateTableAndSummary();
applyVisibility();
requestRender();
}
for (let i = 0; i < 3; i++) {
inputMap[`slot${i}`].addEventListener("input", (event) => {
state.slots[i] = Number(event.target.value);
updateSlot(i);
updateReadouts();
updateTableAndSummary();
announce(`Slot ${i + 1} set to ${state.slots[i].toFixed(2)} schematic units.`);
});
}
inputMap.standingMin.addEventListener("input", (event) => {
state.standing[0] = Number(event.target.value);
if (state.standing[0] >= state.standing[1]) {
state.standing[1] = Math.min(2.5, state.standing[0] + 0.1);
}
updateStandingEnvelope();
updateReadouts();
updateTableAndSummary();
announce(`Standing lower bound set to ${state.standing[0].toFixed(2)} schematic units.`);
});
inputMap.standingMax.addEventListener("input", (event) => {
state.standing[1] = Number(event.target.value);
if (state.standing[1] <= state.standing[0]) {
state.standing[0] = Math.max(0.25, state.standing[1] - 0.1);
}
updateStandingEnvelope();
updateReadouts();
updateTableAndSummary();
announce(`Standing upper bound set to ${state.standing[1].toFixed(2)} schematic units.`);
});
inputMap.seatedMin.addEventListener("input", (event) => {
state.seated[0] = Number(event.target.value);
if (state.seated[0] >= state.seated[1]) {
state.seated[1] = Math.min(1.6, state.seated[0] + 0.1);
}
updateSeatedEnvelope();
updateReadouts();
updateTableAndSummary();
announce(`Seated lower bound set to ${state.seated[0].toFixed(2)} schematic units.`);
});
inputMap.seatedMax.addEventListener("input", (event) => {
state.seated[1] = Number(event.target.value);
if (state.seated[1] <= state.seated[0]) {
state.seated[0] = Math.max(0.25, state.seated[1] - 0.1);
}
updateSeatedEnvelope();
updateReadouts();
updateTableAndSummary();
announce(`Seated upper bound set to ${state.seated[1].toFixed(2)} schematic units.`);
});
inputMap.wheelWidth.addEventListener("input", (event) => {
state.wheel.width = Number(event.target.value);
updateWheelchairZone();
updateReadouts();
updateTableAndSummary();
announce(`Wheelchair approach width set to ${state.wheel.width.toFixed(2)} schematic units.`);
});
inputMap.wheelDepth.addEventListener("input", (event) => {
state.wheel.depth = Number(event.target.value);
updateWheelchairZone();
updateReadouts();
updateTableAndSummary();
announce(`Wheelchair approach depth set to ${state.wheel.depth.toFixed(2)} schematic units.`);
});
document.getElementById("showBodies").addEventListener("change", (event) => {
state.showBodies = event.target.checked;
applyVisibility();
announce(`Schematic bodies ${state.showBodies ? "shown" : "hidden"}.`);
});
document.getElementById("showZones").addEventListener("change", (event) => {
state.showZones = event.target.checked;
applyVisibility();
announce(`Reach and approach zones ${state.showZones ? "shown" : "hidden"}.`);
});
document.querySelectorAll("[data-mode]").forEach((button) => {
button.addEventListener("click", () => {
state.mode = button.dataset.mode;
applyVisibility();
announce(`${button.textContent.trim()} view selected.`);
});
});
// Direct camera controls; no addons are used.
let dragging = false;
let lastX = 0;
let lastY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
canvas.focus({ preventScroll: true });
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.42,
1.45
);
updateCamera();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
5.4,
16
);
updateCamera();
}, { passive: false });
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraState.theta -= 0.12;
break;
case "ArrowRight":
cameraState.theta += 0.12;
break;
case "ArrowUp":
cameraState.phi = Math.max(0.42, cameraState.phi - 0.08);
break;
case "ArrowDown":
cameraState.phi = Math.min(1.45, cameraState.phi + 0.08);
break;
case "+":
case "=":
cameraState.radius = Math.max(5.4, cameraState.radius - 0.6);
break;
case "-":
case "_":
cameraState.radius = Math.min(16, cameraState.radius + 0.6);
break;
case "0":
cameraState.radius = 10.8;
cameraState.theta = 0.72;
cameraState.phi = 1.04;
cameraState.target.set(0, 1.12, 0.48);
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
function rotate(amount) {
cameraState.theta += amount;
updateCamera();
}
function zoom(factor) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * factor,
5.4,
16
);
updateCamera();
}
function resetCamera() {
cameraState.radius = 10.8;
cameraState.theta = 0.72;
cameraState.phi = 1.04;
cameraState.target.set(0, 1.12, 0.48);
updateCamera();
}
document.getElementById("rotateLeft").addEventListener("click", () => rotate(-0.16));
document.getElementById("rotateRight").addEventListener("click", () => rotate(0.16));
document.getElementById("zoomIn").addEventListener("click", () => zoom(0.88));
document.getElementById("zoomOut").addEventListener("click", () => zoom(1.12));
document.getElementById("resetView").addEventListener("click", resetCamera);
// Display preferences.
const contrastButton = document.getElementById("contrastButton");
const textButton = document.getElementById("textButton");
const motionButton = document.getElementById("motionButton");
contrastButton.addEventListener("click", () => {
state.highContrast = !state.highContrast;
document.body.classList.toggle("high-contrast", state.highContrast);
contrastButton.setAttribute("aria-pressed", String(state.highContrast));
scene.background.set(state.highContrast ? 0xffffff : 0xe9eef0);
requestRender();
announce(`High contrast ${state.highContrast ? "enabled" : "disabled"}.`);
});
textButton.addEventListener("click", () => {
const enabled = !document.body.classList.contains("large-text");
document.body.classList.toggle("large-text", enabled);
textButton.setAttribute("aria-pressed", String(enabled));
announce(`Large text ${enabled ? "enabled" : "disabled"}.`);
});
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
let reduceMotion = prefersReducedMotion.matches;
function applyMotionPreference() {
document.body.classList.toggle("reduce-motion", reduceMotion);
motionButton.setAttribute("aria-pressed", String(reduceMotion));
}
motionButton.addEventListener("click", () => {
reduceMotion = !reduceMotion;
applyMotionPreference();
announce(`Reduce motion ${reduceMotion ? "enabled" : "disabled"}.`);
});
prefersReducedMotion.addEventListener?.("change", (event) => {
reduceMotion = event.matches;
applyMotionPreference();
});
applyMotionPreference();
// Resize without adding external controls.
const resizeObserver = new ResizeObserver(() => {
const rect = canvas.parentElement.getBoundingClientRect();
const width = Math.max(1, Math.floor(rect.width));
const height = Math.max(1, Math.floor(rect.height));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
requestRender();
});
resizeObserver.observe(canvas.parentElement);
updateScene();
updateCamera();
canvas.setAttribute("aria-busy", "false");
</script>
</body>
</html>
```