Back to the app
The code
Jelly Orange Slice 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"><meta name="theme-color" content="#f8f4ec">
<title>Orange Jelly Lab</title>
<style>
*{box-sizing:border-box}body{margin:0;font-family:Inter,ui-sans-serif,system-ui,-apple-system,sans-serif;color:#47372e;background:#f8f4ec;overflow:hidden}#scene{position:absolute;inset:0;touch-action:none}canvas{display:block;width:100%;height:100%;touch-action:none}.top{position:absolute;top:0;left:0;width:100%;padding:26px 30px;pointer-events:none}.eyebrow{font-size:11px;letter-spacing:.2em;font-weight:800;color:#e7842e}.top h1{font-family:Georgia,serif;font-weight:500;font-size:clamp(28px,4vw,46px);letter-spacing:-.045em;margin:6px 0}.top p{font-size:14px;color:#8d7b6d;margin:0;line-height:1.5}.badge{position:absolute;right:30px;top:30px;background:#fff9;border:1px solid #fff;border-radius:99px;padding:10px 15px;color:#a87a55;font-size:11px;font-weight:700;letter-spacing:.08em}.controls{position:absolute;bottom:24px;left:50%;transform:translateX(-50%);width:min(680px,calc(100% - 32px));display:flex;align-items:center;gap:12px;padding:14px;background:rgba(255,255,255,.84);border:1px solid white;border-radius:22px;box-shadow:0 18px 55px #7a4d251a;backdrop-filter:blur(16px)}button{border:0;border-radius:14px;font:700 14px inherit;cursor:pointer;min-height:50px;padding:0 25px;white-space:nowrap}button:active{transform:scale(.97)}#squeeze{background:#f28b2c;color:white;box-shadow:0 5px 15px #e88a3a55}#reset{background:#f4eee6;color:#725949}.slider{flex:1;min-width:110px;padding:0 8px}.slider div{display:flex;justify-content:space-between;font-size:12px;font-weight:700;margin-bottom:7px}.slider span{color:#d58948;font-weight:600}input{width:100%;accent-color:#ee8b35;cursor:pointer}.hint{position:absolute;bottom:112px;left:50%;transform:translateX(-50%);white-space:nowrap;background:#fff9;border:1px solid #fff;border-radius:99px;padding:9px 16px;color:#957967;font-size:12px;pointer-events:none}.dot{display:inline-block;width:7px;height:7px;background:#f4a146;border-radius:50%;margin-right:7px}@media(max-width:560px){.top{padding:22px}.top p{max-width:210px}.badge{right:18px;top:23px;font-size:9px}.controls{bottom:12px;gap:7px;padding:10px;border-radius:18px}button{padding:0 14px;min-height:48px}.slider{padding:0 3px}.hint{bottom:95px}.top h1{font-size:31px}}
</style></head><body>
<div id="scene"></div><div class="top"><div class="eyebrow">A LITTLE MOMENT OF PLAY</div><h1>Orange you glad?</h1><p>A juicy little slice, made to wobble.</p></div><div class="badge">✦ JELLY LAB</div><div class="hint"><i class="dot"></i> Poke or drag the jelly to play</div><div class="controls"><button id="squeeze" type="button">Squeeze</button><div class="slider"><div><label for="firm">Firmness</label><span id="firmLabel">Medium</span></div><input id="firm" type="range" min="0" max="100" value="48" aria-label="Firmness"></div><button id="reset" type="button">Reset</button></div>
<script src="https://cdn.jsdelivr.net/npm/three@0.160.1/build/three.min.js"></script>
<script>
(()=>{'use strict';
const host=document.getElementById('scene'), firm=document.getElementById('firm'), label=document.getElementById('firmLabel');
const scene=new THREE.Scene();scene.background=new THREE.Color(0xf8f4ec);scene.fog=new THREE.Fog(0xf8f4ec,14,26);
const camera=new THREE.PerspectiveCamera(36,1,.1,100);camera.position.set(0,5.4,10.5);camera.lookAt(0,1.05,0);
const renderer=new THREE.WebGLRenderer({antialias:true,alpha:false});renderer.setPixelRatio(Math.min(devicePixelRatio,2));renderer.setSize(innerWidth,innerHeight);renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFSoftShadowMap;renderer.outputColorSpace=THREE.SRGBColorSpace;renderer.toneMapping=THREE.ACESFilmicToneMapping;renderer.toneMappingExposure=1.16;host.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(0xfff8e8,0xb18b70,2));const sun=new THREE.DirectionalLight(0xffffff,2.6);sun.position.set(-3,8,5);sun.castShadow=true;sun.shadow.mapSize.set(1024,1024);sun.shadow.camera.left=-6;sun.shadow.camera.right=6;sun.shadow.camera.top=6;sun.shadow.camera.bottom=-6;sun.shadow.bias=-.0004;scene.add(sun);const back=new THREE.DirectionalLight(0xffbd5d,2.1);back.position.set(2,3,-5);scene.add(back);
const floor=new THREE.Mesh(new THREE.PlaneGeometry(200,200),new THREE.MeshStandardMaterial({color:0xf8f4ec,roughness:1}));floor.rotation.x=-Math.PI/2;floor.position.y=-.16;floor.receiveShadow=true;scene.add(floor);
const plateMat=new THREE.MeshPhysicalMaterial({color:0xfffefa,roughness:.22,metalness:0,clearcoat:1,clearcoatRoughness:.12});const plate=new THREE.Mesh(new THREE.CylinderGeometry(3.1,2.72,.14,96),plateMat);plate.position.y=-.045;plate.receiveShadow=true;plate.castShadow=true;scene.add(plate);const rim=new THREE.Mesh(new THREE.TorusGeometry(2.94,.13,16,100),plateMat);rim.rotation.x=Math.PI/2;rim.position.y=.045;rim.receiveShadow=true;scene.add(rim);const ring=new THREE.Mesh(new THREE.TorusGeometry(2.55,.018,8,100),new THREE.MeshStandardMaterial({color:0xeeeae4,roughness:.5}));ring.rotation.x=Math.PI/2;ring.position.y=.032;scene.add(ring);
// Volumetric mass-spring lattice. Every rendered surface follows these simulated particles.
const A=28,R=9,Z=2,radius=2.12,depth=.58,base=.11,nodes=[],springs=[];const idx=(a,r,z)=>(z*(R+1)+r)*(A+1)+a;
for(let z=0;z<=Z;z++)for(let r=0;r<=R;r++)for(let a=0;a<=A;a++){let t=Math.PI*a/A,rad=.055+(radius-.055)*r/R;let p=new THREE.Vector3(Math.cos(t)*rad,base+Math.sin(t)*rad,(z/Z-.5)*depth);nodes.push({p:p.clone(),prev:p.clone(),rest:p.clone()});}
function spring(i,j,weight=1){let d=nodes[i].rest.distanceTo(nodes[j].rest);if(d>.0001)springs.push({i,j,d,weight})}
for(let z=0;z<=Z;z++)for(let r=0;r<=R;r++)for(let a=0;a<=A;a++){let i=idx(a,r,z);if(a<A)spring(i,idx(a+1,r,z));if(r<R)spring(i,idx(a,r+1,z));if(z<Z)spring(i,idx(a,r,z+1));if(a<A&&r<R){spring(i,idx(a+1,r+1,z),.7);spring(idx(a+1,r,z),idx(a,r+1,z),.7)}if(z<Z&&r<R){spring(i,idx(a,r+1,z+1),.65);spring(idx(a,r+1,z),idx(a,r,z+1),.65)}if(z<Z&&a<A){spring(i,idx(a+1,r,z+1),.65);spring(idx(a+1,r,z),idx(a,r,z+1),.65)}}
function surface(indices,mat){let geo=new THREE.BufferGeometry(),arr=new Float32Array(indices.length*3);geo.setAttribute('position',new THREE.BufferAttribute(arr,3));let mesh=new THREE.Mesh(geo,mat);mesh.castShadow=true;mesh.receiveShadow=true;mesh.frustumCulled=false;scene.add(mesh);return {geo,indices,arr}}
const fleshMat=new THREE.MeshPhysicalMaterial({color:0xff9c19,roughness:.2,metalness:0,transparent:true,opacity:.85,side:THREE.DoubleSide,clearcoat:1,clearcoatRoughness:.12,emissive:0xf56b00,emissiveIntensity:.13});const pithMat=new THREE.MeshPhysicalMaterial({color:0xffedc1,roughness:.45,side:THREE.DoubleSide});const peelMat=new THREE.MeshPhysicalMaterial({color:0xff8a08,roughness:.3,clearcoat:1,side:THREE.DoubleSide,emissive:0x773000,emissiveIntensity:.1});
let flesh=[],pith=[],peel=[];function quad(out,a,b,c,d){out.push(a,b,d,b,c,d)}
for(let z of [0,Z])for(let r=0;r<R;r++)for(let a=0;a<A;a++){let out=r===R-1?pith:flesh;quad(out,idx(a,r,z),idx(a+1,r,z),idx(a+1,r+1,z),idx(a,r+1,z))}for(let a=0;a<A;a++)for(let z=0;z<Z;z++)quad(peel,idx(a,R,z),idx(a+1,R,z),idx(a+1,R,z+1),idx(a,R,z+1));for(let a of [0,A])for(let r=0;r<R;r++)for(let z=0;z<Z;z++)quad(r===R-1?peel:pith,idx(a,r,z),idx(a,r+1,z),idx(a,r+1,z+1),idx(a,r,z+1));
const surfaces=[surface(flesh,fleshMat),surface(pith,pithMat),surface(peel,peelMat)];
// Fine membranes and hundreds of translucent juice vesicles on both cut faces.
const membranes=[];const lineMat=new THREE.LineBasicMaterial({color:0xffe0a0,transparent:true,opacity:.75});for(let z of [0,Z])for(let a=0;a<=A;a+=4){let g=new THREE.BufferGeometry();g.setAttribute('position',new THREE.BufferAttribute(new Float32Array((R-1)*3),3));let line=new THREE.Line(g,lineMat);line.frustumCulled=false;scene.add(line);membranes.push({g,a,z})}
const cellGeo=new THREE.SphereGeometry(1,5,4),cellMat=new THREE.MeshPhysicalMaterial({color:0xffd058,transparent:true,opacity:.6,roughness:.15,clearcoat:1,emissive:0xff8a00,emissiveIntensity:.17});const count=460,cells=new THREE.InstancedMesh(cellGeo,cellMat,count);cells.frustumCulled=false;scene.add(cells);let seed=5723;function rnd(){seed=(seed*1664525+1013904223)>>>0;return seed/4294967296}const ves=[];for(let i=0;i<count;i++){let a=1+Math.floor(rnd()*(A-2)),r=1+Math.floor(rnd()*(R-2)),z=rnd()<.5?0:Z;ves.push({a,r,z,scale:.018+rnd()*.022,offset:(rnd()-.5)*.07})}const dummy=new THREE.Object3D();
function updateVisual(){for(const s of surfaces){for(let i=0;i<s.indices.length;i++){let p=nodes[s.indices[i]].p;s.arr[i*3]=p.x;s.arr[i*3+1]=p.y;s.arr[i*3+2]=p.z}s.geo.attributes.position.needsUpdate=true;s.geo.computeVertexNormals()}for(const m of membranes){let ar=m.g.attributes.position.array;for(let r=1;r<R;r++){let p=nodes[idx(m.a,r,m.z)].p,k=(r-1)*3;ar[k]=p.x;ar[k+1]=p.y;ar[k+2]=p.z+(m.z===Z?.008:-.008)}m.g.attributes.position.needsUpdate=true}for(let i=0;i<count;i++){let v=ves[i],p=nodes[idx(v.a,v.r,v.z)].p;dummy.position.set(p.x+v.offset,p.y+v.offset,p.z+(v.z===Z?.012:-.012));dummy.rotation.z=Math.PI*v.a/A;dummy.scale.set(v.scale*.55,v.scale*1.7,v.scale*.3);dummy.updateMatrix();cells.setMatrixAt(i,dummy.matrix)}cells.instanceMatrix.needsUpdate=true}
let dragging=null,squeeze=0,dropClock=0;const ray=new THREE.Raycaster(),pointer=new THREE.Vector2(),plane=new THREE.Plane(),hit=new THREE.Vector3();let demo=location.hash==='#demo',demoStart=performance.now();const drops=[];
function spawnDrop(){let mat=new THREE.MeshPhysicalMaterial({color:0xffaa2a,transparent:true,opacity:.75,roughness:.08,clearcoat:1});let m=new THREE.Mesh(new THREE.SphereGeometry(.065,12,8),mat);m.scale.set(.7,1.25,.7);let side=Math.random()<.5?-1:1;m.position.set(side*(1.45+Math.random()*.3),.3+Math.random()*.2,.25);scene.add(m);drops.push({m,v:new THREE.Vector3(side*(.3+Math.random()*.5),.8+Math.random()*.5,.3),life:1.8})}
function reset(){for(const n of nodes){n.p.copy(n.rest);n.prev.copy(n.rest)}dragging=null;squeeze=0;for(const d of drops){scene.remove(d.m);d.m.geometry.dispose();d.m.material.dispose()}drops.length=0;firm.value=48;updateLabel()}
function updateLabel(){let v=+firm.value;label.textContent=v<34?'Soft':v<67?'Medium':'Firm'}firm.addEventListener('input',()=>{demo=false;updateLabel()});document.getElementById('reset').addEventListener('click',()=>{demo=false;reset()});document.getElementById('squeeze').addEventListener('click',()=>{demo=false;squeeze=1.8;dropClock=0});
function setRay(e){let rect=renderer.domElement.getBoundingClientRect();pointer.set((e.clientX-rect.left)/rect.width*2-1,-((e.clientY-rect.top)/rect.height)*2+1);ray.setFromCamera(pointer,camera)}
renderer.domElement.addEventListener('pointerdown',e=>{demo=false;setRay(e);let hits=ray.intersectObject(surfaces[0].geo?scene.children.find(o=>o.geometry===surfaces[0].geo):null);if(!hits.length)return;let point=hits[0].point,best=Infinity,id=0;for(let i=0;i<nodes.length;i++){let d=nodes[i].p.distanceToSquared(point);if(d<best){best=d;id=i}}plane.setFromNormalAndCoplanarPoint(camera.getWorldDirection(new THREE.Vector3()),point);dragging={id,target:point.clone(),origin:point.clone()};renderer.domElement.setPointerCapture(e.pointerId);e.preventDefault()});renderer.domElement.addEventListener('pointermove',e=>{if(!dragging)return;setRay(e);if(ray.ray.intersectPlane(plane,hit)){let delta=hit.clone().sub(dragging.origin).clampLength(0,1.05);dragging.target.copy(dragging.origin).add(delta)}e.preventDefault()});function release(){dragging=null}renderer.domElement.addEventListener('pointerup',release);renderer.domElement.addEventListener('pointercancel',release);
let accumulator=0,last=performance.now();function physics(dt){let stiffness=.23+(+firm.value/100)*.42;for(let n of nodes){let v=n.p.clone().sub(n.prev).multiplyScalar(.985);n.prev.copy(n.p);n.p.add(v);n.p.y-=2.9*dt*dt;if(squeeze>0){let envelope=Math.sin(Math.PI*Math.min(1,(1.8-squeeze)/1.8));n.p.x-=n.p.x*envelope*.0028}}
if(dragging){let n=nodes[dragging.id];n.p.lerp(dragging.target,.28)}for(let pass=0;pass<5;pass++){for(const s of springs){let a=nodes[s.i].p,b=nodes[s.j].p,dx=b.x-a.x,dy=b.y-a.y,dz=b.z-a.z,len=Math.sqrt(dx*dx+dy*dy+dz*dz)||1,cor=(len-s.d)/len*stiffness*s.weight*.5;dx*=cor;dy*=cor;dz*=cor;a.x+=dx;a.y+=dy;a.z+=dz;b.x-=dx;b.y-=dy;b.z-=dz}for(const n of nodes){if(n.p.y<base){n.p.y=base;n.prev.x+=(n.p.x-n.prev.x)*.12;n.prev.z+=(n.p.z-n.prev.z)*.12}}if(dragging)nodes[dragging.id].p.lerp(dragging.target,.18)}if(squeeze>0){squeeze-=dt;dropClock+=dt;if(dropClock>.32&&squeeze>.25){spawnDrop();dropClock=0}}for(let i=drops.length-1;i>=0;i--){let d=drops[i];d.v.y-=3.4*dt;d.m.position.addScaledVector(d.v,dt);if(d.m.position.y<.1){d.m.position.y=.1;d.v.y*=-.18;d.v.x*=.7;d.m.scale.y=.35}d.life-=dt;d.m.material.opacity=Math.min(.75,Math.max(0,d.life));if(d.life<=0){scene.remove(d.m);d.m.geometry.dispose();d.m.material.dispose();drops.splice(i,1)}}}
function resize(){let w=innerWidth,h=innerHeight;camera.aspect=w/h;camera.position.set(0,w<600?6.8:5.4,w<600?13.8:10.5);camera.lookAt(0,1,0);camera.updateProjectionMatrix();renderer.setSize(w,h)}window.addEventListener('resize',resize);resize();updateVisual();
function animate(now){requestAnimationFrame(animate);let elapsed=Math.min(.05,(now-last)/1000);last=now;if(demo){let t=((now-demoStart)/1000)%20;if(t<4){let id=idx(8,7,Z);if(!dragging||dragging.demo!==true)dragging={id,target:nodes[id].rest.clone(),origin:nodes[id].rest.clone(),demo:true};dragging.target.copy(dragging.origin).add(new THREE.Vector3(Math.sin(t*Math.PI/4)*.7,.35*Math.sin(t*Math.PI/4),.25*Math.sin(t*Math.PI/4))}else if(dragging&&dragging.demo)dragging=null;if(t>6&&t<6.1&&squeeze<=0){squeeze=1.8;dropClock=0}if(t>11&&t<14){firm.value=15;updateLabel()}if(t>15&&t<18){firm.value=90;updateLabel()}if(t>19.8){firm.value=48;updateLabel()}}accumulator+=elapsed;while(accumulator>=1/120){physics(1/120);accumulator-=1/120}updateVisual();renderer.render(scene,camera)}requestAnimationFrame(animate);
})();
</script></body></html>
