Prompt specification
Build or customize the Three.js 3D scene "Package-origin inference sorting desk" 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: Package-origin inference sorting desk
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/package-origin-inference-sorting-desk-x1767
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Bayesian updates from evidence. Compose fictional packages from two suppliers with different label frequencies; show how one observed label changes source probabilities without treating it as certain identification. Voxel style.
Working Three.js Starter (package-origin-inference-sorting-desk-x1767):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Parcel Origins — Bayesian Evidence Lab</title>
<style>
:root {
--bg: #071218;
--panel: rgba(9, 24, 31, 0.91);
--panel-solid: #0a1a21;
--line: rgba(157, 213, 219, 0.16);
--text: #e7f4f2;
--muted: #89a6aa;
--aster: #58e0cf;
--birch: #ff7b78;
--cobalt: #4d8dff;
--ember: #ffa14f;
--jade: #57d79a;
--cyan: #68e6df;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 72% 34%, rgba(38, 92, 98, 0.18), transparent 34%),
radial-gradient(circle at 22% 75%, rgba(37, 67, 82, 0.22), transparent 32%),
linear-gradient(145deg, #071218 0%, #091920 52%, #061015 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.topbar {
position: fixed;
z-index: 5;
top: 0;
left: 0;
right: 0;
height: 82px;
padding: 18px 24px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: none;
background: linear-gradient(to bottom, rgba(5, 15, 20, 0.93), transparent);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 42px;
height: 42px;
position: relative;
transform: rotate(-4deg);
}
.brand-mark i {
position: absolute;
display: block;
background: var(--cyan);
box-shadow: 0 0 18px rgba(104, 230, 223, 0.18);
}
.brand-mark i:nth-child(1) {
width: 18px;
height: 18px;
left: 0;
top: 0;
}
.brand-mark i:nth-child(2) {
width: 18px;
height: 18px;
right: 0;
top: 0;
opacity: 0.72;
}
.brand-mark i:nth-child(3) {
width: 18px;
height: 18px;
right: 0;
bottom: 0;
opacity: 0.44;
}
.brand-mark i:nth-child(4) {
width: 18px;
height: 18px;
left: 0;
bottom: 0;
opacity: 0.25;
}
.eyebrow {
margin: 0 0 3px;
color: var(--cyan);
font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(20px, 2vw, 27px);
line-height: 1;
letter-spacing: -0.035em;
font-weight: 750;
}
.model-badge {
padding: 8px 11px;
border: 1px solid var(--line);
background: rgba(10, 28, 34, 0.74);
color: #a8c6c7;
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.model-badge::before {
content: "";
display: inline-block;
width: 6px;
height: 6px;
margin-right: 8px;
background: var(--cyan);
box-shadow: 0 0 9px var(--cyan);
vertical-align: 1px;
}
.panel {
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
}
.control-panel {
position: fixed;
z-index: 6;
top: 91px;
left: 24px;
width: 324px;
max-height: calc(100vh - 300px);
overflow: auto;
padding: 19px;
scrollbar-width: thin;
scrollbar-color: rgba(104, 230, 223, 0.28) transparent;
}
.control-panel h2 {
margin: 4px 0 7px;
font-size: 21px;
letter-spacing: -0.035em;
}
.intro {
margin: 0 0 16px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.suppliers {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 19px;
}
.supplier {
min-width: 0;
padding: 10px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.025);
}
.supplier-name {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 5px;
font-size: 11px;
font-weight: 750;
}
.swatch {
width: 10px;
height: 10px;
flex: 0 0 auto;
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
.aster-color {
color: var(--aster);
}
.birch-color {
color: var(--birch);
}
.supplier small {
display: block;
color: var(--muted);
font-size: 9px;
line-height: 1.4;
}
.section-title {
display: flex;
align-items: center;
gap: 9px;
margin: 16px 0 9px;
color: #c9dddd;
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.section-title span {
color: var(--cyan);
}
.evidence-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.evidence-button {
min-width: 0;
padding: 10px 8px 9px;
border: 1px solid var(--line);
border-radius: 0;
background: rgba(255, 255, 255, 0.025);
cursor: pointer;
text-align: left;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.evidence-button:hover {
transform: translateY(-2px);
border-color: rgba(255, 255, 255, 0.3);
}
.evidence-button.active {
border-color: var(--evidence-color);
background: color-mix(in srgb, var(--evidence-color) 11%, transparent);
box-shadow: inset 0 -2px 0 var(--evidence-color);
}
.label-line {
display: flex;
align-items: center;
gap: 6px;
font-size: 11px;
font-weight: 750;
}
.label-dot {
width: 8px;
height: 8px;
background: var(--evidence-color);
box-shadow: 0 0 9px color-mix(in srgb, var(--evidence-color) 60%, transparent);
}
.evidence-button small {
display: block;
margin-top: 6px;
color: var(--muted);
font: 600 8px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.frequency-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.frequency-table th {
padding: 7px 5px;
color: #718d92;
text-align: right;
font-weight: 650;
border-bottom: 1px solid var(--line);
}
.frequency-table th:first-child,
.frequency-table td:first-child {
text-align: left;
}
.frequency-table td {
padding: 7px 5px;
text-align: right;
color: #b4cacc;
border-bottom: 1px solid rgba(157, 213, 219, 0.07);
}
.frequency-table tr.active td {
color: #f1ffff;
background: rgba(104, 230, 223, 0.07);
}
.prior-box {
padding: 11px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.022);
}
.prior-header {
display: flex;
justify-content: space-between;
gap: 8px;
margin-bottom: 10px;
font-size: 10px;
}
.prior-values {
color: var(--cyan);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 0;
appearance: none;
background: linear-gradient(
to right,
var(--aster) 0%,
var(--aster) var(--fill, 50%),
rgba(255, 255, 255, 0.11) var(--fill, 50%),
rgba(255, 255, 255, 0.11) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 13px;
height: 13px;
appearance: none;
border: 2px solid #071218;
border-radius: 0;
background: var(--cyan);
box-shadow: 0 0 0 1px var(--cyan);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid #071218;
border-radius: 0;
background: var(--cyan);
box-shadow: 0 0 0 1px var(--cyan);
}
.prior-scale {
display: flex;
justify-content: space-between;
margin-top: 8px;
color: #6f898d;
font: 600 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.model-note {
margin: 14px 0 0;
padding: 11px 12px;
border-left: 2px solid var(--cyan);
background: rgba(104, 230, 223, 0.055);
color: #9fb9bc;
font-size: 10px;
line-height: 1.55;
}
.model-note strong {
color: #d9eeee;
}
.posterior-panel {
position: fixed;
z-index: 6;
left: 370px;
right: 24px;
bottom: 24px;
padding: 17px 19px;
display: grid;
grid-template-columns: minmax(360px, 1.15fr) minmax(320px, 1fr);
gap: 21px;
}
.posterior-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.posterior-header h2 {
margin: 0;
font-size: 15px;
letter-spacing: -0.02em;
}
.observation-pill {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 6px 8px;
border: 1px solid rgba(77, 141, 255, 0.35);
color: #bcd2ff;
background: rgba(77, 141, 255, 0.08);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.observation-pill i {
width: 6px;
height: 6px;
background: var(--cobalt);
box-shadow: 0 0 9px var(--cobalt);
}
.posterior-cards {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.posterior-card {
position: relative;
padding: 12px;
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.022);
overflow: hidden;
}
.posterior-card.leader {
border-color: color-mix(in srgb, var(--source-color) 44%, transparent);
background: color-mix(in srgb, var(--source-color) 7%, transparent);
}
.card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 10px;
}
.card-name {
display: flex;
align-items: center;
gap: 7px;
color: #c7d9da;
font-size: 10px;
font-weight: 750;
}
.card-value {
color: var(--source-color);
font: 800 21px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: -0.06em;
}
.prob-track {
height: 7px;
background: rgba(255, 255, 255, 0.075);
overflow: hidden;
}
.prob-fill {
width: 50%;
height: 100%;
background: var(--source-color);
box-shadow: 0 0 14px color-mix(in srgb, var(--source-color) 55%, transparent);
transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}
.card-caption {
margin-top: 7px;
color: #708b8f;
font: 600 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.formula-label {
margin-bottom: 6px;
color: var(--cyan);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.formula {
min-height: 42px;
margin-bottom: 10px;
color: #c0d5d7;
font: 600 11px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
overflow-wrap: anywhere;
}
.interpretation {
margin: 0;
padding-left: 10px;
border-left: 2px solid var(--cyan);
color: #9bb5b8;
font-size: 10px;
line-height: 1.55;
}
.interpretation strong {
color: #dceeed;
}
.scan-button {
margin-top: 11px;
padding: 8px 11px;
border: 1px solid rgba(104, 230, 223, 0.3);
border-radius: 0;
background: rgba(104, 230, 223, 0.07);
color: var(--cyan);
cursor: pointer;
font: 750 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.scan-button:hover {
background: rgba(104, 230, 223, 0.13);
}
.camera-tools {
position: fixed;
z-index: 7;
right: 24px;
top: 92px;
display: flex;
gap: 5px;
}
.camera-tools button {
width: 34px;
height: 34px;
padding: 0;
border: 1px solid var(--line);
border-radius: 0;
background: rgba(9, 24, 31, 0.8);
color: #a9c2c4;
cursor: pointer;
font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.camera-tools button:hover {
border-color: var(--cyan);
color: var(--cyan);
}
.scene-caption {
position: fixed;
z-index: 4;
right: 24px;
bottom: 258px;
color: rgba(173, 205, 207, 0.6);
font: 600 9px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
text-align: right;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 1000px) {
.control-panel {
width: 296px;
}
.posterior-panel {
left: 338px;
grid-template-columns: 1fr;
gap: 12px;
}
.formula {
min-height: 0;
}
.scene-caption {
display: none;
}
}
@media (max-width: 760px) {
.topbar {
height: 68px;
padding: 13px 12px;
}
.brand-mark {
width: 34px;
height: 34px;
}
.brand-mark i {
width: 15px;
height: 15px;
}
.model-badge {
display: none;
}
.control-panel {
top: 74px;
left: 12px;
right: 12px;
width: auto;
max-height: 37vh;
padding: 14px;
}
.control-panel h2 {
font-size: 18px;
}
.intro {
margin-bottom: 11px;
}
.suppliers {
margin-bottom: 10px;
}
.posterior-panel {
left: 12px;
right: 12px;
bottom: 12px;
padding: 13px;
gap: 10px;
}
.posterior-header {
margin-bottom: 9px;
}
.posterior-header h2 {
font-size: 13px;
}
.posterior-card {
padding: 9px;
}
.card-value {
font-size: 17px;
}
.card-caption,
.formula,
.camera-tools,
.model-note {
display: none;
}
.interpretation {
font-size: 9px;
}
.scan-button {
margin-top: 8px;
}
}
@media (max-width: 430px) {
.posterior-cards {
gap: 6px;
}
.card-name {
font-size: 9px;
}
.observation-pill {
padding: 5px;
font-size: 8px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel warehouse showing parcels from two suppliers"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div>
<p class="eyebrow">Evidence Lab / Bayesian Logistics</p>
<h1>Parcel Origins</h1>
</div>
</div>
<div class="model-badge">Single-label model · Live</div>
</header>
<aside class="control-panel panel" aria-label="Evidence controls">
<p class="eyebrow">Fictional supply network</p>
<h2>Who sent the parcel?</h2>
<p class="intro">
Two suppliers use overlapping freight labels. One scanner observation changes
the odds, but it does not identify the sender by itself.
</p>
<div class="suppliers">
<div class="supplier">
<div class="supplier-name aster-color">
<span class="swatch"></span>
Aster Freight
</div>
<small>Teal parcels<br />10 representative labels</small>
</div>
<div class="supplier">
<div class="supplier-name birch-color">
<span class="swatch"></span>
Birch Depot
</div>
<small>Coral parcels<br />10 representative labels</small>
</div>
</div>
<div class="section-title"><span>01</span> Observed label</div>
<div class="evidence-grid">
<button
class="evidence-button active"
data-label="cobalt"
style="--evidence-color: var(--cobalt)"
aria-pressed="true"
>
<span class="label-line"><i class="label-dot"></i>Cobalt</span>
<small>1/10 · 5/10</small>
</button>
<button
class="evidence-button"
data-label="ember"
style="--evidence-color: var(--ember)"
aria-pressed="false"
>
<span class="label-line"><i class="label-dot"></i>Ember</span>
<small>3/10 · 2/10</small>
</button>
<button
class="evidence-button"
data-label="jade"
style="--evidence-color: var(--jade)"
aria-pressed="false"
>
<span class="label-line"><i class="label-dot"></i>Jade</span>
<small>6/10 · 3/10</small>
</button>
</div>
<table class="frequency-table" aria-label="Label frequencies by supplier">
<thead>
<tr>
<th>LABEL</th>
<th>ASTER</th>
<th>BIRCH</th>
</tr>
</thead>
<tbody>
<tr data-row="cobalt" class="active">
<td>Cobalt</td><td>10%</td><td>50%</td>
</tr>
<tr data-row="ember">
<td>Ember</td><td>30%</td><td>20%</td>
</tr>
<tr data-row="jade">
<td>Jade</td><td>60%</td><td>30%</td>
</tr>
</tbody>
</table>
<div class="section-title"><span>02</span> Prior source odds</div>
<div class="prior-box">
<div class="prior-header">
<span>Aster / Birch</span>
<span class="prior-values" id="priorValues">50% / 50%</span>
</div>
<input
id="priorSlider"
type="range"
min="1"
max="99"
step="1"
value="50"
aria-label="Prior probability that Aster Freight supplied the parcel"
/>
<div class="prior-scale">
<span>ASTER 1%</span>
<span>BIRCH 99%</span>
</div>
</div>
<div class="model-note">
<strong>One observation. No identity lock.</strong><br />
Frequencies are fixed for this fictional network. Posteriors describe which
supplier is more plausible, not a guaranteed origin.
</div>
</aside>
<div class="camera-tools" aria-label="Camera controls">
<button id="zoomIn" title="Zoom in" aria-label="Zoom in">+</button>
<button id="zoomOut" title="Zoom out" aria-label="Zoom out">−</button>
<button id="resetView" title="Reset view" aria-label="Reset view">↺</button>
</div>
<div class="scene-caption">
Drag to orbit · Wheel to zoom · Double-click to reset<br />
Ten representative parcels per supplier
</div>
<section class="posterior-panel panel" aria-live="polite">
<div class="posterior-main">
<div class="posterior-header">
<h2>Posterior origin probability</h2>
<div class="observation-pill">
<i id="observationDot"></i>
Evidence: <span id="observationName">Cobalt</span>
</div>
</div>
<div class="posterior-cards">
<article class="posterior-card" id="cardA" style="--source-color: var(--aster)">
<div class="card-top">
<div class="card-name">
<span class="swatch aster-color"></span>
Aster Freight
</div>
<div class="card-value" id="posteriorA">16.7%</div>
</div>
<div class="prob-track">
<div class="prob-fill" id="fillA"></div>
</div>
<div class="card-caption" id="captionA">P(Aster | cobalt)</div>
</article>
<article class="posterior-card leader" id="cardB" style="--source-color: var(--birch)">
<div class="card-top">
<div class="card-name">
<span class="swatch birch-color"></span>
Birch Depot
</div>
<div class="card-value" id="posteriorB">83.3%</div>
</div>
<div class="prob-track">
<div class="prob-fill" id="fillB"></div>
</div>
<div class="card-caption" id="captionB">P(Birch | cobalt)</div>
</article>
</div>
</div>
<div class="posterior-explain">
<div class="formula-label">Bayes update</div>
<div class="formula" id="formula"></div>
<p class="interpretation" id="interpretation"></p>
<button class="scan-button" id="scanNext">Scan next label ↻</button>
</div>
</section>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const COLORS = {
background: 0x071218,
floor: 0x0a1a20,
cyan: 0x68e6df,
pale: 0xd9eee9,
dark: 0x071218,
aster: 0x58e0cf,
birch: 0xff7b78,
cobalt: 0x4d8dff,
ember: 0xffa14f,
jade: 0x57d79a
};
const LABELS = {
cobalt: {
name: "Cobalt",
color: COLORS.cobalt,
css: "#4d8dff",
aster: 0.10,
birch: 0.50,
counts: "1/10 · 5/10"
},
ember: {
name: "Ember",
color: COLORS.ember,
css: "#ffa14f",
aster: 0.30,
birch: 0.20,
counts: "3/10 · 2/10"
},
jade: {
name: "Jade",
color: COLORS.jade,
css: "#57d79a",
aster: 0.60,
birch: 0.30,
counts: "6/10 · 3/10"
}
};
const state = {
evidence: "cobalt",
priorAster: 0.5,
posteriorAster: 1 / 6,
posteriorBirch: 5 / 6,
displayedAster: 1 / 6,
displayedBirch: 5 / 6,
centerScale: 1
};
const dom = (id) => document.getElementById(id);
const sceneContainer = dom("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(COLORS.background, 0);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute("aria-label", "Voxel warehouse. Drag to orbit and scroll to zoom.");
sceneContainer.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(COLORS.background, 12, 27);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraState = {
target: new THREE.Vector3(0, 0.45, 0),
theta: 0.25,
phi: 1.02,
radius: 11.8
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xbcecf0, 0x14232a, 1.65);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xe5ffff, 2.4);
keyLight.position.set(5.5, 10, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0007;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5a89b3, 1.1);
rimLight.position.set(-7, 4, -5);
scene.add(rimLight);
const world = new THREE.Group();
scene.add(world);
const packages = [];
let towerAster;
let towerBirch;
let centerPackage;
let centerLabelRoot;
let scannerLine;
let scannerLight;
let scannerPlaque;
let asteroidPlaque;
let birchPlaque;
const pixelGeometry = new THREE.BoxGeometry(0.032, 0.032, 0.016);
const pixelDarkMaterial = new THREE.MeshStandardMaterial({
color: 0x102027,
roughness: 0.85,
metalness: 0.02
});
const pixelPatterns = {
cobalt: [
[1, 1, 1],
[1, 0, 0],
[1, 0, 0],
[1, 0, 0],
[1, 1, 1]
],
ember: [
[1, 1, 1],
[1, 0, 0],
[1, 1, 0],
[1, 0, 0],
[1, 1, 1]
],
jade: [
[0, 0, 1],
[0, 0, 1],
[0, 0, 1],
[1, 0, 1],
[1, 1, 1]
]
};
function addFrontGlyph(parent, label, z, centerY, pixelSize = 0.032) {
const pattern = pixelPatterns[label];
for (let row = 0; row < pattern.length; row++) {
for (let col = 0; col < pattern[row].length; col++) {
if (!pattern[row][col]) continue;
const pixel = new THREE.Mesh(pixelGeometry, pixelDarkMaterial);
pixel.scale.set(pixelSize / 0.032, pixelSize / 0.032, 1);
pixel.position.set(
(col - 1) * pixelSize,
centerY + (2 - row) * pixelSize,
z
);
parent.add(pixel);
}
}
}
function makePlaque(title, subtitle, accent, scaleX = 2.25, scaleY = 0.63) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 176;
const ctx = canvas.getContext("2d");
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false,
depthTest: true
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(scaleX, scaleY, 1);
sprite.renderOrder = 8;
function draw(nextTitle, nextSubtitle) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(6, 18, 24, 0.94)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 7;
ctx.strokeRect(4, 4, canvas.width - 8, canvas.height - 8);
ctx.fillStyle = accent;
ctx.fillRect(25, 35, 13, 13);
ctx.fillRect(44, 35, 13, 13);
ctx.textBaseline = "top";
ctx.font = "700 49px monospace";
ctx.fillStyle = "#e8f7f4";
ctx.fillText(nextTitle.toUpperCase(), 79, 27);
ctx.font = "600 23px monospace";
ctx.fillStyle = "#8faeb1";
ctx.fillText(nextSubtitle.toUpperCase(), 28, 111);
texture.needsUpdate = true;
}
draw(title, subtitle);
return { sprite, set: draw };
}
function createFloor() {
const base = new THREE.Mesh(
new THREE.BoxGeometry(13.4, 0.22, 9.8),
new THREE.MeshStandardMaterial({
color: 0x061116,
roughness: 0.96
})
);
base.position.y = -0.48;
base.receiveShadow = true;
world.add(base);
const nx = 18;
const nz = 13;
const spacing = 0.74;
const tileSize = 0.69;
const geometry = new THREE.BoxGeometry(tileSize, 0.08, tileSize);
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94,
metalness: 0.02
});
const tiles = new THREE.InstancedMesh(geometry, material, nx * nz);
tiles.receiveShadow = true;
const matrix = new THREE.Matrix4();
const color = new THREE.Color();
let index = 0;
for (let iz = 0; iz < nz; iz++) {
for (let ix = 0; ix < nx; ix++) {
const x = (ix - (nx - 1) / 2) * spacing;
const z = (iz - (nz - 1) / 2) * spacing;
matrix.makeTranslation(x, -0.31, z);
tiles.setMatrixAt(index, matrix);
const shade = ((ix * 7 + iz * 11) % 5) * 0.006;
color.setRGB(0.035 + shade, 0.087 + shade, 0.102 + shade);
tiles.setColorAt(index, color);
index++;
}
}
tiles.instanceMatrix.needsUpdate = true;
if (tiles.instanceColor) tiles.instanceColor.needsUpdate = true;
world.add(tiles);
const grid = new THREE.GridHelper(13, 18, 0x18343b, 0x10262d);
grid.position.y = -0.265;
grid.material.transparent = true;
grid.material.opacity = 0.28;
world.add(grid);
}
function createParcel(sourceColor, label, variant = 0, size = {}) {
const width = size.width ?? 0.49;
const height = size.height ?? 0.45;
const depth = size.depth ?? 0.47;
const group = new THREE.Group();
const bodyGeometry = new THREE.BoxGeometry(width, height, depth);
const bodyMaterial = new THREE.MeshStandardMaterial({
color: sourceColor,
roughness: 0.76,
metalness: 0.03,
emissive: 0x000000,
emissiveIntensity: 0
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = height / 2;
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(bodyGeometry),
new THREE.LineBasicMaterial({
color: 0x10272b,
transparent: true,
opacity: 0.65
})
);
edges.position.copy(body.position);
group.add(edges);
const tapeMaterial = new THREE.MeshStandardMaterial({
color: variant === 0 ? 0xd7e6d7 : 0x25343a,
roughness: 0.85
});
if (variant === 0) {
const tape = new THREE.Mesh(
new THREE.BoxGeometry(0.075, 0.018, depth + 0.008),
tapeMaterial
);
tape.position.y = height + 0.007;
tape.castShadow = true;
group.add(tape);
} else {
const tape = new THREE.Mesh(
new THREE.BoxGeometry(width + 0.008, 0.018, 0.075),
tapeMaterial
);
tape.position.y = height + 0.007;
tape.castShadow = true;
group.add(tape);
}
const badgeMaterial = new THREE.MeshStandardMaterial({
color: LABELS[label].color,
roughness: 0.7,
emissive: LABELS[label].color,
emissiveIntensity: 0.08
});
const badge = new THREE.Mesh(
new THREE.BoxGeometry(0.17, 0.17, 0.018),
badgeMaterial
);
badge.position.set(0, height * 0.49, depth / 2 + 0.012);
group.add(badge);
addFrontGlyph(group, label, depth / 2 + 0.025, height * 0.49, 0.026);
return {
group,
bodyMaterial,
label,
baseColor: new THREE.Color(sourceColor),
baseY: group.position.y,
phase: packages.length * 0.73
};
}
function createDock(sourceName, x, sourceColor, labelSequence, variant) {
const dock = new THREE.Group();
dock.position.set(x, 0, -1.55);
world.add(dock);
const platform = new THREE.Mesh(
new THREE.BoxGeometry(3.38, 0.26, 2.28),
new THREE.MeshStandardMaterial({
color: new THREE.Color(sourceColor).multiplyScalar(0.25),
roughness: 0.85,
emissive: new THREE.Color(sourceColor).multiplyScalar(0.04)
})
);
platform.position.y = -0.18;
platform.receiveShadow = true;
platform.castShadow = true;
dock.add(platform);
const trim = new THREE.Mesh(
new THREE.BoxGeometry(3.46, 0.035, 2.36),
new THREE.MeshStandardMaterial({
color: sourceColor,
emissive: sourceColor,
emissiveIntensity: 0.16,
roughness: 0.55
})
);
trim.position.y = -0.035;
dock.add(trim);
const positions = [];
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 5; col++) {
positions.push({
x: (col - 2) * 0.63,
z: row === 0 ? -0.51 : 0.28
});
}
}
labelSequence.forEach((label, i) => {
const parcel = createParcel(sourceColor, label, variant);
parcel.group.position.set(
positions[i].x,
-0.05,
positions[i].z
);
parcel.baseY = parcel.group.position.y;
dock.add(parcel.group);
packages.push(parcel);
});
const plaque = makePlaque(
sourceName,
"10 representative parcels",
sourceColor === COLORS.aster ? "#58e0cf" : "#ff7b78",
2.5,
0.69
);
plaque.sprite.position.set(0, 1.14, -2.65);
dock.add(plaque.sprite);
const light = new THREE.PointLight(sourceColor, 5.5, 5.5, 2);
light.position.set(x, 3.1, -0.6);
world.add(light);
}
function createScanner() {
const platform = new THREE.Mesh(
new THREE.BoxGeometry(2.35, 0.28, 1.9),
new THREE.MeshStandardMaterial({
color: 0x13272d,
roughness: 0.76,
metalness: 0.12
})
);
platform.position.set(0, -0.13, 0.05);
platform.castShadow = true;
platform.receiveShadow = true;
world.add(platform);
const platformTrim = new THREE.Mesh(
new THREE.BoxGeometry(2.42, 0.035, 1.97),
new THREE.MeshStandardMaterial({
color: 0x68e6df,
emissive: 0x68e6df,
emissiveIntensity: 0.2
})
);
platformTrim.position.set(0, 0.015, 0.05);
world.add(platformTrim);
const frameMaterial = new THREE.MeshStandardMaterial({
color: 0x31515a,
roughness: 0.52,
metalness: 0.35,
emissive: 0x102b30,
emissiveIntensity: 0.3
});
[-1.05, 1.05].forEach((x) => {
const post = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 1.45, 0.12),
frameMaterial
);
post.position.set(x, 0.735, -0.52);
post.castShadow = true;
world.add(post);
});
const topBar = new THREE.Mesh(
new THREE.BoxGeometry(2.22, 0.12, 0.12),
frameMaterial
);
topBar.position.set(0, 1.46, -0.52);
topBar.castShadow = true;
world.add(topBar);
centerPackage = createParcel(
0xcddbd2,
state.evidence,
0,
{ width: 0.72, height: 0.58, depth: 0.62 }
);
centerPackage.group.position.set(0, 0.03, 0.12);
centerPackage.baseY = 0.03;
world.add(centerPackage.group);
// Replace the decorative source label on the scanned parcel with a large badge.
centerPackage.group.children.forEach((child) => {
if (child.isMesh && child.geometry?.type === "BoxGeometry") {
const dimensions = child.geometry.parameters;
if (dimensions.width === 0.17 && dimensions.height === 0.17) {
child.visible = false;
}
}
});
centerLabelRoot = new THREE.Group();
centerPackage.group.add(centerLabelRoot);
scannerLine = new THREE.Mesh(
new THREE.BoxGeometry(1.38, 0.022, 1.08),
new THREE.MeshBasicMaterial({
color: LABELS[state.evidence].color,
transparent: true,
opacity: 0.35,
depthWrite: false
})
);
scannerLine.position.set(0, 0.2, 0.1);
world.add(scannerLine);
scannerLight = new THREE.PointLight(LABELS[state.evidence].color, 3.2, 3.6, 2);
scannerLight.position.set(0, 0.7, 0.1);
world.add(scannerLight);
scannerPlaque = makePlaque(
"Evidence",
"cobalt label observed",
LABELS[state.evidence].css,
1.85,
0.52
);
scannerPlaque.sprite.position.set(0, 1.82, -0.45);
world.add(scannerPlaque.sprite);
}
function rebuildCenterLabel() {
while (centerLabelRoot.children.length) {
centerLabelRoot.remove(centerLabelRoot.children[0]);
}
const badge = new THREE.Mesh(
new THREE.BoxGeometry(0.255, 0.255, 0.02),
new THREE.MeshStandardMaterial({
color: LABELS[state.evidence].color,
roughness: 0.68,
emissive: LABELS[state.evidence].color,
emissiveIntensity: 0.12
})
);
badge.position.set(0, 0.285, 0.326);
centerLabelRoot.add(badge);
addFrontGlyph(centerLabelRoot, state.evidence, 0.342, 0.285, 0.039);
const topBadge = new THREE.Mesh(
new THREE.BoxGeometry(0.16, 0.018, 0.2),
new THREE.MeshStandardMaterial({
color: LABELS[state.evidence].color,
emissive: LABELS[state.evidence].color,
emissiveIntensity: 0.16
})
);
topBadge.position.set(0.1, 0.593, 0);
centerLabelRoot.add(topBadge);
}
function createProbabilityTower(sourceName, x, sourceColor, cssColor) {
const group = new THREE.Group();
group.position.set(x, 0, 2.48);
world.add(group);
const base = new THREE.Mesh(
new THREE.BoxGeometry(1.22, 0.3, 1.16),
new THREE.MeshStandardMaterial({
color: 0x102229,
roughness: 0.82
})
);
base.position.y = -0.12;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const baseTrim = new THREE.Mesh(
new THREE.BoxGeometry(1.28, 0.03, 1.22),
new THREE.MeshStandardMaterial({
color: sourceColor,
emissive: sourceColor,
emissiveIntensity: 0.2
})
);
baseTrim.position.y = 0.035;
group.add(baseTrim);
const ghost = new THREE.Mesh(
new THREE.BoxGeometry(0.76, 2.0, 0.5),
new THREE.MeshBasicMaterial({
color: sourceColor,
transparent: true,
opacity: 0.045,
depthWrite: false
})
);
ghost.position.y = 1.03;
group.add(ghost);
const barPivot = new THREE.Group();
barPivot.position.y = 0.05;
group.add(barPivot);
const barGeometry = new THREE.BoxGeometry(0.72, 2.0, 0.46);
barGeometry.translate(0, 1, 0);
const bar = new THREE.Mesh(
barGeometry,
new THREE.MeshStandardMaterial({
color: sourceColor,
roughness: 0.55,
metalness: 0.05,
emissive: sourceColor,
emissiveIntensity: 0.12
})
);
bar.castShadow = true;
barPivot.add(bar);
for (let i = 1; i < 8; i++) {
const separator = new THREE.Mesh(
new THREE.BoxGeometry(0.735, 0.018, 0.475),
new THREE.MeshBasicMaterial({ color: 0x163038 })
);
separator.position.y = i * 0.25;
barPivot.add(separator);
}
const plaque = makePlaque(sourceName, "0% likely", cssColor, 1.82, 0.50);
plaque.sprite.position.set(0, 2.42, 0);
group.add(plaque.sprite);
return { pivot: barPivot, plaque };
}
function createFloatingBlocks() {
const geometry = new THREE.BoxGeometry(0.16, 0.16, 0.16);
const material = new THREE.MeshStandardMaterial({
color: 0x29464d,
roughness: 0.85,
emissive: 0x102a30,
emissiveIntensity: 0.2
});
const positions = [
[-6.2, 2.6, -3.8], [-5.5, 3.2, -2.7], [-4.7, 2.2, -4.3],
[5.4, 2.8, -3.7], [6.1, 3.5, -2.5], [4.9, 2.1, -4.1],
[-6.0, 1.2, 2.8], [6.2, 1.5, 2.4], [-4.8, 3.9, 0.2],
[4.7, 4.1, -0.5], [-2.9, 4.5, -3.8], [2.9, 4.7, -3.6]
];
positions.forEach((position, i) => {
const block = new THREE.Mesh(geometry, material);
block.position.set(...position);
block.rotation.set(i * 0.17, i * 0.29, i * 0.11);
block.scale.setScalar(0.75 + (i % 3) * 0.2);
world.add(block);
});
}
createFloor();
// Exact representative compositions matching the displayed frequencies.
const asterLabels = [
"jade", "ember", "jade", "cobalt", "jade",
"jade", "ember", "jade", "ember", "jade"
];
const birchLabels = [
"cobalt", "jade", "ember", "cobalt", "jade",
"ember", "cobalt", "jade", "ember", "cobalt"
];
createDock("Aster Freight", -3.35, COLORS.aster, asterLabels, 0);
createDock("Birch Depot", 3.35, COLORS.birch, birchLabels, 1);
createScanner();
towerAster = createProbabilityTower("Aster", -1.34, COLORS.aster, "#58e0cf");
towerBirch = createProbabilityTower("Birch", 1.34, COLORS.birch, "#ff7b78");
asteroidPlaque = towerAster.plaque;
birchPlaque = towerBirch.plaque;
createFloatingBlocks();
rebuildCenterLabel();
function updatePackagesForEvidence() {
const dimColor = new THREE.Color(0x193038);
packages.forEach((parcel) => {
const matched = parcel.label === state.evidence;
parcel.bodyMaterial.color.copy(parcel.baseColor);
if (!matched) {
parcel.bodyMaterial.color.lerp(dimColor, 0.46);
}
parcel.bodyMaterial.emissive.setHex(
matched ? LABELS[state.evidence].color : 0x000000
);
parcel.bodyMaterial.emissiveIntensity = matched ? 0.2 : 0;
});
}
function updateModel() {
const evidence = LABELS[state.evidence];
const priorAster = state.priorAster;
const priorBirch = 1 - priorAster;
const weightedAster = evidence.aster * priorAster;
const weightedBirch = evidence.birch * priorBirch;
const normalizer = weightedAster + weightedBirch;
state.posteriorAster = weightedAster / normalizer;
state.posteriorBirch = weightedBirch / normalizer;
const percentA = state.posteriorAster * 100;
const percentB = state.posteriorBirch * 100;
dom("posteriorA").textContent = `${percentA.toFixed(1)}%`;
dom("posteriorB").textContent = `${percentB.toFixed(1)}%`;
dom("fillA").style.width = `${percentA}%`;
dom("fillB").style.width = `${percentB}%`;
dom("cardA").classList.toggle("leader", percentA >= percentB);
dom("cardB").classList.toggle("leader", percentB > percentA);
dom("captionA").textContent = `P(Aster | ${state.evidence})`;
dom("captionB").textContent = `P(Birch | ${state.evidence})`;
dom("priorValues").textContent =
`${Math.round(priorAster * 100)}% / ${Math.round(priorBirch * 100)}%`;
const slider = dom("priorSlider");
slider.style.setProperty("--fill", `${priorAster * 100}%`);
dom("formula").textContent =
`P(Aster | ${state.evidence}) = ` +
`(${evidence.aster.toFixed(2)} × ${priorAster.toFixed(2)}) ÷ ` +
`[(${evidence.aster.toFixed(2)} × ${priorAster.toFixed(2)}) + ` +
`(${evidence.birch.toFixed(2)} × ${priorBirch.toFixed(2)})] ` +
`= ${percentA.toFixed(1)}%`;
const ratio = evidence.aster / evidence.birch;
let frequencyText;
if (Math.abs(ratio - 1) < 0.05) {
frequencyText = "The label is about equally common at both suppliers.";
} else if (ratio > 1) {
frequencyText =
`${evidence.name} is ${ratio.toFixed(ratio % 1 ? 1 : 0)}× more common at Aster Freight.`;
} else {
frequencyText =
`${evidence.name} is ${(1 / ratio).toFixed((1 / ratio) % 1 ? 1 : 0)}× more common at Birch Depot.`;
}
const favoredName = percentA >= percentB ? "Aster Freight" : "Birch Depot";
const favoredPercent = Math.max(percentA, percentB);
const alternativePercent = Math.min(percentA, percentB);
dom("interpretation").innerHTML =
`<strong>${frequencyText}</strong> The parcel is ${favoredPercent.toFixed(1)}% ` +
`likely from ${favoredName}. The ${alternativePercent.toFixed(1)}% alternative ` +
`remains possible: the label changes the odds, it does not prove the source.`;
asteroidPlaque.set("Aster", `${percentA.toFixed(1)}% likely`);
birchPlaque.set("Birch", `${percentB.toFixed(1)}% likely`);
updatePackagesForEvidence();
}
function selectEvidence(label) {
state.evidence = label;
state.centerScale = 0.84;
document.querySelectorAll(".evidence-button").forEach((button) => {
const active = button.dataset.label === label;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
document.querySelectorAll(".frequency-table tbody tr").forEach((row) => {
row.classList.toggle("active", row.dataset.row === label);
});
dom("observationName").textContent = LABELS[label].name;
dom("observationDot").style.background = LABELS[label].css;
dom("observationDot").style.boxShadow = `0 0 9px ${LABELS[label].css}`;
scannerLine.material.color.setHex(LABELS[label].color);
scannerLight.color.setHex(LABELS[label].color);
scannerPlaque.set(
"Evidence",
`${LABELS[label].name.toLowerCase()} label observed`,
LABELS[label].css
);
rebuildCenterLabel();
updateModel();
}
document.querySelectorAll(".evidence-button").forEach((button) => {
button.addEventListener("click", () => selectEvidence(button.dataset.label));
});
dom("priorSlider").addEventListener("input", (event) => {
state.priorAster = Number(event.target.value) / 100;
updateModel();
});
dom("scanNext").addEventListener("click", () => {
const order = ["cobalt", "ember", "jade"];
const nextIndex = (order.indexOf(state.evidence) + 1) % order.length;
selectEvidence(order[nextIndex]);
});
// Direct camera controls: no examples or addons are imported.
let dragging = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.52,
1.36
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
7.4,
17.5
);
updateCamera();
},
{ passive: false }
);
function resetCamera() {
cameraState.theta = 0.25;
cameraState.phi = 1.02;
cameraState.radius = 11.8;
updateCamera();
}
renderer.domElement.addEventListener("dblclick", resetCamera);
dom("resetView").addEventListener("click", resetCamera);
dom("zoomIn").addEventListener("click", () => {
cameraState.radius = Math.max(7.4, cameraState.radius - 0.8);
updateCamera();
});
dom("zoomOut").addEventListener("click", () => {
cameraState.radius = Math.min(17.5, cameraState.radius + 0.8);
updateCamera();
});
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
updateModel();
let previousTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const dt = Math.min(0.05, (now - previousTime) / 1000);
previousTime = now;
const smoothing = 1 - Math.exp(-dt * 5.5);
state.displayedAster +=
(state.posteriorAster - state.displayedAster) * smoothing;
state.displayedBirch +=
(state.posteriorBirch - state.displayedBirch) * smoothing;
towerAster.pivot.scale.y = Math.max(0.025, state.displayedAster);
towerBirch.pivot.scale.y = Math.max(0.025, state.displayedBirch);
state.centerScale += (1 - state.centerScale) * smoothing;
centerPackage.group.scale.setScalar(state.centerScale);
const time = now * 0.001;
const scanPhase = (time * 0.48) % 1;
scannerLine.position.y = 0.12 + scanPhase * 0.58;
scannerLine.material.opacity =
0.1 + Math.sin(scanPhase * Math.PI) * 0.38;
scannerLight.intensity = 2.4 + Math.sin(scanPhase * Math.PI) * 1.6;
packages.forEach((parcel) => {
const matched = parcel.label === state.evidence;
if (matched) {
parcel.bodyMaterial.emissiveIntensity =
0.16 + (Math.sin(time * 2.4 + parcel.phase) + 1) * 0.08;
parcel.group.position.y =
parcel.baseY + Math.sin(time * 2 + parcel.phase) * 0.018;
} else {
parcel.group.position.y = parcel.baseY;
}
});
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```