Skip to content
VibeCodeBench
Back to the app

The code

Build a Cell, Part by Part by GPT-6.1 Sol

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.)17.0 KB · 50 lines · loads cdn.jsdelivr.net/npm/[email protected]/build/three.module.js, cdn.jsdelivr.net/npm/[email protected]/examples/jsm/controls/OrbitControls.js/+esm
Download
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Cell by cell · A living explorer</title><style>
@import url('data:text/css,');
:root{color-scheme:dark;font-family:Arial,Helvetica,sans-serif;color:#ecf5fa;background:#081721}*{box-sizing:border-box}body{margin:0;overflow:hidden}canvas{display:block;touch-action:none}#world{position:absolute;inset:0}header{position:absolute;top:30px;left:36px;pointer-events:none}.eyebrow{color:#79d8bf;text-transform:uppercase;font-size:11px;letter-spacing:3px;font-weight:bold}h1{font-size:32px;letter-spacing:-1px;margin:10px 0 8px}header p{font-size:13px;color:#91a9b8;margin:0}.badge{position:absolute;right:32px;top:35px;color:#a5bdca;font-size:11px;letter-spacing:2px;display:flex;gap:10px;align-items:center}.dot{width:7px;height:7px;background:#82dbb6;border-radius:50%;box-shadow:0 0 14px #82dbb6}.panel{position:absolute;right:30px;top:125px;width:280px;background:#102733e8;border:1px solid #29424f;border-radius:20px;padding:23px;backdrop-filter:blur(16px)}.count{font-size:10px;letter-spacing:2px;color:#80bdad;text-transform:uppercase}.panel h2{font-size:26px;letter-spacing:-.7px;margin:13px 0 12px}.panel p{color:#b4c9d3;font-size:14px;line-height:1.7;margin:0}.particon{width:38px;height:38px;border-radius:12px;background:#ffffff0c;display:grid;place-items:center;color:#9de2c6;font-size:22px;margin-bottom:20px}.hint{font-size:11px!important;border-top:1px solid #ffffff12;margin-top:23px!important;padding-top:16px;color:#7894a3!important}.bottom{position:absolute;bottom:25px;left:50%;transform:translateX(-50%);width:min(820px,calc(100% - 48px));background:#102632ed;border:1px solid #2b4551;border-radius:19px;padding:19px 23px;backdrop-filter:blur(16px)}.row{display:flex;align-items:center;gap:15px}.progressText{font-size:11px;color:#a9c3cd;letter-spacing:1.5px;flex:1}.progressText strong{color:#e9f7f5}button{font:inherit;color:#d2e5eb;border:1px solid #35535f;background:#193542;border-radius:11px;min-height:44px;padding:0 16px;cursor:pointer}button:hover{background:#254957}button:focus-visible,input:focus-visible{outline:2px solid #9ae7c8;outline-offset:4px}#play{background:#9ae2c6;color:#123630;border:0;min-width:44px;padding:0 12px;font-weight:bold}.switch{display:flex;align-items:center;gap:9px;font-size:12px;white-space:nowrap;cursor:pointer;min-height:44px}.switch input{position:absolute;opacity:0}.track{width:34px;height:20px;background:#3c5562;border-radius:20px;padding:3px}.track:after{content:'';display:block;background:#c3d1d7;height:14px;width:14px;border-radius:50%;transition:.2s}.switch input:checked+.track{background:#77cdb0}.switch input:checked+.track:after{transform:translateX(14px);background:white}.timeline{display:flex;gap:14px;align-items:center;margin-top:15px}input[type=range]{width:100%;accent-color:#94dfc3;cursor:pointer;height:20px}.timeline span{font-size:10px;color:#7493a1}#label{position:absolute;pointer-events:none;border:1px solid #70b9a68c;background:#12332eeb;color:#c7f8e5;border-radius:20px;padding:8px 15px;font-size:12px;white-space:nowrap;transform:translate(-50%,-140%);transition:opacity .3s}#legend{position:absolute;bottom:160px;left:36px;color:#76929f;font-size:11px;line-height:2}.keys{color:#b5ced6}#status{position:absolute;top:55%;left:50%;transform:translate(-50%,-50%);font-size:13px;color:#aed7d0}#home{position:absolute;right:33px;bottom:165px;border-radius:50%;width:44px;padding:0;font-size:19px}.smalltag{display:inline-block;border:1px solid #36534e;border-radius:6px;color:#9ed5bf;font-size:10px;padding:4px 7px;margin-top:17px;letter-spacing:1px}@media(max-width:700px){header{top:22px;left:22px}h1{font-size:25px}.badge{right:20px;top:27px;font-size:9px;letter-spacing:1px}.badge .words{display:none}header p{font-size:11px}.panel{top:auto;bottom:171px;left:18px;right:18px;width:auto;padding:15px 18px;border-radius:15px}.particon,.hint,.smalltag{display:none}.panel h2{font-size:20px;margin:6px 0}.panel p{font-size:12px;line-height:1.5}.count{font-size:9px}.bottom{bottom:16px;width:calc(100% - 32px);padding:12px 14px}.row{gap:9px;flex-wrap:wrap}.progressText{font-size:9px;min-width:90px}button{padding:0 12px;font-size:12px}.switch{font-size:11px}.timeline{margin-top:7px}#legend{display:none}#home{bottom:340px;right:20px}#label{font-size:10px;padding:6px 10px}}
</style></head><body><div id="world"></div><header><div class="eyebrow">The little things are everything</div><h1>Cell by cell<span style="color:#7ed9b6">.</span></h1><p>A tiny world. A whole lot of life.</p></header><div class="badge"><span class="dot"></span><span class="words">ANIMAL CELL / LIVE EXPLORER</span></div><aside class="panel" aria-live="polite"><div class="particon">◉</div><div class="count" id="partno">THE BEGINNING</div><h2 id="title">Cell membrane</h2><p id="desc">This flexible skin controls what enters and leaves the cell.</p><div class="smalltag" id="tag">THE CELL'S BOUNDARY</div><p class="hint">Every part has a job.<br>Tap one to get a closer look.</p></aside><div id="label">Cell membrane</div><div id="legend"><span class="keys">Drag</span> to explore &nbsp; · &nbsp; <span class="keys">Scroll / pinch</span> to zoom<br><span class="keys">Tap a part</span> to discover its job</div><button id="home" aria-label="Show whole cell" title="Show whole cell">⌖</button><div class="bottom"><div class="row"><button id="play" aria-label="Pause build">Ⅱ</button><div class="progressText" id="progress"><strong>BUILDING LIFE</strong> &nbsp; 0 / 12</div><label class="switch"><input type="checkbox" id="cut"><span class="track"></span>Cut open</label><button id="rebuild">↻ &nbsp; Rebuild</button></div><div class="timeline"><span>EMPTY</span><input id="scrub" type="range" min="0" max="12" step="0.01" value="0" aria-label="Build progress"><span>ALIVE</span></div></div><div id="status">Growing your tiny world…</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/+esm';
const $=s=>document.getElementById(s);
try {
const scene=new THREE.Scene();scene.fog=new THREE.FogExp2(0x081721,.025);
const camera=new THREE.PerspectiveCamera(42,innerWidth/innerHeight,.1,100);camera.position.set(0,3,14.5);
const renderer=new THREE.WebGLRenderer({antialias:true,alpha:true});renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setSize(innerWidth,innerHeight);renderer.localClippingEnabled=true;renderer.setClearColor(0x081721);$('world').appendChild(renderer.domElement);
const controls=new OrbitControls(camera,renderer.domElement);controls.enableDamping=true;controls.dampingFactor=.055;controls.minDistance=3;controls.maxDistance=23;controls.enablePan=false;controls.autoRotate=true;controls.autoRotateSpeed=.35;
scene.add(new THREE.HemisphereLight(0xc9f7ff,0x204353,2.1));let light=new THREE.DirectionalLight(0xffe4ce,3);light.position.set(2,6,6);scene.add(light);light=new THREE.PointLight(0x65b9db,30);light.position.set(-5,-2,2);scene.add(light);
const cell=new THREE.Group();scene.add(cell);cell.rotation.z=-.13;
const plane=new THREE.Plane(new THREE.Vector3(0,0,-1),.1);let cut=false;
function mat(color,extra={}){return new THREE.MeshStandardMaterial({color,roughness:.4,metalness:.05,...extra})}
const membrane=new THREE.Mesh(new THREE.SphereGeometry(3.65,64,48),mat(0x7ad7ce,{transparent:true,opacity:.12,side:THREE.DoubleSide,depthWrite:false}));membrane.scale.set(1.12,.88,1);cell.add(membrane);
const rim=new THREE.Mesh(new THREE.SphereGeometry(3.69,48,32),mat(0x64b2b4,{transparent:true,opacity:.045,wireframe:true,depthWrite:false}));rim.scale.copy(membrane.scale);cell.add(rim);
const data=[['Nucleus','The nucleus stores DNA, the instructions that help run the cell.',0xcba1df,'THE CONTROL CENTER'],['Nucleolus','The nucleolus makes the pieces needed to build ribosomes.',0xe9b0d6,'THE RIBOSOME WORKSHOP'],['Rough endoplasmic reticulum','The rough ER helps fold and move proteins made by its ribosomes.',0x739dd6,'THE PROTEIN PATHWAY'],['Smooth endoplasmic reticulum','The smooth ER makes fats and helps break down harmful chemicals.',0x77c8b5,'THE CHEMISTRY LAB'],['Ribosomes','Ribosomes follow instructions to build proteins the cell needs.',0xf0d6a1,'THE PROTEIN BUILDERS'],['Golgi apparatus','The Golgi apparatus sorts and packages proteins for delivery.',0xf1b383,'THE PACKING STATION'],['Mitochondria','Mitochondria turn energy from food into a form the cell can use.',0xe39380,'THE ENERGY SUPPLY'],['Lysosomes','Lysosomes break down waste and worn-out cell parts for recycling.',0xc1ca71,'THE RECYCLING CREW'],['Vesicles','Vesicles are tiny bags that carry materials around the cell.',0x83cfe1,'THE DELIVERY BUBBLES'],['Centrioles','Centrioles help organize the fibers that separate chromosomes during cell division.',0xe9cc89,'THE DIVISION ORGANIZERS'],['Cytoskeleton','The cytoskeleton supports the cell and gives its parts tracks to move along.',0x74c4b8,'THE INNER FRAMEWORK'],['Cytoplasm','This jelly-like fluid holds the cell parts and hosts many chemical reactions.',0x8ecdc1,'THE SPACE BETWEEN']];
const groups=[],pickables=[];let seed=19;function rand(){seed=(seed*16807)%2147483647;return(seed-1)/2147483646}function mesh(geo,color,parent,pos=[0,0,0],extra={}){let m=new THREE.Mesh(geo,mat(color,extra));m.position.set(...pos);parent.add(m);return m}function ball(parent,pos,r,color,extra={}){return mesh(new THREE.SphereGeometry(r,24,16),color,parent,pos,extra)}function tube(parent,pts,r,color){return mesh(new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts.map(p=>new THREE.Vector3(...p))),40,r,7,false),color,parent)}
for(let i=0;i<12;i++){const g=new THREE.Group();g.userData.index=i;groups.push(g);cell.add(g)}
let n=ball(groups[0],[-.55,.35,0],1.13,0xb58ac6,{transparent:true,opacity:.78});n.scale.set(1,1.08,.92);ball(groups[1],[-.55,.4,.65],.37,0xe3a5cb);
for(let i=0;i<7;i++){let pts=[];for(let j=0;j<18;j++){let a=j/17*Math.PI*1.45+.2,r=1.35+i*.065;pts.push([-.55+Math.cos(a)*r,.2+(i-3)*.19+Math.sin(a*2)*.14,Math.sin(a)*r*.73])}tube(groups[2],pts,.115,0x6f9dcc);for(let j=0;j<9;j++){let p=pts[j*2];ball(groups[2],[p[0],p[1]+.12,p[2]],.045,0xe8d3ad)}}
for(let i=0;i<7;i++){let pts=[];for(let j=0;j<12;j++)pts.push([1.2+j*.1+Math.sin(j*.85+i)*.27,-.5+i*.17,Math.cos(j*.6+i)*.45-.6]);tube(groups[3],pts,.075,0x70b9a7)}
for(let i=0;i<85;i++){let p;do{p=[(rand()-.5)*6.4,(rand()-.5)*4.8,(rand()-.5)*5.6]}while(new THREE.Vector3(...p).length()>3.1);ball(groups[4],p,.038+rand()*.018,0xf1d0a0)}
for(let i=0;i<6;i++){let pts=[];for(let j=0;j<16;j++){let x=(j/15-.5)*1.5;pts.push([1.65+x,-1.1+i*.18,.7+Math.cos(x*2.1)*(.35+i*.025)])}tube(groups[5],pts,.12,0xe9a57c)}
const mitopos=[[-2.3,-.8,.8],[2,1.3,.2],[.4,-1.9,-.8],[-1.8,1.65,-.8]];mitopos.forEach((p,i)=>{let g=new THREE.Group();g.position.set(...p);g.rotation.set(.3,i*.8,.5+i*.4);groups[6].add(g);let b=ball(g,[0,0,0],.43,0xd98070);b.scale.set(1.8,.78,.8);let pts=[];for(let j=0;j<20;j++)pts.push([-.58+j/19*1.16,Math.sin(j*1.35)*.17,.29]);tube(g,pts,.044,0xffcc9d)});
[[-2,.4,1.5],[1.1,1.9,1.1],[2.45,-.6,-.7],[-.6,-2,1.25]].forEach(p=>{ball(groups[7],p,.23,0xb6bf64);for(let j=0;j<6;j++)ball(groups[7],[p[0]+(rand()-.5)*.25,p[1]+(rand()-.5)*.25,p[2]+.18],.035,0xe7e3a4)});
for(let i=0;i<11;i++){let a=i*2.4;ball(groups[8],[Math.sin(a)*2.6,Math.cos(a*1.3)*1.9,Math.cos(a)*1.5],.12+rand()*.1,0x8fd4df,{transparent:true,opacity:.6})}
for(let k=0;k<2;k++){let g=new THREE.Group();g.position.set(.8+k*.45,-.15,-1.8);g.rotation.z=k?Math.PI/2:.1;groups[9].add(g);for(let j=0;j<9;j++){let a=j/9*Math.PI*2;mesh(new THREE.CylinderGeometry(.045,.045,.65,8),0xe6ca87,g,[Math.cos(a)*.15,0,Math.sin(a)*.15])}}
for(let i=0;i<22;i++){let a=rand()*Math.PI*2,b=rand()*Math.PI*2;let pts=[ [Math.cos(a)*3.3,Math.sin(a)*2.7,Math.sin(b)*.7],[(rand()-.5)*2,(rand()-.5)*2,(rand()-.5)*2],[Math.cos(a+2)*3.1,Math.sin(a+2)*2.6,Math.cos(b)*.8] ];tube(groups[10],pts,.014,0x68a89e)}
for(let i=0;i<90;i++){let p=[(rand()-.5)*6,(rand()-.5)*4.8,(rand()-.5)*5];if(new THREE.Vector3(...p).length()<3)ball(groups[11],p,.018,0xa2d6d1,{transparent:true,opacity:.35})}
groups.forEach((g,i)=>g.traverse(o=>{if(o.isMesh){o.userData.index=i;pickables.push(o);o.material.clippingPlanes=[]}}));membrane.userData.index=-1;pickables.push(membrane);
// A quiet field of procedural particles gives the cell a sense of scale.
const starGeo=new THREE.BufferGeometry(),stars=[];for(let i=0;i<170;i++)stars.push((rand()-.5)*40,(rand()-.5)*25,-4-rand()*14);starGeo.setAttribute('position',new THREE.Float32BufferAttribute(stars,3));scene.add(new THREE.Points(starGeo,new THREE.PointsMaterial({color:0x6b9aab,size:.027,transparent:true,opacity:.35})));
let build=0,playing=true,selected=-1,elapsed=0,flight=null,demo=location.hash==='#demo',demoTime=0,lastDemo=-1;
function select(i,fly=false){selected=i;const d=i<0?['Cell membrane','This flexible skin controls what enters and leaves the cell.',0x91d8c1,"THE CELL'S BOUNDARY"]:data[i];$('title').textContent=d[0];$('desc').textContent=d[1];$('partno').textContent=i<0?'THE BEGINNING':`PART ${String(i+1).padStart(2,'0')} / 12`;$('tag').textContent=d[3];$('label').textContent=d[0];$('label').style.borderColor='#'+new THREE.Color(d[2]).getHexString();if(fly){let target=new THREE.Vector3();if(i>=0){new THREE.Box3().setFromObject(groups[i]).getCenter(target)}let dir=camera.position.clone().sub(controls.target).normalize();flight={from:camera.position.clone(),to:target.clone().add(dir.multiplyScalar(i<0?14:6)),a:controls.target.clone(),b:target,t:0};controls.autoRotate=false}}
function setBuild(v,autoSelect=true){build=Math.max(0,Math.min(12,v));$('scrub').value=build;groups.forEach((g,i)=>{let f=THREE.MathUtils.clamp(build-i,0,1);g.visible=f>0;g.scale.setScalar(Math.max(.001,THREE.MathUtils.smoothstep(f,0,1)))});$('progress').innerHTML=`<strong>${build>=12?'A WORLD ALIVE':'BUILDING LIFE'}</strong> &nbsp; ${Math.floor(build)} / 12`;if(autoSelect){let idx=build===0?-1:Math.min(11,Math.ceil(build)-1);if(idx!==selected)select(idx)}if(build>=12){playing=false;updatePlay()}}
function updatePlay(){$('play').textContent=playing?'Ⅱ':'▶';$('play').setAttribute('aria-label',playing?'Pause build':'Play build')}
function setCut(v){cut=v;$('cut').checked=v;[membrane,rim,...pickables.filter(o=>o!==membrane)].forEach(o=>{o.material.clippingPlanes=v?[plane]:[];o.material.needsUpdate=true})}
function reset(){playing=true;setBuild(0);select(-1);setCut(false);controls.autoRotate=true;flight={from:camera.position.clone(),to:new THREE.Vector3(0,3,14.5),a:controls.target.clone(),b:new THREE.Vector3(),t:0};updatePlay()}
$('play').onclick=()=>{if(build>=12)setBuild(0);playing=!playing;updatePlay()};$('rebuild').onclick=reset;$('cut').onchange=e=>setCut(e.target.checked);$('scrub').oninput=e=>{playing=false;updatePlay();setBuild(+e.target.value)};$('home').onclick=()=>select(-1,true);
let down=null;renderer.domElement.addEventListener('pointerdown',e=>{down={x:e.clientX,y:e.clientY}});renderer.domElement.addEventListener('pointerup',e=>{if(!down||Math.hypot(e.clientX-down.x,e.clientY-down.y)>7)return;const ray=new THREE.Raycaster();ray.setFromCamera(new THREE.Vector2(e.clientX/innerWidth*2-1,-e.clientY/innerHeight*2+1),camera);let hits=ray.intersectObjects(pickables).filter(h=>{let i=h.object.userData.index;return(i<0||groups[i].visible&&build>i+.5)&&(!cut||cell.worldToLocal(h.point.clone()).z<=.1)});let hit=hits.find(h=>h.object!==membrane)||hits[0];if(hit)select(hit.object.userData.index,true)});
for(const event of ['pointerdown','wheel'])window.addEventListener(event,()=>{demo=false;controls.autoRotate=false},{passive:true});controls.addEventListener('start',()=>flight=null);
window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});
$('status').remove();select(-1);const clock=new THREE.Clock();function animate(){requestAnimationFrame(animate);const dt=Math.min(clock.getDelta(),.05);elapsed+=dt;if(playing)setBuild(build+dt*.8);groups.forEach((g,i)=>{g.position.y=Math.sin(elapsed*.6+i*1.7)*.035;g.rotation.y=Math.sin(elapsed*.2+i)*.012});membrane.scale.set(1.12*(1+Math.sin(elapsed*.8)*.006),.88*(1+Math.sin(elapsed*.8)*.006),1+Math.sin(elapsed*.8)*.006);if(flight){flight.t=Math.min(1,flight.t+dt*.8);let q=flight.t*flight.t*(3-2*flight.t);camera.position.lerpVectors(flight.from,flight.to,q);controls.target.lerpVectors(flight.a,flight.b,q);if(flight.t>=1)flight=null}if(demo){demoTime+=dt;let phase=demoTime%20;if(phase<.1&&lastDemo!==0){reset();lastDemo=0}if(phase>14&&lastDemo===0){setBuild(12);select(6,true);lastDemo=1}if(phase>16.5&&lastDemo===1){setCut(true);lastDemo=2}if(phase>18.5&&lastDemo===2){select(-1,true);lastDemo=3}}controls.update();let p=new THREE.Vector3();if(selected>=0&&groups[selected].visible)new THREE.Box3().setFromObject(groups[selected]).getCenter(p);else p.set(-2,2.5,0);p.project(camera);$('label').style.left=(p.x*.5+.5)*innerWidth+'px';$('label').style.top=(-p.y*.5+.5)*innerHeight+'px';$('label').style.opacity=p.z>1?'0':'1';renderer.render(scene,camera)}animate();
} catch(error){$('status').textContent='The 3D explorer could not start. Please check that WebGL and the library CDN are available.';console.error(error)}
</script></body></html>