@needle-tools/engine 3.44.2 → 3.44.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+e.toString())}const n=aa()||qx()&&st();if((
4344
4344
  #__vconsole .vc-mask {
4345
4345
  overflow: hidden;
4346
4346
  }
4347
- `,ua?.prepend(r),n===!0&&MI()<=0&&lz(),console.log("\u{1F335} Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function ine(){const n=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+n._id+" iframe");return n.on("renderTab",function(t){const r=globalThis["needle:codegen_files"];if(!r||r.length===0)return;let s=globalThis["needle:codegen_files"][0];const o=s.indexOf("?");o>-1&&(s=s.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+s,l=encodeURIComponent(a);n.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),n.on("show",function(){const t=e();t&&t.src!==n.fullUrl&&(t.src=n.fullUrl)}),n.on("hide",function(){const t=e();t&&(t.src="")}),n.on("addTopBar",function(t){var r=new Array;r.push({name:"Open in new window \u2197",onClick:function(s){window.open(n.fullUrl,"_blank"),ha?.hide()}}),r.push({name:"Reload",onClick:function(s){const o=e();o&&(o.src=n.fullUrl)}}),r.push({name:"Fullscreen",onClick:function(s){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(r)}),n}function nne(){return document.querySelector("#__vconsole .vc-switch")||null}function rne(){return document.querySelector("#__vconsole")||null}const dz=te("debugdefines");jf('if(!globalThis[""3.44.2""]) globalThis[""3.44.2""] = "0.0.0";'),jf('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),jf('if(!globalThis[""Fri Jul 05 2024 15:23:54 GMT+0200 (Central European Summer Time)""]) globalThis[""Fri Jul 05 2024 15:23:54 GMT+0200 (Central European Summer Time)""] = "unknown";'),jf('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.44.2";'),jf('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),jf('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Jul 05 2024 15:23:54 GMT+0200 (Central European Summer Time)";');const Za="3.44.2",mw="undefined",ER="Fri Jul 05 2024 15:23:54 GMT+0200 (Central European Summer Time)";dz&&console.log(`Engine version: ${Za} (generator: ${mw})
4347
+ `,ua?.prepend(r),n===!0&&MI()<=0&&lz(),console.log("\u{1F335} Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function ine(){const n=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+n._id+" iframe");return n.on("renderTab",function(t){const r=globalThis["needle:codegen_files"];if(!r||r.length===0)return;let s=globalThis["needle:codegen_files"][0];const o=s.indexOf("?");o>-1&&(s=s.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+s,l=encodeURIComponent(a);n.fullUrl="https://viewer.needle.tools?inspect&file="+l;var c='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(c)}),n.on("show",function(){const t=e();t&&t.src!==n.fullUrl&&(t.src=n.fullUrl)}),n.on("hide",function(){const t=e();t&&(t.src="")}),n.on("addTopBar",function(t){var r=new Array;r.push({name:"Open in new window \u2197",onClick:function(s){window.open(n.fullUrl,"_blank"),ha?.hide()}}),r.push({name:"Reload",onClick:function(s){const o=e();o&&(o.src=n.fullUrl)}}),r.push({name:"Fullscreen",onClick:function(s){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(r)}),n}function nne(){return document.querySelector("#__vconsole .vc-switch")||null}function rne(){return document.querySelector("#__vconsole")||null}const dz=te("debugdefines");jf('if(!globalThis[""3.44.3""]) globalThis[""3.44.3""] = "0.0.0";'),jf('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),jf('if(!globalThis[""Fri Jul 05 2024 19:08:58 GMT+0200 (Central European Summer Time)""]) globalThis[""Fri Jul 05 2024 19:08:58 GMT+0200 (Central European Summer Time)""] = "unknown";'),jf('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.44.3";'),jf('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),jf('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Jul 05 2024 19:08:58 GMT+0200 (Central European Summer Time)";');const Za="3.44.3",mw="undefined",ER="Fri Jul 05 2024 19:08:58 GMT+0200 (Central European Summer Time)";dz&&console.log(`Engine version: ${Za} (generator: ${mw})
4348
4348
  Project built at ${ER}`);const Jc="needle_isActiveInHierarchy",bp="builtin_components",Kv="needle_editor_guid";function jf(n){try{(0,eval)(n)}catch(e){dz&&console.error(e)}}const sne='<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>',one=btoa(sne),ane="data:image/svg+xml;base64,"+one,lne=ane,cne=`<?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(cne);const hne='<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>',une=btoa(hne),dne="data:image/svg+xml;charset=utf-8;base64,"+une,pne=dne,da=te("debuglicense");let _p="basic";da&&console.log("License Type: "+_p);function cu(){switch(_p){case"pro":case"enterprise":return!0}return!1}function MR(){switch(_p){case"indie":return!0}return!1}function Kc(){return cu()||MR()}const pz=[];function mne(n){if(cu()||MR())return n(!0);pz.push(n)}function fne(n){for(const e of pz)try{e(n)}catch{}}ui.registerCallback(Si.ContextRegistered,n=>{yne(n.context),bne(),vne(n.context)});let xp,TR=!1,fw="";async function gne(){if(xp)return xp;if(_p==="basic")try{const n="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Za+"&generator="+encodeURIComponent(mw),e=await fetch(n,{method:"GET"}).catch(t=>{da&&console.error("License check failed",t)});e?.status===200?(TR=!1,da&&console.log("License check succeeded"),_p="pro",fne(!0)):e?.status===403?(TR=!0,fw=await e.text()):da&&console.log("License check failed with status "+e?.status)}catch(n){da&&console.error("License check failed",n)}else da&&console.log('Runtime license check is skipped because license is already applied as "'+_p+'"')}xp=gne();async function vne(n){function e(){const s=document.createElement("div");s.className="needle-forbidden",s.style.cssText=`
4349
4349
  position: fixed;
4350
4350
  top: 0;
@@ -5668,7 +5668,7 @@ Could not find method ${u.method} on object ${m.name}. Please rename ${u.method}
5668
5668
  `,m[_],`
5669
5669
  in script: `,m),ki("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
5670
5670
  Could not find method ${u.method} on object ${m.name}`,m,typeof m[u.method])};if(typeof m[u.method]!="function"){let _=!1,b=m;for(;b;){const x=Object.getOwnPropertyDescriptor(b,u.method);if(x&&(x.writable===!0||x.set)){_=!0;break}b=Object.getPrototypeOf(b)}!_&&(st()||wr)&&y()}}let g=u.argument;g!==void 0?g=p(g):u.arguments!==void 0&&(g=u.arguments.map(p));const v=f?this.createEventMethod(m,u.method,g):void 0,A=new Hg(v,u.enabled);if(A.method||(A[vpe]=(a=t.object)==null?void 0:a.name),!m||!A.method){const y=t.object?"Current object: "+t.object.name+", "+t.object.guid:null;m?console.warn('EventList method not found: "'+u.method+'" on',m):console.warn("EventList is missing target - will be ignored",u.target,y,e)}else l.push(A)}const c=new Un(l);wr&&console.log(c);const h=t.target;return h!==void 0&&t.path!==void 0&&c.setEventTarget(t.path,h),c}}createEventMethod(e,t,r){return(...s)=>{const o=e[t];typeof o=="function"?r!==void 0?Array.isArray(r)?o?.call(e,...r):o?.call(e,r):o?.call(e,...s):e[t]=r}}}const Ape=new ype;class rQ extends ul{constructor(){super([Wg,Wt])}onSerialize(e,t){}onDeserialize(e,t){if(e instanceof zt&&t.type===Wg){const r=e,s=new Wg(r.image.width,r.image.height,{colorSpace:Ti});return s.texture=r,r.isRenderTargetTexture=!0,r.flipY=!0,r.offset.y=1,r.repeat.y=-1,r.needsUpdate=!0,r.mipmaps=[],r instanceof nu&&(r.isCompressedTexture=!1,r.format=RGBAFormat),s}}}new rQ;class sQ extends ul{constructor(){super([URL])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"&&e.length>0)return ou(t.gltfId,e)}}new sQ;const oQ={type:"change"},tD={type:"start"},aQ={type:"end"},ES=new lo,lQ=new Us,bpe=Math.cos(70*hi.DEG2RAD);let cQ=class extends mr{constructor(n,e){super(),this.object=n,this.domElement=e,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new C,this.cursor=new C,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Pd.ROTATE,MIDDLE:Pd.DOLLY,RIGHT:Pd.PAN},this.touches={ONE:Bd.ROTATE,TWO:Bd.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(S){S.addEventListener("keydown",ht),this._domElementKeyEvents=S},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ht),this._domElementKeyEvents=null},this.saveState=function(){t.target0.copy(t.target),t.position0.copy(t.object.position),t.zoom0=t.object.zoom},this.reset=function(){t.target.copy(t.target0),t.object.position.copy(t.position0),t.object.zoom=t.zoom0,t.object.updateProjectionMatrix(),t.dispatchEvent(oQ),t.update(),s=r.NONE},this.update=function(){const S=new C,B=new Ce().setFromUnitVectors(n.up,new C(0,1,0)),j=B.clone().invert(),ee=new C,N=new Ce,J=new C,W=2*Math.PI;return function(ae=null){const ce=t.object.getWorldPosition(n.position);S.copy(ce).sub(t.target),S.applyQuaternion(B),a.setFromVector3(S),t.autoRotate&&s===r.NONE&&z(M(ae)),t.enableDamping?(a.theta+=l.theta*t.dampingFactor,a.phi+=l.phi*t.dampingFactor):(a.theta+=l.theta,a.phi+=l.phi);let _e=t.minAzimuthAngle,Re=t.maxAzimuthAngle;isFinite(_e)&&isFinite(Re)&&(_e<-Math.PI?_e+=W:_e>Math.PI&&(_e-=W),Re<-Math.PI?Re+=W:Re>Math.PI&&(Re-=W),_e<=Re?a.theta=Math.max(_e,Math.min(Re,a.theta)):a.theta=a.theta>(_e+Re)/2?Math.max(_e,a.theta):Math.min(Re,a.theta)),a.phi=Math.max(t.minPolarAngle,Math.min(t.maxPolarAngle,a.phi)),a.makeSafe(),t.enableDamping===!0?t.target.addScaledVector(u,t.dampingFactor):t.target.add(u),t.target.sub(t.cursor),t.target.clampLength(t.minTargetRadius,t.maxTargetRadius),t.target.add(t.cursor);let Xe=!1;if(t.zoomToCursor&&I||t.object.isOrthographicCamera)a.radius=K(a.radius);else{t.enableDamping?h=hi.lerp(h,c,t.dampingFactor):h=c,a.radius=K(a.radius*h);const We=a.radius;a.radius=K(a.radius*c),Xe=We!=a.radius}if(S.setFromSpherical(a),S.applyQuaternion(j),ce.copy(t.target).add(S),t.object.parent?t.object.parent.worldToLocal(ce):t.object.position.copy(ce),t.object.lookAt(t.target),t.enableDamping===!0?(l.theta*=1-t.dampingFactor,l.phi*=1-t.dampingFactor,u.multiplyScalar(1-t.dampingFactor)):(l.set(0,0,0),u.set(0,0,0)),t.zoomToCursor&&I){let We=null;if(t.object.isPerspectiveCamera){const Ke=S.length();We=K(Ke*c);const gt=Ke-We;t.object.position.addScaledVector(x,gt),t.object.updateMatrixWorld(),Xe=!!gt}else if(t.object.isOrthographicCamera){const Ke=new C(E.x,E.y,0);Ke.unproject(t.object);const gt=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/c)),t.object.updateProjectionMatrix(),Xe=gt!==t.object.zoom;const rt=new C(E.x,E.y,0);rt.unproject(t.object),t.object.position.sub(rt).add(Ke),t.object.updateMatrixWorld(),We=S.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),t.zoomToCursor=!1;We!==null&&(this.screenSpacePanning?t.target.set(0,0,-1).transformDirection(t.object.matrix).multiplyScalar(We).add(t.object.position):(ES.origin.copy(t.object.position),ES.direction.set(0,0,-1).transformDirection(t.object.matrix),Math.abs(t.object.up.dot(ES.direction))<bpe?n.lookAt(t.target):(lQ.setFromNormalAndCoplanarPoint(t.object.up,t.target),ES.intersectPlane(lQ,t.target))))}else if(t.object.isOrthographicCamera){const We=t.object.zoom;t.object.zoom=Math.max(t.minZoom,Math.min(t.maxZoom,t.object.zoom/c)),We!==t.object.zoom&&(t.object.updateProjectionMatrix(),Xe=!0)}return c=1,I=!1,Xe||ee.distanceToSquared(t.object.position)>o||8*(1-N.dot(t.object.quaternion))>o||J.distanceToSquared(t.target)>o?(t.dispatchEvent(oQ),ee.copy(t.object.position),N.copy(t.object.quaternion),J.copy(t.target),!0):!1}}(),this.dispose=function(){t.domElement.removeEventListener("contextmenu",wt),t.domElement.removeEventListener("pointerdown",ct),t.domElement.removeEventListener("pointercancel",V),t.domElement.removeEventListener("wheel",Ee),t.domElement.removeEventListener("pointermove",Tt),window.removeEventListener("pointerup",V),t.domElement.getRootNode().removeEventListener("keydown",Pe,{capture:!0}),t._domElementKeyEvents!==null&&(t._domElementKeyEvents.removeEventListener("keydown",ht),t._domElementKeyEvents=null)};const t=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let s=r.NONE;const o=1e-6,a=new uI,l=new uI;let c=1,h=1;const u=new C,p=new Z,m=new Z,f=new Z,g=new Z,v=new Z,A=new Z,y=new Z,_=new Z,b=new Z,x=new C,E=new Z;let I=!1;const T=[],R={};let k=!1;function M(S){return S!==null?2*Math.PI/60*t.autoRotateSpeed*S:2*Math.PI/60/60*t.autoRotateSpeed}function P(S){const B=Math.abs(S*.01);return Math.pow(.95,t.zoomSpeed*B)}function z(S){l.theta-=S}function Q(S){l.phi-=S}const L=function(){const S=new C;return function(B,j){S.setFromMatrixColumn(j,0),S.multiplyScalar(-B),u.add(S)}}(),H=function(){const S=new C;return function(B,j){t.screenSpacePanning===!0?S.setFromMatrixColumn(j,1):(S.setFromMatrixColumn(j,0),S.crossVectors(t.object.up,S)),S.multiplyScalar(B),u.add(S)}}(),O=function(){const S=new C,B=new C;return function(j,ee){const N=t.domElement;if(t.object.isPerspectiveCamera){t.object.getWorldPosition(B),S.copy(B).sub(t.target);let J=S.length();J*=Math.tan(t.object.fov/2*Math.PI/180),L(2*j*J/N.clientHeight,t.object.matrixWorld),H(2*ee*J/N.clientHeight,t.object.matrixWorld)}else t.object.isOrthographicCamera?(L(j*(t.object.right-t.object.left)/t.object.zoom/N.clientWidth,t.object.matrixWorld),H(ee*(t.object.top-t.object.bottom)/t.object.zoom/N.clientHeight,t.object.matrixWorld)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),t.enablePan=!1)}}();function F(S){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c/=S:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function G(S){t.object.isPerspectiveCamera||t.object.isOrthographicCamera?c*=S:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),t.enableZoom=!1)}function Y(S,B){if(!t.zoomToCursor)return;I=!0;const j=t.domElement.getBoundingClientRect(),ee=S-j.left,N=B-j.top,J=j.width,W=j.height;E.x=ee/J*2-1,E.y=-(N/W)*2+1,x.set(E.x,E.y,1).unproject(t.object).sub(t.object.position).normalize()}function K(S){return Math.max(t.minDistance,Math.min(t.maxDistance,S))}function oe(S){p.set(S.clientX,S.clientY)}function we(S){Y(S.clientX,S.clientX),y.set(S.clientX,S.clientY)}function ke(S){g.set(S.clientX,S.clientY)}function se(S){m.set(S.clientX,S.clientY),f.subVectors(m,p).multiplyScalar(t.rotateSpeed);const B=t.domElement;z(2*Math.PI*f.x/B.clientHeight),Q(2*Math.PI*f.y/B.clientHeight),p.copy(m),t.update()}function be(S){_.set(S.clientX,S.clientY),b.subVectors(_,y),b.y>0?F(P(b.y)):b.y<0&&G(P(b.y)),y.copy(_),t.update()}function Ie(S){v.set(S.clientX,S.clientY),A.subVectors(v,g).multiplyScalar(t.panSpeed),O(A.x,A.y),g.copy(v),t.update()}function Je(S){Y(S.clientX,S.clientY),S.deltaY<0?G(P(S.deltaY)):S.deltaY>0&&F(P(S.deltaY)),t.update()}function $e(S){let B=!1;switch(S.code){case t.keys.UP:S.ctrlKey||S.metaKey||S.shiftKey?Q(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):O(0,t.keyPanSpeed),B=!0;break;case t.keys.BOTTOM:S.ctrlKey||S.metaKey||S.shiftKey?Q(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):O(0,-t.keyPanSpeed),B=!0;break;case t.keys.LEFT:S.ctrlKey||S.metaKey||S.shiftKey?z(2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):O(t.keyPanSpeed,0),B=!0;break;case t.keys.RIGHT:S.ctrlKey||S.metaKey||S.shiftKey?z(-2*Math.PI*t.rotateSpeed/t.domElement.clientHeight):O(-t.keyPanSpeed,0),B=!0;break}B&&(S.preventDefault(),t.update())}function Oe(S){if(T.length===1)p.set(S.pageX,S.pageY);else{const B=ut(S),j=.5*(S.pageX+B.x),ee=.5*(S.pageY+B.y);p.set(j,ee)}}function lt(S){if(T.length===1)g.set(S.pageX,S.pageY);else{const B=ut(S),j=.5*(S.pageX+B.x),ee=.5*(S.pageY+B.y);g.set(j,ee)}}function fe(S){const B=ut(S),j=S.pageX-B.x,ee=S.pageY-B.y,N=Math.sqrt(j*j+ee*ee);y.set(0,N)}function X(S){t.enableZoom&&fe(S),t.enablePan&&lt(S)}function ze(S){t.enableZoom&&fe(S),t.enableRotate&&Oe(S)}function Te(S){if(T.length==1)m.set(S.pageX,S.pageY);else{const j=ut(S),ee=.5*(S.pageX+j.x),N=.5*(S.pageY+j.y);m.set(ee,N)}f.subVectors(m,p).multiplyScalar(t.rotateSpeed);const B=t.domElement;z(2*Math.PI*f.x/B.clientHeight),Q(2*Math.PI*f.y/B.clientHeight),p.copy(m)}function Me(S){if(T.length===1)v.set(S.pageX,S.pageY);else{const B=ut(S),j=.5*(S.pageX+B.x),ee=.5*(S.pageY+B.y);v.set(j,ee)}A.subVectors(v,g).multiplyScalar(t.panSpeed),O(A.x,A.y),g.copy(v)}function Ve(S){const B=ut(S),j=S.pageX-B.x,ee=S.pageY-B.y,N=Math.sqrt(j*j+ee*ee);_.set(0,N),b.set(0,Math.pow(_.y/y.y,t.zoomSpeed)),F(b.y),y.copy(_);const J=(S.pageX+B.x)*.5,W=(S.pageY+B.y)*.5;Y(J,W)}function ye(S){t.enableZoom&&Ve(S),t.enablePan&&Me(S)}function et(S){t.enableZoom&&Ve(S),t.enableRotate&&Te(S)}function ct(S){t.enabled!==!1&&(T.length===0&&(t.domElement.setPointerCapture(S.pointerId),t.domElement.addEventListener("pointermove",Tt),window.addEventListener("pointerup",V)),!Fe(S)&&(Ue(S),S.pointerType==="touch"?je(S):D(S)))}function Tt(S){t.enabled!==!1&&(S.pointerType==="touch"?Qe(S):he(S))}function V(S){switch(qt(S),T.length){case 0:t.domElement.releasePointerCapture(S.pointerId),t.domElement.removeEventListener("pointermove",Tt),t.domElement.removeEventListener("pointerup",V),t.dispatchEvent(aQ),s=r.NONE;break;case 1:const B=T[0],j=R[B];je({pointerId:B,pageX:j.x,pageY:j.y});break}}function D(S){let B;switch(S.button){case 0:B=t.mouseButtons.LEFT;break;case 1:B=t.mouseButtons.MIDDLE;break;case 2:B=t.mouseButtons.RIGHT;break;default:B=-1}switch(B){case Pd.DOLLY:if(t.enableZoom===!1)return;we(S),s=r.DOLLY;break;case Pd.ROTATE:if(S.ctrlKey||S.metaKey||S.shiftKey){if(t.enablePan===!1)return;ke(S),s=r.PAN}else{if(t.enableRotate===!1)return;oe(S),s=r.ROTATE}break;case Pd.PAN:if(S.ctrlKey||S.metaKey||S.shiftKey){if(t.enableRotate===!1)return;oe(S),s=r.ROTATE}else{if(t.enablePan===!1)return;ke(S),s=r.PAN}break;default:s=r.NONE}s!==r.NONE&&t.dispatchEvent(tD)}function he(S){switch(s){case r.ROTATE:if(t.enableRotate===!1)return;se(S);break;case r.DOLLY:if(t.enableZoom===!1)return;be(S);break;case r.PAN:if(t.enablePan===!1)return;Ie(S);break}}function Ee(S){t.enabled===!1||t.enableZoom===!1||s!==r.NONE||(S.preventDefault(),t.dispatchEvent(tD),Je(Le(S)),t.dispatchEvent(aQ))}function Le(S){const B=S.deltaMode,j={clientX:S.clientX,clientY:S.clientY,deltaY:S.deltaY};switch(B){case 1:j.deltaY*=16;break;case 2:j.deltaY*=100;break}return S.ctrlKey&&!k&&(j.deltaY*=10),j}function Pe(S){S.key==="Control"&&(k=!0,t.domElement.getRootNode().addEventListener("keyup",vt,{passive:!0,capture:!0}))}function vt(S){S.key==="Control"&&(k=!1,t.domElement.getRootNode().removeEventListener("keyup",vt,{passive:!0,capture:!0}))}function ht(S){t.enabled===!1||t.enablePan===!1||$e(S)}function je(S){switch(_t(S),T.length){case 1:switch(t.touches.ONE){case Bd.ROTATE:if(t.enableRotate===!1)return;Oe(S),s=r.TOUCH_ROTATE;break;case Bd.PAN:if(t.enablePan===!1)return;lt(S),s=r.TOUCH_PAN;break;default:s=r.NONE}break;case 2:switch(t.touches.TWO){case Bd.DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;X(S),s=r.TOUCH_DOLLY_PAN;break;case Bd.DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;ze(S),s=r.TOUCH_DOLLY_ROTATE;break;default:s=r.NONE}break;default:s=r.NONE}s!==r.NONE&&t.dispatchEvent(tD)}function Qe(S){switch(_t(S),s){case r.TOUCH_ROTATE:if(t.enableRotate===!1)return;Te(S),t.update();break;case r.TOUCH_PAN:if(t.enablePan===!1)return;Me(S),t.update();break;case r.TOUCH_DOLLY_PAN:if(t.enableZoom===!1&&t.enablePan===!1)return;ye(S),t.update();break;case r.TOUCH_DOLLY_ROTATE:if(t.enableZoom===!1&&t.enableRotate===!1)return;et(S),t.update();break;default:s=r.NONE}}function wt(S){t.enabled!==!1&&S.preventDefault()}function Ue(S){T.push(S.pointerId)}function qt(S){delete R[S.pointerId];for(let B=0;B<T.length;B++)if(T[B]==S.pointerId){T.splice(B,1);return}}function Fe(S){for(let B=0;B<T.length;B++)if(T[B]==S.pointerId)return!0;return!1}function _t(S){let B=R[S.pointerId];B===void 0&&(B=new Z,R[S.pointerId]=B),B.set(S.pageX,S.pageY)}function ut(S){const B=S.pointerId===T[0]?T[1]:T[0];return R[B]}t.domElement.addEventListener("contextmenu",wt),t.domElement.addEventListener("pointerdown",ct),t.domElement.addEventListener("pointercancel",V),t.domElement.addEventListener("wheel",Ee,{passive:!1}),t.domElement.getRootNode().addEventListener("keydown",Pe,{passive:!0,capture:!0}),this.update()}};var _pe=Object.defineProperty,xpe=Object.getOwnPropertyDescriptor,iD=(n,e,t,r)=>{for(var s=r>1?void 0:r?xpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&_pe(e,t,s),s};class tm extends Be{constructor(){super(...arguments),d(this,"constraintActive",!0),d(this,"locked",!1),d(this,"sources",[])}}iD([w()],tm.prototype,"constraintActive",2),iD([w()],tm.prototype,"locked",2),iD([w(Ae)],tm.prototype,"sources",2);function wpe(n,e){return Uu(n,Si.ContextCreated,e),()=>Nu(n,Si.ContextCreated)}function Spe(n,e){return Uu(n,Si.ContextClearing,e),()=>Nu(n,Si.ContextClearing)}function Cpe(n,e){return Uu(n,Si.ContextDestroying,e),()=>Nu(n,Si.ContextDestroying)}function hQ(n,e){return Uu(n,Hi.Start,e),()=>Nu(n,Hi.Start)}function uQ(n,e){return Uu(n,Hi.Update,e),()=>Nu(n,Hi.Update)}function Epe(n,e){return Uu(n,Hi.OnBeforeRender,e),()=>Nu(n,Hi.OnBeforeRender)}function Mpe(n,e){return Uu(n,Hi.OnAfterRender,e),()=>Nu(n,Hi.OnAfterRender)}class im{constructor(){d(this,"bb",null),d(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}static sizeOf(){return 12}static createVec3(e,t,r,s){return e.prep(4,12),e.writeFloat32(s),e.writeFloat32(r),e.writeFloat32(t),e.offset()}}class dQ{constructor(){d(this,"bb",null),d(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}position(e){return(e||new im).__init(this.bb_pos,this.bb)}rotation(e){return(e||new im).__init(this.bb_pos+12,this.bb)}scale(e){return(e||new im).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(e,t,r,s,o,a,l,c,h,u){return e.prep(4,36),e.prep(4,12),e.writeFloat32(u),e.writeFloat32(h),e.writeFloat32(c),e.prep(4,12),e.writeFloat32(l),e.writeFloat32(a),e.writeFloat32(o),e.prep(4,12),e.writeFloat32(s),e.writeFloat32(r),e.writeFloat32(t),e.offset()}}class Nh{constructor(){d(this,"bb",null),d(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSyncedTransformModel(e,t){return(t||new Nh).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSyncedTransformModel(e,t){return e.setPosition(e.position()+fB),(t||new Nh).__init(e.readInt32(e.position())+e.position(),e)}guid(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}fast(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}transform(e){const t=this.bb.__offset(this.bb_pos,8);return t?(e||new dQ).__init(this.bb_pos+t,this.bb):null}dontSave(){const e=this.bb.__offset(this.bb_pos,10);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startSyncedTransformModel(e){e.startObject(4)}static addGuid(e,t){e.addFieldOffset(0,t,0)}static addFast(e,t){e.addFieldInt8(1,+t,0)}static addTransform(e,t){e.addFieldStruct(2,t,0)}static addDontSave(e,t){e.addFieldInt8(3,+t,0)}static endSyncedTransformModel(e){return e.endObject()}static finishSyncedTransformModelBuffer(e,t){e.finish(t)}static finishSizePrefixedSyncedTransformModelBuffer(e,t){e.finish(t,void 0,!0)}}var Er=(n=>(n[n.Average=0]="Average",n[n.Multiply=1]="Multiply",n[n.Minimum=2]="Minimum",n[n.Maximum=3]="Maximum",n))(Er||{}),MS=(n=>(n[n.Discrete=0]="Discrete",n[n.Continuous=1]="Continuous",n))(MS||{}),Nn=(n=>(n[n.None=0]="None",n[n.FreezePositionX=2]="FreezePositionX",n[n.FreezePositionY=4]="FreezePositionY",n[n.FreezePositionZ=8]="FreezePositionZ",n[n.FreezePosition=14]="FreezePosition",n[n.FreezeRotationX=16]="FreezeRotationX",n[n.FreezeRotationY=32]="FreezeRotationY",n[n.FreezeRotationZ=64]="FreezeRotationZ",n[n.FreezeRotation=112]="FreezeRotation",n[n.FreezeAll=126]="FreezeAll",n))(Nn||{}),Xg=(n=>(n[n.None=0]="None",n[n.X=2]="X",n[n.Y=4]="Y",n[n.Z=8]="Z",n[n.All=-1]="All",n))(Xg||{});const Hr=function(n,e){return function(t,r,s){Tpe(t,r,s,n,e)}};function Tpe(n,e,t,r,s){if(!s&&!r&&!n.onValidate)return;if(t!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",n,e,t),rn("Invalid usage of validate decorator. Only fields can be validated. Property: "+e,Bo.Error);return}let o="";if(typeof e=="string"?o=e:o=e.name,n.__internalAwake){const a=Symbol(o),l=n.__internalAwake;n.__internalAwake=function(){var c;if(!this.onValidate){st()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((c=n.constructor)==null?void 0:c.name)+'"');return}if(this[a]===void 0){this[a]=this[o];const h=this[o];if(h instanceof Z||h instanceof C||h instanceof Ye||h instanceof Ce){const u=this[o];Wx(u,()=>{this.onValidate(o)})}Object.defineProperty(this,o,{set:function(u){var p;if(this[nB]===!0)this[a]=u;else{r?.call(this,u);const m=this[a];this[a]=u,(p=this.onValidate)==null||p.call(this,o,m)}},get:function(){return s?.call(this),this[a]}})}l.call(this)}}}const Ipe=function(n){return function(e,t,r){let s="";typeof t=="string"?s=t:s=t.name;const o=n.prototype,a=Object.getOwnPropertyDescriptor(o,s);if(!(a!=null&&a.value)){console.warn("Can not apply prefix: type does not have method named",t,n);return}const l=a.value,c=e[s];Object.defineProperty(o,s,{value:function(...h){const u=c?.call(this,...h);if(u instanceof Promise){u.then(p=>{if(p!==!1)return l.call(this,...h)});return}if(u!==!1)return l.call(this,...h)}})}};var Rpe=Object.defineProperty,Ppe=Object.getOwnPropertyDescriptor,Uo=(n,e,t,r)=>{for(var s=r>1?void 0:r?Ppe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Rpe(e,t,s),s};class Bpe{constructor(e,t){d(this,"positionChanged",!1),d(this,"rotationChanged",!1),d(this,"position"),d(this,"quaternion"),d(this,"_positionKeys",["x","y","z"]),d(this,"_quaternionKeys",["_x","_y","_z","_w"]),d(this,"mute",!1),d(this,"context"),d(this,"obj"),d(this,"_positionWatch"),d(this,"_rotationWatch"),this.context=t,this.obj=e}get isDirty(){return this.positionChanged||this.rotationChanged}reset(e=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,e){if(this.position)for(const t of this._positionKeys)delete this.position[t];if(this.quaternion)for(const t of this._quaternionKeys)delete this.quaternion[t]}}syncValues(){for(const e of this._positionKeys)this.position[e]=this.obj.position[e];for(const e of this._quaternionKeys)this.quaternion[e]=this.obj.quaternion[e]}applyValues(){if(this.positionChanged&&this.position)for(const e of this._positionKeys){const t=this.position[e];t!==void 0&&(this.obj.position[e]=t)}if(this.rotationChanged&&this.quaternion)for(const e of this._quaternionKeys){const t=this.quaternion[e];t!==void 0&&(this.obj.quaternion[e]=t)}}start(e,t){this.reset(),e&&(this._positionWatch||(this._positionWatch=new Oh(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((o,a)=>{var l;if((l=this.context.physics.engine)!=null&&l.isUpdating||this.mute)return;const c=this.position[a];Math.abs(c-o)<1e-5||(this.position[a]=o,this.positionChanged=!0)})),t&&(this._rotationWatch||(this._rotationWatch=new Oh(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((o,a)=>{var l;if((l=this.context.physics.engine)!=null&&l.isUpdating||this.mute)return;const c=this.quaternion[a];Math.abs(c-o)<1e-5||(this.quaternion[a]=o,this.rotationChanged=!0)}));const r=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),s=new ve;this.obj.matrixWorld.multiplyMatrices=(o,a)=>{var l;return(l=this.context.physics.engine)!=null&&l.isUpdating||this.mute||s.equals(o)||(this.positionChanged=!0,this.rotationChanged=!0,s.copy(o)),r(o,a)}}stop(){var e,t;(e=this._positionWatch)==null||e.revoke(),(t=this._rotationWatch)==null||t.revoke()}}var nD;const rD=(nD=class extends Be{constructor(){super(...arguments),d(this,"autoMass",!0),d(this,"_mass",0),d(this,"useGravity",!0),d(this,"centerOfMass",new C(0,0,0)),d(this,"constraints",Nn.None),d(this,"isKinematic",!1),d(this,"drag",0),d(this,"angularDrag",1),d(this,"detectCollisions",!0),d(this,"sleepThreshold",.01),d(this,"collisionDetectionMode",MS.Discrete),d(this,"_gravityScale",1),d(this,"dominanceGroup",0),d(this,"_propertiesChanged",!1),d(this,"_currentVelocity",new C),d(this,"_smoothedVelocity",new C),d(this,"_smoothedVelocityGetter",new C),d(this,"_lastPosition",new C),d(this,"_watch")}set mass(n){n!==this._mass&&(this._mass=n,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var n,e;return this.autoMass?((e=(n=this.context.physics.engine)==null?void 0:n.getBody(this))==null?void 0:e.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&Nn.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&Nn.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&Nn.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&Nn.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&Nn.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&Nn.FreezeRotationZ)!==0}set lockPositionX(n){n?this.constraints|=Nn.FreezePositionX:this.constraints&=~Nn.FreezePositionX}set lockPositionY(n){n?this.constraints|=Nn.FreezePositionY:this.constraints&=~Nn.FreezePositionY}set lockPositionZ(n){n?this.constraints|=Nn.FreezePositionZ:this.constraints&=~Nn.FreezePositionZ}set lockRotationX(n){n?this.constraints|=Nn.FreezeRotationX:this.constraints&=~Nn.FreezeRotationX}set lockRotationY(n){n?this.constraints|=Nn.FreezeRotationY:this.constraints&=~Nn.FreezeRotationY}set lockRotationZ(n){n?this.constraints|=Nn.FreezeRotationZ:this.constraints&=~Nn.FreezeRotationZ}set gravityScale(n){this._gravityScale=n}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new Bpe(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),Hi.LateUpdate)}onDisable(){var n,e;(n=this._watch)==null||n.stop(),(e=this.context.physics.engine)==null||e.removeBody(this)}onDestroy(){var n;(n=this.context.physics.engine)==null||n.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){for(var n,e,t,r;;)this._propertiesChanged&&(this._propertiesChanged=!1,(n=this.context.physics.engine)==null||n.updateProperties(this)),(e=this._watch)!=null&&e.isDirty?(this._watch.mute=!0,this._watch.applyValues(),(t=this.context.physics.engine)==null||t.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):(r=this._watch)==null||r.syncValues(),this.captureVelocity(),yield}teleport(n,e=!0){var t;(t=this._watch)==null||t.reset(!0),e?this.gameObject.position.set(n.x,n.y,n.z):this.setWorldPosition(n.x,n.y,n.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(n=!0){var e;(e=this.context.physics.engine)==null||e.resetForces(this,n)}resetTorques(n=!0){var e;(e=this.context.physics.engine)==null||e.resetTorques(this,n)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var n;(n=this.context.physics.engine)==null||n.wakeup(this)}get isSleeping(){var n;return(n=this.context.physics.engine)==null?void 0:n.isSleeping(this)}updateProperties(){var n;return this._propertiesChanged=!1,(n=this.context.physics.engine)==null?void 0:n.updateProperties(this)}applyForce(n,e,t=!0){var r;this._propertiesChanged&&this.updateProperties(),(r=this.context.physics.engine)==null||r.addForce(this,n,t)}applyImpulse(n,e=!0){var t;this._propertiesChanged&&this.updateProperties(),(t=this.context.physics.engine)==null||t.applyImpulse(this,n,e)}setForce(n,e,t,r=!0){var s,o,a;(s=this.context.physics.engine)==null||s.resetForces(this,r),typeof n=="number"?(e??(e=0),t??(t=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:n,y:e,z:t},r)):(a=this.context.physics.engine)==null||a.addForce(this,n,r)}getVelocity(){var n;const e=(n=this.context.physics.engine)==null?void 0:n.getLinearVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(n,e,t,r=!0){var s,o;if(n instanceof C){const a=n;(s=this.context.physics.engine)==null||s.setLinearVelocity(this,a,r);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:n,y:e,z:t},r)}getAngularVelocity(){var n;const e=(n=this.context.physics.engine)==null?void 0:n.getAngularVelocity(this);return e?(this._currentVelocity.x=e.x,this._currentVelocity.y=e.y,this._currentVelocity.z=e.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(n,e,t,r=!0){var s,o;if(n instanceof C){const a=n;(s=this.context.physics.engine)==null||s.setAngularVelocity(this,a,r);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:n,y:e,z:t},r)}setTorque(n,e,t){this.setAngularVelocity(n,e,t)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(n=null){}captureVelocity(){const n=Bt(this.gameObject);rD.tempPosition.copy(n);const e=n.sub(this._lastPosition);this._lastPosition.copy(rD.tempPosition),this._smoothedVelocity.lerp(e,this.context.time.deltaTime/.1)}},d(nD,"tempPosition",new C),nD);let Oi=rD;Uo([Hr()],Oi.prototype,"autoMass",2),Uo([w()],Oi.prototype,"mass",1),Uo([Hr(),w()],Oi.prototype,"useGravity",2),Uo([w(C)],Oi.prototype,"centerOfMass",2),Uo([Hr(),w()],Oi.prototype,"constraints",2),Uo([Hr(),w()],Oi.prototype,"isKinematic",2),Uo([Hr(),w()],Oi.prototype,"drag",2),Uo([Hr(),w()],Oi.prototype,"angularDrag",2),Uo([Hr(),w()],Oi.prototype,"detectCollisions",2),Uo([Hr(),w()],Oi.prototype,"sleepThreshold",2),Uo([Hr(),w()],Oi.prototype,"collisionDetectionMode",2),Uo([Hr()],Oi.prototype,"_gravityScale",2),Uo([Hr()],Oi.prototype,"dominanceGroup",2);const qu=te("debugsync"),fA="STRS";yB(fA,Nh.getRootAsSyncedTransformModel);const Jl=new e_;function pQ(n,e,t=!0){Jl.clear();const r=Jl.createString(n);Nh.startSyncedTransformModel(Jl),Nh.addGuid(Jl,r),Nh.addFast(Jl,t);const s=e.worldPosition,o=e.worldEuler,a=e.gameObject.scale;Nh.addTransform(Jl,dQ.createTransform(Jl,s.x,s.y,s.z,o.x,o.y,o.z,a.x,a.y,a.z));const l=Nh.endSyncedTransformModel(Jl);return Jl.finish(l,fA),Jl.asUint8Array()}let sD=0,gA=0;uQ(n=>{var e;const t=(e=n.connection.currentServerUrl)!=null&&e.includes("glitch")?10:40;gA=Math.floor(sD/t),sD=0,qu&&gA>0&&console.log("Sync Transform Fast Interval",gA)});class Yu extends Be{constructor(){super(...arguments),d(this,"overridePhysics",!0),d(this,"interpolatePosition",!0),d(this,"interpolateRotation",!0),d(this,"fastMode",!1),d(this,"syncDestroy",!1),d(this,"_model",null),d(this,"_needsUpdate",!0),d(this,"rb",null),d(this,"_wasKinematic",!1),d(this,"_receivedDataBefore",!1),d(this,"_targetPosition"),d(this,"_targetRotation"),d(this,"_receivedFastUpdate",!1),d(this,"_shouldRequestOwnership",!1),d(this,"joinedRoomCallback",null),d(this,"receivedDataCallback",null),d(this,"tempEuler",new pi),d(this,"receivedUpdate",!1),d(this,"lastWorldPos"),d(this,"lastWorldRotation")}requestOwnership(){qu&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}hasOwnership(){var e;return((e=this._model)==null?void 0:e.hasOwnership)??void 0}isOwned(){var e;return(e=this._model)==null?void 0:e.isOwned}awake(){qu&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new C,this._targetRotation=new Ce,this.lastWorldPos=new C,this.lastWorldRotation=new Ce,this.rb=ie.getComponentInChildren(this.gameObject,Oi),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new LB(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(Qt.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(fA,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&qB(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(Qt.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(fA,this.receivedDataCallback)}tryGetLastState(){const e=this.context.connection.tryGetState(this.guid);e&&this.onReceivedData(e)}onReceivedData(e){var t;if(!this.destroyed&&typeof e.guid=="function"&&e.guid()===this.guid){qu&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const r=e.transform();if(r){ja.markDirty(this.gameObject,!0);const s=r.position();s&&(this.interpolatePosition&&((t=this._targetPosition)==null||t.set(s.x(),s.y(),s.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(s.x(),s.y(),s.z()));const o=r.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&yR(this.gameObject,this.tempEuler))}this._receivedDataBefore=!0}}onEnable(){this.lastWorldPos.copy(this.worldPosition),this.lastWorldRotation.copy(this.worldQuaternion),this._needsUpdate=!0,this._model&&this._model.updateIsOwned()}onDisable(){this._model&&this._model.freeOwnership()}onBeforeRender(){if(!this.activeAndEnabled||!this.context.connection.isConnected)return;if(!this.context.connection.isInRoom||!this._model){qu&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const e=this.worldPosition,t=this.worldQuaternion;if(this._model.isOwned&&!this.receivedUpdate){const o=e.distanceTo(this.lastWorldPos),a=t.angleTo(this.lastWorldRotation),l=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>l||a>l)&&(this._model.hasOwnership?this._needsUpdate=!0:(qu&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastWorldPos),this.worldPosition=this.lastWorldPos,e.copy(this.lastWorldPos),this.worldQuaternion=this.lastWorldRotation,t.copy(this.lastWorldRotation),ja.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const o=this._receivedFastUpdate||this.fastMode?.5:.3;let a=!1;if(this.interpolatePosition&&this._targetPosition){const l=this.worldPosition;l.lerp(this._targetPosition,o),this.worldPosition=l,a=!0}if(this.interpolateRotation&&this._targetRotation){const l=this.worldQuaternion;l.slerp(this._targetRotation,o),this.worldQuaternion=l,a=!0}a&&ja.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastWorldPos.copy(e),this.lastWorldRotation.copy(t),!this._model||!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership)return;this.rb&&this.overridePhysics&&this._wasKinematic!==void 0&&(qu&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const r=10,s=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%r===0||s)){if(sD++,s&&gA>0&&this.context.time.frameCount%gA!==0)return;qu&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const o=pQ(this.guid,this,!!s);this.context.connection.sendBinary(o)}}}const Dpe=te("debugshadowcomponents");sR.prototype.interactable={get(){return this.interactive},set(n){this.interactable=n}};const Ca=Symbol("shadowDomOwner");class za extends Be{constructor(){super(...arguments),d(this,"_shadowComponent",null),d(this,"_controlsChildLayout",!0),d(this,"_root"),d(this,"_parentComponent")}isRoot(){var e;return((e=this.Root)==null?void 0:e.gameObject)===this.gameObject}get canvas(){const e=this.Root;return e!=null&&e.isCanvas?e:null}get Canvas(){return this.canvas}markDirty(){Ea.markUIDirty(this.context)}get shadowComponent(){return this._shadowComponent}set shadowComponent(e){this._shadowComponent=e}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(e){this._controlsChildLayout=e,this.shadowComponent&&(this.shadowComponent.autoLayout=e)}get Root(){return this._root===void 0&&(this._root=ie.getComponentInParent(this.gameObject,vA)),this._root}__internalNewInstanceCreated(e){return super.__internalNewInstanceCreated(e),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0,this}onEnable(){super.onEnable()}addShadowComponent(e,t){var r;if(!e)return;this.removeShadowComponent();const s=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=ie.getComponentInParent(s,za),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`,this);return}e.name=this.name+" ("+(this.constructor.name??"UI")+")",e.autoLayout=this._parentComponent.controlsChildLayout,e[Ca]=this,this.setShadowComponentOwner(e);let o=!1;if(((r=this.Root)==null?void 0:r.gameObject)===this.gameObject)this.gameObject.add(e);else{const a=this._parentComponent.shadowComponent;a&&(a?.add(e),o=!0)}this.shadowComponent=e,t&&t.shadowComponent&&this.shadowComponent&&t.shadowComponent.add(this.shadowComponent),Gy&&e.add(new Po(.5)),this.onAfterAddedToScene(),o&&VN(),Dpe&&console.warn("Added shadow component",this.shadowComponent)}setShadowComponentOwner(e){if(e&&(e[Ca]===void 0||e[Ca]===this)&&(e[Ca]=this,e.children))for(const t of e.children)this.setShadowComponentOwner(t)}traverseOwnedShadowComponents(e,t,r){if(e&&e[Ca]===t){r(e);for(const s of e.children)this.traverseOwnedShadowComponents(s,t,r)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(e){this.shadowComponent&&(this.shadowComponent.interactable=e)}}class vA extends za{awake(){super.awake()}}class q0{constructor(e,t){d(this,"event"),d(this,"button"),d(this,"buttonName"),d(this,"_used",!1),d(this,"_propagationStopped",!1),d(this,"z__pointer_ctured",!1),d(this,"z__pointer_cture_rleased",!1),d(this,"inputSource"),d(this,"object"),d(this,"point"),d(this,"normal"),d(this,"face"),d(this,"distance"),d(this,"instanceId"),d(this,"intersection"),d(this,"isDown"),d(this,"isUp"),d(this,"isPressed"),d(this,"isClick"),d(this,"isDoubleClick"),d(this,"input"),this.event=t,this.input=e,this.button=t.button}get deviceIndex(){return this.event.deviceIndex}get pointerId(){return this.event.pointerId}get pressure(){return this.event.pressure}get used(){return this._used}use(){this._used||(this._used=!0,this.event.use(),this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId))}get propagationStopped(){return this._propagationStopped}stopPropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}stopImmediatePropagation(){this._propagationStopped=!0,this.event.stopImmediatePropagation()}setPointerCapture(){this.z__pointer_ctured=!0}releasePointerCapture(){this.z__pointer_cture_rleased=!0}get mode(){return this.event.mode}clone(){const e=new q0(this.input,this.event);return Object.assign(e,this),e}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function oD(n,e){return ie.foreachComponent(n,t=>{if(!t.enabled)return;const r=t;if(e)switch(e){case"pointerdown":if(r.onPointerDown)return!0;break;case"pointerup":if(r.onPointerUp||r.onPointerClick)return!0;break;case"pointermove":if(r.onPointerEnter||r.onPointerExit||r.onPointerMove)return!0;break}else if(r.onPointerDown||r.onPointerUp||r.onPointerEnter||r.onPointerExit||r.onPointerClick)return!0},!1)===!0}var kpe=Object.defineProperty,Ope=Object.getOwnPropertyDescriptor,Lpe=(n,e,t,r)=>{for(var s=r>1?void 0:r?Ope(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&kpe(e,t,s),s};class yA extends Be{awake(){Ea.createIfNoneExists(this.context)}onEnable(){var e;(e=Ea.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Ea.get(this.context))==null||e.unregister(this)}}class No extends yA{constructor(){super(...arguments),d(this,"targets",null),d(this,"raycastHits",[]),d(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new pl),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=s=>s instanceof ho?"continue in children":t?t(s):!0);const r=this.context.physics.raycast(e);return e.testObject=t,r}}Lpe([w()],No.prototype,"ignoreSkinnedMeshes",2);class TS extends No{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class AA extends yA{performRaycast(e){if(!Ct.active||!(e!=null&&e.ray))return null;const t=e.ray.origin,r=.01;return this.context.physics.sphereOverlap(t,r)}}class IS{static getObject(e){const t=e[Ca];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const r=this.tryFindCanvasGroup(e);if(r?.isCanvasGroup===!0&&(t&&(t.canvasGroup=r),r.blocksRaycasts===!1||r.interactable===!1))return!1;const s=Jp(e,o=>{if(o.isGraphic===!0)return o},!1);return t&&s?.isGraphic===!0&&(t.graphic=s),!(s?.raycastTarget===!1||s?.layer===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=Jp(e,r=>{const s=r;if(s.blocksRaycasts!==void 0&&s.interactable!==void 0)return s},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}function aD(n){return n[Ca]||(n.parent?aD(n.parent):null)}function Fpe(n){return n.isUI===!0||typeof n[Ca]=="object"}function RS(n,e){if(!n)return;const t=n.material;if(t?.isMaterial===!0){const r=n.parent;r&&r.isText,t.side=e.doubleSided??!0?gi:nr,t.shadowSide=e.doubleSided?gi:nr,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const r of n.children)RS(r,e)}function qg(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const r=Proxy.revocable(n[e],{set(a,l,c,h){const u=a[l],p=Reflect.set(a,l,c,h);return t(c,u),p}}),s=r.revoke,o=n[e];return r.revoke=()=>{n[e]=o,s()},n[e]=r.proxy,r}const mQ=Symbol("Scheduled action");function Upe(n,e,t=Hi.OnBeforeRender){let r=n[mQ];r||(r=n[mQ]={});const s=e.name;r[t]||(r[t]={});const o=r[t];if(o[s])return;function*a(){e?.call(n),o[s]=null}const l=n.startCoroutine(a(),t);o[s]=l}const gh=te("debugeventsystem");var lD=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(lD||{});const vh=class extends Be{constructor(){super(),d(this,"raycaster",[]),d(this,"_handleInputFn"),d(this,"pressedByID",new Map),d(this,"hoveredByID",new Map),d(this,"_sortedHits",[]),d(this,"_testObjectsCache",new Map),d(this,"_currentlyActiveRaycaster",null),d(this,"_currentPointerEventName",null),d(this,"shouldRaycastObject",n=>{var e;let t=null;if(Fpe(n)&&(t=(e=n[Ca])==null?void 0:e.gameObject),this._testObjectsCache.has(n)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(n)===!1?"continue in children":!0;{let r=oD(n,this._currentPointerEventName);if(!r&&t&&(r=oD(t,this._currentPointerEventName)),r){this._testObjectsCache.set(n,!0);for(const s of n.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(n,!1),"continue in children"}}),d(this,"_sortingBuffer",[]),d(this,"_noDepthTestingResults",[]),d(this,"out",{}),d(this,"_capturedPointer",{}),d(this,"pointerEnterSymbol",Symbol("pointerEnter")),d(this,"pointerExitSymbol",Symbol("pointerExit")),d(this,"currentActiveMeshUIComponents",[]),vh.systems.push(this)}static createIfNoneExists(n){this.didSearchEventSystem||(this.didSearchEventSystem=!0,vh.systems.length<=0&&vh.systems.push(...ie.findObjectsOfType(vh,n)));for(const t of vh.systems)if(t.context===n)return;const e=new Ae;ie.addNewComponent(e,vh),n.scene.add(e)}static get systems(){const n=Dt.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,t=!1){Ju.update(n,e,t)}static markUIDirty(n){Ju.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){vh.systems.splice(vh.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ie.findObjectOfType(yA,this.context)){const n=ie.addNewComponent(this.context.scene,No);this.raycaster.push(n),(st()||gh)&&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,t;const r=(e=this.raycaster)==null?void 0:e.indexOf(n);r!==void 0&&r!==-1&&((t=this.raycaster)==null||t.splice(r,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(an.PointerDown,this._handleInputFn),this.context.input.addEventListener(an.PointerUp,this._handleInputFn),this.context.input.addEventListener(an.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(an.PointerDown,this._handleInputFn),this.context.input.removeEventListener(an.PointerUp,this._handleInputFn),this.context.input.removeEventListener(an.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(n){if(n===void 0||n.propagationStopped)return;const e=new q0(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==an.PointerDown,e.isUp=n.type==an.PointerUp,e.isPressed=this.context.input.getPointerPressed(n.pointerId),gh&&(e.isDown?console.log("DOWN",e.pointerId):e.isUp&&console.log("UP",e.pointerId),e.isClick&&console.log("CLICK",e.pointerId));const t=new pl;n.hasRay?t.ray=n.ray:t.screenPoint=this.context.input.getPointerPositionRC(n.pointerId);const r=this.performRaycast(t);if(r)for(const o of r)o.event=n,n.intersections.push(o);gh&&e.isClick&&rn("EventSystem: "+e.pointerId+" - "+this.context.time.frame+" - Up:"+e.isUp+", Down:"+e.isDown);const s={sender:this,args:e,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:s})),this.handleIntersections(r,e),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:s}))}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 pl),n.testObject=this.shouldRaycastObject;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;this._currentlyActiveRaycaster=e;const t=e.performRaycast(n);this._currentlyActiveRaycaster=null,t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.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 t;if(n!=null&&n.length){n=this.sortCandidates(n);for(const s of n){if(e.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(e,s),this.handleEventOnObject(s.object,e))return!0}}this.assignHitInformation(e,n?.[0]),this.invokePointerCapture(e);const r=this.hoveredByID.get(e.pointerId);return r&&this.propagatePointerExit(r.obj,r.data,null),this.hoveredByID.delete(e.pointerId),e.isUp&&((t=this.pressedByID.get(e.pointerId))==null||t.handlers.forEach(s=>this.invokeOnPointerUp(e,s)),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 t=n[e],r=t.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEventOnObject(n,e){if(!this.testIsVisible(n))return e.isClick&&gh&&console.log("not allowed",n),!1;if(e.pointerId===void 0)return gh&&console.error("Event without pointer can't be handled",e),!1;e.object=n;const t=n.parent,r=e.isClick??!1;let s=null;if(t&&t.isUI){const c=(e.isPressed||e.isClick)??!1;if(t[Ca]){const h=t[Ca].gameObject;if(h){if(!IS.isInteractable(h,this.out))return!1;s=this.out.canvasGroup??null,this.handleMeshUIIntersection(n,c),n=h}}}r&&gh&&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(s===null||s.interactable)&&this.handleMainInteraction(n,e,a??null),!0}propagate(n,e){for(;n;)ie.foreachComponent(n,t=>{e(t)},!1),n=n.parent}handleMainInteraction(n,e,t){const r=this.pressedByID.get(e.pointerId),s=t!==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&&!it.approximately(a,l);break}this.propagate(n,a=>{var l;const c=a;c.interactable!==!1&&(!c.activeAndEnabled||!c.enabled||(c.onPointerEnter&&s&&this.handlePointerEnter(c,e),e.isDown&&c.onPointerDown&&(c.onPointerDown(e),r?.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),r?.handlers.delete(c)),c.onPointerExit&&((l=e.event)==null?void 0:l.pointerType)===z1.Touch&&(this.handlePointerExit(c,e),this.hoveredByID.delete(e.pointerId))),e.isClick&&c.onPointerClick&&c.onPointerClick(e)))}),e.isUp&&(r?.handlers.forEach(a=>{this.invokeOnPointerUp(e,a)}),this.pressedByID.delete(e.pointerId))}propagatePointerExit(n,e,t){this.propagate(n,r=>{if(!r.gameObject||r.destroyed)return;const s=r;if(s.onPointerExit){if(t&&this.isChild(t,r.gameObject))return;this.handlePointerExit(s,e)}})}invokeOnPointerUp(n,e){var t;(t=e.onPointerUp)==null||t.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,t,r){let s=n[t];if(r)return s&&s.includes(e)?!1:(s=s||[],s.push(e),n[t]=s,!0);{if(!s||!s.includes(e))return!1;const o=s.indexOf(e);return o!==-1&&s.splice(o,1),!0}}handlePointerCapture(n,e){if(n.z__pointer_ctured){n.z__pointer_ctured=!1;const t=n.pointerId;if(e.onPointerMove){const r=this._capturedPointer[t]||[];r.push(e),this._capturedPointer[t]=r}else st()&&!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 t=n.pointerId;if(this._capturedPointer[t]){const r=this._capturedPointer[t].indexOf(e);r!==-1&&(this._capturedPointer[t].splice(r,1),gh&&console.log("released pointer capture",t,e,this._capturedPointer))}}invokePointerCapture(n){var e;if(n.event.type===an.PointerMove){const t=n.pointerId,r=this._capturedPointer[t];if(r){gh&&console.log("Captured",t,r);for(let s=0;s<r.length;s++){const o=r[s];if(o.destroyed){r.splice(s,1),s--;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 t=Ju.updateState(n,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ju.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let n=0;n<this.currentActiveMeshUIComponents.length;n++){const e=this.currentActiveMeshUIComponents[n];Ju.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(n){return n?ie.isActiveSelf(n)?this.testIsVisible(n.parent):!1:!0}};let Ea=vh;d(Ea,"_eventSystemMap",new Map),d(Ea,"didSearchEventSystem",!1);class Ju{static markDirty(){this.needsUpdate=!0}static update(e,t,r=!1){if(r){e.update();return}const s=t.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===t){if(s===o.frame)return;o.frame=s;let a=this.needsUpdate||s<1;o.nextUpdate===t.time.frameCount&&(a=!0),a&&(gh&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let r=null;if(e&&(r=this.findBlockInParent(e),r&&r!==this.lastSelected)){if(r.interactable===!1)return null;this.needsUpdate=!0}return r}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}}d(Ju,"lastSelected",null),d(Ju,"lastUpdateFrame",[]),d(Ju,"needsUpdate",!1);var Npe=Object.defineProperty,zpe=Object.getOwnPropertyDescriptor,ln=(n,e,t,r)=>{for(var s=r>1?void 0:r?zpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Npe(e,t,s),s};const cD=te("debugorbit"),PS=te("freecam"),BS=te("debugcamerafit"),DS=te("smoothcam"),jpe={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let hD;class bA extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class yi extends Be{constructor(){super(...arguments),d(this,"autoTarget",!0),d(this,"autoFit",!1),d(this,"enableRotate",!0),d(this,"autoRotate",!1),d(this,"autoRotateSpeed",1),d(this,"minAzimuthAngle",1/0),d(this,"maxAzimuthAngle",1/0),d(this,"minPolarAngle",0),d(this,"maxPolarAngle",Math.PI),d(this,"enableKeys",!0),d(this,"enableDamping",!0),d(this,"dampingFactor",.1),d(this,"enableZoom",!0),d(this,"minZoom",0),d(this,"maxZoom",1/0),d(this,"zoomSpeed",1),d(this,"zoomToCursor",!1),d(this,"enablePan",!0),d(this,"lookAtConstraint",null),d(this,"lookAtConstraint01",1),d(this,"allowInterrupt",!0),d(this,"middleClickToFocus",!0),d(this,"doubleClickToFocus",!0),d(this,"clickBackgroundToFitScene",2),d(this,"debugLog",!1),d(this,"targetLerpDuration",1),d(this,"_controls",null),d(this,"_cameraObject",null),d(this,"_lookTargetLerpActive",!1),d(this,"_lookTargetStartPosition",new C),d(this,"_lookTargetEndPosition",new C),d(this,"_lookTargetLerp01",0),d(this,"_lookTargetLerpDuration",0),d(this,"_cameraLerpActive",!1),d(this,"_cameraStartPosition",new C),d(this,"_cameraEndPosition",new C),d(this,"_cameraLerp01",0),d(this,"_cameraLerpDuration",0),d(this,"_inputs",0),d(this,"_enableTime",0),d(this,"_startedListeningToKeyEvents",!1),d(this,"_eventSystem"),d(this,"_afterHandleInputFn"),d(this,"_camera",null),d(this,"_syncedTransform"),d(this,"_didStart",!1),d(this,"_didSetTarget",0),d(this,"targetElement",null),d(this,"_lastTimeClickOnBackground",-1),d(this,"_clickOnBackgroundCount",0),d(this,"_onPointerDown",e=>{if(this.clickBackgroundToFitScene>0&&e.isClick&&e.button===0){if(e.hasRay||e.intersections.push(...this.context.physics.raycast()),e.intersections.length<=0){const t=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||t<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}cD&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}}),d(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),d(this,"_shouldDisable",!1),d(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.fitCamera(this.scene.children,{centerCamera:"y",immediate:!0})}),d(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=Ea.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(lD.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(lD.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=ie.getComponent(this.gameObject,zi);this._camera=e;let t=e?.cam;if(!t&&this.gameObject instanceof Lt&&(t=this.gameObject),t&&cR(t,this,!0),!this._controls&&t instanceof Lt){this._cameraObject=t;const r=this.targetElement??this.context.renderer.domElement,s=t?.quaternion.clone();this._controls=new cQ(t,r),t?.quaternion.copy(s),hD===void 0&&(hD={...this._controls.keys})}this._controls&&(PS&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,aa()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?PS||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):PS||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ie.getComponent(this.gameObject,Yu)??void 0,this.context.input.addEventListener("pointerup",this._onPointerDown),this.context.pre_render_callbacks.push(this.__onPreRender)}onDisable(){var e;(e=this._camera)!=null&&e.cam&&cR(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted)),this.context.input.removeEventListener("pointerup",this._onPointerDown)}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,t;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}if(this._controls.enabled=!0,(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(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 s=ie.getComponent(this.gameObject,zi);if(s&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const o=Bt(s.cam).length(),a=new C(0,0,-o).applyMatrix4(s.cam.matrixWorld);this.setLookTargetPosition(a,!0)}if(!this.setLookTargetFromConstraint()){const o=new pl;o.screenPoint=new Z(0,0),o.lineThreshold=.1;const a=this.context.physics.raycast(o);a.length>0&&this.setLookTargetPosition(a[0].point,!0),BS&&console.log("OrbitControls hits",...a)}}let r=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(r||(r=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),r&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){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 bA(this,"camera"));else{const s=it.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,s)}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 bA(this,"lookat"));else{const s=it.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,s)}}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._controls.keys=this.enableKeys?hD:jpe,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,typeof DS=="number"||DS===!0){this._controls.enableDamping=!0;const s=typeof DS=="number"?DS:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,s))}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||(!PS&&(t=this.lookAtConstraint)!=null&&t.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),cD&&At.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof Ae))return;const t=Bt(e),r=gR(e);this.setTargetFromRaycast(new lo(t,r)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var r,s;e&&(e instanceof Ae&&(e=Bt(e)),this._cameraEndPosition||(this._cameraEndPosition=new C),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(r=this.controllerObject)==null||r.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((s=this._cameraObject)==null?void 0:s.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof Ae&&(e=Bt(e)),this._lookTargetEndPosition.copy(e),cD&&(console.warn("OrbitControls: setLookTargetPosition",e,t),At.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const r of t)if(r.distance>0&&ie.isActiveInHierarchy(r.object)){const s=aD(r.object);if(s){const o=s.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(r.point);break}}fitCamera(e,t={fitOffset:void 0,immediate:!1}){if(this.context.isInXR)return;const{immediate:r=!1,centerCamera:s}=t;let{fitOffset:o}=t;o==null&&(o=1.1);const a=this._cameraObject,l=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0){console.warn("No objects to fit camera to...");return}if(!a||!l){console.warn("No camera or controls found to fit camera to objects...");return}const c=new C,h=new C,u=lu(e);a.updateMatrixWorld(),a.updateProjectionMatrix(),u.getCenter(h);const p=new C;if(u.getSize(p),u.applyMatrix4(a.matrixWorldInverse),u.getSize(c),u.setFromCenterAndSize(h,c),Number.isNaN(c.x)||Number.isNaN(c.y)||Number.isNaN(c.z)){console.warn("Camera fit size resultet in NaN",a,u,[...e]);return}if(c.length()<=1e-10){BS&&console.warn("Camera fit size is zero",u,[...e]);return}const m=a.fov,f=2*Math.atan(Math.tan(m*Math.PI/360/2)*a.aspect)/Math.PI*360,g=c.y/(2*Math.atan(Math.PI*m/360)),v=c.x/(2*Math.atan(Math.PI*f/360)),A=o*Math.max(g,v)+c.z/2;BS&&console.log("Fit camera to objects",g,v,"distance",A),l.maxDistance=A*10,l.minDistance=A*.01;const y=.05,_=h.clone();_.y-=c.y*y,this.setLookTargetPosition(_,r),this.autoTarget=!1;const b=Math.max(p.x,p.y,p.z);a.near=A/100,a.far=b+A*10,a.updateMatrixWorld(),a.updateProjectionMatrix();const x=Bt(a),E=h.clone();if(E.sub(x),s==="y"&&(E.y=0),E.normalize(),E.multiplyScalar(A),s==="y"&&(E.y+=-y*4*c.y),a.parent){const I=a.parent.worldToLocal(h.clone().sub(E));this.setCameraTargetPosition(I,r)}else console.error(`Can not fit camera ${a.name} because it has no parent`);if(BS){const I=new fI(u);this.context.scene.add(I),AR(I,Wv(a)),setTimeout(()=>{this.context.scene.remove(I)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",T=>{T.code==="KeyF"&&this.fitCamera(e,{fitOffset:o,immediate:r})}))}l.update()}}ln([w()],yi.prototype,"autoTarget",2),ln([w()],yi.prototype,"autoFit",2),ln([w()],yi.prototype,"enableRotate",2),ln([w()],yi.prototype,"autoRotate",2),ln([w()],yi.prototype,"autoRotateSpeed",2),ln([w()],yi.prototype,"minAzimuthAngle",2),ln([w()],yi.prototype,"maxAzimuthAngle",2),ln([w()],yi.prototype,"minPolarAngle",2),ln([w()],yi.prototype,"maxPolarAngle",2),ln([w()],yi.prototype,"enableKeys",2),ln([w()],yi.prototype,"enableDamping",2),ln([w()],yi.prototype,"dampingFactor",2),ln([w()],yi.prototype,"enableZoom",2),ln([w()],yi.prototype,"minZoom",2),ln([w()],yi.prototype,"maxZoom",2),ln([w()],yi.prototype,"zoomSpeed",2),ln([w()],yi.prototype,"enablePan",2),ln([w(tm)],yi.prototype,"lookAtConstraint",2),ln([w()],yi.prototype,"lookAtConstraint01",2),ln([w()],yi.prototype,"allowInterrupt",2),ln([w()],yi.prototype,"middleClickToFocus",2),ln([w()],yi.prototype,"doubleClickToFocus",2),ln([w()],yi.prototype,"clickBackgroundToFitScene",2),ln([w()],yi.prototype,"targetLerpDuration",2);var Gpe=Object.defineProperty,Qpe=Object.getOwnPropertyDescriptor,Ao=(n,e,t,r)=>{for(var s=r>1?void 0:r?Qpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Gpe(e,t,s),s},Ku=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Ku||{});const yh=te("debugcam"),fQ=te("debugscreenpointtoray");var kS;const _A=(kS=class extends Be{constructor(){super(...arguments),d(this,"_nearClipPlane",.1),d(this,"_farClipPlane",1e3),d(this,"orthographic",!1),d(this,"orthographicSize",5),d(this,"ARBackgroundAlpha",0),d(this,"_cullingMask",4294967295),d(this,"_backgroundBlurriness",0),d(this,"_backgroundIntensity",1),d(this,"_environmentIntensity"),d(this,"_targetTexture",null),d(this,"_backgroundColor"),d(this,"_fov"),d(this,"_cam",null),d(this,"_clearFlags",2),d(this,"_skybox"),d(this,"_frustum"),d(this,"_projScreenMatrix",new ve)}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.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.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 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.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(n,e,t){const r=this.cam,s=_A._origin;s.set(n,e,-1),this.context.input.convertScreenspaceToRaycastSpace(s),fQ&&console.log("screenPointToRay",n.toFixed(2),e.toFixed(2),"now:",s.x.toFixed(2),s.y.toFixed(2),"isInXR:"+this.context.isInXR),s.z=-1,s.unproject(r);const o=_A._direction.set(s.x,s.y,s.z),a=Bt(r);return o.sub(a),o.normalize(),t?(t.set(a,o),t):new lo(a.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new Wd,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Wd),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(n,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),n===this._projScreenMatrix?n:n.copy(this._projScreenMatrix)}awake(){fQ&&window.addEventListener("pointerdown",n=>{const e=n.clientX,t=n.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const r=this.screenPointToRay(e,t),s="#"+Math.floor(Math.random()*16777215).toString(16);At.DrawRay(r.origin,r.direction,s,10)})}onEnable(){yh&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ku[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Hpe(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 t=this.orthographicSize*100;e=new Bl(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,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){if(!this._cam){yh&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,yh){const e=`Camera "${this.name}" clear flags: ${Ku[this._clearFlags]}`;console.debug(e)}switch(this._clearFlags){case 1:if(_A.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:yh&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:yh&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;_A.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else yh&&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 Vpe(this)),this._skybox.apply()}static backgroundShouldBeTransparent(n){var e,t,r,s;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;yh&&rn("Environment blend mode: "+a+" on "+navigator.userAgent);let l=a==="additive"||a==="alpha-blend";return n.isInAR&&a==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(r=navigator.userAgent)!=null&&r.includes("Mozilla")&&(s=navigator.userAgent)!=null&&s.includes("Mobile WebXRViewer/v2"))&&(l=!0),o._transparent=l,l}},d(kS,"_origin",new C),d(kS,"_direction",new C),kS);let zi=_A;Ao([w()],zi.prototype,"aspect",1),Ao([w()],zi.prototype,"fieldOfView",1),Ao([w()],zi.prototype,"nearClipPlane",1),Ao([w()],zi.prototype,"farClipPlane",1),Ao([w()],zi.prototype,"clearFlags",1),Ao([w()],zi.prototype,"orthographic",2),Ao([w()],zi.prototype,"orthographicSize",2),Ao([w()],zi.prototype,"ARBackgroundAlpha",2),Ao([w()],zi.prototype,"cullingMask",1),Ao([w()],zi.prototype,"backgroundBlurriness",1),Ao([w()],zi.prototype,"backgroundIntensity",1),Ao([w()],zi.prototype,"environmentIntensity",1),Ao([w(xi)],zi.prototype,"backgroundColor",1),Ao([w(Wg)],zi.prototype,"targetTexture",1);class Vpe{constructor(e){d(this,"_camera"),d(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&&(yh&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=ro,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}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(yh||st())&&ki(`Camera "${this._camera.name}" has no skybox texture`))}}function Hpe(n){te("freecam")&&n.context.mainCameraComponent===n&&ie.getOrAddComponent(n.gameObject,yi)}class Zu extends Be{constructor(){super(...arguments),d(this,"_listener",null),d(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new lU),this._listener}onEnable(){Qu.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Qu.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const t=this.context.mainCameraComponent||ie.getComponentInParent(this.gameObject,zi);t!=null&&t.cam?t.cam.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())}}class Wpe extends Sn{constructor(e,t=1,r=16,s=2){const o=new yt,a=r+s*2,l=new Float32Array((a*3+3)*3);o.setAttribute("position",new nt(l,3));const c=new Gi({color:65280}),h=new Gi({color:16776960});super(o,[h,c]),this.audio=e,this.range=t,this.divisionsInnerAngle=r,this.divisionsOuterAngle=s,this.type="PositionalAudioHelper",this.update()}update(){const e=this.audio,t=this.range,r=this.divisionsInnerAngle,s=this.divisionsOuterAngle,o=hi.degToRad(e.panner.coneInnerAngle),a=hi.degToRad(e.panner.coneOuterAngle),l=o/2,c=a/2;let h=0,u=0,p,m;const f=this.geometry,g=f.attributes.position;f.clearGroups();function v(A,y,_,b){const x=(y-A)/_;for(g.setXYZ(h,0,0,0),u++,p=A;p<y;p+=x)m=h+u,g.setXYZ(m,Math.sin(p)*t,0,Math.cos(p)*t),g.setXYZ(m+1,Math.sin(Math.min(p+x,y))*t,0,Math.cos(Math.min(p+x,y))*t),g.setXYZ(m+2,0,0,0),u+=3;f.addGroup(h,u,b),h+=u,u=0}v(-c,-l,s,0),v(-l,l,r,1),v(l,c,s,0),g.needsUpdate=!0,o===a&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var Xpe=Object.defineProperty,qpe=Object.getOwnPropertyDescriptor,Kl=(n,e,t,r)=>{for(var s=r>1?void 0:r?qpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Xpe(e,t,s),s};const Es=te("debugaudio"),$u=class extends Be{constructor(){super(...arguments),d(this,"clip",""),d(this,"playOnAwake",!1),d(this,"preload",!1),d(this,"_spatialBlend",0),d(this,"_minDistance",1),d(this,"_maxDistance",100),d(this,"_volume",1),d(this,"rollOffMode",0),d(this,"playInBackground",!0),d(this,"_loop",!1),d(this,"sound",null),d(this,"helper",null),d(this,"wasPlaying",!1),d(this,"audioLoader",null),d(this,"shouldPlay",!1),d(this,"_lastClipStartedLoading",null),d(this,"_audioElement",null),d(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||aa())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":Es&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,$u.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&$u.userInteractionRegistered&&this.wasPlaying&&this.play();break}}),d(this,"onApplicationMuteChanged",()=>{var n,e;this.context.application.muted?(n=this.sound)==null||n.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)}),d(this,"createAudio",n=>{Es&&console.log("AudioBuffer finished loading",n);const e=this.Sound;if(!e){Es&&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&&$u.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),$u.registerWaitForAllowAudio(this.__onAllowAudioCallback)}),d(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()}),d(this,"_lastContextTime",0),d(this,"_hasEnded",!0),d(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Qu.userInteractionRegistered}static registerWaitForAllowAudio(n){Qu.registerWaitForAllowAudio(n)}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&&(Es&&console.log(this.name,"audio set volume",n),this.sound.setVolume(n))}get Sound(){var n;if(!this.sound&&$u.userInteractionRegistered){let e=ie.getComponent(this.context.mainCamera,Zu)??ie.findObjectOfType(Zu,this.context);!e&&this.context.mainCamera&&(e=ie.addNewComponent(this.context.mainCamera,Zu)),e!=null&&e.listener?(this.sound=new hU(e.listener),(n=this.gameObject)==null||n.add(this.sound)):Es&&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(){Es&&console.log(this),this.audioLoader=new kx,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),$u.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():$u.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(tS.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(tS.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const n=this.sound;if(!n)return;this._needUpdateSpatialDistanceSettings=!1;const e=it.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(Es&&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?Es&&!this.helper&&(this.helper=new Wpe(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(Es&&console.log(n),n.endsWith(".mp3")||n.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new kx),this.shouldPlay=!0,this._lastClipStartedLoading===n){Es&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=n,Es&&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,t,r;!n&&this.clip&&(n=this.clip),n!==void 0&&typeof n!="string"&&!(n instanceof MediaStream)&&(st()&&console.warn("Called play on AudioSource with unknown argument type:",n+`
5671
- Using the assigned clip instead:`,this.clip),n=this.clip);let s=!this.sound||n&&n!==this.clip;if(typeof n=="string"&&!this.audioLoader&&(s=!0),(n instanceof MediaStream||typeof n=="string")&&(this.clip=n),s){this.shouldPlay=!0,this.onNewClip(n);return}if(this.shouldPlay=!0,this._hasEnded=!1,Es&&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),(t=this.gameObject)==null||t.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||(r=this.context.domElement.shadowRoot)==null||r.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;Es&&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;Es&&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,Es&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}get isPlaying(){var n;return((n=this.sound)==null?void 0:n.isPlaying)??!1}set isPlaying(n){}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()}}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,Es&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Mn=$u;Kl([w(URL)],Mn.prototype,"clip",2),Kl([w()],Mn.prototype,"playOnAwake",2),Kl([w()],Mn.prototype,"preload",2),Kl([w()],Mn.prototype,"loop",1),Kl([w()],Mn.prototype,"spatialBlend",1),Kl([w()],Mn.prototype,"minDistance",1),Kl([w()],Mn.prototype,"maxDistance",1),Kl([w()],Mn.prototype,"volume",1),Kl([w()],Mn.prototype,"rollOffMode",2),Kl([w()],Mn.prototype,"playInBackground",2);var Ype=Object.defineProperty,Jpe=Object.getOwnPropertyDescriptor,OS=(n,e,t,r)=>{for(var s=r>1?void 0:r?Jpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Ype(e,t,s),s};const Kpe=te("debugsignals");class xA{constructor(){d(this,"guid")}}OS([w()],xA.prototype,"guid",2);class Yg{constructor(){d(this,"signal"),d(this,"reaction")}}OS([w(xA)],Yg.prototype,"signal",2),OS([w(Un)],Yg.prototype,"reaction",2);var uD;const Ah=(uD=class extends Be{constructor(){super(...arguments),d(this,"events")}static invoke(n){if(Ah.receivers[n]){const e=Ah.receivers[n];if(!e)return;for(const t of e)t.invoke(n)}}awake(){Kpe&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const n of this.events)Ah.receivers[n.signal.guid]||(Ah.receivers[n.signal.guid]=[]),Ah.receivers[n.signal.guid].push(this)}onDisable(){if(this.events){for(const n of this.events)if(Ah.receivers[n.signal.guid]){const e=Ah.receivers[n.signal.guid].indexOf(this);e>=0&&Ah.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 t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(r){console.error(r)}}},d(uD,"receivers",{}),uD);let Jg=Ah;OS([w(Yg)],Jg.prototype,"events",2);var zo=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(zo||{}),Zl=(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))(Zl||{}),dD=(n=>(n.Signal="SignalEmitter",n))(dD||{});const $l=te("debugtimeline");class wA{constructor(){d(this,"director"),d(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let r=this.track.clips.length-1;r>=0;r--)yield this.track.clips[r];else for(const r of this.track.clips)yield r}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,r,s=!0){if(t<0||t>=r.length)return 0;const o=r[t];if(s||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 Zpe{constructor(e){d(this,"clip"),d(this,"rootPositionOffset"),d(this,"rootQuaternionOffset"),d(this,"rootStartPosition"),d(this,"rootEndPosition"),d(this,"rootStartQuaternion"),d(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const r=e.getRoot(),s=r.name+".position",o=r.name+".quaternion";$l&&console.log(t.name,t.tracks,s);for(const a of t.tracks)if(!(a.times.length<=0)){if(a.name.endsWith(s))this.rootStartPosition=new C().fromArray(a.values,0),this.rootEndPosition=new C().fromArray(a.values,a.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$l&&console.log(this.rootPositionOffset);else if(a.name.endsWith(o)&&(this.rootStartQuaternion=new Ce().fromArray(a.values,0),this.rootEndQuaternion=new Ce().fromArray(a.values,a.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$l)){const l=new pi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",l)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class LS extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"trackOffset"),d(this,"target"),d(this,"mixer"),d(this,"clips",[]),d(this,"actions",[]),d(this,"_actionOffsets",[]),d(this,"_didBind",!1),d(this,"_animator",null),d(this,"_useclipOffsets",!0),d(this,"_totalOffsetPosition",new C),d(this,"_totalOffsetRotation",new Ce),d(this,"_totalOffsetPosition2",new C),d(this,"_totalOffsetRotation2",new Ce),d(this,"_summedPos",new C),d(this,"_tempPos",new C),d(this,"_summedRot",new Ce),d(this,"_tempRot",new Ce),d(this,"_clipRotQuat",new Ce)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&vQ(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var r,s;if(((r=t.tracks)==null?void 0:r.length)<=0){console.warn("No tracks in AnimationClip",t);return}const o=t.tracks[0].name.split("."),a=o[o.length-2],l=a+".position",c=a+".quaternion";let h=!1,u=!1;for(const p of t.tracks)p.name.endsWith(l)?(h=!0,this.createPositionInterpolant(t,e,p)):p.name.endsWith(c)&&(u=!0,this.createRotationInterpolant(t,e,p));if(!h||!u){const p=(s=this.mixer)==null?void 0:s.getRoot(),m=t.tracks[0],f=m.name.lastIndexOf("."),g=m.name.substring(0,f),v=g.substring(g.lastIndexOf(".")+1),A=p.getObjectByName(v);if(A)if(h){if(!u){const y=t.tracks[0].name.substring(0,f)+".quaternion";$l&&console.warn("Create quaternion track",v,A);const _=A.quaternion,b=new sa(y,[0,t.duration],[_.x,_.y,_.z,_.w,_.x,_.y,_.z,_.w]);t.tracks.push(b),this.createRotationInterpolant(t,e,b)}}else{const y=g+".position";$l&&console.warn("Create position track",v,A);const _=A.position,b=new Dl(y,[0,t.duration],[_.x,_.y,_.z,_.x,_.y,_.z]);t.tracks.push(b),this.createPositionInterpolant(t,e,b)}}}bind(){if(!this._didBind){this._didBind=!0,$l&&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 t=new Zpe(e);this._actionOffsets.push(t)}this.target&&(this._animator=ie.getComponent(this.target,Wr)??null,this._animator&&vQ(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,r=t.position,s=t.rotation;r&&r.x!==void 0&&(r.isVector3||(t.position=new C(r.x,r.y,r.z)),s.isQuaternion||(t.rotation=new Ce(s.x,s.y,s.z,s.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new C(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ce(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,r,s,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,u=0,p=!1,m=!1,f=0;for(let g=0;g<this.clips.length;g++){const v=this.models[g],A=this.actions[g],y=v.asset;A.weight=0;const _=e>=v.start&&e<=v.end,b=v.preExtrapolationMode,x=v.postExtrapolationMode,E=g<this.clips.length-1?this.models[g+1]:null;let I=_,T=!1;if(!I&&!p&&v.end<e&&x!==Zl.None?(!E||E.start>e)&&(I=!0,p=!0):g==0&&!I&&!m&&v.start>e&&b!==Zl.None&&(!E||E.start<e)&&(I=!0,T=!0,m=!0),I){let R=1;R*=this.evaluateWeight(e,g,this.models,I),R*=this.director.weight;let k=_;if(T)switch(b){case Zl.Hold:break;case Zl.Loop:e+=v.start,k=!0;break;default:e+=v.start,k=!0;break}let M=this.getClipTime(e,v),P=0;const z=y.duration;if(T&&b===Zl.Hold&&(M=0),k){if(y.loop)for(P+=Math.floor(M/(z+1e-6));M>z;)M-=z}else if(!_&&p)switch(x){case Zl.Hold:M=this.getClipTime(v.end,v);break;case Zl.Loop:M%=z;break;case Zl.PingPong:const L=Math.floor(M/z)%2!==0;M%=z,L&&(M=z-M);break}v.reversed===!0?A.time=A.getClip().duration-M:A.time=M,A.timeScale=0;const Q=Math.max(0,R);if(A.weight=Q,f+=Q,A.clampWhenFinished=!1,A.isRunning()||A.play(),this._useclipOffsets){const L=h==0?this._totalOffsetPosition:this._totalOffsetPosition2,H=h==0?this._totalOffsetRotation:this._totalOffsetRotation2;h<1&&(u=1-R),h+=1;const O=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),G=this._summedRot.identity(),Y=this._tempRot.identity(),K=y.rotation;K&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(K,R));const oe=this._actionOffsets[g];if(oe.hasOffsets)for(let we=0;we<P;we++)oe.rootPositionOffset?F.copy(oe.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(G),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),oe.rootQuaternionOffset&&(Y.copy(oe.rootQuaternionOffset),G.multiply(Y)),O.add(F);this._clipRotQuat&&H.multiply(this._clipRotQuat),H.multiply(G),y.position&&O.add(y.position),L.add(O)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&($l||st())&&(r=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&r.mixer&&this.mixer!==((o=(s=this._animator)==null?void 0:s.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,t,r){var s;const o=r.createInterpolant.bind(r),a=new Ce;this.ensureTrackOffsets();const l=(s=this.trackOffset)==null?void 0:s.rotation;r.createInterpolant=()=>{const c=o(),h=c.evaluate.bind(c);return c.evaluate=u=>{var p;const m=h(u);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)(p=f?.onTimelineRotation)==null||p.call(f,this.director,this.target,u,a);return m[0]=a.x,m[1]=a.y,m[2]=a.z,m[3]=a.w,m},c}}createPositionInterpolant(e,t,r){var s,o;const a=r.createInterpolant.bind(r),l=new C;this.ensureTrackOffsets();const c=(s=this.trackOffset)==null?void 0:s.rotation,h=(o=this.trackOffset)==null?void 0:o.position;let u;r.createInterpolant=()=>{const p=a(),m=p.evaluate.bind(p);return p.evaluate=f=>{var g,v,A;const y=m(f);if(l.set(y[0],y[1],y[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(v=(g=this._actionOffsets.find(_=>_.clip===e))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):u!=null&&u.isVector3&&l.sub(u)),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 _ of this.director.animationCallbackReceivers)(A=_?.onTimelinePosition)==null||A.call(_,this.director,this.target,f,l);return y[0]=l.x,y[1]=l.y,y[2]=l.z,y},p}}}const $pe=te("mutetimeline"),SA=class extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"listener"),d(this,"audio",[]),d(this,"audioContextTimeOffset",[]),d(this,"lastTime",0),d(this,"audioSource"),d(this,"_audioLoader",null),d(this,"_playableDirectorResumed",!1)}getAudioFilePath(n){const e=this.director.sourceId;return ou(e,n)}onAllowAudioChanged(n){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(n?t.asset.volume:0)}}addModel(n){const e=new aI(this.listener);this.audio.push(e);const t=n;t._didTriggerPlay=!1,this.models.push(t)}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($pe||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=this._playableDirectorResumed;this._playableDirectorResumed=!1;const r=e?.1:0;for(let s=0;s<this.models.length;s++){const o=this.models[s],a=this.audio[s],l=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,n-1,n+1)&&this.handleAudioLoading(o,a),Mn.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)(t||!o._didTriggerPlay&&this.lastTime<n)&&(o.duration*o.timeScale>.3?a.offset=o.clipIn+(n-o.start)*o.timeScale:a.offset=0,$l&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+o.asset.clip),a.play(r),o._didTriggerPlay=!0);else{const h=o.clipIn+(n-o.start)*o.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(h-u)>.3&&(a.offset=h,a.stop(),a.play(r))}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,t=0){let r=null;const s=n-t,o=n+e;for(const a of this.models)if(this.isInTimeRange(a,s,o)){const l=this.audio[this.models.indexOf(a)],c=this.handleAudioLoading(a,l);c!==null&&(r===null&&(r=[]),r.push(c))}return r!==null?Promise.all(r):null}isInTimeRange(n,e,t){return e<=n.start&&t>=n.end||e>=n.start&&e<=n.end||t>=n.start&&t<=n.end}static dispose(){SA._audioBuffers.clear()}handleAudioLoading(n,e){this._audioLoader||(this._audioLoader=new kx);const t=this.getAudioFilePath(n.asset.clip);if(SA._audioBuffers.get(t)){const s=SA._audioBuffers.get(t);return s.then(o=>{o&&e.setBuffer(o)}),s}$l&&console.warn("LOAD audio track",t,this.director.sourceId);const r=new Promise((s,o)=>{this._audioLoader.load(t,a=>{e.setBuffer(a),s(a)},void 0,a=>{console.error("Error loading audio",a),s(null)})});return SA._audioBuffers.set(t,r),r}};let CA=SA;d(CA,"_audioBuffers",new Map);class EA extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"didTrigger",[]),d(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const r=this.director.context.time.deltaTime*1.5;for(let s=0;s<this.models.length;s++){const o=this.models[s],a=this.didTrigger[s],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<r)&&(c=!0)}if(c){if(!a)if($l&&console.log("Trigger signal",e,o.time,o),this.didTrigger[s]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Jg.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[s]=!1)}}}class FS extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"timelines",[]),d(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const r=this.models[t].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",t,r),this.models.splice(t,1);continue}else{const s=ie.getComponent(r.sourceObject,ed);this.timelines.push(s),s&&r.updateDirector&&(s.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=s.asset;if(e>=s.start&&e<=s.end){this._previousActiveModel=s;const a=this.getClipTime(e,s);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[r];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const l=o.sourceObject;a?.sourceObject!==l&&(l.visible=!1)}}}}}var eme=Object.defineProperty,tme=Object.getOwnPropertyDescriptor,gQ=(n,e,t,r)=>{for(var s=r>1?void 0:r?tme(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&eme(e,t,s),s};const Kg=te("debugtimeline");var pD;const mD=(pD=class extends Be{constructor(){super(...arguments),d(this,"playableAsset"),d(this,"playOnAwake"),d(this,"extrapolationMode",1),d(this,"waitForAudio",!0),d(this,"_visibilityChangeEvt"),d(this,"_clonedPlayableAsset",!1),d(this,"_speed",1),d(this,"_guidsMap"),d(this,"_isPlaying",!1),d(this,"_internalUpdateRoutine"),d(this,"_isPaused",!1),d(this,"_isStopping",!1),d(this,"_time",0),d(this,"_duration",0),d(this,"_weight",1),d(this,"_animationTracks",[]),d(this,"_audioTracks",[]),d(this,"_signalTracks",[]),d(this,"_controlTracks",[]),d(this,"_customTracks",[]),d(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),d(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:(Kg||js())&&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,t;Kg&&console.log(this,(n=this.playableAsset)==null?void 0:n.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var n,e,t;for(const r of this._audioTracks)(n=r.onEnable)==null||n.call(r);for(const r of this._customTracks)(e=r.onEnable)==null||e.call(r);for(const r of this._animationTracks)(t=r.onEnable)==null||t.call(r);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,t;this.stop();for(const r of this._audioTracks)(n=r.onDisable)==null||n.call(r);for(const r of this._customTracks)(e=r.onDisable)==null||e.call(r);for(const r of this._animationTracks)(t=r.onDisable)==null||t.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var n;for(const e of this._allTracks)for(const t of e)(n=t.onDestroy)==null||n.call(t)}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 t of this._audioTracks){const r=t.loadAudio(this._time,1,0);r&&e.push(r)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Mn.userInteractionRegistered&&this.waitForAudio;)await Ll(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Hi.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.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 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 t=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case zo.Activation:if(!n&&!this._isPlaying)continue;for(let s=0;s<r.outputs.length;s++){const o=r.outputs[s];if(typeof o=="object"){let a=!1;if(r.clips)for(const c of r.clips)c.start<=t&&t<=c.end&&(a=!0);const l=o;l.visible!==void 0&&l.visible!==a&&(l.visible=a,Kg&&console.warn(this.name,"set ActivationTrack-"+s,l.name,a,t))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(t);for(const r of this._audioTracks)r.evaluate(t);for(const r of this._signalTracks)r.evaluate(t);for(const r of this._controlTracks)r.evaluate(t);for(const r of this._customTracks)r.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Nv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const n=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let r=e.outputs[t];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const s=ie.findByGuid(r,n);s===null||typeof s!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",r,e.name,e.type)):(Kg&&console.log("Resolved binding",r,"to",s),e.outputs[t]=s)}else if(r===null){if(e.outputs.splice(t,1),mD.createTrackFunctions[e.type])continue;e.type!==zo.Audio&&e.type!==zo.Control&&e.type!==zo.Marker&&e.type!==zo.Signal&&console.warn("Missing binding",r,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===zo.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const r=e.clips[t];let s=r.asset.sourceObject;if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const o=ie.findByGuid(s,n);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",s,e.name,r):(Kg&&console.log("Resolved binding",s,"to",o),r.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,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let r=ie.findObjectOfType(Zu,this.context);for(const s of this.playableAsset.tracks){const o=s.type,a=mD.createTrackFunctions[o];if(a!=null){const l=a(this,s);if(typeof l.evaluate=="function"){l.director=this,l.track=s,this._customTracks.push(l);continue}}if(s.type===zo.Animation){if(!s.clips||s.clips.length<=0){Kg&&console.warn("Animation track has no clips",s);continue}for(let l=s.outputs.length-1;l>=0;l--){let c=s.outputs[l];if(c instanceof Ae){const u=ie.getOrAddComponent(c,Wr);u&&(c=u)}const h=(n=c?.gameObject)==null?void 0:n.animations;if(h){const u=new LS;u.trackOffset=s.trackOffset,u.director=this,u.track=s;for(let p=0;p<s.clips.length;p++){const m=s.clips[p],f=m.asset;if(!f){console.error(`Timeline ${this.name}: clip #${p} on track "${s.name}" has no animation data`);continue}const g=f.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=h.find(y=>y.name===g)),!v){console.warn("Could not find animationClip for model",m,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}c instanceof Wr&&c.runtimeAnimatorController&&(c.__internalDidAwakeAndStart||c.initializeRuntimeAnimatorController(),c.runtimeAnimatorController.mixer||c.runtimeAnimatorController.bind(c),u.mixer=c.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Ox(c.gameObject),this.context.animations.registerAnimationMixer(u.mixer)),u.clips.push(v),u.mixer.uncacheAction(v),u.createHooks(m.asset,v);const A=u.mixer.clipAction(v);u.actions.push(A),u.models.push(m)}this._animationTracks.push(u)}}}else if(s.type===zo.Audio){if(!s.clips||s.clips.length<=0)continue;const l=new CA;l.director=this,l.track=s,l.audioSource=s.outputs.find(c=>c instanceof Mn),this._audioTracks.push(l),r||(r=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(Zu)),l.listener=r.listener;for(let c=0;c<s.clips.length;c++){const h=s.clips[c];l.addModel(h)}}else if(s.type===zo.Marker){const l=new EA;if(l.director=this,l.track=s,s.markers)for(const c of s.markers)switch(c.type){case dD.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=ie.getComponent(this.gameObject,Jg);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(s.type===zo.Signal){const l=new EA;if(l.director=this,l.track=s,s.markers)for(const c of s.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of s.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(s.type===zo.Control){const l=new FS;if(l.director=this,l.track=s,s.clips)for(const c of s.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)}},d(pD,"createTrackFunctions",{}),pD);let ed=mD;gQ([w()],ed.prototype,"playOnAwake",2),gQ([w()],ed.prototype,"extrapolationMode",2);const US=Symbol("objectIsAnimatedData");function vQ(n,e,t){if(!n)return;if(n[US]===void 0){if(!t)return;n[US]=new Set}const r=n[US];t?r.add(e):r.has(e)&&r.delete(e)}function ime(n){if(!n)return!1;const e=n[US];return e!==void 0&&e.size>0}ui.registerCallback(Si.ContextCreated,n=>{const e=n.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&n.files)for(const t of n.files)ie.foreachComponent(t.file.scene,r=>{if(r.enabled!==!1){if(r instanceof Cs&&r.playAutomatically||r instanceof Wr||r instanceof ed&&r.playOnAwake===!0)return!0;if(r instanceof Cs)return r.playAutomatically=!0,!0;if(r instanceof ed)return r.playOnAwake=!0,!0}},!0)!==!0&&Bg.assignAnimationsFromFile(t.file,{createAnimationComponent:(r,s)=>fl(r,Cs)})});class nme{constructor(){d(this,"_context")}get context(){return this._context??Dt.Current}get isStateMachineBehaviour(){return!0}}class MA{constructor(e,t,r,s){d(this,"name"),d(this,"nameHash"),d(this,"normalizedTime"),d(this,"length"),d(this,"speed"),d(this,"action"),d(this,"hasTransitions");var o;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=r,this.speed=s,this.action=e.motion.action||null,this.hasTransitions=((o=e.transitions)==null?void 0:o.length)>0||!1}}function yQ(n,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??hi.generateUUID(),index:-1,clip:new zs(n,0,[])}}var td=(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))(td||{}),fD=(n=>(n[n.Float=1]="Float",n[n.Int=3]="Int",n[n.Bool=4]="Bool",n[n.Trigger=9]="Trigger",n))(fD||{});const Mr=te("debuganimatorcontroller"),NS=te("debugrootmotion");class ea{constructor(e){d(this,"_speed",1),d(this,"normalizedStartOffset",0),d(this,"animator"),d(this,"model"),d(this,"_mixer"),d(this,"_activeState"),d(this,"_activeStates",[]),d(this,"_heldActions",[]),d(this,"rootMotionHandler"),this.model=e,Mr&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const r=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(t.autoTransition!==!1){const h=t.transitionDuration??0,u=h/a.duration;let p=o;(t.autoTransition===void 0||t.autoTransition===!0)&&(p=(o+1)%e.length),l.push({exitTime:1-u,offset:0,duration:h,hasExitTime:!0,destinationState:p,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:t?.looping??!1},transitions:l,behaviours:[]};r.push(c)}const s={name:"AnimatorController",guid:new kr(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:r}}]};return new ea(s)}play(e,t=-1,r=Number.NEGATIVE_INFINITY,s=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[t].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){Mr&&console.log("transition to ",a),this.transitionTo(a,s,r);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var r,s;const o=typeof e=="string"?"name":"hash";return(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(a=>a[o]===e).forEach(a=>a.value=t)}getBool(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??!1}setFloat(e,t){var r,s;const o=typeof e=="string"?"name":"hash",a=(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(l=>l[o]===e);return a.forEach(l=>l.value=t),a?.length>0}getFloat(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??0}setInteger(e,t){var r,s;const o=typeof e=="string"?"name":"hash";return(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(a=>a[o]===e).forEach(a=>a.value=t)}getInteger(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??0}setTrigger(e){var t,r;Mr&&console.log("SET TRIGGER",e);const s=typeof e=="string"?"name":"hash";return(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=!0)}resetTrigger(e){var t,r;const s=typeof e=="string"?"name":"hash";return(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=!1)}getTrigger(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.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 t of this.model.layers)for(const r of t.stateMachine.states)if(r.name===e||r.hash==e)return r}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,r=t<=0?0:Math.abs(e.time/t);return new MA(this._activeState,r,t,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 t of this._activeStates)t.motion.clip&&this.mixer.uncacheAction(t.motion.clip,this.animator.gameObject)}(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)}bind(e){var t,r;e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),(t=this.context)==null||t.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new Ox(this.animator.gameObject),(r=this.context)==null||r.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;Mr&&console.warn("AnimatorController clone()",this.model);const e=Nv(this.model,(t,r,s)=>s==null?!0:!(s.type==="Object3D"||s.isObject3D===!0||tz(s)||s.tracks!==void 0||s instanceof ea));return console.assert(e!==this.model),new ea(e)}update(e){var t,r;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const s=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(e)),this._mixer.update(s),this.animator.applyRootMotion&&((r=this.rootMotionHandler)==null||r.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const r=this._activeStates[t],s=r.motion;if(!s.action)this._activeStates.splice(t,1),t--;else{const o=s.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(Mr&&console.debug("REMOVE",r.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){var e;this.model.layers.length>1&&(Mr||st())&&console.warn("Multiple layers are not supported yet "+((e=this.animator)==null?void 0:e.name));for(const t of this.model.layers){const r=t.stateMachine;r.defaultState===void 0&&(Mr&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",t),r.defaultState=0);const s=r.states[r.defaultState];this.transitionTo(s,0,this.normalizedStartOffset);break}}evaluateTransitions(){var e;let t=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;t=!0}const r=this._activeState,s=r.motion.action;for(const a of r.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(s){const c=r.motion.clip.duration,h=c<=0?1:Math.abs(s.time/c);let u=a.exitTime;s.timeScale<0&&(u=1-u);let p=!1;if(a.hasExitTime?p=h>=u:p=!0,p){for(const m of a.conditions){const f=this.model.parameters.find(g=>g.name===m.parameter);f?.type===fD.Trigger&&f.value&&(f.value=!1)}if(s.clampWhenFinished=!0,Mr){const m=this.getState(a.destinationState,0);console.log(`Transition to ${a.destinationState} / ${m?.name}`,a,`
5671
+ Using the assigned clip instead:`,this.clip),n=this.clip);let s=!this.sound||n&&n!==this.clip;if(typeof n=="string"&&!this.audioLoader&&(s=!0),(n instanceof MediaStream||typeof n=="string")&&(this.clip=n),s){this.shouldPlay=!0,this.onNewClip(n);return}if(this.shouldPlay=!0,this._hasEnded=!1,Es&&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),(t=this.gameObject)==null||t.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||(r=this.context.domElement.shadowRoot)==null||r.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;Es&&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;Es&&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,Es&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}get isPlaying(){var n;return((n=this.sound)==null?void 0:n.isPlaying)??!1}set isPlaying(n){}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()}}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,Es&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let Mn=$u;Kl([w(URL)],Mn.prototype,"clip",2),Kl([w()],Mn.prototype,"playOnAwake",2),Kl([w()],Mn.prototype,"preload",2),Kl([w()],Mn.prototype,"loop",1),Kl([w()],Mn.prototype,"spatialBlend",1),Kl([w()],Mn.prototype,"minDistance",1),Kl([w()],Mn.prototype,"maxDistance",1),Kl([w()],Mn.prototype,"volume",1),Kl([w()],Mn.prototype,"rollOffMode",2),Kl([w()],Mn.prototype,"playInBackground",2);var Ype=Object.defineProperty,Jpe=Object.getOwnPropertyDescriptor,OS=(n,e,t,r)=>{for(var s=r>1?void 0:r?Jpe(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&Ype(e,t,s),s};const Kpe=te("debugsignals");class xA{constructor(){d(this,"guid")}}OS([w()],xA.prototype,"guid",2);class Yg{constructor(){d(this,"signal"),d(this,"reaction")}}OS([w(xA)],Yg.prototype,"signal",2),OS([w(Un)],Yg.prototype,"reaction",2);var uD;const Ah=(uD=class extends Be{constructor(){super(...arguments),d(this,"events")}static invoke(n){if(Ah.receivers[n]){const e=Ah.receivers[n];if(!e)return;for(const t of e)t.invoke(n)}}awake(){Kpe&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const n of this.events)Ah.receivers[n.signal.guid]||(Ah.receivers[n.signal.guid]=[]),Ah.receivers[n.signal.guid].push(this)}onDisable(){if(this.events){for(const n of this.events)if(Ah.receivers[n.signal.guid]){const e=Ah.receivers[n.signal.guid].indexOf(this);e>=0&&Ah.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 t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(r){console.error(r)}}},d(uD,"receivers",{}),uD);let Jg=Ah;OS([w(Yg)],Jg.prototype,"events",2);var zo=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(zo||{}),Zl=(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))(Zl||{}),dD=(n=>(n.Signal="SignalEmitter",n))(dD||{});const $l=te("debugtimeline");class wA{constructor(){d(this,"director"),d(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let r=this.track.clips.length-1;r>=0;r--)yield this.track.clips[r];else for(const r of this.track.clips)yield r}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,r,s=!0){if(t<0||t>=r.length)return 0;const o=r[t];if(s||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 Zpe{constructor(e){d(this,"clip"),d(this,"rootPositionOffset"),d(this,"rootQuaternionOffset"),d(this,"rootStartPosition"),d(this,"rootEndPosition"),d(this,"rootStartQuaternion"),d(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const r=e.getRoot(),s=r.name+".position",o=r.name+".quaternion";$l&&console.log(t.name,t.tracks,s);for(const a of t.tracks)if(!(a.times.length<=0)){if(a.name.endsWith(s))this.rootStartPosition=new C().fromArray(a.values,0),this.rootEndPosition=new C().fromArray(a.values,a.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$l&&console.log(this.rootPositionOffset);else if(a.name.endsWith(o)&&(this.rootStartQuaternion=new Ce().fromArray(a.values,0),this.rootEndQuaternion=new Ce().fromArray(a.values,a.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$l)){const l=new pi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",l)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class LS extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"trackOffset"),d(this,"target"),d(this,"mixer"),d(this,"clips",[]),d(this,"actions",[]),d(this,"_actionOffsets",[]),d(this,"_didBind",!1),d(this,"_animator",null),d(this,"_useclipOffsets",!0),d(this,"_totalOffsetPosition",new C),d(this,"_totalOffsetRotation",new Ce),d(this,"_totalOffsetPosition2",new C),d(this,"_totalOffsetRotation2",new Ce),d(this,"_summedPos",new C),d(this,"_tempPos",new C),d(this,"_summedRot",new Ce),d(this,"_tempRot",new Ce),d(this,"_clipRotQuat",new Ce)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&vQ(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var r,s;if(((r=t.tracks)==null?void 0:r.length)<=0){console.warn("No tracks in AnimationClip",t);return}const o=t.tracks[0].name.split("."),a=o[o.length-2],l=a+".position",c=a+".quaternion";let h=!1,u=!1;for(const p of t.tracks)p.name.endsWith(l)?(h=!0,this.createPositionInterpolant(t,e,p)):p.name.endsWith(c)&&(u=!0,this.createRotationInterpolant(t,e,p));if(!h||!u){const p=(s=this.mixer)==null?void 0:s.getRoot(),m=t.tracks[0],f=m.name.lastIndexOf("."),g=m.name.substring(0,f),v=g.substring(g.lastIndexOf(".")+1),A=p.getObjectByName(v);if(A)if(h){if(!u){const y=t.tracks[0].name.substring(0,f)+".quaternion";$l&&console.warn("Create quaternion track",v,A);const _=A.quaternion,b=new sa(y,[0,t.duration],[_.x,_.y,_.z,_.w,_.x,_.y,_.z,_.w]);t.tracks.push(b),this.createRotationInterpolant(t,e,b)}}else{const y=g+".position";$l&&console.warn("Create position track",v,A);const _=A.position,b=new Dl(y,[0,t.duration],[_.x,_.y,_.z,_.x,_.y,_.z]);t.tracks.push(b),this.createPositionInterpolant(t,e,b)}}}bind(){if(!this._didBind){this._didBind=!0,$l&&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 t=new Zpe(e);this._actionOffsets.push(t)}this.target&&(this._animator=ie.getComponent(this.target,Wr)??null,this._animator&&vQ(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,r=t.position,s=t.rotation;r&&r.x!==void 0&&(r.isVector3||(t.position=new C(r.x,r.y,r.z)),s.isQuaternion||(t.rotation=new Ce(s.x,s.y,s.z,s.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new C(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ce(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,r,s,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,u=0,p=!1,m=!1,f=0;for(let g=0;g<this.clips.length;g++){const v=this.models[g],A=this.actions[g],y=v.asset;A.weight=0;const _=e>=v.start&&e<=v.end,b=v.preExtrapolationMode,x=v.postExtrapolationMode,E=g<this.clips.length-1?this.models[g+1]:null;let I=_,T=!1;if(!I&&!p&&v.end<e&&x!==Zl.None?(!E||E.start>e)&&(I=!0,p=!0):g==0&&!I&&!m&&v.start>e&&b!==Zl.None&&(!E||E.start<e)&&(I=!0,T=!0,m=!0),I){let R=1;R*=this.evaluateWeight(e,g,this.models,I),R*=this.director.weight;let k=_;if(T)switch(b){case Zl.Hold:break;case Zl.Loop:e+=v.start,k=!0;break;default:e+=v.start,k=!0;break}let M=this.getClipTime(e,v),P=0;const z=y.duration;if(T&&b===Zl.Hold&&(M=0),k){if(y.loop)for(P+=Math.floor(M/(z+1e-6));M>z;)M-=z}else if(!_&&p)switch(x){case Zl.Hold:M=this.getClipTime(v.end,v);break;case Zl.Loop:M%=z;break;case Zl.PingPong:const L=Math.floor(M/z)%2!==0;M%=z,L&&(M=z-M);break}v.reversed===!0?A.time=A.getClip().duration-M:A.time=M,A.timeScale=0;const Q=Math.max(0,R);if(A.weight=Q,f+=Q,A.clampWhenFinished=!1,A.isRunning()||A.play(),this._useclipOffsets){const L=h==0?this._totalOffsetPosition:this._totalOffsetPosition2,H=h==0?this._totalOffsetRotation:this._totalOffsetRotation2;h<1&&(u=1-R),h+=1;const O=this._summedPos.set(0,0,0),F=this._tempPos.set(0,0,0),G=this._summedRot.identity(),Y=this._tempRot.identity(),K=y.rotation;K&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(K,R));const oe=this._actionOffsets[g];if(oe.hasOffsets)for(let we=0;we<P;we++)oe.rootPositionOffset?F.copy(oe.rootPositionOffset):F.set(0,0,0),F.applyQuaternion(G),this._clipRotQuat&&F.applyQuaternion(this._clipRotQuat),oe.rootQuaternionOffset&&(Y.copy(oe.rootQuaternionOffset),G.multiply(Y)),O.add(F);this._clipRotQuat&&H.multiply(this._clipRotQuat),H.multiply(G),y.position&&O.add(y.position),L.add(O)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&($l||st())&&(r=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&r.mixer&&this.mixer!==((o=(s=this._animator)==null?void 0:s.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,t,r){var s;const o=r.createInterpolant.bind(r),a=new Ce;this.ensureTrackOffsets();const l=(s=this.trackOffset)==null?void 0:s.rotation;r.createInterpolant=()=>{const c=o(),h=c.evaluate.bind(c);return c.evaluate=u=>{var p;const m=h(u);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)(p=f?.onTimelineRotation)==null||p.call(f,this.director,this.target,u,a);return m[0]=a.x,m[1]=a.y,m[2]=a.z,m[3]=a.w,m},c}}createPositionInterpolant(e,t,r){var s,o;const a=r.createInterpolant.bind(r),l=new C;this.ensureTrackOffsets();const c=(s=this.trackOffset)==null?void 0:s.rotation,h=(o=this.trackOffset)==null?void 0:o.position;let u;r.createInterpolant=()=>{const p=a(),m=p.evaluate.bind(p);return p.evaluate=f=>{var g,v,A;const y=m(f);if(l.set(y[0],y[1],y[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(v=(g=this._actionOffsets.find(_=>_.clip===e))==null?void 0:g.rootStartPosition)==null?void 0:v.clone()):u!=null&&u.isVector3&&l.sub(u)),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 _ of this.director.animationCallbackReceivers)(A=_?.onTimelinePosition)==null||A.call(_,this.director,this.target,f,l);return y[0]=l.x,y[1]=l.y,y[2]=l.z,y},p}}}const $pe=te("mutetimeline"),SA=class extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"listener"),d(this,"audio",[]),d(this,"audioContextTimeOffset",[]),d(this,"lastTime",0),d(this,"audioSource"),d(this,"_audioLoader",null),d(this,"_playableDirectorResumed",!1)}getAudioFilePath(n){const e=this.director.sourceId;return ou(e,n)}onAllowAudioChanged(n){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(n?t.asset.volume:0)}}addModel(n){const e=new aI(this.listener);this.audio.push(e);const t=n;t._didTriggerPlay=!1,this.models.push(t)}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($pe||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=this._playableDirectorResumed;this._playableDirectorResumed=!1;const r=e?.1:0;for(let s=0;s<this.models.length;s++){const o=this.models[s],a=this.audio[s],l=o.asset;if((!a||!a.buffer)&&this.isInTimeRange(o,n-1,n+1)&&this.handleAudioLoading(o,a),Mn.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)(t||!o._didTriggerPlay&&this.lastTime<n)&&(o.duration*o.timeScale>.3?a.offset=o.clipIn+(n-o.start)*o.timeScale:a.offset=0,$l&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+o.asset.clip),a.play(r),o._didTriggerPlay=!0);else{const h=o.clipIn+(n-o.start)*o.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(h-u)>.3&&(a.offset=h,a.stop(),a.play(r))}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,t=0){let r=null;const s=n-t,o=n+e;for(const a of this.models)if(this.isInTimeRange(a,s,o)){const l=this.audio[this.models.indexOf(a)],c=this.handleAudioLoading(a,l);c!==null&&(r===null&&(r=[]),r.push(c))}return r!==null?Promise.all(r):null}isInTimeRange(n,e,t){return e<=n.start&&t>=n.end||e>=n.start&&e<=n.end||t>=n.start&&t<=n.end}static dispose(){SA._audioBuffers.clear()}handleAudioLoading(n,e){this._audioLoader||(this._audioLoader=new kx);const t=this.getAudioFilePath(n.asset.clip);if(SA._audioBuffers.get(t)){const s=SA._audioBuffers.get(t);return s.then(o=>{o&&e.setBuffer(o)}),s}$l&&console.warn("LOAD audio track",t,this.director.sourceId);const r=new Promise((s,o)=>{this._audioLoader.load(t,a=>{e.setBuffer(a),s(a)},void 0,a=>{console.error("Error loading audio",a),s(null)})});return SA._audioBuffers.set(t,r),r}};let CA=SA;d(CA,"_audioBuffers",new Map);class EA extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"didTrigger",[]),d(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const r=this.director.context.time.deltaTime*1.5;for(let s=0;s<this.models.length;s++){const o=this.models[s],a=this.didTrigger[s],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<r)&&(c=!0)}if(c){if(!a)if($l&&console.log("Trigger signal",e,o.time,o),this.didTrigger[s]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Jg.invoke(o.asset);else for(const h of this.receivers)h&&h.invoke(o.asset)}else o.emitOnce||(this.didTrigger[s]=!1)}}}class FS extends wA{constructor(){super(...arguments),d(this,"models",[]),d(this,"timelines",[]),d(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const r=this.models[t].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",t,r),this.models.splice(t,1);continue}else{const s=ie.getComponent(r.sourceObject,ed);this.timelines.push(s),s&&r.updateDirector&&(s.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let r=0;r<this.models.length;r++){const s=this.models[r],o=s.asset;if(e>=s.start&&e<=s.end){this._previousActiveModel=s;const a=this.getClipTime(e,s);if(o.controlActivation){const l=o.sourceObject;l.visible=!0}if(o.updateDirector){const l=this.timelines[r];l&&(l.isPlaying&&l.pause(),l.time=a,l.evaluate())}}else{const a=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const l=o.sourceObject;a?.sourceObject!==l&&(l.visible=!1)}}}}}var eme=Object.defineProperty,tme=Object.getOwnPropertyDescriptor,gQ=(n,e,t,r)=>{for(var s=r>1?void 0:r?tme(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&eme(e,t,s),s};const Kg=te("debugtimeline");var pD;const mD=(pD=class extends Be{constructor(){super(...arguments),d(this,"playableAsset"),d(this,"playOnAwake"),d(this,"extrapolationMode",1),d(this,"waitForAudio",!0),d(this,"_visibilityChangeEvt"),d(this,"_clonedPlayableAsset",!1),d(this,"_speed",1),d(this,"_guidsMap"),d(this,"_isPlaying",!1),d(this,"_internalUpdateRoutine"),d(this,"_isPaused",!1),d(this,"_isStopping",!1),d(this,"_time",0),d(this,"_duration",0),d(this,"_weight",1),d(this,"_animationTracks",[]),d(this,"_audioTracks",[]),d(this,"_signalTracks",[]),d(this,"_controlTracks",[]),d(this,"_customTracks",[]),d(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),d(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:(Kg||js())&&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,t;Kg&&console.log(this,(n=this.playableAsset)==null?void 0:n.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var n,e,t;for(const r of this._audioTracks)(n=r.onEnable)==null||n.call(r);for(const r of this._customTracks)(e=r.onEnable)==null||e.call(r);for(const r of this._animationTracks)(t=r.onEnable)==null||t.call(r);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,t;this.stop();for(const r of this._audioTracks)(n=r.onDisable)==null||n.call(r);for(const r of this._customTracks)(e=r.onDisable)==null||e.call(r);for(const r of this._animationTracks)(t=r.onDisable)==null||t.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var n;for(const e of this._allTracks)for(const t of e)(n=t.onDestroy)==null||n.call(t)}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 t of this._audioTracks){const r=t.loadAudio(this._time,1,0);r&&e.push(r)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Mn.userInteractionRegistered&&this.waitForAudio;)await Ll(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Hi.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.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 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 t=this._time;for(const r of this.playableAsset.tracks)if(!r.muted)switch(r.type){case zo.Activation:if(!n&&!this._isPlaying)continue;for(let s=0;s<r.outputs.length;s++){const o=r.outputs[s];if(typeof o=="object"){let a=!1;if(r.clips)for(const c of r.clips)c.start<=t&&t<=c.end&&(a=!0);const l=o;l.visible!==void 0&&l.visible!==a&&(l.visible=a,Kg&&console.warn(this.name,"set ActivationTrack-"+s,l.name,a,t))}}break}if(!this._isStopping)for(const r of this._animationTracks)r.evaluate(t);for(const r of this._audioTracks)r.evaluate(t);for(const r of this._signalTracks)r.evaluate(t);for(const r of this._controlTracks)r.evaluate(t);for(const r of this._customTracks)r.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Nv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const n=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let r=e.outputs[t];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const s=ie.findByGuid(r,n);s===null||typeof s!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",r,e.name,e.type)):(Kg&&console.log("Resolved binding",r,"to",s),e.outputs[t]=s)}else if(r===null){if(e.outputs.splice(t,1),mD.createTrackFunctions[e.type])continue;e.type!==zo.Audio&&e.type!==zo.Control&&e.type!==zo.Marker&&e.type!==zo.Signal&&console.warn("Missing binding",r,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===zo.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const r=e.clips[t];let s=r.asset.sourceObject;if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const o=ie.findByGuid(s,n);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",s,e.name,r):(Kg&&console.log("Resolved binding",s,"to",o),r.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,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let r=ie.findObjectOfType(Zu,this.context);for(const s of this.playableAsset.tracks){const o=s.type,a=mD.createTrackFunctions[o];if(a!=null){const l=a(this,s);if(typeof l.evaluate=="function"){l.director=this,l.track=s,this._customTracks.push(l);continue}}if(s.type===zo.Animation){if(!s.clips||s.clips.length<=0){Kg&&console.warn("Animation track has no clips",s);continue}for(let l=s.outputs.length-1;l>=0;l--){let c=s.outputs[l];if(c instanceof Ae){const u=ie.getOrAddComponent(c,Wr);u&&(c=u)}const h=(n=c?.gameObject)==null?void 0:n.animations;if(h){const u=new LS;u.trackOffset=s.trackOffset,u.director=this,u.track=s;for(let p=0;p<s.clips.length;p++){const m=s.clips[p],f=m.asset;if(!f){console.error(`Timeline ${this.name}: clip #${p} on track "${s.name}" has no animation data`);continue}const g=f.clip;let v=g;if((typeof v=="string"||typeof v=="number")&&(v=h.find(y=>y.name===g)),!v){console.warn("Could not find animationClip for model",m,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}c instanceof Wr&&c.runtimeAnimatorController&&(c.__internalDidAwakeAndStart||c.initializeRuntimeAnimatorController(),c.runtimeAnimatorController.mixer||c.runtimeAnimatorController.bind(c),u.mixer=c.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Ox(c.gameObject),this.context.animations.registerAnimationMixer(u.mixer)),u.clips.push(v),u.mixer.uncacheAction(v),u.createHooks(m.asset,v);const A=u.mixer.clipAction(v);u.actions.push(A),u.models.push(m)}this._animationTracks.push(u)}}}else if(s.type===zo.Audio){if(!s.clips||s.clips.length<=0)continue;const l=new CA;l.director=this,l.track=s,l.audioSource=s.outputs.find(c=>c instanceof Mn),this._audioTracks.push(l),r||(r=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(Zu)),l.listener=r.listener;for(let c=0;c<s.clips.length;c++){const h=s.clips[c];l.addModel(h)}}else if(s.type===zo.Marker){const l=new EA;if(l.director=this,l.track=s,s.markers)for(const c of s.markers)switch(c.type){case dD.Signal:l.models.push(c),l.didTrigger.push(!1);break}if(l!==null&&l.models.length>0){const c=ie.getComponent(this.gameObject,Jg);c&&(l.receivers.push(c),this._signalTracks.push(l))}}else if(s.type===zo.Signal){const l=new EA;if(l.director=this,l.track=s,s.markers)for(const c of s.markers)l.models.push(c),l.didTrigger.push(!1);for(const c of s.outputs)l.receivers.push(c);this._signalTracks.push(l)}else if(s.type===zo.Control){const l=new FS;if(l.director=this,l.track=s,s.clips)for(const c of s.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)}},d(pD,"createTrackFunctions",{}),pD);let ed=mD;gQ([w()],ed.prototype,"playOnAwake",2),gQ([w()],ed.prototype,"extrapolationMode",2);const US=Symbol("objectIsAnimatedData");function vQ(n,e,t){if(!n)return;if(n[US]===void 0){if(!t)return;n[US]=new Set}const r=n[US];t?r.add(e):r.has(e)&&r.delete(e)}function ime(n){if(!n)return!1;const e=n[US];return e!==void 0&&e.size>0}ui.registerCallback(Si.ContextCreated,n=>{const e=n.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&n.files)for(const t of n.files)ie.foreachComponent(t.file.scene,r=>{if(r.enabled!==!1){if(r instanceof Cs&&r.playAutomatically||r instanceof Wr||r instanceof ed&&r.playOnAwake===!0)return!0;if(r instanceof Cs)return r.playAutomatically=!0,!0;if(r instanceof ed)return r.playOnAwake=!0,!0}},!0)!==!0&&Bg.assignAnimationsFromFile(t.file,{createAnimationComponent:(r,s)=>fl(r,Cs)})});class nme{constructor(){d(this,"_context")}get context(){return this._context??Dt.Current}get isStateMachineBehaviour(){return!0}}class MA{constructor(e,t,r,s){d(this,"name"),d(this,"nameHash"),d(this,"normalizedTime"),d(this,"length"),d(this,"speed"),d(this,"action"),d(this,"hasTransitions");var o;this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=r,this.speed=s,this.action=e.motion.action||null,this.hasTransitions=((o=e.transitions)==null?void 0:o.length)>0||!1}}function yQ(n,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??hi.generateUUID(),index:-1,clip:new zs(n,0,[])}}var td=(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))(td||{}),fD=(n=>(n[n.Float=1]="Float",n[n.Int=3]="Int",n[n.Bool=4]="Bool",n[n.Trigger=9]="Trigger",n))(fD||{});const Mr=te("debuganimatorcontroller"),NS=te("debugrootmotion");class ea{constructor(e){d(this,"_speed",1),d(this,"normalizedStartOffset",0),d(this,"animator"),d(this,"model"),d(this,"_mixer"),d(this,"_activeState"),d(this,"_activeStates",[]),d(this,"_heldActions",[]),d(this,"rootMotionHandler"),this.model=e,Mr&&console.log(this)}static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const r=[];for(let o=0;o<e.length;o++){const a=e[o],l=[];if(t.autoTransition!==!1){const h=t.transitionDuration??0,u=h/a.duration;let p=o;(t.autoTransition===void 0||t.autoTransition===!0)&&(p=(o+1)%e.length),l.push({exitTime:1-u,offset:0,duration:h,hasExitTime:!0,destinationState:p,conditions:[]})}const c={name:a.name,hash:o,motion:{name:a.name,clip:a,isLooping:t?.looping??!1},transitions:l,behaviours:[]};r.push(c)}const s={name:"AnimatorController",guid:new kr(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:r}}]};return new ea(s)}play(e,t=-1,r=Number.NEGATIVE_INFINITY,s=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[t].stateMachine;for(const a of o.states)if(a.name===e||a.hash===e){Mr&&console.log("transition to ",a),this.transitionTo(a,s,r);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){var r,s;const o=typeof e=="string"?"name":"hash";return(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(a=>a[o]===e).forEach(a=>a.value=t)}getBool(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??!1}setFloat(e,t){var r,s;const o=typeof e=="string"?"name":"hash",a=(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(l=>l[o]===e);return a.forEach(l=>l.value=t),a?.length>0}getFloat(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??0}setInteger(e,t){var r,s;const o=typeof e=="string"?"name":"hash";return(s=(r=this.model)==null?void 0:r.parameters)==null?void 0:s.filter(a=>a[o]===e).forEach(a=>a.value=t)}getInteger(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.value)??0}setTrigger(e){var t,r;Mr&&console.log("SET TRIGGER",e);const s=typeof e=="string"?"name":"hash";return(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=!0)}resetTrigger(e){var t,r;const s=typeof e=="string"?"name":"hash";return(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.filter(o=>o[s]===e).forEach(o=>o.value=!1)}getTrigger(e){var t,r,s;const o=typeof e=="string"?"name":"hash";return((s=(r=(t=this.model)==null?void 0:t.parameters)==null?void 0:r.find(a=>a[o]===e))==null?void 0:s.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 t of this.model.layers)for(const r of t.stateMachine.states)if(r.name===e||r.hash==e)return r}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,r=t<=0?0:Math.abs(e.time/t);return new MA(this._activeState,r,t,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 t of this._activeStates)t.motion.clip&&this.mixer.uncacheAction(t.motion.clip,this.animator.gameObject)}(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)}bind(e){var t,r;e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),(t=this.context)==null||t.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new Ox(this.animator.gameObject),(r=this.context)==null||r.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;Mr&&console.warn("AnimatorController clone()",this.model);const e=Nv(this.model,(t,r,s)=>s==null?!0:!(s.type==="Object3D"||s.isObject3D===!0||tz(s)||s.tracks!==void 0||s instanceof ea));return console.assert(e!==this.model),new ea(e)}update(e){var t,r;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const s=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(e)),this._mixer.update(s),this.animator.applyRootMotion&&((r=this.rootMotionHandler)==null||r.onAfterUpdate(e))}get activeState(){return this._activeState}updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const r=this._activeStates[t],s=r.motion;if(!s.action)this._activeStates.splice(t,1),t--;else{const o=s.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(Mr&&console.debug("REMOVE",r.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){var e;this.model.layers.length>1&&(Mr||st())&&console.warn("Multiple layers are not supported yet "+((e=this.animator)==null?void 0:e.name));for(const t of this.model.layers){const r=t.stateMachine;r.defaultState===void 0&&(Mr&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",t),r.defaultState=0);const s=r.states[r.defaultState];this.transitionTo(s,0,this.normalizedStartOffset);break}}evaluateTransitions(){var e;let t=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;t=!0}const r=this._activeState,s=r.motion.action;for(const a of r.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(s){const c=r.motion.clip.duration,h=c<=0?1:Math.abs(s.time/c);let u=a.exitTime;s.timeScale<0&&(u=1-u);let p=!1;if(a.hasExitTime?s.timeScale>0?p=h>=a.exitTime:s.timeScale<0&&(p=1-h>=a.exitTime):p=!0,p){for(const m of a.conditions){const f=this.model.parameters.find(g=>g.name===m.parameter);f?.type===fD.Trigger&&f.value&&(f.value=!1)}if(s.clampWhenFinished=!0,Mr){const m=this.getState(a.destinationState,0);console.log(`Transition to ${a.destinationState} / ${m?.name}`,a,`
5672
5672
  Timescale: `+s.timeScale,`
5673
5673
  Normalized time: `+h.toFixed(3),`
5674
5674
  Exit Time: `+u,a.hasExitTime)}this.transitionTo(a.destinationState,a.duration,a.offset);return}}else{this.transitionTo(a.destinationState,a.duration,a.offset);return}}s&&this.setTimescale(s,r);let o=!1;if(r.motion.isLooping&&s&&(s.time>=s.getClip().duration?(o=!0,s.reset(),s.time=0,s.play()):s.time<=0&&s.timeScale<0&&(o=!0,s.reset(),s.time=s.getClip().duration,s.play())),!o&&r&&!t&&s&&this.animator&&r.behaviours){const a=s?.getClip().duration,l=s.time/a,c=new MA(this._activeState,l,a,this._speed);for(const h of r.behaviours)h.instance&&((e=h.instance.onStateUpdate)==null||e.call(h.instance,this.animator,c,0))}}setTimescale(e,t){let r=t.speed??1;t.speedParameter&&(r*=this.getFloat(t.speedParameter)),r!==void 0&&(e.timeScale=r*this._speed)}getState(e,t){return typeof e=="number"&&(e==-1&&(e=this.model.layers[t].stateMachine.defaultState,e===void 0&&(Mr&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+t),e=0)),e=this.model.layers[t].stateMachine.states[e]),e}releaseHeldActions(e){for(const t of this._heldActions)t.fadeOut(e);this._heldActions.length=0}transitionTo(e,t,r){var s,o,a,l,c,h,u,p;if(!this.animator)return;const m=0;if(e=this.getState(e,m),!(e!=null&&e.motion)||!e.motion.clip||!(e.motion.clip instanceof zs))return;const f=this._activeState===e;if(f){const _=e.motion;if(!_.action_loopback&&_.clip){const b=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(_.clip,this.animator.gameObject),b&&b.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),_.action_loopback=this.createAction(_.clip)}}if((s=this._activeState)!=null&&s.behaviours&&this._activeState.motion.action){const _=(o=this._activeState)==null?void 0:o.motion.clip.duration,b=this._activeState.motion.action.time/_,x=new MA(this._activeState,b,_,this._speed);for(const E of this._activeState.behaviours)(l=(a=E.instance)==null?void 0:a.onStateExit)==null||l.call(E.instance,this.animator,x,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 A=(h=e.motion)==null?void 0:h.action,y=e.motion.clip;if(y?.duration<=0&&y.tracks.length<=0?g&&this._heldActions.push(g):g&&(g.fadeOut(t),this.releaseHeldActions(t)),A){if(r=Math.max(0,Math.min(1,r)),e.cycleOffsetParameter){let b=this.getFloat(e.cycleOffsetParameter);typeof b=="number"?(b<0&&(b+=1),r+=b,r%=1):Mr&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(r+=e.cycleOffset,r%=1);A.isRunning()&&A.stop(),A.reset(),A.enabled=!0,this.setTimescale(A,e);const _=e.motion.clip.duration;if(A.time=f?0:r*_,A.timeScale<0&&(A.time=_-A.time),A.clampWhenFinished=!0,A.setLoop(nv,0),t>0?A.fadeIn(t):A.weight=1,A.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(A),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const b=new MA(e,r,_,this._speed);for(const x of this._activeState.behaviours)(p=(u=x.instance)==null?void 0:u.onStateEnter)==null||p.call(x.instance,this.animator,b,m)}}else Mr&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));Mr&&console.log("TRANSITION FROM "+v?.name+" TO "+e.name,t,g,A,A?.getEffectiveTimeScale(),A?.getEffectiveWeight(),A?.isRunning(),A?.isScheduled(),A?.paused)}createAction(e){var t,r;if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,(t=this.animator)==null?void 0:t.gameObject),(r=this.animator)!=null&&r.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new rme(this));const s=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,s,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const t=this.model.parameters.find(r=>r.name===e.parameter);if(!t)return!1;switch(e.mode){case td.If:return t.value===!0;case td.IfNot:return t.value===!1;case td.Greater:return t.value>e.threshold;case td.Less:return t.value<e.threshold;case td.Equals:return t.value===e.threshold;case td.NotEqual:return t.value!==e.threshold}return!1}createActions(e){var t,r,s,o;Mr&&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 u of h.transitions)u.conditions||(u.conditions=[]);if(h.motion||(Mr&&console.warn("No motion",h),h.motion=yQ(h.name)),this.animator&&h.motion.clips){const u=(t=h.motion.clips)==null?void 0:t.find(p=>{var m,f;return p.node.name===((f=(m=this.animator)==null?void 0:m.gameObject)==null?void 0:f.name)});u?h.motion.clip=u.clip:(Mr||st())&&console.warn('Could not find clip for animator "'+((s=(r=this.animator)==null?void 0:r.gameObject)==null?void 0:s.name)+'"',h.motion.clips.map(p=>p.node.name))}if(!h.motion.clip){Mr&&console.warn("No clip assigned to state",h);const u=new zs(void 0,void 0,[]);h.motion.clip=u}if((o=h.motion)!=null&&o.clip){const u=h.motion.clip;if(u instanceof zs){const p=this.createAction(u);h.motion.action=p}else(Mr||st())&&console.warn("No valid animationclip assigned",h)}if(h.behaviours&&Array.isArray(h.behaviours))for(const u of h.behaviours){if(!(u!=null&&u.typeName))continue;const p=q.get(u.typeName),m=new p;m.isStateMachineBehaviour&&(m._context=this.context??void 0,Rg(m,u.properties),u.instance=m),Mr&&console.log("Created animator controller behaviour",h.name,u.typeName,u.properties,m)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let r=0;r<t.states.length;r++){const s=t.states[r];s!=null&&s.motion&&(s.motion.action&&(yield s.motion.action),s.motion.action_loopback&&(yield s.motion.action_loopback))}}}}class AQ{constructor(e,t){d(this,"track"),d(this,"createdInterpolant"),d(this,"originalEvaluate"),d(this,"customEvaluate"),this.track=e;const r=e,s=r.createInterpolant.bind(e);r.createInterpolant=()=>(r.createInterpolant=s,this.createdInterpolant=s(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=o=>{if(!this.originalEvaluate)return;const a=this.originalEvaluate(o);return t(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 Tr=class{constructor(n,e,t,r,s){if(d(this,"_action"),d(this,"root"),d(this,"clip"),d(this,"positionWrapper",null),d(this,"rotationWrapper",null),d(this,"context"),d(this,"positionChange",new C),d(this,"rotationChange",new Ce),d(this,"_prevTime",0),this.context=n,this.root=e,this.clip=t,Tr.firstKeyframeRotation[this.cacheId]||(Tr.firstKeyframeRotation[this.cacheId]=new Ce),s){const o=s.values;Tr.firstKeyframeRotation[this.cacheId].set(o[0],o[1],o[2],o[3])}Tr.spaceRotation[this.cacheId]||(Tr.spaceRotation[this.cacheId]=new Ce),Tr.effectiveSpaceRotation[this.cacheId]||(Tr.effectiveSpaceRotation[this.cacheId]=new Ce),Tr.clipOffsetRotation[this.cacheId]=new Ce,s&&Tr.clipOffsetRotation[this.cacheId].set(s.values[0],s.values[1],s.values[2],s.values[3]).invert(),this.handlePosition(t,r),this.handleRotation(t,s)}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;Tr.lastObjRotation[this.cacheId]||(Tr.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const e=Tr.lastObjRotation[this.cacheId];if(Tr.spaceRotation[this.cacheId].copy(e),NS){const t=new pi().setFromQuaternion(e);console.log("START",this.clip.name,it.toDegrees(t.y),this.root.position.z)}}getClipRotationOffset(){return Tr.clipOffsetRotation[this.cacheId]}handlePosition(n,e){if(e){const t=this.root;NS&&t.add(new Po),Tr.lastObjPosition[this.cacheId]||(Tr.lastObjPosition[this.cacheId]=this.root.position.clone());const r=new C,s=new C;this.positionWrapper=new AQ(e,(o,a)=>{const l=this.action.getEffectiveWeight();return NS&&t.position.length()>8&&t.position.set(0,t.position.y,0),o>this._prevTime&&(r.set(a[0],a[1],a[2]),r.sub(s),r.multiplyScalar(l),r.applyQuaternion(this.getClipRotationOffset()),r.applyQuaternion(t.quaternion),this.positionChange.copy(r)),s.fromArray(a),this._prevTime=o,a[0]=0,a[1]=0,a[2]=0,a})}}handleRotation(n,e){if(e){if(NS){const o=e.values,a=new pi().setFromQuaternion(new Ce(o[0],o[1],o[2],o[3]));console.log(n.name,e.name,"FIRST ROTATION IN TRACK",it.toDegrees(a.y));const l=e.values.length-4,c=new Ce().set(o[l],o[l+1],o[l+2],o[l+3]),h=new pi().setFromQuaternion(c);console.log(n.name,e.name,"LAST ROTATION IN TRACK",it.toDegrees(h.y))}let t=0;const r=new Ce,s=new Ce;this.rotationWrapper=new AQ(e,(o,a)=>(o>t&&(s.set(a[0],a[1],a[2],a[3]),r.invert(),s.multiply(r),this.rotationChange.copy(s)),r.fromArray(a),t=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(Tr.identityQuaternion,1-n),!0)}};let id=Tr;d(id,"lastObjPosition",{}),d(id,"lastObjRotation",{}),d(id,"firstKeyframeRotation",{}),d(id,"spaceRotation",{}),d(id,"effectiveSpaceRotation",{}),d(id,"clipOffsetRotation",{}),d(id,"identityQuaternion",new Ce);class rme{constructor(e){d(this,"controller"),d(this,"handler",[]),d(this,"root"),d(this,"basePosition",new C),d(this,"baseQuaternion",new Ce),d(this,"baseRotation",new pi),d(this,"summedPosition",new C),d(this,"summedRotation",new Ce),this.controller=e}createClip(e,t,r){this.root=t,t&&"name"in t&&t.name;const s=this.findRootTrack(r,".position"),o=this.findRootTrack(r,".quaternion"),a=new id(this.controller.context,t,r,s,o);this.handler.push(a);const l=e.clipAction(r);return a.action=l,l}onStart(e){for(const t of this.handler)t.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const t of this.handler)t.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 t of this.handler)t.onAfterUpdate(e)&&(this.summedPosition.add(t.positionChange),this.summedRotation.multiply(t.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,t){const r=e.tracks;if(!r)return null;for(const s of r)if(s.name.endsWith(t))return s;return null}}class sme extends ul{onSerialize(e,t){}onDeserialize(e,t){if(t.type===ea&&e?.__type==="AnimatorController")return new ea(e)}}new sme(ea);var ome=Object.defineProperty,ame=Object.getOwnPropertyDescriptor,zS=(n,e,t,r)=>{for(var s=r>1?void 0:r?ame(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&ome(e,t,s),s};const Ma=te("debuganimator");class Wr extends Be{constructor(){super(...arguments),d(this,"applyRootMotion",!1),d(this,"hasRootMotion",!1),d(this,"keepAnimatorControllerStateOnDisable",!1),d(this,"_parametersAreDirty",!1),d(this,"_isDirty",!1),d(this,"_speed",1),d(this,"_normalizedStartOffset",0),d(this,"_animatorController",null),d(this,"_initializeWithRuntimeAnimatorController")}get isAnimationComponent(){return!0}set runtimeAnimatorController(e){var t;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",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new ea(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Ma&&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,t=-1,r=Number.NEGATIVE_INFINITY,s=0){this.play(e,t,r,s)}play(e,t=-1,r=Number.NEGATIVE_INFINITY,s=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,r,s),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var r,s;Ma&&console.log("setBool",e,t),((r=this.runtimeAnimatorController)==null?void 0:r.getBool(e))!==t&&(this._parametersAreDirty=!0),(s=this.runtimeAnimatorController)==null||s.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var t;const r=((t=this.runtimeAnimatorController)==null?void 0:t.getBool(e))??!1;return Ma&&console.log("getBool",e,r),r}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var r,s;((r=this.runtimeAnimatorController)==null?void 0:r.getFloat(e))!==t&&(this._parametersAreDirty=!0),Ma&&console.log("setFloat",e,t),(s=this.runtimeAnimatorController)==null||s.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var t;const r=((t=this.runtimeAnimatorController)==null?void 0:t.getFloat(e))??-1;return Ma&&console.log("getFloat",e,r),r}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var r,s;((r=this.runtimeAnimatorController)==null?void 0:r.getInteger(e))!==t&&(this._parametersAreDirty=!0),Ma&&console.log("setInteger",e,t),(s=this.runtimeAnimatorController)==null||s.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var t;const r=((t=this.runtimeAnimatorController)==null?void 0:t.getInteger(e))??-1;return Ma&&console.log("getInteger",e,r),r}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;this._parametersAreDirty=!0,Ma&&console.log("setTrigger",e),(t=this.runtimeAnimatorController)==null||t.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;this._parametersAreDirty=!0,Ma&&console.log("resetTrigger",e),(t=this.runtimeAnimatorController)==null||t.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var t;const r=(t=this.runtimeAnimatorController)==null?void 0:t.getTrigger(e);return Ma&&console.log("getTrigger",e,r),r}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 t;e!==this._speed&&(Ma&&console.log("setSpeed",e),this._speed=e,((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){var t;this._speed=it.lerp(e.x,e.y,Math.random()),((t=this._animatorController)==null?void 0:t.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){var t;this._normalizedStartOffset=it.lerp(e.x,e.y,Math.random()),((t=this.runtimeAnimatorController)==null?void 0:t.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){Ma&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const r=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=r,r?(console.assert(this.runtimeAnimatorController!==r),this.runtimeAnimatorController=r,console.assert(this.runtimeAnimatorController===r),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,!ime(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}zS([w()],Wr.prototype,"applyRootMotion",2),zS([w()],Wr.prototype,"hasRootMotion",2),zS([w()],Wr.prototype,"keepAnimatorControllerStateOnDisable",2),zS([w()],Wr.prototype,"runtimeAnimatorController",1);const ec=te("debugusdzanimation"),gD=te("debugusdzanimationserialization");class jS{constructor(e,t,r){d(this,"_start"),d(this,"ext"),d(this,"root"),d(this,"clip"),d(this,"speed"),this.ext=e,this.root=t,this.clip=r}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){var e;return((e=this.clip)==null?void 0:e.duration)??Ir.restPoseClipDuration}}const bQ=class{constructor(n,e,t){d(this,"clip"),d(this,"pos"),d(this,"rot"),d(this,"scale"),d(this,"root"),d(this,"target"),d(this,"duration",0),d(this,"useRootMotion",!1),this.root=n,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=bQ.restPoseClipDuration;const r=ie.getComponent(n,Wr);r&&(this.useRootMotion=r.applyRootMotion)}get frameRate(){return 60}addTrack(n){var e,t;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 "+(((t=this.root)==null?void 0:t.name)??this.target.name)+". Only .position, .rotation, .scale are supported."),st()&&ki("[USDZ] Some animations can't be exported. See console for details."))}getFrames(){var n,e,t,r,s,o;return this.clip?Math.max(((e=(n=this.pos)==null?void 0:n.times)==null?void 0:e.length)??0,((r=(t=this.rot)==null?void 0:t.times)==null?void 0:r.length)??0,((o=(s=this.scale)==null?void 0:s.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(n=!0,e=!0,t=!0){var r,s,o;if(!this.clip)return[0,this.duration];const a=(r=this.pos)==null?void 0:r.times,l=(s=this.rot)==null?void 0:s.times,c=(o=this.scale)==null?void 0:o.times,h=[];if(n&&a)for(const u of a)h.push(u);if(e&&l)for(const u of l)h.push(u);if(t&&c)for(const u of c)h.push(u);return h.includes(0)||h.push(0),h.sort((u,p)=>u-p),[...new Set(h)]}*getValues(n,e=!0,t=!0,r=!0){var s,o,a;const l=new C,c=new Ce,h=new C(1,1,1),u=this.target,p=e?(s=this.pos)==null?void 0:s.createInterpolant():void 0,m=t?(o=this.rot)==null?void 0:o.createInterpolant():void 0,f=r?(a=this.scale)==null?void 0:a.createInterpolant():void 0;p||l.set(u.position.x,u.position.y,u.position.z),m||c.set(u.quaternion.x,u.quaternion.y,u.quaternion.z,u.quaternion.w),f||h.set(u.scale.x,u.scale.y,u.scale.z);for(let g=0;g<n.length;g++){const v=n[g];if(p){const A=p.evaluate(v);l.set(A[0],A[1],A[2])}if(m){const A=m.evaluate(v);c.set(A[0],A[1],A[2],A[3])}if(f){const A=f.evaluate(v);h.set(A[0],A[1],A[2])}if(this.useRootMotion&&u===this.root){const A=new ve;A.compose(l,c,h),A.multiply(u.matrix),A.decompose(l,c,h)}yield{time:v,translation:l,rotation:c,scale:h,index:g}}}};let Ir=bQ;d(Ir,"animationDurationPadding",1/60),d(Ir,"restPoseClipDuration",1/60);class TA{constructor(e){d(this,"dict",new Map),d(this,"rootTargetMap",new Map),d(this,"rootAndClipToRegisteredAnimationMap",new Map),d(this,"rootToRegisteredClip",new Map),d(this,"serializers",[]),d(this,"injectRestPoses",!1),d(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(Ir.restPoseClipDuration+Ir.animationDurationPadding)*60}getEndTimeCode(){let e=0;for(const[t,r]of this.rootAndClipToRegisteredAnimationMap){const s=r.start+r.duration;s>e&&(e=s)}return e*60}getClipCount(e){var t;return((t=this.rootToRegisteredClip.get(e))==null?void 0:t.length)??0??0}getStartTime01(e,t){if(!t)return 0;const r=this.rootTargetMap.get(e);if(!r)return 0;const s=this.dict.get(r[0]);if(!s)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let o=0;for(let a=0;a<s.length&&s[a].clip!==t;a++)o+=s[a].getDuration()+Ir.animationDurationPadding;return o}registerAnimation(e,t){var r;if(!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const s=e.uuid+(t?.uuid??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(s))return this.rootAndClipToRegisteredAnimationMap.get(s);ec&&console.log("registerAnimation",e,t);const o=this.injectRestPoses?1:0,a=(((r=this.rootToRegisteredClip.get(e))==null?void 0:r.length)??0)+o,l=this.rootTargetMap.get(e),c=new Set(l);if(t&&t.tracks)for(const u of t.tracks){const p=Xt.parseTrackName(u.name),m=Xt.findNode(e,p.nodeName);if(!m){console.warn("no object found for track",u.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]&&(f[0]=new Ir(null,m,null));let g=f[a];g||(g=new Ir(e,m,t),f[a]=g),g.addTrack(u),l!=null&&l.includes(m)||l==null||l.push(m)}ec&&console.log("Unregistered nodes for this clip",c,"clip",t,"at slot",a,"for root",e,"targets",l);for(const u of c){const p=this.dict.get(u);if(!p)continue;if(this.injectRestPoses&&!p[0]){console.warn("Adding rest pose for ",u,t,"at slot",a,"This is likely a bug, should have been added earlier.");const f=new Ir(null,u,null);p[0]=f}let m=p[a];m||(ec&&console.log("Adding padding clip for ",u,t,"at slot",a),m=new Ir(e,u,t),p[a]=m)}const h=new jS(this,e,t);if(this.rootAndClipToRegisteredAnimationMap.set(s,h),ec&&console.log({root:e,clip:t,info:h}),t){const u=this.rootToRegisteredClip.get(e);u?u.push(t):this.rootToRegisteredClip.set(e,[t])}return h}onAfterHierarchy(e){ec&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,r;ec&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const s of this.rootTargetMap.keys()){const o=this.rootTargetMap.get(s);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 u=0;u<h.length;u++){let p=h[u];if(!p){const f=u-(this.injectRestPoses?1:0);h[u]=new Ir(null,c,this.rootToRegisteredClip.get(s)[f]),p=h[u]}const m=p.getDuration();if(l[u]===void 0)l[u]=m;else if(l[u]!==m){console.error("Error during UDSZ export: Encountered different animation durations for animated targets. Please report a bug!",{datas:h,target:c}),l[u]=m;continue}}}}for(const s of this.serializers){const o=(t=s.model)==null?void 0:t.parent,a=o?.isDynamic===!0;gD&&console.log(a,(r=s.model)==null?void 0:r.parent),a&&s.registerCallback(o)}}onExportObject(e,t,r){ie.foreachComponent(e,o=>{const a=o;typeof a.createAnimation=="function"&&a.createAnimation(this,t,r)},!1);const s=new lme(e,this.dict);this.serializers.push(s),s.registerCallback(t)}}class lme{constructor(e,t){d(this,"object"),d(this,"dict"),d(this,"model"),d(this,"callback"),this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),gD&&console.log("REPARENT",e),this.model=e,this.callback&&this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){var r;const s=this.model,o=this.dict;if(s&&s.skinnedMesh){let a=function(P){const z=[];for(const[Q,L]of P){let H=`${Q} : [`;const O=[];for(const F of L)O.push(`(${Ar(F.x)}, ${Ar(F.y)}, ${Ar(F.z)})`);H=H.concat(O.join(", ")),H=H.concat("],"),z.push(H)}return z},l=function(P){const z=[];for(const[Q,L]of P){let H=`${Q} : [`;const O=[];for(const F of L)O.push(`(${Ar(F.w)}, ${Ar(F.x)}, ${Ar(F.y)}, ${Ar(F.z)})`);H=H.concat(O.join(", ")),H=H.concat("],"),z.push(H)}return z},c=function(P){let z,Q=!0;const L=new Map;for(const[O,F]of P){z===void 0&&(z=F.length),z!==F.length&&(Q=!1);let G=0;for(const Y of F)G++,Y||(L.has(O)||L.set(O,[]),L.get(O).push(G))}ec&&console.log("Bone count: ",P.size,"TransformData entries per bone: ",z,"Undefined bone entries: ",L),console.assert(Q,"All bones should have the same number of TransformData entries",P),console.assert(L.size===0,"All TransformData entries should be set",L);const H=[];for(const[O,F]of P){const G=new Array;let Y=0;for(let K=0;K<F.length;K++)G.push(Y),Y+=F[K].getDuration()+Ir.animationDurationPadding;for(let K=0;K<F.length;K++){const oe=F[K],we=G[K];H.length<=K&&H.push({pos:[],rot:[],scale:[],timeOffset:we});const ke=H[K];ke.pos.push(...oe.getSortedTimesArray(!0,!1,!1)),ke.rot.push(...oe.getSortedTimesArray(!1,!0,!1)),ke.scale.push(...oe.getSortedTimesArray(!1,!1,!0))}}for(const O of H)O.pos.sort((F,G)=>F-G),O.rot.sort((F,G)=>F-G),O.scale.sort((F,G)=>F-G),O.pos=[...new Set(O.pos)],O.rot=[...new Set(O.rot)],O.scale=[...new Set(O.scale)];return H},h=function(P,z,Q){const L=new Map,H=new Map,O=new Map,F=z.length;for(const G of Q){const Y=P.get(G);let K;Y?console.assert(Y.length===F,"We should have the same number of TransformData entries for each bone",Y,z):K=new Ir(null,G,null);for(let oe=0;oe<F;oe++){const we=Y?Y[oe]:K,ke=z[oe];for(const{time:se,translation:be}of we.getValues(ke.pos,!0,!1,!1)){const Ie=(se+ke.timeOffset)*60;L.has(Ie)||L.set(Ie,new Array),L.get(Ie).push(be.clone())}for(const{time:se,rotation:be}of we.getValues(ke.rot,!1,!0,!1)){const Ie=(se+ke.timeOffset)*60;H.has(Ie)||H.set(Ie,new Array),H.get(Ie).push(be.clone())}for(const{time:se,scale:be}of we.getValues(ke.scale,!1,!1,!0)){const Ie=(se+ke.timeOffset)*60;O.has(Ie)||O.set(Ie,new Array),O.get(Ie).push(be.clone())}}}return{position:L.size==0?void 0:L,quaternion:H.size==0?void 0:H,scale:O.size==0?void 0:O}},u=function(P){const z=[];for(const Q of P)z.push(`(${Ar(Q.x)}, ${Ar(Q.y)}, ${Ar(Q.z)})`);return z.join(", ")},p=function(P){const z=[];for(const Q of P)z.push(`(${Ar(Q.w)}, ${Ar(Q.x)}, ${Ar(Q.y)}, ${Ar(Q.z)})`);return z.join(", ")},m=function(P){const z=new Map;if(ec){const Q=new Array;for(const[L,H]of o)Q.push(L.uuid+": "+H.length+" "+H.map(O=>{var F;return(F=O.clip)==null?void 0:F.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
@@ -6150,7 +6150,7 @@ Texture:`,r),this.setLightmapDebugMaterial()):g0&&console.log("Use debuglightmap
6150
6150
  }
6151
6151
  `};class lk extends Pt{constructor(e){super({type:"LineMaterial",uniforms:vf.clone(Lr.line.uniforms),vertexShader:Lr.line.vertexShader,fragmentShader:Lr.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const fV=new C,gV=new C,es=new Ye,ts=new Ye,mc=new Ye,ck=new C,hk=new ve,is=new dI,vV=new C,yC=new bi,AC=new wn,fc=new Ye;let gc,Am;function yV(n,e,t){return fc.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),fc.multiplyScalar(1/fc.w),fc.x=Am/t.width,fc.y=Am/t.height,fc.applyMatrix4(n.projectionMatrixInverse),fc.multiplyScalar(1/fc.w),Math.abs(Math.max(fc.x,fc.y))}function Yge(n,e){const t=n.matrixWorld,r=n.geometry,s=r.attributes.instanceStart,o=r.attributes.instanceEnd,a=Math.min(r.instanceCount,s.count);for(let l=0,c=a;l<c;l++){is.start.fromBufferAttribute(s,l),is.end.fromBufferAttribute(o,l),is.applyMatrix4(t);const h=new C,u=new C;gc.distanceSqToSegment(is.start,is.end,u,h),u.distanceTo(h)<Am*.5&&e.push({point:u,pointOnLine:h,distance:gc.origin.distanceTo(u),object:n,face:null,faceIndex:l,uv:null,uv1:null})}}function Jge(n,e,t){const r=e.projectionMatrix,s=n.material.resolution,o=n.matrixWorld,a=n.geometry,l=a.attributes.instanceStart,c=a.attributes.instanceEnd,h=Math.min(a.instanceCount,l.count),u=-e.near;gc.at(1,mc),mc.w=1,mc.applyMatrix4(e.matrixWorldInverse),mc.applyMatrix4(r),mc.multiplyScalar(1/mc.w),mc.x*=s.x/2,mc.y*=s.y/2,mc.z=0,ck.copy(mc),hk.multiplyMatrices(e.matrixWorldInverse,o);for(let p=0,m=h;p<m;p++){if(es.fromBufferAttribute(l,p),ts.fromBufferAttribute(c,p),es.w=1,ts.w=1,es.applyMatrix4(hk),ts.applyMatrix4(hk),es.z>u&&ts.z>u)continue;if(es.z>u){const y=es.z-ts.z,_=(es.z-u)/y;es.lerp(ts,_)}else if(ts.z>u){const y=ts.z-es.z,_=(ts.z-u)/y;ts.lerp(es,_)}es.applyMatrix4(r),ts.applyMatrix4(r),es.multiplyScalar(1/es.w),ts.multiplyScalar(1/ts.w),es.x*=s.x/2,es.y*=s.y/2,ts.x*=s.x/2,ts.y*=s.y/2,is.start.copy(es),is.start.z=0,is.end.copy(ts),is.end.z=0;const f=is.closestPointToPointParameter(ck,!0);is.at(f,vV);const g=hi.lerp(es.z,ts.z,f),v=g>=-1&&g<=1,A=ck.distanceTo(vV)<Am*.5;if(v&&A){is.start.fromBufferAttribute(l,p),is.end.fromBufferAttribute(c,p),is.start.applyMatrix4(o),is.end.applyMatrix4(o);const y=new C,_=new C;gc.distanceSqToSegment(is.start,is.end,_,y),t.push({point:_,pointOnLine:y,distance:gc.origin.distanceTo(_),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Kge extends pe{constructor(e=new mV,t=new lk({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,r=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let a=0,l=0,c=t.count;a<c;a++,l+=2)fV.fromBufferAttribute(t,a),gV.fromBufferAttribute(r,a),s[l]=l===0?0:s[l-1],s[l+1]=s[l]+fV.distanceTo(gV);const o=new Lx(s,2,1);return e.setAttribute("instanceDistanceStart",new Io(o,1,0)),e.setAttribute("instanceDistanceEnd",new Io(o,1,1)),this}raycast(e,t){const r=this.material.worldUnits,s=e.camera;s===null&&!r&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;gc=e.ray;const a=this.matrixWorld,l=this.geometry,c=this.material;Am=c.linewidth+o,l.boundingSphere===null&&l.computeBoundingSphere(),AC.copy(l.boundingSphere).applyMatrix4(a);let h;if(r)h=Am*.5;else{const p=Math.max(s.near,AC.distanceToPoint(gc.origin));h=yV(s,p,c.resolution)}if(AC.radius+=h,gc.intersectsSphere(AC)===!1)return;l.boundingBox===null&&l.computeBoundingBox(),yC.copy(l.boundingBox).applyMatrix4(a);let u;if(r)u=Am*.5;else{const p=Math.max(s.near,yC.distanceToPoint(gc.origin));u=yV(s,p,c.resolution)}yC.expandByScalar(u),gc.intersectsBox(yC)!==!1&&(r?Yge(this,t):Jge(this,s,t))}}class AV extends mV{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,r=new Float32Array(2*t);for(let s=0;s<t;s+=3)r[2*s]=e[s],r[2*s+1]=e[s+1],r[2*s+2]=e[s+2],r[2*s+3]=e[s+3],r[2*s+4]=e[s+4],r[2*s+5]=e[s+5];return super.setPositions(r),this}setColors(e){const t=e.length-3,r=new Float32Array(2*t);for(let s=0;s<t;s+=3)r[2*s]=e[s],r[2*s+1]=e[s+1],r[2*s+2]=e[s+2],r[2*s+3]=e[s+3],r[2*s+4]=e[s+4],r[2*s+5]=e[s+5];return super.setColors(r),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Zge extends Kge{constructor(e=new AV,t=new lk({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}class bC extends Be{}var $ge=Object.defineProperty,e0e=Object.getOwnPropertyDescriptor,bm=(n,e,t,r)=>{for(var s=r>1?void 0:r?e0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&$ge(e,t,s),s};const bV=te("debugwebxr");class Ba extends Be{constructor(){super(...arguments),d(this,"movementSpeed",1),d(this,"rotationStep",60),d(this,"useTeleport",!0),d(this,"useTeleportTarget",!1),d(this,"useTeleportFade",!1),d(this,"showRays",!0),d(this,"showHits",!0),d(this,"isXRMovementHandler",!0),d(this,"xrSessionMode","immersive-vr"),d(this,"_didApplyRotation",!1),d(this,"_didTeleport",!1),d(this,"_lines",[]),d(this,"_hitDiscs",[]),d(this,"_hitDistances",[]),d(this,"hitPointRaycastFilter",e=>e.type==="SkinnedMesh"?"continue in children":!0)}onUpdateXR(e){const t=e.xr.rig;if(!(t!=null&&t.gameObject)||e.xr.isPassThrough)return;const r=e.xr.leftController,s=e.xr.rightController;r&&this.onHandleMovement(r,t.gameObject),s&&(this.onHandleRotation(s,t.gameObject),this.useTeleport&&this.onHandleTeleport(s,t.gameObject))}onLeaveXR(e){for(const t of this._lines)t.removeFromParent();for(const t of this._hitDiscs)t?.removeFromParent()}onBeforeRender(){var e;(e=this.context.xr)!=null&&e.running&&(this.showRays&&this.renderRays(this.context.xr),this.showHits&&this.renderHits(this.context.xr))}onHandleMovement(e,t){const r=e.getStick("xr-standard-thumbstick"),s=new C(r.x,0,r.y);s.multiplyScalar(this.context.time.deltaTimeUnscaled*this.movementSpeed);const o=Qi(t);s.multiplyScalar(o.x),s.applyQuaternion(e.xr.poseOrientation),s.y=0,s.applyQuaternion(t.worldQuaternion),t.position.add(s),t.updateMatrixWorld()}onHandleRotation(e,t){const r=e.getStick("xr-standard-thumbstick").x;if(this._didApplyRotation)Math.abs(r)<.3&&(this._didApplyRotation=!1);else if(Math.abs(r)>.5){this._didApplyRotation=!0;const s=r>0?1:-1;t.rotateY(s*it.toRadians(this.rotationStep))}}onHandleTeleport(e,t){var r;const s=e.getStick("xr-standard-thumbstick");if(this._didTeleport)s.y<.2&&(this._didTeleport=!1);else if(s.y>.8){this._didTeleport=!0;const o=this.context.physics.raycastFromRay(e.ray)[0];if(o){if(this.useTeleportTarget&&!ie.getComponentInParent(o.object,bC))return;bV&&At.DrawSphere(o.point,.025,16711680,5);const a=o.point.clone();this.useTeleportFade?(r=e.xr.fadeTransition())==null||r.then(()=>{t.worldPosition=a}):t.worldPosition=a}}}renderRays(e){for(let t=0;t<this._lines.length;t++){const r=this._lines[t];r&&(r.visible=!1)}for(let t=0;t<e.controllers.length;t++){const r=e.controllers[t];let s=this._lines[t];if(!r.connected||!r.isTracking||!r.ray||r.targetRayMode==="transient-pointer"||!r.hasSelectEvent){s&&(s.visible=!1);continue}s||(s=this.createRayLineObject(),s.scale.z=.5,this._lines[t]=s),r.updateRayWorldPosition(),r.updateRayWorldQuaternion();const o=r.rayWorldPosition,a=r.rayWorldQuaternion;s.position.copy(o),s.quaternion.copy(a);const l=e.rigScale,c=this._hitDistances[t]??1;s.scale.set(l,l,c),s.visible=!0,s.layers.disableAll(),s.layers.enable(2),s.parent!==this.context.scene&&this.context.scene.add(s)}}renderHits(e){for(const t of this._hitDiscs)t&&(t.visible=!1);for(let t=0;t<e.controllers.length;t++){const r=e.controllers[t];if(!r.connected||!r.isTracking||!r.ray||!r.hasSelectEvent)continue;if(this.context.time.frame%2!==0){const a=this._hitDiscs[t];a&&a.hit&&(a.visible=!0);continue}const s=this.context.physics.raycastFromRay(r.ray,{testObject:this.hitPointRaycastFilter})[0];this._hitDistances[t]=s?.distance;let o=this._hitDiscs[t];if(o&&(o.hit=s),s){const a=e.rigScale??1;bV&&(At.DrawWireSphere(s.point,.025*a,16711680),At.DrawLabel(Di(0,.2,0).add(s.point),s.object.name,.02,0)),o||(o=this.createHitPointObject(),this._hitDiscs[t]=o),o.visible=!0;const l=.01*(a+s.distance);if(o.scale.set(l,l,l),o.layers.disableAll(),o.layers.enable(2),o.hit=s,s.normal){const c=.02*a;o.position.set(0,0,-.1*c).applyQuaternion(r.rayWorldQuaternion),o.position.add(s.point);const h=s.normal.applyQuaternion(Ii(s.object));o.quaternion.setFromUnitVectors(t0e,h)}else o.position.add(s.point);o.parent!==this.context.scene&&this.context.scene.add(o)}else this._hitDiscs[t]&&(this._hitDiscs[t].visible=!1)}}createHitPointObject(){var e=new Ae;const t=new pe(new Wm(.3,.5,32).rotateX(-Math.PI/2),new Jt({color:15658734,opacity:.7,transparent:!0,side:gi}));t.layers.disableAll(),t.layers.enable(2),e.add(t);const r=new pe(new Wm(.43,.5,32).rotateX(-Math.PI/2),new Jt({color:0,opacity:.2,transparent:!0,side:gi}));return r.layers.disableAll(),r.layers.enable(2),r.position.y=.01,e.add(r),e}createRayLineObject(){const e=new Zge;e.layers.disableAll(),e.layers.enable(2);const t=new AV;e.geometry=t;const r=new Float32Array(9);r.set([0,0,.02,0,0,.4,0,0,1]),t.setPositions(r);const s=new Float32Array(9);s.set([1,1,1,.1,.1,.1,0,0,0]),t.setColors(s);const o=new lk({color:16777215,vertexColors:!0,worldUnits:!0,linewidth:.004,transparent:!0,blending:Dd,dashed:!1,alphaToCoverage:!0});return e.material=o,e}}bm([w()],Ba.prototype,"movementSpeed",2),bm([w()],Ba.prototype,"rotationStep",2),bm([w()],Ba.prototype,"useTeleport",2),bm([w()],Ba.prototype,"useTeleportTarget",2),bm([w()],Ba.prototype,"useTeleportFade",2),bm([w()],Ba.prototype,"showRays",2),bm([w()],Ba.prototype,"showHits",2);const t0e=new C(0,1,0);var i0e=Object.defineProperty,n0e=Object.getOwnPropertyDescriptor,xo=(n,e,t,r)=>{for(var s=r>1?void 0:r?n0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&i0e(e,t,s),s};const _C=te("debugwebxr"),r0e=te("debugusdz");class Rr extends Be{constructor(){super(...arguments),d(this,"createVRButton",!0),d(this,"createARButton",!0),d(this,"createSendToQuestButton",!0),d(this,"createQRCode",!0),d(this,"useDefaultControls",!0),d(this,"showControllerModels",!0),d(this,"showHandModels",!0),d(this,"usePlacementReticle",!0),d(this,"usePlacementAdjustment",!0),d(this,"arSceneScale",1),d(this,"useXRAnchor",!1),d(this,"useQuicklookExport",!1),d(this,"useDepthSensing",!1),d(this,"defaultAvatar"),d(this,"_playerSync"),d(this,"_createdComponentsInSession",[]),d(this,"_usdzExporter"),d(this,"_previousXRState",0),d(this,"onAvatarSpawned",e=>{_C&&console.log("WebXR.onAvatarSpawned",e),ie.getComponentInChildren(e,nd)??(i=ie.addComponent(e,nd))}),d(this,"_buttonFactory"),d(this,"_buttons",[])}awake(){Ct.getXRSync(this.context)}onEnable(){var e,t;window.location.protocol!=="https:"&&ki('<a href="https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API" target="_blank">WebXR</a> only works on secure connections (https).'),this.useQuicklookExport&&(ie.findObjectOfType(Rn)||(_C&&console.log("WebXR: Adding USDZExporter"),this._usdzExporter=ie.addComponent(this.gameObject,Rn),this._usdzExporter.objectToExport=this.context.scene,this._usdzExporter.autoExportAnimations=!0,this._usdzExporter.autoExportAudioSources=!0)),this.handleCreatingHTML(),this.handleOfferSession(),this.defaultAvatar&&(this._playerSync=this.gameObject.getOrAddComponent(Zg),this._playerSync.autoSync=!1),this._playerSync&&(this._playerSync.asset=this.defaultAvatar,(e=this._playerSync.onPlayerSpawned)==null||e.removeEventListener(this.onAvatarSpawned),(t=this._playerSync.onPlayerSpawned)==null||t.addEventListener(this.onAvatarSpawned))}onDisable(){var e;(e=this._usdzExporter)==null||e.destroy(),this.removeButtons()}async handleOfferSession(){return this.createVRButton&&await Ct.isVRSupported()&&this.createVRButton?Ct.offerSession("immersive-vr","default",this.context):this.createARButton&&await Ct.isARSupported()&&this.createARButton?Ct.offerSession("immersive-ar","default",this.context):!1}get session(){return Ct.active??null}get sessionMode(){return Ct.activeMode??null}async enterVR(e){return Ct.start("immersive-vr",e,this.context)}async enterAR(e){return Ct.start("immersive-ar",e,this.context)}exitXR(){Ct.stop()}onBeforeXR(e,t){e=="immersive-ar"&&this.useDepthSensing&&(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("depth-sensing"))}async onEnterXR(e){_C&&console.log("WebXR onEnterXR"),this._previousXRState=$s.Global.Mask;const t=e.xr.isVR;if($s.Global.Set(t?ic.VR:ic.AR),this.usePlacementReticle&&e.xr.isAR){let s=ie.findObjectOfType(to);if(s)_C&&console.log("WebXR: WebARSessionRoot already exists, not creating a new one");else{const o=new Ae;for(const a of this.context.scene.children)o.add(a);this.context.scene.add(o),s=ie.addNewComponent(o,to),this._createdComponentsInSession.push(s),s.arScale=this.arSceneScale,s.arTouchTransform=this.usePlacementAdjustment,s.useXRAnchor=this.useXRAnchor}}this.useDefaultControls&&this.setDefaultMovementEnabled(!0),(this.showControllerModels||this.showHandModels)&&this.setDefaultControllerRenderingEnabled(!0);let r=ie.findObjectOfType(AA);r||(r=this.gameObject.addNewComponent(AA)),this.createLocalAvatar(e.xr)}onLeaveXR(e){var t;$s.Global.Set(this._previousXRState),(t=this._playerSync)==null||t.destroyInstance();for(const r of this._createdComponentsInSession)r.destroy();this._createdComponentsInSession.length=0,this.handleOfferSession()}setDefaultMovementEnabled(e){let t=this.gameObject.getComponent(Ba);return!t&&e&&(t=this.gameObject.addComponent(Ba),this._createdComponentsInSession.push(t)),t&&(t.enabled=e),t}setDefaultControllerRenderingEnabled(e){let t=this.gameObject.getComponent(pc);return!t&&e&&(t=this.gameObject.addComponent(pc),this._createdComponentsInSession.push(t),t.createControllerModel=this.showControllerModels,t.createHandModel==this.showHandModels),t&&(t.enabled=e),t}async createLocalAvatar(e){this._playerSync&&e.running&&(this._playerSync.asset=this.defaultAvatar,await this._playerSync.getInstance())}getButtonsContainer(){return this.getButtonsFactory()}getButtonsFactory(){return this._buttonFactory||(this._buttonFactory=ym.getOrCreate()),this._buttonFactory}handleCreatingHTML(){if(this.createARButton||this.createVRButton||this.useQuicklookExport){if((mp()&&Ff()||r0e)&&this.useQuicklookExport){const e=ie.findObjectOfType(Rn);if(!e||e&&e.allowCreateQuicklookButton){const t=this.getButtonsFactory().createQuicklookButton();this.addButton(t,50)}}if(this.createARButton){const e=this.getButtonsFactory().createARButton();this.addButton(e,50)}if(this.createVRButton){const e=this.getButtonsFactory().createVRButton();this.addButton(e,50)}}if(this.createSendToQuestButton&&!qx()&&Ct.isVRSupported().then(e=>{if(!e){const t=this.getButtonsFactory().createSendToQuestButton();this.addButton(t,50)}}),this.createQRCode&&!aa()){const e=wS(uc);e&&e.createQRCodeButton===!1?st()&&console.warn("WebXR: QRCode button is disabled in the Needle Menu component"):Ct.isXRSupported().then(t=>{if(dp()||!t){const r=fh.getOrCreate().createQRCode();this.addButton(r,50)}})}}addButton(e,t){this._buttons.push(e),e.setAttribute("priority",t.toString()),this.context.menu.appendChild(e)}removeButtons(){for(const e of this._buttons)e.remove();this._buttons.length=0}}xo([w()],Rr.prototype,"createVRButton",2),xo([w()],Rr.prototype,"createARButton",2),xo([w()],Rr.prototype,"createSendToQuestButton",2),xo([w()],Rr.prototype,"createQRCode",2),xo([w()],Rr.prototype,"useDefaultControls",2),xo([w()],Rr.prototype,"showControllerModels",2),xo([w()],Rr.prototype,"showHandModels",2),xo([w()],Rr.prototype,"usePlacementReticle",2),xo([w()],Rr.prototype,"usePlacementAdjustment",2),xo([w()],Rr.prototype,"arSceneScale",2),xo([w()],Rr.prototype,"useXRAnchor",2),xo([w()],Rr.prototype,"useQuicklookExport",2),xo([w()],Rr.prototype,"useDepthSensing",2),xo([w(ii)],Rr.prototype,"defaultAvatar",2);class xC{get extensionName(){return"Physics"}onExportObject(e,t,r){const s=ie.getComponents(e,Oi).filter(c=>c.enabled),o=ie.getComponents(e,Qo).filter(c=>c.enabled&&!c.isTrigger);let a=s.length>0?s[0]:null;const l=o.length>0?o[0]:null;l&&!a&&(a=new Oi,a.isKinematic=!0),a&&t.addEventListener("serialize",(c,h)=>{var u,p,m;if(a){if(c.appendLine(),c.beginBlock('def RealityKitComponent "RigidBody"',"{",!0),a.useGravity||c.appendLine("bool gravityEnabled = 0"),c.appendLine('uniform token info:id = "RealityKit.RigidBody"'),a.isKinematic&&c.appendLine('token motionType = "Kinematic"'),c.beginBlock('def RealityKitStruct "massFrame"',"{",!0),c.appendLine(`float m_mass = ${a.mass}`),c.beginBlock('def RealityKitStruct "m_pose"',"{",!0),c.appendLine(`float3 position = (${a.centerOfMass.x}, ${a.centerOfMass.y}, ${a.centerOfMass.z})`),c.closeBlock("}"),c.closeBlock("}"),o.length>0){const f=o[0];c.beginBlock('def RealityKitStruct "material"',"{",!0);const g=f.sharedMaterial;g&&g.dynamicFriction!==void 0&&c.appendLine(`double dynamicFriction = ${(u=f.sharedMaterial)==null?void 0:u.dynamicFriction}`),g&&g.bounciness!==void 0&&c.appendLine(`double restitution = ${(p=f.sharedMaterial)==null?void 0:p.bounciness}`),g&&g.staticFriction!==void 0&&c.appendLine(`double staticFriction = ${(m=f.sharedMaterial)==null?void 0:m.staticFriction}`),c.closeBlock("}")}c.closeBlock("}")}}),l&&(t.addEventListener("serialize",(c,h)=>{var u;c.beginBlock('def RealityKitComponent "Collider"',"{",!0),c.appendLine("uint group = 1"),c.appendLine('uniform token info:id = "RealityKit.Collider"'),c.appendLine("uint mask = 4294967295");const p=l.isTrigger?"Trigger":"Default";if(c.appendLine(`token type = "${p}"`),c.beginBlock('def RealityKitStruct "Shape"',"{",!0),l instanceof n0){const m=l;c.appendLine('token shapeType = "Sphere"'),c.appendLine(`float radius = ${m.radius}`)}else if(l instanceof r0){const m=l;c.appendLine('token shapeType = "Box"'),c.appendLine(`float3 extent = (${m.size.x}, ${m.size.y}, ${m.size.z})`)}else if(l instanceof xh){const m=l;c.appendLine('token shapeType = "Capsule"'),c.appendLine(`float radius = ${m.radius}`),c.appendLine(`float height = ${m.height}`)}else if(l instanceof am&&(u=l.sharedMesh)!=null&&u.geometry){const m=l.sharedMesh.geometry;m.boundingBox||m.computeBoundingBox();const f=l.sharedMesh.geometry.boundingBox;f&&(c.appendLine('token shapeType = "Box"'),c.appendLine(`float3 extent = (${f.max.x-f.min.x}, ${f.max.y-f.min.y}, ${f.max.z-f.min.z})`),console.log("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. MeshCollider will be exported as Box",l))}else console.warn("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. Ignoring collider:",l);c.beginBlock('def RealityKitStruct "pose"',"{",!0),c.closeBlock("}"),c.closeBlock("}"),c.closeBlock("}")}),o.length>1&&console.log("WARNING: Multiple colliders detected. visionOS / iOS can only support objects with a single collider, only exporting the first collider: ",l))}}var s0e=Object.defineProperty,o0e=Object.getOwnPropertyDescriptor,Ph=(n,e,t,r)=>{for(var s=r>1?void 0:r?o0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&s0e(e,t,s),s};const _m=te("debugtext");var hr=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(hr||{}),_V=(n=>(n[n.Normal=0]="Normal",n[n.Bold=1]="Bold",n[n.Italic=2]="Italic",n[n.BoldAndItalic=3]="BoldAndItalic",n))(_V||{});class Is extends cm{constructor(){super(...arguments),d(this,"alignment",0),d(this,"verticalOverflow",0),d(this,"horizontalOverflow",0),d(this,"lineSpacing",1),d(this,"supportRichText",!1),d(this,"font"),d(this,"fontStyle",0),d(this,"sRGBTextColor",new xe(1,0,1)),d(this,"_text",""),d(this,"_fontSize",12),d(this,"_textMeshUi",null),d(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(e=this.uiObject)==null||e.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(e){this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){_m&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,_m&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),_m&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){var e;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(e=this.canvas)==null||e.registerEventReceiver(this)}onDisable(){var e;super.onDisable(),(e=this.canvas)==null||e.unregisterEventReceiver(this)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var r,s,o;if(_m&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let a=this.getNextTag(e);if(a){if(a.startIndex>0){for(let h=this.uiObject.children.length-1;h>=0;h--){const u=this.uiObject.children[h];u.isUI&&(this.uiObject.remove(u),u.clear())}const c=new lw({textContent:e.substring(0,a.startIndex),color:"inherit"});this.uiObject.add(c)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const l=[];for(;a;){const c=this.getNextTag(e,a.endIndex),h={fontFamily:(r=this.uiObject)==null?void 0:r.get("fontFamily"),color:"inherit",textContent:""};if(c){h.textContent=this.getText(e,a,c),this.handleTag(a,h,l);const u=new lw(h);(s=this.uiObject)==null||s.add(u)}else{h.textContent=e.substring(a.endIndex),this.handleTag(a,h,l);const u=new lw(h);(o=this.uiObject)==null||o.add(u)}a=c}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,r={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let s=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;s=!0;const a=this._textMeshUi[o];a.textContent&&(RS(a,r),e[o]=!0)}if(!s)break;yield}}handleTag(e,t,r){if(!e.isEndTag){if(e.type.includes("color")){const s=new uk(e,{color:t.color});if(r.push(s),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new xe(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const s=new uk(e,{fontWeight:700});r.push(s)}else if(e.type=="i"){this.setFont(t,2);const s=new uk(e,{fontStyle:"italic"});r.push(s)}}}getText(e,t,r){return e.substring(t.endIndex,r.startIndex)}getNextTag(e,t=0){const r=e.indexOf("<",t),s=e.indexOf(">",r);if(r>=0&&s>=0){const o=e.substring(r+1,s);return{type:o,startIndex:r,endIndex:s+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const r=this.font,s=this.getFamilyNameWithCorrectSuffix(r,t);_m&&console.log("Selected font family:"+s);let o=oR.getFontFamily(s);switch(o||(o=oR.addFontFamily(s)),e.fontFamily=o,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let a=o.getVariant(e.fontWeight,e.fontStyle);if(!a){let l=s;l!=null&&l.endsWith("-msdf.json")||(l+="-msdf.json");let c=s;c!=null&&c.endsWith(".png")||(c+=".png"),a=o.addVariant(e.fontWeight,e.fontStyle,l,c),a?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var r;const s=e.lastIndexOf("-");if(s<0)return e;const o=(r=e.substring(s+1))==null?void 0:r.toLowerCase();if(a0e.includes(o))return _m&&console.warn("Unsupported font style: "+o),e;const a=e.lastIndexOf("/");let l=e;a>=0&&(l=l.substring(a+1));const c=l[0]===l[0].toUpperCase(),h=e.substring(0,s);switch(_m&&console.log("Select font: ",e,_V[t],l,c,h),t){case 0:return c?h+"-Regular":h+"-regular";case 1:return c?h+"-Bold":h+"-bold";case 2:return c?h+"-Italic":h+"-italic";case 3:return c?h+"-BoldItalic":h+"-bolditalic";default:return e}}}Ph([w()],Is.prototype,"alignment",2),Ph([w()],Is.prototype,"verticalOverflow",2),Ph([w()],Is.prototype,"horizontalOverflow",2),Ph([w()],Is.prototype,"lineSpacing",2),Ph([w()],Is.prototype,"supportRichText",2),Ph([w(URL)],Is.prototype,"font",2),Ph([w()],Is.prototype,"fontStyle",2),Ph([w()],Is.prototype,"text",1),Ph([w()],Is.prototype,"fontSize",1);class uk{constructor(e,t){d(this,"tag"),d(this,"previousValues"),this.tag=e,this.previousValues=t}}const a0e=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class gd{constructor(e){d(this,"id"),d(this,"content",""),d(this,"font",[]),d(this,"pointSize",144),d(this,"width"),d(this,"height"),d(this,"depth"),d(this,"wrapMode"),d(this,"horizontalAlignment"),d(this,"verticalAlignment"),d(this,"material"),this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var r;t.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),t.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),t.closeBlock(")"),t.beginBlock(),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(r=this.font)==null||r.push("sans-serif"));const s=this.font.map(o=>`"${o}"`).join(", ");t.appendLine(`string[] font = [ ${s} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </StageRoot/Materials/${bP(this.material)}>`),t.closeBlock()}}d(gd,"global_id",0);class wC{static singleLine(e,t,r){const s=new gd("text_"+gd.getId());return s.content=e,t&&(s.pointSize=t),r&&(s.depth=r),s}static multiLine(e,t,r,s,o,a){const l=new gd("text_"+gd.getId());return l.content=e,l.width=t,l.height=r,l.horizontalAlignment=s,l.verticalAlignment=o,a!==void 0&&(l.wrapMode=a),l}}const l0e=new ve().makeRotationY(Math.PI),c0e=new ve().makeScale(-1,1,-1);class sb{get extensionName(){return"text"}exportText(e,t,r){const s=ie.getComponent(e,Is);if(!s)return;const o=ie.getComponent(e,Ms);let a=100,l=100;o&&(a=o.width,l=o.height),t.matrix=l0e.clone(),o&&t.matrix.premultiply(c0e);const c=s.color.clone();t.material=new gs({color:c,emissive:c}),t.addEventListener("serialize",(h,u)=>{let p=s.text;p=p.replace(/\r/g,""),p=p.replace(/\n/g,"\\n");const m=wC.multiLine(p,a,l,"center","bottom","flowing");this.setTextAlignment(m,s.alignment),this.setOverflow(m,s),t.material&&(m.material=t.material),m.pointSize=this.convertToTextSize(s.fontSize),m.depth=.001,m.writeTo(void 0,h)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case hr.LowerLeft:case hr.MiddleLeft:case hr.UpperLeft:e.horizontalAlignment="left";break;case hr.LowerCenter:case hr.MiddleCenter:case hr.UpperCenter:e.horizontalAlignment="center";break;case hr.LowerRight:case hr.MiddleRight:case hr.UpperRight:e.horizontalAlignment="right";break}switch(t){case hr.LowerLeft:case hr.LowerCenter:case hr.LowerRight:e.verticalAlignment="bottom";break;case hr.MiddleLeft:case hr.MiddleCenter:case hr.MiddleRight:e.verticalAlignment="middle";break;case hr.UpperLeft:case hr.UpperCenter:case hr.UpperRight:e.verticalAlignment="top";break}}}class SC{get extensionName(){return"tmui"}onExportObject(e,t,r){const s=ie.getComponent(e,Jr);if(s&&s.enabled&&s.renderMode===UQ.WorldSpace){const o=new sb,a=ie.getComponent(e,Ms),l=ie.getComponent(e,ad),c=new Array;if(a){if(!ie.isActiveSelf(e)){const p=ie.isActiveSelf(e);ie.setActive(e,!0),a.onEnable(),a.updateTransform(),c.push(()=>{a.onDisable(),ie.setActive(e,p)})}e.traverse(p=>{if(!ie.isActiveInHierarchy(p)){const m=ie.isActiveSelf(p);ie.setActive(p,!0);const f=ie.getComponent(p,za);f&&(f.onEnable(),c.push(()=>{f.onDisable()}));const g=ie.getComponent(p,Ms);g&&(g.onEnable(),g.updateTransform(),g.onApplyTransform(),c.push(()=>{g.onDisable()}));const v=ie.getComponent(p,Is);v&&(v.onEnable(),c.push(()=>{v.onDisable()})),c.push(()=>{ie.setActive(p,m)})}}),a.width,a.height;const h=Ws.createEmpty(),u=a.shadowComponent;if(t.add(h),u){const p=u.matrix;h.matrix.copy(p);const m=new Map,f=new Map;m.set(u,h),f.set(u,l?l.alpha:1),u.traverse(g=>{if(g===u)return;const v=Ws.createEmpty();v.matrix.copy(g.matrix);const A=g.parent,y=!!A&&typeof A.textContent=="string"&&A.textContent.length>0;let _=f.get(A)||1;const b=ie.getComponent(g,ad);if(b&&(_*=b.alpha),g instanceof pe&&y){const E=g[Ca];E?o.exportText(E.gameObject,v,r):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",g)}if(g instanceof pe&&!y){const E=g.geometry.clone();E.scale(1,1,-1),this.flipWindingOrder(E),v.geometry=E;const I=new xe,T=g.material.opacity;I.copy(g.material.color),v.material=new Jt({color:I,opacity:T*_,map:g.material.map,transparent:!0})}m.set(g,v),f.set(g,_);const x=m.get(A);if(!x){console.error("Error when exporting UI: shadow component parent not found!",g,g.parent);return}x.add(v)})}}for(const h of c)h()}}flipWindingOrder(e){const t=e.index.array;for(let r=0,s=t.length/3;r<s;r++){const o=t[r*3];t[r*3]=t[r*3+2],t[r*3+2]=o}e.index.needsUpdate=!0}}const ob=te("debugusdz");function h0e(n,e){var t;const r=[],s=ie.getComponentsInChildren(n,Wr),o=ie.getComponentsInChildren(n,Cs),a=new Array,l=new Array;if(e.injectImplicitBehaviours)for(const c of s){if(!c||!c.runtimeAnimatorController||!c.enabled)continue;const h=c.runtimeAnimatorController.activeState;if(!h||!h.motion||!h.motion.clip||((t=h.motion.clip.tracks)==null?void 0:t.length)<1||a.includes(c))continue;const u=new pm;u.animator=c,u.stateName=h.name,u.trigger="start",u.name="PlayAnimationOnClick_implicitAtStart_"+u.stateName;const p=new Ae;ie.addComponent(p,u),l.push(p),a.push(c),n.add(p)}else for(const c of s){if(!c||!c.runtimeAnimatorController||!c.enabled)continue;ob&&console.log(c);const h=[];for(const u of c.runtimeAnimatorController.enumerateActions()){ob&&console.log(u);const p=u.getClip();h.includes(p)||h.push(p)}r.push({root:c.gameObject,clips:h})}if(e.injectImplicitBehaviours)for(const c of o){if(!c||!c.clip||!c.enabled||!c.playAutomatically||a.includes(c))continue;const h=new pm;h.animation=c,h.stateName=c.clip.name,h.trigger="start",h.name="PlayAnimationOnClick_implicitAtStart_"+h.stateName;const u=new Ae;ie.addComponent(u,h),l.push(u),a.push(c),n.add(u)}else for(const c of o){ob&&console.log(c);const h=[];for(const u of c.animations)h.includes(u)||h.push(u);r.push({root:c.gameObject,clips:h})}ob&&r?.length>0&&console.log("USDZ Animation Clips without behaviours",r);for(const c of r)for(const h of c.clips)e.registerAnimation(c.root,h);return l}function u0e(n,e){const t=ie.getComponentsInChildren(n,Mn),r=ie.getComponentsInChildren(n,ld),s=new Array,o=new Array;ob&&console.log({audioSources:t,playAudioOnClicks:r});for(const a of r){if(!a.target)continue;const l=t.indexOf(a.target);l>-1&&t.splice(l,1)}for(const a of t){if(!a||!a.clip||a.volume<=0||s.includes(a))continue;const l=new ld;l.target=a,l.name="PlayAudioOnClick_implicitAtStart_",l.trigger="start";const c=new Ae;ie.addComponent(c,l),console.log("implicit PlayAudioOnStart",c,l),o.push(c),s.push(a),n.add(c)}return o}function d0e(n){return new br("DisableAtStart",_r.sceneStartTrigger(),fi.fadeAction(n,0,!1))}function xV(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const r=document.createElement("button");r.id="open-in-ar",r.innerText="Open in QuickLook",t.appendChild(r);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const o=document.createElement("img");return o.id="button",s.appendChild(o),n.domElement.shadowRoot.appendChild(t),s}var p0e=Object.defineProperty,m0e=Object.getOwnPropertyDescriptor,Rs=(n,e,t,r)=>{for(var s=r>1?void 0:r?m0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&p0e(e,t,s),s};const Da=te("debugusdz");class vd{constructor(){d(this,"callToAction"),d(this,"checkoutTitle"),d(this,"checkoutSubtitle"),d(this,"callToActionURL")}}Rs([w()],vd.prototype,"callToAction",2),Rs([w()],vd.prototype,"checkoutTitle",2),Rs([w()],vd.prototype,"checkoutSubtitle",2),Rs([w()],vd.prototype,"callToActionURL",2);var CC;const dk=(CC=class extends Be{constructor(){super(...arguments),d(this,"objectToExport"),d(this,"autoExportAnimations",!0),d(this,"autoExportAudioSources",!0),d(this,"exportFileName"),d(this,"customUsdzFile"),d(this,"customBranding"),d(this,"anchoringType","plane"),d(this,"maxTextureSize",2048),d(this,"planeAnchoringAlignment","horizontal"),d(this,"interactive",!0),d(this,"allowCreateQuicklookButton",!0),d(this,"quickLookCompatible",!0),d(this,"extensions",[]),d(this,"link"),d(this,"button"),d(this,"onClickedOpenInARElement",n=>{n.preventDefault(),this.exportAndOpen()}),d(this,"_currentExportTasks",new Map),d(this,"_previousTimeScale",1),d(this,"lastCallback"),d(this,"_rootSessionRootWasAppliedTo",null),d(this,"_rootPositionBeforeExport",new C),d(this,"_rootRotationBeforeExport",new Ce),d(this,"_rootScaleBeforeExport",new C)}start(){var n,e,t;Da&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),aa()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(n=this.objectToExport)==null?void 0:n.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new WS),this.extensions.push(new Td),this.extensions.push(new xC),this.extensions.push(new sb),this.extensions.push(new SC))}onEnable(){var n;const e=mp(),t=Ff();(Da||e&&t)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=xV(this.context),this.link.addEventListener("message",this.lastCallback)),Da&&rn("USDZ Exporter enabled: "+this.name),(n=document.getElementById("open-in-ar"))==null||n.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var n,e,t;(n=this.button)==null||n.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),Da&&rn("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var n;let e=this.exportFileName??((n=this.objectToExport)==null?void 0:n.name)??this.name;if(e+="-"+Xj(),cu()||(e!==""&&(e+="-"),e+="MadeWithNeedle"),this.link||(this.link=xV(this.context)),this.customUsdzFile)return Da&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,e),null;if(!this.objectToExport)return console.warn("No object to export",this),null;const t=await this.export(this.objectToExport);return t?(Da&&console.log("USDZ generation done. Downloading as "+e),this.openInQuickLook(t,e),t):(console.error("USDZ generation failed. Please report a bug",this),null)}async export(n){if(!n)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(n);if(e)return e;const t=this.internalExport(n);return t instanceof Promise?(this._currentExportTasks.set(n,t),t.then(r=>(this._currentExportTasks.delete(n),r)).catch(r=>(this._currentExportTasks.delete(n),console.error("Error during USDZ export \u2013 please report a bug!",r),null))):t}async internalExport(n){ti.start("export-usdz",{onProgress:A=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:A}}))}}),ti.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ti.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ti.start("export-usdz-textures","export-usdz");const e=ie.getComponentsInChildren(n,Pa);for(const A of e)A&&A.enabled&&A.start&&A.start();const t=ie.getComponentsInChildren(n,Tn),r=new Array;let s=0;for(const A of t){for(const y of A.sharedMeshes)if(y){const _=mi.assignMeshLOD(y,0);_ instanceof Promise&&r.push(new Promise((b,x)=>{_.then(()=>{s++,ti.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:s,totalSteps:r.length}),b()}).catch(E=>x(E))}))}for(const y of A.sharedMaterials)if(y){const _=mi.assignTextureLOD(y,0);_ instanceof Promise&&r.push(new Promise((b,x)=>{_.then(()=>{s++,ti.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:s,totalSteps:r.length}),b()}).catch(E=>x(E))}))}}Da&&rn("Progressive Loading: "+r.length),await Promise.all(r),Da&&rn("Progressive Loading: done"),ti.end("export-usdz-textures");const o=$s.Global.Mask;$s.Global.Set(ic.AR);const a=new Zj,l=new TA(this.quickLookCompatible),c=[l,...this.extensions],h={self:this,exporter:a,extensions:c,object:n};ti.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:h})),this.applyWebARSessionRoot(),this._previousTimeScale=this.context.time.timeScale,this.context.time.timeScale=0,ti.report("export-usdz","auto export animations and audio sources");const u=new Array;this.autoExportAnimations&&u.push(...h0e(n,l)),this.extensions.find(A=>A.extensionName==="Audio")&&this.autoExportAudioSources&&u.push(...u0e(n)),a.debug=Da,a.keepObject=A=>{const y=ie.getComponent(A,Tn);return!(y&&!y.enabled)};const p=new Array;this.objectToExport&&this.quickLookCompatible&&this.interactive&&this.objectToExport.traverse(A=>{A.visible||p.push(A)});const m=this.extensions.find(A=>A.extensionName==="Behaviour");this.interactive&&m&&p.length>0&&m.addBehavior(d0e(p));let f=!0;this.quickLookCompatible&&!this.interactive&&(f=!1),this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal"),ti.report("export-usdz","Invoking exporter.parse");const g=await a.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:c,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize,exportInvisible:f}),v=new Blob([g],{type:"model/vnd.usdz+zip"});this.revertWebARSessionRoot(),this.context.time.timeScale=this._previousTimeScale,ti.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:h}));for(const A of u)ie.destroy(A);return $s.Global.Set(o),ti.end("export-usdz"),v}openInQuickLook(n,e){const t=n instanceof Blob?URL.createObjectURL(n):n,r=this.buildQuicklookOverlay();Da&&console.log("QuickLook Overlay",r);const s=r.callToAction?encodeURIComponent(r.callToAction):"",o=r.checkoutTitle?encodeURIComponent(r.checkoutTitle):"",a=r.checkoutSubtitle?encodeURIComponent(r.checkoutSubtitle):"";this.link.href=t+`#callToAction=${s}&checkoutTitle=${o}&checkoutSubtitle=${a}&callToActionURL=${r.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(n,e){dk.save(n,e)}static save(n,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof n=="string"?t.href=n:t.href=URL.createObjectURL(n),t.download=e,t.click(),t.remove()}quicklookCallback(n){if(n?.data=="_apple_ar_quicklook_button_tapped"){Da&&ki("Quicklook closed via call to action button");var e=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(e),!e.defaultPrevented){const t=new URLSearchParams(this.link.href);if(t){const r=t.get("callToActionURL");Da&&rn("Quicklook url: "+r),r&&(cu()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var n,e,t,r,s,o;const a={};return this.customBranding&&Object.assign(a,this.customBranding),cu()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),a.callToAction="Close",a.checkoutTitle="\u{1F335} Made with Needle",a.checkoutSubtitle="_"),(((n=a.callToAction)==null?void 0:n.length)||((e=a.checkoutTitle)==null?void 0:e.length)||((t=a.checkoutSubtitle)==null?void 0:t.length))&&((r=a.callToAction)!=null&&r.length||(a.callToAction="\0"),(s=a.checkoutTitle)!=null&&s.length||(a.checkoutTitle="\0"),(o=a.checkoutSubtitle)!=null&&o.length||(a.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:a})),a}getARScaleAndTarget(){if(!this.objectToExport)return{scale:1,_invertForward:!1,target:this.gameObject,sessionRoot:null};let n=ie.getComponentInParent(this.objectToExport,to);n||(n=ie.getComponentInChildren(this.objectToExport,to));let e=1,t=!1;const r=this.objectToExport;if(n)e=n.arScale,t=n.invertForward;else{const s=ie.findObjectOfType(Rr);s&&(e=s.arSceneScale)}return{scale:1/e,_invertForward:t,target:r,sessionRoot:n?.gameObject??null}}applyWebARSessionRoot(){if(!this.objectToExport)return;const{scale:n,_invertForward:e,target:t,sessionRoot:r}=this.getARScaleAndTarget(),s=r?.matrixWorld.clone().invert();this._rootSessionRootWasAppliedTo=t,this._rootPositionBeforeExport.copy(t.position),this._rootRotationBeforeExport.copy(t.quaternion),this._rootScaleBeforeExport.copy(t.scale),t.scale.multiplyScalar(n),e&&t.quaternion.multiply(dk.invertForwardQuaternion),t.updateMatrix(),t.updateMatrixWorld(!0),r&&s&&t.matrix.premultiply(s)}revertWebARSessionRoot(){if(!this.objectToExport||!this._rootSessionRootWasAppliedTo)return;const n=this._rootSessionRootWasAppliedTo;n.position.copy(this._rootPositionBeforeExport),n.quaternion.copy(this._rootRotationBeforeExport),n.scale.copy(this._rootScaleBeforeExport),n.updateMatrix(),n.updateMatrixWorld(!0),this._rootSessionRootWasAppliedTo=null}createQuicklookButton(){const n=ym.getOrCreate().createQuicklookButton();return n.parentNode||this.context.menu.appendChild(n),n}},d(CC,"invertForwardMatrix",new ve().makeRotationY(Math.PI)),d(CC,"invertForwardQuaternion",new Ce().setFromEuler(new pi(0,Math.PI,0))),CC);let Rn=dk;Rs([w(Ae)],Rn.prototype,"objectToExport",2),Rs([w()],Rn.prototype,"autoExportAnimations",2),Rs([w()],Rn.prototype,"autoExportAudioSources",2),Rs([w()],Rn.prototype,"exportFileName",2),Rs([w(URL)],Rn.prototype,"customUsdzFile",2),Rs([w(vd)],Rn.prototype,"customBranding",2),Rs([w()],Rn.prototype,"anchoringType",2),Rs([w()],Rn.prototype,"maxTextureSize",2),Rs([w()],Rn.prototype,"planeAnchoringAlignment",2),Rs([w()],Rn.prototype,"interactive",2),Rs([w()],Rn.prototype,"allowCreateQuicklookButton",2),Rs([w()],Rn.prototype,"quickLookCompatible",2);class ab extends Be{constructor(){super(...arguments),d(this,"isUsed",!0),d(this,"usedBy",null)}}class pk extends Be{}const wV=te("debugdeletable");class EC extends sc{}class mk extends Be{constructor(){super(...arguments),d(this,"deleteBoxes",[])}awake(){this.deleteBoxes=ie.findObjectsOfType(EC,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const r=ie.getComponentInParent(this.gameObject,ab);r?wV&&console.warn("Can not delete object with usage marker",this.guid,r):(wV&&console.log("DESTROY",this.gameObject),oA(this.gameObject,this.context.connection))}}}}var f0e=Object.defineProperty,g0e=Object.getOwnPropertyDescriptor,xm=(n,e,t,r)=>{for(var s=r>1?void 0:r?g0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&f0e(e,t,s),s};const v0e=te("debugpost");class _l extends Xr{constructor(){super(...arguments),d(this,"mode"),d(this,"focusDistance",new qe(1)),d(this,"focalLength",new qe(.2)),d(this,"aperture",new qe(20)),d(this,"gaussianMaxRadius",new qe),d(this,"resolutionScale",new qe(1*1/window.devicePixelRatio)),d(this,"bokehScale",new qe)}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const r=t/300,s=2;return it.lerp(s,.01,r)};const e=20;this.aperture.valueProcessor=t=>{const r=1-t/32;return it.lerp(1,e,r)}}onCreateEffect(){if(this.mode===0){v0e&&console.warn("DepthOfField: Mode is set to Off");return}const e=new Y5(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=t=>{e.cocMaterial.worldFocusDistance=t},this.focalLength.onValueChanged=t=>e.cocMaterial.worldFocusRange=t,this.aperture.onValueChanged=t=>e.bokehScale=t,this.resolutionScale&&(this.resolutionScale.onValueChanged=t=>e.resolution.scale=t),[e]}unapply(){}}xm([w()],_l.prototype,"mode",2),xm([w(qe)],_l.prototype,"focusDistance",2),xm([w(qe)],_l.prototype,"focalLength",2),xm([w(qe)],_l.prototype,"aperture",2),xm([w(qe)],_l.prototype,"gaussianMaxRadius",2),xm([w(qe)],_l.prototype,"resolutionScale",2),xm([w(qe)],_l.prototype,"bokehScale",2),Ta("DepthOfField",_l);var y0e=Object.defineProperty,A0e=Object.getOwnPropertyDescriptor,b0e=(n,e,t,r)=>{for(var s=r>1?void 0:r?A0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&y0e(e,t,s),s};class MC extends Be{constructor(){super(...arguments),d(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||ie.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:aa()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}b0e([w()],MC.prototype,"visibleOn",2);class fk{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var _0e=Object.defineProperty,x0e=Object.getOwnPropertyDescriptor,wm=(n,e,t,r)=>{for(var s=r>1?void 0:r?x0e(e,t):e,o=n.length-1,a;o>=0;o--)(a=n[o])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&_0e(e,t,s),s};const vc=te("debugdrag");var SV=(n=>(n[n.XZPlane=0]="XZPlane",n[n.Attached=1]="Attached",n[n.HitNormal=2]="HitNormal",n[n.DynamicViewAngle=3]="DynamicViewAngle",n[n.SnapToSurfaces=4]="SnapToSurfaces",n[n.None=5]="None",n))(SV||{}),TC;const yc=(TC=class extends Be{constructor(){super(...arguments),d(this,"dragMode",3),d(this,"snapGridResolution",0),d(this,"keepRotation",!0),d(this,"xrDragMode",1),d(this,"xrKeepRotation",!1),d(this,"xrDistanceDragFactor",1),d(this,"showGizmo",!1),d(this,"targetObject",null),d(this,"orbit",null),d(this,"_dragHelper",null),d(this,"_draggingRigidbodies",[]),d(this,"_potentialDragStartEvt",null),d(this,"_dragHandlers",new Map),d(this,"_totalMovement",new C),d(this,"_marker",null),d(this,"_isDragging",!1),d(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(n){this.targetObject=n;for(const e of this._dragHandlers.values())e.setTargetObject(n)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new C,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=ie.findObjectOfType(yi,this.context),this.gameObject.getComponentInParent(No)||this.gameObject.addComponent(No)}allowEdit(n=null){return this.context.connection.allowEditing}onPointerEnter(n){if(!this.allowEdit(this.gameObject)||n.mode!=="screen"||(n.event.mode==="tracked-pointer"||n.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const e=ie.getComponentInParent(n.object,yc);!e||e!==this||(yc.lastHovered=n.object,this.context.domElement.style.cursor="pointer")}onPointerExit(n){this.allowEdit(this.gameObject)&&n.mode==="screen"&&yc.lastHovered===n.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(n){if(!(!this.allowEdit(this.gameObject)||n.used||(n.mode==="tracked-pointer"||n.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(yc.lastHovered=n.object,n.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=n),yc._active+=1;const e=new S0e(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(n.event.space,e),this.orbit&&(this.orbit.enabled=!1),e.onDragStart(n),this._dragHandlers.size===2){const t=this._dragHandlers.values(),r=t.next().value,s=t.next().value,o=new w0e(this,this.targetObject||this.gameObject,r,s);this._dragHandlers.set(this.gameObject,o),o.onDragStart(n)}n.use()}}onPointerMove(n){(this._isDragging||this._potentialDragStartEvt!==null)&&n.use()}onPointerUp(n){if(vc&&At.DrawLabel(n.point??this.gameObject.worldPosition,"POINTERUP:"+n.pointerId+", "+n.button,.03,3),!this.allowEdit(this.gameObject)||n.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(n.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(n)),e&&(yc._active>0&&(yc._active-=1),e.onDragEnd&&e.onDragEnd(n),this._dragHandlers.delete(n.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(n),n.use()),yc._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const n of this._dragHandlers.values())n.collectMovementInfo&&n.collectMovementInfo(),n.getTotalMovement&&this._totalMovement.add(n.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const n=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(n)}for(const n of this._dragHandlers.values())n.onDragUpdate&&n.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(n){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new EV(this.context.mainCamera);else return;if(!n||!n.object)return;const e=ie.getComponentInParent(n.object,yc);if(!e||e!==this&&e._isDragging)return;const t=this.targetObject||this.gameObject;if(!t)return;this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const r=ie.getComponentInChildren(t,Yu);vc&&console.log("DRAG START",r,t),r&&(r.fastMode=!0,r?.requestOwnership()),this._marker=ie.addComponent(t,ab),this._draggingRigidbodies.length=0;const s=ie.getComponentsInChildren(t,Oi);s&&this._draggingRigidbodies.push(...s)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const e of this._draggingRigidbodies)e.wakeUp(),e.resetVelocities(),e.resetForcesAndTorques();const n=this.targetObject||this.gameObject;ja.markDirty(n)}onLastDragEnd(n){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const t of this._draggingRigidbodies)t.setVelocity(t.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(vc&&console.log("DRAG END",e,e?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),n!=null&&n.object){const t=ie.getComponentInChildren(n.object,Yu);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},d(TC,"_active",0),d(TC,"lastHovered"),TC);let ka=yc;wm([w()],ka.prototype,"dragMode",2),wm([w()],ka.prototype,"snapGridResolution",2),wm([w()],ka.prototype,"keepRotation",2),wm([w()],ka.prototype,"xrDragMode",2),wm([w()],ka.prototype,"xrKeepRotation",2),wm([w()],ka.prototype,"xrDistanceDragFactor",2),wm([w()],ka.prototype,"showGizmo",2);class w0e{constructor(e,t,r,s){d(this,"handlerA"),d(this,"handlerB"),d(this,"context"),d(this,"settings"),d(this,"gameObject"),d(this,"_handlerAAttachmentPoint",new C),d(this,"_handlerBAttachmentPoint",new C),d(this,"_followObject"),d(this,"_manipulatorObject"),d(this,"_deviceMode"),d(this,"_followObjectStartWorldQuaternion",new Ce),d(this,"_manipulatorPosOffset",new C),d(this,"_manipulatorRotOffset",new Ce),d(this,"_manipulatorScaleOffset",new C),d(this,"_tempVec1",new C),d(this,"_tempVec2",new C),d(this,"_tempVec3",new C),d(this,"tempLookMatrix",new ve),d(this,"_initialScale",new C),d(this,"_initialDistance",0);var o,a;this.context=e.context,this.settings=e,this.gameObject=t,this.handlerA=r,this.handlerB=s,this._followObject=new Ae,this._manipulatorObject=new Ae,this.context.scene.add(this._manipulatorObject);const l=(a=(o=Ct.active)==null?void 0:o.rig)==null?void 0:a.gameObject;if(!this.handlerA||!this.handlerB||!this.handlerA.hitPointInLocalSpace||!this.handlerB.hitPointInLocalSpace){console.error("Invalid: MultiTouchDragHandler needs two valid DragPointerHandlers with hitPointInLocalSpace set.");return}if(this._tempVec1.copy(this.handlerA.hitPointInLocalSpace),this._tempVec2.copy(this.handlerB.hitPointInLocalSpace),this.gameObject.localToWorld(this._tempVec1),this.gameObject.localToWorld(this._tempVec2),l&&(l.worldToLocal(this._tempVec1),l.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(vc&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now \u2013 controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(t.scale),vc){this._followObject.add(new Po(2)),this._manipulatorObject.add(new Po(5));const c=h=>`${h.x.toFixed(2)}, ${h.y.toFixed(2)}, ${h.z.toFixed(2)}`;At.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),At.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
6152
6152
  `+c(this._tempVec1)+`
6153
- `+c(this._tempVec2),.03,5)}}onDragStart(e){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=e.mode,this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this.alignManipulator(),this._manipulatorObject.attach(this._followObject),this._manipulatorPosOffset.copy(this._followObject.position),this._manipulatorRotOffset.copy(this._followObject.quaternion),this._manipulatorScaleOffset.copy(this._followObject.scale)}onDragEnd(e){if(!this.handlerA||!this.handlerB){console.error("onDragEnd called on MultiTouchDragHandler without valid handlers. This is likely a bug.");return}this.handlerA.recenter(),this.handlerB.recenter(),this._manipulatorObject.removeFromParent(),this._followObject.removeFromParent(),this._manipulatorObject.destroy(),this._followObject.destroy()}alignManipulator(){if(!this.handlerA||!this.handlerB){console.error("alignManipulator called on MultiTouchDragHandler without valid handlers. This is likely a bug.",this);return}if(!this.handlerA.followObject||!this.handlerB.followObject){console.error("alignManipulator called on MultiTouchDragHandler without valid follow objects. This is likely a bug.",this.handlerA,this.handlerB);return}this._tempVec1.copy(this._handlerAAttachmentPoint),this._tempVec2.copy(this._handlerBAttachmentPoint),this.handlerA.followObject.localToWorld(this._tempVec1),this.handlerB.followObject.localToWorld(this._tempVec2),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._manipulatorObject.position.copy(this._tempVec3);const e=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,e.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const t=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(t/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),vc&&(At.DrawLabel(this._tempVec3.clone().add(new C(0,.2,0)),"A:B "+t.toFixed(2),.03),At.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const e=30,t=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const r=this.gameObject,s=this._followObject;s.updateMatrix(),s.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const u=this._followObject.worldPosition,p=this.settings.snapGridResolution;u.x=Math.round(u.x/p)*p,u.y=Math.round(u.y/p)*p,u.z=Math.round(u.z/p)*p,this._followObject.worldPosition=u,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const a=it.clamp01(this.context.time.deltaTime*e*t),l=r.worldPosition;l.lerp(s.worldPosition,a),r.worldPosition=l;const c=r.worldQuaternion;c.slerp(s.worldQuaternion,a),r.worldQuaternion=c;const h=r.worldScale;h.lerp(s.worldScale,a),r.worldScale=h}setTargetObject(e){this.gameObject=e}}class S0e{constructor(e,t){d(this,"context"),d(this,"gameObject"),d(this,"settings"),d(this,"_lastRig"),d(this,"_followObject"),d(this,"_totalMovement",new C),d(this,"_totalMovementAlongRayDirection",0),d(this,"_grabStartDistance",0),d(this,"_deviceMode"),d(this,"_followObjectStartPosition",new C),d(this,"_followObjectStartQuaternion",new Ce),d(this,"_followObjectStartWorldQuaternion",new Ce),d(this,"_lastDragPosRigSpace"),d(this,"_tempVec",new C),d(this,"_tempMat",new ve),d(this,"_hitPointInLocalSpace",new C),d(this,"_hitNormalInLocalSpace",new C),d(this,"_bottomCenter",new C),d(this,"_backCenter",new C),d(this,"_backBottomCenter",new C),d(this,"_bounds",new bi),d(this,"_dragPlane",new Us(new C(0,1,0))),d(this,"_draggedOverObject",null),d(this,"_draggedOverObjectLastSetUp",null),d(this,"_draggedOverObjectLastNormal",new C),d(this,"_draggedOverObjectDuration",0),this.settings=e,this.context=e.context,this.gameObject=t,this._followObject=new Ae}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(e){this.gameObject=e}recenter(){var e,t;if(!this._followObject.parent){console.warn("Error: space follow object doesn't have parent but recenter() is called. This is likely a bug");return}const r=this._followObject.parent;this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.position.set(0,0,0),this._followObject.quaternion.set(0,0,0,1),this._followObject.scale.set(1,1,1),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0),r.attach(this._followObject),this._followObjectStartPosition.copy(this._followObject.position),this._followObjectStartQuaternion.copy(this._followObject.quaternion),this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const s=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(s),this._grabStartDistance=s.distanceTo(r.worldPosition);const o=(t=(e=Ct.active)==null?void 0:e.rig)==null?void 0:t.gameObject,a=o?.worldScale.x||1;this._grabStartDistance/=a,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,vc&&(At.DrawLine(s,r.worldPosition,65280,.5,!1),At.DrawLabel(r.worldPosition.add(new C(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(e){if(e.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,e.point&&e.normal)this._hitPointInLocalSpace.copy(e.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(e.normal);else if(e){const f=e.event.space,g=f.worldPosition;this.gameObject.worldToLocal(g),this._hitPointInLocalSpace.copy(g);const v=f.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),v.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(v)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=e.mode;const t=this._followObject.parent.worldForward,r=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,s=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(s),r){case 0:const f=new C(0,1,0);this.gameObject.parent&&f.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(f,s);break;case 2:const g=this._hitNormalInLocalSpace.clone();g.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(g,s);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,s);break;case 3:const v=new C(0,1,0),A=t,y=v.angleTo(A),_=.5;y>Math.PI/2+_||y<Math.PI/2-_?this._dragPlane.setFromNormalAndCoplanarPoint(new C(0,1,0),s):this._dragPlane.setFromNormalAndCoplanarPoint(t,s);break}const o=this.gameObject.parent,a=this.gameObject.position.clone(),l=this.gameObject.quaternion.clone(),c=this.gameObject.scale.clone(),h=this.gameObject.matrixWorld.clone();o&&o.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1);const u=lu([this.gameObject]);u.expandByPoint(this.gameObject.worldPosition);const p=new C;u.getCenter(p);const m=new C;u.getSize(m),this._bottomCenter.copy(p.clone().add(new C(0,-m.y/2,0))),this._backCenter.copy(p.clone().add(new C(0,0,m.z/2))),this._backBottomCenter.copy(p.clone().add(new C(0,-m.y/2,m.z/2))),this._bounds.copy(u),o&&o.add(this.gameObject),this.gameObject.position.copy(a),this.gameObject.quaternion.copy(l),this.gameObject.scale.copy(c),this.gameObject.matrixWorld.copy(h),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var e,t;if(!this._followObject.parent)return;const r=this._followObject.parent;this._followObject.updateMatrix();const s=r.worldPosition,o=(t=(e=Ct.active)==null?void 0:e.rig)==null?void 0:t.gameObject;o&&o.worldToLocal(s),(this._lastDragPosRigSpace===void 0||o!=this._lastRig)&&(this._lastDragPosRigSpace=s.clone(),this._lastRig=o),this._tempVec.copy(s).sub(this._lastDragPosRigSpace);const a=r.worldForward;if(o&&(this._tempMat.copy(o.matrixWorld).invert(),a.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=a.dot(this._tempVec),this._tempVec.x=Math.abs(this._tempVec.x),this._tempVec.y=Math.abs(this._tempVec.y),this._tempVec.z=Math.abs(this._tempVec.z),this._totalMovement.add(this._tempVec),this._lastDragPosRigSpace.copy(s),vc){let l=s;o&&(l=l.clone(),l.transformDirection(o.matrixWorld)),At.DrawRay(l,a,255)}}onDragUpdate(e){if(e>1)return;const t=this.gameObject,r=this._followObject.parent;this._followObject.updateMatrix();const s=r.worldPosition,o=r.worldForward,a=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",l=a?this.settings.xrKeepRotation:this.settings.keepRotation,c=a?this.settings.xrDragMode:this.settings.dragMode;if(c===5)return;const h=10;l&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let u=1,p=2;if(a&&this._grabStartDistance>.5){const A=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);u=Math.max(0,A),u=u*u*u}else this._grabStartDistance<=.5&&(p=3);this._followObject.position.copy(this._followObjectStartPosition),l||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(u),this._followObject.updateMatrix();const m=new lo(s,o);if(c==4){const A=new pl;A.testObject=_=>_!==this.followObject&&_!==r&&_!==t;const y=this.context.physics.raycastFromRay(m,A);if(y.length>0){const _=y[0];if(this._draggedOverObject===_.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=_.object,this._draggedOverObjectDuration=0),_.face){const b=this._draggedOverObjectDuration>=.15;if(b&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(_.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(_.face.normal);const x=Di(),E=Di();this._bounds.getCenter(x),this._bounds.getSize(E),x.sub(E.multiplyScalar(.5).multiply(_.face.normal)),this._hitPointInLocalSpace.copy(x),this._hitNormalInLocalSpace.copy(_.face.normal),this._bounds.getCenter(x),this._bounds.getSize(E),x.add(E.multiplyScalar(.5).multiply(_.face.normal));const I=Di(this._hitPointInLocalSpace).add(x);this._followObject.localToWorld(I);const T=_.point;this._dragPlane.setFromNormalAndCoplanarPoint(_.face.normal,T)}else if(!b)return}}}if(c!==1&&m.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const A=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(A),vc&&At.DrawLine(A,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(A),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const A=this._followObject.worldPosition,y=this.settings.snapGridResolution;A.x=Math.round(A.x/y)*y,A.y=Math.round(A.y/y)*y,A.z=Math.round(A.z/y)*y,this._followObject.worldPosition=A,this._followObject.updateMatrix()}l&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const f=it.clamp01(this.context.time.deltaTime*h*p),g=t.worldPosition;g.lerp(this._followObject.worldPosition,f),t.worldPosition=g;const v=t.worldQuaternion;if(v.slerp(this._followObject.worldQuaternion,f),t.worldQuaternion=v,vc){const A=this._hitPointInLocalSpace.clone();t.localToWorld(A),At.DrawSphere(A,.02,16711680);const y=this._hitNormalInLocalSpace.clone();y.applyQuaternion(v),At.DrawRay(A,y,16711680),At.DrawLabel(g.add(new C(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
6153
+ `+c(this._tempVec2),.03,5)}}onDragStart(e){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=e.mode,this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this.alignManipulator(),this._manipulatorObject.attach(this._followObject),this._manipulatorPosOffset.copy(this._followObject.position),this._manipulatorRotOffset.copy(this._followObject.quaternion),this._manipulatorScaleOffset.copy(this._followObject.scale)}onDragEnd(e){if(!this.handlerA||!this.handlerB){console.error("onDragEnd called on MultiTouchDragHandler without valid handlers. This is likely a bug.");return}this.handlerA.recenter(),this.handlerB.recenter(),this._manipulatorObject.removeFromParent(),this._followObject.removeFromParent(),this._manipulatorObject.destroy(),this._followObject.destroy()}alignManipulator(){if(!this.handlerA||!this.handlerB){console.error("alignManipulator called on MultiTouchDragHandler without valid handlers. This is likely a bug.",this);return}if(!this.handlerA.followObject||!this.handlerB.followObject){console.error("alignManipulator called on MultiTouchDragHandler without valid follow objects. This is likely a bug.",this.handlerA,this.handlerB);return}this._tempVec1.copy(this._handlerAAttachmentPoint),this._tempVec2.copy(this._handlerBAttachmentPoint),this.handlerA.followObject.localToWorld(this._tempVec1),this.handlerB.followObject.localToWorld(this._tempVec2),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._manipulatorObject.position.copy(this._tempVec3);const e=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,e.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const t=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(t/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),vc&&(At.DrawLabel(this._tempVec3.clone().add(new C(0,.2,0)),"A:B "+t.toFixed(2),.03),At.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const e=30,t=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const r=this.gameObject,s=this._followObject;s.updateMatrix(),s.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const u=this._followObject.worldPosition,p=this.settings.snapGridResolution;u.x=Math.round(u.x/p)*p,u.y=Math.round(u.y/p)*p,u.z=Math.round(u.z/p)*p,this._followObject.worldPosition=u,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const a=it.clamp01(this.context.time.deltaTime*e*t),l=r.worldPosition;l.lerp(s.worldPosition,a),r.worldPosition=l;const c=r.worldQuaternion;c.slerp(s.worldQuaternion,a),r.worldQuaternion=c;const h=r.worldScale;h.lerp(s.worldScale,a),r.worldScale=h}setTargetObject(e){this.gameObject=e}}class S0e{constructor(e,t){d(this,"context"),d(this,"gameObject"),d(this,"settings"),d(this,"_lastRig"),d(this,"_followObject"),d(this,"_totalMovement",new C),d(this,"_totalMovementAlongRayDirection",0),d(this,"_grabStartDistance",0),d(this,"_deviceMode"),d(this,"_followObjectStartPosition",new C),d(this,"_followObjectStartQuaternion",new Ce),d(this,"_followObjectStartWorldQuaternion",new Ce),d(this,"_lastDragPosRigSpace"),d(this,"_tempVec",new C),d(this,"_tempMat",new ve),d(this,"_hitPointInLocalSpace",new C),d(this,"_hitNormalInLocalSpace",new C),d(this,"_bottomCenter",new C),d(this,"_backCenter",new C),d(this,"_backBottomCenter",new C),d(this,"_bounds",new bi),d(this,"_dragPlane",new Us(new C(0,1,0))),d(this,"_draggedOverObject",null),d(this,"_draggedOverObjectLastSetUp",null),d(this,"_draggedOverObjectLastNormal",new C),d(this,"_draggedOverObjectDuration",0),this.settings=e,this.context=e.context,this.gameObject=t,this._followObject=new Ae}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(e){this.gameObject=e}recenter(){var e,t;if(!this._followObject.parent){console.warn("Error: space follow object doesn't have parent but recenter() is called. This is likely a bug");return}const r=this._followObject.parent;this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.position.set(0,0,0),this._followObject.quaternion.set(0,0,0,1),this._followObject.scale.set(1,1,1),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0),r.attach(this._followObject),this._followObjectStartPosition.copy(this._followObject.position),this._followObjectStartQuaternion.copy(this._followObject.quaternion),this._followObjectStartWorldQuaternion.copy(this._followObject.worldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const s=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(s),this._grabStartDistance=s.distanceTo(r.worldPosition);const o=(t=(e=Ct.active)==null?void 0:e.rig)==null?void 0:t.gameObject,a=o?.worldScale.x||1;this._grabStartDistance/=a,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,vc&&(At.DrawLine(s,r.worldPosition,65280,.5,!1),At.DrawLabel(r.worldPosition.add(new C(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(e){if(e.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,e.point&&e.normal)this._hitPointInLocalSpace.copy(e.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(e.normal);else if(e){const f=e.event.space,g=f.worldPosition;this.gameObject.worldToLocal(g),this._hitPointInLocalSpace.copy(g);const v=f.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),v.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(v)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=e.mode;const t=this._followObject.parent.worldForward,r=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,s=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(s),r){case 0:const f=new C(0,1,0);this.gameObject.parent&&f.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(f,s);break;case 2:const g=this._hitNormalInLocalSpace.clone();g.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(g,s);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,s);break;case 3:const v=new C(0,1,0),A=t,y=v.angleTo(A),_=.5;y>Math.PI/2+_||y<Math.PI/2-_?this._dragPlane.setFromNormalAndCoplanarPoint(new C(0,1,0),s):this._dragPlane.setFromNormalAndCoplanarPoint(t,s);break}const o=this.gameObject.parent,a=this.gameObject.position.clone(),l=this.gameObject.quaternion.clone(),c=this.gameObject.scale.clone(),h=this.gameObject.matrixWorld.clone();o&&o.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1);const u=lu([this.gameObject]);u.expandByPoint(this.gameObject.worldPosition);const p=new C;u.getCenter(p);const m=new C;u.getSize(m),this._bottomCenter.copy(p.clone().add(new C(0,-m.y/2,0))),this._backCenter.copy(p.clone().add(new C(0,0,m.z/2))),this._backBottomCenter.copy(p.clone().add(new C(0,-m.y/2,m.z/2))),this._bounds.copy(u),o&&o.add(this.gameObject),this.gameObject.position.copy(a),this.gameObject.quaternion.copy(l),this.gameObject.scale.copy(c),this.gameObject.matrixWorld.copy(h),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var e,t;if(!this._followObject.parent)return;const r=this._followObject.parent;this._followObject.updateMatrix();const s=r.worldPosition,o=(t=(e=Ct.active)==null?void 0:e.rig)==null?void 0:t.gameObject;o&&o.worldToLocal(s),(this._lastDragPosRigSpace===void 0||o!=this._lastRig)&&(this._lastDragPosRigSpace=s.clone(),this._lastRig=o),this._tempVec.copy(s).sub(this._lastDragPosRigSpace);const a=r.worldForward;if(o&&(this._tempMat.copy(o.matrixWorld).invert(),a.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=a.dot(this._tempVec),this._tempVec.x=Math.abs(this._tempVec.x),this._tempVec.y=Math.abs(this._tempVec.y),this._tempVec.z=Math.abs(this._tempVec.z),this._totalMovement.add(this._tempVec),this._lastDragPosRigSpace.copy(s),vc){let l=s;o&&(l=l.clone(),l.transformDirection(o.matrixWorld)),At.DrawRay(l,a,255)}}onDragUpdate(e){if(e>1)return;const t=this.gameObject,r=this._followObject.parent;this._followObject.updateMatrix();const s=r.worldPosition,o=r.worldForward,a=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",l=a?this.settings.xrKeepRotation:this.settings.keepRotation,c=a?this.settings.xrDragMode:this.settings.dragMode;if(c===5)return;const h=10;l&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let u=1,p=2;if(a&&this._grabStartDistance>.5){const A=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);u=Math.max(0,A),u=u*u*u}else this._grabStartDistance<=.5&&(p=3);this._followObject.position.copy(this._followObjectStartPosition),l||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(u),this._followObject.updateMatrix();const m=new lo(s,o);if(c==4){const A=new pl;A.testObject=_=>_!==this.followObject&&_!==r&&_!==t;const y=this.context.physics.raycastFromRay(m,A);if(y.length>0){const _=y[0];if(this._draggedOverObject===_.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=_.object,this._draggedOverObjectDuration=0),_.face){const b=this._draggedOverObjectDuration>=.15,x=.001,E=this._totalMovement.length()>=x;if((b||E)&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(_.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(_.face.normal);const I=Di(),T=Di();this._bounds.getCenter(I),this._bounds.getSize(T),I.sub(T.multiplyScalar(.5).multiply(_.face.normal)),this._hitPointInLocalSpace.copy(I),this._hitNormalInLocalSpace.copy(_.face.normal),this._bounds.getCenter(I),this._bounds.getSize(T),I.add(T.multiplyScalar(.5).multiply(_.face.normal));const R=Di(this._hitPointInLocalSpace).add(I);this._followObject.localToWorld(R);const k=_.point;this._dragPlane.setFromNormalAndCoplanarPoint(_.face.normal,k)}else if(!(b||E))return}}}if(c!==1&&m.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const A=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(A),vc&&At.DrawLine(A,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(A),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const A=this._followObject.worldPosition,y=this.settings.snapGridResolution;A.x=Math.round(A.x/y)*y,A.y=Math.round(A.y/y)*y,A.z=Math.round(A.z/y)*y,this._followObject.worldPosition=A,this._followObject.updateMatrix()}l&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const f=it.clamp01(this.context.time.deltaTime*h*p),g=t.worldPosition;g.lerp(this._followObject.worldPosition,f),t.worldPosition=g;const v=t.worldQuaternion;if(v.slerp(this._followObject.worldQuaternion,f),t.worldQuaternion=v,vc){const A=this._hitPointInLocalSpace.clone();t.localToWorld(A),At.DrawSphere(A,.02,16711680);const y=this._hitNormalInLocalSpace.clone();y.applyQuaternion(v),At.DrawRay(A,y,16711680),At.DrawLabel(g.add(new C(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
6154
6154
 
6155
6155
  Along Ray: ${this._totalMovementAlongRayDirection.toFixed(2)}
6156
6156