Prompt specification
Build or customize the Three.js 3D scene "Division planes and cell arrangements" 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: Division planes and cell arrangements
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/division-planes-and-cell-arrangements-x0802
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing bacterial morphology. Show simple division sequences producing pairs, chains, and clusters under different attachment rules; distinguish individual cell shape from the resulting multicellular arrangement. Stylized solid forms.
Working Three.js Starter (division-planes-and-cell-arrangements-x0802):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bacterial Morphology — Interactive Three.js Atlas</title>
<style>
:root {
color-scheme: dark;
--bg: #061116;
--panel: #0a1a21;
--panel-2: #0e222b;
--line: rgba(177, 221, 224, 0.14);
--text: #edf8f7;
--muted: #91a9ad;
--mint: #79dec5;
--coral: #ff8b78;
--gold: #f2c86d;
--blue: #72c9e8;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
min-height: 100%;
margin: 0;
}
body {
overflow: hidden;
background:
radial-gradient(circle at 75% 12%, rgba(44, 104, 111, 0.16), transparent 32%),
var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: 100%;
height: 100vh;
min-height: 680px;
display: flex;
flex-direction: column;
}
.topbar {
height: 82px;
flex: 0 0 82px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 28px;
border-bottom: 1px solid var(--line);
background: rgba(6, 17, 22, 0.88);
backdrop-filter: blur(18px);
z-index: 20;
}
.brand {
display: flex;
align-items: center;
gap: 15px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 42px;
height: 42px;
flex: 0 0 42px;
border: 1px solid rgba(121, 222, 197, 0.4);
border-radius: 50%;
background:
radial-gradient(circle at 36% 32%, #a8f3df 0 7%, transparent 8%),
radial-gradient(circle at 65% 68%, #58bba7 0 6%, transparent 7%),
rgba(121, 222, 197, 0.08);
box-shadow: 0 0 30px rgba(121, 222, 197, 0.09);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 12px rgba(121, 222, 197, 0.65);
}
.brand-mark::before {
left: 8px;
top: 11px;
}
.brand-mark::after {
right: 8px;
bottom: 9px;
}
.eyebrow {
margin: 0 0 5px;
color: var(--mint);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(18px, 2vw, 25px);
font-weight: 650;
letter-spacing: -0.035em;
white-space: nowrap;
}
.brand h1 span {
color: var(--muted);
font-weight: 430;
}
.header-actions {
display: flex;
align-items: center;
gap: 14px;
}
.live-status {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 0 5px rgba(121, 222, 197, 0.08);
animation: breathe 2.2s ease-in-out infinite;
}
@keyframes breathe {
50% {
opacity: 0.45;
box-shadow: 0 0 0 8px rgba(121, 222, 197, 0.02);
}
}
.workspace {
flex: 1;
min-height: 0;
display: grid;
grid-template-columns: 310px minmax(0, 1fr);
}
.sidebar {
min-height: 0;
overflow-y: auto;
padding: 24px 22px 28px;
border-right: 1px solid var(--line);
background: linear-gradient(180deg, rgba(10, 26, 33, 0.98), rgba(7, 20, 26, 0.98));
scrollbar-width: thin;
scrollbar-color: rgba(121, 222, 197, 0.25) transparent;
z-index: 10;
}
.sidebar h2 {
margin: 0 0 8px;
font-size: 20px;
font-weight: 630;
letter-spacing: -0.025em;
}
.intro {
margin: 0 0 22px;
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.concept-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-bottom: 24px;
}
.concept {
min-height: 96px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.025);
}
.concept strong {
display: block;
margin-bottom: 7px;
font-size: 11px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.concept p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.concept.shape strong {
color: var(--gold);
}
.concept.arrangement strong {
color: var(--mint);
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin: 23px 0 11px;
color: #c9d9d9;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.section-title::after {
content: "";
flex: 1;
height: 1px;
background: var(--line);
}
.shape-list {
display: grid;
gap: 7px;
}
.shape-item {
display: grid;
grid-template-columns: 42px 1fr;
align-items: center;
gap: 10px;
padding: 8px 10px;
border-radius: 9px;
background: rgba(255, 255, 255, 0.022);
}
.shape-item strong {
display: block;
margin-bottom: 2px;
font-size: 12px;
font-weight: 600;
}
.shape-item small {
color: var(--muted);
font-size: 10px;
}
.mini-icon {
position: relative;
width: 36px;
height: 27px;
display: grid;
place-items: center;
}
.mini-coccus {
width: 19px;
height: 19px;
border-radius: 50%;
background: var(--coral);
box-shadow: inset -3px -3px 6px rgba(75, 21, 16, 0.25);
}
.mini-bacillus {
width: 31px;
height: 11px;
border-radius: 9px;
background: var(--blue);
box-shadow: inset -4px -3px 6px rgba(11, 60, 81, 0.28);
}
.mini-spirillum {
width: 29px;
height: 18px;
border: 4px solid var(--gold);
border-left-color: transparent;
border-right-color: transparent;
border-radius: 50%;
transform: rotate(-14deg) scaleY(0.65);
}
.story-tabs {
display: grid;
gap: 8px;
}
.story-tab {
position: relative;
width: 100%;
display: grid;
grid-template-columns: 35px 1fr auto;
align-items: center;
gap: 10px;
padding: 10px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
text-align: left;
cursor: pointer;
transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.story-tab:hover {
transform: translateX(2px);
border-color: rgba(121, 222, 197, 0.3);
background: rgba(255, 255, 255, 0.045);
}
.story-tab.active {
border-color: color-mix(in srgb, var(--accent) 55%, transparent);
background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.arrangement-icon {
position: relative;
width: 32px;
height: 27px;
}
.arrangement-icon i {
position: absolute;
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--accent);
box-shadow: inset -1px -1px 2px rgba(0, 0, 0, 0.25);
}
.icon-pair i:nth-child(1) { left: 5px; top: 9px; }
.icon-pair i:nth-child(2) { left: 17px; top: 9px; }
.icon-chain i:nth-child(1) { left: 1px; top: 9px; }
.icon-chain i:nth-child(2) { left: 11px; top: 9px; }
.icon-chain i:nth-child(3) { left: 21px; top: 9px; }
.icon-cluster i:nth-child(1) { left: 11px; top: 8px; }
.icon-cluster i:nth-child(2) { left: 3px; top: 2px; }
.icon-cluster i:nth-child(3) { left: 19px; top: 2px; }
.icon-cluster i:nth-child(4) { left: 3px; top: 15px; }
.icon-cluster i:nth-child(5) { left: 19px; top: 15px; }
.story-tab strong {
display: block;
font-size: 12px;
font-weight: 620;
}
.story-tab small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.story-tab .arrow {
color: var(--muted);
font-size: 16px;
}
.all-button {
width: 100%;
margin-top: 8px;
padding: 9px 10px;
border: 1px solid var(--line);
border-radius: 9px;
background: transparent;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
}
.all-button:hover,
.all-button.active {
color: var(--text);
border-color: rgba(121, 222, 197, 0.35);
background: rgba(121, 222, 197, 0.06);
}
.detail-card {
margin-top: 14px;
padding: 14px;
border: 1px solid rgba(121, 222, 197, 0.18);
border-radius: 12px;
background:
linear-gradient(135deg, rgba(121, 222, 197, 0.07), transparent 70%),
rgba(255, 255, 255, 0.02);
}
.detail-card .label {
margin-bottom: 7px;
color: var(--mint);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.detail-card h3 {
margin: 0 0 5px;
font-size: 14px;
font-weight: 650;
}
.detail-card p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.playback {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 20px;
}
.control-button {
padding: 10px 8px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.035);
font-size: 11px;
cursor: pointer;
}
.control-button:hover {
border-color: rgba(121, 222, 197, 0.35);
background: rgba(121, 222, 197, 0.07);
}
.control-button.primary {
color: #062019;
border-color: var(--mint);
background: var(--mint);
font-weight: 750;
}
.speed-row {
grid-column: 1 / -1;
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 10px;
margin-top: 3px;
color: var(--muted);
font-size: 10px;
}
input[type="range"] {
width: 100%;
accent-color: var(--mint);
}
.toggle-row {
grid-column: 1 / -1;
display: flex;
align-items: center;
justify-content: space-between;
color: var(--muted);
font-size: 10px;
}
.toggle-row input {
accent-color: var(--mint);
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 50% 43%, rgba(40, 91, 97, 0.13), transparent 43%),
#07151c;
}
.stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
cursor: grab;
touch-action: none;
}
.stage canvas:active {
cursor: grabbing;
}
.stage-vignette {
position: absolute;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(3, 11, 15, 0.45), transparent 24%, transparent 76%, rgba(3, 11, 15, 0.42)),
radial-gradient(circle at center, transparent 45%, rgba(2, 9, 12, 0.42) 100%);
z-index: 2;
}
.stage-heading {
position: absolute;
left: 28px;
top: 24px;
pointer-events: none;
z-index: 5;
}
.stage-heading .eyebrow {
margin-bottom: 7px;
}
.stage-heading h2 {
margin: 0;
font-size: clamp(17px, 2vw, 25px);
font-weight: 520;
letter-spacing: -0.03em;
}
.stage-heading h2 span {
color: var(--muted);
font-weight: 390;
}
.section-tag {
position: absolute;
left: 28px;
display: flex;
align-items: center;
gap: 9px;
color: rgba(217, 234, 233, 0.72);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
pointer-events: none;
z-index: 5;
}
.section-tag::before {
content: "";
width: 20px;
height: 1px;
background: currentColor;
}
.section-tag.single {
top: 105px;
}
.section-tag.sequence {
top: 52%;
}
.stage-note {
position: absolute;
top: 25px;
right: 25px;
max-width: 235px;
padding: 11px 13px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(6, 18, 24, 0.68);
color: var(--muted);
font-size: 10px;
line-height: 1.5;
pointer-events: none;
z-index: 5;
backdrop-filter: blur(12px);
}
.stage-note strong {
display: block;
margin-bottom: 3px;
color: var(--text);
font-size: 10px;
}
.world-label {
position: absolute;
left: 0;
top: 0;
z-index: 4;
width: max-content;
max-width: 210px;
pointer-events: none;
will-change: transform;
transition: opacity 180ms ease;
}
.specimen-label {
padding: 8px 11px;
border: 1px solid rgba(180, 220, 222, 0.16);
border-radius: 9px;
background: rgba(6, 18, 24, 0.74);
text-align: center;
backdrop-filter: blur(10px);
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
}
.specimen-label strong {
display: block;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.specimen-label small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
.story-label {
min-width: 174px;
padding: 9px 11px 8px;
border: 1px solid rgba(180, 220, 222, 0.16);
border-top: 2px solid var(--accent);
border-radius: 9px;
background: rgba(6, 18, 24, 0.79);
backdrop-filter: blur(10px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.story-label.selected {
border-color: color-mix(in srgb, var(--accent) 48%, transparent);
border-top-color: var(--accent);
}
.story-label .story-name {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
}
.story-label strong {
font-size: 11px;
font-weight: 700;
}
.story-label .term {
color: var(--accent);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.story-label small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
}
.progress-track {
height: 2px;
margin-top: 8px;
overflow: hidden;
border-radius: 2px;
background: rgba(255, 255, 255, 0.08);
}
.progress-fill {
width: 0;
height: 100%;
background: var(--accent);
box-shadow: 0 0 7px var(--accent);
}
.camera-hint {
position: absolute;
right: 24px;
bottom: 22px;
display: flex;
align-items: center;
gap: 9px;
color: rgba(192, 214, 215, 0.58);
font-size: 9px;
letter-spacing: 0.05em;
pointer-events: none;
z-index: 5;
}
.camera-hint kbd {
padding: 4px 6px;
border: 1px solid rgba(180, 220, 222, 0.16);
border-radius: 5px;
background: rgba(6, 18, 24, 0.62);
color: rgba(237, 248, 247, 0.72);
font-family: inherit;
font-size: 8px;
}
.hidden-labels .world-label {
opacity: 0 !important;
}
@media (max-width: 980px) {
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100vh;
}
.workspace {
display: flex;
flex-direction: column;
}
.stage {
order: 1;
height: 68vh;
min-height: 560px;
}
.sidebar {
order: 2;
overflow: visible;
border-right: 0;
border-top: 1px solid var(--line);
}
.concept-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 620px) {
.topbar {
height: 70px;
flex-basis: 70px;
padding: 0 16px;
}
.brand h1 {
font-size: 17px;
}
.brand h1 span,
.live-status {
display: none;
}
.header-actions button {
padding: 8px 10px;
font-size: 10px;
}
.stage {
height: 72vh;
min-height: 520px;
}
.stage-heading {
left: 17px;
top: 18px;
}
.stage-heading h2 {
max-width: 270px;
font-size: 18px;
}
.stage-note {
display: none;
}
.section-tag {
left: 17px;
}
.section-tag.single {
top: 97px;
}
.section-tag.sequence {
top: 49%;
}
.camera-hint {
right: 13px;
bottom: 12px;
}
.camera-hint span {
display: none;
}
.sidebar {
padding: 22px 16px 30px;
}
}
@media (prefers-reduced-motion: reduce) {
.live-dot {
animation: none;
}
.story-tab,
.world-label {
transition: none;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Interactive microbiology · Plate 01</p>
<h1>Bacterial Morphology <span>/ Cell & Arrangement</span></h1>
</div>
</div>
<div class="header-actions">
<div class="live-status">
<span class="live-dot"></span>
Live division model
</div>
<button id="reset-view" class="control-button" type="button">Reset view</button>
</div>
</header>
<div class="workspace">
<aside class="sidebar" aria-label="Morphology guide and controls">
<p class="eyebrow">Read the model</p>
<h2>Two different questions.</h2>
<p class="intro">
A bacterium’s <strong>shape</strong> describes one cell.
Its <strong>arrangement</strong> describes how daughter cells remain
attached after division.
</p>
<div class="concept-grid">
<div class="concept shape">
<strong>Cell shape</strong>
<p>The geometry of an individual bacterium.</p>
</div>
<div class="concept arrangement">
<strong>Arrangement</strong>
<p>The pattern created by cell-to-cell attachment.</p>
</div>
</div>
<div class="section-title">Single-cell forms</div>
<div class="shape-list">
<div class="shape-item">
<div class="mini-icon" aria-hidden="true"><span class="mini-coccus"></span></div>
<div><strong>Coccus</strong><small>Spherical or ovoid cell</small></div>
</div>
<div class="shape-item">
<div class="mini-icon" aria-hidden="true"><span class="mini-bacillus"></span></div>
<div><strong>Bacillus</strong><small>Rod-shaped cell</small></div>
</div>
<div class="shape-item">
<div class="mini-icon" aria-hidden="true"><span class="mini-spirillum"></span></div>
<div><strong>Spirillum</strong><small>Curved or helical cell</small></div>
</div>
</div>
<div class="section-title">Division outcomes</div>
<div class="story-tabs" role="group" aria-label="Choose a division sequence">
<button class="story-tab" type="button" data-story="0" style="--accent: var(--coral)">
<span class="arrangement-icon icon-pair" aria-hidden="true"><i></i><i></i></span>
<span><strong>Pair</strong><small>One polar attachment</small></span>
<span class="arrow">›</span>
</button>
<button class="story-tab" type="button" data-story="1" style="--accent: var(--mint)">
<span class="arrangement-icon icon-chain" aria-hidden="true"><i></i><i></i><i></i></span>
<span><strong>Chain</strong><small>Persistent polar attachment</small></span>
<span class="arrow">›</span>
</button>
<button class="story-tab" type="button" data-story="2" style="--accent: var(--gold)">
<span class="arrangement-icon icon-cluster" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i></span>
<span><strong>Cluster</strong><small>Lateral attachment in several planes</small></span>
<span class="arrow">›</span>
</button>
</div>
<button id="compare-all" class="all-button active" type="button">Compare all three</button>
<div class="detail-card" aria-live="polite">
<div id="detail-label" class="label">Controlled comparison</div>
<h3 id="detail-title">Shape held constant</h3>
<p id="detail-copy">
Every sequence uses the same spherical cell. Only the attachment
rule and division plane change.
</p>
</div>
<div class="playback">
<button id="play-toggle" class="control-button primary" type="button">Pause</button>
<button id="restart" class="control-button" type="button">Restart</button>
<label class="speed-row" for="speed">
<span>Speed</span>
<input id="speed" type="range" min="0.5" max="1.8" value="1" step="0.1" />
<output id="speed-value">1.0×</output>
</label>
<label class="toggle-row" for="labels-toggle">
<span>Show annotations</span>
<input id="labels-toggle" type="checkbox" checked />
</label>
</div>
</aside>
<main id="stage" class="stage" aria-label="Interactive three-dimensional bacterial morphology model">
<div class="stage-vignette"></div>
<div class="stage-heading">
<p class="eyebrow">Morphology atlas</p>
<h2>One cell. <span>Three attachment rules.</span></h2>
</div>
<div class="section-tag single">Individual cells · shape</div>
<div class="section-tag sequence">Division sequences · arrangement</div>
<div class="stage-note">
<strong>Observe the yellow division plane.</strong>
A daughter cell grows from the mother, then settles into the attachment pattern.
</div>
<div id="world-labels"></div>
<div class="camera-hint">
<kbd>Drag</kbd><span>orbit</span>
<kbd>Scroll</kbd><span>zoom</span>
<kbd>Click</kbd><span>focus</span>
</div>
</main>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const labelRoot = document.getElementById("world-labels");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"3D bacterial morphology. Drag to orbit, scroll to zoom, and click a division sequence to focus it."
);
stage.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07151c);
scene.fog = new THREE.FogExp2(0x07151c, 0.026);
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
const hemisphere = new THREE.HemisphereLight(0xc8f2f0, 0x071015, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xf4fffc, 3.2);
keyLight.position.set(5, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -15;
keyLight.shadow.camera.right = 15;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const warmLight = new THREE.PointLight(0xff806f, 18, 22, 2);
warmLight.position.set(-8, 4, -2);
scene.add(warmLight);
const coolLight = new THREE.PointLight(0x63d8ca, 20, 24, 2);
coolLight.position.set(7, 5, 4);
scene.add(coolLight);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x0a1b22,
roughness: 0.9,
metalness: 0.02
});
const floor = new THREE.Mesh(new THREE.PlaneGeometry(42, 30), floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.position.set(0, -0.07, 0);
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(38, 38, 0x28505a, 0x15323a);
grid.position.y = -0.045;
grid.material.transparent = true;
grid.material.opacity = 0.34;
scene.add(grid);
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x142b34,
roughness: 0.62,
metalness: 0.12
});
const pedestalTopMaterial = new THREE.MeshStandardMaterial({
color: 0x18333c,
roughness: 0.5,
metalness: 0.1
});
const cellGeometry = new THREE.SphereGeometry(0.31, 30, 22);
// -------------------------------------------------------------------------
// Small helpers
// -------------------------------------------------------------------------
const clamp = THREE.MathUtils.clamp;
function smooth01(value) {
const x = clamp(value, 0, 1);
return x * x * (3 - 2 * x);
}
function easeOutCubic(value) {
const x = clamp(value, 0, 1);
return 1 - Math.pow(1 - x, 3);
}
function makeAnchor(parent, x, y, z) {
const anchor = new THREE.Object3D();
anchor.position.set(x, y, z);
parent.add(anchor);
return anchor;
}
function makeWorldLabel(className, html, accent) {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.innerHTML = html;
if (accent) element.style.setProperty("--accent", accent);
labelRoot.appendChild(element);
return element;
}
function makePedestal(radius, y = 0.045) {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius * 1.03, 0.12, 64),
pedestalMaterial
);
base.position.y = y;
base.receiveShadow = true;
base.castShadow = true;
group.add(base);
const top = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 0.94, radius * 0.96, 0.025, 64),
pedestalTopMaterial
);
top.position.y = y + 0.071;
top.receiveShadow = true;
group.add(top);
return group;
}
// -------------------------------------------------------------------------
// Individual cell shape specimens
// -------------------------------------------------------------------------
const specimenData = [
{
name: "Coccus",
subtitle: "spherical cell",
color: 0xff8b78,
x: -5.1
},
{
name: "Bacillus",
subtitle: "rod-shaped cell",
color: 0x72c9e8,
x: 0
},
{
name: "Spirillum",
subtitle: "curved / helical cell",
color: 0xf2c86d,
x: 5.1
}
];
const specimenLabels = [];
function buildSpecimens() {
for (const spec of specimenData) {
const group = new THREE.Group();
group.position.set(spec.x, 0, -3.65);
scene.add(group);
group.add(makePedestal(1.22));
const membraneMaterial = new THREE.MeshPhysicalMaterial({
color: spec.color,
roughness: 0.3,
metalness: 0,
clearcoat: 0.55,
clearcoatRoughness: 0.3
});
if (spec.name === "Coccus") {
const cell = new THREE.Mesh(new THREE.SphereGeometry(0.61, 42, 30), membraneMaterial);
cell.scale.set(1, 0.88, 1);
cell.position.y = 0.83;
cell.castShadow = true;
cell.receiveShadow = true;
group.add(cell);
}
if (spec.name === "Bacillus") {
const cell = new THREE.Mesh(
new THREE.CapsuleGeometry(0.285, 0.94, 9, 24),
membraneMaterial
);
cell.rotation.z = Math.PI / 2;
cell.rotation.y = -0.18;
cell.position.y = 0.79;
cell.castShadow = true;
cell.receiveShadow = true;
group.add(cell);
}
if (spec.name === "Spirillum") {
const points = [];
const turns = 1.65;
for (let i = 0; i <= 44; i++) {
const t = i / 44;
const angle = t * Math.PI * 2 * turns;
points.push(
new THREE.Vector3(
(t - 0.5) * 1.48,
Math.cos(angle) * 0.23,
Math.sin(angle) * 0.23
)
);
}
const curve = new THREE.CatmullRomCurve3(points);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 90, 0.15, 14, false),
membraneMaterial
);
tube.position.y = 0.81;
tube.rotation.y = -0.28;
tube.castShadow = true;
tube.receiveShadow = true;
group.add(tube);
const capGeometry = new THREE.SphereGeometry(0.15, 18, 14);
for (const point of [points[0], points[points.length - 1]]) {
const cap = new THREE.Mesh(capGeometry, membraneMaterial);
cap.position.copy(point);
cap.position.y += 0.81;
cap.rotation.y = -0.28;
cap.castShadow = true;
group.add(cap);
}
}
const anchor = makeAnchor(group, 0, 1.8, 0);
const label = makeWorldLabel(
"specimen-label",
`<strong>${spec.name}</strong><small>${spec.subtitle}</small>`,
`#${spec.color.toString(16).padStart(6, "0")}`
);
specimenLabels.push({ element: label, anchor });
}
}
buildSpecimens();
// -------------------------------------------------------------------------
// Division sequence stories
// -------------------------------------------------------------------------
const stories = [
{
id: "pair",
name: "Pair",
term: "Diplococci",
rule: "One polar attachment",
description:
"After one division, the daughter remains joined to one pole of the mother cell.",
accent: 0xff8b78,
accentCSS: "#ff8b78",
x: -5,
duration: 7.4,
phase: 0,
cells: [
{ target: [-0.31, 0, 0], birth: 0, from: [-0.31, 0, 0] },
{ target: [0.31, 0, 0], birth: 1.35, from: [-0.08, 0, 0] }
],
ringAxes: [1]
},
{
id: "chain",
name: "Chain",
term: "Streptococci",
rule: "Persistent polar attachment",
description:
"Each new daughter stays attached to a free pole, extending the chain at successive divisions.",
accent: 0x79dec5,
accentCSS: "#79dec5",
x: 0,
duration: 11.1,
phase: 0.55,
cells: [
{ target: [-1.12, 0, 0], birth: 0, from: [-1.12, 0, 0] },
{ target: [-0.56, 0, 0], birth: 1.25, from: [-1.12, 0, 0] },
{ target: [0, 0, 0], birth: 2.85, from: [-0.56, 0, 0] },
{ target: [0.56, 0, 0], birth: 4.45, from: [0, 0, 0] },
{ target: [1.12, 0, 0], birth: 6.05, from: [0.56, 0, 0] }
],
ringAxes: [1, 1, 1, 1]
},
{
id: "cluster",
name: "Cluster",
term: "Staphylococci",
rule: "Lateral attachment in several planes",
description:
"Daughters remain attached around the mother in different planes, producing a compact cluster.",
accent: 0xf2c86d,
accentCSS: "#f2c86d",
x: 5,
duration: 12.6,
phase: 1.1,
cells: [
{ target: [0, 0, 0], birth: 0, from: [0, 0, 0] },
{ target: [-0.49, 0.08, 0.05], birth: 1.3, from: [0, 0, 0] },
{ target: [0.49, 0.1, 0.04], birth: 2.55, from: [0, 0, 0] },
{ target: [-0.25, 0.47, -0.03], birth: 3.8, from: [0, 0, 0] },
{ target: [0.27, 0.48, 0.02], birth: 5.05, from: [0, 0, 0] },
{ target: [-0.33, -0.37, 0.05], birth: 6.3, from: [0, 0, 0] },
{ target: [0.34, -0.35, 0.07], birth: 7.55, from: [0, 0, 0] }
],
ringAxes: [0.2, 1.1, 2.0, 0.7, 2.6, 1.7]
}
];
const pickableObjects = [];
const storyLabels = [];
const ringGeometry = new THREE.TorusGeometry(0.35, 0.012, 8, 56);
for (const story of stories) {
const group = new THREE.Group();
group.position.set(story.x, 0, 2.45);
scene.add(group);
story.group = group;
group.add(makePedestal(1.72));
const selectionMaterial = new THREE.MeshBasicMaterial({
color: story.accent,
transparent: true,
opacity: 0.2,
depthWrite: false
});
const selectionRing = new THREE.Mesh(
new THREE.TorusGeometry(1.51, 0.018, 8, 90),
selectionMaterial
);
selectionRing.rotation.x = Math.PI / 2;
selectionRing.position.y = 0.125;
group.add(selectionRing);
story.selectionRing = selectionRing;
const cellMaterial = new THREE.MeshPhysicalMaterial({
color: 0x79dec5,
roughness: 0.29,
metalness: 0,
clearcoat: 0.5,
clearcoatRoughness: 0.28,
emissive: story.accent,
emissiveIntensity: 0.025
});
story.cellMaterial = cellMaterial;
story.cellMeshes = [];
for (const cellData of story.cells) {
const mesh = new THREE.Mesh(cellGeometry, cellMaterial);
mesh.position.set(
cellData.from[0],
0.58,
cellData.from[2]
);
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.storyIndex = stories.indexOf(story);
group.add(mesh);
pickableObjects.push(mesh);
story.cellMeshes.push(mesh);
}
story.divisionRings = [];
for (let i = 0; i < story.cells.length - 1; i++) {
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0xf6d67f,
transparent: true,
opacity: 0,
depthWrite: false
});
const ring = new THREE.Mesh(ringGeometry, ringMaterial);
ring.visible = false;
const axis = story.ringAxes[i] ?? 0;
if (story.id === "chain" || story.id === "pair") {
ring.rotation.y = Math.PI / 2;
} else {
ring.rotation.y = axis;
ring.rotation.x = axis * 0.23;
}
group.add(ring);
story.divisionRings.push(ring);
}
const labelAnchor = makeAnchor(group, 0, 0.12, 1.48);
const label = makeWorldLabel(
"story-label",
`
<div class="story-name">
<strong>${story.name}</strong>
<span class="term">${story.term}</span>
</div>
<small class="stage-copy">Preparing sequence…</small>
<div class="progress-track"><div class="progress-fill"></div></div>
`,
story.accentCSS
);
story.label = label;
story.labelAnchor = labelAnchor;
story.labelStage = label.querySelector(".stage-copy");
story.labelProgress = label.querySelector(".progress-fill");
storyLabels.push(label);
}
// -------------------------------------------------------------------------
// Animation state
// -------------------------------------------------------------------------
let playhead = 0;
let playbackSpeed = 1;
let isPlaying = true;
let selectedStory = -1;
const clock = new THREE.Clock();
function storyTime(story) {
return (playhead + story.phase) % story.duration;
}
function countAttachedCells(story, time) {
let count = 0;
for (const cell of story.cells) {
if (time >= cell.birth + 0.22) count++;
}
return Math.max(1, count);
}
function updateStory(story, time) {
const fadeOut = 1 - smooth01((time - (story.duration - 0.42)) / 0.42);
for (let i = 0; i < story.cells.length; i++) {
const cell = story.cells[i];
const mesh = story.cellMeshes[i];
const age = time - cell.birth;
if (age < 0) {
mesh.visible = false;
continue;
}
mesh.visible = true;
const growth = easeOutCubic(age / 0.82);
const movement = smooth01(age / 0.92);
mesh.position.x = THREE.MathUtils.lerp(cell.from[0], cell.target[0], movement);
mesh.position.y = 0.58 + THREE.MathUtils.lerp(cell.from[1], cell.target[1], movement);
mesh.position.z = THREE.MathUtils.lerp(cell.from[2], cell.target[2], movement);
let pulse = 0;
if (i > 0) {
const sourceBirth = cell.birth;
const pulseAge = time - sourceBirth;
if (pulseAge >= 0 && pulseAge < 0.65) {
pulse = Math.sin((pulseAge / 0.65) * Math.PI) * 0.055;
}
}
const finalScale = growth * fadeOut;
mesh.scale.set(
finalScale * (1 + pulse),
finalScale * 0.9 * (1 + pulse),
finalScale
);
}
for (let i = 0; i < story.divisionRings.length; i++) {
const ring = story.divisionRings[i];
const birth = story.cells[i + 1].birth;
const age = time - birth;
if (age < 0 || age > 1.05) {
ring.visible = false;
continue;
}
const u = age / 1.05;
ring.visible = true;
ring.position.set(
story.cells[i + 1].from[0],
0.58,
story.cells[i + 1].from[2]
);
ring.scale.setScalar(0.82 + u * 0.5);
ring.material.opacity = Math.sin(u * Math.PI) * 0.78 * fadeOut;
}
const attachedCount = countAttachedCells(story, time);
const latestBirth = story.cells
.map(cell => cell.birth)
.filter(birth => birth > 0)
.reduce((latest, birth) => Math.max(latest, birth), 0);
const isDividing = time >= latestBirth && time < latestBirth + 0.8;
let stageText;
if (isDividing) {
stageText = `Division plane ${Math.max(1, attachedCount - 1)} · daughter forming`;
} else {
stageText = `${attachedCount} cell${attachedCount === 1 ? "" : "s"} · ${story.rule.toLowerCase()}`;
}
if (story.labelStage.textContent !== stageText) {
story.labelStage.textContent = stageText;
}
const progress = clamp(time / (story.duration - 0.42), 0, 1);
story.labelProgress.style.width = `${progress * 100}%`;
const isSelected = selectedStory === stories.indexOf(story);
story.selectionRing.material.opacity = isSelected ? 0.9 : 0.16;
story.cellMaterial.emissiveIntensity = isSelected ? 0.075 : 0.02;
story.label.classList.toggle("selected", isSelected);
}
// -------------------------------------------------------------------------
// Custom camera controls: orbit, zoom, focus, keyboard
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0, 0.35, 0);
const desiredTarget = cameraTarget.clone();
let theta = 0;
let phi = 0.93;
let radius = 15;
let desiredTheta = theta;
let desiredPhi = phi;
let desiredRadius = radius;
let pointerDown = false;
let pointerMoved = false;
let pointerX = 0;
let pointerY = 0;
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function comparisonRadius() {
const aspect = Math.max(camera.aspect, 0.45);
return 14.7 * Math.max(1, 1.08 / aspect);
}
function focusRadius(index) {
const aspect = Math.max(camera.aspect, 0.45);
return 5.7 * Math.max(1, 0.9 / aspect);
}
function compareAll() {
selectedStory = -1;
desiredTarget.set(0, 0.35, 0);
desiredRadius = comparisonRadius();
desiredTheta = 0;
desiredPhi = 0.93;
document.querySelectorAll(".story-tab").forEach(button => {
button.classList.remove("active");
});
document.getElementById("compare-all").classList.add("active");
document.getElementById("detail-label").textContent = "Controlled comparison";
document.getElementById("detail-title").textContent = "Shape held constant";
document.getElementById("detail-copy").textContent =
"Every sequence uses the same spherical cell. Only the attachment rule and division plane change.";
}
function selectStory(index, focus = true) {
selectedStory = index;
const story = stories[index];
document.querySelectorAll(".story-tab").forEach(button => {
const buttonIndex = Number(button.dataset.story);
button.classList.toggle("active", buttonIndex === index);
});
document.getElementById("compare-all").classList.remove("active");
document.getElementById("detail-label").textContent = story.rule;
document.getElementById("detail-title").textContent = `${story.name} · ${story.term}`;
document.getElementById("detail-copy").textContent = story.description;
if (focus) {
desiredTarget.set(story.x, 0.54, story.group.position.z);
desiredRadius = focusRadius(index);
desiredTheta = 0;
desiredPhi = 0.9;
}
}
document.querySelectorAll(".story-tab").forEach(button => {
button.addEventListener("click", () => {
selectStory(Number(button.dataset.story), true);
});
});
document.getElementById("compare-all").addEventListener("click", compareAll);
document.getElementById("reset-view").addEventListener("click", compareAll);
renderer.domElement.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
if (Math.abs(dx) + Math.abs(dy) > 3) pointerMoved = true;
desiredTheta -= dx * 0.006;
desiredPhi = clamp(desiredPhi + dy * 0.004, 0.42, 1.36);
pointerX = event.clientX;
pointerY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", event => {
pointerDown = false;
if (!pointerMoved) {
const rect = renderer.domElement.getBoundingClientRect();
pointerNDC.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const hits = raycaster.intersectObjects(pickableObjects, false);
if (hits.length) {
selectStory(hits[0].object.userData.storyIndex, true);
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = false;
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
desiredRadius = clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
4.3,
29
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", compareAll);
renderer.domElement.addEventListener("keydown", event => {
const key = event.key;
if (key === "ArrowLeft") desiredTheta += 0.12;
else if (key === "ArrowRight") desiredTheta -= 0.12;
else if (key === "ArrowUp") desiredPhi = clamp(desiredPhi - 0.09, 0.42, 1.36);
else if (key === "ArrowDown") desiredPhi = clamp(desiredPhi + 0.09, 0.42, 1.36);
else if (key === "+" || key === "=") desiredRadius = clamp(desiredRadius - 0.7, 4.3, 29);
else if (key === "-" || key === "_") desiredRadius = clamp(desiredRadius + 0.7, 4.3, 29);
else if (key.toLowerCase() === "r") compareAll();
else return;
event.preventDefault();
});
// -------------------------------------------------------------------------
// Sidebar controls
// -------------------------------------------------------------------------
const playButton = document.getElementById("play-toggle");
const speedInput = document.getElementById("speed");
const speedOutput = document.getElementById("speed-value");
playButton.addEventListener("click", () => {
isPlaying = !isPlaying;
playButton.textContent = isPlaying ? "Pause" : "Play";
});
document.getElementById("restart").addEventListener("click", () => {
playhead = 0;
});
speedInput.addEventListener("input", () => {
playbackSpeed = Number(speedInput.value);
speedOutput.value = `${playbackSpeed.toFixed(1)}×`;
});
document.getElementById("labels-toggle").addEventListener("change", event => {
stage.classList.toggle("hidden-labels", !event.target.checked);
});
// -------------------------------------------------------------------------
// Responsive sizing and label projection
// -------------------------------------------------------------------------
let stageWidth = 1;
let stageHeight = 1;
function resize() {
stageWidth = Math.max(stage.clientWidth, 1);
stageHeight = Math.max(stage.clientHeight, 1);
camera.aspect = stageWidth / stageHeight;
camera.updateProjectionMatrix();
renderer.setSize(stageWidth, stageHeight, false);
if (selectedStory < 0) {
desiredRadius = comparisonRadius();
} else {
desiredRadius = focusRadius(selectedStory);
}
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
resize();
const projected = new THREE.Vector3();
function positionLabel(element, anchor, offsetX = 0, offsetY = 0) {
anchor.getWorldPosition(projected);
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
if (!visible) {
element.style.opacity = "0";
return;
}
const x = (projected.x * 0.5 + 0.5) * stageWidth + offsetX;
const y = (-projected.y * 0.5 + 0.5) * stageHeight + offsetY;
element.style.transform =
`translate(-50%, -50%) translate(${x.toFixed(1)}px, ${y.toFixed(1)}px)`;
}
function updateLabels() {
for (const item of specimenLabels) {
positionLabel(item.element, item.anchor, 0, 0);
}
for (const story of stories) {
positionLabel(story.label, story.labelAnchor, 0, 18);
}
}
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (isPlaying) {
playhead += delta * playbackSpeed;
}
for (const story of stories) {
updateStory(story, storyTime(story));
}
const damping = 1 - Math.exp(-delta * 8.5);
cameraTarget.lerp(desiredTarget, damping);
theta += (desiredTheta - theta) * damping;
phi += (desiredPhi - phi) * damping;
radius += (desiredRadius - radius) * damping;
const horizontalRadius = Math.sin(phi) * radius;
camera.position.set(
cameraTarget.x + horizontalRadius * Math.sin(theta),
cameraTarget.y + Math.cos(phi) * radius,
cameraTarget.z + horizontalRadius * Math.cos(theta)
);
camera.lookAt(cameraTarget);
camera.updateMatrixWorld();
updateLabels();
renderer.render(scene, camera);
}
compareAll();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```