Deck.transition('portal-in',{dur:1.25,frag:`void main(){ vec2 q=vUv-.5; float k=p*p*(3.-2.*p); float edge=max(abs(q.x),abs(q.y)); float m=1.-smoothstep(.51*k-.012,.51*k,edge); vec3 a=texture(tA,.5+q/(1.+.42*k)).rgb; vec3 b=texture(tB,clamp(.5+q/max(k,.001),0.,1.)).rgb; o=vec4(mix(a,b,m),1.); }`}); Deck.scene({ id:'pile',title:'You are here',enterWith:'portal-in', post:{tone:'none',grain:.012}, beats:[{dur:11.5,hold:4},{dur:4.5,hold:5}], notes:['That was the whole talk, on one curve. Now we go back down it. (Wait for the ride to stop.) This is today.', 'Look up. Everything in this talk is in that wall, and the wall starts a few steps in front of us. From down here it still looks flat. That is what the bottom of an exponential looks like.'], setup(d){ const yy=[],zz=[],N=640,lo=-8; let y=.023,z=-8; for(let i=0;i<=N;i++){ yy.push(y);zz.push(z); const a=Math.atan(Math.exp((lo+(i+.5)/16-4.35)*.92)); y+=Math.sin(a)/16;z+=Math.cos(a)/16; } const lookup=(arr,t)=>{const n=Math.max(0,Math.min(N-.001,(t-lo)*16)),i=Math.floor(n);return arr[i]+(arr[i+1]-arr[i])*(n-i)}; const U={eye:[0,0,0],ang:0,cx:960,foc:1080}; const pt={x:0,y:0,z:0}; function project(x,y,z){ let dy=y-U.eye[1],dz=z-U.eye[2],sn=Math.sin(U.ang),cs=Math.cos(U.ang); pt.z=dy*sn+dz*cs; pt.x=U.cx+(x-U.eye[0])*U.foc/Math.max(.04,pt.z); pt.y=540-(dy*cs-dz*sn)*U.foc/Math.max(.04,pt.z);return pt; } const paper=(x,t)=>project(x,lookup(yy,t),lookup(zz,t)); const cols=['#f3f3ef','#f8ba83','#536878','#efcf92','#162636','#7b9993','#ded8cc','#342a30','#112c48','#cbbaa0','#92c1b8']; return {U,project,paper,cols,Y:t=>lookup(yy,t),Z:t=>lookup(zz,t), date:new Intl.DateTimeFormat('en-GB',{day:'numeric',month:'long',year:'numeric'}).format(new Date()), bg:d.pass(`uniform vec3 eye; uniform float ang,cx,foc; void main(){ vec2 q=design(vUv); vec2 uv=(q-vec2(cx,540.))*vec2(1.,-1.)/foc; vec3 ray=normalize(vec3(uv.x,sin(ang)+uv.y*cos(ang),cos(ang)-uv.y*sin(ang))); float h=ray.y; vec3 haze=vec3(.84,.905,.936); vec3 c=mix(haze,vec3(.12,.48,.83),smoothstep(-.04,.68,h)); if(h>0.){ vec2 sky=ray.xz/(h+.16); float n=fbm(sky*1.9+vec2(uTime*.009,3.1)); float shelter=(1.-smoothstep(600.,1100.,q.x))*(1.-smoothstep(380.,820.,q.y))*smoothstep(.02,.16,h); c=mix(c,vec3(.075,.305,.535),.92*shelter); float cl=smoothstep(.48,.78,n)*smoothstep(.01,.14,h)*(1.-.96*shelter); c=mix(c,mix(vec3(.77,.85,.9),vec3(.99,.985,.96),smoothstep(.55,.72,n)),cl*.85); }else{ float t=eye.y/max(.0001,-h); vec2 g=eye.xz+t*ray.xz; float sh=exp(-pow(max(abs(g.x-.14)-.88,0.)*2.8,2.))*(1.-smoothstep(3.8,6.8,g.y)); float refl=exp(-pow((g.x+.05)*.9,2.))*exp(-abs(g.y-4.8)*.22); vec3 floorCol=mix(vec3(.83,.885,.905),vec3(.64,.80,.89),smoothstep(.02,.6,1.+h)); c=mix(floorCol-sh*vec3(.20,.18,.15)-refl*vec3(.09,.05,.035),haze,1.-exp(-t*.034)); c+=(vnoise(g*vec2(6.,21.))-.5)*.015*exp(-t*.09); } o=vec4(c,1.); }`,'sky and pearl floor')}; }, draw(s,d,r){ const ride=s.k(0,.25,10.4),up=s.k(1,0,4.5),at=10-11*ride+4.1*up; const tangent=Math.atan(Math.exp((at-4.35)*.92)); const a=tangent-Math.PI/2+.47*ride+.97*up; const dist=1.18+1.65*ride-1.46*up; const U=r.U; U.ang=a;U.cx=960+326*ride+4*s.mouse.x;U.foc=1060; U.eye[0]=.03*s.mouse.x+.045*Math.sin(s.t*.19)*ride; U.eye[1]=r.Y(at)-dist*Math.sin(a)+.54*up; U.eye[2]=r.Z(at)-dist*Math.cos(a); r.bg.draw(U); const c=d.ctx2d; c.save(); function poly(t,pts,col){ c.beginPath();let behind=true; for(let j=0;j.055)behind=false; if(j===0)c.moveTo(p.x,p.y);else c.lineTo(p.x,p.y); } if(!behind){c.closePath();c.fillStyle=col;c.fill();} } function box(t,x,b,w,h,col){poly(t,[x,b,x+w,b,x+w,b+h,x,b+h],col)} function disc(t,x,b,rad,col){ c.beginPath(); for(let j=0;j<=32;j++){let a=j*Math.PI/16,p=r.paper(x+rad*Math.cos(a),t+b+rad*Math.sin(a));if(p.z<.06)return;if(j)c.lineTo(p.x,p.y);else c.moveTo(p.x,p.y)} c.fillStyle=col;c.fill(); } for(let i=29;i>=-7;i--){ if(r.paper(0,i+.54).z<.05&&r.paper(0,i-.54).z<.05)continue; box(i,-.968,-.506,1.936,1.012,'#99acaf'); box(i,-.96,-.502,1.92,1.004,'#f4f2e9'); const ink=i>=0&&i<11; box(i,-.875,-.484,1.75,.968,ink?r.cols[i]:'#ced5d2'); if(!ink){box(i,-.866,-.475,1.732,.95,'#eeefe9');continue} if(i===0){ box(i,-.445,.02,.89,.038,'#374554');box(i,-.25,-.072,.5,.019,'#9ba5a8');box(i,-.875,-.484,1.75,.035,'#5680b8'); }else if(i===10){ for(let j=0;j<2;j++){ let x=-.875+j*.875; box(i,x,-.484,.875,.968,j?'#a8cfc9':'#d4b396'); disc(i,x+.59,.24,.079,j?'#fff2ca':'#e4c1a1'); poly(i,[x,-.13,x+.21,.06,x+.35,-.023,x+.59,.13,x+.875,-.06,x+.875,-.48,x,-.48],j?'#5c8781':'#8a7877'); poly(i,[x,-.24,x+.28,-.17,x+.54,-.23,x+.875,-.12,x+.875,-.48,x,-.48],j?'#385c53':'#635859'); } box(i,-.004,-.48,.008,.96,'#478aea');disc(i,0,0,.018,'#bfe4ff'); }else if(i===1||i===5){ box(i,-.875,-.484,1.75,.31,i===1?'#dfb99a':'#68857e'); for(let j=0;j<9;j++)box(i,-.64+j*.15,-.18,.083,.035*Math.exp(j*.34),i===1?'#81584b':'#f0dec0'); }else if(i===2){ box(i,-.875,-.484,1.75,.5,'#233e54');poly(i,[-.28,-.06,.32,-.06,.17,-.17,-.16,-.17],'#151f2a');poly(i,[0,-.04,0,.29,.23,-.04],'#dbd2b8'); }else if(i===3||i===8){ disc(i,.14,.01,.34,i===3?'#ba4533':'#5185a6');disc(i,.14,.01,.21,i===3?r.cols[i]:'#497773'); }else if(i===4){ for(let j=0;j<56;j++)box(i,-.76+(j%8)*.2,-.39+Math.floor(j/8)*.115,.12,.043,j%5?'#d39e58':'#344253'); }else if(i===6){ box(i,-.34,-.32,.68,.67,'#fffaf1');box(i,-.34,.22,.68,.13,'#b85243'); for(let j=0;j<15;j++)box(i,-.25+j%5*.11,-.2+Math.floor(j/5)*.135,.06,.06,'#b2ada6'); }else if(i===7){ disc(i,0,.01,.22,'#8d5540');disc(i,0,.01,.11,'#f5bb65');box(i,-.15,-.26,.3,.07,'#a78063'); }else{box(i,-.42,-.26,.84,.52,'#ece3d1');poly(i,[-.35,-.02,.37,.055,.37,.067,-.35,-.008],'#576878')} } for(let j=0;j<14;j++){ const ph=j*2.39+s.t*.19, x=(j%2?1:-1)*(1.55+.43*(j%5))+.16*Math.sin(ph); const p=r.project(x,1.14+j*.54+.17*Math.sin(ph*.8),3.3+Math.sin(j*5.2)*2); if(p.z<.6)continue; let w=U.foc*.24/p.z,h=w*(.09+.42*Math.abs(Math.cos(ph))); const clear=Math.max(p.x-1.4*w-820,p.y-1.4*w-460); const alpha=Math.min(1,Math.max(0,clear/100)); if(alpha===0)continue; c.save();c.globalAlpha=alpha;c.translate(p.x,p.y);c.rotate(.51*Math.sin(ph)); c.fillStyle='#f8f6eb';c.beginPath();c.moveTo(-w,-h);c.quadraticCurveTo(0,-h*.3,w,-h*.8);c.lineTo(w*.89,h);c.quadraticCurveTo(0,h*1.5,-w,h*.55);c.fill();c.restore(); } c.restore(); const sel=s.k(0,10,10.8)*(1-s.k(1,0,.55)); if(sel>.001){ const left=r.paper(-.9,-1.49).x,right=r.paper(.9,-1.49).x,top=r.paper(0,-.51).y,bot=r.paper(0,-1.49).y; d.select(left,top,right-left,bot-top,{a:sel}); } const hide=s.k(1,0,.55); d.text('You are here.',{x:134,y:435,size:100,font:'display',color:'#142e48',show:s.k(0,9.7,10.8),hide}); d.text(r.date,{x:140,y:569,size:32,font:'mono',color:'#415970',show:s.k(0,10.6,11.5),hide}); d.text('This is\nthe flat part.',{x:134,y:127,size:106,font:'display',color:'#ffffff',show:s.k(1,.9,2.1)}); } });