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,maximum-scale=1,user-scalable=no"><title>Cell Explorer</title><style>
:root{color-scheme:dark;--ink:#e9f7ff;--muted:#93adc0;--cyan:#74e8e5}*{box-sizing:border-box}body{margin:0;background:#07131f;color:var(--ink);font:15px/1.4 system-ui,-apple-system,sans-serif;overflow:hidden}canvas{display:block;touch-action:none}#scene{position:absolute;inset:0}#scene canvas{width:100%;height:100%}.top{position:absolute;top:0;left:0;right:0;padding:20px 24px;background:linear-gradient(#07131fea,transparent);pointer-events:none;display:flex;justify-content:space-between;align-items:flex-start;gap:10px}.eyebrow{color:var(--cyan);font-size:10px;font-weight:800;letter-spacing:.2em;text-transform:uppercase}h1{font-size:clamp(24px,4vw,38px);letter-spacing:-.05em;line-height:1;margin:5px 0} .sub{color:var(--muted);font-size:12px}.badge{border:1px solid #4f7886;border-radius:99px;padding:7px 10px;color:#aad4dc;font-size:10px;letter-spacing:.08em;white-space:nowrap}.card{position:absolute;left:24px;top:120px;width:min(290px,calc(100% - 48px));padding:18px 19px;background:#102837df;border:1px solid #376274;border-radius:18px;box-shadow:0 18px 55px #0005;backdrop-filter:blur(12px);transition:opacity .3s}.card .number{color:#8ab3c2;font-size:11px;font-weight:800;letter-spacing:.12em}.card h2{font-size:22px;letter-spacing:-.03em;margin:6px 0}.card p{color:#bed2dc;margin:0;font-size:14px}.card .hint{margin-top:13px;color:#76dfdd;font-size:11px}.bottom{position:absolute;left:50%;bottom:20px;transform:translateX(-50%);width:min(680px,calc(100% - 32px));padding:14px 16px;background:#102837eF;border:1px solid #386071;border-radius:20px;box-shadow:0 16px 50px #0008;backdrop-filter:blur(14px)}.row{display:flex;align-items:center;gap:12px}.progress-label{display:flex;justify-content:space-between;font-size:11px;color:#a9c6d0;font-weight:700;letter-spacing:.06em;text-transform:uppercase}.progress-label strong{color:#79e5df}input[type=range]{width:100%;accent-color:#72e8df;height:28px;cursor:pointer}.actions{display:flex;gap:8px;align-items:center}button{font:700 13px system-ui;color:#e9f7ff;background:#204456;border:1px solid #507888;border-radius:12px;padding:11px 15px;min-height:44px;cursor:pointer}button:active{transform:scale(.97)}button.primary{background:#86e9dc;color:#08252a;border-color:#86e9dc}.spacer{flex:1}.switch{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:700;cursor:pointer;white-space:nowrap}.switch input{appearance:none;width:42px;height:24px;background:#345463;border-radius:20px;position:relative;cursor:pointer}.switch input:checked{background:#70dcd3}.switch input:after{content:'';position:absolute;width:18px;height:18px;border-radius:50%;background:white;left:3px;top:3px;transition:.2s}.switch input:checked:after{left:21px}.tip{position:absolute;right:24px;bottom:174px;color:#a7c8d1;font-size:11px;text-align:right;text-shadow:0 2px 5px #000}.label{position:absolute;pointer-events:none;transform:translate(-50%,-50%);font-size:11px;font-weight:700;color:#eafcff;text-shadow:0 1px 5px #000,0 1px 5px #000;white-space:nowrap}.label:before{content:'';display:inline-block;width:6px;height:6px;background:#91f2df;border-radius:50%;margin-right:5px;box-shadow:0 0 8px #79e8d9}#loading{position:absolute;inset:0;display:grid;place-items:center;background:#07131f;color:#a6cbd2}.error{max-width:350px;text-align:center;padding:20px}@media(max-width:600px){.top{padding:16px}.badge{font-size:9px}.card{left:16px;top:95px;width:230px;padding:13px 15px}.card h2{font-size:18px}.card p{font-size:12px}.card .hint{margin-top:7px}.tip{right:16px;bottom:166px;max-width:145px}.bottom{bottom:12px}.actions button{padding:10px 12px}}
</style></head><body><div id="scene"></div><div id="labels"></div><header class="top"><div><div class="eyebrow">A tiny world, up close</div><h1>Cell Explorer<span style="color:#79e8df">.</span></h1><div class="sub">Meet the parts that keep an animal cell alive.</div></div><div class="badge">✳ ANIMAL CELL</div></header><article class="card"><div class="number" id="counter">THE BEGINNING</div><h2 id="title">Cell membrane</h2><p id="description">This flexible outer layer holds the cell together and controls what goes in and out.</p><div class="hint" id="hint">Watch the cell come to life ↓</div></article><div class="tip" id="tip">Drag to orbit · Pinch or scroll to zoom<br>Tap a part to explore</div><section class="bottom"><div class="progress-label"><span>Build the cell</span><strong id="progress">0 / 11 parts</strong></div><input id="slider" type="range" min="0" max="11" value="0" step="1" aria-label="Build progress"><div class="actions"><button id="play" class="primary">❚❚ Pause</button><button id="rebuild">↺ Rebuild</button><div class="spacer"></div><label class="switch"><input id="cut" type="checkbox"><span>Cut open</span></label></div></section><div id="loading">Building your tiny world…</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script><script>
(function(){'use strict';const loading=document.getElementById('loading');if(!window.THREE){loading.innerHTML='<div class="error">The 3D library could not load. Please check your connection and reload.</div>';return}loading.remove();const $=id=>document.getElementById(id),container=$('scene'),labels=$('labels');const scene=new THREE.Scene();scene.background=new THREE.Color(0x07131f);scene.fog=new THREE.Fog(0x07131f,15,30);const camera=new THREE.PerspectiveCamera(40,innerWidth/innerHeight,.1,100);camera.position.set(0,1,11);const renderer=new THREE.WebGLRenderer({antialias:true,alpha:true});renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setSize(innerWidth,innerHeight);renderer.localClippingEnabled=true;container.appendChild(renderer.domElement);scene.add(new THREE.HemisphereLight(0xb7ffff,0x23304e,2));const light=new THREE.DirectionalLight(0xffffff,2);light.position.set(3,6,8);scene.add(light);const rim=new THREE.PointLight(0x34bfc7,35,20);rim.position.set(-5,1,4);scene.add(rim);const cell=new THREE.Group();scene.add(cell);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:.38,metalness:.08,clippingPlanes:[clip],...extra})}const membraneMat=mat(0x76e9da,{transparent:true,opacity:.17,side:THREE.DoubleSide,depthWrite:false});const membrane=new THREE.Mesh(new THREE.SphereGeometry(3,64,48),membraneMat);membrane.scale.set(1.15,.88,.9);cell.add(membrane);const wire=new THREE.Mesh(new THREE.SphereGeometry(3.015,32,20),mat(0x85fff0,{wireframe:true,transparent:true,opacity:.07,depthWrite:false}));wire.scale.copy(membrane.scale);cell.add(wire);const inner=new THREE.Mesh(new THREE.SphereGeometry(2.94,40,28),mat(0x49b8bb,{transparent:true,opacity:.045,side:THREE.BackSide,depthWrite:false}));inner.scale.copy(membrane.scale);cell.add(inner);const parts=[
['Nucleus','The nucleus is the control center that stores the cell’s DNA.',0xa58af8],['Nucleolus','The nucleolus makes the building blocks of ribosomes.',0xf782c5],['Rough ER','Rough endoplasmic reticulum folds and transports proteins, with ribosomes attached.',0x5899ef],['Smooth ER','Smooth endoplasmic reticulum makes fats and helps break down chemicals.',0x56c4e5],['Ribosomes','Ribosomes are tiny protein-making machines.',0xffcf79],['Golgi apparatus','The Golgi apparatus packages and sends materials around the cell.',0xffaa78],['Mitochondria','Mitochondria release energy from food for the cell to use.',0xff807a],['Lysosomes','Lysosomes break down waste and worn-out cell parts.',0xfbd061],['Vesicles','Vesicles are little sacs that carry materials around the cell.',0x8eeab5],['Centrioles','Centrioles help organize the cell when it divides.',0xf4b3df],['Cytoskeleton','The cytoskeleton is a network of fibers that gives the cell shape and support.',0x8bdde9]];let groups=[],clickables=[],anchors=[];function mesh(geo,m,parent,pos,scale){let o=new THREE.Mesh(geo,m);if(pos)o.position.set(...pos);if(scale)o.scale.set(...scale);parent.add(o);return o}const sphere=new THREE.SphereGeometry(1,24,16);function addPart(i,pos){let g=new THREE.Group();g.position.set(...pos);g.userData.index=i;g.userData.base=g.position.clone();cell.add(g);groups[i]=g;let lab=document.createElement('div');lab.className='label';lab.textContent=parts[i][0];labels.appendChild(lab);anchors[i]={object:g,element:lab};return g}function register(g,i){g.traverse(o=>{if(o.isMesh){o.userData.index=i;clickables.push(o)}})}function tube(points,r,color,parent){let curve=new THREE.CatmullRomCurve3(points.map(p=>new THREE.Vector3(...p)));return mesh(new THREE.TubeGeometry(curve,64,r,8,false),mat(color),parent)}
let g=addPart(0,[-.65,.15,-.05]);mesh(sphere,mat(0x8f77dc,{transparent:true,opacity:.88}),g,null,[1.02,.92,.88]);let shell=mesh(new THREE.SphereGeometry(1.04,24,16),mat(0xc0aaff,{wireframe:true,transparent:true,opacity:.14}),g,null,[1,.91,.87]);register(g,0);
g=addPart(1,[-.55,.3,.63]);mesh(sphere,mat(0xf48cc9),g,null,[.28,.25,.22]);register(g,1);
function folds(i,pos,color,rough){let a=addPart(i,pos);for(let k=0;k<4;k++){let points=[];for(let j=0;j<=20;j++){let x=(j/20-.5)*1.35;points.push([x,Math.sin(j*.55+k*.5)*.13+(k-1.5)*.18,Math.cos(j*.45+k)*.16])}tube(points,.055,color,a);if(rough)for(let j=1;j<20;j+=3)mesh(sphere,mat(0xffd084),a,points[j],[.055,.055,.055])}register(a,i)}folds(2,[-1.72,.2,.48],0x649ff0,true);folds(3,[-1.38,-1.12,.3],0x58c9db,false);
g=addPart(4,[.4,1.5,.3]);for(let i=0;i<20;i++){let a=i*2.4,r=.3+(i%4)*.13;mesh(sphere,mat(0xffd080),g,[Math.cos(a)*r,Math.sin(a)*r,(i%3-.8)*.18],[.075,.075,.075])}register(g,4);
g=addPart(5,[1.2,.75,.15]);for(let k=0;k<5;k++){let pts=[];for(let j=0;j<=16;j++){let x=(j/16-.5)*1.3;pts.push([x,(k-2)*.13+.35*x*x,Math.sin(j*.25)*.08])}tube(pts,.075,0xffa87b,g)}register(g,5);
g=addPart(6,[1.35,-.85,.35]);function mito(parent,pos,rot){let m=new THREE.Group();m.position.set(...pos);m.rotation.z=rot;parent.add(m);mesh(sphere,mat(0xf57470),m,null,[.58,.27,.27]);let pts=[];for(let i=0;i<=24;i++)pts.push([(i/24-.5)*.9,Math.sin(i*1.3)*.15,.235]);tube(pts,.025,0xffc3a4,m)}mito(g,[0,0,0],.45);mito(g,[-.3,-.75,-.65],-.5);register(g,6);
g=addPart(7,[2.05,.1,-.4]);mesh(sphere,mat(0xf3c855),g,[0,0,0],[.28,.28,.28]);mesh(sphere,mat(0xffdb72),g,[-.35,-.35,.45],[.18,.18,.18]);register(g,7);
g=addPart(8,[.6,-1.55,.65]);for(let p of [[0,0,0],[.65,.15,-.4],[-.25,.3,-.5]])mesh(sphere,mat(0x8de8b5,{transparent:true,opacity:.8}),g,p,[.17,.17,.17]);register(g,8);
g=addPart(9,[1.95,1.1,-.5]);for(let k=0;k<2;k++){let cyl=mesh(new THREE.CylinderGeometry(.13,.13,.55,12),mat(0xf4aeda),g,[k*.28,0,0]);cyl.rotation.z=k?Math.PI/2:.2}register(g,9);
g=addPart(10,[0,0,0]);for(let k=0;k<9;k++){let angle=k*Math.PI*2/9;let pts=[];for(let j=0;j<6;j++){let r=.7+j*.43;pts.push([Math.cos(angle)*r,Math.sin(angle)*r*.7,Math.sin(j+k)*.65-.65])}tube(pts,.018,0x83d6db,g)}register(g,10);
let step=0,playing=true,selected=-1,last=performance.now(),elapsed=0,orbitX=.1,orbitY=0,distance=11,target=new THREE.Vector3(),desired=new THREE.Vector3(),drag=null,pointers=new Map(),pinch=0,demo=location.hash==='#demo',demoStart=performance.now();function update(){groups.forEach((g,i)=>g.visible=i<step);$('slider').value=step;$('progress').textContent=step+' / 11 parts';$('play').textContent=playing?'❚❚ Pause':'▶ Play';if(selected>=step)selected=-1;let i=selected>=0?selected:step-1;if(i>=0){$('counter').textContent=(i+1).toString().padStart(2,'0')+' / 11 · CELL PART';$('title').textContent=parts[i][0];$('description').textContent=parts[i][1]}else{$('counter').textContent='THE BEGINNING';$('title').textContent='Cell membrane';$('description').textContent='This flexible outer layer holds the cell together and controls what goes in and out.'}$('hint').textContent=step===11?'Tap a part to learn more':'Watch the cell come to life ↓';}
function setStep(n){step=Math.max(0,Math.min(11,n));selected=-1;desired.set(0,0,0);update()}function select(i){if(i>=step)return;selected=i;desired.copy(groups[i].position).multiplyScalar(.45);distance=7.5;update()}$('slider').oninput=e=>{playing=false;setStep(+e.target.value)};$('play').onclick=()=>{if(step===11)setStep(0);playing=!playing;elapsed=0;update()};$('rebuild').onclick=()=>{setStep(0);playing=true;elapsed=0;distance=11;update()};$('cut').onchange=e=>{cut=e.target.checked};function stopDemo(){demo=false}document.addEventListener('pointerdown',stopDemo,{once:true});renderer.domElement.addEventListener('pointerdown',e=>{renderer.domElement.setPointerCapture(e.pointerId);pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});if(pointers.size===1)drag={x:e.clientX,y:e.clientY,startX:e.clientX,startY:e.clientY,moved:false};if(pointers.size===2){let a=[...pointers.values()];pinch=Math.hypot(a[0].x-a[1].x,a[0].y-a[1].y);if(drag)drag.moved=true}});renderer.domElement.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===2){let a=[...pointers.values()],d=Math.hypot(a[0].x-a[1].x,a[0].y-a[1].y);if(pinch)distance=THREE.MathUtils.clamp(distance*pinch/d,5,16);pinch=d}else if(drag){orbitY+=(e.clientX-old.x)*.008;orbitX=THREE.MathUtils.clamp(orbitX+(e.clientY-old.y)*.008,-1.2,1.2);if(Math.hypot(e.clientX-drag.startX,e.clientY-drag.startY)>5)drag.moved=true}});renderer.domElement.addEventListener('pointerup',e=>{if(drag&&!drag.moved&&pointers.size===1&&step===11){let rect=renderer.domElement.getBoundingClientRect(),mouse=new THREE.Vector2((e.clientX-rect.left)/rect.width*2-1,-(e.clientY-rect.top)/rect.height*2+1),ray=new THREE.Raycaster();ray.setFromCamera(mouse,camera);let hits=ray.intersectObjects(clickables).filter(h=>groups[h.object.userData.index].visible&&(!cut||h.point.z<=0));if(hits.length)select(hits[0].object.userData.index)}pointers.delete(e.pointerId);if(!pointers.size)drag=null;pinch=0});renderer.domElement.addEventListener('pointercancel',e=>{pointers.delete(e.pointerId);drag=null});renderer.domElement.addEventListener('wheel',e=>{e.preventDefault();distance=THREE.MathUtils.clamp(distance+e.deltaY*.008,5,16)},{passive:false});window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});update();function animate(now){requestAnimationFrame(animate);let dt=Math.min((now-last)/1000,.1);last=now;if(demo){let t=((now-demoStart)/1000)%20;if(t<11){if(step!==Math.floor(t))setStep(Math.floor(t));playing=false}else{if(step!==11)setStep(11);orbitY+=dt*.28;if(t>13&&t<17){cut=true;$('cut').checked=true}else{cut=false;$('cut').checked=false}if(t>17&&selected!==6)select(6)}if(t<1&&selected!==-1)selected=-1;update()}else if(playing){elapsed+=dt;if(elapsed>1.5){elapsed=0;setStep(step+1);if(step===11){playing=false;update()}}}clip.constant=cut?0:100;let time=now*.001;groups.forEach((g,i)=>{g.position.y=g.userData.base.y+Math.sin(time*.8+i)*.035;g.rotation.z=Math.sin(time*.6+i)*.025});membrane.scale.set(1.15*(1+Math.sin(time)*.008),.88*(1+Math.sin(time)*.008),.9*(1+Math.sin(time)*.008));wire.scale.copy(membrane.scale);target.lerp(desired,.035);let x=Math.sin(orbitY)*Math.cos(orbitX)*distance,y=Math.sin(orbitX)*distance,z=Math.cos(orbitY)*Math.cos(orbitX)*distance;camera.position.lerp(new THREE.Vector3(x,y,z).add(target),.09);camera.lookAt(target);renderer.render(scene,camera);anchors.forEach((a,i)=>{let visible=i<step&&(selected===i||selected<0&&i===step-1);let v=a.object.getWorldPosition(new THREE.Vector3()).project(camera);a.element.style.display=visible&&v.z<1?'block':'none';a.element.style.left=((v.x*.5+.5)*innerWidth)+'px';a.element.style.top=((-v.y*.5+.5)*innerHeight-25)+'px'})}requestAnimationFrame(animate);
})();</script></body></html>
