PageSourceSearch

https://aorum.io/_next/static/chunks/510.0364c5b4d6ea6581.js

js aorum.io collected 2026-10-06 13:38:30 UTC 68,610 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[510],{5510:function(e,t,r){r.r(t),r.d(t,{default:function(){return $}});var n=r(7437),o=r(2265),i=r(9285),a=r(1448),s=r(5550),l=r(697),c=r(782),u=r(3281),d=r(8328),f=r(4637),h=r(6538);let m="undefined"!=typeof navigator&&/iPhone|iPad|Android/i.test(navigator.userAgent),v={MAX_PARTICLES:m?80:200,SHADOW_MAP_SIZE:m?256:512};var p=r(2885);new a.Vector3;class g{setCollisionMask(e){this.collisionMask=e}isBlockedByMask(e,t){if(!this.collisionMask)return!1;let r=(0,p.Ul)(e),n=(0,p.Ul)(t);return!(r<0)&&!(r>=p.Zq)&&!(n<0)&&!(n>=p.Zq)&&this.collisionMask[n*p.Zq+r]>128}addObstacle(e){this.obstacles.push(e)}addTrigger(e){this.triggers.push(e)}resolvePosition(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(Math.sqrt(e.x*e.x+e.z*e.z)>this.worldRadius){let t=Math.atan2(e.z,e.x);e.x=Math.cos(t)*this.worldRadius,e.z=Math.sin(t)*this.worldRadius}for(let r of(this.isBlockedByMask(e.x,e.z)&&t&&(this.isBlockedByMask(e.x,t.z)?this.isBlockedByMask(t.x,e.z)?(e.x=t.x,e.z=t.z):e.x=t.x:e.z=t.z),this.obstacles))"box"===r.type?this.resolveBox(e,r):this.resolveCylinder(e,r);return e}resolveCylinder(e,t){let[r,n]=t.center,o=e.x-r,i=e.z-n;if(Math.sqrt(o*o+i*i)<t.radius){let a=Math.atan2(i,o);e.x=r+Math.cos(a)*t.radius,e.z=n+Math.sin(a)*t.radius}}resolveBox(e,t){let{center:r,size:n,rotation:o=0}=t,[i,a]=r,[s,l]=[n[0]/2,n[1]/2],c=Math.cos(-o),u=Math.sin(-o),d=(e.x-i)*c-(e.z-a)*u,f=(e.x-i)*u+(e.z-a)*c;if(Math.abs(d)<s&&Math.abs(f)<l){let t=s-Math.abs(d),r=l-Math.abs(f),n=0,i=0;t<r?n=t*Math.sign(d):i=r*Math.sign(f);let a=n*Math.cos(o)-i*Math.sin(o),c=n*Math.sin(o)+i*Math.cos(o);e.x+=a,e.z+=c}}checkTriggers(e){let t=[];for(let r of this.triggers){let[n,o]=r.center,i=e.x-n,a=e.z-o,s=Math.sqrt(i*i+a*a);s<r.radius&&t.push({...r,distance:s,proximity:1-s/r.radius})}return t}getDistanceFromCenter(e){return Math.sqrt(e.x*e.x+e.z*e.z)}getNormalizedDistance(e){return this.getDistanceFromCenter(e)/this.worldRadius}constructor(e,t=[]){this.worldRadius=e,this.obstacles=t,this.triggers=[],this.collisionMask=null}}var x=r(7588),y=r(6434),w=r(8994),M=r(1106);let b={uniforms:{time:{value:0},baseTexture:{value:null},hasTexture:{value:0},glowColor1:{value:new a.Color(6324479)},glowColor2:{value:new a.Color(16736416)},pulseIntensity:{value:1}},vertexShader:"\n    #include <fog_pars_vertex>\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n    varying vec3 vViewPosition;\n\n    uniform float time;\n\n    void main() {\n      vUv = uv;\n      vNormal = normalize(mat3(modelMatrix) * normal);\n\n      vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n      vWorldPosition = worldPosition.xyz;\n\n      vec4 mvPosition = viewMatrix * worldPosition;\n      vViewPosition = -mvPosition.xyz;\n\n      gl_Position = projectionMatrix * mvPosition;\n      #include <fog_vertex>\n    }\n  ",fragmentShader:"\n    precision highp float;\n    #include <fog_pars_fragment>\n\n    varying vec2 vUv;\n    varying vec3 vNormal;\n    varying vec3 vWorldPosition;\n    varying vec3 vViewPosition;\n\n    uniform float time;\n    uniform sampler2D baseTexture;\n    uniform float hasTexture;\n    uniform vec3 glowColor1;\n    uniform vec3 glowColor2;\n    uniform float pulseIntensity;\n\n    void main() {\n      vec3 baseColor = vec3(0.7, 0.7, 0.8);\n\n      if (hasTexture > 0.5) {\n        baseColor = texture2D(baseTexture, vUv).rgb;\n        baseColor = pow(baseColor, vec3(0.85));\n      }\n\n      vec3 normal = normalize(vNormal);\n      vec3 viewDir = normalize(cameraPosition - vWorldPosition);\n\n      // -- Directional lighting (additive, doesn't darken base) --\n      vec3 lightDir = normalize(vec3(10.0, 20.0, -8.0));\n      vec3 lightColor = vec3(0.85, 0.82, 1.0);\n      float NdotL = max(dot(normal, lightDir), 0.0);\n      float diffuse = NdotL * 0.5 + 0.5;\n\n      vec3 fillDir = normalize(vec3(-5.0, 3.0, 8.0));\n      float fillDiffuse = max(dot(normal, fillDir), 0.0) * 0.25;\n\n      // Subtle additive light — just enough for directional depth\n      vec3 lighting = lightColor * diffuse * 0.08 + vec3(0.5, 0.5, 0.7) * fillDiffuse * 0.08;\n\n      // -- Specular (Blinn-Phong) --\n      vec3 halfVec = normalize(lightDir + viewDir);\n      float spec = pow(max(dot(normal, halfVec), 0.0), 32.0);\n      vec3 specular = lightColor * spec * 0.25;\n\n      // -- Fresnel --\n      float fresnel = 1.0 - max(dot(viewDir, normal), 0.0);\n      fresnel = pow(fresnel, 2.0);\n      fresnel = smoothstep(0.0, 1.0, fresnel);\n\n      float gradientMix = sin(vWorldPosition.y * 0.5 + time * 0.5) * 0.5 + 0.5;\n      vec3 glowColor = mix(glowColor1, glowColor2, gradientMix);\n\n      vec3 finalColor = baseColor + lighting + specular;\n      finalColor = mix(finalColor, glowColor, fresnel * 0.6);\n      finalColor += glowColor * fresnel * pulseIntensity * 0.5;\n      finalColor = max(finalColor, vec3(0.1));\n\n      // Darken bottom of mesh to blend with ground\n      float groundFade = smoothstep(0.0, 4.0, vWorldPosition.y);\n      finalColor *= mix(0.08, 1.0, groundFade);\n\n      gl_FragColor = vec4(finalColor, 1.0);\n      #include <fog_fragment>\n    }\n  "},C="undefined"!=typeof navigator&&/iPhone|iPad|Android/i.test(navigator.userAgent)?"/room-mobile.glb":"/room-compressed.glb";function j(e){let t=(0,o.useRef)(),{scene:r}=(0,M.L)(C),{gl:s}=(0,i.D)(),l=(0,o.useRef)([]);return(0,o.useEffect)(()=>(r.traverse(e=>{if(e.isMesh&&e.material)try{let t=e.material,r=t.map?1:0,n=new a.ShaderMaterial({fog:!0,uniforms:{...a.UniformsUtils.clone(a.UniformsLib.fog),time:{value:0},baseTexture:{value:t.map||null},hasTexture:{value:r},glowColor1:{value:new a.Color(6324479)},glowColor2:{value:new a.Color(16736416)},pulseIntensity:{value:1}},vertexShader:b.vertexShader,fragmentShader:b.fragmentShader,side:a.DoubleSide});l.current.push(n),e.material=n,t.dispose(),e.castShadow=!0,e.receiveShadow=!0}
1catch(r){let t=new a.MeshStandardMaterial({color:8421504,emissive:4210752,emissiveIntensity:.5});e.material=t}}),()=>{l.current.forEach(e=>{e.dispose&&e.dispose()}),l.current=[]}),[r]),(0,o.useEffect)(()=>{let e=new Set;r.traverse(t=>{var r,n,o;t.isMesh&&(null===(o=t.material)||void 0===o?void 0:null===(n=o.uniforms)||void 0===n?void 0:null===(r=n.baseTexture)||void 0===r?void 0:r.value)&&e.add(t.material.uniforms.baseTexture.value)}),e.forEach(e=>{e.image&&(s.initTexture(e),e.source.data={width:e.image.width,height:e.image.height})})},[r,s]),(0,i.F)(e=>{let{clock:t}=e,r=t.getElapsedTime();l.current.forEach(e=>{e.uniforms&&(e.uniforms.time.value=r,e.uniforms.pulseIntensity.value=.85+.15*Math.sin(2*r))})}),(0,n.jsx)("primitive",{ref:t,object:r,...e})}var S=r(1538);function A(e){let{position:t,scale:r=1,floatIntensity:s=2,collisionRadius:l=1,glowColor:c="#ff6b6b",useSharedLight:d=!1}=e,f=(0,o.useRef)(),h=(0,o.useMemo)(()=>new a.ShaderMaterial({vertexShader:"\nvarying vec3 vNormal;\nvarying vec3 vViewDir;\nvarying vec3 vWorldPos;\nvarying vec3 vObjPos;\n\nvoid main() {\n  vObjPos = position;\n  vNormal = normalize(normalMatrix * normal);\n  vec4 worldPos = modelMatrix * vec4(position, 1.0);\n  vWorldPos = worldPos.xyz;\n  vViewDir = normalize(cameraPosition - worldPos.xyz);\n  gl_Position = projectionMatrix * viewMatrix * worldPos;\n}\n",fragmentShader:"\nuniform float time;\nuniform vec3 glowCol;\n\nvarying vec3 vNormal;\nvarying vec3 vViewDir;\nvarying vec3 vWorldPos;\nvarying vec3 vObjPos;\n\n// Noise for cutout holes\nvec3 m289(vec3 x){ return x - floor(x * (1.0/289.0)) * 289.0; }\nvec4 m289(vec4 x){ return x - floor(x * (1.0/289.0)) * 289.0; }\nvec4 pm(vec4 x){ return m289(((x * 34.0) + 1.0) * x); }\nfloat n3d(vec3 p){\n  vec3 a = floor(p), d = p - a;\n  d = d * d * (3.0 - 2.0 * d);\n  vec4 b = a.xxyy + vec4(0,1,0,1);\n  vec4 k1 = pm(b.xyxy), k2 = pm(k1.xyxy + b.zzww);\n  vec4 c = k2 + a.zzzz, k3 = pm(c), k4 = pm(c + 1.0);\n  vec4 o1 = fract(k3/41.0), o2 = fract(k4/41.0);\n  vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);\n  vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);\n  return o4.y * d.y + o4.x * (1.0 - d.y);\n}\n\nvoid main() {\n  // Cutout holes\n  vec3 sn = normalize(vObjPos);\n  float th = atan(sn.z, sn.x), ph = acos(sn.y);\n  vec3 np = vec3(th * 1.5, ph * 2.5, 0.5);\n  float p = n3d(np * 2.0) * 0.45 + n3d(np * 4.0 + 3.7) * 0.35 + n3d(sn * 5.0 + 1.3) * 0.2;\n  if (p < 0.45) discard;\n\n  // Edge glow — fragments near the cutout threshold get bright emission\n  float edgeDist = smoothstep(0.45, 0.52, p);\n  float edgeGlow = 1.0 - edgeDist; // 1.0 at edge, 0.0 away from edge\n\n  vec3 normal = normalize(vNormal);\n  vec3 viewDir = normalize(vViewDir);\n\n  // Fresnel — strong rim glow\n  float fresnel = 1.0 - max(dot(viewDir, normal), 0.0);\n  fresnel = pow(fresnel, 2.0);\n  fresnel = smoothstep(0.0, 1.0, fresnel);\n\n  // Fake chrome reflection — use normal to create color variation\n  vec3 reflected = reflect(-viewDir, normal);\n  float envFake = reflected.y * 0.5 + 0.5; // vertical gradient as fake environment\n  float envShift = sin(reflected.x * 3.0 + time * 0.3) * 0.15 + 0.5;\n\n  // Chrome base — dark with specular highlights\n  vec3 chromeBase = vec3(0.12, 0.12, 0.14);\n  vec3 chromeHighlight = vec3(0.7, 0.75, 0.85);\n  vec3 chrome = mix(chromeBase, chromeHighlight, pow(envFake, 3.0) * 0.6 + pow(envShift, 4.0) * 0.4);\n\n  // Specular highlights — fake directional lights\n  vec3 lightDir1 = normalize(vec3(5.0, 8.0, 3.0));\n  vec3 lightDir2 = normalize(vec3(-3.0, 5.0, -5.0));\n  float spec1 = pow(max(dot(reflect(-lightDir1, normal), viewDir), 0.0), 64.0);\n  float spec2 = pow(max(dot(reflect(-lightDir2, normal), viewDir), 0.0), 32.0);\n  chrome += vec3(1.0, 1.0, 1.0) * spec1 * 0.8;\n  chrome += vec3(0.5, 0.55, 1.0) * spec2 * 0.5;\n\n  // Glow color gradient matching scene aesthetic (blue → orb color)\n  vec3 glowBlue = vec3(0.375, 0.5, 1.0); // #6080ff\n  float gradientT = sin(vWorldPos.y * 0.5 + time * 0.5) * 0.5 + 0.5;\n  vec3 glow = mix(glowBlue, glowCol, gradientT);\n\n  // Pulse\n  float pulse = 0.85 + sin(time * 2.0) * 0.15;\n\n  // Combine: chrome base + fresnel glow\n  vec3 finalColor = chrome + glow * fresnel * 0.6 * pulse;\n\n  // Subtle emissive from orb color\n  finalColor += glowCol * 0.05;\n\n  // Hot edge glow at cutout boundaries\n  finalColor += glowCol * edgeGlow * 1.5 + vec3(1.0) * edgeGlow * 0.3;\n\n  gl_FragColor = vec4(finalColor, 1.0);\n}\n",uniforms:{time:{value:0},glowCol:{value:new a.Color(c)}},side:a.DoubleSide}),[c]);(0,i.F)(e=>{f.current&&(f.current.rotation.y=.1*e.clock.elapsedTime,h.uniforms.time.value=e.clock.elapsedTime)});let m=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("mesh",{ref:f,material:h,children:(0,n.jsx)("sphereGeometry",{args:[.4,48,48]})}),(0,n.jsx)(u.P,{count:20,scale:2,size:1.5,speed:.1,color:c,opacity:.3,noise:.5})]});return s>0?(0,n.jsx)(S.b,{speed:1.2,rotationIntensity:.05,floatIntensity:.3*s,floatingRange:[-.2,.4],children:(0,n.jsx)("group",{position:t,scale:r,children:m})}):(0,n.jsx)("group",{position:t,scale:r,children:m})}let P={WORLD_RADIUS:55,CHUNK_GRID_SIZE:16,BLADES_PER_CHUNK:250,BLADE_WIDTH:.035,BLADE_HEIGHT:.8,BLADE_JOINTS:3,CHUNK_PADDING:1,GROUND_COLOR:"#0f1a08"},E=(0,r(8345).g)({bladeHeight:1,map:null,alphaMap:null,time:0,tipColor:new a.Color(.18,.3,.1).convertSRGBToLinear(),bottomColor:new a.Color(.04,.08,.02).convertSRGBToLinear(),windMultiplier:1,fogColor:new a.Color(329736),fogDensity:.025,fogNear:1,fogFar:1e3,edgeFadeStart:44,edgeFadeEnd:54,proximityFog:0},"\n    precision mediump float;\n    #include <fog_pars_vertex>\n\n    attribute vec3  offset;\n    attribute vec4  orientation;\n    attribute float halfRootAngleSin;\n    attribute float halfRootAngleCos;\n    attribute float stretch;\n\n    uniform float time;\n    uniform float bladeHeight;\n    uniform float windMultiplier;\n    uniform float edgeFadeStart;\n    uniform float edgeFadeEnd;\n\n    varying vec2  vUv;\n    varying float frc;\n    varying float vWorldY;\n    varying float vEdgeFade;\n\n    /* quaternion-vector rotation ----------------------------------- */\n    vec3 rotateVectorByQuaternion(vec3 v, vec4 q) {\n      return 2.0 * cross(q.xyz, v * q.w + cross(q.xyz, v)) + v;\n    }\n\n    /* nlerp for quaternions (cheaper than slerp, visually equivalent for small angles) */\n    vec4 nlerp(vec4 v0, vec4 v1, float t) {\n      float d = dot(v0, v1);\n      if (d < 0.0) { v1 = -v1; }\n      return normalize(mix(v0, v1, t));\n    }\n\n    /*--------------------------------------------------------------- */\n    void main() {\n      /* how far up the blade is this vertex? 0 = root, 1 = tip ----- */\n      frc = position.y / bladeHeight;\n\n      /* BOTW-style rolling wind waves - simplified ------------------- */\n      // Single sine wave for coordinated wind + noise for variation\n      float wave = sin(offset.x * 0.08 + offset.z * 0.05 + time * 1.5) * 0.5 + 0.5;\n      float detail = sin(offset.x * 0.15 + time * 0.5) * cos(offset.z * 0.15 + time * 0.3);\n      float n = wave + detail * 0.3;\n\n      /* base direction (straight up, yawed) ------------------------ */\n      vec4 dir = vec4(0.0, halfRootAngleSin, 0.0, halfRootAngleCos);\n\n      /* smoothly mix with growth orientation supplied by CPU ------- */\n      dir = nlerp(dir, orientation, frc);\n\n      /* vertex position -------------------------------------------- */\n      vec3 vPos 
1= position;\n      vPos.y += vPos.y * stretch;\n      vPos = rotateVectorByQuaternion(vPos, dir);\n\n      /* bend entire blade by wind - stronger, biased direction ------- */\n      float windStrength = n * 0.25 * frc * windMultiplier;\n      float windAngle = 0.8;  // Prevailing wind direction\n      vPos = rotateVectorByQuaternion(\n        vPos,\n        normalize(vec4(sin(windStrength) * cos(windAngle), 0.0, sin(windStrength) * sin(windAngle), cos(windStrength)))\n      );\n\n      vUv = uv;\n\n      vec4 worldPos = modelMatrix * vec4(offset + vPos, 1.0);\n      vWorldY = worldPos.y;\n      vEdgeFade = 1.0 - smoothstep(edgeFadeStart, edgeFadeEnd, length(worldPos.xz));\n\n      vec4 mvPosition = modelViewMatrix * vec4(offset + vPos, 1.0);\n\n      gl_Position = projectionMatrix * mvPosition;\n\n      #include <fog_vertex>\n    }\n  ","\n    precision mediump float;\n    #include <fog_pars_fragment>\n\n    uniform sampler2D map;\n    uniform sampler2D alphaMap;\n    uniform vec3 tipColor;\n    uniform vec3 bottomColor;\n    uniform float proximityFog;\n\n    varying vec2  vUv;\n    varying float frc;\n    varying float vWorldY;\n    varying float vEdgeFade;\n\n    void main() {\n      float alpha = texture2D(alphaMap, vUv).r * vEdgeFade;\n      if (alpha < 0.15) discard;\n\n      // Dark grass with subtle gradient to tips\n      vec3 grassColor = mix(bottomColor, tipColor, frc * 0.7);  // Less contrast\n\n      // Minimal texture influence - keeps it dark\n      vec4 texCol = texture2D(map, vUv);\n      grassColor = mix(grassColor, texCol.rgb * bottomColor, 0.15);\n\n      // Rare highlight on tips - only brightest blades catch light\n      float tipHighlight = smoothstep(0.85, 1.0, frc) * 0.08;\n      grassColor += vec3(tipHighlight);\n\n      gl_FragColor = vec4(grassColor, alpha);\n\n      #include <fog_fragment>\n\n      // Near-field dissolve: exp fog barely touches blades 1-2 units away, so as the\n      // player nears the portal fog we blend every blade toward the fog color and\n      // thin it out (tips first) until the field reads as haze.\n      #ifdef USE_FOG\n        // Recolor toward a slightly darker fog so additive haze sprites + bloom\n        // on top land at fog color instead of overshooting to white, then thin\n        // blades to nothing by ~80% proximity (tips vanish first).\n        float dissolve = smoothstep(0.08, 1.0, proximityFog); // dead zone so far-off fog never tints blades\n        gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor * 0.7, dissolve);\n        float thin = smoothstep(0.0, 0.8, dissolve);\n        gl_FragColor.a *= 1.0 - thin * mix(0.85, 1.0, frc);\n        if (gl_FragColor.a < 0.02) discard;\n      #endif\n      #include <tonemapping_fragment>\n      #include <colorspace_fragment>\n    }\n  ",e=>{e.side=a.DoubleSide,e.transparent=!0,e.fog=!0});function R(e){return Math.floor((e+55)/110*512)}function z(e){let{radius:t=P.WORLD_RADIUS,obstacles:r=[],groundColor:s=P.GROUND_COLOR,maskData:l=null,windMultiplier:c=1,fogProximityRef:u=null,...d}=e,f=(0,o.useRef)(0),h=(0,o.useRef)(),m=(0,o.useMemo)(()=>new a.Color(s),[s]),[v,p]=(0,i.H)(a.TextureLoader,["/materials/blade_diffuse.jpg","/materials/blade_alpha.jpg"]),{chunks:g,bladeGeometry:x,groundGeometry:y}=(0,o.useMemo)(()=>(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,{CHUNK_GRID_SIZE:n,BLADES_PER_CHUNK:o,BLADE_WIDTH:i,BLADE_HEIGHT:s,BLADE_JOINTS:l}=P,c=2*e/n,u=[],d=function(e,t,r){let n=[],o=[],i=[];for(let{angle:s,dx:l,dz:c,heightScale:u}of[{angle:0,dx:0,dz:0,heightScale:1},{angle:.38*Math.PI,dx:.4*e,dz:.2*e,heightScale:.85},{angle:.72*Math.PI,dx:-(.3*e),dz:.35*e,heightScale:.92}]){let d=t*u,f=new a.PlaneGeometry(e,d,1,r);f.translate(0,d/2,0);let h=f.attributes.position.array,m=f.attributes.uv.array,v=f.index.array,p=n.length/3,g=Math.cos(s),x=Math.sin(s);for(let e=0;e<h.length;e+=3){let t=h[e],r=h[e+1],o=h[e+2];n.push(t*g+o*x+l,r,-t*x+o*g+c)}for(let e=0;e<m.length;e++)o.push(m[e]);for(let e=0;e<v.length;e++)i.push(v[e]+p);f.dispose()}let s=new a.BufferGeometry;return s.setAttribute("position",new a.Float32BufferAttribute(n,3)),s.setAttribute("uv",new a.Float32BufferAttribute(o,2)),s.setIndex(i),s}(i,s,l),f=new a.CircleGeometry(e,64);f.rotateX(-Math.PI/2),f.translate(0,-.02,0);for(let i=0;i<n;i++)for(let s=0;s<n;s++){let n=-e+i*c,l=n+c,d=-e+s*c,f=d+c,h=(n+l)/2,m=(d+f)/2;if(Math.sqrt(Math.max(n*n,l*l)+Math.max(d*d,f*f))>1.2*e)continue;let v=function(e,t,r,n,o,i,s){let l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,c=[],u=[],d=[],f=[],h=[],m=0,v=3*o,p=(e,t)=>s.some(r=>{let{position:n,radius:o}=r;if(!n)return!1;let[i,,a]=n,s=e-i,l=t-a;return s*s+l*l<o*o}),g=(e,t)=>{if(!l)return!1;let r=R(e),n=R(t);return!(r<0)&&!(r>
1=512)&&!(n<0)&&!(n>=512)&&l[512*n+r]<128};for(let s=0;s<v&&m<o;s++){let o;let s=e+Math.random()*(t-e),l=r+Math.random()*(n-r);if(s*s+l*l>i*i||p(s,l)||g(s,l))continue;c.push(s,0,l);let v=Math.random()*Math.PI*2;f.push(Math.sin(.5*v)),h.push(Math.cos(.5*v));let x=(Math.random()-.5)*1,y=(Math.random()-.5)*1,w=new a.Quaternion().setFromAxisAngle(new a.Vector3(0,1,0),v);w.multiply(new a.Quaternion().setFromAxisAngle(new a.Vector3(1,0,0),x)),w.multiply(new a.Quaternion().setFromAxisAngle(new a.Vector3(0,0,1),y)),u.push(w.x,w.y,w.z,w.w);let M=Math.random();o=M<.3?.2+.3*Math.random():M<.7?.6+.5*Math.random():1.2+.8*Math.random(),d.push(o),m++}return{count:m,offsets:new Float32Array(c),orientations:new Float32Array(u),stretches:new Float32Array(d),halfRootAngleSin:new Float32Array(f),halfRootAngleCos:new Float32Array(h)}}(n,l,d,f,o,e,t,r);0!==v.count&&u.push({id:"chunk-".concat(i,"-").concat(s),center:[h,0,m],size:c,attributes:v})}return{chunks:u,bladeGeometry:d,groundGeometry:f}})(t,r,l),[t,r,l]);return(0,i.F)(e=>{var t;let{clock:r,scene:n}=e;f.current=.8*r.elapsedTime;let o=null!==(t=null==u?void 0:u.current)&&void 0!==t?t:0;h.current&&(n.fog&&o>0?h.current.color.copy(m).lerp(n.fog.color,o):h.current.color.copy(m))}),(0,n.jsxs)("group",{...d,children:[(0,n.jsx)("mesh",{geometry:y,children:(0,n.jsx)("meshBasicMaterial",{ref:h,color:s})}),g.map(e=>(0,n.jsx)(k,{chunk:e,bladeGeometry:x,sharedTimeRef:f,diffuse:v,alpha:p,windMultiplier:c,fogProximityRef:u},e.id))]})}function k(e){let{chunk:t,bladeGeometry:r,sharedTimeRef:s,diffuse:l,alpha:c,windMultiplier:u=1,fogProximityRef:d=null}=e,f=(0,o.useRef)();(0,i.F)(()=>{if(f.current&&void 0!==s.current){var e;f.current.uniforms.time.value=s.current,f.current.uniforms.proximityFog.value=null!==(e=null==d?void 0:d.current)&&void 0!==e?e:0}});let h=(0,o.useMemo)(()=>{let e=new a.InstancedBufferGeometry;e.index=r.index,e.attributes.position=r.attributes.position,e.attributes.uv=r.attributes.uv,e.setAttribute("offset",new a.InstancedBufferAttribute(t.attributes.offsets,3)),e.setAttribute("orientation",new a.InstancedBufferAttribute(t.attributes.orientations,4)),e.setAttribute("stretch",new a.InstancedBufferAttribute(t.attributes.stretches,1)),e.setAttribute("halfRootAngleSin",new a.InstancedBufferAttribute(t.attributes.halfRootAngleSin,1)),e.setAttribute("halfRootAngleCos",new a.InstancedBufferAttribute(t.attributes.halfRootAngleCos,1));let n=new a.Vector3(t.center[0],.5,t.center[2]),o=Math.sqrt(2)*t.size/2+P.BLADE_HEIGHT;return e.boundingSphere=new a.Sphere(n,o),e},[r,t]);return(0,n.jsx)("mesh",{geometry:h,frustumCulled:!0,children:(0,n.jsx)("grassMaterial",{ref:f,map:l,alphaMap:c,toneMapped:!1,bladeHeight:P.BLADE_HEIGHT,windMultiplier:u})})}(0,i.e)({GrassMaterial:E});let F=new a.Vector3;var I=function(e){let{position:t=[30,40,-50],scale:r=10,emissiveIntensity:s,lightIntensity:l}=e,c=(0,o.useRef)(),u=(0,o.useRef)(),d=(0,o.useRef)(),f=(0,o.useRef)(),[h,m]=(0,i.H)(a.TextureLoader,["./materials/lroc_color_poles_1k.jpg","./materials/ldem_3_8bit.jpg"]),v=(0,o.useMemo)(()=>{let e=new Float32Array(120),t=new Float32Array(40),n=new Float32Array(120);for(let o=0;o<40;o++){let i;let a=Math.floor(3*Math.random()),s=Math.random()*Math.PI*2,l=Math.acos(2*Math.random()-1);i=0===a?r+Math.random()*r*.3:1===a?1.5*r+Math.random()*r*.5:2*r+Math.random()*r,e[3*o]=i*Math.sin(l)*Math.cos(s),e[3*o+1]=i*Math.sin(l)*Math.sin(s),e[3*o+2]=i*Math.cos(l),t[o]=1.5*Math.random()+.3;let c=Math.random();c<.3?(n[3*o]=.7,n[3*o+1]=.8,n[3*o+2]=1):c<.6?(n[3*o]=.9,n[3*o+1]=.95,n[3*o+2]=1):(n[3*o]=1,n[3*o+1]=.95,n[3*o+2]=.9)}return{positions:e,sizes:t,colors:n}},[r]),p=(0,o.useMemo)(()=>new a.ShaderMaterial({uniforms:{time:{value:0}},vertexShader:"\n        attribute float size;\n        attribute vec3 color;\n        varying float vAlpha;\n        varying vec3 vColor;\n        uniform float time;\n\n        void main() {\n          vAlpha = size;\n          vColor = color;\n          vec3 pos = position;\n\n          pos += sin(time * 0.3 + position.x * 0.1) * 0.5;\n          pos += cos(time * 0.2 + position.y * 0.1) * 0.5;\n          pos += sin(time * 0.5 + position.z * 0.1) * 0.3;
1\n\n          vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);\n          gl_PointSize = size * (350.0 / -mvPosition.z);\n          gl_Position = projectionMatrix * mvPosition;\n        }\n      ",fragmentShader:"\n        varying float vAlpha;\n        varying vec3 vColor;\n\n        void main() {\n          vec2 center = gl_PointCoord - vec2(0.5);\n          float dist = length(center);\n          if (dist > 0.5) discard;\n\n          float alpha = pow(smoothstep(0.5, 0.0, dist), 2.0) * vAlpha * 0.4;\n          vec3 finalColor = vColor + vec3(0.05 * sin(dist * 10.0));\n\n          gl_FragColor = vec4(finalColor, alpha);\n        }\n      ",transparent:!0,blending:a.AdditiveBlending,depthWrite:!1}),[]),g=(0,o.useMemo)(()=>new a.ShaderMaterial({uniforms:{time:{value:0},glowColor:{value:new a.Color("#a8c0ff")},viewVector:{value:new a.Vector3}},vertexShader:"\n        uniform vec3 viewVector;\n        varying float intensity;\n\n        void main() {\n          vec3 vNormal = normalize(normalMatrix * normal);\n          vec3 vNormel = normalize(normalMatrix * viewVector);\n          intensity = pow(0.7 - dot(vNormal, vNormel), 3.0);\n\n          gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n        }\n      ",fragmentShader:"\n        uniform vec3 glowColor;\n        uniform float time;\n        varying float intensity;\n\n        void main() {\n          vec3 glow = glowColor * intensity;\n          float pulse = sin(time * 2.0) * 0.1 + 0.9;\n          gl_FragColor = vec4(glow * pulse, intensity * 0.6);\n        }\n      ",side:a.FrontSide,blending:a.AdditiveBlending,transparent:!0}),[]);return(0,i.F)(e=>{let t=e.clock.elapsedTime;if(c.current&&(c.current.rotation.y+=5e-4),u.current&&(u.current.material.uniforms.time.value=t,u.current.rotation.y+=3e-4,u.current.rotation.x=.05*Math.sin(.1*t)),d.current&&(d.current.material.uniforms.time.value=t,F.subVectors(e.camera.position,d.current.position),d.current.material.uniforms.viewVector.value.copy(F)),f.current){let e=.02*Math.sin(.5*t)+1;f.current.scale.setScalar(e)}}),(0,n.jsxs)("group",{position:t,children:[(0,n.jsxs)("mesh",{ref:c,castShadow:!0,receiveShadow:!0,children:[(0,n.jsx)("sphereGeometry",{args:[r,32,32]}),(0,n.jsx)("meshStandardMaterial",{fog:!1,map:h,displacementMap:m,displacementScale:.5,roughness:.9,metalness:.1,emissive:"#6080ff",emissiveIntensity:null!=s?s:.15})]}),(0,n.jsxs)("mesh",{ref:d,scale:1.15,children:[(0,n.jsx)("sphereGeometry",{args:[r,24,24]}),(0,n.jsx)("primitive",{object:g})]}),(0,n.jsxs)("mesh",{ref:f,scale:1.3,children:[(0,n.jsx)("sphereGeometry",{args:[r,16,16]}),(0,n.jsx)("meshBasicMaterial",{fog:!1,color:"#a0b0ff",transparent:!0,opacity:.06,side:a.BackSide,blending:a.AdditiveBlending})]}),(0,n.jsx)("points",{ref:u,material:p,children:(0,n.jsxs)("bufferGeometry",{children:[(0,n.jsx)("bufferAttribute",{attach:"attributes-position",count:v.positions.length/3,array:v.positions,itemSize:3}),(0,n.jsx)("bufferAttribute",{attach:"attributes-size",count:v.sizes.length,array:v.sizes,itemSize:1}),(0,n.jsx)("bufferAttribute",{attach:"attributes-color",count:v.colors.length/3,array:v.colors,itemSize:3})]})}),(0,n.jsx)("pointLight",{color:"#c8d8ff",intensity:null!=l?l:1.5,distance:300,decay:1.5})]})};function L(e){let{fogMask:t,maskVersion:r=0,color1:s="#ff60a0",color2:l="#ff90c0",opacity:c=.13,spriteSize:u=[5,12],spritesPerCell:d=6,sampleStep:f=6,maxSprites:h=600,onEnterFog:m,enterRadius:v=8}=e,g=(0,o.useRef)(),x=(0,o.useRef)(null),y=(0,o.useRef)(!1),w=(0,o.useRef)(m);w.current=m;let{fogGeo:M,fogMat:b}=(0,o.useMemo)(()=>{let e=[],r=new Set;if(t)for(let n=0;n<p.Zq;n+=f)for(let o=0;o<p.Zq;o+=f)t[n*p.Zq+o]>=128&&(r.add("".concat(o,",").concat(n)),e.push({mx:o,mz:n,x:(0,p.sx)(o),z:(0,p.sx)(n)}));for(let t of e){let e=0;for(let n=-f;n<=f;n+=f)for(let o=-f;o<=f;o+=f)(0!==o||0!==n)&&r.has("".concat(t.mx+o,",").concat(t.mz+n))&&e++;t.edgeFactor=e/8}let n=Math.min(e.length*d,h),o=Math.max(n,1),i=new a.InstancedBufferGeometry,m=new a.PlaneGeometry(1,1);i.index=m.index,i.attributes.position=m.attributes.position,i.attributes.uv=m.attributes.uv;let v=new Float32Array(3*o),w=new Float32Array(o),M=new Float32Array(o),b=new Float32Array(3*o),C=new a.Color(s),j=new a.Color(l);
1if(n>0){let t=2*p.UT/p.Zq*f;for(let r=0;r<n;r++){let n=e[r%e.length],o=1+(1-n.edgeFactor)*2,i=(Math.random()-.5)*t*o*2,a=(Math.random()-.5)*t*o*3;v[3*r]=n.x+i,v[3*r+1]=8*Math.pow(Math.random(),.6)+.8,v[3*r+2]=n.z+a;let s=.3+.7*n.edgeFactor;w[r]=(u[0]+Math.random()*(u[1]-u[0]))*s,M[r]=c*(.2+.6*n.edgeFactor)*(.4+.6*Math.random());let l=Math.random(),d=C.clone().lerp(j,l);b[3*r]=d.r,b[3*r+1]=d.g,b[3*r+2]=d.b}}i.setAttribute("instancePos",new a.InstancedBufferAttribute(v,3)),i.setAttribute("instanceScale",new a.InstancedBufferAttribute(w,1)),i.setAttribute("instanceAlpha",new a.InstancedBufferAttribute(M,1)),i.setAttribute("instanceColor",new a.InstancedBufferAttribute(b,3)),i.instanceCount=n;let S=new a.ShaderMaterial({uniforms:{time:{value:0},groundColor:{value:new a.Color("#1a2a20")},playerPos:{value:new a.Vector3}},vertexShader:"\n  attribute vec3 instancePos;\n  attribute float instanceScale;\n  attribute float instanceAlpha;\n  attribute vec3 instanceColor;\n\n  uniform vec3 playerPos;\n\n  varying float vAlpha;\n  varying vec2 vCenter;\n  varying vec3 vColor;\n  varying float vProximity;\n\n  void main() {\n    vCenter = position.xy;\n    vColor = instanceColor;\n\n    // Distance from player to this sprite (XZ plane)\n    float distToPlayer = length(instancePos.xz - playerPos.xz);\n\n    // Closer = slightly denser. Scene fog does the heavy lifting on approach,\n    // so keep this mild — additive sprites blow out to white if stacked too hard.\n    vProximity = 1.0 + 0.8 * (1.0 - smoothstep(0.0, 30.0, distToPlayer));\n    vAlpha = instanceAlpha * vProximity;\n\n    // Also scale up sprites slightly when close for extra coverage\n    float proxScale = 1.0 + 0.5 * (1.0 - smoothstep(0.0, 20.0, distToPlayer));\n\n    vec3 camRight = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n    vec3 camUp = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);\n\n    vec3 worldPos = instancePos\n      + camRight * position.x * instanceScale * proxScale\n      + camUp * position.y * instanceScale * proxScale;\n\n    gl_Position = projectionMatrix * viewMatrix * vec4(worldPos, 1.0);\n  }\n",fragmentShader:"\n  uniform float time;\n  uniform vec3 groundColor;\n  varying float vAlpha;\n  varying vec2 vCenter;\n  varying vec3 vColor;\n  varying float vProximity;\n\n  void main() {\n    float dist = length(vCenter);\n\n    // Soft gaussian falloff — wider so edges dissolve more\n    float alpha = exp(-dist * dist * 5.0);\n\n    // Bottom fade lessens as player gets closer — fog envelops from below\n    float proxNorm = clamp((vProximity - 1.0) / 0.8, 0.0, 1.0); // 0 = far, 1 = very close\n    float bottomFade = smoothstep(-0.5, mix(-0.1, -0.5, proxNorm), vCenter.y);\n    alpha *= bottomFade;\n\n    // Extra fade at top and sides — soften the upper corners\n    // Also relaxes when player is close so fog fills the view\n    float edgeSoftness = mix(0.6, 0.2, proxNorm);\n    float topFade = 1.0 - smoothstep(0.1, 0.5, vCenter.y);\n    float sideFade = 1.0 - smoothstep(0.15, 0.45, abs(vCenter.x));\n    alpha *= mix(1.0, topFade * sideFade, edgeSoftness);\n\n    float pulse = 0.95 + sin(time * 0.5 + vAlpha * 30.0) * 0.05;\n    alpha *= vAlpha * pulse;\n\n    if (alpha < 0.01) discard;\n\n    // Vertical gradient: bottom = dark grass green, top = full glow\n    // When close, everything shifts more toward the glow color\n    float vertGrad = smoothstep(mix(-0.2, -0.5, proxNorm), mix(0.4, 0.0, proxNorm), vCenter.y);\n    vec3 col = mix(groundColor, vColor, vertGrad);\n\n    gl_FragColor = vec4(col, alpha);\n  }\n",transparent:!0,blending:a.AdditiveBlending,depthWrite:!1,side:a.DoubleSide});if(e.length>0){let t=0,r=0;for(let n of e)t+=n.x,r+=n.z;x.current=new a.Vector2(t/e.length,r/e.length)}else x.current=null;return y.current=!1,g.current=S,{fogGeo:i,fogMat:S}},[t,r,s,l,c,u,d,f,h]);return((0,i.F)(e=>{let{clock:t,camera:r}=e;if(g.current&&(g.current.uniforms.time.value=t.elapsedTime,g.current.uniforms.playerPos.value.copy(r.position)),x.current&&w.current&&!y.current){let e=r.position.x-x.current.x,t=r.position.z-x.current.y;Math.sqrt(e*e+t*t)<v&&(y.current=!0,w.current())}if(y.current&&x.current){let e=r.position.x-x.current.x,t=r.position.z-x.current.y;Math.sqrt(e*e+t*t)>v+5&&(y.current=!1)}}),t)?(0,n.jsxs)("mesh",{frustumCulled:!1,children:[(0,n.jsx)("primitive",{object:M,attach:"geometry"}),(0,n.jsx)("primitive",{object:b,attach:"material"})]}):null}function T(e){let{fogProximityRef:t=null}=e,r=(0,o.useRef)(),s=(0,o.useMemo)(()=>new a.ShaderMaterial({uniforms:{hazeColor:{value:new a.Color},proximity:{value:0}},vertexShader:"\n      varying vec3 vDir;\n      void main() {\n        vDir = position;\n        // Rotation only — dome stays centered on the camera, pinned to the far plane\n        vec4 pos = projectionMatrix * vec4(mat3(viewMatrix) * position, 1.0
1);\n        gl_Position = pos.xyww;\n      }\n    ",fragmentShader:"\n      uniform vec3 hazeColor;\n      uniform float proximity;\n      varying vec3 vDir;\n      void main() {\n        float y = normalize(vDir).y;\n        // Band is solid below the horizon and climbs higher as the player gets closer\n        float height = mix(0.12, 1.2, proximity);\n        float band = 1.0 - smoothstep(0.0, height, y);\n        float strength = smoothstep(0.0, 0.55, proximity);\n        // Whole sky goes to fog color just before the black-out\n        float alpha = max(band * strength, smoothstep(0.6, 0.95, proximity));\n        gl_FragColor = vec4(hazeColor, alpha);\n        #include <tonemapping_fragment>\n        #include <colorspace_fragment>\n      }\n    ",side:a.BackSide,transparent:!0,depthWrite:!1,fog:!1}),[]);return(0,i.F)(e=>{var n;let{scene:o}=e,i=null!==(n=null==t?void 0:t.current)&&void 0!==n?n:0,a=!!o.fog&&i>.001;r.current&&(r.current.visible=a),a&&(s.uniforms.proximity.value=i,s.uniforms.hazeColor.value.copy(o.fog.color))}),(0,n.jsx)("mesh",{ref:r,material:s,frustumCulled:!1,renderOrder:-1e3,visible:!1,children:(0,n.jsx)("sphereGeometry",{args:[1,32,16]})})}function D(e){let{positionRef:t,radius:r=1,color:s="#ff4444"}=e,l=(0,o.useRef)();return(0,i.F)(()=>{l.current&&(null==t?void 0:t.current)&&l.current.position.copy(t.current)}),(0,n.jsxs)("mesh",{ref:l,rotation:[-Math.PI/2,0,0],children:[(0,n.jsx)("ringGeometry",{args:[.9*r,r,32]}),(0,n.jsx)("meshBasicMaterial",{color:s,transparent:!0,opacity:.6,side:a.DoubleSide,depthWrite:!1})]})}function G(e){let{maskData:t,collisionMask:r,rocksMask:s,fogMask:l,maskVersion:c,activeLayer:u="grass",mode:f="add",cursorRef:h,brushSize:m=5,paintTool:v="paint",notePositions:g=[],selectedNoteId:x=1,noteHeight:y=1,portalPositions:w=[],selectedPortalId:M=0}=e,b=(0,o.useRef)(),C=(0,o.useRef)(null),j=(0,o.useRef)(),S=(0,o.useRef)(),A=(0,o.useRef)(0),P=(0,o.useMemo)(()=>{let e=new Uint8Array(p.Zq*p.Zq*4),t=new a.DataTexture(e,p.Zq,p.Zq,a.RGBAFormat);return t.minFilter=a.LinearFilter,t.magFilter=a.LinearFilter,t.needsUpdate=!0,C.current=t,t},[]);return(0,i.F)((e,n)=>{var o,i;if(!C.current||!t)return;A.current+=3*n;let a=.3*Math.sin(A.current)+.7,c=C.current.image.data,d="erase"===f,g=-1,x=-1;d&&(null==h?void 0:h.current)&&(g=(0,p.Ul)(h.current.x),x=(0,p.Ul)(h.current.z));for(let e=0;e<p.Zq*p.Zq;e++){let n=4*e,o=e%p.Zq,i=Math.floor(e/p.Zq),f=(p.Zq-1-i)*p.Zq+o,h=t[f]>=128,v=!!r&&r[f]>=128,y=!!s&&s[f]>=128,w=!!l&&l[f]>=128,M=!1;if(d&&g>=0){let e=o-g,t=p.Zq-1-i-x;M=e*e+t*t<=m*m}v?M&&"collision"===u?(c[n]=255,c[n+1]=Math.floor(100*a),c[n+2]=Math.floor(100*a),c[n+3]=Math.floor(220*a)):(c[n]=220,c[n+1]=40,c[n+2]=40,c[n+3]=180):y?M&&"rocks"===u?(c[n]=Math.floor(100*a),c[n+1]=Math.floor(150*a),c[n+2]=255,c[n+3]=Math.floor(220*a)):(c[n]=60,c[n+1]=120,c[n+2]=220,c[n+3]=170):w?M&&"fog"===u?(c[n]=Math.floor(100*a),c[n+1]=255,c[n+2]=Math.floor(200*a),c[n+3]=Math.floor(220*a)):(c[n]=60,c[n+1]=200,c[n+2]=180,c[n+3]=160):h?(c[n]=30,c[n+1]=80,c[n+2]=30,c[n+3]=40):M&&"grass"===u?(c[n]=Math.floor(80*a),c[n+1]=255,c[n+2]=Math.floor(80*a),c[n+3]=Math.floor(220*a)):(c[n]=220,c[n+1]=160,c[n+2]=40,c[n+3]=180)}if(C.current.needsUpdate=!0,j.current&&(null==h?void 0:h.current)&&"notes"===v){j.current.position.set(h.current.x,y,h.current.z),j.current.visible=!0;let e=null===(o=j.current.children[0])||void 0===o?void 0:o.material;e&&(e.opacity=.3+.15*Math.sin(2*A.current))}else j.current&&(j.current.visible=!1);if(S.current&&(null==h?void 0:h.current)&&"portals"===v){S.current.position.set(h.current.x,.05,h.current.z),S.current.visible=!0;let e=null===(i=S.current.children[0])||void 0===i?void 0:i.material;e&&(e.opacity=.3+.15*Math.sin(2*A.current))}else S.current&&(S.current.visible=!1)}),(0,n.jsxs)("group",{children:[(0,n.jsxs)("mesh",{ref:b,rotation:[-Math.PI/2,0,0],position:[0,1.2,0],renderOrder:999,children:[(0,n.jsx)("planeGeometry",{args:[2*p.UT,2*p.UT]}),(0,n.jsx)("meshBasicMaterial",{map:P,transparent:!0,opacity:.85,depthTest:!1,depthWrite:!1,side:a.DoubleSide})]}),(0,n.jsxs)("group",{ref:j,visible:!1,renderOrder:1e3,children:[(0,n.jsxs)("mesh",{children:[(0,n.jsx)("octahedronGeometry",{args:[.25,0]}),(0,n.jsx)("meshBasicMaterial",{color:"#aa88ff",transparent:!0,opacity:.4,depthTest:!1})]}),(0,n.jsx)(d.V,{center:!0,style:{pointerEvents:"none"},children:(0,n.jsxs)("div",{style:{background:"rgba(170, 68, 255, 0.6)",color:"#fff",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",fontFamily:"var(--font-dm-sans), sans-serif",whiteSpace:"nowrap",transform:"translateY(-24px)",border:"1px dashed rgba(255,255,255,0.5)"},children:["Note ",x]})})]}),(0,n.jsxs)("group",{ref:S,visible:!1,renderOrder:1e3,children:[(0,n.jsxs)("mesh",{rotation:[-Math.PI/2,0,0],children:[(0,n.jsx)("ringGeometry",{args:[1,1.3,32]}),(0,n.jsx)("meshBasicMaterial",{color:"#00ddff",transparent:!0,opacity:.4,depthTest:!1})]}),(0,n.jsxs)("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.01,0],children:[(0,n.jsx)("circleGeometry",{args:[.3,16]}),(0,n.jsx)("meshBasicMaterial",{color:"#00ddff",transparent:!0,opacity:.3,depthTest:!1})]})]})]})}function _(e){let{rocksMask:t,maskVersion:r,maxRocks:s=500,minScale:l=.2,maxScale:c=.8,groundY:u=0,fogProximityRef:d=null}=e,f=(0,o.useRef)(),h=(0,o.useMemo)(()=>new a.Color(3487024),[]);(0,i.F)(e=>{var t,r;let{scene:n}=e,o=null!==(r=null==d?void 0:d.current)&&void 0!==r?r:0,i=null===(t=f.current)||void 0===t?void 0:t.material;i&&(n.fog&&o>0?(i.color.copy(h).lerp(n.fog.color,o),i.emissive.copy(n.fog.color).multiplyScalar(.6*o)):(i.color.copy(h),i.emissive.setScalar(0)))});let m=(0,o.useMemo)(()=>new a.Object3D,[]),v=(0,o.useMemo)(()=>{let e=[];for(let t=0;t<5;t++)e.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{baseSize:r=1,detail:n=2,noiseScale:o=1.5,noiseStrength:i=.3,octaves:s=3,flattenY:l=.6,roughness:c=.5}=t,u=Math.random;Math.random=()=>(e=(9301*e+49297)%233280)/233280;let d=function(){let e=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1
1],[0,-1,-1]],t=new Uint8Array(512),r=new Uint8Array(256);for(let e=0;e<256;e++)r[e]=e;for(let e=255;e>0;e--){let t=Math.floor(Math.random()*(e+1)),n=r[e];r[e]=r[t],r[t]=n}for(let e=0;e<512;e++)t[e]=r[255&e];function n(e,t,r,n){return e[0]*t+e[1]*r+e[2]*n}return function(r,o,i){let a,s,l,c,u,d,f,h,m;let v=1/3*(r+o+i),p=Math.floor(r+v),g=Math.floor(o+v),x=Math.floor(i+v),y=1/6*(p+g+x),w=r-(p-y),M=o-(g-y),b=i-(x-y);w>=M?M>=b?(a=1,s=0,l=0,c=1,u=1,d=0):(w>=b?(a=1,s=0,l=0):(a=0,s=0,l=1),c=1,u=0,d=1):M<b?(a=0,s=0,l=1,c=0,u=1,d=1):w<b?(a=0,s=1,l=0,c=0,u=1,d=1):(a=0,s=1,l=0,c=1,u=1,d=0);let C=w-a+1/6,j=M-s+1/6,S=b-l+1/6,A=w-c+1/6*2,P=M-u+1/6*2,E=b-d+1/6*2,R=w-1+1/6*3,z=M-1+1/6*3,k=b-1+1/6*3,F=255&p,I=255&g,L=255&x,T=t[F+t[I+t[L]]]%12,D=t[F+a+t[I+s+t[L+l]]]%12,G=t[F+c+t[I+u+t[L+d]]]%12,_=t[F+1+t[I+1+t[L+1]]]%12,B=.6-w*w-M*M-b*b;f=B<0?0:(B*=B)*B*n(e[T],w,M,b);let V=.6-C*C-j*j-S*S;h=V<0?0:(V*=V)*V*n(e[D],C,j,S);let q=.6-A*A-P*P-E*E;m=q<0?0:(q*=q)*q*n(e[G],A,P,E);let H=.6-R*R-z*z-k*k;return 32*(f+h+m+(H<0?0:(H*=H)*H*n(e[_],R,z,k)))}}();Math.random=u;let f=new a.IcosahedronGeometry(r,n),h=f.attributes.position.array;for(let t=0;t<h.length;t+=3){let r=h[t],n=h[t+1],a=h[t+2],u=Math.sqrt(r*r+n*n+a*a),f=r/u,m=n/u,v=a/u,p=0,g=i,x=o;for(let t=0;t<s;t++)p+=d(r*x+e,n*x+1.3*e,a*x+.7*e)*g,g*=.5,x*=2;let y=u+(p+=d(r*o*4+2*e,n*o*4+2.5*e,a*o*4+1.5*e)*c*.1);h[t]=f*y,h[t+1]=m*y*l,h[t+2]=v*y}return f.computeVertexNormals(),f}(1e3*t+42,{baseSize:1,detail:1,noiseScale:1.2+.3*t,noiseStrength:.25+.05*t,flattenY:.5+.3*Math.random()}));return e},[])[0],g=(0,o.useMemo)(()=>(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{baseColor:t=2763304,roughness:r=.9,metalness:n=.1}=e;return new a.MeshStandardMaterial({color:t,roughness:r,metalness:n,flatShading:!0})})({baseColor:3487024,roughness:.95}),[]),x=(0,o.useMemo)(()=>{if(!t)return[];let e=[],r=[];for(let e=0;e<p.Zq;e+=4)for(let n=0;n<p.Zq;n+=4)if(t[e*p.Zq+n]>128){let t=(0,p.sx)(n),o=(0,p.sx)(e);r.push({x:t,z:o})}let n=[];for(let t of r){let r=4/p.Zq*(Math.random()-.5)*p.UT*2,o=4/p.Zq*(Math.random()-.5)*p.UT*2,i=t.x+r,a=t.z+o,d=!1;for(let e of n){let t=i-e.x,r=a-e.z;if(t*t+r*r<2.25){d=!0;break}}if(!d&&e.length<s){let t=l+Math.random()*(c-l),r=Math.random()*Math.PI*2,o=(Math.random()-.5)*.3,s=(Math.random()-.5)*.3,d=Math.floor(5*Math.random());e.push({x:i,y:u-.2*t,z:a,scale:t,rotationX:o,rotationY:r,rotationZ:s,variant:d}),n.push({x:i,z:a})}}return e},[t,r,s,l,c,u]);return((0,o.useEffect)(()=>{f.current&&0!==x.length&&(x.forEach((e,t)=>{m.position.set(e.x,e.y,e.z),m.rotation.set(e.rotationX,e.rotationY,e.rotationZ),m.scale.setScalar(e.scale),m.updateMatrix(),f.current.setMatrixAt(t,m.matrix)}),f.current.instanceMatrix.needsUpdate=!0,f.current.count=x.length)},[x,m]),0===x.length)?null:(0,n.jsx)("instancedMesh",{ref:f,args:[v,g,s],castShadow:!0,receiveShadow:!0,frustumCulled:!1})}let B=new a.Vector3;function V(e){let{position:t=[0,0,0],radius:r=1.2,targetId:s,onEnter:l,color:c="#a0c4ff",label:u}=e,d=(0,o.useRef)(),f=(0,o.useRef)(),h=(0,o.useRef)(!1),m=(0,o.useRef)(!1),v=(0,o.useMemo)(()=>new a.Color(c),[c]),p=(0,o.useMemo)(()=>{let e=new a.Color(c);return e.lerp(new a.Color(1,1,1),.7),e},[c]),g=(0,o.useMemo)(()=>new a.ShaderMaterial({uniforms:{time:{value:0},coreColor:{value:p},outerColor:{value:v}},vertexShader:"\n  attribute float offset;\n  attribute float speed;\n  attribute float size;\n  uniform float time;\n  varying float vAlpha;\n  varying float vHeat;\n\n  void main() {\n    // Rise and loop\n    float life = fract(time * speed * 0.12 + offset);\n    float height = life * 4.0;\n\n    // Slight outward drift then inward as it rises\n    float spread = sin(life * 3.14159) * 0.6;\n    float flickerX = sin(time * 3.0 + offset * 20.0) * 0.15 * spread;\n    float flickerZ = cos(time * 2.7 + offset * 15.0) * 0.15 * spread;\n\n    vec3 pos;\n    pos.x = position.x * spread + flickerX;\n    pos.z = position.z * spread + flickerZ;\n    pos.y = height;\n\n    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);\n\n    // Larger at base, smaller at top\n    float baseSize = size * mix(1.0, 0.2, life);\n    float dist = length(mvPosition.xyz);\n    gl_PointSize = baseSize * (200.0 / max(1.0, dist));\n    gl_Position = projectionMatrix * mvPosition;\n\n    // Hot at bottom, fading at top\n    vAlpha = (1.0 - life) * (0.8 + sin(time * 5.0 + offset * 6.28) * 0.2);\n    vHeat = 1.0 - life; // 1.0 = base (hot), 0.0 = top (cool)\n  }\n",fragmentShader:"\n  uniform vec3 coreColor;\n  uniform vec3 outerColor;\n  varying float vAlpha;\n  varying float vHeat;\n\n  void main() {\n    float d = length(gl_PointCoord - 0.5);\n    if (d > 0.5) discard;\n\n    // Soft circular falloff\n    float glow = 1.0 - smoothstep(0.0, 0.5, d);
1\n\n    // Hot core → cooler outer based on height\n    vec3 col = mix(outerColor, coreColor, vHeat * glow);\n\n    gl_FragColor = vec4(col, glow * vAlpha * 0.7);\n  }\n",transparent:!0,blending:a.AdditiveBlending,depthWrite:!1}),[v,p]),x=(0,o.useMemo)(()=>{let e=new a.BufferGeometry,t=new Float32Array(360),n=new Float32Array(120),o=new Float32Array(120),i=new Float32Array(120);for(let e=0;e<120;e++){let a=Math.random()*Math.PI*2,s=Math.random()*r*.5;t[3*e]=Math.cos(a)*s,t[3*e+1]=4*Math.random(),t[3*e+2]=Math.sin(a)*s,n[e]=Math.random(),o[e]=.5+.8*Math.random(),i[e]=6+10*Math.random()}return e.setAttribute("position",new a.BufferAttribute(t,3)),e.setAttribute("offset",new a.BufferAttribute(n,1)),e.setAttribute("speed",new a.BufferAttribute(o,1)),e.setAttribute("size",new a.BufferAttribute(i,1)),e},[r]);return(0,i.F)(e=>{let{clock:t,camera:n}=e,o=t.elapsedTime;if(f.current&&(f.current.material.uniforms.time.value=o),d.current&&l){d.current.getWorldPosition(B);let e=n.position.distanceTo(B)<r+.5;!e||m.current||h.current||(h.current=!0,l(s)),!e&&m.current&&(h.current=!1),m.current=e}}),(0,n.jsx)("group",{ref:d,position:t,children:(0,n.jsxs)("points",{ref:f,frustumCulled:!1,children:[(0,n.jsx)("primitive",{object:x,attach:"geometry"}),(0,n.jsx)("primitive",{object:g,attach:"material"})]})})}function q(e){let{position:t=[0,-50,0],visible:r=!1,onExit:s,color:l="#a0c4ff"}=e,c=(0,o.useRef)(),u={length:80,width:24,height:35,aisleWidth:6,columnRows:10,columnRadius:.4,archHeight:28},d=(0,o.useMemo)(()=>new a.MeshStandardMaterial({color:"#e8e4e0",roughness:.9,metalness:0}),[]),f=(0,o.useMemo)(()=>new a.MeshStandardMaterial({color:"#d4d0cc",roughness:.95}),[]),h=(0,o.useMemo)(()=>{let e=[],t=u.length/(u.columnRows+1);for(let r=1;r<=u.columnRows;r++)e.push([-u.aisleWidth,0,-u.length/2+r*t]),e.push([u.aisleWidth,0,-u.length/2+r*t]);return e},[]);(0,o.useMemo)(()=>{let e=new a.Shape;return e.moveTo(-4,0),e.lineTo(-4,7.199999999999999),e.quadraticCurveTo(-4,12,0,14),e.quadraticCurveTo(4,12,4,7.199999999999999),e.lineTo(4,0),e},[]);let m=(0,o.useMemo)(()=>{let e=[],t=u.length/7;for(let r=1;r<=6;r++)e.push({position:[r%2?u.width/2-.1:-u.width/2+.1,.7*u.height,-u.length/2+r*t],rotation:[0,r%2?-Math.PI/2:Math.PI/2,0]});return e},[]),v=(0,o.useRef)([]);return((0,i.F)(e=>{let{clock:t}=e,r=t.elapsedTime;v.current.forEach((e,t)=>{e&&(e.intensity=.3+.1*Math.sin(.5*r+.5*t))})}),r)?(0,n.jsxs)("group",{ref:c,position:t,children:[(0,n.jsx)("mesh",{rotation:[-Math.PI/2,0,0],position:[0,0,0],material:f,children:(0,n.jsx)("planeGeometry",{args:[u.width,u.length]})}),(0,n.jsx)("mesh",{rotation:[Math.PI/2,0,0],position:[0,u.height,0],material:d,children:(0,n.jsx)("planeGeometry",{args:[u.width,u.length]})}),(0,n.jsx)("mesh",{position:[-u.width/2,u.height/2,0],rotation:[0,Math.PI/2,0],material:d,children:(0,n.jsx)("planeGeometry",{args:[u.length,u.height]})}),(0,n.jsx)("mesh",{position:[u.width/2,u.height/2,0],rotation:[0,-Math.PI/2,0],material:d,children:(0,n.jsx)("planeGeometry",{args:[u.length,u.height]})}),(0,n.jsx)("mesh",{position:[0,u.height/2,-u.length/2],material:d,children:(0,n.jsx)("planeGeometry",{args:[u.width,u.height]})}),(0,n.jsx)("mesh",{position:[0,u.height/2,u.length/2],rotation:[0,Math.PI,0],material:d,children:(0,n.jsx)("planeGeometry",{args:[u.width,u.height]})}),h.map((e,t)=>(0,n.jsxs)("group",{position:e,children:[(0,n.jsx)("mesh",{position:[0,u.archHeight/2,0],material:d,children:(0,n.jsx)("cylinderGeometry",{args:[u.columnRadius,1.2*u.columnRadius,u.archHeight,12]})}),(0,n.jsx)("mesh",{position:[0,u.archHeight,0],material:d,children:(0,n.jsx)("boxGeometry",{args:[1.2,.4,1.2]})}),(0,n.jsx)("mesh",{position:[0,.2,0],material:d,children:(0,n.jsx)("boxGeometry",{args:[1.4,.4,1.4]})})]},t)),h.slice(0,h.length/2).map((e,t)=>(0,n.jsx)("mesh",{position:[0,u.archHeight+2,e[2]],rotation:[0,0,Math.PI/2],material:d,children:(0,n.jsx)("boxGeometry",{args:[.3,2*u.aisleWidth,.3]})},"rib-".concat(t))),m.map((e,t)=>(0,n.jsxs)("mesh",{position:e.position,rotation:e.rotation,children:[(0,n.jsx)("planeGeometry",{args:[3,8]}),(0,n.jsx)("meshBasicMaterial",{color:"#fff9f0",transparent:!0,opacity:.6})]},"shaft-".concat(t))),(0,n.jsx)("ambientLight",{intensity:.15,color:"#e8e4f0"}),(0,n.jsx)("pointLight",{ref:e=>v.current[0]=e,position:[0,u.height-2,0],intensity:.4,color:"#fff8f0",distance:60,decay:2}),(0,n.jsxs)("group",{position:[0,0,-u.length/2+5],children:[(0,n.jsx)("mesh",{position:[0,.3,0],material:d,children:(0,n.jsx)("boxGeometry",{args:[8,.6,6]})}),(0,n.jsx)("mesh",{position:[0,1.2,0],material:d,children:(0,n.jsx)("boxGeometry",{args:[3,1.2,1.5]})}),(0,n.jsx)("mesh",{position:[0,8,-2.5],material:d,children:(0,n.jsx)("boxGeometry",{args:[6,16,.3]}
1)})]}),(0,n.jsx)(V,{position:[0,0,u.length/2-4],radius:1.5,targetId:"exit",onEnter:s,color:l})]}):null}function H(e){let{portalPositions:t=[],onInteriorChange:r}=e,{camera:s}=(0,i.D)(),[l,c]=(0,o.useState)(null),[u,d]=(0,o.useState)(!1),f=(0,o.useRef)(0),h=(0,o.useRef)(0),m=(0,o.useRef)(null),v=(0,o.useRef)(new a.Vector3),p=(0,o.useRef)(new a.Euler),g=(0,o.useRef)(new a.MeshBasicMaterial({color:"#000000",transparent:!0,opacity:0,depthTest:!1}));(0,i.F)((e,t)=>{if(0!==h.current){if(f.current+=h.current*t*2.5,f.current=Math.max(0,Math.min(1,f.current)),g.current.opacity=f.current,1===h.current&&f.current>=1){if(m.current){let{type:e,portal:t}=m.current;"enter"===e?(s.position.set(t.interiorPosition[0],t.interiorPosition[1]+1.6,t.interiorPosition[2]+20),s.rotation.set(0,Math.PI,0),c(t.id),null==r||r(!0)):(s.position.copy(v.current),s.rotation.copy(p.current),c(null),null==r||r(!1)),m.current=null}h.current=-1}-1===h.current&&f.current<=0&&(h.current=0,d(!1))}});let x=(0,o.useCallback)(e=>{if(u||l)return;let r=t.find(t=>t.id===e);r&&(d(!0),v.current.copy(s.position),p.current.copy(s.rotation),m.current={type:"enter",portal:r},h.current=1)},[s,u,l,t]),y=(0,o.useCallback)(()=>{!u&&l&&(d(!0),m.current={type:"exit"},h.current=1)},[u,l]);return(0,n.jsxs)(n.Fragment,{children:[!l&&t.map(e=>(0,n.jsx)(V,{position:e.position,targetId:e.id,onEnter:x,color:e.color},e.id)),t.map(e=>(0,n.jsx)(q,{position:e.interiorPosition,visible:l===e.id,onExit:y,color:e.color},e.id)),(0,n.jsxs)("mesh",{position:[0,0,-.5],renderOrder:999,children:[(0,n.jsx)("planeGeometry",{args:[10,10]}),(0,n.jsx)("primitive",{object:g.current,attach:"material"})]})]})}let N=new a.Vector3,O=new a.Vector3,U=new a.Euler(0,0,0,"YXZ");new a.Vector3,new a.Vector3;let W=new a.Raycaster,Z=new a.Plane(new a.Vector3(0,1,0),0),Y=new a.Vector3,X={outerRadius:22,innerRadius:8,triggerAt:.9,resetBelow:.3,maxDensity:.3,portalColor:new a.Color("#7a2f57"),overlayStart:.5,overlayEnd:.88},K=new a.Color,Q=new a.Color,J={position:new a.Vector3,yaw:0,pitch:0};function $(e){var t,m,M,b,C,S,P,E,R,k,F;let{onMove:B,onLock:V,constructionMode:q=!1,maskData:$,collisionMask:ee,rocksMask:et,fogMask:er,maskVersion:en,onPaint:eo,onPaintEnd:ei,brushSize:ea=5,paintTool:es="paint",notePositions:el=[],selectedNoteId:ec=1,portalPositions:eu=[],selectedPortalId:ed=0,orbPositions:ef,selectedOrbId:eh=0,initialPosition:em=null,initialYaw:ev=null,initialPitch:ep=null,cameraStateRef:eg=null,audioEngine:ex="synth",onEnterFog:ey,fogOverlayRef:ew=null,atmosphere:eM=null}=e,{keys:eb}=(0,f.I)({enabled:!q}),eC=(0,o.useRef)(new a.Vector3),ej=(0,o.useRef)(0),eS=(0,o.useRef)(!1);(0,o.useEffect)(()=>{null!==em&&(eS.current=!1)},[em,ev,ep]);let eA=(0,o.useRef)(0),eP=(0,o.useRef)(0),eE=(0,o.useRef)(!1),eR=(0,o.useRef)(),ez=(0,o.useRef)(!1),ek=(0,o.useRef)(new g(h.v.WORLD_RADIUS,h.v.OBSTACLES)),eF=(0,o.useRef)("latent"===ex?(0,y.Nv)():(0,x.lH)()),eI=(0,o.useRef)(0),eL=(0,o.useRef)(Array(h.v.ASSETS.count).fill(!1)),eT=(0,o.useRef)(new a.Vector3(em?em[0]:0,h.v.CAMERA_HEIGHT,em?em[2]:15));(0,o.useEffect)(()=>{ee&&ek.current.setCollisionMask(ee)},[ee,en]),(0,o.useMemo)(()=>[0,0,0],[]);let eD=(0,o.useMemo)(()=>[],[]),eG=(0,o.useMemo)(()=>{if(!$)return null;if(!er)return $;let e=new Uint8Array($);for(let t=0;t<er.length;t++)if(er[t]>=128){let r=t/p.Zq|0,n=t%p.Zq,o=Math.max(0,r-4),i=Math.min(p.Zq-1,r+4),a=Math.max(0,n-4),s=Math.min(p.Zq-1,n+4);for(let t=o;t<=i;t++){let r=t*p.Zq;for(let t=a;t<=s;t++)e[r+t]=0}}return e},[$,er,en]),e_=(0,o.useMemo)(()=>{if(!er)return null;let e=0,t=0,r=0;for(let n=0;n<p.Zq;n+=6)for(let o=0;o<p.Zq;o+=6)er[n*p.Zq+o]>=128&&(e+=(0,p.sx)(o),t+=(0,p.sx)(n),r++);return r>0?new a.Vector2(e/r,t/r):null},[er,en]),eB=(0,o.useRef)(),eV=(0,o.useRef)(0),eq=(0,o.useRef)(!1),eH=(0,o.useMemo)(()=>{let e=h.v.ASSETS.colors,t=ef||h.v.ASSETS.defaultPositions;return Array.from({length:h.v.ASSETS.count},(r,n)=>{let o=t[n]||h.v.ASSETS.defaultPositions[n];return{id:n,position:new a.Vector3(o[0],o[1],o[2]),color:e[n]}})},[ef]),{gl:eN,camera:eO}=(0,i.D)(),eU=(0,o.useRef)(!1),eW=(0,o.useRef)(new a.Vector3(0,.1,0)),eZ=(0,o.useRef)(!1),eY=(0,o.useRef)(q);eY.current=q;let eX=(0,o.useRef)(80),eK=(0,o.useRef)({x:0,z:0}),eQ=(0,o.useRef)({active:!1,lastX:0,lastY:0}),eJ=(0,o.useRef)({w:!1,a:!1,s:!1,d:!1}),e$=(0,o.useRef)(),e0=(0,o.useRef)(),e1=(0,o.useRef)({active:!1,startX:0,startY:0,identifier:null}),e2=(0,o.useRef)(!1);(0,o.useEffect)(()=>{let e=eN.domElement,t=t=>{eY.current||eE.current||!e||e.requestPointerLock()},r=()=>{eE.current,eE.current=document.pointerLockElement===e,eE.current&&V&&V()},n=e=>{!eY.current&&eE.current&&(eA.current-=e.movementX*h.v.MOVEMENT.mouseSensitivity,eP.current-=e.movementY*h.v.MOVEMENT.mouseSensitivity,eP.current=Math.max(-Math.PI/2+.1,Math.min(Math.PI/2-.1,eP.current)))},o=e=>{if(!eY.current){for(let t of e.touches)if(t.clientX>.4*window.innerWidth&&!e1.current.active){e1.current={active:!0,startX:t.clientX,startY:t.clientY,identifier:t.identifier},V&&V();break}}},i=e=>{if(!eY.current&&e1.current.active){for(let t of e.touches)if(t.identifier===e1.current.identifier){let e=t.clientX-e1.current.startX,r=t.clientY-e1.current.startY,n=.5*h.v.MOVEMENT.mouseSensitivity;eA.current-=e*n,eP.current-=r*n,eP.current=Math.max(-Math.PI/2+.1,Math.min(Math.PI/2-.1,eP.current)),e1.current.startX=t.clientX,e1.current.startY=t.clientY;break}}},a=e=>{for(let t of e.changedTouches)if(t.identifier===e1.current.identifier){e1.current.active=!1,e1.current.identifier=null;break}};e.addEventListener("click",t),document.addEventListener("pointerlockchange",r),document.addEventListener("mousemove",n),e.addEventListener("touchstart",o,{passive:!0}),e.addEventListener("touchmove",i,{passive:!0}),e.addEventListener("touchend",a),e.addEventListener("touchcancel",a);let s=()=>{};return document.addEventListener("pointerlockerror",s),()=>{e.removeEventListener("click",t),document.removeEventListener("pointerlockchange",r),document.removeEventListener("mousemove",n),e.removeEventListener("touchstart",o),e.removeEventListener("touchmove",i),e.removeEventListener("touchend",a),e.removeEventListener("touchcancel",a),document.removeEventListener("pointerlockerror",s)}},[eN,V]),(0,o.useEffect)(()=>{let e=!1,t=()=>{let t=(0,w.getContext)().rawContext;document.hidden?"running"===t.state&&(e=!0,t.suspend().catch(()=>{})):e&&(e=!1,t.resume().catch(()=>{}))};return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[]),(0,o.useEffect)(()=>{let e=!1,t=async()=>{e||(e=!0,(0,w.start)().catch(()=>{}),await eF.current.init(),eF.current.setOrbPositions&&eF.current.setOrbPositions(eH.map(e=>e.position)),window.removeEventListener("click",t,!0),window.removeEventListener("keydown",t,!0),window.removeEventListener("touchstart",t,!0))};return window.addEventListener("click",t,!0),window.addEventListener("keydown",t,!0),window.addEventListener("touchstart",t,!0),()=>{window.removeEventListener("click",t,!0),window.removeEventListener("keydown",t,!0),window.removeEventListener("touchstart",t,!0)}},[eH]),(0,o.useEffect)(()=>{let e=eF.current,t="latent"===ex?(0,y.Nv)():(0,x.lH)();if(e===t)return;let r=e.isReady;e.dispose(),"latent"===ex?(0,x.Hp)():(0,y._w)(),eF.current=t,r&&t.init().then(()=>{t.setOrbPositions&&t.setOrbPositions(eH.map(e=>e.position))})},[ex,eH]);let e3=(0,o.useRef)(null);(0,o.useEffect)(()=>{var e,t,n;if(!eM)return;let o=null!==(t=eM.audioLowpass)&&void 0!==t?t:2e4,i=null!==(n=eM.audioReverbBoost)&&void 0!==n?n:0;if(async function(){try{let e=await Promise.resolve().then(r.bind(r,8994)),t=e.getContext().rawContext;if(!e3.current){let r=t.createBiquadFilter();r.type="lowpass",r.Q.value=.7,e.getDestination().disconnect(),e.getDestination().connect(r),r.connect(t.destination),e3.current=r}let n=e3.current.context.currentTime;e3.current.frequency.linearRampToValueAtTime(o,n+2)}catch(e){}}(),i>0&&(null===(e=eF.current)||void 0===e?void 0:e.isReady)){let e=eF.current.synths,t=eF.current.effects;(null==e?void 0:e.masterReverb)&&e.masterReverb.wet.rampTo(Math.min(e.masterReverb.wet.value+i,.95),2),(null==t?void 0:t.masterReverb)&&t.masterReverb.wet.rampTo(Math.min(t.masterReverb.wet.value+i,.95),2)}},[null==eM?void 0:eM.audioLowpass,null==eM?void 0:eM.audioReverbBoost]),(0,o.useEffect)(()=>
1{if(q&&!eZ.current){var e,t;J.position.copy(eO.position),J.yaw=eA.current,J.pitch=eP.current,eX.current=80,eK.current={x:0,z:0},eO.position.set(0,80,.1),eA.current=0,eP.current=-Math.PI/2+.01,null===(e=(t=document).exitPointerLock)||void 0===e||e.call(t),eZ.current=!0}else!q&&eZ.current&&(eO.position.copy(J.position),eA.current=J.yaw,eP.current=J.pitch,eZ.current=!1)},[q,eO]),(0,o.useEffect)(()=>{if(!q)return;let e=eN.domElement,t=e=>{e.preventDefault();let t=.1*eX.current;eX.current=a.MathUtils.clamp(eX.current+(e.deltaY>0?t:-t),15,200)},r=e=>{1===e.button&&(e.preventDefault(),eQ.current={active:!0,lastX:e.clientX,lastY:e.clientY})},n=e=>{if(!eQ.current.active)return;let t=e.clientX-eQ.current.lastX,r=e.clientY-eQ.current.lastY,n=eX.current/800;eK.current.x-=t*n,eK.current.z-=r*n,eQ.current.lastX=e.clientX,eQ.current.lastY=e.clientY},o=e=>{1===e.button&&(eQ.current.active=!1)},i=e=>{"KeyW"===e.code&&(eJ.current.w=!0),"KeyA"===e.code&&(eJ.current.a=!0),"KeyS"===e.code&&(eJ.current.s=!0),"KeyD"===e.code&&(eJ.current.d=!0)},s=e=>{"KeyW"===e.code&&(eJ.current.w=!1),"KeyA"===e.code&&(eJ.current.a=!1),"KeyS"===e.code&&(eJ.current.s=!1),"KeyD"===e.code&&(eJ.current.d=!1)},l=e=>{1===e.button&&e.preventDefault()};return e.addEventListener("wheel",t,{passive:!1}),e.addEventListener("mousedown",r),window.addEventListener("mousemove",n),window.addEventListener("mouseup",o),window.addEventListener("keydown",i),window.addEventListener("keyup",s),e.addEventListener("contextmenu",l),()=>{e.removeEventListener("wheel",t),e.removeEventListener("mousedown",r),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",o),window.removeEventListener("keydown",i),window.removeEventListener("keyup",s),e.removeEventListener("contextmenu",l),eJ.current={w:!1,a:!1,s:!1,d:!1}}},[q,eN]),(0,o.useEffect)(()=>{if(!q)return;let e=eN.domElement,t=(t,r)=>{let n=e.getBoundingClientRect(),o=new a.Vector2((t-n.left)/n.width*2-1,-((r-n.top)/n.height*2)+1);return(W.setFromCamera(o,eO),W.ray.intersectPlane(Z,Y))?Y.clone():null},r=e=>{let r=t(e.clientX,e.clientY);r&&(eW.current.set(r.x,.1,r.z),eU.current&&eo&&eo(r.x,r.z))},n=e=>{if(0===e.button){eU.current=!0;let r=t(e.clientX,e.clientY);r&&eo&&eo(r.x,r.z)}},o=e=>{0===e.button&&eU.current&&(eU.current=!1,ei&&ei())};return e.addEventListener("mousemove",r),e.addEventListener("mousedown",n),e.addEventListener("mouseup",o),window.addEventListener("mouseup",o),()=>{e.removeEventListener("mousemove",r),e.removeEventListener("mousedown",n),e.removeEventListener("mouseup",o),window.removeEventListener("mouseup",o)}},[q,eN,eO,eo,ei]);let e5=(0,o.useRef)(ey);e5.current=ey;let e4=()=>{var e;eO.position.set(-4,h.v.CAMERA_HEIGHT,16.6),eA.current=-.23,eP.current=.35,ej.current=0,eT.current.set(-4,h.v.CAMERA_HEIGHT,16.6),null===(e=e5.current)||void 0===e||e.call(e5)};return(0,i.F)((e,t)=>{var r,n,o,i,s;if(eR.current){ez.current||(eR.current.traverse(e=>{e.material&&(e.material.fog=!1,e.material.transparent=!0)}),ez.current=!0);let e=null!==(r=null==eM?void 0:eM.starsOpacity)&&void 0!==r?r:1;eR.current.traverse(t=>{t.material&&(t.material.opacity=e)})}if(eS.current||q||(em?(e.camera.position.set(em[0],h.v.CAMERA_HEIGHT,em[2]),eT.current.set(em[0],h.v.CAMERA_HEIGHT,em[2])):(e.camera.position.set(-4,h.v.CAMERA_HEIGHT,16.6),eT.current.set(-4,h.v.CAMERA_HEIGHT,16.6)),eA.current=null!=ev?ev:-.23,eP.current=null!=ep?ep:.35,ej.current=0,eS.current=!0),eg&&(q?eg.current={position:[J.position.x,J.position.y,J.position.z],yaw:J.yaw,pitch:J.pitch}:eg.current={position:[e.camera.position.x,e.camera.position.y,e.camera.position.z],yaw:eA.current,pitch:eP.current}),q){let r=.8*eX.current*t;eJ.current.w&&(eK.current.z-=r),eJ.current.s&&(eK.current.z+=r),eJ.current.a&&(eK.current.x-=r),eJ.current.d&&(eK.current.x+=r),e.camera.position.set(eK.current.x,eX.current,eK.current.z+.1),U.set(-Math.PI/2+.01,0,0),e.camera.quaternion.setFromEuler(U);return}if(e2.current){U.set(eP.current,eA.current,0),e.camera.quaternion.setFromEuler(U);let{forward:r,backward:n,left:o,right:i,shift:a}=eb;if(eC.current.set(0,0,0),r&&(eC.current.z-=1),n&&(eC.current.z+=1),o&&(eC.current.x-=1),i&&(eC.current.x+=1),eC.current.length()){eC.current.normalize();let r=(a?h.v.MOVEMENT.runSpeed:h.v.MOVEMENT.walkSpeed)*t;N.copy(eC.current).multiplyScalar(r).applyQuaternion(e.camera.quaternion),e.camera.position.x+=N.x,e.camera.position.z+=N.z}return}U.set(eP.current,eA.current,0),e.camera.quaternion.setFromEuler(U);let{forward:l,backward:c,left:u,right:d,shift:f}=eb;eC.current.set(0,0,0),l&&(eC.current.z-=1),c&&(eC.current.z+=1),u&&(eC.current.x-=1),d&&(eC.current.x+=1),eC.current.length()&&B&&B();let m=f?h.v.MOVEMENT.runSpeed:h.v.MOVEMENT.walkSpeed,v=h.v.MOVEMENT.acceleration,p=h.v.MOVEMENT.deceleration;eC.current.length()?(eC.current.normalize(),ej.current=a.MathUtils.lerp(ej.current,m,v*t)):ej.current=a.MathUtils.lerp(ej.current,0,p*t),N.copy(eC.current).multiplyScalar(ej.current*t).applyQuaternion(e.camera.quaternion),O.copy(e.camera.position),O.x+=N.x,O.z+=N.z,O.y=h.v.CAMERA_HEIGHT,ek.current.resolvePosition(O,eT.current),e.camera.position.copy(O),eT.current.copy(O);{let r=0;if(e_){let e=O.x-e_.x,t=O.z-e_.y;r=1-(r=a.MathUtils.smoothstep(Math.sqrt(e*e+t*t),X.innerRadius,X.outerRadius))}eV.current=a.MathUtils.damp(eV.current,r,6,t);let s=eV.current;if(eB.current){let t=null!==(o=null==eM?void 0:eM.fogDensity)&&void 0!==o?o:h.v.FOG.density;K.set(null!==(i=null==eM?void 0:eM.fogSceneColor)&&void 0!==i?i:h.v.FOG.sceneColor),eB.current.density=a.MathUtils.lerp(t,X.maxDensity,s*s),Q.copy(K).lerp(X.portalColor,Math.min(1,1.4*s)),eB.current.color.copy(Q),(null===(n=e.scene.background)||void 0===n?void 0:n.isColor)&&e.scene.background.copy(Q)}
1if(null==ew?void 0:ew.current){let e=a.MathUtils.smoothstep(s,X.overlayStart,X.overlayEnd);ew.current.style.opacity=e.toFixed(3)}s>=X.triggerAt&&!eq.current?(eq.current=!0,e4()):s<X.resetBelow&&eq.current&&(eq.current=!1)}let g=eF.current;if(g.isReady){let e=Date.now(),t=ek.current.getDistanceFromCenter(O);h.v.WORLD_RADIUS,g.updateFromPosition(O,ej.current),eH.forEach((e,t)=>{let r=O.x-e.position.x,n=O.z-e.position.z,o=Math.sqrt(r*r+n*n),i=o<5,a=eL.current[t];if(i&&!a){var s;null===(s=g.triggerVocalFromOrb)||void 0===s||s.call(g,t,1-o/5),g.playProximityChime(o,e.color),eL.current[t]=!0}else!i&&a&&(eL.current[t]=!1)}),t<8&&e-eI.current>3e3&&(null===(s=g.triggerVocalFromCenter)||void 0===s||s.call(g,1-t/8),eI.current=e)}if(e$.current&&e0.current){let e=eH.map((e,t)=>({index:t,dist:O.distanceToSquared(e.position),position:e.position,color:e.color}));e.sort((e,t)=>e.dist-t.dist),e[0]&&(e$.current.position.copy(e[0].position),e$.current.color.set(e[0].color)),e[1]&&(e0.current.position.copy(e[1].position),e0.current.color.set(e[1].color))}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("fogExp2",{ref:eB,attach:"fog",args:[null!==(t=null==eM?void 0:eM.fogSceneColor)&&void 0!==t?t:h.v.FOG.sceneColor,null!==(m=null==eM?void 0:eM.fogDensity)&&void 0!==m?m:h.v.FOG.density]}),(0,n.jsx)("color",{attach:"background",args:[null!==(M=null==eM?void 0:eM.fogSceneColor)&&void 0!==M?M:h.v.FOG.sceneColor]}),(0,n.jsx)("ambientLight",{intensity:null!==(b=null==eM?void 0:eM.ambientIntensity)&&void 0!==b?b:h.v.LIGHTING.ambient.intensity,color:null!==(C=null==eM?void 0:eM.ambientColor)&&void 0!==C?C:h.v.LIGHTING.ambient.color}),(0,n.jsx)("directionalLight",{position:h.v.LIGHTING.directional.position,intensity:null!==(S=null==eM?void 0:eM.directionalIntensity)&&void 0!==S?S:h.v.LIGHTING.directional.intensity,color:null!==(P=null==eM?void 0:eM.directionalColor)&&void 0!==P?P:h.v.LIGHTING.directional.color,castShadow:!0,"shadow-mapSize":[v.SHADOW_MAP_SIZE,v.SHADOW_MAP_SIZE]}),(0,n.jsx)("pointLight",{position:h.v.LIGHTING.accent.position,intensity:h.v.LIGHTING.accent.intensity,color:h.v.LIGHTING.accent.color,distance:30,decay:2}),(0,n.jsx)("pointLight",{ref:e$,intensity:1.2,distance:15,decay:2}),(0,n.jsx)("pointLight",{ref:e0,intensity:1.2,distance:15,decay:2}),(0,n.jsxs)(s.qA,{background:!1,environmentIntensity:.8,children:[(0,n.jsxs)("mesh",{scale:100,children:[(0,n.jsx)("sphereGeometry",{args:[1,16,16]}),(0,n.jsx)("meshBasicMaterial",{color:"#1a2a30",side:a.BackSide})]}),(0,n.jsx)("directionalLight",{position:[5,8,3],intensity:2}),(0,n.jsx)("directionalLight",{position:[-3,5,-5],intensity:1,color:"#8090ff"})]}),(0,n.jsx)(l.q,{distance:45e4,sunPosition:[0,-1,0],inclination:0,azimuth:.25,rayleigh:0,turbidity:0,mieCoefficient:0}),(0,n.jsx)(T,{fogProximityRef:eV}),(0,n.jsx)("group",{ref:eR,visible:(null!==(E=null==eM?void 0:eM.starsOpacity)&&void 0!==E?E:1)>.01,children:(0,n.jsx)(c.t,{radius:80,depth:40,count:5e3,factor:4,saturation:0,fade:!0})}),(0,n.jsx)(I,{position:[30,40,-50],scale:8,emissiveIntensity:null==eM?void 0:eM.moonEmissiveIntensity,lightIntensity:null==eM?void 0:eM.moonLightIntensity}),(0,n.jsx)(u.P,{count:v.MAX_PARTICLES/2,scale:25,size:2,speed:null!==(R=null==eM?void 0:eM.sparkleSpeed)&&void 0!==R?R:.3,opacity:null!==(k=null==eM?void 0:eM.sparkleOpacity)&&void 0!==k?k:.5}),(0,n.jsx)(z,{radius:h.v.GRASS.radius,obstacles:eD,groundColor:h.v.GRASS.groundColor,maskData:eG,windMultiplier:null!==(F=null==eM?void 0:eM.windMultiplier)&&void 0!==F?F:1,fogProximityRef:eV},en),(0,n.jsx)(L,{fogMask:er,maskVersion:en}),(0,n.jsx)("group",{position:[-4,0,-15],rotation:[0,Math.PI-.2,0],scale:2,children:(0,n.jsx)(j,{castShadow:!0,receiveShadow:!0})}),eH.map(e=>(0,n.jsx)(A,{position:e.position.toArray(),scale:1.5+.5*Math.sin(.7*e.id),floatIntensity:2+1*Math.sin(1.2*e.id),collisionRadius:1.2,glowColor:e.color,useSharedLight:!0},e.id)),(0,n.jsx)(_,{rocksMask:et,maskVersion:en,maxRocks:300,minScale:.15,maxScale:.6,groundY:0,fogProximityRef:eV}),q&&(0,n.jsx)(G,{maskData:$,collisionMask:ee,rocksMask:et,fogMask:er,maskVersion:en,activeLayer:"collision"===es||"erase-collision"===es?"collision":"rocks"===es||"erase-rocks"===es?"rocks":"fog"===es||"erase-fog"===es?"fog":"grass",mode:"erase"===es||"erase-collision"===es||"erase-rocks"===es||"erase-fog"===es?"erase":"add",cursorRef:eW,brushSize:ea,paintTool:es,notePositions:el,selectedNoteId:ec,portalPositions:eu,selectedPortalId:ed}
1),q&&(0,n.jsx)(D,{positionRef:eW,radius:"notes"===es?.3:"portals"===es?1.2:"orbs"===es?1.5:2*p.UT/p.Zq*ea,color:"collision"===es?"#ff2222":"rocks"===es?"#4488ff":"notes"===es?"#aa44ff":"portals"===es?"#00ddff":"orbs"===es?"#ffaa00":"paint"===es?"#cc8800":"#44ff44"}),q&&el.map((e,t)=>{let r=t+1===ec;return(0,n.jsxs)("group",{position:e,children:[(0,n.jsxs)("mesh",{children:[(0,n.jsx)("octahedronGeometry",{args:[r?.25:.18,0]}),(0,n.jsx)("meshStandardMaterial",{color:r?"#ffffff":"#8866ff",emissive:r?"#aa88ff":"#4422aa",emissiveIntensity:r?1.5:.5,transparent:!0,opacity:.9})]}),(0,n.jsx)(d.V,{center:!0,style:{pointerEvents:"none"},children:(0,n.jsx)("div",{style:{background:r?"rgba(170, 68, 255, 0.9)":"rgba(0, 0, 0, 0.7)",color:r?"#fff":"#aaa",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",fontWeight:r?"bold":"normal",fontFamily:"var(--font-dm-sans), sans-serif",whiteSpace:"nowrap",border:r?"1px solid #fff":"1px solid transparent",transform:"translateY(-24px)"},children:t+1})}),(0,n.jsxs)("line",{children:[(0,n.jsx)("bufferGeometry",{children:(0,n.jsx)("bufferAttribute",{attach:"attributes-position",count:2,array:new Float32Array([0,0,0,0,-e[1],0]),itemSize:3})}),(0,n.jsx)("lineBasicMaterial",{color:r?"#ffff00":"#8866ff",transparent:!0,opacity:.4})]})]},t)}),!q&&(0,n.jsx)(H,{portalPositions:eu,onInteriorChange:e=>{e2.current=e}}),q&&eu.map((e,t)=>{let r=t===ed;return(0,n.jsxs)("group",{position:e.position,children:[(0,n.jsxs)("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.05,0],children:[(0,n.jsx)("ringGeometry",{args:[1,1.3,32]}),(0,n.jsx)("meshBasicMaterial",{color:r?"#ffffff":e.color})]}),(0,n.jsxs)("mesh",{rotation:[-Math.PI/2,0,0],position:[0,.06,0],children:[(0,n.jsx)("circleGeometry",{args:[.3,16]}),(0,n.jsx)("meshBasicMaterial",{color:e.color})]}),(0,n.jsx)(d.V,{center:!0,style:{pointerEvents:"none"},children:(0,n.jsxs)("div",{style:{background:r?"rgba(0, 200, 255, 0.9)":"rgba(0, 0, 0, 0.7)",color:"#fff",padding:"2px 6px",borderRadius:"4px",fontSize:"11px",fontWeight:r?"bold":"normal",fontFamily:"var(--font-dm-sans), sans-serif",whiteSpace:"nowrap",border:r?"1px solid #fff":"1px solid transparent",transform:"translateY(-30px)"},children:["Portal ",t+1,": ",e.id]})})]},e.id)}),q&&eH.map((e,t)=>{let r=t===eh&&"orbs"===es,o=h.v.ASSETS.trackNames[t];return(0,n.jsxs)("group",{position:e.position.toArray(),children:[(0,n.jsxs)("mesh",{rotation:[-Math.PI/2,0,0],position:[0,-e.position.y+.07,0],children:[(0,n.jsx)("circleGeometry",{args:[1.5,24]}),(0,n.jsx)("meshBasicMaterial",{color:e.color,transparent:!0,opacity:r?.6:.25})]}),(0,n.jsxs)("line",{children:[(0,n.jsx)("bufferGeometry",{children:(0,n.jsx)("bufferAttribute",{attach:"attributes-position",count:2,array:new Float32Array([0,0,0,0,-e.position.y,0]),itemSize:3})}),(0,n.jsx)("lineBasicMaterial",{color:e.color,transparent:!0,opacity:r?.8:.3})]}),(0,n.jsx)(d.V,{center:!0,style:{pointerEvents:"none"},children:(0,n.jsxs)("div",{style:{background:r?"".concat(e.color,"dd"):"rgba(0, 0, 0, 0.7)",color:"#fff",padding:"2px 6px",borderRadius:"4px",fontSize:"10px",fontWeight:r?"bold":"normal",fontFamily:"var(--font-dm-sans), sans-serif",whiteSpace:"nowrap",border:r?"1px solid #fff":"1px solid ".concat(e.color,"66"),transform:"translateY(-24px)"},children:[t,": ",o]})})]},"orb-marker-".concat(t))})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.