@needle-tools/engine 4.0.2-alpha → 4.0.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/needle-engine.js +313 -297
- package/dist/needle-engine.light.js +23 -7
- package/dist/needle-engine.light.min.js +23 -23
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine-components/OrbitControls.js +8 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/OrbitControls.ts +6 -2
|
@@ -4345,7 +4345,7 @@ Open this page to get the console: `+e.toString())}const n=At.isMobileDevice()||
|
|
|
4345
4345
|
#__vconsole .vc-mask {
|
|
4346
4346
|
overflow: hidden;
|
|
4347
4347
|
}
|
|
4348
|
-
`,Da?.prepend(s),n===!0&&xI()<=0&&V5(),console.log("\u{1F335} Debug console has loaded")}},e.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),$v=!1,Io=null},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function Xoe(){if(!globalThis.VConsole)return;const n=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+n._id+" iframe");return n.on("renderTab",function(i){const s=globalThis["needle:codegen_files"];if(!s||s.length===0)return;let r=globalThis["needle:codegen_files"][0];const o=r.indexOf("?");o>-1&&(r=r.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+r,l=encodeURIComponent(a);n.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(c)}),n.on("show",function(){const i=e();i&&i.src!==n.fullUrl&&(i.src=n.fullUrl)}),n.on("hide",function(){const i=e();i&&(i.src="")}),n.on("addTopBar",function(i){var s=new Array;s.push({name:"Open in new window \u2197",onClick:function(r){window.open(n.fullUrl,"_blank"),Io?.hide()}}),s.push({name:"Reload",onClick:function(r){const o=e();o&&(o.src=n.fullUrl)}}),s.push({name:"Fullscreen",onClick:function(r){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),i(s)}),n}function Woe(){return document.querySelector("#__vconsole .vc-switch")||null}function Hoe(){return document.querySelector("#__vconsole")||null}const j5=te("debugdefines");Yd('if(!globalThis[""4.0.2-alpha""]) globalThis[""4.0.2-alpha""] = "0.0.0";'),Yd('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Yd('if(!globalThis[""Thu Dec 12 2024 16:
|
|
4348
|
+
`,Da?.prepend(s),n===!0&&xI()<=0&&V5(),console.log("\u{1F335} Debug console has loaded")}},e.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),$v=!1,Io=null},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function Xoe(){if(!globalThis.VConsole)return;const n=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+n._id+" iframe");return n.on("renderTab",function(i){const s=globalThis["needle:codegen_files"];if(!s||s.length===0)return;let r=globalThis["needle:codegen_files"][0];const o=r.indexOf("?");o>-1&&(r=r.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+r,l=encodeURIComponent(a);n.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(c)}),n.on("show",function(){const i=e();i&&i.src!==n.fullUrl&&(i.src=n.fullUrl)}),n.on("hide",function(){const i=e();i&&(i.src="")}),n.on("addTopBar",function(i){var s=new Array;s.push({name:"Open in new window \u2197",onClick:function(r){window.open(n.fullUrl,"_blank"),Io?.hide()}}),s.push({name:"Reload",onClick:function(r){const o=e();o&&(o.src=n.fullUrl)}}),s.push({name:"Fullscreen",onClick:function(r){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),i(s)}),n}function Woe(){return document.querySelector("#__vconsole .vc-switch")||null}function Hoe(){return document.querySelector("#__vconsole")||null}const j5=te("debugdefines");Yd('if(!globalThis[""4.0.2-alpha.1""]) globalThis[""4.0.2-alpha.1""] = "0.0.0";'),Yd('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),Yd('if(!globalThis[""Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)""]) globalThis[""Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)""] = "unknown";'),Yd('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";'),Yd('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.0.2-alpha.1";'),Yd('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),Yd('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)";'),Yd('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const _l="4.0.2-alpha.1",O_="undefined",AL="Thu Dec 12 2024 16:54:57 GMT+0100 (Central European Standard Time)";j5&&console.log(`Engine version: ${_l} (generator: ${O_})
|
|
4349
4349
|
Project built at ${AL}`);const tb="npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9",Ch="needle_isActiveInHierarchy",om="builtin_components",ib="needle_editor_guid";function Yd(n){try{(0,eval)(n)}catch(e){j5&&console.error(e)}}const joe='<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>',Qoe=btoa(joe),Zoe="data:image/svg+xml;base64,"+Qoe,Yoe=Zoe,Koe=`<?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(Koe);const Joe='<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>',qoe=btoa(Joe),$oe="data:image/svg+xml;charset=utf-8;base64,"+qoe,eae=$oe;/**
|
|
4350
4350
|
* postprocessing v6.36.2 build Tue Sep 10 2024
|
|
4351
4351
|
* https://github.com/pmndrs/postprocessing
|
|
@@ -4960,13 +4960,13 @@ a=extmap-allow-mixed`)!==-1){const r=s.sdp.split(`
|
|
|
4960
4960
|
`+sa);const l=await Promise.resolve().then(()=>ZSe),c=((s=l.default)==null?void 0:s.WebsocketBuilder)??l.WebsocketBuilder,h=((r=l.default)==null?void 0:r.ExponentialBackoff)??l.ExponentialBackoff,d=new c(sa).withMaxRetries(10).withBackoff(new h(2e3,4)).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=d,this.connected=!0,je()||Bo?console.log(`\u229E Connected to networking backend
|
|
4961
4961
|
`+sa):console.debug("\u229E Connected to networking backend",sa),a(!0),this.onSendQueued(Bl.OnConnection)}).onClose(u=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,a(!1);let m="Websocket connection closed...";sa!=null&&sa.includes("/socket")||(m+=' Do you perhaps mean to connect to "/socket"?'),console.error(m)}).onError(u=>{console.error("\u22A0 Websocket connection failed..."),a(!1)}).onRetry(()=>{console.log("\u2192 Retry connecting to networking websocket")}).build();d.addEventListener(l.WebsocketEvent.message,(u,m)=>{this.onMessage(u,m)})})}onMessage(e,i){const s=i.data;try{if(typeof s!="string"){s.size&&this.handleIncomingBinaryMessage(s);return}const r=JSON.parse(s);if(Array.isArray(r))for(const o of r)this.handleIncomingStringMessage(o);else this.handleIncomingStringMessage(r);return}catch(r){Bo&&s==="pong"?console.log("<<",s):je()&&console.error("Failed to parse message",r)}}async handleIncomingBinaryMessage(e){fk&&console.log("<< bin",this.context.time.frame);const i=await e.arrayBuffer();var s=new Uint8Array(i);const r=new b1(s),o=r.getBufferIdentifier(),a=this._listenersBinary[o],l=TW(r),c=RW(l);if(c&&typeof c=="string"&&(this._state[c]=l),!a)return;const h=l??r;for(const d of a)d(h)}handleIncomingStringMessage(e){var i,s;if(Bo&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const l=e.data;l&&(console.assert(l.id!==void 0&&l.id!==null&&l.id.length>0,"server did not send connection id",l.id),console.debug("Your id is: "+l.id,this.context.alias??""),this._connectionId=l.id)}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(Bo&&console.log(e),e){this._isInRoom=!0;const l=e;this._currentRoomName=l.room,this._currentRoomViewId=l.viewId,this._currentRoomAllowEditing=l.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...l.inRoom),(fk||je())&&console.debug("Joined Needle Engine Room: "+l.room);const c=new URL(window.location.href);c.searchParams.has("room")&&c.searchParams.delete("room"),c.searchParams.set("view",this._currentRoomViewId),console.debug(`Room view id: ${this._currentRoomViewId}
|
|
4962
4962
|
${c.href}`)}this.onSendQueued(Bl.OnRoomJoin);break;case"left-room":e.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentInRoom.length=0);break;case"user-joined-room":if(e.data){const l=e.data;this._currentInRoom.push(l.userId),Bo&&console.log(l.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const l=e.data,c=this._currentInRoom.indexOf(l.userId);c>=0&&(Bo&&console.log(l.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(c,1)),l.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":Bo&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const a=(i=e.data)==null?void 0:i.time;a&&(this._currentDelay=this.context.time.time-a),Bo&&console.log("Current latency: "+this._currentDelay.toFixed(4)+" sec","Clients in room: "+((s=this._currentInRoom)==null?void 0:s.length));break}const r=e.data;r&&(this._state[r.guid]=r);let o=this._listeners[e.key];if(o){o=[...o];for(const a of o)try{a(e.data)}catch(l){console.error('Error invoking callback for "'+e.key+'"',l)}}}toMessage(e,i){return{key:e,data:i}}sendWithWebsocket(e,i,s=Bl.OnRoomJoin){if(!this._ws){const o=this._waitingForSocket[s]||[];o.push(()=>this.sendWithWebsocket(e,i,s)),this._waitingForSocket[s]=o;return}const r=JSON.stringify(this.toMessage(e,i));Bo&&console.log(">>",e),this._ws.send(r)}onSendQueued(e){const i=this._waitingForSocket[e];if(i){for(const s of i)s();i.length=0}}}const Xb=te("debugwebxr");class yk{constructor(e,i){p(this,"controllerStates",[]),p(this,"userId"),p(this,"context"),p(this,"userStateEvtName"),p(this,"onReceivedControllerState",s=>{Xb&&console.log(`XRSync: Received change for ${this.userId}: ${s.type} ${s.handedness}; tracked=${s.isTracking}`);let r=!1;for(let o=0;o<this.controllerStates.length;o++)if(this.controllerStates[o].index===s.index){this.controllerStates[o]=s,r=!0;break}r||this.controllerStates.push(s)}),this.userId=e,this.context=i,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}update(e){if(this.context.connection.isConnected!=!1){for(let i=this.controllerStates.length-1;i>=0;i--){const s=this.controllerStates[i];let r=!1;for(let o=0;o<e.controllers.length;o++)e.controllers[o].index===s.index&&(r=!0);r||(Xb&&console.log(`XRSync: ${s.type} ${s.handedness} removed`,s.index),this.controllerStates.splice(i,1),this.sendControllerRemoved(s))}for(const i of e.controllers)this.updateControllerStates(i)}}onExitXR(e){for(const i of this.controllerStates)this.sendControllerRemoved(i);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const i=this.controllerStates.find(s=>s.index===e.index);if(i){let s=!1;s||(s=i.isTracking!=e.isTracking),s&&(i.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,i))}else{const s={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(s),this.context.connection.send(this.userStateEvtName,s),Xb&&console.log(`XRSync: ${s.type} ${s.handedness} added`,s.index)}}}class YH{constructor(e){p(this,"context"),p(this,"onJoinedRoom",()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(Xb&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new yk(this.context.connection.connectionId,this.context)));for(const i of this.context.connection.usersInRoom())this._states.has(i)||this._states.set(i,new yk(i,this.context))}}),p(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)}}),p(this,"onOtherUserJoinedRoom",i=>{const s=i.userId;this._states.has(s)||(Xb&&console.log("XRSync: Remote user joined room",s),this._states.set(s,new yk(s,this.context)))}),p(this,"onOtherUserLeftRoom",i=>{const s=i.userId;if(!this._states.has(s)){const r=this._states.get(s);r?.dispose(),this._states.delete(s)}}),p(this,"_states",new Map),this.context=e,this.context.connection.beginListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}hasState(e){return e?this._states.has(e):!1}isTracking(e,i){if(!e)return;const s=this._states.get(e);if(!s)return;const r=s.controllerStates.find(o=>o.handedness===i);return r?.isTracking||!1}getDeviceType(e,i){if(!e)return;const s=this._states.get(e);if(!s)return;const r=s.controllerStates.find(o=>o.handedness===i);return r?.type||"unknown"}destroy(){this.context.connection.stopListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Xt.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Xt.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Xt.UserLeftRoom,this.onOtherUserLeftRoom)}onUpdate(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const i=this._states.get(this.context.connection.connectionId);i?.update(e)}}onExitXR(e){if(this.context.connection.isConnected&&this.context.connection.connectionId){const i=this._states.get(this.context.connection.connectionId);i?.onExitXR(e)}}}class KH{constructor(){p(this,"_fadeToColorQuad"),p(this,"_fadeToColorMaterial"),p(this,"_requestedFadeValue",0),p(this,"_transitionPromise",null),p(this,"_transitionResolve",null),this._fadeToColorMaterial=new Ht({color:0,transparent:!0,depthTest:!1,fog:!1,side:Ai}),this._fadeToColorQuad=new ue(new Kn(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,i){const s=this._fadeToColorQuad,r=this._fadeToColorMaterial;s.parent!==e&&r.opacity>0?e.add(s):r.opacity===0&&s.removeFromParent(),s.layers.set(2),s.material=this._fadeToColorMaterial,s.position.z=-1,s.renderOrder=1/0;const o=this._requestedFadeValue;r.opacity=et.lerp(r.opacity,o,i/.03),Math.abs(r.opacity-o)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(i=>{this._transitionResolve=i});return this._transitionPromise=e,e}}class lpe extends Hy{constructor(e,i={}){const s=i.font;if(s===void 0)super();else{const r=s.generateShapes(e,i.size);i.depth=i.height!==void 0?i.height:50,i.bevelThickness===void 0&&(i.bevelThickness=10),i.bevelSize===void 0&&(i.bevelSize=8),i.bevelEnabled===void 0&&(i.bevelEnabled=!1),super(r,i)}this.type="TextGeometry"}}class cpe extends is{constructor(e){super(e)}load(e,i,s,r){const o=this,a=new Js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){const c=o.parse(JSON.parse(l));i&&i(c)},s,r)}parse(e){return new JH(e)}}class JH{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,i=100){const s=[],r=hpe(e,i,this.data);for(let o=0,a=r.length;o<a;o++)s.push(...r[o].toShapes());return s}}function hpe(n,e,i){const s=Array.from(n),r=e/i.resolution,o=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,a=[];let l=0,c=0;for(let h=0;h<s.length;h++){const d=s[h];if(d===`
|
|
4963
|
-
`)l=0,c-=o;else{const u=dpe(d,r,l,c,i);l+=u.offsetX,a.push(u.path)}}return a}function dpe(n,e,i,s,r){const o=r.glyphs[n]||r.glyphs["?"];if(!o){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const a=new sU;let l,c,h,d,u,m,f,g;if(o.o){const v=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let y=0,b=v.length;y<b;)switch(v[y++]){case"m":l=v[y++]*e+i,c=v[y++]*e+s,a.moveTo(l,c);break;case"l":l=v[y++]*e+i,c=v[y++]*e+s,a.lineTo(l,c);break;case"q":h=v[y++]*e+i,d=v[y++]*e+s,u=v[y++]*e+i,m=v[y++]*e+s,a.quadraticCurveTo(u,m,h,d);break;case"b":h=v[y++]*e+i,d=v[y++]*e+s,u=v[y++]*e+i,m=v[y++]*e+s,f=v[y++]*e+i,g=v[y++]*e+s,a.bezierCurveTo(u,m,f,g,h,d);break}}return{offsetX:o.ha*e,path:a}}function upe(n,e=1e-4){e=Math.max(e,Number.EPSILON);const i={},s=n.getIndex(),r=n.getAttribute("position"),o=s?s.count:r.count;let a=0;const l=Object.keys(n.attributes),c={},h={},d=[],u=["getX","getY","getZ","getW"],m=["setX","setY","setZ","setW"];for(let A=0,x=l.length;A<x;A++){const w=l[A],_=n.attributes[w];c[w]=new $e(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized);const S=n.morphAttributes[w];S&&(h[w]=new $e(new S.array.constructor(S.count*S.itemSize),S.itemSize,S.normalized))}const f=e*.5,g=Math.log10(1/e),v=Math.pow(10,g),y=f*v;for(let A=0;A<o;A++){const x=s?s.getX(A):A;let w="";for(let _=0,S=l.length;_<S;_++){const C=l[_],R=n.getAttribute(C),P=R.itemSize;for(let T=0;T<P;T++)w+=`${~~(R[u[T]](x)*v+y)},`}if(w in i)d.push(i[w]);else{for(let _=0,S=l.length;_<S;_++){const C=l[_],R=n.getAttribute(C),P=n.morphAttributes[C],T=R.itemSize,L=c[C],k=h[C];for(let G=0;G<T;G++){const O=u[G],W=m[G];if(L[W](a,R[O](x)),P)for(let D=0,F=P.length;D<F;D++)k[D][W](a,P[D][O](x))}}i[w]=a,d.push(a),a++}}const b=n.clone();for(const A in n.attributes){const x=c[A];if(b.setAttribute(A,new $e(x.array.slice(0,a*x.itemSize),x.itemSize,x.normalized)),A in h)for(let w=0;w<h[A].length;w++){const _=h[A][w];b.morphAttributes[A][w]=new $e(_.array.slice(0,a*_.itemSize),_.itemSize,_.normalized)}}return b.setIndex(d),b}function qH(n,e){if(e===hN)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===j1||e===OR){let i=n.getIndex();if(i===null){const a=[],l=n.getAttribute("position");if(l!==void 0){for(let c=0;c<l.count;c++)a.push(c);n.setIndex(a),i=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const s=i.count-2,r=[];if(e===j1)for(let a=1;a<=s;a++)r.push(i.getX(0)),r.push(i.getX(a)),r.push(i.getX(a+1));else for(let a=0;a<s;a++)a%2===0?(r.push(i.getX(a)),r.push(i.getX(a+1)),r.push(i.getX(a+2))):(r.push(i.getX(a+2)),r.push(i.getX(a+1)),r.push(i.getX(a)));r.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=n.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class zh extends is{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(i){return new ype(i)}),this.register(function(i){return new Mpe(i)}),this.register(function(i){return new Epe(i)}),this.register(function(i){return new Tpe(i)}),this.register(function(i){return new bpe(i)}),this.register(function(i){return new Ape(i)}),this.register(function(i){return new xpe(i)}),this.register(function(i){return new wpe(i)}),this.register(function(i){return new gpe(i)}),this.register(function(i){return new _pe(i)}),this.register(function(i){return new vpe(i)}),this.register(function(i){return new Cpe(i)}),this.register(function(i){return new Spe(i)}),this.register(function(i){return new mpe(i)}),this.register(function(i){return new Rpe(i)}),this.register(function(i){return new Ipe(i)})}load(e,i,s,r){const o=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const h=wh.extractUrlBase(e);a=wh.resolveURL(h,this.path)}else a=wh.extractUrlBase(e);this.manager.itemStart(e);const l=function(h){r?r(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},c=new Js(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{o.parse(h,a,function(d){i(d),o.manager.itemEnd(e)},l)}catch(d){l(d)}},s,l)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,i,s,r){let o;const a={},l={},c=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===$H){try{a[fi.KHR_BINARY_GLTF]=new Lpe(e)}catch(d){r&&r(d);return}o=JSON.parse(a[fi.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new Wpe(o,{path:i||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[u.name]=u,a[u.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const u=o.extensionsUsed[d],m=o.extensionsRequired||[];switch(u){case fi.KHR_MATERIALS_UNLIT:a[u]=new fpe;break;case fi.KHR_DRACO_MESH_COMPRESSION:a[u]=new Ppe(o,this.dracoLoader);break;case fi.KHR_TEXTURE_TRANSFORM:a[u]=new kpe;break;case fi.KHR_MESH_QUANTIZATION:a[u]=new Bpe;break;default:m.indexOf(u)>=0&&l[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}h.setExtensions(a),h.setPlugins(l),h.parse(s,r)}parseAsync(e,i){const s=this;return new Promise(function(r,o){s.parse(e,i,r,o)})}}function ppe(){let n={};return{get:function(e){return n[e]},add:function(e,i){n[e]=i},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const fi={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class mpe{constructor(e){this.parser=e,this.name=fi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,i=this.parser.json.nodes||[];for(let s=0,r=i.length;s<r;s++){const o=i[s];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const i=this.parser,s="light:"+e;let r=i.cache.get(s);if(r)return r;const o=i.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let l;const c=new Ae(16777215);a.color!==void 0&&c.setRGB(a.color[0],a.color[1],a.color[2],ki);const h=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new Yp(c),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Zp(c),l.distance=h;break;case"spot":l=new Nv(c),l.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,l.angle=a.spot.outerConeAngle,l.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return l.position.set(0,0,0),l.decay=2,yu(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=i.createUniqueName(a.name||"light_"+e),r=Promise.resolve(l),i.cache.add(s,r),r}getDependency(e,i){if(e==="light")return this._loadLight(i)}createNodeAttachment(e){const i=this,s=this.parser,r=s.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return s._getNodeRef(i.cache,o,a)})}}let fpe=class{constructor(){this.name=fi.KHR_MATERIALS_UNLIT}getMaterialType(){return Ht}extendParams(n,e,i){const s=[];n.color=new Ae(1,1,1),n.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;n.color.setRGB(o[0],o[1],o[2],ki),n.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(n,"map",r.baseColorTexture,vt))}return Promise.all(s)}},gpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const i=this.parser.json.materials[n];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}},ype=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(e.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(e,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new K(a,a)}return Promise.all(r)}},vpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(e.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(e.iridescenceIOR=o.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},bpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_SHEEN}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Ae(0,0,0),e.sheenRoughness=0,e.sheen=1;const o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],ki)}return o.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(i.assignTexture(e,"sheenColorMap",o.sheenColorTexture,vt)),o.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},Ape=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(e.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(i.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},xpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_VOLUME}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];e.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(i.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return e.attenuationColor=new Ae().setRGB(a[0],a[1],a[2],ki),Promise.all(r)}},wpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_IOR}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser.json.materials[n];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},_pe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_SPECULAR}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];e.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(i.assignTexture(e,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return e.specularColor=new Ae().setRGB(a[0],a[1],a[2],ki),o.specularColorTexture!==void 0&&r.push(i.assignTexture(e,"specularColorMap",o.specularColorTexture,vt)),Promise.all(r)}},Spe=class{constructor(n){this.parser=n,this.name=fi.EXT_MATERIALS_BUMP}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return e.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(i.assignTexture(e,"bumpMap",o.bumpTexture)),Promise.all(r)}},Cpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(e.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(e.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(i.assignTexture(e,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}};class Mpe{constructor(e){this.parser=e,this.name=fi.KHR_TEXTURE_BASISU}loadTexture(e){const i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],a=i.options.ktx2Loader;if(!a){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return i.loadTextureImage(e,o.source,a)}}class Epe{constructor(e){this.parser=e,this.name=fi.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const i=this.name,s=this.parser,r=s.json,o=r.textures[e];if(!o.extensions||!o.extensions[i])return null;const a=o.extensions[i],l=r.images[a.source];let c=s.textureLoader;if(l.uri){const h=s.options.manager.getHandler(l.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,a.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(i)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const i=new Image;i.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",i.onload=i.onerror=function(){e(i.height===1)}})),this.isSupported}}class Tpe{constructor(e){this.parser=e,this.name=fi.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const i=this.name,s=this.parser,r=s.json,o=r.textures[e];if(!o.extensions||!o.extensions[i])return null;const a=o.extensions[i],l=r.images[a.source];let c=s.textureLoader;if(l.uri){const h=s.options.manager.getHandler(l.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,a.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(i)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const i=new Image;i.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",i.onload=i.onerror=function(){e(i.height===1)}})),this.isSupported}}class Rpe{constructor(e){this.name=fi.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const i=this.parser.json,s=i.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const r=s.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(l){const c=r.byteOffset||0,h=r.byteLength||0,d=r.count,u=r.byteStride,m=new Uint8Array(l,c,h);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,u,m,r.mode,r.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(d*u);return a.decodeGltfBuffer(new Uint8Array(f),d,u,m,r.mode,r.filter),f})})}else return null}}let Ipe=class{constructor(n){this.name=fi.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,i=e.nodes[n];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=e.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==Xa.TRIANGLES&&l.mode!==Xa.TRIANGLE_STRIP&&l.mode!==Xa.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=i.extensions[this.name].attributes,o=[],a={};for(const l in r)o.push(this.parser.getDependency("accessor",r[l]).then(c=>(a[l]=c,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(n)),Promise.all(o).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,u=[];for(const m of h){const f=new he,g=new M,v=new Se,y=new M(1,1,1),b=new T2(m.geometry,m.material,d);for(let A=0;A<d;A++)a.TRANSLATION&&g.fromBufferAttribute(a.TRANSLATION,A),a.ROTATION&&v.fromBufferAttribute(a.ROTATION,A),a.SCALE&&y.fromBufferAttribute(a.SCALE,A),b.setMatrixAt(A,f.compose(g,v,y));for(const A in a)if(A==="_COLOR_0"){const x=a[A];b.instanceColor=new Eo(x.array,x.itemSize,x.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,a[A]);ge.prototype.copy.call(b,m),this.parser.assignFinalMaterial(b),u.push(b)}return c.isGroup?(c.clear(),c.add(...u),c):u[0]}))}};const $H="glTF",Wb=12,e4={JSON:1313821514,BIN:5130562};class Lpe{constructor(e){this.name=fi.KHR_BINARY_GLTF,this.content=null,this.body=null;const i=new DataView(e,0,Wb),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:i.getUint32(4,!0),length:i.getUint32(8,!0)},this.header.magic!==$H)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Wb,o=new DataView(e,Wb);let a=0;for(;a<r;){const l=o.getUint32(a,!0);a+=4;const c=o.getUint32(a,!0);if(a+=4,c===e4.JSON){const h=new Uint8Array(e,Wb+a,l);this.content=s.decode(h)}else if(c===e4.BIN){const h=Wb+a;this.body=e.slice(h,h+l)}a+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ppe{constructor(e,i){if(!i)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=fi.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=i,this.dracoLoader.preload()}decodePrimitive(e,i){const s=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,l={},c={},h={};for(const d in a){const u=bk[d]||d.toLowerCase();l[u]=a[d]}for(const d in e.attributes){const u=bk[d]||d.toLowerCase();if(a[d]!==void 0){const m=s.accessors[e.attributes[d]],f=o0[m.componentType];h[u]=f.name,c[u]=m.normalized===!0}}return i.getDependency("bufferView",o).then(function(d){return new Promise(function(u,m){r.decodeDracoFile(d,function(f){for(const g in f.attributes){const v=f.attributes[g],y=c[g];y!==void 0&&(v.normalized=y)}u(f)},l,h,ki,m)})})}}class kpe{constructor(){this.name=fi.KHR_TEXTURE_TRANSFORM}extendTexture(e,i){return(i.texCoord===void 0||i.texCoord===e.channel)&&i.offset===void 0&&i.rotation===void 0&&i.scale===void 0||(e=e.clone(),i.texCoord!==void 0&&(e.channel=i.texCoord),i.offset!==void 0&&e.offset.fromArray(i.offset),i.rotation!==void 0&&(e.rotation=i.rotation),i.scale!==void 0&&e.repeat.fromArray(i.scale),e.needsUpdate=!0),e}}class Bpe{constructor(){this.name=fi.KHR_MESH_QUANTIZATION}}class t4 extends yg{constructor(e,i,s,r){super(e,i,s,r)}copySampleValue_(e){const i=this.resultBuffer,s=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let a=0;a!==r;a++)i[a]=s[o+a];return i}interpolate_(e,i,s,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,c=l*2,h=l*3,d=r-i,u=(s-i)/d,m=u*u,f=m*u,g=e*h,v=g-h,y=-2*f+3*m,b=f-m,A=1-y,x=b-m+u;for(let w=0;w!==l;w++){const _=a[v+w+l],S=a[v+w+c]*d,C=a[g+w+l],R=a[g+w]*d;o[w]=A*_+x*S+y*C+b*R}return o}}const Ope=new Se;class Dpe extends t4{interpolate_(e,i,s,r){const o=super.interpolate_(e,i,s,r);return Ope.fromArray(o).normalize().toArray(o),o}}const Xa={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},o0={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},i4={9728:Ot,9729:Dt,9984:Df,9985:Mp,9986:ch,9987:_o},n4={33071:es,33648:lh,10497:wo},vk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bk={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},gu={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gpe={CUBICSPLINE:void 0,LINEAR:sc,STEP:Ld},Ak={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Npe(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new vs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Vn})),n.DefaultMaterial}function wm(n,e,i){for(const s in i.extensions)n[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=i.extensions[s])}function yu(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Fpe(n,e,i){let s=!1,r=!1,o=!1;for(let h=0,d=e.length;h<d;h++){const u=e[h];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(r=!0),u.COLOR_0!==void 0&&(o=!0),s&&r&&o)break}if(!s&&!r&&!o)return Promise.resolve(n);const a=[],l=[],c=[];for(let h=0,d=e.length;h<d;h++){const u=e[h];if(s){const m=u.POSITION!==void 0?i.getDependency("accessor",u.POSITION):n.attributes.position;a.push(m)}if(r){const m=u.NORMAL!==void 0?i.getDependency("accessor",u.NORMAL):n.attributes.normal;l.push(m)}if(o){const m=u.COLOR_0!==void 0?i.getDependency("accessor",u.COLOR_0):n.attributes.color;c.push(m)}}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c)]).then(function(h){const d=h[0],u=h[1],m=h[2];return s&&(n.morphAttributes.position=d),r&&(n.morphAttributes.normal=u),o&&(n.morphAttributes.color=m),n.morphTargetsRelative=!0,n})}function zpe(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let i=0,s=e.weights.length;i<s;i++)n.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(n.morphTargetInfluences.length===i.length){n.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++)n.morphTargetDictionary[i[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Upe(n){let e;const i=n.extensions&&n.extensions[fi.KHR_DRACO_MESH_COMPRESSION];if(i?e="draco:"+i.bufferView+":"+i.indices+":"+xk(i.attributes):e=n.indices+":"+xk(n.attributes)+":"+n.mode,n.targets!==void 0)for(let s=0,r=n.targets.length;s<r;s++)e+=":"+xk(n.targets[s]);return e}function xk(n){let e="";const i=Object.keys(n).sort();for(let s=0,r=i.length;s<r;s++)e+=i[s]+":"+n[i[s]]+";";return e}function wk(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Vpe(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Xpe=new he;class Wpe{constructor(e={},i={}){this.json=e,this.extensions={},this.plugins={},this.options=i,this.cache=new ppe,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=!1,o=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||r&&o<98?this.textureLoader=new lc(this.options.manager):this.textureLoader=new Bz(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Js(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,i){const s=this,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(a){const l={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:s,userData:{}};return wm(o,l,r),yu(l,r),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(l)})).then(function(){e(l)})}).catch(i)}_markDefs(){const e=this.json.nodes||[],i=this.json.skins||[],s=this.json.meshes||[];for(let r=0,o=i.length;r<o;r++){const a=i[r].joints;for(let l=0,c=a.length;l<c;l++)e[a[l]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(s[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,i){i!==void 0&&(e.refs[i]===void 0&&(e.refs[i]=e.uses[i]=0),e.refs[i]++)}_getNodeRef(e,i,s){if(e.refs[i]<=1)return s;const r=s.clone(),o=(a,l)=>{const c=this.associations.get(a);c!=null&&this.associations.set(l,c);for(const[h,d]of a.children.entries())o(d,l.children[h])};return o(s,r),r.name+="_instance_"+e.uses[i]++,r}_invokeOne(e){const i=Object.values(this.plugins);i.push(this);for(let s=0;s<i.length;s++){const r=e(i[s]);if(r)return r}return null}_invokeAll(e){const i=Object.values(this.plugins);i.unshift(this);const s=[];for(let r=0;r<i.length;r++){const o=e(i[r]);o&&s.push(o)}return s}getDependency(e,i){const s=e+":"+i;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(i);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(i)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(i)});break;case"accessor":r=this.loadAccessor(i);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(i)});break;case"buffer":r=this.loadBuffer(i);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(i)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(i)});break;case"skin":r=this.loadSkin(i);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(i)});break;case"camera":r=this.loadCamera(i);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,i)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(s,r)}return r}getDependencies(e){let i=this.cache.get(e);if(!i){const s=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];i=Promise.all(r.map(function(o,a){return s.getDependency(e,a)})),this.cache.add(e,i)}return i}loadBuffer(e){const i=this.json.buffers[e],s=this.fileLoader;if(i.type&&i.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+i.type+" buffer type is not supported.");if(i.uri===void 0&&e===0)return Promise.resolve(this.extensions[fi.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,a){s.load(wh.resolveURL(i.uri,r.path),o,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+i.uri+'".'))})})}loadBufferView(e){const i=this.json.bufferViews[e];return this.getDependency("buffer",i.buffer).then(function(s){const r=i.byteLength||0,o=i.byteOffset||0;return s.slice(o,o+r)})}loadAccessor(e){const i=this,s=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=vk[r.type],l=o0[r.componentType],c=r.normalized===!0,h=new l(r.count*a);return Promise.resolve(new $e(h,a,c))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(a){const l=a[0],c=vk[r.type],h=o0[r.componentType],d=h.BYTES_PER_ELEMENT,u=d*c,m=r.byteOffset||0,f=r.bufferView!==void 0?s.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0;let v,y;if(f&&f!==u){const b=Math.floor(m/f),A="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+b+":"+r.count;let x=i.cache.get(A);x||(v=new h(l,b*f,r.count*f/d),x=new _v(v,f/d),i.cache.add(A,x)),y=new Qo(x,c,m%f/d,g)}else l===null?v=new h(r.count*c):v=new h(l,m,r.count*c),y=new $e(v,c,g);if(r.sparse!==void 0){const b=vk.SCALAR,A=o0[r.sparse.indices.componentType],x=r.sparse.indices.byteOffset||0,w=r.sparse.values.byteOffset||0,_=new A(a[1],x,r.sparse.count*b),S=new h(a[2],w,r.sparse.count*c);l!==null&&(y=new $e(y.array.slice(),y.itemSize,y.normalized));for(let C=0,R=_.length;C<R;C++){const P=_[C];if(y.setX(P,S[C*c]),c>=2&&y.setY(P,S[C*c+1]),c>=3&&y.setZ(P,S[C*c+2]),c>=4&&y.setW(P,S[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const i=this.json,s=this.options,r=i.textures[e].source,o=i.images[r];let a=this.textureLoader;if(o.uri){const l=s.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,i,s){const r=this,o=this.json,a=o.textures[e],l=o.images[i],c=(l.uri||l.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(i,s).then(function(d){d.flipY=!1,d.name=a.name||l.name||"",d.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(d.name=l.uri);const u=(o.samplers||{})[a.sampler]||{};return d.magFilter=i4[u.magFilter]||Dt,d.minFilter=i4[u.minFilter]||_o,d.wrapS=n4[u.wrapS]||wo,d.wrapT=n4[u.wrapT]||wo,d.anisotropy=4,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,i){const s=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=r.images[e],l=self.URL||self.webkitURL;let c=a.uri||"",h=!1;if(a.bufferView!==void 0)c=s.getDependency("bufferView",a.bufferView).then(function(u){h=!0;const m=new Blob([u],{type:a.mimeType});return c=l.createObjectURL(m),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then(function(u){return new Promise(function(m,f){let g=m;i.isImageBitmapLoader===!0&&(g=function(v){const y=new Vt(v);y.needsUpdate=!0,m(y)}),i.load(wh.resolveURL(u,o.path),g,void 0,f)})}).then(function(u){return h===!0&&l.revokeObjectURL(c),u.userData.mimeType=a.mimeType||Vpe(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=d,d}assignTexture(e,i,s,r){const o=this;return this.getDependency("texture",s.index).then(function(a){if(!a)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(a=a.clone(),a.channel=s.texCoord),o.extensions[fi.KHR_TEXTURE_TRANSFORM]){const l=s.extensions!==void 0?s.extensions[fi.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const c=o.associations.get(a);a=o.extensions[fi.KHR_TEXTURE_TRANSFORM].extendTexture(a,l),o.associations.set(a,c)}}return r!==void 0&&(a.colorSpace=r),e[i]=a,a})}assignFinalMaterial(e){const i=e.geometry;let s=e.material;const r=i.attributes.tangent===void 0,o=i.attributes.color!==void 0,a=i.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new Ud,Ft.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(l,c)),s=c}else if(e.isLine){const l="LineBasicMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new Vi,Ft.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(l,c)),s=c}if(r||o||a){let l="ClonedMaterial:"+s.uuid+":";r&&(l+="derivative-tangents:"),o&&(l+="vertex-colors:"),a&&(l+="flat-shading:");let c=this.cache.get(l);c||(c=s.clone(),o&&(c.vertexColors=!0),a&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(l,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return vs}loadMaterial(e){const i=this,s=this.json,r=this.extensions,o=s.materials[e];let a;const l={},c=o.extensions||{},h=[];if(c[fi.KHR_MATERIALS_UNLIT]){const u=r[fi.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),h.push(u.extendParams(l,o,i))}else{const u=o.pbrMetallicRoughness||{};if(l.color=new Ae(1,1,1),l.opacity=1,Array.isArray(u.baseColorFactor)){const m=u.baseColorFactor;l.color.setRGB(m[0],m[1],m[2],ki),l.opacity=m[3]}u.baseColorTexture!==void 0&&h.push(i.assignTexture(l,"map",u.baseColorTexture,vt)),l.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,l.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(i.assignTexture(l,"metalnessMap",u.metallicRoughnessTexture)),h.push(i.assignTexture(l,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,l)})))}o.doubleSided===!0&&(l.side=Ai);const d=o.alphaMode||Ak.OPAQUE;if(d===Ak.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,d===Ak.MASK&&(l.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&a!==Ht&&(h.push(i.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new K(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;l.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&a!==Ht&&(h.push(i.assignTexture(l,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&a!==Ht){const u=o.emissiveFactor;l.emissive=new Ae().setRGB(u[0],u[1],u[2],ki)}return o.emissiveTexture!==void 0&&a!==Ht&&h.push(i.assignTexture(l,"emissiveMap",o.emissiveTexture,vt)),Promise.all(h).then(function(){const u=new a(l);return o.name&&(u.name=o.name),yu(u,o),i.associations.set(u,{materials:e}),o.extensions&&wm(r,u,o),u})}createUniqueName(e){const i=Zt.sanitizeNodeName(e||"");return i in this.nodeNamesUsed?i+"_"+ ++this.nodeNamesUsed[i]:(this.nodeNamesUsed[i]=0,i)}loadGeometries(e){const i=this,s=this.extensions,r=this.primitiveCache;function o(l){return s[fi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,i).then(function(c){return s4(c,l,i)})}const a=[];for(let l=0,c=e.length;l<c;l++){const h=e[l],d=Upe(h),u=r[d];if(u)a.push(u.promise);else{let m;h.extensions&&h.extensions[fi.KHR_DRACO_MESH_COMPRESSION]?m=o(h):m=s4(new pt,h,i),r[d]={primitive:h,promise:m},a.push(m)}}return Promise.all(a)}loadMesh(e){const i=this,s=this.json,r=this.extensions,o=s.meshes[e],a=o.primitives,l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c].material===void 0?Npe(this.cache):this.getDependency("material",a[c].material);l.push(d)}return l.push(i.loadGeometries(a)),Promise.all(l).then(function(c){const h=c.slice(0,c.length-1),d=c[c.length-1],u=[];for(let f=0,g=d.length;f<g;f++){const v=d[f],y=a[f];let b;const A=h[f];if(y.mode===Xa.TRIANGLES||y.mode===Xa.TRIANGLE_STRIP||y.mode===Xa.TRIANGLE_FAN||y.mode===void 0)b=o.isSkinnedMesh===!0?new Mo(v,A):new ue(v,A),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),y.mode===Xa.TRIANGLE_STRIP?b.geometry=qH(b.geometry,OR):y.mode===Xa.TRIANGLE_FAN&&(b.geometry=qH(b.geometry,j1));else if(y.mode===Xa.LINES)b=new Lr(v,A);else if(y.mode===Xa.LINE_STRIP)b=new mn(v,A);else if(y.mode===Xa.LINE_LOOP)b=new P2(v,A);else if(y.mode===Xa.POINTS)b=new mg(v,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(b.geometry.morphAttributes).length>0&&zpe(b,o),b.name=i.createUniqueName(o.name||"mesh_"+e),yu(b,o),y.extensions&&wm(r,b,y),i.assignFinalMaterial(b),u.push(b)}for(let f=0,g=u.length;f<g;f++)i.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return o.extensions&&wm(r,u[0],o),u[0];const m=new Xn;o.extensions&&wm(r,m,o),i.associations.set(m,{meshes:e});for(let f=0,g=u.length;f<g;f++)m.add(u[f]);return m})}loadCamera(e){let i;const s=this.json.cameras[e],r=s[s.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?i=new Lt(oi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):s.type==="orthographic"&&(i=new oc(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(i.name=this.createUniqueName(s.name)),yu(i,s),Promise.resolve(i)}loadSkin(e){const i=this.json.skins[e],s=[];for(let r=0,o=i.joints.length;r<o;r++)s.push(this._loadNodeShallow(i.joints[r]));return i.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",i.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(r){const o=r.pop(),a=r,l=[],c=[];for(let h=0,d=a.length;h<d;h++){const u=a[h];if(u){l.push(u);const m=new he;o!==null&&m.fromArray(o.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',i.joints[h])}return new Ev(l,c)})}loadAnimation(e){const i=this.json,s=this,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],l=[],c=[],h=[],d=[];let u=0,m=r.channels.length;for(u=0,m=r.channels.length;u<m;u++){const f=r.channels[u],g=r.samplers[f.sampler],v=f.target,y=v.node,b=r.parameters!==void 0?r.parameters[g.input]:g.input,A=r.parameters!==void 0?r.parameters[g.output]:g.output;v.node!==void 0&&(a.push(this.getDependency("node",y)),l.push(this.getDependency("accessor",b)),c.push(this.getDependency("accessor",A)),h.push(g),d.push(v))}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d)]).then(function(f){const g=f[0],v=f[1],y=f[2],b=f[3],A=f[4],x=[];for(u=0,m=g.length;u<m;u++){const w=g[u],_=v[u],S=y[u],C=b[u],R=A[u];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const P=s._createAnimationTracks(w,_,S,C,R);if(P)for(let T=0;T<P.length;T++)x.push(P[T])}return new to(o,void 0,x)})}createNodeMesh(e){const i=this.json,s=this,r=i.nodes[e];return r.mesh===void 0?null:s.getDependency("mesh",r.mesh).then(function(o){const a=s._getNodeRef(s.meshCache,r.mesh,o);return r.weights!==void 0&&a.traverse(function(l){if(l.isMesh)for(let c=0,h=r.weights.length;c<h;c++)l.morphTargetInfluences[c]=r.weights[c]}),a})}loadNode(e){const i=this.json,s=this,r=i.nodes[e],o=s._loadNodeShallow(e),a=[],l=r.children||[];for(let h=0,d=l.length;h<d;h++)a.push(s.getDependency("node",l[h]));const c=r.skin===void 0?Promise.resolve(null):s.getDependency("skin",r.skin);return Promise.all([o,Promise.all(a),c]).then(function(h){const d=h[0],u=h[1],m=h[2];m!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(m,Xpe)});for(let f=0,g=u.length;f<g;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const i=this.json,s=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=i.nodes[e],a=o.name?r.createUniqueName(o.name):"",l=[],c=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&l.push(c),o.camera!==void 0&&l.push(r.getDependency("camera",o.camera).then(function(h){return r._getNodeRef(r.cameraCache,o.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){l.push(h)}),this.nodeCache[e]=Promise.all(l).then(function(h){let d;if(o.isBone===!0?d=new Vp:h.length>1?d=new Xn:h.length===1?d=h[0]:d=new ge,d!==h[0])for(let u=0,m=h.length;u<m;u++)d.add(h[u]);if(o.name&&(d.userData.name=o.name,d.name=a),yu(d,o),o.extensions&&wm(s,d,o),o.matrix!==void 0){const u=new he;u.fromArray(o.matrix),d.applyMatrix4(u)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const i=this.extensions,s=this.json.scenes[e],r=this,o=new Xn;s.name&&(o.name=r.createUniqueName(s.name)),yu(o,s),s.extensions&&wm(i,o,s);const a=s.nodes||[],l=[];for(let c=0,h=a.length;c<h;c++)l.push(r.getDependency("node",a[c]));return Promise.all(l).then(function(c){for(let d=0,u=c.length;d<u;d++)o.add(c[d]);const h=d=>{const u=new Map;for(const[m,f]of r.associations)(m instanceof Ft||m instanceof Vt)&&u.set(m,f);return d.traverse(m=>{const f=r.associations.get(m);f!=null&&u.set(m,f)}),u};return r.associations=h(o),o})}_createAnimationTracks(e,i,s,r,o){const a=[],l=e.name?e.name:e.uuid,c=[];gu[o.path]===gu.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(l);let h;switch(gu[o.path]){case gu.weights:h=bh;break;case gu.rotation:h=yl;break;case gu.position:case gu.scale:h=ac;break;default:switch(s.itemSize){case 1:h=bh;break;case 2:case 3:default:h=ac;break}break}const d=r.interpolation!==void 0?Gpe[r.interpolation]:sc,u=this._getArrayFromAccessor(s);for(let m=0,f=c.length;m<f;m++){const g=new h(c[m]+"."+gu[o.path],i.array,u,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let i=e.array;if(e.normalized){const s=wk(i.constructor),r=new Float32Array(i.length);for(let o=0,a=i.length;o<a;o++)r[o]=i[o]*s;i=r}return i}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof yl?Dpe:t4;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Hpe(n,e,i){const s=e.attributes,r=new Wt;if(s.POSITION!==void 0){const l=i.json.accessors[s.POSITION],c=l.min,h=l.max;if(c!==void 0&&h!==void 0){if(r.set(new M(c[0],c[1],c[2]),new M(h[0],h[1],h[2])),l.normalized){const d=wk(o0[l.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const l=new M,c=new M;for(let h=0,d=o.length;h<d;h++){const u=o[h];if(u.POSITION!==void 0){const m=i.json.accessors[u.POSITION],f=m.min,g=m.max;if(f!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),m.normalized){const v=wk(o0[m.componentType]);c.multiplyScalar(v)}l.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}n.boundingBox=r;const a=new tn;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=a}function s4(n,e,i){const s=e.attributes,r=[];function o(a,l){return i.getDependency("accessor",a).then(function(c){n.setAttribute(l,c)})}for(const a in s){const l=bk[a]||a.toLowerCase();l in n.attributes||r.push(o(s[a],l))}if(e.indices!==void 0&&!n.index){const a=i.getDependency("accessor",e.indices).then(function(l){n.setIndex(l)});r.push(a)}return Mi.workingColorSpace!==ki&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Mi.workingColorSpace}" not supported.`),yu(n,e),Hpe(n,e,i),Promise.all(r).then(function(){return e.targets!==void 0?Fpe(n,e.targets,i):n})}var _m=(n=>(n[n.Quad=0]="Quad",n[n.Cube=1]="Cube",n[n.Sphere=2]="Sphere",n[n.RoundedCube=10]="RoundedCube",n))(_m||{}),XS,_k;class vu{static createText(e,i){let s=null;const r=i?.font||Qpe(i?.familyFamily||null);r instanceof JH?s=If(this,XS,_k).call(this,e,r,i):s==null&&(s=new pt);const o=i?.color||16777215,a=new ue(s,i?.material??new vs({color:o}));return this.applyDefaultObjectOptions(a,i),r instanceof Promise?r.then(l=>{a.geometry=If(this,XS,_k).call(this,e,l,i),i!=null&&i.onGeometry&&i.onGeometry(a)}):i!=null&&i.onGeometry&&i.onGeometry(a),a}static createOccluder(e){const i=new Ht({colorWrite:!1,depthWrite:!0,side:Ai});return this.createPrimitive(e,{material:i})}static createPrimitive(e,i){let s;const r=i?.color||16777215;switch(e){case"Quad":case 0:{const o=new Kn(1,1,1,1),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Quad"}break;case"Cube":case 1:{const o=new Hi(1,1,1),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Cube"}break;case 10:case"RoundedCube":{const o=jpe(1,1,1,.1,2),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="RoundedCube"}break;case"Sphere":case 2:{const o=new ll(.5,16,16),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Sphere"}break;case"ShaderBall":s=new Xn,s.name="ShaderBall",Zpe(s,i);break}return this.applyDefaultObjectOptions(s,i),s}static createSprite(e){const i=new Cw({color:16777215});e!=null&&e.texture&&"map"in i&&(i.map=e.texture);const s=new S2(i);return this.applyDefaultObjectOptions(s,e),s}static applyDefaultObjectOptions(e,i){e.receiveShadow=!0,e.castShadow=!0,i!=null&&i.name&&(e.name=i.name),i!=null&&i.position&&(Array.isArray(i.position)?e.position.set(i.position[0],i.position[1],i.position[2]):e.position.set(i.position.x,i.position.y,i.position.z)),i!=null&&i.rotation&&(Array.isArray(i.rotation)?e.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2]):e.rotation.set(i.rotation.x,i.rotation.y,i.rotation.z)),i!=null&&i.scale&&(typeof i.scale=="number"?e.scale.set(i.scale,i.scale,i.scale):e.scale.set(i.scale.x,i.scale.y,i.scale.z)),i?.receiveShadow!=null&&(e.receiveShadow=i.receiveShadow),i?.castShadow!=null&&(e.castShadow=i.castShadow),i!=null&&i.parent&&i.parent.add(e)}}XS=new WeakSet,_k=function(n,e,i){const s=i?.depth||.1;return new lpe(n,{font:e,size:1,depth:s,height:s,bevelEnabled:i?.bevel||!1,bevelThickness:.01,bevelOffset:.01,bevelSize:.01})},Ia(vu,XS);function jpe(n,e,i,s,r){const o=new Xd,a=1e-5,l=s-a;o.absarc(a,a,a,-Math.PI/2,-Math.PI,!0),o.absarc(a,e-l*2,a,Math.PI,Math.PI/2,!0),o.absarc(n-l*2,e-l*2,a,Math.PI/2,0,!0),o.absarc(n-l*2,a,a,0,-Math.PI/2,!0);const c=new Hy(o,{bevelEnabled:!0,bevelSegments:r*2,steps:1,bevelSize:l,bevelThickness:s,curveSegments:r});return c.scale(1,1,1-s),c.center(),c.computeVertexNormals(),c}const WS=new Map;function Qpe(n){let e="";switch(n){default:case"OpenSans":e="https://cdn.needle.tools/static/fonts/facetype/Open Sans_Regular_ascii.json";break;case"Helvetiker":e="https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/helvetiker_regular.typeface.json";break}if(WS.has(e)){const r=WS.get(e);if(r)return r}const i=new cpe,s=new Promise((r,o)=>{i.load(e,a=>{WS.set(e,a),r(a)},void 0,o)});return WS.set(e,s),s}let Sk=!1,Ck=null;function Zpe(n,e){if(Ck===null){const i="https://cdn.needle.tools/static/models/shaderball.glb",s=new zh,r=DP(null);s.setDRACOLoader(r.dracoLoader),s.setKTX2Loader(r.ktx2Loader),Sk=!0,Ck=s.loadAsync(i).then(o=>{const a=o.scene;return a.position.y-=.5,a}).catch(o=>(console.warn("Failed to load shaderball mesh: "+o.message),o4())).finally(()=>{Sk=!1})}if(Sk){const i=o4();i.name="ShaderBall-Placeholder";const s=i.children[0];s?.type==="Mesh"&&r4(s,e),n.add(i)}Ck.then(i=>{n.children.forEach(o=>{o.name==="ShaderBall-Placeholder"&&n.remove(o)});const s=i.clone(),r=s.children[0];r?.type==="Mesh"&&r4(r,e),n.add(s)})}function r4(n,e){var i;if(e?.color||e?.material||e?.texture){const s=e?.material??((i=n.material)==null?void 0:i.clone())??new vs;e.color&&"color"in s&&s.color instanceof Ae&&s.color.set(e.color),e!=null&&e.texture&&"map"in s&&(s.map=e.texture),n.material=s}}function o4(){return new Xn().add(vu.createPrimitive("Sphere",{material:new Ht({transparent:!0,opacity:.1})}))}const a4=class{constructor(n,e,i){p(this,"_session"),p(this,"_mode"),p(this,"_init"),p(this,"_renderer"),p(this,"_camera"),p(this,"_scene"),p(this,"onEnd",()=>{var s;(s=this._session)==null||s.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),p(this,"_lastTime",0),p(this,"onFrame",(s,r)=>{const o=s-this._lastTime;this.update(s,o),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),p(this,"_objects",[]),this._mode=n,this._init=e,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new vh({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new Lt,this._scene=new Is,this._scene.fog=new Sw(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(n,e){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(!e)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(n,e);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new a4(n,e,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 bl(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 n={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,n}async onBeforeHandoff(){await bl(1e3),this._scene.clear()}setupScene(){this._scene.background=new Ae(0),this._scene.add(new a_(5,10,1118481,1118481));const n=new Yp(16777215,1);n.position.set(0,20,0),n.castShadow=!1,this._scene.add(n);const e=new Yp(16777215,1);e.position.set(0,-1,0),e.castShadow=!1,this._scene.add(e);const i=new Zp(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const s=50;for(let r=0;r<100;r++){const o=new vs({color:2236962,metalness:1,roughness:.8});this.isAR&&(o.emissive=new Ae(Math.random(),Math.random(),Math.random()),o.emissiveIntensity=Math.random());const a=et.random(0,1)>.5?_m.Sphere:_m.Cube,l=vu.createPrimitive(a,{material:o});l.position.x=et.random(-s,s),l.position.y=et.random(-2,s),l.position.z=et.random(-s,s),l.rotation.x=et.random(0,Math.PI*2),l.rotation.y=et.random(0,Math.PI*2),l.rotation.z=et.random(0,Math.PI*2),l.scale.multiplyScalar(.5+Math.random()*10);const c=l.position.distanceTo(this._camera.position)-l.scale.x;c<1&&l.position.multiplyScalar(1+1/c),this._objects.push(l),this._scene.add(l)}}update(n,e){const i=n*4e-4;for(let s=0;s<this._objects.length;s++){const r=this._objects[s];r.position.y+=Math.sin(i+s*.5)*.005,r.rotateY(.002)}}};let a0=a4;p(a0,"_active",null),p(a0,"_requestInFlight",!1);var Hb;(n=>{const e=[];function i(){if(!(e!=null&&e.length))return!1;for(const o of e)o.exportAndOpen();return!0}n.exportAndOpen=i;function s(o){e.push(o)}n.registerExporter=s;function r(o){if(!e)return;const a=e.indexOf(o);a>=0&&e.splice(a,1)}n.unregisterExporter=r})(Hb||(Hb={}));const l4="NeedleXRSession onStart",c4="NeedleXRSession onEnd",Os=te("debugwebxr"),h4=te("stats");let Mk=0;function Ype(n){let e=null;const i=n;return i.getAROverlayContainer?e=i.getAROverlayContainer():e=n,e}Kpe();async function Kpe(){var n;if(te("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],xi.addContextCreatedCallback(async i=>{if(!e)return;rm(!0);const s=await e;if(s){const r=Et.getDefaultSessionInit("immersive-vr");Et.setSession("immersive-vr",s,r,i.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(n=navigator.xr)==null||n.addEventListener("sessiongranted",async()=>{rm(!0),console.log("Received Session Granted..."),await bl(100);const e=sessionStorage.getItem("needle_xr_session_mode"),i=sessionStorage.getItem("needle_xr_session_init")??null,s=i?JSON.parse(i):null;let r=null;if(d4()&&(await a0.start(e||"immersive-vr",s||Et.getDefaultSessionInit("immersive-vr")),await $pe(),r=await a0.handoff()),r)Et.setSession(r.mode,r.session,r.init,Pt.Current);else if(e&&i){console.log("Session Granted: Restore last session");const o=JSON.parse(i);Et.start(e,o).catch(a=>console.warn(a))}else Et.start("immersive-vr").catch(o=>console.warn("Session Granted failed:",o))},{once:!0})}}function Jpe(n,e){sessionStorage.setItem("needle_xr_session_mode",n),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function qpe(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const Ek=new Set;xi.registerCallback(_i.ContextCreationStart,async n=>{Ek.add(n.context)}),xi.registerCallback(_i.ContextCreated,async n=>{Ek.delete(n.context)});function d4(){return Ek.size>0}function $pe(){return new Promise(n=>{const e=Date.now(),i=setInterval(()=>{(!d4()||Date.now()-e>6e4)&&(clearInterval(i),n())},100)})}At.isDesktop()&&je()&&window.addEventListener("keydown",n=>{(n.key==="x"||n.key==="Escape")&&Et.active&&Et.stop()});const bu=class{constructor(n,e,i,s){p(this,"context"),p(this,"session"),p(this,"mode"),p(this,"controllers",[]),p(this,"_rigScale",1),p(this,"_lastRigScaleUpdate",-1),p(this,"_rigs",[]),p(this,"_viewerHitTestSource",null),p(this,"_defaultRig"),p(this,"_xr_scripts"),p(this,"_xr_update_scripts",[]),p(this,"_inactive_scripts",[]),p(this,"_controllerAdded"),p(this,"_controllerRemoved"),p(this,"_originalCameraWorldPosition"),p(this,"_originalCameraWorldRotation"),p(this,"_originalCameraWorldScale"),p(this,"_originalCameraParent"),p(this,"_mainCamera",null),p(this,"onRendererSessionSet",()=>{var a;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(a=this.context.mainCameraComponent)==null||a.applyClearFlags())}),p(this,"onInputSourceAdded",a=>{if(a.targetRayMode==="screen")return;let l=0;for(let h=0;h<this.session.inputSources.length;h++)if(this.session.inputSources[h]===a){l=h;break}if(this.controllers.find(h=>h.inputSource===a)){console.debug("Controller already exists for input source",l);return}else if(this._newControllers.find(h=>h.inputSource===a)){console.debug("Controller already registered for input source",l);return}const c=new HP(this,a,l);this._newControllers.push(c)}),p(this,"_ended",!1),p(this,"_newControllers",[]),p(this,"onEnd",a=>{var l,c,h;if(this._ended)return;this._ended=!0,console.debug("XR Session ended"),qpe(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,mu(this.onBefore,Ji.LateUpdate);const d=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);d>=0&&this.context.pre_render_callbacks.splice(d,1);const u=this.context.post_render_callbacks.indexOf(this.onAfterRender);u>=0&&this.context.post_render_callbacks.splice(u,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var f,g;(f=this.context.mainCameraComponent)==null||f.applyClearFlags(),(g=this.context.mainCameraComponent)==null||g.applyClippingPlane()}),yW({session:this});for(const f of bu._xrEndListeners)f({xr:this});const m=[...this.controllers];for(let f=0;f<m.length;f++)this.disconnectInputSource(m[f].inputSource);this._newControllers.length=0,this.controllers.length=0;for(const f of this._xr_scripts)(l=f?.onLeaveXR)==null||l.call(f,{xr:this});(c=this.sync)==null||c.onExitXR(this),this.context.mainCamera&&((h=this._originalCameraParent)==null||h.add(this.context.mainCamera),this._originalCameraWorldPosition&&bs(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&Ba(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&wg(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),rm(!1),performance.mark(c4),performance.measure("NeedleXRSession",l4,c4)}),p(this,"_didStart",!1),p(this,"onBefore",a=>{var l,c,h,d,u,m,f,g;const v=a.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),((l=this.rig)==null?void 0:l.isActive)==!1&&(Os&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(c=this._mainCamera)!=null&&c.gameObject&&((d=(h=this._mainCamera)==null?void 0:h.gameObject)==null?void 0:d.parent)!==this.rig.gameObject&&this.rig.gameObject.add((u=this._mainCamera)==null?void 0:u.gameObject),this.internalUpdateState(),this.applyCustomForward();const y={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const b=[...this.context.new_scripts_xr];for(let A=0;A<b.length;A++){const x=this.context.new_scripts_xr[A];if(!x||x.destroyed||((m=x.supportsXR)==null?void 0:m.call(x,this.mode))==!1){this.context.new_scripts_xr.splice(A,1);continue}if(!x.activeAndEnabled){this.context.new_scripts_xr.splice(A,1),this.markInactive(x);continue}if(this.addScript(x)){this.invokeCallback_EnterXR(x);for(const w of this.controllers)this.invokeCallback_ControllerAdded(x,w)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const A=Jo(this.context.scene.children);if(A){const x=A.getSize(ht());if(x.length()>0){const w=this._defaultRig.gameObject;w.position.set(A.min.x+x.x*.5,A.min.y,A.max.z+x.z*.5+1.5);const _=A.getCenter(ht());_.y=w.position.y,w.lookAt(_)}}}gW({session:this});for(const A of bu._xrStartListeners)A(y);const b=[...this._xr_scripts];Os&&console.log("NeedleXRSession start, handle scripts:",b);for(const A of b){if(A.destroyed){this._script_to_remove.push(A);continue}if(!A.activeAndEnabled){this.markInactive(A);continue}this.invokeCallback_EnterXR(A);for(const x of this.controllers)this.invokeCallback_ControllerAdded(A,x)}}this.syncCameraCullingMask();for(const b of this.controllers)b.onUpdate(v);if(this._newControllers.length>0){const b=[...this._newControllers];this._newControllers.length=0;for(const A of b){if(!A.connected){console.warn("New controller is not connected",A);continue}this.controllers.push(A);for(const x of this._xr_scripts){if(x.destroyed){this._script_to_remove.push(x);continue}x.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(x,A)}}this.controllers.sort((A,x)=>A.index-x.index)}Os&&this.context.time.frame%30===0&&this.controllers.length<=0&&this.session.inputSources.length>0&&(rm(!0),console.error("XRControllers are not added but inputSources are present")),performance.mark("NeedleXRSession update scripts start");for(const b of this._xr_update_scripts){if(b.destroyed===!0){this._script_to_remove.push(b);continue}if(b.activeAndEnabled===!1){this.markInactive(b);continue}b.onUpdateXR&&b.onUpdateXR(y)}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 b=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const A of b)!A.destroyed&&this.running&&((f=A.onLeaveXR)==null||f.call(A,y)),this.removeScript(A)}(g=this.sync)==null||g.onUpdate(this),this.onRenderDebug(),performance.mark("NeedleXRSession onBefore end"),performance.measure("NE XR frame","NeedleXRSession onBefore start","NeedleXRSession onBefore end")}),p(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),p(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),At.isDesktop()||!this._renderOnceOnDevice){const a=this.context.renderer;if(a.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const l=a.xr.enabled,c=a.getRenderTarget(),h=this.context.scene.background;a.xr.enabled=!1,a.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):a.render(this.context.scene,this.context.mainCamera),a.xr.enabled=l,a.setRenderTarget(c),this.context.scene.background=h}}}),p(this,"_script_to_remove",[]),p(this,"_camera"),p(this,"_cameraRenderParent",new ge().rotateY(Math.PI)),p(this,"_previousCameraParent"),p(this,"_customforward",!0),p(this,"originalCameraNearPlane"),p(this,"_viewerPose"),p(this,"_transformOrientation",new Se),p(this,"_transformPosition",new M),p(this,"_transition");var r,o;performance.mark(l4),Jpe(n,s.init),this.session=e,this.mode=n,this.context=i,(Os||te("console"))&&rm(!0),this._xr_scripts=[...s.scripts],this._xr_update_scripts=this._xr_scripts.filter(a=>typeof a.onUpdateXR=="function"),this._controllerAdded=s.controller_added,this._controllerRemoved=s.controller_removed,pu(this.onBefore,Ji.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=s.init.optionalFeatures)!=null&&r.includes("hit-test")||(o=s.init.requiredFeatures)!=null&&o.includes("hit-test"))&&e.requestReferenceSpace("viewer").then(a=>{var l,c;return(c=(l=e.requestHitTestSource)==null?void 0:l.call(e,{space:a}))==null?void 0:c.then(h=>this._viewerHitTestSource=h).catch(h=>console.error(h))}).catch(a=>console.error(a)),this.context.mainCamera&&(this._originalCameraWorldPosition=Nt(this.context.mainCamera,new M),this._originalCameraWorldRotation=Bi(this.context.mainCamera,new Se),this._originalCameraWorldScale=Yi(this.context.mainCamera,new M),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new fue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let a=0;a<e.inputSources.length;a++){const l=e.inputSources[a];if(!l.handedness){console.warn("Input source in xr session has no handedness - ignoring",a);continue}this.onInputSourceAdded(l)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",a=>{for(const l of a.removed)this.disconnectInputSource(l);for(const l of a.added)this.onInputSourceAdded(l)}),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):Os&&console.warn("controllerAutoUpdate is not available in three.js - cannot disable it")}static getXRSync(n){return this._sync||(this._sync=new YH(n)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var n;return((n=this._activeSession)==null?void 0:n.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(n=>n.some(e=>e)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(n){var e;return((e=this.xrSystem)==null?void 0:e.isSessionSupported(n).catch(i=>(Os&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(n){this._sessionRequestStartListeners.push(n)}static offSessionRequestStart(n){const e=this._sessionRequestStartListeners.indexOf(n);e>=0&&this._sessionRequestStartListeners.splice(e,1)}static onSessionRequestEnd(n){this._sessionRequestEndListeners.push(n)}static offSessionRequestEnd(n){const e=this._sessionRequestEndListeners.indexOf(n);e>=0&&this._sessionRequestEndListeners.splice(e,1)}static onXRSessionStart(n){this._xrStartListeners.push(n)}static offXRSessionStart(n){const e=this._xrStartListeners.indexOf(n);e>=0&&this._xrStartListeners.splice(e,1)}static onXRSessionEnd(n){this._xrEndListeners.push(n)}static offXRSessionEnd(n){const e=this._xrEndListeners.indexOf(n);e>=0&&this._xrEndListeners.splice(e,1)}static onControllerAdded(n){this._controllerAddedListeners.push(n)}static offControllerAdded(n){const e=this._controllerAddedListeners.indexOf(n);e>=0&&this._controllerAddedListeners.splice(e,1)}static onControllerRemoved(n){this._controllerRemovedListeners.push(n)}static offControllerRemoved(n){const e=this._controllerRemovedListeners.indexOf(n);e>=0&&this._controllerRemovedListeners.splice(e,1)}static offerSession(n,e,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+n),e=="default"&&(e=this.getDefaultSessionInit(n)),navigator.xr.offerSession(n,{...e}).then(s=>bu.setSession(n,s,e,i)).catch(s=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(n){switch(n){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test","unbounded"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",n),{}}}static async start(n,e,i){var s,r,o,a;if(At.isiOS()){if(n==="ar")if(await this.isARSupported())n="immersive-ar";else return Hb.exportAndOpen(),null}else n=="ar"&&(n="immersive-ar");if(je()&&te("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await a0.start(n,e||bu.getDefaultSessionInit(n)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Os||je())&&Oi("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=Pt.Current),i||(i=xi.All[0]),!i)throw new Error("No Needle Engine Context found");switch(performance.mark("NeedleXRSession start"),e||(e={}),n){case"immersive-ar":{if(await((s=this.xrSystem)==null?void 0:s.isSessionSupported("immersive-ar"))!==!0)return console.error(n+" is not supported by this browser."),null;const d=this.getDefaultSessionInit(n),u=Ype(i.domElement);u&&!At.isQuest()&&(d.domOverlay={root:u},d.optionalFeatures.push("dom-overlay")),e={...d,...e}}break;case"immersive-vr":{if(await((r=this.xrSystem)==null?void 0:r.isSessionSupported("immersive-vr"))!==!0)return console.error(n+" is not supported by this browser."),null;e={...this.getDefaultSessionInit(n),...e}}break;default:console.warn("No default session init for mode",n);break}e.optionalFeatures??(e.optionalFeatures=[]),e.requiredFeatures??(e.requiredFeatures=[]),await a0.stop();const l=n=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Os?console.log(`%cRequesting ${n} session`,"font-weight:bold;",e,l):console.log(`%cRequesting ${n} session`,"font-weight:bold;");for(const d of l)d.onBeforeXR&&d.onBeforeXR(n,e);for(const d of this._sessionRequestStartListeners)d({mode:n,init:e});Os&&gn("Requesting "+n+" session ("+Date.now()+")"),this._currentSessionRequest=(o=navigator.xr)==null?void 0:o.requestSession(n,e),this._currentSessionRequestMode=n;const c=await((a=this._currentSessionRequest)==null?void 0:a.catch(d=>{console.error(d,"Code: "+d.code),d.code===9&&Oi("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:"&&Oi("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const d of this._sessionRequestEndListeners)d({mode:n,init:e,newSession:c||null});if(!c)return console.warn("XR Session request was rejected"),null;const h=this.setSession(n,c,e,i);return performance.mark("NeedleXRSession end"),performance.measure("NeedleXRSession Startup","NeedleXRSession start","NeedleXRSession end"),h}static setSession(n,e,i,s){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=n=="immersive-ar"?s.scripts_immersive_ar:s.scripts_immersive_vr;return this._activeSession=new bu(n,e,s,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),e.addEventListener("end",this.onEnd),Os?console.log(`%cStarted ${n} session`,"font-weight:bold;",r):console.log(`%cStarted ${n} session`,"font-weight:bold;"),this._activeSession}static stop(){var n;(n=this._activeSession)==null||n.end()}get sync(){return bu._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(n=>n.side==="left")}get rightController(){return this.controllers.find(n=>n.side==="right")}getController(n){return typeof n=="number"?this.controllers[n]||null:this.controllers.find(e=>e.side===n)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(n=>n.inputSource.targetRayMode==="tracked-pointer")||je()&&At.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 n=this.frame.getImageTrackingResults();for(const e of n)if(e.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const n=this._rigs[0]??null;return n!=null&&n.gameObject&&Lm(n.gameObject)||n?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):n}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(n){this._rigs.indexOf(n)>=0||(n.priority===void 0&&(n.priority=0),this._rigs.push(n),this.updateActiveXRRig())}removeRig(n){const e=this._rigs.indexOf(n);e!==-1&&(this._rigs.splice(e,1),this.updateActiveXRRig())}setRigActive(n){const e=this._rigs.indexOf(n);this._rigs.splice(e,1),this._rigs.unshift(n),this.updateActiveXRRig()}getUserOffsetInRig(){var n;const e=(n=this.context.mainCamera)==null?void 0:n.position;if(!e||!this.rig)return ht(0,0,0);const i=ht(e);return i.x*=-1,i.z*=-1,i.applyQuaternion(xl(this.rig.gameObject.quaternion)),i}updateActiveXRRig(){const n=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 e=this._rigs[0];e&&e.priority===void 0&&(e.priority=0);for(let i=1;i<this._rigs.length;i++){const s=this._rigs[i];if(s.isActive){if(Lm(s.gameObject)){this._rigs.splice(i,1),i--;continue}(!e||e.isActive===!1||s.priority!==void 0&&s.priority>e.priority)&&(e=s)}}if(n!==e){const i=this._rigs.indexOf(e);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(e)}Os&&(n===e?console.log("Updated Active XR Rig:",e,"prev:",n):console.log("Updated Active XRRig:",e," (the same as before)"))}getHitTest(n){if(n)return this.getControllerHitTest(n);if(!this._viewerHitTestSource)return null;const e=this._viewerHitTestSource,i=this.frame.getHitTestResults(e);if(i.length>0){const s=i[0];return this.convertHitTestResult(s)}return null}getControllerHitTest(n){const e=n.getHitTestSource();if(!e)return null;const i=this.frame.getHitTestResultsForTransientInput(e);for(const s of i)if(s.inputSource===n.inputSource)for(const r of s.results)return this.convertHitTestResult(r);return null}convertHitTestResult(n){const e=this.context.renderer.xr.getReferenceSpace(),i=e&&n.getPose(e);if(i){const s=ht(i.transform.position),r=xl(i.transform.orientation),o=this.context.mainCamera;if(o?.parent!==this._cameraRenderParent&&s.applyMatrix4(i0),o!=null&&o.parent){s.applyMatrix4(o.parent.matrixWorld),r.multiply(Va);const a=Bi(o.parent);a.premultiply(Va),r.premultiply(a)}return{hit:n,position:s,quaternion:r}}return null}convertSpace(n){const e=ht(n.position);e.applyMatrix4(i0);const i=xl(n.orientation);return i.premultiply(Va),{position:e,quaternion:i}}disconnectInputSource(n){const e=(i,s,r)=>{if(i.inputSource===n){Os&&console.log("Disconnecting controller",i.index),this.controllers.splice(r,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const o={xr:this,controller:i,change:"removed"};for(const a of this._xr_scripts)a.onXRControllerRemoved&&a.onXRControllerRemoved(o);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const s=this.controllers[i];e(s,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const s=this._newControllers[i];e(s,this._newControllers,i)}}end(){this._ended||this.session.end().catch(n=>console.warn(n))}onRenderDebug(){if(Os)for(const n of this.controllers)n.onRenderDebug();if((Os||h4)&&this.rig&&(Mk++,Mk>=20)){const n=this.rig.gameObject.worldPosition,e=this.rig.gameObject.worldForward;n.add(e.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;n.add(i.multiplyScalar(2.5));let s="";if(s+=`${this.context.time.smoothedFps.toFixed(0)} FPS`,s+=`, calls: ${this.context.renderer.info.render.calls}, tris: ${this.context.renderer.info.render.triangles.toLocaleString()}`,Os||h4)for(const r of this.controllers)s+=`
|
|
4964
|
-
${r.hand?"hand":"ctrl"} ${r.inputSource.handedness}[${r.index}] con:${r.connected} tr:${r.isTracking} hts:${r.hasHitTestSource?"yes":"no"}`;Mk=0,ft.DrawLabel(n,s,void 0,1/60*20)}}addScript(n){return this._xr_scripts.includes(n)?!1:(Os&&console.log("Register new XRScript",n),this._xr_scripts.push(n),typeof n.onUpdateXR=="function"&&this._xr_update_scripts.push(n),!0)}markInactive(n){if(!(this._inactive_scripts.indexOf(n)>=0)){this.removeScript(n,!1),this._inactive_scripts.push(n);for(const e of this.controllers)this.invokeCallback_ControllerRemoved(n,e);this.invokeCallback_LeaveXR(n)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let n=this._inactive_scripts.length-1;n>=0;n--){const e=this._inactive_scripts[n];if(e.activeAndEnabled){this._inactive_scripts.splice(n,1),this.addScript(e),this.invokeCallback_EnterXR(e);for(const i of this.controllers)this.invokeCallback_ControllerAdded(e,i)}}}removeScript(n,e=!0){Os&&console.log("Remove XRScript",n);const i=this._xr_scripts.indexOf(n);i>=0&&this._xr_scripts.splice(i,1);const s=this._xr_update_scripts.indexOf(n);if(s>=0&&this._xr_update_scripts.splice(s,1),e){const r=this._inactive_scripts.indexOf(n);r>=0&&this._inactive_scripts.splice(r,1)}}invokeCallback_EnterXR(n){n.onEnterXR&&n.onEnterXR({xr:this})}invokeCallback_ControllerAdded(n,e){n.onXRControllerAdded&&n.onXRControllerAdded({xr:this,controller:e,change:"added"})}invokeCallback_ControllerRemoved(n,e){n.onXRControllerRemoved&&n.onXRControllerRemoved({xr:this,controller:e,change:"removed"})}invokeCallback_LeaveXR(n){n.onLeaveXR&&!n.destroyed&&n.onLeaveXR({xr:this})}syncCameraCullingMask(){var n;const e=this.context.xrCamera,i=(n=this.context.mainCameraComponent)==null?void 0:n.cullingMask;if(e&&i!==void 0){for(const s of e.cameras)s.layers.mask=i;e.layers.mask=i}else if(e){for(const s of e.cameras)s.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(n,e,i){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r)try{r({xr:this,controller:n,change:i})}catch(o){console.error(o)}}}applyCustomForward(){var n;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(n=this._previousCameraParent)==null||n.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let e=.02;if(this.rig){const i=Yi(this.rig.gameObject);e*=i.x}this._camera instanceof Lt&&this._camera.near>e&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=e)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Lt&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const n=this.context.renderer.xr.getReferenceSpace();if(!n){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(n),this._viewerPose){const e=this._viewerPose.transform;this._transformPosition.set(e.position.x,e.position.y,e.position.z),this._transformOrientation.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w)}}get transition(){return this._transition||(this._transition=new KH),this._transition}fadeTransition(){return this._transition||(this._transition=new KH),this._transition.fadeTransition()}updateFade(n){this._transition&&n instanceof Lt&&this._transition.update(n,this.context.time.deltaTime)}onUpdateFade_PostRender(){var n;(n=this._transition)==null||n.remove()}};let Et=bu;p(Et,"_sync",null),p(Et,"_currentSessionRequestMode",null),p(Et,"_currentSessionRequest"),p(Et,"_activeSession"),p(Et,"_sessionRequestStartListeners",[]),p(Et,"_sessionRequestEndListeners",[]),p(Et,"_xrStartListeners",[]),p(Et,"_xrEndListeners",[]),p(Et,"_controllerAddedListeners",[]),p(Et,"_controllerRemovedListeners",[]),p(Et,"onEnd",()=>{Os&&console.log("XR Session ended"),bu._activeSession=null});const Tk=te("debugwebxr");class u4{static tryFindAvatarObjects(e,i,s){if(s.head&&s.leftHand&&s.rightHand)return;const r=e.name.toLocaleLowerCase();!s.head&&r.includes("head")&&(Tk&&console.log("FOUND AVATAR HEAD",e.name),s.head=new ei("",i,e)),r.includes("hand")&&(!s.leftHand&&r.includes("left")&&(Tk&&console.log("FOUND AVATAR LEFT HAND",e.name),s.leftHand=new ei("",i,e)),!s.rightHand&&r.includes("right")&&(Tk&&console.log("FOUND AVATAR RIGHT HAND",e.name),s.rightHand=new ei("",i,e)));for(let o=0;o<e.children.length;o++){if(s.head&&s.leftHand&&s.rightHand)return;const a=e.children[o];this.tryFindAvatarObjects(a,i,s)}}}const Nr=new M,p4=new M,m4=new Se,eme=te("debuggizmos"),Ol=8947848,Rk=32,Dl=class{constructor(){}static isGizmo(n){return n[Lk]!==void 0}static DrawLabel(n,e,i=.05,s=0,r,o,a){var l;if(!Dl.enabled)return null;r||(r=Ol);const c=((l=Et.active)==null?void 0:l.rigScale)??1,h=rn.getTextLabel(s,e,i*c,r,o);return a instanceof ge&&a.add(h),h.position.x=n.x,h.position.y=n.y,h.position.z=n.z,h}static DrawRay(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,n.x,n.y,n.z),Nr.set(e.x,e.y,e.z).multiplyScalar(999999999),a.setXYZ(1,n.x+Nr.x,n.y+Nr.y,n.z+Nr.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(n,e,i=Ol,s=0,r=!0,o=1){if(!Dl.enabled)return;const a=rn.getLine(s),l=a.geometry.getAttribute("position");l.setXYZ(0,n.x,n.y,n.z),e.w!==void 0?(Nr.set(0,0,-o),m4.set(e.x,e.y,e.z,e.w),Nr.applyQuaternion(m4)):(Nr.set(e.x,e.y,e.z),Nr.multiplyScalar(o)),l.setXYZ(1,n.x+Nr.x,n.y+Nr.y,n.z+Nr.z),l.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,n.x,n.y,n.z),a.setXYZ(1,e.x,e.y,e.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawCircle(n,e,i,s=Ol,r=0,o=!0){if(!Dl.enabled)return;const a=rn.getCircle(r);a.position.set(n.x,n.y,n.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,Nr.set(e.x,e.y,e.z).normalize()),a.material.color.set(s),a.material.depthTest=o,a.material.depthWrite=!1,a.material.fog=!1}static DrawWireSphere(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getSphere(e,s,!0);nm(o,n.x,n.y,n.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getSphere(e,s,!1);nm(o,n.x,n.y,n.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getBox(s);o.position.set(n.x,n.y,n.z),o.scale.set(e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(n,e=Ol,i=0,s=!0){if(!Dl.enabled)return;const r=rn.getBox(i);r.position.copy(n.getCenter(Nr)),r.scale.copy(n.getSize(Nr)),r.material.color.set(e),r.material.depthTest=s,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawArrow(n,e,i=Ol,s=0,r=!0,o=!1){if(!Dl.enabled)return;const a=rn.getArrowHead(s);a.position.set(e.x,e.y,e.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Nr.set(e.x,e.y,e.z).sub(p4.set(n.x,n.y,n.z)).normalize());const l=Nr.set(e.x,e.y,e.z).sub(p4.set(n.x,n.y,n.z)).length()*.1;a.scale.set(l,l,l),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(n,e,i,s,r)}static DrawWireMesh(n){const e=rn.getMesh(n.duration??0);"mesh"in n?(e.geometry=n.mesh.geometry,e.matrix.copy(n.mesh.matrixWorld)):(e.geometry=n.geometry,e.matrix.copy(n.matrix)),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,e.material.color.set(n.color??Ol),e.material.depthTest=n.depthTest??!0,e.material.wireframe=!0}static setVisible(n){for(const e of rn.timedObjectsBuffer)e.visible=n}};let ft=Dl;p(ft,"enabled",!0),p(ft,"_up",new M(0,1,0));const tme=new Hi(1,1,1);function Ik(n=null){const e=new Ae(n??14540253),i=new H2(tme);return new Lr(i,new Vi({color:e}))}const Lk=Symbol("GizmoCache");class rn{static ensureFont(){let e=Xi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Xi.FontLibrary.addFontFamily(this.familyName);const i=e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");i?.addEventListener("ready",()=>{Xi.update()})}}static getTextLabel(e,i,s,r,o){this.ensureFont();let a=this.textLabelCache.pop(),l=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(l=parseInt(o.substring(7),16)/255,o=o.substring(0,7),eme&&console.log(o,l)):typeof o=="object"&&o.a!==void 0&&(l=o.a);const c={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:s,color:r,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:l,textContent:i,borderRadius:.5*s,padding:.8*s,whiteSpace:"pre",offset:.05*s};if(a)a.set(c);else{a=new tL(c);const h=this,d=a;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Pt.Current,a,e,this.textLabelCache),a}static getBox(e){let i=this.boxesCache.pop();if(!i){const s=new Hi(1,1,1);i=new ue(s)}return this.registerTimedObject(Pt.Current,i,e,this.boxesCache),i}static getLine(e){let i=this.linesCache.pop();if(!i){i=new mn;let s=i.geometry.getAttribute("position");s||(s=new $e(new Float32Array(2*3),3),i.geometry.setAttribute("position",s))}return i.frustumCulled=!1,this.registerTimedObject(Pt.Current,i,e,this.linesCache),i}static getCircle(e){let i=this.circlesCache.pop();if(!i){i=new mn;let s=i.geometry.getAttribute("position");if(!s){s=new $e(new Float32Array(Rk*3),3),i.geometry.setAttribute("position",s);const r=ht(0,1,0),o=ht(0,0,1),a=ht(o);a.cross(r).normalize();const l=ht(a),c=Math.PI*2/(Rk-1);for(let h=0;h<Rk+1;h++){const d=c*h;r.copy(l).multiplyScalar(Math.cos(d)*1),a.copy(o).multiplyScalar(Math.sin(d)*1);const u=r.add(a);s.setXYZ(h,u.x,u.y,u.z)}}}return i.frustumCulled=!1,this.registerTimedObject(Pt.Current,i,e,this.circlesCache),i}static getSphere(e,i,s){let r=this.spheresCache.pop();return r||(r=new ue(new ll(1,8,8))),r.scale.set(e,e,e),r.material.wireframe=s,this.registerTimedObject(Pt.Current,r,i,this.spheresCache),r}static getArrowHead(e){let i=this.arrowHeadsCache.pop();return i||(i=new ue(new Jn(0,.5,1,8))),this.registerTimedObject(Pt.Current,i,e,this.arrowHeadsCache),i}static getMesh(e){let i=this.mesh.pop();return i||(i=new ue,i.material=new Ht),this.registerTimedObject(Pt.Current,i,e,this.mesh),i}static registerTimedObject(e,i,s,r){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),a=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const l=e.pre_render_callbacks.indexOf(o);l>=0&&e.pre_render_callbacks.splice(l,1),e.pre_render_callbacks.push(o)}}else{const l=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,l),e.pre_render_callbacks.push(l)}if(a){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==a){const l=e.post_render_callbacks.indexOf(a);l>=0&&e.post_render_callbacks.splice(l,1),e.post_render_callbacks.push(a)}}else{const l=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,l),e.post_render_callbacks.push(l)}i.traverse(l=>{l.layers.disableAll(),l.layers.enable(2)}),i.renderOrder=999999,i[Lk]=r,i.castShadow=!1,i.receiveShadow=!1,i.isGizmo=!0,this.timedObjectsBuffer.push(i),this.timesBuffer.push(Pt.Current.time.realtimeSinceStartup+s),e.scene.add(i)}static onBeforeRender(e,i){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,Xi.update());for(let s=0;s<i.length;s++){const r=i[s];if(e.mainCamera&&r instanceof Xi.MeshUIBaseElement){if(Lm(r))continue;const o=e.isInVR,a=!1,l=!o;Zv(r,e.mainCamera,a,l)}}}static onPostRender(e,i,s){const r=e.time.realtimeSinceStartup;for(let o=i.length-1;o>=0;o--){const a=i[o];r>=s[o]-1e-6&&(i.splice(o,1),s.splice(o,1),a.removeFromParent(),Lm(a)!=!0&&a[Lk].push(a))}}}p(rn,"familyName","needle-gizmos"),p(rn,"linesCache",[]),p(rn,"circlesCache",[]),p(rn,"spheresCache",[]),p(rn,"boxesCache",[]),p(rn,"arrowHeadsCache",[]),p(rn,"mesh",[]),p(rn,"textLabelCache",[]),p(rn,"timedObjectsBuffer",new Array),p(rn,"timesBuffer",new Array),p(rn,"contextPostRenderCallbacks",new Map),p(rn,"contextBeforeRenderCallbacks",new Map),p(rn,"tmuiNeedsUpdate",!1);const Gl=te("debugphysics"),f4=new Er;class Ac{constructor(){p(this,"ray"),p(this,"cam"),p(this,"screenPoint"),p(this,"raycaster"),p(this,"results"),p(this,"targets"),p(this,"recursive",!0),p(this,"minDistance"),p(this,"maxDistance"),p(this,"lineThreshold"),p(this,"layerMask"),p(this,"ignore"),p(this,"testObject"),p(this,"useAcceleratedRaycast")}screenPointFromOffset(e,i){this.screenPoint===void 0&&(this.screenPoint=new K),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(i/window.innerHeight)*2+1}setLayer(e){f4.set(e),this.layerMask=f4}setMask(e){this.layerMask||(this.layerMask=new Er);const i=this.layerMask;i?i.mask=e:this.layerMask=e}}p(Ac,"AllLayers",4294967295);class Pk{constructor(e,i,s){p(this,"distance"),p(this,"point"),p(this,"object"),this.object=e,this.distance=i,this.point=s}}const kk=class{constructor(n){p(this,"context"),p(this,"engine"),p(this,"raycaster",new Hd),p(this,"defaultRaycastOptions",new Ac),p(this,"targetBuffer",new Array(1)),p(this,"defaultThresholds",{Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}}),p(this,"sphereResults",new Array),p(this,"sphereMask",new Er),p(this,"sphere",new tn),p(this,"tempBoundingBox",new Wt),this.context=n}static get raycasting(){return this._raycasting>0}raycastPhysicsFast(n,e=void 0,i=1/0,s=!0){var r;return((r=this.context.physics.engine)==null?void 0:r.raycast(n,e,{maxDistance:i,solid:s}))??null}raycastPhysicsFastAndGetNormal(n,e=void 0,i=1/0,s=!0){var r;return((r=this.context.physics.engine)==null?void 0:r.raycastAndGetNormal(n,e,{maxDistance:i,solid:s}))??null}sphereOverlapPhysics(n,e){var i;return((i=this.context.physics.engine)==null?void 0:i.sphereOverlap(n,e))??null}sphereOverlap(n,e,i=!0,s=!1,r=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const o=this.sphereMask;o.enableAll(),o.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,n,e,o,this.sphereResults,i,s,r);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(n,e=null){const i=e??this.defaultRaycastOptions;i.ray=n;const s=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),s}raycast(n=null){Gl&&performance.mark("raycast.start"),n||(n=this.defaultRaycastOptions);const e=n.screenPoint??this.context.input.mousePositionRC,i=n.raycaster??this.raycaster;if(i.near=n.minDistance??0,i.far=n.maxDistance??1/0,i.params=this.defaultThresholds,n.lineThreshold===void 0&&(n.lineThreshold=-1),i.params.Line={threshold:n.lineThreshold},n.ray)i.ray.copy(n.ray);else{const a=n.cam??this.context.mainCamera;if(!a)return Gl&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof x2&&l.cameras.length>0?i.setFromCamera(e,l.cameras[0]):i.setFromCamera(e,a)}let s=n.targets;s||(s=this.targetBuffer,s.length=1,s[0]=this.context.scene);let r=n.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),r||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),r=this.defaultRaycastOptions.results),n.layerMask!==void 0?n.layerMask instanceof Er?i.layers.mask=n.layerMask.mask:i.layers.mask=n.layerMask:(i.layers.enableAll(),i.layers.disable(2)),Gl&&(ft.DrawRay(i.ray.origin,i.ray.direction,16711680,2),console.time("raycast")),r.length=0,kk._raycasting++,this.intersect(this.raycaster,s,r,n),r.sort((a,l)=>a.distance-l.distance);const o=n.ignore;return o!==void 0&&o.length>0&&(r=r.filter(a=>!o.includes(a.object))),kk._raycasting--,Gl&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",r!=null&&r.length?[...r]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),r}intersect(n,e,i,s){var r,o,a;for(const l of e){if(!l||l.visible===!1||ft.isGizmo(l)||s.lineThreshold!==void 0&&s.lineThreshold<0&&l instanceof mn)continue;let c=!0;const h=l,d=h.geometry;if(s.testObject){const u=(r=s.testObject)==null?void 0:r.call(s,l);if(u===!1)continue;u==="continue in children"&&(c=!1)}if(c&&(d&&g4(d)||(c=!1)),c){const u=Ib(l);u&&(h.geometry=u);const m=i.length;let f=!0;s.precise===!1&&(f=!1),f||(f=((a=(o=d.getAttribute("position"))==null?void 0:o.array)==null?void 0:a.length)<64),h instanceof xg&&(f=!1),!f&&nme(h,n,i)||(s.useAcceleratedRaycast!==!1?QS.runMeshBVHRaycast(n,h,i,this.context):n.intersectObject(h,!1,i)),Gl&&i.length!=m&&ft.DrawWireMesh({mesh:l,depthTest:!1,duration:.2,color:u?8969557:7798784}),h.geometry=d}s.recursive!==!1&&this.intersect(n,l.children,i,s)}return i}intersectSphere(n,e,i,s,r,o,a,l){let c=n&&n.isMesh&&n.layers.test(s)&&!ft.isGizmo(n);c&&(c=n.visible),c&&(c=!(n instanceof mn)),c&&(c=!(n instanceof xg));const h=n,d=h.geometry;if(c&&l){const u=l(n);if(u===!1)return;u==="continue in children"&&(c=!1)}if(d&&g4(d)||(c=!1),c){if(a){const u=this.sphere;u.center.copy(e),u.radius=i;const m=r.length;if(QS.runMeshBVHRaycast(this.sphere,h,r,this.context),m!=r.length&&!o)return}else if(d.boundingBox||d.computeBoundingBox(),d.boundingBox){h.matrixWorldNeedsUpdate&&h.updateWorldMatrix(!1,!1);const u=this.tempBoundingBox.copy(d.boundingBox).applyMatrix4(h.matrixWorld),m=this.sphere;if(m.center.copy(e),m.radius=i,m.intersectsBox(u)){const f=Nt(n),g=f.distanceTo(m.center),v=new Pk(n,g,f);if(r.push(v),!o)return}}}if(n.children)for(const u of n.children){const m=r.length;if(this.intersectSphere(u,e,i,s,r,o,a,l),m!=r.length&&!o)return}}};let HS=kk;p(HS,"_raycasting",0);function g4(n){return!(n.index&&n.index.array.length<3)}const Sm=new tn,jS=new fs,ime=new Gt;function nme(n,e,i){const s=n._computeIntersections;if(!s)return!1;let r=n["_computeIntersections:Needle"];return r||(r=n["_computeIntersections:Needle"]=function(o,a,l){const c=this,h=c.geometry.boundingSphere;if(h){if(c instanceof xg){jS.setFromNormalAndCoplanarPoint(ht(0,1,0),ht(0,-c.position.y,0)),jS.applyMatrix4(c.matrixWorld,ime);const u=o.ray.intersectPlane(jS,ht());if(u){Sm.copy(h),Sm.applyMatrix4(c.matrixWorld);const m=ht(u).sub(o.ray.origin).length(),f=Sm.radius*.5;m<f&&a.push({distance:m,point:u,object:c,normal:jS.normal.clone()})}return}Sm.copy(h),Sm.applyMatrix4(c.matrixWorld);const d=o.ray.intersectSphere(Sm,ht());if(d){const u=ht(d).sub(o.ray.origin),m=u.length();if(m>Sm.radius){const f=u.clone().normalize();a.push({distance:m,point:d,object:c,normal:f})}}}}),n._computeIntersections=r,e.intersectObject(n,!1,i),n._computeIntersections=s,!0}var QS;(n=>{function e(b,A,x,w){var _,S,C;if(!A.geometry||!A.geometry.hasAttribute("position"))return!1;const R=A.geometry;if(A!=null&&A.isSkinnedMesh){const P=A,T=P.bvhNeedsUpdate;if(!P.staticGenerator)l(),o&&(P.staticGenerator=new o(A),P.staticGenerator.applyWorldTransforms=!1,P.staticGeometry=P.staticGenerator.generate(),R.boundsTree=a?.call(P.staticGeometry),P.staticGeometryLastUpdate=performance.now()+Math.random()*200,P.autoUpdateMeshBVH===void 0&&(P.autoUpdateMeshBVH=!1));else if(R.boundsTree&&(P.autoUpdateMeshBVH===!0||T===!0)){const L=performance.now(),k=L-P.staticGeometryLastUpdate;(T||k>100)&&(P.bvhNeedsUpdate=!1,P.staticGeometryLastUpdate=L,(_=P.staticGenerator)==null||_.generate(P.staticGeometry),R.boundsTree.refit())}}else if(!R.boundsTree){h||y();let P=!0;if((w.xr||R[f]===!1||(S=R.getAttribute("position"))!=null&&S.isInterleavedBufferAttribute||R.index&&(C=R.index)!=null&&C.isInterleavedBufferAttribute)&&(P=!1),P&&u){if(R[m]===void 0){let T=null;if(v.length>0){const L=v.shift();L&&!L.running&&(T=L)}if(!T&&g.length<3&&(T=new u,g.push(T)),T!=null&&!T.running){Gl&&console.log("<<<< worker start",T),R[m]="queued",performance.mark("bvh.create.start");const L=R.clone();T.generate(L).then(k=>{R[m]="done",R.boundsTree=k}).catch(k=>{R[m]="failed - "+k?.message,R[f]=!1}).finally(()=>{Gl&&console.log(">>>>> worker done"),v.push(T),L.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}else Gl&&console.warn("No worker available")}}else(!d||!P)&&(l(),r&&(performance.mark("bvh.create.start"),R.boundsTree=new r(R),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(b instanceof Hd){const P=b,T=A.raycast;s&&R.boundsTree?(A.acceleratedRaycast||(A.acceleratedRaycast=s.bind(A)),A.raycast=A.acceleratedRaycast):Gl&&console.warn("No bounds tree found for mesh",A.name);const L=P.firstHitOnly;return P.firstHitOnly=!1,P.intersectObject(A,!1,x),P.firstHitOnly=L,A.raycast=T,!0}else if(b instanceof tn){const P=R.boundsTree;if(P){const T=b;if(c.copy(A.matrixWorld).invert(),T.applyMatrix4(c),P.intersectsSphere(T)){const L=Nt(A),k=L.distanceTo(T.center),G=new Pk(A,k,L);x.push(G)}}return!0}return!1}n.runMeshBVHRaycast=e;let i=!1,s=null,r=null,o=null,a=null;function l(){i||(i=!0,Promise.resolve().then(()=>_Me).then(b=>{s=b.acceleratedRaycast,r=b.MeshBVH,o=b.StaticGeometryGenerator,a=b.computeBoundsTree}).catch(b=>{(Gl||je())&&console.warn("Failed to load mesh bvh library")}))}const c=new he;let h=!1,d=!1,u=null;const m=Symbol("Needle:MeshBVH-Worker"),f=Symbol("Needle:MeshBVH-CanUseWorker"),g=[],v=[];function y(){h=!0,d=!0,Promise.resolve().then(()=>EMe).then(b=>{u=b.GenerateMeshBVHWorker}).catch(b=>{(Gl||je())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{d=!1})}})(QS||(QS={}));const y4=Symbol("gltf-loader-internal-usage-tracker"),sme=te("debugusers"),ZS=class{constructor(n){p(this,"parser"),p(this,"_getDependency"),p(this,"_loadingId"),p(this,"_loadedObjects",new Set),this.parser=n,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(n){return ZS._loadingProcesses>0}beforeRoot(){ZS._loadingProcesses++;const n=this,e=this._getDependency;return this.parser.getDependency=function(i,s){const r=e.call(this,i,s);return r.then(o=>(o&&(n._loadedObjects.add(o),o[y4]=n._loadingId),o)),r},null}afterRoot(n){ZS._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[y4],e instanceof ge&&(e.parent||e instanceof ue&&setTimeout(()=>{sme&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null},1e3));return null}};let Bk=ZS;p(Bk,"_loadingProcesses",0);class v4{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const s=(i=e?.reason)==null?void 0:i.path;if(s){const r=s[0];r&&r.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4965
|
-
`+r.src),e.preventDefault())}})}}const YS=te("trackresources");function
|
|
4963
|
+
`)l=0,c-=o;else{const u=dpe(d,r,l,c,i);l+=u.offsetX,a.push(u.path)}}return a}function dpe(n,e,i,s,r){const o=r.glyphs[n]||r.glyphs["?"];if(!o){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const a=new sU;let l,c,h,d,u,m,f,g;if(o.o){const v=o._cachedOutline||(o._cachedOutline=o.o.split(" "));for(let y=0,b=v.length;y<b;)switch(v[y++]){case"m":l=v[y++]*e+i,c=v[y++]*e+s,a.moveTo(l,c);break;case"l":l=v[y++]*e+i,c=v[y++]*e+s,a.lineTo(l,c);break;case"q":h=v[y++]*e+i,d=v[y++]*e+s,u=v[y++]*e+i,m=v[y++]*e+s,a.quadraticCurveTo(u,m,h,d);break;case"b":h=v[y++]*e+i,d=v[y++]*e+s,u=v[y++]*e+i,m=v[y++]*e+s,f=v[y++]*e+i,g=v[y++]*e+s,a.bezierCurveTo(u,m,f,g,h,d);break}}return{offsetX:o.ha*e,path:a}}function upe(n,e=1e-4){e=Math.max(e,Number.EPSILON);const i={},s=n.getIndex(),r=n.getAttribute("position"),o=s?s.count:r.count;let a=0;const l=Object.keys(n.attributes),c={},h={},d=[],u=["getX","getY","getZ","getW"],m=["setX","setY","setZ","setW"];for(let A=0,x=l.length;A<x;A++){const w=l[A],_=n.attributes[w];c[w]=new $e(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized);const S=n.morphAttributes[w];S&&(h[w]=new $e(new S.array.constructor(S.count*S.itemSize),S.itemSize,S.normalized))}const f=e*.5,g=Math.log10(1/e),v=Math.pow(10,g),y=f*v;for(let A=0;A<o;A++){const x=s?s.getX(A):A;let w="";for(let _=0,S=l.length;_<S;_++){const C=l[_],R=n.getAttribute(C),P=R.itemSize;for(let T=0;T<P;T++)w+=`${~~(R[u[T]](x)*v+y)},`}if(w in i)d.push(i[w]);else{for(let _=0,S=l.length;_<S;_++){const C=l[_],R=n.getAttribute(C),P=n.morphAttributes[C],T=R.itemSize,L=c[C],k=h[C];for(let G=0;G<T;G++){const O=u[G],W=m[G];if(L[W](a,R[O](x)),P)for(let D=0,F=P.length;D<F;D++)k[D][W](a,P[D][O](x))}}i[w]=a,d.push(a),a++}}const b=n.clone();for(const A in n.attributes){const x=c[A];if(b.setAttribute(A,new $e(x.array.slice(0,a*x.itemSize),x.itemSize,x.normalized)),A in h)for(let w=0;w<h[A].length;w++){const _=h[A][w];b.morphAttributes[A][w]=new $e(_.array.slice(0,a*_.itemSize),_.itemSize,_.normalized)}}return b.setIndex(d),b}function qH(n,e){if(e===hN)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===j1||e===OR){let i=n.getIndex();if(i===null){const a=[],l=n.getAttribute("position");if(l!==void 0){for(let c=0;c<l.count;c++)a.push(c);n.setIndex(a),i=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const s=i.count-2,r=[];if(e===j1)for(let a=1;a<=s;a++)r.push(i.getX(0)),r.push(i.getX(a)),r.push(i.getX(a+1));else for(let a=0;a<s;a++)a%2===0?(r.push(i.getX(a)),r.push(i.getX(a+1)),r.push(i.getX(a+2))):(r.push(i.getX(a+2)),r.push(i.getX(a+1)),r.push(i.getX(a)));r.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=n.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class zh extends is{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(i){return new ype(i)}),this.register(function(i){return new Mpe(i)}),this.register(function(i){return new Epe(i)}),this.register(function(i){return new Tpe(i)}),this.register(function(i){return new bpe(i)}),this.register(function(i){return new Ape(i)}),this.register(function(i){return new xpe(i)}),this.register(function(i){return new wpe(i)}),this.register(function(i){return new gpe(i)}),this.register(function(i){return new _pe(i)}),this.register(function(i){return new vpe(i)}),this.register(function(i){return new Cpe(i)}),this.register(function(i){return new Spe(i)}),this.register(function(i){return new mpe(i)}),this.register(function(i){return new Rpe(i)}),this.register(function(i){return new Ipe(i)})}load(e,i,s,r){const o=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const h=wh.extractUrlBase(e);a=wh.resolveURL(h,this.path)}else a=wh.extractUrlBase(e);this.manager.itemStart(e);const l=function(h){r?r(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},c=new Js(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{o.parse(h,a,function(d){i(d),o.manager.itemEnd(e)},l)}catch(d){l(d)}},s,l)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,i,s,r){let o;const a={},l={},c=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===$H){try{a[fi.KHR_BINARY_GLTF]=new Lpe(e)}catch(d){r&&r(d);return}o=JSON.parse(a[fi.KHR_BINARY_GLTF].content)}else o=JSON.parse(c.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new Wpe(o,{path:i||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const u=this.pluginCallbacks[d](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[u.name]=u,a[u.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const u=o.extensionsUsed[d],m=o.extensionsRequired||[];switch(u){case fi.KHR_MATERIALS_UNLIT:a[u]=new fpe;break;case fi.KHR_DRACO_MESH_COMPRESSION:a[u]=new Ppe(o,this.dracoLoader);break;case fi.KHR_TEXTURE_TRANSFORM:a[u]=new kpe;break;case fi.KHR_MESH_QUANTIZATION:a[u]=new Bpe;break;default:m.indexOf(u)>=0&&l[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}h.setExtensions(a),h.setPlugins(l),h.parse(s,r)}parseAsync(e,i){const s=this;return new Promise(function(r,o){s.parse(e,i,r,o)})}}function ppe(){let n={};return{get:function(e){return n[e]},add:function(e,i){n[e]=i},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const fi={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class mpe{constructor(e){this.parser=e,this.name=fi.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,i=this.parser.json.nodes||[];for(let s=0,r=i.length;s<r;s++){const o=i[s];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const i=this.parser,s="light:"+e;let r=i.cache.get(s);if(r)return r;const o=i.json,a=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let l;const c=new Ae(16777215);a.color!==void 0&&c.setRGB(a.color[0],a.color[1],a.color[2],ki);const h=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new Yp(c),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Zp(c),l.distance=h;break;case"spot":l=new Nv(c),l.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,l.angle=a.spot.outerConeAngle,l.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return l.position.set(0,0,0),l.decay=2,yu(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=i.createUniqueName(a.name||"light_"+e),r=Promise.resolve(l),i.cache.add(s,r),r}getDependency(e,i){if(e==="light")return this._loadLight(i)}createNodeAttachment(e){const i=this,s=this.parser,r=s.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return s._getNodeRef(i.cache,o,a)})}}let fpe=class{constructor(){this.name=fi.KHR_MATERIALS_UNLIT}getMaterialType(){return Ht}extendParams(n,e,i){const s=[];n.color=new Ae(1,1,1),n.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;n.color.setRGB(o[0],o[1],o[2],ki),n.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(i.assignTexture(n,"map",r.baseColorTexture,vt))}return Promise.all(s)}},gpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(n,e){const i=this.parser.json.materials[n];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}},ype=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_CLEARCOAT}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(e.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(i.assignTexture(e,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new K(a,a)}return Promise.all(r)}},vpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_IRIDESCENCE}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(e.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(e.iridescenceIOR=o.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(i.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},bpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_SHEEN}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new Ae(0,0,0),e.sheenRoughness=0,e.sheen=1;const o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],ki)}return o.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(i.assignTexture(e,"sheenColorMap",o.sheenColorTexture,vt)),o.sheenRoughnessTexture!==void 0&&r.push(i.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},Ape=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_TRANSMISSION}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(e.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(i.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},xpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_VOLUME}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];e.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(i.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return e.attenuationColor=new Ae().setRGB(a[0],a[1],a[2],ki),Promise.all(r)}},wpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_IOR}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser.json.materials[n];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},_pe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_SPECULAR}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];e.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(i.assignTexture(e,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return e.specularColor=new Ae().setRGB(a[0],a[1],a[2],ki),o.specularColorTexture!==void 0&&r.push(i.assignTexture(e,"specularColorMap",o.specularColorTexture,vt)),Promise.all(r)}},Spe=class{constructor(n){this.parser=n,this.name=fi.EXT_MATERIALS_BUMP}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return e.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(i.assignTexture(e,"bumpMap",o.bumpTexture)),Promise.all(r)}},Cpe=class{constructor(n){this.parser=n,this.name=fi.KHR_MATERIALS_ANISOTROPY}getMaterialType(n){const e=this.parser.json.materials[n];return!e.extensions||!e.extensions[this.name]?null:To}extendMaterialParams(n,e){const i=this.parser,s=i.json.materials[n];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(e.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(e.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(i.assignTexture(e,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}};class Mpe{constructor(e){this.parser=e,this.name=fi.KHR_TEXTURE_BASISU}loadTexture(e){const i=this.parser,s=i.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],a=i.options.ktx2Loader;if(!a){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return i.loadTextureImage(e,o.source,a)}}class Epe{constructor(e){this.parser=e,this.name=fi.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const i=this.name,s=this.parser,r=s.json,o=r.textures[e];if(!o.extensions||!o.extensions[i])return null;const a=o.extensions[i],l=r.images[a.source];let c=s.textureLoader;if(l.uri){const h=s.options.manager.getHandler(l.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,a.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(i)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const i=new Image;i.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",i.onload=i.onerror=function(){e(i.height===1)}})),this.isSupported}}class Tpe{constructor(e){this.parser=e,this.name=fi.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const i=this.name,s=this.parser,r=s.json,o=r.textures[e];if(!o.extensions||!o.extensions[i])return null;const a=o.extensions[i],l=r.images[a.source];let c=s.textureLoader;if(l.uri){const h=s.options.manager.getHandler(l.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return s.loadTextureImage(e,a.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(i)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const i=new Image;i.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",i.onload=i.onerror=function(){e(i.height===1)}})),this.isSupported}}class Rpe{constructor(e){this.name=fi.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const i=this.parser.json,s=i.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const r=s.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(l){const c=r.byteOffset||0,h=r.byteLength||0,d=r.count,u=r.byteStride,m=new Uint8Array(l,c,h);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(d,u,m,r.mode,r.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(d*u);return a.decodeGltfBuffer(new Uint8Array(f),d,u,m,r.mode,r.filter),f})})}else return null}}let Ipe=class{constructor(n){this.name=fi.EXT_MESH_GPU_INSTANCING,this.parser=n}createNodeMesh(n){const e=this.parser.json,i=e.nodes[n];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const s=e.meshes[i.mesh];for(const l of s.primitives)if(l.mode!==Xa.TRIANGLES&&l.mode!==Xa.TRIANGLE_STRIP&&l.mode!==Xa.TRIANGLE_FAN&&l.mode!==void 0)return null;const r=i.extensions[this.name].attributes,o=[],a={};for(const l in r)o.push(this.parser.getDependency("accessor",r[l]).then(c=>(a[l]=c,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(n)),Promise.all(o).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,u=[];for(const m of h){const f=new he,g=new M,v=new Se,y=new M(1,1,1),b=new T2(m.geometry,m.material,d);for(let A=0;A<d;A++)a.TRANSLATION&&g.fromBufferAttribute(a.TRANSLATION,A),a.ROTATION&&v.fromBufferAttribute(a.ROTATION,A),a.SCALE&&y.fromBufferAttribute(a.SCALE,A),b.setMatrixAt(A,f.compose(g,v,y));for(const A in a)if(A==="_COLOR_0"){const x=a[A];b.instanceColor=new Eo(x.array,x.itemSize,x.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,a[A]);ge.prototype.copy.call(b,m),this.parser.assignFinalMaterial(b),u.push(b)}return c.isGroup?(c.clear(),c.add(...u),c):u[0]}))}};const $H="glTF",Wb=12,e9={JSON:1313821514,BIN:5130562};class Lpe{constructor(e){this.name=fi.KHR_BINARY_GLTF,this.content=null,this.body=null;const i=new DataView(e,0,Wb),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:i.getUint32(4,!0),length:i.getUint32(8,!0)},this.header.magic!==$H)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Wb,o=new DataView(e,Wb);let a=0;for(;a<r;){const l=o.getUint32(a,!0);a+=4;const c=o.getUint32(a,!0);if(a+=4,c===e9.JSON){const h=new Uint8Array(e,Wb+a,l);this.content=s.decode(h)}else if(c===e9.BIN){const h=Wb+a;this.body=e.slice(h,h+l)}a+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ppe{constructor(e,i){if(!i)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=fi.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=i,this.dracoLoader.preload()}decodePrimitive(e,i){const s=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,l={},c={},h={};for(const d in a){const u=bk[d]||d.toLowerCase();l[u]=a[d]}for(const d in e.attributes){const u=bk[d]||d.toLowerCase();if(a[d]!==void 0){const m=s.accessors[e.attributes[d]],f=o0[m.componentType];h[u]=f.name,c[u]=m.normalized===!0}}return i.getDependency("bufferView",o).then(function(d){return new Promise(function(u,m){r.decodeDracoFile(d,function(f){for(const g in f.attributes){const v=f.attributes[g],y=c[g];y!==void 0&&(v.normalized=y)}u(f)},l,h,ki,m)})})}}class kpe{constructor(){this.name=fi.KHR_TEXTURE_TRANSFORM}extendTexture(e,i){return(i.texCoord===void 0||i.texCoord===e.channel)&&i.offset===void 0&&i.rotation===void 0&&i.scale===void 0||(e=e.clone(),i.texCoord!==void 0&&(e.channel=i.texCoord),i.offset!==void 0&&e.offset.fromArray(i.offset),i.rotation!==void 0&&(e.rotation=i.rotation),i.scale!==void 0&&e.repeat.fromArray(i.scale),e.needsUpdate=!0),e}}class Bpe{constructor(){this.name=fi.KHR_MESH_QUANTIZATION}}class t9 extends yg{constructor(e,i,s,r){super(e,i,s,r)}copySampleValue_(e){const i=this.resultBuffer,s=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let a=0;a!==r;a++)i[a]=s[o+a];return i}interpolate_(e,i,s,r){const o=this.resultBuffer,a=this.sampleValues,l=this.valueSize,c=l*2,h=l*3,d=r-i,u=(s-i)/d,m=u*u,f=m*u,g=e*h,v=g-h,y=-2*f+3*m,b=f-m,A=1-y,x=b-m+u;for(let w=0;w!==l;w++){const _=a[v+w+l],S=a[v+w+c]*d,C=a[g+w+l],R=a[g+w]*d;o[w]=A*_+x*S+y*C+b*R}return o}}const Ope=new Se;class Dpe extends t9{interpolate_(e,i,s,r){const o=super.interpolate_(e,i,s,r);return Ope.fromArray(o).normalize().toArray(o),o}}const Xa={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},o0={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},i9={9728:Ot,9729:Dt,9984:Df,9985:Mp,9986:ch,9987:_o},n9={33071:es,33648:lh,10497:wo},vk={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bk={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},gu={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gpe={CUBICSPLINE:void 0,LINEAR:sc,STEP:Ld},Ak={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Npe(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new vs({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Vn})),n.DefaultMaterial}function wm(n,e,i){for(const s in i.extensions)n[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=i.extensions[s])}function yu(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Fpe(n,e,i){let s=!1,r=!1,o=!1;for(let h=0,d=e.length;h<d;h++){const u=e[h];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(r=!0),u.COLOR_0!==void 0&&(o=!0),s&&r&&o)break}if(!s&&!r&&!o)return Promise.resolve(n);const a=[],l=[],c=[];for(let h=0,d=e.length;h<d;h++){const u=e[h];if(s){const m=u.POSITION!==void 0?i.getDependency("accessor",u.POSITION):n.attributes.position;a.push(m)}if(r){const m=u.NORMAL!==void 0?i.getDependency("accessor",u.NORMAL):n.attributes.normal;l.push(m)}if(o){const m=u.COLOR_0!==void 0?i.getDependency("accessor",u.COLOR_0):n.attributes.color;c.push(m)}}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c)]).then(function(h){const d=h[0],u=h[1],m=h[2];return s&&(n.morphAttributes.position=d),r&&(n.morphAttributes.normal=u),o&&(n.morphAttributes.color=m),n.morphTargetsRelative=!0,n})}function zpe(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let i=0,s=e.weights.length;i<s;i++)n.morphTargetInfluences[i]=e.weights[i];if(e.extras&&Array.isArray(e.extras.targetNames)){const i=e.extras.targetNames;if(n.morphTargetInfluences.length===i.length){n.morphTargetDictionary={};for(let s=0,r=i.length;s<r;s++)n.morphTargetDictionary[i[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Upe(n){let e;const i=n.extensions&&n.extensions[fi.KHR_DRACO_MESH_COMPRESSION];if(i?e="draco:"+i.bufferView+":"+i.indices+":"+xk(i.attributes):e=n.indices+":"+xk(n.attributes)+":"+n.mode,n.targets!==void 0)for(let s=0,r=n.targets.length;s<r;s++)e+=":"+xk(n.targets[s]);return e}function xk(n){let e="";const i=Object.keys(n).sort();for(let s=0,r=i.length;s<r;s++)e+=i[s]+":"+n[i[s]]+";";return e}function wk(n){switch(n){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Vpe(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Xpe=new he;class Wpe{constructor(e={},i={}){this.json=e,this.extensions={},this.plugins={},this.options=i,this.cache=new ppe,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=!1,o=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||r&&o<98?this.textureLoader=new lc(this.options.manager):this.textureLoader=new Bz(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Js(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,i){const s=this,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(a){const l={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:s,userData:{}};return wm(o,l,r),yu(l,r),Promise.all(s._invokeAll(function(c){return c.afterRoot&&c.afterRoot(l)})).then(function(){e(l)})}).catch(i)}_markDefs(){const e=this.json.nodes||[],i=this.json.skins||[],s=this.json.meshes||[];for(let r=0,o=i.length;r<o;r++){const a=i[r].joints;for(let l=0,c=a.length;l<c;l++)e[a[l]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(s[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,i){i!==void 0&&(e.refs[i]===void 0&&(e.refs[i]=e.uses[i]=0),e.refs[i]++)}_getNodeRef(e,i,s){if(e.refs[i]<=1)return s;const r=s.clone(),o=(a,l)=>{const c=this.associations.get(a);c!=null&&this.associations.set(l,c);for(const[h,d]of a.children.entries())o(d,l.children[h])};return o(s,r),r.name+="_instance_"+e.uses[i]++,r}_invokeOne(e){const i=Object.values(this.plugins);i.push(this);for(let s=0;s<i.length;s++){const r=e(i[s]);if(r)return r}return null}_invokeAll(e){const i=Object.values(this.plugins);i.unshift(this);const s=[];for(let r=0;r<i.length;r++){const o=e(i[r]);o&&s.push(o)}return s}getDependency(e,i){const s=e+":"+i;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(i);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(i)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(i)});break;case"accessor":r=this.loadAccessor(i);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(i)});break;case"buffer":r=this.loadBuffer(i);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(i)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(i)});break;case"skin":r=this.loadSkin(i);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(i)});break;case"camera":r=this.loadCamera(i);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,i)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(s,r)}return r}getDependencies(e){let i=this.cache.get(e);if(!i){const s=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];i=Promise.all(r.map(function(o,a){return s.getDependency(e,a)})),this.cache.add(e,i)}return i}loadBuffer(e){const i=this.json.buffers[e],s=this.fileLoader;if(i.type&&i.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+i.type+" buffer type is not supported.");if(i.uri===void 0&&e===0)return Promise.resolve(this.extensions[fi.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,a){s.load(wh.resolveURL(i.uri,r.path),o,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+i.uri+'".'))})})}loadBufferView(e){const i=this.json.bufferViews[e];return this.getDependency("buffer",i.buffer).then(function(s){const r=i.byteLength||0,o=i.byteOffset||0;return s.slice(o,o+r)})}loadAccessor(e){const i=this,s=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=vk[r.type],l=o0[r.componentType],c=r.normalized===!0,h=new l(r.count*a);return Promise.resolve(new $e(h,a,c))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(a){const l=a[0],c=vk[r.type],h=o0[r.componentType],d=h.BYTES_PER_ELEMENT,u=d*c,m=r.byteOffset||0,f=r.bufferView!==void 0?s.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0;let v,y;if(f&&f!==u){const b=Math.floor(m/f),A="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+b+":"+r.count;let x=i.cache.get(A);x||(v=new h(l,b*f,r.count*f/d),x=new _v(v,f/d),i.cache.add(A,x)),y=new Qo(x,c,m%f/d,g)}else l===null?v=new h(r.count*c):v=new h(l,m,r.count*c),y=new $e(v,c,g);if(r.sparse!==void 0){const b=vk.SCALAR,A=o0[r.sparse.indices.componentType],x=r.sparse.indices.byteOffset||0,w=r.sparse.values.byteOffset||0,_=new A(a[1],x,r.sparse.count*b),S=new h(a[2],w,r.sparse.count*c);l!==null&&(y=new $e(y.array.slice(),y.itemSize,y.normalized));for(let C=0,R=_.length;C<R;C++){const P=_[C];if(y.setX(P,S[C*c]),c>=2&&y.setY(P,S[C*c+1]),c>=3&&y.setZ(P,S[C*c+2]),c>=4&&y.setW(P,S[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const i=this.json,s=this.options,r=i.textures[e].source,o=i.images[r];let a=this.textureLoader;if(o.uri){const l=s.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,i,s){const r=this,o=this.json,a=o.textures[e],l=o.images[i],c=(l.uri||l.bufferView)+":"+a.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(i,s).then(function(d){d.flipY=!1,d.name=a.name||l.name||"",d.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(d.name=l.uri);const u=(o.samplers||{})[a.sampler]||{};return d.magFilter=i9[u.magFilter]||Dt,d.minFilter=i9[u.minFilter]||_o,d.wrapS=n9[u.wrapS]||wo,d.wrapT=n9[u.wrapT]||wo,d.anisotropy=4,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,i){const s=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const a=r.images[e],l=self.URL||self.webkitURL;let c=a.uri||"",h=!1;if(a.bufferView!==void 0)c=s.getDependency("bufferView",a.bufferView).then(function(u){h=!0;const m=new Blob([u],{type:a.mimeType});return c=l.createObjectURL(m),c});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then(function(u){return new Promise(function(m,f){let g=m;i.isImageBitmapLoader===!0&&(g=function(v){const y=new Vt(v);y.needsUpdate=!0,m(y)}),i.load(wh.resolveURL(u,o.path),g,void 0,f)})}).then(function(u){return h===!0&&l.revokeObjectURL(c),u.userData.mimeType=a.mimeType||Vpe(a.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=d,d}assignTexture(e,i,s,r){const o=this;return this.getDependency("texture",s.index).then(function(a){if(!a)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(a=a.clone(),a.channel=s.texCoord),o.extensions[fi.KHR_TEXTURE_TRANSFORM]){const l=s.extensions!==void 0?s.extensions[fi.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const c=o.associations.get(a);a=o.extensions[fi.KHR_TEXTURE_TRANSFORM].extendTexture(a,l),o.associations.set(a,c)}}return r!==void 0&&(a.colorSpace=r),e[i]=a,a})}assignFinalMaterial(e){const i=e.geometry;let s=e.material;const r=i.attributes.tangent===void 0,o=i.attributes.color!==void 0,a=i.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new Ud,Ft.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,c.sizeAttenuation=!1,this.cache.add(l,c)),s=c}else if(e.isLine){const l="LineBasicMaterial:"+s.uuid;let c=this.cache.get(l);c||(c=new Vi,Ft.prototype.copy.call(c,s),c.color.copy(s.color),c.map=s.map,this.cache.add(l,c)),s=c}if(r||o||a){let l="ClonedMaterial:"+s.uuid+":";r&&(l+="derivative-tangents:"),o&&(l+="vertex-colors:"),a&&(l+="flat-shading:");let c=this.cache.get(l);c||(c=s.clone(),o&&(c.vertexColors=!0),a&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(l,c),this.associations.set(c,this.associations.get(s))),s=c}e.material=s}getMaterialType(){return vs}loadMaterial(e){const i=this,s=this.json,r=this.extensions,o=s.materials[e];let a;const l={},c=o.extensions||{},h=[];if(c[fi.KHR_MATERIALS_UNLIT]){const u=r[fi.KHR_MATERIALS_UNLIT];a=u.getMaterialType(),h.push(u.extendParams(l,o,i))}else{const u=o.pbrMetallicRoughness||{};if(l.color=new Ae(1,1,1),l.opacity=1,Array.isArray(u.baseColorFactor)){const m=u.baseColorFactor;l.color.setRGB(m[0],m[1],m[2],ki),l.opacity=m[3]}u.baseColorTexture!==void 0&&h.push(i.assignTexture(l,"map",u.baseColorTexture,vt)),l.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,l.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(i.assignTexture(l,"metalnessMap",u.metallicRoughnessTexture)),h.push(i.assignTexture(l,"roughnessMap",u.metallicRoughnessTexture))),a=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,l)})))}o.doubleSided===!0&&(l.side=Ai);const d=o.alphaMode||Ak.OPAQUE;if(d===Ak.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,d===Ak.MASK&&(l.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&a!==Ht&&(h.push(i.assignTexture(l,"normalMap",o.normalTexture)),l.normalScale=new K(1,1),o.normalTexture.scale!==void 0)){const u=o.normalTexture.scale;l.normalScale.set(u,u)}if(o.occlusionTexture!==void 0&&a!==Ht&&(h.push(i.assignTexture(l,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&a!==Ht){const u=o.emissiveFactor;l.emissive=new Ae().setRGB(u[0],u[1],u[2],ki)}return o.emissiveTexture!==void 0&&a!==Ht&&h.push(i.assignTexture(l,"emissiveMap",o.emissiveTexture,vt)),Promise.all(h).then(function(){const u=new a(l);return o.name&&(u.name=o.name),yu(u,o),i.associations.set(u,{materials:e}),o.extensions&&wm(r,u,o),u})}createUniqueName(e){const i=Zt.sanitizeNodeName(e||"");return i in this.nodeNamesUsed?i+"_"+ ++this.nodeNamesUsed[i]:(this.nodeNamesUsed[i]=0,i)}loadGeometries(e){const i=this,s=this.extensions,r=this.primitiveCache;function o(l){return s[fi.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,i).then(function(c){return s9(c,l,i)})}const a=[];for(let l=0,c=e.length;l<c;l++){const h=e[l],d=Upe(h),u=r[d];if(u)a.push(u.promise);else{let m;h.extensions&&h.extensions[fi.KHR_DRACO_MESH_COMPRESSION]?m=o(h):m=s9(new pt,h,i),r[d]={primitive:h,promise:m},a.push(m)}}return Promise.all(a)}loadMesh(e){const i=this,s=this.json,r=this.extensions,o=s.meshes[e],a=o.primitives,l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c].material===void 0?Npe(this.cache):this.getDependency("material",a[c].material);l.push(d)}return l.push(i.loadGeometries(a)),Promise.all(l).then(function(c){const h=c.slice(0,c.length-1),d=c[c.length-1],u=[];for(let f=0,g=d.length;f<g;f++){const v=d[f],y=a[f];let b;const A=h[f];if(y.mode===Xa.TRIANGLES||y.mode===Xa.TRIANGLE_STRIP||y.mode===Xa.TRIANGLE_FAN||y.mode===void 0)b=o.isSkinnedMesh===!0?new Mo(v,A):new ue(v,A),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),y.mode===Xa.TRIANGLE_STRIP?b.geometry=qH(b.geometry,OR):y.mode===Xa.TRIANGLE_FAN&&(b.geometry=qH(b.geometry,j1));else if(y.mode===Xa.LINES)b=new Lr(v,A);else if(y.mode===Xa.LINE_STRIP)b=new mn(v,A);else if(y.mode===Xa.LINE_LOOP)b=new P2(v,A);else if(y.mode===Xa.POINTS)b=new mg(v,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(b.geometry.morphAttributes).length>0&&zpe(b,o),b.name=i.createUniqueName(o.name||"mesh_"+e),yu(b,o),y.extensions&&wm(r,b,y),i.assignFinalMaterial(b),u.push(b)}for(let f=0,g=u.length;f<g;f++)i.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return o.extensions&&wm(r,u[0],o),u[0];const m=new Xn;o.extensions&&wm(r,m,o),i.associations.set(m,{meshes:e});for(let f=0,g=u.length;f<g;f++)m.add(u[f]);return m})}loadCamera(e){let i;const s=this.json.cameras[e],r=s[s.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?i=new Lt(oi.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):s.type==="orthographic"&&(i=new oc(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(i.name=this.createUniqueName(s.name)),yu(i,s),Promise.resolve(i)}loadSkin(e){const i=this.json.skins[e],s=[];for(let r=0,o=i.joints.length;r<o;r++)s.push(this._loadNodeShallow(i.joints[r]));return i.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",i.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(r){const o=r.pop(),a=r,l=[],c=[];for(let h=0,d=a.length;h<d;h++){const u=a[h];if(u){l.push(u);const m=new he;o!==null&&m.fromArray(o.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',i.joints[h])}return new Ev(l,c)})}loadAnimation(e){const i=this.json,s=this,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],l=[],c=[],h=[],d=[];let u=0,m=r.channels.length;for(u=0,m=r.channels.length;u<m;u++){const f=r.channels[u],g=r.samplers[f.sampler],v=f.target,y=v.node,b=r.parameters!==void 0?r.parameters[g.input]:g.input,A=r.parameters!==void 0?r.parameters[g.output]:g.output;v.node!==void 0&&(a.push(this.getDependency("node",y)),l.push(this.getDependency("accessor",b)),c.push(this.getDependency("accessor",A)),h.push(g),d.push(v))}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d)]).then(function(f){const g=f[0],v=f[1],y=f[2],b=f[3],A=f[4],x=[];for(u=0,m=g.length;u<m;u++){const w=g[u],_=v[u],S=y[u],C=b[u],R=A[u];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const P=s._createAnimationTracks(w,_,S,C,R);if(P)for(let T=0;T<P.length;T++)x.push(P[T])}return new to(o,void 0,x)})}createNodeMesh(e){const i=this.json,s=this,r=i.nodes[e];return r.mesh===void 0?null:s.getDependency("mesh",r.mesh).then(function(o){const a=s._getNodeRef(s.meshCache,r.mesh,o);return r.weights!==void 0&&a.traverse(function(l){if(l.isMesh)for(let c=0,h=r.weights.length;c<h;c++)l.morphTargetInfluences[c]=r.weights[c]}),a})}loadNode(e){const i=this.json,s=this,r=i.nodes[e],o=s._loadNodeShallow(e),a=[],l=r.children||[];for(let h=0,d=l.length;h<d;h++)a.push(s.getDependency("node",l[h]));const c=r.skin===void 0?Promise.resolve(null):s.getDependency("skin",r.skin);return Promise.all([o,Promise.all(a),c]).then(function(h){const d=h[0],u=h[1],m=h[2];m!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(m,Xpe)});for(let f=0,g=u.length;f<g;f++)d.add(u[f]);return d})}_loadNodeShallow(e){const i=this.json,s=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=i.nodes[e],a=o.name?r.createUniqueName(o.name):"",l=[],c=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&l.push(c),o.camera!==void 0&&l.push(r.getDependency("camera",o.camera).then(function(h){return r._getNodeRef(r.cameraCache,o.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){l.push(h)}),this.nodeCache[e]=Promise.all(l).then(function(h){let d;if(o.isBone===!0?d=new Vp:h.length>1?d=new Xn:h.length===1?d=h[0]:d=new ge,d!==h[0])for(let u=0,m=h.length;u<m;u++)d.add(h[u]);if(o.name&&(d.userData.name=o.name,d.name=a),yu(d,o),o.extensions&&wm(s,d,o),o.matrix!==void 0){const u=new he;u.fromArray(o.matrix),d.applyMatrix4(u)}else o.translation!==void 0&&d.position.fromArray(o.translation),o.rotation!==void 0&&d.quaternion.fromArray(o.rotation),o.scale!==void 0&&d.scale.fromArray(o.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const i=this.extensions,s=this.json.scenes[e],r=this,o=new Xn;s.name&&(o.name=r.createUniqueName(s.name)),yu(o,s),s.extensions&&wm(i,o,s);const a=s.nodes||[],l=[];for(let c=0,h=a.length;c<h;c++)l.push(r.getDependency("node",a[c]));return Promise.all(l).then(function(c){for(let d=0,u=c.length;d<u;d++)o.add(c[d]);const h=d=>{const u=new Map;for(const[m,f]of r.associations)(m instanceof Ft||m instanceof Vt)&&u.set(m,f);return d.traverse(m=>{const f=r.associations.get(m);f!=null&&u.set(m,f)}),u};return r.associations=h(o),o})}_createAnimationTracks(e,i,s,r,o){const a=[],l=e.name?e.name:e.uuid,c=[];gu[o.path]===gu.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(l);let h;switch(gu[o.path]){case gu.weights:h=bh;break;case gu.rotation:h=yl;break;case gu.position:case gu.scale:h=ac;break;default:switch(s.itemSize){case 1:h=bh;break;case 2:case 3:default:h=ac;break}break}const d=r.interpolation!==void 0?Gpe[r.interpolation]:sc,u=this._getArrayFromAccessor(s);for(let m=0,f=c.length;m<f;m++){const g=new h(c[m]+"."+gu[o.path],i.array,u,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),a.push(g)}return a}_getArrayFromAccessor(e){let i=e.array;if(e.normalized){const s=wk(i.constructor),r=new Float32Array(i.length);for(let o=0,a=i.length;o<a;o++)r[o]=i[o]*s;i=r}return i}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(i){const s=this instanceof yl?Dpe:t9;return new s(this.times,this.values,this.getValueSize()/3,i)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Hpe(n,e,i){const s=e.attributes,r=new Wt;if(s.POSITION!==void 0){const l=i.json.accessors[s.POSITION],c=l.min,h=l.max;if(c!==void 0&&h!==void 0){if(r.set(new M(c[0],c[1],c[2]),new M(h[0],h[1],h[2])),l.normalized){const d=wk(o0[l.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const l=new M,c=new M;for(let h=0,d=o.length;h<d;h++){const u=o[h];if(u.POSITION!==void 0){const m=i.json.accessors[u.POSITION],f=m.min,g=m.max;if(f!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(f[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(f[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(f[2]),Math.abs(g[2]))),m.normalized){const v=wk(o0[m.componentType]);c.multiplyScalar(v)}l.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}n.boundingBox=r;const a=new tn;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=a}function s9(n,e,i){const s=e.attributes,r=[];function o(a,l){return i.getDependency("accessor",a).then(function(c){n.setAttribute(l,c)})}for(const a in s){const l=bk[a]||a.toLowerCase();l in n.attributes||r.push(o(s[a],l))}if(e.indices!==void 0&&!n.index){const a=i.getDependency("accessor",e.indices).then(function(l){n.setIndex(l)});r.push(a)}return Mi.workingColorSpace!==ki&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Mi.workingColorSpace}" not supported.`),yu(n,e),Hpe(n,e,i),Promise.all(r).then(function(){return e.targets!==void 0?Fpe(n,e.targets,i):n})}var _m=(n=>(n[n.Quad=0]="Quad",n[n.Cube=1]="Cube",n[n.Sphere=2]="Sphere",n[n.RoundedCube=10]="RoundedCube",n))(_m||{}),XS,_k;class vu{static createText(e,i){let s=null;const r=i?.font||Qpe(i?.familyFamily||null);r instanceof JH?s=If(this,XS,_k).call(this,e,r,i):s==null&&(s=new pt);const o=i?.color||16777215,a=new ue(s,i?.material??new vs({color:o}));return this.applyDefaultObjectOptions(a,i),r instanceof Promise?r.then(l=>{a.geometry=If(this,XS,_k).call(this,e,l,i),i!=null&&i.onGeometry&&i.onGeometry(a)}):i!=null&&i.onGeometry&&i.onGeometry(a),a}static createOccluder(e){const i=new Ht({colorWrite:!1,depthWrite:!0,side:Ai});return this.createPrimitive(e,{material:i})}static createPrimitive(e,i){let s;const r=i?.color||16777215;switch(e){case"Quad":case 0:{const o=new Kn(1,1,1,1),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Quad"}break;case"Cube":case 1:{const o=new Hi(1,1,1),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Cube"}break;case 10:case"RoundedCube":{const o=jpe(1,1,1,.1,2),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="RoundedCube"}break;case"Sphere":case 2:{const o=new ll(.5,16,16),a=i?.material??new vs({color:r});i!=null&&i.texture&&"map"in a&&(a.map=i.texture),s=new ue(o,a),s.name="Sphere"}break;case"ShaderBall":s=new Xn,s.name="ShaderBall",Zpe(s,i);break}return this.applyDefaultObjectOptions(s,i),s}static createSprite(e){const i=new Cw({color:16777215});e!=null&&e.texture&&"map"in i&&(i.map=e.texture);const s=new S2(i);return this.applyDefaultObjectOptions(s,e),s}static applyDefaultObjectOptions(e,i){e.receiveShadow=!0,e.castShadow=!0,i!=null&&i.name&&(e.name=i.name),i!=null&&i.position&&(Array.isArray(i.position)?e.position.set(i.position[0],i.position[1],i.position[2]):e.position.set(i.position.x,i.position.y,i.position.z)),i!=null&&i.rotation&&(Array.isArray(i.rotation)?e.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2]):e.rotation.set(i.rotation.x,i.rotation.y,i.rotation.z)),i!=null&&i.scale&&(typeof i.scale=="number"?e.scale.set(i.scale,i.scale,i.scale):e.scale.set(i.scale.x,i.scale.y,i.scale.z)),i?.receiveShadow!=null&&(e.receiveShadow=i.receiveShadow),i?.castShadow!=null&&(e.castShadow=i.castShadow),i!=null&&i.parent&&i.parent.add(e)}}XS=new WeakSet,_k=function(n,e,i){const s=i?.depth||.1;return new lpe(n,{font:e,size:1,depth:s,height:s,bevelEnabled:i?.bevel||!1,bevelThickness:.01,bevelOffset:.01,bevelSize:.01})},Ia(vu,XS);function jpe(n,e,i,s,r){const o=new Xd,a=1e-5,l=s-a;o.absarc(a,a,a,-Math.PI/2,-Math.PI,!0),o.absarc(a,e-l*2,a,Math.PI,Math.PI/2,!0),o.absarc(n-l*2,e-l*2,a,Math.PI/2,0,!0),o.absarc(n-l*2,a,a,0,-Math.PI/2,!0);const c=new Hy(o,{bevelEnabled:!0,bevelSegments:r*2,steps:1,bevelSize:l,bevelThickness:s,curveSegments:r});return c.scale(1,1,1-s),c.center(),c.computeVertexNormals(),c}const WS=new Map;function Qpe(n){let e="";switch(n){default:case"OpenSans":e="https://cdn.needle.tools/static/fonts/facetype/Open Sans_Regular_ascii.json";break;case"Helvetiker":e="https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/helvetiker_regular.typeface.json";break}if(WS.has(e)){const r=WS.get(e);if(r)return r}const i=new cpe,s=new Promise((r,o)=>{i.load(e,a=>{WS.set(e,a),r(a)},void 0,o)});return WS.set(e,s),s}let Sk=!1,Ck=null;function Zpe(n,e){if(Ck===null){const i="https://cdn.needle.tools/static/models/shaderball.glb",s=new zh,r=DP(null);s.setDRACOLoader(r.dracoLoader),s.setKTX2Loader(r.ktx2Loader),Sk=!0,Ck=s.loadAsync(i).then(o=>{const a=o.scene;return a.position.y-=.5,a}).catch(o=>(console.warn("Failed to load shaderball mesh: "+o.message),o9())).finally(()=>{Sk=!1})}if(Sk){const i=o9();i.name="ShaderBall-Placeholder";const s=i.children[0];s?.type==="Mesh"&&r9(s,e),n.add(i)}Ck.then(i=>{n.children.forEach(o=>{o.name==="ShaderBall-Placeholder"&&n.remove(o)});const s=i.clone(),r=s.children[0];r?.type==="Mesh"&&r9(r,e),n.add(s)})}function r9(n,e){var i;if(e?.color||e?.material||e?.texture){const s=e?.material??((i=n.material)==null?void 0:i.clone())??new vs;e.color&&"color"in s&&s.color instanceof Ae&&s.color.set(e.color),e!=null&&e.texture&&"map"in s&&(s.map=e.texture),n.material=s}}function o9(){return new Xn().add(vu.createPrimitive("Sphere",{material:new Ht({transparent:!0,opacity:.1})}))}const a9=class{constructor(n,e,i){p(this,"_session"),p(this,"_mode"),p(this,"_init"),p(this,"_renderer"),p(this,"_camera"),p(this,"_scene"),p(this,"onEnd",()=>{var s;(s=this._session)==null||s.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()}),p(this,"_lastTime",0),p(this,"onFrame",(s,r)=>{const o=s-this._lastTime;this.update(s,o),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)}),p(this,"_objects",[]),this._mode=n,this._init=e,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new vh({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new Lt,this._scene=new Is,this._scene.fog=new Sw(4473924,10,250),this._scene.add(this._camera),this.setupScene()}static get active(){return this._active}static async start(n,e){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(!e)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(n,e);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new a9(n,e,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 bl(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 n={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,n}async onBeforeHandoff(){await bl(1e3),this._scene.clear()}setupScene(){this._scene.background=new Ae(0),this._scene.add(new a_(5,10,1118481,1118481));const n=new Yp(16777215,1);n.position.set(0,20,0),n.castShadow=!1,this._scene.add(n);const e=new Yp(16777215,1);e.position.set(0,-1,0),e.castShadow=!1,this._scene.add(e);const i=new Zp(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const s=50;for(let r=0;r<100;r++){const o=new vs({color:2236962,metalness:1,roughness:.8});this.isAR&&(o.emissive=new Ae(Math.random(),Math.random(),Math.random()),o.emissiveIntensity=Math.random());const a=et.random(0,1)>.5?_m.Sphere:_m.Cube,l=vu.createPrimitive(a,{material:o});l.position.x=et.random(-s,s),l.position.y=et.random(-2,s),l.position.z=et.random(-s,s),l.rotation.x=et.random(0,Math.PI*2),l.rotation.y=et.random(0,Math.PI*2),l.rotation.z=et.random(0,Math.PI*2),l.scale.multiplyScalar(.5+Math.random()*10);const c=l.position.distanceTo(this._camera.position)-l.scale.x;c<1&&l.position.multiplyScalar(1+1/c),this._objects.push(l),this._scene.add(l)}}update(n,e){const i=n*4e-4;for(let s=0;s<this._objects.length;s++){const r=this._objects[s];r.position.y+=Math.sin(i+s*.5)*.005,r.rotateY(.002)}}};let a0=a9;p(a0,"_active",null),p(a0,"_requestInFlight",!1);var Hb;(n=>{const e=[];function i(){if(!(e!=null&&e.length))return!1;for(const o of e)o.exportAndOpen();return!0}n.exportAndOpen=i;function s(o){e.push(o)}n.registerExporter=s;function r(o){if(!e)return;const a=e.indexOf(o);a>=0&&e.splice(a,1)}n.unregisterExporter=r})(Hb||(Hb={}));const l9="NeedleXRSession onStart",c9="NeedleXRSession onEnd",Os=te("debugwebxr"),h9=te("stats");let Mk=0;function Ype(n){let e=null;const i=n;return i.getAROverlayContainer?e=i.getAROverlayContainer():e=n,e}Kpe();async function Kpe(){var n;if(te("debugasap")){let e=globalThis["needle:XRSession"];if(e instanceof Promise){delete globalThis["needle:XRSession"],xi.addContextCreatedCallback(async i=>{if(!e)return;rm(!0);const s=await e;if(s){const r=Et.getDefaultSessionInit("immersive-vr");Et.setSession("immersive-vr",s,r,i.context)}else console.error("NeedleXRSession: ASAP session was rejected");e=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}(n=navigator.xr)==null||n.addEventListener("sessiongranted",async()=>{rm(!0),console.log("Received Session Granted..."),await bl(100);const e=sessionStorage.getItem("needle_xr_session_mode"),i=sessionStorage.getItem("needle_xr_session_init")??null,s=i?JSON.parse(i):null;let r=null;if(d9()&&(await a0.start(e||"immersive-vr",s||Et.getDefaultSessionInit("immersive-vr")),await $pe(),r=await a0.handoff()),r)Et.setSession(r.mode,r.session,r.init,Pt.Current);else if(e&&i){console.log("Session Granted: Restore last session");const o=JSON.parse(i);Et.start(e,o).catch(a=>console.warn(a))}else Et.start("immersive-vr").catch(o=>console.warn("Session Granted failed:",o))},{once:!0})}}function Jpe(n,e){sessionStorage.setItem("needle_xr_session_mode",n),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function qpe(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const Ek=new Set;xi.registerCallback(_i.ContextCreationStart,async n=>{Ek.add(n.context)}),xi.registerCallback(_i.ContextCreated,async n=>{Ek.delete(n.context)});function d9(){return Ek.size>0}function $pe(){return new Promise(n=>{const e=Date.now(),i=setInterval(()=>{(!d9()||Date.now()-e>6e4)&&(clearInterval(i),n())},100)})}At.isDesktop()&&je()&&window.addEventListener("keydown",n=>{(n.key==="x"||n.key==="Escape")&&Et.active&&Et.stop()});const bu=class{constructor(n,e,i,s){p(this,"context"),p(this,"session"),p(this,"mode"),p(this,"controllers",[]),p(this,"_rigScale",1),p(this,"_lastRigScaleUpdate",-1),p(this,"_rigs",[]),p(this,"_viewerHitTestSource",null),p(this,"_defaultRig"),p(this,"_xr_scripts"),p(this,"_xr_update_scripts",[]),p(this,"_inactive_scripts",[]),p(this,"_controllerAdded"),p(this,"_controllerRemoved"),p(this,"_originalCameraWorldPosition"),p(this,"_originalCameraWorldRotation"),p(this,"_originalCameraWorldScale"),p(this,"_originalCameraParent"),p(this,"_mainCamera",null),p(this,"onRendererSessionSet",()=>{var a;this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),(a=this.context.mainCameraComponent)==null||a.applyClearFlags())}),p(this,"onInputSourceAdded",a=>{if(a.targetRayMode==="screen")return;let l=0;for(let h=0;h<this.session.inputSources.length;h++)if(this.session.inputSources[h]===a){l=h;break}if(this.controllers.find(h=>h.inputSource===a)){console.debug("Controller already exists for input source",l);return}else if(this._newControllers.find(h=>h.inputSource===a)){console.debug("Controller already registered for input source",l);return}const c=new HP(this,a,l);this._newControllers.push(c)}),p(this,"_ended",!1),p(this,"_newControllers",[]),p(this,"onEnd",a=>{var l,c,h;if(this._ended)return;this._ended=!0,console.debug("XR Session ended"),qpe(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,mu(this.onBefore,Ji.LateUpdate);const d=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);d>=0&&this.context.pre_render_callbacks.splice(d,1);const u=this.context.post_render_callbacks.indexOf(this.onAfterRender);u>=0&&this.context.post_render_callbacks.splice(u,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{var f,g;(f=this.context.mainCameraComponent)==null||f.applyClearFlags(),(g=this.context.mainCameraComponent)==null||g.applyClippingPlane()}),yW({session:this});for(const f of bu._xrEndListeners)f({xr:this});const m=[...this.controllers];for(let f=0;f<m.length;f++)this.disconnectInputSource(m[f].inputSource);this._newControllers.length=0,this.controllers.length=0;for(const f of this._xr_scripts)(l=f?.onLeaveXR)==null||l.call(f,{xr:this});(c=this.sync)==null||c.onExitXR(this),this.context.mainCamera&&((h=this._originalCameraParent)==null||h.add(this.context.mainCamera),this._originalCameraWorldPosition&&bs(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&Ba(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&wg(this.context.mainCamera,this._originalCameraWorldScale)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),rm(!1),performance.mark(c9),performance.measure("NeedleXRSession",l9,c9)}),p(this,"_didStart",!1),p(this,"onBefore",a=>{var l,c,h,d,u,m,f,g;const v=a.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),((l=this.rig)==null?void 0:l.isActive)==!1&&(Os&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&(c=this._mainCamera)!=null&&c.gameObject&&((d=(h=this._mainCamera)==null?void 0:h.gameObject)==null?void 0:d.parent)!==this.rig.gameObject&&this.rig.gameObject.add((u=this._mainCamera)==null?void 0:u.gameObject),this.internalUpdateState(),this.applyCustomForward();const y={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const b=[...this.context.new_scripts_xr];for(let A=0;A<b.length;A++){const x=this.context.new_scripts_xr[A];if(!x||x.destroyed||((m=x.supportsXR)==null?void 0:m.call(x,this.mode))==!1){this.context.new_scripts_xr.splice(A,1);continue}if(!x.activeAndEnabled){this.context.new_scripts_xr.splice(A,1),this.markInactive(x);continue}if(this.addScript(x)){this.invokeCallback_EnterXR(x);for(const w of this.controllers)this.invokeCallback_ControllerAdded(x,w)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const A=Jo(this.context.scene.children);if(A){const x=A.getSize(ht());if(x.length()>0){const w=this._defaultRig.gameObject;w.position.set(A.min.x+x.x*.5,A.min.y,A.max.z+x.z*.5+1.5);const _=A.getCenter(ht());_.y=w.position.y,w.lookAt(_)}}}gW({session:this});for(const A of bu._xrStartListeners)A(y);const b=[...this._xr_scripts];Os&&console.log("NeedleXRSession start, handle scripts:",b);for(const A of b){if(A.destroyed){this._script_to_remove.push(A);continue}if(!A.activeAndEnabled){this.markInactive(A);continue}this.invokeCallback_EnterXR(A);for(const x of this.controllers)this.invokeCallback_ControllerAdded(A,x)}}this.syncCameraCullingMask();for(const b of this.controllers)b.onUpdate(v);if(this._newControllers.length>0){const b=[...this._newControllers];this._newControllers.length=0;for(const A of b){if(!A.connected){console.warn("New controller is not connected",A);continue}this.controllers.push(A);for(const x of this._xr_scripts){if(x.destroyed){this._script_to_remove.push(x);continue}x.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(x,A)}}this.controllers.sort((A,x)=>A.index-x.index)}Os&&this.context.time.frame%30===0&&this.controllers.length<=0&&this.session.inputSources.length>0&&(rm(!0),console.error("XRControllers are not added but inputSources are present")),performance.mark("NeedleXRSession update scripts start");for(const b of this._xr_update_scripts){if(b.destroyed===!0){this._script_to_remove.push(b);continue}if(b.activeAndEnabled===!1){this.markInactive(b);continue}b.onUpdateXR&&b.onUpdateXR(y)}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 b=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const A of b)!A.destroyed&&this.running&&((f=A.onLeaveXR)==null||f.call(A,y)),this.removeScript(A)}(g=this.sync)==null||g.onUpdate(this),this.onRenderDebug(),performance.mark("NeedleXRSession onBefore end"),performance.measure("NE XR frame","NeedleXRSession onBefore start","NeedleXRSession onBefore end")}),p(this,"onBeforeRender",()=>{this.context.mainCamera&&this.updateFade(this.context.mainCamera)}),p(this,"onAfterRender",()=>{if(this.onUpdateFade_PostRender(),At.isDesktop()||!this._renderOnceOnDevice){const a=this.context.renderer;if(a.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const l=a.xr.enabled,c=a.getRenderTarget(),h=this.context.scene.background;a.xr.enabled=!1,a.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):a.render(this.context.scene,this.context.mainCamera),a.xr.enabled=l,a.setRenderTarget(c),this.context.scene.background=h}}}),p(this,"_script_to_remove",[]),p(this,"_camera"),p(this,"_cameraRenderParent",new ge().rotateY(Math.PI)),p(this,"_previousCameraParent"),p(this,"_customforward",!0),p(this,"originalCameraNearPlane"),p(this,"_viewerPose"),p(this,"_transformOrientation",new Se),p(this,"_transformPosition",new M),p(this,"_transition");var r,o;performance.mark(l9),Jpe(n,s.init),this.session=e,this.mode=n,this.context=i,(Os||te("console"))&&rm(!0),this._xr_scripts=[...s.scripts],this._xr_update_scripts=this._xr_scripts.filter(a=>typeof a.onUpdateXR=="function"),this._controllerAdded=s.controller_added,this._controllerRemoved=s.controller_removed,pu(this.onBefore,Ji.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),((r=s.init.optionalFeatures)!=null&&r.includes("hit-test")||(o=s.init.requiredFeatures)!=null&&o.includes("hit-test"))&&e.requestReferenceSpace("viewer").then(a=>{var l,c;return(c=(l=e.requestHitTestSource)==null?void 0:l.call(e,{space:a}))==null?void 0:c.then(h=>this._viewerHitTestSource=h).catch(h=>console.error(h))}).catch(a=>console.error(a)),this.context.mainCamera&&(this._originalCameraWorldPosition=Nt(this.context.mainCamera,new M),this._originalCameraWorldRotation=Bi(this.context.mainCamera,new Se),this._originalCameraWorldScale=Yi(this.context.mainCamera,new M),this._originalCameraParent=this.context.mainCamera.parent),this._defaultRig=new fue,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let a=0;a<e.inputSources.length;a++){const l=e.inputSources[a];if(!l.handedness){console.warn("Input source in xr session has no handedness - ignoring",a);continue}this.onInputSourceAdded(l)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",a=>{for(const l of a.removed)this.disconnectInputSource(l);for(const l of a.added)this.onInputSourceAdded(l)}),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):Os&&console.warn("controllerAutoUpdate is not available in three.js - cannot disable it")}static getXRSync(n){return this._sync||(this._sync=new YH(n)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static get active(){return this._activeSession}static get activeMode(){var n;return((n=this._activeSession)==null?void 0:n.mode)??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(n=>n.some(e=>e)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(n){var e;return((e=this.xrSystem)==null?void 0:e.isSessionSupported(n).catch(i=>(Os&&console.error(i),!1)))??Promise.resolve(!1)}static onSessionRequestStart(n){this._sessionRequestStartListeners.push(n)}static offSessionRequestStart(n){const e=this._sessionRequestStartListeners.indexOf(n);e>=0&&this._sessionRequestStartListeners.splice(e,1)}static onSessionRequestEnd(n){this._sessionRequestEndListeners.push(n)}static offSessionRequestEnd(n){const e=this._sessionRequestEndListeners.indexOf(n);e>=0&&this._sessionRequestEndListeners.splice(e,1)}static onXRSessionStart(n){this._xrStartListeners.push(n)}static offXRSessionStart(n){const e=this._xrStartListeners.indexOf(n);e>=0&&this._xrStartListeners.splice(e,1)}static onXRSessionEnd(n){this._xrEndListeners.push(n)}static offXRSessionEnd(n){const e=this._xrEndListeners.indexOf(n);e>=0&&this._xrEndListeners.splice(e,1)}static onControllerAdded(n){this._controllerAddedListeners.push(n)}static offControllerAdded(n){const e=this._controllerAddedListeners.indexOf(n);e>=0&&this._controllerAddedListeners.splice(e,1)}static onControllerRemoved(n){this._controllerRemovedListeners.push(n)}static offControllerRemoved(n){const e=this._controllerRemovedListeners.indexOf(n);e>=0&&this._controllerRemovedListeners.splice(e,1)}static offerSession(n,e,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+n),e=="default"&&(e=this.getDefaultSessionInit(n)),navigator.xr.offerSession(n,{...e}).then(s=>bu.setSession(n,s,e,i)).catch(s=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(n){switch(n){case"immersive-ar":return{optionalFeatures:["anchors","local-floor","hand-tracking","layers","dom-overlay","hit-test","unbounded"]};case"immersive-vr":return{optionalFeatures:["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]};default:return console.warn("No default session init for mode",n),{}}}static async start(n,e,i){var s,r,o,a;if(At.isiOS()){if(n==="ar")if(await this.isARSupported())n="immersive-ar";else return Hb.exportAndOpen(),null}else n=="ar"&&(n="immersive-ar");if(je()&&te("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await a0.start(n,e||bu.getDefaultSessionInit(n)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(Os||je())&&Oi("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=Pt.Current),i||(i=xi.All[0]),!i)throw new Error("No Needle Engine Context found");switch(performance.mark("NeedleXRSession start"),e||(e={}),n){case"immersive-ar":{if(await((s=this.xrSystem)==null?void 0:s.isSessionSupported("immersive-ar"))!==!0)return console.error(n+" is not supported by this browser."),null;const d=this.getDefaultSessionInit(n),u=Ype(i.domElement);u&&!At.isQuest()&&(d.domOverlay={root:u},d.optionalFeatures.push("dom-overlay")),e={...d,...e}}break;case"immersive-vr":{if(await((r=this.xrSystem)==null?void 0:r.isSessionSupported("immersive-vr"))!==!0)return console.error(n+" is not supported by this browser."),null;e={...this.getDefaultSessionInit(n),...e}}break;default:console.warn("No default session init for mode",n);break}e.optionalFeatures??(e.optionalFeatures=[]),e.requiredFeatures??(e.requiredFeatures=[]),await a0.stop();const l=n=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;Os?console.log(`%cRequesting ${n} session`,"font-weight:bold;",e,l):console.log(`%cRequesting ${n} session`,"font-weight:bold;");for(const d of l)d.onBeforeXR&&d.onBeforeXR(n,e);for(const d of this._sessionRequestStartListeners)d({mode:n,init:e});Os&&gn("Requesting "+n+" session ("+Date.now()+")"),this._currentSessionRequest=(o=navigator.xr)==null?void 0:o.requestSession(n,e),this._currentSessionRequestMode=n;const c=await((a=this._currentSessionRequest)==null?void 0:a.catch(d=>{console.error(d,"Code: "+d.code),d.code===9&&Oi("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:"&&Oi("XR requires a secure connection (HTTPS)")}));this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const d of this._sessionRequestEndListeners)d({mode:n,init:e,newSession:c||null});if(!c)return console.warn("XR Session request was rejected"),null;const h=this.setSession(n,c,e,i);return performance.mark("NeedleXRSession end"),performance.measure("NeedleXRSession Startup","NeedleXRSession start","NeedleXRSession end"),h}static setSession(n,e,i,s){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const r=n=="immersive-ar"?s.scripts_immersive_ar:s.scripts_immersive_vr;return this._activeSession=new bu(n,e,s,{scripts:r,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),e.addEventListener("end",this.onEnd),Os?console.log(`%cStarted ${n} session`,"font-weight:bold;",r):console.log(`%cStarted ${n} session`,"font-weight:bold;"),this._activeSession}static stop(){var n;(n=this._activeSession)==null||n.end()}get sync(){return bu._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(n=>n.side==="left")}get rightController(){return this.controllers.find(n=>n.side==="right")}getController(n){return typeof n=="number"?this.controllers[n]||null:this.controllers.find(e=>e.side===n)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(n=>n.inputSource.targetRayMode==="tracked-pointer")||je()&&At.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 n=this.frame.getImageTrackingResults();for(const e of n)if(e.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const n=this._rigs[0]??null;return n!=null&&n.gameObject&&Lm(n.gameObject)||n?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):n}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(n){this._rigs.indexOf(n)>=0||(n.priority===void 0&&(n.priority=0),this._rigs.push(n),this.updateActiveXRRig())}removeRig(n){const e=this._rigs.indexOf(n);e!==-1&&(this._rigs.splice(e,1),this.updateActiveXRRig())}setRigActive(n){const e=this._rigs.indexOf(n);this._rigs.splice(e,1),this._rigs.unshift(n),this.updateActiveXRRig()}getUserOffsetInRig(){var n;const e=(n=this.context.mainCamera)==null?void 0:n.position;if(!e||!this.rig)return ht(0,0,0);const i=ht(e);return i.x*=-1,i.z*=-1,i.applyQuaternion(xl(this.rig.gameObject.quaternion)),i}updateActiveXRRig(){const n=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 e=this._rigs[0];e&&e.priority===void 0&&(e.priority=0);for(let i=1;i<this._rigs.length;i++){const s=this._rigs[i];if(s.isActive){if(Lm(s.gameObject)){this._rigs.splice(i,1),i--;continue}(!e||e.isActive===!1||s.priority!==void 0&&s.priority>e.priority)&&(e=s)}}if(n!==e){const i=this._rigs.indexOf(e);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(e)}Os&&(n===e?console.log("Updated Active XR Rig:",e,"prev:",n):console.log("Updated Active XRRig:",e," (the same as before)"))}getHitTest(n){if(n)return this.getControllerHitTest(n);if(!this._viewerHitTestSource)return null;const e=this._viewerHitTestSource,i=this.frame.getHitTestResults(e);if(i.length>0){const s=i[0];return this.convertHitTestResult(s)}return null}getControllerHitTest(n){const e=n.getHitTestSource();if(!e)return null;const i=this.frame.getHitTestResultsForTransientInput(e);for(const s of i)if(s.inputSource===n.inputSource)for(const r of s.results)return this.convertHitTestResult(r);return null}convertHitTestResult(n){const e=this.context.renderer.xr.getReferenceSpace(),i=e&&n.getPose(e);if(i){const s=ht(i.transform.position),r=xl(i.transform.orientation),o=this.context.mainCamera;if(o?.parent!==this._cameraRenderParent&&s.applyMatrix4(i0),o!=null&&o.parent){s.applyMatrix4(o.parent.matrixWorld),r.multiply(Va);const a=Bi(o.parent);a.premultiply(Va),r.premultiply(a)}return{hit:n,position:s,quaternion:r}}return null}convertSpace(n){const e=ht(n.position);e.applyMatrix4(i0);const i=xl(n.orientation);return i.premultiply(Va),{position:e,quaternion:i}}disconnectInputSource(n){const e=(i,s,r)=>{if(i.inputSource===n){Os&&console.log("Disconnecting controller",i.index),this.controllers.splice(r,1),this.invokeControllerEvent(i,this._controllerRemoved,"removed");const o={xr:this,controller:i,change:"removed"};for(const a of this._xr_scripts)a.onXRControllerRemoved&&a.onXRControllerRemoved(o);i.onDisconnected()}};for(let i=this.controllers.length-1;i>=0;i--){const s=this.controllers[i];e(s,this.controllers,i)}for(let i=this._newControllers.length-1;i>=0;i--){const s=this._newControllers[i];e(s,this._newControllers,i)}}end(){this._ended||this.session.end().catch(n=>console.warn(n))}onRenderDebug(){if(Os)for(const n of this.controllers)n.onRenderDebug();if((Os||h9)&&this.rig&&(Mk++,Mk>=20)){const n=this.rig.gameObject.worldPosition,e=this.rig.gameObject.worldForward;n.add(e.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;n.add(i.multiplyScalar(2.5));let s="";if(s+=`${this.context.time.smoothedFps.toFixed(0)} FPS`,s+=`, calls: ${this.context.renderer.info.render.calls}, tris: ${this.context.renderer.info.render.triangles.toLocaleString()}`,Os||h9)for(const r of this.controllers)s+=`
|
|
4964
|
+
${r.hand?"hand":"ctrl"} ${r.inputSource.handedness}[${r.index}] con:${r.connected} tr:${r.isTracking} hts:${r.hasHitTestSource?"yes":"no"}`;Mk=0,ft.DrawLabel(n,s,void 0,1/60*20)}}addScript(n){return this._xr_scripts.includes(n)?!1:(Os&&console.log("Register new XRScript",n),this._xr_scripts.push(n),typeof n.onUpdateXR=="function"&&this._xr_update_scripts.push(n),!0)}markInactive(n){if(!(this._inactive_scripts.indexOf(n)>=0)){this.removeScript(n,!1),this._inactive_scripts.push(n);for(const e of this.controllers)this.invokeCallback_ControllerRemoved(n,e);this.invokeCallback_LeaveXR(n)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let n=this._inactive_scripts.length-1;n>=0;n--){const e=this._inactive_scripts[n];if(e.activeAndEnabled){this._inactive_scripts.splice(n,1),this.addScript(e),this.invokeCallback_EnterXR(e);for(const i of this.controllers)this.invokeCallback_ControllerAdded(e,i)}}}removeScript(n,e=!0){Os&&console.log("Remove XRScript",n);const i=this._xr_scripts.indexOf(n);i>=0&&this._xr_scripts.splice(i,1);const s=this._xr_update_scripts.indexOf(n);if(s>=0&&this._xr_update_scripts.splice(s,1),e){const r=this._inactive_scripts.indexOf(n);r>=0&&this._inactive_scripts.splice(r,1)}}invokeCallback_EnterXR(n){n.onEnterXR&&n.onEnterXR({xr:this})}invokeCallback_ControllerAdded(n,e){n.onXRControllerAdded&&n.onXRControllerAdded({xr:this,controller:e,change:"added"})}invokeCallback_ControllerRemoved(n,e){n.onXRControllerRemoved&&n.onXRControllerRemoved({xr:this,controller:e,change:"removed"})}invokeCallback_LeaveXR(n){n.onLeaveXR&&!n.destroyed&&n.onLeaveXR({xr:this})}syncCameraCullingMask(){var n;const e=this.context.xrCamera,i=(n=this.context.mainCameraComponent)==null?void 0:n.cullingMask;if(e&&i!==void 0){for(const s of e.cameras)s.layers.mask=i;e.layers.mask=i}else if(e){for(const s of e.cameras)s.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(n,e,i){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r)try{r({xr:this,controller:n,change:i})}catch(o){console.error(o)}}}applyCustomForward(){var n;if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,(n=this._previousCameraParent)==null||n.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);let e=.02;if(this.rig){const i=Yi(this.rig.gameObject);e*=i.x}this._camera instanceof Lt&&this._camera.near>e&&(this.originalCameraNearPlane=this._camera.near,this._camera.near=e)}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof Lt&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane)}internalUpdateState(){const n=this.context.renderer.xr.getReferenceSpace();if(!n){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(n),this._viewerPose){const e=this._viewerPose.transform;this._transformPosition.set(e.position.x,e.position.y,e.position.z),this._transformOrientation.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w)}}get transition(){return this._transition||(this._transition=new KH),this._transition}fadeTransition(){return this._transition||(this._transition=new KH),this._transition.fadeTransition()}updateFade(n){this._transition&&n instanceof Lt&&this._transition.update(n,this.context.time.deltaTime)}onUpdateFade_PostRender(){var n;(n=this._transition)==null||n.remove()}};let Et=bu;p(Et,"_sync",null),p(Et,"_currentSessionRequestMode",null),p(Et,"_currentSessionRequest"),p(Et,"_activeSession"),p(Et,"_sessionRequestStartListeners",[]),p(Et,"_sessionRequestEndListeners",[]),p(Et,"_xrStartListeners",[]),p(Et,"_xrEndListeners",[]),p(Et,"_controllerAddedListeners",[]),p(Et,"_controllerRemovedListeners",[]),p(Et,"onEnd",()=>{Os&&console.log("XR Session ended"),bu._activeSession=null});const Tk=te("debugwebxr");class u9{static tryFindAvatarObjects(e,i,s){if(s.head&&s.leftHand&&s.rightHand)return;const r=e.name.toLocaleLowerCase();!s.head&&r.includes("head")&&(Tk&&console.log("FOUND AVATAR HEAD",e.name),s.head=new ei("",i,e)),r.includes("hand")&&(!s.leftHand&&r.includes("left")&&(Tk&&console.log("FOUND AVATAR LEFT HAND",e.name),s.leftHand=new ei("",i,e)),!s.rightHand&&r.includes("right")&&(Tk&&console.log("FOUND AVATAR RIGHT HAND",e.name),s.rightHand=new ei("",i,e)));for(let o=0;o<e.children.length;o++){if(s.head&&s.leftHand&&s.rightHand)return;const a=e.children[o];this.tryFindAvatarObjects(a,i,s)}}}const Nr=new M,p9=new M,m9=new Se,eme=te("debuggizmos"),Ol=8947848,Rk=32,Dl=class{constructor(){}static isGizmo(n){return n[Lk]!==void 0}static DrawLabel(n,e,i=.05,s=0,r,o,a){var l;if(!Dl.enabled)return null;r||(r=Ol);const c=((l=Et.active)==null?void 0:l.rigScale)??1,h=rn.getTextLabel(s,e,i*c,r,o);return a instanceof ge&&a.add(h),h.position.x=n.x,h.position.y=n.y,h.position.z=n.z,h}static DrawRay(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,n.x,n.y,n.z),Nr.set(e.x,e.y,e.z).multiplyScalar(999999999),a.setXYZ(1,n.x+Nr.x,n.y+Nr.y,n.z+Nr.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawDirection(n,e,i=Ol,s=0,r=!0,o=1){if(!Dl.enabled)return;const a=rn.getLine(s),l=a.geometry.getAttribute("position");l.setXYZ(0,n.x,n.y,n.z),e.w!==void 0?(Nr.set(0,0,-o),m9.set(e.x,e.y,e.z,e.w),Nr.applyQuaternion(m9)):(Nr.set(e.x,e.y,e.z),Nr.multiplyScalar(o)),l.setXYZ(1,n.x+Nr.x,n.y+Nr.y,n.z+Nr.z),l.needsUpdate=!0,a.material.color.set(i),a.material.depthTest=r,a.material.depthWrite=!1}static DrawLine(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getLine(s),a=o.geometry.getAttribute("position");a.setXYZ(0,n.x,n.y,n.z),a.setXYZ(1,e.x,e.y,e.z),a.needsUpdate=!0,o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawCircle(n,e,i,s=Ol,r=0,o=!0){if(!Dl.enabled)return;const a=rn.getCircle(r);a.position.set(n.x,n.y,n.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,Nr.set(e.x,e.y,e.z).normalize()),a.material.color.set(s),a.material.depthTest=o,a.material.depthWrite=!1,a.material.fog=!1}static DrawWireSphere(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getSphere(e,s,!0);nm(o,n.x,n.y,n.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1,o.material.fog=!1}static DrawSphere(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getSphere(e,s,!1);nm(o,n.x,n.y,n.z),o.material.color.set(i),o.material.depthTest=r,o.material.depthWrite=!1}static DrawWireBox(n,e,i=Ol,s=0,r=!0){if(!Dl.enabled)return;const o=rn.getBox(s);o.position.set(n.x,n.y,n.z),o.scale.set(e.x,e.y,e.z),o.material.color.set(i),o.material.depthTest=r,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1}static DrawWireBox3(n,e=Ol,i=0,s=!0){if(!Dl.enabled)return;const r=rn.getBox(i);r.position.copy(n.getCenter(Nr)),r.scale.copy(n.getSize(Nr)),r.material.color.set(e),r.material.depthTest=s,r.material.wireframe=!0,r.material.depthWrite=!1,r.material.fog=!1}static DrawArrow(n,e,i=Ol,s=0,r=!0,o=!1){if(!Dl.enabled)return;const a=rn.getArrowHead(s);a.position.set(e.x,e.y,e.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),Nr.set(e.x,e.y,e.z).sub(p9.set(n.x,n.y,n.z)).normalize());const l=Nr.set(e.x,e.y,e.z).sub(p9.set(n.x,n.y,n.z)).length()*.1;a.scale.set(l,l,l),a.material.color.set(i),a.material.depthTest=r,a.material.wireframe=o,this.DrawLine(n,e,i,s,r)}static DrawWireMesh(n){const e=rn.getMesh(n.duration??0);"mesh"in n?(e.geometry=n.mesh.geometry,e.matrix.copy(n.mesh.matrixWorld)):(e.geometry=n.geometry,e.matrix.copy(n.matrix)),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,e.material.color.set(n.color??Ol),e.material.depthTest=n.depthTest??!0,e.material.wireframe=!0}static setVisible(n){for(const e of rn.timedObjectsBuffer)e.visible=n}};let ft=Dl;p(ft,"enabled",!0),p(ft,"_up",new M(0,1,0));const tme=new Hi(1,1,1);function Ik(n=null){const e=new Ae(n??14540253),i=new H2(tme);return new Lr(i,new Vi({color:e}))}const Lk=Symbol("GizmoCache");class rn{static ensureFont(){let e=Xi.FontLibrary.getFontFamily(this.familyName);if(!e){e=Xi.FontLibrary.addFontFamily(this.familyName);const i=e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png");i?.addEventListener("ready",()=>{Xi.update()})}}static getTextLabel(e,i,s,r,o){this.ensureFont();let a=this.textLabelCache.pop(),l=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(l=parseInt(o.substring(7),16)/255,o=o.substring(0,7),eme&&console.log(o,l)):typeof o=="object"&&o.a!==void 0&&(l=o.a);const c={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:s,color:r,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:l,textContent:i,borderRadius:.5*s,padding:.8*s,whiteSpace:"pre",offset:.05*s};if(a)a.set(c);else{a=new tL(c);const h=this,d=a;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(Pt.Current,a,e,this.textLabelCache),a}static getBox(e){let i=this.boxesCache.pop();if(!i){const s=new Hi(1,1,1);i=new ue(s)}return this.registerTimedObject(Pt.Current,i,e,this.boxesCache),i}static getLine(e){let i=this.linesCache.pop();if(!i){i=new mn;let s=i.geometry.getAttribute("position");s||(s=new $e(new Float32Array(2*3),3),i.geometry.setAttribute("position",s))}return i.frustumCulled=!1,this.registerTimedObject(Pt.Current,i,e,this.linesCache),i}static getCircle(e){let i=this.circlesCache.pop();if(!i){i=new mn;let s=i.geometry.getAttribute("position");if(!s){s=new $e(new Float32Array(Rk*3),3),i.geometry.setAttribute("position",s);const r=ht(0,1,0),o=ht(0,0,1),a=ht(o);a.cross(r).normalize();const l=ht(a),c=Math.PI*2/(Rk-1);for(let h=0;h<Rk+1;h++){const d=c*h;r.copy(l).multiplyScalar(Math.cos(d)*1),a.copy(o).multiplyScalar(Math.sin(d)*1);const u=r.add(a);s.setXYZ(h,u.x,u.y,u.z)}}}return i.frustumCulled=!1,this.registerTimedObject(Pt.Current,i,e,this.circlesCache),i}static getSphere(e,i,s){let r=this.spheresCache.pop();return r||(r=new ue(new ll(1,8,8))),r.scale.set(e,e,e),r.material.wireframe=s,this.registerTimedObject(Pt.Current,r,i,this.spheresCache),r}static getArrowHead(e){let i=this.arrowHeadsCache.pop();return i||(i=new ue(new Jn(0,.5,1,8))),this.registerTimedObject(Pt.Current,i,e,this.arrowHeadsCache),i}static getMesh(e){let i=this.mesh.pop();return i||(i=new ue,i.material=new Ht),this.registerTimedObject(Pt.Current,i,e,this.mesh),i}static registerTimedObject(e,i,s,r){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),a=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const l=e.pre_render_callbacks.indexOf(o);l>=0&&e.pre_render_callbacks.splice(l,1),e.pre_render_callbacks.push(o)}}else{const l=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,l),e.pre_render_callbacks.push(l)}if(a){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==a){const l=e.post_render_callbacks.indexOf(a);l>=0&&e.post_render_callbacks.splice(l,1),e.post_render_callbacks.push(a)}}else{const l=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,l),e.post_render_callbacks.push(l)}i.traverse(l=>{l.layers.disableAll(),l.layers.enable(2)}),i.renderOrder=999999,i[Lk]=r,i.castShadow=!1,i.receiveShadow=!1,i.isGizmo=!0,this.timedObjectsBuffer.push(i),this.timesBuffer.push(Pt.Current.time.realtimeSinceStartup+s),e.scene.add(i)}static onBeforeRender(e,i){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,Xi.update());for(let s=0;s<i.length;s++){const r=i[s];if(e.mainCamera&&r instanceof Xi.MeshUIBaseElement){if(Lm(r))continue;const o=e.isInVR,a=!1,l=!o;Zv(r,e.mainCamera,a,l)}}}static onPostRender(e,i,s){const r=e.time.realtimeSinceStartup;for(let o=i.length-1;o>=0;o--){const a=i[o];r>=s[o]-1e-6&&(i.splice(o,1),s.splice(o,1),a.removeFromParent(),Lm(a)!=!0&&a[Lk].push(a))}}}p(rn,"familyName","needle-gizmos"),p(rn,"linesCache",[]),p(rn,"circlesCache",[]),p(rn,"spheresCache",[]),p(rn,"boxesCache",[]),p(rn,"arrowHeadsCache",[]),p(rn,"mesh",[]),p(rn,"textLabelCache",[]),p(rn,"timedObjectsBuffer",new Array),p(rn,"timesBuffer",new Array),p(rn,"contextPostRenderCallbacks",new Map),p(rn,"contextBeforeRenderCallbacks",new Map),p(rn,"tmuiNeedsUpdate",!1);const Gl=te("debugphysics"),f9=new Er;class Ac{constructor(){p(this,"ray"),p(this,"cam"),p(this,"screenPoint"),p(this,"raycaster"),p(this,"results"),p(this,"targets"),p(this,"recursive",!0),p(this,"minDistance"),p(this,"maxDistance"),p(this,"lineThreshold"),p(this,"layerMask"),p(this,"ignore"),p(this,"testObject"),p(this,"useAcceleratedRaycast")}screenPointFromOffset(e,i){this.screenPoint===void 0&&(this.screenPoint=new K),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(i/window.innerHeight)*2+1}setLayer(e){f9.set(e),this.layerMask=f9}setMask(e){this.layerMask||(this.layerMask=new Er);const i=this.layerMask;i?i.mask=e:this.layerMask=e}}p(Ac,"AllLayers",4294967295);class Pk{constructor(e,i,s){p(this,"distance"),p(this,"point"),p(this,"object"),this.object=e,this.distance=i,this.point=s}}const kk=class{constructor(n){p(this,"context"),p(this,"engine"),p(this,"raycaster",new Hd),p(this,"defaultRaycastOptions",new Ac),p(this,"targetBuffer",new Array(1)),p(this,"defaultThresholds",{Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}}),p(this,"sphereResults",new Array),p(this,"sphereMask",new Er),p(this,"sphere",new tn),p(this,"tempBoundingBox",new Wt),this.context=n}static get raycasting(){return this._raycasting>0}raycastPhysicsFast(n,e=void 0,i=1/0,s=!0){var r;return((r=this.context.physics.engine)==null?void 0:r.raycast(n,e,{maxDistance:i,solid:s}))??null}raycastPhysicsFastAndGetNormal(n,e=void 0,i=1/0,s=!0){var r;return((r=this.context.physics.engine)==null?void 0:r.raycastAndGetNormal(n,e,{maxDistance:i,solid:s}))??null}sphereOverlapPhysics(n,e){var i;return((i=this.context.physics.engine)==null?void 0:i.sphereOverlap(n,e))??null}sphereOverlap(n,e,i=!0,s=!1,r=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const o=this.sphereMask;o.enableAll(),o.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,n,e,o,this.sphereResults,i,s,r);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(n,e=null){const i=e??this.defaultRaycastOptions;i.ray=n;const s=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),s}raycast(n=null){Gl&&performance.mark("raycast.start"),n||(n=this.defaultRaycastOptions);const e=n.screenPoint??this.context.input.mousePositionRC,i=n.raycaster??this.raycaster;if(i.near=n.minDistance??0,i.far=n.maxDistance??1/0,i.params=this.defaultThresholds,n.lineThreshold===void 0&&(n.lineThreshold=-1),i.params.Line={threshold:n.lineThreshold},n.ray)i.ray.copy(n.ray);else{const a=n.cam??this.context.mainCamera;if(!a)return Gl&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof x2&&l.cameras.length>0?i.setFromCamera(e,l.cameras[0]):i.setFromCamera(e,a)}let s=n.targets;s||(s=this.targetBuffer,s.length=1,s[0]=this.context.scene);let r=n.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),r||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),r=this.defaultRaycastOptions.results),n.layerMask!==void 0?n.layerMask instanceof Er?i.layers.mask=n.layerMask.mask:i.layers.mask=n.layerMask:(i.layers.enableAll(),i.layers.disable(2)),Gl&&(ft.DrawRay(i.ray.origin,i.ray.direction,16711680,2),console.time("raycast")),r.length=0,kk._raycasting++,this.intersect(this.raycaster,s,r,n),r.sort((a,l)=>a.distance-l.distance);const o=n.ignore;return o!==void 0&&o.length>0&&(r=r.filter(a=>!o.includes(a.object))),kk._raycasting--,Gl&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",r!=null&&r.length?[...r]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),r}intersect(n,e,i,s){var r,o,a;for(const l of e){if(!l||l.visible===!1||ft.isGizmo(l)||s.lineThreshold!==void 0&&s.lineThreshold<0&&l instanceof mn)continue;let c=!0;const h=l,d=h.geometry;if(s.testObject){const u=(r=s.testObject)==null?void 0:r.call(s,l);if(u===!1)continue;u==="continue in children"&&(c=!1)}if(c&&(d&&g9(d)||(c=!1)),c){const u=Ib(l);u&&(h.geometry=u);const m=i.length;let f=!0;s.precise===!1&&(f=!1),f||(f=((a=(o=d.getAttribute("position"))==null?void 0:o.array)==null?void 0:a.length)<64),h instanceof xg&&(f=!1),!f&&nme(h,n,i)||(s.useAcceleratedRaycast!==!1?QS.runMeshBVHRaycast(n,h,i,this.context):n.intersectObject(h,!1,i)),Gl&&i.length!=m&&ft.DrawWireMesh({mesh:l,depthTest:!1,duration:.2,color:u?8969557:7798784}),h.geometry=d}s.recursive!==!1&&this.intersect(n,l.children,i,s)}return i}intersectSphere(n,e,i,s,r,o,a,l){let c=n&&n.isMesh&&n.layers.test(s)&&!ft.isGizmo(n);c&&(c=n.visible),c&&(c=!(n instanceof mn)),c&&(c=!(n instanceof xg));const h=n,d=h.geometry;if(c&&l){const u=l(n);if(u===!1)return;u==="continue in children"&&(c=!1)}if(d&&g9(d)||(c=!1),c){if(a){const u=this.sphere;u.center.copy(e),u.radius=i;const m=r.length;if(QS.runMeshBVHRaycast(this.sphere,h,r,this.context),m!=r.length&&!o)return}else if(d.boundingBox||d.computeBoundingBox(),d.boundingBox){h.matrixWorldNeedsUpdate&&h.updateWorldMatrix(!1,!1);const u=this.tempBoundingBox.copy(d.boundingBox).applyMatrix4(h.matrixWorld),m=this.sphere;if(m.center.copy(e),m.radius=i,m.intersectsBox(u)){const f=Nt(n),g=f.distanceTo(m.center),v=new Pk(n,g,f);if(r.push(v),!o)return}}}if(n.children)for(const u of n.children){const m=r.length;if(this.intersectSphere(u,e,i,s,r,o,a,l),m!=r.length&&!o)return}}};let HS=kk;p(HS,"_raycasting",0);function g9(n){return!(n.index&&n.index.array.length<3)}const Sm=new tn,jS=new fs,ime=new Gt;function nme(n,e,i){const s=n._computeIntersections;if(!s)return!1;let r=n["_computeIntersections:Needle"];return r||(r=n["_computeIntersections:Needle"]=function(o,a,l){const c=this,h=c.geometry.boundingSphere;if(h){if(c instanceof xg){jS.setFromNormalAndCoplanarPoint(ht(0,1,0),ht(0,-c.position.y,0)),jS.applyMatrix4(c.matrixWorld,ime);const u=o.ray.intersectPlane(jS,ht());if(u){Sm.copy(h),Sm.applyMatrix4(c.matrixWorld);const m=ht(u).sub(o.ray.origin).length(),f=Sm.radius*.5;m<f&&a.push({distance:m,point:u,object:c,normal:jS.normal.clone()})}return}Sm.copy(h),Sm.applyMatrix4(c.matrixWorld);const d=o.ray.intersectSphere(Sm,ht());if(d){const u=ht(d).sub(o.ray.origin),m=u.length();if(m>Sm.radius){const f=u.clone().normalize();a.push({distance:m,point:d,object:c,normal:f})}}}}),n._computeIntersections=r,e.intersectObject(n,!1,i),n._computeIntersections=s,!0}var QS;(n=>{function e(b,A,x,w){var _,S,C;if(!A.geometry||!A.geometry.hasAttribute("position"))return!1;const R=A.geometry;if(A!=null&&A.isSkinnedMesh){const P=A,T=P.bvhNeedsUpdate;if(!P.staticGenerator)l(),o&&(P.staticGenerator=new o(A),P.staticGenerator.applyWorldTransforms=!1,P.staticGeometry=P.staticGenerator.generate(),R.boundsTree=a?.call(P.staticGeometry),P.staticGeometryLastUpdate=performance.now()+Math.random()*200,P.autoUpdateMeshBVH===void 0&&(P.autoUpdateMeshBVH=!1));else if(R.boundsTree&&(P.autoUpdateMeshBVH===!0||T===!0)){const L=performance.now(),k=L-P.staticGeometryLastUpdate;(T||k>100)&&(P.bvhNeedsUpdate=!1,P.staticGeometryLastUpdate=L,(_=P.staticGenerator)==null||_.generate(P.staticGeometry),R.boundsTree.refit())}}else if(!R.boundsTree){h||y();let P=!0;if((w.xr||R[f]===!1||(S=R.getAttribute("position"))!=null&&S.isInterleavedBufferAttribute||R.index&&(C=R.index)!=null&&C.isInterleavedBufferAttribute)&&(P=!1),P&&u){if(R[m]===void 0){let T=null;if(v.length>0){const L=v.shift();L&&!L.running&&(T=L)}if(!T&&g.length<3&&(T=new u,g.push(T)),T!=null&&!T.running){Gl&&console.log("<<<< worker start",T),R[m]="queued",performance.mark("bvh.create.start");const L=R.clone();T.generate(L).then(k=>{R[m]="done",R.boundsTree=k}).catch(k=>{R[m]="failed - "+k?.message,R[f]=!1}).finally(()=>{Gl&&console.log(">>>>> worker done"),v.push(T),L.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}else Gl&&console.warn("No worker available")}}else(!d||!P)&&(l(),r&&(performance.mark("bvh.create.start"),R.boundsTree=new r(R),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(b instanceof Hd){const P=b,T=A.raycast;s&&R.boundsTree?(A.acceleratedRaycast||(A.acceleratedRaycast=s.bind(A)),A.raycast=A.acceleratedRaycast):Gl&&console.warn("No bounds tree found for mesh",A.name);const L=P.firstHitOnly;return P.firstHitOnly=!1,P.intersectObject(A,!1,x),P.firstHitOnly=L,A.raycast=T,!0}else if(b instanceof tn){const P=R.boundsTree;if(P){const T=b;if(c.copy(A.matrixWorld).invert(),T.applyMatrix4(c),P.intersectsSphere(T)){const L=Nt(A),k=L.distanceTo(T.center),G=new Pk(A,k,L);x.push(G)}}return!0}return!1}n.runMeshBVHRaycast=e;let i=!1,s=null,r=null,o=null,a=null;function l(){i||(i=!0,Promise.resolve().then(()=>_Me).then(b=>{s=b.acceleratedRaycast,r=b.MeshBVH,o=b.StaticGeometryGenerator,a=b.computeBoundsTree}).catch(b=>{(Gl||je())&&console.warn("Failed to load mesh bvh library")}))}const c=new he;let h=!1,d=!1,u=null;const m=Symbol("Needle:MeshBVH-Worker"),f=Symbol("Needle:MeshBVH-CanUseWorker"),g=[],v=[];function y(){h=!0,d=!0,Promise.resolve().then(()=>EMe).then(b=>{u=b.GenerateMeshBVHWorker}).catch(b=>{(Gl||je())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{d=!1})}})(QS||(QS={}));const y9=Symbol("gltf-loader-internal-usage-tracker"),sme=te("debugusers"),ZS=class{constructor(n){p(this,"parser"),p(this,"_getDependency"),p(this,"_loadingId"),p(this,"_loadedObjects",new Set),this.parser=n,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(n){return ZS._loadingProcesses>0}beforeRoot(){ZS._loadingProcesses++;const n=this,e=this._getDependency;return this.parser.getDependency=function(i,s){const r=e.call(this,i,s);return r.then(o=>(o&&(n._loadedObjects.add(o),o[y9]=n._loadingId),o)),r},null}afterRoot(n){ZS._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const e of this._loadedObjects)delete e[y9],e instanceof ge&&(e.parent||e instanceof ue&&setTimeout(()=>{sme&&console.warn("> GLTF LOADER: Mesh not used in scene!",e),e.material=null,e.geometry=null},1e3));return null}};let Bk=ZS;p(Bk,"_loadingProcesses",0);class v9{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const s=(i=e?.reason)==null?void 0:i.path;if(s){const r=s[0];r&&r.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
4965
|
+
`+r.src),e.preventDefault())}})}}const YS=te("trackresources");function b9(){return YS==="dispose"}let Cm=!0;YS===0&&(Cm=!1);function rme(n){Cm=n}function A9(){return Cm}const x9=Symbol("disposable");function Ok(n,e){n&&(n[x9]=e,Mm&&console.warn("Set disposable",e,n))}const w9=Symbol("disposed");function ome(n){return n[w9]===!0}function Ki(n){var e;if(n){if(n[x9]===!1){Mm&&console.warn("Object is marked as not disposable",n);return}if(n[w9]=!0,n instanceof Is)Ki(n.environment),Ki(n.background),Ki(n.customDepthMaterial),Ki(n.customDistanceMaterial);else if(n instanceof Mo)Ki(n.geometry),Ki(n.material),Ki(n.skeleton),Ki(n.bindMatrix),Ki(n.bindMatrixInverse),Ki(n.customDepthMaterial),Ki(n.customDistanceMaterial),n.geometry=null,n.material=null,n.visible=!1;else if(n instanceof ue)Ki(n.geometry),Ki(n.material),Ki(n.customDepthMaterial),Ki(n.customDistanceMaterial),n.geometry=null,n.material=null,n.visible=!1;else if(n instanceof pt){l0(n);for(const i of Object.keys(n.attributes)){const s=n.attributes[i];Ki(s)}}else if(n instanceof $e||n instanceof Qo)Mm&&console.warn("BufferAttribute dispose not supported",n.count);else if(n instanceof Array)for(const i of n)i instanceof Ft&&Ki(i);else if(n instanceof Ft){l0(n);for(const s of Object.keys(n)){const r=n[s];r instanceof Vt&&(Ki(r),n[s]=null)}const i=n.uniforms;if(i)for(const s of Object.keys(i)){const r=i[s];r instanceof Vt?(Ki(r),i[s]=null):r instanceof Ce&&(Ki(r.value),r.value=null)}}else n instanceof Vt?(l0(n),l0(n.source),((e=n.source)==null?void 0:e.data)instanceof ImageBitmap&&l0(n.source.data)):n instanceof Ev?(l0(n.boneTexture),n.boneTexture=null):n instanceof Vp||!(n instanceof ge)&&Mm&&console.warn("Unknown object type",n)}}function l0(n){n&&((Mm||b9()||YS)&&console.warn("\u{1F9E8} FREE",n),n instanceof ImageBitmap?n.close():n instanceof dh?n.data=null:n.dispose())}function _9(n){(n instanceof ue||n instanceof Mo)&&(n.material=null,n.geometry=null)}const ame=new Set;function Dk(n,e,i=null,s){if(s||(s=ame,s.clear()),!n)return s;const r=n[jb];if(r)for(const o of r)s.has(o)||i?.call(null,o)!==!1&&(s.add(o),e&&Dk(o,!0,i,s));return s}function lme(n){return n[Qb]}const Mm=te("debugresourceusers")||te("debugmemory"),jb=Symbol("needle-resource-users"),Qb=Symbol("needle-resource-users-count");function ao(n,e){z_(n,e,function(i,s){Cm&&!HS.raycasting&&(KS(jb,this,i,!1),KS(jb,this,s,!0))})}Cm&&(ao(ue.prototype,"material"),ao(ue.prototype,"geometry"),ao(Ft.prototype,"map"),ao(Ft.prototype,"bumpMap"),ao(Ft.prototype,"alphaMap"),ao(Ft.prototype,"normalMap"),ao(Ft.prototype,"displacementMap"),ao(Ft.prototype,"roughnessMap"),ao(Ft.prototype,"metalnessMap"),ao(Ft.prototype,"emissiveMap"),ao(Ft.prototype,"specularMap"),ao(Ft.prototype,"envMap"),ao(Ft.prototype,"lightMap"),ao(Ft.prototype,"aoMap"),ao(Ft.prototype,"gradientMap"));function cme(n){if(Cm===!1)return;const e=n[jb];if(e)for(const i of e)KS(jb,i,n,!1)}Cm&&z_(Ft.prototype,"dispose",function(){cme(this)});let Gk=0;function KS(n,e,i,s){if(Gk>0)return;if(Array.isArray(i)){for(const o of i)KS(n,e,o,s);return}if(!i)return;let r=i[n];if(r||(r=new Set),s){if(e&&!r.has(e)){r.add(e);let o=i[Qb]||0;o+=1,i[Qb]=o,Mm&&console.warn(`\u{1F7E2} Added user of "${i.type}"`,e,i,o,"users:",r)}}else if(e&&r.has(e)){r.delete(e);let o=i[Qb]||0;o>0&&(o-=1,i[Qb]=o),Mm&&console.warn(`\u{1F534} Removed user of "${i.type}"`,e,i,o,"users:",r),o<=0&&(Bk.isLoading(i)||(YS&&console.warn(`\u{1F534} Removed all user of "${i.type}"`,i),b9()&&Ki(i)))}i[n]=r}try{z_(vh.prototype,"render",function(){Gk++},function(){Gk--})}catch(n){console.warn("Could not wrap WebGLRenderer.render",n)}const S9=te("debugcomponentevents");class Zb{static addComponentLifecylceEventListener(e,i){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let s=this.eventListeners.get(e);s||(s=[]),s.push(i),this.eventListeners.set(e,s),S9&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,i){const s=this.eventListeners.get(e);if(!s)return;const r=s.indexOf(i);r<0||s.splice(r,1)}static dispatchComponentLifecycleEvent(e,i){const s=this.eventListeners.get(e);if(S9&&console.log("Dispatching event "+e,s),!!s)for(const r of s)r(i)}}p(Zb,"eventListeners",new Map);const Yb=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),C9=Symbol("isUsingInstancing"),M9=Symbol("instancingRenderer"),Kb=Symbol("instancingAutoUpdateBounds");class dl{static isUsingInstancing(e){return e[C9]===!0}static getRenderer(e){return e[M9]||null}setAutoUpdateBounds(e,i){const s=dl.getRenderer(e);s&&(s[Kb]=i)}static markDirty(e,i=!0){if(e&&(this.isUsingInstancing(e)&&(e[Yb]=!0,e.matrixWorldNeedsUpdate=!0),i))for(const s of e.children)dl.markDirty(s,!0)}}function c0(n,e){try{e?n(e):n()}catch(i){return console.error(i),!1}return!0}const Nk=te("debugnewscripts"),hme=te("debughierarchy"),vn=[];function dme(){return vn.length>0}function JS(n){if(!(n.new_scripts.length<=0)){if(Nk&&console.log("Register new components",n.new_scripts.length,[...n.new_scripts],n.alias?"element: "+n.alias:n.hash,n),n.new_scripts_pre_setup_callbacks.length>0){for(const e of n.new_scripts_pre_setup_callbacks)e&&e();n.new_scripts_pre_setup_callbacks.length=0}vn.length=0,n.new_scripts.length>0&&vn.push(...n.new_scripts),n.new_scripts.length=0;for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.isComponent!==!0){(je()||Nk)&&console.error(`Registered script is not a Needle Engine component.
|
|
4966
4966
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
4967
4967
|
`,i),vn.splice(e,1),e--;continue}if(i.destroyed)continue;if(!i.gameObject){console.warn(`Component can not be initialized: no GameObject assigned.
|
|
4968
|
-
Did you add and remove a component in the same frame?`),vn.splice(e,1),e--;continue}i.context=n,Jb(i.gameObject),Fk(i,n)}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed){Uh(vn[e],n),vn.splice(e,1),e--;continue}if(i.registering)try{i.registering()}catch(s){console.error(s)}i.__internalAwake!==void 0&&(i.gameObject||console.error("Calling awake for a component without a GameObject",i,i.gameObject),Jb(i.gameObject),i.activeAndEnabled&&c0(i.__internalAwake.bind(i)))}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed||i.enabled===!1||(Jb(i.gameObject),i.activeAndEnabled===!1))continue;i.__internalEnable!==void 0&&(i.enabled=!0,c0(i.__internalEnable.bind(i)))}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed||!i.gameObject)continue;n.new_script_start.push(i)}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}vn.length=0;for(const e of n.new_scripts_post_setup_callbacks)e&&e();n.new_scripts_post_setup_callbacks.length=0}}function ume(n){n&&(n.__internalDisable(!0),Uh(n,n.context))}function
|
|
4969
|
-
Do you have circular references in your project? <a target="_blank" href="https://docs.needle.tools/circular-reference"> Click here for more information.`,n):console.error('Failed to update active state in hierarchy of "'+n.name+'"',n),console.warn(" \u2191 this error might be caused by circular references. Please make sure you don't have files with circular references (e.g. one GLB 1 is loading GLB 2 which is then loading GLB 1 again)."))}function T4(n,e,i,s=0){if(s>1e3)return console.warn("Hierarchy is too deep (> 1000 level) - will abort updating active state"),!1;const r=p0(n);if(e&&(e=r,e&&n.parent)){const l=n.parent;e=l[Ch],e===void 0&&(l instanceof Is||(e=!0))}const o=n[Ch]!==e;n[Ch]=e,o&&(hme&&console.warn("ACTIVE CHANGE",n.name,r,n.visible,e,"changed?"+o,n),i&&pme(n,l=>{e?l.enabled&&(c0(l.__internalAwake.bind(l)),l.enabled&&(l.__didEnable=!0,l.onEnable())):l.__didAwake&&l.enabled&&(l.__didEnable=!1,l.onDisable())}));let a=!0;if(n.children){const l=s+1;for(const c of n.children)T4(c,e,i,l)===!1&&(a=!1)}return a}function Jb(n){let e=!0,i=n,s=!1;for(;i&&i;){if(i.type==="Scene"&&(s=!0),!p0(i)){e=!1;break}i=i.parent}if(!n){console.error("GO is null");return}n[Ch]=e&&s}function pme(n,e){var i;if((i=n.userData)!=null&&i.components)for(const s of n.userData.components)e(s)}const $S=new Map,R4=Symbol("prewarmFlag"),Uk=Symbol("waitingForPrewarm"),Vk=te("debugprewarm");function mme(n,e){!n||n[R4]===!0||n[Uk]===!0||($S.has(e)||$S.set(e,[]),n[Uk]=!0,$S.get(e).push(n),Vk&&console.debug("register prewarm",n.name))}let Xk=null,Wk=null;function fme(n){if(!n)return;const e=$S.get(n);if(!(e!=null&&e.length))return;const i=n.mainCamera;if(i){Vk&&console.log("prewarm",e.length,"objects",[...e]);const s=n.renderer;if(s.compile){const r=n.scene;s.compile(r,i),Xk??(Xk=new c2(64)),Wk??(Wk=new l2(.001,9999999,Xk)),Wk.update(s,r);for(const o of e)o[R4]=!0,o[Uk]=!1;e.length=0,Vk&&console.log("prewarm done")}}}const gme=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function yme(n){return typeof n=="string"&&gme.test(n)}const tr=[];for(let n=0;n<256;++n)tr.push((n+256).toString(16).slice(1));function vme(n,e=0){return tr[n[e+0]]+tr[n[e+1]]+tr[n[e+2]]+tr[n[e+3]]+"-"+tr[n[e+4]]+tr[n[e+5]]+"-"+tr[n[e+6]]+tr[n[e+7]]+"-"+tr[n[e+8]]+tr[n[e+9]]+"-"+tr[n[e+10]]+tr[n[e+11]]+tr[n[e+12]]+tr[n[e+13]]+tr[n[e+14]]+tr[n[e+15]]}function bme(n){if(!yme(n))throw TypeError("Invalid UUID");let e;const i=new Uint8Array(16);return i[0]=(e=parseInt(n.slice(0,8),16))>>>24,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=e&255,i[4]=(e=parseInt(n.slice(9,13),16))>>>8,i[5]=e&255,i[6]=(e=parseInt(n.slice(14,18),16))>>>8,i[7]=e&255,i[8]=(e=parseInt(n.slice(19,23),16))>>>8,i[9]=e&255,i[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,i[11]=e/4294967296&255,i[12]=e>>>24&255,i[13]=e>>>16&255,i[14]=e>>>8&255,i[15]=e&255,i}function Ame(n){n=unescape(encodeURIComponent(n));const e=[];for(let i=0;i<n.length;++i)e.push(n.charCodeAt(i));return e}const xme="6ba7b810-9dad-11d1-80b4-00c04fd430c8",wme="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _me(n,e,i){function s(r,o,a,l){var c;if(typeof r=="string"&&(r=Ame(r)),typeof o=="string"&&(o=bme(o)),((c=o)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let h=new Uint8Array(16+r.length);if(h.set(o),h.set(r,o.length),h=i(h),h[6]=h[6]&15|e,h[8]=h[8]&63|128,a){l=l||0;for(let d=0;d<16;++d)a[l+d]=h[d];return a}return vme(h)}try{s.name=n}catch{}return s.DNS=xme,s.URL=wme,s}function Sme(n,e,i,s){switch(n){case 0:return e&i^~e&s;case 1:return e^i^s;case 2:return e&i^e&s^i&s;case 3:return e^i^s}}function Hk(n,e){return n<<e|n>>>32-e}function Cme(n){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){const a=unescape(encodeURIComponent(n));n=[];for(let l=0;l<a.length;++l)n.push(a.charCodeAt(l))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);const s=n.length/4+2,r=Math.ceil(s/16),o=new Array(r);for(let a=0;a<r;++a){const l=new Uint32Array(16);for(let c=0;c<16;++c)l[c]=n[a*64+c*4]<<24|n[a*64+c*4+1]<<16|n[a*64+c*4+2]<<8|n[a*64+c*4+3];o[a]=l}o[r-1][14]=(n.length-1)*8/Math.pow(2,32),o[r-1][14]=Math.floor(o[r-1][14]),o[r-1][15]=(n.length-1)*8&4294967295;for(let a=0;a<r;++a){const l=new Uint32Array(80);for(let f=0;f<16;++f)l[f]=o[a][f];for(let f=16;f<80;++f)l[f]=Hk(l[f-3]^l[f-8]^l[f-14]^l[f-16],1);let c=i[0],h=i[1],d=i[2],u=i[3],m=i[4];for(let f=0;f<80;++f){const g=Math.floor(f/20),v=Hk(c,5)+Sme(g,h,d,u)+m+e[g]+l[f]>>>0;m=u,u=d,d=Hk(h,30)>>>0,h=c,c=v}i[0]=i[0]+c>>>0,i[1]=i[1]+h>>>0,i[2]=i[2]+d>>>0,i[3]=i[3]+u>>>0,i[4]=i[4]+m>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,i[0]&255,i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,i[1]&255,i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,i[2]&255,i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,i[3]&255,i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,i[4]&255]}const Mme=_me("v5",80,Cme),I4=Mme;xi.registerCallback(_i.ContextCreated,n=>{const e=n.context;D4(e),k4(e)});const eC=te("debugcomponents"),L4="eff8ba80-635d-11ec-90d6-0242ac120003";class xr{constructor(e){p(this,"_originalSeed"),p(this,"_seed"),typeof e=="string"&&(e=xr.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return I4(e,L4);const i=this._seed;return this._seed-=1,I4(i.toString(),L4)}initialize(e){typeof e=="string"?this._seed=xr.hash(e):this._seed=e}static createFromString(e){return new xr(this.hash(e))}static hash(e){let i=0;for(let s=0;s<e.length;s++)i=e.charCodeAt(s)+((i<<5)-i);return i}}var P4=(n=>(n.NewInstanceCreated="new-instance-created",n.InstanceDestroyed="instance-destroyed",n))(P4||{});class Eme{constructor(e){p(this,"guid"),p(this,"dontSave"),this.guid=e}}function qb(n,e,i=!0,s){if(!n)return;const r=n;if(oa(n,i),!e){console.warn("Can not send destroy: No networking connection provided",n.guid);return}if(!e.isConnected){je()&&console.debug("Can not send destroy: not connected",n.guid);return}let o=n.guid;if(!o&&r.uuid&&(o=r.uuid),!o){console.warn("Can not send destroy: failed to find guid",n);return}jk(o,e,s)}function jk(n,e,i){const s=new Eme(n);i?.saveInRoom===!1&&(s.dontSave=!0),e.send("instance-destroyed",s,Bl.Queued)}function k4(n){n.connection.beginListen("instance-destroyed",e=>{eC&&console.log("[Remote] Destroyed",n.scene,e);const i=oB(e.guid,n.scene);i&&oa(i)})}class Tme{constructor(e,i,s){p(this,"filename"),p(this,"hash"),p(this,"size"),this.filename=e,this.hash=i,this.size=s}}class B4{constructor(e,i){p(this,"guid"),p(this,"originalGuid"),p(this,"seed"),p(this,"visible"),p(this,"hostData"),p(this,"dontSave"),p(this,"parent"),p(this,"position"),p(this,"rotation"),p(this,"scale"),p(this,"preventCreation"),p(this,"deleteStateOnDisconnect"),this.originalGuid=e,this.guid=i}}function Qk(n,e,i,s){var r,o;const a=n;if(!a.guid)return console.warn("Can not instantiate: No guid",a),null;if(e.context||(e.context=Pt.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const l=e?{...e}:null,{instance:c,seed:h}=Rme(a,e);if(c){const d=c;if(d.guid){eC&&console.log("[Local] new instance","gameobject:",c?.guid);const u=new B4(a.guid,d.guid);u.seed=h,e.deleteOnDisconnect===!0&&(u.deleteStateOnDisconnect=!0),l&&(l.position&&(u.position={x:l.position.x,y:l.position.y,z:l.position.z}),l.rotation&&(u.rotation={x:l.rotation.x,y:l.rotation.y,z:l.rotation.z,w:l.rotation.w}),l.scale&&(u.scale={x:l.scale.x,y:l.scale.y,z:l.scale.z})),u.position||(u.position={x:d.position.x,y:d.position.y,z:d.position.z}),u.rotation||(u.rotation={x:d.quaternion.x,y:d.quaternion.y,z:d.quaternion.z,w:d.quaternion.w}),u.scale||(u.scale={x:d.scale.x,y:d.scale.y,z:d.scale.z}),u.visible=a.visible,l!=null&&l.parent&&(typeof l.parent=="string"?u.parent=l.parent:u.parent=l.parent.guid),u.hostData=i,s===!1&&(u.dontSave=!0),!((r=e?.context)!=null&&r.connection)&&je()&&console.debug("Object will be instantiated but it will not be synced: not connected",a.guid),e.context.connection.isInRoom&&h0.push(new WeakRef(d)),(o=e?.context)==null||o.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",d)}return c}function O4(){return Math.random()*9999999}const h0=new Array;function D4(n){n.connection.beginListen("new-instance-created",async e=>{const i=await Ime(e.originalGuid,n.scene);if(e.preventCreation===!0)return;if(!i){console.warn("could not find object that was instantiated: "+e.guid);return}console.log(i);const s=new tc;e.position&&(s.position=new M(e.position.x,e.position.y,e.position.z)),e.rotation&&(s.rotation=new Se(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(s.scale=new M(e.scale.x,e.scale.y,e.scale.z)),s.parent=e.parent,e.seed&&(s.idProvider=new xr(e.seed)),s.visible=e.visible,s.context=n,eC&&n.alias&&console.log("[Remote] instantiate in: "+n.alias);const r=f0(i,s);h0.push(new WeakRef(r)),r&&(e.parent==="scene"&&n.scene.add(r),eC&&console.log("[Remote] new instance","gameobject:",r?.guid,i))}),n.connection.beginListen("left-room",()=>{h0.length>0&&console.debug(`Left networking room, cleaning up ${h0.length} instantiated objects`);for(const e of h0){const i=e.deref();i&&i.destroy()}h0.length=0})}function Rme(n,e){const i=O4(),s=e??new tc;s.idProvider=new xr(i);const r=f0(n,s);return{seed:i,instance:r}}const G4={};function N4(n,e){G4[n]=e}async function Ime(n,e){const i=G4[n];if(i!=null){const s=await i(n);if(s)return s}return F4(n,e)}function F4(n,e){if(e===null||!n)return null;if(e.guid===n)return e;if(e.children)for(const i of e.children){const s=F4(n,i);if(s)return s}return null}const $b=te("gizmos"),Ds=te("debugextension"),Zk=te("debugtypes");class Lme{constructor(){p(this,"_types",new Map),Zk&&console.warn("TypeStore: Created",this)}add(e,i){Zk&&console.warn("ADD TYPE",e);const s=this._types.get(e);s?Zk&&s!==i&&console.warn("Type name exists multiple times in your project and may lead to runtime errors:",e):this._types.set(e,i)}get(e){return this._types.get(e)||null}getKey(e){for(const[i,s]of this._types)if(s===e)return i;return null}}const Pme=Symbol("BuiltInType"),Z=new Lme,kme=function(n){Z.get(n.name)||Z.add(n.name,n)},Yk=te("debugresolvedependencies"),Bme=["/extensions/","extensions/"],Ome=[{prefix:"/nodes/",dependencyName:"node"},{prefix:"/meshes/",dependencyName:"mesh"},{prefix:"/materials/",dependencyName:"material"},{prefix:"/textures/",dependencyName:"texture"},{prefix:"/animations/",dependencyName:"animation"},{prefix:"nodes/",dependencyName:"node"},{prefix:"meshes/",dependencyName:"mesh"},{prefix:"materials/",dependencyName:"material"},{prefix:"textures/",dependencyName:"texture"},{prefix:"animations/",dependencyName:"animation"}];async function Kk(n,e){Yk&&console.log(n,e);const i=[];Jk(Ome,n,e,i);const s=await Promise.all(i);return typeof e=="string"&&s.length===1?s[0]:s}function z4(n,e){return!n||!e?!1:n["needle:identifier"]!=null&&e["needle:identifier"]!=null?n["needle:identifier"]===e["needle:identifier"]:!1}function Dme(n,e){n["needle:identifier"]=e}function Jk(n,e,i,s){if(typeof i=="object"&&i!==void 0&&i!==null)for(const r of Object.keys(i)){const o=i[r];if(typeof o=="string"){const a=U4(e,o);if(a!=null)typeof a.then=="function"?s.push(a.then(l=>i[r]=l)):i[r]=a;else{const l=V4(n,e,o);if(l){s.push(l.then(c=>(i[r]=c,c)));continue}}}else if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a],c=U4(e,l);if(c!==null){typeof c.then=="function"?s.push(c.then(h=>o[a]=h)):o[a]=c;continue}for(const h of n){const d=X4(h.prefix,l);if(d>=0){Yk&&console.log(h,d,h.dependencyName),s.push(e.getDependency(h.dependencyName,d).then(u=>o[a]=u));break}}typeof l=="object"&&Jk(n,e,l,s)}else typeof o=="object"&&Jk(n,e,o,s)}else if(typeof i=="string"){const r=V4(n,e,i);r&&s.push(r)}}function U4(n,e){if(n&&n.plugins&&typeof e=="string"){for(const i of Bme)if(e.startsWith(i)){let s=e.substring(i.length);const r=s.indexOf("/");r>=0&&(s=s.substring(0,r));const o=n.plugins[s];if(Ds&&console.log(s,o),typeof o?.resolve=="function"){const a=e.substring(i.length+s.length+1);return o.resolve(n,a)}break}}return null}function V4(n,e,i){for(const s of n){const r=X4(s.prefix,i);if(r>=0)return Yk&&console.warn("GET DEPENDENCY",s,r,s.dependencyName),e.getDependency(s.dependencyName,r)}return null}function X4(n,e){if(typeof e=="string"&&e.startsWith(n)){const i=e.substring(n.length),s=Number.parseInt(i);if(s>=0)return s}return-1}const qk="NEEDLE_persistent_assets";function Gme(n){return n?.___persistentAsset===!0}class Nme{constructor(e){p(this,"parser"),this.parser=e}get name(){return qk}async afterRoot(e){var i,s;if(!((s=(i=this.parser)==null?void 0:i.json)!=null&&s.extensions))return;const r=this.parser.json.extensions[qk];if(!r)return;Ds&&console.log(r);const o=new Array;for(const a of r?.assets){const l=Kk(this.parser,a);l&&o.push(l)}await Promise.all(o)}resolve(e,i){const s=Number.parseInt(i);if(s>=0){Ds&&console.log(i);const r=e.json.extensions[qk];if(r){const o=r?.assets[s];if(o&&typeof o=="object"){o.___persistentAsset=!0;const a=o.__type;a&&Z.get(a)}return o}}return null}}const xc=te("debugserializer");class Fme{constructor(){p(this,"typeMap",new Map)}register(e,i){if(this.typeMap.has(e)){const s=this.typeMap.get(e);if(s===i)return;xc&&console.warn("Type: "+e+" is already registered",i,s)}xc&&console.log("Register type serializer",i.name,i,e),this.typeMap.set(e,i)}getSerializer(e){if(e)return this.typeMap.get(e)}getSerializerForConstructor(e,i=0){if(i>20)return;if(!e||!e.constructor){xc&&console.log("invalid type");return}const s=e.name,r=this.getSerializer(e);if(r!==void 0)return xc&&console.log("FOUND SERIALIZER",r?.name,e.name,e.constructor.name,"for type: "+s,r,e,this.typeMap),r;const o=Object.getPrototypeOf(e);if(o&&o!==e){const a=this.getSerializerForConstructor(o,++i);if(a){const l=o.constructor||o.prototype;xc&&console.log("FOUND SERIALIZER(in constructor) "+l.constructor.name,l.name,l,a),this.register(l,a)}return a}xc&&console.warn("No serializer found for "+s,e,e.name,e.constructor.name)}}const tC=new Fme;class Ha{constructor(e,i){if(p(this,"name"),this.name=i,Array.isArray(e))for(const s of e)tC.register(s,this);else tC.register(e,this)}}class zme{constructor(){p(this,"isDevMode",io()),p(this,"cache",{})}registerDefinedKeys(e,i){if(this.isDevMode&&this.cache[e]===void 0){this.cache[e]=Object.keys(i);const s=i;s.$serializedTypes&&Object.keys(s.$serializedTypes)&&this.cache[e].push(...Object.keys(s.$serializedTypes)),xc&&console.log("registerDefinedKeys for "+e,this.cache[e],i)}}getDefinedKey(e,i){return this.cache[e]===void 0?!1:this.cache[e].includes(i)}}class $k{constructor(e){p(this,"root"),p(this,"gltf"),p(this,"gltfId"),p(this,"object"),p(this,"target"),p(this,"nodeId"),p(this,"nodeToObject"),p(this,"objectToNode"),p(this,"context"),p(this,"path"),p(this,"type"),p(this,"serializable"),p(this,"implementationInformation"),this.root=e}}function W4(n,e){const i=n.$serializedTypes;if(i===void 0)return null;const s={};for(const r in i){const o=n[r];if(o!=null&&typeof o=="object"){const a=tC.getSerializerForConstructor(o);if(a){s[r]=a.onSerialize(o,e);continue}}s[r]=o}return s.name=n.constructor.name,typeof n.guid=="string"&&(s.guid=n.guid),s}const iC=[];function H4(n,e){if(!n)return e;typeof n.$serializedTypes=="object"&&(e||(e={}),Object.assign(e,n.$serializedTypes));const i=Object.getPrototypeOf(n);return H4(i,e)}function nC(n,e,i){if(!n)return!1;if(i.target=n,n.onBeforeDeserialize!==void 0){const r=n.onBeforeDeserialize(e,i);if(typeof r=="boolean")return r}const s=H4(n);if(e){if(typeof e.guid=="string"&&(n.guid=e.guid),s)for(const r in s){let o=function(c){const h=c.type;return h?eB(l,h,i,void 0,n[r]):eB(l,c,i,void 0,n[r])};const a=s[r],l=e[r];if(xc&&console.log(r,l,n,a),!(n[r]!==void 0&&l===void 0)&&(i.type=void 0,i.path=r,i.serializable=a,!(n.onBeforeDeserializeMember!==void 0&&n.onBeforeDeserializeMember(r,l,i)===!0))){if(a===null)n[r]=l;else{if(Array.isArray(a))for(let c=0;c<a.length;c++){const h=a[c],d=o(h);if(d!==void 0||c===a.length-1){n[r]=d;break}}else n[r]=o(a);iC.length=0}n.onAfterDeserializeMember!==void 0&&n.onAfterDeserializeMember(r,l,i)}}Xme(n,e)}return Vme(n,e,i.implementationInformation),n.onAfterDeserialize!==void 0&&n.onAfterDeserialize(e,i),!0}const Ume=te("noerrors");function Vme(n,e,i){var s,r;if(Ume||!e||!io()||!n||n.constructor&&n.constructor[Pme]===!0)return;const o=(s=n.constructor)==null?void 0:s.name,a=Object.getOwnPropertyNames(e);for(const l of a){if(l==="sourceId")continue;const c=n[l];if(c==null)continue;const h=e[l];if(i?.getDefinedKey(o,l)===!1){const d=l.charAt(0).toUpperCase()+l.slice(1);i.getDefinedKey(o,d)&&(hc(Ko.Warn,'<strong>Please rename</strong> "'+d+'" to "'+l+'" in '+o),console.warn('Please use lowercase for field: "'+d+'" in '+o,h,n));continue}if(h!=null){if(typeof h=="object"&&(c===void 0||!c.isObject3D)){if(typeof h.node=="number"||typeof h.guid=="string"){if(h.could_not_resolve)continue;if(!(c!==void 0&&Object.keys(c).length>1)){hc(Ko.Warn,`<strong>Missing serialization for object reference!</strong>
|
|
4968
|
+
Did you add and remove a component in the same frame?`),vn.splice(e,1),e--;continue}i.context=n,Jb(i.gameObject),Fk(i,n)}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed){Uh(vn[e],n),vn.splice(e,1),e--;continue}if(i.registering)try{i.registering()}catch(s){console.error(s)}i.__internalAwake!==void 0&&(i.gameObject||console.error("Calling awake for a component without a GameObject",i,i.gameObject),Jb(i.gameObject),i.activeAndEnabled&&c0(i.__internalAwake.bind(i)))}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed||i.enabled===!1||(Jb(i.gameObject),i.activeAndEnabled===!1))continue;i.__internalEnable!==void 0&&(i.enabled=!0,c0(i.__internalEnable.bind(i)))}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}for(let e=0;e<vn.length;e++)try{const i=vn[e];if(i.destroyed||!i.gameObject)continue;n.new_script_start.push(i)}catch(i){console.error(i),Uh(vn[e],n),vn.splice(e,1),e--}vn.length=0;for(const e of n.new_scripts_post_setup_callbacks)e&&e();n.new_scripts_post_setup_callbacks.length=0}}function ume(n){n&&(n.__internalDisable(!0),Uh(n,n.context))}function E9(n,e){for(let i=0;i<n.new_script_start.length;i++)try{const s=n.new_script_start[i];if(e!==void 0&&s.gameObject!==e||s.destroyed||s.activeAndEnabled===!1)continue;c0(s.__internalAwake.bind(s)),s.enabled&&(c0(s.__internalEnable.bind(s)),c0(s.__internalStart.bind(s)),n.new_script_start.splice(i,1),i--)}catch(s){console.error(s),Uh(n.new_script_start[i],n),n.new_script_start.splice(i,1),i--}}function Fk(n,e){e.scripts.indexOf(n)===-1&&(e.scripts.push(n),n.earlyUpdate&&e.scripts_earlyUpdate.push(n),n.update&&e.scripts_update.push(n),n.lateUpdate&&e.scripts_lateUpdate.push(n),n.onBeforeRender&&e.scripts_onBeforeRender.push(n),n.onAfterRender&&e.scripts_onAfterRender.push(n),n.onPausedChanged&&e.scripts_pausedChanged.push(n),zk(n,null)&&e.new_scripts_xr.push(n),zk(n,"immersive-vr")&&e.scripts_immersive_vr.push(n),zk(n,"immersive-ar")&&e.scripts_immersive_ar.push(n))}function Uh(n,e){Wa(n,e.new_scripts),Wa(n,e.new_script_start),Wa(n,e.scripts),Wa(n,e.scripts_earlyUpdate),Wa(n,e.scripts_update),Wa(n,e.scripts_lateUpdate),Wa(n,e.scripts_onBeforeRender),Wa(n,e.scripts_onAfterRender),Wa(n,e.scripts_pausedChanged),Wa(n,e.new_scripts_xr),Wa(n,e.scripts_immersive_vr),Wa(n,e.scripts_immersive_ar),e.stopAllCoroutinesFrom(n)}function Wa(n,e){const i=e.indexOf(n);i>=0&&e.splice(i,1)}function zk(n,e){var i;if(n){const s=n;if(s.onBeforeXR||s.onEnterXR||s.onUpdateXR||s.onLeaveXR||s.onXRControllerAdded||s.onXRControllerRemoved)return!(e!=null&&((i=s.supportsXR)==null?void 0:i.call(s,e))===!1)}return!1}function qS(n){if(n||(n=xi.Current.scene),!n){console.trace("Invalid call - no current context.");return}const e=p0(n);T9(n,e,!0)||(Nk||je()?console.error(`Error updating hierarchy
|
|
4969
|
+
Do you have circular references in your project? <a target="_blank" href="https://docs.needle.tools/circular-reference"> Click here for more information.`,n):console.error('Failed to update active state in hierarchy of "'+n.name+'"',n),console.warn(" \u2191 this error might be caused by circular references. Please make sure you don't have files with circular references (e.g. one GLB 1 is loading GLB 2 which is then loading GLB 1 again)."))}function T9(n,e,i,s=0){if(s>1e3)return console.warn("Hierarchy is too deep (> 1000 level) - will abort updating active state"),!1;const r=p0(n);if(e&&(e=r,e&&n.parent)){const l=n.parent;e=l[Ch],e===void 0&&(l instanceof Is||(e=!0))}const o=n[Ch]!==e;n[Ch]=e,o&&(hme&&console.warn("ACTIVE CHANGE",n.name,r,n.visible,e,"changed?"+o,n),i&&pme(n,l=>{e?l.enabled&&(c0(l.__internalAwake.bind(l)),l.enabled&&(l.__didEnable=!0,l.onEnable())):l.__didAwake&&l.enabled&&(l.__didEnable=!1,l.onDisable())}));let a=!0;if(n.children){const l=s+1;for(const c of n.children)T9(c,e,i,l)===!1&&(a=!1)}return a}function Jb(n){let e=!0,i=n,s=!1;for(;i&&i;){if(i.type==="Scene"&&(s=!0),!p0(i)){e=!1;break}i=i.parent}if(!n){console.error("GO is null");return}n[Ch]=e&&s}function pme(n,e){var i;if((i=n.userData)!=null&&i.components)for(const s of n.userData.components)e(s)}const $S=new Map,R9=Symbol("prewarmFlag"),Uk=Symbol("waitingForPrewarm"),Vk=te("debugprewarm");function mme(n,e){!n||n[R9]===!0||n[Uk]===!0||($S.has(e)||$S.set(e,[]),n[Uk]=!0,$S.get(e).push(n),Vk&&console.debug("register prewarm",n.name))}let Xk=null,Wk=null;function fme(n){if(!n)return;const e=$S.get(n);if(!(e!=null&&e.length))return;const i=n.mainCamera;if(i){Vk&&console.log("prewarm",e.length,"objects",[...e]);const s=n.renderer;if(s.compile){const r=n.scene;s.compile(r,i),Xk??(Xk=new c2(64)),Wk??(Wk=new l2(.001,9999999,Xk)),Wk.update(s,r);for(const o of e)o[R9]=!0,o[Uk]=!1;e.length=0,Vk&&console.log("prewarm done")}}}const gme=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function yme(n){return typeof n=="string"&&gme.test(n)}const tr=[];for(let n=0;n<256;++n)tr.push((n+256).toString(16).slice(1));function vme(n,e=0){return tr[n[e+0]]+tr[n[e+1]]+tr[n[e+2]]+tr[n[e+3]]+"-"+tr[n[e+4]]+tr[n[e+5]]+"-"+tr[n[e+6]]+tr[n[e+7]]+"-"+tr[n[e+8]]+tr[n[e+9]]+"-"+tr[n[e+10]]+tr[n[e+11]]+tr[n[e+12]]+tr[n[e+13]]+tr[n[e+14]]+tr[n[e+15]]}function bme(n){if(!yme(n))throw TypeError("Invalid UUID");let e;const i=new Uint8Array(16);return i[0]=(e=parseInt(n.slice(0,8),16))>>>24,i[1]=e>>>16&255,i[2]=e>>>8&255,i[3]=e&255,i[4]=(e=parseInt(n.slice(9,13),16))>>>8,i[5]=e&255,i[6]=(e=parseInt(n.slice(14,18),16))>>>8,i[7]=e&255,i[8]=(e=parseInt(n.slice(19,23),16))>>>8,i[9]=e&255,i[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,i[11]=e/4294967296&255,i[12]=e>>>24&255,i[13]=e>>>16&255,i[14]=e>>>8&255,i[15]=e&255,i}function Ame(n){n=unescape(encodeURIComponent(n));const e=[];for(let i=0;i<n.length;++i)e.push(n.charCodeAt(i));return e}const xme="6ba7b810-9dad-11d1-80b4-00c04fd430c8",wme="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function _me(n,e,i){function s(r,o,a,l){var c;if(typeof r=="string"&&(r=Ame(r)),typeof o=="string"&&(o=bme(o)),((c=o)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let h=new Uint8Array(16+r.length);if(h.set(o),h.set(r,o.length),h=i(h),h[6]=h[6]&15|e,h[8]=h[8]&63|128,a){l=l||0;for(let d=0;d<16;++d)a[l+d]=h[d];return a}return vme(h)}try{s.name=n}catch{}return s.DNS=xme,s.URL=wme,s}function Sme(n,e,i,s){switch(n){case 0:return e&i^~e&s;case 1:return e^i^s;case 2:return e&i^e&s^i&s;case 3:return e^i^s}}function Hk(n,e){return n<<e|n>>>32-e}function Cme(n){const e=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){const a=unescape(encodeURIComponent(n));n=[];for(let l=0;l<a.length;++l)n.push(a.charCodeAt(l))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);const s=n.length/4+2,r=Math.ceil(s/16),o=new Array(r);for(let a=0;a<r;++a){const l=new Uint32Array(16);for(let c=0;c<16;++c)l[c]=n[a*64+c*4]<<24|n[a*64+c*4+1]<<16|n[a*64+c*4+2]<<8|n[a*64+c*4+3];o[a]=l}o[r-1][14]=(n.length-1)*8/Math.pow(2,32),o[r-1][14]=Math.floor(o[r-1][14]),o[r-1][15]=(n.length-1)*8&4294967295;for(let a=0;a<r;++a){const l=new Uint32Array(80);for(let f=0;f<16;++f)l[f]=o[a][f];for(let f=16;f<80;++f)l[f]=Hk(l[f-3]^l[f-8]^l[f-14]^l[f-16],1);let c=i[0],h=i[1],d=i[2],u=i[3],m=i[4];for(let f=0;f<80;++f){const g=Math.floor(f/20),v=Hk(c,5)+Sme(g,h,d,u)+m+e[g]+l[f]>>>0;m=u,u=d,d=Hk(h,30)>>>0,h=c,c=v}i[0]=i[0]+c>>>0,i[1]=i[1]+h>>>0,i[2]=i[2]+d>>>0,i[3]=i[3]+u>>>0,i[4]=i[4]+m>>>0}return[i[0]>>24&255,i[0]>>16&255,i[0]>>8&255,i[0]&255,i[1]>>24&255,i[1]>>16&255,i[1]>>8&255,i[1]&255,i[2]>>24&255,i[2]>>16&255,i[2]>>8&255,i[2]&255,i[3]>>24&255,i[3]>>16&255,i[3]>>8&255,i[3]&255,i[4]>>24&255,i[4]>>16&255,i[4]>>8&255,i[4]&255]}const Mme=_me("v5",80,Cme),I9=Mme;xi.registerCallback(_i.ContextCreated,n=>{const e=n.context;D9(e),k9(e)});const eC=te("debugcomponents"),L9="eff8ba80-635d-11ec-90d6-0242ac120003";class xr{constructor(e){p(this,"_originalSeed"),p(this,"_seed"),typeof e=="string"&&(e=xr.hash(e)),this._originalSeed=e,this._seed=e}get seed(){return this._seed}set seed(e){this._seed=e}reset(){this._seed=this._originalSeed}generateUUID(e){if(typeof e=="string")return I9(e,L9);const i=this._seed;return this._seed-=1,I9(i.toString(),L9)}initialize(e){typeof e=="string"?this._seed=xr.hash(e):this._seed=e}static createFromString(e){return new xr(this.hash(e))}static hash(e){let i=0;for(let s=0;s<e.length;s++)i=e.charCodeAt(s)+((i<<5)-i);return i}}var P9=(n=>(n.NewInstanceCreated="new-instance-created",n.InstanceDestroyed="instance-destroyed",n))(P9||{});class Eme{constructor(e){p(this,"guid"),p(this,"dontSave"),this.guid=e}}function qb(n,e,i=!0,s){if(!n)return;const r=n;if(oa(n,i),!e){console.warn("Can not send destroy: No networking connection provided",n.guid);return}if(!e.isConnected){je()&&console.debug("Can not send destroy: not connected",n.guid);return}let o=n.guid;if(!o&&r.uuid&&(o=r.uuid),!o){console.warn("Can not send destroy: failed to find guid",n);return}jk(o,e,s)}function jk(n,e,i){const s=new Eme(n);i?.saveInRoom===!1&&(s.dontSave=!0),e.send("instance-destroyed",s,Bl.Queued)}function k9(n){n.connection.beginListen("instance-destroyed",e=>{eC&&console.log("[Remote] Destroyed",n.scene,e);const i=oB(e.guid,n.scene);i&&oa(i)})}class Tme{constructor(e,i,s){p(this,"filename"),p(this,"hash"),p(this,"size"),this.filename=e,this.hash=i,this.size=s}}class B9{constructor(e,i){p(this,"guid"),p(this,"originalGuid"),p(this,"seed"),p(this,"visible"),p(this,"hostData"),p(this,"dontSave"),p(this,"parent"),p(this,"position"),p(this,"rotation"),p(this,"scale"),p(this,"preventCreation"),p(this,"deleteStateOnDisconnect"),this.originalGuid=e,this.guid=i}}function Qk(n,e,i,s){var r,o;const a=n;if(!a.guid)return console.warn("Can not instantiate: No guid",a),null;if(e.context||(e.context=Pt.Current),!e.context)return console.error("Missing network instantiate options / reference to network connection in sync instantiate"),null;const l=e?{...e}:null,{instance:c,seed:h}=Rme(a,e);if(c){const d=c;if(d.guid){eC&&console.log("[Local] new instance","gameobject:",c?.guid);const u=new B9(a.guid,d.guid);u.seed=h,e.deleteOnDisconnect===!0&&(u.deleteStateOnDisconnect=!0),l&&(l.position&&(u.position={x:l.position.x,y:l.position.y,z:l.position.z}),l.rotation&&(u.rotation={x:l.rotation.x,y:l.rotation.y,z:l.rotation.z,w:l.rotation.w}),l.scale&&(u.scale={x:l.scale.x,y:l.scale.y,z:l.scale.z})),u.position||(u.position={x:d.position.x,y:d.position.y,z:d.position.z}),u.rotation||(u.rotation={x:d.quaternion.x,y:d.quaternion.y,z:d.quaternion.z,w:d.quaternion.w}),u.scale||(u.scale={x:d.scale.x,y:d.scale.y,z:d.scale.z}),u.visible=a.visible,l!=null&&l.parent&&(typeof l.parent=="string"?u.parent=l.parent:u.parent=l.parent.guid),u.hostData=i,s===!1&&(u.dontSave=!0),!((r=e?.context)!=null&&r.connection)&&je()&&console.debug("Object will be instantiated but it will not be synced: not connected",a.guid),e.context.connection.isInRoom&&h0.push(new WeakRef(d)),(o=e?.context)==null||o.connection.send("new-instance-created",u)}else console.warn("Missing guid, can not send new instance event",d)}return c}function O9(){return Math.random()*9999999}const h0=new Array;function D9(n){n.connection.beginListen("new-instance-created",async e=>{const i=await Ime(e.originalGuid,n.scene);if(e.preventCreation===!0)return;if(!i){console.warn("could not find object that was instantiated: "+e.guid);return}console.log(i);const s=new tc;e.position&&(s.position=new M(e.position.x,e.position.y,e.position.z)),e.rotation&&(s.rotation=new Se(e.rotation.x,e.rotation.y,e.rotation.z,e.rotation.w)),e.scale&&(s.scale=new M(e.scale.x,e.scale.y,e.scale.z)),s.parent=e.parent,e.seed&&(s.idProvider=new xr(e.seed)),s.visible=e.visible,s.context=n,eC&&n.alias&&console.log("[Remote] instantiate in: "+n.alias);const r=f0(i,s);h0.push(new WeakRef(r)),r&&(e.parent==="scene"&&n.scene.add(r),eC&&console.log("[Remote] new instance","gameobject:",r?.guid,i))}),n.connection.beginListen("left-room",()=>{h0.length>0&&console.debug(`Left networking room, cleaning up ${h0.length} instantiated objects`);for(const e of h0){const i=e.deref();i&&i.destroy()}h0.length=0})}function Rme(n,e){const i=O9(),s=e??new tc;s.idProvider=new xr(i);const r=f0(n,s);return{seed:i,instance:r}}const G9={};function N9(n,e){G9[n]=e}async function Ime(n,e){const i=G9[n];if(i!=null){const s=await i(n);if(s)return s}return F9(n,e)}function F9(n,e){if(e===null||!n)return null;if(e.guid===n)return e;if(e.children)for(const i of e.children){const s=F9(n,i);if(s)return s}return null}const $b=te("gizmos"),Ds=te("debugextension"),Zk=te("debugtypes");class Lme{constructor(){p(this,"_types",new Map),Zk&&console.warn("TypeStore: Created",this)}add(e,i){Zk&&console.warn("ADD TYPE",e);const s=this._types.get(e);s?Zk&&s!==i&&console.warn("Type name exists multiple times in your project and may lead to runtime errors:",e):this._types.set(e,i)}get(e){return this._types.get(e)||null}getKey(e){for(const[i,s]of this._types)if(s===e)return i;return null}}const Pme=Symbol("BuiltInType"),Z=new Lme,kme=function(n){Z.get(n.name)||Z.add(n.name,n)},Yk=te("debugresolvedependencies"),Bme=["/extensions/","extensions/"],Ome=[{prefix:"/nodes/",dependencyName:"node"},{prefix:"/meshes/",dependencyName:"mesh"},{prefix:"/materials/",dependencyName:"material"},{prefix:"/textures/",dependencyName:"texture"},{prefix:"/animations/",dependencyName:"animation"},{prefix:"nodes/",dependencyName:"node"},{prefix:"meshes/",dependencyName:"mesh"},{prefix:"materials/",dependencyName:"material"},{prefix:"textures/",dependencyName:"texture"},{prefix:"animations/",dependencyName:"animation"}];async function Kk(n,e){Yk&&console.log(n,e);const i=[];Jk(Ome,n,e,i);const s=await Promise.all(i);return typeof e=="string"&&s.length===1?s[0]:s}function z9(n,e){return!n||!e?!1:n["needle:identifier"]!=null&&e["needle:identifier"]!=null?n["needle:identifier"]===e["needle:identifier"]:!1}function Dme(n,e){n["needle:identifier"]=e}function Jk(n,e,i,s){if(typeof i=="object"&&i!==void 0&&i!==null)for(const r of Object.keys(i)){const o=i[r];if(typeof o=="string"){const a=U9(e,o);if(a!=null)typeof a.then=="function"?s.push(a.then(l=>i[r]=l)):i[r]=a;else{const l=V9(n,e,o);if(l){s.push(l.then(c=>(i[r]=c,c)));continue}}}else if(Array.isArray(o))for(let a=0;a<o.length;a++){const l=o[a],c=U9(e,l);if(c!==null){typeof c.then=="function"?s.push(c.then(h=>o[a]=h)):o[a]=c;continue}for(const h of n){const d=X9(h.prefix,l);if(d>=0){Yk&&console.log(h,d,h.dependencyName),s.push(e.getDependency(h.dependencyName,d).then(u=>o[a]=u));break}}typeof l=="object"&&Jk(n,e,l,s)}else typeof o=="object"&&Jk(n,e,o,s)}else if(typeof i=="string"){const r=V9(n,e,i);r&&s.push(r)}}function U9(n,e){if(n&&n.plugins&&typeof e=="string"){for(const i of Bme)if(e.startsWith(i)){let s=e.substring(i.length);const r=s.indexOf("/");r>=0&&(s=s.substring(0,r));const o=n.plugins[s];if(Ds&&console.log(s,o),typeof o?.resolve=="function"){const a=e.substring(i.length+s.length+1);return o.resolve(n,a)}break}}return null}function V9(n,e,i){for(const s of n){const r=X9(s.prefix,i);if(r>=0)return Yk&&console.warn("GET DEPENDENCY",s,r,s.dependencyName),e.getDependency(s.dependencyName,r)}return null}function X9(n,e){if(typeof e=="string"&&e.startsWith(n)){const i=e.substring(n.length),s=Number.parseInt(i);if(s>=0)return s}return-1}const qk="NEEDLE_persistent_assets";function Gme(n){return n?.___persistentAsset===!0}class Nme{constructor(e){p(this,"parser"),this.parser=e}get name(){return qk}async afterRoot(e){var i,s;if(!((s=(i=this.parser)==null?void 0:i.json)!=null&&s.extensions))return;const r=this.parser.json.extensions[qk];if(!r)return;Ds&&console.log(r);const o=new Array;for(const a of r?.assets){const l=Kk(this.parser,a);l&&o.push(l)}await Promise.all(o)}resolve(e,i){const s=Number.parseInt(i);if(s>=0){Ds&&console.log(i);const r=e.json.extensions[qk];if(r){const o=r?.assets[s];if(o&&typeof o=="object"){o.___persistentAsset=!0;const a=o.__type;a&&Z.get(a)}return o}}return null}}const xc=te("debugserializer");class Fme{constructor(){p(this,"typeMap",new Map)}register(e,i){if(this.typeMap.has(e)){const s=this.typeMap.get(e);if(s===i)return;xc&&console.warn("Type: "+e+" is already registered",i,s)}xc&&console.log("Register type serializer",i.name,i,e),this.typeMap.set(e,i)}getSerializer(e){if(e)return this.typeMap.get(e)}getSerializerForConstructor(e,i=0){if(i>20)return;if(!e||!e.constructor){xc&&console.log("invalid type");return}const s=e.name,r=this.getSerializer(e);if(r!==void 0)return xc&&console.log("FOUND SERIALIZER",r?.name,e.name,e.constructor.name,"for type: "+s,r,e,this.typeMap),r;const o=Object.getPrototypeOf(e);if(o&&o!==e){const a=this.getSerializerForConstructor(o,++i);if(a){const l=o.constructor||o.prototype;xc&&console.log("FOUND SERIALIZER(in constructor) "+l.constructor.name,l.name,l,a),this.register(l,a)}return a}xc&&console.warn("No serializer found for "+s,e,e.name,e.constructor.name)}}const tC=new Fme;class Ha{constructor(e,i){if(p(this,"name"),this.name=i,Array.isArray(e))for(const s of e)tC.register(s,this);else tC.register(e,this)}}class zme{constructor(){p(this,"isDevMode",io()),p(this,"cache",{})}registerDefinedKeys(e,i){if(this.isDevMode&&this.cache[e]===void 0){this.cache[e]=Object.keys(i);const s=i;s.$serializedTypes&&Object.keys(s.$serializedTypes)&&this.cache[e].push(...Object.keys(s.$serializedTypes)),xc&&console.log("registerDefinedKeys for "+e,this.cache[e],i)}}getDefinedKey(e,i){return this.cache[e]===void 0?!1:this.cache[e].includes(i)}}class $k{constructor(e){p(this,"root"),p(this,"gltf"),p(this,"gltfId"),p(this,"object"),p(this,"target"),p(this,"nodeId"),p(this,"nodeToObject"),p(this,"objectToNode"),p(this,"context"),p(this,"path"),p(this,"type"),p(this,"serializable"),p(this,"implementationInformation"),this.root=e}}function W9(n,e){const i=n.$serializedTypes;if(i===void 0)return null;const s={};for(const r in i){const o=n[r];if(o!=null&&typeof o=="object"){const a=tC.getSerializerForConstructor(o);if(a){s[r]=a.onSerialize(o,e);continue}}s[r]=o}return s.name=n.constructor.name,typeof n.guid=="string"&&(s.guid=n.guid),s}const iC=[];function H9(n,e){if(!n)return e;typeof n.$serializedTypes=="object"&&(e||(e={}),Object.assign(e,n.$serializedTypes));const i=Object.getPrototypeOf(n);return H9(i,e)}function nC(n,e,i){if(!n)return!1;if(i.target=n,n.onBeforeDeserialize!==void 0){const r=n.onBeforeDeserialize(e,i);if(typeof r=="boolean")return r}const s=H9(n);if(e){if(typeof e.guid=="string"&&(n.guid=e.guid),s)for(const r in s){let o=function(c){const h=c.type;return h?eB(l,h,i,void 0,n[r]):eB(l,c,i,void 0,n[r])};const a=s[r],l=e[r];if(xc&&console.log(r,l,n,a),!(n[r]!==void 0&&l===void 0)&&(i.type=void 0,i.path=r,i.serializable=a,!(n.onBeforeDeserializeMember!==void 0&&n.onBeforeDeserializeMember(r,l,i)===!0))){if(a===null)n[r]=l;else{if(Array.isArray(a))for(let c=0;c<a.length;c++){const h=a[c],d=o(h);if(d!==void 0||c===a.length-1){n[r]=d;break}}else n[r]=o(a);iC.length=0}n.onAfterDeserializeMember!==void 0&&n.onAfterDeserializeMember(r,l,i)}}Xme(n,e)}return Vme(n,e,i.implementationInformation),n.onAfterDeserialize!==void 0&&n.onAfterDeserialize(e,i),!0}const Ume=te("noerrors");function Vme(n,e,i){var s,r;if(Ume||!e||!io()||!n||n.constructor&&n.constructor[Pme]===!0)return;const o=(s=n.constructor)==null?void 0:s.name,a=Object.getOwnPropertyNames(e);for(const l of a){if(l==="sourceId")continue;const c=n[l];if(c==null)continue;const h=e[l];if(i?.getDefinedKey(o,l)===!1){const d=l.charAt(0).toUpperCase()+l.slice(1);i.getDefinedKey(o,d)&&(hc(Ko.Warn,'<strong>Please rename</strong> "'+d+'" to "'+l+'" in '+o),console.warn('Please use lowercase for field: "'+d+'" in '+o,h,n));continue}if(h!=null){if(typeof h=="object"&&(c===void 0||!c.isObject3D)){if(typeof h.node=="number"||typeof h.guid=="string"){if(h.could_not_resolve)continue;if(!(c!==void 0&&Object.keys(c).length>1)){hc(Ko.Warn,`<strong>Missing serialization for object reference!</strong>
|
|
4970
4970
|
|
|
4971
4971
|
Please change to:
|
|
4972
4972
|
@serializable(Object3D)
|
|
@@ -4981,26 +4981,26 @@ Please change to:
|
|
|
4981
4981
|
${l}? : AssetReference;
|
|
4982
4982
|
|
|
4983
4983
|
in script ${o}.ts
|
|
4984
|
-
<a href="https://docs.needle.tools/serializable" target="_blank">documentation</a>`),console.warn(o,l,n[l],n);continue}}}}function Xme(n,e){for(const i of Object.keys(e)){const s=e[i];if(typeof s=="object"&&s!==null&&s!==void 0){const r=n[i];if(!r){xc&&console.log(i,"is undefined on",n);continue}for(const o of Object.keys(s))if(r[o]===void 0&&j4(s[o])&&!j4(r)){const a=Wme(r,o);if(a&&(a?.writable===void 0||a?.writable===!1)&&a.set===void 0){xc&&console.warn('Property is not writable "'+o+'"',r,a,s[o],r[o]);continue}r[o]=s[o]}}}}function Wme(n,e){for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=Object.getPrototypeOf(n)}}function j4(n){switch(typeof n){case"number":case"string":case"boolean":return!0}return!1}function eB(n,e,i,s,r){let o=typeof e=="function"&&e.prototype===void 0,a=e;if(o)try{if(a=e?.call(e,r),o=!1,a==null)return}catch(d){console.error("Error in callback",d,n)}if(i.type=a,!o&&r instanceof a)return r;if(s||(s={serializer:tC.getSerializerForConstructor(a)}),r&&typeof r=="object"&&Gme(r)){if(r.__concreteInstance)return r.__concreteInstance;const d=r;if(!d.$serializedTypes&&a.prototype.$serializedTypes&&(d.$serializedTypes=a.prototype.$serializedTypes),d.$serializedTypes&&nC(d,n,i),r&&a!==void 0)try{let u=null;s.serializer&&(u=s.serializer.onDeserialize(n,i)),u||(u=new a,Ds&&console.log("Create concrete instance for persistent asset",r,"instance:",u),d0(u,r)),r.__concreteInstance=u,r=u}catch(u){console.error("Error creating instance or creating values on instance",u,r,a)}return r}if(Array.isArray(n)){const d=[];for(let u=0;u<n.length;u++){const m=n[u],f=eB(m,e,i,s,m);d.push(f)}return d}const l=s?.serializer;if(l)return l.onDeserialize(n,i);let c;if(n&&(n.isMaterial||n.isTexture||n.isObject3D||n instanceof to))c=n;else{if(n===void 0)return;if(n===null&&(a===Ft||a===Vt||a===ue||a===to))return null;try{c=new a(...Hme(n))}catch(d){console.error("Error creating "+i.path,i.target,d);return}}const h=c;return h.$serializedTypes&&nC(h,n,i),c}function Hme(n){if(iC.length=0,typeof n=="object"&&n!==null&&n!==void 0)for(const e of Object.keys(n))iC.push(n[e]);return iC}const tB=Symbol("assigned component properties");function d0(n,e,i){var s;if(e==null||n==null)return;n[tB]=!0;const r=((s=n.constructor)==null?void 0:s.name)??"unknown";i?.registerDefinedKeys(r,n);for(const o of Object.keys(e)){const a=jme(n,o);typeof a?.value!="function"&&(!a||a.writable===!0||a?.set!==void 0)&&(n[o]=e[o])}delete n[tB]}function jme(n,e){let i;do i=Object.getOwnPropertyDescriptor(n,e);while(!i&&(n=Object.getPrototypeOf(n)));return i}const Q4=Symbol("customVisibilityFlag");function Vh(n,e){n.layers[Q4]=e}const Z4=Symbol("DidPatchLayers");function Qme(){const n=Er.prototype;if(n[Z4])return;n[Z4]=!0;const e=n.test;n.test=function(i){return this[Q4]===!1?!1:e.call(this,i)}}Qme(),Object.defineProperty(Lt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0}),Object.defineProperty(Lt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0}),Object.defineProperty(Lt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0});const Y4=new Map;function K4(n,e){if(!n)return;if(!e){console.warn("No prototype found",n,n.prototype,n.constructor);return}const i=Y4.get(e);i&&i.apply(n)}function J4(n){const e=Zme(n.prototype);Y4.set(n,e)}function Zme(n){return new Yme(n)}class Yme{constructor(e){p(this,"$symbol"),p(this,"extensions"),p(this,"descriptors"),this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let i=0;i<this.extensions.length;i++){const s=this.extensions[i],r=Object.getOwnPropertyDescriptor(e,s);r&&this.descriptors.push(r)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let i=0;i<this.extensions.length;i++){const s=this.extensions[i],r=this.descriptors[i];r&&Object.defineProperty(e,s,r)}}}}const Em=new Hd,Fr=new M,Au=new M,bn=new Se,q4={X:new M(1,0,0),Y:new M(0,1,0),Z:new M(0,0,1)},iB={type:"change"},$4={type:"mouseDown"},e9={type:"mouseUp",mode:null},t9={type:"objectChange"};class Kme extends ge{constructor(e,i){super(),i===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),i=document),this.isTransformControls=!0,this.visible=!1,this.domElement=i,this.domElement.style.touchAction="none";const s=new sB;this._gizmo=s,this.add(s);const r=new ife;this._plane=r,this.add(r);const o=this;function a(A,x){let w=x;Object.defineProperty(o,A,{get:function(){return w!==void 0?w:x},set:function(_){w!==_&&(w=_,r[A]=_,s[A]=_,o.dispatchEvent({type:A+"-changed",value:_}),o.dispatchEvent(iB))}}),o[A]=x,r[A]=x,s[A]=x}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const l=new M,c=new M,h=new Se,d=new Se,u=new M,m=new Se,f=new M,g=new M,v=new M,y=0,b=new M;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",u),a("cameraQuaternion",m),a("pointStart",f),a("pointEnd",g),a("rotationAxis",v),a("rotationAngle",y),a("eye",b),this._offset=new M,this._startNorm=new M,this._endNorm=new M,this._cameraScale=new M,this._parentPosition=new M,this._parentQuaternion=new Se,this._parentQuaternionInv=new Se,this._parentScale=new M,this._worldScaleStart=new M,this._worldQuaternionInv=new Se,this._worldScale=new M,this._positionStart=new M,this._quaternionStart=new Se,this._scaleStart=new M,this._getPointer=Jme.bind(this),this._onPointerDown=$me.bind(this),this._onPointerHover=qme.bind(this),this._onPointerMove=efe.bind(this),this._onPointerUp=tfe.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Em.setFromCamera(e,this.camera);const i=nB(this._gizmo.picker[this.mode],Em);i?this.axis=i.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Em.setFromCamera(e,this.camera);const i=nB(this._plane,Em,!0);i&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(i.point).sub(this.worldPositionStart)),this.dragging=!0,$4.mode=this.mode,this.dispatchEvent($4)}}pointerMove(e){const i=this.axis,s=this.mode,r=this.object;let o=this.space;if(s==="scale"?o="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(o="world"),r===void 0||i===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Em.setFromCamera(e,this.camera);const a=nB(this._plane,Em,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&i!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),i.indexOf("X")===-1&&(this._offset.x=0),i.indexOf("Y")===-1&&(this._offset.y=0),i.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&i!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(r.position.applyQuaternion(bn.copy(this._quaternionStart).invert()),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),o==="world"&&(r.parent&&r.position.add(Fr.setFromMatrixPosition(r.parent.matrixWorld)),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Fr.setFromMatrixPosition(r.parent.matrixWorld))));else if(s==="scale"){if(i.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Au.set(l,l,l)}else Fr.copy(this.pointStart),Au.copy(this.pointEnd),Fr.applyQuaternion(this._worldQuaternionInv),Au.applyQuaternion(this._worldQuaternionInv),Au.divide(Fr),i.search("X")===-1&&(Au.x=1),i.search("Y")===-1&&(Au.y=1),i.search("Z")===-1&&(Au.z=1);r.scale.copy(this._scaleStart).multiply(Au),this.scaleSnap&&(i.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(Fr.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;i==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Fr.copy(this.rotationAxis).cross(this.eye))*l):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(q4[i]),Fr.copy(q4[i]),o==="local"&&Fr.applyQuaternion(this.worldQuaternion),Fr.cross(this.eye),Fr.length()===0?c=!0:this.rotationAngle=this._offset.dot(Fr.normalize())*l),(i==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&i!=="E"&&i!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(bn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(bn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(iB),this.dispatchEvent(t9)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(e9.mode=this.mode,this.dispatchEvent(e9)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(iB),this.dispatchEvent(t9),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Em}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Jme(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function qme(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function $me(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function efe(n){this.enabled&&this.pointerMove(this._getPointer(n))}function tfe(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function nB(n,e,i){const s=e.intersectObject(n,!0);for(let r=0;r<s.length;r++)if(s[r].object.visible||i)return s[r];return!1}const sC=new si,Wi=new M(0,1,0),i9=new M(0,0,0),n9=new he,rC=new Se,oC=new Se,wc=new M,s9=new he,eA=new M(1,0,0),Tm=new M(0,1,0),tA=new M(0,0,1),aC=new M,iA=new M,nA=new M;class sB extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Ht({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new Vi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const r=i.clone();r.opacity=.5;const o=e.clone();o.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const u=e.clone();u.opacity=.25;const m=e.clone();m.color.setHex(16776960),m.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const g=new Jn(0,.04,.1,12);g.translate(0,.05,0);const v=new Hi(.08,.08,.08);v.translate(0,.04,0);const y=new pt;y.setAttribute("position",new st([0,0,0,1,0,0],3));const b=new Jn(.0075,.0075,.5,3);b.translate(0,.25,0);function A(O,W){const D=new bd(O,.0075,3,64,W*Math.PI*2);return D.rotateY(Math.PI/2),D.rotateX(Math.PI/2),D}function x(){const O=new pt;return O.setAttribute("position",new st([0,0,0,1,1,1],3)),O}const w={X:[[new ue(g,o),[.5,0,0],[0,0,-Math.PI/2]],[new ue(g,o),[-.5,0,0],[0,0,Math.PI/2]],[new ue(b,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ue(g,a),[0,.5,0]],[new ue(g,a),[0,-.5,0],[Math.PI,0,0]],[new ue(b,a)]],Z:[[new ue(g,l),[0,0,.5],[Math.PI/2,0,0]],[new ue(g,l),[0,0,-.5],[-Math.PI/2,0,0]],[new ue(b,l),null,[Math.PI/2,0,0]]],XYZ:[[new ue(new vd(.1,0),u.clone()),[0,0,0]]],XY:[[new ue(new Hi(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new ue(new Hi(.15,.15,.01),c.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},_={X:[[new ue(new Jn(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Jn(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Jn(.2,0,.6,4),s),[0,.3,0]],[new ue(new Jn(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Jn(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Jn(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ue(new vd(.2,0),s)]],XY:[[new ue(new Hi(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new ue(new Hi(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},S={START:[[new ue(new vd(.01,2),r),null,null,null,"helper"]],END:[[new ue(new vd(.01,2),r),null,null,null,"helper"]],DELTA:[[new mn(x(),r),null,null,null,"helper"]],X:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new mn(y,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new mn(y,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new ue(A(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new ue(A(.5,.5),o)]],Y:[[new ue(A(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new ue(A(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new ue(A(.75,1),m),null,[0,Math.PI/2,0]]]},R={AXIS:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},P={XYZE:[[new ue(new ll(.25,10,8),s)]],X:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ue(new bd(.75,.1,2,24),s)]]},T={X:[[new ue(v,o),[.5,0,0],[0,0,-Math.PI/2]],[new ue(b,o),[0,0,0],[0,0,-Math.PI/2]],[new ue(v,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ue(v,a),[0,.5,0]],[new ue(b,a)],[new ue(v,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ue(v,l),[0,0,.5],[Math.PI/2,0,0]],[new ue(b,l),[0,0,0],[Math.PI/2,0,0]],[new ue(v,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ue(new Hi(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new ue(new Hi(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Hi(.1,.1,.1),u.clone())]]},L={X:[[new ue(new Jn(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Jn(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Jn(.2,0,.6,4),s),[0,.3,0]],[new ue(new Jn(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Jn(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Jn(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ue(new Hi(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new ue(new Hi(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Hi(.2,.2,.2),s),[0,0,0]]]},k={X:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new mn(y,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new mn(y,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function G(O){const W=new ge;for(const D in O)for(let F=O[D].length;F--;){const U=O[D][F][0].clone(),Y=O[D][F][1],q=O[D][F][2],oe=O[D][F][3],xe=O[D][F][4];U.name=D,U.tag=xe,Y&&U.position.set(Y[0],Y[1],Y[2]),q&&U.rotation.set(q[0],q[1],q[2]),oe&&U.scale.set(oe[0],oe[1],oe[2]),U.updateMatrix();const Be=U.geometry.clone();Be.applyMatrix4(U.matrix),U.geometry=Be,U.renderOrder=1/0,U.position.set(0,0,0),U.rotation.set(0,0,0),U.scale.set(1,1,1),W.add(U)}return W}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=G(w)),this.add(this.gizmo.rotate=G(C)),this.add(this.gizmo.scale=G(T)),this.add(this.picker.translate=G(_)),this.add(this.picker.rotate=G(P)),this.add(this.picker.scale=G(L)),this.add(this.helper.translate=G(S)),this.add(this.helper.rotate=G(R)),this.add(this.helper.scale=G(k)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:oC;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const o=s[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(bn.setFromEuler(sC.set(0,0,0)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(bn.setFromEuler(sC.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(bn.setFromEuler(sC.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(bn.setFromEuler(sC.set(0,Math.PI/2,0)),Wi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(n9.lookAt(i9,Wi,Tm)),o.quaternion.multiply(bn),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Fr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Fr.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Fr),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(rC.copy(i),Wi.copy(this.eye).applyQuaternion(bn.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(n9.lookAt(this.eye,i9,Tm)),o.name==="X"&&(bn.setFromAxisAngle(eA,Math.atan2(-Wi.y,Wi.z)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn)),o.name==="Y"&&(bn.setFromAxisAngle(Tm,Math.atan2(Wi.x,Wi.z)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn)),o.name==="Z"&&(bn.setFromAxisAngle(tA,Math.atan2(Wi.y,Wi.x)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class ife extends ue{constructor(){super(new Kn(1e5,1e5,2,2),new Ht({visible:!1,wireframe:!0,side:Ai,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let i=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(i="local"),aC.copy(eA).applyQuaternion(i==="local"?this.worldQuaternion:oC),iA.copy(Tm).applyQuaternion(i==="local"?this.worldQuaternion:oC),nA.copy(tA).applyQuaternion(i==="local"?this.worldQuaternion:oC),Wi.copy(iA),this.mode){case"translate":case"scale":switch(this.axis){case"X":Wi.copy(this.eye).cross(aC),wc.copy(aC).cross(Wi);break;case"Y":Wi.copy(this.eye).cross(iA),wc.copy(iA).cross(Wi);break;case"Z":Wi.copy(this.eye).cross(nA),wc.copy(nA).cross(Wi);break;case"XY":wc.copy(nA);break;case"YZ":wc.copy(aC);break;case"XZ":Wi.copy(nA),wc.copy(iA);break;case"XYZ":case"E":wc.set(0,0,0);break}break;case"rotate":default:wc.set(0,0,0)}wc.length()===0?this.quaternion.copy(this.cameraQuaternion):(s9.lookAt(Fr.set(0,0,0),wc,Wi),this.quaternion.setFromRotationMatrix(s9)),super.updateMatrixWorld(e)}}const nfe=te("debuggetcomponent"),r9=()=>nfe||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function sfe(n){return n==null||n.isObject3D?n:n.object&&n.object.isObject3D?n.object:n}function rB(n,e){if(!n||!n.userData.components)return e;const i=n.userData.components.indexOf(e);return i<0||(Zb.dispatchComponentLifecycleEvent("removing-component",e),e.gameObject=null,n.userData.components.splice(i,1)),e}function sA(n,e,i){return Im(n,e)||ra(n,e,i)}const o9=new xr("addComponentIdProvider");function Rm(n,e,i=!0){n.userData||(n.userData={}),n.userData.components||(n.userData.components=[]),n.userData.components.push(e),e.gameObject=n,(e.guid===void 0||e.guid==="invalid")&&(e.guid=o9.generateUUID()),hC(n),GC(e,e.context);try{i&&e.__internalAwake&&(Jb(n),e.activeAndEnabled&&e.__internalAwake()),Zb.dispatchComponentLifecycleEvent("component-added",e)}catch(s){console.error(s)}return e}function ra(n,e,i,s){if(typeof e=="function"){const r=new e;i&&r.__internalNewInstanceCreated(i);let o=!0;return s?.callAwake!=null&&(o=s.callAwake),Rm(n,r,o)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===n)return e;if(e.gameObject&&e.gameObject.userData.components){const r=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(r,1)}if(!n.userData.components)n.userData.components=[];else if(n.userData.components.includes(e))return e;return n.userData.components.push(e),e.gameObject=n,(e.guid===void 0||e.guid==="invalid")&&(e.guid=o9.generateUUID()),i&&e._internalInit(i),GC(e,e.context),e}function a9(n){if(n.gameObject&&n.gameObject.userData.components){const e=n.gameObject.userData.components.indexOf(n);n.gameObject.userData.components.splice(e,1)}n.__internalDisable&&n.__internalDisable(),Uh(n,n.context??Pt.Current),n.destroy(),n.gameObject=null}let l9=!1;function c9(n,e,i){var s;if(n==null)return null;if(!n.isObject3D)return console.error("Object is not object3D"),null;if(!((s=n?.userData)!=null&&s.components)||(typeof e=="string"&&(l9||(l9=!0,console.warn(`Accessing components by name is not supported.
|
|
4984
|
+
<a href="https://docs.needle.tools/serializable" target="_blank">documentation</a>`),console.warn(o,l,n[l],n);continue}}}}function Xme(n,e){for(const i of Object.keys(e)){const s=e[i];if(typeof s=="object"&&s!==null&&s!==void 0){const r=n[i];if(!r){xc&&console.log(i,"is undefined on",n);continue}for(const o of Object.keys(s))if(r[o]===void 0&&j9(s[o])&&!j9(r)){const a=Wme(r,o);if(a&&(a?.writable===void 0||a?.writable===!1)&&a.set===void 0){xc&&console.warn('Property is not writable "'+o+'"',r,a,s[o],r[o]);continue}r[o]=s[o]}}}}function Wme(n,e){for(;n;){const i=Object.getOwnPropertyDescriptor(n,e);if(i)return i;n=Object.getPrototypeOf(n)}}function j9(n){switch(typeof n){case"number":case"string":case"boolean":return!0}return!1}function eB(n,e,i,s,r){let o=typeof e=="function"&&e.prototype===void 0,a=e;if(o)try{if(a=e?.call(e,r),o=!1,a==null)return}catch(d){console.error("Error in callback",d,n)}if(i.type=a,!o&&r instanceof a)return r;if(s||(s={serializer:tC.getSerializerForConstructor(a)}),r&&typeof r=="object"&&Gme(r)){if(r.__concreteInstance)return r.__concreteInstance;const d=r;if(!d.$serializedTypes&&a.prototype.$serializedTypes&&(d.$serializedTypes=a.prototype.$serializedTypes),d.$serializedTypes&&nC(d,n,i),r&&a!==void 0)try{let u=null;s.serializer&&(u=s.serializer.onDeserialize(n,i)),u||(u=new a,Ds&&console.log("Create concrete instance for persistent asset",r,"instance:",u),d0(u,r)),r.__concreteInstance=u,r=u}catch(u){console.error("Error creating instance or creating values on instance",u,r,a)}return r}if(Array.isArray(n)){const d=[];for(let u=0;u<n.length;u++){const m=n[u],f=eB(m,e,i,s,m);d.push(f)}return d}const l=s?.serializer;if(l)return l.onDeserialize(n,i);let c;if(n&&(n.isMaterial||n.isTexture||n.isObject3D||n instanceof to))c=n;else{if(n===void 0)return;if(n===null&&(a===Ft||a===Vt||a===ue||a===to))return null;try{c=new a(...Hme(n))}catch(d){console.error("Error creating "+i.path,i.target,d);return}}const h=c;return h.$serializedTypes&&nC(h,n,i),c}function Hme(n){if(iC.length=0,typeof n=="object"&&n!==null&&n!==void 0)for(const e of Object.keys(n))iC.push(n[e]);return iC}const tB=Symbol("assigned component properties");function d0(n,e,i){var s;if(e==null||n==null)return;n[tB]=!0;const r=((s=n.constructor)==null?void 0:s.name)??"unknown";i?.registerDefinedKeys(r,n);for(const o of Object.keys(e)){const a=jme(n,o);typeof a?.value!="function"&&(!a||a.writable===!0||a?.set!==void 0)&&(n[o]=e[o])}delete n[tB]}function jme(n,e){let i;do i=Object.getOwnPropertyDescriptor(n,e);while(!i&&(n=Object.getPrototypeOf(n)));return i}const Q9=Symbol("customVisibilityFlag");function Vh(n,e){n.layers[Q9]=e}const Z9=Symbol("DidPatchLayers");function Qme(){const n=Er.prototype;if(n[Z9])return;n[Z9]=!0;const e=n.test;n.test=function(i){return this[Q9]===!1?!1:e.call(this,i)}}Qme(),Object.defineProperty(Lt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0}),Object.defineProperty(Lt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0}),Object.defineProperty(Lt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()},configurable:!0});const Y9=new Map;function K9(n,e){if(!n)return;if(!e){console.warn("No prototype found",n,n.prototype,n.constructor);return}const i=Y9.get(e);i&&i.apply(n)}function J9(n){const e=Zme(n.prototype);Y9.set(n,e)}function Zme(n){return new Yme(n)}class Yme{constructor(e){p(this,"$symbol"),p(this,"extensions"),p(this,"descriptors"),this.$symbol=Symbol("prototype-extension"),this.extensions=Object.keys(e),this.descriptors=new Array;for(let i=0;i<this.extensions.length;i++){const s=this.extensions[i],r=Object.getOwnPropertyDescriptor(e,s);r&&this.descriptors.push(r)}}apply(e){if(!e[this.$symbol]){e[this.$symbol]=!0;for(let i=0;i<this.extensions.length;i++){const s=this.extensions[i],r=this.descriptors[i];r&&Object.defineProperty(e,s,r)}}}}const Em=new Hd,Fr=new M,Au=new M,bn=new Se,q9={X:new M(1,0,0),Y:new M(0,1,0),Z:new M(0,0,1)},iB={type:"change"},$9={type:"mouseDown"},e4={type:"mouseUp",mode:null},t4={type:"objectChange"};class Kme extends ge{constructor(e,i){super(),i===void 0&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),i=document),this.isTransformControls=!0,this.visible=!1,this.domElement=i,this.domElement.style.touchAction="none";const s=new sB;this._gizmo=s,this.add(s);const r=new ife;this._plane=r,this.add(r);const o=this;function a(A,x){let w=x;Object.defineProperty(o,A,{get:function(){return w!==void 0?w:x},set:function(_){w!==_&&(w=_,r[A]=_,s[A]=_,o.dispatchEvent({type:A+"-changed",value:_}),o.dispatchEvent(iB))}}),o[A]=x,r[A]=x,s[A]=x}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const l=new M,c=new M,h=new Se,d=new Se,u=new M,m=new Se,f=new M,g=new M,v=new M,y=0,b=new M;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",u),a("cameraQuaternion",m),a("pointStart",f),a("pointEnd",g),a("rotationAxis",v),a("rotationAngle",y),a("eye",b),this._offset=new M,this._startNorm=new M,this._endNorm=new M,this._cameraScale=new M,this._parentPosition=new M,this._parentQuaternion=new Se,this._parentQuaternionInv=new Se,this._parentScale=new M,this._worldScaleStart=new M,this._worldQuaternionInv=new Se,this._worldScale=new M,this._positionStart=new M,this._quaternionStart=new Se,this._scaleStart=new M,this._getPointer=Jme.bind(this),this._onPointerDown=$me.bind(this),this._onPointerHover=qme.bind(this),this._onPointerMove=efe.bind(this),this._onPointerUp=tfe.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Em.setFromCamera(e,this.camera);const i=nB(this._gizmo.picker[this.mode],Em);i?this.axis=i.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Em.setFromCamera(e,this.camera);const i=nB(this._plane,Em,!0);i&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(i.point).sub(this.worldPositionStart)),this.dragging=!0,$9.mode=this.mode,this.dispatchEvent($9)}}pointerMove(e){const i=this.axis,s=this.mode,r=this.object;let o=this.space;if(s==="scale"?o="local":(i==="E"||i==="XYZE"||i==="XYZ")&&(o="world"),r===void 0||i===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Em.setFromCamera(e,this.camera);const a=nB(this._plane,Em,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),o==="local"&&i!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),i.indexOf("X")===-1&&(this._offset.x=0),i.indexOf("Y")===-1&&(this._offset.y=0),i.indexOf("Z")===-1&&(this._offset.z=0),o==="local"&&i!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(o==="local"&&(r.position.applyQuaternion(bn.copy(this._quaternionStart).invert()),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),o==="world"&&(r.parent&&r.position.add(Fr.setFromMatrixPosition(r.parent.matrixWorld)),i.search("X")!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),i.search("Y")!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),i.search("Z")!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(Fr.setFromMatrixPosition(r.parent.matrixWorld))));else if(s==="scale"){if(i.search("XYZ")!==-1){let l=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(l*=-1),Au.set(l,l,l)}else Fr.copy(this.pointStart),Au.copy(this.pointEnd),Fr.applyQuaternion(this._worldQuaternionInv),Au.applyQuaternion(this._worldQuaternionInv),Au.divide(Fr),i.search("X")===-1&&(Au.x=1),i.search("Y")===-1&&(Au.y=1),i.search("Z")===-1&&(Au.z=1);r.scale.copy(this._scaleStart).multiply(Au),this.scaleSnap&&(i.search("X")!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Y")!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),i.search("Z")!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const l=20/this.worldPosition.distanceTo(Fr.setFromMatrixPosition(this.camera.matrixWorld));let c=!1;i==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Fr.copy(this.rotationAxis).cross(this.eye))*l):(i==="X"||i==="Y"||i==="Z")&&(this.rotationAxis.copy(q9[i]),Fr.copy(q9[i]),o==="local"&&Fr.applyQuaternion(this.worldQuaternion),Fr.cross(this.eye),Fr.length()===0?c=!0:this.rotationAngle=this._offset.dot(Fr.normalize())*l),(i==="E"||c)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),o==="local"&&i!=="E"&&i!=="XYZE"?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(bn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(bn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(iB),this.dispatchEvent(t4)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(e4.mode=this.mode,this.dispatchEvent(e4)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(iB),this.dispatchEvent(t4),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Em}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Jme(n){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:n.button};{const e=this.domElement.getBoundingClientRect();return{x:(n.clientX-e.left)/e.width*2-1,y:-(n.clientY-e.top)/e.height*2+1,button:n.button}}}function qme(n){if(this.enabled)switch(n.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(n));break}}function $me(n){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(n.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(n)),this.pointerDown(this._getPointer(n)))}function efe(n){this.enabled&&this.pointerMove(this._getPointer(n))}function tfe(n){this.enabled&&(this.domElement.releasePointerCapture(n.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(n)))}function nB(n,e,i){const s=e.intersectObject(n,!0);for(let r=0;r<s.length;r++)if(s[r].object.visible||i)return s[r];return!1}const sC=new si,Wi=new M(0,1,0),i4=new M(0,0,0),n4=new he,rC=new Se,oC=new Se,wc=new M,s4=new he,eA=new M(1,0,0),Tm=new M(0,1,0),tA=new M(0,0,1),aC=new M,iA=new M,nA=new M;class sB extends ge{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Ht({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=new Vi({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const r=i.clone();r.opacity=.5;const o=e.clone();o.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const l=e.clone();l.color.setHex(255);const c=e.clone();c.color.setHex(16711680),c.opacity=.5;const h=e.clone();h.color.setHex(65280),h.opacity=.5;const d=e.clone();d.color.setHex(255),d.opacity=.5;const u=e.clone();u.opacity=.25;const m=e.clone();m.color.setHex(16776960),m.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const g=new Jn(0,.04,.1,12);g.translate(0,.05,0);const v=new Hi(.08,.08,.08);v.translate(0,.04,0);const y=new pt;y.setAttribute("position",new st([0,0,0,1,0,0],3));const b=new Jn(.0075,.0075,.5,3);b.translate(0,.25,0);function A(O,W){const D=new bd(O,.0075,3,64,W*Math.PI*2);return D.rotateY(Math.PI/2),D.rotateX(Math.PI/2),D}function x(){const O=new pt;return O.setAttribute("position",new st([0,0,0,1,1,1],3)),O}const w={X:[[new ue(g,o),[.5,0,0],[0,0,-Math.PI/2]],[new ue(g,o),[-.5,0,0],[0,0,Math.PI/2]],[new ue(b,o),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new ue(g,a),[0,.5,0]],[new ue(g,a),[0,-.5,0],[Math.PI,0,0]],[new ue(b,a)]],Z:[[new ue(g,l),[0,0,.5],[Math.PI/2,0,0]],[new ue(g,l),[0,0,-.5],[-Math.PI/2,0,0]],[new ue(b,l),null,[Math.PI/2,0,0]]],XYZ:[[new ue(new vd(.1,0),u.clone()),[0,0,0]]],XY:[[new ue(new Hi(.15,.15,.01),d.clone()),[.15,.15,0]]],YZ:[[new ue(new Hi(.15,.15,.01),c.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.15,.15,.01),h.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},_={X:[[new ue(new Jn(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Jn(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Jn(.2,0,.6,4),s),[0,.3,0]],[new ue(new Jn(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Jn(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Jn(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new ue(new vd(.2,0),s)]],XY:[[new ue(new Hi(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new ue(new Hi(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},S={START:[[new ue(new vd(.01,2),r),null,null,null,"helper"]],END:[[new ue(new vd(.01,2),r),null,null,null,"helper"]],DELTA:[[new mn(x(),r),null,null,null,"helper"]],X:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new mn(y,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new mn(y,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},C={XYZE:[[new ue(A(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new ue(A(.5,.5),o)]],Y:[[new ue(A(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new ue(A(.5,.5),l),null,[0,Math.PI/2,0]]],E:[[new ue(A(.75,1),m),null,[0,Math.PI/2,0]]]},R={AXIS:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},P={XYZE:[[new ue(new ll(.25,10,8),s)]],X:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new ue(new bd(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new ue(new bd(.75,.1,2,24),s)]]},T={X:[[new ue(v,o),[.5,0,0],[0,0,-Math.PI/2]],[new ue(b,o),[0,0,0],[0,0,-Math.PI/2]],[new ue(v,o),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new ue(v,a),[0,.5,0]],[new ue(b,a)],[new ue(v,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new ue(v,l),[0,0,.5],[Math.PI/2,0,0]],[new ue(b,l),[0,0,0],[Math.PI/2,0,0]],[new ue(v,l),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new ue(new Hi(.15,.15,.01),d),[.15,.15,0]]],YZ:[[new ue(new Hi(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Hi(.1,.1,.1),u.clone())]]},L={X:[[new ue(new Jn(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new ue(new Jn(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new ue(new Jn(.2,0,.6,4),s),[0,.3,0]],[new ue(new Jn(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new ue(new Jn(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new ue(new Jn(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new ue(new Hi(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new ue(new Hi(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new ue(new Hi(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new ue(new Hi(.2,.2,.2),s),[0,0,0]]]},k={X:[[new mn(y,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new mn(y,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new mn(y,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function G(O){const W=new ge;for(const D in O)for(let F=O[D].length;F--;){const U=O[D][F][0].clone(),Y=O[D][F][1],q=O[D][F][2],oe=O[D][F][3],xe=O[D][F][4];U.name=D,U.tag=xe,Y&&U.position.set(Y[0],Y[1],Y[2]),q&&U.rotation.set(q[0],q[1],q[2]),oe&&U.scale.set(oe[0],oe[1],oe[2]),U.updateMatrix();const Be=U.geometry.clone();Be.applyMatrix4(U.matrix),U.geometry=Be,U.renderOrder=1/0,U.position.set(0,0,0),U.rotation.set(0,0,0),U.scale.set(1,1,1),W.add(U)}return W}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=G(w)),this.add(this.gizmo.rotate=G(C)),this.add(this.gizmo.scale=G(T)),this.add(this.picker.translate=G(_)),this.add(this.picker.rotate=G(P)),this.add(this.picker.scale=G(L)),this.add(this.helper.translate=G(S)),this.add(this.helper.rotate=G(R)),this.add(this.helper.scale=G(k)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:oC;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let r=0;r<s.length;r++){const o=s[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(bn.setFromEuler(sC.set(0,0,0)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(bn.setFromEuler(sC.set(0,0,Math.PI/2)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(bn.setFromEuler(sC.set(0,Math.PI/2,0)),o.quaternion.copy(i).multiply(bn),Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(bn.setFromEuler(sC.set(0,Math.PI/2,0)),Wi.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(n4.lookAt(i4,Wi,Tm)),o.quaternion.multiply(bn),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),Fr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Fr.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(Fr),o.visible=this.dragging):(o.quaternion.copy(i),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(i),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(Wi.copy(tA).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(Wi.copy(eA).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(Wi.copy(Tm).applyQuaternion(i).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(rC.copy(i),Wi.copy(this.eye).applyQuaternion(bn.copy(i).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(n4.lookAt(this.eye,i4,Tm)),o.name==="X"&&(bn.setFromAxisAngle(eA,Math.atan2(-Wi.y,Wi.z)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn)),o.name==="Y"&&(bn.setFromAxisAngle(Tm,Math.atan2(Wi.x,Wi.z)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn)),o.name==="Z"&&(bn.setFromAxisAngle(tA,Math.atan2(Wi.y,Wi.x)),bn.multiplyQuaternions(rC,bn),o.quaternion.copy(bn))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis||this.axis.split("").some(function(l){return o.name===l}))&&(o.material.color.setHex(16776960),o.material.opacity=1)}super.updateMatrixWorld(e)}}class ife extends ue{constructor(){super(new Kn(1e5,1e5,2,2),new Ht({visible:!1,wireframe:!0,side:Ai,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let i=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(i="local"),aC.copy(eA).applyQuaternion(i==="local"?this.worldQuaternion:oC),iA.copy(Tm).applyQuaternion(i==="local"?this.worldQuaternion:oC),nA.copy(tA).applyQuaternion(i==="local"?this.worldQuaternion:oC),Wi.copy(iA),this.mode){case"translate":case"scale":switch(this.axis){case"X":Wi.copy(this.eye).cross(aC),wc.copy(aC).cross(Wi);break;case"Y":Wi.copy(this.eye).cross(iA),wc.copy(iA).cross(Wi);break;case"Z":Wi.copy(this.eye).cross(nA),wc.copy(nA).cross(Wi);break;case"XY":wc.copy(nA);break;case"YZ":wc.copy(aC);break;case"XZ":Wi.copy(nA),wc.copy(iA);break;case"XYZ":case"E":wc.set(0,0,0);break}break;case"rotate":default:wc.set(0,0,0)}wc.length()===0?this.quaternion.copy(this.cameraQuaternion):(s4.lookAt(Fr.set(0,0,0),wc,Wi),this.quaternion.setFromRotationMatrix(s4)),super.updateMatrixWorld(e)}}const nfe=te("debuggetcomponent"),r4=()=>nfe||globalThis.NEEDLE_DEBUG_GETCOMPONENT===!0;function sfe(n){return n==null||n.isObject3D?n:n.object&&n.object.isObject3D?n.object:n}function rB(n,e){if(!n||!n.userData.components)return e;const i=n.userData.components.indexOf(e);return i<0||(Zb.dispatchComponentLifecycleEvent("removing-component",e),e.gameObject=null,n.userData.components.splice(i,1)),e}function sA(n,e,i){return Im(n,e)||ra(n,e,i)}const o4=new xr("addComponentIdProvider");function Rm(n,e,i=!0){n.userData||(n.userData={}),n.userData.components||(n.userData.components=[]),n.userData.components.push(e),e.gameObject=n,(e.guid===void 0||e.guid==="invalid")&&(e.guid=o4.generateUUID()),hC(n),GC(e,e.context);try{i&&e.__internalAwake&&(Jb(n),e.activeAndEnabled&&e.__internalAwake()),Zb.dispatchComponentLifecycleEvent("component-added",e)}catch(s){console.error(s)}return e}function ra(n,e,i,s){if(typeof e=="function"){const r=new e;i&&r.__internalNewInstanceCreated(i);let o=!0;return s?.callAwake!=null&&(o=s.callAwake),Rm(n,r,o)}if(e.destroyed)return console.warn("Can not move/add a destroyed component",e),e;if(e.gameObject===n)return e;if(e.gameObject&&e.gameObject.userData.components){const r=e.gameObject.userData.components.indexOf(e);e.gameObject.userData.components.splice(r,1)}if(!n.userData.components)n.userData.components=[];else if(n.userData.components.includes(e))return e;return n.userData.components.push(e),e.gameObject=n,(e.guid===void 0||e.guid==="invalid")&&(e.guid=o4.generateUUID()),i&&e._internalInit(i),GC(e,e.context),e}function a4(n){if(n.gameObject&&n.gameObject.userData.components){const e=n.gameObject.userData.components.indexOf(n);n.gameObject.userData.components.splice(e,1)}n.__internalDisable&&n.__internalDisable(),Uh(n,n.context??Pt.Current),n.destroy(),n.gameObject=null}let l4=!1;function c4(n,e,i){var s;if(n==null)return null;if(!n.isObject3D)return console.error("Object is not object3D"),null;if(!((s=n?.userData)!=null&&s.components)||(typeof e=="string"&&(l4||(l4=!0,console.warn(`Accessing components by name is not supported.
|
|
4985
4985
|
Please use the component type instead. This may keep working in local development but it will fail when bundling your application.
|
|
4986
4986
|
|
|
4987
4987
|
You can import other modules your main module to get access to types
|
|
4988
4988
|
or if you use npmdefs you can make types available globally using globalThis:
|
|
4989
|
-
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),r9()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r];let a=Object.getPrototypeOf(o);for(;a;){if(a===e.prototype)if(r9()&&console.log("[onGetComponent] MATCH BY PROTOYPE",a),i)i.push(o);else return o;a=Object.getPrototypeOf(a)}}return i||null}function Im(n,e){const i=c9(n,e);return i?Array.isArray(i)?i[0]:i:null}function rA(n,e,i,s=!0){return i||(i=[]),s&&(i.length=0),c9(n,e,i),i}function oA(n,e,i){var s;const r=Im(n,e);if(i===!1&&r?.enabled===!1)return null;if(r)return r;for(let o=0;o<((s=n?.children)==null?void 0:s.length);o++){const a=oA(n.children[o],e);if(a)return a}return null}function u0(n,e,i,s=!0){var r;i||(i=[]),s&&(i.length=0),rA(n,e,i,!1);for(let o=0;o<((r=n?.children)==null?void 0:r.length);o++)u0(n.children[o],e,i,!1);return i}function aA(n,e){if(!n)return null;if(Array.isArray(n)){for(let s=0;s<n.length;s++){const r=sfe(n[s]),o=aA(r,e);if(o)return o}return null}return Im(n,e)||(n.parent?aA(n.parent,e):null)}function lC(n,e,i,s=!0){return i||(i=[]),s&&(i.length=0),n?(rA(n,e,i,!1),n.parent?lC(n.parent,e,i,!1):i):i}function cC(n,e=void 0,i=!0){if(!n)return null;if(!e&&(e=Pt.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let s=e;if(s.isScene||(s=e?.scene),!s)return null;for(const r in s.children){const o=s.children[r];if(i===!1&&o[Ch]===!1)continue;const a=oA(o,n);if(a)return a}return null}function h9(n,e,i=void 0){if(!n)return e??[];if(e||(e=[]),e.length=0,!i&&(i=Pt.Current,!i))return console.error("Can not search object without any needle context or scene!!!"),e;"scene"in i&&(i=i.scene);const s=i;if(!s)return e;for(const r in s.children){const o=s.children[r];u0(o,n,e,!1)}return e}function hC(n){n&&n.isObject3D===!0&&K4(n,ge)}ge.prototype.SetActive=function(n){this.visible=n},ge.prototype.setActive=function(n){this.visible=n},ge.prototype.destroy=function(){oa(this)},ge.prototype.addComponent=function(n,e){return ra(this,n,e)},ge.prototype.addNewComponent=function(n,e){return ra(this,n,e)},ge.prototype.removeComponent=function(n){return rB(this,n)},ge.prototype.getOrAddComponent=function(n,e){return sA(this,n,e)},ge.prototype.getComponent=function(n){return Im(this,n)},ge.prototype.getComponents=function(n,e){return rA(this,n,e)},ge.prototype.getComponentInChildren=function(n){return oA(this,n)},ge.prototype.getComponentsInChildren=function(n,e){return u0(this,n,e)},ge.prototype.getComponentInParent=function(n){return aA(this,n)},ge.prototype.getComponentsInParent=function(n,e){return lC(this,n,e)},Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return p0(this)},set:function(n){lA(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof sB?Nt(this.object):Nt(this)},set:function(n){bs(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof sB?Bi(this.object):Bi(this)},set:function(n){Ba(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return Yv(this)},set:function(n){pL(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return Yi(this)},set:function(n){wg(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return ht().set(0,0,1).applyQuaternion(Bi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return ht().set(1,0,0).applyQuaternion(Bi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return ht().set(0,1,0).applyQuaternion(Bi(this))}}),J4(ge);class Li extends Ae{constructor(e,i,s,r){var o=(...a)=>{super(...a),p(this,"alpha",1)};i!=null&&s!=null?(o(e,i,s),this.alpha=r):(o(e),this.alpha=1)}get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,i){const s=e;return s.alpha!=null&&(this.alpha=et.lerp(this.alpha,s.alpha,i)),super.lerp(e,i)}lerpColors(e,i,s){const r=e,o=i;return r.alpha!=null&&o.alpha!=null&&(this.alpha=et.lerp(r.alpha,o.alpha,s)),super.lerpColors(e,i,s)}multiply(e){const i=e;return i.alpha!=null&&(this.alpha=this.alpha*i.alpha),super.multiply(e)}fromArray(e,i=0){return this.alpha=e[i+3],super.fromArray(e,i)}}const dC=te("debuggetcomponent"),uC=te("debuginstantiate");var d9=(n=>(n[n.None=0]="None",n[n.HideInHierarchy=1]="HideInHierarchy",n[n.HideInInspector=2]="HideInInspector",n[n.DontSaveInEditor=4]="DontSaveInEditor",n[n.NotEditable=8]="NotEditable",n[n.DontSaveInBuild=16]="DontSaveInBuild",n[n.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",n[n.DontSave=52]="DontSave",n[n.HideAndDontSave=61]="HideAndDontSave",n))(d9||{});class tc{constructor(){p(this,"idProvider"),p(this,"parent"),p(this,"keepWorldPosition"),p(this,"position"),p(this,"rotation"),p(this,"scale"),p(this,"visible"),p(this,"context"),p(this,"components")}clone(){var e,i,s;const r=new tc;return r.idProvider=this.idProvider,r.parent=this.parent,r.keepWorldPosition=this.keepWorldPosition,r.position=(e=this.position)==null?void 0:e.clone(),r.rotation=(i=this.rotation)==null?void 0:i.clone(),r.scale=(s=this.scale)==null?void 0:s.clone(),r.visible=this.visible,r.context=this.context,r.components=this.components,r}cloneAssign(e){var i,s,r;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(i=e.position)==null?void 0:i.clone(),this.rotation=(s=e.rotation)==null?void 0:s.clone(),this.scale=(r=e.scale)==null?void 0:r.clone(),this.visible=e.visible,this.context=e.context,this.components=e.components}}function p0(n){return n.visible}function lA(n,e){return typeof e=="number"&&(e=e>.5),n.visible=e,n.visible}function u9(n){return n[Ch]||pC(n)}function p9(n,e){n[C4]=e}function pC(n){return dl.isUsingInstancing(n)}function oB(n,e){return vg(n,e,!0,!0)}const m9=Symbol("isDestroyed");function Lm(n){return n[m9]}function f9(n,e){n[m9]=e}const aB=Symbol("isDontDestroy");function m0(n,e=!0){n[aB]=e}const mC=[],fC=[];function oa(n,e=!0,i=!1){mC.length=0,fC.length=0,lB(n,e,!0);for(const s of mC)s.gameObject=null,s.context=null;for(const s of fC)f9(s,!0),i&&Ki(s),_4(s);fC.length=0,mC.length=0}function lB(n,e=!0,i=!0){var s;if(n==null)return;const r=n;if(r.isComponent){if(r[aB])return;mC.push(r);const l=r.gameObject;r.__internalDisable(),r.__internalDestroy(),r.gameObject=l;return}if(n[aB])return;const o=n;dC&&console.log(o),fC.push(o);const a=(s=o.userData)==null?void 0:s.components;if(a!=null&&Array.isArray(a)){let l=a.length;for(let c=0;c<a.length;c++){const h=a[c];lB(h,e,!1),a.length<l&&(l=a.length,c--)}}if(e&&o.children)for(const l of o.children)lB(l,e,!1);i&&o.removeFromParent()}function Pm(n,e,i=!0){return g9(n,e,i)}function*gC(n,e,i=!1,s=999,r=0){if(n!=null&&n.userData.components&&!(r>s)){for(const o of n.userData.components)e&&o?.isComponent===!0&&o instanceof e?yield o:yield o;if(i===!0)for(const o of n.children)yield*gC(o,e,!0,s,r+1)}}function g9(n,e,i,s=0){var r;if(n){if(n.isObject3D,s>1e3){console.warn("Failed to iterate components: too many levels");return}if((r=n.userData)!=null&&r.components)for(let o=0;o<n.userData.components.length;o++){const a=n.userData.components[o];if(a?.isComponent===!0){const l=e(a);if(l!==void 0)return l}}if(i&&n.children){const o=s+1;for(let a=0;a<n.children.length;a++){const l=n.children[a];if(!l)continue;const c=g9(l,e,i,o);if(c!==void 0)return c}}}}function f0(n,e=null){let i=null;e!==null&&(e.x!==void 0?(i=new tc,i.position=e):i=e);let s=Pt.Current;i!=null&&i.context&&(s=i.context),dC&&s.alias&&console.log("context",s.alias),i&&!i.idProvider&&(i.idProvider=new xr(Date.now()));const r=[],o={},a={},l=y9(s,n,i,r,o,a);l&&(ofe(o),rfe(a,o)),dC&&(P_(n,!0),P_(l,!0));const c={};if(i?.components!==!1){for(const h in r){const d=r[h],u=d.guid;i&&i.idProvider&&(d.guid=i.idProvider.generateUUID(),c[u]=d.guid,dC&&console.log(d.name,d.guid)),GC(d,s),d.__internalNewInstanceCreated&&d.__internalNewInstanceCreated()}for(const h in r){const d=r[h];d.resolveGuids&&d.resolveGuids(c),d.enabled!==!1&&(d.enabled=!0)}JS(s)}return l}function y9(n,e,i,s,r,o){var a;if(!e)return null;const l=e.userData;e.userData={};const c=e.children;e.children=[];const h=e.clone(!1);if(hC(h),e.userData=l,e.children=c,r[e.uuid]={original:e,clone:h},uC&&console.log("ADD",e,h),e.type==="SkinnedMesh"&&(o[e.uuid]={original:e,clone:h}),i?.visible!==void 0&&(h.visible=i.visible),i!=null&&i.idProvider){h.uuid=i.idProvider.generateUUID();const u=h;u&&(u.guid=h.uuid)}e.animations&&e.animations.length>0&&(h.animations=[...e.animations]);const d=e.parent;if(d&&d.add(h),i!=null&&i.position?bs(h,i.position):h.position.copy(e.position),i!=null&&i.rotation?Ba(h,i.rotation):h.quaternion.copy(e.quaternion),i!=null&&i.scale?h.scale.copy(i.scale):h.scale.copy(e.scale),i!=null&&i.parent&&i.parent!=="scene"){let u=null;if(typeof i.parent=="string"?u=vg(i.parent,n.scene,!0):u=i.parent,u){const m=i.keepWorldPosition===!0?u.attach:u.add;m?m.call(u,h):console.error("Invalid parent object",u,"received when instantiating:",e)}else console.warn("could not find parent:",i.parent)}for(const[u,m]of Object.entries(e.userData))u!=="components"&&(h.userData[u]=m);if((a=e.userData)!=null&&a.components){const u=e.userData.components,m=[];h.userData.components=m;for(let f=0;f<u.length;f++){const g=u[f],v=new g.constructor;d0(v,g),g[ib]!==void 0&&(v[ib]=g[ib]),m.push(v),v.gameObject=h,s.push(v),r[g.guid]={original:g,clone:v},Zb.dispatchComponentLifecycleEvent("component-added",v)}}i&&(i.position=void 0,i.rotation=void 0,i.scale=void 0,i.parent=void 0);for(const u in e.children){const m=e.children[u],f=y9(n,m,i,s,r,o);f&&h.add(f)}return h}function rfe(n,e){for(const i in n){const s=n[i],r=s.original,o=r.skeleton,a=s.clone;if(!o){console.warn("Skinned mesh has no skeleton?",s);continue}const l=o.bones,c=a.skeleton.clone();a.skeleton=c,a.bindMatrix.clone().copy(r.bindMatrix),a.bindMatrixInverse.copy(r.bindMatrixInverse);const h=[];c.bones=h;for(let d=0;d<l.length;d++){const u=l[d],m=e[u.uuid].clone;h.push(m)}}for(const i in n){const s=n[i].clone;s.skeleton.update(),s.bind(s.skeleton,s.bindMatrix),s.updateMatrixWorld(!0)}}function ofe(n){var e;for(const i in n){const s=n[i].clone;if(s!=null&&s.isObject3D&&(e=s?.userData)!=null&&e.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const h=[];o[l]=h;for(let d=0;d<c.length;d++){const u=c[d];if(typeof u!="object"){h.push(u);continue}const m=v9(o,l,u,n);m!==void 0?h.push(m):h.push(u)}}else if(typeof c=="object"){const h=v9(o,l,c,n);h!==void 0&&(o[l]=h)}}}}function v9(n,e,i,s){var r,o;if(i!=null)if(i.isComponent===!0){const a=i.gameObject;if(a){const l=a.uuid,c=(r=s[l])==null?void 0:r.clone;if(!c){uC&&console.log("reference did not change",e,n,i);return}const h=a.userData.components.indexOf(i);if(h>=0&&c.isObject3D)return uC&&console.log(e,l),c.userData.components[h];console.warn("could not find component",e,i)}}else if(i.isObject3D===!0){if(e==="gameObject")return;const a=i;if(a){const l=a.uuid,c=(o=s[l])==null?void 0:o.clone;if(c)return uC&&console.log(e,"old",i,"new",c),c}}else{if(i.isVector4||i.isVector3||i.isVector2||i.isQuaternion||i.isEuler||i.isColor===!0)return i.clone();if(i.isEventList===!0)return i.__internalOnInstantiate(s)}}var b9={exports:{}},A9={exports:{}};(function(){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(i,s){return i<<s|i>>>32-s},rotr:function(i,s){return i<<32-s|i>>>s},endian:function(i){if(i.constructor==Number)return e.rotl(i,8)&16711935|e.rotl(i,24)&4278255360;for(var s=0;s<i.length;s++)i[s]=e.endian(i[s]);return i},randomBytes:function(i){for(var s=[];i>0;i--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(i){for(var s=[],r=0,o=0;r<i.length;r++,o+=8)s[o>>>5]|=i[r]<<24-o%32;return s},wordsToBytes:function(i){for(var s=[],r=0;r<i.length*32;r+=8)s.push(i[r>>>5]>>>24-r%32&255);return s},bytesToHex:function(i){for(var s=[],r=0;r<i.length;r++)s.push((i[r]>>>4).toString(16)),s.push((i[r]&15).toString(16));return s.join("")},hexToBytes:function(i){for(var s=[],r=0;r<i.length;r+=2)s.push(parseInt(i.substr(r,2),16));return s},bytesToBase64:function(i){for(var s=[],r=0;r<i.length;r+=3)for(var o=i[r]<<16|i[r+1]<<8|i[r+2],a=0;a<4;a++)r*8+a*6<=i.length*8?s.push(n.charAt(o>>>6*(3-a)&63)):s.push("=");return s.join("")},base64ToBytes:function(i){i=i.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],r=0,o=0;r<i.length;o=++r%4)o!=0&&s.push((n.indexOf(i.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<o*2|n.indexOf(i.charAt(r))>>>6-o*2);return s}};A9.exports=e})();var afe=A9.exports,cB={utf8:{stringToBytes:function(n){return cB.bin.stringToBytes(unescape(encodeURIComponent(n)))},bytesToString:function(n){return decodeURIComponent(escape(cB.bin.bytesToString(n)))}},bin:{stringToBytes:function(n){for(var e=[],i=0;i<n.length;i++)e.push(n.charCodeAt(i)&255);return e},bytesToString:function(n){for(var e=[],i=0;i<n.length;i++)e.push(String.fromCharCode(n[i]));return e.join("")}}},x9=cB;/*!
|
|
4989
|
+
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis`,e))),r4()&&console.log("[onGetComponent] FIND",e),e==null))return null;for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r];let a=Object.getPrototypeOf(o);for(;a;){if(a===e.prototype)if(r4()&&console.log("[onGetComponent] MATCH BY PROTOYPE",a),i)i.push(o);else return o;a=Object.getPrototypeOf(a)}}return i||null}function Im(n,e){const i=c4(n,e);return i?Array.isArray(i)?i[0]:i:null}function rA(n,e,i,s=!0){return i||(i=[]),s&&(i.length=0),c4(n,e,i),i}function oA(n,e,i){var s;const r=Im(n,e);if(i===!1&&r?.enabled===!1)return null;if(r)return r;for(let o=0;o<((s=n?.children)==null?void 0:s.length);o++){const a=oA(n.children[o],e);if(a)return a}return null}function u0(n,e,i,s=!0){var r;i||(i=[]),s&&(i.length=0),rA(n,e,i,!1);for(let o=0;o<((r=n?.children)==null?void 0:r.length);o++)u0(n.children[o],e,i,!1);return i}function aA(n,e){if(!n)return null;if(Array.isArray(n)){for(let s=0;s<n.length;s++){const r=sfe(n[s]),o=aA(r,e);if(o)return o}return null}return Im(n,e)||(n.parent?aA(n.parent,e):null)}function lC(n,e,i,s=!0){return i||(i=[]),s&&(i.length=0),n?(rA(n,e,i,!1),n.parent?lC(n.parent,e,i,!1):i):i}function cC(n,e=void 0,i=!0){if(!n)return null;if(!e&&(e=Pt.Current,!e))return console.error("Can not search object without any needle context or scene!!!"),null;let s=e;if(s.isScene||(s=e?.scene),!s)return null;for(const r in s.children){const o=s.children[r];if(i===!1&&o[Ch]===!1)continue;const a=oA(o,n);if(a)return a}return null}function h4(n,e,i=void 0){if(!n)return e??[];if(e||(e=[]),e.length=0,!i&&(i=Pt.Current,!i))return console.error("Can not search object without any needle context or scene!!!"),e;"scene"in i&&(i=i.scene);const s=i;if(!s)return e;for(const r in s.children){const o=s.children[r];u0(o,n,e,!1)}return e}function hC(n){n&&n.isObject3D===!0&&K9(n,ge)}ge.prototype.SetActive=function(n){this.visible=n},ge.prototype.setActive=function(n){this.visible=n},ge.prototype.destroy=function(){oa(this)},ge.prototype.addComponent=function(n,e){return ra(this,n,e)},ge.prototype.addNewComponent=function(n,e){return ra(this,n,e)},ge.prototype.removeComponent=function(n){return rB(this,n)},ge.prototype.getOrAddComponent=function(n,e){return sA(this,n,e)},ge.prototype.getComponent=function(n){return Im(this,n)},ge.prototype.getComponents=function(n,e){return rA(this,n,e)},ge.prototype.getComponentInChildren=function(n){return oA(this,n)},ge.prototype.getComponentsInChildren=function(n,e){return u0(this,n,e)},ge.prototype.getComponentInParent=function(n){return aA(this,n)},ge.prototype.getComponentsInParent=function(n,e){return lC(this,n,e)},Object.getOwnPropertyDescriptor(ge.prototype,"activeSelf")||Object.defineProperty(ge.prototype,"activeSelf",{get:function(){return p0(this)},set:function(n){lA(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldPosition")||Object.defineProperty(ge.prototype,"worldPosition",{get:function(){return this instanceof sB?Nt(this.object):Nt(this)},set:function(n){bs(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldQuaternion")||Object.defineProperty(ge.prototype,"worldQuaternion",{get:function(){return this instanceof sB?Bi(this.object):Bi(this)},set:function(n){Ba(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRotation")||Object.defineProperty(ge.prototype,"worldRotation",{get:function(){return Yv(this)},set:function(n){pL(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldScale")||Object.defineProperty(ge.prototype,"worldScale",{get:function(){return Yi(this)},set:function(n){wg(this,n)}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldForward")||Object.defineProperty(ge.prototype,"worldForward",{get:function(){return ht().set(0,0,1).applyQuaternion(Bi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldRight")||Object.defineProperty(ge.prototype,"worldRight",{get:function(){return ht().set(1,0,0).applyQuaternion(Bi(this))}}),Object.getOwnPropertyDescriptor(ge.prototype,"worldUp")||Object.defineProperty(ge.prototype,"worldUp",{get:function(){return ht().set(0,1,0).applyQuaternion(Bi(this))}}),J9(ge);class Li extends Ae{constructor(e,i,s,r){var o=(...a)=>{super(...a),p(this,"alpha",1)};i!=null&&s!=null?(o(e,i,s),this.alpha=r):(o(e),this.alpha=1)}get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,i){const s=e;return s.alpha!=null&&(this.alpha=et.lerp(this.alpha,s.alpha,i)),super.lerp(e,i)}lerpColors(e,i,s){const r=e,o=i;return r.alpha!=null&&o.alpha!=null&&(this.alpha=et.lerp(r.alpha,o.alpha,s)),super.lerpColors(e,i,s)}multiply(e){const i=e;return i.alpha!=null&&(this.alpha=this.alpha*i.alpha),super.multiply(e)}fromArray(e,i=0){return this.alpha=e[i+3],super.fromArray(e,i)}}const dC=te("debuggetcomponent"),uC=te("debuginstantiate");var d4=(n=>(n[n.None=0]="None",n[n.HideInHierarchy=1]="HideInHierarchy",n[n.HideInInspector=2]="HideInInspector",n[n.DontSaveInEditor=4]="DontSaveInEditor",n[n.NotEditable=8]="NotEditable",n[n.DontSaveInBuild=16]="DontSaveInBuild",n[n.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",n[n.DontSave=52]="DontSave",n[n.HideAndDontSave=61]="HideAndDontSave",n))(d4||{});class tc{constructor(){p(this,"idProvider"),p(this,"parent"),p(this,"keepWorldPosition"),p(this,"position"),p(this,"rotation"),p(this,"scale"),p(this,"visible"),p(this,"context"),p(this,"components")}clone(){var e,i,s;const r=new tc;return r.idProvider=this.idProvider,r.parent=this.parent,r.keepWorldPosition=this.keepWorldPosition,r.position=(e=this.position)==null?void 0:e.clone(),r.rotation=(i=this.rotation)==null?void 0:i.clone(),r.scale=(s=this.scale)==null?void 0:s.clone(),r.visible=this.visible,r.context=this.context,r.components=this.components,r}cloneAssign(e){var i,s,r;this.idProvider=e.idProvider,this.parent=e.parent,this.keepWorldPosition=e.keepWorldPosition,this.position=(i=e.position)==null?void 0:i.clone(),this.rotation=(s=e.rotation)==null?void 0:s.clone(),this.scale=(r=e.scale)==null?void 0:r.clone(),this.visible=e.visible,this.context=e.context,this.components=e.components}}function p0(n){return n.visible}function lA(n,e){return typeof e=="number"&&(e=e>.5),n.visible=e,n.visible}function u4(n){return n[Ch]||pC(n)}function p4(n,e){n[C9]=e}function pC(n){return dl.isUsingInstancing(n)}function oB(n,e){return vg(n,e,!0,!0)}const m4=Symbol("isDestroyed");function Lm(n){return n[m4]}function f4(n,e){n[m4]=e}const aB=Symbol("isDontDestroy");function m0(n,e=!0){n[aB]=e}const mC=[],fC=[];function oa(n,e=!0,i=!1){mC.length=0,fC.length=0,lB(n,e,!0);for(const s of mC)s.gameObject=null,s.context=null;for(const s of fC)f4(s,!0),i&&Ki(s),_9(s);fC.length=0,mC.length=0}function lB(n,e=!0,i=!0){var s;if(n==null)return;const r=n;if(r.isComponent){if(r[aB])return;mC.push(r);const l=r.gameObject;r.__internalDisable(),r.__internalDestroy(),r.gameObject=l;return}if(n[aB])return;const o=n;dC&&console.log(o),fC.push(o);const a=(s=o.userData)==null?void 0:s.components;if(a!=null&&Array.isArray(a)){let l=a.length;for(let c=0;c<a.length;c++){const h=a[c];lB(h,e,!1),a.length<l&&(l=a.length,c--)}}if(e&&o.children)for(const l of o.children)lB(l,e,!1);i&&o.removeFromParent()}function Pm(n,e,i=!0){return g4(n,e,i)}function*gC(n,e,i=!1,s=999,r=0){if(n!=null&&n.userData.components&&!(r>s)){for(const o of n.userData.components)e&&o?.isComponent===!0&&o instanceof e?yield o:yield o;if(i===!0)for(const o of n.children)yield*gC(o,e,!0,s,r+1)}}function g4(n,e,i,s=0){var r;if(n){if(n.isObject3D,s>1e3){console.warn("Failed to iterate components: too many levels");return}if((r=n.userData)!=null&&r.components)for(let o=0;o<n.userData.components.length;o++){const a=n.userData.components[o];if(a?.isComponent===!0){const l=e(a);if(l!==void 0)return l}}if(i&&n.children){const o=s+1;for(let a=0;a<n.children.length;a++){const l=n.children[a];if(!l)continue;const c=g4(l,e,i,o);if(c!==void 0)return c}}}}function f0(n,e=null){let i=null;e!==null&&(e.x!==void 0?(i=new tc,i.position=e):i=e);let s=Pt.Current;i!=null&&i.context&&(s=i.context),dC&&s.alias&&console.log("context",s.alias),i&&!i.idProvider&&(i.idProvider=new xr(Date.now()));const r=[],o={},a={},l=y4(s,n,i,r,o,a);l&&(ofe(o),rfe(a,o)),dC&&(P_(n,!0),P_(l,!0));const c={};if(i?.components!==!1){for(const h in r){const d=r[h],u=d.guid;i&&i.idProvider&&(d.guid=i.idProvider.generateUUID(),c[u]=d.guid,dC&&console.log(d.name,d.guid)),GC(d,s),d.__internalNewInstanceCreated&&d.__internalNewInstanceCreated()}for(const h in r){const d=r[h];d.resolveGuids&&d.resolveGuids(c),d.enabled!==!1&&(d.enabled=!0)}JS(s)}return l}function y4(n,e,i,s,r,o){var a;if(!e)return null;const l=e.userData;e.userData={};const c=e.children;e.children=[];const h=e.clone(!1);if(hC(h),e.userData=l,e.children=c,r[e.uuid]={original:e,clone:h},uC&&console.log("ADD",e,h),e.type==="SkinnedMesh"&&(o[e.uuid]={original:e,clone:h}),i?.visible!==void 0&&(h.visible=i.visible),i!=null&&i.idProvider){h.uuid=i.idProvider.generateUUID();const u=h;u&&(u.guid=h.uuid)}e.animations&&e.animations.length>0&&(h.animations=[...e.animations]);const d=e.parent;if(d&&d.add(h),i!=null&&i.position?bs(h,i.position):h.position.copy(e.position),i!=null&&i.rotation?Ba(h,i.rotation):h.quaternion.copy(e.quaternion),i!=null&&i.scale?h.scale.copy(i.scale):h.scale.copy(e.scale),i!=null&&i.parent&&i.parent!=="scene"){let u=null;if(typeof i.parent=="string"?u=vg(i.parent,n.scene,!0):u=i.parent,u){const m=i.keepWorldPosition===!0?u.attach:u.add;m?m.call(u,h):console.error("Invalid parent object",u,"received when instantiating:",e)}else console.warn("could not find parent:",i.parent)}for(const[u,m]of Object.entries(e.userData))u!=="components"&&(h.userData[u]=m);if((a=e.userData)!=null&&a.components){const u=e.userData.components,m=[];h.userData.components=m;for(let f=0;f<u.length;f++){const g=u[f],v=new g.constructor;d0(v,g),g[ib]!==void 0&&(v[ib]=g[ib]),m.push(v),v.gameObject=h,s.push(v),r[g.guid]={original:g,clone:v},Zb.dispatchComponentLifecycleEvent("component-added",v)}}i&&(i.position=void 0,i.rotation=void 0,i.scale=void 0,i.parent=void 0);for(const u in e.children){const m=e.children[u],f=y4(n,m,i,s,r,o);f&&h.add(f)}return h}function rfe(n,e){for(const i in n){const s=n[i],r=s.original,o=r.skeleton,a=s.clone;if(!o){console.warn("Skinned mesh has no skeleton?",s);continue}const l=o.bones,c=a.skeleton.clone();a.skeleton=c,a.bindMatrix.clone().copy(r.bindMatrix),a.bindMatrixInverse.copy(r.bindMatrixInverse);const h=[];c.bones=h;for(let d=0;d<l.length;d++){const u=l[d],m=e[u.uuid].clone;h.push(m)}}for(const i in n){const s=n[i].clone;s.skeleton.update(),s.bind(s.skeleton,s.bindMatrix),s.updateMatrixWorld(!0)}}function ofe(n){var e;for(const i in n){const s=n[i].clone;if(s!=null&&s.isObject3D&&(e=s?.userData)!=null&&e.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r],a=Object.entries(o);for(const[l,c]of a)if(Array.isArray(c)){const h=[];o[l]=h;for(let d=0;d<c.length;d++){const u=c[d];if(typeof u!="object"){h.push(u);continue}const m=v4(o,l,u,n);m!==void 0?h.push(m):h.push(u)}}else if(typeof c=="object"){const h=v4(o,l,c,n);h!==void 0&&(o[l]=h)}}}}function v4(n,e,i,s){var r,o;if(i!=null)if(i.isComponent===!0){const a=i.gameObject;if(a){const l=a.uuid,c=(r=s[l])==null?void 0:r.clone;if(!c){uC&&console.log("reference did not change",e,n,i);return}const h=a.userData.components.indexOf(i);if(h>=0&&c.isObject3D)return uC&&console.log(e,l),c.userData.components[h];console.warn("could not find component",e,i)}}else if(i.isObject3D===!0){if(e==="gameObject")return;const a=i;if(a){const l=a.uuid,c=(o=s[l])==null?void 0:o.clone;if(c)return uC&&console.log(e,"old",i,"new",c),c}}else{if(i.isVector4||i.isVector3||i.isVector2||i.isQuaternion||i.isEuler||i.isColor===!0)return i.clone();if(i.isEventList===!0)return i.__internalOnInstantiate(s)}}var b4={exports:{}},A4={exports:{}};(function(){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(i,s){return i<<s|i>>>32-s},rotr:function(i,s){return i<<32-s|i>>>s},endian:function(i){if(i.constructor==Number)return e.rotl(i,8)&16711935|e.rotl(i,24)&4278255360;for(var s=0;s<i.length;s++)i[s]=e.endian(i[s]);return i},randomBytes:function(i){for(var s=[];i>0;i--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(i){for(var s=[],r=0,o=0;r<i.length;r++,o+=8)s[o>>>5]|=i[r]<<24-o%32;return s},wordsToBytes:function(i){for(var s=[],r=0;r<i.length*32;r+=8)s.push(i[r>>>5]>>>24-r%32&255);return s},bytesToHex:function(i){for(var s=[],r=0;r<i.length;r++)s.push((i[r]>>>4).toString(16)),s.push((i[r]&15).toString(16));return s.join("")},hexToBytes:function(i){for(var s=[],r=0;r<i.length;r+=2)s.push(parseInt(i.substr(r,2),16));return s},bytesToBase64:function(i){for(var s=[],r=0;r<i.length;r+=3)for(var o=i[r]<<16|i[r+1]<<8|i[r+2],a=0;a<4;a++)r*8+a*6<=i.length*8?s.push(n.charAt(o>>>6*(3-a)&63)):s.push("=");return s.join("")},base64ToBytes:function(i){i=i.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],r=0,o=0;r<i.length;o=++r%4)o!=0&&s.push((n.indexOf(i.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<o*2|n.indexOf(i.charAt(r))>>>6-o*2);return s}};A4.exports=e})();var afe=A4.exports,cB={utf8:{stringToBytes:function(n){return cB.bin.stringToBytes(unescape(encodeURIComponent(n)))},bytesToString:function(n){return decodeURIComponent(escape(cB.bin.bytesToString(n)))}},bin:{stringToBytes:function(n){for(var e=[],i=0;i<n.length;i++)e.push(n.charCodeAt(i)&255);return e},bytesToString:function(n){for(var e=[],i=0;i<n.length;i++)e.push(String.fromCharCode(n[i]));return e.join("")}}},x4=cB;/*!
|
|
4990
4990
|
* Determine if an object is a Buffer
|
|
4991
4991
|
*
|
|
4992
4992
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
4993
4993
|
* @license MIT
|
|
4994
|
-
*/var lfe=function(n){return n!=null&&(w9(n)||cfe(n)||!!n._isBuffer)};function w9(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function cfe(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&w9(n.slice(0,0))}(function(){var n=afe,e=x9.utf8,i=lfe,s=x9.bin,r=function(o,a){o.constructor==String?a&&a.encoding==="binary"?o=s.stringToBytes(o):o=e.stringToBytes(o):i(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var l=n.bytesToWords(o),c=o.length*8,h=1732584193,d=-271733879,u=-1732584194,m=271733878,f=0;f<l.length;f++)l[f]=(l[f]<<8|l[f]>>>24)&16711935|(l[f]<<24|l[f]>>>8)&4278255360;l[c>>>5]|=128<<c%32,l[(c+64>>>9<<4)+14]=c;for(var g=r._ff,v=r._gg,y=r._hh,b=r._ii,f=0;f<l.length;f+=16){var A=h,x=d,w=u,_=m;h=g(h,d,u,m,l[f+0],7,-680876936),m=g(m,h,d,u,l[f+1],12,-389564586),u=g(u,m,h,d,l[f+2],17,606105819),d=g(d,u,m,h,l[f+3],22,-1044525330),h=g(h,d,u,m,l[f+4],7,-176418897),m=g(m,h,d,u,l[f+5],12,1200080426),u=g(u,m,h,d,l[f+6],17,-1473231341),d=g(d,u,m,h,l[f+7],22,-45705983),h=g(h,d,u,m,l[f+8],7,1770035416),m=g(m,h,d,u,l[f+9],12,-1958414417),u=g(u,m,h,d,l[f+10],17,-42063),d=g(d,u,m,h,l[f+11],22,-1990404162),h=g(h,d,u,m,l[f+12],7,1804603682),m=g(m,h,d,u,l[f+13],12,-40341101),u=g(u,m,h,d,l[f+14],17,-1502002290),d=g(d,u,m,h,l[f+15],22,1236535329),h=v(h,d,u,m,l[f+1],5,-165796510),m=v(m,h,d,u,l[f+6],9,-1069501632),u=v(u,m,h,d,l[f+11],14,643717713),d=v(d,u,m,h,l[f+0],20,-373897302),h=v(h,d,u,m,l[f+5],5,-701558691),m=v(m,h,d,u,l[f+10],9,38016083),u=v(u,m,h,d,l[f+15],14,-660478335),d=v(d,u,m,h,l[f+4],20,-405537848),h=v(h,d,u,m,l[f+9],5,568446438),m=v(m,h,d,u,l[f+14],9,-1019803690),u=v(u,m,h,d,l[f+3],14,-187363961),d=v(d,u,m,h,l[f+8],20,1163531501),h=v(h,d,u,m,l[f+13],5,-1444681467),m=v(m,h,d,u,l[f+2],9,-51403784),u=v(u,m,h,d,l[f+7],14,1735328473),d=v(d,u,m,h,l[f+12],20,-1926607734),h=y(h,d,u,m,l[f+5],4,-378558),m=y(m,h,d,u,l[f+8],11,-2022574463),u=y(u,m,h,d,l[f+11],16,1839030562),d=y(d,u,m,h,l[f+14],23,-35309556),h=y(h,d,u,m,l[f+1],4,-1530992060),m=y(m,h,d,u,l[f+4],11,1272893353),u=y(u,m,h,d,l[f+7],16,-155497632),d=y(d,u,m,h,l[f+10],23,-1094730640),h=y(h,d,u,m,l[f+13],4,681279174),m=y(m,h,d,u,l[f+0],11,-358537222),u=y(u,m,h,d,l[f+3],16,-722521979),d=y(d,u,m,h,l[f+6],23,76029189),h=y(h,d,u,m,l[f+9],4,-640364487),m=y(m,h,d,u,l[f+12],11,-421815835),u=y(u,m,h,d,l[f+15],16,530742520),d=y(d,u,m,h,l[f+2],23,-995338651),h=b(h,d,u,m,l[f+0],6,-198630844),m=b(m,h,d,u,l[f+7],10,1126891415),u=b(u,m,h,d,l[f+14],15,-1416354905),d=b(d,u,m,h,l[f+5],21,-57434055),h=b(h,d,u,m,l[f+12],6,1700485571),m=b(m,h,d,u,l[f+3],10,-1894986606),u=b(u,m,h,d,l[f+10],15,-1051523),d=b(d,u,m,h,l[f+1],21,-2054922799),h=b(h,d,u,m,l[f+8],6,1873313359),m=b(m,h,d,u,l[f+15],10,-30611744),u=b(u,m,h,d,l[f+6],15,-1560198380),d=b(d,u,m,h,l[f+13],21,1309151649),h=b(h,d,u,m,l[f+4],6,-145523070),m=b(m,h,d,u,l[f+11],10,-1120210379),u=b(u,m,h,d,l[f+2],15,718787259),d=b(d,u,m,h,l[f+9],21,-343485551),h=h+A>>>0,d=d+x>>>0,u=u+w>>>0,m=m+_>>>0}return n.endian([h,d,u,m])};r._ff=function(o,a,l,c,h,d,u){var m=o+(a&l|~a&c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._gg=function(o,a,l,c,h,d,u){var m=o+(a&c|l&~c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._hh=function(o,a,l,c,h,d,u){var m=o+(a^l^c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._ii=function(o,a,l,c,h,d,u){var m=o+(l^(a|~c))+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._blocksize=16,r._digestsize=16,b9.exports=function(o,a){if(o==null)throw new Error("Illegal argument "+o);var l=n.wordsToBytes(r(o,a));return a&&a.asBytes?l:a&&a.asString?s.bytesToString(l):n.bytesToHex(l)}})();var hfe=b9.exports;const _9=PS(hfe);var km;(n=>{n.baseUrl="https://networking.needle.tools";function e(c){return _9(new Uint8Array(c))}n.hashMD5=e;function i(c){const h=_9(new Uint8Array(c),{encoding:"binary",asBytes:!0});return btoa(String.fromCharCode(...h))}n.hashMD5_Base64=i;function s(c){const h=new Uint8Array(c);return crypto.subtle.digest("SHA-256",h).then(d=>btoa(String.fromCharCode(...new Uint8Array(d))))}n.hashSha256=s;function r(c){const h=c.filesize/1024/1024;return zl()?h<50:h<5}n.canUpload=r;async function o(c,h){var d;const u=n.baseUrl;if(u){if(!c.name)return console.error("Upload: file name is missing"),null}else return console.error("Blob storage base url is not set"),null;let m=null;c instanceof File?m=await c.arrayBuffer():m=c.data;const f=m.byteLength,g=f/1024/1024;if(g>50)return h?.silent!==!0&&Oi(`File (${g.toFixed(1)}MB) is too large for uploading (see console for details)`),console.warn(`Your file is too large for uploading (${g.toFixed(1)}MB). Max allowed size is 50MB`),null;if(!zl()&&g>5)return h?.silent!==!0&&Oi('File is too large for uploading. Please get a <a href="https://needle.tools/pricing" target="_blank">commercial license</a> to upload files larger than 5MB'),console.warn(`Your file is too large for uploading (${g.toFixed(1)}MB). Max size is 5MB for non-commercial users. Please get a commercial license at https://needle.tools/pricing for larger files (up to 50MB)`),null;if(f<1)return console.warn(`Your file is too small for uploading (${g.toFixed(1)}MB). Min size is 1 byte`),null;const v=i(m),y={filename:c.name,"Content-Md5":v,"Content-Type":c.type||"application/octet-stream",FileSize:f.toString(),"Content-Disposition":`attachment; filename="${c.name}"`,"x-amz-server-side-encryption":"AES256"},b=await fetch(u+"/api/needle/blob",{method:"POST",headers:y,signal:h?.abort}).then(A=>A.json()).catch(A=>(console.error(A),null));if(b==null)return console.warn("Upload failed..."),null;if("error"in b)return console.error(b.error),null;if("upload"in b&&b.upload){let A=function(_){var S;return(S=h?.onProgress)==null||S.call(null,{progress01:0,state:"inprogress"}),fetch(_,{method:"PUT",headers:y,body:m,signal:h?.abort}).then(C=>{var R;return(R=h?.onProgress)==null||R.call(null,{progress01:1,state:"finished"}),C}).catch(C=>C)};console.debug("Uploading file",b.upload);let x=!1,w=null;for(let _=0;_<3;_++)try{if(x)break;if((d=h?.abort)!=null&&d.aborted)return console.debug("Aborted upload"),null;const S=await A(b.upload);S instanceof Error?(w=S,await bl(1e3*_)):S.ok&&(console.debug("File uploaded successfully"),x=!0)}catch(S){console.error(S)}if(!x)return console.error(w?.message||"Failed to upload file"),null}if("download"in b){const A=u+b.download;return console.debug("File found in blob storage",A),{key:b.key,success:!0,download_url:A}}return null}n.upload=o;function a(c){return`${n.baseUrl}/api/needle/blob/${c}`}n.getBlobUrlForKey=a;async function l(c,h){var d;const u=await fetch(c),m=(d=u.body)==null?void 0:d.getReader(),f=u.headers.get("Content-Length"),g=f?parseInt(f):0;if(!m)return null;let v=0;const y=[];for(;;){const{done:x,value:w}=await m.read();if(w&&(y.push(w),v+=w.length,h?.call(null,new ProgressEvent("progress",{loaded:v,total:g}))),x)break}const b=new Uint8Array(v);let A=0;for(const x of y)b.set(x,A),A+=x.length;return b}n.download=l})(km||(km={}));const xu=te("debugaddressables");class S9{constructor(e){p(this,"_context"),p(this,"_assetReferences",{}),p(this,"preUpdate",()=>{}),this._context=e,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const e=this._context.pre_update_callbacks.indexOf(this.preUpdate);e>=0&&this._context.pre_update_callbacks.splice(e,1);for(const i in this._assetReferences){const s=this._assetReferences[i];s?.unload()}this._assetReferences={}}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.url&&(this._assetReferences[e.url]?console.warn("Asset reference already registered",e):this._assetReferences[e.url]=e),e}unregisterAssetReference(e){e.url&&delete this._assetReferences[e.url]}}const hB=Symbol("assetReference"),g0=class{constructor(n,e,i=null){p(this,"_loading"),p(this,"_asset"),p(this,"_glbRoot"),p(this,"_url"),p(this,"_progressListeners",[]),p(this,"_hash"),p(this,"_hashedUri"),p(this,"_isLoadingRawBinary",!1),p(this,"_rawBinary"),this._url=n,this._hash=e,n.includes("?v=")?this._hashedUri=n:this._hashedUri=e?n+"?v="+e:n,i!==null&&(this.asset=i),N4(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(n,e){if(!e&&(e=Pt.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const i=e.addressables,s=i.findAssetReference(n);if(s)return s;const r=new g0(n,e.hash);return i.registerAssetReference(r),r}static getOrCreate(n,e,i){if(typeof n=="string"){if(!i&&(i=Pt.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=n.context,n=n.sourceId;const s=Qd(n,e);xu&&console.log("GetOrCreate Addressable from",n,e,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new g0(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(n){this._asset=n}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:")||this._url.startsWith("www.")||this._url.includes("/"))}get rawAsset(){return this._asset}async onResolvePrefab(n){return n===this.url&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Lm(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(xu&&console.log("Unload",this.asset),this.asset.scene&&oa(this.asset.scene,!0,!0),oa(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Pt.Current&&Pt.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,xu&&console.log("Preload",this._hashedUri);const n=await km.download(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=n?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(n){if(xu&&console.log("loadAssetAsync",this.url),!this.mustLoad)return this.asset;if(n&&this._progressListeners.push(n),this._loading!==void 0)return this._loading.then(s=>this.asset);const e=Pt.Current;this._rawBinary?(this._loading=vl().parseSync(e,this._rawBinary,this.url,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(xu&&console.log("Load async",this.url),this._loading=vl().loadSync(e,this._hashedUri,this.url,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[hB]=this,this._glbRoot&&(this._glbRoot[hB]=this),this.asset&&(this.asset[hB]=this),JS(e),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(n){return this.onInstantiate(n,!1)}async instantiateSynced(n,e=!0){return this.onInstantiate(n,!0,e)}beginListenDownload(n){this._progressListeners.indexOf(n)<0&&this._progressListeners.push(n)}endListenDownload(n){const e=this._progressListeners.indexOf(n);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(n){for(const e of this._progressListeners)e(this,n)}async onInstantiate(n,e=!1,i){const s=Pt.Current,r=new tc;if(n instanceof ge?r.parent=n:n&&(Object.assign(r,n),r.cloneAssign(n)),r.parent||(r.parent=s.scene),this.mustLoad&&await this.loadAssetAsync(),xu&&console.log("Instantiate",this.url,"parent:",n),this.asset){xu&&console.log("Add to scene",this.asset);let o=g0.currentlyInstantiating.get(this.url);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.url+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,g0.currentlyInstantiating.set(this.url,o),e){r.context=s;const a=this.asset;a.guid=this.url;const l=Qk(a,r,void 0,i);if(l)return l}else{const a=f0(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,g0.currentlyInstantiating.set(this.url,o)})}}else xu&&console.warn("Failed to load asset",this.url);return null}tryGetActualGameObjectRoot(n){if(n&&n.scene){const e=n.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let ei=g0;p(ei,"currentlyInstantiating",new Map);class dfe extends Ha{constructor(){super([ei],"AssetReferenceSerializer")}onSerialize(e,i){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,i){if(typeof e=="string")return i.context?i.gltfId?ei.getOrCreate(i.gltfId,e,i.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ge){if(!i.context)return console.error("Missing context"),null;if(!i.gltfId)return console.error("Missing source id"),null;const s=e,r=i.context,o=s.guid??s.uuid,a=r.addressables.findAssetReference(o);if(a)return a;const l=new ei(o,void 0,s);return r.addressables.registerAssetReference(l),l}return null}}new dfe;const ufe=Promise.resolve(null),yC=class{constructor(n){p(this,"url"),p(this,"_bitmap"),p(this,"_bitmapObject"),p(this,"loader",null),this.url=n}static getOrCreate(n){let e=yC.imageReferences.get(n);return e||(e=new yC(n),yC.imageReferences.set(n,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const n=new Image;return n.src=this.url,n}createTexture(){return this.url?(this.loader||(this.loader=new lc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):ufe}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((n,e)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,n(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),n(null)}),i.src=this.url}),this._bitmap)}};let vC=yC;p(vC,"imageReferences",new Map);class C9 extends Ha{constructor(){super([vC],"ImageReferenceSerializer")}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"){const s=Qd(i.gltfId,e);return vC.getOrCreate(s)}}}new C9;const bC=class{constructor(n){p(this,"url"),p(this,"res"),this.url=n}static getOrCreate(n){let e=bC.cache.get(n);return e||(e=new bC(n),bC.cache.set(n,e)),e}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(n=>n.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(n=>n.text())}};let AC=bC;p(AC,"cache",new Map);class M9 extends Ha{constructor(){super([AC],"FileReferenceSerializer")}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"){const s=Qd(i.gltfId,e);return AC.getOrCreate(s)}}}new M9;class pfe{constructor(e){p(this,"context"),p(this,"mixers",[]),this.context=e}onDestroy(){this.mixers.forEach(e=>e.stopAllAction()),this.mixers.length=0}registerAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(e)||this.mixers.push(e)}unregisterAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.unregisterAnimationMixer called with null or undefined mixer");return}const i=this.mixers.indexOf(e);i!==-1&&this.mixers.splice(i,1)}}class y0{static tryGetActionsFromMixer(e){return e._actions||null}static tryGetAnimationClipsFromObjectHierarchy(e,i){if(i||(i=new Array),e)e.animations&&i.push(...e.animations);else return i;if(e.children)for(const s of e.children)this.tryGetAnimationClipsFromObjectHierarchy(s,i);return i}static assignAnimationsFromFile(e,i){if(!e||!e.animations){console.debug("No animations found in file");return}for(let r=0;r<e.animations.length;r++){const o=e.animations[r];if(!o.tracks||o.tracks.length<=0){console.warn("Animation has no tracks");continue}for(const a in o.tracks){const l=o.tracks[a],c=Zt.parseTrackName(l.name);let h=Zt.findNode(e.scene,c.nodeName);if(!h){const u=l.__objectName??l.name.substring(0,l.name.indexOf("."));if(h=e.scene.getObjectByProperty("uuid",u),!h)continue}let d=s(h);if(!d){if(!(i!=null&&i.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}d=i.createAnimationComponent(e.scene,o)}d.addClip&&d.addClip(o)}}function s(r){var o;if(!r)return null;const a=(o=r.userData)==null?void 0:o.components;if(a&&a.length>0){for(let l=0;l<a.length;l++)if(a[l].isAnimationComponent===!0)return r}return s(r.parent)}}}var xC=(n=>(n.Visible="application-visible",n.Hidden="application-hidden",n.MuteChanged="application-mutechanged",n))(xC||{});let wC=!1;const v0=[];function Bm(){if(wC)return;je()&&console.debug("User interaction registered: audio can now be played"),wC=!0;const n=[...v0];v0.length=0,n.forEach(e=>e())}document.addEventListener("mousedown",Bm),document.addEventListener("pointerup",Bm),document.addEventListener("click",Bm),document.addEventListener("dragstart",Bm),document.addEventListener("touchend",Bm),document.addEventListener("keydown",Bm),Et.onXRSessionStart(()=>{Bm()});const E9=class extends EventTarget{constructor(n){super(),p(this,"_mute",!1),p(this,"context"),p(this,"_isVisible",!0),this.context=n,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return wC}static registerWaitForInteraction(n){if(n!==null){if(wC){n();return}v0.indexOf(n)===-1&&v0.push(n)}}static unregisterWaitForInteraction(n){const e=v0.indexOf(n);e!==-1&&v0.splice(e,1)}get muted(){return this._mute}set muted(n){n!==this._mute&&(this._mute=n,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(n){switch(n.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}};let Xh=E9;p(Xh,"registerWaitForAllowAudio",E9.registerWaitForInteraction);function*T9(n,e=null){const i=e?e.time:Pt.Current.time,s=i.time;for(;i.time-s<n;)yield}function*mfe(n){for(let e=0;e<n;e++)yield}function*R9(n){let e=!0;for(n.then(()=>e=!1),n.catch(()=>e=!1);e;)yield}/*!
|
|
4994
|
+
*/var lfe=function(n){return n!=null&&(w4(n)||cfe(n)||!!n._isBuffer)};function w4(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function cfe(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&w4(n.slice(0,0))}(function(){var n=afe,e=x4.utf8,i=lfe,s=x4.bin,r=function(o,a){o.constructor==String?a&&a.encoding==="binary"?o=s.stringToBytes(o):o=e.stringToBytes(o):i(o)?o=Array.prototype.slice.call(o,0):!Array.isArray(o)&&o.constructor!==Uint8Array&&(o=o.toString());for(var l=n.bytesToWords(o),c=o.length*8,h=1732584193,d=-271733879,u=-1732584194,m=271733878,f=0;f<l.length;f++)l[f]=(l[f]<<8|l[f]>>>24)&16711935|(l[f]<<24|l[f]>>>8)&4278255360;l[c>>>5]|=128<<c%32,l[(c+64>>>9<<4)+14]=c;for(var g=r._ff,v=r._gg,y=r._hh,b=r._ii,f=0;f<l.length;f+=16){var A=h,x=d,w=u,_=m;h=g(h,d,u,m,l[f+0],7,-680876936),m=g(m,h,d,u,l[f+1],12,-389564586),u=g(u,m,h,d,l[f+2],17,606105819),d=g(d,u,m,h,l[f+3],22,-1044525330),h=g(h,d,u,m,l[f+4],7,-176418897),m=g(m,h,d,u,l[f+5],12,1200080426),u=g(u,m,h,d,l[f+6],17,-1473231341),d=g(d,u,m,h,l[f+7],22,-45705983),h=g(h,d,u,m,l[f+8],7,1770035416),m=g(m,h,d,u,l[f+9],12,-1958414417),u=g(u,m,h,d,l[f+10],17,-42063),d=g(d,u,m,h,l[f+11],22,-1990404162),h=g(h,d,u,m,l[f+12],7,1804603682),m=g(m,h,d,u,l[f+13],12,-40341101),u=g(u,m,h,d,l[f+14],17,-1502002290),d=g(d,u,m,h,l[f+15],22,1236535329),h=v(h,d,u,m,l[f+1],5,-165796510),m=v(m,h,d,u,l[f+6],9,-1069501632),u=v(u,m,h,d,l[f+11],14,643717713),d=v(d,u,m,h,l[f+0],20,-373897302),h=v(h,d,u,m,l[f+5],5,-701558691),m=v(m,h,d,u,l[f+10],9,38016083),u=v(u,m,h,d,l[f+15],14,-660478335),d=v(d,u,m,h,l[f+4],20,-405537848),h=v(h,d,u,m,l[f+9],5,568446438),m=v(m,h,d,u,l[f+14],9,-1019803690),u=v(u,m,h,d,l[f+3],14,-187363961),d=v(d,u,m,h,l[f+8],20,1163531501),h=v(h,d,u,m,l[f+13],5,-1444681467),m=v(m,h,d,u,l[f+2],9,-51403784),u=v(u,m,h,d,l[f+7],14,1735328473),d=v(d,u,m,h,l[f+12],20,-1926607734),h=y(h,d,u,m,l[f+5],4,-378558),m=y(m,h,d,u,l[f+8],11,-2022574463),u=y(u,m,h,d,l[f+11],16,1839030562),d=y(d,u,m,h,l[f+14],23,-35309556),h=y(h,d,u,m,l[f+1],4,-1530992060),m=y(m,h,d,u,l[f+4],11,1272893353),u=y(u,m,h,d,l[f+7],16,-155497632),d=y(d,u,m,h,l[f+10],23,-1094730640),h=y(h,d,u,m,l[f+13],4,681279174),m=y(m,h,d,u,l[f+0],11,-358537222),u=y(u,m,h,d,l[f+3],16,-722521979),d=y(d,u,m,h,l[f+6],23,76029189),h=y(h,d,u,m,l[f+9],4,-640364487),m=y(m,h,d,u,l[f+12],11,-421815835),u=y(u,m,h,d,l[f+15],16,530742520),d=y(d,u,m,h,l[f+2],23,-995338651),h=b(h,d,u,m,l[f+0],6,-198630844),m=b(m,h,d,u,l[f+7],10,1126891415),u=b(u,m,h,d,l[f+14],15,-1416354905),d=b(d,u,m,h,l[f+5],21,-57434055),h=b(h,d,u,m,l[f+12],6,1700485571),m=b(m,h,d,u,l[f+3],10,-1894986606),u=b(u,m,h,d,l[f+10],15,-1051523),d=b(d,u,m,h,l[f+1],21,-2054922799),h=b(h,d,u,m,l[f+8],6,1873313359),m=b(m,h,d,u,l[f+15],10,-30611744),u=b(u,m,h,d,l[f+6],15,-1560198380),d=b(d,u,m,h,l[f+13],21,1309151649),h=b(h,d,u,m,l[f+4],6,-145523070),m=b(m,h,d,u,l[f+11],10,-1120210379),u=b(u,m,h,d,l[f+2],15,718787259),d=b(d,u,m,h,l[f+9],21,-343485551),h=h+A>>>0,d=d+x>>>0,u=u+w>>>0,m=m+_>>>0}return n.endian([h,d,u,m])};r._ff=function(o,a,l,c,h,d,u){var m=o+(a&l|~a&c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._gg=function(o,a,l,c,h,d,u){var m=o+(a&c|l&~c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._hh=function(o,a,l,c,h,d,u){var m=o+(a^l^c)+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._ii=function(o,a,l,c,h,d,u){var m=o+(l^(a|~c))+(h>>>0)+u;return(m<<d|m>>>32-d)+a},r._blocksize=16,r._digestsize=16,b4.exports=function(o,a){if(o==null)throw new Error("Illegal argument "+o);var l=n.wordsToBytes(r(o,a));return a&&a.asBytes?l:a&&a.asString?s.bytesToString(l):n.bytesToHex(l)}})();var hfe=b4.exports;const _4=PS(hfe);var km;(n=>{n.baseUrl="https://networking.needle.tools";function e(c){return _4(new Uint8Array(c))}n.hashMD5=e;function i(c){const h=_4(new Uint8Array(c),{encoding:"binary",asBytes:!0});return btoa(String.fromCharCode(...h))}n.hashMD5_Base64=i;function s(c){const h=new Uint8Array(c);return crypto.subtle.digest("SHA-256",h).then(d=>btoa(String.fromCharCode(...new Uint8Array(d))))}n.hashSha256=s;function r(c){const h=c.filesize/1024/1024;return zl()?h<50:h<5}n.canUpload=r;async function o(c,h){var d;const u=n.baseUrl;if(u){if(!c.name)return console.error("Upload: file name is missing"),null}else return console.error("Blob storage base url is not set"),null;let m=null;c instanceof File?m=await c.arrayBuffer():m=c.data;const f=m.byteLength,g=f/1024/1024;if(g>50)return h?.silent!==!0&&Oi(`File (${g.toFixed(1)}MB) is too large for uploading (see console for details)`),console.warn(`Your file is too large for uploading (${g.toFixed(1)}MB). Max allowed size is 50MB`),null;if(!zl()&&g>5)return h?.silent!==!0&&Oi('File is too large for uploading. Please get a <a href="https://needle.tools/pricing" target="_blank">commercial license</a> to upload files larger than 5MB'),console.warn(`Your file is too large for uploading (${g.toFixed(1)}MB). Max size is 5MB for non-commercial users. Please get a commercial license at https://needle.tools/pricing for larger files (up to 50MB)`),null;if(f<1)return console.warn(`Your file is too small for uploading (${g.toFixed(1)}MB). Min size is 1 byte`),null;const v=i(m),y={filename:c.name,"Content-Md5":v,"Content-Type":c.type||"application/octet-stream",FileSize:f.toString(),"Content-Disposition":`attachment; filename="${c.name}"`,"x-amz-server-side-encryption":"AES256"},b=await fetch(u+"/api/needle/blob",{method:"POST",headers:y,signal:h?.abort}).then(A=>A.json()).catch(A=>(console.error(A),null));if(b==null)return console.warn("Upload failed..."),null;if("error"in b)return console.error(b.error),null;if("upload"in b&&b.upload){let A=function(_){var S;return(S=h?.onProgress)==null||S.call(null,{progress01:0,state:"inprogress"}),fetch(_,{method:"PUT",headers:y,body:m,signal:h?.abort}).then(C=>{var R;return(R=h?.onProgress)==null||R.call(null,{progress01:1,state:"finished"}),C}).catch(C=>C)};console.debug("Uploading file",b.upload);let x=!1,w=null;for(let _=0;_<3;_++)try{if(x)break;if((d=h?.abort)!=null&&d.aborted)return console.debug("Aborted upload"),null;const S=await A(b.upload);S instanceof Error?(w=S,await bl(1e3*_)):S.ok&&(console.debug("File uploaded successfully"),x=!0)}catch(S){console.error(S)}if(!x)return console.error(w?.message||"Failed to upload file"),null}if("download"in b){const A=u+b.download;return console.debug("File found in blob storage",A),{key:b.key,success:!0,download_url:A}}return null}n.upload=o;function a(c){return`${n.baseUrl}/api/needle/blob/${c}`}n.getBlobUrlForKey=a;async function l(c,h){var d;const u=await fetch(c),m=(d=u.body)==null?void 0:d.getReader(),f=u.headers.get("Content-Length"),g=f?parseInt(f):0;if(!m)return null;let v=0;const y=[];for(;;){const{done:x,value:w}=await m.read();if(w&&(y.push(w),v+=w.length,h?.call(null,new ProgressEvent("progress",{loaded:v,total:g}))),x)break}const b=new Uint8Array(v);let A=0;for(const x of y)b.set(x,A),A+=x.length;return b}n.download=l})(km||(km={}));const xu=te("debugaddressables");class S4{constructor(e){p(this,"_context"),p(this,"_assetReferences",{}),p(this,"preUpdate",()=>{}),this._context=e,this._context.pre_update_callbacks.push(this.preUpdate)}dispose(){const e=this._context.pre_update_callbacks.indexOf(this.preUpdate);e>=0&&this._context.pre_update_callbacks.splice(e,1);for(const i in this._assetReferences){const s=this._assetReferences[i];s?.unload()}this._assetReferences={}}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.url&&(this._assetReferences[e.url]?console.warn("Asset reference already registered",e):this._assetReferences[e.url]=e),e}unregisterAssetReference(e){e.url&&delete this._assetReferences[e.url]}}const hB=Symbol("assetReference"),g0=class{constructor(n,e,i=null){p(this,"_loading"),p(this,"_asset"),p(this,"_glbRoot"),p(this,"_url"),p(this,"_progressListeners",[]),p(this,"_hash"),p(this,"_hashedUri"),p(this,"_isLoadingRawBinary",!1),p(this,"_rawBinary"),this._url=n,this._hash=e,n.includes("?v=")?this._hashedUri=n:this._hashedUri=e?n+"?v="+e:n,i!==null&&(this.asset=i),N9(this._url,this.onResolvePrefab.bind(this))}static getOrCreateFromUrl(n,e){if(!e&&(e=Pt.Current,!e))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.');const i=e.addressables,s=i.findAssetReference(n);if(s)return s;const r=new g0(n,e.hash);return i.registerAssetReference(r),r}static getOrCreate(n,e,i){if(typeof n=="string"){if(!i&&(i=Pt.Current,!i))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else i=n.context,n=n.sourceId;const s=Qd(n,e);xu&&console.log("GetOrCreate Addressable from",n,e,"FinalPath=",s);const r=i.addressables,o=r.findAssetReference(s);if(o)return o;const a=new g0(s,i.hash);return r.registerAssetReference(a),a}get asset(){return this._glbRoot??this._asset}set asset(n){this._asset=n}get uri(){return this._url}get url(){return this._url}get hasUrl(){return this._url!==void 0&&(this._url.startsWith("http")||this._url.startsWith("blob:")||this._url.startsWith("www.")||this._url.includes("/"))}get rawAsset(){return this._asset}async onResolvePrefab(n){return n===this.url&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||Lm(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(xu&&console.log("Unload",this.asset),this.asset.scene&&oa(this.asset.scene,!0,!0),oa(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Pt.Current&&Pt.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,xu&&console.log("Preload",this._hashedUri);const n=await km.download(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=n?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(n){if(xu&&console.log("loadAssetAsync",this.url),!this.mustLoad)return this.asset;if(n&&this._progressListeners.push(n),this._loading!==void 0)return this._loading.then(s=>this.asset);const e=Pt.Current;this._rawBinary?(this._loading=vl().parseSync(e,this._rawBinary,this.url,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(xu&&console.log("Load async",this.url),this._loading=vl().loadSync(e,this._hashedUri,this.url,null,s=>{this.raiseProgressEvent(s)}));const i=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(i),this._loading=void 0,i)return i[hB]=this,this._glbRoot&&(this._glbRoot[hB]=this),this.asset&&(this.asset[hB]=this),JS(e),i.scene!==void 0&&(this.asset=i),this.asset}async instantiate(n){return this.onInstantiate(n,!1)}async instantiateSynced(n,e=!0){return this.onInstantiate(n,!0,e)}beginListenDownload(n){this._progressListeners.indexOf(n)<0&&this._progressListeners.push(n)}endListenDownload(n){const e=this._progressListeners.indexOf(n);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(n){for(const e of this._progressListeners)e(this,n)}async onInstantiate(n,e=!1,i){const s=Pt.Current,r=new tc;if(n instanceof ge?r.parent=n:n&&(Object.assign(r,n),r.cloneAssign(n)),r.parent||(r.parent=s.scene),this.mustLoad&&await this.loadAssetAsync(),xu&&console.log("Instantiate",this.url,"parent:",n),this.asset){xu&&console.log("Add to scene",this.asset);let o=g0.currentlyInstantiating.get(this.url);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.url+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,g0.currentlyInstantiating.set(this.url,o),e){r.context=s;const a=this.asset;a.guid=this.url;const l=Qk(a,r,void 0,i);if(l)return l}else{const a=f0(this.asset,r);if(a)return a}}finally{s.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,g0.currentlyInstantiating.set(this.url,o)})}}else xu&&console.warn("Failed to load asset",this.url);return null}tryGetActualGameObjectRoot(n){if(n&&n.scene){const e=n.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let ei=g0;p(ei,"currentlyInstantiating",new Map);class dfe extends Ha{constructor(){super([ei],"AssetReferenceSerializer")}onSerialize(e,i){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,i){if(typeof e=="string")return i.context?i.gltfId?ei.getOrCreate(i.gltfId,e,i.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof ge){if(!i.context)return console.error("Missing context"),null;if(!i.gltfId)return console.error("Missing source id"),null;const s=e,r=i.context,o=s.guid??s.uuid,a=r.addressables.findAssetReference(o);if(a)return a;const l=new ei(o,void 0,s);return r.addressables.registerAssetReference(l),l}return null}}new dfe;const ufe=Promise.resolve(null),yC=class{constructor(n){p(this,"url"),p(this,"_bitmap"),p(this,"_bitmapObject"),p(this,"loader",null),this.url=n}static getOrCreate(n){let e=yC.imageReferences.get(n);return e||(e=new yC(n),yC.imageReferences.set(n,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const n=new Image;return n.src=this.url,n}createTexture(){return this.url?(this.loader||(this.loader=new lc),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):ufe}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((n,e)=>{const i=document.createElement("img");i.addEventListener("load",()=>{this._bitmap=createImageBitmap(i).then(s=>(this._bitmapObject=s,n(s),s))}),i.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),n(null)}),i.src=this.url}),this._bitmap)}};let vC=yC;p(vC,"imageReferences",new Map);class C4 extends Ha{constructor(){super([vC],"ImageReferenceSerializer")}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"){const s=Qd(i.gltfId,e);return vC.getOrCreate(s)}}}new C4;const bC=class{constructor(n){p(this,"url"),p(this,"res"),this.url=n}static getOrCreate(n){let e=bC.cache.get(n);return e||(e=new bC(n),bC.cache.set(n,e)),e}async loadRaw(){return this.res||(this.res=fetch(this.url)),this.res.then(n=>n.blob())}async loadText(){return this.res||(this.res=fetch(this.url)),this.res.then(n=>n.text())}};let AC=bC;p(AC,"cache",new Map);class M4 extends Ha{constructor(){super([AC],"FileReferenceSerializer")}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"){const s=Qd(i.gltfId,e);return AC.getOrCreate(s)}}}new M4;class pfe{constructor(e){p(this,"context"),p(this,"mixers",[]),this.context=e}onDestroy(){this.mixers.forEach(e=>e.stopAllAction()),this.mixers.length=0}registerAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.registerAnimationMixer called with null or undefined mixer");return}this.mixers.includes(e)||this.mixers.push(e)}unregisterAnimationMixer(e){if(!e){console.warn("AnimationsRegistry.unregisterAnimationMixer called with null or undefined mixer");return}const i=this.mixers.indexOf(e);i!==-1&&this.mixers.splice(i,1)}}class y0{static tryGetActionsFromMixer(e){return e._actions||null}static tryGetAnimationClipsFromObjectHierarchy(e,i){if(i||(i=new Array),e)e.animations&&i.push(...e.animations);else return i;if(e.children)for(const s of e.children)this.tryGetAnimationClipsFromObjectHierarchy(s,i);return i}static assignAnimationsFromFile(e,i){if(!e||!e.animations){console.debug("No animations found in file");return}for(let r=0;r<e.animations.length;r++){const o=e.animations[r];if(!o.tracks||o.tracks.length<=0){console.warn("Animation has no tracks");continue}for(const a in o.tracks){const l=o.tracks[a],c=Zt.parseTrackName(l.name);let h=Zt.findNode(e.scene,c.nodeName);if(!h){const u=l.__objectName??l.name.substring(0,l.name.indexOf("."));if(h=e.scene.getObjectByProperty("uuid",u),!h)continue}let d=s(h);if(!d){if(!(i!=null&&i.createAnimationComponent)){console.warn("No AnimationComponent found in parent hierarchy of object and no 'createAnimationComponent' callback was provided in options.");continue}d=i.createAnimationComponent(e.scene,o)}d.addClip&&d.addClip(o)}}function s(r){var o;if(!r)return null;const a=(o=r.userData)==null?void 0:o.components;if(a&&a.length>0){for(let l=0;l<a.length;l++)if(a[l].isAnimationComponent===!0)return r}return s(r.parent)}}}var xC=(n=>(n.Visible="application-visible",n.Hidden="application-hidden",n.MuteChanged="application-mutechanged",n))(xC||{});let wC=!1;const v0=[];function Bm(){if(wC)return;je()&&console.debug("User interaction registered: audio can now be played"),wC=!0;const n=[...v0];v0.length=0,n.forEach(e=>e())}document.addEventListener("mousedown",Bm),document.addEventListener("pointerup",Bm),document.addEventListener("click",Bm),document.addEventListener("dragstart",Bm),document.addEventListener("touchend",Bm),document.addEventListener("keydown",Bm),Et.onXRSessionStart(()=>{Bm()});const E4=class extends EventTarget{constructor(n){super(),p(this,"_mute",!1),p(this,"context"),p(this,"_isVisible",!0),this.context=n,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}static get userInteractionRegistered(){return wC}static registerWaitForInteraction(n){if(n!==null){if(wC){n();return}v0.indexOf(n)===-1&&v0.push(n)}}static unregisterWaitForInteraction(n){const e=v0.indexOf(n);e!==-1&&v0.splice(e,1)}get muted(){return this._mute}set muted(n){n!==this._mute&&(this._mute=n,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(n){switch(n.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}};let Xh=E4;p(Xh,"registerWaitForAllowAudio",E4.registerWaitForInteraction);function*T4(n,e=null){const i=e?e.time:Pt.Current.time,s=i.time;for(;i.time-s<n;)yield}function*mfe(n){for(let e=0;e<n;e++)yield}function*R4(n){let e=!0;for(n.then(()=>e=!1),n.catch(()=>e=!1);e;)yield}/*!
|
|
4995
4995
|
fflate - fast JavaScript compression/decompression
|
|
4996
4996
|
<https://101arrowz.github.io/fflate>
|
|
4997
4997
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
4998
4998
|
version 0.6.9
|
|
4999
|
-
*/var I9=function(n){return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))};try{URL.revokeObjectURL(I9(""))}catch{I9=function(n){return"data:application/javascript;charset=UTF-8,"+encodeURI(n)}}var os=Uint8Array,lo=Uint16Array,b0=Uint32Array,_C=new os([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),SC=new os([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dB=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),L9=function(n,e){for(var i=new lo(31),s=0;s<31;++s)i[s]=e+=1<<n[s-1];for(var r=new b0(i[30]),s=1;s<30;++s)for(var o=i[s];o<i[s+1];++o)r[o]=o-i[s]<<5|s;return[i,r]},P9=L9(_C,2),k9=P9[0],uB=P9[1];k9[28]=258,uB[258]=28;for(var B9=L9(SC,0),ffe=B9[0],O9=B9[1],pB=new lo(32768),cn=0;cn<32768;++cn){var wu=(cn&43690)>>>1|(cn&21845)<<1;wu=(wu&52428)>>>2|(wu&13107)<<2,wu=(wu&61680)>>>4|(wu&3855)<<4,pB[cn]=((wu&65280)>>>8|(wu&255)<<8)>>>1}for(var _c=function(n,e,i){for(var s=n.length,r=0,o=new lo(e);r<s;++r)++o[n[r]-1];var a=new lo(e);for(r=0;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;var l;if(i){l=new lo(1<<e);var c=15-e;for(r=0;r<s;++r)if(n[r])for(var h=r<<4|n[r],d=e-n[r],u=a[n[r]-1]++<<d,m=u|(1<<d)-1;u<=m;++u)l[pB[u]>>>c]=h}else for(l=new lo(s),r=0;r<s;++r)n[r]&&(l[r]=pB[a[n[r]-1]++]>>>15-n[r]);return l},_u=new os(288),cn=0;cn<144;++cn)_u[cn]=8;for(var cn=144;cn<256;++cn)_u[cn]=9;for(var cn=256;cn<280;++cn)_u[cn]=7;for(var cn=280;cn<288;++cn)_u[cn]=8;for(var cA=new os(32),cn=0;cn<32;++cn)cA[cn]=5;var gfe=_c(_u,9,0),yfe=_c(_u,9,1),vfe=_c(cA,5,0),bfe=_c(cA,5,1),mB=function(n){for(var e=n[0],i=1;i<n.length;++i)n[i]>e&&(e=n[i]);return e},Nl=function(n,e,i){var s=e/8|0;return(n[s]|n[s+1]<<8)>>(e&7)&i},fB=function(n,e){var i=e/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(e&7)},gB=function(n){return(n/8|0)+(n&7&&1)},yB=function(n,e,i){(e==null||e<0)&&(e=0),(i==null||i>n.length)&&(i=n.length);var s=new(n instanceof lo?lo:n instanceof b0?b0:os)(i-e);return s.set(n.subarray(e,i)),s},Afe=function(n,e,i){var s=n.length;if(!s||i&&!i.l&&s<5)return e||new os(0);var r=!e||i,o=!i||i.i;i||(i={}),e||(e=new os(s*3));var a=function(Ie){var We=e.length;if(Ie>We){var Ze=new os(Math.max(We*2,Ie));Ze.set(e),e=Ze}},l=i.f||0,c=i.p||0,h=i.b||0,d=i.l,u=i.d,m=i.m,f=i.n,g=s*8;do{if(!d){i.f=l=Nl(n,c,1);var v=Nl(n,c+1,3);if(c+=3,v)if(v==1)d=yfe,u=bfe,m=9,f=5;else if(v==2){var y=Nl(n,c,31)+257,b=Nl(n,c+10,15)+4,A=y+Nl(n,c+5,31)+1;c+=14;for(var x=new os(A),w=new os(19),_=0;_<b;++_)w[dB[_]]=Nl(n,c+_*3,7);c+=b*3;for(var S=mB(w),C=(1<<S)-1,R=_c(w,S,1),_=0;_<A;){var P=R[Nl(n,c,C)];c+=P&15;var T=P>>>4;if(T<16)x[_++]=T;else{var L=0,k=0;for(T==16?(k=3+Nl(n,c,3),c+=2,L=x[_-1]):T==17?(k=3+Nl(n,c,7),c+=3):T==18&&(k=11+Nl(n,c,127),c+=7);k--;)x[_++]=L}}var G=x.subarray(0,y),O=x.subarray(y);m=mB(G),f=mB(O),d=_c(G,m,1),u=_c(O,f,1)}else throw"invalid block type";else{var T=gB(c)+4,W=n[T-4]|n[T-3]<<8,D=T+W;if(D>s){if(o)throw"unexpected EOF";break}r&&a(h+W),e.set(n.subarray(T,D),h),i.b=h+=W,i.p=c=D*8;continue}if(c>g){if(o)throw"unexpected EOF";break}}r&&a(h+131072);for(var F=(1<<m)-1,U=(1<<f)-1,Y=c;;Y=c){var L=d[fB(n,c)&F],q=L>>>4;if(c+=L&15,c>g){if(o)throw"unexpected EOF";break}if(!L)throw"invalid length/literal";if(q<256)e[h++]=q;else if(q==256){Y=c,d=null;break}else{var oe=q-254;if(q>264){var _=q-257,xe=_C[_];oe=Nl(n,c,(1<<xe)-1)+k9[_],c+=xe}var Be=u[fB(n,c)&U],re=Be>>>4;if(!Be)throw"invalid distance";c+=Be&15;var O=ffe[re];if(re>3){var xe=SC[re];O+=fB(n,c)&(1<<xe)-1,c+=xe}if(c>g){if(o)throw"unexpected EOF";break}r&&a(h+131072);for(var _e=h+oe;h<_e;h+=4)e[h]=e[h-O],e[h+1]=e[h+1-O],e[h+2]=e[h+2-O],e[h+3]=e[h+3-O];h=_e}}i.l=d,i.p=Y,i.b=h,d&&(l=1,i.m=m,i.d=u,i.n=f)}while(!l);return h==e.length?e:yB(e,0,h)},Wh=function(n,e,i){i<<=e&7;var s=e/8|0;n[s]|=i,n[s+1]|=i>>>8},hA=function(n,e,i){i<<=e&7;var s=e/8|0;n[s]|=i,n[s+1]|=i>>>8,n[s+2]|=i>>>16},vB=function(n,e){for(var i=[],s=0;s<n.length;++s)n[s]&&i.push({s,f:n[s]});var r=i.length,o=i.slice();if(!r)return[AB,0];if(r==1){var a=new os(i[0].s+1);return a[i[0].s]=1,[a,1]}i.sort(function(_,S){return _.f-S.f}),i.push({s:-1,f:25001});var l=i[0],c=i[1],h=0,d=1,u=2;for(i[0]={s:-1,f:l.f+c.f,l,r:c};d!=r-1;)l=i[i[h].f<i[u].f?h++:u++],c=i[h!=d&&i[h].f<i[u].f?h++:u++],i[d++]={s:-1,f:l.f+c.f,l,r:c};for(var m=o[0].s,s=1;s<r;++s)o[s].s>m&&(m=o[s].s);var f=new lo(m+1),g=bB(i[d-1],f,0);if(g>e){var s=0,v=0,y=g-e,b=1<<y;for(o.sort(function(S,C){return f[C.s]-f[S.s]||S.f-C.f});s<r;++s){var A=o[s].s;if(f[A]>e)v+=b-(1<<g-f[A]),f[A]=e;else break}for(v>>>=y;v>0;){var x=o[s].s;f[x]<e?v-=1<<e-f[x]++-1:++s}for(;s>=0&&v;--s){var w=o[s].s;f[w]==e&&(--f[w],++v)}g=e}return[new os(f),g]},bB=function(n,e,i){return n.s==-1?Math.max(bB(n.l,e,i+1),bB(n.r,e,i+1)):e[n.s]=i},D9=function(n){for(var e=n.length;e&&!n[--e];);for(var i=new lo(++e),s=0,r=n[0],o=1,a=function(c){i[s++]=c},l=1;l<=e;++l)if(n[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(r),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(r);o=1,r=n[l]}return[i.subarray(0,s),e]},dA=function(n,e){for(var i=0,s=0;s<e.length;++s)i+=n[s]*e[s];return i},CC=function(n,e,i){var s=i.length,r=gB(e+2);n[r]=s&255,n[r+1]=s>>>8,n[r+2]=n[r]^255,n[r+3]=n[r+1]^255;for(var o=0;o<s;++o)n[r+o+4]=i[o];return(r+4+s)*8},G9=function(n,e,i,s,r,o,a,l,c,h,d){Wh(e,d++,i),++r[256];for(var u=vB(r,15),m=u[0],f=u[1],g=vB(o,15),v=g[0],y=g[1],b=D9(m),A=b[0],x=b[1],w=D9(v),_=w[0],S=w[1],C=new lo(19),R=0;R<A.length;++R)C[A[R]&31]++;for(var R=0;R<_.length;++R)C[_[R]&31]++;for(var P=vB(C,7),T=P[0],L=P[1],k=19;k>4&&!T[dB[k-1]];--k);var G=h+5<<3,O=dA(r,_u)+dA(o,cA)+a,W=dA(r,m)+dA(o,v)+a+14+3*k+dA(C,T)+(2*C[16]+3*C[17]+7*C[18]);if(G<=O&&G<=W)return CC(e,d,n.subarray(c,c+h));var D,F,U,Y;if(Wh(e,d,1+(W<O)),d+=2,W<O){D=_c(m,f,0),F=m,U=_c(v,y,0),Y=v;var q=_c(T,L,0);Wh(e,d,x-257),Wh(e,d+5,S-1),Wh(e,d+10,k-4),d+=14;for(var R=0;R<k;++R)Wh(e,d+3*R,T[dB[R]]);d+=3*k;for(var oe=[A,_],xe=0;xe<2;++xe)for(var Be=oe[xe],R=0;R<Be.length;++R){var re=Be[R]&31;Wh(e,d,q[re]),d+=T[re],re>15&&(Wh(e,d,Be[R]>>>5&127),d+=Be[R]>>>12)}}else D=gfe,F=_u,U=vfe,Y=cA;for(var R=0;R<l;++R)if(s[R]>255){var re=s[R]>>>18&31;hA(e,d,D[re+257]),d+=F[re+257],re>7&&(Wh(e,d,s[R]>>>23&31),d+=_C[re]);var _e=s[R]&31;hA(e,d,U[_e]),d+=Y[_e],_e>3&&(hA(e,d,s[R]>>>5&8191),d+=SC[_e])}else hA(e,d,D[s[R]]),d+=F[s[R]];return hA(e,d,D[256]),d+F[256]},xfe=new b0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),AB=new os(0),wfe=function(n,e,i,s,r,o){var a=n.length,l=new os(s+a+5*(1+Math.ceil(a/7e3))+r),c=l.subarray(s,l.length-r),h=0;if(!e||a<8)for(var d=0;d<=a;d+=65535){var u=d+65535;u<a?h=CC(c,h,n.subarray(d,u)):(c[d]=o,h=CC(c,h,n.subarray(d,a)))}else{for(var m=xfe[e-1],f=m>>>13,g=m&8191,v=(1<<i)-1,y=new lo(32768),b=new lo(v+1),A=Math.ceil(i/3),x=2*A,w=function(Te){return(n[Te]^n[Te+1]<<A^n[Te+2]<<x)&v},_=new b0(25e3),S=new lo(288),C=new lo(32),R=0,P=0,d=0,T=0,L=0,k=0;d<a;++d){var G=w(d),O=d&32767,W=b[G];if(y[O]=W,b[G]=O,L<=d){var D=a-d;if((R>7e3||T>24576)&&D>423){h=G9(n,c,0,_,S,C,P,T,k,d-k,h),T=R=P=0,k=d;for(var F=0;F<286;++F)S[F]=0;for(var F=0;F<30;++F)C[F]=0}var U=2,Y=0,q=g,oe=O-W&32767;if(D>2&&G==w(d-oe))for(var xe=Math.min(f,D)-1,Be=Math.min(32767,d),re=Math.min(258,D);oe<=Be&&--q&&O!=W;){if(n[d+U]==n[d+U-oe]){for(var _e=0;_e<re&&n[d+_e]==n[d+_e-oe];++_e);if(_e>U){if(U=_e,Y=oe,_e>xe)break;for(var Ie=Math.min(oe,_e-2),We=0,F=0;F<Ie;++F){var Ze=d-oe+F+32768&32767,Ge=y[Ze],rt=Ze-Ge+32768&32767;rt>We&&(We=rt,W=Ze)}}}O=W,W=y[O],oe+=O-W+32768&32767}if(Y){_[T++]=268435456|uB[U]<<18|O9[Y];var ye=uB[U]&31,Q=O9[Y]&31;P+=_C[ye]+SC[Q],++S[257+ye],++C[Q],L=d+U,++R}else _[T++]=n[d],++S[n[d]]}}h=G9(n,c,o,_,S,C,P,T,k,d-k,h),!o&&h&7&&(h=CC(c,h+1,AB))}return yB(l,0,s+gB(h)+r)},_fe=function(){for(var n=new b0(256),e=0;e<256;++e){for(var i=e,s=9;--s;)i=(i&1&&3988292384)^i>>>1;n[e]=i}return n}(),Sfe=function(){var n=-1;return{p:function(e){for(var i=n,s=0;s<e.length;++s)i=_fe[i&255^e[s]]^i>>>8;n=i},d:function(){return~n}}},Cfe=function(n,e,i,s,r){return wfe(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,i,s,!r)},N9=function(n,e){var i={};for(var s in n)i[s]=n[s];for(var s in e)i[s]=e[s];return i},ir=function(n,e,i){for(;i;++e)n[e]=i,i>>>=8},Mfe=function(n){if((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Efe(n,e){return Cfe(n,e||{},0,0)}function uA(n,e){return Afe((Mfe(n),n.subarray(2,-4)),e)}var F9=function(n,e,i,s){for(var r in n){var o=n[r],a=e+r;o instanceof os?i[a]=[o,s]:Array.isArray(o)?i[a]=[o[0],N9(s,o[1])]:F9(o,a+"/",i,s)}},z9=typeof TextEncoder<"u"&&new TextEncoder,Tfe=typeof TextDecoder<"u"&&new TextDecoder,Rfe=0;try{Tfe.decode(AB,{stream:!0}),Rfe=1}catch{}function MC(n,e){if(e){for(var i=new os(n.length),s=0;s<n.length;++s)i[s]=n.charCodeAt(s);return i}if(z9)return z9.encode(n);for(var r=n.length,o=new os(n.length+(n.length>>1)),a=0,l=function(u){o[a++]=u},s=0;s<r;++s){if(a+5>o.length){var c=new os(a+8+(r-s<<1));c.set(o),o=c}var h=n.charCodeAt(s);h<128||e?l(h):h<2048?(l(192|h>>6),l(128|h&63)):h>55295&&h<57344?(h=65536+(h&1047552)|n.charCodeAt(++s)&1023,l(240|h>>18),l(128|h>>12&63),l(128|h>>6&63),l(128|h&63)):(l(224|h>>12),l(128|h>>6&63),l(128|h&63))}return yB(o,0,a)}var xB=function(n){var e=0;if(n)for(var i in n){var s=n[i].length;if(s>65535)throw"extra field too long";e+=s+4}return e},U9=function(n,e,i,s,r,o,a,l){var c=s.length,h=i.extra,d=l&&l.length,u=xB(h);ir(n,e,a!=null?33639248:67324752),e+=4,a!=null&&(n[e++]=20,n[e++]=i.os),n[e]=20,e+=2,n[e++]=i.flag<<1|(o==null&&8),n[e++]=r&&8,n[e++]=i.compression&255,n[e++]=i.compression>>8;var m=new Date(i.mtime==null?Date.now():i.mtime),f=m.getFullYear()-1980;if(f<0||f>119)throw"date not in range 1980-2099";if(ir(n,e,f<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>>1),e+=4,o!=null&&(ir(n,e,i.crc),ir(n,e+4,o),ir(n,e+8,i.size)),ir(n,e+12,c),ir(n,e+14,u),e+=16,a!=null&&(ir(n,e,d),ir(n,e+6,i.attrs),ir(n,e+10,a),e+=14),n.set(s,e),e+=c,u)for(var g in h){var v=h[g],y=v.length;ir(n,e,+g),ir(n,e+2,y),n.set(v,e+4),e+=4+y}return d&&(n.set(l,e),e+=d),e},Ife=function(n,e,i,s,r){ir(n,e,101010256),ir(n,e+8,i),ir(n,e+10,i),ir(n,e+12,s),ir(n,e+16,r)};function Lfe(n,e){e||(e={});var i={},s=[];F9(n,"",i,e);var r=0,o=0;for(var a in i){var l=i[a],c=l[0],h=l[1],d=h.level==0?0:8,u=MC(a),m=u.length,f=h.comment,g=f&&MC(f),v=g&&g.length,y=xB(h.extra);if(m>65535)throw"filename too long";var b=d?Efe(c,h):c,A=b.length,x=Sfe();x.p(c),s.push(N9(h,{size:c.length,crc:x.d(),c:b,f:u,m:g,u:m!=a.length||g&&f.length!=v,o:r,compression:d})),r+=30+m+y+A,o+=76+2*(m+y)+(v||0)+A}for(var w=new os(o+22),_=r,S=o-r,C=0;C<s.length;++C){var u=s[C];U9(w,u.o,u,u.f,u.u,u.c.length);var R=30+u.f.length+xB(u.extra);w.set(u.c,u.o+R),U9(w,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+R+(u.m?u.m.length:0)}return Ife(w,r,s.length,S,_),w}class pA extends $2{constructor(e){super(e),this.type=ms}parse(e){const i=Math.pow(2.7182818,2.2);function s(I,B){let X=0;for(let V=0;V<65536;++V)(V==0||I[V>>3]&1<<(V&7))&&(B[X++]=V);const ee=X-1;for(;X<65536;)B[X++]=0;return ee}function r(I){for(let B=0;B<16384;B++)I[B]={},I[B].len=0,I[B].lit=0,I[B].p=null}const o={l:0,c:0,lc:0};function a(I,B,X,ee,V){for(;X<I;)B=B<<8|Q(ee,V),X+=8;X-=I,o.l=B>>X&(1<<I)-1,o.c=B,o.lc=X}const l=new Array(59);function c(I){for(let X=0;X<=58;++X)l[X]=0;for(let X=0;X<65537;++X)l[I[X]]+=1;let B=0;for(let X=58;X>0;--X){const ee=B+l[X]>>1;l[X]=B,B=ee}for(let X=0;X<65537;++X){const ee=I[X];ee>0&&(I[X]=ee|l[ee]++<<6)}}function h(I,B,X,ee,V,J){const j=B;let ae=0,ce=0;for(;ee<=V;ee++){if(j.value-B.value>X)return!1;a(6,ae,ce,I,j);const we=o.l;if(ae=o.c,ce=o.lc,J[ee]=we,we==63){if(j.value-B.value>X)throw new Error("Something wrong with hufUnpackEncTable");a(8,ae,ce,I,j);let Re=o.l+6;if(ae=o.c,ce=o.lc,ee+Re>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)J[ee++]=0;ee--}else if(we>=59){let Re=we-59+2;if(ee+Re>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)J[ee++]=0;ee--}}c(J)}function d(I){return I&63}function u(I){return I>>6}function m(I,B,X,ee){for(;B<=X;B++){const V=u(I[B]),J=d(I[B]);if(V>>J)throw new Error("Invalid table entry");if(J>14){const j=ee[V>>J-14];if(j.len)throw new Error("Invalid table entry");if(j.lit++,j.p){const ae=j.p;j.p=new Array(j.lit);for(let ce=0;ce<j.lit-1;++ce)j.p[ce]=ae[ce]}else j.p=new Array(1);j.p[j.lit-1]=B}else if(J){let j=0;for(let ae=1<<14-J;ae>0;ae--){const ce=ee[(V<<14-J)+j];if(ce.len||ce.p)throw new Error("Invalid table entry");ce.len=J,ce.lit=B,j++}}}return!0}const f={c:0,lc:0};function g(I,B,X,ee){I=I<<8|Q(X,ee),B+=8,f.c=I,f.lc=B}const v={c:0,lc:0};function y(I,B,X,ee,V,J,j,ae,ce){if(I==B){ee<8&&(g(X,ee,V,J),X=f.c,ee=f.lc),ee-=8;let we=X>>ee;if(we=new Uint8Array([we])[0],ae.value+we>ce)return!1;const Re=j[ae.value-1];for(;we-- >0;)j[ae.value++]=Re}else if(ae.value<ce)j[ae.value++]=I;else return!1;v.c=X,v.lc=ee}function b(I){return I&65535}function A(I){const B=b(I);return B>32767?B-65536:B}const x={a:0,b:0};function w(I,B){const X=A(I),ee=A(B),V=X+(ee&1)+(ee>>1),J=V,j=V-ee;x.a=J,x.b=j}function _(I,B){const X=b(I),ee=b(B),V=X-(ee>>1)&65535,J=ee+V-32768&65535;x.a=J,x.b=V}function S(I,B,X,ee,V,J,j){const ae=j<16384,ce=X>V?V:X;let we=1,Re,Je;for(;we<=ce;)we<<=1;for(we>>=1,Re=we,we>>=1;we>=1;){Je=0;const Ye=Je+J*(V-Re),tt=J*we,bt=J*Re,ot=ee*we,St=ee*Re;let ti,Ui,hn,Es;for(;Je<=Ye;Je+=bt){let Ni=Je;const ui=Je+ee*(X-Re);for(;Ni<=ui;Ni+=St){const zn=Ni+ot,xo=Ni+tt,$n=xo+ot;ae?(w(I[Ni+B],I[xo+B]),ti=x.a,hn=x.b,w(I[zn+B],I[$n+B]),Ui=x.a,Es=x.b,w(ti,Ui),I[Ni+B]=x.a,I[zn+B]=x.b,w(hn,Es),I[xo+B]=x.a,I[$n+B]=x.b):(_(I[Ni+B],I[xo+B]),ti=x.a,hn=x.b,_(I[zn+B],I[$n+B]),Ui=x.a,Es=x.b,_(ti,Ui),I[Ni+B]=x.a,I[zn+B]=x.b,_(hn,Es),I[xo+B]=x.a,I[$n+B]=x.b)}if(X&we){const zn=Ni+tt;ae?w(I[Ni+B],I[zn+B]):_(I[Ni+B],I[zn+B]),ti=x.a,I[zn+B]=x.b,I[Ni+B]=ti}}if(V&we){let Ni=Je;const ui=Je+ee*(X-Re);for(;Ni<=ui;Ni+=St){const zn=Ni+ot;ae?w(I[Ni+B],I[zn+B]):_(I[Ni+B],I[zn+B]),ti=x.a,I[zn+B]=x.b,I[Ni+B]=ti}}Re=we,we>>=1}return Je}function C(I,B,X,ee,V,J,j,ae,ce){let we=0,Re=0;const Je=j,Ye=Math.trunc(ee.value+(V+7)/8);for(;ee.value<Ye;)for(g(we,Re,X,ee),we=f.c,Re=f.lc;Re>=14;){const bt=we>>Re-14&16383,ot=B[bt];if(ot.len)Re-=ot.len,y(ot.lit,J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;else{if(!ot.p)throw new Error("hufDecode issues");let St;for(St=0;St<ot.lit;St++){const ti=d(I[ot.p[St]]);for(;Re<ti&&ee.value<Ye;)g(we,Re,X,ee),we=f.c,Re=f.lc;if(Re>=ti&&u(I[ot.p[St]])==(we>>Re-ti&(1<<ti)-1)){Re-=ti,y(ot.p[St],J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;break}}if(St==ot.lit)throw new Error("hufDecode issues")}}const tt=8-V&7;for(we>>=tt,Re-=tt;Re>0;){const bt=B[we<<14-Re&16383];if(bt.len)Re-=bt.len,y(bt.lit,J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;else throw new Error("hufDecode issues")}return!0}function R(I,B,X,ee,V,J){const j={value:0},ae=X.value,ce=ye(B,X),we=ye(B,X);X.value+=4;const Re=ye(B,X);if(X.value+=4,ce<0||ce>=65537||we<0||we>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const Je=new Array(65537),Ye=new Array(16384);r(Ye);const tt=ee-(X.value-ae);if(h(I,X,tt,ce,we,Je),Re>8*(ee-(X.value-ae)))throw new Error("Something wrong with hufUncompress");m(Je,ce,we,Ye),C(Je,Ye,I,X,Re,we,J,V,j)}function P(I,B,X){for(let ee=0;ee<X;++ee)B[ee]=I[B[ee]]}function T(I){for(let B=1;B<I.length;B++){const X=I[B-1]+I[B]-128;I[B]=X}}function L(I,B){let X=0,ee=Math.floor((I.length+1)/2),V=0;const J=I.length-1;for(;!(V>J||(B[V++]=I[X++],V>J));)B[V++]=I[ee++]}function k(I){let B=I.byteLength;const X=new Array;let ee=0;const V=new DataView(I);for(;B>0;){const J=V.getInt8(ee++);if(J<0){const j=-J;B-=j+1;for(let ae=0;ae<j;ae++)X.push(V.getUint8(ee++))}else{const j=J;B-=2;const ae=V.getUint8(ee++);for(let ce=0;ce<j+1;ce++)X.push(ae)}}return X}function G(I,B,X,ee,V,J){let j=new DataView(J.buffer);const ae=X[I.idx[0]].width,ce=X[I.idx[0]].height,we=3,Re=Math.floor(ae/8),Je=Math.ceil(ae/8),Ye=Math.ceil(ce/8),tt=ae-(Je-1)*8,bt=ce-(Ye-1)*8,ot={value:0},St=new Array(we),ti=new Array(we),Ui=new Array(we),hn=new Array(we),Es=new Array(we);for(let ui=0;ui<we;++ui)Es[ui]=B[I.idx[ui]],St[ui]=ui<1?0:St[ui-1]+Je*Ye,ti[ui]=new Float32Array(64),Ui[ui]=new Uint16Array(64),hn[ui]=new Uint16Array(Je*64);for(let ui=0;ui<Ye;++ui){let zn=8;ui==Ye-1&&(zn=bt);let xo=8;for(let z=0;z<Je;++z){z==Je-1&&(xo=tt);for(let ne=0;ne<we;++ne)Ui[ne].fill(0),Ui[ne][0]=V[St[ne]++],O(ot,ee,Ui[ne]),W(Ui[ne],ti[ne]),D(ti[ne]);F(ti);for(let ne=0;ne<we;++ne)U(ti[ne],hn[ne],z*64)}let $n=0;for(let z=0;z<we;++z){const ne=X[I.idx[z]].type;for(let fe=8*ui;fe<8*ui+zn;++fe){$n=Es[z][fe];for(let ve=0;ve<Re;++ve){const le=ve*64+(fe&7)*8;j.setUint16($n+0*2*ne,hn[z][le+0],!0),j.setUint16($n+1*2*ne,hn[z][le+1],!0),j.setUint16($n+2*2*ne,hn[z][le+2],!0),j.setUint16($n+3*2*ne,hn[z][le+3],!0),j.setUint16($n+4*2*ne,hn[z][le+4],!0),j.setUint16($n+5*2*ne,hn[z][le+5],!0),j.setUint16($n+6*2*ne,hn[z][le+6],!0),j.setUint16($n+7*2*ne,hn[z][le+7],!0),$n+=8*2*ne}}if(Re!=Je)for(let fe=8*ui;fe<8*ui+zn;++fe){const ve=Es[z][fe]+8*Re*2*ne,le=Re*64+(fe&7)*8;for(let it=0;it<xo;++it)j.setUint16(ve+it*2*ne,hn[z][le+it],!0)}}}const Ni=new Uint16Array(ae);j=new DataView(J.buffer);for(let ui=0;ui<we;++ui){X[I.idx[ui]].decoded=!0;const zn=X[I.idx[ui]].type;if(X[ui].type==2)for(let xo=0;xo<ce;++xo){const $n=Es[ui][xo];for(let z=0;z<ae;++z)Ni[z]=j.getUint16($n+z*2*zn,!0);for(let z=0;z<ae;++z)j.setFloat32($n+z*2*zn,be(Ni[z]),!0)}}}function O(I,B,X){let ee,V=1;for(;V<64;)ee=B[I.value],ee==65280?V=64:ee>>8==255?V+=ee&255:(X[V]=ee,V++),I.value++}function W(I,B){B[0]=be(I[0]),B[1]=be(I[1]),B[2]=be(I[5]),B[3]=be(I[6]),B[4]=be(I[14]),B[5]=be(I[15]),B[6]=be(I[27]),B[7]=be(I[28]),B[8]=be(I[2]),B[9]=be(I[4]),B[10]=be(I[7]),B[11]=be(I[13]),B[12]=be(I[16]),B[13]=be(I[26]),B[14]=be(I[29]),B[15]=be(I[42]),B[16]=be(I[3]),B[17]=be(I[8]),B[18]=be(I[12]),B[19]=be(I[17]),B[20]=be(I[25]),B[21]=be(I[30]),B[22]=be(I[41]),B[23]=be(I[43]),B[24]=be(I[9]),B[25]=be(I[11]),B[26]=be(I[18]),B[27]=be(I[24]),B[28]=be(I[31]),B[29]=be(I[40]),B[30]=be(I[44]),B[31]=be(I[53]),B[32]=be(I[10]),B[33]=be(I[19]),B[34]=be(I[23]),B[35]=be(I[32]),B[36]=be(I[39]),B[37]=be(I[45]),B[38]=be(I[52]),B[39]=be(I[54]),B[40]=be(I[20]),B[41]=be(I[22]),B[42]=be(I[33]),B[43]=be(I[38]),B[44]=be(I[46]),B[45]=be(I[51]),B[46]=be(I[55]),B[47]=be(I[60]),B[48]=be(I[21]),B[49]=be(I[34]),B[50]=be(I[37]),B[51]=be(I[47]),B[52]=be(I[50]),B[53]=be(I[56]),B[54]=be(I[59]),B[55]=be(I[61]),B[56]=be(I[35]),B[57]=be(I[36]),B[58]=be(I[48]),B[59]=be(I[49]),B[60]=be(I[57]),B[61]=be(I[58]),B[62]=be(I[62]),B[63]=be(I[63])}function D(I){const B=.5*Math.cos(.7853975),X=.5*Math.cos(3.14159/16),ee=.5*Math.cos(3.14159/8),V=.5*Math.cos(3*3.14159/16),J=.5*Math.cos(5*3.14159/16),j=.5*Math.cos(3*3.14159/8),ae=.5*Math.cos(7*3.14159/16),ce=new Array(4),we=new Array(4),Re=new Array(4),Je=new Array(4);for(let Ye=0;Ye<8;++Ye){const tt=Ye*8;ce[0]=ee*I[tt+2],ce[1]=j*I[tt+2],ce[2]=ee*I[tt+6],ce[3]=j*I[tt+6],we[0]=X*I[tt+1]+V*I[tt+3]+J*I[tt+5]+ae*I[tt+7],we[1]=V*I[tt+1]-ae*I[tt+3]-X*I[tt+5]-J*I[tt+7],we[2]=J*I[tt+1]-X*I[tt+3]+ae*I[tt+5]+V*I[tt+7],we[3]=ae*I[tt+1]-J*I[tt+3]+V*I[tt+5]-X*I[tt+7],Re[0]=B*(I[tt+0]+I[tt+4]),Re[3]=B*(I[tt+0]-I[tt+4]),Re[1]=ce[0]+ce[3],Re[2]=ce[1]-ce[2],Je[0]=Re[0]+Re[1],Je[1]=Re[3]+Re[2],Je[2]=Re[3]-Re[2],Je[3]=Re[0]-Re[1],I[tt+0]=Je[0]+we[0],I[tt+1]=Je[1]+we[1],I[tt+2]=Je[2]+we[2],I[tt+3]=Je[3]+we[3],I[tt+4]=Je[3]-we[3],I[tt+5]=Je[2]-we[2],I[tt+6]=Je[1]-we[1],I[tt+7]=Je[0]-we[0]}for(let Ye=0;Ye<8;++Ye)ce[0]=ee*I[16+Ye],ce[1]=j*I[16+Ye],ce[2]=ee*I[48+Ye],ce[3]=j*I[48+Ye],we[0]=X*I[8+Ye]+V*I[24+Ye]+J*I[40+Ye]+ae*I[56+Ye],we[1]=V*I[8+Ye]-ae*I[24+Ye]-X*I[40+Ye]-J*I[56+Ye],we[2]=J*I[8+Ye]-X*I[24+Ye]+ae*I[40+Ye]+V*I[56+Ye],we[3]=ae*I[8+Ye]-J*I[24+Ye]+V*I[40+Ye]-X*I[56+Ye],Re[0]=B*(I[Ye]+I[32+Ye]),Re[3]=B*(I[Ye]-I[32+Ye]),Re[1]=ce[0]+ce[3],Re[2]=ce[1]-ce[2],Je[0]=Re[0]+Re[1],Je[1]=Re[3]+Re[2],Je[2]=Re[3]-Re[2],Je[3]=Re[0]-Re[1],I[0+Ye]=Je[0]+we[0],I[8+Ye]=Je[1]+we[1],I[16+Ye]=Je[2]+we[2],I[24+Ye]=Je[3]+we[3],I[32+Ye]=Je[3]-we[3],I[40+Ye]=Je[2]-we[2],I[48+Ye]=Je[1]-we[1],I[56+Ye]=Je[0]-we[0]}function F(I){for(let B=0;B<64;++B){const X=I[0][B],ee=I[1][B],V=I[2][B];I[0][B]=X+1.5747*V,I[1][B]=X-.1873*ee-.4682*V,I[2][B]=X+1.8556*ee}}function U(I,B,X){for(let ee=0;ee<64;++ee)B[X+ee]=Bp.toHalfFloat(Y(I[ee]))}function Y(I){return I<=1?Math.sign(I)*Math.pow(Math.abs(I),2.2):Math.sign(I)*Math.pow(i,Math.abs(I)-1)}function q(I){return new DataView(I.array.buffer,I.offset.value,I.size)}function oe(I){const B=I.viewer.buffer.slice(I.offset.value,I.offset.value+I.size),X=new Uint8Array(k(B)),ee=new Uint8Array(X.length);return T(X),L(X,ee),new DataView(ee.buffer)}function xe(I){const B=I.array.slice(I.offset.value,I.offset.value+I.size),X=uA(B),ee=new Uint8Array(X.length);return T(X),L(X,ee),new DataView(ee.buffer)}function Be(I){const B=I.viewer,X={value:I.offset.value},ee=new Uint16Array(I.width*I.scanlineBlockSize*(I.channels*I.type)),V=new Uint8Array(8192);let J=0;const j=new Array(I.channels);for(let bt=0;bt<I.channels;bt++)j[bt]={},j[bt].start=J,j[bt].end=j[bt].start,j[bt].nx=I.width,j[bt].ny=I.lines,j[bt].size=I.type,J+=j[bt].nx*j[bt].ny*j[bt].size;const ae=nt(B,X),ce=nt(B,X);if(ce>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(ae<=ce)for(let bt=0;bt<ce-ae+1;bt++)V[bt+ae]=ze(B,X);const we=new Uint16Array(65536),Re=s(V,we),Je=ye(B,X);R(I.array,B,X,Je,ee,J);for(let bt=0;bt<I.channels;++bt){const ot=j[bt];for(let St=0;St<j[bt].size;++St)S(ee,ot.start+St,ot.nx,ot.size,ot.ny,ot.nx*ot.size,Re)}P(we,ee,J);let Ye=0;const tt=new Uint8Array(ee.buffer.byteLength);for(let bt=0;bt<I.lines;bt++)for(let ot=0;ot<I.channels;ot++){const St=j[ot],ti=St.nx*St.size,Ui=new Uint8Array(ee.buffer,St.end*2,ti*2);tt.set(Ui,Ye),Ye+=ti*2,St.end+=ti}return new DataView(tt.buffer)}function re(I){const B=I.array.slice(I.offset.value,I.offset.value+I.size),X=uA(B),ee=I.lines*I.channels*I.width,V=I.type==1?new Uint16Array(ee):new Uint32Array(ee);let J=0,j=0;const ae=new Array(4);for(let ce=0;ce<I.lines;ce++)for(let we=0;we<I.channels;we++){let Re=0;switch(I.type){case 1:ae[0]=J,ae[1]=ae[0]+I.width,J=ae[1]+I.width;for(let Je=0;Je<I.width;++Je){const Ye=X[ae[0]++]<<8|X[ae[1]++];Re+=Ye,V[j]=Re,j++}break;case 2:ae[0]=J,ae[1]=ae[0]+I.width,ae[2]=ae[1]+I.width,J=ae[2]+I.width;for(let Je=0;Je<I.width;++Je){const Ye=X[ae[0]++]<<24|X[ae[1]++]<<16|X[ae[2]++]<<8;Re+=Ye,V[j]=Re,j++}break}}return new DataView(V.buffer)}function _e(I){const B=I.viewer,X={value:I.offset.value},ee=new Uint8Array(I.width*I.lines*(I.channels*I.type*2)),V={version:Te(B,X),unknownUncompressedSize:Te(B,X),unknownCompressedSize:Te(B,X),acCompressedSize:Te(B,X),dcCompressedSize:Te(B,X),rleCompressedSize:Te(B,X),rleUncompressedSize:Te(B,X),rleRawSize:Te(B,X),totalAcUncompressedCount:Te(B,X),totalDcUncompressedCount:Te(B,X),acCompression:Te(B,X)};if(V.version<2)throw new Error("EXRLoader.parse: "+qt.compression+" version "+V.version+" is unsupported");const J=new Array;let j=nt(B,X)-2;for(;j>0;){const ot=Ie(B.buffer,X),St=ze(B,X),ti=St>>2&3,Ui=(St>>4)-1,hn=new Int8Array([Ui])[0],Es=ze(B,X);J.push({name:ot,index:hn,type:Es,compression:ti}),j-=ot.length+3}const ae=qt.channels,ce=new Array(I.channels);for(let ot=0;ot<I.channels;++ot){const St=ce[ot]={},ti=ae[ot];St.name=ti.name,St.compression=0,St.decoded=!1,St.type=ti.pixelType,St.pLinear=ti.pLinear,St.width=I.width,St.height=I.lines}const we={idx:new Array(3)};for(let ot=0;ot<I.channels;++ot){const St=ce[ot];for(let ti=0;ti<J.length;++ti){const Ui=J[ti];St.name==Ui.name&&(St.compression=Ui.compression,Ui.index>=0&&(we.idx[Ui.index]=ot),St.offset=ot)}}let Re,Je,Ye;if(V.acCompressedSize>0)switch(V.acCompression){case 0:Re=new Uint16Array(V.totalAcUncompressedCount),R(I.array,B,X,V.acCompressedSize,Re,V.totalAcUncompressedCount);break;case 1:const ot=I.array.slice(X.value,X.value+V.totalAcUncompressedCount),St=uA(ot);Re=new Uint16Array(St.buffer),X.value+=V.totalAcUncompressedCount;break}if(V.dcCompressedSize>0){const ot={array:I.array,offset:X,size:V.dcCompressedSize};Je=new Uint16Array(xe(ot).buffer),X.value+=V.dcCompressedSize}if(V.rleRawSize>0){const ot=I.array.slice(X.value,X.value+V.rleCompressedSize),St=uA(ot);Ye=k(St.buffer),X.value+=V.rleCompressedSize}let tt=0;const bt=new Array(ce.length);for(let ot=0;ot<bt.length;++ot)bt[ot]=new Array;for(let ot=0;ot<I.lines;++ot)for(let St=0;St<ce.length;++St)bt[St].push(tt),tt+=ce[St].width*I.type*2;G(we,bt,ce,Re,Je,ee);for(let ot=0;ot<ce.length;++ot){const St=ce[ot];if(!St.decoded)switch(St.compression){case 2:let ti=0,Ui=0;for(let hn=0;hn<I.lines;++hn){let Es=bt[ot][ti];for(let Ni=0;Ni<St.width;++Ni){for(let ui=0;ui<2*St.type;++ui)ee[Es++]=Ye[Ui+ui*St.width*St.height];Ui++}ti++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(ee.buffer)}function Ie(I,B){const X=new Uint8Array(I);let ee=0;for(;X[B.value+ee]!=0;)ee+=1;const V=new TextDecoder().decode(X.slice(B.value,B.value+ee));return B.value=B.value+ee+1,V}function We(I,B,X){const ee=new TextDecoder().decode(new Uint8Array(I).slice(B.value,B.value+X));return B.value=B.value+X,ee}function Ze(I,B){const X=rt(I,B),ee=ye(I,B);return[X,ee]}function Ge(I,B){const X=ye(I,B),ee=ye(I,B);return[X,ee]}function rt(I,B){const X=I.getInt32(B.value,!0);return B.value=B.value+4,X}function ye(I,B){const X=I.getUint32(B.value,!0);return B.value=B.value+4,X}function Q(I,B){const X=I[B.value];return B.value=B.value+1,X}function ze(I,B){const X=I.getUint8(B.value);return B.value=B.value+1,X}const Te=function(I,B){let X;return"getBigInt64"in DataView.prototype?X=Number(I.getBigInt64(B.value,!0)):X=I.getUint32(B.value+4,!0)+Number(I.getUint32(B.value,!0)<<32),B.value+=8,X};function Ee(I,B){const X=I.getFloat32(B.value,!0);return B.value+=4,X}function He(I,B){return Bp.toHalfFloat(Ee(I,B))}function be(I){const B=(I&31744)>>10,X=I&1023;return(I>>15?-1:1)*(B?B===31?X?NaN:1/0:Math.pow(2,B-15)*(1+X/1024):6103515625e-14*(X/1024))}function nt(I,B){const X=I.getUint16(B.value,!0);return B.value+=2,X}function ct(I,B){return be(nt(I,B))}function It(I,B,X,ee){const V=X.value,J=[];for(;X.value<V+ee-1;){const j=Ie(B,X),ae=rt(I,X),ce=ze(I,X);X.value+=3;const we=rt(I,X),Re=rt(I,X);J.push({name:j,pixelType:ae,pLinear:ce,xSampling:we,ySampling:Re})}return X.value+=1,J}function H(I,B){const X=Ee(I,B),ee=Ee(I,B),V=Ee(I,B),J=Ee(I,B),j=Ee(I,B),ae=Ee(I,B),ce=Ee(I,B),we=Ee(I,B);return{redX:X,redY:ee,greenX:V,greenY:J,blueX:j,blueY:ae,whiteX:ce,whiteY:we}}function N(I,B){const X=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],ee=ze(I,B);return X[ee]}function de(I,B){const X=ye(I,B),ee=ye(I,B),V=ye(I,B),J=ye(I,B);return{xMin:X,yMin:ee,xMax:V,yMax:J}}function Me(I,B){const X=["INCREASING_Y"],ee=ze(I,B);return X[ee]}function Oe(I,B){const X=Ee(I,B),ee=Ee(I,B);return[X,ee]}function Le(I,B){const X=Ee(I,B),ee=Ee(I,B),V=Ee(I,B);return[X,ee,V]}function xt(I,B,X,ee,V){if(ee==="string"||ee==="stringvector"||ee==="iccProfile")return We(B,X,V);if(ee==="chlist")return It(I,B,X,V);if(ee==="chromaticities")return H(I,X);if(ee==="compression")return N(I,X);if(ee==="box2i")return de(I,X);if(ee==="lineOrder")return Me(I,X);if(ee==="float")return Ee(I,X);if(ee==="v2f")return Oe(I,X);if(ee==="v3f")return Le(I,X);if(ee==="int")return rt(I,X);if(ee==="rational")return Ze(I,X);if(ee==="timecode")return Ge(I,X);if(ee==="preview")return X.value+=V,"skipped";X.value+=V}function dt(I,B,X){const ee={};if(I.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");ee.version=I.getUint8(4);const V=I.getUint8(5);ee.spec={singleTile:!!(V&2),longName:!!(V&4),deepFormat:!!(V&8),multiPart:!!(V&16)},X.value=8;let J=!0;for(;J;){const j=Ie(B,X);if(j==0)J=!1;else{const ae=Ie(B,X),ce=ye(I,X),we=xt(I,B,X,ae,ce);we===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${ae}'.`):ee[j]=we}}if(V&-5)throw console.error("THREE.EXRHeader:",ee),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return ee}function Ue(I,B,X,ee,V){const J={size:0,viewer:B,array:X,offset:ee,width:I.dataWindow.xMax-I.dataWindow.xMin+1,height:I.dataWindow.yMax-I.dataWindow.yMin+1,channels:I.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:I.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:ki};switch(I.compression){case"NO_COMPRESSION":J.lines=1,J.uncompress=q;break;case"RLE_COMPRESSION":J.lines=1,J.uncompress=oe;break;case"ZIPS_COMPRESSION":J.lines=1,J.uncompress=xe;break;case"ZIP_COMPRESSION":J.lines=16,J.uncompress=xe;break;case"PIZ_COMPRESSION":J.lines=32,J.uncompress=Be;break;case"PXR24_COMPRESSION":J.lines=16,J.uncompress=re;break;case"DWAA_COMPRESSION":J.lines=32,J.uncompress=_e;break;case"DWAB_COMPRESSION":J.lines=256,J.uncompress=_e;break;default:throw new Error("EXRLoader.parse: "+I.compression+" is unsupported")}if(J.scanlineBlockSize=J.lines,J.type==1)switch(V){case Qi:J.getter=ct,J.inputSize=2;break;case ms:J.getter=nt,J.inputSize=2;break}else if(J.type==2)switch(V){case Qi:J.getter=Ee,J.inputSize=4;break;case ms:J.getter=He,J.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+J.type+" for "+I.compression+".");J.blockCount=(I.dataWindow.yMax+1)/J.scanlineBlockSize;for(let ae=0;ae<J.blockCount;ae++)Te(B,ee);J.outputChannels=J.channels==3?4:J.channels;const j=J.width*J.height*J.outputChannels;switch(V){case Qi:J.byteArray=new Float32Array(j),J.channels<J.outputChannels&&J.byteArray.fill(1,0,j);break;case ms:J.byteArray=new Uint16Array(j),J.channels<J.outputChannels&&J.byteArray.fill(15360,0,j);break;default:console.error("THREE.EXRLoader: unsupported type: ",V);break}return J.bytesPerLine=J.width*J.inputSize*J.channels,J.outputChannels==4?(J.format=wi,J.colorSpace=ki):(J.format=Tp,J.colorSpace=So),J}const Xe=new DataView(e),Ct=new Uint8Array(e),Ne={value:0},qt=dt(Xe,e,Ne),De=Ue(qt,Xe,Ct,Ne,this.type),_t={value:0},ut={R:0,G:1,B:2,A:3,Y:0};for(let I=0;I<De.height/De.scanlineBlockSize;I++){const B=ye(Xe,Ne);De.size=ye(Xe,Ne),De.lines=B+De.scanlineBlockSize>De.height?De.height-B:De.scanlineBlockSize;const X=De.size<De.lines*De.bytesPerLine?De.uncompress(De):q(De);Ne.value+=De.size;for(let ee=0;ee<De.scanlineBlockSize;ee++){const V=ee+I*De.scanlineBlockSize;if(V>=De.height)break;for(let J=0;J<De.channels;J++){const j=ut[qt.channels[J].name];for(let ae=0;ae<De.width;ae++){_t.value=(ee*(De.channels*De.width)+J*De.width+ae)*De.inputSize;const ce=(De.height-1-V)*(De.width*De.outputChannels)+ae*De.outputChannels+j;De.byteArray[ce]=De.getter(X,_t)}}}}return{header:qt,width:De.width,height:De.height,data:De.byteArray,format:De.format,colorSpace:De.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,i,s,r){function o(a,l){a.colorSpace=l.colorSpace,a.minFilter=Dt,a.magFilter=Dt,a.generateMipmaps=!1,a.flipY=!1,i&&i(a,l)}return super.load(e,o,s,r)}}const Pfe=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:pA},Symbol.toStringTag,{value:"Module"}));class EC extends $2{constructor(e){super(e),this.type=ms}parse(e){const i=function(b,A){switch(b){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(A||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(A||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(A||""))}},s=`
|
|
4999
|
+
*/var I4=function(n){return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))};try{URL.revokeObjectURL(I4(""))}catch{I4=function(n){return"data:application/javascript;charset=UTF-8,"+encodeURI(n)}}var os=Uint8Array,lo=Uint16Array,b0=Uint32Array,_C=new os([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),SC=new os([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dB=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),L4=function(n,e){for(var i=new lo(31),s=0;s<31;++s)i[s]=e+=1<<n[s-1];for(var r=new b0(i[30]),s=1;s<30;++s)for(var o=i[s];o<i[s+1];++o)r[o]=o-i[s]<<5|s;return[i,r]},P4=L4(_C,2),k4=P4[0],uB=P4[1];k4[28]=258,uB[258]=28;for(var B4=L4(SC,0),ffe=B4[0],O4=B4[1],pB=new lo(32768),cn=0;cn<32768;++cn){var wu=(cn&43690)>>>1|(cn&21845)<<1;wu=(wu&52428)>>>2|(wu&13107)<<2,wu=(wu&61680)>>>4|(wu&3855)<<4,pB[cn]=((wu&65280)>>>8|(wu&255)<<8)>>>1}for(var _c=function(n,e,i){for(var s=n.length,r=0,o=new lo(e);r<s;++r)++o[n[r]-1];var a=new lo(e);for(r=0;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;var l;if(i){l=new lo(1<<e);var c=15-e;for(r=0;r<s;++r)if(n[r])for(var h=r<<4|n[r],d=e-n[r],u=a[n[r]-1]++<<d,m=u|(1<<d)-1;u<=m;++u)l[pB[u]>>>c]=h}else for(l=new lo(s),r=0;r<s;++r)n[r]&&(l[r]=pB[a[n[r]-1]++]>>>15-n[r]);return l},_u=new os(288),cn=0;cn<144;++cn)_u[cn]=8;for(var cn=144;cn<256;++cn)_u[cn]=9;for(var cn=256;cn<280;++cn)_u[cn]=7;for(var cn=280;cn<288;++cn)_u[cn]=8;for(var cA=new os(32),cn=0;cn<32;++cn)cA[cn]=5;var gfe=_c(_u,9,0),yfe=_c(_u,9,1),vfe=_c(cA,5,0),bfe=_c(cA,5,1),mB=function(n){for(var e=n[0],i=1;i<n.length;++i)n[i]>e&&(e=n[i]);return e},Nl=function(n,e,i){var s=e/8|0;return(n[s]|n[s+1]<<8)>>(e&7)&i},fB=function(n,e){var i=e/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(e&7)},gB=function(n){return(n/8|0)+(n&7&&1)},yB=function(n,e,i){(e==null||e<0)&&(e=0),(i==null||i>n.length)&&(i=n.length);var s=new(n instanceof lo?lo:n instanceof b0?b0:os)(i-e);return s.set(n.subarray(e,i)),s},Afe=function(n,e,i){var s=n.length;if(!s||i&&!i.l&&s<5)return e||new os(0);var r=!e||i,o=!i||i.i;i||(i={}),e||(e=new os(s*3));var a=function(Ie){var We=e.length;if(Ie>We){var Ze=new os(Math.max(We*2,Ie));Ze.set(e),e=Ze}},l=i.f||0,c=i.p||0,h=i.b||0,d=i.l,u=i.d,m=i.m,f=i.n,g=s*8;do{if(!d){i.f=l=Nl(n,c,1);var v=Nl(n,c+1,3);if(c+=3,v)if(v==1)d=yfe,u=bfe,m=9,f=5;else if(v==2){var y=Nl(n,c,31)+257,b=Nl(n,c+10,15)+4,A=y+Nl(n,c+5,31)+1;c+=14;for(var x=new os(A),w=new os(19),_=0;_<b;++_)w[dB[_]]=Nl(n,c+_*3,7);c+=b*3;for(var S=mB(w),C=(1<<S)-1,R=_c(w,S,1),_=0;_<A;){var P=R[Nl(n,c,C)];c+=P&15;var T=P>>>4;if(T<16)x[_++]=T;else{var L=0,k=0;for(T==16?(k=3+Nl(n,c,3),c+=2,L=x[_-1]):T==17?(k=3+Nl(n,c,7),c+=3):T==18&&(k=11+Nl(n,c,127),c+=7);k--;)x[_++]=L}}var G=x.subarray(0,y),O=x.subarray(y);m=mB(G),f=mB(O),d=_c(G,m,1),u=_c(O,f,1)}else throw"invalid block type";else{var T=gB(c)+4,W=n[T-4]|n[T-3]<<8,D=T+W;if(D>s){if(o)throw"unexpected EOF";break}r&&a(h+W),e.set(n.subarray(T,D),h),i.b=h+=W,i.p=c=D*8;continue}if(c>g){if(o)throw"unexpected EOF";break}}r&&a(h+131072);for(var F=(1<<m)-1,U=(1<<f)-1,Y=c;;Y=c){var L=d[fB(n,c)&F],q=L>>>4;if(c+=L&15,c>g){if(o)throw"unexpected EOF";break}if(!L)throw"invalid length/literal";if(q<256)e[h++]=q;else if(q==256){Y=c,d=null;break}else{var oe=q-254;if(q>264){var _=q-257,xe=_C[_];oe=Nl(n,c,(1<<xe)-1)+k4[_],c+=xe}var Be=u[fB(n,c)&U],re=Be>>>4;if(!Be)throw"invalid distance";c+=Be&15;var O=ffe[re];if(re>3){var xe=SC[re];O+=fB(n,c)&(1<<xe)-1,c+=xe}if(c>g){if(o)throw"unexpected EOF";break}r&&a(h+131072);for(var _e=h+oe;h<_e;h+=4)e[h]=e[h-O],e[h+1]=e[h+1-O],e[h+2]=e[h+2-O],e[h+3]=e[h+3-O];h=_e}}i.l=d,i.p=Y,i.b=h,d&&(l=1,i.m=m,i.d=u,i.n=f)}while(!l);return h==e.length?e:yB(e,0,h)},Wh=function(n,e,i){i<<=e&7;var s=e/8|0;n[s]|=i,n[s+1]|=i>>>8},hA=function(n,e,i){i<<=e&7;var s=e/8|0;n[s]|=i,n[s+1]|=i>>>8,n[s+2]|=i>>>16},vB=function(n,e){for(var i=[],s=0;s<n.length;++s)n[s]&&i.push({s,f:n[s]});var r=i.length,o=i.slice();if(!r)return[AB,0];if(r==1){var a=new os(i[0].s+1);return a[i[0].s]=1,[a,1]}i.sort(function(_,S){return _.f-S.f}),i.push({s:-1,f:25001});var l=i[0],c=i[1],h=0,d=1,u=2;for(i[0]={s:-1,f:l.f+c.f,l,r:c};d!=r-1;)l=i[i[h].f<i[u].f?h++:u++],c=i[h!=d&&i[h].f<i[u].f?h++:u++],i[d++]={s:-1,f:l.f+c.f,l,r:c};for(var m=o[0].s,s=1;s<r;++s)o[s].s>m&&(m=o[s].s);var f=new lo(m+1),g=bB(i[d-1],f,0);if(g>e){var s=0,v=0,y=g-e,b=1<<y;for(o.sort(function(S,C){return f[C.s]-f[S.s]||S.f-C.f});s<r;++s){var A=o[s].s;if(f[A]>e)v+=b-(1<<g-f[A]),f[A]=e;else break}for(v>>>=y;v>0;){var x=o[s].s;f[x]<e?v-=1<<e-f[x]++-1:++s}for(;s>=0&&v;--s){var w=o[s].s;f[w]==e&&(--f[w],++v)}g=e}return[new os(f),g]},bB=function(n,e,i){return n.s==-1?Math.max(bB(n.l,e,i+1),bB(n.r,e,i+1)):e[n.s]=i},D4=function(n){for(var e=n.length;e&&!n[--e];);for(var i=new lo(++e),s=0,r=n[0],o=1,a=function(c){i[s++]=c},l=1;l<=e;++l)if(n[l]==r&&l!=e)++o;else{if(!r&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(r),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(r);o=1,r=n[l]}return[i.subarray(0,s),e]},dA=function(n,e){for(var i=0,s=0;s<e.length;++s)i+=n[s]*e[s];return i},CC=function(n,e,i){var s=i.length,r=gB(e+2);n[r]=s&255,n[r+1]=s>>>8,n[r+2]=n[r]^255,n[r+3]=n[r+1]^255;for(var o=0;o<s;++o)n[r+o+4]=i[o];return(r+4+s)*8},G4=function(n,e,i,s,r,o,a,l,c,h,d){Wh(e,d++,i),++r[256];for(var u=vB(r,15),m=u[0],f=u[1],g=vB(o,15),v=g[0],y=g[1],b=D4(m),A=b[0],x=b[1],w=D4(v),_=w[0],S=w[1],C=new lo(19),R=0;R<A.length;++R)C[A[R]&31]++;for(var R=0;R<_.length;++R)C[_[R]&31]++;for(var P=vB(C,7),T=P[0],L=P[1],k=19;k>4&&!T[dB[k-1]];--k);var G=h+5<<3,O=dA(r,_u)+dA(o,cA)+a,W=dA(r,m)+dA(o,v)+a+14+3*k+dA(C,T)+(2*C[16]+3*C[17]+7*C[18]);if(G<=O&&G<=W)return CC(e,d,n.subarray(c,c+h));var D,F,U,Y;if(Wh(e,d,1+(W<O)),d+=2,W<O){D=_c(m,f,0),F=m,U=_c(v,y,0),Y=v;var q=_c(T,L,0);Wh(e,d,x-257),Wh(e,d+5,S-1),Wh(e,d+10,k-4),d+=14;for(var R=0;R<k;++R)Wh(e,d+3*R,T[dB[R]]);d+=3*k;for(var oe=[A,_],xe=0;xe<2;++xe)for(var Be=oe[xe],R=0;R<Be.length;++R){var re=Be[R]&31;Wh(e,d,q[re]),d+=T[re],re>15&&(Wh(e,d,Be[R]>>>5&127),d+=Be[R]>>>12)}}else D=gfe,F=_u,U=vfe,Y=cA;for(var R=0;R<l;++R)if(s[R]>255){var re=s[R]>>>18&31;hA(e,d,D[re+257]),d+=F[re+257],re>7&&(Wh(e,d,s[R]>>>23&31),d+=_C[re]);var _e=s[R]&31;hA(e,d,U[_e]),d+=Y[_e],_e>3&&(hA(e,d,s[R]>>>5&8191),d+=SC[_e])}else hA(e,d,D[s[R]]),d+=F[s[R]];return hA(e,d,D[256]),d+F[256]},xfe=new b0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),AB=new os(0),wfe=function(n,e,i,s,r,o){var a=n.length,l=new os(s+a+5*(1+Math.ceil(a/7e3))+r),c=l.subarray(s,l.length-r),h=0;if(!e||a<8)for(var d=0;d<=a;d+=65535){var u=d+65535;u<a?h=CC(c,h,n.subarray(d,u)):(c[d]=o,h=CC(c,h,n.subarray(d,a)))}else{for(var m=xfe[e-1],f=m>>>13,g=m&8191,v=(1<<i)-1,y=new lo(32768),b=new lo(v+1),A=Math.ceil(i/3),x=2*A,w=function(Te){return(n[Te]^n[Te+1]<<A^n[Te+2]<<x)&v},_=new b0(25e3),S=new lo(288),C=new lo(32),R=0,P=0,d=0,T=0,L=0,k=0;d<a;++d){var G=w(d),O=d&32767,W=b[G];if(y[O]=W,b[G]=O,L<=d){var D=a-d;if((R>7e3||T>24576)&&D>423){h=G4(n,c,0,_,S,C,P,T,k,d-k,h),T=R=P=0,k=d;for(var F=0;F<286;++F)S[F]=0;for(var F=0;F<30;++F)C[F]=0}var U=2,Y=0,q=g,oe=O-W&32767;if(D>2&&G==w(d-oe))for(var xe=Math.min(f,D)-1,Be=Math.min(32767,d),re=Math.min(258,D);oe<=Be&&--q&&O!=W;){if(n[d+U]==n[d+U-oe]){for(var _e=0;_e<re&&n[d+_e]==n[d+_e-oe];++_e);if(_e>U){if(U=_e,Y=oe,_e>xe)break;for(var Ie=Math.min(oe,_e-2),We=0,F=0;F<Ie;++F){var Ze=d-oe+F+32768&32767,Ge=y[Ze],rt=Ze-Ge+32768&32767;rt>We&&(We=rt,W=Ze)}}}O=W,W=y[O],oe+=O-W+32768&32767}if(Y){_[T++]=268435456|uB[U]<<18|O4[Y];var ye=uB[U]&31,Q=O4[Y]&31;P+=_C[ye]+SC[Q],++S[257+ye],++C[Q],L=d+U,++R}else _[T++]=n[d],++S[n[d]]}}h=G4(n,c,o,_,S,C,P,T,k,d-k,h),!o&&h&7&&(h=CC(c,h+1,AB))}return yB(l,0,s+gB(h)+r)},_fe=function(){for(var n=new b0(256),e=0;e<256;++e){for(var i=e,s=9;--s;)i=(i&1&&3988292384)^i>>>1;n[e]=i}return n}(),Sfe=function(){var n=-1;return{p:function(e){for(var i=n,s=0;s<e.length;++s)i=_fe[i&255^e[s]]^i>>>8;n=i},d:function(){return~n}}},Cfe=function(n,e,i,s,r){return wfe(n,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):12+e.mem,i,s,!r)},N4=function(n,e){var i={};for(var s in n)i[s]=n[s];for(var s in e)i[s]=e[s];return i},ir=function(n,e,i){for(;i;++e)n[e]=i,i>>>=8},Mfe=function(n){if((n[0]&15)!=8||n[0]>>>4>7||(n[0]<<8|n[1])%31)throw"invalid zlib data";if(n[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Efe(n,e){return Cfe(n,e||{},0,0)}function uA(n,e){return Afe((Mfe(n),n.subarray(2,-4)),e)}var F4=function(n,e,i,s){for(var r in n){var o=n[r],a=e+r;o instanceof os?i[a]=[o,s]:Array.isArray(o)?i[a]=[o[0],N4(s,o[1])]:F4(o,a+"/",i,s)}},z4=typeof TextEncoder<"u"&&new TextEncoder,Tfe=typeof TextDecoder<"u"&&new TextDecoder,Rfe=0;try{Tfe.decode(AB,{stream:!0}),Rfe=1}catch{}function MC(n,e){if(e){for(var i=new os(n.length),s=0;s<n.length;++s)i[s]=n.charCodeAt(s);return i}if(z4)return z4.encode(n);for(var r=n.length,o=new os(n.length+(n.length>>1)),a=0,l=function(u){o[a++]=u},s=0;s<r;++s){if(a+5>o.length){var c=new os(a+8+(r-s<<1));c.set(o),o=c}var h=n.charCodeAt(s);h<128||e?l(h):h<2048?(l(192|h>>6),l(128|h&63)):h>55295&&h<57344?(h=65536+(h&1047552)|n.charCodeAt(++s)&1023,l(240|h>>18),l(128|h>>12&63),l(128|h>>6&63),l(128|h&63)):(l(224|h>>12),l(128|h>>6&63),l(128|h&63))}return yB(o,0,a)}var xB=function(n){var e=0;if(n)for(var i in n){var s=n[i].length;if(s>65535)throw"extra field too long";e+=s+4}return e},U4=function(n,e,i,s,r,o,a,l){var c=s.length,h=i.extra,d=l&&l.length,u=xB(h);ir(n,e,a!=null?33639248:67324752),e+=4,a!=null&&(n[e++]=20,n[e++]=i.os),n[e]=20,e+=2,n[e++]=i.flag<<1|(o==null&&8),n[e++]=r&&8,n[e++]=i.compression&255,n[e++]=i.compression>>8;var m=new Date(i.mtime==null?Date.now():i.mtime),f=m.getFullYear()-1980;if(f<0||f>119)throw"date not in range 1980-2099";if(ir(n,e,f<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>>1),e+=4,o!=null&&(ir(n,e,i.crc),ir(n,e+4,o),ir(n,e+8,i.size)),ir(n,e+12,c),ir(n,e+14,u),e+=16,a!=null&&(ir(n,e,d),ir(n,e+6,i.attrs),ir(n,e+10,a),e+=14),n.set(s,e),e+=c,u)for(var g in h){var v=h[g],y=v.length;ir(n,e,+g),ir(n,e+2,y),n.set(v,e+4),e+=4+y}return d&&(n.set(l,e),e+=d),e},Ife=function(n,e,i,s,r){ir(n,e,101010256),ir(n,e+8,i),ir(n,e+10,i),ir(n,e+12,s),ir(n,e+16,r)};function Lfe(n,e){e||(e={});var i={},s=[];F4(n,"",i,e);var r=0,o=0;for(var a in i){var l=i[a],c=l[0],h=l[1],d=h.level==0?0:8,u=MC(a),m=u.length,f=h.comment,g=f&&MC(f),v=g&&g.length,y=xB(h.extra);if(m>65535)throw"filename too long";var b=d?Efe(c,h):c,A=b.length,x=Sfe();x.p(c),s.push(N4(h,{size:c.length,crc:x.d(),c:b,f:u,m:g,u:m!=a.length||g&&f.length!=v,o:r,compression:d})),r+=30+m+y+A,o+=76+2*(m+y)+(v||0)+A}for(var w=new os(o+22),_=r,S=o-r,C=0;C<s.length;++C){var u=s[C];U4(w,u.o,u,u.f,u.u,u.c.length);var R=30+u.f.length+xB(u.extra);w.set(u.c,u.o+R),U4(w,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+R+(u.m?u.m.length:0)}return Ife(w,r,s.length,S,_),w}class pA extends $2{constructor(e){super(e),this.type=ms}parse(e){const i=Math.pow(2.7182818,2.2);function s(I,B){let X=0;for(let V=0;V<65536;++V)(V==0||I[V>>3]&1<<(V&7))&&(B[X++]=V);const ee=X-1;for(;X<65536;)B[X++]=0;return ee}function r(I){for(let B=0;B<16384;B++)I[B]={},I[B].len=0,I[B].lit=0,I[B].p=null}const o={l:0,c:0,lc:0};function a(I,B,X,ee,V){for(;X<I;)B=B<<8|Q(ee,V),X+=8;X-=I,o.l=B>>X&(1<<I)-1,o.c=B,o.lc=X}const l=new Array(59);function c(I){for(let X=0;X<=58;++X)l[X]=0;for(let X=0;X<65537;++X)l[I[X]]+=1;let B=0;for(let X=58;X>0;--X){const ee=B+l[X]>>1;l[X]=B,B=ee}for(let X=0;X<65537;++X){const ee=I[X];ee>0&&(I[X]=ee|l[ee]++<<6)}}function h(I,B,X,ee,V,J){const j=B;let ae=0,ce=0;for(;ee<=V;ee++){if(j.value-B.value>X)return!1;a(6,ae,ce,I,j);const we=o.l;if(ae=o.c,ce=o.lc,J[ee]=we,we==63){if(j.value-B.value>X)throw new Error("Something wrong with hufUnpackEncTable");a(8,ae,ce,I,j);let Re=o.l+6;if(ae=o.c,ce=o.lc,ee+Re>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)J[ee++]=0;ee--}else if(we>=59){let Re=we-59+2;if(ee+Re>V+1)throw new Error("Something wrong with hufUnpackEncTable");for(;Re--;)J[ee++]=0;ee--}}c(J)}function d(I){return I&63}function u(I){return I>>6}function m(I,B,X,ee){for(;B<=X;B++){const V=u(I[B]),J=d(I[B]);if(V>>J)throw new Error("Invalid table entry");if(J>14){const j=ee[V>>J-14];if(j.len)throw new Error("Invalid table entry");if(j.lit++,j.p){const ae=j.p;j.p=new Array(j.lit);for(let ce=0;ce<j.lit-1;++ce)j.p[ce]=ae[ce]}else j.p=new Array(1);j.p[j.lit-1]=B}else if(J){let j=0;for(let ae=1<<14-J;ae>0;ae--){const ce=ee[(V<<14-J)+j];if(ce.len||ce.p)throw new Error("Invalid table entry");ce.len=J,ce.lit=B,j++}}}return!0}const f={c:0,lc:0};function g(I,B,X,ee){I=I<<8|Q(X,ee),B+=8,f.c=I,f.lc=B}const v={c:0,lc:0};function y(I,B,X,ee,V,J,j,ae,ce){if(I==B){ee<8&&(g(X,ee,V,J),X=f.c,ee=f.lc),ee-=8;let we=X>>ee;if(we=new Uint8Array([we])[0],ae.value+we>ce)return!1;const Re=j[ae.value-1];for(;we-- >0;)j[ae.value++]=Re}else if(ae.value<ce)j[ae.value++]=I;else return!1;v.c=X,v.lc=ee}function b(I){return I&65535}function A(I){const B=b(I);return B>32767?B-65536:B}const x={a:0,b:0};function w(I,B){const X=A(I),ee=A(B),V=X+(ee&1)+(ee>>1),J=V,j=V-ee;x.a=J,x.b=j}function _(I,B){const X=b(I),ee=b(B),V=X-(ee>>1)&65535,J=ee+V-32768&65535;x.a=J,x.b=V}function S(I,B,X,ee,V,J,j){const ae=j<16384,ce=X>V?V:X;let we=1,Re,Je;for(;we<=ce;)we<<=1;for(we>>=1,Re=we,we>>=1;we>=1;){Je=0;const Ye=Je+J*(V-Re),tt=J*we,bt=J*Re,ot=ee*we,St=ee*Re;let ti,Ui,hn,Es;for(;Je<=Ye;Je+=bt){let Ni=Je;const ui=Je+ee*(X-Re);for(;Ni<=ui;Ni+=St){const zn=Ni+ot,xo=Ni+tt,$n=xo+ot;ae?(w(I[Ni+B],I[xo+B]),ti=x.a,hn=x.b,w(I[zn+B],I[$n+B]),Ui=x.a,Es=x.b,w(ti,Ui),I[Ni+B]=x.a,I[zn+B]=x.b,w(hn,Es),I[xo+B]=x.a,I[$n+B]=x.b):(_(I[Ni+B],I[xo+B]),ti=x.a,hn=x.b,_(I[zn+B],I[$n+B]),Ui=x.a,Es=x.b,_(ti,Ui),I[Ni+B]=x.a,I[zn+B]=x.b,_(hn,Es),I[xo+B]=x.a,I[$n+B]=x.b)}if(X&we){const zn=Ni+tt;ae?w(I[Ni+B],I[zn+B]):_(I[Ni+B],I[zn+B]),ti=x.a,I[zn+B]=x.b,I[Ni+B]=ti}}if(V&we){let Ni=Je;const ui=Je+ee*(X-Re);for(;Ni<=ui;Ni+=St){const zn=Ni+ot;ae?w(I[Ni+B],I[zn+B]):_(I[Ni+B],I[zn+B]),ti=x.a,I[zn+B]=x.b,I[Ni+B]=ti}}Re=we,we>>=1}return Je}function C(I,B,X,ee,V,J,j,ae,ce){let we=0,Re=0;const Je=j,Ye=Math.trunc(ee.value+(V+7)/8);for(;ee.value<Ye;)for(g(we,Re,X,ee),we=f.c,Re=f.lc;Re>=14;){const bt=we>>Re-14&16383,ot=B[bt];if(ot.len)Re-=ot.len,y(ot.lit,J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;else{if(!ot.p)throw new Error("hufDecode issues");let St;for(St=0;St<ot.lit;St++){const ti=d(I[ot.p[St]]);for(;Re<ti&&ee.value<Ye;)g(we,Re,X,ee),we=f.c,Re=f.lc;if(Re>=ti&&u(I[ot.p[St]])==(we>>Re-ti&(1<<ti)-1)){Re-=ti,y(ot.p[St],J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;break}}if(St==ot.lit)throw new Error("hufDecode issues")}}const tt=8-V&7;for(we>>=tt,Re-=tt;Re>0;){const bt=B[we<<14-Re&16383];if(bt.len)Re-=bt.len,y(bt.lit,J,we,Re,X,ee,ae,ce,Je),we=v.c,Re=v.lc;else throw new Error("hufDecode issues")}return!0}function R(I,B,X,ee,V,J){const j={value:0},ae=X.value,ce=ye(B,X),we=ye(B,X);X.value+=4;const Re=ye(B,X);if(X.value+=4,ce<0||ce>=65537||we<0||we>=65537)throw new Error("Something wrong with HUF_ENCSIZE");const Je=new Array(65537),Ye=new Array(16384);r(Ye);const tt=ee-(X.value-ae);if(h(I,X,tt,ce,we,Je),Re>8*(ee-(X.value-ae)))throw new Error("Something wrong with hufUncompress");m(Je,ce,we,Ye),C(Je,Ye,I,X,Re,we,J,V,j)}function P(I,B,X){for(let ee=0;ee<X;++ee)B[ee]=I[B[ee]]}function T(I){for(let B=1;B<I.length;B++){const X=I[B-1]+I[B]-128;I[B]=X}}function L(I,B){let X=0,ee=Math.floor((I.length+1)/2),V=0;const J=I.length-1;for(;!(V>J||(B[V++]=I[X++],V>J));)B[V++]=I[ee++]}function k(I){let B=I.byteLength;const X=new Array;let ee=0;const V=new DataView(I);for(;B>0;){const J=V.getInt8(ee++);if(J<0){const j=-J;B-=j+1;for(let ae=0;ae<j;ae++)X.push(V.getUint8(ee++))}else{const j=J;B-=2;const ae=V.getUint8(ee++);for(let ce=0;ce<j+1;ce++)X.push(ae)}}return X}function G(I,B,X,ee,V,J){let j=new DataView(J.buffer);const ae=X[I.idx[0]].width,ce=X[I.idx[0]].height,we=3,Re=Math.floor(ae/8),Je=Math.ceil(ae/8),Ye=Math.ceil(ce/8),tt=ae-(Je-1)*8,bt=ce-(Ye-1)*8,ot={value:0},St=new Array(we),ti=new Array(we),Ui=new Array(we),hn=new Array(we),Es=new Array(we);for(let ui=0;ui<we;++ui)Es[ui]=B[I.idx[ui]],St[ui]=ui<1?0:St[ui-1]+Je*Ye,ti[ui]=new Float32Array(64),Ui[ui]=new Uint16Array(64),hn[ui]=new Uint16Array(Je*64);for(let ui=0;ui<Ye;++ui){let zn=8;ui==Ye-1&&(zn=bt);let xo=8;for(let z=0;z<Je;++z){z==Je-1&&(xo=tt);for(let ne=0;ne<we;++ne)Ui[ne].fill(0),Ui[ne][0]=V[St[ne]++],O(ot,ee,Ui[ne]),W(Ui[ne],ti[ne]),D(ti[ne]);F(ti);for(let ne=0;ne<we;++ne)U(ti[ne],hn[ne],z*64)}let $n=0;for(let z=0;z<we;++z){const ne=X[I.idx[z]].type;for(let fe=8*ui;fe<8*ui+zn;++fe){$n=Es[z][fe];for(let ve=0;ve<Re;++ve){const le=ve*64+(fe&7)*8;j.setUint16($n+0*2*ne,hn[z][le+0],!0),j.setUint16($n+1*2*ne,hn[z][le+1],!0),j.setUint16($n+2*2*ne,hn[z][le+2],!0),j.setUint16($n+3*2*ne,hn[z][le+3],!0),j.setUint16($n+4*2*ne,hn[z][le+4],!0),j.setUint16($n+5*2*ne,hn[z][le+5],!0),j.setUint16($n+6*2*ne,hn[z][le+6],!0),j.setUint16($n+7*2*ne,hn[z][le+7],!0),$n+=8*2*ne}}if(Re!=Je)for(let fe=8*ui;fe<8*ui+zn;++fe){const ve=Es[z][fe]+8*Re*2*ne,le=Re*64+(fe&7)*8;for(let it=0;it<xo;++it)j.setUint16(ve+it*2*ne,hn[z][le+it],!0)}}}const Ni=new Uint16Array(ae);j=new DataView(J.buffer);for(let ui=0;ui<we;++ui){X[I.idx[ui]].decoded=!0;const zn=X[I.idx[ui]].type;if(X[ui].type==2)for(let xo=0;xo<ce;++xo){const $n=Es[ui][xo];for(let z=0;z<ae;++z)Ni[z]=j.getUint16($n+z*2*zn,!0);for(let z=0;z<ae;++z)j.setFloat32($n+z*2*zn,be(Ni[z]),!0)}}}function O(I,B,X){let ee,V=1;for(;V<64;)ee=B[I.value],ee==65280?V=64:ee>>8==255?V+=ee&255:(X[V]=ee,V++),I.value++}function W(I,B){B[0]=be(I[0]),B[1]=be(I[1]),B[2]=be(I[5]),B[3]=be(I[6]),B[4]=be(I[14]),B[5]=be(I[15]),B[6]=be(I[27]),B[7]=be(I[28]),B[8]=be(I[2]),B[9]=be(I[4]),B[10]=be(I[7]),B[11]=be(I[13]),B[12]=be(I[16]),B[13]=be(I[26]),B[14]=be(I[29]),B[15]=be(I[42]),B[16]=be(I[3]),B[17]=be(I[8]),B[18]=be(I[12]),B[19]=be(I[17]),B[20]=be(I[25]),B[21]=be(I[30]),B[22]=be(I[41]),B[23]=be(I[43]),B[24]=be(I[9]),B[25]=be(I[11]),B[26]=be(I[18]),B[27]=be(I[24]),B[28]=be(I[31]),B[29]=be(I[40]),B[30]=be(I[44]),B[31]=be(I[53]),B[32]=be(I[10]),B[33]=be(I[19]),B[34]=be(I[23]),B[35]=be(I[32]),B[36]=be(I[39]),B[37]=be(I[45]),B[38]=be(I[52]),B[39]=be(I[54]),B[40]=be(I[20]),B[41]=be(I[22]),B[42]=be(I[33]),B[43]=be(I[38]),B[44]=be(I[46]),B[45]=be(I[51]),B[46]=be(I[55]),B[47]=be(I[60]),B[48]=be(I[21]),B[49]=be(I[34]),B[50]=be(I[37]),B[51]=be(I[47]),B[52]=be(I[50]),B[53]=be(I[56]),B[54]=be(I[59]),B[55]=be(I[61]),B[56]=be(I[35]),B[57]=be(I[36]),B[58]=be(I[48]),B[59]=be(I[49]),B[60]=be(I[57]),B[61]=be(I[58]),B[62]=be(I[62]),B[63]=be(I[63])}function D(I){const B=.5*Math.cos(.7853975),X=.5*Math.cos(3.14159/16),ee=.5*Math.cos(3.14159/8),V=.5*Math.cos(3*3.14159/16),J=.5*Math.cos(5*3.14159/16),j=.5*Math.cos(3*3.14159/8),ae=.5*Math.cos(7*3.14159/16),ce=new Array(4),we=new Array(4),Re=new Array(4),Je=new Array(4);for(let Ye=0;Ye<8;++Ye){const tt=Ye*8;ce[0]=ee*I[tt+2],ce[1]=j*I[tt+2],ce[2]=ee*I[tt+6],ce[3]=j*I[tt+6],we[0]=X*I[tt+1]+V*I[tt+3]+J*I[tt+5]+ae*I[tt+7],we[1]=V*I[tt+1]-ae*I[tt+3]-X*I[tt+5]-J*I[tt+7],we[2]=J*I[tt+1]-X*I[tt+3]+ae*I[tt+5]+V*I[tt+7],we[3]=ae*I[tt+1]-J*I[tt+3]+V*I[tt+5]-X*I[tt+7],Re[0]=B*(I[tt+0]+I[tt+4]),Re[3]=B*(I[tt+0]-I[tt+4]),Re[1]=ce[0]+ce[3],Re[2]=ce[1]-ce[2],Je[0]=Re[0]+Re[1],Je[1]=Re[3]+Re[2],Je[2]=Re[3]-Re[2],Je[3]=Re[0]-Re[1],I[tt+0]=Je[0]+we[0],I[tt+1]=Je[1]+we[1],I[tt+2]=Je[2]+we[2],I[tt+3]=Je[3]+we[3],I[tt+4]=Je[3]-we[3],I[tt+5]=Je[2]-we[2],I[tt+6]=Je[1]-we[1],I[tt+7]=Je[0]-we[0]}for(let Ye=0;Ye<8;++Ye)ce[0]=ee*I[16+Ye],ce[1]=j*I[16+Ye],ce[2]=ee*I[48+Ye],ce[3]=j*I[48+Ye],we[0]=X*I[8+Ye]+V*I[24+Ye]+J*I[40+Ye]+ae*I[56+Ye],we[1]=V*I[8+Ye]-ae*I[24+Ye]-X*I[40+Ye]-J*I[56+Ye],we[2]=J*I[8+Ye]-X*I[24+Ye]+ae*I[40+Ye]+V*I[56+Ye],we[3]=ae*I[8+Ye]-J*I[24+Ye]+V*I[40+Ye]-X*I[56+Ye],Re[0]=B*(I[Ye]+I[32+Ye]),Re[3]=B*(I[Ye]-I[32+Ye]),Re[1]=ce[0]+ce[3],Re[2]=ce[1]-ce[2],Je[0]=Re[0]+Re[1],Je[1]=Re[3]+Re[2],Je[2]=Re[3]-Re[2],Je[3]=Re[0]-Re[1],I[0+Ye]=Je[0]+we[0],I[8+Ye]=Je[1]+we[1],I[16+Ye]=Je[2]+we[2],I[24+Ye]=Je[3]+we[3],I[32+Ye]=Je[3]-we[3],I[40+Ye]=Je[2]-we[2],I[48+Ye]=Je[1]-we[1],I[56+Ye]=Je[0]-we[0]}function F(I){for(let B=0;B<64;++B){const X=I[0][B],ee=I[1][B],V=I[2][B];I[0][B]=X+1.5747*V,I[1][B]=X-.1873*ee-.4682*V,I[2][B]=X+1.8556*ee}}function U(I,B,X){for(let ee=0;ee<64;++ee)B[X+ee]=Bp.toHalfFloat(Y(I[ee]))}function Y(I){return I<=1?Math.sign(I)*Math.pow(Math.abs(I),2.2):Math.sign(I)*Math.pow(i,Math.abs(I)-1)}function q(I){return new DataView(I.array.buffer,I.offset.value,I.size)}function oe(I){const B=I.viewer.buffer.slice(I.offset.value,I.offset.value+I.size),X=new Uint8Array(k(B)),ee=new Uint8Array(X.length);return T(X),L(X,ee),new DataView(ee.buffer)}function xe(I){const B=I.array.slice(I.offset.value,I.offset.value+I.size),X=uA(B),ee=new Uint8Array(X.length);return T(X),L(X,ee),new DataView(ee.buffer)}function Be(I){const B=I.viewer,X={value:I.offset.value},ee=new Uint16Array(I.width*I.scanlineBlockSize*(I.channels*I.type)),V=new Uint8Array(8192);let J=0;const j=new Array(I.channels);for(let bt=0;bt<I.channels;bt++)j[bt]={},j[bt].start=J,j[bt].end=j[bt].start,j[bt].nx=I.width,j[bt].ny=I.lines,j[bt].size=I.type,J+=j[bt].nx*j[bt].ny*j[bt].size;const ae=nt(B,X),ce=nt(B,X);if(ce>=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(ae<=ce)for(let bt=0;bt<ce-ae+1;bt++)V[bt+ae]=ze(B,X);const we=new Uint16Array(65536),Re=s(V,we),Je=ye(B,X);R(I.array,B,X,Je,ee,J);for(let bt=0;bt<I.channels;++bt){const ot=j[bt];for(let St=0;St<j[bt].size;++St)S(ee,ot.start+St,ot.nx,ot.size,ot.ny,ot.nx*ot.size,Re)}P(we,ee,J);let Ye=0;const tt=new Uint8Array(ee.buffer.byteLength);for(let bt=0;bt<I.lines;bt++)for(let ot=0;ot<I.channels;ot++){const St=j[ot],ti=St.nx*St.size,Ui=new Uint8Array(ee.buffer,St.end*2,ti*2);tt.set(Ui,Ye),Ye+=ti*2,St.end+=ti}return new DataView(tt.buffer)}function re(I){const B=I.array.slice(I.offset.value,I.offset.value+I.size),X=uA(B),ee=I.lines*I.channels*I.width,V=I.type==1?new Uint16Array(ee):new Uint32Array(ee);let J=0,j=0;const ae=new Array(4);for(let ce=0;ce<I.lines;ce++)for(let we=0;we<I.channels;we++){let Re=0;switch(I.type){case 1:ae[0]=J,ae[1]=ae[0]+I.width,J=ae[1]+I.width;for(let Je=0;Je<I.width;++Je){const Ye=X[ae[0]++]<<8|X[ae[1]++];Re+=Ye,V[j]=Re,j++}break;case 2:ae[0]=J,ae[1]=ae[0]+I.width,ae[2]=ae[1]+I.width,J=ae[2]+I.width;for(let Je=0;Je<I.width;++Je){const Ye=X[ae[0]++]<<24|X[ae[1]++]<<16|X[ae[2]++]<<8;Re+=Ye,V[j]=Re,j++}break}}return new DataView(V.buffer)}function _e(I){const B=I.viewer,X={value:I.offset.value},ee=new Uint8Array(I.width*I.lines*(I.channels*I.type*2)),V={version:Te(B,X),unknownUncompressedSize:Te(B,X),unknownCompressedSize:Te(B,X),acCompressedSize:Te(B,X),dcCompressedSize:Te(B,X),rleCompressedSize:Te(B,X),rleUncompressedSize:Te(B,X),rleRawSize:Te(B,X),totalAcUncompressedCount:Te(B,X),totalDcUncompressedCount:Te(B,X),acCompression:Te(B,X)};if(V.version<2)throw new Error("EXRLoader.parse: "+qt.compression+" version "+V.version+" is unsupported");const J=new Array;let j=nt(B,X)-2;for(;j>0;){const ot=Ie(B.buffer,X),St=ze(B,X),ti=St>>2&3,Ui=(St>>4)-1,hn=new Int8Array([Ui])[0],Es=ze(B,X);J.push({name:ot,index:hn,type:Es,compression:ti}),j-=ot.length+3}const ae=qt.channels,ce=new Array(I.channels);for(let ot=0;ot<I.channels;++ot){const St=ce[ot]={},ti=ae[ot];St.name=ti.name,St.compression=0,St.decoded=!1,St.type=ti.pixelType,St.pLinear=ti.pLinear,St.width=I.width,St.height=I.lines}const we={idx:new Array(3)};for(let ot=0;ot<I.channels;++ot){const St=ce[ot];for(let ti=0;ti<J.length;++ti){const Ui=J[ti];St.name==Ui.name&&(St.compression=Ui.compression,Ui.index>=0&&(we.idx[Ui.index]=ot),St.offset=ot)}}let Re,Je,Ye;if(V.acCompressedSize>0)switch(V.acCompression){case 0:Re=new Uint16Array(V.totalAcUncompressedCount),R(I.array,B,X,V.acCompressedSize,Re,V.totalAcUncompressedCount);break;case 1:const ot=I.array.slice(X.value,X.value+V.totalAcUncompressedCount),St=uA(ot);Re=new Uint16Array(St.buffer),X.value+=V.totalAcUncompressedCount;break}if(V.dcCompressedSize>0){const ot={array:I.array,offset:X,size:V.dcCompressedSize};Je=new Uint16Array(xe(ot).buffer),X.value+=V.dcCompressedSize}if(V.rleRawSize>0){const ot=I.array.slice(X.value,X.value+V.rleCompressedSize),St=uA(ot);Ye=k(St.buffer),X.value+=V.rleCompressedSize}let tt=0;const bt=new Array(ce.length);for(let ot=0;ot<bt.length;++ot)bt[ot]=new Array;for(let ot=0;ot<I.lines;++ot)for(let St=0;St<ce.length;++St)bt[St].push(tt),tt+=ce[St].width*I.type*2;G(we,bt,ce,Re,Je,ee);for(let ot=0;ot<ce.length;++ot){const St=ce[ot];if(!St.decoded)switch(St.compression){case 2:let ti=0,Ui=0;for(let hn=0;hn<I.lines;++hn){let Es=bt[ot][ti];for(let Ni=0;Ni<St.width;++Ni){for(let ui=0;ui<2*St.type;++ui)ee[Es++]=Ye[Ui+ui*St.width*St.height];Ui++}ti++}break;case 1:default:throw new Error("EXRLoader.parse: unsupported channel compression")}}return new DataView(ee.buffer)}function Ie(I,B){const X=new Uint8Array(I);let ee=0;for(;X[B.value+ee]!=0;)ee+=1;const V=new TextDecoder().decode(X.slice(B.value,B.value+ee));return B.value=B.value+ee+1,V}function We(I,B,X){const ee=new TextDecoder().decode(new Uint8Array(I).slice(B.value,B.value+X));return B.value=B.value+X,ee}function Ze(I,B){const X=rt(I,B),ee=ye(I,B);return[X,ee]}function Ge(I,B){const X=ye(I,B),ee=ye(I,B);return[X,ee]}function rt(I,B){const X=I.getInt32(B.value,!0);return B.value=B.value+4,X}function ye(I,B){const X=I.getUint32(B.value,!0);return B.value=B.value+4,X}function Q(I,B){const X=I[B.value];return B.value=B.value+1,X}function ze(I,B){const X=I.getUint8(B.value);return B.value=B.value+1,X}const Te=function(I,B){let X;return"getBigInt64"in DataView.prototype?X=Number(I.getBigInt64(B.value,!0)):X=I.getUint32(B.value+4,!0)+Number(I.getUint32(B.value,!0)<<32),B.value+=8,X};function Ee(I,B){const X=I.getFloat32(B.value,!0);return B.value+=4,X}function He(I,B){return Bp.toHalfFloat(Ee(I,B))}function be(I){const B=(I&31744)>>10,X=I&1023;return(I>>15?-1:1)*(B?B===31?X?NaN:1/0:Math.pow(2,B-15)*(1+X/1024):6103515625e-14*(X/1024))}function nt(I,B){const X=I.getUint16(B.value,!0);return B.value+=2,X}function ct(I,B){return be(nt(I,B))}function It(I,B,X,ee){const V=X.value,J=[];for(;X.value<V+ee-1;){const j=Ie(B,X),ae=rt(I,X),ce=ze(I,X);X.value+=3;const we=rt(I,X),Re=rt(I,X);J.push({name:j,pixelType:ae,pLinear:ce,xSampling:we,ySampling:Re})}return X.value+=1,J}function H(I,B){const X=Ee(I,B),ee=Ee(I,B),V=Ee(I,B),J=Ee(I,B),j=Ee(I,B),ae=Ee(I,B),ce=Ee(I,B),we=Ee(I,B);return{redX:X,redY:ee,greenX:V,greenY:J,blueX:j,blueY:ae,whiteX:ce,whiteY:we}}function N(I,B){const X=["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"],ee=ze(I,B);return X[ee]}function de(I,B){const X=ye(I,B),ee=ye(I,B),V=ye(I,B),J=ye(I,B);return{xMin:X,yMin:ee,xMax:V,yMax:J}}function Me(I,B){const X=["INCREASING_Y"],ee=ze(I,B);return X[ee]}function Oe(I,B){const X=Ee(I,B),ee=Ee(I,B);return[X,ee]}function Le(I,B){const X=Ee(I,B),ee=Ee(I,B),V=Ee(I,B);return[X,ee,V]}function xt(I,B,X,ee,V){if(ee==="string"||ee==="stringvector"||ee==="iccProfile")return We(B,X,V);if(ee==="chlist")return It(I,B,X,V);if(ee==="chromaticities")return H(I,X);if(ee==="compression")return N(I,X);if(ee==="box2i")return de(I,X);if(ee==="lineOrder")return Me(I,X);if(ee==="float")return Ee(I,X);if(ee==="v2f")return Oe(I,X);if(ee==="v3f")return Le(I,X);if(ee==="int")return rt(I,X);if(ee==="rational")return Ze(I,X);if(ee==="timecode")return Ge(I,X);if(ee==="preview")return X.value+=V,"skipped";X.value+=V}function dt(I,B,X){const ee={};if(I.getUint32(0,!0)!=20000630)throw new Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");ee.version=I.getUint8(4);const V=I.getUint8(5);ee.spec={singleTile:!!(V&2),longName:!!(V&4),deepFormat:!!(V&8),multiPart:!!(V&16)},X.value=8;let J=!0;for(;J;){const j=Ie(B,X);if(j==0)J=!1;else{const ae=Ie(B,X),ce=ye(I,X),we=xt(I,B,X,ae,ce);we===void 0?console.warn(`THREE.EXRLoader: Skipped unknown header attribute type '${ae}'.`):ee[j]=we}}if(V&-5)throw console.error("THREE.EXRHeader:",ee),new Error("THREE.EXRLoader: Provided file is currently unsupported.");return ee}function Ue(I,B,X,ee,V){const J={size:0,viewer:B,array:X,offset:ee,width:I.dataWindow.xMax-I.dataWindow.xMin+1,height:I.dataWindow.yMax-I.dataWindow.yMin+1,channels:I.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:I.channels[0].pixelType,uncompress:null,getter:null,format:null,colorSpace:ki};switch(I.compression){case"NO_COMPRESSION":J.lines=1,J.uncompress=q;break;case"RLE_COMPRESSION":J.lines=1,J.uncompress=oe;break;case"ZIPS_COMPRESSION":J.lines=1,J.uncompress=xe;break;case"ZIP_COMPRESSION":J.lines=16,J.uncompress=xe;break;case"PIZ_COMPRESSION":J.lines=32,J.uncompress=Be;break;case"PXR24_COMPRESSION":J.lines=16,J.uncompress=re;break;case"DWAA_COMPRESSION":J.lines=32,J.uncompress=_e;break;case"DWAB_COMPRESSION":J.lines=256,J.uncompress=_e;break;default:throw new Error("EXRLoader.parse: "+I.compression+" is unsupported")}if(J.scanlineBlockSize=J.lines,J.type==1)switch(V){case Qi:J.getter=ct,J.inputSize=2;break;case ms:J.getter=nt,J.inputSize=2;break}else if(J.type==2)switch(V){case Qi:J.getter=Ee,J.inputSize=4;break;case ms:J.getter=He,J.inputSize=4}else throw new Error("EXRLoader.parse: unsupported pixelType "+J.type+" for "+I.compression+".");J.blockCount=(I.dataWindow.yMax+1)/J.scanlineBlockSize;for(let ae=0;ae<J.blockCount;ae++)Te(B,ee);J.outputChannels=J.channels==3?4:J.channels;const j=J.width*J.height*J.outputChannels;switch(V){case Qi:J.byteArray=new Float32Array(j),J.channels<J.outputChannels&&J.byteArray.fill(1,0,j);break;case ms:J.byteArray=new Uint16Array(j),J.channels<J.outputChannels&&J.byteArray.fill(15360,0,j);break;default:console.error("THREE.EXRLoader: unsupported type: ",V);break}return J.bytesPerLine=J.width*J.inputSize*J.channels,J.outputChannels==4?(J.format=wi,J.colorSpace=ki):(J.format=Tp,J.colorSpace=So),J}const Xe=new DataView(e),Ct=new Uint8Array(e),Ne={value:0},qt=dt(Xe,e,Ne),De=Ue(qt,Xe,Ct,Ne,this.type),_t={value:0},ut={R:0,G:1,B:2,A:3,Y:0};for(let I=0;I<De.height/De.scanlineBlockSize;I++){const B=ye(Xe,Ne);De.size=ye(Xe,Ne),De.lines=B+De.scanlineBlockSize>De.height?De.height-B:De.scanlineBlockSize;const X=De.size<De.lines*De.bytesPerLine?De.uncompress(De):q(De);Ne.value+=De.size;for(let ee=0;ee<De.scanlineBlockSize;ee++){const V=ee+I*De.scanlineBlockSize;if(V>=De.height)break;for(let J=0;J<De.channels;J++){const j=ut[qt.channels[J].name];for(let ae=0;ae<De.width;ae++){_t.value=(ee*(De.channels*De.width)+J*De.width+ae)*De.inputSize;const ce=(De.height-1-V)*(De.width*De.outputChannels)+ae*De.outputChannels+j;De.byteArray[ce]=De.getter(X,_t)}}}}return{header:qt,width:De.width,height:De.height,data:De.byteArray,format:De.format,colorSpace:De.colorSpace,type:this.type}}setDataType(e){return this.type=e,this}load(e,i,s,r){function o(a,l){a.colorSpace=l.colorSpace,a.minFilter=Dt,a.magFilter=Dt,a.generateMipmaps=!1,a.flipY=!1,i&&i(a,l)}return super.load(e,o,s,r)}}const Pfe=Object.freeze(Object.defineProperty({__proto__:null,EXRLoader:pA},Symbol.toStringTag,{value:"Module"}));class EC extends $2{constructor(e){super(e),this.type=ms}parse(e){const i=function(b,A){switch(b){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(A||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(A||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(A||""))}},s=`
|
|
5000
5000
|
`,r=function(b,A,x){A=A||1024;let w=b.pos,_=-1,S=0,C="",R=String.fromCharCode.apply(null,new Uint16Array(b.subarray(w,w+128)));for(;0>(_=R.indexOf(s))&&S<A&&w<b.byteLength;)C+=R,S+=R.length,w+=128,R+=String.fromCharCode.apply(null,new Uint16Array(b.subarray(w,w+128)));return-1<_?(x!==!1&&(b.pos+=S+_+1),C+R.slice(0,_)):!1},o=function(b){const A=/^#\?(\S+)/,x=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,w=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,S=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,C={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let R,P;for((b.pos>=b.byteLength||!(R=r(b)))&&i(1,"no header found"),(P=R.match(A))||i(3,"bad initial token"),C.valid|=1,C.programtype=P[1],C.string+=R+`
|
|
5001
5001
|
`;R=r(b),R!==!1;){if(C.string+=R+`
|
|
5002
5002
|
`,R.charAt(0)==="#"){C.comments+=R+`
|
|
5003
|
-
`;continue}if((P=R.match(x))&&(C.gamma=parseFloat(P[1])),(P=R.match(w))&&(C.exposure=parseFloat(P[1])),(P=R.match(_))&&(C.valid|=2,C.format=P[1]),(P=R.match(S))&&(C.valid|=4,C.height=parseInt(P[1],10),C.width=parseInt(P[2],10)),C.valid&2&&C.valid&4)break}return C.valid&2||i(3,"missing format specifier"),C.valid&4||i(3,"missing image size specifier"),C},a=function(b,A,x){const w=A;if(w<8||w>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);w!==(b[2]<<8|b[3])&&i(3,"wrong scanline width");const _=new Uint8Array(4*A*x);_.length||i(4,"unable to allocate buffer space");let S=0,C=0;const R=4*w,P=new Uint8Array(4),T=new Uint8Array(R);let L=x;for(;L>0&&C<b.byteLength;){C+4>b.byteLength&&i(1),P[0]=b[C++],P[1]=b[C++],P[2]=b[C++],P[3]=b[C++],(P[0]!=2||P[1]!=2||(P[2]<<8|P[3])!=w)&&i(3,"bad rgbe scanline format");let k=0,G;for(;k<R&&C<b.byteLength;){G=b[C++];const W=G>128;if(W&&(G-=128),(G===0||k+G>R)&&i(3,"bad scanline data"),W){const D=b[C++];for(let F=0;F<G;F++)T[k++]=D}else T.set(b.subarray(C,C+G),k),k+=G,C+=G}const O=w;for(let W=0;W<O;W++){let D=0;_[S]=T[W+D],D+=w,_[S+1]=T[W+D],D+=w,_[S+2]=T[W+D],D+=w,_[S+3]=T[W+D],S+=4}L--}return _},l=function(b,A,x,w){const _=b[A+3],S=Math.pow(2,_-128)/255;x[w+0]=b[A+0]*S,x[w+1]=b[A+1]*S,x[w+2]=b[A+2]*S,x[w+3]=1},c=function(b,A,x,w){const _=b[A+3],S=Math.pow(2,_-128)/255;x[w+0]=Bp.toHalfFloat(Math.min(b[A+0]*S,65504)),x[w+1]=Bp.toHalfFloat(Math.min(b[A+1]*S,65504)),x[w+2]=Bp.toHalfFloat(Math.min(b[A+2]*S,65504)),x[w+3]=Bp.toHalfFloat(1)},h=new Uint8Array(e);h.pos=0;const d=o(h),u=d.width,m=d.height,f=a(h.subarray(h.pos),u,m);let g,v,y;switch(this.type){case Qi:y=f.length/4;const b=new Float32Array(y*4);for(let x=0;x<y;x++)l(f,x*4,b,x*4);g=b,v=Qi;break;case ms:y=f.length/4;const A=new Uint16Array(y*4);for(let x=0;x<y;x++)c(f,x*4,A,x*4);g=A,v=ms;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:u,height:m,data:g,header:d.string,gamma:d.gamma,exposure:d.exposure,type:v}}setDataType(e){return this.type=e,this}load(e,i,s,r){function o(a,l){switch(a.type){case Qi:case ms:a.colorSpace=ki,a.minFilter=Dt,a.magFilter=Dt,a.generateMipmaps=!1,a.flipY=!0;break}i&&i(a,l)}return super.load(e,o,s,r)}}const kfe=Object.freeze(Object.defineProperty({__proto__:null,RGBELoader:EC},Symbol.toStringTag,{value:"Module"})),
|
|
5003
|
+
`;continue}if((P=R.match(x))&&(C.gamma=parseFloat(P[1])),(P=R.match(w))&&(C.exposure=parseFloat(P[1])),(P=R.match(_))&&(C.valid|=2,C.format=P[1]),(P=R.match(S))&&(C.valid|=4,C.height=parseInt(P[1],10),C.width=parseInt(P[2],10)),C.valid&2&&C.valid&4)break}return C.valid&2||i(3,"missing format specifier"),C.valid&4||i(3,"missing image size specifier"),C},a=function(b,A,x){const w=A;if(w<8||w>32767||b[0]!==2||b[1]!==2||b[2]&128)return new Uint8Array(b);w!==(b[2]<<8|b[3])&&i(3,"wrong scanline width");const _=new Uint8Array(4*A*x);_.length||i(4,"unable to allocate buffer space");let S=0,C=0;const R=4*w,P=new Uint8Array(4),T=new Uint8Array(R);let L=x;for(;L>0&&C<b.byteLength;){C+4>b.byteLength&&i(1),P[0]=b[C++],P[1]=b[C++],P[2]=b[C++],P[3]=b[C++],(P[0]!=2||P[1]!=2||(P[2]<<8|P[3])!=w)&&i(3,"bad rgbe scanline format");let k=0,G;for(;k<R&&C<b.byteLength;){G=b[C++];const W=G>128;if(W&&(G-=128),(G===0||k+G>R)&&i(3,"bad scanline data"),W){const D=b[C++];for(let F=0;F<G;F++)T[k++]=D}else T.set(b.subarray(C,C+G),k),k+=G,C+=G}const O=w;for(let W=0;W<O;W++){let D=0;_[S]=T[W+D],D+=w,_[S+1]=T[W+D],D+=w,_[S+2]=T[W+D],D+=w,_[S+3]=T[W+D],S+=4}L--}return _},l=function(b,A,x,w){const _=b[A+3],S=Math.pow(2,_-128)/255;x[w+0]=b[A+0]*S,x[w+1]=b[A+1]*S,x[w+2]=b[A+2]*S,x[w+3]=1},c=function(b,A,x,w){const _=b[A+3],S=Math.pow(2,_-128)/255;x[w+0]=Bp.toHalfFloat(Math.min(b[A+0]*S,65504)),x[w+1]=Bp.toHalfFloat(Math.min(b[A+1]*S,65504)),x[w+2]=Bp.toHalfFloat(Math.min(b[A+2]*S,65504)),x[w+3]=Bp.toHalfFloat(1)},h=new Uint8Array(e);h.pos=0;const d=o(h),u=d.width,m=d.height,f=a(h.subarray(h.pos),u,m);let g,v,y;switch(this.type){case Qi:y=f.length/4;const b=new Float32Array(y*4);for(let x=0;x<y;x++)l(f,x*4,b,x*4);g=b,v=Qi;break;case ms:y=f.length/4;const A=new Uint16Array(y*4);for(let x=0;x<y;x++)c(f,x*4,A,x*4);g=A,v=ms;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:u,height:m,data:g,header:d.string,gamma:d.gamma,exposure:d.exposure,type:v}}setDataType(e){return this.type=e,this}load(e,i,s,r){function o(a,l){switch(a.type){case Qi:case ms:a.colorSpace=ki,a.minFilter=Dt,a.magFilter=Dt,a.generateMipmaps=!1,a.flipY=!0;break}i&&i(a,l)}return super.load(e,o,s,r)}}const kfe=Object.freeze(Object.defineProperty({__proto__:null,RGBELoader:EC},Symbol.toStringTag,{value:"Module"})),V4="NEEDLE_lightmaps",mA=te("debuglightmapsextension")||te("debuglightmaps");var Su=(n=>(n[n.Lightmap=0]="Lightmap",n[n.Skybox=1]="Skybox",n[n.Reflection=2]="Reflection",n))(Su||{});class Bfe{constructor(e,i,s){p(this,"parser"),p(this,"registry"),p(this,"source"),this.parser=e,this.registry=i,this.source=s}get name(){return V4}afterRoot(e){const i=this.parser.json.extensions;if(i){const s=i[V4];if(s){const r=s.textures;return r!=null&&r.length?(mA&&console.log(s),new Promise(async(o,a)=>{const l=[];for(const h of r)if(h.pointer){mA&&console.log(h);let d=null;if(h.pointer.startsWith("/textures/"))mA&&console.log("Load texture from gltf",h.pointer),d=Kk(this.parser,h.pointer).then(u=>this.resolveTexture(h,u));else if(typeof h.pointer=="string"){mA&&console.log("Load texture from path",h.pointer);const u=Qd(this.source,h.pointer);let m;u.endsWith(".exr")?m=new pA(this.parser.options.manager):u.endsWith(".hdr")?m=new EC(this.parser.options.manager):m=new lc(this.parser.options.manager),d=m.loadAsync(u,void 0).then(f=>this.resolveTexture(h,f))}else h.pointer;d&&l.push(d)}const c=await f_(l);c!=null&&c.anyFailed&&je()&&console.error("Failed to load lightmap extension",c),o()})):null}}return null}resolveTexture(e,i){const s=i;mA&&console.log("Lightmap loaded:",s),s!=null&&s.isTexture&&(this.registry?(s.colorSpace=ki,this.registry.registerTexture(this.source,e.type,s,e.index)):console.log(Su[e.type],e.pointer,s))}}const X4=!!te("debuglightmaps");class Ofe{constructor(e){p(this,"_context"),p(this,"_lightmaps",new Map),this._context=e}clear(){this._lightmaps.clear()}registerTexture(e,i,s,r){X4&&console.log("Registering ",Su[i]+' "'+e+'"',s),this._lightmaps.has(e)||this._lightmaps.set(e,new Map);const o=this._lightmaps.get(e),a=o?.get(i)??[];a.length<r&&(a.length=r+1),a[r]=s,o?.set(i,a)}tryGetLightmap(e,i=0){return this.tryGet(e,Su.Lightmap,i)}tryGetSkybox(e){return this.tryGet(e,Su.Skybox,0)}tryGetReflection(e){return this.tryGet(e,Su.Reflection,0)}tryGet(e,i,s){if(!e)return X4&&console.warn("Missing source id"),null;const r=this._lightmaps.get(e);if(!r)return null;const o=r.get(i);return o===void 0||!(o!=null&&o.length)||o.length<=s?null:o[s]}}Mt.lights_fragment_maps=Mt.lights_fragment_maps.replace("vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );",`
|
|
5004
5004
|
vec2 lUv = vLightMapUv.xy * lightmapScaleOffset.xy + vec2(lightmapScaleOffset.z, (1. - (lightmapScaleOffset.y + lightmapScaleOffset.w)));
|
|
5005
5005
|
vec4 lightMapTexel = texture2D( lightMap, lUv);
|
|
5006
5006
|
// The range of RGBM lightmaps goes from 0 to 34.49 (5^2.2) in linear space, and from 0 to 5 in gamma space.
|
|
@@ -5029,7 +5029,7 @@ TEX `+s.texture_lod;if(wB=="density"&&(A+=`
|
|
|
5029
5029
|
`+(b/l.lastScreenCoverage).toFixed(0)+` dens
|
|
5030
5030
|
`+(l.lastScreenCoverage*100).toFixed(1)+`% cov
|
|
5031
5031
|
`+(l.lastCentrality*100).toFixed(1)+`% centr
|
|
5032
|
-
`+(TC.min.x.toFixed(2)+"-"+TC.max.x.toFixed(2)+"x"+TC.min.y.toFixed(2)+"-"+TC.max.y.toFixed(2))+" scr"),l.lastScreenCoverage>.1){const x=e,w=x.worldForward,_=x.worldPosition,S=ht(w).multiplyScalar(m*.7).add(u),C=S.distanceTo(_),R=f[Math.min(f.length-1,Math.max(0,c))]+"88",P=this.context.domHeight>0?screen.height/this.context.domHeight:1,T=e.isPerspectiveCamera?Math.tan(e.fov*Math.PI/180/2):1;ft.DrawLabel(S,A,C*.012*P*T,void 0,16777215,R)}}}}}const Gfe=te("debugplayerview");var Cu=(n=>(n.Browser="browser",n.Headset="headset",n.Handheld="handheld",n))(Cu||{});class
|
|
5032
|
+
`+(TC.min.x.toFixed(2)+"-"+TC.max.x.toFixed(2)+"x"+TC.min.y.toFixed(2)+"-"+TC.max.y.toFixed(2))+" scr"),l.lastScreenCoverage>.1){const x=e,w=x.worldForward,_=x.worldPosition,S=ht(w).multiplyScalar(m*.7).add(u),C=S.distanceTo(_),R=f[Math.min(f.length-1,Math.max(0,c))]+"88",P=this.context.domHeight>0?screen.height/this.context.domHeight:1,T=e.isPerspectiveCamera?Math.tan(e.fov*Math.PI/180/2):1;ft.DrawLabel(S,A,C*.012*P*T,void 0,16777215,R)}}}}}const Gfe=te("debugplayerview");var Cu=(n=>(n.Browser="browser",n.Headset="headset",n.Handheld="handheld",n))(Cu||{});class W4{constructor(e,i){p(this,"userId"),p(this,"context"),p(this,"viewDevice","browser"),p(this,"removed",!1),p(this,"_object"),this.userId=e,this.context=i}get currentObject(){return this._object}set currentObject(e){this._object=e}get isConnected(){return this.context.connection.userIsInRoom(this.userId)}}class H4{constructor(e){p(this,"context"),p(this,"playerViews",new Map),this.context=e}setPlayerView(e,i,s){let r=this.playerViews.get(e);r||(r=new W4(e,this.context),this.playerViews.set(e,r)),r.viewDevice=s,r.currentObject=i,r.removed=!1}getPlayerView(e){if(!!e){if(!this.context.connection.userIsInRoom(e)){this.playerViews.delete(e);return}return this.playerViews.get(e)}}removePlayerView(e,i){const s=this.playerViews.get(e);s?.viewDevice===i&&(Gfe&&console.log("REMOVE",e),s.removed=!0,this.playerViews.delete(e))}}new Js;const fA=new Uint8Array(4);fA[0]=255,fA[1]=255,fA[2]=255,fA[3]=255;const Nfe=new Rr(fA,1,1,wi);function _B(n,e=1){const i="alpha"in n,s=e*e,r=new Uint8Array(4*s),o=Math.floor(n.r*255),a=Math.floor(n.g*255),l=Math.floor(n.b*255);for(let h=0;h<s;h++){const d=h*4;r[d+0]=o,r[d+1]=a,r[d+2]=l,i?r[d+3]=Math.floor(n.alpha*255):r[d+3]=255}const c=new Rr(r,e,e);return c.needsUpdate=!0,c}function Ffe(n,e,i,s=1,r=3){const o=s*r,a=[n,e,i],l=a.length,c=new Uint8Array(4*l*o),h=new Ae;for(let u=0;u<r;u++){const m=Math.floor(u/r*l),f=et.clamp(m+1,0,l-1),g=a[m],v=a[f],y=u/r*l%1;h.lerpColors(g,v,y);const b=Math.floor(h.r*255),A=Math.floor(h.g*255),x=Math.floor(h.b*255);for(let w=0;w<s;w++){const _=(u*s+w)*4;c[_+0]=b,c[_+1]=A,c[_+2]=x,c[_+3]=255}}const d=new Rr(c,s,r);return d.needsUpdate=!0,d}function IC(n,e){const i=n.elements;e||(e=[]),e.length=0;for(let s=0;s<16;s+=4){const r=i[s],o=i[s+1],a=i[s+2],l=i[s+3],c=new Ke(r,o,a,l);e.push(c)}return e}const SB=[],j4=[];function zfe(n,e){if(SB.length===0)for(let i=0;i<27;i++)SB.push(0);e||(e=SB);for(let i=0;i<27;i++)j4[i]=e[i];e=j4,n.unity_SHAr={value:new Ke(e[9],e[3],e[6],e[0])},n.unity_SHBr={value:new Ke(e[12],e[15],e[18],e[21])},n.unity_SHAg={value:new Ke(e[10],e[4],e[7],e[1])},n.unity_SHBg={value:new Ke(e[13],e[16],e[19],e[22])},n.unity_SHAb={value:new Ke(e[11],e[5],e[8],e[2])},n.unity_SHBb={value:new Ke(e[14],e[17],e[20],e[23])},n.unity_SHC={value:new Ke(e[24],e[25],e[26],1)}}class Ufe{constructor(e,i,s){p(this,"vertexShader"),p(this,"fragmentShader"),p(this,"technique"),this.vertexShader=e,this.fragmentShader=i,this.technique=s}}async function Vfe(n,e){if(!n)return console.error("Can not find technique: no shader data"),null;const i=n.programs[e],s=i.vertexShader,r=i.fragmentShader;if(s!==void 0&&r!==void 0){const o=n.shaders[s],a=n.shaders[r];if(o.uri&&a.uri||o.code&&a.code){if(!o.code&&o.uri&&await Q4(o),!a.code&&a.uri&&await Q4(a),!o.code||!a.code)return null;const l=n.techniques[e];return new Ufe(o.code,a.code,l)}}return console.error("Shader technique not found",e),null}async function Q4(n){const e=n.uri;if(e)if(e.endsWith(".glsl")){const i=await new Js().loadAsync(e);n.code=i.toString()}else n.code=Xfe(n.uri)}function Xfe(n){return decodeURIComponent(Array.prototype.map.call(atob(n),function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)}).join(""))}const Fl=te("debugenvlight");var A0=(n=>(n[n.Skybox=0]="Skybox",n[n.Trilight=1]="Trilight",n[n.Flat=3]="Flat",n[n.Custom=4]="Custom",n))(A0||{}),LC=(n=>(n[n.Skybox=0]="Skybox",n[n.Custom=1]="Custom",n))(LC||{});class Z4{constructor(e){p(this,"context"),p(this,"_currentLightSettingsId"),p(this,"_sceneLightSettings"),p(this,"_timevec4",new Ke),p(this,"__currentReflectionId",null),p(this,"_lighting",{}),this.context=e,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const e=this.context.time;this._timevec4.x=e.time,this._timevec4.y=Math.sin(e.time),this._timevec4.z=Math.cos(e.time),this._timevec4.w=e.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const e=this._sceneLightSettings.get(this._currentLightSettingsId);return e?e.ambientIntensity:1}get sceneLightSettings(){var e;return(e=this._sceneLightSettings)==null?void 0:e.values()}enable(e){var i;e instanceof ei&&(e=e.url);const s=(i=this._sceneLightSettings)==null?void 0:i.get(e);return s?(Fl&&console.log("Enable scene light settings",e,s),e!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=e,s.enabled=!0,!0):(Fl&&console.warn("No light settings found for",e),!1)}disable(e){var i;if(e instanceof ei&&(e=e.url),e==null)return!1;const s=(i=this._sceneLightSettings)==null?void 0:i.get(e);return s?(Fl&&console.log("Disable scene light settings",e,s),s.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const e=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),e}return null}internalRegisterSceneLightSettings(e){const i=e.sourceId;if(!i){console.error("Missing source id for scene light settings, can not register:",e);return}Fl&&console.log("Register "+e?.sourceId+" lighting",e),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(i,e)}internalUnregisterSceneLightSettings(e){const i=e.sourceId;if(!i){console.error("Missing source id for scene light settings, can not unregister:",e);return}Fl&&console.log("Unregister "+e?.sourceId+" lighting",e),this._sceneLightSettings&&this._sceneLightSettings.delete(i)}internalRegisterReflection(e,i){Fl&&console.log("Register reflection",e,i);const s=new Y4(this.context,i,1);this._lighting[e]=s}internalGetReflection(e){return this._lighting[e]}internalEnableReflection(e){var i;this.__currentReflectionId=e;const s=(i=this._sceneLightSettings)==null?void 0:i.get(e);switch(Fl&&console.log("Enable reflection",e,s?A0[s.ambientMode]:"Unknown ambient mode",s),s?.ambientMode){case 0:case 4:const r=this.internalGetReflection(e);if(r&&r.Source){Fl&&console.log("Setting environment reflection",r);const o=this.context.scene,a=r.Source;a.mapping=Kr,o.environment=a;return}else Fl&&console.warn("Could not find reflection for source",e);break}if(s?.environmentReflectionSource===1)switch(s?.ambientMode){case 1:if(s.ambientTrilight){const r=s.ambientTrilight,o=Ffe(r[0],r[1],r[2],64,64);o.colorSpace=vt,o.mapping=Kr,this.context.scene.environment=o}else console.error("Missing ambient trilight",s.sourceId);return;case 3:if(s.ambientLight){const r=_B(s.ambientLight,64);r.colorSpace=vt,r.mapping=Kr,this.context.scene.environment=r}else console.error("Missing ambientlight",s.sourceId);return;default:return}}internalDisableReflection(e){if(e&&e!==this.__currentReflectionId){Fl&&console.log("Not disabling reflection for",e,"because it is not the current light settings id",this.__currentReflectionId);return}Fl&&console.log("Disable reflection",e);const i=this.context.scene;i.environment=null}}class Y4{constructor(e,i,s=1){p(this,"_source"),this._source=i,i.mapping=Kr}get Source(){return this._source}}const K4=te("timescale");let CB=1;typeof K4=="number"&&(CB=K4);class J4{constructor(){p(this,"_time",0),p(this,"_deltaTime",0),p(this,"_deltaTimeUnscaled",0),p(this,"timeScale",1),p(this,"_frame",0),p(this,"clock",new sI),p(this,"_smoothedFps",0),p(this,"_smoothedDeltaTime",0),p(this,"_fpsSamples",[]),p(this,"_fpsSampleIndex",0),typeof CB=="number"&&(this.timeScale=CB)}get time(){return this._time}set time(e){this._time=e}get deltaTime(){return this._deltaTime}set deltaTime(e){this._deltaTime=e}get deltaTimeUnscaled(){return this._deltaTimeUnscaled}get frame(){return this._frame}set frame(e){this._frame=e}get frameCount(){return this.frame}get realtimeSinceStartup(){return this.clock.elapsedTime}get smoothedFps(){return this._smoothedFps}get smoothedDeltaTime(){return 1/this._smoothedFps}update(){this.deltaTime=this.clock.getDelta(),this.deltaTime=Math.min(.1,this.deltaTime),this._deltaTimeUnscaled=this.deltaTime,this.deltaTime<=0&&(this.deltaTime=1e-12),this.deltaTime*=this.timeScale,this.frame+=1,this.time+=this.deltaTime,this._fpsSamples.length<60?this._fpsSamples.push(this.deltaTime):this._fpsSamples[this._fpsSampleIndex++%60]=this.deltaTime;let e=0;for(let i=0;i<this._fpsSamples.length;i++)e+=this._fpsSamples[i];this._smoothedDeltaTime=e/this._fpsSamples.length,this._smoothedFps=1/this._smoothedDeltaTime}}let q4=!1;function $4(n){q4||(q4=!0,Wfe(),Hfe())}$4();function Wfe(){const n=`
|
|
5033
5033
|
float startCompression = 0.8;
|
|
5034
5034
|
float desaturation = 0.5;
|
|
5035
5035
|
// Patched tonemapping function
|
|
@@ -5576,7 +5576,7 @@ vec3 AgXToneMapping( vec3 color ) {
|
|
|
5576
5576
|
</div>
|
|
5577
5577
|
`;const l=this.attachShadow({mode:"open"});tj(),kC(TB,{loadedCallback:()=>{this.handleSizeChange()}}),kC(TB,{element:l});const c=a.content.cloneNode(!0);l?.appendChild(c),this.root=l.querySelector("#root"),this.wrapper=(n=this.root)==null?void 0:n.querySelector(".wrapper"),this.options=(e=this.root)==null?void 0:e.querySelector(".options"),this.logoContainer=(i=this.root)==null?void 0:i.querySelector(".logo"),this.compactMenuButton=(s=this.root)==null?void 0:s.querySelector(".compact-menu-button"),this.compactMenuButton.append(nr("more_vert")),this.foldout=(r=this.root)==null?void 0:r.querySelector(".foldout"),(o=this.root)==null||o.appendChild(this.wrapper),this.wrapper.classList.add("wrapper");const h=ij.create();h.style.minHeight="1rem",this.logoContainer.append(h),this.logoContainer.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")});try{tge(g=>{if(g==!0&&zl()&&!sj){let v=this._userRequestedLogoVisible;v===void 0&&(v=!1),If(this,DC,IB).call(this,v)}})}catch(g){console.error("[Needle Menu] License check failed.",g)}this.compactMenuButton.addEventListener("click",g=>{g.preventDefault(),this.root.classList.toggle("open")});let d=this._context;setTimeout(()=>d=this._context);let u=0;const m=(g,v)=>{var y,b,A;gA&&console.log("Set menu visible",v),d!=null&&d.isInAR&&d.arOverlayElement?g!=d.arOverlayElement&&d.arOverlayElement.appendChild(this):this.parentNode!=((y=this._domElement)==null?void 0:y.shadowRoot)&&((A=(b=this._domElement)==null?void 0:b.shadowRoot)==null||A.appendChild(this)),this.style.display=v?"flex":"none",this.style.visibility="visible",this.style.opacity="1"};let f=!1;new MutationObserver(g=>{var v;if(!f)try{f=!0,this.onChangeDetected(g);const y=this==null?void 0:this.parentNode;if((this.style.display!="flex"||this.style.visibility!="visible"||this.style.opacity!="1"||y!=((v=this._domElement)==null?void 0:v.shadowRoot))&&!zl()){const b=u++;io()&&this._userRequestedMenuVisible===!1?(b===0&&m(y,this._userRequestedMenuVisible),b===1&&console.warn("Needle Menu Warning: You need a PRO license to hide the Needle Engine menu \u2192 The menu will be visible in your deployed website if you don't have a PRO license. See https://needle.tools/pricing for details.")):b===0?m(y,!0):setTimeout(()=>m(y,!0),5)}}finally{f=!1}}).observe(this.root,{childList:!0,subtree:!0,attributes:!0}),gA&&this.___insertDebugOptions()}static create(){return document.createElement(x0,{is:x0})}static getOrCreate(n,e){let i=n.querySelector(x0);return!i&&n.shadowRoot&&(i=n.shadowRoot.querySelector(x0)),i||(i=rj.create(),n.shadowRoot?n.shadowRoot.appendChild(i):n.appendChild(i)),i._domElement=n,i._context=e,i}connectedCallback(){window.addEventListener("resize",this.handleSizeChange),this.handleMenuVisible(),this._sizeChangeInterval=setInterval(()=>this.handleSizeChange(void 0,!0),5e3),setTimeout(()=>{var n,e;(n=this._domElement)==null||n.addEventListener("resize",this.handleSizeChange),(e=this._domElement)==null||e.addEventListener("click",bi(this,OC))},1)}disconnectedCallback(){var n,e;window.removeEventListener("resize",this.handleSizeChange),clearInterval(this._sizeChangeInterval),(n=this._domElement)==null||n.removeEventListener("resize",this.handleSizeChange),(e=this._context)==null||e.domElement.removeEventListener("click",bi(this,OC))}showNeedleLogo(n){this._userRequestedLogoVisible=n,!(!n&&(!zl()||sj)&&(console.warn("Needle Menu: You need a PRO license to hide the Needle Engine logo."),!io()))&&If(this,DC,IB).call(this,n)}setPosition(n){if(n!=="top"&&n!=="bottom")return console.error("NeedleMenu.setPosition: invalid position",n);this.root.classList.remove("top","bottom"),this.root.classList.add(n)}setVisible(n){this._userRequestedMenuVisible=n,this.style.display=n?"flex":"none"}closeFoldout(){this.root.classList.remove("open")}append(...n){for(const e of n)if(typeof e=="string"){const i=document.createTextNode(e);this.options.appendChild(i)}else this.options.appendChild(e)}appendChild(n){var e;if(!(n instanceof Node)){const i=document.createElement("button");if(i.textContent=n.label,i.onclick=n.onClick,i.setAttribute("priority",((e=n.priority)==null?void 0:e.toString())??"0"),n.title&&(i.title=n.title),n.icon){const s=nr(n.icon);n.iconSide==="right"?i.appendChild(s):i.prepend(s)}n.class&&i.classList.add(n.class),n=i}return this.options.appendChild(n)}prepend(...n){for(const e of n)if(typeof e=="string"){const i=document.createTextNode(e);this.options.prepend(i)}else this.options.prepend(e)}onChangeDetected(n){if(!this._isHandlingChange){this._isHandlingChange=!0;try{this.handleMenuVisible();for(const e of n)e.target==this.options&&this.onOptionsChildrenChanged(e)}finally{this._isHandlingChange=!1}}}onOptionsChildrenChanged(n){if(this.root.classList.toggle("has-options",this.hasAnyVisibleOptions),this.root.classList.toggle("has-no-options",!this.hasAnyVisibleOptions),this.handleSizeChange(void 0,!0),n.type==="childList"&&n.addedNodes.length>0){const e=Array.from(this.options.children);e.sort((s,r)=>{const o=parseInt(s.getAttribute("priority")||"0"),a=parseInt(r.getAttribute("priority")||"0");return o-a});let i=!1;for(let s=0;s<e.length;s++){const r=this.options.children[s],o=e[s];if(r!==o){i=!0;break}}if(i)for(const s of e)this.options.appendChild(s)}}handleMenuVisible(){gA&&console.log("Update VisibleState: Any Content?",this.hasAnyContent),this.hasAnyContent?this.root.style.display="":this.root.style.display="none",this.root.classList.toggle("has-options",this.hasAnyVisibleOptions),this.root.classList.toggle("has-no-options",!this.hasAnyVisibleOptions)}get hasAnyContent(){return!!(this.logoContainer.style.display!="none"||this.hasAnyVisibleOptions)}get hasAnyVisibleOptions(){for(let n=0;n<this.options.children.length;n++){const e=this.options.children[n];if(e.tagName==="SLOT"){const i=e.assignedNodes();for(const s of i)if(s instanceof HTMLElement&&s.style.display!="none")return!0}else if(e.style.display!="none")return!0}return!1}___insertDebugOptions(){window.addEventListener("keydown",i=>{i.key==="p"&&this.setPosition(this.root.classList.contains("top")?"bottom":"top")});const n=document.createElement("button");n.textContent="Hide Buttons",n.onclick=()=>{const i=new Array(this.options.children.length);for(let s=0;s<this.options.children.length;s++)i[s]=this.options.children[s];for(const s of i)this.options.removeChild(s);setTimeout(()=>{for(const s of i)this.options.appendChild(s)},1e3)},this.appendChild(n);const e=document.createElement("button");e.textContent="Toggle Logo",e.addEventListener("click",()=>{this.logoContainer.style.display=this.logoContainer.style.display==="none"?"":"none"}),this.appendChild(e)}};let oj=rj;OC=new WeakMap,DC=new WeakSet,IB=function(n){this.logoContainer.style.display="",this.logoContainer.style.opacity="1",this.logoContainer.style.visibility="visible",n?(this.root.classList.remove("logo-hidden"),this.root.classList.add("logo-visible")):(this.root.classList.remove("logo-visible"),this.root.classList.add("logo-hidden"))},customElements.get(x0)||customElements.define(x0,oj);const ws=te("debugcontext"),Yfe=te("stats"),Kfe=te("debugactive"),Jfe=te("debugframerate"),qfe=te("debugcoroutine"),$fe={};class ege{constructor(){p(this,"name"),p(this,"alias"),p(this,"hash"),p(this,"runInBackground"),p(this,"domElement"),p(this,"renderer"),p(this,"camera"),p(this,"scene")}}var Ji=(n=>(n[n.Start=-1]="Start",n[n.EarlyUpdate=0]="EarlyUpdate",n[n.Update=1]="Update",n[n.LateUpdate=2]="LateUpdate",n[n.OnBeforeRender=3]="OnBeforeRender",n[n.OnAfterRender=4]="OnAfterRender",n[n.PrePhysicsStep=9]="PrePhysicsStep",n[n.PostPhysicsStep=10]="PostPhysicsStep",n[n.Undefined=-1]="Undefined",n))(Ji||{});function GC(n,e){if(!n)return;if(!n.isComponent){(je()||ws)&&console.error(`Registered script is not a Needle Engine component.
|
|
5578
5578
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
5579
|
-
`,n);return}e||(e=Pt.Current,ws&&console.warn("> Registering component without context"));const i=e?.new_scripts;i.includes(n)||i.push(n)}const on=class{constructor(n){p(this,"name"),p(this,"alias"),p(this,"isManagedExternally",!1),p(this,"isPaused",!1),p(this,"runInBackground",!1),p(this,"targetFrameRate"),p(this,"physicsSteps",1),p(this,"hash"),p(this,"domElement"),p(this,"_resolutionScaleFactor",1),p(this,"_boundingClientRectFrame",-1),p(this,"_boundingClientRect",null),p(this,"_domX"),p(this,"_domY"),p(this,"xr",null),p(this,"_xrFrame",null),p(this,"_currentFrameEvent",-1),p(this,"scene"),p(this,"renderer"),p(this,"composer",null),p(this,"scripts",[]),p(this,"scripts_pausedChanged",[]),p(this,"scripts_earlyUpdate",[]),p(this,"scripts_update",[]),p(this,"scripts_lateUpdate",[]),p(this,"scripts_onBeforeRender",[]),p(this,"scripts_onAfterRender",[]),p(this,"scripts_WithCorroutines",[]),p(this,"scripts_immersive_vr",[]),p(this,"scripts_immersive_ar",[]),p(this,"coroutines",{}),p(this,"post_setup_callbacks",[]),p(this,"pre_update_callbacks",[]),p(this,"pre_render_callbacks",[]),p(this,"post_render_callbacks",[]),p(this,"pre_update_oneshot_callbacks",[]),p(this,"new_scripts",[]),p(this,"new_script_start",[]),p(this,"new_scripts_pre_setup_callbacks",[]),p(this,"new_scripts_post_setup_callbacks",[]),p(this,"new_scripts_xr",[]),p(this,"mainCameraComponent"),p(this,"_mainCamera",null),p(this,"_fallbackCamera",null),p(this,"application"),p(this,"animations"),p(this,"time"),p(this,"input"),p(this,"physics"),p(this,"connection"),p(this,"assets"),p(this,"mainLight",null),p(this,"sceneLighting"),p(this,"addressables"),p(this,"lightmaps"),p(this,"players"),p(this,"lodsManager"),p(this,"menu"),p(this,"_sizeChanged",!1),p(this,"_isCreated",!1),p(this,"_isCreating",!1),p(this,"_isVisible",!1),p(this,"_stats",Yfe?new Kle:null),p(this,"_intersectionObserver",null),p(this,"_disposeCallbacks",[]),p(this,"maxRenderResolution"),p(this,"_originalCreationArgs"),p(this,"onUnhandledRejection",s=>{this.onError(s.reason)}),p(this,"_cameraStack",[]),p(this,"_onBeforeRenderListeners",new Map),p(this,"_onAfterRenderListeners",new Map),p(this,"_requireDepthTexture",!1),p(this,"_requireColorTexture",!1),p(this,"_renderTarget"),p(this,"_isRendering",!1),p(this,"_createId",0),p(this,"_renderlooperrors",0),p(this,"_lastTimestamp",0),p(this,"_accumulatedTime",0),p(this,"_dispatchReadyAfterFrame",!1),p(this,"_wasPaused",!1),this.name=n?.name||"",this.alias=n?.alias,this.domElement=n?.domElement||document.body,this.hash=n?.hash,n!=null&&n.renderer&&(this.renderer=n.renderer,this.isManagedExternally=!0),n?.runInBackground!==void 0&&(this.runInBackground=n.runInBackground),n!=null&&n.scene?this.scene=n.scene:this.scene=new Is,n!=null&&n.camera&&(this._mainCamera=n.camera),this.application=new Xh(this),this.time=new J9,this.input=new bW(this),this.physics=new HS(this),this.connection=new ZH(this),this.assets=new v4,this.sceneLighting=new Z9(this),this.addressables=new S9(this),this.lightmaps=new Ofe(this),this.players=new H9(this),this.menu=new Zfe(this),this.lodsManager=new Dfe(this),this.animations=new pfe(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const i=new ResizeObserver(s=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()}),xi.register(this)}static get DefaultTargetFrameRate(){return on._defaultTargetFramerate.value}static set DefaultTargetFrameRate(n){on._defaultTargetFramerate.value=n}static get DefaultWebGLRendererParameters(){return on._defaultWebglRendererParameters}get version(){return _l}static get Current(){return xi.Current}static set Current(n){xi.Current=n}appendHTMLElement(n){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(n):this.domElement.appendChild(n)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(n){if(n!==this._resolutionScaleFactor&&typeof n=="number"){if(n<=0){console.error("Invalid resolution scale factor",n);return}this._resolutionScaleFactor=n,this.updateSize()}}calculateBoundingClientRect(){if(this.xr){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var n,e;return((e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var n;return(n=this.xr)==null?void 0:n.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var n,e;return(e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var n,e;return this.renderer.xr.isPresenting?(e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const n=this.domElement;return typeof n.getAROverlayContainer=="function"?n.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._mainCamera)return this._mainCamera;if(this.mainCameraComponent){const n=this.mainCameraComponent;return n.threeCamera||n.buildCamera(),n.threeCamera}return this._fallbackCamera||(this._fallbackCamera=new Lt(75,this.domWidth/this.domHeight,.1,1e3)),this._fallbackCamera}set mainCamera(n){this._mainCamera=n}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(n){var e,i,s;if((e=this.renderer)==null||e.dispose(),n={...on.DefaultWebGLRendererParameters,...n},!n.canvas){const r=(s=(i=this.domElement)==null?void 0:i.shadowRoot)==null?void 0:s.querySelector("canvas");r&&(n.canvas=r,ws&&console.log("Using canvas from shadow root",r))}ws&&console.log("Using Renderer Parameters:",n,this.domElement),this.renderer=new vh(n),this.renderer.debug.checkShaderErrors=je()||te("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=Yr,this.renderer.setClearColor(new Ae("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=JT,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=vt,this.lodsManager.setRenderer(this.renderer),this.input.bindEvents()}internalOnUpdateVisible(){var n,e;(n=this._intersectionObserver)==null||n.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(n=!1){var e,i,s;if(n||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const r=this.resolutionScaleFactor;let o=this.domWidth*r,a=this.domHeight*r;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),o=Math.min(this.maxRenderResolution.x,o),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),a=Math.min(this.maxRenderResolution.y,a));const l=this.mainCamera;this.updateAspect(l),this.renderer.setSize(o,a,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((i=this.composer.setSize)==null||i.call(this.composer,o,a),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((s=this.composer.setPixelRatio)==null||s.call(this.composer,window.devicePixelRatio)))}}updateAspect(n,e,i){if(!n)return;e===void 0&&(e=this.domWidth),i===void 0&&(i=this.domHeight);const s=n.aspect;n.aspect=e/i,s!==n.aspect&&n.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(n){return this.create(n)}async create(n){try{this._isCreating=!0,n!==this._originalCreationArgs&&(this._originalCreationArgs=Vv(n)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(n);return this._isCreated=e,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}onError(n){this.domElement.dispatchEvent(new CustomEvent("error",{detail:n}))}clear(){var n,e,i,s;xi.dispatchCallback(_i.ContextClearing,this),yc(this,_i.ContextClearing),oa(this.scene,!0,!0),this.scene=new Is,(n=this.addressables)==null||n.dispose(),(e=this.lightmaps)==null||e.clear(),(s=(i=this.physics)==null?void 0:i.engine)==null||s.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),xi.dispatchCallback(_i.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var n,e;on.Current=this,xi.dispatchCallback(_i.ContextDestroying,this),yc(this,_i.ContextDestroying),this.clear(),(n=this.renderer)==null||n.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(ws&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy(),this.animations.onDestroy();for(const i of this._disposeCallbacks)try{i()}catch(s){console.error("Error in on dispose callback:",s,i)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,xi.dispatchCallback(_i.ContextDestroyed,this),yc(this,_i.ContextDestroyed),xi.unregister(this),on.Current===this&&(on.Current=null)}registerCoroutineUpdate(n,e,i){return typeof e?.next!="function"?(console.error("Registered invalid coroutine function from "+n.name+`
|
|
5579
|
+
`,n);return}e||(e=Pt.Current,ws&&console.warn("> Registering component without context"));const i=e?.new_scripts;i.includes(n)||i.push(n)}const on=class{constructor(n){p(this,"name"),p(this,"alias"),p(this,"isManagedExternally",!1),p(this,"isPaused",!1),p(this,"runInBackground",!1),p(this,"targetFrameRate"),p(this,"physicsSteps",1),p(this,"hash"),p(this,"domElement"),p(this,"_resolutionScaleFactor",1),p(this,"_boundingClientRectFrame",-1),p(this,"_boundingClientRect",null),p(this,"_domX"),p(this,"_domY"),p(this,"xr",null),p(this,"_xrFrame",null),p(this,"_currentFrameEvent",-1),p(this,"scene"),p(this,"renderer"),p(this,"composer",null),p(this,"scripts",[]),p(this,"scripts_pausedChanged",[]),p(this,"scripts_earlyUpdate",[]),p(this,"scripts_update",[]),p(this,"scripts_lateUpdate",[]),p(this,"scripts_onBeforeRender",[]),p(this,"scripts_onAfterRender",[]),p(this,"scripts_WithCorroutines",[]),p(this,"scripts_immersive_vr",[]),p(this,"scripts_immersive_ar",[]),p(this,"coroutines",{}),p(this,"post_setup_callbacks",[]),p(this,"pre_update_callbacks",[]),p(this,"pre_render_callbacks",[]),p(this,"post_render_callbacks",[]),p(this,"pre_update_oneshot_callbacks",[]),p(this,"new_scripts",[]),p(this,"new_script_start",[]),p(this,"new_scripts_pre_setup_callbacks",[]),p(this,"new_scripts_post_setup_callbacks",[]),p(this,"new_scripts_xr",[]),p(this,"mainCameraComponent"),p(this,"_mainCamera",null),p(this,"_fallbackCamera",null),p(this,"application"),p(this,"animations"),p(this,"time"),p(this,"input"),p(this,"physics"),p(this,"connection"),p(this,"assets"),p(this,"mainLight",null),p(this,"sceneLighting"),p(this,"addressables"),p(this,"lightmaps"),p(this,"players"),p(this,"lodsManager"),p(this,"menu"),p(this,"_sizeChanged",!1),p(this,"_isCreated",!1),p(this,"_isCreating",!1),p(this,"_isVisible",!1),p(this,"_stats",Yfe?new Kle:null),p(this,"_intersectionObserver",null),p(this,"_disposeCallbacks",[]),p(this,"maxRenderResolution"),p(this,"_originalCreationArgs"),p(this,"onUnhandledRejection",s=>{this.onError(s.reason)}),p(this,"_cameraStack",[]),p(this,"_onBeforeRenderListeners",new Map),p(this,"_onAfterRenderListeners",new Map),p(this,"_requireDepthTexture",!1),p(this,"_requireColorTexture",!1),p(this,"_renderTarget"),p(this,"_isRendering",!1),p(this,"_createId",0),p(this,"_renderlooperrors",0),p(this,"_lastTimestamp",0),p(this,"_accumulatedTime",0),p(this,"_dispatchReadyAfterFrame",!1),p(this,"_wasPaused",!1),this.name=n?.name||"",this.alias=n?.alias,this.domElement=n?.domElement||document.body,this.hash=n?.hash,n!=null&&n.renderer&&(this.renderer=n.renderer,this.isManagedExternally=!0),n?.runInBackground!==void 0&&(this.runInBackground=n.runInBackground),n!=null&&n.scene?this.scene=n.scene:this.scene=new Is,n!=null&&n.camera&&(this._mainCamera=n.camera),this.application=new Xh(this),this.time=new J4,this.input=new bW(this),this.physics=new HS(this),this.connection=new ZH(this),this.assets=new v9,this.sceneLighting=new Z4(this),this.addressables=new S4(this),this.lightmaps=new Ofe(this),this.players=new H4(this),this.menu=new Zfe(this),this.lodsManager=new Dfe(this),this.animations=new pfe(this);const e=()=>this._sizeChanged=!0;window.addEventListener("resize",e),this._disposeCallbacks.push(()=>window.removeEventListener("resize",e));const i=new ResizeObserver(s=>this._sizeChanged=!0);i.observe(this.domElement),this._disposeCallbacks.push(()=>i.disconnect()),this._intersectionObserver=new IntersectionObserver(s=>{this._isVisible=s[0].isIntersecting}),this._disposeCallbacks.push(()=>{var s;return(s=this._intersectionObserver)==null?void 0:s.disconnect()}),xi.register(this)}static get DefaultTargetFrameRate(){return on._defaultTargetFramerate.value}static set DefaultTargetFrameRate(n){on._defaultTargetFramerate.value=n}static get DefaultWebGLRendererParameters(){return on._defaultWebglRendererParameters}get version(){return _l}static get Current(){return xi.Current}static set Current(n){xi.Current=n}appendHTMLElement(n){return this.domElement.shadowRoot?this.domElement.shadowRoot.appendChild(n):this.domElement.appendChild(n)}get resolutionScaleFactor(){return this._resolutionScaleFactor}set resolutionScaleFactor(n){if(n!==this._resolutionScaleFactor&&typeof n=="number"){if(n<=0){console.error("Invalid resolution scale factor",n);return}this._resolutionScaleFactor=n,this.updateSize()}}calculateBoundingClientRect(){if(this.xr){this._domX=0,this._domY=0;return}this._boundingClientRectFrame!==this.time.frame&&(this._boundingClientRectFrame=this.time.frame,this._boundingClientRect=this.domElement.getBoundingClientRect(),this._domX=this._boundingClientRect.x,this._domY=this._boundingClientRect.y)}get domWidth(){return this.isInAR?window.innerWidth:this.domElement.clientWidth}get domHeight(){return this.isInAR?window.innerHeight:this.domElement.clientHeight}get domX(){return this.calculateBoundingClientRect(),this._domX}get domY(){return this.calculateBoundingClientRect(),this._domY}get isInXR(){var n,e;return((e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.isPresenting)||!1}get xrSessionMode(){var n;return(n=this.xr)==null?void 0:n.mode}get isInVR(){return this.xrSessionMode==="immersive-vr"}get isInAR(){return this.xrSessionMode==="immersive-ar"}get isInPassThrough(){return this.xr?this.xr.isPassThrough:!1}get xrSession(){var n,e;return(e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.getSession()}get xrFrame(){return this._xrFrame}get xrCamera(){var n,e;return this.renderer.xr.isPresenting?(e=(n=this.renderer)==null?void 0:n.xr)==null?void 0:e.getCamera():void 0}get arOverlayElement(){const n=this.domElement;return typeof n.getAROverlayContainer=="function"?n.getAROverlayContainer():this.domElement}get currentFrameEvent(){return this._currentFrameEvent}get mainCamera(){if(this._mainCamera)return this._mainCamera;if(this.mainCameraComponent){const n=this.mainCameraComponent;return n.threeCamera||n.buildCamera(),n.threeCamera}return this._fallbackCamera||(this._fallbackCamera=new Lt(75,this.domWidth/this.domHeight,.1,1e3)),this._fallbackCamera}set mainCamera(n){this._mainCamera=n}get rendererData(){return this.sceneLighting}get isCreated(){return this._isCreated}createNewRenderer(n){var e,i,s;if((e=this.renderer)==null||e.dispose(),n={...on.DefaultWebGLRendererParameters,...n},!n.canvas){const r=(s=(i=this.domElement)==null?void 0:i.shadowRoot)==null?void 0:s.querySelector("canvas");r&&(n.canvas=r,ws&&console.log("Using canvas from shadow root",r))}ws&&console.log("Using Renderer Parameters:",n,this.domElement),this.renderer=new vh(n),this.renderer.debug.checkShaderErrors=je()||te("checkshadererrors")===!0,this.renderer.toneMappingExposure=1,this.renderer.toneMapping=Yr,this.renderer.setClearColor(new Ae("lightgrey"),0),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=JT,this.renderer.setSize(this.domWidth,this.domHeight),this.renderer.outputColorSpace=vt,this.lodsManager.setRenderer(this.renderer),this.input.bindEvents()}internalOnUpdateVisible(){var n,e;(n=this._intersectionObserver)==null||n.disconnect(),(e=this._intersectionObserver)==null||e.observe(this.domElement)}requestSizeUpdate(){this._sizeChanged=!0}updateSize(n=!1){var e,i,s;if(n||!this.isManagedExternally&&((e=this.renderer.xr)==null?void 0:e.isPresenting)===!1){this._sizeChanged=!1;const r=this.resolutionScaleFactor;let o=this.domWidth*r,a=this.domHeight*r;this.maxRenderResolution&&(this.maxRenderResolution.x=Math.max(1,this.maxRenderResolution.x),o=Math.min(this.maxRenderResolution.x,o),this.maxRenderResolution.y=Math.max(1,this.maxRenderResolution.y),a=Math.min(this.maxRenderResolution.y,a));const l=this.mainCamera;this.updateAspect(l),this.renderer.setSize(o,a,!0),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.composer&&((i=this.composer.setSize)==null||i.call(this.composer,o,a),"setPixelRatio"in this.composer&&typeof this.composer.setPixelRatio=="function"&&((s=this.composer.setPixelRatio)==null||s.call(this.composer,window.devicePixelRatio)))}}updateAspect(n,e,i){if(!n)return;e===void 0&&(e=this.domWidth),i===void 0&&(i=this.domHeight);const s=n.aspect;n.aspect=e/i,s!==n.aspect&&n.updateProjectionMatrix()}recreate(){this.clear(),this.create(this._originalCreationArgs)}async onCreate(n){return this.create(n)}async create(n){try{this._isCreating=!0,n!==this._originalCreationArgs&&(this._originalCreationArgs=Vv(n)),window.addEventListener("unhandledrejection",this.onUnhandledRejection);const e=await this.internalOnCreate(n);return this._isCreated=e,e}finally{window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this._isCreating=!1}}onError(n){this.domElement.dispatchEvent(new CustomEvent("error",{detail:n}))}clear(){var n,e,i,s;xi.dispatchCallback(_i.ContextClearing,this),yc(this,_i.ContextClearing),oa(this.scene,!0,!0),this.scene=new Is,(n=this.addressables)==null||n.dispose(),(e=this.lightmaps)==null||e.clear(),(s=(i=this.physics)==null?void 0:i.engine)==null||s.clearCaches(),this.isManagedExternally||this.renderer&&(this.renderer.renderLists.dispose(),this.renderer.state.reset(),this.renderer.resetState()),xi.dispatchCallback(_i.ContextCleared,this)}dispose(){this.internalOnDestroy()}onDestroy(){this.internalOnDestroy()}internalOnDestroy(){var n,e;on.Current=this,xi.dispatchCallback(_i.ContextDestroying,this),yc(this,_i.ContextDestroying),this.clear(),(n=this.renderer)==null||n.setAnimationLoop(null),this.renderer&&(this.renderer.setClearAlpha(0),this.renderer.clear(),this.isManagedExternally||(ws&&console.log("Disposing renderer"),this.renderer.dispose())),this.scene=null,this.renderer=null,this.input.dispose(),this.menu.onDestroy(),this.animations.onDestroy();for(const i of this._disposeCallbacks)try{i()}catch(s){console.error("Error in on dispose callback:",s,i)}(e=this.domElement)!=null&&e.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this._isCreated=!1,xi.dispatchCallback(_i.ContextDestroyed,this),yc(this,_i.ContextDestroyed),xi.unregister(this),on.Current===this&&(on.Current=null)}registerCoroutineUpdate(n,e,i){return typeof e?.next!="function"?(console.error("Registered invalid coroutine function from "+n.name+`
|
|
5580
5580
|
Coroutine functions must be generators: "*myCoroutine() {...}"
|
|
5581
5581
|
Start a coroutine from a component by calling "this.startCoroutine(myCoroutine())"`),e):(this.coroutines[i]||(this.coroutines[i]=[]),this.coroutines[i].push({comp:n,main:e}),e)}unregisterCoroutineUpdate(n,e){if(!this.coroutines[e])return;const i=this.coroutines[e].findIndex(s=>s.main===n);i>=0&&this.coroutines[e].splice(i,1)}stopAllCoroutinesFrom(n){for(const e in this.coroutines){const i=this.coroutines[e];for(let s=i.length-1;s>=0;s--)i[s].comp===n&&i.splice(s,1)}}setCurrentCamera(n){var e;if(!n)return;if(n.threeCamera||n.buildCamera(),!n.threeCamera){console.warn("Camera component is missing camera",n);return}const i=this._cameraStack.indexOf(n);i>=0&&this._cameraStack.splice(i,1),this._cameraStack.push(n),this.mainCameraComponent=n;const s=n.threeCamera;s.isPerspectiveCamera&&this.updateAspect(s),(e=this.mainCameraComponent)==null||e.applyClearFlagsIfIsActiveCamera()}removeCamera(n){if(!n)return;const e=this._cameraStack.indexOf(n);if(e>=0&&this._cameraStack.splice(e,1),this.mainCameraComponent===n&&(this.mainCameraComponent=void 0,this._cameraStack.length>0)){const i=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(i)}}addBeforeRenderListener(n,e){this._onBeforeRenderListeners.has(n.uuid)||(this._onBeforeRenderListeners.set(n.uuid,[]),n.onBeforeRender=this._createRenderCallbackWrapper(n,this._onBeforeRenderListeners)),this._onBeforeRenderListeners.get(n.uuid).push(e)}removeBeforeRenderListener(n,e){if(this._onBeforeRenderListeners.has(n.uuid)){const i=this._onBeforeRenderListeners.get(n.uuid),s=i.indexOf(e);s>=0&&i.splice(s,1)}}addAfterRenderListener(n,e){var i;this._onAfterRenderListeners.has(n.uuid)||(this._onAfterRenderListeners.set(n.uuid,[]),n.onAfterRender=this._createRenderCallbackWrapper(n,this._onAfterRenderListeners)),(i=this._onAfterRenderListeners.get(n.uuid))==null||i.push(e)}removeAfterRenderListener(n,e){if(this._onAfterRenderListeners.has(n.uuid)){const i=this._onAfterRenderListeners.get(n.uuid),s=i.indexOf(e);s>=0&&i.splice(s,1)}}_createRenderCallbackWrapper(n,e){return(i,s,r,o,a,l)=>{const c=e.get(n.uuid);if(c)for(let h=0;h<c.length;h++){const d=c[h];d(i,s,r,o,a,l)}}}get isRendering(){return this._isRendering}setRequireDepth(n){this._requireDepthTexture=n}setRequireColor(n){this._requireColorTexture=n}get depthTexture(){var n;return((n=this._renderTarget)==null?void 0:n.depthTexture)||null}get opaqueColorTexture(){var n;return((n=this._renderTarget)==null?void 0:n.texture)||null}get isVisibleToUser(){if(this.isInXR)return!0;if(!this._isVisible)return!1;const n=getComputedStyle(this.domElement);return n.visibility!=="hidden"&&n.display!=="none"&&n.opacity!=="0"}async internalOnCreate(n){var e,i,s,r,o,a,l,c;const h=++this._createId;ws&&console.log("Creating context",this.name,n);const d=globalThis["needle:dependencies:ready"];d instanceof Promise&&(ws&&console.log("Waiting for dependencies to be ready"),await d.catch(g=>{if(ws||je()){if(B_("Needle Engine dependencies failed to load. Please check the console for more details"),g instanceof ReferenceError){let v="YourComponentName";const y=g.message.indexOf("'");if(y>0){const b=g.message.indexOf("'",y+1);if(b>0){const A=g.message.substring(y+1,b);A.length>3&&(v=A)}}console.error(`Needle Engine dependencies failed to load:
|
|
5582
5582
|
|
|
@@ -5584,10 +5584,10 @@ Start a coroutine from a component by calling "this.startCoroutine(myCoroutine()
|
|
|
5584
5584
|
\u2192 Possible solution: Replace @serializable(${v}) in your script with @serializable(Behaviour)
|
|
5585
5585
|
|
|
5586
5586
|
---`,g);return}console.error("Needle Engine dependencies failed to load",g)}}).then(()=>{ws&&console.log("Needle Engine dependencies are ready")})),this.clear(),this.isManagedExternally===!1&&(this.createNewRenderer(),(e=this.renderer)==null||e.setAnimationLoop(null)),await bl(1),on.Current=this,await xi.dispatchCallback(_i.ContextCreationStart,this);let u=!0,m;try{on.Current=this,n?m=await this.internalLoadInitialContent(h,n):m=[]}catch(g){console.error(g),u=!1}if(!u)return this.onError("Failed to load initial content"),!1;if(h!==this._createId||(i=n?.abortSignal)!=null&&i.aborted)return!1;if(this.internalOnUpdateVisible(),!this.renderer)return ws&&console.warn("Context has no renderer (perhaps it was disconnected?",this.domElement.isConnected),!1;!this.isManagedExternally&&!this.domElement.shadowRoot&&this.domElement.prepend(this.renderer.domElement),on.Current=this,on.Current=this;for(let g=0;g<this.new_scripts.length;g++){const v=this.new_scripts[g];if(v.gameObject!==void 0&&v.gameObject!==null){v.gameObject.userData===void 0&&(v.gameObject.userData={}),v.gameObject.userData.components===void 0&&(v.gameObject.userData.components=[]);const y=v.gameObject.userData.components;y.includes(v)||y.push(v)}}if(this.post_setup_callbacks)for(let g=0;g<this.post_setup_callbacks.length;g++)on.Current=this,await this.post_setup_callbacks[g](this);if(!this._mainCamera){on.Current=this;let g=null;Pm(this.scene,v=>{const y=v;if(y!=null&&y.isCamera){if(Jb(y.gameObject),!y.activeAndEnabled)return;if(y.tag==="MainCamera")return g=y,!0;g=y}}),g?this.setCurrentCamera(g):!xi.dispatchCallback(_i.MissingCamera,this,{files:m})&&!this.mainCamera&&!this.isManagedExternally&&console.warn("Missing camera in main scene",this)}if(this.input.bindEvents(),on.Current=this,JS(this),this.physics.engine&&((s=this.physics.engine)==null||s.step(0),(r=this.physics.engine)==null||r.postStep()),!this.isManagedExternally&&this.composer&&this.mainCamera){const g=new N_(this.scene,this.mainCamera);this.renderer.setSize(this.domWidth,this.domHeight),this.composer.addPass(g),this.composer.setSize(this.domWidth,this.domHeight)}this._sizeChanged=!0,this._stats&&(this._stats.showPanel(0),this._stats.dom.style.position="absolute",(o=this.domElement.shadowRoot)==null||o.appendChild(this._stats.dom)),ws&&P_(this.scene,!0),this.targetFrameRate===void 0?(ws&&console.warn("No target framerate set, using default",on.DefaultTargetFrameRate),this.targetFrameRate=on._defaultTargetFramerate):ws&&console.log("Target framerate set to",this.targetFrameRate),this._dispatchReadyAfterFrame=!0;const f=xi.dispatchCallback(_i.ContextCreated,this,{files:m});return f&&("internalSetLoadingMessage"in this.domElement&&typeof this.domElement.internalSetLoadingMessage=="function"&&((a=this.domElement)==null||a.internalSetLoadingMessage("finish loading")),await f),(l=n?.abortSignal)!=null&&l.aborted?!1:(yc(this,_i.ContextCreated),ws&&console.log("Context Created...",this.renderer,this.renderer.domElement),this._isCreating=!1,!this.isManagedExternally&&!((c=n?.abortSignal)!=null&&c.aborted)&&this.restartRenderLoop(),!0)}async internalLoadInitialContent(n,e){var i,s,r,o;const a=new Array;if(e.files.length===0)return a;const l=[...e.files],c={name:"",progress:null,index:0,count:l.length},h=vl(),d=0;for(let u=0;u<l.length;u++){if((i=e.abortSignal)!=null&&i.aborted){ws&&console.log("Aborting loading because of abort signal");break}if(n!==this._createId){ws&&console.log("Aborting loading because create id changed",n,this._createId);break}const m=l[u];(s=e?.onLoadingStart)==null||s.call(this,u,m),ws&&console.log("Context Load "+m);const f=await h.loadSync(this,m,m,d,g=>{var v,y;(v=e.abortSignal)!=null&&v.aborted||(c.name=m,c.progress=g,c.index=u,c.count=l.length,(y=e.onLoadingProgress)==null||y.call(this,c))});(r=e?.onLoadingFinished)==null||r.call(this,u,m,f??null),f?a.push({src:m,file:f}):console.warn("Could not load file: "+m)}if(n!==this._createId||(o=e.abortSignal)!=null&&o.aborted){for(const u of a)if(u&&u.file)for(const m of u.file.scenes)oa(m,!0,!0)}else{let u=!1;for(const m of a)m&&m.file&&(m.file.scene?(u=!0,this.scene.add(m.file.scene)):console.warn("No scene found in loaded file"));if(!u){for(const m of a)if(m&&m.file&&"parser"in m.file){let f=0;for(let g=0;g<m.file.parser.json.materials.length;g++){const v=await m.file.parser.getDependency("material",g),y=new ge;y.position.x=g*1.1,y.position.y=f,this.scene.add(y),vu.createPrimitive("ShaderBall",{parent:y,material:v})}f+=1}}}return a}restartRenderLoop(){return this.renderer?this._isCreating?(console.warn("Can not start render loop while creating context"),!1):(this.renderer.setAnimationLoop((n,e)=>{this.isManagedExternally||this.update(n,e)}),!0):(console.error("Can not start render loop without renderer"),!1)}update(n,e){if(e===void 0&&(e=null),je()||ws||dme())try{performance.mark("update.start"),this.internalStep(n,e),this._renderlooperrors=0,performance.mark("update.end"),performance.measure("NE Frame","update.start","update.end")}catch(i){this._renderlooperrors+=1,(je()||ws)&&(i instanceof Error||i instanceof TypeError)&&gn("Caught unhandled exception during render-loop - see console for details.",Ko.Error),console.error("Frame #"+this.time.frame+`
|
|
5587
|
-
`,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(n,e)}updatePhysics(n){this.internalUpdatePhysics(n)}internalStep(n,e){this.internalOnBeforeRender(n,e)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(n,e){var i;this.renderer.info.autoReset=!0;const s=e!==null&&this._xrFrame===null;if(this._xrFrame=e,s&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:e}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=n),this._accumulatedTime+=(n-this._lastTimestamp)/1e3,this._lastTimestamp=n;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return!1;this._accumulatedTime=0}if((i=this._stats)==null||i.begin(),on.Current=this,this.onHandlePaused())return!1;for(on.Current=this,this.time.update(),Jfe&&console.log("FPS",this.time.smoothedFps.toFixed(0)),JS(this),qS(this.scene),
|
|
5587
|
+
`,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(n,e)}updatePhysics(n){this.internalUpdatePhysics(n)}internalStep(n,e){this.internalOnBeforeRender(n,e)!==!1&&(this.internalOnRender(),this.internalOnAfterRender())}internalOnBeforeRender(n,e){var i;this.renderer.info.autoReset=!0;const s=e!==null&&this._xrFrame===null;if(this._xrFrame=e,s&&this.domElement.dispatchEvent(new CustomEvent("xr-session-started",{detail:{context:this,session:this.xrSession,frame:e}})),this._currentFrameEvent=-1,this.isManagedExternally===!1&&this.isInXR===!1&&this.targetFrameRate!==void 0){this._lastTimestamp===0&&(this._lastTimestamp=n),this._accumulatedTime+=(n-this._lastTimestamp)/1e3,this._lastTimestamp=n;let r=this.targetFrameRate;if(typeof r=="object"&&(r=r.value),this._accumulatedTime<1/(r+1))return!1;this._accumulatedTime=0}if((i=this._stats)==null||i.begin(),on.Current=this,this.onHandlePaused())return!1;for(on.Current=this,this.time.update(),Jfe&&console.log("FPS",this.time.smoothedFps.toFixed(0)),JS(this),qS(this.scene),E9(this),yc(this,-1);this._cameraStack.length>0&&(!this.mainCameraComponent||this.mainCameraComponent.destroyed);){this._cameraStack.splice(this._cameraStack.length-1,1);const r=this._cameraStack[this._cameraStack.length-1];this.setCurrentCamera(r)}if(this.pre_update_oneshot_callbacks){for(const r in this.pre_update_oneshot_callbacks)this.pre_update_oneshot_callbacks[r]();this.pre_update_oneshot_callbacks.length=0}if(this.pre_update_callbacks)for(const r in this.pre_update_callbacks)this.pre_update_callbacks[r]();this._currentFrameEvent=0;for(let r=0;r<this.scripts_earlyUpdate.length;r++){const o=this.scripts_earlyUpdate[r];o.activeAndEnabled&&o.earlyUpdate!==void 0&&(on.Current=this,o.earlyUpdate())}if(this.executeCoroutines(0),yc(this,0),this.onHandlePaused())return!1;this._currentFrameEvent=1;for(let r=0;r<this.scripts_update.length;r++){const o=this.scripts_update[r];o.activeAndEnabled&&o.update!==void 0&&(on.Current=this,o.update())}if(this.executeCoroutines(1),yc(this,1),this.onHandlePaused())return!1;this._currentFrameEvent=2;for(let r=0;r<this.scripts_lateUpdate.length;r++){const o=this.scripts_lateUpdate[r];o.activeAndEnabled&&o.lateUpdate!==void 0&&(on.Current=this,o.lateUpdate())}if(this.executeCoroutines(2),yc(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 r=0;r<this.scripts_onBeforeRender.length;r++){const o=this.scripts_onBeforeRender[r];o.activeAndEnabled&&o.onBeforeRender!==void 0&&(on.Current=this,o.onBeforeRender(e))}if(this.executeCoroutines(3),yc(this,3),this._sizeChanged&&this.updateSize(),this.pre_render_callbacks)for(const r in this.pre_render_callbacks)this.pre_render_callbacks[r](e)}return!0}internalUpdatePhysics(n){if(!this.physics.engine)return!1;const e=n,i=this.time.deltaTime/e;for(let s=0;s<e;s++)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||(fme(this),this._currentFrameEvent=-1,this.renderNow(),this._currentFrameEvent=4)}internalOnAfterRender(){if(this.isVisibleToUser||this.runInBackground){for(let n=0;n<this.scripts_onAfterRender.length;n++){const e=this.scripts_onAfterRender[n];e.activeAndEnabled&&e.onAfterRender!==void 0&&(on.Current=this,e.onAfterRender())}if(this.executeCoroutines(4),yc(this,4),this.post_render_callbacks)for(const n in this.post_render_callbacks)this.post_render_callbacks[n]()}this._currentFrameEvent=-1,this.connection.sendBufferedMessagesNow(),this._stats&&(this._stats.end(),this.time.frameCount%150===0&&console.log(this.renderer.info.render.calls+" DrawCalls",`
|
|
5588
5588
|
Render:`,{...this.renderer.info.render},`
|
|
5589
5589
|
Memory:`,{...this.renderer.info.memory},`
|
|
5590
|
-
Target Framerate: `+this.targetFrameRate)),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),xi.dispatchCallback(_i.ContextFirstFrameRendered,this))}renderNow(n){return!n&&(n=this.mainCamera,!n)?!1:(this.handleRendererContextLost(),this._isRendering=!0,this.renderRequiredTextures(),this.renderer.toneMapping!==Yr&&$
|
|
5590
|
+
Target Framerate: `+this.targetFrameRate)),this._dispatchReadyAfterFrame&&(this._dispatchReadyAfterFrame=!1,this.domElement.dispatchEvent(new CustomEvent("ready")),xi.dispatchCallback(_i.ContextFirstFrameRendered,this))}renderNow(n){return!n&&(n=this.mainCamera,!n)?!1:(this.handleRendererContextLost(),this._isRendering=!0,this.renderRequiredTextures(),this.renderer.toneMapping!==Yr&&$4(),this.composer&&!this.isInXR?this.composer.render(this.time.deltaTime):n&&(this.isInXR&&At.isMacOS()&&this.renderer.clearDepth(),this.renderer.render(this.scene,n)),this._isRendering=!1,!0)}handleRendererContextLost(){this.renderer.getContext().isContextLost()&&(console.warn("Attempting to recover WebGL context..."),this.renderer.forceContextRestore())}onHandlePaused(){const n=this.evaluatePaused();if(this._wasPaused!==n){Kfe&&console.log("Paused?",n,"context:"+this.alias);for(let e=0;e<this.scripts_pausedChanged.length;e++){const i=this.scripts_pausedChanged[e];i.activeAndEnabled&&i.onPausedChanged!==void 0&&(on.Current=this,i.onPausedChanged(n,this._wasPaused))}}return this._wasPaused=n,n}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 Yt(this.domWidth,this.domHeight),this._requireDepthTexture){const i=new rg(this.domWidth,this.domHeight);this._renderTarget.depthTexture=i}this._requireColorTexture&&(this._renderTarget.texture=new Vt,this._renderTarget.texture.generateMipmaps=!1,this._renderTarget.texture.minFilter=Ot,this._renderTarget.texture.magFilter=Ot,this._renderTarget.texture.format=wi)}const n=this._renderTarget;n.texture&&(n.texture.colorSpace=this.renderer.outputColorSpace);const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(n),this.renderer.render(this.scene,this.mainCamera),this.renderer.setRenderTarget(e)}executeCoroutines(n){var e;if(this.coroutines[n]){const s=this.coroutines[n];for(let r=0;r<s.length;r++)try{const o=s[r];if(!o.comp||o.comp.destroyed||!o.main||o.comp.enabled===!1){qfe&&console.log("Removing coroutine",o.comp,o.comp.enabled),s.splice(r,1),--r;continue}const a=o.chained;if(a&&a.length>0){const h=a[a.length-1].next();if(h.done&&a.pop(),i(h)&&(o.chained||(o.chained=[]),o.chained.push(h.value)),!h.done)continue}const l=o.main.next();if(l.done===!0){s.splice(r,1),--r;continue}const c=l.value;if(i(c)){if(c.next().done)continue;o.chained||(o.chained=[]),o.chained.push(c)}else if(c instanceof Promise){const h=c;o.chained||(o.chained=[]);const d=R4(h);(e=o.chained)==null||e.push(d);continue}}catch(o){console.error(o)}}function i(s){return!!(s&&s.next&&s.return)}}};let Pt=on;p(Pt,"_defaultTargetFramerate",{value:90,toString(){return this.value}}),p(Pt,"_defaultWebglRendererParameters",{antialias:!0,alpha:!1,powerPreference:At.isiOS()||At.isMacOS()?"default":"high-performance"});const ja=te("debuglicense");let Om="basic";ja&&console.log("License Type: "+Om);function Mu(){switch(Om){case"pro":case"enterprise":return!0}return!1}function LB(){switch(Om){case"indie":return!0}return!1}function zl(){return Mu()||LB()}const aj=[];function tge(n){if(Mu()||LB())return n(!0);aj.push(n)}function ige(n){for(const e of aj)try{e(n)}catch{}}xi.registerCallback(_i.ContextRegistered,n=>{rge(n.context),age(),sge(n.context)});let Dm,PB=!1,NC="";async function nge(){if(Dm)return Dm;if(Om==="basic")try{const n="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+_l+"&generator="+encodeURIComponent(O_),e=await fetch(n,{method:"GET"}).catch(i=>{ja&&console.error("License check failed",i)});e?.status===200?(PB=!1,ja&&console.log("License check succeeded"),Om="pro",ige(!0)):e?.status===403?(PB=!0,NC=await e.text()):ja&&console.log("License check failed with status "+e?.status)}catch(n){ja&&console.error("License check failed",n)}else ja&&console.log('Runtime license check is skipped because license is already applied as "'+Om+'"')}Dm=nge();async function sge(n){function e(){const r=document.createElement("div");r.className="needle-forbidden",r.style.cssText=`
|
|
5591
5591
|
position: fixed;
|
|
5592
5592
|
top: 0;
|
|
5593
5593
|
left: 0;
|
|
@@ -5867,7 +5867,7 @@ ${d.has(1)?`
|
|
|
5867
5867
|
`:""}
|
|
5868
5868
|
${h.join(`
|
|
5869
5869
|
`)}`:""}
|
|
5870
|
-
}`}function Xj(n){return`(${n.r}, ${n.g}, ${n.b})`}function Wj(n){return`(${n.x}, ${n.y})`}const Hj=[1023,33777,33778,33779,35842,35843,37496,37808,37809,37810,37811,37812,37813,37814,37815,37816,37817,37818,37819,37820,37821,36492];te("debugusdz");const jj=class{constructor(n,e,i){p(this,"id"),p(this,"trigger"),p(this,"action"),p(this,"exclusive",!1),this.id="Behavior_"+Ul(n)+"_"+jj.global_id++,this.trigger=e,this.action=i}makeExclusive(n){return this.exclusive=n,this}writeTo(n,e,i){if(!this.trigger||!this.action)return;i.beginBlock(`def Preliminary_Behavior "${this.id}"`);let s="";if(Array.isArray(this.trigger)){s="[";for(let r=0;r<this.trigger.length;r++){const o=this.trigger[r];s+="<"+o.id+">",r+1<this.trigger.length&&(s+=", ")}s+="]"}else s=`<${this.trigger.id}>`;if(i.appendLine(`rel triggers = ${s}`),i.appendLine(`rel actions = <${this.action.id}>`),i.appendLine(`uniform bool exclusive = ${this.exclusive?1:0}`),i.appendLine(),Array.isArray(this.trigger))for(const r of this.trigger)r.writeTo(e,i),i.appendLine();else this.trigger.writeTo(e,i);i.appendLine(),this.action.writeTo(e,i),i.closeBlock()}};let Gs=jj;p(Gs,"global_id",0);const E0=new Set;function JB(n,e){var i,s;let r="";if(Array.isArray(n)){E0.clear();let o="[ ";for(let a=0;a<n.length;a++){let l=n[a];if(!l){console.warn("Invalid target object in behavior",n+". Is the object exported?");continue}if(typeof l=="string"){if(E0.has(l))continue;o+=l,E0.add(l)}else if(typeof l=="object"){if(l.isObject3D&&(l=e.findById(l.uuid),!l)){console.warn("Invalid target object in behavior",n+". Is the object exported?");continue}const c=(i=l.getPath)==null?void 0:i.call(l);if(E0.has(c))continue;o+=c,E0.add(c)}a+1<n.length&&(o+=", ")}o+=" ]",r=o,E0.clear()}else if(typeof n=="object"){const o=n;if(o.isObject3D&&(n=e.findById(o.uuid)),!n)throw console.error("Invalid target object in behavior, the target object is likely missing from USDZ export. Is the object exported?",o),new Error(`Invalid target object in behavior, the target object is likely missing from USDZ export. Please report a bug. uuid: ${o.uuid}.`);r=(s=n.getPath)==null?void 0:s.call(n)}return r}const Qj=class{constructor(n,e){p(this,"id"),p(this,"targetId"),p(this,"tokenId"),p(this,"type"),p(this,"distance"),n&&(this.targetId=n),e?this.id=e:this.id="Trigger_"+Qj.global_id++}writeTo(n,e){e.beginBlock(`def Preliminary_Trigger "${this.id}"`),this.targetId&&(typeof this.targetId!="string"&&(this.targetId=JB(this.targetId,n)),e.appendLine("rel affectedObjects = "+this.targetId)),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.type&&e.appendLine(`token type = "${this.type}"`),typeof this.distance=="number"&&e.appendLine(`double distance = ${this.distance}`),e.closeBlock()}};let Eu=Qj;p(Eu,"global_id",0);function Zj(n,e={direct:!0,indirect:!0}){const i=ho.createEmpty();i.name="InputTarget_"+i.name,i.displayName=void 0,i.type="RealityKitComponent",i.onSerialize=s=>{s.appendLine("bool allowsDirectInput = "+(e.direct?1:0)),s.appendLine("bool allowsIndirectInput = "+(e.indirect?1:0)),s.appendLine('uniform token info:id = "RealityKit.InputTarget"')},n.add(i)}class Ns{static sceneStartTrigger(){const e=new Eu;return e.targetId=void 0,e.tokenId="SceneTransition",e.type="enter",e}static tapTrigger(e,i={direct:!0,indirect:!0}){const s=new Eu(e);if(Array.isArray(e)&&e.length>1)for(const r of e)r instanceof ho&&Zj(r,i);else e instanceof ho&&Zj(e,i);return s.tokenId="TapGesture",s}static isTapTrigger(e){return e?.tokenId==="TapGesture"}static proximityToCameraTrigger(e,i){const s=new Eu(e);return s.tokenId="ProximityToCamera",s.distance=i,s}}class jh{constructor(e,i){p(this,"id"),p(this,"actions"),p(this,"loops",0),p(this,"performCount",1),p(this,"type","serial"),p(this,"multiplePerformOperation"),this.id=e,this.actions=i}static getId(){return this.global_id++}addAction(e){return this.actions.push(e),this}makeParallel(){return this.type="parallel",this}makeSequence(){return this.type="serial",this}makeLooping(){return this.loops=1,this.performCount=0,this}makeRepeat(e){return this.performCount=e,this}writeTo(e,i){i.beginBlock(`def Preliminary_Action "${this.id}"`),i.beginArray("rel actions");for(const s of this.actions){if(!s)continue;const r=s===this.actions[this.actions.length-1];i.appendLine("<"+s.id+">"+(r?"":", "))}i.closeArray(),i.appendLine(),i.appendLine('token info:id = "Group"'),i.appendLine(`bool loops = ${this.loops}`),i.appendLine(`int performCount = ${this.loops>0?0:Math.max(0,this.performCount)}`),i.appendLine(`token type = "${this.type}"`),typeof this.multiplePerformOperation=="string"&&i.appendLine(`token multiplePerformOperation = "${this.multiplePerformOperation}"`),i.appendLine();for(const s of this.actions)s&&(s.writeTo(e,i),i.appendLine());i.closeBlock()}}p(jh,"global_id",0);const qB=class{constructor(n,e){p(this,"id"),p(this,"tokenId"),p(this,"affectedObjects"),p(this,"easeType"),p(this,"motionType"),p(this,"duration"),p(this,"moveDistance"),p(this,"style"),p(this,"type"),p(this,"front"),p(this,"up"),p(this,"start"),p(this,"animationSpeed"),p(this,"reversed"),p(this,"pingPong"),p(this,"xFormTarget"),p(this,"audio"),p(this,"gain"),p(this,"auralMode"),p(this,"multiplePerformOperation"),p(this,"velocity"),p(this,"comment"),p(this,"animationName"),n&&(this.affectedObjects=n),e?this.id=e:this.id="Action",this.id+="_"+qB.global_id++}clone(){const n=new qB,e=n.id;return Object.assign(n,this),n.id=e,n}writeTo(n,e){e.beginBlock(`def Preliminary_Action "${this.id}"`),this.comment&&e.appendLine(`# ${this.comment}`),this.affectedObjects&&(typeof this.affectedObjects!="string"&&(this.affectedObjects=JB(this.affectedObjects,n)),e.appendLine("rel affectedObjects = "+this.affectedObjects)),typeof this.duration=="number"&&(typeof this.animationSpeed=="number"&&this.animationSpeed!==1?e.appendLine(`double duration = ${this.duration/this.animationSpeed} `):e.appendLine(`double duration = ${this.duration} `)),this.easeType&&e.appendLine(`token easeType = "${this.easeType}"`),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.tokenId==="ChangeScene"&&e.appendLine("rel scene = </StageRoot/Scenes/Scene>"),this.motionType!==void 0&&e.appendLine(`token motionType = "${this.motionType}"`),typeof this.moveDistance=="number"&&e.appendLine(`double moveDistance = ${this.moveDistance} `),this.style&&e.appendLine(`token style = "${this.style}"`),this.type&&e.appendLine(`token type = "${this.type}"`),this.front&&e.appendLine(`vector3d front = (${this.front.x}, ${this.front.y}, ${this.front.z})`),this.up&&e.appendLine(`vector3d upVector = (${this.up.x}, ${this.up.y}, ${this.up.z})`),typeof this.start=="number"&&e.appendLine(`double start = ${this.start} `),typeof this.animationSpeed=="number"&&e.appendLine(`double animationSpeed = ${this.animationSpeed.toFixed(2)} `),typeof this.reversed=="boolean"&&e.appendLine(`bool reversed = ${this.reversed}`),typeof this.pingPong=="boolean"&&e.appendLine(`bool reverses = ${this.pingPong}`),this.xFormTarget&&(typeof this.xFormTarget!="string"&&(this.xFormTarget=JB(this.xFormTarget,n)),e.appendLine(`rel xformTarget = ${this.xFormTarget}`)),typeof this.audio=="string"&&e.appendLine(`asset audio = @${this.audio}@`),typeof this.gain=="number"&&e.appendLine(`double gain = ${this.gain}`),typeof this.auralMode=="string"&&e.appendLine(`token auralMode = "${this.auralMode}"`),typeof this.multiplePerformOperation=="string"&&e.appendLine(`token multiplePerformOperation = "${this.multiplePerformOperation}"`),typeof this.velocity=="object"&&e.appendLine(`vector3d velocity = (${this.velocity.x}, ${this.velocity.y}, ${this.velocity.z})`),e.closeBlock()}};let aa=qB;p(aa,"global_id",0);let T0=class Wy{constructor(e,i,s){p(this,"x",0),p(this,"y",0),p(this,"z",0),this.x=e,this.y=i,this.z=s}static get up(){return new Wy(0,1,0)}static get right(){return new Wy(1,0,0)}static get forward(){return new Wy(0,0,1)}static get back(){return new Wy(0,0,-1)}static get zero(){return new Wy(0,0,0)}};class vi{static sequence(...e){return new jh("Group_"+jh.getId(),e).makeSequence()}static parallel(...e){return new jh("Group_"+jh.getId(),e).makeParallel()}static fadeAction(e,i,s){const r=new aa(e);return r.tokenId="Visibility",r.type=s?"show":"hide",r.duration=i,r.style="basic",r.motionType="none",r.moveDistance=0,r.easeType="none",r}static startAnimationAction(e,i,s=!1,r=!1){const o=new aa(e);o.tokenId="StartAnimation";const a=i.start,l=i.duration,c=i.speed,h=i.clipName;if(o.comment=`Animation: ${h}, start=${a*60}, length=${l*60}, end=${(a+l)*60}`,o.animationName=h,o.start=a,o.duration=l,o.animationSpeed=c,o.reversed=s,o.pingPong=r,o.multiplePerformOperation="allow",s&&(o.start-=l),r){o.pingPong=!1;const d=o.clone();return d.reversed=!s,d.start=o.start,d.reversed&&(d.start-=l),vi.sequence(o,d)}return o}static waitAction(e){const i=new aa;return i.tokenId="Wait",i.duration=e,i.motionType=void 0,i}static lookAtCameraAction(e,i,s,r){const o=new aa(e);return o.tokenId="LookAtCamera",o.duration=i===void 0?9999999999999:i,o.front=s??T0.forward,o.up=r??T0.up,o}static emphasize(e,i,s="bounce",r=1,o="basic"){const a=new aa(e);return a.tokenId="Emphasize",a.duration=i,a.style=o??"basic",a.motionType=s,a.moveDistance=r,a}static transformAction(e,i,s,r,o="inout"){const a=new aa(e);return a.tokenId="Transform",a.duration=s,a.duration=Math.max(1e-6,s),a.type=r,a.easeType=s>0?o:"none",Array.isArray(i)&&console.error("Transform target must not be an array",i),a.xFormTarget=i,a}static playAudioAction(e,i,s="play",r=1,o="spatial"){const a=new aa(e);return a.tokenId="Audio",a.type=s,a.audio=i,a.gain=r,a.auralMode=o,a.multiplePerformOperation="allow",a}static impulseAction(e,i){const s=new aa(e);return s.tokenId="Impulse",s.velocity=i,s}}class qge{constructor(e){p(this,"object"),p(this,"model"),this.object=e}get id(){return this.object.uuid}apply(e){if(!this.model&&(this.model=e.findById(this.object.uuid),!this.model)){console.error("could not find model with id "+this.object.uuid);return}this.onApply(e)}}class $B extends qge{constructor(e,i,s,r){super(e),p(this,"matrix"),p(this,"material"),p(this,"geometry"),p(this,"_enableAction"),p(this,"_disableAction"),this.matrix=i,this.material=s,this.geometry=r}onApply(e){var i,s;const r=this.model;if(!r)return;(i=r.parent)!=null&&i.isDynamic||ho.createEmptyParent(r);const o=r.clone();this.matrix&&o.setMatrix(this.matrix),this.material&&(o.material=this.material),this.geometry&&(o.geometry=this.geometry),(s=r.parent)==null||s.add(o)}enable(){return this._enableAction?this._enableAction:(this._enableAction=vi.fadeAction(this.object,0,!0),this._enableAction)}disable(){return this._disableAction?this._disableAction:(this._disableAction=vi.fadeAction(this.object,0,!1),this._disableAction)}}class eO{constructor(e){p(this,"actions"),p(this,"sortedActions"),this.actions=[...e]}organize(){this.sortedActions={};for(const e of this.actions){const i=e.id;this.sortedActions[i]||(this.sortedActions[i]=[]),this.sortedActions[i].push(e)}}getActions(e){return this.sortedActions||this.organize(),this.sortedActions[e.uuid]}}const R0=function(n){return E(n)},E=function(n){if(n===void 0&&(n=null),!Array.isArray(n))n=Yj(n);else for(let e=0;e<n.length;e++){const i=n[e];n[e]=Yj(i)}return function(e,i){typeof i!="string"&&(i=i.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const s=e.$serializedTypes=e.$serializedTypes||{};s[i]=n}};function Yj(n){var e,i;switch((i=(e=n?.prototype)==null?void 0:e.constructor)==null?void 0:i.name){case"Number":case"String":case"Boolean":return null}return n}class ie extends ge{constructor(){super(...arguments),p(this,"guid")}static isDestroyed(e){return Lm(e)}static setActive(e,i,s=!0){e&&(lA(e,i),qS(e),i&&s&&E4(Pt.Current,e))}static isActiveSelf(e){return p0(e)}static isActiveInHierarchy(e){return u9(e)}static markAsInstancedRendered(e,i){p9(e,i)}static isUsingInstancing(e){return pC(e)}static foreachComponent(e,i,s=!0){return Pm(e,i,s)}static instantiateSynced(e,i){return e?Qk(e,i):null}static instantiate(e,i=null){return f0(e,i)}static destroySynced(e,i,s=!0){if(!e)return;const r=e;i=i??Pt.Current,qb(r,i.connection,s)}static destroy(e,i=!0){return oa(e,i)}static add(e,i,s){if(!(!e||!i)){if(e===i){console.warn("Can not add object to self",e);return}s||(s=Pt.Current),i.add(e),lA(e,!0),qS(e),s?ie.foreachComponent(e,r=>{Fk(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var i;e&&((i=e.parent)==null||i.remove(e),lA(e,!1),qS(e),ie.foreachComponent(e,s=>{ume(s)},!0))}static invokeOnChildren(e,i,...s){this.invoke(e,i,!0,s)}static invoke(e,i,s=!1,...r){e&&this.foreachComponent(e,o=>{const a=o[i];a&&typeof a=="function"&&a?.call(o,...r)},s)}static addNewComponent(e,i,s,r=!0){return ra(e,i,s,{callAwake:r})}static addComponent(e,i,s,r){return ra(e,i,s,r)}static moveComponent(e,i){return ra(e,i)}static removeComponent(e){return rB(e.gameObject,e),e}static getOrAddComponent(e,i){return sA(e,i)}static getComponent(e,i){return e===null?null:Im(e,i)}static getComponents(e,i,s=null){return e===null?s??[]:rA(e,i,s)}static findByGuid(e,i){return oB(e,i)}static findObjectOfType(e,i,s=!0){return cC(e,i??Pt.Current,s)}static findObjectsOfType(e,i){const s=[];return h9(e,s,i),s}static getComponentInChildren(e,i){return oA(e,i)}static getComponentsInChildren(e,i,s=null){return u0(e,i,s??void 0)}static getComponentInParent(e,i){return aA(e,i)}static getComponentsInParent(e,i,s=null){return lC(e,i,s)}static getAllComponents(e){var i;const s=(i=e.userData)==null?void 0:i.components;return s?[...s]:[]}static*iterateComponents(e){var i;const s=(i=e?.userData)==null?void 0:i.components;if(s&&Array.isArray(s))for(let r=0;r<s.length;r++)yield s[r]}}var Tu;let Pe=(Tu=class{constructor(n){p(this,"__context"),p(this,"__name"),p(this,"gameObject"),p(this,"guid","invalid"),p(this,"sourceId"),p(this,"__didAwake",!1),p(this,"__didStart",!1),p(this,"__didEnable",!1),p(this,"__isEnabled"),p(this,"__destroyed",!1),p(this,"_eventListeners",new Map),this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(n)}get isComponent(){return!0}get context(){return this.__context??Pt.Current}set context(n){this.__context=n}get scene(){return this.context.scene}get layer(){var n,e;return(e=(n=this.gameObject)==null?void 0:n.userData)==null?void 0:e.layer}get name(){var n,e;return(n=this.gameObject)!=null&&n.name?this.gameObject.name:(e=this.gameObject)==null?void 0:e.userData.name}set name(n){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=n,this.__name=n):this.__name=n}get tag(){var n;return(n=this.gameObject)==null?void 0:n.userData.tag}set tag(n){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=n)}get static(){var n;return(n=this.gameObject)==null?void 0:n.userData.static}set static(n){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.static=n)}get hideFlags(){var n;return(n=this.gameObject)==null?void 0:n.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const n=this.gameObject[Ch];return n===void 0?!0:n}set __isActiveInHierarchy(n){this.gameObject&&(this.gameObject[Ch]=n)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(n,e=Ji.Update){return this.context.registerCoroutineUpdate(this,n,e)}stopCoroutine(n,e=Ji.Update){this.context.unregisterCoroutineUpdate(n,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(n){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(n),this}_internalInit(n){if(typeof n=="object")for(const e of Object.keys(n)){const i=n[e];typeof i!="function"&&(this[e]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(n){return this.__destroyed?(je()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(n!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(n){if(this.__didAwake){if(!this.__didEnable){n!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var n;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((n=this.onDestroy)==null||n.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),a9(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(n){if(this.__destroyed){je()&&console.warn(`[Needle Engine Dev] Trying to ${n?"enable":"disable"} destroyed component`);return}if(typeof n=="number"&&(n>=.5?n=!0:n=!1),!this.__didAwake){this.__isEnabled=n;return}n?this.__internalEnable():this.__internalDisable()}get worldPosition(){return Nt(this.gameObject)}set worldPosition(n){bs(this.gameObject,n)}setWorldPosition(n,e,i){nm(this.gameObject,n,e,i)}get worldQuaternion(){return Bi(this.gameObject)}set worldQuaternion(n){Ba(this.gameObject,n)}setWorldQuaternion(n,e,i,s){cL(this.gameObject,n,e,i,s)}get worldEuler(){return dL(this.gameObject)}set worldEuler(n){uL(this.gameObject,n)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(n){this.setWorldRotation(n.x,n.y,n.z,!0)}setWorldRotation(n,e,i,s=!0){Kv(this.gameObject,n,e,i,s)}get forward(){return Tu._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Tu._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Tu._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(n,e){this._eventListeners[n]=this._eventListeners[n]||[],this._eventListeners[n].push(e)}removeEventListener(n,e){if(!this._eventListeners[n])return;const i=this._eventListeners[n].indexOf(e);i>=0&&this._eventListeners[n].splice(i,1)}dispatchEvent(n){if(!n||!this._eventListeners[n.type])return!1;const e=this._eventListeners[n.type];for(let i=0;i<e.length;i++)e[i](n);return!1}},p(Tu,"_forward",new M),p(Tu,"_right",new M),p(Tu,"_up",new M),Tu);const $ge=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Pe,Component:Pe,GameObject:ie},Symbol.toStringTag,{value:"Module"}));var e0e=Object.defineProperty,t0e=Object.getOwnPropertyDescriptor,Kj=(n,e,i,s)=>{for(var r=s>1?void 0:s?t0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&e0e(e,i,r),r};class xA extends Pe{constructor(){super(...arguments),p(this,"from"),p(this,"to"),p(this,"width",0),p(this,"centered",!0),p(this,"_centerPos")}awake(){this._centerPos=new M}update(){if(!this.from||!this.to)return;const e=Nt(this.from).clone(),i=Nt(this.to).clone(),s=e.distanceTo(i);this._centerPos.copy(e),this._centerPos.add(i),this._centerPos.multiplyScalar(.5),bs(this.gameObject,this.centered?this._centerPos:e),this.gameObject.lookAt(Nt(this.to).clone()),this.gameObject.scale.set(this.width,this.width,s)}}Kj([E(ie)],xA.prototype,"from",2),Kj([E(ie)],xA.prototype,"to",2);var i0e=Object.defineProperty,n0e=Object.getOwnPropertyDescriptor,Nm=(n,e,i,s)=>{for(var r=s>1?void 0:s?n0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&i0e(e,i,r),r};const Ru=te("debuganimation");let Jj=class{constructor(){p(this,"x"),p(this,"y")}};class zr extends Pe{constructor(){super(...arguments),p(this,"playAutomatically",!0),p(this,"randomStartTime",!0),p(this,"minMaxSpeed"),p(this,"minMaxOffsetNormalized"),p(this,"loop",!0),p(this,"clampWhenFinished",!1),p(this,"_tempAnimationClipBeforeGameObjectExisted",null),p(this,"_tempAnimationsArray"),p(this,"mixer"),p(this,"_actions"),p(this,"_handles")}get isAnimationComponent(){return!0}addClip(e){this.animations||(this.animations=[]),this.animations.push(e)}get time(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.time}return 0}set time(e){if(this.actions)for(const i of this.actions)i.time=e}get clip(){var e;return(e=this.animations)!=null&&e.length?this.animations[0]:null}set clip(e){if(!this.__didAwake){Ru&&console.warn("Assign clip during serialization",e),this._tempAnimationClipBeforeGameObjectExisted=e;return}e&&(this.gameObject.animations||(this.gameObject.animations=[]),!this.animations.includes(e)&&(this.animations.length>0?this.animations.splice(0,0,e):this.animations.push(e)))}set clips(e){this.animations=e}set animations(e){e==null||!Array.isArray(e)||(this.gameObject?this.gameObject.animations=e:this._tempAnimationsArray=e)}get animations(){return this.gameObject.animations||this._tempAnimationsArray||[]}get actions(){return this._actions}set actions(e){this._actions=e}awake(){this.mixer=void 0,Ru&&console.log("Animation Awake",this.name,this),this._tempAnimationsArray&&(this.animations=this._tempAnimationsArray,this._tempAnimationsArray=void 0),this._tempAnimationClipBeforeGameObjectExisted&&(this.clip=this._tempAnimationClipBeforeGameObjectExisted,this._tempAnimationClipBeforeGameObjectExisted=null),this.actions=[],this._handles=[]}onEnable(){var e;if(this.playAutomatically&&((e=this.animations)==null?void 0:e.length)>0){const i=Math.floor(Math.random()*this.animations.length),s=this.animations[i];this.play(i,{exclusive:!0,fadeDuration:0,startTime:this.randomStartTime?Math.random()*s.duration:0,loop:this.loop,clampWhenFinished:this.clampWhenFinished})}}update(){this.mixer&&(this.mixer.update(this.context.time.deltaTime),this._handles.forEach(e=>e.update()))}onDisable(){this.mixer&&this.mixer.stopAllAction()}onDestroy(){this.context.animations.unregisterAnimationMixer(this.mixer)}getAction(e){var i;return((i=this.actions)==null?void 0:i.find(s=>s.getClip().name===e))||null}get isPlaying(){if(this.actions){for(let e=0;e<this.actions.length;e++)if(this.actions[e].isRunning())return!0}return!1}stopAll(e){if(this.actions)for(const i of this.actions)e!=null&&e.fadeDuration?i.fadeOut(e.fadeDuration):i.stop()}stop(e,i){if(e===void 0){this.stopAll();return}else if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(r=>r.name===e));if(!e){console.error("Could not find clip",e);return}const s=this.actions.find(r=>r.getClip()===e);if(!s){console.error("Could not find action",e);return}i!=null&&i.fadeDuration?s.fadeOut(i.fadeDuration):s.stop()}pause(e,i=!1){if(e===void 0){for(const r of this.actions)r.paused=!i;return}else if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(r=>r.name===e));if(!e){console.error("Could not find clip",e);return}const s=this.actions.find(r=>r.getClip()===e);if(!s){console.error("Could not find action",e);return}s.paused=!i}resume(){for(const e of this.actions)e.paused=!1}play(e=0,i){if(Ru&&console.log("PLAY",e),this.ensureMixer(),!this.mixer){Ru&&console.warn("Missing mixer",this);return}e===void 0&&(e=0);let s=e;if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}s=this.animations[e]}else typeof e=="string"&&(s=this.animations.find(o=>o.name===e));if(!s){console.error("Could not find clip",e);return}i||(i={});for(const o of this.actions)if(o.getClip()===s)return this.internalOnPlay(o,i);if(!s.tracks){console.warn("Clip is no AnimationClip",s);return}const r=this.mixer.clipAction(s);return this.actions.push(r),this.internalOnPlay(r,i)}internalOnPlay(e,i){var s=this.actions.find(o=>o===e);if(s===e&&s.isRunning()&&s.time<s.getClip().duration){const o=this.tryFindHandle(e);if(s.paused&&(s.paused=!1),o)return o.waitForFinish()}if(i.loop===void 0&&(i.loop=this.loop),i.clampWhenFinished===void 0&&(i.clampWhenFinished=this.clampWhenFinished),i.minMaxOffsetNormalized===void 0&&this.randomStartTime&&(i.minMaxOffsetNormalized=this.minMaxOffsetNormalized),i.minMaxSpeed===void 0&&(i.minMaxSpeed=this.minMaxSpeed),i?.exclusive??!0)for(const o of this.actions)o!=s&&(i.fadeDuration?o.fadeOut(i.fadeDuration):o.stop());if(i!=null&&i.fadeDuration&&e.fadeIn(i.fadeDuration),e.enabled=!0,i?.startTime!=null)e.time=i.startTime;else if(i!=null&&i.minMaxOffsetNormalized&&i.minMaxOffsetNormalized.x!=0&&i.minMaxOffsetNormalized.y!=0){const o=e.getClip();e.time=et.lerp(i.minMaxOffsetNormalized.x,i.minMaxOffsetNormalized.y,Math.random())*o.duration}else e.time>=e.getClip().duration&&(e.time=0);i!=null&&i.minMaxSpeed?e.timeScale=et.lerp(i.minMaxSpeed.x,i.minMaxSpeed.y,Math.random()):e.timeScale=i?.speed??1,i?.loop!=null?e.loop=i.loop?kR:rv:e.loop=rv,i!=null&&i.clampWhenFinished&&(e.clampWhenFinished=!0),e.paused=!1,e.play(),Ru&&console.log("PLAY",e.getClip().name,e);const r=new s0e(e,this.mixer,i,o=>{this._handles.splice(this._handles.indexOf(r),1)});return this._handles.push(r),r.waitForFinish()}tryFindHandle(e){for(const i of this._handles)if(i.action===e)return i}ensureMixer(){if(!this.mixer){const e="animationMixer";this.gameObject[e]&&(this.mixer=this.gameObject[e]),(!this.mixer||!this.mixer.clipAction)&&(this.mixer=new n_(this.gameObject),this.gameObject[e]=this.mixer)}this.context.animations.registerAnimationMixer(this.mixer)}}Nm([E()],zr.prototype,"playAutomatically",2),Nm([E()],zr.prototype,"randomStartTime",2),Nm([E(Jj)],zr.prototype,"minMaxSpeed",2),Nm([E(Jj)],zr.prototype,"minMaxOffsetNormalized",2),Nm([E()],zr.prototype,"loop",2),Nm([E()],zr.prototype,"clampWhenFinished",2),Nm([E(to)],zr.prototype,"clips",1);class s0e{constructor(e,i,s,r){p(this,"mixer"),p(this,"action"),p(this,"promise",null),p(this,"_options"),p(this,"_resolveCallback",null),p(this,"_resolvedOrRejectedCallback"),p(this,"onLoop",o=>{}),p(this,"onFinished",o=>{o.action===this.action&&this.onResolve()}),this.action=e,this.mixer=i,this._resolvedOrRejectedCallback=r,this._options=s}waitForFinish(){return this.promise?this.promise:(this.promise=new Promise(e=>{this._resolveCallback=e}),this.mixer.addEventListener("loop",this.onLoop),this.mixer.addEventListener("finished",this.onFinished),this.promise)}update(){this._options&&this._options.endTime!==void 0&&this.action.time>this._options.endTime&&(this._options.loop===!0?this.action.time=this._options.startTime??0:(this.action.time=this._options.endTime,this.action.timeScale=0,this.onResolve()))}onResolve(){var e,i;this.dispose(),(e=this._resolvedOrRejectedCallback)==null||e.call(this,this),(i=this._resolveCallback)==null||i.call(this,this.action)}dispose(){this.mixer.removeEventListener("loop",this.onLoop),this.mixer.removeEventListener("finished",this.onFinished)}}var r0e=Object.defineProperty,o0e=Object.getOwnPropertyDescriptor,Iu=(n,e,i,s)=>{for(var r=s>1?void 0:s?o0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&r0e(e,i,r),r};class mo{constructor(e=0,i=0){p(this,"time",0),p(this,"value",0),p(this,"inTangent",1/0),p(this,"inWeight"),p(this,"outTangent",1/0),p(this,"outWeight"),p(this,"weightedMode"),this.time=e,this.value=i}}Iu([E()],mo.prototype,"time",2),Iu([E()],mo.prototype,"value",2),Iu([E()],mo.prototype,"inTangent",2),Iu([E()],mo.prototype,"inWeight",2),Iu([E()],mo.prototype,"outTangent",2),Iu([E()],mo.prototype,"outWeight",2),Iu([E()],mo.prototype,"weightedMode",2);const wA=class{constructor(){p(this,"keys",[])}static linearFromTo(n,e,i){const s=new wA,r=new mo;r.time=0,r.value=n;const o=new mo;return o.time=i,o.value=e,s.keys.push(r,o),s}static constant(n){const e=new wA,i=new mo;return i.time=0,i.value=n,e.keys.push(i),e}clone(){var n;const e=new wA;return e.keys=((n=this.keys)==null?void 0:n.map(i=>{const s=new mo;return s.time=i.time,s.value=i.value,s.inTangent=i.inTangent,s.inWeight=i.inWeight,s.outTangent=i.outTangent,s.outWeight=i.outWeight,s.weightedMode=i.weightedMode,s}))||[],e}get duration(){return!this.keys||this.keys.length==0?0:this.keys[this.keys.length-1].time}evaluate(n){if(!this.keys||this.keys.length==0)return 0;if(this.keys.length===1)return this.keys[0].value;if(this.keys[0].time>=n)return this.keys[0].value;for(let e=0;e<this.keys.length;e++){const i=this.keys[e];if(i.time<=n)if(e+1<this.keys.length){const s=this.keys[e+1];if(s.time<n)continue;return!isFinite(i.outTangent)||!isFinite(s.inTangent)?i.value:wA.interpolateValue(n,i,s)}else return i.value}return this.keys[this.keys.length-1].value}static interpolateValue(n,e,i){const s=e.time,r=e.value,o=e.outTangent,a=i.time,l=i.value,c=i.inTangent,h=a-s,d=h*h,u=d*h,m=((o+c)*h-2*(l-r))/u,f=(3*(l-r)-(c+2*o)*h)/d,g=o,v=r,y=n-s,b=y*y,A=b*y;return m*A+f*b+g*y+v}};let Fm=wA;Iu([E(mo)],Fm.prototype,"keys",2);const YC=Symbol("objectIsAnimatedData");function qj(n,e,i){if(!n)return;if(n[YC]===void 0){if(!i)return;n[YC]=new Set}const s=n[YC];i?s.add(e):s.has(e)&&s.delete(e)}function a0e(n){if(!n)return!1;const e=n[YC];return e!==void 0&&e.size>0}class l0e{constructor(){p(this,"_context")}get context(){return this._context??Pt.Current}get isStateMachineBehaviour(){return!0}}class _A{constructor(e,i,s,r){p(this,"name"),p(this,"nameHash"),p(this,"normalizedTime"),p(this,"length"),p(this,"speed"),p(this,"action"),p(this,"hasTransitions");var o;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=i,this.length=s,this.speed=r,this.action=e.motion.action||null,this.hasTransitions=((o=e.transitions)==null?void 0:o.length)>0||!1}}function $j(n,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??oi.generateUUID(),index:-1,clip:new to(n,0,[])}}var Lu=(n=>(n[n.If=1]="If",n[n.IfNot=2]="IfNot",n[n.Greater=3]="Greater",n[n.Less=4]="Less",n[n.Equals=6]="Equals",n[n.NotEqual=7]="NotEqual",n))(Lu||{}),tO=(n=>(n[n.Float=1]="Float",n[n.Int=3]="Int",n[n.Bool=4]="Bool",n[n.Trigger=9]="Trigger",n))(tO||{});const _s=te("debuganimatorcontroller"),KC=te("debugrootmotion");class Ea{constructor(e){p(this,"_speed",1),p(this,"normalizedStartOffset",0),p(this,"animator"),p(this,"model"),p(this,"_mixer"),p(this,"_activeState"),p(this,"_activeStates",[]),p(this,"_heldActions",[]),p(this,"rootMotionHandler"),this.model=e,_s&&console.log(this)}static createFromClips(e,i={looping:!1,autoTransition:!0,transitionDuration:0}){const s=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(i.autoTransition!==!1){const h=i.transitionDuration??0,d=h/a.duration;let u=o;(i.autoTransition===void 0||i.autoTransition===!0)&&(u=(o+1)%e.length),l.push({exitTime:1-d,offset:0,duration:h,hasExitTime:!0,destinationState:u,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:i?.looping??!1},transitions:l,behaviours:[]};s.push(c)}const r={name:"AnimatorController",guid:new xr(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:s}}]};return new Ea(r)}play(e,i=-1,s=Number.NEGATIVE_INFINITY,r=0){if(i<0)i=0;else if(i>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[i].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){_s&&console.log("transition to ",a),this.transitionTo(a,r,s);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,i){var s,r;const o=typeof e=="string"?"name":"hash";return(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(a=>a[o]===e).forEach(a=>a.value=i)}getBool(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??!1}setFloat(e,i){var s,r;const o=typeof e=="string"?"name":"hash",a=(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(l=>l[o]===e);return a.forEach(l=>l.value=i),a?.length>0}getFloat(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??0}setInteger(e,i){var s,r;const o=typeof e=="string"?"name":"hash";return(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(a=>a[o]===e).forEach(a=>a.value=i)}getInteger(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??0}setTrigger(e){var i,s;_s&&console.log("SET TRIGGER",e);const r=typeof e=="string"?"name":"hash";return(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.filter(o=>o[r]===e).forEach(o=>o.value=!0)}resetTrigger(e){var i,s;const r=typeof e=="string"?"name":"hash";return(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.filter(o=>o[r]===e).forEach(o=>o.value=!1)}getTrigger(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const i of this.model.layers)for(const s of i.stateMachine.states)if(s.name===e||s.hash==e)return s}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const i=this._activeState.motion.clip.duration,s=i<=0?0:Math.abs(e.time/i);return new _A(this._activeState,s,i,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var e;return(e=this.animator)==null?void 0:e.context}get mixer(){return this._mixer}dispose(){var e;if(this._mixer.stopAllAction(),this.animator){this._mixer.uncacheRoot(this.animator.gameObject);for(const i of this._activeStates)i.motion.clip&&this.mixer.uncacheAction(i.motion.clip,this.animator.gameObject)}(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)}bind(e){var i,s;e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),(i=this.context)==null||i.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new n_(this.animator.gameObject),(s=this.context)==null||s.animations.registerAnimationMixer(this._mixer),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;_s&&console.warn("AnimatorController clone()",this.model);const e=Vv(this.model,(i,s,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||B5(r)||r.tracks!==void 0||r instanceof Ea));return console.assert(e!==this.model),new Ea(e)}update(e){var i,s;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const r=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onBeforeUpdate(e)),this._mixer.update(r),this.animator.applyRootMotion&&((s=this.rootMotionHandler)==null||s.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let i=0;i<this._activeStates.length;i++){const s=this._activeStates[i],r=s.motion;if(!r.action)this._activeStates.splice(i,1),i--;else{const o=r.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(_s&&console.debug("REMOVE",s.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(i,1),i--)}}}setStartTransition(){var e;this.model.layers.length>1&&(_s||je())&&console.warn("Multiple layers are not supported yet "+((e=this.animator)==null?void 0:e.name));for(const i of this.model.layers){const s=i.stateMachine;s.defaultState===void 0&&(_s&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",i),s.defaultState=0);const r=s.states[s.defaultState];this.transitionTo(r,0,this.normalizedStartOffset);break}}evaluateTransitions(){var e;let i=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;i=!0}const s=this._activeState,r=s.motion.action;for(const a of s.transitions){if(!a.hasExitTime&&a.conditions.length<=0)continue;let l=!0;for(const c of a.conditions)if(!this.evaluateCondition(c)){l=!1;break}if(l)if(r){const c=s.motion.clip.duration,h=c<=0?1:Math.abs(r.time/c);let d=a.exitTime;r.timeScale<0&&(d=1-d);let u=!1;if(a.hasExitTime?r.timeScale>0?u=h>=a.exitTime:r.timeScale<0&&(u=1-h>=a.exitTime):u=!0,u){for(const m of a.conditions){const f=this.model.parameters.find(g=>g.name===m.parameter);f?.type===tO.Trigger&&f.value&&(f.value=!1)}if(r.clampWhenFinished=!0,_s){const m=this.getState(a.destinationState,0);console.log(`Transition to ${a.destinationState} / ${m?.name}`,a,`
|
|
5870
|
+
}`}function Xj(n){return`(${n.r}, ${n.g}, ${n.b})`}function Wj(n){return`(${n.x}, ${n.y})`}const Hj=[1023,33777,33778,33779,35842,35843,37496,37808,37809,37810,37811,37812,37813,37814,37815,37816,37817,37818,37819,37820,37821,36492];te("debugusdz");const jj=class{constructor(n,e,i){p(this,"id"),p(this,"trigger"),p(this,"action"),p(this,"exclusive",!1),this.id="Behavior_"+Ul(n)+"_"+jj.global_id++,this.trigger=e,this.action=i}makeExclusive(n){return this.exclusive=n,this}writeTo(n,e,i){if(!this.trigger||!this.action)return;i.beginBlock(`def Preliminary_Behavior "${this.id}"`);let s="";if(Array.isArray(this.trigger)){s="[";for(let r=0;r<this.trigger.length;r++){const o=this.trigger[r];s+="<"+o.id+">",r+1<this.trigger.length&&(s+=", ")}s+="]"}else s=`<${this.trigger.id}>`;if(i.appendLine(`rel triggers = ${s}`),i.appendLine(`rel actions = <${this.action.id}>`),i.appendLine(`uniform bool exclusive = ${this.exclusive?1:0}`),i.appendLine(),Array.isArray(this.trigger))for(const r of this.trigger)r.writeTo(e,i),i.appendLine();else this.trigger.writeTo(e,i);i.appendLine(),this.action.writeTo(e,i),i.closeBlock()}};let Gs=jj;p(Gs,"global_id",0);const E0=new Set;function JB(n,e){var i,s;let r="";if(Array.isArray(n)){E0.clear();let o="[ ";for(let a=0;a<n.length;a++){let l=n[a];if(!l){console.warn("Invalid target object in behavior",n+". Is the object exported?");continue}if(typeof l=="string"){if(E0.has(l))continue;o+=l,E0.add(l)}else if(typeof l=="object"){if(l.isObject3D&&(l=e.findById(l.uuid),!l)){console.warn("Invalid target object in behavior",n+". Is the object exported?");continue}const c=(i=l.getPath)==null?void 0:i.call(l);if(E0.has(c))continue;o+=c,E0.add(c)}a+1<n.length&&(o+=", ")}o+=" ]",r=o,E0.clear()}else if(typeof n=="object"){const o=n;if(o.isObject3D&&(n=e.findById(o.uuid)),!n)throw console.error("Invalid target object in behavior, the target object is likely missing from USDZ export. Is the object exported?",o),new Error(`Invalid target object in behavior, the target object is likely missing from USDZ export. Please report a bug. uuid: ${o.uuid}.`);r=(s=n.getPath)==null?void 0:s.call(n)}return r}const Qj=class{constructor(n,e){p(this,"id"),p(this,"targetId"),p(this,"tokenId"),p(this,"type"),p(this,"distance"),n&&(this.targetId=n),e?this.id=e:this.id="Trigger_"+Qj.global_id++}writeTo(n,e){e.beginBlock(`def Preliminary_Trigger "${this.id}"`),this.targetId&&(typeof this.targetId!="string"&&(this.targetId=JB(this.targetId,n)),e.appendLine("rel affectedObjects = "+this.targetId)),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.type&&e.appendLine(`token type = "${this.type}"`),typeof this.distance=="number"&&e.appendLine(`double distance = ${this.distance}`),e.closeBlock()}};let Eu=Qj;p(Eu,"global_id",0);function Zj(n,e={direct:!0,indirect:!0}){const i=ho.createEmpty();i.name="InputTarget_"+i.name,i.displayName=void 0,i.type="RealityKitComponent",i.onSerialize=s=>{s.appendLine("bool allowsDirectInput = "+(e.direct?1:0)),s.appendLine("bool allowsIndirectInput = "+(e.indirect?1:0)),s.appendLine('uniform token info:id = "RealityKit.InputTarget"')},n.add(i)}class Ns{static sceneStartTrigger(){const e=new Eu;return e.targetId=void 0,e.tokenId="SceneTransition",e.type="enter",e}static tapTrigger(e,i={direct:!0,indirect:!0}){const s=new Eu(e);if(Array.isArray(e)&&e.length>1)for(const r of e)r instanceof ho&&Zj(r,i);else e instanceof ho&&Zj(e,i);return s.tokenId="TapGesture",s}static isTapTrigger(e){return e?.tokenId==="TapGesture"}static proximityToCameraTrigger(e,i){const s=new Eu(e);return s.tokenId="ProximityToCamera",s.distance=i,s}}class jh{constructor(e,i){p(this,"id"),p(this,"actions"),p(this,"loops",0),p(this,"performCount",1),p(this,"type","serial"),p(this,"multiplePerformOperation"),this.id=e,this.actions=i}static getId(){return this.global_id++}addAction(e){return this.actions.push(e),this}makeParallel(){return this.type="parallel",this}makeSequence(){return this.type="serial",this}makeLooping(){return this.loops=1,this.performCount=0,this}makeRepeat(e){return this.performCount=e,this}writeTo(e,i){i.beginBlock(`def Preliminary_Action "${this.id}"`),i.beginArray("rel actions");for(const s of this.actions){if(!s)continue;const r=s===this.actions[this.actions.length-1];i.appendLine("<"+s.id+">"+(r?"":", "))}i.closeArray(),i.appendLine(),i.appendLine('token info:id = "Group"'),i.appendLine(`bool loops = ${this.loops}`),i.appendLine(`int performCount = ${this.loops>0?0:Math.max(0,this.performCount)}`),i.appendLine(`token type = "${this.type}"`),typeof this.multiplePerformOperation=="string"&&i.appendLine(`token multiplePerformOperation = "${this.multiplePerformOperation}"`),i.appendLine();for(const s of this.actions)s&&(s.writeTo(e,i),i.appendLine());i.closeBlock()}}p(jh,"global_id",0);const qB=class{constructor(n,e){p(this,"id"),p(this,"tokenId"),p(this,"affectedObjects"),p(this,"easeType"),p(this,"motionType"),p(this,"duration"),p(this,"moveDistance"),p(this,"style"),p(this,"type"),p(this,"front"),p(this,"up"),p(this,"start"),p(this,"animationSpeed"),p(this,"reversed"),p(this,"pingPong"),p(this,"xFormTarget"),p(this,"audio"),p(this,"gain"),p(this,"auralMode"),p(this,"multiplePerformOperation"),p(this,"velocity"),p(this,"comment"),p(this,"animationName"),n&&(this.affectedObjects=n),e?this.id=e:this.id="Action",this.id+="_"+qB.global_id++}clone(){const n=new qB,e=n.id;return Object.assign(n,this),n.id=e,n}writeTo(n,e){e.beginBlock(`def Preliminary_Action "${this.id}"`),this.comment&&e.appendLine(`# ${this.comment}`),this.affectedObjects&&(typeof this.affectedObjects!="string"&&(this.affectedObjects=JB(this.affectedObjects,n)),e.appendLine("rel affectedObjects = "+this.affectedObjects)),typeof this.duration=="number"&&(typeof this.animationSpeed=="number"&&this.animationSpeed!==1?e.appendLine(`double duration = ${this.duration/this.animationSpeed} `):e.appendLine(`double duration = ${this.duration} `)),this.easeType&&e.appendLine(`token easeType = "${this.easeType}"`),this.tokenId&&e.appendLine(`token info:id = "${this.tokenId}"`),this.tokenId==="ChangeScene"&&e.appendLine("rel scene = </StageRoot/Scenes/Scene>"),this.motionType!==void 0&&e.appendLine(`token motionType = "${this.motionType}"`),typeof this.moveDistance=="number"&&e.appendLine(`double moveDistance = ${this.moveDistance} `),this.style&&e.appendLine(`token style = "${this.style}"`),this.type&&e.appendLine(`token type = "${this.type}"`),this.front&&e.appendLine(`vector3d front = (${this.front.x}, ${this.front.y}, ${this.front.z})`),this.up&&e.appendLine(`vector3d upVector = (${this.up.x}, ${this.up.y}, ${this.up.z})`),typeof this.start=="number"&&e.appendLine(`double start = ${this.start} `),typeof this.animationSpeed=="number"&&e.appendLine(`double animationSpeed = ${this.animationSpeed.toFixed(2)} `),typeof this.reversed=="boolean"&&e.appendLine(`bool reversed = ${this.reversed}`),typeof this.pingPong=="boolean"&&e.appendLine(`bool reverses = ${this.pingPong}`),this.xFormTarget&&(typeof this.xFormTarget!="string"&&(this.xFormTarget=JB(this.xFormTarget,n)),e.appendLine(`rel xformTarget = ${this.xFormTarget}`)),typeof this.audio=="string"&&e.appendLine(`asset audio = @${this.audio}@`),typeof this.gain=="number"&&e.appendLine(`double gain = ${this.gain}`),typeof this.auralMode=="string"&&e.appendLine(`token auralMode = "${this.auralMode}"`),typeof this.multiplePerformOperation=="string"&&e.appendLine(`token multiplePerformOperation = "${this.multiplePerformOperation}"`),typeof this.velocity=="object"&&e.appendLine(`vector3d velocity = (${this.velocity.x}, ${this.velocity.y}, ${this.velocity.z})`),e.closeBlock()}};let aa=qB;p(aa,"global_id",0);let T0=class Wy{constructor(e,i,s){p(this,"x",0),p(this,"y",0),p(this,"z",0),this.x=e,this.y=i,this.z=s}static get up(){return new Wy(0,1,0)}static get right(){return new Wy(1,0,0)}static get forward(){return new Wy(0,0,1)}static get back(){return new Wy(0,0,-1)}static get zero(){return new Wy(0,0,0)}};class vi{static sequence(...e){return new jh("Group_"+jh.getId(),e).makeSequence()}static parallel(...e){return new jh("Group_"+jh.getId(),e).makeParallel()}static fadeAction(e,i,s){const r=new aa(e);return r.tokenId="Visibility",r.type=s?"show":"hide",r.duration=i,r.style="basic",r.motionType="none",r.moveDistance=0,r.easeType="none",r}static startAnimationAction(e,i,s=!1,r=!1){const o=new aa(e);o.tokenId="StartAnimation";const a=i.start,l=i.duration,c=i.speed,h=i.clipName;if(o.comment=`Animation: ${h}, start=${a*60}, length=${l*60}, end=${(a+l)*60}`,o.animationName=h,o.start=a,o.duration=l,o.animationSpeed=c,o.reversed=s,o.pingPong=r,o.multiplePerformOperation="allow",s&&(o.start-=l),r){o.pingPong=!1;const d=o.clone();return d.reversed=!s,d.start=o.start,d.reversed&&(d.start-=l),vi.sequence(o,d)}return o}static waitAction(e){const i=new aa;return i.tokenId="Wait",i.duration=e,i.motionType=void 0,i}static lookAtCameraAction(e,i,s,r){const o=new aa(e);return o.tokenId="LookAtCamera",o.duration=i===void 0?9999999999999:i,o.front=s??T0.forward,o.up=r??T0.up,o}static emphasize(e,i,s="bounce",r=1,o="basic"){const a=new aa(e);return a.tokenId="Emphasize",a.duration=i,a.style=o??"basic",a.motionType=s,a.moveDistance=r,a}static transformAction(e,i,s,r,o="inout"){const a=new aa(e);return a.tokenId="Transform",a.duration=s,a.duration=Math.max(1e-6,s),a.type=r,a.easeType=s>0?o:"none",Array.isArray(i)&&console.error("Transform target must not be an array",i),a.xFormTarget=i,a}static playAudioAction(e,i,s="play",r=1,o="spatial"){const a=new aa(e);return a.tokenId="Audio",a.type=s,a.audio=i,a.gain=r,a.auralMode=o,a.multiplePerformOperation="allow",a}static impulseAction(e,i){const s=new aa(e);return s.tokenId="Impulse",s.velocity=i,s}}class qge{constructor(e){p(this,"object"),p(this,"model"),this.object=e}get id(){return this.object.uuid}apply(e){if(!this.model&&(this.model=e.findById(this.object.uuid),!this.model)){console.error("could not find model with id "+this.object.uuid);return}this.onApply(e)}}class $B extends qge{constructor(e,i,s,r){super(e),p(this,"matrix"),p(this,"material"),p(this,"geometry"),p(this,"_enableAction"),p(this,"_disableAction"),this.matrix=i,this.material=s,this.geometry=r}onApply(e){var i,s;const r=this.model;if(!r)return;(i=r.parent)!=null&&i.isDynamic||ho.createEmptyParent(r);const o=r.clone();this.matrix&&o.setMatrix(this.matrix),this.material&&(o.material=this.material),this.geometry&&(o.geometry=this.geometry),(s=r.parent)==null||s.add(o)}enable(){return this._enableAction?this._enableAction:(this._enableAction=vi.fadeAction(this.object,0,!0),this._enableAction)}disable(){return this._disableAction?this._disableAction:(this._disableAction=vi.fadeAction(this.object,0,!1),this._disableAction)}}class eO{constructor(e){p(this,"actions"),p(this,"sortedActions"),this.actions=[...e]}organize(){this.sortedActions={};for(const e of this.actions){const i=e.id;this.sortedActions[i]||(this.sortedActions[i]=[]),this.sortedActions[i].push(e)}}getActions(e){return this.sortedActions||this.organize(),this.sortedActions[e.uuid]}}const R0=function(n){return E(n)},E=function(n){if(n===void 0&&(n=null),!Array.isArray(n))n=Yj(n);else for(let e=0;e<n.length;e++){const i=n[e];n[e]=Yj(i)}return function(e,i){typeof i!="string"&&(i=i.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const s=e.$serializedTypes=e.$serializedTypes||{};s[i]=n}};function Yj(n){var e,i;switch((i=(e=n?.prototype)==null?void 0:e.constructor)==null?void 0:i.name){case"Number":case"String":case"Boolean":return null}return n}class ie extends ge{constructor(){super(...arguments),p(this,"guid")}static isDestroyed(e){return Lm(e)}static setActive(e,i,s=!0){e&&(lA(e,i),qS(e),i&&s&&E9(Pt.Current,e))}static isActiveSelf(e){return p0(e)}static isActiveInHierarchy(e){return u4(e)}static markAsInstancedRendered(e,i){p4(e,i)}static isUsingInstancing(e){return pC(e)}static foreachComponent(e,i,s=!0){return Pm(e,i,s)}static instantiateSynced(e,i){return e?Qk(e,i):null}static instantiate(e,i=null){return f0(e,i)}static destroySynced(e,i,s=!0){if(!e)return;const r=e;i=i??Pt.Current,qb(r,i.connection,s)}static destroy(e,i=!0){return oa(e,i)}static add(e,i,s){if(!(!e||!i)){if(e===i){console.warn("Can not add object to self",e);return}s||(s=Pt.Current),i.add(e),lA(e,!0),qS(e),s?ie.foreachComponent(e,r=>{Fk(r,s),!r.__internalDidAwakeAndStart&&s.new_script_start.includes(r)===!1&&s.new_script_start.push(r)},!0):console.warn("Missing context")}}static remove(e){var i;e&&((i=e.parent)==null||i.remove(e),lA(e,!1),qS(e),ie.foreachComponent(e,s=>{ume(s)},!0))}static invokeOnChildren(e,i,...s){this.invoke(e,i,!0,s)}static invoke(e,i,s=!1,...r){e&&this.foreachComponent(e,o=>{const a=o[i];a&&typeof a=="function"&&a?.call(o,...r)},s)}static addNewComponent(e,i,s,r=!0){return ra(e,i,s,{callAwake:r})}static addComponent(e,i,s,r){return ra(e,i,s,r)}static moveComponent(e,i){return ra(e,i)}static removeComponent(e){return rB(e.gameObject,e),e}static getOrAddComponent(e,i){return sA(e,i)}static getComponent(e,i){return e===null?null:Im(e,i)}static getComponents(e,i,s=null){return e===null?s??[]:rA(e,i,s)}static findByGuid(e,i){return oB(e,i)}static findObjectOfType(e,i,s=!0){return cC(e,i??Pt.Current,s)}static findObjectsOfType(e,i){const s=[];return h4(e,s,i),s}static getComponentInChildren(e,i){return oA(e,i)}static getComponentsInChildren(e,i,s=null){return u0(e,i,s??void 0)}static getComponentInParent(e,i){return aA(e,i)}static getComponentsInParent(e,i,s=null){return lC(e,i,s)}static getAllComponents(e){var i;const s=(i=e.userData)==null?void 0:i.components;return s?[...s]:[]}static*iterateComponents(e){var i;const s=(i=e?.userData)==null?void 0:i.components;if(s&&Array.isArray(s))for(let r=0;r<s.length;r++)yield s[r]}}var Tu;let Pe=(Tu=class{constructor(n){p(this,"__context"),p(this,"__name"),p(this,"gameObject"),p(this,"guid","invalid"),p(this,"sourceId"),p(this,"__didAwake",!1),p(this,"__didStart",!1),p(this,"__didEnable",!1),p(this,"__isEnabled"),p(this,"__destroyed",!1),p(this,"_eventListeners",new Map),this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(n)}get isComponent(){return!0}get context(){return this.__context??Pt.Current}set context(n){this.__context=n}get scene(){return this.context.scene}get layer(){var n,e;return(e=(n=this.gameObject)==null?void 0:n.userData)==null?void 0:e.layer}get name(){var n,e;return(n=this.gameObject)!=null&&n.name?this.gameObject.name:(e=this.gameObject)==null?void 0:e.userData.name}set name(n){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=n,this.__name=n):this.__name=n}get tag(){var n;return(n=this.gameObject)==null?void 0:n.userData.tag}set tag(n){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=n)}get static(){var n;return(n=this.gameObject)==null?void 0:n.userData.static}set static(n){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.static=n)}get hideFlags(){var n;return(n=this.gameObject)==null?void 0:n.userData.hideFlags}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const n=this.gameObject[Ch];return n===void 0?!0:n}set __isActiveInHierarchy(n){this.gameObject&&(this.gameObject[Ch]=n)}awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(n,e=Ji.Update){return this.context.registerCoroutineUpdate(this,n,e)}stopCoroutine(n,e=Ji.Update){this.context.unregisterCoroutineUpdate(n,e)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}__internalNewInstanceCreated(n){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(n),this}_internalInit(n){if(typeof n=="object")for(const e of Object.keys(n)){const i=n[e];typeof i!="function"&&(this[e]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(n){return this.__destroyed?(je()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(n!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(n){if(this.__didAwake){if(!this.__didEnable){n!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){var n;this.__destroyed||(this.__destroyed=!0,this.__didAwake&&((n=this.onDestroy)==null||n.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),a4(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(n){if(this.__destroyed){je()&&console.warn(`[Needle Engine Dev] Trying to ${n?"enable":"disable"} destroyed component`);return}if(typeof n=="number"&&(n>=.5?n=!0:n=!1),!this.__didAwake){this.__isEnabled=n;return}n?this.__internalEnable():this.__internalDisable()}get worldPosition(){return Nt(this.gameObject)}set worldPosition(n){bs(this.gameObject,n)}setWorldPosition(n,e,i){nm(this.gameObject,n,e,i)}get worldQuaternion(){return Bi(this.gameObject)}set worldQuaternion(n){Ba(this.gameObject,n)}setWorldQuaternion(n,e,i,s){cL(this.gameObject,n,e,i,s)}get worldEuler(){return dL(this.gameObject)}set worldEuler(n){uL(this.gameObject,n)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(n){this.setWorldRotation(n.x,n.y,n.z,!0)}setWorldRotation(n,e,i,s=!0){Kv(this.gameObject,n,e,i,s)}get forward(){return Tu._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}get right(){return Tu._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}get up(){return Tu._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}addEventListener(n,e){this._eventListeners[n]=this._eventListeners[n]||[],this._eventListeners[n].push(e)}removeEventListener(n,e){if(!this._eventListeners[n])return;const i=this._eventListeners[n].indexOf(e);i>=0&&this._eventListeners[n].splice(i,1)}dispatchEvent(n){if(!n||!this._eventListeners[n.type])return!1;const e=this._eventListeners[n.type];for(let i=0;i<e.length;i++)e[i](n);return!1}},p(Tu,"_forward",new M),p(Tu,"_right",new M),p(Tu,"_up",new M),Tu);const $ge=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:Pe,Component:Pe,GameObject:ie},Symbol.toStringTag,{value:"Module"}));var e0e=Object.defineProperty,t0e=Object.getOwnPropertyDescriptor,Kj=(n,e,i,s)=>{for(var r=s>1?void 0:s?t0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&e0e(e,i,r),r};class xA extends Pe{constructor(){super(...arguments),p(this,"from"),p(this,"to"),p(this,"width",0),p(this,"centered",!0),p(this,"_centerPos")}awake(){this._centerPos=new M}update(){if(!this.from||!this.to)return;const e=Nt(this.from).clone(),i=Nt(this.to).clone(),s=e.distanceTo(i);this._centerPos.copy(e),this._centerPos.add(i),this._centerPos.multiplyScalar(.5),bs(this.gameObject,this.centered?this._centerPos:e),this.gameObject.lookAt(Nt(this.to).clone()),this.gameObject.scale.set(this.width,this.width,s)}}Kj([E(ie)],xA.prototype,"from",2),Kj([E(ie)],xA.prototype,"to",2);var i0e=Object.defineProperty,n0e=Object.getOwnPropertyDescriptor,Nm=(n,e,i,s)=>{for(var r=s>1?void 0:s?n0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&i0e(e,i,r),r};const Ru=te("debuganimation");let Jj=class{constructor(){p(this,"x"),p(this,"y")}};class zr extends Pe{constructor(){super(...arguments),p(this,"playAutomatically",!0),p(this,"randomStartTime",!0),p(this,"minMaxSpeed"),p(this,"minMaxOffsetNormalized"),p(this,"loop",!0),p(this,"clampWhenFinished",!1),p(this,"_tempAnimationClipBeforeGameObjectExisted",null),p(this,"_tempAnimationsArray"),p(this,"mixer"),p(this,"_actions"),p(this,"_handles")}get isAnimationComponent(){return!0}addClip(e){this.animations||(this.animations=[]),this.animations.push(e)}get time(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.time}return 0}set time(e){if(this.actions)for(const i of this.actions)i.time=e}get clip(){var e;return(e=this.animations)!=null&&e.length?this.animations[0]:null}set clip(e){if(!this.__didAwake){Ru&&console.warn("Assign clip during serialization",e),this._tempAnimationClipBeforeGameObjectExisted=e;return}e&&(this.gameObject.animations||(this.gameObject.animations=[]),!this.animations.includes(e)&&(this.animations.length>0?this.animations.splice(0,0,e):this.animations.push(e)))}set clips(e){this.animations=e}set animations(e){e==null||!Array.isArray(e)||(this.gameObject?this.gameObject.animations=e:this._tempAnimationsArray=e)}get animations(){return this.gameObject.animations||this._tempAnimationsArray||[]}get actions(){return this._actions}set actions(e){this._actions=e}awake(){this.mixer=void 0,Ru&&console.log("Animation Awake",this.name,this),this._tempAnimationsArray&&(this.animations=this._tempAnimationsArray,this._tempAnimationsArray=void 0),this._tempAnimationClipBeforeGameObjectExisted&&(this.clip=this._tempAnimationClipBeforeGameObjectExisted,this._tempAnimationClipBeforeGameObjectExisted=null),this.actions=[],this._handles=[]}onEnable(){var e;if(this.playAutomatically&&((e=this.animations)==null?void 0:e.length)>0){const i=Math.floor(Math.random()*this.animations.length),s=this.animations[i];this.play(i,{exclusive:!0,fadeDuration:0,startTime:this.randomStartTime?Math.random()*s.duration:0,loop:this.loop,clampWhenFinished:this.clampWhenFinished})}}update(){this.mixer&&(this.mixer.update(this.context.time.deltaTime),this._handles.forEach(e=>e.update()))}onDisable(){this.mixer&&this.mixer.stopAllAction()}onDestroy(){this.context.animations.unregisterAnimationMixer(this.mixer)}getAction(e){var i;return((i=this.actions)==null?void 0:i.find(s=>s.getClip().name===e))||null}get isPlaying(){if(this.actions){for(let e=0;e<this.actions.length;e++)if(this.actions[e].isRunning())return!0}return!1}stopAll(e){if(this.actions)for(const i of this.actions)e!=null&&e.fadeDuration?i.fadeOut(e.fadeDuration):i.stop()}stop(e,i){if(e===void 0){this.stopAll();return}else if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(r=>r.name===e));if(!e){console.error("Could not find clip",e);return}const s=this.actions.find(r=>r.getClip()===e);if(!s){console.error("Could not find action",e);return}i!=null&&i.fadeDuration?s.fadeOut(i.fadeDuration):s.stop()}pause(e,i=!1){if(e===void 0){for(const r of this.actions)r.paused=!i;return}else if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(r=>r.name===e));if(!e){console.error("Could not find clip",e);return}const s=this.actions.find(r=>r.getClip()===e);if(!s){console.error("Could not find action",e);return}s.paused=!i}resume(){for(const e of this.actions)e.paused=!1}play(e=0,i){if(Ru&&console.log("PLAY",e),this.ensureMixer(),!this.mixer){Ru&&console.warn("Missing mixer",this);return}e===void 0&&(e=0);let s=e;if(typeof e=="number"){if(e>=this.animations.length){Ru&&console.log("No animation at index",e);return}s=this.animations[e]}else typeof e=="string"&&(s=this.animations.find(o=>o.name===e));if(!s){console.error("Could not find clip",e);return}i||(i={});for(const o of this.actions)if(o.getClip()===s)return this.internalOnPlay(o,i);if(!s.tracks){console.warn("Clip is no AnimationClip",s);return}const r=this.mixer.clipAction(s);return this.actions.push(r),this.internalOnPlay(r,i)}internalOnPlay(e,i){var s=this.actions.find(o=>o===e);if(s===e&&s.isRunning()&&s.time<s.getClip().duration){const o=this.tryFindHandle(e);if(s.paused&&(s.paused=!1),o)return o.waitForFinish()}if(i.loop===void 0&&(i.loop=this.loop),i.clampWhenFinished===void 0&&(i.clampWhenFinished=this.clampWhenFinished),i.minMaxOffsetNormalized===void 0&&this.randomStartTime&&(i.minMaxOffsetNormalized=this.minMaxOffsetNormalized),i.minMaxSpeed===void 0&&(i.minMaxSpeed=this.minMaxSpeed),i?.exclusive??!0)for(const o of this.actions)o!=s&&(i.fadeDuration?o.fadeOut(i.fadeDuration):o.stop());if(i!=null&&i.fadeDuration&&e.fadeIn(i.fadeDuration),e.enabled=!0,i?.startTime!=null)e.time=i.startTime;else if(i!=null&&i.minMaxOffsetNormalized&&i.minMaxOffsetNormalized.x!=0&&i.minMaxOffsetNormalized.y!=0){const o=e.getClip();e.time=et.lerp(i.minMaxOffsetNormalized.x,i.minMaxOffsetNormalized.y,Math.random())*o.duration}else e.time>=e.getClip().duration&&(e.time=0);i!=null&&i.minMaxSpeed?e.timeScale=et.lerp(i.minMaxSpeed.x,i.minMaxSpeed.y,Math.random()):e.timeScale=i?.speed??1,i?.loop!=null?e.loop=i.loop?kR:rv:e.loop=rv,i!=null&&i.clampWhenFinished&&(e.clampWhenFinished=!0),e.paused=!1,e.play(),Ru&&console.log("PLAY",e.getClip().name,e);const r=new s0e(e,this.mixer,i,o=>{this._handles.splice(this._handles.indexOf(r),1)});return this._handles.push(r),r.waitForFinish()}tryFindHandle(e){for(const i of this._handles)if(i.action===e)return i}ensureMixer(){if(!this.mixer){const e="animationMixer";this.gameObject[e]&&(this.mixer=this.gameObject[e]),(!this.mixer||!this.mixer.clipAction)&&(this.mixer=new n_(this.gameObject),this.gameObject[e]=this.mixer)}this.context.animations.registerAnimationMixer(this.mixer)}}Nm([E()],zr.prototype,"playAutomatically",2),Nm([E()],zr.prototype,"randomStartTime",2),Nm([E(Jj)],zr.prototype,"minMaxSpeed",2),Nm([E(Jj)],zr.prototype,"minMaxOffsetNormalized",2),Nm([E()],zr.prototype,"loop",2),Nm([E()],zr.prototype,"clampWhenFinished",2),Nm([E(to)],zr.prototype,"clips",1);class s0e{constructor(e,i,s,r){p(this,"mixer"),p(this,"action"),p(this,"promise",null),p(this,"_options"),p(this,"_resolveCallback",null),p(this,"_resolvedOrRejectedCallback"),p(this,"onLoop",o=>{}),p(this,"onFinished",o=>{o.action===this.action&&this.onResolve()}),this.action=e,this.mixer=i,this._resolvedOrRejectedCallback=r,this._options=s}waitForFinish(){return this.promise?this.promise:(this.promise=new Promise(e=>{this._resolveCallback=e}),this.mixer.addEventListener("loop",this.onLoop),this.mixer.addEventListener("finished",this.onFinished),this.promise)}update(){this._options&&this._options.endTime!==void 0&&this.action.time>this._options.endTime&&(this._options.loop===!0?this.action.time=this._options.startTime??0:(this.action.time=this._options.endTime,this.action.timeScale=0,this.onResolve()))}onResolve(){var e,i;this.dispose(),(e=this._resolvedOrRejectedCallback)==null||e.call(this,this),(i=this._resolveCallback)==null||i.call(this,this.action)}dispose(){this.mixer.removeEventListener("loop",this.onLoop),this.mixer.removeEventListener("finished",this.onFinished)}}var r0e=Object.defineProperty,o0e=Object.getOwnPropertyDescriptor,Iu=(n,e,i,s)=>{for(var r=s>1?void 0:s?o0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&r0e(e,i,r),r};class mo{constructor(e=0,i=0){p(this,"time",0),p(this,"value",0),p(this,"inTangent",1/0),p(this,"inWeight"),p(this,"outTangent",1/0),p(this,"outWeight"),p(this,"weightedMode"),this.time=e,this.value=i}}Iu([E()],mo.prototype,"time",2),Iu([E()],mo.prototype,"value",2),Iu([E()],mo.prototype,"inTangent",2),Iu([E()],mo.prototype,"inWeight",2),Iu([E()],mo.prototype,"outTangent",2),Iu([E()],mo.prototype,"outWeight",2),Iu([E()],mo.prototype,"weightedMode",2);const wA=class{constructor(){p(this,"keys",[])}static linearFromTo(n,e,i){const s=new wA,r=new mo;r.time=0,r.value=n;const o=new mo;return o.time=i,o.value=e,s.keys.push(r,o),s}static constant(n){const e=new wA,i=new mo;return i.time=0,i.value=n,e.keys.push(i),e}clone(){var n;const e=new wA;return e.keys=((n=this.keys)==null?void 0:n.map(i=>{const s=new mo;return s.time=i.time,s.value=i.value,s.inTangent=i.inTangent,s.inWeight=i.inWeight,s.outTangent=i.outTangent,s.outWeight=i.outWeight,s.weightedMode=i.weightedMode,s}))||[],e}get duration(){return!this.keys||this.keys.length==0?0:this.keys[this.keys.length-1].time}evaluate(n){if(!this.keys||this.keys.length==0)return 0;if(this.keys.length===1)return this.keys[0].value;if(this.keys[0].time>=n)return this.keys[0].value;for(let e=0;e<this.keys.length;e++){const i=this.keys[e];if(i.time<=n)if(e+1<this.keys.length){const s=this.keys[e+1];if(s.time<n)continue;return!isFinite(i.outTangent)||!isFinite(s.inTangent)?i.value:wA.interpolateValue(n,i,s)}else return i.value}return this.keys[this.keys.length-1].value}static interpolateValue(n,e,i){const s=e.time,r=e.value,o=e.outTangent,a=i.time,l=i.value,c=i.inTangent,h=a-s,d=h*h,u=d*h,m=((o+c)*h-2*(l-r))/u,f=(3*(l-r)-(c+2*o)*h)/d,g=o,v=r,y=n-s,b=y*y,A=b*y;return m*A+f*b+g*y+v}};let Fm=wA;Iu([E(mo)],Fm.prototype,"keys",2);const YC=Symbol("objectIsAnimatedData");function qj(n,e,i){if(!n)return;if(n[YC]===void 0){if(!i)return;n[YC]=new Set}const s=n[YC];i?s.add(e):s.has(e)&&s.delete(e)}function a0e(n){if(!n)return!1;const e=n[YC];return e!==void 0&&e.size>0}class l0e{constructor(){p(this,"_context")}get context(){return this._context??Pt.Current}get isStateMachineBehaviour(){return!0}}class _A{constructor(e,i,s,r){p(this,"name"),p(this,"nameHash"),p(this,"normalizedTime"),p(this,"length"),p(this,"speed"),p(this,"action"),p(this,"hasTransitions");var o;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=i,this.length=s,this.speed=r,this.action=e.motion.action||null,this.hasTransitions=((o=e.transitions)==null?void 0:o.length)>0||!1}}function $j(n,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??oi.generateUUID(),index:-1,clip:new to(n,0,[])}}var Lu=(n=>(n[n.If=1]="If",n[n.IfNot=2]="IfNot",n[n.Greater=3]="Greater",n[n.Less=4]="Less",n[n.Equals=6]="Equals",n[n.NotEqual=7]="NotEqual",n))(Lu||{}),tO=(n=>(n[n.Float=1]="Float",n[n.Int=3]="Int",n[n.Bool=4]="Bool",n[n.Trigger=9]="Trigger",n))(tO||{});const _s=te("debuganimatorcontroller"),KC=te("debugrootmotion");class Ea{constructor(e){p(this,"_speed",1),p(this,"normalizedStartOffset",0),p(this,"animator"),p(this,"model"),p(this,"_mixer"),p(this,"_activeState"),p(this,"_activeStates",[]),p(this,"_heldActions",[]),p(this,"rootMotionHandler"),this.model=e,_s&&console.log(this)}static createFromClips(e,i={looping:!1,autoTransition:!0,transitionDuration:0}){const s=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(i.autoTransition!==!1){const h=i.transitionDuration??0,d=h/a.duration;let u=o;(i.autoTransition===void 0||i.autoTransition===!0)&&(u=(o+1)%e.length),l.push({exitTime:1-d,offset:0,duration:h,hasExitTime:!0,destinationState:u,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:i?.looping??!1},transitions:l,behaviours:[]};s.push(c)}const r={name:"AnimatorController",guid:new xr(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:s}}]};return new Ea(r)}play(e,i=-1,s=Number.NEGATIVE_INFINITY,r=0){if(i<0)i=0;else if(i>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[i].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){_s&&console.log("transition to ",a),this.transitionTo(a,r,s);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,i){var s,r;const o=typeof e=="string"?"name":"hash";return(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(a=>a[o]===e).forEach(a=>a.value=i)}getBool(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??!1}setFloat(e,i){var s,r;const o=typeof e=="string"?"name":"hash",a=(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(l=>l[o]===e);return a.forEach(l=>l.value=i),a?.length>0}getFloat(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??0}setInteger(e,i){var s,r;const o=typeof e=="string"?"name":"hash";return(r=(s=this.model)==null?void 0:s.parameters)==null?void 0:r.filter(a=>a[o]===e).forEach(a=>a.value=i)}getInteger(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??0}setTrigger(e){var i,s;_s&&console.log("SET TRIGGER",e);const r=typeof e=="string"?"name":"hash";return(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.filter(o=>o[r]===e).forEach(o=>o.value=!0)}resetTrigger(e){var i,s;const r=typeof e=="string"?"name":"hash";return(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.filter(o=>o[r]===e).forEach(o=>o.value=!1)}getTrigger(e){var i,s,r;const o=typeof e=="string"?"name":"hash";return((r=(s=(i=this.model)==null?void 0:i.parameters)==null?void 0:s.find(a=>a[o]===e))==null?void 0:r.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const i of this.model.layers)for(const s of i.stateMachine.states)if(s.name===e||s.hash==e)return s}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const i=this._activeState.motion.clip.duration,s=i<=0?0:Math.abs(e.time/i);return new _A(this._activeState,s,i,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var e;return(e=this.animator)==null?void 0:e.context}get mixer(){return this._mixer}dispose(){var e;if(this._mixer.stopAllAction(),this.animator){this._mixer.uncacheRoot(this.animator.gameObject);for(const i of this._activeStates)i.motion.clip&&this.mixer.uncacheAction(i.motion.clip,this.animator.gameObject)}(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)}bind(e){var i,s;e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),(i=this.context)==null||i.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new n_(this.animator.gameObject),(s=this.context)==null||s.animations.registerAnimationMixer(this._mixer),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;_s&&console.warn("AnimatorController clone()",this.model);const e=Vv(this.model,(i,s,r)=>r==null?!0:!(r.type==="Object3D"||r.isObject3D===!0||B5(r)||r.tracks!==void 0||r instanceof Ea));return console.assert(e!==this.model),new Ea(e)}update(e){var i,s;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const r=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onBeforeUpdate(e)),this._mixer.update(r),this.animator.applyRootMotion&&((s=this.rootMotionHandler)==null||s.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let i=0;i<this._activeStates.length;i++){const s=this._activeStates[i],r=s.motion;if(!r.action)this._activeStates.splice(i,1),i--;else{const o=r.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(_s&&console.debug("REMOVE",s.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(i,1),i--)}}}setStartTransition(){var e;this.model.layers.length>1&&(_s||je())&&console.warn("Multiple layers are not supported yet "+((e=this.animator)==null?void 0:e.name));for(const i of this.model.layers){const s=i.stateMachine;s.defaultState===void 0&&(_s&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",i),s.defaultState=0);const r=s.states[s.defaultState];this.transitionTo(r,0,this.normalizedStartOffset);break}}evaluateTransitions(){var e;let i=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;i=!0}const s=this._activeState,r=s.motion.action;for(const a of s.transitions){if(!a.hasExitTime&&a.conditions.length<=0)continue;let l=!0;for(const c of a.conditions)if(!this.evaluateCondition(c)){l=!1;break}if(l)if(r){const c=s.motion.clip.duration,h=c<=0?1:Math.abs(r.time/c);let d=a.exitTime;r.timeScale<0&&(d=1-d);let u=!1;if(a.hasExitTime?r.timeScale>0?u=h>=a.exitTime:r.timeScale<0&&(u=1-h>=a.exitTime):u=!0,u){for(const m of a.conditions){const f=this.model.parameters.find(g=>g.name===m.parameter);f?.type===tO.Trigger&&f.value&&(f.value=!1)}if(r.clampWhenFinished=!0,_s){const m=this.getState(a.destinationState,0);console.log(`Transition to ${a.destinationState} / ${m?.name}`,a,`
|
|
5871
5871
|
Timescale: `+r.timeScale,`
|
|
5872
5872
|
Normalized time: `+h.toFixed(3),`
|
|
5873
5873
|
Exit Time: `+d,a.hasExitTime)}this.transitionTo(a.destinationState,a.duration,a.offset);return}}else{this.transitionTo(a.destinationState,a.duration,a.offset);return}}r&&this.setTimescale(r,s);let o=!1;if(s.motion.isLooping&&r&&(r.time>=r.getClip().duration?(o=!0,r.reset(),r.time=0,r.play()):r.time<=0&&r.timeScale<0&&(o=!0,r.reset(),r.time=r.getClip().duration,r.play())),!o&&s&&!i&&r&&this.animator&&s.behaviours){const a=r?.getClip().duration,l=r.time/a,c=new _A(this._activeState,l,a,this._speed);for(const h of s.behaviours)h.instance&&((e=h.instance.onStateUpdate)==null||e.call(h.instance,this.animator,c,0))}}setTimescale(e,i){let s=i.speed??1;i.speedParameter&&(s*=this.getFloat(i.speedParameter)),s!==void 0&&(e.timeScale=s*this._speed)}getState(e,i){return typeof e=="number"&&(e==-1&&(e=this.model.layers[i].stateMachine.defaultState,e===void 0&&(_s&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+i),e=0)),e=this.model.layers[i].stateMachine.states[e]),e}releaseHeldActions(e){for(const i of this._heldActions)i.fadeOut(e);this._heldActions.length=0}transitionTo(e,i,s){var r,o,a,l,c,h,d,u;if(!this.animator)return;const m=0;if(e=this.getState(e,m),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof to))return;const f=this._activeState===e;if(f){const A=e.motion;if(!A.action_loopback&&A.clip){const x=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(A.clip,this.animator.gameObject),x&&x.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),A.action_loopback=this.createAction(A.clip)}}if((r=this._activeState)!=null&&r.behaviours&&this._activeState.motion.action){const A=(o=this._activeState)==null?void 0:o.motion.clip.duration,x=this._activeState.motion.action.time/A,w=new _A(this._activeState,x,A,this._speed);for(const _ of this._activeState.behaviours)(l=(a=_.instance)==null?void 0:a.onStateExit)==null||l.call(_.instance,this.animator,w,m)}const g=(c=this._activeState)==null?void 0:c.motion.action;f&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=g);const v=this._activeState;this._activeState=e;const y=(h=e.motion)==null?void 0:h.action,b=e.motion.clip;if(b?.duration<=0&&b.tracks.length<=0?g&&this._heldActions.push(g):g&&(g.fadeOut(i),this.releaseHeldActions(i)),y){if(s=Math.max(0,Math.min(1,s)),e.cycleOffsetParameter){let x=this.getFloat(e.cycleOffsetParameter);typeof x=="number"?(x<0&&(x+=1),s+=x,s%=1):_s&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(s+=e.cycleOffset,s%=1);y.isRunning()&&y.stop(),y.reset(),y.enabled=!0,this.setTimescale(y,e);const A=e.motion.clip.duration;if(y.time=f?0:s*A,y.timeScale<0&&(y.time=A-y.time),y.clampWhenFinished=!0,y.setLoop(rv,0),i>0?y.fadeIn(i):y.weight=1,y.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(y),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const x=new _A(e,s,A,this._speed);for(const w of this._activeState.behaviours)(u=(d=w.instance)==null?void 0:d.onStateEnter)==null||u.call(w.instance,this.animator,x,m)}}else _s&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));_s&&console.log("TRANSITION FROM "+v?.name+" TO "+e.name,i,g,y,y?.getEffectiveTimeScale(),y?.getEffectiveWeight(),y?.isRunning(),y?.isScheduled(),y?.paused)}createAction(e){var i,s;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(i=this.animator)==null?void 0:i.gameObject),(s=this.animator)!=null&&s.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new c0e(this));const r=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,r,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const i=this.model.parameters.find(s=>s.name===e.parameter);if(!i)return!1;switch(e.mode){case Lu.If:return i.value===!0;case Lu.IfNot:return i.value===!1;case Lu.Greater:return i.value>e.threshold;case Lu.Less:return i.value<e.threshold;case Lu.Equals:return i.value===e.threshold;case Lu.NotEqual:return i.value!==e.threshold}return!1}createActions(e){var i,s,r,o;_s&&console.log("AnimatorController createActions",this.model);for(const a of this.model.layers){const l=a.stateMachine;for(let c=0;c<l.states.length;c++){const h=l.states[c];h.transitions||(h.transitions=[]);for(const d of h.transitions)d.conditions||(d.conditions=[]);if(h.motion||(_s&&console.warn("No motion",h),h.motion=$j(h.name)),this.animator&&h.motion.clips){const d=(i=h.motion.clips)==null?void 0:i.find(u=>{var m,f;return u.node.name===((f=(m=this.animator)==null?void 0:m.gameObject)==null?void 0:f.name)});d?h.motion.clip=d.clip:(_s||je())&&console.warn('Could not find clip for animator "'+((r=(s=this.animator)==null?void 0:s.gameObject)==null?void 0:r.name)+'"',h.motion.clips.map(u=>u.node.name))}if(!h.motion.clip){_s&&console.warn("No clip assigned to state",h);const d=new to(void 0,void 0,[]);h.motion.clip=d}if((o=h.motion)!=null&&o.clip){const d=h.motion.clip;if(d instanceof to){const u=this.createAction(d);h.motion.action=u}else(_s||je())&&console.warn("No valid animationclip assigned",h)}if(h.behaviours&&Array.isArray(h.behaviours))for(const d of h.behaviours){if(!(d!=null&&d.typeName))continue;const u=Z.get(d.typeName);if(u){const m=new u;m.isStateMachineBehaviour&&(m._context=this.context??void 0,d0(m,d.properties),d.instance=m),_s&&console.log("Created animator controller behaviour",h.name,d.typeName,d.properties,m)}else(_s||je())&&console.warn("Could not find AnimatorBehaviour type: "+d.typeName)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const i=e.stateMachine;for(let s=0;s<i.states.length;s++){const r=i.states[s];r!=null&&r.motion&&(r.motion.action&&(yield r.motion.action),r.motion.action_loopback&&(yield r.motion.action_loopback))}}}}class eQ{constructor(e,i){p(this,"track"),p(this,"createdInterpolant"),p(this,"originalEvaluate"),p(this,"customEvaluate"),this.track=e;const s=e,r=s.createInterpolant.bind(e);s.createInterpolant=()=>(s.createInterpolant=r,this.createdInterpolant=r(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=o=>{if(!this.originalEvaluate)return;const a=this.originalEvaluate(o);return i(o,a)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const Fs=class{constructor(n,e,i,s,r){if(p(this,"_action"),p(this,"root"),p(this,"clip"),p(this,"positionWrapper",null),p(this,"rotationWrapper",null),p(this,"context"),p(this,"positionChange",new M),p(this,"rotationChange",new Se),p(this,"_prevTime",0),this.context=n,this.root=e,this.clip=i,Fs.firstKeyframeRotation[this.cacheId]||(Fs.firstKeyframeRotation[this.cacheId]=new Se),r){const o=r.values;Fs.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}Fs.spaceRotation[this.cacheId]||(Fs.spaceRotation[this.cacheId]=new Se),Fs.effectiveSpaceRotation[this.cacheId]||(Fs.effectiveSpaceRotation[this.cacheId]=new Se),Fs.clipOffsetRotation[this.cacheId]=new Se,r&&Fs.clipOffsetRotation[this.cacheId].set(r.values[0],r.values[1],r.values[2],r.values[3]).invert(),this.handlePosition(i,s),this.handleRotation(i,r)}set action(n){this._action=n}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(n){if(n.getClip()!==this.clip)return;Fs.lastObjRotation[this.cacheId]||(Fs.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=Fs.lastObjRotation[this.cacheId];if(Fs.spaceRotation[this.cacheId].copy(e),KC){const i=new si().setFromQuaternion(e);console.log("START",this.clip.name,et.toDegrees(i.y),this.root.position.z)}}getClipRotationOffset(){return Fs.clipOffsetRotation[this.cacheId]}handlePosition(n,e){if(e){const i=this.root;KC&&i.add(new Ro),Fs.lastObjPosition[this.cacheId]||(Fs.lastObjPosition[this.cacheId]=this.root.position.clone());const s=new M,r=new M;this.positionWrapper=new eQ(e,(o,a)=>{const l=this.action.getEffectiveWeight();return KC&&i.position.length()>8&&i.position.set(0,i.position.y,0),o>this._prevTime&&(s.set(a[0],a[1],a[2]),s.sub(r),s.multiplyScalar(l),s.applyQuaternion(this.getClipRotationOffset()),s.applyQuaternion(i.quaternion),this.positionChange.copy(s)),r.fromArray(a),this._prevTime=o,a[0]=0,a[1]=0,a[2]=0,a})}}handleRotation(n,e){if(e){if(KC){const o=e.values,a=new si().setFromQuaternion(new Se(o[0],o[1],o[2],o[3]));console.log(n.name,e.name,"FIRST ROTATION IN TRACK",et.toDegrees(a.y));const l=e.values.length-4,c=new Se().set(o[l],o[l+1],o[l+2],o[l+3]),h=new si().setFromQuaternion(c);console.log(n.name,e.name,"LAST ROTATION IN TRACK",et.toDegrees(h.y))}let i=0;const s=new Se,r=new Se;this.rotationWrapper=new eQ(e,(o,a)=>(o>i&&(r.set(a[0],a[1],a[2],a[3]),s.invert(),r.multiply(s),this.rotationChange.copy(r)),s.fromArray(a),i=o,a[0]=0,a[1]=0,a[2]=0,a[3]=1,a))}}onBeforeUpdate(n){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(n){return!this.action||(n*=this.action.getEffectiveWeight(),n<=0)?!1:(this.positionChange.multiplyScalar(n),this.rotationChange.slerp(Fs.identityQuaternion,1-n),!0)}};let Pu=Fs;p(Pu,"lastObjPosition",{}),p(Pu,"lastObjRotation",{}),p(Pu,"firstKeyframeRotation",{}),p(Pu,"spaceRotation",{}),p(Pu,"effectiveSpaceRotation",{}),p(Pu,"clipOffsetRotation",{}),p(Pu,"identityQuaternion",new Se);class c0e{constructor(e){p(this,"controller"),p(this,"handler",[]),p(this,"root"),p(this,"basePosition",new M),p(this,"baseQuaternion",new Se),p(this,"baseRotation",new si),p(this,"summedPosition",new M),p(this,"summedRotation",new Se),this.controller=e}createClip(e,i,s){this.root=i,i&&"name"in i&&i.name;const r=this.findRootTrack(s,".position"),o=this.findRootTrack(s,".quaternion"),a=new Pu(this.controller.context,i,s,r,o);this.handler.push(a);const l=e.clipAction(s);return a.action=l,l}onStart(e){for(const i of this.handler)i.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const i of this.handler)i.onBeforeUpdate(e)}onAfterUpdate(e){if(!(e<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const i of this.handler)i.onAfterUpdate(e)&&(this.summedPosition.add(i.positionChange),this.summedRotation.multiply(i.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,i){const s=e.tracks;if(!s)return null;for(const r of s)if(r.name.endsWith(i))return r;return null}}class h0e extends Ha{onSerialize(e,i){}onDeserialize(e,i){if(i.type===Ea&&e?.__type==="AnimatorController")return new Ea(e)}}new h0e(Ea);var d0e=Object.defineProperty,u0e=Object.getOwnPropertyDescriptor,JC=(n,e,i,s)=>{for(var r=s>1?void 0:s?u0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&d0e(e,i,r),r};const Za=te("debuganimator");class sr extends Pe{constructor(){super(...arguments),p(this,"applyRootMotion",!1),p(this,"hasRootMotion",!1),p(this,"keepAnimatorControllerStateOnDisable",!1),p(this,"_parametersAreDirty",!1),p(this,"_isDirty",!1),p(this,"_speed",1),p(this,"_normalizedStartOffset",0),p(this,"_animatorController",null),p(this,"_initializeWithRuntimeAnimatorController")}get isAnimationComponent(){return!0}set runtimeAnimatorController(e){var i;this._animatorController&&this._animatorController.model===e||(e?e instanceof Ea?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(i=e.model)==null?void 0:i.name),e.model||console.error("AnimatorController has no model"),e=new Ea(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Za&&console.log("Assign animator controller",e,this),this._animatorController=new Ea(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var e;return(e=this.runtimeAnimatorController)==null?void 0:e.getCurrentStateInfo()}get currentAction(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,i=-1,s=Number.NEGATIVE_INFINITY,r=0){this.play(e,i,s,r)}play(e,i=-1,s=Number.NEGATIVE_INFINITY,r=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,i,s,r),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,i){this.setBool(e,i)}setBool(e,i){var s,r;Za&&console.log("setBool",e,i),((s=this.runtimeAnimatorController)==null?void 0:s.getBool(e))!==i&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.setBool(e,i)}GetBool(e){return this.getBool(e)}getBool(e){var i;const s=((i=this.runtimeAnimatorController)==null?void 0:i.getBool(e))??!1;return Za&&console.log("getBool",e,s),s}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,i){this.setFloat(e,i)}setFloat(e,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getFloat(e))!==i&&(this._parametersAreDirty=!0),Za&&console.log("setFloat",e,i),(r=this.runtimeAnimatorController)==null||r.setFloat(e,i)}GetFloat(e){return this.getFloat(e)}getFloat(e){var i;const s=((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(e))??-1;return Za&&console.log("getFloat",e,s),s}SetInteger(e,i){this.setInteger(e,i)}setInteger(e,i){var s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getInteger(e))!==i&&(this._parametersAreDirty=!0),Za&&console.log("setInteger",e,i),(r=this.runtimeAnimatorController)==null||r.setInteger(e,i)}GetInteger(e){return this.getInteger(e)}getInteger(e){var i;const s=((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(e))??-1;return Za&&console.log("getInteger",e,s),s}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var i;this._parametersAreDirty=!0,Za&&console.log("setTrigger",e),(i=this.runtimeAnimatorController)==null||i.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var i;this._parametersAreDirty=!0,Za&&console.log("resetTrigger",e),(i=this.runtimeAnimatorController)==null||i.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var i;const s=(i=this.runtimeAnimatorController)==null?void 0:i.getTrigger(e);return Za&&console.log("getTrigger",e,s),s}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var i;e!==this._speed&&(Za&&console.log("setSpeed",e),this._speed=e,((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){var i;this._speed=et.lerp(e.x,e.y,Math.random()),((i=this._animatorController)==null?void 0:i.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){var i;this._normalizedStartOffset=et.lerp(e.x,e.y,Math.random()),((i=this.runtimeAnimatorController)==null?void 0:i.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Za&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const i=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&i){const s=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=s,s?(console.assert(this.runtimeAnimatorController!==s),this.runtimeAnimatorController=s,console.assert(this.runtimeAnimatorController===s),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this._speed),this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!a0e(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}JC([E()],sr.prototype,"applyRootMotion",2),JC([E()],sr.prototype,"hasRootMotion",2),JC([E()],sr.prototype,"keepAnimatorControllerStateOnDisable",2),JC([E()],sr.prototype,"runtimeAnimatorController",1);const Sc=te("debugusdzanimation"),iO=te("debugusdzanimationserialization");class Cd{constructor(e,i,s){p(this,"_start"),p(this,"ext"),p(this,"root"),p(this,"_nearestAnimatedRoot"),p(this,"clip"),p(this,"speed"),this.ext=e,this.root=i,this.clip=s,this._nearestAnimatedRoot=this.getNearestAnimatedRoot()}get start(){return this._start===void 0&&(this._start=this.ext.getStartTimeByClip(this.clip)),this._start}get duration(){var e;return((e=this.clip)==null?void 0:e.duration)??Sn.restPoseClipDuration}get nearestAnimatedRoot(){return this._nearestAnimatedRoot}get clipName(){var e;return((e=this.clip)==null?void 0:e.name)??"rest"}static isDescendantOf(e,i){let s=i;if(!s||!e)return!1;for(;s;){if(!s)return!1;if(s===e)return!0;s=s.parent}return!1}getNearestAnimatedRoot(){var e;let i;try{for(const s of((e=this.clip)==null?void 0:e.tracks)??[]){const r=Zt.parseTrackName(s.name);let o=Zt.findNode(this.root,r.nodeName);if(o)if(!i)i=o;else{if(o===i||Cd.isDescendantOf(i,o))continue;if(!Cd.isDescendantOf(o,i)){for(;!Cd.isDescendantOf(o,i)&&o.parent;)o=o.parent;Cd.isDescendantOf(o,i)||console.error("USDZExporter: Animation clip targets multiple roots that are not parent/child. Please report a bug",this.root,this.clip,i,o)}i=o}}}catch(s){console.error("USDZExporter: Exception when trying to find nearest animated root. Please report a bug",s),i=void 0}return i}}const qC=class{constructor(n,e,i){if(p(this,"clip"),p(this,"pos"),p(this,"rot"),p(this,"scale"),p(this,"root"),p(this,"target"),p(this,"duration",0),p(this,"useRootMotion",!1),this.root=n,this.target=e,this.clip=i,i?this.duration=i.duration:this.duration=qC.restPoseClipDuration,i&&i.tracks){const r=Math.max(...i.tracks.map(o=>o.times[o.times.length-1]));r!==this.duration&&(console.warn("USDZExporter: Animation clip duration does not match the maximum time value in the tracks.",i,r,this.duration),this.duration=r)}const s=ie.getComponent(n,sr);s&&(this.useRootMotion=s.applyRootMotion)}addTrack(n){var e,i;if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}n.name.endsWith("position")?this.pos=n:n.name.endsWith("quaternion")?this.rot=n:n.name.endsWith("scale")?this.scale=n:(n.name.endsWith("activeSelf")?console.warn("[USDZ] Animation of enabled/disabled state is not supported for USDZ export and will NOT be exported: "+n.name+" on "+(((e=this.root)==null?void 0:e.name)??this.target.name)+". Animate scale 0/1 instead."):console.warn("[USDZ] Animation track type not supported for USDZ export and will NOT be exported: "+n.name+" on "+(((i=this.root)==null?void 0:i.name)??this.target.name)+". Only .position, .rotation, .scale are supported."),je()&&Oi("[USDZ] Some animations can't be exported. See console for details."))}getFrames(){var n,e,i,s,r,o;return this.clip?Math.max(((e=(n=this.pos)==null?void 0:n.times)==null?void 0:e.length)??0,((s=(i=this.rot)==null?void 0:i.times)==null?void 0:s.length)??0,((o=(r=this.scale)==null?void 0:r.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(n=!0,e=!0,i=!0){var s,r,o;if(!this.clip)return[0,this.duration];const a=(s=this.pos)==null?void 0:s.times,l=(r=this.rot)==null?void 0:r.times,c=(o=this.scale)==null?void 0:o.times,h=[];if(n&&a)for(const d of a)h.push(d);if(e&&l)for(const d of l)h.push(d);if(i&&c)for(const d of c)h.push(d);return h.includes(0)||h.push(0),h.sort((d,u)=>d-u),[...new Set(h)]}*getValues(n,e=!0,i=!0,s=!0){var r,o,a;const l=new M,c=new Se,h=new M(1,1,1),d=this.target,u=e?(r=this.pos)==null?void 0:r.createInterpolant():void 0,m=i?(o=this.rot)==null?void 0:o.createInterpolant():void 0,f=s?(a=this.scale)==null?void 0:a.createInterpolant():void 0;u||l.set(d.position.x,d.position.y,d.position.z),m||c.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w),f||h.set(d.scale.x,d.scale.y,d.scale.z),u&&u.valueSize!==3&&(u.valueSize=3),m&&m.valueSize!==4&&(m.valueSize=4),f&&f.valueSize!==3&&(f.valueSize=3);const g=0;for(let v=0-g;v<n.length+g;v++){let y=0,b=0;if(v<0?(y=n[0],b=y-qC.animationDurationPadding/2+1/60):v>=n.length?(y=n[n.length-1],b=y+qC.animationDurationPadding/2-1/60):(y=n[v],b=y),u){const A=u.evaluate(y);l.set(A[0],A[1],A[2])}if(m){const A=m.evaluate(y);c.set(A[0],A[1],A[2],A[3])}if(f){const A=f.evaluate(y);h.set(A[0],A[1],A[2])}if(this.useRootMotion&&d===this.root){const A=new he;A.compose(l,c,h),A.multiply(d.matrix),A.decompose(l,c,h)}yield{time:b,translation:l,rotation:c,scale:h,index:v}}}};let Sn=qC;p(Sn,"frameRate",60),p(Sn,"animationDurationPadding",6/60),p(Sn,"restPoseClipDuration",6/60);class SA{constructor(e){p(this,"dict",new Map),p(this,"rootTargetMap",new Map),p(this,"rootAndClipToRegisteredAnimationMap",new Map),p(this,"rootToRegisteredClip",new Map),p(this,"lastClipEndTime",0),p(this,"clipToStartTime",new Map),p(this,"clipToHoldClip",new Map),p(this,"serializers",[]),p(this,"injectRestPoses",!1),p(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}get animationData(){return this.dict}get registeredClips(){return this.clipToStartTime.keys()}get animatedRoots(){return this.rootTargetMap.keys()}get holdClipMap(){return this.clipToHoldClip}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(Sn.restPoseClipDuration+Sn.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[i,s]of this.rootAndClipToRegisteredAnimationMap){const r=s.start+s.duration;r>e&&(e=r)}return e*60}getClipCount(e){var i;return((i=this.rootToRegisteredClip.get(e))==null?void 0:i.length)??0??0}getStartTimeByClip(e){return e?this.clipToStartTime.has(e)?this.clipToStartTime.get(e):(console.error("USDZExporter: Missing start time for clip \u2013 please report a bug.",e),0):0}registerAnimation(e,i){var s;if(!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const r=e.uuid+(i?.uuid??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(r))return this.rootAndClipToRegisteredAnimationMap.get(r);Sc&&console.log("registerAnimation",e,i);const o=this.injectRestPoses?1:0,a=(((s=this.rootToRegisteredClip.get(e))==null?void 0:s.length)??0)+o,l=this.rootTargetMap.get(e),c=new Set(l);if(i&&i.tracks)for(const d of i.tracks){const u=Zt.parseTrackName(d.name),m=Zt.findNode(e,u.nodeName);if(!m){console.warn("no object found for track",d.name,"using "+e.name+" instead");continue}this.dict.has(m)||this.dict.set(m,[]);const f=this.dict.get(m);if(!f){console.warn("no transform data found for target ",m,"at slot "+a+", this is likely a bug");continue}c.delete(m),this.injectRestPoses&&!f[0]&&(console.log("Injecting rest pose",m,i,"at slot",a),f[0]=new Sn(null,m,null));let g=f[a];g||(g=new Sn(e,m,i),f[a]=g),g.addTrack(d),l!=null&&l.includes(m)||l==null||l.push(m)}Sc&&console.log("Unregistered nodes for this clip",c,"clip",i,"at slot",a,"for root",e,"targets",l);for(const d of c){const u=this.dict.get(d);if(!u)continue;if(this.injectRestPoses&&!u[0]){console.warn("Adding rest pose for ",d,i,"at slot",a,"This is likely a bug, should have been added earlier.");const f=new Sn(null,d,null);u[0]=f}let m=u[a];m||(Sc&&console.log("Adding padding clip for ",d,i,"at slot",a),m=new Sn(e,d,i),u[a]=m)}const h=new Cd(this,e,i);if(this.rootAndClipToRegisteredAnimationMap.set(r,h),Sc&&console.log({root:e,clip:i,info:h}),i){const d=this.rootToRegisteredClip.get(e);if(d?d.push(i):this.rootToRegisteredClip.set(e,[i]),!this.clipToStartTime.get(i)){this.lastClipEndTime==null&&(this.lastClipEndTime=Sn.restPoseClipDuration);let u=this.lastClipEndTime+Sn.animationDurationPadding,m=u+i.duration;const f=Math.round(u*60)/60,g=Math.round(m*60)/60;Math.abs(f-u)<.01&&(u=f),Math.abs(g-m)<.01&&(m=g),u=Math.ceil(u),m=u+i.duration,this.clipToStartTime.set(i,u),this.lastClipEndTime=m}}return h}onAfterHierarchy(e){Sc&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var i,s;Sc&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const r of this.rootTargetMap.keys()){const o=this.rootTargetMap.get(r);if(!o)continue;let a;const l=[];for(const c of o){const h=this.dict.get(c);if(!h){console.error("No data found for target on USDZ export \u2013 please report a bug!",c);continue}a===void 0&&(a=h?.length),a!==h?.length&&console.error("Different array lengths for targets \u2013 please report a bug!",h);for(let d=0;d<h.length;d++){let u=h[d];if(!u){const f=d-(this.injectRestPoses?1:0);h[d]=new Sn(null,c,this.rootToRegisteredClip.get(r)[f]),u=h[d]}const m=u.getDuration();if(l[d]===void 0)l[d]=m;else if(l[d]!==m){console.error("Error during UDSZ export: Encountered different animation durations for animated targets. Please report a bug!",{datas:h,target:c}),l[d]=m;continue}}}}for(const r of this.serializers){const o=(i=r.model)==null?void 0:i.parent,a=o?.isDynamic===!0;iO&&console.log(a,(s=r.model)==null?void 0:s.parent),a&&r.registerCallback(o)}}onExportObject(e,i,s){ie.foreachComponent(e,o=>{const a=o;typeof a.createAnimation=="function"&&a.createAnimation(this,i,s)},!1);const r=new p0e(e,this);this.serializers.push(r),r.registerCallback(i)}}class p0e{constructor(e,i){p(this,"model"),p(this,"object"),p(this,"animationData"),p(this,"ext"),p(this,"callback"),this.object=e,this.animationData=i.animationData,this.ext=i}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),iO&&console.log("REPARENT",e),this.model=e,this.callback&&this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,i,s){var r;const o=this.model,a=this.animationData;if(o&&o.skinnedMesh){let l=function(k){const G=[];for(const[O,W]of k){let D=`${O} : [`;const F=[];for(const U of W)F.push(`(${li(U.x)}, ${li(U.y)}, ${li(U.z)})`);D=D.concat(F.join(", ")),D=D.concat("],"),G.push(D)}return G},c=function(k){const G=[];for(const[O,W]of k){let D=`${O} : [`;const F=[];for(const U of W)F.push(`(${li(U.w)}, ${li(U.x)}, ${li(U.y)}, ${li(U.z)})`);D=D.concat(F.join(", ")),D=D.concat("],"),G.push(D)}return G},h=function(k){let G,O=!0;const W=new Map;for(const[F,U]of k){G===void 0&&(G=U.length),G!==U.length&&(O=!1);let Y=0;for(const q of U)Y++,q||(W.has(F)||W.set(F,[]),W.get(F).push(Y))}Sc&&console.log("Bone count: ",k.size,"TransformData entries per bone: ",G,"Undefined bone entries: ",W),console.assert(O,"All bones should have the same number of TransformData entries",k),console.assert(W.size===0,"All TransformData entries should be set",W);const D=[];for(const[F,U]of k)for(let Y=0;Y<U.length;Y++){const q=U[Y],oe=s.getStartTimeByClip(q.clip);D.length<=Y&&D.push({pos:[],rot:[],scale:[],timeOffset:oe});const xe=D[Y];xe.pos.push(...q.getSortedTimesArray(!0,!1,!1)),xe.rot.push(...q.getSortedTimesArray(!1,!0,!1)),xe.scale.push(...q.getSortedTimesArray(!1,!1,!0))}for(const F of D)F.pos.sort((U,Y)=>U-Y),F.rot.sort((U,Y)=>U-Y),F.scale.sort((U,Y)=>U-Y),F.pos=[...new Set(F.pos)],F.rot=[...new Set(F.rot)],F.scale=[...new Set(F.scale)];return D},d=function(k,G,O){const W=new Map,D=new Map,F=new Map,U=G.length;for(const Y of O){const q=k.get(Y);let oe;q?console.assert(q.length===U,"We should have the same number of TransformData entries for each bone",q,G):oe=new Sn(null,Y,null);for(let xe=0;xe<U;xe++){const Be=q?q[xe]:oe,re=G[xe];for(const{time:_e,translation:Ie}of Be.getValues(re.pos,!0,!1,!1)){const We=(_e+re.timeOffset)*60;W.has(We)||W.set(We,new Array),W.get(We).push(Ie.clone())}for(const{time:_e,rotation:Ie}of Be.getValues(re.rot,!1,!0,!1)){const We=(_e+re.timeOffset)*60;D.has(We)||D.set(We,new Array),D.get(We).push(Ie.clone())}for(const{time:_e,scale:Ie}of Be.getValues(re.scale,!1,!1,!0)){const We=(_e+re.timeOffset)*60;F.has(We)||F.set(We,new Array),F.get(We).push(Ie.clone())}}}return{position:W.size==0?void 0:W,quaternion:D.size==0?void 0:D,scale:F.size==0?void 0:F}},u=function(k){const G=[];for(const O of k)G.push(`(${li(O.x)}, ${li(O.y)}, ${li(O.z)})`);return G.join(", ")},m=function(k){const G=[];for(const O of k)G.push(`(${li(O.w)}, ${li(O.x)}, ${li(O.y)}, ${li(O.z)})`);return G.join(", ")},f=function(k){const G=new Map;if(Sc){const O=new Array;for(const[W,D]of a)O.push(W.uuid+": "+D.length+" "+D.map(F=>{var U;return(U=F.clip)==null?void 0:U.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
@@ -5953,8 +5953,8 @@ ${i.path}! : AssetReference;
|
|
|
5953
5953
|
Could not find method ${h.method} on object ${u.name}. Please rename ${h.method} to ${g}?
|
|
5954
5954
|
`,u[g],`
|
|
5955
5955
|
in script: `,u),Oi("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
|
|
5956
|
-
Could not find method ${h.method} on object ${u.name}`,u,typeof u[h.method])};if(typeof u[h.method]!="function"){let g=!1,v=u;for(;v;){const y=Object.getOwnPropertyDescriptor(v,h.method);if(y&&(y.writable===!0||y.set)){g=!0;break}v=Object.getPrototypeOf(v)}!g&&(je()||Ds)&&f()}}if(u){let f=h.argument;if(f!==void 0?f=d(f):h.arguments!==void 0&&(f=h.arguments.map(d)),!u[h.method])console.warn(`EventList method not found: "${h.method}" on ${u?.name}`);else{f!==void 0&&!Array.isArray(f)&&(f=[f]);const g=new Tc(u,h.method,f,h.enabled);a.push(g)}}else je()&&console.warn("[Debug] EventList: Could not find event listener in scene",h,i.object,e)}const l=new ji(a);Ds&&console.log(l);const c=i.target;return c!==void 0&&i.path!==void 0&&l.setEventTarget(i.path,c),l}}}const V0e=new U0e,sM=new WeakMap,X0e=Vt.prototype.clone;Vt.prototype.clone=function(){const n=X0e.call(this);return sM.has(n)||sM.set(n,this),n};class hQ extends Ha{constructor(){super([I0,Yt])}onSerialize(e,i){}onDeserialize(e,i){if(e instanceof Vt&&i.type===I0){let s=e;sM.has(s)&&(s=sM.get(s)),s.isRenderTargetTexture=!0,s.flipY=!0,s.offset.y=1,s.repeat.y=-1,s.needsUpdate=!0,s.mipmaps=[],s instanceof Vd&&(s.isCompressedTexture=!1,s.format=wi);const r=new I0(s.image.width,s.image.height,{colorSpace:ki});return r.texture=s,r}}}new hQ;class dQ extends Ha{constructor(){super([URL])}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"&&e.length>0)return Qd(i.gltfId,e)}}new dQ;var W0e=Object.defineProperty,H0e=Object.getOwnPropertyDescriptor,j0e=(n,e,i,s)=>{for(var r=s>1?void 0:s?H0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&W0e(e,i,r),r};class IA extends Pe{awake(){Ka.createIfNoneExists(this.context)}onEnable(){var e;(e=Ka.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Ka.get(this.context))==null||e.unregister(this)}}class ca extends IA{constructor(){super(...arguments),p(this,"targets",null),p(this,"raycastHits",[]),p(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Ac),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const i=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=r=>r instanceof Mo?"continue in children":i?i(r):!0);const s=this.context.physics.raycast(e);return e.testObject=i,s}}j0e([E()],ca.prototype,"ignoreSkinnedMeshes",2);class rM extends ca{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const uQ=class extends IA{performRaycast(n){if(!Et.active||!uQ.allow||!(n!=null&&n.ray))return null;const e=n.ray.origin,i=.015;return this.context.physics.sphereOverlap(e,i,!1,!0)}};let P0=uQ;p(P0,"allow",!0);class oM{static getObject(e){const i=e[Ya];return i&&(i.isComponent===!0?e=i.gameObject:e=i),e}static isInteractable(e,i){if(i&&(i.canvasGroup=void 0,i.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const s=this.tryFindCanvasGroup(e);if(s?.isCanvasGroup===!0&&(i&&(i.canvasGroup=s),s.blocksRaycasts===!1||s.interactable===!1))return!1;const r=Pm(e,o=>{if(o.isGraphic===!0)return o},!1);return i&&r?.isGraphic===!0&&(i.graphic=r),!(r?.raycastTarget===!1||r?.layer===2)}static tryFindCanvasGroup(e){if(!e)return null;const i=Pm(e,s=>{const r=s;if(r.blocksRaycasts!==void 0&&r.interactable!==void 0)return r},!1);return i!==void 0?i:this.tryFindCanvasGroup(e.parent)}}function dO(n){return n[Ya]||(n.parent?dO(n.parent):null)}function Q0e(n){return n.isUI===!0||typeof n[Ya]=="object"}function aM(n,e){if(!n)return;const i=n.material;if(i?.isMaterial===!0){const s=n.parent;s&&s.isText,i.side=e.doubleSided??!0?Ai:Vn,i.shadowSide=e.doubleSided?Ai:Vn,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of n.children)aM(s,e)}function k0(n,e,i){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const s=Proxy.revocable(n[e],{set(a,l,c,h){const d=a[l],u=Reflect.set(a,l,c,h);return i(c,d),u}}),r=s.revoke,o=n[e];return s.revoke=()=>{n[e]=o,r()},n[e]=s.proxy,s}const pQ=Symbol("Scheduled action");function Z0e(n,e,i=Ji.OnBeforeRender){let s=n[pQ];s||(s=n[pQ]={});const r=e.name;s[i]||(s[i]={});const o=s[i];if(o[r])return;function*a(){e?.call(n),o[r]=null}const l=n.startCoroutine(a(),i);o[r]=l}const Zh=te("debugeventsystem");var uO=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(uO||{});const Yh=class extends Pe{constructor(){super(),p(this,"raycaster",[]),p(this,"pressedByID",new Map),p(this,"hoveredByID",new Map),p(this,"onPointerEvent",n=>{if(n===void 0||n.propagationStopped||n.defaultPrevented||n.used)return;const e=new Qy(this.context.input,n);this._currentPointerEventName=n.type,e.inputSource=this.context.input,e.isClick=n.isClick,e.isDoubleClick=n.isDoubleClick,e.isDown=n.type==yn.PointerDown,e.isUp=n.type==yn.PointerUp,e.isPressed=this.context.input.getPointerPressed(n.pointerId),Zh&&(e.isDown?console.log("DOWN",e.pointerId):e.isUp&&console.log("UP",e.pointerId),e.isClick&&console.log("CLICK",e.pointerId));const i=new Ac;n.hasRay?i.ray=n.ray:i.screenPoint=this.context.input.getPointerPositionRC(n.pointerId);const s=this.performRaycast(i);if(s){for(const o of s)o.event=n,n.intersections.push(o);n.origin.onPointerHits&&n.origin.onPointerHits({sender:this,event:n,hits:s})}Zh&&e.isClick&&gn("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown);const r={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(s,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}),p(this,"_sortedHits",[]),p(this,"_testObjectsCache",new Map),p(this,"_currentlyActiveRaycaster",null),p(this,"_currentPointerEventName",null),p(this,"shouldRaycastObject",n=>{var e;let i=null;if(Q0e(n)&&(i=(e=n[Ya])==null?void 0:e.gameObject),this._testObjectsCache.has(n)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(n)===!1?"continue in children":!0;{let s=tM(n,this._currentPointerEventName);if(!s&&i&&(s=tM(i,this._currentPointerEventName)),s){this._testObjectsCache.set(n,!0);for(const r of n.children)this.shouldRaycastObject_AddToYesCache(r);return!0}return this._testObjectsCache.set(n,!1),"continue in children"}}),p(this,"_sortingBuffer",[]),p(this,"_noDepthTestingResults",[]),p(this,"out",{}),p(this,"_capturedPointer",{}),p(this,"pointerEnterSymbol",Symbol("pointerEnter")),p(this,"pointerExitSymbol",Symbol("pointerExit")),p(this,"currentActiveMeshUIComponents",[]),Yh.systems.push(this)}static createIfNoneExists(n){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Yh.systems.length<=0&&Yh.systems.push(...ie.findObjectsOfType(Yh,n)));for(const i of Yh.systems)if(i.context===n)return;const e=new ge;ie.addComponent(e,Yh),n.scene.add(e)}static get systems(){const n=Pt.Current;return this._eventSystemMap.has(n)||this._eventSystemMap.set(n,[]),this._eventSystemMap.get(n)}static get(n){const e=this._eventSystemMap.get(n);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(n,e,i=!1){Bu.update(n,e,i)}static markUIDirty(n){Bu.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Yh.systems.splice(Yh.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ie.findObjectOfType(IA,this.context)){const n=ie.addComponent(this.context.scene,ca);this.raycaster.push(n),(je()||Zh)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(n){var e;n&&this.raycaster&&!this.raycaster.includes(n)&&((e=this.raycaster)==null||e.push(n))}unregister(n){var e,i;const s=(e=this.raycaster)==null?void 0:e.indexOf(n);s!==void 0&&s!==-1&&((i=this.raycaster)==null||i.splice(s,1))}onEnable(){this.context.input.addEventListener(yn.PointerDown,this.onPointerEvent),this.context.input.addEventListener(yn.PointerUp,this.onPointerEvent),this.context.input.addEventListener(yn.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(yn.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(yn.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(yn.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(n){this._testObjectsCache.set(n,!0);for(const e of n.children)this.shouldRaycastObject_AddToYesCache(e)}performRaycast(n){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,n||(n=new Ac),n.testObject=this.shouldRaycastObject;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;this._currentlyActiveRaycaster=e;const i=e.performRaycast(n);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((e,i)=>e.distance-i.distance),this._sortedHits}assignHitInformation(n,e){e?(n.intersection=e,n.point=e.point,n.normal=e.normal,n.face=e.face,n.distance=e.distance,n.instanceId=e.instanceId):(n.intersection=void 0,n.point=void 0,n.normal=void 0,n.face=void 0,n.distance=void 0,n.instanceId=void 0)}handleIntersections(n,e){var i;if(n!=null&&n.length){n=this.sortCandidates(n);for(const r of n){if(e.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(e,r),this.handleEventOnObject(r.object,e))return!0}}this.assignHitInformation(e,n?.[0]),this.invokePointerCapture(e);const s=this.hoveredByID.get(e.pointerId);return s&&this.propagatePointerExit(s.obj,s.data,null),this.hoveredByID.delete(e.pointerId),e.isUp&&((i=this.pressedByID.get(e.pointerId))==null||i.handlers.forEach(r=>this.invokeOnPointerUp(e,r)),this.pressedByID.delete(e.pointerId)),!1}sortCandidates(n){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<n.length;e++){const i=n[e],s=i.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventOnObject(n,e){if(!this.testIsVisible(n))return e.isClick&&Zh&&console.log("not allowed",n),!1;if(e.pointerId===void 0)return Zh&&console.error("Event without pointer can't be handled",e),!1;e.object=n;const i=n.parent,s=e.isClick??!1;let r=null;if(i&&i.isUI){const c=(e.isPressed||e.isClick)??!1;if(i[Ya]){const h=i[Ya].gameObject;if(h){if(!oM.isInteractable(h,this.out))return!1;r=this.out.canvasGroup??null,this.handleMeshUIIntersection(n,c),n=h}}}s&&Zh&&console.log(this.context.time.frame,n);const o=this.hoveredByID.get(e.pointerId),a=o?.obj;a!==n&&a&&this.propagatePointerExit(a,o.data,n);const l=this.hoveredByID.get(e.pointerId);if(l?(l.obj=n,l.data=e):this.hoveredByID.set(e.pointerId,{obj:n,data:e}),e.isDown){const c=this.pressedByID.get(e.pointerId);c?(c.obj=n,c.data=e):this.pressedByID.set(e.pointerId,{obj:n,data:e,handlers:new Set})}return(r===null||r.interactable)&&this.handleMainInteraction(n,e,a??null),!0}propagate(n,e){for(;n;)ie.foreachComponent(n,i=>{e(i)},!1),n=n.parent}handleMainInteraction(n,e,i){const s=this.pressedByID.get(e.pointerId),r=i!==n;let o=!0;switch(e.event.pointerType){case"mouse":case"touch":const a=this.context.input.getPointerPositionLastFrame(e.pointerId),l=this.context.input.getPointerPosition(e.pointerId);o=a&&!et.approximately(a,l);break}this.propagate(n,a=>{var l;const c=a;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&r&&this.handlePointerEnter(c,e),e.isDown&&c.onPointerDown&&(c.onPointerDown(e),s?.handlers.add(c),this.handlePointerCapture(e,c)),c.onPointerMove&&(o&&c.onPointerMove(e),this.handlePointerCapture(e,c)),e.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(e,c),s?.handlers.delete(c)),c.onPointerExit&&((l=e.event)==null?void 0:l.pointerType)===TS.Touch&&(this.handlePointerExit(c,e),this.hoveredByID.delete(e.pointerId))),e.isClick&&c.onPointerClick&&c.onPointerClick(e)))}),e.isUp&&(s?.handlers.forEach(a=>{this.invokeOnPointerUp(e,a)}),this.pressedByID.delete(e.pointerId))}propagatePointerExit(n,e,i){this.propagate(n,s=>{if(!s.gameObject||s.destroyed)return;const r=s;if(r.onPointerExit||r.onPointerEnter){if(i&&this.isChild(i,s.gameObject))return;this.handlePointerExit(r,e)}})}invokeOnPointerUp(n,e){var i;(i=e.onPointerUp)==null||i.call(e,n),this.releasePointerCapture(n,e)}handlePointerEnter(n,e){n.onPointerEnter&&this.updatePointerState(n,e.pointerId,this.pointerEnterSymbol,!0)&&n.onPointerEnter(e),this.updatePointerState(n,e.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(n,e){n.onPointerExit&&this.updatePointerState(n,e.pointerId,this.pointerExitSymbol,!0)&&n.onPointerExit(e),this.updatePointerState(n,e.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(n,e,i,s){let r=n[i];if(s)return r&&r.includes(e)?!1:(r=r||[],r.push(e),n[i]=r,!0);{if(!r||!r.includes(e))return!1;const o=r.indexOf(e);return o!==-1&&r.splice(o,1),!0}}handlePointerCapture(n,e){if(n.z__pointer_ctured){n.z__pointer_ctured=!1;const i=n.pointerId;if(e.onPointerMove){const s=this._capturedPointer[i]||[];s.push(e),this._capturedPointer[i]=s}else je()&&!e.z__warned_no_pointermove&&(e.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else n.z__pointer_cture_rleased&&(n.z__pointer_cture_rleased=!1,this.releasePointerCapture(n,e))}releasePointerCapture(n,e){const i=n.pointerId;if(this._capturedPointer[i]){const s=this._capturedPointer[i].indexOf(e);s!==-1&&(this._capturedPointer[i].splice(s,1),Zh&&console.log("released pointer capture",i,e,this._capturedPointer))}}invokePointerCapture(n){var e;if(n.event.type===yn.PointerMove){const i=n.pointerId,s=this._capturedPointer[i];if(s){Zh&&console.log("Captured",i,s);for(let r=0;r<s.length;r++){const o=s[r];if(o.destroyed){s.splice(r,1),r--;continue}(e=o.onPointerMove)==null||e.call(o,n)}}}}isChild(n,e){return!n||!e?!1:n===e?!0:n.parent?this.isChild(n.parent,e):!1}handleMeshUiObjectWithoutShadowDom(n,e){return!n||!n.isUI?!0:this.handleMeshUIIntersection(n,e)}handleMeshUIIntersection(n,e){const i=Bu.updateState(n,e);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Bu.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let n=0;n<this.currentActiveMeshUIComponents.length;n++){const e=this.currentActiveMeshUIComponents[n];Bu.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(n){return n?ie.isActiveSelf(n)?this.testIsVisible(n.parent):!1:!0}};let Ka=Yh;p(Ka,"_eventSystemMap",new Map),p(Ka,"didSearchEventSystem",!1);class Bu{static markDirty(){this.needsUpdate=!0}static update(e,i,s=!1){if(s){e.update();return}const r=i.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===i){if(r===o.frame)return;o.frame=r;let a=this.needsUpdate||r<1;o.nextUpdate<=r&&(a=!0),a&&(Zh&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=r+60,e.update());return}this.lastUpdateFrame=[{context:i,frame:r,nextUpdate:r+60}],e.update(),this.needsUpdate=!1}static updateState(e,i){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}p(Bu,"lastSelected",null),p(Bu,"lastUpdateFrame",[]),p(Bu,"needsUpdate",!1);var Y0e=Object.defineProperty,K0e=Object.getOwnPropertyDescriptor,An=(n,e,i,s)=>{for(var r=s>1?void 0:s?K0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Y0e(e,i,r),r};const pO=te("debugorbit"),mO=te("freecam"),lM=te("debugcamerafit"),cM=te("smoothcam"),J0e={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let fO;class LA extends CustomEvent{constructor(e,i){super("target-reached",{detail:{controls:e,type:i}})}}class Ti extends Pe{constructor(){super(...arguments),p(this,"autoTarget",!0),p(this,"autoFit",!1),p(this,"enableRotate",!0),p(this,"autoRotate",!1),p(this,"autoRotateSpeed",1),p(this,"minAzimuthAngle",1/0),p(this,"maxAzimuthAngle",1/0),p(this,"minPolarAngle",0),p(this,"maxPolarAngle",Math.PI),p(this,"enableKeys",!1),p(this,"enableDamping",!0),p(this,"dampingFactor",.1),p(this,"enableZoom",!0),p(this,"minZoom",0),p(this,"maxZoom",1/0),p(this,"zoomSpeed",1),p(this,"zoomToCursor",!1),p(this,"enablePan",!0),p(this,"lookAtConstraint",null),p(this,"lookAtConstraint01",1),p(this,"allowInterrupt",!0),p(this,"middleClickToFocus",!0),p(this,"doubleClickToFocus",!0),p(this,"clickBackgroundToFitScene",2),p(this,"debugLog",!1),p(this,"targetLerpDuration",1),p(this,"_controls",null),p(this,"_cameraObject",null),p(this,"_lookTargetLerpActive",!1),p(this,"_lookTargetStartPosition",new M),p(this,"_lookTargetEndPosition",new M),p(this,"_lookTargetLerp01",0),p(this,"_lookTargetLerpDuration",0),p(this,"_cameraLerpActive",!1),p(this,"_cameraStartPosition",new M),p(this,"_cameraEndPosition",new M),p(this,"_cameraLerp01",0),p(this,"_cameraLerpDuration",0),p(this,"_fovLerpActive",!1),p(this,"_fovLerpStartValue",0),p(this,"_fovLerpEndValue",0),p(this,"_fovLerp01",0),p(this,"_fovLerpDuration",0),p(this,"_inputs",0),p(this,"_enableTime",0),p(this,"_startedListeningToKeyEvents",!1),p(this,"_eventSystem"),p(this,"_afterHandleInputFn"),p(this,"_camera",null),p(this,"_syncedTransform"),p(this,"_didSetTarget",0),p(this,"targetElement",null),p(this,"_activePointerEvents"),p(this,"_lastTimeClickOnBackground",-1),p(this,"_clickOnBackgroundCount",0),p(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)}),p(this,"_onPointerUp",e=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const s=this._activePointerEvents[i];if(s.pointerId===e.pointerId&&s.button===e.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}pO&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}}),p(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()}),p(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),p(this,"_shouldDisable",!1),p(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))}),p(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var i;(i=this.controls)==null||i.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Ka.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(uO.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,i;(e=this._controls)==null||e.dispose(),(i=this._eventSystem)==null||i.removeEventListener(uO.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=ie.getComponent(this.gameObject,Fi);this._camera=e;let i=e?.threeCamera;if(!i&&this.gameObject instanceof Lt&&(i=this.gameObject),i&&nL(i,this,!0),!this._controls&&i instanceof Lt){this._cameraObject=i;const s=this.targetElement??this.context.renderer.domElement,r=i?.quaternion.clone();this._controls=new rQ(i,s),i?.quaternion.copy(r),fO===void 0&&(fO={...this._controls.keys})}this._controls&&(mO&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,At.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys?(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement)):this._controls.stopListenToKeyEvents()),this._syncedTransform=ie.getComponent(this.gameObject,Ec)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:na.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:na.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:na.Late})}onDisable(){var e;(e=this._camera)!=null&&e.threeCamera&&nL(this._camera.threeCamera,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted),this._controls.stopListenToKeyEvents(),this._startedListeningToKeyEvents=!1),this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var e,i,s,r;if(!!this._controls){if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.length()||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const o=ie.getComponent(this.gameObject,Fi);if(o&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const a=Nt(o.threeCamera),l=Math.max(.01,a.length()),c=new M(0,0,-l).applyMatrix4(o.threeCamera.matrixWorld);this.setLookTargetPosition(c,!0)}if(!this.setLookTargetFromConstraint()){const a=new Ac;a.screenPoint=new K(0,0),a.lineThreshold=.1;const l=this.context.physics.raycast(a);l.length>0&&this.setLookTargetPosition(l[0].point,!0),lM&&console.log("OrbitControls hits",...l)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new LA(this,"camera"));else{const o=et.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,o)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new LA(this,"lookat"));else{const o=et.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,o)}if(this._fovLerpActive&&this._cameraObject){const o=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)o.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const a=et.easeInOutCubic(this._fovLerp01);o.fov=et.lerp(this._fovLerpStartValue,this._fovLerpEndValue,a)}o.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(o=>o.used),this._controls.keys=this.enableKeys?fO:J0e,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,mO||(((s=(i=this._camera)==null?void 0:i.threeCamera)==null?void 0:s.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof cM=="number"||cM===!0){this._controls.enableDamping=!0;const o=typeof cM=="number"?cM:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,o))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!mO&&(r=this.lookAtConstraint)!=null&&r.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),pO&&ft.DrawWireSphere(this._controls.target,.1,65280))}}}setCameraAndLookTarget(e){if(!e||!(e instanceof ge))return;const i=Nt(e),s=hL(e);this.setTargetFromRaycast(new qr(i,s)),this.setCameraTargetPosition(i)}setCameraTargetPosition(e,i=!1){var s;e&&(e instanceof ge&&(e=Nt(e)),this._cameraEndPosition||(this._cameraEndPosition=new M),this._cameraEndPosition.copy(e),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((s=this._cameraObject)==null?void 0:s.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,i=!1){var s;if(!this._controls||typeof e!="number")return;const r=(s=this._camera)==null?void 0:s.threeCamera;r&&(i===!0?r.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=r.fov,this._fovLerpEndValue=e,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,i=!1){this._controls&&e&&(e instanceof ge&&(e=Nt(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,pO&&(console.warn("OrbitControls: setLookTargetPosition",e,i),ft.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,i=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const o=r[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(e,i){return this.lerpLookTarget(e,i)}lerpLookTarget(e,i){this._controls&&(i>=1?this._controls.target.copy(e):this._controls.target.lerp(e,i))}setTargetFromRaycast(e){if(!this.controls)return;const i=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const s of i)if(s.distance>0&&ie.isActiveInHierarchy(s.object)){const r=dO(s.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(s.point);break}}fitCamera(e,i){var s,r;if(this.context.isInXR)return;let o;if(Array.isArray(e)?o=e:e&&"type"in e?o=e.children:e&&"objects"in e&&(o=e?.objects,i=e),o&&!Array.isArray(o)&&(o=o.children),(!Array.isArray(o)||o&&o.length<=0)&&(o=this.context.scene.children),!Array.isArray(o)||o.length<=0){console.warn("No objects to fit camera to...");return}const a=this._cameraObject,l=this._controls;if(!a||!l){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:c=!1,centerCamera:h="y",cameraNearFar:d="auto",fitOffset:u=1.1,fov:m=a?.fov}=i,f=new M,g=new M,v=Jo(o,void 0,(r=(s=this._camera)==null?void 0:s.threeCamera)==null?void 0:r.layers),y=v.clone();a.updateMatrixWorld(),a.updateProjectionMatrix(),v.getCenter(g);const b=new M;if(v.getSize(b),v.applyMatrix4(a.matrixWorldInverse),v.getSize(f),v.setFromCenterAndSize(g,f),Number.isNaN(f.x)||Number.isNaN(f.y)||Number.isNaN(f.z)){console.warn("Camera fit size resultet in NaN",a,v,[...o]);return}if(f.length()<=1e-10){lM&&console.warn("Camera fit size is zero",v,[...o]);return}const A=i.fov||a.fov,x=2*Math.atan(Math.tan(A*Math.PI/360/2)*a.aspect)/Math.PI*360,w=f.y/(2*Math.atan(Math.PI*A/360)),_=f.x/(2*Math.atan(Math.PI*x/360)),S=u*Math.max(w,_)+f.z/2;lM&&console.log("Fit camera to objects",{fitHeightDistance:w,fitWidthDistance:_,distance:S,verticalFov:A,horizontalFov:x}),this.maxZoom=S*10,this.minZoom=S*.01;const C=.05,R=g.clone();if(R.y-=f.y*C,this.setLookTargetPosition(R,c),this.setFieldOfView(i.fov,c),this.autoTarget=!1,d==null||d=="auto"){const G=ie.findObjectOfType(Cc),O=G?G.radius:0,W=Math.max(b.x,b.y,b.z,O);a.near=S/100,a.far=W+S*10,G&&(this.maxZoom=Math.max(Math.min(this.maxZoom,O*.5),S))}const P=l.getDistance();P<this.minZoom&&(this.minZoom=P*.9),P>this.maxZoom&&(this.maxZoom=P*1.1),a.updateMatrixWorld(),a.updateProjectionMatrix();const T=Nt(a),L=g.clone();L.sub(T),h==="y"&&(L.y=0),L.normalize(),L.multiplyScalar(S),h==="y"&&(L.y+=-C*4*S);let k=g.clone().sub(L);if(a.parent&&(k=a.parent.worldToLocal(k)),this.setCameraTargetPosition(k,c),lM){const G=new dI(v);this.context.scene.add(G),pL(G,Yv(a)),setTimeout(()=>{this.context.scene.remove(G)},1e4),ft.DrawWireBox3(y,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",O=>{if(O.code==="KeyF"){let W;this._cameraObject instanceof Lt&&(W=Math.random()*Math.random()*170+10),this.fitCamera({objects:o,fitOffset:u,immediate:!1,fov:W})}O.code==="KeyV"&&this._cameraObject instanceof Lt&&(this._cameraObject.fov=60)}))}l.update()}}An([E()],Ti.prototype,"autoTarget",2),An([E()],Ti.prototype,"autoFit",2),An([E()],Ti.prototype,"enableRotate",2),An([E()],Ti.prototype,"autoRotate",2),An([E()],Ti.prototype,"autoRotateSpeed",2),An([E()],Ti.prototype,"minAzimuthAngle",2),An([E()],Ti.prototype,"maxAzimuthAngle",2),An([E()],Ti.prototype,"minPolarAngle",2),An([E()],Ti.prototype,"maxPolarAngle",2),An([E()],Ti.prototype,"enableKeys",2),An([E()],Ti.prototype,"enableDamping",2),An([E()],Ti.prototype,"dampingFactor",2),An([E()],Ti.prototype,"enableZoom",2),An([E()],Ti.prototype,"minZoom",2),An([E()],Ti.prototype,"maxZoom",2),An([E()],Ti.prototype,"zoomSpeed",2),An([E()],Ti.prototype,"enablePan",2),An([E(zm)],Ti.prototype,"lookAtConstraint",2),An([E()],Ti.prototype,"lookAtConstraint01",2),An([E()],Ti.prototype,"allowInterrupt",2),An([E()],Ti.prototype,"middleClickToFocus",2),An([E()],Ti.prototype,"doubleClickToFocus",2),An([E()],Ti.prototype,"clickBackgroundToFitScene",2),An([E()],Ti.prototype,"targetLerpDuration",2);var q0e=Object.defineProperty,$0e=Object.getOwnPropertyDescriptor,fo=(n,e,i,s)=>{for(var r=s>1?void 0:s?$0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&q0e(e,i,r),r},Ou=(n=>(n[n.None=0]="None",n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Ou||{});const Du=te("debugcam"),mQ=te("debugscreenpointtoray");var hM;const PA=(hM=class extends Pe{constructor(){super(...arguments),p(this,"_nearClipPlane",.1),p(this,"_farClipPlane",1e3),p(this,"orthographic",!1),p(this,"orthographicSize",5),p(this,"ARBackgroundAlpha",0),p(this,"_cullingMask",4294967295),p(this,"_backgroundBlurriness"),p(this,"_backgroundIntensity"),p(this,"_backgroundRotation"),p(this,"_environmentIntensity"),p(this,"_targetTexture",null),p(this,"_backgroundColor"),p(this,"_fov"),p(this,"_cam",null),p(this,"_clearFlags",2),p(this,"_skybox"),p(this,"_frustum"),p(this,"_projScreenMatrix",new he)}get isCamera(){return!0}get aspect(){return this._cam instanceof Lt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(n){this._cam instanceof Lt&&this._cam.aspect!==n&&(this._cam.aspect=n,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Lt?this._cam.fov:this._fov}set fieldOfView(n){const e=this.fieldOfView!=n;if(this._fov=n,e&&this._cam&&this._cam instanceof Lt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(n){const e=this._nearClipPlane!=n;this._nearClipPlane=n,this._cam&&(e||this._cam.near!=n)&&(this._cam.near=n,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(n){const e=this._farClipPlane!=n;this._farClipPlane=n,this._cam&&(e||this._cam.far!=n)&&(this._cam.far=n,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(n){n!==this._clearFlags&&(this._clearFlags=n,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(n){this._cullingMask=n,this._cam&&(this._cam.layers.mask=n)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(n){this.cullingMask=(1<<n|0)>>>0}set backgroundBlurriness(n){n!==this._backgroundBlurriness&&(n===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(n,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(n){n!==this._backgroundIntensity&&(n===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(n,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(n){n!==this._backgroundRotation&&(n===void 0?this._backgroundRotation=void 0:this._backgroundRotation=n,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(n){this._environmentIntensity=n}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(n){if(n){if(this._backgroundColor)this._backgroundColor.copy(n);else{if(!n.clone)return;this._backgroundColor=n.clone()}n.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(n){this._targetTexture=n}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(n,e,i){const s=this.threeCamera,r=PA._origin;r.set(n,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),mQ&&console.log("screenPointToRay",n.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=PA._direction.set(r.x,r.y,r.z),a=Nt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new qr(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new Gp,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Gp),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(n,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),n===this._projScreenMatrix?n:n.copy(this._projScreenMatrix)}awake(){mQ&&window.addEventListener("pointerdown",n=>{const e=n.clientX,i=n.clientY;console.log("touch",e.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(e,i),r="#"+Math.floor(Math.random()*16777215).toString(16);ft.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Du&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ou[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),tye(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const n=this.context.renderer;if(n){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,n),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const n=this.gameObject.isCamera;let e=null;if(n?(e=this.gameObject,e?.layers.enableAll(),e instanceof Lt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Lt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Lt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const i=this.orthographicSize*100;e=new oc(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(n){this.context.mainCameraComponent===this&&this.applyClearFlags(n)}applyClearFlags(n){var e;if(!this._cam){Du&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Du){const i=`Camera "${this.name}" clear flags: ${Ou[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(PA.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||n?.applySkybox===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:Du&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:Du&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;PA.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(T5(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else Du&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new eye(this)),this._skybox.apply()}static backgroundShouldBeTransparent(n){var e,i,s,r;const o=(e=n.renderer.xr)==null?void 0:e.getSession();if(!o)return!1;if(typeof o._transparent=="boolean")return o._transparent;const a=o.environmentBlendMode;Du&&gn("Environment blend mode: "+a+" on "+navigator.userAgent);let l=a==="additive"||a==="alpha-blend";return n.isInAR&&a==="opaque"&&((i=navigator.userAgent)!=null&&i.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(l=!0),o._transparent=l,l}},p(hM,"_origin",new M),p(hM,"_direction",new M),hM);let Fi=PA;fo([E()],Fi.prototype,"aspect",1),fo([E()],Fi.prototype,"fieldOfView",1),fo([E()],Fi.prototype,"nearClipPlane",1),fo([E()],Fi.prototype,"farClipPlane",1),fo([E()],Fi.prototype,"clearFlags",1),fo([E()],Fi.prototype,"orthographic",2),fo([E()],Fi.prototype,"orthographicSize",2),fo([E()],Fi.prototype,"ARBackgroundAlpha",2),fo([E()],Fi.prototype,"cullingMask",1),fo([E()],Fi.prototype,"backgroundBlurriness",1),fo([E()],Fi.prototype,"backgroundIntensity",1),fo([E(si)],Fi.prototype,"backgroundRotation",1),fo([E()],Fi.prototype,"environmentIntensity",1),fo([E(Li)],Fi.prototype,"backgroundColor",1),fo([E(I0)],Fi.prototype,"targetTexture",1);class eye{constructor(e){p(this,"_camera"),p(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Du&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Kr,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function tye(n){te("freecam")&&n.context.mainCameraComponent===n&&ie.getOrAddComponent(n.gameObject,Ti)}class Gu extends Pe{constructor(){super(...arguments),p(this,"_listener",null),p(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new Fz),this._listener}onEnable(){Xh.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Xh.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const i=this.context.mainCameraComponent||ie.getComponentInParent(this.gameObject,Fi);i!=null&&i.threeCamera?i.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var iye=Object.defineProperty,nye=Object.getOwnPropertyDescriptor,Vl=(n,e,i,s)=>{for(var r=s>1?void 0:s?nye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&iye(e,i,r),r};const Ur=te("debugaudio"),Nu=class extends Pe{constructor(){super(...arguments),p(this,"clip",""),p(this,"playOnAwake",!1),p(this,"preload",!1),p(this,"playInBackground",!0),p(this,"_spatialBlend",0),p(this,"_minDistance",1),p(this,"_maxDistance",100),p(this,"_volume",1),p(this,"rollOffMode",0),p(this,"_loop",!1),p(this,"sound",null),p(this,"helper",null),p(this,"wasPlaying",!1),p(this,"audioLoader",null),p(this,"shouldPlay",!1),p(this,"_lastClipStartedLoading",null),p(this,"_audioElement",null),p(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||At.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Ur&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,Nu.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&Nu.userInteractionRegistered&&this.wasPlaying&&this.play();break}}),p(this,"onApplicationMuteChanged",()=>{var n,e;this.context.application.muted?(n=this.sound)==null||n.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)}),p(this,"createAudio",n=>{Ur&&console.log("AudioBuffer finished loading",n);const e=this.Sound;if(!e){Ur&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),n&&e.setBuffer(n),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&Nu.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),Nu.registerWaitForAllowAudio(this.__onAllowAudioCallback)}),p(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()}),p(this,"_lastContextTime",0),p(this,"_hasEnded",!0),p(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Xh.userInteractionRegistered}static registerWaitForAllowAudio(n){Xh.registerWaitForInteraction(n)}get isPlaying(){var n;return((n=this.sound)==null?void 0:n.isPlaying)??!1}get duration(){var n,e;return(e=(n=this.sound)==null?void 0:n.buffer)==null?void 0:e.duration}get time01(){var n;const e=this.duration;return e&&this.sound?((n=this.sound)==null?void 0:n.context.currentTime)/e:0}set time01(n){const e=this.duration;e&&this.sound&&(this.time=n*e)}get time(){var n,e;return(n=this.sound)!=null&&n.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(n){if(this.sound){if(n===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=n,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(n){this._loop=n,this.sound&&this.sound.setLoop(n)}get spatialBlend(){return this._spatialBlend}set spatialBlend(n){n!==this._spatialBlend&&(this._spatialBlend=n,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(n){this._minDistance!==n&&(this._minDistance=n,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(n){this._maxDistance!==n&&(this._maxDistance=n,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(n){this._volume=n,this.sound&&!this.context.application.muted&&(Ur&&console.log(this.name,"audio set volume",n),this.sound.setVolume(n))}set pitch(n){this.sound&&this.sound.setPlaybackRate(n)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var n;if(!this.sound&&Nu.userInteractionRegistered){let e=ie.getComponent(this.context.mainCamera,Gu)??ie.findObjectOfType(Gu,this.context);!e&&this.context.mainCamera&&(e=ie.addComponent(this.context.mainCamera,Gu)),e!=null&&e.listener?(this.sound=new Uz(e.listener),(n=this.gameObject)==null||n.add(this.sound)):Ur&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var n;return(n=this.sound)==null?void 0:n.context}awake(){Ur&&console.log(this),this.audioLoader=new i_,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),Nu.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():Nu.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(xC.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(xC.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const n=this.sound;if(!n)return;this._needUpdateSpatialDistanceSettings=!1;const e=et.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Ur&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),n.setRefDistance(e),n.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:n.setDistanceModel("exponential");break;case 1:n.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Ur&&!this.helper&&(this.helper=new m0e(n,n.getRefDistance()),n.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(n){if(n&&(this.clip=n),typeof n=="string")if(Ur&&console.log(n),n.endsWith(".mp3")||n.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new i_),this.shouldPlay=!0,this._lastClipStartedLoading===n){Ur&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=n,Ur&&console.log("load audio",n);const e=await this.audioLoader.loadAsync(n).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",n);else this.shouldPlay=!0,this.createAudio()}play(n=void 0){var e,i,s;!n&&this.clip&&(n=this.clip),n!==void 0&&typeof n!="string"&&!(n instanceof MediaStream)&&(je()&&console.warn("Called play on AudioSource with unknown argument type:",n+`
|
|
5957
|
-
Using the assigned clip instead:`,this.clip),n=this.clip);let r=!this.sound||n&&n!==this.clip;if(typeof n=="string"&&!this.audioLoader&&(r=!0),(n instanceof MediaStream||typeof n=="string")&&(this.clip=n),r){this.shouldPlay=!0,this.onNewClip(n);return}if(this.shouldPlay=!0,this._hasEnded=!1,Ur&&console.log("play",(e=this.sound)==null?void 0:e.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(i=this.gameObject)==null||i.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(s=this.context.domElement.shadowRoot)==null||s.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(o?.1:0))}}pause(){var n,e;Ur&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(n=this.sound)==null?void 0:n.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var n,e;Ur&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(n=this.sound)==null?void 0:n.context.currentTime,Ur&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,Ur&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Cn=Nu;Vl([E(URL)],Cn.prototype,"clip",2),Vl([E()],Cn.prototype,"playOnAwake",2),Vl([E()],Cn.prototype,"preload",2),Vl([E()],Cn.prototype,"playInBackground",2),Vl([E()],Cn.prototype,"loop",1),Vl([E()],Cn.prototype,"spatialBlend",1),Vl([E()],Cn.prototype,"minDistance",1),Vl([E()],Cn.prototype,"maxDistance",1),Vl([E()],Cn.prototype,"volume",1),Vl([E()],Cn.prototype,"pitch",1),Vl([E()],Cn.prototype,"rollOffMode",2);var sye=Object.defineProperty,rye=Object.getOwnPropertyDescriptor,dM=(n,e,i,s)=>{for(var r=s>1?void 0:s?rye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&sye(e,i,r),r};const oye=te("debugsignals");class kA{constructor(){p(this,"guid")}}dM([E()],kA.prototype,"guid",2);class B0{constructor(){p(this,"signal"),p(this,"reaction")}}dM([E(kA)],B0.prototype,"signal",2),dM([E(ji)],B0.prototype,"reaction",2);var gO;const Kh=(gO=class extends Pe{constructor(){super(...arguments),p(this,"events")}static invoke(n){if(Kh.receivers[n]){const e=Kh.receivers[n];if(!e)return;for(const i of e)i.invoke(n)}}awake(){oye&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const n of this.events)Kh.receivers[n.signal.guid]||(Kh.receivers[n.signal.guid]=[]),Kh.receivers[n.signal.guid].push(this)}onDisable(){if(this.events){for(const n of this.events)if(Kh.receivers[n.signal.guid]){const e=Kh.receivers[n.signal.guid].indexOf(this);e>=0&&Kh.receivers[n.signal.guid].splice(e,1)}}}invoke(n){if(!this.events||!Array.isArray(this.events))return;const e=typeof n=="object"?n.guid:n;for(const i of this.events)if(i.signal.guid===e)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},p(gO,"receivers",{}),gO);let O0=Kh;dM([E(B0)],O0.prototype,"events",2);var ha=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(ha||{}),Rc=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Rc||{}),yO=(n=>(n.Signal="SignalEmitter",n))(yO||{}),aye=Object.defineProperty,lye=Object.getOwnPropertyDescriptor,fQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?lye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&aye(e,i,r),r};const Jh=te("debugtimeline");var vO;const bO=(vO=class extends Pe{constructor(){super(...arguments),p(this,"playableAsset"),p(this,"playOnAwake"),p(this,"extrapolationMode",1),p(this,"waitForAudio",!0),p(this,"_visibilityChangeEvt"),p(this,"_clonedPlayableAsset",!1),p(this,"_speed",1),p(this,"_guidsMap"),p(this,"_isPlaying",!1),p(this,"_internalUpdateRoutine"),p(this,"_isPaused",!1),p(this,"_isStopping",!1),p(this,"_time",0),p(this,"_duration",0),p(this,"_weight",1),p(this,"_animationTracks",[]),p(this,"_audioTracks",[]),p(this,"_signalTracks",[]),p(this,"_controlTracks",[]),p(this,"_customTracks",[]),p(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),p(this,"animationCallbackReceivers",[])}static registerCreateTrack(n,e){this.createTrackFunctions[n]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(n){typeof n=="number"&&!Number.isNaN(n)?this._time=n:(Jh||io())&&console.error("INVALID TIMELINE.TIME VALUE",n,this.name)}get duration(){return this._duration}set duration(n){this._duration=n}get weight(){return this._weight}set weight(n){this._weight=n}get speed(){return this._speed}set speed(n){this._speed=n}awake(){var n,e,i,s,r;Jh&&console.log(this,(n=this.playableAsset)==null?void 0:n.tracks),this.rebuildGraph(),!this.isValid()&&(Jh||je())&&(Jh?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",(e=this.playableAsset)==null?void 0:e.tracks,"IsArray?",Array.isArray((i=this.playableAsset)==null?void 0:i.tracks),this):(r=(s=this.playableAsset)==null?void 0:s.tracks)!=null&&r.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){var n,e,i;for(const s of this._audioTracks)(n=s.onEnable)==null||n.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(i=s.onEnable)==null||i.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var n,e,i;this.stop();for(const s of this._audioTracks)(n=s.onDisable)==null||n.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(i=s.onDisable)==null||i.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var n;for(const e of this._allTracks)for(const i of e)(n=i.onDestroy)==null||n.call(i)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const n=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,n&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const i of this._audioTracks){const s=i.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Cn.userInteractionRegistered&&this.waitForAudio;)await bl(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ji.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const n=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),n&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,n&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const n of this._allTracks)for(const e of n)yield e}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}resolveGuids(n){this._guidsMap=n}invokePauseChangedMethodsOnTracks(){var n;for(const e of this.forEachTrack())(n=e.onPauseChanged)==null||n.call(e)}invokeStateChangedMethodsOnTracks(){var n;for(const e of this.forEachTrack())(n=e.onStateChanged)==null||n.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(n=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const i=this._time;for(const s of this.playableAsset.tracks)if(!s.muted)switch(s.type){case ha.Activation:if(!n&&!this._isPlaying)continue;for(let r=0;r<s.outputs.length;r++){const o=s.outputs[r];if(typeof o=="object"){let a=!1;if(s.clips)for(const c of s.clips)c.start<=i&&i<=c.end&&(a=!0);const l=o;l.visible!==void 0&&l.visible!==a&&(l.visible=a,Jh&&console.warn(this.name,"set ActivationTrack-"+r,l.name,a,i))}}break}if(!this._isStopping)for(const s of this._animationTracks)s.evaluate(i);for(const s of this._audioTracks)s.evaluate(i);for(const s of this._signalTracks)s.evaluate(i);for(const s of this._controlTracks)s.evaluate(i);for(const s of this._customTracks)s.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Vv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const n=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let i=e.outputs.length-1;i>=0;i--){let s=e.outputs[i];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=ie.findByGuid(s,n);r===null||typeof r!="object"?(e.outputs.splice(i,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Jh&&console.log("Resolved binding",s,"to",r),e.outputs[i]=r)}else if(s===null){if(e.outputs.splice(i,1),bO.createTrackFunctions[e.type])continue;e.type!==ha.Audio&&e.type!==ha.Control&&e.type!==ha.Marker&&e.type!==ha.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===ha.Control&&e.clips)for(let i=0;i<e.clips.length;i++){const s=e.clips[i];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=ie.findByGuid(r,n);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Jh&&console.log("Resolved binding",r,"to",o),s.asset.sourceObject=o)}}}}findRoot(n){return n.parent?this.findRoot(n.parent):n}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const n of this.playableAsset.tracks)if(n.muted!==!0){if(n.clips)for(const e of n.clips)e.end>this._duration&&(this._duration=e.end);if(n.markers)for(const e of n.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var n,e,i;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let s=ie.findObjectOfType(Gu,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=bO.createTrackFunctions[o];if(a!=null){const l=a(this,r);if(typeof l.evaluate=="function"){l.director=this,l.track=r,this._customTracks.push(l);continue}}if(r.type===ha.Animation){if(!r.clips||r.clips.length<=0){Jh&&console.warn("Animation track has no clips",r);continue}for(let l=r.outputs.length-1;l>=0;l--){let c=r.outputs[l];if(c instanceof ge){const d=ie.getOrAddComponent(c,sr);d&&(c=d)}const h=(n=c?.gameObject)==null?void 0:n.animations;if(h){const d=new uM;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let u=0;u<r.clips.length;u++){const m=r.clips[u],f=m.asset;if(!f){console.error(`Timeline ${this.name}: clip #${u} on track "${r.name}" has no animation data`);continue}const g=f.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===g)),Jh&&console.log(f,g,"\u2192",v),!v){console.warn("Could not find animationClip for model",m,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name,h,c);continue}c instanceof sr&&c.runtimeAnimatorController&&(c.__internalDidAwakeAndStart||c.initializeRuntimeAnimatorController(),c.runtimeAnimatorController.mixer||c.runtimeAnimatorController.bind(c),d.mixer=c.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new n_(c.gameObject),this.context.animations.registerAnimationMixer(d.mixer)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(m.asset,v);const y=d.mixer.clipAction(v);d.actions.push(y),d.models.push(m)}this._animationTracks.push(d)}}}else if(r.type===ha.Audio){if(!r.clips||r.clips.length<=0)continue;const l=new DA;l.director=this,l.track=r,l.audioSource=r.outputs.find(c=>c instanceof Cn),this._audioTracks.push(l),s||(s=(i=this.context.mainCameraComponent)==null?void 0:i.gameObject.addComponent(Gu)),l.listener=s.listener;for(let c=0;c<r.clips.length;c++){const h=r.clips[c];l.addModel(h)}}else if(r.type===ha.Marker){const l=new GA;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)switch(c.type){case yO.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=ie.getComponent(this.gameObject,O0);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(r.type===ha.Signal){const l=new GA;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of r.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(r.type===ha.Control){const l=new pM;if(l.director=this,l.track=r,r.clips)for(const c of r.clips)l.models.push(c);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(n){for(const e of this._audioTracks)e.onAllowAudioChanged(n)}registerAnimationCallback(n){this.animationCallbackReceivers.push(n)}unregisterAnimationCallback(n){const e=this.animationCallbackReceivers.indexOf(n);e!==-1&&this.animationCallbackReceivers.splice(e,1)}},p(vO,"createTrackFunctions",{}),vO);let Fu=bO;fQ([E()],Fu.prototype,"playOnAwake",2),fQ([E()],Fu.prototype,"extrapolationMode",2);const Ic=te("debugtimeline");class BA{constructor(){p(this,"director"),p(this,"track")}get muted(){return this.track.muted}set muted(e){var i;e!==this.track.muted&&(this.track.muted=e,(i=this.onMuteChanged)==null||i.call(this))}*forEachClip(e=!1){var i;if((i=this.track)!=null&&i.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,i){return i.clipIn+(e-i.start)*i.timeScale}getClipTimeNormalized(e,i){return(e-i.start)/i.duration}evaluateWeight(e,i,s,r=!0){if(i<0||i>=s.length)return 0;const o=s[i];if(r||e>=o.start&&e<=o.end){let a=1;const l=!1;if(o.easeInDuration>0){const c=Math.min((e-o.start)/o.easeInDuration,1);a*=c}if(o.easeOutDuration>0&&!l){const c=Math.min((o.end-e)/o.easeOutDuration,1);a*=c}return a}return 0}}class cye{constructor(e){p(this,"clip"),p(this,"rootPositionOffset"),p(this,"rootQuaternionOffset"),p(this,"rootStartPosition"),p(this,"rootEndPosition"),p(this,"rootStartQuaternion"),p(this,"rootEndQuaternion");const i=e.getClip();this.clip=i;const s=e.getRoot(),r=s.name+".position",o=s.name+".quaternion";Ic&&console.log(i.name,i.tracks,r);for(const a of i.tracks)if(!(a.times.length<=0)){if(a.name.endsWith(r))this.rootStartPosition=new M().fromArray(a.values,0),this.rootEndPosition=new M().fromArray(a.values,a.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Ic&&console.log(this.rootPositionOffset);else if(a.name.endsWith(o)&&(this.rootStartQuaternion=new Se().fromArray(a.values,0),this.rootEndQuaternion=new Se().fromArray(a.values,a.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Ic)){const l=new si().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",l)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class uM extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"trackOffset"),p(this,"target"),p(this,"mixer"),p(this,"clips",[]),p(this,"actions",[]),p(this,"weight",1),p(this,"_actionOffsets",[]),p(this,"_didBind",!1),p(this,"_animator",null),p(this,"_useclipOffsets",!0),p(this,"_totalOffsetPosition",new M),p(this,"_totalOffsetRotation",new Se),p(this,"_totalOffsetPosition2",new M),p(this,"_totalOffsetRotation2",new Se),p(this,"_summedPos",new M),p(this,"_tempPos",new M),p(this,"_summedRot",new Se),p(this,"_tempRot",new Se),p(this,"_clipRotQuat",new Se)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&qj(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,i){var s,r;if(((s=i.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",i);return}const o=i.tracks[0].name.split("."),a=o[o.length-2],l=a+".position",c=a+".quaternion";let h=!1,d=!1;for(const u of i.tracks)u.name.endsWith(l)?(h=!0,this.createPositionInterpolant(i,e,u)):u.name.endsWith(c)&&(d=!0,this.createRotationInterpolant(i,e,u));if(!h||!d){const u=(r=this.mixer)==null?void 0:r.getRoot(),m=i.tracks[0],f=m.name.lastIndexOf("."),g=m.name.substring(0,f),v=g.substring(g.lastIndexOf(".")+1),y=u.getObjectByName(v);if(y)if(h){if(!d){const b=i.tracks[0].name.substring(0,f)+".quaternion";Ic&&console.warn("Create quaternion track",v,y);const A=y.quaternion,x=new yl(b,[0,i.duration],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);i.tracks.push(x),this.createRotationInterpolant(i,e,x)}}else{const b=g+".position";Ic&&console.warn("Create position track",v,y);const A=y.position,x=new ac(b,[0,i.duration],[A.x,A.y,A.z,A.x,A.y,A.z]);i.tracks.push(x),this.createPositionInterpolant(i,e,x)}}}bind(){if(!this._didBind){this._didBind=!0,Ic&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const i=new cye(e);this._actionOffsets.push(i)}this.target&&(this._animator=ie.getComponent(this.target,sr)??null,this._animator&&qj(this._animator.gameObject,this,!0));for(const e of this.models){const i=e.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new M(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new M(e.x,e.y,e.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(e){var i,s,r,o,a,l,c;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let h=0,d=0,u=!1,m=!1,f=0;for(let g=0;g<this.clips.length;g++){const v=this.models[g],y=this.actions[g],b=v.asset;y.weight=0;const A=e>=v.start&&e<=v.end,x=v.preExtrapolationMode,w=v.postExtrapolationMode,_=g<this.clips.length-1?this.models[g+1]:null;let S=A,C=!1;if(!S&&!u&&v.end<e&&w!==Rc.None?(!_||_.start>e)&&(S=!0,u=!0):g==0&&!S&&!m&&v.start>e&&x!==Rc.None&&(!_||_.start<e)&&(S=!0,C=!0,m=!0),S){let R=this.weight;R*=this.evaluateWeight(e,g,this.models,S),R*=this.director.weight;let P=A;if(C)switch(x){case Rc.Hold:break;case Rc.Loop:e+=v.start,P=!0;break;default:e+=v.start,P=!0;break}let T=this.getClipTime(e,v),L=0;const k=b.duration;if(C&&x===Rc.Hold&&(T=0),P){if(b.loop)for(L+=Math.floor(T/(k+1e-6));T>k;)T-=k}else if(!A&&u)switch(w){case Rc.Hold:T=this.getClipTime(v.end,v);break;case Rc.Loop:T%=k;break;case Rc.PingPong:const O=Math.floor(T/k)%2!==0;T%=k,O&&(T=k-T);break}v.reversed===!0?y.time=y.getClip().duration-T:y.time=T,y.timeScale=0;const G=Math.max(0,R);if(y.weight=G,f+=G,y.clampWhenFinished=!1,y.isRunning()||y.play(),this._useclipOffsets){const O=h==0?this._totalOffsetPosition:this._totalOffsetPosition2,W=h==0?this._totalOffsetRotation:this._totalOffsetRotation2;h<1&&(d=1-R),h+=1;const D=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),U=this._summedRot.identity(),Y=this._tempRot.identity(),q=b.rotation;q&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(q,R));const oe=this._actionOffsets[g];if(oe.hasOffsets)for(let xe=0;xe<L;xe++)oe.rootPositionOffset?F.copy(oe.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(U),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),oe.rootQuaternionOffset&&(Y.copy(oe.rootQuaternionOffset),U.multiply(Y)),D.add(F);this._clipRotQuat&&W.multiply(this._clipRotQuat),W.multiply(U),b.position&&D.add(b.position),O.add(D)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,d),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,d)),this.__mixerError===void 0&&(Ic||je())&&(s=(i=this._animator)==null?void 0:i.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((o=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:o.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(a=this._animator)!=null&&a.runtimeAnimatorController){const g=Math.max(0,1-f);(c=(l=this._animator)==null?void 0:l.runtimeAnimatorController)==null||c.update(g)}else this.mixer.update(e)}createRotationInterpolant(e,i,s){var r;const o=s.createInterpolant.bind(s),a=new Se;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const c=o(),h=c.evaluate.bind(c);return c.evaluate=d=>{var u;const m=h(d);if(a.set(m[0],m[1],m[2],m[3]),a.premultiply(this._totalOffsetRotation),l&&a.premultiply(l),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(u=f?.onTimelineRotation)==null||u.call(f,this.director,this.target,d,a);return m[0]=a.x,m[1]=a.y,m[2]=a.z,m[3]=a.w,m},c}}createPositionInterpolant(e,i,s){var r,o;const a=s.createInterpolant.bind(s),l=new M;this.ensureTrackOffsets();const c=(r=this.trackOffset)==null?void 0:r.rotation,h=(o=this.trackOffset)==null?void 0:o.position;let d;s.createInterpolant=()=>{const u=a(),m=u.evaluate.bind(u);return u.evaluate=f=>{var g,v,y;const b=m(f);if(l.set(b[0],b[1],b[2]),i.removeStartOffset&&(d===void 0?(d=null,d=(v=(g=this._actionOffsets.find(A=>A.clip===e))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):d!=null&&d.isVector3&&l.sub(d)),l.applyQuaternion(this._totalOffsetRotation),l.add(this._totalOffsetPosition),c&&l.applyQuaternion(c),h&&(l.x-=h.x,l.y+=h.y,l.z+=h.z),this.director.animationCallbackReceivers)for(const A of this.director.animationCallbackReceivers)(y=A?.onTimelinePosition)==null||y.call(A,this.director,this.target,f,l);return b[0]=l.x,b[1]=l.y,b[2]=l.z,b},u}}}const hye=te("mutetimeline"),OA=class extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"listener"),p(this,"audio",[]),p(this,"audioContextTimeOffset",[]),p(this,"lastTime",0),p(this,"audioSource"),p(this,"_audioLoader",null),p(this,"_playableDirectorResumed",!1)}getAudioFilePath(n){const e=this.director.sourceId;return Qd(e,n)}onAllowAudioChanged(n){for(let e=0;e<this.models.length;e++){const i=this.models[e];this.audio[e].setVolume(n?i.asset.volume:0)}}addModel(n){const e=new rI(this.listener);this.audio.push(e);const i=n;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const n of this.audio)n.isPlaying&&n.stop();for(const n of this.models)n._didTriggerPlay=!1}onDestroy(){for(const n of this.audio)n.source&&n?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}for(const n of this.models)n._didTriggerPlay=!1}onPauseChanged(){for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(n){if(hye||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const s=e?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r],l=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,n-1,n+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=l.loop,n>=o.start&&n<=o.end&&n<this.director.duration){if(!a.isPlaying||!this.director.isPlaying)(i||!o._didTriggerPlay&&this.lastTime<n)&&(o.duration*o.timeScale>.3?a.offset=o.clipIn+(n-o.start)*o.timeScale:a.offset=0,Ic&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+o.asset.clip),a.play(s),o._didTriggerPlay=!0);else{const h=o.clipIn+(n-o.start)*o.timeScale,d=a.context.currentTime-a._startedAt+a.offset;Math.abs(h-d)>.3&&(a.offset=h,a.stop(),a.play(s))}let c=l.volume;if(this.track.volume!==void 0&&(c*=this.track.volume),e&&(c=0),o.easeInDuration>0){const h=Math.min((n-o.start)/o.easeInDuration,1);c*=h}if(o.easeOutDuration>0){const h=Math.min((o.end-n)/o.easeOutDuration,1);c*=h}a.setVolume(c*this.director.weight)}else o._didTriggerPlay=!1,this.director.isPlaying&&a.isPlaying&&a.stop()}this.lastTime=n}loadAudio(n,e=0,i=0){let s=null;const r=n-i,o=n+e;for(const a of this.models)if(this.isInTimeRange(a,r,o)){const l=this.audio[this.models.indexOf(a)],c=this.handleAudioLoading(a,l);c!==null&&(s===null&&(s=[]),s.push(c))}return s!==null?Promise.all(s):null}isInTimeRange(n,e,i){return e<=n.start&&i>=n.end||e>=n.start&&e<=n.end||i>=n.start&&i<=n.end}static dispose(){OA._audioBuffers.clear()}handleAudioLoading(n,e){this._audioLoader||(this._audioLoader=new i_);const i=this.getAudioFilePath(n.asset.clip);if(OA._audioBuffers.get(i)){const r=OA._audioBuffers.get(i);return r.then(o=>{o&&e.setBuffer(o)}),r}Ic&&console.warn("LOAD audio track",i,this.director.sourceId);const s=new Promise((r,o)=>{this._audioLoader.load(i,a=>{e.setBuffer(a),r(a)},void 0,a=>{console.error("Error loading audio",a),r(null)})});return OA._audioBuffers.set(i,s),s}};let DA=OA;p(DA,"_audioBuffers",new Map);class GA extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"didTrigger",[]),p(this,"receivers",[])}evaluate(e){var i;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-e;let c=!1;if(o.retroActive)c=l<=1e-6;else{const h=Math.abs(l);(h===0||h>=1e-5&&h<s)&&(c=!0)}if(c){if(!a)if(Ic&&console.log("Trigger signal",e,o.time,o),this.didTrigger[r]=!0,((i=this.receivers)==null?void 0:i.length)<=0)O0.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class pM extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"timelines",[]),p(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let i=this.models.length-1;i>=0;i--){const s=this.models[i].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",i,s),this.models.splice(i,1);continue}else{const r=ie.getComponent(s.sourceObject,Fu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const a=this.getClipTime(e,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[s];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;a?.sourceObject!==l&&(l.visible=!1)}}}}}const dye=te("debugpost");let AO=null;function uye(n){AO=n}function gQ(n){let e=n.gameObject;for(;e;){for(const i of gC(e))if(i.isPostProcessingManager===!0)return i;e=e.parent}return null}function pye(n){let e=gQ(n);if(!e)if(AO){dye&&console.warn("Adding postprocessing manager to the scene.");const i=n.scene;e=ra(i,AO)}else je()&&console.warn("No post processing manager found");return e}var mye=Object.defineProperty,fye=Object.getOwnPropertyDescriptor,yQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?fye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&mye(e,i,r),r};const gye=te("debugpost");class qe{constructor(e){p(this,"isVolumeParameter",!0),p(this,"_isInitialized",!1),p(this,"_active",!0),p(this,"_value"),p(this,"_valueRaw"),p(this,"_defaultValue"),p(this,"valueProcessor"),p(this,"onValueChanged"),e!==void 0&&this.initialize(e)}get isInitialized(){return this._isInitialized}initialize(e){e!==void 0&&(this._value=e,this._defaultValue=e,this._valueRaw=e,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const i=e?this._valueRaw:this._defaultValue;this.processValue(i,!0)}get value(){return this._valueRaw}set value(e){this.isInitialized||this.initialize(e),this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,i){if(e==null||!i&&this.testIfValueChanged(e)===!1)return;const s=this._value;gye&&typeof s=="number"&&typeof e=="number"&&(s?.toFixed(4),e?.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}yQ([E()],qe.prototype,"overrideState",1),yQ([E()],qe.prototype,"value",1);class yye extends Ha{constructor(){super([qe])}onSerialize(e,i){}onDeserialize(e,i){const s=i.target,r=i.path;let o;if(s&&r&&(o=s[r]),(typeof o!="object"||typeof o=="object"&&o.isVolumeParameter!==!0)&&(o=new qe),typeof e=="object"&&"value"in e){const a=e.value;o.initialize(a),o.overrideState=e.overrideState}else o.value=e;return o}}new yye;var vye=Object.defineProperty,bye=Object.getOwnPropertyDescriptor,Aye=(n,e,i,s)=>{for(var r=s>1?void 0:s?bye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&vye(e,i,r),r};const xye=te("debugpost");class Us extends Pe{constructor(e=void 0){if(super(),p(this,"active",!0),p(this,"_manager",null),p(this,"_result"),p(this,"_postprocessingContext",null),e)for(const i of Object.keys(e)){const s=e[i],r=this[i];r instanceof qe?r.initialize(s):r!==void 0&&(this[i]=s)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var e;super.onDisable(),(e=this._manager)==null||e.removeEffect(this),this.active=!1}onEffectEnabled(e){var i;e&&e.isPostProcessingManager===!0?this._manager=e:this._manager||(this._manager=pye(this)),(i=this._manager)==null||i.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(e){var i;return this._postprocessingContext=e,this._result||(this.initParameters(),this._result=(i=this.onCreateEffect)==null?void 0:i.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){xye&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const i of e){const s=this[i];s instanceof qe&&s.__init()}}onEditorModification(e){const i=e.propertyName;if(this[i]instanceof qe){const s=e.value;return this[i].value=s,!0}}}Aye([E()],Us.prototype,"active",2);var wye=Object.defineProperty,_ye=Object.getOwnPropertyDescriptor,Sye=(n,e,i,s)=>{for(var r=s>1?void 0:s?_ye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&wye(e,i,r),r};const Cye=te("debugpost"),xO={};function Ja(n,e){xO[n]=e}function Mye(n){return n.__type in xO?xO[n.__type]:(Cye&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Us)}class NA{constructor(){p(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(i=>i.init())}addEffect(e){this.components.push(e)}removeEffect(e){const i=this.components.indexOf(e);i>=0&&this.components.splice(i,1)}}Sye([R0([n=>Mye(n),Us])],NA.prototype,"components",2);var Eye=Object.defineProperty,Tye=Object.getOwnPropertyDescriptor,Rye=(n,e,i,s)=>{for(var r=s>1?void 0:s?Tye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Eye(e,i,r),r};class FA extends Us{constructor(){super(...arguments),p(this,"preset",new qe(cm.HIGH))}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new cV({preset:cm.HIGH,edgeDetectionMode:EL.DEPTH});return this.preset.onValueChanged=i=>{e.applyPreset(i)},e}}Rye([E(qe)],FA.prototype,"preset",2),Ja("Antialiasing",FA);const Iye=te("debugusdz");class vp{constructor(){p(this,"files",new Array)}static getName(e){var i;const s=e.split(".").pop();let r=(i=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:i.replace(".","_");return r||(r="Audio_"+Math.random().toString(36).substring(2,15)),Ul(r)+"."+s}get extensionName(){return"Audio"}onExportObject(e,i,s){const r=ie.getComponents(e,Cn);if(r.length)for(const o of r){if(!o.clip||typeof o.clip!="string"||!o.playOnAwake)continue;const a=o.clip.split("/").pop()||"Audio",l=vp.getName(o.clip),c=Ul(l);if(!this.files.some(h=>h.path===o.clip)){this.files.push({path:o.clip,name:l});const h=l.toLowerCase();s.quickLookCompatible&&!h.endsWith(".mp3")&&!h.endsWith(".wav")&&!h.endsWith(".m4a")&&console.error("Audio file "+o.clip+" from "+o.name+" is not an MP3 or WAV file. QuickLook may not support playing it.")}s.quickLookCompatible||i.addEventListener("serialize",(h,d)=>{h.appendLine(),h.beginBlock(`def SpatialAudio "${c}"`,"(",!1),h.appendLine(`displayName = "${a}"`),h.closeBlock(")"),h.beginBlock(),h.appendLine(`uniform asset filePath = @audio/${l}@`),h.appendLine(`uniform token auralMode = "${o.spatialBlend>0?"spatial":"nonSpatial"}"`),h.appendLine(`uniform token playbackMode = "${o.loop?"loopFromStage":"onceFromStart"}"`),h.appendLine(`uniform float gain = ${o.volume}`),h.closeBlock()})}}async onAfterSerialize(e){for(const i of this.files){const s="audio/"+i.name;if(e.files[s]){Iye&&console.warn("Audio file with name "+s+" already exists in the context. Skipping.");continue}const r=await(await(await fetch(i.path)).blob()).arrayBuffer(),o=new Uint8Array(r);e.files[s]=o}}}const qh=te("debugautosync"),wO=Symbol("syncerId");class Lye{constructor(){p(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const i=new Pye(e);return i[wO]=e.guid,this._syncers[i[wO]]=i,i}removeSyncer(e){delete this._syncers[e[wO]]}}const _O=new Lye;class Pye{constructor(e){p(this,"comp"),p(this,"hasChanges",!1),p(this,"changedProperties",{}),p(this,"_isReceiving",!1),p(this,"_isInit",!1),p(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const i=this.comp.context.connection;if(!i||!i.isConnected||!i.isInRoom){for(const s in this.changedProperties)delete this.changedProperties[s];return}for(const s in this.changedProperties){const r=this.comp.guid+"/"+s,o=this.changedProperties[s];qh&&console.log("SEND",this.comp.name,this.networkingKey),i.send(this.networkingKey,{guid:r,data:o},Bl.Queued)}}),p(this,"onHandleReceiving",i=>{if(qh&&console.log("RECEIVE",this.comp.name,this.comp.guid,i),!this._isInit||!this.comp||i.guid.startsWith(this.comp.guid)===!1)return;const[s,r]=i.guid.split("/");qh&&console.log("RECEIVED",this.comp.name,this.comp.guid,i);try{this._isReceiving=!0,this.comp[r]=i.data}catch(o){console.error(o)}finally{this._isReceiving=!1}}),this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const i=this.comp.context.connection.tryGetState(this.comp.guid);i&&this.onHandleReceiving(i)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,i){this._isReceiving||(qh&&console.log("Property changed: "+e,i),this.hasChanges=!0,this.changedProperties[e]=i)}}function kye(n,e){let i=e!==n;return!i&&n&&e&&(Array.isArray(n)&&Array.isArray(e)||typeof n=="object"&&typeof e=="object")&&(i=!0),i}const zA=Symbol("AutoSyncHandler");function Bye(n){if(n[zA])return n[zA];const e=_O.getOrCreateSyncer(n);return e?.init(n),n[zA]=e,e}function Oye(n){const e=n[zA];e&&(_O.removeSyncer(e),e.destroy(),delete n[zA])}const SO=function(n=null){return function(e,i){var s;let r="";typeof i=="string"?r=i:r=i.name;let o=null,a;typeof n=="string"?a=e[n]:typeof n=="function"&&(a=n),a==null&&(je()||qh)&&n!=null&&console.warn('syncField: no callback function found for property "'+r+'"','"'+n+'"');const l=e,c=l.__internalAwake;if(typeof c!="function"){(qh||je())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((s=e?.constructor)==null?void 0:s.name)+'" is not supported',e);return}qh&&console.log(r);const h=Symbol(r);l.__internalAwake=function(){if(this[h]!==void 0)return;this[h]=this[r],o=_O.getOrCreateSyncer(this);const u=Object.getOwnPropertyDescriptor(this,r);if(u?.set===void 0){let m=!1;Object.defineProperty(this,r,{set:function(f){var g;const v=this[h];if(this[h]=f,m){(je()||qh)&&console.warn("Recursive call detected",r);return}m=!0;try{const y=kye(f,v);qh&&console.log("SyncField assignment",r,"changed?",y,f,a),y&&a?.call(this,f,v)!==!1&&((g=Bye(this))==null||g.notifyChanged(r,f))}finally{m=!1}},get:function(){return this[h]},configurable:!0,enumerable:!0})}o?.init(this),c.call(this)};const d=l.__internalDestroy;l.__internalDestroy=function(){Oye(this),d.call(this)}}};var Dye=Object.defineProperty,Gye=Object.getOwnPropertyDescriptor,mM=(n,e,i,s)=>{for(var r=s>1?void 0:s?Gye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Dye(e,i,r),r};const da=te("debugplayersync"),vQ=class extends Pe{constructor(){super(...arguments),p(this,"autoSync",!0),p(this,"asset"),p(this,"onPlayerSpawned"),p(this,"_localInstance"),p(this,"onJoinedRoom",()=>{da&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()}),p(this,"destroyInstance",()=>{var n;(n=this._localInstance)==null||n.then(e=>{da&&console.log("PlayerSync.destroyInstance",e),qb(e,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(n,e){const i=ei.getOrCreateFromUrl(n);if(!i.asset){const o=await i.loadAssetAsync();ie.getOrAddComponent(o,ua)}const s=new vQ;s._internalInit(e),s.asset=i;const r=new ge;return r.guid=n,ie.addComponent(r,s),s}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new ji)}onEnable(){this.context.connection.beginListen(Xt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Xt.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Xt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Xt.LeftRoom,this.destroyInstance)}async getInstance(){var n,e,i,s,r,o;if(this._localInstance)return this._localInstance;if(da&&console.log("PlayerSync.createInstance",(n=this.asset)==null?void 0:n.url),!((e=this.asset)!=null&&e.asset)&&!((i=this.asset)!=null&&i.url))return console.error('PlayerSync: can not create an instance because "asset" is not set and or has no URL!'),null;this.gameObject.guid||console.warn("PlayerSync: gameObject has no guid! This might cause issues with syncing the player state."),this._localInstance=(s=this.asset)==null?void 0:s.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const a=await this._localInstance;if(a){const l=ie.getComponentsInChildren(a,ua);if(l!=null&&l.length){for(const c of l)c.owner=this.context.connection.connectionId;(r=this.onPlayerSpawned)==null||r.invoke(a)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.url)+"</strong>: please make sure the asset has a PlayerState component!"),ie.destroySynced(a)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",n=>{if(document.visibilityState==="visible")for(let e=ua.all.length-1;e>=0;e--){const i=ua.all[e];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}};let D0=vQ;mM([E()],D0.prototype,"autoSync",2),mM([E(ei)],D0.prototype,"asset",2),mM([E(ji)],D0.prototype,"onPlayerSpawned",2);var bQ=(n=>(n.OwnerChanged="ownerChanged",n))(bQ||{}),UA;const or=(UA=class extends Pe{constructor(){super(...arguments),p(this,"onOwnerChangeEvent",new ji),p(this,"onFirstOwnerChangeEvent",new ji),p(this,"hasOwner",!1),p(this,"owner"),p(this,"dontDestroy",!1),p(this,"onUserLeftRoom",n=>{if(n.userId===this.owner){da&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return or._all}static get local(){return or._local}static getFor(n){if(n instanceof ge)return ie.getComponentInParent(n,or);if(n instanceof Pe)return ie.getComponentInParent(n.gameObject,or)}static isLocalPlayer(n){const e=or.getFor(n);return e?.isLocalPlayer??!1}static addEventListener(n,e){return this._callbacks[n]||(this._callbacks[n]=[]),this._callbacks[n].push(e),e}static removeEventListener(n,e){if(!this._callbacks[n])return;const i=this._callbacks[n].indexOf(e);i>=0&&this._callbacks[n].splice(i,1)}static dispatchEvent(n,e){if(this._callbacks[n])for(const i of this._callbacks[n])i(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(n,e){var i,s;da&&console.log("PlayerSync.onOwnerChange",this,"newOwner",n,"oldOwner",e);const r=or._local.indexOf(this);r>=0&&or._local.splice(r,1);const o={playerState:this,oldValue:e,newValue:n};if(this.hasOwner||(this.hasOwner=!0,(i=this.onFirstOwnerChangeEvent)==null||i.invoke(o)),(s=this.onOwnerChangeEvent)==null||s.invoke(o),this.owner===this.context.connection.connectionId){or._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:o});this.dispatchEvent(l)}const a=new CustomEvent("owner-changed",{detail:o});this.dispatchEvent(a),or.dispatchEvent("ownerChanged",a)}awake(){or.all.push(this),da&&console.log("Registered new PlayerState",this.guid,or.all.length-1,or.all),this.context.connection.beginListen(Xt.UserLeftRoom,this.onUserLeftRoom)}async start(){da&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await bl(300),this.context.connection.userIsInRoom(this.owner)==!1&&(da&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(da&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?da&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(da&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):da&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){da&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),qb(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(this.context.connection.stopListen(Xt.UserLeftRoom,this.onUserLeftRoom),or.all.splice(or.all.indexOf(this),1),this.isLocalPlayer){const n=or._local.indexOf(this);n>=0&&or._local.splice(n,1)}}},p(UA,"_all",[]),p(UA,"_local",[]),p(UA,"_callbacks",{}),UA);let ua=or;mM([SO(ua.prototype.onOwnerChange)],ua.prototype,"owner",2);const Nye=te("debugavatar"),Lc=class extends Pe{constructor(){super(...arguments),p(this,"connectionId"),p(this,"avatar")}static getAvatar(n){return n>=0&&n<Lc.instances.length?Lc.instances[n]:null}static onAvatarMarkerCreated(n){return Lc._onNewAvatarMarkerAdded.push(n),n}static onAvatarMarkerDestroyed(n){return Lc._onAvatarMarkerDestroyed.push(n),n}awake(){Lc.instances.push(this),Nye&&console.log(this);for(const n of Lc._onNewAvatarMarkerAdded)n({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Lc.instances.splice(Lc.instances.indexOf(this),1);for(const n of Lc._onAvatarMarkerDestroyed)n({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ar=Lc;p(ar,"instances",[]),p(ar,"_onNewAvatarMarkerAdded",[]),p(ar,"_onAvatarMarkerDestroyed",[]);var Fye=Object.defineProperty,zye=Object.getOwnPropertyDescriptor,Uye=(n,e,i,s)=>{for(var r=s>1?void 0:s?zye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Fye(e,i,r),r};const G0=te("debugxrflags"),AQ=te("disablexrflags");AQ&&console.warn("XRFlags are disabled");var Pc=(n=>(n[n.Never=0]="Never",n[n.Browser=1]="Browser",n[n.AR=2]="AR",n[n.VR=4]="VR",n[n.FirstPerson=8]="FirstPerson",n[n.ThirdPerson=16]="ThirdPerson",n[n.All=4294967295]="All",n))(Pc||{});const xQ=class{constructor(){p(this,"Mask",17)}Has(n){return(this.Mask&n)!==0}Set(n){G0&&console.warn("Set XR flag state to",n),this.Mask=n,pa.Apply()}Enable(n){this.Mask|=n,pa.Apply()}Disable(n){this.Mask&=~n,pa.Apply()}Toggle(n){this.Mask^=n,pa.Apply()}EnableAll(){this.Mask=-1,pa.Apply()}DisableAll(){this.Mask=0,pa.Apply()}};let go=xQ;p(go,"Global",new xQ);var VA;const $h=(VA=class extends Pe{constructor(){super(...arguments),p(this,"visibleIn")}static Apply(){for(const n of this.registry)n.UpdateVisible(go.Global)}awake(){$h.registry.push(this)}onEnable(){$h.firstApply?this.UpdateVisible(go.Global):($h.firstApply=!0,$h.Apply())}onDestroy(){const n=$h.registry.indexOf(this);n>=0&&$h.registry.splice(n,1)}get isOn(){return this.gameObject.visible}UpdateVisible(n=null){if(AQ)return;let e;const i=n;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),G0&&console.log(i),$h.buffer.Mask=i,n=$h.buffer),n instanceof go?(G0&&console.warn(this.name,"use passed in mask",n.Mask,this.visibleIn),e=n.Has(this.visibleIn)):(G0&&console.log(this.name,"use global mask"),go.Global.Has(this.visibleIn)),e!==void 0)if(e)G0&&console.log(this.name,"is visible",this.gameObject.uuid),ie.setActive(this.gameObject,!0);else{if(G0&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},p(VA,"registry",[]),p(VA,"firstApply"),p(VA,"buffer",new go),VA);let pa=$h;Uye([E()],pa.prototype,"visibleIn",2);var Vye=Object.defineProperty,Xye=Object.getOwnPropertyDescriptor,CO=(n,e,i,s)=>{for(var r=s>1?void 0:s?Xye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Vye(e,i,r),r};const XA=te("debugwebxr"),wQ=new Se().setFromAxisAngle(new M(0,1,0),Math.PI);class zu extends Pe{constructor(){super(...arguments),p(this,"head"),p(this,"leftHand"),p(this,"rightHand"),p(this,"_leftHandMeshes"),p(this,"_rightHandMeshes"),p(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;XA&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=ua.getFor(this);if(i!=null&&i.owner){const s=this.gameObject.addComponent(ar);s.avatar=this.gameObject,s.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(e){const i=this.gameObject.getComponent(ar);i&&i.destroy()}onUpdateXR(e){var i,s;if(!this.activeAndEnabled)return;const r=ua.isLocalPlayer(this);if(!r)return;const o=e.xr;if(o.rig&&o.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),o.rig.gameObject.add(this.gameObject)),this._syncTransforms&&r)for(const d of this._syncTransforms)d.fastMode=!0,d.isOwned()||d.requestOwnership();if(this.head&&this.context.mainCamera){const d=this.head.asset;if(d.position.copy(this.context.mainCamera.position),d.position.x*=-1,d.position.z*=-1,d.quaternion.copy(this.context.mainCamera.quaternion),d.quaternion.x*=-1,this.context.time.frameCount%10===0){const u=ie.getComponentsInChildren(this.head.asset,pa);for(const m of u)m.enabled=!1,m.gameObject.visible=!1}}const a=e.xr.leftController,l=(i=this.leftHand)==null?void 0:i.asset;a&&l?(l.position.copy(a.gripPosition),l.quaternion.copy(a.gripQuaternion),l.quaternion.multiply(wQ),l.visible=a.isTracking,this.updateHandVisibility(a,l,this._leftHandMeshes)):l&&l.visible&&(l.visible=!1);const c=e.xr.rightController,h=(s=this.rightHand)==null?void 0:s.asset;c&&h?(h.position.copy(c.gripPosition),h.quaternion.copy(c.gripQuaternion),h.quaternion.multiply(wQ),h.visible=c.isTracking,this.updateHandVisibility(c,h,this._rightHandMeshes)):h&&h.visible&&(h.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(e,i,s){if(s){const r=e.model&&e.model.visible&&e.model!==i;s.forEach(o=>{Vh(o,!r)})}}updateRemoteAvatarVisibility(){var e,i,s;if(this.context.connection.isConnected){const r=ua.getFor(this);if(r&&r.isLocalPlayer==!1){const o=Et.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(e=this.leftHand)==null?void 0:e.asset;a&&(a.visible=o?.isTracking(r.owner,"left")??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=o?.isTracking(r.owner,"right")??!1)}if((s=this.head)!=null&&s.asset){const a=ie.getComponentsInChildren(this.head.asset,pa);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};u4.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof ge&&(this.head=new ei("",this.sourceId,this.head));else{const e=new ge;e.name="Head";const i=vu.createPrimitive(_m.Cube);e.add(i),this.gameObject.add(e),this.head=new ei("",this.sourceId,e),XA&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof ge&&(this.rightHand=new ei("",this.sourceId,this.rightHand));else{const e=new ge;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new ei("",this.sourceId,e),XA&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof ge&&(this.leftHand=new ei("",this.sourceId,this.leftHand));else{const e=new ge;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new ei("",this.sourceId,e),XA&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],this.leftHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._leftHandMeshes.push(e)}),this._rightHandMeshes=[],this.rightHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._rightHandMeshes.push(e)}),ua.isLocalPlayer(this.gameObject)&&(this._syncTransforms=ie.getComponentsInChildren(this.gameObject,Ec))}async loadAvatarObjects(e,i,s){const r=e.loadAssetAsync(),o=i.loadAssetAsync(),a=s.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await f_(l);XA&&console.log("Avatar loaded results:",c)}}CO([E(ei)],zu.prototype,"head",2),CO([E(ei)],zu.prototype,"leftHand",2),CO([E(ei)],zu.prototype,"rightHand",2);class kc{static Add(e,i,s=null){if(i){for(const r of this.Pois)if(r.obj===i)return;this.Pois.push({obj:i,avatar:s}),this.LastChangeTime=e.time.time}}static Remove(e,i){var s;if(i){for(const r of this.Pois)if(r.obj===i){this.Pois.splice(this.Pois.indexOf(r),1),this.LastChangeTime=e?.time.time??((s=Pt.Current)==null?void 0:s.time.time);return}}}}p(kc,"Pois",[]),p(kc,"LastChangeTime",0);class Wye{constructor(){p(this,"guid"),p(this,"position",new M)}}class WA extends Pe{constructor(){super(...arguments),p(this,"target",null),p(this,"avatar",null),p(this,"_model",null),p(this,"_targetModel",new Wye),p(this,"_currentTargetObject",null),p(this,"_lastUpdateTime",0),p(this,"_lookDuration",0),p(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const i=Z.get("MoveRandom");if(i&&this.target){const s=ie.getComponent(this.target,i);s&&s.destroy()}}awake(){if(this.avatar=ie.getComponentInParent(this.gameObject,ar),this.avatar){const e=ie.getComponentInParent(this.gameObject,ar);this._model=new gk(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var i;this.target&&e&&e.guid===((i=this.avatar)==null?void 0:i.guid)&&bs(this.target,e.position)})}update(){var e;if((!this.context.connection.isConnected||(e=this._model)!=null&&e.hasOwnership)&&(kc.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=kc.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const i=Nt(this._currentTargetObject);bs(this.target,i),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(i))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const e=kc.Pois;if(e.length>0){const i=e[Math.floor(Math.random()*e.length)];if(i&&i.obj){if(i.avatar&&i.avatar===this.avatar)return;this._currentTargetObject=i.obj}}}}}function _Q(n){return n&&n.isComponent}const Hye=Symbol("object"),MO=new Yo(()=>new M,20);class SQ{constructor(e,i,s,r,o,a){p(this,"_point"),p(this,"_normal"),p(this,"_tangentVelocity"),p(this,"distance"),p(this,"impulse"),p(this,"friction"),this._point=e,this.distance=i,this._normal=s,this.impulse=r,this.friction=o,this._tangentVelocity=a}get point(){return MO.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return MO.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return MO.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class CQ{constructor(e,i,s){p(this,"contacts"),p(this,"me"),p(this,"_collider"),p(this,"_gameObject"),this.me=e,this._collider=i,this._gameObject=i.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class MQ{constructor(e,i){p(this,"object"),p(this,"collider"),this.object=e,this.collider=i}}const Zn=te("debugnetworkingstreams");var Bc=(n=>(n.Connected="peer-user-connected",n.StreamReceived="receive-stream",n.StreamEnded="call-ended",n.Disconnected="peer-user-disconnected",n.UserJoined="user-joined",n))(Bc||{});class EO{constructor(e,i){p(this,"type","call-ended"),p(this,"userId"),p(this,"direction"),this.userId=e,this.direction=i}}class EQ{constructor(e,i,s){p(this,"type","receive-stream"),p(this,"userId"),p(this,"stream"),p(this,"target"),this.userId=e,this.stream=i,this.target=s}}class jye{constructor(e,i){p(this,"guid"),p(this,"peerId"),p(this,"dontSave",!0),this.guid=e.id,this.peerId=i}}var TQ=(n=>(n.Incoming="incoming",n.Outgoing="outgoing",n))(TQ||{});class Qye extends Ts{constructor(e,i,s,r=null){super(),p(this,"peerId"),p(this,"userId"),p(this,"direction"),p(this,"call"),p(this,"_stream",null),p(this,"_isDisposed",!1),this.peerId=i.peer,this.userId=e,this.call=i,this.direction=s,this._stream=r,i.on("stream",o=>{if(Zn&&console.log("Receive stream",`
|
|
5956
|
+
Could not find method ${h.method} on object ${u.name}`,u,typeof u[h.method])};if(typeof u[h.method]!="function"){let g=!1,v=u;for(;v;){const y=Object.getOwnPropertyDescriptor(v,h.method);if(y&&(y.writable===!0||y.set)){g=!0;break}v=Object.getPrototypeOf(v)}!g&&(je()||Ds)&&f()}}if(u){let f=h.argument;if(f!==void 0?f=d(f):h.arguments!==void 0&&(f=h.arguments.map(d)),!u[h.method])console.warn(`EventList method not found: "${h.method}" on ${u?.name}`);else{f!==void 0&&!Array.isArray(f)&&(f=[f]);const g=new Tc(u,h.method,f,h.enabled);a.push(g)}}else je()&&console.warn("[Debug] EventList: Could not find event listener in scene",h,i.object,e)}const l=new ji(a);Ds&&console.log(l);const c=i.target;return c!==void 0&&i.path!==void 0&&l.setEventTarget(i.path,c),l}}}const V0e=new U0e,sM=new WeakMap,X0e=Vt.prototype.clone;Vt.prototype.clone=function(){const n=X0e.call(this);return sM.has(n)||sM.set(n,this),n};class hQ extends Ha{constructor(){super([I0,Yt])}onSerialize(e,i){}onDeserialize(e,i){if(e instanceof Vt&&i.type===I0){let s=e;sM.has(s)&&(s=sM.get(s)),s.isRenderTargetTexture=!0,s.flipY=!0,s.offset.y=1,s.repeat.y=-1,s.needsUpdate=!0,s.mipmaps=[],s instanceof Vd&&(s.isCompressedTexture=!1,s.format=wi);const r=new I0(s.image.width,s.image.height,{colorSpace:ki});return r.texture=s,r}}}new hQ;class dQ extends Ha{constructor(){super([URL])}onSerialize(e,i){return null}onDeserialize(e,i){if(typeof e=="string"&&e.length>0)return Qd(i.gltfId,e)}}new dQ;var W0e=Object.defineProperty,H0e=Object.getOwnPropertyDescriptor,j0e=(n,e,i,s)=>{for(var r=s>1?void 0:s?H0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&W0e(e,i,r),r};class IA extends Pe{awake(){Ka.createIfNoneExists(this.context)}onEnable(){var e;(e=Ka.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Ka.get(this.context))==null||e.unregister(this)}}class ca extends IA{constructor(){super(...arguments),p(this,"targets",null),p(this,"raycastHits",[]),p(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Ac),e.targets=this.targets,e.results=this.raycastHits,e.useAcceleratedRaycast=!0;const i=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=r=>r instanceof Mo?"continue in children":i?i(r):!0);const s=this.context.physics.raycast(e);return e.testObject=i,s}}j0e([E()],ca.prototype,"ignoreSkinnedMeshes",2);class rM extends ca{constructor(){super(),this.ignoreSkinnedMeshes=!0}}const uQ=class extends IA{performRaycast(n){if(!Et.active||!uQ.allow||!(n!=null&&n.ray))return null;const e=n.ray.origin,i=.015;return this.context.physics.sphereOverlap(e,i,!1,!0)}};let P0=uQ;p(P0,"allow",!0);class oM{static getObject(e){const i=e[Ya];return i&&(i.isComponent===!0?e=i.gameObject:e=i),e}static isInteractable(e,i){if(i&&(i.canvasGroup=void 0,i.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const s=this.tryFindCanvasGroup(e);if(s?.isCanvasGroup===!0&&(i&&(i.canvasGroup=s),s.blocksRaycasts===!1||s.interactable===!1))return!1;const r=Pm(e,o=>{if(o.isGraphic===!0)return o},!1);return i&&r?.isGraphic===!0&&(i.graphic=r),!(r?.raycastTarget===!1||r?.layer===2)}static tryFindCanvasGroup(e){if(!e)return null;const i=Pm(e,s=>{const r=s;if(r.blocksRaycasts!==void 0&&r.interactable!==void 0)return r},!1);return i!==void 0?i:this.tryFindCanvasGroup(e.parent)}}function dO(n){return n[Ya]||(n.parent?dO(n.parent):null)}function Q0e(n){return n.isUI===!0||typeof n[Ya]=="object"}function aM(n,e){if(!n)return;const i=n.material;if(i?.isMaterial===!0){const s=n.parent;s&&s.isText,i.side=e.doubleSided??!0?Ai:Vn,i.shadowSide=e.doubleSided?Ai:Vn,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of n.children)aM(s,e)}function k0(n,e,i){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const s=Proxy.revocable(n[e],{set(a,l,c,h){const d=a[l],u=Reflect.set(a,l,c,h);return i(c,d),u}}),r=s.revoke,o=n[e];return s.revoke=()=>{n[e]=o,r()},n[e]=s.proxy,s}const pQ=Symbol("Scheduled action");function Z0e(n,e,i=Ji.OnBeforeRender){let s=n[pQ];s||(s=n[pQ]={});const r=e.name;s[i]||(s[i]={});const o=s[i];if(o[r])return;function*a(){e?.call(n),o[r]=null}const l=n.startCoroutine(a(),i);o[r]=l}const Zh=te("debugeventsystem");var uO=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(uO||{});const Yh=class extends Pe{constructor(){super(),p(this,"raycaster",[]),p(this,"pressedByID",new Map),p(this,"hoveredByID",new Map),p(this,"onPointerEvent",n=>{if(n===void 0||n.propagationStopped||n.defaultPrevented||n.used)return;const e=new Qy(this.context.input,n);this._currentPointerEventName=n.type,e.inputSource=this.context.input,e.isClick=n.isClick,e.isDoubleClick=n.isDoubleClick,e.isDown=n.type==yn.PointerDown,e.isUp=n.type==yn.PointerUp,e.isPressed=this.context.input.getPointerPressed(n.pointerId),Zh&&(e.isDown?console.log("DOWN",e.pointerId):e.isUp&&console.log("UP",e.pointerId),e.isClick&&console.log("CLICK",e.pointerId));const i=new Ac;n.hasRay?i.ray=n.ray:i.screenPoint=this.context.input.getPointerPositionRC(n.pointerId);const s=this.performRaycast(i);if(s){for(const o of s)o.event=n,n.intersections.push(o);n.origin.onPointerHits&&n.origin.onPointerHits({sender:this,event:n,hits:s})}Zh&&e.isClick&&gn("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown);const r={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:r})),this.handleIntersections(s,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:r}))}),p(this,"_sortedHits",[]),p(this,"_testObjectsCache",new Map),p(this,"_currentlyActiveRaycaster",null),p(this,"_currentPointerEventName",null),p(this,"shouldRaycastObject",n=>{var e;let i=null;if(Q0e(n)&&(i=(e=n[Ya])==null?void 0:e.gameObject),this._testObjectsCache.has(n)||i&&this._testObjectsCache.has(i))return this._testObjectsCache.get(n)===!1?"continue in children":!0;{let s=tM(n,this._currentPointerEventName);if(!s&&i&&(s=tM(i,this._currentPointerEventName)),s){this._testObjectsCache.set(n,!0);for(const r of n.children)this.shouldRaycastObject_AddToYesCache(r);return!0}return this._testObjectsCache.set(n,!1),"continue in children"}}),p(this,"_sortingBuffer",[]),p(this,"_noDepthTestingResults",[]),p(this,"out",{}),p(this,"_capturedPointer",{}),p(this,"pointerEnterSymbol",Symbol("pointerEnter")),p(this,"pointerExitSymbol",Symbol("pointerExit")),p(this,"currentActiveMeshUIComponents",[]),Yh.systems.push(this)}static createIfNoneExists(n){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Yh.systems.length<=0&&Yh.systems.push(...ie.findObjectsOfType(Yh,n)));for(const i of Yh.systems)if(i.context===n)return;const e=new ge;ie.addComponent(e,Yh),n.scene.add(e)}static get systems(){const n=Pt.Current;return this._eventSystemMap.has(n)||this._eventSystemMap.set(n,[]),this._eventSystemMap.get(n)}static get(n){const e=this._eventSystemMap.get(n);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(n,e,i=!1){Bu.update(n,e,i)}static markUIDirty(n){Bu.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Yh.systems.splice(Yh.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ie.findObjectOfType(IA,this.context)){const n=ie.addComponent(this.context.scene,ca);this.raycaster.push(n),(je()||Zh)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(n){var e;n&&this.raycaster&&!this.raycaster.includes(n)&&((e=this.raycaster)==null||e.push(n))}unregister(n){var e,i;const s=(e=this.raycaster)==null?void 0:e.indexOf(n);s!==void 0&&s!==-1&&((i=this.raycaster)==null||i.splice(s,1))}onEnable(){this.context.input.addEventListener(yn.PointerDown,this.onPointerEvent),this.context.input.addEventListener(yn.PointerUp,this.onPointerEvent),this.context.input.addEventListener(yn.PointerMove,this.onPointerEvent)}onDisable(){this.context.input.removeEventListener(yn.PointerDown,this.onPointerEvent),this.context.input.removeEventListener(yn.PointerUp,this.onPointerEvent),this.context.input.removeEventListener(yn.PointerMove,this.onPointerEvent)}onBeforeRender(){this.resetMeshUIStates()}shouldRaycastObject_AddToYesCache(n){this._testObjectsCache.set(n,!0);for(const e of n.children)this.shouldRaycastObject_AddToYesCache(e)}performRaycast(n){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,n||(n=new Ac),n.testObject=this.shouldRaycastObject;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;this._currentlyActiveRaycaster=e;const i=e.performRaycast(n);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((e,i)=>e.distance-i.distance),this._sortedHits}assignHitInformation(n,e){e?(n.intersection=e,n.point=e.point,n.normal=e.normal,n.face=e.face,n.distance=e.distance,n.instanceId=e.instanceId):(n.intersection=void 0,n.point=void 0,n.normal=void 0,n.face=void 0,n.distance=void 0,n.instanceId=void 0)}handleIntersections(n,e){var i;if(n!=null&&n.length){n=this.sortCandidates(n);for(const r of n){if(e.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(e,r),this.handleEventOnObject(r.object,e))return!0}}this.assignHitInformation(e,n?.[0]),this.invokePointerCapture(e);const s=this.hoveredByID.get(e.pointerId);return s&&this.propagatePointerExit(s.obj,s.data,null),this.hoveredByID.delete(e.pointerId),e.isUp&&((i=this.pressedByID.get(e.pointerId))==null||i.handlers.forEach(r=>this.invokeOnPointerUp(e,r)),this.pressedByID.delete(e.pointerId)),!1}sortCandidates(n){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<n.length;e++){const i=n[e],s=i.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventOnObject(n,e){if(!this.testIsVisible(n))return e.isClick&&Zh&&console.log("not allowed",n),!1;if(e.pointerId===void 0)return Zh&&console.error("Event without pointer can't be handled",e),!1;e.object=n;const i=n.parent,s=e.isClick??!1;let r=null;if(i&&i.isUI){const c=(e.isPressed||e.isClick)??!1;if(i[Ya]){const h=i[Ya].gameObject;if(h){if(!oM.isInteractable(h,this.out))return!1;r=this.out.canvasGroup??null,this.handleMeshUIIntersection(n,c),n=h}}}s&&Zh&&console.log(this.context.time.frame,n);const o=this.hoveredByID.get(e.pointerId),a=o?.obj;a!==n&&a&&this.propagatePointerExit(a,o.data,n);const l=this.hoveredByID.get(e.pointerId);if(l?(l.obj=n,l.data=e):this.hoveredByID.set(e.pointerId,{obj:n,data:e}),e.isDown){const c=this.pressedByID.get(e.pointerId);c?(c.obj=n,c.data=e):this.pressedByID.set(e.pointerId,{obj:n,data:e,handlers:new Set})}return(r===null||r.interactable)&&this.handleMainInteraction(n,e,a??null),!0}propagate(n,e){for(;n;)ie.foreachComponent(n,i=>{e(i)},!1),n=n.parent}handleMainInteraction(n,e,i){const s=this.pressedByID.get(e.pointerId),r=i!==n;let o=!0;switch(e.event.pointerType){case"mouse":case"touch":const a=this.context.input.getPointerPositionLastFrame(e.pointerId),l=this.context.input.getPointerPosition(e.pointerId);o=a&&!et.approximately(a,l);break}this.propagate(n,a=>{var l;const c=a;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&r&&this.handlePointerEnter(c,e),e.isDown&&c.onPointerDown&&(c.onPointerDown(e),s?.handlers.add(c),this.handlePointerCapture(e,c)),c.onPointerMove&&(o&&c.onPointerMove(e),this.handlePointerCapture(e,c)),e.isUp&&(c.onPointerUp&&(this.invokeOnPointerUp(e,c),s?.handlers.delete(c)),c.onPointerExit&&((l=e.event)==null?void 0:l.pointerType)===TS.Touch&&(this.handlePointerExit(c,e),this.hoveredByID.delete(e.pointerId))),e.isClick&&c.onPointerClick&&c.onPointerClick(e)))}),e.isUp&&(s?.handlers.forEach(a=>{this.invokeOnPointerUp(e,a)}),this.pressedByID.delete(e.pointerId))}propagatePointerExit(n,e,i){this.propagate(n,s=>{if(!s.gameObject||s.destroyed)return;const r=s;if(r.onPointerExit||r.onPointerEnter){if(i&&this.isChild(i,s.gameObject))return;this.handlePointerExit(r,e)}})}invokeOnPointerUp(n,e){var i;(i=e.onPointerUp)==null||i.call(e,n),this.releasePointerCapture(n,e)}handlePointerEnter(n,e){n.onPointerEnter&&this.updatePointerState(n,e.pointerId,this.pointerEnterSymbol,!0)&&n.onPointerEnter(e),this.updatePointerState(n,e.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(n,e){n.onPointerExit&&this.updatePointerState(n,e.pointerId,this.pointerExitSymbol,!0)&&n.onPointerExit(e),this.updatePointerState(n,e.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(n,e,i,s){let r=n[i];if(s)return r&&r.includes(e)?!1:(r=r||[],r.push(e),n[i]=r,!0);{if(!r||!r.includes(e))return!1;const o=r.indexOf(e);return o!==-1&&r.splice(o,1),!0}}handlePointerCapture(n,e){if(n.z__pointer_ctured){n.z__pointer_ctured=!1;const i=n.pointerId;if(e.onPointerMove){const s=this._capturedPointer[i]||[];s.push(e),this._capturedPointer[i]=s}else je()&&!e.z__warned_no_pointermove&&(e.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else n.z__pointer_cture_rleased&&(n.z__pointer_cture_rleased=!1,this.releasePointerCapture(n,e))}releasePointerCapture(n,e){const i=n.pointerId;if(this._capturedPointer[i]){const s=this._capturedPointer[i].indexOf(e);s!==-1&&(this._capturedPointer[i].splice(s,1),Zh&&console.log("released pointer capture",i,e,this._capturedPointer))}}invokePointerCapture(n){var e;if(n.event.type===yn.PointerMove){const i=n.pointerId,s=this._capturedPointer[i];if(s){Zh&&console.log("Captured",i,s);for(let r=0;r<s.length;r++){const o=s[r];if(o.destroyed){s.splice(r,1),r--;continue}(e=o.onPointerMove)==null||e.call(o,n)}}}}isChild(n,e){return!n||!e?!1:n===e?!0:n.parent?this.isChild(n.parent,e):!1}handleMeshUiObjectWithoutShadowDom(n,e){return!n||!n.isUI?!0:this.handleMeshUIIntersection(n,e)}handleMeshUIIntersection(n,e){const i=Bu.updateState(n,e);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Bu.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let n=0;n<this.currentActiveMeshUIComponents.length;n++){const e=this.currentActiveMeshUIComponents[n];Bu.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(n){return n?ie.isActiveSelf(n)?this.testIsVisible(n.parent):!1:!0}};let Ka=Yh;p(Ka,"_eventSystemMap",new Map),p(Ka,"didSearchEventSystem",!1);class Bu{static markDirty(){this.needsUpdate=!0}static update(e,i,s=!1){if(s){e.update();return}const r=i.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===i){if(r===o.frame)return;o.frame=r;let a=this.needsUpdate||r<1;o.nextUpdate<=r&&(a=!0),a&&(Zh&&console.log("Update threemeshui"),this.needsUpdate=!1,o.nextUpdate=r+60,e.update());return}this.lastUpdateFrame=[{context:i,frame:r,nextUpdate:r+60}],e.update(),this.needsUpdate=!1}static updateState(e,i){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}p(Bu,"lastSelected",null),p(Bu,"lastUpdateFrame",[]),p(Bu,"needsUpdate",!1);var Y0e=Object.defineProperty,K0e=Object.getOwnPropertyDescriptor,An=(n,e,i,s)=>{for(var r=s>1?void 0:s?K0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Y0e(e,i,r),r};const pO=te("debugorbit"),mO=te("freecam"),lM=te("debugcamerafit"),cM=te("smoothcam"),J0e={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let fO;class LA extends CustomEvent{constructor(e,i){super("target-reached",{detail:{controls:e,type:i}})}}class Ti extends Pe{constructor(){super(...arguments),p(this,"autoTarget",!0),p(this,"autoFit",!1),p(this,"enableRotate",!0),p(this,"autoRotate",!1),p(this,"autoRotateSpeed",1),p(this,"minAzimuthAngle",1/0),p(this,"maxAzimuthAngle",1/0),p(this,"minPolarAngle",0),p(this,"maxPolarAngle",Math.PI),p(this,"enableKeys",!1),p(this,"enableDamping",!0),p(this,"dampingFactor",.1),p(this,"enableZoom",!0),p(this,"minZoom",0),p(this,"maxZoom",1/0),p(this,"zoomSpeed",1),p(this,"zoomToCursor",!1),p(this,"enablePan",!0),p(this,"lookAtConstraint",null),p(this,"lookAtConstraint01",1),p(this,"allowInterrupt",!0),p(this,"middleClickToFocus",!0),p(this,"doubleClickToFocus",!0),p(this,"clickBackgroundToFitScene",2),p(this,"debugLog",!1),p(this,"targetLerpDuration",1),p(this,"_controls",null),p(this,"_cameraObject",null),p(this,"_lookTargetLerpActive",!1),p(this,"_lookTargetStartPosition",new M),p(this,"_lookTargetEndPosition",new M),p(this,"_lookTargetLerp01",0),p(this,"_lookTargetLerpDuration",0),p(this,"_cameraLerpActive",!1),p(this,"_cameraStartPosition",new M),p(this,"_cameraEndPosition",new M),p(this,"_cameraLerp01",0),p(this,"_cameraLerpDuration",0),p(this,"_fovLerpActive",!1),p(this,"_fovLerpStartValue",0),p(this,"_fovLerpEndValue",0),p(this,"_fovLerp01",0),p(this,"_fovLerpDuration",0),p(this,"_inputs",0),p(this,"_enableTime",0),p(this,"_startedListeningToKeyEvents",!1),p(this,"_eventSystem"),p(this,"_afterHandleInputFn"),p(this,"_camera",null),p(this,"_syncedTransform"),p(this,"_didSetTarget",0),p(this,"targetElement",null),p(this,"_activePointerEvents"),p(this,"_lastTimeClickOnBackground",-1),p(this,"_clickOnBackgroundCount",0),p(this,"_onPointerDown",e=>{this._activePointerEvents.push(e)}),p(this,"_onPointerUp",e=>{for(let i=this._activePointerEvents.length-1;i>=0;i--){const s=this._activePointerEvents[i];if(s.pointerId===e.pointerId&&s.button===e.button){this._activePointerEvents.splice(i,1);break}}if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const i=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||i<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}pO&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}}),p(this,"_onPointerUpLate",e=>{this.doubleClickToFocus&&e.isDoubleClick&&!e.used&&this.setTargetFromRaycast()}),p(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),p(this,"_shouldDisable",!1),p(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera({centerCamera:"y",immediate:!0,objects:this.scene.children}))}),p(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var i;(i=this.controls)==null||i.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Ka.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(uO.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,i;(e=this._controls)==null||e.dispose(),(i=this._eventSystem)==null||i.removeEventListener(uO.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=ie.getComponent(this.gameObject,Fi);this._camera=e;let i=e?.threeCamera;if(!i&&this.gameObject instanceof Lt&&(i=this.gameObject),i&&nL(i,this,!0),!this._controls&&i instanceof Lt){this._cameraObject=i;const s=this.targetElement??this.context.renderer.domElement,r=i?.quaternion.clone();this._controls=new rQ(i,s),i?.quaternion.copy(r),fO===void 0&&(fO={...this._controls.keys})}if(this._controls)if(mO&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,At.isMobileDevice()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),!this._startedListeningToKeyEvents&&this.enableKeys)this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(this.context.domElement);else try{this._controls.stopListenToKeyEvents()}catch{}this._syncedTransform=ie.getComponent(this.gameObject,Ec)??void 0,this.context.pre_render_callbacks.push(this.__onPreRender),this._activePointerEvents=[],this.context.input.addEventListener("pointerdown",this._onPointerDown,{queue:na.Early}),this.context.input.addEventListener("pointerup",this._onPointerUp,{queue:na.Early}),this.context.input.addEventListener("pointerup",this._onPointerUpLate,{queue:na.Late})}onDisable(){var e;if((e=this._camera)!=null&&e.threeCamera&&nL(this._camera.threeCamera,this,!1),this._controls){this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted);try{this._controls.stopListenToKeyEvents()}catch{}this._startedListeningToKeyEvents=!1}this._activePointerEvents.length=0,this.context.input.removeEventListener("pointerdown",this._onPointerDown),this.context.input.removeEventListener("pointerup",this._onPointerUp),this.context.input.removeEventListener("pointerup",this._onPointerUpLate)}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var e,i,s,r;if(!!this._controls){if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.length()||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0,this.autoTarget&&this._didSetTarget++===0){const o=ie.getComponent(this.gameObject,Fi);if(o&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const a=Nt(o.threeCamera),l=Math.max(.01,a.length()),c=new M(0,0,-l).applyMatrix4(o.threeCamera.matrixWorld);this.setLookTargetPosition(c,!0)}if(!this.setLookTargetFromConstraint()){const a=new Ac;a.screenPoint=new K(0,0),a.lineThreshold=.1;const l=this.context.physics.raycast(a);l.length>0&&this.setLookTargetPosition(l[0].point,!0),lM&&console.log("OrbitControls hits",...l)}}if(this.middleClickToFocus&&this.context.input.getPointerClicked(1)&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive||this._fovLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new LA(this,"camera"));else{const o=et.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,o)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new LA(this,"lookat"));else{const o=et.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,o)}if(this._fovLerpActive&&this._cameraObject){const o=this._cameraObject;if(this._fovLerp01+=this.context.time.deltaTime/this._fovLerpDuration,this._fovLerp01>=1)o.fov=this._fovLerpEndValue,this._fovLerpActive=!1;else{const a=et.easeInOutCubic(this._fovLerp01);o.fov=et.lerp(this._fovLerpStartValue,this._fovLerpEndValue,a)}o.updateProjectionMatrix()}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR&&!this._activePointerEvents.some(o=>o.used),this._controls.keys=this.enableKeys?fO:J0e,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.zoomSpeed=this.zoomSpeed,this._controls.zoomToCursor=this.zoomToCursor,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,mO||(((s=(i=this._camera)==null?void 0:i.threeCamera)==null?void 0:s.type)==="PerspectiveCamera"?(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom,this._controls.minZoom=0,this._controls.maxZoom=1/0):(this._controls.minDistance=0,this._controls.maxDistance=1/0,this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom)),typeof cM=="number"||cM===!0){this._controls.enableDamping=!0;const o=typeof cM=="number"?cM:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,o))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!mO&&(r=this.lookAtConstraint)!=null&&r.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(this.context.time.deltaTime),pO&&ft.DrawWireSphere(this._controls.target,.1,65280))}}}setCameraAndLookTarget(e){if(!e||!(e instanceof ge))return;const i=Nt(e),s=hL(e);this.setTargetFromRaycast(new qr(i,s)),this.setCameraTargetPosition(i)}setCameraTargetPosition(e,i=!1){var s;e&&(e instanceof ge&&(e=Nt(e)),this._cameraEndPosition||(this._cameraEndPosition=new M),this._cameraEndPosition.copy(e),i===!0?(this._cameraLerpActive=!1,this._cameraObject&&this._cameraObject.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((s=this._cameraObject)==null?void 0:s.position),typeof i=="number"?this._cameraLerpDuration=i:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setFieldOfView(e,i=!1){var s;if(!this._controls||typeof e!="number")return;const r=(s=this._camera)==null?void 0:s.threeCamera;r&&(i===!0?r.fov=e:(this._fovLerpActive=!0,this._fovLerp01=0,this._fovLerpStartValue=r.fov,this._fovLerpEndValue=e,typeof i=="number"?this._fovLerpDuration=i:this._fovLerpDuration=this.targetLerpDuration))}setLookTargetPosition(e=null,i=!1){this._controls&&e&&(e instanceof ge&&(e=Nt(e)),this._lookTargetEndPosition.copy(e),this._didSetTarget++,pO&&(console.warn("OrbitControls: setLookTargetPosition",e,i),ft.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),i===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof i=="number"?this._lookTargetLerpDuration=i:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,i=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const o=r[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,i),!0}return!1}lerpTarget(e,i){return this.lerpLookTarget(e,i)}lerpLookTarget(e,i){this._controls&&(i>=1?this._controls.target.copy(e):this._controls.target.lerp(e,i))}setTargetFromRaycast(e){if(!this.controls)return;const i=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const s of i)if(s.distance>0&&ie.isActiveInHierarchy(s.object)){const r=dO(s.object);if(r){const o=r.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(s.point);break}}fitCamera(e,i){var s,r;if(this.context.isInXR)return;let o;if(Array.isArray(e)?o=e:e&&"type"in e?o=e.children:e&&"objects"in e&&(o=e?.objects,i=e),o&&!Array.isArray(o)&&(o=o.children),(!Array.isArray(o)||o&&o.length<=0)&&(o=this.context.scene.children),!Array.isArray(o)||o.length<=0){console.warn("No objects to fit camera to...");return}const a=this._cameraObject,l=this._controls;if(!a||!l){console.warn("No camera or controls found to fit camera to objects...");return}i||(i={});const{immediate:c=!1,centerCamera:h="y",cameraNearFar:d="auto",fitOffset:u=1.1,fov:m=a?.fov}=i,f=new M,g=new M,v=Jo(o,void 0,(r=(s=this._camera)==null?void 0:s.threeCamera)==null?void 0:r.layers),y=v.clone();a.updateMatrixWorld(),a.updateProjectionMatrix(),v.getCenter(g);const b=new M;if(v.getSize(b),v.applyMatrix4(a.matrixWorldInverse),v.getSize(f),v.setFromCenterAndSize(g,f),Number.isNaN(f.x)||Number.isNaN(f.y)||Number.isNaN(f.z)){console.warn("Camera fit size resultet in NaN",a,v,[...o]);return}if(f.length()<=1e-10){lM&&console.warn("Camera fit size is zero",v,[...o]);return}const A=i.fov||a.fov,x=2*Math.atan(Math.tan(A*Math.PI/360/2)*a.aspect)/Math.PI*360,w=f.y/(2*Math.atan(Math.PI*A/360)),_=f.x/(2*Math.atan(Math.PI*x/360)),S=u*Math.max(w,_)+f.z/2;lM&&console.log("Fit camera to objects",{fitHeightDistance:w,fitWidthDistance:_,distance:S,verticalFov:A,horizontalFov:x}),this.maxZoom=S*10,this.minZoom=S*.01;const C=.05,R=g.clone();if(R.y-=f.y*C,this.setLookTargetPosition(R,c),this.setFieldOfView(i.fov,c),this.autoTarget=!1,d==null||d=="auto"){const G=ie.findObjectOfType(Cc),O=G?G.radius:0,W=Math.max(b.x,b.y,b.z,O);a.near=S/100,a.far=W+S*10,G&&(this.maxZoom=Math.max(Math.min(this.maxZoom,O*.5),S))}const P=l.getDistance();P<this.minZoom&&(this.minZoom=P*.9),P>this.maxZoom&&(this.maxZoom=P*1.1),a.updateMatrixWorld(),a.updateProjectionMatrix();const T=Nt(a),L=g.clone();L.sub(T),h==="y"&&(L.y=0),L.normalize(),L.multiplyScalar(S),h==="y"&&(L.y+=-C*4*S);let k=g.clone().sub(L);if(a.parent&&(k=a.parent.worldToLocal(k)),this.setCameraTargetPosition(k,c),lM){const G=new dI(v);this.context.scene.add(G),pL(G,Yv(a)),setTimeout(()=>{this.context.scene.remove(G)},1e4),ft.DrawWireBox3(y,65280,10),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",O=>{if(O.code==="KeyF"){let W;this._cameraObject instanceof Lt&&(W=Math.random()*Math.random()*170+10),this.fitCamera({objects:o,fitOffset:u,immediate:!1,fov:W})}O.code==="KeyV"&&this._cameraObject instanceof Lt&&(this._cameraObject.fov=60)}))}l.update()}}An([E()],Ti.prototype,"autoTarget",2),An([E()],Ti.prototype,"autoFit",2),An([E()],Ti.prototype,"enableRotate",2),An([E()],Ti.prototype,"autoRotate",2),An([E()],Ti.prototype,"autoRotateSpeed",2),An([E()],Ti.prototype,"minAzimuthAngle",2),An([E()],Ti.prototype,"maxAzimuthAngle",2),An([E()],Ti.prototype,"minPolarAngle",2),An([E()],Ti.prototype,"maxPolarAngle",2),An([E()],Ti.prototype,"enableKeys",2),An([E()],Ti.prototype,"enableDamping",2),An([E()],Ti.prototype,"dampingFactor",2),An([E()],Ti.prototype,"enableZoom",2),An([E()],Ti.prototype,"minZoom",2),An([E()],Ti.prototype,"maxZoom",2),An([E()],Ti.prototype,"zoomSpeed",2),An([E()],Ti.prototype,"enablePan",2),An([E(zm)],Ti.prototype,"lookAtConstraint",2),An([E()],Ti.prototype,"lookAtConstraint01",2),An([E()],Ti.prototype,"allowInterrupt",2),An([E()],Ti.prototype,"middleClickToFocus",2),An([E()],Ti.prototype,"doubleClickToFocus",2),An([E()],Ti.prototype,"clickBackgroundToFitScene",2),An([E()],Ti.prototype,"targetLerpDuration",2);var q0e=Object.defineProperty,$0e=Object.getOwnPropertyDescriptor,fo=(n,e,i,s)=>{for(var r=s>1?void 0:s?$0e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&q0e(e,i,r),r},Ou=(n=>(n[n.None=0]="None",n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Ou||{});const Du=te("debugcam"),mQ=te("debugscreenpointtoray");var hM;const PA=(hM=class extends Pe{constructor(){super(...arguments),p(this,"_nearClipPlane",.1),p(this,"_farClipPlane",1e3),p(this,"orthographic",!1),p(this,"orthographicSize",5),p(this,"ARBackgroundAlpha",0),p(this,"_cullingMask",4294967295),p(this,"_backgroundBlurriness"),p(this,"_backgroundIntensity"),p(this,"_backgroundRotation"),p(this,"_environmentIntensity"),p(this,"_targetTexture",null),p(this,"_backgroundColor"),p(this,"_fov"),p(this,"_cam",null),p(this,"_clearFlags",2),p(this,"_skybox"),p(this,"_frustum"),p(this,"_projScreenMatrix",new he)}get isCamera(){return!0}get aspect(){return this._cam instanceof Lt?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(n){this._cam instanceof Lt&&this._cam.aspect!==n&&(this._cam.aspect=n,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof Lt?this._cam.fov:this._fov}set fieldOfView(n){const e=this.fieldOfView!=n;if(this._fov=n,e&&this._cam&&this._cam instanceof Lt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(n){const e=this._nearClipPlane!=n;this._nearClipPlane=n,this._cam&&(e||this._cam.near!=n)&&(this._cam.near=n,this._cam.updateProjectionMatrix())}applyClippingPlane(){this._cam&&(this._cam.near=this._nearClipPlane,this._cam.far=this._farClipPlane,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(n){const e=this._farClipPlane!=n;this._farClipPlane=n,this._cam&&(e||this._cam.far!=n)&&(this._cam.far=n,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(n){n!==this._clearFlags&&(this._clearFlags=n,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(n){this._cullingMask=n,this._cam&&(this._cam.layers.mask=n)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(n){this.cullingMask=(1<<n|0)>>>0}set backgroundBlurriness(n){n!==this._backgroundBlurriness&&(n===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(n,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(n){n!==this._backgroundIntensity&&(n===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(n,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(n){n!==this._backgroundRotation&&(n===void 0?this._backgroundRotation=void 0:this._backgroundRotation=n,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(n){this._environmentIntensity=n}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(n){if(n){if(this._backgroundColor)this._backgroundColor.copy(n);else{if(!n.clone)return;this._backgroundColor=n.clone()}n.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(n){this._targetTexture=n}get targetTexture(){return this._targetTexture}get cam(){return this.threeCamera}get threeCamera(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(n,e,i){const s=this.threeCamera,r=PA._origin;r.set(n,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),mQ&&console.log("screenPointToRay",n.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=PA._direction.set(r.x,r.y,r.z),a=Nt(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new qr(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new Gp,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Gp),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(n,e){return e&&this._projScreenMatrix.multiplyMatrices(this.threeCamera.projectionMatrix,this.threeCamera.matrixWorldInverse),n===this._projScreenMatrix?n:n.copy(this._projScreenMatrix)}awake(){mQ&&window.addEventListener("pointerdown",n=>{const e=n.clientX,i=n.clientY;console.log("touch",e.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(e,i),r="#"+Math.floor(Math.random()*16777215).toString(16);ft.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Du&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ou[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),tye(this)),this.applyClearFlagsIfIsActiveCamera({applySkybox:!0})}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),this._targetTexture)){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const n=this.context.renderer;if(n){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,n),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const n=this.gameObject.isCamera;let e=null;if(n?(e=this.gameObject,e?.layers.enableAll(),e instanceof Lt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof Lt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new Lt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const i=this.orthographicSize*100;e=new oc(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(n){this.context.mainCameraComponent===this&&this.applyClearFlags(n)}applyClearFlags(n){var e;if(!this._cam){Du&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Du){const i=`Camera "${this.name}" clear flags: ${Ou[this._clearFlags]}`;console.debug(i)}switch(this._clearFlags){case 0:return;case 1:if(PA.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}(!this.scene.background||!this._skybox||n?.applySkybox===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:Du&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:Du&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;PA.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,(e=this.context.xr)!=null&&e.isVR?this.context.renderer.setClearColor(T5(this._backgroundColor).convertLinearToSRGB()):this.context.renderer.setClearColor(this._backgroundColor,i)}else Du&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}applySceneSkybox(){this._skybox||(this._skybox=new eye(this)),this._skybox.apply()}static backgroundShouldBeTransparent(n){var e,i,s,r;const o=(e=n.renderer.xr)==null?void 0:e.getSession();if(!o)return!1;if(typeof o._transparent=="boolean")return o._transparent;const a=o.environmentBlendMode;Du&&gn("Environment blend mode: "+a+" on "+navigator.userAgent);let l=a==="additive"||a==="alpha-blend";return n.isInAR&&a==="opaque"&&((i=navigator.userAgent)!=null&&i.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(l=!0),o._transparent=l,l}},p(hM,"_origin",new M),p(hM,"_direction",new M),hM);let Fi=PA;fo([E()],Fi.prototype,"aspect",1),fo([E()],Fi.prototype,"fieldOfView",1),fo([E()],Fi.prototype,"nearClipPlane",1),fo([E()],Fi.prototype,"farClipPlane",1),fo([E()],Fi.prototype,"clearFlags",1),fo([E()],Fi.prototype,"orthographic",2),fo([E()],Fi.prototype,"orthographicSize",2),fo([E()],Fi.prototype,"ARBackgroundAlpha",2),fo([E()],Fi.prototype,"cullingMask",1),fo([E()],Fi.prototype,"backgroundBlurriness",1),fo([E()],Fi.prototype,"backgroundIntensity",1),fo([E(si)],Fi.prototype,"backgroundRotation",1),fo([E()],Fi.prototype,"environmentIntensity",1),fo([E(Li)],Fi.prototype,"backgroundColor",1),fo([E(I0)],Fi.prototype,"targetTexture",1);class eye{constructor(e){p(this,"_camera"),p(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Du&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Kr,this.context.scene.background=this._skybox):this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" has no skybox texture. ${this._camera.sourceId}`))}}function tye(n){te("freecam")&&n.context.mainCameraComponent===n&&ie.getOrAddComponent(n.gameObject,Ti)}class Gu extends Pe{constructor(){super(...arguments),p(this,"_listener",null),p(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new Fz),this._listener}onEnable(){Xh.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Xh.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const i=this.context.mainCameraComponent||ie.getComponentInParent(this.gameObject,Fi);i!=null&&i.threeCamera?i.threeCamera.add(e):this.gameObject.add(e),e.filter?(e.gain.connect(e.filter),e.filter.connect(e.context.destination)):e.gain.connect(e.context.destination)}removeListenerIfItExists(){const e=this._listener;e&&(e.removeFromParent(),e.filter&&e.filter.disconnect(),e.gain&&e.gain.disconnect())}}var iye=Object.defineProperty,nye=Object.getOwnPropertyDescriptor,Vl=(n,e,i,s)=>{for(var r=s>1?void 0:s?nye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&iye(e,i,r),r};const Ur=te("debugaudio"),Nu=class extends Pe{constructor(){super(...arguments),p(this,"clip",""),p(this,"playOnAwake",!1),p(this,"preload",!1),p(this,"playInBackground",!0),p(this,"_spatialBlend",0),p(this,"_minDistance",1),p(this,"_maxDistance",100),p(this,"_volume",1),p(this,"rollOffMode",0),p(this,"_loop",!1),p(this,"sound",null),p(this,"helper",null),p(this,"wasPlaying",!1),p(this,"audioLoader",null),p(this,"shouldPlay",!1),p(this,"_lastClipStartedLoading",null),p(this,"_audioElement",null),p(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||At.isMobileDevice())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Ur&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,Nu.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&Nu.userInteractionRegistered&&this.wasPlaying&&this.play();break}}),p(this,"onApplicationMuteChanged",()=>{var n,e;this.context.application.muted?(n=this.sound)==null||n.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)}),p(this,"createAudio",n=>{Ur&&console.log("AudioBuffer finished loading",n);const e=this.Sound;if(!e){Ur&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),n&&e.setBuffer(n),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&Nu.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),Nu.registerWaitForAllowAudio(this.__onAllowAudioCallback)}),p(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()}),p(this,"_lastContextTime",0),p(this,"_hasEnded",!0),p(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Xh.userInteractionRegistered}static registerWaitForAllowAudio(n){Xh.registerWaitForInteraction(n)}get isPlaying(){var n;return((n=this.sound)==null?void 0:n.isPlaying)??!1}get duration(){var n,e;return(e=(n=this.sound)==null?void 0:n.buffer)==null?void 0:e.duration}get time01(){var n;const e=this.duration;return e&&this.sound?((n=this.sound)==null?void 0:n.context.currentTime)/e:0}set time01(n){const e=this.duration;e&&this.sound&&(this.time=n*e)}get time(){var n,e;return(n=this.sound)!=null&&n.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(n){if(this.sound){if(n===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=n,e&&this.play()}}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(n){this._loop=n,this.sound&&this.sound.setLoop(n)}get spatialBlend(){return this._spatialBlend}set spatialBlend(n){n!==this._spatialBlend&&(this._spatialBlend=n,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(n){this._minDistance!==n&&(this._minDistance=n,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(n){this._maxDistance!==n&&(this._maxDistance=n,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(n){this._volume=n,this.sound&&!this.context.application.muted&&(Ur&&console.log(this.name,"audio set volume",n),this.sound.setVolume(n))}set pitch(n){this.sound&&this.sound.setPlaybackRate(n)}get pitch(){return this.sound?this.sound.getPlaybackRate():1}get Sound(){var n;if(!this.sound&&Nu.userInteractionRegistered){let e=ie.getComponent(this.context.mainCamera,Gu)??ie.findObjectOfType(Gu,this.context);!e&&this.context.mainCamera&&(e=ie.addComponent(this.context.mainCamera,Gu)),e!=null&&e.listener?(this.sound=new Uz(e.listener),(n=this.gameObject)==null||n.add(this.sound)):Ur&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var n;return(n=this.sound)==null?void 0:n.context}awake(){Ur&&console.log(this),this.audioLoader=new i_,this.playOnAwake&&(this.shouldPlay=!0),this.preload&&typeof this.clip=="string"&&this.audioLoader.load(this.clip,this.createAudio,()=>{},console.error)}onEnable(){this.sound&&this.gameObject.add(this.sound),Nu.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():Nu.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(xC.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(xC.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const n=this.sound;if(!n)return;this._needUpdateSpatialDistanceSettings=!1;const e=et.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Ur&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),n.setRefDistance(e),n.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:n.setDistanceModel("exponential");break;case 1:n.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?Ur&&!this.helper&&(this.helper=new m0e(n,n.getRefDistance()),n.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(n){if(n&&(this.clip=n),typeof n=="string")if(Ur&&console.log(n),n.endsWith(".mp3")||n.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new i_),this.shouldPlay=!0,this._lastClipStartedLoading===n){Ur&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=n,Ur&&console.log("load audio",n);const e=await this.audioLoader.loadAsync(n).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",n);else this.shouldPlay=!0,this.createAudio()}play(n=void 0){var e,i,s;!n&&this.clip&&(n=this.clip),n!==void 0&&typeof n!="string"&&!(n instanceof MediaStream)&&(je()&&console.warn("Called play on AudioSource with unknown argument type:",n+`
|
|
5957
|
+
Using the assigned clip instead:`,this.clip),n=this.clip);let r=!this.sound||n&&n!==this.clip;if(typeof n=="string"&&!this.audioLoader&&(r=!0),(n instanceof MediaStream||typeof n=="string")&&(this.clip=n),r){this.shouldPlay=!0,this.onNewClip(n);return}if(this.shouldPlay=!0,this._hasEnded=!1,Ur&&console.log("play",(e=this.sound)==null?void 0:e.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(i=this.gameObject)==null||i.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(s=this.context.domElement.shadowRoot)==null||s.append(this._audioElement),this._audioElement.srcObject=this.clip,this._audioElement.autoplay=!1):(this._audioElement&&this._audioElement.remove(),this.sound.play(o?.1:0))}}pause(){var n,e;Ur&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(n=this.sound)==null?void 0:n.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var n,e;Ur&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(n=this.sound)==null?void 0:n.context.currentTime,Ur&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}update(){this.helper&&(this.isPlaying&&this.helper.update(),this.helper.visible=this.isPlaying),this._needUpdateSpatialDistanceSettings&&this.applySpatialDistanceSettings(),this.sound&&!this.sound.isPlaying&&this.shouldPlay&&!this._hasEnded&&(this._hasEnded=!0,Ur&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Cn=Nu;Vl([E(URL)],Cn.prototype,"clip",2),Vl([E()],Cn.prototype,"playOnAwake",2),Vl([E()],Cn.prototype,"preload",2),Vl([E()],Cn.prototype,"playInBackground",2),Vl([E()],Cn.prototype,"loop",1),Vl([E()],Cn.prototype,"spatialBlend",1),Vl([E()],Cn.prototype,"minDistance",1),Vl([E()],Cn.prototype,"maxDistance",1),Vl([E()],Cn.prototype,"volume",1),Vl([E()],Cn.prototype,"pitch",1),Vl([E()],Cn.prototype,"rollOffMode",2);var sye=Object.defineProperty,rye=Object.getOwnPropertyDescriptor,dM=(n,e,i,s)=>{for(var r=s>1?void 0:s?rye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&sye(e,i,r),r};const oye=te("debugsignals");class kA{constructor(){p(this,"guid")}}dM([E()],kA.prototype,"guid",2);class B0{constructor(){p(this,"signal"),p(this,"reaction")}}dM([E(kA)],B0.prototype,"signal",2),dM([E(ji)],B0.prototype,"reaction",2);var gO;const Kh=(gO=class extends Pe{constructor(){super(...arguments),p(this,"events")}static invoke(n){if(Kh.receivers[n]){const e=Kh.receivers[n];if(!e)return;for(const i of e)i.invoke(n)}}awake(){oye&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const n of this.events)Kh.receivers[n.signal.guid]||(Kh.receivers[n.signal.guid]=[]),Kh.receivers[n.signal.guid].push(this)}onDisable(){if(this.events){for(const n of this.events)if(Kh.receivers[n.signal.guid]){const e=Kh.receivers[n.signal.guid].indexOf(this);e>=0&&Kh.receivers[n.signal.guid].splice(e,1)}}}invoke(n){if(!this.events||!Array.isArray(this.events))return;const e=typeof n=="object"?n.guid:n;for(const i of this.events)if(i.signal.guid===e)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},p(gO,"receivers",{}),gO);let O0=Kh;dM([E(B0)],O0.prototype,"events",2);var ha=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(ha||{}),Rc=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Rc||{}),yO=(n=>(n.Signal="SignalEmitter",n))(yO||{}),aye=Object.defineProperty,lye=Object.getOwnPropertyDescriptor,fQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?lye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&aye(e,i,r),r};const Jh=te("debugtimeline");var vO;const bO=(vO=class extends Pe{constructor(){super(...arguments),p(this,"playableAsset"),p(this,"playOnAwake"),p(this,"extrapolationMode",1),p(this,"waitForAudio",!0),p(this,"_visibilityChangeEvt"),p(this,"_clonedPlayableAsset",!1),p(this,"_speed",1),p(this,"_guidsMap"),p(this,"_isPlaying",!1),p(this,"_internalUpdateRoutine"),p(this,"_isPaused",!1),p(this,"_isStopping",!1),p(this,"_time",0),p(this,"_duration",0),p(this,"_weight",1),p(this,"_animationTracks",[]),p(this,"_audioTracks",[]),p(this,"_signalTracks",[]),p(this,"_controlTracks",[]),p(this,"_customTracks",[]),p(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),p(this,"animationCallbackReceivers",[])}static registerCreateTrack(n,e){this.createTrackFunctions[n]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(n){typeof n=="number"&&!Number.isNaN(n)?this._time=n:(Jh||io())&&console.error("INVALID TIMELINE.TIME VALUE",n,this.name)}get duration(){return this._duration}set duration(n){this._duration=n}get weight(){return this._weight}set weight(n){this._weight=n}get speed(){return this._speed}set speed(n){this._speed=n}awake(){var n,e,i,s,r;Jh&&console.log(this,(n=this.playableAsset)==null?void 0:n.tracks),this.rebuildGraph(),!this.isValid()&&(Jh||je())&&(Jh?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",(e=this.playableAsset)==null?void 0:e.tracks,"IsArray?",Array.isArray((i=this.playableAsset)==null?void 0:i.tracks),this):(r=(s=this.playableAsset)==null?void 0:s.tracks)!=null&&r.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){var n,e,i;for(const s of this._audioTracks)(n=s.onEnable)==null||n.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(i=s.onEnable)==null||i.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var n,e,i;this.stop();for(const s of this._audioTracks)(n=s.onDisable)==null||n.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(i=s.onDisable)==null||i.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var n;for(const e of this._allTracks)for(const i of e)(n=i.onDestroy)==null||n.call(i)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const n=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,n&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const i of this._audioTracks){const s=i.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Cn.userInteractionRegistered&&this.waitForAudio;)await bl(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ji.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const n=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),n&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,n&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const n of this._allTracks)for(const e of n)yield e}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}resolveGuids(n){this._guidsMap=n}invokePauseChangedMethodsOnTracks(){var n;for(const e of this.forEachTrack())(n=e.onPauseChanged)==null||n.call(e)}invokeStateChangedMethodsOnTracks(){var n;for(const e of this.forEachTrack())(n=e.onStateChanged)==null||n.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(n=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const i=this._time;for(const s of this.playableAsset.tracks)if(!s.muted)switch(s.type){case ha.Activation:if(!n&&!this._isPlaying)continue;for(let r=0;r<s.outputs.length;r++){const o=s.outputs[r];if(typeof o=="object"){let a=!1;if(s.clips)for(const c of s.clips)c.start<=i&&i<=c.end&&(a=!0);const l=o;l.visible!==void 0&&l.visible!==a&&(l.visible=a,Jh&&console.warn(this.name,"set ActivationTrack-"+r,l.name,a,i))}}break}if(!this._isStopping)for(const s of this._animationTracks)s.evaluate(i);for(const s of this._audioTracks)s.evaluate(i);for(const s of this._signalTracks)s.evaluate(i);for(const s of this._controlTracks)s.evaluate(i);for(const s of this._customTracks)s.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Vv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const n=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let i=e.outputs.length-1;i>=0;i--){let s=e.outputs[i];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=ie.findByGuid(s,n);r===null||typeof r!="object"?(e.outputs.splice(i,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Jh&&console.log("Resolved binding",s,"to",r),e.outputs[i]=r)}else if(s===null){if(e.outputs.splice(i,1),bO.createTrackFunctions[e.type])continue;e.type!==ha.Audio&&e.type!==ha.Control&&e.type!==ha.Marker&&e.type!==ha.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===ha.Control&&e.clips)for(let i=0;i<e.clips.length;i++){const s=e.clips[i];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=ie.findByGuid(r,n);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Jh&&console.log("Resolved binding",r,"to",o),s.asset.sourceObject=o)}}}}findRoot(n){return n.parent?this.findRoot(n.parent):n}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const n of this.playableAsset.tracks)if(n.muted!==!0){if(n.clips)for(const e of n.clips)e.end>this._duration&&(this._duration=e.end);if(n.markers)for(const e of n.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var n,e,i;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let s=ie.findObjectOfType(Gu,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=bO.createTrackFunctions[o];if(a!=null){const l=a(this,r);if(typeof l.evaluate=="function"){l.director=this,l.track=r,this._customTracks.push(l);continue}}if(r.type===ha.Animation){if(!r.clips||r.clips.length<=0){Jh&&console.warn("Animation track has no clips",r);continue}for(let l=r.outputs.length-1;l>=0;l--){let c=r.outputs[l];if(c instanceof ge){const d=ie.getOrAddComponent(c,sr);d&&(c=d)}const h=(n=c?.gameObject)==null?void 0:n.animations;if(h){const d=new uM;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let u=0;u<r.clips.length;u++){const m=r.clips[u],f=m.asset;if(!f){console.error(`Timeline ${this.name}: clip #${u} on track "${r.name}" has no animation data`);continue}const g=f.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=h.find(b=>b.name===g)),Jh&&console.log(f,g,"\u2192",v),!v){console.warn("Could not find animationClip for model",m,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name,h,c);continue}c instanceof sr&&c.runtimeAnimatorController&&(c.__internalDidAwakeAndStart||c.initializeRuntimeAnimatorController(),c.runtimeAnimatorController.mixer||c.runtimeAnimatorController.bind(c),d.mixer=c.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new n_(c.gameObject),this.context.animations.registerAnimationMixer(d.mixer)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(m.asset,v);const y=d.mixer.clipAction(v);d.actions.push(y),d.models.push(m)}this._animationTracks.push(d)}}}else if(r.type===ha.Audio){if(!r.clips||r.clips.length<=0)continue;const l=new DA;l.director=this,l.track=r,l.audioSource=r.outputs.find(c=>c instanceof Cn),this._audioTracks.push(l),s||(s=(i=this.context.mainCameraComponent)==null?void 0:i.gameObject.addComponent(Gu)),l.listener=s.listener;for(let c=0;c<r.clips.length;c++){const h=r.clips[c];l.addModel(h)}}else if(r.type===ha.Marker){const l=new GA;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)switch(c.type){case yO.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=ie.getComponent(this.gameObject,O0);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(r.type===ha.Signal){const l=new GA;if(l.director=this,l.track=r,r.markers)for(const c of r.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of r.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(r.type===ha.Control){const l=new pM;if(l.director=this,l.track=r,r.clips)for(const c of r.clips)l.models.push(c);l.resolveSourceObjects(this.context),this._controlTracks.push(l)}}}setAudioTracksAllowPlaying(n){for(const e of this._audioTracks)e.onAllowAudioChanged(n)}registerAnimationCallback(n){this.animationCallbackReceivers.push(n)}unregisterAnimationCallback(n){const e=this.animationCallbackReceivers.indexOf(n);e!==-1&&this.animationCallbackReceivers.splice(e,1)}},p(vO,"createTrackFunctions",{}),vO);let Fu=bO;fQ([E()],Fu.prototype,"playOnAwake",2),fQ([E()],Fu.prototype,"extrapolationMode",2);const Ic=te("debugtimeline");class BA{constructor(){p(this,"director"),p(this,"track")}get muted(){return this.track.muted}set muted(e){var i;e!==this.track.muted&&(this.track.muted=e,(i=this.onMuteChanged)==null||i.call(this))}*forEachClip(e=!1){var i;if((i=this.track)!=null&&i.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,i){return i.clipIn+(e-i.start)*i.timeScale}getClipTimeNormalized(e,i){return(e-i.start)/i.duration}evaluateWeight(e,i,s,r=!0){if(i<0||i>=s.length)return 0;const o=s[i];if(r||e>=o.start&&e<=o.end){let a=1;const l=!1;if(o.easeInDuration>0){const c=Math.min((e-o.start)/o.easeInDuration,1);a*=c}if(o.easeOutDuration>0&&!l){const c=Math.min((o.end-e)/o.easeOutDuration,1);a*=c}return a}return 0}}class cye{constructor(e){p(this,"clip"),p(this,"rootPositionOffset"),p(this,"rootQuaternionOffset"),p(this,"rootStartPosition"),p(this,"rootEndPosition"),p(this,"rootStartQuaternion"),p(this,"rootEndQuaternion");const i=e.getClip();this.clip=i;const s=e.getRoot(),r=s.name+".position",o=s.name+".quaternion";Ic&&console.log(i.name,i.tracks,r);for(const a of i.tracks)if(!(a.times.length<=0)){if(a.name.endsWith(r))this.rootStartPosition=new M().fromArray(a.values,0),this.rootEndPosition=new M().fromArray(a.values,a.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Ic&&console.log(this.rootPositionOffset);else if(a.name.endsWith(o)&&(this.rootStartQuaternion=new Se().fromArray(a.values,0),this.rootEndQuaternion=new Se().fromArray(a.values,a.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Ic)){const l=new si().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",l)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class uM extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"trackOffset"),p(this,"target"),p(this,"mixer"),p(this,"clips",[]),p(this,"actions",[]),p(this,"weight",1),p(this,"_actionOffsets",[]),p(this,"_didBind",!1),p(this,"_animator",null),p(this,"_useclipOffsets",!0),p(this,"_totalOffsetPosition",new M),p(this,"_totalOffsetRotation",new Se),p(this,"_totalOffsetPosition2",new M),p(this,"_totalOffsetRotation2",new Se),p(this,"_summedPos",new M),p(this,"_tempPos",new M),p(this,"_summedRot",new Se),p(this,"_tempRot",new Se),p(this,"_clipRotQuat",new Se)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&qj(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,i){var s,r;if(((s=i.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",i);return}const o=i.tracks[0].name.split("."),a=o[o.length-2],l=a+".position",c=a+".quaternion";let h=!1,d=!1;for(const u of i.tracks)u.name.endsWith(l)?(h=!0,this.createPositionInterpolant(i,e,u)):u.name.endsWith(c)&&(d=!0,this.createRotationInterpolant(i,e,u));if(!h||!d){const u=(r=this.mixer)==null?void 0:r.getRoot(),m=i.tracks[0],f=m.name.lastIndexOf("."),g=m.name.substring(0,f),v=g.substring(g.lastIndexOf(".")+1),y=u.getObjectByName(v);if(y)if(h){if(!d){const b=i.tracks[0].name.substring(0,f)+".quaternion";Ic&&console.warn("Create quaternion track",v,y);const A=y.quaternion,x=new yl(b,[0,i.duration],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);i.tracks.push(x),this.createRotationInterpolant(i,e,x)}}else{const b=g+".position";Ic&&console.warn("Create position track",v,y);const A=y.position,x=new ac(b,[0,i.duration],[A.x,A.y,A.z,A.x,A.y,A.z]);i.tracks.push(x),this.createPositionInterpolant(i,e,x)}}}bind(){if(!this._didBind){this._didBind=!0,Ic&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const i=new cye(e);this._actionOffsets.push(i)}this.target&&(this._animator=ie.getComponent(this.target,sr)??null,this._animator&&qj(this._animator.gameObject,this,!0));for(const e of this.models){const i=e.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new M(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new Se(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new M(e.x,e.y,e.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new Se(i.x,i.y,i.z,i.w)))}}evaluate(e){var i,s,r,o,a,l,c;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let h=0,d=0,u=!1,m=!1,f=0;for(let g=0;g<this.clips.length;g++){const v=this.models[g],y=this.actions[g],b=v.asset;y.weight=0;const A=e>=v.start&&e<=v.end,x=v.preExtrapolationMode,w=v.postExtrapolationMode,_=g<this.clips.length-1?this.models[g+1]:null;let S=A,C=!1;if(!S&&!u&&v.end<e&&w!==Rc.None?(!_||_.start>e)&&(S=!0,u=!0):g==0&&!S&&!m&&v.start>e&&x!==Rc.None&&(!_||_.start<e)&&(S=!0,C=!0,m=!0),S){let R=this.weight;R*=this.evaluateWeight(e,g,this.models,S),R*=this.director.weight;let P=A;if(C)switch(x){case Rc.Hold:break;case Rc.Loop:e+=v.start,P=!0;break;default:e+=v.start,P=!0;break}let T=this.getClipTime(e,v),L=0;const k=b.duration;if(C&&x===Rc.Hold&&(T=0),P){if(b.loop)for(L+=Math.floor(T/(k+1e-6));T>k;)T-=k}else if(!A&&u)switch(w){case Rc.Hold:T=this.getClipTime(v.end,v);break;case Rc.Loop:T%=k;break;case Rc.PingPong:const O=Math.floor(T/k)%2!==0;T%=k,O&&(T=k-T);break}v.reversed===!0?y.time=y.getClip().duration-T:y.time=T,y.timeScale=0;const G=Math.max(0,R);if(y.weight=G,f+=G,y.clampWhenFinished=!1,y.isRunning()||y.play(),this._useclipOffsets){const O=h==0?this._totalOffsetPosition:this._totalOffsetPosition2,W=h==0?this._totalOffsetRotation:this._totalOffsetRotation2;h<1&&(d=1-R),h+=1;const D=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),U=this._summedRot.identity(),Y=this._tempRot.identity(),q=b.rotation;q&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(q,R));const oe=this._actionOffsets[g];if(oe.hasOffsets)for(let xe=0;xe<L;xe++)oe.rootPositionOffset?F.copy(oe.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(U),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),oe.rootQuaternionOffset&&(Y.copy(oe.rootQuaternionOffset),U.multiply(Y)),D.add(F);this._clipRotQuat&&W.multiply(this._clipRotQuat),W.multiply(U),b.position&&D.add(b.position),O.add(D)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,d),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,d)),this.__mixerError===void 0&&(Ic||je())&&(s=(i=this._animator)==null?void 0:i.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((o=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:o.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(a=this._animator)!=null&&a.runtimeAnimatorController){const g=Math.max(0,1-f);(c=(l=this._animator)==null?void 0:l.runtimeAnimatorController)==null||c.update(g)}else this.mixer.update(e)}createRotationInterpolant(e,i,s){var r;const o=s.createInterpolant.bind(s),a=new Se;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const c=o(),h=c.evaluate.bind(c);return c.evaluate=d=>{var u;const m=h(d);if(a.set(m[0],m[1],m[2],m[3]),a.premultiply(this._totalOffsetRotation),l&&a.premultiply(l),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(u=f?.onTimelineRotation)==null||u.call(f,this.director,this.target,d,a);return m[0]=a.x,m[1]=a.y,m[2]=a.z,m[3]=a.w,m},c}}createPositionInterpolant(e,i,s){var r,o;const a=s.createInterpolant.bind(s),l=new M;this.ensureTrackOffsets();const c=(r=this.trackOffset)==null?void 0:r.rotation,h=(o=this.trackOffset)==null?void 0:o.position;let d;s.createInterpolant=()=>{const u=a(),m=u.evaluate.bind(u);return u.evaluate=f=>{var g,v,y;const b=m(f);if(l.set(b[0],b[1],b[2]),i.removeStartOffset&&(d===void 0?(d=null,d=(v=(g=this._actionOffsets.find(A=>A.clip===e))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):d!=null&&d.isVector3&&l.sub(d)),l.applyQuaternion(this._totalOffsetRotation),l.add(this._totalOffsetPosition),c&&l.applyQuaternion(c),h&&(l.x-=h.x,l.y+=h.y,l.z+=h.z),this.director.animationCallbackReceivers)for(const A of this.director.animationCallbackReceivers)(y=A?.onTimelinePosition)==null||y.call(A,this.director,this.target,f,l);return b[0]=l.x,b[1]=l.y,b[2]=l.z,b},u}}}const hye=te("mutetimeline"),OA=class extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"listener"),p(this,"audio",[]),p(this,"audioContextTimeOffset",[]),p(this,"lastTime",0),p(this,"audioSource"),p(this,"_audioLoader",null),p(this,"_playableDirectorResumed",!1)}getAudioFilePath(n){const e=this.director.sourceId;return Qd(e,n)}onAllowAudioChanged(n){for(let e=0;e<this.models.length;e++){const i=this.models[e];this.audio[e].setVolume(n?i.asset.volume:0)}}addModel(n){const e=new rI(this.listener);this.audio.push(e);const i=n;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const n of this.audio)n.isPlaying&&n.stop();for(const n of this.models)n._didTriggerPlay=!1}onDestroy(){for(const n of this.audio)n.source&&n?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}for(const n of this.models)n._didTriggerPlay=!1}onPauseChanged(){for(let n=0;n<this.audio.length;n++){const e=this.audio[n];e!=null&&e.isPlaying&&e.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(n){if(hye||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const s=e?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r],l=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,n-1,n+1)&&this.handleAudioLoading(o,a),Cn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=l.loop,n>=o.start&&n<=o.end&&n<this.director.duration){if(!a.isPlaying||!this.director.isPlaying)(i||!o._didTriggerPlay&&this.lastTime<n)&&(o.duration*o.timeScale>.3?a.offset=o.clipIn+(n-o.start)*o.timeScale:a.offset=0,Ic&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+o.asset.clip),a.play(s),o._didTriggerPlay=!0);else{const h=o.clipIn+(n-o.start)*o.timeScale,d=a.context.currentTime-a._startedAt+a.offset;Math.abs(h-d)>.3&&(a.offset=h,a.stop(),a.play(s))}let c=l.volume;if(this.track.volume!==void 0&&(c*=this.track.volume),e&&(c=0),o.easeInDuration>0){const h=Math.min((n-o.start)/o.easeInDuration,1);c*=h}if(o.easeOutDuration>0){const h=Math.min((o.end-n)/o.easeOutDuration,1);c*=h}a.setVolume(c*this.director.weight)}else o._didTriggerPlay=!1,this.director.isPlaying&&a.isPlaying&&a.stop()}this.lastTime=n}loadAudio(n,e=0,i=0){let s=null;const r=n-i,o=n+e;for(const a of this.models)if(this.isInTimeRange(a,r,o)){const l=this.audio[this.models.indexOf(a)],c=this.handleAudioLoading(a,l);c!==null&&(s===null&&(s=[]),s.push(c))}return s!==null?Promise.all(s):null}isInTimeRange(n,e,i){return e<=n.start&&i>=n.end||e>=n.start&&e<=n.end||i>=n.start&&i<=n.end}static dispose(){OA._audioBuffers.clear()}handleAudioLoading(n,e){this._audioLoader||(this._audioLoader=new i_);const i=this.getAudioFilePath(n.asset.clip);if(OA._audioBuffers.get(i)){const r=OA._audioBuffers.get(i);return r.then(o=>{o&&e.setBuffer(o)}),r}Ic&&console.warn("LOAD audio track",i,this.director.sourceId);const s=new Promise((r,o)=>{this._audioLoader.load(i,a=>{e.setBuffer(a),r(a)},void 0,a=>{console.error("Error loading audio",a),r(null)})});return OA._audioBuffers.set(i,s),s}};let DA=OA;p(DA,"_audioBuffers",new Map);class GA extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"didTrigger",[]),p(this,"receivers",[])}evaluate(e){var i;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],l=o.time-e;let c=!1;if(o.retroActive)c=l<=1e-6;else{const h=Math.abs(l);(h===0||h>=1e-5&&h<s)&&(c=!0)}if(c){if(!a)if(Ic&&console.log("Trigger signal",e,o.time,o),this.didTrigger[r]=!0,((i=this.receivers)==null?void 0:i.length)<=0)O0.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class pM extends BA{constructor(){super(...arguments),p(this,"models",[]),p(this,"timelines",[]),p(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let i=this.models.length-1;i>=0;i--){const s=this.models[i].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",i,s),this.models.splice(i,1);continue}else{const r=ie.getComponent(s.sourceObject,Fu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const a=this.getClipTime(e,r);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[s];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const l=o.sourceObject;a?.sourceObject!==l&&(l.visible=!1)}}}}}const dye=te("debugpost");let AO=null;function uye(n){AO=n}function gQ(n){let e=n.gameObject;for(;e;){for(const i of gC(e))if(i.isPostProcessingManager===!0)return i;e=e.parent}return null}function pye(n){let e=gQ(n);if(!e)if(AO){dye&&console.warn("Adding postprocessing manager to the scene.");const i=n.scene;e=ra(i,AO)}else je()&&console.warn("No post processing manager found");return e}var mye=Object.defineProperty,fye=Object.getOwnPropertyDescriptor,yQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?fye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&mye(e,i,r),r};const gye=te("debugpost");class qe{constructor(e){p(this,"isVolumeParameter",!0),p(this,"_isInitialized",!1),p(this,"_active",!0),p(this,"_value"),p(this,"_valueRaw"),p(this,"_defaultValue"),p(this,"valueProcessor"),p(this,"onValueChanged"),e!==void 0&&this.initialize(e)}get isInitialized(){return this._isInitialized}initialize(e){e!==void 0&&(this._value=e,this._defaultValue=e,this._valueRaw=e,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const i=e?this._valueRaw:this._defaultValue;this.processValue(i,!0)}get value(){return this._valueRaw}set value(e){this.isInitialized||this.initialize(e),this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,i){if(e==null||!i&&this.testIfValueChanged(e)===!1)return;const s=this._value;gye&&typeof s=="number"&&typeof e=="number"&&(s?.toFixed(4),e?.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}yQ([E()],qe.prototype,"overrideState",1),yQ([E()],qe.prototype,"value",1);class yye extends Ha{constructor(){super([qe])}onSerialize(e,i){}onDeserialize(e,i){const s=i.target,r=i.path;let o;if(s&&r&&(o=s[r]),(typeof o!="object"||typeof o=="object"&&o.isVolumeParameter!==!0)&&(o=new qe),typeof e=="object"&&"value"in e){const a=e.value;o.initialize(a),o.overrideState=e.overrideState}else o.value=e;return o}}new yye;var vye=Object.defineProperty,bye=Object.getOwnPropertyDescriptor,Aye=(n,e,i,s)=>{for(var r=s>1?void 0:s?bye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&vye(e,i,r),r};const xye=te("debugpost");class Us extends Pe{constructor(e=void 0){if(super(),p(this,"active",!0),p(this,"_manager",null),p(this,"_result"),p(this,"_postprocessingContext",null),e)for(const i of Object.keys(e)){const s=e[i],r=this[i];r instanceof qe?r.initialize(s):r!==void 0&&(this[i]=s)}}get isPostProcessingEffect(){return!0}onEnable(){super.onEnable(),this.onEffectEnabled(),this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){var e;super.onDisable(),(e=this._manager)==null||e.removeEffect(this),this.active=!1}onEffectEnabled(e){var i;e&&e.isPostProcessingManager===!0?this._manager=e:this._manager||(this._manager=pye(this)),(i=this._manager)==null||i.addEffect(this)}init(){}get postprocessingContext(){return this._postprocessingContext}apply(e){var i;return this._postprocessingContext=e,this._result||(this.initParameters(),this._result=(i=this.onCreateEffect)==null?void 0:i.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){xye&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const i of e){const s=this[i];s instanceof qe&&s.__init()}}onEditorModification(e){const i=e.propertyName;if(this[i]instanceof qe){const s=e.value;return this[i].value=s,!0}}}Aye([E()],Us.prototype,"active",2);var wye=Object.defineProperty,_ye=Object.getOwnPropertyDescriptor,Sye=(n,e,i,s)=>{for(var r=s>1?void 0:s?_ye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&wye(e,i,r),r};const Cye=te("debugpost"),xO={};function Ja(n,e){xO[n]=e}function Mye(n){return n.__type in xO?xO[n.__type]:(Cye&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Us)}class NA{constructor(){p(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(i=>i.init())}addEffect(e){this.components.push(e)}removeEffect(e){const i=this.components.indexOf(e);i>=0&&this.components.splice(i,1)}}Sye([R0([n=>Mye(n),Us])],NA.prototype,"components",2);var Eye=Object.defineProperty,Tye=Object.getOwnPropertyDescriptor,Rye=(n,e,i,s)=>{for(var r=s>1?void 0:s?Tye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Eye(e,i,r),r};class FA extends Us{constructor(){super(...arguments),p(this,"preset",new qe(cm.HIGH))}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new cV({preset:cm.HIGH,edgeDetectionMode:EL.DEPTH});return this.preset.onValueChanged=i=>{e.applyPreset(i)},e}}Rye([E(qe)],FA.prototype,"preset",2),Ja("Antialiasing",FA);const Iye=te("debugusdz");class vp{constructor(){p(this,"files",new Array)}static getName(e){var i;const s=e.split(".").pop();let r=(i=e.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:i.replace(".","_");return r||(r="Audio_"+Math.random().toString(36).substring(2,15)),Ul(r)+"."+s}get extensionName(){return"Audio"}onExportObject(e,i,s){const r=ie.getComponents(e,Cn);if(r.length)for(const o of r){if(!o.clip||typeof o.clip!="string"||!o.playOnAwake)continue;const a=o.clip.split("/").pop()||"Audio",l=vp.getName(o.clip),c=Ul(l);if(!this.files.some(h=>h.path===o.clip)){this.files.push({path:o.clip,name:l});const h=l.toLowerCase();s.quickLookCompatible&&!h.endsWith(".mp3")&&!h.endsWith(".wav")&&!h.endsWith(".m4a")&&console.error("Audio file "+o.clip+" from "+o.name+" is not an MP3 or WAV file. QuickLook may not support playing it.")}s.quickLookCompatible||i.addEventListener("serialize",(h,d)=>{h.appendLine(),h.beginBlock(`def SpatialAudio "${c}"`,"(",!1),h.appendLine(`displayName = "${a}"`),h.closeBlock(")"),h.beginBlock(),h.appendLine(`uniform asset filePath = @audio/${l}@`),h.appendLine(`uniform token auralMode = "${o.spatialBlend>0?"spatial":"nonSpatial"}"`),h.appendLine(`uniform token playbackMode = "${o.loop?"loopFromStage":"onceFromStart"}"`),h.appendLine(`uniform float gain = ${o.volume}`),h.closeBlock()})}}async onAfterSerialize(e){for(const i of this.files){const s="audio/"+i.name;if(e.files[s]){Iye&&console.warn("Audio file with name "+s+" already exists in the context. Skipping.");continue}const r=await(await(await fetch(i.path)).blob()).arrayBuffer(),o=new Uint8Array(r);e.files[s]=o}}}const qh=te("debugautosync"),wO=Symbol("syncerId");class Lye{constructor(){p(this,"_syncers",{})}getOrCreateSyncer(e){if(!e.guid)return null;if(this._syncers[e.guid])return this._syncers[e.guid];const i=new Pye(e);return i[wO]=e.guid,this._syncers[i[wO]]=i,i}removeSyncer(e){delete this._syncers[e[wO]]}}const _O=new Lye;class Pye{constructor(e){p(this,"comp"),p(this,"hasChanges",!1),p(this,"changedProperties",{}),p(this,"_isReceiving",!1),p(this,"_isInit",!1),p(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const i=this.comp.context.connection;if(!i||!i.isConnected||!i.isInRoom){for(const s in this.changedProperties)delete this.changedProperties[s];return}for(const s in this.changedProperties){const r=this.comp.guid+"/"+s,o=this.changedProperties[s];qh&&console.log("SEND",this.comp.name,this.networkingKey),i.send(this.networkingKey,{guid:r,data:o},Bl.Queued)}}),p(this,"onHandleReceiving",i=>{if(qh&&console.log("RECEIVE",this.comp.name,this.comp.guid,i),!this._isInit||!this.comp||i.guid.startsWith(this.comp.guid)===!1)return;const[s,r]=i.guid.split("/");qh&&console.log("RECEIVED",this.comp.name,this.comp.guid,i);try{this._isReceiving=!0,this.comp[r]=i.data}catch(o){console.error(o)}finally{this._isReceiving=!1}}),this.comp=e}get networkingKey(){return this.comp.guid}init(e){if(this._isInit)return;this._isInit=!0,this.comp=e,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const i=this.comp.context.connection.tryGetState(this.comp.guid);i&&this.onHandleReceiving(i)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(e,i){this._isReceiving||(qh&&console.log("Property changed: "+e,i),this.hasChanges=!0,this.changedProperties[e]=i)}}function kye(n,e){let i=e!==n;return!i&&n&&e&&(Array.isArray(n)&&Array.isArray(e)||typeof n=="object"&&typeof e=="object")&&(i=!0),i}const zA=Symbol("AutoSyncHandler");function Bye(n){if(n[zA])return n[zA];const e=_O.getOrCreateSyncer(n);return e?.init(n),n[zA]=e,e}function Oye(n){const e=n[zA];e&&(_O.removeSyncer(e),e.destroy(),delete n[zA])}const SO=function(n=null){return function(e,i){var s;let r="";typeof i=="string"?r=i:r=i.name;let o=null,a;typeof n=="string"?a=e[n]:typeof n=="function"&&(a=n),a==null&&(je()||qh)&&n!=null&&console.warn('syncField: no callback function found for property "'+r+'"','"'+n+'"');const l=e,c=l.__internalAwake;if(typeof c!="function"){(qh||je())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((s=e?.constructor)==null?void 0:s.name)+'" is not supported',e);return}qh&&console.log(r);const h=Symbol(r);l.__internalAwake=function(){if(this[h]!==void 0)return;this[h]=this[r],o=_O.getOrCreateSyncer(this);const u=Object.getOwnPropertyDescriptor(this,r);if(u?.set===void 0){let m=!1;Object.defineProperty(this,r,{set:function(f){var g;const v=this[h];if(this[h]=f,m){(je()||qh)&&console.warn("Recursive call detected",r);return}m=!0;try{const y=kye(f,v);qh&&console.log("SyncField assignment",r,"changed?",y,f,a),y&&a?.call(this,f,v)!==!1&&((g=Bye(this))==null||g.notifyChanged(r,f))}finally{m=!1}},get:function(){return this[h]},configurable:!0,enumerable:!0})}o?.init(this),c.call(this)};const d=l.__internalDestroy;l.__internalDestroy=function(){Oye(this),d.call(this)}}};var Dye=Object.defineProperty,Gye=Object.getOwnPropertyDescriptor,mM=(n,e,i,s)=>{for(var r=s>1?void 0:s?Gye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Dye(e,i,r),r};const da=te("debugplayersync"),vQ=class extends Pe{constructor(){super(...arguments),p(this,"autoSync",!0),p(this,"asset"),p(this,"onPlayerSpawned"),p(this,"_localInstance"),p(this,"onJoinedRoom",()=>{da&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()}),p(this,"destroyInstance",()=>{var n;(n=this._localInstance)==null||n.then(e=>{da&&console.log("PlayerSync.destroyInstance",e),qb(e,this.context.connection,!0,{saveInRoom:!1})}),this._localInstance=void 0})}static async setupFrom(n,e){const i=ei.getOrCreateFromUrl(n);if(!i.asset){const o=await i.loadAssetAsync();ie.getOrAddComponent(o,ua)}const s=new vQ;s._internalInit(e),s.asset=i;const r=new ge;return r.guid=n,ie.addComponent(r,s),s}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new ji)}onEnable(){this.context.connection.beginListen(Xt.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Xt.LeftRoom,this.destroyInstance),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(Xt.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(Xt.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Xt.LeftRoom,this.destroyInstance)}async getInstance(){var n,e,i,s,r,o;if(this._localInstance)return this._localInstance;if(da&&console.log("PlayerSync.createInstance",(n=this.asset)==null?void 0:n.url),!((e=this.asset)!=null&&e.asset)&&!((i=this.asset)!=null&&i.url))return console.error('PlayerSync: can not create an instance because "asset" is not set and or has no URL!'),null;this.gameObject.guid||console.warn("PlayerSync: gameObject has no guid! This might cause issues with syncing the player state."),this._localInstance=(s=this.asset)==null?void 0:s.instantiateSynced({parent:this.gameObject,deleteOnDisconnect:!0},!0);const a=await this._localInstance;if(a){const l=ie.getComponentsInChildren(a,ua);if(l!=null&&l.length){for(const c of l)c.owner=this.context.connection.connectionId;(r=this.onPlayerSpawned)==null||r.invoke(a)}else this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.url)+"</strong>: please make sure the asset has a PlayerState component!"),ie.destroySynced(a)}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}watchTabVisible(){window.addEventListener("visibilitychange",n=>{if(document.visibilityState==="visible")for(let e=ua.all.length-1;e>=0;e--){const i=ua.all[e];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}};let D0=vQ;mM([E()],D0.prototype,"autoSync",2),mM([E(ei)],D0.prototype,"asset",2),mM([E(ji)],D0.prototype,"onPlayerSpawned",2);var bQ=(n=>(n.OwnerChanged="ownerChanged",n))(bQ||{}),UA;const or=(UA=class extends Pe{constructor(){super(...arguments),p(this,"onOwnerChangeEvent",new ji),p(this,"onFirstOwnerChangeEvent",new ji),p(this,"hasOwner",!1),p(this,"owner"),p(this,"dontDestroy",!1),p(this,"onUserLeftRoom",n=>{if(n.userId===this.owner){da&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return or._all}static get local(){return or._local}static getFor(n){if(n instanceof ge)return ie.getComponentInParent(n,or);if(n instanceof Pe)return ie.getComponentInParent(n.gameObject,or)}static isLocalPlayer(n){const e=or.getFor(n);return e?.isLocalPlayer??!1}static addEventListener(n,e){return this._callbacks[n]||(this._callbacks[n]=[]),this._callbacks[n].push(e),e}static removeEventListener(n,e){if(!this._callbacks[n])return;const i=this._callbacks[n].indexOf(e);i>=0&&this._callbacks[n].splice(i,1)}static dispatchEvent(n,e){if(this._callbacks[n])for(const i of this._callbacks[n])i(e)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(n,e){var i,s;da&&console.log("PlayerSync.onOwnerChange",this,"newOwner",n,"oldOwner",e);const r=or._local.indexOf(this);r>=0&&or._local.splice(r,1);const o={playerState:this,oldValue:e,newValue:n};if(this.hasOwner||(this.hasOwner=!0,(i=this.onFirstOwnerChangeEvent)==null||i.invoke(o)),(s=this.onOwnerChangeEvent)==null||s.invoke(o),this.owner===this.context.connection.connectionId){or._local.push(this);const l=new CustomEvent("local-owner-changed",{detail:o});this.dispatchEvent(l)}const a=new CustomEvent("owner-changed",{detail:o});this.dispatchEvent(a),or.dispatchEvent("ownerChanged",a)}awake(){or.all.push(this),da&&console.log("Registered new PlayerState",this.guid,or.all.length-1,or.all),this.context.connection.beginListen(Xt.UserLeftRoom,this.onUserLeftRoom)}async start(){da&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await bl(300),this.context.connection.userIsInRoom(this.owner)==!1&&(da&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(da&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?da&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(da&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):da&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){da&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),qb(this.gameObject,this.context.connection,!0,{saveInRoom:!1})}onDestroy(){if(this.context.connection.stopListen(Xt.UserLeftRoom,this.onUserLeftRoom),or.all.splice(or.all.indexOf(this),1),this.isLocalPlayer){const n=or._local.indexOf(this);n>=0&&or._local.splice(n,1)}}},p(UA,"_all",[]),p(UA,"_local",[]),p(UA,"_callbacks",{}),UA);let ua=or;mM([SO(ua.prototype.onOwnerChange)],ua.prototype,"owner",2);const Nye=te("debugavatar"),Lc=class extends Pe{constructor(){super(...arguments),p(this,"connectionId"),p(this,"avatar")}static getAvatar(n){return n>=0&&n<Lc.instances.length?Lc.instances[n]:null}static onAvatarMarkerCreated(n){return Lc._onNewAvatarMarkerAdded.push(n),n}static onAvatarMarkerDestroyed(n){return Lc._onAvatarMarkerDestroyed.push(n),n}awake(){Lc.instances.push(this),Nye&&console.log(this);for(const n of Lc._onNewAvatarMarkerAdded)n({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){Lc.instances.splice(Lc.instances.indexOf(this),1);for(const n of Lc._onAvatarMarkerDestroyed)n({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let ar=Lc;p(ar,"instances",[]),p(ar,"_onNewAvatarMarkerAdded",[]),p(ar,"_onAvatarMarkerDestroyed",[]);var Fye=Object.defineProperty,zye=Object.getOwnPropertyDescriptor,Uye=(n,e,i,s)=>{for(var r=s>1?void 0:s?zye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Fye(e,i,r),r};const G0=te("debugxrflags"),AQ=te("disablexrflags");AQ&&console.warn("XRFlags are disabled");var Pc=(n=>(n[n.Never=0]="Never",n[n.Browser=1]="Browser",n[n.AR=2]="AR",n[n.VR=4]="VR",n[n.FirstPerson=8]="FirstPerson",n[n.ThirdPerson=16]="ThirdPerson",n[n.All=4294967295]="All",n))(Pc||{});const xQ=class{constructor(){p(this,"Mask",17)}Has(n){return(this.Mask&n)!==0}Set(n){G0&&console.warn("Set XR flag state to",n),this.Mask=n,pa.Apply()}Enable(n){this.Mask|=n,pa.Apply()}Disable(n){this.Mask&=~n,pa.Apply()}Toggle(n){this.Mask^=n,pa.Apply()}EnableAll(){this.Mask=-1,pa.Apply()}DisableAll(){this.Mask=0,pa.Apply()}};let go=xQ;p(go,"Global",new xQ);var VA;const $h=(VA=class extends Pe{constructor(){super(...arguments),p(this,"visibleIn")}static Apply(){for(const n of this.registry)n.UpdateVisible(go.Global)}awake(){$h.registry.push(this)}onEnable(){$h.firstApply?this.UpdateVisible(go.Global):($h.firstApply=!0,$h.Apply())}onDestroy(){const n=$h.registry.indexOf(this);n>=0&&$h.registry.splice(n,1)}get isOn(){return this.gameObject.visible}UpdateVisible(n=null){if(AQ)return;let e;const i=n;if(i&&typeof i=="number"&&(console.assert(typeof i=="number","XRFlag.UpdateVisible: state must be a number",i),G0&&console.log(i),$h.buffer.Mask=i,n=$h.buffer),n instanceof go?(G0&&console.warn(this.name,"use passed in mask",n.Mask,this.visibleIn),e=n.Has(this.visibleIn)):(G0&&console.log(this.name,"use global mask"),go.Global.Has(this.visibleIn)),e!==void 0)if(e)G0&&console.log(this.name,"is visible",this.gameObject.uuid),ie.setActive(this.gameObject,!0);else{if(G0&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},p(VA,"registry",[]),p(VA,"firstApply"),p(VA,"buffer",new go),VA);let pa=$h;Uye([E()],pa.prototype,"visibleIn",2);var Vye=Object.defineProperty,Xye=Object.getOwnPropertyDescriptor,CO=(n,e,i,s)=>{for(var r=s>1?void 0:s?Xye(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Vye(e,i,r),r};const XA=te("debugwebxr"),wQ=new Se().setFromAxisAngle(new M(0,1,0),Math.PI);class zu extends Pe{constructor(){super(...arguments),p(this,"head"),p(this,"leftHand"),p(this,"rightHand"),p(this,"_leftHandMeshes"),p(this,"_rightHandMeshes"),p(this,"_syncTransforms")}async onEnterXR(e){if(!this.activeAndEnabled)return;XA&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const i=ua.getFor(this);if(i!=null&&i.owner){const s=this.gameObject.addComponent(ar);s.avatar=this.gameObject,s.connectionId=i.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):i&&!this.context.connection.isConnected&&(i.dontDestroy=!0)}onLeaveXR(e){const i=this.gameObject.getComponent(ar);i&&i.destroy()}onUpdateXR(e){var i,s;if(!this.activeAndEnabled)return;const r=ua.isLocalPlayer(this);if(!r)return;const o=e.xr;if(o.rig&&o.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),o.rig.gameObject.add(this.gameObject)),this._syncTransforms&&r)for(const d of this._syncTransforms)d.fastMode=!0,d.isOwned()||d.requestOwnership();if(this.head&&this.context.mainCamera){const d=this.head.asset;if(d.position.copy(this.context.mainCamera.position),d.position.x*=-1,d.position.z*=-1,d.quaternion.copy(this.context.mainCamera.quaternion),d.quaternion.x*=-1,this.context.time.frameCount%10===0){const u=ie.getComponentsInChildren(this.head.asset,pa);for(const m of u)m.enabled=!1,m.gameObject.visible=!1}}const a=e.xr.leftController,l=(i=this.leftHand)==null?void 0:i.asset;a&&l?(l.position.copy(a.gripPosition),l.quaternion.copy(a.gripQuaternion),l.quaternion.multiply(wQ),l.visible=a.isTracking,this.updateHandVisibility(a,l,this._leftHandMeshes)):l&&l.visible&&(l.visible=!1);const c=e.xr.rightController,h=(s=this.rightHand)==null?void 0:s.asset;c&&h?(h.position.copy(c.gripPosition),h.quaternion.copy(c.gripQuaternion),h.quaternion.multiply(wQ),h.visible=c.isTracking,this.updateHandVisibility(c,h,this._rightHandMeshes)):h&&h.visible&&(h.visible=!1)}onBeforeRender(){this.context.xr&&this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateHandVisibility(e,i,s){if(s){const r=e.model&&e.model.visible&&e.model!==i;s.forEach(o=>{Vh(o,!r)})}}updateRemoteAvatarVisibility(){var e,i,s;if(this.context.connection.isConnected){const r=ua.getFor(this);if(r&&r.isLocalPlayer==!1){const o=Et.getXRSync(this.context);if(o&&o.hasState(r.owner)){this.tryFindAvatarObjectsIfMissing();const a=(e=this.leftHand)==null?void 0:e.asset;a&&(a.visible=o?.isTracking(r.owner,"left")??!1);const l=(i=this.rightHand)==null?void 0:i.asset;l&&(l.visible=o?.isTracking(r.owner,"right")??!1)}if((s=this.head)!=null&&s.asset){const a=ie.getComponentsInChildren(this.head.asset,pa);for(const l of a)l.enabled=!1,l.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const e={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};u9.tryFindAvatarObjects(this.gameObject,this.sourceId||"",e),e.head&&(this.head=e.head),e.leftHand&&(this.leftHand=e.leftHand),e.rightHand&&(this.rightHand=e.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof ge&&(this.head=new ei("",this.sourceId,this.head));else{const e=new ge;e.name="Head";const i=vu.createPrimitive(_m.Cube);e.add(i),this.gameObject.add(e),this.head=new ei("",this.sourceId,e),XA&&console.log("Create head",e)}if(this.rightHand)this.rightHand instanceof ge&&(this.rightHand=new ei("",this.sourceId,this.rightHand));else{const e=new ge;e.name="Right Hand",this.gameObject.add(e),this.rightHand=new ei("",this.sourceId,e),XA&&console.log("Create right hand",e)}if(this.leftHand)this.leftHand instanceof ge&&(this.leftHand=new ei("",this.sourceId,this.leftHand));else{const e=new ge;e.name="Left Hand",this.gameObject.add(e),this.leftHand=new ei("",this.sourceId,e),XA&&console.log("Create left hand",e)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),this._leftHandMeshes=[],this.leftHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._leftHandMeshes.push(e)}),this._rightHandMeshes=[],this.rightHand.asset.traverse(e=>{e!=null&&e.isMesh&&this._rightHandMeshes.push(e)}),ua.isLocalPlayer(this.gameObject)&&(this._syncTransforms=ie.getComponentsInChildren(this.gameObject,Ec))}async loadAvatarObjects(e,i,s){const r=e.loadAssetAsync(),o=i.loadAssetAsync(),a=s.loadAssetAsync(),l=new Array;r&&l.push(r),o&&l.push(o),a&&l.push(a);const c=await f_(l);XA&&console.log("Avatar loaded results:",c)}}CO([E(ei)],zu.prototype,"head",2),CO([E(ei)],zu.prototype,"leftHand",2),CO([E(ei)],zu.prototype,"rightHand",2);class kc{static Add(e,i,s=null){if(i){for(const r of this.Pois)if(r.obj===i)return;this.Pois.push({obj:i,avatar:s}),this.LastChangeTime=e.time.time}}static Remove(e,i){var s;if(i){for(const r of this.Pois)if(r.obj===i){this.Pois.splice(this.Pois.indexOf(r),1),this.LastChangeTime=e?.time.time??((s=Pt.Current)==null?void 0:s.time.time);return}}}}p(kc,"Pois",[]),p(kc,"LastChangeTime",0);class Wye{constructor(){p(this,"guid"),p(this,"position",new M)}}class WA extends Pe{constructor(){super(...arguments),p(this,"target",null),p(this,"avatar",null),p(this,"_model",null),p(this,"_targetModel",new Wye),p(this,"_currentTargetObject",null),p(this,"_lastUpdateTime",0),p(this,"_lookDuration",0),p(this,"_lastPoiChangedTime",0)}set controlledTarget(e){this.target=e;const i=Z.get("MoveRandom");if(i&&this.target){const s=ie.getComponent(this.target,i);s&&s.destroy()}}awake(){if(this.avatar=ie.getComponentInParent(this.gameObject,ar),this.avatar){const e=ie.getComponentInParent(this.gameObject,ar);this._model=new gk(this.context.connection,this.guid),e!=null&&e.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",e=>{var i;this.target&&e&&e.guid===((i=this.avatar)==null?void 0:i.guid)&&bs(this.target,e.position)})}update(){var e;if((!this.context.connection.isConnected||(e=this._model)!=null&&e.hasOwnership)&&(kc.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=kc.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const i=Nt(this._currentTargetObject);bs(this.target,i),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(i))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const e=kc.Pois;if(e.length>0){const i=e[Math.floor(Math.random()*e.length)];if(i&&i.obj){if(i.avatar&&i.avatar===this.avatar)return;this._currentTargetObject=i.obj}}}}}function _Q(n){return n&&n.isComponent}const Hye=Symbol("object"),MO=new Yo(()=>new M,20);class SQ{constructor(e,i,s,r,o,a){p(this,"_point"),p(this,"_normal"),p(this,"_tangentVelocity"),p(this,"distance"),p(this,"impulse"),p(this,"friction"),this._point=e,this.distance=i,this._normal=s,this.impulse=r,this.friction=o,this._tangentVelocity=a}get point(){return MO.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return MO.get().set(this._normal.x,this._normal.y,this._normal.z)}get tangentVelocity(){return MO.get().set(this._tangentVelocity.x,this._tangentVelocity.y,this._tangentVelocity.z)}}class CQ{constructor(e,i,s){p(this,"contacts"),p(this,"me"),p(this,"_collider"),p(this,"_gameObject"),this.me=e,this._collider=i,this._gameObject=i.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class MQ{constructor(e,i){p(this,"object"),p(this,"collider"),this.object=e,this.collider=i}}const Zn=te("debugnetworkingstreams");var Bc=(n=>(n.Connected="peer-user-connected",n.StreamReceived="receive-stream",n.StreamEnded="call-ended",n.Disconnected="peer-user-disconnected",n.UserJoined="user-joined",n))(Bc||{});class EO{constructor(e,i){p(this,"type","call-ended"),p(this,"userId"),p(this,"direction"),this.userId=e,this.direction=i}}class EQ{constructor(e,i,s){p(this,"type","receive-stream"),p(this,"userId"),p(this,"stream"),p(this,"target"),this.userId=e,this.stream=i,this.target=s}}class jye{constructor(e,i){p(this,"guid"),p(this,"peerId"),p(this,"dontSave",!0),this.guid=e.id,this.peerId=i}}var TQ=(n=>(n.Incoming="incoming",n.Outgoing="outgoing",n))(TQ||{});class Qye extends Ts{constructor(e,i,s,r=null){super(),p(this,"peerId"),p(this,"userId"),p(this,"direction"),p(this,"call"),p(this,"_stream",null),p(this,"_isDisposed",!1),this.peerId=i.peer,this.userId=e,this.call=i,this.direction=s,this._stream=r,i.on("stream",o=>{if(Zn&&console.log("Receive stream",`
|
|
5958
5958
|
Audio:`,o.getAudioTracks(),`
|
|
5959
5959
|
Video:`,o.getVideoTracks()),this._stream=o,s==="incoming"){const a=new EQ(e,o,this);this.dispatchEvent(a)}}),i.on("close",()=>{this.dispatchEvent(new EO(e,s))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),Oc(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen||this._isDisposed}}function RQ(n){return n=n.replace("a=fmtp:111 minptime=10;useinbandfec=1","a=fmtp:111 ptime=5;useinbandfec=1;stereo=1;maxplaybackrate=48000;maxaveragebitrat=128000;sprop-stereo=1"),n}const HA=class extends Ts{constructor(n,e){super(),p(this,"updateCalls",()=>{var i;for(let s=this._incomingCalls.length-1;s>=0;s--){const r=this._incomingCalls[s];r.isClosed&&!r.isOpening&&this._incomingCalls.splice(s,1)}for(let s=this._outgoingCalls.length-1;s>=0;s--){const r=this._outgoingCalls[s];let o=!1;r.isClosed&&!r.isOpening&&((i=r.stream)!=null&&i.active?Zn&&console.warn("!!! Stream is still active, don't remove call",r.userId,"Your id: "+this.context.connection.connectionId):(Zn&&console.warn("!!! Remove closed call",r.userId),o=!0)),this.context.connection.userIsInRoom(r.userId)===!1&&(Zn&&console.warn("!!! User is not in room anymore, remove call",r.userId),o=!0),o&&(r.close(),this._outgoingCalls.splice(s,1))}}),p(this,"id"),p(this,"context"),p(this,"_incomingCalls",[]),p(this,"_outgoingCalls",[]),p(this,"_peer"),p(this,"_enabled",!1),p(this,"_enabledPeer",!1),p(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),p(this,"onPeerConnect",i=>{if(Zn&&console.log("PEER opened as",i),i===null){console.error("Peer connection failed",i);return}this.context.connection.send("peer-user-connected",new jye(this,i))}),p(this,"onPeerClose",()=>{Zn&&console.log("PEER closed"),this.updateCalls()}),p(this,"onPeerDisconnected",()=>{Zn&&console.log("PEER disconnected"),this.updateCalls()}),p(this,"onPeerError",i=>{Zn&&console.error("PEER error",i)}),p(this,"onPeerReceivingCall",i=>{i.answer(void 0,{sdpTransform:s=>RQ(s)}),this.registerCall(i,"incoming",null)}),this.context=n,this.id=e,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(n,e){if(HA.instances.has(e))return HA.instances.get(e);const i=new HA(n,e);return HA.instances.set(e,i),i}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(n){return this.id+"-"+n}getUserIdFromPeerId(n){return n.substring(this.id.length+1)}makeCall(n,e){var i;if(!(e!=null&&e.id)){Zn?console.warn("Can not make a call: mediastream has no id or is undefined"):console.debug("Can not make a call: mediastream has no id or is undefined");return}const s={metadata:{userId:this.context.connection.connectionId,streamId:e.id},sdpTransform:o=>RQ(o)},r=(i=this._peer)==null?void 0:i.call(n,e,s);if(r){const o=this.registerCall(r,"outgoing",e);return Zn&&console.warn(`\u{1F4DE} CALL ${n}`,`
|
|
5960
5960
|
Outgoing:`,this._outgoingCalls,`
|
|
@@ -5976,11 +5976,11 @@ dateFormat X
|
|
|
5976
5976
|
axisFormat %s
|
|
5977
5977
|
`;const m=Array.from(o),f=new Set;for(const b of m)if(b.affectedObjects&&typeof b.affectedObjects!="string"){if(Array.isArray(b.affectedObjects))for(const A of b.affectedObjects)f.add(A);else f.add(b.affectedObjects);a&&(u+=`section ${b.animationName} (${b.id})
|
|
5978
5978
|
`,u+=`${b.id} : ${b.start}, ${b.duration}s
|
|
5979
|
-
`)}a&&console.log(u);const g=new Set;for(const b of f){b.getPath||console.error("USDZExporter: Animation target object has no getPath method. This is likely a bug",b);let A=b.getPath();A.startsWith("<")&&(A=A.substring(1)),A.endsWith(">")&&(A=A.substring(0,A.length-1)),g.add({path:A,obj:b})}const v=Array.from(g).sort((b,A)=>b.path.length-A.path.length),y=new Array;for(let b=0;b<v.length;b++)for(let A=b+1;A<v.length;A++)if(v[A].path.startsWith(v[b].path)){const x=v[A],w=v[b];y.push({child:x.obj.displayName+" ("+x.path+")",parent:w.obj.displayName+" ("+w.path+")"})}y.length&&console.warn("USDZExporter: There are overlapping PlayAnimation actions. This can lead to undefined runtime behaviour when playing multiple animations. Please restructure the hierarchy so that animations don't overlap.",{overlappingTargets:y,playAnimationActions:o})}for(const u of new Set([...i,...s]))if(Array.isArray(u))for(const m of u)r.add(m.uuid);else r.add(u.uuid);yM&&console.log("All Behavior trigger sources and action targets",i,s,r),this.targetUuids=new Set(r)}onAfterHierarchy(e,i){var s;if((s=this.behaviours)!=null&&s.length){i.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,i);i.closeBlock()}}async onAfterSerialize(e){yM&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const i of this.behaviourComponentsCopy)typeof i.afterSerialize=="function"&&(i.afterSerialize.constructor.name==="AsyncFunction"?await i.afterSerialize(this,e):i.afterSerialize(this,e));for(const{clipUrl:i,filesKey:s}of this.audioClipsCopy){if(e.files[s])return;const r=await(await(await fetch(i)).blob()).arrayBuffer(),o=new Uint8Array(r);e.files[s]=o}this.behaviourComponentsCopy.length=0,this.audioClipsCopy.length=0}}var ave=Object.defineProperty,lve=Object.getOwnPropertyDescriptor,OO=(n,e,i,s)=>{for(var r=s>1?void 0:s?lve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&ave(e,i,r),r},DO;const PQ=(DO=class extends Us{constructor(){super(...arguments),p(this,"threshold",new qe(.9)),p(this,"intensity",new qe(1)),p(this,"scatter",new qe(.3)),p(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.valueProcessor=n=>n,this.intensity.valueProcessor=n=>n,this.scatter.valueProcessor=n=>n}onCreateEffect(){let n;if(this.selectiveBloom==null&&(this.selectiveBloom=PQ.useSelectiveBloom),this.selectiveBloom){const e=n=new oV(this.context.scene,this.context.mainCamera,{blendFunction:jt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});e.inverted=!0}else n=new ML({blendFunction:jt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{n.intensity=e},this.threshold.onValueChanged=e=>{n.luminanceMaterial.threshold=Math.pow(e,2.2)},this.scatter.onValueChanged=e=>{n.luminancePass.enabled=!0,n.luminanceMaterial.smoothing=e,n.mipmapBlurPass&&(n.mipmapBlurPass.radius=oi.lerp(.1,.9,e))},n}},p(DO,"useSelectiveBloom",!1),DO);let Xm=PQ;OO([E(qe)],Xm.prototype,"threshold",2),OO([E(qe)],Xm.prototype,"intensity",2),OO([E(qe)],Xm.prototype,"scatter",2),Ja("Bloom",Xm);var cve=Object.defineProperty,hve=Object.getOwnPropertyDescriptor,Oo=(n,e,i,s)=>{for(var r=s>1?void 0:s?hve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&cve(e,i,r),r};class Do extends Pe{constructor(){super(...arguments),p(this,"attachedRigidbody",null),p(this,"isTrigger",!1),p(this,"sharedMaterial"),p(this,"membership",[0]),p(this,"filter"),p(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Oo([E(Ci)],Do.prototype,"attachedRigidbody",2),Oo([E()],Do.prototype,"isTrigger",2),Oo([E()],Do.prototype,"sharedMaterial",2),Oo([E()],Do.prototype,"membership",2),Oo([E()],Do.prototype,"filter",2);class z0 extends Do{constructor(){super(...arguments),p(this,"radius",.5),p(this,"center",new M(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),m_(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),vI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Oo([rr(),E()],z0.prototype,"radius",2),Oo([E(M)],z0.prototype,"center",2);const kQ=class extends Do{constructor(){super(...arguments),p(this,"size",new M(1,1,1)),p(this,"center",new M(0,0,0))}static add(n,e){const i=new kQ;n.geometry.boundingBox||n.geometry.computeBoundingBox();const s=n.geometry.boundingBox;return i.size=s.getSize(new M)||new M(1,1,1),i.center=s.getCenter(new M)||new M(0,0,0),ra(n,i),e?.rigidbody===!0&&ra(n,Ci,{isKinematic:!1}),i}onEnable(){var n;super.onEnable(),(n=this.context.physics.engine)==null||n.addBoxCollider(this,this.size),m_(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),vI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}};let U0=kQ;Oo([rr(),E(M)],U0.prototype,"size",2),Oo([E(M)],U0.prototype,"center",2);class Wm extends Do{constructor(){super(...arguments),p(this,"sharedMesh"),p(this,"convex",!1)}onEnable(){var e,i,s;if(super.onEnable(),!this.context.physics.engine)return;(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ue&&(this.sharedMesh=this.gameObject);const r=0;if((i=this.sharedMesh)!=null&&i.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Yi(this.gameObject)),mi.assignMeshLOD(this.sharedMesh,r).then(o=>{o&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=o,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Yi(this.gameObject)))});else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((s=this.sharedMesh)==null?void 0:s.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const a=new Array;for(const l in o.children){const c=o.children[l];c.isMesh&&(this.context.physics.engine.addMeshCollider(this,c,this.convex,Yi(this.gameObject)),a.push(mi.assignMeshLOD(c,r)))}Promise.all(a).then(l=>{var c,h;if(l.some(u=>u)==!1)return;(c=this.context.physics.engine)==null||c.removeBody(this);const d=new ue;for(const u of l)u&&this.activeAndEnabled&&(d.geometry=u,(h=this.context.physics.engine)==null||h.addMeshCollider(this,d,this.convex,Yi(this.gameObject)))})}}}}Oo([E(ue)],Wm.prototype,"sharedMesh",2),Oo([E()],Wm.prototype,"convex",2);class ed extends Do{constructor(){super(...arguments),p(this,"center",new M(0,0,0)),p(this,"radius",.5),p(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Oo([E(M)],ed.prototype,"center",2),Oo([E()],ed.prototype,"radius",2),Oo([E()],ed.prototype,"height",2);var dve=Object.defineProperty,uve=Object.getOwnPropertyDescriptor,GO=(n,e,i,s)=>{for(var r=s>1?void 0:s?uve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&dve(e,i,r),r};class Hm extends Pe{constructor(){super(...arguments),p(this,"objectBounds",!1),p(this,"color"),p(this,"isGizmo",!0),p(this,"_gizmoObject",null),p(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!$b||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new iU(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=Ik(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ji.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var e;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}GO([E()],Hm.prototype,"objectBounds",2),GO([E(Ae)],Hm.prototype,"color",2),GO([E()],Hm.prototype,"isGizmo",2);const pve=te("gizmos"),mve=te("debugboxhelper"),Dc=class extends Pe{constructor(){super(...arguments),p(this,"box",null),p(this,"_lastMatrixUpdateFrame",-1),p(this,"_helper",null),p(this,"_color",null)}isInBox(n){var e;if(!n)return;if(this.box||(this.box=new Wt),Jo([n],void 0,void 0,Dc.testBox),Dc.testBox.isEmpty()){const s=Nt(n,Dc._position);Dc.testBox.setFromCenterAndSize(s,Dc._emptyObjectSize)}this.updateBox();const i=(e=this.box)==null?void 0:e.intersectsBox(Dc.testBox);return i&&mve&&ft.DrawWireBox3(Dc.testBox,16711680,5),i}intersects(n){return n?this.updateBox(!1).intersectsBox(n):!1}updateBox(n=!1){if(this.box||(this.box=new Wt),n||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const i=e,s=Nt(this.gameObject,Dc._position,i),r=Yi(this.gameObject,Dc._size);this.box.setFromCenterAndSize(s,r)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(n=null,e=!1){var i;if(!(!pve&&!e)){if(this._helper){n&&((i=this._color)==null||i.set(n)),this.gameObject.add(this._helper);return}this._helper=Ik(n),this.gameObject.add(this._helper)}}};let qa=Dc;p(qa,"testBox",new Wt),p(qa,"_position",new M),p(qa,"_size",new M(.01,.01,.01)),p(qa,"_emptyObjectSize",new M(.01,.01,.01));class fve extends x5{constructor(e,i={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=i,e._simpleState__statesProperties={};for(const s in i)for(const r in i[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,i){this._simpleState__states[e]=i;const s=[];for(const r in i)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const i in this._simpleState__states)this._simpleState__activeStates.indexOf(i)>-1&&(e={...e,...this._simpleState__states[i]});this.set(e,!1)}storeSet(e,i=!0){if(i)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const i=this._simpleState__activeStates.indexOf(e);i>-1&&(this._simpleState__activeStates.splice(i,1),this.renderStates())}togglePseudoState(e){const i=this._simpleState__activeStates.indexOf(e);i>-1?this._simpleState__activeStates.splice(i,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var gve=Object.defineProperty,yve=Object.getOwnPropertyDescriptor,BQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?yve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&gve(e,i,r),r};class V0 extends Pe{constructor(){super(...arguments),p(this,"effectColor"),p(this,"effectDistance")}}BQ([E(Li)],V0.prototype,"effectColor",2),BQ([E(K)],V0.prototype,"effectDistance",2);var vve=Object.defineProperty,bve=Object.getOwnPropertyDescriptor,YA=(n,e,i,s)=>{for(var r=s>1?void 0:s?bve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&vve(e,i,r),r};const NO=te("debugui"),FO=te("debuguilayout");class zO{constructor(){p(this,"width"),p(this,"height")}}class UO{constructor(){p(this,"x"),p(this,"y"),p(this,"width"),p(this,"height")}}const Xl=new M,KA=new he,bM=new Se,OQ=class extends hl{constructor(){super(...arguments),p(this,"_anchoredPosition"),p(this,"sizeDelta",new K(100,100)),p(this,"pivot",new K(.5,.5)),p(this,"anchorMin",new K(0,0)),p(this,"anchorMax",new K(1,1)),p(this,"minWidth"),p(this,"minHeight"),p(this,"lastMatrix"),p(this,"rectBlock"),p(this,"_transformNeedsUpdate",!1),p(this,"_initialPosition"),p(this,"_parentRectTransform"),p(this,"_lastUpdateFrame",-1),p(this,"_lastAnchoring"),p(this,"_createdBlocks",[]),p(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new K),this._anchoredPosition}set anchoredPosition(n){this._anchoredPosition=n}get width(){let n=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;n=e*i,n+=this.sizeDelta.x}return this.minWidth!==void 0&&n<this.minWidth?this.minWidth:n}get height(){let n=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;n=e*i,n+=this.sizeDelta.y}return this.minHeight!==void 0&&n<this.minHeight?this.minHeight:n}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new K),this.lastMatrix=new he,this.rectBlock=new ge,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,k0(this,"_anchoredPosition",()=>{this.markDirty()}),k0(this,"sizeDelta",()=>{this.markDirty()}),k0(this,"pivot",()=>{this.markDirty()}),k0(this,"anchorMin",()=>{this.markDirty()}),k0(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var n;super.onEnable(),this.rectBlock||(this.rectBlock=new ge),this.lastMatrix||(this.lastMatrix=new he),this._lastAnchoring||(this._lastAnchoring=new K),this._initialPosition||(this._initialPosition=new M),this._anchoredPosition||(this._anchoredPosition=new K),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(n=this.canvas)==null||n.registerTransform(this)}onDisable(){var n;super.onDisable(),this.removeShadowComponent(),(n=this.canvas)==null||n.unregisterTransform(this)}onParentRectTransformChanged(n){this._transformNeedsUpdate||this.onApplyTransform(FO?`${n.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(FO&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(n){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const i=this.shadowComponent;if(!i)return;this.gameObject.parent?this._parentRectTransform=ie.getComponentInParent(this.gameObject.parent,OQ):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,FO&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+n),this.isRoot()?this.Root.screenspace||(i.rotation.y=Math.PI):(i.matrix.identity(),i.matrixAutoUpdate=!1,Xl.set(0,0,0),this.applyPivot(Xl),i.matrix.setPosition(Xl.x,Xl.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(bM.copy(this.gameObject.quaternion),bM.x*=-1,bM.z*=-1,KA.makeRotationFromQuaternion(bM),i.matrix.premultiply(KA)),Xl.set(0,0,0),this.applyAnchoring(Xl),(e=this.canvas)!=null&&e.screenspace?Xl.z+=.1:Xl.z+=.01,KA.identity(),KA.setPosition(Xl.x,Xl.y,Xl.z),i.matrix.premultiply(KA),i.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of gC(this.gameObject,hl,s,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(n){this._lastAnchoring||(this._lastAnchoring=new K);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),n.x+=this._initialPosition.x-this.gameObject.position.x,n.y+=this._initialPosition.y-this.gameObject.position.y,n.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,n.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,n.x+=o}}applyPivot(n){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;n.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;n.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const n={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(n),n}ensureValidSize(n,e=1e-4){return n.width<=0&&(n.width=e),n.height<=0&&(n.height=1e-4),n}createNewBlock(n){n={...this.getBasicOptions(),...n},NO&&console.log(this.name,n);const e=new $I(n);return this._createdBlocks.push(e),e}createNewText(n){NO&&console.log(n),n={...this.getBasicOptions(),...n},NO&&console.log(this.name,n);const e=new tL(n);return this._createdTextBlocks.push(e),e}};let Vr=OQ;YA([E(K)],Vr.prototype,"anchoredPosition",1),YA([E(K)],Vr.prototype,"sizeDelta",2),YA([E(K)],Vr.prototype,"pivot",2),YA([E(K)],Vr.prototype,"anchorMin",2),YA([E(K)],Vr.prototype,"anchorMax",2);var Ave=Object.defineProperty,xve=Object.getOwnPropertyDescriptor,DQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?xve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Ave(e,i,r),r};const AM={backgroundColor:new Ae(1,1,1),backgroundOpacity:1,borderColor:new Ae(1,1,1),borderOpacity:1};var VO;const JA=(VO=class extends hl{constructor(){super(...arguments),p(this,"_alphaFactor",1),p(this,"sRGBColor",new Ae(1,0,1)),p(this,"raycastTarget",!0),p(this,"uiObject",null),p(this,"_color",null),p(this,"_rect",null),p(this,"_stateManager",null),p(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Li(1,1,1,1)),this._color}set color(n){(!this._color||this._color.r!==n.r||this._color.g!==n.g||this._color.b!==n.b||this._color.alpha!==n.alpha)&&(this._color||(this._color=new Li(1,1,1,1)),this._color.copy(n),this.onColorChanged())}setAlphaFactor(n){this._alphaFactor=n,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),AM.backgroundColor=this.sRGBColor,AM.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(AM,this._alphaFactor),this.uiObject.set(AM),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=ie.getComponent(this.gameObject,Vr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var n;(n=this.uiObject)==null||n.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(n){return super.__internalNewInstanceCreated(n),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(n){this.makePanel(),this.uiObject&&(this.uiObject.setState(n),this==null||this.markDirty())}setupState(n){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new fve(this.uiObject)),this.uiObject.setupState(n.state,n.attributes))}setOptions(n){this.makePanel(),this.uiObject&&this.uiObject.set(n)}awake(){super.awake(),this.makePanel(),k0(this,"_color",()=>Z0e(this,this.onColorChanged))}onEnable(){var n;super.onEnable(),this.uiObject&&((n=this.rectTransform.shadowComponent)==null||n.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const n=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:n};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(n){}onCreate(n){this.uiObject=this.rectTransform.createNewBlock(n),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(n,e=1){var i;const s=(i=this.gameObject)==null?void 0:i.getComponent(V0);s&&(s.effectDistance&&(n.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(n.borderColor=s.effectColor,n.borderOpacity=s.effectColor.alpha*e))}async setTexture(n){if(this.setOptions({backgroundOpacity:0}),n){if(JA.textureCache.has(n))n=JA.textureCache.get(n);else if(!n.isRenderTargetTexture){const e=n.clone();e.colorSpace=ki,JA.textureCache.set(n,e),n=e}this.setOptions({backgroundImage:n,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),mi.assignTextureLOD(n,0).then(e=>{e instanceof Vt&&(n&&JA.textureCache.set(n,e),this.setOptions({backgroundImage:e}),this.markDirty())})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},p(VO,"textureCache",new Map),VO);let jm=JA;DQ([E(Li)],jm.prototype,"color",1),DQ([E()],jm.prototype,"raycastTarget",2);class qA extends jm{constructor(){super(...arguments),p(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wve=Object.defineProperty,_ve=Object.getOwnPropertyDescriptor,xM=(n,e,i,s)=>{for(var r=s>1?void 0:s?_ve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&wve(e,i,r),r};let XO=class{constructor(){p(this,"texture",null),p(this,"rect")}};xM([E(Vt)],XO.prototype,"texture",2);let X0=class extends qA{constructor(){super(...arguments),p(this,"_sprite"),p(this,"pixelsPerUnitMultiplier",1)}set image(n){this.sprite||(this.sprite=new XO),this.sprite.texture=n,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(n){this._sprite!==n&&(this._sprite=n,this.onAfterCreated())}isBuiltinSprite(){var n,e,i,s,r,o,a;const l=this.sprite;switch((n=l?.texture)==null?void 0:n.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((i=(e=l?.texture)==null?void 0:e.name)!=null&&i.length)&&((r=(s=l?.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=l?.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(n){var e,i;super.onBeforeCreate(n),this.isBuiltinSprite()&&(n.borderRadius=5/this.pixelsPerUnitMultiplier,((i=(e=this.sprite)==null?void 0:e.texture)==null?void 0:i.name)==="Knob"&&(n.borderRadius=999))}onAfterCreated(){var n;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((n=this.sprite)==null?void 0:n.texture))}};xM([E(XO)],X0.prototype,"sprite",1),xM([E()],X0.prototype,"pixelsPerUnitMultiplier",2);class wM extends qA{constructor(){super(...arguments),p(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}xM([E(Vt)],wM.prototype,"mainTexture",1);var Sve=Object.defineProperty,Cve=Object.getOwnPropertyDescriptor,ma=(n,e,i,s)=>{for(var r=s>1?void 0:s?Cve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Sve(e,i,r),r};const Qm=te("debugbutton");class Vu{constructor(){p(this,"colorMultiplier"),p(this,"disabledColor"),p(this,"fadeDuration"),p(this,"highlightedColor"),p(this,"normalColor"),p(this,"pressedColor"),p(this,"selectedColor")}}ma([E()],Vu.prototype,"colorMultiplier",2),ma([E(Li)],Vu.prototype,"disabledColor",2),ma([E()],Vu.prototype,"fadeDuration",2),ma([E(Li)],Vu.prototype,"highlightedColor",2),ma([E(Li)],Vu.prototype,"normalColor",2),ma([E(Li)],Vu.prototype,"pressedColor",2),ma([E(Li)],Vu.prototype,"selectedColor",2);class Mve{constructor(){p(this,"disabledTrigger"),p(this,"highlightedTrigger"),p(this,"normalTrigger"),p(this,"pressedTrigger"),p(this,"selectedTrigger")}}class td extends Pe{constructor(){super(...arguments),p(this,"onClick",new ji),p(this,"_isHovered",0),p(this,"colors"),p(this,"transition"),p(this,"animationTriggers"),p(this,"animator"),p(this,"_interactable",!0),p(this,"_requestedAnimatorTrigger"),p(this,"_isInit",!1),p(this,"_image")}click(){var e;(e=this.onClick)==null||e.invoke()}onPointerEnter(e){var i,s;const r=e.event.pointerType==="mouse"&&e.button===0;r&&(this._isHovered+=1),Qm&&console.warn("Button Enter",r,this._isHovered,(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),r&&this.context.input.setCursorPointer())}onPointerExit(){var e,i;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),Qm&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var i,s;Qm&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var i,s;Qm&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===TS.Mouse)&&(Qm&&(console.warn("Button Click",this.onClick),gn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Qm))){const i=this.gameObject.worldPosition;i.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),ft.DrawLabel(i,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Qm&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(IA)||this.gameObject.addComponent(rM)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var i;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((i=this.animator)==null||i.setTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=ie.getComponent(this.gameObject,X0),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var i,s,r,o,a;e.setInteractable(this.interactable);const l=this.getFinalColor(e.color,(i=this.colors)==null?void 0:i.normalColor),c={state:"normal",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};e.setupState(c);const h=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),d={state:"hovered",attributes:{backgroundColor:h,backgroundOpacity:h.alpha}};e.setupState(d);const u=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),m={state:"pressed",attributes:{backgroundColor:u,backgroundOpacity:u.alpha}};e.setupState(m);const f=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.selectedColor),g={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(g);const v=this.getFinalColor(e.color,(a=this.colors)==null?void 0:a.disabledColor),y={state:"disabled",attributes:{backgroundColor:v,backgroundOpacity:v.alpha}};e.setupState(y)}getFinalColor(e,i){return i?e.clone().multiply(i).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}ma([E(ji)],td.prototype,"onClick",2),ma([E(Vu)],td.prototype,"colors",2),ma([E()],td.prototype,"transition",2),ma([E(Mve)],td.prototype,"animationTriggers",2),ma([E(sr)],td.prototype,"animator",2),ma([E()],td.prototype,"interactable",1);var Eve=Object.defineProperty,Tve=Object.getOwnPropertyDescriptor,as=(n,e,i,s)=>{for(var r=s>1?void 0:s?Tve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Eve(e,i,r),r};const GQ=te("debuguilayout");class Xu{constructor(){p(this,"left",0),p(this,"right",0),p(this,"top",0),p(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}as([E()],Xu.prototype,"left",2),as([E()],Xu.prototype,"right",2),as([E()],Xu.prototype,"top",2),as([E()],Xu.prototype,"bottom",2);class fa extends Pe{constructor(){super(...arguments),p(this,"_rectTransform",null),p(this,"_needsUpdate",!1),p(this,"childAlignment",0),p(this,"reverseArrangement",!1),p(this,"spacing",0),p(this,"padding"),p(this,"minWidth",0),p(this,"minHeight",0),p(this,"flexibleHeight",0),p(this,"flexibleWidth",0),p(this,"preferredHeight",0),p(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(GQ&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){GQ&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Vr);const e=this.gameObject.getComponentInParent(lr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(lr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}as([E()],fa.prototype,"childAlignment",2),as([E()],fa.prototype,"reverseArrangement",2),as([E()],fa.prototype,"spacing",2),as([E(Xu)],fa.prototype,"padding",2),as([E()],fa.prototype,"minWidth",2),as([E()],fa.prototype,"minHeight",2),as([E()],fa.prototype,"flexibleHeight",2),as([E()],fa.prototype,"flexibleWidth",2),as([E()],fa.prototype,"preferredHeight",2),as([E()],fa.prototype,"preferredWidth",2);class Wu extends fa{constructor(){super(...arguments),p(this,"childControlHeight",!0),p(this,"childControlWidth",!0),p(this,"childForceExpandHeight",!1),p(this,"childForceExpandWidth",!1),p(this,"childScaleHeight",!1),p(this,"childScaleWidth",!1)}onCalculateLayout(e){var i;const s=this.primaryAxis,r=e.width;let o=r;const a=e.height;let l=a;o-=this.padding.horizontal,l-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const c=s==="x",h=c?"y":"x",d=c?this.childControlWidth:this.childControlHeight,u=c?this.childControlHeight:this.childControlWidth,m=c?this.childForceExpandWidth:this.childForceExpandHeight,f=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?l:o,v=c?r:a,y=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let b=0;c?b+=this.padding.left:b+=this.padding.top;let A=0,x=0;for(let R=0;R<this.gameObject.children.length;R++){const P=this.gameObject.children[R],T=ie.getComponent(P,Vr);T!=null&&T.activeAndEnabled&&(x+=1,c?A+=T.width:A+=T.height)}let w=0;const _=this.spacing*(x-1);if(m||d){let R=0;c?R=o-=_:R=l-=_,x>0&&(w=R/x)}let S=0;S+=this.padding.left,S-=this.padding.right,y!==0&&(b=v-A,b*=y,b-=_*y,c?(b-=this.padding.right*y,b+=this.padding.left*(1-y),b<this.padding.left&&(b=this.padding.left)):(b-=this.padding.bottom*y,b+=this.padding.top*(1-y),b<this.padding.top&&(b=this.padding.top)));let C=1;for(let R=0;R<this.gameObject.children.length;R++){const P=this.gameObject.children[R],T=ie.getComponent(P,Vr);if(T!=null&&T.activeAndEnabled){(i=T.pivot)==null||i.set(.5,.5),T.anchorMin.set(0,1),T.anchorMax.set(0,1);const L=r*.5+S*.5;T.anchoredPosition.x!==L&&(T.anchoredPosition.x=L);const k=a*-.5;T.anchoredPosition.y!==k&&(T.anchoredPosition.y=k),f&&u&&T.sizeDelta[h]!==g&&(T.sizeDelta[h]=g),m&&d&&T.sizeDelta[s]!==w&&(T.sizeDelta[s]=w);const G=c?T.width:T.height,O=G*.5;if(b+=O,m){const D=w*C-w*.5;D>b&&(b=D-w*.5+G+this.padding.left,b-=O)}let W=b;s==="y"&&(W=-W),T.anchoredPosition[s]!==W&&(T.anchoredPosition[s]=W),b+=O,b+=this.spacing,C+=1}}}}as([E()],Wu.prototype,"childControlHeight",2),as([E()],Wu.prototype,"childControlWidth",2),as([E()],Wu.prototype,"childForceExpandHeight",2),as([E()],Wu.prototype,"childForceExpandWidth",2),as([E()],Wu.prototype,"childScaleHeight",2),as([E()],Wu.prototype,"childScaleWidth",2);class WO extends Wu{get primaryAxis(){return"y"}}class HO extends Wu{get primaryAxis(){return"x"}}class jO extends fa{onCalculateLayout(){}}var Rve=Object.defineProperty,Ive=Object.getOwnPropertyDescriptor,Gc=(n,e,i,s)=>{for(var r=s>1?void 0:s?Ive(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Rve(e,i,r),r},NQ=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(NQ||{});const QO=te("debuguilayout"),FQ=class extends RA{constructor(){super(...arguments),p(this,"_renderOnTop"),p(this,"_depthWrite",!1),p(this,"_doubleSided",!0),p(this,"_castShadows",!1),p(this,"_receiveShadows",!1),p(this,"_renderMode",-1),p(this,"_rootCanvas"),p(this,"_scaleFactor",1),p(this,"worldCamera"),p(this,"planeDistance",-1),p(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),p(this,"previousParent",null),p(this,"_lastMatrixWorld",null),p(this,"_rectTransforms",[]),p(this,"_layoutGroups",new Map),p(this,"_receivers",[]),p(this,"onBeforeRenderRoutine",()=>{var n,e,i,s;if(this.previousParent=this.gameObject.parent,((n=this.context.xr)!=null&&n.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Ka.ensureUpdateMeshUI(_5,this.context))}),p(this,"onAfterRenderRoutine",()=>{var n,e,i,s,r;if(((n=this.context.xr)!=null&&n.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const l=this.context.mainCamera;l?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,a=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(s=this.shadowComponent)==null||s.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Ka.ensureUpdateMeshUI(_5,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=a,this.previousParent.add(this.gameObject)}(r=this._lastMatrixWorld)==null||r.copy(this.gameObject.matrixWorld)}),p(this,"_updateRenderSettingsRoutine"),p(this,"_activeRenderMode",-1),p(this,"_lastWidth",-1),p(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(n){n!==this._renderOnTop&&(this._renderOnTop=n,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(n){this._depthWrite!==n&&(this._depthWrite=n,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(n){this._doubleSided!==n&&(this._doubleSided=n,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(n){this._castShadows!==n&&(this._castShadows=n,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(n){this._receiveShadows!==n&&(this._receiveShadows=n,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(n){this._renderMode!==n&&(this._renderMode=n,this.onRenderSettingsChanged())}set rootCanvas(n){this._rootCanvas instanceof FQ||(this._rootCanvas=n)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(n){this._scaleFactor=n}awake(){var n;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,QO&&console.log("Canvas.Awake()",((n=this.previousParent)==null?void 0:n.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new he,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const n=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);n!==-1&&this.context.pre_render_callbacks.splice(n,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(n){this._rectTransforms.push(n)}unregisterTransform(n){const e=this._rectTransforms.indexOf(n);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(n){const e=n.gameObject;this._layoutGroups.set(e,n)}unregisterLayoutGroup(n){const e=n.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(n){this._receivers.push(n)}unregisterEventReceiver(n){const e=this._receivers.indexOf(n);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(n){this.screenspace?(n.xr.isVR||n.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await u_(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(n){this.screenspace&&(n.xr.isVR||n.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var n;for(const e of this._receivers)(n=e.onBeforeCanvasRender)==null||n.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new he);const n=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);QO&&n&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const i of this._rectTransforms){n&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(fa)),(i.isDirty||s!=null&&s.isDirty)&&(QO&&!e&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ji.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),aM(this.shadowComponent,this);for(const n of ie.getComponentsInChildren(this.gameObject,hl))aM(n.shadowComponent,this)}}onUpdateRenderMode(n=!1){if(!n&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,i=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(i=et.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Vr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=e.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let lr=FQ;Gc([E()],lr.prototype,"renderOnTop",1),Gc([E()],lr.prototype,"depthWrite",1),Gc([E()],lr.prototype,"doubleSided",1),Gc([E()],lr.prototype,"castShadows",1),Gc([E()],lr.prototype,"receiveShadows",1),Gc([E()],lr.prototype,"renderMode",1),Gc([E(lr)],lr.prototype,"rootCanvas",1),Gc([E()],lr.prototype,"scaleFactor",1),Gc([E(Fi)],lr.prototype,"worldCamera",2),Gc([E()],lr.prototype,"planeDistance",2);var Lve=Object.defineProperty,Pve=Object.getOwnPropertyDescriptor,ZO=(n,e,i,s)=>{for(var r=s>1?void 0:s?Pve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Lve(e,i,r),r};class Hu extends Pe{constructor(){super(...arguments),p(this,"_alpha",1),p(this,"interactable",!0),p(this,"blocksRaycasts",!0),p(this,"_isDirty",!1),p(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ji.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of ie.getComponentsInChildren(this.gameObject,hl,this._buffer)){const i=e;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}ZO([E()],Hu.prototype,"alpha",1),ZO([E()],Hu.prototype,"interactable",2),ZO([E()],Hu.prototype,"blocksRaycasts",2);var kve=Object.defineProperty,Bve=Object.getOwnPropertyDescriptor,Mn=(n,e,i,s)=>{for(var r=s>1?void 0:s?Bve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&kve(e,i,r),r};const zQ=te("debugusdzbehaviours");function $A(n){n&&(n.getComponentInParent(IA)||(je()&&console.debug('Raycaster on "'+n.name+'" was automatically added, because no raycaster was found in the parent hierarchy.'),n.addComponent(ca)))}class Zm extends Pe{constructor(){super(...arguments),p(this,"object"),p(this,"target"),p(this,"duration",1),p(this,"relativeMotion",!1),p(this,"coroutine",null),p(this,"targetPos",new M),p(this,"targetRot",new Se),p(this,"targetScale",new M)}start(){$A(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Nt(this.object).clone(),i=Nt(this.target).clone(),s=Bi(this.object).clone(),r=Bi(this.target).clone(),o=Yi(this.object).clone(),a=Yi(this.target).clone(),l=e.distanceTo(i),c=s.angleTo(r),h=o.distanceTo(a);if(l<.01&&c<.01&&h<.01){bs(this.object,i),Ba(this.object,r),wg(this.object,a),this.coroutine=null;return}let d=0,u=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),u=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(e,i,u),this.targetRot.slerpQuaternions(s,r,u),this.targetScale.lerpVectors(o,a,u),bs(this.object,this.targetPos),Ba(this.object,this.targetRot),wg(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(s,this.targetScale,c),yield;this.coroutine=null}beforeCreateDocument(e){var i;if(this.target&&this.object&&this.gameObject){const s=new Gs("Move to "+((i=this.target)==null?void 0:i.name),Ns.tapTrigger(this.gameObject),vi.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));e.addBehavior(s)}}}Mn([E(ge)],Zm.prototype,"object",2),Mn([E(ge)],Zm.prototype,"target",2),Mn([E()],Zm.prototype,"duration",2),Mn([E()],Zm.prototype,"relativeMotion",2);var _M;const Nc=(_M=class extends Pe{constructor(){super(...arguments),p(this,"materialToSwitch"),p(this,"variantMaterial"),p(this,"fadeDuration",0),p(this,"_objectsWithThisMaterial",null),p(this,"selfModel"),p(this,"targetModels")}start(){var n;this._objectsWithThisMaterial=this.objectsWithThisMaterial,$A(this.gameObject),je()&&this._objectsWithThisMaterial.length<=0&&console.warn('ChangeMaterialOnClick: No objects found with material "'+((n=this.materialToSwitch)==null?void 0:n.name)+'"')}onPointerEnter(n){this.context.input.setCursorPointer()}onPointerExit(n){this.context.input.setCursorNormal()}onPointerClick(n){if(n.use(),!!this.variantMaterial)for(let e=0;e<this.objectsWithThisMaterial.length;e++){const i=this.objectsWithThisMaterial[e];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(n=>{if(n instanceof ue)if(Array.isArray(n.material)){for(const e of n.material)if(e===this.materialToSwitch){this.objectsWithThisMaterial.push(n);break}}else n.material===this.materialToSwitch?this.objectsWithThisMaterial.push(n):z4(n.material,this.materialToSwitch)&&this.objectsWithThisMaterial.push(n)}),this._objectsWithThisMaterial)}async beforeCreateDocument(n,e){this.targetModels=[],Nc._materialTriggersPerId={},Nc.variantSwitchIndex=0,this.materialToSwitch&&await mi.assignTextureLOD(this.materialToSwitch,0),this.variantMaterial&&await mi.assignTextureLOD(this.variantMaterial,0)}createBehaviours(n,e,i){this.objectsWithThisMaterial.find(s=>s.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Nc._materialTriggersPerId[this.materialToSwitch.uuid]||(Nc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Nc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(n,e){if(!this.materialToSwitch)return;const i=Nc._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(s[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in s)a!==r.selfModel.uuid&&o.push(...s[a]);r.createAndAttachBehaviors(n,s[r.selfModel.uuid],o)}}delete Nc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(n,e,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);r.push(vi.fadeAction([...this.targetModels,...i],o,!1)),s.push(vi.fadeAction(e,o,!1)),r.push(vi.fadeAction(e,o,!0)),n.addBehavior(new Gs("Select_"+this.selfModel.name,Ns.tapTrigger(this.selfModel),vi.parallel(...r))),n.addBehavior(new Gs("StartHidden_"+this.selfModel.name,Ns.sceneStartTrigger(),vi.parallel(...s)))}static getMaterialName(n){return Ul(n.name||"Material")+"_"+n.id}createVariants(){if(!this.variantMaterial)return null;const n=[];for(const e of this.targetModels){const i=e.clone();i.name+="_Variant_"+Nc.variantSwitchIndex+++"_"+Nc.getMaterialName(this.variantMaterial),i.displayName=i.displayName+": Variant with material "+this.variantMaterial.name,i.material=this.variantMaterial,i.geometry=e.geometry,i.transform=e.transform,(!e.parent||!e.parent.isEmpty())&&ho.createEmptyParent(e),e.parent&&e.parent.add(i),n.push(i)}return n}},p(_M,"_materialTriggersPerId",{}),p(_M,"variantSwitchIndex",0),_M);let W0=Nc;Mn([E(Ft)],W0.prototype,"materialToSwitch",2),Mn([E(Ft)],W0.prototype,"variantMaterial",2),Mn([E()],W0.prototype,"fadeDuration",2);var H0;const En=(H0=class extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"toggleOnClick",!1),p(this,"targetState",!0),p(this,"hideSelf",!0),p(this,"selfModel"),p(this,"selfModelClone"),p(this,"targetModel"),p(this,"toggleModel"),p(this,"stateBeforeCreatingDocument",!1),p(this,"targetStateBeforeCreatingDocument",!1)}start(){$A(this.gameObject)}onPointerClick(n){n.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(n,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[En.wasVisible]===void 0&&(this.gameObject[En.wasVisible]=this.gameObject.activeSelf),this.target[En.wasVisible]===void 0&&(this.target[En.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[En.wasVisible],this.targetStateBeforeCreatingDocument=this.target[En.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(n,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let s=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&XB.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[En.toggleClone]){const l=this.selfModelClone.clone();l.setMatrix(new he),l.name+="_toggle"+En.clonedToggleIndex++,i.add(l),this.gameObject[En.toggleClone]=l,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[En.toggleClone];if(!this.gameObject[En.reverseToggleClone]){const l=this.selfModelClone.clone();l.setMatrix(new he),l.name+="_toggleReverse"+En.clonedToggleIndex++,i.add(l),this.gameObject[En.reverseToggleClone]=l}this.toggleModel=this.gameObject[En.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),s=a,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(vi.fadeAction(s,0,!1)),a.push(vi.fadeAction(this.toggleModel,0,!0)),a.push(vi.fadeAction(this.targetModel,0,r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Ns.tapTrigger(s),vi.parallel(...a)));const l=[];l.push(vi.fadeAction(this.toggleModel,0,!1)),l.push(vi.fadeAction(s,0,!0)),l.push(vi.fadeAction(this.targetModel,0,!r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"Off":"On"),Ns.tapTrigger(this.toggleModel),vi.parallel(...l)))}}else{const a=[];this.hideSelf&&a.push(vi.fadeAction(s,0,!1)),a.push(vi.fadeAction(this.targetModel,0,r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Ns.tapTrigger(s),vi.parallel(...a)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(i),this.toggleModel&&o.push(this.toggleModel),n.addBehavior(new Gs("HideOnStart_"+this.gameObject.name,Ns.sceneStartTrigger(),vi.fadeAction(o,0,!1)))}}afterSerialize(n,e){this.gameObject[En.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[En.wasVisible],delete this.gameObject[En.wasVisible]),this.target&&this.target[En.wasVisible]!==void 0&&(this.target.visible=this.target[En.wasVisible],delete this.target[En.wasVisible]),delete this.gameObject[En.toggleClone],delete this.gameObject[En.reverseToggleClone]}},p(H0,"clonedToggleIndex",0),p(H0,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),p(H0,"toggleClone",Symbol("clone for toggling")),p(H0,"reverseToggleClone",Symbol("clone for reverse toggling")),H0);let Ym=En;Mn([E(ge)],Ym.prototype,"target",2),Mn([E()],Ym.prototype,"toggleOnClick",2),Mn([E()],Ym.prototype,"targetState",2),Mn([E()],Ym.prototype,"hideSelf",2);class YO extends Pe{constructor(){super(...arguments),p(this,"wasVisible",!1)}start(){ie.setActive(this.gameObject,!1)}createBehaviours(e,i,s){i.uuid===this.gameObject.uuid&&(this.wasVisible||e.addBehavior(new Gs("HideOnStart_"+this.gameObject.name,Ns.sceneStartTrigger(),vi.fadeAction(i,0,!1))))}beforeCreateDocument(){this.wasVisible=ie.isActiveSelf(this.gameObject)}}class j0 extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"duration",.5),p(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(e,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new Gs("emphasize "+this.name,Ns.tapTrigger(this.gameObject),vi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,i){}}Mn([E()],j0.prototype,"target",2),Mn([E()],j0.prototype,"duration",2),Mn([E()],j0.prototype,"motionType",2);class ju extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"clip",""),p(this,"toggleOnClick",!1),p(this,"trigger","tap")}start(){$A(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addComponent(Cn);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1,e.preload=!0)}}onPointerClick(e){var i;e.use(),!(!((i=this.target)!=null&&i.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject;vp.getName(r);const a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let c=!1;this.gameObject.traverse(m=>{m instanceof ue&&m.visible&&(c=!0)}),c=!0;const h=e.addAudioClip(r);let d=vi.playAudioAction(o,h,"play",a,l);this.target&&this.target.loop&&(d=vi.sequence(d).makeLooping());const u=this.name?"_"+this.name:"";if(c&&this.trigger==="tap"){this.toggleOnClick&&(d.multiplePerformOperation="stop");const m=new Gs("playAudio"+u,Ns.tapTrigger(i),d);e.addBehavior(m)}if(this.target&&this.target.playOnAwake&&this.target.enabled)if(c&&this.trigger==="tap")console.warn("USDZExport: Audio sources that are played on tap can't also auto-play at scene start due to a QuickLook bug.");else{const m=new Gs("playAudioOnStart"+u,Ns.sceneStartTrigger(),d);e.addBehavior(m)}}}}Mn([E(Cn)],ju.prototype,"target",2),Mn([E(URL)],ju.prototype,"clip",2),Mn([E()],ju.prototype,"toggleOnClick",2);var SM;const Fc=(SM=class extends Pe{constructor(){super(...arguments),p(this,"animator"),p(this,"stateName"),p(this,"trigger","tap"),p(this,"animation"),p(this,"selfModel"),p(this,"stateAnimationModel"),p(this,"animationSequence",new Array),p(this,"animationLoopAfterSequence",new Array),p(this,"randomOffsetNormalized",0)}get target(){var n,e;return((n=this.animator)==null?void 0:n.gameObject)||((e=this.animation)==null?void 0:e.gameObject)}start(){$A(this.gameObject)}onPointerClick(n){var e;n.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(n,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Fc.rootsWithExclusivePlayback.size>1){const n='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';je()&&Oi(n),console.warn(n,...Fc.rootsWithExclusivePlayback)}Fc.animationActions=[],Fc.rootsWithExclusivePlayback=new Set}afterCreateDocument(n,e){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=e.document,s=e.extensions.find(a=>a instanceof SA);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(je()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Fc.rootsWithExclusivePlayback.add(this.target));const o=this.name?this.name:"";i.traverse(a=>{var l,c;if(a.uuid===((l=this.target)==null?void 0:l.uuid)){const h=Fc.getActionForSequences(i,a,this.animationSequence,this.animationLoopAfterSequence,this.randomOffsetNormalized),d=new Gs(this.trigger+"_"+o+"_toPlayAnimation_"+this.stateName+"_on_"+((c=this.target)==null?void 0:c.name),this.trigger=="tap"?Ns.tapTrigger(this.selfModel):Ns.sceneStartTrigger(),h);r&&d.makeExclusive(!0),n.addBehavior(d)}})}static getActionForSequences(n,e,i,s,r){const o=(l,c)=>{let h=Fc.animationActions.find(d=>d.affectedObjects==l&&d.start==c.start&&d.duration==c.duration&&d.animationSpeed==c.speed);return h||(h=vi.startAnimationAction(l,c),Fc.animationActions.push(h)),h},a=vi.sequence();if(i&&i.length>0)for(const l of i)a.addAction(o(e,l));if(s&&s.length>0){const l=a.actions.length==0?a:vi.sequence();for(const c of s)l.addAction(o(e,c));l.makeLooping(),a!==l&&a.addAction(l)}return r&&r>0&&a.actions.unshift(vi.waitAction(r)),a}static getAndRegisterAnimationSequences(n,e,i){var s,r,o,a,l,c,h,d;if(!e)return;const u=e.getComponent(sr),m=e.getComponent(zr);if(!u&&!m)return;if(u&&!i)throw new Error("PlayAnimationOnClick: No stateName specified for animator "+u.name+" on "+e.name);let f=[],g=[];if(m){const _=n.registerAnimation(e,m.clip);_&&(m.loop?g.push(_):f.push(_));let S=0;if(m.minMaxOffsetNormalized){const C=m.minMaxOffsetNormalized.x,R=m.minMaxOffsetNormalized.y;S=(((s=m.clip)==null?void 0:s.duration)||1)*(C+Math.random()*(R-C))}return{animationSequence:f,animationLoopAfterSequence:g,randomTimeOffset:S}}const v=u?.runtimeAnimatorController;let y=v?.findState(i),b=[],A=[];if(v&&y){const _=new Array;_.push(y);let S=!1;for(;_.length<100;){if(!y||y===null||!y.transitions||y.transitions.length===0){(r=y.motion)!=null&&r.isLooping&&(S=!0);break}const C=y.transitions.find(P=>P.conditions.length===0),R=C?v.getState(C.destinationState,0):null;if(R&&_.includes(R)){y=R,S=!0;break}else if(C){if(y=R,!y)break;_.push(y)}else{S=((o=y.motion)==null?void 0:o.isLooping)??!1;break}}if(S&&y){const C=_.indexOf(y);b=_.slice(0,C),A=_.slice(C),zQ&&console.log("found loop from "+i,"states until loop",b,"states looping",A)}else b=_,A=[],zQ&&console.log("found no loop from "+i,"states",b);if(!A.length){const C=b[b.length-1],R=(a=C.motion)==null?void 0:a.clip;if(R){let P;if(n.holdClipMap.has(R))P=n.holdClipMap.get(R);else{const T=C.name+"_hold";P=R.clone(),P.duration=1,P.name=T;const L=R.duration;P.tracks=R.tracks.map(k=>{const G=k.clone();G.times=new Float32Array([0,L]);const O=k.values.length,W=k.getValueSize(),D=k.values.slice(O-W,O);return G.values=new Float32Array(2*W),G.values.set(D,0),G.values.set(D,W),G}),P.name=T,n.holdClipMap.set(R,P)}if(P){const T={name:P.name,motion:{clip:P,isLooping:!1,name:P.name},speed:1,transitions:[],behaviours:[],hash:C.hash+1};A.push(T)}}}}if(b.length===1&&(!((l=b[0].motion)!=null&&l.clip)||((h=(c=b[0].motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)===0)){f=new Array;const _=n.registerAnimation(e,null);_&&f.push(_);return}if(b=b.filter(_=>{var S,C,R;return((S=_.motion)==null?void 0:S.clip)&&((R=(C=_.motion)==null?void 0:C.clip.tracks)==null?void 0:R.length)>0}),A=A.filter(_=>{var S,C,R;return((S=_.motion)==null?void 0:S.clip)&&((R=(C=_.motion)==null?void 0:C.clip.tracks)==null?void 0:R.length)>0}),b.length===0&&A.length===0){console.warn("No clips found for state "+i+" on "+u?.name+", can't export animation data");return}const x=(_,S)=>{if(!e)return;const C=n.registerAnimation(e,_.motion.clip??null);C?(C.speed=_.speed,S.push(C)):console.warn("Couldn't register animation for state "+_.name+" on "+u?.name)};if(b.length>0){f=new Array;for(const _ of b)x(_,f)}if(A.length>0){g=new Array;for(const _ of A)x(_,g)}let w=0;if(u&&v&&u.minMaxOffsetNormalized){const _=u.minMaxOffsetNormalized.x,S=u.minMaxOffsetNormalized.y,C=b.length?b[0]:A.length?A[0]:null;w=(((d=C?.motion.clip)==null?void 0:d.duration)||1)*(_+Math.random()*(S-_))}return{animationSequence:f,animationLoopAfterSequence:g,randomTimeOffset:w}}createAnimation(n,e,i){if(!this.target||!this.animator&&!this.animation)return;const s=Fc.getAndRegisterAnimationSequences(n,this.target,this.stateName);s&&(this.animationSequence=s.animationSequence,this.animationLoopAfterSequence=s.animationLoopAfterSequence,this.randomOffsetNormalized=s.randomTimeOffset,this.stateAnimationModel=e)}},p(SM,"animationActions",[]),p(SM,"rootsWithExclusivePlayback",new Set),SM);let Km=Fc;Mn([E(sr)],Km.prototype,"animator",2),Mn([E()],Km.prototype,"stateName",2);class Q0 extends Pe{constructor(){super(...arguments),p(this,"target")}getType(){}getDuration(){}}Mn([E(ge)],Q0.prototype,"target",2);class ex extends Pe{constructor(){super(...arguments),p(this,"target")}}Mn([E(Q0)],ex.prototype,"target",2);class tx extends Q0{constructor(){super(...arguments),p(this,"type",1),p(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Mn([E()],tx.prototype,"type",2),Mn([E()],tx.prototype,"duration",2);class KO extends ex{}var Ove=Object.defineProperty,Dve=Object.getOwnPropertyDescriptor,id=(n,e,i,s)=>{for(var r=s>1?void 0:s?Dve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Ove(e,i,r),r};const UQ=te("debugcharactercontroller");class Jm extends Pe{constructor(){super(...arguments),p(this,"center",new M(0,0,0)),p(this,"radius",.5),p(this,"height",2),p(this,"_rigidbody",null),p(this,"_activeGroundCollisions"),p(this,"_contactVelocity",new M)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ci),this._rigidbody||(this._rigidbody=this.gameObject.addComponent(Ci)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let i=this.gameObject.getComponent(ed);i||(i=this.gameObject.addComponent(ed)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new M(0,0,1),r=new M(1,0,0),o=new M(0,1,0),a=this.gameObject.getWorldDirection(new M);a.y=0;const l=r.dot(a)<0?-1:1,c=s.angleTo(a)*l;this.gameObject.setRotationFromAxisAngle(o,c),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(e),UQ&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),UQ&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const s=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(i.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}id([E(M)],Jm.prototype,"center",2),id([E()],Jm.prototype,"radius",2),id([E()],Jm.prototype,"height",2);class nd extends Pe{constructor(){super(...arguments),p(this,"controller"),p(this,"movementSpeed",2),p(this,"rotationSpeed",2),p(this,"jumpForce",1),p(this,"doubleJumpForce",2),p(this,"animator"),p(this,"lookForward",!0),p(this,"lookInput",new K(0,0)),p(this,"moveInput",new K(0,0)),p(this,"jumpInput",!1),p(this,"_currentSpeed",new M(0,0,0)),p(this,"_currentAngularSpeed",new M(0,0,0)),p(this,"_temp",new M(0,0,0)),p(this,"_jumpCount",0),p(this,"_currentRotation"),p(this,"_raycastOptions",new Ac)}awake(){this._currentRotation=new Se}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,i,s){var r,o,a,l,c,h,d,u,m,f,g;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",e.length()>.01),(c=this.animator)==null||c.setBool("jumping",((l=this.controller)==null?void 0:l.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=et.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new M(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(u=this.animator)==null||u.setBool("doubleJump",!0)),v){this._jumpCount+=1;const y=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;y.applyImpulse(new M(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(m=this.controller)==null?void 0:m.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qr),this._raycastOptions.ray.origin.copy(Nt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const y=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(y),(b.length&&b[0].distance>2||v<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(g=this.animator)==null||g.setBool("falling",!1)}}}id([E(Jm)],nd.prototype,"controller",2),id([E()],nd.prototype,"movementSpeed",2),id([E()],nd.prototype,"rotationSpeed",2),id([E()],nd.prototype,"jumpForce",2),id([E()],nd.prototype,"doubleJumpForce",2),id([E(sr)],nd.prototype,"animator",2);var Gve=Object.defineProperty,Nve=Object.getOwnPropertyDescriptor,Fve=(n,e,i,s)=>{for(var r=s>1?void 0:s?Nve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Gve(e,i,r),r};class ix extends Us{constructor(){super(...arguments),p(this,"intensity",new qe(0))}get typeName(){return"ChromaticAberration"}onCreateEffect(){const e=new eV;return e.offset=new K(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{e.offset.x=-i,e.offset.y=i},e}}Fve([E(qe)],ix.prototype,"intensity",2),Ja("ChromaticAberration",ix);var zve=Object.defineProperty,Uve=Object.getOwnPropertyDescriptor,VQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?Uve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&zve(e,i,r),r};const XQ=te("debugpost");var CM=(n=>(n[n.None=0]="None",n[n.Neutral=1]="Neutral",n[n.ACES=2]="ACES",n[n.AgX=3]="AgX",n[n.KhronosNeutral=4]="KhronosNeutral",n))(CM||{});function JO(n){switch(n){case 0:return Pf;case 1:return tv;case 2:return iv;case 3:return kf;case 4:return Cp;default:return Cp}}function Vve(n){switch(n){case Pf:return 0;case iv:return 2;case kf:return 3;case Cp:return 1;case tv:return 1;default:return 0}}function WQ(n){switch(n){case Pf:return As.LINEAR;case iv:return As.ACES_FILMIC;case kf:return As.AGX;case Cp:return As.NEUTRAL;case tv:return As.REINHARD;default:return As.LINEAR}}const HQ=class extends Us{constructor(){super(...arguments),p(this,"mode",new qe(void 0)),p(this,"exposure",new qe(1))}get typeName(){return"ToneMapping"}setMode(n){const e=CM[n];return e===void 0?(console.error("Invalid ToneMapping mode",n),this):(this.mode.value=e,this)}get isToneMapping(){return!0}onEffectEnabled(){const n=gQ(this);n&&super.onEffectEnabled(n)}onCreateEffect(){if(this.postprocessingContext)for(const i of this.postprocessingContext.components){if(i===this)break;if(i!=this&&i instanceof HQ){console.warn("Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.",{activeEffect:i,ignoredEffect:this});return}}if(this.mode.isInitialized==!1){const i=Vve(this.context.renderer.toneMapping);this.mode.initialize(i)}const n=JO(this.mode.value),e=new F_({mode:WQ(n)});return this.mode.onValueChanged=i=>{const s=JO(i);e.mode=WQ(s),XQ&&console.log("ToneMapping mode changed to",CM[i],s,e.mode)},XQ&&console.log("Use ToneMapping",CM[this.mode.value],n,e.mode,"renderer.tonemapping: "+this.context.renderer.toneMapping),this.exposure.onValueChanged=i=>{this.context.renderer.toneMappingExposure=i},e}onBeforeRender(){this.mode.overrideState&&(this.context.renderer.toneMapping=JO(this.mode.value)),this.exposure.overrideState&&(this.context.renderer.toneMappingExposure=this.exposure.value)}};let Qu=HQ;VQ([E(qe)],Qu.prototype,"mode",2),VQ([E(qe)],Qu.prototype,"exposure",2),Ja("Tonemapping",Qu);var Xve=Object.defineProperty,Wve=Object.getOwnPropertyDescriptor,MM=(n,e,i,s)=>{for(var r=s>1?void 0:s?Wve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Xve(e,i,r),r};class Zu extends Us{constructor(){super(...arguments),p(this,"postExposure",new qe(0)),p(this,"contrast",new qe(0)),p(this,"hueShift",new qe(0)),p(this,"saturation",new qe(0))}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.contrast.valueProcessor=e=>{let i=1;return e>0?i=200:e<0&&(i=100),e/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}onCreateEffect(){var e,i;const s=[];this.context.renderer.toneMapping!==Yr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Yr);let r=(e=this.postprocessingContext)==null?void 0:e.components.find(l=>l instanceof Qu);r||(r=new Qu,(i=this.postprocessingContext)==null||i.components.push(r)),this.postExposure.onValueChanged=l=>{this.postExposure.overrideState&&(r.exposure.value=l)};const o=new $5;this.contrast.onValueChanged=l=>o.contrast=l;const a=new sV;return s.push(o),s.push(a),this.hueShift.onValueChanged=l=>a.hue=l,this.saturation.onValueChanged=l=>a.saturation=l,s}}MM([E(qe)],Zu.prototype,"postExposure",2),MM([E(qe)],Zu.prototype,"contrast",2),MM([E(qe)],Zu.prototype,"hueShift",2),MM([E(qe)],Zu.prototype,"saturation",2),Ja("ColorAdjustments",Zu);const jQ=Math.sqrt(5),Hve=(jQ-1)/4,cr=(5-jQ)/20,EM=n=>Math.floor(n)|0,TM=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function jve(n=Math.random){const e=Qve(n),i=new Float64Array(e).map(a=>TM[a%32*4]),s=new Float64Array(e).map(a=>TM[a%32*4+1]),r=new Float64Array(e).map(a=>TM[a%32*4+2]),o=new Float64Array(e).map(a=>TM[a%32*4+3]);return function(a,l,c,h){let d,u,m,f,g;const v=(a+l+c+h)*Hve,y=EM(a+v),b=EM(l+v),A=EM(c+v),x=EM(h+v),w=(y+b+A+x)*cr,_=y-w,S=b-w,C=A-w,R=x-w,P=a-_,T=l-S,L=c-C,k=h-R;let G=0,O=0,W=0,D=0;P>T?G++:O++,P>L?G++:W++,P>k?G++:D++,T>L?O++:W++,T>k?O++:D++,L>k?W++:D++;const F=G>=3?1:0,U=O>=3?1:0,Y=W>=3?1:0,q=D>=3?1:0,oe=G>=2?1:0,xe=O>=2?1:0,Be=W>=2?1:0,re=D>=2?1:0,_e=G>=1?1:0,Ie=O>=1?1:0,We=W>=1?1:0,Ze=D>=1?1:0,Ge=P-F+cr,rt=T-U+cr,ye=L-Y+cr,Q=k-q+cr,ze=P-oe+2*cr,Te=T-xe+2*cr,Ee=L-Be+2*cr,He=k-re+2*cr,be=P-_e+3*cr,nt=T-Ie+3*cr,ct=L-We+3*cr,It=k-Ze+3*cr,H=P-1+4*cr,N=T-1+4*cr,de=L-1+4*cr,Me=k-1+4*cr,Oe=y&255,Le=b&255,xt=A&255,dt=x&255;let Ue=.6-P*P-T*T-L*L-k*k;if(Ue<0)d=0;else{const De=Oe+e[Le+e[xt+e[dt]]];Ue*=Ue,d=Ue*Ue*(i[De]*P+s[De]*T+r[De]*L+o[De]*k)}let Xe=.6-Ge*Ge-rt*rt-ye*ye-Q*Q;if(Xe<0)u=0;else{const De=Oe+F+e[Le+U+e[xt+Y+e[dt+q]]];Xe*=Xe,u=Xe*Xe*(i[De]*Ge+s[De]*rt+r[De]*ye+o[De]*Q)}let Ct=.6-ze*ze-Te*Te-Ee*Ee-He*He;if(Ct<0)m=0;else{const De=Oe+oe+e[Le+xe+e[xt+Be+e[dt+re]]];Ct*=Ct,m=Ct*Ct*(i[De]*ze+s[De]*Te+r[De]*Ee+o[De]*He)}let Ne=.6-be*be-nt*nt-ct*ct-It*It;if(Ne<0)f=0;else{const De=Oe+_e+e[Le+Ie+e[xt+We+e[dt+Ze]]];Ne*=Ne,f=Ne*Ne*(i[De]*be+s[De]*nt+r[De]*ct+o[De]*It)}let qt=.6-H*H-N*N-de*de-Me*Me;if(qt<0)g=0;else{const De=Oe+1+e[Le+1+e[xt+1+e[dt+1]]];qt*=qt,g=qt*qt*(i[De]*H+s[De]*N+r[De]*de+o[De]*Me)}return 27*(d+u+m+f+g)}}function Qve(n){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=e[i];e[i]=e[s],e[s]=r}for(let i=256;i<512;i++)e[i]=e[i-256];return e}const qO=te("debugstencil");function Zve(n,e){return(n&1<<e.layer)!=0}const Yve=Symbol("stencils"),Z0=class{constructor(n,e){p(this,"parser"),p(this,"source"),this.parser=n,this.source=e}get name(){return"NEEDLE_render_objects"}static applyStencil(n){if(!n)return;const e=n.sourceId;if(qO&&console.log(e,Z0.stencils),!e)return;const i=Z0.stencils[e];if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];if(Zve(r.layer,n)){qO&&console.log(r),setTimeout(()=>{io()&&pC(n.gameObject)&&(Oi("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",n))},500);for(let o=0;o<n.sharedMaterials.length;o++){let a=n.sharedMaterials[o];a&&(a=a.clone(),a[Yve]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=r.value,a.stencilFunc=r.compareFunc,a.stencilZPass=r.passOp,a.stencilFail=r.failOp,a.stencilZFail=r.zFailOp,n.sharedMaterials[o]=a)}n.gameObject.renderOrder=r.event*1e3+r.index*50;break}}}afterRoot(n){const e=this.parser.json.extensions;if(e){const i=e[Jve];if(i){qO&&console.log(i);const s=i.stencil;if(s&&Array.isArray(s))for(const r of s){const o={...r};o.compareFunc=Kve(o.compareFunc),o.passOp=eD(o.passOp),o.failOp=eD(o.failOp),o.zFailOp=eD(o.zFailOp),Z0.stencils[this.source]||(Z0.stencils[this.source]=[]),Z0.stencils[this.source].push(o)}}}return null}};let $O=Z0;p($O,"stencils",{});function eD(n){switch(n){case 0:return kd;case 1:return pN;case 2:return mN;case 3:return fN;case 4:return gN;case 6:return yN;case 7:return vN;case 5:return bN}return 0}function Kve(n){switch(n){case 1:return GR;case 2:return AN;case 3:return xN;case 4:return wN;case 5:return _N;case 6:return SN;case 7:return CN;case 8:return Y1}return GR}const Jve="NEEDLE_render_objects";var qve=Object.defineProperty,$ve=Object.getOwnPropertyDescriptor,QQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?$ve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&qve(e,i,r),r};const RM=te("debugreflectionprobe"),ZQ=te("noreflectionprobe"),ebe=Symbol("reflectionProbeKey"),tbe=Symbol("original material");var IM;const sd=(IM=class extends Pe{constructor(){var n;super(),p(this,"_texture"),p(this,"center"),p(this,"size"),p(this,"_boxHelper"),sd._probes.has(this.context)||sd._probes.set(this.context,[]),(n=sd._probes.get(this.context))==null||n.push(this)}static get(n,e,i,s){if(!n||n.isObject3D!==!0||ZQ)return null;const r=sd._probes.get(e);if(r){for(const o of r)if(o.__didAwake||o.__internalAwake(),o.enabled&&s&&o.gameObject===s)return o}return RM&&console.debug("Did not find reflection probe",n.name,i,n),null}set texture(n){if(n&&!(n instanceof Vt)){console.error("ReflectionProbe.texture must be a Texture",n);return}this._texture=n,n&&(n.mapping=Kr,n.colorSpace=vt,n.needsUpdate=!0)}get texture(){return this._texture}isInBox(n){var e;return(e=this._boxHelper)==null?void 0:e.isInBox(n)}awake(){this._boxHelper=this.gameObject.addComponent(qa),this._boxHelper.updateBox(!0),RM&&this._boxHelper.showHelper(5592320,!0),this.texture&&(this.texture.mapping=Kr,this.texture.colorSpace=vt,this.texture.needsUpdate=!0)}onDestroy(){const n=sd._probes.get(this.context);if(n){const e=n.indexOf(this);e>=0&&n.splice(e,1)}}onSet(n){var e;if(ZQ||!this.enabled||((e=n.sharedMaterials)==null?void 0:e.length)<=0||!this.texture)return;let i=sd._rendererMaterialsCache.get(n);i||(i=[],sd._rendererMaterialsCache.set(n,i));for(let s=0;s<n.sharedMaterials.length;s++){const r=n.sharedMaterials[s];if(!r||r.envMap===void 0||r instanceof Ht)continue;let o=i[s];const a=r===o?.copy,l=!o||o.material.uuid!==r.uuid||o.copy.version!==r.version;if(!a&&l){if(RM){let d="";o?o.material!==r?d="reference changed; cached instance?: "+a:o.copy.version!==r.version&&(d="version changed"):d="not cached",console.warn("Cloning material",r.name,r.version,"Reason:",d,`
|
|
5979
|
+
`)}a&&console.log(u);const g=new Set;for(const b of f){b.getPath||console.error("USDZExporter: Animation target object has no getPath method. This is likely a bug",b);let A=b.getPath();A.startsWith("<")&&(A=A.substring(1)),A.endsWith(">")&&(A=A.substring(0,A.length-1)),g.add({path:A,obj:b})}const v=Array.from(g).sort((b,A)=>b.path.length-A.path.length),y=new Array;for(let b=0;b<v.length;b++)for(let A=b+1;A<v.length;A++)if(v[A].path.startsWith(v[b].path)){const x=v[A],w=v[b];y.push({child:x.obj.displayName+" ("+x.path+")",parent:w.obj.displayName+" ("+w.path+")"})}y.length&&console.warn("USDZExporter: There are overlapping PlayAnimation actions. This can lead to undefined runtime behaviour when playing multiple animations. Please restructure the hierarchy so that animations don't overlap.",{overlappingTargets:y,playAnimationActions:o})}for(const u of new Set([...i,...s]))if(Array.isArray(u))for(const m of u)r.add(m.uuid);else r.add(u.uuid);yM&&console.log("All Behavior trigger sources and action targets",i,s,r),this.targetUuids=new Set(r)}onAfterHierarchy(e,i){var s;if((s=this.behaviours)!=null&&s.length){i.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,i);i.closeBlock()}}async onAfterSerialize(e){yM&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const i of this.behaviourComponentsCopy)typeof i.afterSerialize=="function"&&(i.afterSerialize.constructor.name==="AsyncFunction"?await i.afterSerialize(this,e):i.afterSerialize(this,e));for(const{clipUrl:i,filesKey:s}of this.audioClipsCopy){if(e.files[s])return;const r=await(await(await fetch(i)).blob()).arrayBuffer(),o=new Uint8Array(r);e.files[s]=o}this.behaviourComponentsCopy.length=0,this.audioClipsCopy.length=0}}var ave=Object.defineProperty,lve=Object.getOwnPropertyDescriptor,OO=(n,e,i,s)=>{for(var r=s>1?void 0:s?lve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&ave(e,i,r),r},DO;const PQ=(DO=class extends Us{constructor(){super(...arguments),p(this,"threshold",new qe(.9)),p(this,"intensity",new qe(1)),p(this,"scatter",new qe(.3)),p(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.valueProcessor=n=>n,this.intensity.valueProcessor=n=>n,this.scatter.valueProcessor=n=>n}onCreateEffect(){let n;if(this.selectiveBloom==null&&(this.selectiveBloom=PQ.useSelectiveBloom),this.selectiveBloom){const e=n=new oV(this.context.scene,this.context.mainCamera,{blendFunction:jt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});e.inverted=!0}else n=new ML({blendFunction:jt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{n.intensity=e},this.threshold.onValueChanged=e=>{n.luminanceMaterial.threshold=Math.pow(e,2.2)},this.scatter.onValueChanged=e=>{n.luminancePass.enabled=!0,n.luminanceMaterial.smoothing=e,n.mipmapBlurPass&&(n.mipmapBlurPass.radius=oi.lerp(.1,.9,e))},n}},p(DO,"useSelectiveBloom",!1),DO);let Xm=PQ;OO([E(qe)],Xm.prototype,"threshold",2),OO([E(qe)],Xm.prototype,"intensity",2),OO([E(qe)],Xm.prototype,"scatter",2),Ja("Bloom",Xm);var cve=Object.defineProperty,hve=Object.getOwnPropertyDescriptor,Oo=(n,e,i,s)=>{for(var r=s>1?void 0:s?hve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&cve(e,i,r),r};class Do extends Pe{constructor(){super(...arguments),p(this,"attachedRigidbody",null),p(this,"isTrigger",!1),p(this,"sharedMaterial"),p(this,"membership",[0]),p(this,"filter"),p(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ci))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}Oo([E(Ci)],Do.prototype,"attachedRigidbody",2),Oo([E()],Do.prototype,"isTrigger",2),Oo([E()],Do.prototype,"sharedMaterial",2),Oo([E()],Do.prototype,"membership",2),Oo([E()],Do.prototype,"filter",2);class z0 extends Do{constructor(){super(...arguments),p(this,"radius",.5),p(this,"center",new M(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),m_(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),vI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Oo([rr(),E()],z0.prototype,"radius",2),Oo([E(M)],z0.prototype,"center",2);const kQ=class extends Do{constructor(){super(...arguments),p(this,"size",new M(1,1,1)),p(this,"center",new M(0,0,0))}static add(n,e){const i=new kQ;n.geometry.boundingBox||n.geometry.computeBoundingBox();const s=n.geometry.boundingBox;return i.size=s.getSize(new M)||new M(1,1,1),i.center=s.getCenter(new M)||new M(0,0,0),ra(n,i),e?.rigidbody===!0&&ra(n,Ci,{isKinematic:!1}),i}onEnable(){var n;super.onEnable(),(n=this.context.physics.engine)==null||n.addBoxCollider(this,this.size),m_(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),vI(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}};let U0=kQ;Oo([rr(),E(M)],U0.prototype,"size",2),Oo([E(M)],U0.prototype,"center",2);class Wm extends Do{constructor(){super(...arguments),p(this,"sharedMesh"),p(this,"convex",!1)}onEnable(){var e,i,s;if(super.onEnable(),!this.context.physics.engine)return;(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ue&&(this.sharedMesh=this.gameObject);const r=0;if((i=this.sharedMesh)!=null&&i.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Yi(this.gameObject)),mi.assignMeshLOD(this.sharedMesh,r).then(o=>{o&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=o,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Yi(this.gameObject)))});else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((s=this.sharedMesh)==null?void 0:s.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const a=new Array;for(const l in o.children){const c=o.children[l];c.isMesh&&(this.context.physics.engine.addMeshCollider(this,c,this.convex,Yi(this.gameObject)),a.push(mi.assignMeshLOD(c,r)))}Promise.all(a).then(l=>{var c,h;if(l.some(u=>u)==!1)return;(c=this.context.physics.engine)==null||c.removeBody(this);const d=new ue;for(const u of l)u&&this.activeAndEnabled&&(d.geometry=u,(h=this.context.physics.engine)==null||h.addMeshCollider(this,d,this.convex,Yi(this.gameObject)))})}}}}Oo([E(ue)],Wm.prototype,"sharedMesh",2),Oo([E()],Wm.prototype,"convex",2);class ed extends Do{constructor(){super(...arguments),p(this,"center",new M(0,0,0)),p(this,"radius",.5),p(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Oo([E(M)],ed.prototype,"center",2),Oo([E()],ed.prototype,"radius",2),Oo([E()],ed.prototype,"height",2);var dve=Object.defineProperty,uve=Object.getOwnPropertyDescriptor,GO=(n,e,i,s)=>{for(var r=s>1?void 0:s?uve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&dve(e,i,r),r};class Hm extends Pe{constructor(){super(...arguments),p(this,"objectBounds",!1),p(this,"color"),p(this,"isGizmo",!0),p(this,"_gizmoObject",null),p(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!$b||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new iU(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=Ik(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ji.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var e;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}GO([E()],Hm.prototype,"objectBounds",2),GO([E(Ae)],Hm.prototype,"color",2),GO([E()],Hm.prototype,"isGizmo",2);const pve=te("gizmos"),mve=te("debugboxhelper"),Dc=class extends Pe{constructor(){super(...arguments),p(this,"box",null),p(this,"_lastMatrixUpdateFrame",-1),p(this,"_helper",null),p(this,"_color",null)}isInBox(n){var e;if(!n)return;if(this.box||(this.box=new Wt),Jo([n],void 0,void 0,Dc.testBox),Dc.testBox.isEmpty()){const s=Nt(n,Dc._position);Dc.testBox.setFromCenterAndSize(s,Dc._emptyObjectSize)}this.updateBox();const i=(e=this.box)==null?void 0:e.intersectsBox(Dc.testBox);return i&&mve&&ft.DrawWireBox3(Dc.testBox,16711680,5),i}intersects(n){return n?this.updateBox(!1).intersectsBox(n):!1}updateBox(n=!1){if(this.box||(this.box=new Wt),n||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const e=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const i=e,s=Nt(this.gameObject,Dc._position,i),r=Yi(this.gameObject,Dc._size);this.box.setFromCenterAndSize(s,r)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(n=null,e=!1){var i;if(!(!pve&&!e)){if(this._helper){n&&((i=this._color)==null||i.set(n)),this.gameObject.add(this._helper);return}this._helper=Ik(n),this.gameObject.add(this._helper)}}};let qa=Dc;p(qa,"testBox",new Wt),p(qa,"_position",new M),p(qa,"_size",new M(.01,.01,.01)),p(qa,"_emptyObjectSize",new M(.01,.01,.01));class fve extends x5{constructor(e,i={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=i,e._simpleState__statesProperties={};for(const s in i)for(const r in i[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,i){this._simpleState__states[e]=i;const s=[];for(const r in i)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const i in this._simpleState__states)this._simpleState__activeStates.indexOf(i)>-1&&(e={...e,...this._simpleState__states[i]});this.set(e,!1)}storeSet(e,i=!0){if(i)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const i=this._simpleState__activeStates.indexOf(e);i>-1&&(this._simpleState__activeStates.splice(i,1),this.renderStates())}togglePseudoState(e){const i=this._simpleState__activeStates.indexOf(e);i>-1?this._simpleState__activeStates.splice(i,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var gve=Object.defineProperty,yve=Object.getOwnPropertyDescriptor,BQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?yve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&gve(e,i,r),r};class V0 extends Pe{constructor(){super(...arguments),p(this,"effectColor"),p(this,"effectDistance")}}BQ([E(Li)],V0.prototype,"effectColor",2),BQ([E(K)],V0.prototype,"effectDistance",2);var vve=Object.defineProperty,bve=Object.getOwnPropertyDescriptor,YA=(n,e,i,s)=>{for(var r=s>1?void 0:s?bve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&vve(e,i,r),r};const NO=te("debugui"),FO=te("debuguilayout");class zO{constructor(){p(this,"width"),p(this,"height")}}class UO{constructor(){p(this,"x"),p(this,"y"),p(this,"width"),p(this,"height")}}const Xl=new M,KA=new he,bM=new Se,OQ=class extends hl{constructor(){super(...arguments),p(this,"_anchoredPosition"),p(this,"sizeDelta",new K(100,100)),p(this,"pivot",new K(.5,.5)),p(this,"anchorMin",new K(0,0)),p(this,"anchorMax",new K(1,1)),p(this,"minWidth"),p(this,"minHeight"),p(this,"lastMatrix"),p(this,"rectBlock"),p(this,"_transformNeedsUpdate",!1),p(this,"_initialPosition"),p(this,"_parentRectTransform"),p(this,"_lastUpdateFrame",-1),p(this,"_lastAnchoring"),p(this,"_createdBlocks",[]),p(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new K),this._anchoredPosition}set anchoredPosition(n){this._anchoredPosition=n}get width(){let n=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,i=this.anchorMax.x-this.anchorMin.x;n=e*i,n+=this.sizeDelta.x}return this.minWidth!==void 0&&n<this.minWidth?this.minWidth:n}get height(){let n=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,i=this.anchorMax.y-this.anchorMin.y;n=e*i,n+=this.sizeDelta.y}return this.minHeight!==void 0&&n<this.minHeight?this.minHeight:n}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new K),this.lastMatrix=new he,this.rectBlock=new ge,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,k0(this,"_anchoredPosition",()=>{this.markDirty()}),k0(this,"sizeDelta",()=>{this.markDirty()}),k0(this,"pivot",()=>{this.markDirty()}),k0(this,"anchorMin",()=>{this.markDirty()}),k0(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var n;super.onEnable(),this.rectBlock||(this.rectBlock=new ge),this.lastMatrix||(this.lastMatrix=new he),this._lastAnchoring||(this._lastAnchoring=new K),this._initialPosition||(this._initialPosition=new M),this._anchoredPosition||(this._anchoredPosition=new K),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(n=this.canvas)==null||n.registerTransform(this)}onDisable(){var n;super.onDisable(),this.removeShadowComponent(),(n=this.canvas)==null||n.unregisterTransform(this)}onParentRectTransformChanged(n){this._transformNeedsUpdate||this.onApplyTransform(FO?`${n.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(FO&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(n){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const i=this.shadowComponent;if(!i)return;this.gameObject.parent?this._parentRectTransform=ie.getComponentInParent(this.gameObject.parent,OQ):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,FO&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+n),this.isRoot()?this.Root.screenspace||(i.rotation.y=Math.PI):(i.matrix.identity(),i.matrixAutoUpdate=!1,Xl.set(0,0,0),this.applyPivot(Xl),i.matrix.setPosition(Xl.x,Xl.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(bM.copy(this.gameObject.quaternion),bM.x*=-1,bM.z*=-1,KA.makeRotationFromQuaternion(bM),i.matrix.premultiply(KA)),Xl.set(0,0,0),this.applyAnchoring(Xl),(e=this.canvas)!=null&&e.screenspace?Xl.z+=.1:Xl.z+=.01,KA.identity(),KA.setPosition(Xl.x,Xl.y,Xl.z),i.matrix.premultiply(KA),i.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of gC(this.gameObject,hl,s,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(n){this._lastAnchoring||(this._lastAnchoring=new K);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),n.x+=this._initialPosition.x-this.gameObject.position.x,n.y+=this._initialPosition.y-this.gameObject.position.y,n.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,n.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,n.x+=o}}applyPivot(n){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;n.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;n.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const n={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(n),n}ensureValidSize(n,e=1e-4){return n.width<=0&&(n.width=e),n.height<=0&&(n.height=1e-4),n}createNewBlock(n){n={...this.getBasicOptions(),...n},NO&&console.log(this.name,n);const e=new $I(n);return this._createdBlocks.push(e),e}createNewText(n){NO&&console.log(n),n={...this.getBasicOptions(),...n},NO&&console.log(this.name,n);const e=new tL(n);return this._createdTextBlocks.push(e),e}};let Vr=OQ;YA([E(K)],Vr.prototype,"anchoredPosition",1),YA([E(K)],Vr.prototype,"sizeDelta",2),YA([E(K)],Vr.prototype,"pivot",2),YA([E(K)],Vr.prototype,"anchorMin",2),YA([E(K)],Vr.prototype,"anchorMax",2);var Ave=Object.defineProperty,xve=Object.getOwnPropertyDescriptor,DQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?xve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Ave(e,i,r),r};const AM={backgroundColor:new Ae(1,1,1),backgroundOpacity:1,borderColor:new Ae(1,1,1),borderOpacity:1};var VO;const JA=(VO=class extends hl{constructor(){super(...arguments),p(this,"_alphaFactor",1),p(this,"sRGBColor",new Ae(1,0,1)),p(this,"raycastTarget",!0),p(this,"uiObject",null),p(this,"_color",null),p(this,"_rect",null),p(this,"_stateManager",null),p(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Li(1,1,1,1)),this._color}set color(n){(!this._color||this._color.r!==n.r||this._color.g!==n.g||this._color.b!==n.b||this._color.alpha!==n.alpha)&&(this._color||(this._color=new Li(1,1,1,1)),this._color.copy(n),this.onColorChanged())}setAlphaFactor(n){this._alphaFactor=n,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),AM.backgroundColor=this.sRGBColor,AM.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(AM,this._alphaFactor),this.uiObject.set(AM),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=ie.getComponent(this.gameObject,Vr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var n;(n=this.uiObject)==null||n.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(n){return super.__internalNewInstanceCreated(n),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(n){this.makePanel(),this.uiObject&&(this.uiObject.setState(n),this==null||this.markDirty())}setupState(n){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new fve(this.uiObject)),this.uiObject.setupState(n.state,n.attributes))}setOptions(n){this.makePanel(),this.uiObject&&this.uiObject.set(n)}awake(){super.awake(),this.makePanel(),k0(this,"_color",()=>Z0e(this,this.onColorChanged))}onEnable(){var n;super.onEnable(),this.uiObject&&((n=this.rectTransform.shadowComponent)==null||n.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const n=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:n};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(n){}onCreate(n){this.uiObject=this.rectTransform.createNewBlock(n),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(n,e=1){var i;const s=(i=this.gameObject)==null?void 0:i.getComponent(V0);s&&(s.effectDistance&&(n.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(n.borderColor=s.effectColor,n.borderOpacity=s.effectColor.alpha*e))}async setTexture(n){if(this.setOptions({backgroundOpacity:0}),n){if(JA.textureCache.has(n))n=JA.textureCache.get(n);else if(!n.isRenderTargetTexture){const e=n.clone();e.colorSpace=ki,JA.textureCache.set(n,e),n=e}this.setOptions({backgroundImage:n,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),mi.assignTextureLOD(n,0).then(e=>{e instanceof Vt&&(n&&JA.textureCache.set(n,e),this.setOptions({backgroundImage:e}),this.markDirty())})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},p(VO,"textureCache",new Map),VO);let jm=JA;DQ([E(Li)],jm.prototype,"color",1),DQ([E()],jm.prototype,"raycastTarget",2);class qA extends jm{constructor(){super(...arguments),p(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wve=Object.defineProperty,_ve=Object.getOwnPropertyDescriptor,xM=(n,e,i,s)=>{for(var r=s>1?void 0:s?_ve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&wve(e,i,r),r};let XO=class{constructor(){p(this,"texture",null),p(this,"rect")}};xM([E(Vt)],XO.prototype,"texture",2);let X0=class extends qA{constructor(){super(...arguments),p(this,"_sprite"),p(this,"pixelsPerUnitMultiplier",1)}set image(n){this.sprite||(this.sprite=new XO),this.sprite.texture=n,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(n){this._sprite!==n&&(this._sprite=n,this.onAfterCreated())}isBuiltinSprite(){var n,e,i,s,r,o,a;const l=this.sprite;switch((n=l?.texture)==null?void 0:n.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((i=(e=l?.texture)==null?void 0:e.name)!=null&&i.length)&&((r=(s=l?.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=l?.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(n){var e,i;super.onBeforeCreate(n),this.isBuiltinSprite()&&(n.borderRadius=5/this.pixelsPerUnitMultiplier,((i=(e=this.sprite)==null?void 0:e.texture)==null?void 0:i.name)==="Knob"&&(n.borderRadius=999))}onAfterCreated(){var n;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((n=this.sprite)==null?void 0:n.texture))}};xM([E(XO)],X0.prototype,"sprite",1),xM([E()],X0.prototype,"pixelsPerUnitMultiplier",2);class wM extends qA{constructor(){super(...arguments),p(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}xM([E(Vt)],wM.prototype,"mainTexture",1);var Sve=Object.defineProperty,Cve=Object.getOwnPropertyDescriptor,ma=(n,e,i,s)=>{for(var r=s>1?void 0:s?Cve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Sve(e,i,r),r};const Qm=te("debugbutton");class Vu{constructor(){p(this,"colorMultiplier"),p(this,"disabledColor"),p(this,"fadeDuration"),p(this,"highlightedColor"),p(this,"normalColor"),p(this,"pressedColor"),p(this,"selectedColor")}}ma([E()],Vu.prototype,"colorMultiplier",2),ma([E(Li)],Vu.prototype,"disabledColor",2),ma([E()],Vu.prototype,"fadeDuration",2),ma([E(Li)],Vu.prototype,"highlightedColor",2),ma([E(Li)],Vu.prototype,"normalColor",2),ma([E(Li)],Vu.prototype,"pressedColor",2),ma([E(Li)],Vu.prototype,"selectedColor",2);class Mve{constructor(){p(this,"disabledTrigger"),p(this,"highlightedTrigger"),p(this,"normalTrigger"),p(this,"pressedTrigger"),p(this,"selectedTrigger")}}class td extends Pe{constructor(){super(...arguments),p(this,"onClick",new ji),p(this,"_isHovered",0),p(this,"colors"),p(this,"transition"),p(this,"animationTriggers"),p(this,"animator"),p(this,"_interactable",!0),p(this,"_requestedAnimatorTrigger"),p(this,"_isInit",!1),p(this,"_image")}click(){var e;(e=this.onClick)==null||e.invoke()}onPointerEnter(e){var i,s;const r=e.event.pointerType==="mouse"&&e.button===0;r&&(this._isHovered+=1),Qm&&console.warn("Button Enter",r,this._isHovered,(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),r&&this.context.input.setCursorPointer())}onPointerExit(){var e,i;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),Qm&&console.log("Button Exit",this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(e){var i,s;Qm&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var i,s;Qm&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===TS.Mouse)&&(Qm&&(console.warn("Button Click",this.onClick),gn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Qm))){const i=this.gameObject.worldPosition;i.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),ft.DrawLabel(i,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Qm&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(IA)||this.gameObject.addComponent(rM)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(e){var i;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((i=this.animator)==null||i.setTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=ie.getComponent(this.gameObject,X0),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var i,s,r,o,a;e.setInteractable(this.interactable);const l=this.getFinalColor(e.color,(i=this.colors)==null?void 0:i.normalColor),c={state:"normal",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};e.setupState(c);const h=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),d={state:"hovered",attributes:{backgroundColor:h,backgroundOpacity:h.alpha}};e.setupState(d);const u=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),m={state:"pressed",attributes:{backgroundColor:u,backgroundOpacity:u.alpha}};e.setupState(m);const f=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.selectedColor),g={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(g);const v=this.getFinalColor(e.color,(a=this.colors)==null?void 0:a.disabledColor),y={state:"disabled",attributes:{backgroundColor:v,backgroundOpacity:v.alpha}};e.setupState(y)}getFinalColor(e,i){return i?e.clone().multiply(i).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}ma([E(ji)],td.prototype,"onClick",2),ma([E(Vu)],td.prototype,"colors",2),ma([E()],td.prototype,"transition",2),ma([E(Mve)],td.prototype,"animationTriggers",2),ma([E(sr)],td.prototype,"animator",2),ma([E()],td.prototype,"interactable",1);var Eve=Object.defineProperty,Tve=Object.getOwnPropertyDescriptor,as=(n,e,i,s)=>{for(var r=s>1?void 0:s?Tve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Eve(e,i,r),r};const GQ=te("debuguilayout");class Xu{constructor(){p(this,"left",0),p(this,"right",0),p(this,"top",0),p(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}as([E()],Xu.prototype,"left",2),as([E()],Xu.prototype,"right",2),as([E()],Xu.prototype,"top",2),as([E()],Xu.prototype,"bottom",2);class fa extends Pe{constructor(){super(...arguments),p(this,"_rectTransform",null),p(this,"_needsUpdate",!1),p(this,"childAlignment",0),p(this,"reverseArrangement",!1),p(this,"spacing",0),p(this,"padding"),p(this,"minWidth",0),p(this,"minHeight",0),p(this,"flexibleHeight",0),p(this,"flexibleWidth",0),p(this,"preferredHeight",0),p(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(GQ&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){GQ&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Vr);const e=this.gameObject.getComponentInParent(lr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(lr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}as([E()],fa.prototype,"childAlignment",2),as([E()],fa.prototype,"reverseArrangement",2),as([E()],fa.prototype,"spacing",2),as([E(Xu)],fa.prototype,"padding",2),as([E()],fa.prototype,"minWidth",2),as([E()],fa.prototype,"minHeight",2),as([E()],fa.prototype,"flexibleHeight",2),as([E()],fa.prototype,"flexibleWidth",2),as([E()],fa.prototype,"preferredHeight",2),as([E()],fa.prototype,"preferredWidth",2);class Wu extends fa{constructor(){super(...arguments),p(this,"childControlHeight",!0),p(this,"childControlWidth",!0),p(this,"childForceExpandHeight",!1),p(this,"childForceExpandWidth",!1),p(this,"childScaleHeight",!1),p(this,"childScaleWidth",!1)}onCalculateLayout(e){var i;const s=this.primaryAxis,r=e.width;let o=r;const a=e.height;let l=a;o-=this.padding.horizontal,l-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const c=s==="x",h=c?"y":"x",d=c?this.childControlWidth:this.childControlHeight,u=c?this.childControlHeight:this.childControlWidth,m=c?this.childForceExpandWidth:this.childForceExpandHeight,f=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?l:o,v=c?r:a,y=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let b=0;c?b+=this.padding.left:b+=this.padding.top;let A=0,x=0;for(let R=0;R<this.gameObject.children.length;R++){const P=this.gameObject.children[R],T=ie.getComponent(P,Vr);T!=null&&T.activeAndEnabled&&(x+=1,c?A+=T.width:A+=T.height)}let w=0;const _=this.spacing*(x-1);if(m||d){let R=0;c?R=o-=_:R=l-=_,x>0&&(w=R/x)}let S=0;S+=this.padding.left,S-=this.padding.right,y!==0&&(b=v-A,b*=y,b-=_*y,c?(b-=this.padding.right*y,b+=this.padding.left*(1-y),b<this.padding.left&&(b=this.padding.left)):(b-=this.padding.bottom*y,b+=this.padding.top*(1-y),b<this.padding.top&&(b=this.padding.top)));let C=1;for(let R=0;R<this.gameObject.children.length;R++){const P=this.gameObject.children[R],T=ie.getComponent(P,Vr);if(T!=null&&T.activeAndEnabled){(i=T.pivot)==null||i.set(.5,.5),T.anchorMin.set(0,1),T.anchorMax.set(0,1);const L=r*.5+S*.5;T.anchoredPosition.x!==L&&(T.anchoredPosition.x=L);const k=a*-.5;T.anchoredPosition.y!==k&&(T.anchoredPosition.y=k),f&&u&&T.sizeDelta[h]!==g&&(T.sizeDelta[h]=g),m&&d&&T.sizeDelta[s]!==w&&(T.sizeDelta[s]=w);const G=c?T.width:T.height,O=G*.5;if(b+=O,m){const D=w*C-w*.5;D>b&&(b=D-w*.5+G+this.padding.left,b-=O)}let W=b;s==="y"&&(W=-W),T.anchoredPosition[s]!==W&&(T.anchoredPosition[s]=W),b+=O,b+=this.spacing,C+=1}}}}as([E()],Wu.prototype,"childControlHeight",2),as([E()],Wu.prototype,"childControlWidth",2),as([E()],Wu.prototype,"childForceExpandHeight",2),as([E()],Wu.prototype,"childForceExpandWidth",2),as([E()],Wu.prototype,"childScaleHeight",2),as([E()],Wu.prototype,"childScaleWidth",2);class WO extends Wu{get primaryAxis(){return"y"}}class HO extends Wu{get primaryAxis(){return"x"}}class jO extends fa{onCalculateLayout(){}}var Rve=Object.defineProperty,Ive=Object.getOwnPropertyDescriptor,Gc=(n,e,i,s)=>{for(var r=s>1?void 0:s?Ive(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Rve(e,i,r),r},NQ=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(NQ||{});const QO=te("debuguilayout"),FQ=class extends RA{constructor(){super(...arguments),p(this,"_renderOnTop"),p(this,"_depthWrite",!1),p(this,"_doubleSided",!0),p(this,"_castShadows",!1),p(this,"_receiveShadows",!1),p(this,"_renderMode",-1),p(this,"_rootCanvas"),p(this,"_scaleFactor",1),p(this,"worldCamera"),p(this,"planeDistance",-1),p(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),p(this,"previousParent",null),p(this,"_lastMatrixWorld",null),p(this,"_rectTransforms",[]),p(this,"_layoutGroups",new Map),p(this,"_receivers",[]),p(this,"onBeforeRenderRoutine",()=>{var n,e,i,s;if(this.previousParent=this.gameObject.parent,((n=this.context.xr)!=null&&n.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Ka.ensureUpdateMeshUI(_5,this.context))}),p(this,"onAfterRenderRoutine",()=>{var n,e,i,s,r;if(((n=this.context.xr)!=null&&n.isVR||(e=this.context.xr)!=null&&e.isPassThrough)&&this.screenspace){(i=this.previousParent)==null||i.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const l=this.context.mainCamera;l?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const o=this.context.renderer.autoClear,a=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(s=this.shadowComponent)==null||s.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Ka.ensureUpdateMeshUI(_5,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=o,this.context.renderer.autoClearColor=a,this.previousParent.add(this.gameObject)}(r=this._lastMatrixWorld)==null||r.copy(this.gameObject.matrixWorld)}),p(this,"_updateRenderSettingsRoutine"),p(this,"_activeRenderMode",-1),p(this,"_lastWidth",-1),p(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(n){n!==this._renderOnTop&&(this._renderOnTop=n,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(n){this._depthWrite!==n&&(this._depthWrite=n,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(n){this._doubleSided!==n&&(this._doubleSided=n,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(n){this._castShadows!==n&&(this._castShadows=n,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(n){this._receiveShadows!==n&&(this._receiveShadows=n,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(n){this._renderMode!==n&&(this._renderMode=n,this.onRenderSettingsChanged())}set rootCanvas(n){this._rootCanvas instanceof FQ||(this._rootCanvas=n)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(n){this._scaleFactor=n}awake(){var n;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,QO&&console.log("Canvas.Awake()",((n=this.previousParent)==null?void 0:n.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new he,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const n=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);n!==-1&&this.context.pre_render_callbacks.splice(n,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(n){this._rectTransforms.push(n)}unregisterTransform(n){const e=this._rectTransforms.indexOf(n);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(n){const e=n.gameObject;this._layoutGroups.set(e,n)}unregisterLayoutGroup(n){const e=n.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(n){this._receivers.push(n)}unregisterEventReceiver(n){const e=this._receivers.indexOf(n);e!==-1&&this._receivers.splice(e,1)}async onEnterXR(n){this.screenspace?(n.xr.isVR||n.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await u_(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(n){this.screenspace&&(n.xr.isVR||n.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var n;for(const e of this._receivers)(n=e.onBeforeCanvasRender)==null||n.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new he);const n=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);QO&&n&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const i of this._rectTransforms){n&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(fa)),(i.isDirty||s!=null&&s.isDirty)&&(QO&&!e&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ji.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),aM(this.shadowComponent,this);for(const n of ie.getComponentsInChildren(this.gameObject,hl))aM(n.shadowComponent,this)}}onUpdateRenderMode(n=!1){if(!n&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,i=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(i=et.lerp(e.nearClipPlane,e.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Vr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=e.fieldOfView*Math.PI/180,l=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=l/this.context.domHeight,this.gameObject.scale.y=l/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let lr=FQ;Gc([E()],lr.prototype,"renderOnTop",1),Gc([E()],lr.prototype,"depthWrite",1),Gc([E()],lr.prototype,"doubleSided",1),Gc([E()],lr.prototype,"castShadows",1),Gc([E()],lr.prototype,"receiveShadows",1),Gc([E()],lr.prototype,"renderMode",1),Gc([E(lr)],lr.prototype,"rootCanvas",1),Gc([E()],lr.prototype,"scaleFactor",1),Gc([E(Fi)],lr.prototype,"worldCamera",2),Gc([E()],lr.prototype,"planeDistance",2);var Lve=Object.defineProperty,Pve=Object.getOwnPropertyDescriptor,ZO=(n,e,i,s)=>{for(var r=s>1?void 0:s?Pve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Lve(e,i,r),r};class Hu extends Pe{constructor(){super(...arguments),p(this,"_alpha",1),p(this,"interactable",!0),p(this,"blocksRaycasts",!0),p(this,"_isDirty",!1),p(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ji.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const e of ie.getComponentsInChildren(this.gameObject,hl,this._buffer)){const i=e;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}ZO([E()],Hu.prototype,"alpha",1),ZO([E()],Hu.prototype,"interactable",2),ZO([E()],Hu.prototype,"blocksRaycasts",2);var kve=Object.defineProperty,Bve=Object.getOwnPropertyDescriptor,Mn=(n,e,i,s)=>{for(var r=s>1?void 0:s?Bve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&kve(e,i,r),r};const zQ=te("debugusdzbehaviours");function $A(n){n&&(n.getComponentInParent(IA)||(je()&&console.debug('Raycaster on "'+n.name+'" was automatically added, because no raycaster was found in the parent hierarchy.'),n.addComponent(ca)))}class Zm extends Pe{constructor(){super(...arguments),p(this,"object"),p(this,"target"),p(this,"duration",1),p(this,"relativeMotion",!1),p(this,"coroutine",null),p(this,"targetPos",new M),p(this,"targetRot",new Se),p(this,"targetScale",new M)}start(){$A(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=Nt(this.object).clone(),i=Nt(this.target).clone(),s=Bi(this.object).clone(),r=Bi(this.target).clone(),o=Yi(this.object).clone(),a=Yi(this.target).clone(),l=e.distanceTo(i),c=s.angleTo(r),h=o.distanceTo(a);if(l<.01&&c<.01&&h<.01){bs(this.object,i),Ba(this.object,r),wg(this.object,a),this.coroutine=null;return}let d=0,u=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),u=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(e,i,u),this.targetRot.slerpQuaternions(s,r,u),this.targetScale.lerpVectors(o,a,u),bs(this.object,this.targetPos),Ba(this.object,this.targetRot),wg(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let l=0,c=0;for(;l<1;)l+=this.context.time.deltaTime/this.duration,l>1&&(l=1),c=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,c),this.object.quaternion.slerpQuaternions(i,this.targetRot,c),this.object.scale.lerpVectors(s,this.targetScale,c),yield;this.coroutine=null}beforeCreateDocument(e){var i;if(this.target&&this.object&&this.gameObject){const s=new Gs("Move to "+((i=this.target)==null?void 0:i.name),Ns.tapTrigger(this.gameObject),vi.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));e.addBehavior(s)}}}Mn([E(ge)],Zm.prototype,"object",2),Mn([E(ge)],Zm.prototype,"target",2),Mn([E()],Zm.prototype,"duration",2),Mn([E()],Zm.prototype,"relativeMotion",2);var _M;const Nc=(_M=class extends Pe{constructor(){super(...arguments),p(this,"materialToSwitch"),p(this,"variantMaterial"),p(this,"fadeDuration",0),p(this,"_objectsWithThisMaterial",null),p(this,"selfModel"),p(this,"targetModels")}start(){var n;this._objectsWithThisMaterial=this.objectsWithThisMaterial,$A(this.gameObject),je()&&this._objectsWithThisMaterial.length<=0&&console.warn('ChangeMaterialOnClick: No objects found with material "'+((n=this.materialToSwitch)==null?void 0:n.name)+'"')}onPointerEnter(n){this.context.input.setCursorPointer()}onPointerExit(n){this.context.input.setCursorNormal()}onPointerClick(n){if(n.use(),!!this.variantMaterial)for(let e=0;e<this.objectsWithThisMaterial.length;e++){const i=this.objectsWithThisMaterial[e];i.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(n=>{if(n instanceof ue)if(Array.isArray(n.material)){for(const e of n.material)if(e===this.materialToSwitch){this.objectsWithThisMaterial.push(n);break}}else n.material===this.materialToSwitch?this.objectsWithThisMaterial.push(n):z9(n.material,this.materialToSwitch)&&this.objectsWithThisMaterial.push(n)}),this._objectsWithThisMaterial)}async beforeCreateDocument(n,e){this.targetModels=[],Nc._materialTriggersPerId={},Nc.variantSwitchIndex=0,this.materialToSwitch&&await mi.assignTextureLOD(this.materialToSwitch,0),this.variantMaterial&&await mi.assignTextureLOD(this.variantMaterial,0)}createBehaviours(n,e,i){this.objectsWithThisMaterial.find(s=>s.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Nc._materialTriggersPerId[this.materialToSwitch.uuid]||(Nc._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Nc._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(n,e){if(!this.materialToSwitch)return;const i=Nc._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const r of i){const o=r.createVariants();o&&o.length>0&&(s[r.selfModel.uuid]=o)}for(const r of i){const o=[];for(const a in s)a!==r.selfModel.uuid&&o.push(...s[a]);r.createAndAttachBehaviors(n,s[r.selfModel.uuid],o)}}delete Nc._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(n,e,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);r.push(vi.fadeAction([...this.targetModels,...i],o,!1)),s.push(vi.fadeAction(e,o,!1)),r.push(vi.fadeAction(e,o,!0)),n.addBehavior(new Gs("Select_"+this.selfModel.name,Ns.tapTrigger(this.selfModel),vi.parallel(...r))),n.addBehavior(new Gs("StartHidden_"+this.selfModel.name,Ns.sceneStartTrigger(),vi.parallel(...s)))}static getMaterialName(n){return Ul(n.name||"Material")+"_"+n.id}createVariants(){if(!this.variantMaterial)return null;const n=[];for(const e of this.targetModels){const i=e.clone();i.name+="_Variant_"+Nc.variantSwitchIndex+++"_"+Nc.getMaterialName(this.variantMaterial),i.displayName=i.displayName+": Variant with material "+this.variantMaterial.name,i.material=this.variantMaterial,i.geometry=e.geometry,i.transform=e.transform,(!e.parent||!e.parent.isEmpty())&&ho.createEmptyParent(e),e.parent&&e.parent.add(i),n.push(i)}return n}},p(_M,"_materialTriggersPerId",{}),p(_M,"variantSwitchIndex",0),_M);let W0=Nc;Mn([E(Ft)],W0.prototype,"materialToSwitch",2),Mn([E(Ft)],W0.prototype,"variantMaterial",2),Mn([E()],W0.prototype,"fadeDuration",2);var H0;const En=(H0=class extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"toggleOnClick",!1),p(this,"targetState",!0),p(this,"hideSelf",!0),p(this,"selfModel"),p(this,"selfModelClone"),p(this,"targetModel"),p(this,"toggleModel"),p(this,"stateBeforeCreatingDocument",!1),p(this,"targetStateBeforeCreatingDocument",!1)}start(){$A(this.gameObject)}onPointerClick(n){n.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(n,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e,this.selfModelClone=e.clone())}beforeCreateDocument(){this.target&&(this.gameObject[En.wasVisible]===void 0&&(this.gameObject[En.wasVisible]=this.gameObject.activeSelf),this.target[En.wasVisible]===void 0&&(this.target[En.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[En.wasVisible],this.targetStateBeforeCreatingDocument=this.target[En.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(n,e){if(!this.target)return;this.targetModel=e.document.findById(this.target.uuid);const i=this.selfModel;if(this.selfModel&&this.targetModel){let s=this.selfModel,r=this.targetState;if(this.toggleOnClick)if(r=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&XB.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[En.toggleClone]){const l=this.selfModelClone.clone();l.setMatrix(new he),l.name+="_toggle"+En.clonedToggleIndex++,i.add(l),this.gameObject[En.toggleClone]=l,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const a=this.gameObject[En.toggleClone];if(!this.gameObject[En.reverseToggleClone]){const l=this.selfModelClone.clone();l.setMatrix(new he),l.name+="_toggleReverse"+En.clonedToggleIndex++,i.add(l),this.gameObject[En.reverseToggleClone]=l}this.toggleModel=this.gameObject[En.reverseToggleClone],(!this.toggleModel.geometry||!a.geometry)&&console.error("triggers without childs and without geometry won't work!",this,i.geometry),s=a,i.geometry=null,i.material=null}if(this.toggleModel){if(this.toggleOnClick){const a=[];a.push(vi.fadeAction(s,0,!1)),a.push(vi.fadeAction(this.toggleModel,0,!0)),a.push(vi.fadeAction(this.targetModel,0,r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Ns.tapTrigger(s),vi.parallel(...a)));const l=[];l.push(vi.fadeAction(this.toggleModel,0,!1)),l.push(vi.fadeAction(s,0,!0)),l.push(vi.fadeAction(this.targetModel,0,!r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"Off":"On"),Ns.tapTrigger(this.toggleModel),vi.parallel(...l)))}}else{const a=[];this.hideSelf&&a.push(vi.fadeAction(s,0,!1)),a.push(vi.fadeAction(this.targetModel,0,r)),n.addBehavior(new Gs("Toggle_"+s.name+"_toggleTo"+(r?"On":"Off"),Ns.tapTrigger(s),vi.parallel(...a)))}const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(i),this.toggleModel&&o.push(this.toggleModel),n.addBehavior(new Gs("HideOnStart_"+this.gameObject.name,Ns.sceneStartTrigger(),vi.fadeAction(o,0,!1)))}}afterSerialize(n,e){this.gameObject[En.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[En.wasVisible],delete this.gameObject[En.wasVisible]),this.target&&this.target[En.wasVisible]!==void 0&&(this.target.visible=this.target[En.wasVisible],delete this.target[En.wasVisible]),delete this.gameObject[En.toggleClone],delete this.gameObject[En.reverseToggleClone]}},p(H0,"clonedToggleIndex",0),p(H0,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),p(H0,"toggleClone",Symbol("clone for toggling")),p(H0,"reverseToggleClone",Symbol("clone for reverse toggling")),H0);let Ym=En;Mn([E(ge)],Ym.prototype,"target",2),Mn([E()],Ym.prototype,"toggleOnClick",2),Mn([E()],Ym.prototype,"targetState",2),Mn([E()],Ym.prototype,"hideSelf",2);class YO extends Pe{constructor(){super(...arguments),p(this,"wasVisible",!1)}start(){ie.setActive(this.gameObject,!1)}createBehaviours(e,i,s){i.uuid===this.gameObject.uuid&&(this.wasVisible||e.addBehavior(new Gs("HideOnStart_"+this.gameObject.name,Ns.sceneStartTrigger(),vi.fadeAction(i,0,!1))))}beforeCreateDocument(){this.wasVisible=ie.isActiveSelf(this.gameObject)}}class j0 extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"duration",.5),p(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(e,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new Gs("emphasize "+this.name,Ns.tapTrigger(this.gameObject),vi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,i){}}Mn([E()],j0.prototype,"target",2),Mn([E()],j0.prototype,"duration",2),Mn([E()],j0.prototype,"motionType",2);class ju extends Pe{constructor(){super(...arguments),p(this,"target"),p(this,"clip",""),p(this,"toggleOnClick",!1),p(this,"trigger","tap")}start(){$A(this.gameObject)}ensureAudioSource(){if(!this.target){const e=this.gameObject.addComponent(Cn);e&&(this.target=e,e.spatialBlend=1,e.volume=1,e.loop=!1,e.preload=!0)}}onPointerClick(e){var i;e.use(),!(!((i=this.target)!=null&&i.clip)&&!this.clip)&&(this.ensureAudioSource(),this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play())))}createBehaviours(e,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const o=this.target?this.target.gameObject:this.gameObject;vp.getName(r);const a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let c=!1;this.gameObject.traverse(m=>{m instanceof ue&&m.visible&&(c=!0)}),c=!0;const h=e.addAudioClip(r);let d=vi.playAudioAction(o,h,"play",a,l);this.target&&this.target.loop&&(d=vi.sequence(d).makeLooping());const u=this.name?"_"+this.name:"";if(c&&this.trigger==="tap"){this.toggleOnClick&&(d.multiplePerformOperation="stop");const m=new Gs("playAudio"+u,Ns.tapTrigger(i),d);e.addBehavior(m)}if(this.target&&this.target.playOnAwake&&this.target.enabled)if(c&&this.trigger==="tap")console.warn("USDZExport: Audio sources that are played on tap can't also auto-play at scene start due to a QuickLook bug.");else{const m=new Gs("playAudioOnStart"+u,Ns.sceneStartTrigger(),d);e.addBehavior(m)}}}}Mn([E(Cn)],ju.prototype,"target",2),Mn([E(URL)],ju.prototype,"clip",2),Mn([E()],ju.prototype,"toggleOnClick",2);var SM;const Fc=(SM=class extends Pe{constructor(){super(...arguments),p(this,"animator"),p(this,"stateName"),p(this,"trigger","tap"),p(this,"animation"),p(this,"selfModel"),p(this,"stateAnimationModel"),p(this,"animationSequence",new Array),p(this,"animationLoopAfterSequence",new Array),p(this,"randomOffsetNormalized",0)}get target(){var n,e;return((n=this.animator)==null?void 0:n.gameObject)||((e=this.animation)==null?void 0:e.gameObject)}start(){$A(this.gameObject)}onPointerClick(n){var e;n.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(n,e,i){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Fc.rootsWithExclusivePlayback.size>1){const n='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';je()&&Oi(n),console.warn(n,...Fc.rootsWithExclusivePlayback)}Fc.animationActions=[],Fc.rootsWithExclusivePlayback=new Set}afterCreateDocument(n,e){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const i=e.document,s=e.extensions.find(a=>a instanceof SA);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(je()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Fc.rootsWithExclusivePlayback.add(this.target));const o=this.name?this.name:"";i.traverse(a=>{var l,c;if(a.uuid===((l=this.target)==null?void 0:l.uuid)){const h=Fc.getActionForSequences(i,a,this.animationSequence,this.animationLoopAfterSequence,this.randomOffsetNormalized),d=new Gs(this.trigger+"_"+o+"_toPlayAnimation_"+this.stateName+"_on_"+((c=this.target)==null?void 0:c.name),this.trigger=="tap"?Ns.tapTrigger(this.selfModel):Ns.sceneStartTrigger(),h);r&&d.makeExclusive(!0),n.addBehavior(d)}})}static getActionForSequences(n,e,i,s,r){const o=(l,c)=>{let h=Fc.animationActions.find(d=>d.affectedObjects==l&&d.start==c.start&&d.duration==c.duration&&d.animationSpeed==c.speed);return h||(h=vi.startAnimationAction(l,c),Fc.animationActions.push(h)),h},a=vi.sequence();if(i&&i.length>0)for(const l of i)a.addAction(o(e,l));if(s&&s.length>0){const l=a.actions.length==0?a:vi.sequence();for(const c of s)l.addAction(o(e,c));l.makeLooping(),a!==l&&a.addAction(l)}return r&&r>0&&a.actions.unshift(vi.waitAction(r)),a}static getAndRegisterAnimationSequences(n,e,i){var s,r,o,a,l,c,h,d;if(!e)return;const u=e.getComponent(sr),m=e.getComponent(zr);if(!u&&!m)return;if(u&&!i)throw new Error("PlayAnimationOnClick: No stateName specified for animator "+u.name+" on "+e.name);let f=[],g=[];if(m){const _=n.registerAnimation(e,m.clip);_&&(m.loop?g.push(_):f.push(_));let S=0;if(m.minMaxOffsetNormalized){const C=m.minMaxOffsetNormalized.x,R=m.minMaxOffsetNormalized.y;S=(((s=m.clip)==null?void 0:s.duration)||1)*(C+Math.random()*(R-C))}return{animationSequence:f,animationLoopAfterSequence:g,randomTimeOffset:S}}const v=u?.runtimeAnimatorController;let y=v?.findState(i),b=[],A=[];if(v&&y){const _=new Array;_.push(y);let S=!1;for(;_.length<100;){if(!y||y===null||!y.transitions||y.transitions.length===0){(r=y.motion)!=null&&r.isLooping&&(S=!0);break}const C=y.transitions.find(P=>P.conditions.length===0),R=C?v.getState(C.destinationState,0):null;if(R&&_.includes(R)){y=R,S=!0;break}else if(C){if(y=R,!y)break;_.push(y)}else{S=((o=y.motion)==null?void 0:o.isLooping)??!1;break}}if(S&&y){const C=_.indexOf(y);b=_.slice(0,C),A=_.slice(C),zQ&&console.log("found loop from "+i,"states until loop",b,"states looping",A)}else b=_,A=[],zQ&&console.log("found no loop from "+i,"states",b);if(!A.length){const C=b[b.length-1],R=(a=C.motion)==null?void 0:a.clip;if(R){let P;if(n.holdClipMap.has(R))P=n.holdClipMap.get(R);else{const T=C.name+"_hold";P=R.clone(),P.duration=1,P.name=T;const L=R.duration;P.tracks=R.tracks.map(k=>{const G=k.clone();G.times=new Float32Array([0,L]);const O=k.values.length,W=k.getValueSize(),D=k.values.slice(O-W,O);return G.values=new Float32Array(2*W),G.values.set(D,0),G.values.set(D,W),G}),P.name=T,n.holdClipMap.set(R,P)}if(P){const T={name:P.name,motion:{clip:P,isLooping:!1,name:P.name},speed:1,transitions:[],behaviours:[],hash:C.hash+1};A.push(T)}}}}if(b.length===1&&(!((l=b[0].motion)!=null&&l.clip)||((h=(c=b[0].motion)==null?void 0:c.clip.tracks)==null?void 0:h.length)===0)){f=new Array;const _=n.registerAnimation(e,null);_&&f.push(_);return}if(b=b.filter(_=>{var S,C,R;return((S=_.motion)==null?void 0:S.clip)&&((R=(C=_.motion)==null?void 0:C.clip.tracks)==null?void 0:R.length)>0}),A=A.filter(_=>{var S,C,R;return((S=_.motion)==null?void 0:S.clip)&&((R=(C=_.motion)==null?void 0:C.clip.tracks)==null?void 0:R.length)>0}),b.length===0&&A.length===0){console.warn("No clips found for state "+i+" on "+u?.name+", can't export animation data");return}const x=(_,S)=>{if(!e)return;const C=n.registerAnimation(e,_.motion.clip??null);C?(C.speed=_.speed,S.push(C)):console.warn("Couldn't register animation for state "+_.name+" on "+u?.name)};if(b.length>0){f=new Array;for(const _ of b)x(_,f)}if(A.length>0){g=new Array;for(const _ of A)x(_,g)}let w=0;if(u&&v&&u.minMaxOffsetNormalized){const _=u.minMaxOffsetNormalized.x,S=u.minMaxOffsetNormalized.y,C=b.length?b[0]:A.length?A[0]:null;w=(((d=C?.motion.clip)==null?void 0:d.duration)||1)*(_+Math.random()*(S-_))}return{animationSequence:f,animationLoopAfterSequence:g,randomTimeOffset:w}}createAnimation(n,e,i){if(!this.target||!this.animator&&!this.animation)return;const s=Fc.getAndRegisterAnimationSequences(n,this.target,this.stateName);s&&(this.animationSequence=s.animationSequence,this.animationLoopAfterSequence=s.animationLoopAfterSequence,this.randomOffsetNormalized=s.randomTimeOffset,this.stateAnimationModel=e)}},p(SM,"animationActions",[]),p(SM,"rootsWithExclusivePlayback",new Set),SM);let Km=Fc;Mn([E(sr)],Km.prototype,"animator",2),Mn([E()],Km.prototype,"stateName",2);class Q0 extends Pe{constructor(){super(...arguments),p(this,"target")}getType(){}getDuration(){}}Mn([E(ge)],Q0.prototype,"target",2);class ex extends Pe{constructor(){super(...arguments),p(this,"target")}}Mn([E(Q0)],ex.prototype,"target",2);class tx extends Q0{constructor(){super(...arguments),p(this,"type",1),p(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Mn([E()],tx.prototype,"type",2),Mn([E()],tx.prototype,"duration",2);class KO extends ex{}var Ove=Object.defineProperty,Dve=Object.getOwnPropertyDescriptor,id=(n,e,i,s)=>{for(var r=s>1?void 0:s?Dve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Ove(e,i,r),r};const UQ=te("debugcharactercontroller");class Jm extends Pe{constructor(){super(...arguments),p(this,"center",new M(0,0,0)),p(this,"radius",.5),p(this,"height",2),p(this,"_rigidbody",null),p(this,"_activeGroundCollisions"),p(this,"_contactVelocity",new M)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ci),this._rigidbody||(this._rigidbody=this.gameObject.addComponent(Ci)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let i=this.gameObject.getComponent(ed);i||(i=this.gameObject.addComponent(ed)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new M(0,0,1),r=new M(1,0,0),o=new M(0,1,0),a=this.gameObject.getWorldDirection(new M);a.y=0;const l=r.dot(a)<0?-1:1,c=s.angleTo(a)*l;this.gameObject.setRotationFromAxisAngle(o,c),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(i=>i.normal.y>.2))&&(this._activeGroundCollisions.add(e),UQ&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(i=>i.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),UQ&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const i of this._activeGroundCollisions){const s=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(i.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}id([E(M)],Jm.prototype,"center",2),id([E()],Jm.prototype,"radius",2),id([E()],Jm.prototype,"height",2);class nd extends Pe{constructor(){super(...arguments),p(this,"controller"),p(this,"movementSpeed",2),p(this,"rotationSpeed",2),p(this,"jumpForce",1),p(this,"doubleJumpForce",2),p(this,"animator"),p(this,"lookForward",!0),p(this,"lookInput",new K(0,0)),p(this,"moveInput",new K(0,0)),p(this,"jumpInput",!1),p(this,"_currentSpeed",new M(0,0,0)),p(this,"_currentAngularSpeed",new M(0,0,0)),p(this,"_temp",new M(0,0,0)),p(this,"_jumpCount",0),p(this,"_currentRotation"),p(this,"_raycastOptions",new Ac)}awake(){this._currentRotation=new Se}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,i,s){var r,o,a,l,c,h,d,u,m,f,g;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",e.length()>.01),(c=this.animator)==null||c.setBool("jumping",((l=this.controller)==null?void 0:l.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=et.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new M(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(h=this.controller)==null?void 0:h.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(u=this.animator)==null||u.setBool("doubleJump",!0)),v){this._jumpCount+=1;const y=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;y.applyImpulse(new M(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(m=this.controller)==null?void 0:m.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new qr),this._raycastOptions.ray.origin.copy(Nt(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const y=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(y),(b.length&&b[0].distance>2||v<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(g=this.animator)==null||g.setBool("falling",!1)}}}id([E(Jm)],nd.prototype,"controller",2),id([E()],nd.prototype,"movementSpeed",2),id([E()],nd.prototype,"rotationSpeed",2),id([E()],nd.prototype,"jumpForce",2),id([E()],nd.prototype,"doubleJumpForce",2),id([E(sr)],nd.prototype,"animator",2);var Gve=Object.defineProperty,Nve=Object.getOwnPropertyDescriptor,Fve=(n,e,i,s)=>{for(var r=s>1?void 0:s?Nve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Gve(e,i,r),r};class ix extends Us{constructor(){super(...arguments),p(this,"intensity",new qe(0))}get typeName(){return"ChromaticAberration"}onCreateEffect(){const e=new eV;return e.offset=new K(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{e.offset.x=-i,e.offset.y=i},e}}Fve([E(qe)],ix.prototype,"intensity",2),Ja("ChromaticAberration",ix);var zve=Object.defineProperty,Uve=Object.getOwnPropertyDescriptor,VQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?Uve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&zve(e,i,r),r};const XQ=te("debugpost");var CM=(n=>(n[n.None=0]="None",n[n.Neutral=1]="Neutral",n[n.ACES=2]="ACES",n[n.AgX=3]="AgX",n[n.KhronosNeutral=4]="KhronosNeutral",n))(CM||{});function JO(n){switch(n){case 0:return Pf;case 1:return tv;case 2:return iv;case 3:return kf;case 4:return Cp;default:return Cp}}function Vve(n){switch(n){case Pf:return 0;case iv:return 2;case kf:return 3;case Cp:return 1;case tv:return 1;default:return 0}}function WQ(n){switch(n){case Pf:return As.LINEAR;case iv:return As.ACES_FILMIC;case kf:return As.AGX;case Cp:return As.NEUTRAL;case tv:return As.REINHARD;default:return As.LINEAR}}const HQ=class extends Us{constructor(){super(...arguments),p(this,"mode",new qe(void 0)),p(this,"exposure",new qe(1))}get typeName(){return"ToneMapping"}setMode(n){const e=CM[n];return e===void 0?(console.error("Invalid ToneMapping mode",n),this):(this.mode.value=e,this)}get isToneMapping(){return!0}onEffectEnabled(){const n=gQ(this);n&&super.onEffectEnabled(n)}onCreateEffect(){if(this.postprocessingContext)for(const i of this.postprocessingContext.components){if(i===this)break;if(i!=this&&i instanceof HQ){console.warn("Multiple tonemapping effects found in the same postprocessing stack: Please check your scene setup.",{activeEffect:i,ignoredEffect:this});return}}if(this.mode.isInitialized==!1){const i=Vve(this.context.renderer.toneMapping);this.mode.initialize(i)}const n=JO(this.mode.value),e=new F_({mode:WQ(n)});return this.mode.onValueChanged=i=>{const s=JO(i);e.mode=WQ(s),XQ&&console.log("ToneMapping mode changed to",CM[i],s,e.mode)},XQ&&console.log("Use ToneMapping",CM[this.mode.value],n,e.mode,"renderer.tonemapping: "+this.context.renderer.toneMapping),this.exposure.onValueChanged=i=>{this.context.renderer.toneMappingExposure=i},e}onBeforeRender(){this.mode.overrideState&&(this.context.renderer.toneMapping=JO(this.mode.value)),this.exposure.overrideState&&(this.context.renderer.toneMappingExposure=this.exposure.value)}};let Qu=HQ;VQ([E(qe)],Qu.prototype,"mode",2),VQ([E(qe)],Qu.prototype,"exposure",2),Ja("Tonemapping",Qu);var Xve=Object.defineProperty,Wve=Object.getOwnPropertyDescriptor,MM=(n,e,i,s)=>{for(var r=s>1?void 0:s?Wve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Xve(e,i,r),r};class Zu extends Us{constructor(){super(...arguments),p(this,"postExposure",new qe(0)),p(this,"contrast",new qe(0)),p(this,"hueShift",new qe(0)),p(this,"saturation",new qe(0))}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.contrast.valueProcessor=e=>{let i=1;return e>0?i=200:e<0&&(i=100),e/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}onCreateEffect(){var e,i;const s=[];this.context.renderer.toneMapping!==Yr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Yr);let r=(e=this.postprocessingContext)==null?void 0:e.components.find(l=>l instanceof Qu);r||(r=new Qu,(i=this.postprocessingContext)==null||i.components.push(r)),this.postExposure.onValueChanged=l=>{this.postExposure.overrideState&&(r.exposure.value=l)};const o=new $5;this.contrast.onValueChanged=l=>o.contrast=l;const a=new sV;return s.push(o),s.push(a),this.hueShift.onValueChanged=l=>a.hue=l,this.saturation.onValueChanged=l=>a.saturation=l,s}}MM([E(qe)],Zu.prototype,"postExposure",2),MM([E(qe)],Zu.prototype,"contrast",2),MM([E(qe)],Zu.prototype,"hueShift",2),MM([E(qe)],Zu.prototype,"saturation",2),Ja("ColorAdjustments",Zu);const jQ=Math.sqrt(5),Hve=(jQ-1)/4,cr=(5-jQ)/20,EM=n=>Math.floor(n)|0,TM=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function jve(n=Math.random){const e=Qve(n),i=new Float64Array(e).map(a=>TM[a%32*4]),s=new Float64Array(e).map(a=>TM[a%32*4+1]),r=new Float64Array(e).map(a=>TM[a%32*4+2]),o=new Float64Array(e).map(a=>TM[a%32*4+3]);return function(a,l,c,h){let d,u,m,f,g;const v=(a+l+c+h)*Hve,y=EM(a+v),b=EM(l+v),A=EM(c+v),x=EM(h+v),w=(y+b+A+x)*cr,_=y-w,S=b-w,C=A-w,R=x-w,P=a-_,T=l-S,L=c-C,k=h-R;let G=0,O=0,W=0,D=0;P>T?G++:O++,P>L?G++:W++,P>k?G++:D++,T>L?O++:W++,T>k?O++:D++,L>k?W++:D++;const F=G>=3?1:0,U=O>=3?1:0,Y=W>=3?1:0,q=D>=3?1:0,oe=G>=2?1:0,xe=O>=2?1:0,Be=W>=2?1:0,re=D>=2?1:0,_e=G>=1?1:0,Ie=O>=1?1:0,We=W>=1?1:0,Ze=D>=1?1:0,Ge=P-F+cr,rt=T-U+cr,ye=L-Y+cr,Q=k-q+cr,ze=P-oe+2*cr,Te=T-xe+2*cr,Ee=L-Be+2*cr,He=k-re+2*cr,be=P-_e+3*cr,nt=T-Ie+3*cr,ct=L-We+3*cr,It=k-Ze+3*cr,H=P-1+4*cr,N=T-1+4*cr,de=L-1+4*cr,Me=k-1+4*cr,Oe=y&255,Le=b&255,xt=A&255,dt=x&255;let Ue=.6-P*P-T*T-L*L-k*k;if(Ue<0)d=0;else{const De=Oe+e[Le+e[xt+e[dt]]];Ue*=Ue,d=Ue*Ue*(i[De]*P+s[De]*T+r[De]*L+o[De]*k)}let Xe=.6-Ge*Ge-rt*rt-ye*ye-Q*Q;if(Xe<0)u=0;else{const De=Oe+F+e[Le+U+e[xt+Y+e[dt+q]]];Xe*=Xe,u=Xe*Xe*(i[De]*Ge+s[De]*rt+r[De]*ye+o[De]*Q)}let Ct=.6-ze*ze-Te*Te-Ee*Ee-He*He;if(Ct<0)m=0;else{const De=Oe+oe+e[Le+xe+e[xt+Be+e[dt+re]]];Ct*=Ct,m=Ct*Ct*(i[De]*ze+s[De]*Te+r[De]*Ee+o[De]*He)}let Ne=.6-be*be-nt*nt-ct*ct-It*It;if(Ne<0)f=0;else{const De=Oe+_e+e[Le+Ie+e[xt+We+e[dt+Ze]]];Ne*=Ne,f=Ne*Ne*(i[De]*be+s[De]*nt+r[De]*ct+o[De]*It)}let qt=.6-H*H-N*N-de*de-Me*Me;if(qt<0)g=0;else{const De=Oe+1+e[Le+1+e[xt+1+e[dt+1]]];qt*=qt,g=qt*qt*(i[De]*H+s[De]*N+r[De]*de+o[De]*Me)}return 27*(d+u+m+f+g)}}function Qve(n){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=e[i];e[i]=e[s],e[s]=r}for(let i=256;i<512;i++)e[i]=e[i-256];return e}const qO=te("debugstencil");function Zve(n,e){return(n&1<<e.layer)!=0}const Yve=Symbol("stencils"),Z0=class{constructor(n,e){p(this,"parser"),p(this,"source"),this.parser=n,this.source=e}get name(){return"NEEDLE_render_objects"}static applyStencil(n){if(!n)return;const e=n.sourceId;if(qO&&console.log(e,Z0.stencils),!e)return;const i=Z0.stencils[e];if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];if(Zve(r.layer,n)){qO&&console.log(r),setTimeout(()=>{io()&&pC(n.gameObject)&&(Oi("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",n))},500);for(let o=0;o<n.sharedMaterials.length;o++){let a=n.sharedMaterials[o];a&&(a=a.clone(),a[Yve]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=r.value,a.stencilFunc=r.compareFunc,a.stencilZPass=r.passOp,a.stencilFail=r.failOp,a.stencilZFail=r.zFailOp,n.sharedMaterials[o]=a)}n.gameObject.renderOrder=r.event*1e3+r.index*50;break}}}afterRoot(n){const e=this.parser.json.extensions;if(e){const i=e[Jve];if(i){qO&&console.log(i);const s=i.stencil;if(s&&Array.isArray(s))for(const r of s){const o={...r};o.compareFunc=Kve(o.compareFunc),o.passOp=eD(o.passOp),o.failOp=eD(o.failOp),o.zFailOp=eD(o.zFailOp),Z0.stencils[this.source]||(Z0.stencils[this.source]=[]),Z0.stencils[this.source].push(o)}}}return null}};let $O=Z0;p($O,"stencils",{});function eD(n){switch(n){case 0:return kd;case 1:return pN;case 2:return mN;case 3:return fN;case 4:return gN;case 6:return yN;case 7:return vN;case 5:return bN}return 0}function Kve(n){switch(n){case 1:return GR;case 2:return AN;case 3:return xN;case 4:return wN;case 5:return _N;case 6:return SN;case 7:return CN;case 8:return Y1}return GR}const Jve="NEEDLE_render_objects";var qve=Object.defineProperty,$ve=Object.getOwnPropertyDescriptor,QQ=(n,e,i,s)=>{for(var r=s>1?void 0:s?$ve(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&qve(e,i,r),r};const RM=te("debugreflectionprobe"),ZQ=te("noreflectionprobe"),ebe=Symbol("reflectionProbeKey"),tbe=Symbol("original material");var IM;const sd=(IM=class extends Pe{constructor(){var n;super(),p(this,"_texture"),p(this,"center"),p(this,"size"),p(this,"_boxHelper"),sd._probes.has(this.context)||sd._probes.set(this.context,[]),(n=sd._probes.get(this.context))==null||n.push(this)}static get(n,e,i,s){if(!n||n.isObject3D!==!0||ZQ)return null;const r=sd._probes.get(e);if(r){for(const o of r)if(o.__didAwake||o.__internalAwake(),o.enabled&&s&&o.gameObject===s)return o}return RM&&console.debug("Did not find reflection probe",n.name,i,n),null}set texture(n){if(n&&!(n instanceof Vt)){console.error("ReflectionProbe.texture must be a Texture",n);return}this._texture=n,n&&(n.mapping=Kr,n.colorSpace=vt,n.needsUpdate=!0)}get texture(){return this._texture}isInBox(n){var e;return(e=this._boxHelper)==null?void 0:e.isInBox(n)}awake(){this._boxHelper=this.gameObject.addComponent(qa),this._boxHelper.updateBox(!0),RM&&this._boxHelper.showHelper(5592320,!0),this.texture&&(this.texture.mapping=Kr,this.texture.colorSpace=vt,this.texture.needsUpdate=!0)}onDestroy(){const n=sd._probes.get(this.context);if(n){const e=n.indexOf(this);e>=0&&n.splice(e,1)}}onSet(n){var e;if(ZQ||!this.enabled||((e=n.sharedMaterials)==null?void 0:e.length)<=0||!this.texture)return;let i=sd._rendererMaterialsCache.get(n);i||(i=[],sd._rendererMaterialsCache.set(n,i));for(let s=0;s<n.sharedMaterials.length;s++){const r=n.sharedMaterials[s];if(!r||r.envMap===void 0||r instanceof Ht)continue;let o=i[s];const a=r===o?.copy,l=!o||o.material.uuid!==r.uuid||o.copy.version!==r.version;if(!a&&l){if(RM){let d="";o?o.material!==r?d="reference changed; cached instance?: "+a:o.copy.version!==r.version&&(d="version changed"):d="not cached",console.warn("Cloning material",r.name,r.version,"Reason:",d,`
|
|
5980
5980
|
`,r.uuid,`
|
|
5981
5981
|
`,o?.copy.uuid,`
|
|
5982
5982
|
`,n.name)}const h=r.clone();h.version=r.version,o?(o.copy=h,o.material=r):(o={material:r,copy:h},i.push(o)),h[ebe]=this,h[tbe]=r,RM&&console.log("Set reflection",n.name,n.guid)}o&&o.copy&&(o.copy.onBeforeCompile=r.onBeforeCompile);const c=o?.copy;c.envMap=this.texture,n.sharedMaterials[s]=c}}onUnset(n){const e=sd._rendererMaterialsCache.get(n);if(e)for(let i=0;i<e.length;i++){const s=e[i];n.sharedMaterials[i]=s.material}}},p(IM,"_probes",new Map),p(IM,"_rendererMaterialsCache",new Map),IM);let Y0=sd;QQ([E(M)],Y0.prototype,"center",2),QQ([E(M)],Y0.prototype,"size",2);const tD=te("debugexr");class ibe{constructor(e){p(this,"parser"),this.parser=e,tD&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const i=this.name,s=this.parser,r=s.json.textures[e];if(tD&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[i])return null;const o=r.extensions[i],a=new pA(s.options.manager);return tD&&console.log("EXT_texture_exr.loadTexture",o),s.loadTextureImage(e,o.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",n=>{});const rd=Ds,LM="$___Export_Components",nbe="NEEDLE_components";var YQ;class sbe{constructor(){p(this,YQ)}}YQ=om;class rbe{constructor(e,i,s){p(this,"node"),p(this,"nodeIndex"),p(this,"nodeDef"),this.node=e,this.nodeIndex=i,this.nodeDef=s}}class obe{constructor(){p(this,"parser"),p(this,"nodeToObjectMap",{}),p(this,"gltf",null),p(this,"exportContext"),p(this,"objectToNodeMap",{}),p(this,"context"),p(this,"writer")}get name(){return nbe}registerExport(e){e.register(i=>{if("serializeUserData"in i){const s=i.serializeUserData.bind(i);this.writer=i,i.serializeUserData=(r,o)=>{try{this.serializeUserData(r,o),s(r,o)}finally{this.afterSerializeUserData(r,o)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,i){var s;const r=(s=e.userData)==null?void 0:s.components;!r||r.length<=0||(delete e.userData.components,e[LM]=r)}afterSerializeUserData(e,i){if(e.type==="Scene"&&rd&&console.log("DONE",JSON.stringify(i)),e[LM]===void 0)return;const s=e[LM];delete e[LM],s!==null&&(e.userData.components=s)}writeNode(e,i){const s=this.writer.json.nodes.length;rd&&console.log(e.name,s,e.uuid);const r=new rbe(e,s,i);this.exportContext[s]=r,this.objectToNodeMap[e.uuid]=s}afterParse(e){var i;rd&&console.log("AFTER",e);for(const s in this.exportContext){const r=this.exportContext[s],o=r.node,a=r.nodeDef,l=r.nodeIndex,c=(i=o.userData)==null?void 0:i.components;if(!c||c.length<=0)continue;const h=new sbe;a.extensions=a.extensions||{},a.extensions[this.name]=h,this.context.object=o,this.context.nodeId=l,this.context.objectToNode=this.objectToNodeMap;const d=[];for(const u of c){this.context.target=u;const m=vl().writeBuiltinComponentData(u,this.context);m!==null&&d.push(m)}d.length>0&&(h[om]=d,rd&&console.log("DID WRITE",o,"nodeIndex",l,d))}}beforeRoot(){return rd&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){this.gltf=e;const i=e.parser,s=i?.extensions;if(!s)return;const r=s[this.name];rd&&console.log("After root",e,this.parser,s);const o=[];if(r===!0){const a=i.json.nodes;if(a){for(let l=0;l<a.length;l++){const c=await i.getDependency("node",l);this.nodeToObjectMap[l]=c}for(let l=0;l<a.length;l++){const c=a[l],h=l,d=c.extensions;if(!d)continue;const u=d[this.name];if(!u)continue;rd&&console.log("NODE",c);const m=this.nodeToObjectMap[h];if(!m){console.error("Could not find object for node index: "+h,c,i);continue}hC(m),o.push(this.createComponents(m,u))}}}await Promise.all(o);for(const a of i.associations.keys()){const l=i.associations.get(a);if(l?.materials!=null){const c="/materials/"+l.materials;Dme(a,c)}}}async createComponents(e,i){if(!i)return;const s=i[om];if(s){const r=new Array;rd&&console.log(e.name,s);for(const o in s){const a=s[o];rd&&console.log("Serialized data",JSON.parse(JSON.stringify(a))),a&&this.parser&&r.push(Kk(this.parser,a).catch(l=>console.error(`Error while resolving references (see console for details)
|
|
5983
|
-
`,l,e,a))),e.userData=e.userData||{},e.userData[om]=e.userData[om]||[],e.userData[om].push(a)}await Promise.all(r).catch(o=>{console.error("Error while loading components",o)})}}}const KQ="NEEDLE_gameobject_data";class abe{constructor(e){p(this,"parser"),this.parser=e}get name(){return KQ}afterRoot(e){var i;const s=[];for(let r=0;r<((i=this.parser.json.nodes)==null?void 0:i.length);r++){const o=this.parser.json.nodes[r];if(o&&o.extensions){const a=o.extensions[KQ];if(a){const l=this.findAndApplyExtensionData(r,a);s.push(l)}}}return Promise.all(s).then(()=>null)}async findAndApplyExtensionData(e,i){const s=await this.parser.getDependency("node",e);s&&this.applyExtensionData(s,i)}applyExtensionData(e,i){i.layers===void 0&&(i.layers=0),e.userData.layer=i.layers,e.layers.disableAll(),e.layers.set(i.layers),e.userData.tag=i.tag??"none",e.userData.hideFlags=i.hideFlags??0,e.userData.static=i.static??!1,e.visible=i.activeSelf??!0,e.guid=i.guid}}const JQ="NEEDLE_lighting_settings",K0=te("debugenvlight");class lbe{constructor(e,i,s){p(this,"parser"),p(this,"sourceId"),p(this,"context"),this.parser=e,this.sourceId=i,this.context=s}get name(){return JQ}afterRoot(e){const i=this.parser.json.extensions;if(i){const s=i[JQ];if(s){K0&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',s);let r;if(e.scene.children.length===1){const o=e.scene.children[0];r=ie.addComponent(o,PM,{},{callAwake:!1})}else{const o=new ge;o.name="LightSettings "+this.sourceId,e.scene.add(o),r=ie.addComponent(o,PM,{},{callAwake:!1})}r.sourceId=this.sourceId,r.ambientIntensity=s.ambientIntensity,r.ambientLight=new Ae().fromArray(s.ambientLight),Array.isArray(s.ambientTrilight)&&(r.ambientTrilight=s.ambientTrilight.map(o=>new Ae().fromArray(o))),r.ambientMode=s.ambientMode,r.environmentReflectionSource=s.environmentReflectionSource}}return null}}xi.registerCallback(_i.ContextCreated,n=>{const e=n.context,i=ie.findObjectOfType(PM,e);i!=null&&i.sourceId&&(i.enabled=!0)});class PM extends Pe{constructor(){super(...arguments),p(this,"ambientMode",A0.Skybox),p(this,"ambientLight"),p(this,"ambientTrilight"),p(this,"ambientIntensity",1),p(this,"environmentReflectionSource",LC.Skybox),p(this,"_hasReflection",!1),p(this,"_ambientLightObj"),p(this,"_hemisphereLightObj")}awake(){var e;if(this.sourceId){const s=this.environmentReflectionSource===LC.Skybox?Su.Skybox:Su.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,s,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),K0&&window.addEventListener("keydown",s=>{if(!this.destroyed)switch(s.key){case"l":this.enabled=!this.enabled;break}});const i=(e=this.gameObject.userData)==null?void 0:e.components;if(i){const s=i.indexOf(this);i.splice(s,1),i.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const i=Math.max(e.r,e.g,e.b);return 2.2*et.lerp(0,1.33,i)}onEnable(){if(K0&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==A0.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new qw(this.ambientLight,this.ambientIntensity*e),K0&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===A0.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],i=this.ambientTrilight[this.ambientTrilight.length-1],s=this.calculateIntensityFactor(i);this._hemisphereLightObj=new eI(i,e,this.ambientIntensity*s),this.gameObject.add(this._hemisphereLightObj),K0&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,s)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){K0&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var qQ=(n=>(n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_3D=35680]="SAMPLER_3D",n[n.SAMPLER_CUBE=35681]="SAMPLER_CUBE",n[n.UNKNOWN=0]="UNKNOWN",n))(qQ||{});const zc=te("debugcustomshader"),J0="NEEDLE_techniques_webgl";class cbe{constructor(){p(this,"objectToWorldMatrix",new he),p(this,"worldToObjectMatrix",new he),p(this,"objectToWorld",new Array),p(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),IC(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),IC(this.worldToObjectMatrix,this.worldToObject)}}const Tn=class extends Zw{constructor(n,...e){super(...e),p(this,"identifier"),p(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),p(this,"_sphericalHarmonicsName","unity_SpecCube0"),p(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),p(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),p(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),p(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),p(this,"_rendererData",new cbe),this.identifier=n,zc&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&Pt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const n=super.clone();return $Q(n),n}dispose(){super.dispose();const n=Pt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);n>=0&&Pt.Current.pre_render_callbacks.splice(n,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Pt.Current.setRequireColor(!0),this.depthTextureUniform&&Pt.Current.setRequireDepth(!0)}onBeforeRender(n,e,i,s,r,o){s.attributes.tangent||s.computeTangents(),this.onUpdateUniforms(i,r)}onUpdateUniforms(n,e){const i=Pt.Current;if(n&&(Tn.viewProjection&&this.uniforms[this._viewProjectionName]&&(Tn.viewProjection.copy(n.projectionMatrix).multiply(n.matrixWorldInverse),IC(Tn.viewProjection,Tn._viewProjectionValues)),Tn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Tn.viewMatrix.copy(n.matrixWorldInverse),IC(Tn.viewMatrix,Tn._viewMatrixValues)),this.uniforms[Tn._worldSpaceCameraPosName]&&Tn._worldSpaceCameraPos.setFromMatrixPosition(n.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=i.sceneLighting.timeVec4),this.uniforms._Time){const a=this.uniforms._Time.value;a.x=i.sceneLighting.timeVec4.x/20,a.y=i.sceneLighting.timeVec4.x,a.z=i.sceneLighting.timeVec4.x*2,a.w=i.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const a=this.uniforms._SinTime.value;a.x=Math.sin(i.sceneLighting.timeVec4.x/8),a.y=Math.sin(i.sceneLighting.timeVec4.x/4),a.z=Math.sin(i.sceneLighting.timeVec4.x/2),a.w=Math.sin(i.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const a=this.uniforms._CosTime.value;a.x=Math.cos(i.sceneLighting.timeVec4.x/8),a.y=Math.cos(i.sceneLighting.timeVec4.x/4),a.z=Math.cos(i.sceneLighting.timeVec4.x/2),a.w=Math.cos(i.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const a=this.uniforms.unity_DeltaTime.value;a.x=i.time.deltaTime,a.y=1/i.time.deltaTime,a.z=i.time.smoothedDeltaTime,a.w=1/i.time.smoothedDeltaTime}const s=i.mainLight;if(s){const a=Nt(s.gameObject,Tn._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},Tn._mainLightColor.set(s.color.r,s.color.g,s.color.b,0),this.uniforms._MainLightColor={value:Tn._mainLightColor};const l=s.intensity;Tn._lightData.z=l,this.uniforms.unity_LightData={value:Tn._lightData}}if(n&&(Tn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Tn._viewProjectionValues),Tn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Tn._viewMatrixValues),this.uniforms[Tn._worldSpaceCameraPosName]&&(this.uniforms[Tn._worldSpaceCameraPosName]={value:Tn._worldSpaceCameraPos}),i.mainCameraComponent)){if(this.uniforms._ProjectionParams){const a=this.uniforms._ProjectionParams.value;a.x=1,a.y=i.mainCameraComponent.nearClipPlane,a.z=i.mainCameraComponent.farClipPlane,a.w=1/a.z,this.uniforms._ProjectionParams.value=a}if(this.uniforms._ZBufferParams){const a=this.uniforms._ZBufferParams.value,l=i.mainCameraComponent;a.x=1-l.farClipPlane/l.nearClipPlane,a.y=l.farClipPlane/l.nearClipPlane,a.z=a.x/l.farClipPlane,a.w=a.y/l.farClipPlane,this.uniforms._ZBufferParams.value=a}if(this.uniforms._ScreenParams){const a=this.uniforms._ScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScreenParams.value=a}if(this.uniforms._ScaledScreenParams){const a=this.uniforms._ScaledScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScaledScreenParams.value=a}}const r=this.depthTextureUniform;r&&(r.value=i.depthTexture);const o=this.opaqueTextureUniform;if(o&&(o.value=i.opaqueColorTexture),e){const a=this._rendererData;a.updateFrom(e),this.uniforms[this._worldToObjectName].value=a.worldToObject,this.uniforms[this._objToWorldName].value=a.objectToWorld}this.uniformsNeedUpdate=!0}};let Wl=Tn;p(Wl,"viewProjection",new he),p(Wl,"_viewProjectionValues",[]),p(Wl,"viewMatrix",new he),p(Wl,"_viewMatrixValues",[]),p(Wl,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),p(Wl,"_worldSpaceCameraPos",new M),p(Wl,"_mainLightColor",new Ke),p(Wl,"_mainLightPosition",new M),p(Wl,"_lightData",new Ke);class hbe{constructor(e,i){p(this,"parser"),p(this,"identifier"),this.parser=e,this.identifier=i}get name(){return J0}loadMaterial(e){const i=this.parser.json.materials[e];if(!i)return zc&&console.log(e,this.parser.json.materials),null;if(!i.extensions||!i.extensions[J0])return zc&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;zc&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,i);const s=i.extensions[J0].technique;if(s<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const r=this.parser.json.extensions[J0];if(!r)return zc?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;zc&&console.log(r);const o=r.techniques[s];return o?new Promise(async(a,l)=>{var c,h,d;const u=await Vfe(r,o.program),m=u?.fragmentShader,f=u?.vertexShader;if(!m||!f)return l();zc&&console.log("loadMaterial",i,u);const g={},v=o.uniforms;(f.includes("_Time")||m.includes("_Time"))&&(g._Time={value:new Ke(0,0,0,0)}),(f.includes("_SinTime")||m.includes("_SinTime"))&&(g._SinTime={value:new Ke(0,0,0,0)}),(f.includes("_CosTime")||m.includes("_CosTime"))&&(g._CosTime={value:new Ke(0,0,0,0)}),(f.includes("unity_DeltaTime")||m.includes("unity_DeltaTime"))&&(g.unity_DeltaTime={value:new Ke(0,0,0,0)});for(const A in v){const x=A;switch(x){case"_TimeParameters":const w=new Ke;g[x]={value:w};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":g[x]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":g[x]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":g[x]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":g[x]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":g[x]={value:null};break}}let y=!1;if(i.extensions&&i.extensions[J0]){const A=i.extensions[J0];if(A.technique===s){zc&&console.log(i.name,"Material Properties",A);for(const x in A.values){const w=A.values[x];if(typeof w=="string"){if(w.startsWith("/textures/")){const _=w.substring(10),S=Number.parseInt(_);if(S>=0){const C=await this.parser.getDependency("texture",S);C instanceof Vt&&(C.colorSpace=ki,C.needsUpdate=!0),g[x]={value:C};continue}}switch(x){case"alphaMode":w==="BLEND"&&(y=!0);continue}}if(Array.isArray(w)&&w.length===4){g[x]={value:new Ke(w[0],w[1],w[2],w[3])};continue}g[x]={value:w}}}}const b=new Wl(this.identifier,{name:i.name??"",uniforms:g,vertexShader:f,fragmentShader:m,lights:!1});switch(b.glslVersion=K1,b.vertexShader=b.vertexShader.replace("#version 300 es",""),b.fragmentShader=b.fragmentShader.replace("#version 300 es",""),(c=g._Cull)==null?void 0:c.value){case 0:b.side=Ai;break;case 1:b.side=dn;break;case 2:b.side=Vn;break;default:b.side=Vn;break}switch((h=g._ZTest)==null?void 0:h.value){case 3:b.depthTest=!0,b.depthFunc=Lf;break;case 6:b.depthTest=!0,b.depthFunc=$y;break;case 2:b.depthTest=!0,b.depthFunc=qy;break;case 4:b.depthTest=!0,b.depthFunc=Sp;break;case 5:b.depthTest=!0,b.depthFunc=k1;break;case 7:b.depthTest=!0,b.depthFunc=P1;break;case 8:b.depthTest=!1,b.depthFunc=L1;break}b.transparent=y,y&&(b.depthWrite=!1),zfe(g),b.onUpdateUniforms();for(const A in v){const x=A,w=v[A].type;if(((d=g[x])==null?void 0:d.value)===void 0)switch(w){case qQ.SAMPLER_2D:g[x]={value:Nfe},console.warn("Missing/unassigned texture, fallback to white: "+x);break;default:x==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+x,v[A]);break}}zc&&console.log(b.uuid,g),$Q(b),a(b)}):null}}function $Q(n){if(n.uniforms){zc&&console.log("Uniforms:",n.uniforms);for(const i in n.uniforms)switch(e(i,i),i){case"_Color":e("color",i);break}}function e(i,s){Object.getOwnPropertyDescriptor(n,i)||Object.defineProperty(n,i,{get:()=>n.uniforms[s].value,set:r=>{n.uniforms[s].value=r,n.needsUpdate=!0}})}}const dbe=te("debugextensions");let kM;const ube=Promise.resolve().then(()=>IMe).then(async n=>(kM=n.GLTFAnimationPointerExtension,kM)).catch(n=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",n)}),qm=new Array;function pbe(n){qm.includes(n)||qm.push(n)}function mbe(n){const e=qm.indexOf(n);e>=0&&qm.splice(e,1)}function BM(n){const e=new obe;return n.register(i=>(e.parser=i,e)),e}class fbe{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function OM(n,e,i){const s=i.indexOf("?");s>=0&&(i=i.substring(0,s)),n.register(r=>new abe(r)),n.register(r=>new Nme(r)),n.register(r=>new Bfe(r,e.lightmaps,i)),n.register(r=>new lbe(r,i,e)),n.register(r=>new hbe(r,i)),n.register(r=>new $O(r,i)),n.register(r=>new mi(r,i)),n.register(r=>new ibe(r)),A4()&&n.register(r=>new Bk(r)),await ube.catch(r=>{}),n.register(r=>{if(kM){const o=new kM(r);return o.setAnimationPointerResolver.bind(o)(new fbe),o}else return(dbe||je())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const r of qm)r.onImport&&r.onImport(n,i,e)}function iD(n,e){for(const i of qm)i.onExport&&i.onExport(n,e)}function nD(n,e,i){for(const s of qm)s.onLoaded&&s.onLoaded(n,e,i)}const Hl=te("debuginstancing"),eZ=class{constructor(){p(this,"objs",[])}setup(n,e,i,s,r,o=0){n.applySettings(e);const a=this.tryCreateOrAddInstance(e,i,r);if(a){s===null&&(s=[]),s.push(a),mi.assignTextureLOD(a.renderer.material,0);for(const l of n.sharedMeshes){const c=l.geometry;mi.assignMeshLOD(l,0).then(h=>{h&&n.activeAndEnabled&&c!=h&&a.setGeometry(h)})}}else if(o<=0&&e.type!=="Mesh"){const l=o+1;for(const c of e.children)s=this.setup(n,c,i,s,r,l)}return o===0&&r.useMatrixWorldAutoUpdate&&s&&s.length>=0&&this.autoUpdateInstanceMatrix(e),s}tryCreateOrAddInstance(n,e,i){if(n.type==="Mesh"){const s=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(s>=i.rend.enableInstancing.length)return Hl&&console.error("Something is wrong with instance setup",n,i.rend.enableInstancing,s),null;if(!i.rend.enableInstancing[s])return null}const r=n,o=r.material;for(const h of this.objs)if(!!h.canAdd(r.geometry,o))return h.addInstance(r);const a=16;let l=n.name;l!=null&&l.length||(l=uU());const c=new tZ(l,r.geometry,o,a,e);return this.objs.push(c),c.addInstance(r)}return null}autoUpdateInstanceMatrix(n){const e=n.matrixWorld.multiplyMatrices.bind(n.matrixWorld),i=n.matrixWorld.clone(),s=(r,o)=>{const a=e(r,o);return(n[Yb]||i.equals(a)===!1)&&(i.copy(a),n[Yb]=!0),a};n.matrixWorld.multiplyMatrices=s}};let q0=eZ;p(q0,"instance",new eZ);const DM=class{constructor(n,e){p(this,"object"),p(this,"renderer"),p(this,"__instanceIndex",-1),p(this,"__reservedVertexRange",0),p(this,"__reservedIndexRange",0),p(this,"meshInformation"),this.__instanceIndex=-1,this.object=n,this.renderer=e,n[M4]=e,this.meshInformation=$0(n.geometry),DM.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(n=!1,e=!0){this.__instanceIndex<0||(e&&this.object.updateWorldMatrix(!0,n),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(n){this.__instanceIndex<0||this.renderer.updateInstance(n,this.__instanceIndex)}setGeometry(n){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved vertex range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved index range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(n,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),ie.markAsInstancedRendered(this.object,!0))}remove(n){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,n),ie.markAsInstancedRendered(this.object,!1),n)){const e=DM.all.indexOf(this);e>=0&&DM.all.splice(e,1)}}};let nx=DM;p(nx,"all",[]);class tZ{constructor(e,i,s,r,o){p(this,"allowResize",!0),p(this,"name",""),p(this,"geometry"),p(this,"material"),p(this,"_context"),p(this,"_batchedMesh"),p(this,"_handles",[]),p(this,"_maxInstanceCount"),p(this,"_currentInstanceCount",0),p(this,"_currentVertexCount",0),p(this,"_currentIndexCount",0),p(this,"_maxVertexCount"),p(this,"_maxIndexCount"),p(this,"_needUpdateBounds",!1),p(this,"_debugMaterial",null),p(this,"onBeforeRender",()=>{this._batchedMesh.layers.enableAll(),this._needUpdateBounds&&this._batchedMesh[Kb]===!0&&(Hl&&console.log("Update instancing bounds",this.name,this._batchedMesh.matrixWorldNeedsUpdate),this.updateBounds())}),p(this,"onAfterRender",()=>{this._batchedMesh.layers.disableAll()}),p(this,"_availableBuckets",new Array),p(this,"_usedBuckets",new Array),this.name=e,this.geometry=i,this.material=s,this._context=o,this._maxInstanceCount=Math.max(2,r),Hl&&(this._debugMaterial=iZ());const a=this.tryEstimateVertexCountSize(this._maxInstanceCount,[i],r);this._maxVertexCount=a.vertexCount,this._maxIndexCount=a.indexCount,this._batchedMesh=new Bw(this._maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this._batchedMesh[Kb]=!0,this._batchedMesh.visible=!0,this._context.scene.add(this._batchedMesh),s instanceof Zw&&(s.defines.USE_INSTANCING=!0,s.needsUpdate=!0),o.pre_render_callbacks.push(this.onBeforeRender),o.post_render_callbacks.push(this.onAfterRender),Hl&&console.log(`Instanced renderer created with ${this._maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get batchedMesh(){return this._batchedMesh}get visible(){return this._batchedMesh.visible}set visible(e){this._batchedMesh.visible=e}get castShadow(){return this._batchedMesh.castShadow}set castShadow(e){this._batchedMesh.castShadow=e}set receiveShadow(e){this._batchedMesh.receiveShadow=e}get count(){return this._currentInstanceCount}updateBounds(e=!0,i=!0){this._needUpdateBounds=!1,e&&this._batchedMesh.computeBoundingBox(),i&&this._batchedMesh.computeBoundingSphere()}canAdd(e,i){return this._maxVertexCount>1e7||i!==this.material||!this.validateGeometry(e)?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){Hl&&console.warn("Dispose instanced renderer",this.name),this._context.scene.remove(this._batchedMesh),this._batchedMesh.dispose(),this._batchedMesh=null,this._handles=[]}addInstance(e){const i=new nx(e,this);e.castShadow===!0&&this._batchedMesh.castShadow===!1&&(this._batchedMesh.castShadow=!0),e.receiveShadow===!0&&this._batchedMesh.receiveShadow===!1&&(this._batchedMesh.receiveShadow=!0);try{this.add(i)}catch(s){return console.error(`Failed adding mesh to instancing
|
|
5983
|
+
`,l,e,a))),e.userData=e.userData||{},e.userData[om]=e.userData[om]||[],e.userData[om].push(a)}await Promise.all(r).catch(o=>{console.error("Error while loading components",o)})}}}const KQ="NEEDLE_gameobject_data";class abe{constructor(e){p(this,"parser"),this.parser=e}get name(){return KQ}afterRoot(e){var i;const s=[];for(let r=0;r<((i=this.parser.json.nodes)==null?void 0:i.length);r++){const o=this.parser.json.nodes[r];if(o&&o.extensions){const a=o.extensions[KQ];if(a){const l=this.findAndApplyExtensionData(r,a);s.push(l)}}}return Promise.all(s).then(()=>null)}async findAndApplyExtensionData(e,i){const s=await this.parser.getDependency("node",e);s&&this.applyExtensionData(s,i)}applyExtensionData(e,i){i.layers===void 0&&(i.layers=0),e.userData.layer=i.layers,e.layers.disableAll(),e.layers.set(i.layers),e.userData.tag=i.tag??"none",e.userData.hideFlags=i.hideFlags??0,e.userData.static=i.static??!1,e.visible=i.activeSelf??!0,e.guid=i.guid}}const JQ="NEEDLE_lighting_settings",K0=te("debugenvlight");class lbe{constructor(e,i,s){p(this,"parser"),p(this,"sourceId"),p(this,"context"),this.parser=e,this.sourceId=i,this.context=s}get name(){return JQ}afterRoot(e){const i=this.parser.json.extensions;if(i){const s=i[JQ];if(s){K0&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',s);let r;if(e.scene.children.length===1){const o=e.scene.children[0];r=ie.addComponent(o,PM,{},{callAwake:!1})}else{const o=new ge;o.name="LightSettings "+this.sourceId,e.scene.add(o),r=ie.addComponent(o,PM,{},{callAwake:!1})}r.sourceId=this.sourceId,r.ambientIntensity=s.ambientIntensity,r.ambientLight=new Ae().fromArray(s.ambientLight),Array.isArray(s.ambientTrilight)&&(r.ambientTrilight=s.ambientTrilight.map(o=>new Ae().fromArray(o))),r.ambientMode=s.ambientMode,r.environmentReflectionSource=s.environmentReflectionSource}}return null}}xi.registerCallback(_i.ContextCreated,n=>{const e=n.context,i=ie.findObjectOfType(PM,e);i!=null&&i.sourceId&&(i.enabled=!0)});class PM extends Pe{constructor(){super(...arguments),p(this,"ambientMode",A0.Skybox),p(this,"ambientLight"),p(this,"ambientTrilight"),p(this,"ambientIntensity",1),p(this,"environmentReflectionSource",LC.Skybox),p(this,"_hasReflection",!1),p(this,"_ambientLightObj"),p(this,"_hemisphereLightObj")}awake(){var e;if(this.sourceId){const s=this.environmentReflectionSource===LC.Skybox?Su.Skybox:Su.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,s,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),K0&&window.addEventListener("keydown",s=>{if(!this.destroyed)switch(s.key){case"l":this.enabled=!this.enabled;break}});const i=(e=this.gameObject.userData)==null?void 0:e.components;if(i){const s=i.indexOf(this);i.splice(s,1),i.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const i=Math.max(e.r,e.g,e.b);return 2.2*et.lerp(0,1.33,i)}onEnable(){if(K0&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==A0.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new qw(this.ambientLight,this.ambientIntensity*e),K0&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===A0.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],i=this.ambientTrilight[this.ambientTrilight.length-1],s=this.calculateIntensityFactor(i);this._hemisphereLightObj=new eI(i,e,this.ambientIntensity*s),this.gameObject.add(this._hemisphereLightObj),K0&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,s)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){K0&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}var qQ=(n=>(n[n.INT=5124]="INT",n[n.FLOAT=5126]="FLOAT",n[n.FLOAT_VEC2=35664]="FLOAT_VEC2",n[n.FLOAT_VEC3=35665]="FLOAT_VEC3",n[n.FLOAT_VEC4=35666]="FLOAT_VEC4",n[n.INT_VEC2=35667]="INT_VEC2",n[n.INT_VEC3=35668]="INT_VEC3",n[n.INT_VEC4=35669]="INT_VEC4",n[n.BOOL=35670]="BOOL",n[n.BOOL_VEC2=35671]="BOOL_VEC2",n[n.BOOL_VEC3=35672]="BOOL_VEC3",n[n.BOOL_VEC4=35673]="BOOL_VEC4",n[n.FLOAT_MAT2=35674]="FLOAT_MAT2",n[n.FLOAT_MAT3=35675]="FLOAT_MAT3",n[n.FLOAT_MAT4=35676]="FLOAT_MAT4",n[n.SAMPLER_2D=35678]="SAMPLER_2D",n[n.SAMPLER_3D=35680]="SAMPLER_3D",n[n.SAMPLER_CUBE=35681]="SAMPLER_CUBE",n[n.UNKNOWN=0]="UNKNOWN",n))(qQ||{});const zc=te("debugcustomshader"),J0="NEEDLE_techniques_webgl";class cbe{constructor(){p(this,"objectToWorldMatrix",new he),p(this,"worldToObjectMatrix",new he),p(this,"objectToWorld",new Array),p(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),IC(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),IC(this.worldToObjectMatrix,this.worldToObject)}}const Tn=class extends Zw{constructor(n,...e){super(...e),p(this,"identifier"),p(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),p(this,"_sphericalHarmonicsName","unity_SpecCube0"),p(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),p(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),p(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),p(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),p(this,"_rendererData",new cbe),this.identifier=n,zc&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&Pt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const n=super.clone();return $Q(n),n}dispose(){super.dispose();const n=Pt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);n>=0&&Pt.Current.pre_render_callbacks.splice(n,1)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&Pt.Current.setRequireColor(!0),this.depthTextureUniform&&Pt.Current.setRequireDepth(!0)}onBeforeRender(n,e,i,s,r,o){s.attributes.tangent||s.computeTangents(),this.onUpdateUniforms(i,r)}onUpdateUniforms(n,e){const i=Pt.Current;if(n&&(Tn.viewProjection&&this.uniforms[this._viewProjectionName]&&(Tn.viewProjection.copy(n.projectionMatrix).multiply(n.matrixWorldInverse),IC(Tn.viewProjection,Tn._viewProjectionValues)),Tn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Tn.viewMatrix.copy(n.matrixWorldInverse),IC(Tn.viewMatrix,Tn._viewMatrixValues)),this.uniforms[Tn._worldSpaceCameraPosName]&&Tn._worldSpaceCameraPos.setFromMatrixPosition(n.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=i.sceneLighting.timeVec4),this.uniforms._Time){const a=this.uniforms._Time.value;a.x=i.sceneLighting.timeVec4.x/20,a.y=i.sceneLighting.timeVec4.x,a.z=i.sceneLighting.timeVec4.x*2,a.w=i.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const a=this.uniforms._SinTime.value;a.x=Math.sin(i.sceneLighting.timeVec4.x/8),a.y=Math.sin(i.sceneLighting.timeVec4.x/4),a.z=Math.sin(i.sceneLighting.timeVec4.x/2),a.w=Math.sin(i.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const a=this.uniforms._CosTime.value;a.x=Math.cos(i.sceneLighting.timeVec4.x/8),a.y=Math.cos(i.sceneLighting.timeVec4.x/4),a.z=Math.cos(i.sceneLighting.timeVec4.x/2),a.w=Math.cos(i.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const a=this.uniforms.unity_DeltaTime.value;a.x=i.time.deltaTime,a.y=1/i.time.deltaTime,a.z=i.time.smoothedDeltaTime,a.w=1/i.time.smoothedDeltaTime}const s=i.mainLight;if(s){const a=Nt(s.gameObject,Tn._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},Tn._mainLightColor.set(s.color.r,s.color.g,s.color.b,0),this.uniforms._MainLightColor={value:Tn._mainLightColor};const l=s.intensity;Tn._lightData.z=l,this.uniforms.unity_LightData={value:Tn._lightData}}if(n&&(Tn.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Tn._viewProjectionValues),Tn.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Tn._viewMatrixValues),this.uniforms[Tn._worldSpaceCameraPosName]&&(this.uniforms[Tn._worldSpaceCameraPosName]={value:Tn._worldSpaceCameraPos}),i.mainCameraComponent)){if(this.uniforms._ProjectionParams){const a=this.uniforms._ProjectionParams.value;a.x=1,a.y=i.mainCameraComponent.nearClipPlane,a.z=i.mainCameraComponent.farClipPlane,a.w=1/a.z,this.uniforms._ProjectionParams.value=a}if(this.uniforms._ZBufferParams){const a=this.uniforms._ZBufferParams.value,l=i.mainCameraComponent;a.x=1-l.farClipPlane/l.nearClipPlane,a.y=l.farClipPlane/l.nearClipPlane,a.z=a.x/l.farClipPlane,a.w=a.y/l.farClipPlane,this.uniforms._ZBufferParams.value=a}if(this.uniforms._ScreenParams){const a=this.uniforms._ScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScreenParams.value=a}if(this.uniforms._ScaledScreenParams){const a=this.uniforms._ScaledScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScaledScreenParams.value=a}}const r=this.depthTextureUniform;r&&(r.value=i.depthTexture);const o=this.opaqueTextureUniform;if(o&&(o.value=i.opaqueColorTexture),e){const a=this._rendererData;a.updateFrom(e),this.uniforms[this._worldToObjectName].value=a.worldToObject,this.uniforms[this._objToWorldName].value=a.objectToWorld}this.uniformsNeedUpdate=!0}};let Wl=Tn;p(Wl,"viewProjection",new he),p(Wl,"_viewProjectionValues",[]),p(Wl,"viewMatrix",new he),p(Wl,"_viewMatrixValues",[]),p(Wl,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),p(Wl,"_worldSpaceCameraPos",new M),p(Wl,"_mainLightColor",new Ke),p(Wl,"_mainLightPosition",new M),p(Wl,"_lightData",new Ke);class hbe{constructor(e,i){p(this,"parser"),p(this,"identifier"),this.parser=e,this.identifier=i}get name(){return J0}loadMaterial(e){const i=this.parser.json.materials[e];if(!i)return zc&&console.log(e,this.parser.json.materials),null;if(!i.extensions||!i.extensions[J0])return zc&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;zc&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,i);const s=i.extensions[J0].technique;if(s<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const r=this.parser.json.extensions[J0];if(!r)return zc?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;zc&&console.log(r);const o=r.techniques[s];return o?new Promise(async(a,l)=>{var c,h,d;const u=await Vfe(r,o.program),m=u?.fragmentShader,f=u?.vertexShader;if(!m||!f)return l();zc&&console.log("loadMaterial",i,u);const g={},v=o.uniforms;(f.includes("_Time")||m.includes("_Time"))&&(g._Time={value:new Ke(0,0,0,0)}),(f.includes("_SinTime")||m.includes("_SinTime"))&&(g._SinTime={value:new Ke(0,0,0,0)}),(f.includes("_CosTime")||m.includes("_CosTime"))&&(g._CosTime={value:new Ke(0,0,0,0)}),(f.includes("unity_DeltaTime")||m.includes("unity_DeltaTime"))&&(g.unity_DeltaTime={value:new Ke(0,0,0,0)});for(const A in v){const x=A;switch(x){case"_TimeParameters":const w=new Ke;g[x]={value:w};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":g[x]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":g[x]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":g[x]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":g[x]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":g[x]={value:null};break}}let y=!1;if(i.extensions&&i.extensions[J0]){const A=i.extensions[J0];if(A.technique===s){zc&&console.log(i.name,"Material Properties",A);for(const x in A.values){const w=A.values[x];if(typeof w=="string"){if(w.startsWith("/textures/")){const _=w.substring(10),S=Number.parseInt(_);if(S>=0){const C=await this.parser.getDependency("texture",S);C instanceof Vt&&(C.colorSpace=ki,C.needsUpdate=!0),g[x]={value:C};continue}}switch(x){case"alphaMode":w==="BLEND"&&(y=!0);continue}}if(Array.isArray(w)&&w.length===4){g[x]={value:new Ke(w[0],w[1],w[2],w[3])};continue}g[x]={value:w}}}}const b=new Wl(this.identifier,{name:i.name??"",uniforms:g,vertexShader:f,fragmentShader:m,lights:!1});switch(b.glslVersion=K1,b.vertexShader=b.vertexShader.replace("#version 300 es",""),b.fragmentShader=b.fragmentShader.replace("#version 300 es",""),(c=g._Cull)==null?void 0:c.value){case 0:b.side=Ai;break;case 1:b.side=dn;break;case 2:b.side=Vn;break;default:b.side=Vn;break}switch((h=g._ZTest)==null?void 0:h.value){case 3:b.depthTest=!0,b.depthFunc=Lf;break;case 6:b.depthTest=!0,b.depthFunc=$y;break;case 2:b.depthTest=!0,b.depthFunc=qy;break;case 4:b.depthTest=!0,b.depthFunc=Sp;break;case 5:b.depthTest=!0,b.depthFunc=k1;break;case 7:b.depthTest=!0,b.depthFunc=P1;break;case 8:b.depthTest=!1,b.depthFunc=L1;break}b.transparent=y,y&&(b.depthWrite=!1),zfe(g),b.onUpdateUniforms();for(const A in v){const x=A,w=v[A].type;if(((d=g[x])==null?void 0:d.value)===void 0)switch(w){case qQ.SAMPLER_2D:g[x]={value:Nfe},console.warn("Missing/unassigned texture, fallback to white: "+x);break;default:x==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+x,v[A]);break}}zc&&console.log(b.uuid,g),$Q(b),a(b)}):null}}function $Q(n){if(n.uniforms){zc&&console.log("Uniforms:",n.uniforms);for(const i in n.uniforms)switch(e(i,i),i){case"_Color":e("color",i);break}}function e(i,s){Object.getOwnPropertyDescriptor(n,i)||Object.defineProperty(n,i,{get:()=>n.uniforms[s].value,set:r=>{n.uniforms[s].value=r,n.needsUpdate=!0}})}}const dbe=te("debugextensions");let kM;const ube=Promise.resolve().then(()=>IMe).then(async n=>(kM=n.GLTFAnimationPointerExtension,kM)).catch(n=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",n)}),qm=new Array;function pbe(n){qm.includes(n)||qm.push(n)}function mbe(n){const e=qm.indexOf(n);e>=0&&qm.splice(e,1)}function BM(n){const e=new obe;return n.register(i=>(e.parser=i,e)),e}class fbe{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function OM(n,e,i){const s=i.indexOf("?");s>=0&&(i=i.substring(0,s)),n.register(r=>new abe(r)),n.register(r=>new Nme(r)),n.register(r=>new Bfe(r,e.lightmaps,i)),n.register(r=>new lbe(r,i,e)),n.register(r=>new hbe(r,i)),n.register(r=>new $O(r,i)),n.register(r=>new mi(r,i)),n.register(r=>new ibe(r)),A9()&&n.register(r=>new Bk(r)),await ube.catch(r=>{}),n.register(r=>{if(kM){const o=new kM(r);return o.setAnimationPointerResolver.bind(o)(new fbe),o}else return(dbe||je())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const r of qm)r.onImport&&r.onImport(n,i,e)}function iD(n,e){for(const i of qm)i.onExport&&i.onExport(n,e)}function nD(n,e,i){for(const s of qm)s.onLoaded&&s.onLoaded(n,e,i)}const Hl=te("debuginstancing"),eZ=class{constructor(){p(this,"objs",[])}setup(n,e,i,s,r,o=0){n.applySettings(e);const a=this.tryCreateOrAddInstance(e,i,r);if(a){s===null&&(s=[]),s.push(a),mi.assignTextureLOD(a.renderer.material,0);for(const l of n.sharedMeshes){const c=l.geometry;mi.assignMeshLOD(l,0).then(h=>{h&&n.activeAndEnabled&&c!=h&&a.setGeometry(h)})}}else if(o<=0&&e.type!=="Mesh"){const l=o+1;for(const c of e.children)s=this.setup(n,c,i,s,r,l)}return o===0&&r.useMatrixWorldAutoUpdate&&s&&s.length>=0&&this.autoUpdateInstanceMatrix(e),s}tryCreateOrAddInstance(n,e,i){if(n.type==="Mesh"){const s=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(s>=i.rend.enableInstancing.length)return Hl&&console.error("Something is wrong with instance setup",n,i.rend.enableInstancing,s),null;if(!i.rend.enableInstancing[s])return null}const r=n,o=r.material;for(const h of this.objs)if(!!h.canAdd(r.geometry,o))return h.addInstance(r);const a=16;let l=n.name;l!=null&&l.length||(l=uU());const c=new tZ(l,r.geometry,o,a,e);return this.objs.push(c),c.addInstance(r)}return null}autoUpdateInstanceMatrix(n){const e=n.matrixWorld.multiplyMatrices.bind(n.matrixWorld),i=n.matrixWorld.clone(),s=(r,o)=>{const a=e(r,o);return(n[Yb]||i.equals(a)===!1)&&(i.copy(a),n[Yb]=!0),a};n.matrixWorld.multiplyMatrices=s}};let q0=eZ;p(q0,"instance",new eZ);const DM=class{constructor(n,e){p(this,"object"),p(this,"renderer"),p(this,"__instanceIndex",-1),p(this,"__reservedVertexRange",0),p(this,"__reservedIndexRange",0),p(this,"meshInformation"),this.__instanceIndex=-1,this.object=n,this.renderer=e,n[M9]=e,this.meshInformation=$0(n.geometry),DM.all.push(this)}get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return this.meshInformation.vertexCount}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return this.meshInformation.indexCount}get reservedIndexCount(){return this.__reservedIndexRange}updateInstanceMatrix(n=!1,e=!0){this.__instanceIndex<0||(e&&this.object.updateWorldMatrix(!0,n),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(n){this.__instanceIndex<0||this.renderer.updateInstance(n,this.__instanceIndex)}setGeometry(n){return this.__instanceIndex<0?!1:this.vertexCount>this.__reservedVertexRange?(console.error(`Cannot update geometry, reserved vertex range is too small: ${this.__reservedVertexRange} < ${this.vertexCount} vertices for ${this.name}`),!1):this.indexCount>this.__reservedIndexRange?(console.error(`Cannot update geometry, reserved index range is too small: ${this.__reservedIndexRange} < ${this.indexCount} indices for ${this.name}`),!1):this.renderer.updateGeometry(n,this.__instanceIndex)}add(){this.__instanceIndex>=0||(this.renderer.add(this),ie.markAsInstancedRendered(this.object,!0))}remove(n){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,n),ie.markAsInstancedRendered(this.object,!1),n)){const e=DM.all.indexOf(this);e>=0&&DM.all.splice(e,1)}}};let nx=DM;p(nx,"all",[]);class tZ{constructor(e,i,s,r,o){p(this,"allowResize",!0),p(this,"name",""),p(this,"geometry"),p(this,"material"),p(this,"_context"),p(this,"_batchedMesh"),p(this,"_handles",[]),p(this,"_maxInstanceCount"),p(this,"_currentInstanceCount",0),p(this,"_currentVertexCount",0),p(this,"_currentIndexCount",0),p(this,"_maxVertexCount"),p(this,"_maxIndexCount"),p(this,"_needUpdateBounds",!1),p(this,"_debugMaterial",null),p(this,"onBeforeRender",()=>{this._batchedMesh.layers.enableAll(),this._needUpdateBounds&&this._batchedMesh[Kb]===!0&&(Hl&&console.log("Update instancing bounds",this.name,this._batchedMesh.matrixWorldNeedsUpdate),this.updateBounds())}),p(this,"onAfterRender",()=>{this._batchedMesh.layers.disableAll()}),p(this,"_availableBuckets",new Array),p(this,"_usedBuckets",new Array),this.name=e,this.geometry=i,this.material=s,this._context=o,this._maxInstanceCount=Math.max(2,r),Hl&&(this._debugMaterial=iZ());const a=this.tryEstimateVertexCountSize(this._maxInstanceCount,[i],r);this._maxVertexCount=a.vertexCount,this._maxIndexCount=a.indexCount,this._batchedMesh=new Bw(this._maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this._batchedMesh[Kb]=!0,this._batchedMesh.visible=!0,this._context.scene.add(this._batchedMesh),s instanceof Zw&&(s.defines.USE_INSTANCING=!0,s.needsUpdate=!0),o.pre_render_callbacks.push(this.onBeforeRender),o.post_render_callbacks.push(this.onAfterRender),Hl&&console.log(`Instanced renderer created with ${this._maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}get batchedMesh(){return this._batchedMesh}get visible(){return this._batchedMesh.visible}set visible(e){this._batchedMesh.visible=e}get castShadow(){return this._batchedMesh.castShadow}set castShadow(e){this._batchedMesh.castShadow=e}set receiveShadow(e){this._batchedMesh.receiveShadow=e}get count(){return this._currentInstanceCount}updateBounds(e=!0,i=!0){this._needUpdateBounds=!1,e&&this._batchedMesh.computeBoundingBox(),i&&this._batchedMesh.computeBoundingSphere()}canAdd(e,i){return this._maxVertexCount>1e7||i!==this.material||!this.validateGeometry(e)?!1:!!(!this.mustGrow(e)||this.allowResize)}dispose(){Hl&&console.warn("Dispose instanced renderer",this.name),this._context.scene.remove(this._batchedMesh),this._batchedMesh.dispose(),this._batchedMesh=null,this._handles=[]}addInstance(e){const i=new nx(e,this);e.castShadow===!0&&this._batchedMesh.castShadow===!1&&(this._batchedMesh.castShadow=!0),e.receiveShadow===!0&&this._batchedMesh.receiveShadow===!1&&(this._batchedMesh.receiveShadow=!0);try{this.add(i)}catch(s){return console.error(`Failed adding mesh to instancing
|
|
5984
5984
|
`,s),je()&&B_("Failed instancing mesh. See the browser console for details."),null}return i}add(e){const i=e.object.geometry;if(this.mustGrow(i))if(this.allowResize)this.grow(i);else return console.error("Cannot add instance, max count reached",this.name,this.count,this._maxInstanceCount),!1;return e.object.updateWorldMatrix(!0,!0),this.addGeometry(e),this._handles[e.__instanceIndex]=e,this._currentInstanceCount+=1,this.markNeedsUpdate(),this._currentInstanceCount>0&&(this._batchedMesh.visible=!0),!0}remove(e,i){e&&(e.__instanceIndex<0||this._handles[e.__instanceIndex]!=e||this._currentInstanceCount<=0||(this.removeGeometry(e,i),this._handles[e.__instanceIndex]=null,e.__instanceIndex=-1,this._currentInstanceCount>0&&(this._currentInstanceCount-=1),this._currentInstanceCount<=0&&(this._batchedMesh.visible=!1),this.markNeedsUpdate()))}updateInstance(e,i){this._batchedMesh.setMatrixAt(i,e),this.markNeedsUpdate()}updateGeometry(e,i){return this.validateGeometry(e)?(this.mustGrow()&&this.grow(e),Hl&&console.debug("UPDATE MESH",i,e.name,$0(e),e.attributes.position.count,e.index?e.index.count:0),this._batchedMesh.setGeometryAt(i,e),this.markNeedsUpdate(),!0):!1}validateGeometry(e){const i=this.geometry;for(const s in i.attributes)if(s!=="batchId"&&!e.hasAttribute(s))return je()&&console.warn(`BatchedMesh: Added geometry missing "${s}". All geometries must have consistent attributes.`),!1;return!0}markNeedsUpdate(){Hl&&console.warn("Marking instanced mesh dirty",this.name),this._needUpdateBounds=!0}mustGrow(e){if(this.count>=this._maxInstanceCount)return!0;if(!e)return!1;const i=$0(e),s=i.vertexCount,r=i.indexCount;return this._currentVertexCount+s>this._maxVertexCount||this._currentIndexCount+r>this._maxIndexCount}grow(e){const i=this._maxInstanceCount*2,s=this.tryEstimateVertexCountSize(i,[e]),r=Math.max(this._maxVertexCount,s.vertexCount),o=Math.max(this._maxIndexCount,s.indexCount,this._maxVertexCount*2);if(Hl){const l=$0(e);console.warn(`Growing batched mesh for "${this.name}/${e.name}" ${l.vertexCount} vertices, ${l.indexCount} indices
|
|
5985
5985
|
Max count ${this._maxInstanceCount} \u2192 ${i}
|
|
5986
5986
|
Max vertex count ${this._maxVertexCount} -> ${r}
|
|
@@ -7090,7 +7090,7 @@ void main() {
|
|
|
7090
7090
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
7091
7091
|
|
|
7092
7092
|
#include <fog_vertex>
|
|
7093
|
-
}`);new M(0,0,1);var w1e=function(n){py(i,n);var e=my(i);function i(s){var r;return Tt(this,i),r=e.call(this,s),$(hi(r),"positionBuffer",void 0),$(hi(r),"previousBuffer",void 0),$(hi(r),"nextBuffer",void 0),$(hi(r),"uvBuffer",void 0),$(hi(r),"sideBuffer",void 0),$(hi(r),"widthBuffer",void 0),$(hi(r),"colorBuffer",void 0),$(hi(r),"indexBuffer",void 0),$(hi(r),"vector_",new M),$(hi(r),"vector2_",new M),$(hi(r),"vector3_",new M),$(hi(r),"quaternion_",new Se),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return Rt(i,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new pt,this.indexBuffer=new $e(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Cr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Cr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Cr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Cr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Cr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Cr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new $e(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Cr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new $e(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Cr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(s){for(;s>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var s={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new K(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new K(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=tG(this.settings.material.map.channel),s.map=new Ce(this.settings.material.map),s.mapTransform=new Ce(new Gt().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Bt({uniforms:s,defines:r,vertexShader:x1e,fragmentShader:A1e,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||_p});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var s=this,r=0,o=0,a=0;this.systems.forEach(function(l){for(var c=0;c<l.particleNum;c++)a+=l.particles[c].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(l){var c=s.quaternion_,h=s.vector2_,d=s.vector3_;l.emitter.matrixWorld.decompose(h,c,d);for(var u=l.particles,m=l.particleNum,f=s.settings.uTileCount,g=s.settings.vTileCount,v=1/f,y=1/g,b=0;b<m;b++){var A=u[b],x=A.uvTile%g,w=Math.floor(A.uvTile/g),_=A.previous.values(),S=_.next(),C=S.value,R=C;S.done||(S=_.next());var P=void 0;S.value!==void 0?P=S.value:P=R;for(var T=0;T<A.previous.length;T++,r+=2){if(s.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),s.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z),l.worldSpace?(s.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),s.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z)):(A.parentMatrix?s.vector_.copy(R.position).applyMatrix4(A.parentMatrix):s.vector_.copy(R.position).applyMatrix4(l.emitter.matrixWorld),s.positionBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.positionBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),l.worldSpace?(s.previousBuffer.setXYZ(r,C.position.x,C.position.y,C.position.z),s.previousBuffer.setXYZ(r+1,C.position.x,C.position.y,C.position.z)):(A.parentMatrix?s.vector_.copy(C.position).applyMatrix4(A.parentMatrix):s.vector_.copy(C.position).applyMatrix4(l.emitter.matrixWorld),s.previousBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.previousBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),l.worldSpace?(s.nextBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),s.nextBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z)):(A.parentMatrix?s.vector_.copy(P.position).applyMatrix4(A.parentMatrix):s.vector_.copy(P.position).applyMatrix4(l.emitter.matrixWorld),s.nextBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.nextBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),s.sideBuffer.setX(r,-1),s.sideBuffer.setX(r+1,1),l.worldSpace)s.widthBuffer.setX(r,R.size),s.widthBuffer.setX(r+1,R.size);else if(A.parentMatrix)s.widthBuffer.setX(r,R.size),s.widthBuffer.setX(r+1,R.size);else{var L=(Math.abs(d.x)+Math.abs(d.y)+Math.abs(d.z))/3;s.widthBuffer.setX(r,R.size*L),s.widthBuffer.setX(r+1,R.size*L)}s.uvBuffer.setXY(r,(T/A.previous.length+x)*v,(g-w-1)*y),s.uvBuffer.setXY(r+1,(T/A.previous.length+x)*v,(g-w)*y),s.colorBuffer.setXYZW(r,R.color.x,R.color.y,R.color.z,R.color.w),s.colorBuffer.setXYZW(r+1,R.color.x,R.color.y,R.color.z,R.color.w),T+1<A.previous.length&&(s.indexBuffer.setX(o*3,r),s.indexBuffer.setX(o*3+1,r+1),s.indexBuffer.setX(o*3+2,r+2),o++,s.indexBuffer.setX(o*3,r+2),s.indexBuffer.setX(o*3+1,r+1),s.indexBuffer.setX(o*3+2,r+3),o++),C=R,R=P,S.done||(S=_.next(),S.value!==void 0&&(P=S.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),i}(vY),_1e=function(n){py(i,n);var e=my(i);function i(){var s;return Tt(this,i),s=e.call(this),$(hi(s),"batches",[]),$(hi(s),"systemToBatchIndex",new Map),$(hi(s),"type","BatchedRenderer"),s}return Rt(i,[{key:"addSystem",value:function(s){s._renderer=this;for(var r=s.getRendererSettings(),o=0;o<this.batches.length;o++)if(i.equals(this.batches[o].settings,r)){this.batches[o].addSystem(s),this.systemToBatchIndex.set(s,o);return}var a;switch(r.renderMode){case at.Trail:a=new w1e(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new b1e(r);break}a.addSystem(s),this.batches.push(a),this.systemToBatchIndex.set(s,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(s){var r=this.systemToBatchIndex.get(s);r!=null&&(this.batches[r].removeSystem(s),this.systemToBatchIndex.delete(s))}},{key:"updateSystem",value:function(s){this.deleteSystem(s),this.addSystem(s)}},{key:"update",value:function(s){this.systemToBatchIndex.forEach(function(o,a){a.update(s)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(s,r){return s.material.side===r.material.side&&s.material.blending===r.material.blending&&s.material.transparent===r.material.transparent&&s.material.type===r.material.type&&s.material.alphaTest===r.material.alphaTest&&s.material.map===r.material.map&&s.renderMode===r.renderMode&&s.uTileCount===r.uTileCount&&s.vTileCount===r.vTileCount&&s.instancingGeometry===r.instancingGeometry&&s.renderOrder===r.renderOrder&&s.layers.mask===r.layers.mask}}]),i}(ge),S1e=_1e,AY=function(){function n(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new M;Tt(this,n),$(this,"locations",[]),this.scaleX=e,this.scaleY=i,this.position=s}return Rt(n,[{key:"transform",value:function(e,i){e.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new n(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(i){return i.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,i){var s=document.createElement("canvas");s.width=e.width,s.height=e.height;var r=s.getContext("2d");if(r){r.drawImage(e,0,0);var o=r.getImageData(0,0,s.width,s.height,{colorSpace:"srgb"});s.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var l=0;l<o.width;l++)o.data[(a*o.width+l)*4+3]>i&&this.locations.push(new K(l,o.height-a))}}}],[{key:"fromJSON",value:function(e){var i=new n(e.scaleX,e.scaleY,new M(e.position[0],e.position[1],e.position[2]));return i.locations=e.locations.map(function(s){return new K(s.x,s.y)}),i}}]),n}();function C1e(n){switch(n.type){case"TextureSequencer":return AY.fromJSON(n);default:return new AY}}var M1e=function(){function n(e){Tt(this,n),$(this,"type","ApplySequences"),$(this,"sequencers",[]),$(this,"time",0),$(this,"index",0),$(this,"pCount",0),$(this,"delay",void 0),$(this,"tempV",new M),this.delay=e}return Rt(n,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new M,e.begin=new M,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,i){var s=this.sequencers[this.index],r=e.id*this.delay;this.time>=s[0].a+r&&this.time<=s[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),s[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,n.BEZIER.genValue((this.time-s[0].a-r)/(s[0].b-s[0].a)))):this.time>s[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,i){this.sequencers.push([e,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var i=fy(e,2),s=i[0],r=i[1];return{range:s.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new n(this.delay);return e.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var i=new n(e.delay);return e.sequencers.forEach(function(s){i.sequencers.push([qi(s.range),C1e(s.sequencer)])}),i}}]),n}();$(M1e,"BEZIER",new QD(0,0,1,1));var pe=function(n){return n[n.Number=0]="Number",n[n.Vec2=1]="Vec2",n[n.Vec3=2]="Vec3",n[n.Vec4=3]="Vec4",n[n.Boolean=4]="Boolean",n[n.AnyType=5]="AnyType",n}({}),xY=Rt(function n(e,i,s,r){Tt(this,n),$(this,"input",void 0),$(this,"inputIndex",void 0),$(this,"output",void 0),$(this,"outputIndex",void 0),this.input=e,this.inputIndex=i,this.input.outputs[i].push(this),this.output=s,this.outputIndex=r,this.output.inputs[r]=this}),E1e=function(){function n(){Tt(this,n),$(this,"visited",new Set),$(this,"graph_",void 0),$(this,"context_",void 0),n.Instance=this}return Rt(n,[{key:"traverse",value:function(e){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(e.id);for(var i=[],s=0;s<e.inputs.length;s++)if(e.inputs[s]instanceof xY){var r=e.inputs[s].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[e.inputs[s].inputIndex])}else i.push(e.inputs[s].getValue(this.context_));e.func(this.context_,i,e.outputValues),this.graph_.nodesInOrder.push(e)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var e=this.graph_.nodesInOrder,i=0;i<e.length;i++){for(var s=[],r=e[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof xY)s.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)s.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,s,r.outputValues)}}},{key:"run",value:function(e,i){if(this.graph_=e,this.context_=i,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var s=0;s<e.outputNodes.length;s++){var r=e.outputNodes[s];this.traverse(r)}e.compiled=!0}}}]),n}();$(E1e,"Instance",void 0);var yi=function(){function n(e){Tt(this,n),$(this,"name",void 0),$(this,"nodeTypeSignatures",[]),this.name=e}return Rt(n,[{key:"addSignature",value:function(e,i,s){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:i,func:s})}}]),n}(),bE=new yi("add");bE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]+i[1]}),bE.addSignature([pe.Vec2,pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].addVectors(i[0],i[1])}),bE.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].addVectors(i[0],i[1])}),bE.addSignature([pe.Vec4,pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].addVectors(i[0],i[1])});var AE=new yi("sub");AE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]-i[1]}),AE.addSignature([pe.Vec2,pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].subVectors(i[0],i[1])}),AE.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].subVectors(i[0],i[1])}),AE.addSignature([pe.Vec4,pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].subVectors(i[0],i[1])});var xE=new yi("mul");xE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]*i[1]}),xE.addSignature([pe.Vec2,pe.Number],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])}),xE.addSignature([pe.Vec3,pe.Number],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])}),xE.addSignature([pe.Vec4,pe.Number],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])});var wE=new yi("div");wE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]/i[1]}),wE.addSignature([pe.Vec2,pe.Number],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])}),wE.addSignature([pe.Vec3,pe.Number],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])}),wE.addSignature([pe.Vec4,pe.Number],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])});var T1e=new yi("sin");T1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.sin(i[0])});var R1e=new yi("cos");R1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.cos(i[0])});var I1e=new yi("tan");I1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.tan(i[0])});var L1e=new yi("abs");L1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.abs(i[0])});var P1e=new yi("min");P1e.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.min(i[0],i[1])});var k1e=new yi("max");k1e.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.max(i[0],i[1])});var iG=new yi("dot");iG.addSignature([pe.Vec2,pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])}),iG.addSignature([pe.Vec3,pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])}),iG.addSignature([pe.Vec4,pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])});var B1e=new yi("cross");B1e.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].crossVectors(i[0],i[1])});var nG=new yi("length");nG.addSignature([pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].length()}),nG.addSignature([pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].length()}),nG.addSignature([pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].length()});var sG=new yi("lengthSq");sG.addSignature([pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()}),sG.addSignature([pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()}),sG.addSignature([pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()});var rG=new yi("normalize");rG.addSignature([pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).normalize()}),rG.addSignature([pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).normalize()}),rG.addSignature([pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).normalize()});var wY=new yi("distance");wY.addSignature([pe.Vec2,pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].distanceTo(i[1])}),wY.addSignature([pe.Vec3,pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].distanceTo(i[1])});var O1e=new yi("and");O1e.addSignature([pe.Boolean,pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]&&i[1]});var D1e=new yi("or");D1e.addSignature([pe.Boolean,pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]||i[1]});var G1e=new yi("not");G1e.addSignature([pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=!i[0]});var _E=new yi("equal");_E.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]===i[1]}),_E.addSignature([pe.Vec2,pe.Vec2],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])}),_E.addSignature([pe.Vec3,pe.Vec3],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])}),_E.addSignature([pe.Vec4,pe.Vec4],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])});var N1e=new yi("lessThan");N1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]<i[1]});var F1e=new yi("greaterThan");F1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]>i[1]});var z1e=new yi("lessThanOrEqual");z1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]<=i[1]});var U1e=new yi("greaterThanOrEqual");U1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]>=i[1]});var V1e=new yi("if");V1e.addSignature([pe.Boolean,pe.AnyType,pe.AnyType],[pe.AnyType],function(n,e,i,s){s[0]=i[0]?i[1]:i[2]});var X1e=new yi("number");X1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=e.value});var W1e=new yi("vec2");W1e.addSignature([],[pe.Vec2],function(n,e,i,s){s[0]=e.value});var H1e=new yi("vec3");H1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=e.value});var j1e=new yi("vec4");j1e.addSignature([],[pe.Vec4],function(n,e,i,s){s[0]=e.value});var Q1e=new yi("bool");Q1e.addSignature([],[pe.Boolean],function(n,e,i,s){s[0]=e.value});var Z1e=new yi("particlePosition");Z1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=n.particle[e.property]});var Y1e=new yi("particleVelocity");Y1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=n.particle[e.property]});var K1e=new yi("particleRotation");K1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=n.particle[e.property]});var J1e=new yi("particleAge");J1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=n.particle[e.property]});var Px=new yi("output");Px.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var q1e=Object.defineProperty,$1e=Object.getOwnPropertyDescriptor,Pn=(n,e,i,s)=>{for(var r=s>1?void 0:s?$1e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&q1e(e,i,r),r};const kx=te("debugparticles"),ewe=te("noprogressive"),twe=te("debugprogressive");var oG=(n=>(n[n.Birth=0]="Birth",n[n.Collision=1]="Collision",n[n.Death=2]="Death",n[n.Trigger=3]="Trigger",n[n.Manual=4]="Manual",n))(oG||{});class tl extends Pe{constructor(){super(...arguments),p(this,"renderMode"),p(this,"particleMaterial"),p(this,"trailMaterial"),p(this,"particleMesh"),p(this,"maxParticleSize"),p(this,"minParticleSize"),p(this,"velocityScale"),p(this,"cameraVelocityScale"),p(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&je()){const e=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let i=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&e&&i.side===Vn&&(i=i.clone(),i.side=dn,e?this.trailMaterial=i:this.particleMaterial=i),i&&!ewe&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,twe&&console.log("Load material LOD",i.name),mi.assignTextureLOD(i,0)),i}getMesh(e){let i=null;if(!i&&(this.particleMesh instanceof ue&&(i=this.particleMesh.geometry),i===null)){i=new Kn(1,1);const s=i.attributes.uv;for(let r=0;r<s.count;r++)s.setX(r,1-s.getX(r))}return new ue(i,this.getMaterial())}}Pn([E()],tl.prototype,"renderMode",2),Pn([E(Ft)],tl.prototype,"particleMaterial",2),Pn([E(Ft)],tl.prototype,"trailMaterial",2),Pn([E()],tl.prototype,"maxParticleSize",2),Pn([E()],tl.prototype,"minParticleSize",2),Pn([E()],tl.prototype,"velocityScale",2),Pn([E()],tl.prototype,"cameraVelocityScale",2),Pn([E()],tl.prototype,"lengthScale",2);class SE{constructor(e,i=1){p(this,"_curve"),p(this,"_factor"),p(this,"type","function"),this._curve=e,this._factor=i}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class aG{constructor(e){p(this,"type","value"),p(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class iwe extends aG{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class nwe extends aG{constructor(){super(...arguments),p(this,"_lastPosition",new M),p(this,"_lastDistance",0)}update(){const e=Nt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let o=this._lastDistance/this.system.deltaTime*r;Number.isFinite(o)||(o=0),e+=o}const i=this.system.emission.getBurst();i>0&&(e+=i/this.system.deltaTime);const s=this.system.maxParticles-this.system.currentParticles;return et.clamp(e,0,s/this.system.deltaTime)}}class swe extends aG{genValue(){return this.system.isPlaying,0}}class op{constructor(e){p(this,"system"),p(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,i){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class rwe extends op{constructor(){super(...arguments),p(this,"type","NeedleTextureSheet")}update(e,i){const s=this.system.textureSheetAnimation;if(s.enabled){const r=e.age/e.life,o=s.evaluate(r);o!==void 0&&(e.uvTile=o)}}}const _Y=Symbol("particleRotation");class owe extends op{constructor(){super(...arguments),p(this,"type","NeedleRotation")}initialize(e){e[_Y]=Math.random()}update(e,i){if(e.rotation===void 0)return;const s=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(s,e[_Y])*i:this.system.renderer.renderMode===ad.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(s,r)*i}}}const SY=Symbol("sizeLerpFactor"),awe=new M;class lwe extends op{constructor(){super(...arguments),p(this,"type","NeedleSize"),p(this,"_minSize",0),p(this,"_maxSize",1)}initialize(e){e[SY]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,i){const s=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(s,void 0,e[SY]).x);let o=1;if(this.system.renderer.renderMode!==ad.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*o,this.system.localspace){const a=RY(this.system,awe);e.size*=a.x}}}const gy=Symbol("particleLife"),lG=Symbol("trailLifetime"),CY=Symbol("trailStartLength"),cG=Symbol("trailWidthRandom");class cwe extends op{constructor(){super(...arguments),p(this,"type","NeedleTrail")}initialize(e){e instanceof Ex&&(e[gy]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[lG]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[lG]),e[CY]=e.length,e[cG]=Math.random())}update(e){var i;if((i=this.system.trails)!=null&&i.enabled&&e instanceof Ex){const s=e,r=e.age/e[gy],o=e.previous.values(),a=e.previous.length;for(let l=0;l<a;l++){const c=o.next().value,h=1-l/(a-1);let d=e.size;d<=0&&!this.system.trails.sizeAffectsWidth&&(d=20*this.system.trails.widthOverTrail.evaluate(.5,s[cG])),c.size=this.system.trails.getWidth(d,r,h,s[cG]),c.color.copy(e.color),this.system.trails.getColor(c.color,r,h)}if(e.age>e[gy]){e.velocity.set(0,0,0);const l=(e.age-e[gy])/e[lG];s.length=et.lerp(e[CY],0,l)}}}}const CE=Symbol("startVelocity"),MY=Symbol("gravityModifier"),hG=Symbol("gravitySpeed"),ME=Symbol("velocity lerp factor"),dG=new M;class hwe extends op{constructor(){super(...arguments),p(this,"type","NeedleVelocity"),p(this,"_gravityDirection",new M)}initialize(e){var i,s;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[CE]?e[CE].copy(e.velocity):e[CE]=e.velocity.clone();const o=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[MY]=o*r,e[hG]=o*r*.5,e[ME]=Math.random(),(s=this.system.velocityOverLifetime)==null||s.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===ax.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,i){var s;const r=e[CE],o=e[MY];if(o!==0){const m=o*e[hG];dG.copy(this._gravityDirection).multiplyScalar(m),e[hG]+=i*.05,r.add(dG)}e.velocity.copy(r);const a=e.age/e.life;(s=this.system.inheritVelocity)!=null&&s.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,a,e[ME]);const l=this.system.noise;l.enabled&&l.apply(0,e.position,e.velocity,i,e.age,e.life);const c=this.system.sizeBySpeed;c!=null&&c.enabled&&(e.size=c.evaluate(e.velocity,a,e[ME],e.size));const h=this.system.colorBySpeed;h!=null&&h.enabled&&h.evaluate(e.velocity,e[ME],e.color);const d=this.system.velocityOverLifetime;d.enabled&&d.apply(e,0,e.position,e.velocity,i,e.age,e.life);const u=this.system.limitVelocityOverLifetime;u.enabled&&u.apply(e.position,r,e.velocity,e.size,a,i,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const EY=Symbol("colorLerpFactor"),TY=new Li(1,1,1,1),df=new Li(1,1,1,1);class dwe extends op{constructor(){super(...arguments),p(this,"type","NeedleColor")}initialize(e){}_init(e){const i=this.system.renderer.particleMaterial;df.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(TY.copy(i.color),df.multiply(TY)),df.convertLinearToSRGB(),e.startColor.set(df.r,df.g,df.b,df.alpha),e.color.copy(e.startColor),e[EY]=Math.random()}update(e,i){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const s=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(s,e[EY]);e.color.set(r.r,r.g,r.b,"alpha"in r?r.alpha:1).multiply(e.startColor)}else e.color.copy(e.startColor)}}class uwe{constructor(e){p(this,"system"),p(this,"emission"),p(this,"autoDestroy"),p(this,"startLength"),p(this,"emissionBursts"),p(this,"onlyUsedByOther"),p(this,"behaviors",[]),p(this,"rendererEmitterSettings",{startLength:new Wr(220),followLocalOrigin:!1}),p(this,"flatWhiteTexture"),p(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new nwe(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new SE(this.system.main.startLifetime)}get startSpeed(){return new SE(this.system.main.startSpeed)}get startRotation(){return new SE(this.system.main.startRotation)}get startSize(){return new SE(this.system.main.startSize)}get startColor(){return new vE(new Ke(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new swe(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ad.Billboard:return at.BillBoard;case ad.Stretch:return at.StretchedBillBoard;case ad.HorizontalBillboard:return at.HorizontalBillBoard;case ad.VerticalBillboard:return at.VerticalBillBoard;case ad.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var e;let i=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===ad.Stretch&&(i*=this.system.renderer.velocityScale??1),i}get texture(){const e=this.material;if(e&&e.map){const i=e.map;if(this.clonedTexture.original!==i||!this.clonedTexture.clone){const s=i.clone();s.premultiplyAlpha=!1,s.colorSpace=ki,this.clonedTexture.original=i,this.clonedTexture.clone=s}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=_B(new Li(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new iwe(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Md}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===ax.World}}class pwe{constructor(){p(this,"burstIndex",0),p(this,"burstWaveIndex",0),p(this,"time",0),p(this,"waitEmiting",0)}}const EE=class extends Pe{constructor(){super(...arguments),p(this,"_state"),p(this,"colorOverLifetime"),p(this,"main"),p(this,"emission"),p(this,"sizeOverLifetime"),p(this,"shape"),p(this,"noise"),p(this,"trails"),p(this,"velocityOverLifetime"),p(this,"limitVelocityOverLifetime"),p(this,"inheritVelocity"),p(this,"colorBySpeed"),p(this,"textureSheetAnimation"),p(this,"rotationOverLifetime"),p(this,"rotationBySpeed"),p(this,"sizeBySpeed"),p(this,"_cameraScale",1),p(this,"__worldQuaternion",new Se),p(this,"_worldQuaternionInverted",new Se),p(this,"_worldScale",new M),p(this,"_worldPositionFrame",-1),p(this,"_worldPos",new M),p(this,"_renderer"),p(this,"_batchSystem"),p(this,"_particleSystem"),p(this,"_interface"),p(this,"_container"),p(this,"_time",0),p(this,"_isPlaying",!0),p(this,"_isUsedAsSubsystem",!1),p(this,"_didPreWarm",!1),p(this,"_bursts"),p(this,"_subEmitterSystems"),p(this,"_lastBatchesCount",-1),p(this,"lastMaterialVersion",-1)}play(n=!1){var e;n&&ie.foreachComponent(this.gameObject,i=>{i instanceof EE&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(n=!0){n&&ie.foreachComponent(this.gameObject,e=>{e instanceof EE&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(n=!0,e=!1){n&&ie.foreachComponent(this.gameObject,i=>{i instanceof EE&&i!==this&&i.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var n;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(n=this.emission)==null||n.reset())}emit(n){if(this._particleSystem){this.onUpdate(),n=Math.min(n,this.maxParticles-this.currentParticles),this._state||(this._state=new pwe),this._state.waitEmiting=n,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(n){this.main.playOnAwake=n}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var n;return((n=this._particleSystem)==null?void 0:n.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===ax.World}get localspace(){return this.main.simulationSpace===ax.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Nt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(n){return this._particleSystem?(n instanceof op&&(n.system=this),je()&&console.log("add behaviour",n),this._particleSystem.addBehavior(n),!0):!1}removeBehaviour(n){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,i=e.indexOf(n);return i!==-1&&e.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(n){for(let e=0;e<n.length;e++){const i=n[e];if(!(i instanceof cx)){const s=new cx;d0(s,i),n[e]=s}}this._bursts=n}set subEmitterSystems(n){for(let e=0;e<n.length;e++){const i=n[e];if(!(i instanceof Bx)){const s=new Bx;d0(s,i),n[e]=s}}kx&&n.length>0&&console.log("SubEmitters: ",n,this),this._subEmitterSystems=n}onAfterDeserialize(n){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(tl),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ge,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new S1e,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new uwe(this),this._particleSystem=new p1e(this._interface),this._particleSystem.addBehavior(new lwe(this)),this._particleSystem.addBehavior(new dwe(this)),this._particleSystem.addBehavior(new rwe(this)),this._particleSystem.addBehavior(new owe(this)),this._particleSystem.addBehavior(new hwe(this)),this._particleSystem.addBehavior(new cwe(this)),this._batchSystem.addSystem(this._particleSystem);const n=this._particleSystem.emitter;this.context.scene.add(n),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),kx&&(console.log(this),this.gameObject.add(new Ro(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof ue&&this._interface.renderMode==at.Mesh&&mi.assignMeshLOD(this.renderer.particleMesh,0).then(n=>{n&&this.particleSystem&&this._interface.renderMode==at.Mesh&&(this.particleSystem.instancingGeometry=n)})}onDestroy(){var n,e,i,s;(n=this._container)==null||n.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(s=this._particleSystem)==null||s.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var n;this.main&&(this._didPreWarm===!1&&((n=this.main)==null?void 0:n.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var n;if(!((n=this.emission)!=null&&n.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,i=this.main.duration,s=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,s)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/e),l=Date.now();kx&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${s}`);for(let c=0;c<a&&!(this.currentParticles>=this.maxParticles);c++){const h=Date.now()-l;if(h>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${h}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(n){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(n)}this._time+=n,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let n=0;n<this._batchSystem.batches.length;n++){const e=this._batchSystem.batches[n];e.layers.disableAll();const i=this.layer;e.layers.mask=1<<i}}onUpdate(){var n,e;const i=this.renderer.getMaterial(this.trails.enabled);if(i&&i.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=i.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const s=this.context.mainCamera;if(s){const a=Yi(s);this._cameraScale=a.x}const r=!this.worldspace,o=this.gameObject;if(Bi(o,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Yi(this.gameObject,this._worldScale),r&&this._container&&(n=this.gameObject)!=null&&n.parent){const a=RY(this,dG);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var n;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():je()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const i=(n=e.particleSystem)==null?void 0:n._particleSystem;if(i){e.particleSystem._isUsedAsSubsystem=!0;const s=new TE(this,this._particleSystem,e.particleSystem,i);s.emitterType=e.type,s.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(s)}else kx&&console.warn("Could not add SubParticleSystem",e,this)}}};let hs=EE;Pn([E(hx)],hs.prototype,"colorOverLifetime",2),Pn([E(hr)],hs.prototype,"main",2),Pn([E(Uc)],hs.prototype,"emission",2),Pn([E(Ku)],hs.prototype,"sizeOverLifetime",2),Pn([E(Rn)],hs.prototype,"shape",2),Pn([E(Pi)],hs.prototype,"noise",2),Pn([E(xn)],hs.prototype,"trails",2),Pn([E(In)],hs.prototype,"velocityOverLifetime",2),Pn([E(ls)],hs.prototype,"limitVelocityOverLifetime",2),Pn([E(Ju)],hs.prototype,"inheritVelocity",2),Pn([E($m)],hs.prototype,"colorBySpeed",2),Pn([E(dr)],hs.prototype,"textureSheetAnimation",2),Pn([E($a)],hs.prototype,"rotationOverLifetime",2),Pn([E(ya)],hs.prototype,"rotationBySpeed",2),Pn([E(vo)],hs.prototype,"sizeBySpeed",2);class Bx{constructor(){p(this,"particleSystem"),p(this,"emitProbability",1),p(this,"properties"),p(this,"type")}_deserialize(e,i){const s=this.particleSystem;if(s instanceof hs)return;let r="";s&&typeof s.guid=="string"&&(r=s.guid,this.particleSystem=ie.findByGuid(r,i)),kx&&!(this.particleSystem instanceof hs)&&console.warn("Could not find particle system for sub emitter",r,i,this)}}function RY(n,e){if(e.set(1,1,1),n.gameObject.parent&&n.localspace)switch(n.main.scalingMode){case oD.Local:e=Yi(n.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!n.unsupported_scaling_mode){n.unsupported_scaling_mode=!0;const i="ParticleSystem scale mode "+oD[n.main.scalingMode]+" is not supported";je()&&Oi(i),console.warn(i,n.name,n)}e=Yi(n.gameObject,e);break}return e}new M(1,1,1),new M(0,0,1);class TE{constructor(e,i,s,r){p(this,"type","NeedleParticleSubEmitter"),p(this,"emitterType"),p(this,"emitterProbability"),p(this,"q_",new Se),p(this,"v_",new M),p(this,"v2_",new M),p(this,"_emitterMatrix",new he),p(this,"_circularBuffer"),this.system=e,this.particleSystem=i,this.subSystem=s,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const o=1e3;this._circularBuffer=new Yo(()=>new he,o)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===oG.Birth&&this.run(e)}update(e,i){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const i=this.system.deltaTime;if(this.emitterType===oG.Death){let r=e.life;if(e[gy]!==void 0&&(r=e[gy]),!(e.age+i*1.2>=r))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const s=new he;s.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||s.multiplyMatrices(this._emitterMatrix,s),this.subParticleSystem.emit(i,e.emissionState,s)}}var mwe=Object.defineProperty,fwe=Object.getOwnPropertyDescriptor,gwe=(n,e,i,s)=>{for(var r=s>1?void 0:s?fwe(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&mwe(e,i,r),r};class Ox extends Us{constructor(){super(...arguments),p(this,"granularity",new qe(10))}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new rV;return this.granularity.onValueChanged=i=>{e.granularity=i},e}}gwe([E(qe)],Ox.prototype,"granularity",2),Ja("PixelationEffect",Ox);class Ky extends Pe{constructor(){super(...arguments),p(this,"_didAssignPlayerColor",!1),p(this,"tryAssignColor",()=>{const e=ie.getComponentInParent(this.gameObject,ua);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const i=ie.getComponentInParent(this.gameObject,ar);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Xt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Xt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield T9(.2),!this.tryAssignColor()););}assignUserColor(e){const i=Ky.hashCode(e),s=Ky.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(s,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(s,e,o)}}assignColor(e,i,s){let r=s.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,s.material=r),r.color=e)}static hashCode(e){var i=0,s,r;if(e.length===0)return i;for(s=0;s<e.length;s++)r=e.charCodeAt(s),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(e){const i=(e&16711680)>>16,s=(e&65280)>>8,r=e&255;return new Ae(i/255,s/255,r/255)}}const Dx=new pt;Dx.setAttribute("position",new $e(new Float32Array([-1,-1,3,-1,-1,3]),2)),Dx.setAttribute("uv",new $e(new Float32Array([0,0,2,0,0,2]),2)),Dx.boundingSphere=new tn,Dx.computeBoundingSphere=function(){};const ywe=new oc;class uf{constructor(e){this._mesh=new ue(Dx,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,ywe)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const vwe={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new he},viewMat:{value:new he},projViewMat:{value:new he},projectionMatrixInv:{value:new he},viewMatrixInv:{value:new he},cameraPos:{value:new M},resolution:{value:new K},biasAdjustment:{value:new K},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|
|
7093
|
+
}`);new M(0,0,1);var w1e=function(n){py(i,n);var e=my(i);function i(s){var r;return Tt(this,i),r=e.call(this,s),$(hi(r),"positionBuffer",void 0),$(hi(r),"previousBuffer",void 0),$(hi(r),"nextBuffer",void 0),$(hi(r),"uvBuffer",void 0),$(hi(r),"sideBuffer",void 0),$(hi(r),"widthBuffer",void 0),$(hi(r),"colorBuffer",void 0),$(hi(r),"indexBuffer",void 0),$(hi(r),"vector_",new M),$(hi(r),"vector2_",new M),$(hi(r),"vector3_",new M),$(hi(r),"quaternion_",new Se),r.maxParticles=1e4,r.setupBuffers(),r.rebuildMaterial(),r}return Rt(i,[{key:"setupBuffers",value:function(){this.geometry&&this.geometry.dispose(),this.geometry=new pt,this.indexBuffer=new $e(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(Cr),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(Cr),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(Cr),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new $e(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(Cr),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(Cr),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new $e(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(Cr),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new $e(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(Cr),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new $e(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(Cr),this.geometry.setAttribute("color",this.colorBuffer)}},{key:"expandBuffers",value:function(s){for(;s>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}},{key:"rebuildMaterial",value:function(){this.layers.mask=this.settings.layers.mask;var s={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new K(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0},repeat:{value:new K(1,1)}},r={};if(r.USE_UV="",r.USE_COLOR_ALPHA="",this.settings.material.map&&(r.USE_MAP="",r.MAP_UV=tG(this.settings.material.map.channel),s.map=new Ce(this.settings.material.map),s.mapTransform=new Ce(new Gt().copy(this.settings.material.map.matrix))),this.settings.renderMode===at.Trail)this.material=new Bt({uniforms:s,defines:r,vertexShader:x1e,fragmentShader:A1e,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||_p});else throw new Error("render mode unavailable")}},{key:"update",value:function(){var s=this,r=0,o=0,a=0;this.systems.forEach(function(l){for(var c=0;c<l.particleNum;c++)a+=l.particles[c].previous.length*2}),a>this.maxParticles&&this.expandBuffers(a),this.systems.forEach(function(l){var c=s.quaternion_,h=s.vector2_,d=s.vector3_;l.emitter.matrixWorld.decompose(h,c,d);for(var u=l.particles,m=l.particleNum,f=s.settings.uTileCount,g=s.settings.vTileCount,v=1/f,y=1/g,b=0;b<m;b++){var A=u[b],x=A.uvTile%g,w=Math.floor(A.uvTile/g),_=A.previous.values(),S=_.next(),C=S.value,R=C;S.done||(S=_.next());var P=void 0;S.value!==void 0?P=S.value:P=R;for(var T=0;T<A.previous.length;T++,r+=2){if(s.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),s.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z),l.worldSpace?(s.positionBuffer.setXYZ(r,R.position.x,R.position.y,R.position.z),s.positionBuffer.setXYZ(r+1,R.position.x,R.position.y,R.position.z)):(A.parentMatrix?s.vector_.copy(R.position).applyMatrix4(A.parentMatrix):s.vector_.copy(R.position).applyMatrix4(l.emitter.matrixWorld),s.positionBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.positionBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),l.worldSpace?(s.previousBuffer.setXYZ(r,C.position.x,C.position.y,C.position.z),s.previousBuffer.setXYZ(r+1,C.position.x,C.position.y,C.position.z)):(A.parentMatrix?s.vector_.copy(C.position).applyMatrix4(A.parentMatrix):s.vector_.copy(C.position).applyMatrix4(l.emitter.matrixWorld),s.previousBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.previousBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),l.worldSpace?(s.nextBuffer.setXYZ(r,P.position.x,P.position.y,P.position.z),s.nextBuffer.setXYZ(r+1,P.position.x,P.position.y,P.position.z)):(A.parentMatrix?s.vector_.copy(P.position).applyMatrix4(A.parentMatrix):s.vector_.copy(P.position).applyMatrix4(l.emitter.matrixWorld),s.nextBuffer.setXYZ(r,s.vector_.x,s.vector_.y,s.vector_.z),s.nextBuffer.setXYZ(r+1,s.vector_.x,s.vector_.y,s.vector_.z)),s.sideBuffer.setX(r,-1),s.sideBuffer.setX(r+1,1),l.worldSpace)s.widthBuffer.setX(r,R.size),s.widthBuffer.setX(r+1,R.size);else if(A.parentMatrix)s.widthBuffer.setX(r,R.size),s.widthBuffer.setX(r+1,R.size);else{var L=(Math.abs(d.x)+Math.abs(d.y)+Math.abs(d.z))/3;s.widthBuffer.setX(r,R.size*L),s.widthBuffer.setX(r+1,R.size*L)}s.uvBuffer.setXY(r,(T/A.previous.length+x)*v,(g-w-1)*y),s.uvBuffer.setXY(r+1,(T/A.previous.length+x)*v,(g-w)*y),s.colorBuffer.setXYZW(r,R.color.x,R.color.y,R.color.z,R.color.w),s.colorBuffer.setXYZW(r+1,R.color.x,R.color.y,R.color.z,R.color.w),T+1<A.previous.length&&(s.indexBuffer.setX(o*3,r),s.indexBuffer.setX(o*3+1,r+1),s.indexBuffer.setX(o*3+2,r+2),o++,s.indexBuffer.setX(o*3,r+2),s.indexBuffer.setX(o*3+1,r+1),s.indexBuffer.setX(o*3+2,r+3),o++),C=R,R=P,S.done||(S=_.next(),S.value!==void 0&&(P=S.value))}}}),this.positionBuffer.updateRange.count=r*3,this.positionBuffer.needsUpdate=!0,this.previousBuffer.updateRange.count=r*3,this.previousBuffer.needsUpdate=!0,this.nextBuffer.updateRange.count=r*3,this.nextBuffer.needsUpdate=!0,this.sideBuffer.updateRange.count=r,this.sideBuffer.needsUpdate=!0,this.widthBuffer.updateRange.count=r,this.widthBuffer.needsUpdate=!0,this.uvBuffer.updateRange.count=r*2,this.uvBuffer.needsUpdate=!0,this.colorBuffer.updateRange.count=r*4,this.colorBuffer.needsUpdate=!0,this.indexBuffer.updateRange.count=o*3,this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,o*3)}},{key:"dispose",value:function(){this.geometry.dispose()}}]),i}(vY),_1e=function(n){py(i,n);var e=my(i);function i(){var s;return Tt(this,i),s=e.call(this),$(hi(s),"batches",[]),$(hi(s),"systemToBatchIndex",new Map),$(hi(s),"type","BatchedRenderer"),s}return Rt(i,[{key:"addSystem",value:function(s){s._renderer=this;for(var r=s.getRendererSettings(),o=0;o<this.batches.length;o++)if(i.equals(this.batches[o].settings,r)){this.batches[o].addSystem(s),this.systemToBatchIndex.set(s,o);return}var a;switch(r.renderMode){case at.Trail:a=new w1e(r);break;case at.Mesh:case at.BillBoard:case at.VerticalBillBoard:case at.HorizontalBillBoard:case at.StretchedBillBoard:a=new b1e(r);break}a.addSystem(s),this.batches.push(a),this.systemToBatchIndex.set(s,this.batches.length-1),this.add(a)}},{key:"deleteSystem",value:function(s){var r=this.systemToBatchIndex.get(s);r!=null&&(this.batches[r].removeSystem(s),this.systemToBatchIndex.delete(s))}},{key:"updateSystem",value:function(s){this.deleteSystem(s),this.addSystem(s)}},{key:"update",value:function(s){this.systemToBatchIndex.forEach(function(o,a){a.update(s)});for(var r=0;r<this.batches.length;r++)this.batches[r].update()}}],[{key:"equals",value:function(s,r){return s.material.side===r.material.side&&s.material.blending===r.material.blending&&s.material.transparent===r.material.transparent&&s.material.type===r.material.type&&s.material.alphaTest===r.material.alphaTest&&s.material.map===r.material.map&&s.renderMode===r.renderMode&&s.uTileCount===r.uTileCount&&s.vTileCount===r.vTileCount&&s.instancingGeometry===r.instancingGeometry&&s.renderOrder===r.renderOrder&&s.layers.mask===r.layers.mask}}]),i}(ge),S1e=_1e,AY=function(){function n(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new M;Tt(this,n),$(this,"locations",[]),this.scaleX=e,this.scaleY=i,this.position=s}return Rt(n,[{key:"transform",value:function(e,i){e.x=this.locations[i%this.locations.length].x*this.scaleX+this.position.x,e.y=this.locations[i%this.locations.length].y*this.scaleY+this.position.y,e.z=this.position.z}},{key:"clone",value:function(){var e=new n(this.scaleX,this.scaleY,this.position.clone());return e.locations=this.locations.map(function(i){return i.clone()}),e}},{key:"toJSON",value:function(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(function(e){return{x:e.x,y:e.y}})}}},{key:"fromImage",value:function(e,i){var s=document.createElement("canvas");s.width=e.width,s.height=e.height;var r=s.getContext("2d");if(r){r.drawImage(e,0,0);var o=r.getImageData(0,0,s.width,s.height,{colorSpace:"srgb"});s.remove(),this.locations.length=0;for(var a=0;a<o.height;a++)for(var l=0;l<o.width;l++)o.data[(a*o.width+l)*4+3]>i&&this.locations.push(new K(l,o.height-a))}}}],[{key:"fromJSON",value:function(e){var i=new n(e.scaleX,e.scaleY,new M(e.position[0],e.position[1],e.position[2]));return i.locations=e.locations.map(function(s){return new K(s.x,s.y)}),i}}]),n}();function C1e(n){switch(n.type){case"TextureSequencer":return AY.fromJSON(n);default:return new AY}}var M1e=function(){function n(e){Tt(this,n),$(this,"type","ApplySequences"),$(this,"sequencers",[]),$(this,"time",0),$(this,"index",0),$(this,"pCount",0),$(this,"delay",void 0),$(this,"tempV",new M),this.delay=e}return Rt(n,[{key:"initialize",value:function(e){e.id=this.pCount,e.dst=new M,e.begin=new M,e.inMotion=!1,this.pCount++}},{key:"reset",value:function(){this.time=0,this.index=0,this.pCount=0}},{key:"update",value:function(e,i){var s=this.sequencers[this.index],r=e.id*this.delay;this.time>=s[0].a+r&&this.time<=s[0].b+r?(e.inMotion||(e.inMotion=!0,e.begin.copy(e.position),s[1].transform(e.dst,e.id)),e.position.lerpVectors(e.begin,e.dst,n.BEZIER.genValue((this.time-s[0].a-r)/(s[0].b-s[0].a)))):this.time>s[0].b+r&&(e.inMotion=!1)}},{key:"frameUpdate",value:function(e){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=e}},{key:"appendSequencer",value:function(e,i){this.sequencers.push([e,i])}},{key:"toJSON",value:function(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(function(e){var i=fy(e,2),s=i[0],r=i[1];return{range:s.toJSON(),sequencer:r.toJSON()}})}}},{key:"clone",value:function(){var e=new n(this.delay);return e.sequencers=this.sequencers.map(function(i){return[i[0].clone(),i[1].clone()]}),e}}],[{key:"fromJSON",value:function(e){var i=new n(e.delay);return e.sequencers.forEach(function(s){i.sequencers.push([qi(s.range),C1e(s.sequencer)])}),i}}]),n}();$(M1e,"BEZIER",new QD(0,0,1,1));var pe=function(n){return n[n.Number=0]="Number",n[n.Vec2=1]="Vec2",n[n.Vec3=2]="Vec3",n[n.Vec4=3]="Vec4",n[n.Boolean=4]="Boolean",n[n.AnyType=5]="AnyType",n}({}),xY=Rt(function n(e,i,s,r){Tt(this,n),$(this,"input",void 0),$(this,"inputIndex",void 0),$(this,"output",void 0),$(this,"outputIndex",void 0),this.input=e,this.inputIndex=i,this.input.outputs[i].push(this),this.output=s,this.outputIndex=r,this.output.inputs[r]=this}),E1e=function(){function n(){Tt(this,n),$(this,"visited",new Set),$(this,"graph_",void 0),$(this,"context_",void 0),n.Instance=this}return Rt(n,[{key:"traverse",value:function(e){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");this.visited.add(e.id);for(var i=[],s=0;s<e.inputs.length;s++)if(e.inputs[s]instanceof xY){var r=e.inputs[s].input;this.visited.has(r.id)||this.traverse(r),i.push(r.outputValues[e.inputs[s].inputIndex])}else i.push(e.inputs[s].getValue(this.context_));e.func(this.context_,i,e.outputValues),this.graph_.nodesInOrder.push(e)}},{key:"executeCompiledGraph",value:function(){if(this.context_===void 0)throw new Error("context is undefined");if(this.graph_===void 0)throw new Error("graph is undefined");for(var e=this.graph_.nodesInOrder,i=0;i<e.length;i++){for(var s=[],r=e[i],o=0;o<r.inputs.length;o++)if(r.inputs[o]instanceof xY)s.push(r.inputs[o].input.outputValues[r.inputs[o].inputIndex]);else if(r.inputs[o]!==void 0)s.push(r.inputs[o].getValue(this.context_));else throw new Error("miss input for node ".concat(r.id));r.func(this.context_,s,r.outputValues)}}},{key:"run",value:function(e,i){if(this.graph_=e,this.context_=i,e.compiled)this.executeCompiledGraph();else{e.nodesInOrder.length=0,this.visited.clear();for(var s=0;s<e.outputNodes.length;s++){var r=e.outputNodes[s];this.traverse(r)}e.compiled=!0}}}]),n}();$(E1e,"Instance",void 0);var yi=function(){function n(e){Tt(this,n),$(this,"name",void 0),$(this,"nodeTypeSignatures",[]),this.name=e}return Rt(n,[{key:"addSignature",value:function(e,i,s){this.nodeTypeSignatures.push({inputTypes:e,outputTypes:i,func:s})}}]),n}(),bE=new yi("add");bE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]+i[1]}),bE.addSignature([pe.Vec2,pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].addVectors(i[0],i[1])}),bE.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].addVectors(i[0],i[1])}),bE.addSignature([pe.Vec4,pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].addVectors(i[0],i[1])});var AE=new yi("sub");AE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]-i[1]}),AE.addSignature([pe.Vec2,pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].subVectors(i[0],i[1])}),AE.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].subVectors(i[0],i[1])}),AE.addSignature([pe.Vec4,pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].subVectors(i[0],i[1])});var xE=new yi("mul");xE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]*i[1]}),xE.addSignature([pe.Vec2,pe.Number],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])}),xE.addSignature([pe.Vec3,pe.Number],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])}),xE.addSignature([pe.Vec4,pe.Number],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).multiplyScalar(i[1])});var wE=new yi("div");wE.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]/i[1]}),wE.addSignature([pe.Vec2,pe.Number],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])}),wE.addSignature([pe.Vec3,pe.Number],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])}),wE.addSignature([pe.Vec4,pe.Number],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).divideScalar(i[1])});var T1e=new yi("sin");T1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.sin(i[0])});var R1e=new yi("cos");R1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.cos(i[0])});var I1e=new yi("tan");I1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.tan(i[0])});var L1e=new yi("abs");L1e.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.abs(i[0])});var P1e=new yi("min");P1e.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.min(i[0],i[1])});var k1e=new yi("max");k1e.addSignature([pe.Number,pe.Number],[pe.Number],function(n,e,i,s){s[0]=Math.max(i[0],i[1])});var iG=new yi("dot");iG.addSignature([pe.Vec2,pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])}),iG.addSignature([pe.Vec3,pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])}),iG.addSignature([pe.Vec4,pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].dot(i[1])});var B1e=new yi("cross");B1e.addSignature([pe.Vec3,pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].crossVectors(i[0],i[1])});var nG=new yi("length");nG.addSignature([pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].length()}),nG.addSignature([pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].length()}),nG.addSignature([pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].length()});var sG=new yi("lengthSq");sG.addSignature([pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()}),sG.addSignature([pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()}),sG.addSignature([pe.Vec4],[pe.Number],function(n,e,i,s){s[0]=i[0].lengthSq()});var rG=new yi("normalize");rG.addSignature([pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0].copy(i[0]).normalize()}),rG.addSignature([pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0].copy(i[0]).normalize()}),rG.addSignature([pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0].copy(i[0]).normalize()});var wY=new yi("distance");wY.addSignature([pe.Vec2,pe.Vec2],[pe.Number],function(n,e,i,s){s[0]=i[0].distanceTo(i[1])}),wY.addSignature([pe.Vec3,pe.Vec3],[pe.Number],function(n,e,i,s){s[0]=i[0].distanceTo(i[1])});var O1e=new yi("and");O1e.addSignature([pe.Boolean,pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]&&i[1]});var D1e=new yi("or");D1e.addSignature([pe.Boolean,pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]||i[1]});var G1e=new yi("not");G1e.addSignature([pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=!i[0]});var _E=new yi("equal");_E.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]===i[1]}),_E.addSignature([pe.Vec2,pe.Vec2],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])}),_E.addSignature([pe.Vec3,pe.Vec3],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])}),_E.addSignature([pe.Vec4,pe.Vec4],[pe.Boolean],function(n,e,i,s){s[0]=i[0].equals(i[1])});var N1e=new yi("lessThan");N1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]<i[1]});var F1e=new yi("greaterThan");F1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]>i[1]});var z1e=new yi("lessThanOrEqual");z1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]<=i[1]});var U1e=new yi("greaterThanOrEqual");U1e.addSignature([pe.Number,pe.Number],[pe.Boolean],function(n,e,i,s){s[0]=i[0]>=i[1]});var V1e=new yi("if");V1e.addSignature([pe.Boolean,pe.AnyType,pe.AnyType],[pe.AnyType],function(n,e,i,s){s[0]=i[0]?i[1]:i[2]});var X1e=new yi("number");X1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=e.value});var W1e=new yi("vec2");W1e.addSignature([],[pe.Vec2],function(n,e,i,s){s[0]=e.value});var H1e=new yi("vec3");H1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=e.value});var j1e=new yi("vec4");j1e.addSignature([],[pe.Vec4],function(n,e,i,s){s[0]=e.value});var Q1e=new yi("bool");Q1e.addSignature([],[pe.Boolean],function(n,e,i,s){s[0]=e.value});var Z1e=new yi("particlePosition");Z1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=n.particle[e.property]});var Y1e=new yi("particleVelocity");Y1e.addSignature([],[pe.Vec3],function(n,e,i,s){s[0]=n.particle[e.property]});var K1e=new yi("particleRotation");K1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=n.particle[e.property]});var J1e=new yi("particleAge");J1e.addSignature([],[pe.Number],function(n,e,i,s){s[0]=n.particle[e.property]});var Px=new yi("output");Px.addSignature([pe.Number],[pe.Number],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec2],[pe.Vec2],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec3],[pe.Vec3],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Vec4],[pe.Vec4],function(n,e,i,s){s[0]=i[0]}),Px.addSignature([pe.Boolean],[pe.Boolean],function(n,e,i,s){s[0]=i[0]}),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 16px; font-weight: bold;");var q1e=Object.defineProperty,$1e=Object.getOwnPropertyDescriptor,Pn=(n,e,i,s)=>{for(var r=s>1?void 0:s?$1e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&q1e(e,i,r),r};const kx=te("debugparticles"),ewe=te("noprogressive"),twe=te("debugprogressive");var oG=(n=>(n[n.Birth=0]="Birth",n[n.Collision=1]="Collision",n[n.Death=2]="Death",n[n.Trigger=3]="Trigger",n[n.Manual=4]="Manual",n))(oG||{});class tl extends Pe{constructor(){super(...arguments),p(this,"renderMode"),p(this,"particleMaterial"),p(this,"trailMaterial"),p(this,"particleMesh"),p(this,"maxParticleSize"),p(this,"minParticleSize"),p(this,"velocityScale"),p(this,"cameraVelocityScale"),p(this,"lengthScale")}start(){if(this.maxParticleSize!==.5&&this.minParticleSize!==0&&je()){const e=`ParticleSystem "${this.name}" has non-default min/max particle size. This may not render correctly. Please set min size to 0 and the max size to 0.5 and use the "StartSize" setting instead`;console.warn(e)}}get transparent(){var e;return((e=this.particleMaterial)==null?void 0:e.transparent)??!1}getMaterial(e=!1){let i=e===!0&&this.trailMaterial?this.trailMaterial:this.particleMaterial;return i&&e&&i.side===Vn&&(i=i.clone(),i.side=dn,e?this.trailMaterial=i:this.particleMaterial=i),i&&!ewe&&i._didRequestTextureLOD===void 0&&(i._didRequestTextureLOD=0,twe&&console.log("Load material LOD",i.name),mi.assignTextureLOD(i,0)),i}getMesh(e){let i=null;if(!i&&(this.particleMesh instanceof ue&&(i=this.particleMesh.geometry),i===null)){i=new Kn(1,1);const s=i.attributes.uv;for(let r=0;r<s.count;r++)s.setX(r,1-s.getX(r))}return new ue(i,this.getMaterial())}}Pn([E()],tl.prototype,"renderMode",2),Pn([E(Ft)],tl.prototype,"particleMaterial",2),Pn([E(Ft)],tl.prototype,"trailMaterial",2),Pn([E()],tl.prototype,"maxParticleSize",2),Pn([E()],tl.prototype,"minParticleSize",2),Pn([E()],tl.prototype,"velocityScale",2),Pn([E()],tl.prototype,"cameraVelocityScale",2),Pn([E()],tl.prototype,"lengthScale",2);class SE{constructor(e,i=1){p(this,"_curve"),p(this,"_factor"),p(this,"type","function"),this._curve=e,this._factor=i}genValue(e){return this._curve.evaluate(e,Math.random())*this._factor}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class aG{constructor(e){p(this,"type","value"),p(this,"system"),this.system=e}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}}class iwe extends aG{genValue(){return this.system.textureSheetAnimation.getStartIndex()}}class nwe extends aG{constructor(){super(...arguments),p(this,"_lastPosition",new M),p(this,"_lastDistance",0)}update(){const e=Nt(this.system.gameObject);this._lastDistance=this._lastPosition.distanceTo(e),this._lastPosition.copy(e)}genValue(){if(!this.system.isPlaying||!this.system.emission.enabled||this.system.currentParticles>=this.system.maxParticles)return 0;let e=this.system.emission.rateOverTime.evaluate(this.system.time/this.system.duration,Math.random());if(this.system.deltaTime>0){const r=this.system.emission.rateOverDistance.evaluate(this.system.time/this.system.duration,Math.random());let o=this._lastDistance/this.system.deltaTime*r;Number.isFinite(o)||(o=0),e+=o}const i=this.system.emission.getBurst();i>0&&(e+=i/this.system.deltaTime);const s=this.system.maxParticles-this.system.currentParticles;return et.clamp(e,0,s/this.system.deltaTime)}}class swe extends aG{genValue(){return this.system.isPlaying,0}}class op{constructor(e){p(this,"system"),p(this,"type"),this.type=Object.getPrototypeOf(this).constructor.name||"ParticleSystemBaseBehaviour",e&&(this.system=e)}get context(){return this.system.context}initialize(e){}update(e,i){}frameUpdate(e){}toJSON(){throw new Error("Method not implemented.")}clone(){throw new Error("Method not implemented.")}reset(){}}class rwe extends op{constructor(){super(...arguments),p(this,"type","NeedleTextureSheet")}update(e,i){const s=this.system.textureSheetAnimation;if(s.enabled){const r=e.age/e.life,o=s.evaluate(r);o!==void 0&&(e.uvTile=o)}}}const _Y=Symbol("particleRotation");class owe extends op{constructor(){super(...arguments),p(this,"type","NeedleRotation")}initialize(e){e[_Y]=Math.random()}update(e,i){if(e.rotation===void 0)return;const s=e.age/e.life;if(typeof e.rotation=="number"&&(this.system.rotationOverLifetime.enabled?e.rotation+=this.system.rotationOverLifetime.evaluate(s,e[_Y])*i:this.system.renderer.renderMode===ad.Billboard&&(e.rotation=Math.PI),this.system.rotationBySpeed.enabled)){const r=e.velocity.length();e.rotation+=this.system.rotationBySpeed.evaluate(s,r)*i}}}const SY=Symbol("sizeLerpFactor"),awe=new M;class lwe extends op{constructor(){super(...arguments),p(this,"type","NeedleSize"),p(this,"_minSize",0),p(this,"_maxSize",1)}initialize(e){e[SY]=Math.random(),this._minSize=this.system.renderer.minParticleSize,this._maxSize=this.system.renderer.maxParticleSize}update(e,i){const s=e.age/e.life;let r=1;this.system.sizeOverLifetime.enabled&&(r*=this.system.sizeOverLifetime.evaluate(s,void 0,e[SY]).x);let o=1;if(this.system.renderer.renderMode!==ad.Mesh&&(o=this.system.worldScale.x/this.system.cameraScale),e.size=e.startSize*r*o,this.system.localspace){const a=RY(this.system,awe);e.size*=a.x}}}const gy=Symbol("particleLife"),lG=Symbol("trailLifetime"),CY=Symbol("trailStartLength"),cG=Symbol("trailWidthRandom");class cwe extends op{constructor(){super(...arguments),p(this,"type","NeedleTrail")}initialize(e){e instanceof Ex&&(e[gy]=e.life,this.system.trails.enabled&&this.system.trails.dieWithParticles===!1&&(e[lG]=this.system.trails.lifetime.evaluate(Math.random(),Math.random()),e.life+=e[lG]),e[CY]=e.length,e[cG]=Math.random())}update(e){var i;if((i=this.system.trails)!=null&&i.enabled&&e instanceof Ex){const s=e,r=e.age/e[gy],o=e.previous.values(),a=e.previous.length;for(let l=0;l<a;l++){const c=o.next().value,h=1-l/(a-1);let d=e.size;d<=0&&!this.system.trails.sizeAffectsWidth&&(d=20*this.system.trails.widthOverTrail.evaluate(.5,s[cG])),c.size=this.system.trails.getWidth(d,r,h,s[cG]),c.color.copy(e.color),this.system.trails.getColor(c.color,r,h)}if(e.age>e[gy]){e.velocity.set(0,0,0);const l=(e.age-e[gy])/e[lG];s.length=et.lerp(e[CY],0,l)}}}}const CE=Symbol("startVelocity"),MY=Symbol("gravityModifier"),hG=Symbol("gravitySpeed"),ME=Symbol("velocity lerp factor"),dG=new M;class hwe extends op{constructor(){super(...arguments),p(this,"type","NeedleVelocity"),p(this,"_gravityDirection",new M)}initialize(e){var i,s;const r=this.system.main.simulationSpeed;e.startSpeed=this.system.main.startSpeed.evaluate(Math.random(),Math.random()),e.velocity.copy(this.system.shape.getDirection(e,e.position)).multiplyScalar(e.startSpeed),(i=this.system.inheritVelocity)!=null&&i.enabled&&this.system.inheritVelocity.applyInitial(e.velocity),e[CE]?e[CE].copy(e.velocity):e[CE]=e.velocity.clone();const o=this.system.main.gravityModifier.evaluate(Math.random(),Math.random());e[MY]=o*r,e[hG]=o*r*.5,e[ME]=Math.random(),(s=this.system.velocityOverLifetime)==null||s.init(e),this._gravityDirection.set(0,-1,0),this.system.main.simulationSpace===ax.Local&&this._gravityDirection.applyQuaternion(this.system.worldQuaternionInverted).normalize()}update(e,i){var s;const r=e[CE],o=e[MY];if(o!==0){const m=o*e[hG];dG.copy(this._gravityDirection).multiplyScalar(m),e[hG]+=i*.05,r.add(dG)}e.velocity.copy(r);const a=e.age/e.life;(s=this.system.inheritVelocity)!=null&&s.enabled&&this.system.inheritVelocity.applyCurrent(e.velocity,a,e[ME]);const l=this.system.noise;l.enabled&&l.apply(0,e.position,e.velocity,i,e.age,e.life);const c=this.system.sizeBySpeed;c!=null&&c.enabled&&(e.size=c.evaluate(e.velocity,a,e[ME],e.size));const h=this.system.colorBySpeed;h!=null&&h.enabled&&h.evaluate(e.velocity,e[ME],e.color);const d=this.system.velocityOverLifetime;d.enabled&&d.apply(e,0,e.position,e.velocity,i,e.age,e.life);const u=this.system.limitVelocityOverLifetime;u.enabled&&u.apply(e.position,r,e.velocity,e.size,a,i,1),this.system.worldspace&&e.velocity.multiply(this.system.worldScale)}}const EY=Symbol("colorLerpFactor"),TY=new Li(1,1,1,1),df=new Li(1,1,1,1);class dwe extends op{constructor(){super(...arguments),p(this,"type","NeedleColor")}initialize(e){}_init(e){const i=this.system.renderer.particleMaterial;df.copy(this.system.main.startColor.evaluate(Math.random())),i!=null&&i.color&&(TY.copy(i.color),df.multiply(TY)),df.convertLinearToSRGB(),e.startColor.set(df.r,df.g,df.b,df.alpha),e.color.copy(e.startColor),e[EY]=Math.random()}update(e,i){if(e.age===0&&this._init(e),this.system.colorOverLifetime.enabled){const s=e.age/e.life,r=this.system.colorOverLifetime.color.evaluate(s,e[EY]);e.color.set(r.r,r.g,r.b,"alpha"in r?r.alpha:1).multiply(e.startColor)}else e.color.copy(e.startColor)}}class uwe{constructor(e){p(this,"system"),p(this,"emission"),p(this,"autoDestroy"),p(this,"startLength"),p(this,"emissionBursts"),p(this,"onlyUsedByOther"),p(this,"behaviors",[]),p(this,"rendererEmitterSettings",{startLength:new Wr(220),followLocalOrigin:!1}),p(this,"flatWhiteTexture"),p(this,"clonedTexture",{original:void 0,clone:void 0}),this.system=e,this.emission=new nwe(this.system)}get anim(){return this.system.textureSheetAnimation}get prewarm(){return!1}get material(){return this.system.renderer.getMaterial(this.system.trails.enabled)}get layers(){return this.system.gameObject.layers}update(){this.emission.update()}get looping(){return this.system.main.loop}get duration(){return this.system.duration}get shape(){return this.system.shape}get startLife(){return new SE(this.system.main.startLifetime)}get startSpeed(){return new SE(this.system.main.startSpeed)}get startRotation(){return new SE(this.system.main.startRotation)}get startSize(){return new SE(this.system.main.startSize)}get startColor(){return new vE(new Ke(1,1,1,1))}get emissionOverTime(){return this.emission}get emissionOverDistance(){return new swe(this.system)}get instancingGeometry(){return this.system.renderer.getMesh(this.system.renderer.renderMode).geometry}get renderMode(){if(this.system.trails.enabled===!0)return at.Trail;switch(this.system.renderer.renderMode){case ad.Billboard:return at.BillBoard;case ad.Stretch:return at.StretchedBillBoard;case ad.HorizontalBillboard:return at.HorizontalBillBoard;case ad.VerticalBillboard:return at.VerticalBillBoard;case ad.Mesh:return at.Mesh}return at.BillBoard}get speedFactor(){var e;let i=this.system.main.simulationSpeed;return((e=this.system.renderer)==null?void 0:e.renderMode)===ad.Stretch&&(i*=this.system.renderer.velocityScale??1),i}get texture(){const e=this.material;if(e&&e.map){const i=e.map;if(this.clonedTexture.original!==i||!this.clonedTexture.clone){const s=i.clone();s.premultiplyAlpha=!1,s.colorSpace=ki,this.clonedTexture.original=i,this.clonedTexture.clone=s}return this.clonedTexture.clone}return this.flatWhiteTexture||(this.flatWhiteTexture=_B(new Li(1,1,1,1),1)),this.flatWhiteTexture}get startTileIndex(){return new iwe(this.system)}get uTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesX:void 0}get vTileCount(){var e;return this.anim.enabled?(e=this.anim)==null?void 0:e.numTilesY:void 0}get renderOrder(){return 1}get blending(){var e;return((e=this.system.renderer.particleMaterial)==null?void 0:e.blending)??Md}get transparent(){return this.system.renderer.transparent}get worldSpace(){return this.system.main.simulationSpace===ax.World}}class pwe{constructor(){p(this,"burstIndex",0),p(this,"burstWaveIndex",0),p(this,"time",0),p(this,"waitEmiting",0)}}const EE=class extends Pe{constructor(){super(...arguments),p(this,"_state"),p(this,"colorOverLifetime"),p(this,"main"),p(this,"emission"),p(this,"sizeOverLifetime"),p(this,"shape"),p(this,"noise"),p(this,"trails"),p(this,"velocityOverLifetime"),p(this,"limitVelocityOverLifetime"),p(this,"inheritVelocity"),p(this,"colorBySpeed"),p(this,"textureSheetAnimation"),p(this,"rotationOverLifetime"),p(this,"rotationBySpeed"),p(this,"sizeBySpeed"),p(this,"_cameraScale",1),p(this,"__worldQuaternion",new Se),p(this,"_worldQuaternionInverted",new Se),p(this,"_worldScale",new M),p(this,"_worldPositionFrame",-1),p(this,"_worldPos",new M),p(this,"_renderer"),p(this,"_batchSystem"),p(this,"_particleSystem"),p(this,"_interface"),p(this,"_container"),p(this,"_time",0),p(this,"_isPlaying",!0),p(this,"_isUsedAsSubsystem",!1),p(this,"_didPreWarm",!1),p(this,"_bursts"),p(this,"_subEmitterSystems"),p(this,"_lastBatchesCount",-1),p(this,"lastMaterialVersion",-1)}play(n=!1){var e;n&&ie.foreachComponent(this.gameObject,i=>{i instanceof EE&&i!==this&&i.play(!1)},!0),this._isPlaying=!0,this._particleSystem&&(this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1),(e=this.emission)==null||e.reset()}pause(n=!0){n&&ie.foreachComponent(this.gameObject,e=>{e instanceof EE&&e!==this&&e.pause(!1)},!0),this._isPlaying=!1}stop(n=!0,e=!1){n&&ie.foreachComponent(this.gameObject,i=>{i instanceof EE&&i!==this&&i.stop(!1,e)},!0),this._isPlaying=!1,this._time=0,e&&this.reset()}reset(){var n;this._time=0,this._particleSystem&&(this._particleSystem.particleNum=0,this._particleSystem.emissionState.time=0,this._particleSystem.emitEnded=!1,(n=this.emission)==null||n.reset())}emit(n){if(this._particleSystem){this.onUpdate(),n=Math.min(n,this.maxParticles-this.currentParticles),this._state||(this._state=new pwe),this._state.waitEmiting=n,this._state.time=0;const e=this._particleSystem.emitEnded;this._particleSystem.emitEnded=!1,this._particleSystem.emit(this.deltaTime,this._state,this._particleSystem.emitter.matrixWorld),this._particleSystem.emitEnded=e}}get playOnAwake(){return this.main.playOnAwake}set playOnAwake(n){this.main.playOnAwake=n}get renderer(){return this._renderer}get isPlaying(){return this._isPlaying}get currentParticles(){var n;return((n=this._particleSystem)==null?void 0:n.particleNum)??0}get maxParticles(){return this.main.maxParticles}get time(){return this._time}get duration(){return this.main.duration}get deltaTime(){return this.context.time.deltaTime*this.main.simulationSpeed}get scale(){return this.gameObject.scale.x}get cameraScale(){return this._cameraScale}get container(){return this._container}get worldspace(){return this.main.simulationSpace===ax.World}get localspace(){return this.main.simulationSpace===ax.Local}get worldQuaternion(){return this.__worldQuaternion}get worldQuaternionInverted(){return this._worldQuaternionInverted}get worldScale(){return this._worldScale}get worldPos(){return this._worldPositionFrame!==this.context.time.frame&&(this._worldPositionFrame=this.context.time.frame,Nt(this.gameObject,this._worldPos)),this._worldPos}get matrixWorld(){return this._container.matrixWorld}get isSubsystem(){return this._isUsedAsSubsystem}addBehaviour(n){return this._particleSystem?(n instanceof op&&(n.system=this),je()&&console.log("add behaviour",n),this._particleSystem.addBehavior(n),!0):!1}removeBehaviour(n){if(!this._particleSystem)return!1;const e=this._particleSystem.behaviors,i=e.indexOf(n);return i!==-1&&e.splice(i,1),!0}removeAllBehaviours(){return this._particleSystem?(this._particleSystem.behaviors.length=0,!0):!1}get behaviours(){return this._particleSystem?this._particleSystem.behaviors:null}get particleSystem(){return this._particleSystem??null}set bursts(n){for(let e=0;e<n.length;e++){const i=n[e];if(!(i instanceof cx)){const s=new cx;d0(s,i),n[e]=s}}this._bursts=n}set subEmitterSystems(n){for(let e=0;e<n.length;e++){const i=n[e];if(!(i instanceof Bx)){const s=new Bx;d0(s,i),n[e]=s}}kx&&n.length>0&&console.log("SubEmitters: ",n,this),this._subEmitterSystems=n}onAfterDeserialize(n){if(this._subEmitterSystems&&Array.isArray(this._subEmitterSystems))for(const e of this._subEmitterSystems)e._deserialize(this.context,this.gameObject)}awake(){if(this._worldPositionFrame=-1,this._renderer=this.gameObject.getComponent(tl),!this.main)throw new Error("Not Supported: ParticleSystem needs a serialized MainModule. Creating new particle systems at runtime is currently not supported.");this._container=new ge,this._container.matrixAutoUpdate=!1,this.context.scene.add(this._container),this._batchSystem=new S1e,this._batchSystem.name=this.gameObject.name,this._container.add(this._batchSystem),this._interface=new uwe(this),this._particleSystem=new p1e(this._interface),this._particleSystem.addBehavior(new lwe(this)),this._particleSystem.addBehavior(new dwe(this)),this._particleSystem.addBehavior(new rwe(this)),this._particleSystem.addBehavior(new owe(this)),this._particleSystem.addBehavior(new hwe(this)),this._particleSystem.addBehavior(new cwe(this)),this._batchSystem.addSystem(this._particleSystem);const n=this._particleSystem.emitter;this.context.scene.add(n),this.inheritVelocity.system&&this.inheritVelocity.system!==this&&(this.inheritVelocity=this.inheritVelocity.clone()),this.inheritVelocity.awake(this),kx&&(console.log(this),this.gameObject.add(new Ro(1)))}start(){this.addSubParticleSystems(),this.updateLayers(),this.renderer.particleMesh instanceof ue&&this._interface.renderMode==at.Mesh&&mi.assignMeshLOD(this.renderer.particleMesh,0).then(n=>{n&&this.particleSystem&&this._interface.renderMode==at.Mesh&&(this.particleSystem.instancingGeometry=n)})}onDestroy(){var n,e,i,s;(n=this._container)==null||n.removeFromParent(),(e=this._batchSystem)==null||e.removeFromParent(),(i=this._particleSystem)==null||i.emitter.removeFromParent(),(s=this._particleSystem)==null||s.dispose()}onEnable(){this.main&&(this.inheritVelocity&&(this.inheritVelocity.system=this),this._batchSystem&&(this._batchSystem.visible=!0),this.playOnAwake&&this.play(),this._isPlaying=this.playOnAwake)}onDisable(){this._batchSystem&&(this._batchSystem.visible=!1)}onBeforeRender(){var n;this.main&&(this._didPreWarm===!1&&((n=this.main)==null?void 0:n.prewarm)===!0&&(this._didPreWarm=!0,this.preWarm()),this.onUpdate(),this.onSimulate(this.deltaTime))}preWarm(){var n;if(!((n=this.emission)!=null&&n.enabled)||this.emission.rateOverTime.getMax()<=0)return;const e=1/60,i=this.main.duration,s=this.main.startLifetime.getMax(),r=1e3,o=Math.min(Math.max(i,s)/Math.max(.01,this.main.simulationSpeed),r),a=Math.ceil(o/e),l=Date.now();kx&&console.log(`Particles ${this.name} - Prewarm for ${a} frames (${o} sec). Duration: ${i}, Lifetime: ${s}`);for(let c=0;c<a&&!(this.currentParticles>=this.maxParticles);c++){const h=Date.now()-l;if(h>2e3){console.warn(`Particles ${this.name} - Prewarm took too long. Aborting: ${h}`);break}this.onUpdate(),this.onSimulate(e)}}onSimulate(n){if(this._batchSystem){let e=this.context.time.frameCount%60===0;this._lastBatchesCount!==this._batchSystem.batches.length&&(this._lastBatchesCount=this._batchSystem.batches.length,e=!0),e&&this.updateLayers(),this._batchSystem.update(n)}this._time+=n,this._time>this.duration&&(this._time=0)}updateLayers(){if(this._batchSystem)for(let n=0;n<this._batchSystem.batches.length;n++){const e=this._batchSystem.batches[n];e.layers.disableAll();const i=this.layer;e.layers.mask=1<<i}}onUpdate(){var n,e;const i=this.renderer.getMaterial(this.trails.enabled);if(i&&i.version!=this.lastMaterialVersion&&this._particleSystem&&(this.lastMaterialVersion=i.version,this._particleSystem.texture=this._interface.texture),this._bursts&&(this.emission.bursts=this._bursts,delete this._bursts),!this._isPlaying)return;const s=this.context.mainCamera;if(s){const a=Yi(s);this._cameraScale=a.x}const r=!this.worldspace,o=this.gameObject;if(Bi(o,this.__worldQuaternion),this._worldQuaternionInverted.copy(this.__worldQuaternion).invert(),Yi(this.gameObject,this._worldScale),r&&this._container&&(n=this.gameObject)!=null&&n.parent){const a=RY(this,dG);this._container.matrix.makeScale(a.x,a.y,a.z),this._container.matrix.makeRotationFromQuaternion(this.__worldQuaternion),this._container.matrix.setPosition(this.worldPos),this._container.matrix.scale(this.gameObject.scale)}this.emission.system=this,this._interface.update(),this.shape.update(this,this.context,this.main.simulationSpace,this.gameObject),this.noise.update(this.context),(e=this.inheritVelocity)==null||e.update(this.context),this.velocityOverLifetime.update(this)}addSubParticleSystems(){var n;if(this._subEmitterSystems&&this._particleSystem)for(const e of this._subEmitterSystems){e.particleSystem&&(e.particleSystem.__internalAwake?e.particleSystem.__internalAwake():je()&&console.warn("SubParticleSystem serialization issue(?)",e.particleSystem,e));const i=(n=e.particleSystem)==null?void 0:n._particleSystem;if(i){e.particleSystem._isUsedAsSubsystem=!0;const s=new TE(this,this._particleSystem,e.particleSystem,i);s.emitterType=e.type,s.emitterProbability=e.emitProbability,this._particleSystem.addBehavior(s)}else kx&&console.warn("Could not add SubParticleSystem",e,this)}}};let hs=EE;Pn([E(hx)],hs.prototype,"colorOverLifetime",2),Pn([E(hr)],hs.prototype,"main",2),Pn([E(Uc)],hs.prototype,"emission",2),Pn([E(Ku)],hs.prototype,"sizeOverLifetime",2),Pn([E(Rn)],hs.prototype,"shape",2),Pn([E(Pi)],hs.prototype,"noise",2),Pn([E(xn)],hs.prototype,"trails",2),Pn([E(In)],hs.prototype,"velocityOverLifetime",2),Pn([E(ls)],hs.prototype,"limitVelocityOverLifetime",2),Pn([E(Ju)],hs.prototype,"inheritVelocity",2),Pn([E($m)],hs.prototype,"colorBySpeed",2),Pn([E(dr)],hs.prototype,"textureSheetAnimation",2),Pn([E($a)],hs.prototype,"rotationOverLifetime",2),Pn([E(ya)],hs.prototype,"rotationBySpeed",2),Pn([E(vo)],hs.prototype,"sizeBySpeed",2);class Bx{constructor(){p(this,"particleSystem"),p(this,"emitProbability",1),p(this,"properties"),p(this,"type")}_deserialize(e,i){const s=this.particleSystem;if(s instanceof hs)return;let r="";s&&typeof s.guid=="string"&&(r=s.guid,this.particleSystem=ie.findByGuid(r,i)),kx&&!(this.particleSystem instanceof hs)&&console.warn("Could not find particle system for sub emitter",r,i,this)}}function RY(n,e){if(e.set(1,1,1),n.gameObject.parent&&n.localspace)switch(n.main.scalingMode){case oD.Local:e=Yi(n.gameObject.parent,e),e.x=1/e.x,e.y=1/e.y,e.z=1/e.z;break;default:if(!n.unsupported_scaling_mode){n.unsupported_scaling_mode=!0;const i="ParticleSystem scale mode "+oD[n.main.scalingMode]+" is not supported";je()&&Oi(i),console.warn(i,n.name,n)}e=Yi(n.gameObject,e);break}return e}new M(1,1,1),new M(0,0,1);class TE{constructor(e,i,s,r){p(this,"type","NeedleParticleSubEmitter"),p(this,"emitterType"),p(this,"emitterProbability"),p(this,"q_",new Se),p(this,"v_",new M),p(this,"v2_",new M),p(this,"_emitterMatrix",new he),p(this,"_circularBuffer"),this.system=e,this.particleSystem=i,this.subSystem=s,this.subParticleSystem=r,this.subParticleSystem&&this.subParticleSystem&&(this.subParticleSystem.onlyUsedByOther=!0);const o=1e3;this._circularBuffer=new Yo(()=>new he,o)}clone(){throw new Error("Method not implemented.")}initialize(e){e.emissionState={burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0},this._emitterMatrix.copy(this.subSystem.matrixWorld).invert().premultiply(this.system.matrixWorld),this._emitterMatrix.setPosition(0,0,0),this.emitterType===oG.Birth&&this.run(e)}update(e,i){this.run(e)}frameUpdate(e){}toJSON(){}reset(){}run(e){if(this.subSystem.currentParticles>=this.subSystem.main.maxParticles||!this.subParticleSystem||!e.emissionState||this.emitterProbability&&Math.random()>this.emitterProbability)return;const i=this.system.deltaTime;if(this.emitterType===oG.Death){let r=e.life;if(e[gy]!==void 0&&(r=e[gy]),!(e.age+i*1.2>=r))return;const o=this.subSystem.main.maxParticles-this.subSystem.currentParticles;e.emissionState.waitEmiting=o}const s=new he;s.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1),this.particleSystem.worldSpace||s.multiplyMatrices(this._emitterMatrix,s),this.subParticleSystem.emit(i,e.emissionState,s)}}var mwe=Object.defineProperty,fwe=Object.getOwnPropertyDescriptor,gwe=(n,e,i,s)=>{for(var r=s>1?void 0:s?fwe(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&mwe(e,i,r),r};class Ox extends Us{constructor(){super(...arguments),p(this,"granularity",new qe(10))}get typeName(){return"PixelationEffect"}onCreateEffect(){const e=new rV;return this.granularity.onValueChanged=i=>{e.granularity=i},e}}gwe([E(qe)],Ox.prototype,"granularity",2),Ja("PixelationEffect",Ox);class Ky extends Pe{constructor(){super(...arguments),p(this,"_didAssignPlayerColor",!1),p(this,"tryAssignColor",()=>{const e=ie.getComponentInParent(this.gameObject,ua);if(e&&e.owner)return this._didAssignPlayerColor=!0,this.assignUserColor(e.owner),!0;const i=ie.getComponentInParent(this.gameObject,ar);return i!=null&&i.connectionId?(this._didAssignPlayerColor=!0,this.assignUserColor(i.connectionId),!0):!1})}onEnable(){this.context.connection.beginListen(Xt.JoinedRoom,this.tryAssignColor),this._didAssignPlayerColor||this.startCoroutine(this.waitForConnection())}onDisable(){this.context.connection.stopListen(Xt.JoinedRoom,this.tryAssignColor)}*waitForConnection(){for(;!this.destroyed&&this.activeAndEnabled&&(yield T4(.2),!this.tryAssignColor()););}assignUserColor(e){const i=Ky.hashCode(e),s=Ky.colorFromHashCode(i);if(this.gameObject.type==="Mesh"){const r=this.gameObject;this.assignColor(s,e,r)}else if(this.gameObject.children)for(const r of this.gameObject.children){const o=r;o.material&&o.material.color&&this.assignColor(s,e,o)}}assignColor(e,i,s){let r=s.material;r&&(r._playerMaterial!==i&&(r=r.clone(),r._playerMaterial=i,s.material=r),r.color=e)}static hashCode(e){var i=0,s,r;if(e.length===0)return i;for(s=0;s<e.length;s++)r=e.charCodeAt(s),i=(i<<5)-i+r,i|=0;return i}static colorFromHashCode(e){const i=(e&16711680)>>16,s=(e&65280)>>8,r=e&255;return new Ae(i/255,s/255,r/255)}}const Dx=new pt;Dx.setAttribute("position",new $e(new Float32Array([-1,-1,3,-1,-1,3]),2)),Dx.setAttribute("uv",new $e(new Float32Array([0,0,2,0,0,2]),2)),Dx.boundingSphere=new tn,Dx.computeBoundingSphere=function(){};const ywe=new oc;class uf{constructor(e){this._mesh=new ue(Dx,e),this._mesh.frustumCulled=!1}render(e){e.render(this._mesh,ywe)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const vwe={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new he},viewMat:{value:new he},projViewMat:{value:new he},projectionMatrixInv:{value:new he},viewMatrixInv:{value:new he},cameraPos:{value:new M},resolution:{value:new K},biasAdjustment:{value:new K},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|
|
7094
7094
|
varying vec2 vUv;
|
|
7095
7095
|
void main() {
|
|
7096
7096
|
vUv = uv;
|
|
@@ -7951,7 +7951,7 @@ void main() {
|
|
|
7951
7951
|
#include <colorspace_fragment>
|
|
7952
7952
|
}
|
|
7953
7953
|
`;function F_e(n){const e="vec4("+n.r.toFixed(3)+","+n.g.toFixed(3)+","+n.b.toFixed(3)+","+n.a.toFixed(3)+")";zE&&console.log(e);const i=new ue(new Kn(2,2),new Bt({name:"BackgroundMaterial",uniforms:eg.clone(Ks.background.uniforms),vertexShader:Ks.background.vertexShader,fragmentShader:N_e.replaceAll("<backgroundTint>",e),side:Ai,depthTest:!1,depthWrite:!1,fog:!1}));return i.geometry.deleteAttribute("normal"),Object.defineProperty(i.material,"map",{get:function(){return this.threeTexture}}),i.renderOrder=-1e4,i.layers.set(2),i.frustumCulled=!1,i.setTexture=function(s){i.material.uniforms.t2D.value=s},i}var z_e=Object.defineProperty,U_e=Object.getOwnPropertyDescriptor,yf=(n,e,i,s)=>{for(var r=s>1?void 0:s?U_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&z_e(e,i,r),r};const JY=te("debugimagetracking"),EG=class{constructor(n,e,i,s,r,o){p(this,"measuredSize"),p(this,"state"),p(this,"_position"),p(this,"_rotation"),p(this,"_trackingComponent"),p(this,"_trackedImage"),p(this,"_bitmap"),p(this,"_pose"),this._trackingComponent=n,this._trackedImage=e,this._bitmap=i,this.measuredSize=s,this.state=r,this._pose=o}get url(){return this._trackedImage.image??""}get widthInMeters(){return this._trackedImage.widthInMeters??void 0}get bitmap(){return this._bitmap}get model(){return this._trackedImage}getPosition(n){return this.ensureTransformData(),n.copy(this._position),n}getQuaternion(n){return this.ensureTransformData(),n.copy(this._rotation),n}applyToObject(n,e=void 0){this.ensureTransformData();const i=n.position.distanceToSquared(this._position)/.05+n.quaternion.angleTo(this._rotation)/.05;e&&(e*=Math.max(1,i)),e===void 0||e>=1?(n.position.copy(this._position),n.quaternion.copy(this._rotation)):(e=Math.max(0,Math.min(1,e)),n.position.lerp(this._position,e),n.quaternion.slerp(this._rotation,e))}ensureTransformData(){if(!this._position){this._position=EG._positionBuffer.get(),this._rotation=EG._rotationBuffer.get();const n=this._pose.transform,e=Et.active.convertSpace(n);this._position.copy(e?.position),this._rotation.copy(e?.quaternion)}}};let Ay=EG;p(Ay,"_positionBuffer",new Yo(()=>new M,20)),p(Ay,"_rotationBuffer",new Yo(()=>new Se,20));class eh{constructor(){p(this,"image"),p(this,"widthInMeters",.25),p(this,"object"),p(this,"createObjectInstance",!1),p(this,"imageDoesNotMove",!1),p(this,"hideWhenTrackingIsLost",!0)}}yf([E(URL)],eh.prototype,"image",2),yf([E()],eh.prototype,"widthInMeters",2),yf([E(ei)],eh.prototype,"object",2),yf([E()],eh.prototype,"createObjectInstance",2),yf([E()],eh.prototype,"imageDoesNotMove",2),yf([E()],eh.prototype,"hideWhenTrackingIsLost",2);class V_e{constructor(e,i,s){p(this,"filename"),p(this,"widthInMeters"),p(this,"imageData"),this.filename=e,this.imageData=i,this.widthInMeters=s}get extensionName(){return"image-tracking"}onAfterHierarchy(e,i){i.beginBlock('def Preliminary_ReferenceImage "AnchoringReferenceImage"'),i.appendLine("uniform asset image = @image_tracking/"+this.filename+"@"),i.appendLine("uniform double physicalWidth = "+(this.widthInMeters*100).toFixed(8)),i.closeBlock()}onBeforeBuildDocument(e){const i=ie.findObjectOfType(xy);!i||!i.trackedImages||i.trackedImages.length>1&&(je()&&Oi("USDZ: Only one tracked image is supported."),console.warn("USDZ: Only one tracked image is supported."))}onAfterSerialize(e){e.files["image_tracking/"+this.filename]=this.imageData}onExportObject(e,i,s){var r;const o=ie.findObjectOfType(xy);if(!(!o||!o.trackedImages)){for(const a of o.trackedImages)if(((r=a.object)==null?void 0:r.asset)===e){const l=ie.findObjectOfType(Ln);if(!l)continue;const{scale:c,target:h}=l.getARScaleAndTarget();let d=e;const u=new he;if(e!==h)for(;d.parent&&d.parent!==h;)d=d.parent,u.premultiply(d.matrix);const m=u.clone().invert();i.setMatrix(m.scale(new M(c,c,c)));break}}}}var TG;const jx=(TG=class extends Pe{constructor(){super(...arguments),p(this,"trackedImages"),p(this,"smooth",!0),p(this,"trackedImageIndexMap",new Map),p(this,"imageToObjectMap",new Map),p(this,"currentImages",[]),p(this,"onImageTrackingUpdate",n=>{const e=Et.active;if(e)for(const i of n){const s=i.model,r=i.state==="tracked";if(!s.object)continue;let o=this.imageToObjectMap.get(s);if(o===void 0)o={object:null,frames:0,lastTrackingTime:Date.now()},this.imageToObjectMap.set(s,o),s.object.loadAssetAsync().then(a=>{if(s.createObjectInstance&&a&&(a=ie.instantiate(a)),a){o.object=a;for(const l of a.getComponentsInChildren(Dn))l.setInstancingEnabled(!1);e.rig?(e.rig.gameObject.add(a),i.applyToObject(a),a.activeSelf||ie.setActive(a,!0)):console.warn("XRImageTracking: missing XRRig")}});else{if(o.frames++,r&&(o.lastTrackingTime=Date.now()),s.imageDoesNotMove&&o.frames>10||!o.object)continue;e.rig&&(e.rig.gameObject.add(o.object),i.applyToObject(o.object,this.smooth?this.context.time.deltaTimeUnscaled*3:void 0),o.object.activeSelf||ie.setActive(o.object,!0))}}})}awake(){if(JY&&console.log(this),!!this.trackedImages){for(const n of this.trackedImages)if(n.image&&!jx._imageElements.has(n.image)){const e=n.image;jx._imageElements.set(e,null);const i=document.createElement("img");i.src=e,i.addEventListener("load",async()=>{const s=await createImageBitmap(i);jx._imageElements.set(e,s);const r=await Gj(s);if(r){const o=await(await r.convertToBlob({type:"image/png"})).arrayBuffer(),a=ie.findObjectOfType(Ln);a&&this.trackedImages&&(a.extensions.push(new V_e("marker.png",new Uint8Array(o),this.trackedImages[0].widthInMeters)),a.anchoringType="image")}})}}}onBeforeXR(n,e){var i;if(this.trackedImages){e.optionalFeatures=e.optionalFeatures||[],e.optionalFeatures.includes("image-tracking")||e.optionalFeatures.push("image-tracking"),e.trackedImages=[];for(const s of this.trackedImages)if((i=s.image)!=null&&i.length&&s.widthInMeters>0){const r=jx._imageElements.get(s.image);r&&(this.trackedImageIndexMap.set(e.trackedImages.length,s),e.trackedImages.push({image:r,widthInMeters:s.widthInMeters}))}}}onEnterXR(n){var e;if(this.trackedImages){for(const i of this.trackedImages)if((e=i.object)!=null&&e.asset){const s=i.object.asset;s.userData||(s.userData={});const r={visible:s.visible,parent:s.parent,matrix:s.matrix.clone()};s.userData["image-tracking"]=r}}for(const i of this.imageToObjectMap.values())i.frames=0}onLeaveXR(n){var e,i;if(this.trackedImages){for(const s of this.trackedImages)if((e=s.object)!=null&&e.asset){const r=s.object.asset;if(r.userData){const o=r.userData["image-tracking"];o&&(r.visible=o.visible,(i=o.parent)==null||i.add(r),r.matrix.copy(o.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)),delete r.userData["image-tracking"]}}}}onUpdateXR(n){var e;this.currentImages.length=0;const i=n.xr.frame;if(!i)return;if("getImageTrackingResults"in i){if(((e=n.xr.session.enabledFeatures)==null?void 0:e.includes("image-tracking"))===!1)return;if(i.session&&typeof i.getImageTrackingResults=="function"){const r=i.getImageTrackingResults();if(r.length>0){const o=this.context.renderer.xr.getReferenceSpace();if(o){for(const a of r){const l=a.trackingState,c=a.index,h=this.trackedImageIndexMap.get(c);if(h){const d=i.getPose(a.imageSpace,o),u=new Ay(this,h,a.image,a.measuredSize,l,d);this.currentImages.push(u)}else JY&&console.warn("No tracked image for index",c)}if(this.currentImages.length>0)try{this.dispatchEvent(new CustomEvent("image-tracking",{detail:this.currentImages})),this.onImageTrackingUpdate(this.currentImages)}catch(a){console.error(a)}}}}}else{const r=`Image tracking is currently not supported on this device. On Chrome for Android, you can enable the <a target="_blank" href="#" onclick="() => console.log('I')">chrome://flags/#webxr-incubations</a> flag.`;this.didPrintWarning||(this.didPrintWarning=!0,console.log(r)),Oi(r);return}const s=1e3;for(const[r,o]of this.imageToObjectMap){if(!o.object||!r||r.hideWhenTrackingIsLost===!1)continue;let a=!1;for(const l of this.currentImages)if(l.model===r){const c=Date.now()-o.lastTrackingTime;if(r.imageDoesNotMove||l.state==="tracked"||c<=s){a=!0;break}}a||ie.setActive(o.object,!1)}}},p(TG,"_imageElements",new Map),TG);let xy=jx;yf([E(eh)],xy.prototype,"trackedImages",2);const Qx=new M,Zx=new M,qY=new Gt;class X_e extends Lr{constructor(e,i=1,s=16711680){const r=new pt,o=e.geometry.attributes.normal.count,a=new st(o*2*3,3);r.setAttribute("position",a),super(r,new Vi({color:s,toneMapped:!1})),this.object=e,this.size=i,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){this.object.updateMatrixWorld(!0),qY.getNormalMatrix(this.object.matrixWorld);const e=this.object.matrixWorld,i=this.geometry.attributes.position,s=this.object.geometry;if(s){const r=s.attributes.position,o=s.attributes.normal;let a=0;for(let l=0,c=r.count;l<c;l++)Qx.fromBufferAttribute(r,l).applyMatrix4(e),Zx.fromBufferAttribute(o,l),Zx.applyMatrix3(qY).normalize().multiplyScalar(this.size).add(Qx),i.setXYZ(a,Qx.x,Qx.y,Qx.z),a=a+1,i.setXYZ(a,Zx.x,Zx.y,Zx.z),a=a+1}i.needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}var W_e=Object.defineProperty,H_e=Object.getOwnPropertyDescriptor,wy=(n,e,i,s)=>{for(var r=s>1?void 0:s?H_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&W_e(e,i,r),r};const vf=te("debugplanetracking");class md extends Pe{constructor(){super(...arguments),p(this,"dataTemplate"),p(this,"occluder",!0),p(this,"initiateRoomCaptureIfNoData",!0),p(this,"usePlaneData",!0),p(this,"useMeshData",!0),p(this,"runInVR",!0),p(this,"bounds",new Wt),p(this,"center",new M),p(this,"labelOffset",new M),p(this,"_dataId",1),p(this,"_allPlanes",new Map),p(this,"_allMeshes",new Map),p(this,"firstTimeNoPlanesDetected",-100),p(this,"makeOccluder",(e,i,s=!1)=>{if(i){if(i instanceof Array){for(const r of i)this.makeOccluder(e,r,s);return}!s&&!i.name.toLowerCase().includes("occlu")||(i.colorWrite=!1,i.depthTest=!0,i.depthWrite=!0,i.transparent=!1,i.polygonOffset=!0,i.polygonOffsetFactor=1,i.polygonOffsetUnits=.1,e.renderOrder=-1e3)}}),p(this,"_flipForwardMatrix",new he().makeRotationY(Math.PI)),p(this,"_verticesCache",new Map)}get trackedPlanes(){return this._allPlanes.values()}get trackedMeshes(){return this._allMeshes.values()}onBeforeXR(e,i){e==="immersive-vr"&&!this.runInVR||(i.optionalFeatures=i.optionalFeatures||[],this.usePlaneData&&!i.optionalFeatures.includes("plane-detection")&&i.optionalFeatures.push("plane-detection"),this.useMeshData&&!i.optionalFeatures.includes("mesh-detection")&&i.optionalFeatures.push("mesh-detection"))}onEnterXR(e){for(const i of this._allPlanes.keys())this.removeData(i,this._allPlanes);for(const i of this._allMeshes.keys())this.removeData(i,this._allMeshes)}onLeaveXR(e){for(const i of this._allPlanes.keys())this.removeData(i,this._allPlanes);for(const i of this._allMeshes.keys())this.removeData(i,this._allMeshes)}onUpdateXR(e){if(!this.runInVR&&e.xr.isVR)return;const i=e.xr.rig;if(!i){console.warn("No XR rig found, cannot parent tracked planes to it");return}const s=e.xr.frame;if(!this.context.renderer.xr.getReferenceSpace())return;const r=s.detectedPlanes,o=s.detectedMeshes,a=r!==void 0&&r.size>0,l=o!==void 0&&o.size>0;if(this.initiateRoomCaptureIfNoData&&(!a&&!l&&this.firstTimeNoPlanesDetected<-10&&(this.firstTimeNoPlanesDetected=Date.now()),(a||l)&&(this.firstTimeNoPlanesDetected=-1),this.firstTimeNoPlanesDetected>0&&Date.now()-this.firstTimeNoPlanesDetected>2500&&"initiateRoomCapture"in s.session&&(s.session.initiateRoomCapture(),this.firstTimeNoPlanesDetected=-1)),r!==void 0&&this.processFrameData(e.xr,i.gameObject,s,r,this._allPlanes),o!==void 0&&this.processFrameData(e.xr,i.gameObject,s,o,this._allMeshes),vf){const c=this.context.mainCameraComponent.gameObject.worldPosition;for(const h of this._allPlanes.values())!h.mesh||!h.mesh.visible||(this.bounds.makeEmpty(),h.mesh.traverse(d=>{d instanceof ue&&this.bounds.expandByObject(d)}),this.bounds.getCenter(this.center),this.labelOffset.copy(c).sub(this.center).normalize().multiplyScalar(.1),ft.DrawLabel(this.center.add(this.labelOffset),(h.xrData.semanticLabel||"plane").toUpperCase()+`
|
|
7954
|
-
`+h.xrData.lastChangedTime.toFixed(2),.02))}}removeData(e,i){const s=i.get(e);if(!s)return;i.delete(e),vf&&console.log("Plane no longer tracked, id="+s.id),s.mesh&&(s.mesh.removeFromParent(),s.mesh.traverse(o=>{const a=o.userData.normalsHelper;a?(a.dispose(),a.removeFromParent()):vf&&console.warn("No normals helper found for mesh",s.mesh)}),oa(s.mesh,!0,!0));const r=new CustomEvent("plane-tracking",{detail:{type:"plane-removed",context:s}});this.dispatchEvent(r)}processFrameData(e,i,s,r,o){const a=this.context.renderer.xr.getReferenceSpace();if(a){for(const l of o.keys())r.has(l)||this.removeData(l,o);for(const l of r){const c="planeSpace"in l?l.planeSpace:"meshSpace"in l?l.meshSpace:void 0;if(!c)continue;const h=s.getPose(c,a);let d;if(o.has(l)){const u=o.get(l);if(d=u.mesh,u.timestamp<l.lastChangedTime){if(u.timestamp=l.lastChangedTime,u.mesh){const f=this.createGeometry(l);if(u.mesh instanceof ue)u.mesh.geometry.dispose(),u.mesh.geometry=f,this.makeOccluder(u.mesh,u.mesh.material);else if(u.mesh instanceof Xn)for(const g of u.mesh.children)g instanceof ue&&(g.geometry.dispose(),g.geometry=f,this.makeOccluder(g,g.material));if(u.collider){const g=u.mesh;u.collider.sharedMesh=g,u.collider.convex=this.checkIfContextShouldBeConvex(g,u.xrData),u.collider.onDisable(),u.collider.onEnable()}vf&&(console.log("Plane updated, id="+u.id,u),u.mesh.traverse(g=>{if(!(g instanceof ue))return;const v=g.userData.normalsHelper;v&&v.update()}))}const m=new CustomEvent("plane-tracking",{detail:{type:"plane-updated",context:u}});this.dispatchEvent(m)}}else{if(!this.dataTemplate){const u=new ue;vf?u.material=new Yw:this.occluder?(u.material=new Ht,this.makeOccluder(u,u.material,!0)):u.material=new Ht({wireframe:!0,opacity:.5,transparent:!0,color:3355443}),this.dataTemplate=new ei("","",u)}if(!this.dataTemplate.asset)this.dataTemplate.loadAssetAsync();else{const u=ie.instantiate(this.dataTemplate.asset);if(u.name="xr-tracked-plane",d=u,mL(u,!1),u instanceof ue)Ki(u.geometry),u.geometry=this.createGeometry(l),this.makeOccluder(u,u.material,this.occluder);else if(u instanceof Xn)for(const g of u.children)g instanceof ue&&(Ki(g.geometry),g.geometry=this.createGeometry(l),this.makeOccluder(g,g.material,this.occluder));const m=u.getComponent(Wm);if(m){const g=u;m.sharedMesh=g,m.convex=this.checkIfContextShouldBeConvex(g,l),m.onDisable(),m.onEnable()}u.matrixAutoUpdate=!1,u.matrixWorldNeedsUpdate=!0,i.add(u);const f={id:this._dataId++,xrData:l,timestamp:l.lastChangedTime,mesh:u,collider:m};o.set(l,f),vf&&console.log("New plane detected, id="+f.id,f,{hasCollider:!!m,isGroup:u instanceof Xn});try{const g=new CustomEvent("plane-tracking",{detail:{type:"plane-added",context:f}});this.dispatchEvent(g)}catch(g){console.error(g)}}}d&&(h?(d.visible=!0,d.matrix.fromArray(h.transform.matrix),d.matrix.premultiply(this._flipForwardMatrix)):d.visible=!1,vf&&d.traverse(u=>{if(u instanceof ue)if(u.userData.normalsHelper)u.userData.normalsHelper.update();else{const m=new X_e(u,.05,255);m.layers.disableAll(),m.layers.set(2),this.context.scene.add(m),u.userData.normalsHelper=m}}))}}}checkIfContextShouldBeConvex(e,i){if(!e)return!0;if(e){const s=new Wt;s.expandByObject(e);const r=new M;s.getSize(r);let o=!0;return r.x>2&&r.y>2&&r.z>1.5&&(o=!1),o&&"semanticLabel"in i&&i.semanticLabel==="wall"&&(o=!0),o}return!0}createGeometry(e){return"polygon"in e?this.createPlaneGeometry(e.polygon):"vertices"in e&&"indices"in e?this.createMeshGeometry(e.vertices,e.indices):new pt}createMeshGeometry(e,i){const s=e.toString()+"_"+i.toString();if(this._verticesCache.has(s))return this._verticesCache.get(s);const r=new pt;r.setIndex(new $e(i,1)),r.setAttribute("position",new $e(e,3));const o=Array();for(let a=0;a<e.length;a+=3)o.push(e[a],e[a+2]);return r.setAttribute("uv",new $e(e,3)),r.computeVertexNormals(),this._verticesCache.set(s,r),r}createPlaneGeometry(e){const i=new pt,s=[],r=[];e.forEach(m=>{s.push(m.x,m.y,m.z),r.push(m.x,m.z)});const o=new M(s[0],s[1],s[2]),a=new M(s[3],s[4],s[5]),l=new M(s[6],s[7],s[8]),c=new M,h=new M;c.subVectors(a,o),h.subVectors(l,o),c.cross(h),c.normalize();const d=[];for(let m=0;m<s.length/3;m++)d.push(c.x,c.y,c.z);const u=[];for(let m=2;m<e.length;++m)u.push(0,m-1,m);return i.setAttribute("position",new $e(new Float32Array(s),3)),i.setAttribute("uv",new $e(new Float32Array(r),2)),i.setAttribute("normal",new $e(new Float32Array(d),3)),i.setIndex(u),i.computeBoundingBox(),i.computeBoundingSphere(),i}}wy([E(ei)],md.prototype,"dataTemplate",2),wy([E()],md.prototype,"occluder",2),wy([E()],md.prototype,"initiateRoomCaptureIfNoData",2),wy([E()],md.prototype,"usePlaneData",2),wy([E()],md.prototype,"useMeshData",2),wy([E()],md.prototype,"runInVR",2);var j_e=Object.defineProperty,Q_e=Object.getOwnPropertyDescriptor,_y=(n,e,i,s)=>{for(var r=s>1?void 0:s?Q_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&j_e(e,i,r),r};class fd extends Pe{constructor(){super(...arguments),p(this,"side","none"),p(this,"controller",!0),p(this,"hands",!1),p(this,"controlVisibility",!0),p(this,"useGripSpace",!1),p(this,"resetTransformAfterXRSession",!0),p(this,"_startPosition",new M),p(this,"_startRotation",new Se),p(this,"_startScale",new M)}get activeAndEnabled(){return!0}onEnterXR(e){this._startPosition.copy(this.gameObject.position),this._startRotation.copy(this.gameObject.quaternion),this._startScale.copy(this.gameObject.scale)}onUpdateXR(e){const i=e.xr.getController(this.side);if(i){if(i.hand&&!this.hands){this.controlVisibility&&(this.gameObject.visible=!1);return}else if(!this.controller){this.controlVisibility&&(this.gameObject.visible=!1);return}this.controlVisibility&&(this.gameObject.visible=!0),this.useGripSpace||i.targetRayMode==="transient-pointer"?(this.gameObject.worldPosition=i.gripWorldPosition,this.gameObject.worldQuaternion=i.gripWorldQuaternion,this.gameObject.worldScale=ht(i.xr.rigScale,i.xr.rigScale,i.xr.rigScale).multiply(this._startScale)):(this.gameObject.worldPosition=i.rayWorldPosition,this.gameObject.worldQuaternion=i.rayWorldQuaternion,this.gameObject.worldScale=ht(i.xr.rigScale,i.xr.rigScale,i.xr.rigScale).multiply(this._startScale))}}onLeaveXR(e){this.resetTransformAfterXRSession&&(this.gameObject.position.copy(this._startPosition),this.gameObject.quaternion.copy(this._startRotation),this.gameObject.scale.copy(this._startScale))}}_y([E()],fd.prototype,"side",2),_y([E()],fd.prototype,"controller",2),_y([E()],fd.prototype,"hands",2),_y([E()],fd.prototype,"controlVisibility",2),_y([E()],fd.prototype,"useGripSpace",2),_y([E()],fd.prototype,"resetTransformAfterXRSession",2);var Z_e=Object.defineProperty,Y_e=Object.getOwnPropertyDescriptor,K_e=(n,e,i,s)=>{for(var r=s>1?void 0:s?Y_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Z_e(e,i,r),r};const $Y=te("debugwebxr");class VE extends Pe{constructor(){super(...arguments),p(this,"priority",0),p(this,"_startScale")}get isActive(){return this.activeAndEnabled&&this.gameObject.visible}setAsActiveXRRig(){var e;(e=Et.active)==null||e.setRigActive(this)}awake(){if($Y){const e=new ge;e.position.y+=.5,this.gameObject.add(e);const i=e.addNewComponent(Hm);i&&(i.isGizmo=!1);const s=new Ro(.5);this.gameObject.add(s)}}isXRRig(){return!0}supportsXR(e){return!0}onEnterXR(e){this._startScale=this.gameObject.scale.clone(),e.xr.addRig(this),$Y&&console.log("WebXR: add Rig",this.name,this.priority)}onLeaveXR(e){e.xr.removeRig(this),this._startScale&&this.gameObject&&this.gameObject.scale.copy(this._startScale)}}K_e([E()],VE.prototype,"priority",2);class RG{}const J_e=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:vi,ActionCollection:eO,ActionModel:aa,AlignmentConstraint:xA,Animation:zr,AnimationCurve:Fm,AnimationExtension:SA,AnimationTrackHandler:uM,Animator:sr,AnimatorController:Ea,Antialiasing:FA,AudioExtension:vp,AudioListener:Gu,AudioSource:Cn,AudioTrackHandler:DA,Avatar:zu,AvatarBlink_Simple:Vm,AvatarEyeLook_Rotation:N0,AvatarLoader:PO,AvatarMarker:ar,AvatarModel:gM,Avatar_Brain_LookAt:WA,Avatar_MouthShapes:QA,Avatar_MustacheShake:RO,Avatar_POI:kc,AxesHelper:F0,BaseUIComponent:hl,BasicIKConstraint:BO,BehaviorExtension:vM,BehaviorModel:Gs,BloomEffect:Xm,BoxCollider:U0,BoxGizmo:Hm,BoxHelperComponent:qa,Button:td,CallInfo:Tc,Camera:Fi,CameraTargetReachedEvent:LA,Canvas:lr,CanvasGroup:Hu,CapsuleCollider:ed,ChangeMaterialOnClick:W0,ChangeTransformOnClick:Zm,CharacterController:Jm,CharacterControllerInput:nd,ChromaticAberration:ix,Collider:Do,ColorAdjustments:Zu,ColorBySpeedModule:$m,ColorOverLifetimeModule:hx,ContactShadows:jl,ControlTrackHandler:pM,CustomBranding:ip,Deletable:AD,DeleteBox:yx,DepthOfField:Ql,DeviceFlag:tE,DocumentExtension:xD,DragControls:No,DropListener:ud,DropListenerAddedEvent:iE,Duplicatable:of,EffectWrapper:bx,EmissionModule:Uc,EmphasizeOnClick:j0,EventList:ji,EventListEvent:iM,EventSystem:Ka,EventTrigger:rE,FieldWithDefault:sD,FixedJoint:TD,FlyControls:RD,Fog:oy,GltfExport:_x,GltfExportBox:OD,Gradient:Yu,Graphic:jm,GraphicRaycaster:rM,GridHelper:cy,GridLayoutGroup:jO,GroundProjectedEnv:Cc,GroupActionModel:jh,HideOnStart:YO,HingeJoint:Ax,HorizontalLayoutGroup:HO,Image:X0,InheritVelocityModule:Ju,InputField:af,InstanceHandle:nx,InstancingHandler:q0,Interactable:bD,Keyframe:mo,LODGroup:Cx,LODModel:lf,Light:Fo,LimitVelocityOverLifetimeModule:ls,LogStats:FD,LookAt:cf,LookAtConstraint:zm,MainModule:hr,MaskableGraphic:qA,MeshCollider:Wm,MeshRenderer:ox,MinMaxCurve:gt,MinMaxGradient:yo,NeedleMenu:Xc,NestedGltf:uE,Networking:dy,NoiseModule:Pi,ObjectRaycaster:ca,OffsetConstraint:hf,OpenURL:uy,OrbitControls:Ti,Outline:V0,Padding:Xu,ParticleBurst:cx,ParticleSubEmitter:TE,ParticleSystem:hs,ParticleSystemRenderer:tl,PhysicsExtension:KM,PixelationEffect:Ox,PlayAnimationOnClick:Km,PlayAudioOnClick:ju,PlayableDirector:Fu,PlayerColor:Ky,PointerEventData:Qy,PostProcessingHandler:RE,PreliminaryAction:Q0,PreliminaryTrigger:ex,RawImage:wM,Rect:UO,RectTransform:Vr,ReflectionProbe:Y0,RegisteredAnimationInfo:Cd,RemoteSkybox:Jc,Renderer:Dn,RendererLightmap:sx,Rigidbody:Ci,RotationBySpeedModule:ya,RotationOverLifetimeModule:$a,SceneSwitcher:Cs,ScreenCapture:lp,ScreenSpaceAmbientOcclusion:pd,ScreenSpaceAmbientOcclusionN8:Yl,SetActiveOnClick:Ym,ShadowCatcher:Ux,ShapeModule:Rn,SharpeningEffect:Gx,SignalAsset:kA,SignalReceiver:O0,SignalReceiverEvent:B0,SignalTrackHandler:GA,Size:zO,SizeBySpeedModule:vo,SizeOverLifetimeModule:Ku,SkinnedMeshRenderer:rD,SmoothFollow:cp,SpatialGrabRaycaster:P0,SpatialHtml:Vx,SpatialTrigger:Hx,SpatialTriggerReceiver:qc,SpectatorCamera:BE,SphereCollider:z0,Sprite:Vc,SpriteData:ld,SpriteRenderer:Go,SpriteSheet:qu,SubEmitterSystem:Bx,SyncedCamera:DE,SyncedRoom:Kl,SyncedTransform:Ec,TapGestureTrigger:KO,TeleportTarget:ZM,TestRunner:SG,TestSimulateUserData:CG,Text:Xr,TextBuilder:JM,TextExtension:mx,TextureSheetAnimationModule:dr,TiltShiftEffect:$c,ToneMappingEffect:Qu,TrailModule:xn,TransformData:Sn,TransformGizmo:ff,TriggerBuilder:Ns,TriggerModel:Eu,UIRaycastUtils:oM,UIRootComponent:RA,USDZExporter:Ln,USDZText:tp,USDZUIExtension:qM,UsageMarker:gx,VariantAction:$B,VelocityOverLifetimeModule:In,VerticalLayoutGroup:WO,VideoPlayer:Ms,Vignette:gf,VisibilityAction:tx,Voip:Uu,Volume:by,VolumeParameter:qe,VolumeProfile:NA,WebARCameraBackground:UE,WebARSessionRoot:cd,WebXR:Nn,WebXRImageTracking:xy,WebXRImageTrackingModel:eh,WebXRPlaneTracking:md,WebXRTrackedImage:Ay,XRControllerFollow:fd,XRControllerModel:Wc,XRControllerMovement:va,XRFlag:pa,XRRig:VE,XRState:go,__Ignore:RG},Symbol.toStringTag,{value:"Module"}));class q_e extends Pe{constructor(){super(...arguments),p(this,"toggleKey","KeyP")}update(){this.context.input.isKeyDown(this.toggleKey)&&this.context.domElement.classList.toggle("presentation-mode")}}Z.add("__Ignore",RG),Z.add("ActionBuilder",vi),Z.add("ActionCollection",eO),Z.add("ActionModel",aa),Z.add("AlignmentConstraint",xA),Z.add("Animation",zr),Z.add("AnimationCurve",Fm),Z.add("AnimationExtension",SA),Z.add("AnimationTrackHandler",uM),Z.add("Animator",sr),Z.add("AnimatorController",Ea),Z.add("Antialiasing",FA),Z.add("AudioExtension",vp),Z.add("AudioListener",Gu),Z.add("AudioSource",Cn),Z.add("AudioTrackHandler",DA),Z.add("Avatar",zu),Z.add("Avatar_Brain_LookAt",WA),Z.add("Avatar_MouthShapes",QA),Z.add("Avatar_MustacheShake",RO),Z.add("Avatar_POI",kc),Z.add("AvatarBlink_Simple",Vm),Z.add("AvatarEyeLook_Rotation",N0),Z.add("AvatarLoader",PO),Z.add("AvatarMarker",ar),Z.add("AvatarModel",gM),Z.add("AxesHelper",F0),Z.add("BaseUIComponent",hl),Z.add("BasicIKConstraint",BO),Z.add("BehaviorExtension",vM),Z.add("BehaviorModel",Gs),Z.add("BloomEffect",Xm),Z.add("BoxCollider",U0),Z.add("BoxGizmo",Hm),Z.add("BoxHelperComponent",qa),Z.add("Button",td),Z.add("CallInfo",Tc),Z.add("Camera",Fi),Z.add("CameraTargetReachedEvent",LA),Z.add("Canvas",lr),Z.add("CanvasGroup",Hu),Z.add("CapsuleCollider",ed),Z.add("ChangeMaterialOnClick",W0),Z.add("ChangeTransformOnClick",Zm),Z.add("CharacterController",Jm),Z.add("CharacterControllerInput",nd),Z.add("ChromaticAberration",ix),Z.add("Collider",Do),Z.add("ColorAdjustments",Zu),Z.add("ColorBySpeedModule",$m),Z.add("ColorOverLifetimeModule",hx),Z.add("ContactShadows",jl),Z.add("ControlTrackHandler",pM),Z.add("CustomBranding",ip),Z.add("Deletable",AD),Z.add("DeleteBox",yx),Z.add("DepthOfField",Ql),Z.add("DeviceFlag",tE),Z.add("DocumentExtension",xD),Z.add("DragControls",No),Z.add("DropListener",ud),Z.add("DropListenerAddedEvent",iE),Z.add("Duplicatable",of),Z.add("EffectWrapper",bx),Z.add("EmissionModule",Uc),Z.add("EmphasizeOnClick",j0),Z.add("EventList",ji),Z.add("EventListEvent",iM),Z.add("EventSystem",Ka),Z.add("EventTrigger",rE),Z.add("FieldWithDefault",sD),Z.add("FixedJoint",TD),Z.add("FlyControls",RD),Z.add("Fog",oy),Z.add("GltfExport",_x),Z.add("GltfExportBox",OD),Z.add("Gradient",Yu),Z.add("Graphic",jm),Z.add("GraphicRaycaster",rM),Z.add("GridHelper",cy),Z.add("GridLayoutGroup",jO),Z.add("GroundProjectedEnv",Cc),Z.add("GroupActionModel",jh),Z.add("HideOnStart",YO),Z.add("HingeJoint",Ax),Z.add("HorizontalLayoutGroup",HO),Z.add("Image",X0),Z.add("InheritVelocityModule",Ju),Z.add("InputField",af),Z.add("InstanceHandle",nx),Z.add("InstancingHandler",q0),Z.add("Interactable",bD),Z.add("Keyframe",mo),Z.add("Light",Fo),Z.add("LimitVelocityOverLifetimeModule",ls),Z.add("LODGroup",Cx),Z.add("LODModel",lf),Z.add("LogStats",FD),Z.add("LookAt",cf),Z.add("LookAtConstraint",zm),Z.add("MainModule",hr),Z.add("MaskableGraphic",qA),Z.add("MeshCollider",Wm),Z.add("MeshRenderer",ox),Z.add("MinMaxCurve",gt),Z.add("MinMaxGradient",yo),Z.add("NeedleMenu",Xc),Z.add("NestedGltf",uE),Z.add("Networking",dy),Z.add("NoiseModule",Pi),Z.add("ObjectRaycaster",ca),Z.add("OffsetConstraint",hf),Z.add("OpenURL",uy),Z.add("OrbitControls",Ti),Z.add("Outline",V0),Z.add("Padding",Xu),Z.add("ParticleBurst",cx),Z.add("ParticleSubEmitter",TE),Z.add("ParticleSystem",hs),Z.add("ParticleSystemRenderer",tl),Z.add("PhysicsExtension",KM),Z.add("PixelationEffect",Ox),Z.add("PlayableDirector",Fu),Z.add("PlayAnimationOnClick",Km),Z.add("PlayAudioOnClick",ju),Z.add("PlayerColor",Ky),Z.add("PlayerState",ua),Z.add("PlayerSync",D0),Z.add("PointerEventData",Qy),Z.add("PostProcessingHandler",RE),Z.add("PreliminaryAction",Q0),Z.add("PreliminaryTrigger",ex),Z.add("PresentationMode",q_e),Z.add("RawImage",wM),Z.add("Rect",UO),Z.add("RectTransform",Vr),Z.add("ReflectionProbe",Y0),Z.add("RegisteredAnimationInfo",Cd),Z.add("RemoteSkybox",Jc),Z.add("Renderer",Dn),Z.add("RendererLightmap",sx),Z.add("Rigidbody",Ci),Z.add("RotationBySpeedModule",ya),Z.add("RotationOverLifetimeModule",$a),Z.add("SceneSwitcher",Cs),Z.add("ScreenCapture",lp),Z.add("ScreenSpaceAmbientOcclusion",pd),Z.add("ScreenSpaceAmbientOcclusionN8",Yl),Z.add("SetActiveOnClick",Ym),Z.add("ShadowCatcher",Ux),Z.add("ShapeModule",Rn),Z.add("SharpeningEffect",Gx),Z.add("SignalAsset",kA),Z.add("SignalReceiver",O0),Z.add("SignalReceiverEvent",B0),Z.add("SignalTrackHandler",GA),Z.add("Size",zO),Z.add("SizeBySpeedModule",vo),Z.add("SizeOverLifetimeModule",Ku),Z.add("SkinnedMeshRenderer",rD),Z.add("SmoothFollow",cp),Z.add("SpatialGrabRaycaster",P0),Z.add("SpatialHtml",Vx),Z.add("SpatialTrigger",Hx),Z.add("SpatialTriggerReceiver",qc),Z.add("SpectatorCamera",BE),Z.add("SphereCollider",z0),Z.add("Sprite",Vc),Z.add("SpriteData",ld),Z.add("SpriteRenderer",Go),Z.add("SpriteSheet",qu),Z.add("SubEmitterSystem",Bx),Z.add("SyncedCamera",DE),Z.add("SyncedRoom",Kl),Z.add("SyncedTransform",Ec),Z.add("TapGestureTrigger",KO),Z.add("TeleportTarget",ZM),Z.add("TestRunner",SG),Z.add("TestSimulateUserData",CG),Z.add("Text",Xr),Z.add("TextBuilder",JM),Z.add("TextExtension",mx),Z.add("TextureSheetAnimationModule",dr),Z.add("TiltShiftEffect",$c),Z.add("ToneMappingEffect",Qu),Z.add("TrailModule",xn),Z.add("TransformData",Sn),Z.add("TransformGizmo",ff),Z.add("TriggerBuilder",Ns),Z.add("TriggerModel",Eu),Z.add("UIRaycastUtils",oM),Z.add("UIRootComponent",RA),Z.add("UsageMarker",gx),Z.add("USDZExporter",Ln),Z.add("USDZText",tp),Z.add("USDZUIExtension",qM),Z.add("VariantAction",$B),Z.add("VelocityOverLifetimeModule",In),Z.add("VerticalLayoutGroup",WO),Z.add("VideoPlayer",Ms),Z.add("Vignette",gf),Z.add("VisibilityAction",tx),Z.add("Voip",Uu),Z.add("Volume",by),Z.add("VolumeParameter",qe),Z.add("VolumeProfile",NA),Z.add("WebARCameraBackground",UE),Z.add("WebARSessionRoot",cd),Z.add("WebXR",Nn),Z.add("WebXRImageTracking",xy),Z.add("WebXRImageTrackingModel",eh),Z.add("WebXRPlaneTracking",md),Z.add("WebXRTrackedImage",Ay),Z.add("XRControllerFollow",fd),Z.add("XRControllerModel",Wc),Z.add("XRControllerMovement",va),Z.add("XRFlag",pa),Z.add("XRRig",VE),Z.add("XRState",go);const Yx=Ds,$_e=te("debugtypestore");$_e&&console.log(Z);function eSe(n,e){const i=W4(n,e);return i!==void 0?i:null}const tSe=new zme,IG=Symbol("deserialize-queue");async function iSe(n,e,i,s=null,r){if(!i){console.debug("Can not create component instances: gltf is null");return}let o=s;typeof o=="number"&&(o=new xr(s));const a=e.indexOf("?");e=a===-1?e:e.substring(0,a);const l=new $k(i.scene);l.gltfId=e,l.context=n,l.gltf=i,l.nodeToObject=r?.nodeToObjectMap,l.implementationInformation=tSe;let c=n[IG];if(c||(c=n[IG]=[]),i.scenes)for(const h of i.scenes)await kG(l,h,c);if(i.children)for(const h of i.children)await kG(l,h,c);n.new_scripts_pre_setup_callbacks.push(()=>{const h=n[IG];if(h){for(const d of h)nSe(d,l);h.length=0}if(o){const d={},u=[];PG(i,o,d,u);for(const m of i.scenes)PG(m,o,d,u);for(const m of u)m.resolveGuids(d)}})}const LG=Symbol("original-component-name"),Sy=new Map;function PG(n,e,i,s){if(e===null||!n)return;const r=n.guid,o=n.guid;o!=null&&o.length&&(Sy.has(o)||(Yx&&console.log('Creating InstanceIdProvider with key "'+o+'" for object '+n.name),Sy.set(o,new xr(o))));const a=o&&Sy.get(o)||e;if(n.guid=a.generateUUID(),r&&r!=="invalid"&&(i[r]=n.guid),n&&n.userData&&n.userData.components)for(const l of n.userData.components){if(l===null)continue;const c=l.guid;c?Sy.has(c)||(Yx&&console.log('Creating InstanceIdProvider with key "'+c+'" for component '+l[LG]),Sy.set(c,new xr(c))):Yx&&console.warn("Can not create IdProvider: component "+l[LG]+" has no guid",l.guid);const h=Sy.get(c)||e,d=l.guid;l.guid=h.generateUUID(),d&&d!=="invalid"&&(i[d]=l.guid),l.resolveGuids&&s.push(l)}if(n.children)for(const l of n.children)PG(l,e,i,s)}const Kx=[];async function kG(n,e,i,s){if(!e)return;const r=e.userData;if(r){const o=r.builtin_components;if(o&&o.length>0)for(const a of o)try{if(a===null)continue;const l=Z.get(a.name);if(l!=null){const c=new l;c.sourceId=n.gltfId,d0(c,a,n.implementationInformation),c.context=n.context,"guid"in a&&(c[ib]=a.guid),c[LG]=a.name,Rm(e,c,!1),i.push({instance:c,compData:a,obj:e}),c.isCamera&&n.context&&n.context.mainCamera===null&&c.tag==="MainCamera"&&n.context.setCurrentCamera(c)}else Yx&&console.debug("unknown component: "+a.name),Kx.includes(a.name)||Kx.push(a.name)}catch(l){console.error(a.name+" - "+l.message,l)}if(Kx.length>0){const a=Kx.join(", ");console.warn("unknown components: "+a),Kx.length=0,io()&&gn(`<strong>Unknown components in scene</strong>:
|
|
7954
|
+
`+h.xrData.lastChangedTime.toFixed(2),.02))}}removeData(e,i){const s=i.get(e);if(!s)return;i.delete(e),vf&&console.log("Plane no longer tracked, id="+s.id),s.mesh&&(s.mesh.removeFromParent(),s.mesh.traverse(o=>{const a=o.userData.normalsHelper;a?(a.dispose(),a.removeFromParent()):vf&&console.warn("No normals helper found for mesh",s.mesh)}),oa(s.mesh,!0,!0));const r=new CustomEvent("plane-tracking",{detail:{type:"plane-removed",context:s}});this.dispatchEvent(r)}processFrameData(e,i,s,r,o){const a=this.context.renderer.xr.getReferenceSpace();if(a){for(const l of o.keys())r.has(l)||this.removeData(l,o);for(const l of r){const c="planeSpace"in l?l.planeSpace:"meshSpace"in l?l.meshSpace:void 0;if(!c)continue;const h=s.getPose(c,a);let d;if(o.has(l)){const u=o.get(l);if(d=u.mesh,u.timestamp<l.lastChangedTime){if(u.timestamp=l.lastChangedTime,u.mesh){const f=this.createGeometry(l);if(u.mesh instanceof ue)u.mesh.geometry.dispose(),u.mesh.geometry=f,this.makeOccluder(u.mesh,u.mesh.material);else if(u.mesh instanceof Xn)for(const g of u.mesh.children)g instanceof ue&&(g.geometry.dispose(),g.geometry=f,this.makeOccluder(g,g.material));if(u.collider){const g=u.mesh;u.collider.sharedMesh=g,u.collider.convex=this.checkIfContextShouldBeConvex(g,u.xrData),u.collider.onDisable(),u.collider.onEnable()}vf&&(console.log("Plane updated, id="+u.id,u),u.mesh.traverse(g=>{if(!(g instanceof ue))return;const v=g.userData.normalsHelper;v&&v.update()}))}const m=new CustomEvent("plane-tracking",{detail:{type:"plane-updated",context:u}});this.dispatchEvent(m)}}else{if(!this.dataTemplate){const u=new ue;vf?u.material=new Yw:this.occluder?(u.material=new Ht,this.makeOccluder(u,u.material,!0)):u.material=new Ht({wireframe:!0,opacity:.5,transparent:!0,color:3355443}),this.dataTemplate=new ei("","",u)}if(!this.dataTemplate.asset)this.dataTemplate.loadAssetAsync();else{const u=ie.instantiate(this.dataTemplate.asset);if(u.name="xr-tracked-plane",d=u,mL(u,!1),u instanceof ue)Ki(u.geometry),u.geometry=this.createGeometry(l),this.makeOccluder(u,u.material,this.occluder);else if(u instanceof Xn)for(const g of u.children)g instanceof ue&&(Ki(g.geometry),g.geometry=this.createGeometry(l),this.makeOccluder(g,g.material,this.occluder));const m=u.getComponent(Wm);if(m){const g=u;m.sharedMesh=g,m.convex=this.checkIfContextShouldBeConvex(g,l),m.onDisable(),m.onEnable()}u.matrixAutoUpdate=!1,u.matrixWorldNeedsUpdate=!0,i.add(u);const f={id:this._dataId++,xrData:l,timestamp:l.lastChangedTime,mesh:u,collider:m};o.set(l,f),vf&&console.log("New plane detected, id="+f.id,f,{hasCollider:!!m,isGroup:u instanceof Xn});try{const g=new CustomEvent("plane-tracking",{detail:{type:"plane-added",context:f}});this.dispatchEvent(g)}catch(g){console.error(g)}}}d&&(h?(d.visible=!0,d.matrix.fromArray(h.transform.matrix),d.matrix.premultiply(this._flipForwardMatrix)):d.visible=!1,vf&&d.traverse(u=>{if(u instanceof ue)if(u.userData.normalsHelper)u.userData.normalsHelper.update();else{const m=new X_e(u,.05,255);m.layers.disableAll(),m.layers.set(2),this.context.scene.add(m),u.userData.normalsHelper=m}}))}}}checkIfContextShouldBeConvex(e,i){if(!e)return!0;if(e){const s=new Wt;s.expandByObject(e);const r=new M;s.getSize(r);let o=!0;return r.x>2&&r.y>2&&r.z>1.5&&(o=!1),o&&"semanticLabel"in i&&i.semanticLabel==="wall"&&(o=!0),o}return!0}createGeometry(e){return"polygon"in e?this.createPlaneGeometry(e.polygon):"vertices"in e&&"indices"in e?this.createMeshGeometry(e.vertices,e.indices):new pt}createMeshGeometry(e,i){const s=e.toString()+"_"+i.toString();if(this._verticesCache.has(s))return this._verticesCache.get(s);const r=new pt;r.setIndex(new $e(i,1)),r.setAttribute("position",new $e(e,3));const o=Array();for(let a=0;a<e.length;a+=3)o.push(e[a],e[a+2]);return r.setAttribute("uv",new $e(e,3)),r.computeVertexNormals(),this._verticesCache.set(s,r),r}createPlaneGeometry(e){const i=new pt,s=[],r=[];e.forEach(m=>{s.push(m.x,m.y,m.z),r.push(m.x,m.z)});const o=new M(s[0],s[1],s[2]),a=new M(s[3],s[4],s[5]),l=new M(s[6],s[7],s[8]),c=new M,h=new M;c.subVectors(a,o),h.subVectors(l,o),c.cross(h),c.normalize();const d=[];for(let m=0;m<s.length/3;m++)d.push(c.x,c.y,c.z);const u=[];for(let m=2;m<e.length;++m)u.push(0,m-1,m);return i.setAttribute("position",new $e(new Float32Array(s),3)),i.setAttribute("uv",new $e(new Float32Array(r),2)),i.setAttribute("normal",new $e(new Float32Array(d),3)),i.setIndex(u),i.computeBoundingBox(),i.computeBoundingSphere(),i}}wy([E(ei)],md.prototype,"dataTemplate",2),wy([E()],md.prototype,"occluder",2),wy([E()],md.prototype,"initiateRoomCaptureIfNoData",2),wy([E()],md.prototype,"usePlaneData",2),wy([E()],md.prototype,"useMeshData",2),wy([E()],md.prototype,"runInVR",2);var j_e=Object.defineProperty,Q_e=Object.getOwnPropertyDescriptor,_y=(n,e,i,s)=>{for(var r=s>1?void 0:s?Q_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&j_e(e,i,r),r};class fd extends Pe{constructor(){super(...arguments),p(this,"side","none"),p(this,"controller",!0),p(this,"hands",!1),p(this,"controlVisibility",!0),p(this,"useGripSpace",!1),p(this,"resetTransformAfterXRSession",!0),p(this,"_startPosition",new M),p(this,"_startRotation",new Se),p(this,"_startScale",new M)}get activeAndEnabled(){return!0}onEnterXR(e){this._startPosition.copy(this.gameObject.position),this._startRotation.copy(this.gameObject.quaternion),this._startScale.copy(this.gameObject.scale)}onUpdateXR(e){const i=e.xr.getController(this.side);if(i){if(i.hand&&!this.hands){this.controlVisibility&&(this.gameObject.visible=!1);return}else if(!this.controller){this.controlVisibility&&(this.gameObject.visible=!1);return}this.controlVisibility&&(this.gameObject.visible=!0),this.useGripSpace||i.targetRayMode==="transient-pointer"?(this.gameObject.worldPosition=i.gripWorldPosition,this.gameObject.worldQuaternion=i.gripWorldQuaternion,this.gameObject.worldScale=ht(i.xr.rigScale,i.xr.rigScale,i.xr.rigScale).multiply(this._startScale)):(this.gameObject.worldPosition=i.rayWorldPosition,this.gameObject.worldQuaternion=i.rayWorldQuaternion,this.gameObject.worldScale=ht(i.xr.rigScale,i.xr.rigScale,i.xr.rigScale).multiply(this._startScale))}}onLeaveXR(e){this.resetTransformAfterXRSession&&(this.gameObject.position.copy(this._startPosition),this.gameObject.quaternion.copy(this._startRotation),this.gameObject.scale.copy(this._startScale))}}_y([E()],fd.prototype,"side",2),_y([E()],fd.prototype,"controller",2),_y([E()],fd.prototype,"hands",2),_y([E()],fd.prototype,"controlVisibility",2),_y([E()],fd.prototype,"useGripSpace",2),_y([E()],fd.prototype,"resetTransformAfterXRSession",2);var Z_e=Object.defineProperty,Y_e=Object.getOwnPropertyDescriptor,K_e=(n,e,i,s)=>{for(var r=s>1?void 0:s?Y_e(e,i):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(r=(s?a(e,i,r):a(r))||r);return s&&r&&Z_e(e,i,r),r};const $Y=te("debugwebxr");class VE extends Pe{constructor(){super(...arguments),p(this,"priority",0),p(this,"_startScale")}get isActive(){return this.activeAndEnabled&&this.gameObject.visible}setAsActiveXRRig(){var e;(e=Et.active)==null||e.setRigActive(this)}awake(){if($Y){const e=new ge;e.position.y+=.5,this.gameObject.add(e);const i=e.addNewComponent(Hm);i&&(i.isGizmo=!1);const s=new Ro(.5);this.gameObject.add(s)}}isXRRig(){return!0}supportsXR(e){return!0}onEnterXR(e){this._startScale=this.gameObject.scale.clone(),e.xr.addRig(this),$Y&&console.log("WebXR: add Rig",this.name,this.priority)}onLeaveXR(e){e.xr.removeRig(this),this._startScale&&this.gameObject&&this.gameObject.scale.copy(this._startScale)}}K_e([E()],VE.prototype,"priority",2);class RG{}const J_e=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:vi,ActionCollection:eO,ActionModel:aa,AlignmentConstraint:xA,Animation:zr,AnimationCurve:Fm,AnimationExtension:SA,AnimationTrackHandler:uM,Animator:sr,AnimatorController:Ea,Antialiasing:FA,AudioExtension:vp,AudioListener:Gu,AudioSource:Cn,AudioTrackHandler:DA,Avatar:zu,AvatarBlink_Simple:Vm,AvatarEyeLook_Rotation:N0,AvatarLoader:PO,AvatarMarker:ar,AvatarModel:gM,Avatar_Brain_LookAt:WA,Avatar_MouthShapes:QA,Avatar_MustacheShake:RO,Avatar_POI:kc,AxesHelper:F0,BaseUIComponent:hl,BasicIKConstraint:BO,BehaviorExtension:vM,BehaviorModel:Gs,BloomEffect:Xm,BoxCollider:U0,BoxGizmo:Hm,BoxHelperComponent:qa,Button:td,CallInfo:Tc,Camera:Fi,CameraTargetReachedEvent:LA,Canvas:lr,CanvasGroup:Hu,CapsuleCollider:ed,ChangeMaterialOnClick:W0,ChangeTransformOnClick:Zm,CharacterController:Jm,CharacterControllerInput:nd,ChromaticAberration:ix,Collider:Do,ColorAdjustments:Zu,ColorBySpeedModule:$m,ColorOverLifetimeModule:hx,ContactShadows:jl,ControlTrackHandler:pM,CustomBranding:ip,Deletable:AD,DeleteBox:yx,DepthOfField:Ql,DeviceFlag:tE,DocumentExtension:xD,DragControls:No,DropListener:ud,DropListenerAddedEvent:iE,Duplicatable:of,EffectWrapper:bx,EmissionModule:Uc,EmphasizeOnClick:j0,EventList:ji,EventListEvent:iM,EventSystem:Ka,EventTrigger:rE,FieldWithDefault:sD,FixedJoint:TD,FlyControls:RD,Fog:oy,GltfExport:_x,GltfExportBox:OD,Gradient:Yu,Graphic:jm,GraphicRaycaster:rM,GridHelper:cy,GridLayoutGroup:jO,GroundProjectedEnv:Cc,GroupActionModel:jh,HideOnStart:YO,HingeJoint:Ax,HorizontalLayoutGroup:HO,Image:X0,InheritVelocityModule:Ju,InputField:af,InstanceHandle:nx,InstancingHandler:q0,Interactable:bD,Keyframe:mo,LODGroup:Cx,LODModel:lf,Light:Fo,LimitVelocityOverLifetimeModule:ls,LogStats:FD,LookAt:cf,LookAtConstraint:zm,MainModule:hr,MaskableGraphic:qA,MeshCollider:Wm,MeshRenderer:ox,MinMaxCurve:gt,MinMaxGradient:yo,NeedleMenu:Xc,NestedGltf:uE,Networking:dy,NoiseModule:Pi,ObjectRaycaster:ca,OffsetConstraint:hf,OpenURL:uy,OrbitControls:Ti,Outline:V0,Padding:Xu,ParticleBurst:cx,ParticleSubEmitter:TE,ParticleSystem:hs,ParticleSystemRenderer:tl,PhysicsExtension:KM,PixelationEffect:Ox,PlayAnimationOnClick:Km,PlayAudioOnClick:ju,PlayableDirector:Fu,PlayerColor:Ky,PointerEventData:Qy,PostProcessingHandler:RE,PreliminaryAction:Q0,PreliminaryTrigger:ex,RawImage:wM,Rect:UO,RectTransform:Vr,ReflectionProbe:Y0,RegisteredAnimationInfo:Cd,RemoteSkybox:Jc,Renderer:Dn,RendererLightmap:sx,Rigidbody:Ci,RotationBySpeedModule:ya,RotationOverLifetimeModule:$a,SceneSwitcher:Cs,ScreenCapture:lp,ScreenSpaceAmbientOcclusion:pd,ScreenSpaceAmbientOcclusionN8:Yl,SetActiveOnClick:Ym,ShadowCatcher:Ux,ShapeModule:Rn,SharpeningEffect:Gx,SignalAsset:kA,SignalReceiver:O0,SignalReceiverEvent:B0,SignalTrackHandler:GA,Size:zO,SizeBySpeedModule:vo,SizeOverLifetimeModule:Ku,SkinnedMeshRenderer:rD,SmoothFollow:cp,SpatialGrabRaycaster:P0,SpatialHtml:Vx,SpatialTrigger:Hx,SpatialTriggerReceiver:qc,SpectatorCamera:BE,SphereCollider:z0,Sprite:Vc,SpriteData:ld,SpriteRenderer:Go,SpriteSheet:qu,SubEmitterSystem:Bx,SyncedCamera:DE,SyncedRoom:Kl,SyncedTransform:Ec,TapGestureTrigger:KO,TeleportTarget:ZM,TestRunner:SG,TestSimulateUserData:CG,Text:Xr,TextBuilder:JM,TextExtension:mx,TextureSheetAnimationModule:dr,TiltShiftEffect:$c,ToneMappingEffect:Qu,TrailModule:xn,TransformData:Sn,TransformGizmo:ff,TriggerBuilder:Ns,TriggerModel:Eu,UIRaycastUtils:oM,UIRootComponent:RA,USDZExporter:Ln,USDZText:tp,USDZUIExtension:qM,UsageMarker:gx,VariantAction:$B,VelocityOverLifetimeModule:In,VerticalLayoutGroup:WO,VideoPlayer:Ms,Vignette:gf,VisibilityAction:tx,Voip:Uu,Volume:by,VolumeParameter:qe,VolumeProfile:NA,WebARCameraBackground:UE,WebARSessionRoot:cd,WebXR:Nn,WebXRImageTracking:xy,WebXRImageTrackingModel:eh,WebXRPlaneTracking:md,WebXRTrackedImage:Ay,XRControllerFollow:fd,XRControllerModel:Wc,XRControllerMovement:va,XRFlag:pa,XRRig:VE,XRState:go,__Ignore:RG},Symbol.toStringTag,{value:"Module"}));class q_e extends Pe{constructor(){super(...arguments),p(this,"toggleKey","KeyP")}update(){this.context.input.isKeyDown(this.toggleKey)&&this.context.domElement.classList.toggle("presentation-mode")}}Z.add("__Ignore",RG),Z.add("ActionBuilder",vi),Z.add("ActionCollection",eO),Z.add("ActionModel",aa),Z.add("AlignmentConstraint",xA),Z.add("Animation",zr),Z.add("AnimationCurve",Fm),Z.add("AnimationExtension",SA),Z.add("AnimationTrackHandler",uM),Z.add("Animator",sr),Z.add("AnimatorController",Ea),Z.add("Antialiasing",FA),Z.add("AudioExtension",vp),Z.add("AudioListener",Gu),Z.add("AudioSource",Cn),Z.add("AudioTrackHandler",DA),Z.add("Avatar",zu),Z.add("Avatar_Brain_LookAt",WA),Z.add("Avatar_MouthShapes",QA),Z.add("Avatar_MustacheShake",RO),Z.add("Avatar_POI",kc),Z.add("AvatarBlink_Simple",Vm),Z.add("AvatarEyeLook_Rotation",N0),Z.add("AvatarLoader",PO),Z.add("AvatarMarker",ar),Z.add("AvatarModel",gM),Z.add("AxesHelper",F0),Z.add("BaseUIComponent",hl),Z.add("BasicIKConstraint",BO),Z.add("BehaviorExtension",vM),Z.add("BehaviorModel",Gs),Z.add("BloomEffect",Xm),Z.add("BoxCollider",U0),Z.add("BoxGizmo",Hm),Z.add("BoxHelperComponent",qa),Z.add("Button",td),Z.add("CallInfo",Tc),Z.add("Camera",Fi),Z.add("CameraTargetReachedEvent",LA),Z.add("Canvas",lr),Z.add("CanvasGroup",Hu),Z.add("CapsuleCollider",ed),Z.add("ChangeMaterialOnClick",W0),Z.add("ChangeTransformOnClick",Zm),Z.add("CharacterController",Jm),Z.add("CharacterControllerInput",nd),Z.add("ChromaticAberration",ix),Z.add("Collider",Do),Z.add("ColorAdjustments",Zu),Z.add("ColorBySpeedModule",$m),Z.add("ColorOverLifetimeModule",hx),Z.add("ContactShadows",jl),Z.add("ControlTrackHandler",pM),Z.add("CustomBranding",ip),Z.add("Deletable",AD),Z.add("DeleteBox",yx),Z.add("DepthOfField",Ql),Z.add("DeviceFlag",tE),Z.add("DocumentExtension",xD),Z.add("DragControls",No),Z.add("DropListener",ud),Z.add("DropListenerAddedEvent",iE),Z.add("Duplicatable",of),Z.add("EffectWrapper",bx),Z.add("EmissionModule",Uc),Z.add("EmphasizeOnClick",j0),Z.add("EventList",ji),Z.add("EventListEvent",iM),Z.add("EventSystem",Ka),Z.add("EventTrigger",rE),Z.add("FieldWithDefault",sD),Z.add("FixedJoint",TD),Z.add("FlyControls",RD),Z.add("Fog",oy),Z.add("GltfExport",_x),Z.add("GltfExportBox",OD),Z.add("Gradient",Yu),Z.add("Graphic",jm),Z.add("GraphicRaycaster",rM),Z.add("GridHelper",cy),Z.add("GridLayoutGroup",jO),Z.add("GroundProjectedEnv",Cc),Z.add("GroupActionModel",jh),Z.add("HideOnStart",YO),Z.add("HingeJoint",Ax),Z.add("HorizontalLayoutGroup",HO),Z.add("Image",X0),Z.add("InheritVelocityModule",Ju),Z.add("InputField",af),Z.add("InstanceHandle",nx),Z.add("InstancingHandler",q0),Z.add("Interactable",bD),Z.add("Keyframe",mo),Z.add("Light",Fo),Z.add("LimitVelocityOverLifetimeModule",ls),Z.add("LODGroup",Cx),Z.add("LODModel",lf),Z.add("LogStats",FD),Z.add("LookAt",cf),Z.add("LookAtConstraint",zm),Z.add("MainModule",hr),Z.add("MaskableGraphic",qA),Z.add("MeshCollider",Wm),Z.add("MeshRenderer",ox),Z.add("MinMaxCurve",gt),Z.add("MinMaxGradient",yo),Z.add("NeedleMenu",Xc),Z.add("NestedGltf",uE),Z.add("Networking",dy),Z.add("NoiseModule",Pi),Z.add("ObjectRaycaster",ca),Z.add("OffsetConstraint",hf),Z.add("OpenURL",uy),Z.add("OrbitControls",Ti),Z.add("Outline",V0),Z.add("Padding",Xu),Z.add("ParticleBurst",cx),Z.add("ParticleSubEmitter",TE),Z.add("ParticleSystem",hs),Z.add("ParticleSystemRenderer",tl),Z.add("PhysicsExtension",KM),Z.add("PixelationEffect",Ox),Z.add("PlayableDirector",Fu),Z.add("PlayAnimationOnClick",Km),Z.add("PlayAudioOnClick",ju),Z.add("PlayerColor",Ky),Z.add("PlayerState",ua),Z.add("PlayerSync",D0),Z.add("PointerEventData",Qy),Z.add("PostProcessingHandler",RE),Z.add("PreliminaryAction",Q0),Z.add("PreliminaryTrigger",ex),Z.add("PresentationMode",q_e),Z.add("RawImage",wM),Z.add("Rect",UO),Z.add("RectTransform",Vr),Z.add("ReflectionProbe",Y0),Z.add("RegisteredAnimationInfo",Cd),Z.add("RemoteSkybox",Jc),Z.add("Renderer",Dn),Z.add("RendererLightmap",sx),Z.add("Rigidbody",Ci),Z.add("RotationBySpeedModule",ya),Z.add("RotationOverLifetimeModule",$a),Z.add("SceneSwitcher",Cs),Z.add("ScreenCapture",lp),Z.add("ScreenSpaceAmbientOcclusion",pd),Z.add("ScreenSpaceAmbientOcclusionN8",Yl),Z.add("SetActiveOnClick",Ym),Z.add("ShadowCatcher",Ux),Z.add("ShapeModule",Rn),Z.add("SharpeningEffect",Gx),Z.add("SignalAsset",kA),Z.add("SignalReceiver",O0),Z.add("SignalReceiverEvent",B0),Z.add("SignalTrackHandler",GA),Z.add("Size",zO),Z.add("SizeBySpeedModule",vo),Z.add("SizeOverLifetimeModule",Ku),Z.add("SkinnedMeshRenderer",rD),Z.add("SmoothFollow",cp),Z.add("SpatialGrabRaycaster",P0),Z.add("SpatialHtml",Vx),Z.add("SpatialTrigger",Hx),Z.add("SpatialTriggerReceiver",qc),Z.add("SpectatorCamera",BE),Z.add("SphereCollider",z0),Z.add("Sprite",Vc),Z.add("SpriteData",ld),Z.add("SpriteRenderer",Go),Z.add("SpriteSheet",qu),Z.add("SubEmitterSystem",Bx),Z.add("SyncedCamera",DE),Z.add("SyncedRoom",Kl),Z.add("SyncedTransform",Ec),Z.add("TapGestureTrigger",KO),Z.add("TeleportTarget",ZM),Z.add("TestRunner",SG),Z.add("TestSimulateUserData",CG),Z.add("Text",Xr),Z.add("TextBuilder",JM),Z.add("TextExtension",mx),Z.add("TextureSheetAnimationModule",dr),Z.add("TiltShiftEffect",$c),Z.add("ToneMappingEffect",Qu),Z.add("TrailModule",xn),Z.add("TransformData",Sn),Z.add("TransformGizmo",ff),Z.add("TriggerBuilder",Ns),Z.add("TriggerModel",Eu),Z.add("UIRaycastUtils",oM),Z.add("UIRootComponent",RA),Z.add("UsageMarker",gx),Z.add("USDZExporter",Ln),Z.add("USDZText",tp),Z.add("USDZUIExtension",qM),Z.add("VariantAction",$B),Z.add("VelocityOverLifetimeModule",In),Z.add("VerticalLayoutGroup",WO),Z.add("VideoPlayer",Ms),Z.add("Vignette",gf),Z.add("VisibilityAction",tx),Z.add("Voip",Uu),Z.add("Volume",by),Z.add("VolumeParameter",qe),Z.add("VolumeProfile",NA),Z.add("WebARCameraBackground",UE),Z.add("WebARSessionRoot",cd),Z.add("WebXR",Nn),Z.add("WebXRImageTracking",xy),Z.add("WebXRImageTrackingModel",eh),Z.add("WebXRPlaneTracking",md),Z.add("WebXRTrackedImage",Ay),Z.add("XRControllerFollow",fd),Z.add("XRControllerModel",Wc),Z.add("XRControllerMovement",va),Z.add("XRFlag",pa),Z.add("XRRig",VE),Z.add("XRState",go);const Yx=Ds,$_e=te("debugtypestore");$_e&&console.log(Z);function eSe(n,e){const i=W9(n,e);return i!==void 0?i:null}const tSe=new zme,IG=Symbol("deserialize-queue");async function iSe(n,e,i,s=null,r){if(!i){console.debug("Can not create component instances: gltf is null");return}let o=s;typeof o=="number"&&(o=new xr(s));const a=e.indexOf("?");e=a===-1?e:e.substring(0,a);const l=new $k(i.scene);l.gltfId=e,l.context=n,l.gltf=i,l.nodeToObject=r?.nodeToObjectMap,l.implementationInformation=tSe;let c=n[IG];if(c||(c=n[IG]=[]),i.scenes)for(const h of i.scenes)await kG(l,h,c);if(i.children)for(const h of i.children)await kG(l,h,c);n.new_scripts_pre_setup_callbacks.push(()=>{const h=n[IG];if(h){for(const d of h)nSe(d,l);h.length=0}if(o){const d={},u=[];PG(i,o,d,u);for(const m of i.scenes)PG(m,o,d,u);for(const m of u)m.resolveGuids(d)}})}const LG=Symbol("original-component-name"),Sy=new Map;function PG(n,e,i,s){if(e===null||!n)return;const r=n.guid,o=n.guid;o!=null&&o.length&&(Sy.has(o)||(Yx&&console.log('Creating InstanceIdProvider with key "'+o+'" for object '+n.name),Sy.set(o,new xr(o))));const a=o&&Sy.get(o)||e;if(n.guid=a.generateUUID(),r&&r!=="invalid"&&(i[r]=n.guid),n&&n.userData&&n.userData.components)for(const l of n.userData.components){if(l===null)continue;const c=l.guid;c?Sy.has(c)||(Yx&&console.log('Creating InstanceIdProvider with key "'+c+'" for component '+l[LG]),Sy.set(c,new xr(c))):Yx&&console.warn("Can not create IdProvider: component "+l[LG]+" has no guid",l.guid);const h=Sy.get(c)||e,d=l.guid;l.guid=h.generateUUID(),d&&d!=="invalid"&&(i[d]=l.guid),l.resolveGuids&&s.push(l)}if(n.children)for(const l of n.children)PG(l,e,i,s)}const Kx=[];async function kG(n,e,i,s){if(!e)return;const r=e.userData;if(r){const o=r.builtin_components;if(o&&o.length>0)for(const a of o)try{if(a===null)continue;const l=Z.get(a.name);if(l!=null){const c=new l;c.sourceId=n.gltfId,d0(c,a,n.implementationInformation),c.context=n.context,"guid"in a&&(c[ib]=a.guid),c[LG]=a.name,Rm(e,c,!1),i.push({instance:c,compData:a,obj:e}),c.isCamera&&n.context&&n.context.mainCamera===null&&c.tag==="MainCamera"&&n.context.setCurrentCamera(c)}else Yx&&console.debug("unknown component: "+a.name),Kx.includes(a.name)||Kx.push(a.name)}catch(l){console.error(a.name+" - "+l.message,l)}if(Kx.length>0){const a=Kx.join(", ");console.warn("unknown components: "+a),Kx.length=0,io()&&gn(`<strong>Unknown components in scene</strong>:
|
|
7955
7955
|
|
|
7956
7956
|
${a}
|
|
7957
7957
|
|
|
@@ -8560,4 +8560,4 @@ struct BVH {
|
|
|
8560
8560
|
`,bMe=Object.freeze(Object.defineProperty({__proto__:null,bvh_distance_functions:B6,bvh_ray_functions:O6,bvh_struct_definitions:D6,common_functions:k6},Symbol.toStringTag,{value:"Module"})),AMe=D6,xMe=B6,wMe=`
|
|
8561
8561
|
${k6}
|
|
8562
8562
|
${O6}
|
|
8563
|
-
`,_Me=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:KK,BVHShaderGLSL:bMe,CENTER:qG,CONTAINED:$G,ExtendedTriangle:rl,FloatVertexAttributeTexture:M6,INTERSECTED:KSe,IntVertexAttributeTexture:cMe,MeshBVH:Zy,MeshBVHHelper:O3,MeshBVHUniformStruct:hMe,NOT_INTERSECTED:YSe,OrientedBox:Qr,SAH:JK,StaticGeometryGenerator:vMe,UIntVertexAttributeTexture:C6,VertexAttributeTexture:_T,acceleratedRaycast:nMe,computeBoundsTree:sMe,disposeBoundsTree:rMe,estimateMemoryInBytes:$Ce,getBVHExtremes:qCe,getJSONStructure:tMe,getTriangleHitPointInfo:ACe,shaderDistanceFunction:xMe,shaderIntersectFunction:wMe,shaderStructs:AMe,validateBounds:eMe},Symbol.toStringTag,{value:"Module"}));class SMe{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=i=>{throw i.message?new Error(`${this.name}: Could not create Web Worker with error "${i.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const i=this.runTask(this.worker,...e);return i.finally(()=>{this.running=!1}),i}dispose(){this.worker.terminate(),this.worker=null}}const G6="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiOy8qKgogKiBAbGljZW5zZQogKiBDb3B5cmlnaHQgMjAxMC0yMDIzIFRocmVlLmpzIEF1dGhvcnMKICogU1BEWC1MaWNlbnNlLUlkZW50aWZpZXI6IE1JVAogKi9jb25zdCBXZT0iMTYyIixzcz0iIjtjbGFzcyBYZXthZGRFdmVudExpc3RlbmVyKHQsZSl7dGhpcy5fbGlzdGVuZXJzPT09dm9pZCAwJiYodGhpcy5fbGlzdGVuZXJzPXt9KTtjb25zdCBpPXRoaXMuX2xpc3RlbmVycztpW3RdPT09dm9pZCAwJiYoaVt0XT1bXSksaVt0XS5pbmRleE9mKGUpPT09LTEmJmlbdF0ucHVzaChlKX1oYXNFdmVudExpc3RlbmVyKHQsZSl7aWYodGhpcy5fbGlzdGVuZXJzPT09dm9pZCAwKXJldHVybiExO2NvbnN0IGk9dGhpcy5fbGlzdGVuZXJzO3JldHVybiBpW3RdIT09dm9pZCAwJiZpW3RdLmlu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ZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueCtlLngsdGhpcy55PXQueStlLnksdGhpcy56PXQueitlLnosdGhpc31hZGRTY2FsZWRWZWN0b3IodCxlKXtyZXR1cm4gdGhpcy54Kz10LngqZSx0aGlzLnkrPXQueSplLHRoaXMueis9dC56KmUsdGhpc31zdWIodCl7cmV0dXJuIHRoaXMueC09dC54LHRoaXMueS09dC55LHRoaXMuei09dC56LHRoaXN9c3ViU2NhbGFyKHQpe3JldHVybiB0aGlzLngtPXQsdGhpcy55LT10LHRoaXMuei09dCx0aGlzfXN1YlZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueC1lLngsdGhpcy55PXQueS1lLnksdGhpcy56PXQuei1lLnosdGhpc31tdWx0aXBseSh0KXtyZXR1cm4gdGhpcy54Kj10LngsdGhpcy55Kj10LnksdGhpcy56Kj10LnosdGhpc31tdWx0aXBseVNjYWxhcih0KXtyZXR1cm4gdGhpcy54Kj10LHRoaXMueSo9dCx0aGlzLnoqPXQsdGhpc31tdWx0aXBseVZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueCplLngsdGhpcy55PXQueSplLnksdGhpcy56PXQueiplLnosdGhpc31hcHBseUV1bGVyKHQpe3JldHVybiB0aGlzLmFwcGx5UXVhdGVybmlvbihDaS5zZXRGcm9tRXVsZXIodCkpfWFwcGx5QXhpc0FuZ2xlKHQsZSl7cmV0dXJuIHRoaXMuYXBwbHlRdWF0ZXJuaW9uKENpLnNldEZyb21BeGlzQW5nbGUodCxlKSl9YXBwbHlNYXRyaXgzKHQpe2NvbnN0IGU9dGhpcy54LGk9dGhpcy55LHM9dGhpcy56LG49dC5lbGVtZW50cztyZXR1cm4gdGhpcy54PW5bMF0qZStuWzNdKmkrbls2XSpzLHRoaXMueT1uWzFdKmUrbls0XSppK25bN10qcyx0aGlzLno9blsyXSplK25bNV0qaStuWzhdKnMsdGhpc31hcHBseU5vcm1hbE1hdHJpeCh0KXtyZXR1cm4gdGhp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zLnkvPXQueSx0aGlzLnovPXQueix0aGlzfWRpdmlkZVNjYWxhcih0KXtyZXR1cm4gdGhpcy5tdWx0aXBseVNjYWxhcigxL3QpfW1pbih0KXtyZXR1cm4gdGhpcy54PU1hdGgubWluKHRoaXMueCx0LngpLHRoaXMueT1NYXRoLm1pbih0aGlzLnksdC55KSx0aGlzLno9TWF0aC5taW4odGhpcy56LHQueiksdGhpc31tYXgodCl7cmV0dXJuIHRoaXMueD1NYXRoLm1heCh0aGlzLngsdC54KSx0aGlzLnk9TWF0aC5tYXgodGhpcy55LHQueSksdGhpcy56PU1hdGgubWF4KHRoaXMueix0LnopLHRoaXN9Y2xhbXAodCxlKXtyZXR1cm4gdGhpcy54PU1hdGgubWF4KHQueCxNYXRoLm1pbihlLngsdGhpcy54KSksdGhpcy55PU1hdGgubWF4KHQueSxNYXRoLm1pbihlLnksdGhpcy55KSksdGhpcy56PU1hdGgubWF4KHQueixNYXRoLm1pbihlLnosdGhpcy56KSksdGhpc31jbGFtcFNjYWxhcih0LGUpe3JldHVybiB0aGlzLng9TWF0aC5tYXgodCxNYXRoLm1pbihlLHRoaXMueCkpLHRoaXMueT1NYXRoLm1heCh0LE1hdGgubWluKGUsdGhpcy55KSksdGhpcy56PU1hdGgubWF4KHQsTWF0aC5taW4oZSx0aGlzLnopKSx0aGlzfWNsYW1wTGVuZ3RoKHQsZSl7Y29uc3QgaT10aGlzLmxlbmd0aCgpO3JldHVybiB0aGlzLmRpdmlkZVNjYWxhcihpfHwxKS5tdWx0aXBseVNjYWxhcihNYXRoLm1heCh0LE1hdGgubWluKGUsaSkpKX1mbG9vcigpe3JldHVybiB0aGlzLng9TWF0aC5mbG9vcih0aGlzLngpLHRoaXMueT1NYXRoLmZsb29yKHRoaXMueSksdGhpcy56PU1hdGguZmxvb3IodGhpcy56KSx0aGlzfWNlaWwoKXtyZXR1cm4gdGhpcy54PU1hdGguY2VpbCh0aGlzLngpLHRoaXMueT1NYXRoLmNlaWwodGhpcy55KSx0a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jb21wdXRlQm91bmRpbmdCb3goKSxkZS5jb3B5KHQuYm91bmRpbmdCb3gpKTooaS5ib3VuZGluZ0JveD09PW51bGwmJmkuY29tcHV0ZUJvdW5kaW5nQm94KCksZGUuY29weShpLmJvdW5kaW5nQm94KSksZGUuYXBwbHlNYXRyaXg0KHQubWF0cml4V29ybGQpLHRoaXMudW5pb24oZGUpfWNvbnN0IHM9dC5jaGlsZHJlbjtmb3IobGV0IG49MCxyPXMubGVuZ3RoO248cjtuKyspdGhpcy5leHBhbmRCeU9iamVjdChzW25dLGUpO3JldHVybiB0aGlzfWNvbnRhaW5zUG9pbnQodCl7cmV0dXJuISh0Lng8dGhpcy5taW4ueHx8dC54PnRoaXMubWF4Lnh8fHQueTx0aGlzLm1pbi55fHx0Lnk+dGhpcy5tYXgueXx8dC56PHRoaXMubWluLnp8fHQuej50aGlzLm1heC56KX1jb250YWluc0JveCh0KXtyZXR1cm4gdGhpcy5taW4ueDw9dC5taW4ueCYmdC5tYXgueDw9dGhpcy5tYXgueCYmdGhpcy5taW4ueTw9dC5taW4ueSYmdC5tYXgueTw9dGhpcy5tYXgueSYmdGhpcy5taW4uejw9dC5taW4ueiYmdC5tYXguejw9dGhpcy5tYXguen1nZXRQYXJhbWV0ZXIodCxlKXtyZXR1cm4gZS5zZXQoKHQueC10aGlzLm1pbi54KS8odGhpcy5tYXgueC10aGlzLm1pbi54KSwodC55LXRoaXMubWluLnkpLyh0aGlzLm1heC55LXRoaXMubWluLnkpLCh0LnotdGhpcy5taW4ueikvKHRoaXMubWF4LnotdGhpcy5taW4ueikpfWludGVyc2VjdHNCb3godCl7cmV0dXJuISh0Lm1heC54PHRoaXMubWluLnh8fHQubWluLng+dGhpcy5tYXgueHx8dC5tYXgueTx0aGlzLm1pbi55fHx0Lm1pbi55PnRoaXMubWF4Lnl8fHQubWF4Lno8dGhpcy5taW4uenx8dC5taW4uej50aGlzLm1heC56KX1pbnRlcnNlY3RzU3BoZXJlKHQpe3JldHVybiB0aGlz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19KSgpOwo=",N6=typeof window<"u"&&window.Blob&&new Blob([atob(G6)],{type:"text/javascript;charset=utf-8"});function CMe(){let n;try{if(n=N6&&(window.URL||window.webkitURL).createObjectURL(N6),!n)throw"";return new Worker(n)}catch{return new Worker("data:application/javascript;base64,"+G6)}finally{n&&(window.URL||window.webkitURL).revokeObjectURL(n)}}class MMe extends SMe{constructor(){super(new CMe),this.name="GenerateMeshBVHWorker"}runTask(e,i,s={}){return new Promise((r,o)=>{if(i.getAttribute("position").isInterleavedBufferAttribute||i.index&&i.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`GenerateMeshBVHWorker: ${h.message}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:m}=d,f=Zy.deserialize(u,i,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},s);if(i.attributes.position.array=m,u.index)if(i.index)i.index.array=u.index;else{const v=new $e(u.index,1,!1);i.setIndex(v)}g.setBoundingBox&&(i.boundingBox=f.getBoundingBox(new Wt)),s.onProgress&&s.onProgress(d.progress),r(f),e.onmessage=null}else s.onProgress&&s.onProgress(d.progress)};const a=i.index?i.index.array:null,l=i.attributes.position.array,c=[l];a&&c.push(a),e.postMessage({index:a,position:l,options:{...s,onProgress:null,includedProgressCallback:!!s.onProgress,groups:[...i.groups]}},c.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const EMe=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:MMe},Symbol.toStringTag,{value:"Module"})),al={node:"node",material:"material",camera:"camera",light:"light"},Rf="KHR_animation_pointer",TMe={CUBICSPLINE:void 0,LINEAR:sc,STEP:Ld},F6=Zt.findNode;let z6=!1;class RMe{constructor(e){this.parser=e,this.name=Rf,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){z6||(z6=!0,Zt.findNode=function(e,i){if(i.startsWith(".materials.")){const s=i.substring(11).substring(i.indexOf(".")),r=s.indexOf("."),o=r<0?s:s.substring(0,r);let a=null;return e.traverse(l=>{a!==null||l.type!=="Mesh"&&l.type!=="SkinnedMesh"||l.material&&(l.material.uuid===o||l.material.name===o)&&(a=l.material,a!==null&&(s.endsWith(".map")?a=a.map:s.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(i.startsWith(".nodes.")||i.startsWith(".lights.")||i.startsWith(".cameras.")){const s=i.split(".");let r;for(let o=1;o<s.length;o++){const a=s[o];if(a.length==36)r=e.getObjectByProperty("uuid",a);else if(r&&r[a]){const l=Number.parseInt(a);let c=a;l>=0&&(c=l),r=r[c]}else{const l=e.getObjectByName(a);l&&(r=l)}}if(!r){const o=F6(e,s[2]);return o||console.warn(Rf+": Property binding not found",i,e,e.name,s),o}return r}return F6(e,i)})}loadAnimationTargetFromChannel(e){const i=e.target,s=i.node!==void 0?i.node:i.id;return this.parser.getDependency("node",s)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const i=e.target,s=i.extensions&&i.extensions[Rf]&&i.path&&i.path==="pointer";if(!s)return null;let r,o=al.node,a;if(s){const c=i.extensions[Rf];let h=c.pointer;if(!h){console.warn("Invalid path",c,i);return}if(h.startsWith("/materials/")?o=al.material:h.startsWith("/extensions/KHR_lights_punctual/lights/")?o=al.light:h.startsWith("/cameras/")&&(o=al.camera),a=this._tryResolveTargetId(h,o),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,h);return}switch(o){case al.material:const u=("/materials/"+a.toString()+"/").length,m=h.substring(0,u);switch(r=h.substring(u),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}h=m+r;break;case al.node:const f=("/nodes/"+a.toString()+"/").length,g=h.substring(0,f);switch(r=h.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}h=g+r;break;case al.light:const v=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(r=h.substring(v),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}h="/lights/"+a.toString()+"/"+r;break;case al.camera:const y=("/cameras/"+a.toString()+"/").length,b=h.substring(0,y);switch(r=h.substring(y),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}h=b+r;break}const d=this.animationPointerResolver;d&&d.resolvePath&&(h=d.resolvePath(h)),i.extensions[Rf].pointer=h}if(a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,i);return}let l;return o===al.node?l=this.parser.getDependency("node",a):o===al.material?l=this.parser.getDependency("material",a):o===al.light?l=this.parser.getDependency("light",a):o===al.camera?l=this.parser.getDependency("camera",a):console.error("Unhandled type",o),l}createAnimationTracksWithAnimationPointer(e,i,s,r,o){if(!(o.extensions&&o.extensions[Rf]&&o.path&&o.path==="pointer"))return null;let a=o.extensions[Rf].pointer;if(!a)return null;const l=[];a=a.replaceAll("/",".");const c=a.split(".");var h=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=h,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const u of e.children)u instanceof Mo&&u.morphTargetInfluences&&(c[3]=u.name,c[4]="morphTargetInfluences",d(this.parser));return l}d(this.parser);function d(u){a=c.join(".");let m;switch(s.itemSize){case 1:m=bh;break;case 2:case 3:m=ac;break;case 4:a.endsWith(".quaternion")?m=yl:m=Kw;break}const f=r.interpolation!==void 0?TMe[r.interpolation]:sc;let g=u._getArrayFromAccessor(s);a.endsWith(".fov")&&(g=g.map(y=>y/Math.PI*180));const v=new m(a,i.array,g,f);if(f==="CUBICSPLINE"&&u._createCubicSplineTrackInterpolant(v),l.push(v),a&&s.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const y=new Float32Array(g.length/4);for(let A=0,x=g.length/4;A<x;A+=1)y[A]=g[A*4+3];const b=new m(a.replace(".color",".opacity"),i.array,y,f);f==="CUBICSPLINE"&&u._createCubicSplineTrackInterpolant(v),l.push(b)}}return l}_tryResolveTargetId(e,i){let s="";return i==="node"?s=e.substring(7):i==="material"?s=e.substring(11):i==="light"?s=e.substring(39):i==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const i=this,s=this.parser.json,r=this.parser,o=s.animations[e],a=o.name?o.name:"animation_"+e,l=[],c=[],h=[],d=[],u=[];for(let m=0,f=o.channels.length;m<f;m++){const g=o.channels[m],v=o.samplers[g.sampler],y=g.target,b=o.parameters!==void 0?o.parameters[v.input]:v.input,A=o.parameters!==void 0?o.parameters[v.output]:v.output;let x=i.loadAnimationTargetFromChannelWithAnimationPointer(g);x||(x=i.loadAnimationTargetFromChannel(g)),l.push(x),c.push(r.getDependency("accessor",b)),h.push(r.getDependency("accessor",A)),d.push(v),u.push(y)}return Promise.all([Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d),Promise.all(u)]).then(function(m){const f=m[0],g=m[1],v=m[2],y=m[3],b=m[4],A=[];for(let x=0,w=f.length;x<w;x++){const _=f[x],S=g[x],C=v[x],R=y[x],P=b[x];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);let T=i.createAnimationTracksWithAnimationPointer(_,S,C,R,P);if(T||(T=r._createAnimationTracks(_,S,C,R,P)),T)for(let L=0;L<T.length;L++)A.push(T[L])}return new to(a,void 0,A)})}}const IMe=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:RMe},Symbol.toStringTag,{value:"Module"}));export{Hye as $physicsKey,vi as ActionBuilder,eO as ActionCollection,aa as ActionModel,S9 as Addressables,xA as AlignmentConstraint,A0 as AmbientMode,zr as Animation,Fm as AnimationCurve,SA as AnimationExtension,uM as AnimationTrackHandler,y0 as AnimationUtils,sr as Animator,Lu as AnimatorConditionMode,Ea as AnimatorController,tO as AnimatorControllerParameterType,_A as AnimatorStateInfo,FA as Antialiasing,Xh as Application,xC as ApplicationEvents,v4 as AssetDatabase,ei as AssetReference,vp as AudioExtension,Gu as AudioListener,Cn as AudioSource,DA as AudioTrackHandler,zu as Avatar,Vm as AvatarBlink_Simple,N0 as AvatarEyeLook_Rotation,PO as AvatarLoader,ar as AvatarMarker,gM as AvatarModel,WA as Avatar_Brain_LookAt,QA as Avatar_MouthShapes,RO as Avatar_MustacheShake,kc as Avatar_POI,L0 as Axes,F0 as AxesHelper,AL as BUILD_TIME,hl as BaseUIComponent,BO as BasicIKConstraint,vM as BehaviorExtension,Gs as BehaviorModel,Pe as Behaviour,km as BlobStorage,Xm as BloomEffect,U0 as BoxCollider,Hm as BoxGizmo,qa as BoxHelperComponent,td as Button,Hh as ButtonsFactory,TQ as CallDirection,Tc as CallInfo,Fi as Camera,LA as CameraTargetReachedEvent,lr as Canvas,Hu as CanvasGroup,ed as CapsuleCollider,W0 as ChangeMaterialOnClick,Zm as ChangeTransformOnClick,Jm as CharacterController,nd as CharacterControllerInput,ix as ChromaticAberration,Yo as CircularBuffer,Ou as ClearFlags,Rc as ClipExtrapolation,Do as Collider,CQ as Collision,eM as CollisionDetectionMode,Zu as ColorAdjustments,$m as ColorBySpeedModule,hx as ColorOverLifetimeModule,Pe as Component,Zb as ComponentLifecycleEvents,jH as ConnectionEvents,SQ as ContactPoint,jl as ContactShadows,Pt as Context,ege as ContextArgs,_i as ContextEvent,xi as ContextRegistry,pM as ControlTrackHandler,ip as CustomBranding,Wl as CustomShader,LC as DefaultReflectionMode,AD as Deletable,yx as DeleteBox,Ql as DepthOfField,tE as DeviceFlag,At as DeviceUtilities,xD as DocumentExtension,No as DragControls,_D as DragMode,ud as DropListener,iE as DropListenerAddedEvent,of as Duplicatable,bx as EffectWrapper,Uc as EmissionModule,j0 as EmphasizeOnClick,DB as EngineLoadingView,ji as EventList,iM as EventListEvent,Ka as EventSystem,rE as EventTrigger,sD as FieldWithDefault,AC as FileReference,M9 as FileReferenceSerializer,EAe as FileSpawnModel,CZ as File_Event,TD as FixedJoint,RD as FlyControls,oy as Fog,Ji as FrameEvent,O_ as GENERATOR,ie as GameObject,ft as Gizmos,_x as GltfExport,OD as GltfExportBox,bf as GltfLoadEvent,sK as GltfLoadEventType,Yu as Gradient,jm as Graphic,rM as GraphicRaycaster,Oa as Graphics,cy as GridHelper,jO as GridLayoutGroup,Cc as GroundProjectedEnv,jh as GroupActionModel,d9 as HideFlags,YO as HideOnStart,Ax as HingeJoint,HO as HorizontalLayoutGroup,Tme as HostData,X0 as Image,vC as ImageReference,C9 as ImageReferenceSerializer,Ju as InheritVelocityModule,bW as Input,na as InputEventQueue,yn as InputEvents,af as InputField,nx as InstanceHandle,q0 as InstancingHandler,dl as InstancingUtil,P4 as InstantiateEvent,xr as InstantiateIdProvider,tc as InstantiateOptions,bD as Interactable,rpe as JoinedRoomResponse,pue as KeyEventArgs,mo as Keyframe,Cx as LODGroup,lf as LODModel,ope as LeftRoomResponse,Fo as Light,Y9 as LightData,ls as LimitVelocityOverLifetimeModule,lge as LoadingElementOptions,FD as LogStats,Ko as LogType,cf as LookAt,zm as LookAtConstraint,hr as MainModule,yO as MarkerType,qA as MaskableGraphic,et as Mathf,Wm as MeshCollider,ox as MeshRenderer,gt as MinMaxCurve,yo as MinMaxGradient,mi as NEEDLE_progressive,kb as NEKeyboardEvent,Dh as NEPointerEvent,JG as NeedleButtonElement,xi as NeedleEngine,GG as NeedleEngineHTMLElement,BG as NeedleLoader,Xc as NeedleMenu,U_ as NeedlePatchesKey,Pj as NeedleUSDZExporter,HP as NeedleXRController,Et as NeedleXRSession,YH as NeedleXRSync,u4 as NeedleXRUtils,uE as NestedGltf,ZH as NetworkConnection,Bc as NetworkedStreamEvents,x1 as NetworkedStreams,dy as Networking,B4 as NewInstanceModel,Pi as NoiseModule,ca as ObjectRaycaster,vu as ObjectUtils,hf as OffsetConstraint,R_ as OneEuroFilter,iL as OneEuroFilterXYZ,uy as OpenURL,Ti as OrbitControls,V0 as Outline,QH as OwnershipEvent,gk as OwnershipModel,tb as PUBLIC_KEY,Xu as Padding,cx as ParticleBurst,TE as ParticleSubEmitter,hs as ParticleSystem,op as ParticleSystemBaseBehaviour,tl as ParticleSystemRenderer,FM as ParticleSystemShapeType,jA as PeerHandle,WH as PeerNetworking,HS as Physics,KM as PhysicsExtension,zs as PhysicsMaterialCombine,Ox as PixelationEffect,Km as PlayAnimationOnClick,ju as PlayAudioOnClick,Fu as PlayableDirector,Ky as PlayerColor,ua as PlayerState,bQ as PlayerStateEvent,D0 as PlayerSync,W9 as PlayerView,H9 as PlayerViewManager,Qy as PointerEventData,TS as PointerType,Us as PostProcessingEffect,RE as PostProcessingHandler,by as PostProcessingManager,Q0 as PreliminaryAction,ex as PreliminaryTrigger,np as PreviewHelper,_m as PrimitiveType,ai as Progress,f_ as PromiseAllWithErrors,bI as PromiseErrorResult,Li as RGBAColor,s1 as RapierPhysics,wM as RawImage,Ac as RaycastOptions,UO as Rect,Vr as RectTransform,Y0 as ReflectionProbe,Cd as RegisteredAnimationInfo,Jc as RemoteSkybox,I0 as RenderTexture,hQ as RenderTextureSerializer,Dn as Renderer,Z9 as RendererData,sx as RendererLightmap,Ci as Rigidbody,Qn as RigidbodyConstraints,Xt as RoomEvents,ya as RotationBySpeedModule,$a as RotationOverLifetimeModule,PM as SceneLightSettings,Cs as SceneSwitcher,lp as ScreenCapture,pd as ScreenSpaceAmbientOcclusion,Yl as ScreenSpaceAmbientOcclusionN8,Bl as SendQueue,$k as SerializationContext,Ym as SetActiveOnClick,Ux as ShadowCatcher,Rn as ShapeModule,Gx as SharpeningEffect,kA as SignalAsset,O0 as SignalReceiver,B0 as SignalReceiverEvent,GA as SignalTrackHandler,zO as Size,vo as SizeBySpeedModule,Ku as SizeOverLifetimeModule,rD as SkinnedMeshRenderer,cp as SmoothFollow,P0 as SpatialGrabRaycaster,Vx as SpatialHtml,Hx as SpatialTrigger,qc as SpatialTriggerReceiver,BE as SpectatorCamera,z0 as SphereCollider,Pk as SphereIntersection,MQ as SphereOverlapResult,Vc as Sprite,ld as SpriteData,Go as SpriteRenderer,qu as SpriteSheet,l0e as StateMachineBehaviour,EO as StreamEndedEvent,EQ as StreamReceivedEvent,Bx as SubEmitterSystem,DE as SyncedCamera,Kl as SyncedRoom,Ec as SyncedTransform,KO as TapGestureTrigger,ZM as TeleportTarget,SG as TestRunner,kSe as TestSceneUtils,CG as TestSimulateUserData,Xr as Text,JM as TextBuilder,mx as TextExtension,dr as TextureSheetAnimationModule,$c as TiltShiftEffect,J9 as Time,Qu as ToneMappingEffect,BA as TrackHandler,ha as TrackType,xn as TrailModule,Sn as TransformData,ff as TransformGizmo,Ns as TriggerBuilder,Eu as TriggerModel,Z as TypeStore,oM as UIRaycastUtils,RA as UIRootComponent,XB as USDDocument,ho as USDObject,Lj as USDWriter,Ln as USDZExporter,tp as USDZText,qM as USDZUIExtension,dQ as UriSerializer,gx as UsageMarker,ape as UserJoinedOrLeftRoomModel,_l as VERSION,$B as VariantAction,In as VelocityOverLifetimeModule,WO as VerticalLayoutGroup,Ms as VideoPlayer,Cu as ViewDevice,gf as Vignette,tx as VisibilityAction,Uu as Voip,by as Volume,qe as VolumeParameter,NA as VolumeProfile,mfe as WaitForFrames,R9 as WaitForPromise,T9 as WaitForSeconds,Ad as Watch,UE as WebARCameraBackground,cd as WebARSessionRoot,Nn as WebXR,ef as WebXRButtonFactory,xy as WebXRImageTracking,eh as WebXRImageTrackingModel,md as WebXRPlaneTracking,Ay as WebXRTrackedImage,fd as XRControllerFollow,Wc as XRControllerModel,va as XRControllerMovement,pa as XRFlag,VE as XRRig,go as XRState,Pc as XRStateFlag,RG as __Ignore,_4 as __internalNotifyObjectDestroyed,Ch as activeInHierarchyFieldName,fU as addAttributeChangeCallback,ra as addComponent,pbe as addCustomExtensionPlugin,rSe as addGltfLoadEventListener,Rm as addNewComponent,z_ as addPatch,hC as apply,ySe as applyHMRChanges,K4 as applyPrototypeExtensions,k4 as beginListenDestroy,D4 as beginListenInstantiate,KP as binaryIdentifierCasts,$fe as build_scene_functions,om as builtinComponentKeyName,BB as calculateProgress01,_U as clearBalloonMessages,_U as clearOverlayMessages,D0e as colorSerializer,z4 as compareAssociation,nM as componentSerializer,O5 as copyTexture,OG as createLoader,$j as createMotion,Bo as debugNet,Vb as debugOwner,Vv as deepClone,bl as delay,u_ as delayForFrames,nC as deserializeObject,oa as destroy,a9 as destroyComponentInstance,Ki as disposeObjectResources,Oc as disposeStream,ib as editorGuidKeyName,mG as effectsOrder,rm as enableSpatialConsole,N0e as euler,V0e as eventListSerializer,FSe as exportAsGLTF,oB as findByGuid,cC as findObjectOfType,h9 as findObjectsOfType,Dk as findResourceUsers,G5 as fitObjectIntoVolume,Pm as foreachComponent,gC as foreachComponentEnumerator,Moe as forward,yU as generateQRCode,O4 as generateSeed,Jo as getBoundingBox,C5 as getCameraController,Im as getComponent,oA as getComponentInChildren,aA as getComponentInParent,rA as getComponents,u0 as getComponentsInChildren,lC as getComponentsInParent,Ej as getFormattedDate,nr as getIconElement,MB as getIconTexture,Lie as getIp,Pie as getIpAndLocation,Iie as getIpCloudflare,vl as getLoader,sA as getOrAddComponent,te as getParam,Roe as getParentHierarchyPath,gie as getPath,tpe as getPeerOptions,VH as getPeerjsInstance,lme as getResourceUserCount,T5 as getTempColor,xl as getTempQuaternion,ht as getTempVector,zv as getUrlParams,D5 as getVisibleInCustomShadowRendering,hL as getWorldDirection,dL as getWorldEuler,Nt as getWorldPosition,Bi as getWorldQuaternion,Yv as getWorldRotation,Yi as getWorldScale,zl as hasCommercialLicense,LB as hasIndieLicense,tM as hasPointerEventComponent,Mu as hasProLicense,V5 as hideDebugConsole,Gj as imageToCanvas,f0 as instantiate,nD as invokeAfterImportPluginHooks,yW as invokeXRSessionEnd,gW as invokeXRSessionStart,u9 as isActiveInHierarchy,p0 as isActiveSelf,wie as isAndroidDevice,B5 as isAnimationAction,_Q as isComponent,uie as isDebugMode,vie as isDesktop,Lm as isDestroyed,je as isDevEnvironment,ome as isDisposed,OSe as isExporting,aU as isHostedOnGlitch,pSe as isHotReloading,Aie as isIPad,ej as isIconElement,io as isLocalNetwork,Sie as isMacOS,bie as isMobileDevice,_ie as isMozillaXR,Eie as isQuest,A4 as isResourceTrackingEnabled,Mie as isSafari,pC as isUsingInstancing,Cie as isiOS,xie as isiPad,DG as loadSync,P_ as logHierarchy,boe as lookAtInverse,Zv as lookAtObject,mie as makeId,uU as makeIdFromRandomWords,Ul as makeNameSafeForUSD,p9 as markAsInstancedRendered,Tie as microphonePermissionsGranted,die as nameof,lU as nameofFactory,cQ as objectSerializer,rue as offXRSessionEnd,sue as offXRSessionStart,C0e as onAfterRender,oQ as onBeforeRender,_0e as onClear,S0e as onDestroy,w0e as onInitialized,oO as onStart,aO as onUpdate,WP as onXRSessionEnd,ES as onXRSessionStart,oK as parseSync,N5 as placeOnSurface,fL as postprocessFBXMaterials,E0e as prefix,cU as pushState,fie as randomNumber,JP as registerBinaryType,GC as registerComponent,BM as registerComponentExtension,Ja as registerCustomEffectType,iD as registerExportExtensions,OM as registerExtensions,mSe as registerHotReloadType,pI as registerLoader,N4 as registerPrefabProvider,J4 as registerPrototypeExtensions,kme as registerType,mU as relativePathPrefix,gU as removeAttributeChangeCallback,rB as removeComponent,mbe as removeCustomImportExtensionType,oSe as removeGltfLoadEventListener,qle as removePatch,Qd as resolveUrl,pU as sanitizeString,zK as saveImage,BSe as screenshot,FK as screenshot2,jk as sendDestroyed,E as serializable,W4 as serializeObject,R0 as serializeable,lA as setActive,xU as setAllowBalloonMessages,Die as setAllowOverlayMessages,rL as setAutoFitEnabled,nL as setCameraController,f9 as setDestroyed,Goe as setDevEnvironment,Ok as setDisposable,m0 as setDontDestroy,gI as setOrAddParamsToUrl,pie as setParam,Uv as setParamWithoutReload,ipe as setPeerOptions,rme as setResourceTrackingEnabled,yI as setState,mL as setVisibleInCustomShadowRendering,uL as setWorldEuler,bs as setWorldPosition,nm as setWorldPositionXYZ,Ba as setWorldQuaternion,cL as setWorldQuaternionXYZW,pL as setWorldRotation,Kv as setWorldRotationXYZ,wg as setWorldScale,B_ as showBalloonError,gn as showBalloonMessage,Oi as showBalloonWarning,bL as showDebugConsole,voe as slerp,qb as syncDestroy,SO as syncField,Qk as syncInstantiate,Ioe as textureToCanvas,TW as tryCastBinary,tK as tryDetermineFileTypeFromBinary,eK as tryDetermineFileTypeFromURL,vg as tryFindObject,RW as tryGetGuid,fSe as unregisterHotReloadType,vI as unwatchWrite,M5 as useForAutoFit,rr as validate,m_ as watchWrite};
|
|
8563
|
+
`,_Me=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:KK,BVHShaderGLSL:bMe,CENTER:qG,CONTAINED:$G,ExtendedTriangle:rl,FloatVertexAttributeTexture:M6,INTERSECTED:KSe,IntVertexAttributeTexture:cMe,MeshBVH:Zy,MeshBVHHelper:O3,MeshBVHUniformStruct:hMe,NOT_INTERSECTED:YSe,OrientedBox:Qr,SAH:JK,StaticGeometryGenerator:vMe,UIntVertexAttributeTexture:C6,VertexAttributeTexture:_T,acceleratedRaycast:nMe,computeBoundsTree:sMe,disposeBoundsTree:rMe,estimateMemoryInBytes:$Ce,getBVHExtremes:qCe,getJSONStructure:tMe,getTriangleHitPointInfo:ACe,shaderDistanceFunction:xMe,shaderIntersectFunction:wMe,shaderStructs:AMe,validateBounds:eMe},Symbol.toStringTag,{value:"Module"}));class SMe{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=i=>{throw i.message?new Error(`${this.name}: Could not create Web Worker with error "${i.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const i=this.runTask(this.worker,...e);return i.finally(()=>{this.running=!1}),i}dispose(){this.worker.terminate(),this.worker=null}}const G6="KGZ1bmN0aW9uKCl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dGhpc31tdWx0aXBseVZlY3RvcnModCxlKXtyZXR1cm4gdGhpcy54PXQueCplLngsdGhpcy55PXQueSplLnksdGhpcy56PXQueiplLnosdGhpc31hcHBseUV1bGVyKHQpe3JldHVybiB0aGlzLmFwcGx5UXVhdGVybmlvbihDaS5zZXRGcm9tRXVsZXIodCkpfWFwcGx5QXhpc0FuZ2xlKHQsZSl7cmV0dXJuIHRoaXMuYXBwbHlRdWF0ZXJuaW9uKENpLnNldEZyb21BeGlzQW5nbGUodCxlKSl9YXBwbHlNYXRyaXgzKHQpe2NvbnN0IGU9dGhpcy54LGk9dGhpcy55LHM9dGhpcy56LG49dC5lbGVtZW50cztyZXR1cm4gdGhpcy54PW5bMF0qZStuWzNdKmkrbls2XSpzLHRoaXMueT1uWzFdKmUrbls0XSppK25bN10qcyx0aGlzLno9blsyXSplK25bNV0qaStuWzhdKnMsdGhpc31hcHBseU5vcm1hbE1hdHJpeCh0KXtyZXR1cm4gdGhpcy5hcHBseU1hdHJpeDModCkubm9ybWFsaXplKCl9YXBwbHlNYXRyaXg0KHQpe2NvbnN0IGU9dGhpcy54LGk9dGhpcy55LHM9dGhpcy56LG49dC5lbGVtZW50cyxyPTEvKG5bM10qZStuWzddKmkrblsxMV0qcytuWzE1XSk7cmV0dXJuIHRoaXMueD0oblswXSplK25bNF0qaStuWzhdKnMrblsxMl0pKnIsdGhpcy55PShuWzFdKmUrbls1XSppK25bOV0qcytuWzEzXSkqcix0aGlzLno9KG5bMl0qZStuWzZdKmkrblsxMF0qcytuWzE0XSkqcix0aGlzfWFwcGx5UXVhdGVybmlvbih0KXtjb25zdCBlPXRoaXMueCxpPXRoaXMueSxzPXRoaXMueixuPXQueCxyPXQueSxhPXQueixvPXQudyxoPTIqKHIqcy1hKmkpLGM9MiooYSplLW4qcyksZj0yKihuKmktciplKTtyZXR1cm4gdGhpcy54PWUrbypoK3IqZi1hKmMsdGhpcy55PWkrbypjK2EqaC1uKmYsdGhpcy56PXMrbypmK24qYy1yKm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CYmdGhpcy5taW4ueTw9dC5taW4ueSYmdC5tYXgueTw9dGhpcy5tYXgueSYmdGhpcy5taW4uejw9dC5taW4ueiYmdC5tYXguejw9dGhpcy5tYXguen1nZXRQYXJhbWV0ZXIodCxlKXtyZXR1cm4gZS5zZXQoKHQueC10aGlzLm1pbi54KS8odGhpcy5tYXgueC10aGlzLm1pbi54KSwodC55LXRoaXMubWluLnkpLyh0aGlzLm1heC55LXRoaXMubWluLnkpLCh0LnotdGhpcy5taW4ueikvKHRoaXMubWF4LnotdGhpcy5taW4ueikpfWludGVyc2VjdHNCb3godCl7cmV0dXJuISh0Lm1heC54PHRoaXMubWluLnh8fHQubWluLng+dGhpcy5tYXgueHx8dC5tYXgueTx0aGlzLm1pbi55fHx0Lm1pbi55PnRoaXMubWF4Lnl8fHQubWF4Lno8dGhpcy5taW4uenx8dC5taW4uej50aGlzLm1heC56KX1pbnRlcnNlY3RzU3BoZXJlKHQpe3JldHVybiB0aGlzLmNsYW1wUG9pbnQodC5jZW50ZXIsZXQpLGV0LmRpc3RhbmNlVG9TcXVhcmVkKHQuY2VudGVyKTw9dC5yYWRpdXMqdC5yYWRpdXN9aW50ZXJzZWN0c1BsYW5lKHQpe2xldCBlLGk7cmV0dXJuIHQubm9ybWFsLng+MD8oZT10Lm5vcm1hbC54KnRoaXMubWluLngsaT10Lm5vcm1hbC54KnRoaXMubWF4LngpOihlPXQubm9ybWFsLngqdGhpcy5tYXgueCxpPXQubm9ybWFsLngqdGhpcy5taW4ueCksdC5ub3JtYWwueT4wPyhlKz10Lm5vcm1hbC55KnRoaXMubWluLnksaSs9dC5ub3JtYWwueSp0aGlzLm1heC55KTooZSs9dC5ub3JtYWwueSp0aGlzLm1heC55LGkrPXQubm9ybWFsLnkqdGhpcy5taW4ueSksdC5ub3JtYWwuej4wPyhlKz10Lm5vcm1hbC56KnRoaXMubWluLnosaSs9dC5ub3JtYWwueip0aGlzLm1heC56KTooZSs9dC5ub3JtYWwueip0aGlzLm1heC56LGk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X19Y29uc3QgYT1uZXcgTmUocixuKSxvPU5lLnNlcmlhbGl6ZShhLHtjb3B5SW5kZXhCdWZmZXI6ITF9KTtsZXQgaD1bcy5idWZmZXIsLi4uby5yb290c107by5pbmRleCYmaC5wdXNoKG8uaW5kZXguYnVmZmVyKSxoPWguZmlsdGVyKGM9PnR5cGVvZiBTaGFyZWRBcnJheUJ1ZmZlcj4idSJ8fCEoYyBpbnN0YW5jZW9mIFNoYXJlZEFycmF5QnVmZmVyKSksYS5faW5kaXJlY3RCdWZmZXImJmgucHVzaChvLmluZGlyZWN0QnVmZmVyLmJ1ZmZlcikscG9zdE1lc3NhZ2Uoe2Vycm9yOm51bGwsc2VyaWFsaXplZDpvLHBvc2l0aW9uOnMscHJvZ3Jlc3M6MX0saCl9Y2F0Y2gocil7cG9zdE1lc3NhZ2Uoe2Vycm9yOnIsc2VyaWFsaXplZDpudWxsLHBvc2l0aW9uOm51bGwscHJvZ3Jlc3M6MX0pfX19KSgpOwo=",N6=typeof window<"u"&&window.Blob&&new Blob([atob(G6)],{type:"text/javascript;charset=utf-8"});function CMe(){let n;try{if(n=N6&&(window.URL||window.webkitURL).createObjectURL(N6),!n)throw"";return new Worker(n)}catch{return new Worker("data:application/javascript;base64,"+G6)}finally{n&&(window.URL||window.webkitURL).revokeObjectURL(n)}}class MMe extends SMe{constructor(){super(new CMe),this.name="GenerateMeshBVHWorker"}runTask(e,i,s={}){return new Promise((r,o)=>{if(i.getAttribute("position").isInterleavedBufferAttribute||i.index&&i.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`GenerateMeshBVHWorker: ${h.message}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:m}=d,f=Zy.deserialize(u,i,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},s);if(i.attributes.position.array=m,u.index)if(i.index)i.index.array=u.index;else{const v=new $e(u.index,1,!1);i.setIndex(v)}g.setBoundingBox&&(i.boundingBox=f.getBoundingBox(new Wt)),s.onProgress&&s.onProgress(d.progress),r(f),e.onmessage=null}else s.onProgress&&s.onProgress(d.progress)};const a=i.index?i.index.array:null,l=i.attributes.position.array,c=[l];a&&c.push(a),e.postMessage({index:a,position:l,options:{...s,onProgress:null,includedProgressCallback:!!s.onProgress,groups:[...i.groups]}},c.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const EMe=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:MMe},Symbol.toStringTag,{value:"Module"})),al={node:"node",material:"material",camera:"camera",light:"light"},Rf="KHR_animation_pointer",TMe={CUBICSPLINE:void 0,LINEAR:sc,STEP:Ld},F6=Zt.findNode;let z6=!1;class RMe{constructor(e){this.parser=e,this.name=Rf,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){z6||(z6=!0,Zt.findNode=function(e,i){if(i.startsWith(".materials.")){const s=i.substring(11).substring(i.indexOf(".")),r=s.indexOf("."),o=r<0?s:s.substring(0,r);let a=null;return e.traverse(l=>{a!==null||l.type!=="Mesh"&&l.type!=="SkinnedMesh"||l.material&&(l.material.uuid===o||l.material.name===o)&&(a=l.material,a!==null&&(s.endsWith(".map")?a=a.map:s.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(i.startsWith(".nodes.")||i.startsWith(".lights.")||i.startsWith(".cameras.")){const s=i.split(".");let r;for(let o=1;o<s.length;o++){const a=s[o];if(a.length==36)r=e.getObjectByProperty("uuid",a);else if(r&&r[a]){const l=Number.parseInt(a);let c=a;l>=0&&(c=l),r=r[c]}else{const l=e.getObjectByName(a);l&&(r=l)}}if(!r){const o=F6(e,s[2]);return o||console.warn(Rf+": Property binding not found",i,e,e.name,s),o}return r}return F6(e,i)})}loadAnimationTargetFromChannel(e){const i=e.target,s=i.node!==void 0?i.node:i.id;return this.parser.getDependency("node",s)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const i=e.target,s=i.extensions&&i.extensions[Rf]&&i.path&&i.path==="pointer";if(!s)return null;let r,o=al.node,a;if(s){const c=i.extensions[Rf];let h=c.pointer;if(!h){console.warn("Invalid path",c,i);return}if(h.startsWith("/materials/")?o=al.material:h.startsWith("/extensions/KHR_lights_punctual/lights/")?o=al.light:h.startsWith("/cameras/")&&(o=al.camera),a=this._tryResolveTargetId(h,o),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,h);return}switch(o){case al.material:const u=("/materials/"+a.toString()+"/").length,m=h.substring(0,u);switch(r=h.substring(u),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}h=m+r;break;case al.node:const f=("/nodes/"+a.toString()+"/").length,g=h.substring(0,f);switch(r=h.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}h=g+r;break;case al.light:const v=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(r=h.substring(v),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}h="/lights/"+a.toString()+"/"+r;break;case al.camera:const y=("/cameras/"+a.toString()+"/").length,b=h.substring(0,y);switch(r=h.substring(y),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}h=b+r;break}const d=this.animationPointerResolver;d&&d.resolvePath&&(h=d.resolvePath(h)),i.extensions[Rf].pointer=h}if(a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,i);return}let l;return o===al.node?l=this.parser.getDependency("node",a):o===al.material?l=this.parser.getDependency("material",a):o===al.light?l=this.parser.getDependency("light",a):o===al.camera?l=this.parser.getDependency("camera",a):console.error("Unhandled type",o),l}createAnimationTracksWithAnimationPointer(e,i,s,r,o){if(!(o.extensions&&o.extensions[Rf]&&o.path&&o.path==="pointer"))return null;let a=o.extensions[Rf].pointer;if(!a)return null;const l=[];a=a.replaceAll("/",".");const c=a.split(".");var h=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=h,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const u of e.children)u instanceof Mo&&u.morphTargetInfluences&&(c[3]=u.name,c[4]="morphTargetInfluences",d(this.parser));return l}d(this.parser);function d(u){a=c.join(".");let m;switch(s.itemSize){case 1:m=bh;break;case 2:case 3:m=ac;break;case 4:a.endsWith(".quaternion")?m=yl:m=Kw;break}const f=r.interpolation!==void 0?TMe[r.interpolation]:sc;let g=u._getArrayFromAccessor(s);a.endsWith(".fov")&&(g=g.map(y=>y/Math.PI*180));const v=new m(a,i.array,g,f);if(f==="CUBICSPLINE"&&u._createCubicSplineTrackInterpolant(v),l.push(v),a&&s.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const y=new Float32Array(g.length/4);for(let A=0,x=g.length/4;A<x;A+=1)y[A]=g[A*4+3];const b=new m(a.replace(".color",".opacity"),i.array,y,f);f==="CUBICSPLINE"&&u._createCubicSplineTrackInterpolant(v),l.push(b)}}return l}_tryResolveTargetId(e,i){let s="";return i==="node"?s=e.substring(7):i==="material"?s=e.substring(11):i==="light"?s=e.substring(39):i==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const i=this,s=this.parser.json,r=this.parser,o=s.animations[e],a=o.name?o.name:"animation_"+e,l=[],c=[],h=[],d=[],u=[];for(let m=0,f=o.channels.length;m<f;m++){const g=o.channels[m],v=o.samplers[g.sampler],y=g.target,b=o.parameters!==void 0?o.parameters[v.input]:v.input,A=o.parameters!==void 0?o.parameters[v.output]:v.output;let x=i.loadAnimationTargetFromChannelWithAnimationPointer(g);x||(x=i.loadAnimationTargetFromChannel(g)),l.push(x),c.push(r.getDependency("accessor",b)),h.push(r.getDependency("accessor",A)),d.push(v),u.push(y)}return Promise.all([Promise.all(l),Promise.all(c),Promise.all(h),Promise.all(d),Promise.all(u)]).then(function(m){const f=m[0],g=m[1],v=m[2],y=m[3],b=m[4],A=[];for(let x=0,w=f.length;x<w;x++){const _=f[x],S=g[x],C=v[x],R=y[x],P=b[x];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);let T=i.createAnimationTracksWithAnimationPointer(_,S,C,R,P);if(T||(T=r._createAnimationTracks(_,S,C,R,P)),T)for(let L=0;L<T.length;L++)A.push(T[L])}return new to(a,void 0,A)})}}const IMe=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:RMe},Symbol.toStringTag,{value:"Module"}));export{Hye as $physicsKey,vi as ActionBuilder,eO as ActionCollection,aa as ActionModel,S4 as Addressables,xA as AlignmentConstraint,A0 as AmbientMode,zr as Animation,Fm as AnimationCurve,SA as AnimationExtension,uM as AnimationTrackHandler,y0 as AnimationUtils,sr as Animator,Lu as AnimatorConditionMode,Ea as AnimatorController,tO as AnimatorControllerParameterType,_A as AnimatorStateInfo,FA as Antialiasing,Xh as Application,xC as ApplicationEvents,v9 as AssetDatabase,ei as AssetReference,vp as AudioExtension,Gu as AudioListener,Cn as AudioSource,DA as AudioTrackHandler,zu as Avatar,Vm as AvatarBlink_Simple,N0 as AvatarEyeLook_Rotation,PO as AvatarLoader,ar as AvatarMarker,gM as AvatarModel,WA as Avatar_Brain_LookAt,QA as Avatar_MouthShapes,RO as Avatar_MustacheShake,kc as Avatar_POI,L0 as Axes,F0 as AxesHelper,AL as BUILD_TIME,hl as BaseUIComponent,BO as BasicIKConstraint,vM as BehaviorExtension,Gs as BehaviorModel,Pe as Behaviour,km as BlobStorage,Xm as BloomEffect,U0 as BoxCollider,Hm as BoxGizmo,qa as BoxHelperComponent,td as Button,Hh as ButtonsFactory,TQ as CallDirection,Tc as CallInfo,Fi as Camera,LA as CameraTargetReachedEvent,lr as Canvas,Hu as CanvasGroup,ed as CapsuleCollider,W0 as ChangeMaterialOnClick,Zm as ChangeTransformOnClick,Jm as CharacterController,nd as CharacterControllerInput,ix as ChromaticAberration,Yo as CircularBuffer,Ou as ClearFlags,Rc as ClipExtrapolation,Do as Collider,CQ as Collision,eM as CollisionDetectionMode,Zu as ColorAdjustments,$m as ColorBySpeedModule,hx as ColorOverLifetimeModule,Pe as Component,Zb as ComponentLifecycleEvents,jH as ConnectionEvents,SQ as ContactPoint,jl as ContactShadows,Pt as Context,ege as ContextArgs,_i as ContextEvent,xi as ContextRegistry,pM as ControlTrackHandler,ip as CustomBranding,Wl as CustomShader,LC as DefaultReflectionMode,AD as Deletable,yx as DeleteBox,Ql as DepthOfField,tE as DeviceFlag,At as DeviceUtilities,xD as DocumentExtension,No as DragControls,_D as DragMode,ud as DropListener,iE as DropListenerAddedEvent,of as Duplicatable,bx as EffectWrapper,Uc as EmissionModule,j0 as EmphasizeOnClick,DB as EngineLoadingView,ji as EventList,iM as EventListEvent,Ka as EventSystem,rE as EventTrigger,sD as FieldWithDefault,AC as FileReference,M4 as FileReferenceSerializer,EAe as FileSpawnModel,CZ as File_Event,TD as FixedJoint,RD as FlyControls,oy as Fog,Ji as FrameEvent,O_ as GENERATOR,ie as GameObject,ft as Gizmos,_x as GltfExport,OD as GltfExportBox,bf as GltfLoadEvent,sK as GltfLoadEventType,Yu as Gradient,jm as Graphic,rM as GraphicRaycaster,Oa as Graphics,cy as GridHelper,jO as GridLayoutGroup,Cc as GroundProjectedEnv,jh as GroupActionModel,d4 as HideFlags,YO as HideOnStart,Ax as HingeJoint,HO as HorizontalLayoutGroup,Tme as HostData,X0 as Image,vC as ImageReference,C4 as ImageReferenceSerializer,Ju as InheritVelocityModule,bW as Input,na as InputEventQueue,yn as InputEvents,af as InputField,nx as InstanceHandle,q0 as InstancingHandler,dl as InstancingUtil,P9 as InstantiateEvent,xr as InstantiateIdProvider,tc as InstantiateOptions,bD as Interactable,rpe as JoinedRoomResponse,pue as KeyEventArgs,mo as Keyframe,Cx as LODGroup,lf as LODModel,ope as LeftRoomResponse,Fo as Light,Y4 as LightData,ls as LimitVelocityOverLifetimeModule,lge as LoadingElementOptions,FD as LogStats,Ko as LogType,cf as LookAt,zm as LookAtConstraint,hr as MainModule,yO as MarkerType,qA as MaskableGraphic,et as Mathf,Wm as MeshCollider,ox as MeshRenderer,gt as MinMaxCurve,yo as MinMaxGradient,mi as NEEDLE_progressive,kb as NEKeyboardEvent,Dh as NEPointerEvent,JG as NeedleButtonElement,xi as NeedleEngine,GG as NeedleEngineHTMLElement,BG as NeedleLoader,Xc as NeedleMenu,U_ as NeedlePatchesKey,Pj as NeedleUSDZExporter,HP as NeedleXRController,Et as NeedleXRSession,YH as NeedleXRSync,u9 as NeedleXRUtils,uE as NestedGltf,ZH as NetworkConnection,Bc as NetworkedStreamEvents,x1 as NetworkedStreams,dy as Networking,B9 as NewInstanceModel,Pi as NoiseModule,ca as ObjectRaycaster,vu as ObjectUtils,hf as OffsetConstraint,R_ as OneEuroFilter,iL as OneEuroFilterXYZ,uy as OpenURL,Ti as OrbitControls,V0 as Outline,QH as OwnershipEvent,gk as OwnershipModel,tb as PUBLIC_KEY,Xu as Padding,cx as ParticleBurst,TE as ParticleSubEmitter,hs as ParticleSystem,op as ParticleSystemBaseBehaviour,tl as ParticleSystemRenderer,FM as ParticleSystemShapeType,jA as PeerHandle,WH as PeerNetworking,HS as Physics,KM as PhysicsExtension,zs as PhysicsMaterialCombine,Ox as PixelationEffect,Km as PlayAnimationOnClick,ju as PlayAudioOnClick,Fu as PlayableDirector,Ky as PlayerColor,ua as PlayerState,bQ as PlayerStateEvent,D0 as PlayerSync,W4 as PlayerView,H4 as PlayerViewManager,Qy as PointerEventData,TS as PointerType,Us as PostProcessingEffect,RE as PostProcessingHandler,by as PostProcessingManager,Q0 as PreliminaryAction,ex as PreliminaryTrigger,np as PreviewHelper,_m as PrimitiveType,ai as Progress,f_ as PromiseAllWithErrors,bI as PromiseErrorResult,Li as RGBAColor,s1 as RapierPhysics,wM as RawImage,Ac as RaycastOptions,UO as Rect,Vr as RectTransform,Y0 as ReflectionProbe,Cd as RegisteredAnimationInfo,Jc as RemoteSkybox,I0 as RenderTexture,hQ as RenderTextureSerializer,Dn as Renderer,Z4 as RendererData,sx as RendererLightmap,Ci as Rigidbody,Qn as RigidbodyConstraints,Xt as RoomEvents,ya as RotationBySpeedModule,$a as RotationOverLifetimeModule,PM as SceneLightSettings,Cs as SceneSwitcher,lp as ScreenCapture,pd as ScreenSpaceAmbientOcclusion,Yl as ScreenSpaceAmbientOcclusionN8,Bl as SendQueue,$k as SerializationContext,Ym as SetActiveOnClick,Ux as ShadowCatcher,Rn as ShapeModule,Gx as SharpeningEffect,kA as SignalAsset,O0 as SignalReceiver,B0 as SignalReceiverEvent,GA as SignalTrackHandler,zO as Size,vo as SizeBySpeedModule,Ku as SizeOverLifetimeModule,rD as SkinnedMeshRenderer,cp as SmoothFollow,P0 as SpatialGrabRaycaster,Vx as SpatialHtml,Hx as SpatialTrigger,qc as SpatialTriggerReceiver,BE as SpectatorCamera,z0 as SphereCollider,Pk as SphereIntersection,MQ as SphereOverlapResult,Vc as Sprite,ld as SpriteData,Go as SpriteRenderer,qu as SpriteSheet,l0e as StateMachineBehaviour,EO as StreamEndedEvent,EQ as StreamReceivedEvent,Bx as SubEmitterSystem,DE as SyncedCamera,Kl as SyncedRoom,Ec as SyncedTransform,KO as TapGestureTrigger,ZM as TeleportTarget,SG as TestRunner,kSe as TestSceneUtils,CG as TestSimulateUserData,Xr as Text,JM as TextBuilder,mx as TextExtension,dr as TextureSheetAnimationModule,$c as TiltShiftEffect,J4 as Time,Qu as ToneMappingEffect,BA as TrackHandler,ha as TrackType,xn as TrailModule,Sn as TransformData,ff as TransformGizmo,Ns as TriggerBuilder,Eu as TriggerModel,Z as TypeStore,oM as UIRaycastUtils,RA as UIRootComponent,XB as USDDocument,ho as USDObject,Lj as USDWriter,Ln as USDZExporter,tp as USDZText,qM as USDZUIExtension,dQ as UriSerializer,gx as UsageMarker,ape as UserJoinedOrLeftRoomModel,_l as VERSION,$B as VariantAction,In as VelocityOverLifetimeModule,WO as VerticalLayoutGroup,Ms as VideoPlayer,Cu as ViewDevice,gf as Vignette,tx as VisibilityAction,Uu as Voip,by as Volume,qe as VolumeParameter,NA as VolumeProfile,mfe as WaitForFrames,R4 as WaitForPromise,T4 as WaitForSeconds,Ad as Watch,UE as WebARCameraBackground,cd as WebARSessionRoot,Nn as WebXR,ef as WebXRButtonFactory,xy as WebXRImageTracking,eh as WebXRImageTrackingModel,md as WebXRPlaneTracking,Ay as WebXRTrackedImage,fd as XRControllerFollow,Wc as XRControllerModel,va as XRControllerMovement,pa as XRFlag,VE as XRRig,go as XRState,Pc as XRStateFlag,RG as __Ignore,_9 as __internalNotifyObjectDestroyed,Ch as activeInHierarchyFieldName,fU as addAttributeChangeCallback,ra as addComponent,pbe as addCustomExtensionPlugin,rSe as addGltfLoadEventListener,Rm as addNewComponent,z_ as addPatch,hC as apply,ySe as applyHMRChanges,K9 as applyPrototypeExtensions,k9 as beginListenDestroy,D9 as beginListenInstantiate,KP as binaryIdentifierCasts,$fe as build_scene_functions,om as builtinComponentKeyName,BB as calculateProgress01,_U as clearBalloonMessages,_U as clearOverlayMessages,D0e as colorSerializer,z9 as compareAssociation,nM as componentSerializer,O5 as copyTexture,OG as createLoader,$j as createMotion,Bo as debugNet,Vb as debugOwner,Vv as deepClone,bl as delay,u_ as delayForFrames,nC as deserializeObject,oa as destroy,a4 as destroyComponentInstance,Ki as disposeObjectResources,Oc as disposeStream,ib as editorGuidKeyName,mG as effectsOrder,rm as enableSpatialConsole,N0e as euler,V0e as eventListSerializer,FSe as exportAsGLTF,oB as findByGuid,cC as findObjectOfType,h4 as findObjectsOfType,Dk as findResourceUsers,G5 as fitObjectIntoVolume,Pm as foreachComponent,gC as foreachComponentEnumerator,Moe as forward,yU as generateQRCode,O9 as generateSeed,Jo as getBoundingBox,C5 as getCameraController,Im as getComponent,oA as getComponentInChildren,aA as getComponentInParent,rA as getComponents,u0 as getComponentsInChildren,lC as getComponentsInParent,Ej as getFormattedDate,nr as getIconElement,MB as getIconTexture,Lie as getIp,Pie as getIpAndLocation,Iie as getIpCloudflare,vl as getLoader,sA as getOrAddComponent,te as getParam,Roe as getParentHierarchyPath,gie as getPath,tpe as getPeerOptions,VH as getPeerjsInstance,lme as getResourceUserCount,T5 as getTempColor,xl as getTempQuaternion,ht as getTempVector,zv as getUrlParams,D5 as getVisibleInCustomShadowRendering,hL as getWorldDirection,dL as getWorldEuler,Nt as getWorldPosition,Bi as getWorldQuaternion,Yv as getWorldRotation,Yi as getWorldScale,zl as hasCommercialLicense,LB as hasIndieLicense,tM as hasPointerEventComponent,Mu as hasProLicense,V5 as hideDebugConsole,Gj as imageToCanvas,f0 as instantiate,nD as invokeAfterImportPluginHooks,yW as invokeXRSessionEnd,gW as invokeXRSessionStart,u4 as isActiveInHierarchy,p0 as isActiveSelf,wie as isAndroidDevice,B5 as isAnimationAction,_Q as isComponent,uie as isDebugMode,vie as isDesktop,Lm as isDestroyed,je as isDevEnvironment,ome as isDisposed,OSe as isExporting,aU as isHostedOnGlitch,pSe as isHotReloading,Aie as isIPad,ej as isIconElement,io as isLocalNetwork,Sie as isMacOS,bie as isMobileDevice,_ie as isMozillaXR,Eie as isQuest,A9 as isResourceTrackingEnabled,Mie as isSafari,pC as isUsingInstancing,Cie as isiOS,xie as isiPad,DG as loadSync,P_ as logHierarchy,boe as lookAtInverse,Zv as lookAtObject,mie as makeId,uU as makeIdFromRandomWords,Ul as makeNameSafeForUSD,p4 as markAsInstancedRendered,Tie as microphonePermissionsGranted,die as nameof,lU as nameofFactory,cQ as objectSerializer,rue as offXRSessionEnd,sue as offXRSessionStart,C0e as onAfterRender,oQ as onBeforeRender,_0e as onClear,S0e as onDestroy,w0e as onInitialized,oO as onStart,aO as onUpdate,WP as onXRSessionEnd,ES as onXRSessionStart,oK as parseSync,N5 as placeOnSurface,fL as postprocessFBXMaterials,E0e as prefix,cU as pushState,fie as randomNumber,JP as registerBinaryType,GC as registerComponent,BM as registerComponentExtension,Ja as registerCustomEffectType,iD as registerExportExtensions,OM as registerExtensions,mSe as registerHotReloadType,pI as registerLoader,N9 as registerPrefabProvider,J9 as registerPrototypeExtensions,kme as registerType,mU as relativePathPrefix,gU as removeAttributeChangeCallback,rB as removeComponent,mbe as removeCustomImportExtensionType,oSe as removeGltfLoadEventListener,qle as removePatch,Qd as resolveUrl,pU as sanitizeString,zK as saveImage,BSe as screenshot,FK as screenshot2,jk as sendDestroyed,E as serializable,W9 as serializeObject,R0 as serializeable,lA as setActive,xU as setAllowBalloonMessages,Die as setAllowOverlayMessages,rL as setAutoFitEnabled,nL as setCameraController,f4 as setDestroyed,Goe as setDevEnvironment,Ok as setDisposable,m0 as setDontDestroy,gI as setOrAddParamsToUrl,pie as setParam,Uv as setParamWithoutReload,ipe as setPeerOptions,rme as setResourceTrackingEnabled,yI as setState,mL as setVisibleInCustomShadowRendering,uL as setWorldEuler,bs as setWorldPosition,nm as setWorldPositionXYZ,Ba as setWorldQuaternion,cL as setWorldQuaternionXYZW,pL as setWorldRotation,Kv as setWorldRotationXYZ,wg as setWorldScale,B_ as showBalloonError,gn as showBalloonMessage,Oi as showBalloonWarning,bL as showDebugConsole,voe as slerp,qb as syncDestroy,SO as syncField,Qk as syncInstantiate,Ioe as textureToCanvas,TW as tryCastBinary,tK as tryDetermineFileTypeFromBinary,eK as tryDetermineFileTypeFromURL,vg as tryFindObject,RW as tryGetGuid,fSe as unregisterHotReloadType,vI as unwatchWrite,M5 as useForAutoFit,rr as validate,m_ as watchWrite};
|