Back to the app
The code
Swim the Kelp Garden 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,viewport-fit=cover">
<meta name="theme-color" content="#092f3a">
<title>Kelp Garden — a quiet place to drift</title>
<style>
:root{color-scheme:dark;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#082a38}canvas{display:block;width:100%;height:100%;touch-action:none}.wash{position:fixed;inset:0;pointer-events:none;background:linear-gradient(180deg,rgba(3,27,32,.28),transparent 24%,transparent 72%,rgba(2,23,29,.36));box-shadow:inset 0 0 110px rgba(1,22,29,.25)}.top{position:fixed;top:max(22px,env(safe-area-inset-top));left:clamp(20px,4vw,54px);right:clamp(20px,4vw,54px);display:flex;align-items:flex-start;justify-content:space-between;pointer-events:none}.brand{display:flex;gap:12px;align-items:center}.mark{width:36px;height:36px;border:1px solid rgba(212,238,218,.6);border-radius:50%;display:grid;place-items:center;color:#d7ddaa;font-size:19px}.eyebrow{font-size:9px;letter-spacing:.23em;text-transform:uppercase;color:#b4d3c9;font-weight:700}.name{font-family:Georgia,serif;font-size:20px;letter-spacing:.02em;color:#f1efdb;margin-top:2px}.status{font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:#d6e5cf;display:flex;gap:8px;align-items:center;padding-top:10px}.dot{width:6px;height:6px;border-radius:50%;background:#d5c47b;box-shadow:0 0 12px #e8d38a}.bottom{position:fixed;left:clamp(20px,4vw,54px);right:clamp(20px,4vw,54px);bottom:max(24px,env(safe-area-inset-bottom));display:flex;align-items:end;justify-content:space-between;gap:18px;pointer-events:none}.intro{max-width:410px;transition:opacity 1s,transform 1s;text-shadow:0 2px 18px #07323a}.intro.dim{opacity:.5}.kicker{font-size:10px;letter-spacing:.22em;text-transform:uppercase;color:#c9d6ae;font-weight:700}.intro h1{font:normal clamp(33px,5vw,62px)/.98 Georgia,serif;color:#f6f0d8;letter-spacing:-.035em;margin:12px 0}.intro p{font-size:13px;line-height:1.55;color:#c5ded5;margin:0;max-width:330px}.actions{display:flex;gap:9px;align-items:center;pointer-events:auto}.button{height:48px;min-width:48px;border:1px solid rgba(222,239,220,.42);border-radius:50px;background:rgba(7,43,47,.46);backdrop-filter:blur(12px);color:#f0f1dd;cursor:pointer;font:600 11px system-ui;letter-spacing:.08em;padding:0 19px}.button:active{background:rgba(230,226,170,.25)}.hint{position:fixed;left:50%;bottom:max(30px,env(safe-area-inset-bottom));transform:translateX(-50%);color:#d8e7da;font-size:10px;text-transform:uppercase;letter-spacing:.16em;white-space:nowrap;pointer-events:none;opacity:.8;transition:opacity 1s}.hint.hidden{opacity:0}.reticle{position:fixed;left:50%;top:50%;width:5px;height:5px;margin:-2px;border:1px solid rgba(236,244,219,.65);border-radius:50%;pointer-events:none;opacity:.7}.loading{position:fixed;inset:0;display:grid;place-items:center;background:#092d38;color:#c9ddd0;letter-spacing:.18em;text-transform:uppercase;font-size:10px;transition:opacity 1s;pointer-events:none}.loading.done{opacity:0}.error{position:fixed;inset:0;display:none;place-items:center;text-align:center;padding:30px;background:#092d38;color:#dae9df;font:16px/1.6 system-ui}.error.show{display:grid}@media(max-width:650px){.top{top:max(18px,env(safe-area-inset-top))}.status{font-size:9px}.bottom{bottom:max(20px,env(safe-area-inset-bottom));align-items:end}.intro h1{font-size:39px}.intro p{font-size:12px;max-width:240px}.hint{bottom:160px;font-size:9px}.button{padding:0 15px}.name{font-size:17px}.intro.dim{opacity:.28}}
</style>
</head>
<body>
<div id="error" class="error">The garden could not load. Please check your connection and try again.</div>
<div id="loading" class="loading">Finding the quiet current...</div>
<div class="wash"></div><div class="reticle"></div>
<header class="top"><div class="brand"><div class="mark">✳</div><div><div class="eyebrow">A little underwater escape</div><div class="name">Kelp Garden</div></div></div><div class="status"><span class="dot"></span> Beneath the surface</div></header>
<div id="hint" class="hint">Hold to swim · drag to look around</div>
<footer class="bottom"><div class="intro" id="intro"><div class="kicker">Take your time</div><h1>Drift a little<br>deeper.</h1><p>Follow the light through a garden that moves with the sea.</p></div><div class="actions"><button class="button" id="reset" aria-label="Return to the beginning">↺ Start over</button></div></footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<script>
(()=>{
'use strict';
if(!window.THREE){document.getElementById('error').classList.add('show');return}
try{
const T=THREE, scene=new T.Scene();scene.background=new T.Color(0x185564);scene.fog=new T.FogExp2(0x185564,0.022);
const renderer=new T.WebGLRenderer({antialias:true,powerPreference:'high-performance'});renderer.setPixelRatio(Math.min(devicePixelRatio,1.5));renderer.setSize(innerWidth,innerHeight);renderer.outputColorSpace=T.SRGBColorSpace;renderer.toneMapping=T.ACESFilmicToneMapping;renderer.toneMappingExposure=1.1;document.body.prepend(renderer.domElement);
const camera=new T.PerspectiveCamera(62,innerWidth/innerHeight,.1,160);const hemi=new T.HemisphereLight(0xaad9d0,0x725c36,2.0);scene.add(hemi);const sun=new T.DirectionalLight(0xffe9a9,2.2);sun.position.set(-18,32,10);scene.add(sun);
const mat=(c,extra={})=>new T.MeshStandardMaterial({color:c,roughness:.87,...extra});const sandMat=mat(0xb4a26b),rockMats=[mat(0x526c5d),mat(0x58685a),mat(0x6f7861),mat(0x426258)],wood=mat(0x73503a),woodDark=mat(0x473b31),kelpMats=[mat(0x396e49,{side:T.DoubleSide}),mat(0x56854b,{side:T.DoubleSide}),mat(0x8b914e,{side:T.DoubleSide})];
let seed=12345;function rand(){seed=(seed*1664525+1013904223)>>>0;return seed/4294967296}function range(a,b){return a+(b-a)*rand()}function pick(a){return a[Math.floor(rand()*a.length)]}
const ground=new T.Mesh(new T.PlaneGeometry(230,230,80,80),sandMat);ground.rotation.x=-Math.PI/2;let gp=ground.geometry.attributes.position;for(let i=0;i<gp.count;i++){let x=gp.getX(i),y=gp.getY(i);gp.setZ(i,Math.sin(x*.16)*.12+Math.cos(y*.2)*.1+Math.sin(x*.43+y*.35)*.045)}ground.geometry.computeVertexNormals();scene.add(ground);
const surface=new T.Mesh(new T.PlaneGeometry(220,220,48,48),new T.MeshBasicMaterial({color:0x71b7ad,transparent:true,opacity:.35,side:T.DoubleSide,depthWrite:false}));surface.rotation.x=Math.PI/2;surface.position.y=21;scene.add(surface);const surfBase=surface.geometry.attributes.position.array.slice();
// A scattering of bright, broken lines suggests refracted sunlight on the sand.
const rippleMat=new T.MeshBasicMaterial({color:0xf4d999,transparent:true,opacity:.18,side:T.DoubleSide,depthWrite:false});const ripples=[];for(let i=0;i<110;i++){let m=new T.Mesh(new T.RingGeometry(.65, .7, 30,1,0,range(1,3.5)),rippleMat);m.rotation.x=-Math.PI/2;m.rotation.z=range(0,6.28);m.scale.set(range(.6,2.3),range(.2,.65),1);m.position.set(range(-52,52),.14,range(-52,52));scene.add(m);ripples.push(m)}
// Subtle slanted shafts fade into the blue.
const beamMat=new T.MeshBasicMaterial({color:0xdce8b5,transparent:true,opacity:.045,side:T.DoubleSide,depthWrite:false,blending:T.AdditiveBlending});for(let i=0;i<9;i++){let b=new T.Mesh(new T.ConeGeometry(range(1.5,3.2),25,6,1,true),beamMat);b.position.set(-25+i*7,10,range(-35,20));b.rotation.z=-.34;scene.add(b)}
const colliders=[];function rock(x,y,z,sx,sy,sz,solid=true){let g=new T.IcosahedronGeometry(1,1);let p=g.attributes.position;for(let i=0;i<p.count;i++){let v=range(.85,1.15);p.setXYZ(i,p.getX(i)*v,p.getY(i)*v,p.getZ(i)*v)}g.computeVertexNormals();let m=new T.Mesh(g,pick(rockMats));m.position.set(x,y,z);m.scale.set(sx,sy,sz);m.rotation.set(range(-.2,.2),range(0,6.28),range(-.2,.2));scene.add(m);if(solid)colliders.push({x,y,z,rx:sx*.84,ry:sy*.85,rz:sz*.84});return m}
// The arch is built from individual boulders; each is also a swimming obstacle.
function arch(cx,cz,rot=0,scale=1){let group=[];for(let side of [-1,1])for(let j=0;j<4;j++){let x=side*(4.3-j*.22)*scale,y=(1+j*1.5)*scale;group.push([x,y,0,1.35*scale,1.35*scale,1.45*scale])}for(let i=0;i<7;i++){let a=Math.PI*i/6;group.push([Math.cos(a)*3.7*scale,(6.1+Math.sin(a)*1.65)*scale,0,1.25*scale,1.1*scale,1.35*scale])}for(const [x,y,z,sx,sy,sz] of group){let xx=cx+x*Math.cos(rot)-z*Math.sin(rot),zz=cz+x*Math.sin(rot)+z*Math.cos(rot);rock(xx,y,zz,sx,sy,sz)}}
arch(-13,-27,.2,1);arch(26,-52,-.4,.8);for(let i=0;i<36;i++){let x=range(-62,62),z=range(-72,22);if(Math.abs(x)<8&&z>-20)continue;let s=range(.5,2.4);rock(x,s*.45,z,s,s*.65,s*range(.7,1.2))}
// An old wooden hull, with broken ribs and a leaning mast.
const ship=new T.Group();ship.position.set(17,.2,-29);ship.rotation.y=-.35;scene.add(ship);
const hullShape=new T.Shape();hullShape.moveTo(-7,2.5);hullShape.lineTo(-5.7,.35);hullShape.quadraticCurveTo(0,-.5,5.7,.35);hullShape.lineTo(7,2.5);hullShape.lineTo(5.8,2.3);hullShape.lineTo(4.9,1.15);hullShape.quadraticCurveTo(0,.4,-4.9,1.15);hullShape.lineTo(-5.8,2.3);hullShape.closePath();const hullGeo=new T.ExtrudeGeometry(hullShape,{depth:4,bevelEnabled:true,bevelSize:.12,bevelThickness:.12,bevelSegments:1});let hull=new T.Mesh(hullGeo,wood);hull.position.z=-2;ship.add(hull);
for(let side of [-1,1])for(let j=0;j<4;j++){let plank=new T.Mesh(new T.BoxGeometry(12.5-j*.4,.27,.18),j%2?wood:woodDark);plank.position.set(0,.7+j*.45,side*(1.98-j*.06));ship.add(plank)}
for(let x of [-5,-3,0,3,5]){let rib=new T.Mesh(new T.BoxGeometry(.22,1.9,4.1),woodDark);rib.position.set(x,1.2,0);ship.add(rib)}let deck=new T.Mesh(new T.BoxGeometry(8,.2,3.7),wood);deck.position.set(0,1.3,0);ship.add(deck);let mast=new T.Mesh(new T.CylinderGeometry(.14,.24,8,7),woodDark);mast.position.set(-1,5,0);mast.rotation.z=.17;ship.add(mast);let spar=new T.Mesh(new T.CylinderGeometry(.09,.1,5,6),wood);spar.position.set(-1.3,6,0);spar.rotation.z=Math.PI/2+.17;ship.add(spar);
// Approximate the hull with overlapping collision volumes.
for(let x=-5;x<=5;x+=2){let wx=17+x*Math.cos(-.35),wz=-29-x*Math.sin(-.35);colliders.push({x:wx,y:1.5,z:wz,rx:1.5,ry:1.8,rz:2.1})}colliders.push({x:16,y:5,z:-29,rx:.45,ry:4,rz:.45});
// Kelp blades are tapered ribbons whose vertices sway independently.
const blades=[];function addKelp(x,z,h,phase){let geo=new T.PlaneGeometry(range(.28,.55),h,1,12);geo.translate(0,h/2,0);let p=geo.attributes.position;for(let i=0;i<p.count;i++){let y=p.getY(i),f=y/h;p.setX(i,p.getX(i)*(1-.82*f));}let mesh=new T.Mesh(geo,pick(kelpMats));mesh.position.set(x,.05,z);mesh.rotation.y=range(0,Math.PI);mesh.userData={base:p.array.slice(),h,phase};scene.add(mesh);blades.push(mesh)}
for(let patch=0;patch<65;patch++){let x=range(-61,61),z=range(-75,15);if(Math.abs(x)<5&&z>-16)continue;for(let j=0;j<5;j++)addKelp(x+range(-1.4,1.4),z+range(-1.4,1.4),range(4,12),range(0,6.28))}
// Warm coral fans and rounded sponges punctuate the green.
const corals=[mat(0xd48242),mat(0xbc7240),mat(0xc5a356),mat(0x9a6e40)];function coral(x,z){let group=new T.Group();group.position.set(x,.15,z);scene.add(group);let cm=pick(corals);for(let i=0;i<5;i++){let a=range(0,6.28),h=range(.5,1.7),stem=new T.Mesh(new T.CylinderGeometry(.06,.13,h,5),cm);stem.position.set(Math.cos(a)*.25,h/2,Math.sin(a)*.25);stem.rotation.z=Math.cos(a)*.35;stem.rotation.x=Math.sin(a)*.35;group.add(stem);let tip=new T.Mesh(new T.SphereGeometry(.13,6,5),cm);tip.position.set(Math.cos(a)*(.25+h*.18),h,Math.sin(a)*(.25+h*.18));group.add(tip)}}for(let i=0;i<65;i++)coral(range(-60,60),range(-70,15));
// Schools share a heading and turn as one.
const fishGeo=new T.SphereGeometry(1,8,5),tailGeo=new T.ConeGeometry(1,1,4),fishMats=[mat(0xd9a64d,{metalness:.15,roughness:.45}),mat(0xe5be6d,{metalness:.15,roughness:.45}),mat(0x8ebcb0,{metalness:.2,roughness:.4})],schools=[];for(let s=0;s<5;s++){let group=new T.Group();scene.add(group);let members=[];for(let i=0;i<17;i++){let f=new T.Group(),body=new T.Mesh(fishGeo,fishMats[s%3]);body.scale.set(.4,.18,.13);f.add(body);let tail=new T.Mesh(tailGeo,fishMats[s%3]);tail.rotation.z=-Math.PI/2;tail.scale.set(.19,.28,.08);tail.position.x=-.42;f.add(tail);f.position.set(range(-3,3),range(-1.2,1.2),range(-2,2));f.scale.setScalar(range(.65,1.2));group.add(f);members.push(f)}schools.push({group,members,cx:range(-30,30),cz:range(-56,-9),y:range(5,13),r:range(5,10),speed:range(.12,.22),phase:range(0,6.28)})}
// Rays have broad animated wings and long trailing tails.
const rays=[];for(let i=0;i<3;i++){let group=new T.Group(),shape=new T.Shape();shape.moveTo(2.3,0);shape.quadraticCurveTo(.55,1.1,0,.7);shape.quadraticCurveTo(-.55,1.1,-2.3,0);shape.quadraticCurveTo(-.7,-.7,0,-.55);shape.quadraticCurveTo(.7,-.7,2.3,0);let m=new T.Mesh(new T.ShapeGeometry(shape,12),mat(0x527c72,{side:T.DoubleSide}));m.rotation.x=-Math.PI/2;group.add(m);let tail=new T.Mesh(new T.CylinderGeometry(.015,.06,2.2,5),mat(0x426c64));tail.rotation.x=Math.PI/2;tail.position.z=1.35;group.add(tail);scene.add(group);rays.push({group,wing:m,phase:i*2.2,cx:-10+i*17,cz:-30-i*8,y:9+i*1.4})}
const bubbles=[];let bubbleGeo=new T.SphereGeometry(1,7,6),bubbleMat=new T.MeshBasicMaterial({color:0xc4eee0,transparent:true,opacity:.35,wireframe:true,depthWrite:false});for(let i=0;i<70;i++){let b=new T.Mesh(bubbleGeo,bubbleMat);let size=range(.04,.17);b.scale.setScalar(size);b.position.set(range(-35,35),range(0,21),range(-60,8));b.userData={speed:range(.5,1.2),phase:range(0,6.28),x:b.position.x};scene.add(b);bubbles.push(b)}
const start=new T.Vector3(0,5,10),position=start.clone();let yaw=0,pitch=-.05,held=false,lastX=0,lastY=0,moved=false,demo=location.hash==='#demo',demoStart=performance.now(),interacted=false;const intro=document.getElementById('intro'),hint=document.getElementById('hint');
function endDemo(){demo=false;interacted=true;intro.classList.add('dim');hint.classList.add('hidden')}
renderer.domElement.addEventListener('pointerdown',e=>{if(e.button!==undefined&&e.button!==0)return;e.preventDefault();endDemo();held=true;lastX=e.clientX;lastY=e.clientY;renderer.domElement.setPointerCapture(e.pointerId)});renderer.domElement.addEventListener('pointermove',e=>{if(!held)return;e.preventDefault();let dx=e.clientX-lastX,dy=e.clientY-lastY;yaw-=dx*.004;pitch=Math.max(-1.05,Math.min(1.05,pitch-dy*.003));lastX=e.clientX;lastY=e.clientY;moved=true});function release(){held=false}renderer.domElement.addEventListener('pointerup',release);renderer.domElement.addEventListener('pointercancel',release);window.addEventListener('blur',release);
document.getElementById('reset').addEventListener('click',()=>{endDemo();held=false;position.copy(start);yaw=0;pitch=-.05});
function blocked(p){if(p.y<.8||p.y>19.5||Math.abs(p.x)>100||Math.abs(p.z)>100)return true;for(const c of colliders){let x=(p.x-c.x)/(c.rx+.55),y=(p.y-c.y)/(c.ry+.55),z=(p.z-c.z)/(c.rz+.55);if(x*x+y*y+z*z<1)return true}return false}
function move(distance){let d=new T.Vector3(-Math.sin(yaw)*Math.cos(pitch),Math.sin(pitch),-Math.cos(yaw)*Math.cos(pitch)).multiplyScalar(distance);let next=position.clone().add(d);if(!blocked(next)){position.copy(next);return}for(let axis of ['x','z','y']){let q=position.clone();q[axis]+=d[axis];if(!blocked(q))position.copy(q)}}
let last=performance.now();function animate(now){requestAnimationFrame(animate);let dt=Math.min((now-last)/1000,.05),t=now/1000;last=now;if(demo){let cycle=((now-demoStart)/1000)%20;if(cycle<.08){position.copy(start);yaw=0;pitch=-.05}yaw=.25*Math.sin(cycle*.32);pitch=.06+Math.sin(cycle*.3)*.09;move(dt*2.3);if(cycle>8&&cycle<14)yaw=-.65;if(cycle>=14)yaw=.8;intro.classList.add('dim')}else if(held)move(dt*3.5);camera.position.copy(position);camera.rotation.order='YXZ';camera.rotation.y=yaw;camera.rotation.x=pitch;
for(const blade of blades){let p=blade.geometry.attributes.position,b=blade.userData.base,h=blade.userData.h,ph=blade.userData.phase;for(let i=0;i<p.count;i++){let y=b[i*3+1],f=y/h;p.setX(i,b[i*3]+Math.sin(t*.75+ph+y*.25)*f*f*.9)}p.needsUpdate=true;blade.geometry.computeVertexNormals()}
let sp=surface.geometry.attributes.position;for(let i=0;i<sp.count;i++){let x=surfBase[i*3],y=surfBase[i*3+1];sp.setZ(i,Math.sin(x*.13+t*.65)*.25+Math.cos(y*.15+t*.5)*.18)}sp.needsUpdate=true;surface.geometry.computeVertexNormals();rippleMat.opacity=.14+Math.sin(t*.9)*.035;
for(const s of schools){let a=t*s.speed+s.phase;s.group.position.set(s.cx+Math.cos(a)*s.r,s.y+Math.sin(a*.7)*.6,s.cz+Math.sin(a)*s.r);s.group.rotation.y=-a-Math.PI/2;for(let i=0;i<s.members.length;i++){s.members[i].rotation.y=Math.sin(t*5+i)*.1}}
for(const r of rays){let a=t*.12+r.phase;r.group.position.set(r.cx+Math.cos(a)*12,r.y+Math.sin(a*1.3)*.8,r.cz+Math.sin(a)*9);r.group.rotation.y=-a;r.wing.scale.x=1+Math.sin(t*1.7+r.phase)*.1;r.wing.rotation.z=Math.sin(t*1.7+r.phase)*.08}
for(const b of bubbles){b.position.y+=dt*b.userData.speed;if(b.position.y>20.5)b.position.y=.2;b.position.x=b.userData.x+Math.sin(t+b.userData.phase+b.position.y*.25)*.25}renderer.render(scene,camera)}requestAnimationFrame(animate);window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setPixelRatio(Math.min(devicePixelRatio,1.5));renderer.setSize(innerWidth,innerHeight)});document.getElementById('loading').classList.add('done');
}catch(e){document.getElementById('loading').classList.add('done');document.getElementById('error').classList.add('show')}
})();
</script>
</body>
</html>
