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"><meta name="theme-color" content="#063d49">
<title>Kelp Garden Swim</title>
<style>
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#063d49;font-family:Georgia,serif;color:#eaf6df}canvas{display:block;touch-action:none}#ui{position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,rgba(0,30,37,.35),transparent 25%,transparent 72%,rgba(0,25,31,.55))}.top{position:absolute;top:max(22px,env(safe-area-inset-top));left:clamp(20px,4vw,52px);text-shadow:0 2px 12px #00383b}.eyebrow{font:600 10px/1.4 system-ui,sans-serif;letter-spacing:.27em;text-transform:uppercase;color:#c5d9a2}.title{font-size:clamp(26px,4vw,48px);font-weight:normal;letter-spacing:.01em;margin:5px 0}.subtitle{font:13px/1.5 system-ui,sans-serif;color:#c7e4d8}.bottom{position:absolute;bottom:max(22px,env(safe-area-inset-bottom));left:0;right:0;display:flex;align-items:end;justify-content:space-between;gap:14px;padding:0 clamp(20px,4vw,52px)}.hint{display:flex;align-items:center;gap:12px;font:12px/1.5 system-ui,sans-serif;color:#e4eee0;text-shadow:0 1px 8px #003}.icon{width:42px;height:42px;display:grid;place-items:center;border:1px solid #b4d8c080;border-radius:50%;font-size:19px;background:#0d5a5880}.hint strong{display:block;font-weight:600;letter-spacing:.04em}.hint span{color:#b8d9d0}.buttons{display:flex;gap:8px;pointer-events:auto}button{border:1px solid #b7d8bd80;background:#0b5556b8;color:#e7f2dc;border-radius:30px;padding:12px 17px;min-height:46px;font:600 11px system-ui,sans-serif;letter-spacing:.1em;text-transform:uppercase;backdrop-filter:blur(8px);cursor:pointer}button:active{background:#b9d7a3;color:#123f3e}#notice{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font:14px system-ui;text-align:center;background:#073c49dd;padding:18px;border-radius:12px;display:none}@media(max-width:600px){.subtitle{max-width:250px}.hint span{display:none}.bottom{align-items:center}.hint{font-size:11px}.icon{width:38px;height:38px}button{padding:11px 13px}.title{font-size:30px}}
</style>
</head>
<body><div id="ui"><div class="top"><div class="eyebrow">A little world beneath the waves</div><h1 class="title">Kelp Garden</h1><div class="subtitle">Take a breath. There’s nowhere to be.</div></div><div class="bottom"><div class="hint"><div class="icon">↗</div><div><strong>Hold & glide</strong><span>Drag to look around · release to drift</span></div></div><div class="buttons"><button id="reset">Start over</button><button id="sound">Sound off</button></div></div><div id="notice"></div></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<script>
(()=>{'use strict';
if(!window.THREE){const n=document.getElementById('notice');n.style.display='block';n.textContent='The underwater world could not load. Please check your connection and try again.';return}
const T=THREE, scene=new T.Scene();scene.background=new T.Color(0x075968);scene.fog=new T.FogExp2(0x075968,.024);
const camera=new T.PerspectiveCamera(66,innerWidth/innerHeight,.1,130);const renderer=new T.WebGLRenderer({antialias:true,alpha:false});renderer.setPixelRatio(Math.min(devicePixelRatio,1.6));renderer.setSize(innerWidth,innerHeight);renderer.outputColorSpace=T.SRGBColorSpace;document.body.prepend(renderer.domElement);
scene.add(new T.HemisphereLight(0xb2ead8,0x6b7044,2.1));const sun=new T.DirectionalLight(0xffe7aa,2);sun.position.set(-12,30,10);scene.add(sun);
const mat=(c,rough=1)=>new T.MeshStandardMaterial({color:c,roughness:rough});const sand=mat(0xc7ac6b),rock=mat(0x536d59),rock2=mat(0x728368),wood=mat(0x79583a),darkwood=mat(0x473e2e),gold=mat(0xe9b65d),orange=mat(0xe79c50),green=mat(0x3e8159),lightgreen=mat(0x79a75c);
function mesh(g,m,x,y,z,parent=scene){const o=new T.Mesh(g,m);o.position.set(x,y,z);parent.add(o);return o}function rand(a,b){return a+Math.random()*(b-a)}
const floor=mesh(new T.PlaneGeometry(240,240,1,1),sand,0,-.5,0);floor.rotation.x=-Math.PI/2;
// Wavy bands on the sand suggest shifting caustic light.
const caustics=[];for(let i=0;i<100;i++){let g=new T.RingGeometry(.65,1.05,32,1,0,rand(1.4,4.5));let m=new T.MeshBasicMaterial({color:0xf7dfa0,transparent:true,opacity:rand(.05,.15),side:T.DoubleSide,depthWrite:false});let o=mesh(g,m,rand(-48,48),-.47,rand(-48,48));o.rotation.x=-Math.PI/2;o.scale.set(rand(1,3),rand(.3,1),1);caustics.push(o)}
// Surface, sunlight shafts and drifting particles.
const surface=mesh(new T.PlaneGeometry(180,180,32,32),new T.MeshBasicMaterial({color:0x63b6a3,transparent:true,opacity:.35,side:T.DoubleSide}),0,23,0);surface.rotation.x=Math.PI/2;const surfaceBase=surface.geometry.attributes.position.array.slice();
for(let i=0;i<10;i++){let beam=mesh(new T.CylinderGeometry(rand(.2,.8),rand(2,4),24,8,1,true),new T.MeshBasicMaterial({color:0xd5eaa6,transparent:true,opacity:.035,depthWrite:false,side:T.DoubleSide}),rand(-35,35),11,rand(-45,20));beam.rotation.z=.25}
let particles=[];for(let i=0;i<180;i++){const p=mesh(new T.SphereGeometry(rand(.025,.065),5,4),new T.MeshBasicMaterial({color:0xc7e6cc,transparent:true,opacity:.55}),rand(-45,45),rand(0,22),rand(-50,30));particles.push(p)}
let bubbles=[];for(let i=0;i<55;i++){let b=mesh(new T.SphereGeometry(rand(.06,.18),8,6),new T.MeshBasicMaterial({color:0xc8f4e1,transparent:true,opacity:.4,wireframe:true}),rand(-35,35),rand(0,22),rand(-40,20));bubbles.push(b)}
const colliders=[];function collider(x,z,r){colliders.push({x,z,r})}
function boulder(x,z,s){let o=mesh(new T.DodecahedronGeometry(1,1),Math.random()<.5?rock:rock2,x,s*.45-.3,z);o.scale.set(s*rand(.8,1.2),s*.55,s*rand(.75,1.1));o.rotation.set(rand(0,2),rand(0,3),rand(0,2));collider(x,z,s*.8)}
for(let i=0;i<55;i++){let x=rand(-50,50),z=rand(-55,35);if(Math.hypot(x,z-8)>8&&Math.hypot(x-7,z+13)>12)boulder(x,z,rand(.8,2.8))}
// Arches are made of overlapping stones; their legs remain solid to the swimmer.
function arch(x,z,angle,scale){let group=new T.Group();group.position.set(x,0,z);group.rotation.y=angle;scene.add(group);for(let i=0;i<=10;i++){let a=Math.PI*i/10;let stone=mesh(new T.DodecahedronGeometry(1,0),i%2?rock:rock2,Math.cos(a)*4*scale,Math.sin(a)*4*scale+1*scale,0,group);stone.scale.set(1.2*scale,1.35*scale,1.45*scale);stone.rotation.z=a}for(const side of [-1,1]){const lx=side*4*scale;collider(x+Math.cos(angle)*lx,z-Math.sin(angle)*lx,1.35*scale)}}arch(-12,-12,.4,1.1);arch(21,-29,-.5,1.4);
// A weathered wooden wreck with curved ribs, mast and torn sail.
const ship=new T.Group();ship.position.set(8,0,-16);ship.rotation.y=-.48;scene.add(ship);let hull=mesh(new T.CylinderGeometry(3.3,2.1,12,10,1,true,0,Math.PI),wood,0,1.4,0,ship);hull.rotation.z=Math.PI/2;hull.rotation.x=Math.PI/2;hull.scale.set(1,1,.65);let deck=mesh(new T.BoxGeometry(11,.35,4.8),darkwood,0,2.05,0,ship);for(let i=-5;i<=5;i++){let plank=mesh(new T.BoxGeometry(.12,.12,4.7),wood,i,2.27,0,ship)}for(let i=-4;i<=4;i+=2){let rib=mesh(new T.TorusGeometry(2.4,.12,6,12,Math.PI),darkwood,i,1.9,0,ship);rib.rotation.y=Math.PI/2;rib.rotation.z=Math.PI}let mast=mesh(new T.CylinderGeometry(.13,.25,9,8),darkwood,-.5,6.3,0,ship);mast.rotation.z=.18;let spar=mesh(new T.CylinderGeometry(.08,.1,5,6),wood,-.9,8,0,ship);spar.rotation.z=Math.PI/2+.18;let sail=mesh(new T.PlaneGeometry(4.2,3.2,4,4),new T.MeshStandardMaterial({color:0xaaa16b,side:T.DoubleSide,transparent:true,opacity:.75}),-.9,6.3,.08,ship);sail.rotation.z=.18;for(let i=-5;i<=5;i+=2){let local=new T.Vector3(i,0,0).applyAxisAngle(new T.Vector3(0,1,0),-.48);collider(8+local.x,-16+local.z,2.8)}
// Kelp ribbons: flexible, articulated strips anchored in the sand.
const kelps=[];function kelp(x,z,h){let group=new T.Group();group.position.set(x,0,z);scene.add(group);let stem=mesh(new T.CylinderGeometry(.035,.09,h,5),green,0,h/2,0,group);for(let j=0;j<7;j++){let y=.8+j*h/8;let leaf=mesh(new T.SphereGeometry(1,7,5),j%2?green:lightgreen,(j%2?1:-1)*.3,y,0,group);leaf.scale.set(.3,rand(.8,1.5),.09);leaf.rotation.z=(j%2?-.5:.5)}kelps.push({group,phase:rand(0,6),h})}for(let i=0;i<260;i++){let x=rand(-50,50),z=rand(-55,30);if(Math.hypot(x,z-8)>4&&Math.hypot(x-8,z+16)>8)kelp(x,z,rand(3,9))}
// Coral clusters in the garden palette.
for(let i=0;i<65;i++){let x=rand(-43,43),z=rand(-48,28);if(Math.hypot(x,z-8)<4)continue;let cluster=new T.Group();cluster.position.set(x,0,z);scene.add(cluster);for(let j=0;j<5;j++){let branch=mesh(new T.CylinderGeometry(.07,.15,rand(.6,1.8),6),j%2?orange:gold,rand(-.5,.5),.55,rand(-.5,.5),cluster);branch.rotation.z=rand(-.55,.55);let tip=mesh(new T.SphereGeometry(.13,6,5),j%2?orange:gold,branch.position.x+Math.sin(-branch.rotation.z)*.5,1.15,branch.position.z,cluster)}}
// Schools move as coherent groups, each fish holding its place in formation.
const schools=[];for(let s=0;s<5;s++){let group=new T.Group();scene.add(group);let count=14;for(let i=0;i<count;i++){let fish=new T.Group();group.add(fish);fish.position.set(rand(-3,3),rand(-1.2,1.2),rand(-2,2));let body=mesh(new T.SphereGeometry(1,8,6),i%3?gold:orange,0,0,0,fish);body.scale.set(.38,.17,.11);let tail=mesh(new T.ConeGeometry(.18,.32,4),i%3?gold:orange,-.42,0,0,fish);tail.rotation.z=-Math.PI/2}schools.push({group,cx:rand(-25,25),cz:rand(-32,5),y:rand(4,12),radius:rand(4,9),speed:rand(.12,.22),phase:rand(0,6)})}
const rays=[];for(let i=0;i<3;i++){let group=new T.Group();scene.add(group);let body=mesh(new T.SphereGeometry(1,10,6),darkwood,0,0,0,group);body.scale.set(.65,.18,1);let wings=[];for(let side of [-1,1]){let wing=mesh(new T.ConeGeometry(1,2.3,3),rock,side*1.1,0,0,group);wing.rotation.z=side*-Math.PI/2;wings.push(wing)}let tail=mesh(new T.CylinderGeometry(.025,.04,2,5),darkwood,0,0,1.5,group);tail.rotation.x=Math.PI/2;rays.push({group,wings,phase:i*2.1,y:8+i*2})}
let yaw=0,pitch=-.05,holding=false,lastX=0,lastY=0,demo=location.hash==='#demo',elapsed=0;camera.position.set(0,3.2,12);function reset(){camera.position.set(0,3.2,12);yaw=0;pitch=-.05}document.getElementById('reset').addEventListener('click',()=>{demo=false;reset()});
let audio=null,soundOn=false;document.getElementById('sound').addEventListener('click',async e=>{try{if(!audio){audio=new (window.AudioContext||window.webkitAudioContext)();let buffer=audio.createBuffer(1,audio.sampleRate*3,audio.sampleRate),d=buffer.getChannelData(0);for(let i=0;i<d.length;i++)d[i]=(Math.random()*2-1)*.12;let source=audio.createBufferSource();source.buffer=buffer;source.loop=true;let filter=audio.createBiquadFilter();filter.type='lowpass';filter.frequency.value=180;let gain=audio.createGain();gain.gain.value=.3;source.connect(filter).connect(gain).connect(audio.destination);source.start()}soundOn=!soundOn;if(soundOn)await audio.resume();else await audio.suspend();e.currentTarget.textContent=soundOn?'Sound on':'Sound off'}catch(err){e.currentTarget.textContent='Sound unavailable'}});
const canvas=renderer.domElement;canvas.addEventListener('pointerdown',e=>{demo=false;holding=true;lastX=e.clientX;lastY=e.clientY;canvas.setPointerCapture(e.pointerId)});canvas.addEventListener('pointermove',e=>{if(!holding)return;yaw-=(e.clientX-lastX)*.004;pitch-=(e.clientY-lastY)*.003;pitch=Math.max(-1,Math.min(1,pitch));lastX=e.clientX;lastY=e.clientY});function release(){holding=false}canvas.addEventListener('pointerup',release);canvas.addEventListener('pointercancel',release);canvas.addEventListener('lostpointercapture',release);
function move(dx,dz){let p=camera.position;let nx=p.x+dx,nz=p.z+dz;for(const c of colliders){let d=Math.hypot(nx-c.x,nz-c.z),min=c.r+.7;if(d<min){if(d<.001){nx=c.x+min;nz=c.z}else{nx=c.x+(nx-c.x)*min/d;nz=c.z+(nz-c.z)*min/d}}}p.x=Math.max(-53,Math.min(53,nx));p.z=Math.max(-58,Math.min(38,nz))}
let clock=new T.Clock();function animate(){requestAnimationFrame(animate);let dt=Math.min(clock.getDelta(),.05),t=clock.elapsedTime;elapsed+=dt;if(demo){let cycle=elapsed%20;yaw=.35+Math.sin(cycle*.28)*.6;pitch=-.02+Math.sin(cycle*.31)*.13;move(-Math.sin(yaw)*dt*2.1,-Math.cos(yaw)*dt*2.1);if(cycle<dt)reset()}else if(holding){move(-Math.sin(yaw)*dt*3.4,-Math.cos(yaw)*dt*3.4);camera.position.y=Math.max(1.2,Math.min(17,camera.position.y+Math.sin(pitch)*dt*2.4))}camera.rotation.order='YXZ';camera.rotation.y=yaw;camera.rotation.x=pitch;
kelps.forEach(k=>{k.group.rotation.z=Math.sin(t*.65+k.phase)*.08;k.group.rotation.x=Math.sin(t*.5+k.phase)*.06});schools.forEach(s=>{let a=t*s.speed+s.phase;s.group.position.set(s.cx+Math.cos(a)*s.radius,s.y+Math.sin(a*.7),s.cz+Math.sin(a)*s.radius);s.group.rotation.y=-a-Math.PI/2});rays.forEach((r,i)=>{let a=t*.12+r.phase;r.group.position.set(Math.cos(a)*19,r.y+Math.sin(a*2)*.6,-20+Math.sin(a)*13);r.group.rotation.y=-a;r.wings.forEach((w,j)=>w.rotation.x=Math.sin(t*1.3+i)*.2*(j?1:-1))});bubbles.forEach(b=>{b.position.y+=dt*.55;if(b.position.y>23)b.position.y=0;b.position.x+=Math.sin(t+b.position.z)*dt*.025});particles.forEach(p=>{p.position.y+=dt*.025;if(p.position.y>23)p.position.y=0});caustics.forEach((c,i)=>{c.material.opacity=.06+.04*(1+Math.sin(t*.8+i))});let arr=surface.geometry.attributes.position.array;for(let i=0;i<arr.length;i+=3)arr[i+2]=surfaceBase[i+2]+Math.sin(arr[i]*.22+t)*.25+Math.cos(arr[i+1]*.18+t*.7)*.2;surface.geometry.attributes.position.needsUpdate=true;renderer.render(scene,camera)}animate();window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});
})();
</script></body></html>
