<!-- SOLID-PLAYTIME · part 168 -->
this.last,this.raf=requestAnimationFrame(this.loop)};constructor(t,e,n){this.mount=t,this.onEvent=n,this.x=e.x,this.z=e.z,this.mobile=window.matchMedia("(max-width: 820px), (pointer: coarse)").matches,this.basePixelRatio=Math.min(window.devicePixelRatio||1,this.mobile?1.16:1.55),this.renderer=new $c({antialias:!this.mobile,powerPreference:"high-performance",alpha:!0}),this.renderer.setClearColor(0,0),this.renderer.setPixelRatio(this.basePixelRatio),this.renderer.outputColorSpace=Hs,this.renderer.toneMapping=Vo,this.renderer.toneMappingExposure=1.06,this.renderer.domElement.className="world-canvas",this.renderer.domElement.setAttribute("aria-label","Free-roam nightmare islands lobby"),t.appendChild(this.renderer.domElement),this.buildWorld(e.color,e.isKing,this.mobile),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(t),this.resize(),this.renderer.render(this.scene,this.camera),this.loop=this.loop.bind(this),document.addEventListener("visibilitychange",this.onVisibilityChange),t.addEventListener("pointermove",this.onTrackMove),t.addEventListener("pointerdown",this.onTapDown),t.addEventListener("pointerup",this.onTapUp),this.qualityWindowStart=performance.now(),this.raf=requestAnimationFrame(this.loop)}ground(t,e){let n=Math.sin(t*0.021)*3.7+Math.cos(e*0.018)*3.2+Math.sin((t-e)*0.009)*2.4,i=Math.max(-22,16-Math.hypot(t-5,e-158)*0.082),s=Math.max(-22,14-Math.hypot(t+92,e-12)*0.072),a=Math.max(-22,15-Math.hypot(t-82,e+126)*0.07),r=Math.max(-22,20-Math.hypot(t+246,e+210)*0.075),o=Math.max(-22,12-Math.hypot(t-278,e-92)*0.064),l=Math.max(-22,17-Math.hypot(t-238,e+286)*0.07),c=Math.max(-22,14-Math.hypot(t+300,e-205)*0.068),u=6-Math.abs(t+e*0.44)*0.02,f=3.8-Math.abs(t-52-(e+45)*0.72)*0.014;return Math.max(n,i,s,a,r,o,l,c,u,f)}glow(t,e=0.82){return new Pn({color:t,transparent:!0,opacity:e,blending:Ye,depthWrite:!1,side:hn})}buildWorld(t,e,n){this.scene.background=new Xt(16766720),this.scene.fog=new dr(394257,0.0031),this.scene.add(new jo(7755119,1049095,1.08));let i=new tl(16764007,2.15);i.position.set(-110,190,90),this.scene.add(i);let s=new On(65535,48,210);s.position.set(-70,36,76),this.scene.add(s);let a=new On(16711901,42,210);a.position.set(90,30,-118),this.scene.add(a),[{z:112,color:4526881,opacity:0.035},{z:24,color:2951962,opacity:0.055},{z:-76,color:1508882,opacity:0.075}].forEach((z,j)=>{let ft=new At(new qn(420,190),new Pn({color:z.color,transparent:!0,opacity:z.opacity,depthWrite:!1,side:hn}));ft.position.set(8,72+j*5,z.z),this.scene.add(ft),this.distantLayers.push(ft)});let o=new qn(920,920,n?42:72,n?42:72),l=o.getAttribute("position"),c=[];for(let z=0;z<l.count;z+=1){let j=l.getX(z),ft=-l.getY(z),K=this.ground(j,ft);l.setZ(z,K);let rt=Math.max(0,Math.min(1,(K+18)/36));c.push(0.006+rt*0.018,0.009+rt*0.02,0.025+rt*0.055)}o.setAttribute("color",new Zt(c,3)),o.computeVertexNormals();let u=new At(o,new Pe({vertexColors:!0,roughness:0.86,metalness:0.38,emissive:131850,emissiveIntensity:0.45}));u.rotation.x=-Math.PI/2,this.scene.add(u);let f=new he;for(let z=-5;z<=5;z+=1){let j=[];for(let K=-430;K<=430;K+=12){let rt=K,_t=z*36+Math.sin(K*0.018+z)*18;j.push(new C(rt,this.ground(rt,_t)+0.18,_t))}let ft=new Ta(new me().setFromPoints(j),new Sn({color:z%3===0?16725471:z%2===0?4191999:16766573,transparent:!0,opacity:z%2?0.22:0.36}));f.add(ft)}for(let z=-4;z<=4;z+=1){let j=[];for(let ft=-430;ft<=430;ft+=12){let K=ft,rt=z*46+Math.cos(ft*0.015-z)*14;j.push(new C(rt,this.ground(rt,K)+0.2,K))}f.add(new Ta(new me().setFromPoints(j),new Sn({color:15251015,transparent:!0,opacity:0.23})))}this.scene.add(f);let h=new me,p=[],v=n?320:820;for(let z=0;z<v;z+=1){let j=270+Math.random()*160,ft=Math.random()*Math.PI*2;p.push(Math.cos(ft)*j,45+Math.random()*250,Math.sin(ft)*j)}h.setAttribute("position",new Zt(p,3)),this.scene.add(new ts(h,new Bs({color:16774856,size:0.85,transparent:!0,opacity:0.78,blending:Ye,depthWrite:!1,map:window._roundStarTex}))),this.buildLivingStorm(n),this.buildBurningCastle(n),this.buildDistantWorld(n),this.buildEmbers(n),this.portals.push(this.buildPortal("ENTRANCE",Jc.x,Jc.y,16765803)),this.portals.push(this.buildPortal("RETURN",eg.x,eg.y,7665151)),this.portals.push(this.buildPortal("ONWARD",tg.x,tg.y,16728799)),this.buildContinuumMonument();let y=new Xt(t),U=new Vf,d=(z,j=!1)=>{let ft=U.load(G3[z]);return ft.colorSpace=Hs,new Pn({color:j?16761933:16777215,map:ft,transparent:!0,opacity:j?0.18:0.08,blending:Ye,depthWrite:!1,side:hn})},g=(z,j)=>(j.name=z,this.kingParts[z]=j,this.hero.add(j),j),m=e?new Xt(14787116):y,x=e?new Xt(16764500):y.clone().offsetHSL(0,-0.04,0.14),S=e?new Xt(7356429):y.clone().offsetHSL(0,0,-0.22),A=new Pe({color:m,emissive:S,emissiveIntensity:0.72,metalness:0.78,roughness:0.24}),T=new Pe({color:x,emissive:m,emissiveIntensity:0.82,metalness:0.86,roughness:0.2}),w=new Pe({color:S,emissive:S,emissiveIntensity:0.38,metalness:0.72,roughness:0.3}),b=new At(new dn(0.78,n?12:18,n?9:14),A);b.position.y=2.05,b.scale.set