Prompt specification
Build or customize the Three.js 3D scene "Inclusive Community Workshop Scene" 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: Inclusive Community Workshop Scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/inclusive-community-workshop-scene-x3695
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts characters, assistive devices, and accessible geometry. Build an original workshop with seated and standing characters using reachable stations. Make access paths and object interactions visible without presenting a universal ergonomic design. Voxel style.
Working Three.js Starter (inclusive-community-workshop-scene-x3695):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mosaic Makers — Accessible Voxel Workshop</title>
<style>
:root {
color-scheme: light;
--ink: #24313a;
--muted: #59666d;
--paper: #fffdf7;
--teal: #087f78;
--teal-light: #d9f2ed;
--gold: #e6aa2d;
--coral: #e76655;
--line: rgba(36, 49, 58, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce7df;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input,
summary {
font: inherit;
}
button {
color: inherit;
}
#app,
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#viewport canvas:active {
cursor: grabbing;
}
#viewport canvas:focus-visible {
outline: 4px solid var(--gold);
outline-offset: -4px;
}
#hud {
position: fixed;
z-index: 5;
top: 18px;
left: 18px;
width: min(380px, calc(100vw - 380px));
padding: 15px 17px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 14px;
background: rgba(255, 253, 247, 0.91);
box-shadow: 0 12px 34px rgba(42, 65, 66, 0.16);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin: 0 0 4px;
color: var(--teal);
font-size: 0.71rem;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
#hud h1 {
margin: 0;
font-size: clamp(1.2rem, 2vw, 1.7rem);
line-height: 1.08;
letter-spacing: -0.035em;
}
#hud p:last-child {
margin: 7px 0 0;
color: var(--muted);
font-size: 0.84rem;
line-height: 1.35;
}
#panel {
position: fixed;
z-index: 10;
top: 18px;
right: 18px;
width: 330px;
max-height: calc(100vh - 36px);
overflow: auto;
padding: 17px;
border: 1px solid rgba(255, 255, 255, 0.78);
border-radius: 16px;
background: rgba(255, 253, 247, 0.94);
box-shadow: 0 15px 42px rgba(42, 65, 66, 0.18);
backdrop-filter: blur(14px);
}
#panel h2 {
margin: 0 0 12px;
font-size: 1rem;
}
.section-title {
margin: 16px 0 8px;
color: var(--muted);
font-size: 0.7rem;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.station-grid,
.action-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.station-grid button,
.action-grid button,
.wide-button {
min-height: 40px;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 9px;
background: #fff;
font-size: 0.79rem;
font-weight: 760;
cursor: pointer;
transition:
transform 120ms ease,
border-color 120ms ease,
background 120ms ease;
}
.station-grid button:hover,
.action-grid button:hover,
.wide-button:hover {
transform: translateY(-1px);
border-color: rgba(8, 127, 120, 0.48);
background: var(--teal-light);
}
.station-grid button:focus-visible,
.action-grid button:focus-visible,
.wide-button:focus-visible,
.toggle input:focus-visible + span {
outline: 3px solid rgba(230, 170, 45, 0.62);
outline-offset: 2px;
}
.action-grid .wide-button {
grid-column: 1 / -1;
}
.primary {
border-color: var(--teal) !important;
background: var(--teal) !important;
color: white !important;
}
.status {
margin-top: 13px;
padding: 12px;
border-left: 4px solid var(--teal);
border-radius: 6px 10px 10px 6px;
background: #eef6f2;
}
.status strong {
display: block;
margin-bottom: 4px;
font-size: 0.85rem;
}
.status p {
margin: 0;
color: var(--muted);
font-size: 0.78rem;
line-height: 1.45;
}
.toggle {
display: flex;
align-items: center;
gap: 9px;
min-height: 34px;
font-size: 0.8rem;
font-weight: 700;
cursor: pointer;
}
.toggle input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.toggle span {
position: relative;
width: 34px;
height: 19px;
flex: 0 0 auto;
border-radius: 20px;
background: #aeb9b8;
transition: background 160ms ease;
}
.toggle span::after {
position: absolute;
top: 3px;
left: 3px;
width: 13px;
height: 13px;
border-radius: 50%;
background: white;
content: "";
transition: transform 160ms ease;
}
.toggle input:checked + span {
background: var(--teal);
}
.toggle input:checked + span::after {
transform: translateX(15px);
}
.note {
margin: 15px 0 0;
padding-top: 13px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 0.73rem;
line-height: 1.45;
}
.note strong {
color: var(--ink);
}
details {
margin-top: 11px;
font-size: 0.76rem;
}
summary {
color: var(--teal);
font-weight: 800;
cursor: pointer;
}
details p {
color: var(--muted);
line-height: 1.45;
}
#labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
z-index: 4;
min-width: max-content;
max-width: 210px;
padding: 7px 10px;
transform: translate(-50%, -100%);
border: 1px solid rgba(255, 255, 255, 0.9);
border-radius: 8px;
background: rgba(36, 49, 58, 0.9);
box-shadow: 0 6px 18px rgba(20, 33, 39, 0.2);
color: white;
font-size: 0.7rem;
font-weight: 820;
letter-spacing: 0.015em;
pointer-events: auto;
cursor: pointer;
}
.world-label::after {
position: absolute;
bottom: -6px;
left: 50%;
width: 10px;
height: 10px;
transform: translateX(-50%) rotate(45deg);
background: rgba(36, 49, 58, 0.9);
content: "";
}
.world-label:hover,
.world-label:focus-visible {
background: var(--teal);
outline: 3px solid rgba(230, 170, 45, 0.65);
}
#legend {
position: fixed;
z-index: 5;
bottom: 18px;
left: 18px;
display: flex;
flex-wrap: wrap;
gap: 8px 14px;
max-width: min(590px, calc(100vw - 36px));
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 11px;
background: rgba(255, 253, 247, 0.9);
box-shadow: 0 8px 24px rgba(42, 65, 66, 0.13);
color: var(--muted);
font-size: 0.7rem;
font-weight: 700;
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 17px;
height: 5px;
border-radius: 2px;
}
.swatch.route {
background: #13a69d;
}
.swatch.reach {
background: #e76655;
}
.swatch.turn {
background: #e6aa2d;
}
#hint {
position: fixed;
z-index: 5;
right: 368px;
bottom: 18px;
max-width: 310px;
padding: 9px 12px;
border-radius: 9px;
background: rgba(36, 49, 58, 0.84);
color: white;
font-size: 0.7rem;
line-height: 1.4;
pointer-events: none;
}
#toast {
position: fixed;
z-index: 30;
bottom: 72px;
left: 50%;
max-width: min(440px, calc(100vw - 40px));
padding: 11px 15px;
transform: translate(-50%, 18px);
border-radius: 10px;
background: var(--ink);
box-shadow: 0 10px 28px rgba(20, 33, 39, 0.24);
color: white;
font-size: 0.78rem;
font-weight: 720;
opacity: 0;
pointer-events: none;
transition:
opacity 180ms ease,
transform 180ms ease;
}
#toast.show {
transform: translate(-50%, 0);
opacity: 1;
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
background: #e8efe9;
color: var(--teal);
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
@media (max-width: 760px) {
#hud {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 11px 13px;
}
#hud p:last-child {
display: none;
}
#panel {
top: auto;
right: 10px;
bottom: 10px;
width: min(330px, calc(100vw - 20px));
max-height: 47vh;
padding: 13px;
}
#hint {
display: none;
}
#legend {
right: 10px;
bottom: calc(47vh + 20px);
left: 10px;
}
.world-label {
font-size: 0.62rem;
}
}
</style>
</head>
<body>
<div id="app">
<div id="viewport"></div>
<header id="hud">
<p class="eyebrow">Community repair workshop</p>
<h1>Mosaic Makers Lab</h1>
<p>
A modular voxel workshop where people choose different tools,
working positions, and ways to move through the space.
</p>
</header>
<section id="panel" aria-label="Workshop controls and descriptions">
<h2>Explore the workshop</h2>
<div class="section-title">Viewpoints</div>
<div class="station-grid">
<button data-view="overview">Overview</button>
<button data-view="standing">Standing bay</button>
<button data-view="seated">Seated bay</button>
<button data-view="entry">Step-free entry</button>
</div>
<div class="section-title">Object interactions</div>
<div class="action-grid">
<button data-action="bench-up">Raise bench</button>
<button data-action="bench-down">Lower bench</button>
<button data-action="tray" id="tray-button">Raise tool tray</button>
<button data-action="lamp" id="lamp-button">Switch lamp off</button>
<button class="wide-button primary" data-action="route" id="route-button">
Preview wheelchair route
</button>
</div>
<div class="status" aria-live="polite">
<strong id="status-title">Adaptive workbench</strong>
<p id="status-text">
Try the height controls, switch the task light, and preview the
illustrated route.
</p>
</div>
<div class="section-title">Visual layers</div>
<label class="toggle">
<input id="toggle-paths" type="checkbox" checked>
<span aria-hidden="true"></span>
Access routes and turning area
</label>
<label class="toggle">
<input id="toggle-reach" type="checkbox" checked>
<span aria-hidden="true"></span>
Reach and interaction markers
</label>
<label class="toggle">
<input id="toggle-labels" type="checkbox" checked>
<span aria-hidden="true"></span>
World labels
</label>
<details>
<summary>Read the scene description</summary>
<p>
Two standing makers work at an adjustable-height bench. One uses
a long reacher toward a high supply tray. A seated maker uses a
wheelchair at a low bench, while another person uses a supportive
chair and personal hearing equipment. A wide colored route connects
the ramp entry, work areas, device library, and a marked turning
area.
</p>
</details>
<p class="note">
<strong>Conceptual scene, not a universal ergonomic standard.</strong>
Reach, transfer, clearance, height, lighting, and controls should be
co-designed with each person. The displayed routes and dimensions are
illustrative only.
</p>
</section>
<div id="labels" aria-hidden="false"></div>
<div id="legend" aria-label="Scene legend">
<span class="legend-item">
<span class="swatch route"></span>
Illustrative access route
</span>
<span class="legend-item">
<span class="swatch reach"></span>
Reach / interaction line
</span>
<span class="legend-item">
<span class="swatch turn"></span>
Shared turning area
</span>
</div>
<div id="hint">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom · Click objects
to inspect
</div>
<div id="toast" role="status" aria-live="polite"></div>
</div>
<div id="loading">Building the workshop…</div>
<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 labelsLayer = document.querySelector("#labels");
const statusTitle = document.querySelector("#status-title");
const statusText = document.querySelector("#status-text");
const toastElement = document.querySelector("#toast");
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.id = "workshop-canvas";
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional Mosaic Makers workshop. Drag to orbit, " +
"shift-drag to pan, scroll to zoom, and use the labeled controls to " +
"change objects and viewpoints."
);
viewport.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce7df);
scene.fog = new THREE.Fog(0xdce7df, 30, 58);
const camera = new THREE.PerspectiveCamera(
43,
innerWidth / innerHeight,
0.1,
100
);
const cameraState = {
target: new THREE.Vector3(0, 1, 0),
theta: 0.63,
phi: 1.02,
radius: 25
};
const cameraGoal = {
target: cameraState.target.clone(),
theta: cameraState.theta,
phi: cameraState.phi,
radius: cameraState.radius
};
function applyCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
applyCamera();
const hemi = new THREE.HemisphereLight(0xf6fbf5, 0x718078, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d2, 3.2);
sun.position.set(9, 16, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d8ff, 0.85);
fill.position.set(-12, 9, 3);
scene.add(fill);
const material = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.83,
metalness: 0,
flatShading: true,
...extra
});
const MAT = {
wall: material(0xf0eadb),
wallSide: material(0xd7e1d9),
floor: material(0xcfd4ca),
ground: material(0xaebcb0),
ink: material(0x24313a),
black: material(0x293238),
white: material(0xfbfaf3),
wood: material(0xc99c68),
woodLight: material(0xe1bd85),
teal: material(0x168f89),
tealDark: material(0x0e6763),
coral: material(0xe76857),
yellow: material(0xf0c459),
violet: material(0x7869aa),
blue: material(0x4f7fba),
mint: material(0x8bc5a7),
skinA: material(0xd79b73),
skinB: material(0x9b654c),
skinC: material(0xe4b58d),
hairA: material(0x3f302b),
hairB: material(0x1f2528),
hairC: material(0x8b5c3f),
lens: material(0x9ed8df, {
transparent: true,
opacity: 0.56,
roughness: 0.28
})
};
const routeMaterial = new THREE.MeshBasicMaterial({
color: 0x13a69d,
transparent: true,
opacity: 0.88
});
const turnMaterial = new THREE.MeshBasicMaterial({
color: 0xe6aa2d,
transparent: true,
opacity: 0.88
});
const reachMaterial = new THREE.LineBasicMaterial({
color: 0xe76857,
transparent: true,
opacity: 0.9
});
function box(parent, w, h, d, x, y, z, mat) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
segments,
x,
y,
z,
mat
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeBeam(parent, a, b, width, depth, mat) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(width, depth, 1), mat);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
setBeam(mesh, a, b);
return mesh;
}
function setBeam(mesh, a, b) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.normalize()
);
mesh.scale.z = length;
}
function makeTextTexture(lines, background = "#24313a", foreground = "#fffdf7") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = foreground;
context.font = "800 48px monospace";
const lineHeight = 58;
const startY = canvas.height / 2 - ((lines.length - 1) * lineHeight) / 2;
lines.forEach((line, index) => {
context.fillText(
line,
canvas.width / 2,
startY + index * lineHeight,
canvas.width - 48
);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function addSign(
parent,
lines,
width,
height,
x,
y,
z,
rotationY = 0,
background = "#24313a",
foreground = "#fffdf7"
) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: makeTextTexture(lines, background, foreground)
})
);
mesh.position.set(x, y, z);
mesh.rotation.y = rotationY;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Architecture
// ---------------------------------------------------------------------
const architecture = new THREE.Group();
scene.add(architecture);
box(architecture, 20, 0.35, 14, 0, -0.175, 0, MAT.floor);
box(architecture, 20, 5.5, 0.25, 0, 2.75, -7, MAT.wall);
box(architecture, 0.25, 5.5, 14, -10, 2.75, 0, MAT.wallSide);
box(architecture, 20, 0.18, 0.16, 0, 0.12, -6.82, MAT.ink);
box(architecture, 0.16, 0.18, 14, -9.82, 0.12, 0, MAT.ink);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
MAT.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.17;
ground.receiveShadow = true;
scene.add(ground);
const gridVertices = [];
for (let x = -10; x <= 10; x += 1) {
gridVertices.push(x, 0.012, -7, x, 0.012, 7);
}
for (let z = -7; z <= 7; z += 1) {
gridVertices.push(-10, 0.012, z, 10, 0.012, z);
}
const floorGrid = new THREE.LineSegments(
new THREE.BufferGeometry().setAttribute(
"position",
new THREE.Float32BufferAttribute(gridVertices, 3)
),
new THREE.LineBasicMaterial({
color: 0x708078,
transparent: true,
opacity: 0.22
})
);
scene.add(floorGrid);
// Open roof beams and block pendant lamps.
box(architecture, 20, 0.22, 0.28, 0, 5.42, -2.5, MAT.ink);
box(architecture, 20, 0.22, 0.28, 0, 5.42, 2.5, MAT.ink);
[-6.5, 0, 6.5].forEach((x, index) => {
box(architecture, 0.06, 1.0, 0.06, x, 4.9, -1.2, MAT.ink);
box(
architecture,
0.65,
0.22,
0.65,
x,
4.32,
-1.2,
index === 1 ? MAT.coral : MAT.yellow
);
box(architecture, 0.48, 0.06, 0.48, x, 4.18, -1.2, MAT.white);
});
addSign(
architecture,
["MOSAIC MAKERS", "FIX • BUILD • SHARE"],
5.4,
1.35,
3.15,
4.72,
-6.84,
0,
"#087f78",
"#fffdf7"
);
addSign(
architecture,
["PERSONAL TOOL LIBRARY"],
3.6,
0.55,
0.15,
3.25,
-6.84,
0,
"#7869aa",
"#fffdf7"
);
// ---------------------------------------------------------------------
// Ramp and handrails
// ---------------------------------------------------------------------
const rampGroup = new THREE.Group();
scene.add(rampGroup);
const rampAngle = Math.atan(1.1 / 3.5);
const ramp = box(
rampGroup,
3,
0.2,
3.58,
6,
-0.55,
8.77,
MAT.wallSide
);
ramp.rotation.x = rampAngle;
box(rampGroup, 3.12, 0.08, 0.12, 6, 0.03, 7.0, MAT.yellow);
box(rampGroup, 3.12, 0.08, 0.12, 6, -1.07, 10.54, MAT.yellow);
[4.45, 7.55].forEach((x) => {
makeBeam(
rampGroup,
new THREE.Vector3(x, 0.88, 7.02),
new THREE.Vector3(x, -0.22, 10.53),
0.08,
0.08,
MAT.ink
);
[7.18, 8.75, 10.34].forEach((z, index) => {
const y = -index * 0.54;
box(rampGroup, 0.08, 0.95, 0.08, x, y + 0.43, z, MAT.ink);
});
});
// ---------------------------------------------------------------------
// Standing workbench
// ---------------------------------------------------------------------
const benchGroup = new THREE.Group();
benchGroup.position.set(-5, 0, -1.2);
scene.add(benchGroup);
box(benchGroup, 5.4, 0.2, 1.55, 0, 0.64, 0, MAT.wood);
box(benchGroup, 5.2, 0.12, 1.3, 0, 0.43, 0, MAT.ink);
[-2.25, 2.25].forEach((x) => {
box(benchGroup, 0.22, 1.25, 1.25, x, 0.63, 0, MAT.ink);
box(benchGroup, 0.42, 0.12, 1.42, x, 0.06, 0, MAT.ink);
});
const benchLift = new THREE.Group();
benchGroup.add(benchLift);
box(benchLift, 5.65, 0.18, 1.65, 0, 1.35, 0, MAT.woodLight);
box(benchLift, 5.7, 0.07, 0.08, 0, 1.29, 0.81, MAT.tealDark);
[-2.25, 2.25].forEach((x) => {
box(benchLift, 0.12, 0.64, 0.12, x, 1.02, 0, MAT.metal);
});
// Vice, blocks, and an adjustable-grip tool.
box(benchLift, 0.65, 0.38, 0.45, 0.8, 1.61, -0.2, MAT.blue);
box(benchLift, 0.17, 0.48, 0.58, 0.46, 1.68, -0.2, MAT.ink);
box(benchLift, 0.42, 0.2, 0.42, -0.4, 1.53, 0.18, MAT.coral);
box(benchLift, 0.45, 0.2, 0.42, -0.12, 1.53, 0.1, MAT.violet);
const gripTool = new THREE.Group();
gripTool.position.set(1.4, 1.57, 0.12);
benchLift.add(gripTool);
cylinder(gripTool, 0.1, 0.1, 0.72, 10, 0, 0, 0, MAT.yellow).rotation.x =
Math.PI / 2;
box(gripTool, 0.32, 0.2, 0.22, 0, 0, 0.39, MAT.coral);
// A high tray that can be moved independently of the worktop.
const trayGroup = new THREE.Group();
trayGroup.position.set(-1.8, 0, -0.12);
scene.add(trayGroup);
box(trayGroup, 1.65, 0.12, 0.72, 0, 2.05, 0, MAT.violet);
box(trayGroup, 0.1, 0.7, 0.1, -0.73, 1.72, 0, MAT.ink);
box(trayGroup, 0.1, 0.7, 0.1, 0.73, 1.72, 0, MAT.ink);
const trayCube = box(
trayGroup,
0.32,
0.32,
0.32,
0.17,
2.28,
0,
MAT.yellow
);
addSign(
trayGroup,
["HIGH TRAY"],
1.1,
0.25,
0,
2.08,
0.39,
0,
"#7869aa"
);
// Task lamp.
const lampGroup = new THREE.Group();
lampGroup.position.set(0.5, 1.45, -0.22);
benchLift.add(lampGroup);
box(lampGroup, 0.46, 0.08, 0.32, 0, 0, 0, MAT.ink);
box(lampGroup, 0.07, 0.72, 0.07, 0, 0.36, 0, MAT.ink);
makeBeam(
lampGroup,
new THREE.Vector3(0, 0.68, 0),
new THREE.Vector3(0.52, 0.92, 0.05),
0.08,
0.08,
MAT.ink
);
box(lampGroup, 0.48, 0.2, 0.32, 0.52, 0.91, 0.05, MAT.coral);
const lampBulbMaterial = material(0xfff5bd, {
emissive: 0xffd766,
emissiveIntensity: 1.7
});
const lampBulb = box(
lampGroup,
0.35,
0.06,
0.22,
0.52,
0.79,
0.05,
lampBulbMaterial
);
const taskLight = new THREE.PointLight(0xffdc8d, 1.4, 5, 2);
taskLight.position.set(0.52, 0.65, 0.05);
lampGroup.add(taskLight);
// ---------------------------------------------------------------------
// Pegboard and voxel tools
// ---------------------------------------------------------------------
const pegboard = new THREE.Group();
pegboard.position.set(-4.95, 2.4, -6.78);
scene.add(pegboard);
box(pegboard, 5.45, 2.55, 0.13, 0, 0, 0, MAT.wood);
for (let row = 0; row < 5; row++) {
for (let column = 0; column < 11; column++) {
box(
pegboard,
0.055,
0.055,
0.035,
-2.35 + column * 0.47,
-0.96 + row * 0.47,
0.09,
MAT.ink
);
}
}
const hammer = new THREE.Group();
hammer.position.set(-1.55, 0.24, 0.18);
pegboard.add(hammer);
box(hammer, 0.13, 0.9, 0.12, 0, -0.1, 0, MAT.yellow);
box(hammer, 0.72, 0.2, 0.18, 0, 0.42, 0, MAT.ink);
const wrench = new THREE.Group();
wrench.position.set(-0.25, 0.15, 0.2);
pegboard.add(wrench);
box(wrench, 0.18, 0.9, 0.12, 0, 0, 0, MAT.blue);
box(wrench, 0.48, 0.18, 0.12, 0, 0.48, 0, MAT.blue);
box(wrench, 0.48, 0.18, 0.12, 0, -0.48, 0, MAT.blue);
const squareTool = new THREE.Group();
squareTool.position.set(1.1, 0.18, 0.19);
pegboard.add(squareTool);
box(squareTool, 0.9, 0.16, 0.14, 0, 0, 0, MAT.coral);
box(squareTool, 0.16, 0.9, 0.14, 0.39, 0, 0, MAT.coral);
const tapeTool = new THREE.Group();
tapeTool.position.set(2.0, -0.38, 0.2);
pegboard.add(tapeTool);
box(tapeTool, 0.52, 0.52, 0.18, 0, 0, 0, MAT.teal);
box(tapeTool, 0.18, 0.52, 0.22, 0.21, 0, 0, MAT.ink);
// ---------------------------------------------------------------------
// Personal device library
// ---------------------------------------------------------------------
const deviceShelf = new THREE.Group();
deviceShelf.position.set(0.15, 0, -6.18);
scene.add(deviceShelf);
[-1.6, 1.6].forEach((x) => {
box(deviceShelf, 0.12, 3.05, 0.55, x, 1.52, 0, MAT.ink);
});
[0.55, 1.25, 1.95, 2.65].forEach((y) => {
box(deviceShelf, 3.35, 0.1, 0.7, 0, y, 0, MAT.woodLight);
});
const binColors = [MAT.coral, MAT.teal, MAT.violet, MAT.yellow];
for (let row = 0; row < 4; row++) {
for (let column = 0; column < 3; column++) {
const x = -1.0 + column * 1.0;
const y = 0.55 + row * 0.7;
box(
deviceShelf,
0.68,
0.35,
0.48,
x,
y,
0,
binColors[(row + column) % binColors.length]
);
box(deviceShelf, 0.28, 0.06, 0.08, x, y + 0.21, 0.25, MAT.ink);
}
}
addSign(
deviceShelf,
["REACHER", "GRIP TOOLS", "SWITCHES", "PERSONAL AIDS"],
3.15,
0.48,
0,
3.12,
0.04,
0,
"#7869aa"
);
// ---------------------------------------------------------------------
// Seated bench, magnifier, and tool controls
// ---------------------------------------------------------------------
const seatedBench = new THREE.Group();
seatedBench.position.set(4.2, 0, -1.55);
scene.add(seatedBench);
box(seatedBench, 5.45, 0.18, 1.45, 0, 1.05, 0, MAT.woodLight);
box(seatedBench, 5.48, 0.06, 0.08, 0, 1.0, 0.73, MAT.tealDark);
[-2.35, 2.35].forEach((x) => {
box(seatedBench, 0.17, 1.0, 1.18, x, 0.5, 0, MAT.ink);
box(seatedBench, 0.38, 0.1, 1.3, x, 0.05, 0, MAT.ink);
});
box(seatedBench, 4.7, 0.13, 0.12, 0, 0.42, -0.56, MAT.ink);
// Square magnifier, deliberately blocky to match the voxel style.
const magnifier = new THREE.Group();
magnifier.position.set(-1.25, 1.14, -0.18);
seatedBench.add(magnifier);
box(magnifier, 0.62, 0.06, 0.48, 0, 0.05, 0, MAT.ink);
box(magnifier, 0.07, 0.72, 0.08, -0.28, 0.38, 0, MAT.ink);
box(magnifier, 0.07, 0.72, 0.08, 0.28, 0.38, 0, MAT.ink);
box(magnifier, 0.62, 0.07, 0.08, 0, 0.72, 0, MAT.ink);
const magnifierLens = box(
magnifier,
0.48,
0.56,
0.045,
0,
0.38,
0,
MAT.lens
);
box(seatedBench, 0.58, 0.18, 0.42, 0.75, 1.23, 0.02, MAT.coral);
const largeButton = cylinder(
seatedBench,
0.13,
0.13,
0.09,
12,
0.75,
1.36,
0.05,
MAT.yellow
);
box(seatedBench, 0.6, 0.06, 0.45, 1.7, 1.17, 0, MAT.violet);
box(seatedBench, 0.24, 0.25, 0.24, 1.7, 1.31, 0, MAT.teal);
// ---------------------------------------------------------------------
// Characters
// ---------------------------------------------------------------------
function createStandingPerson(x, z, rotation, skin, shirt, hair) {
const root = new THREE.Group();
root.position.set(x, 0, z);
root.rotation.y = rotation;
scene.add(root);
const body = new THREE.Group();
root.add(body);
[-0.2, 0.2].forEach((legX) => {
box(body, 0.28, 0.78, 0.3, legX, 0.43, 0, MAT.blue);
box(body, 0.34, 0.18, 0.52, legX, 0.1, 0.08, MAT.ink);
});
box(body, 0.78, 0.78, 0.43, 0, 1.16, 0, shirt);
box(body, 0.13, 0.68, 0.03, 0, 1.17, 0.235, MAT.white);
box(body, 0.66, 0.6, 0.6, 0, 1.91, 0, skin);
box(body, 0.69, 0.15, 0.63, 0, 2.22, -0.02, hair);
box(body, 0.12, 0.3, 0.18, -0.31, 1.95, -0.12, hair);
box(body, 0.07, 0.07, 0.04, -0.14, 1.95, 0.32, MAT.ink);
box(body, 0.07, 0.07, 0.04, 0.14, 1.95, 0.32, MAT.ink);
box(body, 0.1, 0.1, 0.08, 0, 1.82, 0.34, skin);
const arms = [];
[-1, 1].forEach((side) => {
const pivot = new THREE.Group();
pivot.position.set(side * 0.49, 1.49, 0);
pivot.rotation.x = -1.02;
pivot.rotation.z = side * -0.08;
body.add(pivot);
box(pivot, 0.22, 0.58, 0.23, 0, -0.25, 0, shirt);
const hand = box(
pivot,
0.22,
0.2,
0.23,
0,
-0.59,
0.025,
skin
);
arms.push(hand);
});
return {
root,
body,
leftHand: arms[0],
rightHand: arms[1],
head: body.children[8]
};
}
function createSeatedPerson(chairRoot, skin, shirt, hair) {
const body = new THREE.Group();
chairRoot.add(body);
[-0.19, 0.19].forEach((legX) => {
box(body, 0.28, 0.28, 0.72, legX, 0.77, 0.36, MAT.blue);
box(body, 0.25, 0.61, 0.25, legX, 0.4, 0.72, MAT.blue);
box(body, 0.32, 0.17, 0.48, legX, 0.12, 0.82, MAT.ink);
});
box(body, 0.74, 0.73, 0.42, 0, 1.26, 0, shirt);
box(body, 0.64, 0.6, 0.59, 0, 1.92, 0, skin);
box(body, 0.68, 0.15, 0.62, 0, 2.23, -0.02, hair);
box(body, 0.07, 0.07, 0.04, -0.14, 1.96, 0.31, MAT.ink);
box(body, 0.07, 0.07, 0.04, 0.14, 1.96, 0.31, MAT.ink);
const hands = [];
[-1, 1].forEach((side) => {
const pivot = new THREE.Group();
pivot.position.set(side * 0.47, 1.5, 0);
pivot.rotation.x = -1.03;
body.add(pivot);
box(pivot, 0.21, 0.56, 0.22, 0, -0.24, 0, shirt);
const hand = box(
pivot,
0.22,
0.2,
0.22,
0,
-0.57,
0.02,
skin
);
hands.push(hand);
});
return { body, leftHand: hands[0], rightHand: hands[1] };
}
const standingMaker = createStandingPerson(
-6.8,
-3.08,
0,
MAT.skinA,
MAT.coral,
MAT.hairA
);
const secondMaker = createStandingPerson(
-3.6,
-3.05,
0,
MAT.skinB,
MAT.teal,
MAT.hairB
);
// A simple cane leaning beside the second maker.
const cane = new THREE.Group();
cane.position.set(-4.48, 0, -3.25);
cane.rotation.z = -0.16;
scene.add(cane);
cylinder(cane, 0.035, 0.035, 1.08, 8, 0, 0.56, 0, MAT.ink);
box(cane, 0.32, 0.08, 0.1, 0.12, 1.08, 0, MAT.ink);
// Wheelchair.
const wheelchair = new THREE.Group();
wheelchair.position.set(3, 0, -2.8);
scene.add(wheelchair);
box(wheelchair, 0.84, 0.15, 0.78, 0, 0.68, 0, MAT.violet);
box(wheelchair, 0.8, 1.05, 0.13, 0, 1.25, -0.39, MAT.violet);
box(wheelchair, 0.11, 1.05, 0.12, -0.47, 1.2, -0.39, MAT.ink);
box(wheelchair, 0.11, 1.05, 0.12, 0.47, 1.2, -0.39, MAT.ink);
[-0.53, 0.53].forEach((x) => {
box(wheelchair, 0.1, 0.1, 0.84, x, 0.99, 0.08, MAT.ink);
box(wheelchair, 0.22, 0.08, 0.48, x, 0.65, 0.59, MAT.ink);
box(wheelchair, 0.08, 0.36, 0.08, x, 0.48, 0.78, MAT.ink);
});
box(wheelchair, 0.84, 0.08, 0.42, 0, 0.22, 0.8, MAT.ink);
const wheelchairWheels = [];
[-0.67, 0.67].forEach((x) => {
const wheelPivot = new THREE.Group();
wheelPivot.position.set(x, 0.48, -0.08);
wheelchair.add(wheelPivot);
const tire = cylinder(
wheelPivot,
0.43,
0.43,
0.14,
16,
0,
0,
0,
MAT.black
);
tire.rotation.z = Math.PI / 2;
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.34, 0.025, 6, 18),
MAT.metal
);
rim.rotation.y = Math.PI / 2;
wheelPivot.add(rim);
const hub = cylinder(
wheelPivot,
0.1,
0.1,
0.16,
10,
0,
0,
0,
MAT.metal
);
hub.rotation.z = Math.PI / 2;
wheelchairWheels.push(wheelPivot);
});
const wheelchairPerson = createSeatedPerson(
wheelchair,
MAT.skinC,
MAT.yellow,
MAT.hairC
);
// Supportive chair with high back and lateral pads.
const supportChair = new THREE.Group();
supportChair.position.set(5.62, 0, -2.8);
scene.add(supportChair);
box(supportChair, 0.82, 0.15, 0.75, 0, 0.68, 0, MAT.teal);
box(supportChair, 0.78, 1.12, 0.14, 0, 1.25, -0.39, MAT.teal);
box(supportChair, 0.18, 0.83, 0.55, -0.48, 1.19, -0.1, MAT.mint);
box(supportChair, 0.18, 0.83, 0.55, 0.48, 1.19, -0.1, MAT.mint);
box(supportChair, 0.11, 0.12, 0.74, -0.49, 0.98, 0.06, MAT.ink);
box(supportChair, 0.11, 0.12, 0.74, 0.49, 0.98, 0.06, MAT.ink);
[-0.34, 0.34].forEach((x) => {
[-0.28, 0.3].forEach((z) => {
box(supportChair, 0.09, 0.65, 0.09, x, 0.32, z, MAT.ink);
});
});
const seatedPerson = createSeatedPerson(
supportChair,
MAT.skinB,
MAT.mint,
MAT.hairB
);
// Personal hearing equipment.
box(seatedPerson.body, 0.16, 0.32, 0.28, -0.38, 1.94, 0, MAT.ink);
box(seatedPerson.body, 0.16, 0.32, 0.28, 0.38, 1.94, 0, MAT.ink);
box(seatedPerson.body, 0.72, 0.11, 0.2, 0, 2.19, -0.03, MAT.ink);
// ---------------------------------------------------------------------
// Physical reacher
// ---------------------------------------------------------------------
const reacherShaft = makeBeam(
scene,
new THREE.Vector3(-6.8, 1.12, -2.55),
new THREE.Vector3(-6.8, 2.23, -1.25),
0.045,
0.045,
MAT.ink
);
const reacherGrip = box(
scene,
0.28,
0.26,
0.12,
-6.8,
2.23,
-1.25,
MAT.coral
);
// ---------------------------------------------------------------------
// Access route graphics and turning area
// ---------------------------------------------------------------------
const routeGroup = new THREE.Group();
scene.add(routeGroup);
function routeSegment(a, b, mat = routeMaterial, width = 0.18) {
return makeBeam(routeGroup, a, b, width, 0.035, mat);
}
routeSegment(
new THREE.Vector3(3, 0.025, -2.25),
new THREE.Vector3(3, 0.025, 3.4)
);
routeSegment(
new THREE.Vector3(3, 0.025, 3.4),
new THREE.Vector3(6, 0.025, 3.4)
);
routeSegment(
new THREE.Vector3(6, 0.025, 3.4),
new THREE.Vector3(6, 0.025, 7.0)
);
routeSegment(
new THREE.Vector3(3, 0.025, 3.4),
new THREE.Vector3(-5, 0.025, 3.4)
);
routeSegment(
new THREE.Vector3(-5, 0.025, 3.4),
new THREE.Vector3(-5, 0.025, -2.2)
);
routeSegment(
new THREE.Vector3(3, 0.025, 3.4),
new THREE.Vector3(0.2, 0.025, 3.4),
new THREE.MeshBasicMaterial({
color: 0x7869aa,
transparent: true,
opacity: 0.72
})
);
routeSegment(
new THREE.Vector3(0.2, 0.025, 3.4),
new THREE.Vector3(0.2, 0.025, -4.8),
new THREE.MeshBasicMaterial({
color: 0x7869aa,
transparent: true,
opacity: 0.72
})
);
const rampStrip = box(
routeGroup,
0.2,
0.026,
3.52,
6,
-0.438,
8.77,
routeMaterial
);
rampStrip.rotation.x = rampAngle;
const turnGroup = new THREE.Group();
routeGroup.add(turnGroup);
for (let index = 0; index < 18; index++) {
const angle = (index / 18) * Math.PI * 2;
const segment = box(
turnGroup,
0.28,
0.035,
0.1,
3 + Math.cos(angle) * 1.18,
0.035,
3.4 + Math.sin(angle) * 1.18,
turnMaterial
);
segment.rotation.y = -angle;
}
const turnSign = addSign(
turnGroup,
["SHARED TURNING AREA"],
2.1,
0.35,
3,
0.048,
3.4,
0,
"#e6aa2d",
"#24313a"
);
turnSign.rotation.x = -Math.PI / 2;
function floorArrow(x, z, rotation = 0) {
const arrow = new THREE.Group();
arrow.position.set(x, 0.045, z);
arrow.rotation.y = rotation;
routeGroup.add(arrow);
box(arrow, 0.15, 0.035, 0.65, 0, 0, 0, MAT.white);
box(arrow, 0.12, 0.035, 0.48, -0.16, 0, 0.27, MAT.white).rotation.y =
-0.62;
box(arrow, 0.12, 0.035, 0.48, 0.16, 0, 0.27, MAT.white).rotation.y =
0.62;
}
floorArrow(3, 1.25, 0);
floorArrow(4.55, 3.4, Math.PI / 2);
floorArrow(6, 5.55, 0);
floorArrow(-1, 3.4, -Math.PI / 2);
floorArrow(-5, 0.8, Math.PI);
// ---------------------------------------------------------------------
// Dynamic reach overlays
// ---------------------------------------------------------------------
const reachGroup = new THREE.Group();
scene.add(reachGroup);
function dynamicLine(color) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(new Float32Array(6), 3)
);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.9
})
);
line.frustumCulled = false;
reachGroup.add(line);
return {
line,
update(start, end) {
const positions = geometry.attributes.position.array;
positions[0] = start.x;
positions[1] = start.y;
positions[2] = start.z;
positions[3] = end.x;
positions[4] = end.y;
positions[5] = end.z;
geometry.attributes.position.needsUpdate = true;
}
};
}
const standingReach = dynamicLine(0xe76857);
const seatedReach = dynamicLine(0xe76857);
const seatedToolReach = dynamicLine(0x7869aa);
const interactionMarkers = [];
function addMarker(color, size = 0.12) {
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(size),
new THREE.MeshBasicMaterial({ color })
);
reachGroup.add(marker);
interactionMarkers.push(marker);
return marker;
}
const standingMarker = addMarker(0xe76857);
const seatedMarker = addMarker(0xe76857);
const lampMarker = addMarker(0xf0c459, 0.09);
// ---------------------------------------------------------------------
// Interaction registry and status
// ---------------------------------------------------------------------
const interactionRoots = new Map();
const interactives = [];
function registerInteractive(root, id) {
root.userData.interactionId = id;
interactionRoots.set(id, root);
interactives.push(root);
}
registerInteractive(benchGroup, "bench");
registerInteractive(trayGroup, "tray");
registerInteractive(wheelchair, "wheelchair");
registerInteractive(seatedBench, "seated");
registerInteractive(deviceShelf, "shelf");
registerInteractive(lampBulb, "lamp");
registerInteractive(rampGroup, "entry");
const interactionInfo = {
bench: {
title: "Adjustable-height workbench",
text:
"The worktop can move between different illustrative heights. " +
"A suitable height and clear knee space depend on the person and task."
},
tray: {
title: "Movable supply tray",
text:
"The tray demonstrates one way to vary a high reach area. " +
"It can be lowered or raised according to the user’s chosen setup."
},
wheelchair: {
title: "Wheelchair work position",
text:
"The wheelchair maker works at the lower bench. Use the route preview " +
"to see how this individual chair could follow the illustrated path."
},
seated: {
title: "Low seated workstation",
text:
"This station shows an open knee area, a magnifier, a large button, " +
"and a position beside a supportive chair."
},
shelf: {
title: "Personal tool library",
text:
"Tools are stored as choices rather than assigned by color or label. " +
"Examples include reachers, grip tools, switches, and hearing equipment."
},
lamp: {
title: "Adjustable task lamp",
text:
"The lamp demonstrates a switchable task light. Light direction and " +
"brightness should be selected for the person and environment."
},
entry: {
title: "Step-free workshop entry",
text:
"A gently sloped approach connects to the wide internal route. " +
"The route shown is illustrative, not a certification of accessibility."
},
turning: {
title: "Shared turning area",
text:
"This marked zone shows one possible shared maneuvering area. " +
"Its usefulness depends on chair dimensions, transfer choices, and local conditions."
}
};
let selectedHelper = null;
function selectInteraction(id) {
const info = interactionInfo[id];
if (!info) return;
statusTitle.textContent = info.title;
statusText.textContent = info.text;
if (selectedHelper) {
scene.remove(selectedHelper);
selectedHelper.geometry.dispose();
selectedHelper.material.dispose();
selectedHelper = null;
}
const root = interactionRoots.get(id);
if (root) {
selectedHelper = new THREE.BoxHelper(root, 0xe6aa2d);
selectedHelper.material.depthTest = false;
selectedHelper.material.transparent = true;
selectedHelper.material.opacity = 0.9;
selectedHelper.renderOrder = 20;
scene.add(selectedHelper);
}
}
// ---------------------------------------------------------------------
// World labels
// ---------------------------------------------------------------------
const labelDefinitions = [
{
id: "entry",
title: "↗ Step-free entry",
position: new THREE.Vector3(6, 0.85, 8.3)
},
{
id: "turning",
title: "↻ Shared turning area",
position: new THREE.Vector3(3, 0.45, 3.4)
},
{
id: "bench",
title: "↕ Adjustable standing bay",
position: new THREE.Vector3(-5, 2.85, -1.1)
},
{
id: "wheelchair",
title: "◎ Wheelchair station",
position: new THREE.Vector3(3, 2.65, -2.4)
},
{
id: "shelf",
title: "◇ Personal device library",
position: new THREE.Vector3(0.15, 3.55, -6.1)
}
];
const worldLabels = labelDefinitions.map((definition) => {
const element = document.createElement("button");
element.className = "world-label";
element.type = "button";
element.textContent = definition.title;
element.addEventListener("click", () => {
selectInteraction(definition.id);
focusView(definition.id);
});
labelsLayer.appendChild(element);
return { ...definition, element };
});
// ---------------------------------------------------------------------
// Viewpoints
// ---------------------------------------------------------------------
const views = {
overview: {
target: new THREE.Vector3(0, 1, 0),
theta: 0.63,
phi: 1.02,
radius: 25
},
standing: {
target: new THREE.Vector3(-5, 1.15, -1.8),
theta: 0.82,
phi: 1.08,
radius: 11.5
},
seated: {
target: new THREE.Vector3(4.2, 1.1, -1.9),
theta: 0.42,
phi: 1.08,
radius: 10.5
},
entry: {
target: new THREE.Vector3(5.5, 0, 7),
theta: 0.83,
phi: 1.08,
radius: 13
},
tray: {
target: new THREE.Vector3(-6.8, 1.8, -1.5),
theta: 0.65,
phi: 1.08,
radius: 8
},
shelf: {
target: new THREE.Vector3(0.15, 1.7, -5.8),
theta: 0.25,
phi: 1.08,
radius: 8.5
}
};
function focusView(id) {
const view = views[id] || views.overview;
cameraGoal.target.copy(view.target);
cameraGoal.theta = view.theta;
cameraGoal.phi = view.phi;
cameraGoal.radius = view.radius;
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
focusView(button.dataset.view);
selectInteraction(
button.dataset.view === "overview" ? "bench" : button.dataset.view
);
});
});
// ---------------------------------------------------------------------
// State and actions
// ---------------------------------------------------------------------
let benchTarget = 1.35;
let benchBase = 1.35;
let trayTarget = 0;
let trayBase = 0;
let lampOn = true;
const routeHome = new THREE.Vector3(3, 0, -2.8);
let routeState = "idle";
let routeProgress = 0;
let previousRoutePosition = routeHome.clone();
const routeCurve = new THREE.CurvePath();
routeCurve.add(
new THREE.LineCurve3(
new THREE.Vector3(3, 0, -2.8),
new THREE.Vector3(3, 0, 3.4)
)
);
routeCurve.add(
new THREE.LineCurve3(
new THREE.Vector3(3, 0, 3.4),
new THREE.Vector3(6, 0, 3.4)
)
);
routeCurve.add(
new THREE.LineCurve3(
new THREE.Vector3(6, 0, 3.4),
new THREE.Vector3(6, 0, 7)
)
);
routeCurve.add(
new THREE.LineCurve3(
new THREE.Vector3(6, 0, 7),
new THREE.Vector3(6, -1.05, 10.3)
)
);
function showToast(message) {
toastElement.textContent = message;
toastElement.classList.add("show");
clearTimeout(showToast.timeout);
showToast.timeout = setTimeout(() => {
toastElement.classList.remove("show");
}, 2800);
}
function updateTrayButton() {
document.querySelector("#tray-button").textContent =
trayTarget > 0 ? "Lower tool tray" : "Raise tool tray";
}
function updateLampButton() {
document.querySelector("#lamp-button").textContent =
lampOn ? "Switch lamp off" : "Switch lamp on";
}
function resetRoute() {
routeState = "idle";
routeProgress = 0;
wheelchair.position.copy(routeHome);
previousRoutePosition.copy(routeHome);
document.querySelector("#route-button").textContent =
"Preview wheelchair route";
}
document.querySelectorAll("[data-action]").forEach((button) => {
button.addEventListener("click", () => {
const action = button.dataset.action;
if (action === "bench-up") {
benchTarget = Math.min(1.65, benchTarget + 0.1);
selectInteraction("bench");
focusView("bench");
showToast(`Illustrative worktop height: ${benchTarget.toFixed(2)} m.`);
}
if (action === "bench-down") {
benchTarget = Math.max(1.05, benchTarget - 0.1);
selectInteraction("bench");
focusView("bench");
showToast(`Illustrative worktop height: ${benchTarget.toFixed(2)} m.`);
}
if (action === "tray") {
trayTarget = trayTarget > 0 ? 0 : 0.3;
updateTrayButton();
selectInteraction("tray");
focusView("tray");
showToast(
trayTarget > 0
? "The supply tray is shown in its raised position."
: "The supply tray is shown in its lower position."
);
}
if (action === "lamp") {
lampOn = !lampOn;
updateLampButton();
selectInteraction("lamp");
showToast(lampOn ? "Task light on." : "Task light off.");
}
if (action === "route") {
if (routeState === "playing") {
resetRoute();
showToast("Route preview stopped and the chair returned to its station.");
} else {
if (routeState === "complete") {
wheelchair.position.copy(routeHome);
previousRoutePosition.copy(routeHome);
}
routeProgress = 0;
routeState = "playing";
document.querySelector("#route-button").textContent =
"Stop and reset route";
selectInteraction("wheelchair");
focusView("entry");
showToast("Previewing one individual wheelchair route.");
}
}
});
});
document.querySelector("#toggle-paths").addEventListener("change", (event) => {
routeGroup.visible = event.target.checked;
});
document.querySelector("#toggle-reach").addEventListener("change", (event) => {
reachGroup.visible = event.target.checked;
});
document.querySelector("#toggle-labels").addEventListener("change", (event) => {
labelsLayer.hidden = !event.target.checked;
});
// ---------------------------------------------------------------------
// Custom camera controls
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const drag = {
active: false,
mode: "orbit",
startX: 0,
startY: 0,
lastX: 0,
lastY: 0,
moved: 0
};
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.focus({ preventScroll: true });
canvas.setPointerCapture(event.pointerId);
drag.active = true;
drag.mode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
drag.startX = drag.lastX = event.clientX;
drag.startY = drag.lastY = event.clientY;
drag.moved = 0;
});
canvas.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;
drag.moved += Math.abs(dx) + Math.abs(dy);
if (drag.mode === "orbit") {
cameraGoal.theta -= dx * 0.006;
cameraGoal.phi = THREE.MathUtils.clamp(
cameraGoal.phi - dy * 0.005,
0.35,
1.43
);
} else {
const scale = cameraGoal.radius * 0.0015;
const right = new THREE.Vector3(
Math.cos(cameraGoal.theta),
0,
-Math.sin(cameraGoal.theta)
);
cameraGoal.target.addScaledVector(right, -dx * scale);
cameraGoal.target.y += dy * scale;
cameraGoal.target.y = THREE.MathUtils.clamp(
cameraGoal.target.y,
-0.5,
4.5
);
}
});
canvas.addEventListener("pointerup", (event) => {
const wasClick = drag.active && drag.moved < 6;
drag.active = false;
if (wasClick) {
const rect = canvas.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 intersections = raycaster.intersectObjects(interactives, true);
if (intersections.length) {
let object = intersections[0].object;
while (object && !object.userData.interactionId) {
object = object.parent;
}
if (object?.userData.interactionId) {
selectInteraction(object.userData.interactionId);
}
}
}
});
canvas.addEventListener("pointercancel", () => {
drag.active = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius * Math.exp(event.deltaY * 0.001),
5.5,
38
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraGoal.theta += 0.1;
break;
case "ArrowRight":
cameraGoal.theta -= 0.1;
break;
case "ArrowUp":
cameraGoal.phi = Math.max(0.35, cameraGoal.phi - 0.08);
break;
case "ArrowDown":
cameraGoal.phi = Math.min(1.43, cameraGoal.phi + 0.08);
break;
case "+":
case "=":
cameraGoal.radius = Math.max(5.5, cameraGoal.radius - 1);
break;
case "-":
cameraGoal.radius = Math.min(38, cameraGoal.radius + 1);
break;
case "r":
case "R":
focusView("overview");
break;
default:
handled = false;
}
if (handled) event.preventDefault();
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
const projected = new THREE.Vector3();
const worldPosition = new THREE.Vector3();
const targetPosition = new THREE.Vector3();
const handPosition = new THREE.Vector3();
const seatedHandPosition = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const damping = reducedMotion ? 1 : 1 - Math.exp(-dt * 8);
cameraState.target.lerp(cameraGoal.target, damping);
cameraState.theta = THREE.MathUtils.lerp(
cameraState.theta,
cameraGoal.theta,
damping
);
cameraState.phi = THREE.MathUtils.lerp(
cameraState.phi,
cameraGoal.phi,
damping
);
cameraState.radius = THREE.MathUtils.lerp(
cameraState.radius,
cameraGoal.radius,
damping
);
applyCamera();
// Adjustable bench and tray.
const benchDelta = benchTarget - benchBase;
benchLift.position.y = THREE.MathUtils.lerp(
benchLift.position.y,
benchDelta,
damping
);
trayGroup.position.y = THREE.MathUtils.lerp(
trayGroup.position.y,
trayTarget,
damping
);
lampBulbMaterial.emissiveIntensity = THREE.MathUtils.lerp(
lampBulbMaterial.emissiveIntensity,
lampOn ? 1.7 : 0.02,
damping
);
taskLight.intensity = THREE.MathUtils.lerp(
taskLight.intensity,
lampOn ? 1.4 : 0,
damping
);
// Route preview.
if (routeState === "playing") {
routeProgress = Math.min(1, routeProgress + dt / (reducedMotion ? 1.5 : 8));
const routePosition = routeCurve.getPointAt(routeProgress);
wheelchair.position.copy(routePosition);
const traveled = routePosition.distanceTo(previousRoutePosition);
wheelchairWheels.forEach((wheel) => {
wheel.rotation.x -= traveled / 0.43;
});
previousRoutePosition.copy(routePosition);
if (routeProgress >= 1) {
routeState = "complete";
document.querySelector("#route-button").textContent =
"Replay wheelchair route";
showToast("Route preview complete. The actual route requires individual review.");
}
}
// Reach overlays follow moving objects.
standingMaker.leftHand.getWorldPosition(handPosition);
trayCube.getWorldPosition(targetPosition);
standingReach.update(handPosition, targetPosition);
standingMarker.position.copy(targetPosition);
reacherShaft.position.copy(handPosition);
setBeam(
reacherShaft,
handPosition,
targetPosition.clone().add(new THREE.Vector3(0, -0.05, 0.1))
);
reacherGrip.position.copy(targetPosition);
reacherGrip.position.z += 0.12;
wheelchairPerson.rightHand.getWorldPosition(seatedHandPosition);
magnifierLens.getWorldPosition(targetPosition);
seatedReach.update(seatedHandPosition, targetPosition);
seatedMarker.position.copy(targetPosition);
seatedPerson.rightHand.getWorldPosition(seatedHandPosition);
largeButton.getWorldPosition(targetPosition);
seatedToolReach.update(seatedHandPosition, targetPosition);
lampBulb.getWorldPosition(targetPosition);
lampMarker.position.copy(targetPosition);
interactionMarkers.forEach((marker, index) => {
const pulse = reducedMotion ? 1 : 1 + Math.sin(clock.elapsedTime * 3 + index) * 0.16;
marker.scale.setScalar(pulse);
marker.rotation.y += dt * 0.8;
});
if (selectedHelper) selectedHelper.update();
// Project HTML labels into screen space.
worldLabels.forEach((label) => {
projected.copy(label.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
label.element.style.display = visible ? "block" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
});
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
selectInteraction("bench");
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").remove();
});
</script>
</body>
</html>
```