Back to the app
The code
Build a Cell, Part by Part by GPT-6.1 Terra
Exactly as the AI wrote it. Shown as text, so nothing runs on this page.
index.html
broken · 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,viewport-fit=cover"><meta name="theme-color" content="#0b1022">
<title>Cell by Cell · Animal cell explorer</title>
<style>
@import url('data:text/css,');
:root{color-scheme:dark;--ink:#f8f8ff;--muted:#9ca9c5;--line:#ffffff1c;--pink:#f7a8d0;--mint:#a0ead6}*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}body{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:#090e1d;color:var(--ink)}button,input{font:inherit}button{cursor:pointer}#scene{position:absolute;inset:0;touch-action:none}canvas{display:block;width:100%;height:100%}.glow{position:absolute;inset:0;pointer-events:none;background:radial-gradient(ellipse at 53% 46%,transparent 10%,#090e1d19 50%,#090e1d99 100%)}.top{position:absolute;top:0;left:0;right:0;padding:27px 38px;display:flex;align-items:center;justify-content:space-between;pointer-events:none}.brand{display:flex;align-items:center;gap:11px}.brand-icon{width:34px;height:34px;border:1px solid #f4a7d5;border-radius:50%;display:grid;place-items:center;color:#ffc0e0;font-size:19px;box-shadow:0 0 20px #eb82c333}.brand-title{font-size:14px;letter-spacing:.01em;font-weight:750}.brand-sub{font-size:10px;letter-spacing:.16em;text-transform:uppercase;color:#a4aec6;margin-top:2px}.top-note{font-size:11px;letter-spacing:.15em;text-transform:uppercase;color:#a4aec6}.top-note b{color:#a0ead6;margin-right:6px}.intro{position:absolute;top:21%;left:5.5%;max-width:280px;pointer-events:none}.eyebrow{color:#b4ebdd;font-size:10px;letter-spacing:.21em;text-transform:uppercase;font-weight:800}.intro h1{font-size:clamp(34px,4.1vw,62px);line-height:1.02;letter-spacing:-.055em;margin:15px 0;color:#fbf9ff;font-weight:650}.intro h1 span{color:#f0a9d0}.intro p{font-size:14px;line-height:1.65;color:#aeb9d0;max-width:245px}.hint{display:flex;align-items:center;gap:8px;margin-top:23px;color:#d0d6e4;font-size:11px}.hint-icon{border:1px solid #ffffff45;border-radius:50%;width:30px;height:30px;display:grid;place-items:center;font-size:15px}.info{position:absolute;right:5%;top:25%;width:260px;padding:20px 21px 22px;border:1px solid #ffffff22;border-radius:17px;background:linear-gradient(140deg,#1c263add,#121a2ce8);box-shadow:0 20px 60px #0004;backdrop-filter:blur(16px);transition:opacity .25s,transform .25s}.info-top{display:flex;justify-content:space-between;align-items:center;color:#aebbd1;font-size:10px;letter-spacing:.15em;text-transform:uppercase}.info-dot{width:8px;height:8px;background:var(--part-color,#f1a4d0);border-radius:50%;box-shadow:0 0 12px var(--part-color,#f1a4d0)}.info h2{font-size:23px;letter-spacing:-.04em;margin:20px 0 8px}.info p{font-size:13px;line-height:1.6;color:#b8c3d8;margin:0}.info .tag{display:inline-flex;align-items:center;gap:7px;font-size:10px;color:#c6f1e5;letter-spacing:.05em;margin-top:19px}.tag:before{content:'';width:5px;height:5px;border-radius:50%;background:#a0ead6}.bottom{position:absolute;left:50%;bottom:24px;transform:translateX(-50%);width:min(760px,calc(100% - 40px));padding:17px 20px 16px;background:#141d30e8;border:1px solid #ffffff20;border-radius:18px;backdrop-filter:blur(18px);box-shadow:0 20px 60px #0006}.progress-head{display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:11px;color:#acb8ce}.progress-head strong{color:#f1f4fb;font-size:12px}.progress-head span:last-child{font-variant-numeric:tabular-nums}.slider-row{display:flex;align-items:center;gap:12px;margin:10px 0 13px}.slider-row span{font-size:10px;color:#8290aa}input[type=range]{width:100%;height:20px;margin:0;accent-color:#f6a8d0;cursor:pointer}.controls{display:flex;align-items:center;justify-content:space-between;gap:10px;border-top:1px solid #ffffff13;padding-top:13px}.control-group{display:flex;align-items:center;gap:8px}.btn{height:39px;padding:0 15px;border-radius:10px;border:1px solid #ffffff24;background:#ffffff0a;color:#eef3fc;font-size:12px;font-weight:650;white-space:nowrap}.btn:hover{background:#ffffff18}.btn.primary{background:#e9a9cd;color:#202033;border-color:transparent}.btn.primary:hover{background:#ffc5e3}.switch{display:flex;align-items:center;gap:9px;font-size:12px;color:#e5eaf4;cursor:pointer;min-height:40px}.switch input{position:absolute;opacity:0}.track{height:23px;width:40px;background:#435067;border-radius:30px;position:relative;transition:.2s}.track:after{content:'';position:absolute;left:3px;top:3px;width:17px;height:17px;border-radius:50%;background:#fff;transition:.2s}.switch input:checked+.track{background:#e7a4ca}.switch input:checked+.track:after{transform:translateX(17px)}.switch input:focus-visible+.track{outline:2px solid white;outline-offset:3px}.status{font-size:10px;color:#91a1b9;white-space:nowrap}.status i{display:inline-block;width:6px;height:6px;border-radius:50%;background:#98e5cb;margin-right:6px;box-shadow:0 0 10px #98e5cb}.error{display:none;position:absolute;inset:40% 15%;text-align:center;color:#fff}@media(max-width:760px){.top{padding:19px 20px}.top-note{font-size:9px}.intro{top:12%;left:6%;max-width:220px}.intro h1{font-size:35px;margin:10px 0}.intro p{font-size:12px;max-width:190px;line-height:1.45}.hint{margin-top:11px;font-size:10px}.hint-icon{width:25px;height:25px}.info{top:auto;bottom:200px;right:18px;width:210px;padding:14px 15px;border-radius:14px}.info h2{font-size:19px;margin:12px 0 5px}.info p{font-size:11px;line-height:1.4}.info .tag{margin-top:10px}.bottom{bottom:max(12px,env(safe-area-inset-bottom));width:calc(100% - 24px);padding:13px 14px}.status{display:none}.btn{padding:0 12px}.progress-head{font-size:10px}}@media(max-height:600px){.intro{top:15%}.intro p,.hint{display:none}.info{top:18%;bottom:auto}.bottom{bottom:10px}.brand-sub{display:none}}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive 3D animal cell"></div><div class="glow"></div>
<header class="top"><div class="brand"><div class="brand-icon">✳</div><div><div class="brand-title">Cell by Cell</div><div class="brand-sub">A tiny world, up close</div></div></div><div class="top-note"><b>●</b> Interactive biology</div></header>
<section class="intro"><div class="eyebrow">Explore the invisible</div><h1>Meet the<br><span>animal cell.</span></h1><p>A whole world is hiding inside you. Let's build one, piece by piece.</p><div class="hint"><span class="hint-icon">↻</span><span>Drag to orbit · Pinch to zoom</span></div></section>
<aside class="info" id="info" aria-live="polite"><div class="info-top"><span id="info-kicker">The beginning</span><span class="info-dot"></span></div><h2 id="part-name">Cell membrane</h2><p id="part-desc">This flexible outer layer holds the cell together and controls what goes in and out.</p><div class="tag" id="info-tag">Your cell starts here</div></aside>
<div class="bottom"><div class="progress-head"><strong>Build your cell</strong><span id="step-label">Membrane only · 0 / 11</span></div><div class="slider-row"><span>START</span><input id="progress" type="range" min="0" max="11" value="0" step="1" aria-label="Cell build progress"><span>COMPLETE</span></div><div class="controls"><div class="control-group"><button class="btn primary" id="play">Ⅱ Pause</button><button class="btn" id="rebuild">↺ Rebuild</button></div><div class="control-group"><span class="status"><i></i> A living little world</span><label class="switch"><span>Cut open</span><input type="checkbox" id="cut"><span class="track"></span></label></div></div></div><div class="error" id="error">The 3D view couldn't load. Please check your connection and refresh.</div>
<script type="module">
import * as THREE from 'https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js';
import { OrbitControls } from 'https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js';
const parts=[
{name:'Nucleus',color:'#b9a2f4',desc:'The nucleus holds the cell’s DNA and helps direct its activities.'},
{name:'Nucleolus',color:'#efb1df',desc:'The nucleolus makes the pieces needed to build ribosomes.'},
{name:'Rough endoplasmic reticulum',color:'#f19cc3',desc:'This folded network helps make and move proteins, with ribosomes attached to its surface.'},
{name:'Smooth endoplasmic reticulum',color:'#f9c392',desc:'This smooth network makes fats and helps break down harmful substances.'},
{name:'Ribosomes',color:'#ffdc99',desc:'Ribosomes are tiny builders that put proteins together.'},
{name:'Golgi apparatus',color:'#ffa98f',desc:'The Golgi apparatus sorts, packages, and sends materials around the cell.'},
{name:'Mitochondria',color:'#ed8b91',desc:'Mitochondria release energy from food that the cell can use.'},
{name:'Lysosomes',color:'#e1b3ed',desc:'Lysosomes break down waste and worn-out cell parts.'},
{name:'Vesicles',color:'#89dacc',desc:'Vesicles are little sacs that carry materials around the cell.'},
{name:'Centrioles',color:'#f4d58e',desc:'Centrioles help organize the structures used when a cell divides.'},
{name:'Cytoskeleton',color:'#91d9e0',desc:'The cytoskeleton is a network of fibers that supports the cell and helps things move.'}
];
const scene=new THREE.Scene(); scene.background=new THREE.Color(0x0b1122); scene.fog=new THREE.FogExp2(0x0b1122,.035);
const camera=new THREE.PerspectiveCamera(38,innerWidth/innerHeight,.1,100);camera.position.set(0,1,15.8);
const renderer=new THREE.WebGLRenderer({antialias:true,alpha:false});renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setSize(innerWidth,innerHeight);renderer.localClippingEnabled=true;renderer.outputColorSpace=THREE.SRGBColorSpace;document.querySelector('#scene').appendChild(renderer.domElement);
const controls=new OrbitControls(camera,renderer.domElement);controls.enableDamping=true;controls.enablePan=false;controls.minDistance=7;controls.maxDistance=24;controls.target.set(0,0,0);controls.update();
scene.add(new THREE.HemisphereLight(0xd8eaff,0x302243,2));const light=new THREE.DirectionalLight(0xffd3ed,3);light.position.set(5,7,9);scene.add(light);const rim=new THREE.PointLight(0x7adfe3,35,30);rim.position.set(-7,-2,3);scene.add(rim);
const plane=new THREE.Plane(new THREE.Vector3(0,0,-1),0);let cut=false;const materials=[];function mat(color,opts={}){let m=new THREE.MeshStandardMaterial({color,roughness:.38,metalness:.05,clippingPlanes:[],...opts});materials.push(m);return m}const sphere=new THREE.SphereGeometry(1,32,24);const root=new THREE.Group();scene.add(root);
const membrane=new THREE.Mesh(sphere,mat(0x9ce6e0,{transparent:true,opacity:.13,roughness:.15,side:THREE.DoubleSide,depthWrite:false}));membrane.scale.set(4.05,3.48,3.25);root.add(membrane);
const shell=new THREE.Mesh(new THREE.SphereGeometry(1,28,20),new THREE.MeshBasicMaterial({color:0xc6fff4,wireframe:true,transparent:true,opacity:.055,depthWrite:false}));shell.scale.copy(membrane.scale).multiplyScalar(1.002);root.add(shell);
const groups=parts.map(()=>{let g=new THREE.Group();root.add(g);return g});const pick=[];
function mesh(g,geo,m,pos,scale,part){let o=new THREE.Mesh(geo,m);o.position.set(...pos);if(scale)o.scale.set(...scale);g.add(o);if(part!==undefined){o.userData.part=part;pick.push(o)}return o}
const nucleus=mesh(groups[0],sphere,mat(0xa391e3,{transparent:true,opacity:.88}),[-.65,.15,-.25],[1.38,1.24,1.12],0);
mesh(groups[1],sphere,mat(0xecadd9),[-.7,.22,.62],[.46,.43,.39],1);
function tube(g,points,r,color,part){let curve=new THREE.CatmullRomCurve3(points.map(p=>new THREE.Vector3(...p)));return mesh(g,new THREE.TubeGeometry(curve,70,r,8,false),mat(color),[0,0,0],null,part)}
// Curved membrane folds around the nucleus.
for(let j=0;j<5;j++){let pts=[];for(let i=0;i<=30;i++){let t=-1.25+i/30*2.5;let radius=1.48+j*.15;pts.push([-.7+Math.cos(t)*radius,-.05+Math.sin(t)*radius*.8,-.05+(j-2)*.18+Math.sin(t*3+j)*.08])}tube(groups[2],pts,.065,0xef97c1,2);for(let i=3;i<28;i+=4){let p=pts[i];mesh(groups[2],sphere,mat(0xffd5a7),p,[.055,.055,.055],2)}}
for(let j=0;j<4;j++){let pts=[];for(let i=0;i<=24;i++){let t=i/24*Math.PI*1.4;pts.push([-1.8+Math.cos(t)*(.52+j*.12),-.85+Math.sin(t)*(.55+j*.1),.12+j*.13+Math.sin(t*3)*.08])}tube(groups[3],pts,.065,0xf2bd8e,3)}
let seed=13;function rand(){seed=(seed*16807)%2147483647;return(seed-1)/2147483646}for(let i=0;i<45;i++){let x=(rand()-.5)*6.4,y=(rand()-.5)*5.2,z=(rand()-.5)*4.5;if((x+.65)**2+(y-.15)**2+z*z<2.3)x+=1.4;mesh(groups[4],sphere,mat(0xffdc9b),[x,y,z],[.065,.065,.065],4)}
for(let j=0;j<6;j++){let pts=[];for(let i=0;i<=20;i++){let x=-.8+i/20*1.6;pts.push([2.05+x,-1.05+j*.16,.1+.24*(x*x)+Math.sin(x*2+j)*.04])}tube(groups[5],pts,.09,0xffa38a,5)}
const mitoMat=mat(0xe88289);const innerMat=mat(0xffc5a5);[[2,1.4,.35],[-2.45,1.3,-.15],[-2,-1.8,.9],[2.15,-.1,-1.25]].forEach((p,k)=>{let g=new THREE.Group();g.position.set(...p);g.rotation.z=[-.5,.5,.9,-.8][k];groups[6].add(g);mesh(g,sphere,mitoMat,[0,0,0],[.72,.34,.32],6);let pts=[];for(let i=0;i<16;i++)pts.push([-.52+i*.07,(i%2?1:-1)*.18,.29]);tube(g,pts,.035,0xffc3a6,6)});
[[-2.8,.1,.5],[1,2.35,.3],[.9,-2.35,-.3]].forEach(p=>mesh(groups[7],sphere,mat(0xc69cdb),p,[.34,.34,.34],7));
[[-2.9,-.9,-.5],[2.8,.8,0],[.4,-1.9,1.5],[-1,2.35,-.6],[2.8,-1.5,-.2]].forEach((p,i)=>mesh(groups[8],sphere,mat(i%2?0xa0e7df:0x8dcfc9,{transparent:true,opacity:.78}),p,[.2,.2,.2],8));
const cyl=new THREE.CylinderGeometry(.16,.16,.75,12);let c1=mesh(groups[9],cyl,mat(0xf4d28d),[1.5,1.15,1.25],null,9);c1.rotation.z=.5;let c2=mesh(groups[9],cyl,mat(0xf4d28d),[1.75,1.05,1.22],null,9);c2.rotation.z=-.9;
for(let j=0;j<7;j++){let pts=[];let a=j*Math.PI*2/7;for(let i=0;i<=12;i++){let t=i/12;pts.push([Math.cos(a)*(.4+2.8*t),Math.sin(a)*(.4+2.5*t),-1.65+Math.sin(t*4+j)*.45])}tube(groups[10],pts,.022,0x87cdd4,10)}
// Floating specks behind the cell.
const stars=new Float32Array(600*3);for(let i=0;i<600;i++){stars[i*3]=(rand()-.5)*35;stars[i*3+1]=(rand()-.5)*25;stars[i*3+2]=-5-rand()*18}let starGeo=new THREE.BufferGeometry();starGeo.setAttribute('position',new THREE.BufferAttribute(stars,3));scene.add(new THREE.Points(starGeo,new THREE.PointsMaterial({color:0xb0d6e3,size:.025,transparent:true,opacity:.55})));
const progress=document.querySelector('#progress'),stepLabel=document.querySelector('#step-label'),play=document.querySelector('#play'),cutBox=document.querySelector('#cut'),info=document.querySelector('#info'),nameEl=document.querySelector('#part-name'),descEl=document.querySelector('#part-desc'),kicker=document.querySelector('#info-kicker'),tag=document.querySelector('#info-tag');let step=0,playing=true,lastAdvance=performance.now(),selected=-1;let cameraGoal=null,targetGoal=null;
function showInfo(i){selected=i;if(i<0){nameEl.textContent='Cell membrane';descEl.textContent='This flexible outer layer holds the cell together and controls what goes in and out.';kicker.textContent='The beginning';tag.textContent='Your cell starts here';info.style.setProperty('--part-color','#a0ead6')}else{let p=parts[i];nameEl.textContent=p.name;descEl.textContent=p.desc;kicker.textContent='Meet the organelle';tag.textContent=step===11?'Tap another part to explore':'Adding part '+(i+1)+' of 11';info.style.setProperty('--part-color',p.color)}}
function setStep(n,updateInfo=true){step=Math.max(0,Math.min(11,Math.round(n)));groups.forEach((g,i)=>g.visible=i<step);progress.value=step;stepLabel.textContent=step===0?'Membrane only · 0 / 11':step===11?'Cell complete · 11 / 11':parts[step-1].name+' · '+step+' / 11';if(updateInfo)showInfo(step-1);if(step===11){playing=false;play.textContent='▶ Play'}}
function setCut(value){cut=value;cutBox.checked=value;materials.forEach(m=>{m.clippingPlanes=value?[plane]:[];m.needsUpdate=true});shell.visible=!value}
function setPlaying(value){playing=value;play.textContent=value?'Ⅱ Pause':'▶ Play';lastAdvance=performance.now()}
play.addEventListener('click',()=>{endDemo();if(step===11)setStep(0);setPlaying(!playing)});document.querySelector('#rebuild').addEventListener('click',()=>{endDemo();setCut(false);setStep(0);cameraGoal=new THREE.Vector3(0,1,15.8);targetGoal=new THREE.Vector3();setPlaying(true)});progress.addEventListener('input',()=>{endDemo();setPlaying(false);setStep(+progress.value)});cutBox.addEventListener('change',()=>{endDemo();setCut(cutBox.checked)});
let pointerDown=null;renderer.domElement.addEventListener('pointerdown',e=>{endDemo();pointerDown={x:e.clientX,y:e.clientY}});renderer.domElement.addEventListener('pointerup',e=>{if(!pointerDown||Math.hypot(e.clientX-pointerDown.x,e.clientY-pointerDown.y)>8){pointerDown=null;return}pointerDown=null;if(step!==11)return;let pos=new THREE.Vector2(e.clientX/innerWidth*2-1,-e.clientY/innerHeight*2+1),ray=new THREE.Raycaster();ray.setFromCamera(pos,camera);let hits=ray.intersectObjects(pick.filter(o=>o.parent.visible),false).filter(h=>!cut||plane.distanceToPoint(h.point)>=0);if(hits.length){let hit=hits[0];showInfo(hit.object.userData.part);let p=hit.point.clone();targetGoal=p;let direction=camera.position.clone().sub(controls.target).normalize();cameraGoal=p.clone().add(direction.multiplyScalar(8.3))}});
let demo=location.hash==='#demo',demoStart=performance.now(),demoPhase=-1;function endDemo(){demo=false}function demoTick(now){if(!demo)return;let t=((now-demoStart)/1000)%20;if(t<.1&&demoPhase!==0){setCut(false);setStep(0);setPlaying(false);demoPhase=0}if(t<11){let s=Math.min(11,Math.floor(t));if(s!==step)setStep(s);demoPhase=1}else if(t<14){if(demoPhase!==2){setStep(11);setCut(true);demoPhase=2}root.rotation.y+=.004}else if(t<17){if(demoPhase!==3){setCut(false);showInfo(6);targetGoal=new THREE.Vector3(1.6,1,.3);cameraGoal=new THREE.Vector3(1.6,1,9);demoPhase=3}}else{if(demoPhase!==4){setStep(5);cameraGoal=new THREE.Vector3(0,1,15.8);targetGoal=new THREE.Vector3();demoPhase=4}}if(t<1&&demoPhase===4)demoPhase=-1}
window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});function animate(now){requestAnimationFrame(animate);demoTick(now);if(playing&&!demo&&now-lastAdvance>1500){setStep(step+1);lastAdvance=now}groups.forEach((g,i)=>{g.position.y=Math.sin(now*.0007+i)*.045;g.rotation.z=Math.sin(now*.00035+i)*.012});let pulse=1+Math.sin(now*.001)*.012;membrane.scale.set(4.05*pulse,3.48*pulse,3.25*pulse);shell.scale.copy(membrane.scale).multiplyScalar(1.002);if(cameraGoal&&targetGoal){camera.position.lerp(cameraGoal,.045);controls.target.lerp(targetGoal,.045);if(camera.position.distanceTo(cameraGoal)<.02){cameraGoal=null;targetGoal=null}}controls.update();renderer.render(scene,camera)}setStep(0);if(demo)setPlaying(false);requestAnimationFrame(animate);
</script><script>setTimeout(function(){if(!document.querySelector('canvas'))document.getElementById('error').style.display='block'},5000)</script>
</body></html>
