Prompt specification
Build or customize the Three.js 3D scene "Compare subject motion during different exposures" 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: Compare subject motion during different exposures
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/compare-subject-motion-during-different-exposures-x2512
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows subject motion during different photographic exposures. Use a low-poly tabletop with a camera on a fixed tripod and a striped toy passing sideways across a marked track. Beside the physical scene, display an illustrative accumulated image trace for the selected exposure interval. A short interval should produce a shorter trace than a longer one, while the camera position, focus setting, and subject speed remain unchanged. Let the user adjust exposure duration and replay the same pass. Make clear that the trace illustrates motion blur rather than camera shake or a change in focus.
Working Three.js Starter (compare-subject-motion-during-different-exposures-x2512):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Exposure Lab — Subject Motion</title>
<style>
:root {
color-scheme: dark;
--bg: #090d17;
--panel: #111827;
--panel-2: #151f31;
--border: rgba(255, 255, 255, 0.11);
--text: #eef4ff;
--muted: #9caec8;
--accent: #f4b64d;
--accent-2: #74d4fc;
--good: #72e2a8;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
color: var(--text);
background:
radial-gradient(circle at 15% 0%, rgba(74, 111, 179, 0.17), transparent 31rem),
radial-gradient(circle at 100% 35%, rgba(244, 182, 77, 0.08), transparent 28rem),
var(--bg);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
.app {
width: min(1480px, calc(100% - 36px));
margin: 0 auto;
padding: 30px 0 38px;
}
header {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 28px;
margin-bottom: 22px;
}
.eyebrow {
margin: 0 0 8px;
color: var(--accent);
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(2rem, 4vw, 3.4rem);
line-height: 0.98;
letter-spacing: -0.055em;
}
.header-copy {
max-width: 560px;
margin: 0;
color: var(--muted);
font-size: 0.98rem;
line-height: 1.6;
}
.control-deck {
display: grid;
grid-template-columns: minmax(340px, 1fr) minmax(500px, 1.35fr);
gap: 24px;
align-items: center;
padding: 18px 20px;
margin-bottom: 18px;
border: 1px solid var(--border);
border-radius: 18px;
background: linear-gradient(135deg, rgba(21, 31, 49, 0.96), rgba(13, 19, 32, 0.96));
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}
.duration-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 16px;
margin-bottom: 10px;
}
.duration-row label {
font-size: 0.86rem;
font-weight: 750;
}
#durationValue {
color: var(--accent);
font: 800 1.2rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
input[type="range"] {
--fill: 25%;
width: 100%;
height: 6px;
margin: 7px 0 9px;
appearance: none;
border-radius: 99px;
outline: none;
background:
linear-gradient(90deg, var(--accent) 0 var(--fill), #2b3850 var(--fill) 100%);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 20px;
height: 20px;
appearance: none;
border: 4px solid #172033;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 3px 12px rgba(0, 0, 0, 0.35);
}
input[type="range"]::-moz-range-thumb {
width: 13px;
height: 13px;
border: 4px solid #172033;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
}
.range-scale {
display: flex;
justify-content: space-between;
color: #8192aa;
font-size: 0.7rem;
}
.replay-row {
display: flex;
align-items: center;
gap: 14px;
margin-top: 14px;
}
button {
border: 0;
cursor: pointer;
}
#replayButton {
padding: 10px 15px;
border-radius: 10px;
color: #171207;
background: var(--accent);
font-weight: 850;
box-shadow: 0 7px 20px rgba(244, 182, 77, 0.16);
transition: transform 120ms ease, background 120ms ease;
}
#replayButton:hover {
transform: translateY(-1px);
background: #ffd174;
}
#replayButton:active {
transform: translateY(1px);
}
.replay-note {
color: var(--muted);
font-size: 0.75rem;
line-height: 1.35;
}
.locked-facts {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 9px;
}
.fact {
min-height: 66px;
padding: 11px 12px;
border: 1px solid var(--border);
border-radius: 12px;
background: rgba(255, 255, 255, 0.025);
}
.fact strong,
.fact span {
display: block;
}
.fact strong {
margin-bottom: 4px;
font-size: 0.76rem;
}
.fact span {
color: var(--muted);
font-size: 0.7rem;
line-height: 1.35;
}
.fact svg {
width: 15px;
height: 15px;
margin-right: 5px;
vertical-align: -3px;
color: var(--good);
}
.workspace {
display: grid;
grid-template-columns: minmax(0, 1.35fr) minmax(390px, 0.85fr);
gap: 18px;
}
.panel {
overflow: hidden;
border: 1px solid var(--border);
border-radius: 18px;
background: rgba(17, 24, 39, 0.88);
box-shadow: 0 20px 55px rgba(0, 0, 0, 0.21);
}
.panel-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
min-height: 68px;
padding: 14px 17px;
border-bottom: 1px solid var(--border);
}
.panel-title {
margin: 0;
font-size: 0.95rem;
letter-spacing: -0.01em;
}
.panel-subtitle {
margin: 4px 0 0;
color: var(--muted);
font-size: 0.72rem;
}
.badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 9px;
border: 1px solid var(--border);
border-radius: 99px;
color: #c8d5e7;
background: rgba(255, 255, 255, 0.035);
font-size: 0.65rem;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
white-space: nowrap;
}
.badge::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: #8493a9;
content: "";
}
.badge.open {
color: #bff4d9;
border-color: rgba(114, 226, 168, 0.28);
}
.badge.open::before {
background: var(--good);
box-shadow: 0 0 9px rgba(114, 226, 168, 0.8);
}
.scene-wrap,
.trace-wrap {
position: relative;
height: clamp(480px, 63vh, 650px);
overflow: hidden;
background: #101827;
}
.scene-wrap canvas,
.trace-wrap canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
}
.scene-wrap canvas {
cursor: grab;
touch-action: none;
}
.scene-wrap canvas:active {
cursor: grabbing;
}
.scene-overlay {
position: absolute;
inset: 0;
pointer-events: none;
}
.overlay-top {
position: absolute;
top: 14px;
left: 14px;
right: 14px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.scene-tag {
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 8px;
color: rgba(255, 255, 255, 0.76);
background: rgba(8, 12, 20, 0.66);
backdrop-filter: blur(8px);
font-size: 0.65rem;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scene-caption {
position: absolute;
right: 14px;
bottom: 14px;
left: 14px;
padding: 10px 12px;
border: 1px solid rgba(255, 255, 255, 0.11);
border-radius: 10px;
color: #c7d4e6;
background: rgba(8, 12, 20, 0.74);
backdrop-filter: blur(8px);
font-size: 0.72rem;
line-height: 1.45;
}
.scene-caption strong {
color: #fff;
}
.reset-view {
position: absolute;
right: 14px;
bottom: 72px;
padding: 8px 10px;
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 8px;
color: #d8e4f5;
background: rgba(8, 12, 20, 0.7);
pointer-events: auto;
font-size: 0.68rem;
}
.trace-wrap {
background:
radial-gradient(circle at 50% 45%, rgba(73, 102, 153, 0.13), transparent 58%),
#090f1c;
}
.trace-status {
position: absolute;
top: 13px;
left: 14px;
display: inline-flex;
align-items: center;
gap: 7px;
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 8px;
color: #c7d4e6;
background: rgba(8, 12, 20, 0.73);
backdrop-filter: blur(8px);
font-size: 0.67rem;
font-weight: 750;
pointer-events: none;
}
.trace-status::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: #8493a9;
content: "";
}
.trace-status.open {
color: #c4f6dc;
}
.trace-status.open::before {
background: var(--good);
box-shadow: 0 0 10px rgba(114, 226, 168, 0.8);
}
.trace-status.done::before {
background: var(--accent-2);
}
.trace-footer {
display: grid;
grid-template-columns: repeat(3, 1fr);
border-top: 1px solid var(--border);
background: rgba(255, 255, 255, 0.018);
}
.metric {
padding: 13px 15px;
border-right: 1px solid var(--border);
}
.metric:last-child {
border-right: 0;
}
.metric span,
.metric strong {
display: block;
}
.metric span {
margin-bottom: 5px;
color: var(--muted);
font-size: 0.64rem;
font-weight: 750;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.metric strong {
font: 800 1rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.learning-row {
display: grid;
grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
gap: 18px;
margin-top: 18px;
}
.timeline-panel,
.explain-panel {
padding: 18px;
border: 1px solid var(--border);
border-radius: 16px;
background: rgba(17, 24, 39, 0.72);
}
.section-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 17px;
}
.section-heading h2 {
margin: 0;
font-size: 0.87rem;
}
.section-heading span {
color: var(--muted);
font-size: 0.7rem;
}
.timeline-row {
display: grid;
grid-template-columns: auto minmax(100px, 1fr) auto;
align-items: center;
gap: 10px;
color: var(--muted);
font-size: 0.68rem;
}
.timeline {
position: relative;
height: 30px;
border-radius: 8px;
background: #202b3e;
}
.timeline-base,
.pass-progress,
.exposure-window,
.playhead {
position: absolute;
top: 0;
bottom: 0;
}
.timeline-base {
left: 0;
right: 0;
border-radius: 8px;
background: repeating-linear-gradient(
90deg,
#202b3e 0,
#202b3e calc(9.5% - 1px),
#2c3950 calc(9.5% - 1px),
#2c3950 9.5%
);
}
.pass-progress {
left: 0;
width: 0;
border-radius: 8px 0 0 8px;
background: rgba(116, 212, 252, 0.12);
pointer-events: none;
}
.exposure-window {
left: 20%;
width: 20%;
border: 1px solid rgba(244, 182, 77, 0.72);
border-radius: 7px;
background: rgba(244, 182, 77, 0.25);
box-shadow: inset 0 0 14px rgba(244, 182, 77, 0.12);
}
.playhead {
left: 0;
width: 2px;
background: #eaf6ff;
box-shadow: 0 0 9px rgba(255, 255, 255, 0.75);
pointer-events: none;
}
.timeline-legend {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-top: 12px;
color: var(--muted);
font-size: 0.68rem;
}
.legend-key {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend-swatch {
width: 17px;
height: 8px;
border-radius: 3px;
background: rgba(244, 182, 77, 0.38);
border: 1px solid rgba(244, 182, 77, 0.7);
}
.legend-swatch.pass {
background: #2c3950;
border-color: #45536a;
}
.explain-panel h2 {
margin: 0 0 10px;
font-size: 0.87rem;
}
.explain-panel p {
margin: 0 0 10px;
color: var(--muted);
font-size: 0.74rem;
line-height: 1.55;
}
.explain-panel p:last-child {
margin-bottom: 0;
}
.explain-panel strong {
color: #dce8f8;
}
@media (max-width: 1050px) {
.control-deck,
.workspace,
.learning-row {
grid-template-columns: 1fr;
}
.scene-wrap,
.trace-wrap {
height: 520px;
}
}
@media (max-width: 680px) {
.app {
width: min(100% - 20px, 1480px);
padding-top: 20px;
}
header {
display: block;
}
.header-copy {
margin-top: 15px;
}
.locked-facts,
.trace-footer {
grid-template-columns: 1fr;
}
.fact {
min-height: auto;
}
.metric {
border-right: 0;
border-bottom: 1px solid var(--border);
}
.metric:last-child {
border-bottom: 0;
}
.scene-wrap,
.trace-wrap {
height: 440px;
}
.panel-header {
align-items: flex-start;
}
.overlay-top {
flex-direction: column;
}
}
</style>
</head>
<body>
<main class="app">
<header>
<div>
<p class="eyebrow">Exposure Lab / Motion Study</p>
<h1>One subject. One camera.<br />A longer trace.</h1>
</div>
<p class="header-copy">
Change only the shutter-open time and replay the identical pass.
The illustrated trace shows how a stationary camera records the subject’s
movement during that exposure.
</p>
</header>
<section class="control-deck" aria-label="Exposure controls">
<div>
<div class="duration-row">
<label for="duration">Exposure duration</label>
<output id="durationValue" for="duration">0.80 s</output>
</div>
<input
id="duration"
type="range"
min="0.20"
max="2.40"
step="0.05"
value="0.80"
aria-describedby="durationHelp"
/>
<div class="range-scale">
<span>Short · 0.20 s</span>
<span>Long · 2.40 s</span>
</div>
<div class="replay-row">
<button id="replayButton" type="button">↻ Replay same pass</button>
<span class="replay-note" id="durationHelp">
Every replay starts from the same position and uses the same speed.
</span>
</div>
</div>
<div class="locked-facts" aria-label="Locked conditions">
<div class="fact">
<strong>
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true">
<path d="M5 8h10v7H5zM7 8l1.3-3h3.4L13 8" stroke="currentColor" stroke-width="1.6"/>
</svg>
Camera fixed
</strong>
<span>Tripod position and viewing direction never change.</span>
</div>
<div class="fact">
<strong>
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true">
<circle cx="10" cy="10" r="6.5" stroke="currentColor" stroke-width="1.6"/>
<path d="M10 6v4l2.6 1.7" stroke="currentColor" stroke-width="1.6"/>
</svg>
Focus locked
</strong>
<span>Focus stays on the track plane for every exposure.</span>
</div>
<div class="fact">
<strong>
<svg viewBox="0 0 20 20" fill="none" aria-hidden="true">
<path d="M3 10h14M13 6l4 4-4 4" stroke="currentColor" stroke-width="1.6"/>
</svg>
Speed constant
</strong>
<span>The toy travels at 1.50 table units per second.</span>
</div>
</div>
</section>
<section class="workspace">
<article class="panel">
<div class="panel-header">
<div>
<h2 class="panel-title">Physical tabletop scene</h2>
<p class="panel-subtitle">Fixed camera, fixed focus, constant subject speed</p>
</div>
<div class="badge" id="shutterBadge">Shutter closed</div>
</div>
<div class="scene-wrap" id="sceneWrap">
<canvas id="scene" aria-label="Three-dimensional tabletop motion demonstration"></canvas>
<div class="scene-overlay">
<div class="overlay-top">
<div class="scene-tag">Live pass / identical start</div>
<div class="scene-tag">Drag to orbit · scroll to zoom</div>
</div>
<button class="reset-view" id="resetView" type="button">
Reset viewer angle
</button>
<div class="scene-caption">
<strong>The tripod camera is locked.</strong>
Moving the viewer angle does not move the physical camera or alter
its focus. Only the toy moves.
</div>
</div>
</div>
</article>
<article class="panel">
<div class="panel-header">
<div>
<h2 class="panel-title">Illustrative accumulated trace</h2>
<p class="panel-subtitle">Schematic sensor view during the shutter-open interval</p>
</div>
</div>
<div class="trace-wrap" id="traceWrap">
<canvas id="trace" aria-label="Accumulated motion-blur trace"></canvas>
<div class="trace-status" id="traceStatus">Ready to capture</div>
</div>
<div class="trace-footer">
<div class="metric">
<span>Trace span</span>
<strong id="traceSpan">1.20 u</strong>
</div>
<div class="metric">
<span>Track covered</span>
<strong id="traceCoverage">19%</strong>
</div>
<div class="metric">
<span>Trace samples</span>
<strong id="sampleCount">72</strong>
</div>
</div>
</article>
</section>
<section class="learning-row">
<div class="timeline-panel">
<div class="section-heading">
<h2>Exposure timing</h2>
<span>The amber window is the only variable</span>
</div>
<div class="timeline-row">
<span>0.0 s</span>
<div class="timeline" id="timeline">
<div class="timeline-base"></div>
<div class="pass-progress" id="passProgress"></div>
<div class="exposure-window" id="exposureWindow"></div>
<div class="playhead" id="playhead"></div>
</div>
<span>4.2 s</span>
</div>
<div class="timeline-legend">
<span class="legend-key">
<span class="legend-swatch pass"></span>
Complete, identical subject pass
</span>
<span class="legend-key">
<span class="legend-swatch"></span>
Shutter open — frames accumulate here
</span>
</div>
</div>
<aside class="explain-panel">
<h2>What the trace demonstrates</h2>
<p>
A longer exposure leaves the shutter open longer, so the stationary
camera records the striped toy at more positions. Those positions
combine into a longer motion-blur trace.
</p>
<p>
<strong>This is not camera shake:</strong> the tripod and framing stay
fixed. It is also <strong>not a focus change:</strong> the focus plane
and subject speed remain locked.
</p>
</aside>
</section>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Shared state
// -------------------------------------------------------------------------
const PASS_DURATION = 4.2;
const EXPOSURE_START = 0.85;
const TRACK_START = -3.15;
const TRACK_END = 3.15;
const SUBJECT_SPEED = 1.5; // table units per second
const TRACE_SAMPLE_RATE = 90;
const TRACE_STEP = 1 / TRACE_SAMPLE_RATE;
const state = {
duration: 0.8,
playing: false,
startedAt: 0,
elapsed: 0,
samples: [],
lastSampleTime: EXPOSURE_START - TRACE_STEP
};
const durationInput = document.querySelector("#duration");
const durationValue = document.querySelector("#durationValue");
const replayButton = document.querySelector("#replayButton");
const resetViewButton = document.querySelector("#resetView");
const shutterBadge = document.querySelector("#shutterBadge");
const traceStatus = document.querySelector("#traceStatus");
const traceSpan = document.querySelector("#traceSpan");
const traceCoverage = document.querySelector("#traceCoverage");
const sampleCount = document.querySelector("#sampleCount");
const exposureWindow = document.querySelector("#exposureWindow");
const passProgress = document.querySelector("#passProgress");
const playhead = document.querySelector("#playhead");
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const sceneCanvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas: sceneCanvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111a2b);
scene.fog = new THREE.Fog(0x111a2b, 13, 24);
const viewerCamera = new THREE.PerspectiveCamera(39, 1, 0.1, 60);
const orbit = {
yaw: 0.58,
pitch: 0.63,
radius: 10.8,
target: new THREE.Vector3(0, 0.72, 0)
};
function updateViewerCamera() {
const sinPitch = Math.sin(orbit.pitch);
viewerCamera.position.set(
orbit.target.x + orbit.radius * sinPitch * Math.sin(orbit.yaw),
orbit.target.y + orbit.radius * Math.cos(orbit.pitch),
orbit.target.z + orbit.radius * sinPitch * Math.cos(orbit.yaw)
);
viewerCamera.lookAt(orbit.target);
}
updateViewerCamera();
const hemisphere = new THREE.HemisphereLight(0xcfe3ff, 0x3d3026, 2.05);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff0d6, 3.25);
keyLight.position.set(4.5, 8.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 22;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x8bbdff, 1.15);
fillLight.position.set(-5, 4, -4);
scene.add(fillLight);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.04,
flatShading: true,
...options
});
function addBox(parent, size, position, mat, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(...size), mat);
mesh.position.set(...position);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinderBetween(parent, a, b, radius, mat, segments = 8) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Floor and low-poly table.
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
material(0x172132, { roughness: 1 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.17;
floor.receiveShadow = true;
scene.add(floor);
const wood = material(0xc99e68, { roughness: 0.88 });
const woodEdge = material(0xa97746, { roughness: 0.92 });
addBox(scene, [10, 0.5, 6.5], [0, 0.45, 0], wood);
addBox(scene, [10.08, 0.16, 6.58], [0, 0.18, 0], woodEdge);
const legMaterial = material(0x5e4938, { roughness: 0.9 });
for (const x of [-4.25, 4.25]) {
for (const z of [-2.65, 2.65]) {
addBox(scene, [0.65, 1.45, 0.65], [x, -0.42, z], legMaterial);
}
}
// Marked track.
const trackBase = material(0x26354b, { roughness: 0.82 });
const trackInset = material(0x35465f, { roughness: 0.85 });
const chalk = material(0xe7edf3, { roughness: 0.95 });
addBox(scene, [7.25, 0.12, 1.62], [0, 0.76, 0], trackBase);
addBox(scene, [6.95, 0.025, 1.24], [0, 0.835, 0], trackInset);
for (let x = -3.25; x <= 3.3; x += 0.5) {
addBox(scene, [0.27, 0.025, 0.045], [x, 0.858, 0], chalk, false);
}
for (const z of [-0.57, 0.57]) {
for (let x = -3.15; x < 3.2; x += 0.65) {
addBox(scene, [0.39, 0.028, 0.045], [x, 0.86, z], chalk, false);
}
}
function createTrackLabel(text, x) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 128;
labelCanvas.height = 64;
const context = labelCanvas.getContext("2d");
context.clearRect(0, 0, 128, 64);
context.fillStyle = "#e7edf3";
context.font = "bold 36px ui-monospace, monospace";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 64, 32);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const label = new THREE.Mesh(
new THREE.PlaneGeometry(0.38, 0.19),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
})
);
label.rotation.x = -Math.PI / 2;
label.position.set(x, 0.865, -0.43);
label.renderOrder = 2;
scene.add(label);
}
["0", "1", "2", "3"].forEach((label, index) => {
createTrackLabel(label, -3 + index * 2);
});
// A subtle focus marker on the locked focus plane.
const focusMarker = new THREE.Mesh(
new THREE.RingGeometry(0.15, 0.2, 24),
new THREE.MeshBasicMaterial({
color: 0x74d4fc,
transparent: true,
opacity: 0.52,
side: THREE.DoubleSide,
depthWrite: false
})
);
focusMarker.rotation.x = -Math.PI / 2;
focusMarker.position.set(0, 0.867, 0);
scene.add(focusMarker);
// -------------------------------------------------------------------------
// Striped low-poly toy
// -------------------------------------------------------------------------
const toy = new THREE.Group();
toy.position.set(TRACK_START, 0.84, 0);
scene.add(toy);
const toyGold = material(0xe7a83c, { roughness: 0.72 });
const toyStripe = material(0x253044, { roughness: 0.8 });
const toyCream = material(0xf3e2bd, { roughness: 0.88 });
const toyBlue = material(0x317e9e, { roughness: 0.7 });
const eyeMaterial = material(0x101722, { roughness: 0.5 });
// Body, head, legs, tail, and ears.
addBox(toy, [1.08, 0.62, 0.66], [0, 0.51, 0], toyGold);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.36, 8, 6),
toyGold
);
head.position.set(0.64, 0.72, 0);
head.castShadow = true;
toy.add(head);
for (const x of [-0.35, 0.3]) {
for (const z of [-0.22, 0.22]) {
addBox(toy, [0.2, 0.27, 0.2], [x, 0.135, z], toyGold);
}
}
for (const z of [-0.2, 0.2]) {
const ear = new THREE.Mesh(
new THREE.ConeGeometry(0.12, 0.22, 5),
toyGold
);
ear.position.set(0.59, 1.02, z);
ear.castShadow = true;
toy.add(ear);
}
const snout = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 7, 5),
toyCream
);
snout.scale.set(1.25, 0.75, 0.85);
snout.position.set(0.91, 0.62, 0);
snout.castShadow = true;
toy.add(snout);
const nose = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 6, 4),
eyeMaterial
);
nose.position.set(1.04, 0.65, 0);
toy.add(nose);
for (const z of [-0.31, 0.31]) {
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.046, 6, 4),
eyeMaterial
);
eye.position.set(0.73, 0.81, z);
toy.add(eye);
}
// Dark vertical stripes make the subject's motion easy to read.
for (const x of [-0.29, -0.08, 0.14]) {
addBox(toy, [0.095, 0.64, 0.025], [x, 0.51, 0.343], toyStripe);
addBox(toy, [0.095, 0.64, 0.025], [x, 0.51, -0.343], toyStripe);
addBox(toy, [0.095, 0.025, 0.64], [x, 0.825, 0], toyStripe);
}
addBox(toy, [0.07, 0.3, 0.64], [0.48, 0.59, 0], toyStripe);
// Small segmented tail.
addBox(toy, [0.36, 0.13, 0.13], [-0.68, 0.63, 0], toyGold).rotation.z = -0.45;
addBox(toy, [0.31, 0.12, 0.12], [-0.93, 0.78, 0], toyGold).rotation.z = -0.8;
const tailTip = new THREE.Mesh(
new THREE.SphereGeometry(0.11, 6, 4),
toyStripe
);
tailTip.position.set(-1.08, 0.91, 0);
toy.add(tailTip);
// Blue collar.
addBox(toy, [0.075, 0.49, 0.69], [0.43, 0.55, 0], toyBlue);
// -------------------------------------------------------------------------
// Physical camera and fixed tripod
// -------------------------------------------------------------------------
const cameraRig = new THREE.Group();
cameraRig.position.set(-3.8, 0.7, 2.05);
scene.add(cameraRig);
const tripodMaterial = material(0x354254, {
roughness: 0.55,
metalness: 0.42
});
const cameraBodyMaterial = material(0x182231, {
roughness: 0.46,
metalness: 0.24
});
const metalMaterial = material(0x9aa9b8, {
roughness: 0.35,
metalness: 0.72
});
const lensMaterial = material(0x111a29, {
roughness: 0.18,
metalness: 0.35
});
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0x3b8eb1,
roughness: 0.12,
metalness: 0.28,
emissive: 0x0b2734,
emissiveIntensity: 0.45,
side: THREE.DoubleSide
});
const legTop = [0, 1.48, 0];
const feet = [
[0.75, 0.04, 0.45],
[-0.75, 0.04, 0.45],
[0, 0.04, -0.82]
];
feet.forEach((foot) => {
addCylinderBetween(cameraRig, legTop, foot, 0.055, tripodMaterial, 8);
});
addCylinderBetween(
cameraRig,
[0, 0.24, 0],
[0, 1.55, 0],
0.085,
metalMaterial,
10
);
addCylinderBetween(
cameraRig,
[0.34, 0.7, 0.28],
[-0.34, 0.7, -0.28],
0.027,
metalMaterial,
7
);
addBox(cameraRig, [0.48, 0.08, 0.42], [0, 1.53, 0], tripodMaterial);
const cameraHead = new THREE.Group();
cameraHead.position.set(0, 1.86, 0);
cameraHead.rotation.set(-0.16, -1.03, 0, "YXZ");
cameraRig.add(cameraHead);
addBox(cameraHead, [0.86, 0.52, 0.52], [0, 0.05, 0], cameraBodyMaterial);
addBox(cameraHead, [0.28, 0.18, 0.23], [-0.13, 0.39, 0.05], cameraBodyMaterial);
const lens = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.26, 0.48, 16),
lensMaterial
);
lens.rotation.x = Math.PI / 2;
lens.position.set(0, 0.04, -0.48);
lens.castShadow = true;
cameraHead.add(lens);
const frontLens = new THREE.Mesh(
new THREE.CircleGeometry(0.205, 24),
glassMaterial
);
frontLens.position.set(0, 0.04, -0.725);
frontLens.rotation.y = Math.PI;
cameraHead.add(frontLens);
const tallyLight = new THREE.Mesh(
new THREE.SphereGeometry(0.035, 6, 4),
new THREE.MeshBasicMaterial({ color: 0xe96a5b })
);
tallyLight.position.set(0.28, 0.24, 0.27);
cameraHead.add(tallyLight);
// -------------------------------------------------------------------------
// Direct viewer controls: no external controls module
// -------------------------------------------------------------------------
let dragging = false;
let dragX = 0;
let dragY = 0;
sceneCanvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
dragX = event.clientX;
dragY = event.clientY;
sceneCanvas.setPointerCapture(event.pointerId);
});
sceneCanvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - dragX;
const deltaY = event.clientY - dragY;
dragX = event.clientX;
dragY = event.clientY;
orbit.yaw -= deltaX * 0.006;
orbit.pitch = THREE.MathUtils.clamp(
orbit.pitch + deltaY * 0.005,
0.28,
1.22
);
updateViewerCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && sceneCanvas.hasPointerCapture(event.pointerId)) {
sceneCanvas.releasePointerCapture(event.pointerId);
}
}
sceneCanvas.addEventListener("pointerup", endDrag);
sceneCanvas.addEventListener("pointercancel", endDrag);
sceneCanvas.addEventListener("contextmenu", (event) => event.preventDefault());
sceneCanvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.008,
7.2,
15
);
updateViewerCamera();
},
{ passive: false }
);
resetViewButton.addEventListener("click", () => {
orbit.yaw = 0.58;
orbit.pitch = 0.63;
orbit.radius = 10.8;
updateViewerCamera();
});
// -------------------------------------------------------------------------
// Trace canvas
// -------------------------------------------------------------------------
const traceCanvas = document.querySelector("#trace");
const traceContext = traceCanvas.getContext("2d");
const traceSize = { width: 1, height: 1, dpr: 1 };
function roundedRect(context, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
context.beginPath();
context.moveTo(x + r, y);
context.arcTo(x + width, y, x + width, y + height, r);
context.arcTo(x + width, y + height, x, y + height, r);
context.arcTo(x, y + height, x, y, r);
context.arcTo(x, y, x + width, y, r);
context.closePath();
}
function resizeTrace() {
const rect = document.querySelector("#traceWrap").getBoundingClientRect();
traceSize.width = Math.max(1, rect.width);
traceSize.height = Math.max(1, rect.height);
traceSize.dpr = Math.min(window.devicePixelRatio || 1, 2);
traceCanvas.width = Math.round(traceSize.width * traceSize.dpr);
traceCanvas.height = Math.round(traceSize.height * traceSize.dpr);
}
function subjectXAt(time) {
return TRACK_START + (TRACK_END - TRACK_START) * (time / PASS_DURATION);
}
function drawToySnapshot(context, x, y, alpha = 0.11) {
context.save();
context.globalAlpha = alpha;
context.filter = "blur(0.45px)";
// Tail.
context.strokeStyle = "#efb34e";
context.lineWidth = 6;
context.lineCap = "round";
context.beginPath();
context.moveTo(x - 16, y - 10);
context.quadraticCurveTo(x - 25, y - 15, x - 30, y - 24);
context.stroke();
// Legs.
context.fillStyle = "#e7a83c";
context.fillRect(x - 11, y - 5, 4, 11);
context.fillRect(x + 8, y - 5, 4, 11);
// Body.
context.fillStyle = "#efb34e";
context.beginPath();
context.ellipse(x, y - 12, 19, 11, 0, 0, Math.PI * 2);
context.fill();
// Head and snout.
context.beginPath();
context.arc(x + 18, y - 20, 9, 0, Math.PI * 2);
context.fill();
context.beginPath();
context.ellipse(x + 25, y - 16, 6, 4, 0, 0, Math.PI * 2);
context.fill();
// Stripes remain visible in the accumulated trace.
context.fillStyle = "#172238";
context.fillRect(x - 11, y - 21, 3.5, 18);
context.fillRect(x - 3, y - 22, 3.5, 20);
context.fillRect(x + 5, y - 21, 3.5, 18);
context.restore();
}
function drawTrace() {
const context = traceContext;
const width = traceSize.width;
const height = traceSize.height;
context.setTransform(traceSize.dpr, 0, 0, traceSize.dpr, 0, 0);
context.clearRect(0, 0, width, height);
const background = context.createLinearGradient(0, 0, 0, height);
background.addColorStop(0, "#101a2b");
background.addColorStop(1, "#080d17");
context.fillStyle = background;
context.fillRect(0, 0, width, height);
const frameX = 24;
const frameY = 35;
const frameW = Math.max(10, width - 48);
const frameH = Math.max(10, height - 76);
const toyY = frameY + frameH * 0.66;
// Sensor frame.
roundedRect(context, frameX, frameY, frameW, frameH, 12);
context.fillStyle = "rgba(7, 12, 22, 0.7)";
context.fill();
context.strokeStyle = "rgba(148, 175, 210, 0.27)";
context.lineWidth = 1;
context.stroke();
// Schematic grid and tabletop horizon.
context.save();
roundedRect(context, frameX, frameY, frameW, frameH, 12);
context.clip();
context.strokeStyle = "rgba(139, 168, 205, 0.07)";
context.lineWidth = 1;
for (let x = frameX + 20; x < frameX + frameW; x += 30) {
context.beginPath();
context.moveTo(x, frameY);
context.lineTo(x, frameY + frameH);
context.stroke();
}
for (let y = frameY + 20; y < frameY + frameH; y += 30) {
context.beginPath();
context.moveTo(frameX, y);
context.lineTo(frameX + frameW, y);
context.stroke();
}
const horizon = frameY + frameH * 0.37;
const horizonGradient = context.createLinearGradient(0, horizon, 0, frameY + frameH);
horizonGradient.addColorStop(0, "#26364d");
horizonGradient.addColorStop(1, "#121d2d");
context.fillStyle = horizonGradient;
context.fillRect(frameX, horizon, frameW, frameY + frameH - horizon);
context.strokeStyle = "rgba(116, 212, 252, 0.16)";
context.beginPath();
context.moveTo(frameX, horizon);
context.lineTo(frameX + frameW, horizon);
context.stroke();
context.restore();
const mapX = (worldX) =>
frameX + 25 +
((worldX - TRACK_START) / (TRACK_END - TRACK_START)) *
(frameW - 50);
const exposureEnd = EXPOSURE_START + state.duration;
const expectedStartX = mapX(subjectXAt(EXPOSURE_START));
const expectedEndX = mapX(subjectXAt(exposureEnd));
// Predicted shutter interval on the schematic ruler.
const rulerY = frameY + frameH - 19;
context.strokeStyle = "rgba(244, 182, 77, 0.34)";
context.lineWidth = 3;
context.setLineDash([5, 5]);
context.beginPath();
context.moveTo(expectedStartX, rulerY);
context.lineTo(expectedEndX, rulerY);
context.stroke();
context.setLineDash([]);
context.fillStyle = "#f4b64d";
context.fillRect(expectedStartX - 1, rulerY - 6, 2, 12);
context.fillRect(expectedEndX - 1, rulerY - 6, 2, 12);
// Continuous blur body.
if (state.samples.length > 1) {
context.save();
context.lineCap = "round";
context.lineJoin = "round";
context.strokeStyle = "rgba(244, 182, 77, 0.12)";
context.lineWidth = 24;
context.beginPath();
state.samples.forEach((sample, index) => {
const x = mapX(sample);
if (index === 0) context.moveTo(x, toyY - 12);
else context.lineTo(x, toyY - 12);
});
context.stroke();
context.restore();
// Repeated fixed-focus snapshots make up the illustrative trace.
for (const sample of state.samples) {
drawToySnapshot(context, mapX(sample), toyY, 0.095);
}
}
// Live outline identifies the current subject position while capturing.
const shutterIsOpen =
state.elapsed >= EXPOSURE_START &&
state.elapsed < exposureEnd;
if (state.playing && state.elapsed >= EXPOSURE_START) {
const liveX = mapX(subjectXAt(state.elapsed));
context.save();
context.globalAlpha = shutterIsOpen ? 0.58 : 0.22;
context.strokeStyle = shutterIsOpen ? "#83ddff" : "#9aacc2";
context.lineWidth = 1.4;
context.setLineDash([4, 3]);
context.beginPath();
context.ellipse(liveX, toyY - 12, 19, 11, 0, 0, Math.PI * 2);
context.stroke();
context.beginPath();
context.arc(liveX + 18, toyY - 20, 9, 0, Math.PI * 2);
context.stroke();
context.restore();
}
// Labels.
context.font = "700 10px ui-monospace, monospace";
context.fillStyle = "rgba(190, 208, 231, 0.78)";
context.textAlign = "left";
context.fillText("SCHEMATIC SENSOR VIEW", frameX + 4, 20);
context.textAlign = "right";
context.fillStyle = "rgba(244, 182, 77, 0.82)";
context.fillText(
`${state.duration.toFixed(2)} s SHUTTER WINDOW`,
frameX + frameW - 4,
20
);
context.textAlign = "left";
context.fillStyle = "rgba(157, 177, 202, 0.66)";
context.font = "600 9px ui-monospace, monospace";
context.fillText("EXPOSURE INTERVAL", expectedStartX, rulerY + 17);
}
// -------------------------------------------------------------------------
// UI and playback
// -------------------------------------------------------------------------
function updateSelectedDuration() {
const duration = Number(durationInput.value);
state.duration = duration;
const span = SUBJECT_SPEED * duration;
const coverage = (span / (TRACK_END - TRACK_START)) * 100;
const expectedSamples = Math.ceil(duration * TRACE_SAMPLE_RATE);
durationValue.textContent = `${duration.toFixed(2)} s`;
traceSpan.textContent = `${span.toFixed(2)} u`;
traceCoverage.textContent = `${Math.round(coverage)}%`;
sampleCount.textContent = expectedSamples;
const sliderPercent =
((duration - Number(durationInput.min)) /
(Number(durationInput.max) - Number(durationInput.min))) *
100;
durationInput.style.setProperty("--fill", `${sliderPercent}%`);
exposureWindow.style.left = `${(EXPOSURE_START / PASS_DURATION) * 100}%`;
exposureWindow.style.width = `${(duration / PASS_DURATION) * 100}%`;
}
function setStatus(text, mode = "") {
traceStatus.textContent = text;
traceStatus.className = `trace-status ${mode}`.trim();
}
function resetPass() {
state.playing = false;
state.startedAt = 0;
state.elapsed = 0;
state.samples = [];
state.lastSampleTime = EXPOSURE_START - TRACE_STEP;
toy.position.x = TRACK_START;
passProgress.style.width = "0%";
playhead.style.left = "0%";
shutterBadge.textContent = "Shutter closed";
shutterBadge.classList.remove("open");
setStatus("Ready to capture");
}
function replayPass() {
resetPass();
state.playing = true;
state.startedAt = performance.now();
setStatus("Pass running · shutter waiting");
}
durationInput.addEventListener("input", () => {
updateSelectedDuration();
resetPass();
});
replayButton.addEventListener("click", replayPass);
function updateStatus() {
const exposureEnd = EXPOSURE_START + state.duration;
if (!state.playing && state.elapsed === 0) {
setStatus("Ready to capture");
return;
}
if (state.elapsed < EXPOSURE_START) {
setStatus("Pass running · shutter waiting");
return;
}
if (state.elapsed < exposureEnd) {
setStatus("Shutter open · accumulating frames", "open");
shutterBadge.textContent = "Shutter open";
shutterBadge.classList.add("open");
return;
}
shutterBadge.textContent = "Shutter closed";
shutterBadge.classList.remove("open");
if (state.elapsed < PASS_DURATION) {
setStatus("Exposure complete · subject continues", "done");
} else {
setStatus("Pass complete · trace held", "done");
}
}
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resizeScene() {
const rect = document.querySelector("#sceneWrap").getBoundingClientRect();
renderer.setSize(Math.max(1, rect.width), Math.max(1, rect.height), false);
viewerCamera.aspect = Math.max(1, rect.width) / Math.max(1, rect.height);
viewerCamera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(() => {
resizeScene();
resizeTrace();
drawTrace();
});
resizeObserver.observe(document.querySelector("#sceneWrap"));
resizeObserver.observe(document.querySelector("#traceWrap"));
window.addEventListener("resize", () => {
resizeScene();
resizeTrace();
});
function animate(now) {
requestAnimationFrame(animate);
if (state.playing) {
state.elapsed = Math.min(
PASS_DURATION,
(now - state.startedAt) / 1000
);
// Strictly linear movement: every replay has identical velocity.
toy.position.x = subjectXAt(state.elapsed);
const exposureEnd = EXPOSURE_START + state.duration;
// Deterministically sample the selected interval, independent of frame rate.
if (state.elapsed >= EXPOSURE_START) {
let sampleTime = Math.max(
state.lastSampleTime + TRACE_STEP,
EXPOSURE_START
);
const samplingLimit = Math.min(state.elapsed, exposureEnd);
while (sampleTime <= samplingLimit + 0.000001) {
state.samples.push(subjectXAt(sampleTime));
state.lastSampleTime = sampleTime;
sampleTime += TRACE_STEP;
}
}
const progress = (state.elapsed / PASS_DURATION) * 100;
passProgress.style.width = `${progress}%`;
playhead.style.left = `${progress}%`;
updateStatus();
if (state.elapsed >= PASS_DURATION) {
state.playing = false;
}
}
renderer.render(scene, viewerCamera);
drawTrace();
}
resizeScene();
resizeTrace();
updateSelectedDuration();
resetPass();
requestAnimationFrame(animate);
</script>
</body>
</html>
```