Back to the app
The code
Build a Cell, Part by Part by Claude Haiku 5.5
Exactly as the AI wrote it. Shown as text, so nothing runs on this page.
index.html
works · auto-checked (Checked by an automated pass. Not hand-played yet.)<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>3D Animal Cell</title>
<style>
:root{--bg:#070b14;--panel:rgba(12,20,36,.88);--line:rgba(160,200,255,.22);--ink:#e8f4ff;--muted:#9fb4cc;--accent:#5ee2ff}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html,body{margin:0;height:100%;overflow:hidden;background:var(--bg);color:var(--ink);font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif}
canvas#c{position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none;outline:none}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:16px;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
#top{position:fixed;top:10px;left:10px;right:10px;display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.brand{padding:0 14px;min-height:48px;display:flex;align-items:center;font-weight:700;font-size:16px}
.btn{min-height:48px;padding:0 16px;border-radius:14px;border:1px solid var(--line);background:var(--panel);color:var(--ink);font-size:16px;font-weight:600;font-family:inherit;cursor:pointer}
.btn.primary{background:var(--accent);color:#04121c;border-color:transparent}
.switchbox{margin-left:auto;display:flex;align-items:center;gap:10px;padding:0 10px 0 14px;min-height:52px;font-weight:600;font-size:16px}
.sw{position:relative;width:72px;height:44px;border-radius:22px;border:0;background:#2b3b58;padding:0;cursor:pointer;flex:none}
.sw::after{content:"";position:absolute;top:4px;left:4px;width:36px;height:36px;border-radius:50%;background:#fff;transition:transform .25s}
.sw[aria-checked="true"]{background:var(--accent)}
.sw[aria-checked="true"]::after{transform:translateX(28px)}
#dock{position:fixed;left:50%;transform:translateX(-50%);bottom:10px;width:min(720px,calc(100% - 20px));padding:12px 14px;display:grid;gap:10px}
.rt-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
#rtitle{margin:0;font-size:18px}
#rtext{margin:0;font-size:16px;line-height:1.4;color:#d6e6f7;min-height:3em}
.scrubrow{display:flex;align-items:center;gap:10px}
.scrubrow span{font-weight:600;min-width:52px;font-size:16px}
#scrub{flex:1;height:44px;margin:0;accent-color:var(--accent)}
#chips{display:flex;gap:8px;overflow-x:auto;padding:2px 0 4px}
.chip{flex:none;min-height:44px;padding:0 14px;border-radius:22px;border:1px solid var(--line);background:rgba(255,255,255,.04);color:var(--ink);font-size:15px;font-weight:600;font-family:inherit;cursor:pointer}
.chip.on{border-color:var(--accent);color:var(--accent)}
.chip:disabled{opacity:.35;cursor:default}
.hint{margin:0;font-size:14px;color:var(--muted);text-align:center}
</style>
</head>
<body>
<canvas id="c"></canvas>
<div id="top">
<div class="panel brand">Animal cell 3D</div>
<button class="btn primary" id="rebuild" type="button">Rebuild</button>
<button class="btn" id="whole" type="button">Whole cell</button>
<div class="panel switchbox">
<span>Cut open</span>
<button id="cut" class="sw" type="button" role="switch" aria-checked="false" aria-label="Cut open"></button>
</div>
</div>
<div id="dock" class="panel">
<div class="rt-head">
<h2 id="rtitle" style="margin:0;font-size:18px">Starting</h2>
<button class="btn" id="close" type="button" hidden>Close</button>
</div>
<p id="rtext"></p>
<div class="scrubrow">
<span>Build</span>
<input id="scrub" type="range" min="0" max="1000" value="0" aria-label="Build progress">
</div>
<div id="chips"></div>
<p class="hint">Drag to orbit · Pinch or scroll to zoom · Tap a part to fly to it</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<script>
(function(){
'use strict';
const $ = id => document.getElementById(id);
const N = 11;
const PARTS = [
{name:"Nucleus", text:"The control center. It holds the cell's DNA, the instructions for making everything."},
{name:"Nucleolus", text:"A dense spot inside the nucleus where the parts of ribosomes are made."},
{name:"Rough endoplasmic reticulum", text:"A bumpy network of folded tubes. Ribosomes stuck to it make proteins to ship out."},
{name:"Smooth endoplasmic reticulum", text:"A smooth network of tubes that makes fats and helps clean up harmful chemicals."},
{name:"Ribosomes", text:"Tiny factories that follow the DNA's instructions to link building blocks into proteins."},
{name:"Golgi apparatus", text:"A stack of flat, curved sacs that sorts, packs and labels proteins before they leave."},
{name:"Mitochondria", text:"The power plants. They turn food into energy the cell can use."},
{name:"Lysosomes", text:"Recycling bags full of enzymes that break down old parts and invaders."},
{name:"Vesicles", text:"Tiny bubbles that carry things from one spot in the cell to another."},
{name:"Centrioles", text:"A pair of tiny cylinders that help organize the cell when it divides."},
{name:"Cytoskeleton", text:"A web of protein threads that gives the cell its shape and moves things around inside."}
];
const SHORT = ["Nucleus","Nucleolus","Rough ER","Smooth ER","Ribosomes","Golgi","Mitochondria","Lysosomes","Vesicles","Centrioles","Cytoskeleton"];
/* ---------- fallbacks ---------- */
const rtitle = $('rtitle'), rtext = $('rtext'), closeBtn = $('close');
function setReadout(t, x){ rtitle.textContent = t; rtext.textContent = x; }
if (typeof THREE === 'undefined') {
setReadout('3D view unavailable', 'The 3D library could not load. Check the internet connection and reload the page.');
return;
}
let renderer;
try {
renderer = new THREE.WebGLRenderer({canvas: $('c'), antialias: true});
} catch (err) {
setReadout('3D view unavailable', 'This browser cannot show 3D graphics (WebGL is turned off).');
return;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x070b14, 1);
renderer.localClippingEnabled = true;
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x070b14, 45, 120);
const cam = new THREE.PerspectiveCamera(55, 1, 0.1, 300);
scene.add(new THREE.HemisphereLight(0xdff6ff, 0x1a2238, 1.1));
const sun = new THREE.DirectionalLight(0xffffff, 1.1);
sun.position.set(6, 10, 8);
scene.add(sun);
const glow = new THREE.PointLight(0x5ee2ff, 0.6, 40);
glow.position.set(-4, 3, 4);
scene.add(glow);
/* ---------- seeded random so every load looks the same ---------- */
let seed = 20241;
function rnd(){ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0; return seed / 4294967296; }
function rr(a, b){ return a + (b - a) * rnd(); }
function randDir(){
const u = rr(-1, 1), t = rr(0, Math.PI * 2), s = Math.sqrt(1 - u * u);
return new THREE.Vector3(s * Math.cos(t), u, s * Math.sin(t));
}
const NUC = new THREE.Vector3(-1.6, 0.6, -0.4);
const NR = 2.6;
const NUCLEOLUS = NUC.clone().add(new THREE.Vector3(0.7, 0.35, 0.5));
const GOLGI = new THREE.Vector3(3.2, 2.4, 0.6);
const CEN = new THREE.Vector3(2.4, -1.6, 1.4);
function cellPoint(maxR, nucPad){
for (let k = 0; k < 200; k++) {
const p = randDir().multiplyScalar(Math.cbrt(rnd()) * maxR);
if (p.distanceTo(NUC) > NR + nucPad) return p;
}
return randDir().multiplyScalar(maxR * 0.9);
}
/* ---------- materials, parts registry ---------- */
const allMats = new Set();
const pickables = [];
const parts = [];
const cutPlane = new THREE.Plane(new THREE.Vector3(1, 0, 0), 0);
let cutOn = false;
const cutBtn = $('cut');
function mat(color, op){
const o = (op === undefined) ? 1 : op;
const m = new THREE.MeshStandardMaterial({
color: color, roughness: 0.45, metalness: 0.05,
emissive: color, emissiveIntensity: 0.18,
transparent: o < 1, opacity: o, depthWrite: o >= 1
});
allMats.add(m);
return m;
}
function mesh(geo, m, pos){
const o = new THREE.Mesh(geo, m);
if (pos) o.position.copy(pos);
return o;
}
function addPart(i, group, pivot, focus, fr){
group.traverse(o => { if (o.isMesh || o.isLine) { o.userData.part = i; pickables.push(o); } });
let c = focus, r = fr;
if (!c) {
const box = new THREE.Box3().setFromObject(group);
c = box.getCenter(new THREE.Vector3());
r = Math.min(30, Math.max(6, box.getSize(new THREE.Vector3()).length() * 0.8 + 4));
}
parts[i] = {group: group, pivot: pivot, focus: c, fr: r, ph: rnd() * 6.283, p: 0};
group.visible = false;
scene.add(group);
}
/* 0 nucleus */
{
const g = new THREE.Group();
g.add(mesh(new THREE.SphereGeometry(NR, 40, 28), mat(0x9b7bff, 0.7)));
addPart(0, g, NUC.clone());
}
/* 1 nucleolus */
{
const g = new THREE.Group();
g.add(mesh(new THREE.SphereGeometry(0.95, 28, 20), mat(0x4b2c9a), NUCLEOLUS));
addPart(1, g, NUCLEOLUS.clone());
}
/* 2 rough ER: folded rings around the nucleus */
{
const g = new THREE.Group();
const m = mat(0xf19bb0);
for (let k = 0; k < 4; k++) {
const t = mesh(new THREE.TorusGeometry(rr(3.3, 3.9), 0.2, 10, 56), m, NUC);
t.rotation.set(rr(0, 3.1), rr(0, 3.1), rr(0, 3.1));
g.add(t);
}
addPart(2, g, NUC.clone());
}
/* 3 smooth ER: tubes without ribosomes */
{
const g = new THREE.Group();
const m = mat(0xc9f7a0);
for (let k = 0; k < 5; k++) {
const pts = [];
for (let j = 0; j < 6; j++) pts.push(cellPoint(6.8, 0.5));
const curve = new THREE.CatmullRomCurve3(pts);
g.add(mesh(new THREE.TubeGeometry(curve, 80, 0.16, 8, false), m));
}
addPart(3, g, new THREE.Vector3());
}
/* 4 ribosomes: many small spheres */
{
const g = new THREE.Group();
const im = new THREE.InstancedMesh(new THREE.SphereGeometry(0.14, 8, 6), mat(0x8fe3ff), 220);
const dm = new THREE.Object3D();
for (let k = 0; k < 220; k++) {
dm.position.copy(cellPoint(7.0, 0.4));
dm.updateMatrix();
im.setMatrixAt(k, dm.matrix);
}
im.instanceMatrix.needsUpdate = true;
g.add(im);
addPart(4, g, new THREE.Vector3(), new THREE.Vector3(), 17);
}
/* 5 Golgi: stacked curved sacs */
{
const g = new THREE.Group();
const m = mat(0xffb86b);
for (let k = 0; k < 5; k++) {
const a = mesh(new THREE.TorusGeometry(1.25 - k * 0.08, 0.16, 8, 28, Math.PI * 1.25), m,
GOLGI.clone().add(new THREE.Vector3(0, (k - 2) * 0.34, 0)));
a.rotation.set(Math.PI / 2, 0, k * 0.5);
g.add(a);
}
addPart(5, g, GOLGI.clone(), GOLGI.clone(), 6);
}
/* 6 mitochondria: capsules with inner ridges */
{
const g = new THREE.Group();
const m = mat(0xff6b6b);
const mi = mat(0xb8323f);
for (let k = 0; k < 6; k++) {
const outer = mesh(new THREE.CapsuleGeometry(0.34, 1.0, 6, 14), m, cellPoint(6.6, 0.5));
outer.rotation.set(rr(0, 3), rr(0, 3), rr(0, 3));
outer.add(mesh(new THREE.CapsuleGeometry(0.16, 0.7, 4, 10), mi));
g.add(outer);
}
addPart(6, g, new THREE.Vector3());
}
/* 7 lysosomes */
{
const g = new THREE.Group();
const m = mat(0x6bff8a);
for (let k = 0; k < 8; k++) g.add(mesh(new THREE.SphereGeometry(0.3, 16, 12), m, cellPoint(6.8, 0.6)));
addPart(7, g, new THREE.Vector3());
}
/* 8 vesicles: bubbles gathered near the Golgi */
{
const g = new THREE.Group();
const m = mat(0x9fe8ff, 0.8);
for (let k = 0; k < 10; k++) {
const p = GOLGI.clone().add(randDir().multiplyScalar(rr(1.6, 3.2)));
g.add(mesh(new THREE.SphereGeometry(0.22, 12, 10), m, p));
}
addPart(8, g, GOLGI.clone());
}
/* 9 centrioles: two crossed pairs */
{
const g = new THREE.Group();
const m = mat(0xffe066);
for (let k = 0; k < 2; k++) {
const pos = CEN.clone().add(new THREE.Vector3(k * 0.9 - 0.45, 0, 0));
const a = mesh(new THREE.CylinderGeometry(0.13, 0.13, 1.2, 12), m, pos);
const b = mesh(new THREE.CylinderGeometry(0.13, 0.13, 1.2, 12), m, pos);
b.rotation.x = Math.PI / 2;
g.add(a, b);
}
addPart(9, g, CEN.clone());
}
/* 10 cytoskeleton: thin threads across the cell */
{
const g = new THREE.Group();
const arr = new Float32Array(130 * 2 * 3);
for (let k = 0; k < 130; k++) {
const a = cellPoint(7.0, 0.2);
const b = a.clone().add(randDir().multiplyScalar(rr(1.2, 2.6)));
if (b.length() > 7.6) b.setLength(7.6);
arr.set([a.x, a.y, a.z, b.x, b.y, b.z], k * 6);
}
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.BufferAttribute(arr, 3));
const lm = new THREE.LineBasicMaterial({color: 0xd7c7ff, transparent: true, opacity: 0.5});
allMats.add(lm);
g.add(new THREE.LineSegments(geo, lm));
addPart(10, g, new THREE.Vector3(), new THREE.Vector3(), 16);
}
/* ---------- membrane: see-through shell, shown from the start ---------- */
const memMat = new THREE.MeshStandardMaterial({
color: 0x6fd3ff, emissive: 0x1d7fa6, emissiveIntensity: 0.35, roughness: 0.25,
transparent: true, opacity: 0.16, depthWrite: false, side: THREE.DoubleSide
});
allMats.add(memMat);
const mem = new THREE.Mesh(new THREE.SphereGeometry(9, 64, 48), memMat);
scene.add(mem);
const wireMat = new THREE.MeshBasicMaterial({color: 0x9fe8ff, wireframe: true, transparent: true, opacity: 0.08});
allMats.add(wireMat);
const wire = new THREE.Mesh(new THREE.SphereGeometry(9.02, 36, 24), wireMat);
scene.add(wire);
/* ---------- state ---------- */
let buildT = 0, autoBuild = false, speed = N / 22;
let demo = false, demoT = 0, demoStep = 0;
let theta = 0.7, phi = 1.2, radius = 30;
const tgt = new THREE.Vector3();
const flyTgt = new THREE.Vector3();
let flyR = 30;
let mode = 'build', capKey = -2, builtCount = -1;
let sliderTouched = false;
const scrub = $('scrub');
const chipsEl = $('chips');
const chips = [];
function clampR(r){ return Math.min(70, Math.max(3, r)); }
function clampPhi(v){ return Math.min(2.9, Math.max(0.25, v)); }
function wholeDist(){ return 30 * Math.max(1, 0.75 / cam.aspect); }
function easeOutBack(x){
x = Math.min(Math.max(x, 0), 1);
const c1 = 1.4, c3 = c1 + 1;
return 1 + c3 * Math.pow(x - 1, 3) + c1 * Math.pow(x - 1, 2);
}
function setCut(on){
if (on === cutOn) return;
cutOn = on;
const pl = on ? [cutPlane] : [];
allMats.forEach(m => { m.clippingPlanes = pl; m.needsUpdate = true; });
cutBtn.setAttribute('aria-checked', String(on));
}
function showInfo(i){
mode = 'info';
setReadout(PARTS[i].name, PARTS[i].text);
closeBtn.hidden = false;
}
function hideInfo(){
if (mode !== 'info') return;
mode = 'build';
closeBtn.hidden = true;
capKey = -2;
}
function flyWhole(){ flyTgt.set(0, 0, 0); flyR = clampR(wholeDist()); }
function flyToPart(i, card){
const p = parts[i];
if (!p) return;
flyTgt.copy(p.focus);
flyR = clampR(p.fr);
if (card) showInfo(i);
}
function startBuild(){ buildT = 0; autoBuild = true; speed = N / 22; }
function startDemo(){
demo = true; demoT = 0; demoStep = 0;
buildT = 0; autoBuild = true; speed = N / 6.5;
setCut(false); flyWhole(); hideInfo();
}
function stopDemo(){
if (!demo) return;
demo = false;
speed = N / 22;
}
/* ---------- chips (legend) ---------- */
PARTS.forEach((p, i) => {
const b = document.createElement('button');
b.type = 'button';
b.className = 'chip';
b.textContent = SHORT[i];
b.disabled = true;
b.addEventListener('click', () => { if (demo) stopDemo(); flyToPart(i, true); });
chipsEl.appendChild(b);
chips.push(b);
});
/* ---------- UI ---------- */
closeBtn.addEventListener('click', hideInfo);
$('rebuild').addEventListener('click', () => { stopDemo(); hideInfo(); startBuild(); });
$('whole').addEventListener('click', () => { stopDemo(); hideInfo(); flyWhole(); });
cutBtn.addEventListener('click', () => { if (demo) stopDemo(); setCut(!cutOn); });
scrub.addEventListener('input', () => {
stopDemo();
autoBuild = false;
sliderTouched = true;
buildT = (+scrub.value) / 1000 * N;
});
scrub.addEventListener('change', () => { sliderTouched = false; });
// any real touch ends the hands-free demo
window.addEventListener('pointerdown', () => { if (demo) stopDemo(); }, true);
window.addEventListener('touchstart', () => { if (demo) stopDemo(); }, {capture: true, passive: true});
/* ---------- camera controls: drag, pinch, wheel, tap ---------- */
const pointers = new Map();
let moved = false, maxPtrs = 0, pinch = null;
function dist2(a, b){ return Math.hypot(a.x - b.x, a.y - b.y); }
canvas_setup();
function canvas_setup(){
const canvas = $('c');
canvas.addEventListener('pointerdown', e => {
try { canvas.setPointerCapture(e.pointerId); } catch (_) {}
pointers.set(e.pointerId, {x: e.clientX, y: e.clientY, sx: e.clientX, sy: e.clientY, t: performance.now()});
maxPtrs = Math.max(maxPtrs, pointers.size);
if (pointers.size === 2) {
const v = [...pointers.values()];
pinch = {d: dist2(v[0], v[1]), r: radius};
}
});
canvas.addEventListener('pointermove', e => {
const p = pointers.get(e.pointerId);
if (!p) return;
const dx = e.clientX - p.x, dy = e.clientY - p.y;
p.x = e.clientX; p.y = e.clientY;
if (Math.hypot(p.x - p.sx, p.y - p.sy) > 10) moved = true;
if (pointers.size === 1) {
theta -= dx * 0.008;
phi = clampPhi(phi - dy * 0.008);
} else if (pointers.size === 2 && pinch) {
const v = [...pointers.values()];
const d = Math.max(dist2(v[0], v[1]), 1);
radius = clampR(pinch.r * pinch.d / d);
flyR = radius;
}
});
function end(e){
const p = pointers.get(e.pointerId);
if (!p) return;
pointers.delete(e.pointerId);
if (pointers.size === 0) {
if (!moved && maxPtrs === 1 && e.type === 'pointerup' && performance.now() - p.t < 600) {
pick(e.clientX, e.clientY);
}
moved = false; maxPtrs = 0; pinch = null;
} else if (pointers.size === 1) {
pinch = null;
}
}
canvas.addEventListener('pointerup', end);
canvas.addEventListener('pointercancel', end);
canvas.addEventListener('wheel', e => {
e.preventDefault();
radius = clampR(radius * Math.exp(e.deltaY * 0.0015));
flyR = radius;
}, {passive: false});
}
const ray = new THREE.Raycaster();
ray.params.Line.threshold = 0.35;
const ndc = new THREE.Vector2();
function isShown(o){
for (let n = o; n; n = n.parent) { if (!n.visible) return false; }
return true;
}
function pick(x, y){
const r = $('c').getBoundingClientRect();
ndc.set(((x - r.left) / r.width) * 2 - 1, -((y - r.top) / r.height) * 2 + 1);
ray.setFromCamera(ndc, cam);
const cand = pickables.filter(o => {
const idx = o.userData.part;
return idx !== undefined && parts[idx] && parts[idx].p > 0.6 && isShown(o);
});
const hits = ray.intersectObjects(cand, false);
if (hits.length) {
if (demo) stopDemo();
flyToPart(hits[0].object.userData.part, true);
}
}
/* ---------- sizing ---------- */
function resize(){
const w = window.innerWidth, h = window.innerHeight;
renderer.setSize(w, h, false);
cam.aspect = w / h;
cam.updateProjectionMatrix();
}
window.addEventListener('resize', resize);
resize();
flyWhole();
radius = flyR;
/* ---------- loop ---------- */
let last = performance.now(), T = 0;
function frame(now){
requestAnimationFrame(frame);
const dt = Math.min((now - last) / 1000, 0.05);
last = now;
T += dt;
// hands-free demo (#demo): about 20 seconds, then it loops
if (demo) {
demoT += dt;
if (demoStep === 0 && demoT >= 7) { demoStep = 1; flyToPart(6, true); }
else if (demoStep === 1 && demoT >= 10) { demoStep = 2; setCut(true); }
else if (demoStep === 2 && demoT >= 13) { demoStep = 3; setCut(false); hideInfo(); flyWhole(); }
if (demoT >= 20) startDemo();
theta += dt * 0.25;
}
if (autoBuild) {
buildT += speed * dt;
if (buildT >= N) { buildT = N; autoBuild = false; }
}
// each part fills in, then drifts and pulses gently
for (let i = 0; i < N; i++) {
const p = parts[i];
const pr = easeOutBack(buildT - i);
p.p = pr;
const vis = pr > 0.001;
if (p.group.visible !== vis) p.group.visible = vis;
if (vis) {
const sc = pr * (1 + 0.03 * Math.sin(T * 2 + p.ph));
p.group.scale.setScalar(sc);
p.group.position.copy(p.pivot).multiplyScalar(1 - sc);
p.group.position.x += 0.07 * Math.sin(T * 0.45 + p.ph);
p.group.position.y += 0.07 * Math.sin(T * 0.6 + p.ph * 1.7);
p.group.position.z += 0.07 * Math.cos(T * 0.4 + p.ph * 0.6);
}
}
// caption while building
if (mode === 'build') {
const key = buildT >= N - 1e-4 ? 'done' : Math.min(Math.floor(buildT), N - 1);
if (key !== capKey) {
capKey = key;
if (key === 'done') setReadout('Cell complete', 'Drag to orbit, pinch to zoom, and tap any part to fly to it and read what it does.');
else setReadout('Building: ' + PARTS[key].name, PARTS[key].text);
}
}
if (!sliderTouched) scrub.value = Math.round(buildT / N * 1000);
const bc = Math.min(N, Math.floor(buildT + 1e-4));
if (bc !== builtCount) {
builtCount = bc;
chips.forEach((c, i) => {
const ok = i < bc;
c.disabled = !ok;
c.classList.toggle('on', ok);
});
}
// camera: ease toward the fly target, orbit from theta/phi
const k = 1 - Math.exp(-dt * 3);
tgt.lerp(flyTgt, k);
radius += (flyR - radius) * k;
const sp = Math.sin(phi);
cam.position.set(
tgt.x + radius * sp * Math.sin(theta),
tgt.y + radius * Math.cos(phi),
tgt.z + radius * sp * Math.cos(theta)
);
cam.lookAt(tgt);
// membrane breathes
const ms = 1 + 0.012 * Math.sin(T * 1.3);
mem.scale.setScalar(ms);
wire.scale.setScalar(ms);
renderer.render(scene, cam);
}
if (location.hash === '#demo') startDemo();
else startBuild();
requestAnimationFrame(frame);
})();
</script>
</body>
</html>
