@needle-tools/engine 4.13.0-next.e6dcd1c → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{materialx-DTdTjiOL.min.js → materialx-B9ddsHcF.min.js} +18 -18
- package/dist/{materialx-CnsT47BY.umd.cjs → materialx-BF23AVE8.umd.cjs} +9 -9
- package/dist/{materialx-DUlX6ZVi.js → materialx-fkoFuRh3.js} +215 -221
- package/dist/{needle-engine.bundle-zcyz7kwz.min.js → needle-engine.bundle-CxaKFQVS.min.js} +4 -4
- package/dist/{needle-engine.bundle-_--DT-Vr.js → needle-engine.bundle-Dl3TFYyv.js} +9 -8
- package/dist/{needle-engine.bundle-DGrKAD9m.umd.cjs → needle-engine.bundle-J4k4znv8.umd.cjs} +6 -6
- package/dist/needle-engine.d.ts +15 -15
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine-components/ReflectionProbe.js +11 -7
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/package.json +3 -3
- package/src/engine-components/ReflectionProbe.ts +12 -8
|
@@ -141,7 +141,7 @@ void main(){
|
|
|
141
141
|
#__vconsole .vc-mask {
|
|
142
142
|
overflow: hidden;
|
|
143
143
|
}
|
|
144
|
-
`,Sr?.prepend(i),o===!0&&Zb()<=0&&S_(),console.log("\u{1F335} Debug console has loaded")}},e.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),yc=!1,di=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function $O(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+o._id+" iframe");return o.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const s=n.indexOf("?");s>-1&&(n=n.substring(0,s));const r=location.protocol+"//"+location.host+location.pathname+"/"+n,a=encodeURIComponent(r);o.fullUrl="https://viewer.needle.tools?inspect&file="+a;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),o.on("show",function(){const t=e();t&&t.src!==o.fullUrl&&(t.src=o.fullUrl)}),o.on("hide",function(){const t=e();t&&(t.src="")}),o.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window \u2197",onClick:function(n){window.open(o.fullUrl,"_blank"),di?.hide()}}),i.push({name:"Reload",onClick:function(n){const s=e();s&&(s.src=o.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const s=e();s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen instanceof Function&&s.webkitRequestFullscreen()}}),t(i)}),o}const dg="padding: 10px; font-family: monospace;",P_="margin-bottom: 10px;",Cr="margin-bottom: 10px; margin-top: 15px;",HO="width: 100%; border-collapse: collapse; border: 1px solid rgba(0,0,0,0.1); table-layout: fixed;",O_="border: 1px solid rgba(0,0,0,0.1); padding: 5px;",GO=O_,qO=O_+" word-break: break-all;";function qn(o,e=!1){e&&o.sort((i,n)=>(n.value?1:0)-(i.value?1:0));let t=`<table style='${HO}'>`;t+="<tbody>";for(const i of o){const n=typeof i.value=="boolean"?i.value?"\u2705":"\u274C":i.value;t+=`<tr><td style='${GO}'>${i.label}</td><td style='${qO}'>${n}</td></tr>`}return t+="</tbody></table>",t}function k_(){try{if(document.createElement("canvas").getContext("webgl2"))return"\u2705"}catch{}return"\u274C"}function XO(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("device-utilities","\u{1F4F1} Device Info");return o.on("renderTab",function(e){let t=`<div style='${dg}'>`;const i=ok();t+=`<h3 style='${P_}'>Device: ${i}</h3>`,t+=qn([{label:"\u{1F4BB} Desktop",value:I.isDesktop()},{label:"\u{1F4F1} Mobile Device",value:I.isMobileDevice()},{label:"\u{1F34E} iOS",value:I.isiOS()},{label:"\u{1F4F1} iPad",value:I.isiPad()},{label:"\u{1F916} Android",value:I.isAndroidDevice()},{label:"\u{1F98A} Mozilla XR",value:I.isMozillaXR()},{label:"\u{1F335} Needle App Clip",value:I.isNeedleAppClip()},{label:"\u{1F34F} macOS",value:I.isMacOS()},{label:"\u{1F453} VisionOS",value:I.isVisionOS()},{label:"\u{1F9ED} Safari",value:I.isSafari()},{label:"\u{1F576}\uFE0F Meta Quest",value:I.isQuest()},{label:"\u{1F517} QuickLook AR Support",value:I.supportsQuickLookAR()}],!0);const n=[],s=I.getiOSVersion();s&&n.push({label:"\u{1F34E} iOS Version",value:s});const r=I.getChromeVersion();r&&n.push({label:"\u{1F310} Chrome Version",value:r});const a=I.getSafariVersion();a&&n.push({label:"\u{1F9ED} Safari Version",value:a}),n.length>0&&(t+=qn(n,!1)),t+="</div>",t+=`<div style='${dg} margin-top: 20px;'>`,t+=`<h3 style='${P_}'>User Agent Info</h3>`;const l=[{label:"User Agent",value:navigator.userAgent},{label:"Platform",value:navigator.platform},{label:"App Version",value:navigator.appVersion},{label:"User Agent Data",value:navigator.userAgentData?`Platform: ${navigator.userAgentData.platform}, Mobile: ${navigator.userAgentData.mobile}`:"Not supported"},{label:"WebXR",value:"xr"in navigator?"\u2705":"\u274C"},{label:"WebGPU",value:"gpu"in navigator?"\u2705":"\u274C"},{label:"WebGL 2",value:k_()}];t+=qn(l,!1),t+="</div>",e(t)}),o}function QO(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("graphics-info","\u{1F3A8} Graphics Info");return o.on("renderTab",async function(e){let t=`<div style='${dg}'>`;const i=YO();i.length>0&&(t+=`<h3 style='${Cr}'>General GPU Info</h3>`,t+=qn(i,!1));const n=KO();n.length>0&&(t+=`<h3 style='${Cr}'>WebGL</h3>`,t+=qn(n,!1));const s=JO();s.length>0&&(t+=`<h3 style='${Cr}'>WebGL 2 Features</h3>`,t+=qn(s,!1));const r=ek();r.length>0&&(t+=`<h3 style='${Cr}'>WebGL Limits</h3>`,t+=qn(r,!1));const a=tk();a.length>0&&(t+=`<h3 style='${Cr}'>Texture Formats</h3>`,t+=qn(a,!1));const l=await ik();if(l.length>0&&(t+=`<h3 style='${Cr}'>WebGPU</h3>`,t+=qn(l,!1)),I.isSafari()){const c=nk();c.length>0&&(t+=`<h3 style='${Cr}'>Safari GPU Info</h3>`,t+=qn(c,!1))}t+="</div>",e(t)}),o}function YO(){const o=[],e=window.devicePixelRatio;o.push({label:"Device Pixel Ratio",value:e.toString()}),o.push({label:"Width (px)",value:(window.innerWidth*e).toString()}),o.push({label:"Height (px)",value:(window.innerHeight*e).toString()});const t=I.isMobileDevice()?150:96,i=screen.width/t,n=screen.height/t,s=i*2.54,r=n*2.54;o.push({label:"Estimated Width (cm)",value:s.toFixed(1)}),o.push({label:"Estimated Height (cm)",value:r.toFixed(1)});const a=M_();if(a){o.push({label:"GPU",value:a.renderer}),o.push({label:"Driver",value:a.vendor}),o.push({label:"ANGLE",value:a.angle||"Not detected"});const l=ZO(a.renderer);l&&(l.manufacturer&&o.push({label:"Manufacturer",value:l.manufacturer}),l.cardVersion&&o.push({label:"Card Version",value:l.cardVersion}),l.brand&&o.push({label:"Brand",value:l.brand}),o.push({label:"Integrated",value:l.integrated?"Yes":"No"}),l.layer&&o.push({label:"WebGL Layer",value:l.layer}))}return o}function ZO(o){if(!o)return null;const e=(l,c)=>{const h=c.match(l);return h&&h[0]},t=e(/(ANGLE)/g,o)||void 0,i=e(/((NVIDIA|AMD|Intel)[^\d]*[^\s]+)/,o)||o,n=i.split(" ");n.shift();const s=e(/(NVIDIA|AMD|Intel)/g,i)||void 0,r=n.length>0?n.pop():void 0,a=n.length>0?n.join(" "):void 0;return{manufacturer:s,cardVersion:r,brand:a,integrated:s==="Intel",layer:t,card:i}}function KO(){const o=[],e=M_();return e&&(o.push({label:"\u{1F4CA} WebGL Version",value:e.version}),o.push({label:"\u{1F3AE} WebGL 2 Available",value:k_()})),o}function JO(){const o=[];try{const e=document.createElement("canvas").getContext("webgl2");if(!e)return o;o.push({label:"Float Color Buffer",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"Anisotropic Filtering",value:e.getExtension("EXT_texture_filter_anisotropic")?"\u2705":"\u274C"}),o.push({label:"Float Texture Linear",value:e.getExtension("OES_texture_float_linear")?"\u2705":"\u274C"}),o.push({label:"S3TC Compression",value:e.getExtension("WEBGL_compressed_texture_s3tc")?"\u2705":"\u274C"}),o.push({label:"ETC Compression",value:e.getExtension("WEBGL_compressed_texture_etc")?"\u2705":"\u274C"}),o.push({label:"PVRTC Compression",value:e.getExtension("WEBGL_compressed_texture_pvrtc")?"\u2705":"\u274C"}),o.push({label:"ASTC Compression",value:e.getExtension("WEBGL_compressed_texture_astc")?"\u2705":"\u274C"})}catch{}return o}function ek(){const o=[];try{const e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl");if(!t)return o;const i=t instanceof WebGL2RenderingContext;o.push({label:"\u{1F4CF} Max Texture Size",value:t.getParameter(t.MAX_TEXTURE_SIZE).toString()}),o.push({label:"\u{1F3A8} Max Renderbuffer Size",value:t.getParameter(t.MAX_RENDERBUFFER_SIZE).toString()}),o.push({label:"\u{1F517} Max Vertex Attribs",value:t.getParameter(t.MAX_VERTEX_ATTRIBS).toString()}),o.push({label:"\u{1F3AF} Max Texture Units",value:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS).toString()}),i&&(o.push({label:"\u26A1 Max Samples",value:t.getParameter(t.MAX_SAMPLES).toString()}),o.push({label:"\u{1F504} Max Uniform Buffer Bindings",value:t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS).toString()}),o.push({label:"\u{1F4D0} Max 3D Texture Size",value:t.getParameter(t.MAX_3D_TEXTURE_SIZE).toString()}))}catch{}return o}function tk(){const o=[];try{document.createElement("canvas").getContext("webgl")&&(o.push({label:"WebGL 1 RGBA",value:"\u2705"}),o.push({label:"WebGL 1 RGB",value:"\u2705"}));const e=document.createElement("canvas").getContext("webgl2");e&&(o.push({label:"WebGL 2 RGBA32F",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"WebGL 2 RGB32F",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"WebGL 2 R11F_G11F_B10F",value:"\u2705"}),o.push({label:"WebGL 2 RGB565",value:"\u2705"}),o.push({label:"WebGL 2 RGB5_A1",value:"\u2705"}),o.push({label:"WebGL 2 RGBA4444",value:"\u2705"}))}catch{}return o}async function ik(){const o=[];if(!("gpu"in navigator))return o.push({label:"\u{1F680} WebGPU Support",value:"\u274C Not supported"}),o;o.push({label:"\u{1F680} WebGPU Support",value:"\u2705 Supported"});try{const e=await navigator.gpu.requestAdapter();if(!e)return o.push({label:"\u{1F3AF} Adapter",value:"No adapter available"}),o;o.push({label:"\u{1F3AF} Adapter",value:e.name||"Unknown Adapter"});const t=await e.requestDevice();o.push({label:"\u{1F527} Device",value:t.label||"WebGPU Device"}),o.push({label:"\u{1F4CF} Max Texture 2D",value:t.limits.maxTextureDimension2D.toString()}),o.push({label:"\u{1F4D0} Max Texture 3D",value:t.limits.maxTextureDimension3D.toString()}),o.push({label:"\u{1F4CA} Max Texture Array Layers",value:t.limits.maxTextureArrayLayers.toString()}),o.push({label:"\u{1F4BE} Max Buffer Size",value:`${(t.limits.maxBufferSize/1024/1024).toFixed(1)}MB`}),o.push({label:"\u{1F517} Max Bind Groups",value:t.limits.maxBindGroups.toString()})}catch(e){o.push({label:"\u274C Error",value:e.message})}return o}function M_(){try{const o=document.createElement("canvas"),e=o.getContext("webgl2")||o.getContext("webgl");if(!e)return null;const t=e.getExtension("WEBGL_debug_renderer_info"),i=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),n=t?e.getParameter(t.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR),s=e.getParameter(e.VERSION);let r;if(i&&i.includes("ANGLE")){const a=i.match(/ANGLE \(([^)]+)\)/);a&&(r=a[1])}return{renderer:i,vendor:n,version:s,angle:r}}catch{return null}}function nk(){const o=[];try{const e=document.createElement("canvas").getContext("webgl");if(e){const t=e.getExtension("WEBGL_debug_renderer_info");if(t){const i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);i&&i.includes("Apple")&&o.push({label:"\u{1F34E} Apple GPU",value:i})}}}catch{}try{const e=document.createElement("canvas").getContext("webgl");e&&(e.getSupportedExtensions()||[]).includes("WEBGL_compressed_texture_pvrtc")&&o.push({label:"\u{1F5DC}\uFE0F PVRTC Support",value:"\u2705"})}catch{}return o}function ok(){return I.isQuest()?"Meta Quest":I.isVisionOS()?"Vision Pro":I.isiOS()?I.isiPad()?"iPad":"iPhone/iPod":I.isAndroidDevice()?"Android Device":I.isMozillaXR()?"Mozilla XR Browser":I.isNeedleAppClip()?"Needle App Clip":I.isMacOS()?"Mac":I.isDesktop()?"Desktop PC":"Unknown Device"}function sk(){return document.querySelector("#__vconsole .vc-switch")||null}function rk(){return document.querySelector("#__vconsole")||null}const R_=v("debugdefines");ws('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";'),ws('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";'),ws('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";'),ws('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";'),ws('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.13.0";'),ws('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),ws('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Feb 10 2026 21:11:09 GMT+0000 (Coordinated Universal Time)";'),ws('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const Ai="4.13.0",Ua="undefined",bc="Tue Feb 10 2026 21:11:09 GMT+0000 (Coordinated Universal Time)";R_&&console.log(`Engine version: ${Ai} (generator: ${Ua})
|
|
144
|
+
`,Sr?.prepend(i),o===!0&&Zb()<=0&&S_(),console.log("\u{1F335} Debug console has loaded")}},e.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),yc=!1,di=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function $O(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+o._id+" iframe");return o.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const s=n.indexOf("?");s>-1&&(n=n.substring(0,s));const r=location.protocol+"//"+location.host+location.pathname+"/"+n,a=encodeURIComponent(r);o.fullUrl="https://viewer.needle.tools?inspect&file="+a;var l='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(l)}),o.on("show",function(){const t=e();t&&t.src!==o.fullUrl&&(t.src=o.fullUrl)}),o.on("hide",function(){const t=e();t&&(t.src="")}),o.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window \u2197",onClick:function(n){window.open(o.fullUrl,"_blank"),di?.hide()}}),i.push({name:"Reload",onClick:function(n){const s=e();s&&(s.src=o.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const s=e();s.requestFullscreen?s.requestFullscreen():s.webkitRequestFullscreen instanceof Function&&s.webkitRequestFullscreen()}}),t(i)}),o}const dg="padding: 10px; font-family: monospace;",P_="margin-bottom: 10px;",Cr="margin-bottom: 10px; margin-top: 15px;",HO="width: 100%; border-collapse: collapse; border: 1px solid rgba(0,0,0,0.1); table-layout: fixed;",O_="border: 1px solid rgba(0,0,0,0.1); padding: 5px;",GO=O_,qO=O_+" word-break: break-all;";function qn(o,e=!1){e&&o.sort((i,n)=>(n.value?1:0)-(i.value?1:0));let t=`<table style='${HO}'>`;t+="<tbody>";for(const i of o){const n=typeof i.value=="boolean"?i.value?"\u2705":"\u274C":i.value;t+=`<tr><td style='${GO}'>${i.label}</td><td style='${qO}'>${n}</td></tr>`}return t+="</tbody></table>",t}function k_(){try{if(document.createElement("canvas").getContext("webgl2"))return"\u2705"}catch{}return"\u274C"}function XO(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("device-utilities","\u{1F4F1} Device Info");return o.on("renderTab",function(e){let t=`<div style='${dg}'>`;const i=ok();t+=`<h3 style='${P_}'>Device: ${i}</h3>`,t+=qn([{label:"\u{1F4BB} Desktop",value:I.isDesktop()},{label:"\u{1F4F1} Mobile Device",value:I.isMobileDevice()},{label:"\u{1F34E} iOS",value:I.isiOS()},{label:"\u{1F4F1} iPad",value:I.isiPad()},{label:"\u{1F916} Android",value:I.isAndroidDevice()},{label:"\u{1F98A} Mozilla XR",value:I.isMozillaXR()},{label:"\u{1F335} Needle App Clip",value:I.isNeedleAppClip()},{label:"\u{1F34F} macOS",value:I.isMacOS()},{label:"\u{1F453} VisionOS",value:I.isVisionOS()},{label:"\u{1F9ED} Safari",value:I.isSafari()},{label:"\u{1F576}\uFE0F Meta Quest",value:I.isQuest()},{label:"\u{1F517} QuickLook AR Support",value:I.supportsQuickLookAR()}],!0);const n=[],s=I.getiOSVersion();s&&n.push({label:"\u{1F34E} iOS Version",value:s});const r=I.getChromeVersion();r&&n.push({label:"\u{1F310} Chrome Version",value:r});const a=I.getSafariVersion();a&&n.push({label:"\u{1F9ED} Safari Version",value:a}),n.length>0&&(t+=qn(n,!1)),t+="</div>",t+=`<div style='${dg} margin-top: 20px;'>`,t+=`<h3 style='${P_}'>User Agent Info</h3>`;const l=[{label:"User Agent",value:navigator.userAgent},{label:"Platform",value:navigator.platform},{label:"App Version",value:navigator.appVersion},{label:"User Agent Data",value:navigator.userAgentData?`Platform: ${navigator.userAgentData.platform}, Mobile: ${navigator.userAgentData.mobile}`:"Not supported"},{label:"WebXR",value:"xr"in navigator?"\u2705":"\u274C"},{label:"WebGPU",value:"gpu"in navigator?"\u2705":"\u274C"},{label:"WebGL 2",value:k_()}];t+=qn(l,!1),t+="</div>",e(t)}),o}function QO(){if(!globalThis.VConsole)return;const o=new VConsole.VConsolePlugin("graphics-info","\u{1F3A8} Graphics Info");return o.on("renderTab",async function(e){let t=`<div style='${dg}'>`;const i=YO();i.length>0&&(t+=`<h3 style='${Cr}'>General GPU Info</h3>`,t+=qn(i,!1));const n=KO();n.length>0&&(t+=`<h3 style='${Cr}'>WebGL</h3>`,t+=qn(n,!1));const s=JO();s.length>0&&(t+=`<h3 style='${Cr}'>WebGL 2 Features</h3>`,t+=qn(s,!1));const r=ek();r.length>0&&(t+=`<h3 style='${Cr}'>WebGL Limits</h3>`,t+=qn(r,!1));const a=tk();a.length>0&&(t+=`<h3 style='${Cr}'>Texture Formats</h3>`,t+=qn(a,!1));const l=await ik();if(l.length>0&&(t+=`<h3 style='${Cr}'>WebGPU</h3>`,t+=qn(l,!1)),I.isSafari()){const c=nk();c.length>0&&(t+=`<h3 style='${Cr}'>Safari GPU Info</h3>`,t+=qn(c,!1))}t+="</div>",e(t)}),o}function YO(){const o=[],e=window.devicePixelRatio;o.push({label:"Device Pixel Ratio",value:e.toString()}),o.push({label:"Width (px)",value:(window.innerWidth*e).toString()}),o.push({label:"Height (px)",value:(window.innerHeight*e).toString()});const t=I.isMobileDevice()?150:96,i=screen.width/t,n=screen.height/t,s=i*2.54,r=n*2.54;o.push({label:"Estimated Width (cm)",value:s.toFixed(1)}),o.push({label:"Estimated Height (cm)",value:r.toFixed(1)});const a=M_();if(a){o.push({label:"GPU",value:a.renderer}),o.push({label:"Driver",value:a.vendor}),o.push({label:"ANGLE",value:a.angle||"Not detected"});const l=ZO(a.renderer);l&&(l.manufacturer&&o.push({label:"Manufacturer",value:l.manufacturer}),l.cardVersion&&o.push({label:"Card Version",value:l.cardVersion}),l.brand&&o.push({label:"Brand",value:l.brand}),o.push({label:"Integrated",value:l.integrated?"Yes":"No"}),l.layer&&o.push({label:"WebGL Layer",value:l.layer}))}return o}function ZO(o){if(!o)return null;const e=(l,c)=>{const h=c.match(l);return h&&h[0]},t=e(/(ANGLE)/g,o)||void 0,i=e(/((NVIDIA|AMD|Intel)[^\d]*[^\s]+)/,o)||o,n=i.split(" ");n.shift();const s=e(/(NVIDIA|AMD|Intel)/g,i)||void 0,r=n.length>0?n.pop():void 0,a=n.length>0?n.join(" "):void 0;return{manufacturer:s,cardVersion:r,brand:a,integrated:s==="Intel",layer:t,card:i}}function KO(){const o=[],e=M_();return e&&(o.push({label:"\u{1F4CA} WebGL Version",value:e.version}),o.push({label:"\u{1F3AE} WebGL 2 Available",value:k_()})),o}function JO(){const o=[];try{const e=document.createElement("canvas").getContext("webgl2");if(!e)return o;o.push({label:"Float Color Buffer",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"Anisotropic Filtering",value:e.getExtension("EXT_texture_filter_anisotropic")?"\u2705":"\u274C"}),o.push({label:"Float Texture Linear",value:e.getExtension("OES_texture_float_linear")?"\u2705":"\u274C"}),o.push({label:"S3TC Compression",value:e.getExtension("WEBGL_compressed_texture_s3tc")?"\u2705":"\u274C"}),o.push({label:"ETC Compression",value:e.getExtension("WEBGL_compressed_texture_etc")?"\u2705":"\u274C"}),o.push({label:"PVRTC Compression",value:e.getExtension("WEBGL_compressed_texture_pvrtc")?"\u2705":"\u274C"}),o.push({label:"ASTC Compression",value:e.getExtension("WEBGL_compressed_texture_astc")?"\u2705":"\u274C"})}catch{}return o}function ek(){const o=[];try{const e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl");if(!t)return o;const i=t instanceof WebGL2RenderingContext;o.push({label:"\u{1F4CF} Max Texture Size",value:t.getParameter(t.MAX_TEXTURE_SIZE).toString()}),o.push({label:"\u{1F3A8} Max Renderbuffer Size",value:t.getParameter(t.MAX_RENDERBUFFER_SIZE).toString()}),o.push({label:"\u{1F517} Max Vertex Attribs",value:t.getParameter(t.MAX_VERTEX_ATTRIBS).toString()}),o.push({label:"\u{1F3AF} Max Texture Units",value:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS).toString()}),i&&(o.push({label:"\u26A1 Max Samples",value:t.getParameter(t.MAX_SAMPLES).toString()}),o.push({label:"\u{1F504} Max Uniform Buffer Bindings",value:t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS).toString()}),o.push({label:"\u{1F4D0} Max 3D Texture Size",value:t.getParameter(t.MAX_3D_TEXTURE_SIZE).toString()}))}catch{}return o}function tk(){const o=[];try{document.createElement("canvas").getContext("webgl")&&(o.push({label:"WebGL 1 RGBA",value:"\u2705"}),o.push({label:"WebGL 1 RGB",value:"\u2705"}));const e=document.createElement("canvas").getContext("webgl2");e&&(o.push({label:"WebGL 2 RGBA32F",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"WebGL 2 RGB32F",value:e.getExtension("EXT_color_buffer_float")?"\u2705":"\u274C"}),o.push({label:"WebGL 2 R11F_G11F_B10F",value:"\u2705"}),o.push({label:"WebGL 2 RGB565",value:"\u2705"}),o.push({label:"WebGL 2 RGB5_A1",value:"\u2705"}),o.push({label:"WebGL 2 RGBA4444",value:"\u2705"}))}catch{}return o}async function ik(){const o=[];if(!("gpu"in navigator))return o.push({label:"\u{1F680} WebGPU Support",value:"\u274C Not supported"}),o;o.push({label:"\u{1F680} WebGPU Support",value:"\u2705 Supported"});try{const e=await navigator.gpu.requestAdapter();if(!e)return o.push({label:"\u{1F3AF} Adapter",value:"No adapter available"}),o;o.push({label:"\u{1F3AF} Adapter",value:e.name||"Unknown Adapter"});const t=await e.requestDevice();o.push({label:"\u{1F527} Device",value:t.label||"WebGPU Device"}),o.push({label:"\u{1F4CF} Max Texture 2D",value:t.limits.maxTextureDimension2D.toString()}),o.push({label:"\u{1F4D0} Max Texture 3D",value:t.limits.maxTextureDimension3D.toString()}),o.push({label:"\u{1F4CA} Max Texture Array Layers",value:t.limits.maxTextureArrayLayers.toString()}),o.push({label:"\u{1F4BE} Max Buffer Size",value:`${(t.limits.maxBufferSize/1024/1024).toFixed(1)}MB`}),o.push({label:"\u{1F517} Max Bind Groups",value:t.limits.maxBindGroups.toString()})}catch(e){o.push({label:"\u274C Error",value:e.message})}return o}function M_(){try{const o=document.createElement("canvas"),e=o.getContext("webgl2")||o.getContext("webgl");if(!e)return null;const t=e.getExtension("WEBGL_debug_renderer_info"),i=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),n=t?e.getParameter(t.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR),s=e.getParameter(e.VERSION);let r;if(i&&i.includes("ANGLE")){const a=i.match(/ANGLE \(([^)]+)\)/);a&&(r=a[1])}return{renderer:i,vendor:n,version:s,angle:r}}catch{return null}}function nk(){const o=[];try{const e=document.createElement("canvas").getContext("webgl");if(e){const t=e.getExtension("WEBGL_debug_renderer_info");if(t){const i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);i&&i.includes("Apple")&&o.push({label:"\u{1F34E} Apple GPU",value:i})}}}catch{}try{const e=document.createElement("canvas").getContext("webgl");e&&(e.getSupportedExtensions()||[]).includes("WEBGL_compressed_texture_pvrtc")&&o.push({label:"\u{1F5DC}\uFE0F PVRTC Support",value:"\u2705"})}catch{}return o}function ok(){return I.isQuest()?"Meta Quest":I.isVisionOS()?"Vision Pro":I.isiOS()?I.isiPad()?"iPad":"iPhone/iPod":I.isAndroidDevice()?"Android Device":I.isMozillaXR()?"Mozilla XR Browser":I.isNeedleAppClip()?"Needle App Clip":I.isMacOS()?"Mac":I.isDesktop()?"Desktop PC":"Unknown Device"}function sk(){return document.querySelector("#__vconsole .vc-switch")||null}function rk(){return document.querySelector("#__vconsole")||null}const R_=v("debugdefines");ws('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";'),ws('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";'),ws('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";'),ws('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";'),ws('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.13.0";'),ws('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),ws('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Feb 11 2026 13:53:06 GMT+0000 (Coordinated Universal Time)";'),ws('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const Ai="4.13.0",Ua="undefined",bc="Wed Feb 11 2026 13:53:06 GMT+0000 (Coordinated Universal Time)";R_&&console.log(`Engine version: ${Ai} (generator: ${Ua})
|
|
145
145
|
Project built at ${bc}`);const vs=NEEDLE_PUBLIC_KEY,To="needle_isActiveInHierarchy",Pr="builtin_components",_c="needle_editor_guid";function ws(o){try{(0,eval)(o)}catch(e){R_&&console.error(e)}}let E_,T_=null;function Cn(){return E_}function ug(o){if(o==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}T_!==o&&(T_=o,E_=new o)}function ak(o,e){if(typeof window!==void 0&&window.SPECTOR){console.log(window.SPECTOR);const t=new URLSearchParams(window.location.search);if(t.has("spector")){let i=function(){if(n>o.time.frame)return window.requestAnimationFrame(()=>i());const r=s.captureCanvas(e);r&&r instanceof Promise?r.then(()=>s.displayUI()):s.displayUI()};const n=Number.parseInt(t.get("spector")||"0")||0;console.log("Scheduled Spector capture at frame #"+n);const s=new window.SPECTOR.Spector;s.spyCanvases=!0,i();return}else A()&&console.debug("Spector available: Add '?spector=<frame>' to the URL to enable it and capture a frame.")}}const Ii=Symbol("shadowDomOwner"),lk=v("debugpatch");function qd(o,e,t,i){const n=lk===e;if(!t&&!i)return;const s=e+"___needle";hk(o,e,t,i);const r=Object.getOwnPropertyDescriptor(o,e),a=o[e];n&&console.log("Patch",o.constructor.name,e,r,a),r?(n&&console.log("Apply patch with existing descriptor",o.constructor.name,e,r),typeof r.value=="function"&&(o[e]=I_(r.value,o,e))):(n&&console.log("Create patch with new property",o.constructor.name,e,r),Object.defineProperty(o,e,{set:function(l){if(typeof l=="function")this[s]=I_(l,o,e);else{const c=this[s];L_(o,e,this,c,l),this[s]=l,D_(o,e,this,c,l)}},get:function(){const l=this[s];return typeof l=="function"&&l[s]?l[s]:l}}))}function ck(o,e,t){const i=mg(o,e);if(i)for(let n=i.length-1;n>=0;n--){const s=i[n];s.prefix===t&&(s.prefix=null),s.postfix===t&&(s.postfix=null),!s.prefix&&!s.postfix&&i.splice(n,1)}}const A_=Symbol("Needle:Patches:WrappedFunction");function I_(o,e,t){if(o[A_])return o;const i=function(...n){L_(e,t,this,...n);const s=o.apply(this,n);return D_(e,t,this,s,...n),s};return i[A_]=!0,i}const Xd="Needle:Patches";function pg(){return globalThis[Xd]||(globalThis[Xd]=new WeakMap),globalThis[Xd]}function mg(o,e){const t=pg().get(o);return t?t.get(e):null}function hk(o,e,t,i){let n=pg().get(o);n||(n=new Map,pg().set(o,n));let s=n.get(e);s||(s=[],n.set(e,s)),s.push({prefix:t,postfix:i})}function L_(o,e,t,...i){if(!t)return;const n=mg(o,e);if(n)for(const s of n)s.prefix?.call(t,...i)}function D_(o,e,t,i,...n){if(!t)return;const s=mg(o,e);if(s)for(const r of s)r.postfix?.call(t,i,...n)}const za=[];function Qd(o){za.indexOf(o)===-1&&za.push(o)}function dk(o){const e=za.indexOf(o);e!==-1&&za.splice(e,1)}const Na=[];function gg(o){Na.indexOf(o)===-1&&Na.push(o)}function uk(o){const e=Na.indexOf(o);e!==-1&&Na.splice(e,1)}function j_(o){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:o}));for(let e=0;e<za.length;e++)za[e](o)}function B_(o){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:o}));for(let e=0;e<Na.length;e++)Na[e](o)}const qe=v("debuginput");var Yd=(o=>(o.Mouse="mouse",o.Touch="touch",o.Controller="controller",o.Hand="hand",o))(Yd||{}),Te=(o=>(o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerMove="pointermove",o.KeyDown="keydown",o.KeyUp="keyup",o.KeyPressed="keypress",o))(Te||{});class Ao extends PointerEvent{clientZ;deviceIndex;origin;source;mode;get isSpatial(){return this.mode!="screen"}get ray(){return this._ray||(this._ray=new So(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(e){this._ray=e}get hasRay(){return this._ray!==void 0}_ray;space;isClick=!1;isDoubleClick=!1;get used(){return this._used}_used=!1;use(){this._used=!0}get pointerId(){return this._pointerid}_pointerid;get pointerType(){return this._pointerType}_pointerType;buttonName=void 0;get type(){return this._type}_type;metadata={};intersections=new Array;constructor(e,t,i){super(e,i),this.clientZ=i.clientZ,this._pointerid=i.pointerId,this._pointerType=i.pointerType,this._type=e,this.deviceIndex=i.deviceIndex,this.origin=i.origin,this.source=t,this.mode=i.mode,this._ray=i.ray,this.space=i.device,this.buttonName=i.buttonName}_immediatePropagationStopped=!1;get immediatePropagationStopped(){return this._immediatePropagationStopped}_propagationStopped=!1;get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),this.source?.stopImmediatePropagation()}stopPropagation(){this._propagationStopped=!0,super.stopPropagation(),this.source?.stopPropagation(),qe&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class vc extends KeyboardEvent{source;constructor(e,t,i){super(e,i),this.source=t}stopImmediatePropagation(){super.stopImmediatePropagation(),this.source?.stopImmediatePropagation()}}class pk{key;keyType;source;constructor(e){this.key=e.key,this.keyType=e.type,this.source=e}}var ui=(o=>(o[o.Early=-100]="Early",o[o.Default=0]="Default",o[o.Late=100]="Late",o))(ui||{});class F_{_eventListeners={};addEventListener(e,t,i){if(this._eventListeners[e]||(this._eventListeners[e]=[]),!t||typeof t!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}i?i={...i}:i={};let n=0;i?.queue!=null&&(n=i.queue);const s=this._eventListeners[e],r=s.find(a=>a.priority===n);r?r.listeners.push({callback:t,options:i}):(s.push({priority:n,listeners:[{callback:t,options:i}]}),s.sort((a,l)=>a.priority-l.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e]||!t)return;const n=this._eventListeners[e];if(i?.queue!=null){const s=n.find(a=>a.priority===i.queue);if(!s)return;const r=s.listeners.findIndex(a=>a.callback===t);r>=0&&s.listeners.splice(r,1)}else for(const s of n){const r=s.listeners.findIndex(a=>a.callback===t);r>=0&&s.listeners.splice(r,1)}}dispatchEvent(e){let t=!1;if(e instanceof vc){const i=this._eventListeners[e.type];if(i)for(const n of i)for(let s=0;s<n.listeners.length;s++){const r=n.listeners[s];if(r.options?.signal?.aborted){n.listeners.splice(s,1),s--;continue}r.options.once&&(n.listeners.splice(s,1),s--),r.callback(e)}}if(e instanceof Ao){const i=this._eventListeners[e.type];if(i)for(const n of i){if(t)break;for(let s=0;s<n.listeners.length;s++){const r=n.listeners[s];if(r.options?.signal?.aborted){n.listeners.splice(s,1),s--;continue}if(e.immediatePropagationStopped){t=!0,qe&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,qe&&console.log("propagationStopped",e.type));r.options.once&&(n.listeners.splice(s,1),s--),r.callback(e)}}}}_doubleClickTimeThreshold=.2;_longPressTimeThreshold=1;get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}get click(){return this._pointerClick[0]}get doubleClick(){return this._pointerDoubleClick[0]}getGamepad(e=0){return typeof navigator<"u"&&"getGamepads"in navigator&&navigator.getGamepads()[e]||null}_setCursorTypes=[];setCursorPointer(){this.setCursor("pointer")}setCursorNormal(){this.unsetCursor("pointer")}setCursor(e){this._setCursorTypes.push(e),this._setCursorTypes.length>10&&this._setCursorTypes.shift(),this.updateCursor()}unsetCursor(e){for(let t=this._setCursorTypes.length-1;t>=0;t--)if(this._setCursorTypes[t]===e){this._setCursorTypes.splice(t,1),this.updateCursor();break}}updateCursor(){this._setCursorTypes?.length==0?this.context.domElement.style.cursor="default":this.context.domElement.style.cursor=this._setCursorTypes[this._setCursorTypes.length-1]}getIsPointerIdInUse(e){for(const t of this._pointerEventsPressed)if(t.pointerId===e&&t.used)return!0;return!1}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let n=!1;for(const s of e)if(i===s){n=!0;break}if(!n)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}context;_pointerDown=[!1];_pointerUp=[!1];_pointerClick=[!1];_pointerDoubleClick=[!1];_pointerPressed=[!1];_pointerPositions=[new ee];_pointerPositionsLastFrame=[new ee];_pointerPositionsDelta=[new ee];_pointerPositionsRC=[new ee];_pointerPositionDown=[new b];_pointerDownTime=[];_pointerUpTime=[];_pointerUpTimestamp=[];_pointerIds=[];_pointerTypes=[""];_mouseWheelChanged=[!1];_mouseWheelDeltaY=[0];_pointerEvent=[];_pointerEventsPressed=[];_pointerSpace=[];_pressedStack=new Map;onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(e){if(e!==void 0)return this.isKeyDown(e);for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(e){if(e!==void 0)return this.isKeyPressed(e);for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}getKeyUp(e){if(e!==void 0)return this.isKeyUp(e);for(const t in this.keysPressed){const i=this.keysPressed[t];return i.pressed===!1&&i.frame===this.context.time.frameCount}return null}isKeyDown(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyDown(n))return!0;return!1}const i=this.keysPressed[e];return i?i.startFrame===this.context.time.frameCount&&i.pressed:!1}isKeyUp(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyUp(n))return!0;return!1}const i=this.keysPressed[e];return i?i.frame===this.context.time.frameCount&&i.pressed===!1:!1}isKeyPressed(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyPressed(n))return!0;return!1}const i=this.keysPressed[e];return i&&i.pressed||!1}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":qe&&Pe("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":qe&&Pe("Create Pointer move"),this.onMove(e);break;case"pointerup":qe&&Pe("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){return e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1,e}constructor(e){this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}_htmlEventSource;bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){for(const e in this._eventListeners)this._eventListeners[e].length=0;window.removeEventListener("contextmenu",this.onContextMenu),this._htmlEventSource?.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),window.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd),this._htmlEventSource?.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}onLostFocus=()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1};_receivedPointerMoveEventsThisFrame=new Array;onEndOfFrame=()=>{this._receivedPointerMoveEventsThisFrame.length=0;for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0};canReceiveInput(e){return e.target===this.context.renderer?.domElement||e.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&e.target===document.body&&I.isMozillaXR()?!0:(qe&&console.warn("CanReceiveInput:False for",e.target),!1)}onContextMenu=e=>{this.canReceiveInput(e)};keysPressed={};onKeyDown=e=>{if(qe&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new vc("keydown",e,e);this.onDispatchEvent(i)};onKeyPressed=e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new vc("keypress",e,e);this.onDispatchEvent(i)};onKeyUp=e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new vc("keyup",e,e);this.onDispatchEvent(i)};onWheelWindow=e=>{document.pointerLockElement&&this.onMouseWheel(e)};onMouseWheel=e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY};onPointerDown=e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const t=this.getPointerId(e);qe&&Pe(`pointer down #${t}, identifier:${e.pointerId}`);const i=this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),n=new Ao("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:i,pressure:e.pressure});this.onDown(n)};onPointerMove=e=>{if(this.context.isInAR||this._receivedPointerMoveEventsThisFrame.includes(e.pointerId))return;this._receivedPointerMoveEventsThisFrame.push(e.pointerId);let t=e.button;e.pointerType==="mouse"&&(t=this.getFirstPressedButtonForPointer(0)??0);const i=this.getPointerId(e,t);t===-1&&(t=i);const n=this.getAndUpdateSpatialObjectForScreenPosition(i,e.clientX,e.clientY),s=new Ao("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:i,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:n,pressure:e.pressure});this.onMove(s)};onPointerCancel=e=>{this.context.isInAR||(qe&&console.log("Pointer cancel",e),this.onPointerUp(e))};onPointerUp=e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const t=this.getPointerId(e),i=new Ao("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),pressure:e.pressure});this.onUp(i),this._pointerIds[t]=-1,qe&&console.log("ID="+t,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])};getPointerId(e,t){return e.pointerType==="mouse"?0+(t??e.button):this.getPointerIndex(e.pointerId)}getButtonName(e){const t=e.button;if(e.pointerType==="mouse")switch(t){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}onTouchStart=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Ao("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:i.force});this.onDown(r)}};onTouchMove=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),s=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Ao("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:s,pressure:i.force});this.onMove(r)}};onTouchEnd=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),s=new Ao("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.force});this.onUp(s),this._pointerIds[n]=-1}};tempNearPlaneVector=new b;tempFarPlaneVector=new b;tempLookMatrix=new K;getAndUpdateSpatialObjectForScreenPosition(e,t,i){let n=this._pointerSpace[e];n||(n=new M,this._pointerSpace[e]=n),this._pointerSpace[e]=n;const s=this.context.mainCamera;if(s){const r=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(r);const a=this.tempFarPlaneVector.set(r.x,r.y,1);r.unproject(s),a.unproject(s);const l=s.worldUp||F(0,1,0).applyQuaternion(_e(s));this.tempLookMatrix.lookAt(a,r,l),n.position.set(r.x,r.y,r.z),n.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return n}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,n=e.clientY,s=i>=t.x&&i<=t.right&&n>=t.y&&n<=t.bottom;return qe&&!s&&console.log("Not in rect",t,i,n),s}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)){qe&&console.warn(`Received pointerDown event for pointerId that is already pressed: ${t}/${e.button}`,qe?e:"");return}if(qe&&console.log(e.pointerType,"DOWN",t,e.button),!!this.isInRect(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new b);for(this._pointerPositionDown[t].set(e.clientX,e.clientY,e.clientZ??0);t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.realtimeSinceStartup,this.updatePointerPosition(e),this._pointerEventsPressed.push(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||(this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){qe&&console.warn(`Received pointerUp for pointerId that is not pressed: ${t}/${e.button}`,qe?e:"");return}qe&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0),this.updatePointerPosition(e);for(let a=this._pointerEventsPressed.length-1;a>=0;a--)if(this._pointerEventsPressed[a].pointerId===t){this._pointerEventsPressed.splice(a,1);break}if(!this._pointerPositionDown[t]){qe&&be("[Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const i=this._pointerUpTime[t],n=this._pointerDownTime[t],s=this.context.time.realtimeSinceStartup,r=s-n;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),this._pointerUpTime[t]=s,r<1){let a=e.clientX-this._pointerPositionDown[t].x,l=e.clientY-this._pointerPositionDown[t].y,c=0;if(e.isSpatial&&e.clientZ!=null&&(c=e.clientZ-this._pointerPositionDown[t].z,a*=200,l*=200,c*=200),Math.abs(a)<5&&Math.abs(l)<5&&Math.abs(c)<5){this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const h=s-i;qe&&console.log("CLICK",t,a,l,c,h),h<this._doubleClickTimeThreshold&&h>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}}this.onDispatchEvent(e)}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new ee);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new ee);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new ee);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const n=this._pointerPositionsDelta[t];let s=e.clientX-i.x,r=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const h=e.source;s===0&&h.movementX!==0&&(s=h.movementX||0),r===0&&h.movementY!==0&&(r=h.movementY||0)}n.x+=s,n.y+=r,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,l=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new ee);const c=this._pointerPositionsRC[t];c.set(a,l),this.convertScreenspaceToRaycastSpace(c)}getPointerIndex(e){let t=-1;for(let i=0;i<this._pointerIds.length;i++){if(this._pointerIds[i]===e)return i;t===-1&&this._pointerIds[i]===-1&&(t=i)}return t!==-1?(this._pointerIds[t]=e,t):(qe&&console.log("PUSH pointerId:",e),this._pointerIds.push(e),this._pointerIds.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=U.Current;try{U.Current=this.context,this.dispatchEvent(e)}finally{U.Current=t}}}const Wa=new K().makeRotationY(Math.PI),Xi=new N().setFromAxisAngle(new b(0,1,0),Math.PI),mk=v("debugwebxr");class gk{priority=-1e5;gameObject;isXRRig(){return!0}get isActive(){return this.gameObject.visible}constructor(){if(this.gameObject=new M,this.gameObject.name="Implicit XR Rig",mk){const e=Eg(16733661);e.position.y+=.5,this.gameObject.add(e)}}}const Io=v("debugwebxr"),Zd=v("debugcustomgesture"),fk="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",yk="generic-trigger",bk=new N().setFromEuler(new rt(Co.degToRad(0),Co.degToRad(-90),Co.degToRad(-90))),_k=new b(.04,-.04,0);class fg{xr;get context(){return this.xr.context}inputSource;index=0;emitEvents=!0;get connected(){return this._connected}_connected=!0;get isTracking(){return this._isTracking}_isTracking=!1;get gamepad(){return this.__gamepad??=this.inputSource.gamepad}__gamepad;get isHand(){return this.hand!=null}get hand(){return this.__hand??=this.inputSource.hand}__hand;get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.__side??=this.inputSource.handedness}__side=void 0;get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get isStylus(){return this._isMxInk}getHitTestSource(){return this._hitTestSource||this._requestHitTestSource(),this._hitTestSource}get hasHitTestSource(){return this._hitTestSource}cancelHitTestSource(){this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=void 0)}_hitTestSource=void 0;_hasSelectEvent=!1;get hasSelectEvent(){return this._hasSelectEvent}_isMxInk=!1;_isMetaQuestTouchController=!1;getHitTest(){return this.xr.getHitTest(this)}_handJointPoses=new Map;getHandJointPose(e,t){if(t=t||this.xr.frame,!this.hand||!t?.getJointPose||!this.xr.referenceSpace)return null;let i=this._handJointPoses?.get(e);return i||(i=t.getJointPose(e,this.xr.referenceSpace),i&&this._handJointPoses.set(e,i),i)}_gripMatrix=new K;_gripPosition=new b;_gripQuaternion=new N;_linearVelocity=new b;_rayPositionRaw=new b;_rayRotationRaw=new N;_rayMatrix=new K;_rayPosition=new b;_rayQuaternion=new N;get gripPosition(){return F(this._gripPosition)}get gripQuaternion(){return hi(this._gripQuaternion)}get gripMatrix(){return this._gripMatrix}get gripLinearVelocity(){return F(this._linearVelocity).applyQuaternion(Xi)}get rayPosition(){return F(this._rayPosition)}get rayQuaternion(){return hi(this._rayQuaternion)}get gripWorldPosition(){return F(this._gripWorldPosition)}_gripWorldPosition=new b;get gripWorldQuaternion(){return hi(this._gripWorldQuaternion)}_gripWorldQuaternion=new N;get rayWorldPosition(){return F(this._rayWorldPosition)}_rayWorldPosition=new b;updateRayWorldPosition(){const e=this.xr.context.mainCamera?.parent;this._rayWorldPosition.copy(this._rayPositionRaw),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return hi(this._rayWorldQuaternion)}_rayWorldQuaternion=new N;get pinchPosition(){return F(this._pinchPosition)}_pinchPosition=new b;updateRayWorldQuaternion(){const e=this.xr.context.mainCamera?.parent,t=e?_e(e):void 0;this._rayWorldQuaternion.copy(this._rayRotationRaw).multiply(Xi),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(F(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}_ray;_hand_wristDotUp=void 0;get handWristDotUp(){if(this._hand_wristDotUp!==void 0)return this._hand_wristDotUp;const e=this.handObject?.joints.wrist;if(e){const t=F(0,1,0).applyQuaternion(e.quaternion),i=F(0,1,0).dot(t);return this._hand_wristDotUp=i}}get isHandUpsideDown(){return this.handWristDotUp!==void 0?this.handWristDotUp<-.7:!1}get isTeleportGesture(){return this.isHandUpsideDown&&this.getGesture("pinch")?.isDown}get object(){return this._object}_object;_gripSpaceObject;_raySpaceObject;model=null;_debugAxesHelper=new Oi(.15);_debugGripAxesHelper=new Oi(.07);_debugRayAxesHelper=new Oi(.07);async getModelUrl(){return this.getMotionController?.then(e=>e?.assetUrl||null)}constructor(e,t,i){this.xr=e,this.inputSource=t,this.index=i,this._object=new M,this._object.name=`NeedleXRController_${i}`,Io&&(this._object.add(this._debugAxesHelper),this._gripSpaceObject=new M,this._raySpaceObject=new M,this._gripSpaceObject.name=`NeedleXRController_${i}_gripSpace`,this._raySpaceObject.name=`NeedleXRController_${i}_raySpace`,this._gripSpaceObject.add(this._debugGripAxesHelper),this._raySpaceObject.add(this._debugRayAxesHelper),this.xr.context.scene.add(this._gripSpaceObject),this.xr.context.scene.add(this._raySpaceObject)),this.xr.context.scene.add(this._object),this._ray=new So,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents()}_hitTestSourcePromise=null;_requestHitTestSource(){return this._hitTestSourcePromise?this._hitTestSourcePromise:this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&this.xr.session.requestHitTestSourceForTransientInput?this._hitTestSourcePromise=this.xr.session.requestHitTestSourceForTransientInput({profile:this.inputSource.profiles[0],offsetRay:new XRRay})?.then(e=>(this._hitTestSourcePromise=null,this.connected?this._hitTestSource=e:(e.cancel(),null)))??null:null}onPointerHits=e=>{};onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){B.DrawSphere(this.rayWorldPosition,.003),B.DrawDirection(this.rayWorldPosition,F(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=(this.inputSource.gripSpace?this.gripWorldPosition:this.object.worldPosition).sub(this.object.worldForward.multiplyScalar(.1)),t=this.inputSource.profiles.join(`
|
|
146
146
|
`);let i=`Controller[${this.index}] (${this.inputSource.targetRayMode}, ${this.side})
|
|
147
147
|
C:${this.connected?"x":"-"} T:${this.isTracking?"x":"-"} Hand:${this.inputSource.hand?"x":"-"} Pen: ${this._isMxInk?"x":"-"}`;if(this.inputSource.hand&&(i+=`
|
|
@@ -955,7 +955,7 @@ Exit Time: `+c,s.hasExitTime)}this.transitionTo(s.destinationState,s.duration,s.
|
|
|
955
955
|
// Uncomment to visualize blur amount
|
|
956
956
|
// gl_FragColor = vec4(blurAmount, 0.0, 0.0, 1.0);
|
|
957
957
|
}
|
|
958
|
-
`;function qw(o){if(Z.active)return console.warn("[OrbitControls] Can not fit camera while XR session is active"),null;const e=U.Current;if(!e)return console.warn("[OrbitControls] No context found"),null;const t=o?.camera||e.mainCamera;if(!t)return console.warn("No camera or controls found to fit camera to objects..."),null;o||(o={}),o.autoApply=o.autoApply!==!1,o.minZoom||=0,o.maxZoom||=1/0;const{centerCamera:i,cameraNearFar:n="auto",fitOffset:s=1.1,fov:r=t instanceof ae?t?.fov:-1}=o,a=new b,l=new b,c=t instanceof ae?t.aspect:1,h=o.objects||e.scene,d=Zt(h,void 0,t?.layers),p=d.clone();d.getCenter(l);const m=new b;if(d.getSize(m),t instanceof ae&&t.updateProjectionMatrix(),t.updateMatrixWorld(),d.applyMatrix4(t.matrixWorldInverse),d.getSize(a),d.setFromCenterAndSize(l,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z))return console.warn("Camera fit size resultet in NaN",t,d),null;if(a.length()<=1e-10)return console.warn("Camera fit size is zero",d),null;const g=r,f=2*Math.atan(Math.tan(g*Math.PI/360/2)*c)/Math.PI*360,y=a.y/(2*Math.atan(Math.PI*g/360)),_=a.x/(2*Math.atan(Math.PI*f/360)),w=s*Math.max(y,_)+a.z/2;o.maxZoom=w*10,o.minZoom=w*.01,o.debug===!0&&console.log("Fit camera to objects",{fitHeightDistance:y,fitWidthDistance:_,distance:w,verticalFov:g,horizontalFov:f});const P=.05,k=l.clone();if(k.y-=a.y*P,o.targetOffset&&(o.targetOffset.x!==void 0&&(k.x+=o.targetOffset.x),o.targetOffset.y!==void 0&&(k.y+=o.targetOffset.y),o.targetOffset.z!==void 0&&(k.z+=o.targetOffset.z)),o.relativeTargetOffset&&(o.relativeTargetOffset.x!==void 0&&(k.x+=o.relativeTargetOffset.x*a.x),o.relativeTargetOffset.y!==void 0&&(k.y+=o.relativeTargetOffset.y*a.y),o.relativeTargetOffset.z!==void 0&&(k.z+=o.relativeTargetOffset.z*a.z)),n==null||n=="auto"){const L=Ka(eo),V=L?L.radius:0,W=Math.max(m.x,m.y,m.z,V);t instanceof ae&&(t.near=w/100,t.far=W+w*10,t.updateProjectionMatrix()),L&&(o.maxZoom=Math.max(Math.min(o.maxZoom,V*.5),w))}o.currentZoom!==void 0&&(o.currentZoom<o.minZoom&&(o.minZoom=o.currentZoom*.9),o.currentZoom>o.maxZoom&&(o.maxZoom=o.currentZoom*1.1));const O=l.clone();o.fitDirection?O.sub(new b().copy(o.fitDirection).multiplyScalar(1e6)):O.sub(t.worldPosition),i==="y"&&(O.y=0),O.normalize(),O.multiplyScalar(w),i==="y"&&(O.y+=-P*4*w);let D=l.clone().sub(O);return o.cameraOffset&&(o.cameraOffset.x!==void 0&&(D.x+=o.cameraOffset.x),o.cameraOffset.y!==void 0&&(D.y+=o.cameraOffset.y),o.cameraOffset.z!==void 0&&(D.z+=o.cameraOffset.z)),o.relativeCameraOffset&&(o.relativeCameraOffset.x!==void 0&&(D.x+=o.relativeCameraOffset.x*a.x),o.relativeCameraOffset.y!==void 0&&(D.y+=o.relativeCameraOffset.y*a.y),o.relativeCameraOffset.z!==void 0&&(D.z+=o.relativeCameraOffset.z*a.z)),t.parent&&(D=t.parent.worldToLocal(D)),o.debug&&(B.DrawWireBox3(d,16777011,10),B.DrawWireBox3(p,65280,10)),o.autoApply&&(t.position.copy(D),t.lookAt(k),r>0&&t instanceof ae&&(t.fov=r,t.updateProjectionMatrix())),{camera:t,position:D,lookAt:k,fov:o.fov}}var FR=Object.defineProperty,Of=(o,e,t,i)=>{for(var n=void 0,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=r(e,t,n)||n);return n&&FR(e,t,n),n};class zr extends R{constraintActive=!0;locked=!1;sources=[];setConstraintPosition(e){const t=this.sources[0];t&&(t.worldPosition=e)}}Of([u()],zr.prototype,"constraintActive"),Of([u()],zr.prototype,"locked"),Of([u(M)],zr.prototype,"sources");let Nr=class{bb=null;bb_pos=0;__init(o,e){return this.bb_pos=o,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static sizeOf(){return 12}static createVec3(o,e,t,i){return o.prep(4,12),o.writeFloat32(i),o.writeFloat32(t),o.writeFloat32(e),o.offset()}};class Xw{bb=null;bb_pos=0;__init(e,t){return this.bb_pos=e,this.bb=t,this}position(e){return(e||new Nr).__init(this.bb_pos,this.bb)}rotation(e){return(e||new Nr).__init(this.bb_pos+12,this.bb)}scale(e){return(e||new Nr).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(e,t,i,n,s,r,a,l,c,h){return e.prep(4,36),e.prep(4,12),e.writeFloat32(h),e.writeFloat32(c),e.writeFloat32(l),e.prep(4,12),e.writeFloat32(a),e.writeFloat32(r),e.writeFloat32(s),e.prep(4,12),e.writeFloat32(n),e.writeFloat32(i),e.writeFloat32(t),e.offset()}}class ds{bb=null;bb_pos=0;__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedTransformModel(e,t){return(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedTransformModel(e,t){return e.setPosition(e.position()+Db),(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}guid(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}fast(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}transform(e){const t=this.bb.__offset(this.bb_pos,8);return t?(e||new Xw).__init(this.bb_pos+t,this.bb):null}dontSave(){const e=this.bb.__offset(this.bb_pos,10);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startSyncedTransformModel(e){e.startObject(4)}static addGuid(e,t){e.addFieldOffset(0,t,0)}static addFast(e,t){e.addFieldInt8(1,+t,0)}static addTransform(e,t){e.addFieldStruct(2,t,0)}static addDontSave(e,t){e.addFieldInt8(3,+t,0)}static endSyncedTransformModel(e){return e.endObject()}static finishSyncedTransformModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedTransformModelBuffer(e,t){e.finish(t,void 0,!0)}}var T;(o=>{(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./materialx-DTdTjiOL.min.js");return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.MaterialX||(o.MaterialX={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./rapier-DJ-luMxr.min.js");return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.RAPIER_PHYSICS||(o.RAPIER_PHYSICS={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./postprocessing-BVNrgYZK.min.js").then(r=>r.index);return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.POSTPROCESSING||(o.POSTPROCESSING={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./postprocessing-BVNrgYZK.min.js").then(r=>r.N8AO);return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.POSTPROCESSING_AO||(o.POSTPROCESSING_AO={}))})(T||(T={}));var _t=(o=>(o[o.Average=0]="Average",o[o.Multiply=1]="Multiply",o[o.Minimum=2]="Minimum",o[o.Maximum=3]="Maximum",o))(_t||{}),ju=(o=>(o[o.Discrete=0]="Discrete",o[o.Continuous=1]="Continuous",o))(ju||{}),Ye=(o=>(o[o.None=0]="None",o[o.FreezePositionX=2]="FreezePositionX",o[o.FreezePositionY=4]="FreezePositionY",o[o.FreezePositionZ=8]="FreezePositionZ",o[o.FreezePosition=14]="FreezePosition",o[o.FreezeRotationX=16]="FreezeRotationX",o[o.FreezeRotationY=32]="FreezeRotationY",o[o.FreezeRotationZ=64]="FreezeRotationZ",o[o.FreezeRotation=112]="FreezeRotation",o[o.FreezeAll=126]="FreezeAll",o))(Ye||{}),sl=(o=>(o[o.None=0]="None",o[o.X=2]="X",o[o.Y=4]="Y",o[o.Z=8]="Z",o[o.All=-1]="All",o))(sl||{});const Mt=function(o,e){return function(t,i,n){UR(t,i,n,o,e)}};function UR(o,e,t,i,n){if(!n&&!i&&!o.onValidate)return;if(t!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",o,e,t),Pe("Invalid usage of validate decorator. Only fields can be validated. Property: "+e,Ti.Error);return}let s="";if(typeof e=="string"?s=e:s=e.name,o.__internalAwake){const r=Symbol(s),a=o.__internalAwake;o.__internalAwake=function(){if(!this.onValidate){A()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+o.constructor?.name+'"');return}if(this[r]===void 0){this[r]=this[s];const l=this[s];if(l instanceof ee||l instanceof b||l instanceof me||l instanceof N){const c=this[s];Fd(c,()=>{this.onValidate(s)})}Object.defineProperty(this,s,{set:function(c){if(this[Kg]===!0)this[r]=c;else{i?.call(this,c);const h=this[r];this[r]=c,this.onValidate?.call(this,s,h)}},get:function(){return n?.call(this),this[r]}})}a.call(this)}}}const zR=function(o){return function(e,t,i){let n="";typeof t=="string"?n=t:n=t.name;const s=o.prototype,r=Object.getOwnPropertyDescriptor(s,n);if(!r?.value){console.warn("Can not apply prefix: type does not have method named",t,o);return}const a=r.value,l=e[n];Object.defineProperty(s,n,{value:function(...c){const h=l?.call(this,...c);if(h instanceof Promise){h.then(d=>{if(d!==!1)return a.call(this,...c)});return}if(h!==!1)return a.call(this,...c)}})}};var NR=Object.defineProperty,WR=Object.getOwnPropertyDescriptor,Di=(o,e,t,i)=>{for(var n=i>1?void 0:i?WR(e,t):e,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&NR(e,t,n),n};class VR{get isDirty(){return this.positionChanged||this.rotationChanged}positionChanged=!1;rotationChanged=!1;position;quaternion;_positionKeys=["x","y","z"];_quaternionKeys=["_x","_y","_z","_w"];reset(e=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,e){if(this.position)for(const t of this._positionKeys)delete this.position[t];if(this.quaternion)for(const t of this._quaternionKeys)delete this.quaternion[t]}}syncValues(){for(const e of this._positionKeys)this.position[e]=this.obj.position[e];for(const e of this._quaternionKeys)this.quaternion[e]=this.obj.quaternion[e]}mute=!1;applyValues(){if(this.positionChanged&&this.position)for(const e of this._positionKeys){const t=this.position[e];t!==void 0&&(this.obj.position[e]=t)}if(this.rotationChanged&&this.quaternion)for(const e of this._quaternionKeys){const t=this.quaternion[e];t!==void 0&&(this.obj.quaternion[e]=t)}}context;obj;_positionWatch;_rotationWatch;constructor(e,t){this.context=t,this.obj=e}start(e,t){this.reset(),e&&(this._positionWatch||(this._positionWatch=new hs(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((s,r)=>{if(this.context.physics.engine?.isUpdating||this.mute)return;const a=this.position[r];Math.abs(a-s)<1e-5||(this.position[r]=s,this.positionChanged=!0)})),t&&(this._rotationWatch||(this._rotationWatch=new hs(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((s,r)=>{if(this.context.physics.engine?.isUpdating||this.mute)return;const a=this.quaternion[r];Math.abs(a-s)<1e-5||(this.quaternion[r]=s,this.rotationChanged=!0)}));const i=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),n=new K;this.obj.matrixWorld.multiplyMatrices=(s,r)=>(this.context.physics.engine?.isUpdating||this.mute||n.equals(s)||(this.positionChanged=!0,this.rotationChanged=!0,n.copy(s)),i(s,r))}stop(){this._positionWatch?.revoke(),this._rotationWatch?.revoke()}}const gi=class dm extends R{get isRigidbody(){return!0}autoMass=!0;set mass(e){e!==this._mass&&(this._mass=e,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){return this.autoMass?this.context.physics.engine?.getBody(this)?.mass()??-1:this._mass}_mass=0;useGravity=!0;centerOfMass=new b(0,0,0);constraints=Ye.None;isKinematic=!1;drag=0;angularDrag=1;detectCollisions=!0;sleepThreshold=.01;collisionDetectionMode=ju.Discrete;get lockPositionX(){return(this.constraints&Ye.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&Ye.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&Ye.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&Ye.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&Ye.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&Ye.FreezeRotationZ)!==0}set lockPositionX(e){e?this.constraints|=Ye.FreezePositionX:this.constraints&=~Ye.FreezePositionX}set lockPositionY(e){e?this.constraints|=Ye.FreezePositionY:this.constraints&=~Ye.FreezePositionY}set lockPositionZ(e){e?this.constraints|=Ye.FreezePositionZ:this.constraints&=~Ye.FreezePositionZ}set lockRotationX(e){e?this.constraints|=Ye.FreezeRotationX:this.constraints&=~Ye.FreezeRotationX}set lockRotationY(e){e?this.constraints|=Ye.FreezeRotationY:this.constraints&=~Ye.FreezeRotationY}set lockRotationZ(e){e?this.constraints|=Ye.FreezeRotationZ:this.constraints&=~Ye.FreezeRotationZ}set gravityScale(e){this._gravityScale=e}get gravityScale(){return this._gravityScale}_gravityScale=1;dominanceGroup=0;static tempPosition=new b;_propertiesChanged=!1;_currentVelocity=new b;_smoothedVelocity=new b;_smoothedVelocityGetter=new b;_lastPosition=new b;_watch;awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new VR(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),Se.LateUpdate),A()&&(globalThis.NEEDLE_USE_RAPIER?T.RAPIER_PHYSICS.ready().then(async()=>{await hc(3),this.context.physics.engine?.getBody(this)||console.warn(`Rigidbody could not be created. Ensure "${this.name}" has a Collider component.`)}):console.warn("Rigidbody could not be created: Rapier physics are explicitly disabled."))}onDisable(){this._watch?.stop(),this.context.physics.engine?.removeBody(this)}onDestroy(){this.context.physics.engine?.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,this.context.physics.engine?.updateProperties(this)),this._watch?.isDirty?(this._watch.mute=!0,this._watch.applyValues(),this.context.physics.engine?.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):this._watch?.syncValues(),this.captureVelocity(),yield}teleport(e,t=!0){this._watch?.reset(!0),t?this.gameObject.position.set(e.x,e.y,e.z):this.setWorldPosition(e.x,e.y,e.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(e=!0){this.context.physics.engine?.resetForces(this,e)}resetTorques(e=!0){this.context.physics.engine?.resetTorques(this,e)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){this.context.physics.engine?.wakeup(this)}get isSleeping(){return this.context.physics.engine?.isSleeping(this)}updateProperties(){return this._propertiesChanged=!1,this.context.physics.engine?.updateProperties(this)}applyForce(e,t,i=!0){this._propertiesChanged&&this.updateProperties(),this.context.physics.engine?.addForce(this,e,i)}applyImpulse(e,t=!0){this._propertiesChanged&&this.updateProperties(),this.context.physics.engine?.applyImpulse(this,e,t)}setForce(e,t,i,n=!0){this.context.physics.engine?.resetForces(this,n),typeof e=="number"?(t??=0,i??=0,this.context.physics.engine?.addForce(this,{x:e,y:t,z:i},n)):this.context.physics.engine?.addForce(this,e,n)}getVelocity(){const e=this.context.physics.engine?.getLinearVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(e,t,i,n=!0){if(e instanceof b){const s=e;this.context.physics.engine?.setLinearVelocity(this,s,n);return}t===void 0||i===void 0||this.context.physics.engine?.setLinearVelocity(this,{x:e,y:t,z:i},n)}getAngularVelocity(){const e=this.context.physics.engine?.getAngularVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(e,t,i,n=!0){if(typeof e=="object"){const s=e;this.context.physics.engine?.setAngularVelocity(this,s,n);return}if(t===void 0||i===void 0||typeof t=="boolean"){console.warn("setAngularVelocity expects either a Vec3 or 3 numbers");return}this.context.physics.engine?.setAngularVelocity(this,{x:e,y:t,z:i},n)}setTorque(e,t,i){typeof e=="number"?this.setAngularVelocity(e,t,i):this.setAngularVelocity(e)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(e=null){}captureVelocity(){const e=this.gameObject.matrixWorld;dm.tempPosition.setFromMatrixPosition(e);const t=dm.tempPosition.sub(this._lastPosition);this._lastPosition.copy(dm.tempPosition),this._smoothedVelocity.lerp(t,this.context.time.deltaTime/.1)}};Di([Mt()],gi.prototype,"autoMass",2),Di([u()],gi.prototype,"mass",1),Di([Mt(),u()],gi.prototype,"useGravity",2),Di([u(b)],gi.prototype,"centerOfMass",2),Di([Mt(),u()],gi.prototype,"constraints",2),Di([Mt(),u()],gi.prototype,"isKinematic",2),Di([Mt(),u()],gi.prototype,"drag",2),Di([Mt(),u()],gi.prototype,"angularDrag",2),Di([Mt(),u()],gi.prototype,"detectCollisions",2),Di([Mt(),u()],gi.prototype,"sleepThreshold",2),Di([Mt(),u()],gi.prototype,"collisionDetectionMode",2),Di([Mt()],gi.prototype,"_gravityScale",2),Di([Mt()],gi.prototype,"dominanceGroup",2);let Ze=gi;new b,new b;const Es=v("debugsync"),Gc="STRS";vg(Gc,ds.getRootAsSyncedTransformModel);const to=new Dm;function Qw(o,e,t=!0){to.clear();const i=to.createString(o);ds.startSyncedTransformModel(to),ds.addGuid(to,i),ds.addFast(to,t);const n=e.worldPosition,s=e.worldEuler,r=e.gameObject.scale;ds.addTransform(to,Xw.createTransform(to,n.x,n.y,n.z,s.x,s.y,s.z,r.x,r.y,r.z));const a=ds.endSyncedTransformModel(to);return to.finish(a,Gc),to.asUint8Array()}let kf=0,qc=0;Rw(o=>{const e=o.connection.currentServerUrl?.includes("glitch")?10:40;qc=Math.floor(kf/e),kf=0,Es&&qc>0&&console.log("Sync Transform Fast Interval",qc)});class Tn extends R{overridePhysics=!0;interpolatePosition=!0;interpolateRotation=!0;fastMode=!1;syncDestroy=!1;_model=null;_needsUpdate=!0;rb=null;_wasKinematic=!1;_receivedDataBefore=!1;_targetPosition;_targetRotation;_receivedFastUpdate=!1;_shouldRequestOwnership=!1;requestOwnership(){Es&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}freeOwnership(){this._model?.freeOwnership()}hasOwnership(){return this._model?.hasOwnership??void 0}isOwned(){return this._model?.isOwned}joinedRoomCallback=null;receivedDataCallback=null;awake(){Es&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new b,this._targetRotation=new N,this.lastPosition=new b,this.lastRotation=new N,this.lastScale=new b,this.rb=S.getComponentInChildren(this.gameObject,Ze),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new xg(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(ie.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(Gc,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&Wg(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(ie.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(Gc,this.receivedDataCallback)}tryGetLastState(){const e=this.context.connection.tryGetState(this.guid);e&&this.onReceivedData(e)}tempEuler=new rt;onReceivedData(e){if(!this.destroyed&&typeof e.guid=="function"&&e.guid()===this.guid){Es&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const t=e.transform();if(t){pn.markDirty(this.gameObject,!0);const i=t.position();i&&(this.interpolatePosition&&this._targetPosition?.set(i.x(),i.y(),i.z()),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(i.x(),i.y(),i.z()));const n=t.rotation();n&&(this.tempEuler.set(n.x(),n.y(),n.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&sg(this.gameObject,this.tempEuler));const s=t.scale();s&&this.gameObject.scale.set(s.x(),s.y(),s.z())}this._receivedDataBefore=!0}}onEnable(){this.lastPosition.copy(this.worldPosition),this.lastRotation.copy(this.worldQuaternion),this.lastScale.copy(this.gameObject.scale),this._needsUpdate=!0,this._model&&this._model.updateIsOwned()}onDisable(){this._model&&this._model.freeOwnership()}receivedUpdate=!1;lastPosition;lastRotation;lastScale;onBeforeRender(){if(!this.activeAndEnabled||!this.context.connection.isConnected)return;if(!this.context.connection.isInRoom||!this._model){Es&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const e=this.worldPosition,t=this.worldQuaternion,i=this.gameObject.scale;if(this._model.isOwned&&!this.receivedUpdate){const r=this._model.hasOwnership||this.fastMode?1e-4:.001;(e.distanceTo(this.lastPosition)>r||t.angleTo(this.lastRotation)>r||i.distanceTo(this.lastScale)>r)&&(this._model.hasOwnership?this._needsUpdate=!0:(Es&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastPosition),this.worldPosition=this.lastPosition,e.copy(this.lastPosition),this.worldQuaternion=this.lastRotation,t.copy(this.lastRotation),this.gameObject.scale.copy(this.lastScale),pn.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const r=this._receivedFastUpdate||this.fastMode?.5:.3;let a=!1;if(this.interpolatePosition&&this._targetPosition){const l=this.worldPosition;l.lerp(this._targetPosition,r),this.worldPosition=l,a=!0}if(this.interpolateRotation&&this._targetRotation){const l=this.worldQuaternion;l.slerp(this._targetRotation,r),this.worldQuaternion=l,a=!0}a&&pn.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastPosition.copy(e),this.lastRotation.copy(t),this.lastScale.copy(i),!this._model||!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership)return;this.rb&&this.overridePhysics&&this._wasKinematic!==void 0&&(Es&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const n=10,s=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%n===0||s)){if(kf++,s&&qc>0&&this.context.time.frameCount%qc!==0)return;Es&&console.debug("[SyncedTransform] Send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const r=Qw(this.guid,this,!!s);this.context.connection.sendBinary(r)}}}class wd{event;get deviceIndex(){return this.event.deviceIndex}get pointerId(){return this.event.pointerId}button;buttonName;get pressure(){return this.event.pressure}get used(){return this._used}_used=!1;use(){this._used||(this._used=!0,this.event.use())}_propagationStopped=!1;get propagationStopped(){return this._propagationStopped}stopPropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}stopImmediatePropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}z__pointer_ctured=!1;setPointerCapture(){this.z__pointer_ctured=!0}z__pointer_cture_rleased=!1;releasePointerCapture(){this.z__pointer_cture_rleased=!0}inputSource;get mode(){return this.event.mode}object;point;normal;face;distance;instanceId;intersection;isDown;isUp;isPressed;isClick;isDoubleClick;input;constructor(e,t){this.event=t,this.input=e,this.button=t.button}clone(){const e=new wd(this.input,this.event);return Object.assign(e,this),e}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function Bu(o,e){return S.foreachComponent(o,t=>{if(!t.enabled)return;const i=t;if(e)switch(e){case"pointerdown":if(i.onPointerDown)return!0;break;case"pointerup":if(i.onPointerUp||i.onPointerClick)return!0;break;case"pointermove":if(i.onPointerEnter||i.onPointerExit||i.onPointerMove)return!0;break}else if(i.onPointerDown||i.onPointerUp||i.onPointerEnter||i.onPointerExit||i.onPointerClick)return!0},!1)===!0}const Fo=new Array;class Uo{enabled=!0;target;methodName;arguments;get canClone(){return this.target instanceof Object}constructor(e,t,i,n){this.target=e,this.methodName=t||null,this.arguments=i,n!=null&&(this.enabled=n)}invoke(...e){if(this.enabled!==!1){if(typeof this.target=="function")this.arguments?(Fo.length=0,e!==void 0&&e.length>0&&Fo.push(...e),Fo.push(...this.arguments),this.target(...this.arguments),Fo.length=0):this.target(...e);else if(this.methodName!=null){const t=this.target[this.methodName];typeof t=="function"?this.arguments?(Fo.length=0,e!==void 0&&e.length>0&&Fo.push(...e),Fo.push(...this.arguments),t.call(this.target,...Fo),Fo.length=0):t.call(this.target,...e):this.arguments?e!==void 0&&e.length>0?this.target[this.methodName]=e[0]:this.target[this.methodName]=this.arguments[0]:this.target[this.methodName]=e[0]}}}}const $R=o=>/^[A-Z]*$/.test(o);class Fu extends Event{args}class de{isEventList=!0;__internalOnInstantiate(e){const t=new Array;for(let i=0;i<this.methods.length;i++){const n=this.methods[i];if(!(n.target instanceof Function)){const s=n.target;let r=s?.uuid;if(s&&(r=s.guid),r){const a=e[r];if(a){const l=n.arguments?.map(c=>c instanceof Object&&c.uuid?e[c.uuid]:c?.isComponent?e[c.guid]:c);t.push(new Uo(a.clone,n.methodName,l,n.enabled))}else A()&&console.warn("Could not find target for event listener")}}}return new de(t)}target;key;setEventTarget(e,t){if(this.key=e,this.target=t,this.key!==void 0){let i="",n=!1;for(const s of this.key)n&&$R(s)&&(i+="-"),n=!0,i+=s.toLowerCase();this.key=i}}get listenerCount(){return this.methods?.length??0}get isInvoking(){return this._isInvoking}_isInvoking=!1;methods=[];_methodsCopy=[];static from(...e){return new de(e)}constructor(e){if(this.methods=[],Array.isArray(e))for(const t of e)t instanceof Uo?this.methods.push(t):typeof t=="function"&&this.methods.push(new Uo(t));else typeof e=="function"&&this.methods.push(new Uo(e))}invoke(...e){if(this._isInvoking)return console.warn("Circular event invocation detected. Please check your event listeners for circular references.",this),!1;if(this.methods?.length<=0)return!1;this._isInvoking=!0;try{this._methodsCopy.length=0,this._methodsCopy.push(...this.methods);for(const t of this._methodsCopy)t.invoke(...e);if(typeof this.target=="object"&&typeof this.key=="string"){const t=this.target.dispatchEvent;if(typeof t=="function"){const i=new Fu(this.key);i.args=e,t.call(this.target,i)}}}finally{this._isInvoking=!1,this._methodsCopy.length=0}return!0}addEventListener(e){return this.methods.push(new Uo(e)),e}removeEventListener(e){if(e)for(let t=this.methods.length-1;t>=0;t--)this.methods[t].target===e&&(this.methods[t].enabled=!1,this.methods.splice(t,1))}removeAllEventListeners(){this.methods.length=0}}class HR extends Ki{constructor(){super([oe,se],"ColorSerializer")}onDeserialize(e){if(e!=null)return e.a!==void 0?new se(e.r,e.g,e.b,e.a):e.alpha!==void 0?new se(e.r,e.g,e.b,e.alpha):new oe(e.r,e.g,e.b)}onSerialize(e){if(e!=null)return e.a!==void 0?{r:e.r,g:e.g,b:e.b,a:e.a}:{r:e.r,g:e.g,b:e.b}}}const GR=new HR;class qR extends Ki{constructor(){super([rt],"EulerSerializer")}onDeserialize(e,t){if(e!=null){if(e.order)return new rt(e.x,e.y,e.z,e.order);if(e.x!=null)return new rt(e.x,e.y,e.z)}}onSerialize(e,t){return{x:e.x,y:e.y,z:e.z,order:e.order}}}const XR=new qR;class QR extends Ki{constructor(){super(M,"ObjectSerializer")}onSerialize(e,t){if(t.objectToNode!==void 0&&e.uuid){const i=t.objectToNode[e.uuid];return yt&&console.log(i,e.name,e.uuid),{node:i}}}onDeserialize(e,t){if(typeof e=="string"){if(e.endsWith(".glb")||e.endsWith(".gltf")){if(t.serializable instanceof Array&&t.serializable.includes(ne))return;A()&&be("Detected wrong usage of @serializable with Object3D or GameObject. Instead you should use AssetReference here! Please see the console for details.");const i=t.target?.constructor?.name;console.warn(`Wrong usage of @serializable detected in your script "${i}"
|
|
958
|
+
`;function qw(o){if(Z.active)return console.warn("[OrbitControls] Can not fit camera while XR session is active"),null;const e=U.Current;if(!e)return console.warn("[OrbitControls] No context found"),null;const t=o?.camera||e.mainCamera;if(!t)return console.warn("No camera or controls found to fit camera to objects..."),null;o||(o={}),o.autoApply=o.autoApply!==!1,o.minZoom||=0,o.maxZoom||=1/0;const{centerCamera:i,cameraNearFar:n="auto",fitOffset:s=1.1,fov:r=t instanceof ae?t?.fov:-1}=o,a=new b,l=new b,c=t instanceof ae?t.aspect:1,h=o.objects||e.scene,d=Zt(h,void 0,t?.layers),p=d.clone();d.getCenter(l);const m=new b;if(d.getSize(m),t instanceof ae&&t.updateProjectionMatrix(),t.updateMatrixWorld(),d.applyMatrix4(t.matrixWorldInverse),d.getSize(a),d.setFromCenterAndSize(l,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z))return console.warn("Camera fit size resultet in NaN",t,d),null;if(a.length()<=1e-10)return console.warn("Camera fit size is zero",d),null;const g=r,f=2*Math.atan(Math.tan(g*Math.PI/360/2)*c)/Math.PI*360,y=a.y/(2*Math.atan(Math.PI*g/360)),_=a.x/(2*Math.atan(Math.PI*f/360)),w=s*Math.max(y,_)+a.z/2;o.maxZoom=w*10,o.minZoom=w*.01,o.debug===!0&&console.log("Fit camera to objects",{fitHeightDistance:y,fitWidthDistance:_,distance:w,verticalFov:g,horizontalFov:f});const P=.05,k=l.clone();if(k.y-=a.y*P,o.targetOffset&&(o.targetOffset.x!==void 0&&(k.x+=o.targetOffset.x),o.targetOffset.y!==void 0&&(k.y+=o.targetOffset.y),o.targetOffset.z!==void 0&&(k.z+=o.targetOffset.z)),o.relativeTargetOffset&&(o.relativeTargetOffset.x!==void 0&&(k.x+=o.relativeTargetOffset.x*a.x),o.relativeTargetOffset.y!==void 0&&(k.y+=o.relativeTargetOffset.y*a.y),o.relativeTargetOffset.z!==void 0&&(k.z+=o.relativeTargetOffset.z*a.z)),n==null||n=="auto"){const L=Ka(eo),V=L?L.radius:0,W=Math.max(m.x,m.y,m.z,V);t instanceof ae&&(t.near=w/100,t.far=W+w*10,t.updateProjectionMatrix()),L&&(o.maxZoom=Math.max(Math.min(o.maxZoom,V*.5),w))}o.currentZoom!==void 0&&(o.currentZoom<o.minZoom&&(o.minZoom=o.currentZoom*.9),o.currentZoom>o.maxZoom&&(o.maxZoom=o.currentZoom*1.1));const O=l.clone();o.fitDirection?O.sub(new b().copy(o.fitDirection).multiplyScalar(1e6)):O.sub(t.worldPosition),i==="y"&&(O.y=0),O.normalize(),O.multiplyScalar(w),i==="y"&&(O.y+=-P*4*w);let D=l.clone().sub(O);return o.cameraOffset&&(o.cameraOffset.x!==void 0&&(D.x+=o.cameraOffset.x),o.cameraOffset.y!==void 0&&(D.y+=o.cameraOffset.y),o.cameraOffset.z!==void 0&&(D.z+=o.cameraOffset.z)),o.relativeCameraOffset&&(o.relativeCameraOffset.x!==void 0&&(D.x+=o.relativeCameraOffset.x*a.x),o.relativeCameraOffset.y!==void 0&&(D.y+=o.relativeCameraOffset.y*a.y),o.relativeCameraOffset.z!==void 0&&(D.z+=o.relativeCameraOffset.z*a.z)),t.parent&&(D=t.parent.worldToLocal(D)),o.debug&&(B.DrawWireBox3(d,16777011,10),B.DrawWireBox3(p,65280,10)),o.autoApply&&(t.position.copy(D),t.lookAt(k),r>0&&t instanceof ae&&(t.fov=r,t.updateProjectionMatrix())),{camera:t,position:D,lookAt:k,fov:o.fov}}var FR=Object.defineProperty,Of=(o,e,t,i)=>{for(var n=void 0,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=r(e,t,n)||n);return n&&FR(e,t,n),n};class zr extends R{constraintActive=!0;locked=!1;sources=[];setConstraintPosition(e){const t=this.sources[0];t&&(t.worldPosition=e)}}Of([u()],zr.prototype,"constraintActive"),Of([u()],zr.prototype,"locked"),Of([u(M)],zr.prototype,"sources");let Nr=class{bb=null;bb_pos=0;__init(o,e){return this.bb_pos=o,this.bb=e,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static sizeOf(){return 12}static createVec3(o,e,t,i){return o.prep(4,12),o.writeFloat32(i),o.writeFloat32(t),o.writeFloat32(e),o.offset()}};class Xw{bb=null;bb_pos=0;__init(e,t){return this.bb_pos=e,this.bb=t,this}position(e){return(e||new Nr).__init(this.bb_pos,this.bb)}rotation(e){return(e||new Nr).__init(this.bb_pos+12,this.bb)}scale(e){return(e||new Nr).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(e,t,i,n,s,r,a,l,c,h){return e.prep(4,36),e.prep(4,12),e.writeFloat32(h),e.writeFloat32(c),e.writeFloat32(l),e.prep(4,12),e.writeFloat32(a),e.writeFloat32(r),e.writeFloat32(s),e.prep(4,12),e.writeFloat32(n),e.writeFloat32(i),e.writeFloat32(t),e.offset()}}class ds{bb=null;bb_pos=0;__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedTransformModel(e,t){return(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedTransformModel(e,t){return e.setPosition(e.position()+Db),(t||new ds).__init(e.readInt32(e.position())+e.position(),e)}guid(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}fast(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}transform(e){const t=this.bb.__offset(this.bb_pos,8);return t?(e||new Xw).__init(this.bb_pos+t,this.bb):null}dontSave(){const e=this.bb.__offset(this.bb_pos,10);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startSyncedTransformModel(e){e.startObject(4)}static addGuid(e,t){e.addFieldOffset(0,t,0)}static addFast(e,t){e.addFieldInt8(1,+t,0)}static addTransform(e,t){e.addFieldStruct(2,t,0)}static addDontSave(e,t){e.addFieldInt8(3,+t,0)}static endSyncedTransformModel(e){return e.endObject()}static finishSyncedTransformModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedTransformModelBuffer(e,t){e.finish(t,void 0,!0)}}var T;(o=>{(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./materialx-B9ddsHcF.min.js");return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.MaterialX||(o.MaterialX={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./rapier-DJ-luMxr.min.js");return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.RAPIER_PHYSICS||(o.RAPIER_PHYSICS={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./postprocessing-BVNrgYZK.min.js").then(r=>r.index);return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.POSTPROCESSING||(o.POSTPROCESSING={})),(e=>{e.MAYBEMODULE=null;const t=[];function i(){return e.MODULE?Promise.resolve(e.MODULE):new Promise(s=>{t.push(s)})}e.ready=i;async function n(){if(e.MODULE)return e.MODULE;const s=await import("./postprocessing-BVNrgYZK.min.js").then(r=>r.N8AO);return e.MODULE=s,e.MAYBEMODULE=s,t.forEach(r=>r(s)),t.length=0,s}e.load=n})(o.POSTPROCESSING_AO||(o.POSTPROCESSING_AO={}))})(T||(T={}));var _t=(o=>(o[o.Average=0]="Average",o[o.Multiply=1]="Multiply",o[o.Minimum=2]="Minimum",o[o.Maximum=3]="Maximum",o))(_t||{}),ju=(o=>(o[o.Discrete=0]="Discrete",o[o.Continuous=1]="Continuous",o))(ju||{}),Ye=(o=>(o[o.None=0]="None",o[o.FreezePositionX=2]="FreezePositionX",o[o.FreezePositionY=4]="FreezePositionY",o[o.FreezePositionZ=8]="FreezePositionZ",o[o.FreezePosition=14]="FreezePosition",o[o.FreezeRotationX=16]="FreezeRotationX",o[o.FreezeRotationY=32]="FreezeRotationY",o[o.FreezeRotationZ=64]="FreezeRotationZ",o[o.FreezeRotation=112]="FreezeRotation",o[o.FreezeAll=126]="FreezeAll",o))(Ye||{}),sl=(o=>(o[o.None=0]="None",o[o.X=2]="X",o[o.Y=4]="Y",o[o.Z=8]="Z",o[o.All=-1]="All",o))(sl||{});const Mt=function(o,e){return function(t,i,n){UR(t,i,n,o,e)}};function UR(o,e,t,i,n){if(!n&&!i&&!o.onValidate)return;if(t!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",o,e,t),Pe("Invalid usage of validate decorator. Only fields can be validated. Property: "+e,Ti.Error);return}let s="";if(typeof e=="string"?s=e:s=e.name,o.__internalAwake){const r=Symbol(s),a=o.__internalAwake;o.__internalAwake=function(){if(!this.onValidate){A()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+o.constructor?.name+'"');return}if(this[r]===void 0){this[r]=this[s];const l=this[s];if(l instanceof ee||l instanceof b||l instanceof me||l instanceof N){const c=this[s];Fd(c,()=>{this.onValidate(s)})}Object.defineProperty(this,s,{set:function(c){if(this[Kg]===!0)this[r]=c;else{i?.call(this,c);const h=this[r];this[r]=c,this.onValidate?.call(this,s,h)}},get:function(){return n?.call(this),this[r]}})}a.call(this)}}}const zR=function(o){return function(e,t,i){let n="";typeof t=="string"?n=t:n=t.name;const s=o.prototype,r=Object.getOwnPropertyDescriptor(s,n);if(!r?.value){console.warn("Can not apply prefix: type does not have method named",t,o);return}const a=r.value,l=e[n];Object.defineProperty(s,n,{value:function(...c){const h=l?.call(this,...c);if(h instanceof Promise){h.then(d=>{if(d!==!1)return a.call(this,...c)});return}if(h!==!1)return a.call(this,...c)}})}};var NR=Object.defineProperty,WR=Object.getOwnPropertyDescriptor,Di=(o,e,t,i)=>{for(var n=i>1?void 0:i?WR(e,t):e,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&NR(e,t,n),n};class VR{get isDirty(){return this.positionChanged||this.rotationChanged}positionChanged=!1;rotationChanged=!1;position;quaternion;_positionKeys=["x","y","z"];_quaternionKeys=["_x","_y","_z","_w"];reset(e=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,e){if(this.position)for(const t of this._positionKeys)delete this.position[t];if(this.quaternion)for(const t of this._quaternionKeys)delete this.quaternion[t]}}syncValues(){for(const e of this._positionKeys)this.position[e]=this.obj.position[e];for(const e of this._quaternionKeys)this.quaternion[e]=this.obj.quaternion[e]}mute=!1;applyValues(){if(this.positionChanged&&this.position)for(const e of this._positionKeys){const t=this.position[e];t!==void 0&&(this.obj.position[e]=t)}if(this.rotationChanged&&this.quaternion)for(const e of this._quaternionKeys){const t=this.quaternion[e];t!==void 0&&(this.obj.quaternion[e]=t)}}context;obj;_positionWatch;_rotationWatch;constructor(e,t){this.context=t,this.obj=e}start(e,t){this.reset(),e&&(this._positionWatch||(this._positionWatch=new hs(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((s,r)=>{if(this.context.physics.engine?.isUpdating||this.mute)return;const a=this.position[r];Math.abs(a-s)<1e-5||(this.position[r]=s,this.positionChanged=!0)})),t&&(this._rotationWatch||(this._rotationWatch=new hs(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((s,r)=>{if(this.context.physics.engine?.isUpdating||this.mute)return;const a=this.quaternion[r];Math.abs(a-s)<1e-5||(this.quaternion[r]=s,this.rotationChanged=!0)}));const i=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),n=new K;this.obj.matrixWorld.multiplyMatrices=(s,r)=>(this.context.physics.engine?.isUpdating||this.mute||n.equals(s)||(this.positionChanged=!0,this.rotationChanged=!0,n.copy(s)),i(s,r))}stop(){this._positionWatch?.revoke(),this._rotationWatch?.revoke()}}const gi=class dm extends R{get isRigidbody(){return!0}autoMass=!0;set mass(e){e!==this._mass&&(this._mass=e,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){return this.autoMass?this.context.physics.engine?.getBody(this)?.mass()??-1:this._mass}_mass=0;useGravity=!0;centerOfMass=new b(0,0,0);constraints=Ye.None;isKinematic=!1;drag=0;angularDrag=1;detectCollisions=!0;sleepThreshold=.01;collisionDetectionMode=ju.Discrete;get lockPositionX(){return(this.constraints&Ye.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&Ye.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&Ye.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&Ye.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&Ye.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&Ye.FreezeRotationZ)!==0}set lockPositionX(e){e?this.constraints|=Ye.FreezePositionX:this.constraints&=~Ye.FreezePositionX}set lockPositionY(e){e?this.constraints|=Ye.FreezePositionY:this.constraints&=~Ye.FreezePositionY}set lockPositionZ(e){e?this.constraints|=Ye.FreezePositionZ:this.constraints&=~Ye.FreezePositionZ}set lockRotationX(e){e?this.constraints|=Ye.FreezeRotationX:this.constraints&=~Ye.FreezeRotationX}set lockRotationY(e){e?this.constraints|=Ye.FreezeRotationY:this.constraints&=~Ye.FreezeRotationY}set lockRotationZ(e){e?this.constraints|=Ye.FreezeRotationZ:this.constraints&=~Ye.FreezeRotationZ}set gravityScale(e){this._gravityScale=e}get gravityScale(){return this._gravityScale}_gravityScale=1;dominanceGroup=0;static tempPosition=new b;_propertiesChanged=!1;_currentVelocity=new b;_smoothedVelocity=new b;_smoothedVelocityGetter=new b;_lastPosition=new b;_watch;awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new VR(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),Se.LateUpdate),A()&&(globalThis.NEEDLE_USE_RAPIER?T.RAPIER_PHYSICS.ready().then(async()=>{await hc(3),this.context.physics.engine?.getBody(this)||console.warn(`Rigidbody could not be created. Ensure "${this.name}" has a Collider component.`)}):console.warn("Rigidbody could not be created: Rapier physics are explicitly disabled."))}onDisable(){this._watch?.stop(),this.context.physics.engine?.removeBody(this)}onDestroy(){this.context.physics.engine?.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,this.context.physics.engine?.updateProperties(this)),this._watch?.isDirty?(this._watch.mute=!0,this._watch.applyValues(),this.context.physics.engine?.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):this._watch?.syncValues(),this.captureVelocity(),yield}teleport(e,t=!0){this._watch?.reset(!0),t?this.gameObject.position.set(e.x,e.y,e.z):this.setWorldPosition(e.x,e.y,e.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(e=!0){this.context.physics.engine?.resetForces(this,e)}resetTorques(e=!0){this.context.physics.engine?.resetTorques(this,e)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){this.context.physics.engine?.wakeup(this)}get isSleeping(){return this.context.physics.engine?.isSleeping(this)}updateProperties(){return this._propertiesChanged=!1,this.context.physics.engine?.updateProperties(this)}applyForce(e,t,i=!0){this._propertiesChanged&&this.updateProperties(),this.context.physics.engine?.addForce(this,e,i)}applyImpulse(e,t=!0){this._propertiesChanged&&this.updateProperties(),this.context.physics.engine?.applyImpulse(this,e,t)}setForce(e,t,i,n=!0){this.context.physics.engine?.resetForces(this,n),typeof e=="number"?(t??=0,i??=0,this.context.physics.engine?.addForce(this,{x:e,y:t,z:i},n)):this.context.physics.engine?.addForce(this,e,n)}getVelocity(){const e=this.context.physics.engine?.getLinearVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(e,t,i,n=!0){if(e instanceof b){const s=e;this.context.physics.engine?.setLinearVelocity(this,s,n);return}t===void 0||i===void 0||this.context.physics.engine?.setLinearVelocity(this,{x:e,y:t,z:i},n)}getAngularVelocity(){const e=this.context.physics.engine?.getAngularVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(e,t,i,n=!0){if(typeof e=="object"){const s=e;this.context.physics.engine?.setAngularVelocity(this,s,n);return}if(t===void 0||i===void 0||typeof t=="boolean"){console.warn("setAngularVelocity expects either a Vec3 or 3 numbers");return}this.context.physics.engine?.setAngularVelocity(this,{x:e,y:t,z:i},n)}setTorque(e,t,i){typeof e=="number"?this.setAngularVelocity(e,t,i):this.setAngularVelocity(e)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(e=null){}captureVelocity(){const e=this.gameObject.matrixWorld;dm.tempPosition.setFromMatrixPosition(e);const t=dm.tempPosition.sub(this._lastPosition);this._lastPosition.copy(dm.tempPosition),this._smoothedVelocity.lerp(t,this.context.time.deltaTime/.1)}};Di([Mt()],gi.prototype,"autoMass",2),Di([u()],gi.prototype,"mass",1),Di([Mt(),u()],gi.prototype,"useGravity",2),Di([u(b)],gi.prototype,"centerOfMass",2),Di([Mt(),u()],gi.prototype,"constraints",2),Di([Mt(),u()],gi.prototype,"isKinematic",2),Di([Mt(),u()],gi.prototype,"drag",2),Di([Mt(),u()],gi.prototype,"angularDrag",2),Di([Mt(),u()],gi.prototype,"detectCollisions",2),Di([Mt(),u()],gi.prototype,"sleepThreshold",2),Di([Mt(),u()],gi.prototype,"collisionDetectionMode",2),Di([Mt()],gi.prototype,"_gravityScale",2),Di([Mt()],gi.prototype,"dominanceGroup",2);let Ze=gi;new b,new b;const Es=v("debugsync"),Gc="STRS";vg(Gc,ds.getRootAsSyncedTransformModel);const to=new Dm;function Qw(o,e,t=!0){to.clear();const i=to.createString(o);ds.startSyncedTransformModel(to),ds.addGuid(to,i),ds.addFast(to,t);const n=e.worldPosition,s=e.worldEuler,r=e.gameObject.scale;ds.addTransform(to,Xw.createTransform(to,n.x,n.y,n.z,s.x,s.y,s.z,r.x,r.y,r.z));const a=ds.endSyncedTransformModel(to);return to.finish(a,Gc),to.asUint8Array()}let kf=0,qc=0;Rw(o=>{const e=o.connection.currentServerUrl?.includes("glitch")?10:40;qc=Math.floor(kf/e),kf=0,Es&&qc>0&&console.log("Sync Transform Fast Interval",qc)});class Tn extends R{overridePhysics=!0;interpolatePosition=!0;interpolateRotation=!0;fastMode=!1;syncDestroy=!1;_model=null;_needsUpdate=!0;rb=null;_wasKinematic=!1;_receivedDataBefore=!1;_targetPosition;_targetRotation;_receivedFastUpdate=!1;_shouldRequestOwnership=!1;requestOwnership(){Es&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}freeOwnership(){this._model?.freeOwnership()}hasOwnership(){return this._model?.hasOwnership??void 0}isOwned(){return this._model?.isOwned}joinedRoomCallback=null;receivedDataCallback=null;awake(){Es&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new b,this._targetRotation=new N,this.lastPosition=new b,this.lastRotation=new N,this.lastScale=new b,this.rb=S.getComponentInChildren(this.gameObject,Ze),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new xg(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(ie.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(Gc,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&Wg(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(ie.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(Gc,this.receivedDataCallback)}tryGetLastState(){const e=this.context.connection.tryGetState(this.guid);e&&this.onReceivedData(e)}tempEuler=new rt;onReceivedData(e){if(!this.destroyed&&typeof e.guid=="function"&&e.guid()===this.guid){Es&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const t=e.transform();if(t){pn.markDirty(this.gameObject,!0);const i=t.position();i&&(this.interpolatePosition&&this._targetPosition?.set(i.x(),i.y(),i.z()),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(i.x(),i.y(),i.z()));const n=t.rotation();n&&(this.tempEuler.set(n.x(),n.y(),n.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&sg(this.gameObject,this.tempEuler));const s=t.scale();s&&this.gameObject.scale.set(s.x(),s.y(),s.z())}this._receivedDataBefore=!0}}onEnable(){this.lastPosition.copy(this.worldPosition),this.lastRotation.copy(this.worldQuaternion),this.lastScale.copy(this.gameObject.scale),this._needsUpdate=!0,this._model&&this._model.updateIsOwned()}onDisable(){this._model&&this._model.freeOwnership()}receivedUpdate=!1;lastPosition;lastRotation;lastScale;onBeforeRender(){if(!this.activeAndEnabled||!this.context.connection.isConnected)return;if(!this.context.connection.isInRoom||!this._model){Es&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const e=this.worldPosition,t=this.worldQuaternion,i=this.gameObject.scale;if(this._model.isOwned&&!this.receivedUpdate){const r=this._model.hasOwnership||this.fastMode?1e-4:.001;(e.distanceTo(this.lastPosition)>r||t.angleTo(this.lastRotation)>r||i.distanceTo(this.lastScale)>r)&&(this._model.hasOwnership?this._needsUpdate=!0:(Es&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastPosition),this.worldPosition=this.lastPosition,e.copy(this.lastPosition),this.worldQuaternion=this.lastRotation,t.copy(this.lastRotation),this.gameObject.scale.copy(this.lastScale),pn.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const r=this._receivedFastUpdate||this.fastMode?.5:.3;let a=!1;if(this.interpolatePosition&&this._targetPosition){const l=this.worldPosition;l.lerp(this._targetPosition,r),this.worldPosition=l,a=!0}if(this.interpolateRotation&&this._targetRotation){const l=this.worldQuaternion;l.slerp(this._targetRotation,r),this.worldQuaternion=l,a=!0}a&&pn.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastPosition.copy(e),this.lastRotation.copy(t),this.lastScale.copy(i),!this._model||!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership)return;this.rb&&this.overridePhysics&&this._wasKinematic!==void 0&&(Es&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const n=10,s=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%n===0||s)){if(kf++,s&&qc>0&&this.context.time.frameCount%qc!==0)return;Es&&console.debug("[SyncedTransform] Send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const r=Qw(this.guid,this,!!s);this.context.connection.sendBinary(r)}}}class wd{event;get deviceIndex(){return this.event.deviceIndex}get pointerId(){return this.event.pointerId}button;buttonName;get pressure(){return this.event.pressure}get used(){return this._used}_used=!1;use(){this._used||(this._used=!0,this.event.use())}_propagationStopped=!1;get propagationStopped(){return this._propagationStopped}stopPropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}stopImmediatePropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}z__pointer_ctured=!1;setPointerCapture(){this.z__pointer_ctured=!0}z__pointer_cture_rleased=!1;releasePointerCapture(){this.z__pointer_cture_rleased=!0}inputSource;get mode(){return this.event.mode}object;point;normal;face;distance;instanceId;intersection;isDown;isUp;isPressed;isClick;isDoubleClick;input;constructor(e,t){this.event=t,this.input=e,this.button=t.button}clone(){const e=new wd(this.input,this.event);return Object.assign(e,this),e}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function Bu(o,e){return S.foreachComponent(o,t=>{if(!t.enabled)return;const i=t;if(e)switch(e){case"pointerdown":if(i.onPointerDown)return!0;break;case"pointerup":if(i.onPointerUp||i.onPointerClick)return!0;break;case"pointermove":if(i.onPointerEnter||i.onPointerExit||i.onPointerMove)return!0;break}else if(i.onPointerDown||i.onPointerUp||i.onPointerEnter||i.onPointerExit||i.onPointerClick)return!0},!1)===!0}const Fo=new Array;class Uo{enabled=!0;target;methodName;arguments;get canClone(){return this.target instanceof Object}constructor(e,t,i,n){this.target=e,this.methodName=t||null,this.arguments=i,n!=null&&(this.enabled=n)}invoke(...e){if(this.enabled!==!1){if(typeof this.target=="function")this.arguments?(Fo.length=0,e!==void 0&&e.length>0&&Fo.push(...e),Fo.push(...this.arguments),this.target(...this.arguments),Fo.length=0):this.target(...e);else if(this.methodName!=null){const t=this.target[this.methodName];typeof t=="function"?this.arguments?(Fo.length=0,e!==void 0&&e.length>0&&Fo.push(...e),Fo.push(...this.arguments),t.call(this.target,...Fo),Fo.length=0):t.call(this.target,...e):this.arguments?e!==void 0&&e.length>0?this.target[this.methodName]=e[0]:this.target[this.methodName]=this.arguments[0]:this.target[this.methodName]=e[0]}}}}const $R=o=>/^[A-Z]*$/.test(o);class Fu extends Event{args}class de{isEventList=!0;__internalOnInstantiate(e){const t=new Array;for(let i=0;i<this.methods.length;i++){const n=this.methods[i];if(!(n.target instanceof Function)){const s=n.target;let r=s?.uuid;if(s&&(r=s.guid),r){const a=e[r];if(a){const l=n.arguments?.map(c=>c instanceof Object&&c.uuid?e[c.uuid]:c?.isComponent?e[c.guid]:c);t.push(new Uo(a.clone,n.methodName,l,n.enabled))}else A()&&console.warn("Could not find target for event listener")}}}return new de(t)}target;key;setEventTarget(e,t){if(this.key=e,this.target=t,this.key!==void 0){let i="",n=!1;for(const s of this.key)n&&$R(s)&&(i+="-"),n=!0,i+=s.toLowerCase();this.key=i}}get listenerCount(){return this.methods?.length??0}get isInvoking(){return this._isInvoking}_isInvoking=!1;methods=[];_methodsCopy=[];static from(...e){return new de(e)}constructor(e){if(this.methods=[],Array.isArray(e))for(const t of e)t instanceof Uo?this.methods.push(t):typeof t=="function"&&this.methods.push(new Uo(t));else typeof e=="function"&&this.methods.push(new Uo(e))}invoke(...e){if(this._isInvoking)return console.warn("Circular event invocation detected. Please check your event listeners for circular references.",this),!1;if(this.methods?.length<=0)return!1;this._isInvoking=!0;try{this._methodsCopy.length=0,this._methodsCopy.push(...this.methods);for(const t of this._methodsCopy)t.invoke(...e);if(typeof this.target=="object"&&typeof this.key=="string"){const t=this.target.dispatchEvent;if(typeof t=="function"){const i=new Fu(this.key);i.args=e,t.call(this.target,i)}}}finally{this._isInvoking=!1,this._methodsCopy.length=0}return!0}addEventListener(e){return this.methods.push(new Uo(e)),e}removeEventListener(e){if(e)for(let t=this.methods.length-1;t>=0;t--)this.methods[t].target===e&&(this.methods[t].enabled=!1,this.methods.splice(t,1))}removeAllEventListeners(){this.methods.length=0}}class HR extends Ki{constructor(){super([oe,se],"ColorSerializer")}onDeserialize(e){if(e!=null)return e.a!==void 0?new se(e.r,e.g,e.b,e.a):e.alpha!==void 0?new se(e.r,e.g,e.b,e.alpha):new oe(e.r,e.g,e.b)}onSerialize(e){if(e!=null)return e.a!==void 0?{r:e.r,g:e.g,b:e.b,a:e.a}:{r:e.r,g:e.g,b:e.b}}}const GR=new HR;class qR extends Ki{constructor(){super([rt],"EulerSerializer")}onDeserialize(e,t){if(e!=null){if(e.order)return new rt(e.x,e.y,e.z,e.order);if(e.x!=null)return new rt(e.x,e.y,e.z)}}onSerialize(e,t){return{x:e.x,y:e.y,z:e.z,order:e.order}}}const XR=new qR;class QR extends Ki{constructor(){super(M,"ObjectSerializer")}onSerialize(e,t){if(t.objectToNode!==void 0&&e.uuid){const i=t.objectToNode[e.uuid];return yt&&console.log(i,e.name,e.uuid),{node:i}}}onDeserialize(e,t){if(typeof e=="string"){if(e.endsWith(".glb")||e.endsWith(".gltf")){if(t.serializable instanceof Array&&t.serializable.includes(ne))return;A()&&be("Detected wrong usage of @serializable with Object3D or GameObject. Instead you should use AssetReference here! Please see the console for details.");const i=t.target?.constructor?.name;console.warn(`Wrong usage of @serializable detected in your script "${i}"
|
|
959
959
|
|
|
960
960
|
It looks like you used @serializable(Object3D) or @serializable(GameObject) for a prefab or scene reference which is exported to a separate glTF file.
|
|
961
961
|
|
|
@@ -993,10 +993,10 @@ Consider registering a custom loader via the 'onCreateCustomModelLoader' callbac
|
|
|
993
993
|
|
|
994
994
|
Content-Type: "${t.headers.get("content-type")}"
|
|
995
995
|
"Text: "${s}"
|
|
996
|
-
Binary:`,i)}else console.debug("Could not determine file type from binary data");return"unknown"}const Yf=v("debugstencil");function zE(o,e){return(o&1<<e.layer)!=0}const NE=Symbol("stencils");class dr{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Yf&&console.log(t,dr.stencils),!t)return;const i=dr.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const s=i[n];if(zE(s.layer,e)){Yf&&console.log(s),setTimeout(()=>{Ri()&&yu(e.gameObject)&&(be("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",e))},500);for(let r=0;r<e.sharedMaterials.length;r++){let a=e.sharedMaterials[r];a&&(a=a.clone(),a[NE]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=s.value,a.stencilFunc=s.compareFunc,a.stencilZPass=s.passOp,a.stencilFail=s.failOp,a.stencilZFail=s.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=s.event*1e3+s.index*50;break}}}parser;source;constructor(e,t){this.parser=e,this.source=t}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[VE];if(i){Yf&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const s of n){const r={...s};r.compareFunc=WE(r.compareFunc),r.passOp=Zf(r.passOp),r.failOp=Zf(r.failOp),r.zFailOp=Zf(r.zFailOp),dr.stencils[this.source]||(dr.stencils[this.source]=[]),dr.stencils[this.source].push(r)}}}return null}}function Zf(o){switch(o){case 0:return vC;case 1:return _C;case 2:return bC;case 3:return yC;case 4:return fC;case 6:return gC;case 7:return mC;case 5:return pC}return 0}function WE(o){switch(o){case 1:return fb;case 2:return uC;case 3:return dC;case 4:return hC;case 5:return cC;case 6:return lC;case 7:return aC;case 8:return rC}return fb}const VE="NEEDLE_render_objects";var $E=Object.defineProperty,_x=(o,e,t,i)=>{for(var n=void 0,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=r(e,t,n)||n);return n&&$E(e,t,n),n};const pl=v("debugreflectionprobe"),vx=v("noreflectionprobe"),Kf=Symbol("reflectionProbeKey"),wx=Symbol("original material"),Jf=class ls extends R{static _probes=new Map;static isUsingReflectionProbe(e){return!!(e[Kf]||e[wx]?.[Kf])}static get(e,t,i,n){if(!e||e.isObject3D!==!0||vx)return null;const s=ls._probes.get(t);if(s){for(const r of s)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return pl&&console.log("Found reflection probe",e.name,r.name),r}}return pl&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;set texture(e){this._texture!==e&&(this._texture=e,pl&&console.debug("[ReflectionProbe] Set reflection probe texture "+(e?.name||"(removed)")),e&&(e instanceof yb||e.mapping!==$n&&(e.mapping=$n),e.colorSpace=Oo,e.needsUpdate=!0))}get texture(){return this._texture}center;size;_boxHelper;isInBox(e){return this._boxHelper?.isInBox(e)}constructor(){super(),ls._probes.has(this.context)||ls._probes.set(this.context,[]),ls._probes.get(this.context)?.push(this)}awake(){this._boxHelper=this.gameObject.addComponent(Pt),this._boxHelper.updateBox(!0),pl&&this._boxHelper.showHelper(5592320,!0),this._texture&&(this._texture.mapping=$n,this._texture.colorSpace=Oo,this._texture.needsUpdate=!0)}start(){this._texture||console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`)}onDestroy(){const e=ls._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}static _rendererMaterialsCache=new Map;onSet(e){if(vx||!this.enabled||e.sharedMaterials?.length<=0||!this.texture)return;let t=ls._rendererMaterialsCache.get(e);t||(t=[],ls._rendererMaterialsCache.set(e,t));for(let i=0;i<e.sharedMaterials.length;i++){const n=e.sharedMaterials[i];if(!n||n.envMap===void 0||n instanceof xe)continue;let s=t[i];const r=n===s?.copy,a=!s||s.material.uuid!==n.uuid||s.
|
|
996
|
+
Binary:`,i)}else console.debug("Could not determine file type from binary data");return"unknown"}const Yf=v("debugstencil");function zE(o,e){return(o&1<<e.layer)!=0}const NE=Symbol("stencils");class dr{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Yf&&console.log(t,dr.stencils),!t)return;const i=dr.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const s=i[n];if(zE(s.layer,e)){Yf&&console.log(s),setTimeout(()=>{Ri()&&yu(e.gameObject)&&(be("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",e))},500);for(let r=0;r<e.sharedMaterials.length;r++){let a=e.sharedMaterials[r];a&&(a=a.clone(),a[NE]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=s.value,a.stencilFunc=s.compareFunc,a.stencilZPass=s.passOp,a.stencilFail=s.failOp,a.stencilZFail=s.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=s.event*1e3+s.index*50;break}}}parser;source;constructor(e,t){this.parser=e,this.source=t}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[VE];if(i){Yf&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const s of n){const r={...s};r.compareFunc=WE(r.compareFunc),r.passOp=Zf(r.passOp),r.failOp=Zf(r.failOp),r.zFailOp=Zf(r.zFailOp),dr.stencils[this.source]||(dr.stencils[this.source]=[]),dr.stencils[this.source].push(r)}}}return null}}function Zf(o){switch(o){case 0:return vC;case 1:return _C;case 2:return bC;case 3:return yC;case 4:return fC;case 6:return gC;case 7:return mC;case 5:return pC}return 0}function WE(o){switch(o){case 1:return fb;case 2:return uC;case 3:return dC;case 4:return hC;case 5:return cC;case 6:return lC;case 7:return aC;case 8:return rC}return fb}const VE="NEEDLE_render_objects";var $E=Object.defineProperty,_x=(o,e,t,i)=>{for(var n=void 0,s=o.length-1,r;s>=0;s--)(r=o[s])&&(n=r(e,t,n)||n);return n&&$E(e,t,n),n};const pl=v("debugreflectionprobe"),vx=v("noreflectionprobe"),Kf=Symbol("reflectionProbeKey"),wx=Symbol("original material"),Jf=class ls extends R{static _probes=new Map;static isUsingReflectionProbe(e){return!!(e[Kf]||e[wx]?.[Kf])}static get(e,t,i,n){if(!e||e.isObject3D!==!0||vx)return null;const s=ls._probes.get(t);if(s){for(const r of s)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return pl&&console.log("Found reflection probe",e.name,r.name),r}}return pl&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;set texture(e){this._texture!==e&&(this._texture=e,pl&&console.debug("[ReflectionProbe] Set reflection probe texture "+(e?.name||"(removed)")),e&&(e instanceof yb||e.mapping!==$n&&(e.mapping=$n),e.colorSpace=Oo,e.needsUpdate=!0))}get texture(){return this._texture}center;size;_boxHelper;isInBox(e){return this._boxHelper?.isInBox(e)}constructor(){super(),ls._probes.has(this.context)||ls._probes.set(this.context,[]),ls._probes.get(this.context)?.push(this)}awake(){this._boxHelper=this.gameObject.addComponent(Pt),this._boxHelper.updateBox(!0),pl&&this._boxHelper.showHelper(5592320,!0),this._texture&&(this._texture.mapping=$n,this._texture.colorSpace=Oo,this._texture.needsUpdate=!0)}start(){this._texture||console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`)}onDestroy(){const e=ls._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}static _rendererMaterialsCache=new Map;onSet(e){if(vx||!this.enabled||e.sharedMaterials?.length<=0||!this.texture)return;let t=ls._rendererMaterialsCache.get(e);t||(t=[],ls._rendererMaterialsCache.set(e,t));for(let i=0;i<e.sharedMaterials.length;i++){const n=e.sharedMaterials[i];if(!n||n.envMap===void 0||n instanceof xe)continue;let s=t[i];const r=n===s?.copy,a=!s||s.material.uuid!==n.uuid||s.originalVersion!==n.version;if(!r&&a){if(pl){let h="";s?s.material!==n?h="reference changed; cached instance?: "+r:s.originalVersion!==n.version&&(h="version changed"):h="not cached",console.warn("Cloning material",n.name,n.version,"Reason:",h,`
|
|
997
997
|
`,n.uuid,`
|
|
998
998
|
`,s?.copy.uuid,`
|
|
999
|
-
`,e.name)}const c=n.clone();c.version=n.version,s?(s.copy=c,s.material=n):(s={material:n,copy:c},t.push(s)),c[Kf]=this,c[wx]=n,pl&&console.log("Set reflection",e.name,e.guid)}s&&s.copy&&(s.copy.onBeforeCompile=n.onBeforeCompile);const l=s?.copy;"envMap"in l&&(l.envMap=this.texture,l.needsUpdate=!0),e.sharedMaterials[i]=l}}onUnset(e){const t=ls._rendererMaterialsCache.get(e);if(t)for(let i=0;i<t.length;i++){const n=t[i];e.sharedMaterials[i]=n.material}}};_x([u(b)],Jf.prototype,"center"),_x([u(b)],Jf.prototype,"size");let ih=Jf;const ey=v("debugexr");class HE{get name(){return"EXT_texture_exr"}parser;constructor(e){this.parser=e,ey&&console.log(e)}loadTexture(e){const t=this.name,i=this.parser,n=i.json.textures[e];if(ey&&console.log("EXT_texture_exr.loadTexture",e,n),!n.extensions||!n.extensions[t])return null;const s=n.extensions[t],r=new Im(i.options.manager);return ey&&console.log("EXT_texture_exr.loadTexture",s),i.loadTextureImage(e,s.source,r)}}typeof window<"u"&&window.addEventListener("unhandledrejection",o=>{});const ro=yt,Yu="$___Export_Components",GE="NEEDLE_components";class qE{[Pr]}class XE{node;nodeIndex;nodeDef;constructor(e,t,i){this.node=e,this.nodeIndex=t,this.nodeDef=i}}class xx{get name(){return GE}exportContext;objectToNodeMap={};context;writer;registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(n,s)=>{try{this.serializeUserData(n,s)&&(t.extensionsUsed[this.name]=!0),i(n,s)}finally{this.afterSerializeUserData(n,s)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){const i=e.userData?.components;return!i||i.length<=0?!1:(delete e.userData.components,e[Yu]=i,!0)}afterSerializeUserData(e,t){if(e.type==="Scene"&&ro&&console.log("DONE",JSON.stringify(t)),e[Yu]===void 0)return;const i=e[Yu];delete e[Yu],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;ro&&console.log(e.name,i,e.uuid);const n=new XE(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){ro&&console.log("AFTER",e);for(const t in this.exportContext){const i=this.exportContext[t],n=i.node,s=i.nodeDef,r=i.nodeIndex,a=n.userData?.components;if(!a||a.length<=0)continue;const l=new qE;s.extensions=s.extensions||{},s.extensions[this.name]=l,this.context.object=n,this.context.nodeId=r,this.context.objectToNode=this.objectToNodeMap;const c=[];for(const h of a){this.context.target=h;const d=Cn().writeBuiltinComponentData(h,this.context);d!==null&&c.push(d)}c.length>0&&(l[Pr]=c,ro&&console.log("DID WRITE",n,"nodeIndex",r,c))}}parser;nodeToObjectMap={};gltf=null;beforeRoot(){return ro&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){this.gltf=e;const t=e.parser,i=t?.extensions;if(!i)return;const n=i[this.name];ro&&console.log("After root",e,this.parser,i);const s=[];if(n===!0){const r=t.json.nodes;if(r){for(let a=0;a<r.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<r.length;a++){const l=r[a],c=a,h=l.extensions;if(!h)continue;const d=h[this.name];if(!d)continue;ro&&console.log("NODE",l);const p=this.nodeToObjectMap[c];if(!p){console.error("Could not find object for node index: "+c,l,t);continue}gu(p),s.push(this.createComponents(e,l,p,d))}}}await Promise.all(s);for(const r of t.associations.keys()){const a=t.associations.get(r);if(a?.materials!=null){const l="/materials/"+a.materials;gM(r,l)}}}async createComponents(e,t,i,n){if(!n)return;const s=n[Pr];if(s){const r=new Array;ro&&console.log(i.name,s);for(const a in s){const l=s[a];if(ro&&console.log("Serialized data",JSON.parse(JSON.stringify(l))),(l?.name==="MeshRenderer"||l?.name==="SkinnedMeshRenderer")&&!l.sharedMaterials){let c=!1;if("mesh"in t){const h=t.mesh;if(typeof h=="number"&&e.parser){const d=e.parser.json.meshes?.[h];d?.primitives&&(l.sharedMaterials=d.primitives.map(p=>"/materials/"+(p.material??0)),c=!0)}}!c&&(ro||A())&&console.warn(`[NEEDLE_components] Component '${l.name}' on object '${i.name}' is not added to a mesh or failed to retrieve materials from glTF.`)}l&&this.parser&&r.push(qg(this.parser,l).catch(c=>console.error(`Error while resolving references (see console for details)
|
|
999
|
+
`,e.name)}const c=n.clone();c.version=n.version,s?(s.copy=c,s.material=n,s.originalVersion=n.version):(s={material:n,copy:c,originalVersion:n.version},t.push(s)),c[Kf]=this,c[wx]=n,pl&&console.log("Set reflection",e.name,e.guid)}s&&s.copy&&(s.copy.onBeforeCompile=n.onBeforeCompile);const l=s?.copy;"envMap"in l&&l.envMap!==this.texture&&(l.envMap=this.texture,l.needsUpdate=!0),e.sharedMaterials[i]=l}}onUnset(e){const t=ls._rendererMaterialsCache.get(e);if(t)for(let i=0;i<t.length;i++){const n=t[i];e.sharedMaterials[i]=n.material}}};_x([u(b)],Jf.prototype,"center"),_x([u(b)],Jf.prototype,"size");let ih=Jf;const ey=v("debugexr");class HE{get name(){return"EXT_texture_exr"}parser;constructor(e){this.parser=e,ey&&console.log(e)}loadTexture(e){const t=this.name,i=this.parser,n=i.json.textures[e];if(ey&&console.log("EXT_texture_exr.loadTexture",e,n),!n.extensions||!n.extensions[t])return null;const s=n.extensions[t],r=new Im(i.options.manager);return ey&&console.log("EXT_texture_exr.loadTexture",s),i.loadTextureImage(e,s.source,r)}}typeof window<"u"&&window.addEventListener("unhandledrejection",o=>{});const ro=yt,Yu="$___Export_Components",GE="NEEDLE_components";class qE{[Pr]}class XE{node;nodeIndex;nodeDef;constructor(e,t,i){this.node=e,this.nodeIndex=t,this.nodeDef=i}}class xx{get name(){return GE}exportContext;objectToNodeMap={};context;writer;registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(n,s)=>{try{this.serializeUserData(n,s)&&(t.extensionsUsed[this.name]=!0),i(n,s)}finally{this.afterSerializeUserData(n,s)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){const i=e.userData?.components;return!i||i.length<=0?!1:(delete e.userData.components,e[Yu]=i,!0)}afterSerializeUserData(e,t){if(e.type==="Scene"&&ro&&console.log("DONE",JSON.stringify(t)),e[Yu]===void 0)return;const i=e[Yu];delete e[Yu],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;ro&&console.log(e.name,i,e.uuid);const n=new XE(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){ro&&console.log("AFTER",e);for(const t in this.exportContext){const i=this.exportContext[t],n=i.node,s=i.nodeDef,r=i.nodeIndex,a=n.userData?.components;if(!a||a.length<=0)continue;const l=new qE;s.extensions=s.extensions||{},s.extensions[this.name]=l,this.context.object=n,this.context.nodeId=r,this.context.objectToNode=this.objectToNodeMap;const c=[];for(const h of a){this.context.target=h;const d=Cn().writeBuiltinComponentData(h,this.context);d!==null&&c.push(d)}c.length>0&&(l[Pr]=c,ro&&console.log("DID WRITE",n,"nodeIndex",r,c))}}parser;nodeToObjectMap={};gltf=null;beforeRoot(){return ro&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){this.gltf=e;const t=e.parser,i=t?.extensions;if(!i)return;const n=i[this.name];ro&&console.log("After root",e,this.parser,i);const s=[];if(n===!0){const r=t.json.nodes;if(r){for(let a=0;a<r.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<r.length;a++){const l=r[a],c=a,h=l.extensions;if(!h)continue;const d=h[this.name];if(!d)continue;ro&&console.log("NODE",l);const p=this.nodeToObjectMap[c];if(!p){console.error("Could not find object for node index: "+c,l,t);continue}gu(p),s.push(this.createComponents(e,l,p,d))}}}await Promise.all(s);for(const r of t.associations.keys()){const a=t.associations.get(r);if(a?.materials!=null){const l="/materials/"+a.materials;gM(r,l)}}}async createComponents(e,t,i,n){if(!n)return;const s=n[Pr];if(s){const r=new Array;ro&&console.log(i.name,s);for(const a in s){const l=s[a];if(ro&&console.log("Serialized data",JSON.parse(JSON.stringify(l))),(l?.name==="MeshRenderer"||l?.name==="SkinnedMeshRenderer")&&!l.sharedMaterials){let c=!1;if("mesh"in t){const h=t.mesh;if(typeof h=="number"&&e.parser){const d=e.parser.json.meshes?.[h];d?.primitives&&(l.sharedMaterials=d.primitives.map(p=>"/materials/"+(p.material??0)),c=!0)}}!c&&(ro||A())&&console.warn(`[NEEDLE_components] Component '${l.name}' on object '${i.name}' is not added to a mesh or failed to retrieve materials from glTF.`)}l&&this.parser&&r.push(qg(this.parser,l).catch(c=>console.error(`Error while resolving references (see console for details)
|
|
1000
1000
|
`,c,i,l))),i.userData=i.userData||{},i.userData[Pr]=i.userData[Pr]||[],i.userData[Pr].push(l)}await Promise.all(r).catch(a=>{console.error("Error while loading components",a)})}}}const Sx="NEEDLE_gameobject_data";class QE{get name(){return Sx}parser;constructor(e){this.parser=e}afterRoot(e){const t=[];for(let i=0;i<this.parser.json.nodes?.length;i++){const n=this.parser.json.nodes[i];if(n&&n.extensions){const s=n.extensions[Sx];if(s){const r=this.findAndApplyExtensionData(i,s);t.push(r)}}}return Promise.all(t).then(()=>null)}async findAndApplyExtensionData(e,t){const i=await this.parser.getDependency("node",e);i&&this.applyExtensionData(i,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.hideFlags=0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const Cx="NEEDLE_lighting_settings",ml=v("debugenvlight");class YE{get name(){return Cx}parser;sourceId;context;constructor(e,t,i){this.parser=e,this.sourceId=t,this.context=i}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[Cx];if(i){ml&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const s=e.scene.children[0];n=S.addComponent(s,Zu,{},{callAwake:!1})}else{const s=new M;s.name="LightSettings "+this.sourceId,e.scene.add(s),n=S.addComponent(s,Zu,{},{callAwake:!1})}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new oe().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(s=>new oe().fromArray(s))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}pe.registerCallback(ue.ContextCreated,o=>{const e=o.context,t=S.findObjectOfType(Zu,e);t?.sourceId&&(t.enabled=!0)});class Zu extends R{ambientMode=nl.Skybox;ambientLight;ambientTrilight;ambientIntensity=1;environmentReflectionSource=Cu.Skybox;_hasReflection=!1;_ambientLightObj;_hemisphereLightObj;awake(){if(this.sourceId){const t=this.environmentReflectionSource===Cu.Skybox?Zn.Skybox:Zn.Reflection,i=this.context.lightmaps.tryGet(this.sourceId,t,0);this._hasReflection=i!=null,i&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,i)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),ml&&window.addEventListener("keydown",t=>{this.destroyed||t.key==="l"&&(this.enabled=!this.enabled)});const e=this.gameObject.userData?.components;if(e){const t=e.indexOf(this);e.splice(t,1),e.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*j.lerp(0,1.33,t)}onEnable(){if(ml&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==nl.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new wC(this.ambientLight,this.ambientIntensity*e),ml&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===nl.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],i=this.calculateIntensityFactor(t);this._hemisphereLightObj=new xC(t,e,this.ambientIntensity*i),this.gameObject.add(this._hemisphereLightObj),ml&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,i)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&(this.context.domElement.getAttribute("environment-image")||this.context.sceneLighting.internalEnableReflection(this.sourceId))}onDisable(){ml&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var Ku;(o=>{async function e(t,i){if(!t)throw new Error("URL or XML string is required to load a MaterialX material");const n=await T.MaterialX.load(),s=t.trimStart().startsWith("<"),r=s?t:await fetch(t).then(c=>c.text()).catch(console.error);if(!r)return console.warn("Failed to load MaterialX file from url",t),null;let a;if(i?.url||!s){const c=(i?.url||t).split("/");c.pop(),a=c.join("/")}const l=new gr;return n.Experimental_API.createMaterialXMaterial(r,i?.materialNameOrIndex??0,{getTexture:async c=>(!c.startsWith("http")&&!c.startsWith("data:")&&!c.startsWith("blob:")&&!c.startsWith("file:")&&a&&(c=a+"/"+c),l.loadAsync(c).catch(h=>{console.warn(`Failed to load texture for MaterialX material ${c}`,h)}))},{cacheKey:t})}o.loadFromUrl=e})(Ku||(Ku={}));class ZE extends SC{loadAsync(e,t){return new Promise((i,n)=>{this.load(e,i,t,n)})}load(e,t,i,n){i?.({type:"progress",loaded:0,total:0}),Ku.loadFromUrl(e,{}).then(s=>{s?t(this.onLoaded(s)):n?.(new Error("Failed to load MaterialX material from url: "+e))})}onLoaded(e){return Ss.createPrimitive("ShaderBall",{material:e})}}class KE{constructor(e,t,i,n){this.context=e,this.loader=t,this.url=i,this.parser=n}get name(){return"materialx-loading-helper"}mtlxLoader;async beforeRoot(){if(this.parser.json.extensions?.NEEDLE_materials_mtlx){const e=await T.MaterialX.load();try{this.mtlxLoader=new e.MaterialXLoader(this.parser,{cacheKey:`${this.url}:materialx`,parameters:{precision:this.context.renderer?.capabilities.precision}},{getFrame:()=>this.context.time.frame,getTime:()=>this.context.time.time})}catch(t){console.error(t)}}}loadMaterial(e){return this.mtlxLoader?this.mtlxLoader.loadMaterial(e):null}}var Px=(o=>(o[o.INT=5124]="INT",o[o.FLOAT=5126]="FLOAT",o[o.FLOAT_VEC2=35664]="FLOAT_VEC2",o[o.FLOAT_VEC3=35665]="FLOAT_VEC3",o[o.FLOAT_VEC4=35666]="FLOAT_VEC4",o[o.INT_VEC2=35667]="INT_VEC2",o[o.INT_VEC3=35668]="INT_VEC3",o[o.INT_VEC4=35669]="INT_VEC4",o[o.BOOL=35670]="BOOL",o[o.BOOL_VEC2=35671]="BOOL_VEC2",o[o.BOOL_VEC3=35672]="BOOL_VEC3",o[o.BOOL_VEC4=35673]="BOOL_VEC4",o[o.FLOAT_MAT2=35674]="FLOAT_MAT2",o[o.FLOAT_MAT3=35675]="FLOAT_MAT3",o[o.FLOAT_MAT4=35676]="FLOAT_MAT4",o[o.SAMPLER_2D=35678]="SAMPLER_2D",o[o.SAMPLER_3D=35680]="SAMPLER_3D",o[o.SAMPLER_CUBE=35681]="SAMPLER_CUBE",o[o.UNKNOWN=0]="UNKNOWN",o))(Px||{});const ao=v("debugcustomshader"),gl="NEEDLE_techniques_webgl";class JE{objectToWorldMatrix=new K;worldToObjectMatrix=new K;objectToWorld=new Array;worldToObject=new Array;updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),Su(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),Su(this.worldToObjectMatrix,this.worldToObject)}}class Ee extends bb{identifier;onBeforeRenderSceneCallback=this.onBeforeRenderScene.bind(this);clone(){const e=super.clone();return Ox(e),e}constructor(e,...t){super(...t),this.identifier=e,ao&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&U.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}dispose(){super.dispose();const e=U.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);e>=0&&U.Current.pre_render_callbacks.splice(e,1)}_sphericalHarmonicsName="unity_SpecCube0";_objToWorldName="hlslcc_mtx4x4unity_ObjectToWorld";_worldToObjectName="hlslcc_mtx4x4unity_WorldToObject";static viewProjection=new K;static _viewProjectionValues=[];_viewProjectionName="hlslcc_mtx4x4unity_MatrixVP";static viewMatrix=new K;static _viewMatrixValues=[];_viewMatrixName="hlslcc_mtx4x4unity_MatrixV";static _worldSpaceCameraPosName="_WorldSpaceCameraPos";static _worldSpaceCameraPos=new b;static _mainLightColor=new me;static _mainLightPosition=new b;static _lightData=new me;_rendererData=new JE;get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&U.Current.setRequireColor(!0),this.depthTextureUniform&&U.Current.setRequireDepth(!0)}onBeforeRender(e,t,i,n,s,r){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(i,s)}onUpdateUniforms(e,t){const i=U.Current;if(e&&(Ee.viewProjection&&this.uniforms[this._viewProjectionName]&&(Ee.viewProjection.copy(e.projectionMatrix).multiply(e.matrixWorldInverse),Su(Ee.viewProjection,Ee._viewProjectionValues)),Ee.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Ee.viewMatrix.copy(e.matrixWorldInverse),Su(Ee.viewMatrix,Ee._viewMatrixValues)),this.uniforms[Ee._worldSpaceCameraPosName]&&Ee._worldSpaceCameraPos.setFromMatrixPosition(e.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=i.sceneLighting.timeVec4),this.uniforms._Time){const a=this.uniforms._Time.value;a.x=i.sceneLighting.timeVec4.x/20,a.y=i.sceneLighting.timeVec4.x,a.z=i.sceneLighting.timeVec4.x*2,a.w=i.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const a=this.uniforms._SinTime.value;a.x=Math.sin(i.sceneLighting.timeVec4.x/8),a.y=Math.sin(i.sceneLighting.timeVec4.x/4),a.z=Math.sin(i.sceneLighting.timeVec4.x/2),a.w=Math.sin(i.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const a=this.uniforms._CosTime.value;a.x=Math.cos(i.sceneLighting.timeVec4.x/8),a.y=Math.cos(i.sceneLighting.timeVec4.x/4),a.z=Math.cos(i.sceneLighting.timeVec4.x/2),a.w=Math.cos(i.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const a=this.uniforms.unity_DeltaTime.value;a.x=i.time.deltaTime,a.y=1/i.time.deltaTime,a.z=i.time.smoothedDeltaTime,a.w=1/i.time.smoothedDeltaTime}const n=i.mainLight;if(n){const a=J(n.gameObject,Ee._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},Ee._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:Ee._mainLightColor};const l=n.intensity;Ee._lightData.z=l,this.uniforms.unity_LightData={value:Ee._lightData}}if(e&&(Ee.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Ee._viewProjectionValues),Ee.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Ee._viewMatrixValues),this.uniforms[Ee._worldSpaceCameraPosName]&&(this.uniforms[Ee._worldSpaceCameraPosName]={value:Ee._worldSpaceCameraPos}),i.mainCameraComponent)){if(this.uniforms._ProjectionParams){const a=this.uniforms._ProjectionParams.value;a.x=1,a.y=i.mainCameraComponent.nearClipPlane,a.z=i.mainCameraComponent.farClipPlane,a.w=1/a.z,this.uniforms._ProjectionParams.value=a}if(this.uniforms._ZBufferParams){const a=this.uniforms._ZBufferParams.value,l=i.mainCameraComponent;a.x=1-l.farClipPlane/l.nearClipPlane,a.y=l.farClipPlane/l.nearClipPlane,a.z=a.x/l.farClipPlane,a.w=a.y/l.farClipPlane,this.uniforms._ZBufferParams.value=a}if(this.uniforms._ScreenParams){const a=this.uniforms._ScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScreenParams.value=a}if(this.uniforms._ScaledScreenParams){const a=this.uniforms._ScaledScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScaledScreenParams.value=a}}const s=this.depthTextureUniform;s&&(s.value=i.depthTexture);const r=this.opaqueTextureUniform;if(r&&(r.value=i.opaqueColorTexture),t){const a=this._rendererData;a.updateFrom(t),this.uniforms[this._worldToObjectName].value=a.worldToObject,this.uniforms[this._objToWorldName].value=a.objectToWorld}this.uniformsNeedUpdate=!0}}class eT{get name(){return gl}parser;identifier;constructor(e,t){this.parser=e,this.identifier=t}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return ao&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[gl])return ao&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;ao&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,t);const i=t.extensions[gl].technique;if(i<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const n=this.parser.json.extensions[gl];if(!n)return ao?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;ao&&console.log(n);const s=n.techniques[i];return s?new Promise(async(r,a)=>{const l=await QM(n,s.program),c=l?.fragmentShader,h=l?.vertexShader;if(!c||!h)return a();ao&&console.log("loadMaterial",t,l);const d={},p=s.uniforms;(h.includes("_Time")||c.includes("_Time"))&&(d._Time={value:new me(0,0,0,0)}),(h.includes("_SinTime")||c.includes("_SinTime"))&&(d._SinTime={value:new me(0,0,0,0)}),(h.includes("_CosTime")||c.includes("_CosTime"))&&(d._CosTime={value:new me(0,0,0,0)}),(h.includes("unity_DeltaTime")||c.includes("unity_DeltaTime"))&&(d.unity_DeltaTime={value:new me(0,0,0,0)});for(const f in p){const y=f;switch(y){case"_TimeParameters":const _=new me;d[y]={value:_};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":d[y]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":d[y]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":d[y]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":d[y]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":d[y]={value:null};break}}let m=!1;if(t.extensions&&t.extensions[gl]){const f=t.extensions[gl];if(f.technique===i){ao&&console.log(t.name,"Material Properties",f);for(const y in f.values){const _=f.values[y];if(typeof _=="string"){if(_.startsWith("/textures/")){const w=_.substring(10),P=Number.parseInt(w);if(P>=0){const k=await this.parser.getDependency("texture",P);k instanceof Le&&(k.colorSpace=Oo,k.needsUpdate=!0),d[y]={value:k};continue}}if(y==="alphaMode"){_==="BLEND"&&(m=!0);continue}}if(Array.isArray(_)&&_.length===4){d[y]={value:new me(_[0],_[1],_[2],_[3])};continue}d[y]={value:_}}}}const g=new Ee(this.identifier,{name:t.name??"",uniforms:d,vertexShader:h,fragmentShader:c,lights:!1});switch(g.glslVersion=CC,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),d._Cull?.value){case 0:g.side=ki;break;case 1:g.side=Ld;break;case 2:g.side=ys;break;default:g.side=ys;break}switch(d._ZTest?.value){case 3:g.depthTest=!0,g.depthFunc=TC;break;case 6:g.depthTest=!0,g.depthFunc=EC;break;case 2:g.depthTest=!0,g.depthFunc=RC;break;case 4:g.depthTest=!0,g.depthFunc=MC;break;case 5:g.depthTest=!0,g.depthFunc=kC;break;case 7:g.depthTest=!0,g.depthFunc=OC;break;case 8:g.depthTest=!1,g.depthFunc=PC;break}g.transparent=m,m&&(g.depthWrite=!1),qM(d),g.onUpdateUniforms();for(const f in p){const y=f,_=p[f].type;d[y]?.value===void 0&&(_===Px.SAMPLER_2D?(d[y]={value:HM},console.warn("Missing/unassigned texture, fallback to white: "+y)):y==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+y,p[f]))}ao&&console.log(g.uuid,d),Ox(g),r(g)}):null}}function Ox(o){if(o.uniforms){ao&&console.log("Uniforms:",o.uniforms);for(const t in o.uniforms)e(t,t),t==="_Color"&&e("color",t)}function e(t,i){Object.getOwnPropertyDescriptor(o,t)||Object.defineProperty(o,t,{get:()=>o.uniforms[i].value,set:n=>{o.uniforms[i].value=n,o.needsUpdate=!0}})}}const tT=v("debugextensions");let Ju;const iT=import("./vendor-DW7zqjuT.min.js").then(o=>o.index$2).then(async o=>(Ju=o.GLTFAnimationPointerExtension,Ju)).catch(o=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three-animationpointer for full KHR_animation support",o)}),Qr=new Array;function nT(o){Qr.includes(o)||Qr.push(o)}function oT(o){const e=Qr.indexOf(o);e>=0&&Qr.splice(e,1)}function ty(o){if(o instanceof Mo){const e=new xx;return o.register(t=>(e.parser=t,e)),e}return null}class sT{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function ep(o,e,t,i){const n=t.indexOf("?");n>=0&&(t=t.substring(0,n)),i||(i=t),(i.startsWith("blob:")||i.startsWith("data:"))&&console.debug("[GLTFLoader] Suspicious sourceId detected"),o.register(s=>new QE(s)),o.register(s=>new yM(s)),o.register(s=>new NM(s,e.lightmaps,i)),o.register(s=>new YE(s,i,e)),o.register(s=>new eT(s,i)),o.register(s=>new dr(s,i)),o.register(s=>new Ve(s)),o.register(s=>new HE(s)),o.register(s=>new KE(e,o,t,s)),gv()&&o.register(s=>new tc(s)),await iT.catch(s=>{}),o.register(s=>{if(Ju){const r=new Ju(s);return r.setAnimationPointerResolver.bind(r)(new sT),r}else return(tT||A())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const s of Qr)s.onImport&&s.onImport(o,t,e)}function iy(o,e){for(const t of Qr)t.onExport&&t.onExport(o,e)}function kx(o,e,t){for(const i of Qr)i.onLoaded&&i.onLoaded(o,e,t)}const Wt=v("debuginstancing");class Ca{static instance=new Ca;static getStartInstanceCount=e=>4;objs=[];setup(e,t,i,n,s,r=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,s);if(a){n===null&&(n=[]),n.push(a);const l=a.object.material;Array.isArray(l)?l.forEach(d=>Ve.assignTextureLOD(d,0)):Ve.assignTextureLOD(l,0);const c=a.object,h=c.geometry;Ve.assignMeshLOD(c,0).then(d=>{d&&h!=d&&a.setGeometry(d)})}else if(r<=0&&t.type!=="Mesh"){const l=r+1;for(const c of t.children)n=this.setup(e,c,i,n,s,l)}return r===0&&s.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(t),n}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const n=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(n>=i.rend.enableInstancing.length)return Wt&&console.error("Something is wrong with instance setup",e,i.rend.enableInstancing,n),null;if(!i.rend.enableInstancing[n])return null}const s=e,r=s.material;for(const h of this.objs)if(!!h.canAdd(s.geometry,r))return h.addInstance(s);let a=Ca.getStartInstanceCount(e);(!a||a<0)&&(a=4);let l=e.name;l?.length||(l=qb());const c=new rT(l,s.geometry,r,a,t);return this.objs.push(c),c.addInstance(s)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),n=(s,r)=>{const a=t(s,r);return(e[kc]||i.equals(a)===!1)&&(i.copy(a),e[kc]=!0),a};e.matrixWorld.multiplyMatrices=n}}class Ma{static all=[];get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return Math.max(this.meshInformation.vertexCount,this.vertexCount)}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return Math.max(this.meshInformation.indexCount,this.indexCount)}get reservedIndexCount(){return this.__reservedIndexRange}object;renderer;__instanceIndex=-1;__reservedVertexRange=0;__reservedIndexRange=0;__geometryIndex=-1;meshInformation;constructor(e,t){this.__instanceIndex=-1,this.object=e,this.renderer=t,e[wv]=t,this.meshInformation=Yr(e.geometry),Ma.all.push(this)}updateMeshInformation(){const e=Yr(this.object.geometry),t=this.meshInformation.vertexCount,i=this.meshInformation.indexCount;return Object.assign(this.meshInformation,e),t!==this.meshInformation.vertexCount||i!==this.meshInformation.indexCount}updateInstanceMatrix(e=!1,t=!0){this.__instanceIndex<0||(t&&this.object.updateWorldMatrix(!0,e),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(e){this.__instanceIndex<0||this.renderer.updateInstance(e,this.__instanceIndex)}setGeometry(e){if(this.__geometryIndex<0)return!1;const t=this;if(this.vertexCount>this.__reservedVertexRange)return i(`Instancing: Can not update geometry (${this.name}), reserved vertex range is too small: ${this.__reservedVertexRange.toLocaleString()} < ${this.vertexCount.toLocaleString()} vertices for ${this.name}`);if(this.indexCount>this.__reservedIndexRange)return i(`Instancing: Can not update geometry (${this.name}), reserved index range is too small: ${this.__reservedIndexRange.toLocaleString()} < ${this.indexCount.toLocaleString()} indices for ${this.name}`);return this.renderer.updateGeometry(e,this.__geometryIndex);function i(n){return t.updateMeshInformation()&&(t.renderer.remove(t,!0),t.renderer.add(t))?!0:((A()||Wt)&&console.error(n),!1)}}add(){this.__instanceIndex>=0||(this.renderer.add(this),S.markAsInstancedRendered(this.object,!0))}remove(e){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,e),S.markAsInstancedRendered(this.object,!1),e)){const t=Ma.all.indexOf(this);t>=0&&Ma.all.splice(t,1)}}}class rT{get batchedMesh(){return this._batchedMesh}get visible(){return this._batchedMesh.visible}set visible(e){this._batchedMesh.visible=e}get castShadow(){return this._batchedMesh.castShadow}set castShadow(e){this._batchedMesh.castShadow=e}set receiveShadow(e){this._batchedMesh.receiveShadow=e}allowResize=!0;name="";geometry;material;get count(){return this._currentInstanceCount}updateBounds(e=!0,t=!0){if(this._needUpdateBounds=!1,e&&this._batchedMesh.computeBoundingBox(),t&&this._batchedMesh.computeBoundingSphere(),Wt&&this._batchedMesh.boundingSphere){const i=this._batchedMesh.boundingSphere;B.DrawWireSphere(i.center,i.radius,65280)}}_context;_batchedMesh;_handles=[];_geometryIds=new WeakMap;_maxInstanceCount;_currentInstanceCount=0;_currentVertexCount=0;_currentIndexCount=0;_maxVertexCount;_maxIndexCount;static nullMatrix=new K;canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material||!this.validateGeometry(e)?!1:!!(!this.mustGrow(e)||this.allowResize)}_needUpdateBounds=!1;_debugMaterial=null;getBatchedMeshName(){return this.name?`${this.name} (BatchedMesh)`:"BatchedMesh"}constructor(e,t,i,n,s){this.name=e,this.geometry=t,this.material=i,this._context=s,this._maxInstanceCount=Math.max(2,n),Wt&&(this._debugMaterial=Mx());const r=this.tryEstimateVertexCountSize(this._maxInstanceCount,[t],n);this._maxVertexCount=r.vertexCount,this._maxIndexCount=r.indexCount,this._batchedMesh=new _b(this._maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this._batchedMesh.name=this.getBatchedMeshName(),this._batchedMesh[Mc]=!0,this._batchedMesh.visible=!0,this._context.scene.add(this._batchedMesh),i instanceof bb&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),s.pre_render_callbacks.push(this.onBeforeRender),s.post_render_callbacks.push(this.onAfterRender),Wt&&console.log(`Instanced renderer (${this.name}) created with ${this._maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}dispose(){Wt&&console.warn("Dispose instanced renderer",this.name),this._context.scene.remove(this._batchedMesh),this._batchedMesh.dispose(),this._batchedMesh=null,this._handles=[]}addInstance(e){const t=new Ma(e,this);e.castShadow===!0&&this._batchedMesh.castShadow===!1&&(this._batchedMesh.castShadow=!0),e.receiveShadow===!0&&this._batchedMesh.receiveShadow===!1&&(this._batchedMesh.receiveShadow=!0);try{this.add(t)}catch(i){if(console.error(`Failed adding mesh to instancing (object name: "${e.name}", instances: ${this._currentInstanceCount.toLocaleString()}/${this._maxInstanceCount.toLocaleString()}, vertices: ${this._currentVertexCount.toLocaleString()}/${this._maxVertexCount.toLocaleString()}, indices: ${this._currentIndexCount.toLocaleString()}/${this._maxIndexCount.toLocaleString()})
|
|
1001
1001
|
`,i),A()){fc("Failed instancing mesh. See the browser console for details.");debugger}return null}return t}add(e){const t=e.object.geometry;if(!t||!t.attributes)return console.error("Cannot add object to instancing without geometry",e.name),!1;if(this._currentInstanceCount+1>this._maxInstanceCount||this.mustGrow(t))if(this.allowResize)this.grow(t);else return console.error("Cannot add instance, max count reached",this.name,this.count,this._maxInstanceCount),!1;return e.object.updateWorldMatrix(!0,!0),this.addGeometry(e),this._handles[e.__instanceIndex]=e,this._currentInstanceCount+=1,this.markNeedsUpdate(),this._currentInstanceCount>0&&(this._batchedMesh.visible=!0),!0}remove(e,t){e&&(e.__instanceIndex<0||this._handles[e.__instanceIndex]!=e||this._currentInstanceCount<=0||(this.removeGeometry(e,t),this._handles[e.__instanceIndex]=null,e.__instanceIndex=-1,this._currentInstanceCount>0&&(this._currentInstanceCount-=1),this._currentInstanceCount<=0&&(this._batchedMesh.visible=!1),this.markNeedsUpdate()))}updateInstance(e,t){this._batchedMesh.setMatrixAt(t,e),this.markNeedsUpdate()}updateGeometry(e,t){return this.validateGeometry(e)?(this.mustGrow()&&this.grow(e),Wt&&console.debug("[Instancing] UPDATE GEOMETRY at "+t,this._batchedMesh._geometryCount,e.name,Yr(e),e.attributes.position.count,e.index?e.index.count:0),this._batchedMesh.setGeometryAt(t,e),this._geometryIds.set(e,t),this.markNeedsUpdate(),!0):!1}onBeforeRender=()=>{this._batchedMesh.layers.enableAll(),this._needUpdateBounds&&this._batchedMesh[Mc]===!0&&(Wt==="verbose"&&console.log("Update instancing bounds",this.name,this._batchedMesh.matrixWorldNeedsUpdate),this.updateBounds())};onAfterRender=()=>{this._batchedMesh.layers.disableAll()};validateGeometry(e){const t=this.geometry;for(const i in t.attributes)if(i!=="batchId"&&!e.hasAttribute(i))return A()&&console.warn(`BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`),!1;return!0}markNeedsUpdate(){Wt==="verbose"&&console.warn("Marking instanced mesh dirty",this.name),this._needUpdateBounds=!0}mustGrow(e){if(this.count>=this._maxInstanceCount)return!0;if(!e||!e.attributes||this._geometryIds.has(e))return!1;const t=Yr(e),i=t.vertexCount,n=t.indexCount;return this._currentVertexCount+i>this._maxVertexCount||this._currentIndexCount+n>this._maxIndexCount}_growId=0;grow(e){const t=++this._growId,i=this.count>=this._maxInstanceCount?Math.ceil(this._maxInstanceCount*2):this._maxInstanceCount,n=this.tryEstimateVertexCountSize(i,[e]),s=1.25,r=Math.max(this._maxVertexCount,Math.ceil(n.vertexCount*s)),a=Math.max(this._maxIndexCount,Math.ceil(n.indexCount*s));if(Wt){const h=Yr(e);console.warn(`[Instancing] Growing Buffer
|
|
1002
1002
|
Mesh: "${this.name}${e.name?.length?"/"+e.name:""}" (${h.vertexCount.toLocaleString()} vertices, ${h.indexCount.toLocaleString()} indices)
|
|
@@ -1917,9 +1917,9 @@ Oo('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUIL
|
|
|
1917
1917
|
Oo('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');
|
|
1918
1918
|
Oo('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.13.0";');
|
|
1919
1919
|
Oo('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');
|
|
1920
|
-
Oo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "
|
|
1920
|
+
Oo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Wed Feb 11 2026 13:53:06 GMT+0000 (Coordinated Universal Time)";');
|
|
1921
1921
|
Oo('globalThis["__NEEDLE_PUBLIC_KEY__"] = "' + NEEDLE_PUBLIC_KEY + '";');
|
|
1922
|
-
const Xi = "4.13.0", Rc = "undefined", Ad = "
|
|
1922
|
+
const Xi = "4.13.0", Rc = "undefined", Ad = "Wed Feb 11 2026 13:53:06 GMT+0000 (Coordinated Universal Time)";
|
|
1923
1923
|
G0 && console.log(`Engine version: ${Xi} (generator: ${Rc})
|
|
1924
1924
|
Project built at ${Ad}`);
|
|
1925
1925
|
const ur = NEEDLE_PUBLIC_KEY, yo = "needle_isActiveInHierarchy", ca = "builtin_components", rd = "needle_editor_guid";
|
|
@@ -15208,7 +15208,7 @@ var T;
|
|
|
15208
15208
|
e.ready = i;
|
|
15209
15209
|
async function n() {
|
|
15210
15210
|
if (e.MODULE) return e.MODULE;
|
|
15211
|
-
const o = await import("./materialx-
|
|
15211
|
+
const o = await import("./materialx-fkoFuRh3.js");
|
|
15212
15212
|
return e.MODULE = o, e.MAYBEMODULE = o, t.forEach((r) => r(o)), t.length = 0, o;
|
|
15213
15213
|
}
|
|
15214
15214
|
e.load = n;
|
|
@@ -20921,24 +20921,25 @@ const ea = x("debugreflectionprobe"), lb = x("noreflectionprobe"), rp = /* @__PU
|
|
|
20921
20921
|
if (!n || n.envMap === void 0 || n instanceof we)
|
|
20922
20922
|
continue;
|
|
20923
20923
|
let o = t[i];
|
|
20924
|
-
const r = n === o?.copy, a = !o || o.material.uuid !== n.uuid || o.
|
|
20924
|
+
const r = n === o?.copy, a = !o || o.material.uuid !== n.uuid || o.originalVersion !== n.version;
|
|
20925
20925
|
if (!r && a) {
|
|
20926
20926
|
if (ea) {
|
|
20927
20927
|
let h = "";
|
|
20928
|
-
o ? o.material !== n ? h = "reference changed; cached instance?: " + r : o.
|
|
20928
|
+
o ? o.material !== n ? h = "reference changed; cached instance?: " + r : o.originalVersion !== n.version && (h = "version changed") : h = "not cached", console.warn("Cloning material", n.name, n.version, "Reason:", h, `
|
|
20929
20929
|
`, n.uuid, `
|
|
20930
20930
|
`, o?.copy.uuid, `
|
|
20931
20931
|
`, e.name);
|
|
20932
20932
|
}
|
|
20933
20933
|
const c = n.clone();
|
|
20934
|
-
c.version = n.version, o ? (o.copy = c, o.material = n) : (o = {
|
|
20934
|
+
c.version = n.version, o ? (o.copy = c, o.material = n, o.originalVersion = n.version) : (o = {
|
|
20935
20935
|
material: n,
|
|
20936
|
-
copy: c
|
|
20936
|
+
copy: c,
|
|
20937
|
+
originalVersion: n.version
|
|
20937
20938
|
}, t.push(o)), c[rp] = this, c[cb] = n, ea && console.log("Set reflection", e.name, e.guid);
|
|
20938
20939
|
}
|
|
20939
20940
|
o && o.copy && (o.copy.onBeforeCompile = n.onBeforeCompile);
|
|
20940
20941
|
const l = o?.copy;
|
|
20941
|
-
"envMap" in l && (l.envMap = this.texture, l.needsUpdate = !0), e.sharedMaterials[i] = l;
|
|
20942
|
+
"envMap" in l && l.envMap !== this.texture && (l.envMap = this.texture, l.needsUpdate = !0), e.sharedMaterials[i] = l;
|
|
20942
20943
|
}
|
|
20943
20944
|
}
|
|
20944
20945
|
onUnset(e) {
|