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
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,viewport-fit=cover"><title>Cell Explorer</title>
<style>
:root{color-scheme:dark;font-family:system-ui,-apple-system,sans-serif;background:#071322;color:#edfaff}*{box-sizing:border-box}body{margin:0;overflow:hidden}#scene{position:absolute;inset:0;touch-action:none}canvas{display:block}button,input{font:inherit}button{border:1px solid #ffffff28;background:#152c40;color:#effcff;border-radius:14px;padding:12px 16px;cursor:pointer;font-weight:700;min-height:46px}button:active{transform:scale(.97)}button.primary{background:#8ce8d1;color:#073b3c;border-color:transparent}.top{position:absolute;top:0;left:0;right:0;padding:20px 24px;pointer-events:none;display:flex;justify-content:space-between;gap:12px}.eyebrow{color:#7de4d0;text-transform:uppercase;letter-spacing:.18em;font-size:11px;font-weight:800}.top h1{margin:4px 0;font-size:clamp(22px,3vw,34px);letter-spacing:-.04em}.top p{margin:0;color:#a8c4ce;font-size:13px}.badge{height:fit-content;padding:8px 12px;border:1px solid #ffffff20;border-radius:99px;color:#b4dedb;font-size:12px;background:#0b1c2caa}.card{position:absolute;left:24px;bottom:133px;width:min(340px,calc(100% - 48px));padding:20px;border:1px solid #ffffff22;border-radius:22px;background:#10283adc;box-shadow:0 16px 60px #0005;backdrop-filter:blur(16px);pointer-events:none}.card .kicker{font-size:11px;color:#80e5cf;font-weight:800;letter-spacing:.13em;text-transform:uppercase}.card h2{font-size:25px;line-height:1.1;margin:8px 0}.card p{color:#c6dce2;line-height:1.5;font-size:14px;margin:0}.card .hint{margin-top:13px;color:#86aeb8;font-size:12px}.controls{position:absolute;bottom:0;left:0;right:0;padding:16px 24px max(18px,env(safe-area-inset-bottom));background:linear-gradient(transparent,#071322ee 28%);display:flex;gap:12px;align-items:end}.timeline{flex:1;min-width:120px}.line{display:flex;justify-content:space-between;gap:10px;color:#c6dce2;font-size:12px;font-weight:700;margin-bottom:5px}input[type=range]{width:100%;accent-color:#8ce8d1;height:28px;margin:0;cursor:pointer}.actions{display:flex;gap:8px}.switch.on{background:#573b83;border-color:#c7a5ff}.legend{position:absolute;right:24px;top:100px;color:#b5d2d9;font-size:12px;text-align:right;line-height:1.7;pointer-events:none}.legend span{display:block}.dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#89e7d3;margin-right:6px}.notice{position:absolute;right:24px;bottom:135px;color:#9ab9c3;font-size:12px;text-align:right;pointer-events:none}@media(max-width:600px){.top{padding:16px}.top p{max-width:230px}.badge{font-size:10px}.legend{display:none}.card{left:16px;bottom:153px;width:min(290px,calc(100% - 32px));padding:15px}.card h2{font-size:21px}.card p{font-size:13px}.controls{padding:12px 16px max(14px,env(safe-area-inset-bottom));flex-wrap:wrap;gap:6px}.timeline{flex-basis:100%}.actions{width:100%}.actions button{flex:1;padding:10px}.notice{display:none}}
</style></head><body>
<div id="scene" aria-label="Interactive 3D animal cell"></div>
<header class="top"><div><div class="eyebrow">A tiny world, made visible</div><h1>Cell Explorer <span style="color:#8ce8d1">✳</span></h1><p>Build an animal cell, one amazing part at a time.</p></div><div class="badge">INTERACTIVE LAB · 01</div></header>
<div class="legend"><span><i class="dot"></i> A living system</span><span>Not to scale</span></div>
<section class="card" aria-live="polite"><div class="kicker" id="step">THE BEGINNING</div><h2 id="title">Cell membrane</h2><p id="description">The membrane is a flexible boundary that controls what enters and leaves the cell.</p><div class="hint" id="hint">Watch the cell come together.</div></section>
<div class="notice">Drag to orbit · Pinch or scroll to zoom<br>Tap a part to explore</div>
<div class="controls"><div class="timeline"><div class="line"><span>BUILD THE CELL</span><span id="progress">0 / 11 parts</span></div><input id="slider" aria-label="Scrub through cell build" type="range" min="0" max="11" value="0" step="1"></div><div class="actions"><button id="cut" class="switch" aria-pressed="false">◐ Cut open</button><button id="rebuild" class="primary">↻ Rebuild</button></div></div>
<script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
<script>
(()=>{
const data=[
['Nucleus','The nucleus holds the cell’s DNA and helps direct its activities.'],
['Nucleolus','The nucleolus makes the building blocks of ribosomes inside the nucleus.'],
['Rough endoplasmic reticulum','The rough endoplasmic reticulum helps make and transport proteins.'],
['Smooth endoplasmic reticulum','The smooth endoplasmic reticulum makes fats and helps break down harmful substances.'],
['Ribosomes','Ribosomes are tiny protein-making machines.'],
['Golgi apparatus','The Golgi apparatus sorts and packages materials for delivery.'],
['Mitochondria','Mitochondria release usable energy from food for the cell.'],
['Lysosomes','Lysosomes break down waste and worn-out cell parts.'],
['Vesicles','Vesicles are tiny sacs that carry materials around the cell.'],
['Centrioles','Centrioles help organize structures used when a cell divides.'],
['Cytoskeleton','The cytoskeleton is a network of fibers that supports the cell and helps it move.']];
const host=document.getElementById('scene'),slider=document.getElementById('slider'),title=document.getElementById('title'),desc=document.getElementById('description'),step=document.getElementById('step'),hint=document.getElementById('hint'),progress=document.getElementById('progress'),cutButton=document.getElementById('cut');
const scene=new THREE.Scene();scene.background=new THREE.Color(0x071322);scene.fog=new THREE.Fog(0x071322,18,35);
const camera=new THREE.PerspectiveCamera(42,1,.1,100);const renderer=new THREE.WebGLRenderer({antialias:true,alpha:false});renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.localClippingEnabled=true;host.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0xb8fff3,0x182343,2));const light=new THREE.DirectionalLight(0xffffff,2.5);light.position.set(5,8,10);scene.add(light);const fill=new THREE.PointLight(0x8e6aff,30,22);fill.position.set(-5,-2,4);scene.add(fill);
const root=new THREE.Group();scene.add(root);const clip=new THREE.Plane(new THREE.Vector3(0,0,-1),0);let cut=false;
function mat(color,extra={}){return new THREE.MeshStandardMaterial({color,roughness:.42,metalness:.08,clippingPlanes:[clip],clipShadows:true,...extra})}
const membraneMat=mat(0x58dbc7,{transparent:true,opacity:.14,side:THREE.DoubleSide,depthWrite:false});const membrane=new THREE.Mesh(new THREE.SphereGeometry(3.05,64,48),membraneMat);membrane.scale.set(1.13,.88,1);root.add(membrane);
const wire=new THREE.Mesh(new THREE.SphereGeometry(3.07,32,24),mat(0x65d9c4,{wireframe:true,transparent:true,opacity:.07,depthWrite:false}));wire.scale.copy(membrane.scale);root.add(wire);
const parts=[],clickables=[];function group(i){const g=new THREE.Group();g.userData.index=i;root.add(g);parts[i]=g;return g}function mesh(g,geo,material,pos,scale){const m=new THREE.Mesh(geo,material);if(pos)m.position.set(...pos);if(scale)m.scale.set(...scale);m.userData.index=g.userData.index;g.add(m);clickables.push(m);return m}
const sphere=new THREE.SphereGeometry(1,32,24);const tube=(points,r=.06)=>new THREE.TubeGeometry(new THREE.CatmullRomCurve3(points.map(p=>new THREE.Vector3(...p))),60,r,8,false);
let g=group(0);mesh(g,sphere,mat(0x9772e8,{transparent:true,opacity:.84}),[-.35,.22,0],[1.16,1.04,1.03]);
g=group(1);mesh(g,sphere,mat(0xf4a5f0),[-.15,.34,.77],[.31,.31,.31]);
g=group(2);for(let j=0;j<5;j++){let pts=[];for(let k=0;k<=36;k++){let a=-1.35+k/36*2.7;let r=1.35+j*.13;pts.push([-.4-Math.cos(a)*r,.2+Math.sin(a)*r*.75,(j-2)*.17])}mesh(g,tube(pts,.075),mat(0x79bdf4))}
g=group(3);for(let j=0;j<4;j++){let pts=[];for(let k=0;k<=32;k++){let a=-1.2+k/32*2.4;let r=1.35+j*.15;pts.push([-.25+Math.cos(a)*r,.15+Math.sin(a)*r*.74,(j-1.5)*.18-.35])}mesh(g,tube(pts,.08),mat(0x70dfd2))}
g=group(4);const ribMat=mat(0xffe092);for(let j=0;j<48;j++){let a=-1.25+(j%12)/11*2.5,r=1.35+Math.floor(j/12)*.13;mesh(g,sphere,ribMat,[-.4-Math.cos(a)*r,.2+Math.sin(a)*r*.75,(Math.floor(j/12)-2)*.17+.09],[.065,.065,.065])}for(let j=0;j<15;j++){let a=j*2.4;mesh(g,sphere,ribMat,[Math.cos(a)*(1.7+(j%3)*.25),Math.sin(a)*1.5,Math.sin(j*4)*.9],[.055,.055,.055])}
g=group(5);for(let j=0;j<5;j++){let pts=[];for(let k=0;k<=20;k++){let x=(k/20-.5)*1.15;pts.push([1.65+x,-.9+j*.12+.24*x*x,.6+Math.sin(k/20*Math.PI)*.12])}mesh(g,tube(pts,.08),mat(0xffa7bc))}
g=group(6);let mitoMat=mat(0xff9b72);for(const p of [[-2,-1.05,.55],[1.85,1.05,.25],[.65,-1.65,-.45]]){let m=mesh(g,sphere,mitoMat,p,[.55,.25,.28]);m.rotation.z=.6;let line=[];for(let k=0;k<12;k++)line.push([p[0]+(k/11-.5)*.75,p[1]+Math.sin(k*Math.PI)*.08+Math.sin(k*2.6)*.12,p[2]+.23]);mesh(g,tube(line,.025),mat(0xffdfaa))}
g=group(7);for(const p of [[-1.7,.95,1],[2,.1,.9],[-.7,-1.7,.65]])mesh(g,sphere,mat(0xf4c460),p,[.21,.21,.21]);
g=group(8);for(const p of [[1.55,-1.55,.65],[2.35,.5,-.4],[-2.2,.25,.1],[.5,1.65,.65]])mesh(g,sphere,mat(0x8de0ed,{transparent:true,opacity:.75}),p,[.15,.15,.15]);
g=group(9);for(let i=0;i<2;i++){let m=mesh(g,new THREE.CylinderGeometry(.13,.13,.72,12),mat(0xf6d68b),[.95,1.55,.8]);m.rotation.z=i?Math.PI/2:.2;m.position.x+=i*.28}
g=group(10);for(let j=0;j<13;j++){let a=j*2.4;let pts=[];for(let k=0;k<7;k++){let t=k/6;pts.push([Math.cos(a+t*1.2)*(1.1+t*1.5),Math.sin(a+t*1.2)*(1+t*1.1),Math.sin(a*2+t*3)*.9])}mesh(g,tube(pts,.025),mat(0xd2f6b2,{transparent:true,opacity:.7}))}
let current=0,selected=-1,playing=true,lastBuild=performance.now(),distance=9.7,theta=.3,phi=1.3,target=new THREE.Vector3(),desiredTarget=new THREE.Vector3(),desiredDistance=distance;let demo=location.hash==='#demo',demoStart=performance.now();
function setInfo(i){selected=i;if(i<0){step.textContent='THE BEGINNING';title.textContent='Cell membrane';desc.textContent='The membrane is a flexible boundary that controls what enters and leaves the cell.';hint.textContent=current===11?'Tap a part to discover what it does.':'Watch the cell come together.'}else{step.textContent='PART '+(i+1)+' OF 11';title.textContent=data[i][0];desc.textContent=data[i][1];hint.textContent=current===11?'Tap another part to keep exploring.':'The cell is coming together.'}}
function setBuild(n,show=true){current=Math.max(0,Math.min(11,n));slider.value=current;progress.textContent=current+' / 11 parts';parts.forEach((p,i)=>p.visible=i<current);if(show)setInfo(current?current-1:-1)}
function setCut(value){cut=value;clip.constant=cut?0:100;cutButton.classList.toggle('on',cut);cutButton.setAttribute('aria-pressed',String(cut));cutButton.textContent=cut?'◐ Cut open: on':'◐ Cut open'}setCut(false);setBuild(0);
function stopDemo(){demo=false}slider.addEventListener('input',()=>{stopDemo();playing=false;setBuild(+slider.value);desiredTarget.set(0,0,0);desiredDistance=9.7});cutButton.addEventListener('click',()=>{stopDemo();setCut(!cut)});document.getElementById('rebuild').addEventListener('click',()=>{stopDemo();setBuild(0);setCut(false);playing=true;lastBuild=performance.now();desiredTarget.set(0,0,0);desiredDistance=9.7});
const pointers=new Map();let moved=false,lastPinch=0,downX=0,downY=0;function pointDist(){let p=[...pointers.values()];return Math.hypot(p[0].x-p[1].x,p[0].y-p[1].y)}
host.addEventListener('pointerdown',e=>{stopDemo();host.setPointerCapture(e.pointerId);pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});if(pointers.size===1){moved=false;downX=e.clientX;downY=e.clientY}else{moved=true;lastPinch=pointDist()}});
host.addEventListener('pointermove',e=>{if(!pointers.has(e.pointerId))return;let old=pointers.get(e.pointerId);pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});if(pointers.size===1){let dx=e.clientX-old.x,dy=e.clientY-old.y;if(Math.hypot(e.clientX-downX,e.clientY-downY)>5)moved=true;theta-=dx*.008;phi=Math.max(.15,Math.min(Math.PI-.15,phi+dy*.008))}else if(pointers.size===2){let d=pointDist();if(lastPinch)desiredDistance=Math.max(4.8,Math.min(15,desiredDistance*lastPinch/d));lastPinch=d}});
function choose(x,y){if(current<11)return;let rect=renderer.domElement.getBoundingClientRect();let ray=new THREE.Raycaster();ray.setFromCamera(new THREE.Vector2((x-rect.left)/rect.width*2-1,-(y-rect.top)/rect.height*2+1),camera);let hit=ray.intersectObjects(clickables,false).find(h=>h.object.visible&&h.object.parent.visible&&(!cut||h.point.z<=0));if(hit){let i=hit.object.userData.index;setInfo(i);let box=new THREE.Box3().setFromObject(parts[i]);box.getCenter(desiredTarget);desiredDistance=6.5}else{desiredTarget.set(0,0,0);desiredDistance=9.7;setInfo(-1)}}
host.addEventListener('pointerup',e=>{if(!moved&&pointers.size===1)choose(e.clientX,e.clientY);pointers.delete(e.pointerId);lastPinch=0});host.addEventListener('pointercancel',e=>pointers.delete(e.pointerId));host.addEventListener('wheel',e=>{e.preventDefault();stopDemo();desiredDistance=Math.max(4.8,Math.min(15,desiredDistance+e.deltaY*.006))},{passive:false});
function resize(){camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)}window.addEventListener('resize',resize);resize();
function animate(now){requestAnimationFrame(animate);if(demo){let t=((now-demoStart)/1000)%20;theta+=.003;if(t<8){let n=Math.min(11,Math.floor(t/8*12));if(n!==current)setBuild(n);setCut(false);desiredTarget.set(0,0,0);desiredDistance=9.7}else if(t<12){if(current!==11)setBuild(11);setCut(true)}else if(t<17){setCut(false);if(selected!==6){setInfo(6);new THREE.Box3().setFromObject(parts[6]).getCenter(desiredTarget)}desiredDistance=6.5}else{desiredTarget.set(0,0,0);desiredDistance=9.7}}else if(playing&¤t<11&&now-lastBuild>1050){setBuild(current+1);lastBuild=now;if(current===11)playing=false}
let time=now*.001;membrane.scale.set(1.13*(1+Math.sin(time*1.1)*.012),.88*(1+Math.sin(time*1.1)*.012),1+Math.sin(time*1.1)*.012);wire.scale.copy(membrane.scale);parts.forEach((p,i)=>{p.position.y=Math.sin(time*.75+i)*.035;p.rotation.y=Math.sin(time*.35+i)*.018});distance+=(desiredDistance-distance)*.06;target.lerp(desiredTarget,.06);camera.position.set(target.x+distance*Math.sin(phi)*Math.sin(theta),target.y+distance*Math.cos(phi),target.z+distance*Math.sin(phi)*Math.cos(theta));camera.lookAt(target);renderer.render(scene,camera)}requestAnimationFrame(animate);
})();
</script></body></html>
