@needle-tools/engine 4.1.0-beta.3 → 4.1.0-beta.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.
@@ -130,7 +130,7 @@ Open this page to get the console: `+t.toString())}const s=exports.DeviceUtiliti
130
130
  #__vconsole .vc-mask {
131
131
  overflow: hidden;
132
132
  }
133
- `,di==null||di.prepend(i),s===!0&&Am()<=0&&nv(),console.log("🌵 Debug console has loaded")}},t.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),hl=!1,Nt=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function pS(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(e){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 l=location.protocol+"//"+location.host+location.pathname+"/"+n,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var d='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(d)}),s.on("show",function(){const e=t();e&&e.src!==s.fullUrl&&(e.src=s.fullUrl)}),s.on("hide",function(){const e=t();e&&(e.src="")}),s.on("addTopBar",function(e){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Nt==null||Nt.hide()}}),i.push({name:"Reload",onClick:function(n){const o=t();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=t();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(i)}),s}function mS(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function gS(){const s=document.querySelector("#__vconsole");return s||null}const rv=S("debugdefines");go('if(!globalThis[""4.1.0-beta.3""]) globalThis[""4.1.0-beta.3""] = "0.0.0";');go('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');go('if(!globalThis[""Thu Jan 30 2025 13:38:09 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Jan 30 2025 13:38:09 GMT+0100 (Central European Standard Time)""] = "unknown";');go('if(!globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""]) globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""] = "unknown";');go('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.1.0-beta.3";');go('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');go('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Jan 30 2025 13:38:09 GMT+0100 (Central European Standard Time)";');go('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006";');const on="4.1.0-beta.3",bu="undefined",$m="Thu Jan 30 2025 13:38:09 GMT+0100 (Central European Standard Time)";rv&&console.log(`Engine version: ${on} (generator: ${bu})
133
+ `,di==null||di.prepend(i),s===!0&&Am()<=0&&nv(),console.log("🌵 Debug console has loaded")}},t.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),hl=!1,Nt=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function pS(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(e){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 l=location.protocol+"//"+location.host+location.pathname+"/"+n,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var d='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(d)}),s.on("show",function(){const e=t();e&&e.src!==s.fullUrl&&(e.src=s.fullUrl)}),s.on("hide",function(){const e=t();e&&(e.src="")}),s.on("addTopBar",function(e){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Nt==null||Nt.hide()}}),i.push({name:"Reload",onClick:function(n){const o=t();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=t();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(i)}),s}function mS(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function gS(){const s=document.querySelector("#__vconsole");return s||null}const rv=S("debugdefines");go('if(!globalThis[""4.1.0-beta.4""]) globalThis[""4.1.0-beta.4""] = "0.0.0";');go('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');go('if(!globalThis[""Mon Feb 03 2025 09:35:07 GMT+0100 (Central European Standard Time)""]) globalThis[""Mon Feb 03 2025 09:35:07 GMT+0100 (Central European Standard Time)""] = "unknown";');go('if(!globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""]) globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""] = "unknown";');go('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.1.0-beta.4";');go('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');go('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Feb 03 2025 09:35:07 GMT+0100 (Central European Standard Time)";');go('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006";');const on="4.1.0-beta.4",bu="undefined",$m="Mon Feb 03 2025 09:35:07 GMT+0100 (Central European Standard Time)";rv&&console.log(`Engine version: ${on} (generator: ${bu})
134
134
  Project built at ${$m}`);const Hl="npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006",vs="needle_isActiveInHierarchy",Ho="builtin_components",Gl="needle_editor_guid";function go(s){try{(0,eval)(s)}catch(t){rv&&console.error(t)}}const _S='<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>',yS=btoa(_S),bS="data:image/svg+xml;base64,"+yS,vS=bS,wS=`<?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(wS);const xS='<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>',SS=btoa(xS),CS="data:image/svg+xml;charset=utf-8;base64,"+SS,PS=CS,OS=S("debugpatch");function vu(s,t,e,i){const n=OS===t;if(!e&&!i)return;const o=t+"___needle";RS(s,t,e,i);const a=Object.getOwnPropertyDescriptor(s,t),l=s[t];n&&console.log("Patch",s.constructor.name,t,a,l),a?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,t,a),typeof a.value=="function"&&(s[t]=V_(a.value,s,t))):(n&&console.log("Create patch with new property",s.constructor.name,t,a),Object.defineProperty(s,t,{set:function(c){if(typeof c=="function")this[o]=V_(c,s,t);else{const d=this[o];av(s,t,this,d,c),this[o]=c,lv(s,t,this,d,c)}},get:function(){const c=this[o];return typeof c=="function"&&c[o]?c[o]:c}}))}function MS(s,t,e){const i=Wm(s,t);if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];o.prefix===e&&(o.prefix=null),o.postfix===e&&(o.postfix=null),!o.prefix&&!o.postfix&&i.splice(n,1)}}const N_=Symbol("Needle:Patches:WrappedFunction");function V_(s,t,e){if(s[N_])return s;const i=function(...n){av(t,e,this,...n);const o=s.apply(this,n);return lv(t,e,this,o,...n),o};return i[N_]=!0,i}const md="Needle:Patches";function Hp(){return globalThis[md]||(globalThis[md]=new WeakMap),globalThis[md]}function Wm(s,t){const e=Hp().get(s);return e?e.get(t):null}function RS(s,t,e,i){let n=Hp().get(s);n||(n=new Map,Hp().set(s,n));let o=n.get(t);o||(o=[],n.set(t,o)),o.push({prefix:e,postfix:i})}function av(s,t,e,...i){var o;if(!e)return;const n=Wm(s,t);if(n)for(const a of n)(o=a.prefix)==null||o.call(e,...i)}function lv(s,t,e,i,...n){var a;if(!e)return;const o=Wm(s,t);if(o)for(const l of o)(a=l.postfix)==null||a.call(e,i,...n)}const ka=[];function wu(s){ka.indexOf(s)===-1&&ka.push(s)}function kS(s){const t=ka.indexOf(s);t!==-1&&ka.splice(t,1)}const Ea=[];function Hm(s){Ea.indexOf(s)===-1&&Ea.push(s)}function ES(s){const t=Ea.indexOf(s);t!==-1&&Ea.splice(t,1)}function cv(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let t=0;t<ka.length;t++)ka[t](s)}function hv(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let t=0;t<Ea.length;t++)Ea[t](s)}const et=S("debuginput");var xu=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(xu||{}),Ee=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(Ee||{});class cs extends PointerEvent{constructor(e,i,n){super(e,n);r(this,"clientZ");r(this,"deviceIndex");r(this,"origin");r(this,"source");r(this,"mode");r(this,"_ray");r(this,"space");r(this,"isClick",!1);r(this,"isDoubleClick",!1);r(this,"_used",!1);r(this,"_pointerid");r(this,"_pointerType");r(this,"_type");r(this,"metadata",{});r(this,"intersections",new Array);r(this,"_immediatePropagationStopped",!1);r(this,"_propagationStopped",!1);this.clientZ=n.clientZ,this._pointerid=n.pointerId,this._pointerType=n.pointerType,this._type=e,this.deviceIndex=n.deviceIndex,this.origin=n.origin,this.source=i,this.mode=n.mode,this._ray=n.ray,this.space=n.device}get isSpatial(){return this.mode!="screen"}get ray(){return this._ray||(this._ray=new h.Ray(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(e){this._ray=e}get hasRay(){return this._ray!==void 0}get used(){return this._used}use(){this._used=!0}get pointerId(){return this._pointerid}get pointerType(){return this._pointerType}get type(){return this._type}get immediatePropagationStopped(){return this._immediatePropagationStopped}get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){var e;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}stopPropagation(){var e;this._propagationStopped=!0,super.stopPropagation(),(e=this.source)==null||e.stopPropagation(),et&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class Ml extends KeyboardEvent{constructor(e,i,n){super(e,n);r(this,"source");this.source=i}stopImmediatePropagation(){var e;super.stopImmediatePropagation(),(e=this.source)==null||e.stopImmediatePropagation()}}class TS{constructor(t){r(this,"key");r(this,"keyType");r(this,"source");this.key=t.key,this.keyType=t.type,this.source=t}}var fi=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))(fi||{});class dv{constructor(t){r(this,"_eventListeners",{});r(this,"_doubleClickTimeThreshold",.2);r(this,"_longPressTimeThreshold",1);r(this,"_specialCursorTrigger",0);r(this,"context");r(this,"_pointerDown",[!1]);r(this,"_pointerUp",[!1]);r(this,"_pointerClick",[!1]);r(this,"_pointerDoubleClick",[!1]);r(this,"_pointerPressed",[!1]);r(this,"_pointerPositions",[new h.Vector2]);r(this,"_pointerPositionsLastFrame",[new h.Vector2]);r(this,"_pointerPositionsDelta",[new h.Vector2]);r(this,"_pointerPositionsRC",[new h.Vector2]);r(this,"_pointerPositionDown",[new h.Vector3]);r(this,"_pointerDownTime",[]);r(this,"_pointerUpTime",[]);r(this,"_pointerUpTimestamp",[]);r(this,"_pointerIds",[]);r(this,"_pointerTypes",[""]);r(this,"_mouseWheelChanged",[!1]);r(this,"_mouseWheelDeltaY",[0]);r(this,"_pointerEvent",[]);r(this,"_pointerEventsPressed",[]);r(this,"_pointerSpace",[]);r(this,"_pressedStack",new Map);r(this,"_htmlEventSource");r(this,"onLostFocus",()=>{for(const t in this.keysPressed)this.keysPressed[t].pressed=!1});r(this,"onEndOfFrame",()=>{for(let t=0;t<this._pointerUp.length;t++)this._pointerUp[t]=!1;for(let t=0;t<this._pointerDown.length;t++)this._pointerDown[t]=!1;for(let t=0;t<this._pointerClick.length;t++)this._pointerClick[t]=!1;for(let t=0;t<this._pointerDoubleClick.length;t++)this._pointerDoubleClick[t]=!1;for(const t of this._pointerPositionsDelta)t.set(0,0);for(let t=0;t<this._mouseWheelChanged.length;t++)this._mouseWheelChanged[t]=!1;for(let t=0;t<this._mouseWheelDeltaY.length;t++)this._mouseWheelDeltaY[t]=0});r(this,"onContextMenu",t=>{this.canReceiveInput(t)!==!1&&t instanceof PointerEvent&&t.pointerType});r(this,"keysPressed",{});r(this,"onKeyDown",t=>{if(et&&console.log(`key down ${t.code}, ${this.context.application.hasFocus}`,t),!this.context.application.hasFocus)return;const e=this.keysPressed[t.code];if(e&&e.pressed)return;this.keysPressed[t.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:t.key,code:t.code};const i=new Ml("keydown",t,t);this.onDispatchEvent(i)});r(this,"onKeyPressed",t=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[t.code];if(!e)return;e.pressed=!0,e.frame=this.context.time.frameCount+1;const i=new Ml("keypress",t,t);this.onDispatchEvent(i)});r(this,"onKeyUp",t=>{if(!this.context.application.hasFocus)return;const e=this.keysPressed[t.code];if(!e)return;e.pressed=!1,e.frame=this.context.time.frameCount+1;const i=new Ml("keyup",t,t);this.onDispatchEvent(i)});r(this,"onWheelWindow",t=>{document.pointerLockElement&&this.onMouseWheel(t)});r(this,"onMouseWheel",t=>{if(this.canReceiveInput(t)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const e=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=e+t.deltaY});r(this,"onPointerDown",t=>{if(this.context.isInAR||this.canReceiveInput(t)===!1)return;t.target instanceof HTMLElement&&t.target.setPointerCapture(t.pointerId);const e=this.getPointerId(t);et&&Te(`pointer down #${e}, identifier:${t.pointerId}`);const i=this.getAndUpdateSpatialObjectForScreenPosition(e,t.clientX,t.clientY),n=new cs("pointerdown",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:e,button:t.button,clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,buttonName:this.getButtonName(t),device:i,pressure:t.pressure});this.onDown(n)});r(this,"onPointerMove",t=>{if(this.context.isInAR)return;let e=t.button;t.pointerType==="mouse"&&(e=this.getFirstPressedButtonForPointer(0)??0);const i=this.getPointerId(t,e);e===-1&&(e=i);const n=this.getAndUpdateSpatialObjectForScreenPosition(i,t.clientX,t.clientY),o=new cs("pointermove",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:i,button:e,clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,buttonName:this.getButtonName(t),device:n,pressure:t.pressure});this.onMove(o)});r(this,"onPointerCancel",t=>{this.context.isInAR||(et&&console.log("Pointer cancel",t),this.onPointerUp(t))});r(this,"onPointerUp",t=>{if(this.context.isInAR)return;t.target instanceof HTMLElement&&t.target.releasePointerCapture(t.pointerId);const e=this.getPointerId(t),i=new cs("pointerup",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:e,button:t.button,clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,buttonName:this.getButtonName(t),device:this.getAndUpdateSpatialObjectForScreenPosition(e,t.clientX,t.clientY),pressure:t.pressure});this.onUp(i),this._pointerIds[e]=-1,et&&console.log("ID="+e,"PointerId="+t.pointerId,"ALL:",[...this._pointerIds])});r(this,"onTouchStart",t=>{if(this.context.isInAR)for(let e=0;e<t.changedTouches.length;e++){const i=t.changedTouches[e],n=this.getPointerIndex(i.identifier),o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),a=new cs("pointerdown",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:o,pressure:i.force});this.onDown(a)}});r(this,"onTouchMove",t=>{if(this.context.isInAR)for(let e=0;e<t.changedTouches.length;e++){const i=t.changedTouches[e],n=this.getPointerIndex(i.identifier),o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),a=new cs("pointermove",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:o,pressure:i.force});this.onMove(a)}});r(this,"onTouchEnd",t=>{if(this.context.isInAR)for(let e=0;e<t.changedTouches.length;e++){const i=t.changedTouches[e],n=this.getPointerIndex(i.identifier),o=new cs("pointerup",t,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.force});this.onUp(o),this._pointerIds[n]=-1}});r(this,"tempNearPlaneVector",new h.Vector3);r(this,"tempFarPlaneVector",new h.Vector3);r(this,"tempLookMatrix",new h.Matrix4);this.context=t,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(t,e,i){if(this._eventListeners[t]||(this._eventListeners[t]=[]),!e||typeof e!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}i?i={...i}:i={};let n=0;(i==null?void 0:i.queue)!=null&&(n=i.queue);const o=this._eventListeners[t],a=o.find(l=>l.priority===n);a?a.listeners.push({callback:e,options:i}):(o.push({priority:n,listeners:[{callback:e,options:i}]}),o.sort((l,c)=>l.priority-c.priority))}removeEventListener(t,e,i){if(!this._eventListeners[t]||!e)return;const n=this._eventListeners[t];if((i==null?void 0:i.queue)!=null){const o=n.find(l=>l.priority===i.queue);if(!o)return;const a=o.listeners.findIndex(l=>l.callback===e);a>=0&&o.listeners.splice(a,1)}else for(const o of n){const a=o.listeners.findIndex(l=>l.callback===e);a>=0&&o.listeners.splice(a,1)}}dispatchEvent(t){var i,n,o,a;let e=!1;if(t instanceof Ml){const l=this._eventListeners[t.type];if(l)for(const c of l)for(let d=0;d<c.listeners.length;d++){const u=c.listeners[d];if((n=(i=u.options)==null?void 0:i.signal)!=null&&n.aborted){c.listeners.splice(d,1),d--;continue}u.options.once&&(c.listeners.splice(d,1),d--),u.callback(t)}}if(t instanceof cs){const l=this._eventListeners[t.type];if(l)for(const c of l){if(e)break;for(let d=0;d<c.listeners.length;d++){const u=c.listeners[d];if((a=(o=u.options)==null?void 0:o.signal)!=null&&a.aborted){c.listeners.splice(d,1),d--;continue}if(t.immediatePropagationStopped){e=!0,et&&console.log("immediatePropagationStopped",t.type);break}else t.propagationStopped&&(e=!0,et&&console.log("propagationStopped",t.type));u.options.once&&(c.listeners.splice(d,1),d--),u.callback(t)}}}}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}get click(){return this._pointerClick[0]}get doubleClick(){return this._pointerDoubleClick[0]}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}getIsPointerIdInUse(t){for(const e of this._pointerEventsPressed)if(e.pointerId===t&&e.used)return!0;return!1}getPointerPressedCount(){let t=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&t++;return t}getPointerPosition(t){return t>=this._pointerPositions.length?null:this._pointerPositions[t]}getPointerPositionLastFrame(t){return t>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[t]}getPointerPositionDelta(t){return t>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[t]}getPointerPositionRC(t){return t>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[t]}getPointerDown(t){return t>=this._pointerDown.length?!1:this._pointerDown[t]}getPointerUp(t){return t>=this._pointerUp.length?!1:this._pointerUp[t]}getPointerPressed(t){return t>=this._pointerPressed.length?!1:this._pointerPressed[t]}getPointerClicked(t){return t>=this._pointerClick.length?!1:this._pointerClick[t]}getPointerDoubleClicked(t){return t>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[t]}getPointerDownTime(t){return t>=this._pointerDownTime.length?-1:this._pointerDownTime[t]}getPointerUpTime(t){return t>=this._pointerUpTime.length?-1:this._pointerUpTime[t]}getPointerLongPress(t){return t>=this._pointerDownTime.length?!1:this.getPointerPressed(t)&&this.context.time.time-this._pointerDownTime[t]>this._longPressTimeThreshold}getIsMouse(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="mouse"}getIsTouch(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="touch"}getTouchesPressedCount(){let t=0;for(let e=0;e<this._pointerPressed.length;e++)this._pointerPressed[e]&&this.getIsTouch(e)&&t++;return t}getMouseWheelChanged(t=0){return t>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[t]}getMouseWheelDeltaY(t=0){return t>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[t]}getPointerEvent(t){if(!(t>=this._pointerEvent.length))return this._pointerEvent[t]??void 0}*foreachPointerId(t){for(let e=0;e<this._pointerTypes.length;e++)if(this._pointerIsActive(e)){if(t!==void 0){const i=this._pointerTypes[e];if(Array.isArray(t)){let n=!1;for(const o of t)if(i===o){n=!0;break}if(!n)continue}else if(t!==i)continue}yield e}}*foreachTouchId(){for(let t=0;t<this._pointerTypes.length;t++)this._pointerTypes[t]==="touch"&&this._pointerIsActive[t]&&(yield t)}_pointerIsActive(t){return t<0?!1:this._pointerPressed[t]||this._pointerDown[t]||this._pointerUp[t]}onDownButton(t,e){let i=this._pressedStack.get(t);i||(i=[],this._pressedStack.set(t,i)),i.push(e)}onReleaseButton(t,e){const i=this._pressedStack.get(t);if(!i)return;const n=i.indexOf(e);n>=0&&i.splice(n,1)}getFirstPressedButtonForPointer(t){const e=this._pressedStack.get(t);if(e)return e[0]}getLatestPressedButtonForPointer(t){const e=this._pressedStack.get(t);if(e)return e[e.length-1]}getKeyDown(){for(const t in this.keysPressed){const e=this.keysPressed[t];if(e.startFrame===this.context.time.frameCount)return e.key}return null}getKeyPressed(){for(const t in this.keysPressed){const e=this.keysPressed[t];if(e.pressed)return e.key}return null}isKeyDown(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(t);if(e!==null){for(const n of e)if(this.isKeyDown(n))return!0;return!1}return((i=this.keysPressed[t])==null?void 0:i.startFrame)===this.context.time.frameCount&&this.keysPressed[t].pressed}isKeyUp(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(t);if(e!==null){for(const n of e)if(this.isKeyUp(n))return!0;return!1}return((i=this.keysPressed[t])==null?void 0:i.frame)===this.context.time.frameCount&&!this.keysPressed[t].pressed}isKeyPressed(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const e=this.getCodeForCommonKeyName(t);if(e!==null){for(const n of e)if(this.isKeyPressed(n))return!0;return!1}return(i=this.keysPressed[t])==null?void 0:i.pressed}getCodeForCommonKeyName(t){if(t.length===1){if(t>="0"&&t<="9")return["Digit"+t];if(t>="a"&&t<="z")return["Key"+t.toUpperCase()];if(t==" ")return["Space"]}switch(t){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(t){switch(t.type){case"pointerdown":et&&Te("Create Pointer down"),this.onDownButton(t.deviceIndex,t.button),this.onDown(t);break;case"pointermove":et&&Te("Create Pointer move"),this.onMove(t);break;case"pointerup":et&&Te("Create Pointer up"),this.onUp(t),this.onReleaseButton(t.deviceIndex,t.button);break}}convertScreenspaceToRaycastSpace(t){return t.x=(t.x-this.context.domX)/this.context.domWidth*2-1,t.y=-((t.y-this.context.domY)/this.context.domHeight)*2+1,t}bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){var t,e;window.removeEventListener("contextmenu",this.onContextMenu),(t=this._htmlEventSource)==null||t.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),(e=this._htmlEventSource)==null||e.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const t=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);t>=0&&this.context.post_render_callbacks.splice(t,1),this.unbindEvents()}canReceiveInput(t){var e;return t.target===((e=this.context.renderer)==null?void 0:e.domElement)||t.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&t.target===document.body&&exports.DeviceUtilities.isMozillaXR()?!0:(et&&console.warn("CanReceiveInput:False for",t.target),!1)}getPointerId(t,e){return t.pointerType==="mouse"?0+(e??t.button):this.getPointerIndex(t.pointerId)}getButtonName(t){const e=t.button;if(t.pointerType==="mouse")switch(e){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(t,e,i){let n=this._pointerSpace[t];n||(n=new h.Object3D,this._pointerSpace[t]=n),this._pointerSpace[t]=n;const o=this.context.mainCamera;if(o){const a=this.tempNearPlaneVector.set(e,i,-1);this.convertScreenspaceToRaycastSpace(a);const l=this.tempFarPlaneVector.set(a.x,a.y,1);a.unproject(o),l.unproject(o);const c=o.worldUp||V(0,1,0).applyQuaternion(ge(o));this.tempLookMatrix.lookAt(l,a,c),n.position.set(a.x,a.y,a.z),n.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return n}isInRect(t){if(this.context.isInXR)return!0;const e=this.context.domElement.getBoundingClientRect(),i=t.clientX,n=t.clientY,o=i>=e.x&&i<=e.right&&n>=e.y&&n<=e.bottom;return et&&!o&&console.log("Not in rect",e,i,n),o}onDown(t){const e=t.pointerId;if(this.getPointerPressed(e)&&console.warn(`Received pointerDown for pointerId that is already pressed: ${e}`,et?t:""),et&&console.log(t.pointerType,"DOWN",e),!!this.isInRect(t)){for(this.setPointerState(e,this._pointerPressed,!0),this.setPointerState(e,this._pointerDown,!0),this.setPointerStateT(e,this._pointerEvent,t.source);e>=this._pointerTypes.length;)this._pointerTypes.push(t.pointerType);for(this._pointerTypes[e]=t.pointerType;e>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new h.Vector3);for(this._pointerPositionDown[e].set(t.clientX,t.clientY,t.clientZ??0);e>=this._pointerPositions.length;)this._pointerPositions.push(new h.Vector2);this._pointerPositions[e].set(t.clientX,t.clientY),e>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[e]=this.context.time.realtimeSinceStartup,this.updatePointerPosition(t),this._pointerEventsPressed.push(t),this.onDispatchEvent(t)}}onMove(t){const e=t.pointerId,i=this.getPointerPressed(e);i===!1&&!this.isInRect(t)||t.pointerType==="touch"&&!i||(this.updatePointerPosition(t),this.setPointerStateT(e,this._pointerEvent,t.source),this.onDispatchEvent(t))}onUp(t){const e=t.pointerId;if(!this.getPointerPressed(e)){et&&console.log(t.pointerType,"UP",e,"was not down");return}et&&console.log(t.pointerType,"UP",e),this.setPointerState(e,this._pointerPressed,!1),this.setPointerStateT(e,this._pointerEvent,t.source),this.setPointerState(e,this._pointerUp,!0),this.updatePointerPosition(t);for(let c=this._pointerEventsPressed.length-1;c>=0;c--)if(this._pointerEventsPressed[c].pointerId===e){this._pointerEventsPressed.splice(c,1);break}if(!this._pointerPositionDown[e]){et&&fe("Received pointer up event without matching down event for button: "+e),console.warn("Received pointer up event without matching down event for button: "+e);return}const n=this._pointerUpTime[e],o=this._pointerDownTime[e],a=this.context.time.realtimeSinceStartup,l=a-o;if(e>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),this._pointerUpTime[e]=a,l<1){let c=t.clientX-this._pointerPositionDown[e].x,d=t.clientY-this._pointerPositionDown[e].y,u=0;if(t.isSpatial&&t.clientZ!=null&&(u=t.clientZ-this._pointerPositionDown[e].z,c*=200,d*=200,u*=200),Math.abs(c)<5&&Math.abs(d)<5&&Math.abs(u)<5){this.setPointerState(e,this._pointerClick,!0),t.isClick=!0;const f=a-n;et&&console.log("CLICK",e,c,d,u,f),f<this._doubleClickTimeThreshold&&f>0&&(this.setPointerState(e,this._pointerDoubleClick,!0),t.isDoubleClick=!0)}}this.onDispatchEvent(t)}updatePointerPosition(t){const e=t.pointerId;for(;e>=this._pointerPositions.length;)this._pointerPositions.push(new h.Vector2);for(;e>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new h.Vector2);for(;e>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new h.Vector2);const i=this._pointerPositionsLastFrame[e];i.copy(this._pointerPositions[e]);const n=this._pointerPositionsDelta[e];let o=t.clientX-i.x,a=t.clientY-i.y;if(t.source instanceof MouseEvent||t.source instanceof TouchEvent){const u=t.source;o===0&&u.movementX!==0&&(o=u.movementX||0),a===0&&u.movementY!==0&&(a=u.movementY||0)}n.x+=o,n.y+=a,this._pointerPositions[e].x=t.clientX,this._pointerPositions[e].y=t.clientY;const l=t.clientX,c=t.clientY;for(;e>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new h.Vector2);const d=this._pointerPositionsRC[e];d.set(l,c),this.convertScreenspaceToRaycastSpace(d)}getPointerIndex(t){let e=-1;for(let i=0;i<this._pointerIds.length;i++){if(this._pointerIds[i]===t)return i;e===-1&&this._pointerIds[i]===-1&&(e=i)}return e!==-1?(this._pointerIds[e]=t,e):(et&&console.log("PUSH pointerId:",t),this._pointerIds.push(t),this._pointerIds.length-1)}setPointerState(t,e,i){e[t]=i}setPointerStateT(t,e,i){return e[t]=i,i}onDispatchEvent(t){const e=X.Current;try{X.Current=this.context,this.dispatchEvent(t)}finally{X.Current=e}}}const _a=new h.Matrix4().makeRotationY(Math.PI),Li=new h.Quaternion().setFromAxisAngle(new h.Vector3(0,1,0),Math.PI),AS=S("debugwebxr");class DS{constructor(){r(this,"priority",-1e5);r(this,"gameObject");if(this.gameObject=new h.Object3D,this.gameObject.name="Implicit XR Rig",AS){const t=Zm(16733661);t.position.y+=.5,this.gameObject.add(t)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const yn=S("debugwebxr"),Th=S("debugcustomgesture"),LS="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",IS="generic-trigger",jS=new h.Quaternion().setFromEuler(new h.Euler(h.MathUtils.degToRad(0),h.MathUtils.degToRad(-90),h.MathUtils.degToRad(-90))),BS=new h.Vector3(.04,-.04,0);class Gm{constructor(t,e,i){r(this,"xr");r(this,"inputSource");r(this,"index",0);r(this,"emitEvents",!0);r(this,"_connected",!0);r(this,"_isTracking",!1);r(this,"__gamepad");r(this,"__hand");r(this,"__side");r(this,"_hitTestSource");r(this,"_hasSelectEvent",!1);r(this,"_isMxInk",!1);r(this,"_isMxInkFallback",!1);r(this,"_isMetaQuestTouchController",!1);r(this,"_handJointPoses",new Map);r(this,"_gripMatrix",new h.Matrix4);r(this,"_gripPosition",new h.Vector3);r(this,"_gripQuaternion",new h.Quaternion);r(this,"_linearVelocity",new h.Vector3);r(this,"_rayPositionRaw",new h.Vector3);r(this,"_rayRotationRaw",new h.Quaternion);r(this,"_rayMatrix",new h.Matrix4);r(this,"_rayPosition",new h.Vector3);r(this,"_rayQuaternion",new h.Quaternion);r(this,"_gripWorldPosition",new h.Vector3);r(this,"_gripWorldQuaternion",new h.Quaternion);r(this,"_rayWorldPosition",new h.Vector3);r(this,"_rayWorldQuaternion",new h.Quaternion);r(this,"_pinchPosition",new h.Vector3);r(this,"_ray");r(this,"_hand_wristDotUp");r(this,"_object");r(this,"_gripSpaceObject");r(this,"_raySpaceObject");r(this,"model",null);r(this,"_debugAxesHelper",new h.AxesHelper(.15));r(this,"_debugGripAxesHelper",new h.AxesHelper(.07));r(this,"_debugRayAxesHelper",new h.AxesHelper(.07));r(this,"_hitTestSourcePromise",null);r(this,"onPointerHits",t=>{});r(this,"_needleGamepadButtons",{});r(this,"_buttonMap",new Map);r(this,"_motioncontroller");r(this,"_layout");r(this,"getMotionController");r(this,"emitPointerDownEvent",!0);r(this,"emitPointerUpEvent",!0);r(this,"emitPointerMoveEvent",!0);r(this,"pointerMoveDistanceThreshold",.03);r(this,"pointerMoveAngleThreshold",.05);r(this,"_selectButtonIndex");r(this,"_squeezeButtonIndex");r(this,"onSelectStart",t=>{var n,o,a,l;if(!this.emitPointerDownEvent||this.inputSource!==t.inputSource)return;this.onUpdateFrame(t.frame),this._hasSelectEvent=!0;const e=(n=this._layout)==null?void 0:n.selectComponentId,i=(l=(a=(o=this._layout)==null?void 0:o.components[e])==null?void 0:a.gamepadIndices)==null?void 0:l.button;i!==void 0&&(this._selectButtonIndex=i),!Th&&(yn&&$.DrawDirection(this.rayWorldPosition,V(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(Ee.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,t))});r(this,"onSelectEnd",t=>{this.emitPointerUpEvent&&(Th||this.inputSource===t.inputSource&&this.emitPointerEvent(Ee.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,t))});r(this,"onSequeezeStart",t=>{var e,i,n;this.emitPointerDownEvent&&this.inputSource===t.inputSource&&(this._squeezeButtonIndex=(n=(i=(e=this._layout)==null?void 0:e.components["xr-standard-squeeze"])==null?void 0:i.gamepadIndices)==null?void 0:n.button,this._squeezeButtonIndex!==void 0&&(yn&&$.DrawDirection(this.rayWorldPosition,V(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(Ee.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,t)))});r(this,"onSequeezeEnd",t=>{this.emitPointerUpEvent&&this.inputSource===t.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(Ee.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,t)});r(this,"states",{});r(this,"_didMoveLastFrame",!1);r(this,"_lastPointerMovePosition",new h.Vector3);r(this,"_lastPointerMoveQuaternion",new h.Quaternion);r(this,"pointerInit");this.xr=t,this.inputSource=e,this.index=i,this._object=new h.Object3D,this._object.name=`NeedleXRController_${i}`,yn&&(this._object.add(this._debugAxesHelper),this._gripSpaceObject=new h.Object3D,this._raySpaceObject=new h.Object3D,this._gripSpaceObject.name=`NeedleXRController_${i}_gripSpace`,this._raySpaceObject.name=`NeedleXRController_${i}_raySpace`,this._gripSpaceObject.add(this._debugGripAxesHelper),this._raySpaceObject.add(this._debugRayAxesHelper),this.xr.context.scene.add(this._gripSpaceObject),this.xr.context.scene.add(this._raySpaceObject)),this.xr.context.scene.add(this._object),this._ray=new h.Ray,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents()}get context(){return this.xr.context}get connected(){return this._connected}get isTracking(){return this._isTracking}get gamepad(){return this.__gamepad??(this.__gamepad=this.inputSource.gamepad)}get isHand(){return this.hand!=null}get hand(){return this.__hand??(this.__hand=this.inputSource.hand)}get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.__side??(this.__side=this.inputSource.handedness)}get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get isStylus(){return this._isMxInk}getHitTestSource(){return this._hitTestSource||this._requestHitTestSource(),this._hitTestSource}get hasHitTestSource(){return this._hitTestSource}cancelHitTestSource(){this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=void 0)}get hasSelectEvent(){return this._hasSelectEvent}getHitTest(){return this.xr.getHitTest(this)}getHandJointPose(t,e){var n;if(e=e||this.xr.frame,!this.hand||!(e!=null&&e.getJointPose)||!this.xr.referenceSpace)return null;let i=(n=this._handJointPoses)==null?void 0:n.get(t);return i||(i=e.getJointPose(t,this.xr.referenceSpace),i&&this._handJointPoses.set(t,i),i)}get gripPosition(){return V(this._gripPosition)}get gripQuaternion(){return tn(this._gripQuaternion)}get gripMatrix(){return this._gripMatrix}get gripLinearVelocity(){return V(this._linearVelocity).applyQuaternion(Li)}get rayPosition(){return V(this._rayPosition)}get rayQuaternion(){return tn(this._rayQuaternion)}get gripWorldPosition(){return V(this._gripWorldPosition)}get gripWorldQuaternion(){return tn(this._gripWorldQuaternion)}get rayWorldPosition(){return V(this._rayWorldPosition)}updateRayWorldPosition(){var e;const t=(e=this.xr.context.mainCamera)==null?void 0:e.parent;this._rayWorldPosition.copy(this._rayPositionRaw),t&&this._rayWorldPosition.applyMatrix4(t.matrixWorld)}get rayWorldQuaternion(){return tn(this._rayWorldQuaternion)}get pinchPosition(){return V(this._pinchPosition)}updateRayWorldQuaternion(){var i;const t=(i=this.xr.context.mainCamera)==null?void 0:i.parent,e=t?ge(t):void 0;this._rayWorldQuaternion.copy(this._rayRotationRaw).multiply(Li),e&&this._rayWorldQuaternion.premultiply(e)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(V(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get handWristDotUp(){var e;if(this._hand_wristDotUp!==void 0)return this._hand_wristDotUp;const t=(e=this.handObject)==null?void 0:e.joints.wrist;if(t){const i=V(0,1,0).applyQuaternion(t.quaternion),n=V(0,1,0).dot(i);return this._hand_wristDotUp=n}}get isHandUpsideDown(){return this.handWristDotUp!==void 0?this.handWristDotUp<-.7:!1}get isTeleportGesture(){var t;return this.isHandUpsideDown&&((t=this.getGesture("pinch"))==null?void 0:t.isDown)}get object(){return this._object}async getModelUrl(){var t;return(t=this.getMotionController)==null?void 0:t.then(e=>(e==null?void 0:e.assetUrl)||null)}_requestHitTestSource(){var t;return this._hitTestSourcePromise?this._hitTestSourcePromise:this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&this.xr.session.requestHitTestSourceForTransientInput?this._hitTestSourcePromise=((t=this.xr.session.requestHitTestSourceForTransientInput({profile:this.inputSource.profiles[0],offsetRay:new XRRay}))==null?void 0:t.then(e=>(this._hitTestSourcePromise=null,this.connected?this._hitTestSource=e:(e.cancel(),null))))??null:null}onUpdate(t){performance.mark("NeedleXRController onUpdate start"),this.onUpdateFrame(t),this.updateInputEvents(),this.onUpdateMove(),performance.mark("NeedleXRController onUpdate end"),performance.measure("NeedleXRController onUpdate","NeedleXRController onUpdate start","NeedleXRController onUpdate end")}onRenderDebug(){var o;$.DrawSphere(this.rayWorldPosition,.003),$.DrawDirection(this.rayWorldPosition,V(0,0,10).applyQuaternion(this.rayWorldQuaternion));const e=(this.inputSource.gripSpace?this.gripWorldPosition:this.object.worldPosition).sub(this.object.worldForward.multiplyScalar(.1)),i=this.inputSource.profiles.join(`
135
135
  `);let n=`Controller[${this.index}] (${this.inputSource.targetRayMode}, ${this.side})
136
136
  C:${this.connected?"x":"-"} T:${this.isTracking?"x":"-"} Hand:${this.inputSource.hand?"x":"-"} Pen: ${this._isMxInk?"x":"-"}`;if(this.inputSource.hand&&(n+=`
@@ -751,7 +751,7 @@ vec3 AgXToneMapping( vec3 color ) {
751
751
  </div>
752
752
  `;const i=this.attachShadow({mode:"open"});b0(),Gd(rm,{loadedCallback:()=>{this.handleSizeChange()}}),Gd(rm,{element:i});const n=e.content.cloneNode(!0);i==null||i.appendChild(n),this.root=i.querySelector("#root"),this.wrapper=(f=this.root)==null?void 0:f.querySelector(".wrapper"),this.options=(m=this.root)==null?void 0:m.querySelector(".options"),this.logoContainer=(g=this.root)==null?void 0:g.querySelector(".logo"),this.compactMenuButton=(_=this.root)==null?void 0:_.querySelector(".compact-menu-button"),this.compactMenuButton.append(_t("more_vert")),this.foldout=(y=this.root)==null?void 0:y.querySelector(".foldout"),(b=this.root)==null||b.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const o=v0.create();o.style.minHeight="1rem",this.logoContainer.append(o),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")});try{f1(v=>{if(v==!0&&an()&&!Py){let x=this._userRequestedLogoVisible;x===void 0&&(x=!1),Fo(this,Tc,am).call(this,x)}})}catch(v){console.error("[Needle Menu] License check failed.",v)}this.compactMenuButton.addEventListener("click",v=>{v.preventDefault(),this.root.classList.toggle("open")});let a=this._context;setTimeout(()=>a=this._context);let l=0;const c=(v,x)=>{var M,k,O;Kl&&console.log("Set menu visible",x),a!=null&&a.isInAR&&a.arOverlayElement?v!=a.arOverlayElement&&a.arOverlayElement.appendChild(this):this.parentNode!=((M=this._domElement)==null?void 0:M.shadowRoot)&&((O=(k=this._domElement)==null?void 0:k.shadowRoot)==null||O.appendChild(this)),this.style.display=x?"flex":"none",this.style.visibility="visible",this.style.opacity="1"};let d=!1;new MutationObserver(v=>{var x;if(!d)try{d=!0,this.onChangeDetected(v);const M=this==null?void 0:this.parentNode;if((this.style.display!="flex"||this.style.visibility!="visible"||this.style.opacity!="1"||M!=((x=this._domElement)==null?void 0:x.shadowRoot))&&!an()){const k=l++;$t()&&this._userRequestedMenuVisible===!1?(k===0&&c(M,this._userRequestedMenuVisible),k===1&&console.warn("Needle Menu Warning: You need a PRO license to hide the Needle Engine menu → The menu will be visible in your deployed website if you don't have a PRO license. See https://needle.tools/pricing for details.")):k===0?c(M,!0):setTimeout(()=>c(M,!0),5)}}finally{d=!1}}).observe(this.root,{childList:!0,subtree:!0,attributes:!0}),Kl&&this.___insertDebugOptions()}static create(){return document.createElement(ha,{is:ha})}static getOrCreate(e,i){let n=e.querySelector(ha);return!n&&e.shadowRoot&&(n=e.shadowRoot.querySelector(ha)),n||(n=w_.create(),e.shadowRoot?e.shadowRoot.appendChild(n):e.appendChild(n)),n._domElement=e,n._context=i,n}connectedCallback(){window.addEventListener("resize",this.handleSizeChange),this.handleMenuVisible(),this._sizeChangeInterval=setInterval(()=>this.handleSizeChange(void 0,!0),5e3),setTimeout(()=>{var e,i;(e=this._domElement)==null||e.addEventListener("resize",this.handleSizeChange),(i=this._domElement)==null||i.addEventListener("click",ae(this,Ec))},1)}disconnectedCallback(){var e,i;window.removeEventListener("resize",this.handleSizeChange),clearInterval(this._sizeChangeInterval),(e=this._domElement)==null||e.removeEventListener("resize",this.handleSizeChange),(i=this._context)==null||i.domElement.removeEventListener("click",ae(this,Ec))}showNeedleLogo(e){this._userRequestedLogoVisible=e,!(!e&&(!an()||Py)&&(console.warn("Needle Menu: You need a PRO license to hide the Needle Engine logo."),!$t()))&&Fo(this,Tc,am).call(this,e)}setPosition(e){if(e!=="top"&&e!=="bottom")return console.error("NeedleMenu.setPosition: invalid position",e);this.root.classList.remove("top","bottom"),this.root.classList.add(e)}setVisible(e){this._userRequestedMenuVisible=e,this.style.display=e?"flex":"none"}closeFoldout(){this.root.classList.remove("open")}append(...e){for(const i of e)if(typeof i=="string"){const n=document.createTextNode(i);this.options.appendChild(n)}else this.options.appendChild(i)}appendChild(e){var n;if(!(e instanceof Node)){const o=document.createElement("button");if(o.textContent=e.label,o.onclick=e.onClick,o.setAttribute("priority",((n=e.priority)==null?void 0:n.toString())??"0"),e.title&&(o.title=e.title),e.icon){const a=_t(e.icon);e.iconSide==="right"?o.appendChild(a):o.prepend(a)}e.class&&o.classList.add(e.class),e=o}return this.options.appendChild(e)}prepend(...e){for(const i of e)if(typeof i=="string"){const n=document.createTextNode(i);this.options.prepend(n)}else this.options.prepend(i)}onChangeDetected(e){if(!this._isHandlingChange){this._isHandlingChange=!0;try{this.handleMenuVisible();for(const i of e)i.target==this.options&&this.onOptionsChildrenChanged(i)}finally{this._isHandlingChange=!1}}}onOptionsChildrenChanged(e){if(this.root.classList.toggle("has-options",this.hasAnyVisibleOptions),this.root.classList.toggle("has-no-options",!this.hasAnyVisibleOptions),this.handleSizeChange(void 0,!0),e.type==="childList"&&e.addedNodes.length>0){const i=Array.from(this.options.children);i.sort((o,a)=>{const l=parseInt(o.getAttribute("priority")||"0"),c=parseInt(a.getAttribute("priority")||"0");return l-c});let n=!1;for(let o=0;o<i.length;o++){const a=this.options.children[o],l=i[o];if(a!==l){n=!0;break}}if(n)for(const o of i)this.options.appendChild(o)}}handleMenuVisible(){Kl&&console.log("Update VisibleState: Any Content?",this.hasAnyContent),this.hasAnyContent?this.root.style.display="":this.root.style.display="none",this.root.classList.toggle("has-options",this.hasAnyVisibleOptions),this.root.classList.toggle("has-no-options",!this.hasAnyVisibleOptions)}get hasAnyContent(){return!!(this.logoContainer.style.display!="none"||this.hasAnyVisibleOptions)}get hasAnyVisibleOptions(){for(let e=0;e<this.options.children.length;e++){const i=this.options.children[e];if(i.tagName==="SLOT"){const o=i.assignedNodes();for(const a of o)if(a instanceof HTMLElement&&a.style.display!="none")return!0}else if(i.style.display!="none")return!0}return!1}___insertDebugOptions(){window.addEventListener("keydown",n=>{n.key==="p"&&this.setPosition(this.root.classList.contains("top")?"bottom":"top")});const e=document.createElement("button");e.textContent="Hide Buttons",e.onclick=()=>{const n=new Array(this.options.children.length);for(let o=0;o<this.options.children.length;o++)n[o]=this.options.children[o];for(const o of n)this.options.removeChild(o);setTimeout(()=>{for(const o of n)this.options.appendChild(o)},1e3)},this.appendChild(e);const i=document.createElement("button");i.textContent="Toggle Logo",i.addEventListener("click",()=>{this.logoContainer.style.display=this.logoContainer.style.display==="none"?"":"none"}),this.appendChild(i)}};let Xd=w_;Ec=new WeakMap,Tc=new WeakSet,am=function(e){this.logoContainer.style.display="",this.logoContainer.style.opacity="1",this.logoContainer.style.visibility="visible",e?(this.root.classList.remove("logo-hidden"),this.root.classList.add("logo-visible")):(this.root.classList.remove("logo-visible"),this.root.classList.add("logo-hidden"))};customElements.get(ha)||customElements.define(ha,Xd);const Ge=S("debugcontext"),a1=S("stats"),l1=S("debugactive"),c1=S("debugframerate"),h1=S("debugcoroutine"),d1={};class u1{constructor(){r(this,"name");r(this,"alias");r(this,"hash");r(this,"runInBackground");r(this,"domElement");r(this,"renderer");r(this,"camera");r(this,"scene")}}var _e=(s=>(s[s.Start=-1]="Start",s[s.EarlyUpdate=0]="EarlyUpdate",s[s.Update=1]="Update",s[s.LateUpdate=2]="LateUpdate",s[s.OnBeforeRender=3]="OnBeforeRender",s[s.OnAfterRender=4]="OnAfterRender",s[s.PrePhysicsStep=9]="PrePhysicsStep",s[s.PostPhysicsStep=10]="PostPhysicsStep",s[s.Undefined=-1]="Undefined",s))(_e||{});function ku(s,t){if(!s)return;if(!s.isComponent){(F()||Ge)&&console.error(`Registered script is not a Needle Engine component.
753
753
  The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
754
- `,s);return}t||(t=X.Current,Ge&&console.warn("> Registering component without context"));const e=t==null?void 0:t.new_scripts;e.includes(s)||e.push(s)}const ve=class{constructor(t){r(this,"name");r(this,"alias");r(this,"isManagedExternally",!1);r(this,"isPaused",!1);r(this,"runInBackground",!1);r(this,"targetFrameRate");r(this,"physicsSteps",1);r(this,"hash");r(this,"domElement");r(this,"_resolutionScaleFactor",1);r(this,"_boundingClientRectFrame",-1);r(this,"_boundingClientRect",null);r(this,"_domX");r(this,"_domY");r(this,"xr",null);r(this,"_xrFrame",null);r(this,"_currentFrameEvent",-1);r(this,"scene");r(this,"renderer");r(this,"composer",null);r(this,"scripts",[]);r(this,"scripts_pausedChanged",[]);r(this,"scripts_earlyUpdate",[]);r(this,"scripts_update",[]);r(this,"scripts_lateUpdate",[]);r(this,"scripts_onBeforeRender",[]);r(this,"scripts_onAfterRender",[]);r(this,"scripts_WithCorroutines",[]);r(this,"scripts_immersive_vr",[]);r(this,"scripts_immersive_ar",[]);r(this,"coroutines",{});r(this,"post_setup_callbacks",[]);r(this,"pre_update_callbacks",[]);r(this,"pre_render_callbacks",[]);r(this,"post_render_callbacks",[]);r(this,"pre_update_oneshot_callbacks",[]);r(this,"new_scripts",[]);r(this,"new_script_start",[]);r(this,"new_scripts_pre_setup_callbacks",[]);r(this,"new_scripts_post_setup_callbacks",[]);r(this,"new_scripts_xr",[]);r(this,"mainCameraComponent");r(this,"_mainCamera",null);r(this,"_fallbackCamera",null);r(this,"application");r(this,"animations");r(this,"time");r(this,"input");r(this,"physics");r(this,"connection");r(this,"assets");r(this,"mainLight",null);r(this,"sceneLighting");r(this,"addressables");r(this,"lightmaps");r(this,"players");r(this,"lodsManager");r(this,"menu");r(this,"_sizeChanged",!1);r(this,"_isCreated",!1);r(this,"_isCreating",!1);r(this,"_isVisible",!1);r(this,"_stats",a1?new Q.Stats:null);r(this,"_intersectionObserver",null);r(this,"_disposeCallbacks",[]);r(this,"maxRenderResolution");r(this,"_originalCreationArgs");r(this,"onUnhandledRejection",t=>{this.onError(t.reason)});r(this,"_cameraStack",[]);r(this,"_onBeforeRenderListeners",new Map);r(this,"_onAfterRenderListeners",new Map);r(this,"_requireDepthTexture",!1);r(this,"_requireColorTexture",!1);r(this,"_renderTarget");r(this,"_isRendering",!1);r(this,"_createId",0);r(this,"_renderlooperrors",0);r(this,"_lastTimestamp",0);r(this,"_accumulatedTime",0);r(this,"_dispatchReadyAfterFrame",!1);r(this,"_wasPaused",!1);this.name=(t==null?void 0:t.name)||"",this.alias=t==null?void 0:t.alias,this.domElement=(t==null?void 0:t.domElement)||document.body,this.hash=t==null?void 0:t.hash,t!=null&&t.renderer&&(this.renderer=t.renderer,this.isManagedExternally=!0),(t==null?void 0:t.runInBackground)!==void 0&&(this.runInBackground=t.runInBackground),t!=null&&t.scene?this.scene=t.scene:this.scene=new h.Scene,t!=null&&t.camera&&(this._mainCamera=t.camera),this.application=new rn(this),this.time=new g0,this.input=new dv(this),this.physics=new ba(this),this.connection=new bv(this),this.assets=new Sv,this.sceneLighting=new p0(this),this.addressables=new a0(this),this.lightmaps=new qC(this),this.players=new f0(this),this.menu=new r1(this),this.lodsManager=new XC(this),this.animations=new WC(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const i=new ResizeObserver(n=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(n=>{this._isVisible=n[0].isIntersecting}),this._disposeCallbacks.push(()=>{var n;return(n=this._intersectionObserver)==null?void 0:n.disconnect()}),ce.register(this)}static get DefaultTargetFrameRate(){return ve._defaultTargetFramerate.value}static set DefaultTargetFrameRate(t){ve._defaultTargetFramerate.value=t}static get DefaultWebGLRendererParameters(){return ve._defaultWebglRendererParameters}get version(){return on}static get Current(){return ce.Current}static set Current(t){ce.Current=t}appendHTMLElement(t){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(t):this.domElement.appendChild(t)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(t){if(t!==this._resolutionScaleFactor&&typeof t=="number"){if(t<=0){console.error("Invalid resolution scale factor",t);return}this._resolutionScaleFactor=t,this.updateSize()}}calculateBoundingClientRect(){if(this.xr){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var t,e;return((e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var t;return(t=this.xr)==null?void 0:t.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var t,e;return(e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var t,e;return this.renderer.xr.isPresenting?(e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const t=this.domElement;return typeof t.getAROverlayContainer=="function"?t.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._mainCamera)return this._mainCamera;if(this.mainCameraComponent){const t=this.mainCameraComponent;return t.threeCamera||t.buildCamera(),t.threeCamera}return this._fallbackCamera||(this._fallbackCamera=new h.PerspectiveCamera(75,this.domWidth/this.domHeight,.1,1e3)),this._fallbackCamera}set mainCamera(t){this._mainCamera=t}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(t){var e,i,n;if((e=this.renderer)==null||e.dispose(),t={...ve.DefaultWebGLRendererParameters,...t},!t.canvas){const o=(n=(i=this.domElement)==null?void 0:i.shadowRoot)==null?void 0:n.querySelector("canvas");o&&(t.canvas=o,Ge&&console.log("Using canvas from shadow root",o))}Ge&&console.log("Using Renderer Parameters:",t,this.domElement),this.renderer=new h.WebGLRenderer(t),this.renderer.debug.checkShaderErrors=F()||S("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=h.NoToneMapping,this.renderer.setClearColor(new h.Color("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=h.PCFSoftShadowMap$1,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=h.SRGBColorSpace,this.renderer.nodes={library:new h.BasicNodeLibrary,modelViewMatrix:null,modelNormalViewMatrix:null},this.lodsManager.setRenderer(this.renderer),this.input.bindEvents()}internalOnUpdateVisible(){var t,e;(t=this._intersectionObserver)==null||t.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(t=!1){var e,i,n;if(t||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const o=this.resolutionScaleFactor;let a=this.domWidth*o,l=this.domHeight*o;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),a=Math.min(this.maxRenderResolution.x,a),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),l=Math.min(this.maxRenderResolution.y,l));const c=this.mainCamera;this.updateAspect(c),this.renderer.setSize(a,l,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((i=this.composer.setSize)==null||i.call(this.composer,a,l),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((n=this.composer.setPixelRatio)==null||n.call(this.composer,window.devicePixelRatio)))}}updateAspect(t,e,i){if(!t)return;e===void 0&&(e=this.domWidth),i===void 0&&(i=this.domHeight);const n=t.aspect;t.aspect=e/i,n!==t.aspect&&t.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(t){return this.create(t)}async create(t){try{this._isCreating=!0,t!==this._originalCreationArgs&&(this._originalCreationArgs=Lc(t)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(t);return this._isCreated=e,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}onError(t){this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}clear(){var t,e,i,n;ce.dispatchCallback(he.ContextClearing,this),bn(this,he.ContextClearing),xi(this.scene,!0,!0),this.scene=new h.Scene,(t=this.addressables)==null||t.dispose(),(e=this.lightmaps)==null||e.clear(),(n=(i=this.physics)==null?void 0:i.engine)==null||n.clearCaches(),this.lodsManager.disable(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),ce.dispatchCallback(he.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var t,e;ve.Current=this,ce.dispatchCallback(he.ContextDestroying,this),bn(this,he.ContextDestroying),this.clear(),(t=this.renderer)==null||t.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(Ge&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy(),this.animations.onDestroy();for(const i of this._disposeCallbacks)try{i()}catch(n){console.error("Error in on dispose callback:",n,i)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,ce.dispatchCallback(he.ContextDestroyed,this),bn(this,he.ContextDestroyed),ce.unregister(this),ve.Current===this&&(ve.Current=null)}registerCoroutineUpdate(t,e,i){return typeof(e==null?void 0:e.next)!="function"?(console.error("Registered invalid coroutine function from "+t.name+`
754
+ `,s);return}t||(t=X.Current,Ge&&console.warn("> Registering component without context"));const e=t==null?void 0:t.new_scripts;e.includes(s)||e.push(s)}const ve=class{constructor(t){r(this,"name");r(this,"alias");r(this,"isManagedExternally",!1);r(this,"isPaused",!1);r(this,"runInBackground",!1);r(this,"targetFrameRate");r(this,"physicsSteps",1);r(this,"hash");r(this,"domElement");r(this,"_resolutionScaleFactor",1);r(this,"_boundingClientRectFrame",-1);r(this,"_boundingClientRect",null);r(this,"_domX");r(this,"_domY");r(this,"xr",null);r(this,"_xrFrame",null);r(this,"_currentFrameEvent",-1);r(this,"scene");r(this,"renderer");r(this,"composer",null);r(this,"scripts",[]);r(this,"scripts_pausedChanged",[]);r(this,"scripts_earlyUpdate",[]);r(this,"scripts_update",[]);r(this,"scripts_lateUpdate",[]);r(this,"scripts_onBeforeRender",[]);r(this,"scripts_onAfterRender",[]);r(this,"scripts_WithCorroutines",[]);r(this,"scripts_immersive_vr",[]);r(this,"scripts_immersive_ar",[]);r(this,"coroutines",{});r(this,"post_setup_callbacks",[]);r(this,"pre_update_callbacks",[]);r(this,"pre_render_callbacks",[]);r(this,"post_render_callbacks",[]);r(this,"pre_update_oneshot_callbacks",[]);r(this,"new_scripts",[]);r(this,"new_script_start",[]);r(this,"new_scripts_pre_setup_callbacks",[]);r(this,"new_scripts_post_setup_callbacks",[]);r(this,"new_scripts_xr",[]);r(this,"mainCameraComponent");r(this,"_mainCamera",null);r(this,"_fallbackCamera",null);r(this,"application");r(this,"animations");r(this,"time");r(this,"input");r(this,"physics");r(this,"connection");r(this,"assets");r(this,"mainLight",null);r(this,"sceneLighting");r(this,"addressables");r(this,"lightmaps");r(this,"players");r(this,"lodsManager");r(this,"menu");r(this,"_sizeChanged",!1);r(this,"_isCreated",!1);r(this,"_isCreating",!1);r(this,"_isVisible",!1);r(this,"_stats",a1?new Q.Stats:null);r(this,"_intersectionObserver",null);r(this,"_disposeCallbacks",[]);r(this,"maxRenderResolution");r(this,"_originalCreationArgs");r(this,"onUnhandledRejection",t=>{this.onError(t.reason)});r(this,"_cameraStack",[]);r(this,"_onBeforeRenderListeners",new Map);r(this,"_onAfterRenderListeners",new Map);r(this,"_requireDepthTexture",!1);r(this,"_requireColorTexture",!1);r(this,"_renderTarget");r(this,"_isRendering",!1);r(this,"_createId",0);r(this,"_renderlooperrors",0);r(this,"_lastTimestamp",0);r(this,"_accumulatedTime",0);r(this,"_dispatchReadyAfterFrame",!1);r(this,"_wasPaused",!1);this.name=(t==null?void 0:t.name)||"",this.alias=t==null?void 0:t.alias,this.domElement=(t==null?void 0:t.domElement)||document.body,this.hash=t==null?void 0:t.hash,t!=null&&t.renderer&&(this.renderer=t.renderer,this.isManagedExternally=!0),(t==null?void 0:t.runInBackground)!==void 0&&(this.runInBackground=t.runInBackground),t!=null&&t.scene?this.scene=t.scene:this.scene=new h.Scene,t!=null&&t.camera&&(this._mainCamera=t.camera),this.application=new rn(this),this.time=new g0,this.input=new dv(this),this.physics=new ba(this),this.connection=new bv(this),this.assets=new Sv,this.sceneLighting=new p0(this),this.addressables=new a0(this),this.lightmaps=new qC(this),this.players=new f0(this),this.menu=new r1(this),this.lodsManager=new XC(this),this.animations=new WC(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const i=new ResizeObserver(n=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(n=>{this._isVisible=n[0].isIntersecting}),this._disposeCallbacks.push(()=>{var n;return(n=this._intersectionObserver)==null?void 0:n.disconnect()}),ce.register(this)}static get DefaultTargetFrameRate(){return ve._defaultTargetFramerate.value}static set DefaultTargetFrameRate(t){ve._defaultTargetFramerate.value=t}static get DefaultWebGLRendererParameters(){return ve._defaultWebglRendererParameters}get version(){return on}static get Current(){return ce.Current}static set Current(t){ce.Current=t}appendHTMLElement(t){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(t):this.domElement.appendChild(t)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(t){if(t!==this._resolutionScaleFactor&&typeof t=="number"){if(t<=0){console.error("Invalid resolution scale factor",t);return}this._resolutionScaleFactor=t,this.updateSize()}}calculateBoundingClientRect(){if(this.xr){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var t,e;return((e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var t;return(t=this.xr)==null?void 0:t.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var t,e;return(e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var t,e;return this.renderer.xr.isPresenting?(e=(t=this.renderer)==null?void 0:t.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const t=this.domElement;return typeof t.getAROverlayContainer=="function"?t.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._mainCamera)return this._mainCamera;if(this.mainCameraComponent){const t=this.mainCameraComponent;return t.threeCamera||t.buildCamera(),t.threeCamera}return this._fallbackCamera||(this._fallbackCamera=new h.PerspectiveCamera(75,this.domWidth/this.domHeight,.1,1e3)),this._fallbackCamera}set mainCamera(t){this._mainCamera=t}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(t){var e,i,n;if((e=this.renderer)==null||e.dispose(),t={...ve.DefaultWebGLRendererParameters,...t},!t.canvas){const o=(n=(i=this.domElement)==null?void 0:i.shadowRoot)==null?void 0:n.querySelector("canvas");o&&(t.canvas=o,Ge&&console.log("Using canvas from shadow root",o))}Ge&&console.log("Using Renderer Parameters:",t,this.domElement),this.renderer=new h.WebGLRenderer(t),this.renderer.debug.checkShaderErrors=F()||S("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=h.NoToneMapping,this.renderer.setClearColor(new h.Color("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=h.PCFSoftShadowMap$1,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=h.SRGBColorSpace,this.renderer.nodes={library:new h.BasicNodeLibrary,modelViewMatrix:null,modelNormalViewMatrix:null},this.lodsManager.setRenderer(this.renderer),this.input.bindEvents()}internalOnUpdateVisible(){var t,e;(t=this._intersectionObserver)==null||t.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(t=!1){var e,i,n;if(t||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const o=this.resolutionScaleFactor;let a=this.domWidth*o,l=this.domHeight*o;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),a=Math.min(this.maxRenderResolution.x,a),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),l=Math.min(this.maxRenderResolution.y,l));const c=this.mainCamera;this.updateAspect(c),this.renderer.setSize(a,l,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((i=this.composer.setSize)==null||i.call(this.composer,a,l),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((n=this.composer.setPixelRatio)==null||n.call(this.composer,window.devicePixelRatio)))}}updateAspect(t,e,i){if(!t)return;e===void 0&&(e=this.domWidth),i===void 0&&(i=this.domHeight);const n=e/i;if(t.isPerspectiveCamera){const o=t,a=o.aspect;o.aspect=n,a!==o.aspect&&t.updateProjectionMatrix()}else if(t.isOrthographicCamera){const o=t,a=o.top-o.bottom,c=a*n/2,d=a/2;(o.left!=-c||o.top!=d)&&(o.left=-c,o.right=c,o.top=d,o.bottom=-d,t.updateProjectionMatrix())}}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(t){return this.create(t)}async create(t){try{this._isCreating=!0,t!==this._originalCreationArgs&&(this._originalCreationArgs=Lc(t)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(t);return this._isCreated=e,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}onError(t){this.domElement.dispatchEvent(new CustomEvent("error",{detail:t}))}clear(){var t,e,i,n;ce.dispatchCallback(he.ContextClearing,this),bn(this,he.ContextClearing),xi(this.scene,!0,!0),this.scene=new h.Scene,(t=this.addressables)==null||t.dispose(),(e=this.lightmaps)==null||e.clear(),(n=(i=this.physics)==null?void 0:i.engine)==null||n.clearCaches(),this.lodsManager.disable(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),ce.dispatchCallback(he.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var t,e;ve.Current=this,ce.dispatchCallback(he.ContextDestroying,this),bn(this,he.ContextDestroying),this.clear(),(t=this.renderer)==null||t.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(Ge&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy(),this.animations.onDestroy();for(const i of this._disposeCallbacks)try{i()}catch(n){console.error("Error in on dispose callback:",n,i)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,ce.dispatchCallback(he.ContextDestroyed,this),bn(this,he.ContextDestroyed),ce.unregister(this),ve.Current===this&&(ve.Current=null)}registerCoroutineUpdate(t,e,i){return typeof(e==null?void 0:e.next)!="function"?(console.error("Registered invalid coroutine function from "+t.name+`
755
755
  Coroutine functions must be generators: "*myCoroutine() {...}"
756
756
  Start a coroutine from a component by calling "this.startCoroutine(myCoroutine())"`),e):(this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:t,main:e}),e)}unregisterCoroutineUpdate(t,e){if(!this.coroutines[e])return;const i=this.coroutines[e].findIndex(n=>n.main===t);i>=0&&this.coroutines[e].splice(i,1)}stopAllCoroutinesFrom(t){for(const e in this.coroutines){const i=this.coroutines[e];for(let n=i.length-1;n>=0;n--)i[n].comp===t&&i.splice(n,1)}}setCurrentCamera(t){var n;if(!t)return;if(t.threeCamera||t.buildCamera(),!t.threeCamera){console.warn("Camera component is missing camera",t);return}const e=this._cameraStack.indexOf(t);e>=0&&this._cameraStack.splice(e,1),this._cameraStack.push(t),this.mainCameraComponent=t;const i=t.threeCamera;i.isPerspectiveCamera&&this.updateAspect(i),(n=this.mainCameraComponent)==null||n.applyClearFlagsIfIsActiveCamera()}removeCamera(t){if(!t)return;const e=this._cameraStack.indexOf(t);if(e>=0&&this._cameraStack.splice(e,1),this.mainCameraComponent===t&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(t,e){this._onBeforeRenderListeners.has(t.uuid)||(this._onBeforeRenderListeners.set(t.uuid,[]),t.onBeforeRender=this._createRenderCallbackWrapper(t,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(t.uuid).push(e)}removeBeforeRenderListener(t,e){if(this._onBeforeRenderListeners.has(t.uuid)){const i=this._onBeforeRenderListeners.get(t.uuid),n=i.indexOf(e);n>=0&&i.splice(n,1)}}addAfterRenderListener(t,e){var i;this._onAfterRenderListeners.has(t.uuid)||(this._onAfterRenderListeners.set(t.uuid,[]),t.onAfterRender=this._createRenderCallbackWrapper(t,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(t.uuid))==null||i.push(e)}removeAfterRenderListener(t,e){if(this._onAfterRenderListeners.has(t.uuid)){const i=this._onAfterRenderListeners.get(t.uuid),n=i.indexOf(e);n>=0&&i.splice(n,1)}}_createRenderCallbackWrapper(t,e){return(i,n,o,a,l,c)=>{const d=e.get(t.uuid);if(d)for(let u=0;u<d.length;u++){const f=d[u];f(i,n,o,a,l,c)}}}get isRendering(){return this._isRendering}setRequireDepth(t){this._requireDepthTexture=t}setRequireColor(t){this._requireColorTexture=t}get depthTexture(){var t;return((t=this._renderTarget)==null?void 0:t.depthTexture)||null}get opaqueColorTexture(){var t;return((t=this._renderTarget)==null?void 0:t.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const t=getComputedStyle(this.domElement);return t.visibility!=="hidden"&&t.display!=="none"&&t.opacity!=="0"}async internalOnCreate(t){var l,c,d,u,f,m,g,_;const e=++this._createId;Ge&&console.log("Creating context",this.name,t);const i=globalThis["needle:dependencies:ready"];i instanceof Promise&&(Ge&&console.log("Waiting for dependencies to be ready"),await i.catch(y=>{if(Ge||F()){if(Uc("Needle Engine dependencies failed to load. Please check the console for more details"),y instanceof ReferenceError){let b="YourComponentName";const v=y.message.indexOf("'");if(v>0){const x=y.message.indexOf("'",v+1);if(x>0){const M=y.message.substring(v+1,x);M.length>3&&(b=M)}}console.error(`Needle Engine dependencies failed to load:
757
757
 
@@ -917,7 +917,7 @@ ${e.path}! : AssetReference;
917
917
  Could not find method ${d.method} on object ${f.name}. Please rename ${d.method} to ${y}?
918
918
  `,f[y],`
919
919
  in script: `,f),fe("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
920
- Could not find method ${d.method} on object ${f.name}`,f,typeof f[d.method])};if(typeof f[d.method]!="function"){let y=!1,b=f;for(;b;){const v=Object.getOwnPropertyDescriptor(b,d.method);if(v&&(v.writable===!0||v.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(F()||dt)&&g()}}if(f){let g=d.argument;if(g!==void 0?g=u(g):d.arguments!==void 0&&(g=d.arguments.map(u)),!f[d.method])console.warn(`EventList method not found: "${d.method}" on ${f==null?void 0:f.name}`);else{g!==void 0&&!Array.isArray(g)&&(g=[g]);const y=new En(f,d.method,g,d.enabled);a.push(y)}}else F()&&console.warn("[Debug] EventList: Could not find event listener in scene",d,e.object,t)}const l=new ye(a);dt&&console.log(l);const c=e.target;return c!==void 0&&e.path!==void 0&&l.setEventTarget(e.path,c),l}}}const hP=new cP,Yd=new WeakMap,dP=h.Texture.prototype.clone;h.Texture.prototype.clone=function(){const s=dP.call(this);return Yd.has(s)||Yd.set(s,this),s};class T0 extends $i{constructor(){super([no,h.WebGLRenderTarget])}onSerialize(t,e){}onDeserialize(t,e){if(t instanceof h.Texture&&e.type===no){let i=t;Yd.has(i)&&(i=Yd.get(i)),i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof h.CompressedTexture&&(i.isCompressedTexture=!1,i.format=h.RGBAFormat);const n=new no(i.image.width,i.image.height,{colorSpace:h.LinearSRGBColorSpace});return n.texture=i,n}}}new T0;class A0 extends $i{constructor(){super([URL])}onSerialize(t,e){return null}onDeserialize(t,e){if(typeof t=="string"&&t.length>0)return mo(e.gltfId,t)}}new A0;var uP=Object.defineProperty,fP=Object.getOwnPropertyDescriptor,pP=(s,t,e,i)=>{for(var n=i>1?void 0:i?fP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&uP(t,e,n),n};class Yc extends L{awake(){Jt.createIfNoneExists(this.context)}onEnable(){var t;(t=Jt.get(this.context))==null||t.register(this)}onDisable(){var t;(t=Jt.get(this.context))==null||t.unregister(this)}}class Si extends Yc{constructor(){super(...arguments);r(this,"targets",null);r(this,"raycastHits",[]);r(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Nn),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const i=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=o=>o instanceof h.SkinnedMesh?"continue in children":i?i(o):!0);const n=this.context.physics.raycast(e);return e.testObject=i,n}}pP([p()],Si.prototype,"ignoreSkinnedMeshes",2);class Iu extends Si{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const x_=class extends Yc{performRaycast(t){if(!q.active||!x_.allow||!(t!=null&&t.ray))return null;const e=t.ray.origin,i=.015;return this.context.physics.sphereOverlap(e,i,!1,!0)}};let so=x_;r(so,"allow",!0);class ju{static getObject(t){const e=t[Fi];return e&&(e.isComponent===!0?t=e.gameObject:t=e),t}static isInteractable(t,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),t==null||!t.visible||(t=this.getObject(t),!t.visible))return!1;const i=this.tryFindCanvasGroup(t);if((i==null?void 0:i.isCanvasGroup)===!0&&(e&&(e.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=mr(t,o=>{if(o.isGraphic===!0)return o},!1);return e&&(n==null?void 0:n.isGraphic)===!0&&(e.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(t){if(!t)return null;const e=mr(t,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return e!==void 0?e:this.tryFindCanvasGroup(t.parent)}}function gg(s){const t=s[Fi];return t||(s.parent?gg(s.parent):null)}function mP(s){return s.isUI===!0||typeof s[Fi]=="object"}function Kd(s,t){if(!s)return;const e=s.material;if((e==null?void 0:e.isMaterial)===!0){const i=s.parent;i&&i.isText,e.side=t.doubleSided??!0?h.DoubleSide:h.FrontSide,e.shadowSide=t.doubleSided?h.DoubleSide:h.FrontSide,s.castShadow=t.castShadows?t.castShadows:!1,s.receiveShadow=t.receiveShadows?t.receiveShadows:!1}for(const i of s.children)Kd(i,t)}function ta(s,t,e){s[t]===void 0&&console.warn("Field",t,"is undefined on",s);const i=Proxy.revocable(s[t],{set(a,l,c,d){const u=a[l],f=Reflect.set(a,l,c,d);return e(c,u),f}}),n=i.revoke,o=s[t];return i.revoke=()=>{s[t]=o,n()},s[t]=i.proxy,i}const jy=Symbol("Scheduled action");function gP(s,t,e=_e.OnBeforeRender){let i=s[jy];i||(i=s[jy]={});const n=t.name;i[e]||(i[e]={});const o=i[e];if(o[n])return;function*l(){t==null||t.call(s),o[n]=null}const c=s.startCoroutine(l(),e);o[n]=c}const os=S("debugeventsystem");var dm=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(dm||{});const On=class extends L{constructor(){super();r(this,"raycaster",[]);r(this,"pressedByID",new Map);r(this,"hoveredByID",new Map);r(this,"onPointerEvent",e=>{if(e===void 0||e.propagationStopped||e.defaultPrevented||e.used)return;const i=new Fa(this.context.input,e);this._currentPointerEventName=e.type,i.inputSource=this.context.input,i.isClick=e.isClick,i.isDoubleClick=e.isDoubleClick,i.isDown=e.type==Ee.PointerDown,i.isUp=e.type==Ee.PointerUp,i.isPressed=this.context.input.getPointerPressed(e.pointerId),os&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new Nn;e.hasRay?n.ray=e.ray:n.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const o=this.performRaycast(n);if(o){for(const l of o)l.event=e,e.intersections.push(l);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:o})}os&&i.isClick&&Te("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const a={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),this.handleIntersections(o,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))});r(this,"_sortedHits",[]);r(this,"_testObjectsCache",new Map);r(this,"_currentlyActiveRaycaster",null);r(this,"_currentPointerEventName",null);r(this,"shouldRaycastObject",e=>{var o;let i=null;if(mP(e)&&(i=(o=e[Fi])==null?void 0:o.gameObject),this._testObjectsCache.has(e)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let a=Qd(e,this._currentPointerEventName);if(!a&&i&&(a=Qd(i,this._currentPointerEventName)),a){this._testObjectsCache.set(e,!0);for(const l of e.children)this.shouldRaycastObject_AddToYesCache(l);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});r(this,"_sortingBuffer",[]);r(this,"_noDepthTestingResults",[]);r(this,"out",{});r(this,"_capturedPointer",{});r(this,"pointerEnterSymbol",Symbol("pointerEnter"));r(this,"pointerExitSymbol",Symbol("pointerExit"));r(this,"currentActiveMeshUIComponents",[]);On.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,On.systems.length<=0&&On.systems.push(...C.findObjectsOfType(On,e)));for(const n of On.systems)if(n.context===e)return;const i=new h.Object3D;C.addComponent(i,On),e.scene.add(i)}static get systems(){const e=X.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const i=this._eventSystemMap.get(e);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,i,n=!1){qs.update(e,i,n)}static markUIDirty(e){qs.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){On.systems.splice(On.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!C.findObjectOfType(Yc,this.context)){const i=C.addComponent(this.context.scene,Si);this.raycaster.push(i),(F()||os)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var i;e&&this.raycaster&&!this.raycaster.includes(e)&&((i=this.raycaster)==null||i.push(e))}unregister(e){var n,o;const i=(n=this.raycaster)==null?void 0:n.indexOf(e);i!==void 0&&i!==-1&&((o=this.raycaster)==null||o.splice(i,1))}onEnable(){this.context.input.addEventListener(Ee.PointerDown,this.onPointerEvent),this.context.input.addEventListener(Ee.PointerUp,this.onPointerEvent),this.context.input.addEventListener(Ee.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(Ee.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(Ee.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(Ee.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const i of e.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Nn),e.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(e);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(e,i){i?(e.intersection=i,e.point=i.point,e.normal=i.normal,e.face=i.face,e.distance=i.distance,e.instanceId=i.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,i){var o;if(e!=null&&e.length){e=this.sortCandidates(e);for(const a of e){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,a),this.handleEventOnObject(a.object,i))return!0}}this.assignHitInformation(i,e==null?void 0:e[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((o=this.pressedByID.get(i.pointerId))==null||o.handlers.forEach(a=>this.invokeOnPointerUp(i,a)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<e.length;i++){const n=e[i],o=n.object;if(o.material&&o.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(e,i){if(!this.testIsVisible(e))return i.isClick&&os&&console.log("not allowed",e),!1;if(i.pointerId===void 0)return os&&console.error("Event without pointer can't be handled",i),!1;i.object=e;const n=e.parent,o=i.isClick??!1;let a=null;if(n&&n.isUI){const f=(i.isPressed||i.isClick)??!1;if(n[Fi]){const m=n[Fi].gameObject;if(m){if(!ju.isInteractable(m,this.out))return!1;a=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,f),e=m}}}o&&os&&console.log(this.context.time.frame,e);const l=this.hoveredByID.get(i.pointerId),c=l==null?void 0:l.obj;c!==e&&c&&this.propagatePointerExit(c,l.data,e);const u=this.hoveredByID.get(i.pointerId);if(u?(u.obj=e,u.data=i):this.hoveredByID.set(i.pointerId,{obj:e,data:i}),i.isDown){const f=this.pressedByID.get(i.pointerId);f?(f.obj=e,f.data=i):this.pressedByID.set(i.pointerId,{obj:e,data:i,handlers:new Set})}return(a===null||a.interactable)&&this.handleMainInteraction(e,i,c??null),!0}propagate(e,i){for(;e;)C.foreachComponent(e,n=>{i(n)},!1),e=e.parent}handleMainInteraction(e,i,n){const o=this.pressedByID.get(i.pointerId),a=n!==e;let l=!0;switch(i.event.pointerType){case"mouse":case"touch":const c=this.context.input.getPointerPositionLastFrame(i.pointerId),d=this.context.input.getPointerPosition(i.pointerId);l=c&&!z.approximately(c,d);break}this.propagate(e,c=>{var u;const d=c;d.interactable!==!1&&(!d.activeAndEnabled||!d.enabled||(d.onPointerEnter&&a&&this.handlePointerEnter(d,i),i.isDown&&d.onPointerDown&&(d.onPointerDown(i),o==null||o.handlers.add(d),this.handlePointerCapture(i,d)),d.onPointerMove&&(l&&d.onPointerMove(i),this.handlePointerCapture(i,d)),i.isUp&&(d.onPointerUp&&(this.invokeOnPointerUp(i,d),o==null||o.handlers.delete(d)),d.onPointerExit&&((u=i.event)==null?void 0:u.pointerType)===xu.Touch&&(this.handlePointerExit(d,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&d.onPointerClick&&d.onPointerClick(i)))}),i.isUp&&(o==null||o.handlers.forEach(c=>{this.invokeOnPointerUp(i,c)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(e,i,n){this.propagate(e,o=>{if(!o.gameObject||o.destroyed)return;const a=o;if(a.onPointerExit||a.onPointerEnter){if(n&&this.isChild(n,o.gameObject))return;this.handlePointerExit(a,i)}})}invokeOnPointerUp(e,i){var n;(n=i.onPointerUp)==null||n.call(i,e),this.releasePointerCapture(e,i)}handlePointerEnter(e,i){e.onPointerEnter&&this.updatePointerState(e,i.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(i),this.updatePointerState(e,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,i){e.onPointerExit&&this.updatePointerState(e,i.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(i),this.updatePointerState(e,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,i,n,o){let a=e[n];if(o)return a&&a.includes(i)?!1:(a=a||[],a.push(i),e[n]=a,!0);{if(!a||!a.includes(i))return!1;const l=a.indexOf(i);return l!==-1&&a.splice(l,1),!0}}handlePointerCapture(e,i){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const n=e.pointerId;if(i.onPointerMove){const o=this._capturedPointer[n]||[];o.push(i),this._capturedPointer[n]=o}else F()&&!i.z__warned_no_pointermove&&(i.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,i))}releasePointerCapture(e,i){const n=e.pointerId;if(this._capturedPointer[n]){const o=this._capturedPointer[n].indexOf(i);o!==-1&&(this._capturedPointer[n].splice(o,1),os&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(e){var i;if(e.event.type===Ee.PointerMove){const n=e.pointerId,o=this._capturedPointer[n];if(o){os&&console.log("Captured",n,o);for(let a=0;a<o.length;a++){const l=o[a];if(l.destroyed){o.splice(a,1),a--;continue}(i=l.onPointerMove)==null||i.call(l,e)}}}}isChild(e,i){return!e||!i?!1:e===i?!0:e.parent?this.isChild(e.parent,i):!1}handleMeshUiObjectWithoutShadowDom(e,i){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,i)}handleMeshUIIntersection(e,i){const n=qs.updateState(e,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qs.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const i=this.currentActiveMeshUIComponents[e];qs.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?C.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let Jt=On;r(Jt,"_eventSystemMap",new Map),r(Jt,"didSearchEventSystem",!1);class qs{static markDirty(){this.needsUpdate=!0}static update(t,e,i=!1){if(i){t.update();return}const n=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(n===o.frame)return;o.frame=n;let a=this.needsUpdate||n<1;o.nextUpdate<=n&&(a=!0),a&&(os&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=n+60,t.update());return}this.lastUpdateFrame=[{context:e,frame:n,nextUpdate:n+60}],t.update(),this.needsUpdate=!1}static updateState(t,e){let i=null;if(t&&(i=this.findBlockInParent(t),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const t=this.lastSelected;t&&(this.lastSelected=null,this.resetState(t))}static resetState(t){t&&(this.needsUpdate=!0)}static findBlockInParent(t){return t?t.isBlock?t:this.findBlockInParent(t.parent):null}}r(qs,"lastSelected",null),r(qs,"lastUpdateFrame",[]),r(qs,"needsUpdate",!1);var _P=Object.defineProperty,yP=Object.getOwnPropertyDescriptor,Ae=(s,t,e,i)=>{for(var n=i>1?void 0:i?yP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&_P(t,e,n),n};const zh=S("debugorbit"),Ff=S("freecam"),Nh=S("debugcamerafit"),Vh=S("smoothcam"),bP={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let Uf;class vc extends CustomEvent{constructor(t,e){super("target-reached",{detail:{controls:t,type:e}})}}class ue extends L{constructor(){super(...arguments);r(this,"autoTarget",!0);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"minAzimuthAngle",1/0);r(this,"maxAzimuthAngle",1/0);r(this,"minPolarAngle",0);r(this,"maxPolarAngle",Math.PI);r(this,"enableKeys",!1);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"zoomSpeed",1);r(this,"zoomToCursor",!1);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"clickBackgroundToFitScene",2);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new h.Vector3);r(this,"_lookTargetEndPosition",new h.Vector3);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new h.Vector3);r(this,"_cameraEndPosition",new h.Vector3);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_fovLerpActive",!1);r(this,"_fovLerpStartValue",0);r(this,"_fovLerpEndValue",0);r(this,"_fovLerp01",0);r(this,"_fovLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didSetTarget",0);r(this,"targetElement",null);r(this,"_activePointerEvents");r(this,"_lastTimeClickOnBackground",-1);r(this,"_clickOnBackgroundCount",0);r(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)});r(this,"_onPointerUp",e=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const n=this._activePointerEvents[i];if(n.pointerId===e.pointerId&&n.button===e.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}zh&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});r(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()});r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var i;(i=this.controls)==null||i.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){zh&&console.debug("OrbitControls",this),this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Jt.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(dm.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,i;(e=this._controls)==null||e.dispose(),(i=this._eventSystem)==null||i.removeEventListener(dm.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=C.getComponent(this.gameObject,be);this._camera=e;let i=e==null?void 0:e.threeCamera;if(!i&&this.gameObject instanceof h.PerspectiveCamera&&(i=this.gameObject),i&&zp(i,this,!0),!this._controls&&i instanceof h.PerspectiveCamera){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,o=i==null?void 0:i.quaternion.clone();this._controls=new Q.OrbitControls(i,n),i==null||i.quaternion.copy(o),Uf===void 0&&(Uf={...this._controls.keys});const a=Y(i),l=this.gameObject.worldForward,c=2.5,d=a.clone().sub(l.multiplyScalar(c));this._controls.target.copy(d)}if(this._controls)if(Ff&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,exports.DeviceUtilities.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys)this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement);else try{this._controls.stopListenToKeyEvents()}catch{}this._syncedTransform=C.getComponent(this.gameObject,Vn)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:fi.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:fi.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:fi.Late})}onDisable(){var e;if((e=this._camera)!=null&&e.threeCamera&&zp(this._camera.threeCamera,this,!1),this._controls){this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted);try{this._controls.stopListenToKeyEvents()}catch{}this._startedListeningToKeyEvents=!1}this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n,o,a;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const l=C.getComponent(this.gameObject,be);if(l&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const c=Y(l.threeCamera),d=Math.max(.01,c.length()),u=new h.Vector3(0,0,-d).applyMatrix4(l.threeCamera.matrixWorld);this.setLookTargetPosition(u,!0)}if(!this.setLookTargetFromConstraint()){const c=new Nn;c.screenPoint=new h.Vector2(0,0),c.lineThreshold=.1;const d=this.context.physics.raycast(c);d.length>0&&this.setLookTargetPosition(d[0].point,!0),Nh&&console.log("OrbitControls hits",...d)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new vc(this,"camera"));else{const l=z.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,l)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new vc(this,"lookat"));else{const l=z.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,l)}if(this._fovLerpActive&&this._cameraObject){const l=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)l.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const c=z.easeInOutCubic(this._fovLerp01);l.fov=z.lerp(this._fovLerpStartValue,this._fovLerpEndValue,c)}l.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(l=>l.used),this._controls.keys=this.enableKeys?Uf:bP,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,Ff||(((o=(n=this._camera)==null?void 0:n.threeCamera)==null?void 0:o.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof Vh=="number"||Vh===!0){this._controls.enableDamping=!0;const l=typeof Vh=="number"?Vh:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,l))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Ff&&((a=this.lookAtConstraint)!=null&&a.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),zh&&$.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof h.Object3D))return;const i=Y(e),n=jm(e);this.setTargetFromRaycast(new h.Ray(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(e,i=!1){var n;e&&(e instanceof h.Object3D&&(e=Y(e)),this._cameraEndPosition||(this._cameraEndPosition=new h.Vector3),this._cameraEndPosition.copy(e),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((n=this._cameraObject)==null?void 0:n.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,i=!1){var o;if(!this._controls||typeof e!="number")return;const n=(o=this._camera)==null?void 0:o.threeCamera;n&&(i===!0?n.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=n.fov,this._fovLerpEndValue=e,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,i=!1){this._controls&&e&&(e instanceof h.Object3D&&(e=Y(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,zh&&(console.warn("OrbitControls: setLookTargetPosition",e,i),$.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,i=1){var o;if(!this._controls)return!1;const n=(o=this.lookAtConstraint)==null?void 0:o.sources;if(n&&n.length>0){const a=n[e];if(a)return a.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(e,i){return this.lerpLookTarget(e,i)}lerpLookTarget(e,i){this._controls&&(i>=1?this._controls.target.copy(e):this._controls.target.lerp(e,i))}setTargetFromRaycast(e){if(!this.controls)return;const i=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of i)if(n.distance>0&&C.isActiveInHierarchy(n.object)){const o=gg(n.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(e,i){var D,T;if(this.context.isInXR)return;let n;if(Array.isArray(e)?n=e:e&&"type"in e?n=e.children:e&&"objects"in e&&(n=e==null?void 0:e.objects,i=e),n&&!Array.isArray(n)&&(n=n.children),(!Array.isArray(n)||n&&n.length<=0)&&(n=this.context.scene.children),!Array.isArray(n)||n.length<=0){console.warn("No objects to fit camera to...");return}const o=this._cameraObject,a=this._controls;if(!o||!a){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:l=!1,centerCamera:c="y",cameraNearFar:d="auto",fitOffset:u=1.1,fov:f=o==null?void 0:o.fov}=i,m=new h.Vector3,g=new h.Vector3,_=wi(n,void 0,(T=(D=this._camera)==null?void 0:D.threeCamera)==null?void 0:T.layers),y=_.clone();o.updateMatrixWorld(),o.updateProjectionMatrix(),_.getCenter(g);const b=new h.Vector3;if(_.getSize(b),_.applyMatrix4(o.matrixWorldInverse),_.getSize(m),_.setFromCenterAndSize(g,m),Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn("Camera fit size resultet in NaN",o,_,[...n]);return}if(m.length()<=1e-10){Nh&&console.warn("Camera fit size is zero",_,[...n]);return}const v=i.fov||o.fov,x=2*Math.atan(Math.tan(v*Math.PI/360/2)*o.aspect)/Math.PI*360,M=m.y/(2*Math.atan(Math.PI*v/360)),k=m.x/(2*Math.atan(Math.PI*x/360)),O=u*Math.max(M,k)+m.z/2;Nh&&console.log("Fit camera to objects",{fitHeightDistance:M,fitWidthDistance:k,distance:O,verticalFov:v,horizontalFov:x}),this.maxZoom=O*10,this.minZoom=O*.01;const R=.05,A=g.clone();if(A.y-=m.y*R,this.setLookTargetPosition(A,l),this.setFieldOfView(i.fov,l),this.autoTarget=!1,d==null||d=="auto"){const N=C.findObjectOfType(Hn),K=N?N.radius:0,G=Math.max(b.x,b.y,b.z,K);o.near=O/100,o.far=G+O*10,N&&(this.maxZoom=Math.max(Math.min(this.maxZoom,K*.5),O))}const I=a.getDistance();I<this.minZoom&&(this.minZoom=I*.9),I>this.maxZoom&&(this.maxZoom=I*1.1),o.updateMatrixWorld(),o.updateProjectionMatrix();const E=Y(o),B=g.clone();B.sub(E),c==="y"&&(B.y=0),B.normalize(),B.multiplyScalar(O),c==="y"&&(B.y+=-R*4*O);let j=g.clone().sub(B);if(o.parent&&(j=o.parent.worldToLocal(j)),this.setCameraTargetPosition(j,l),Nh){const N=new h.Box3Helper(_);this.context.scene.add(N),Um(N,Bc(o)),setTimeout(()=>{this.context.scene.remove(N)},1e4),$.DrawWireBox3(y,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",K=>{if(K.code==="KeyF"){let G;this._cameraObject instanceof h.PerspectiveCamera&&(G=Math.random()*Math.random()*170+10),this.fitCamera({objects:n,fitOffset:u,immediate:!1,fov:G})}K.code==="KeyV"&&this._cameraObject instanceof h.PerspectiveCamera&&(this._cameraObject.fov=60)}))}a.update()}}Ae([p()],ue.prototype,"autoTarget",2);Ae([p()],ue.prototype,"autoFit",2);Ae([p()],ue.prototype,"enableRotate",2);Ae([p()],ue.prototype,"autoRotate",2);Ae([p()],ue.prototype,"autoRotateSpeed",2);Ae([p()],ue.prototype,"minAzimuthAngle",2);Ae([p()],ue.prototype,"maxAzimuthAngle",2);Ae([p()],ue.prototype,"minPolarAngle",2);Ae([p()],ue.prototype,"maxPolarAngle",2);Ae([p()],ue.prototype,"enableKeys",2);Ae([p()],ue.prototype,"enableDamping",2);Ae([p()],ue.prototype,"dampingFactor",2);Ae([p()],ue.prototype,"enableZoom",2);Ae([p()],ue.prototype,"minZoom",2);Ae([p()],ue.prototype,"maxZoom",2);Ae([p()],ue.prototype,"zoomSpeed",2);Ae([p()],ue.prototype,"enablePan",2);Ae([p(Cr)],ue.prototype,"lookAtConstraint",2);Ae([p()],ue.prototype,"lookAtConstraint01",2);Ae([p()],ue.prototype,"allowInterrupt",2);Ae([p()],ue.prototype,"middleClickToFocus",2);Ae([p()],ue.prototype,"doubleClickToFocus",2);Ae([p()],ue.prototype,"clickBackgroundToFitScene",2);Ae([p()],ue.prototype,"targetLerpDuration",2);var vP=Object.defineProperty,wP=Object.getOwnPropertyDescriptor,Wt=(s,t,e,i)=>{for(var n=i>1?void 0:i?wP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&vP(t,e,n),n},oo=(s=>(s[s.None=0]="None",s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(oo||{});const $s=S("debugcam"),By=S("debugscreenpointtoray");var rd;const Ll=(rd=class extends L{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_backgroundRotation");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox");r(this,"_frustum");r(this,"_projScreenMatrix",new h.Matrix4)}get isCamera(){return!0}get aspect(){return this._cam instanceof h.PerspectiveCamera?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(t){this._cam instanceof h.PerspectiveCamera&&this._cam.aspect!==t&&(this._cam.aspect=t,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof h.PerspectiveCamera?this._cam.fov:this._fov}set fieldOfView(t){const e=this.fieldOfView!=t;if(this._fov=t,e&&this._cam&&this._cam instanceof h.PerspectiveCamera){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const e=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&(e||this._cam.near!=t)&&(this._cam.near=t,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const e=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&(e||this._cam.far!=t)&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(t){t!==this._backgroundRotation&&(t===void 0?this._backgroundRotation=void 0:this._backgroundRotation=t,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,e,i){const n=this.threeCamera,o=Ll._origin;o.set(t,e,-1),this.context.input.convertScreenspaceToRaycastSpace(o),By&&console.log("screenPointToRay",t.toFixed(2),e.toFixed(2),"now:",o.x.toFixed(2),o.y.toFixed(2),"isInXR:"+this.context.isInXR),o.z=-1,o.unproject(n);const a=Ll._direction.set(o.x,o.y,o.z),l=Y(n);return a.sub(l),a.normalize(),i?(i.set(l,a),i):new h.Ray(l.clone(),a.clone())}getFrustum(){return this._frustum||(this._frustum=new h.Frustum,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new h.Frustum),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(t,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),t===this._projScreenMatrix?t:t.copy(this._projScreenMatrix)}awake(){By&&window.addEventListener("pointerdown",t=>{const e=t.clientX,i=t.clientY;console.log("touch",e.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(e,i),o="#"+Math.floor(Math.random()*16777215).toString(16);$.DrawRay(n.origin,n.direction,o,10)})}onEnable(){$s&&console.log(`Camera enabled: "${this.name}". ClearFlags=${oo[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),SP(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;if(t){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let e=null;if(t?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof h.PerspectiveCamera&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof h.PerspectiveCamera&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new h.PerspectiveCamera(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const i=this.orthographicSize*100;e=new h.OrthographicCamera(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(t){this.context.mainCameraComponent===this&&this.applyClearFlags(t)}applyClearFlags(t){var e;if(!this._cam){$s&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,$s){const i=`Camera "${this.name}" clear flags: ${oo[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(Ll.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||(t==null?void 0:t.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:$s&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:$s&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Ll.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(Qb(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else $s&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new xP(this)),this._skybox.apply()}static backgroundShouldBeTransparent(t){var o,a,l,c;const e=(o=t.renderer.xr)==null?void 0:o.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const i=e.environmentBlendMode;$s&&Te("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return t.isInAR&&i==="opaque"&&((a=navigator.userAgent)!=null&&a.includes("OculusBrowser")||(l=navigator.userAgent)!=null&&l.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))&&(n=!0),e._transparent=n,n}},r(rd,"_origin",new h.Vector3),r(rd,"_direction",new h.Vector3),rd);let be=Ll;Wt([p()],be.prototype,"aspect",1);Wt([p()],be.prototype,"fieldOfView",1);Wt([p()],be.prototype,"nearClipPlane",1);Wt([p()],be.prototype,"farClipPlane",1);Wt([p()],be.prototype,"clearFlags",1);Wt([p()],be.prototype,"orthographic",2);Wt([p()],be.prototype,"orthographicSize",2);Wt([p()],be.prototype,"ARBackgroundAlpha",2);Wt([p()],be.prototype,"cullingMask",1);Wt([p()],be.prototype,"backgroundBlurriness",1);Wt([p()],be.prototype,"backgroundIntensity",1);Wt([p(h.Euler)],be.prototype,"backgroundRotation",1);Wt([p()],be.prototype,"environmentIntensity",1);Wt([p(pe)],be.prototype,"backgroundColor",1);Wt([p(no)],be.prototype,"targetTexture",1);class xP{constructor(t){r(this,"_camera");r(this,"_skybox");this._camera=t}get context(){var t;return(t=this._camera)==null?void 0:t.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&($s&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=h.EquirectangularReflectionMapping,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function SP(s){S("freecam")&&s.context.mainCameraComponent===s&&C.getOrAddComponent(s.gameObject,ue)}class ro extends L{constructor(){super(...arguments);r(this,"_listener",null);r(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new h.AudioListener),this._listener}onEnable(){rn.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){rn.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const i=this.context.mainCameraComponent||C.getComponentInParent(this.gameObject,be);i!=null&&i.threeCamera?i.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var CP=Object.defineProperty,PP=Object.getOwnPropertyDescriptor,un=(s,t,e,i)=>{for(var n=i>1?void 0:i?PP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&CP(t,e,n),n};const Rt=S("debugaudio"),Ws=class extends L{constructor(){super(...arguments);r(this,"clip","");r(this,"playOnAwake",!1);r(this,"preload",!1);r(this,"playInBackground",!0);r(this,"_spatialBlend",0);r(this,"_minDistance",1);r(this,"_maxDistance",100);r(this,"_volume",1);r(this,"rollOffMode",0);r(this,"_loop",!1);r(this,"sound",null);r(this,"helper",null);r(this,"wasPlaying",!1);r(this,"audioLoader",null);r(this,"shouldPlay",!1);r(this,"_lastClipStartedLoading",null);r(this,"_audioElement",null);r(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Rt&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,Ws.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&Ws.userInteractionRegistered&&this.wasPlaying&&this.play();break}});r(this,"onApplicationMuteChanged",()=>{var t,e;this.context.application.muted?(t=this.sound)==null||t.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});r(this,"createAudio",t=>{Rt&&console.log("AudioBuffer finished loading",t);const e=this.Sound;if(!e){Rt&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),t&&e.setBuffer(t),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&Ws.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),Ws.registerWaitForAllowAudio(this.__onAllowAudioCallback)});r(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});r(this,"_lastContextTime",0);r(this,"_hasEnded",!0);r(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return rn.userInteractionRegistered}static registerWaitForAllowAudio(t){rn.registerWaitForInteraction(t)}get isPlaying(){var t;return((t=this.sound)==null?void 0:t.isPlaying)??!1}get duration(){var t,e;return(e=(t=this.sound)==null?void 0:t.buffer)==null?void 0:e.duration}get time01(){var e;const t=this.duration;return t&&this.sound?((e=this.sound)==null?void 0:e.context.currentTime)/t:0}set time01(t){const e=this.duration;e&&this.sound&&(this.time=t*e)}get time(){var t,e;return(t=this.sound)!=null&&t.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(t){if(this.sound){if(t===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=t,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(t){this._loop=t,this.sound&&this.sound.setLoop(t)}get spatialBlend(){return this._spatialBlend}set spatialBlend(t){t!==this._spatialBlend&&(this._spatialBlend=t,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(t){this._minDistance!==t&&(this._minDistance=t,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(t){this._maxDistance!==t&&(this._maxDistance=t,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.sound&&!this.context.application.muted&&(Rt&&console.log(this.name,"audio set volume",t),this.sound.setVolume(t))}set pitch(t){this.sound&&this.sound.setPlaybackRate(t)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var t;if(!this.sound&&Ws.userInteractionRegistered){let e=C.getComponent(this.context.mainCamera,ro)??C.findObjectOfType(ro,this.context);!e&&this.context.mainCamera&&(e=C.addComponent(this.context.mainCamera,ro)),e!=null&&e.listener?(this.sound=new h.PositionalAudio(e.listener),(t=this.gameObject)==null||t.add(this.sound)):Rt&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var t;return(t=this.sound)==null?void 0:t.context}awake(){Rt&&console.log(this),this.audioLoader=new h.AudioLoader,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),Ws.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():Ws.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(Vd.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(Vd.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const t=this.sound;if(!t)return;this._needUpdateSpatialDistanceSettings=!1;const e=z.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Rt&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),t.setRefDistance(e),t.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:t.setDistanceModel("exponential");break;case 1:t.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Rt&&!this.helper&&(this.helper=new Q.PositionalAudioHelper(t,t.getRefDistance()),t.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(t){if(t&&(this.clip=t),typeof t=="string")if(Rt&&console.log(t),t.endsWith(".mp3")||t.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new h.AudioLoader),this.shouldPlay=!0,this._lastClipStartedLoading===t){Rt&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=t,Rt&&console.log("load audio",t);const e=await this.audioLoader.loadAsync(t).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",t);else this.shouldPlay=!0,this.createAudio()}play(t=void 0){var i,n,o;!t&&this.clip&&(t=this.clip),t!==void 0&&typeof t!="string"&&!(t instanceof MediaStream)&&(F()&&console.warn("Called play on AudioSource with unknown argument type:",t+`
920
+ Could not find method ${d.method} on object ${f.name}`,f,typeof f[d.method])};if(typeof f[d.method]!="function"){let y=!1,b=f;for(;b;){const v=Object.getOwnPropertyDescriptor(b,d.method);if(v&&(v.writable===!0||v.set)){y=!0;break}b=Object.getPrototypeOf(b)}!y&&(F()||dt)&&g()}}if(f){let g=d.argument;if(g!==void 0?g=u(g):d.arguments!==void 0&&(g=d.arguments.map(u)),!f[d.method])console.warn(`EventList method not found: "${d.method}" on ${f==null?void 0:f.name}`);else{g!==void 0&&!Array.isArray(g)&&(g=[g]);const y=new En(f,d.method,g,d.enabled);a.push(y)}}else F()&&console.warn("[Debug] EventList: Could not find event listener in scene",d,e.object,t)}const l=new ye(a);dt&&console.log(l);const c=e.target;return c!==void 0&&e.path!==void 0&&l.setEventTarget(e.path,c),l}}}const hP=new cP,Yd=new WeakMap,dP=h.Texture.prototype.clone;h.Texture.prototype.clone=function(){const s=dP.call(this);return Yd.has(s)||Yd.set(s,this),s};class T0 extends $i{constructor(){super([no,h.WebGLRenderTarget])}onSerialize(t,e){}onDeserialize(t,e){if(t instanceof h.Texture&&e.type===no){let i=t;Yd.has(i)&&(i=Yd.get(i)),i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof h.CompressedTexture&&(i.isCompressedTexture=!1,i.format=h.RGBAFormat);const n=new no(i.image.width,i.image.height,{colorSpace:h.LinearSRGBColorSpace});return n.texture=i,n}}}new T0;class A0 extends $i{constructor(){super([URL])}onSerialize(t,e){return null}onDeserialize(t,e){if(typeof t=="string"&&t.length>0)return mo(e.gltfId,t)}}new A0;var uP=Object.defineProperty,fP=Object.getOwnPropertyDescriptor,pP=(s,t,e,i)=>{for(var n=i>1?void 0:i?fP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&uP(t,e,n),n};class Yc extends L{awake(){Jt.createIfNoneExists(this.context)}onEnable(){var t;(t=Jt.get(this.context))==null||t.register(this)}onDisable(){var t;(t=Jt.get(this.context))==null||t.unregister(this)}}class Si extends Yc{constructor(){super(...arguments);r(this,"targets",null);r(this,"raycastHits",[]);r(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Nn),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const i=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=o=>o instanceof h.SkinnedMesh?"continue in children":i?i(o):!0);const n=this.context.physics.raycast(e);return e.testObject=i,n}}pP([p()],Si.prototype,"ignoreSkinnedMeshes",2);class Iu extends Si{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const x_=class extends Yc{performRaycast(t){if(!q.active||!x_.allow||!(t!=null&&t.ray))return null;const e=t.ray.origin,i=.015;return this.context.physics.sphereOverlap(e,i,!1,!0)}};let so=x_;r(so,"allow",!0);class ju{static getObject(t){const e=t[Fi];return e&&(e.isComponent===!0?t=e.gameObject:t=e),t}static isInteractable(t,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),t==null||!t.visible||(t=this.getObject(t),!t.visible))return!1;const i=this.tryFindCanvasGroup(t);if((i==null?void 0:i.isCanvasGroup)===!0&&(e&&(e.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const n=mr(t,o=>{if(o.isGraphic===!0)return o},!1);return e&&(n==null?void 0:n.isGraphic)===!0&&(e.graphic=n),!((n==null?void 0:n.raycastTarget)===!1||(n==null?void 0:n.layer)===2)}static tryFindCanvasGroup(t){if(!t)return null;const e=mr(t,i=>{const n=i;if(n.blocksRaycasts!==void 0&&n.interactable!==void 0)return n},!1);return e!==void 0?e:this.tryFindCanvasGroup(t.parent)}}function gg(s){const t=s[Fi];return t||(s.parent?gg(s.parent):null)}function mP(s){return s.isUI===!0||typeof s[Fi]=="object"}function Kd(s,t){if(!s)return;const e=s.material;if((e==null?void 0:e.isMaterial)===!0){const i=s.parent;i&&i.isText,e.side=t.doubleSided??!0?h.DoubleSide:h.FrontSide,e.shadowSide=t.doubleSided?h.DoubleSide:h.FrontSide,s.castShadow=t.castShadows?t.castShadows:!1,s.receiveShadow=t.receiveShadows?t.receiveShadows:!1}for(const i of s.children)Kd(i,t)}function ta(s,t,e){s[t]===void 0&&console.warn("Field",t,"is undefined on",s);const i=Proxy.revocable(s[t],{set(a,l,c,d){const u=a[l],f=Reflect.set(a,l,c,d);return e(c,u),f}}),n=i.revoke,o=s[t];return i.revoke=()=>{s[t]=o,n()},s[t]=i.proxy,i}const jy=Symbol("Scheduled action");function gP(s,t,e=_e.OnBeforeRender){let i=s[jy];i||(i=s[jy]={});const n=t.name;i[e]||(i[e]={});const o=i[e];if(o[n])return;function*l(){t==null||t.call(s),o[n]=null}const c=s.startCoroutine(l(),e);o[n]=c}const os=S("debugeventsystem");var dm=(s=>(s.BeforeHandleInput="BeforeHandleInput",s.AfterHandleInput="AfterHandleInput",s))(dm||{});const On=class extends L{constructor(){super();r(this,"raycaster",[]);r(this,"pressedByID",new Map);r(this,"hoveredByID",new Map);r(this,"onPointerEvent",e=>{if(e===void 0||e.propagationStopped||e.defaultPrevented||e.used)return;const i=new Fa(this.context.input,e);this._currentPointerEventName=e.type,i.inputSource=this.context.input,i.isClick=e.isClick,i.isDoubleClick=e.isDoubleClick,i.isDown=e.type==Ee.PointerDown,i.isUp=e.type==Ee.PointerUp,i.isPressed=this.context.input.getPointerPressed(e.pointerId),os&&(i.isDown?console.log("DOWN",i.pointerId):i.isUp&&console.log("UP",i.pointerId),i.isClick&&console.log("CLICK",i.pointerId));const n=new Nn;e.hasRay?n.ray=e.ray:n.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const o=this.performRaycast(n);if(o){for(const l of o)l.event=e,e.intersections.push(l);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:o})}os&&i.isClick&&Te("EventSystem: "+i.pointerId+" - "+this.context.time.frame+" - Up:"+i.isUp+", Down:"+i.isDown);const a={sender:this,args:i,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),this.handleIntersections(o,i),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))});r(this,"_sortedHits",[]);r(this,"_testObjectsCache",new Map);r(this,"_currentlyActiveRaycaster",null);r(this,"_currentPointerEventName",null);r(this,"shouldRaycastObject",e=>{var o;let i=null;if(mP(e)&&(i=(o=e[Fi])==null?void 0:o.gameObject),this._testObjectsCache.has(e)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let a=Qd(e,this._currentPointerEventName);if(!a&&i&&(a=Qd(i,this._currentPointerEventName)),a){this._testObjectsCache.set(e,!0);for(const l of e.children)this.shouldRaycastObject_AddToYesCache(l);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});r(this,"_sortingBuffer",[]);r(this,"_noDepthTestingResults",[]);r(this,"out",{});r(this,"_capturedPointer",{});r(this,"pointerEnterSymbol",Symbol("pointerEnter"));r(this,"pointerExitSymbol",Symbol("pointerExit"));r(this,"currentActiveMeshUIComponents",[]);On.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,On.systems.length<=0&&On.systems.push(...C.findObjectsOfType(On,e)));for(const n of On.systems)if(n.context===e)return;const i=new h.Object3D;C.addComponent(i,On),e.scene.add(i)}static get systems(){const e=X.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const i=this._eventSystemMap.get(e);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,i,n=!1){qs.update(e,i,n)}static markUIDirty(e){qs.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){On.systems.splice(On.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!C.findObjectOfType(Yc,this.context)){const i=C.addComponent(this.context.scene,Si);this.raycaster.push(i),(F()||os)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var i;e&&this.raycaster&&!this.raycaster.includes(e)&&((i=this.raycaster)==null||i.push(e))}unregister(e){var n,o;const i=(n=this.raycaster)==null?void 0:n.indexOf(e);i!==void 0&&i!==-1&&((o=this.raycaster)==null||o.splice(i,1))}onEnable(){this.context.input.addEventListener(Ee.PointerDown,this.onPointerEvent),this.context.input.addEventListener(Ee.PointerUp,this.onPointerEvent),this.context.input.addEventListener(Ee.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(Ee.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(Ee.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(Ee.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const i of e.children)this.shouldRaycastObject_AddToYesCache(i)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Nn),e.testObject=this.shouldRaycastObject;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;this._currentlyActiveRaycaster=i;const n=i.performRaycast(e);this._currentlyActiveRaycaster=null,n&&n.length>0&&this._sortedHits.push(...n)}return this._sortedHits.sort((i,n)=>i.distance-n.distance),this._sortedHits}assignHitInformation(e,i){i?(e.intersection=i,e.point=i.point,e.normal=i.normal,e.face=i.face,e.distance=i.distance,e.instanceId=i.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,i){var o;if(e!=null&&e.length){e=this.sortCandidates(e);for(const a of e){if(i.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(i,a),this.handleEventOnObject(a.object,i))return!0}}this.assignHitInformation(i,e==null?void 0:e[0]),this.invokePointerCapture(i);const n=this.hoveredByID.get(i.pointerId);return n&&this.propagatePointerExit(n.obj,n.data,null),this.hoveredByID.delete(i.pointerId),i.isUp&&((o=this.pressedByID.get(i.pointerId))==null||o.handlers.forEach(a=>this.invokeOnPointerUp(i,a)),this.pressedByID.delete(i.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<e.length;i++){const n=e[i],o=n.object;if(o.material&&o.material.depthTest===!1){this._noDepthTestingResults.push(n);continue}this._sortingBuffer.push(n)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(e,i){if(!this.testIsVisible(e))return i.isClick&&os&&console.log("not allowed",e),!1;if(i.pointerId===void 0)return os&&console.error("Event without pointer can't be handled",i),!1;i.object=e;const n=e.parent,o=i.isClick??!1;let a=null;if(n&&n.isUI){const f=(i.isPressed||i.isClick)??!1;if(n[Fi]){const m=n[Fi].gameObject;if(m){if(!ju.isInteractable(m,this.out))return!1;a=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,f),e=m}}}o&&os&&console.log(this.context.time.frame,e);const l=this.hoveredByID.get(i.pointerId),c=l==null?void 0:l.obj;c!==e&&c&&this.propagatePointerExit(c,l.data,e);const u=this.hoveredByID.get(i.pointerId);if(u?(u.obj=e,u.data=i):this.hoveredByID.set(i.pointerId,{obj:e,data:i}),i.isDown){const f=this.pressedByID.get(i.pointerId);f?(f.obj=e,f.data=i):this.pressedByID.set(i.pointerId,{obj:e,data:i,handlers:new Set})}return(a===null||a.interactable)&&this.handleMainInteraction(e,i,c??null),!0}propagate(e,i){for(;e;)C.foreachComponent(e,n=>{i(n)},!1),e=e.parent}handleMainInteraction(e,i,n){const o=this.pressedByID.get(i.pointerId),a=n!==e;let l=!0;switch(i.event.pointerType){case"mouse":case"touch":const c=this.context.input.getPointerPositionLastFrame(i.pointerId),d=this.context.input.getPointerPosition(i.pointerId);l=c&&!z.approximately(c,d);break}this.propagate(e,c=>{var u;const d=c;d.interactable!==!1&&(!d.activeAndEnabled||!d.enabled||(d.onPointerEnter&&a&&this.handlePointerEnter(d,i),i.isDown&&d.onPointerDown&&(d.onPointerDown(i),o==null||o.handlers.add(d),this.handlePointerCapture(i,d)),d.onPointerMove&&(l&&d.onPointerMove(i),this.handlePointerCapture(i,d)),i.isUp&&(d.onPointerUp&&(this.invokeOnPointerUp(i,d),o==null||o.handlers.delete(d)),d.onPointerExit&&((u=i.event)==null?void 0:u.pointerType)===xu.Touch&&(this.handlePointerExit(d,i),this.hoveredByID.delete(i.pointerId))),i.isClick&&d.onPointerClick&&d.onPointerClick(i)))}),i.isUp&&(o==null||o.handlers.forEach(c=>{this.invokeOnPointerUp(i,c)}),this.pressedByID.delete(i.pointerId))}propagatePointerExit(e,i,n){this.propagate(e,o=>{if(!o.gameObject||o.destroyed)return;const a=o;if(a.onPointerExit||a.onPointerEnter){if(n&&this.isChild(n,o.gameObject))return;this.handlePointerExit(a,i)}})}invokeOnPointerUp(e,i){var n;(n=i.onPointerUp)==null||n.call(i,e),this.releasePointerCapture(e,i)}handlePointerEnter(e,i){e.onPointerEnter&&this.updatePointerState(e,i.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(i),this.updatePointerState(e,i.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,i){e.onPointerExit&&this.updatePointerState(e,i.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(i),this.updatePointerState(e,i.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,i,n,o){let a=e[n];if(o)return a&&a.includes(i)?!1:(a=a||[],a.push(i),e[n]=a,!0);{if(!a||!a.includes(i))return!1;const l=a.indexOf(i);return l!==-1&&a.splice(l,1),!0}}handlePointerCapture(e,i){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const n=e.pointerId;if(i.onPointerMove){const o=this._capturedPointer[n]||[];o.push(i),this._capturedPointer[n]=o}else F()&&!i.z__warned_no_pointermove&&(i.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,i))}releasePointerCapture(e,i){const n=e.pointerId;if(this._capturedPointer[n]){const o=this._capturedPointer[n].indexOf(i);o!==-1&&(this._capturedPointer[n].splice(o,1),os&&console.log("released pointer capture",n,i,this._capturedPointer))}}invokePointerCapture(e){var i;if(e.event.type===Ee.PointerMove){const n=e.pointerId,o=this._capturedPointer[n];if(o){os&&console.log("Captured",n,o);for(let a=0;a<o.length;a++){const l=o[a];if(l.destroyed){o.splice(a,1),a--;continue}(i=l.onPointerMove)==null||i.call(l,e)}}}}isChild(e,i){return!e||!i?!1:e===i?!0:e.parent?this.isChild(e.parent,i):!1}handleMeshUiObjectWithoutShadowDom(e,i){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,i)}handleMeshUIIntersection(e,i){const n=qs.updateState(e,i);return n&&this.currentActiveMeshUIComponents.push(n),n!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qs.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const i=this.currentActiveMeshUIComponents[e];qs.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?C.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let Jt=On;r(Jt,"_eventSystemMap",new Map),r(Jt,"didSearchEventSystem",!1);class qs{static markDirty(){this.needsUpdate=!0}static update(t,e,i=!1){if(i){t.update();return}const n=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(n===o.frame)return;o.frame=n;let a=this.needsUpdate||n<1;o.nextUpdate<=n&&(a=!0),a&&(os&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=n+60,t.update());return}this.lastUpdateFrame=[{context:e,frame:n,nextUpdate:n+60}],t.update(),this.needsUpdate=!1}static updateState(t,e){let i=null;if(t&&(i=this.findBlockInParent(t),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const t=this.lastSelected;t&&(this.lastSelected=null,this.resetState(t))}static resetState(t){t&&(this.needsUpdate=!0)}static findBlockInParent(t){return t?t.isBlock?t:this.findBlockInParent(t.parent):null}}r(qs,"lastSelected",null),r(qs,"lastUpdateFrame",[]),r(qs,"needsUpdate",!1);var _P=Object.defineProperty,yP=Object.getOwnPropertyDescriptor,Ae=(s,t,e,i)=>{for(var n=i>1?void 0:i?yP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&_P(t,e,n),n};const zh=S("debugorbit"),Ff=S("freecam"),Nh=S("debugcamerafit"),Vh=S("smoothcam"),bP={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let Uf;class vc extends CustomEvent{constructor(t,e){super("target-reached",{detail:{controls:t,type:e}})}}class ue extends L{constructor(){super(...arguments);r(this,"autoTarget",!0);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"minAzimuthAngle",1/0);r(this,"maxAzimuthAngle",1/0);r(this,"minPolarAngle",0);r(this,"maxPolarAngle",Math.PI);r(this,"enableKeys",!1);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"zoomSpeed",1);r(this,"zoomToCursor",!1);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"clickBackgroundToFitScene",2);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new h.Vector3);r(this,"_lookTargetEndPosition",new h.Vector3);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new h.Vector3);r(this,"_cameraEndPosition",new h.Vector3);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_fovLerpActive",!1);r(this,"_fovLerpStartValue",0);r(this,"_fovLerpEndValue",0);r(this,"_fovLerp01",0);r(this,"_fovLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didSetTarget",0);r(this,"targetElement",null);r(this,"_activePointerEvents");r(this,"_lastTimeClickOnBackground",-1);r(this,"_clickOnBackgroundCount",0);r(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)});r(this,"_onPointerUp",e=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const n=this._activePointerEvents[i];if(n.pointerId===e.pointerId&&n.button===e.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}zh&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});r(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()});r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))});r(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var i;(i=this.controls)==null||i.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){zh&&console.debug("OrbitControls",this),this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Jt.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(dm.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,i;(e=this._controls)==null||e.dispose(),(i=this._eventSystem)==null||i.removeEventListener(dm.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=C.getComponent(this.gameObject,be);this._camera=e;let i=e==null?void 0:e.threeCamera;if(!i&&this.gameObject instanceof h.PerspectiveCamera&&(i=this.gameObject),i&&zp(i,this,!0),!this._controls&&i instanceof h.Object3D){this._cameraObject=i;const n=this.targetElement??this.context.renderer.domElement,o=i==null?void 0:i.quaternion.clone();this._controls=new Q.OrbitControls(i,n),i==null||i.quaternion.copy(o),Uf===void 0&&(Uf={...this._controls.keys});const a=Y(i),l=this.gameObject.worldForward,c=2.5,d=a.clone().sub(l.multiplyScalar(c));this._controls.target.copy(d)}if(this._controls)if(Ff&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,exports.DeviceUtilities.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys)this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement);else try{this._controls.stopListenToKeyEvents()}catch{}this._syncedTransform=C.getComponent(this.gameObject,Vn)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:fi.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:fi.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:fi.Late})}onDisable(){var e;if((e=this._camera)!=null&&e.threeCamera&&zp(this._camera.threeCamera,this,!1),this._controls){this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted);try{this._controls.stopListenToKeyEvents()}catch{}this._startedListeningToKeyEvents=!1}this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,n,o,a;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((i=this.context.input.getPointerPositionDelta(0))!=null&&i.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const l=C.getComponent(this.gameObject,be);if(l&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const c=Y(l.threeCamera),d=Math.max(.01,c.length()),u=new h.Vector3(0,0,-d).applyMatrix4(l.threeCamera.matrixWorld);this.setLookTargetPosition(u,!0)}if(!this.setLookTargetFromConstraint()){const c=new Nn;c.screenPoint=new h.Vector2(0,0),c.lineThreshold=.1;const d=this.context.physics.raycast(c);d.length>0&&this.setLookTargetPosition(d[0].point,!0),Nh&&console.log("OrbitControls hits",...d)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new vc(this,"camera"));else{const l=z.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,l)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new vc(this,"lookat"));else{const l=z.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,l)}if(this._fovLerpActive&&this._cameraObject){const l=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)l.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const c=z.easeInOutCubic(this._fovLerp01);l.fov=z.lerp(this._fovLerpStartValue,this._fovLerpEndValue,c)}l.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(l=>l.used),this._controls.keys=this.enableKeys?Uf:bP,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,Ff||(((o=(n=this._camera)==null?void 0:n.threeCamera)==null?void 0:o.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof Vh=="number"||Vh===!0){this._controls.enableDamping=!0;const l=typeof Vh=="number"?Vh:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,l))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Ff&&((a=this.lookAtConstraint)!=null&&a.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),zh&&$.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof h.Object3D))return;const i=Y(e),n=jm(e);this.setTargetFromRaycast(new h.Ray(i,n)),this.setCameraTargetPosition(i)}setCameraTargetPosition(e,i=!1){var n;e&&(e instanceof h.Object3D&&(e=Y(e)),this._cameraEndPosition||(this._cameraEndPosition=new h.Vector3),this._cameraEndPosition.copy(e),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((n=this._cameraObject)==null?void 0:n.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,i=!1){var o;if(!this._controls||typeof e!="number")return;const n=(o=this._camera)==null?void 0:o.threeCamera;n&&(i===!0?n.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=n.fov,this._fovLerpEndValue=e,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,i=!1){this._controls&&e&&(e instanceof h.Object3D&&(e=Y(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,zh&&(console.warn("OrbitControls: setLookTargetPosition",e,i),$.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,i=1){var o;if(!this._controls)return!1;const n=(o=this.lookAtConstraint)==null?void 0:o.sources;if(n&&n.length>0){const a=n[e];if(a)return a.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(e,i){return this.lerpLookTarget(e,i)}lerpLookTarget(e,i){this._controls&&(i>=1?this._controls.target.copy(e):this._controls.target.lerp(e,i))}setTargetFromRaycast(e){if(!this.controls)return;const i=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of i)if(n.distance>0&&C.isActiveInHierarchy(n.object)){const o=gg(n.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}this.setLookTargetPosition(n.point);break}}fitCamera(e,i){var D,T;if(this.context.isInXR)return;let n;if(Array.isArray(e)?n=e:e&&"type"in e?n=e.children:e&&"objects"in e&&(n=e==null?void 0:e.objects,i=e),n&&!Array.isArray(n)&&(n=n.children),(!Array.isArray(n)||n&&n.length<=0)&&(n=this.context.scene.children),!Array.isArray(n)||n.length<=0){console.warn("No objects to fit camera to...");return}const o=this._cameraObject,a=this._controls;if(!o||!a){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:l=!1,centerCamera:c="y",cameraNearFar:d="auto",fitOffset:u=1.1,fov:f=o==null?void 0:o.fov}=i,m=new h.Vector3,g=new h.Vector3,_=wi(n,void 0,(T=(D=this._camera)==null?void 0:D.threeCamera)==null?void 0:T.layers),y=_.clone();o.updateMatrixWorld(),o.updateProjectionMatrix(),_.getCenter(g);const b=new h.Vector3;if(_.getSize(b),_.applyMatrix4(o.matrixWorldInverse),_.getSize(m),_.setFromCenterAndSize(g,m),Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn("Camera fit size resultet in NaN",o,_,[...n]);return}if(m.length()<=1e-10){Nh&&console.warn("Camera fit size is zero",_,[...n]);return}const v=i.fov||o.fov,x=2*Math.atan(Math.tan(v*Math.PI/360/2)*o.aspect)/Math.PI*360,M=m.y/(2*Math.atan(Math.PI*v/360)),k=m.x/(2*Math.atan(Math.PI*x/360)),O=u*Math.max(M,k)+m.z/2;Nh&&console.log("Fit camera to objects",{fitHeightDistance:M,fitWidthDistance:k,distance:O,verticalFov:v,horizontalFov:x}),this.maxZoom=O*10,this.minZoom=O*.01;const R=.05,A=g.clone();if(A.y-=m.y*R,this.setLookTargetPosition(A,l),this.setFieldOfView(i.fov,l),this.autoTarget=!1,d==null||d=="auto"){const N=C.findObjectOfType(Hn),K=N?N.radius:0,G=Math.max(b.x,b.y,b.z,K);o.near=O/100,o.far=G+O*10,N&&(this.maxZoom=Math.max(Math.min(this.maxZoom,K*.5),O))}const I=a.getDistance();I<this.minZoom&&(this.minZoom=I*.9),I>this.maxZoom&&(this.maxZoom=I*1.1),o.updateMatrixWorld(),o.updateProjectionMatrix();const E=Y(o),B=g.clone();B.sub(E),c==="y"&&(B.y=0),B.normalize(),B.multiplyScalar(O),c==="y"&&(B.y+=-R*4*O);let j=g.clone().sub(B);if(o.parent&&(j=o.parent.worldToLocal(j)),this.setCameraTargetPosition(j,l),Nh){const N=new h.Box3Helper(_);this.context.scene.add(N),Um(N,Bc(o)),setTimeout(()=>{this.context.scene.remove(N)},1e4),$.DrawWireBox3(y,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",K=>{if(K.code==="KeyF"){let G;this._cameraObject instanceof h.PerspectiveCamera&&(G=Math.random()*Math.random()*170+10),this.fitCamera({objects:n,fitOffset:u,immediate:!1,fov:G})}K.code==="KeyV"&&this._cameraObject instanceof h.PerspectiveCamera&&(this._cameraObject.fov=60)}))}a.update()}}Ae([p()],ue.prototype,"autoTarget",2);Ae([p()],ue.prototype,"autoFit",2);Ae([p()],ue.prototype,"enableRotate",2);Ae([p()],ue.prototype,"autoRotate",2);Ae([p()],ue.prototype,"autoRotateSpeed",2);Ae([p()],ue.prototype,"minAzimuthAngle",2);Ae([p()],ue.prototype,"maxAzimuthAngle",2);Ae([p()],ue.prototype,"minPolarAngle",2);Ae([p()],ue.prototype,"maxPolarAngle",2);Ae([p()],ue.prototype,"enableKeys",2);Ae([p()],ue.prototype,"enableDamping",2);Ae([p()],ue.prototype,"dampingFactor",2);Ae([p()],ue.prototype,"enableZoom",2);Ae([p()],ue.prototype,"minZoom",2);Ae([p()],ue.prototype,"maxZoom",2);Ae([p()],ue.prototype,"zoomSpeed",2);Ae([p()],ue.prototype,"enablePan",2);Ae([p(Cr)],ue.prototype,"lookAtConstraint",2);Ae([p()],ue.prototype,"lookAtConstraint01",2);Ae([p()],ue.prototype,"allowInterrupt",2);Ae([p()],ue.prototype,"middleClickToFocus",2);Ae([p()],ue.prototype,"doubleClickToFocus",2);Ae([p()],ue.prototype,"clickBackgroundToFitScene",2);Ae([p()],ue.prototype,"targetLerpDuration",2);var vP=Object.defineProperty,wP=Object.getOwnPropertyDescriptor,Wt=(s,t,e,i)=>{for(var n=i>1?void 0:i?wP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&vP(t,e,n),n},oo=(s=>(s[s.None=0]="None",s[s.Skybox=1]="Skybox",s[s.SolidColor=2]="SolidColor",s[s.Uninitialized=4]="Uninitialized",s))(oo||{});const $s=S("debugcam"),By=S("debugscreenpointtoray");var rd;const Ll=(rd=class extends L{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_backgroundRotation");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox");r(this,"_frustum");r(this,"_projScreenMatrix",new h.Matrix4)}get isCamera(){return!0}get aspect(){return this._cam instanceof h.PerspectiveCamera?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(t){this._cam instanceof h.PerspectiveCamera&&this._cam.aspect!==t&&(this._cam.aspect=t,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof h.PerspectiveCamera?this._cam.fov:this._fov}set fieldOfView(t){const e=this.fieldOfView!=t;if(this._fov=t,e&&this._cam&&this._cam instanceof h.PerspectiveCamera){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(t){const e=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&(e||this._cam.near!=t)&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const e=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&(e||this._cam.far!=t)&&(this._cam.far=t,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(t){t!==this._backgroundRotation&&(t===void 0?this._backgroundRotation=void 0:this._backgroundRotation=t,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,e,i){const n=this.threeCamera,o=Ll._origin;o.set(t,e,-1),this.context.input.convertScreenspaceToRaycastSpace(o),By&&console.log("screenPointToRay",t.toFixed(2),e.toFixed(2),"now:",o.x.toFixed(2),o.y.toFixed(2),"isInXR:"+this.context.isInXR),o.z=-1,o.unproject(n);const a=Ll._direction.set(o.x,o.y,o.z),l=Y(n);return a.sub(l),a.normalize(),i?(i.set(l,a),i):new h.Ray(l.clone(),a.clone())}getFrustum(){return this._frustum||(this._frustum=new h.Frustum,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new h.Frustum),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(t,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),t===this._projScreenMatrix?t:t.copy(this._projScreenMatrix)}awake(){By&&window.addEventListener("pointerdown",t=>{const e=t.clientX,i=t.clientY;console.log("touch",e.toFixed(2),i.toFixed(2));const n=this.screenPointToRay(e,i),o="#"+Math.floor(Math.random()*16777215).toString(16);$.DrawRay(n.origin,n.direction,o,10)})}onEnable(){$s&&console.log(`Camera enabled: "${this.name}". ClearFlags=${oo[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),SP(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const t=this.context.renderer;if(t){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let e=null;if(t?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof h.PerspectiveCamera&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof h.PerspectiveCamera&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new h.PerspectiveCamera(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const i=this.orthographicSize*100;e=new h.OrthographicCamera(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(t){this.context.mainCameraComponent===this&&this.applyClearFlags(t)}applyClearFlags(t){var e;if(!this._cam){$s&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,$s){const i=`Camera "${this.name}" clear flags: ${oo[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(Ll.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||(t==null?void 0:t.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:$s&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:$s&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Ll.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(Qb(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else $s&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new xP(this)),this._skybox.apply()}static backgroundShouldBeTransparent(t){var o,a,l,c;const e=(o=t.renderer.xr)==null?void 0:o.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const i=e.environmentBlendMode;$s&&Te("Environment blend mode: "+i+" on "+navigator.userAgent);let n=i==="additive"||i==="alpha-blend";return t.isInAR&&i==="opaque"&&((a=navigator.userAgent)!=null&&a.includes("OculusBrowser")||(l=navigator.userAgent)!=null&&l.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))&&(n=!0),e._transparent=n,n}},r(rd,"_origin",new h.Vector3),r(rd,"_direction",new h.Vector3),rd);let be=Ll;Wt([p()],be.prototype,"aspect",1);Wt([p()],be.prototype,"fieldOfView",1);Wt([p()],be.prototype,"nearClipPlane",1);Wt([p()],be.prototype,"farClipPlane",1);Wt([p()],be.prototype,"clearFlags",1);Wt([p()],be.prototype,"orthographic",2);Wt([p()],be.prototype,"orthographicSize",2);Wt([p()],be.prototype,"ARBackgroundAlpha",2);Wt([p()],be.prototype,"cullingMask",1);Wt([p()],be.prototype,"backgroundBlurriness",1);Wt([p()],be.prototype,"backgroundIntensity",1);Wt([p(h.Euler)],be.prototype,"backgroundRotation",1);Wt([p()],be.prototype,"environmentIntensity",1);Wt([p(pe)],be.prototype,"backgroundColor",1);Wt([p(no)],be.prototype,"targetTexture",1);class xP{constructor(t){r(this,"_camera");r(this,"_skybox");this._camera=t}get context(){var t;return(t=this._camera)==null?void 0:t.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&($s&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=h.EquirectangularReflectionMapping,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function SP(s){S("freecam")&&s.context.mainCameraComponent===s&&C.getOrAddComponent(s.gameObject,ue)}class ro extends L{constructor(){super(...arguments);r(this,"_listener",null);r(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new h.AudioListener),this._listener}onEnable(){rn.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){rn.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const i=this.context.mainCameraComponent||C.getComponentInParent(this.gameObject,be);i!=null&&i.threeCamera?i.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var CP=Object.defineProperty,PP=Object.getOwnPropertyDescriptor,un=(s,t,e,i)=>{for(var n=i>1?void 0:i?PP(t,e):t,o=s.length-1,a;o>=0;o--)(a=s[o])&&(n=(i?a(t,e,n):a(n))||n);return i&&n&&CP(t,e,n),n};const Rt=S("debugaudio"),Ws=class extends L{constructor(){super(...arguments);r(this,"clip","");r(this,"playOnAwake",!1);r(this,"preload",!1);r(this,"playInBackground",!0);r(this,"_spatialBlend",0);r(this,"_minDistance",1);r(this,"_maxDistance",100);r(this,"_volume",1);r(this,"rollOffMode",0);r(this,"_loop",!1);r(this,"sound",null);r(this,"helper",null);r(this,"wasPlaying",!1);r(this,"audioLoader",null);r(this,"shouldPlay",!1);r(this,"_lastClipStartedLoading",null);r(this,"_audioElement",null);r(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||exports.DeviceUtilities.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Rt&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,Ws.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&Ws.userInteractionRegistered&&this.wasPlaying&&this.play();break}});r(this,"onApplicationMuteChanged",()=>{var t,e;this.context.application.muted?(t=this.sound)==null||t.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});r(this,"createAudio",t=>{Rt&&console.log("AudioBuffer finished loading",t);const e=this.Sound;if(!e){Rt&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),t&&e.setBuffer(t),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&Ws.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),Ws.registerWaitForAllowAudio(this.__onAllowAudioCallback)});r(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});r(this,"_lastContextTime",0);r(this,"_hasEnded",!0);r(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return rn.userInteractionRegistered}static registerWaitForAllowAudio(t){rn.registerWaitForInteraction(t)}get isPlaying(){var t;return((t=this.sound)==null?void 0:t.isPlaying)??!1}get duration(){var t,e;return(e=(t=this.sound)==null?void 0:t.buffer)==null?void 0:e.duration}get time01(){var e;const t=this.duration;return t&&this.sound?((e=this.sound)==null?void 0:e.context.currentTime)/t:0}set time01(t){const e=this.duration;e&&this.sound&&(this.time=t*e)}get time(){var t,e;return(t=this.sound)!=null&&t.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(t){if(this.sound){if(t===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=t,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(t){this._loop=t,this.sound&&this.sound.setLoop(t)}get spatialBlend(){return this._spatialBlend}set spatialBlend(t){t!==this._spatialBlend&&(this._spatialBlend=t,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(t){this._minDistance!==t&&(this._minDistance=t,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(t){this._maxDistance!==t&&(this._maxDistance=t,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.sound&&!this.context.application.muted&&(Rt&&console.log(this.name,"audio set volume",t),this.sound.setVolume(t))}set pitch(t){this.sound&&this.sound.setPlaybackRate(t)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var t;if(!this.sound&&Ws.userInteractionRegistered){let e=C.getComponent(this.context.mainCamera,ro)??C.findObjectOfType(ro,this.context);!e&&this.context.mainCamera&&(e=C.addComponent(this.context.mainCamera,ro)),e!=null&&e.listener?(this.sound=new h.PositionalAudio(e.listener),(t=this.gameObject)==null||t.add(this.sound)):Rt&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var t;return(t=this.sound)==null?void 0:t.context}awake(){Rt&&console.log(this),this.audioLoader=new h.AudioLoader,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),Ws.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():Ws.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(Vd.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(Vd.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const t=this.sound;if(!t)return;this._needUpdateSpatialDistanceSettings=!1;const e=z.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Rt&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),t.setRefDistance(e),t.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:t.setDistanceModel("exponential");break;case 1:t.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Rt&&!this.helper&&(this.helper=new Q.PositionalAudioHelper(t,t.getRefDistance()),t.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(t){if(t&&(this.clip=t),typeof t=="string")if(Rt&&console.log(t),t.endsWith(".mp3")||t.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new h.AudioLoader),this.shouldPlay=!0,this._lastClipStartedLoading===t){Rt&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=t,Rt&&console.log("load audio",t);const e=await this.audioLoader.loadAsync(t).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",t);else this.shouldPlay=!0,this.createAudio()}play(t=void 0){var i,n,o;!t&&this.clip&&(t=this.clip),t!==void 0&&typeof t!="string"&&!(t instanceof MediaStream)&&(F()&&console.warn("Called play on AudioSource with unknown argument type:",t+`
921
921
  Using the assigned clip instead:`,this.clip),t=this.clip);let e=!this.sound||t&&t!==this.clip;if(typeof t=="string"&&!this.audioLoader&&(e=!0),(t instanceof MediaStream||typeof t=="string")&&(this.clip=t),e){this.shouldPlay=!0,this.onNewClip(t);return}if(this.shouldPlay=!0,this._hasEnded=!1,Rt&&console.log("play",(i=this.sound)==null?void 0:i.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const a=this.context.application.muted;a&&this.sound.setVolume(0),(n=this.gameObject)==null||n.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(o=this.context.domElement.shadowRoot)==null||o.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(a?.1:0))}}pause(){var t,e;Rt&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(t=this.sound)==null?void 0:t.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var t,e;Rt&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(t=this.sound)==null?void 0:t.context.currentTime,Rt&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,Rt&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let je=Ws;un([p(URL)],je.prototype,"clip",2);un([p()],je.prototype,"playOnAwake",2);un([p()],je.prototype,"preload",2);un([p()],je.prototype,"playInBackground",2);un([p()],je.prototype,"loop",1);un([p()],je.prototype,"spatialBlend",1);un([p()],je.prototype,"minDistance",1);un([p()],je.prototype,"maxDistance",1);un([p()],je.prototype,"volume",1);un([p()],je.prototype,"pitch",1);un([p()],je.prototype,"rollOffMode",2);const OP=S("debugavatar"),Zi=class extends L{constructor(){super(...arguments);r(this,"connectionId");r(this,"avatar")}static getAvatar(e){return e>=0&&e<Zi.instances.length?Zi.instances[e]:null}static onAvatarMarkerCreated(e){return Zi._onNewAvatarMarkerAdded.push(e),e}static onAvatarMarkerDestroyed(e){return Zi._onAvatarMarkerDestroyed.push(e),e}awake(){Zi.instances.push(this),OP&&console.log(this);for(const e of Zi._onNewAvatarMarkerAdded)e({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Zi.instances.splice(Zi.instances.indexOf(this),1);for(const e of Zi._onAvatarMarkerDestroyed)e({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let nt=Zi;r(nt,"instances",[]),r(nt,"_onNewAvatarMarkerAdded",[]),r(nt,"_onAvatarMarkerDestroyed",[]);class Fn{static Add(t,e,i=null){if(e){for(const n of this.Pois)if(n.obj===e)return;this.Pois.push({obj:e,avatar:i}),this.LastChangeTime=t.time.time}}static Remove(t,e){var i;if(e){for(const n of this.Pois)if(n.obj===e){this.Pois.splice(this.Pois.indexOf(n),1),this.LastChangeTime=(t==null?void 0:t.time.time)??((i=X.Current)==null?void 0:i.time.time);return}}}}r(Fn,"Pois",[]),r(Fn,"LastChangeTime",0);class MP{constructor(){r(this,"guid");r(this,"position",new h.Vector3)}}class wc extends L{constructor(){super(...arguments);r(this,"target",null);r(this,"avatar",null);r(this,"_model",null);r(this,"_targetModel",new MP);r(this,"_currentTargetObject",null);r(this,"_lastUpdateTime",0);r(this,"_lookDuration",0);r(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const i=w.get("MoveRandom");if(i&&this.target){const n=C.getComponent(this.target,i);n&&n.destroy()}}awake(){if(this.avatar=C.getComponentInParent(this.gameObject,nt),this.avatar){const e=C.getComponentInParent(this.gameObject,nt);this._model=new Ym(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var i;this.target&&e&&e.guid===((i=this.avatar)==null?void 0:i.guid)&&st(this.target,e.position)})}update(){var i;if((!this.context.connection.isConnected||(i=this._model)!=null&&i.hasOwnership)&&(Fn.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=Fn.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const n=Y(this._currentTargetObject);st(this.target,n),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(n))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const i=Fn.Pois;if(i.length>0){const n=i[Math.floor(Math.random()*i.length)];if(n&&n.obj){if(n.avatar&&n.avatar===this.avatar)return;this._currentTargetObject=n.obj}}}}}function D0(s){return s&&s.isComponent}const RP=Symbol("object"),zf=new vi(()=>new h.Vector3,20);class L0{constructor(t,e,i,n,o,a){r(this,"_point");r(this,"_normal");r(this,"_tangentVelocity");r(this,"distance");r(this,"impulse");r(this,"friction");this._point=t,this.distance=e,this._normal=i,this.impulse=n,this.friction=o,this._tangentVelocity=a}get point(){return zf.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return zf.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return zf.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class I0{constructor(t,e,i){r(this,"contacts");r(this,"me");r(this,"_collider");r(this,"_gameObject");this.me=t,this._collider=e,this._gameObject=e.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var t;return(t=this.collider)==null?void 0:t.attachedRigidbody}}class j0{constructor(t,e){r(this,"object");r(this,"collider");this.object=t,this.collider=e}}const He=S("debugnetworkingstreams");var Ln=(s=>(s.Connected="peer-user-connected",s.StreamReceived="receive-stream",s.StreamEnded="call-ended",s.Disconnected="peer-user-disconnected",s.UserJoined="user-joined",s))(Ln||{});class _g{constructor(t,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=t,this.direction=e}}class B0{constructor(t,e,i){r(this,"type","receive-stream");r(this,"userId");r(this,"stream");r(this,"target");this.userId=t,this.stream=e,this.target=i}}class kP{constructor(t,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=t.id,this.peerId=e}}var F0=(s=>(s.Incoming="incoming",s.Outgoing="outgoing",s))(F0||{});class EP extends h.EventDispatcher{constructor(e,i,n,o=null){super();r(this,"peerId");r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.peerId=i.peer,this.userId=e,this.call=i,this.direction=n,this._stream=o,i.on("stream",a=>{if(He&&console.log("Receive stream",`
922
922
  Audio:`,a.getAudioTracks(),`
923
923
  Video:`,a.getVideoTracks()),this._stream=a,n==="incoming"){const l=new B0(e,a,this);this.dispatchEvent(l)}}),i.on("close",()=>{this.dispatchEvent(new _g(e,n))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),In(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen||this._isDisposed}}function Fy(s){return s=s.replace("a=fmtp:111 minptime=10;useinbandfec=1","a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1"),s}const pa=class extends h.EventDispatcher{constructor(e,i){super();r(this,"updateCalls",()=>{var e;for(let i=this._incomingCalls.length-1;i>=0;i--){const n=this._incomingCalls[i];n.isClosed&&!n.isOpening&&this._incomingCalls.splice(i,1)}for(let i=this._outgoingCalls.length-1;i>=0;i--){const n=this._outgoingCalls[i];let o=!1;n.isClosed&&!n.isOpening&&((e=n.stream)!=null&&e.active?He&&console.warn("!!! Stream is still active, don't remove call",n.userId,"Your id: "+this.context.connection.connectionId):(He&&console.warn("!!! Remove closed call",n.userId),o=!0)),this.context.connection.userIsInRoom(n.userId)===!1&&(He&&console.warn("!!! User is not in room anymore, remove call",n.userId),o=!0),o&&(n.close(),this._outgoingCalls.splice(i,1))}});r(this,"id");r(this,"context");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_peer");r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnect",e=>{if(He&&console.log("PEER opened as",e),e===null){console.error("Peer connection failed",e);return}this.context.connection.send("peer-user-connected",new kP(this,e))});r(this,"onPeerClose",()=>{He&&console.log("PEER closed"),this.updateCalls()});r(this,"onPeerDisconnected",()=>{He&&console.log("PEER disconnected"),this.updateCalls()});r(this,"onPeerError",e=>{He&&console.error("PEER error",e)});r(this,"onPeerReceivingCall",e=>{e.answer(void 0,{sdpTransform:i=>Fy(i)}),this.registerCall(e,"incoming",null)});this.context=e,this.id=i,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,i){if(pa.instances.has(i))return pa.instances.get(i);const n=new pa(e,i);return pa.instances.set(i,n),n}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,i){var a;if(!(i!=null&&i.id)){He?console.warn("Can not make a call: mediastream has no id or is undefined"):console.debug("Can not make a call: mediastream has no id or is undefined");return}const n={metadata:{userId:this.context.connection.connectionId,streamId:i.id},sdpTransform:l=>Fy(l)},o=(a=this._peer)==null?void 0:a.call(e,i,n);if(o){const l=this.registerCall(o,"outgoing",i);return He&&console.warn(`📞 CALL ${e}`,`
@@ -1,6 +1,6 @@
1
1
  /// <reference types="webxr" />
2
2
  import type { EffectComposer } from "postprocessing";
3
- import { BufferGeometry, Camera, DepthTexture, Group, Material, Object3D, PerspectiveCamera, Scene, Texture, WebGLRenderer, type WebGLRendererParameters, type WebXRArrayCamera } from 'three';
3
+ import { BufferGeometry, Camera, DepthTexture, Group, Material, Object3D, OrthographicCamera, PerspectiveCamera, Scene, Texture, WebGLRenderer, type WebGLRendererParameters, type WebXRArrayCamera } from 'three';
4
4
  import { Addressables } from './engine_addressables.js';
5
5
  import { AnimationsRegistry } from './engine_animation.js';
6
6
  import { Application } from './engine_application.js';
@@ -262,7 +262,7 @@ export declare class Context implements IContext {
262
262
  maxRenderResolution?: Vec2;
263
263
  /** update the renderer and canvas size */
264
264
  updateSize(force?: boolean): void;
265
- updateAspect(camera: PerspectiveCamera, width?: number, height?: number): void;
265
+ updateAspect(camera: PerspectiveCamera | OrthographicCamera, width?: number, height?: number): void;
266
266
  /** This will recreate the whole needle engine context and dispose the whole scene content
267
267
  * All content will be reloaded (loading times might be faster due to browser caches)
268
268
  * All scripts will be recreated */