Prompt specification
Build or customize the Three.js 3D scene "Catalytic cycle tabletop sequence" 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: Catalytic cycle tabletop sequence
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/catalytic-cycle-tabletop-sequence-x0846
Scene Description Prompt:
Make one HTML file using Three.js from cdnjs for this stylized scene: Show substrate binding, a simplified reaction stage, and product release in four linked displays; the enzyme remains reusable and no molecules appear or vanish without labeled transformation.
Working Three.js Starter (catalytic-cycle-tabletop-sequence-x0846):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Catalytic Cycle — Three.js Molecular Scene</title>
<style>
:root {
color-scheme: dark;
--bg: #06101d;
--panel: rgba(12, 24, 43, 0.78);
--panel-strong: rgba(16, 31, 54, 0.94);
--line: rgba(136, 177, 218, 0.17);
--text: #eef7ff;
--muted: #91a8c2;
--cyan: #50dcff;
--violet: #a587ff;
--coral: #ff6f79;
--gold: #ffd166;
--green: #64e6ad;
}
* {
box-sizing: border-box;
}
html {
min-width: 320px;
background: var(--bg);
}
body {
min-height: 100vh;
margin: 0;
overflow-x: hidden;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
background:
radial-gradient(circle at 12% 0%, rgba(41, 119, 170, 0.22), transparent 33rem),
radial-gradient(circle at 88% 12%, rgba(127, 82, 201, 0.18), transparent 32rem),
linear-gradient(180deg, #071321 0%, #050c16 100%);
}
body::before {
position: fixed;
inset: 0;
z-index: -1;
content: "";
pointer-events: none;
opacity: 0.28;
background-image:
linear-gradient(rgba(114, 170, 214, 0.035) 1px, transparent 1px),
linear-gradient(90deg, rgba(114, 170, 214, 0.035) 1px, transparent 1px);
background-size: 48px 48px;
mask-image: linear-gradient(to bottom, black, transparent 82%);
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: min(1540px, calc(100% - 32px));
margin: 0 auto;
padding: 34px 0 28px;
}
.hero {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 28px;
align-items: end;
margin-bottom: 22px;
}
.eyebrow {
display: inline-flex;
gap: 10px;
align-items: center;
margin-bottom: 11px;
color: var(--cyan);
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 1px;
content: "";
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
h1 {
max-width: 920px;
margin: 0;
font-size: clamp(2rem, 4vw, 4.45rem);
font-weight: 760;
line-height: 0.99;
letter-spacing: -0.055em;
}
.hero-copy {
max-width: 780px;
margin: 16px 0 0;
color: var(--muted);
font-size: clamp(0.95rem, 1.5vw, 1.08rem);
line-height: 1.65;
}
.balance-card {
min-width: 280px;
padding: 17px 19px;
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(10, 23, 41, 0.7);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}
.balance-title {
margin-bottom: 13px;
color: var(--muted);
font-size: 0.68rem;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.balance-row {
display: flex;
gap: 8px;
align-items: center;
}
.atom-token {
display: grid;
width: 30px;
height: 30px;
place-items: center;
border-radius: 50%;
color: #071321;
font-size: 0.74rem;
font-weight: 900;
box-shadow: 0 0 16px currentColor;
}
.atom-a {
color: var(--cyan);
background: var(--cyan);
}
.atom-b {
color: var(--coral);
background: var(--coral);
}
.atom-c {
color: var(--gold);
background: var(--gold);
}
.enzyme-token {
display: grid;
width: 34px;
height: 34px;
margin-left: 8px;
place-items: center;
border: 1px solid rgba(165, 135, 255, 0.7);
border-radius: 11px;
color: #d9ceff;
background: rgba(165, 135, 255, 0.13);
font-size: 0.76rem;
font-weight: 900;
}
.balance-arrow {
color: var(--muted);
font-size: 1.2rem;
}
.balance-note {
margin-left: auto;
color: var(--green);
font-size: 0.73rem;
font-weight: 750;
text-align: right;
}
.controls {
display: grid;
grid-template-columns: auto minmax(220px, 1fr) auto;
gap: 18px;
align-items: center;
margin-bottom: 18px;
padding: 15px 17px;
border: 1px solid var(--line);
border-radius: 17px;
background: rgba(8, 18, 33, 0.72);
backdrop-filter: blur(16px);
}
.button-row {
display: flex;
gap: 8px;
}
.control-button {
min-height: 40px;
padding: 0 15px;
border: 1px solid rgba(112, 158, 203, 0.25);
border-radius: 11px;
cursor: pointer;
background: rgba(119, 164, 211, 0.08);
font-size: 0.8rem;
font-weight: 760;
transition: 160ms ease;
}
.control-button:hover {
border-color: rgba(80, 220, 255, 0.5);
background: rgba(80, 220, 255, 0.12);
transform: translateY(-1px);
}
.control-button.primary {
border-color: rgba(80, 220, 255, 0.38);
color: #07131f;
background: linear-gradient(135deg, #72e6ff, #42c7ef);
box-shadow: 0 8px 25px rgba(60, 202, 242, 0.16);
}
.timeline-wrap {
min-width: 0;
}
.timeline-labels {
display: grid;
grid-template-columns: repeat(4, 1fr);
margin-bottom: 7px;
color: #7f98b5;
font-size: 0.63rem;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.timeline-labels span:nth-child(2),
.timeline-labels span:nth-child(3) {
text-align: center;
}
.timeline-labels span:last-child {
text-align: right;
}
input[type="range"] {
width: 100%;
height: 5px;
margin: 0;
border-radius: 999px;
outline: none;
cursor: pointer;
accent-color: var(--cyan);
background: linear-gradient(
90deg,
var(--cyan) 0%,
var(--cyan) var(--progress, 100%),
rgba(121, 154, 191, 0.2) var(--progress, 100%)
);
}
.cycle-label {
color: var(--muted);
font-size: 0.73rem;
font-weight: 700;
text-align: right;
white-space: nowrap;
}
.cycle-label strong {
display: block;
margin-bottom: 3px;
color: var(--text);
font-size: 0.83rem;
}
.checkpoint-note {
display: flex;
gap: 10px;
align-items: center;
margin: 0 0 15px;
color: #829bb8;
font-size: 0.77rem;
}
.checkpoint-note::before {
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 50%;
content: "";
background: var(--violet);
box-shadow: 0 0 12px var(--violet);
}
.stage-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 16px;
}
.stage {
position: relative;
min-width: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 21px;
background:
linear-gradient(180deg, rgba(16, 31, 53, 0.92), rgba(8, 19, 34, 0.88));
box-shadow:
0 18px 55px rgba(0, 0, 0, 0.2),
inset 0 1px rgba(255, 255, 255, 0.035);
transition:
border-color 180ms ease,
transform 180ms ease,
box-shadow 180ms ease;
}
.stage.active {
border-color: rgba(80, 220, 255, 0.48);
transform: translateY(-4px);
box-shadow:
0 20px 60px rgba(0, 0, 0, 0.28),
0 0 28px rgba(80, 220, 255, 0.08),
inset 0 1px rgba(255, 255, 255, 0.05);
}
.stage.passed {
border-color: rgba(100, 230, 173, 0.23);
}
.stage:not(:last-child)::after {
position: absolute;
top: 50%;
right: -20px;
z-index: 5;
width: 22px;
height: 22px;
display: grid;
place-items: center;
border: 1px solid rgba(99, 153, 201, 0.2);
border-radius: 50%;
content: "→";
color: #819dbc;
background: #091524;
font-size: 0.8rem;
transform: translateY(-50%);
}
.stage-header {
display: flex;
gap: 12px;
align-items: center;
min-height: 76px;
padding: 14px 15px;
border-bottom: 1px solid rgba(130, 171, 211, 0.11);
}
.step-jump {
width: 38px;
height: 38px;
flex: 0 0 auto;
border: 1px solid rgba(80, 220, 255, 0.24);
border-radius: 12px;
cursor: pointer;
color: var(--cyan);
background: rgba(80, 220, 255, 0.08);
font-size: 0.78rem;
font-weight: 850;
transition: 150ms ease;
}
.step-jump:hover {
color: #05111c;
background: var(--cyan);
}
.stage-title-wrap {
min-width: 0;
}
.stage-kicker {
display: block;
margin-bottom: 4px;
color: #7892b0;
font-size: 0.61rem;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.stage-title {
margin: 0;
overflow: hidden;
font-size: 1rem;
font-weight: 780;
letter-spacing: -0.02em;
text-overflow: ellipsis;
white-space: nowrap;
}
.viewport {
position: relative;
height: 315px;
overflow: hidden;
background:
radial-gradient(circle at 50% 44%, rgba(49, 112, 153, 0.18), transparent 49%),
radial-gradient(circle at 80% 16%, rgba(125, 87, 192, 0.09), transparent 35%);
}
.viewport canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
cursor: grab;
touch-action: none;
}
.viewport canvas:active {
cursor: grabbing;
}
.scene-chip {
position: absolute;
top: 13px;
left: 13px;
z-index: 3;
max-width: calc(100% - 26px);
padding: 7px 9px;
border: 1px solid rgba(117, 175, 220, 0.18);
border-radius: 9px;
pointer-events: none;
color: #bdd1e8;
background: rgba(4, 12, 23, 0.68);
backdrop-filter: blur(10px);
font-size: 0.63rem;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.scene-chip::before {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 7px;
border-radius: 50%;
content: "";
background: var(--cyan);
box-shadow: 0 0 9px var(--cyan);
}
.orbit-hint {
position: absolute;
right: 12px;
bottom: 10px;
z-index: 3;
pointer-events: none;
color: rgba(159, 183, 208, 0.55);
font-size: 0.58rem;
font-weight: 700;
letter-spacing: 0.04em;
}
.stage-body {
min-height: 160px;
padding: 15px 16px 17px;
border-top: 1px solid rgba(130, 171, 211, 0.1);
}
.equation {
display: inline-flex;
min-height: 30px;
align-items: center;
margin-bottom: 10px;
padding: 5px 10px;
border: 1px solid rgba(136, 177, 218, 0.15);
border-radius: 9px;
color: #d9e9fa;
background: rgba(93, 140, 186, 0.07);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.76rem;
font-weight: 700;
}
.stage-description {
min-height: 43px;
margin: 0;
color: #9db2ca;
font-size: 0.78rem;
line-height: 1.55;
}
.atom-track {
display: flex;
gap: 8px;
align-items: center;
margin-top: 12px;
color: #718ba8;
font-size: 0.66rem;
font-weight: 750;
}
.track-dot {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: 0 0 10px currentColor;
}
.track-line {
width: 20px;
height: 1px;
background: rgba(147, 178, 209, 0.34);
}
.reaction-readout {
margin-left: auto;
color: var(--green);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.footer-note {
display: grid;
grid-template-columns: auto 1fr auto;
gap: 16px;
align-items: center;
margin-top: 17px;
padding: 15px 18px;
border: 1px solid rgba(100, 230, 173, 0.15);
border-radius: 16px;
background: rgba(16, 43, 42, 0.35);
}
.footer-icon {
display: grid;
width: 36px;
height: 36px;
place-items: center;
border: 1px solid rgba(100, 230, 173, 0.3);
border-radius: 50%;
color: var(--green);
font-size: 1.1rem;
}
.footer-note p {
margin: 0;
color: #a5b9ca;
font-size: 0.78rem;
line-height: 1.55;
}
.footer-note strong {
color: #e7fbf4;
}
.unchanged {
padding: 7px 10px;
border: 1px solid rgba(100, 230, 173, 0.2);
border-radius: 9px;
color: var(--green);
background: rgba(100, 230, 173, 0.07);
font-size: 0.68rem;
font-weight: 850;
white-space: nowrap;
}
@media (max-width: 1100px) {
.stage-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stage:not(:last-child)::after {
display: none;
}
.hero {
grid-template-columns: 1fr;
}
.balance-card {
max-width: 480px;
}
}
@media (max-width: 720px) {
.app {
width: min(100% - 20px, 650px);
padding-top: 23px;
}
.controls {
grid-template-columns: 1fr;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
}
.cycle-label {
text-align: left;
}
.stage-grid {
grid-template-columns: 1fr;
}
.viewport {
height: 285px;
}
.footer-note {
grid-template-columns: auto 1fr;
}
.unchanged {
grid-column: 1 / -1;
text-align: center;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main class="app">
<header class="hero">
<div>
<div class="eyebrow">Molecular editing lab / catalytic cycle</div>
<h1>One enzyme. Three atoms. A complete catalytic cycle.</h1>
<p class="hero-copy">
Follow the same tracked atoms through approach, binding, bond editing,
and release. The catalyst remains chemically unchanged and ready for
another cycle.
</p>
</div>
<aside class="balance-card" aria-label="Atom and enzyme balance">
<div class="balance-title">Conservation tracker</div>
<div class="balance-row">
<span class="atom-token atom-a">A</span>
<span class="atom-token atom-b">B</span>
<span class="atom-token atom-c">C</span>
<span class="balance-arrow">→</span>
<span class="balance-note">3 atoms → 3 atoms</span>
<span class="enzyme-token">E</span>
<span class="balance-note">unchanged</span>
</div>
</aside>
</header>
<section class="controls" aria-label="Cycle playback controls">
<div class="button-row">
<button id="playButton" class="control-button primary" type="button">
Replay cycle
</button>
<button id="resetButton" class="control-button" type="button">
Start over
</button>
</div>
<div class="timeline-wrap">
<div class="timeline-labels" aria-hidden="true">
<span>01 Approach</span>
<span>02 Bind</span>
<span>03 React</span>
<span>04 Release</span>
</div>
<input
id="timeline"
type="range"
min="0"
max="1000"
value="1000"
aria-label="Catalytic cycle timeline"
/>
</div>
<div class="cycle-label">
<strong id="phaseLabel">Cycle complete</strong>
<span id="timeLabel">100%</span>
</div>
</section>
<p class="checkpoint-note">
Four magnified checkpoints of one cycle. Atom colors track identity;
no molecule is deleted or silently replaced.
</p>
<section class="stage-grid" aria-label="Four linked catalytic cycle displays">
<article class="stage" data-stage="0">
<header class="stage-header">
<button class="step-jump" type="button" aria-label="Jump to approach stage">
01
</button>
<div class="stage-title-wrap">
<span class="stage-kicker">Substrate binding</span>
<h2 class="stage-title">Guided approach</h2>
</div>
</header>
<div class="viewport">
<div class="scene-chip">Substrate S approaching</div>
<div class="orbit-hint">Drag to orbit · scroll to zoom</div>
</div>
<div class="stage-body">
<div class="equation">S = A—B—C</div>
<p class="stage-description">
The intact three-atom substrate approaches the enzyme’s active site.
Its shape and atom identities remain unchanged during transport.
</p>
<div class="atom-track">
<span class="track-dot" style="color:#50dcff;background:#50dcff"></span>
<span class="track-dot" style="color:#ff6f79;background:#ff6f79"></span>
<span class="track-dot" style="color:#ffd166;background:#ffd166"></span>
<span>same atom identities</span>
</div>
</div>
</article>
<article class="stage" data-stage="1">
<header class="stage-header">
<button class="step-jump" type="button" aria-label="Jump to binding stage">
02
</button>
<div class="stage-title-wrap">
<span class="stage-kicker">Substrate binding</span>
<h2 class="stage-title">Active-site capture</h2>
</div>
</header>
<div class="viewport">
<div class="scene-chip">Substrate S docking</div>
<div class="orbit-hint">Drag to orbit · scroll to zoom</div>
</div>
<div class="stage-body">
<div class="equation">S + E → E·S</div>
<p class="stage-description">
The substrate docks without losing an atom. The enzyme binds the
molecule temporarily; binding is not yet the chemical reaction.
</p>
<div class="atom-track">
<span class="track-dot" style="color:#50dcff;background:#50dcff"></span>
<span class="track-dot" style="color:#ff6f79;background:#ff6f79"></span>
<span class="track-dot" style="color:#ffd166;background:#ffd166"></span>
<span class="reaction-readout">3 / 3 retained</span>
</div>
</div>
</article>
<article class="stage" data-stage="2">
<header class="stage-header">
<button class="step-jump" type="button" aria-label="Jump to reaction stage">
03
</button>
<div class="stage-title-wrap">
<span class="stage-kicker">Simplified reaction stage</span>
<h2 class="stage-title">Bond-order editing</h2>
</div>
</header>
<div class="viewport">
<div class="scene-chip">A—B bond: single</div>
<div class="orbit-hint">Drag to orbit · scroll to zoom</div>
</div>
<div class="stage-body">
<div class="equation">E·S → E·P</div>
<p class="stage-description">
A labeled transformation changes the A–B bond from single to double.
A, B, and C remain present; only their connectivity is edited.
</p>
<div class="atom-track">
<span class="track-dot" style="color:#50dcff;background:#50dcff"></span>
<span class="track-dot" style="color:#ff6f79;background:#ff6f79"></span>
<span class="track-dot" style="color:#ffd166;background:#ffd166"></span>
<span class="reaction-readout">A–B: 1× → 2×</span>
</div>
</div>
</article>
<article class="stage" data-stage="3">
<header class="stage-header">
<button class="step-jump" type="button" aria-label="Jump to release stage">
04
</button>
<div class="stage-title-wrap">
<span class="stage-kicker">Product release</span>
<h2 class="stage-title">Release and reuse</h2>
</div>
</header>
<div class="viewport">
<div class="scene-chip">Product P leaving active site</div>
<div class="orbit-hint">Drag to orbit · scroll to zoom</div>
</div>
<div class="stage-body">
<div class="equation">E·P → E + P</div>
<p class="stage-description">
The transformed product exits as a visible molecule. Enzyme E has
the same composition and active site, so it can bind another substrate.
</p>
<div class="atom-track">
<span class="track-dot" style="color:#50dcff;background:#50dcff"></span>
<span class="track-dot" style="color:#ff6f79;background:#ff6f79"></span>
<span class="track-dot" style="color:#ffd166;background:#ffd166"></span>
<span class="reaction-readout">E ready again</span>
</div>
</div>
</article>
</section>
<footer class="footer-note">
<div class="footer-icon">✓</div>
<p>
<strong>Nothing disappears silently.</strong>
This abstract isomerization retains all three atoms, labels the exact bond
change, and shows the product after release. The enzyme is a regenerated
catalyst, not a reactant.
</p>
<div class="unchanged">E unchanged · reusable</div>
</footer>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const COLORS = {
atomA: 0x50dcff,
atomB: 0xff6f79,
atomC: 0xffd166,
enzyme: 0xa587ff,
enzymeDark: 0x6448b5,
active: 0x65efff,
bond: 0xc8d8e8,
grid: 0x24516a
};
const stageElements = [...document.querySelectorAll(".stage")];
const timeline = document.querySelector("#timeline");
const playButton = document.querySelector("#playButton");
const resetButton = document.querySelector("#resetButton");
const phaseLabel = document.querySelector("#phaseLabel");
const timeLabel = document.querySelector("#timeLabel");
const stageDefinitions = [
{
type: "approach",
phase: "Substrate approaching",
focus: 0.11
},
{
type: "binding",
phase: "Substrate binding",
focus: 0.36
},
{
type: "reaction",
phase: "Reaction in progress",
focus: 0.61
},
{
type: "release",
phase: "Product release",
focus: 0.88
}
];
const Y_AXIS = new THREE.Vector3(0, 1, 0);
const SUBSTRATE_POSITIONS = {
A: new THREE.Vector3(-0.78, 0.75, 1.0),
B: new THREE.Vector3(0.0, 1.25, 1.0),
C: new THREE.Vector3(0.78, 0.65, 1.0)
};
const PRODUCT_POSITIONS = {
A: new THREE.Vector3(-0.43, 1.04, 1.0),
B: new THREE.Vector3(0.0, 1.25, 1.0),
C: new THREE.Vector3(0.78, 0.65, 1.0)
};
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function smoothRange(value, start, end) {
const t = clamp((value - start) / (end - start), 0, 1);
return t * t * (3 - 2 * t);
}
function easeInOut(value) {
return value < 0.5
? 4 * value * value * value
: 1 - Math.pow(-2 * value + 2, 3) / 2;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeTextSprite(
text,
{
color = "#eaf6ff",
background = "rgba(5, 14, 27, 0.78)",
border = "rgba(119, 173, 218, 0.35)",
width = 1.8,
height = 0.44,
fontSize = 38
} = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 10, 496, 108, 25);
ctx.fillStyle = background;
ctx.fill();
ctx.strokeStyle = border;
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = color;
ctx.font = `800 ${fontSize}px system-ui, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 65);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, height, 1);
sprite.renderOrder = 20;
return sprite;
}
function makeAtomLabel(letter, color) {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(64, 64, 49, 0, Math.PI * 2);
ctx.fillStyle = "rgba(4, 12, 24, 0.82)";
ctx.fill();
ctx.strokeStyle = `#${new THREE.Color(color).getHexString()}`;
ctx.lineWidth = 6;
ctx.stroke();
ctx.fillStyle = "#f7fbff";
ctx.font = "900 55px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(letter, 64, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(0.48, 0.48, 1);
sprite.renderOrder = 22;
return sprite;
}
function makeAtom(letter, color, labelOffset = [0, 0.39, 0]) {
const group = new THREE.Group();
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.24,
metalness: 0.08,
emissive: new THREE.Color(color).multiplyScalar(0.1)
});
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(0.23, 32, 24),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const highlight = new THREE.Mesh(
new THREE.SphereGeometry(0.12, 20, 16),
new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.18,
depthWrite: false
})
);
highlight.position.set(-0.07, 0.09, 0.16);
group.add(highlight);
const label = makeAtomLabel(letter, color);
label.position.set(...labelOffset);
group.add(label);
return group;
}
function makeBond(materialOptions = {}) {
const material = new THREE.MeshStandardMaterial({
color: COLORS.bond,
roughness: 0.38,
metalness: 0.12,
...materialOptions
});
const bond = new THREE.Mesh(
new THREE.CylinderGeometry(0.052, 0.052, 1, 18),
material
);
bond.castShadow = true;
bond.receiveShadow = true;
return bond;
}
function placeBond(mesh, pointA, pointB, offset = null) {
const a = pointA.clone();
const b = pointB.clone();
if (offset) {
a.add(offset);
b.add(offset);
}
const direction = b.clone().sub(a);
const length = Math.max(direction.length(), 0.0001);
const midpoint = a.clone().add(b).multiplyScalar(0.5);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(Y_AXIS, direction.normalize());
mesh.scale.set(1, length, 1);
}
function makeMolecule(kind) {
const group = new THREE.Group();
const atoms = {
A: makeAtom("A", COLORS.atomA, [-0.12, 0.39, 0]),
B: makeAtom("B", COLORS.atomB, [0.14, 0.43, 0]),
C: makeAtom("C", COLORS.atomC, [0, 0.39, 0])
};
group.add(atoms.A, atoms.B, atoms.C);
const bondAB = makeBond();
const bondBC = makeBond();
group.add(bondAB, bondBC);
let extraBond = null;
if (kind === "reaction" || kind === "product") {
extraBond = makeBond({
transparent: true,
opacity: kind === "product" ? 1 : 0,
depthWrite: false
});
group.add(extraBond);
}
const tagText =
kind === "product"
? "PRODUCT P"
: kind === "reaction"
? "S → P"
: "SUBSTRATE S";
const tag = makeTextSprite(tagText, {
color: kind === "product" ? "#dffcf0" : "#e8f5ff",
border:
kind === "product"
? "rgba(100, 230, 173, 0.42)"
: "rgba(80, 220, 255, 0.35)",
width: 1.72,
height: 0.4
});
tag.position.set(0, 1.98, 0.7);
group.add(tag);
return {
group,
atoms,
bondAB,
bondBC,
extraBond,
tag
};
}
function updateMolecule(molecule, positions, doubleBondAmount = 0) {
const a = positions.A;
const b = positions.B;
const c = positions.C;
molecule.atoms.A.position.copy(a);
molecule.atoms.B.position.copy(b);
molecule.atoms.C.position.copy(c);
placeBond(molecule.bondAB, a, b);
placeBond(molecule.bondBC, b, c);
if (molecule.extraBond) {
const direction = b.clone().sub(a);
const perpendicular = new THREE.Vector3(
-direction.y,
direction.x,
0
)
.normalize()
.multiplyScalar(0.115);
placeBond(molecule.extraBond, a, b, perpendicular);
molecule.extraBond.material.opacity = doubleBondAmount;
molecule.extraBond.scale.x = 0.12 + doubleBondAmount * 0.88;
molecule.extraBond.scale.z = 0.12 + doubleBondAmount * 0.88;
}
}
function makeEnzyme() {
const group = new THREE.Group();
const shellMaterial = new THREE.MeshStandardMaterial({
color: COLORS.enzyme,
roughness: 0.34,
metalness: 0.16,
emissive: new THREE.Color(COLORS.enzymeDark).multiplyScalar(0.12)
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: COLORS.enzymeDark,
roughness: 0.42,
metalness: 0.12
});
const leftLobe = new THREE.Mesh(
new THREE.SphereGeometry(1, 48, 32),
shellMaterial
);
leftLobe.scale.set(0.76, 0.94, 0.43);
leftLobe.position.set(-0.73, 0.55, -0.17);
leftLobe.rotation.z = -0.24;
leftLobe.castShadow = true;
leftLobe.receiveShadow = true;
const rightLobe = leftLobe.clone();
rightLobe.position.set(0.73, 0.54, -0.17);
rightLobe.rotation.z = 0.24;
const upperLobe = new THREE.Mesh(
new THREE.SphereGeometry(1, 48, 32),
darkMaterial
);
upperLobe.scale.set(0.77, 0.46, 0.4);
upperLobe.position.set(0, 1.33, -0.33);
upperLobe.castShadow = true;
group.add(leftLobe, rightLobe, upperLobe);
const activeRing = new THREE.Mesh(
new THREE.TorusGeometry(0.68, 0.065, 18, 72),
new THREE.MeshStandardMaterial({
color: COLORS.active,
roughness: 0.25,
metalness: 0.15,
emissive: new THREE.Color(COLORS.active).multiplyScalar(0.35)
})
);
activeRing.position.set(0, 0.85, 0.57);
group.add(activeRing);
const residueMaterial = new THREE.MeshStandardMaterial({
color: 0xd7ceff,
roughness: 0.3,
emissive: new THREE.Color(COLORS.enzyme).multiplyScalar(0.1)
});
const residueAngles = [0.18, 2.05, 4.15];
for (const angle of residueAngles) {
const residue = new THREE.Mesh(
new THREE.SphereGeometry(0.095, 20, 16),
residueMaterial
);
residue.position.set(
Math.cos(angle) * 0.68,
0.85 + Math.sin(angle) * 0.68,
0.59
);
residue.castShadow = true;
group.add(residue);
}
const activeLight = new THREE.PointLight(COLORS.active, 1.5, 4.2, 2);
activeLight.position.set(0, 0.95, 1.0);
group.add(activeLight);
const label = makeTextSprite("ENZYME E", {
color: "#e7deff",
background: "rgba(28, 17, 54, 0.78)",
border: "rgba(165, 135, 255, 0.42)",
width: 1.65,
height: 0.39,
fontSize: 34
});
label.position.set(0, 2.28, -0.1);
group.add(label);
const reusable = makeTextSprite("REUSABLE CATALYST", {
color: "#bdfce6",
background: "rgba(10, 34, 33, 0.72)",
border: "rgba(100, 230, 173, 0.25)",
width: 1.85,
height: 0.33,
fontSize: 24
});
reusable.position.set(0, -0.38, 0.45);
group.add(reusable);
return { group, activeRing, activeLight };
}
function makeStageEnvironment(scene) {
const grid = new THREE.GridHelper(10, 24, COLORS.grid, 0x173149);
grid.position.y = -0.17;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
const halo = new THREE.Mesh(
new THREE.CircleGeometry(2.65, 80),
new THREE.MeshBasicMaterial({
color: 0x3ca6c6,
transparent: true,
opacity: 0.075,
depthWrite: false,
side: THREE.DoubleSide
})
);
halo.rotation.x = -Math.PI / 2;
halo.position.y = -0.155;
scene.add(halo);
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(2.05, 2.22, 0.13, 72),
new THREE.MeshStandardMaterial({
color: 0x102b43,
roughness: 0.48,
metalness: 0.35
})
);
pedestal.position.y = -0.12;
pedestal.receiveShadow = true;
scene.add(pedestal);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(2.06, 0.025, 10, 96),
new THREE.MeshBasicMaterial({
color: 0x2f8eae,
transparent: true,
opacity: 0.48
})
);
rim.rotation.x = Math.PI / 2;
rim.position.y = -0.045;
scene.add(rim);
}
function makePath(scene, start, control, end, color = COLORS.active) {
const curve = new THREE.QuadraticBezierCurve3(
start.clone(),
control.clone(),
end.clone()
);
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(48)
);
const material = new THREE.LineDashedMaterial({
color,
transparent: true,
opacity: 0.56,
dashSize: 0.13,
gapSize: 0.09,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
scene.add(line);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.095, 0.27, 18),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.82
})
);
arrow.position.copy(end);
arrow.quaternion.setFromUnitVectors(
Y_AXIS,
curve.getTangent(1).normalize()
);
scene.add(arrow);
return { curve, line, arrow };
}
function installCameraControls(camera, renderer) {
const target = new THREE.Vector3(0.18, 0.72, 0.42);
let theta = 0.2;
let phi = 1.15;
let radius = 6.6;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
function resetCamera() {
theta = 0.2;
phi = 1.15;
radius = 6.6;
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
theta -= deltaX * 0.008;
phi = clamp(phi - deltaY * 0.006, 0.56, 1.43);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = clamp(
radius * Math.exp(event.deltaY * 0.001),
4.45,
9.2
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
updateCamera();
return { resetCamera };
}
function createStage(definition, index) {
const viewport = stageElements[index].querySelector(".viewport");
const stateChip = viewport.querySelector(".scene-chip");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
renderer.setClearColor(0x07111f, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
`Interactive 3D display: ${stageElements[index].querySelector(".stage-title").textContent}`
);
renderer.domElement.setAttribute("role", "img");
viewport.prepend(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(0xbadfff, 0x152039, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(4, 7, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(512, 512);
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 18;
keyLight.shadow.camera.left = -4;
keyLight.shadow.camera.right = 4;
keyLight.shadow.camera.top = 4;
keyLight.shadow.camera.bottom = -4;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x8a62ff, 12, 9, 2);
rimLight.position.set(-4, 3.3, 2.5);
scene.add(rimLight);
makeStageEnvironment(scene);
const enzyme = makeEnzyme();
scene.add(enzyme.group);
const molecule = makeMolecule(definition.type);
scene.add(molecule.group);
const update = (time) => {
let text = "";
if (definition.type === "approach") {
const progress = easeInOut(smoothRange(time, 0, 0.24));
const start = new THREE.Vector3(-2.72, -0.2, 0.72);
const end = new THREE.Vector3(-1.43, -0.04, 0.52);
molecule.group.position.lerpVectors(start, end, progress);
updateMolecule(molecule, SUBSTRATE_POSITIONS, 0);
if (progress < 0.08) {
text = "Substrate S ready";
} else if (progress < 0.92) {
text = "Substrate S approaching";
} else {
text = "Substrate at active-site edge";
}
}
if (definition.type === "binding") {
const progress = easeInOut(smoothRange(time, 0.24, 0.48));
const start = new THREE.Vector3(-1.76, -0.2, 0.68);
const end = new THREE.Vector3(0, 0, 0);
molecule.group.position.lerpVectors(start, end, progress);
updateMolecule(molecule, SUBSTRATE_POSITIONS, 0);
if (progress < 0.05) {
text = "Free substrate S";
} else if (progress < 0.93) {
text = "Substrate S docking";
} else {
text = "Bound substrate E·S";
}
}
if (definition.type === "reaction") {
const progress = smoothRange(time, 0.48, 0.73);
const positions = {
A: SUBSTRATE_POSITIONS.A.clone().lerp(PRODUCT_POSITIONS.A, progress),
B: SUBSTRATE_POSITIONS.B.clone().lerp(PRODUCT_POSITIONS.B, progress),
C: SUBSTRATE_POSITIONS.C.clone().lerp(PRODUCT_POSITIONS.C, progress)
};
updateMolecule(molecule, positions, progress);
enzyme.activeLight.intensity =
1.2 + Math.sin(progress * Math.PI) * 7.5;
if (progress < 0.06) {
text = "A–B bond: single";
} else if (progress < 0.94) {
text = `Bond editing · ${Math.round(progress * 100)}%`;
} else {
text = "Product P · A–B bond: double";
}
} else {
enzyme.activeLight.intensity = 1.2;
}
if (definition.type === "release") {
const progress = easeInOut(smoothRange(time, 0.73, 1));
const start = new THREE.Vector3(0, 0, 0);
const end = new THREE.Vector3(2.38, -0.03, 0.35);
molecule.group.position.lerpVectors(start, end, progress);
updateMolecule(molecule, PRODUCT_POSITIONS, 1);
if (progress < 0.06) {
text = "Product P bound in E·P";
} else if (progress < 0.94) {
text = "Product P leaving active site";
} else {
text = "Product P free · enzyme E ready";
}
}
if (stateChip.textContent !== text) {
stateChip.textContent = text;
}
};
if (definition.type === "approach") {
makePath(
scene,
new THREE.Vector3(-2.72, 0.64, 1.72),
new THREE.Vector3(-2.05, 1.25, 2.0),
new THREE.Vector3(-1.43, 0.86, 1.52)
);
}
if (definition.type === "binding") {
makePath(
scene,
new THREE.Vector3(-1.76, 0.65, 1.68),
new THREE.Vector3(-0.85, 1.32, 2.05),
new THREE.Vector3(0, 0.88, 1.0)
);
}
if (definition.type === "release") {
makePath(
scene,
new THREE.Vector3(0, 0.9, 1.0),
new THREE.Vector3(1.24, 1.52, 1.28),
new THREE.Vector3(2.38, 0.9, 1.35),
COLORS.atomC
);
const collectionRing = new THREE.Mesh(
new THREE.TorusGeometry(0.73, 0.026, 12, 72),
new THREE.MeshBasicMaterial({
color: COLORS.atomC,
transparent: true,
opacity: 0.56
})
);
collectionRing.rotation.x = Math.PI / 2;
collectionRing.position.set(2.38, -0.035, 1.35);
scene.add(collectionRing);
const collectionLabel = makeTextSprite("RELEASE ZONE", {
color: "#ffe6a3",
background: "rgba(48, 35, 8, 0.68)",
border: "rgba(255, 209, 102, 0.28)",
width: 1.45,
height: 0.32,
fontSize: 24
});
collectionLabel.position.set(2.38, -0.12, 1.35);
scene.add(collectionLabel);
}
installCameraControls(camera, renderer);
function resize() {
const bounds = viewport.getBoundingClientRect();
const width = Math.max(1, Math.floor(bounds.width));
const height = Math.max(1, Math.floor(bounds.height));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
resize();
return {
renderer,
scene,
camera,
update,
resize
};
}
const stages = stageDefinitions.map(createStage);
let currentTime = 1;
let playing = false;
let lastFrame = performance.now();
function phaseIndex(time) {
if (time < 0.24) return 0;
if (time < 0.48) return 1;
if (time < 0.73) return 2;
return 3;
}
function updateTimelineUI() {
const percentage = Math.round(currentTime * 100);
timeline.value = String(Math.round(currentTime * 1000));
timeline.style.setProperty("--progress", `${percentage}%`);
timeLabel.textContent = `${percentage}%`;
const activeIndex = phaseIndex(currentTime);
stageElements.forEach((element, index) => {
element.classList.toggle("active", index === activeIndex);
element.classList.toggle("passed", index < activeIndex);
});
if (playing) {
phaseLabel.textContent = stageDefinitions[activeIndex].phase;
playButton.textContent = "Pause cycle";
} else {
if (currentTime >= 0.999) {
phaseLabel.textContent = "Cycle complete";
playButton.textContent = "Replay cycle";
} else if (currentTime <= 0.001) {
phaseLabel.textContent = "Cycle ready";
playButton.textContent = "Play cycle";
} else {
phaseLabel.textContent = "Cycle paused";
playButton.textContent = "Continue cycle";
}
}
timeline.setAttribute(
"aria-valuetext",
`${percentage} percent, ${stageDefinitions[activeIndex].phase}`
);
}
function setTime(value) {
currentTime = clamp(value, 0, 1);
updateTimelineUI();
}
playButton.addEventListener("click", () => {
if (playing) {
playing = false;
} else {
if (currentTime >= 0.999) {
currentTime = 0;
}
playing = true;
}
updateTimelineUI();
});
resetButton.addEventListener("click", () => {
playing = false;
setTime(0);
});
timeline.addEventListener("input", () => {
playing = false;
setTime(Number(timeline.value) / 1000);
});
document.querySelectorAll(".step-jump").forEach((button, index) => {
button.addEventListener("click", () => {
playing = false;
setTime(stageDefinitions[index].focus);
});
});
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min(0.05, (now - lastFrame) / 1000);
lastFrame = now;
if (playing) {
currentTime = Math.min(1, currentTime + delta / 7.5);
if (currentTime >= 1) {
playing = false;
}
updateTimelineUI();
}
for (const stage of stages) {
stage.update(currentTime);
stage.renderer.render(stage.scene, stage.camera);
}
}
setTime(1);
requestAnimationFrame(animate);
</script>
</body>
</html>
```