Prompt specification
Build or customize the Three.js 3D scene "Balance sensory-integration 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: Balance sensory-integration exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/balance-sensory-integration-exhibit-x1031
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts the vestibular balance system. Compose a stylized person with visual target, foot-contact markers, and inner-ear inset; show that balance combines several signals rather than one isolated sensor. Voxel style.
Working Three.js Starter (balance-sensory-integration-exhibit-x1031):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Vestibular Balance System — Voxel Visualization</title>
<style>
:root {
--bg: #07111f;
--panel: rgba(9, 22, 39, 0.78);
--border: rgba(157, 194, 220, 0.18);
--text: #edf4f2;
--muted: #91a6b8;
--vision: #5ce1e6;
--vestibular: #ffb84d;
--proprioception: #8cf07a;
--fusion: #fff1bd;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app,
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
#world-labels {
position: fixed;
inset: 0;
z-index: 4;
pointer-events: none;
overflow: hidden;
}
.world-label {
--tone: #ffffff;
position: absolute;
display: flex;
align-items: flex-start;
gap: 8px;
min-width: 120px;
padding: 8px 10px;
border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
border-left: 3px solid var(--tone);
border-radius: 4px;
background: rgba(5, 15, 28, 0.83);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(8px);
transform: translate(-50%, -50%);
transition: opacity 160ms ease;
white-space: nowrap;
}
.world-label b {
display: block;
color: var(--tone);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.world-label small {
display: block;
margin-top: 3px;
color: #aebdca;
font-size: 9px;
letter-spacing: 0.025em;
}
.ui {
position: fixed;
z-index: 10;
pointer-events: none;
}
header {
top: 28px;
left: 30px;
max-width: 430px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: var(--vision);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 2px;
content: "";
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
h1 {
margin: 0;
max-width: 390px;
font-size: clamp(34px, 4.5vw, 62px);
font-weight: 760;
line-height: 0.95;
letter-spacing: -0.055em;
text-transform: uppercase;
}
.intro {
max-width: 355px;
margin: 16px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.toolbar {
top: 28px;
right: 28px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 36px;
padding: 0 13px;
border: 1px solid var(--border);
border-radius: 5px;
background: rgba(10, 25, 43, 0.78);
color: #dbe8ed;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover {
border-color: rgba(92, 225, 230, 0.6);
color: var(--vision);
}
.counter {
top: 80px;
right: 30px;
color: #71879a;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
letter-spacing: 0.12em;
text-align: right;
text-transform: uppercase;
}
.counter strong {
color: var(--fusion);
font-size: 16px;
}
.legend {
left: 50%;
bottom: 24px;
display: grid;
grid-template-columns: repeat(3, minmax(145px, 1fr)) 34px minmax(190px, 1.25fr);
align-items: stretch;
width: min(1000px, calc(100vw - 48px));
overflow: hidden;
border: 1px solid var(--border);
border-radius: 8px;
background: rgba(6, 17, 31, 0.84);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(14px);
transform: translateX(-50%);
}
.signal-card {
position: relative;
min-height: 90px;
padding: 14px 16px 13px 19px;
border-right: 1px solid var(--border);
}
.signal-card::before {
position: absolute;
top: 0;
left: 0;
width: 3px;
height: 100%;
content: "";
background: var(--tone);
box-shadow: 0 0 15px color-mix(in srgb, var(--tone) 60%, transparent);
}
.signal-card .index {
color: var(--tone);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
letter-spacing: 0.12em;
}
.signal-card strong {
display: block;
margin-top: 7px;
color: var(--tone);
font-size: 11px;
letter-spacing: 0.075em;
text-transform: uppercase;
}
.signal-card small {
display: block;
margin-top: 5px;
color: #8499aa;
font-size: 10px;
line-height: 1.35;
}
.fusion-arrow {
display: grid;
place-items: center;
color: #62798d;
font-size: 24px;
}
.result-card {
padding: 14px 17px;
background: linear-gradient(
100deg,
rgba(255, 241, 189, 0.045),
rgba(92, 225, 230, 0.025)
);
}
.result-card strong {
display: block;
color: var(--fusion);
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.result-card small {
display: block;
margin-top: 7px;
color: #a6b4bd;
font-size: 10px;
line-height: 1.4;
}
.hint {
left: 28px;
bottom: 130px;
color: #6f879a;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: var(--bg);
color: var(--vision);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
letter-spacing: 0.14em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 820px) {
header {
top: 20px;
left: 20px;
}
h1 {
font-size: 36px;
}
.intro {
display: none;
}
.toolbar {
top: 20px;
right: 18px;
}
.counter,
.hint {
display: none;
}
.legend {
bottom: 14px;
grid-template-columns: repeat(3, 1fr);
width: calc(100vw - 28px);
}
.fusion-arrow {
display: none;
}
.result-card {
grid-column: 1 / -1;
min-height: 62px;
border-top: 1px solid var(--border);
}
.signal-card {
min-height: 84px;
padding: 12px 8px 11px 13px;
}
.signal-card small {
font-size: 9px;
}
}
@media (max-width: 520px) {
.toolbar button {
padding: 0 9px;
font-size: 9px;
}
.world-label {
min-width: 100px;
padding: 6px 8px;
}
.world-label small {
display: none;
}
.legend {
grid-template-columns: 1fr;
}
.signal-card {
min-height: 54px;
padding-left: 15px;
}
.signal-card .index,
.signal-card small {
display: none;
}
.signal-card strong {
margin-top: 3px;
}
}
</style>
</head>
<body>
<main id="app">
<div id="scene"></div>
<div id="world-labels"></div>
<header class="ui">
<div class="eyebrow">Neuroscience / interactive voxel model</div>
<h1>Balance,<br>in context.</h1>
<p class="intro">
The vestibular system does not work alone. The brain combines visual,
inner-ear, and body signals to estimate orientation and correct posture.
</p>
</header>
<div class="toolbar ui">
<button id="pauseButton" type="button">Pause</button>
<button id="labelsButton" type="button">Labels</button>
<button id="resetButton" type="button">Reset view</button>
</div>
<div class="counter ui">
<strong>3</strong> sensory streams<br>
<strong>1</strong> fused posture estimate
</div>
<div class="hint ui">Drag to orbit · Scroll to zoom · Space to pause</div>
<section class="legend ui" aria-label="Signals used for balance">
<article class="signal-card" style="--tone: var(--vision)">
<span class="index">01 / EXTERNAL</span>
<strong>Vision</strong>
<small>Landmarks and optic flow reveal movement.</small>
</article>
<article class="signal-card" style="--tone: var(--vestibular)">
<span class="index">02 / INTERNAL</span>
<strong>Vestibular</strong>
<small>The inner ear detects rotation and gravity.</small>
</article>
<article class="signal-card" style="--tone: var(--proprioception)">
<span class="index">03 / SOMATIC</span>
<strong>Proprioception</strong>
<small>Feet and joints report contact and load.</small>
</article>
<div class="fusion-arrow">→</div>
<article class="result-card">
<strong>Sensor fusion → stable stance</strong>
<small>
Weighted together by the nervous system to predict orientation and
generate small postural corrections.
</small>
</article>
</section>
<div id="loading">Building vestibular model…</div>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const sceneHost = document.querySelector("#scene");
const labelHost = document.querySelector("#world-labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111f);
scene.fog = new THREE.FogExp2(0x07111f, 0.032);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel model of the vestibular balance system"
);
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const palette = {
bg: 0x07111f,
platform: 0x10243a,
platformEdge: 0x24445d,
grid: 0x29465d,
skin: 0xe8aa7b,
skinLight: 0xf3c29a,
shirt: 0x4777ee,
shirtLight: 0x6b98ff,
pants: 0x233854,
shoe: 0x0b1627,
hair: 0x172033,
vision: 0x5ce1e6,
vestibular: 0xffb84d,
proprioception: 0x8cf07a,
fusion: 0xfff1bd,
muted: 0x617b93
};
const hemisphere = new THREE.HemisphereLight(0xc9edff, 0x091222, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(4.5, 8, 6.5);
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 = -4;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x568cff, 1.8);
rimLight.position.set(-5, 4, -5);
scene.add(rimLight);
const targetLight = new THREE.PointLight(palette.vision, 9, 4, 2);
targetLight.position.set(-1.4, 2.8, 1.9);
scene.add(targetLight);
const earLight = new THREE.PointLight(palette.vestibular, 7, 3.5, 2);
earLight.position.set(2.7, 2.4, 0.4);
scene.add(earLight);
// -------------------------------------------------------------------------
// Voxel helpers
// -------------------------------------------------------------------------
function box(
parent,
size,
position,
color,
options = {}
) {
const geometry = new THREE.BoxGeometry(...size);
const material =
options.material ||
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.78,
metalness: options.metalness ?? 0.04,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function basicBox(parent, size, position, color, opacity = 1) {
const material = new THREE.MeshBasicMaterial({
color,
transparent: opacity < 1,
opacity,
depthWrite: opacity > 0.7
});
return box(parent, size, position, color, {
material,
castShadow: false,
receiveShadow: false
});
}
function makeLabel(title, subtitle, anchor, color, offset = [0, 0, 0]) {
const element = document.createElement("div");
element.className = "world-label";
element.style.setProperty("--tone", color);
element.innerHTML = `
<span>
<b>${title}</b>
<small>${subtitle}</small>
</span>
`;
labelHost.appendChild(element);
const label = {
element,
anchor,
offset: new THREE.Vector3(...offset)
};
labels.push(label);
return label;
}
const labels = [];
// -------------------------------------------------------------------------
// Platform
// -------------------------------------------------------------------------
const platform = new THREE.Group();
scene.add(platform);
box(
platform,
[8.1, 0.25, 5.8],
[0.45, -0.43, 0],
0x09182a
);
box(
platform,
[7.6, 0.32, 5.35],
[0.45, -0.18, 0],
palette.platform
);
const gridMaterial = new THREE.MeshBasicMaterial({
color: palette.grid,
transparent: true,
opacity: 0.36
});
for (let x = -3.2; x <= 4.15; x += 0.5) {
box(
platform,
[0.012, 0.008, 5.18],
[x, 0.005, 0],
palette.grid,
{ material: gridMaterial, castShadow: false }
);
}
for (let z = -2.5; z <= 2.5; z += 0.5) {
box(
platform,
[7.42, 0.008, 0.012],
[0.45, 0.006, z],
palette.grid,
{ material: gridMaterial, castShadow: false }
);
}
box(
platform,
[7.65, 0.035, 0.055],
[0.45, 0.025, -2.64],
palette.platformEdge
);
box(
platform,
[7.65, 0.035, 0.055],
[0.45, 0.025, 2.64],
palette.platformEdge
);
box(
platform,
[0.055, 0.035, 5.25],
[-3.34, 0.025, 0],
palette.platformEdge
);
box(
platform,
[0.055, 0.035, 5.25],
[4.24, 0.025, 0],
palette.platformEdge
);
box(
scene,
[40, 0.18, 40],
[0, -0.66, 0],
0x050c17
);
// -------------------------------------------------------------------------
// Voxel person
// -------------------------------------------------------------------------
const person = new THREE.Group();
person.position.set(-1.4, 0, 0);
scene.add(person);
const torso = box(
person,
[0.94, 1.02, 0.52],
[0, 1.92, 0],
palette.shirt
);
box(
person,
[0.98, 0.15, 0.56],
[0, 2.39, 0],
palette.shirtLight
);
box(
person,
[0.86, 0.3, 0.49],
[0, 1.32, 0],
palette.pants
);
// Split legs and block shoes.
for (const side of [-1, 1]) {
box(
person,
[0.31, 0.67, 0.32],
[side * 0.25, 0.99, 0],
palette.pants
);
box(
person,
[0.29, 0.64, 0.31],
[side * 0.25, 0.49, 0.015],
palette.pants
);
box(
person,
[0.39, 0.18, 0.66],
[side * 0.25, 0.13, 0.12],
palette.shoe
);
box(
person,
[0.4, 0.055, 0.67],
[side * 0.25, 0.035, 0.12],
0x263a50
);
}
box(
person,
[0.27, 0.2, 0.28],
[0, 2.54, 0],
palette.skin
);
const head = new THREE.Group();
head.position.set(0, 2.9, 0);
person.add(head);
box(head, [0.7, 0.68, 0.64], [0, 0, 0], palette.skinLight);
box(head, [0.72, 0.19, 0.66], [0, 0.27, -0.015], palette.hair);
box(head, [0.12, 0.32, 0.67], [-0.31, 0.05, -0.015], palette.hair);
box(head, [0.12, 0.32, 0.67], [0.31, 0.05, -0.015], palette.hair);
// Eyes face the visual target.
box(head, [0.09, 0.09, 0.035], [-0.14, 0.055, 0.333], 0x0a1422);
box(head, [0.09, 0.09, 0.035], [0.14, 0.055, 0.333], 0x0a1422);
box(head, [0.07, 0.05, 0.035], [0, -0.09, 0.335], palette.skin, {
castShadow: false
});
// A tiny voxel ear on the side of the head.
box(head, [0.08, 0.16, 0.17], [0.36, 0.01, -0.02], palette.vestibular);
box(head, [0.09, 0.08, 0.08], [0.38, 0.08, -0.03], palette.fusion);
const arms = [];
for (const side of [-1, 1]) {
const arm = new THREE.Group();
arm.position.set(side * 0.61, 2.2, 0);
person.add(arm);
box(arm, [0.23, 0.61, 0.29], [0, -0.27, 0], palette.shirt);
box(arm, [0.21, 0.57, 0.26], [0, -0.81, 0.02], palette.skin);
box(arm, [0.23, 0.19, 0.27], [0, -1.15, 0.03], palette.skinLight);
arm.rotation.z = side * 0.055;
arms.push({ arm, side });
}
// -------------------------------------------------------------------------
// Foot-contact pressure markers
// -------------------------------------------------------------------------
const contactMaterial = new THREE.MeshStandardMaterial({
color: palette.proprioception,
emissive: 0x1b6d47,
emissiveIntensity: 1.1,
transparent: true,
opacity: 0.72,
roughness: 0.55
});
const contactMarkers = [];
for (const side of [-1, 1]) {
for (let ix = -1; ix <= 1; ix++) {
for (let iz = -2; iz <= 2; iz++) {
const marker = box(
person,
[0.095, 0.022, 0.095],
[side * 0.25 + ix * 0.115, 0.018, iz * 0.115],
palette.proprioception,
{
material: contactMaterial,
castShadow: false
}
);
contactMarkers.push({
mesh: marker,
phase: ix * 0.65 + iz * 0.28 + (side > 0 ? 1.2 : 0)
});
}
}
}
// Four brighter corner brackets around each footprint.
for (const side of [-1, 1]) {
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
box(
person,
[0.18, 0.025, 0.025],
[side * 0.25 + sx * 0.36, 0.026, sz * 0.39],
palette.proprioception,
{
material: contactMaterial,
castShadow: false
}
);
box(
person,
[0.025, 0.025, 0.18],
[side * 0.25 + sx * 0.43, 0.026, sz * 0.39],
palette.proprioception,
{
material: contactMaterial,
castShadow: false
}
);
}
}
}
// -------------------------------------------------------------------------
// Visual target
// -------------------------------------------------------------------------
const visualTarget = new THREE.Group();
visualTarget.position.set(-1.4, 2.78, 1.9);
scene.add(visualTarget);
const targetCoreMaterial = new THREE.MeshStandardMaterial({
color: 0xff776b,
emissive: 0xff3e35,
emissiveIntensity: 1.5,
roughness: 0.5
});
const targetCore = box(
visualTarget,
[0.18, 0.18, 0.18],
[0, 0, 0],
0xff776b,
{ material: targetCoreMaterial }
);
const targetHalo = new THREE.Group();
visualTarget.add(targetHalo);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const radius = 0.48;
basicBox(
targetHalo,
[0.075, 0.075, 0.075],
[
Math.cos(angle) * radius,
Math.sin(angle) * radius,
0
],
palette.vision,
0.9
);
}
// Pixelated corner brackets around the target.
for (const sx of [-1, 1]) {
for (const sy of [-1, 1]) {
for (let k = 0; k < 3; k++) {
basicBox(
visualTarget,
[0.12, 0.07, 0.07],
[sx * (0.43 - k * 0.12), sy * 0.43, 0],
palette.vision,
0.9
);
basicBox(
visualTarget,
[0.07, 0.12, 0.07],
[sx * 0.43, sy * (0.43 - k * 0.12), 0],
palette.vision,
0.9
);
}
}
}
// -------------------------------------------------------------------------
// Inner-ear inset
// -------------------------------------------------------------------------
const earPanel = new THREE.Group();
earPanel.position.set(3.05, 2.12, -0.15);
scene.add(earPanel);
box(
earPanel,
[2.62, 3.18, 0.16],
[0, 0, -0.08],
0x0a192b,
{ roughness: 0.9 }
);
// Panel frame.
box(earPanel, [2.65, 0.07, 0.10], [0, 1.56, 0.05], 0x36566f);
box(earPanel, [2.65, 0.07, 0.10], [0, -1.56, 0.05], 0x36566f);
box(earPanel, [0.07, 3.12, 0.10], [-1.29, 0, 0.05], 0x36566f);
box(earPanel, [0.07, 3.12, 0.10], [1.29, 0, 0.05], 0x36566f);
// Small inset grid.
for (let x = -1; x <= 1; x++) {
basicBox(
earPanel,
[0.009, 2.9, 0.008],
[x * 0.42, 0, 0.015],
0x27435a,
0.45
);
}
for (let y = -1; y <= 1; y++) {
basicBox(
earPanel,
[2.35, 0.009, 0.008],
[0, y * 0.42, 0.015],
0x27435a,
0.45
);
}
const canals = [];
function createCanal(points, color) {
const canalGroup = new THREE.Group();
earPanel.add(canalGroup);
const material = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.28,
roughness: 0.62
});
const positions = [];
points.forEach((point, index) => {
positions.push(new THREE.Vector3(...point));
box(
canalGroup,
[0.115, 0.115, 0.115],
point,
color,
{ material, roughness: 0.62 }
);
if (index % 2 === 0) {
box(
canalGroup,
[0.075, 0.075, 0.075],
[
point[0],
point[1],
point[2] + 0.035
],
palette.fusion,
{ castShadow: false }
);
}
});
const highlight = basicBox(
canalGroup,
[0.15, 0.15, 0.15],
positions[0],
0xffffff
);
canals.push({ positions, highlight, offset: canals.length * 0.27 });
}
const canalXY = [];
const canalXZ = [];
const canalYZ = [];
for (let i = 0; i < 24; i++) {
const a = (i / 24) * Math.PI * 2;
canalXY.push([
-0.33 + Math.cos(a) * 0.61,
0.38 + Math.sin(a) * 0.55,
0.11
]);
canalXZ.push([
-0.33 + Math.cos(a) * 0.55,
0.25,
0.11 + Math.sin(a) * 0.43
]);
canalYZ.push([
-0.33,
0.38 + Math.sin(a) * 0.51,
0.11 + Math.cos(a) * 0.43
]);
}
createCanal(canalXY, palette.vestibular);
createCanal(canalXZ, 0xffd16b);
createCanal(canalYZ, 0xff9d42);
// Voxel otolith organs beneath the canals.
for (const side of [-1, 1]) {
box(
earPanel,
[0.32, 0.22, 0.18],
[-0.33 + side * 0.31, -0.93, 0.12],
0xff657d,
{ emissive: 0x7b1d36, emissiveIntensity: 0.45 }
);
box(
earPanel,
[0.17, 0.14, 0.14],
[-0.33 + side * 0.31, -1.13, 0.12],
0xd94565
);
box(
earPanel,
[0.09, 0.09, 0.09],
[-0.33 + side * 0.31, -1.25, 0.12],
palette.fusion
);
}
// A highlighted signal source within the inset.
const earSourceAnchor = new THREE.Object3D();
earSourceAnchor.position.set(-0.33, 0.38, 0.24);
earPanel.add(earSourceAnchor);
basicBox(
earPanel,
[0.16, 0.16, 0.16],
[-0.33, 0.38, 0.22],
0xffffff
);
// -------------------------------------------------------------------------
// Multisensor fusion hub
// -------------------------------------------------------------------------
const hubPosition = new THREE.Vector3(-1.4, 2.22, 0.72);
const fusionHub = new THREE.Group();
fusionHub.position.copy(hubPosition);
scene.add(fusionHub);
const hubCore = box(
fusionHub,
[0.25, 0.25, 0.25],
[0, 0, 0],
palette.fusion,
{
emissive: 0xffd873,
emissiveIntensity: 1.2,
roughness: 0.45
}
);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
basicBox(
fusionHub,
[0.075, 0.075, 0.075],
[
Math.cos(angle) * 0.37,
Math.sin(angle) * 0.37,
0
],
palette.fusion,
0.7
);
}
const visionInput = basicBox(
fusionHub,
[0.13, 0.13, 0.13],
[0, 0.34, 0.05],
palette.vision
);
const vestibularInput = basicBox(
fusionHub,
[0.13, 0.13, 0.13],
[0.34, -0.03, 0.05],
palette.vestibular
);
const proprioInput = basicBox(
fusionHub,
[0.13, 0.13, 0.13],
[-0.34, -0.03, 0.05],
palette.proprioception
);
// -------------------------------------------------------------------------
// Dotted voxel signal paths
// -------------------------------------------------------------------------
function makeDottedPath(
points,
color,
{
count = 30,
opacity = 0.36,
pulse = true,
pulseSpeed = 0.19,
pulseOffset = 0,
size = 0.055
} = {}
) {
const curve = new THREE.CatmullRomCurve3(
points.map((point) =>
point instanceof THREE.Vector3
? point.clone()
: new THREE.Vector3(...point)
),
false,
"catmullrom",
0.35
);
const group = new THREE.Group();
scene.add(group);
const dotMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthWrite: false
});
const dotGeometry = new THREE.BoxGeometry(size, size, size);
for (let i = 0; i < count; i++) {
const dot = new THREE.Mesh(dotGeometry, dotMaterial);
dot.position.copy(curve.getPointAt(i / (count - 1)));
group.add(dot);
}
let pulseMesh = null;
if (pulse) {
pulseMesh = new THREE.Mesh(
new THREE.BoxGeometry(size * 2.25, size * 2.25, size * 2.25),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.95,
depthWrite: false
})
);
group.add(pulseMesh);
}
return {
curve,
pulse: pulseMesh,
speed: pulseSpeed,
offset: pulseOffset
};
}
// Visual signal: target -> brain.
const visionPath = makeDottedPath(
[
[-1.4, 2.78, 1.9],
[-1.4, 2.84, 1.33],
[-1.4, 2.55, 0.98],
hubPosition
],
palette.vision,
{ count: 32, pulseSpeed: 0.2 }
);
// Gaze connection from the eyes to the target.
makeDottedPath(
[
[-1.54, 2.96, 0.34],
[-1.53, 2.9, 0.85],
[-1.48, 2.83, 1.4],
[-1.4, 2.78, 1.9]
],
palette.vision,
{
count: 18,
opacity: 0.2,
pulseSpeed: 0.25,
size: 0.035
}
);
// Vestibular signal: inner-ear inset -> brain.
const vestibularPath = makeDottedPath(
[
[2.72, 2.5, 0.09],
[2.0, 2.92, 0.42],
[0.35, 2.75, 0.82],
hubPosition
],
palette.vestibular,
{
count: 38,
pulseSpeed: 0.16,
pulseOffset: 0.22
}
);
// Somatosensory signals from both loaded feet.
const leftFootPath = makeDottedPath(
[
[-1.65, 0.11, 0.08],
[-1.93, 0.92, 0.34],
[-1.62, 1.77, 0.62],
hubPosition
],
palette.proprioception,
{
count: 30,
pulseSpeed: 0.2,
pulseOffset: 0.12
}
);
const rightFootPath = makeDottedPath(
[
[-1.15, 0.11, 0.08],
[-0.91, 0.94, 0.35],
[-1.15, 1.78, 0.63],
hubPosition
],
palette.proprioception,
{
count: 30,
pulseSpeed: 0.2,
pulseOffset: 0.57
}
);
// The fused estimate produces a postural correction down the body.
makeDottedPath(
[
hubPosition,
[-1.4, 1.72, 0.47],
[-1.4, 0.65, 0.32],
[-1.4, 0.18, 0.2]
],
palette.fusion,
{
count: 24,
opacity: 0.25,
pulseSpeed: 0.14,
size: 0.045
}
);
// Dashed anatomical callout line from the head to the magnified inset.
makeDottedPath(
[
[-1.02, 2.95, 0.02],
[-0.45, 3.25, 0.02],
[0.6, 3.23, 0.02],
[1.73, 2.84, 0.02]
],
palette.muted,
{
count: 24,
opacity: 0.42,
pulse: false,
size: 0.045
}
);
// -------------------------------------------------------------------------
// World-space labels
// -------------------------------------------------------------------------
makeLabel(
"Visual target",
"Vision / optic flow",
visualTarget,
"#5ce1e6",
[0, 0.72, 0]
);
const footLabelAnchor = new THREE.Object3D();
footLabelAnchor.position.set(-0.88, 0.08, 0.62);
scene.add(footLabelAnchor);
makeLabel(
"Foot contact",
"Pressure / joint position",
footLabelAnchor,
"#8cf07a",
[0.2, -0.03, 0]
);
const panelLabelAnchor = new THREE.Object3D();
panelLabelAnchor.position.set(0, 1.78, 0.12);
earPanel.add(panelLabelAnchor);
makeLabel(
"Inner ear / magnified",
"Rotation + gravity",
panelLabelAnchor,
"#ffb84d",
[0, 0.16, 0]
);
const hubLabelAnchor = new THREE.Object3D();
hubLabelAnchor.position.set(0, 0, 0.18);
fusionHub.add(hubLabelAnchor);
makeLabel(
"Integration hub",
"Vision + vestibular + body",
hubLabelAnchor,
"#fff1bd",
[0.28, 0.43, 0]
);
// -------------------------------------------------------------------------
// Ambient voxel particles
// -------------------------------------------------------------------------
let randomSeed = 13;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
const starGeometry = new THREE.BoxGeometry(0.045, 0.045, 0.045);
const starMaterial = new THREE.MeshBasicMaterial({
color: 0x36536c,
transparent: true,
opacity: 0.48
});
for (let i = 0; i < 90; i++) {
const star = new THREE.Mesh(starGeometry, starMaterial);
star.position.set(
-9 + random() * 18,
0.5 + random() * 8,
-3 - random() * 9
);
const size = 0.5 + random() * 1.8;
star.scale.setScalar(size);
scene.add(star);
}
// -------------------------------------------------------------------------
// Direct camera controls: no Three.js addons
// -------------------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0.35, 1.65, 0.2),
radius: 9.2,
theta: 0.47,
phi: 1.13
};
const defaultCamera = { ...cameraState, target: cameraState.target.clone() };
function updateCamera() {
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);
}
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.58,
1.46
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
6.8,
14
);
},
{ passive: false }
);
function resetView() {
cameraState.target.copy(defaultCamera.target);
cameraState.radius = defaultCamera.radius;
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
}
// -------------------------------------------------------------------------
// UI controls
// -------------------------------------------------------------------------
let paused = false;
let labelsVisible = true;
const pauseButton = document.querySelector("#pauseButton");
const labelsButton = document.querySelector("#labelsButton");
const resetButton = document.querySelector("#resetButton");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
labelsButton.addEventListener("click", () => {
labelsVisible = !labelsVisible;
labelHost.style.display = labelsVisible ? "block" : "none";
labelsButton.textContent = labelsVisible ? "Labels" : "Show labels";
});
resetButton.addEventListener("click", resetView);
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
if (event.key.toLowerCase() === "r") {
resetView();
}
if (event.key.toLowerCase() === "l") {
labelsButton.click();
}
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animatePath(path) {
if (!path.pulse) return;
const t = (elapsed * path.speed + path.offset) % 1;
path.pulse.position.copy(path.curve.getPointAt(t));
const pulse = 0.8 + Math.sin(t * Math.PI * 2) * 0.18;
path.pulse.scale.setScalar(pulse);
path.pulse.rotation.x = t * Math.PI * 2;
path.pulse.rotation.y = t * Math.PI;
}
function updateLabels() {
const projected = new THREE.Vector3();
for (const label of labels) {
label.anchor.getWorldPosition(projected);
projected.add(label.offset);
projected.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.opacity = visible ? "1" : "0";
label.element.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
label.element.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
}
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) {
elapsed += delta;
// Small involuntary sway and compensatory arm movement.
person.rotation.z = Math.sin(elapsed * 1.15) * 0.018;
person.rotation.x = Math.sin(elapsed * 0.72) * 0.007;
arms[0].arm.rotation.z =
0.055 + Math.sin(elapsed * 1.15 + 0.2) * 0.035;
arms[1].arm.rotation.z =
-0.055 - Math.sin(elapsed * 1.15 + 0.2) * 0.035;
head.rotation.y = Math.sin(elapsed * 0.48) * 0.025;
// Target pulse.
const targetPulse = 1 + Math.sin(elapsed * 2.7) * 0.12;
targetCore.scale.setScalar(targetPulse);
targetHalo.rotation.z = elapsed * 0.23;
targetLight.intensity = 8 + Math.sin(elapsed * 2.7) * 1.8;
// Pressure-marker breathing.
contactMaterial.emissiveIntensity =
0.9 + Math.sin(elapsed * 3.1) * 0.38;
for (const marker of contactMarkers) {
const pulse = 0.88 + Math.sin(elapsed * 3.1 + marker.phase) * 0.15;
marker.mesh.scale.set(pulse, 0.9 + pulse * 0.25, pulse);
}
// Fusion hub pulse.
const hubPulse = 1 + Math.sin(elapsed * 2.1) * 0.075;
hubCore.scale.setScalar(hubPulse);
visionInput.scale.setScalar(1 + Math.sin(elapsed * 3) * 0.12);
vestibularInput.scale.setScalar(1 + Math.sin(elapsed * 3 + 2) * 0.12);
proprioInput.scale.setScalar(1 + Math.sin(elapsed * 3 + 4) * 0.12);
// Moving highlights inside the three orthogonal canals.
for (const canal of canals) {
const index =
Math.floor(
(elapsed * 0.34 + canal.offset) % 1 * canal.positions.length
);
canal.highlight.position.copy(canal.positions[index]);
canal.highlight.scale.setScalar(
0.8 + Math.sin(elapsed * 5 + canal.offset * 10) * 0.16
);
}
animatePath(visionPath);
animatePath(vestibularPath);
animatePath(leftFootPath);
animatePath(rightFootPath);
}
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```