@needle-tools/engine 4.3.2-beta.1 → 4.3.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/needle-engine.bundle.js +95 -14
- package/dist/needle-engine.bundle.light.js +95 -14
- package/dist/needle-engine.bundle.light.min.js +5 -5
- package/dist/needle-engine.bundle.light.umd.cjs +5 -5
- package/dist/needle-engine.bundle.min.js +5 -5
- package/dist/needle-engine.bundle.umd.cjs +5 -5
- package/lib/engine/engine_context.d.ts +2 -1
- package/lib/engine/engine_context.js +1 -1
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_gizmos.d.ts +84 -3
- package/lib/engine/engine_gizmos.js +88 -7
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_texture.d.ts +2 -1
- package/lib/engine/engine_texture.js.map +1 -1
- package/lib/engine/engine_tonemapping.js +2 -2
- package/package.json +1 -1
- package/src/engine/engine_context.ts +3 -2
- package/src/engine/engine_gizmos.ts +89 -8
- package/src/engine/engine_texture.ts +3 -2
- package/src/engine/engine_tonemapping.ts +2 -2
|
@@ -130,7 +130,7 @@ Open this page to get the console: `+t.toString())}const s=X.isMobileDevice()||X
|
|
|
130
130
|
#__vconsole .vc-mask {
|
|
131
131
|
overflow: hidden;
|
|
132
132
|
}
|
|
133
|
-
`,Qi?.prepend(n),s===!0&&Bm()<=0&&cb(),console.log("\u{1F335} Debug console has loaded")}},t.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),hc=!1,hi=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function bP(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(i){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let o=globalThis["needle:codegen_files"][0];const r=o.indexOf("?");r>-1&&(o=o.substring(0,r));const l=location.protocol+"//"+location.host+location.pathname+"/"+o,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(h)}),s.on("show",function(){const i=t();i&&i.src!==s.fullUrl&&(i.src=s.fullUrl)}),s.on("hide",function(){const i=t();i&&(i.src="")}),s.on("addTopBar",function(i){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(o){window.open(s.fullUrl,"_blank"),hi?.hide()}}),n.push({name:"Reload",onClick:function(o){const r=t();r&&(r.src=s.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(o){const r=t();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),i(n)}),s}function _P(){return document.querySelector("#__vconsole .vc-switch")||null}function wP(){return document.querySelector("#__vconsole")||null}const pb=O("debugdefines");mo('if(!globalThis[""4.3.2-beta.
|
|
133
|
+
`,Qi?.prepend(n),s===!0&&Bm()<=0&&cb(),console.log("\u{1F335} Debug console has loaded")}},t.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),hc=!1,hi=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function bP(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(i){const n=globalThis["needle:codegen_files"];if(!n||n.length===0)return;let o=globalThis["needle:codegen_files"][0];const r=o.indexOf("?");r>-1&&(o=o.substring(0,r));const l=location.protocol+"//"+location.host+location.pathname+"/"+o,c=encodeURIComponent(l);s.fullUrl="https://viewer.needle.tools?inspect&file="+c;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(h)}),s.on("show",function(){const i=t();i&&i.src!==s.fullUrl&&(i.src=s.fullUrl)}),s.on("hide",function(){const i=t();i&&(i.src="")}),s.on("addTopBar",function(i){var n=new Array;n.push({name:"Open in new window \u2197",onClick:function(o){window.open(s.fullUrl,"_blank"),hi?.hide()}}),n.push({name:"Reload",onClick:function(o){const r=t();r&&(r.src=s.fullUrl)}}),n.push({name:"Fullscreen",onClick:function(o){const r=t();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),i(n)}),s}function _P(){return document.querySelector("#__vconsole .vc-switch")||null}function wP(){return document.querySelector("#__vconsole")||null}const pb=O("debugdefines");mo('if(!globalThis[""4.3.2-beta.3""]) globalThis[""4.3.2-beta.3""] = "0.0.0";'),mo('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),mo('if(!globalThis[""Tue Mar 18 2025 15:17:13 GMT+0100 (Central European Standard Time)""]) globalThis[""Tue Mar 18 2025 15:17:13 GMT+0100 (Central European Standard Time)""] = "unknown";'),mo('if(!globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""]) globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""] = "unknown";'),mo('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.3.2-beta.3";'),mo('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),mo('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Mar 18 2025 15:17:13 GMT+0100 (Central European Standard Time)";'),mo('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006";');const _s="4.3.2-beta.3",Ad="undefined",sg="Tue Mar 18 2025 15:17:13 GMT+0100 (Central European Standard Time)";pb&&console.log(`Engine version: ${_s} (generator: ${Ad})
|
|
134
134
|
Project built at ${sg}`);const uc="npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006",On="needle_isActiveInHierarchy",br="builtin_components",pc="needle_editor_guid";function mo(s){try{(0,eval)(s)}catch(t){pb&&console.error(t)}}const xP='<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>',SP=btoa(xP),CP="data:image/svg+xml;base64,"+SP,OP=CP,PP=`<?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(PP);const kP='<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>',MP=btoa(kP),RP="data:image/svg+xml;charset=utf-8;base64,"+MP,TP=RP,EP=O("debugpatch");function Id(s,t,i,n){const o=EP===t;if(!i&&!n)return;const r=t+"___needle";IP(s,t,i,n);const l=Object.getOwnPropertyDescriptor(s,t),c=s[t];o&&console.log("Patch",s.constructor.name,t,l,c),l?(o&&console.log("Apply patch with existing descriptor",s.constructor.name,t,l),typeof l.value=="function"&&(s[t]=gb(l.value,s,t))):(o&&console.log("Create patch with new property",s.constructor.name,t,l),Object.defineProperty(s,t,{set:function(h){if(typeof h=="function")this[r]=gb(h,s,t);else{const d=this[r];fb(s,t,this,d,h),this[r]=h,yb(s,t,this,d,h)}},get:function(){const h=this[r];return typeof h=="function"&&h[r]?h[r]:h}}))}function AP(s,t,i){const n=og(s,t);if(n)for(let o=n.length-1;o>=0;o--){const r=n[o];r.prefix===i&&(r.prefix=null),r.postfix===i&&(r.postfix=null),!r.prefix&&!r.postfix&&n.splice(o,1)}}const mb=Symbol("Needle:Patches:WrappedFunction");function gb(s,t,i){if(s[mb])return s;const n=function(...o){fb(t,i,this,...o);const r=s.apply(this,o);return yb(t,i,this,r,...o),r};return n[mb]=!0,n}const jd="Needle:Patches";function ng(){return globalThis[jd]||(globalThis[jd]=new WeakMap),globalThis[jd]}function og(s,t){const i=ng().get(s);return i?i.get(t):null}function IP(s,t,i,n){let o=ng().get(s);o||(o=new Map,ng().set(s,o));let r=o.get(t);r||(r=[],o.set(t,r)),r.push({prefix:i,postfix:n})}function fb(s,t,i,...n){var o;if(!i)return;const r=og(s,t);if(r)for(const l of r)(o=l.prefix)==null||o.call(i,...n)}function yb(s,t,i,n,...o){var r;if(!i)return;const l=og(s,t);if(l)for(const c of l)(r=c.postfix)==null||r.call(i,n,...o)}const ka=[];function Ld(s){ka.indexOf(s)===-1&&ka.push(s)}function jP(s){const t=ka.indexOf(s);t!==-1&&ka.splice(t,1)}const Ma=[];function rg(s){Ma.indexOf(s)===-1&&Ma.push(s)}function LP(s){const t=Ma.indexOf(s);t!==-1&&Ma.splice(t,1)}function vb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let t=0;t<ka.length;t++)ka[t](s)}function bb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let t=0;t<Ma.length;t++)Ma[t](s)}const ut=O("debuginput");var Dd=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(Dd||{}),Be=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(Be||{});class Pn extends PointerEvent{constructor(t,i,n){super(t,n),a(this,"clientZ"),a(this,"deviceIndex"),a(this,"origin"),a(this,"source"),a(this,"mode"),a(this,"_ray"),a(this,"space"),a(this,"isClick",!1),a(this,"isDoubleClick",!1),a(this,"_used",!1),a(this,"_pointerid"),a(this,"_pointerType"),a(this,"_type"),a(this,"metadata",{}),a(this,"intersections",new Array),a(this,"_immediatePropagationStopped",!1),a(this,"_propagationStopped",!1),this.clientZ=n.clientZ,this._pointerid=n.pointerId,this._pointerType=n.pointerType,this._type=t,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 ao(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(t){this._ray=t}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 t;this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}stopPropagation(){var t;this._propagationStopped=!0,super.stopPropagation(),(t=this.source)==null||t.stopPropagation(),ut&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class mc extends KeyboardEvent{constructor(t,i,n){super(t,n),a(this,"source"),this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class DP{constructor(t){a(this,"key"),a(this,"keyType"),a(this,"source"),this.key=t.key,this.keyType=t.type,this.source=t}}var di=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))(di||{});class _b{constructor(t){a(this,"_eventListeners",{}),a(this,"_doubleClickTimeThreshold",.2),a(this,"_longPressTimeThreshold",1),a(this,"_setCursorTypes",[]),a(this,"context"),a(this,"_pointerDown",[!1]),a(this,"_pointerUp",[!1]),a(this,"_pointerClick",[!1]),a(this,"_pointerDoubleClick",[!1]),a(this,"_pointerPressed",[!1]),a(this,"_pointerPositions",[new re]),a(this,"_pointerPositionsLastFrame",[new re]),a(this,"_pointerPositionsDelta",[new re]),a(this,"_pointerPositionsRC",[new re]),a(this,"_pointerPositionDown",[new x]),a(this,"_pointerDownTime",[]),a(this,"_pointerUpTime",[]),a(this,"_pointerUpTimestamp",[]),a(this,"_pointerIds",[]),a(this,"_pointerTypes",[""]),a(this,"_mouseWheelChanged",[!1]),a(this,"_mouseWheelDeltaY",[0]),a(this,"_pointerEvent",[]),a(this,"_pointerEventsPressed",[]),a(this,"_pointerSpace",[]),a(this,"_pressedStack",new Map),a(this,"_htmlEventSource"),a(this,"onLostFocus",()=>{for(const i in this.keysPressed)this.keysPressed[i].pressed=!1}),a(this,"_receivedPointerMoveEventsThisFrame",new Array),a(this,"onEndOfFrame",()=>{this._receivedPointerMoveEventsThisFrame.length=0;for(let i=0;i<this._pointerUp.length;i++)this._pointerUp[i]=!1;for(let i=0;i<this._pointerDown.length;i++)this._pointerDown[i]=!1;for(let i=0;i<this._pointerClick.length;i++)this._pointerClick[i]=!1;for(let i=0;i<this._pointerDoubleClick.length;i++)this._pointerDoubleClick[i]=!1;for(const i of this._pointerPositionsDelta)i.set(0,0);for(let i=0;i<this._mouseWheelChanged.length;i++)this._mouseWheelChanged[i]=!1;for(let i=0;i<this._mouseWheelDeltaY.length;i++)this._mouseWheelDeltaY[i]=0}),a(this,"onContextMenu",i=>{this.canReceiveInput(i)!==!1&&i instanceof PointerEvent&&i.pointerType}),a(this,"keysPressed",{}),a(this,"onKeyDown",i=>{if(ut&&console.log(`key down ${i.code}, ${this.context.application.hasFocus}`,i),!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(n&&n.pressed)return;this.keysPressed[i.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:i.key,code:i.code};const o=new mc("keydown",i,i);this.onDispatchEvent(o)}),a(this,"onKeyPressed",i=>{if(!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(!n)return;n.pressed=!0,n.frame=this.context.time.frameCount+1;const o=new mc("keypress",i,i);this.onDispatchEvent(o)}),a(this,"onKeyUp",i=>{if(!this.context.application.hasFocus)return;const n=this.keysPressed[i.code];if(!n)return;n.pressed=!1,n.frame=this.context.time.frameCount+1;const o=new mc("keyup",i,i);this.onDispatchEvent(o)}),a(this,"onWheelWindow",i=>{document.pointerLockElement&&this.onMouseWheel(i)}),a(this,"onMouseWheel",i=>{if(this.canReceiveInput(i)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const n=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=n+i.deltaY}),a(this,"onPointerDown",i=>{if(this.context.isInAR||this.canReceiveInput(i)===!1)return;i.target instanceof HTMLElement&&i.target.setPointerCapture(i.pointerId);const n=this.getPointerId(i);ut&&De(`pointer down #${n}, identifier:${i.pointerId}`);const o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Pn("pointerdown",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:i.button,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:o,pressure:i.pressure});this.onDown(r)}),a(this,"onPointerMove",i=>{if(this.context.isInAR||this._receivedPointerMoveEventsThisFrame.includes(i.pointerId))return;this._receivedPointerMoveEventsThisFrame.push(i.pointerId);let n=i.button;i.pointerType==="mouse"&&(n=this.getFirstPressedButtonForPointer(0)??0);const o=this.getPointerId(i,n);n===-1&&(n=o);const r=this.getAndUpdateSpatialObjectForScreenPosition(o,i.clientX,i.clientY),l=new Pn("pointermove",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:o,button:n,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:r,pressure:i.pressure});this.onMove(l)}),a(this,"onPointerCancel",i=>{this.context.isInAR||(ut&&console.log("Pointer cancel",i),this.onPointerUp(i))}),a(this,"onPointerUp",i=>{if(this.context.isInAR)return;i.target instanceof HTMLElement&&i.target.releasePointerCapture(i.pointerId);const n=this.getPointerId(i),o=new Pn("pointerup",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:i.button,clientX:i.clientX,clientY:i.clientY,pointerType:i.pointerType,buttonName:this.getButtonName(i),device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.pressure});this.onUp(o),this._pointerIds[n]=-1,ut&&console.log("ID="+n,"PointerId="+i.pointerId,"ALL:",[...this._pointerIds])}),a(this,"onTouchStart",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),c=new Pn("pointerdown",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:l,pressure:o.force});this.onDown(c)}}),a(this,"onTouchMove",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),c=new Pn("pointermove",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:l,pressure:o.force});this.onMove(c)}}),a(this,"onTouchEnd",i=>{if(this.context.isInAR)for(let n=0;n<i.changedTouches.length;n++){const o=i.changedTouches[n],r=this.getPointerIndex(o.identifier),l=new Pn("pointerup",i,{origin:this,mode:"screen",deviceIndex:0,pointerId:r,button:0,clientX:o.clientX,clientY:o.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(r,o.clientX,o.clientY),pressure:o.force});this.onUp(l),this._pointerIds[r]=-1}}),a(this,"tempNearPlaneVector",new x),a(this,"tempFarPlaneVector",new x),a(this,"tempLookMatrix",new ne),this.context=t,this.context.post_render_callbacks.push(this.onEndOfFrame)}addEventListener(t,i,n){if(this._eventListeners[t]||(this._eventListeners[t]=[]),!i||typeof i!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}n?n={...n}:n={};let o=0;n?.queue!=null&&(o=n.queue);const r=this._eventListeners[t],l=r.find(c=>c.priority===o);l?l.listeners.push({callback:i,options:n}):(r.push({priority:o,listeners:[{callback:i,options:n}]}),r.sort((c,h)=>c.priority-h.priority))}removeEventListener(t,i,n){if(!this._eventListeners[t]||!i)return;const o=this._eventListeners[t];if(n?.queue!=null){const r=o.find(c=>c.priority===n.queue);if(!r)return;const l=r.listeners.findIndex(c=>c.callback===i);l>=0&&r.listeners.splice(l,1)}else for(const r of o){const l=r.listeners.findIndex(c=>c.callback===i);l>=0&&r.listeners.splice(l,1)}}dispatchEvent(t){var i,n,o,r;let l=!1;if(t instanceof mc){const c=this._eventListeners[t.type];if(c)for(const h of c)for(let d=0;d<h.listeners.length;d++){const u=h.listeners[d];if((n=(i=u.options)==null?void 0:i.signal)!=null&&n.aborted){h.listeners.splice(d,1),d--;continue}u.options.once&&(h.listeners.splice(d,1),d--),u.callback(t)}}if(t instanceof Pn){const c=this._eventListeners[t.type];if(c)for(const h of c){if(l)break;for(let d=0;d<h.listeners.length;d++){const u=h.listeners[d];if((r=(o=u.options)==null?void 0:o.signal)!=null&&r.aborted){h.listeners.splice(d,1),d--;continue}if(t.immediatePropagationStopped){l=!0,ut&&console.log("immediatePropagationStopped",t.type);break}else t.propagationStopped&&(l=!0,ut&&console.log("propagationStopped",t.type));u.options.once&&(h.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.setCursor("pointer")}setCursorNormal(){this.unsetCursor("pointer")}setCursor(t){this._setCursorTypes.push(t),this._setCursorTypes.length>10&&this._setCursorTypes.shift(),this.updateCursor()}unsetCursor(t){for(let i=this._setCursorTypes.length-1;i>=0;i--)if(this._setCursorTypes[i]===t){this._setCursorTypes.splice(i,1),this.updateCursor();break}}updateCursor(){var t;((t=this._setCursorTypes)==null?void 0:t.length)==0?this.context.domElement.style.cursor="default":this.context.domElement.style.cursor=this._setCursorTypes[this._setCursorTypes.length-1]}getIsPointerIdInUse(t){for(const i of this._pointerEventsPressed)if(i.pointerId===t&&i.used)return!0;return!1}getPointerPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&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 i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&this.getIsTouch(i)&&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 i=0;i<this._pointerTypes.length;i++)if(this._pointerIsActive(i)){if(t!==void 0){const n=this._pointerTypes[i];if(Array.isArray(t)){let o=!1;for(const r of t)if(n===r){o=!0;break}if(!o)continue}else if(t!==n)continue}yield i}}*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,i){let n=this._pressedStack.get(t);n||(n=[],this._pressedStack.set(t,n)),n.push(i)}onReleaseButton(t,i){const n=this._pressedStack.get(t);if(!n)return;const o=n.indexOf(i);o>=0&&n.splice(o,1)}getFirstPressedButtonForPointer(t){const i=this._pressedStack.get(t);if(i)return i[0]}getLatestPressedButtonForPointer(t){const i=this._pressedStack.get(t);if(i)return i[i.length-1]}getKeyDown(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}isKeyDown(t){var i;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyDown(o))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 n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyUp(o))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 n=this.getCodeForCommonKeyName(t);if(n!==null){for(const o of n)if(this.isKeyPressed(o))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":ut&&De("Create Pointer down"),this.onDownButton(t.deviceIndex,t.button),this.onDown(t);break;case"pointermove":ut&&De("Create Pointer move"),this.onMove(t);break;case"pointerup":ut&&De("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,i;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),window.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd),(i=this._htmlEventSource)==null||i.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 i;return t.target===((i=this.context.renderer)==null?void 0:i.domElement)||t.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&t.target===document.body&&X.isMozillaXR()?!0:(ut&&console.warn("CanReceiveInput:False for",t.target),!1)}getPointerId(t,i){return t.pointerType==="mouse"?0+(i??t.button):this.getPointerIndex(t.pointerId)}getButtonName(t){const i=t.button;if(t.pointerType==="mouse")switch(i){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}getAndUpdateSpatialObjectForScreenPosition(t,i,n){let o=this._pointerSpace[t];o||(o=new I,this._pointerSpace[t]=o),this._pointerSpace[t]=o;const r=this.context.mainCamera;if(r){const l=this.tempNearPlaneVector.set(i,n,-1);this.convertScreenspaceToRaycastSpace(l);const c=this.tempFarPlaneVector.set(l.x,l.y,1);l.unproject(r),c.unproject(r);const h=r.worldUp||G(0,1,0).applyQuaternion(Oe(r));this.tempLookMatrix.lookAt(c,l,h),o.position.set(l.x,l.y,l.z),o.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return o}isInRect(t){if(this.context.isInXR)return!0;const i=this.context.domElement.getBoundingClientRect(),n=t.clientX,o=t.clientY,r=n>=i.x&&n<=i.right&&o>=i.y&&o<=i.bottom;return ut&&!r&&console.log("Not in rect",i,n,o),r}onDown(t){const i=t.pointerId;if(this.getPointerPressed(i)&&console.warn(`Received pointerDown for pointerId that is already pressed: ${i}`,ut?t:""),ut&&console.log(t.pointerType,"DOWN",i),!!this.isInRect(t)){for(this.setPointerState(i,this._pointerPressed,!0),this.setPointerState(i,this._pointerDown,!0),this.setPointerStateT(i,this._pointerEvent,t.source);i>=this._pointerTypes.length;)this._pointerTypes.push(t.pointerType);for(this._pointerTypes[i]=t.pointerType;i>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new x);for(this._pointerPositionDown[i].set(t.clientX,t.clientY,t.clientZ??0);i>=this._pointerPositions.length;)this._pointerPositions.push(new re);this._pointerPositions[i].set(t.clientX,t.clientY),i>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[i]=this.context.time.realtimeSinceStartup,this.updatePointerPosition(t),this._pointerEventsPressed.push(t),this.onDispatchEvent(t)}}onMove(t){const i=t.pointerId,n=this.getPointerPressed(i);n===!1&&!this.isInRect(t)||t.pointerType==="touch"&&!n||(this.updatePointerPosition(t),this.setPointerStateT(i,this._pointerEvent,t.source),this.onDispatchEvent(t))}onUp(t){const i=t.pointerId;if(!this.getPointerPressed(i)){ut&&console.log(t.pointerType,"UP",i,"was not down");return}ut&&console.log(t.pointerType,"UP",i),this.setPointerState(i,this._pointerPressed,!1),this.setPointerStateT(i,this._pointerEvent,t.source),this.setPointerState(i,this._pointerUp,!0),this.updatePointerPosition(t);for(let c=this._pointerEventsPressed.length-1;c>=0;c--)if(this._pointerEventsPressed[c].pointerId===i){this._pointerEventsPressed.splice(c,1);break}if(!this._pointerPositionDown[i]){ut&&xe("Received pointer up event without matching down event for button: "+i),console.warn("Received pointer up event without matching down event for button: "+i);return}const n=this._pointerUpTime[i],o=this._pointerDownTime[i],r=this.context.time.realtimeSinceStartup,l=r-o;if(i>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),this._pointerUpTime[i]=r,l<1){let c=t.clientX-this._pointerPositionDown[i].x,h=t.clientY-this._pointerPositionDown[i].y,d=0;if(t.isSpatial&&t.clientZ!=null&&(d=t.clientZ-this._pointerPositionDown[i].z,c*=200,h*=200,d*=200),Math.abs(c)<5&&Math.abs(h)<5&&Math.abs(d)<5){this.setPointerState(i,this._pointerClick,!0),t.isClick=!0;const u=r-n;ut&&console.log("CLICK",i,c,h,d,u),u<this._doubleClickTimeThreshold&&u>0&&(this.setPointerState(i,this._pointerDoubleClick,!0),t.isDoubleClick=!0)}}this.onDispatchEvent(t)}updatePointerPosition(t){const i=t.pointerId;for(;i>=this._pointerPositions.length;)this._pointerPositions.push(new re);for(;i>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new re);for(;i>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new re);const n=this._pointerPositionsLastFrame[i];n.copy(this._pointerPositions[i]);const o=this._pointerPositionsDelta[i];let r=t.clientX-n.x,l=t.clientY-n.y;if(t.source instanceof MouseEvent||t.source instanceof TouchEvent){const u=t.source;r===0&&u.movementX!==0&&(r=u.movementX||0),l===0&&u.movementY!==0&&(l=u.movementY||0)}o.x+=r,o.y+=l,this._pointerPositions[i].x=t.clientX,this._pointerPositions[i].y=t.clientY;const c=t.clientX,h=t.clientY;for(;i>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new re);const d=this._pointerPositionsRC[i];d.set(c,h),this.convertScreenspaceToRaycastSpace(d)}getPointerIndex(t){let i=-1;for(let n=0;n<this._pointerIds.length;n++){if(this._pointerIds[n]===t)return n;i===-1&&this._pointerIds[n]===-1&&(i=n)}return i!==-1?(this._pointerIds[i]=t,i):(ut&&console.log("PUSH pointerId:",t),this._pointerIds.push(t),this._pointerIds.length-1)}setPointerState(t,i,n){i[t]=n}setPointerStateT(t,i,n){return i[t]=n,n}onDispatchEvent(t){const i=ee.Current;try{ee.Current=this.context,this.dispatchEvent(t)}finally{ee.Current=i}}}const Ra=new ne().makeRotationY(Math.PI),Yi=new V().setFromAxisAngle(new x(0,1,0),Math.PI),BP=O("debugwebxr");class FP{constructor(){if(a(this,"priority",-1e5),a(this,"gameObject"),this.gameObject=new I,this.gameObject.name="Implicit XR Rig",BP){const t=xg(16733661);t.position.y+=.5,this.gameObject.add(t)}}isXRRig(){return!0}get isActive(){return this.gameObject.visible}}const kn=O("debugwebxr"),Bd=O("debugcustomgesture"),zP="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",UP="generic-trigger",NP=new V().setFromEuler(new Ut(bn.degToRad(0),bn.degToRad(-90),bn.degToRad(-90))),WP=new x(.04,-.04,0);class ag{constructor(t,i,n){a(this,"xr"),a(this,"inputSource"),a(this,"index",0),a(this,"emitEvents",!0),a(this,"_connected",!0),a(this,"_isTracking",!1),a(this,"__gamepad"),a(this,"__hand"),a(this,"__side"),a(this,"_hitTestSource"),a(this,"_hasSelectEvent",!1),a(this,"_isMxInk",!1),a(this,"_isMetaQuestTouchController",!1),a(this,"_handJointPoses",new Map),a(this,"_gripMatrix",new ne),a(this,"_gripPosition",new x),a(this,"_gripQuaternion",new V),a(this,"_linearVelocity",new x),a(this,"_rayPositionRaw",new x),a(this,"_rayRotationRaw",new V),a(this,"_rayMatrix",new ne),a(this,"_rayPosition",new x),a(this,"_rayQuaternion",new V),a(this,"_gripWorldPosition",new x),a(this,"_gripWorldQuaternion",new V),a(this,"_rayWorldPosition",new x),a(this,"_rayWorldQuaternion",new V),a(this,"_pinchPosition",new x),a(this,"_ray"),a(this,"_hand_wristDotUp"),a(this,"_object"),a(this,"_gripSpaceObject"),a(this,"_raySpaceObject"),a(this,"model",null),a(this,"_debugAxesHelper",new xi(.15)),a(this,"_debugGripAxesHelper",new xi(.07)),a(this,"_debugRayAxesHelper",new xi(.07)),a(this,"_hitTestSourcePromise",null),a(this,"onPointerHits",o=>{}),a(this,"_needleGamepadButtons",{}),a(this,"_buttonMap",new Map),a(this,"_motioncontroller"),a(this,"_layout"),a(this,"getMotionController"),a(this,"emitPointerDownEvent",!0),a(this,"emitPointerUpEvent",!0),a(this,"emitPointerMoveEvent",!0),a(this,"pointerMoveDistanceThreshold",.03),a(this,"pointerMoveAngleThreshold",.05),a(this,"_selectButtonIndex"),a(this,"_squeezeButtonIndex"),a(this,"onSelectStart",o=>{var r,l,c,h;if(!this.emitPointerDownEvent||this.inputSource!==o.inputSource)return;this.onUpdateFrame(o.frame),this._hasSelectEvent=!0;const d=(r=this._layout)==null?void 0:r.selectComponentId,u=(h=(c=(l=this._layout)==null?void 0:l.components[d])==null?void 0:c.gamepadIndices)==null?void 0:h.button;u!==void 0&&(this._selectButtonIndex=u),!Bd&&(kn&&q.DrawDirection(this.rayWorldPosition,G(0,.01,1).applyQuaternion(this.rayWorldQuaternion),16711680,10),this.emitPointerEvent(Be.PointerDown,this._selectButtonIndex||0,"xr-standard-trigger",!0,o))}),a(this,"onSelectEnd",o=>{this.emitPointerUpEvent&&(Bd||this.inputSource===o.inputSource&&this.emitPointerEvent(Be.PointerUp,this._selectButtonIndex||0,"xr-standard-trigger",!0,o))}),a(this,"onSequeezeStart",o=>{var r,l,c;this.emitPointerDownEvent&&this.inputSource===o.inputSource&&(this._squeezeButtonIndex=(c=(l=(r=this._layout)==null?void 0:r.components["xr-standard-squeeze"])==null?void 0:l.gamepadIndices)==null?void 0:c.button,this._squeezeButtonIndex!==void 0&&(kn&&q.DrawDirection(this.rayWorldPosition,G(0,.01,1).applyQuaternion(this.rayWorldQuaternion),255,10),this.emitPointerEvent(Be.PointerDown,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,o)))}),a(this,"onSequeezeEnd",o=>{this.emitPointerUpEvent&&this.inputSource===o.inputSource&&this._squeezeButtonIndex!==void 0&&this.emitPointerEvent(Be.PointerUp,this._squeezeButtonIndex||0,"xr-standard-squeeze",!0,o)}),a(this,"states",{}),a(this,"_didMoveLastFrame",!1),a(this,"_lastPointerMovePosition",new x),a(this,"_lastPointerMoveQuaternion",new V),a(this,"pointerInit"),this.xr=t,this.inputSource=i,this.index=n,this._object=new I,this._object.name=`NeedleXRController_${n}`,kn&&(this._object.add(this._debugAxesHelper),this._gripSpaceObject=new I,this._raySpaceObject=new I,this._gripSpaceObject.name=`NeedleXRController_${n}_gripSpace`,this._raySpaceObject.name=`NeedleXRController_${n}_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 ao,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,i){var n;if(i=i||this.xr.frame,!this.hand||!(i!=null&&i.getJointPose)||!this.xr.referenceSpace)return null;let o=(n=this._handJointPoses)==null?void 0:n.get(t);return o||(o=i.getJointPose(t,this.xr.referenceSpace),o&&this._handJointPoses.set(t,o),o)}get gripPosition(){return G(this._gripPosition)}get gripQuaternion(){return vs(this._gripQuaternion)}get gripMatrix(){return this._gripMatrix}get gripLinearVelocity(){return G(this._linearVelocity).applyQuaternion(Yi)}get rayPosition(){return G(this._rayPosition)}get rayQuaternion(){return vs(this._rayQuaternion)}get gripWorldPosition(){return G(this._gripWorldPosition)}get gripWorldQuaternion(){return vs(this._gripWorldQuaternion)}get rayWorldPosition(){return G(this._rayWorldPosition)}updateRayWorldPosition(){var t;const i=(t=this.xr.context.mainCamera)==null?void 0:t.parent;this._rayWorldPosition.copy(this._rayPositionRaw),i&&this._rayWorldPosition.applyMatrix4(i.matrixWorld)}get rayWorldQuaternion(){return vs(this._rayWorldQuaternion)}get pinchPosition(){return G(this._pinchPosition)}updateRayWorldQuaternion(){var t;const i=(t=this.xr.context.mainCamera)==null?void 0:t.parent,n=i?Oe(i):void 0;this._rayWorldQuaternion.copy(this._rayRotationRaw).multiply(Yi),n&&this._rayWorldQuaternion.premultiply(n)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(G(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}get handWristDotUp(){var t;if(this._hand_wristDotUp!==void 0)return this._hand_wristDotUp;const i=(t=this.handObject)==null?void 0:t.joints.wrist;if(i){const n=G(0,1,0).applyQuaternion(i.quaternion),o=G(0,1,0).dot(n);return this._hand_wristDotUp=o}}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(i=>i?.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(i=>(this._hitTestSourcePromise=null,this.connected?this._hitTestSource=i:(i.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 t;q.DrawSphere(this.rayWorldPosition,.003),q.DrawDirection(this.rayWorldPosition,G(0,0,10).applyQuaternion(this.rayWorldQuaternion));const i=(this.inputSource.gripSpace?this.gripWorldPosition:this.object.worldPosition).sub(this.object.worldForward.multiplyScalar(.1)),n=this.inputSource.profiles.join(`
|
|
135
135
|
`);let o=`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&&(o+=`
|
|
@@ -151,7 +151,7 @@ See https://engine.needle.tools/docs/scripting.html#special-lifecycle-hooks for
|
|
|
151
151
|
`+Pi);const c=await import("./vendor.light.min.js").then(p=>p.j),h=((n=c.default)==null?void 0:n.WebsocketBuilder)??c.WebsocketBuilder,d=((o=c.default)==null?void 0:o.ExponentialBackoff)??c.ExponentialBackoff,u=new h(Pi).withMaxRetries(10).withBackoff(new d(2e3,4)).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=u,this.connected=!0,F()||ui?console.log(`\u229E Connected to networking backend
|
|
152
152
|
`+Pi):console.debug("\u229E Connected to networking backend",Pi),l(!0),this.onSendQueued(ws.OnConnection)}).onClose(p=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,l(!1);let g="Websocket connection closed...";Pi!=null&&Pi.includes("/socket")||(g+=' Do you perhaps mean to connect to "/socket"?'),console.error(g)}).onError(p=>{console.error("\u22A0 Websocket connection failed..."),l(!1)}).onRetry(()=>{console.log("\u2192 Retry connecting to networking websocket")}).build();u.addEventListener(c.WebsocketEvent.message,(p,g)=>{this.onMessage(p,g)})})}onMessage(t,i){const n=i.data;try{if(typeof n!="string"){n.size&&this.handleIncomingBinaryMessage(n);return}const o=JSON.parse(n);if(Array.isArray(o))for(const r of o)this.handleIncomingStringMessage(r);else this.handleIncomingStringMessage(o);return}catch(o){ui&&n==="pong"?console.log("<<",n):F()&&console.error("Failed to parse message",o)}}async handleIncomingBinaryMessage(t){ug&&console.log("<< bin",this.context.time.frame);const i=await t.arrayBuffer();var n=new Uint8Array(i);const o=new tO(n),r=o.getBufferIdentifier(),l=this._listenersBinary[r],c=kb(o),h=Mb(c);if(h&&typeof h=="string"&&(this._state[h]=c),!l)return;const d=c??o;for(const u of l)u(d)}handleIncomingStringMessage(t){var i,n;if(ui&&console.log("<<",t.key??t),t.key)switch(t.key){case"connection-start-info":if(t.data){const c=t.data;c&&(console.assert(c.id!==void 0&&c.id!==null&&c.id.length>0,"server did not send connection id",c.id),console.debug("Your id is: "+c.id,this.context.alias??""),this._connectionId=c.id)}else console.warn("Expected connection id in "+t.key);break;case"joined-room":if(ui&&console.log(t),t){this._isInRoom=!0;const c=t;this._currentRoomName=c.room,this._currentRoomViewId=c.viewId,this._currentRoomAllowEditing=c.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...c.inRoom),(ug||F())&&console.debug("Joined Needle Engine Room: "+c.room);const h=new URL(window.location.href);h.searchParams.has("room")&&h.searchParams.delete("room"),h.searchParams.set("view",this._currentRoomViewId),console.debug(`Room view id: ${this._currentRoomViewId}
|
|
153
153
|
${h.href}`)}this.onSendQueued(ws.OnRoomJoin);break;case"left-room":t.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(t.data){const c=t.data;this._currentInRoom.push(c.userId),ui&&console.log(c.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(t.data){const c=t.data,h=this._currentInRoom.indexOf(c.userId);h>=0&&(ui&&console.log(c.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(h,1)),c.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":ui&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const l=(i=t.data)==null?void 0:i.time;l&&(this._currentDelay=this.context.time.time-l),ui&&console.log("Current latency: "+this._currentDelay.toFixed(4)+" sec","Clients in room: "+((n=this._currentInRoom)==null?void 0:n.length));break}const o=t.data;o&&(this._state[o.guid]=o);let r=this._listeners[t.key];if(r){r=[...r];for(const l of r)try{l(t.data)}catch(c){console.error('Error invoking callback for "'+t.key+'"',c)}}}toMessage(t,i){return{key:t,data:i}}sendWithWebsocket(t,i,n=ws.OnRoomJoin){if(!this._ws){const r=this._waitingForSocket[n]||[];r.push(()=>this.sendWithWebsocket(t,i,n)),this._waitingForSocket[n]=r;return}const o=JSON.stringify(this.toMessage(t,i));ui&&console.log(">>",t),this._ws.send(o)}onSendQueued(t){const i=this._waitingForSocket[t];if(i){for(const n of i)n();i.length=0}}}const fc=O("debugwebxr");class mg{constructor(t,i){a(this,"controllerStates",[]),a(this,"userId"),a(this,"context"),a(this,"userStateEvtName"),a(this,"onReceivedControllerState",n=>{fc&&console.log(`XRSync: Received change for ${this.userId}: ${n.type} ${n.handedness}; tracked=${n.isTracking}`);let o=!1;for(let r=0;r<this.controllerStates.length;r++)if(this.controllerStates[r].index===n.index){this.controllerStates[r]=n,o=!0;break}o||this.controllerStates.push(n)}),this.userId=t,this.context=i,this.userStateEvtName="xr-sync-user-state-"+t,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(t){if(this.context.connection.isConnected!=!1){for(let i=this.controllerStates.length-1;i>=0;i--){const n=this.controllerStates[i];let o=!1;for(let r=0;r<t.controllers.length;r++)t.controllers[r].index===n.index&&(o=!0);o||(fc&&console.log(`XRSync: ${n.type} ${n.handedness} removed`,n.index),this.controllerStates.splice(i,1),this.sendControllerRemoved(n))}for(const i of t.controllers)this.updateControllerStates(i)}}onExitXR(t){for(const i of this.controllerStates)this.sendControllerRemoved(i);this.controllerStates.length=0}sendControllerRemoved(t){t.isTracking=!1,t.guid="",this.context.connection.send(this.userStateEvtName,t),this.context.connection.sendDeleteRemoteState(t.guid)}updateControllerStates(t){const i=this.controllerStates.find(n=>n.index===t.index);if(i){let n=!1;n||(n=i.isTracking!=t.isTracking),n&&(i.isTracking=t.isTracking,this.context.connection.send(this.userStateEvtName,i))}else{const n={guid:this.userId+"-"+t.index,isTracking:t.isTracking,handedness:t.side,index:t.index,type:t.hand?"hand":"controller"};this.controllerStates.push(n),this.context.connection.send(this.userStateEvtName,n),fc&&console.log(`XRSync: ${n.type} ${n.handedness} added`,n.index)}}}class Db{constructor(t){a(this,"context"),a(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(fc&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new mg(this.context.connection.connectionId,this.context)));for(const i of this.context.connection.usersInRoom())this._states.has(i)||this._states.set(i,new mg(i,this.context))}}),a(this,"onLeftRoom",()=>{if(this.context.connection.connectionId&&!this._states.has(this.context.connection.connectionId)){const i=this._states.get(this.context.connection.connectionId);i?.dispose(),this._states.delete(this.context.connection.connectionId)}}),a(this,"onOtherUserJoinedRoom",i=>{const n=i.userId;this._states.has(n)||(fc&&console.log("XRSync: Remote user joined room",n),this._states.set(n,new mg(n,this.context)))}),a(this,"onOtherUserLeftRoom",i=>{const n=i.userId;if(!this._states.has(n)){const o=this._states.get(n);o?.dispose(),this._states.delete(n)}}),a(this,"_states",new Map),this.context=t,this.context.connection.beginListen(se.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(se.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(se.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(se.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(t){return t?this._states.has(t):!1}isTracking(t,i){if(!t)return;const n=this._states.get(t);if(!n)return;const o=n.controllerStates.find(r=>r.handedness===i);return o?.isTracking||!1}getDeviceType(t,i){if(!t)return;const n=this._states.get(t);if(!n)return;const o=n.controllerStates.find(r=>r.handedness===i);return o?.type||"unknown"}destroy(){this.context.connection.stopListen(se.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(se.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(se.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(se.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(t){if(this.context.connection.isConnected&&this.context.connection.connectionId){const i=this._states.get(this.context.connection.connectionId);i?.update(t)}}onExitXR(t){if(this.context.connection.isConnected&&this.context.connection.connectionId){const i=this._states.get(this.context.connection.connectionId);i?.onExitXR(t)}}}class Bb{constructor(){a(this,"_fadeToColorQuad"),a(this,"_fadeToColorMaterial"),a(this,"_requestedFadeValue",0),a(this,"_transitionPromise",null),a(this,"_transitionResolve",null),this._fadeToColorMaterial=new Re({color:0,transparent:!0,depthTest:!1,fog:!1,side:Si}),this._fadeToColorQuad=new Z(new Fs(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(t,i){const n=this._fadeToColorQuad,o=this._fadeToColorMaterial;n.parent!==t&&o.opacity>0?t.add(n):o.opacity===0&&n.removeFromParent(),n.layers.set(2),n.material=this._fadeToColorMaterial,n.position.z=-1,n.renderOrder=1/0;const r=this._requestedFadeValue;o.opacity=W.lerp(o.opacity,r,i/.03),Math.abs(o.opacity-r)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const t=new Promise(i=>{this._transitionResolve=i});return this._transitionPromise=t,t}}var _r=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s[s.RoundedCube=10]="RoundedCube",s))(_r||{}),zd,gg;class fo{static createText(t,i){let n=null;const o=i?.font||ZP(i?.familyFamily||null);o instanceof IC?n=va(this,zd,gg).call(this,t,o,i):n==null&&(n=new _n);const r=i?.color||16777215,l=new Z(n,i?.material??new li({color:r}));return this.applyDefaultObjectOptions(l,i),o instanceof Promise?o.then(c=>{l.geometry=va(this,zd,gg).call(this,t,c,i),i!=null&&i.onGeometry&&i.onGeometry(l)}):i!=null&&i.onGeometry&&i.onGeometry(l),l}static createOccluder(t){const i=new Re({colorWrite:!1,depthWrite:!0,side:Si});return this.createPrimitive(t,{material:i})}static createPrimitive(t,i){let n;const o=i?.color||16777215;switch(t){case"Quad":case 0:{const r=new Fs(1,1,1,1),l=i?.material??new li({color:o});i!=null&&i.texture&&"map"in l&&(l.map=i.texture),n=new Z(r,l),n.name="Quad"}break;case"Cube":case 1:{const r=new Ql(1,1,1),l=i?.material??new li({color:o});i!=null&&i.texture&&"map"in l&&(l.map=i.texture),n=new Z(r,l),n.name="Cube"}break;case 10:case"RoundedCube":{const r=YP(1,1,1,.1,2),l=i?.material??new li({color:o});i!=null&&i.texture&&"map"in l&&(l.map=i.texture),n=new Z(r,l),n.name="RoundedCube"}break;case"Sphere":case 2:{const r=new pd(.5,16,16),l=i?.material??new li({color:o});i!=null&&i.texture&&"map"in l&&(l.map=i.texture),n=new Z(r,l),n.name="Sphere"}break;case"ShaderBall":n=new lo,n.name="ShaderBall",KP(n,i);break}return this.applyDefaultObjectOptions(n,i),n}static createSprite(t){const i=new mS({color:16777215});t!=null&&t.texture&&"map"in i&&(i.map=t.texture);const n=new gS(i);return this.applyDefaultObjectOptions(n,t),n}static applyDefaultObjectOptions(t,i){t.receiveShadow=!0,t.castShadow=!0,i!=null&&i.name&&(t.name=i.name),i!=null&&i.position&&(Array.isArray(i.position)?t.position.set(i.position[0],i.position[1],i.position[2]):t.position.set(i.position.x,i.position.y,i.position.z)),i!=null&&i.rotation&&(Array.isArray(i.rotation)?t.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2]):t.rotation.set(i.rotation.x,i.rotation.y,i.rotation.z)),i!=null&&i.scale&&(typeof i.scale=="number"?t.scale.set(i.scale,i.scale,i.scale):t.scale.set(i.scale.x,i.scale.y,i.scale.z)),i?.receiveShadow!=null&&(t.receiveShadow=i.receiveShadow),i?.castShadow!=null&&(t.castShadow=i.castShadow),i!=null&&i.parent&&i.parent.add(t)}}zd=new WeakSet,gg=function(s,t,i){const n=i?.depth||.1;return new jC(s,{font:t,size:1,depth:n,height:n,bevelEnabled:i?.bevel||!1,bevelThickness:.01,bevelOffset:.01,bevelSize:.01})},$i(fo,zd);function YP(s,t,i,n,o){const r=new fS,l=1e-5,c=n-l;r.absarc(l,l,l,-Math.PI/2,-Math.PI,!0),r.absarc(l,t-c*2,l,Math.PI,Math.PI/2,!0),r.absarc(s-c*2,t-c*2,l,Math.PI/2,0,!0),r.absarc(s-c*2,l,l,0,-Math.PI/2,!0);const h=new yS(r,{bevelEnabled:!0,bevelSegments:o*2,steps:1,bevelSize:c,bevelThickness:n,curveSegments:o});return h.scale(1,1,1-n),h.center(),h.computeVertexNormals(),h}const Ud=new Map;function ZP(s){let t="";switch(s){default:case"OpenSans":t="https://cdn.needle.tools/static/fonts/facetype/Open Sans_Regular_ascii.json";break;case"Helvetiker":t="https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/helvetiker_regular.typeface.json";break}if(Ud.has(t)){const o=Ud.get(t);if(o)return o}const i=new LC,n=new Promise((o,r)=>{i.load(t,l=>{Ud.set(t,l),o(l)},void 0,r)});return Ud.set(t,n),n}let fg=!1,yg=null;function KP(s,t){if(yg===null){const i="https://cdn.needle.tools/static/models/shaderball.glb",n=new mr,o=Sm(null);n.setDRACOLoader(o.dracoLoader),n.setKTX2Loader(o.ktx2Loader),fg=!0,yg=n.loadAsync(i).then(r=>{const l=r.scene;return l.position.y-=.5,l}).catch(r=>(console.warn("Failed to load shaderball mesh: "+r.message),zb())).finally(()=>{fg=!1})}if(fg){const i=zb();i.name="ShaderBall-Placeholder";const n=i.children[0];n?.type==="Mesh"&&Fb(n,t),s.add(i)}yg.then(i=>{s.children.forEach(r=>{r.name==="ShaderBall-Placeholder"&&s.remove(r)});const n=i.clone(),o=n.children[0];o?.type==="Mesh"&&Fb(o,t),s.add(n)})}function Fb(s,t){var i;if(t?.color||t?.material||t?.texture){const n=t?.material??((i=s.material)==null?void 0:i.clone())??new li;t.color&&"color"in n&&n.color instanceof ae&&n.color.set(t.color),t!=null&&t.texture&&"map"in n&&(n.map=t.texture),s.material=n}}function zb(){return new lo().add(fo.createPrimitive("Sphere",{material:new Re({transparent:!0,opacity:.1})}))}const Ub=class{constructor(s,t,i){a(this,"_session"),a(this,"_mode"),a(this,"_init"),a(this,"_renderer"),a(this,"_camera"),a(this,"_scene"),a(this,"onEnd",()=>{var n;(n=this._session)==null||n.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),a(this,"_lastTime",0),a(this,"onFrame",(n,o)=>{const r=n-this._lastTime;this.update(n,r),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),a(this,"_objects",[]),this._mode=s,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new dr({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new we,this._scene=new qi,this._scene.fog=new Qy(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(s,t){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(s,t);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new Ub(s,t,i),this._active):(i.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await ys(100)),this._active=null}get isAR(){return this._mode==="immersive-ar"}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const s={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,s}async onBeforeHandoff(){await ys(1e3),this._scene.clear()}setupScene(){this._scene.background=new ae(0),this._scene.add(new dm(5,10,1118481,1118481));const s=new um(16777215,1);s.position.set(0,20,0),s.castShadow=!1,this._scene.add(s);const t=new um(16777215,1);t.position.set(0,-1,0),t.castShadow=!1,this._scene.add(t);const i=new Yy(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const n=50;for(let o=0;o<100;o++){const r=new li({color:2236962,metalness:1,roughness:.8});this.isAR&&(r.emissive=new ae(Math.random(),Math.random(),Math.random()),r.emissiveIntensity=Math.random());const l=W.random(0,1)>.5?_r.Sphere:_r.Cube,c=fo.createPrimitive(l,{material:r});c.position.x=W.random(-n,n),c.position.y=W.random(-2,n),c.position.z=W.random(-n,n),c.rotation.x=W.random(0,Math.PI*2),c.rotation.y=W.random(0,Math.PI*2),c.rotation.z=W.random(0,Math.PI*2),c.scale.multiplyScalar(.5+Math.random()*10);const h=c.position.distanceTo(this._camera.position)-c.scale.x;h<1&&c.position.multiplyScalar(1+1/h),this._objects.push(c),this._scene.add(c)}}update(s,t){const i=s*4e-4;for(let n=0;n<this._objects.length;n++){const o=this._objects[n];o.position.y+=Math.sin(i+n*.5)*.005,o.rotateY(.002)}}};let Aa=Ub;a(Aa,"_active",null),a(Aa,"_requestInFlight",!1);var yc;(s=>{const t=[];function i(){if(!(t!=null&&t.length))return!1;for(const r of t)r.exportAndOpen();return!0}s.exportAndOpen=i;function n(r){t.push(r)}s.registerExporter=n;function o(r){if(!t)return;const l=t.indexOf(r);l>=0&&t.splice(l,1)}s.unregisterExporter=o})(yc||(yc={}));const Nb="NeedleXRSession onStart",Wb="NeedleXRSession onEnd",yt=O("debugwebxr"),Vb=O("stats");let vg=0;function JP(s){let t=null;const i=s;return i.getAROverlayContainer?t=i.getAROverlayContainer():t=s,t}e2();async function e2(){var s;if(O("debugasap")){let t=globalThis["needle:XRSession"];if(t instanceof Promise){delete globalThis["needle:XRSession"],ge.addContextCreatedCallback(async i=>{if(!t)return;vr(!0);const n=await t;if(n){const o=J.getDefaultSessionInit("immersive-vr");J.setSession("immersive-vr",n,o,i.context)}else console.error("NeedleXRSession: ASAP session was rejected");t=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(s=navigator.xr)==null||s.addEventListener("sessiongranted",async()=>{vr(!0),console.log("Received Session Granted..."),await ys(100);const t=sessionStorage.getItem("needle_xr_session_mode"),i=sessionStorage.getItem("needle_xr_session_init")??null,n=i?JSON.parse(i):null;let o=null;if(Hb()&&(await Aa.start(t||"immersive-vr",n||J.getDefaultSessionInit("immersive-vr")),await s2(),o=await Aa.handoff()),o)J.setSession(o.mode,o.session,o.init,ee.Current);else if(t&&i){console.log("Session Granted: Restore last session");const r=JSON.parse(i);J.start(t,r).catch(l=>console.warn(l))}else J.start("immersive-vr").catch(r=>console.warn("Session Granted failed:",r))},{once:!0})}}function t2(s,t){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(t))}function i2(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const bg=new Set;ge.registerCallback(ye.ContextCreationStart,async s=>{bg.add(s.context)}),ge.registerCallback(ye.ContextCreated,async s=>{bg.delete(s.context)});function Hb(){return bg.size>0}function s2(){return new Promise(s=>{const t=Date.now(),i=setInterval(()=>{(!Hb()||Date.now()-t>6e4)&&(clearInterval(i),s())},100)})}X.isDesktop()&&F()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&J.active&&J.stop()});const yo=class{constructor(s,t,i,n){a(this,"context"),a(this,"session"),a(this,"mode"),a(this,"controllers",[]),a(this,"_rigScale",1),a(this,"_lastRigScaleUpdate",-1),a(this,"_rigs",[]),a(this,"_viewerHitTestSource",null),a(this,"_defaultRig"),a(this,"_xr_scripts"),a(this,"_xr_update_scripts",[]),a(this,"_inactive_scripts",[]),a(this,"_controllerAdded"),a(this,"_controllerRemoved"),a(this,"_originalCameraWorldPosition"),a(this,"_originalCameraWorldRotation"),a(this,"_originalCameraWorldScale"),a(this,"_originalCameraParent"),a(this,"_mainCamera",null),a(this,"onRendererSessionSet",()=>{var l;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(l=this.context.mainCameraComponent)==null||l.applyClearFlags())}),a(this,"onInputSourceAdded",l=>{if(l.targetRayMode==="screen")return;let c=0;for(let d=0;d<this.session.inputSources.length;d++)if(this.session.inputSources[d]===l){c=d;break}if(this.controllers.find(d=>d.inputSource===l)){console.debug("Controller already exists for input source",c);return}else if(this._newControllers.find(d=>d.inputSource===l)){console.debug("Controller already registered for input source",c);return}const h=new ag(this,l,c);this._newControllers.push(h)}),a(this,"_ended",!1),a(this,"_newControllers",[]),a(this,"onEnd",l=>{var c,h,d;if(this._ended)return;this._ended=!0,console.debug("XR Session ended"),i2(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,go(this.onBefore,Me.LateUpdate);const u=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);u>=0&&this.context.pre_render_callbacks.splice(u,1);const p=this.context.post_render_callbacks.indexOf(this.onAfterRender);p>=0&&this.context.post_render_callbacks.splice(p,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var y,f;(y=this.context.mainCameraComponent)==null||y.applyClearFlags(),(f=this.context.mainCameraComponent)==null||f.applyClippingPlane()}),bb({session:this});for(const y of yo._xrEndListeners)y({xr:this});const g=[...this.controllers];for(let y=0;y<g.length;y++)this.disconnectInputSource(g[y].inputSource);this._newControllers.length=0,this.controllers.length=0;for(const y of this._xr_scripts)(c=y?.onLeaveXR)==null||c.call(y,{xr:this});(h=this.sync)==null||h.onExitXR(this),this.context.mainCamera&&((d=this._originalCameraParent)==null||d.add(this.context.mainCamera),this._originalCameraWorldPosition&&dt(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&Gi(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&Pa(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),vr(!1),performance.mark(Wb),performance.measure("NeedleXRSession",Nb,Wb)}),a(this,"_didStart",!1),a(this,"onBefore",l=>{var c,h,d,u,p,g,y,f;const v=l.xrFrame;if(!v)return;performance.mark("NeedleXRSession onBefore start"),this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),((c=this.rig)==null?void 0:c.isActive)==!1&&(yt&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(h=this._mainCamera)!=null&&h.gameObject&&((u=(d=this._mainCamera)==null?void 0:d.gameObject)==null?void 0:u.parent)!==this.rig.gameObject&&this.rig.gameObject.add((p=this._mainCamera)==null?void 0:p.gameObject),this.internalUpdateState(),this.applyCustomForward();const b={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const w=[...this.context.new_scripts_xr];for(let _=0;_<w.length;_++){const C=this.context.new_scripts_xr[_];if(!C||C.destroyed||((g=C.supportsXR)==null?void 0:g.call(C,this.mode))==!1){this.context.new_scripts_xr.splice(_,1);continue}if(!C.activeAndEnabled){this.context.new_scripts_xr.splice(_,1),this.markInactive(C);continue}if(this.addScript(C)){this.invokeCallback_EnterXR(C);for(const R of this.controllers)this.invokeCallback_ControllerAdded(C,R)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const _=ci(this.context.scene.children);if(_){const C=_.getSize(G());if(C.length()>0){const R=this._defaultRig.gameObject;R.position.set(_.min.x+C.x*.5,_.min.y,_.max.z+C.z*.5+1.5);const M=_.getCenter(G());M.y=R.position.y,R.lookAt(M)}}}vb({session:this});for(const _ of yo._xrStartListeners)_(b);const w=[...this._xr_scripts];yt&&console.log("NeedleXRSession start, handle scripts:",w);for(const _ of w){if(_.destroyed){this._script_to_remove.push(_);continue}if(!_.activeAndEnabled){this.markInactive(_);continue}this.invokeCallback_EnterXR(_);for(const C of this.controllers)this.invokeCallback_ControllerAdded(_,C)}}this.syncCameraCullingMask();for(const w of this.controllers)w.onUpdate(v);if(this._newControllers.length>0){const w=[...this._newControllers];this._newControllers.length=0;for(const _ of w){if(!_.connected){console.warn("New controller is not connected",_);continue}this.controllers.push(_);for(const C of this._xr_scripts){if(C.destroyed){this._script_to_remove.push(C);continue}C.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(C,_)}}this.controllers.sort((_,C)=>_.index-C.index)}yt&&this.context.time.frame%30===0&&this.controllers.length<=0&&this.session.inputSources.length>0&&(vr(!0),console.error("XRControllers are not added but inputSources are present")),performance.mark("NeedleXRSession update scripts start");for(const w of this._xr_update_scripts){if(w.destroyed===!0){this._script_to_remove.push(w);continue}if(w.activeAndEnabled===!1){this.markInactive(w);continue}w.onUpdateXR&&w.onUpdateXR(b)}if(performance.mark("NeedleXRSession update scripts end"),performance.measure("NeedleXRSession update scripts","NeedleXRSession update scripts start","NeedleXRSession update scripts end"),this.handleInactiveScripts(),this._script_to_remove.length>0){const w=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const _ of w)!_.destroyed&&this.running&&((y=_.onLeaveXR)==null||y.call(_,b)),this.removeScript(_)}(f=this.sync)==null||f.onUpdate(this),this.onRenderDebug(),performance.mark("NeedleXRSession onBefore end"),performance.measure("NE XR frame","NeedleXRSession onBefore start","NeedleXRSession onBefore end")}),a(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),a(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),X.isDesktop()||!this._renderOnceOnDevice){const l=this.context.renderer;if(l.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const c=l.xr.enabled,h=l.getRenderTarget(),d=this.context.scene.background;l.xr.enabled=!1,l.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):l.render(this.context.scene,this.context.mainCamera),l.xr.enabled=c,l.setRenderTarget(h),this.context.scene.background=d}}}),a(this,"_script_to_remove",[]),a(this,"_camera"),a(this,"_cameraRenderParent",new I().rotateY(Math.PI)),a(this,"_previousCameraParent"),a(this,"_customforward",!0),a(this,"originalCameraNearPlane"),a(this,"_viewerPose"),a(this,"_transformOrientation",new V),a(this,"_transformPosition",new x),a(this,"_transition");var o,r;performance.mark(Nb),t2(s,n.init),this.session=t,this.mode=s,this.context=i,(yt||O("console"))&&vr(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(l=>typeof l.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,Mn(this.onBefore,Me.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((o=n.init.optionalFeatures)!=null&&o.includes("hit-test")||(r=n.init.requiredFeatures)!=null&&r.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(l=>{var c,h;return(h=(c=t.requestHitTestSource)==null?void 0:c.call(t,{space:l}))==null?void 0:h.then(d=>this._viewerHitTestSource=d).catch(d=>console.error(d))}).catch(l=>console.error(l)),this.context.mainCamera&&(this._originalCameraWorldPosition=te(this.context.mainCamera,new x),this._originalCameraWorldRotation=Oe(this.context.mainCamera,new V),this._originalCameraWorldScale=Je(this.context.mainCamera,new x),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new FP,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let l=0;l<t.inputSources.length;l++){const c=t.inputSources[l];if(!c.handedness){console.warn("Input source in xr session has no handedness - ignoring",l);continue}this.onInputSourceAdded(c)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",l=>{for(const c of l.removed)this.disconnectInputSource(c);for(const c of l.added)this.onInputSourceAdded(c)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet),"controllerAutoUpdate"in this.context.renderer.xr?(console.debug("Disabling three.js controllerAutoUpdate"),this.context.renderer.xr.controllerAutoUpdate=!1):yt&&console.warn("controllerAutoUpdate is not available in three.js - cannot disable it")}static getXRSync(s){return this._sync||(this._sync=new Db(s)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var s;return((s=this._activeSession)==null?void 0:s.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(s=>s.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(s){var t;return((t=this.xrSystem)==null?void 0:t.isSessionSupported(s).catch(i=>(yt&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(s){this._sessionRequestStartListeners.push(s)}static offSessionRequestStart(s){const t=this._sessionRequestStartListeners.indexOf(s);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static onSessionRequestEnd(s){this._sessionRequestEndListeners.push(s)}static offSessionRequestEnd(s){const t=this._sessionRequestEndListeners.indexOf(s);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static onXRSessionStart(s){this._xrStartListeners.push(s)}static offXRSessionStart(s){const t=this._xrStartListeners.indexOf(s);t>=0&&this._xrStartListeners.splice(t,1)}static onXRSessionEnd(s){this._xrEndListeners.push(s)}static offXRSessionEnd(s){const t=this._xrEndListeners.indexOf(s);t>=0&&this._xrEndListeners.splice(t,1)}static onControllerAdded(s){this._controllerAddedListeners.push(s)}static offControllerAdded(s){const t=this._controllerAddedListeners.indexOf(s);t>=0&&this._controllerAddedListeners.splice(t,1)}static onControllerRemoved(s){this._controllerRemovedListeners.push(s)}static offControllerRemoved(s){const t=this._controllerRemovedListeners.indexOf(s);t>=0&&this._controllerRemovedListeners.splice(t,1)}static offerSession(s,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+s),t=="default"&&(t=this.getDefaultSessionInit(s)),navigator.xr.offerSession(s,{...t}).then(n=>yo.setSession(s,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(s){switch(s){case"immersive-ar":const t=["anchors","local-floor","layers","dom-overlay","hit-test","unbounded"];return X.isVisionOS()||t.push("hand-tracking"),{optionalFeatures:t};case"immersive-vr":const i=["local-floor","bounded-floor","high-fixed-foveation-level","layers"];return X.isVisionOS()||i.push("hand-tracking"),{optionalFeatures:i};default:return console.warn("No default session init for mode",s),{}}}static async start(s,t,i){var n,o,r,l;if(X.isiOS()){if(s==="ar")if(await this.isARSupported())s="immersive-ar";else return yc.exportAndOpen(),null}else s=="ar"&&(s="immersive-ar");if(F()&&O("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await Aa.start(s,t||yo.getDefaultSessionInit(s)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(yt||F())&&xe("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(i||(i=ee.Current),i||(i=ge.All[0]),!i)throw new Error("No Needle Engine Context found");switch(performance.mark("NeedleXRSession start"),t||(t={}),s){case"immersive-ar":{if(await((n=this.xrSystem)==null?void 0:n.isSessionSupported("immersive-ar"))!==!0)return console.error(s+" is not supported by this browser."),null;const u=this.getDefaultSessionInit(s),p=JP(i.domElement);p&&!X.isQuest()&&(u.domOverlay={root:p},u.optionalFeatures.push("dom-overlay")),t={...u,...t}}break;case"immersive-vr":{if(await((o=this.xrSystem)==null?void 0:o.isSessionSupported("immersive-vr"))!==!0)return console.error(s+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(s),...t}}break;default:console.warn("No default session init for mode",s);break}t.optionalFeatures??(t.optionalFeatures=[]),t.requiredFeatures??(t.requiredFeatures=[]),await Aa.stop();const c=s=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;yt?console.log(`%cRequesting ${s} session`,"font-weight:bold;",t,c):console.log(`%cRequesting ${s} session`,"font-weight:bold;");for(const u of c)u.onBeforeXR&&u.onBeforeXR(s,t);for(const u of this._sessionRequestStartListeners)u({mode:s,init:t});yt&&De("Requesting "+s+" session ("+Date.now()+")"),this._currentSessionRequest=(r=navigator.xr)==null?void 0:r.requestSession(s,t),this._currentSessionRequestMode=s;const h=await((l=this._currentSessionRequest)==null?void 0:l.catch(u=>{console.error(u,"Code: "+u.code),u.code===9&&xe("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&xe("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const u of this._sessionRequestEndListeners)u({mode:s,init:t,newSession:h||null});if(!h)return console.warn("XR Session request was rejected"),null;const d=this.setSession(s,h,t,i);return performance.mark("NeedleXRSession end"),performance.measure("NeedleXRSession Startup","NeedleXRSession start","NeedleXRSession end"),d}static setSession(s,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const o=s=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new yo(s,t,n,{scripts:o,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),yt?console.log(`%cStarted ${s} session`,"font-weight:bold;",o):console.log(`%cStarted ${s} session`,"font-weight:bold;"),this._activeSession}static stop(){var s;(s=this._activeSession)==null||s.end()}get sync(){return yo._sync}get running(){return!this._ended&&this.session!=null}get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get isVisibleBlurred(){return this.session.visibilityState==="visible-blurred"}get isSystemKeyboardSupported(){return this.session.isSystemKeyboardSupported}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}get leftController(){return this.controllers.find(s=>s.side==="left")}get rightController(){return this.controllers.find(s=>s.side==="right")}getController(s){return typeof s=="number"?this.controllers[s]||null:this.controllers.find(t=>t.side===s)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(s=>s.inputSource.targetRayMode==="tracked-pointer")||F()&&X.isDesktop()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const s=this.frame.getImageTrackingResults();for(const t of s)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const s=this._rigs[0]??null;return s!=null&&s.gameObject&&Pr(s.gameObject)||s?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):s}get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(s){this._rigs.indexOf(s)>=0||(s.priority===void 0&&(s.priority=0),this._rigs.push(s),this.updateActiveXRRig())}removeRig(s){const t=this._rigs.indexOf(s);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(s){const t=this._rigs.indexOf(s),i=this._rigs[0];this._rigs.splice(t,1),this._rigs.unshift(s),s.priority=i?.priority??0,this.updateActiveXRRig()}getUserOffsetInRig(){var s;const t=(s=this.context.mainCamera)==null?void 0:s.position;if(!t||!this.rig)return G(0,0,0);const i=G(t);return i.x*=-1,i.z*=-1,i.applyQuaternion(vs(this.rig.gameObject.quaternion)),i}updateActiveXRRig(){const s=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(Pr(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(s!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}yt&&(s===t?console.log("Updated Active XR Rig:",t,"prev:",s):console.log("Updated Active XRRig:",t," (the same as before)"))}getHitTest(s){if(s)return this.getControllerHitTest(s);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(s){const t=s.getHitTestSource();if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===s.inputSource)for(const o of n.results)return this.convertHitTestResult(o);return null}convertHitTestResult(s){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&s.getPose(t);if(i){const n=G(i.transform.position),o=vs(i.transform.orientation),r=this.context.mainCamera;if(r?.parent!==this._cameraRenderParent&&n.applyMatrix4(Ra),r!=null&&r.parent){n.applyMatrix4(r.parent.matrixWorld),o.multiply(Yi);const l=Oe(r.parent);l.premultiply(Yi),o.premultiply(l)}return{hit:s,position:n,quaternion:o}}return null}convertSpace(s){const t=G(s.position);t.applyMatrix4(Ra);const i=vs(s.orientation);return i.premultiply(Yi),{position:t,quaternion:i}}disconnectInputSource(s){const t=(i,n,o)=>{if(i.inputSource===s){yt&&console.log("Disconnecting controller",i.index),this.controllers.splice(o,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const r={xr:this,controller:i,change:"removed"};for(const l of this._xr_scripts)l.onXRControllerRemoved&&l.onXRControllerRemoved(r);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const n=this.controllers[i];t(n,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const n=this._newControllers[i];t(n,this._newControllers,i)}}end(){this._ended||this.session.end().catch(s=>console.warn(s))}onRenderDebug(){if(yt)for(const s of this.controllers)s.onRenderDebug();if((yt||Vb)&&this.rig&&(vg++,vg>=20)){const s=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;s.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;s.add(i.multiplyScalar(2.5));let n="";if(n+=`${this.context.time.smoothedFps.toFixed(0)} FPS`,n+=`, calls: ${this.context.renderer.info.render.calls}, tris: ${this.context.renderer.info.render.triangles.toLocaleString()}`,yt||Vb)for(const o of this.controllers)n+=`
|
|
154
|
-
${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;vg=0,q.DrawLabel(s,n,void 0,1/60*20)}}addScript(s){return this._xr_scripts.includes(s)?!1:(yt&&console.log("Register new XRScript",s),this._xr_scripts.push(s),typeof s.onUpdateXR=="function"&&this._xr_update_scripts.push(s),!0)}markInactive(s){if(!(this._inactive_scripts.indexOf(s)>=0)){this.removeScript(s,!1),this._inactive_scripts.push(s);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(s,t);this.invokeCallback_LeaveXR(s)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let s=this._inactive_scripts.length-1;s>=0;s--){const t=this._inactive_scripts[s];if(t.activeAndEnabled){this._inactive_scripts.splice(s,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}removeScript(s,t=!0){yt&&console.log("Remove XRScript",s);const i=this._xr_scripts.indexOf(s);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(s);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(s);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(s){s.onEnterXR&&s.onEnterXR({xr:this})}invokeCallback_ControllerAdded(s,t){s.onXRControllerAdded&&s.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(s,t){s.onXRControllerRemoved&&s.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(s){s.onLeaveXR&&!s.destroyed&&s.onLeaveXR({xr:this})}syncCameraCullingMask(){var s;const t=this.context.xrCamera,i=(s=this.context.mainCameraComponent)==null?void 0:s.cullingMask;if(t&&i!==void 0){for(const n of t.cameras)n.layers.mask=i;t.layers.mask=i}else if(t){for(const n of t.cameras)n.layers.enableAll();t.layers.enableAll()}}invokeControllerEvent(s,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:s,change:i})}catch(r){console.error(r)}}}applyCustomForward(){var s;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(s=this._previousCameraParent)==null||s.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let t=.02;if(this.rig){const i=Je(this.rig.gameObject);t*=i.x}this._camera instanceof we&&this._camera.near>t&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=t)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof we&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const s=this.context.renderer.xr.getReferenceSpace();if(!s){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(s),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}get transition(){return this._transition||(this._transition=new Bb),this._transition}fadeTransition(){return this._transition||(this._transition=new Bb),this._transition.fadeTransition()}updateFade(s){this._transition&&s instanceof we&&this._transition.update(s,this.context.time.deltaTime)}onUpdateFade_PostRender(){var s;(s=this._transition)==null||s.remove()}};let J=yo;a(J,"_sync",null),a(J,"_currentSessionRequestMode",null),a(J,"_currentSessionRequest"),a(J,"_activeSession"),a(J,"_sessionRequestStartListeners",[]),a(J,"_sessionRequestEndListeners",[]),a(J,"_xrStartListeners",[]),a(J,"_xrEndListeners",[]),a(J,"_controllerAddedListeners",[]),a(J,"_controllerRemovedListeners",[]),a(J,"onEnd",()=>{yt&&console.log("XR Session ended"),yo._activeSession=null});const _g=O("debugwebxr");class $b{static tryFindAvatarObjects(t,i,n){if(n.head&&n.leftHand&&n.rightHand)return;const o=t.name.toLocaleLowerCase();!n.head&&o.includes("head")&&(_g&&console.log("FOUND AVATAR HEAD",t.name),n.head=new le("",i,t)),o.includes("hand")&&(!n.leftHand&&o.includes("left")&&(_g&&console.log("FOUND AVATAR LEFT HAND",t.name),n.leftHand=new le("",i,t)),!n.rightHand&&o.includes("right")&&(_g&&console.log("FOUND AVATAR RIGHT HAND",t.name),n.rightHand=new le("",i,t)));for(let r=0;r<t.children.length;r++){if(n.head&&n.leftHand&&n.rightHand)return;const l=t.children[r];this.tryFindAvatarObjects(l,i,n)}}}const Nt=new x,qb=new x,Gb=new V,n2=O("debuggizmos"),xs=8947848,wg=32,Ss=class{constructor(){}static isGizmo(s){return s[Sg]!==void 0}static DrawLabel(s,t,i=.05,n=0,o,r,l){var c;if(!Ss.enabled)return null;o||(o=xs);const h=((c=J.active)==null?void 0:c.rigScale)??1,d=Ae.getTextLabel(n,t,i*h,o,r);return l instanceof I&&l.add(d),d.position.x=s.x,d.position.y=s.y,d.position.z=s.z,d}static DrawRay(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getLine(n),l=r.geometry.getAttribute("position");l.setXYZ(0,s.x,s.y,s.z),Nt.set(t.x,t.y,t.z).multiplyScalar(999999999),l.setXYZ(1,s.x+Nt.x,s.y+Nt.y,s.z+Nt.z),l.needsUpdate=!0,r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1}static DrawDirection(s,t,i=xs,n=0,o=!0,r=1){if(!Ss.enabled)return;const l=Ae.getLine(n),c=l.geometry.getAttribute("position");c.setXYZ(0,s.x,s.y,s.z),t.w!==void 0?(Nt.set(0,0,-r),Gb.set(t.x,t.y,t.z,t.w),Nt.applyQuaternion(Gb)):(Nt.set(t.x,t.y,t.z),Nt.multiplyScalar(r)),c.setXYZ(1,s.x+Nt.x,s.y+Nt.y,s.z+Nt.z),c.needsUpdate=!0,l.material.color.set(i),l.material.depthTest=o,l.material.depthWrite=!1}static DrawLine(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getLine(n),l=r.geometry.getAttribute("position");l.setXYZ(0,s.x,s.y,s.z),l.setXYZ(1,t.x,t.y,t.z),l.needsUpdate=!0,r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1}static DrawCircle(s,t,i,n=xs,o=0,r=!0){if(!Ss.enabled)return;const l=Ae.getCircle(o);l.position.set(s.x,s.y,s.z),l.scale.set(i,i,i),l.quaternion.setFromUnitVectors(this._up,Nt.set(t.x,t.y,t.z).normalize()),l.material.color.set(n),l.material.depthTest=r,l.material.depthWrite=!1,l.material.fog=!1}static DrawWireSphere(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getSphere(t,n,!0);fr(r,s.x,s.y,s.z),r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1}static DrawSphere(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getSphere(t,n,!1);fr(r,s.x,s.y,s.z),r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1}static DrawWireBox(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getBox(n);r.position.set(s.x,s.y,s.z),r.scale.set(t.x,t.y,t.z),r.material.color.set(i),r.material.depthTest=o,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawWireBox3(s,t=xs,i=0,n=!0){if(!Ss.enabled)return;const o=Ae.getBox(i);o.position.copy(s.getCenter(Nt)),o.scale.copy(s.getSize(Nt)),o.material.color.set(t),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawArrow(s,t,i=xs,n=0,o=!0,r=!1){if(!Ss.enabled)return;const l=Ae.getArrowHead(n);l.position.set(t.x,t.y,t.z),l.quaternion.setFromUnitVectors(this._up.set(0,1,0),Nt.set(t.x,t.y,t.z).sub(qb.set(s.x,s.y,s.z)).normalize());const c=Nt.set(t.x,t.y,t.z).sub(qb.set(s.x,s.y,s.z)).length()*.1;l.scale.set(c,c,c),l.material.color.set(i),l.material.depthTest=o,l.material.wireframe=r,this.DrawLine(s,t,i,n,o)}static DrawWireMesh(s){const t=Ae.getMesh(s.duration??0);"mesh"in s?(t.geometry=s.mesh.geometry,t.matrix.copy(s.mesh.matrixWorld)):(t.geometry=s.geometry,t.matrix.copy(s.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.color.set(s.color??xs),t.material.depthTest=s.depthTest??!0,t.material.wireframe=!0}static setVisible(s){for(const t of Ae.timedObjectsBuffer)t.visible=s}};let q=Ss;a(q,"enabled",!0),a(q,"_up",new x(0,1,0));const o2=new Ql(1,1,1);function xg(s=null){const t=new ae(s??14540253),i=new bS(o2);return new Zy(i,new Ky({color:t}))}const Sg=Symbol("GizmoCache");class Ae{static ensureFont(){let t=Te.FontLibrary.getFontFamily(this.familyName);if(!t){t=Te.FontLibrary.addFontFamily(this.familyName);const i=t.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");i?.addEventListener("ready",()=>{Te.update()})}}static getTextLabel(t,i,n,o,r){this.ensureFont();let l=this.textLabelCache.pop(),c=1;r&&typeof r=="string"&&r?.length>=8&&r.startsWith("#")?(c=parseInt(r.substring(7),16)/255,r=r.substring(0,7),n2&&console.log(r,c)):typeof r=="object"&&r.a!==void 0&&(c=r.a);const h={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:n,color:o,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:c,textContent:i,borderRadius:.5*n,padding:.8*n,whiteSpace:"pre",offset:.05*n};if(l)l.set(h);else{l=new _v(h);const d=this,u=l;u.setText=function(p){this.set({textContent:p}),d.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(ee.Current,l,t,this.textLabelCache),l}static getBox(t){let i=this.boxesCache.pop();if(!i){const n=new Ql(1,1,1);i=new Z(n)}return this.registerTimedObject(ee.Current,i,t,this.boxesCache),i}static getLine(t){let i=this.linesCache.pop();if(!i){i=new Yl;let n=i.geometry.getAttribute("position");n||(n=new ft(new Float32Array(2*3),3),i.geometry.setAttribute("position",n))}return i.frustumCulled=!1,this.registerTimedObject(ee.Current,i,t,this.linesCache),i}static getCircle(t){let i=this.circlesCache.pop();if(!i){i=new Yl;let n=i.geometry.getAttribute("position");if(!n){n=new ft(new Float32Array(wg*3),3),i.geometry.setAttribute("position",n);const o=G(0,1,0),r=G(0,0,1),l=G(r);l.cross(o).normalize();const c=G(l),h=Math.PI*2/(wg-1);for(let d=0;d<wg+1;d++){const u=h*d;o.copy(c).multiplyScalar(Math.cos(u)*1),l.copy(r).multiplyScalar(Math.sin(u)*1);const p=o.add(l);n.setXYZ(d,p.x,p.y,p.z)}}}return i.frustumCulled=!1,this.registerTimedObject(ee.Current,i,t,this.circlesCache),i}static getSphere(t,i,n){let o=this.spheresCache.pop();return o||(o=new Z(new pd(1,8,8))),o.scale.set(t,t,t),o.material.wireframe=n,this.registerTimedObject(ee.Current,o,i,this.spheresCache),o}static getArrowHead(t){let i=this.arrowHeadsCache.pop();return i||(i=new Z(new vS(0,.5,1,8))),this.registerTimedObject(ee.Current,i,t,this.arrowHeadsCache),i}static getMesh(t){let i=this.mesh.pop();return i||(i=new Z,i.material=new Re),this.registerTimedObject(ee.Current,i,t,this.mesh),i}static registerTimedObject(t,i,n,o){if(!t){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const r=this.contextBeforeRenderCallbacks.get(t),l=this.contextPostRenderCallbacks.get(t);if(r){if(t.pre_render_callbacks[t.pre_render_callbacks.length-1]!==r){const c=t.pre_render_callbacks.indexOf(r);c>=0&&t.pre_render_callbacks.splice(c,1),t.pre_render_callbacks.push(r)}}else{const c=()=>{this.onBeforeRender(t,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(t,c),t.pre_render_callbacks.push(c)}if(l){if(t.post_render_callbacks[t.post_render_callbacks.length-1]!==l){const c=t.post_render_callbacks.indexOf(l);c>=0&&t.post_render_callbacks.splice(c,1),t.post_render_callbacks.push(l)}}else{const c=()=>{this.onPostRender(t,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(t,c),t.post_render_callbacks.push(c)}i.traverse(c=>{c.layers.disableAll(),c.layers.enable(2)}),i.renderOrder=999999,i[Sg]=o,i.castShadow=!1,i.receiveShadow=!1,i.isGizmo=!0,this.timedObjectsBuffer.push(i),this.timesBuffer.push(ee.Current.time.realtimeSinceStartup+n),t.scene.add(i)}static onBeforeRender(t,i){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,Te.update());for(let n=0;n<i.length;n++){const o=i[n];if(t.mainCamera&&o instanceof Te.MeshUIBaseElement){if(Pr(o))continue;const r=t.isInVR,l=!1,c=!r;nc(o,t.mainCamera,l,c)}}}static onPostRender(t,i,n){const o=t.time.realtimeSinceStartup;for(let r=i.length-1;r>=0;r--){const l=i[r];o>=n[r]-1e-6&&(i.splice(r,1),n.splice(r,1),l.removeFromParent(),Pr(l)!=!0&&l[Sg].push(l))}}}a(Ae,"familyName","needle-gizmos"),a(Ae,"linesCache",[]),a(Ae,"circlesCache",[]),a(Ae,"spheresCache",[]),a(Ae,"boxesCache",[]),a(Ae,"arrowHeadsCache",[]),a(Ae,"mesh",[]),a(Ae,"textLabelCache",[]),a(Ae,"timedObjectsBuffer",new Array),a(Ae,"timesBuffer",new Array),a(Ae,"contextPostRenderCallbacks",new Map),a(Ae,"contextBeforeRenderCallbacks",new Map),a(Ae,"tmuiNeedsUpdate",!1);const ki=O("debugphysics"),Xb=new ro;class Ws{constructor(){a(this,"ray"),a(this,"cam"),a(this,"screenPoint"),a(this,"raycaster"),a(this,"results"),a(this,"targets"),a(this,"recursive",!0),a(this,"minDistance"),a(this,"maxDistance"),a(this,"lineThreshold"),a(this,"layerMask"),a(this,"ignore"),a(this,"testObject"),a(this,"useAcceleratedRaycast")}screenPointFromOffset(t,i){this.screenPoint===void 0&&(this.screenPoint=new re),this.screenPoint.x=t/window.innerWidth*2-1,this.screenPoint.y=-(i/window.innerHeight)*2+1}setLayer(t){Xb.set(t),this.layerMask=Xb}setMask(t){this.layerMask||(this.layerMask=new ro);const i=this.layerMask;i?i.mask=t:this.layerMask=t}}a(Ws,"AllLayers",4294967295);class Cg{constructor(t,i,n){a(this,"distance"),a(this,"point"),a(this,"object"),this.object=t,this.distance=i,this.point=n}}const Og=class{constructor(s){a(this,"context"),a(this,"engine"),a(this,"raycaster",new gd),a(this,"defaultRaycastOptions",new Ws),a(this,"targetBuffer",new Array(1)),a(this,"defaultThresholds",{Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}}),a(this,"sphereResults",new Array),a(this,"sphereMask",new ro),a(this,"sphere",new md),a(this,"tempBoundingBox",new wi),this.context=s}static get raycasting(){return this._raycasting>0}raycastPhysicsFast(s,t=void 0,i=1/0,n=!0){var o;return((o=this.context.physics.engine)==null?void 0:o.raycast(s,t,{maxDistance:i,solid:n}))??null}raycastPhysicsFastAndGetNormal(s,t=void 0,i=1/0,n=!0){var o;return((o=this.context.physics.engine)==null?void 0:o.raycastAndGetNormal(s,t,{maxDistance:i,solid:n}))??null}sphereOverlapPhysics(s,t){var i;return((i=this.context.physics.engine)==null?void 0:i.sphereOverlap(s,t))??null}sphereOverlap(s,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const l of this.context.scene.children)this.intersectSphere(l,s,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((l,c)=>l.distance-c.distance)}raycastFromRay(s,t=null){const i=t??this.defaultRaycastOptions;i.ray=s;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(s=null){ki&&performance.mark("raycast.start"),s||(s=this.defaultRaycastOptions);const t=s.screenPoint??this.context.input.mousePositionRC,i=s.raycaster??this.raycaster;if(i.near=s.minDistance??0,i.far=s.maxDistance??1/0,i.params=this.defaultThresholds,s.lineThreshold===void 0&&(s.lineThreshold=-1),i.params.Line={threshold:s.lineThreshold},s.ray)i.ray.copy(s.ray);else{const l=s.cam??this.context.mainCamera;if(!l)return ki&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const c=this.context.xrCamera;this.context.isInXR&&c instanceof _S&&c.cameras.length>0?i.setFromCamera(t,c.cameras[0]):i.setFromCamera(t,l)}let n=s.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=s.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),s.layerMask!==void 0?s.layerMask instanceof ro?i.layers.mask=s.layerMask.mask:i.layers.mask=s.layerMask:(i.layers.enableAll(),i.layers.disable(2)),ki&&console.time("raycast"),o.length=0,Og._raycasting++,this.intersect(this.raycaster,n,o,s),o.sort((l,c)=>l.distance-c.distance);const r=s.ignore;return r!==void 0&&r.length>0&&(o=o.filter(l=>!r.includes(l.object))),Og._raycasting--,ki&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o!=null&&o.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(s,t,i,n){var o,r,l;for(const c of t){if(!c||c.visible===!1||q.isGizmo(c)||n.lineThreshold!==void 0&&n.lineThreshold<0&&c instanceof Yl)continue;let h=!0;const d=c,u=d.geometry;if(n.testObject){const p=(o=n.testObject)==null?void 0:o.call(n,c);if(p===!1)continue;p==="continue in children"&&(h=!1)}if(h&&(u&&Qb(u)||(h=!1)),h){const p=cv(c);p&&(d.geometry=p);const g=i.length;let y=!0;if(n.precise===!1&&(y=!1),y||(y=((l=(r=u.getAttribute("position"))==null?void 0:r.array)==null?void 0:l.length)<64),d instanceof Sa&&(y=!1),!y&&a2(d,s,i)||(n.useAcceleratedRaycast!==!1?Vd.runMeshBVHRaycast(s,d,i,this.context):s.intersectObject(d,!1,i)),ki&&i.length!=g){const f=i[i.length-1],v=p?8969557:7798784;q.DrawWireSphere(f.point,.1,v,1,!1),q.DrawWireMesh({mesh:c,depthTest:!1,duration:.2,color:v})}d.geometry=u}n.recursive!==!1&&this.intersect(s,c.children,i,n)}return i}intersectSphere(s,t,i,n,o,r,l,c){let h=s&&s.isMesh&&s.layers.test(n)&&!q.isGizmo(s);h&&(h=s.visible),h&&(h=!(s instanceof Yl)),h&&(h=!(s instanceof Sa));const d=s,u=d.geometry;if(h&&c){const p=c(s);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&Qb(u)||(h=!1),h){if(l){const p=this.sphere;p.center.copy(t),p.radius=i;const g=o.length;if(Vd.runMeshBVHRaycast(this.sphere,d,o,this.context),g!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),g=this.sphere;if(g.center.copy(t),g.radius=i,g.intersectsBox(p)){const y=te(s),f=y.distanceTo(g.center),v=new Cg(s,f,y);if(o.push(v),!r)return}}}if(s.children)for(const p of s.children){const g=o.length;if(this.intersectSphere(p,t,i,n,o,r,l,c),g!=o.length&&!r)return}}};let Nd=Og;a(Nd,"_raycasting",0);function Qb(s){return!(s.index&&s.index.array.length<3)}const wr=new md,Wd=new ur,r2=new Xy;function a2(s,t,i){const n=s._computeIntersections;if(!n)return!1;let o=s["_computeIntersections:Needle"];return o||(o=s["_computeIntersections:Needle"]=function(r,l,c){const h=this,d=h.geometry.boundingSphere;if(d){if(h instanceof Sa){Wd.setFromNormalAndCoplanarPoint(G(0,1,0),G(0,-h.position.y,0)),Wd.applyMatrix4(h.matrixWorld,r2);const p=r.ray.intersectPlane(Wd,G());if(p){wr.copy(d),wr.applyMatrix4(h.matrixWorld);const g=G(p).sub(r.ray.origin).length(),y=wr.radius*.5;g<y&&l.push({distance:g,point:p,object:h,normal:Wd.normal.clone()})}return}wr.copy(d),wr.applyMatrix4(h.matrixWorld);const u=r.ray.intersectSphere(wr,G());if(u){const p=G(u).sub(r.ray.origin),g=p.length();if(g>wr.radius){const y=p.clone().normalize();l.push({distance:g,point:u,object:h,normal:y})}}}}),s._computeIntersections=o,t.intersectObject(s,!1,i),s._computeIntersections=n,!0}var Vd;(s=>{function t(w,_,C,R){var M,T,j;if(!_.geometry||!_.geometry.hasAttribute("position"))return!1;const L=_.geometry;if(_!=null&&_.isSkinnedMesh){const U=_,B=U.bvhNeedsUpdate;if(!U.staticGenerator)c(),r&&(U.staticGenerator=new r(_),U.staticGenerator.applyWorldTransforms=!1,U.staticGeometry=U.staticGenerator.generate(),L.boundsTree=l?.call(U.staticGeometry),U.staticGeometryLastUpdate=performance.now()+Math.random()*200,U.autoUpdateMeshBVH===void 0&&(U.autoUpdateMeshBVH=!1));else if(L.boundsTree&&(U.autoUpdateMeshBVH===!0||B===!0)){const Y=performance.now(),$=Y-U.staticGeometryLastUpdate;(B||$>100)&&(U.bvhNeedsUpdate=!1,U.staticGeometryLastUpdate=Y,(M=U.staticGenerator)==null||M.generate(U.staticGeometry),L.boundsTree.refit())}}else if(!L.boundsTree){d||b();let U=!0;if((R.xr||L[y]===!1||(T=L.getAttribute("position"))!=null&&T.isInterleavedBufferAttribute||L.index&&(j=L.index)!=null&&j.isInterleavedBufferAttribute)&&(U=!1),U&&p){if(L[g]===void 0){let B=null;if(v.length>0){const Y=v.shift();Y&&!Y.running&&(B=Y)}if(!B&&f.length<3&&(B=new p,f.push(B)),B!=null&&!B.running){const Y=_.name;ki&&console.log("<<<< worker start",Y,B),L[g]="queued",performance.mark("bvh.create.start");const $=L.clone();try{B.generate($).then(E=>{L[g]="done",L.boundsTree=E}).catch(E=>{L[g]="failed - "+E?.message,L[y]=!1,ki&&console.error("Failed to generate mesh bvh on worker",E)}).finally(()=>{ki&&console.log(">>>>> worker done",Y,{hasBoundsTre:L.boundsTree!=null}),v.push(B),$.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch(E){console.error("Failed to generate mesh bvh on worker",E)}}else ki&&console.warn("No worker available")}}else(!u||!U)&&(c(),o&&(performance.mark("bvh.create.start"),L.boundsTree=new o(L),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(w instanceof gd){const U=w,B=_.raycast;L.boundsTree?(c(),n&&(_.acceleratedRaycast||(_.acceleratedRaycast=n.bind(_),ki&&console.debug(`Physics: bind acceleratedRaycast fn to "${_.name}"`)),_.raycast=_.acceleratedRaycast)):ki&&console.warn("No bounds tree found for mesh",_.name,{workerTask:L[g],hasAcceleratedRaycast:n!=null});const Y=U.firstHitOnly;return U.firstHitOnly=!1,U.intersectObject(_,!1,C),U.firstHitOnly=Y,_.raycast=B,!0}else if(w instanceof md){const U=L.boundsTree;if(U){const B=w;if(h.copy(_.matrixWorld).invert(),B.applyMatrix4(h),U.intersectsSphere(B)){const Y=te(_),$=Y.distanceTo(B.center),E=new Cg(_,$,Y);C.push(E)}}return!0}return!1}s.runMeshBVHRaycast=t;let i=!1,n=null,o=null,r=null,l=null;function c(){i||(i=!0,import("./vendor.light.min.js").then(w=>w.k).then(w=>{n=w.acceleratedRaycast,o=w.MeshBVH,r=w.StaticGeometryGenerator,l=w.computeBoundsTree}).catch(w=>{(ki||F())&&console.error("Failed to load BVH library...",w.message)}))}const h=new ne;let d=!1,u=!1,p=null;const g=Symbol("Needle:MeshBVH-Worker"),y=Symbol("Needle:MeshBVH-CanUseWorker"),f=[],v=[];function b(){d=!0,u=!0,Promise.resolve().then(()=>Xj).then(w=>{p=w.GenerateMeshBVHWorker}).catch(w=>{(ki||F())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{u=!1})}})(Vd||(Vd={}));const Yb=Symbol("gltf-loader-internal-usage-tracker"),l2=O("debugusers"),Hd=class{constructor(s){a(this,"parser"),a(this,"_getDependency"),a(this,"_loadingId"),a(this,"_loadedObjects",new Set),this.parser=s,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(s){return Hd._loadingProcesses>0}beforeRoot(){Hd._loadingProcesses++;const s=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(s._loadedObjects.add(r),r[Yb]=s._loadingId),r)),o},null}afterRoot(s){Hd._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[Yb],t instanceof I&&(t.parent||t instanceof Z&&setTimeout(()=>{l2&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}};let Pg=Hd;a(Pg,"_loadingProcesses",0);class Zb{constructor(){window.addEventListener("unhandledrejection",t=>{var i;if(t.defaultPrevented)return;const n=(i=t?.reason)==null?void 0:i.path;if(n){const o=n[0];o&&o.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
154
|
+
${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;vg=0,q.DrawLabel(s,n,void 0,1/60*20)}}addScript(s){return this._xr_scripts.includes(s)?!1:(yt&&console.log("Register new XRScript",s),this._xr_scripts.push(s),typeof s.onUpdateXR=="function"&&this._xr_update_scripts.push(s),!0)}markInactive(s){if(!(this._inactive_scripts.indexOf(s)>=0)){this.removeScript(s,!1),this._inactive_scripts.push(s);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(s,t);this.invokeCallback_LeaveXR(s)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let s=this._inactive_scripts.length-1;s>=0;s--){const t=this._inactive_scripts[s];if(t.activeAndEnabled){this._inactive_scripts.splice(s,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}removeScript(s,t=!0){yt&&console.log("Remove XRScript",s);const i=this._xr_scripts.indexOf(s);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(s);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(s);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(s){s.onEnterXR&&s.onEnterXR({xr:this})}invokeCallback_ControllerAdded(s,t){s.onXRControllerAdded&&s.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(s,t){s.onXRControllerRemoved&&s.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(s){s.onLeaveXR&&!s.destroyed&&s.onLeaveXR({xr:this})}syncCameraCullingMask(){var s;const t=this.context.xrCamera,i=(s=this.context.mainCameraComponent)==null?void 0:s.cullingMask;if(t&&i!==void 0){for(const n of t.cameras)n.layers.mask=i;t.layers.mask=i}else if(t){for(const n of t.cameras)n.layers.enableAll();t.layers.enableAll()}}invokeControllerEvent(s,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:s,change:i})}catch(r){console.error(r)}}}applyCustomForward(){var s;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(s=this._previousCameraParent)==null||s.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let t=.02;if(this.rig){const i=Je(this.rig.gameObject);t*=i.x}this._camera instanceof we&&this._camera.near>t&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=t)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof we&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const s=this.context.renderer.xr.getReferenceSpace();if(!s){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(s),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}get transition(){return this._transition||(this._transition=new Bb),this._transition}fadeTransition(){return this._transition||(this._transition=new Bb),this._transition.fadeTransition()}updateFade(s){this._transition&&s instanceof we&&this._transition.update(s,this.context.time.deltaTime)}onUpdateFade_PostRender(){var s;(s=this._transition)==null||s.remove()}};let J=yo;a(J,"_sync",null),a(J,"_currentSessionRequestMode",null),a(J,"_currentSessionRequest"),a(J,"_activeSession"),a(J,"_sessionRequestStartListeners",[]),a(J,"_sessionRequestEndListeners",[]),a(J,"_xrStartListeners",[]),a(J,"_xrEndListeners",[]),a(J,"_controllerAddedListeners",[]),a(J,"_controllerRemovedListeners",[]),a(J,"onEnd",()=>{yt&&console.log("XR Session ended"),yo._activeSession=null});const _g=O("debugwebxr");class $b{static tryFindAvatarObjects(t,i,n){if(n.head&&n.leftHand&&n.rightHand)return;const o=t.name.toLocaleLowerCase();!n.head&&o.includes("head")&&(_g&&console.log("FOUND AVATAR HEAD",t.name),n.head=new le("",i,t)),o.includes("hand")&&(!n.leftHand&&o.includes("left")&&(_g&&console.log("FOUND AVATAR LEFT HAND",t.name),n.leftHand=new le("",i,t)),!n.rightHand&&o.includes("right")&&(_g&&console.log("FOUND AVATAR RIGHT HAND",t.name),n.rightHand=new le("",i,t)));for(let r=0;r<t.children.length;r++){if(n.head&&n.leftHand&&n.rightHand)return;const l=t.children[r];this.tryFindAvatarObjects(l,i,n)}}}const Nt=new x,qb=new x,Gb=new V,n2=O("debuggizmos"),xs=8947848,wg=32,Ss=class{constructor(){}static isGizmo(s){return s[Sg]!==void 0}static setVisible(s){for(const t of Ae.timedObjectsBuffer)t.visible=s}static DrawLabel(s,t,i=.05,n=0,o,r,l){var c;if(!Ss.enabled)return null;o||(o=xs);const h=((c=J.active)==null?void 0:c.rigScale)??1,d=Ae.getTextLabel(n,t,i*h,o,r);return l instanceof I&&l.add(d),d.position.x=s.x,d.position.y=s.y,d.position.z=s.z,d}static DrawRay(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getLine(n),l=r.geometry.getAttribute("position");l.setXYZ(0,s.x,s.y,s.z),Nt.set(t.x,t.y,t.z).multiplyScalar(999999999),l.setXYZ(1,s.x+Nt.x,s.y+Nt.y,s.z+Nt.z),l.needsUpdate=!0,r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1}static DrawDirection(s,t,i=xs,n=0,o=!0,r=1){if(!Ss.enabled)return;const l=Ae.getLine(n),c=l.geometry.getAttribute("position");c.setXYZ(0,s.x,s.y,s.z),t.w!==void 0?(Nt.set(0,0,-r),Gb.set(t.x,t.y,t.z,t.w),Nt.applyQuaternion(Gb)):(Nt.set(t.x,t.y,t.z),Nt.multiplyScalar(r)),c.setXYZ(1,s.x+Nt.x,s.y+Nt.y,s.z+Nt.z),c.needsUpdate=!0,l.material.color.set(i),l.material.depthTest=o,l.material.depthWrite=!1}static DrawLine(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getLine(n),l=r.geometry.getAttribute("position");l.setXYZ(0,s.x,s.y,s.z),l.setXYZ(1,t.x,t.y,t.z),l.needsUpdate=!0,r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1}static DrawCircle(s,t,i,n=xs,o=0,r=!0){if(!Ss.enabled)return;const l=Ae.getCircle(o);l.position.set(s.x,s.y,s.z),l.scale.set(i,i,i),l.quaternion.setFromUnitVectors(this._up,Nt.set(t.x,t.y,t.z).normalize()),l.material.color.set(n),l.material.depthTest=r,l.material.depthWrite=!1,l.material.fog=!1}static DrawWireSphere(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getSphere(t,n,!0);fr(r,s.x,s.y,s.z),r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1}static DrawSphere(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getSphere(t,n,!1);fr(r,s.x,s.y,s.z),r.material.color.set(i),r.material.depthTest=o,r.material.depthWrite=!1}static DrawWireBox(s,t,i=xs,n=0,o=!0){if(!Ss.enabled)return;const r=Ae.getBox(n);r.position.set(s.x,s.y,s.z),r.scale.set(t.x,t.y,t.z),r.material.color.set(i),r.material.depthTest=o,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawWireBox3(s,t=xs,i=0,n=!0){if(!Ss.enabled)return;const o=Ae.getBox(i);o.position.copy(s.getCenter(Nt)),o.scale.copy(s.getSize(Nt)),o.material.color.set(t),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawArrow(s,t,i=xs,n=0,o=!0,r=!1){if(!Ss.enabled)return;const l=Ae.getArrowHead(n);l.position.set(t.x,t.y,t.z),l.quaternion.setFromUnitVectors(this._up.set(0,1,0),Nt.set(t.x,t.y,t.z).sub(qb.set(s.x,s.y,s.z)).normalize());const c=Nt.set(t.x,t.y,t.z).sub(qb.set(s.x,s.y,s.z)).length()*.1;l.scale.set(c,c,c),l.material.color.set(i),l.material.depthTest=o,l.material.wireframe=r,this.DrawLine(s,t,i,n,o)}static DrawWireMesh(s){const t=Ae.getMesh(s.duration??0);"mesh"in s?(t.geometry=s.mesh.geometry,t.matrix.copy(s.mesh.matrixWorld)):(t.geometry=s.geometry,t.matrix.copy(s.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.color.set(s.color??xs),t.material.depthTest=s.depthTest??!0,t.material.wireframe=!0}};let q=Ss;a(q,"enabled",!0),a(q,"_up",new x(0,1,0));const o2=new Ql(1,1,1);function xg(s=null){const t=new ae(s??14540253),i=new bS(o2);return new Zy(i,new Ky({color:t}))}const Sg=Symbol("GizmoCache");class Ae{static ensureFont(){let t=Te.FontLibrary.getFontFamily(this.familyName);if(!t){t=Te.FontLibrary.addFontFamily(this.familyName);const i=t.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");i?.addEventListener("ready",()=>{Te.update()})}}static getTextLabel(t,i,n,o,r){this.ensureFont();let l=this.textLabelCache.pop(),c=1;r&&typeof r=="string"&&r?.length>=8&&r.startsWith("#")?(c=parseInt(r.substring(7),16)/255,r=r.substring(0,7),n2&&console.log(r,c)):typeof r=="object"&&r.a!==void 0&&(c=r.a);const h={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:n,color:o,lineHeight:1,backgroundColor:r??void 0,backgroundOpacity:c,textContent:i,borderRadius:.5*n,padding:.8*n,whiteSpace:"pre",offset:.05*n};if(l)l.set(h);else{l=new _v(h);const d=this,u=l;u.setText=function(p){this.set({textContent:p}),d.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(ee.Current,l,t,this.textLabelCache),l}static getBox(t){let i=this.boxesCache.pop();if(!i){const n=new Ql(1,1,1);i=new Z(n)}return this.registerTimedObject(ee.Current,i,t,this.boxesCache),i}static getLine(t){let i=this.linesCache.pop();if(!i){i=new Yl;let n=i.geometry.getAttribute("position");n||(n=new ft(new Float32Array(2*3),3),i.geometry.setAttribute("position",n))}return i.frustumCulled=!1,this.registerTimedObject(ee.Current,i,t,this.linesCache),i}static getCircle(t){let i=this.circlesCache.pop();if(!i){i=new Yl;let n=i.geometry.getAttribute("position");if(!n){n=new ft(new Float32Array(wg*3),3),i.geometry.setAttribute("position",n);const o=G(0,1,0),r=G(0,0,1),l=G(r);l.cross(o).normalize();const c=G(l),h=Math.PI*2/(wg-1);for(let d=0;d<wg+1;d++){const u=h*d;o.copy(c).multiplyScalar(Math.cos(u)*1),l.copy(r).multiplyScalar(Math.sin(u)*1);const p=o.add(l);n.setXYZ(d,p.x,p.y,p.z)}}}return i.frustumCulled=!1,this.registerTimedObject(ee.Current,i,t,this.circlesCache),i}static getSphere(t,i,n){let o=this.spheresCache.pop();return o||(o=new Z(new pd(1,8,8))),o.scale.set(t,t,t),o.material.wireframe=n,this.registerTimedObject(ee.Current,o,i,this.spheresCache),o}static getArrowHead(t){let i=this.arrowHeadsCache.pop();return i||(i=new Z(new vS(0,.5,1,8))),this.registerTimedObject(ee.Current,i,t,this.arrowHeadsCache),i}static getMesh(t){let i=this.mesh.pop();return i||(i=new Z,i.material=new Re),this.registerTimedObject(ee.Current,i,t,this.mesh),i}static registerTimedObject(t,i,n,o){if(!t){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const r=this.contextBeforeRenderCallbacks.get(t),l=this.contextPostRenderCallbacks.get(t);if(r){if(t.pre_render_callbacks[t.pre_render_callbacks.length-1]!==r){const c=t.pre_render_callbacks.indexOf(r);c>=0&&t.pre_render_callbacks.splice(c,1),t.pre_render_callbacks.push(r)}}else{const c=()=>{this.onBeforeRender(t,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(t,c),t.pre_render_callbacks.push(c)}if(l){if(t.post_render_callbacks[t.post_render_callbacks.length-1]!==l){const c=t.post_render_callbacks.indexOf(l);c>=0&&t.post_render_callbacks.splice(c,1),t.post_render_callbacks.push(l)}}else{const c=()=>{this.onPostRender(t,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(t,c),t.post_render_callbacks.push(c)}i.traverse(c=>{c.layers.disableAll(),c.layers.enable(2)}),i.renderOrder=999999,i[Sg]=o,i.castShadow=!1,i.receiveShadow=!1,i.isGizmo=!0,this.timedObjectsBuffer.push(i),this.timesBuffer.push(ee.Current.time.realtimeSinceStartup+n),t.scene.add(i)}static onBeforeRender(t,i){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,Te.update());for(let n=0;n<i.length;n++){const o=i[n];if(t.mainCamera&&o instanceof Te.MeshUIBaseElement){if(Pr(o))continue;const r=t.isInVR,l=!1,c=!r;nc(o,t.mainCamera,l,c)}}}static onPostRender(t,i,n){const o=t.time.realtimeSinceStartup;for(let r=i.length-1;r>=0;r--){const l=i[r];o>=n[r]-1e-6&&(i.splice(r,1),n.splice(r,1),l.removeFromParent(),Pr(l)!=!0&&l[Sg].push(l))}}}a(Ae,"familyName","needle-gizmos"),a(Ae,"linesCache",[]),a(Ae,"circlesCache",[]),a(Ae,"spheresCache",[]),a(Ae,"boxesCache",[]),a(Ae,"arrowHeadsCache",[]),a(Ae,"mesh",[]),a(Ae,"textLabelCache",[]),a(Ae,"timedObjectsBuffer",new Array),a(Ae,"timesBuffer",new Array),a(Ae,"contextPostRenderCallbacks",new Map),a(Ae,"contextBeforeRenderCallbacks",new Map),a(Ae,"tmuiNeedsUpdate",!1);const ki=O("debugphysics"),Xb=new ro;class Ws{constructor(){a(this,"ray"),a(this,"cam"),a(this,"screenPoint"),a(this,"raycaster"),a(this,"results"),a(this,"targets"),a(this,"recursive",!0),a(this,"minDistance"),a(this,"maxDistance"),a(this,"lineThreshold"),a(this,"layerMask"),a(this,"ignore"),a(this,"testObject"),a(this,"useAcceleratedRaycast")}screenPointFromOffset(t,i){this.screenPoint===void 0&&(this.screenPoint=new re),this.screenPoint.x=t/window.innerWidth*2-1,this.screenPoint.y=-(i/window.innerHeight)*2+1}setLayer(t){Xb.set(t),this.layerMask=Xb}setMask(t){this.layerMask||(this.layerMask=new ro);const i=this.layerMask;i?i.mask=t:this.layerMask=t}}a(Ws,"AllLayers",4294967295);class Cg{constructor(t,i,n){a(this,"distance"),a(this,"point"),a(this,"object"),this.object=t,this.distance=i,this.point=n}}const Og=class{constructor(s){a(this,"context"),a(this,"engine"),a(this,"raycaster",new gd),a(this,"defaultRaycastOptions",new Ws),a(this,"targetBuffer",new Array(1)),a(this,"defaultThresholds",{Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}}),a(this,"sphereResults",new Array),a(this,"sphereMask",new ro),a(this,"sphere",new md),a(this,"tempBoundingBox",new wi),this.context=s}static get raycasting(){return this._raycasting>0}raycastPhysicsFast(s,t=void 0,i=1/0,n=!0){var o;return((o=this.context.physics.engine)==null?void 0:o.raycast(s,t,{maxDistance:i,solid:n}))??null}raycastPhysicsFastAndGetNormal(s,t=void 0,i=1/0,n=!0){var o;return((o=this.context.physics.engine)==null?void 0:o.raycastAndGetNormal(s,t,{maxDistance:i,solid:n}))??null}sphereOverlapPhysics(s,t){var i;return((i=this.context.physics.engine)==null?void 0:i.sphereOverlap(s,t))??null}sphereOverlap(s,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const l of this.context.scene.children)this.intersectSphere(l,s,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((l,c)=>l.distance-c.distance)}raycastFromRay(s,t=null){const i=t??this.defaultRaycastOptions;i.ray=s;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(s=null){ki&&performance.mark("raycast.start"),s||(s=this.defaultRaycastOptions);const t=s.screenPoint??this.context.input.mousePositionRC,i=s.raycaster??this.raycaster;if(i.near=s.minDistance??0,i.far=s.maxDistance??1/0,i.params=this.defaultThresholds,s.lineThreshold===void 0&&(s.lineThreshold=-1),i.params.Line={threshold:s.lineThreshold},s.ray)i.ray.copy(s.ray);else{const l=s.cam??this.context.mainCamera;if(!l)return ki&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const c=this.context.xrCamera;this.context.isInXR&&c instanceof _S&&c.cameras.length>0?i.setFromCamera(t,c.cameras[0]):i.setFromCamera(t,l)}let n=s.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=s.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),s.layerMask!==void 0?s.layerMask instanceof ro?i.layers.mask=s.layerMask.mask:i.layers.mask=s.layerMask:(i.layers.enableAll(),i.layers.disable(2)),ki&&console.time("raycast"),o.length=0,Og._raycasting++,this.intersect(this.raycaster,n,o,s),o.sort((l,c)=>l.distance-c.distance);const r=s.ignore;return r!==void 0&&r.length>0&&(o=o.filter(l=>!r.includes(l.object))),Og._raycasting--,ki&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o!=null&&o.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(s,t,i,n){var o,r,l;for(const c of t){if(!c||c.visible===!1||q.isGizmo(c)||n.lineThreshold!==void 0&&n.lineThreshold<0&&c instanceof Yl)continue;let h=!0;const d=c,u=d.geometry;if(n.testObject){const p=(o=n.testObject)==null?void 0:o.call(n,c);if(p===!1)continue;p==="continue in children"&&(h=!1)}if(h&&(u&&Qb(u)||(h=!1)),h){const p=cv(c);p&&(d.geometry=p);const g=i.length;let y=!0;if(n.precise===!1&&(y=!1),y||(y=((l=(r=u.getAttribute("position"))==null?void 0:r.array)==null?void 0:l.length)<64),d instanceof Sa&&(y=!1),!y&&a2(d,s,i)||(n.useAcceleratedRaycast!==!1?Vd.runMeshBVHRaycast(s,d,i,this.context):s.intersectObject(d,!1,i)),ki&&i.length!=g){const f=i[i.length-1],v=p?8969557:7798784;q.DrawWireSphere(f.point,.1,v,1,!1),q.DrawWireMesh({mesh:c,depthTest:!1,duration:.2,color:v})}d.geometry=u}n.recursive!==!1&&this.intersect(s,c.children,i,n)}return i}intersectSphere(s,t,i,n,o,r,l,c){let h=s&&s.isMesh&&s.layers.test(n)&&!q.isGizmo(s);h&&(h=s.visible),h&&(h=!(s instanceof Yl)),h&&(h=!(s instanceof Sa));const d=s,u=d.geometry;if(h&&c){const p=c(s);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&Qb(u)||(h=!1),h){if(l){const p=this.sphere;p.center.copy(t),p.radius=i;const g=o.length;if(Vd.runMeshBVHRaycast(this.sphere,d,o,this.context),g!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),g=this.sphere;if(g.center.copy(t),g.radius=i,g.intersectsBox(p)){const y=te(s),f=y.distanceTo(g.center),v=new Cg(s,f,y);if(o.push(v),!r)return}}}if(s.children)for(const p of s.children){const g=o.length;if(this.intersectSphere(p,t,i,n,o,r,l,c),g!=o.length&&!r)return}}};let Nd=Og;a(Nd,"_raycasting",0);function Qb(s){return!(s.index&&s.index.array.length<3)}const wr=new md,Wd=new ur,r2=new Xy;function a2(s,t,i){const n=s._computeIntersections;if(!n)return!1;let o=s["_computeIntersections:Needle"];return o||(o=s["_computeIntersections:Needle"]=function(r,l,c){const h=this,d=h.geometry.boundingSphere;if(d){if(h instanceof Sa){Wd.setFromNormalAndCoplanarPoint(G(0,1,0),G(0,-h.position.y,0)),Wd.applyMatrix4(h.matrixWorld,r2);const p=r.ray.intersectPlane(Wd,G());if(p){wr.copy(d),wr.applyMatrix4(h.matrixWorld);const g=G(p).sub(r.ray.origin).length(),y=wr.radius*.5;g<y&&l.push({distance:g,point:p,object:h,normal:Wd.normal.clone()})}return}wr.copy(d),wr.applyMatrix4(h.matrixWorld);const u=r.ray.intersectSphere(wr,G());if(u){const p=G(u).sub(r.ray.origin),g=p.length();if(g>wr.radius){const y=p.clone().normalize();l.push({distance:g,point:u,object:h,normal:y})}}}}),s._computeIntersections=o,t.intersectObject(s,!1,i),s._computeIntersections=n,!0}var Vd;(s=>{function t(w,_,C,R){var M,T,j;if(!_.geometry||!_.geometry.hasAttribute("position"))return!1;const L=_.geometry;if(_!=null&&_.isSkinnedMesh){const U=_,B=U.bvhNeedsUpdate;if(!U.staticGenerator)c(),r&&(U.staticGenerator=new r(_),U.staticGenerator.applyWorldTransforms=!1,U.staticGeometry=U.staticGenerator.generate(),L.boundsTree=l?.call(U.staticGeometry),U.staticGeometryLastUpdate=performance.now()+Math.random()*200,U.autoUpdateMeshBVH===void 0&&(U.autoUpdateMeshBVH=!1));else if(L.boundsTree&&(U.autoUpdateMeshBVH===!0||B===!0)){const Y=performance.now(),$=Y-U.staticGeometryLastUpdate;(B||$>100)&&(U.bvhNeedsUpdate=!1,U.staticGeometryLastUpdate=Y,(M=U.staticGenerator)==null||M.generate(U.staticGeometry),L.boundsTree.refit())}}else if(!L.boundsTree){d||b();let U=!0;if((R.xr||L[y]===!1||(T=L.getAttribute("position"))!=null&&T.isInterleavedBufferAttribute||L.index&&(j=L.index)!=null&&j.isInterleavedBufferAttribute)&&(U=!1),U&&p){if(L[g]===void 0){let B=null;if(v.length>0){const Y=v.shift();Y&&!Y.running&&(B=Y)}if(!B&&f.length<3&&(B=new p,f.push(B)),B!=null&&!B.running){const Y=_.name;ki&&console.log("<<<< worker start",Y,B),L[g]="queued",performance.mark("bvh.create.start");const $=L.clone();try{B.generate($).then(E=>{L[g]="done",L.boundsTree=E}).catch(E=>{L[g]="failed - "+E?.message,L[y]=!1,ki&&console.error("Failed to generate mesh bvh on worker",E)}).finally(()=>{ki&&console.log(">>>>> worker done",Y,{hasBoundsTre:L.boundsTree!=null}),v.push(B),$.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch(E){console.error("Failed to generate mesh bvh on worker",E)}}else ki&&console.warn("No worker available")}}else(!u||!U)&&(c(),o&&(performance.mark("bvh.create.start"),L.boundsTree=new o(L),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(w instanceof gd){const U=w,B=_.raycast;L.boundsTree?(c(),n&&(_.acceleratedRaycast||(_.acceleratedRaycast=n.bind(_),ki&&console.debug(`Physics: bind acceleratedRaycast fn to "${_.name}"`)),_.raycast=_.acceleratedRaycast)):ki&&console.warn("No bounds tree found for mesh",_.name,{workerTask:L[g],hasAcceleratedRaycast:n!=null});const Y=U.firstHitOnly;return U.firstHitOnly=!1,U.intersectObject(_,!1,C),U.firstHitOnly=Y,_.raycast=B,!0}else if(w instanceof md){const U=L.boundsTree;if(U){const B=w;if(h.copy(_.matrixWorld).invert(),B.applyMatrix4(h),U.intersectsSphere(B)){const Y=te(_),$=Y.distanceTo(B.center),E=new Cg(_,$,Y);C.push(E)}}return!0}return!1}s.runMeshBVHRaycast=t;let i=!1,n=null,o=null,r=null,l=null;function c(){i||(i=!0,import("./vendor.light.min.js").then(w=>w.k).then(w=>{n=w.acceleratedRaycast,o=w.MeshBVH,r=w.StaticGeometryGenerator,l=w.computeBoundsTree}).catch(w=>{(ki||F())&&console.error("Failed to load BVH library...",w.message)}))}const h=new ne;let d=!1,u=!1,p=null;const g=Symbol("Needle:MeshBVH-Worker"),y=Symbol("Needle:MeshBVH-CanUseWorker"),f=[],v=[];function b(){d=!0,u=!0,Promise.resolve().then(()=>Xj).then(w=>{p=w.GenerateMeshBVHWorker}).catch(w=>{(ki||F())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{u=!1})}})(Vd||(Vd={}));const Yb=Symbol("gltf-loader-internal-usage-tracker"),l2=O("debugusers"),Hd=class{constructor(s){a(this,"parser"),a(this,"_getDependency"),a(this,"_loadingId"),a(this,"_loadedObjects",new Set),this.parser=s,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(s){return Hd._loadingProcesses>0}beforeRoot(){Hd._loadingProcesses++;const s=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(s._loadedObjects.add(r),r[Yb]=s._loadingId),r)),o},null}afterRoot(s){Hd._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[Yb],t instanceof I&&(t.parent||t instanceof Z&&setTimeout(()=>{l2&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}};let Pg=Hd;a(Pg,"_loadingProcesses",0);class Zb{constructor(){window.addEventListener("unhandledrejection",t=>{var i;if(t.defaultPrevented)return;const n=(i=t?.reason)==null?void 0:i.path;if(n){const o=n[0];o&&o.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
155
155
|
`+o.src),t.preventDefault())}})}}const $d=O("trackresources");function Kb(){return $d==="dispose"}let xr=!0;$d===0&&(xr=!1);function c2(s){xr=s}function Jb(){return xr}const e_=Symbol("disposable");function kg(s,t){s&&(s[e_]=t,Sr&&console.warn("Set disposable",t,s))}const t_=Symbol("disposed");function h2(s){return s[t_]===!0}function Ee(s){var t;if(s){if(s[e_]===!1){Sr&&console.warn("Object is marked as not disposable",s);return}if(s[t_]=!0,s instanceof qi)Ee(s.environment),Ee(s.background),Ee(s.customDepthMaterial),Ee(s.customDistanceMaterial);else if(s instanceof wn)Ee(s.geometry),Ee(s.material),Ee(s.skeleton),Ee(s.bindMatrix),Ee(s.bindMatrixInverse),Ee(s.customDepthMaterial),Ee(s.customDistanceMaterial),s.geometry=null,s.material=null,s.visible=!1;else if(s instanceof Z)Ee(s.geometry),Ee(s.material),Ee(s.customDepthMaterial),Ee(s.customDistanceMaterial),s.geometry=null,s.material=null,s.visible=!1;else if(s instanceof _n){Ia(s);for(const i of Object.keys(s.attributes)){const n=s.attributes[i];Ee(n)}}else if(s instanceof ft||s instanceof Jy)Sr&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const i of s)i instanceof ke&&Ee(i);else if(s instanceof ke){Ia(s);for(const n of Object.keys(s)){const o=s[n];o instanceof Le&&(Ee(o),s[n]=null)}const i=s.uniforms;if(i)for(const n of Object.keys(i)){const o=i[n];o instanceof Le?(Ee(o),i[n]=null):o instanceof oo&&(Ee(o.value),o.value=null)}}else s instanceof Le?(Ia(s),Ia(s.source),((t=s.source)==null?void 0:t.data)instanceof ImageBitmap&&Ia(s.source.data)):s instanceof wS?(Ia(s.boneTexture),s.boneTexture=null):s instanceof xS||!(s instanceof I)&&Sr&&console.warn("Unknown object type",s)}}function Ia(s){s&&((Sr||Kb()||$d)&&console.warn("\u{1F9E8} FREE",s),s instanceof ImageBitmap?s.close():s instanceof SS?s.data=null:s.dispose())}function i_(s){(s instanceof Z||s instanceof wn)&&(s.material=null,s.geometry=null)}const d2=new Set;function Mg(s,t,i=null,n){if(n||(n=d2,n.clear()),!s)return n;const o=s[vc];if(o)for(const r of o)n.has(r)||i?.call(null,r)!==!1&&(n.add(r),t&&Mg(r,!0,i,n));return n}function u2(s){return s[bc]}const Sr=O("debugresourceusers")||O("debugmemory"),vc=Symbol("needle-resource-users"),bc=Symbol("needle-resource-users-count");function Xt(s,t){Id(s,t,function(i,n){xr&&!Nd.raycasting&&(qd(vc,this,i,!1),qd(vc,this,n,!0))})}xr&&(Xt(Z.prototype,"material"),Xt(Z.prototype,"geometry"),Xt(ke.prototype,"map"),Xt(ke.prototype,"bumpMap"),Xt(ke.prototype,"alphaMap"),Xt(ke.prototype,"normalMap"),Xt(ke.prototype,"displacementMap"),Xt(ke.prototype,"roughnessMap"),Xt(ke.prototype,"metalnessMap"),Xt(ke.prototype,"emissiveMap"),Xt(ke.prototype,"specularMap"),Xt(ke.prototype,"envMap"),Xt(ke.prototype,"lightMap"),Xt(ke.prototype,"aoMap"),Xt(ke.prototype,"gradientMap"));function p2(s){if(xr===!1)return;const t=s[vc];if(t)for(const i of t)qd(vc,i,s,!1)}xr&&Id(ke.prototype,"dispose",function(){p2(this)});let Rg=0;function qd(s,t,i,n){if(Rg>0)return;if(Array.isArray(i)){for(const r of i)qd(s,t,r,n);return}if(!i)return;let o=i[s];if(o||(o=new Set),n){if(t&&!o.has(t)){o.add(t);let r=i[bc]||0;r+=1,i[bc]=r,Sr&&console.warn(`\u{1F7E2} Added user of "${i.type}"`,t,i,r,"users:",o)}}else if(t&&o.has(t)){o.delete(t);let r=i[bc]||0;r>0&&(r-=1,i[bc]=r),Sr&&console.warn(`\u{1F534} Removed user of "${i.type}"`,t,i,r,"users:",o),r<=0&&(Pg.isLoading(i)||($d&&console.warn(`\u{1F534} Removed all user of "${i.type}"`,i),Kb()&&Ee(i)))}i[s]=o}try{Id(dr.prototype,"render",function(){Rg++},function(){Rg--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}const s_=O("debugcomponentevents");class _c{static addComponentLifecylceEventListener(t,i){this.eventListeners.has(t)&&this.eventListeners.set(t,[]);let n=this.eventListeners.get(t);n||(n=[]),n.push(i),this.eventListeners.set(t,n),s_&&console.log("Added event listener for "+t,this.eventListeners)}static removeComponentLifecylceEventListener(t,i){const n=this.eventListeners.get(t);if(!n)return;const o=n.indexOf(i);o<0||n.splice(o,1)}static dispatchComponentLifecycleEvent(t,i){const n=this.eventListeners.get(t);if(s_&&console.log("Dispatching event "+t,n),!!n)for(const o of n)o(i)}}a(_c,"eventListeners",new Map);const wc=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),n_=Symbol("isUsingInstancing"),o_=Symbol("instancingRenderer"),xc=Symbol("instancingAutoUpdateBounds");class cs{static isUsingInstancing(t){return t[n_]===!0}static getRenderer(t){return t[o_]||null}setAutoUpdateBounds(t,i){const n=cs.getRenderer(t);n&&(n[xc]=i)}static markDirty(t,i=!0){if(t&&(this.isUsingInstancing(t)&&(t[wc]=!0,t.matrixWorldNeedsUpdate=!0),i))for(const n of t.children)cs.markDirty(n,!0)}}function ja(s,t){try{t?s(t):s()}catch(i){return console.error(i),!1}return!0}const Tg=O("debugnewscripts"),m2=O("debughierarchy"),Fe=[];function g2(){return Fe.length>0}function Gd(s){if(Tg&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const t of s.new_scripts_pre_setup_callbacks)t&&t();s.new_scripts_pre_setup_callbacks.length=0}if(!(s.new_scripts.length<=0)){Fe.length=0,s.new_scripts.length>0&&Fe.push(...s.new_scripts),s.new_scripts.length=0;for(let t=0;t<Fe.length;t++)try{const i=Fe[t];if(i.isComponent!==!0){(F()||Tg)&&console.error(`Registered script is not a Needle Engine component.
|
|
156
156
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
157
157
|
`,i),Fe.splice(t,1),t--;continue}if(i.destroyed)continue;if(!i.gameObject){console.warn(`Component can not be initialized: no GameObject assigned.
|
|
@@ -255,8 +255,8 @@ vec3 _agx(vec3 val) {
|
|
|
255
255
|
0.0784335999999992, 0.878468636469772, 0.0784336,
|
|
256
256
|
0.0792237451477643, 0.0791661274605434, 0.879142973793104);
|
|
257
257
|
|
|
258
|
-
const float min_ev = -12.
|
|
259
|
-
const float max_ev = 4.
|
|
258
|
+
const float min_ev = -12.47393;
|
|
259
|
+
const float max_ev = 4.026069;
|
|
260
260
|
|
|
261
261
|
// val = pow(val, vec3(2.2));
|
|
262
262
|
|
|
@@ -765,7 +765,7 @@ Possible solutions:
|
|
|
765
765
|
`,i),this._renderlooperrors>=3&&(console.warn("Stopping render loop due to error"),this.renderer.setAnimationLoop(null)),this.domElement.dispatchEvent(new CustomEvent("error",{detail:i}))}else this.internalStep(s,t)}updatePhysics(s){this.internalUpdatePhysics(s)}internalStep(s,t){this.internalOnBeforeRender(s,t)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(s,t){var i;this.renderer.info.autoReset=!0;const n=t!==null&&this._xrFrame===null;if(this._xrFrame=t,n&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:t}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=s),this._accumulatedTime+=(s-this._lastTimestamp)/1e3,this._lastTimestamp=s;let o=this.targetFrameRate;if(typeof o=="object"&&(o=o.value),this._accumulatedTime<1/(o+1))return!1;this._accumulatedTime=0}if((i=this._stats)==null||i.begin(),Ie.Current=this,this.onHandlePaused())return!1;for(Ie.Current=this,this.time.update(),mk&&console.log("FPS",this.time.smoothedFps.toFixed(0)),Gd(this),Xd(this.scene),r_(this),Ns(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const o=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(o)}if(this.pre_update_oneshot_callbacks){for(const o in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[o]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const o in this.pre_update_callbacks)this.pre_update_callbacks[o]();this._currentFrameEvent=0;for(let o=0;o<this.scripts_earlyUpdate.length;o++){const r=this.scripts_earlyUpdate[o];r.activeAndEnabled&&r.earlyUpdate!==void 0&&(Ie.Current=this,r.earlyUpdate())}if(this.executeCoroutines(0),Ns(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let o=0;o<this.scripts_update.length;o++){const r=this.scripts_update[o];r.activeAndEnabled&&r.update!==void 0&&(Ie.Current=this,r.update())}if(this.executeCoroutines(1),Ns(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let o=0;o<this.scripts_lateUpdate.length;o++){const r=this.scripts_lateUpdate[o];r.activeAndEnabled&&r.lateUpdate!==void 0&&(Ie.Current=this,r.lateUpdate())}if(this.executeCoroutines(2),Ns(this,2),this.onHandlePaused()||(this.physicsSteps===void 0&&(this.physicsSteps=1),this.physics.engine&&this.physicsSteps>0&&this.internalUpdatePhysics(this.physicsSteps),this.onHandlePaused()))return!1;if(this.isVisibleToUser||this.runInBackground){this._currentFrameEvent=3;for(let o=0;o<this.scripts_onBeforeRender.length;o++){const r=this.scripts_onBeforeRender[o];r.activeAndEnabled&&r.onBeforeRender!==void 0&&(Ie.Current=this,r.onBeforeRender(t))}if(this.executeCoroutines(3),Ns(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const o in this.pre_render_callbacks)this.pre_render_callbacks[o](t)}return!0}internalUpdatePhysics(s){if(!this.physics.engine)return!1;const t=s,i=this.time.deltaTime/t;for(let n=0;n<t;n++)this._currentFrameEvent=9,this.executeCoroutines(9),this.physics.engine.step(i),this._currentFrameEvent=10,this.executeCoroutines(10);return this.physics.engine.postStep(),!0}internalOnRender(){this.isManagedExternally||(b2(this),this._currentFrameEvent=-1,BC.update(),this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let s=0;s<this.scripts_onAfterRender.length;s++){const t=this.scripts_onAfterRender[s];t.activeAndEnabled&&t.onAfterRender!==void 0&&(Ie.Current=this,t.onAfterRender())}if(this.executeCoroutines(4),Ns(this,4),this.post_render_callbacks)for(const s in this.post_render_callbacks)this.post_render_callbacks[s]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log(this.renderer.info.render.calls+" DrawCalls",`
|
|
766
766
|
Render:`,{...this.renderer.info.render},`
|
|
767
767
|
Memory:`,{...this.renderer.info.memory},`
|
|
768
|
-
Target Framerate: `+this.targetFrameRate)),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),ge.dispatchCallback(ye.ContextFirstFrameRendered,this))}renderNow(s){var t;return!s&&(s=this.mainCamera,!s)?!1:(this.handleRendererContextLost(),this._isRendering=!0,this.renderRequiredTextures(),this.renderer.toneMapping!==wa&&ow(),this.composer&&!this.isInXR?(s&&((t=this.composer.passes[0])==null?void 0:t.mainCamera)!=s&&this.composer.setMainCamera(s),this.composer.render(this.time.deltaTime)):s&&(this.isInXR&&X.isMacOS()&&this.renderer.clearDepth(),this.renderer.render(this.scene,s)),this._isRendering=!1,!0)}handleRendererContextLost(){this.time.frame%10&&this.renderer.getContext().isContextLost()&&this._contextRestoreTries++<100&&(console.warn("Attempting to recover WebGL context..."),this.renderer.forceContextRestore())}onHandlePaused(){const s=this.evaluatePaused();if(this._wasPaused!==s){pk&&console.log("Paused?",s,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ie.Current=this,i.onPausedChanged(s,this._wasPaused))}}return this._wasPaused=s,s}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Sn(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new TS(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Le,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=yd,this._renderTarget.texture.magFilter=yd,this._renderTarget.texture.format=fd)}const s=this._renderTarget;s.texture&&(s.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(s),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(s){var t;if(this.coroutines[s]){const n=this.coroutines[s];for(let o=0;o<n.length;o++)try{const r=n[o];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){gk&&console.log("Removing coroutine",r.comp,r.comp.enabled),n.splice(o,1),--o;continue}const l=r.chained;if(l&&l.length>0){const d=l[l.length-1].next();if(d.done&&l.pop(),i(d)&&(r.chained||(r.chained=[]),r.chained.push(d.value)),!d.done)continue}const c=r.main.next();if(c.done===!0){n.splice(o,1),--o;continue}const h=c.value;if(i(h)){if(h.next().done)continue;r.chained||(r.chained=[]),r.chained.push(h)}else if(h instanceof Promise){const d=h;r.chained||(r.chained=[]);const u=G_(d);(t=r.chained)==null||t.push(u);continue}}catch(r){console.error(r)}}function i(n){return!!(n&&n.next&&n.return)}}};let ee=Ie;a(ee,"_defaultTargetFramerate",{value:90,toString(){return this.value}}),a(ee,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:X.isiOS()||X.isMacOS()?"default":"high-performance",stencil:!0});const Ji=O("debuglicense"),pw=[];let Er="basic";Ji&&console.log("License Type: "+Er);function wo(){switch(Er){case"pro":case"enterprise":return!0}return!1}function cf(){switch(Er){case"indie":return!0}return!1}function Os(){return wo()||cf()}function vk(s){if(wo()||cf())return s(!0);pw.push(s)}function bk(s){for(const t of pw)try{t(s)}catch{}}ge.registerCallback(ye.ContextRegistered,s=>{xk(s.context),Ck(),wk(s.context)});let Ar,hf=!1,Cu="";async function _k(){if(Ar)return Ar;if(Er==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+_s+"&generator="+encodeURIComponent(Ad),t=await fetch(s,{method:"GET"}).catch(i=>{Ji&&console.error("License check failed",i)});t?.status===200?(hf=!1,Ji&&console.log("License check succeeded"),Er="pro",bk(!0)):t?.status===403?(hf=!0,Cu=await t.text()):Ji&&console.log("License check failed with status "+t?.status)}catch(s){Ji&&console.error("License check failed",s)}else Ji&&console.log('Runtime license check is skipped because license is already applied as "'+Er+'"')}Ar=_k();async function wk(s){function t(){const o=document.createElement("div");o.className="needle-forbidden",o.style.cssText=`
|
|
768
|
+
Target Framerate: `+this.targetFrameRate)),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),ge.dispatchCallback(ye.ContextFirstFrameRendered,this))}renderNow(s){var t;return!s&&(s=this.mainCamera,!s)?!1:(this.handleRendererContextLost(),this._isRendering=!0,this.renderRequiredTextures(),this.renderer.toneMapping!==wa&&ow(),this.composer&&!this.isInXR?(s&&"setMainCamera"in this.composer&&((t=this.composer.passes[0])==null?void 0:t.mainCamera)!=s&&this.composer.setMainCamera(s),this.composer.render(this.time.deltaTime)):s&&(this.isInXR&&X.isMacOS()&&this.renderer.clearDepth(),this.renderer.render(this.scene,s)),this._isRendering=!1,!0)}handleRendererContextLost(){this.time.frame%10&&this.renderer.getContext().isContextLost()&&this._contextRestoreTries++<100&&(console.warn("Attempting to recover WebGL context..."),this.renderer.forceContextRestore())}onHandlePaused(){const s=this.evaluatePaused();if(this._wasPaused!==s){pk&&console.log("Paused?",s,"context:"+this.alias);for(let t=0;t<this.scripts_pausedChanged.length;t++){const i=this.scripts_pausedChanged[t];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(Ie.Current=this,i.onPausedChanged(s,this._wasPaused))}}return this._wasPaused=s,s}evaluatePaused(){return this.isInXR?!1:this.isPaused?!0:this.runInBackground?!1:!this.isVisibleToUser}renderRequiredTextures(){if(!this.mainCamera||!this._requireDepthTexture&&!this._requireColorTexture)return;if(!this._renderTarget){if(this._renderTarget=new Sn(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new TS(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Le,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=yd,this._renderTarget.texture.magFilter=yd,this._renderTarget.texture.format=fd)}const s=this._renderTarget;s.texture&&(s.texture.colorSpace=this.renderer.outputColorSpace);const t=this.renderer.getRenderTarget();this.renderer.setRenderTarget(s),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(t)}executeCoroutines(s){var t;if(this.coroutines[s]){const n=this.coroutines[s];for(let o=0;o<n.length;o++)try{const r=n[o];if(!r.comp||r.comp.destroyed||!r.main||r.comp.enabled===!1){gk&&console.log("Removing coroutine",r.comp,r.comp.enabled),n.splice(o,1),--o;continue}const l=r.chained;if(l&&l.length>0){const d=l[l.length-1].next();if(d.done&&l.pop(),i(d)&&(r.chained||(r.chained=[]),r.chained.push(d.value)),!d.done)continue}const c=r.main.next();if(c.done===!0){n.splice(o,1),--o;continue}const h=c.value;if(i(h)){if(h.next().done)continue;r.chained||(r.chained=[]),r.chained.push(h)}else if(h instanceof Promise){const d=h;r.chained||(r.chained=[]);const u=G_(d);(t=r.chained)==null||t.push(u);continue}}catch(r){console.error(r)}}function i(n){return!!(n&&n.next&&n.return)}}};let ee=Ie;a(ee,"_defaultTargetFramerate",{value:90,toString(){return this.value}}),a(ee,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:X.isiOS()||X.isMacOS()?"default":"high-performance",stencil:!0});const Ji=O("debuglicense"),pw=[];let Er="basic";Ji&&console.log("License Type: "+Er);function wo(){switch(Er){case"pro":case"enterprise":return!0}return!1}function cf(){switch(Er){case"indie":return!0}return!1}function Os(){return wo()||cf()}function vk(s){if(wo()||cf())return s(!0);pw.push(s)}function bk(s){for(const t of pw)try{t(s)}catch{}}ge.registerCallback(ye.ContextRegistered,s=>{xk(s.context),Ck(),wk(s.context)});let Ar,hf=!1,Cu="";async function _k(){if(Ar)return Ar;if(Er==="basic")try{const s="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+_s+"&generator="+encodeURIComponent(Ad),t=await fetch(s,{method:"GET"}).catch(i=>{Ji&&console.error("License check failed",i)});t?.status===200?(hf=!1,Ji&&console.log("License check succeeded"),Er="pro",bk(!0)):t?.status===403?(hf=!0,Cu=await t.text()):Ji&&console.log("License check failed with status "+t?.status)}catch(s){Ji&&console.error("License check failed",s)}else Ji&&console.log('Runtime license check is skipped because license is already applied as "'+Er+'"')}Ar=_k();async function wk(s){function t(){const o=document.createElement("div");o.className="needle-forbidden",o.style.cssText=`
|
|
769
769
|
position: fixed;
|
|
770
770
|
top: 0;
|
|
771
771
|
left: 0;
|