Prompt specification
Build or customize the Three.js 3D scene "Sequential evidence update display" 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: Sequential evidence update display
Category: Algorithms & Systems · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/sequential-evidence-update-display-x1766
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Bayesian updates from evidence. Reveal synthetic token colors one at a time from a chosen hidden urn under stated replacement rules; update posterior probabilities and retain the entire observation history. Stylized solid forms.
Working Three.js Starter (sequential-evidence-update-display-x1766):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#18342d" />
<title>Bayes Urn Lab</title>
<style>
:root {
--paper: #f4f1e8;
--paper-deep: #e9e4d7;
--ink: #17231f;
--muted: #6c756f;
--green: #18342d;
--green-2: #245247;
--line: #d8d4c8;
--white: #fffdf7;
--cobalt: #4d6fff;
--amber: #f3a52d;
--mint: #42b596;
--shadow: 0 18px 50px rgba(28, 43, 37, 0.10);
--radius: 22px;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
min-height: 100%;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
background-image:
linear-gradient(rgba(24, 52, 45, 0.025) 1px, transparent 1px),
linear-gradient(90deg, rgba(24, 52, 45, 0.025) 1px, transparent 1px);
background-size: 28px 28px;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible,
input:focus-visible {
outline: 3px solid rgba(77, 111, 255, 0.35);
outline-offset: 3px;
}
.shell {
width: min(1460px, calc(100% - 36px));
margin: 0 auto;
padding: 24px 0 38px;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
margin-bottom: 22px;
}
.brand {
display: flex;
align-items: center;
gap: 14px;
}
.brand-mark {
position: relative;
width: 48px;
height: 48px;
flex: 0 0 auto;
border-radius: 15px;
background: var(--green);
box-shadow: 0 8px 22px rgba(24, 52, 45, 0.2);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
border-radius: 50%;
background: var(--paper);
}
.brand-mark::before {
width: 9px;
height: 9px;
top: 11px;
left: 11px;
box-shadow: 17px 0 0 var(--paper);
}
.brand-mark::after {
width: 9px;
height: 9px;
top: 28px;
left: 20px;
}
.brand-kicker {
margin: 0 0 2px;
color: var(--muted);
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(1.35rem, 2.2vw, 2rem);
line-height: 1.05;
letter-spacing: -0.045em;
}
.top-status {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
justify-content: flex-end;
}
.pill {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 34px;
padding: 7px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 253, 247, 0.75);
color: var(--muted);
font-size: 0.76rem;
font-weight: 750;
white-space: nowrap;
}
.pill::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mint);
}
.pill.live::before {
animation: pulse 1.4s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.38; transform: scale(0.72); }
}
.workspace {
display: grid;
grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
gap: 20px;
align-items: stretch;
}
.panel,
.stage-card,
.history-card {
border: 1px solid rgba(24, 52, 45, 0.1);
border-radius: var(--radius);
background: rgba(255, 253, 247, 0.91);
box-shadow: var(--shadow);
}
.control-column {
display: flex;
flex-direction: column;
gap: 14px;
}
.panel {
padding: 21px;
}
.section-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
margin-bottom: 16px;
}
.section-index {
display: block;
margin-bottom: 5px;
color: var(--green-2);
font-size: 0.69rem;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
h2, h3, p { margin-top: 0; }
h2 {
margin-bottom: 0;
font-size: 1.16rem;
letter-spacing: -0.025em;
}
h3 {
margin-bottom: 0;
font-size: 0.93rem;
}
.microcopy {
margin: 7px 0 0;
color: var(--muted);
font-size: 0.79rem;
line-height: 1.5;
}
.small-tag {
flex: 0 0 auto;
padding: 5px 8px;
border-radius: 999px;
background: var(--paper-deep);
color: var(--green-2);
font-size: 0.67rem;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
fieldset {
min-width: 0;
margin: 0;
padding: 0;
border: 0;
}
.urn-options {
display: grid;
gap: 9px;
}
.urn-option {
position: relative;
display: grid;
grid-template-columns: 18px 1fr auto;
align-items: center;
gap: 11px;
min-height: 64px;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 15px;
background: #faf8f1;
cursor: pointer;
transition: border-color 160ms, background 160ms, transform 160ms;
}
.urn-option:hover {
transform: translateY(-1px);
border-color: #aebbb4;
}
.urn-option.selected {
border-color: var(--green-2);
background: #edf3ec;
box-shadow: inset 0 0 0 1px var(--green-2);
}
.urn-option.locked {
cursor: not-allowed;
opacity: 0.72;
}
.urn-option input {
width: 16px;
height: 16px;
margin: 0;
accent-color: var(--green-2);
}
.urn-name {
display: block;
margin-bottom: 3px;
font-size: 0.86rem;
font-weight: 820;
}
.urn-meta {
display: flex;
align-items: center;
gap: 7px;
color: var(--muted);
font-size: 0.69rem;
}
.composition {
display: inline-flex;
align-items: center;
gap: 3px;
}
.composition i,
.color-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
}
.cobalt { background: var(--cobalt); }
.amber { background: var(--amber); }
.mint { background: var(--mint); }
.prior-number {
color: var(--green-2);
font-size: 0.74rem;
font-weight: 850;
}
.rule-switch {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 13px;
}
.rule-button {
min-height: 57px;
padding: 10px;
border: 1px solid var(--line);
border-radius: 13px;
background: #faf8f1;
text-align: left;
cursor: pointer;
transition: 160ms ease;
}
.rule-button strong {
display: block;
margin-bottom: 3px;
font-size: 0.75rem;
}
.rule-button span {
display: block;
color: var(--muted);
font-size: 0.64rem;
line-height: 1.35;
}
.rule-button.active {
border-color: var(--green-2);
background: var(--green);
color: var(--white);
box-shadow: 0 8px 18px rgba(24, 52, 45, 0.14);
}
.rule-button.active span { color: #cbd9d3; }
.rule-button:disabled { cursor: not-allowed; opacity: 0.72; }
.formula {
margin-top: 14px;
padding: 12px 13px;
border-radius: 13px;
background: var(--green);
color: var(--white);
}
.formula code {
display: block;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.78rem;
line-height: 1.5;
}
.formula small {
display: block;
margin-top: 5px;
color: #bed0c8;
font-size: 0.65rem;
line-height: 1.45;
}
.posterior-list {
display: grid;
gap: 13px;
}
.posterior-row {
display: grid;
grid-template-columns: 1fr auto;
gap: 7px 12px;
align-items: center;
}
.posterior-name {
font-size: 0.78rem;
font-weight: 800;
}
.posterior-value {
font-variant-numeric: tabular-nums;
font-size: 0.88rem;
font-weight: 900;
}
.prob-bar {
position: relative;
grid-column: 1 / -1;
height: 9px;
overflow: visible;
border-radius: 999px;
background: #e8e5dc;
}
.prob-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
border-radius: inherit;
background: var(--green-2);
transition: width 450ms cubic-bezier(.2,.8,.2,1);
}
.prior-marker {
position: absolute;
top: -4px;
width: 2px;
height: 17px;
border-radius: 2px;
background: rgba(23, 35, 31, 0.45);
transition: left 350ms ease;
}
.posterior-caption {
display: flex;
justify-content: space-between;
gap: 12px;
color: var(--muted);
font-size: 0.66rem;
}
.predictive {
display: grid;
gap: 9px;
}
.predictive-row {
display: grid;
grid-template-columns: 12px 1fr 52px;
gap: 9px;
align-items: center;
}
.predictive-label {
font-size: 0.77rem;
font-weight: 760;
}
.predictive-value {
text-align: right;
font-size: 0.78rem;
font-weight: 850;
font-variant-numeric: tabular-nums;
}
.predictive-bar {
grid-column: 2 / -1;
height: 5px;
margin-top: -4px;
overflow: hidden;
border-radius: 99px;
background: #ebe8df;
}
.predictive-bar span {
display: block;
height: 100%;
width: 0;
border-radius: inherit;
transition: width 450ms ease;
}
.evidence-box {
margin-top: 14px;
padding: 13px;
border-left: 4px solid var(--green-2);
border-radius: 4px 12px 12px 4px;
background: #edf3ec;
}
.evidence-box strong {
display: block;
margin-bottom: 4px;
font-size: 0.8rem;
}
.evidence-box p {
margin: 0;
color: var(--muted);
font-size: 0.7rem;
line-height: 1.5;
}
.stage-card {
position: relative;
min-height: 680px;
overflow: hidden;
background: #e7ece7;
}
.stage-toolbar {
position: absolute;
z-index: 5;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 20px 22px;
pointer-events: none;
}
.stage-title {
display: flex;
align-items: center;
gap: 10px;
}
.stage-title strong {
font-size: 0.86rem;
letter-spacing: -0.01em;
}
.stage-title span {
color: var(--muted);
font-size: 0.68rem;
}
.stage-counter {
padding: 7px 10px;
border: 1px solid rgba(24, 52, 45, 0.12);
border-radius: 999px;
background: rgba(255, 253, 247, 0.72);
color: var(--green-2);
font-size: 0.69rem;
font-weight: 850;
}
#stage {
position: absolute;
inset: 0 0 86px;
overflow: hidden;
touch-action: none;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
}
#stage canvas:active { cursor: grabbing; }
.urn-label {
position: absolute;
z-index: 3;
min-width: 112px;
padding: 8px 10px;
border: 1px solid rgba(24, 52, 45, 0.12);
border-radius: 12px;
background: rgba(255, 253, 247, 0.86);
box-shadow: 0 8px 22px rgba(24, 52, 45, 0.08);
text-align: center;
pointer-events: none;
transform: translate(-50%, -100%);
transition: background 160ms, border-color 160ms;
}
.urn-label.selected {
border-color: var(--green-2);
background: var(--green);
color: var(--white);
}
.label-name {
display: block;
font-size: 0.72rem;
font-weight: 850;
}
.label-sub {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 0.59rem;
}
.urn-label.selected .label-sub { color: #bcd0c8; }
.latest-card {
position: absolute;
z-index: 5;
top: 67px;
right: 22px;
display: flex;
align-items: center;
gap: 10px;
max-width: 230px;
padding: 10px 12px;
border: 1px solid rgba(24, 52, 45, 0.12);
border-radius: 14px;
background: rgba(255, 253, 247, 0.88);
box-shadow: 0 10px 30px rgba(24, 52, 45, 0.09);
pointer-events: none;
}
.latest-swatch {
width: 23px;
height: 23px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--green-2);
box-shadow: inset -3px -4px 0 rgba(0,0,0,.1);
}
.latest-card strong {
display: block;
font-size: 0.72rem;
}
.latest-card span {
display: block;
margin-top: 1px;
color: var(--muted);
font-size: 0.61rem;
}
.stage-help {
position: absolute;
z-index: 4;
left: 22px;
bottom: 94px;
color: rgba(24, 52, 45, 0.55);
font-size: 0.65rem;
pointer-events: none;
}
.actionbar {
position: absolute;
z-index: 6;
right: 20px;
bottom: 18px;
left: 20px;
display: grid;
grid-template-columns: minmax(180px, 1fr) auto auto;
gap: 9px;
padding: 10px;
border: 1px solid rgba(24, 52, 45, 0.1);
border-radius: 18px;
background: rgba(255, 253, 247, 0.93);
box-shadow: 0 12px 35px rgba(24, 52, 45, 0.12);
backdrop-filter: blur(10px);
}
.action-button {
min-height: 48px;
padding: 0 18px;
border: 1px solid var(--line);
border-radius: 12px;
background: #faf8f1;
font-size: 0.76rem;
font-weight: 850;
cursor: pointer;
transition: transform 150ms, background 150ms, opacity 150ms;
}
.action-button:hover:not(:disabled) {
transform: translateY(-1px);
background: #f0eee5;
}
.action-button.primary {
border-color: var(--green);
background: var(--green);
color: var(--white);
}
.action-button.primary:hover:not(:disabled) { background: var(--green-2); }
.action-button:disabled { cursor: not-allowed; opacity: 0.42; }
.history-card {
margin-top: 20px;
padding: 22px;
}
.history-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 16px;
}
.history-track {
position: relative;
display: flex;
gap: 10px;
min-height: 78px;
padding: 13px;
overflow-x: auto;
border: 1px solid var(--line);
border-radius: 16px;
background: #f7f5ed;
scrollbar-width: thin;
}
.history-track::before {
content: "";
position: absolute;
top: 36px;
right: 25px;
left: 25px;
height: 2px;
background: #d9d6cc;
}
.empty-history {
position: relative;
z-index: 1;
display: flex;
align-items: center;
gap: 11px;
width: 100%;
color: var(--muted);
font-size: 0.76rem;
}
.empty-icon {
display: grid;
place-items: center;
width: 32px;
height: 32px;
flex: 0 0 auto;
border: 1px dashed #aeb5af;
border-radius: 50%;
background: #fffdf7;
font-size: 1rem;
}
.history-step {
position: relative;
z-index: 1;
min-width: 78px;
padding: 0;
border: 0;
background: transparent;
text-align: center;
cursor: pointer;
}
.history-token {
display: grid;
place-items: center;
width: 43px;
height: 43px;
margin: 0 auto 7px;
border: 4px solid #f7f5ed;
border-radius: 50%;
box-shadow: 0 0 0 1px rgba(24,52,45,.15), inset -5px -6px 0 rgba(0,0,0,.1);
transition: transform 150ms;
}
.history-step:hover .history-token,
.history-step.active .history-token { transform: translateY(-3px) scale(1.08); }
.history-step small {
color: var(--muted);
font-size: 0.62rem;
font-weight: 750;
}
.table-wrap {
margin-top: 14px;
overflow-x: auto;
border: 1px solid var(--line);
border-radius: 15px;
}
table {
width: 100%;
border-collapse: collapse;
min-width: 660px;
font-size: 0.72rem;
}
th, td {
padding: 11px 13px;
border-bottom: 1px solid #e4e1d8;
text-align: left;
}
th {
background: #f0eee6;
color: var(--muted);
font-size: 0.62rem;
letter-spacing: 0.07em;
text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #faf8f1; }
.table-color {
display: inline-flex;
align-items: center;
gap: 7px;
font-weight: 800;
}
.table-color i {
width: 10px;
height: 10px;
border-radius: 50%;
}
.footer {
display: flex;
justify-content: space-between;
gap: 16px;
padding: 14px 4px 0;
color: var(--muted);
font-size: 0.65rem;
line-height: 1.5;
}
@media (max-width: 980px) {
.workspace { grid-template-columns: 1fr; }
.control-column {
display: grid;
grid-template-columns: 1fr 1fr;
align-items: start;
}
.stage-card { min-height: 620px; }
}
@media (max-width: 700px) {
.shell {
width: min(100% - 20px, 1460px);
padding-top: 14px;
}
.topbar { align-items: flex-start; }
.top-status .pill:first-child { display: none; }
.control-column { grid-template-columns: 1fr; }
.panel { padding: 17px; }
.stage-card { min-height: 560px; }
.stage-toolbar { padding: 16px; }
.latest-card { top: 61px; right: 16px; }
.actionbar {
right: 12px;
bottom: 12px;
left: 12px;
grid-template-columns: 1fr 1fr;
}
.action-button.primary { grid-column: 1 / -1; }
.history-card { padding: 17px; }
.footer { flex-direction: column; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
scroll-behavior: auto !important;
transition-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<div class="shell">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="brand-kicker">Interactive probability studio</p>
<h1>Bayes Urn Lab</h1>
</div>
</div>
<div class="top-status">
<span class="pill">Saved in this browser</span>
<span class="pill live" id="modePill">Prior model</span>
</div>
</header>
<main class="workspace">
<aside class="control-column">
<section class="panel">
<div class="section-head">
<div>
<span class="section-index">01 / Experiment setup</span>
<h2>Choose the hidden urn</h2>
</div>
<span class="small-tag">Simulation</span>
</div>
<p class="microcopy">
This selection controls which urn generates the tokens. The posterior
treats all three urns as unresolved hypotheses.
</p>
<fieldset id="urnFieldset" style="margin-top: 14px;">
<legend class="sr-only" hidden>Hidden simulation urn</legend>
<div class="urn-options">
<label class="urn-option selected" data-option="azure">
<input type="radio" name="hiddenUrn" value="azure" checked />
<span>
<span class="urn-name">Azure urn</span>
<span class="urn-meta">
<span class="composition">
<i class="cobalt"></i><i class="cobalt"></i><i class="cobalt"></i>
<i class="cobalt"></i><i class="cobalt"></i><i class="cobalt"></i>
<i class="cobalt"></i><i class="amber"></i><i class="amber"></i><i class="amber"></i>
</span>
7 cobalt · 3 amber
</span>
</span>
<span class="prior-number">45% prior</span>
</label>
<label class="urn-option" data-option="ember">
<input type="radio" name="hiddenUrn" value="ember" />
<span>
<span class="urn-name">Ember urn</span>
<span class="urn-meta">
<span class="composition">
<i class="cobalt"></i><i class="cobalt"></i><i class="cobalt"></i>
<i class="amber"></i><i class="amber"></i><i class="amber"></i>
<i class="amber"></i><i class="amber"></i><i class="amber"></i><i class="amber"></i>
</span>
3 cobalt · 7 amber
</span>
</span>
<span class="prior-number">35% prior</span>
</label>
<label class="urn-option" data-option="garden">
<input type="radio" name="hiddenUrn" value="garden" />
<span>
<span class="urn-name">Garden urn</span>
<span class="urn-meta">
<span class="composition">
<i class="cobalt"></i><i class="cobalt"></i><i class="cobalt"></i>
<i class="cobalt"></i><i class="cobalt"></i>
<i class="amber"></i><i class="amber"></i><i class="amber"></i>
<i class="mint"></i><i class="mint"></i>
</span>
5 cobalt · 3 amber · 2 mint
</span>
</span>
<span class="prior-number">20% prior</span>
</label>
</div>
</fieldset>
<div class="section-head" style="margin: 19px 0 0;">
<div>
<h3 style="font-size: .88rem;">Replacement rule</h3>
<p class="microcopy">The rule is fixed once the first token is drawn.</p>
</div>
</div>
<div class="rule-switch" id="ruleSwitch">
<button class="rule-button active" type="button" data-rule="replacement">
<strong>With replacement</strong>
<span>Return the token. Draws are independent.</span>
</button>
<button class="rule-button" type="button" data-rule="without">
<strong>Without replacement</strong>
<span>Keep the token out. Odds shift as the urn empties.</span>
</button>
</div>
<div class="formula">
<code>P(Uₖ | E) ∝ P(Uₖ) × P(E | Uₖ)</code>
<small>
The prior is multiplied by the likelihood of the complete observed
sequence, then normalized across the three urn hypotheses.
</small>
</div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="section-index">02 / Updated belief</span>
<h2>Posterior probabilities</h2>
</div>
<span class="small-tag" id="posteriorTag">Prior</span>
</div>
<div class="posterior-list" id="posteriorList"></div>
<div class="evidence-box">
<strong id="evidenceTitle">Waiting for evidence</strong>
<p id="evidenceText">
Reveal a token to compare its likelihood under each urn hypothesis.
</p>
</div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="section-index">03 / Next prediction</span>
<h2>Posterior predictive</h2>
</div>
</div>
<p class="microcopy" style="margin-bottom: 14px;">
Probability of the next token after averaging over the remaining
uncertainty about which urn was used.
</p>
<div class="predictive" id="predictiveList"></div>
</section>
</aside>
<section class="stage-card">
<div class="stage-toolbar">
<div class="stage-title">
<strong>Hidden urn laboratory</strong>
<span>Three candidate compositions</span>
</div>
<div class="stage-counter" id="stageCounter">0 observations</div>
</div>
<div id="stage" aria-label="Interactive 3D urn visualization">
<div class="urn-label" id="label-azure"></div>
<div class="urn-label" id="label-ember"></div>
<div class="urn-label" id="label-garden"></div>
<div class="latest-card" id="latestCard" hidden>
<div class="latest-swatch" id="latestSwatch"></div>
<div>
<strong id="latestTitle">No observation</strong>
<span id="latestSubtitle">Reveal a token to begin</span>
</div>
</div>
<div class="stage-help">Drag to orbit · scroll to zoom · double-click to reset view</div>
</div>
<div class="actionbar">
<button class="action-button primary" id="revealButton" type="button">
Reveal next token
</button>
<button class="action-button" id="autoButton" type="button">Auto reveal</button>
<button class="action-button" id="resetButton" type="button" disabled>New run</button>
</div>
</section>
</main>
<section class="history-card">
<div class="history-header">
<div>
<span class="section-index">Observation ledger</span>
<h2>Complete evidence history</h2>
<p class="microcopy">
Every draw is retained, along with the posterior implied at that moment.
</p>
</div>
<span class="small-tag" id="historyCount">0 draws</span>
</div>
<div class="history-track" id="historyTrack"></div>
<div class="table-wrap" id="historyTableWrap" hidden>
<table>
<thead>
<tr>
<th>Draw</th>
<th>Observed token</th>
<th>P(Azure | E)</th>
<th>P(Ember | E)</th>
<th>P(Garden | E)</th>
</tr>
</thead>
<tbody id="historyTableBody"></tbody>
</table>
</div>
</section>
<footer class="footer">
<span>
The selected simulation urn is exposed only for setup. During inference,
its identity is hidden and its composition is learned from the evidence.
</span>
<span>History is stored locally in this browser until “New run” is pressed.</span>
</footer>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const COLORS = {
cobalt: { name: "Cobalt", hex: "#4d6fff" },
amber: { name: "Amber", hex: "#f3a52d" },
mint: { name: "Mint", hex: "#42b596" }
};
const CANDIDATES = [
{
id: "azure",
name: "Azure urn",
short: "Azure",
prior: 0.45,
counts: { cobalt: 7, amber: 3, mint: 0 },
body: "#b8cbd0"
},
{
id: "ember",
name: "Ember urn",
short: "Ember",
prior: 0.35,
counts: { cobalt: 3, amber: 7, mint: 0 },
body: "#d6bda8"
},
{
id: "garden",
name: "Garden urn",
short: "Garden",
prior: 0.20,
counts: { cobalt: 5, amber: 3, mint: 2 },
body: "#b9cdbd"
}
];
const COLOR_KEYS = ["cobalt", "amber", "mint"];
const STORAGE_KEY = "bayes-urn-lab-v1";
const state = {
selectedId: "azure",
rule: "replacement",
observations: [],
activeHistoryIndex: -1
};
const $ = selector => document.querySelector(selector);
const $$ = selector => [...document.querySelectorAll(selector)];
const stage = $("#stage");
const urnFieldset = $("#urnFieldset");
const revealButton = $("#revealButton");
const autoButton = $("#autoButton");
const resetButton = $("#resetButton");
const ruleButtons = $$(".rule-button");
let autoTimer = null;
function saveState() {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify({
selectedId: state.selectedId,
rule: state.rule,
observations: state.observations
}));
} catch (_) {}
}
function loadState() {
try {
const saved = JSON.parse(localStorage.getItem(STORAGE_KEY));
if (!saved) return;
if (CANDIDATES.some(c => c.id === saved.selectedId)) {
state.selectedId = saved.selectedId;
}
if (["replacement", "without"].includes(saved.rule)) {
state.rule = saved.rule;
}
if (Array.isArray(saved.observations)) {
state.observations = saved.observations.filter(obs =>
obs &&
COLOR_KEYS.includes(obs.color) &&
Number.isFinite(obs.time)
);
}
} catch (_) {}
}
function candidateById(id) {
return CANDIDATES.find(c => c.id === id);
}
function totalOf(counts) {
return COLOR_KEYS.reduce((sum, key) => sum + counts[key], 0);
}
function normalizedCounts(candidate) {
const total = totalOf(candidate.counts);
const counts = {};
for (const key of COLOR_KEYS) {
counts[key] = candidate.counts[key] / total;
}
return counts;
}
function candidateLikelihood(candidate, observations, rule) {
const remaining = { ...candidate.counts };
let total = totalOf(remaining);
let likelihood = 1;
for (const obs of observations) {
if (remaining[obs.color] <= 0) return 0;
likelihood *= remaining[obs.color] / total;
if (rule === "without") {
remaining[obs.color] -= 1;
total -= 1;
}
}
return likelihood;
}
function posteriorFor(observations, rule = state.rule) {
const likelihoods = CANDIDATES.map(candidate =>
candidateLikelihood(candidate, observations, rule)
);
const weights = CANDIDATES.map((candidate, i) =>
candidate.prior * likelihoods[i]
);
const normalizer = weights.reduce((sum, value) => sum + value, 0);
if (!normalizer) {
return CANDIDATES.map(candidate => candidate.prior);
}
return weights.map(value => value / normalizer);
}
function remainingCounts(candidate, observations) {
const remaining = { ...candidate.counts };
if (state.rule === "without") {
for (const obs of observations) {
remaining[obs.color] = Math.max(0, remaining[obs.color] - 1);
}
}
return remaining;
}
function predictiveProbabilities() {
const posterior = posteriorFor(state.observations);
const result = { cobalt: 0, amber: 0, mint: 0 };
CANDIDATES.forEach((candidate, i) => {
const remaining = remainingCounts(candidate, state.observations);
const total = totalOf(remaining);
for (const key of COLOR_KEYS) {
result[key] += posterior[i] * (total ? remaining[key] / total : 0);
}
});
return result;
}
function renderSetup() {
const locked = state.observations.length > 0;
$$(".urn-option").forEach(option => {
const selected = option.dataset.option === state.selectedId;
option.classList.toggle("selected", selected);
option.classList.toggle("locked", locked);
option.querySelector("input").checked = selected;
option.querySelector("input").disabled = locked;
});
ruleButtons.forEach(button => {
const active = button.dataset.rule === state.rule;
button.classList.toggle("active", active);
button.disabled = locked;
});
resetButton.disabled = state.observations.length === 0;
revealButton.disabled = state.rule === "without" && state.observations.length >= 10;
const modePill = $("#modePill");
modePill.textContent = state.observations.length ? "Posterior model" : "Prior model";
modePill.classList.toggle("live", state.observations.length > 0);
}
function renderPosterior() {
const posterior = posteriorFor(state.observations);
const list = $("#posteriorList");
list.innerHTML = CANDIDATES.map((candidate, i) => {
const value = posterior[i];
const delta = value - candidate.prior;
const deltaText = Math.abs(delta) < 0.0005
? "unchanged"
: `${delta > 0 ? "+" : ""}${(delta * 100).toFixed(1)} pts`;
return `
<div class="posterior-row">
<span class="posterior-name">${candidate.name}</span>
<span class="posterior-value">${(value * 100).toFixed(1)}%</span>
<div class="prob-bar" aria-label="${candidate.name}: ${(value * 100).toFixed(1)} percent">
<span class="prob-fill" style="width:${value * 100}%"></span>
<span class="prior-marker" style="left:${candidate.prior * 100}%"></span>
</div>
<div class="posterior-caption">
<span>Prior ${(candidate.prior * 100).toFixed(0)}%</span>
<span>${deltaText}</span>
</div>
</div>
`;
}).join("");
const posteriors = CANDIDATES.map(candidate => candidate.prior);
const priorBest = CANDIDATES[posteriors.indexOf(Math.max(...posteriors))];
if (!state.observations.length) {
$("#posteriorTag").textContent = "Prior";
$("#evidenceTitle").textContent = "Waiting for evidence";
$("#evidenceText").textContent =
`The current belief favors ${priorBest.name}. Reveal a token to compare its likelihood under each urn hypothesis.`;
return;
}
const bestIndex = posterior.indexOf(Math.max(...posterior));
const best = CANDIDATES[bestIndex];
const latest = state.observations[state.observations.length - 1];
const counts = {};
for (const obs of state.observations) {
counts[obs.color] = (counts[obs.color] || 0) + 1;
}
const colorCount = counts[latest.color];
const colorPhrase = colorCount === 1
? `A ${COLORS[latest.color].name.toLowerCase()} token`
: `${colorCount} ${COLORS[latest.color].name.toLowerCase()} tokens`;
$("#posteriorTag").textContent = "Posterior";
$("#evidenceTitle").textContent = `${best.name} now has ${(posterior[bestIndex] * 100).toFixed(1)}% posterior probability`;
$("#evidenceText").textContent =
`${colorPhrase} have been observed. ` +
(state.rule === "replacement"
? "Each draw was evaluated independently using the original composition."
: "Each draw was evaluated sequentially using the number of tokens remaining in each urn.");
}
function renderPredictive() {
const probabilities = predictiveProbabilities();
const list = $("#predictiveList");
list.innerHTML = COLOR_KEYS.map(key => {
const value = probabilities[key];
return `
<div class="predictive-row">
<i class="color-dot ${key}"></i>
<span class="predictive-label">${COLORS[key].name}</span>
<span class="predictive-value">${(value * 100).toFixed(1)}%</span>
<div class="predictive-bar">
<span style="width:${value * 100}%;background:${COLORS[key].hex}"></span>
</div>
</div>
`;
}).join("");
}
function renderHistory() {
const track = $("#historyTrack");
const tableWrap = $("#historyTableWrap");
const tableBody = $("#historyTableBody");
const count = state.observations.length;
$("#historyCount").textContent = `${count} ${count === 1 ? "draw" : "draws"}`;
$("#stageCounter").textContent = `${count} ${count === 1 ? "observation" : "observations"}`;
if (!count) {
tableWrap.hidden = true;
track.innerHTML = `
<div class="empty-history">
<span class="empty-icon">+</span>
<span>No evidence yet. The first reveal begins the posterior update.</span>
</div>
`;
return;
}
tableWrap.hidden = false;
track.innerHTML = state.observations.map((obs, index) => `
<button
class="history-step ${index === state.activeHistoryIndex ? "active" : ""}"
type="button"
data-history-index="${index}"
aria-label="View observation ${index + 1}: ${COLORS[obs.color].name}"
>
<span class="history-token ${obs.color}" style="background:${COLORS[obs.color].hex}"></span>
<small>${String(index + 1).padStart(2, "0")} · ${COLORS[obs.color].name}</small>
</button>
`).join("");
tableBody.innerHTML = state.observations.map((obs, index) => {
const posterior = posteriorFor(state.observations.slice(0, index + 1));
const time = new Date(obs.time).toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
return `
<tr>
<td>#${index + 1} · ${time}</td>
<td>
<span class="table-color">
<i style="background:${COLORS[obs.color].hex}"></i>
${COLORS[obs.color].name}
</span>
</td>
<td>${(posterior[0] * 100).toFixed(1)}%</td>
<td>${(posterior[1] * 100).toFixed(1)}%</td>
<td>${(posterior[2] * 100).toFixed(1)}%</td>
</tr>
`;
}).join("");
$$(".history-step").forEach(button => {
button.addEventListener("click", () => {
const index = Number(button.dataset.historyIndex);
state.activeHistoryIndex = index;
const obs = state.observations[index];
showFloatingToken(obs.color, false);
renderHistory();
});
});
}
function renderAll() {
renderSetup();
renderPosterior();
renderPredictive();
renderHistory();
updateLabels();
}
function actualRemainingCounts() {
const candidate = candidateById(state.selectedId);
return remainingCounts(candidate, state.observations);
}
function randomColorFromCounts(counts) {
const entries = COLOR_KEYS
.map(key => ({ key, count: counts[key] }))
.filter(entry => entry.count > 0);
if (!entries.length) return null;
const total = entries.reduce((sum, entry) => sum + entry.count, 0);
let roll = Math.random() * total;
for (const entry of entries) {
roll -= entry.count;
if (roll <= 0) return entry.key;
}
return entries[entries.length - 1].key;
}
function revealToken() {
const counts = actualRemainingCounts();
const color = randomColorFromCounts(counts);
if (!color) {
stopAuto();
revealButton.disabled = true;
return;
}
state.observations.push({
color,
time: Date.now()
});
state.activeHistoryIndex = state.observations.length - 1;
if (state.rule === "without") {
consumeTokenVisual(color);
}
showFloatingToken(color, true);
saveState();
renderAll();
if (state.rule === "without" && state.observations.length >= 10) {
stopAuto();
revealButton.disabled = true;
}
}
function startAuto() {
if (autoTimer) return;
revealToken();
if (state.rule === "without" && state.observations.length >= 10) return;
autoTimer = setInterval(revealToken, 1500);
autoButton.textContent = "Pause auto";
}
function stopAuto() {
if (autoTimer) clearInterval(autoTimer);
autoTimer = null;
autoButton.textContent = "Auto reveal";
}
function resetRun() {
if (state.observations.length &&
!window.confirm("Start a new run and clear the saved observation history?")) {
return;
}
stopAuto();
state.observations = [];
state.activeHistoryIndex = -1;
saveState();
rebuildTokenMeshes();
floatingToken.visible = false;
$("#latestCard").hidden = true;
renderAll();
}
revealButton.addEventListener("click", revealToken);
autoButton.addEventListener("click", () => autoTimer ? stopAuto() : startAuto());
resetButton.addEventListener("click", resetRun);
ruleButtons.forEach(button => {
button.addEventListener("click", () => {
if (state.observations.length) return;
state.rule = button.dataset.rule;
saveState();
renderAll();
});
});
urnFieldset.addEventListener("change", event => {
if (state.observations.length) return;
state.selectedId = event.target.value;
saveState();
rebuildTokenMeshes();
floatingToken.visible = false;
$("#latestCard").hidden = true;
renderAll();
});
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.fog = new THREE.Fog("#e7ece7", 12, 25);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.prepend(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Three stylized urn candidates. Drag to orbit and scroll to zoom."
);
const ambient = new THREE.HemisphereLight("#ffffff", "#809086", 2.2);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight("#fff8e8", 4.2);
keyLight.position.set(5, 9, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight("#a9d8e0", 1.4);
fillLight.position.set(-6, 4, -4);
scene.add(fillLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: "#e4ebe5",
roughness: 0.95,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.04;
ground.receiveShadow = true;
scene.add(ground);
const tokenGeometry = new THREE.SphereGeometry(0.18, 20, 14);
const tokenMaterials = {};
for (const key of COLOR_KEYS) {
tokenMaterials[key] = new THREE.MeshStandardMaterial({
color: COLORS[key].hex,
roughness: 0.38,
metalness: 0.02
});
}
const urnGroups = {};
const tokenMeshes = {};
const selectionRings = {};
const urnPositions = {
azure: -2.25,
ember: 0,
garden: 2.25
};
function createUrn(candidate, x) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const profile = [
new THREE.Vector2(0.62, 0.08),
new THREE.Vector2(0.78, 0.18),
new THREE.Vector2(0.92, 0.66),
new THREE.Vector2(0.91, 1.15),
new THREE.Vector2(0.78, 1.67),
new THREE.Vector2(0.65, 1.94),
new THREE.Vector2(0.66, 2.12),
new THREE.Vector2(0.81, 2.17)
];
const body = new THREE.Mesh(
new THREE.LatheGeometry(profile, 48),
new THREE.MeshPhysicalMaterial({
color: candidate.body,
transparent: true,
opacity: 0.29,
roughness: 0.22,
metalness: 0.02,
clearcoat: 0.35,
clearcoatRoughness: 0.3,
side: THREE.DoubleSide,
depthWrite: false
})
);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.79, 0.075, 10, 48),
new THREE.MeshStandardMaterial({
color: candidate.body,
roughness: 0.38,
metalness: 0.04
})
);
rim.rotation.x = Math.PI / 2;
rim.position.y = 2.17;
rim.castShadow = true;
group.add(rim);
const foot = new THREE.Mesh(
new THREE.CylinderGeometry(0.67, 0.72, 0.16, 32),
new THREE.MeshStandardMaterial({
color: candidate.body,
roughness: 0.55,
metalness: 0
})
);
foot.position.y = 0.04;
foot.castShadow = true;
foot.receiveShadow = true;
group.add(foot);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(1.05, 0.035, 8, 56),
new THREE.MeshStandardMaterial({
color: "#245247",
emissive: "#245247",
emissiveIntensity: 0.8,
roughness: 0.4,
transparent: true,
opacity: 0
})
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.04;
group.add(ring);
selectionRings[candidate.id] = ring;
const tokenLayer = new THREE.Group();
group.add(tokenLayer);
urnGroups[candidate.id] = group;
tokenMeshes[candidate.id] = tokenLayer;
}
CANDIDATES.forEach(candidate => createUrn(candidate, urnPositions[candidate.id]));
updateSelectionVisuals();
const floatingToken = new THREE.Mesh(
new THREE.SphereGeometry(0.25, 24, 18),
tokenMaterials.cobalt.clone()
);
floatingToken.castShadow = true;
floatingToken.visible = false;
scene.add(floatingToken);
const revealAnimation = {
active: false,
start: 0,
from: new THREE.Vector3(),
to: new THREE.Vector3()
};
function showFloatingToken(color, animate) {
const x = urnPositions[state.selectedId];
floatingToken.material.color.set(COLORS[color].hex);
floatingToken.visible = true;
floatingToken.position.set(x, 2.62, 0);
floatingToken.scale.setScalar(1);
if (animate) {
revealAnimation.active = true;
revealAnimation.start = performance.now();
revealAnimation.from.set(x, 2.36, 0);
revealAnimation.to.set(x, 3.03, 0);
floatingToken.position.copy(revealAnimation.from);
floatingToken.scale.setScalar(0.05);
}
$("#latestCard").hidden = false;
$("#latestSwatch").style.background = COLORS[color].hex;
$("#latestTitle").textContent = COLORS[color].name;
$("#latestSubtitle").textContent = state.observations.length
? `Draw ${String(state.observations.length).padStart(2, "0")}`
: "Historical evidence";
}
function rebuildTokenMeshes() {
for (const candidate of CANDIDATES) {
const layer = tokenMeshes[candidate.id];
layer.clear();
const list = [];
for (const key of COLOR_KEYS) {
for (let i = 0; i < candidate.counts[key]; i++) {
list.push(key);
}
}
list.forEach((key, index) => {
const row = Math.floor(index / 2);
const column = index % 2;
const token = new THREE.Mesh(tokenGeometry, tokenMaterials[key]);
token.position.set(
(column - 0.5) * 0.48,
0.40 + row * 0.32,
((row % 2) - 0.5) * 0.39
);
token.castShadow = true;
token.receiveShadow = true;
token.userData.color = key;
layer.add(token);
});
}
if (state.rule === "without") {
for (const obs of state.observations) {
consumeTokenVisual(obs.color);
}
}
updateSelectionVisuals();
}
function consumeTokenVisual(color) {
const layer = tokenMeshes[state.selectedId];
if (!layer) return;
for (let i = layer.children.length - 1; i >= 0; i--) {
const token = layer.children[i];
if (token.userData.color === color) {
layer.remove(token);
return;
}
}
}
function updateSelectionVisuals() {
for (const candidate of CANDIDATES) {
const selected = candidate.id === state.selectedId;
selectionRings[candidate.id].material.opacity = selected ? 0.95 : 0;
}
}
function updateLabels() {
const posterior = posteriorFor(state.observations);
CANDIDATES.forEach((candidate, i) => {
const label = $(`#label-${candidate.id}`);
const selected = candidate.id === state.selectedId;
label.classList.toggle("selected", selected);
label.innerHTML = `
<span class="label-name">${candidate.short}</span>
<span class="label-sub">
${selected ? "Simulation urn · " : ""}${(posterior[i] * 100).toFixed(1)}% posterior
</span>
`;
});
}
// Custom orbit controls, implemented without addons.
const orbit = {
yaw: -0.08,
pitch: 0.20,
distance: 9.4,
target: new THREE.Vector3(0, 1.08, 0)
};
const pointers = new Map();
let previousPinchDistance = 0;
function updateCamera() {
const aspect = stage.clientWidth / Math.max(1, stage.clientHeight);
const responsiveFactor = Math.max(1, 1.12 / Math.max(aspect, 0.58));
const distance = orbit.distance * responsiveFactor;
camera.position.set(
orbit.target.x + distance * Math.cos(orbit.pitch) * Math.sin(orbit.yaw),
orbit.target.y + distance * Math.sin(orbit.pitch),
orbit.target.z + distance * Math.cos(orbit.pitch) * Math.cos(orbit.yaw)
);
camera.lookAt(orbit.target);
camera.updateMatrixWorld();
}
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
orbit.yaw -= dx * 0.006;
orbit.pitch = THREE.MathUtils.clamp(orbit.pitch + dy * 0.004, 0.04, 0.72);
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance) {
orbit.distance = THREE.MathUtils.clamp(
orbit.distance * (previousPinchDistance / distance),
6.5,
13.5
);
}
previousPinchDistance = distance;
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("pointerleave", endPointer);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
orbit.distance = THREE.MathUtils.clamp(
orbit.distance * Math.exp(event.deltaY * 0.001),
6.5,
13.5
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
orbit.yaw = -0.08;
orbit.pitch = 0.20;
orbit.distance = 9.4;
});
const resizeObserver = new ResizeObserver(() => {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(1, height);
camera.updateProjectionMatrix();
});
resizeObserver.observe(stage);
const projected = new THREE.Vector3();
function positionLabels() {
const width = stage.clientWidth;
const height = stage.clientHeight;
for (const candidate of CANDIDATES) {
projected.set(urnPositions[candidate.id], 2.52, 0);
projected.project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const label = $(`#label-${candidate.id}`);
label.style.left = `${x}px`;
label.style.top = `${y}px`;
label.style.opacity = projected.z > 1 ? "0" : "1";
}
}
function animate(time) {
requestAnimationFrame(animate);
if (revealAnimation.active) {
const t = THREE.MathUtils.clamp((time - revealAnimation.start) / 650, 0, 1);
const eased = 1 - Math.pow(1 - t, 3);
floatingToken.position.lerpVectors(revealAnimation.from, revealAnimation.to, eased);
floatingToken.scale.setScalar(0.05 + eased * 0.95);
floatingToken.rotation.y += 0.035;
if (t >= 1) revealAnimation.active = false;
} else if (floatingToken.visible) {
floatingToken.position.y = 3.03 + Math.sin(time * 0.0024) * 0.055;
floatingToken.rotation.y += 0.012;
}
updateCamera();
positionLabels();
renderer.render(scene, camera);
}
// Restore persisted state, then construct all synchronized views.
loadState();
rebuildTokenMeshes();
if (state.observations.length) {
const latest = state.observations[state.observations.length - 1];
state.activeHistoryIndex = state.observations.length - 1;
showFloatingToken(latest.color, false);
}
renderAll();
requestAnimationFrame(animate);
</script>
</body>
</html>
```