Prompt specification
Build or customize the Three.js 3D scene "Conflicting sensory-cue teaching model" 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: Conflicting sensory-cue teaching model
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/conflicting-sensory-cue-teaching-model-x1032
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows the vestibular balance system. Allow toggling visual, support, and head-motion cues in a symbolic balance display; illustrate agreement and conflict without inducing motion sickness or prescribing clinical interpretations. Voxel style.
Working Three.js Starter (conflicting-sensory-cue-teaching-model-x1032):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<title>Vestibular Balance — Symbolic Cue Explorer</title>
<style>
:root {
--ink: #17262d;
--muted: #617077;
--paper: #f4f1e8;
--panel: #fbf9f2;
--line: #cbd0ca;
--visual: #4f7cac;
--support: #8668a5;
--motion: #d79b35;
--state: #2d8b72;
--state-soft: #dceee7;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
}
body {
overflow: hidden;
color: var(--ink);
background: var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
font: inherit;
color: inherit;
}
button:focus-visible,
canvas:focus-visible {
outline: 3px solid #f0b84b;
outline-offset: 3px;
}
#app {
display: grid;
grid-template-rows: 74px minmax(0, 1fr);
height: 100%;
}
header {
z-index: 5;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 24px;
border-bottom: 2px solid var(--ink);
background: var(--panel);
}
.brand {
display: flex;
align-items: center;
gap: 14px;
min-width: 0;
}
.voxel-mark {
display: grid;
grid-template-columns: repeat(3, 8px);
grid-template-rows: repeat(3, 8px);
gap: 2px;
flex: 0 0 auto;
}
.voxel-mark i {
display: block;
background: var(--ink);
}
.voxel-mark i:nth-child(1),
.voxel-mark i:nth-child(5),
.voxel-mark i:nth-child(9) {
background: var(--motion);
}
.brand h1 {
margin: 0;
font-size: clamp(16px, 2vw, 21px);
line-height: 1;
letter-spacing: .08em;
text-transform: uppercase;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 12px;
}
.header-actions {
display: flex;
align-items: center;
gap: 10px;
}
.safety-pill,
.small-button {
border: 1px solid var(--ink);
background: #fff;
padding: 9px 12px;
font-size: 11px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
.safety-pill {
background: #e9f3ee;
border-color: #5a9a80;
}
.small-button {
cursor: pointer;
box-shadow: 2px 2px 0 var(--ink);
}
.small-button:active {
transform: translate(2px, 2px);
box-shadow: none;
}
main {
display: grid;
grid-template-columns: 350px minmax(0, 1fr);
min-height: 0;
}
aside {
z-index: 4;
overflow: auto;
padding: 22px;
border-right: 2px solid var(--ink);
background: var(--panel);
scrollbar-width: thin;
}
.eyebrow {
margin: 0 0 8px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: .14em;
text-transform: uppercase;
}
aside > h2 {
margin: 0;
font-size: 23px;
line-height: 1.1;
}
.intro {
margin: 11px 0 20px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
section {
padding: 18px 0;
border-top: 1px solid var(--line);
}
section:first-of-type {
border-top: 0;
padding-top: 4px;
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 12px;
}
.section-title h3 {
margin: 0;
font-size: 12px;
letter-spacing: .1em;
text-transform: uppercase;
}
.section-title small {
color: var(--muted);
font-size: 10px;
}
.preset-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.preset {
min-height: 43px;
padding: 9px 8px;
border: 1px solid var(--line);
background: #fff;
cursor: pointer;
font-size: 11px;
font-weight: 750;
text-align: left;
}
.preset:hover,
.preset.selected {
border-color: var(--ink);
box-shadow: 2px 2px 0 var(--ink);
}
.cue-list {
display: grid;
gap: 10px;
}
.cue-card {
padding: 12px;
border: 1px solid var(--line);
background: #fff;
transition: opacity .15s ease;
}
.cue-card.off {
opacity: .55;
background: #f0eee8;
}
.cue-head {
display: grid;
grid-template-columns: 12px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
}
.cue-dot {
width: 11px;
height: 11px;
background: var(--cue);
box-shadow: 2px 2px 0 color-mix(in srgb, var(--cue) 55%, #777);
}
.cue-name {
font-size: 13px;
font-weight: 850;
}
.cue-sub {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
font-weight: 500;
}
.switch {
position: relative;
width: 38px;
height: 22px;
padding: 0;
border: 1px solid var(--ink);
background: #c9cec9;
cursor: pointer;
}
.switch span {
position: absolute;
top: 3px;
left: 3px;
width: 14px;
height: 14px;
background: #fff;
border: 1px solid var(--ink);
transition: left .15s ease;
}
.switch[aria-checked="true"] {
background: var(--cue);
}
.switch[aria-checked="true"] span {
left: 19px;
}
.direction-label {
display: block;
margin: 11px 0 6px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
letter-spacing: .1em;
text-transform: uppercase;
}
.direction {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5px;
}
.direction button {
min-height: 31px;
border: 1px solid var(--line);
background: #f6f4ed;
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 13px;
font-weight: 800;
}
.direction button.selected {
border-color: var(--ink);
background: var(--cue);
color: #fff;
box-shadow: 2px 2px 0 var(--ink);
}
.direction button:disabled {
cursor: not-allowed;
}
.state-card {
padding: 15px;
border: 2px solid var(--state);
background: var(--state-soft);
box-shadow: 4px 4px 0 color-mix(in srgb, var(--state) 28%, transparent);
}
.state-top {
display: flex;
align-items: center;
gap: 10px;
}
.state-symbol {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border: 2px solid var(--state);
background: #fff;
color: var(--state);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 23px;
font-weight: 900;
}
.state-kicker {
color: var(--state);
font-size: 9px;
font-weight: 850;
letter-spacing: .12em;
text-transform: uppercase;
}
.state-name {
margin-top: 2px;
font-size: 18px;
font-weight: 900;
letter-spacing: .02em;
text-transform: uppercase;
}
.state-description {
margin: 11px 0 0;
font-size: 12px;
line-height: 1.5;
}
.readout {
display: grid;
gap: 6px;
margin-top: 14px;
}
.readout-row {
display: grid;
grid-template-columns: 12px 1fr auto;
align-items: center;
gap: 8px;
padding: 7px 8px;
border: 1px solid rgba(23, 38, 45, .12);
background: rgba(255, 255, 255, .7);
font-size: 11px;
}
.readout-row i {
width: 8px;
height: 8px;
background: var(--cue);
}
.readout-row.off {
color: var(--muted);
}
.readout-row.off i {
background: #a8afb0;
}
.readout-value {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-weight: 800;
}
.comfort-note,
.clinical-note {
padding: 13px;
border: 1px solid var(--line);
background: #f1efe8;
font-size: 11px;
line-height: 1.55;
}
.comfort-note strong,
.clinical-note strong {
display: block;
margin-bottom: 4px;
font-size: 10px;
letter-spacing: .08em;
text-transform: uppercase;
}
.clinical-note {
margin-top: 12px;
border-left: 4px solid var(--ink);
}
#viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background: #e7ecec;
}
#viewport canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas.dragging {
cursor: grabbing;
}
.scene-label {
position: absolute;
z-index: 2;
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border: 1px solid rgba(23, 38, 45, .35);
background: rgba(251, 249, 242, .92);
box-shadow: 2px 2px 0 rgba(23, 38, 45, .18);
pointer-events: none;
transform: translate(-50%, -50%);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 850;
letter-spacing: .06em;
text-transform: uppercase;
white-space: nowrap;
}
.scene-label::before {
width: 8px;
height: 8px;
background: var(--cue);
content: "";
}
.scene-status {
position: absolute;
z-index: 3;
top: 22px;
right: 22px;
min-width: 190px;
padding: 13px 15px;
border: 2px solid var(--state);
background: rgba(251, 249, 242, .94);
box-shadow: 4px 4px 0 color-mix(in srgb, var(--state) 25%, transparent);
pointer-events: none;
}
.scene-status small {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
}
.scene-status strong {
display: block;
margin-top: 3px;
color: var(--state);
font-size: 16px;
letter-spacing: .04em;
text-transform: uppercase;
}
.legend {
position: absolute;
z-index: 3;
left: 22px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
gap: 12px;
max-width: calc(100% - 220px);
padding: 9px 11px;
border: 1px solid rgba(23, 38, 45, .2);
background: rgba(251, 249, 242, .9);
pointer-events: none;
font-size: 10px;
}
.legend span {
display: flex;
align-items: center;
gap: 5px;
}
.legend i {
width: 8px;
height: 8px;
background: var(--cue);
}
.view-controls {
position: absolute;
z-index: 3;
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 6px;
}
.view-controls button {
width: 34px;
height: 34px;
border: 1px solid var(--ink);
background: rgba(251, 249, 242, .95);
cursor: pointer;
font-weight: 900;
box-shadow: 2px 2px 0 var(--ink);
}
.view-controls button:active {
transform: translate(2px, 2px);
box-shadow: none;
}
.view-hint {
position: absolute;
z-index: 3;
right: 22px;
bottom: 65px;
padding: 5px 7px;
background: rgba(251, 249, 242, .8);
color: var(--muted);
pointer-events: none;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
}
#fallback {
position: absolute;
z-index: 10;
inset: 0;
display: none;
place-items: center;
padding: 30px;
background: #e7ecec;
text-align: center;
}
@media (max-width: 860px) {
body {
overflow: auto;
}
#app {
height: auto;
min-height: 100dvh;
grid-template-rows: 68px auto;
}
header {
position: sticky;
top: 0;
padding: 0 14px;
}
.brand p,
.safety-pill {
display: none;
}
main {
display: flex;
flex-direction: column;
}
#viewport {
order: 0;
height: 62vh;
min-height: 430px;
border-bottom: 2px solid var(--ink);
}
aside {
order: 1;
overflow: visible;
width: 100%;
padding: 20px;
border-right: 0;
}
.scene-status {
top: 12px;
right: 12px;
min-width: 150px;
padding: 9px 11px;
}
.scene-status strong {
font-size: 13px;
}
.legend {
left: 12px;
bottom: 12px;
max-width: calc(100% - 24px);
}
.view-controls {
right: 12px;
bottom: 52px;
}
.view-hint {
right: 12px;
bottom: 93px;
}
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
transition-duration: 0.001ms !important;
animation-duration: 0.001ms !important;
}
}
</style>
</head>
<body data-state="agreement">
<div id="app">
<header>
<div class="brand">
<div class="voxel-mark" aria-hidden="true">
<i></i><i></i><i></i>
<i></i><i></i><i></i>
<i></i><i></i><i></i>
</div>
<div>
<h1>Vestibular Balance</h1>
<p>Symbolic multisensory cue explorer</p>
</div>
</div>
<div class="header-actions">
<span class="safety-pill">Static by design · non-clinical</span>
<button class="small-button" id="resetCamera">Reset view</button>
</div>
</header>
<main>
<aside aria-label="Balance cue controls">
<p class="eyebrow">Interactive model / 01</p>
<h2>Compare cue agreement</h2>
<p class="intro">
Toggle the three symbolic references and choose a shared direction.
The halo and readout show whether the active cues agree or conflict.
</p>
<section>
<div class="section-title">
<h3>Example scenarios</h3>
<small>Instant presets</small>
</div>
<div class="preset-grid">
<button class="preset" data-preset="aligned">All aligned</button>
<button class="preset" data-preset="one">One differs</button>
<button class="preset" data-preset="conflict">Mixed directions</button>
<button class="preset" data-preset="missing">One cue missing</button>
</div>
</section>
<section>
<div class="section-title">
<h3>Symbolic cues</h3>
<small>Availability + direction</small>
</div>
<div class="cue-list">
<article class="cue-card" data-card="visual" style="--cue: var(--visual)">
<div class="cue-head">
<i class="cue-dot"></i>
<div>
<div class="cue-name">Visual horizon</div>
<span class="cue-sub">Seen reference</span>
</div>
<button class="switch" data-toggle="visual"
role="switch" aria-checked="true"
aria-label="Toggle visual horizon cue">
<span></span>
</button>
</div>
<span class="direction-label">Symbolic direction</span>
<div class="direction" role="group" aria-label="Visual horizon direction">
<button data-cue="visual" data-dir="-1" aria-label="Visual cue points left">←</button>
<button data-cue="visual" data-dir="0" aria-label="Visual cue is level">•</button>
<button data-cue="visual" data-dir="1" aria-label="Visual cue points right">→</button>
</div>
</article>
<article class="cue-card" data-card="support" style="--cue: var(--support)">
<div class="cue-head">
<i class="cue-dot"></i>
<div>
<div class="cue-name">Support surface</div>
<span class="cue-sub">Foot-contact reference</span>
</div>
<button class="switch" data-toggle="support"
role="switch" aria-checked="true"
aria-label="Toggle support surface cue">
<span></span>
</button>
</div>
<span class="direction-label">Symbolic direction</span>
<div class="direction" role="group" aria-label="Support surface direction">
<button data-cue="support" data-dir="-1" aria-label="Support cue points left">←</button>
<button data-cue="support" data-dir="0" aria-label="Support cue is level">•</button>
<button data-cue="support" data-dir="1" aria-label="Support cue points right">→</button>
</div>
</article>
<article class="cue-card" data-card="motion" style="--cue: var(--motion)">
<div class="cue-head">
<i class="cue-dot"></i>
<div>
<div class="cue-name">Head-motion signal</div>
<span class="cue-sub">Vestibular motion reference</span>
</div>
<button class="switch" data-toggle="motion"
role="switch" aria-checked="true"
aria-label="Toggle head-motion cue">
<span></span>
</button>
</div>
<span class="direction-label">Symbolic direction</span>
<div class="direction" role="group" aria-label="Head-motion signal direction">
<button data-cue="motion" data-dir="-1" aria-label="Head-motion cue points left">←</button>
<button data-cue="motion" data-dir="0" aria-label="Head-motion cue is level">•</button>
<button data-cue="motion" data-dir="1" aria-label="Head-motion cue points right">→</button>
</div>
</article>
</div>
</section>
<section>
<div class="section-title">
<h3>Symbolic result</h3>
<small id="activeCount">3 active</small>
</div>
<div class="state-card" aria-live="polite">
<div class="state-top">
<div class="state-symbol" id="stateSymbol">=</div>
<div>
<div class="state-kicker" id="stateKicker">Cue relationship</div>
<div class="state-name" id="stateName">Agreement</div>
</div>
</div>
<p class="state-description" id="stateDescription">
All three active cues point to the same symbolic direction.
</p>
<div class="readout">
<div class="readout-row" data-readout-row="visual" style="--cue: var(--visual)">
<i></i><span>Visual horizon</span>
<span class="readout-value" data-readout="visual">Level</span>
</div>
<div class="readout-row" data-readout-row="support" style="--cue: var(--support)">
<i></i><span>Support surface</span>
<span class="readout-value" data-readout="support">Level</span>
</div>
<div class="readout-row" data-readout-row="motion" style="--cue: var(--motion)">
<i></i><span>Head-motion signal</span>
<span class="readout-value" data-readout="motion">Level</span>
</div>
</div>
</div>
</section>
<section>
<div class="comfort-note">
<strong>Low-motion design</strong>
There is no auto-rotation, bobbing, parallax, or timed animation.
Cue changes are small, discrete, and user initiated. The camera moves
only when directly controlled.
</div>
<div class="clinical-note">
<strong>Scope</strong>
This is a schematic illustration of cue agreement, not an anatomical
simulation, medical assessment, diagnosis, or treatment guidance.
</div>
</section>
</aside>
<section id="viewport" aria-label="Interactive voxel balance scene">
<div class="scene-label" id="visualLabel" style="--cue: var(--visual)">Visual / horizon</div>
<div class="scene-label" id="supportLabel" style="--cue: var(--support)">Support / base</div>
<div class="scene-label" id="motionLabel" style="--cue: var(--motion)">Head-motion / signal</div>
<div class="scene-status">
<small>Current symbolic state</small>
<strong id="sceneState">Agreement</strong>
</div>
<div class="legend" aria-hidden="true">
<span style="--cue: var(--visual)"><i></i>Visual</span>
<span style="--cue: var(--support)"><i></i>Support</span>
<span style="--cue: var(--motion)"><i></i>Head motion</span>
</div>
<div class="view-hint">Drag to orbit · scroll or ± to zoom</div>
<div class="view-controls" aria-label="Camera controls">
<button id="zoomOut" aria-label="Zoom out">−</button>
<button id="zoomIn" aria-label="Zoom in">+</button>
<button id="resetView" aria-label="Reset camera view">⌂</button>
</div>
<div id="fallback">
<div>
<h2>3D view unavailable</h2>
<p>This demonstration requires a browser with WebGL enabled.</p>
</div>
</div>
</section>
</main>
</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 fallback = document.querySelector("#fallback");
const cueState = {
visual: { active: true, dir: 0 },
support: { active: true, dir: 0 },
motion: { active: true, dir: 0 }
};
const directionName = value => {
if (value < 0) return "Left";
if (value > 0) return "Right";
return "Level";
};
const stateMeta = {
agreement: {
name: "Agreement",
symbol: "=",
kicker: "All active cues align",
color: "#2d8b72",
three: 0x2d8b72
},
pair: {
name: "Pair agreement",
symbol: "=",
kicker: "Two active cues align",
color: "#3b82a0",
three: 0x3b82a0
},
conflict: {
name: "Conflict",
symbol: "≠",
kicker: "Active cues differ",
color: "#d86555",
three: 0xd86555
},
single: {
name: "Single cue",
symbol: "•",
kicker: "No comparison available",
color: "#5c72b8",
three: 0x5c72b8
},
none: {
name: "No cues",
symbol: "–",
kicker: "No active references",
color: "#7b8792",
three: 0x7b8792
}
};
let renderer;
let scene;
let camera;
let statusMaterial;
let supportPivot;
let horizonPivot;
let motionPivot;
let frameQueued = false;
const cameraState = {
radius: 8.4,
theta: 0.52,
phi: 1.12,
target: new THREE.Vector3(0, 1.28, 0)
};
const geometryCache = new Map();
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
flatShading: true,
...options
});
}
function box(parent, size, position, mat, rotation = null) {
const key = size.map(value => value.toFixed(3)).join("x");
let geometry = geometryCache.get(key);
if (!geometry) {
geometry = new THREE.BoxGeometry(...size);
geometryCache.set(key, geometry);
}
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(...position);
if (rotation) {
mesh.rotation.set(...rotation);
}
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function setOpacity(materials, opacity) {
for (const mat of materials) {
mat.opacity = opacity;
mat.transparent = opacity < 0.999;
mat.depthWrite = opacity > 0.7;
mat.needsUpdate = true;
}
}
function buildScene() {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Voxel balance display. Drag to orbit, use arrow keys to move the camera, and plus or minus to zoom."
);
viewport.appendChild(renderer.domElement);
scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7ecec);
camera = new THREE.PerspectiveCamera(38, 1, 0.1, 60);
const hemisphere = new THREE.HemisphereLight(0xfff7e8, 0x8295a0, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.0);
keyLight.position.set(5, 8, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 24;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb8d9ff, 1.0);
fillLight.position.set(-5, 4, -3);
scene.add(fillLight);
const groundMat = material(0xd9dfdc);
const gridMat = material(0xaebbb9, {
transparent: true,
opacity: 0.38,
depthWrite: false
});
box(scene, [12, 0.1, 10], [0, -0.08, 0], groundMat);
for (let i = -5; i <= 5; i++) {
const offset = i * 0.85;
box(scene, [0.018, 0.012, 8.5], [offset, -0.022, 0], gridMat);
box(scene, [10.2, 0.012, 0.018], [0, -0.021, offset], gridMat);
}
buildSupport();
buildPerson();
buildHorizon();
buildMotionSignal();
buildStatusHalo();
buildCueTokens();
const visualAnchor = new THREE.Object3D();
visualAnchor.position.set(0, 0.68, 0);
horizonPivot.add(visualAnchor);
const supportAnchor = new THREE.Object3D();
supportAnchor.position.set(1.28, 0.32, 0.62);
scene.add(supportAnchor);
const motionAnchor = new THREE.Object3D();
motionAnchor.position.set(0.52, 0.48, 0);
motionPivot.add(motionAnchor);
const anchors = [
{ element: document.querySelector("#visualLabel"), object: visualAnchor },
{ element: document.querySelector("#supportLabel"), object: supportAnchor },
{ element: document.querySelector("#motionLabel"), object: motionAnchor }
];
updateCamera();
updateScene();
invalidate();
return anchors;
}
function buildSupport() {
supportPivot = new THREE.Group();
scene.add(supportPivot);
const baseMat = material(0x33434a);
const tileMat = material(0x8668a5);
box(supportPivot, [3.0, 0.28, 2.2], [0, 0.14, 0], baseMat);
for (let x = 0; x < 7; x++) {
for (let z = 0; z < 5; z++) {
box(
supportPivot,
[0.37, 0.08, 0.35],
[(x - 3) * 0.42, 0.32, (z - 2) * 0.42],
tileMat
);
}
}
supportPivot.userData.materials = [baseMat, tileMat];
}
function buildPerson() {
const person = new THREE.Group();
scene.add(person);
const coat = material(0x2c6971);
const coatLight = material(0x3f8185);
const trousers = material(0x263b45);
const shoes = material(0x17262d);
const skin = material(0xe7b98e);
const hair = material(0x3a302d);
const shirt = material(0xf0eadb);
for (const side of [-1, 1]) {
box(person, [0.34, 0.18, 0.52], [side * 0.2, 0.43, 0.1], shoes);
box(person, [0.2, 0.52, 0.24], [side * 0.2, 0.76, 0], trousers);
}
box(person, [0.76, 0.72, 0.44], [0, 1.34, 0], coat);
box(person, [0.24, 0.52, 0.455], [0, 1.36, 0.01], shirt);
box(person, [0.78, 0.09, 0.46], [0, 1.12, 0], trousers);
for (const side of [-1, 1]) {
box(
person,
[0.18, 0.62, 0.22],
[side * 0.53, 1.31, 0],
coatLight,
[0, 0, side * -0.08]
);
box(person, [0.2, 0.2, 0.22], [side * 0.57, 0.91, 0], skin);
}
box(person, [0.22, 0.16, 0.22], [0, 1.77, 0], skin);
box(person, [0.66, 0.64, 0.60], [0, 2.18, 0], skin);
box(person, [0.70, 0.16, 0.64], [0, 2.50, -0.01], hair);
const eyeMat = material(0x17262d);
box(person, [0.065, 0.065, 0.025], [-0.14, 2.24, 0.308], eyeMat);
box(person, [0.065, 0.065, 0.025], [0.14, 2.24, 0.308], eyeMat);
box(person, [0.07, 0.08, 0.05], [0, 2.16, 0.32], skin);
}
function buildHorizon() {
horizonPivot = new THREE.Group();
horizonPivot.position.set(0, 2.05, -1.42);
scene.add(horizonPivot);
const horizonMat = material(0x4f7cac);
horizonPivot.userData.materials = [horizonMat];
for (let i = -5; i <= 5; i++) {
box(horizonPivot, [0.41, 0.09, 0.12], [i * 0.43, 0, 0], horizonMat);
}
const skyline = [
[-1.35, 0.22, 0.35],
[-0.82, 0.34, 0.28],
[-0.24, 0.19, 0.31],
[0.36, 0.40, 0.32],
[0.91, 0.25, 0.30],
[1.42, 0.17, 0.27]
];
for (const [x, y, h] of skyline) {
box(horizonPivot, [0.34, h, 0.12], [x, 0.05 + h / 2, 0], horizonMat);
}
}
function buildMotionSignal() {
motionPivot = new THREE.Group();
motionPivot.position.set(0, 2.18, 0.02);
scene.add(motionPivot);
const motionMat = material(0xd79b35, {
emissive: 0x4b2d00,
emissiveIntensity: 0.08
});
motionPivot.userData.materials = [motionMat];
// Symbolic, non-anatomical voxel loops around the head.
const count = 22;
const radius = 0.53;
for (let i = 0; i < count; i++) {
if (i === 4 || i === 5) continue;
const angle = (i / count) * Math.PI * 2;
box(
motionPivot,
[0.105, 0.105, 0.105],
[Math.cos(angle) * radius, Math.sin(angle) * radius, 0],
motionMat
);
}
// Two smaller side loops suggest vestibular canal-like channels.
for (const side of [-1, 1]) {
for (let i = 0; i < 12; i++) {
const angle = -1.2 + (i / 11) * 4.1;
box(
motionPivot,
[0.075, 0.075, 0.075],
[
side * 0.39,
Math.sin(angle) * 0.28,
Math.cos(angle) * 0.28
],
motionMat
);
}
}
// A block-like direction marker.
box(motionPivot, [0.16, 0.16, 0.16], [0.58, 0, 0], motionMat);
box(motionPivot, [0.12, 0.12, 0.12], [0.70, 0, 0], motionMat);
}
function buildStatusHalo() {
statusMaterial = material(0x2d8b72, {
emissive: 0x123b31,
emissiveIntensity: 0.12
});
const count = 30;
const radius = 1.53;
for (let i = 0; i < count; i++) {
const angle = (i / count) * Math.PI * 2;
box(
scene,
[0.105, 0.105, 0.105],
[
Math.cos(angle) * radius,
1.48 + Math.sin(angle) * radius,
-0.48
],
statusMaterial
);
}
}
const cueTokens = {};
function buildCueTokens() {
const definitions = [
["visual", -1.05, 0x4f7cac],
["support", 0, 0x8668a5],
["motion", 1.05, 0xd79b35]
];
for (const [cue, x, color] of definitions) {
const group = new THREE.Group();
group.position.set(x, 0, 1.53);
scene.add(group);
const baseMat = material(0xf5f2e8);
const markerMat = material(color);
box(group, [0.64, 0.09, 0.45], [0, 0.045, 0], baseMat);
box(group, [0.08, 0.14, 0.08], [0, 0.13, 0], markerMat);
const marker = new THREE.Group();
group.add(marker);
marker.position.set(0, 0.23, 0);
box(marker, [0.18, 0.18, 0.18], [0, 0, 0], markerMat);
cueTokens[cue] = { group, marker, material: markerMat };
}
}
function applyOpacityToScene() {
const cueToGroup = {
visual: horizonPivot,
support: supportPivot,
motion: motionPivot
};
for (const cue of Object.keys(cueState)) {
const active = cueState[cue].active;
const opacity = active ? 1 : 0.14;
setOpacity(cueToGroup[cue].userData.materials, opacity);
setOpacity([cueTokens[cue].material], active ? 1 : 0.14);
}
}
function updateScene() {
if (!supportPivot) return;
const visual = cueState.visual;
const support = cueState.support;
const motion = cueState.motion;
const tilt = THREE.MathUtils.degToRad(5);
supportPivot.rotation.z = support.active ? support.dir * tilt : 0;
horizonPivot.rotation.z = visual.active ? visual.dir * tilt : 0;
motionPivot.rotation.z = motion.active ? motion.dir * tilt : 0;
for (const cue of Object.keys(cueState)) {
const entry = cueTokens[cue];
const direction = cueState[cue].active ? cueState[cue].dir : 0;
entry.marker.position.x = direction * 0.22;
}
applyOpacityToScene();
}
function determineState() {
const active = Object.entries(cueState)
.filter(([, value]) => value.active)
.map(([, value]) => value.dir);
if (active.length === 0) return "none";
if (active.length === 1) return "single";
const aligned = active.every(value => value === active[0]);
if (!aligned) return "conflict";
return active.length === 3 ? "agreement" : "pair";
}
function describeState(key) {
if (key === "agreement") {
return "All three active cues point to the same symbolic direction.";
}
if (key === "pair") {
return "The two active cues agree; one reference is absent.";
}
if (key === "conflict") {
return "At least two active cues point in different symbolic directions.";
}
if (key === "single") {
return "Only one reference is active, so no comparison can be made.";
}
return "No cue references are active.";
}
const presetDefinitions = {
aligned: {
visual: { active: true, dir: 0 },
support: { active: true, dir: 0 },
motion: { active: true, dir: 0 }
},
one: {
visual: { active: true, dir: -1 },
support: { active: true, dir: 0 },
motion: { active: true, dir: 0 }
},
conflict: {
visual: { active: true, dir: -1 },
support: { active: true, dir: 0 },
motion: { active: true, dir: 1 }
},
missing: {
visual: { active: true, dir: 0 },
support: { active: true, dir: 0 },
motion: { active: false, dir: 0 }
}
};
function presetMatches(name) {
const preset = presetDefinitions[name];
return Object.keys(preset).every(cue => {
const current = cueState[cue];
const expected = preset[cue];
return current.active === expected.active && current.dir === expected.dir;
});
}
function updateUI() {
const key = determineState();
const meta = stateMeta[key];
document.body.dataset.state = key;
document.documentElement.style.setProperty("--state", meta.color);
document.documentElement.style.setProperty("--state-soft", `${meta.color}22`);
document.querySelector("#stateSymbol").textContent = meta.symbol;
document.querySelector("#stateKicker").textContent = meta.kicker;
document.querySelector("#stateName").textContent = meta.name;
document.querySelector("#stateDescription").textContent = describeState(key);
document.querySelector("#sceneState").textContent = meta.name;
const activeCount = Object.values(cueState).filter(value => value.active).length;
document.querySelector("#activeCount").textContent =
`${activeCount} active${activeCount === 1 ? "" : "s"}`;
for (const cue of Object.keys(cueState)) {
const value = cueState[cue];
const toggle = document.querySelector(`[data-toggle="${cue}"]`);
toggle.setAttribute("aria-checked", String(value.active));
const card = document.querySelector(`[data-card="${cue}"]`);
card.classList.toggle("off", !value.active);
const row = document.querySelector(`[data-readout-row="${cue}"]`);
row.classList.toggle("off", !value.active);
document.querySelector(`[data-readout="${cue}"]`).textContent =
value.active ? directionName(value.dir) : "Off";
document.querySelectorAll(`[data-cue="${cue}"]`).forEach(button => {
button.disabled = !value.active;
button.classList.toggle(
"selected",
value.active && Number(button.dataset.dir) === value.dir
);
});
}
document.querySelectorAll("[data-preset]").forEach(button => {
button.classList.toggle("selected", presetMatches(button.dataset.preset));
});
if (statusMaterial) {
statusMaterial.color.setHex(meta.three);
statusMaterial.emissive.setHex(meta.three);
}
updateScene();
invalidate();
}
function updateCamera() {
if (!camera) return;
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);
}
function resetCamera() {
cameraState.radius = 8.4;
cameraState.theta = 0.52;
cameraState.phi = 1.12;
cameraState.target.set(0, 1.28, 0);
updateCamera();
invalidate();
}
function zoomBy(amount) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + amount,
5.6,
12
);
updateCamera();
invalidate();
}
function updateLabels(anchors) {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
for (const { element, object } of anchors) {
const world = new THREE.Vector3();
object.getWorldPosition(world);
world.project(camera);
const visible = world.z > -1 && world.z < 1;
element.style.display = visible ? "flex" : "none";
if (visible) {
element.style.left = `${(world.x * 0.5 + 0.5) * width}px`;
element.style.top = `${(-world.y * 0.5 + 0.5) * height}px`;
}
}
}
function invalidate() {
if (frameQueued) return;
frameQueued = true;
requestAnimationFrame(() => {
frameQueued = false;
updateCamera();
renderer.render(scene, camera);
updateLabels(scene.userData.anchors || []);
});
}
function resize() {
if (!renderer) return;
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
invalidate();
}
function setupControls(anchors) {
const canvas = renderer.domElement;
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.theta -= deltaX * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - deltaY * 0.005,
0.55,
1.42
);
updateCamera();
invalidate();
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", event => {
event.preventDefault();
zoomBy(event.deltaY * 0.006);
}, { passive: false });
canvas.addEventListener("keydown", event => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
cameraState.theta += 0.08;
break;
case "ArrowRight":
cameraState.theta -= 0.08;
break;
case "ArrowUp":
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - 0.06, 0.55, 1.42);
break;
case "ArrowDown":
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi + 0.06, 0.55, 1.42);
break;
case "+":
case "=":
zoomBy(-0.6);
break;
case "-":
case "_":
zoomBy(0.6);
break;
case "Home":
resetCamera();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
invalidate();
}
});
document.querySelector("#zoomIn").addEventListener("click", () => zoomBy(-0.65));
document.querySelector("#zoomOut").addEventListener("click", () => zoomBy(0.65));
document.querySelector("#resetView").addEventListener("click", resetCamera);
document.querySelector("#resetCamera").addEventListener("click", resetCamera);
document.querySelectorAll("[data-toggle]").forEach(button => {
button.addEventListener("click", () => {
const cue = button.dataset.toggle;
cueState[cue].active = !cueState[cue].active;
updateUI();
});
});
document.querySelectorAll("[data-cue][data-dir]").forEach(button => {
button.addEventListener("click", () => {
const cue = button.dataset.cue;
cueState[cue].dir = Number(button.dataset.dir);
updateUI();
});
});
document.querySelectorAll("[data-preset]").forEach(button => {
button.addEventListener("click", () => {
const preset = presetDefinitions[button.dataset.preset];
for (const cue of Object.keys(preset)) {
cueState[cue].active = preset[cue].active;
cueState[cue].dir = preset[cue].dir;
}
updateUI();
});
});
const observer = new ResizeObserver(resize);
observer.observe(viewport);
window.addEventListener("resize", resize);
}
try {
const anchors = buildScene();
scene.userData.anchors = anchors;
setupControls(anchors);
resize();
updateUI();
} catch (error) {
console.error(error);
fallback.style.display = "grid";
}
</script>
</body>
</html>
```