Prompt specification
Build or customize the Three.js 3D scene "Parcel Moved While One Observer Turns Away" 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: Parcel Moved While One Observer Turns Away
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/parcel-moved-while-one-observer-turns-away-x3750
Scene Description Prompt:
Parcel moved while one observer turns away. Animate a fictional parcel relocation with one character's view blocked. Show observable events for each character without claiming the animation reveals their actual beliefs. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (parcel-moved-while-one-observer-turns-away-x3750):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Voxel Parcel Relay — Observable Events</title>
<style>
:root {
color-scheme: dark;
--bg: #08111f;
--panel: rgba(12, 23, 40, 0.88);
--border: rgba(167, 195, 224, 0.2);
--text: #edf6ff;
--muted: #94abc2;
--cyan: #63dcff;
--green: #58e6aa;
--amber: #ffc857;
--red: #ff5d78;
}
* { 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;
}
#scene {
display: block;
width: 100vw;
height: 100vh;
touch-action: none;
}
.glass {
background: var(--panel);
border: 1px solid var(--border);
box-shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
}
header {
position: fixed;
z-index: 5;
top: 18px;
left: 18px;
max-width: 440px;
padding: 15px 17px;
border-radius: 16px;
pointer-events: none;
}
.eyebrow {
color: var(--cyan);
font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 7px 0 5px;
font-size: clamp(20px, 2.5vw, 30px);
line-height: 1.05;
letter-spacing: -0.035em;
}
header p {
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
#panel {
position: fixed;
z-index: 6;
top: 18px;
right: 18px;
width: min(390px, calc(100vw - 36px));
max-height: calc(100vh - 116px);
overflow: auto;
padding: 15px;
border-radius: 18px;
scrollbar-width: thin;
scrollbar-color: #37516e transparent;
}
.scope {
padding: 11px 12px;
border: 1px solid rgba(255, 200, 87, 0.24);
border-radius: 12px;
background: rgba(255, 200, 87, 0.06);
color: #d9e6f3;
font-size: 12px;
line-height: 1.45;
}
.scope strong { color: var(--amber); }
.status-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-top: 10px;
}
.person-card {
min-width: 0;
padding: 11px;
border-radius: 12px;
background: rgba(255, 255, 255, 0.035);
border: 1px solid rgba(255, 255, 255, 0.075);
}
.person-name {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 8px;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 2px;
}
.mira-dot { background: var(--cyan); }
.nico-dot { background: #ff9a62; }
.status-pill {
display: inline-block;
max-width: 100%;
padding: 5px 7px;
border-radius: 7px;
font: 800 10px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.035em;
}
.status-green {
color: var(--green);
background: rgba(88, 230, 170, 0.12);
}
.status-amber {
color: var(--amber);
background: rgba(255, 200, 87, 0.12);
}
.status-red {
color: var(--red);
background: rgba(255, 93, 120, 0.13);
}
.status-blue {
color: var(--cyan);
background: rgba(99, 220, 255, 0.12);
}
.status-detail {
min-height: 34px;
margin-top: 8px;
color: var(--muted);
font-size: 11px;
line-height: 1.4;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 12px;
margin: 11px 2px 13px;
color: var(--muted);
font-size: 10px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 5px;
}
.line-key {
width: 17px;
height: 2px;
border-radius: 2px;
}
.event-heading {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 10px;
margin: 12px 2px 7px;
}
.event-heading h2 {
margin: 0;
font-size: 13px;
letter-spacing: 0.02em;
}
.event-heading small {
color: var(--muted);
font-size: 10px;
}
.events {
display: grid;
gap: 6px;
}
.event {
display: grid;
grid-template-columns: 48px 1fr;
gap: 8px;
padding: 8px 9px;
border-radius: 9px;
border: 1px solid transparent;
background: rgba(255, 255, 255, 0.025);
font-size: 11px;
line-height: 1.38;
transition: opacity 160ms, border-color 160ms, background 160ms;
}
.event time {
color: var(--cyan);
font: 700 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.event.future {
opacity: 0.3;
}
.event.done {
border-color: rgba(99, 220, 255, 0.12);
background: rgba(99, 220, 255, 0.035);
}
#timeline {
position: fixed;
z-index: 7;
left: 18px;
right: 18px;
bottom: 18px;
display: grid;
grid-template-columns: auto minmax(150px, 1fr) auto auto auto;
align-items: center;
gap: 10px;
padding: 11px 13px;
border-radius: 15px;
}
button, select {
appearance: none;
border: 1px solid rgba(170, 205, 235, 0.2);
border-radius: 9px;
background: rgba(255, 255, 255, 0.055);
color: var(--text);
padding: 8px 10px;
font: 700 11px/1 ui-sans-serif, system-ui, sans-serif;
cursor: pointer;
}
button:hover, select:hover {
background: rgba(99, 220, 255, 0.11);
border-color: rgba(99, 220, 255, 0.35);
}
button.primary {
color: #06121e;
background: var(--cyan);
border-color: transparent;
min-width: 66px;
}
button[aria-pressed="true"] {
color: var(--cyan);
border-color: rgba(99, 220, 255, 0.42);
background: rgba(99, 220, 255, 0.09);
}
input[type="range"] {
width: 100%;
accent-color: var(--cyan);
cursor: pointer;
}
#clock {
min-width: 94px;
color: #c9dceb;
font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
text-align: center;
}
#camera-help {
position: fixed;
z-index: 4;
left: 20px;
bottom: 84px;
padding: 7px 9px;
border-radius: 8px;
color: rgba(224, 239, 252, 0.7);
background: rgba(5, 13, 24, 0.55);
font: 10px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
pointer-events: none;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: var(--bg);
color: var(--cyan);
font: 700 13px/1 ui-monospace, monospace;
letter-spacing: 0.12em;
}
@media (max-width: 820px) {
header {
top: 10px;
left: 10px;
right: 10px;
max-width: none;
padding: 11px 13px;
}
header p { display: none; }
#panel {
top: 83px;
right: 10px;
width: min(350px, calc(100vw - 20px));
max-height: calc(100vh - 175px);
}
#timeline {
left: 10px;
right: 10px;
bottom: 10px;
grid-template-columns: auto 1fr auto;
}
#timeline .secondary,
#speed,
#camera-help {
display: none;
}
}
@media (max-width: 480px) {
.status-grid {
grid-template-columns: 1fr;
}
#panel {
width: calc(100vw - 20px);
}
#clock {
display: none;
}
#timeline {
grid-template-columns: auto 1fr;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Animated voxel scene of a parcel being relocated"></canvas>
<header class="glass">
<div class="eyebrow">Geometric observation study</div>
<h1>Voxel Parcel Relay</h1>
<p>Mira turns away while Nico carries the parcel around a block partition.</p>
</header>
<aside id="panel" class="glass">
<div class="scope">
<strong>Observable events only.</strong>
Body poses, parcel coordinates, directional arcs, and line-segment
intersections are shown. The animation makes no claim about what either
character perceives, knows, intends, or believes.
</div>
<div class="status-grid">
<article class="person-card">
<div class="person-name">
<span class="dot mira-dot"></span>
Mira · pose + sightline
</div>
<div id="mira-status" class="status-pill status-green">CLEAR IN ARC</div>
<div id="mira-detail" class="status-detail"></div>
</article>
<article class="person-card">
<div class="person-name">
<span class="dot nico-dot"></span>
Nico · carry + parcel
</div>
<div id="nico-status" class="status-pill status-blue">CLEAR IN ARC</div>
<div id="nico-detail" class="status-detail"></div>
</article>
</div>
<div class="legend">
<span><i class="line-key" style="background:#58e6aa"></i>clear in arc</span>
<span><i class="line-key" style="background:#ffc857"></i>outside arc</span>
<span><i class="line-key" style="background:#ff5d78"></i>partition intersects</span>
<span><i class="line-key" style="background:#63dcff"></i>Nico head-to-parcel</span>
</div>
<div class="event-heading">
<h2>Mira event stream</h2>
<small>dim = not yet reached</small>
</div>
<div id="mira-events" class="events"></div>
<div class="event-heading">
<h2>Nico event stream</h2>
<small>position / contact / route</small>
</div>
<div id="nico-events" class="events"></div>
</aside>
<div id="camera-help">
drag: orbit · wheel: zoom · right-drag: pan
</div>
<div id="timeline" class="glass">
<button id="play" class="primary" type="button">Pause</button>
<input id="scrub" type="range" min="0" max="8.4" step="0.01" value="0" aria-label="Animation timeline" />
<div id="clock">0.00 / 8.40 s</div>
<button id="replay" class="secondary" type="button">Replay</button>
<button id="sight-toggle" class="secondary" type="button" aria-pressed="true">Sight lines</button>
<select id="speed" class="secondary" aria-label="Playback speed">
<option value="0.5">0.5×</option>
<option value="1" selected>1×</option>
<option value="1.5">1.5×</option>
</select>
<button id="reset-camera" class="secondary" type="button">Reset view</button>
<button id="top-view" class="secondary" type="button">Top view</button>
</div>
<div id="loading">LOADING VOXEL SCENE</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, scene, camera, and direct (non-addon) camera controls.
// ---------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x08111f);
scene.fog = new THREE.Fog(0x08111f, 23, 43);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraState = {
theta: 0.72,
phi: 0.83,
radius: 18,
target: new THREE.Vector3(0, 0.75, 0)
};
function applyCamera() {
const { theta, phi, radius, target } = cameraState;
const horizontal = Math.sin(phi) * radius;
camera.position.set(
target.x + horizontal * Math.sin(theta),
target.y + Math.cos(phi) * radius,
target.z + horizontal * Math.cos(theta)
);
camera.lookAt(target);
}
applyCamera();
let dragging = false;
let dragButton = 0;
let lastPointerX = 0;
let lastPointerY = 0;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
dragButton = event.button;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
if (dragButton === 2) {
const scale = cameraState.radius * 0.0014;
const c = Math.cos(cameraState.theta);
const s = Math.sin(cameraState.theta);
cameraState.target.x += (-dx * c + dy * s) * scale;
cameraState.target.z += (dx * s + dy * c) * scale;
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.12,
1.38
);
}
applyCamera();
});
function endDrag(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
9.5,
29
);
applyCamera();
}, { passive: false });
// ---------------------------------------------------------------------
// Lighting.
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xb9ddff, 0x172033, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d8, 3.2);
sun.position.set(7, 14, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -12;
sun.shadow.camera.right = 12;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00025;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x5ab8ff, 1.25);
rim.position.set(-8, 7, -9);
scene.add(rim);
// ---------------------------------------------------------------------
// Shared voxel construction helpers.
// ---------------------------------------------------------------------
const unitCube = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0.02
})
);
}
return materialCache.get(color);
}
function block(parent, sx, sy, sz, x, y, z, color, castShadow = true) {
const mesh = new THREE.Mesh(unitCube, material(color));
mesh.scale.set(sx, sy, sz);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function labelSprite(text, color = "#dff7ff", width = 2.0) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 128;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 512, 128);
ctx.fillStyle = "rgba(5, 13, 24, 0.86)";
ctx.fillRect(12, 20, 488, 88);
ctx.strokeStyle = color;
ctx.lineWidth = 5;
ctx.strokeRect(12, 20, 488, 88);
ctx.fillStyle = color;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "700 50px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText(text, 256, 65);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 20;
return sprite;
}
// ---------------------------------------------------------------------
// Voxel floor and environment.
// ---------------------------------------------------------------------
const floorGeometry = new THREE.BoxGeometry(0.96, 0.34, 0.96);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.95
});
const floor = new THREE.InstancedMesh(floorGeometry, floorMaterial, 225);
floor.receiveShadow = true;
const matrix = new THREE.Matrix4();
const color = new THREE.Color();
let floorIndex = 0;
for (let x = -7; x <= 7; x++) {
for (let z = -7; z <= 7; z++) {
matrix.makeTranslation(x, -0.17, z);
floor.setMatrixAt(floorIndex, matrix);
const checker = (x + z) & 1;
color.setHex(checker ? 0x182b3d : 0x20364a);
floor.setColorAt(floorIndex, color);
floorIndex++;
}
}
scene.add(floor);
// Low perimeter blocks leave the scene readable from all camera angles.
for (let i = -7; i <= 7; i++) {
block(scene, 0.72, 0.55, 0.72, i, 0.275, -7.25, 0x284259);
block(scene, 0.72, 0.55, 0.72, i, 0.275, 7.25, 0x284259);
block(scene, 0.72, 0.55, 0.72, -7.25, 0.275, i, 0x284259);
block(scene, 0.72, 0.55, 0.72, 7.25, 0.275, i, 0x284259);
}
// The partition is a solid stack of visible voxel blocks.
const WALL_MIN = new THREE.Vector3(0.10, 0.00, -2.00);
const WALL_MAX = new THREE.Vector3(0.60, 2.50, 5.00);
for (let z = -1.75; z <= 4.76; z += 0.5) {
for (let level = 0; level < 5; level++) {
const topBand = level === 4;
block(
scene,
0.50,
0.50,
0.50,
0.35,
0.25 + level * 0.5,
z,
topBand ? 0x42637d : ((level + Math.round(z * 2)) % 2 ? 0x36526c : 0x304a63)
);
}
}
const partitionLabel = labelSprite("PARTITION", "#b8d8f1", 1.75);
partitionLabel.position.set(0.35, 2.88, 1.2);
scene.add(partitionLabel);
// Decorative voxel corner stacks.
for (const x of [-6.4, 6.4]) {
for (const z of [-6.4, 6.4]) {
for (let y = 0; y < 3; y++) {
block(scene, 0.62, 0.48, 0.62, x, 0.24 + y * 0.48, z,
y % 2 ? 0x31536b : 0x25445c);
}
}
}
// ---------------------------------------------------------------------
// Fixed world coordinates.
// ---------------------------------------------------------------------
const PARCEL_START = new THREE.Vector2(-2.90, 1.40);
const PARCEL_END = new THREE.Vector2(3.40, -1.50);
const MIRA_POSITION = new THREE.Vector3(-4.80, 0, 3.40);
const NICO_START = new THREE.Vector3(-4.60, 0, 2.80);
const FOV_DEGREES = 100;
const FOV_RADIANS = THREE.MathUtils.degToRad(FOV_DEGREES);
const DURATION = 8.4;
const REST_Y = 0.98;
const CARRY_Y = 1.15;
function makeStand(x, z, color) {
block(scene, 1.45, 0.20, 1.45, x, 0.10, z, 0x24384d);
block(scene, 1.15, 0.40, 1.15, x, 0.40, z, color);
block(scene, 0.72, 0.04, 0.72, x, 0.62, z, 0xc9b47d, false);
}
makeStand(PARCEL_START.x, PARCEL_START.y, 0x526b7d);
makeStand(PARCEL_END.x, PARCEL_END.y, 0x526b7d);
const sourceLabel = labelSprite("SOURCE", "#d9c38d", 1.45);
sourceLabel.position.set(PARCEL_START.x, 0.90, PARCEL_START.y + 0.75);
scene.add(sourceLabel);
const destinationLabel = labelSprite("DESTINATION", "#d9c38d", 1.7);
destinationLabel.position.set(PARCEL_END.x, 0.90, PARCEL_END.y + 0.82);
scene.add(destinationLabel);
// ---------------------------------------------------------------------
// Parcel: eight visibly separated cubic blocks plus block-like tape.
// ---------------------------------------------------------------------
const parcel = new THREE.Group();
for (let x = 0; x < 2; x++) {
for (let y = 0; y < 2; y++) {
for (let z = 0; z < 2; z++) {
const shades = [0xc99a5b, 0xb98345, 0xd6aa6d];
const shade = shades[(x + y + z) % shades.length];
block(
parcel,
0.36,
0.36,
0.36,
(x - 0.5) * 0.38,
(y - 0.5) * 0.38,
(z - 0.5) * 0.38,
shade
);
}
}
}
block(parcel, 0.12, 0.78, 0.78, 0, 0, 0, 0xe7d4a2);
block(parcel, 0.78, 0.10, 0.78, 0, 0.38, 0, 0xe7d4a2);
block(parcel, 0.18, 0.16, 0.18, 0, 0.46, 0, 0x9f6935);
const parcelLabel = labelSprite("PARCEL", "#ffe2a7", 1.45);
parcelLabel.position.set(0, 0.83, 0);
parcel.add(parcelLabel);
scene.add(parcel);
// ---------------------------------------------------------------------
// Voxel characters.
// ---------------------------------------------------------------------
function createCharacter(name, accent, skin = 0xd7a87f) {
const root = new THREE.Group();
const torso = block(root, 0.62, 0.70, 0.38, 0, 0.90, 0, accent);
block(root, 0.66, 0.12, 0.42, 0, 0.69, 0, 0x263a50);
const headPivot = new THREE.Group();
headPivot.position.set(0, 1.28, 0);
root.add(headPivot);
block(headPivot, 0.52, 0.50, 0.48, 0, 0.25, 0, skin);
block(headPivot, 0.10, 0.09, 0.035, -0.12, 0.29, 0.252, 0x122030);
block(headPivot, 0.10, 0.09, 0.035, 0.12, 0.29, 0.252, 0x122030);
block(headPivot, 0.17, 0.05, 0.035, 0, 0.12, 0.252, 0x7a4e41);
const legPivots = [];
for (const x of [-0.17, 0.17]) {
const pivot = new THREE.Group();
pivot.position.set(x, 0.55, 0);
root.add(pivot);
block(pivot, 0.26, 0.50, 0.30, 0, -0.25, 0, 0x233449);
block(pivot, 0.29, 0.12, 0.40, 0, -0.48, 0.07, 0x111c2a);
legPivots.push(pivot);
}
const armPivots = [];
for (const x of [-0.42, 0.42]) {
const pivot = new THREE.Group();
pivot.position.set(x, 1.13, 0);
root.add(pivot);
block(pivot, 0.20, 0.50, 0.22, 0, -0.25, 0, accent);
block(pivot, 0.22, 0.15, 0.23, 0, -0.53, 0, skin);
armPivots.push(pivot);
}
const label = labelSprite(name, name === "MIRA" ? "#7ce7ff" : "#ffb083", 1.45);
label.position.set(0, 2.16, 0);
root.add(label);
scene.add(root);
return { root, torso, headPivot, legPivots, armPivots };
}
const mira = createCharacter("MIRA", 0x2e91aa, 0xe0b58f);
const nico = createCharacter("NICO", 0xd87542, 0x9b654d);
mira.root.position.copy(MIRA_POSITION);
nico.root.position.copy(NICO_START);
// A directional, ground-level arc. It communicates heading only,
// not distance, attention, perception, or belief.
function createFieldWedge(fovRadians, radius) {
const vertices = [];
const half = fovRadians * 0.5;
const segments = 36;
for (let i = 0; i < segments; i++) {
const a = -half + (i / segments) * fovRadians;
const b = -half + ((i + 1) / segments) * fovRadians;
vertices.push(
0, 0, 0,
Math.sin(a) * radius, 0, Math.cos(a) * radius,
Math.sin(b) * radius, 0, Math.cos(b) * radius
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
const mesh = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color: 0x63dcff,
transparent: true,
opacity: 0.065,
depthWrite: false,
side: THREE.DoubleSide
})
);
mesh.position.y = 0.025;
mesh.renderOrder = 2;
return mesh;
}
mira.root.add(createFieldWedge(FOV_RADIANS, 6.1));
// ---------------------------------------------------------------------
// Route and deterministic animation state.
// ---------------------------------------------------------------------
const route = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(PARCEL_START.x, CARRY_Y, PARCEL_START.y),
new THREE.Vector3(-1.40, CARRY_Y, 1.25),
new THREE.Vector3(-0.40, CARRY_Y, 4.85),
new THREE.Vector3(1.05, CARRY_Y, 5.45),
new THREE.Vector3(2.60, CARRY_Y, 2.60),
new THREE.Vector3(PARCEL_END.x, CARRY_Y, PARCEL_END.y)
],
false,
"centripetal",
0.5
);
const startTangent = route.getTangentAt(0).normalize();
const endTangent = route.getTangentAt(1).normalize();
const pickupRoot = new THREE.Vector3(
PARCEL_START.x - startTangent.x * 0.92,
0,
PARCEL_START.y - startTangent.z * 0.92
);
const releaseRoot = new THREE.Vector3(
PARCEL_END.x - endTangent.x * 0.92,
0,
PARCEL_END.y - endTangent.z * 0.92
);
const releaseSide = new THREE.Vector3(endTangent.z, 0, -endTangent.x);
const initialMiraYaw = Math.atan2(
PARCEL_START.x - MIRA_POSITION.x,
PARCEL_START.y - MIRA_POSITION.z
);
const startNicoYaw = Math.atan2(startTangent.x, startTangent.z);
const endNicoYaw = Math.atan2(endTangent.x, endTangent.z);
function clamp01(value) {
return THREE.MathUtils.clamp(value, 0, 1);
}
function smooth(value) {
const x = clamp01(value);
return x * x * (3 - 2 * x);
}
function smoother(value) {
const x = clamp01(value);
return x * x * x * (x * (x * 6 - 15) + 10);
}
function stateAt(time) {
const state = {
parcel: new THREE.Vector3(),
mover: new THREE.Vector3(),
moverYaw: startNicoYaw,
observerYaw: initialMiraYaw,
armCarry: 0,
walk: 0
};
if (time < 1.2) {
const q = smoother(time / 1.2);
state.mover.lerpVectors(NICO_START, pickupRoot, q);
state.moverYaw = startNicoYaw;
state.parcel.set(PARCEL_START.x, REST_Y, PARCEL_START.y);
state.walk = Math.sin(time * 9) * (1 - q);
} else if (time < 1.8) {
const q = smoother((time - 1.2) / 0.6);
state.mover.copy(pickupRoot);
state.moverYaw = startNicoYaw;
state.parcel.set(
PARCEL_START.x,
THREE.MathUtils.lerp(REST_Y, CARRY_Y, q),
PARCEL_START.y
);
state.armCarry = smoother((time - 1.2) / 0.34);
} else if (time < 6.7) {
const u = clamp01((time - 1.8) / 4.9);
const tangent = route.getTangentAt(u).normalize();
route.getPointAt(u, state.parcel);
state.mover.set(
state.parcel.x - tangent.x * 0.92,
0,
state.parcel.z - tangent.z * 0.92
);
state.moverYaw = Math.atan2(tangent.x, tangent.z);
state.armCarry = 1;
state.walk = Math.sin(time * 7.5) * 0.62;
} else if (time < 7.4) {
const q = smoother((time - 6.7) / 0.7);
state.mover.copy(releaseRoot);
state.moverYaw = endNicoYaw;
state.parcel.set(
PARCEL_END.x,
THREE.MathUtils.lerp(CARRY_Y, REST_Y, q),
PARCEL_END.y
);
state.armCarry = 1;
} else {
const q = smoother((time - 7.4) / 1.0);
state.mover.copy(releaseRoot)
.addScaledVector(releaseSide, q * 0.70)
.addScaledVector(endTangent, -q * 0.12);
state.moverYaw = endNicoYaw;
state.parcel.set(PARCEL_END.x, REST_Y, PARCEL_END.y);
state.armCarry = 1 - smoother((time - 7.4) / 0.48);
state.walk = Math.sin((time - 7.4) * 8) * Math.sin(q * Math.PI);
}
const turn = smoother((time - 1.0) / 2.2);
state.observerYaw = initialMiraYaw + Math.PI * turn;
return state;
}
// ---------------------------------------------------------------------
// Geometric visibility: directional field and segment/AABB intersection.
// These functions do not model perception or cognition.
// ---------------------------------------------------------------------
function segmentAABB(start, end, min, max) {
let tMin = 0;
let tMax = 1;
for (const axis of ["x", "y", "z"]) {
const delta = end[axis] - start[axis];
if (Math.abs(delta) < 1e-8) {
if (start[axis] < min[axis] || start[axis] > max[axis]) {
return null;
}
} else {
let t1 = (min[axis] - start[axis]) / delta;
let t2 = (max[axis] - start[axis]) / delta;
if (t1 > t2) [t1, t2] = [t2, t1];
tMin = Math.max(tMin, t1);
tMax = Math.min(tMax, t2);
if (tMin > tMax) return null;
}
}
return tMin;
}
function visibilityAt(position, yaw, target) {
const eye = position.clone().add(new THREE.Vector3(0, 1.53, 0));
const flat = target.clone().sub(eye);
flat.y = 0;
if (flat.lengthSq() < 1e-8) flat.set(0, 0, 1);
flat.normalize();
const forward = new THREE.Vector3(Math.sin(yaw), 0, Math.cos(yaw));
const dot = THREE.MathUtils.clamp(flat.dot(forward), -1, 1);
const inArc = dot >= Math.cos(FOV_RADIANS * 0.5);
const intersectionT = segmentAABB(eye, target, WALL_MIN, WALL_MAX);
const blocked = intersectionT !== null;
return {
eye,
inArc,
blocked,
intersectionT,
angle: Math.acos(dot)
};
}
function createSightLine() {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(new Float32Array(6), 3)
);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({
color: 0x58e6aa,
transparent: true,
opacity: 0.92,
depthTest: false,
depthWrite: false
})
);
line.frustumCulled = false;
line.renderOrder = 12;
scene.add(line);
return line;
}
const miraSightLine = createSightLine();
const nicoSightLine = createSightLine();
const intersectionMarker = new THREE.Mesh(
new THREE.BoxGeometry(0.17, 0.17, 0.17),
new THREE.MeshBasicMaterial({
color: 0xff5d78,
depthTest: false,
depthWrite: false
})
);
intersectionMarker.renderOrder = 15;
scene.add(intersectionMarker);
function updateLine(line, start, end, hexColor) {
const array = line.geometry.attributes.position.array;
array[0] = start.x;
array[1] = start.y;
array[2] = start.z;
array[3] = end.x;
array[4] = end.y;
array[5] = end.z;
line.geometry.attributes.position.needsUpdate = true;
line.geometry.computeBoundingSphere();
line.material.color.setHex(hexColor);
}
// ---------------------------------------------------------------------
// Event streams. Wording is restricted to observable geometry/actions.
// ---------------------------------------------------------------------
const events = {
MIRA: [
{ time: 0.00, text: "Mira's marked forward arc points toward the source stand." },
{ time: 1.00, text: "Mira's torso and head begin a 180-degree rotation." },
{ time: 1.80, text: "The parcel starts changing position while Mira is still rotating." },
{ time: 3.20, text: "Mira's rotation ends with the forward arc pointing away from the source." },
{ time: 6.70, text: "The parcel becomes stationary on the destination stand." }
],
NICO: [
{ time: 0.00, text: "Nico moves from the starting position toward the source stand." },
{ time: 1.20, text: "Nico reaches the stand and moves both arms toward the parcel." },
{ time: 1.30, text: "The parcel rises from the stand while remaining adjacent to Nico." },
{ time: 1.80, text: "Nico and the parcel begin moving along the block route." },
{ time: 6.70, text: "The parcel reaches the destination stand." },
{ time: 6.90, text: "The parcel descends toward the stand surface." },
{ time: 7.40, text: "Nico's arms return to a neutral position; the parcel remains on the stand." }
]
};
// Find the first actual geometric transitions by sampling the animation.
let previousArc = true;
let previousBlocked = false;
let previousRounded = false;
for (let t = 0.02; t <= DURATION; t += 0.02) {
const state = stateAt(t);
const miraView = visibilityAt(MIRA_POSITION, state.observerYaw, state.parcel);
if (previousArc && !miraView.inArc) {
events.MIRA.push({
time: t,
text: "The parcel leaves Mira's marked forward arc."
});
}
if (!previousBlocked && miraView.blocked) {
events.MIRA.push({
time: t,
text: "The head-to-parcel segment intersects the partition blocks."
});
}
if (!previousRounded && state.parcel.z > 5.05) {
events.NICO.push({
time: t,
text: "The parcel passes around the partition's upper edge."
});
}
previousArc = miraView.inArc;
previousBlocked = miraView.blocked;
previousRounded = state.parcel.z > 5.05;
}
for (const key of Object.keys(events)) {
events[key].sort((a, b) => a.time - b.time);
const container = document.querySelector(`#${key.toLowerCase()}-events`);
container.innerHTML = "";
for (const event of events[key]) {
const row = document.createElement("div");
row.className = "event future";
row.dataset.time = String(event.time);
row.innerHTML = `
<time>${event.time.toFixed(2)}s</time>
<span>${event.text}</span>
`;
container.appendChild(row);
}
}
const eventRows = Array.from(document.querySelectorAll(".event"));
// ---------------------------------------------------------------------
// Playback and UI.
// ---------------------------------------------------------------------
const playButton = document.querySelector("#play");
const replayButton = document.querySelector("#replay");
const scrub = document.querySelector("#scrub");
const clock = document.querySelector("#clock");
const speedSelect = document.querySelector("#speed");
const sightToggle = document.querySelector("#sight-toggle");
const resetCameraButton = document.querySelector("#reset-camera");
const topViewButton = document.querySelector("#top-view");
const miraStatus = document.querySelector("#mira-status");
const nicoStatus = document.querySelector("#nico-status");
const miraDetail = document.querySelector("#mira-detail");
const nicoDetail = document.querySelector("#nico-detail");
let time = 0;
let playing = true;
let playbackSpeed = 1;
let showSightLines = true;
function updatePlayButton() {
playButton.textContent = playing ? "Pause" : "Play";
}
playButton.addEventListener("click", () => {
if (time >= DURATION) time = 0;
playing = !playing;
updatePlayButton();
});
replayButton.addEventListener("click", () => {
time = 0;
playing = true;
updatePlayButton();
});
scrub.addEventListener("input", () => {
time = Number(scrub.value);
playing = false;
updatePlayButton();
});
speedSelect.addEventListener("change", () => {
playbackSpeed = Number(speedSelect.value);
});
sightToggle.addEventListener("click", () => {
showSightLines = !showSightLines;
sightToggle.setAttribute("aria-pressed", String(showSightLines));
});
resetCameraButton.addEventListener("click", () => {
cameraState.theta = 0.72;
cameraState.phi = 0.83;
cameraState.radius = 18;
cameraState.target.set(0, 0.75, 0);
applyCamera();
});
topViewButton.addEventListener("click", () => {
cameraState.theta = 0.01;
cameraState.phi = 0.12;
cameraState.radius = 19;
cameraState.target.set(0, 0.5, 0);
applyCamera();
});
function setStatus(element, text, mode) {
if (element.textContent !== text) element.textContent = text;
element.classList.remove(
"status-green",
"status-amber",
"status-red",
"status-blue"
);
element.classList.add(`status-${mode}`);
}
function updateUI(miraView, nicoView, state) {
scrub.value = String(time);
clock.textContent = `${time.toFixed(2)} / ${DURATION.toFixed(2)} s`;
if (miraView.blocked) {
setStatus(miraStatus, "PARTITION-BLOCKED", "red");
} else if (!miraView.inArc) {
setStatus(miraStatus, "OUTSIDE FORWARD ARC", "amber");
} else {
setStatus(miraStatus, "CLEAR IN ARC", "green");
}
if (nicoView.blocked) {
setStatus(nicoStatus, "PARCEL-BLOCKED", "red");
} else if (!nicoView.inArc) {
setStatus(nicoStatus, "OUTSIDE FORWARD ARC", "amber");
} else {
setStatus(nicoStatus, "CLEAR IN ARC", "blue");
}
const miraDegrees = THREE.MathUtils.radToDeg(state.observerYaw);
const partitionText = miraView.blocked ? "intersects partition" : "partition clear";
miraDetail.textContent =
`Heading ${((miraDegrees % 360) + 360) % 360 | 0}°. ` +
`Head-to-parcel segment: ${partitionText}.`;
const parcelOffset = state.parcel.clone().sub(state.mover);
const offsetLength = Math.hypot(parcelOffset.x, parcelOffset.z);
const obstructionText = nicoView.blocked ? "intersects partition" : "unobstructed";
nicoDetail.textContent =
`Parcel offset ${offsetLength.toFixed(2)} m. ` +
`Head-to-parcel segment: ${obstructionText}.`;
for (const row of eventRows) {
const eventTime = Number(row.dataset.time);
row.classList.toggle("done", time + 0.001 >= eventTime);
row.classList.toggle("future", time + 0.001 < eventTime);
}
}
function updateScene(state) {
parcel.position.copy(state.parcel);
nico.root.position.copy(state.mover);
nico.root.rotation.y = state.moverYaw;
const legSwing = state.walk * 0.43;
nico.legPivots[0].rotation.x = legSwing;
nico.legPivots[1].rotation.x = -legSwing;
nico.armPivots[0].rotation.x = -1.08 * state.armCarry;
nico.armPivots[1].rotation.x = -1.08 * state.armCarry;
mira.root.rotation.y = state.observerYaw;
const miraView = visibilityAt(
mira.root.position,
state.observerYaw,
state.parcel
);
const nicoView = visibilityAt(
nico.root.position,
state.moverYaw,
state.parcel
);
let miraLineColor = 0x58e6aa;
if (miraView.blocked) miraLineColor = 0xff5d78;
else if (!miraView.inArc) miraLineColor = 0xffc857;
let nicoLineColor = 0x63dcff;
if (nicoView.blocked) nicoLineColor = 0xff5d78;
else if (!nicoView.inArc) nicoLineColor = 0xffc857;
updateLine(miraSightLine, miraView.eye, state.parcel, miraLineColor);
updateLine(nicoSightLine, nicoView.eye, state.parcel, nicoLineColor);
miraSightLine.visible = showSightLines;
nicoSightLine.visible = showSightLines;
intersectionMarker.visible = showSightLines && miraView.blocked;
if (miraView.blocked) {
intersectionMarker.position.lerpVectors(
miraView.eye,
state.parcel,
miraView.intersectionT
);
}
updateUI(miraView, nicoView, state);
}
// ---------------------------------------------------------------------
// Main loop.
// ---------------------------------------------------------------------
let previousFrame = performance.now();
function animate(now) {
const delta = Math.min((now - previousFrame) / 1000, 0.05);
previousFrame = now;
if (playing) {
time += delta * playbackSpeed;
if (time >= DURATION) {
time = DURATION;
playing = false;
updatePlayButton();
}
}
updateScene(stateAt(time));
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
document.querySelector("#loading").remove();
requestAnimationFrame(animate);
</script>
</body>
</html>
```