Prompt specification
Build or customize the Three.js 3D scene "Cooking chemistry conservation exhibit" 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: Cooking chemistry conservation exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/cooking-chemistry-conservation-exhibit-x1987
Scene Description Prompt:
Create a standalone voxel scene in one HTML file using Three.js from cdnjs. Compose a sealed fictional reaction vessel and separate atom-token bookkeeping panel; distinguish mass conservation in the closed system from apparent changes when gases escape open containers.
Working Three.js Starter (cooking-chemistry-conservation-exhibit-x1987):
```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="#07141e" />
<title>Voxel Conservation Lab</title>
<style>
:root {
color-scheme: dark;
--bg: #07141e;
--panel: #101f2b;
--panel-2: #142735;
--line: rgba(190, 224, 235, 0.16);
--text: #eaf5f5;
--muted: #91aab4;
--cyan: #42d9e8;
--coral: #ff806e;
--lime: #b8e75c;
--amber: #ffc45b;
--white: #f5fbfa;
--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
"Liberation Mono", monospace;
--sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family: var(--sans);
}
body {
overflow: hidden;
}
button,
input {
font: inherit;
}
button:focus-visible,
input:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
#app {
display: grid;
grid-template-columns: minmax(0, 1fr) 390px;
width: 100vw;
height: 100vh;
}
#viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 48% 38%, rgba(34, 84, 99, 0.28), transparent 45%),
linear-gradient(180deg, #0a1b27 0%, #06111a 100%);
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
.topbar {
position: absolute;
z-index: 4;
top: 24px;
left: 28px;
pointer-events: none;
}
.eyebrow,
.kicker,
.micro-label {
margin: 0;
color: var(--muted);
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.topbar h1 {
margin: 7px 0 0;
max-width: 520px;
font-size: clamp(23px, 3vw, 42px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.topbar h1 span {
color: var(--cyan);
}
.topbar .subtitle {
max-width: 510px;
margin: 12px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.live-badge {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 15px;
padding: 7px 10px;
border: 1px solid rgba(184, 231, 92, 0.24);
border-radius: 999px;
background: rgba(13, 31, 38, 0.7);
color: var(--lime);
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
}
.live-badge::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--lime);
box-shadow: 0 0 14px var(--lime);
content: "";
}
.legend {
position: absolute;
z-index: 4;
top: 24px;
right: 24px;
display: grid;
gap: 8px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(7, 20, 30, 0.78);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-row {
display: grid;
grid-template-columns: 12px auto auto;
align-items: center;
gap: 8px;
color: #cfdee1;
font-family: var(--mono);
font-size: 10px;
}
.legend-row strong {
color: var(--text);
font-weight: 700;
}
.legend-row .mass {
color: var(--muted);
text-align: right;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.swatch.a {
background: var(--cyan);
}
.swatch.b {
background: var(--coral);
}
.swatch.c {
background: var(--lime);
}
.scene-label {
position: absolute;
z-index: 3;
min-width: 190px;
padding: 10px 12px;
transform: translate(-50%, -100%);
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(7, 20, 30, 0.88);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
pointer-events: none;
backdrop-filter: blur(9px);
}
.scene-label::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 24px;
background: linear-gradient(var(--line), transparent);
content: "";
}
.scene-label .label-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
font-family: var(--mono);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scene-label .label-sub {
margin-top: 5px;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
}
#sealedLabel {
border-color: rgba(66, 217, 232, 0.35);
}
#sealedLabel .label-title {
color: var(--cyan);
}
#openLabel {
border-color: rgba(184, 231, 92, 0.34);
}
#openLabel .label-title {
color: var(--lime);
}
.boundary-pill {
padding: 4px 6px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.07);
color: var(--text);
font-size: 8px;
letter-spacing: 0.1em;
}
.control-deck {
position: absolute;
z-index: 5;
bottom: 28px;
left: 50%;
display: flex;
gap: 9px;
max-width: calc(100% - 48px);
padding: 8px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(8, 23, 33, 0.88);
box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(15px);
}
.control-deck button {
min-width: 150px;
padding: 11px 15px;
border: 1px solid transparent;
border-radius: 9px;
background: #eaf7f6;
color: #07141e;
font-family: var(--mono);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.035em;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease,
opacity 150ms ease;
}
.control-deck button:hover:not(:disabled) {
transform: translateY(-2px);
background: var(--white);
}
.control-deck button.secondary {
border-color: var(--line);
background: rgba(255, 255, 255, 0.055);
color: var(--text);
}
.control-deck button.secondary:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.1);
}
.control-deck button:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.gesture-help {
position: absolute;
z-index: 4;
right: 24px;
bottom: 30px;
color: rgba(185, 211, 216, 0.65);
font-family: var(--mono);
font-size: 9px;
line-height: 1.6;
text-align: right;
pointer-events: none;
}
#panel {
min-height: 0;
overflow-y: auto;
border-left: 1px solid var(--line);
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 28%),
var(--panel);
scrollbar-color: #355061 transparent;
scrollbar-width: thin;
}
.panel-inner {
padding: 27px 24px 32px;
}
.panel-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.panel-head h2 {
margin: 7px 0 0;
font-size: 23px;
line-height: 1.05;
letter-spacing: -0.035em;
}
.ledger-badge {
display: grid;
place-items: center;
width: 42px;
height: 42px;
border: 1px solid rgba(66, 217, 232, 0.35);
border-radius: 10px;
background: rgba(66, 217, 232, 0.08);
color: var(--cyan);
font-family: var(--mono);
font-size: 13px;
font-weight: 800;
}
.intro {
margin: 16px 0 20px;
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.global-card {
margin-bottom: 17px;
padding: 16px;
border: 1px solid rgba(66, 217, 232, 0.22);
border-radius: 13px;
background:
linear-gradient(135deg, rgba(66, 217, 232, 0.09), transparent 68%),
rgba(8, 20, 29, 0.4);
}
.global-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
}
.global-top h3 {
margin: 0;
font-size: 13px;
}
.unchanged {
padding: 5px 7px;
border: 1px solid rgba(184, 231, 92, 0.26);
border-radius: 999px;
color: var(--lime);
font-family: var(--mono);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
}
.global-numbers {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-top: 15px;
}
.global-number {
padding-top: 11px;
border-top: 1px solid var(--line);
}
.global-number strong {
display: block;
font-family: var(--mono);
font-size: 25px;
letter-spacing: -0.05em;
}
.global-number span {
display: block;
margin-top: 3px;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
}
.global-note {
margin: 13px 0 0;
color: #b7c9ce;
font-size: 10px;
line-height: 1.55;
}
.system-card {
margin-top: 14px;
padding: 17px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.022);
}
.system-card.closed {
border-top-color: rgba(66, 217, 232, 0.65);
}
.system-card.open {
border-top-color: rgba(184, 231, 92, 0.65);
}
.system-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
}
.system-head h3 {
margin: 5px 0 0;
font-size: 16px;
letter-spacing: -0.02em;
}
.boundary {
flex: 0 0 auto;
padding: 6px 8px;
border-radius: 6px;
font-family: var(--mono);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
}
.closed .boundary {
border: 1px solid rgba(66, 217, 232, 0.35);
color: var(--cyan);
}
.open .boundary {
border: 1px solid rgba(184, 231, 92, 0.35);
color: var(--lime);
}
.equation {
margin: 14px 0;
padding: 11px 12px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(0, 0, 0, 0.15);
color: #d9e8ea;
font-family: var(--mono);
font-size: 11px;
text-align: center;
}
.equation .arrow {
padding: 0 7px;
color: var(--muted);
}
table {
width: 100%;
border-collapse: collapse;
font-family: var(--mono);
font-size: 10px;
}
th,
td {
padding: 9px 4px;
border-bottom: 1px solid rgba(190, 224, 235, 0.09);
text-align: right;
}
th:first-child,
td:first-child {
text-align: left;
}
th {
color: var(--muted);
font-size: 8px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
}
tr.total td {
border-bottom: 0;
color: var(--white);
font-weight: 800;
}
.delta-zero {
color: var(--lime);
}
.status-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 13px;
color: #bdd0d4;
font-family: var(--mono);
font-size: 9px;
line-height: 1.5;
}
.status-dot {
flex: 0 0 auto;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px rgba(66, 217, 232, 0.75);
}
.open .status-dot {
background: var(--lime);
box-shadow: 0 0 10px rgba(184, 231, 92, 0.65);
}
.meter {
height: 4px;
margin-top: 13px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.07);
}
.meter > span {
display: block;
width: 0;
height: 100%;
border-radius: inherit;
background: var(--cyan);
transition: width 80ms linear;
}
.open .meter > span {
background: var(--lime);
}
.explanation {
margin: 14px 0 0;
padding-left: 11px;
border-left: 2px solid rgba(66, 217, 232, 0.55);
color: var(--muted);
font-size: 10px;
line-height: 1.6;
}
.open .explanation {
border-left-color: rgba(184, 231, 92, 0.55);
}
.event-log {
margin-top: 16px;
padding: 14px;
border: 1px dashed var(--line);
border-radius: 10px;
}
.event-log p {
margin: 7px 0 0;
color: #c4d5d8;
font-family: var(--mono);
font-size: 9px;
line-height: 1.65;
}
.event-mark {
color: var(--cyan);
}
.definition {
margin-top: 18px;
color: #718d98;
font-size: 10px;
line-height: 1.65;
}
.definition strong {
color: #aac0c6;
}
@media (max-width: 1050px) {
#app {
grid-template-columns: minmax(0, 1fr) 350px;
}
.gesture-help {
display: none;
}
.control-deck button {
min-width: 130px;
}
}
@media (max-width: 820px) {
body {
overflow: auto;
}
#app {
display: block;
width: 100%;
height: auto;
}
#viewport {
height: 68vh;
min-height: 560px;
}
#panel {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.topbar {
top: 18px;
left: 18px;
}
.topbar h1 {
max-width: 330px;
}
.topbar .subtitle {
display: none;
}
.legend {
top: auto;
right: 16px;
bottom: 92px;
}
.control-deck {
bottom: 20px;
width: calc(100% - 30px);
overflow-x: auto;
}
.control-deck button {
flex: 1 0 auto;
min-width: 135px;
}
.scene-label {
min-width: 150px;
}
}
</style>
</head>
<body>
<div id="app">
<main id="viewport" aria-label="Interactive voxel conservation laboratory">
<header class="topbar">
<p class="eyebrow">Fictional matter laboratory / test 01</p>
<h1>Voxel <span>Conservation</span> Lab</h1>
<p class="subtitle">
A sealed reactor rearranges atoms without changing their inventory.
An open vessel can lose gas to its surroundings.
</p>
<div class="live-badge">LIVE ATOM LEDGER</div>
</header>
<div class="legend" aria-label="Atom token legend">
<div class="legend-row">
<span class="swatch a"></span><strong>A token</strong><span class="mass">1 mu</span>
</div>
<div class="legend-row">
<span class="swatch b"></span><strong>B token</strong><span class="mass">2 mu</span>
</div>
<div class="legend-row">
<span class="swatch c"></span><strong>C token</strong><span class="mass">3 mu</span>
</div>
</div>
<div id="sealedLabel" class="scene-label">
<div class="label-title">
Sealed reactor
<span class="boundary-pill">Closed</span>
</div>
<div class="label-sub">A + B → AB · no matter crosses</div>
</div>
<div id="openLabel" class="scene-label">
<div class="label-title">
Open vessel
<span class="boundary-pill">Exchanging</span>
</div>
<div class="label-sub">C gas can enter the surrounding air</div>
</div>
<div class="control-deck" aria-label="Scene controls">
<button id="reactBtn" type="button">▶ RUN SEALED REACTION</button>
<button id="ventBtn" type="button" class="secondary">↑ VENT OPEN VESSEL</button>
<button id="resetBtn" type="button" class="secondary">RESET SCENE</button>
</div>
<div class="gesture-help">
DRAG TO ORBIT · SHIFT-DRAG TO PAN<br />
SCROLL TO ZOOM · CLICK A VESSEL TO ACT
</div>
</main>
<aside id="panel" aria-label="Atom bookkeeping panel">
<div class="panel-inner">
<div class="panel-head">
<div>
<p class="kicker">Boundary accounting</p>
<h2>Atom-token ledger</h2>
</div>
<div class="ledger-badge">Σ</div>
</div>
<p class="intro">
Fictional mass units are used for bookkeeping. The important distinction
is the boundary: sealed contents are constant; open-vessel contents can
transfer to the surroundings.
</p>
<section class="global-card" aria-label="Combined tracked inventory">
<div class="global-top">
<h3>Combined tracked universe</h3>
<span class="unchanged">UNCHANGED</span>
</div>
<div class="global-numbers">
<div class="global-number">
<strong id="globalAtoms">11</strong>
<span>tracked atoms</span>
</div>
<div class="global-number">
<strong id="globalMass">21 mu</strong>
<span>fictional mass</span>
</div>
</div>
<p id="globalNote" class="global-note">
Reactor + vessel + surrounding air: A₄ B₄ C₃. Both totals stay fixed.
</p>
</section>
<section class="system-card closed" aria-label="Sealed reactor bookkeeping">
<div class="system-head">
<div>
<p class="micro-label">System 01</p>
<h3>Sealed reactor</h3>
</div>
<span class="boundary">CLOSED SYSTEM</span>
</div>
<div class="equation">
<span id="reactantForm">4A + 4B</span>
<span class="arrow">→</span>
<span id="productForm">4AB</span>
</div>
<table>
<thead>
<tr>
<th>Token</th>
<th>Before</th>
<th>After</th>
<th>Δ</th>
</tr>
</thead>
<tbody>
<tr>
<td>A atoms</td>
<td>4</td>
<td>4</td>
<td class="delta-zero">0</td>
</tr>
<tr>
<td>B atoms</td>
<td>4</td>
<td>4</td>
<td class="delta-zero">0</td>
</tr>
<tr>
<td>Total atoms</td>
<td>8</td>
<td>8</td>
<td class="delta-zero">0</td>
</tr>
<tr class="total">
<td>Mass</td>
<td>12 mu</td>
<td>12 mu</td>
<td class="delta-zero">0 mu</td>
</tr>
</tbody>
</table>
<div class="status-row">
<span class="status-dot"></span>
<span id="sealStatus">Ready: reactants separated</span>
</div>
<div class="meter"><span id="sealProgress"></span></div>
<p class="explanation">
The reaction changes only how atoms are grouped. No atom crosses the
sealed boundary, so both token count and mass remain constant.
</p>
</section>
<section class="system-card open" aria-label="Open vessel bookkeeping">
<div class="system-head">
<div>
<p class="micro-label">System 02</p>
<h3>Open vessel</h3>
</div>
<span class="boundary">OPEN SYSTEM</span>
</div>
<div class="equation">
C(gas) <span class="arrow">→</span> C(surroundings)
</div>
<table>
<thead>
<tr>
<th>Token</th>
<th>In vessel</th>
<th>In air</th>
<th>Tracked</th>
</tr>
</thead>
<tbody>
<tr>
<td>C atoms</td>
<td id="openInsideAtoms">3</td>
<td id="openAirAtoms">0</td>
<td id="openTrackedAtoms">3</td>
</tr>
<tr class="total">
<td>Mass</td>
<td id="openInsideMass">9 mu</td>
<td id="openAirMass">0 mu</td>
<td id="openTrackedMass">9 mu</td>
</tr>
</tbody>
</table>
<div class="status-row">
<span class="status-dot"></span>
<span id="openStatus">Ready: three C tokens inside</span>
</div>
<div class="meter"><span id="openProgress"></span></div>
<p class="explanation">
The vessel contents decrease when gas escapes, but the atoms are not
destroyed. They become part of the surrounding system and remain in
the full ledger.
</p>
</section>
<section class="event-log" aria-live="polite">
<p class="kicker">Event log</p>
<p id="eventLog">
<span class="event-mark">01</span> Both systems initialized.
Combined inventory: 11 atoms / 21 mu.
</p>
</section>
<p class="definition">
<strong>Conservation principle:</strong> matter is conserved for the
system whose boundary is being measured. A sealed vessel is a closed
system. An open vessel exchanges matter with its environment.
</p>
</div>
</aside>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// DOM and shared state
// -------------------------------------------------------------------------
const $ = (id) => document.getElementById(id);
const viewport = $("viewport");
const state = {
reactionStart: null,
reactionDuration: 2600,
ventStart: null,
ventDuration: 3200,
reactionFinished: false,
ventFinished: false,
lastEscaped: -1
};
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
const smooth = (t) => t * t * (3 - 2 * t);
const easeInOut = (t) =>
t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
// -------------------------------------------------------------------------
// Three.js renderer, scene, and orthographic camera
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.domElement.setAttribute(
"aria-label",
"Voxel scene with a sealed reactor and an open gas vessel"
);
viewport.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07141e);
scene.fog = new THREE.Fog(0x07141e, 14, 29);
const camera = new THREE.OrthographicCamera(-6, 6, 4.5, -4.5, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 2.05, 0);
const view = {
azimuth: 0.52,
targetAzimuth: 0.52,
polar: 1.04,
targetPolar: 1.04,
zoom: 1,
targetZoom: 1,
radius: 15
};
const hemisphere = new THREE.HemisphereLight(0xccefff, 0x16251f, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(-4, 9, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x43dce8, 1.45);
rimLight.position.set(7, 5, -6);
scene.add(rimLight);
const warmLight = new THREE.DirectionalLight(0xffa76b, 0.75);
warmLight.position.set(-7, 3, -5);
scene.add(warmLight);
// -------------------------------------------------------------------------
// Shared voxel materials and geometry helpers
// -------------------------------------------------------------------------
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0x0b1b25,
roughness: 0.88,
metalness: 0.08
}),
platform: new THREE.MeshStandardMaterial({
color: 0x162b37,
roughness: 0.58,
metalness: 0.28
}),
platformEdge: new THREE.MeshStandardMaterial({
color: 0x294653,
roughness: 0.42,
metalness: 0.48
}),
frame: new THREE.MeshStandardMaterial({
color: 0x284653,
roughness: 0.38,
metalness: 0.65
}),
frameDark: new THREE.MeshStandardMaterial({
color: 0x132a35,
roughness: 0.44,
metalness: 0.62
}),
glass: new THREE.MeshStandardMaterial({
color: 0x79d8e4,
transparent: true,
opacity: 0.09,
roughness: 0.12,
metalness: 0.05,
depthWrite: false,
side: THREE.DoubleSide
}),
seal: new THREE.MeshStandardMaterial({
color: 0xffa74f,
roughness: 0.42,
metalness: 0.25
}),
bolt: new THREE.MeshStandardMaterial({
color: 0xe9f4ee,
roughness: 0.28,
metalness: 0.74
}),
bond: new THREE.MeshStandardMaterial({
color: 0xf3fbf7,
emissive: 0x78e8ef,
emissiveIntensity: 0.38,
roughness: 0.3,
metalness: 0.35
}),
openRim: new THREE.MeshStandardMaterial({
color: 0x9fbd54,
roughness: 0.42,
metalness: 0.45
}),
white: new THREE.MeshStandardMaterial({
color: 0xeaf4ef,
roughness: 0.55,
metalness: 0.08
})
};
function addBox(parent, sx, sy, sz, x, y, z, material, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(sx, sy, sz),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
parent.add(mesh);
return mesh;
}
function createAtom(type, color, studs) {
const group = new THREE.Group();
group.userData.atomType = type;
const material = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.12,
roughness: 0.32,
metalness: 0.08,
transparent: true,
opacity: 1
});
group.userData.material = material;
addBox(group, 0.36, 0.36, 0.36, 0, 0, 0, material);
for (const stud of studs) {
addBox(
group,
stud[3] ?? 0.14,
stud[3] ?? 0.14,
stud[3] ?? 0.14,
stud[0],
stud[1],
stud[2],
material
);
}
addBox(
group,
0.1,
0.1,
0.1,
0.105,
0.105,
0.185,
materials.white
);
group.rotation.set(
studs.length * 0.13,
studs.length * 0.21,
studs.length * 0.08
);
return group;
}
// -------------------------------------------------------------------------
// Floor, grid, and laboratory platform
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
materials.floor
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.12;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(24, 48, 0x315361, 0x18333f);
grid.position.y = -0.105;
grid.material.transparent = true;
grid.material.opacity = 0.32;
scene.add(grid);
addBox(scene, 9.8, 0.24, 4.6, 0, 0.02, 0, materials.platform);
addBox(scene, 10.05, 0.08, 4.85, 0, -0.06, 0, materials.platformEdge);
// -------------------------------------------------------------------------
// Sealed reactor
// -------------------------------------------------------------------------
const pickables = [];
function createSealedReactor() {
const group = new THREE.Group();
group.position.set(-2.35, 0, 0);
group.userData.action = "react";
scene.add(group);
pickables.push(group);
const width = 3.15;
const height = 3.55;
const depth = 2.55;
const bottom = 0.45;
const top = bottom + height;
const halfW = width / 2;
const halfD = depth / 2;
addBox(group, 3.85, 0.28, 3.1, 0, 0.18, 0, materials.platform);
addBox(group, 3.55, 0.12, 2.9, 0, 0.36, 0, materials.frameDark);
addBox(group, 3.22, 0.1, 2.62, 0, 0.43, 0, materials.seal);
// Transparent walls.
addBox(
group,
width,
height,
0.045,
0,
bottom + height / 2,
halfD,
materials.glass,
{ castShadow: false }
);
addBox(
group,
width,
height,
0.045,
0,
bottom + height / 2,
-halfD,
materials.glass,
{ castShadow: false }
);
addBox(
group,
0.045,
height,
depth,
halfW,
bottom + height / 2,
0,
materials.glass,
{ castShadow: false }
);
addBox(
group,
0.045,
height,
depth,
-halfW,
bottom + height / 2,
0,
materials.glass,
{ castShadow: false }
);
// Twelve structural frame bars.
for (const x of [-halfW, halfW]) {
for (const z of [-halfD, halfD]) {
addBox(group, 0.17, height + 0.12, 0.17, x, bottom + height / 2, z, materials.frame);
}
}
for (const y of [bottom, top]) {
for (const z of [-halfD, halfD]) {
addBox(group, width + 0.17, 0.15, 0.15, 0, y, z, materials.frame);
}
for (const x of [-halfW, halfW]) {
addBox(group, 0.15, 0.15, depth + 0.17, x, y, 0, materials.frame);
}
}
// Sealed top panel and orange gasket.
addBox(group, width - 0.03, 0.055, depth - 0.03, 0, top + 0.03, 0, materials.glass, {
castShadow: false
});
addBox(group, width + 0.16, 0.12, depth + 0.16, 0, top + 0.13, 0, materials.frameDark);
addBox(group, width - 0.13, 0.05, depth - 0.13, 0, top + 0.215, 0, materials.seal);
// Seal bolts.
for (const x of [-halfW + 0.2, halfW - 0.2]) {
for (const z of [-halfD + 0.2, halfD - 0.2]) {
addBox(group, 0.16, 0.12, 0.16, x, top + 0.28, z, materials.bolt);
}
}
// Visible front control strip.
addBox(group, 0.72, 0.27, 0.08, -0.92, 1.0, halfD + 0.07, materials.frameDark);
const ledMaterial = new THREE.MeshStandardMaterial({
color: 0x42d9e8,
emissive: 0x42d9e8,
emissiveIntensity: 1.8
});
addBox(group, 0.16, 0.09, 0.07, -1.12, 1.04, halfD + 0.13, ledMaterial);
const statusBeaconMaterial = new THREE.MeshStandardMaterial({
color: 0x42d9e8,
emissive: 0x42d9e8,
emissiveIntensity: 1.5
});
addBox(
group,
0.22,
0.18,
0.22,
1.16,
top + 0.45,
0,
statusBeaconMaterial
);
addBox(group, 0.12, 0.28, 0.12, 1.16, top + 0.28, 0, materials.frameDark);
// Small pressure-gauge pixels.
addBox(group, 0.36, 0.36, 0.08, 0.68, 1.03, halfD + 0.08, materials.bolt);
addBox(group, 0.18, 0.05, 0.05, 0.68, 1.08, halfD + 0.14, materials.seal);
return {
group,
statusBeaconMaterial
};
}
const sealedReactor = createSealedReactor();
// -------------------------------------------------------------------------
// Open vessel with a raised lid
// -------------------------------------------------------------------------
function createOpenVessel() {
const group = new THREE.Group();
group.position.set(2.4, 0, 0);
group.userData.action = "vent";
scene.add(group);
pickables.push(group);
const width = 2.4;
const height = 2.18;
const depth = 2.05;
const bottom = 0.44;
const halfW = width / 2;
const halfD = depth / 2;
addBox(group, 2.95, 0.26, 2.55, 0, 0.17, 0, materials.platform);
addBox(group, 2.68, 0.1, 2.28, 0, 0.34, 0, materials.frameDark);
addBox(group, 2.44, 0.08, 2.1, 0, 0.41, 0, materials.openRim);
addBox(
group,
width,
height,
0.045,
0,
bottom + height / 2,
halfD,
materials.glass,
{ castShadow: false }
);
addBox(
group,
width,
height,
0.045,
0,
bottom + height / 2,
-halfD,
materials.glass,
{ castShadow: false }
);
addBox(
group,
0.045,
height,
depth,
halfW,
bottom + height / 2,
0,
materials.glass,
{ castShadow: false }
);
addBox(
group,
0.045,
height,
depth,
-halfW,
bottom + height / 2,
0,
materials.glass,
{ castShadow: false }
);
// Open rim: intentionally no top closure.
for (const z of [-halfD, halfD]) {
addBox(group, width + 0.13, 0.14, 0.14, 0, bottom + height, z, materials.openRim);
}
for (const x of [-halfW, halfW]) {
addBox(group, 0.14, 0.14, depth + 0.13, x, bottom + height, 0, materials.openRim);
for (const z of [-halfD, halfD]) {
addBox(group, 0.14, height, 0.14, x, bottom + height / 2, z, materials.frame);
}
}
// Raised lid, hinged at the back.
const lid = new THREE.Group();
lid.position.set(0, bottom + height, -halfD);
lid.rotation.x = 0.72;
group.add(lid);
addBox(lid, width, 0.11, depth, 0, 0, -depth / 2, materials.glass, {
castShadow: false
});
addBox(lid, width + 0.12, 0.12, 0.12, 0, 0, 0, materials.openRim);
addBox(lid, width + 0.12, 0.12, 0.12, 0, 0, -depth, materials.openRim);
addBox(lid, 0.12, 0.12, depth, -halfW, 0, -depth / 2, materials.openRim);
addBox(lid, 0.12, 0.12, depth, halfW, 0, -depth / 2, materials.openRim);
for (const x of [-0.75, 0.75]) {
addBox(group, 0.22, 0.22, 0.22, x, bottom + height, -halfD, materials.bolt);
}
// Hazard marker on the front.
addBox(group, 0.38, 0.38, 0.07, 0.63, 1.05, halfD + 0.08, materials.seal);
addBox(group, 0.07, 0.16, 0.05, 0.63, 1.12, halfD + 0.13, materials.frameDark);
addBox(group, 0.07, 0.07, 0.05, 0.63, 0.98, halfD + 0.13, materials.frameDark);
return group;
}
const openVessel = createOpenVessel();
// -------------------------------------------------------------------------
// Atom tokens and bonds
// -------------------------------------------------------------------------
const closedAtoms = [];
const closedBonds = [];
const closedInitial = [
[-1.12, 1.05, -0.62],
[0.90, 1.62, 0.58],
[-0.82, 2.74, -0.42],
[0.88, 3.03, 0.12],
[0.88, 1.05, 0.58],
[-0.90, 1.62, -0.48],
[0.82, 2.70, 0.52],
[-0.90, 3.03, -0.36]
];
const pairCenters = [
[-0.62, 1.28, -0.18],
[0.56, 2.00, 0.28],
[-0.10, 2.86, -0.18],
[0.63, 1.34, 0.48]
];
const closedFinal = [];
for (const center of pairCenters) {
closedFinal.push([center[0] - 0.32, center[1], center[2]]);
closedFinal.push([center[0] + 0.32, center[1], center[2]]);
}
for (let i = 0; i < 8; i++) {
const isA = i % 2 === 0;
const atom = createAtom(
isA ? "A" : "B",
isA ? 0x42d9e8 : 0xff806e,
isA
? [[0.19, 0, 0], [0, 0.19, 0]]
: [[0.19, 0, 0], [-0.19, 0, 0], [0, 0.19, 0]]
);
atom.position.set(...closedInitial[i]);
atom.userData.initial = new THREE.Vector3(...closedInitial[i]);
atom.userData.final = new THREE.Vector3(...closedFinal[i]);
sealedReactor.group.add(atom);
closedAtoms.push(atom);
}
for (const center of pairCenters) {
const bond = addBox(
sealedReactor.group,
0.31,
0.1,
0.1,
center[0],
center[1],
center[2],
materials.bond
);
bond.visible = false;
bond.userData.isBond = true;
closedBonds.push(bond);
}
const openAtoms = [];
const openInitial = [
[-0.53, 0.83, 0.42],
[0.46, 1.20, -0.38],
[-0.13, 1.62, 0.30]
];
const openEscapedTargets = [
[1.38, 4.28, -1.18],
[2.08, 4.88, -1.62]
];
for (let i = 0; i < 3; i++) {
const atom = createAtom(
"C",
0xb8e75c,
[
[0.19, 0, 0],
[-0.19, 0, 0],
[0, 0.19, 0],
[0, 0, 0.19]
]
);
atom.position.set(...openInitial[i]);
atom.userData.initial = new THREE.Vector3(...openInitial[i]);
atom.userData.baseScale = atom.scale.clone();
openVessel.add(atom);
openAtoms.push(atom);
}
// -------------------------------------------------------------------------
// Reaction light and vent puffs
// -------------------------------------------------------------------------
const reactionLight = new THREE.PointLight(0x42d9e8, 0, 5, 2);
reactionLight.position.set(-2.35, 2.25, 0.6);
scene.add(reactionLight);
const ventLight = new THREE.PointLight(0xb8e75c, 0, 4, 2);
ventLight.position.set(2.4, 2.5, 0);
scene.add(ventLight);
const ventPuffs = [];
const puffMaterial = new THREE.MeshBasicMaterial({
color: 0xb8e75c,
transparent: true,
opacity: 0.14,
depthWrite: false
});
for (let i = 0; i < 12; i++) {
const puff = addBox(
scene,
0.12 + (i % 3) * 0.025,
0.12 + (i % 3) * 0.025,
0.12 + (i % 3) * 0.025,
0,
0,
0,
puffMaterial.clone(),
{ castShadow: false }
);
puff.visible = false;
ventPuffs.push(puff);
}
// -------------------------------------------------------------------------
// Ledger updates
// -------------------------------------------------------------------------
function updateOpenLedger(escaped) {
if (escaped === state.lastEscaped) return;
state.lastEscaped = escaped;
const inside = 3 - escaped;
const insideMass = inside * 3;
const airMass = escaped * 3;
$("openInsideAtoms").textContent = inside;
$("openAirAtoms").textContent = escaped;
$("openTrackedAtoms").textContent = inside + escaped;
$("openInsideMass").textContent = `${insideMass} mu`;
$("openAirMass").textContent = `${airMass} mu`;
$("openTrackedMass").textContent = `${insideMass + airMass} mu`;
if (escaped === 0) {
$("openStatus").textContent = "Ready: three C tokens inside";
} else if (escaped < 3) {
$("openStatus").textContent =
`${escaped} C token${escaped === 1 ? " has" : "s have"} crossed the open boundary`;
} else {
$("openStatus").textContent = "One C token remains inside; two are in the air";
}
$("globalNote").textContent =
`Reactor + vessel + surrounding air: A₄ B₄ C₃. ` +
`${inside} C inside and ${escaped} C outside; both totals stay fixed.`;
}
function writeLog(index, message) {
$("eventLog").innerHTML =
`<span class="event-mark">${index}</span> ${message}`;
}
function startReaction() {
if (state.reactionStart !== null) return;
state.reactionStart = performance.now();
state.reactionFinished = false;
$("reactBtn").disabled = true;
$("reactBtn").textContent = "REACTION RUNNING…";
$("sealStatus").textContent = "Atoms rearranging: A + B → AB";
$("reactantForm").textContent = "4A + 4B";
$("productForm").textContent = "4AB";
writeLog(
"02",
"Sealed reaction started. Atom counts remain 8/8 and mass remains 12 mu."
);
}
function startVent() {
if (state.ventStart !== null) return;
state.ventStart = performance.now();
state.ventFinished = false;
$("ventBtn").disabled = true;
$("ventBtn").textContent = "VENTING…";
$("openStatus").textContent = "C gas is crossing the open boundary";
writeLog(
"03",
"Open vessel venting. Vessel content can decrease while the full tracked inventory stays fixed."
);
}
function resetScene(resetCamera = true) {
state.reactionStart = null;
state.ventStart = null;
state.reactionFinished = false;
state.ventFinished = false;
state.lastEscaped = -1;
for (const atom of closedAtoms) {
atom.position.copy(atom.userData.initial);
atom.rotation.set(0.2, 0.4, 0.05);
}
for (const bond of closedBonds) {
bond.visible = false;
bond.scale.set(1, 1, 1);
}
for (const atom of openAtoms) {
atom.position.copy(atom.userData.initial);
atom.scale.copy(atom.userData.baseScale);
atom.userData.material.opacity = 1;
atom.visible = true;
}
for (const puff of ventPuffs) {
puff.visible = false;
}
reactionLight.intensity = 0;
ventLight.intensity = 0;
$("reactBtn").disabled = false;
$("reactBtn").textContent = "▶ RUN SEALED REACTION";
$("ventBtn").disabled = false;
$("ventBtn").textContent = "↑ VENT OPEN VESSEL";
$("sealStatus").textContent = "Ready: reactants separated";
$("sealProgress").style.width = "0%";
$("openProgress").style.width = "0%";
$("reactantForm").textContent = "4A + 4B";
$("productForm").textContent = "4AB";
updateOpenLedger(0);
writeLog("01", "Both systems reset. Combined inventory: 11 atoms / 21 mu.");
if (resetCamera) {
view.targetAzimuth = 0.52;
view.targetPolar = 1.04;
view.targetZoom = 1;
cameraTarget.set(0, 2.05, 0);
}
}
$("reactBtn").addEventListener("click", startReaction);
$("ventBtn").addEventListener("click", startVent);
$("resetBtn").addEventListener("click", () => resetScene(true));
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, and object clicking
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let dragging = false;
let pointerMoved = false;
let lastX = 0;
let lastY = 0;
function findAction(object) {
let current = object;
while (current) {
if (current.userData.action) return current.userData.action;
current = current.parent;
}
return null;
}
function actionAtEvent(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickables, true);
return hits.length ? findAction(hits[0].object) : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
pointerMoved = false;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) {
renderer.domElement.style.cursor = actionAtEvent(event)
? "pointer"
: "grab";
return;
}
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (Math.abs(dx) + Math.abs(dy) > 2) pointerMoved = true;
if (event.shiftKey) {
cameraTarget.x = clamp(cameraTarget.x + dx * 0.012, -3.2, 3.2);
cameraTarget.z = clamp(cameraTarget.z + dy * 0.012, -2.5, 2.5);
} else {
view.targetAzimuth -= dx * 0.006;
view.targetPolar = clamp(
view.targetPolar - dy * 0.005,
0.55,
1.35
);
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!dragging) return;
dragging = false;
if (!pointerMoved) {
const action = actionAtEvent(event);
if (action === "react") startReaction();
if (action === "vent") startVent();
}
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.targetZoom = clamp(
view.targetZoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.65
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
view.targetAzimuth = 0.52;
view.targetPolar = 1.04;
view.targetZoom = 1;
cameraTarget.set(0, 2.05, 0);
});
function updateCamera() {
view.azimuth = lerp(view.azimuth, view.targetAzimuth, 0.12);
view.polar = lerp(view.polar, view.targetPolar, 0.12);
view.zoom = lerp(view.zoom, view.targetZoom, 0.12);
const sinPolar = Math.sin(view.polar);
camera.position.set(
cameraTarget.x + view.radius * sinPolar * Math.sin(view.azimuth),
cameraTarget.y + view.radius * Math.cos(view.polar),
cameraTarget.z + view.radius * sinPolar * Math.cos(view.azimuth)
);
camera.lookAt(cameraTarget);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
// -------------------------------------------------------------------------
// Responsive camera and projected HTML labels
// -------------------------------------------------------------------------
let viewportWidth = 1;
let viewportHeight = 1;
function resize() {
viewportWidth = viewport.clientWidth;
viewportHeight = viewport.clientHeight;
const aspect = viewportWidth / Math.max(viewportHeight, 1);
const viewHeight = 8.3;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(viewportWidth, viewportHeight);
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
resize();
const labelProjection = new THREE.Vector3();
function placeLabel(element, x, y, z) {
labelProjection.set(x, y, z).project(camera);
const visible = labelProjection.z > -1 && labelProjection.z < 1;
element.style.opacity = visible ? "1" : "0";
element.style.left = `${(labelProjection.x * 0.5 + 0.5) * viewportWidth}px`;
element.style.top = `${(-labelProjection.y * 0.5 + 0.5) * viewportHeight}px`;
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
function quadraticBezier(out, p0, p1, p2, t) {
const inv = 1 - t;
out.set(
inv * inv * p0.x + 2 * inv * t * p1.x + t * t * p2.x,
inv * inv * p0.y + 2 * inv * t * p1.y + t * t * p2.y,
inv * inv * p0.z + 2 * inv * t * p1.z + t * t * p2.z
);
return out;
}
const ventPath = {
p0: new THREE.Vector3(),
p1: new THREE.Vector3(),
p2: new THREE.Vector3(),
out: new THREE.Vector3()
};
function animate(now) {
requestAnimationFrame(animate);
// Sealed reaction animation.
if (state.reactionStart !== null) {
const raw = clamp(
(now - state.reactionStart) / state.reactionDuration,
0,
1
);
const eased = easeInOut(raw);
for (let i = 0; i < closedAtoms.length; i++) {
const atom = closedAtoms[i];
atom.position.lerpVectors(
atom.userData.initial,
atom.userData.final,
eased
);
atom.position.y += Math.sin(eased * Math.PI) * (0.28 + (i % 3) * 0.04);
atom.rotation.x += 0.013;
atom.rotation.y += 0.018;
}
for (let i = 0; i < closedBonds.length; i++) {
const bond = closedBonds[i];
const bondProgress = clamp((raw - 0.47 - i * 0.035) / 0.34, 0, 1);
bond.visible = bondProgress > 0;
bond.scale.x = Math.max(0.001, bondProgress);
}
reactionLight.intensity = Math.sin(raw * Math.PI) * 7.5;
sealedReactor.statusBeaconMaterial.emissiveIntensity =
1.5 + Math.sin(raw * Math.PI * 8) * 0.8;
$("sealProgress").style.width = `${raw * 100}%`;
if (raw >= 1) {
state.reactionFinished = true;
$("sealStatus").textContent =
"Complete: 4AB products; 8 atoms and 12 mu remain";
$("reactBtn").textContent = "✓ SEALED REACTION COMPLETE";
writeLog(
"04",
"Sealed reaction complete. Before and after are both 8 atoms / 12 mu."
);
}
}
// Open-vessel venting animation.
if (state.ventStart !== null) {
const raw = clamp(
(now - state.ventStart) / state.ventDuration,
0,
1
);
let escaped = 0;
for (let i = 0; i < openAtoms.length; i++) {
const atom = openAtoms[i];
const initial = atom.userData.initial;
if (i < 2) {
const localProgress = clamp(
(raw - i * 0.16) / (1 - i * 0.16),
0,
1
);
const eased = smooth(localProgress);
ventPath.p0.copy(initial);
ventPath.p1.set(initial.x, initial.y + 2.3, initial.z);
ventPath.p2.set(...openEscapedTargets[i]);
quadraticBezier(
ventPath.out,
ventPath.p0,
ventPath.p1,
ventPath.p2,
eased
);
atom.position.copy(ventPath.out);
atom.rotation.x += 0.012;
atom.rotation.y += 0.017;
const outside = clamp((localProgress - 0.38) / 0.35, 0, 1);
atom.userData.material.opacity = 1 - outside * 0.42;
atom.scale.setScalar(1 - outside * 0.18);
if (localProgress > 0.56) escaped = i + 1;
} else {
atom.position.copy(initial);
atom.position.y += Math.sin(now * 0.0022) * 0.035;
atom.rotation.y += 0.006;
}
}
updateOpenLedger(escaped);
for (let i = 0; i < ventPuffs.length; i++) {
const puff = ventPuffs[i];
const cycle = (raw * 1.8 + i * 0.083) % 1;
const side = (i % 3 - 1) * 0.24;
puff.visible = raw > 0 && raw < 0.98;
puff.position.set(
2.4 + side + Math.sin(i * 1.7) * 0.14,
2.5 + cycle * 2.75,
0.1 + Math.cos(i * 1.3) * 0.22
);
const scale = 0.7 + cycle * 1.8;
puff.scale.setScalar(scale);
puff.material.opacity = Math.sin(cycle * Math.PI) * 0.14;
}
ventLight.intensity = Math.sin(raw * Math.PI) * 4.5;
$("openProgress").style.width = `${raw * 100}%`;
if (raw >= 1) {
state.ventFinished = true;
$("ventBtn").textContent = "✓ TWO C TOKENS VENTED";
$("openStatus").textContent =
"One C token remains inside; two are in the air";
writeLog(
"05",
"Vent complete. Vessel: 1 C / 3 mu. Air: 2 C / 6 mu. Tracked C remains 3 / 9 mu."
);
}
}
updateCamera();
placeLabel($("sealedLabel"), -2.35, 4.95, 0);
placeLabel($("openLabel"), 2.4, 3.55, 0);
renderer.render(scene, camera);
}
resetScene(false);
requestAnimationFrame(animate);
</script>
</body>
</html>
```