t2-mapper/docs/_next/static/chunks/1498d1f5aa36f719.js
Brian Beck 4fc405ac4b build
2025-12-04 22:35:41 -08:00

1 line
18 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75567,e=>{"use strict";e.s(["setupColor",()=>r,"setupMask",()=>n,"updateTerrainTextureShader",()=>i]);var t=e.i(90072);function r(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[1,1];return e.wrapS=e.wrapT=t.RepeatWrapping,e.colorSpace=t.SRGBColorSpace,e.repeat.set(...r),e.flipY=!1,e.anisotropy=16,e.generateMipmaps=!0,e.minFilter=t.LinearMipmapLinearFilter,e.magFilter=t.LinearFilter,e.needsUpdate=!0,e}function n(e){let r=new t.DataTexture(e,256,256,t.RedFormat,t.UnsignedByteType);return r.colorSpace=t.NoColorSpace,r.wrapS=r.wrapT=t.RepeatWrapping,r.generateMipmaps=!1,r.minFilter=t.LinearFilter,r.magFilter=t.LinearFilter,r.needsUpdate=!0,r}function i(e){let{shader:t,baseTextures:r,alphaTextures:n,visibilityMask:i,tiling:a,debugMode:o=!1}=e,l=r.length;if(r.forEach((e,r)=>{t.uniforms["albedo".concat(r)]={value:e}}),n.forEach((e,r)=>{r>0&&(t.uniforms["mask".concat(r)]={value:e})}),i&&(t.uniforms.visibilityMask={value:i}),r.forEach((e,r)=>{var n;t.uniforms["tiling".concat(r)]={value:null!=(n=a[r])?n:32}}),t.uniforms.debugMode={value:+!!o},t.fragmentShader="\nuniform sampler2D albedo0;\nuniform sampler2D albedo1;\nuniform sampler2D albedo2;\nuniform sampler2D albedo3;\nuniform sampler2D albedo4;\nuniform sampler2D albedo5;\nuniform sampler2D mask1;\nuniform sampler2D mask2;\nuniform sampler2D mask3;\nuniform sampler2D mask4;\nuniform sampler2D mask5;\nuniform float tiling0;\nuniform float tiling1;\nuniform float tiling2;\nuniform float tiling3;\nuniform float tiling4;\nuniform float tiling5;\nuniform float debugMode;\n".concat(i?"uniform sampler2D visibilityMask;":"","\n\n// Wireframe edge detection for debug mode\nfloat getWireframe(vec2 uv, float gridSize, float lineWidth) {\n vec2 gridUv = uv * gridSize;\n vec2 grid = abs(fract(gridUv - 0.5) - 0.5);\n vec2 deriv = fwidth(gridUv);\n vec2 edge = smoothstep(vec2(0.0), deriv * lineWidth, grid);\n return 1.0 - min(edge.x, edge.y);\n}\n")+t.fragmentShader,i){let e="#include <clipping_planes_fragment>";t.fragmentShader=t.fragmentShader.replace(e,"".concat(e,"\n // Early discard for invisible areas (before fog/lighting)\n float visibility = texture2D(visibilityMask, vMapUv).r;\n if (visibility < 0.5) {\n discard;\n }\n "))}t.fragmentShader=t.fragmentShader.replace("#include <map_fragment>","\n // Sample base albedo layers (sRGB textures auto-decoded to linear)\n vec2 baseUv = vMapUv;\n vec3 c0 = texture2D(albedo0, baseUv * vec2(tiling0)).rgb;\n ".concat(l>1?"vec3 c1 = texture2D(albedo1, baseUv * vec2(tiling1)).rgb;":"","\n ").concat(l>2?"vec3 c2 = texture2D(albedo2, baseUv * vec2(tiling2)).rgb;":"","\n ").concat(l>3?"vec3 c3 = texture2D(albedo3, baseUv * vec2(tiling3)).rgb;":"","\n ").concat(l>4?"vec3 c4 = texture2D(albedo4, baseUv * vec2(tiling4)).rgb;":"","\n ").concat(l>5?"vec3 c5 = texture2D(albedo5, baseUv * vec2(tiling5)).rgb;":"","\n\n // Sample linear masks (use R channel)\n float a1 = texture2D(mask1, baseUv).r;\n ").concat(l>1?"float a2 = texture2D(mask2, baseUv).r;":"","\n ").concat(l>2?"float a3 = texture2D(mask3, baseUv).r;":"","\n ").concat(l>3?"float a4 = texture2D(mask4, baseUv).r;":"","\n ").concat(l>4?"float a5 = texture2D(mask5, baseUv).r;":"","\n\n // Bottom-up compositing: each mask tells how much the higher layer replaces lower\n ").concat(l>1?"vec3 blended = mix(c0, c1, clamp(a1, 0.0, 1.0));":"","\n ").concat(l>2?"blended = mix(blended, c2, clamp(a2, 0.0, 1.0));":"","\n ").concat(l>3?"blended = mix(blended, c3, clamp(a3, 0.0, 1.0));":"","\n ").concat(l>4?"blended = mix(blended, c4, clamp(a4, 0.0, 1.0));":"","\n ").concat(l>5?"blended = mix(blended, c5, clamp(a5, 0.0, 1.0));":"","\n\n // Assign to diffuseColor before lighting\n vec3 textureColor = ").concat(l>1?"blended":"c0",";\n\n // Debug mode wireframe handling\n if (debugMode > 0.5) {\n // 256 grid cells across the terrain (matches terrain resolution)\n float wireframe = getWireframe(baseUv, 256.0, 1.0);\n vec3 wireColor = vec3(0.0, 0.8, 0.4); // Green wireframe\n\n if (gl_FrontFacing) {\n // Front face: show textures with barely visible wireframe overlay\n diffuseColor.rgb = mix(textureColor, wireColor, wireframe * 0.05);\n } else {\n // Back face: show only wireframe, discard non-wireframe pixels\n if (wireframe < 0.1) {\n discard;\n }\n diffuseColor.rgb = mix(vec3(0.0), wireColor, 0.25);\n }\n } else {\n diffuseColor.rgb = textureColor;\n }\n"))}},5230,79123,e=>{"use strict";e.s(["useFrame",()=>t.D],5230);var t=e.i(46712);e.s(["SettingsProvider",()=>u,"useControls",()=>c,"useDebug",()=>s,"useSettings",()=>l],79123);var r=e.i(43476),n=e.i(71645);let i=(0,n.createContext)(null),a=(0,n.createContext)(null),o=(0,n.createContext)(null);function l(){return(0,n.useContext)(i)}function s(){return(0,n.useContext)(a)}function c(){return(0,n.useContext)(o)}function u(e){let{children:t}=e,[l,s]=(0,n.useState)(!0),[c,u]=(0,n.useState)(1),[d,f]=(0,n.useState)(90),[m,v]=(0,n.useState)(!1),[h,p]=(0,n.useState)(!0),[g,x]=(0,n.useState)(!1),b=(0,n.useMemo)(()=>({fogEnabled:l,setFogEnabled:s,fov:d,setFov:f,audioEnabled:m,setAudioEnabled:v,animationEnabled:h,setAnimationEnabled:p}),[l,c,d,m,h]),y=(0,n.useMemo)(()=>({debugMode:g,setDebugMode:x}),[g,x]),M=(0,n.useMemo)(()=>({speedMultiplier:c,setSpeedMultiplier:u}),[c,u]);(0,n.useEffect)(()=>{let e={};try{e=JSON.parse(localStorage.getItem("settings"))||{}}catch(e){}null!=e.debugMode&&x(e.debugMode),null!=e.audioEnabled&&v(e.audioEnabled),null!=e.animationEnabled&&p(e.animationEnabled),null!=e.fogEnabled&&s(e.fogEnabled),null!=e.speedMultiplier&&u(e.speedMultiplier),null!=e.fov&&f(e.fov)},[]);let w=(0,n.useRef)(null);return(0,n.useEffect)(()=>(w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{try{localStorage.setItem("settings",JSON.stringify({fogEnabled:l,speedMultiplier:c,fov:d,audioEnabled:m,animationEnabled:h,debugMode:g}))}catch(e){}},500),()=>{w.current&&clearTimeout(w.current)}),[l,c,d,m,h,g]),(0,r.jsx)(i.Provider,{value:b,children:(0,r.jsx)(a.Provider,{value:y,children:(0,r.jsx)(o.Provider,{value:M,children:t})})})}},47071,80520,e=>{"use strict";e.s(["useTexture",()=>o],47071);var t=e.i(71645),r=e.i(90072),n=e.i(16096);e.s(["useLoader",()=>i.G],80520);var i=e.i(46712),i=i;let a=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function o(e,o){let l=(0,n.useThree)(e=>e.gl),s=(0,i.G)(r.TextureLoader,a(e)?Object.values(e):e);return(0,t.useLayoutEffect)(()=>{null==o||o(s)},[o]),(0,t.useEffect)(()=>{if("initTexture"in l){let e=[];Array.isArray(s)?e=s:s instanceof r.Texture?e=[s]:a(s)&&(e=Object.values(s)),e.forEach(e=>{e instanceof r.Texture&&l.initTexture(e)})}},[l,s]),(0,t.useMemo)(()=>{if(!a(e))return s;{let t={},r=0;for(let n in e)t[n]=s[r++];return t}},[e,s])}o.preload=e=>i.G.preload(r.TextureLoader,e),o.clear=e=>i.G.clear(r.TextureLoader,e)},6112,51475,77482,e=>{"use strict";e.s(["useDatablock",()=>u],6112),e.s(["RuntimeProvider",()=>s,"useRuntime",()=>c],77482);var t=e.i(43476),r=e.i(71645);e.s(["TickProvider",()=>a,"useTick",()=>o],51475);var n=e.i(5230);let i=(0,r.createContext)(null);function a(e){let{children:a}=e,o=(0,r.useRef)(void 0),l=(0,r.useRef)(0),s=(0,r.useRef)(0);(0,n.useFrame)((e,t)=>{for(l.current+=t;l.current>=.03125;)if(l.current-=.03125,s.current++,o.current)for(let e of o.current)e(s.current)});let c=(0,r.useCallback)(e=>(null!=o.current||(o.current=new Set),o.current.add(e),()=>{o.current.delete(e)}),[]),u=(0,r.useCallback)(()=>s.current,[]),d=(0,r.useMemo)(()=>({subscribe:c,getTick:u}),[c,u]);return(0,t.jsx)(i.Provider,{value:d,children:a})}function o(e){let t=(0,r.useContext)(i);if(!t)throw Error("useTick must be used within a TickProvider");let n=(0,r.useRef)(e);n.current=e,(0,r.useEffect)(()=>t.subscribe(e=>n.current(e)),[t])}let l=(0,r.createContext)(null);function s(e){let{runtime:r,children:n}=e;return(0,t.jsx)(l.Provider,{value:r,children:(0,t.jsx)(a,{children:n})})}function c(){let e=(0,r.useContext)(l);if(!e)throw Error("useRuntime must be used within a RuntimeProvider");return e}function u(e){let t=c();if(e)return t.state.datablocks.get(e)}},31067,e=>{"use strict";function t(){return(t=Object.assign.bind()).apply(null,arguments)}e.s(["default",()=>t])},77975,e=>{"use strict";e.s(["useDistanceFromCamera",()=>a],77975);var t=e.i(5230),r=e.i(16096),n=e.i(71645),i=e.i(90072);function a(e){let{camera:a}=(0,r.useThree)(),o=(0,n.useRef)(null),l=function(e){let r=(0,n.useRef)(null);return(0,t.useFrame)(()=>{e.current&&(null!=r.current||(r.current=new i.Vector3),e.current.getWorldPosition(r.current))}),r}(e);return(0,t.useFrame)(()=>{l.current?o.current=a.position.distanceTo(l.current):o.current=null}),o}},89887,60099,e=>{"use strict";let t,r;e.s(["FloatingLabel",()=>w],89887);var n=e.i(43476),i=e.i(71645),a=e.i(77975),o=e.i(5230);e.s(["Html",()=>y],60099);var l=e.i(31067),s=e.i(88014),c=e.i(90072),u=e.i(16096);let d=new c.Vector3,f=new c.Vector3,m=new c.Vector3,v=new c.Vector2;function h(e,t,r){let n=d.setFromMatrixPosition(e.matrixWorld);n.project(t);let i=r.width/2,a=r.height/2;return[n.x*i+i,-(n.y*a)+a]}let p=e=>1e-10>Math.abs(e)?0:e;function g(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n="matrix3d(";for(let r=0;16!==r;r++)n+=p(t[r]*e.elements[r])+(15!==r?",":")");return r+n}let x=(t=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>g(e,t)),b=(r=e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1],(e,t)=>g(e,r(t),"translate(-50%,-50%)")),y=i.forwardRef((e,t)=>{let{children:r,eps:n=.001,style:a,className:g,prepend:y,center:M,fullscreen:w,portal:S,distanceFactor:P,sprite:E=!1,transform:C=!1,occlude:T,onOcclude:D,castShadow:k,receiveShadow:R,material:F,geometry:W,zIndexRange:j=[0x1000037,0],calculatePosition:U=h,as:L="div",wrapperClass:A,pointerEvents:z="auto",...O}=e,{gl:I,camera:N,scene:G,size:B,raycaster:V,events:H,viewport:_}=(0,u.useThree)(),[J]=i.useState(()=>document.createElement(L)),K=i.useRef(null),Y=i.useRef(null),Z=i.useRef(0),q=i.useRef([0,0]),Q=i.useRef(null),X=i.useRef(null),$=(null==S?void 0:S.current)||H.connected||I.domElement.parentNode,ee=i.useRef(null),et=i.useRef(!1),er=i.useMemo(()=>T&&"blending"!==T||Array.isArray(T)&&T.length&&function(e){return e&&"object"==typeof e&&"current"in e}(T[0]),[T]);i.useLayoutEffect(()=>{let e=I.domElement;T&&"blending"===T?(e.style.zIndex="".concat(Math.floor(j[0]/2)),e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[T]),i.useLayoutEffect(()=>{if(Y.current){let e=K.current=s.createRoot(J);if(G.updateMatrixWorld(),C)J.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{let e=U(Y.current,N,B);J.style.cssText="position:absolute;top:0;left:0;transform:translate3d(".concat(e[0],"px,").concat(e[1],"px,0);transform-origin:0 0;")}return $&&(y?$.prepend(J):$.appendChild(J)),()=>{$&&$.removeChild(J),e.unmount()}}},[$,C]),i.useLayoutEffect(()=>{A&&(J.className=A)},[A]);let en=i.useMemo(()=>C?{position:"absolute",top:0,left:0,width:B.width,height:B.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:M?"translate3d(-50%,-50%,0)":"none",...w&&{top:-B.height/2,left:-B.width/2,width:B.width,height:B.height},...a},[a,M,w,B,C]),ei=i.useMemo(()=>({position:"absolute",pointerEvents:z}),[z]);i.useLayoutEffect(()=>{var e,n;et.current=!1,C?null==(e=K.current)||e.render(i.createElement("div",{ref:Q,style:en},i.createElement("div",{ref:X,style:ei},i.createElement("div",{ref:t,className:g,style:a,children:r})))):null==(n=K.current)||n.render(i.createElement("div",{ref:t,style:en,className:g,children:r}))});let ea=i.useRef(!0);(0,o.useFrame)(e=>{if(Y.current){N.updateMatrixWorld(),Y.current.updateWorldMatrix(!0,!1);let e=C?q.current:U(Y.current,N,B);if(C||Math.abs(Z.current-N.zoom)>n||Math.abs(q.current[0]-e[0])>n||Math.abs(q.current[1]-e[1])>n){let t=function(e,t){let r=d.setFromMatrixPosition(e.matrixWorld),n=f.setFromMatrixPosition(t.matrixWorld),i=r.sub(n),a=t.getWorldDirection(m);return i.angleTo(a)>Math.PI/2}(Y.current,N),r=!1;er&&(Array.isArray(T)?r=T.map(e=>e.current):"blending"!==T&&(r=[G]));let n=ea.current;r?ea.current=function(e,t,r,n){let i=d.setFromMatrixPosition(e.matrixWorld),a=i.clone();a.project(t),v.set(a.x,a.y),r.setFromCamera(v,t);let o=r.intersectObjects(n,!0);if(o.length){let e=o[0].distance;return i.distanceTo(r.ray.origin)<e}return!0}(Y.current,N,V,r)&&!t:ea.current=!t,n!==ea.current&&(D?D(!ea.current):J.style.display=ea.current?"block":"none");let i=Math.floor(j[0]/2),a=T?er?[j[0],i]:[i-1,0]:j;if(J.style.zIndex="".concat(function(e,t,r){if(t instanceof c.PerspectiveCamera||t instanceof c.OrthographicCamera){let n=d.setFromMatrixPosition(e.matrixWorld),i=f.setFromMatrixPosition(t.matrixWorld),a=n.distanceTo(i),o=(r[1]-r[0])/(t.far-t.near),l=r[1]-o*t.far;return Math.round(o*a+l)}}(Y.current,N,a)),C){let[e,t]=[B.width/2,B.height/2],r=N.projectionMatrix.elements[5]*t,{isOrthographicCamera:n,top:i,left:a,bottom:o,right:l}=N,s=x(N.matrixWorldInverse),c=n?"scale(".concat(r,")translate(").concat(p(-(l+a)/2),"px,").concat(p((i+o)/2),"px)"):"translateZ(".concat(r,"px)"),u=Y.current.matrixWorld;E&&((u=N.matrixWorldInverse.clone().transpose().copyPosition(u).scale(Y.current.scale)).elements[3]=u.elements[7]=u.elements[11]=0,u.elements[15]=1),J.style.width=B.width+"px",J.style.height=B.height+"px",J.style.perspective=n?"":"".concat(r,"px"),Q.current&&X.current&&(Q.current.style.transform="".concat(c).concat(s,"translate(").concat(e,"px,").concat(t,"px)"),X.current.style.transform=b(u,1/((P||10)/400)))}else{let t=void 0===P?1:function(e,t){if(t instanceof c.OrthographicCamera)return t.zoom;if(!(t instanceof c.PerspectiveCamera))return 1;{let r=d.setFromMatrixPosition(e.matrixWorld),n=f.setFromMatrixPosition(t.matrixWorld);return 1/(2*Math.tan(t.fov*Math.PI/180/2)*r.distanceTo(n))}}(Y.current,N)*P;J.style.transform="translate3d(".concat(e[0],"px,").concat(e[1],"px,0) scale(").concat(t,")")}q.current=e,Z.current=N.zoom}}if(!er&&ee.current&&!et.current)if(C){if(Q.current){let e=Q.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){let{isOrthographicCamera:t}=N;if(t||W)O.scale&&(Array.isArray(O.scale)?O.scale instanceof c.Vector3?ee.current.scale.copy(O.scale.clone().divideScalar(1)):ee.current.scale.set(1/O.scale[0],1/O.scale[1],1/O.scale[2]):ee.current.scale.setScalar(1/O.scale));else{let t=(P||10)/400,r=e.clientWidth*t,n=e.clientHeight*t;ee.current.scale.set(r,n,1)}et.current=!0}}}else{let t=J.children[0];if(null!=t&&t.clientWidth&&null!=t&&t.clientHeight){let e=1/_.factor,r=t.clientWidth*e,n=t.clientHeight*e;ee.current.scale.set(r,n,1),et.current=!0}ee.current.lookAt(e.camera.position)}});let eo=i.useMemo(()=>({vertexShader:C?void 0:'\n /*\n This shader is from the THREE\'s SpriteMaterial.\n We need to turn the backing plane into a Sprite\n (make it always face the camera) if "transfrom"\n is false.\n */\n #include <common>\n\n void main() {\n vec2 center = vec2(0., 1.);\n float rotation = 0.0;\n\n // This is somewhat arbitrary, but it seems to work well\n // Need to figure out how to derive this dynamically if it even matters\n float size = 0.03;\n\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n }\n ',fragmentShader:"\n void main() {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n "}),[C]);return i.createElement("group",(0,l.default)({},O,{ref:Y}),T&&!er&&i.createElement("mesh",{castShadow:k,receiveShadow:R,ref:ee},W||i.createElement("planeGeometry",null),F||i.createElement("shaderMaterial",{side:c.DoubleSide,vertexShader:eo.vertexShader,fragmentShader:eo.fragmentShader})))}),M=[0,0,0],w=(0,i.memo)(function(e){let{children:t,color:r="white",position:l=M,opacity:s="fadeWithDistance"}=e,c="fadeWithDistance"===s,u=(0,i.useRef)(null),d=(0,a.useDistanceFromCamera)(u),[f,m]=(0,i.useState)(0!==s),v=(0,i.useRef)(null);return(0,i.useEffect)(()=>{if(c&&v.current&&null!=d.current){let e=Math.max(0,Math.min(1,1-d.current/200));v.current.style.opacity=e.toString()}},[f,c]),(0,o.useFrame)(()=>{if(c){let e=d.current,t=null!=e&&e<200;if(f!==t&&m(t),v.current&&t){let t=Math.max(0,Math.min(1,1-e/200));v.current.style.opacity=t.toString()}}else m(0!==s),v.current&&(v.current.style.opacity=s.toString())}),(0,n.jsx)("group",{ref:u,children:f?(0,n.jsx)(y,{position:l,center:!0,children:(0,n.jsx)("div",{ref:v,className:"StaticShapeLabel",style:{color:r},children:t})}):null})})},51434,e=>{"use strict";e.s(["AudioProvider",()=>o,"useAudio",()=>l]);var t=e.i(43476),r=e.i(71645),n=e.i(16096),i=e.i(90072);let a=(0,r.createContext)(void 0);function o(e){let{children:o}=e,{camera:l}=(0,n.useThree)(),[s,c]=(0,r.useState)({audioLoader:null,audioListener:null});return(0,r.useEffect)(()=>{let e=new i.AudioLoader,t=l.children.find(e=>e instanceof i.AudioListener);t||(t=new i.AudioListener,l.add(t)),c({audioLoader:e,audioListener:t})},[l]),(0,t.jsx)(a.Provider,{value:s,children:o})}function l(){let e=(0,r.useContext)(a);if(void 0===e)throw Error("useAudio must be used within AudioProvider");return e}},61921,e=>{e.v(t=>Promise.all(["static/chunks/5342f4b5b8c465ca.js"].map(t=>e.l(t))).then(()=>t(29055)))},25147,e=>{e.v(t=>Promise.all(["static/chunks/4d7806fca1de54cc.js"].map(t=>e.l(t))).then(()=>t(63724)))},18599,e=>{e.v(t=>Promise.all(["static/chunks/dff8ab8fc8f27466.js"].map(t=>e.l(t))).then(()=>t(42585)))}]);