Prompt specification
Build or customize the Three.js 3D scene "Cell boundary exchange 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: Cell boundary exchange exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/cell-boundary-exchange-exhibit-x0855
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing selective cell membranes. Compose a whole-cell outline with enlarged channel and vesicle stations; trace different cargo routes while making clear that the inset structures use incompatible magnifications. Voxel style.
Working Three.js Starter (cell-boundary-exchange-exhibit-x0855):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<title>Selective Cell Membranes — Voxel Traffic Atlas</title>
<style>
:root {
--bg: #050b14;
--panel: rgba(8, 19, 33, 0.78);
--line: rgba(137, 205, 231, 0.18);
--text: #e7f6ff;
--muted: #91a9ba;
--cyan: #28ddc2;
--magenta: #ff4fb8;
--amber: #ffc857;
--violet: #a486ff;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 47% 44%, rgba(24, 69, 91, 0.18), transparent 35%),
radial-gradient(circle at 80% 15%, rgba(72, 38, 105, 0.12), transparent 30%),
linear-gradient(145deg, #07111d 0%, #030810 100%);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body::before {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
opacity: 0.17;
background-image:
linear-gradient(rgba(114, 180, 205, 0.08) 1px, transparent 1px),
linear-gradient(90deg, rgba(114, 180, 205, 0.08) 1px, transparent 1px);
background-size: 44px 44px;
mask-image: radial-gradient(circle at center, black, transparent 88%);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
#hud {
position: fixed;
inset: 0;
z-index: 10;
pointer-events: none;
}
.title-block {
position: absolute;
left: 3.2%;
top: 4%;
width: min(390px, 30vw);
}
.eyebrow,
.tag-kicker,
.local-label,
.button-label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
text-transform: uppercase;
letter-spacing: 0.16em;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
color: var(--cyan);
font-size: 10px;
font-weight: 750;
}
.eyebrow::before {
content: "";
width: 27px;
height: 2px;
background: var(--cyan);
box-shadow: 0 0 12px rgba(40, 221, 194, 0.6);
}
h1 {
margin: 12px 0 8px;
font-size: clamp(34px, 4vw, 62px);
line-height: 0.92;
letter-spacing: -0.055em;
font-weight: 790;
}
h1 span {
color: var(--cyan);
}
.title-block p {
max-width: 345px;
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.scale-warning {
position: absolute;
left: 50%;
top: 4.5%;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 10px;
padding: 8px 13px;
border: 1px solid rgba(255, 200, 87, 0.36);
border-radius: 3px;
background: rgba(26, 22, 14, 0.72);
color: #ffe0a0;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.scale-warning .warning-icon {
color: var(--amber);
font-size: 15px;
line-height: 1;
}
.view-tag {
position: absolute;
width: 188px;
padding: 10px 12px 9px;
border-left: 2px solid var(--cyan);
background: linear-gradient(90deg, rgba(6, 16, 28, 0.9), rgba(6, 16, 28, 0.52));
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
transition: opacity 180ms ease, transform 180ms ease;
}
.view-tag::after {
content: "";
position: absolute;
left: 0;
right: 18px;
bottom: -5px;
height: 1px;
background: linear-gradient(90deg, currentColor, transparent);
opacity: 0.3;
}
.main-view {
left: 3.3%;
top: 24%;
color: var(--cyan);
}
.detail-a {
left: 60.1%;
top: 10.5%;
color: var(--magenta);
}
.detail-b {
left: 60.1%;
top: 52.7%;
color: var(--amber);
}
.tag-top {
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
}
.tag-kicker {
color: currentColor;
font-size: 8px;
font-weight: 800;
}
.magnification {
padding: 3px 5px;
border: 1px solid currentColor;
color: currentColor;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
opacity: 0.9;
}
.view-tag h2 {
margin: 6px 0 7px;
color: var(--text);
font-size: 14px;
line-height: 1;
letter-spacing: 0.02em;
text-transform: uppercase;
}
.scale-row {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scale-bar {
position: relative;
display: inline-block;
width: 58px;
height: 5px;
border: 1px solid currentColor;
border-top: 0;
opacity: 0.8;
}
.scale-bar::before,
.scale-bar::after {
content: "";
position: absolute;
top: -3px;
width: 1px;
height: 4px;
background: currentColor;
}
.scale-bar::before {
left: 0;
}
.scale-bar::after {
right: 0;
}
.route-key {
position: absolute;
left: 3.3%;
bottom: 4.1%;
display: flex;
flex-wrap: wrap;
gap: 9px 17px;
max-width: 530px;
padding: 10px 12px;
border: 1px solid var(--line);
background: rgba(5, 13, 24, 0.75);
backdrop-filter: blur(8px);
transition: opacity 180ms ease;
}
.key-item {
display: flex;
align-items: center;
gap: 7px;
color: #b8cbd8;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.key-swatch {
position: relative;
width: 10px;
height: 10px;
border: 1px solid currentColor;
background: currentColor;
box-shadow: 0 0 10px currentColor;
}
.key-swatch.gate {
width: 12px;
height: 12px;
border-radius: 50%;
background: transparent;
box-shadow: none;
}
.model-note {
position: absolute;
left: 50%;
bottom: 4.2%;
transform: translateX(-50%);
max-width: 440px;
color: #7e97a9;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
line-height: 1.55;
text-align: center;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.model-note strong {
color: #c2d4df;
}
.controls {
position: absolute;
right: 3.2%;
bottom: 3.7%;
display: flex;
align-items: center;
gap: 6px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(131, 197, 221, 0.24);
border-radius: 3px;
padding: 8px 10px;
background: rgba(7, 17, 29, 0.88);
color: #bcd0dd;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
transition: 140ms ease;
}
button:hover {
color: white;
border-color: rgba(40, 221, 194, 0.6);
background: rgba(12, 34, 47, 0.95);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 2px;
}
.live-status {
position: absolute;
right: 3.2%;
top: 4.5%;
display: flex;
align-items: center;
gap: 7px;
color: #9bb4c5;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.live-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink {
0%, 100% { opacity: 0.45; }
50% { opacity: 1; }
}
.labels-off .dom-label {
opacity: 0 !important;
transform: translateY(4px);
}
.main-view.labels-off,
.detail-a.labels-off,
.detail-b.labels-off {
transform: translateY(4px);
}
@media (max-width: 1050px) {
.title-block {
width: 320px;
}
.title-block p {
display: none;
}
.scale-warning {
left: auto;
right: 3.2%;
top: 8.5%;
transform: none;
}
.live-status {
display: none;
}
.view-tag {
transform: scale(0.88);
transform-origin: left top;
}
.route-key {
max-width: 390px;
}
.model-note {
display: none;
}
}
@media (max-width: 720px) {
.title-block {
top: 3%;
}
h1 {
font-size: 34px;
}
.scale-warning {
top: 14%;
right: 3%;
max-width: 220px;
line-height: 1.4;
}
.main-view {
top: 22%;
}
.detail-a {
top: 14%;
}
.detail-b {
top: 54%;
}
.route-key {
display: none;
}
.controls {
right: 50%;
transform: translateX(50%);
bottom: 3%;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive three-dimensional voxel diagram of selective cell membrane traffic"></div>
<div id="hud">
<header class="title-block">
<div class="eyebrow">Membrane logistics / cutaway 03</div>
<h1>Selective<br><span>Cell Membranes</span></h1>
<p>
A voxel atlas of selective import through membrane channels and
bulk export through vesicle fusion. Colored cargo routes connect
the overview to separately magnified stations.
</p>
</header>
<div class="live-status">
<span class="live-dot"></span>
live traffic model
</div>
<div class="scale-warning dom-label">
<span class="warning-icon">⚠</span>
<span>Different magnifications<br>sizes are not comparable</span>
</div>
<section class="view-tag main-view dom-label" aria-label="Whole cell overview">
<div class="tag-top">
<span class="tag-kicker">View 01 / overview</span>
<span class="magnification">×1,500</span>
</div>
<h2>Whole cell</h2>
<div class="scale-row">
<span class="scale-bar"></span>
<span>local bar · 10 µm</span>
</div>
</section>
<section class="view-tag detail-a dom-label" aria-label="Magnified membrane channel">
<div class="tag-top">
<span class="tag-kicker">View 02 / station A</span>
<span class="magnification">×12,000</span>
</div>
<h2>Channel protein</h2>
<div class="scale-row">
<span class="scale-bar"></span>
<span>local bar · 100 nm</span>
</div>
</section>
<section class="view-tag detail-b dom-label" aria-label="Magnified vesicle fusion station">
<div class="tag-top">
<span class="tag-kicker">View 03 / station B</span>
<span class="magnification">×80,000</span>
</div>
<h2>Vesicle fusion</h2>
<div class="scale-row">
<span class="scale-bar"></span>
<span>local bar · 50 nm</span>
</div>
</section>
<div class="route-key dom-label" aria-label="Cargo route legend">
<div class="key-item">
<span class="key-swatch" style="color:var(--magenta)"></span>
small solute / import
</div>
<div class="key-item">
<span class="key-swatch" style="color:var(--amber)"></span>
cargo batch / export
</div>
<div class="key-item">
<span class="key-swatch gate" style="color:var(--violet)"></span>
selective gate
</div>
</div>
<div class="model-note dom-label">
<strong>Scale note:</strong> each inset is an independent magnified view.
Color carries route identity; distance and object size do not.
</div>
<div class="controls">
<button id="pauseButton" type="button" aria-pressed="false">Pause traffic</button>
<button id="labelsButton" type="button" aria-pressed="false">Labels on</button>
<button id="resetButton" type="button">Reset view</button>
</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, camera, and lighting
// ------------------------------------------------------------
const sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x050b14, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera(-17, 17, 10.6, -10.6, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0, 0);
let cameraYaw = 0;
let cameraPitch = 0;
let cameraZoom = 1;
scene.add(new THREE.HemisphereLight(0xbfefff, 0x101523, 1.55));
const keyLight = new THREE.DirectionalLight(0xffffff, 2.25);
keyLight.position.set(-5, 10, 14);
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x20d9c3, 24, 22, 2);
cyanLight.position.set(-5, 2, 8);
scene.add(cyanLight);
const magentaLight = new THREE.PointLight(0xff4fb8, 16, 15, 2);
magentaLight.position.set(8.5, 5, 5);
scene.add(magentaLight);
const amberLight = new THREE.PointLight(0xffbd47, 16, 15, 2);
amberLight.position.set(8.5, -4.5, 5);
scene.add(amberLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const labelGroup = new THREE.Group();
scene.add(labelGroup);
const palette = {
cyan: 0x28ddc2,
cyanDark: 0x147e78,
cyanDeep: 0x0b444e,
blue: 0x4b9eff,
blueDark: 0x244d78,
violet: 0xa486ff,
violetDark: 0x59458f,
magenta: 0xff4fb8,
amber: 0xffc857,
amberDark: 0x9b6b27,
nucleus: 0x6956a4,
nucleusLight: 0x8b73c2,
white: 0xe8f7ff,
dark: 0x0a1827
};
function standardMaterial(color, emissive = 0x000000, emissiveIntensity = 0) {
return new THREE.MeshStandardMaterial({
color,
emissive,
emissiveIntensity,
roughness: 0.58,
metalness: 0.08,
flatShading: true
});
}
const materials = {
membrane: standardMaterial(palette.cyan, 0x0c665e, 0.35),
membraneAlt: standardMaterial(palette.cyanDark, 0x083b3c, 0.25),
membraneBack: standardMaterial(palette.cyanDeep, 0x062a35, 0.18),
gate: standardMaterial(palette.violet, 0x4d278c, 0.46),
gateDark: standardMaterial(palette.violetDark, 0x2d175c, 0.38),
nucleus: standardMaterial(palette.nucleus, 0x251747, 0.22),
nucleusLight: standardMaterial(palette.nucleusLight, 0x33245a, 0.25),
er: standardMaterial(palette.blue, 0x153a73, 0.22),
erDark: standardMaterial(palette.blueDark, 0x102a53, 0.18),
magenta: standardMaterial(palette.magenta, 0xb31370, 0.85),
amber: standardMaterial(palette.amber, 0x9b5d00, 0.75),
teal: standardMaterial(palette.cyan, 0x0a675f, 0.3),
white: standardMaterial(palette.white, 0x314e59, 0.12)
};
function addBox(parent, x, y, z, sx, sy, sz, material, rotation = 0) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.position.set(x, y, z);
mesh.scale.set(sx, sy, sz);
mesh.rotation.z = rotation;
parent.add(mesh);
return mesh;
}
function roundedRectShape(x, y, width, height, radius) {
const shape = new THREE.Shape();
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + height - radius);
shape.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
shape.lineTo(x + radius, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
return shape;
}
function addPanel(cx, cy, width, height, accent) {
const group = new THREE.Group();
const x = cx - width / 2;
const y = cy - height / 2;
const shape = roundedRectShape(x, y, width, height, 0.35);
const fill = new THREE.Mesh(
new THREE.ShapeGeometry(shape, 10),
new THREE.MeshBasicMaterial({
color: 0x071321,
transparent: true,
opacity: 0.84,
depthWrite: false
})
);
fill.position.z = -1.6;
group.add(fill);
const borderPoints = shape.getPoints(72).map(p => new THREE.Vector3(p.x, p.y, -1.45));
const border = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(borderPoints),
new THREE.LineBasicMaterial({
color: accent,
transparent: true,
opacity: 0.35
})
);
group.add(border);
const gridPositions = [];
for (let gx = x + 1; gx < x + width; gx += 1) {
gridPositions.push(gx, y, -1.45, gx, y + height, -1.45);
}
for (let gy = y + 1; gy < y + height; gy += 1) {
gridPositions.push(x, gy, -1.45, x + width, gy, -1.45);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
group.add(new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: 0x6ca3bd,
transparent: true,
opacity: 0.065
})
));
const cornerMaterial = new THREE.MeshBasicMaterial({ color: accent });
const cornerSize = 0.12;
addBox(group, x + 0.18, y + 0.18, -1.25, cornerSize, cornerSize, 0.08, cornerMaterial);
addBox(group, x + width - 0.18, y + 0.18, -1.25, cornerSize, cornerSize, 0.08, cornerMaterial);
addBox(group, x + 0.18, y + height - 0.18, -1.25, cornerSize, cornerSize, 0.08, cornerMaterial);
addBox(group, x + width - 0.18, y + height - 0.18, -1.25, cornerSize, cornerSize, 0.08, cornerMaterial);
scene.add(group);
return group;
}
function makeTextSprite(text, color = "#dff8ff", width = 3.0) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "rgba(3, 10, 19, 0.78)";
context.fillRect(0, 9, 512, 110);
context.strokeStyle = color;
context.globalAlpha = 0.42;
context.strokeRect(1, 10, 510, 108);
context.globalAlpha = 1;
context.fillStyle = color;
context.font = "700 38px ui-monospace, SFMono-Regular, Menlo, monospace";
context.textAlign = "center";
context.textBaseline = "middle";
context.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, width / 4, 1);
sprite.renderOrder = 20;
labelGroup.add(sprite);
return sprite;
}
function placeLabel(text, x, y, color = "#dff8ff", width = 3.0) {
const sprite = makeTextSprite(text, color, width);
sprite.position.set(x, y, 1.8);
return sprite;
}
// ------------------------------------------------------------
// Background technical grid
// ------------------------------------------------------------
const backgroundGrid = new THREE.GridHelper(38, 38, 0x21475a, 0x10293a);
backgroundGrid.rotation.x = Math.PI / 2;
backgroundGrid.position.z = -2.5;
backgroundGrid.material.transparent = true;
backgroundGrid.material.opacity = 0.22;
scene.add(backgroundGrid);
// ------------------------------------------------------------
// Route rendering: smooth guide plus voxel-like tracer dots
// ------------------------------------------------------------
const movers = [];
function makeRoute(points, color, options = {}) {
const spacing = options.spacing ?? 0.23;
const dotSize = options.dotSize ?? 0.105;
const z = options.z ?? 0.88;
const curve = new THREE.CatmullRomCurve3(
points.map(p => new THREE.Vector3(p[0], p[1], z)),
false,
"catmullrom",
0.25
);
const guide = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(curve.getPoints(100)),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.23
})
);
scene.add(guide);
const sampleCount = Math.max(18, Math.ceil(curve.getLength() / spacing));
const samples = curve.getSpacedPoints(sampleCount);
const dotMaterial = new THREE.MeshBasicMaterial({ color });
const dots = new THREE.InstancedMesh(unitBox, dotMaterial, samples.length);
const dummy = new THREE.Object3D();
samples.forEach((sample, index) => {
dummy.position.copy(sample);
dummy.scale.set(dotSize, dotSize, dotSize);
dummy.rotation.z = index * 0.13;
dummy.updateMatrix();
dots.setMatrixAt(index, dummy.matrix);
});
dots.instanceMatrix.needsUpdate = true;
scene.add(dots);
return curve;
}
function addRouteArrow(curve, color, t) {
const point = curve.getPointAt(t);
const tangent = curve.getTangentAt(t);
const group = new THREE.Group();
group.position.copy(point);
group.rotation.z = Math.atan2(tangent.y, tangent.x);
const material = new THREE.MeshBasicMaterial({ color });
addBox(group, -0.10, 0.065, 0, 0.20, 0.075, 0.12, material, -0.62);
addBox(group, -0.10, -0.065, 0, 0.20, 0.075, 0.12, material, 0.62);
scene.add(group);
}
function addMovers(curve, material, count, speed, size = 0.20, offset = 0) {
for (let i = 0; i < count; i++) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size, size, size);
scene.add(mesh);
movers.push({
mesh,
curve,
speed,
phase: offset + i / count,
size
});
}
}
// ------------------------------------------------------------
// Whole-cell overview
// ------------------------------------------------------------
const cellGroup = new THREE.Group();
scene.add(cellGroup);
const cellCenter = new THREE.Vector2(-7, -0.2);
const cellRadiusX = 5.25;
const cellRadiusY = 3.5;
const cellShape = new THREE.Shape();
cellShape.absellipse(
cellCenter.x,
cellCenter.y,
cellRadiusX - 0.25,
cellRadiusY - 0.25,
0,
Math.PI * 2,
false,
0
);
const cellFill = new THREE.Mesh(
new THREE.ShapeGeometry(cellShape, 72),
new THREE.MeshBasicMaterial({
color: 0x0a2c3e,
transparent: true,
opacity: 0.62,
depthWrite: false
})
);
cellFill.position.z = -1.0;
cellGroup.add(cellFill);
const membraneCount = 82;
for (let i = 0; i < membraneCount; i++) {
const angle = (i / membraneCount) * Math.PI * 2;
const x = cellCenter.x + cellRadiusX * Math.cos(angle);
const y = cellCenter.y + cellRadiusY * Math.sin(angle);
const tangentAngle = Math.atan2(
cellRadiusY * Math.cos(angle),
-cellRadiusX * Math.sin(angle)
);
const material = i % 3 === 0
? materials.membraneAlt
: materials.membrane;
addBox(
cellGroup,
x,
y,
0,
0.64,
0.29,
0.72,
material,
tangentAngle
);
}
// Block-built nucleus.
const nucleusGroup = new THREE.Group();
nucleusGroup.position.set(-8.25, -0.45, -0.25);
cellGroup.add(nucleusGroup);
for (let ix = -2; ix <= 2; ix++) {
for (let iy = -1; iy <= 1; iy++) {
const ellipse = (ix * ix) / 6.2 + (iy * iy) / 2.4;
if (ellipse <= 1.02) {
addBox(
nucleusGroup,
ix * 0.48,
iy * 0.48,
((ix + iy) & 1) * 0.22,
0.51,
0.51,
0.58,
(ix + iy) % 2 === 0 ? materials.nucleus : materials.nucleusLight
);
}
}
}
// ER-like stacks.
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 6; col++) {
const x = -6.45 + col * 0.34;
const y = 0.18 + row * 0.22 + Math.sin(col * 0.9) * 0.09;
addBox(
cellGroup,
x,
y,
-0.25,
0.31,
0.13,
0.38,
row % 2 ? materials.er : materials.erDark
);
}
}
// Golgi-like voxel stack.
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 4 - row; col++) {
addBox(
cellGroup,
-9.75 + col * 0.34 + row * 0.14,
-2.12 + row * 0.25,
-0.16,
0.31,
0.22,
0.48,
row % 2 ? materials.teal : materials.er
);
}
}
// Small intracellular vesicles.
const vesicleLocations = [
[-7.2, 1.4], [-6.3, -0.3], [-9.8, 0.8],
[-5.0, -1.0], [-8.8, -2.7], [-10.2, -1.0]
];
vesicleLocations.forEach(([x, y], index) => {
addBox(
cellGroup,
x,
y,
0.1,
0.25,
0.25,
0.34,
index % 2 ? materials.membraneAlt : materials.teal,
index * 0.23
);
});
// Deterministic cytosol flecks.
let randomSeed = 71;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
for (let i = 0; i < 70; i++) {
const x = cellCenter.x + (random() - 0.5) * 9.1;
const y = cellCenter.y + (random() - 0.5) * 6.0;
const normalized =
((x - cellCenter.x) / (cellRadiusX - 0.5)) ** 2 +
((y - cellCenter.y) / (cellRadiusY - 0.5)) ** 2;
if (normalized > 0.92 || (x < -6.6 && y < 1.0 && y > -2.0)) continue;
const size = 0.045 + random() * 0.07;
addBox(
cellGroup,
x,
y,
-0.48 + random() * 0.4,
size,
size,
size,
i % 3 === 0 ? materials.er : materials.membraneAlt
);
}
// Main import gate.
const importAngle = 0.72;
const importRadial = new THREE.Vector2(
Math.cos(importAngle),
Math.sin(importAngle)
);
const importGatePosition = cellCenter.clone().addScaledVector(importRadial, cellRadiusX);
const importOutside = cellCenter.clone().addScaledVector(importRadial, 7.15);
const importInside = cellCenter.clone().addScaledVector(importRadial, 3.05);
const importTangentAngle = Math.atan2(
cellRadiusY * Math.cos(importAngle),
-cellRadiusX * Math.sin(importAngle)
);
const importGate = new THREE.Group();
importGate.position.set(importGatePosition.x, importGatePosition.y, 0.25);
importGate.rotation.z = importTangentAngle;
cellGroup.add(importGate);
for (const side of [-1, 1]) {
addBox(importGate, side * 0.43, 0, 0, 0.28, 0.67, 0.82, materials.gate);
addBox(importGate, side * 0.34, side * 0.34, 0, 0.27, 0.27, 0.82, materials.gateDark);
}
// Main vesicle docking gate.
const exportAngle = -0.65;
const exportRadial = new THREE.Vector2(
Math.cos(exportAngle),
Math.sin(exportAngle)
);
const exportGatePosition = cellCenter.clone().addScaledVector(exportRadial, cellRadiusX);
const exportOutside = cellCenter.clone().addScaledVector(exportRadial, 7.0);
const exportInside = cellCenter.clone().addScaledVector(exportRadial, 2.9);
const exportTangentAngle = Math.atan2(
cellRadiusY * Math.cos(exportAngle),
-cellRadiusX * Math.sin(exportAngle)
);
const exportGate = new THREE.Group();
exportGate.position.set(exportGatePosition.x, exportGatePosition.y, 0.24);
exportGate.rotation.z = exportTangentAngle;
cellGroup.add(exportGate);
for (const side of [-1, 1]) {
addBox(exportGate, side * 0.37, 0, 0, 0.26, 0.56, 0.76, materials.gateDark);
}
// Small overview vesicle.
const overviewVesicleCenter = new THREE.Vector2(-6.05, -1.35);
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2;
addBox(
cellGroup,
overviewVesicleCenter.x + Math.cos(angle) * 0.58,
overviewVesicleCenter.y + Math.sin(angle) * 0.58,
0.15,
0.28,
0.25,
0.42,
materials.teal,
angle + Math.PI / 2
);
}
addBox(cellGroup, -6.05, -1.35, 0.25, 0.26, 0.26, 0.3, materials.amber);
// Overview routes.
const overviewImportRoute = makeRoute([
[importOutside.x, importOutside.y],
[importGatePosition.x + importRadial.x * 0.55, importGatePosition.y + importRadial.y * 0.55],
[importGatePosition.x, importGatePosition.y],
[importInside.x, importInside.y],
[importInside.x - 1.05, importInside.y - 0.25]
], palette.magenta, { spacing: 0.21, dotSize: 0.105 });
const overviewExportRoute = makeRoute([
[-6.05, -1.35],
[-5.45, -1.63],
[exportInside.x, exportInside.y],
[exportGatePosition.x, exportGatePosition.y],
[exportOutside.x, exportOutside.y]
], palette.amber, { spacing: 0.21, dotSize: 0.105 });
addRouteArrow(overviewImportRoute, palette.magenta, 0.58);
addRouteArrow(overviewExportRoute, palette.amber, 0.74);
addMovers(overviewImportRoute, materials.magenta, 4, 0.075, 0.18);
addMovers(overviewExportRoute, materials.amber, 3, 0.062, 0.19, 0.13);
// Overview cargo concentrations.
for (let i = 0; i < 5; i++) {
addBox(
cellGroup,
importOutside.x + 0.35 + random() * 0.45,
importOutside.y + 0.2 + random() * 0.55,
0.7,
0.16,
0.16,
0.16,
materials.magenta
);
}
for (let i = 0; i < 4; i++) {
addBox(
cellGroup,
exportOutside.x + 0.25 + random() * 0.55,
exportOutside.y + random() * 0.45,
0.65,
0.17,
0.17,
0.17,
materials.amber
);
}
placeLabel("NUCLEUS", -8.25, 1.15, "#c7b8ff", 2.0);
placeLabel("GOLGI", -9.35, -2.85, "#78dfff", 1.45);
placeLabel("IMPORT GATE", -1.85, 2.95, "#ff8ed0", 2.25);
placeLabel("VESICLE DOCK", -3.45, -3.25, "#ffd883", 2.2);
// ------------------------------------------------------------
// Detail A: membrane channel
// ------------------------------------------------------------
const detailA = addPanel(8.65, 3.72, 11.45, 7.55, palette.magenta);
function addMembraneRow(parent, startX, endX, y, skipX, skipWidth = 0.68) {
const step = 0.49;
let index = 0;
for (let x = startX; x <= endX + 0.001; x += step) {
if (Math.abs(x - skipX) < skipWidth) continue;
const material = index % 3 === 0
? materials.membraneAlt
: materials.membrane;
addBox(parent, x, y - 0.16, -0.05, 0.44, 0.25, 0.7, material);
addBox(parent, x, y + 0.16, 0.03, 0.44, 0.25, 0.7, materials.membraneBack);
index++;
}
}
addMembraneRow(detailA, 4.15, 13.15, 3.55, 8.65, 0.74);
// Selectivity protein towers surrounding the pore.
for (const side of [-1, 1]) {
for (let row = 0; row < 3; row++) {
addBox(
detailA,
8.65 + side * (0.40 + (row === 1 ? 0.08 : 0)),
2.86 + row * 0.56,
0.18,
0.34,
0.46,
0.9,
row === 1 ? materials.gate : materials.gateDark
);
}
addBox(
detailA,
8.65 + side * 0.56,
3.55,
0.18,
0.30,
0.42,
0.9,
materials.gate
);
}
// Solute concentration is visibly higher outside than inside.
for (let i = 0; i < 11; i++) {
addBox(
detailA,
8.65 + (random() - 0.5) * 0.95,
4.65 + random() * 1.65,
0.25 + random() * 0.3,
0.16,
0.16,
0.16,
materials.magenta
);
}
for (let i = 0; i < 4; i++) {
addBox(
detailA,
8.65 + (random() - 0.5) * 0.72,
0.95 + random() * 1.75,
0.2,
0.14,
0.14,
0.14,
materials.magenta
);
}
const detailImportRoute = makeRoute([
[8.65, 6.6],
[8.65, 5.55],
[8.65, 4.5],
[8.65, 3.55],
[8.65, 2.55],
[8.65, 0.65]
], palette.magenta, {
spacing: 0.18,
dotSize: 0.095,
z: 0.92
});
addRouteArrow(detailImportRoute, palette.magenta, 0.7);
addMovers(detailImportRoute, materials.magenta, 3, 0.12, 0.2);
placeLabel("EXTRACELLULAR", 11.25, 6.08, "#ff8ed0", 2.85);
placeLabel("CYTOSOL", 11.35, 1.08, "#8ce9dc", 1.85);
placeLabel("PLASMA MEMBRANE", 5.62, 3.05, "#7fe9db", 2.35);
placeLabel("SELECTIVE PORE", 10.75, 4.12, "#c9b8ff", 2.35);
// ------------------------------------------------------------
// Detail B: vesicle fusion
// ------------------------------------------------------------
const detailB = addPanel(8.65, -4.23, 11.45, 7.55, palette.amber);
// Plasma membrane below the fusing vesicle.
addMembraneRow(detailB, 4.15, 13.15, -6.48, 8.72, 0.72);
const vesicleCenter = new THREE.Vector2(8.72, -4.15);
const vesicleRadius = 1.58;
const vesicleSegments = 20;
for (let i = 0; i < vesicleSegments; i++) {
const angle = (i / vesicleSegments) * Math.PI * 2;
const x = vesicleCenter.x + Math.cos(angle) * vesicleRadius;
const y = vesicleCenter.y + Math.sin(angle) * vesicleRadius;
addBox(
detailB,
x,
y,
0.03,
0.47,
0.34,
0.76,
i % 4 === 0 ? materials.membraneAlt : materials.membrane,
angle + Math.PI / 2
);
}
// Fusion neck and contact patch.
addBox(detailB, 8.44, -5.72, 0.12, 0.36, 0.55, 0.78, materials.membrane);
addBox(detailB, 9.00, -5.72, 0.12, 0.36, 0.55, 0.78, materials.membrane);
addBox(detailB, 8.72, -6.35, 0.16, 0.56, 0.35, 0.82, materials.gateDark);
// Cargo batch inside the vesicle.
for (let i = 0; i < 7; i++) {
addBox(
detailB,
8.72 + (random() - 0.5) * 1.25,
-3.9 + (random() - 0.5) * 1.2,
0.28 + random() * 0.2,
0.21,
0.21,
0.21,
materials.amber
);
}
// Released extracellular cargo.
for (let i = 0; i < 5; i++) {
addBox(
detailB,
8.72 + (random() - 0.5) * 1.45,
-7.0 - random() * 0.62,
0.2,
0.18,
0.18,
0.18,
materials.amber
);
}
const detailExportRoute = makeRoute([
[8.72, -3.1],
[8.72, -4.0],
[8.72, -5.15],
[8.72, -6.15],
[8.72, -7.55]
], palette.amber, {
spacing: 0.18,
dotSize: 0.095,
z: 0.92
});
addRouteArrow(detailExportRoute, palette.amber, 0.78);
addMovers(detailExportRoute, materials.amber, 3, 0.095, 0.21);
placeLabel("VESICLE LUMEN", 11.25, -2.68, "#ffd883", 2.65);
placeLabel("FUSION PORE", 11.18, -5.66, "#c9b8ff", 2.15);
placeLabel("EXTRACELLULAR", 11.15, -7.25, "#ffd883", 2.65);
// ------------------------------------------------------------
// Camera controls implemented without add-ons
// ------------------------------------------------------------
function updateCamera() {
const radius = 30;
camera.position.set(
cameraTarget.x + radius * Math.sin(cameraYaw) * Math.cos(cameraPitch),
cameraTarget.y + radius * Math.sin(cameraPitch),
cameraTarget.z + radius * Math.cos(cameraYaw) * Math.cos(cameraPitch)
);
camera.lookAt(cameraTarget);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resetView() {
cameraYaw = 0;
cameraPitch = 0;
cameraZoom = 1;
updateCamera();
}
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
cameraYaw = THREE.MathUtils.clamp(cameraYaw + dx * 0.0015, -0.23, 0.23);
cameraPitch = THREE.MathUtils.clamp(cameraPitch - dy * 0.0012, -0.12, 0.12);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.00075),
0.79,
1.22
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetView);
// ------------------------------------------------------------
// UI controls
// ------------------------------------------------------------
const pauseButton = document.getElementById("pauseButton");
const labelsButton = document.getElementById("labelsButton");
const resetButton = document.getElementById("resetButton");
let running = true;
let labelsVisible = true;
function toggleRunning() {
running = !running;
pauseButton.textContent = running ? "Pause traffic" : "Resume traffic";
pauseButton.setAttribute("aria-pressed", String(!running));
}
function toggleLabels() {
labelsVisible = !labelsVisible;
labelGroup.visible = labelsVisible;
document.body.classList.toggle("labels-off", !labelsVisible);
labelsButton.textContent = labelsVisible ? "Labels on" : "Labels off";
labelsButton.setAttribute("aria-pressed", String(!labelsVisible));
}
pauseButton.addEventListener("click", toggleRunning);
labelsButton.addEventListener("click", toggleLabels);
resetButton.addEventListener("click", resetView);
document.addEventListener("keydown", event => {
if (event.code === "Space") {
event.preventDefault();
toggleRunning();
}
if (event.key.toLowerCase() === "r") resetView();
if (event.key.toLowerCase() === "l") toggleLabels();
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
// Preserve a fixed 34-unit world width; increase vertical field
// on narrower displays so the complete infographic remains visible.
const halfWidth = 17;
const halfHeight = halfWidth / aspect;
camera.left = -halfWidth;
camera.right = halfWidth;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
updateCamera();
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
let simulationTime = 0;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
if (running) simulationTime += delta;
movers.forEach((mover, index) => {
const phase = (simulationTime * mover.speed + mover.phase) % 1;
const point = mover.curve.getPointAt(phase);
const tangent = mover.curve.getTangentAt(phase);
mover.mesh.position.copy(point);
mover.mesh.position.z += 0.09;
mover.mesh.rotation.z = Math.atan2(tangent.y, tangent.x) + simulationTime * 0.8;
const pulse = mover.size * (1 + Math.sin(simulationTime * 4.2 + index) * 0.1);
mover.mesh.scale.set(pulse, pulse, pulse);
});
backgroundGrid.material.opacity = 0.2 + Math.sin(simulationTime * 0.45) * 0.025;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```