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="#063e4d">
<title>Kelp Garden</title>
<style>
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#073e4e;color:#f4efd4;font-family:Georgia,serif;touch-action:none}canvas{display:block;width:100%;height:100%}.overlay{position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,rgba(0,29,42,.35),transparent 22%,transparent 72%,rgba(0,28,35,.46))}.brand{position:absolute;top:25px;left:30px;text-shadow:0 2px 12px #003943}.eyebrow{font:600 10px/1.2 system-ui,sans-serif;letter-spacing:.28em;text-transform:uppercase;color:#b4ddd1}.brand h1{font-size:clamp(25px,4vw,38px);font-weight:400;letter-spacing:.02em;margin:7px 0 3px}.brand p{font:12px system-ui,sans-serif;letter-spacing:.08em;color:#d0e7d7;margin:0}.bottom{position:absolute;bottom:25px;left:30px;right:30px;display:flex;justify-content:space-between;align-items:end;gap:15px}.hint{font:12px/1.6 system-ui,sans-serif;color:#e2eee1;text-shadow:0 1px 6px #00303c}.hint strong{display:block;text-transform:uppercase;letter-spacing:.16em;font-size:10px;color:#a9d5c4}.controls{pointer-events:auto;display:flex;gap:8px}button{border:1px solid rgba(217,240,219,.45);background:rgba(4,55,62,.55);color:#f4efd4;border-radius:99px;padding:12px 17px;min-height:44px;font:600 11px system-ui,sans-serif;letter-spacing:.08em;cursor:pointer;backdrop-filter:blur(8px)}button:active{background:#36776c}.reticle{position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px;border:1px solid rgba(232,247,221,.75);border-radius:50%}.loading{position:absolute;inset:0;display:grid;place-items:center;background:#073e4e;font:12px system-ui;letter-spacing:.25em;text-transform:uppercase;transition:opacity 1s}.loading.hide{opacity:0;pointer-events:none}@media(max-width:600px){.brand{top:20px;left:20px}.bottom{left:20px;right:20px;bottom:20px}.hint{max-width:190px}.brand p{font-size:11px}button{padding:11px 14px}}
</style></head><body>
<div id="scene"></div><div class="overlay"><div class="brand"><div class="eyebrow">A little world beneath the waves</div><h1>Kelp Garden</h1><p>Take a breath. Wander slowly.</p></div><div class="reticle"></div><div class="bottom"><div class="hint"><strong>Explore at your own pace</strong><span id="hint">Press and hold to swim · drag to look around</span></div><div class="controls"><button id="reset">START AGAIN</button></div></div></div><div class="loading" id="loading">Descending into the blue</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></script>
<script>
(()=>{'use strict';
const host=document.getElementById('scene'), loading=document.getElementById('loading');
if(!window.THREE){loading.textContent='The ocean could not load. Please check your connection.';return}
const scene=new THREE.Scene();scene.background=new THREE.Color(0x176b7b);scene.fog=new THREE.FogExp2(0x176b7b,0.027);
const renderer=new THREE.WebGLRenderer({antialias:true,powerPreference:'high-performance'});renderer.setPixelRatio(Math.min(devicePixelRatio,1.6));renderer.setSize(innerWidth,innerHeight);renderer.outputColorSpace=THREE.SRGBColorSpace;renderer.toneMapping=THREE.ACESFilmicToneMapping;renderer.toneMappingExposure=1.1;host.appendChild(renderer.domElement);
const camera=new THREE.PerspectiveCamera(62,innerWidth/innerHeight,.1,160);camera.position.set(0,5,16);let yaw=0,pitch=-.06;
scene.add(new THREE.HemisphereLight(0x9ce7db,0x655d32,2));const sun=new THREE.DirectionalLight(0xffe8a8,2.4);sun.position.set(-15,30,8);scene.add(sun);
const mat=(color,extra={})=>new THREE.MeshStandardMaterial({color,roughness:.85,...extra});const sand=mat(0xc2aa6e),rock=mat(0x496e61),rock2=mat(0x365f5a),green=mat(0x387c4d,{side:THREE.DoubleSide}),green2=mat(0x719551,{side:THREE.DoubleSide}),wood=mat(0x745236),wood2=mat(0x9a7044),gold=mat(0xe6ae52),orange=mat(0xd67a3b),dark=mat(0x254c4b);
const mesh=(g,m,x=0,y=0,z=0,parent=scene)=>{let o=new THREE.Mesh(g,m);o.position.set(x,y,z);parent.add(o);return o};
const rng=(()=>{let s=872314;return()=>{s=(s*1664525+1013904223)>>>0;return s/4294967296}})();const rand=(a,b)=>a+(b-a)*rng();
let floor=mesh(new THREE.PlaneGeometry(220,220,80,80),sand,0,0,0);floor.rotation.x=-Math.PI/2;let fp=floor.geometry.attributes.position;for(let i=0;i<fp.count;i++){let x=fp.getX(i),y=fp.getY(i);fp.setZ(i,Math.sin(x*.33)*.13+Math.sin(y*.24+x*.16)*.15)}floor.geometry.computeVertexNormals();
const surface=mesh(new THREE.PlaneGeometry(200,200,50,50),new THREE.MeshBasicMaterial({color:0x82d5c9,transparent:true,opacity:.34,side:THREE.DoubleSide}),0,24,0);surface.rotation.x=Math.PI/2;const surfaceBase=surface.geometry.attributes.position.array.slice();
// Soft, slanting ribbons of sunlight, translucent from either side.
for(let i=0;i<9;i++){let beam=mesh(new THREE.ConeGeometry(rand(2,4),26,4,1,true),new THREE.MeshBasicMaterial({color:0xe5e8a0,transparent:true,opacity:.035,side:THREE.DoubleSide,depthWrite:false}),-24+i*7,12,-20-(i%3)*12);beam.rotation.z=-.34}
// Animated caustic flecks on the seafloor.
const glints=[];for(let i=0;i<110;i++){let o=mesh(new THREE.PlaneGeometry(rand(.6,2),rand(.08,.2)),new THREE.MeshBasicMaterial({color:0xffebac,transparent:true,opacity:.16,depthWrite:false}),rand(-43,43),.22,rand(-70,35));o.rotation.x=-Math.PI/2;o.rotation.z=rand(-1,1);glints.push(o)}
const colliders=[];function boulder(x,z,s){let o=mesh(new THREE.DodecahedronGeometry(1,1),rng()>.5?rock:rock2,x,s*.54,z);o.scale.set(s*rand(.8,1.3),s*.65,s*rand(.7,1.2));o.rotation.set(rand(0,2),rand(0,3),rand(0,2));colliders.push({x,z,r:s*1.15})}
for(let i=0;i<32;i++){let x=rand(-48,48),z=rand(-75,30);if(Math.hypot(x,z-12)<9||Math.hypot(x-13,z+22)<12||Math.hypot(x+13,z+14)<10)continue;boulder(x,z,rand(1,3))}
// Arch built from individual stone segments, with its opening left clear.
function arch(x,z,rot){let group=new THREE.Group();group.position.set(x,0,z);group.rotation.y=rot;scene.add(group);for(let i=0;i<=10;i++){let a=Math.PI*i/10;let xx=Math.cos(a)*5,yy=2+Math.sin(a)*5;let stone=mesh(new THREE.DodecahedronGeometry(1.3,1),i%2?rock:rock2,xx,yy,0,group);stone.scale.set(1.1,1.2,1.25);stone.rotation.z=a}for(let side of [-1,1]){for(let j=0;j<2;j++){let stone=mesh(new THREE.DodecahedronGeometry(1.4,1),rock2,side*5,1+j*1.25,0,group);stone.scale.set(1,.9,1)}let dx=Math.cos(rot)*side*5,dz=-Math.sin(rot)*side*5;colliders.push({x:x+dx,z:z+dz,r:1.8})}}
arch(-13,-14,.25);arch(24,-48,-.5);
// Wreck: an elongated wooden hull with ribs, deck, broken mast and a ragged sail.
const ship=new THREE.Group();ship.position.set(13,.4,-23);ship.rotation.y=-.35;scene.add(ship);let hull=mesh(new THREE.CylinderGeometry(2.4,1.15,11,8,1),wood,0,1.5,0,ship);hull.rotation.x=Math.PI/2;hull.scale.set(1,1,.7);for(let i=-5;i<=5;i++){let plank=mesh(new THREE.BoxGeometry(4.1,.18,.67),i%2?wood:wood2,0,2.55,i*.93,ship);plank.rotation.z=rand(-.03,.03)}for(let side of [-1,1]){let rail=mesh(new THREE.BoxGeometry(.22,.5,10),wood2,side*2,2.8,0,ship);rail.rotation.z=side*.09;for(let z=-4;z<=4;z+=2){let rib=mesh(new THREE.BoxGeometry(.22,1.4,.25),dark,side*1.9,2,z,ship);rib.rotation.z=-side*.3}}let mast=mesh(new THREE.CylinderGeometry(.13,.25,8,7),wood2,0,6.1,0,ship);mast.rotation.z=.22;let spar=mesh(new THREE.CylinderGeometry(.09,.1,5,6),wood2,.6,8,0,ship);spar.rotation.z=Math.PI/2+.2;let sail=mesh(new THREE.PlaneGeometry(3.4,3,1,1),new THREE.MeshStandardMaterial({color:0xc8ad78,transparent:true,opacity:.78,side:THREE.DoubleSide}),.6,6.4,0,ship);sail.rotation.z=-.12;colliders.push({x:13,z:-23,r:6.5});
// Kelp blades bend independently in the current.
const kelps=[];function kelp(x,z){let group=new THREE.Group();group.position.set(x,0,z);scene.add(group);let stems=3+Math.floor(rng()*4);for(let j=0;j<stems;j++){let h=rand(5,14),curve=new THREE.CatmullRomCurve3([new THREE.Vector3(0,0,0),new THREE.Vector3(rand(-.3,.3),h*.5,0),new THREE.Vector3(rand(-.8,.8),h,0)]);let stem=mesh(new THREE.TubeGeometry(curve,8,.045,4,false),green,rand(-.5,.5),0,rand(-.5,.5),group);for(let k=1;k<8;k++){let leaf=mesh(new THREE.SphereGeometry(1,6,4),rng()>.4?green:green2,(k%2?1:-1)*.38,h*k/8,0,stem);leaf.scale.set(.75,.12,.23);leaf.rotation.z=(k%2?1:-1)*.5}kelps.push({o:stem,phase:rand(0,6),speed:rand(.5,1),h})}}
for(let i=0;i<65;i++){let x=rand(-48,48),z=rand(-70,30);if(Math.hypot(x,z-16)<5)continue;kelp(x,z)}
// Small warm coral gardens.
for(let i=0;i<55;i++){let x=rand(-40,40),z=rand(-65,26),g=new THREE.Group();g.position.set(x,.25,z);scene.add(g);for(let j=0;j<4;j++){let c=mesh(new THREE.CylinderGeometry(.08,.18,rand(.6,1.5),6),rng()>.4?orange:gold,rand(-.5,.5),.5,rand(-.5,.5),g);c.rotation.z=rand(-.5,.5);let tip=mesh(new THREE.SphereGeometry(.18,7,5),c.material,0,.6,0,c)}}
// Schools share a smoothly changing heading and remain in formation.
const schools=[];function makeFish(color){let g=new THREE.Group();let body=mesh(new THREE.SphereGeometry(1,8,6),color,0,0,0,g);body.scale.set(.55,.22,.15);let tail=mesh(new THREE.ConeGeometry(.23,.4,3),color,-.58,0,0,g);tail.rotation.z=-Math.PI/2;return g}for(let s=0;s<5;s++){let group=new THREE.Group();scene.add(group);let fish=[];for(let i=0;i<13;i++){let f=makeFish(s%2?gold:orange);f.position.set(rand(-3,3),rand(-1,1),rand(-2,2));f.scale.setScalar(rand(.6,1.2));group.add(f);fish.push(f)}schools.push({group,fish,phase:rand(0,6),cx:rand(-25,25),cz:rand(-50,0),y:rand(5,13),radius:rand(5,10),speed:rand(.12,.23)})}
const rays=[];for(let i=0;i<3;i++){let g=new THREE.Group();let geo=new THREE.BufferGeometry();geo.setAttribute('position',new THREE.Float32BufferAttribute([0,0,1.1,-2.3,0,0,0,0,-1,0,0,1.1,0,0,-1,2.3,0,0],3));geo.computeVertexNormals();let wing=mesh(geo,mat(0x355e64,{side:THREE.DoubleSide}),0,0,0,g);let tail=mesh(new THREE.CylinderGeometry(.025,.05,2,5),dark,0,0,-1.5,g);tail.rotation.x=Math.PI/2;scene.add(g);rays.push({g,wing,phase:i*2.1})}
const bubbles=[];const bubblemat=new THREE.MeshBasicMaterial({color:0xc7f4dc,transparent:true,opacity:.35,wireframe:true,depthWrite:false});for(let i=0;i<75;i++){let b=mesh(new THREE.SphereGeometry(rand(.035,.12),7,5),bubblemat,rand(-35,35),rand(0,24),rand(-65,25));b.userData={baseX:b.position.x,baseZ:b.position.z,speed:rand(.4,1.3),phase:rand(0,6)};bubbles.push(b)}
let held=false,lastX=0,lastY=0,demo=location.hash==='#demo',demoStart=performance.now(),last=performance.now();const hint=document.getElementById('hint');if(demo)hint.textContent='A hands-free journey · touch to take over';
function stopDemo(){if(demo){demo=false;hint.textContent='Press and hold to swim · drag to look around'}}
renderer.domElement.addEventListener('pointerdown',e=>{stopDemo();held=true;lastX=e.clientX;lastY=e.clientY;renderer.domElement.setPointerCapture(e.pointerId)});renderer.domElement.addEventListener('pointermove',e=>{if(!held)return;let dx=e.clientX-lastX,dy=e.clientY-lastY;yaw-=dx*.004;pitch=Math.max(-.8,Math.min(.65,pitch-dy*.003));lastX=e.clientX;lastY=e.clientY});for(const name of ['pointerup','pointercancel','lostpointercapture'])renderer.domElement.addEventListener(name,()=>held=false);
document.getElementById('reset').addEventListener('click',()=>{stopDemo();camera.position.set(0,5,16);yaw=0;pitch=-.06});
function move(dist){let nx=camera.position.x-Math.sin(yaw)*Math.cos(pitch)*dist,nz=camera.position.z-Math.cos(yaw)*Math.cos(pitch)*dist,ny=THREE.MathUtils.clamp(camera.position.y+Math.sin(pitch)*dist,1.4,20);nx=THREE.MathUtils.clamp(nx,-48,48);nz=THREE.MathUtils.clamp(nz,-75,32);let blocked=colliders.some(c=>Math.hypot(nx-c.x,nz-c.z)<c.r+.8);if(!blocked){camera.position.x=nx;camera.position.z=nz}camera.position.y=ny}
function animate(now){requestAnimationFrame(animate);let t=now*.001,dt=Math.min((now-last)/1000,.05);last=now;if(demo){let u=((now-demoStart)/1000)%20;camera.position.set(Math.sin(u*.27)*9,6+Math.sin(u*.4),12-u*1.3);yaw=.18+Math.sin(u*.35)*.55;pitch=-.05+Math.sin(u*.3)*.12}else if(held)move(dt*4);camera.rotation.order='YXZ';camera.rotation.y=yaw;camera.rotation.x=pitch;
for(const k of kelps){k.o.rotation.z=Math.sin(t*k.speed+k.phase)*.09;k.o.rotation.x=Math.cos(t*.6+k.phase)*.07}for(const s of schools){let a=t*s.speed+s.phase;s.group.position.set(s.cx+Math.cos(a)*s.radius,s.y+Math.sin(a*1.3),s.cz+Math.sin(a)*s.radius);s.group.rotation.y=-a-Math.PI/2;s.fish.forEach((f,i)=>{f.rotation.y=Math.sin(t*8+i)*.15})}rays.forEach((r,i)=>{let a=t*.11+r.phase;r.g.position.set(Math.cos(a)*25,11+i*2+Math.sin(a*2),-25+Math.sin(a)*22);r.g.rotation.y=-a;r.wing.rotation.z=Math.sin(t*2+i)*.12});bubbles.forEach(b=>{b.position.y+=b.userData.speed*dt;if(b.position.y>23)b.position.y=0;b.position.x=b.userData.baseX+Math.sin(t+b.userData.phase)*.3});glints.forEach((g,i)=>{g.material.opacity=.08+.12*(.5+.5*Math.sin(t*1.4+i))});let sp=surface.geometry.attributes.position;for(let i=0;i<sp.count;i++){let x=surfaceBase[i*3],y=surfaceBase[i*3+1];sp.setZ(i,Math.sin(x*.25+t*.7)*.3+Math.cos(y*.2+t*.5)*.25)}sp.needsUpdate=true;renderer.render(scene,camera)}
window.addEventListener('resize',()=>{camera.aspect=innerWidth/innerHeight;camera.updateProjectionMatrix();renderer.setSize(innerWidth,innerHeight)});requestAnimationFrame(animate);loading.classList.add('hide');
})();
</script></body></html>
