@needle-tools/engine 4.17.0-alpha.3 → 4.17.0-alpha.4

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.
@@ -141,7 +141,7 @@ void main(){
141
141
  #__vconsole .vc-mask {
142
142
  overflow: hidden;
143
143
  }
144
- `,Lo?.prepend(i),s===!0&&lv()<=0&&Ov(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),vl=!1,Kt=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function eC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const o=n.indexOf("?");o>-1&&(n=n.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(h)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Kt?.hide()}}),i.push({name:"Reload",onClick:function(n){const o=e();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(i)}),s}const Lp="padding: 10px; font-family: monospace;",r_="margin-bottom: 10px;",jo="margin-bottom: 10px; margin-top: 15px;",tC="width: 100%; border-collapse: collapse; border: 1px solid rgba(0,0,0,0.1); table-layout: fixed;",Mv="border: 1px solid rgba(0,0,0,0.1); padding: 5px;",iC=Mv,nC=Mv+" word-break: break-all;";function kn(s,e=!1){e&&s.sort((i,n)=>(n.value?1:0)-(i.value?1:0));let t=`<table style='${tC}'>`;t+="<tbody>";for(const i of s){const n=typeof i.value=="boolean"?i.value?"✅":"❌":i.value;t+=`<tr><td style='${iC}'>${i.label}</td><td style='${nC}'>${n}</td></tr>`}return t+="</tbody></table>",t}function kv(){try{if(document.createElement("canvas").getContext("webgl2"))return"✅"}catch{}return"❌"}function sC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("device-utilities","📱 Device Info");return s.on("renderTab",function(e){let t=`<div style='${Lp}'>`;const i=pC();t+=`<h3 style='${r_}'>Device: ${i}</h3>`,t+=kn([{label:"💻 Desktop",value:exports.DeviceUtilities.isDesktop()},{label:"📱 Mobile Device",value:exports.DeviceUtilities.isMobileDevice()},{label:"🍎 iOS",value:exports.DeviceUtilities.isiOS()},{label:"📱 iPad",value:exports.DeviceUtilities.isiPad()},{label:"🤖 Android",value:exports.DeviceUtilities.isAndroidDevice()},{label:"🦊 Mozilla XR",value:exports.DeviceUtilities.isMozillaXR()},{label:"🌵 Needle App Clip",value:exports.DeviceUtilities.isNeedleAppClip()},{label:"🍏 macOS",value:exports.DeviceUtilities.isMacOS()},{label:"👓 VisionOS",value:exports.DeviceUtilities.isVisionOS()},{label:"🧭 Safari",value:exports.DeviceUtilities.isSafari()},{label:"🕶️ Meta Quest",value:exports.DeviceUtilities.isQuest()},{label:"🔗 QuickLook AR Support",value:exports.DeviceUtilities.supportsQuickLookAR()}],!0);const n=[],o=exports.DeviceUtilities.getiOSVersion();o&&n.push({label:"🍎 iOS Version",value:o});const r=exports.DeviceUtilities.getChromeVersion();r&&n.push({label:"🌐 Chrome Version",value:r});const a=exports.DeviceUtilities.getSafariVersion();a&&n.push({label:"🧭 Safari Version",value:a}),n.length>0&&(t+=kn(n,!1)),t+="</div>",t+=`<div style='${Lp} margin-top: 20px;'>`,t+=`<h3 style='${r_}'>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?"✅":"❌"},{label:"WebGPU",value:"gpu"in navigator?"✅":"❌"},{label:"WebGL 2",value:kv()}];t+=kn(l,!1),t+="</div>",e(t)}),s}function oC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("graphics-info","🎨 Graphics Info");return s.on("renderTab",async function(e){let t=`<div style='${Lp}'>`;const i=rC();i.length>0&&(t+=`<h3 style='${jo}'>General GPU Info</h3>`,t+=kn(i,!1));const n=lC();n.length>0&&(t+=`<h3 style='${jo}'>WebGL</h3>`,t+=kn(n,!1));const o=cC();o.length>0&&(t+=`<h3 style='${jo}'>WebGL 2 Features</h3>`,t+=kn(o,!1));const r=hC();r.length>0&&(t+=`<h3 style='${jo}'>WebGL Limits</h3>`,t+=kn(r,!1));const a=dC();a.length>0&&(t+=`<h3 style='${jo}'>Texture Formats</h3>`,t+=kn(a,!1));const l=await uC();if(l.length>0&&(t+=`<h3 style='${jo}'>WebGPU</h3>`,t+=kn(l,!1)),exports.DeviceUtilities.isSafari()){const h=fC();h.length>0&&(t+=`<h3 style='${jo}'>Safari GPU Info</h3>`,t+=kn(h,!1))}t+="</div>",e(t)}),s}function rC(){const s=[],e=window.devicePixelRatio;s.push({label:"Device Pixel Ratio",value:e.toString()}),s.push({label:"Width (px)",value:(window.innerWidth*e).toString()}),s.push({label:"Height (px)",value:(window.innerHeight*e).toString()});const i=exports.DeviceUtilities.isMobileDevice()?150:96,n=screen.width/i,o=screen.height/i,r=n*2.54,a=o*2.54;s.push({label:"Estimated Width (cm)",value:r.toFixed(1)}),s.push({label:"Estimated Height (cm)",value:a.toFixed(1)});const l=Ev();if(l){s.push({label:"GPU",value:l.renderer}),s.push({label:"Driver",value:l.vendor}),s.push({label:"ANGLE",value:l.angle||"Not detected"});const h=aC(l.renderer);h&&(h.manufacturer&&s.push({label:"Manufacturer",value:h.manufacturer}),h.cardVersion&&s.push({label:"Card Version",value:h.cardVersion}),h.brand&&s.push({label:"Brand",value:h.brand}),s.push({label:"Integrated",value:h.integrated?"Yes":"No"}),h.layer&&s.push({label:"WebGL Layer",value:h.layer}))}return s}function aC(s){if(!s)return null;const e=(h,d)=>{const u=d.match(h);return u&&u[0]},t=e(/(ANGLE)/g,s)||void 0,i=e(/((NVIDIA|AMD|Intel)[^\d]*[^\s]+)/,s)||s,n=i.split(" ");n.shift();const o=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:o,cardVersion:r,brand:a,integrated:o==="Intel",layer:t,card:i}}function lC(){const s=[],e=Ev();return e&&(s.push({label:"📊 WebGL Version",value:e.version}),s.push({label:"🎮 WebGL 2 Available",value:kv()})),s}function cC(){const s=[];try{const t=document.createElement("canvas").getContext("webgl2");if(!t)return s;s.push({label:"Float Color Buffer",value:t.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"Anisotropic Filtering",value:t.getExtension("EXT_texture_filter_anisotropic")?"✅":"❌"}),s.push({label:"Float Texture Linear",value:t.getExtension("OES_texture_float_linear")?"✅":"❌"}),s.push({label:"S3TC Compression",value:t.getExtension("WEBGL_compressed_texture_s3tc")?"✅":"❌"}),s.push({label:"ETC Compression",value:t.getExtension("WEBGL_compressed_texture_etc")?"✅":"❌"}),s.push({label:"PVRTC Compression",value:t.getExtension("WEBGL_compressed_texture_pvrtc")?"✅":"❌"}),s.push({label:"ASTC Compression",value:t.getExtension("WEBGL_compressed_texture_astc")?"✅":"❌"})}catch{}return s}function hC(){const s=[];try{const e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl");if(!t)return s;const i=t instanceof WebGL2RenderingContext;s.push({label:"📏 Max Texture Size",value:t.getParameter(t.MAX_TEXTURE_SIZE).toString()}),s.push({label:"🎨 Max Renderbuffer Size",value:t.getParameter(t.MAX_RENDERBUFFER_SIZE).toString()}),s.push({label:"🔗 Max Vertex Attribs",value:t.getParameter(t.MAX_VERTEX_ATTRIBS).toString()}),s.push({label:"🎯 Max Texture Units",value:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS).toString()}),i&&(s.push({label:"⚡ Max Samples",value:t.getParameter(t.MAX_SAMPLES).toString()}),s.push({label:"🔄 Max Uniform Buffer Bindings",value:t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS).toString()}),s.push({label:"📐 Max 3D Texture Size",value:t.getParameter(t.MAX_3D_TEXTURE_SIZE).toString()}))}catch{}return s}function dC(){const s=[];try{document.createElement("canvas").getContext("webgl")&&(s.push({label:"WebGL 1 RGBA",value:"✅"}),s.push({label:"WebGL 1 RGB",value:"✅"}));const n=document.createElement("canvas").getContext("webgl2");n&&(s.push({label:"WebGL 2 RGBA32F",value:n.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"WebGL 2 RGB32F",value:n.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"WebGL 2 R11F_G11F_B10F",value:"✅"}),s.push({label:"WebGL 2 RGB565",value:"✅"}),s.push({label:"WebGL 2 RGB5_A1",value:"✅"}),s.push({label:"WebGL 2 RGBA4444",value:"✅"}))}catch{}return s}async function uC(){const s=[];if(!("gpu"in navigator))return s.push({label:"🚀 WebGPU Support",value:"❌ Not supported"}),s;s.push({label:"🚀 WebGPU Support",value:"✅ Supported"});try{const e=await navigator.gpu.requestAdapter();if(!e)return s.push({label:"🎯 Adapter",value:"No adapter available"}),s;s.push({label:"🎯 Adapter",value:e.name||"Unknown Adapter"});const t=await e.requestDevice();s.push({label:"🔧 Device",value:t.label||"WebGPU Device"}),s.push({label:"📏 Max Texture 2D",value:t.limits.maxTextureDimension2D.toString()}),s.push({label:"📐 Max Texture 3D",value:t.limits.maxTextureDimension3D.toString()}),s.push({label:"📊 Max Texture Array Layers",value:t.limits.maxTextureArrayLayers.toString()}),s.push({label:"💾 Max Buffer Size",value:`${(t.limits.maxBufferSize/1024/1024).toFixed(1)}MB`}),s.push({label:"🔗 Max Bind Groups",value:t.limits.maxBindGroups.toString()})}catch(e){s.push({label:"❌ Error",value:e.message})}return s}function Ev(){try{const s=document.createElement("canvas"),e=s.getContext("webgl2")||s.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),o=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:o,angle:r}}catch{return null}}function fC(){const s=[];try{const t=document.createElement("canvas").getContext("webgl");if(t){const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const n=t.getParameter(i.UNMASKED_RENDERER_WEBGL);n&&n.includes("Apple")&&s.push({label:"🍎 Apple GPU",value:n})}}}catch{}try{const t=document.createElement("canvas").getContext("webgl");t&&(t.getSupportedExtensions()||[]).includes("WEBGL_compressed_texture_pvrtc")&&s.push({label:"🗜️ PVRTC Support",value:"✅"})}catch{}return s}function pC(){return exports.DeviceUtilities.isQuest()?"Meta Quest":exports.DeviceUtilities.isVisionOS()?"Vision Pro":exports.DeviceUtilities.isiOS()?exports.DeviceUtilities.isiPad()?"iPad":"iPhone/iPod":exports.DeviceUtilities.isAndroidDevice()?"Android Device":exports.DeviceUtilities.isMozillaXR()?"Mozilla XR Browser":exports.DeviceUtilities.isNeedleAppClip()?"Needle App Clip":exports.DeviceUtilities.isMacOS()?"Mac":exports.DeviceUtilities.isDesktop()?"Desktop PC":"Unknown Device"}function mC(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function gC(){const s=document.querySelector("#__vconsole");return s||null}const Rv=x("debugdefines");yo('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";');yo('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";');yo('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";');yo('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');yo('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.17.0-alpha.3";');yo('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');yo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Mar 23 2026 10:30:40 GMT+0000 (Coordinated Universal Time)";');yo('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const ti="4.17.0-alpha.3",Ra="undefined",mc="Mon Mar 23 2026 10:30:40 GMT+0000 (Coordinated Universal Time)";Rv&&console.log(`Engine version: ${ti} (generator: ${Ra})
144
+ `,Lo?.prepend(i),s===!0&&lv()<=0&&Ov(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),vl=!1,Kt=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function eC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const o=n.indexOf("?");o>-1&&(n=n.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(h)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Kt?.hide()}}),i.push({name:"Reload",onClick:function(n){const o=e();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(i)}),s}const Lp="padding: 10px; font-family: monospace;",r_="margin-bottom: 10px;",jo="margin-bottom: 10px; margin-top: 15px;",tC="width: 100%; border-collapse: collapse; border: 1px solid rgba(0,0,0,0.1); table-layout: fixed;",Mv="border: 1px solid rgba(0,0,0,0.1); padding: 5px;",iC=Mv,nC=Mv+" word-break: break-all;";function kn(s,e=!1){e&&s.sort((i,n)=>(n.value?1:0)-(i.value?1:0));let t=`<table style='${tC}'>`;t+="<tbody>";for(const i of s){const n=typeof i.value=="boolean"?i.value?"✅":"❌":i.value;t+=`<tr><td style='${iC}'>${i.label}</td><td style='${nC}'>${n}</td></tr>`}return t+="</tbody></table>",t}function kv(){try{if(document.createElement("canvas").getContext("webgl2"))return"✅"}catch{}return"❌"}function sC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("device-utilities","📱 Device Info");return s.on("renderTab",function(e){let t=`<div style='${Lp}'>`;const i=pC();t+=`<h3 style='${r_}'>Device: ${i}</h3>`,t+=kn([{label:"💻 Desktop",value:exports.DeviceUtilities.isDesktop()},{label:"📱 Mobile Device",value:exports.DeviceUtilities.isMobileDevice()},{label:"🍎 iOS",value:exports.DeviceUtilities.isiOS()},{label:"📱 iPad",value:exports.DeviceUtilities.isiPad()},{label:"🤖 Android",value:exports.DeviceUtilities.isAndroidDevice()},{label:"🦊 Mozilla XR",value:exports.DeviceUtilities.isMozillaXR()},{label:"🌵 Needle App Clip",value:exports.DeviceUtilities.isNeedleAppClip()},{label:"🍏 macOS",value:exports.DeviceUtilities.isMacOS()},{label:"👓 VisionOS",value:exports.DeviceUtilities.isVisionOS()},{label:"🧭 Safari",value:exports.DeviceUtilities.isSafari()},{label:"🕶️ Meta Quest",value:exports.DeviceUtilities.isQuest()},{label:"🔗 QuickLook AR Support",value:exports.DeviceUtilities.supportsQuickLookAR()}],!0);const n=[],o=exports.DeviceUtilities.getiOSVersion();o&&n.push({label:"🍎 iOS Version",value:o});const r=exports.DeviceUtilities.getChromeVersion();r&&n.push({label:"🌐 Chrome Version",value:r});const a=exports.DeviceUtilities.getSafariVersion();a&&n.push({label:"🧭 Safari Version",value:a}),n.length>0&&(t+=kn(n,!1)),t+="</div>",t+=`<div style='${Lp} margin-top: 20px;'>`,t+=`<h3 style='${r_}'>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?"✅":"❌"},{label:"WebGPU",value:"gpu"in navigator?"✅":"❌"},{label:"WebGL 2",value:kv()}];t+=kn(l,!1),t+="</div>",e(t)}),s}function oC(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("graphics-info","🎨 Graphics Info");return s.on("renderTab",async function(e){let t=`<div style='${Lp}'>`;const i=rC();i.length>0&&(t+=`<h3 style='${jo}'>General GPU Info</h3>`,t+=kn(i,!1));const n=lC();n.length>0&&(t+=`<h3 style='${jo}'>WebGL</h3>`,t+=kn(n,!1));const o=cC();o.length>0&&(t+=`<h3 style='${jo}'>WebGL 2 Features</h3>`,t+=kn(o,!1));const r=hC();r.length>0&&(t+=`<h3 style='${jo}'>WebGL Limits</h3>`,t+=kn(r,!1));const a=dC();a.length>0&&(t+=`<h3 style='${jo}'>Texture Formats</h3>`,t+=kn(a,!1));const l=await uC();if(l.length>0&&(t+=`<h3 style='${jo}'>WebGPU</h3>`,t+=kn(l,!1)),exports.DeviceUtilities.isSafari()){const h=fC();h.length>0&&(t+=`<h3 style='${jo}'>Safari GPU Info</h3>`,t+=kn(h,!1))}t+="</div>",e(t)}),s}function rC(){const s=[],e=window.devicePixelRatio;s.push({label:"Device Pixel Ratio",value:e.toString()}),s.push({label:"Width (px)",value:(window.innerWidth*e).toString()}),s.push({label:"Height (px)",value:(window.innerHeight*e).toString()});const i=exports.DeviceUtilities.isMobileDevice()?150:96,n=screen.width/i,o=screen.height/i,r=n*2.54,a=o*2.54;s.push({label:"Estimated Width (cm)",value:r.toFixed(1)}),s.push({label:"Estimated Height (cm)",value:a.toFixed(1)});const l=Ev();if(l){s.push({label:"GPU",value:l.renderer}),s.push({label:"Driver",value:l.vendor}),s.push({label:"ANGLE",value:l.angle||"Not detected"});const h=aC(l.renderer);h&&(h.manufacturer&&s.push({label:"Manufacturer",value:h.manufacturer}),h.cardVersion&&s.push({label:"Card Version",value:h.cardVersion}),h.brand&&s.push({label:"Brand",value:h.brand}),s.push({label:"Integrated",value:h.integrated?"Yes":"No"}),h.layer&&s.push({label:"WebGL Layer",value:h.layer}))}return s}function aC(s){if(!s)return null;const e=(h,d)=>{const u=d.match(h);return u&&u[0]},t=e(/(ANGLE)/g,s)||void 0,i=e(/((NVIDIA|AMD|Intel)[^\d]*[^\s]+)/,s)||s,n=i.split(" ");n.shift();const o=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:o,cardVersion:r,brand:a,integrated:o==="Intel",layer:t,card:i}}function lC(){const s=[],e=Ev();return e&&(s.push({label:"📊 WebGL Version",value:e.version}),s.push({label:"🎮 WebGL 2 Available",value:kv()})),s}function cC(){const s=[];try{const t=document.createElement("canvas").getContext("webgl2");if(!t)return s;s.push({label:"Float Color Buffer",value:t.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"Anisotropic Filtering",value:t.getExtension("EXT_texture_filter_anisotropic")?"✅":"❌"}),s.push({label:"Float Texture Linear",value:t.getExtension("OES_texture_float_linear")?"✅":"❌"}),s.push({label:"S3TC Compression",value:t.getExtension("WEBGL_compressed_texture_s3tc")?"✅":"❌"}),s.push({label:"ETC Compression",value:t.getExtension("WEBGL_compressed_texture_etc")?"✅":"❌"}),s.push({label:"PVRTC Compression",value:t.getExtension("WEBGL_compressed_texture_pvrtc")?"✅":"❌"}),s.push({label:"ASTC Compression",value:t.getExtension("WEBGL_compressed_texture_astc")?"✅":"❌"})}catch{}return s}function hC(){const s=[];try{const e=document.createElement("canvas"),t=e.getContext("webgl2")||e.getContext("webgl");if(!t)return s;const i=t instanceof WebGL2RenderingContext;s.push({label:"📏 Max Texture Size",value:t.getParameter(t.MAX_TEXTURE_SIZE).toString()}),s.push({label:"🎨 Max Renderbuffer Size",value:t.getParameter(t.MAX_RENDERBUFFER_SIZE).toString()}),s.push({label:"🔗 Max Vertex Attribs",value:t.getParameter(t.MAX_VERTEX_ATTRIBS).toString()}),s.push({label:"🎯 Max Texture Units",value:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS).toString()}),i&&(s.push({label:"⚡ Max Samples",value:t.getParameter(t.MAX_SAMPLES).toString()}),s.push({label:"🔄 Max Uniform Buffer Bindings",value:t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS).toString()}),s.push({label:"📐 Max 3D Texture Size",value:t.getParameter(t.MAX_3D_TEXTURE_SIZE).toString()}))}catch{}return s}function dC(){const s=[];try{document.createElement("canvas").getContext("webgl")&&(s.push({label:"WebGL 1 RGBA",value:"✅"}),s.push({label:"WebGL 1 RGB",value:"✅"}));const n=document.createElement("canvas").getContext("webgl2");n&&(s.push({label:"WebGL 2 RGBA32F",value:n.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"WebGL 2 RGB32F",value:n.getExtension("EXT_color_buffer_float")?"✅":"❌"}),s.push({label:"WebGL 2 R11F_G11F_B10F",value:"✅"}),s.push({label:"WebGL 2 RGB565",value:"✅"}),s.push({label:"WebGL 2 RGB5_A1",value:"✅"}),s.push({label:"WebGL 2 RGBA4444",value:"✅"}))}catch{}return s}async function uC(){const s=[];if(!("gpu"in navigator))return s.push({label:"🚀 WebGPU Support",value:"❌ Not supported"}),s;s.push({label:"🚀 WebGPU Support",value:"✅ Supported"});try{const e=await navigator.gpu.requestAdapter();if(!e)return s.push({label:"🎯 Adapter",value:"No adapter available"}),s;s.push({label:"🎯 Adapter",value:e.name||"Unknown Adapter"});const t=await e.requestDevice();s.push({label:"🔧 Device",value:t.label||"WebGPU Device"}),s.push({label:"📏 Max Texture 2D",value:t.limits.maxTextureDimension2D.toString()}),s.push({label:"📐 Max Texture 3D",value:t.limits.maxTextureDimension3D.toString()}),s.push({label:"📊 Max Texture Array Layers",value:t.limits.maxTextureArrayLayers.toString()}),s.push({label:"💾 Max Buffer Size",value:`${(t.limits.maxBufferSize/1024/1024).toFixed(1)}MB`}),s.push({label:"🔗 Max Bind Groups",value:t.limits.maxBindGroups.toString()})}catch(e){s.push({label:"❌ Error",value:e.message})}return s}function Ev(){try{const s=document.createElement("canvas"),e=s.getContext("webgl2")||s.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),o=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:o,angle:r}}catch{return null}}function fC(){const s=[];try{const t=document.createElement("canvas").getContext("webgl");if(t){const i=t.getExtension("WEBGL_debug_renderer_info");if(i){const n=t.getParameter(i.UNMASKED_RENDERER_WEBGL);n&&n.includes("Apple")&&s.push({label:"🍎 Apple GPU",value:n})}}}catch{}try{const t=document.createElement("canvas").getContext("webgl");t&&(t.getSupportedExtensions()||[]).includes("WEBGL_compressed_texture_pvrtc")&&s.push({label:"🗜️ PVRTC Support",value:"✅"})}catch{}return s}function pC(){return exports.DeviceUtilities.isQuest()?"Meta Quest":exports.DeviceUtilities.isVisionOS()?"Vision Pro":exports.DeviceUtilities.isiOS()?exports.DeviceUtilities.isiPad()?"iPad":"iPhone/iPod":exports.DeviceUtilities.isAndroidDevice()?"Android Device":exports.DeviceUtilities.isMozillaXR()?"Mozilla XR Browser":exports.DeviceUtilities.isNeedleAppClip()?"Needle App Clip":exports.DeviceUtilities.isMacOS()?"Mac":exports.DeviceUtilities.isDesktop()?"Desktop PC":"Unknown Device"}function mC(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function gC(){const s=document.querySelector("#__vconsole");return s||null}const Rv=x("debugdefines");yo('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";');yo('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";');yo('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";');yo('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');yo('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.17.0-alpha.4";');yo('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');yo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Mar 23 2026 14:00:06 GMT+0000 (Coordinated Universal Time)";');yo('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const ti="4.17.0-alpha.4",Ra="undefined",mc="Mon Mar 23 2026 14:00:06 GMT+0000 (Coordinated Universal Time)";Rv&&console.log(`Engine version: ${ti} (generator: ${Ra})
145
145
  Project built at ${mc}`);const no=NEEDLE_PUBLIC_KEY,Ln="needle_isActiveInHierarchy",qo="builtin_components",Jl="needle_editor_guid";function yo(s){try{(0,eval)(s)}catch(e){Rv&&console.error(e)}}let Tv,a_=null;function dn(){return Tv}function Vm(s){if(s==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}a_!==s&&(a_=s,Tv=new s)}function yC(s,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>s.time.frame)return window.requestAnimationFrame(()=>i());const r=o.captureCanvas(e);r&&r instanceof Promise?r.then(()=>o.displayUI()):o.displayUI()};const n=Number.parseInt(t.get("spector")||"0")||0;console.log("Scheduled Spector capture at frame #"+n);const o=new window.SPECTOR.Spector;o.spyCanvases=!0,i();return}else A()&&console.debug("Spector available: Add '?spector=<frame>' to the URL to enable it and capture a frame.")}}function Av(s){const e=s;return!!(e.parser&&e.parser.json)}var du=(s=>(s[s.None=0]="None",s[s.DontExport=1]="DontExport",s))(du||{});const Dv=Symbol("component-name");function $m(s){return s&&s.isComponent}const _C=Symbol("object"),Mf=new yi(()=>new c.Vector3,20);class Iv{_point;_normal;_tangentVelocity;distance;impulse;friction;get point(){return Mf.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Mf.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return Mf.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}constructor(e,t,i,n,o,r){this._point=e,this.distance=t,this._normal=i,this.impulse=n,this.friction=o,this._tangentVelocity=r}}class Lv{contacts;constructor(e,t,i){this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}me;_collider;get collider(){return this._collider}_gameObject;get gameObject(){return this._gameObject}get rigidBody(){return this.collider?.attachedRigidbody}}class jv{object;collider;constructor(e,t){this.object=e,this.collider=t}}class Fd{constructor(e){this.context=e,this.root.style.cssText=`
146
146
  position: absolute;
147
147
  width: 1px; height: 1px;
@@ -173,7 +173,7 @@ See https://engine.needle.tools/docs/scripting.html#special-lifecycle-hooks for
173
173
  `+Mi):console.debug("Connected to networking backend",Mi),n(!0),this.onSendQueued(an.OnConnection)}).onClose(h=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,n(!1);let d="Websocket connection closed...";Mi?.includes("/socket")||(d+=' Do you perhaps mean to connect to "/socket"?'),console.error(d)}).onError(h=>{console.error("Websocket connection failed..."),n(!1),ii.sendEvent(this.context,"networking",{event:"connection_error"})}).onRetry(()=>{console.log("Retry connecting to networking websocket")}).build();l.addEventListener(o.WebsocketEvent.message,(h,d)=>{this.onMessage(h,d)})})}onMessage(e,t){const i=t.data;try{if(typeof i!="string"){i.size&&this.handleIncomingBinaryMessage(i);return}const n=JSON.parse(i);if(Array.isArray(n))for(const o of n)this.handleIncomingStringMessage(o);else this.handleIncomingStringMessage(n);return}catch(n){Qt&&i==="pong"?console.log("<<",i):A()&&console.error("Failed to parse message",n)}}async handleIncomingBinaryMessage(e){Ih&&console.log("<< bin",this.context.time.frame);const t=await e.arrayBuffer();var i=new Uint8Array(t);const n=new ae.ByteBuffer(i),o=n.getBufferIdentifier(),r=this._listenersBinary[o],a=$v(n),l=Wv(a);if(l&&typeof l=="string"&&(this._state[l]=a),!r)return;const h=a??n;for(const d of r)d(h)}handleIncomingStringMessage(e){if(Qt&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const r=e.data;r&&(console.assert(r.id!==void 0&&r.id!==null&&r.id.length>0,"server did not send connection id",r.id),console.debug("Your id is: "+r.id,this.context.alias??""),this._connectionId=r.id,ii.sendEvent(this.context,"networking",{event:"connected"}))}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(Qt&&console.log(e),e){this._isInRoom=!0;const r=e;this._currentRoomName=r.room,this._currentRoomViewId=r.viewId,this._currentRoomAllowEditing=r.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...r.inRoom),(Ih||A())&&console.debug("Joined Needle Engine Room: "+r.room);const a=new URL(window.location.href);a.searchParams.has("room")&&a.searchParams.delete("room"),a.searchParams.set("view",this._currentRoomViewId),console.debug(`Room view id: ${this._currentRoomViewId}
174
174
  ${a.href}`)}this.onSendQueued(an.OnRoomJoin),ii.sendEvent(this.context,"networking",{event:"joined_room",room:this._currentRoomName});break;case"left-room":const n=e;n.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentRoomAllowEditing=!0,this._currentInRoom.length=0,(Ih||A())&&console.debug("Left Needle Engine Room: "+n.room)),ii.sendEvent(this.context,"networking",{event:"left_room",room:n.room});break;case"user-joined-room":if(e.data){const r=e.data;this._currentInRoom.push(r.userId),Qt&&console.log(r.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const r=e.data,a=this._currentInRoom.indexOf(r.userId);a>=0&&(Qt&&console.log(r.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(a,1)),r.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Qt&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const o=e.data?.time;o&&(this._currentDelay=this.context.time.time-o),Qt&&console.log(`Current latency: ${(this._currentDelay*1e3).toFixed()} ms`,"Clients in room: "+this._currentInRoom?.length);break}const t=e.data;t&&(this._state[t.guid]=t);let i=this._listeners[e.key];if(i){i=[...i];for(const n of i)try{n(e.data)}catch(o){console.error('Error invoking callback for "'+e.key+'"',o)}}}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,i=an.OnRoomJoin){if(!this._ws){const o=this._waitingForSocket[i]||[];o.push(()=>this.sendWithWebsocket(e,t,i)),this._waitingForSocket[i]=o;return}const n=JSON.stringify(this.toMessage(e,t));Qt&&console.log(">>",e),this._ws.send(n)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const i of t)i();t.length=0}}}const ec=x("debugwebxr");class kf{controllerStates=[];userId;context;userStateEvtName;constructor(e,t){this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}onReceivedControllerState=e=>{ec&&console.log(`XRSync: Received change for ${this.userId}: ${e.type} ${e.handedness}; tracked=${e.isTracking}`);let t=!1;for(let i=0;i<this.controllerStates.length;i++)if(this.controllerStates[i].index===e.index){this.controllerStates[i]=e,t=!0;break}t||this.controllerStates.push(e)};update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const i=this.controllerStates[t];let n=!1;for(let o=0;o<e.controllers.length;o++)e.controllers[o].index===i.index&&(n=!0);n||(ec&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(i))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(i=>i.index===e.index);if(t){let i=!1;i||=t.isTracking!=e.isTracking,i&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const i={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),ec&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class Yv{hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const i=this._states.get(e);return i?i.controllerStates.find(o=>o.handedness===t)?.isTracking||!1:void 0}getDeviceType(e,t){if(!e)return;const i=this._states.get(e);return i?i.controllerStates.find(o=>o.handedness===t)?.type||"unknown":void 0}context;constructor(e){this.context=e,this.context.connection.beginListen(K.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(K.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(K.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(K.UserLeftRoom,this.onOtherUserLeftRoom)}destroy(){this.context.connection.stopListen(K.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(K.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(K.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(K.UserLeftRoom,this.onOtherUserLeftRoom)}onJoinedRoom=()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(ec&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new kf(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new kf(e,this.context))}};onLeftRoom=()=>{this.context.connection.connectionId&&(this._states.has(this.context.connection.connectionId)||(this._states.get(this.context.connection.connectionId)?.dispose(),this._states.delete(this.context.connection.connectionId)))};onOtherUserJoinedRoom=e=>{const t=e.userId;this._states.has(t)||(ec&&console.log("XRSync: Remote user joined room",t),this._states.set(t,new kf(t,this.context)))};onOtherUserLeftRoom=e=>{const t=e.userId;this._states.has(t)||(this._states.get(t)?.dispose(),this._states.delete(t))};_states=new Map;onUpdate(e){this.context.connection.isConnected&&this.context.connection.connectionId&&this._states.get(this.context.connection.connectionId)?.update(e)}onExitXR(e){this.context.connection.isConnected&&this.context.connection.connectionId&&this._states.get(this.context.connection.connectionId)?.onExitXR(e)}}class y_{_fadeToColorQuad;_fadeToColorMaterial;constructor(){this._fadeToColorMaterial=new c.MeshBasicMaterial({color:0,transparent:!0,depthTest:!1,fog:!1,side:c.DoubleSide}),this._fadeToColorQuad=new c.Mesh(new c.PlaneGeometry(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const i=this._fadeToColorQuad,n=this._fadeToColorMaterial;i.parent!==e&&n.opacity>0?e.add(i):n.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const o=this._requestedFadeValue;n.opacity=L.lerp(n.opacity,o,t/.03),Math.abs(n.opacity-o)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}_requestedFadeValue=0;_transitionPromise=null;_transitionResolve=null}const FC='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',UC=btoa(FC),zC="data:image/svg+xml;base64,"+UC,Da=zC,NC=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(NC);const VC='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',$C=btoa(VC),WC="data:image/svg+xml;charset=utf-8;base64,"+$C,__=WC;var Na=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s[s.Cylinder=3]="Cylinder",s[s.RoundedCube=10]="RoundedCube",s))(Na||{});class bo{static createText(e,t){let i=null;const n=t?.font||HC(t?.familyFamily||null);n instanceof X.Font?i=this.#t(e,n,t):i==null&&(i=new c.BufferGeometry);const o=t?.color||16777215,r=new c.Mesh(i,t?.material??new c.MeshStandardMaterial({color:o}));return this.applyDefaultObjectOptions(r,t),n instanceof Promise?n.then(a=>{r.geometry=this.#t(e,a,t),t?.onGeometry&&t.onGeometry(r)}):t?.onGeometry&&t.onGeometry(r),r}static#t(e,t,i){const n=i?.depth||.1;return new X.TextGeometry(e,{font:t,size:1,depth:n,height:n,bevelEnabled:i?.bevel||!1,bevelThickness:.01,bevelOffset:.01,bevelSize:.01})}static createOccluder(e){const t=new c.MeshBasicMaterial({colorWrite:!1,depthWrite:!0,side:c.DoubleSide});return this.createPrimitive(e,{material:t})}static createPrimitive(e,t){let i;const n=t?.color||16777215;switch(e){case"Quad":case 0:{const o=new c.PlaneGeometry(1,1,1,1),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Quad"}break;case"Cube":case 1:{const o=new c.BoxGeometry(1,1,1),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Cube"}break;case 10:case"RoundedCube":{const o=GC(1,1,1,.1,2),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="RoundedCube"}break;case"Sphere":case 2:{const o=new c.SphereGeometry(.5,16,16),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Sphere"}break;case"Cylinder":case 3:{const o=new c.CylinderGeometry(.5,.5,1,32),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Cylinder"}break;case"ShaderBall":i=new c.Group,i.name="ShaderBall",qC(i,t);break}return this.applyDefaultObjectOptions(i,t),i}static createSprite(e){const i=new c.SpriteMaterial({color:16777215});e?.texture&&"map"in i&&(i.map=e.texture);const n=new c.Sprite(i);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){e.receiveShadow=!0,e.castShadow=!0,t?.name&&(e.name=t.name),t?.position&&(Array.isArray(t.position)?e.position.set(t.position[0],t.position[1],t.position[2]):e.position.set(t.position.x||0,t.position.y||0,t.position.z||0)),t?.rotation&&(Array.isArray(t.rotation)?e.rotation.set(t.rotation[0],t.rotation[1],t.rotation[2]):e.rotation.set(t.rotation.x||0,t.rotation.y||0,t.rotation.z||0)),t?.scale&&(typeof t.scale=="number"?e.scale.set(t.scale,t.scale,t.scale):Array.isArray(t.scale)?e.scale.set(t.scale[0],t.scale[1],t.scale[2]):e.scale.set(t.scale.x||1,t.scale.y||1,t.scale.z||1)),t?.receiveShadow!=null&&(e.receiveShadow=t.receiveShadow),t?.castShadow!=null&&(e.castShadow=t.castShadow),t?.parent&&t.parent.add(e)}}function GC(s,e,t,i,n){const o=new c.Shape,r=1e-5,a=i-r;o.absarc(r,r,r,-Math.PI/2,-Math.PI,!0),o.absarc(r,e-a*2,r,Math.PI,Math.PI/2,!0),o.absarc(s-a*2,e-a*2,r,Math.PI/2,0,!0),o.absarc(s-a*2,r,r,0,-Math.PI/2,!0);const l=new c.ExtrudeGeometry(o,{bevelEnabled:!0,bevelSegments:n*2,steps:1,bevelSize:a,bevelThickness:i,curveSegments:n,UVGenerator:{generateTopUV:(h,d)=>{const u=[];for(let p=0;p<d.length;p+=3)u.push(new c.Vector2(d[p]/s,d[p+1]/e));return u},generateSideWallUV:(h,d,u,p,m,y)=>{const _=[];return _.push(new c.Vector2(d[u]/s,d[u+1]/e)),_.push(new c.Vector2(d[p]/s,d[p+1]/e)),_.push(new c.Vector2(d[m]/s,d[m+1]/e)),_.push(new c.Vector2(d[y]/s,d[y+1]/e)),_}}});return l.scale(1,1,1-i),l.center(),l.index||l.setIndex(Array.from({length:l.attributes.position.count},(h,d)=>d)),l.computeVertexNormals(),l}const Lh=new Map;function HC(s){let e="";switch(s){default:case"OpenSans":e="https://cdn.needle.tools/static/fonts/facetype/Open Sans_Regular_ascii.json";break;case"Helvetiker":e="https://cdn.needle.tools/static/fonts/facetype/Helvetiker_Regular_ascii.json";break}if(Lh.has(e)){const n=Lh.get(e);if(n)return n}const t=new X.FontLoader,i=new Promise((n,o)=>{t.load(e,r=>{Lh.set(e,r),n(r)},void 0,o)});return Lh.set(e,i),i}let Ef=!1,Rf=null;function qC(s,e){if(Rf===null){const t="https://cdn.needle.tools/static/models/shaderball.glb",i=new X.GLTFLoader,n=re.createLoaders(null);i.setDRACOLoader(n.dracoLoader),i.setKTX2Loader(n.ktx2Loader),Ef=!0,Rf=i.loadAsync(t).then(o=>{const r=o.scene;return r.position.y-=.5,r}).catch(o=>(console.warn("Failed to load shaderball mesh: "+o.message),v_())).finally(()=>{Ef=!1})}if(Ef){const t=v_();t.name="ShaderBall-Placeholder";const i=t.children[0];i?.type==="Mesh"&&b_(i,e),s.add(t)}Rf.then(t=>{s.children.forEach(o=>{o.name==="ShaderBall-Placeholder"&&s.remove(o)});const i=t.clone(),n=i.children[0];n?.type==="Mesh"&&(n.geometry.attributes.tangent||n.geometry.computeTangents(),b_(n,e)),s.add(i)})}function b_(s,e){if(e?.color||e?.material||e?.texture){const i=e?.material??s.material?.clone()??new c.MeshStandardMaterial;e.color&&"color"in i&&i.color instanceof c.Color&&i.color.set(e.color),e?.texture&&"map"in i&&(i.map=e.texture),s.material=i}}function v_(){return new c.Group().add(bo.createPrimitive("Sphere",{material:new c.MeshBasicMaterial({transparent:!0,opacity:.1})}))}class Ia{static _active=null;static get active(){return this._active}static _requestInFlight=!1;static async start(e,t){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(e,t).catch(n=>{console.error("Failed to start temporary XR session:",n)});return i?(i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new Ia(e,t,i),this._active):(i.end(),null)):(this._requestInFlight=!1,null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await _s(100)),this._active=null}_session;_mode;_init;get isAR(){return this._mode==="immersive-ar"}get isVR(){return this._mode==="immersive-vr"}_renderer;_camera;_scene;constructor(e,t,i){this._mode=e,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new c.WebGLRenderer({alpha:!0,antialias:!0}),this._renderer.outputColorSpace="srgb",this._renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),this._renderer.setSize(window.innerWidth,window.innerHeight,!0),exports.DeviceUtilities.isNeedleAppClip()&&window.requestAnimationFrame(()=>{const n=Math.min(2,window.devicePixelRatio),o=Math.floor(window.innerWidth*n),r=Math.floor(window.innerHeight*n);this._renderer.domElement.width=o,this._renderer.domElement.height=r}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new c.PerspectiveCamera,this._scene=new c.Scene,this._scene.fog=new c.Fog(4473924,10,250),this._scene.add(this._camera),this.setupScene()}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const e={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,e}onEnd=()=>{this._session?.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()};_lastTime=0;_frames=0;onFrame=(e,t)=>{const i=e-this._lastTime;this.update(e,i),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera),this._lastTime=e,this._frames++};_roomFlyObjects=[];_logoObject=null;get _logoDistance(){return this.isAR?.3:5}get _logoScale(){return this.isAR?.04:1}update(e,t){const i=e*4e-4;for(let r=0;r<this._roomFlyObjects.length;r++){const a=this._roomFlyObjects[r];a.position.y+=Math.sin(i+r*.5)*.005,a.rotateY(.002)}const n=this._logoObject,o=this._renderer.xr.getCamera();if(n){const r=new c.Vector3;o.getWorldDirection(r);const a=o.position.clone().addScaledVector(r,this._logoDistance),l=this.isAR?.005:1e-5;n.position.lerp(a,this._frames<=2?1:t*l),n.lookAt(this._camera.position)}}async onBeforeHandoff(){await _s(1e3),this._scene.clear()}setupScene(){this._scene.background=new c.Color(0);let e=Da;if(Vn()){const d=document.querySelector("needle-engine");if(d){const u=d.getAttribute("logo-src");u?.length&&(e=u,A()&&console.debug("[XR] Using custom loading logo from license:",e))}}const t=this._logoObject=new c.Mesh(new c.PlaneGeometry(1,1,1,1),new c.MeshBasicMaterial({transparent:!0,side:2}));t.scale.multiplyScalar(this._logoScale*window.devicePixelRatio),t.renderOrder=1e3,t.material.opacity=0,this._scene.add(t);const i=document.createElement("canvas"),n=i.getContext("2d"),o=new Image,r=d=>{if(!n)return;t.material.opacity=1;const u=1024;i.width=u,i.height=u,n.imageSmoothingQuality="high";const p=u*.19,m=o.width/o.height;{const v=i.height-p*1.5,R=v*m,O=(i.width-R)/2;n.drawImage(o,O,0,R,v)}const y=u*.12,_="Loading...";n.shadowBlur=0,n.fillStyle=this.isAR?"white":"rgba(255,255,255,0.4)",n.font=`${y}px Arial`,n.shadowBlur=u*.02,n.shadowColor="rgba(0,0,0,0.5)",n.shadowOffsetX=0,n.shadowOffsetY=0;const g=n.measureText(_);n.fillText(_,i.width/2-g.width/2,i.height-p/4),n.font=`${y}px Arial`,n.fillText(_,i.width/2-g.width/2,i.height-p/4);const w=new c.TextureLoader().load(i.toDataURL());w.generateMipmaps=!0,w.colorSpace="srgb",w.anisotropy=4;const b=i.width/i.height;t.scale.x=this._logoScale*b*window.devicePixelRatio,t.scale.y=this._logoScale*window.devicePixelRatio,t.material.map=w,t.material.needsUpdate=!0};o.onload=()=>r(),o.onerror=d=>{console.error("Failed to load temporary XR logo:",e,d),o.src=Da},o.crossOrigin="anonymous",o.src=e;const a=new c.DirectionalLight(16777215,1);a.position.set(0,20,0),a.castShadow=!1,this._scene.add(a);const l=new c.DirectionalLight(16777215,1);l.position.set(0,-1,0),l.castShadow=!1,this._scene.add(l);const h=new c.PointLight(16777215,1,100,1);if(h.position.set(0,2,0),h.castShadow=!1,h.distance=200,this._scene.add(h),this.isAR===!1)for(let u=0;u<100;u++){const p=new c.MeshStandardMaterial({color:2236962,metalness:1,roughness:.8}),m=Na.Sphere,y=bo.createPrimitive(m,{material:p});y.position.x=L.random(-50,50),y.position.y=L.random(-2,50),y.position.z=L.random(-50,50),y.rotation.x=L.random(0,Math.PI*2),y.rotation.y=L.random(0,Math.PI*2),y.rotation.z=L.random(0,Math.PI*2),y.scale.multiplyScalar(.5+Math.random()*10);const _=y.position.distanceTo(this._camera.position)-y.scale.x;_<10&&(y.position.z+=5,y.position.multiplyScalar(1+1/_)),this._roomFlyObjects.push(y),this._scene.add(y)}}}var yc;(s=>{const e=[];function t(){e?.length||A()&&console.warn("No USDZ exporters found – cannot export USDZ for QuickLook.");for(const o of e)o.exportAndOpen();return!0}s.exportAndOpen=t;function i(o){e.push(o)}s.registerExporter=i;function n(o){if(!e)return;const r=e.indexOf(o);r>=0&&e.splice(r,1)}s.unregisterExporter=n})(yc||(yc={}));const Fe=x("debugwebxr"),w_=x("stats");let Tf=0;function XC(s){let e=null;const t=s;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=s,e}QC();async function QC(){let s="immersive-vr";try{if(exports.DeviceUtilities.isNeedleAppClip()?s="immersive-ar":await navigator.xr?.isSessionSupported("immersive-vr")||(s="immersive-ar"),!await navigator.xr?.isSessionSupported("immersive-ar")&&s==="immersive-ar")return}catch(e){console.debug("[NeedleXRSession:granted] Error while checking XR support:",e);return}if(x("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],ce.addContextCreatedCallback(async t=>{if(!e)return;ba(!0);const i=await e;if(i){const n=q.getDefaultSessionInit(s);q.setSession(s,i,n,t.context)}else console.error("[NeedleXRSession:granted] ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}navigator.xr?.addEventListener("sessiongranted",async()=>{const e=sessionStorage.getItem("needle_xr_session_mode"),t=sessionStorage.getItem("needle_xr_session_init")??null,i=t?JSON.parse(t):null;let n=null;if(Kv()&&(await Ia.start(e||s,i||q.getDefaultSessionInit(s)).catch(o=>console.warn("[NeedleXRSession:granted] TemporaryXRContext start failed:",o)),await ZC(),n=await Ia.handoff()),n)q.setSession(n.mode,n.session,n.init,U.Current);else if(e&&t){console.log("[NeedleXRSession:granted] Restore last session");const o=JSON.parse(t);q.start(e,o).catch(r=>console.warn(r))}else q.start(s).catch(o=>console.warn("[NeedleXRSession:granted] failed:",o))},{once:!0})}}function YC(s,e){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function KC(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const Km=new Set;ce.registerCallback(le.ContextCreationStart,async s=>{Km.add(s.context)});ce.registerCallback(le.ContextCreated,async s=>{Km.delete(s.context);const e=s.context?.domElement.getAttribute("autostart")||null;JC(e)});function Kv(){return Km.size>0}function ZC(){return new Promise(s=>{const e=Date.now(),t=setInterval(()=>{(!Kv()||Date.now()-e>6e4)&&(clearInterval(t),s())},100)})}exports.DeviceUtilities.isDesktop()&&A()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&q.active&&q.stop()});function JC(s){s&&s?.toLowerCase()==="ar"&&un.registerWaitForInteraction(()=>{q.start("ar")})}const jh=Symbol("initial-fov"),Af=Symbol("initial-near");class q{static _sync=null;static getXRSync(e){return this._sync||(this._sync=new Yv(e)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static _currentSessionRequestMode=null;static get active(){return this._activeSession}static get activeMode(){return this._activeSession?.mode??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(e=>e.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(e){return this.xrSystem?.isSessionSupported(e).catch(t=>(Fe&&console.error(t),!1))??Promise.resolve(!1)}static _currentSessionRequest;static _activeSession;static onSessionRequestStart(e){this._sessionRequestStartListeners.push(e)}static offSessionRequestStart(e){const t=this._sessionRequestStartListeners.indexOf(e);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static _sessionRequestStartListeners=[];static onSessionRequestEnd(e){this._sessionRequestEndListeners.push(e)}static offSessionRequestEnd(e){const t=this._sessionRequestEndListeners.indexOf(e);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static _sessionRequestEndListeners=[];static onXRSessionStart(e){this._xrStartListeners.push(e)}static offXRSessionStart(e){const t=this._xrStartListeners.indexOf(e);t>=0&&this._xrStartListeners.splice(t,1)}static _xrStartListeners=[];static onXRSessionEnd(e){this._xrEndListeners.push(e)}static offXRSessionEnd(e){const t=this._xrEndListeners.indexOf(e);t>=0&&this._xrEndListeners.splice(t,1)}static _xrEndListeners=[];static onControllerAdded(e){this._controllerAddedListeners.push(e)}static offControllerAdded(e){const t=this._controllerAddedListeners.indexOf(e);t>=0&&this._controllerAddedListeners.splice(t,1)}static _controllerAddedListeners=[];static onControllerRemoved(e){this._controllerRemovedListeners.push(e)}static offControllerRemoved(e){const t=this._controllerRemovedListeners.indexOf(e);t>=0&&this._controllerRemovedListeners.splice(t,1)}static _controllerRemovedListeners=[];static offerSession(e,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+e),t=="default"&&(t=this.getDefaultSessionInit(e)),navigator.xr.offerSession(e,{...t}).then(n=>q.setSession(e,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(e){switch(e){case"immersive-ar":const t=["anchors","local-floor","layers","dom-overlay","hit-test","unbounded"];return exports.DeviceUtilities.isVisionOS()||t.push("hand-tracking"),{optionalFeatures:t};case"immersive-vr":const i=["local-floor","bounded-floor","high-fixed-foveation-level","layers"];return exports.DeviceUtilities.isVisionOS()||i.push("hand-tracking"),{optionalFeatures:i};default:return console.warn("No default session init for mode",e),{}}}static async start(e,t,i){if(t||(t={}),exports.DeviceUtilities.isiOS()){const a=await this.isARSupported().catch(()=>!1);if(exports.DeviceUtilities.isVisionOS()&&!a&&(e==="ar"||e==="immersive-ar")&&(e="quicklook"),e==="quicklook")return ii.sendEvent(U.Current,"xr",{action:"quicklook_export",source:"NeedleXRSession.start"}),yc.exportAndOpen(),null;if(!a&&(e==="immersive-ar"||e==="ar")){this.invokeSessionRequestStart("immersive-ar",t);const l=new URL("https://appclip.apple.com/id?p=tools.needle.launch-app.Clip");l.searchParams.set("url",location.href);const h=l.toString();ii.sendEvent(U.Current,"xr",{action:"app_clip_launch",source:"NeedleXRSession.start",url:h});const d=window.top||window;try{console.debug("iOS device detected - opening Needle App Clip for AR experience",{mode:e,init:t,url:l}),d.location.href=h}catch(u){console.warn("Error navigating to AppClip "+h+`
175
175
  `,u),window!==window.top?window.open(h,"_blank"):window.location.href=h}return setTimeout(()=>{this.invokeSessionRequestEnd("immersive-ar",t||{},null)},3e3),null}}if(e==="quicklook")return console.warn("QuickLook mode is only supported on iOS devices"),null;if(e=="ar"&&(e="immersive-ar"),A()&&x("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await Ia.start(e,t||q.getDefaultSessionInit(e)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Fe||A())&&fe("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(i||(i=U.Current),i||(i=ce.All[0]),!i)throw new Error("No Needle Engine Context found");switch(e){case"immersive-ar":{if(await this.xrSystem?.isSessionSupported("immersive-ar")!==!0)return console.error(e+" is not supported by this browser."),null;const l=this.getDefaultSessionInit(e),h=XC(i.domElement);h&&!exports.DeviceUtilities.isQuest()&&(l.domOverlay={root:h},l.optionalFeatures.push("dom-overlay")),t={...l,...t}}break;case"immersive-vr":{if(await this.xrSystem?.isSessionSupported("immersive-vr")!==!0)return console.error(e+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(e),...t}}break;default:console.warn("No default session init for mode",e);break}t.optionalFeatures??=[],t.requiredFeatures??=[],await Ia.stop();const n=e=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Fe?console.log(`%cRequesting ${e} session`,"font-weight:bold;",t,n):console.log(`%cRequesting ${e} session`,"font-weight:bold;");for(const a of n)a.onBeforeXR&&a.activeAndEnabled&&!a.destroyed&&a.onBeforeXR(e,t);this.invokeSessionRequestStart(e,t),Fe&&xe("Requesting "+e+" session ("+Date.now()+")"),ii.sendEvent(U.Current,"xr",{action:"session_request",mode:e,features:(t.requiredFeatures??[]).concat(t.optionalFeatures??[]).join(","),source:"NeedleXRSession.start"}),this._currentSessionRequest=navigator?.xr?.requestSession(e,t),this._currentSessionRequestMode=e;const o=await this._currentSessionRequest?.catch(a=>{console.error(a,"Code: "+a?.code),a?.code===9&&fe("Couldn't start XR session. Make sure you allow the required permissions."),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&fe("XR requires a secure connection (HTTPS)")});return this._currentSessionRequest=void 0,this._currentSessionRequestMode=null,this.invokeSessionRequestEnd(e,t,o),o?this.setSession(e,o,t,i):(console.warn("XR Session request was rejected"),null)}static invokeSessionRequestStart(e,t){for(const i of this._sessionRequestStartListeners)i({mode:e,init:t})}static invokeSessionRequestEnd(e,t,i){for(const n of this._sessionRequestEndListeners)n({mode:e,init:t,newSession:i||null})}static setSession(e,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const o=e=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new q(e,t,n,{scripts:o,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),Fe?console.log(`%cStarted ${e} session`,"font-weight:bold;",o):console.log(`%cStarted ${e} session`,"font-weight:bold;"),this._activeSession}static $_stop_request=Symbol();static stop(){const e=this._activeSession;e&&(e[this.$_stop_request]===void 0?(Fe&&console.log("[NeedleXRSession] Stopping XR Session... (new)"),e[this.$_stop_request]=setTimeout(()=>{e.end()})):Fe&&console.warn("[NeedleXRSession] XR Session stop already requested"))}static onEnd=()=>{Fe&&console.log("XR Session ended"),this._activeSession=null};context;get sync(){return q._sync}get running(){return!this._ended&&this.session!=null}session;mode;get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get isVisibleBlurred(){return this.session.visibilityState==="visible-blurred"}get isSystemKeyboardSupported(){return this.session.isSystemKeyboardSupported}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}controllers=[];get leftController(){return this.controllers.find(e=>e.side==="left")}get rightController(){return this.controllers.find(e=>e.side==="right")}getController(e){return typeof e=="number"?this.controllers[e]||null:this.controllers.find(t=>t.side===e)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(e=>e.inputSource.targetRayMode==="tracked-pointer")||A()&&exports.DeviceUtilities.isDesktop()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const e=this.frame.getImageTrackingResults();for(const t of e)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const e=this._rigs[0]??null;return e?.gameObject&&ur(e.gameObject)||e?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):e}_rigScale=1;_lastRigScaleUpdate=-1;get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(e){this._rigs.indexOf(e)>=0||(e.priority===void 0&&(e.priority=0),this._rigs.push(e),this.updateActiveXRRig())}removeRig(e){const t=this._rigs.indexOf(e);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(e){const t=this._rigs.indexOf(e),i=this._rigs[0];this._rigs.splice(t,1),this._rigs.unshift(e),e.priority=i?.priority??0,this.updateActiveXRRig()}getUserOffsetInRig(){const e=this.context.mainCamera?.position;if(!e||!this.rig)return F(0,0,0);const t=F(e);return t.x*=-1,t.z*=-1,t.applyQuaternion(Jt(this.rig.gameObject.quaternion)),t}updateActiveXRRig(){const e=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(ur(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(e!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}Fe&&(e===t?console.log("Updated Active XR Rig:",t,"prev:",e):console.log("Updated Active XRRig:",t," (the same as before)"))}_rigs=[];_viewerHitTestSource=null;getHitTest(e){if(e)return this.getControllerHitTest(e);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(e){const t=e.getHitTestSource();if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===e.inputSource)for(const o of n.results)return this.convertHitTestResult(o);return null}convertHitTestResult(e){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&e.getPose(t);if(i){const n=F(i.transform.position),o=Jt(i.transform.orientation),r=this.context.mainCamera;if(r?.parent!==this._cameraRenderParent&&n.applyMatrix4(va),r?.parent){n.applyMatrix4(r.parent.matrixWorld),o.multiply(Di);const a=pe(r.parent);a.premultiply(Di),o.premultiply(a)}return{hit:e,position:n,quaternion:o}}return null}convertSpace(e){const t=F(e.position);t.applyMatrix4(va);const i=Jt(e.orientation);return i.premultiply(Di),{position:t,quaternion:i}}_defaultRig;_xr_scripts;_xr_update_scripts=[];_inactive_scripts=[];_controllerAdded;_controllerRemoved;_originalCameraWorldPosition;_originalCameraWorldRotation;_originalCameraWorldScale;_originalCameraParent;_mainCamera=null;constructor(e,t,i,n){YC(e,n.init),this.session=t,this.mode=e,this.context=i,(Fe||x("console"))&&ba(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(o=>typeof o.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,xs(this.onBefore,ge.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),(n.init.optionalFeatures?.includes("hit-test")||n.init.requiredFeatures?.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(o=>t.requestHitTestSource?.call(t,{space:o})?.then(r=>this._viewerHitTestSource=r).catch(r=>console.error(r))).catch(o=>console.error(o)),this.context.mainCamera&&(this._originalCameraWorldPosition=Y(this.context.mainCamera,new c.Vector3),this._originalCameraWorldRotation=pe(this.context.mainCamera,new c.Quaternion),this._originalCameraWorldScale=je(this.context.mainCamera,new c.Vector3),this._originalCameraParent=this.context.mainCamera.parent,this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera[jh]=this.context.mainCamera.fov)),this._defaultRig=new OC,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let o=0;o<t.inputSources.length;o++){const r=t.inputSources[o];if(!r.handedness){console.warn("Input source in xr session has no handedness - ignoring",o);continue}this.onInputSourceAdded(r)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",o=>{for(const r of o.removed)this.disconnectInputSource(r);for(const r of o.added)this.onInputSourceAdded(r)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet),"controllerAutoUpdate"in this.context.renderer.xr?(console.debug("Disabling three.js controllerAutoUpdate"),this.context.renderer.xr.controllerAutoUpdate=!1):Fe&&console.warn("controllerAutoUpdate is not available in three.js - cannot disable it"),exports.DeviceUtilities.isNeedleAppClip()&&window.requestAnimationFrame(()=>{const o=this.context.renderer.domElement,r=window.devicePixelRatio||1,a=o.width,l=o.height,h=Math.floor(window.innerWidth*r),d=Math.floor(window.innerHeight*r);(Math.abs(a-h)>2||Math.abs(l-d)>2)&&(o.width=h,o.height=d,console.debug("Applied DPR scaling for Needle AppClip XR session",r,o.width,o.height))})}onRendererSessionSet=()=>{this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),this.context.mainCameraComponent?.applyClearFlags())};onInputSourceAdded=e=>{if(e.targetRayMode==="screen")return;let t=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===e){t=n;break}if(this.controllers.find(n=>n.inputSource===e)){console.debug("Controller already exists for input source",t);return}else if(this._newControllers.find(n=>n.inputSource===e)){console.debug("Controller already registered for input source",t);return}const i=new Hm(this,e,t);this._newControllers.push(i)};disconnectInputSource(e){const t=(o,r)=>{if(o.inputSource===e){Fe&&console.log("Disconnecting controller",o.index);const a=r.indexOf(o);a>=0&&r.splice(a,1),this.invokeControllerEvent(o,this._controllerRemoved,"removed");const l={xr:this,controller:o,change:"removed"};for(const h of this._xr_scripts)h.onXRControllerRemoved&&h.onXRControllerRemoved(l);o.onDisconnected()}},i=[...this.controllers];for(let o=i.length-1;o>=0;o--){const r=i[o];t(r,this.controllers)}const n=[...this._newControllers];for(let o=n.length-1;o>=0;o--){const r=n[o];t(r,this._newControllers)}}end(){this._ended||this.session.end().catch(e=>console.warn(e))}_ended=!1;_newControllers=[];onEnd=e=>{if(this._ended)return;this._ended=!0,console.debug("XR Session ended"),ii.sendEvent(U.Current,"xr",{action:"session_end",mode:this.mode,source:"NeedleXRSession.onEnd"}),KC(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,this.requestedCameraNearPlane=null,_o(this.onBefore,ge.LateUpdate);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);t>=0&&this.context.pre_render_callbacks.splice(t,1);const i=this.context.post_render_callbacks.indexOf(this.onAfterRender);i>=0&&this.context.post_render_callbacks.splice(i,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{this.context.mainCameraComponent?.applyClearFlags(),this.context.mainCameraComponent?.applyClippingPlane()}),zv({session:this});for(const o of q._xrEndListeners)o({xr:this});const n=[...this.controllers];for(let o=0;o<n.length;o++)this.disconnectInputSource(n[o].inputSource);this.controllers.length=0,this._newControllers.length=0;for(const o of this._xr_scripts)o?.onLeaveXR?.({xr:this});this.sync?.onExitXR(this),this.context.mainCamera&&(this._originalCameraParent?.add(this.context.mainCamera),this._originalCameraWorldPosition&&at(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&hn(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&Ea(this.context.mainCamera,this._originalCameraWorldScale),this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera[jh]&&(this.context.mainCamera.fov=this.context.mainCamera[jh],this.context.mainCamera[jh]=0),this.context.mainCamera[Af]&&(this.context.mainCamera.near=this.context.mainCamera[Af],this.context.mainCamera[Af]=0))),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),ba(!1)};_didStart=!1;onBefore=e=>{const t=e.xrFrame;if(!t)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),this.rig?.isActive==!1&&(Fe&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&this._mainCamera?.gameObject&&this._mainCamera?.gameObject?.parent!==this.rig.gameObject&&this.rig.gameObject.add(this._mainCamera?.gameObject),this.internalUpdateState(),this.applyCustomForward();const i={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const n=[...this.context.new_scripts_xr];for(let o=0;o<n.length;o++){const r=this.context.new_scripts_xr[o];if(!r||r.destroyed||r.supportsXR?.(this.mode)==!1){this.context.new_scripts_xr.splice(o,1);continue}if(!r.activeAndEnabled){this.context.new_scripts_xr.splice(o,1),this.markInactive(r);continue}if(this.addScript(r)){this.invokeCallback_EnterXR(r);for(const a of this.controllers)this.invokeCallback_ControllerAdded(r,a)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const o=oi(this.context.scene.children);if(o){const r=o.getSize(F());if(r.length()>0){const a=this._defaultRig.gameObject;a.position.set(o.min.x+r.x*.5,o.min.y,o.max.z+r.z*.5+1.5);const l=o.getCenter(F());l.y=a.position.y,a.lookAt(l)}}}Uv({session:this}),vr();for(const o of q._xrStartListeners)o(i);const n=[...this._xr_scripts];Fe&&console.log("NeedleXRSession start, handle scripts:",n);for(const o of n){if(o.destroyed){this._script_to_remove.push(o);continue}if(!o.activeAndEnabled){this.markInactive(o);continue}this.invokeCallback_EnterXR(o);for(const r of this.controllers)this.invokeCallback_ControllerAdded(o,r)}}this.syncCameraCullingMask();for(const n of this.controllers)n.onUpdate(t);if(this._newControllers.length>0){const n=[...this._newControllers];this._newControllers.length=0;for(const o of n){if(!o.connected){console.warn("New controller is not connected",o);continue}this.controllers.push(o);for(const r of this._xr_scripts){if(r.destroyed){this._script_to_remove.push(r);continue}r.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(r,o)}}this.controllers.sort((o,r)=>o.index-r.index)}Fe&&this.context.time.frame%30===0&&this.controllers.length<=0&&this.session.inputSources.length>0&&(ba(!0),console.error("XRControllers are not added but inputSources are present"));for(const n of this._xr_update_scripts){if(n.destroyed===!0){this._script_to_remove.push(n);continue}if(n.activeAndEnabled===!1){this.markInactive(n);continue}n.onUpdateXR&&n.onUpdateXR(i)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const n=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const o of n)!o.destroyed&&this.running&&o.onLeaveXR?.(i),this.removeScript(o)}this.sync?.onUpdate(this),this.onRenderDebug()};onRenderDebug(){if(Fe)for(const e of this.controllers)e.onRenderDebug();if((Fe||w_)&&this.rig&&(Tf++,Tf>=20)){const e=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;e.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;e.add(i.multiplyScalar(2.5));let n="";if(n+=`${this.context.time.smoothedFps.toFixed(0)} FPS`,n+=`, calls: ${this.context.renderer.info.render.calls}, tris: ${this.context.renderer.info.render.triangles.toLocaleString()}`,Fe||w_)for(const o of this.controllers)n+=`
176
- ${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;Tf=0,B.DrawLabel(e,n,void 0,1/60*20)}}onBeforeRender=()=>{this.context.mainCamera&&(this.updateFade(this.context.mainCamera),this.requestedCameraNearPlane!==null&&this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera.near=this.requestedCameraNearPlane,this.requestedCameraNearPlane=null))};onAfterRender=()=>{if(this.onUpdateFade_PostRender(),exports.DeviceUtilities.isDesktop()||!this._renderOnceOnDevice){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const t=e.xr.enabled,i=e.getRenderTarget(),n=this.context.scene.background;e.xr.enabled=!1,e.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i),this.context.scene.background=n}}};addScript(e){return this._xr_scripts.includes(e)?!1:(Fe&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}_script_to_remove=[];removeScript(e,t=!0){Fe&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(e);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){const e=this.context.xrCamera,t=this.context.mainCameraComponent?.cullingMask;if(e&&t!==void 0){for(const i of e.cameras)i.layers.mask=t;e.layers.mask=t}else if(e){for(const i of e.cameras)i.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:e,change:i})}catch(r){console.error(r)}}}_camera;_cameraRenderParent=new c.Object3D().rotateY(Math.PI);_previousCameraParent;_customforward=!0;originalCameraNearPlane;requestedCameraNearPlane=null;applyCustomForward(){if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,this._previousCameraParent?.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);{let e=.02;const t=.001;if(this.rig){const i=je(this.rig.gameObject);e*=i.x}this._camera instanceof c.PerspectiveCamera&&Math.abs(this._camera.near-e)>t&&(this.isAR?this.originalCameraNearPlane=this._camera.near:this._camera.near=e,Fe&&console.debug(`Setting camera near plane to ${e} (was ${this.originalCameraNearPlane}) to account for XR rendering scale`))}}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof c.PerspectiveCamera&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane,this.originalCameraNearPlane=void 0)}_viewerPose;_transformOrientation=new c.Quaternion;_transformPosition=new c.Vector3;internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}_transition;get transition(){return this._transition||(this._transition=new y_),this._transition}fadeTransition(){return this._transition||(this._transition=new y_),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof c.PerspectiveCamera&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){this._transition?.remove()}}const Df=x("debugwebxr");class Zv{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(Df&&console.log("FOUND AVATAR HEAD",e.name),i.head=new Z("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(Df&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new Z("",t,e)),!i.rightHand&&n.includes("right")&&(Df&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new Z("",t,e)));for(let o=0;o<e.children.length;o++){if(i.head&&i.leftHand&&i.rightHand)return;const r=e.children[o];this.tryFindAvatarObjects(r,t,i)}}}class te extends c.Color{alpha=1;get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}constructor(e,t,i,n){super(),typeof e=="number"&&typeof t=="number"&&typeof i=="number"?(this.set(e,t,i),this.alpha=typeof n=="number"?n:1):e!==void 0&&(this.set(e),this.alpha=1)}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const i=e;return i.alpha!=null&&(this.alpha=L.lerp(this.alpha,i.alpha,t)),super.lerp(e,t)}lerpColors(e,t,i){const n=e,o=t;return n.alpha!=null&&o.alpha!=null&&(this.alpha=L.lerp(n.alpha,o.alpha,i)),super.lerpColors(e,t,i)}multiply(e){const t=e;return t.alpha!=null&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}static fromColorRepresentation(e){if(typeof e=="string"){if(e.trim()==="transparent")return new te(0,0,0,0);if(e.startsWith("#")&&e.length===9){const t=parseInt(e.slice(1,9),16),i=t>>24&255,n=t>>16&255,o=t>>8&255,r=t>>0&255;return new te(i/255,n/255,o/255,r/255)}else if(e.startsWith("#")){const t=parseInt(e.slice(1),16),i=t>>16&255,n=t>>8&255,o=t>>0&255;return new te(i/255,n/255,o/255,1)}else if(e.startsWith("rgba")){const t=e.slice(5,-1).split(",").map(Number);return new te(t[0]/255,t[1]/255,t[2]/255,t[3])}else if(e.startsWith("rgb")){const t=e.slice(4,-1).split(",").map(Number);return new te(t[0]/255,t[1]/255,t[2]/255,1)}}else if(Array.isArray(e)){if(e.length===4)return new te(e[0],e[1],e[2],e[3]);if(e.length===3)return new te(e[0],e[1],e[2],1);console.error("Invalid color array length. Expected 3 or 4, got "+e.length)}return new te(e)}}const Pt=new c.Vector3,x_=new c.Vector3,S_=new c.Quaternion,e1=x("debuggizmos"),en=8947848,If=32;class B{constructor(){}static enabled=!0;static isGizmo(e){return e[Up]!==void 0}static setVisible(e){for(const t of ki.timedObjectsBuffer)t.visible=e}static DrawLabel(e,t,i=.05,n=0,o,r,a){if(!B.enabled)return null;o||(o=en);const l=q.active?.rigScale??1,h=ki.getTextLabel(n,t,i*l,o,r);return a instanceof c.Object3D&&a.add(h),h.position.x=e.x,h.position.y=e.y,h.position.z=e.z,h}static DrawRay(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),Pt.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+Pt.x,e.y+Pt.y,e.z+Pt.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawDirection(e,t,i=en,n=0,o=!0,r=1){if(!B.enabled)return;const a=ki.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(Pt.set(0,0,-r),S_.set(t.x,t.y,t.z,t.w),Pt.applyQuaternion(S_)):(Pt.set(t.x,t.y,t.z),Pt.multiplyScalar(r)),l.setXYZ(1,e.x+Pt.x,e.y+Pt.y,e.z+Pt.z),l.needsUpdate=!0,a.material.depthTest=o,a.material.depthWrite=!1,on(a.material,i)}static DrawLine(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawCircle(e,t,i,n=en,o=0,r=!0){if(!B.enabled)return;const a=ki.getCircle(o);a.position.set(e.x,e.y,e.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,Pt.set(t.x,t.y,t.z).normalize()),a.material.depthTest=r,a.material.depthWrite=!1,a.material.fog=!1,on(a.material,n)}static DrawWireSphere(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getSphere(t,n,!0);dr(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawSphere(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getSphere(t,n,!1);dr(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,on(r.material,i)}static DrawWireBox(e,t,i=en,n=0,o=!0,r=void 0){if(!B.enabled)return;const a=ki.getBox(n);a.position.set(e.x,e.y,e.z),a.scale.set(t.x,t.y,t.z),r?a.quaternion.copy(r):a.quaternion.identity(),a.material.depthTest=o,a.material.wireframe=!0,a.material.depthWrite=!1,a.material.fog=!1,on(a.material,i)}static DrawWireBox3(e,t=en,i=0,n=!0){if(!B.enabled)return;const o=ki.getBox(i);o.position.copy(e.getCenter(Pt)),o.scale.copy(e.getSize(Pt)),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1,on(o.material,t)}static _up=new c.Vector3(0,1,0);static DrawArrow(e,t,i=en,n=0,o=!0,r=!1){if(!B.enabled)return;const a=ki.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Pt.set(t.x,t.y,t.z).sub(x_.set(e.x,e.y,e.z)).normalize());const h=Pt.set(t.x,t.y,t.z).sub(x_.set(e.x,e.y,e.z)).length()*.1;a.scale.set(h,h,h),a.material.depthTest=o,a.material.wireframe=r,on(a.material,i),this.DrawLine(e,t,i,n,o)}static DrawWireMesh(e){const t=ki.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrixWorld.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrixWorld.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0,on(t.material,e.color??en)}}const t1=new c.BoxGeometry(1,1,1);function Zm(s=null){const e=new c.Color(s??14540253),t=new c.EdgesGeometry(t1);return new c.LineSegments(t,new c.LineBasicMaterial({color:e}))}function on(s,e){if(Array.isArray(s)){for(const i of s)on(i,e);return}const t=e instanceof te?e.a:1;s.color.set(e),s.opacity=t,s.transparent=t<1}const Up=Symbol("GizmoCache");class ki{static familyName="needle-gizmos";static ensureFont(){let e=ie.__webpack_exports__default.FontLibrary.getFontFamily(this.familyName);e||(e=ie.__webpack_exports__default.FontLibrary.addFontFamily(this.familyName),e.addVariant("normal","normal","https://cdn.needle.tools/static/fonts/msdf/arial/arial-msdf.json","https://cdn.needle.tools/static/fonts/msdf/arial/arial.png")?.addEventListener("ready",()=>{ie.__webpack_exports__default.update()}))}static getTextLabel(e,t,i,n,o){this.ensureFont();let r=this.textLabelCache.pop(),a=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(a=parseInt(o.substring(7),16)/255,o=o.substring(0,7),e1&&console.log(o,a)):typeof o=="object"&&o.a!==void 0&&(a=o.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre",offset:.05*i};if(r)r.set(l);else{r=new ie.__webpack_exports__Text(l);const h=this,d=r;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(U.Current,r,e,this.textLabelCache),r}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new c.BoxGeometry(1,1,1);t=new c.Mesh(i)}return this.registerTimedObject(U.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");i||(i=new c.BufferAttribute(new Float32Array(6),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(U.Current,t,e,this.linesCache),t}static getCircle(e){let t=this.circlesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");if(!i){i=new c.BufferAttribute(new Float32Array(If*3),3),t.geometry.setAttribute("position",i);const n=F(0,1,0),o=F(0,0,1),r=F(o);r.cross(n).normalize();const a=F(r),l=Math.PI*2/(If-1);for(let h=0;h<If+1;h++){const d=l*h;n.copy(a).multiplyScalar(Math.cos(d)*1),r.copy(o).multiplyScalar(Math.sin(d)*1);const u=n.add(r);i.setXYZ(h,u.x,u.y,u.z)}}}return t.frustumCulled=!1,this.registerTimedObject(U.Current,t,e,this.circlesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new c.Mesh(new c.SphereGeometry(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(U.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new c.Mesh(new c.CylinderGeometry(0,.5,1,8))),this.registerTimedObject(U.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new c.Mesh,t.material=new c.MeshBasicMaterial),this.registerTimedObject(U.Current,t,e,this.mesh),t}static linesCache=[];static circlesCache=[];static spheresCache=[];static boxesCache=[];static arrowHeadsCache=[];static mesh=[];static textLabelCache=[];static registerTimedObject(e,t,i,n){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),r=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const a=e.pre_render_callbacks.indexOf(o);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(o)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(r){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==r){const a=e.post_render_callbacks.indexOf(r);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(r)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[Up]=n,t.castShadow=!1,t.receiveShadow=!1,t.isGizmo=!0,this.timedObjectsBuffer.push(t),this.timesBuffer.push(U.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static timedObjectsBuffer=new Array;static timesBuffer=new Array;static contextPostRenderCallbacks=new Map;static contextBeforeRenderCallbacks=new Map;static tmuiNeedsUpdate=!1;static onBeforeRender(e,t){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,ie.__webpack_exports__default.update());for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof ie.__webpack_exports__default.MeshUIBaseElement){if(ur(n))continue;const o=e.isInVR,r=!1,a=!o;Bc(n,e.mainCamera,r,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let o=t.length-1;o>=0;o--){const r=t[o];n>=i[o]-1e-6&&(t.splice(o,1),i.splice(o,1),r.removeFromParent(),ur(r)!=!0&&r[Up].push(r))}}}const Vt=x("debugphysics"),i1=x("debugworker"),C_=new c.Layers;class vo{static AllLayers=4294967295;ray;cam;screenPoint;raycaster;results;targets;recursive=!0;minDistance;maxDistance;lineThreshold;layerMask;ignore;testObject;useAcceleratedRaycast;allowSlowRaycastFallback=!0;screenPointFromOffset(e,t){this.screenPoint===void 0&&(this.screenPoint=new c.Vector2),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(t/window.innerHeight)*2+1}setLayer(e){C_.set(e),this.layerMask=C_}setMask(e){this.layerMask||(this.layerMask=new c.Layers);const t=this.layerMask;t?t.mask=e:this.layerMask=e}}class Jm{distance;point;object;constructor(e,t,i){this.object=e,this.distance=t,this.point=i}}class La{static _raycasting=0;static get raycasting(){return this._raycasting>0}raycastPhysicsFast(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycast(e,t,{maxDistance:i,solid:n})??null}raycastPhysicsFastAndGetNormal(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycastAndGetNormal(e,t,{maxDistance:i,solid:n})??null}sphereOverlapPhysics(e,t){return this.context.physics.engine?.sphereOverlap(e,t)??null}context;engine;constructor(e){this.context=e}raycaster=new c.Raycaster;defaultRaycastOptions=new vo;targetBuffer=new Array(1);defaultThresholds={Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}};sphereResults=new Array;sphereMask=new c.Layers;sphere=new c.Sphere;sphereOverlap(e,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,e,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(e,t=null){const i=t??this.defaultRaycastOptions;i.ray=e;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(e=null){Vt&&performance.mark("raycast.start"),e||(e=this.defaultRaycastOptions);const t=e.screenPoint??this.context.input.mousePositionRC,i=e.raycaster??this.raycaster;if(i.near=e.minDistance??0,i.far=e.maxDistance??1/0,i.params=this.defaultThresholds,e.lineThreshold===void 0&&(e.lineThreshold=-1),i.params.Line={threshold:e.lineThreshold},e.ray)i.ray.copy(e.ray);else{const a=e.cam??this.context.mainCamera;if(!a)return Vt&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof c.ArrayCamera&&l.cameras.length>0?i.setFromCamera(t,l.cameras[0]):i.setFromCamera(t,a)}let n=e.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=e.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),e.layerMask!==void 0?e.layerMask instanceof c.Layers?i.layers.mask=e.layerMask.mask:i.layers.mask=e.layerMask:(i.layers.enableAll(),i.layers.disable(2)),Vt&&console.time("raycast"),o.length=0,La._raycasting++,this.intersect(this.raycaster,n,o,e),o.sort((a,l)=>a.distance-l.distance);const r=e.ignore;return r!==void 0&&r.length>0&&(o=o.filter(a=>!r.includes(a.object))),La._raycasting--,Vt&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o?.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(e,t,i,n){for(const o of t){if(!o||o.visible===!1||B.isGizmo(o)||n.lineThreshold!==void 0&&n.lineThreshold<0&&o instanceof c.Line)continue;let r=!0;const a=o,l=a.geometry;if(o.raycastAllowed===!1&&(r=!1),r&&n.testObject){const h=n.testObject?.(o);if(h===!1)continue;h==="continue in children"&&(r=!1)}else r&&(l&&P_(l)||(r=!1));if(r){const h=i.length,d=o.raycastPreference||"lod";let u=d!=="bounds";if(n.precise===!1&&(u=!1),l&&(u||=l.getAttribute("position")?.array?.length<64),a instanceof X.GroundedSkybox&&(u=!1),d==="lod"){const p=re.getRaycastMesh(o);p&&(a.geometry=p)}if(!u&&s1(a,e,i)||(n.useAcceleratedRaycast!==!1?Ud.runMeshBVHRaycast(e,a,i,this.context,n):e.intersectObject(a,!1,i)),a.geometry=l,Vt&&i.length!=h){const p=i[i.length-1];B.DrawWireSphere(p.point,.1,7798784,1,!1),B.DrawWireMesh({mesh:o,depthTest:!1,duration:.2,color:7798784})}}n.recursive!==!1&&this.intersect(e,o.children,i,n)}return i}tempBoundingBox=new c.Box3;intersectSphere(e,t,i,n,o,r,a,l){let h=e&&e.isMesh&&e.layers.test(n)&&!B.isGizmo(e);h&&=e.visible,h&&=!(e instanceof c.Line),h&&=!(e instanceof X.GroundedSkybox);const d=e,u=d.geometry;if(h&&l){const p=l(e);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&P_(u)||(h=!1),h){if(a){const p=this.sphere;p.center.copy(t),p.radius=i;const m=o.length;if(Ud.runMeshBVHRaycast(this.sphere,d,o,this.context,{}),m!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),m=this.sphere;if(m.center.copy(t),m.radius=i,m.intersectsBox(p)){const y=Y(e),_=y.distanceTo(m.center),g=new Jm(e,_,y);if(o.push(g),!r)return}}}if(e.children)for(const p of e.children){const m=o.length;if(this.intersectSphere(p,t,i,n,o,r,a,l),m!=o.length&&!r)return}}}function P_(s){return!(s.index&&s.index.array.length<3)}const Bo=new c.Sphere,Bh=new c.Plane,n1=new c.Matrix3;function s1(s,e,t){const i=s._computeIntersections;if(!i)return!1;let n=s["_computeIntersections:Needle"];return n||(n=s["_computeIntersections:Needle"]=function(o,r,a){const l=this,h=l.geometry.boundingSphere;if(h){if(l instanceof X.GroundedSkybox){Bh.setFromNormalAndCoplanarPoint(F(0,1,0),F(0,-l.position.y,0)),Bh.applyMatrix4(l.matrixWorld,n1);const u=o.ray.intersectPlane(Bh,F());if(u){Bo.copy(h),Bo.applyMatrix4(l.matrixWorld);const m=F(u).sub(o.ray.origin).length(),y=Bo.radius*.5;m<y&&r.push({distance:m,point:u,object:l,normal:Bh.normal.clone()})}return}Bo.copy(h),Bo.applyMatrix4(l.matrixWorld);const d=o.ray.intersectSphere(Bo,F());if(d){const u=F(d).sub(o.ray.origin),p=u.length();if(p>Bo.radius){const m=u.clone().normalize();r.push({distance:p,point:d,object:l,normal:m})}}}}),s._computeIntersections=n,e.intersectObject(s,!1,t),s._computeIntersections=i,!0}var Ud;(s=>{let e=0;function t(b,v,R,O,M){if(!v.geometry||!v.geometry.hasAttribute("position"))return!1;const D=v.geometry;if(v?.isSkinnedMesh){const I=v,j=I.bvhNeedsUpdate;if(!I.staticGenerator)l(),r&&(I.staticGenerator=new r(v),I.staticGenerator.applyWorldTransforms=!1,I.staticGeometry=I.staticGenerator.generate(),D.boundsTree=a?.call(I.staticGeometry),I.staticGeometryLastUpdate=performance.now()+Math.random()*200,I.bvhNeedsUpdate=!0);else if(D.boundsTree&&(I.autoUpdateMeshBvhInterval!==void 0&&I.autoUpdateMeshBvhInterval>=0||j===!0)){const V=performance.now(),W=V-I.staticGeometryLastUpdate,k=I.autoUpdateMeshBvhInterval??100;(j||W>k)&&(Vt&&console.warn(`Physics: updating skinned mesh bvh for ${v.name} after ${W.toFixed(2)}ms`),I.bvhNeedsUpdate=!1,I.staticGeometryLastUpdate=V,I.staticGenerator?.generate(I.staticGeometry),D.boundsTree.refit())}}else if(!D.boundsTree){d||w();let I=!0;if((O.xr||D[y]===!1||D.getAttribute("position")?.isInterleavedBufferAttribute||D.index&&D.index?.isInterleavedBufferAttribute||e>10)&&(I=!1),I&&p){if(D[m]===void 0){let j=null;if(g.length>0){const V=g.shift();V&&!V.running&&(j=V)}if(!j&&_.length<3)try{i1&&console.warn("[GenerateMeshBVHWorker] Creating worker with import.meta.url:",typeof document>"u"?require("url").pathToFileURL(__filename).href:_a&&_a.tagName.toUpperCase()==="SCRIPT"&&_a.src||new URL("needle-engine.bundle-glRd_Shc.umd.cjs",document.baseURI).href),j=new p,_.push(j)}catch(V){V instanceof DOMException&&V.name==="SecurityError"?(console.warn("Failed to create MeshBVH worker, falling back to main thread generation. This can happen when running from file://, if the browser does not support workers or if the browser is blocking workers for other reasons."),console.debug(V),e+=10):(console.error("Failed to create MeshBVH worker. Please see below for more details:"),console.log(V)),e++}if(j!=null&&!j.running){const V=v.name;Vt&&console.log("<<<< worker start",V,j),D[m]="queued",performance.mark("bvh.create.start");const W=D.clone();try{j.generate(W).then(k=>{D[m]="done",D.boundsTree=k}).catch(k=>{D[m]="failed - "+k?.message,D[y]=!1,Vt&&console.error("Failed to generate mesh bvh on worker",k)}).finally(()=>{Vt&&console.log(">>>>> worker done",V,{hasBoundsTre:D.boundsTree!=null}),g.push(j),W.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch(k){console.error("Failed to generate mesh bvh on worker",k)}}else Vt&&console.warn("No worker available")}}else(!u||!I)&&(l(),o&&(performance.mark("bvh.create.start"),D.boundsTree=new o(D),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(b instanceof c.Raycaster){const I=b,j=v.raycast;if(D.boundsTree)l(),n&&(v.acceleratedRaycast||(v.acceleratedRaycast=n.bind(v),Vt&&console.debug(`Physics: bind acceleratedRaycast fn to "${v.name}"`)),v.raycast=v.acceleratedRaycast);else if(Vt&&console.warn("No bounds tree found for mesh",v.name,{workerTask:D[m],hasAcceleratedRaycast:n!=null}),M.allowSlowRaycastFallback===!1&&(D.getAttribute("position")?.array?.length??0)>2e3)return Vt&&console.warn("Skipping raycast because no bounds tree is available and allowSlowRaycastFallback is false"),!1;const V=I.firstHitOnly;return I.firstHitOnly=!1,I.intersectObject(v,!1,R),I.firstHitOnly=V,v.raycast=j,!0}else if(b instanceof c.Sphere){const I=D.boundsTree;if(I){const j=b;if(h.copy(v.matrixWorld).invert(),j.applyMatrix4(h),I.intersectsSphere(j)){const W=Y(v),k=W.distanceTo(j.center),N=new Jm(v,k,W);R.push(N)}}return!0}return!1}s.runMeshBVHRaycast=t;let i=!1,n=null,o=null,r=null,a=null;function l(){i||(i=!0,Promise.resolve().then(()=>require("./vendor-CipoooTV.umd.cjs")).then(b=>b.index$1).then(b=>{n=b.acceleratedRaycast,o=b.MeshBVH,r=b.StaticGeometryGenerator,a=b.computeBoundsTree}).catch(b=>{(Vt||A())&&console.error("Failed to load BVH library...",b.message)}))}const h=new c.Matrix4;let d=!1,u=!1,p=null;const m=Symbol("Needle:MeshBVH-Worker"),y=Symbol("Needle:MeshBVH-CanUseWorker"),_=[],g=[];function w(){d=!0,u=!0,Promise.resolve().then(()=>aA).then(b=>{p=b.GenerateMeshBVHWorker}).catch(b=>{Vt||A()?console.warn("Failed to setup mesh bvh worker"):console.debug("Failed to setup mesh bvh worker",b)}).finally(()=>{u=!1})}})(Ud||(Ud={}));const O_=Symbol("gltf-loader-internal-usage-tracker"),o1=x("debugusers");class xa{get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return xa._loadingProcesses>0}static _loadingProcesses=0;parser;_getDependency;_loadingId;_loadedObjects=new Set;constructor(e){this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}beforeRoot(){xa._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(e._loadedObjects.add(r),r[O_]=e._loadingId),r)),o},null}afterRoot(e){xa._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[O_],t instanceof c.Object3D&&(t.parent||t instanceof c.Mesh&&setTimeout(()=>{o1&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}}class Jv{constructor(){window.addEventListener("unhandledrejection",e=>{if(e.defaultPrevented)return;const t=e?.reason?.path;if(t){const i=t[0];i&&i.tagName==="IMG"&&(console.warn(`Could not load image:
176
+ ${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;Tf=0,B.DrawLabel(e,n,void 0,1/60*20)}}onBeforeRender=()=>{this.context.mainCamera&&(this.updateFade(this.context.mainCamera),this.requestedCameraNearPlane!==null&&this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera.near=this.requestedCameraNearPlane,this.requestedCameraNearPlane=null))};onAfterRender=()=>{if(this.onUpdateFade_PostRender(),exports.DeviceUtilities.isDesktop()||!this._renderOnceOnDevice){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const t=e.xr.enabled,i=e.getRenderTarget(),n=this.context.scene.background;e.xr.enabled=!1,e.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i),this.context.scene.background=n}}};addScript(e){return this._xr_scripts.includes(e)?!1:(Fe&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}_script_to_remove=[];removeScript(e,t=!0){Fe&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(e);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){const e=this.context.xrCamera,t=this.context.mainCameraComponent?.cullingMask;if(e&&t!==void 0){for(const i of e.cameras)i.layers.mask=t;e.layers.mask=t}else if(e){for(const i of e.cameras)i.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:e,change:i})}catch(r){console.error(r)}}}_camera;_cameraRenderParent=new c.Object3D().rotateY(Math.PI);_previousCameraParent;_customforward=!0;originalCameraNearPlane;requestedCameraNearPlane=null;applyCustomForward(){if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,this._previousCameraParent?.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);{let e=.02;const t=.001;if(this.rig){const i=je(this.rig.gameObject);e*=i.x}this._camera instanceof c.PerspectiveCamera&&Math.abs(this._camera.near-e)>t&&(this.isAR?this.originalCameraNearPlane=this._camera.near:this._camera.near=e,Fe&&console.debug(`Setting camera near plane to ${e} (was ${this.originalCameraNearPlane}) to account for XR rendering scale`))}}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof c.PerspectiveCamera&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane,this.originalCameraNearPlane=void 0)}_viewerPose;_transformOrientation=new c.Quaternion;_transformPosition=new c.Vector3;internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}_transition;get transition(){return this._transition||(this._transition=new y_),this._transition}fadeTransition(){return this._transition||(this._transition=new y_),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof c.PerspectiveCamera&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){this._transition?.remove()}}const Df=x("debugwebxr");class Zv{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(Df&&console.log("FOUND AVATAR HEAD",e.name),i.head=new Z("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(Df&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new Z("",t,e)),!i.rightHand&&n.includes("right")&&(Df&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new Z("",t,e)));for(let o=0;o<e.children.length;o++){if(i.head&&i.leftHand&&i.rightHand)return;const r=e.children[o];this.tryFindAvatarObjects(r,t,i)}}}class te extends c.Color{alpha=1;get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}constructor(e,t,i,n){super(),typeof e=="number"&&typeof t=="number"&&typeof i=="number"?(this.set(e,t,i),this.alpha=typeof n=="number"?n:1):e!==void 0&&(this.set(e),this.alpha=1)}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const i=e;return i.alpha!=null&&(this.alpha=L.lerp(this.alpha,i.alpha,t)),super.lerp(e,t)}lerpColors(e,t,i){const n=e,o=t;return n.alpha!=null&&o.alpha!=null&&(this.alpha=L.lerp(n.alpha,o.alpha,i)),super.lerpColors(e,t,i)}multiply(e){const t=e;return t.alpha!=null&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}static fromColorRepresentation(e){if(typeof e=="string"){if(e.trim()==="transparent")return new te(0,0,0,0);if(e.startsWith("#")&&e.length===9){const t=parseInt(e.slice(1,9),16),i=t>>24&255,n=t>>16&255,o=t>>8&255,r=t>>0&255;return new te(i/255,n/255,o/255,r/255)}else if(e.startsWith("#")){const t=parseInt(e.slice(1),16),i=t>>16&255,n=t>>8&255,o=t>>0&255;return new te(i/255,n/255,o/255,1)}else if(e.startsWith("rgba")){const t=e.slice(5,-1).split(",").map(Number);return new te(t[0]/255,t[1]/255,t[2]/255,t[3])}else if(e.startsWith("rgb")){const t=e.slice(4,-1).split(",").map(Number);return new te(t[0]/255,t[1]/255,t[2]/255,1)}}else if(Array.isArray(e)){if(e.length===4)return new te(e[0],e[1],e[2],e[3]);if(e.length===3)return new te(e[0],e[1],e[2],1);console.error("Invalid color array length. Expected 3 or 4, got "+e.length)}return new te(e)}}const Pt=new c.Vector3,x_=new c.Vector3,S_=new c.Quaternion,e1=x("debuggizmos"),en=8947848,If=32;class B{constructor(){}static enabled=!0;static isGizmo(e){return e[Up]!==void 0}static setVisible(e){for(const t of ki.timedObjectsBuffer)t.visible=e}static DrawLabel(e,t,i=.05,n=0,o,r,a){if(!B.enabled)return null;o||(o=en);const l=q.active?.rigScale??1,h=ki.getTextLabel(n,t,i*l,o,r);return a instanceof c.Object3D&&a.add(h),h.position.x=e.x,h.position.y=e.y,h.position.z=e.z,h}static DrawRay(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),Pt.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+Pt.x,e.y+Pt.y,e.z+Pt.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawDirection(e,t,i=en,n=0,o=!0,r=1){if(!B.enabled)return;const a=ki.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(Pt.set(0,0,-r),S_.set(t.x,t.y,t.z,t.w),Pt.applyQuaternion(S_)):(Pt.set(t.x,t.y,t.z),Pt.multiplyScalar(r)),l.setXYZ(1,e.x+Pt.x,e.y+Pt.y,e.z+Pt.z),l.needsUpdate=!0,a.material.depthTest=o,a.material.depthWrite=!1,on(a.material,i)}static DrawLine(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawCircle(e,t,i,n=en,o=0,r=!0){if(!B.enabled)return;const a=ki.getCircle(o);a.position.set(e.x,e.y,e.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,Pt.set(t.x,t.y,t.z).normalize()),a.material.depthTest=r,a.material.depthWrite=!1,a.material.fog=!1,on(a.material,n)}static DrawWireSphere(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getSphere(t,n,!0);dr(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,on(r.material,i)}static DrawSphere(e,t,i=en,n=0,o=!0){if(!B.enabled)return;const r=ki.getSphere(t,n,!1);dr(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,on(r.material,i)}static DrawWireBox(e,t,i=en,n=0,o=!0,r=void 0){if(!B.enabled)return;const a=ki.getBox(n);a.position.set(e.x,e.y,e.z),a.scale.set(t.x,t.y,t.z),r?a.quaternion.copy(r):a.quaternion.identity(),a.material.depthTest=o,a.material.wireframe=!0,a.material.depthWrite=!1,a.material.fog=!1,on(a.material,i)}static DrawWireBox3(e,t=en,i=0,n=!0){if(!B.enabled)return;const o=ki.getBox(i);o.position.copy(e.getCenter(Pt)),o.scale.copy(e.getSize(Pt)),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1,on(o.material,t)}static _up=new c.Vector3(0,1,0);static DrawArrow(e,t,i=en,n=0,o=!0,r=!1){if(!B.enabled)return;const a=ki.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Pt.set(t.x,t.y,t.z).sub(x_.set(e.x,e.y,e.z)).normalize());const h=Pt.set(t.x,t.y,t.z).sub(x_.set(e.x,e.y,e.z)).length()*.1;a.scale.set(h,h,h),a.material.depthTest=o,a.material.wireframe=r,on(a.material,i),this.DrawLine(e,t,i,n,o)}static DrawWireMesh(e){const t=ki.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrixWorld.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrixWorld.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0,on(t.material,e.color??en)}}const t1=new c.BoxGeometry(1,1,1);function Zm(s=null){const e=new c.Color(s??14540253),t=new c.EdgesGeometry(t1);return new c.LineSegments(t,new c.LineBasicMaterial({color:e}))}function on(s,e){if(Array.isArray(s)){for(const i of s)on(i,e);return}const t=e instanceof te?e.a:1;s.color.set(e),s.opacity=t,s.transparent=t<1}const Up=Symbol("GizmoCache");class ki{static familyName="needle-gizmos";static ensureFont(){let e=ie.__webpack_exports__default.FontLibrary.getFontFamily(this.familyName);e||(e=ie.__webpack_exports__default.FontLibrary.addFontFamily(this.familyName),e.addVariant("normal","normal","https://cdn.needle.tools/static/fonts/msdf/arial/arial-msdf.json","https://cdn.needle.tools/static/fonts/msdf/arial/arial.png")?.addEventListener("ready",()=>{ie.__webpack_exports__default.update()}))}static getTextLabel(e,t,i,n,o){this.ensureFont();let r=this.textLabelCache.pop(),a=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(a=parseInt(o.substring(7),16)/255,o=o.substring(0,7),e1&&console.log(o,a)):typeof o=="object"&&o.a!==void 0&&(a=o.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre",offset:.05*i};if(r)r.set(l);else{r=new ie.__webpack_exports__Text(l);const h=this,d=r;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(U.Current,r,e,this.textLabelCache),r}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new c.BoxGeometry(1,1,1);t=new c.Mesh(i)}return this.registerTimedObject(U.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");i||(i=new c.BufferAttribute(new Float32Array(6),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(U.Current,t,e,this.linesCache),t}static getCircle(e){let t=this.circlesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");if(!i){i=new c.BufferAttribute(new Float32Array(If*3),3),t.geometry.setAttribute("position",i);const n=F(0,1,0),o=F(0,0,1),r=F(o);r.cross(n).normalize();const a=F(r),l=Math.PI*2/(If-1);for(let h=0;h<If+1;h++){const d=l*h;n.copy(a).multiplyScalar(Math.cos(d)*1),r.copy(o).multiplyScalar(Math.sin(d)*1);const u=n.add(r);i.setXYZ(h,u.x,u.y,u.z)}}}return t.frustumCulled=!1,this.registerTimedObject(U.Current,t,e,this.circlesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new c.Mesh(new c.SphereGeometry(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(U.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new c.Mesh(new c.CylinderGeometry(0,.5,1,8))),this.registerTimedObject(U.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new c.Mesh,t.material=new c.MeshBasicMaterial),this.registerTimedObject(U.Current,t,e,this.mesh),t}static linesCache=[];static circlesCache=[];static spheresCache=[];static boxesCache=[];static arrowHeadsCache=[];static mesh=[];static textLabelCache=[];static registerTimedObject(e,t,i,n){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),r=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const a=e.pre_render_callbacks.indexOf(o);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(o)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(r){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==r){const a=e.post_render_callbacks.indexOf(r);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(r)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[Up]=n,t.castShadow=!1,t.receiveShadow=!1,t.isGizmo=!0,this.timedObjectsBuffer.push(t),this.timesBuffer.push(U.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static timedObjectsBuffer=new Array;static timesBuffer=new Array;static contextPostRenderCallbacks=new Map;static contextBeforeRenderCallbacks=new Map;static tmuiNeedsUpdate=!1;static onBeforeRender(e,t){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,ie.__webpack_exports__default.update());for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof ie.__webpack_exports__default.MeshUIBaseElement){if(ur(n))continue;const o=e.isInVR,r=!1,a=!o;Bc(n,e.mainCamera,r,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let o=t.length-1;o>=0;o--){const r=t[o];n>=i[o]-1e-6&&(t.splice(o,1),i.splice(o,1),r.removeFromParent(),ur(r)!=!0&&r[Up].push(r))}}}const Vt=x("debugphysics"),i1=x("debugworker"),C_=new c.Layers;class vo{static AllLayers=4294967295;ray;cam;screenPoint;raycaster;results;targets;recursive=!0;minDistance;maxDistance;lineThreshold;layerMask;ignore;testObject;useAcceleratedRaycast;allowSlowRaycastFallback=!0;screenPointFromOffset(e,t){this.screenPoint===void 0&&(this.screenPoint=new c.Vector2),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(t/window.innerHeight)*2+1}setLayer(e){C_.set(e),this.layerMask=C_}setMask(e){this.layerMask||(this.layerMask=new c.Layers);const t=this.layerMask;t?t.mask=e:this.layerMask=e}}class Jm{distance;point;object;constructor(e,t,i){this.object=e,this.distance=t,this.point=i}}class La{static _raycasting=0;static get raycasting(){return this._raycasting>0}raycastPhysicsFast(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycast(e,t,{maxDistance:i,solid:n})??null}raycastPhysicsFastAndGetNormal(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycastAndGetNormal(e,t,{maxDistance:i,solid:n})??null}sphereOverlapPhysics(e,t){return this.context.physics.engine?.sphereOverlap(e,t)??null}context;engine;constructor(e){this.context=e}raycaster=new c.Raycaster;defaultRaycastOptions=new vo;targetBuffer=new Array(1);defaultThresholds={Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}};sphereResults=new Array;sphereMask=new c.Layers;sphere=new c.Sphere;sphereOverlap(e,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,e,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(e,t=null){const i=t??this.defaultRaycastOptions;i.ray=e;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(e=null){Vt&&performance.mark("raycast.start"),e||(e=this.defaultRaycastOptions);const t=e.screenPoint??this.context.input.mousePositionRC,i=e.raycaster??this.raycaster;if(i.near=e.minDistance??0,i.far=e.maxDistance??1/0,i.params=this.defaultThresholds,e.lineThreshold===void 0&&(e.lineThreshold=-1),i.params.Line={threshold:e.lineThreshold},e.ray)i.ray.copy(e.ray);else{const a=e.cam??this.context.mainCamera;if(!a)return Vt&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof c.ArrayCamera&&l.cameras.length>0?i.setFromCamera(t,l.cameras[0]):i.setFromCamera(t,a)}let n=e.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=e.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),e.layerMask!==void 0?e.layerMask instanceof c.Layers?i.layers.mask=e.layerMask.mask:i.layers.mask=e.layerMask:(i.layers.enableAll(),i.layers.disable(2)),Vt&&console.time("raycast"),o.length=0,La._raycasting++,this.intersect(this.raycaster,n,o,e),o.sort((a,l)=>a.distance-l.distance);const r=e.ignore;return r!==void 0&&r.length>0&&(o=o.filter(a=>!r.includes(a.object))),La._raycasting--,Vt&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o?.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(e,t,i,n){for(const o of t){if(!o||o.visible===!1||B.isGizmo(o)||n.lineThreshold!==void 0&&n.lineThreshold<0&&o instanceof c.Line)continue;let r=!0;const a=o,l=a.geometry;if(o.raycastAllowed===!1&&(r=!1),r&&n.testObject){const h=n.testObject?.(o);if(h===!1)continue;h==="continue in children"&&(r=!1)}else r&&(l&&P_(l)||(r=!1));if(r){const h=i.length,d=o.raycastPreference||"lod";let u=d!=="bounds";if(n.precise===!1&&(u=!1),l&&(u||=l.getAttribute("position")?.array?.length<64),a instanceof X.GroundedSkybox&&(u=!1),d==="lod"){const p=re.getRaycastMesh(o);p&&(a.geometry=p)}if(!u&&s1(a,e,i)||(n.useAcceleratedRaycast!==!1?Ud.runMeshBVHRaycast(e,a,i,this.context,n):e.intersectObject(a,!1,i)),a.geometry=l,Vt&&i.length!=h){const p=i[i.length-1];B.DrawWireSphere(p.point,.1,7798784,1,!1),B.DrawWireMesh({mesh:o,depthTest:!1,duration:.2,color:7798784})}}n.recursive!==!1&&this.intersect(e,o.children,i,n)}return i}tempBoundingBox=new c.Box3;intersectSphere(e,t,i,n,o,r,a,l){let h=e&&e.isMesh&&e.layers.test(n)&&!B.isGizmo(e);h&&=e.visible,h&&=!(e instanceof c.Line),h&&=!(e instanceof X.GroundedSkybox);const d=e,u=d.geometry;if(h&&l){const p=l(e);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&P_(u)||(h=!1),h){if(a){const p=this.sphere;p.center.copy(t),p.radius=i;const m=o.length;if(Ud.runMeshBVHRaycast(this.sphere,d,o,this.context,{}),m!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),m=this.sphere;if(m.center.copy(t),m.radius=i,m.intersectsBox(p)){const y=Y(e),_=y.distanceTo(m.center),g=new Jm(e,_,y);if(o.push(g),!r)return}}}if(e.children)for(const p of e.children){const m=o.length;if(this.intersectSphere(p,t,i,n,o,r,a,l),m!=o.length&&!r)return}}}function P_(s){return!(s.index&&s.index.array.length<3)}const Bo=new c.Sphere,Bh=new c.Plane,n1=new c.Matrix3;function s1(s,e,t){const i=s._computeIntersections;if(!i)return!1;let n=s["_computeIntersections:Needle"];return n||(n=s["_computeIntersections:Needle"]=function(o,r,a){const l=this,h=l.geometry.boundingSphere;if(h){if(l instanceof X.GroundedSkybox){Bh.setFromNormalAndCoplanarPoint(F(0,1,0),F(0,-l.position.y,0)),Bh.applyMatrix4(l.matrixWorld,n1);const u=o.ray.intersectPlane(Bh,F());if(u){Bo.copy(h),Bo.applyMatrix4(l.matrixWorld);const m=F(u).sub(o.ray.origin).length(),y=Bo.radius*.5;m<y&&r.push({distance:m,point:u,object:l,normal:Bh.normal.clone()})}return}Bo.copy(h),Bo.applyMatrix4(l.matrixWorld);const d=o.ray.intersectSphere(Bo,F());if(d){const u=F(d).sub(o.ray.origin),p=u.length();if(p>Bo.radius){const m=u.clone().normalize();r.push({distance:p,point:d,object:l,normal:m})}}}}),s._computeIntersections=n,e.intersectObject(s,!1,t),s._computeIntersections=i,!0}var Ud;(s=>{let e=0;function t(b,v,R,O,M){if(!v.geometry||!v.geometry.hasAttribute("position"))return!1;const D=v.geometry;if(v?.isSkinnedMesh){const I=v,j=I.bvhNeedsUpdate;if(!I.staticGenerator)l(),r&&(I.staticGenerator=new r(v),I.staticGenerator.applyWorldTransforms=!1,I.staticGeometry=I.staticGenerator.generate(),D.boundsTree=a?.call(I.staticGeometry),I.staticGeometryLastUpdate=performance.now()+Math.random()*200,I.bvhNeedsUpdate=!0);else if(D.boundsTree&&(I.autoUpdateMeshBvhInterval!==void 0&&I.autoUpdateMeshBvhInterval>=0||j===!0)){const V=performance.now(),W=V-I.staticGeometryLastUpdate,k=I.autoUpdateMeshBvhInterval??100;(j||W>k)&&(Vt&&console.warn(`Physics: updating skinned mesh bvh for ${v.name} after ${W.toFixed(2)}ms`),I.bvhNeedsUpdate=!1,I.staticGeometryLastUpdate=V,I.staticGenerator?.generate(I.staticGeometry),D.boundsTree.refit())}}else if(!D.boundsTree){d||w();let I=!0;if((O.xr||D[y]===!1||D.getAttribute("position")?.isInterleavedBufferAttribute||D.index&&D.index?.isInterleavedBufferAttribute||e>10)&&(I=!1),I&&p){if(D[m]===void 0){let j=null;if(g.length>0){const V=g.shift();V&&!V.running&&(j=V)}if(!j&&_.length<3)try{i1&&console.warn("[GenerateMeshBVHWorker] Creating worker with import.meta.url:",typeof document>"u"?require("url").pathToFileURL(__filename).href:_a&&_a.tagName.toUpperCase()==="SCRIPT"&&_a.src||new URL("needle-engine.bundle-CK9xKTOH.umd.cjs",document.baseURI).href),j=new p,_.push(j)}catch(V){V instanceof DOMException&&V.name==="SecurityError"?(console.warn("Failed to create MeshBVH worker, falling back to main thread generation. This can happen when running from file://, if the browser does not support workers or if the browser is blocking workers for other reasons."),console.debug(V),e+=10):(console.error("Failed to create MeshBVH worker. Please see below for more details:"),console.log(V)),e++}if(j!=null&&!j.running){const V=v.name;Vt&&console.log("<<<< worker start",V,j),D[m]="queued",performance.mark("bvh.create.start");const W=D.clone();try{j.generate(W).then(k=>{D[m]="done",D.boundsTree=k}).catch(k=>{D[m]="failed - "+k?.message,D[y]=!1,Vt&&console.error("Failed to generate mesh bvh on worker",k)}).finally(()=>{Vt&&console.log(">>>>> worker done",V,{hasBoundsTre:D.boundsTree!=null}),g.push(j),W.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch(k){console.error("Failed to generate mesh bvh on worker",k)}}else Vt&&console.warn("No worker available")}}else(!u||!I)&&(l(),o&&(performance.mark("bvh.create.start"),D.boundsTree=new o(D),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(b instanceof c.Raycaster){const I=b,j=v.raycast;if(D.boundsTree)l(),n&&(v.acceleratedRaycast||(v.acceleratedRaycast=n.bind(v),Vt&&console.debug(`Physics: bind acceleratedRaycast fn to "${v.name}"`)),v.raycast=v.acceleratedRaycast);else if(Vt&&console.warn("No bounds tree found for mesh",v.name,{workerTask:D[m],hasAcceleratedRaycast:n!=null}),M.allowSlowRaycastFallback===!1&&(D.getAttribute("position")?.array?.length??0)>2e3)return Vt&&console.warn("Skipping raycast because no bounds tree is available and allowSlowRaycastFallback is false"),!1;const V=I.firstHitOnly;return I.firstHitOnly=!1,I.intersectObject(v,!1,R),I.firstHitOnly=V,v.raycast=j,!0}else if(b instanceof c.Sphere){const I=D.boundsTree;if(I){const j=b;if(h.copy(v.matrixWorld).invert(),j.applyMatrix4(h),I.intersectsSphere(j)){const W=Y(v),k=W.distanceTo(j.center),N=new Jm(v,k,W);R.push(N)}}return!0}return!1}s.runMeshBVHRaycast=t;let i=!1,n=null,o=null,r=null,a=null;function l(){i||(i=!0,Promise.resolve().then(()=>require("./vendor-CipoooTV.umd.cjs")).then(b=>b.index$1).then(b=>{n=b.acceleratedRaycast,o=b.MeshBVH,r=b.StaticGeometryGenerator,a=b.computeBoundsTree}).catch(b=>{(Vt||A())&&console.error("Failed to load BVH library...",b.message)}))}const h=new c.Matrix4;let d=!1,u=!1,p=null;const m=Symbol("Needle:MeshBVH-Worker"),y=Symbol("Needle:MeshBVH-CanUseWorker"),_=[],g=[];function w(){d=!0,u=!0,Promise.resolve().then(()=>aA).then(b=>{p=b.GenerateMeshBVHWorker}).catch(b=>{Vt||A()?console.warn("Failed to setup mesh bvh worker"):console.debug("Failed to setup mesh bvh worker",b)}).finally(()=>{u=!1})}})(Ud||(Ud={}));const O_=Symbol("gltf-loader-internal-usage-tracker"),o1=x("debugusers");class xa{get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return xa._loadingProcesses>0}static _loadingProcesses=0;parser;_getDependency;_loadingId;_loadedObjects=new Set;constructor(e){this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}beforeRoot(){xa._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(e._loadedObjects.add(r),r[O_]=e._loadingId),r)),o},null}afterRoot(e){xa._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[O_],t instanceof c.Object3D&&(t.parent||t instanceof c.Mesh&&setTimeout(()=>{o1&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}}class Jv{constructor(){window.addEventListener("unhandledrejection",e=>{if(e.defaultPrevented)return;const t=e?.reason?.path;if(t){const i=t[0];i&&i.tagName==="IMG"&&(console.warn(`Could not load image:
177
177
  `+i.src),e.preventDefault())}})}}const mu=x("trackresources");function e0(){return mu==="dispose"}let wr=!0;mu===0&&(wr=!1);function r1(s){wr=s}function t0(){return wr}const i0=Symbol("disposable");function n0(s,e){s&&(s[i0]=e,ir&&console.warn("Set disposable",e,s))}const s0=Symbol("disposed");function a1(s){return s[s0]===!0}function ve(s){if(s){if(s[i0]===!1){ir&&console.warn("Object is marked as not disposable",s);return}if(typeof s=="object"&&(s[s0]=!0),s instanceof c.Scene)ve(s.environment),ve(s.background),ve(s.customDepthMaterial),ve(s.customDistanceMaterial);else if(s instanceof c.SkinnedMesh)ve(s.geometry),ve(s.material),ve(s.skeleton),ve(s.bindMatrix),ve(s.bindMatrixInverse),ve(s.customDepthMaterial),ve(s.customDistanceMaterial),s.visible=!1;else if(s instanceof c.Mesh)ve(s.geometry),ve(s.material),ve(s.customDepthMaterial),ve(s.customDistanceMaterial),s.visible=!1;else if(s instanceof c.Object3D)s.visible=!1;else if(s instanceof c.BufferGeometry){Gr(s);for(const e of Object.keys(s.attributes)){const t=s.attributes[e];ve(t)}}else if(s instanceof c.BufferAttribute||s instanceof c.InterleavedBufferAttribute)ir&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const e of s)e instanceof c.Material&&ve(e);else if(s instanceof c.Material){Gr(s);for(const t of Object.keys(s)){const i=s[t];i instanceof c.Texture&&ve(i)}const e=s.uniforms;if(e)for(const t of Object.keys(e)){const i=e[t];i instanceof c.Texture?ve(i):i instanceof c.Uniform$1&&ve(i.value)}}else s instanceof c.Texture?(Gr(s),Gr(s.source),s.source?.data instanceof ImageBitmap&&Gr(s.source.data)):s instanceof c.Skeleton?(Gr(s.boneTexture),s.boneTexture=null):s instanceof c.Bone||!(s instanceof c.Object3D)&&ir&&console.warn("Unknown object type",s)}}function Gr(s){s&&((ir||e0()||mu)&&console.warn("🧨 FREE",s),s instanceof ImageBitmap||"dispose"in s&&typeof s.dispose=="function"&&s.dispose())}function l1(s){}const c1=new Set;function eg(s,e,t=null,i){if(i||(i=c1,i.clear()),!s)return i;const n=s[_c];if(n)for(const o of n)i.has(o)||t?.call(null,o)!==!1&&(i.add(o),e&&eg(o,!0,t,i));return i}function h1(s){return s[Ul]}const ir=x("debugresourceusers")||x("debugmemory"),_c=Symbol("needle-resource-users"),Ul=Symbol("needle-resource-users-count");function Bt(s,e){uu(s,e,function(t,i){wr&&!La.raycasting&&(zd(_c,this,t,!1),zd(_c,this,i,!0))})}wr&&(Bt(c.Mesh.prototype,"material"),Bt(c.Mesh.prototype,"geometry"),Bt(c.Material.prototype,"map"),Bt(c.Material.prototype,"bumpMap"),Bt(c.Material.prototype,"alphaMap"),Bt(c.Material.prototype,"normalMap"),Bt(c.Material.prototype,"displacementMap"),Bt(c.Material.prototype,"roughnessMap"),Bt(c.Material.prototype,"metalnessMap"),Bt(c.Material.prototype,"emissiveMap"),Bt(c.Material.prototype,"specularMap"),Bt(c.Material.prototype,"envMap"),Bt(c.Material.prototype,"lightMap"),Bt(c.Material.prototype,"aoMap"),Bt(c.Material.prototype,"gradientMap"));function d1(s){if(wr===!1)return;const e=s[_c];if(e)for(const t of e)zd(_c,t,s,!1)}wr&&uu(c.Material.prototype,"dispose",function(){d1(this)});let zp=0;function zd(s,e,t,i){if(zp>0)return;if(Array.isArray(t)){for(const o of t)zd(s,e,o,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let o=t[Ul]||0;o+=1,t[Ul]=o,ir&&console.warn(`🟢 Added user of "${t.type}"`,e,t,o,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let o=t[Ul]||0;o>0&&(o-=1,t[Ul]=o),ir&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,o,"users:",n),o<=0&&(xa.isLoading(t)||(mu&&console.warn(`🔴 Removed all user of "${t.type}"`,t),e0()&&ve(t)))}t[s]=n}try{uu(c.WebGLRenderer.prototype,"render",function(){zp++},function(){zp--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}const M_=x("debugcomponentevents");class gu{static eventListeners=new Map;static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),M_&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(M_&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}const bc=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),o0=Symbol("isUsingInstancing"),r0=Symbol("instancingRenderer"),zl=Symbol("instancingAutoUpdateBounds");class zi{static isUsingInstancing(e){return e[o0]===!0}static getRenderer(e){return e[r0]||null}setAutoUpdateBounds(e,t){const i=zi.getRenderer(e);i&&(i[zl]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[bc]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)zi.markDirty(i,!0)}}const tg={experimentalSmartHierarchyUpdate:!1};function tc(s,e){try{e||s()}catch(t){return console.error(t),!1}return!0}const Np=x("debugnewscripts"),u1=x("debughierarchy"),Ce=[];function f1(){return Ce.length>0}function Nd(s){if(Np&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}if(!(s.new_scripts.length<=0)){Ce.length=0,s.new_scripts.length>0&&Ce.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<Ce.length;e++)try{const t=Ce[e];if(t.isComponent!==!0){(A()||Np)&&console.error(`Registered script is not a Needle Engine component.
178
178
  The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
179
179
  `,t),Ce.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.warn(`Component can not be initialized: no GameObject assigned.
@@ -997,7 +997,7 @@ Consider registering a custom loader via the 'onCreateCustomModelLoader' callbac
997
997
 
998
998
  Content-Type: "${t.headers.get("content-type")}"
999
999
  "Text: "${o}"
1000
- Binary:`,i)}else ke&&console.debug("Could not determine file type from binary data");return"unknown"}const Kf=x("debugstencil");function XO(s,e){return(s&1<<e.layer)!=0}const QO=Symbol("stencils");class eo{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Kf&&console.log(t,eo.stencils),!t)return;const i=eo.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];if(XO(o.layer,e)){Kf&&console.log(o),setTimeout(()=>{gi()&&bu(e.gameObject)&&(fe("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[QO]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=o.value,a.stencilFunc=o.compareFunc,a.stencilZPass=o.passOp,a.stencilFail=o.failOp,a.stencilZFail=o.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=o.event*1e3+o.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[KO];if(i){Kf&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const o of n){const r={...o};r.compareFunc=YO(r.compareFunc),r.passOp=Zf(r.passOp),r.failOp=Zf(r.failOp),r.zFailOp=Zf(r.zFailOp),eo.stencils[this.source]||(eo.stencils[this.source]=[]),eo.stencils[this.source].push(r)}}}return null}}function Zf(s){switch(s){case 0:return c.KeepStencilOp;case 1:return c.ZeroStencilOp;case 2:return c.ReplaceStencilOp;case 3:return c.IncrementStencilOp;case 4:return c.DecrementStencilOp;case 6:return c.IncrementWrapStencilOp;case 7:return c.DecrementWrapStencilOp;case 5:return c.InvertStencilOp}return 0}function YO(s){switch(s){case 1:return c.NeverStencilFunc;case 2:return c.LessStencilFunc;case 3:return c.EqualStencilFunc;case 4:return c.LessEqualStencilFunc;case 5:return c.GreaterStencilFunc;case 6:return c.NotEqualStencilFunc;case 7:return c.GreaterEqualStencilFunc;case 8:return c.AlwaysStencilFunc}return c.NeverStencilFunc}const KO="NEEDLE_render_objects";class ZO{objectToBlock=new WeakMap;meshToOwners=new WeakMap;meshToOriginalCallbacks=new WeakMap;getBlock(e){return this.objectToBlock.get(e)}setBlock(e,t){this.objectToBlock.set(e,t)}deleteBlock(e){this.objectToBlock.delete(e)}isHooked(e,t){return this.meshToOwners.get(e)?.has(t)??!1}addHook(e,t){let i=this.meshToOwners.get(e);i||(i=new Set,this.meshToOwners.set(e,i)),i.add(t)}removeHook(e,t){const i=this.meshToOwners.get(e);i&&(i.delete(t),i.size===0&&this.meshToOwners.delete(e))}getOriginalCallbacks(e){return this.meshToOriginalCallbacks.get(e)}setOriginalCallbacks(e,t){this.meshToOriginalCallbacks.set(e,t)}}const fs=new ZO;class ys{_overrides=[];_defines={};_object=null;get object(){return this._object}constructor(e=null){this._object=e}static get(e){let t=fs.getBlock(e);return t||(t=new ys(e),fs.setBlock(e,t),tM(e,t)),t}static hasOverrides(e){const t=fs.getBlock(e);return t?t.hasOverrides():!1}dispose(){this._object&&fs.deleteBlock(this._object),this._overrides=[],this._object=null}setOverride(e,t,i){const n=this._overrides.find(o=>o.name===e);n?(n.value=t,n.textureTransform=i):this._overrides.push({name:e,value:t,textureTransform:i})}getOverride(e){return this._overrides.find(t=>t.name===e)}removeOveride(e){const t=this._overrides.findIndex(i=>i.name===e);t>=0&&this._overrides.splice(t,1)}clearAllOverrides(){this._overrides=[]}get overrides(){return this._overrides}hasOverrides(){return this._overrides.length>0}setDefine(e,t){this._defines[e]=t}clearDefine(e){this._defines[e]=void 0}getDefines(){return this._defines}getCacheKey(){const e=[],t=Object.keys(this._defines).sort();for(const i of t){const n=this._defines[i];n!==void 0&&e.push(`d:${i}=${n}`)}for(const i of this._overrides){if(i.value===null)continue;let n="";if(i.value instanceof c.Texture){if(n=i.value.uuid||"texture",i.textureTransform){const o=i.textureTransform;o.offset&&(n+=`;to:${o.offset.x},${o.offset.y}`),o.repeat&&(n+=`;tr:${o.repeat.x},${o.repeat.y}`)}}else if(Array.isArray(i.value))n=i.value.join(",");else if(i.value&&typeof i.value=="object"&&"r"in i.value){const o=i.value;n=`${o.r},${o.g},${o.b},${o.a!==void 0?o.a:""}`}else if(i.value&&typeof i.value=="object"&&"x"in i.value){const o=i.value;n=`${o.x},${o.y}${o.z!==void 0?`,${o.z}`:""}${o.w!==void 0?`,${o.w}`:""}`}else n=String(i.value);e.push(`${i.name}=${n}`)}return e.join(";")}}const Cd=Symbol("originalValues"),Pd=Symbol("savedTextureTransforms");function Sw(s){let e=fs.getBlock(s);if(e)return{block:e,owner:s};if(s.parent&&s.parent.type==="Group"&&(e=fs.getBlock(s.parent),e))return{block:e,owner:s.parent}}const Ca=Symbol("beforeRenderingFlag"),am=new WeakMap,lm=new WeakMap,JO=function(s,e,t,i){const n=fs.getBlock(s);if(n&&n.hasOverrides()){const o=n.getOverride("transmission")?.value,r=n.getOverride("transparent")?.value;o!==void 0&&typeof o=="number"&&"transmission"in t&&o!==t.transmission&&(lm.set(this,t.transmission),t.transmission=o),r!==void 0&&typeof r=="boolean"&&r!==t.transparent&&(am.set(this,t.transparent),t.transparent=r)}},eM=function(s,e,t,i){const n=am.get(s);n!==void 0&&(am.delete(s),t.transparent=n);const o=lm.get(s);o!==void 0&&(lm.delete(s),t.transmission=o)},ab=function(s,e,t,i,n,o){const r=this.material;if(!r)return;if(Array.isArray(r)){if(!r.includes(n))return}else if(r!==n)return;this[Ca]===void 0&&(this[Ca]=new WeakSet),this[Ca].add(n);const a=Sw(this);if(!a)return;const{block:l,owner:h}=a,d=l.overrides,u=n,p=l.getDefines(),m=Object.keys(p);if(m.length>0){u.defines||(u.defines={});for(const g of m){const w=p[g];w!==void 0&&(u.defines[g]=w)}}if(d.length===0&&m.length===0)return;let y=m.length>0;u[Cd]||(u[Cd]=[]);const _=u[Cd];for(const g of d){if(g.value===null)continue;const w=u[g.name],b=_.find(v=>v.name===g.name);if(b?b.value=w:_.push({name:g.name,value:w}),!y&&!!w!=!!g.value&&(y=!0),u[g.name]=g.value,g.textureTransform&&g.value instanceof c.Texture){const v=g.value;u[Pd]||(u[Pd]=[]),u[Pd].push({name:g.name,offsetX:v.offset.x,offsetY:v.offset.y,repeatX:v.repeat.x,repeatY:v.repeat.y});const R=g.textureTransform;R.offset&&v.offset.copy(R.offset),R.repeat&&v.repeat.copy(R.repeat)}}y&&(u.needsUpdate=!0),u._forceRefresh=!0},lb=function(s,e,t,i,n,o){if(this[Ca]===void 0||!this[Ca].has(n))return;this[Ca].delete(n);const r=Sw(this);if(!r)return;const{block:a,owner:l}=r,h=a.overrides,d=n,u=d[Cd],p=a.getDefines(),m=Object.keys(p);let y=!1;if(m.length>0&&d.defines){for(const g of m)delete d.defines[g];y=!0}if(h.length===0){y&&(d.needsUpdate=!0,d._forceRefresh=!0);return}if(!u)return;const _=d[Pd];if(_&&_.length>0){for(const g of _){const w=h.find(b=>b.name===g.name);w?.value instanceof c.Texture&&(w.value.offset.set(g.offsetX,g.offsetY),w.value.repeat.set(g.repeatX,g.repeatY))}_.length=0}for(const g of h){const w=u.find(b=>b.name===g.name);w&&(!y&&!!g.value!=!!w.value&&(y=!0),d[g.name]=w.value)}y&&(d.needsUpdate=!0),d._forceRefresh=!0};function tM(s,e){s.type==="Group"?s.children.forEach(t=>{(t.type==="Mesh"||t.type==="SkinnedMesh")&&cb(t,s,e)}):(s.type==="Mesh"||s.type==="SkinnedMesh")&&cb(s,s,e)}function cb(s,e,t){if(!fs.isHooked(s,e)){if(fs.addHook(s,e),s["needle:materialPropertyBlock"]=t,!s.onBeforeRender)s.onBeforeRender=ab;else{const i=s.onBeforeRender;s.onBeforeRender=function(n,o,r,a,l,h){i.call(this,n,o,r,a,l,h),ab.call(this,n,o,r,a,l,h)}}if(!s.onAfterRender)s.onAfterRender=lb;else{const i=s.onAfterRender;s.onAfterRender=function(n,o,r,a,l,h){lb.call(this,n,o,r,a,l,h),i.call(this,n,o,r,a,l,h)}}s.onBeforeRenderListPush=JO,s.onAfterRenderListPush=eM}}const Hh=new Map;function Dg(s,e){if(Hh.has(s))return Hh.get(s);const t=new URL(s,window.location.href),i=iM(t,e);return Hh.set(s,i),i.finally(()=>{Hh.delete(s)}),i}async function iM(s,e){if(!s)return Promise.resolve(null);const t=s.pathname,i=s.toString().toLowerCase().includes("pmrem")||s.searchParams.get("pmrem")!=null,n=t.endsWith(".exr"),o=t.endsWith(".hdr"),r=t.endsWith(".ktx2");let a;if(n)a=new X.EXRLoader;else if(o)a=new X.RGBELoader;else if(r){const{ktx2Loader:u}=re.createLoaders(e);a=u}else a=new c.TextureLoader;const l=s.toString();return await a.loadAsync(l).then(u=>{if(u){const p=t.lastIndexOf("/");u.name=t.substring(p>=0?p+1:0),i&&(u.mapping=c.CubeUVReflectionMapping),a instanceof c.TextureLoader&&(u.colorSpace=c.SRGBColorSpace)}return u}).catch(u=>(console.warn("Failed to load texture from url:",s),null))}var nM=Object.defineProperty,sM=Object.getOwnPropertyDescriptor,Du=(s,e,t,i)=>{for(var n=i>1?void 0:i?sM(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&nM(e,t,n),n};const Xr=x("debugreflectionprobe"),hb=x("noreflectionprobe");let Fo=null;const oM=Symbol("reflectionProbeKey"),eh=class rn extends E{static _probes=new Map;static testBox=new c.Box3;static isUsingReflectionProbe(e){return!!e[oM]}static onEnabled=new ne;static onDisabled=new ne;static get(e,t,i,n){if(!e||e.isObject3D!==!0||hb)return null;const o=rn._probes.get(t);if(o){for(const r of o)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return Xr&&console.log("Found reflection probe",e.name,r.name),r}}return Xr&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;_textureUrlInFlight;set texture(e){if(this._texture!==e){if(typeof e=="string"){Xr&&console.debug(`[ReflectionProbe] Loading reflection probe texture from URL: ${e}`),this._textureUrlInFlight=e;const t=ws(this.sourceId,e);Dg(t,this.context.renderer).then(i=>{this._textureUrlInFlight===e&&i&&(this._textureUrlInFlight=void 0,Xr&&console.debug(`[ReflectionProbe] Successfully loaded reflection probe texture: ${e}`),this.texture=i)});return}this.__didAwake&&(this._textureUrlInFlight=void 0),this._texture=e,Xr&&console.debug("[ReflectionProbe] Set reflection probe texture "+(e?.name||"(removed)")),e&&(e instanceof c.CubeTexture||e.mapping===c.CubeUVReflectionMapping||e.mapping!==c.EquirectangularReflectionMapping&&(e.mapping=c.EquirectangularReflectionMapping),e.colorSpace=c.LinearSRGBColorSpace,e.needsUpdate=!0)}}get texture(){return this._texture}intensity=1;center=new c.Vector3;size=new c.Vector3(1,1,1);__lightmapIntensityScale=!0;isInBox(e){return Fo??=new c.Box3,Fo.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center),this.size),oi([e],void 0,void 0,rn.testBox),rn.testBox.isEmpty()?Fo.containsPoint(e.worldPosition):Fo?.intersectsBox(rn.testBox)}constructor(){super(),rn._probes.has(this.context)||rn._probes.set(this.context,[]),rn._probes.get(this.context)?.push(this)}awake(){this._texture&&(this._texture.mapping!==c.CubeUVReflectionMapping&&(this._texture.mapping=c.EquirectangularReflectionMapping),this._texture.colorSpace=c.LinearSRGBColorSpace,this._texture.needsUpdate=!0)}update(){Xr&&(Fo??=new c.Box3,Fo.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center),this.size),B.DrawWireBox3(Fo,5592320))}onEnable(){rn.onEnabled?.invoke(this)}onDisable(){rn.onDisabled?.invoke(this)}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=rn._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}apply(e){if(hb||!this.enabled||!this.texture)return;const t=ys.get(e);t.setOverride("envMap",this.texture),t.setOverride("envMapRotation",this.gameObject.rotation);let i=this.intensity;this.__lightmapIntensityScale&&t.getOverride("lightMap")&&(i/=Math.PI),t.setOverride("envMapIntensity",i)}unapply(e){const t=ys.get(e);t&&t.getOverride("envMap")?.value===this.texture&&t.removeOveride("envMap")}};Du([f([c.Texture,String])],eh.prototype,"texture",1);Du([f()],eh.prototype,"intensity",2);Du([f(c.Vector3)],eh.prototype,"center",2);Du([f(c.Vector3)],eh.prototype,"size",2);let os=eh;const Jf=x("debugexr");class rM{get name(){return"EXT_texture_exr"}parser;constructor(e){this.parser=e,Jf&&console.log(e)}loadTexture(e){const t=this.name,i=this.parser,o=i.json.textures[e];if(Jf&&console.log("EXT_texture_exr.loadTexture",e,o),!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],a=new X.EXRLoader(i.options.manager);return Jf&&console.log("EXT_texture_exr.loadTexture",r),i.loadTextureImage(e,r.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",s=>{});const Sn=rt,qh="$___Export_Components",aM="NEEDLE_components";class lM{[qo]}class cM{node;nodeIndex;nodeDef;constructor(e,t,i){this.node=e,this.nodeIndex=t,this.nodeDef=i}}class Cw{get name(){return aM}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,o)=>{try{this.serializeUserData(n,o)&&(t.extensionsUsed[this.name]=!0),i(n,o)}finally{this.afterSerializeUserData(n,o)}}}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[qh]=i,!0)}afterSerializeUserData(e,t){if(e.type==="Scene"&&Sn&&console.log("DONE",JSON.stringify(t)),e[qh]===void 0)return;const i=e[qh];delete e[qh],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;Sn&&console.log(e.name,i,e.uuid);const n=new cM(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){Sn&&console.log("AFTER",e);for(const t in this.exportContext){const i=this.exportContext[t],n=i.node,o=i.nodeDef,r=i.nodeIndex,a=n.userData?.components;if(!a||a.length<=0)continue;const l=new lM;o.extensions=o.extensions||{},o.extensions[this.name]=l,this.context.object=n,this.context.nodeId=r,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const d of a){this.context.target=d;const u=dn().writeBuiltinComponentData(d,this.context);u!==null&&h.push(u)}h.length>0&&(l[qo]=h,Sn&&console.log("DID WRITE",n,"nodeIndex",r,h))}}parser;nodeToObjectMap={};gltf=null;beforeRoot(){return Sn&&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];Sn&&console.log("After root",e,this.parser,i);const o=[];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],h=a,d=l.extensions;if(!d)continue;const u=d[this.name];if(!u)continue;Sn&&console.log("NODE",l);const p=this.nodeToObjectMap[h];if(!p){console.error("Could not find object for node index: "+h,l,t);continue}_u(p),o.push(this.createComponents(e,l,p,u))}}}await Promise.all(o);for(const r of t.associations.keys()){const a=t.associations.get(r);if(a?.materials!=null){const l="/materials/"+a.materials;P1(r,l)}}}async createComponents(e,t,i,n){if(!n)return;const o=n[qo];if(o){const r=new Array;Sn&&console.log(i.name,o);for(const a in o){const l=o[a];if(Sn&&console.log("Serialized data",JSON.parse(JSON.stringify(l))),(l?.name==="MeshRenderer"||l?.name==="SkinnedMeshRenderer")&&!l.sharedMaterials){let h=!1;if("mesh"in t){const d=t.mesh;if(typeof d=="number"&&e.parser){const u=e.parser.json.meshes?.[d];u?.primitives&&(l.sharedMaterials=u.primitives.map(p=>"/materials/"+(p.material??0)),h=!0)}}!h&&(Sn||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(ag(this.parser,l).catch(h=>console.error(`Error while resolving references (see console for details)
1000
+ Binary:`,i)}else ke&&console.debug("Could not determine file type from binary data");return"unknown"}const Kf=x("debugstencil");function XO(s,e){return(s&1<<e.layer)!=0}const QO=Symbol("stencils");class eo{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Kf&&console.log(t,eo.stencils),!t)return;const i=eo.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];if(XO(o.layer,e)){Kf&&console.log(o),setTimeout(()=>{gi()&&bu(e.gameObject)&&(fe("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[QO]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=o.value,a.stencilFunc=o.compareFunc,a.stencilZPass=o.passOp,a.stencilFail=o.failOp,a.stencilZFail=o.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=o.event*1e3+o.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[KO];if(i){Kf&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const o of n){const r={...o};r.compareFunc=YO(r.compareFunc),r.passOp=Zf(r.passOp),r.failOp=Zf(r.failOp),r.zFailOp=Zf(r.zFailOp),eo.stencils[this.source]||(eo.stencils[this.source]=[]),eo.stencils[this.source].push(r)}}}return null}}function Zf(s){switch(s){case 0:return c.KeepStencilOp;case 1:return c.ZeroStencilOp;case 2:return c.ReplaceStencilOp;case 3:return c.IncrementStencilOp;case 4:return c.DecrementStencilOp;case 6:return c.IncrementWrapStencilOp;case 7:return c.DecrementWrapStencilOp;case 5:return c.InvertStencilOp}return 0}function YO(s){switch(s){case 1:return c.NeverStencilFunc;case 2:return c.LessStencilFunc;case 3:return c.EqualStencilFunc;case 4:return c.LessEqualStencilFunc;case 5:return c.GreaterStencilFunc;case 6:return c.NotEqualStencilFunc;case 7:return c.GreaterEqualStencilFunc;case 8:return c.AlwaysStencilFunc}return c.NeverStencilFunc}const KO="NEEDLE_render_objects";class ZO{objectToBlock=new WeakMap;meshToOwners=new WeakMap;meshToOriginalCallbacks=new WeakMap;getBlock(e){return this.objectToBlock.get(e)}setBlock(e,t){this.objectToBlock.set(e,t)}deleteBlock(e){this.objectToBlock.delete(e)}isHooked(e,t){return this.meshToOwners.get(e)?.has(t)??!1}addHook(e,t){let i=this.meshToOwners.get(e);i||(i=new Set,this.meshToOwners.set(e,i)),i.add(t)}removeHook(e,t){const i=this.meshToOwners.get(e);i&&(i.delete(t),i.size===0&&this.meshToOwners.delete(e))}getOriginalCallbacks(e){return this.meshToOriginalCallbacks.get(e)}setOriginalCallbacks(e,t){this.meshToOriginalCallbacks.set(e,t)}}const fs=new ZO;class ys{_overrides=[];_defines={};_object=null;get object(){return this._object}constructor(e=null){this._object=e}static get(e){let t=fs.getBlock(e);return t||(t=new ys(e),fs.setBlock(e,t),tM(e,t)),t}static hasOverrides(e){const t=fs.getBlock(e);return t?t.hasOverrides():!1}dispose(){this._object&&fs.deleteBlock(this._object),this._overrides=[],this._object=null}setOverride(e,t,i){const n=this._overrides.find(o=>o.name===e);n?(n.value=t,n.textureTransform=i):this._overrides.push({name:e,value:t,textureTransform:i})}getOverride(e){return this._overrides.find(t=>t.name===e)}removeOveride(e){const t=this._overrides.findIndex(i=>i.name===e);t>=0&&this._overrides.splice(t,1)}clearAllOverrides(){this._overrides=[]}get overrides(){return this._overrides}hasOverrides(){return this._overrides.length>0}setDefine(e,t){this._defines[e]=t}clearDefine(e){this._defines[e]=void 0}getDefines(){return this._defines}getCacheKey(){const e=[],t=Object.keys(this._defines).sort();for(const i of t){const n=this._defines[i];n!==void 0&&e.push(`d:${i}=${n}`)}for(const i of this._overrides){if(i.value===null)continue;let n="";if(i.value instanceof c.Texture){if(n=i.value.uuid||"texture",i.textureTransform){const o=i.textureTransform;o.offset&&(n+=`;to:${o.offset.x},${o.offset.y}`),o.repeat&&(n+=`;tr:${o.repeat.x},${o.repeat.y}`)}}else if(Array.isArray(i.value))n=i.value.join(",");else if(i.value&&typeof i.value=="object"&&"r"in i.value){const o=i.value;n=`${o.r},${o.g},${o.b},${o.a!==void 0?o.a:""}`}else if(i.value&&typeof i.value=="object"&&"x"in i.value){const o=i.value;n=`${o.x},${o.y}${o.z!==void 0?`,${o.z}`:""}${o.w!==void 0?`,${o.w}`:""}`}else n=String(i.value);e.push(`${i.name}=${n}`)}return e.join(";")}}const Cd=Symbol("originalValues"),Pd=Symbol("savedTextureTransforms");function Sw(s){let e=fs.getBlock(s);if(e)return{block:e,owner:s};if(s.parent&&s.parent.type==="Group"&&(e=fs.getBlock(s.parent),e))return{block:e,owner:s.parent}}const Ca=Symbol("beforeRenderingFlag"),am=new WeakMap,lm=new WeakMap,JO=function(s,e,t,i){const n=fs.getBlock(s);if(n&&n.hasOverrides()){const o=n.getOverride("transmission")?.value,r=n.getOverride("transparent")?.value;o!==void 0&&typeof o=="number"&&"transmission"in t&&o!==t.transmission&&(lm.set(this,t.transmission),t.transmission=o),r!==void 0&&typeof r=="boolean"&&r!==t.transparent&&(am.set(this,t.transparent),t.transparent=r)}},eM=function(s,e,t,i){const n=am.get(s);n!==void 0&&(am.delete(s),t.transparent=n);const o=lm.get(s);o!==void 0&&(lm.delete(s),t.transmission=o)},ab=function(s,e,t,i,n,o){const r=this.material;if(!r)return;if(Array.isArray(r)){if(!r.includes(n))return}else if(r!==n)return;this[Ca]===void 0&&(this[Ca]=new WeakSet),this[Ca].add(n);const a=Sw(this);if(!a)return;const{block:l,owner:h}=a,d=l.overrides,u=n,p=l.getDefines(),m=Object.keys(p);if(m.length>0){u.defines||(u.defines={});for(const g of m){const w=p[g];w!==void 0&&(u.defines[g]=w)}}if(d.length===0&&m.length===0)return;let y=m.length>0;u[Cd]||(u[Cd]=[]);const _=u[Cd];for(const g of d){if(g.value===null)continue;const w=u[g.name],b=_.find(v=>v.name===g.name);if(b?b.value=w:_.push({name:g.name,value:w}),!y&&!!w!=!!g.value&&(y=!0),u[g.name]=g.value,g.textureTransform&&g.value instanceof c.Texture){const v=g.value;u[Pd]||(u[Pd]=[]),u[Pd].push({name:g.name,offsetX:v.offset.x,offsetY:v.offset.y,repeatX:v.repeat.x,repeatY:v.repeat.y});const R=g.textureTransform;R.offset&&v.offset.copy(R.offset),R.repeat&&v.repeat.copy(R.repeat)}}y&&(u.needsUpdate=!0),u._forceRefresh=!0},lb=function(s,e,t,i,n,o){if(this[Ca]===void 0||!this[Ca].has(n))return;this[Ca].delete(n);const r=Sw(this);if(!r)return;const{block:a,owner:l}=r,h=a.overrides,d=n,u=d[Cd],p=a.getDefines(),m=Object.keys(p);let y=!1;if(m.length>0&&d.defines){for(const g of m)delete d.defines[g];y=!0}if(h.length===0){y&&(d.needsUpdate=!0,d._forceRefresh=!0);return}if(!u)return;const _=d[Pd];if(_&&_.length>0){for(const g of _){const w=h.find(b=>b.name===g.name);w?.value instanceof c.Texture&&(w.value.offset.set(g.offsetX,g.offsetY),w.value.repeat.set(g.repeatX,g.repeatY))}_.length=0}for(const g of h){const w=u.find(b=>b.name===g.name);w&&(!y&&!!g.value!=!!w.value&&(y=!0),d[g.name]=w.value)}y&&(d.needsUpdate=!0),d._forceRefresh=!0};function tM(s,e){s.type==="Group"?s.children.forEach(t=>{(t.type==="Mesh"||t.type==="SkinnedMesh")&&cb(t,s,e)}):(s.type==="Mesh"||s.type==="SkinnedMesh")&&cb(s,s,e)}function cb(s,e,t){if(!fs.isHooked(s,e)){if(fs.addHook(s,e),s["needle:materialPropertyBlock"]=t,!s.onBeforeRender)s.onBeforeRender=ab;else{const i=s.onBeforeRender;s.onBeforeRender=function(n,o,r,a,l,h){i.call(this,n,o,r,a,l,h),ab.call(this,n,o,r,a,l,h)}}if(!s.onAfterRender)s.onAfterRender=lb;else{const i=s.onAfterRender;s.onAfterRender=function(n,o,r,a,l,h){lb.call(this,n,o,r,a,l,h),i.call(this,n,o,r,a,l,h)}}s.onBeforeRenderListPush=JO,s.onAfterRenderListPush=eM}}const Hh=new Map;function Dg(s,e){if(Hh.has(s))return Hh.get(s);const t=new URL(s,window.location.href),i=iM(t,e);return Hh.set(s,i),i.finally(()=>{Hh.delete(s)}),i}async function iM(s,e){if(!s)return Promise.resolve(null);const t=s.pathname,i=s.toString().toLowerCase().includes("pmrem")||s.searchParams.get("pmrem")!=null,n=t.endsWith(".exr"),o=t.endsWith(".hdr"),r=t.endsWith(".ktx2");let a;if(n)a=new X.EXRLoader;else if(o)a=new X.RGBELoader;else if(r){const{ktx2Loader:u}=re.createLoaders(e);a=u}else a=new c.TextureLoader;const l=s.toString();return await a.loadAsync(l).then(u=>{if(u){const p=t.lastIndexOf("/");u.name=t.substring(p>=0?p+1:0),i?u.mapping=c.CubeUVReflectionMapping:u.mapping=c.EquirectangularRefractionMapping,a instanceof c.TextureLoader&&(u.colorSpace=c.SRGBColorSpace)}return u}).catch(u=>(console.warn("Failed to load texture from url:",s),null))}var nM=Object.defineProperty,sM=Object.getOwnPropertyDescriptor,Du=(s,e,t,i)=>{for(var n=i>1?void 0:i?sM(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&nM(e,t,n),n};const Xr=x("debugreflectionprobe"),hb=x("noreflectionprobe");let Fo=null;const oM=Symbol("reflectionProbeKey"),eh=class rn extends E{static _probes=new Map;static testBox=new c.Box3;static isUsingReflectionProbe(e){return!!e[oM]}static onEnabled=new ne;static onDisabled=new ne;static get(e,t,i,n){if(!e||e.isObject3D!==!0||hb)return null;const o=rn._probes.get(t);if(o){for(const r of o)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return Xr&&console.log("Found reflection probe",e.name,r.name),r}}return Xr&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;_textureUrlInFlight;set texture(e){if(this._texture!==e){if(typeof e=="string"){Xr&&console.debug(`[ReflectionProbe] Loading reflection probe texture from URL: ${e}`),this._textureUrlInFlight=e;const t=ws(this.sourceId,e);Dg(t,this.context.renderer).then(i=>{this._textureUrlInFlight===e&&i&&(this._textureUrlInFlight=void 0,Xr&&console.debug(`[ReflectionProbe] Successfully loaded reflection probe texture: ${e}`),this.texture=i)});return}this.__didAwake&&(this._textureUrlInFlight=void 0),this._texture=e,Xr&&console.debug("[ReflectionProbe] Set reflection probe texture "+(e?.name||"(removed)")),e&&(e instanceof c.CubeTexture||e.mapping===c.CubeUVReflectionMapping||e.mapping!==c.EquirectangularReflectionMapping&&(e.mapping=c.EquirectangularReflectionMapping),e.colorSpace=c.LinearSRGBColorSpace,e.needsUpdate=!0)}}get texture(){return this._texture}intensity=1;center=new c.Vector3;size=new c.Vector3(1,1,1);__lightmapIntensityScale=!0;isInBox(e){return Fo??=new c.Box3,Fo.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center),this.size),oi([e],void 0,void 0,rn.testBox),rn.testBox.isEmpty()?Fo.containsPoint(e.worldPosition):Fo?.intersectsBox(rn.testBox)}constructor(){super(),rn._probes.has(this.context)||rn._probes.set(this.context,[]),rn._probes.get(this.context)?.push(this)}awake(){this._texture&&(this._texture.mapping!==c.CubeUVReflectionMapping&&(this._texture.mapping=c.EquirectangularReflectionMapping),this._texture.colorSpace=c.LinearSRGBColorSpace,this._texture.needsUpdate=!0)}update(){Xr&&(Fo??=new c.Box3,Fo.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center),this.size),B.DrawWireBox3(Fo,5592320))}onEnable(){rn.onEnabled?.invoke(this)}onDisable(){rn.onDisabled?.invoke(this)}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=rn._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}apply(e){if(hb||!this.enabled||!this.texture)return;const t=ys.get(e);t.setOverride("envMap",this.texture),t.setOverride("envMapRotation",this.gameObject.rotation);let i=this.intensity;this.__lightmapIntensityScale&&t.getOverride("lightMap")&&(i/=Math.PI),t.setOverride("envMapIntensity",i)}unapply(e){const t=ys.get(e);t&&t.getOverride("envMap")?.value===this.texture&&t.removeOveride("envMap")}};Du([f([c.Texture,String])],eh.prototype,"texture",1);Du([f()],eh.prototype,"intensity",2);Du([f(c.Vector3)],eh.prototype,"center",2);Du([f(c.Vector3)],eh.prototype,"size",2);let os=eh;const Jf=x("debugexr");class rM{get name(){return"EXT_texture_exr"}parser;constructor(e){this.parser=e,Jf&&console.log(e)}loadTexture(e){const t=this.name,i=this.parser,o=i.json.textures[e];if(Jf&&console.log("EXT_texture_exr.loadTexture",e,o),!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],a=new X.EXRLoader(i.options.manager);return Jf&&console.log("EXT_texture_exr.loadTexture",r),i.loadTextureImage(e,r.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",s=>{});const Sn=rt,qh="$___Export_Components",aM="NEEDLE_components";class lM{[qo]}class cM{node;nodeIndex;nodeDef;constructor(e,t,i){this.node=e,this.nodeIndex=t,this.nodeDef=i}}class Cw{get name(){return aM}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,o)=>{try{this.serializeUserData(n,o)&&(t.extensionsUsed[this.name]=!0),i(n,o)}finally{this.afterSerializeUserData(n,o)}}}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[qh]=i,!0)}afterSerializeUserData(e,t){if(e.type==="Scene"&&Sn&&console.log("DONE",JSON.stringify(t)),e[qh]===void 0)return;const i=e[qh];delete e[qh],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;Sn&&console.log(e.name,i,e.uuid);const n=new cM(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){Sn&&console.log("AFTER",e);for(const t in this.exportContext){const i=this.exportContext[t],n=i.node,o=i.nodeDef,r=i.nodeIndex,a=n.userData?.components;if(!a||a.length<=0)continue;const l=new lM;o.extensions=o.extensions||{},o.extensions[this.name]=l,this.context.object=n,this.context.nodeId=r,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const d of a){this.context.target=d;const u=dn().writeBuiltinComponentData(d,this.context);u!==null&&h.push(u)}h.length>0&&(l[qo]=h,Sn&&console.log("DID WRITE",n,"nodeIndex",r,h))}}parser;nodeToObjectMap={};gltf=null;beforeRoot(){return Sn&&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];Sn&&console.log("After root",e,this.parser,i);const o=[];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],h=a,d=l.extensions;if(!d)continue;const u=d[this.name];if(!u)continue;Sn&&console.log("NODE",l);const p=this.nodeToObjectMap[h];if(!p){console.error("Could not find object for node index: "+h,l,t);continue}_u(p),o.push(this.createComponents(e,l,p,u))}}}await Promise.all(o);for(const r of t.associations.keys()){const a=t.associations.get(r);if(a?.materials!=null){const l="/materials/"+a.materials;P1(r,l)}}}async createComponents(e,t,i,n){if(!n)return;const o=n[qo];if(o){const r=new Array;Sn&&console.log(i.name,o);for(const a in o){const l=o[a];if(Sn&&console.log("Serialized data",JSON.parse(JSON.stringify(l))),(l?.name==="MeshRenderer"||l?.name==="SkinnedMeshRenderer")&&!l.sharedMaterials){let h=!1;if("mesh"in t){const d=t.mesh;if(typeof d=="number"&&e.parser){const u=e.parser.json.meshes?.[d];u?.primitives&&(l.sharedMaterials=u.primitives.map(p=>"/materials/"+(p.material??0)),h=!0)}}!h&&(Sn||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(ag(this.parser,l).catch(h=>console.error(`Error while resolving references (see console for details)
1001
1001
  `,h,i,l))),i.userData=i.userData||{},i.userData[qo]=i.userData[qo]||[],i.userData[qo].push(l)}await Promise.all(r).catch(a=>{console.error("Error while loading components",a)})}}}const db="NEEDLE_gameobject_data";class hM{get name(){return db}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 o=n.extensions[db];if(o){const r=this.findAndApplyExtensionData(i,o);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 ub="NEEDLE_lighting_settings",ra=x("debugenvlight");class dM{get name(){return ub}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[ub];if(i){ra&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const o=e.scene.children[0];n=S.addComponent(o,Jd,{},{callAwake:!1})}else{const o=new c.Object3D;o.name="LightSettings "+this.sourceId,e.scene.add(o),n=S.addComponent(o,Jd,{},{callAwake:!1})}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new c.Color().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(o=>new c.Color().fromArray(o))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}ce.registerCallback(le.ContextCreated,s=>{const e=s.context,t=S.findObjectOfType(Jd,e);t?.sourceId&&(t.enabled=!0)});class Jd extends E{ambientMode=Sa.Skybox;ambientLight;ambientTrilight;ambientIntensity=1;environmentReflectionSource=Hd.Skybox;_hasReflection=!1;_ambientLightObj;_hemisphereLightObj;awake(){if(this.sourceId){const t=this.environmentReflectionSource===Hd.Skybox?Rn.Skybox:Rn.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),ra&&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*L.lerp(0,1.33,t)}onEnable(){if(ra&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==Sa.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new c.AmbientLight(this.ambientLight,this.ambientIntensity*e),ra&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===Sa.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],i=this.calculateIntensityFactor(t);this._hemisphereLightObj=new c.HemisphereLight(t,e,this.ambientIntensity*i),this.gameObject.add(this._hemisphereLightObj),ra&&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(){ra&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}exports.MaterialX=void 0;(s=>{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(),o=t.trimStart().startsWith("<"),r=o?t:await fetch(t).then(h=>h.text()).catch(console.error);if(!r)return console.warn("Failed to load MaterialX file from url",t),null;let a;if(i?.url||!o){const h=(i?.url||t).split("/");h.pop(),a=h.join("/")}const l=new c.TextureLoader;return n.Experimental_API.createMaterialXMaterial(r,i?.materialNameOrIndex??0,{getTexture:async h=>(!h.startsWith("http")&&!h.startsWith("data:")&&!h.startsWith("blob:")&&!h.startsWith("file:")&&a&&(h=a+"/"+h),l.loadAsync(h).catch(d=>{console.warn(`Failed to load texture for MaterialX material ${h}`,d)}))},{cacheKey:t})}s.loadFromUrl=e})(exports.MaterialX||(exports.MaterialX={}));class uM extends c.Loader{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}),exports.MaterialX.loadFromUrl(e,{}).then(o=>{o?t(this.onLoaded(o)):n?.(new Error("Failed to load MaterialX material from url: "+e))})}onLoaded(e){return bo.createPrimitive("ShaderBall",{material:e})}}class fM{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 t=await T.MaterialX.load();try{this.mtlxLoader=new t.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(i){console.error(i)}}}loadMaterial(e){return this.mtlxLoader?this.mtlxLoader.loadMaterial(e):null}}var Pw=(s=>(s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_VEC2=35664]="FLOAT_VEC2",s[s.FLOAT_VEC3=35665]="FLOAT_VEC3",s[s.FLOAT_VEC4=35666]="FLOAT_VEC4",s[s.INT_VEC2=35667]="INT_VEC2",s[s.INT_VEC3=35668]="INT_VEC3",s[s.INT_VEC4=35669]="INT_VEC4",s[s.BOOL=35670]="BOOL",s[s.BOOL_VEC2=35671]="BOOL_VEC2",s[s.BOOL_VEC3=35672]="BOOL_VEC3",s[s.BOOL_VEC4=35673]="BOOL_VEC4",s[s.FLOAT_MAT2=35674]="FLOAT_MAT2",s[s.FLOAT_MAT3=35675]="FLOAT_MAT3",s[s.FLOAT_MAT4=35676]="FLOAT_MAT4",s[s.SAMPLER_2D=35678]="SAMPLER_2D",s[s.SAMPLER_3D=35680]="SAMPLER_3D",s[s.SAMPLER_CUBE=35681]="SAMPLER_CUBE",s[s.UNKNOWN=0]="UNKNOWN",s))(Pw||{});const On=x("debugcustomshader"),Qr="NEEDLE_techniques_webgl";class pM{objectToWorldMatrix=new c.Matrix4;worldToObjectMatrix=new c.Matrix4;objectToWorld=new Array;worldToObject=new Array;updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),Gd(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),Gd(this.worldToObjectMatrix,this.worldToObject)}}class be extends c.RawShaderMaterial{identifier;onBeforeRenderSceneCallback=this.onBeforeRenderScene.bind(this);clone(){const e=super.clone();return Ow(e),e}constructor(e,...t){super(...t),this.identifier=e,On&&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 c.Matrix4;static _viewProjectionValues=[];_viewProjectionName="hlslcc_mtx4x4unity_MatrixVP";static viewMatrix=new c.Matrix4;static _viewMatrixValues=[];_viewMatrixName="hlslcc_mtx4x4unity_MatrixV";static _worldSpaceCameraPosName="_WorldSpaceCameraPos";static _worldSpaceCameraPos=new c.Vector3;static _mainLightColor=new c.Vector4;static _mainLightPosition=new c.Vector3;static _lightData=new c.Vector4;_rendererData=new pM;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,o,r){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(i,o)}onUpdateUniforms(e,t){const i=U.Current;if(e&&(be.viewProjection&&this.uniforms[this._viewProjectionName]&&(be.viewProjection.copy(e.projectionMatrix).multiply(e.matrixWorldInverse),Gd(be.viewProjection,be._viewProjectionValues)),be.viewMatrix&&this.uniforms[this._viewMatrixName]&&(be.viewMatrix.copy(e.matrixWorldInverse),Gd(be.viewMatrix,be._viewMatrixValues)),this.uniforms[be._worldSpaceCameraPosName]&&be._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=Y(n.gameObject,be._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},be._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:be._mainLightColor};const l=n.intensity;be._lightData.z=l,this.uniforms.unity_LightData={value:be._lightData}}if(e&&(be.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=be._viewProjectionValues),be.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=be._viewMatrixValues),this.uniforms[be._worldSpaceCameraPosName]&&(this.uniforms[be._worldSpaceCameraPosName]={value:be._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 o=this.depthTextureUniform;o&&(o.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 mM{get name(){return Qr}parser;identifier;constructor(e,t){this.parser=e,this.identifier=t}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return On&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[Qr])return On&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;On&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,t);const i=t.extensions[Qr].technique;if(i<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const n=this.parser.json.extensions[Qr];if(!n)return On?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;On&&console.log(n);const o=n.techniques[i];return o?new Promise(async(r,a)=>{const l=await oP(n,o.program),h=l?.fragmentShader,d=l?.vertexShader;if(!h||!d)return a();On&&console.log("loadMaterial",t,l);const u={},p=o.uniforms;(d.includes("_Time")||h.includes("_Time"))&&(u._Time={value:new c.Vector4(0,0,0,0)}),(d.includes("_SinTime")||h.includes("_SinTime"))&&(u._SinTime={value:new c.Vector4(0,0,0,0)}),(d.includes("_CosTime")||h.includes("_CosTime"))&&(u._CosTime={value:new c.Vector4(0,0,0,0)}),(d.includes("unity_DeltaTime")||h.includes("unity_DeltaTime"))&&(u.unity_DeltaTime={value:new c.Vector4(0,0,0,0)});for(const w in p){const b=w;switch(b){case"_TimeParameters":const v=new c.Vector4;u[b]={value:v};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":u[b]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":u[b]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":u[b]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":u[b]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":u[b]={value:null};break}}let m=!1;if(t.extensions&&t.extensions[Qr]){const w=t.extensions[Qr];if(w.technique===i){On&&console.log(t.name,"Material Properties",w);for(const b in w.values){const v=w.values[b];if(typeof v=="string"){if(v.startsWith("/textures/")){const R=v.substring(10),O=Number.parseInt(R);if(O>=0){const M=await this.parser.getDependency("texture",O);M instanceof c.Texture&&(M.colorSpace=c.LinearSRGBColorSpace,M.needsUpdate=!0),u[b]={value:M};continue}}if(b==="alphaMode"){v==="BLEND"&&(m=!0);continue}}if(Array.isArray(v)&&v.length===4){u[b]={value:new c.Vector4(v[0],v[1],v[2],v[3])};continue}u[b]={value:v}}}}const y=new be(this.identifier,{name:t.name??"",uniforms:u,vertexShader:d,fragmentShader:h,lights:!1});switch(y.glslVersion=c.GLSL3,y.vertexShader=y.vertexShader.replace("#version 300 es",""),y.fragmentShader=y.fragmentShader.replace("#version 300 es",""),u._Cull?.value){case 0:y.side=c.DoubleSide;break;case 1:y.side=c.BackSide;break;case 2:y.side=c.FrontSide;break;default:y.side=c.FrontSide;break}switch(u._ZTest?.value){case 3:y.depthTest=!0,y.depthFunc=c.EqualDepth;break;case 6:y.depthTest=!0,y.depthFunc=c.NotEqualDepth;break;case 2:y.depthTest=!0,y.depthFunc=c.LessDepth;break;case 4:y.depthTest=!0,y.depthFunc=c.LessEqualDepth;break;case 5:y.depthTest=!0,y.depthFunc=c.GreaterDepth;break;case 7:y.depthTest=!0,y.depthFunc=c.GreaterEqualDepth;break;case 8:y.depthTest=!1,y.depthFunc=c.AlwaysDepth;break}y.transparent=m,m&&(y.depthWrite=!1),nP(u),y.onUpdateUniforms();for(const w in p){const b=w,v=p[w].type;u[b]?.value===void 0&&(v===Pw.SAMPLER_2D?(u[b]={value:tP},console.warn("Missing/unassigned texture, fallback to white: "+b)):b==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+b,p[w]))}On&&console.log(y.uuid,u),Ow(y),r(y)}):null}}function Ow(s){if(s.uniforms){On&&console.log("Uniforms:",s.uniforms);for(const t in s.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break;case"_map":e("map",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>s.uniforms[i].value,set:n=>{s.uniforms[i].value=n,s.needsUpdate=!0}})}}const gM=x("debugextensions");let eu;const yM=Promise.resolve().then(()=>require("./vendor-CipoooTV.umd.cjs")).then(s=>s.index$2).then(async s=>(eu=s.GLTFAnimationPointerExtension,eu)).catch(s=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three-animationpointer for full KHR_animation support",s)}),mr=new Array;function _M(s){mr.includes(s)||mr.push(s)}function bM(s){const e=mr.indexOf(s);e>=0&&mr.splice(e,1)}function Ig(s){if(s instanceof X.GLTFLoader){const e=new Cw;return s.register(t=>(e.parser=t,e)),e}return null}class vM{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 tu(s,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"),s.register(o=>new hM(o)),s.register(o=>new M1(o)),s.register(o=>new K1(o,e.lightmaps,i)),s.register(o=>new dM(o,i,e)),s.register(o=>new mM(o,i)),s.register(o=>new eo(o,i)),s.register(o=>new re.NEEDLE_progressive(o)),s.register(o=>new rM(o)),s.register(o=>new wu(o)),s.register(o=>new fM(e,s,t,o)),t0()&&s.register(o=>new xa(o)),await yM.catch(o=>{}),s.register(o=>{if(eu){const r=new eu(o);return r.setAnimationPointerResolver.bind(r)(new vM),r}else return(gM||A())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const o of mr)o.onImport&&o.onImport(s,t,e)}function Lg(s,e){for(const t of mr)t.onExport&&t.onExport(s,e)}function Mw(s,e,t){for(const i of mr)i.onLoaded&&i.onLoaded(s,e,t)}const kt=x("debuginstancing");class gr{static instance=new gr;static getStartInstanceCount=e=>4;objs=[];setup(e,t,i,n,o,r=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,o);if(a){n===null&&(n=[]),n.push(a);const l=a.object.material;Array.isArray(l)?l.forEach(u=>re.NEEDLE_progressive.assignTextureLOD(u,0)):re.NEEDLE_progressive.assignTextureLOD(l,0);const h=a.object,d=h.geometry;re.NEEDLE_progressive.assignMeshLOD(h,0).then(u=>{u&&d!=u&&a.setGeometry(u)})}else if(r<=0&&t.type!=="Mesh"){const l=r+1;for(const h of t.children)n=this.setup(e,h,i,n,o,l)}return r===0&&o.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 kt&&console.error("Something is wrong with instance setup",e,i.rend.enableInstancing,n),null;if(!i.rend.enableInstancing[n])return null}const o=e,r=o.material;for(const u of this.objs){if(!u.canAdd(o.geometry,r))continue;return u.addInstance(o)}let a=gr.getStartInstanceCount(e);(!a||a<0)&&(a=4);let l=e.name;l?.length||(l=sv());const h=new wM(l,o.geometry,r,a,t);return this.objs.push(h),h.addInstance(o)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),n=(o,r)=>{const a=t(o,r);return(e[bc]||i.equals(a)===!1)&&(i.copy(a),e[bc]=!0),a};e.matrixWorld.multiplyMatrices=n}}class hr{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[r0]=t,this.meshInformation=Xo(e.geometry),hr.all.push(this)}updateMeshInformation(){const e=Xo(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()||kt)&&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=hr.all.indexOf(this);t>=0&&hr.all.splice(t,1)}}}class wM{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(),kt&&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 c.Matrix4;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,o){this.name=e,this.geometry=t,this.material=i,this._context=o,this._maxInstanceCount=Math.max(2,n),kt&&(this._debugMaterial=fb());const r=this.tryEstimateVertexCountSize(this._maxInstanceCount,[t],n);this._maxVertexCount=r.vertexCount,this._maxIndexCount=r.indexCount,this._batchedMesh=new c.BatchedMesh(this._maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this._batchedMesh.name=this.getBatchedMeshName(),this._batchedMesh[zl]=!0,this._batchedMesh.visible=!0,this._context.scene.add(this._batchedMesh),i instanceof c.RawShaderMaterial&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),o.pre_render_callbacks.push(this.onBeforeRender),o.post_render_callbacks.push(this.onAfterRender),kt&&console.log(`Instanced renderer (${this.name}) created with ${this._maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}dispose(){kt&&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 hr(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()})
1002
1002
  `,i),A()){Uc("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),kt&&console.debug("[Instancing] UPDATE GEOMETRY at "+t,this._batchedMesh._geometryCount,e.name,Xo(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[zl]===!0&&(kt==="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(){kt==="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 i=Xo(e),n=i.vertexCount,o=i.indexCount;return this._currentVertexCount+n>this._maxVertexCount||this._currentIndexCount+o>this._maxIndexCount}_growId=0;grow(e){const t=++this._growId,o=this.count>=this._maxInstanceCount?Math.ceil(this._maxInstanceCount*2):this._maxInstanceCount,r=this.tryEstimateVertexCountSize(o,[e]),a=1.25,l=Math.max(this._maxVertexCount,Math.ceil(r.vertexCount*a)),h=Math.max(this._maxIndexCount,Math.ceil(r.indexCount*a));if(kt){const p=Xo(e);console.warn(`[Instancing] Growing Buffer
1003
1003
  Mesh: "${this.name}${e.name?.length?"/"+e.name:""}" (${p.vertexCount.toLocaleString()} vertices, ${p.indexCount.toLocaleString()} indices)
@@ -1651,4 +1651,4 @@ Error:`,r),null}}updateColliderCollisionGroups(e){const t=e[Mt],i=e.membership;l
1651
1651
  justify-content: center;
1652
1652
  gap: .5rem;
1653
1653
  }
1654
- `),this.#n.innerHTML=this.#e.innerHTML,this.#n.style.cssText="display: flex; align-items: center; justify-content: center;",this.#e.innerHTML=this.#n.outerHTML,this.#t.innerHTML=this.#e.outerHTML,this.#t.prepend(this.#s),qd(em,{element:this.#t}),this.#o?.disconnect(),this.#o??=new MutationObserver(()=>this.#c()),this.#o.observe(this.#e,{attributes:!0}),Mp&&console.log("Needle Button updated",this)}#c(){this.#e&&(this.#e.style.display==="none"?this.style.display="none":this.style.display==="none"&&(this.style.display=""))}#a=e=>{Mp&&console.log("Needle Button clicked",{defaultPrevented:e.defaultPrevented,hasButton:!!this.#e}),!e.defaultPrevented&&this.#e&&this.#e.click()}}typeof window<"u"&&!window.customElements.get(ev)&&window.customElements.define(ev,Fx);const jl=x("debugavatar");class Wy{root;head;leftHand;rigthHand;get isValid(){return this.head!==null&&this.head!==void 0}constructor(e,t,i,n){this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,this.root?.traverse(o=>o.layers.set(2))}}class Ux{avatarRegistryUrl=null;async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const o=new mn;i=S.instantiate(ka(t,e.scene),o)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(jl&&console.log("[Custom Avatar] valid config",t,jl?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,jl?n:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(jl&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let o=null;if(n.ok){const a=await n.blob();a&&(o=await a.arrayBuffer())}return o?(await dn().parseSync(e,o,null,0))?.scene??null:null}const i=new X.GLTFLoader;return gg(i,e),new Promise((n,o)=>{const r=this.avatarRegistryUrl+"/"+t;i.load(r,async a=>{await dn().createBuiltinComponents(e,r,a,null,void 0),n(a.scene)},a=>{jl&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const o=this.findAvatarPart(i,["left","hand"]),r=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new c.Vector3;new c.Box3().setFromObject(n).getSize(l);const h=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+h+" meters! Should be < 0.3m"),h>.3&&n.scale.multiplyScalar(1/h*.3)}return new Wy(t,n,o,r)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const o of t){if(!n)break;i.indexOf(o)===-1&&(n=!1)}if(n)return e;if(e.children)for(const o of e.children){const r=this.findAvatarPart(o,t);if(r)return r}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}class zx{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}class Nx{}const oA=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:de,ActionCollection:qw,ActionModel:Zt,AlignmentConstraint:qc,Animation:Tt,AnimationCurve:hh,AnimationExtension:Bu,AnimationTrackHandler:Rc,Animator:lt,AnimatorController:Ni,Antialiasing:uh,Attractor:ol,AudioExtension:Er,AudioListener:ds,AudioSource:bi,AudioTrackHandler:ps,Avatar:po,AvatarBlink_Simple:Pr,AvatarEyeLook_Rotation:Pg,AvatarLoader:Ux,AvatarMarker:Oe,AvatarModel:Wy,Avatar_Brain_LookAt:Pc,Avatar_MouthShapes:Kc,Avatar_MustacheShake:Sg,Avatar_POI:cr,AxesHelper:Ga,BaseUIComponent:$i,BasicIKConstraint:Mg,BehaviorExtension:ny,BehaviorModel:wt,BloomEffect:Zu,BoxCollider:Tu,BoxGizmo:Dr,BoxHelperComponent:yt,Button:Ds,CallInfo:hs,Camera:ni,CameraTargetReachedEvent:Cc,Canvas:Fa,CanvasGroup:mo,CapsuleCollider:bs,ChangeMaterialOnClick:Xg,ChangeTransformOnClick:Rr,CharacterController:Or,CharacterControllerInput:Cs,ChromaticAberration:fh,ClickThrough:gf,ColorAdjustments:Eo,ColorBySpeedModule:sl,ColorOverLifetimeModule:Qu,ContactShadows:Zc,ControlTrackHandler:cf,CursorFollow:$r,CustomBranding:Ar,Deletable:Tg,DeleteBox:ao,DepthOfField:_n,DeviceFlag:Au,DocumentExtension:zx,DragControls:Zo,DropListener:Os,Duplicatable:Ug,EffectWrapper:Ec,EmissionModule:Rs,EmphasizeOnClick:Qa,EnvironmentScene:pf,EventList:ne,EventListEvent:Mu,EventSystem:Gt,EventTrigger:Lu,FieldWithDefault:kw,FixedJoint:yy,Fog:el,GltfExport:Wg,GltfExportBox:Vg,Gradient:Lr,Graphic:ah,GraphicRaycaster:ku,GridHelper:tl,GridLayoutGroup:cy,GroundProjectedEnv:qn,GroupActionModel:Jo,HideOnStart:Ii,HingeJoint:ch,HorizontalLayoutGroup:ly,get HoverAnimation(){return exports.HoverAnimation},Image:dl,InheritVelocityModule:xy,InputField:jy,InstanceHandle:hr,InstancingHandler:gr,Interactable:Rg,Keyframe:si,LODGroup:Hu,LODModel:il,Light:Ct,LimitVelocityOverLifetimeModule:nt,LogStats:Eg,LookAt:By,LookAtConstraint:Cr,MainModule:It,MarkerTrackHandler:lf,MaskableGraphic:lh,MeshCollider:xo,MeshRenderer:th,MinMaxCurve:H,MinMaxGradient:jr,NeedleMenu:Qn,NestedGltf:nl,Networking:vy,NoiseModule:me,ObjectRaycaster:Vi,OffsetConstraint:Ir,OpenURL:ul,OrbitControls:ue,Outline:Ja,Padding:Tr,ParticleBurst:ou,ParticleSubEmitter:Sy,ParticleSystem:kc,ParticleSystemRenderer:Qi,PhysicsExtension:sy,PixelationEffect:ph,PlayAnimationOnClick:Oc,PlayAudioOnClick:fo,PlayableDirector:br,PlayerColor:Ua,PointerEventData:Qc,PostProcessingHandler:ky,PreliminaryAction:Ya,PreliminaryTrigger:nh,RawImage:uf,Rect:Zw,RectTransform:pn,ReflectionProbe:os,RegisteredAnimationInfo:so,RemoteSkybox:ef,Renderer:Ht,RendererLightmap:jg,Rigidbody:Ve,RotationBySpeedModule:Xi,RotationOverLifetimeModule:yn,SceneSwitcher:We,ScreenCapture:Ro,ScreenSpaceAmbientOcclusion:Ts,ScreenSpaceAmbientOcclusionN8:bn,ScrollFollow:Is,SeeThrough:As,SetActiveOnClick:Qg,ShadowCatcher:_h,ShapeModule:wy,SharpeningEffect:gh,SignalAsset:af,SignalReceiver:Sh,SignalReceiverEvent:xh,SignalTrackHandler:Tc,Size:Kw,SizeBySpeedModule:hi,SizeOverLifetimeModule:Br,SkinnedMeshRenderer:Bg,SmoothFollow:nf,SpatialGrabRaycaster:pr,SpatialHtml:Ph,SpatialTrigger:sf,SpatialTriggerReceiver:Wn,SpectatorCamera:of,SphereCollider:Ha,SplineContainer:Nr,SplineData:Hn,SplineWalker:Ki,Sprite:Ms,SpriteData:Oa,SpriteRenderer:li,SpriteSheet:Ba,SubEmitterSystem:ru,SyncedCamera:Ry,SyncedRoom:vn,SyncedTransform:fn,TapGestureTrigger:Kg,TeleportTarget:Vu,TestRunner:Ty,TestSimulateUserData:Ay,Text:Dt,TextBuilder:ry,TextExtension:Wu,TextureSheetAnimationModule:Lt,TiltShiftEffect:Kn,ToneMappingEffect:go,TrailModule:De,TransformData:Te,TransformGizmo:Vr,TriggerBuilder:Rt,TriggerModel:lo,UIRaycastUtils:bg,UIRootComponent:oh,USDZExporter:$n,USDZText:ga,USDZUIExtension:dy,UsageMarker:Jc,VariantAction:qg,VelocityOverLifetimeModule:Be,VerticalLayoutGroup:ay,VideoPlayer:tt,get ViewBox(){return exports.ViewBox},Vignette:zr,VisibilityAction:sh,Voip:wo,Volume:al,VolumeParameter:z,VolumeProfile:Yu,WebARCameraBackground:Mh,WebARSessionRoot:Fi,WebXR:$u,WebXRImageTracking:kh,WebXRImageTrackingModel:js,WebXRPlaneTracking:Bs,WebXRTrackedImage:za,XRControllerFollow:Ls,XRControllerModel:vs,XRControllerMovement:wi,XRFlag:Li,XRRig:bf,XRState:Wt,__Ignore:Nx},Symbol.toStringTag,{value:"Module"})),Dc=x("debugmissingcamera");ce.registerCallback(le.MissingCamera,s=>{Dc&&console.warn("Creating missing camera");const e=s.context.scene,t=new c.PerspectiveCamera;t.name="Default Fallback Camera",e.add(t);const i=new ni;if(i.sourceId=s.files?.[0]?.src??"unknown",i.fieldOfView=35,s.context.domElement.getAttribute("transparent")!=null)i.clearFlags=lr.Uninitialized;else if(s.context.domElement.getAttribute("background-image")?.length||s.context.lightmaps.tryGetSkybox(i.sourceId))i.clearFlags=lr.Skybox;else{if(i.clearFlags=lr.SolidColor,!s.context.domElement.getAttribute("background-color")){let a="#efefef";typeof window!==void 0&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(a="#1f1f1f"),e.background=new c.Color(a)}if(!e.environment){const a=new c.PMREMGenerator$1(s.context.renderer),l=new pf("neutral");e.environment=a.fromScene(l,.025).texture}}const o=nr(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,s.context.domElement?.cameraControls!=!1&&Vx(s.context,o),o});ce.registerCallback(le.ContextCreated,s=>{if(!s.context.mainCamera){Dc&&console.log("Will not auto-fit because a default camera exists");return}if(s.context.domElement?.cameraControls==!0){if(fv(s.context.mainCamera)?.isCameraController==!0){Dc&&console.log("Will not auto-fit because a camera controller exists");return}Vx(s.context)}});function Vx(s,e){e=e??s.mainCameraComponent;const t=e?.gameObject;if(Dc&&console.log("Creating default camera controls",e?.name),t){const i=Vc(t,ue);i.sourceId=e?.sourceId??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!="0"&&n?.toLowerCase()!="false";const o=Number.parseFloat(n||".5");i.autoRotateSpeed=isNaN(o)?.5:o,Dc&&console.log("Auto-rotate",i.autoRotate,"speed:",i.autoRotateSpeed);const r=s.domElement.getAttribute("auto-fit");i.autoFit=r!=="0"&&r?.toLowerCase()!="false",i.autoTarget=!0}else console.warn("Missing camera object, can not add orbit controls")}ce.registerCallback(le.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&s.files)for(const t of s.files)S.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof Tt&&n.playAutomatically||n instanceof lt||n instanceof br&&n.playOnAwake===!0)return!0;if(n instanceof Tt)return n.playAutomatically=!0,!0;if(n instanceof br)return n.playOnAwake=!0,!0}},!0)!==!0&&Gn.autoplayAnimations(t.file)});exports.SplineUtils=void 0;(s=>{function e(t,i=!1,n=.75){const o=new Nr,r=1-L.clamp(n,0,1);return t.forEach((a,l)=>{const h=new c.Vector3;l<t.length-1?h.subVectors(t[l+1],a).normalize().multiplyScalar(r):i&&t.length>1&&h.subVectors(t[0],a).normalize().multiplyScalar(r);const d=new Hn;d.position.copy(a),d.tangentIn.copy(h),d.tangentOut.copy(h),o.addKnot(d)}),o.closed=i,o}s.createFromPoints=e})(exports.SplineUtils||(exports.SplineUtils={}));class rA extends ae.WorkerBase{constructor(){super(new Worker(new URL("/generateMeshBVH.worker-DiCnZlf3.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:_a&&_a.tagName.toUpperCase()==="SCRIPT"&&_a.src||new URL("needle-engine.bundle-glRd_Shc.umd.cjs",document.baseURI).href),{type:"module"})),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((n,o)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`[GenerateMeshBVHWorker] ${h.message||"Unknown error. Please check the server console. If you're using vite try adding 'three-mesh-bvh' to 'optimizeDeps.exclude' in your vite.config.js"}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:p}=d,m=ae.MeshBVH.deserialize(u,t,{setIndex:!1}),y=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=p,u.index)if(t.index)t.index.array=u.index;else{const _=new c.BufferAttribute(u.index,1,!1);t.setIndex(_)}y.setBoundingBox&&(t.boundingBox=m.getBoundingBox(new c.Box3)),i.onProgress&&i.onProgress(d.progress),n(m),e.onmessage=null}else i.onProgress&&i.onProgress(d.progress)};const r=t.index?t.index.array:null,a=t.attributes.position.array,l=[a];r&&l.push(r),e.postMessage({index:r,position:a,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},l.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const aA=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:rA},Symbol.toStringTag,{value:"Module"}));exports.$componentName=Dv;exports.$physicsKey=_C;exports.ActionBuilder=de;exports.ActionCollection=qw;exports.ActionModel=Zt;exports.Addressables=L0;exports.AlignmentConstraint=qc;exports.AmbientMode=Sa;exports.Animation=Tt;exports.AnimationCurve=hh;exports.AnimationExtension=Bu;exports.AnimationTrackHandler=Rc;exports.AnimationUtils=Gn;exports.Animator=lt;exports.AnimatorConditionMode=Zs;exports.AnimatorController=Ni;exports.AnimatorControllerParameterType=yg;exports.AnimatorStateInfo=Nl;exports.Antialiasing=uh;exports.Application=un;exports.AssetDatabase=Jv;exports.AssetReference=Z;exports.Attractor=ol;exports.AudioExtension=Er;exports.AudioListener=ds;exports.AudioSource=bi;exports.AudioTrackHandler=ps;exports.Avatar=po;exports.AvatarBlink_Simple=Pr;exports.AvatarEyeLook_Rotation=Pg;exports.AvatarLoader=Ux;exports.AvatarMarker=Oe;exports.AvatarModel=Wy;exports.Avatar_Brain_LookAt=Pc;exports.Avatar_MouthShapes=Kc;exports.Avatar_MustacheShake=Sg;exports.Avatar_POI=cr;exports.Axes=pa;exports.AxesHelper=Ga;exports.BUILD_TIME=mc;exports.BaseUIComponent=$i;exports.BasicIKConstraint=Mg;exports.BehaviorExtension=ny;exports.BehaviorModel=wt;exports.BloomEffect=Zu;exports.BoxCollider=Tu;exports.BoxGizmo=Dr;exports.BoxHelperComponent=yt;exports.Button=Ds;exports.ButtonsFactory=Bi;exports.CallDirection=uw;exports.CallInfo=hs;exports.Camera=ni;exports.CameraTargetReachedEvent=Cc;exports.Canvas=Fa;exports.CanvasGroup=mo;exports.CapsuleCollider=bs;exports.ChangeMaterialOnClick=Xg;exports.ChangeTransformOnClick=Rr;exports.CharacterController=Or;exports.CharacterControllerInput=Cs;exports.ChromaticAberration=fh;exports.CircularBuffer=yi;exports.ClearFlags=lr;exports.ClickThrough=gf;exports.ClipExtrapolation=Mn;exports.Collider=qi;exports.Collision=Lv;exports.CollisionDetectionMode=Ou;exports.ColorAdjustments=Eo;exports.ColorBySpeedModule=sl;exports.ColorOverLifetimeModule=Qu;exports.Component=AP;exports.Component$1=E;exports.ComponentLifecycleEvents=gu;exports.Components=oA;exports.ConnectionEvents=qv;exports.ContactPoint=Iv;exports.ContactShadows=Zc;exports.Context=U;exports.ContextArgs=yP;exports.ContextEvent=le;exports.ContextRegistry=ce;exports.ControlTrackHandler=cf;exports.CursorFollow=$r;exports.CustomBranding=Ar;exports.CustomShader=be;exports.DefaultReflectionMode=Hd;exports.Deletable=Tg;exports.DeleteBox=ao;exports.DepthOfField=_n;exports.DeviceFlag=Au;exports.DocumentExtension=zx;exports.DragControls=Zo;exports.DragMode=Ag;exports.DropListener=Os;exports.Duplicatable=Ug;exports.EffectWrapper=Ec;exports.EmissionModule=Rs;exports.EmphasizeOnClick=Qa;exports.EngineLoadingView=Ac;exports.EnvironmentScene=pf;exports.EventList=ne;exports.EventListEvent=Mu;exports.EventSystem=Gt;exports.EventTrigger=Lu;exports.FieldWithDefault=kw;exports.FileReference=rr;exports.FileReferenceSerializer=B0;exports.FileSpawnModel=qO;exports.File_Event=bw;exports.FixedJoint=yy;exports.Fog=el;exports.FrameEvent=ge;exports.GENERATOR=Ra;exports.GameObject=S;exports.Gizmos=B;exports.GltfExport=Wg;exports.GltfExportBox=Vg;exports.Gradient=Lr;exports.Graphic=ah;exports.GraphicRaycaster=ku;exports.Graphics=ho;exports.GridHelper=tl;exports.GridLayoutGroup=cy;exports.GroundProjectedEnv=qn;exports.GroupActionModel=Jo;exports.HideFlags=du;exports.HideOnStart=Ii;exports.HingeJoint=ch;exports.HorizontalLayoutGroup=ly;exports.HostData=_1;exports.Image=dl;exports.ImageReference=or;exports.ImageReferenceSerializer=j0;exports.InheritVelocityModule=xy;exports.Input=Nv;exports.InputEventQueue=ei;exports.InputEvents=Pe;exports.InputField=jy;exports.InstanceHandle=hr;exports.InstancingHandler=gr;exports.InstancingUtil=zi;exports.InstantiateEvent=c0;exports.InstantiateIdProvider=vt;exports.InstantiateOptions=mn;exports.Interactable=Rg;exports.JoinedRoomResponse=LC;exports.KeyEventArgs=CC;exports.Keyframe=si;exports.LODGroup=Hu;exports.LODModel=il;exports.LeftRoomResponse=jC;exports.Light=Ct;exports.LightData=V0;exports.LimitVelocityOverLifetimeModule=nt;exports.LoadingElementOptions=GT;exports.LogStats=Eg;exports.LogType=mi;exports.LookAt=By;exports.LookAtConstraint=Cr;exports.MODULES=T;exports.MainModule=It;exports.MarkerTrackHandler=lf;exports.MarkerType=Dy;exports.MaskableGraphic=lh;exports.MaterialPropertyBlock=ys;exports.Mathf=L;exports.MeshCollider=xo;exports.MeshRenderer=th;exports.MinMaxCurve=H;exports.MinMaxGradient=jr;exports.NEEDLE_ENGINE_FEATURE_FLAGS=tg;exports.NEKeyboardEvent=Bl;exports.NEPointerEvent=ss;exports.NeedleButtonElement=Fx;exports.NeedleEngineWebComponent=$y;exports.NeedleMenu=Qn;exports.NeedlePatchesKey=fd;exports.NeedleXRController=Hm;exports.NeedleXRSession=q;exports.NeedleXRSync=Yv;exports.NeedleXRUtils=Zv;exports.NestedGltf=nl;exports.NetworkConnection=Qv;exports.NetworkedStreamEvents=Bn;exports.NetworkedStreams=Yc;exports.Networking=vy;exports.NewInstanceModel=d0;exports.NoiseModule=me;exports.ObjectRaycaster=Vi;exports.ObjectUtils=bo;exports.OffsetConstraint=Ir;exports.OneEuroFilter=dd;exports.OneEuroFilterXYZ=Im;exports.OpenURL=ul;exports.OrbitControls=ue;exports.Outline=Ja;exports.OwnershipEvent=Xv;exports.OwnershipModel=Ym;exports.PUBLIC_KEY=no;exports.Padding=Tr;exports.ParticleBurst=ou;exports.ParticleSubEmitter=Sy;exports.ParticleSystem=kc;exports.ParticleSystemBaseBehaviour=ko;exports.ParticleSystemRenderer=Qi;exports.ParticleSystemShapeType=su;exports.PeerHandle=us;exports.PeerNetworking=Hv;exports.Physics=La;exports.PhysicsExtension=sy;exports.PhysicsMaterialCombine=st;exports.PixelationEffect=ph;exports.PlayAnimationOnClick=Oc;exports.PlayAudioOnClick=fo;exports.PlayableDirector=br;exports.PlayerColor=Ua;exports.PlayerState=Ui;exports.PlayerStateEvent=Yw;exports.PlayerSync=ty;exports.PlayerView=U0;exports.PlayerViewManager=z0;exports.PointerEventData=Qc;exports.PointerType=pu;exports.PostProcessingEffect=Xe;exports.PostProcessingEffectOrder=et;exports.PostProcessingHandler=ky;exports.PreliminaryAction=Ya;exports.PreliminaryTrigger=nh;exports.PrimitiveType=Na;exports.Progress=oe;exports.PromiseAllWithErrors=Am;exports.PromiseErrorResult=Rp;exports.RGBAColor=te;exports.RapierPhysics=Ma;exports.RawImage=uf;exports.RaycastOptions=vo;exports.Rect=Zw;exports.RectTransform=pn;exports.ReflectionProbe=os;exports.RegisteredAnimationInfo=so;exports.RemoteSkybox=ef;exports.RenderTexture=jn;exports.RenderTextureSerializer=cw;exports.Renderer=Ht;exports.RendererData=N0;exports.RendererLightmap=jg;exports.Rigidbody=Ve;exports.RigidbodyConstraints=Ne;exports.RoomEvents=K;exports.RotationBySpeedModule=Xi;exports.RotationOverLifetimeModule=yn;exports.SceneLightSettings=Jd;exports.SceneSwitcher=We;exports.ScreenCapture=Ro;exports.ScreenSpaceAmbientOcclusion=Ts;exports.ScreenSpaceAmbientOcclusionN8=bn;exports.ScrollFollow=Is;exports.SeeThrough=As;exports.SendQueue=an;exports.SerializationContext=lg;exports.SetActiveOnClick=Qg;exports.ShadowCatcher=_h;exports.ShapeModule=wy;exports.ShapeOverlapResult=jv;exports.SharpeningEffect=gh;exports.SignalAsset=af;exports.SignalReceiver=Sh;exports.SignalReceiverEvent=xh;exports.SignalTrackHandler=Tc;exports.Size=Kw;exports.SizeBySpeedModule=hi;exports.SizeOverLifetimeModule=Br;exports.SkinnedMeshRenderer=Bg;exports.SmoothFollow=nf;exports.SpatialGrabRaycaster=pr;exports.SpatialHtml=Ph;exports.SpatialTrigger=sf;exports.SpatialTriggerReceiver=Wn;exports.SpectatorCamera=of;exports.SphereCollider=Ha;exports.SphereIntersection=Jm;exports.SplineContainer=Nr;exports.SplineData=Hn;exports.SplineWalker=Ki;exports.Sprite=Ms;exports.SpriteData=Oa;exports.SpriteRenderer=li;exports.SpriteSheet=Ba;exports.StateMachineBehaviour=FP;exports.StreamEndedEvent=wg;exports.StreamReceivedEvent=dw;exports.SubEmitterSystem=ru;exports.SyncedCamera=Ry;exports.SyncedRoom=vn;exports.SyncedTransform=fn;exports.TapGestureTrigger=Kg;exports.TeleportTarget=Vu;exports.TestRunner=Ty;exports.TestSimulateUserData=Ay;exports.Text=Dt;exports.TextBuilder=ry;exports.TextExtension=Wu;exports.TextureSheetAnimationModule=Lt;exports.TiltShiftEffect=Kn;exports.Time=$0;exports.ToneMappingEffect=go;exports.TrackHandler=hl;exports.TrackType=ui;exports.TrailModule=De;exports.TransformData=Te;exports.TransformGizmo=Vr;exports.TriggerBuilder=Rt;exports.TriggerModel=lo;exports.TypeStore=P;exports.UIRaycastUtils=bg;exports.UIRootComponent=oh;exports.USDDocument=Gg;exports.USDObject=qe;exports.USDWriter=Fw;exports.USDZExporter=Uw;exports.USDZExporter$1=$n;exports.USDZText=ga;exports.USDZUIExtension=dy;exports.UriSerializer=hw;exports.UsageMarker=Jc;exports.UserJoinedOrLeftRoomModel=BC;exports.VERSION=ti;exports.VariantAction=qg;exports.VelocityOverLifetimeModule=Be;exports.VerticalLayoutGroup=ay;exports.VideoPlayer=tt;exports.ViewDevice=gs;exports.Vignette=zr;exports.VisibilityAction=sh;exports.Voip=wo;exports.Volume=al;exports.VolumeParameter=z;exports.VolumeProfile=Yu;exports.WaitForFrames=Y1;exports.WaitForPromise=F0;exports.WaitForSeconds=dg;exports.Watch=ms;exports.WebARCameraBackground=Mh;exports.WebARSessionRoot=Fi;exports.WebXR=$u;exports.WebXRButtonFactory=co;exports.WebXRImageTracking=kh;exports.WebXRImageTrackingModel=js;exports.WebXRPlaneTracking=Bs;exports.WebXRTrackedImage=za;exports.XRControllerFollow=Ls;exports.XRControllerModel=vs;exports.XRControllerMovement=wi;exports.XRFlag=Li;exports.XRRig=bf;exports.XRState=Wt;exports.XRStateFlag=Dn;exports.__Ignore=Nx;exports.__internalNotifyObjectDestroyed=l1;exports.activeInHierarchyFieldName=Ln;exports.addAttributeChangeCallback=Rm;exports.addComponent=ln;exports.addCustomExtensionPlugin=_M;exports.addNewComponent=nr;exports.addPatch=uu;exports.apply=_u;exports.applyHMRChanges=TP;exports.applyPrototypeExtensions=S0;exports.beginListenDestroy=h0;exports.beginListenInstantiate=f0;exports.binaryIdentifierCasts=qm;exports.build_scene_functions=gP;exports.builtinComponentKeyName=qo;exports.calculateProgress01=Vy;exports.clearMessages=yS;exports.colorSerializer=tO;exports.compareAssociation=y0;exports.componentSerializer=xd;exports.copyTexture=vv;exports.createMotion=sw;exports.debugNet=Qt;exports.debugOwner=Fl;exports.decompressGpuTexture=$w;exports.deepClone=Lc;exports.delay=_s;exports.delayForFrames=jc;exports.deserializeObject=Wd;exports.destroy=_i;exports.destroyComponentInstance=O0;exports.determineMimeTypeFromExtension=vw;exports.disposeObjectResources=ve;exports.disposeStream=Fn;exports.editorGuidKeyName=Jl;exports.enableSpatialConsole=ba;exports.euler=nO;exports.eventListSerializer=aO;exports.exportAsGLTF=iA;exports.findByGuid=hg;exports.findObjectOfType=$a;exports.findObjectsOfType=k0;exports.findResourceUsers=eg;exports.fitCamera=ow;exports.fitObjectIntoVolume=xv;exports.foreachComponent=fr;exports.foreachComponentEnumerator=vu;exports.forward=LS;exports.generateQRCode=H0;exports.generateSeed=u0;exports.getBoundingBox=oi;exports.getCameraController=fv;exports.getComponent=xr;exports.getComponentInChildren=Wc;exports.getComponentInParent=vc;exports.getComponents=$c;exports.getComponentsInChildren=Va;exports.getComponentsInParent=yu;exports.getFormattedDate=Iw;exports.getIconElement=bt;exports.getIconTexture=Jp;exports.getLoader=dn;exports.getOrAddComponent=Vc;exports.getParam=x;exports.getParentHierarchyPath=FS;exports.getPath=Qx;exports.getPeerOptions=TC;exports.getPeerjsInstance=Gv;exports.getResourceUserCount=h1;exports.getTempColor=gv;exports.getTempQuaternion=Jt;exports.getTempVector=F;exports.getUrlParams=Ic;exports.getVisibleInCustomShadowRendering=wv;exports.getWorldDirection=yv;exports.getWorldEuler=Bm;exports.getWorldPosition=Y;exports.getWorldQuaternion=pe;exports.getWorldRotation=hu;exports.getWorldScale=je;exports.hasCommercialLicense=Vn;exports.hasIndieLicense=Hc;exports.hasPointerEventComponent=Yd;exports.hasProLicense=Nn;exports.hideDebugConsole=Ov;exports.imageToCanvas=Ww;exports.instantiate=uo;exports.invokeLoadedImportPluginHooks=Mw;exports.invokeXRSessionEnd=zv;exports.invokeXRSessionStart=Uv;exports.isActiveInHierarchy=E0;exports.isActiveSelf=Wa;exports.isAndroidDevice=tS;exports.isAnimationAction=bv;exports.isComponent=$m;exports.isDebugMode=Gx;exports.isDesktop=Kx;exports.isDestroyed=ur;exports.isDevEnvironment=A;exports.isDisposed=a1;exports.isExporting=eA;exports.isGLTFModel=Av;exports.isHostedOnGlitch=tv;exports.isHotReloadEnabled=sm;exports.isHotReloading=EP;exports.isIPad=Jx;exports.isIconElement=q0;exports.isLocalNetwork=gi;exports.isMacOS=nS;exports.isMobileDevice=Zx;exports.isMozillaXR=iS;exports.isQuest=rS;exports.isResourceTrackingEnabled=t0;exports.isSafari=oS;exports.isUsingInstancing=bu;exports.isiOS=sS;exports.isiPad=eS;exports.loadAsset=UT;exports.loadPMREM=Dg;exports.loadSync=Ny;exports.logHierarchy=jd;exports.lookAtInverse=MS;exports.lookAtObject=Bc;exports.lookAtScreenPoint=kS;exports.makeId=qx;exports.makeIdFromRandomWords=sv;exports.makeNameSafe=vi;exports.markAsInstancedRendered=R0;exports.microphonePermissionsGranted=aS;exports.nameof=Wx;exports.nameofFactory=iv;exports.objectSerializer=lw;exports.offXRSessionEnd=SC;exports.offXRSessionStart=xC;exports.onAfterRender=wP;exports.onBeforeRender=vP;exports.onClear=_P;exports.onDestroy=bP;exports.onInitialized=pg;exports.onStart=Cu;exports.onUpdate=Y0;exports.onXRSessionEnd=Gm;exports.onXRSessionStart=fu;exports.parseSync=Dx;exports.placeOnSurface=Sv;exports.postprocessFBXMaterials=zm;exports.prefix=QP;exports.pushState=nv;exports.randomNumber=Xx;exports.registerBinaryType=Xm;exports.registerComponent=Su;exports.registerComponentExtension=Ig;exports.registerCustomEffectType=Yi;exports.registerExportExtensions=Lg;exports.registerExtensions=tu;exports.registerHotReloadType=ew;exports.registerLoader=Vm;exports.registerPrefabProvider=m0;exports.registerPrototypeExtensions=C0;exports.registerType=og;exports.relativePathPrefix=rv;exports.removeAttributeChangeCallback=Tm;exports.removeComponent=cg;exports.removeCustomImportExtensionType=bM;exports.removePatch=vC;exports.resolveUrl=ws;exports.sanitizeString=ov;exports.saveImage=Ex;exports.screenshot=xT;exports.screenshot2=zy;exports.sendDestroyed=ng;exports.serializable=f;exports.serializeObject=b0;exports.serializeable=$e;exports.setActive=nc;exports.setAllowBalloonMessages=hv;exports.setAllowOverlayMessages=fS;exports.setAutoFitEnabled=Id;exports.setCameraController=Ap;exports.setDestroyed=A0;exports.setDevEnvironment=HS;exports.setDisposable=n0;exports.setDontDestroy=na;exports.setOrAddParamsToUrl=Ep;exports.setParam=Hx;exports.setParamWithoutReload=pc;exports.setPeerOptions=AC;exports.setResourceTrackingEnabled=r1;exports.setState=km;exports.setVisibleInCustomShadowRendering=Um;exports.setWorldEuler=Fm;exports.setWorldPosition=at;exports.setWorldPositionXYZ=dr;exports.setWorldQuaternion=hn;exports.setWorldQuaternionXYZW=jm;exports.setWorldRotation=_v;exports.setWorldRotationXYZ=Fc;exports.setWorldScale=Ea;exports.showBalloonError=Uc;exports.showBalloonMessage=xe;exports.showBalloonWarning=fe;exports.showDebugConsole=Nm;exports.slerp=OS;exports.syncDestroy=zc;exports.syncField=ey;exports.syncInstantiate=sg;exports.textureToCanvas=US;exports.toSourceId=av;exports.tryCastBinary=$v;exports.tryDetermineMimetypeFromBinary=xw;exports.tryDetermineMimetypeFromURL=ww;exports.tryFindObject=ka;exports.tryGetGuid=Wv;exports.unregisterHotReloadType=tw;exports.unwatchWrite=Em;exports.useForAutoFit=pv;exports.validate=xt;exports.watchWrite=cu;
1654
+ `),this.#n.innerHTML=this.#e.innerHTML,this.#n.style.cssText="display: flex; align-items: center; justify-content: center;",this.#e.innerHTML=this.#n.outerHTML,this.#t.innerHTML=this.#e.outerHTML,this.#t.prepend(this.#s),qd(em,{element:this.#t}),this.#o?.disconnect(),this.#o??=new MutationObserver(()=>this.#c()),this.#o.observe(this.#e,{attributes:!0}),Mp&&console.log("Needle Button updated",this)}#c(){this.#e&&(this.#e.style.display==="none"?this.style.display="none":this.style.display==="none"&&(this.style.display=""))}#a=e=>{Mp&&console.log("Needle Button clicked",{defaultPrevented:e.defaultPrevented,hasButton:!!this.#e}),!e.defaultPrevented&&this.#e&&this.#e.click()}}typeof window<"u"&&!window.customElements.get(ev)&&window.customElements.define(ev,Fx);const jl=x("debugavatar");class Wy{root;head;leftHand;rigthHand;get isValid(){return this.head!==null&&this.head!==void 0}constructor(e,t,i,n){this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,this.root?.traverse(o=>o.layers.set(2))}}class Ux{avatarRegistryUrl=null;async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const o=new mn;i=S.instantiate(ka(t,e.scene),o)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(jl&&console.log("[Custom Avatar] valid config",t,jl?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,jl?n:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(jl&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let o=null;if(n.ok){const a=await n.blob();a&&(o=await a.arrayBuffer())}return o?(await dn().parseSync(e,o,null,0))?.scene??null:null}const i=new X.GLTFLoader;return gg(i,e),new Promise((n,o)=>{const r=this.avatarRegistryUrl+"/"+t;i.load(r,async a=>{await dn().createBuiltinComponents(e,r,a,null,void 0),n(a.scene)},a=>{jl&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const o=this.findAvatarPart(i,["left","hand"]),r=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new c.Vector3;new c.Box3().setFromObject(n).getSize(l);const h=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+h+" meters! Should be < 0.3m"),h>.3&&n.scale.multiplyScalar(1/h*.3)}return new Wy(t,n,o,r)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const o of t){if(!n)break;i.indexOf(o)===-1&&(n=!1)}if(n)return e;if(e.children)for(const o of e.children){const r=this.findAvatarPart(o,t);if(r)return r}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}class zx{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}class Nx{}const oA=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:de,ActionCollection:qw,ActionModel:Zt,AlignmentConstraint:qc,Animation:Tt,AnimationCurve:hh,AnimationExtension:Bu,AnimationTrackHandler:Rc,Animator:lt,AnimatorController:Ni,Antialiasing:uh,Attractor:ol,AudioExtension:Er,AudioListener:ds,AudioSource:bi,AudioTrackHandler:ps,Avatar:po,AvatarBlink_Simple:Pr,AvatarEyeLook_Rotation:Pg,AvatarLoader:Ux,AvatarMarker:Oe,AvatarModel:Wy,Avatar_Brain_LookAt:Pc,Avatar_MouthShapes:Kc,Avatar_MustacheShake:Sg,Avatar_POI:cr,AxesHelper:Ga,BaseUIComponent:$i,BasicIKConstraint:Mg,BehaviorExtension:ny,BehaviorModel:wt,BloomEffect:Zu,BoxCollider:Tu,BoxGizmo:Dr,BoxHelperComponent:yt,Button:Ds,CallInfo:hs,Camera:ni,CameraTargetReachedEvent:Cc,Canvas:Fa,CanvasGroup:mo,CapsuleCollider:bs,ChangeMaterialOnClick:Xg,ChangeTransformOnClick:Rr,CharacterController:Or,CharacterControllerInput:Cs,ChromaticAberration:fh,ClickThrough:gf,ColorAdjustments:Eo,ColorBySpeedModule:sl,ColorOverLifetimeModule:Qu,ContactShadows:Zc,ControlTrackHandler:cf,CursorFollow:$r,CustomBranding:Ar,Deletable:Tg,DeleteBox:ao,DepthOfField:_n,DeviceFlag:Au,DocumentExtension:zx,DragControls:Zo,DropListener:Os,Duplicatable:Ug,EffectWrapper:Ec,EmissionModule:Rs,EmphasizeOnClick:Qa,EnvironmentScene:pf,EventList:ne,EventListEvent:Mu,EventSystem:Gt,EventTrigger:Lu,FieldWithDefault:kw,FixedJoint:yy,Fog:el,GltfExport:Wg,GltfExportBox:Vg,Gradient:Lr,Graphic:ah,GraphicRaycaster:ku,GridHelper:tl,GridLayoutGroup:cy,GroundProjectedEnv:qn,GroupActionModel:Jo,HideOnStart:Ii,HingeJoint:ch,HorizontalLayoutGroup:ly,get HoverAnimation(){return exports.HoverAnimation},Image:dl,InheritVelocityModule:xy,InputField:jy,InstanceHandle:hr,InstancingHandler:gr,Interactable:Rg,Keyframe:si,LODGroup:Hu,LODModel:il,Light:Ct,LimitVelocityOverLifetimeModule:nt,LogStats:Eg,LookAt:By,LookAtConstraint:Cr,MainModule:It,MarkerTrackHandler:lf,MaskableGraphic:lh,MeshCollider:xo,MeshRenderer:th,MinMaxCurve:H,MinMaxGradient:jr,NeedleMenu:Qn,NestedGltf:nl,Networking:vy,NoiseModule:me,ObjectRaycaster:Vi,OffsetConstraint:Ir,OpenURL:ul,OrbitControls:ue,Outline:Ja,Padding:Tr,ParticleBurst:ou,ParticleSubEmitter:Sy,ParticleSystem:kc,ParticleSystemRenderer:Qi,PhysicsExtension:sy,PixelationEffect:ph,PlayAnimationOnClick:Oc,PlayAudioOnClick:fo,PlayableDirector:br,PlayerColor:Ua,PointerEventData:Qc,PostProcessingHandler:ky,PreliminaryAction:Ya,PreliminaryTrigger:nh,RawImage:uf,Rect:Zw,RectTransform:pn,ReflectionProbe:os,RegisteredAnimationInfo:so,RemoteSkybox:ef,Renderer:Ht,RendererLightmap:jg,Rigidbody:Ve,RotationBySpeedModule:Xi,RotationOverLifetimeModule:yn,SceneSwitcher:We,ScreenCapture:Ro,ScreenSpaceAmbientOcclusion:Ts,ScreenSpaceAmbientOcclusionN8:bn,ScrollFollow:Is,SeeThrough:As,SetActiveOnClick:Qg,ShadowCatcher:_h,ShapeModule:wy,SharpeningEffect:gh,SignalAsset:af,SignalReceiver:Sh,SignalReceiverEvent:xh,SignalTrackHandler:Tc,Size:Kw,SizeBySpeedModule:hi,SizeOverLifetimeModule:Br,SkinnedMeshRenderer:Bg,SmoothFollow:nf,SpatialGrabRaycaster:pr,SpatialHtml:Ph,SpatialTrigger:sf,SpatialTriggerReceiver:Wn,SpectatorCamera:of,SphereCollider:Ha,SplineContainer:Nr,SplineData:Hn,SplineWalker:Ki,Sprite:Ms,SpriteData:Oa,SpriteRenderer:li,SpriteSheet:Ba,SubEmitterSystem:ru,SyncedCamera:Ry,SyncedRoom:vn,SyncedTransform:fn,TapGestureTrigger:Kg,TeleportTarget:Vu,TestRunner:Ty,TestSimulateUserData:Ay,Text:Dt,TextBuilder:ry,TextExtension:Wu,TextureSheetAnimationModule:Lt,TiltShiftEffect:Kn,ToneMappingEffect:go,TrailModule:De,TransformData:Te,TransformGizmo:Vr,TriggerBuilder:Rt,TriggerModel:lo,UIRaycastUtils:bg,UIRootComponent:oh,USDZExporter:$n,USDZText:ga,USDZUIExtension:dy,UsageMarker:Jc,VariantAction:qg,VelocityOverLifetimeModule:Be,VerticalLayoutGroup:ay,VideoPlayer:tt,get ViewBox(){return exports.ViewBox},Vignette:zr,VisibilityAction:sh,Voip:wo,Volume:al,VolumeParameter:z,VolumeProfile:Yu,WebARCameraBackground:Mh,WebARSessionRoot:Fi,WebXR:$u,WebXRImageTracking:kh,WebXRImageTrackingModel:js,WebXRPlaneTracking:Bs,WebXRTrackedImage:za,XRControllerFollow:Ls,XRControllerModel:vs,XRControllerMovement:wi,XRFlag:Li,XRRig:bf,XRState:Wt,__Ignore:Nx},Symbol.toStringTag,{value:"Module"})),Dc=x("debugmissingcamera");ce.registerCallback(le.MissingCamera,s=>{Dc&&console.warn("Creating missing camera");const e=s.context.scene,t=new c.PerspectiveCamera;t.name="Default Fallback Camera",e.add(t);const i=new ni;if(i.sourceId=s.files?.[0]?.src??"unknown",i.fieldOfView=35,s.context.domElement.getAttribute("transparent")!=null)i.clearFlags=lr.Uninitialized;else if(s.context.domElement.getAttribute("background-image")?.length||s.context.lightmaps.tryGetSkybox(i.sourceId))i.clearFlags=lr.Skybox;else{if(i.clearFlags=lr.SolidColor,!s.context.domElement.getAttribute("background-color")){let a="#efefef";typeof window!==void 0&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(a="#1f1f1f"),e.background=new c.Color(a)}if(!e.environment){const a=new c.PMREMGenerator$1(s.context.renderer),l=new pf("neutral");e.environment=a.fromScene(l,.025).texture}}const o=nr(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,s.context.domElement?.cameraControls!=!1&&Vx(s.context,o),o});ce.registerCallback(le.ContextCreated,s=>{if(!s.context.mainCamera){Dc&&console.log("Will not auto-fit because a default camera exists");return}if(s.context.domElement?.cameraControls==!0){if(fv(s.context.mainCamera)?.isCameraController==!0){Dc&&console.log("Will not auto-fit because a camera controller exists");return}Vx(s.context)}});function Vx(s,e){e=e??s.mainCameraComponent;const t=e?.gameObject;if(Dc&&console.log("Creating default camera controls",e?.name),t){const i=Vc(t,ue);i.sourceId=e?.sourceId??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!="0"&&n?.toLowerCase()!="false";const o=Number.parseFloat(n||".5");i.autoRotateSpeed=isNaN(o)?.5:o,Dc&&console.log("Auto-rotate",i.autoRotate,"speed:",i.autoRotateSpeed);const r=s.domElement.getAttribute("auto-fit");i.autoFit=r!=="0"&&r?.toLowerCase()!="false",i.autoTarget=!0}else console.warn("Missing camera object, can not add orbit controls")}ce.registerCallback(le.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&s.files)for(const t of s.files)S.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof Tt&&n.playAutomatically||n instanceof lt||n instanceof br&&n.playOnAwake===!0)return!0;if(n instanceof Tt)return n.playAutomatically=!0,!0;if(n instanceof br)return n.playOnAwake=!0,!0}},!0)!==!0&&Gn.autoplayAnimations(t.file)});exports.SplineUtils=void 0;(s=>{function e(t,i=!1,n=.75){const o=new Nr,r=1-L.clamp(n,0,1);return t.forEach((a,l)=>{const h=new c.Vector3;l<t.length-1?h.subVectors(t[l+1],a).normalize().multiplyScalar(r):i&&t.length>1&&h.subVectors(t[0],a).normalize().multiplyScalar(r);const d=new Hn;d.position.copy(a),d.tangentIn.copy(h),d.tangentOut.copy(h),o.addKnot(d)}),o.closed=i,o}s.createFromPoints=e})(exports.SplineUtils||(exports.SplineUtils={}));class rA extends ae.WorkerBase{constructor(){super(new Worker(new URL("/generateMeshBVH.worker-DiCnZlf3.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:_a&&_a.tagName.toUpperCase()==="SCRIPT"&&_a.src||new URL("needle-engine.bundle-CK9xKTOH.umd.cjs",document.baseURI).href),{type:"module"})),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((n,o)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`[GenerateMeshBVHWorker] ${h.message||"Unknown error. Please check the server console. If you're using vite try adding 'three-mesh-bvh' to 'optimizeDeps.exclude' in your vite.config.js"}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:p}=d,m=ae.MeshBVH.deserialize(u,t,{setIndex:!1}),y=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=p,u.index)if(t.index)t.index.array=u.index;else{const _=new c.BufferAttribute(u.index,1,!1);t.setIndex(_)}y.setBoundingBox&&(t.boundingBox=m.getBoundingBox(new c.Box3)),i.onProgress&&i.onProgress(d.progress),n(m),e.onmessage=null}else i.onProgress&&i.onProgress(d.progress)};const r=t.index?t.index.array:null,a=t.attributes.position.array,l=[a];r&&l.push(r),e.postMessage({index:r,position:a,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},l.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const aA=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:rA},Symbol.toStringTag,{value:"Module"}));exports.$componentName=Dv;exports.$physicsKey=_C;exports.ActionBuilder=de;exports.ActionCollection=qw;exports.ActionModel=Zt;exports.Addressables=L0;exports.AlignmentConstraint=qc;exports.AmbientMode=Sa;exports.Animation=Tt;exports.AnimationCurve=hh;exports.AnimationExtension=Bu;exports.AnimationTrackHandler=Rc;exports.AnimationUtils=Gn;exports.Animator=lt;exports.AnimatorConditionMode=Zs;exports.AnimatorController=Ni;exports.AnimatorControllerParameterType=yg;exports.AnimatorStateInfo=Nl;exports.Antialiasing=uh;exports.Application=un;exports.AssetDatabase=Jv;exports.AssetReference=Z;exports.Attractor=ol;exports.AudioExtension=Er;exports.AudioListener=ds;exports.AudioSource=bi;exports.AudioTrackHandler=ps;exports.Avatar=po;exports.AvatarBlink_Simple=Pr;exports.AvatarEyeLook_Rotation=Pg;exports.AvatarLoader=Ux;exports.AvatarMarker=Oe;exports.AvatarModel=Wy;exports.Avatar_Brain_LookAt=Pc;exports.Avatar_MouthShapes=Kc;exports.Avatar_MustacheShake=Sg;exports.Avatar_POI=cr;exports.Axes=pa;exports.AxesHelper=Ga;exports.BUILD_TIME=mc;exports.BaseUIComponent=$i;exports.BasicIKConstraint=Mg;exports.BehaviorExtension=ny;exports.BehaviorModel=wt;exports.BloomEffect=Zu;exports.BoxCollider=Tu;exports.BoxGizmo=Dr;exports.BoxHelperComponent=yt;exports.Button=Ds;exports.ButtonsFactory=Bi;exports.CallDirection=uw;exports.CallInfo=hs;exports.Camera=ni;exports.CameraTargetReachedEvent=Cc;exports.Canvas=Fa;exports.CanvasGroup=mo;exports.CapsuleCollider=bs;exports.ChangeMaterialOnClick=Xg;exports.ChangeTransformOnClick=Rr;exports.CharacterController=Or;exports.CharacterControllerInput=Cs;exports.ChromaticAberration=fh;exports.CircularBuffer=yi;exports.ClearFlags=lr;exports.ClickThrough=gf;exports.ClipExtrapolation=Mn;exports.Collider=qi;exports.Collision=Lv;exports.CollisionDetectionMode=Ou;exports.ColorAdjustments=Eo;exports.ColorBySpeedModule=sl;exports.ColorOverLifetimeModule=Qu;exports.Component=AP;exports.Component$1=E;exports.ComponentLifecycleEvents=gu;exports.Components=oA;exports.ConnectionEvents=qv;exports.ContactPoint=Iv;exports.ContactShadows=Zc;exports.Context=U;exports.ContextArgs=yP;exports.ContextEvent=le;exports.ContextRegistry=ce;exports.ControlTrackHandler=cf;exports.CursorFollow=$r;exports.CustomBranding=Ar;exports.CustomShader=be;exports.DefaultReflectionMode=Hd;exports.Deletable=Tg;exports.DeleteBox=ao;exports.DepthOfField=_n;exports.DeviceFlag=Au;exports.DocumentExtension=zx;exports.DragControls=Zo;exports.DragMode=Ag;exports.DropListener=Os;exports.Duplicatable=Ug;exports.EffectWrapper=Ec;exports.EmissionModule=Rs;exports.EmphasizeOnClick=Qa;exports.EngineLoadingView=Ac;exports.EnvironmentScene=pf;exports.EventList=ne;exports.EventListEvent=Mu;exports.EventSystem=Gt;exports.EventTrigger=Lu;exports.FieldWithDefault=kw;exports.FileReference=rr;exports.FileReferenceSerializer=B0;exports.FileSpawnModel=qO;exports.File_Event=bw;exports.FixedJoint=yy;exports.Fog=el;exports.FrameEvent=ge;exports.GENERATOR=Ra;exports.GameObject=S;exports.Gizmos=B;exports.GltfExport=Wg;exports.GltfExportBox=Vg;exports.Gradient=Lr;exports.Graphic=ah;exports.GraphicRaycaster=ku;exports.Graphics=ho;exports.GridHelper=tl;exports.GridLayoutGroup=cy;exports.GroundProjectedEnv=qn;exports.GroupActionModel=Jo;exports.HideFlags=du;exports.HideOnStart=Ii;exports.HingeJoint=ch;exports.HorizontalLayoutGroup=ly;exports.HostData=_1;exports.Image=dl;exports.ImageReference=or;exports.ImageReferenceSerializer=j0;exports.InheritVelocityModule=xy;exports.Input=Nv;exports.InputEventQueue=ei;exports.InputEvents=Pe;exports.InputField=jy;exports.InstanceHandle=hr;exports.InstancingHandler=gr;exports.InstancingUtil=zi;exports.InstantiateEvent=c0;exports.InstantiateIdProvider=vt;exports.InstantiateOptions=mn;exports.Interactable=Rg;exports.JoinedRoomResponse=LC;exports.KeyEventArgs=CC;exports.Keyframe=si;exports.LODGroup=Hu;exports.LODModel=il;exports.LeftRoomResponse=jC;exports.Light=Ct;exports.LightData=V0;exports.LimitVelocityOverLifetimeModule=nt;exports.LoadingElementOptions=GT;exports.LogStats=Eg;exports.LogType=mi;exports.LookAt=By;exports.LookAtConstraint=Cr;exports.MODULES=T;exports.MainModule=It;exports.MarkerTrackHandler=lf;exports.MarkerType=Dy;exports.MaskableGraphic=lh;exports.MaterialPropertyBlock=ys;exports.Mathf=L;exports.MeshCollider=xo;exports.MeshRenderer=th;exports.MinMaxCurve=H;exports.MinMaxGradient=jr;exports.NEEDLE_ENGINE_FEATURE_FLAGS=tg;exports.NEKeyboardEvent=Bl;exports.NEPointerEvent=ss;exports.NeedleButtonElement=Fx;exports.NeedleEngineWebComponent=$y;exports.NeedleMenu=Qn;exports.NeedlePatchesKey=fd;exports.NeedleXRController=Hm;exports.NeedleXRSession=q;exports.NeedleXRSync=Yv;exports.NeedleXRUtils=Zv;exports.NestedGltf=nl;exports.NetworkConnection=Qv;exports.NetworkedStreamEvents=Bn;exports.NetworkedStreams=Yc;exports.Networking=vy;exports.NewInstanceModel=d0;exports.NoiseModule=me;exports.ObjectRaycaster=Vi;exports.ObjectUtils=bo;exports.OffsetConstraint=Ir;exports.OneEuroFilter=dd;exports.OneEuroFilterXYZ=Im;exports.OpenURL=ul;exports.OrbitControls=ue;exports.Outline=Ja;exports.OwnershipEvent=Xv;exports.OwnershipModel=Ym;exports.PUBLIC_KEY=no;exports.Padding=Tr;exports.ParticleBurst=ou;exports.ParticleSubEmitter=Sy;exports.ParticleSystem=kc;exports.ParticleSystemBaseBehaviour=ko;exports.ParticleSystemRenderer=Qi;exports.ParticleSystemShapeType=su;exports.PeerHandle=us;exports.PeerNetworking=Hv;exports.Physics=La;exports.PhysicsExtension=sy;exports.PhysicsMaterialCombine=st;exports.PixelationEffect=ph;exports.PlayAnimationOnClick=Oc;exports.PlayAudioOnClick=fo;exports.PlayableDirector=br;exports.PlayerColor=Ua;exports.PlayerState=Ui;exports.PlayerStateEvent=Yw;exports.PlayerSync=ty;exports.PlayerView=U0;exports.PlayerViewManager=z0;exports.PointerEventData=Qc;exports.PointerType=pu;exports.PostProcessingEffect=Xe;exports.PostProcessingEffectOrder=et;exports.PostProcessingHandler=ky;exports.PreliminaryAction=Ya;exports.PreliminaryTrigger=nh;exports.PrimitiveType=Na;exports.Progress=oe;exports.PromiseAllWithErrors=Am;exports.PromiseErrorResult=Rp;exports.RGBAColor=te;exports.RapierPhysics=Ma;exports.RawImage=uf;exports.RaycastOptions=vo;exports.Rect=Zw;exports.RectTransform=pn;exports.ReflectionProbe=os;exports.RegisteredAnimationInfo=so;exports.RemoteSkybox=ef;exports.RenderTexture=jn;exports.RenderTextureSerializer=cw;exports.Renderer=Ht;exports.RendererData=N0;exports.RendererLightmap=jg;exports.Rigidbody=Ve;exports.RigidbodyConstraints=Ne;exports.RoomEvents=K;exports.RotationBySpeedModule=Xi;exports.RotationOverLifetimeModule=yn;exports.SceneLightSettings=Jd;exports.SceneSwitcher=We;exports.ScreenCapture=Ro;exports.ScreenSpaceAmbientOcclusion=Ts;exports.ScreenSpaceAmbientOcclusionN8=bn;exports.ScrollFollow=Is;exports.SeeThrough=As;exports.SendQueue=an;exports.SerializationContext=lg;exports.SetActiveOnClick=Qg;exports.ShadowCatcher=_h;exports.ShapeModule=wy;exports.ShapeOverlapResult=jv;exports.SharpeningEffect=gh;exports.SignalAsset=af;exports.SignalReceiver=Sh;exports.SignalReceiverEvent=xh;exports.SignalTrackHandler=Tc;exports.Size=Kw;exports.SizeBySpeedModule=hi;exports.SizeOverLifetimeModule=Br;exports.SkinnedMeshRenderer=Bg;exports.SmoothFollow=nf;exports.SpatialGrabRaycaster=pr;exports.SpatialHtml=Ph;exports.SpatialTrigger=sf;exports.SpatialTriggerReceiver=Wn;exports.SpectatorCamera=of;exports.SphereCollider=Ha;exports.SphereIntersection=Jm;exports.SplineContainer=Nr;exports.SplineData=Hn;exports.SplineWalker=Ki;exports.Sprite=Ms;exports.SpriteData=Oa;exports.SpriteRenderer=li;exports.SpriteSheet=Ba;exports.StateMachineBehaviour=FP;exports.StreamEndedEvent=wg;exports.StreamReceivedEvent=dw;exports.SubEmitterSystem=ru;exports.SyncedCamera=Ry;exports.SyncedRoom=vn;exports.SyncedTransform=fn;exports.TapGestureTrigger=Kg;exports.TeleportTarget=Vu;exports.TestRunner=Ty;exports.TestSimulateUserData=Ay;exports.Text=Dt;exports.TextBuilder=ry;exports.TextExtension=Wu;exports.TextureSheetAnimationModule=Lt;exports.TiltShiftEffect=Kn;exports.Time=$0;exports.ToneMappingEffect=go;exports.TrackHandler=hl;exports.TrackType=ui;exports.TrailModule=De;exports.TransformData=Te;exports.TransformGizmo=Vr;exports.TriggerBuilder=Rt;exports.TriggerModel=lo;exports.TypeStore=P;exports.UIRaycastUtils=bg;exports.UIRootComponent=oh;exports.USDDocument=Gg;exports.USDObject=qe;exports.USDWriter=Fw;exports.USDZExporter=Uw;exports.USDZExporter$1=$n;exports.USDZText=ga;exports.USDZUIExtension=dy;exports.UriSerializer=hw;exports.UsageMarker=Jc;exports.UserJoinedOrLeftRoomModel=BC;exports.VERSION=ti;exports.VariantAction=qg;exports.VelocityOverLifetimeModule=Be;exports.VerticalLayoutGroup=ay;exports.VideoPlayer=tt;exports.ViewDevice=gs;exports.Vignette=zr;exports.VisibilityAction=sh;exports.Voip=wo;exports.Volume=al;exports.VolumeParameter=z;exports.VolumeProfile=Yu;exports.WaitForFrames=Y1;exports.WaitForPromise=F0;exports.WaitForSeconds=dg;exports.Watch=ms;exports.WebARCameraBackground=Mh;exports.WebARSessionRoot=Fi;exports.WebXR=$u;exports.WebXRButtonFactory=co;exports.WebXRImageTracking=kh;exports.WebXRImageTrackingModel=js;exports.WebXRPlaneTracking=Bs;exports.WebXRTrackedImage=za;exports.XRControllerFollow=Ls;exports.XRControllerModel=vs;exports.XRControllerMovement=wi;exports.XRFlag=Li;exports.XRRig=bf;exports.XRState=Wt;exports.XRStateFlag=Dn;exports.__Ignore=Nx;exports.__internalNotifyObjectDestroyed=l1;exports.activeInHierarchyFieldName=Ln;exports.addAttributeChangeCallback=Rm;exports.addComponent=ln;exports.addCustomExtensionPlugin=_M;exports.addNewComponent=nr;exports.addPatch=uu;exports.apply=_u;exports.applyHMRChanges=TP;exports.applyPrototypeExtensions=S0;exports.beginListenDestroy=h0;exports.beginListenInstantiate=f0;exports.binaryIdentifierCasts=qm;exports.build_scene_functions=gP;exports.builtinComponentKeyName=qo;exports.calculateProgress01=Vy;exports.clearMessages=yS;exports.colorSerializer=tO;exports.compareAssociation=y0;exports.componentSerializer=xd;exports.copyTexture=vv;exports.createMotion=sw;exports.debugNet=Qt;exports.debugOwner=Fl;exports.decompressGpuTexture=$w;exports.deepClone=Lc;exports.delay=_s;exports.delayForFrames=jc;exports.deserializeObject=Wd;exports.destroy=_i;exports.destroyComponentInstance=O0;exports.determineMimeTypeFromExtension=vw;exports.disposeObjectResources=ve;exports.disposeStream=Fn;exports.editorGuidKeyName=Jl;exports.enableSpatialConsole=ba;exports.euler=nO;exports.eventListSerializer=aO;exports.exportAsGLTF=iA;exports.findByGuid=hg;exports.findObjectOfType=$a;exports.findObjectsOfType=k0;exports.findResourceUsers=eg;exports.fitCamera=ow;exports.fitObjectIntoVolume=xv;exports.foreachComponent=fr;exports.foreachComponentEnumerator=vu;exports.forward=LS;exports.generateQRCode=H0;exports.generateSeed=u0;exports.getBoundingBox=oi;exports.getCameraController=fv;exports.getComponent=xr;exports.getComponentInChildren=Wc;exports.getComponentInParent=vc;exports.getComponents=$c;exports.getComponentsInChildren=Va;exports.getComponentsInParent=yu;exports.getFormattedDate=Iw;exports.getIconElement=bt;exports.getIconTexture=Jp;exports.getLoader=dn;exports.getOrAddComponent=Vc;exports.getParam=x;exports.getParentHierarchyPath=FS;exports.getPath=Qx;exports.getPeerOptions=TC;exports.getPeerjsInstance=Gv;exports.getResourceUserCount=h1;exports.getTempColor=gv;exports.getTempQuaternion=Jt;exports.getTempVector=F;exports.getUrlParams=Ic;exports.getVisibleInCustomShadowRendering=wv;exports.getWorldDirection=yv;exports.getWorldEuler=Bm;exports.getWorldPosition=Y;exports.getWorldQuaternion=pe;exports.getWorldRotation=hu;exports.getWorldScale=je;exports.hasCommercialLicense=Vn;exports.hasIndieLicense=Hc;exports.hasPointerEventComponent=Yd;exports.hasProLicense=Nn;exports.hideDebugConsole=Ov;exports.imageToCanvas=Ww;exports.instantiate=uo;exports.invokeLoadedImportPluginHooks=Mw;exports.invokeXRSessionEnd=zv;exports.invokeXRSessionStart=Uv;exports.isActiveInHierarchy=E0;exports.isActiveSelf=Wa;exports.isAndroidDevice=tS;exports.isAnimationAction=bv;exports.isComponent=$m;exports.isDebugMode=Gx;exports.isDesktop=Kx;exports.isDestroyed=ur;exports.isDevEnvironment=A;exports.isDisposed=a1;exports.isExporting=eA;exports.isGLTFModel=Av;exports.isHostedOnGlitch=tv;exports.isHotReloadEnabled=sm;exports.isHotReloading=EP;exports.isIPad=Jx;exports.isIconElement=q0;exports.isLocalNetwork=gi;exports.isMacOS=nS;exports.isMobileDevice=Zx;exports.isMozillaXR=iS;exports.isQuest=rS;exports.isResourceTrackingEnabled=t0;exports.isSafari=oS;exports.isUsingInstancing=bu;exports.isiOS=sS;exports.isiPad=eS;exports.loadAsset=UT;exports.loadPMREM=Dg;exports.loadSync=Ny;exports.logHierarchy=jd;exports.lookAtInverse=MS;exports.lookAtObject=Bc;exports.lookAtScreenPoint=kS;exports.makeId=qx;exports.makeIdFromRandomWords=sv;exports.makeNameSafe=vi;exports.markAsInstancedRendered=R0;exports.microphonePermissionsGranted=aS;exports.nameof=Wx;exports.nameofFactory=iv;exports.objectSerializer=lw;exports.offXRSessionEnd=SC;exports.offXRSessionStart=xC;exports.onAfterRender=wP;exports.onBeforeRender=vP;exports.onClear=_P;exports.onDestroy=bP;exports.onInitialized=pg;exports.onStart=Cu;exports.onUpdate=Y0;exports.onXRSessionEnd=Gm;exports.onXRSessionStart=fu;exports.parseSync=Dx;exports.placeOnSurface=Sv;exports.postprocessFBXMaterials=zm;exports.prefix=QP;exports.pushState=nv;exports.randomNumber=Xx;exports.registerBinaryType=Xm;exports.registerComponent=Su;exports.registerComponentExtension=Ig;exports.registerCustomEffectType=Yi;exports.registerExportExtensions=Lg;exports.registerExtensions=tu;exports.registerHotReloadType=ew;exports.registerLoader=Vm;exports.registerPrefabProvider=m0;exports.registerPrototypeExtensions=C0;exports.registerType=og;exports.relativePathPrefix=rv;exports.removeAttributeChangeCallback=Tm;exports.removeComponent=cg;exports.removeCustomImportExtensionType=bM;exports.removePatch=vC;exports.resolveUrl=ws;exports.sanitizeString=ov;exports.saveImage=Ex;exports.screenshot=xT;exports.screenshot2=zy;exports.sendDestroyed=ng;exports.serializable=f;exports.serializeObject=b0;exports.serializeable=$e;exports.setActive=nc;exports.setAllowBalloonMessages=hv;exports.setAllowOverlayMessages=fS;exports.setAutoFitEnabled=Id;exports.setCameraController=Ap;exports.setDestroyed=A0;exports.setDevEnvironment=HS;exports.setDisposable=n0;exports.setDontDestroy=na;exports.setOrAddParamsToUrl=Ep;exports.setParam=Hx;exports.setParamWithoutReload=pc;exports.setPeerOptions=AC;exports.setResourceTrackingEnabled=r1;exports.setState=km;exports.setVisibleInCustomShadowRendering=Um;exports.setWorldEuler=Fm;exports.setWorldPosition=at;exports.setWorldPositionXYZ=dr;exports.setWorldQuaternion=hn;exports.setWorldQuaternionXYZW=jm;exports.setWorldRotation=_v;exports.setWorldRotationXYZ=Fc;exports.setWorldScale=Ea;exports.showBalloonError=Uc;exports.showBalloonMessage=xe;exports.showBalloonWarning=fe;exports.showDebugConsole=Nm;exports.slerp=OS;exports.syncDestroy=zc;exports.syncField=ey;exports.syncInstantiate=sg;exports.textureToCanvas=US;exports.toSourceId=av;exports.tryCastBinary=$v;exports.tryDetermineMimetypeFromBinary=xw;exports.tryDetermineMimetypeFromURL=ww;exports.tryFindObject=ka;exports.tryGetGuid=Wv;exports.unregisterHotReloadType=tw;exports.unwatchWrite=Em;exports.useForAutoFit=pv;exports.validate=xt;exports.watchWrite=cu;