Prompt specification
Build or customize the Three.js 3D scene "Communication-channel resilience exhibit" 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: Communication-channel resilience exhibit
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/communication-channel-resilience-exhibit-x0440
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring hearing assistance systems. Create a classroom where users enable captions, visual cues, or symbolic assisted audio; event cards test whether each information type remains available through the selected channels. Low-poly.
Working Three.js Starter (communication-channel-resilience-exhibit-x0440):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Classroom Access — Hearing Assistance Lab</title>
<style>
:root {
--ink: #173a3b;
--muted: #667a79;
--line: #dce5e2;
--paper: #fbfcf9;
--teal: #167d76;
--teal-soft: #e1f1ed;
--orange: #ec8058;
--orange-soft: #fff0e8;
--red: #cf514d;
--yellow: #e9b949;
--blue: #6579c5;
--shadow: 0 14px 35px rgba(31, 65, 62, 0.09);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: #dce7e5;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
width: 100%;
height: 100dvh;
overflow: hidden;
}
#viewport {
position: relative;
min-width: 0;
overflow: hidden;
background:
radial-gradient(circle at 40% 20%, rgba(255,255,255,.6), transparent 40%),
#dce7e5;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#viewport canvas.dragging {
cursor: grabbing;
}
.scene-header {
position: absolute;
top: 22px;
left: 22px;
right: 22px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
padding: 11px 15px 11px 11px;
border: 1px solid rgba(255,255,255,.75);
border-radius: 17px;
background: rgba(251, 252, 249, .88);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
pointer-events: auto;
}
.brand-icon {
display: grid;
place-items: center;
width: 44px;
height: 44px;
border-radius: 13px;
color: white;
background: var(--ink);
}
.brand-icon svg {
width: 26px;
height: 26px;
}
.eyebrow {
margin: 0 0 3px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: .15em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: 19px;
line-height: 1.1;
letter-spacing: -.025em;
}
.brand .subtitle {
margin: 4px 0 0;
color: var(--muted);
font-size: 12px;
}
.scene-tools {
display: flex;
gap: 8px;
pointer-events: auto;
}
.icon-button {
display: inline-grid;
place-items: center;
width: 42px;
height: 42px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 13px;
background: rgba(251, 252, 249, .9);
box-shadow: var(--shadow);
cursor: pointer;
transition: transform .18s ease, background .18s ease;
}
.icon-button:hover {
transform: translateY(-2px);
background: white;
}
.icon-button svg {
width: 19px;
height: 19px;
}
.scene-status {
position: absolute;
left: 22px;
bottom: 22px;
width: min(390px, calc(100% - 44px));
padding: 15px 16px;
border: 1px solid rgba(255,255,255,.78);
border-radius: 18px;
background: rgba(251, 252, 249, .9);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.status-top,
.status-bottom {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.status-top {
margin-bottom: 7px;
}
.live-label {
display: flex;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .11em;
text-transform: uppercase;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(22,125,118,.12);
}
#channelSummary {
overflow: hidden;
color: var(--muted);
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
#sceneEventTitle {
display: block;
margin-bottom: 8px;
font-size: 17px;
letter-spacing: -.02em;
}
#sceneEventInfo {
color: var(--muted);
font-size: 12px;
}
.test-badge {
flex: 0 0 auto;
padding: 5px 8px;
border-radius: 999px;
font-size: 10px;
font-weight: 800;
letter-spacing: .04em;
}
.test-badge.pass {
color: #11665f;
background: #dff2eb;
}
.test-badge.gap {
color: #a7413e;
background: #fde5e3;
}
.camera-hint {
position: absolute;
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid rgba(255,255,255,.7);
border-radius: 12px;
color: #4e6866;
background: rgba(251,252,249,.72);
font-size: 11px;
backdrop-filter: blur(8px);
pointer-events: none;
}
.camera-hint svg {
width: 16px;
height: 16px;
}
.panel {
position: relative;
z-index: 2;
overflow-y: auto;
padding: 25px 22px 36px;
border-left: 1px solid rgba(23,58,59,.08);
background: var(--paper);
box-shadow: -12px 0 40px rgba(36,71,68,.08);
scrollbar-width: thin;
scrollbar-color: #c8d5d1 transparent;
}
.panel-head h2 {
margin: 0;
font-size: 25px;
letter-spacing: -.035em;
}
.intro {
margin: 8px 0 19px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.channels {
display: grid;
gap: 9px;
}
.channel-card {
position: relative;
display: grid;
grid-template-columns: 38px 1fr 38px;
align-items: center;
gap: 11px;
min-height: 65px;
padding: 10px 11px;
border: 1px solid var(--line);
border-radius: 15px;
background: white;
cursor: pointer;
transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.channel-card:hover {
transform: translateY(-1px);
border-color: #b9cec9;
box-shadow: 0 7px 18px rgba(37,73,69,.06);
}
.channel-card:has(input:checked) {
border-color: #a7cfc7;
background: #f7fcfa;
}
.channel-card input {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
}
.channel-icon {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border-radius: 11px;
color: var(--teal);
background: var(--teal-soft);
}
.channel-card[data-channel="visual"] .channel-icon {
color: #9b6610;
background: #fff3d2;
}
.channel-card[data-channel="symbolic"] .channel-icon {
color: #5c5da4;
background: #eeedfa;
}
.channel-icon svg {
width: 21px;
height: 21px;
}
.channel-copy {
display: grid;
gap: 3px;
}
.channel-copy strong {
font-size: 13px;
}
.channel-copy small {
color: var(--muted);
font-size: 10px;
line-height: 1.3;
}
.switch {
position: relative;
width: 36px;
height: 21px;
border-radius: 999px;
background: #cbd7d4;
transition: background .2s ease;
}
.knob {
position: absolute;
top: 3px;
left: 3px;
width: 15px;
height: 15px;
border-radius: 50%;
background: white;
box-shadow: 0 2px 5px rgba(24,52,49,.22);
transition: transform .2s ease;
}
.channel-card input:checked ~ .switch {
background: var(--teal);
}
.channel-card input:checked ~ .switch .knob {
transform: translateX(15px);
}
.channel-card input:focus-visible ~ .channel-icon {
outline: 3px solid rgba(22,125,118,.25);
outline-offset: 2px;
}
.test-panel {
margin-top: 18px;
padding: 16px;
border: 1px solid var(--line);
border-radius: 17px;
background: white;
}
.test-panel.pass {
border-color: #b8ddd2;
background: linear-gradient(145deg, #f8fffc, #ffffff);
}
.test-panel.gap {
border-color: #edbdb8;
background: linear-gradient(145deg, #fff8f6, #ffffff);
}
.test-summary {
display: flex;
align-items: center;
gap: 11px;
margin-bottom: 13px;
}
.test-symbol {
display: grid;
place-items: center;
flex: 0 0 auto;
width: 35px;
height: 35px;
border-radius: 11px;
color: white;
background: var(--teal);
font-size: 17px;
font-weight: 800;
}
.gap .test-symbol {
background: var(--red);
}
.test-summary strong {
display: block;
font-size: 14px;
}
.test-summary small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.route-row {
padding: 10px 0;
border-top: 1px solid #edf1ef;
}
.route-label {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 7px;
font-size: 11px;
}
.route-label i {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--teal);
}
.route-chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.route-chip {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 5px 7px;
border-radius: 8px;
color: #29675f;
background: #e9f6f2;
font-size: 9px;
font-weight: 750;
}
.route-chip small {
color: #5f7c77;
font-weight: 500;
}
.route-chip.missing {
color: #a8423f;
background: #fde7e4;
}
.test-note {
margin: 9px 0 0;
padding-top: 10px;
border-top: 1px solid #edf1ef;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.section {
margin-top: 24px;
}
.section-title {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 10px;
}
.section-title h3 {
margin: 0;
font-size: 14px;
letter-spacing: -.015em;
}
.section-title span {
color: var(--muted);
font-size: 10px;
}
.coverage-card {
padding: 12px;
border: 1px solid var(--line);
border-radius: 15px;
background: white;
}
.coverage-table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
}
.coverage-table th,
.coverage-table td {
padding: 7px 4px;
text-align: center;
font-size: 10px;
}
.coverage-table th {
color: var(--muted);
font-weight: 700;
}
.coverage-table th:first-child,
.coverage-table td:first-child {
width: 31%;
text-align: left;
}
.coverage-table td {
border-top: 1px solid #edf1ef;
}
.matrix-cell {
display: inline-grid;
place-items: center;
width: 25px;
height: 25px;
margin: auto;
border-radius: 8px;
color: #aab9b5;
background: #f1f4f2;
font-weight: 800;
}
.matrix-cell.on {
color: #216b61;
background: #dff1eb;
}
.matrix-cell.selected {
box-shadow: 0 0 0 2px rgba(22,125,118,.12);
}
.legend {
display: flex;
gap: 13px;
margin-top: 9px;
color: var(--muted);
font-size: 9px;
}
.legend span {
display: flex;
align-items: center;
gap: 5px;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 3px;
background: #dff1eb;
}
.legend i.off {
background: #edf1ef;
}
.event-list {
display: grid;
gap: 8px;
}
.event-card {
display: grid;
grid-template-columns: 37px 1fr 18px;
align-items: center;
gap: 10px;
width: 100%;
padding: 11px;
border: 1px solid var(--line);
border-radius: 14px;
background: white;
text-align: left;
cursor: pointer;
transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.event-card:hover {
transform: translateY(-1px);
border-color: #b7cbc7;
}
.event-card.active {
border-color: #84bdb3;
background: #f1faf7;
box-shadow: inset 3px 0 0 var(--teal);
}
.event-icon {
display: grid;
place-items: center;
width: 37px;
height: 37px;
border-radius: 11px;
color: var(--event-color);
background: color-mix(in srgb, var(--event-color) 13%, white);
}
.event-icon svg {
width: 20px;
height: 20px;
}
.event-copy {
min-width: 0;
}
.event-copy strong {
display: block;
margin-bottom: 4px;
font-size: 12px;
}
.event-meta {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.info-chip {
padding: 3px 6px;
border-radius: 999px;
color: #637875;
background: #edf2f0;
font-size: 8px;
font-weight: 750;
letter-spacing: .02em;
}
.event-arrow {
color: #9badab;
font-size: 18px;
text-align: center;
}
.panel-footnote {
margin: 18px 2px 0;
color: #879895;
font-size: 10px;
line-height: 1.5;
}
button:focus-visible {
outline: 3px solid rgba(22,125,118,.28);
outline-offset: 2px;
}
@media (max-width: 900px) {
.app {
grid-template-columns: 1fr;
grid-template-rows: 62dvh auto;
height: auto;
min-height: 100dvh;
overflow: visible;
}
body {
overflow-y: auto;
}
.panel {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
box-shadow: 0 -10px 30px rgba(36,71,68,.06);
}
.camera-hint {
display: none;
}
.scene-header {
top: 14px;
left: 14px;
right: 14px;
}
.brand {
padding: 9px 12px 9px 9px;
}
.brand-icon {
width: 38px;
height: 38px;
}
.brand h1 {
font-size: 16px;
}
.brand .subtitle {
display: none;
}
.scene-status {
left: 14px;
bottom: 14px;
width: calc(100% - 28px);
}
}
@media (max-width: 480px) {
.panel {
padding: 22px 15px 30px;
}
.scene-tools .icon-button {
width: 38px;
height: 38px;
}
}
</style>
</head>
<body>
<main class="app">
<section id="viewport" aria-label="Interactive low-poly classroom scene">
<div class="scene-header">
<div class="brand">
<div class="brand-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M7 9a5 5 0 0 1 10 0v4a5 5 0 0 1-10 0V9Z" stroke-linecap="round"/>
<path d="M7 10H5.8A1.8 1.8 0 0 0 4 11.8v1.4A1.8 1.8 0 0 0 5.8 15H7"/>
<path d="M17 10h1.2a1.8 1.8 0 0 1 1.8 1.8v1.4a1.8 1.8 0 0 1-1.8 1.8H17" stroke-linecap="round"/>
<path d="M10 18.5c.7.8 1.4 1.2 2 1.2s1.3-.4 2-1.2"/>
</svg>
</div>
<div>
<p class="eyebrow">Hearing assistance lab</p>
<h1>Classroom Access</h1>
<p class="subtitle">Explore how classroom information travels.</p>
</div>
</div>
<div class="scene-tools">
<button class="icon-button" id="resetCamera" type="button" aria-label="Reset camera">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M4 8V4m0 0h4M4 4l3.1 3.1A7 7 0 1 1 5 13" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
</div>
</div>
<div class="scene-status">
<div class="status-top">
<span class="live-label"><i class="live-dot"></i> Live event</span>
<span id="channelSummary">Text + Visual</span>
</div>
<strong id="sceneEventTitle">Teacher instruction</strong>
<div class="status-bottom">
<span id="sceneEventInfo">Spoken words</span>
<span class="test-badge pass" id="sceneTestBadge">PASS</span>
</div>
</div>
<div class="camera-hint" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<rect x="7" y="2" width="10" height="20" rx="5"/>
<path d="M12 2v7"/>
</svg>
Drag to orbit · Scroll to zoom
</div>
</section>
<aside class="panel" aria-label="Hearing assistance controls">
<div class="panel-head">
<p class="eyebrow">Live assistance mix</p>
<h2>Choose your channels</h2>
<p class="intro">
Enable how information should reach you. Event cards then test each
required signal against the selected channels.
</p>
</div>
<div class="channels">
<label class="channel-card" data-channel="captions">
<input type="checkbox" data-channel="captions" checked>
<span class="channel-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<rect x="3" y="5" width="18" height="14" rx="3"/>
<path d="M7 10h4M13 10h4M7 14h3M12 14h5" stroke-linecap="round"/>
</svg>
</span>
<span class="channel-copy">
<strong>Captions</strong>
<small>Spoken words → live transcript</small>
</span>
<span class="switch" aria-hidden="true"><span class="knob"></span></span>
</label>
<label class="channel-card" data-channel="visual">
<input type="checkbox" data-channel="visual" checked>
<span class="channel-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z"/>
<circle cx="12" cy="12" r="2.7"/>
</svg>
</span>
<span class="channel-copy">
<strong>Visual cues</strong>
<small>Light, motion & gesture</small>
</span>
<span class="switch" aria-hidden="true"><span class="knob"></span></span>
</label>
<label class="channel-card" data-channel="symbolic">
<input type="checkbox" data-channel="symbolic">
<span class="channel-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<rect x="3" y="3" width="7" height="7" rx="2"/>
<rect x="14" y="3" width="7" height="7" rx="2"/>
<rect x="3" y="14" width="7" height="7" rx="2"/>
<path d="M14 17.5h7M17.5 14v7" stroke-linecap="round"/>
</svg>
</span>
<span class="channel-copy">
<strong>Symbolic assisted audio</strong>
<small>AAC-style icons + tone patterns</small>
</span>
<span class="switch" aria-hidden="true"><span class="knob"></span></span>
</label>
</div>
<section class="test-panel" id="testPanel" aria-live="polite"></section>
<section class="section">
<div class="section-title">
<h3>Information coverage</h3>
<span id="coverageCount">3 of 3 types covered</span>
</div>
<div class="coverage-card">
<table class="coverage-table" aria-label="Channel information coverage matrix">
<thead>
<tr>
<th>Information</th>
<th>Text</th>
<th>Visual</th>
<th>Symbols</th>
</tr>
</thead>
<tbody id="matrixBody"></tbody>
</table>
<div class="legend" aria-hidden="true">
<span><i></i> Available</span>
<span><i class="off"></i> Not supported</span>
</div>
</div>
</section>
<section class="section">
<div class="section-title">
<h3>Test an event</h3>
<span>Select a card to activate</span>
</div>
<div class="event-list" id="eventList"></div>
</section>
<p class="panel-footnote">
The access test reruns automatically whenever a channel or event changes.
Symbolic audio uses a low-volume synthesized tone pattern with matching symbols.
</p>
</aside>
</main>
<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.getElementById("viewport");
const testPanel = document.getElementById("testPanel");
const matrixBody = document.getElementById("matrixBody");
const eventList = document.getElementById("eventList");
const sceneEventTitle = document.getElementById("sceneEventTitle");
const sceneEventInfo = document.getElementById("sceneEventInfo");
const sceneTestBadge = document.getElementById("sceneTestBadge");
const channelSummary = document.getElementById("channelSummary");
const state = {
captions: true,
visual: true,
symbolic: false
};
const infoTypes = {
speech: "Spoken words",
ambient: "Ambient sound",
alert: "Alert signal"
};
const channelMeta = {
captions: {
name: "Captions",
short: "Text",
supports: ["speech"],
representations: {
speech: "transcript"
}
},
visual: {
name: "Visual cues",
short: "Visual",
supports: ["speech", "ambient", "alert"],
representations: {
speech: "gesture",
ambient: "light pulse",
alert: "color strobe"
}
},
symbolic: {
name: "Symbolic audio",
short: "Symbols",
supports: ["speech", "ambient", "alert"],
representations: {
speech: "AAC sequence",
ambient: "object + tone",
alert: "alert icon + urgent tone"
}
}
};
const events = [
{
id: "instruction",
time: "09:10",
title: "Teacher instruction",
description: "Ms. Rivera asks the class to open their books.",
info: ["speech"],
caption: "Please open your books to page 12.",
speaker: "MS. RIVERA",
symbolIcon: "book",
symbolLabel: "BOOK",
symbolAction: "OPEN TO 12",
color: "#167d76",
audio: [[659, 0, .11], [784, .13, .16]]
},
{
id: "bell",
time: "09:25",
title: "Classroom bell",
description: "A two-tone bell marks the end of the lesson.",
info: ["ambient"],
caption: null,
speaker: "",
symbolIcon: "bell",
symbolLabel: "BELL",
symbolAction: "PERIOD END",
color: "#e4ad36",
audio: [[784, 0, .22], [1046, .25, .35]]
},
{
id: "door",
time: "09:31",
title: "Door closes",
description: "A visitor enters and the classroom door closes.",
info: ["ambient"],
caption: null,
speaker: "",
symbolIcon: "door",
symbolLabel: "DOOR",
symbolAction: "CLOSED",
color: "#ec8058",
audio: [[180, 0, .1], [115, .08, .22]]
},
{
id: "fire",
time: "09:38",
title: "Safety alert",
description: "An alarm sounds and the teacher gives an exit direction.",
info: ["speech", "alert"],
caption: "Fire drill. Follow me to the hallway.",
speaker: "MS. RIVERA",
symbolIcon: "alert",
symbolLabel: "ALERT",
symbolAction: "EXIT • LINE UP",
color: "#cf514d",
audio: [[740, 0, .12], [988, .16, .12], [740, .32, .12], [988, .48, .2]]
},
{
id: "group",
time: "09:44",
title: "Group work starts",
description: "Students begin a paired discussion.",
info: ["speech", "ambient"],
caption: "Take turns with your partner.",
speaker: "MS. RIVERA",
symbolIcon: "talk",
symbolLabel: "TALK",
symbolAction: "TAKE TURNS",
color: "#6579c5",
audio: [[523, 0, .12], [659, .14, .18]]
}
];
let activeEvent = events[0];
let audioContext = null;
const eventIcon = {
book: `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M4 5.5c2.6-.8 5-.5 8 1.4v12c-3-1.9-5.4-2.2-8-1.4v-12Z"/>
<path d="M20 5.5c-2.6-.8-5-.5-8 1.4v12c3-1.9 5.4-2.2 8-1.4v-12Z" stroke-linejoin="round"/>
</svg>`,
bell: `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M6 16h12l-1.5-2.2V9a4.5 4.5 0 0 0-9 0v4.8L6 16Z" stroke-linejoin="round"/>
<path d="M10 19h4M12 3v2" stroke-linecap="round"/>
</svg>`,
door: `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M5 21V4h12v17M17 21h3V3h-3" stroke-linejoin="round"/>
<circle cx="13.5" cy="12.5" r=".9" fill="currentColor" stroke="none"/>
</svg>`,
alert: `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M12 3 2.8 20h18.4L12 3Z" stroke-linejoin="round"/>
<path d="M12 9v5M12 17.2v.1" stroke-linecap="round"/>
</svg>`,
talk: `
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M4 5h11v8H9l-4 3v-3H4V5Z" stroke-linejoin="round"/>
<path d="M10 9h10v7h-2v3l-4-3h-4" stroke-linejoin="round"/>
</svg>`
};
// ------------------------------------------------------------
// Three.js renderer and camera
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly classroom. Drag to orbit, scroll to zoom, or use arrow keys."
);
viewport.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dce7e5");
scene.fog = new THREE.Fog("#dce7e5", 19, 35);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 70);
const cameraTarget = new THREE.Vector3(-0.6, 1.55, -0.15);
const cameraHome = { theta: 0.22, phi: 1.08, radius: 17.5 };
const cameraState = { ...cameraHome };
function updateCamera() {
const { theta, phi, radius } = cameraState;
camera.position.set(
cameraTarget.x + radius * Math.sin(phi) * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight("#f7fffb", "#71837c", 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff5df", 3.25);
sun.position.set(5, 12, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 32;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b6dce2", 1.25);
fill.position.set(-8, 7, 1);
scene.add(fill);
const materials = {
wall: new THREE.MeshStandardMaterial({
color: "#e8eee8", roughness: .92, flatShading: true
}),
floor: new THREE.MeshStandardMaterial({
color: "#cfd9d0", roughness: .96, flatShading: true
}),
floorAccent: new THREE.MeshStandardMaterial({
color: "#d8b69c", roughness: .95, flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: "#b98763", roughness: .84, flatShading: true
}),
darkWood: new THREE.MeshStandardMaterial({
color: "#745648", roughness: .9, flatShading: true
}),
board: new THREE.MeshStandardMaterial({
color: "#315d55", roughness: .88, flatShading: true
}),
frame: new THREE.MeshStandardMaterial({
color: "#f4eee2", roughness: .8, flatShading: true
}),
ink: new THREE.MeshStandardMaterial({
color: "#274442", roughness: .9, flatShading: true
})
};
function box(parent, width, height, depth, material, x, y, z, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, top, bottom, height, sides, material, x, y, z) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(top, bottom, height, sides),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function ico(parent, radius, material, x, y, z) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, 0),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function makeCanvas(width, height) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
return canvas;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function wrapText(ctx, text, x, y, maxWidth, lineHeight, maxLines = 3) {
const words = text.split(" ");
let line = "";
let lineIndex = 0;
for (const word of words) {
const test = line ? `${line} ${word}` : word;
if (ctx.measureText(test).width > maxWidth && line) {
ctx.fillText(line, x, y + lineIndex * lineHeight);
line = word;
lineIndex++;
if (lineIndex >= maxLines - 1) break;
} else {
line = test;
}
}
if (lineIndex < maxLines) ctx.fillText(line, x, y + lineIndex * lineHeight);
}
function labelSprite(text, color = "#173a3b") {
const canvas = makeCanvas(512, 100);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(251,252,249,.92)";
roundedRect(ctx, 5, 5, 502, 90, 25);
ctx.fill();
ctx.fillStyle = color;
ctx.font = "800 28px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 51);
const texture = canvasTexture(canvas);
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: false
})
);
sprite.scale.set(2.45, .48, 1);
sprite.renderOrder = 20;
return sprite;
}
// ------------------------------------------------------------
// Classroom architecture
// ------------------------------------------------------------
box(scene, 16.4, .18, 11.4, materials.floor, 0, -.09, 0, false);
box(scene, .22, 6.3, 11.2, materials.wall, -8.1, 3.05, 0, false);
// Back wall with a doorway opening.
box(scene, 13, 6.3, .22, materials.wall, -1.5, 3.05, -5.55, false);
box(scene, 1.3, 6.3, .22, materials.wall, 7.35, 3.05, -5.55, false);
box(scene, 1.7, 2.65, .22, materials.wall, 5.85, 4.98, -5.55, false);
box(scene, 16.1, .18, .16, materials.frame, 0, .08, -5.38, false);
box(scene, .14, .18, 11.1, materials.frame, -7.93, .08, 0, false);
const rug = box(
scene, 8.4, .025, 4.1,
new THREE.MeshStandardMaterial({
color: "#d9b49c", roughness: 1, flatShading: true
}),
-.6, .015, 2.2, false
);
rug.receiveShadow = true;
// Door and frame.
box(
scene, 1.55, 3.55, .15,
new THREE.MeshStandardMaterial({
color: "#8f6c55", roughness: .85, flatShading: true
}),
5.85, 1.8, -5.42
);
box(scene, .11, 3.8, .2, materials.frame, 4.98, 1.9, -5.30);
box(scene, .11, 3.8, .2, materials.frame, 6.72, 1.9, -5.30);
box(scene, 1.85, .11, .2, materials.frame, 5.85, 3.76, -5.30);
ico(
scene, .09,
new THREE.MeshStandardMaterial({
color: "#e7bd62", roughness: .55, flatShading: true
}),
6.35, 1.75, -5.30
);
// Windows on the left wall.
const glassMaterial = new THREE.MeshStandardMaterial({
color: "#9acbd0", roughness: .28, flatShading: true,
emissive: "#6d9fa3", emissiveIntensity: .15
});
for (const z of [-2.7, .3]) {
box(scene, .12, 2.35, 2.55, materials.frame, -7.94, 3.55, z);
box(scene, .15, 2.02, 2.22, glassMaterial, -7.84, 3.55, z, false);
box(scene, .16, .08, 2.25, materials.frame, -7.79, 3.55, z);
box(scene, .16, 2.05, .08, materials.frame, -7.79, 3.55, z);
}
// Main teaching board.
box(scene, 7.1, 2.38, .14, materials.frame, -2.2, 3.65, -5.36);
box(scene, 6.82, 2.13, .13, materials.board, -2.2, 3.65, -5.26);
const boardCanvas = makeCanvas(1024, 320);
const boardCtx = boardCanvas.getContext("2d");
boardCtx.fillStyle = "#315d55";
boardCtx.fillRect(0, 0, 1024, 320);
boardCtx.strokeStyle = "rgba(255,255,255,.09)";
boardCtx.lineWidth = 2;
for (let x = 0; x < 1024; x += 64) {
boardCtx.beginPath();
boardCtx.moveTo(x, 0);
boardCtx.lineTo(x, 320);
boardCtx.stroke();
}
for (let y = 0; y < 320; y += 64) {
boardCtx.beginPath();
boardCtx.moveTo(0, y);
boardCtx.lineTo(1024, y);
boardCtx.stroke();
}
boardCtx.fillStyle = "#f6f2df";
boardCtx.font = "800 43px system-ui, sans-serif";
boardCtx.fillText("EARTH SCIENCE", 58, 70);
boardCtx.fillStyle = "#cfe7d5";
boardCtx.font = "500 27px system-ui, sans-serif";
boardCtx.fillText("Water cycle", 58, 120);
boardCtx.strokeStyle = "#cfe7d5";
boardCtx.lineWidth = 7;
boardCtx.beginPath();
boardCtx.arc(755, 180, 95, .2, Math.PI * 1.85);
boardCtx.stroke();
boardCtx.beginPath();
boardCtx.moveTo(660, 100);
boardCtx.bezierCurveTo(690, 30, 820, 35, 850, 100);
boardCtx.stroke();
boardCtx.beginPath();
boardCtx.moveTo(570, 254);
boardCtx.lineTo(890, 254);
boardCtx.stroke();
boardCtx.fillStyle = "#e5c45f";
boardCtx.beginPath();
boardCtx.arc(755, 180, 42, 0, Math.PI * 2);
boardCtx.fill();
const boardTexture = canvasTexture(boardCanvas);
const boardPlane = new THREE.Mesh(
new THREE.PlaneGeometry(6.64, 2.02),
new THREE.MeshBasicMaterial({ map: boardTexture })
);
boardPlane.position.set(-2.2, 3.65, -5.18);
scene.add(boardPlane);
// Clock.
const clockMaterial = new THREE.MeshStandardMaterial({
color: "#fbfaf0", roughness: .8, flatShading: true
});
const wallClock = cylinder(scene, .47, .47, .13, 16, clockMaterial, -6.55, 4.68, -5.28);
wallClock.rotation.x = Math.PI / 2;
box(scene, .055, .28, .04, materials.ink, -6.55, 4.76, -5.17);
box(scene, .23, .055, .04, materials.ink, -6.48, 4.68, -5.16);
// ------------------------------------------------------------
// Dynamic assistance displays
// ------------------------------------------------------------
const captionCanvas = makeCanvas(1024, 256);
const captionCtx = captionCanvas.getContext("2d");
const captionTexture = canvasTexture(captionCanvas);
const symbolCanvas = makeCanvas(512, 512);
const symbolCtx = symbolCanvas.getContext("2d");
const symbolTexture = canvasTexture(symbolCanvas);
function updateCaptionTexture() {
captionCtx.fillStyle = "#153b3b";
captionCtx.fillRect(0, 0, 1024, 256);
captionCtx.fillStyle = "#ef946d";
roundedRect(captionCtx, 34, 27, 160, 43, 12);
captionCtx.fill();
captionCtx.fillStyle = "#153b3b";
captionCtx.font = "800 21px system-ui, sans-serif";
captionCtx.textAlign = "center";
captionCtx.fillText(activeEvent.speaker || "ROOM SOUND", 114, 56);
captionCtx.textAlign = "left";
captionCtx.fillStyle = "#fffdf4";
captionCtx.font = "600 37px system-ui, sans-serif";
if (activeEvent.caption) {
wrapText(
captionCtx,
`“${activeEvent.caption}”`,
38, 132, 948, 49, 2
);
} else {
captionCtx.fillStyle = "#a9c3bd";
captionCtx.font = "600 31px system-ui, sans-serif";
captionCtx.fillText("NO SPOKEN MESSAGE IN THIS EVENT", 38, 143);
}
captionTexture.needsUpdate = true;
}
function drawSymbolIcon(ctx, name) {
ctx.save();
ctx.translate(256, 190);
ctx.strokeStyle = "#234e4a";
ctx.fillStyle = "#234e4a";
ctx.lineWidth = 13;
ctx.lineCap = "round";
ctx.lineJoin = "round";
if (name === "book") {
ctx.beginPath();
ctx.moveTo(-105, -66);
ctx.bezierCurveTo(-55, -88, -15, -65, 0, -38);
ctx.bezierCurveTo(15, -65, 55, -88, 105, -66);
ctx.lineTo(105, 73);
ctx.bezierCurveTo(55, 51, 15, 73, 0, 96);
ctx.bezierCurveTo(-15, 73, -55, 51, -105, 73);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
ctx.moveTo(0, -38);
ctx.lineTo(0, 96);
ctx.stroke();
} else if (name === "bell") {
ctx.beginPath();
ctx.moveTo(-87, 58);
ctx.quadraticCurveTo(-61, 37, -61, -21);
ctx.quadraticCurveTo(-61, -99, 0, -99);
ctx.quadraticCurveTo(61, -99, 61, -21);
ctx.quadraticCurveTo(61, 37, 87, 58);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
ctx.moveTo(-30, 79);
ctx.quadraticCurveTo(0, 115, 30, 79);
ctx.stroke();
} else if (name === "door") {
ctx.strokeRect(-73, -90, 146, 181);
ctx.beginPath();
ctx.moveTo(25, -90);
ctx.lineTo(25, 91);
ctx.stroke();
ctx.beginPath();
ctx.arc(4, 7, 9, 0, Math.PI * 2);
ctx.fill();
} else if (name === "alert") {
ctx.beginPath();
ctx.moveTo(0, -105);
ctx.lineTo(108, 82);
ctx.lineTo(-108, 82);
ctx.closePath();
ctx.stroke();
ctx.fillRect(-10, -44, 20, 74);
ctx.beginPath();
ctx.arc(0, 54, 11, 0, Math.PI * 2);
ctx.fill();
} else if (name === "talk") {
ctx.strokeRect(-106, -83, 135, 103);
ctx.beginPath();
ctx.moveTo(-65, 20);
ctx.lineTo(-65, 55);
ctx.lineTo(-31, 20);
ctx.stroke();
ctx.strokeRect(-20, -35, 125, 98);
ctx.beginPath();
ctx.moveTo(65, 63);
ctx.lineTo(65, 96);
ctx.lineTo(29, 63);
ctx.stroke();
}
ctx.restore();
}
function updateSymbolTexture() {
symbolCtx.fillStyle = "#fbf7e9";
symbolCtx.fillRect(0, 0, 512, 512);
symbolCtx.fillStyle = "#eee2c4";
roundedRect(symbolCtx, 28, 28, 456, 84, 22);
symbolCtx.fill();
symbolCtx.fillStyle = "#264e49";
symbolCtx.font = "800 38px system-ui, sans-serif";
symbolCtx.textAlign = "center";
symbolCtx.textBaseline = "middle";
symbolCtx.fillText(activeEvent.symbolLabel, 256, 71);
drawSymbolIcon(symbolCtx, activeEvent.symbolIcon);
symbolCtx.fillStyle = "#d86446";
roundedRect(symbolCtx, 45, 386, 422, 78, 20);
symbolCtx.fill();
symbolCtx.fillStyle = "#fffaf0";
symbolCtx.font = "800 28px system-ui, sans-serif";
symbolCtx.fillText(activeEvent.symbolAction, 256, 426);
symbolTexture.needsUpdate = true;
}
function makeDisplay(texture, width, height) {
const group = new THREE.Group();
box(group, width + .16, height + .16, .13, materials.frame, 0, 0, 0);
const plane = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
plane.position.z = .076;
group.add(plane);
return { group, plane };
}
const captionGroup = new THREE.Group();
captionGroup.position.set(-2.2, 1.67, -5.25);
scene.add(captionGroup);
const captionDisplay = makeDisplay(captionTexture, 5.65, 1.05);
captionGroup.add(captionDisplay.group);
const captionLabel = labelSprite("LIVE CAPTIONS", "#167d76");
captionLabel.position.set(0, .83, .12);
captionGroup.add(captionLabel);
const symbolGroup = new THREE.Group();
symbolGroup.position.set(3.27, 2.68, -5.25);
scene.add(symbolGroup);
const symbolDisplay = makeDisplay(symbolTexture, 1.78, 1.78);
symbolGroup.add(symbolDisplay.group);
const symbolLabel = labelSprite("SYMBOLIC AUDIO", "#5c5da4");
symbolLabel.scale.set(2.25, .44, 1);
symbolLabel.position.set(0, 1.22, .12);
symbolGroup.add(symbolLabel);
// Visual cue beacon by the doorway.
const visualGroup = new THREE.Group();
visualGroup.position.set(5.85, 0, -5.12);
scene.add(visualGroup);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: "#167d76",
emissive: "#167d76",
emissiveIntensity: 1.2,
roughness: .35,
flatShading: true
});
const beacon = ico(visualGroup, .24, beaconMaterial, 0, 4.42, .05);
const beaconRing = new THREE.Mesh(
new THREE.TorusGeometry(.43, .055, 6, 18),
new THREE.MeshBasicMaterial({
color: "#167d76", transparent: true, opacity: .72
})
);
beaconRing.position.set(0, 4.42, .03);
visualGroup.add(beaconRing);
for (const x of [-.34, 0, .34]) {
box(
visualGroup, .16, .48, .12,
new THREE.MeshStandardMaterial({
color: "#167d76",
emissive: "#167d76",
emissiveIntensity: .65,
roughness: .4,
flatShading: true
}),
x, 3.78, .04
);
}
const visualLabel = labelSprite("VISUAL CUE", "#9b6610");
visualLabel.position.set(0, 4.95, .12);
visualGroup.add(visualLabel);
// ------------------------------------------------------------
// Low-poly teacher and students
// ------------------------------------------------------------
const teacher = new THREE.Group();
teacher.position.set(-2.25, 0, -3.72);
scene.add(teacher);
const teacherSkin = new THREE.MeshStandardMaterial({
color: "#b97c5d", roughness: .85, flatShading: true
});
const teacherShirt = new THREE.MeshStandardMaterial({
color: "#cf684f", roughness: .9, flatShading: true
});
const teacherPants = new THREE.MeshStandardMaterial({
color: "#405b62", roughness: .9, flatShading: true
});
const teacherHair = new THREE.MeshStandardMaterial({
color: "#403c39", roughness: 1, flatShading: true
});
cylinder(teacher, .3, .46, 1.18, 7, teacherPants, 0, .7, 0);
cylinder(teacher, .42, .53, .85, 7, teacherShirt, 0, 1.55, 0);
ico(teacher, .37, teacherSkin, 0, 2.27, 0);
ico(teacher, .38, teacherHair, 0, 2.44, .04);
ico(teacher, .08, teacherHair, -.35, 2.31, 0);
const raisedArm = new THREE.Group();
raisedArm.position.set(.4, 1.82, 0);
cylinder(
raisedArm, .09, .11, .75, 5, teacherShirt, 0, -.32, 0
);
ico(raisedArm, .11, teacherSkin, 0, -.72, 0);
raisedArm.rotation.z = -.45;
teacher.add(raisedArm);
teacher.userData.raisedArm = raisedArm;
const leftArm = new THREE.Group();
leftArm.position.set(-.4, 1.82, 0);
cylinder(leftArm, .09, .11, .72, 5, teacherShirt, 0, -.3, 0);
ico(leftArm, .11, teacherSkin, 0, -.69, 0);
leftArm.rotation.z = .25;
teacher.add(leftArm);
// Teacher desk.
box(scene, 2.05, .14, .85, materials.wood, -2.25, 1.15, -4.55);
box(scene, .13, 1.12, .65, materials.darkWood, -3.12, .56, -4.55);
box(scene, .13, 1.12, .65, materials.darkWood, -1.38, .56, -4.55);
box(
scene, .65, .08, .48,
new THREE.MeshStandardMaterial({
color: "#e8e1ca", roughness: .9, flatShading: true
}),
-1.95, 1.27, -4.55
);
const studentGroups = [];
const skinColors = ["#d7a17b", "#a86c50", "#e0b48e", "#8f5c48", "#c88d67"];
const shirtColors = ["#5f8fa1", "#e3a451", "#7388b8", "#d87967", "#6da382", "#a080ad"];
const hairColors = ["#3d3833", "#6a4938", "#a8794f", "#272c2d"];
function createStudent(x, z, index) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
const deskMaterial = new THREE.MeshStandardMaterial({
color: index % 3 === 0 ? "#d9ae7b" : "#c89b70",
roughness: .87,
flatShading: true
});
box(group, 2.12, .13, .95, deskMaterial, 0, 1.08, -.47);
box(group, .12, 1.03, .12, materials.darkWood, -.88, .52, -.18);
box(group, .12, 1.03, .12, materials.darkWood, .88, .52, -.18);
box(group, .12, 1.03, .12, materials.darkWood, -.88, .52, -.78);
box(group, .12, 1.03, .12, materials.darkWood, .88, .52, -.78);
box(group, .82, .13, .75, materials.darkWood, 0, .72, .34);
box(group, .82, .8, .12, materials.darkWood, 0, 1.08, .67);
const student = new THREE.Group();
group.add(student);
const skin = new THREE.MeshStandardMaterial({
color: skinColors[index % skinColors.length],
roughness: .9,
flatShading: true
});
const shirt = new THREE.MeshStandardMaterial({
color: shirtColors[index % shirtColors.length],
roughness: .92,
flatShading: true
});
const hair = new THREE.MeshStandardMaterial({
color: hairColors[index % hairColors.length],
roughness: 1,
flatShading: true
});
cylinder(student, .25, .32, .64, 6, shirt, 0, 1.38, .15);
ico(student, .31, skin, 0, 1.98, .1);
const hairCap = ico(student, .33, hair, 0, 2.13, .13);
hairCap.scale.set(1, .55, 1);
cylinder(student, .075, .08, .48, 5, shirt, -.32, 1.44, -.1);
cylinder(student, .075, .08, .48, 5, shirt, .32, 1.44, -.1);
if (index % 4 === 0) {
const backpackMaterial = new THREE.MeshStandardMaterial({
color: shirtColors[(index + 2) % shirtColors.length],
roughness: .85,
flatShading: true
});
box(student, .55, .62, .18, backpackMaterial, 0, 1.42, .42);
}
studentGroups.push(student);
}
let studentIndex = 0;
for (const z of [-1.8, .55, 2.9]) {
for (const x of [-4.7, -1.65, 1.4]) {
createStudent(x, z, studentIndex++);
}
}
// Classroom shelf and books.
box(scene, .65, .13, 2.25, materials.wood, -7.58, .55, 3.2);
box(scene, .65, .13, 2.25, materials.wood, -7.58, 1.32, 3.2);
box(scene, .65, .13, 2.25, materials.wood, -7.58, 2.09, 3.2);
const bookColors = ["#d56f58", "#e1b958", "#568b8a", "#7183b6", "#9e7cac"];
for (let shelf = 0; shelf < 3; shelf++) {
for (let book = 0; book < 7; book++) {
const h = .38 + (book % 3) * .06;
box(
scene, .22, h, .18,
new THREE.MeshStandardMaterial({
color: bookColors[(book + shelf) % bookColors.length],
roughness: .9,
flatShading: true
}),
-7.48,
.68 + shelf * .77 + h / 2,
2.3 + book * .25
);
}
}
// Low-poly plant.
const plant = new THREE.Group();
plant.position.set(6.65, 0, 3.65);
scene.add(plant);
cylinder(
plant, .36, .28, .62, 6,
new THREE.MeshStandardMaterial({
color: "#c98060", roughness: .95, flatShading: true
}),
0, .31, 0
);
const leafMaterial = new THREE.MeshStandardMaterial({
color: "#4d8a68", roughness: .95, flatShading: true
});
const leafPositions = [
[-.25, 1.0, 0],
[.25, 1.12, .05],
[0, 1.35, -.05],
[-.12, 1.55, .03],
[.18, 1.72, -.04]
];
leafPositions.forEach((position, index) => {
const leaf = ico(plant, .38, leafMaterial, ...position);
leaf.scale.set(.65, 1.45, .55);
leaf.rotation.z = (index - 2) * .2;
});
// ------------------------------------------------------------
// Channel logic and interface
// ------------------------------------------------------------
function selectedChannelKeys() {
return Object.keys(channelMeta).filter(key => state[key]);
}
function availableChannelsFor(type) {
return selectedChannelKeys().filter(
key => channelMeta[key].supports.includes(type)
);
}
function globalCoverage() {
return Object.keys(infoTypes).filter(
type => availableChannelsFor(type).length > 0
).length;
}
function renderMatrix() {
matrixBody.innerHTML = Object.entries(infoTypes).map(([type, label]) => {
const cells = Object.entries(channelMeta).map(([key, meta]) => {
const supported = meta.supports.includes(type);
const selected = state[key];
const selectedClass = selected ? " selected" : "";
const supportClass = supported ? " on" : "";
const title = supported
? `${meta.name}: ${meta.representations[type]}`
: `${meta.name}: not supported`;
return `
<td>
<span
class="matrix-cell${supportClass}${selectedClass}"
title="${title}"
aria-label="${title}"
>${supported ? "✓" : "–"}</span>
</td>
`;
}).join("");
return `<tr><td>${label}</td>${cells}</tr>`;
}).join("");
document.getElementById("coverageCount").textContent =
`${globalCoverage()} of 3 types covered`;
}
function renderTest() {
const required = activeEvent.info;
const covered = required.filter(
type => availableChannelsFor(type).length > 0
);
const allCovered = covered.length === required.length;
const routes = required.map(type => {
const available = availableChannelsFor(type);
const chips = available.length
? available.map(key => {
const meta = channelMeta[key];
return `
<span class="route-chip">
${meta.name}<small>${meta.representations[type]}</small>
</span>
`;
}).join("")
: `<span class="route-chip missing">No selected route</span>`;
return `
<div class="route-row">
<div class="route-label">
<i></i><strong>${infoTypes[type]}</strong>
</div>
<div class="route-chips">${chips}</div>
</div>
`;
}).join("");
let note = "Every required information type has at least one enabled route.";
if (!allCovered) {
const missing = required.filter(
type => availableChannelsFor(type).length === 0
);
const suggestions = missing.map(type => {
if (type === "speech") {
return "Enable captions, visual cues, or symbolic audio for spoken words.";
}
return `Enable visual cues or symbolic audio for ${infoTypes[type].toLowerCase()}.`;
}).join(" ");
note = suggestions;
}
testPanel.className = `test-panel ${allCovered ? "pass" : "gap"}`;
testPanel.innerHTML = `
<div class="test-summary">
<div class="test-symbol">${allCovered ? "✓" : "!"}</div>
<div>
<strong>
${allCovered
? "Access route complete"
: "Coverage gap detected"}
</strong>
<small>
${activeEvent.title} · ${covered.length}/${required.length} information types covered
</small>
</div>
</div>
${routes}
<p class="test-note">${note}</p>
`;
}
function renderEventCards() {
eventList.innerHTML = events.map(event => `
<button
class="event-card${event.id === activeEvent.id ? " active" : ""}"
type="button"
data-event="${event.id}"
aria-pressed="${event.id === activeEvent.id}"
style="--event-color:${event.color}"
>
<span class="event-icon" aria-hidden="true">${eventIcon[event.symbolIcon]}</span>
<span class="event-copy">
<strong>${event.time} · ${event.title}</strong>
<span class="event-meta">
${event.info.map(type => `
<span class="info-chip">${infoTypes[type]}</span>
`).join("")}
</span>
</span>
<span class="event-arrow" aria-hidden="true">›</span>
</button>
`).join("");
eventList.querySelectorAll(".event-card").forEach(button => {
button.addEventListener("click", () => {
activateEvent(button.dataset.event);
});
});
}
function renderSceneStatus() {
const required = activeEvent.info;
const covered = required.filter(
type => availableChannelsFor(type).length > 0
);
const allCovered = covered.length === required.length;
sceneEventTitle.textContent = activeEvent.title;
sceneEventInfo.textContent = required.map(type => infoTypes[type]).join(" • ");
sceneTestBadge.className = `test-badge ${allCovered ? "pass" : "gap"}`;
sceneTestBadge.textContent = allCovered
? `PASS · ${covered.length}/${required.length}`
: `GAP · ${covered.length}/${required.length}`;
const names = selectedChannelKeys().map(key => channelMeta[key].short);
channelSummary.textContent = names.length ? names.join(" + ") : "No channels";
}
function applyChannelVisibility() {
captionGroup.visible = state.captions;
symbolGroup.visible = state.symbolic;
visualGroup.visible = state.visual;
updateCaptionTexture();
updateSymbolTexture();
const color = new THREE.Color(activeEvent.color);
beaconMaterial.color.copy(color);
beaconMaterial.emissive.copy(color);
beaconRing.material.color.copy(color);
visualGroup.traverse(object => {
if (
object.isMesh &&
object.material?.emissive &&
object !== beacon
) {
object.material.color.copy(color);
object.material.emissive.copy(color);
}
});
}
function activateEvent(id) {
const nextEvent = events.find(event => event.id === id);
if (!nextEvent) return;
activeEvent = nextEvent;
applyChannelVisibility();
renderTest();
renderEventCards();
renderSceneStatus();
if (state.symbolic) playSymbolicCue(activeEvent);
}
document.querySelectorAll(".channel-card input").forEach(input => {
input.addEventListener("change", () => {
const key = input.dataset.channel;
state[key] = input.checked;
applyChannelVisibility();
renderMatrix();
renderTest();
renderSceneStatus();
if (key === "symbolic" && state.symbolic) {
playSymbolicCue(activeEvent);
}
});
});
// ------------------------------------------------------------
// Low-volume symbolic assisted audio
// ------------------------------------------------------------
function getAudioContext() {
if (!audioContext) {
const AudioContextClass =
window.AudioContext || window.webkitAudioContext;
if (!AudioContextClass) return null;
audioContext = new AudioContextClass();
}
return audioContext;
}
function playSymbolicCue(event) {
if (!state.symbolic) return;
const context = getAudioContext();
if (!context) return;
if (context.state === "suspended") context.resume();
const now = context.currentTime + .015;
event.audio.forEach(([frequency, offset, duration]) => {
const oscillator = context.createOscillator();
const gain = context.createGain();
const start = now + offset;
oscillator.type = event.id === "fire" ? "square" : "sine";
oscillator.frequency.setValueAtTime(frequency, start);
gain.gain.setValueAtTime(.0001, start);
gain.gain.exponentialRampToValueAtTime(.035, start + .015);
gain.gain.exponentialRampToValueAtTime(.0001, start + duration);
oscillator.connect(gain);
gain.connect(context.destination);
oscillator.start(start);
oscillator.stop(start + duration + .03);
});
}
// ------------------------------------------------------------
// Direct camera controls
// ------------------------------------------------------------
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
cameraState.theta -= deltaX * .005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - deltaY * .004,
.72,
1.38
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * .012,
11.5,
23
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
Object.assign(cameraState, cameraHome);
updateCamera();
});
renderer.domElement.addEventListener("keydown", event => {
const handled = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "+", "-", "r", "R"];
if (!handled.includes(event.key)) return;
event.preventDefault();
if (event.key === "ArrowLeft") cameraState.theta -= .09;
if (event.key === "ArrowRight") cameraState.theta += .09;
if (event.key === "ArrowUp") cameraState.phi = Math.max(.72, cameraState.phi - .06);
if (event.key === "ArrowDown") cameraState.phi = Math.min(1.38, cameraState.phi + .06);
if (event.key === "+") cameraState.radius = Math.max(11.5, cameraState.radius - .7);
if (event.key === "-") cameraState.radius = Math.min(23, cameraState.radius + .7);
if (event.key.toLowerCase() === "r") Object.assign(cameraState, cameraHome);
updateCamera();
});
document.getElementById("resetCamera").addEventListener("click", () => {
Object.assign(cameraState, cameraHome);
updateCamera();
});
function resize() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
if (!width || !height) return;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
new ResizeObserver(resize).observe(viewport);
resize();
// ------------------------------------------------------------
// Initial state and animation
// ------------------------------------------------------------
updateCaptionTexture();
updateSymbolTexture();
applyChannelVisibility();
renderMatrix();
renderTest();
renderEventCards();
renderSceneStatus();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), .05);
const time = clock.elapsedTime;
if (visualGroup.visible) {
const pulseSpeed = activeEvent.id === "fire" ? 10 : 4.5;
const pulse = (Math.sin(time * pulseSpeed) + 1) * .5;
const burst = .5 + .5 * Math.sin(time * pulseSpeed + 1.2);
beaconMaterial.emissiveIntensity = .65 + pulse * 2.2;
beacon.scale.setScalar(.92 + pulse * .14);
beaconRing.scale.setScalar(.92 + burst * .35);
beaconRing.material.opacity = .38 + pulse * .48;
}
symbolGroup.position.y = 2.68 + Math.sin(time * 1.35) * .025;
const shouldRaiseArm =
state.visual && activeEvent.info.includes("speech");
const targetArmAngle = shouldRaiseArm
? -1.03 + Math.sin(time * 3) * .12
: -.45;
raisedArm.rotation.z = THREE.MathUtils.lerp(
raisedArm.rotation.z,
targetArmAngle,
Math.min(1, delta * 7)
);
studentGroups.forEach((student, index) => {
student.position.y = Math.sin(time * 1.2 + index * .8) * .012;
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```