Prompt specification
Build or customize the Three.js 3D scene "Trace a fictional family's documented process stages" 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: Trace a fictional family's documented process stages
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/trace-a-fictional-family-s-documented-process-stages-x2584
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows immigrant arrival and processing at Ellis Island. Let users follow clearly fictional characters through sourced process stages. Explain branching possibilities without assigning real people's health, ethnicity, or legal outcomes from appearance. Low-poly.
Working Three.js Starter (trace-a-fictional-family-s-documented-process-stages-x2584):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ellis Island — Following the Process</title>
<style>
:root {
--ink: #17333d;
--muted: #577079;
--paper: #fbf7ee;
--paper-2: #f1eadc;
--line: rgba(23, 51, 61, 0.16);
--teal: #1f7375;
--teal-dark: #15585c;
--rust: #b44e36;
--gold: #d49b42;
--shadow: 0 14px 42px rgba(20, 45, 53, 0.18);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background: #b7d4d8;
}
button, input { font: inherit; }
button { color: inherit; }
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene.dragging { cursor: grabbing; }
.topbar {
position: fixed;
z-index: 20;
top: 0;
left: 0;
right: 0;
min-height: 76px;
padding: 14px 20px;
display: flex;
align-items: center;
gap: 18px;
background: linear-gradient(180deg, rgba(251,247,238,.98), rgba(251,247,238,.88));
border-bottom: 1px solid var(--line);
box-shadow: 0 6px 24px rgba(20,45,53,.08);
backdrop-filter: blur(12px);
}
.brand {
min-width: 235px;
}
.brand-kicker {
color: var(--rust);
font-size: 10px;
font-weight: 850;
letter-spacing: .16em;
text-transform: uppercase;
}
h1 {
margin: 2px 0 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(22px, 2vw, 31px);
font-weight: 600;
line-height: 1;
letter-spacing: -.025em;
}
.fiction-note {
flex: 1;
max-width: 590px;
padding: 8px 12px;
border-left: 3px solid var(--gold);
color: #405a62;
font-size: 12px;
line-height: 1.35;
background: rgba(212,155,66,.08);
}
.fiction-note strong { color: var(--ink); }
.top-actions {
margin-left: auto;
display: flex;
gap: 8px;
}
.btn {
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255,255,255,.74);
padding: 9px 12px;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition: background .18s, transform .18s, border-color .18s;
}
.btn:hover {
background: #fff;
border-color: rgba(23,51,61,.32);
transform: translateY(-1px);
}
.btn:focus-visible,
.stage-btn:focus-visible,
.char-card:focus-visible,
.route-btn:focus-visible {
outline: 3px solid rgba(31,115,117,.35);
outline-offset: 2px;
}
.btn.primary {
background: var(--teal);
border-color: var(--teal);
color: #fff;
}
.panel {
position: fixed;
z-index: 15;
top: 94px;
width: 292px;
max-height: calc(100vh - 235px);
overflow: auto;
border: 1px solid rgba(23,51,61,.15);
border-radius: 15px;
background: rgba(251,247,238,.94);
box-shadow: var(--shadow);
backdrop-filter: blur(15px);
}
.left-panel { left: 18px; }
.right-panel { right: 18px; width: 360px; }
.panel-section {
padding: 15px;
border-bottom: 1px solid var(--line);
}
.panel-section:last-child { border-bottom: 0; }
.section-heading {
margin: 0 0 10px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: .14em;
text-transform: uppercase;
}
.section-heading span:last-child {
letter-spacing: 0;
text-transform: none;
font-weight: 650;
font-size: 10px;
}
.stage-list {
display: grid;
gap: 4px;
}
.stage-btn {
width: 100%;
display: grid;
grid-template-columns: 25px 1fr;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid transparent;
border-radius: 9px;
background: transparent;
text-align: left;
cursor: pointer;
color: #4b646c;
font-size: 12px;
line-height: 1.2;
}
.stage-btn:hover { background: rgba(31,115,117,.06); }
.stage-btn.active {
background: #e5efec;
border-color: rgba(31,115,117,.22);
color: var(--teal-dark);
font-weight: 780;
}
.stage-btn.complete { color: var(--ink); }
.stage-num {
width: 24px;
height: 24px;
display: grid;
place-items: center;
border: 1px solid rgba(23,51,61,.24);
border-radius: 50%;
font-size: 10px;
font-weight: 850;
}
.stage-btn.active .stage-num {
color: #fff;
background: var(--teal);
border-color: var(--teal);
}
.stage-btn.complete .stage-num {
color: var(--teal-dark);
background: #d6e8e4;
}
#characterList {
display: grid;
gap: 7px;
}
.char-card {
width: 100%;
display: grid;
grid-template-columns: 31px 1fr;
gap: 9px;
align-items: center;
padding: 9px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255,255,255,.55);
text-align: left;
cursor: pointer;
transition: .18s;
}
.char-card:hover {
background: #fff;
transform: translateX(2px);
}
.char-card.active {
border-color: rgba(31,115,117,.5);
box-shadow: inset 3px 0 0 var(--teal);
background: #fff;
}
.char-avatar {
width: 31px;
height: 31px;
display: grid;
place-items: center;
border-radius: 50%;
color: #fff;
font-size: 12px;
font-weight: 850;
box-shadow: inset 0 -5px 10px rgba(0,0,0,.12);
}
.char-name {
display: block;
font-size: 12px;
font-weight: 800;
}
.char-route {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
line-height: 1.25;
}
.micro-note {
margin: 9px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.detail-panel { padding: 20px; }
.eyebrow {
color: var(--rust);
font-size: 10px;
font-weight: 850;
letter-spacing: .14em;
text-transform: uppercase;
}
.detail-panel h2 {
margin: 7px 0 10px;
font-family: Georgia, "Times New Roman", serif;
font-size: 27px;
font-weight: 600;
line-height: 1.08;
letter-spacing: -.02em;
}
.detail-panel p {
margin: 0 0 13px;
color: #3f5962;
font-size: 13px;
line-height: 1.55;
}
.detail-block {
padding-top: 13px;
margin-top: 13px;
border-top: 1px solid var(--line);
}
.detail-block h3 {
margin: 0 0 8px;
font-size: 11px;
font-weight: 850;
letter-spacing: .09em;
text-transform: uppercase;
}
.branch-list {
margin: 0;
padding-left: 18px;
color: #405960;
font-size: 12px;
line-height: 1.48;
}
.branch-list li + li { margin-top: 6px; }
.uncertainty {
padding: 10px 11px;
border-radius: 9px;
background: rgba(212,155,66,.11);
color: #4d5e61;
font-size: 11px;
line-height: 1.45;
}
.source-cite {
margin-top: 13px;
padding: 10px 11px;
border-left: 3px solid var(--teal);
background: rgba(31,115,117,.06);
color: #49616a;
font-size: 10px;
line-height: 1.45;
}
.source-cite a { color: var(--teal-dark); font-weight: 750; }
.case-record {
margin-top: 12px;
padding: 11px;
border: 1px dashed rgba(23,51,61,.28);
border-radius: 9px;
background: rgba(255,255,255,.45);
}
.case-record strong {
display: block;
margin-bottom: 4px;
font-size: 10px;
letter-spacing: .08em;
text-transform: uppercase;
}
.case-record p {
margin: 0;
font-size: 11px;
}
.route-picker {
display: grid;
gap: 7px;
margin-top: 9px;
}
.route-btn {
width: 100%;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255,255,255,.55);
text-align: left;
cursor: pointer;
font-size: 11px;
line-height: 1.35;
}
.route-btn:hover { background: #fff; }
.route-btn.selected {
color: var(--teal-dark);
border-color: rgba(31,115,117,.48);
background: #e5efec;
font-weight: 750;
}
.route-btn small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
font-weight: 500;
}
.bottom-bar {
position: fixed;
z-index: 18;
left: 50%;
bottom: 17px;
transform: translateX(-50%);
width: min(860px, calc(100vw - 40px));
padding: 12px 15px 11px;
border: 1px solid rgba(23,51,61,.16);
border-radius: 14px;
background: rgba(251,247,238,.96);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.timeline-head {
display: flex;
align-items: center;
gap: 11px;
}
.transport {
display: flex;
gap: 6px;
}
.transport .btn {
min-width: 38px;
padding: 7px 9px;
}
.timeline-label {
flex: 1;
min-width: 0;
}
.timeline-label strong {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 12px;
}
.timeline-label small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
#timeline {
width: 100%;
height: 4px;
margin: 11px 0 1px;
accent-color: var(--teal);
cursor: pointer;
}
.timeline-help {
margin-top: 6px;
color: var(--muted);
font-size: 9px;
text-align: center;
}
.modal {
position: fixed;
z-index: 50;
inset: 0;
display: none;
align-items: center;
justify-content: center;
padding: 20px;
background: rgba(13,35,42,.58);
backdrop-filter: blur(8px);
}
.modal.open { display: flex; }
.modal-card {
width: min(760px, 100%);
max-height: 88vh;
overflow: auto;
padding: 25px;
border-radius: 16px;
background: var(--paper);
box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.modal-card h2 {
margin: 0 0 8px;
font-family: Georgia, "Times New Roman", serif;
font-size: 28px;
font-weight: 600;
}
.modal-card h3 {
margin: 22px 0 8px;
font-size: 12px;
letter-spacing: .08em;
text-transform: uppercase;
}
.modal-card p,
.modal-card li {
color: #405960;
font-size: 13px;
line-height: 1.6;
}
.modal-card ul { padding-left: 20px; }
.source-list {
display: grid;
gap: 10px;
}
.source-item {
padding: 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255,255,255,.45);
}
.source-item strong { display: block; font-size: 12px; }
.source-item p { margin: 4px 0; font-size: 11px; }
.source-item a { color: var(--teal-dark); font-size: 11px; font-weight: 750; }
.close-row {
position: sticky;
bottom: -25px;
margin: 20px -25px -25px;
padding: 13px 25px;
background: var(--paper);
border-top: 1px solid var(--line);
text-align: right;
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
background: #b7d4d8;
transition: opacity .4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loading-card {
padding: 20px 26px;
border-radius: 13px;
background: var(--paper);
box-shadow: var(--shadow);
text-align: center;
}
.loading-card strong {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
}
.loading-card small {
display: block;
margin-top: 5px;
color: var(--muted);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
white-space: nowrap;
border: 0;
}
@media (max-width: 1050px) {
.panel { width: 250px; }
.right-panel { width: 315px; }
.fiction-note { max-width: 390px; }
}
@media (max-width: 800px) {
.topbar {
min-height: 69px;
padding: 10px 12px;
gap: 9px;
}
.brand { min-width: 0; flex: 1; }
.brand-kicker { font-size: 8px; }
h1 { font-size: 21px; }
.fiction-note { display: none; }
.top-actions .btn { padding: 8px; font-size: 10px; }
.left-panel {
top: auto;
bottom: 145px;
left: 10px;
right: 10px;
width: auto;
max-height: 175px;
}
.left-panel .stage-section { display: none; }
#characterList {
grid-template-columns: repeat(2, minmax(0,1fr));
}
.right-panel {
top: 78px;
left: 10px;
right: 10px;
width: auto;
max-height: 35vh;
padding: 16px;
}
.detail-panel h2 { font-size: 23px; }
.detail-panel p { font-size: 12px; }
.bottom-bar { bottom: 8px; width: calc(100vw - 20px); }
}
@media (max-width: 480px) {
.top-actions .btn:first-child { display: none; }
.right-panel { max-height: 31vh; }
.left-panel { bottom: 143px; max-height: 148px; }
.timeline-label small { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly reconstruction of the Ellis Island immigration station"></canvas>
<header class="topbar">
<div class="brand">
<div class="brand-kicker">Historical process · c. 1900–1910</div>
<h1>Ellis Island: Following the Process</h1>
</div>
<div class="fiction-note">
<strong>Fictional cases only.</strong>
Names and records are invented. Coat colors and body shapes are decorative and never indicate health, ethnicity, nationality, or legal status.
</div>
<div class="top-actions">
<button class="btn" id="overviewBtn" title="Return to an overview of the island">Overview</button>
<button class="btn" id="followBtn" title="Follow the selected fictional character">Follow case</button>
<button class="btn primary" id="sourcesBtn">Sources & method</button>
</div>
</header>
<aside class="panel left-panel" aria-label="Process stages and fictional characters">
<section class="panel-section stage-section">
<div class="section-heading">
<span>Process stages</span>
<span>Historical summary</span>
</div>
<div class="stage-list" id="stageList"></div>
</section>
<section class="panel-section">
<div class="section-heading">
<span>Fictional cases</span>
<span>Select to follow</span>
</div>
<div id="characterList"></div>
<p class="micro-note">
All four figures use the same neutral skin tone and simple body forms.
Their colored coats are only visual identifiers.
</p>
</section>
</aside>
<aside class="panel right-panel detail-panel" aria-live="polite">
<div class="eyebrow" id="stageEyebrow"></div>
<h2 id="stageTitle"></h2>
<p id="stageDescription"></p>
<div class="detail-block">
<h3>Branching possibilities</h3>
<ul class="branch-list" id="branchList"></ul>
</div>
<div class="detail-block">
<h3>Using the historical record</h3>
<div class="uncertainty" id="uncertaintyText"></div>
</div>
<div class="case-record" id="caseRecord"></div>
<div class="detail-block" id="routeSection"></div>
<div class="source-cite" id="stageSource"></div>
</aside>
<nav class="bottom-bar" aria-label="Timeline controls">
<div class="timeline-head">
<div class="transport">
<button class="btn" id="prevBtn" aria-label="Previous stage">←</button>
<button class="btn" id="playBtn" aria-label="Play the process">▶</button>
<button class="btn" id="nextBtn" aria-label="Next stage">→</button>
</div>
<div class="timeline-label">
<strong id="timelineTitle"></strong>
<small id="timelineSubtitle"></small>
</div>
</div>
<input id="timeline" type="range" min="0" max="5" step="1" value="0" aria-label="Process stage">
<div class="timeline-help">
Drag to orbit · Scroll to zoom · Left/right arrows change stages · Space plays or pauses
</div>
</nav>
<div class="modal" id="sourcesModal" role="dialog" aria-modal="true" aria-labelledby="sourcesTitle">
<div class="modal-card">
<h2 id="sourcesTitle">Sources & interpretive method</h2>
<p>
This interactive is a simplified teaching model of the federal immigration station
at Ellis Island. It focuses on the broad sequence summarized in National Park
Service histories rather than reproducing every rule, exception, date, or local
arrangement.
</p>
<h3>Primary historical sources</h3>
<div class="source-list">
<div class="source-item">
<strong>National Park Service — “Ellis Island”</strong>
<p>Institutional history, operating context, and the station's role in the United States immigration system.</p>
<a href="https://www.nps.gov/elis/index.htm" target="_blank" rel="noopener noreferrer">nps.gov/elis</a>
</div>
<div class="source-item">
<strong>National Park Service — “The Immigration Process”</strong>
<p>
Broad historical sequence used for arrival, baggage and registry handling,
health inspection, legal inspection, decisions, and onward travel.
</p>
<a href="https://www.nps.gov/elis/learn/historyculture/immigration-process.htm" target="_blank" rel="noopener noreferrer">
View the NPS process history
</a>
</div>
<div class="source-item">
<strong>National Park Service — “Ellis Island Hospital”</strong>
<p>Historical context for station health screening and the existence of hospital care and isolation spaces.</p>
<a href="https://www.nps.gov/elis/learn/historyculture/hospital.htm" target="_blank" rel="noopener noreferrer">
View the hospital history
</a>
</div>
<div class="source-item">
<strong>Library of Congress — Immigration and Naturalization Service Records</strong>
<p>
Documentation of passenger manifests and individual case files, helping explain why
records and answers—not visual appearance—were central to decisions.
</p>
<a href="https://www.loc.gov/collections/immigration-and-naturalization-service-records/" target="_blank" rel="noopener noreferrer">
Explore the LOC collections
</a>
</div>
<div class="source-item">
<strong>National Archives — Immigration and Naturalization Service Records</strong>
<p>Federal archival context for immigration, naturalization, and related records.</p>
<a href="https://www.archives.gov/research/immigration" target="_blank" rel="noopener noreferrer">
Visit the National Archives
</a>
</div>
</div>
<h3>What has been simplified</h3>
<ul>
<li>
Procedures and laws changed over the station's operating years. This scene uses
a c. 1900–1910 teaching frame and does not present one procedure as universal.
</li>
<li>
Shipboard quarantine, administrative exceptions, interpreters, money exchange,
train ticketing, detention, exclusion appeals, and onward travel are compressed
into a small number of understandable stages.
</li>
<li>
The “hearing” path ends without announcing an outcome. Its purpose is to show a
branch in the historical process, not to decide a fictional person's case.
</li>
<li>
Naturalization was a separate legal process. Being admitted to the United States
did not automatically make someone a citizen.
</li>
</ul>
<h3>Ethical boundaries of the model</h3>
<p>
Ari, Bo, Cy, and Dee are invented teaching cases. Their records and routes are
scenario labels, not evidence about real people. No branch is triggered by a
figure's skin, face, clothing, body shape, or movement. All figures share the same
neutral skin tone and simplified form; coat color only helps a visitor distinguish
them in the scene.
</p>
<div class="close-row">
<button class="btn primary" data-close="sourcesModal">Close</button>
</div>
</div>
</div>
<div id="loading">
<div class="loading-card">
<strong>Building Ellis Island</strong>
<small>Low-poly station, ship, and fictional cases</small>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
/* --------------------------------------------------------------------------
Data and interface
--------------------------------------------------------------------------- */
const sources = {
npsGeneral: {
title: "National Park Service, “Ellis Island”",
url: "https://www.nps.gov/elis/index.htm"
},
npsProcess: {
title: "National Park Service, “The Immigration Process”",
url: "https://www.nps.gov/elis/learn/historyculture/immigration-process.htm"
},
npsHospital: {
title: "National Park Service, “Ellis Island Hospital”",
url: "https://www.nps.gov/elis/learn/historyculture/hospital.htm"
},
locRecords: {
title: "Library of Congress, Immigration and Naturalization Service Records",
url: "https://www.loc.gov/collections/immigration-and-naturalization-service-records/"
}
};
const characters = [
{
id: "A",
name: "Ari",
color: "#d49b42",
route: "admitted",
record: "Invented case file: Ari follows an admitted route after inspection and proceeds to onward-travel services."
},
{
id: "B",
name: "Bo",
color: "#3b8f87",
route: "medical",
record: "Invented screening note: Bo is sent to a secondary medical review. The review result and final legal outcome are not shown."
},
{
id: "C",
name: "Cy",
color: "#497b9f",
route: "hearing",
record: "Invented manifest question: Cy's case is sent to a hearing. The hearing's decision and final legal outcome are not shown."
},
{
id: "D",
name: "Dee",
color: "#b45b4a",
route: "admitted",
record: "Invented case file: Dee follows an admitted route after inspection and proceeds to onward-travel services."
}
];
const routeInfo = {
admitted: {
label: "Admitted route",
short: "Admitted",
note: "A fictional admitted case proceeds to exchange and railroad-ticket services.",
position4: [3.2, 1.32, -0.35],
position5: [11.8, 1.32, 5.6]
},
medical: {
label: "Secondary medical review",
short: "Medical review",
note: "A fictional screening note sends the case to further medical review; no diagnosis or result is simulated.",
position4: [3.7, 1.32, 3.3],
position5: [4.7, 1.32, 3.7]
},
hearing: {
label: "Record hearing",
short: "Hearing preview",
note: "A fictional manifest question sends the case to a hearing; no decision or final legal outcome is simulated.",
position4: [6.7, 1.32, -1.25],
position5: [8.2, 1.32, -1.35]
}
};
const stages = [
{
short: "Arrival & disembark",
title: "Arrival at the immigration station",
description:
"Ships brought newly arrived people to Ellis Island. Passengers were directed into the station's processing spaces after arrival. The scene shows the transfer from ship to dock as a broad stage, not a claim that every arrival followed the same minute-by-minute route.",
branches: [
"A ship's medical situation could affect how passengers were handled before or after disembarking.",
"After landing, arrivals moved toward the station's registration, baggage, and inspection spaces.",
"Some people carried documents or letters; those materials could become part of the record reviewed later."
],
uncertainty:
"The fictional cases begin at the station. Their routes are selected from invented case notes, never from the way the 3D figures look.",
sources: [sources.npsGeneral, sources.npsProcess]
},
{
short: "Baggage & registration",
title: "Baggage handling and registry records",
description:
"National Park Service histories describe a registration process and, for arrivals with checked baggage, a baggage room where belongings could be reclaimed. The order could vary by circumstance. This stage represents record handling and property claims before the main inspection sequence.",
branches: [
"Arrivals with checked baggage could be directed to reclaim it.",
"Arrivals without checked baggage could proceed directly toward the next processing area.",
"Questions about documents, names, destinations, or family connections could require an interpreter or additional checking."
],
uncertainty:
"This model does not invent individual family histories, national identities, or legal circumstances. The record text attached to each figure is explicitly fictional.",
sources: [sources.npsProcess, sources.locRecords]
},
{
short: "Health screening",
title: "Health screening and possible further review",
description:
"Station physicians and nurses examined newly arrived people. The historical process included screening, further examination, and hospital care when circumstances warranted it. The scene presents health screening as a documented procedural stage, not as a visual judgment about anyone's body or appearance.",
branches: [
"An arrival could continue to legal inspection after screening.",
"A screening finding recorded by medical staff could send someone to additional examination or hospital care.",
"The existence of a branch does not imply that every arrival experienced it."
],
uncertainty:
"Bo's secondary-review route is triggered only by an invented written screening note. The scene never diagnoses a figure, and the medical result remains unspecified.",
sources: [sources.npsProcess, sources.npsHospital]
},
{
short: "Manifest & legal inspection",
title: "Manifest comparison and legal inspection",
description:
"Immigration inspectors compared arrivals with the ship's manifest and asked questions intended to establish identity and the circumstances of travel. Interpreters could assist when needed. Records, answers, and case-specific questions were central; a person's appearance was not a valid basis for the decision shown here.",
branches: [
"A case could proceed to the decision stage.",
"A document or manifest question could require another record check or additional evidence.",
"A case could be referred for further examination or a hearing, depending on the records and applicable law."
],
uncertainty:
"Cy's hearing route is assigned only through an invented manifest question. Nothing about Cy's body, face, clothing, or ethnicity causes that branch.",
sources: [sources.npsProcess, sources.locRecords]
},
{
short: "Decision & branches",
title: "The decision point was not always final",
description:
"An arrival might be admitted, held for additional review, or excluded under the law then in force. Some exclusion cases could proceed to a Board of Special Inquiry and, in some circumstances, judicial review. This teaching model shows the different routes but deliberately ends the hearing path without inventing an outcome.",
branches: [
"An admitted case could continue to station services and onward travel.",
"A medical finding could direct a case into further review.",
"A documentary or legal question could direct a case into a hearing.",
"The hearing path intentionally stops before a decision."
],
uncertainty:
"Choose a route below to preview the path of the selected fictional case. This is a scenario switch, not a prediction, diagnosis, or judgment.",
sources: [sources.npsProcess]
},
{
short: "Next step",
title: "The next step depends on the route",
description:
"Admitted arrivals could use services such as money exchange and purchasing railroad tickets before leaving the island for another destination. Cases in further review or a hearing followed different paths. Admission and onward travel were not the same as naturalization or proof of citizenship.",
branches: [
"Admitted route: exchange and railroad-ticket services could precede departure from the island.",
"Secondary-review route: further examination or care could determine the next procedural step.",
"Hearing route: testimony, evidence, and a decision could follow; the outcome is not simulated.",
"Destinations and family connections varied; none are invented for these teaching cases."
],
uncertainty:
"Only Ari and Dee have explicitly fictional admitted routes. Bo and Cy remain in process, without a medical result or legal decision.",
sources: [sources.npsProcess]
}
];
let currentStage = 0;
let activeCharacter = 0;
let playing = false;
let playTimer = null;
let focusMode = false;
const stageList = document.getElementById("stageList");
const characterList = document.getElementById("characterList");
const timeline = document.getElementById("timeline");
stages.forEach((stage, index) => {
const button = document.createElement("button");
button.className = "stage-btn";
button.innerHTML = `
<span class="stage-num">${index + 1}</span>
<span>${stage.short}</span>
`;
button.addEventListener("click", () => {
stopPlayback();
setStage(index);
});
stageList.appendChild(button);
});
function renderCharacters() {
characterList.innerHTML = "";
characters.forEach((character, index) => {
const button = document.createElement("button");
button.className = `char-card${index === activeCharacter ? " active" : ""}`;
button.setAttribute("aria-pressed", index === activeCharacter ? "true" : "false");
button.innerHTML = `
<span class="char-avatar" style="background:${character.color}">${character.id}</span>
<span>
<span class="char-name">${character.name} · fictional</span>
<span class="char-route">${routeInfo[character.route].short} · Stage ${currentStage + 1}</span>
</span>
`;
button.addEventListener("click", () => {
activeCharacter = index;
renderCharacters();
renderDetail();
focusTarget.copy(characterMeshes[index].position);
});
characterList.appendChild(button);
});
}
function sourceMarkup(items) {
return items.map((source, index) => {
const prefix = index === 0 ? "Source" : "Additional source";
return `${prefix}: <a href="${source.url}" target="_blank" rel="noopener noreferrer">${source.title}</a>`;
}).join("<br>");
}
function renderDetail() {
const stage = stages[currentStage];
const character = characters[activeCharacter];
document.getElementById("stageEyebrow").textContent =
`Stage ${currentStage + 1} of ${stages.length} · Historical summary`;
document.getElementById("stageTitle").textContent =
currentStage === 5 ? `${routeInfo[character.route].short}: ${stage.title.toLowerCase()}` : stage.title;
let description = stage.description;
if (currentStage === 5 && character.route !== "admitted") {
description = routeInfo[character.route].note + " " + stage.description;
}
document.getElementById("stageDescription").textContent = description;
document.getElementById("branchList").innerHTML =
stage.branches.map(item => `<li>${item}</li>`).join("");
document.getElementById("uncertaintyText").textContent = stage.uncertainty;
document.getElementById("caseRecord").innerHTML = `
<strong>${character.name}'s invented case note</strong>
<p>${character.record}</p>
`;
const routeSection = document.getElementById("routeSection");
if (currentStage === 4) {
routeSection.innerHTML = `
<h3>Preview ${character.name}'s route</h3>
<div class="route-picker">
${Object.entries(routeInfo).map(([key, info]) => `
<button class="route-btn ${character.route === key ? "selected" : ""}" data-route="${key}">
${info.label}
<small>${key === "hearing"
? "Outcome intentionally unspecified."
: key === "medical"
? "Result and final decision unspecified."
: "Fictional case continues to services."}</small>
</button>
`).join("")}
</div>
`;
routeSection.querySelectorAll(".route-btn").forEach(button => {
button.addEventListener("click", () => {
characters[activeCharacter].route = button.dataset.route;
updateCharacterTargets();
renderCharacters();
renderDetail();
});
});
} else {
routeSection.innerHTML = `
<h3>Selected fictional route</h3>
<div class="uncertainty">${routeInfo[character.route].label}. ${routeInfo[character.route].note}</div>
`;
}
document.getElementById("stageSource").innerHTML = sourceMarkup(stage.sources);
document.getElementById("timelineTitle").textContent =
`${currentStage + 1}. ${stage.short}`;
document.getElementById("timelineSubtitle").textContent =
`Following ${character.name}'s fictional case · ${routeInfo[character.route].short}`;
timeline.value = currentStage;
document.getElementById("prevBtn").disabled = currentStage === 0;
document.getElementById("nextBtn").disabled = currentStage === stages.length - 1;
[...stageList.children].forEach((button, index) => {
button.classList.toggle("active", index === currentStage);
button.classList.toggle("complete", index < currentStage);
if (index === currentStage) {
button.setAttribute("aria-current", "step");
} else {
button.removeAttribute("aria-current");
}
});
}
function setStage(index) {
currentStage = Math.max(0, Math.min(stages.length - 1, index));
updateCharacterTargets();
renderCharacters();
renderDetail();
}
function updateCharacterTargets() {
const commonPositions = [
[-12.1, 1.32, 5.35],
[-8.0, 1.32, 3.65],
[-4.6, 1.32, 1.45],
[-0.45, 1.32, -0.65]
];
characters.forEach((character, index) => {
if (!characterMeshes[index]) return;
let position;
if (currentStage === 4) {
position = routeInfo[character.route].position4;
} else if (currentStage === 5) {
position = routeInfo[character.route].position5;
} else {
position = commonPositions[currentStage];
}
characterMeshes[index].target.set(...position);
});
}
function togglePlayback() {
if (playing) {
stopPlayback();
} else {
playing = true;
document.getElementById("playBtn").textContent = "Ⅱ";
document.getElementById("playBtn").setAttribute("aria-label", "Pause the process");
playTimer = setInterval(() => {
if (currentStage >= stages.length - 1) {
stopPlayback();
} else {
setStage(currentStage + 1);
}
}, 6500);
}
}
function stopPlayback() {
playing = false;
clearInterval(playTimer);
document.getElementById("playBtn").textContent = "▶";
document.getElementById("playBtn").setAttribute("aria-label", "Play the process");
}
document.getElementById("prevBtn").addEventListener("click", () => {
stopPlayback();
setStage(currentStage - 1);
});
document.getElementById("nextBtn").addEventListener("click", () => {
stopPlayback();
setStage(currentStage + 1);
});
document.getElementById("playBtn").addEventListener("click", togglePlayback);
timeline.addEventListener("input", event => {
stopPlayback();
setStage(Number(event.target.value));
});
document.getElementById("sourcesBtn").addEventListener("click", () => {
document.getElementById("sourcesModal").classList.add("open");
});
document.querySelectorAll("[data-close]").forEach(button => {
button.addEventListener("click", () => {
document.getElementById(button.dataset.close).classList.remove("open");
});
});
document.getElementById("sourcesModal").addEventListener("click", event => {
if (event.target === event.currentTarget) {
event.currentTarget.classList.remove("open");
}
});
document.addEventListener("keydown", event => {
if (event.key === "Escape") {
document.querySelectorAll(".modal.open").forEach(modal => modal.classList.remove("open"));
}
if (event.target.matches("input, button, a")) return;
if (event.key === "ArrowRight") {
stopPlayback();
setStage(currentStage + 1);
}
if (event.key === "ArrowLeft") {
stopPlayback();
setStage(currentStage - 1);
}
if (event.code === "Space") {
event.preventDefault();
togglePlayback();
}
});
/* --------------------------------------------------------------------------
Three.js scene
--------------------------------------------------------------------------- */
const canvas = document.getElementById("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, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#b7d4d8");
scene.fog = new THREE.Fog("#b7d4d8", 55, 115);
const camera = new THREE.PerspectiveCamera(43, window.innerWidth / window.innerHeight, 0.1, 180);
const hemisphere = new THREE.HemisphereLight("#eaf7f2", "#806e57", 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cf", 3.2);
sun.position.set(-18, 34, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -32;
sun.shadow.camera.right = 32;
sun.shadow.camera.top = 28;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 85;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#a9d9dc", 1.05);
fill.position.set(24, 12, -25);
scene.add(fill);
const material = (color, options = {}) => new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.85,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? "#000000",
emissiveIntensity: options.emissiveIntensity ?? 0
});
const materials = {
grass: material("#8fa879"),
grassDark: material("#718c63"),
earth: material("#9f8b6b"),
sand: material("#c9b58d"),
path: material("#d9c8a2"),
cream: material("#e6d9bd"),
creamLight: material("#f0e6cd"),
red: material("#9f4938"),
roof: material("#713f36"),
dark: material("#29464d"),
glass: material("#547981", { roughness: 0.35, metalness: 0.12 }),
wood: material("#765541"),
steel: material("#5e6a68", { roughness: 0.5, metalness: 0.3 }),
white: material("#f4efe1"),
black: material("#283b40")
};
function addMesh(geometry, mat, parent = scene, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, mat, x, y, z, width, height, depth, cast = true) {
const mesh = addMesh(new THREE.BoxGeometry(width, height, depth), mat, parent, x, y, z);
mesh.castShadow = cast;
return mesh;
}
/* Low-poly water */
const waterGeometry = new THREE.PlaneGeometry(130, 130, 36, 36);
waterGeometry.rotateX(-Math.PI / 2);
const water = addMesh(
waterGeometry,
material("#6ca7ad", { roughness: 0.48, metalness: 0.12 }),
scene,
0,
-0.06,
0
);
water.castShadow = false;
water.receiveShadow = true;
const waterBase = [];
const waterPhase = [];
const waterPositions = waterGeometry.attributes.position;
for (let i = 0; i < waterPositions.count; i++) {
waterBase.push(waterPositions.getY(i));
waterPhase.push((i * 0.731) % (Math.PI * 2));
}
/* Island */
const island = addMesh(
new THREE.CylinderGeometry(13.5, 14.6, 1.15, 14),
materials.earth,
scene,
0,
0.43,
0.3
);
island.scale.x = 1.08;
const islandTop = addMesh(
new THREE.CylinderGeometry(13.25, 13.4, 0.25, 14),
materials.grass,
scene,
0,
1.08,
0.3
);
islandTop.scale.x = 1.08;
/* Paths */
function addPath(points, width = 0.72) {
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const path = addBox(
scene,
materials.path,
(a[0] + b[0]) / 2,
1.225,
(a[1] + b[1]) / 2,
length + 0.12,
0.075,
width,
false
);
path.rotation.y = -Math.atan2(dz, dx);
}
}
addPath([[-12.4, 5.4], [-8, 3.65], [-4.6, 1.45], [-0.45, -0.65]]);
addPath([[-0.45, -0.65], [3.2, -0.35], [10.5, 4.8], [12.3, 6.4]]);
addPath([[-0.45, -0.65], [3.7, 3.3], [5.0, 3.7]], 0.58);
addPath([[-0.45, -0.65], [6.7, -1.25], [8.2, -1.35]], 0.58);
/* Labels */
function makeLabel(text, x, y, z, width = 3.1, color = "#17333d") {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 96;
const context = labelCanvas.getContext("2d");
context.fillStyle = "rgba(251,247,238,0.93)";
context.fillRect(8, 8, 496, 80);
context.strokeStyle = "rgba(23,51,61,0.25)";
context.lineWidth = 4;
context.strokeRect(8, 8, 496, 80);
context.fillStyle = color;
context.font = "700 30px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 256, 50);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
}));
sprite.position.set(x, y, z);
sprite.scale.set(width, width * 96 / 512, 1);
scene.add(sprite);
return sprite;
}
/* Buildings */
function addBuilding({
x,
z,
width,
depth,
height,
wall = materials.cream,
roof = materials.roof,
columns = 0,
label
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
addBox(group, wall, 0, 1.18 + height / 2, 0, width, height, depth);
const roofMesh = addMesh(
new THREE.ConeGeometry(1, 1, 4),
roof,
group,
0,
1.18 + height + 0.78,
0
);
roofMesh.rotation.y = Math.PI / 4;
roofMesh.scale.set(width * 0.56, 1.55, depth * 0.56);
const windowMat = materials.glass;
const windows = Math.max(2, Math.floor(width / 1.55));
for (let i = 0; i < windows; i++) {
const wx = -width / 2 + (i + 1) * width / (windows + 1);
addBox(group, windowMat, wx, 1.18 + height * 0.62, depth / 2 + 0.018, 0.65, 0.8, 0.05, false);
}
if (columns > 0) {
for (let i = 0; i < columns; i++) {
const cx = -width * 0.39 + i * (width * 0.78 / Math.max(1, columns - 1));
addBox(
group,
materials.creamLight,
cx,
1.18 + height / 2,
depth / 2 + 0.65,
0.28,
height,
0.28
);
}
addBox(
group,
materials.creamLight,
0,
1.18 + height + 0.08,
depth / 2 + 0.65,
width * 0.9,
0.3,
0.72
);
}
if (label) {
makeLabel(label, x, 1.18 + height + 2.0, z + depth / 2 + 0.3, Math.min(width, 4.4));
}
return group;
}
addBuilding({
x: -0.35,
z: -4.55,
width: 7.6,
depth: 4.3,
height: 2.8,
columns: 6,
label: "IMMIGRATION HALL"
});
addBuilding({
x: -8.2,
z: 1.95,
width: 3.2,
depth: 2.7,
height: 2.1,
roof: material("#80594c"),
label: "BAGGAGE"
});
addBuilding({
x: -4.8,
z: -0.25,
width: 3.0,
depth: 2.2,
height: 1.8,
wall: materials.white,
roof: material("#4d7c7e"),
label: "HEALTH"
});
addBuilding({
x: 4.55,
z: 2.15,
width: 2.9,
depth: 2.2,
height: 1.8,
wall: materials.creamLight,
roof: material("#5d8586"),
label: "REVIEW"
});
addBuilding({
x: 7.4,
z: -3.65,
width: 4.1,
depth: 3.2,
height: 2.5,
wall: materials.cream,
roof: materials.roof,
columns: 3,
label: "HEARING"
});
addBuilding({
x: 10.25,
z: 2.7,
width: 3.3,
depth: 2.7,
height: 1.9,
wall: materials.creamLight,
roof: material("#a76542"),
label: "RAIL & EXCHANGE"
});
/* Ship and dock */
const dock = addBox(scene, materials.wood, -10.5, 0.67, 5.25, 6.4, 0.32, 3.0);
dock.receiveShadow = true;
for (let i = -3; i <= 3; i++) {
addBox(scene, materials.dark, -10.5 + i * 0.85, 0.86, 5.25, 0.1, 0.08, 3.0, false);
}
const ship = new THREE.Group();
ship.position.set(-15.0, 0, 4.4);
ship.rotation.y = -0.08;
scene.add(ship);
addBox(ship, materials.red, 0, 0.72, 0.45, 4.15, 1.45, 8.3);
addBox(ship, materials.creamLight, 0, 1.52, 0.35, 3.9, 0.18, 8.0);
const bow = addMesh(new THREE.ConeGeometry(1.95, 2.5, 4), materials.red, ship, 0, 0.82, -4.75);
bow.rotation.x = -Math.PI / 2;
bow.rotation.z = Math.PI / 4;
bow.scale.x = 1.05;
addBox(ship, materials.white, 0, 2.25, 1.8, 2.7, 1.25, 3.5);
addBox(ship, materials.dark, 0, 2.43, 3.56, 2.15, 0.58, 0.05, false);
addMesh(new THREE.CylinderGeometry(0.42, 0.52, 2.1, 8), materials.red, ship, 0, 3.4, 0.8);
addMesh(new THREE.CylinderGeometry(0.07, 0.1, 5.2, 6), materials.wood, ship, 0, 4.0, -1.0);
addBox(ship, materials.cream, 0, 4.9, -1.0, 2.6, 0.12, 0.12);
makeLabel("ARRIVAL SHIP", -14.7, 5.8, 4.5, 3.3, "#9f4938");
/* Rail platform and small carriage */
addBox(scene, materials.wood, 11.8, 1.31, 5.1, 4.5, 0.18, 1.35);
for (let i = 0; i < 2; i++) {
addBox(scene, materials.dark, 11.8, 1.43, 4.72 + i * 0.62, 4.5, 0.06, 0.07, false);
}
addBox(scene, materials.red, 13.0, 2.05, 5.1, 2.2, 1.2, 1.25);
addBox(scene, materials.glass, 13.0, 2.18, 5.74, 1.65, 0.42, 0.04, false);
/* Trees and landscaping */
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 1.18, z);
group.scale.setScalar(scale);
scene.add(group);
addMesh(new THREE.CylinderGeometry(0.11, 0.16, 1.25, 6), materials.wood, group, 0, 0.62, 0);
addMesh(new THREE.ConeGeometry(0.78, 1.9, 7), materials.grassDark, group, 0, 1.7, 0);
addMesh(new THREE.ConeGeometry(0.58, 1.55, 7), materials.grass, group, 0, 2.45, 0);
}
[
[-11.1, -4.8, 1.1], [-9.4, -6.1, .9], [-6.9, -5.7, 1.15],
[-4.2, -6.2, .95], [-2.2, -7.2, 1.15], [2.0, -7.4, 1.0],
[5.2, -6.0, 1.2], [9.8, -6.3, 1.0], [11.8, -4.9, .85],
[-10.9, 7.2, .9], [-7.0, 6.4, 1.15], [-2.6, 6.4, .9],
[1.0, 6.7, 1.1], [4.1, 6.5, .8], [7.0, 6.4, 1.05]
].forEach(item => addTree(...item));
/* Fictional low-poly characters */
const skinMaterial = material("#c99168");
const trouserMaterial = material("#4b5555");
const shoeMaterial = material("#28383b");
const characterMeshes = [];
function addCharacter(character, index) {
const group = new THREE.Group();
scene.add(group);
const coat = material(character.color);
const body = addMesh(
new THREE.CylinderGeometry(0.29, 0.37, 0.82, 6),
coat,
group,
0,
0.76,
0
);
addMesh(new THREE.SphereGeometry(0.27, 7, 5), skinMaterial, group, 0, 1.35, 0);
addMesh(new THREE.CylinderGeometry(0.31, 0.31, 0.08, 8), coat, group, 0, 1.57, 0);
const leftLeg = addMesh(new THREE.CylinderGeometry(0.085, 0.09, 0.48, 5), trouserMaterial, group, -0.12, 0.25, 0);
const rightLeg = addMesh(new THREE.CylinderGeometry(0.085, 0.09, 0.48, 5), trouserMaterial, group, 0.12, 0.25, 0);
addBox(group, shoeMaterial, -0.12, 0.02, 0.06, 0.17, 0.10, 0.27);
addBox(group, shoeMaterial, 0.12, 0.02, 0.06, 0.17, 0.10, 0.27);
const leftArm = addMesh(new THREE.CylinderGeometry(0.07, 0.08, 0.62, 5), coat, group, -0.35, 0.82, 0);
const rightArm = addMesh(new THREE.CylinderGeometry(0.07, 0.08, 0.62, 5), coat, group, 0.35, 0.82, 0);
leftArm.rotation.z = -0.14;
rightArm.rotation.z = 0.14;
const ring = addMesh(
new THREE.RingGeometry(0.43, 0.52, 20),
new THREE.MeshBasicMaterial({
color: "#fff2b8",
transparent: true,
opacity: 0.9,
side: THREE.DoubleSide
}),
group,
0,
0.035,
0
);
ring.rotation.x = -Math.PI / 2;
ring.castShadow = false;
ring.receiveShadow = false;
const label = makeLabel(character.id, 0, 2.18, 0, 0.68, "#17333d");
label.material.depthTest = false;
label.renderOrder = 4;
group.position.set(-12.1 + index * 0.55, 1.32, 5.35);
characterMeshes.push({
group,
body,
leftLeg,
rightLeg,
leftArm,
rightArm,
ring,
label,
target: group.position.clone(),
index
});
}
characters.forEach(addCharacter);
/* --------------------------------------------------------------------------
Direct camera controls: orbit, pan-free focus, and zoom
--------------------------------------------------------------------------- */
const cameraState = {
theta: 0.64,
phi: 0.91,
radius: 39,
dragging: false,
previousX: 0,
previousY: 0
};
const defaultTarget = new THREE.Vector3(0, 1.2, 0.7);
const focusTarget = defaultTarget.clone();
const smoothTarget = defaultTarget.clone();
canvas.addEventListener("pointerdown", event => {
cameraState.dragging = true;
cameraState.previousX = event.clientX;
cameraState.previousY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!cameraState.dragging) return;
const dx = event.clientX - cameraState.previousX;
const dy = event.clientY - cameraState.previousY;
cameraState.previousX = event.clientX;
cameraState.previousY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi + dy * 0.0045, 0.35, 1.42);
});
function endDrag(event) {
cameraState.dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.025,
14,
64
);
}, { passive: false });
document.getElementById("overviewBtn").addEventListener("click", () => {
focusMode = false;
document.getElementById("followBtn").textContent = "Follow case";
cameraState.theta = 0.64;
cameraState.phi = 0.91;
cameraState.radius = 39;
});
document.getElementById("followBtn").addEventListener("click", () => {
focusMode = !focusMode;
document.getElementById("followBtn").textContent = focusMode ? "Follow: on" : "Follow case";
if (focusMode) {
focusTarget.copy(characterMeshes[activeCharacter].position);
cameraState.radius = Math.min(cameraState.radius, 22);
}
});
/* --------------------------------------------------------------------------
Resize and animation
--------------------------------------------------------------------------- */
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let frame = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
// Gentle low-poly water motion.
for (let i = 0; i < waterPositions.count; i++) {
waterPositions.setY(
i,
waterBase[i] + Math.sin(time * 0.55 + waterPhase[i]) * 0.035
);
}
waterPositions.needsUpdate = true;
if (frame % 8 === 0) waterGeometry.computeVertexNormals();
// Characters move toward the location associated with the current stage.
characterMeshes.forEach(character => {
const difference = character.target.clone().sub(character.group.position);
const distance = difference.length();
if (distance > 0.03) {
character.group.position.lerp(character.target, 1 - Math.pow(0.0015, delta));
}
const walking = distance > 0.22;
const stride = walking ? Math.sin(time * 9 + character.index) * 0.45 : 0;
character.leftLeg.rotation.x = stride;
character.rightLeg.rotation.x = -stride;
character.leftArm.rotation.x = -stride * 0.65;
character.rightArm.rotation.x = stride * 0.65;
character.group.position.y = character.target.y + Math.sin(time * 7 + character.index) * 0.018;
character.ring.visible = character.index === activeCharacter;
character.ring.rotation.z = time * 0.35;
});
// Camera focus and orbit.
if (focusMode) {
focusTarget.copy(characterMeshes[activeCharacter].position);
focusTarget.y = 1.25;
}
smoothTarget.lerp(focusMode ? focusTarget : defaultTarget, 1 - Math.pow(0.003, delta));
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
smoothTarget.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
smoothTarget.y + cameraState.radius * Math.cos(cameraState.phi),
smoothTarget.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(smoothTarget);
renderer.render(scene, camera);
frame++;
}
setStage(0);
updateCharacterTargets();
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
setTimeout(() => document.getElementById("loading").remove(), 500);
});
</script>
</body>
</html>
```