@needle-tools/engine 3.45.2-beta.3 → 3.45.2-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/needle-engine.js +7 -6
- package/dist/needle-engine.light.js +7 -6
- package/dist/needle-engine.light.min.js +29 -29
- package/dist/needle-engine.light.umd.cjs +3 -3
- package/dist/needle-engine.min.js +3 -3
- package/dist/needle-engine.umd.cjs +3 -3
- package/lib/engine-components/DragControls.js +9 -0
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/ui/Raycaster.js +1 -1
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/package.json +2 -2
- package/plugins/types/userconfig.d.ts +6 -0
- package/plugins/vite/alias.js +38 -17
- package/src/engine-components/DragControls.ts +10 -0
- package/src/engine-components/ui/Raycaster.ts +1 -1
|
@@ -4344,7 +4344,7 @@ Open this page to get the console: `+A.toString())}const g=In()||bk()&&ae();if((
|
|
|
4344
4344
|
#__vconsole .vc-mask {
|
|
4345
4345
|
overflow: hidden;
|
|
4346
4346
|
}
|
|
4347
|
-
`,As==null||As.prepend(t),g===!0&&yJ()<=0&&h3(),console.log("🌵 Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const g=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+g._id+" iframe");return g.on("renderTab",function(e){const t=globalThis["needle:codegen_files"];if(!t||t.length===0)return;let i=globalThis["needle:codegen_files"][0];const I=i.indexOf("?");I>-1&&(i=i.substring(0,I));const s=location.protocol+"//"+location.host+location.pathname+"/"+i,n=encodeURIComponent(s);g.fullUrl="https://viewer.needle.tools?inspect&file="+n;var r='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(r)}),g.on("show",function(){const e=A();e&&e.src!==g.fullUrl&&(e.src=g.fullUrl)}),g.on("hide",function(){const e=A();e&&(e.src="")}),g.on("addTopBar",function(e){var t=new Array;t.push({name:"Open in new window ↗",onClick:function(i){window.open(g.fullUrl,"_blank"),os==null||os.hide()}}),t.push({name:"Reload",onClick:function(i){const I=A();I&&(I.src=g.fullUrl)}}),t.push({name:"Fullscreen",onClick:function(i){const I=A();I.requestFullscreen?I.requestFullscreen():I.webkitRequestFullscreen instanceof Function&&I.webkitRequestFullscreen()}}),e(t)}),g}function xgA(){const g=document.querySelector("#__vconsole .vc-switch");return g||null}function vgA(){const g=document.querySelector("#__vconsole");return g||null}const p3=gA("debugdefines");gd('if(!globalThis[""3.45.2-beta.
|
|
4347
|
+
`,As==null||As.prepend(t),g===!0&&yJ()<=0&&h3(),console.log("🌵 Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const g=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+g._id+" iframe");return g.on("renderTab",function(e){const t=globalThis["needle:codegen_files"];if(!t||t.length===0)return;let i=globalThis["needle:codegen_files"][0];const I=i.indexOf("?");I>-1&&(i=i.substring(0,I));const s=location.protocol+"//"+location.host+location.pathname+"/"+i,n=encodeURIComponent(s);g.fullUrl="https://viewer.needle.tools?inspect&file="+n;var r='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(r)}),g.on("show",function(){const e=A();e&&e.src!==g.fullUrl&&(e.src=g.fullUrl)}),g.on("hide",function(){const e=A();e&&(e.src="")}),g.on("addTopBar",function(e){var t=new Array;t.push({name:"Open in new window ↗",onClick:function(i){window.open(g.fullUrl,"_blank"),os==null||os.hide()}}),t.push({name:"Reload",onClick:function(i){const I=A();I&&(I.src=g.fullUrl)}}),t.push({name:"Fullscreen",onClick:function(i){const I=A();I.requestFullscreen?I.requestFullscreen():I.webkitRequestFullscreen instanceof Function&&I.webkitRequestFullscreen()}}),e(t)}),g}function xgA(){const g=document.querySelector("#__vconsole .vc-switch");return g||null}function vgA(){const g=document.querySelector("#__vconsole");return g||null}const p3=gA("debugdefines");gd('if(!globalThis[""3.45.2-beta.4""]) globalThis[""3.45.2-beta.4""] = "0.0.0";');gd('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";');gd('if(!globalThis[""Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)""]) globalThis[""Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)""] = "unknown";');gd('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta.4";');gd('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');gd('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)";');const Os="3.45.2-beta.4",_k="undefined",gx="Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)";p3&&console.log(`Engine version: ${Os} (generator: ${_k})
|
|
4348
4348
|
Project built at ${gx}`);const ja="needle_isActiveInHierarchy",ZQ="builtin_components",Sp="needle_editor_guid";function gd(g){try{(0,eval)(g)}catch(A){p3&&console.error(A)}}const qgA='<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>',LgA=btoa(qgA),_gA="data:image/svg+xml;base64,"+LgA,TgA=_gA,HgA=`<?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(HgA);const YgA='<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>',OgA=btoa(YgA),PgA="data:image/svg+xml;charset=utf-8;base64,"+OgA,WgA=PgA,_s=gA("debuglicense");let hc="basic";_s&&console.log("License Type: "+hc);function fB(){switch(hc){case"pro":case"enterprise":return!0}return!1}function Ix(){switch(hc){case"indie":return!0}return!1}function za(){return fB()||Ix()}const f3=[];function ZgA(g){if(fB()||Ix())return g(!0);f3.push(g)}function jgA(g){for(const A of f3)try{A(g)}catch{}}Et.registerCallback(Gt.ContextRegistered,g=>{XgA(g.context),AIA(),VgA(g.context)});let DB,WF=!1,Pu="";async function zgA(){if(DB)return DB;if(hc==="basic")try{const g="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Os+"&generator="+encodeURIComponent(_k),A=await fetch(g,{method:"GET"}).catch(e=>{_s&&console.error("License check failed",e)});(A==null?void 0:A.status)===200?(WF=!1,_s&&console.log("License check succeeded"),hc="pro",jgA(!0)):(A==null?void 0:A.status)===403?(WF=!0,Pu=await A.text()):_s&&console.log("License check failed with status "+(A==null?void 0:A.status))}catch(g){_s&&console.error("License check failed",g)}else _s&&console.log('Runtime license check is skipped because license is already applied as "'+hc+'"')}DB=zgA();async function VgA(g){function A(){const i=document.createElement("div");i.className="needle-forbidden",i.style.cssText=`
|
|
4349
4349
|
position: fixed;
|
|
4350
4350
|
top: 0;
|
|
@@ -5729,7 +5729,7 @@ Could not find method ${a.method} on object ${Q.name}`,Q,typeof Q[a.method])};if
|
|
|
5729
5729
|
// Uncomment to visualize blur amount
|
|
5730
5730
|
// gl_FragColor = vec4(blurAmount, 0.0, 0.0, 1.0);
|
|
5731
5731
|
}
|
|
5732
|
-
`;var iEA=Object.defineProperty,gEA=Object.getOwnPropertyDescriptor,Iv=(g,A,e,t)=>{for(var i=t>1?void 0:t?gEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&iEA(A,e,i),i};class sE extends FA{constructor(){super(...arguments);B(this,"constraintActive",!0);B(this,"locked",!1);B(this,"sources",[])}}Iv([D()],sE.prototype,"constraintActive",2);Iv([D()],sE.prototype,"locked",2);Iv([D(DA)],sE.prototype,"sources",2);function IEA(g,A){return ZB(g,Gt.ContextCreated,A),()=>jB(g,Gt.ContextCreated)}function oEA(g,A){return ZB(g,Gt.ContextClearing,A),()=>jB(g,Gt.ContextClearing)}function sEA(g,A){return ZB(g,Gt.ContextDestroying,A),()=>jB(g,Gt.ContextDestroying)}function oj(g,A){return ZB(g,oi.Start,A),()=>jB(g,oi.Start)}function sj(g,A){return ZB(g,oi.Update,A),()=>jB(g,oi.Update)}function nEA(g,A){return ZB(g,oi.OnBeforeRender,A),()=>jB(g,oi.OnBeforeRender)}function rEA(g,A){return ZB(g,oi.OnAfterRender,A),()=>jB(g,oi.OnAfterRender)}class yc{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,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(A,e,t,i){return A.prep(4,12),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class nj{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}position(A){return(A||new yc).__init(this.bb_pos,this.bb)}rotation(A){return(A||new yc).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new yc).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,t,i,I,o,s,n,r,a){return A.prep(4,36),A.prep(4,12),A.writeFloat32(a),A.writeFloat32(r),A.writeFloat32(n),A.prep(4,12),A.writeFloat32(s),A.writeFloat32(o),A.writeFloat32(I),A.prep(4,12),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class qa{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedTransformModel(A,e){return(e||new qa).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+Ox),(e||new qa).__init(A.readInt32(A.position())+A.position(),A)}guid(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}fast(){const A=this.bb.__offset(this.bb_pos,6);return A?!!this.bb.readInt8(this.bb_pos+A):!1}transform(A){const e=this.bb.__offset(this.bb_pos,8);return e?(A||new nj).__init(this.bb_pos+e,this.bb):null}dontSave(){const A=this.bb.__offset(this.bb_pos,10);return A?!!this.bb.readInt8(this.bb_pos+A):!1}static startSyncedTransformModel(A){A.startObject(4)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addFast(A,e){A.addFieldInt8(1,+e,0)}static addTransform(A,e){A.addFieldStruct(2,e,0)}static addDontSave(A,e){A.addFieldInt8(3,+e,0)}static endSyncedTransformModel(A){return A.endObject()}static finishSyncedTransformModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedTransformModelBuffer(A,e){A.finish(e,void 0,!0)}}var Lg=(g=>(g[g.Average=0]="Average",g[g.Multiply=1]="Multiply",g[g.Minimum=2]="Minimum",g[g.Maximum=3]="Maximum",g))(Lg||{}),lM=(g=>(g[g.Discrete=0]="Discrete",g[g.Continuous=1]="Continuous",g))(lM||{}),$i=(g=>(g[g.None=0]="None",g[g.FreezePositionX=2]="FreezePositionX",g[g.FreezePositionY=4]="FreezePositionY",g[g.FreezePositionZ=8]="FreezePositionZ",g[g.FreezePosition=14]="FreezePosition",g[g.FreezeRotationX=16]="FreezeRotationX",g[g.FreezeRotationY=32]="FreezeRotationY",g[g.FreezeRotationZ=64]="FreezeRotationZ",g[g.FreezeRotation=112]="FreezeRotation",g[g.FreezeAll=126]="FreezeAll",g))($i||{}),th=(g=>(g[g.None=0]="None",g[g.X=2]="X",g[g.Y=4]="Y",g[g.Z=8]="Z",g[g.All=-1]="All",g))(th||{});const DI=function(g,A){return function(e,t,i){aEA(e,t,i,g,A)}};function aEA(g,A,e,t,i){if(!i&&!t&&!g.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",g,A,e),fi("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,Is.Error);return}let I="";if(typeof A=="string"?I=A:I=A.name,g.__internalAwake){const o=Symbol(I),s=g.__internalAwake;g.__internalAwake=function(){var n;if(!this.onValidate){ae()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((n=g.constructor)==null?void 0:n.name)+'"');return}if(this[o]===void 0){this[o]=this[I];const r=this[I];if(r instanceof tA||r instanceof y||r instanceof Ae||r instanceof GA){const a=this[I];Kk(a,()=>{this.onValidate(I)})}Object.defineProperty(this,I,{set:function(a){var C;if(this[SK]===!0)this[o]=a;else{t==null||t.call(this,a);const Q=this[o];this[o]=a,(C=this.onValidate)==null||C.call(this,I,Q)}},get:function(){return i==null||i.call(this),this[o]}})}s.call(this)}}}const CEA=function(g){return function(A,e,t){let i="";typeof e=="string"?i=e:i=e.name;const I=g.prototype,o=Object.getOwnPropertyDescriptor(I,i);if(!(o!=null&&o.value)){console.warn("Can not apply prefix: type does not have method named",e,g);return}const s=o.value,n=A[i];Object.defineProperty(I,i,{value:function(...r){const a=n==null?void 0:n.call(this,...r);if(a instanceof Promise){a.then(C=>{if(C!==!1)return s.call(this,...r)});return}if(a!==!1)return s.call(this,...r)}})}};var BEA=Object.defineProperty,QEA=Object.getOwnPropertyDescriptor,Es=(g,A,e,t)=>{for(var i=t>1?void 0:t?QEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&BEA(A,e,i),i};class cEA{constructor(A,e){B(this,"positionChanged",!1);B(this,"rotationChanged",!1);B(this,"position");B(this,"quaternion");B(this,"_positionKeys",["x","y","z"]);B(this,"_quaternionKeys",["_x","_y","_z","_w"]);B(this,"mute",!1);B(this,"context");B(this,"obj");B(this,"_positionWatch");B(this,"_rotationWatch");this.context=e,this.obj=A}get isDirty(){return this.positionChanged||this.rotationChanged}reset(A=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,A){if(this.position)for(const e of this._positionKeys)delete this.position[e];if(this.quaternion)for(const e of this._quaternionKeys)delete this.quaternion[e]}}syncValues(){for(const A of this._positionKeys)this.position[A]=this.obj.position[A];for(const A of this._quaternionKeys)this.quaternion[A]=this.obj.quaternion[A]}applyValues(){if(this.positionChanged&&this.position)for(const A of this._positionKeys){const e=this.position[A];e!==void 0&&(this.obj.position[A]=e)}if(this.rotationChanged&&this.quaternion)for(const A of this._quaternionKeys){const e=this.quaternion[A];e!==void 0&&(this.obj.quaternion[A]=e)}}start(A,e){this.reset(),A&&(this._positionWatch||(this._positionWatch=new Za(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.position[o];Math.abs(s-I)<1e-5||(this.position[o]=I,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new Za(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.quaternion[o];Math.abs(s-I)<1e-5||(this.quaternion[o]=I,this.rotationChanged=!0)}));const t=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),i=new fA;this.obj.matrixWorld.multiplyMatrices=(I,o)=>{var s;return(s=this.context.physics.engine)!=null&&s.isUpdating||this.mute||i.equals(I)||(this.positionChanged=!0,this.rotationChanged=!0,i.copy(I)),t(I,o)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var FN;const WK=(FN=class extends FA{constructor(){super(...arguments);B(this,"autoMass",!0);B(this,"_mass",0);B(this,"useGravity",!0);B(this,"centerOfMass",new y(0,0,0));B(this,"constraints",$i.None);B(this,"isKinematic",!1);B(this,"drag",0);B(this,"angularDrag",1);B(this,"detectCollisions",!0);B(this,"sleepThreshold",.01);B(this,"collisionDetectionMode",lM.Discrete);B(this,"_gravityScale",1);B(this,"dominanceGroup",0);B(this,"_propertiesChanged",!1);B(this,"_currentVelocity",new y);B(this,"_smoothedVelocity",new y);B(this,"_smoothedVelocityGetter",new y);B(this,"_lastPosition",new y);B(this,"_watch")}set mass(A){A!==this._mass&&(this._mass=A,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var A,e;return this.autoMass?((e=(A=this.context.physics.engine)==null?void 0:A.getBody(this))==null?void 0:e.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&$i.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&$i.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&$i.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&$i.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&$i.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&$i.FreezeRotationZ)!==0}set lockPositionX(A){A?this.constraints|=$i.FreezePositionX:this.constraints&=~$i.FreezePositionX}set lockPositionY(A){A?this.constraints|=$i.FreezePositionY:this.constraints&=~$i.FreezePositionY}set lockPositionZ(A){A?this.constraints|=$i.FreezePositionZ:this.constraints&=~$i.FreezePositionZ}set lockRotationX(A){A?this.constraints|=$i.FreezeRotationX:this.constraints&=~$i.FreezeRotationX}set lockRotationY(A){A?this.constraints|=$i.FreezeRotationY:this.constraints&=~$i.FreezeRotationY}set lockRotationZ(A){A?this.constraints|=$i.FreezeRotationZ:this.constraints&=~$i.FreezeRotationZ}set gravityScale(A){this._gravityScale=A}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new cEA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),oi.LateUpdate)}onDisable(){var A,e;(A=this._watch)==null||A.stop(),(e=this.context.physics.engine)==null||e.removeBody(this)}onDestroy(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){var A,e,t,i;for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,(A=this.context.physics.engine)==null||A.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()):(i=this._watch)==null||i.syncValues(),this.captureVelocity(),yield}teleport(A,e=!0){var t;(t=this._watch)==null||t.reset(!0),e?this.gameObject.position.set(A.x,A.y,A.z):this.setWorldPosition(A.x,A.y,A.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(A=!0){var e;(e=this.context.physics.engine)==null||e.resetForces(this,A)}resetTorques(A=!0){var e;(e=this.context.physics.engine)==null||e.resetTorques(this,A)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var A;(A=this.context.physics.engine)==null||A.wakeup(this)}get isSleeping(){var A;return(A=this.context.physics.engine)==null?void 0:A.isSleeping(this)}updateProperties(){var A;return this._propertiesChanged=!1,(A=this.context.physics.engine)==null?void 0:A.updateProperties(this)}applyForce(A,e,t=!0){var i;this._propertiesChanged&&this.updateProperties(),(i=this.context.physics.engine)==null||i.addForce(this,A,t)}applyImpulse(A,e=!0){var t;this._propertiesChanged&&this.updateProperties(),(t=this.context.physics.engine)==null||t.applyImpulse(this,A,e)}setForce(A,e,t,i=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,i),typeof A=="number"?(e??(e=0),t??(t=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:A,y:e,z:t},i)):(s=this.context.physics.engine)==null||s.addForce(this,A,i)}getVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(A,e,t,i=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,i);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:A,y:e,z:t},i)}getAngularVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getAngularVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(A,e,t,i=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,i);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:A,y:e,z:t},i)}setTorque(A,e,t){this.setAngularVelocity(A,e,t)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(A=null){}captureVelocity(){const A=ve(this.gameObject);WK.tempPosition.copy(A);const e=A.sub(this._lastPosition);this._lastPosition.copy(WK.tempPosition),this._smoothedVelocity.lerp(e,this.context.time.deltaTime/.1)}},B(FN,"tempPosition",new y),FN);let Pt=WK;Es([DI()],Pt.prototype,"autoMass",2);Es([D()],Pt.prototype,"mass",1);Es([DI(),D()],Pt.prototype,"useGravity",2);Es([D(y)],Pt.prototype,"centerOfMass",2);Es([DI(),D()],Pt.prototype,"constraints",2);Es([DI(),D()],Pt.prototype,"isKinematic",2);Es([DI(),D()],Pt.prototype,"drag",2);Es([DI(),D()],Pt.prototype,"angularDrag",2);Es([DI(),D()],Pt.prototype,"detectCollisions",2);Es([DI(),D()],Pt.prototype,"sleepThreshold",2);Es([DI(),D()],Pt.prototype,"collisionDetectionMode",2);Es([DI()],Pt.prototype,"_gravityScale",2);Es([DI()],Pt.prototype,"dominanceGroup",2);const zC=gA("debugsync"),Nf="STRS";Wx(Nf,qa.getRootAsSyncedTransformModel);const er=new mD;function rj(g,A,e=!0){er.clear();const t=er.createString(g);qa.startSyncedTransformModel(er),qa.addGuid(er,t),qa.addFast(er,e);const i=A.worldPosition,I=A.worldEuler,o=A.gameObject.scale;qa.addTransform(er,nj.createTransform(er,i.x,i.y,i.z,I.x,I.y,I.z,o.x,o.y,o.z));const s=qa.endSyncedTransformModel(er);return er.finish(s,Nf),er.asUint8Array()}let ZK=0,Lp=0;sj(g=>{var t;const e=((t=g.connection.currentServerUrl)==null?void 0:t.includes("glitch"))?10:40;Lp=Math.floor(ZK/e),ZK=0,zC&&Lp>0&&console.log("Sync Transform Fast Interval",Lp)});class bB extends FA{constructor(){super(...arguments);B(this,"overridePhysics",!0);B(this,"interpolatePosition",!0);B(this,"interpolateRotation",!0);B(this,"fastMode",!1);B(this,"syncDestroy",!1);B(this,"_model",null);B(this,"_needsUpdate",!0);B(this,"rb",null);B(this,"_wasKinematic",!1);B(this,"_receivedDataBefore",!1);B(this,"_targetPosition");B(this,"_targetRotation");B(this,"_receivedFastUpdate",!1);B(this,"_shouldRequestOwnership",!1);B(this,"joinedRoomCallback",null);B(this,"receivedDataCallback",null);B(this,"tempEuler",new rt);B(this,"receivedUpdate",!1);B(this,"lastWorldPos");B(this,"lastWorldRotation")}requestOwnership(){zC&&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(){zC&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new y,this._targetRotation=new GA,this.lastWorldPos=new y,this.lastWorldRotation=new GA,this.rb=sA.getComponentInChildren(this.gameObject,Pt),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new $x(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(ze.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(Nf,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&tv(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(ze.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(Nf,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){zC&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const i=e.transform();if(i){Ws.markDirty(this.gameObject,!0);const I=i.position();I&&(this.interpolatePosition&&((t=this._targetPosition)==null||t.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=i.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&$J(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){zC&&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),s=t.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(zC&&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),Ws.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const s=this._receivedFastUpdate||this.fastMode?.5:.3;let n=!1;if(this.interpolatePosition&&this._targetPosition){const r=this.worldPosition;r.lerp(this._targetPosition,s),this.worldPosition=r,n=!0}if(this.interpolateRotation&&this._targetRotation){const r=this.worldQuaternion;r.slerp(this._targetRotation,s),this.worldQuaternion=r,n=!0}n&&Ws.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&&(zC&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const i=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%i===0||I)){if(ZK++,I&&Lp>0&&this.context.time.frameCount%Lp!==0)return;zC&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const o=rj(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const EEA=gA("debugshadowcomponents");PJ.prototype.interactable={get(){return this.interactive},set(g){this.interactable=g}};const Hs=Symbol("shadowDomOwner");class Xs extends FA{constructor(){super(...arguments);B(this,"_shadowComponent",null);B(this,"_controlsChildLayout",!0);B(this,"_root");B(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(){Uo.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=sA.getComponentInParent(this.gameObject,JD)),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 o;if(!e)return;this.removeShadowComponent();const i=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=sA.getComponentInParent(i,Xs),!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[Hs]=this,this.setShadowComponentOwner(e);let I=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(e);else{const s=this._parentComponent.shadowComponent;s&&(s==null||s.add(e),I=!0)}this.shadowComponent=e,t&&t.shadowComponent&&this.shadowComponent&&t.shadowComponent.add(this.shadowComponent),SD&&e.add(new Qs(.5)),this.onAfterAddedToScene(),I&&s3(),EEA&&console.warn("Added shadow component",this.shadowComponent)}setShadowComponentOwner(e){if(e&&(e[Hs]===void 0||e[Hs]===this)&&(e[Hs]=this,e.children))for(const t of e.children)this.setShadowComponentOwner(t)}traverseOwnedShadowComponents(e,t,i){if(e&&e[Hs]===t){i(e);for(const I of e.children)this.traverseOwnedShadowComponents(I,t,i)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(e){this.shadowComponent&&(this.shadowComponent.interactable=e)}}class JD extends Xs{awake(){super.awake()}}class Ed{constructor(A,e){B(this,"event");B(this,"button");B(this,"buttonName");B(this,"_used",!1);B(this,"_propagationStopped",!1);B(this,"z__pointer_ctured",!1);B(this,"z__pointer_cture_rleased",!1);B(this,"inputSource");B(this,"object");B(this,"point");B(this,"normal");B(this,"face");B(this,"distance");B(this,"instanceId");B(this,"intersection");B(this,"isDown");B(this,"isUp");B(this,"isPressed");B(this,"isClick");B(this,"isDoubleClick");B(this,"input");this.event=e,this.input=A,this.button=e.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 A=new Ed(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function jK(g,A){return sA.foreachComponent(g,t=>{if(!t.enabled)return;const i=t;if(A)switch(A){case"pointerdown":if(i.onPointerDown)return!0;break;case"pointerup":if(i.onPointerUp||i.onPointerClick)return!0;break;case"pointermove":if(i.onPointerEnter||i.onPointerExit||i.onPointerMove)return!0;break}else if(i.onPointerDown||i.onPointerUp||i.onPointerEnter||i.onPointerExit||i.onPointerClick)return!0},!1)===!0}var lEA=Object.defineProperty,hEA=Object.getOwnPropertyDescriptor,dEA=(g,A,e,t)=>{for(var i=t>1?void 0:t?hEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&lEA(A,e,i),i};class xD extends FA{awake(){Uo.createIfNoneExists(this.context)}onEnable(){var A;(A=Uo.get(this.context))==null||A.register(this)}onDisable(){var A;(A=Uo.get(this.context))==null||A.unregister(this)}}class cs extends xD{constructor(){super(...arguments);B(this,"targets",null);B(this,"raycastHits",[]);B(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Yn),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=I=>I instanceof Fo?"continue in children":t?t(I):!0);const i=this.context.physics.raycast(e);return e.testObject=t,i}}dEA([D()],cs.prototype,"ignoreSkinnedMeshes",2);class hM extends cs{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class Ff extends xD{performRaycast(A){if(!ye.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.01;return this.context.physics.sphereOverlap(e,t)}}class dM{static getObject(A){const e=A[Hs];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const i=Oc(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&(i==null?void 0:i.isGraphic)===!0&&(e.graphic=i),!((i==null?void 0:i.raycastTarget)===!1||(i==null?void 0:i.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=Oc(A,t=>{const i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function ov(g){const A=g[Hs];return A||(g.parent?ov(g.parent):null)}function uEA(g){return g.isUI===!0||typeof g[Hs]=="object"}function ym(g,A){if(!g)return;const e=g.material;if((e==null?void 0:e.isMaterial)===!0){const t=g.parent;t&&t.isText,e.side=A.doubleSided??!0?kt:Gg,e.shadowSide=A.doubleSided?kt:Gg,g.castShadow=A.castShadows?A.castShadows:!1,g.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of g.children)ym(t,A)}function vl(g,A,e){g[A]===void 0&&console.warn("Field",A,"is undefined on",g);const t=Proxy.revocable(g[A],{set(o,s,n,r){const a=o[s],C=Reflect.set(o,s,n,r);return e(n,a),C}}),i=t.revoke,I=g[A];return t.revoke=()=>{g[A]=I,i()},g[A]=t.proxy,t}const p2=Symbol("Scheduled action");function pEA(g,A,e=oi.OnBeforeRender){let t=g[p2];t||(t=g[p2]={});const i=A.name;t[e]||(t[e]={});const I=t[e];if(I[i])return;function*s(){A==null||A.call(g),I[i]=null}const n=g.startCoroutine(s(),e);I[i]=n}const fa=gA("debugeventsystem");var zK=(g=>(g.BeforeHandleInput="BeforeHandleInput",g.AfterHandleInput="AfterHandleInput",g))(zK||{});const Br=class extends FA{constructor(){super();B(this,"raycaster",[]);B(this,"_handleInputFn");B(this,"pressedByID",new Map);B(this,"hoveredByID",new Map);B(this,"_sortedHits",[]);B(this,"_testObjectsCache",new Map);B(this,"_currentlyActiveRaycaster",null);B(this,"_currentPointerEventName",null);B(this,"shouldRaycastObject",e=>{var I;let t=null;if(uEA(e)&&(t=(I=e[Hs])==null?void 0:I.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let o=jK(e,this._currentPointerEventName);if(!o&&t&&(o=jK(t,this._currentPointerEventName)),o){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});B(this,"_sortingBuffer",[]);B(this,"_noDepthTestingResults",[]);B(this,"out",{});B(this,"_capturedPointer",{});B(this,"pointerEnterSymbol",Symbol("pointerEnter"));B(this,"pointerExitSymbol",Symbol("pointerExit"));B(this,"currentActiveMeshUIComponents",[]);Br.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Br.systems.length<=0&&Br.systems.push(...sA.findObjectsOfType(Br,e)));for(const i of Br.systems)if(i.context===e)return;const t=new DA;sA.addNewComponent(t,Br),e.scene.add(t)}static get systems(){const e=be.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,i=!1){oB.update(e,t,i)}static markUIDirty(e){oB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Br.systems.splice(Br.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!sA.findObjectOfType(xD,this.context)){const t=sA.addNewComponent(this.context.scene,cs);this.raycaster.push(t),(ae()||fa)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var i,I;const t=(i=this.raycaster)==null?void 0:i.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(pi.PointerDown,this._handleInputFn),this.context.input.addEventListener(pi.PointerUp,this._handleInputFn),this.context.input.addEventListener(pi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(pi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(pi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(pi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(e){if(e===void 0||e.propagationStopped)return;const t=new Ed(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==pi.PointerDown,t.isUp=e.type==pi.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),fa&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const i=new Yn;e.hasRay?i.ray=e.ray:i.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const I=this.performRaycast(i);if(I){for(const s of I)s.event=e,e.intersections.push(s);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:I})}fa&&t.isClick&&fi("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const o={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Yn),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const i=t.performRaycast(e);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((t,i)=>t.distance-i.distance),this._sortedHits}assignHitInformation(e,t){t?(e.intersection=t,e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var I;if(e!=null&&e.length){e=this.sortCandidates(e);for(const o of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,o),this.handleEventOnObject(o.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const i=this.hoveredByID.get(t.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((I=this.pressedByID.get(t.pointerId))==null||I.handlers.forEach(o=>this.invokeOnPointerUp(t,o)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const i=e[t],I=i.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&fa&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return fa&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const i=e.parent,I=t.isClick??!1;let o=null;if(i&&i.isUI){const C=(t.isPressed||t.isClick)??!1;if(i[Hs]){const Q=i[Hs].gameObject;if(Q){if(!dM.isInteractable(Q,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,C),e=Q}}}I&&fa&&console.log(this.context.time.frame,e);const s=this.hoveredByID.get(t.pointerId),n=s==null?void 0:s.obj;n!==e&&n&&this.propagatePointerExit(n,s.data,e);const a=this.hoveredByID.get(t.pointerId);if(a?(a.obj=e,a.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const C=this.pressedByID.get(t.pointerId);C?(C.obj=e,C.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(e,t,n??null),!0}propagate(e,t){for(;e;)sA.foreachComponent(e,i=>{t(i)},!1),e=e.parent}handleMainInteraction(e,t,i){const I=this.pressedByID.get(t.pointerId),o=i!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),r=this.context.input.getPointerPosition(t.pointerId);s=n&&!ge.approximately(n,r);break}this.propagate(e,n=>{var a;const r=n;r.interactable!==!1&&(!r.activeAndEnabled||!r.enabled||(r.onPointerEnter&&o&&this.handlePointerEnter(r,t),t.isDown&&r.onPointerDown&&(r.onPointerDown(t),I==null||I.handlers.add(r),this.handlePointerCapture(t,r)),r.onPointerMove&&(s&&r.onPointerMove(t),this.handlePointerCapture(t,r)),t.isUp&&(r.onPointerUp&&(this.invokeOnPointerUp(t,r),I==null||I.handlers.delete(r)),r.onPointerExit&&((a=t.event)==null?void 0:a.pointerType)===gM.Touch&&(this.handlePointerExit(r,t),this.hoveredByID.delete(t.pointerId))),t.isClick&&r.onPointerClick&&r.onPointerClick(t)))}),t.isUp&&(I==null||I.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,i){this.propagate(e,I=>{if(!I.gameObject||I.destroyed)return;const o=I;if(o.onPointerExit){if(i&&this.isChild(i,I.gameObject))return;this.handlePointerExit(o,t)}})}invokeOnPointerUp(e,t){var i;(i=t.onPointerUp)==null||i.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,i,I){let o=e[i];if(I)return o&&o.includes(t)?!1:(o=o||[],o.push(t),e[i]=o,!0);{if(!o||!o.includes(t))return!1;const s=o.indexOf(t);return s!==-1&&o.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const i=e.pointerId;if(t.onPointerMove){const I=this._capturedPointer[i]||[];I.push(t),this._capturedPointer[i]=I}else ae()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const i=e.pointerId;if(this._capturedPointer[i]){const I=this._capturedPointer[i].indexOf(t);I!==-1&&(this._capturedPointer[i].splice(I,1),fa&&console.log("released pointer capture",i,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===pi.PointerMove){const i=e.pointerId,I=this._capturedPointer[i];if(I){fa&&console.log("Captured",i,I);for(let o=0;o<I.length;o++){const s=I[o];if(s.destroyed){I.splice(o,1),o--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const i=oB.updateState(e,t);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&oB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];oB.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?sA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let Uo=Br;B(Uo,"_eventSystemMap",new Map),B(Uo,"didSearchEventSystem",!1);class oB{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const i=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(i===I.frame)return;I.frame=i;let o=this.needsUpdate||i<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(fa&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}B(oB,"lastSelected",null),B(oB,"lastUpdateFrame",[]),B(oB,"needsUpdate",!1);var fEA=Object.defineProperty,DEA=Object.getOwnPropertyDescriptor,wi=(g,A,e,t)=>{for(var i=t>1?void 0:t?DEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&fEA(A,e,i),i};const PU=gA("debugorbit"),ES=gA("freecam"),lS=gA("debugcamerafit"),hS=gA("smoothcam"),yEA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let WU;class Kf extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Mt extends FA{constructor(){super(...arguments);B(this,"autoTarget",!0);B(this,"autoFit",!1);B(this,"enableRotate",!0);B(this,"autoRotate",!1);B(this,"autoRotateSpeed",1);B(this,"minAzimuthAngle",1/0);B(this,"maxAzimuthAngle",1/0);B(this,"minPolarAngle",0);B(this,"maxPolarAngle",Math.PI);B(this,"enableKeys",!0);B(this,"enableDamping",!0);B(this,"dampingFactor",.1);B(this,"enableZoom",!0);B(this,"minZoom",0);B(this,"maxZoom",1/0);B(this,"zoomSpeed",1);B(this,"zoomToCursor",!1);B(this,"enablePan",!0);B(this,"lookAtConstraint",null);B(this,"lookAtConstraint01",1);B(this,"allowInterrupt",!0);B(this,"middleClickToFocus",!0);B(this,"doubleClickToFocus",!0);B(this,"clickBackgroundToFitScene",2);B(this,"debugLog",!1);B(this,"targetLerpDuration",1);B(this,"_controls",null);B(this,"_cameraObject",null);B(this,"_lookTargetLerpActive",!1);B(this,"_lookTargetStartPosition",new y);B(this,"_lookTargetEndPosition",new y);B(this,"_lookTargetLerp01",0);B(this,"_lookTargetLerpDuration",0);B(this,"_cameraLerpActive",!1);B(this,"_cameraStartPosition",new y);B(this,"_cameraEndPosition",new y);B(this,"_cameraLerp01",0);B(this,"_cameraLerpDuration",0);B(this,"_inputs",0);B(this,"_enableTime",0);B(this,"_startedListeningToKeyEvents",!1);B(this,"_eventSystem");B(this,"_afterHandleInputFn");B(this,"_camera",null);B(this,"_syncedTransform");B(this,"_didSetTarget",0);B(this,"targetElement",null);B(this,"_lastTimeClickOnBackground",-1);B(this,"_clickOnBackgroundCount",0);B(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}PU&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});B(this,"_shouldDisable",!1);B(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera(this.scene.children,{centerCamera:"y",immediate:!0}))});B(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._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Uo.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(zK.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(zK.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=sA.getComponent(this.gameObject,Wt);this._camera=e;let t=e==null?void 0:e.cam;if(!t&&this.gameObject instanceof He&&(t=this.gameObject),t&&TF(t,this,!0),!this._controls&&t instanceof He){this._cameraObject=t;const i=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new Ij(t,i),t==null||t.quaternion.copy(I),WU===void 0&&(WU={...this._controls.keys})}this._controls&&(ES&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,In()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?ES||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):ES||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=sA.getComponent(this.gameObject,bB)??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&&TF(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 t,i;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)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.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 I=sA.getComponent(this.gameObject,Wt);if(I&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const o=ve(I.cam),s=Math.max(.01,o.length()),n=new y(0,0,-s).applyMatrix4(I.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.setLookTargetFromConstraint()){const o=new Yn;o.screenPoint=new tA(0,0),o.lineThreshold=.1;const s=this.context.physics.raycast(o);s.length>0&&this.setLookTargetPosition(s[0].point,!0),lS&&console.log("OrbitControls hits",...s)}}let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&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 Kf(this,"camera"));else{const I=ge.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}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 Kf(this,"lookat"));else{const I=ge.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}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?WU:yEA,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 hS=="number"||hS===!0){this._controls.enableDamping=!0;const I=typeof hS=="number"?hS:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}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||(!ES&&((i=this.lookAtConstraint)!=null&&i.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),PU&&fe.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof DA))return;const t=ve(e),i=VJ(e);this.setTargetFromRaycast(new xo(t,i)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var i,I;e&&(e instanceof DA&&(e=ve(e)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.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 DA&&(e=ve(e)),this._lookTargetEndPosition.copy(e),PU&&(console.warn("OrbitControls: setLookTargetPosition",e,t),fe.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 I;if(!this._controls)return!1;const i=(I=this.lookAtConstraint)==null?void 0:I.sources;if(i&&i.length>0){const o=i[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 i of t)if(i.distance>0&&sA.isActiveInHierarchy(i.object)){const I=ov(i.object);if(I){const o=I.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(e,t={fitOffset:void 0,immediate:!1}){if(this.context.isInXR)return;const{immediate:i=!1,centerCamera:I}=t;let{fitOffset:o}=t;o==null&&(o=1.1);const s=this._cameraObject,n=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(!s||!n){console.warn("No camera or controls found to fit camera to objects...");return}const r=new y,a=new y,C=qr(e,void 0);s.updateMatrixWorld(),s.updateProjectionMatrix(),C.getCenter(a);const Q=new y;if(C.getSize(Q),C.applyMatrix4(s.matrixWorldInverse),C.getSize(r),C.setFromCenterAndSize(a,r),Number.isNaN(r.x)||Number.isNaN(r.y)||Number.isNaN(r.z)){console.warn("Camera fit size resultet in NaN",s,C,[...e]);return}if(r.length()<=1e-10){lS&&console.warn("Camera fit size is zero",C,[...e]);return}const c=s.fov,E=2*Math.atan(Math.tan(c*Math.PI/360/2)*s.aspect)/Math.PI*360,h=r.y/(2*Math.atan(Math.PI*c/360)),l=r.x/(2*Math.atan(Math.PI*E/360)),d=o*Math.max(h,l)+r.z/2;lS&&console.log("Fit camera to objects",h,l,"distance",d),n.maxDistance=d*10,n.minDistance=d*.01;const p=.05,u=a.clone();u.y-=r.y*p,this.setLookTargetPosition(u,i),this.autoTarget=!1;const f=sA.findObjectOfType(VB),w=f?f.radius:0,m=Math.max(Q.x,Q.y,Q.z,w);s.near=d/100,s.far=m+d*10,s.updateMatrixWorld(),s.updateProjectionMatrix();const M=ve(s),G=a.clone();if(G.sub(M),I==="y"&&(G.y=0),G.normalize(),G.multiplyScalar(d),I==="y"&&(G.y+=-p*4*r.y),s.parent){const U=s.parent.worldToLocal(a.clone().sub(G));this.setCameraTargetPosition(U,i)}else console.error(`Can not fit camera ${s.name} because it has no parent`);if(lS){const U=new dJ(C);this.context.scene.add(U),Ax(U,dD(s)),setTimeout(()=>{this.context.scene.remove(U)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",S=>{S.code==="KeyF"&&this.fitCamera(e,{fitOffset:o,immediate:i})}))}n.update()}}wi([D()],Mt.prototype,"autoTarget",2);wi([D()],Mt.prototype,"autoFit",2);wi([D()],Mt.prototype,"enableRotate",2);wi([D()],Mt.prototype,"autoRotate",2);wi([D()],Mt.prototype,"autoRotateSpeed",2);wi([D()],Mt.prototype,"minAzimuthAngle",2);wi([D()],Mt.prototype,"maxAzimuthAngle",2);wi([D()],Mt.prototype,"minPolarAngle",2);wi([D()],Mt.prototype,"maxPolarAngle",2);wi([D()],Mt.prototype,"enableKeys",2);wi([D()],Mt.prototype,"enableDamping",2);wi([D()],Mt.prototype,"dampingFactor",2);wi([D()],Mt.prototype,"enableZoom",2);wi([D()],Mt.prototype,"minZoom",2);wi([D()],Mt.prototype,"maxZoom",2);wi([D()],Mt.prototype,"zoomSpeed",2);wi([D()],Mt.prototype,"enablePan",2);wi([D(sE)],Mt.prototype,"lookAtConstraint",2);wi([D()],Mt.prototype,"lookAtConstraint01",2);wi([D()],Mt.prototype,"allowInterrupt",2);wi([D()],Mt.prototype,"middleClickToFocus",2);wi([D()],Mt.prototype,"doubleClickToFocus",2);wi([D()],Mt.prototype,"clickBackgroundToFitScene",2);wi([D()],Mt.prototype,"targetLerpDuration",2);var wEA=Object.defineProperty,SEA=Object.getOwnPropertyDescriptor,uo=(g,A,e,t)=>{for(var i=t>1?void 0:t?SEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&wEA(A,e,i),i},kB=(g=>(g[g.Skybox=1]="Skybox",g[g.SolidColor=2]="SolidColor",g[g.Uninitialized=4]="Uninitialized",g))(kB||{});const Ma=gA("debugcam"),f2=gA("debugscreenpointtoray");var qS;const op=(qS=class extends FA{constructor(){super(...arguments);B(this,"_nearClipPlane",.1);B(this,"_farClipPlane",1e3);B(this,"orthographic",!1);B(this,"orthographicSize",5);B(this,"ARBackgroundAlpha",0);B(this,"_cullingMask",4294967295);B(this,"_backgroundBlurriness",0);B(this,"_backgroundIntensity",1);B(this,"_backgroundRotation");B(this,"_environmentIntensity");B(this,"_targetTexture",null);B(this,"_backgroundColor");B(this,"_fov");B(this,"_cam",null);B(this,"_clearFlags",2);B(this,"_skybox");B(this,"_frustum");B(this,"_projScreenMatrix",new fA)}get isCamera(){return!0}get aspect(){return this._cam instanceof He?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(A){this._cam instanceof He&&this._cam.aspect!==A&&(this._cam.aspect=A,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof He?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof He){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(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(A){A!==this._backgroundRotation&&(A===void 0?this._backgroundRotation=void 0:this._backgroundRotation=A,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const i=this.cam,I=op._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),f2&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(i);const o=op._direction.set(I.x,I.y,I.z),s=ve(i);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new xo(s.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new Kc,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Kc),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(A,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),A===this._projScreenMatrix?A:A.copy(this._projScreenMatrix)}awake(){f2&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const i=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);fe.DrawRay(i.origin,i.direction,I,10)})}onEnable(){Ma&&console.log(`Camera enabled: "${this.name}". ClearFlags=${kB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),kEA(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 A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof He&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof He&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new He(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 Tr(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(A){this.context.mainCameraComponent===this&&this.applyClearFlags(A)}applyClearFlags(A){if(!this._cam){Ma&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Ma){const e=`Camera "${this.name}" clear flags: ${kB[this._clearFlags]}`;console.debug(e)}switch(this._clearFlags){case 1:if(op.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||(A==null?void 0:A.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:Ma&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:Ma&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;op.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else Ma&&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 mEA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;Ma&&fi("Environment blend mode: "+t+" on "+navigator.userAgent);let i=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(i=!0),e._transparent=i,i}},B(qS,"_origin",new y),B(qS,"_direction",new y),qS);let Wt=op;uo([D()],Wt.prototype,"aspect",1);uo([D()],Wt.prototype,"fieldOfView",1);uo([D()],Wt.prototype,"nearClipPlane",1);uo([D()],Wt.prototype,"farClipPlane",1);uo([D()],Wt.prototype,"clearFlags",1);uo([D()],Wt.prototype,"orthographic",2);uo([D()],Wt.prototype,"orthographicSize",2);uo([D()],Wt.prototype,"ARBackgroundAlpha",2);uo([D()],Wt.prototype,"cullingMask",1);uo([D()],Wt.prototype,"backgroundBlurriness",1);uo([D()],Wt.prototype,"backgroundIntensity",1);uo([D(rt)],Wt.prototype,"backgroundRotation",1);uo([D()],Wt.prototype,"environmentIntensity",1);uo([D(Ft)],Wt.prototype,"backgroundColor",1);uo([D(mB)],Wt.prototype,"targetTexture",1);class mEA{constructor(A){B(this,"_camera");B(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ma&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=No,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)),(Ma||ae())&&Ot(`Camera "${this._camera.name}" has no skybox texture`))}}function kEA(g){gA("freecam")&&g.context.mainCameraComponent===g&&sA.getOrAddComponent(g.gameObject,Mt)}class MB extends FA{constructor(){super(...arguments);B(this,"_listener",null);B(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new ZP),this._listener}onEnable(){Fr.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Fr.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const t=this.context.mainCameraComponent||sA.getComponentInParent(this.gameObject,Wt);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 MEA extends Oi{constructor(A,e=1,t=16,i=2){const I=new we,o=t+i*2,s=new Float32Array((o*3+3)*3);I.setAttribute("position",new ne(s,3));const n=new Ii({color:65280}),r=new Ii({color:16776960});super(I,[r,n]),this.audio=A,this.range=e,this.divisionsInnerAngle=t,this.divisionsOuterAngle=i,this.type="PositionalAudioHelper",this.update()}update(){const A=this.audio,e=this.range,t=this.divisionsInnerAngle,i=this.divisionsOuterAngle,I=ht.degToRad(A.panner.coneInnerAngle),o=ht.degToRad(A.panner.coneOuterAngle),s=I/2,n=o/2;let r=0,a=0,C,Q;const c=this.geometry,E=c.attributes.position;c.clearGroups();function h(l,d,p,u){const f=(d-l)/p;for(E.setXYZ(r,0,0,0),a++,C=l;C<d;C+=f)Q=r+a,E.setXYZ(Q,Math.sin(C)*e,0,Math.cos(C)*e),E.setXYZ(Q+1,Math.sin(Math.min(C+f,d))*e,0,Math.cos(Math.min(C+f,d))*e),E.setXYZ(Q+2,0,0,0),a+=3;c.addGroup(r,a,u),r+=a,a=0}h(-n,-s,i,0),h(-s,s,t,1),h(s,n,i,0),E.needsUpdate=!0,I===o&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var GEA=Object.defineProperty,REA=Object.getOwnPropertyDescriptor,Pr=(g,A,e,t)=>{for(var i=t>1?void 0:t?REA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&GEA(A,e,i),i};const NI=gA("debugaudio"),VC=class extends FA{constructor(){super(...arguments);B(this,"clip","");B(this,"playOnAwake",!1);B(this,"preload",!1);B(this,"_spatialBlend",0);B(this,"_minDistance",1);B(this,"_maxDistance",100);B(this,"_volume",1);B(this,"rollOffMode",0);B(this,"playInBackground",!0);B(this,"_loop",!1);B(this,"sound",null);B(this,"helper",null);B(this,"wasPlaying",!1);B(this,"audioLoader",null);B(this,"shouldPlay",!1);B(this,"_lastClipStartedLoading",null);B(this,"_audioElement",null);B(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||In())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":NI&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,VC.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&VC.userInteractionRegistered&&this.wasPlaying&&this.play();break}});B(this,"onApplicationMuteChanged",()=>{var A,e;this.context.application.muted?(A=this.sound)==null||A.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});B(this,"createAudio",A=>{NI&&console.log("AudioBuffer finished loading",A);const e=this.Sound;if(!e){NI&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),A&&e.setBuffer(A),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&VC.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),VC.registerWaitForAllowAudio(this.__onAllowAudioCallback)});B(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});B(this,"_lastContextTime",0);B(this,"_hasEnded",!0);B(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Fr.userInteractionRegistered}static registerWaitForAllowAudio(A){Fr.registerWaitForAllowAudio(A)}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(A){this._loop=A,this.sound&&this.sound.setLoop(A)}get spatialBlend(){return this._spatialBlend}set spatialBlend(A){A!==this._spatialBlend&&(this._spatialBlend=A,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(A){this._minDistance!==A&&(this._minDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(A){this._maxDistance!==A&&(this._maxDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(A){this._volume=A,this.sound&&!this.context.application.muted&&(NI&&console.log(this.name,"audio set volume",A),this.sound.setVolume(A))}get Sound(){var A;if(!this.sound&&VC.userInteractionRegistered){let e=sA.getComponent(this.context.mainCamera,MB)??sA.findObjectOfType(MB,this.context);!e&&this.context.mainCamera&&(e=sA.addNewComponent(this.context.mainCamera,MB)),e!=null&&e.listener?(this.sound=new jP(e.listener),(A=this.gameObject)==null||A.add(this.sound)):NI&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var A;return(A=this.sound)==null?void 0:A.context}awake(){NI&&console.log(this),this.audioLoader=new O0,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),VC.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():VC.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(Em.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(Em.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const A=this.sound;if(!A)return;this._needUpdateSpatialDistanceSettings=!1;const e=ge.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(NI&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),A.setRefDistance(e),A.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:A.setDistanceModel("exponential");break;case 1:A.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?NI&&!this.helper&&(this.helper=new MEA(A,A.getRefDistance()),A.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(A){if(A&&(this.clip=A),typeof A=="string")if(NI&&console.log(A),A.endsWith(".mp3")||A.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new O0),this.shouldPlay=!0,this._lastClipStartedLoading===A){NI&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=A,NI&&console.log("load audio",A);const e=await this.audioLoader.loadAsync(A).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",A);else this.shouldPlay=!0,this.createAudio()}play(A=void 0){var t,i,I;!A&&this.clip&&(A=this.clip),A!==void 0&&typeof A!="string"&&!(A instanceof MediaStream)&&(ae()&&console.warn("Called play on AudioSource with unknown argument type:",A+`
|
|
5732
|
+
`;var iEA=Object.defineProperty,gEA=Object.getOwnPropertyDescriptor,Iv=(g,A,e,t)=>{for(var i=t>1?void 0:t?gEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&iEA(A,e,i),i};class sE extends FA{constructor(){super(...arguments);B(this,"constraintActive",!0);B(this,"locked",!1);B(this,"sources",[])}}Iv([D()],sE.prototype,"constraintActive",2);Iv([D()],sE.prototype,"locked",2);Iv([D(DA)],sE.prototype,"sources",2);function IEA(g,A){return ZB(g,Gt.ContextCreated,A),()=>jB(g,Gt.ContextCreated)}function oEA(g,A){return ZB(g,Gt.ContextClearing,A),()=>jB(g,Gt.ContextClearing)}function sEA(g,A){return ZB(g,Gt.ContextDestroying,A),()=>jB(g,Gt.ContextDestroying)}function oj(g,A){return ZB(g,oi.Start,A),()=>jB(g,oi.Start)}function sj(g,A){return ZB(g,oi.Update,A),()=>jB(g,oi.Update)}function nEA(g,A){return ZB(g,oi.OnBeforeRender,A),()=>jB(g,oi.OnBeforeRender)}function rEA(g,A){return ZB(g,oi.OnAfterRender,A),()=>jB(g,oi.OnAfterRender)}class yc{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,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(A,e,t,i){return A.prep(4,12),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class nj{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}position(A){return(A||new yc).__init(this.bb_pos,this.bb)}rotation(A){return(A||new yc).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new yc).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,t,i,I,o,s,n,r,a){return A.prep(4,36),A.prep(4,12),A.writeFloat32(a),A.writeFloat32(r),A.writeFloat32(n),A.prep(4,12),A.writeFloat32(s),A.writeFloat32(o),A.writeFloat32(I),A.prep(4,12),A.writeFloat32(i),A.writeFloat32(t),A.writeFloat32(e),A.offset()}}class qa{constructor(){B(this,"bb",null);B(this,"bb_pos",0)}__init(A,e){return this.bb_pos=A,this.bb=e,this}static getRootAsSyncedTransformModel(A,e){return(e||new qa).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+Ox),(e||new qa).__init(A.readInt32(A.position())+A.position(),A)}guid(A){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,A):null}fast(){const A=this.bb.__offset(this.bb_pos,6);return A?!!this.bb.readInt8(this.bb_pos+A):!1}transform(A){const e=this.bb.__offset(this.bb_pos,8);return e?(A||new nj).__init(this.bb_pos+e,this.bb):null}dontSave(){const A=this.bb.__offset(this.bb_pos,10);return A?!!this.bb.readInt8(this.bb_pos+A):!1}static startSyncedTransformModel(A){A.startObject(4)}static addGuid(A,e){A.addFieldOffset(0,e,0)}static addFast(A,e){A.addFieldInt8(1,+e,0)}static addTransform(A,e){A.addFieldStruct(2,e,0)}static addDontSave(A,e){A.addFieldInt8(3,+e,0)}static endSyncedTransformModel(A){return A.endObject()}static finishSyncedTransformModelBuffer(A,e){A.finish(e)}static finishSizePrefixedSyncedTransformModelBuffer(A,e){A.finish(e,void 0,!0)}}var Lg=(g=>(g[g.Average=0]="Average",g[g.Multiply=1]="Multiply",g[g.Minimum=2]="Minimum",g[g.Maximum=3]="Maximum",g))(Lg||{}),lM=(g=>(g[g.Discrete=0]="Discrete",g[g.Continuous=1]="Continuous",g))(lM||{}),$i=(g=>(g[g.None=0]="None",g[g.FreezePositionX=2]="FreezePositionX",g[g.FreezePositionY=4]="FreezePositionY",g[g.FreezePositionZ=8]="FreezePositionZ",g[g.FreezePosition=14]="FreezePosition",g[g.FreezeRotationX=16]="FreezeRotationX",g[g.FreezeRotationY=32]="FreezeRotationY",g[g.FreezeRotationZ=64]="FreezeRotationZ",g[g.FreezeRotation=112]="FreezeRotation",g[g.FreezeAll=126]="FreezeAll",g))($i||{}),th=(g=>(g[g.None=0]="None",g[g.X=2]="X",g[g.Y=4]="Y",g[g.Z=8]="Z",g[g.All=-1]="All",g))(th||{});const DI=function(g,A){return function(e,t,i){aEA(e,t,i,g,A)}};function aEA(g,A,e,t,i){if(!i&&!t&&!g.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",g,A,e),fi("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,Is.Error);return}let I="";if(typeof A=="string"?I=A:I=A.name,g.__internalAwake){const o=Symbol(I),s=g.__internalAwake;g.__internalAwake=function(){var n;if(!this.onValidate){ae()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((n=g.constructor)==null?void 0:n.name)+'"');return}if(this[o]===void 0){this[o]=this[I];const r=this[I];if(r instanceof tA||r instanceof y||r instanceof Ae||r instanceof GA){const a=this[I];Kk(a,()=>{this.onValidate(I)})}Object.defineProperty(this,I,{set:function(a){var C;if(this[SK]===!0)this[o]=a;else{t==null||t.call(this,a);const Q=this[o];this[o]=a,(C=this.onValidate)==null||C.call(this,I,Q)}},get:function(){return i==null||i.call(this),this[o]}})}s.call(this)}}}const CEA=function(g){return function(A,e,t){let i="";typeof e=="string"?i=e:i=e.name;const I=g.prototype,o=Object.getOwnPropertyDescriptor(I,i);if(!(o!=null&&o.value)){console.warn("Can not apply prefix: type does not have method named",e,g);return}const s=o.value,n=A[i];Object.defineProperty(I,i,{value:function(...r){const a=n==null?void 0:n.call(this,...r);if(a instanceof Promise){a.then(C=>{if(C!==!1)return s.call(this,...r)});return}if(a!==!1)return s.call(this,...r)}})}};var BEA=Object.defineProperty,QEA=Object.getOwnPropertyDescriptor,Es=(g,A,e,t)=>{for(var i=t>1?void 0:t?QEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&BEA(A,e,i),i};class cEA{constructor(A,e){B(this,"positionChanged",!1);B(this,"rotationChanged",!1);B(this,"position");B(this,"quaternion");B(this,"_positionKeys",["x","y","z"]);B(this,"_quaternionKeys",["_x","_y","_z","_w"]);B(this,"mute",!1);B(this,"context");B(this,"obj");B(this,"_positionWatch");B(this,"_rotationWatch");this.context=e,this.obj=A}get isDirty(){return this.positionChanged||this.rotationChanged}reset(A=!1){if(this.positionChanged=!1,this.rotationChanged=!1,this.mute=!1,A){if(this.position)for(const e of this._positionKeys)delete this.position[e];if(this.quaternion)for(const e of this._quaternionKeys)delete this.quaternion[e]}}syncValues(){for(const A of this._positionKeys)this.position[A]=this.obj.position[A];for(const A of this._quaternionKeys)this.quaternion[A]=this.obj.quaternion[A]}applyValues(){if(this.positionChanged&&this.position)for(const A of this._positionKeys){const e=this.position[A];e!==void 0&&(this.obj.position[A]=e)}if(this.rotationChanged&&this.quaternion)for(const A of this._quaternionKeys){const e=this.quaternion[A];e!==void 0&&(this.obj.quaternion[A]=e)}}start(A,e){this.reset(),A&&(this._positionWatch||(this._positionWatch=new Za(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.position[o];Math.abs(s-I)<1e-5||(this.position[o]=I,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new Za(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((I,o)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const s=this.quaternion[o];Math.abs(s-I)<1e-5||(this.quaternion[o]=I,this.rotationChanged=!0)}));const t=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),i=new fA;this.obj.matrixWorld.multiplyMatrices=(I,o)=>{var s;return(s=this.context.physics.engine)!=null&&s.isUpdating||this.mute||i.equals(I)||(this.positionChanged=!0,this.rotationChanged=!0,i.copy(I)),t(I,o)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var FN;const WK=(FN=class extends FA{constructor(){super(...arguments);B(this,"autoMass",!0);B(this,"_mass",0);B(this,"useGravity",!0);B(this,"centerOfMass",new y(0,0,0));B(this,"constraints",$i.None);B(this,"isKinematic",!1);B(this,"drag",0);B(this,"angularDrag",1);B(this,"detectCollisions",!0);B(this,"sleepThreshold",.01);B(this,"collisionDetectionMode",lM.Discrete);B(this,"_gravityScale",1);B(this,"dominanceGroup",0);B(this,"_propertiesChanged",!1);B(this,"_currentVelocity",new y);B(this,"_smoothedVelocity",new y);B(this,"_smoothedVelocityGetter",new y);B(this,"_lastPosition",new y);B(this,"_watch")}set mass(A){A!==this._mass&&(this._mass=A,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var A,e;return this.autoMass?((e=(A=this.context.physics.engine)==null?void 0:A.getBody(this))==null?void 0:e.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&$i.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&$i.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&$i.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&$i.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&$i.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&$i.FreezeRotationZ)!==0}set lockPositionX(A){A?this.constraints|=$i.FreezePositionX:this.constraints&=~$i.FreezePositionX}set lockPositionY(A){A?this.constraints|=$i.FreezePositionY:this.constraints&=~$i.FreezePositionY}set lockPositionZ(A){A?this.constraints|=$i.FreezePositionZ:this.constraints&=~$i.FreezePositionZ}set lockRotationX(A){A?this.constraints|=$i.FreezeRotationX:this.constraints&=~$i.FreezeRotationX}set lockRotationY(A){A?this.constraints|=$i.FreezeRotationY:this.constraints&=~$i.FreezeRotationY}set lockRotationZ(A){A?this.constraints|=$i.FreezeRotationZ:this.constraints&=~$i.FreezeRotationZ}set gravityScale(A){this._gravityScale=A}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new cEA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),oi.LateUpdate)}onDisable(){var A,e;(A=this._watch)==null||A.stop(),(e=this.context.physics.engine)==null||e.removeBody(this)}onDestroy(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){var A,e,t,i;for(;;)this._propertiesChanged&&(this._propertiesChanged=!1,(A=this.context.physics.engine)==null||A.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()):(i=this._watch)==null||i.syncValues(),this.captureVelocity(),yield}teleport(A,e=!0){var t;(t=this._watch)==null||t.reset(!0),e?this.gameObject.position.set(A.x,A.y,A.z):this.setWorldPosition(A.x,A.y,A.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(A=!0){var e;(e=this.context.physics.engine)==null||e.resetForces(this,A)}resetTorques(A=!0){var e;(e=this.context.physics.engine)==null||e.resetTorques(this,A)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var A;(A=this.context.physics.engine)==null||A.wakeup(this)}get isSleeping(){var A;return(A=this.context.physics.engine)==null?void 0:A.isSleeping(this)}updateProperties(){var A;return this._propertiesChanged=!1,(A=this.context.physics.engine)==null?void 0:A.updateProperties(this)}applyForce(A,e,t=!0){var i;this._propertiesChanged&&this.updateProperties(),(i=this.context.physics.engine)==null||i.addForce(this,A,t)}applyImpulse(A,e=!0){var t;this._propertiesChanged&&this.updateProperties(),(t=this.context.physics.engine)==null||t.applyImpulse(this,A,e)}setForce(A,e,t,i=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,i),typeof A=="number"?(e??(e=0),t??(t=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:A,y:e,z:t},i)):(s=this.context.physics.engine)==null||s.addForce(this,A,i)}getVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setVelocity(A,e,t,i=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,i);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:A,y:e,z:t},i)}getAngularVelocity(){var e;const A=(e=this.context.physics.engine)==null?void 0:e.getAngularVelocity(this);return A?(this._currentVelocity.x=A.x,this._currentVelocity.y=A.y,this._currentVelocity.z=A.z,this._currentVelocity):this._currentVelocity.set(0,0,0)}setAngularVelocity(A,e,t,i=!0){var I,o;if(A instanceof y){const s=A;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,i);return}e===void 0||t===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:A,y:e,z:t},i)}setTorque(A,e,t){this.setAngularVelocity(A,e,t)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(A=null){}captureVelocity(){const A=ve(this.gameObject);WK.tempPosition.copy(A);const e=A.sub(this._lastPosition);this._lastPosition.copy(WK.tempPosition),this._smoothedVelocity.lerp(e,this.context.time.deltaTime/.1)}},B(FN,"tempPosition",new y),FN);let Pt=WK;Es([DI()],Pt.prototype,"autoMass",2);Es([D()],Pt.prototype,"mass",1);Es([DI(),D()],Pt.prototype,"useGravity",2);Es([D(y)],Pt.prototype,"centerOfMass",2);Es([DI(),D()],Pt.prototype,"constraints",2);Es([DI(),D()],Pt.prototype,"isKinematic",2);Es([DI(),D()],Pt.prototype,"drag",2);Es([DI(),D()],Pt.prototype,"angularDrag",2);Es([DI(),D()],Pt.prototype,"detectCollisions",2);Es([DI(),D()],Pt.prototype,"sleepThreshold",2);Es([DI(),D()],Pt.prototype,"collisionDetectionMode",2);Es([DI()],Pt.prototype,"_gravityScale",2);Es([DI()],Pt.prototype,"dominanceGroup",2);const zC=gA("debugsync"),Nf="STRS";Wx(Nf,qa.getRootAsSyncedTransformModel);const er=new mD;function rj(g,A,e=!0){er.clear();const t=er.createString(g);qa.startSyncedTransformModel(er),qa.addGuid(er,t),qa.addFast(er,e);const i=A.worldPosition,I=A.worldEuler,o=A.gameObject.scale;qa.addTransform(er,nj.createTransform(er,i.x,i.y,i.z,I.x,I.y,I.z,o.x,o.y,o.z));const s=qa.endSyncedTransformModel(er);return er.finish(s,Nf),er.asUint8Array()}let ZK=0,Lp=0;sj(g=>{var t;const e=((t=g.connection.currentServerUrl)==null?void 0:t.includes("glitch"))?10:40;Lp=Math.floor(ZK/e),ZK=0,zC&&Lp>0&&console.log("Sync Transform Fast Interval",Lp)});class bB extends FA{constructor(){super(...arguments);B(this,"overridePhysics",!0);B(this,"interpolatePosition",!0);B(this,"interpolateRotation",!0);B(this,"fastMode",!1);B(this,"syncDestroy",!1);B(this,"_model",null);B(this,"_needsUpdate",!0);B(this,"rb",null);B(this,"_wasKinematic",!1);B(this,"_receivedDataBefore",!1);B(this,"_targetPosition");B(this,"_targetRotation");B(this,"_receivedFastUpdate",!1);B(this,"_shouldRequestOwnership",!1);B(this,"joinedRoomCallback",null);B(this,"receivedDataCallback",null);B(this,"tempEuler",new rt);B(this,"receivedUpdate",!1);B(this,"lastWorldPos");B(this,"lastWorldRotation")}requestOwnership(){zC&&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(){zC&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new y,this._targetRotation=new GA,this.lastWorldPos=new y,this.lastWorldRotation=new GA,this.rb=sA.getComponentInChildren(this.gameObject,Pt),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new $x(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(ze.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary(Nf,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&tv(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(ze.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary(Nf,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){zC&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,e),this.receivedUpdate=!0,this._receivedFastUpdate=e.fast();const i=e.transform();if(i){Ws.markDirty(this.gameObject,!0);const I=i.position();I&&(this.interpolatePosition&&((t=this._targetPosition)==null||t.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=i.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&$J(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){zC&&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),s=t.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(zC&&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),Ws.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const s=this._receivedFastUpdate||this.fastMode?.5:.3;let n=!1;if(this.interpolatePosition&&this._targetPosition){const r=this.worldPosition;r.lerp(this._targetPosition,s),this.worldPosition=r,n=!0}if(this.interpolateRotation&&this._targetRotation){const r=this.worldQuaternion;r.slerp(this._targetRotation,s),this.worldQuaternion=r,n=!0}n&&Ws.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&&(zC&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const i=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%i===0||I)){if(ZK++,I&&Lp>0&&this.context.time.frameCount%Lp!==0)return;zC&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const o=rj(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const EEA=gA("debugshadowcomponents");PJ.prototype.interactable={get(){return this.interactive},set(g){this.interactable=g}};const Hs=Symbol("shadowDomOwner");class Xs extends FA{constructor(){super(...arguments);B(this,"_shadowComponent",null);B(this,"_controlsChildLayout",!0);B(this,"_root");B(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(){Uo.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=sA.getComponentInParent(this.gameObject,JD)),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 o;if(!e)return;this.removeShadowComponent();const i=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=sA.getComponentInParent(i,Xs),!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[Hs]=this,this.setShadowComponentOwner(e);let I=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(e);else{const s=this._parentComponent.shadowComponent;s&&(s==null||s.add(e),I=!0)}this.shadowComponent=e,t&&t.shadowComponent&&this.shadowComponent&&t.shadowComponent.add(this.shadowComponent),SD&&e.add(new Qs(.5)),this.onAfterAddedToScene(),I&&s3(),EEA&&console.warn("Added shadow component",this.shadowComponent)}setShadowComponentOwner(e){if(e&&(e[Hs]===void 0||e[Hs]===this)&&(e[Hs]=this,e.children))for(const t of e.children)this.setShadowComponentOwner(t)}traverseOwnedShadowComponents(e,t,i){if(e&&e[Hs]===t){i(e);for(const I of e.children)this.traverseOwnedShadowComponents(I,t,i)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(e){this.shadowComponent&&(this.shadowComponent.interactable=e)}}class JD extends Xs{awake(){super.awake()}}class Ed{constructor(A,e){B(this,"event");B(this,"button");B(this,"buttonName");B(this,"_used",!1);B(this,"_propagationStopped",!1);B(this,"z__pointer_ctured",!1);B(this,"z__pointer_cture_rleased",!1);B(this,"inputSource");B(this,"object");B(this,"point");B(this,"normal");B(this,"face");B(this,"distance");B(this,"instanceId");B(this,"intersection");B(this,"isDown");B(this,"isUp");B(this,"isPressed");B(this,"isClick");B(this,"isDoubleClick");B(this,"input");this.event=e,this.input=A,this.button=e.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 A=new Ed(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function jK(g,A){return sA.foreachComponent(g,t=>{if(!t.enabled)return;const i=t;if(A)switch(A){case"pointerdown":if(i.onPointerDown)return!0;break;case"pointerup":if(i.onPointerUp||i.onPointerClick)return!0;break;case"pointermove":if(i.onPointerEnter||i.onPointerExit||i.onPointerMove)return!0;break}else if(i.onPointerDown||i.onPointerUp||i.onPointerEnter||i.onPointerExit||i.onPointerClick)return!0},!1)===!0}var lEA=Object.defineProperty,hEA=Object.getOwnPropertyDescriptor,dEA=(g,A,e,t)=>{for(var i=t>1?void 0:t?hEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&lEA(A,e,i),i};class xD extends FA{awake(){Uo.createIfNoneExists(this.context)}onEnable(){var A;(A=Uo.get(this.context))==null||A.register(this)}onDisable(){var A;(A=Uo.get(this.context))==null||A.unregister(this)}}class cs extends xD{constructor(){super(...arguments);B(this,"targets",null);B(this,"raycastHits",[]);B(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(e=null){if(!this.targets)return null;e??(e=new Yn),e.targets=this.targets,e.results=this.raycastHits;const t=e.testObject;this.ignoreSkinnedMeshes&&(e.testObject=I=>I instanceof Fo?"continue in children":t?t(I):!0);const i=this.context.physics.raycast(e);return e.testObject=t,i}}dEA([D()],cs.prototype,"ignoreSkinnedMeshes",2);class hM extends cs{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class Ff extends xD{performRaycast(A){if(!ye.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,t=.015;return this.context.physics.sphereOverlap(e,t)}}class dM{static getObject(A){const e=A[Hs];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const t=this.tryFindCanvasGroup(A);if((t==null?void 0:t.isCanvasGroup)===!0&&(e&&(e.canvasGroup=t),t.blocksRaycasts===!1||t.interactable===!1))return!1;const i=Oc(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&(i==null?void 0:i.isGraphic)===!0&&(e.graphic=i),!((i==null?void 0:i.raycastTarget)===!1||(i==null?void 0:i.layer)===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=Oc(A,t=>{const i=t;if(i.blocksRaycasts!==void 0&&i.interactable!==void 0)return i},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function ov(g){const A=g[Hs];return A||(g.parent?ov(g.parent):null)}function uEA(g){return g.isUI===!0||typeof g[Hs]=="object"}function ym(g,A){if(!g)return;const e=g.material;if((e==null?void 0:e.isMaterial)===!0){const t=g.parent;t&&t.isText,e.side=A.doubleSided??!0?kt:Gg,e.shadowSide=A.doubleSided?kt:Gg,g.castShadow=A.castShadows?A.castShadows:!1,g.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const t of g.children)ym(t,A)}function vl(g,A,e){g[A]===void 0&&console.warn("Field",A,"is undefined on",g);const t=Proxy.revocable(g[A],{set(o,s,n,r){const a=o[s],C=Reflect.set(o,s,n,r);return e(n,a),C}}),i=t.revoke,I=g[A];return t.revoke=()=>{g[A]=I,i()},g[A]=t.proxy,t}const p2=Symbol("Scheduled action");function pEA(g,A,e=oi.OnBeforeRender){let t=g[p2];t||(t=g[p2]={});const i=A.name;t[e]||(t[e]={});const I=t[e];if(I[i])return;function*s(){A==null||A.call(g),I[i]=null}const n=g.startCoroutine(s(),e);I[i]=n}const fa=gA("debugeventsystem");var zK=(g=>(g.BeforeHandleInput="BeforeHandleInput",g.AfterHandleInput="AfterHandleInput",g))(zK||{});const Br=class extends FA{constructor(){super();B(this,"raycaster",[]);B(this,"_handleInputFn");B(this,"pressedByID",new Map);B(this,"hoveredByID",new Map);B(this,"_sortedHits",[]);B(this,"_testObjectsCache",new Map);B(this,"_currentlyActiveRaycaster",null);B(this,"_currentPointerEventName",null);B(this,"shouldRaycastObject",e=>{var I;let t=null;if(uEA(e)&&(t=(I=e[Hs])==null?void 0:I.gameObject),this._testObjectsCache.has(e)||t&&this._testObjectsCache.has(t))return this._testObjectsCache.get(e)===!1?"continue in children":!0;{let o=jK(e,this._currentPointerEventName);if(!o&&t&&(o=jK(t,this._currentPointerEventName)),o){this._testObjectsCache.set(e,!0);for(const s of e.children)this.shouldRaycastObject_AddToYesCache(s);return!0}return this._testObjectsCache.set(e,!1),"continue in children"}});B(this,"_sortingBuffer",[]);B(this,"_noDepthTestingResults",[]);B(this,"out",{});B(this,"_capturedPointer",{});B(this,"pointerEnterSymbol",Symbol("pointerEnter"));B(this,"pointerExitSymbol",Symbol("pointerExit"));B(this,"currentActiveMeshUIComponents",[]);Br.systems.push(this)}static createIfNoneExists(e){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Br.systems.length<=0&&Br.systems.push(...sA.findObjectsOfType(Br,e)));for(const i of Br.systems)if(i.context===e)return;const t=new DA;sA.addNewComponent(t,Br),e.scene.add(t)}static get systems(){const e=be.Current;return this._eventSystemMap.has(e)||this._eventSystemMap.set(e,[]),this._eventSystemMap.get(e)}static get(e){const t=this._eventSystemMap.get(e);return t&&t.length>0?t[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(e,t,i=!1){oB.update(e,t,i)}static markUIDirty(e){oB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Br.systems.splice(Br.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!sA.findObjectOfType(xD,this.context)){const t=sA.addNewComponent(this.context.scene,cs);this.raycaster.push(t),(ae()||fa)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(e){var t;e&&this.raycaster&&!this.raycaster.includes(e)&&((t=this.raycaster)==null||t.push(e))}unregister(e){var i,I;const t=(i=this.raycaster)==null?void 0:i.indexOf(e);t!==void 0&&t!==-1&&((I=this.raycaster)==null||I.splice(t,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(pi.PointerDown,this._handleInputFn),this.context.input.addEventListener(pi.PointerUp,this._handleInputFn),this.context.input.addEventListener(pi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(pi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(pi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(pi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(e){if(e===void 0||e.propagationStopped)return;const t=new Ed(this.context.input,e);this._currentPointerEventName=e.type,t.inputSource=this.context.input,t.isClick=e.isClick,t.isDoubleClick=e.isDoubleClick,t.isDown=e.type==pi.PointerDown,t.isUp=e.type==pi.PointerUp,t.isPressed=this.context.input.getPointerPressed(e.pointerId),fa&&(t.isDown?console.log("DOWN",t.pointerId):t.isUp&&console.log("UP",t.pointerId),t.isClick&&console.log("CLICK",t.pointerId));const i=new Yn;e.hasRay?i.ray=e.ray:i.screenPoint=this.context.input.getPointerPositionRC(e.pointerId);const I=this.performRaycast(i);if(I){for(const s of I)s.event=e,e.intersections.push(s);e.origin.onPointerHits&&e.origin.onPointerHits({sender:this,event:e,hits:I})}fa&&t.isClick&&fi("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown);const o={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:o})),this.handleIntersections(I,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:o}))}shouldRaycastObject_AddToYesCache(e){this._testObjectsCache.set(e,!0);for(const t of e.children)this.shouldRaycastObject_AddToYesCache(t)}performRaycast(e){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,e||(e=new Yn),e.testObject=this.shouldRaycastObject;for(const t of this.raycaster){if(!t.activeAndEnabled)continue;this._currentlyActiveRaycaster=t;const i=t.performRaycast(e);this._currentlyActiveRaycaster=null,i&&i.length>0&&this._sortedHits.push(...i)}return this._sortedHits.sort((t,i)=>t.distance-i.distance),this._sortedHits}assignHitInformation(e,t){t?(e.intersection=t,e.point=t.point,e.normal=t.normal,e.face=t.face,e.distance=t.distance,e.instanceId=t.instanceId):(e.intersection=void 0,e.point=void 0,e.normal=void 0,e.face=void 0,e.distance=void 0,e.instanceId=void 0)}handleIntersections(e,t){var I;if(e!=null&&e.length){e=this.sortCandidates(e);for(const o of e){if(t.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(t,o),this.handleEventOnObject(o.object,t))return!0}}this.assignHitInformation(t,e==null?void 0:e[0]),this.invokePointerCapture(t);const i=this.hoveredByID.get(t.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(t.pointerId),t.isUp&&((I=this.pressedByID.get(t.pointerId))==null||I.handlers.forEach(o=>this.invokeOnPointerUp(t,o)),this.pressedByID.delete(t.pointerId)),!1}sortCandidates(e){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let t=0;t<e.length;t++){const i=e[t],I=i.object;if(I.material&&I.material.depthTest===!1){this._noDepthTestingResults.push(i);continue}this._sortingBuffer.push(i)}for(const t of this._sortingBuffer)this._noDepthTestingResults.push(t);return this._noDepthTestingResults}handleEventOnObject(e,t){if(!this.testIsVisible(e))return t.isClick&&fa&&console.log("not allowed",e),!1;if(t.pointerId===void 0)return fa&&console.error("Event without pointer can't be handled",t),!1;t.object=e;const i=e.parent,I=t.isClick??!1;let o=null;if(i&&i.isUI){const C=(t.isPressed||t.isClick)??!1;if(i[Hs]){const Q=i[Hs].gameObject;if(Q){if(!dM.isInteractable(Q,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(e,C),e=Q}}}I&&fa&&console.log(this.context.time.frame,e);const s=this.hoveredByID.get(t.pointerId),n=s==null?void 0:s.obj;n!==e&&n&&this.propagatePointerExit(n,s.data,e);const a=this.hoveredByID.get(t.pointerId);if(a?(a.obj=e,a.data=t):this.hoveredByID.set(t.pointerId,{obj:e,data:t}),t.isDown){const C=this.pressedByID.get(t.pointerId);C?(C.obj=e,C.data=t):this.pressedByID.set(t.pointerId,{obj:e,data:t,handlers:new Set})}return(o===null||o.interactable)&&this.handleMainInteraction(e,t,n??null),!0}propagate(e,t){for(;e;)sA.foreachComponent(e,i=>{t(i)},!1),e=e.parent}handleMainInteraction(e,t,i){const I=this.pressedByID.get(t.pointerId),o=i!==e;let s=!0;switch(t.event.pointerType){case"mouse":case"touch":const n=this.context.input.getPointerPositionLastFrame(t.pointerId),r=this.context.input.getPointerPosition(t.pointerId);s=n&&!ge.approximately(n,r);break}this.propagate(e,n=>{var a;const r=n;r.interactable!==!1&&(!r.activeAndEnabled||!r.enabled||(r.onPointerEnter&&o&&this.handlePointerEnter(r,t),t.isDown&&r.onPointerDown&&(r.onPointerDown(t),I==null||I.handlers.add(r),this.handlePointerCapture(t,r)),r.onPointerMove&&(s&&r.onPointerMove(t),this.handlePointerCapture(t,r)),t.isUp&&(r.onPointerUp&&(this.invokeOnPointerUp(t,r),I==null||I.handlers.delete(r)),r.onPointerExit&&((a=t.event)==null?void 0:a.pointerType)===gM.Touch&&(this.handlePointerExit(r,t),this.hoveredByID.delete(t.pointerId))),t.isClick&&r.onPointerClick&&r.onPointerClick(t)))}),t.isUp&&(I==null||I.handlers.forEach(n=>{this.invokeOnPointerUp(t,n)}),this.pressedByID.delete(t.pointerId))}propagatePointerExit(e,t,i){this.propagate(e,I=>{if(!I.gameObject||I.destroyed)return;const o=I;if(o.onPointerExit){if(i&&this.isChild(i,I.gameObject))return;this.handlePointerExit(o,t)}})}invokeOnPointerUp(e,t){var i;(i=t.onPointerUp)==null||i.call(t,e),this.releasePointerCapture(e,t)}handlePointerEnter(e,t){e.onPointerEnter&&this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!0)&&e.onPointerEnter(t),this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(e,t){e.onPointerExit&&this.updatePointerState(e,t.pointerId,this.pointerExitSymbol,!0)&&e.onPointerExit(t),this.updatePointerState(e,t.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(e,t,i,I){let o=e[i];if(I)return o&&o.includes(t)?!1:(o=o||[],o.push(t),e[i]=o,!0);{if(!o||!o.includes(t))return!1;const s=o.indexOf(t);return s!==-1&&o.splice(s,1),!0}}handlePointerCapture(e,t){if(e.z__pointer_ctured){e.z__pointer_ctured=!1;const i=e.pointerId;if(t.onPointerMove){const I=this._capturedPointer[i]||[];I.push(t),this._capturedPointer[i]=I}else ae()&&!t.z__warned_no_pointermove&&(t.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else e.z__pointer_cture_rleased&&(e.z__pointer_cture_rleased=!1,this.releasePointerCapture(e,t))}releasePointerCapture(e,t){const i=e.pointerId;if(this._capturedPointer[i]){const I=this._capturedPointer[i].indexOf(t);I!==-1&&(this._capturedPointer[i].splice(I,1),fa&&console.log("released pointer capture",i,t,this._capturedPointer))}}invokePointerCapture(e){var t;if(e.event.type===pi.PointerMove){const i=e.pointerId,I=this._capturedPointer[i];if(I){fa&&console.log("Captured",i,I);for(let o=0;o<I.length;o++){const s=I[o];if(s.destroyed){I.splice(o,1),o--;continue}(t=s.onPointerMove)==null||t.call(s,e)}}}}isChild(e,t){return!e||!t?!1:e===t?!0:e.parent?this.isChild(e.parent,t):!1}handleMeshUiObjectWithoutShadowDom(e,t){return!e||!e.isUI?!0:this.handleMeshUIIntersection(e,t)}handleMeshUIIntersection(e,t){const i=oB.updateState(e,t);return i&&this.currentActiveMeshUIComponents.push(i),i!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&oB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let e=0;e<this.currentActiveMeshUIComponents.length;e++){const t=this.currentActiveMeshUIComponents[e];oB.resetState(t)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(e){return e?sA.isActiveSelf(e)?this.testIsVisible(e.parent):!1:!0}};let Uo=Br;B(Uo,"_eventSystemMap",new Map),B(Uo,"didSearchEventSystem",!1);class oB{static markDirty(){this.needsUpdate=!0}static update(A,e,t=!1){if(t){A.update();return}const i=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(i===I.frame)return;I.frame=i;let o=this.needsUpdate||i<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(fa&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:i,nextUpdate:i}],A.update()}static updateState(A,e){let t=null;if(A&&(t=this.findBlockInParent(A),t&&t!==this.lastSelected)){if(t.interactable===!1)return null;this.needsUpdate=!0}return t}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}B(oB,"lastSelected",null),B(oB,"lastUpdateFrame",[]),B(oB,"needsUpdate",!1);var fEA=Object.defineProperty,DEA=Object.getOwnPropertyDescriptor,wi=(g,A,e,t)=>{for(var i=t>1?void 0:t?DEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&fEA(A,e,i),i};const PU=gA("debugorbit"),ES=gA("freecam"),lS=gA("debugcamerafit"),hS=gA("smoothcam"),yEA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let WU;class Kf extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Mt extends FA{constructor(){super(...arguments);B(this,"autoTarget",!0);B(this,"autoFit",!1);B(this,"enableRotate",!0);B(this,"autoRotate",!1);B(this,"autoRotateSpeed",1);B(this,"minAzimuthAngle",1/0);B(this,"maxAzimuthAngle",1/0);B(this,"minPolarAngle",0);B(this,"maxPolarAngle",Math.PI);B(this,"enableKeys",!0);B(this,"enableDamping",!0);B(this,"dampingFactor",.1);B(this,"enableZoom",!0);B(this,"minZoom",0);B(this,"maxZoom",1/0);B(this,"zoomSpeed",1);B(this,"zoomToCursor",!1);B(this,"enablePan",!0);B(this,"lookAtConstraint",null);B(this,"lookAtConstraint01",1);B(this,"allowInterrupt",!0);B(this,"middleClickToFocus",!0);B(this,"doubleClickToFocus",!0);B(this,"clickBackgroundToFitScene",2);B(this,"debugLog",!1);B(this,"targetLerpDuration",1);B(this,"_controls",null);B(this,"_cameraObject",null);B(this,"_lookTargetLerpActive",!1);B(this,"_lookTargetStartPosition",new y);B(this,"_lookTargetEndPosition",new y);B(this,"_lookTargetLerp01",0);B(this,"_lookTargetLerpDuration",0);B(this,"_cameraLerpActive",!1);B(this,"_cameraStartPosition",new y);B(this,"_cameraEndPosition",new y);B(this,"_cameraLerp01",0);B(this,"_cameraLerpDuration",0);B(this,"_inputs",0);B(this,"_enableTime",0);B(this,"_startedListeningToKeyEvents",!1);B(this,"_eventSystem");B(this,"_afterHandleInputFn");B(this,"_camera",null);B(this,"_syncedTransform");B(this,"_didSetTarget",0);B(this,"targetElement",null);B(this,"_lastTimeClickOnBackground",-1);B(this,"_clickOnBackgroundCount",0);B(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}PU&&console.log(this.clickBackgroundToFitScene,e.intersections.length,this._clickOnBackgroundCount)}});B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});B(this,"_shouldDisable",!1);B(this,"__onPreRender",()=>{const e=this.context.pre_render_callbacks.indexOf(this.__onPreRender);e>=0&&this.context.pre_render_callbacks.splice(e,1),this.autoFit&&(this.autoFit=!1,this.fitCamera(this.scene.children,{centerCamera:"y",immediate:!0}))});B(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._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=Uo.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(zK.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(zK.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const e=sA.getComponent(this.gameObject,Wt);this._camera=e;let t=e==null?void 0:e.cam;if(!t&&this.gameObject instanceof He&&(t=this.gameObject),t&&TF(t,this,!0),!this._controls&&t instanceof He){this._cameraObject=t;const i=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new Ij(t,i),t==null||t.quaternion.copy(I),WU===void 0&&(WU={...this._controls.keys})}this._controls&&(ES&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,In()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?ES||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):ES||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=sA.getComponent(this.gameObject,bB)??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&&TF(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 t,i;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)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.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 I=sA.getComponent(this.gameObject,Wt);if(I&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const o=ve(I.cam),s=Math.max(.01,o.length()),n=new y(0,0,-s).applyMatrix4(I.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.setLookTargetFromConstraint()){const o=new Yn;o.screenPoint=new tA(0,0),o.lineThreshold=.1;const s=this.context.physics.raycast(o);s.length>0&&this.setLookTargetPosition(s[0].point,!0),lS&&console.log("OrbitControls hits",...s)}}let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&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 Kf(this,"camera"));else{const I=ge.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}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 Kf(this,"lookat"));else{const I=ge.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}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?WU:yEA,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 hS=="number"||hS===!0){this._controls.enableDamping=!0;const I=typeof hS=="number"?hS:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}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||(!ES&&((i=this.lookAtConstraint)!=null&&i.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),PU&&fe.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(e){if(!e||!(e instanceof DA))return;const t=ve(e),i=VJ(e);this.setTargetFromRaycast(new xo(t,i)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var i,I;e&&(e instanceof DA&&(e=ve(e)),this._cameraEndPosition||(this._cameraEndPosition=new y),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.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 DA&&(e=ve(e)),this._lookTargetEndPosition.copy(e),PU&&(console.warn("OrbitControls: setLookTargetPosition",e,t),fe.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 I;if(!this._controls)return!1;const i=(I=this.lookAtConstraint)==null?void 0:I.sources;if(i&&i.length>0){const o=i[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 i of t)if(i.distance>0&&sA.isActiveInHierarchy(i.object)){const I=ov(i.object);if(I){const o=I.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(e,t={fitOffset:void 0,immediate:!1}){if(this.context.isInXR)return;const{immediate:i=!1,centerCamera:I}=t;let{fitOffset:o}=t;o==null&&(o=1.1);const s=this._cameraObject,n=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(!s||!n){console.warn("No camera or controls found to fit camera to objects...");return}const r=new y,a=new y,C=qr(e,void 0);s.updateMatrixWorld(),s.updateProjectionMatrix(),C.getCenter(a);const Q=new y;if(C.getSize(Q),C.applyMatrix4(s.matrixWorldInverse),C.getSize(r),C.setFromCenterAndSize(a,r),Number.isNaN(r.x)||Number.isNaN(r.y)||Number.isNaN(r.z)){console.warn("Camera fit size resultet in NaN",s,C,[...e]);return}if(r.length()<=1e-10){lS&&console.warn("Camera fit size is zero",C,[...e]);return}const c=s.fov,E=2*Math.atan(Math.tan(c*Math.PI/360/2)*s.aspect)/Math.PI*360,h=r.y/(2*Math.atan(Math.PI*c/360)),l=r.x/(2*Math.atan(Math.PI*E/360)),d=o*Math.max(h,l)+r.z/2;lS&&console.log("Fit camera to objects",h,l,"distance",d),n.maxDistance=d*10,n.minDistance=d*.01;const p=.05,u=a.clone();u.y-=r.y*p,this.setLookTargetPosition(u,i),this.autoTarget=!1;const f=sA.findObjectOfType(VB),w=f?f.radius:0,m=Math.max(Q.x,Q.y,Q.z,w);s.near=d/100,s.far=m+d*10,s.updateMatrixWorld(),s.updateProjectionMatrix();const M=ve(s),G=a.clone();if(G.sub(M),I==="y"&&(G.y=0),G.normalize(),G.multiplyScalar(d),I==="y"&&(G.y+=-p*4*r.y),s.parent){const U=s.parent.worldToLocal(a.clone().sub(G));this.setCameraTargetPosition(U,i)}else console.error(`Can not fit camera ${s.name} because it has no parent`);if(lS){const U=new dJ(C);this.context.scene.add(U),Ax(U,dD(s)),setTimeout(()=>{this.context.scene.remove(U)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",S=>{S.code==="KeyF"&&this.fitCamera(e,{fitOffset:o,immediate:i})}))}n.update()}}wi([D()],Mt.prototype,"autoTarget",2);wi([D()],Mt.prototype,"autoFit",2);wi([D()],Mt.prototype,"enableRotate",2);wi([D()],Mt.prototype,"autoRotate",2);wi([D()],Mt.prototype,"autoRotateSpeed",2);wi([D()],Mt.prototype,"minAzimuthAngle",2);wi([D()],Mt.prototype,"maxAzimuthAngle",2);wi([D()],Mt.prototype,"minPolarAngle",2);wi([D()],Mt.prototype,"maxPolarAngle",2);wi([D()],Mt.prototype,"enableKeys",2);wi([D()],Mt.prototype,"enableDamping",2);wi([D()],Mt.prototype,"dampingFactor",2);wi([D()],Mt.prototype,"enableZoom",2);wi([D()],Mt.prototype,"minZoom",2);wi([D()],Mt.prototype,"maxZoom",2);wi([D()],Mt.prototype,"zoomSpeed",2);wi([D()],Mt.prototype,"enablePan",2);wi([D(sE)],Mt.prototype,"lookAtConstraint",2);wi([D()],Mt.prototype,"lookAtConstraint01",2);wi([D()],Mt.prototype,"allowInterrupt",2);wi([D()],Mt.prototype,"middleClickToFocus",2);wi([D()],Mt.prototype,"doubleClickToFocus",2);wi([D()],Mt.prototype,"clickBackgroundToFitScene",2);wi([D()],Mt.prototype,"targetLerpDuration",2);var wEA=Object.defineProperty,SEA=Object.getOwnPropertyDescriptor,uo=(g,A,e,t)=>{for(var i=t>1?void 0:t?SEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&wEA(A,e,i),i},kB=(g=>(g[g.Skybox=1]="Skybox",g[g.SolidColor=2]="SolidColor",g[g.Uninitialized=4]="Uninitialized",g))(kB||{});const Ma=gA("debugcam"),f2=gA("debugscreenpointtoray");var qS;const op=(qS=class extends FA{constructor(){super(...arguments);B(this,"_nearClipPlane",.1);B(this,"_farClipPlane",1e3);B(this,"orthographic",!1);B(this,"orthographicSize",5);B(this,"ARBackgroundAlpha",0);B(this,"_cullingMask",4294967295);B(this,"_backgroundBlurriness",0);B(this,"_backgroundIntensity",1);B(this,"_backgroundRotation");B(this,"_environmentIntensity");B(this,"_targetTexture",null);B(this,"_backgroundColor");B(this,"_fov");B(this,"_cam",null);B(this,"_clearFlags",2);B(this,"_skybox");B(this,"_frustum");B(this,"_projScreenMatrix",new fA)}get isCamera(){return!0}get aspect(){return this._cam instanceof He?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(A){this._cam instanceof He&&this._cam.aspect!==A&&(this._cam.aspect=A,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof He?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof He){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(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(A){A!==this._backgroundRotation&&(A===void 0?this._backgroundRotation=void 0:this._backgroundRotation=A,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const i=this.cam,I=op._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),f2&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(i);const o=op._direction.set(I.x,I.y,I.z),s=ve(i);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new xo(s.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new Kc,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Kc),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(A,e){return e&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),A===this._projScreenMatrix?A:A.copy(this._projScreenMatrix)}awake(){f2&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const i=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);fe.DrawRay(i.origin,i.direction,I,10)})}onEnable(){Ma&&console.log(`Camera enabled: "${this.name}". ClearFlags=${kB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),kEA(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 A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof He&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof He&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new He(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 Tr(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(A){this.context.mainCameraComponent===this&&this.applyClearFlags(A)}applyClearFlags(A){if(!this._cam){Ma&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Ma){const e=`Camera "${this.name}" clear flags: ${kB[this._clearFlags]}`;console.debug(e)}switch(this._clearFlags){case 1:if(op.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||(A==null?void 0:A.applySkybox)===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:Ma&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity),this._backgroundRotation!==void 0?this.context.scene.backgroundRotation=this._backgroundRotation:Ma&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;op.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else Ma&&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 mEA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;Ma&&fi("Environment blend mode: "+t+" on "+navigator.userAgent);let i=t==="additive"||t==="alpha-blend";return A.isInAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(i=!0),e._transparent=i,i}},B(qS,"_origin",new y),B(qS,"_direction",new y),qS);let Wt=op;uo([D()],Wt.prototype,"aspect",1);uo([D()],Wt.prototype,"fieldOfView",1);uo([D()],Wt.prototype,"nearClipPlane",1);uo([D()],Wt.prototype,"farClipPlane",1);uo([D()],Wt.prototype,"clearFlags",1);uo([D()],Wt.prototype,"orthographic",2);uo([D()],Wt.prototype,"orthographicSize",2);uo([D()],Wt.prototype,"ARBackgroundAlpha",2);uo([D()],Wt.prototype,"cullingMask",1);uo([D()],Wt.prototype,"backgroundBlurriness",1);uo([D()],Wt.prototype,"backgroundIntensity",1);uo([D(rt)],Wt.prototype,"backgroundRotation",1);uo([D()],Wt.prototype,"environmentIntensity",1);uo([D(Ft)],Wt.prototype,"backgroundColor",1);uo([D(mB)],Wt.prototype,"targetTexture",1);class mEA{constructor(A){B(this,"_camera");B(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}apply(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ma&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=No,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)),(Ma||ae())&&Ot(`Camera "${this._camera.name}" has no skybox texture`))}}function kEA(g){gA("freecam")&&g.context.mainCameraComponent===g&&sA.getOrAddComponent(g.gameObject,Mt)}class MB extends FA{constructor(){super(...arguments);B(this,"_listener",null);B(this,"onInteraction",()=>{this.destroyed||this.listener==null||this.addListenerIfItExists()})}get listener(){return this._listener==null&&(this._listener=new ZP),this._listener}onEnable(){Fr.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){Fr.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const e=this._listener;if(!e||e!=null&&e.parent)return;const t=this.context.mainCameraComponent||sA.getComponentInParent(this.gameObject,Wt);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 MEA extends Oi{constructor(A,e=1,t=16,i=2){const I=new we,o=t+i*2,s=new Float32Array((o*3+3)*3);I.setAttribute("position",new ne(s,3));const n=new Ii({color:65280}),r=new Ii({color:16776960});super(I,[r,n]),this.audio=A,this.range=e,this.divisionsInnerAngle=t,this.divisionsOuterAngle=i,this.type="PositionalAudioHelper",this.update()}update(){const A=this.audio,e=this.range,t=this.divisionsInnerAngle,i=this.divisionsOuterAngle,I=ht.degToRad(A.panner.coneInnerAngle),o=ht.degToRad(A.panner.coneOuterAngle),s=I/2,n=o/2;let r=0,a=0,C,Q;const c=this.geometry,E=c.attributes.position;c.clearGroups();function h(l,d,p,u){const f=(d-l)/p;for(E.setXYZ(r,0,0,0),a++,C=l;C<d;C+=f)Q=r+a,E.setXYZ(Q,Math.sin(C)*e,0,Math.cos(C)*e),E.setXYZ(Q+1,Math.sin(Math.min(C+f,d))*e,0,Math.cos(Math.min(C+f,d))*e),E.setXYZ(Q+2,0,0,0),a+=3;c.addGroup(r,a,u),r+=a,a=0}h(-n,-s,i,0),h(-s,s,t,1),h(s,n,i,0),E.needsUpdate=!0,I===o&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var GEA=Object.defineProperty,REA=Object.getOwnPropertyDescriptor,Pr=(g,A,e,t)=>{for(var i=t>1?void 0:t?REA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&GEA(A,e,i),i};const NI=gA("debugaudio"),VC=class extends FA{constructor(){super(...arguments);B(this,"clip","");B(this,"playOnAwake",!1);B(this,"preload",!1);B(this,"_spatialBlend",0);B(this,"_minDistance",1);B(this,"_maxDistance",100);B(this,"_volume",1);B(this,"rollOffMode",0);B(this,"playInBackground",!0);B(this,"_loop",!1);B(this,"sound",null);B(this,"helper",null);B(this,"wasPlaying",!1);B(this,"audioLoader",null);B(this,"shouldPlay",!1);B(this,"_lastClipStartedLoading",null);B(this,"_audioElement",null);B(this,"onVisibilityChanged",()=>{switch(document.visibilityState){case"hidden":(this.playInBackground===!1||In())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":NI&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,VC.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&VC.userInteractionRegistered&&this.wasPlaying&&this.play();break}});B(this,"onApplicationMuteChanged",()=>{var A,e;this.context.application.muted?(A=this.sound)==null||A.setVolume(0):(e=this.sound)==null||e.setVolume(this.volume)});B(this,"createAudio",A=>{NI&&console.log("AudioBuffer finished loading",A);const e=this.Sound;if(!e){NI&&console.warn("Failed getting sound?",this.name);return}e.isPlaying&&e.stop(),A&&e.setBuffer(A),e.loop=this._loop,this.context.application.muted?e.setVolume(0):e.setVolume(this.volume),e.autoplay=this.shouldPlay&&VC.userInteractionRegistered,this.applySpatialDistanceSettings(),e.isPlaying&&e.stop(),VC.registerWaitForAllowAudio(this.__onAllowAudioCallback)});B(this,"__onAllowAudioCallback",()=>{this.shouldPlay&&this.play()});B(this,"_lastContextTime",0);B(this,"_hasEnded",!0);B(this,"_needUpdateSpatialDistanceSettings",!1)}static get userInteractionRegistered(){return Fr.userInteractionRegistered}static registerWaitForAllowAudio(A){Fr.registerWaitForAllowAudio(A)}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(A){this._loop=A,this.sound&&this.sound.setLoop(A)}get spatialBlend(){return this._spatialBlend}set spatialBlend(A){A!==this._spatialBlend&&(this._spatialBlend=A,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(A){this._minDistance!==A&&(this._minDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(A){this._maxDistance!==A&&(this._maxDistance=A,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(A){this._volume=A,this.sound&&!this.context.application.muted&&(NI&&console.log(this.name,"audio set volume",A),this.sound.setVolume(A))}get Sound(){var A;if(!this.sound&&VC.userInteractionRegistered){let e=sA.getComponent(this.context.mainCamera,MB)??sA.findObjectOfType(MB,this.context);!e&&this.context.mainCamera&&(e=sA.addNewComponent(this.context.mainCamera,MB)),e!=null&&e.listener?(this.sound=new jP(e.listener),(A=this.gameObject)==null||A.add(this.sound)):NI&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var A;return(A=this.sound)==null?void 0:A.context}awake(){NI&&console.log(this),this.audioLoader=new O0,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),VC.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():VC.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(Em.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(Em.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const A=this.sound;if(!A)return;this._needUpdateSpatialDistanceSettings=!1;const e=ge.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(NI&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+e),A.setRefDistance(e),A.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:A.setDistanceModel("exponential");break;case 1:A.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?NI&&!this.helper&&(this.helper=new MEA(A,A.getRefDistance()),A.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(A){if(A&&(this.clip=A),typeof A=="string")if(NI&&console.log(A),A.endsWith(".mp3")||A.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new O0),this.shouldPlay=!0,this._lastClipStartedLoading===A){NI&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=A,NI&&console.log("load audio",A);const e=await this.audioLoader.loadAsync(A).catch(console.error);this._lastClipStartedLoading=null,e&&this.createAudio(e)}else console.warn("Unsupported audio clip type",A);else this.shouldPlay=!0,this.createAudio()}play(A=void 0){var t,i,I;!A&&this.clip&&(A=this.clip),A!==void 0&&typeof A!="string"&&!(A instanceof MediaStream)&&(ae()&&console.warn("Called play on AudioSource with unknown argument type:",A+`
|
|
5733
5733
|
Using the assigned clip instead:`,this.clip),A=this.clip);let e=!this.sound||A&&A!==this.clip;if(typeof A=="string"&&!this.audioLoader&&(e=!0),(A instanceof MediaStream||typeof A=="string")&&(this.clip=A),e){this.shouldPlay=!0,this.onNewClip(A);return}if(this.shouldPlay=!0,this._hasEnded=!1,NI&&console.log("play",(t=this.sound)==null?void 0:t.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(i=this.gameObject)==null||i.add(this.sound),this.clip instanceof MediaStream?(this.sound.setMediaStreamSource(this.clip),this._audioElement||(this._audioElement=document.createElement("audio"),this._audioElement.style.display="none"),this._audioElement.parentNode||(I=this.context.domElement.shadowRoot)==null||I.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 A,e;NI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,this.sound.pause()),(e=this._audioElement)==null||e.remove()}stop(){var A,e;NI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(A=this.sound)==null?void 0:A.context.currentTime,NI&&console.log(this._lastContextTime),this.sound.stop()),(e=this._audioElement)==null||e.remove()}get isPlaying(){var A;return((A=this.sound)==null?void 0:A.isPlaying)??!1}set isPlaying(A){}get time(){var A,e;return(A=this.sound)!=null&&A.source?((e=this.sound.source)==null?void 0:e.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(A){if(this.sound){if(A===this.sound.offset)return;const e=this.isPlaying;this.stop(),this.sound.offset=A,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,NI&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let zi=VC;Pr([D(URL)],zi.prototype,"clip",2);Pr([D()],zi.prototype,"playOnAwake",2);Pr([D()],zi.prototype,"preload",2);Pr([D()],zi.prototype,"loop",1);Pr([D()],zi.prototype,"spatialBlend",1);Pr([D()],zi.prototype,"minDistance",1);Pr([D()],zi.prototype,"maxDistance",1);Pr([D()],zi.prototype,"volume",1);Pr([D()],zi.prototype,"rollOffMode",2);Pr([D()],zi.prototype,"playInBackground",2);var UEA=Object.defineProperty,NEA=Object.getOwnPropertyDescriptor,uM=(g,A,e,t)=>{for(var i=t>1?void 0:t?NEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&UEA(A,e,i),i};const FEA=gA("debugsignals");class vD{constructor(){B(this,"guid")}}uM([D()],vD.prototype,"guid",2);class ld{constructor(){B(this,"signal");B(this,"reaction")}}uM([D(vD)],ld.prototype,"signal",2);uM([D(og)],ld.prototype,"reaction",2);var KN;const Da=(KN=class extends FA{constructor(){super(...arguments);B(this,"events")}static invoke(A){if(Da.receivers[A]){const e=Da.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){FEA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)Da.receivers[A.signal.guid]||(Da.receivers[A.signal.guid]=[]),Da.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(Da.receivers[A.signal.guid]){const e=Da.receivers[A.signal.guid].indexOf(this);e>=0&&Da.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;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(i){console.error(i)}}},B(KN,"receivers",{}),KN);let hd=Da;uM([D(ld)],hd.prototype,"events",2);var zo=(g=>(g.Activation="ActivationTrack",g.Animation="AnimationTrack",g.Audio="AudioTrack",g.Control="ControlTrack",g.Marker="MarkerTrack",g.Signal="SignalTrack",g))(zo||{}),Cr=(g=>(g[g.None=0]="None",g[g.Hold=1]="Hold",g[g.Loop=2]="Loop",g[g.PingPong=3]="PingPong",g[g.Continue=4]="Continue",g))(Cr||{}),sv=(g=>(g.Signal="SignalEmitter",g))(sv||{});const kr=gA("debugtimeline");class qD{constructor(){B(this,"director");B(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,i=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(i||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class KEA{constructor(A){B(this,"clip");B(this,"rootPositionOffset");B(this,"rootQuaternionOffset");B(this,"rootStartPosition");B(this,"rootEndPosition");B(this,"rootStartQuaternion");B(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),i=t.name+".position",I=t.name+".quaternion";kr&&console.log(e.name,e.tracks,i);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(i))this.rootStartPosition=new y().fromArray(o.values,0),this.rootEndPosition=new y().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),kr&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new GA().fromArray(o.values,0),this.rootEndQuaternion=new GA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),kr)){const s=new rt().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class pM extends qD{constructor(){super(...arguments);B(this,"models",[]);B(this,"trackOffset");B(this,"target");B(this,"mixer");B(this,"clips",[]);B(this,"actions",[]);B(this,"_actionOffsets",[]);B(this,"_didBind",!1);B(this,"_animator",null);B(this,"_useclipOffsets",!0);B(this,"_totalOffsetPosition",new y);B(this,"_totalOffsetRotation",new GA);B(this,"_totalOffsetPosition2",new y);B(this,"_totalOffsetRotation2",new GA);B(this,"_summedPos",new y);B(this,"_tempPos",new y);B(this,"_summedRot",new GA);B(this,"_tempRot",new GA);B(this,"_clipRotQuat",new GA)}onDisable(){var e;(e=this.mixer)==null||e.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&D2(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,C;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const i=t.tracks[0].name.split("."),I=i[i.length-2],o=I+".position",s=I+".quaternion";let n=!1,r=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(r=!0,this.createRotationInterpolant(t,e,Q));if(!n||!r){const Q=(C=this.mixer)==null?void 0:C.getRoot(),c=t.tracks[0],E=c.name.lastIndexOf("."),h=c.name.substring(0,E),l=h.substring(h.lastIndexOf(".")+1),d=Q.getObjectByName(l);if(d)if(n){if(!r){const p=t.tracks[0].name.substring(0,E)+".quaternion";kr&&console.warn("Create quaternion track",l,d);const u=d.quaternion,f=new Zs(p,[0,t.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const p=h+".position";kr&&console.warn("Create position track",l,d);const u=d.position,f=new xr(p,[0,t.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,kr&&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 KEA(e);this._actionOffsets.push(t)}this.target&&(this._animator=sA.getComponent(this.target,hI)??null,this._animator&&D2(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,i=t.position,I=t.rotation;i&&i.x!==void 0&&(i.isVector3||(t.position=new y(i.x,i.y,i.z)),I.isQuaternion||(t.rotation=new GA(I.x,I.y,I.z,I.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new y(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new GA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,r,a,C,Q,c,E;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 t=0,i=0,I=!1,o=!1,s=0;for(let h=0;h<this.clips.length;h++){const l=this.models[h],d=this.actions[h],p=l.asset;d.weight=0;const u=e>=l.start&&e<=l.end,f=l.preExtrapolationMode,w=l.postExtrapolationMode,m=h<this.clips.length-1?this.models[h+1]:null;let M=u,G=!1;if(!M&&!I&&l.end<e&&w!==Cr.None?(!m||m.start>e)&&(M=!0,I=!0):h==0&&!M&&!o&&l.start>e&&f!==Cr.None&&(!m||m.start<e)&&(M=!0,G=!0,o=!0),M){let U=1;U*=this.evaluateWeight(e,h,this.models,M),U*=this.director.weight;let S=u;if(G)switch(f){case Cr.Hold:break;case Cr.Loop:e+=l.start,S=!0;break;default:e+=l.start,S=!0;break}let R=this.getClipTime(e,l),v=0;const q=p.duration;if(G&&f===Cr.Hold&&(R=0),S){if(p.loop)for(v+=Math.floor(R/(q+1e-6));R>q;)R-=q}else if(!u&&I)switch(w){case Cr.Hold:R=this.getClipTime(l.end,l);break;case Cr.Loop:R%=q;break;case Cr.PingPong:const K=Math.floor(R/q)%2!==0;R%=q,K&&(R=q-R);break}l.reversed===!0?d.time=d.getClip().duration-R:d.time=R,d.timeScale=0;const b=Math.max(0,U);if(d.weight=b,s+=b,d.clampWhenFinished=!1,d.isRunning()||d.play(),this._useclipOffsets){const O=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,K=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(i=1-U),t+=1;const x=this._summedPos.set(0,0,0),_=this._tempPos.set(0,0,0),Z=this._summedRot.identity(),j=this._tempRot.identity(),oA=p.rotation;oA&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(oA,U));const BA=this._actionOffsets[h];if(BA.hasOffsets)for(let UA=0;UA<v;UA++)BA.rootPositionOffset?_.copy(BA.rootPositionOffset):_.set(0,0,0),_.applyQuaternion(Z),this._clipRotQuat&&_.applyQuaternion(this._clipRotQuat),BA.rootQuaternionOffset&&(j.copy(BA.rootQuaternionOffset),Z.multiply(j)),x.add(_);this._clipRotQuat&&K.multiply(this._clipRotQuat),K.multiply(Z),p.position&&x.add(p.position),O.add(x)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.__mixerError===void 0&&(kr||ae())&&((r=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&r.mixer)&&this.mixer!==((C=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:C.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)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const h=Math.max(0,1-s);(E=(c=this._animator)==null?void 0:c.runtimeAnimatorController)==null||E.update(h)}else this.mixer.update(e)}createRotationInterpolant(e,t,i){var n;const I=i.createInterpolant.bind(i),o=new GA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;i.createInterpolant=()=>{const r=I(),a=r.evaluate.bind(r);return r.evaluate=C=>{var c;const Q=a(C);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(c=E==null?void 0:E.onTimelineRotation)==null||c.call(E,this.director,this.target,C,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},r}}createPositionInterpolant(e,t,i){var a,C;const I=i.createInterpolant.bind(i),o=new y;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(C=this.trackOffset)==null?void 0:C.position;let r;i.createInterpolant=()=>{const Q=I(),c=Q.evaluate.bind(Q);return Q.evaluate=E=>{var l,d,p;const h=c(E);if(o.set(h[0],h[1],h[2]),t.removeStartOffset&&(r===void 0?(r=null,r=(d=(l=this._actionOffsets.find(u=>u.clip===e))==null?void 0:l.rootStartPosition)==null?void 0:d.clone()):r!=null&&r.isVector3&&o.sub(r)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(p=u==null?void 0:u.onTimelinePosition)==null||p.call(u,this.director,this.target,E,o);return h[0]=o.x,h[1]=o.y,h[2]=o.z,h},Q}}}const bEA=gA("mutetimeline"),oh=class extends qD{constructor(){super(...arguments);B(this,"models",[]);B(this,"listener");B(this,"audio",[]);B(this,"audioContextTimeOffset",[]);B(this,"lastTime",0);B(this,"audioSource");B(this,"_audioLoader",null);B(this,"_playableDirectorResumed",!1)}getAudioFilePath(e){const t=this.director.sourceId;return OB(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const i=this.models[t];this.audio[t].setVolume(e?i.asset.volume:0)}}addModel(e){const t=new cJ(this.listener);this.audio.push(t);const i=e;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(bEA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const I=t?.1:0;for(let o=0;o<this.models.length;o++){const s=this.models[o],n=this.audio[o],r=s.asset;if((!n||!n.buffer)&&this.isInTimeRange(s,e-1,e+1)&&this.handleAudioLoading(s,n),zi.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=r.loop,e>=s.start&&e<=s.end&&e<this.director.duration){if(!n.isPlaying||!this.director.isPlaying)(i||!s._didTriggerPlay&&this.lastTime<e)&&(s.duration*s.timeScale>.3?n.offset=s.clipIn+(e-s.start)*s.timeScale:n.offset=0,kr&&console.log("Timeline Audio ("+this.track.name+") play with offset "+n.offset+" - "+s.asset.clip),n.play(I),s._didTriggerPlay=!0);else{const C=s.clipIn+(e-s.start)*s.timeScale,Q=n.context.currentTime-n._startedAt+n.offset;Math.abs(C-Q)>.3&&(n.offset=C,n.stop(),n.play(I))}let a=r.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),t&&(a=0),s.easeInDuration>0){const C=Math.min((e-s.start)/s.easeInDuration,1);a*=C}if(s.easeOutDuration>0){const C=Math.min((s.end-e)/s.easeOutDuration,1);a*=C}n.setVolume(a*this.director.weight)}else s._didTriggerPlay=!1,this.director.isPlaying&&n.isPlaying&&n.stop()}this.lastTime=e}loadAudio(e,t=0,i=0){let I=null;const o=e-i,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const r=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,r);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,i){return t<=e.start&&i>=e.end||t>=e.start&&t<=e.end||i>=e.start&&i<=e.end}static dispose(){oh._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new O0);const i=this.getAudioFilePath(e.asset.clip);if(oh._audioBuffers.get(i)){const o=oh._audioBuffers.get(i);return o.then(s=>{s&&t.setBuffer(s)}),o}kr&&console.warn("LOAD audio track",i,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(i,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return oh._audioBuffers.set(i,I),I}};let wc=oh;B(wc,"_audioBuffers",new Map);class bf extends qD{constructor(){super(...arguments);B(this,"models",[]);B(this,"didTrigger",[]);B(this,"receivers",[])}evaluate(e){var i;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let r=!1;if(o.retroActive)r=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(r=!0)}if(r){if(!s)if(kr&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((i=this.receivers)==null?void 0:i.length)<=0)hd.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class fM extends qD{constructor(){super(...arguments);B(this,"models",[]);B(this,"timelines",[]);B(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=sA.getComponent(I.sourceObject,JB);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const I=this.models[i],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[i];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}var JEA=Object.defineProperty,xEA=Object.getOwnPropertyDescriptor,aj=(g,A,e,t)=>{for(var i=t>1?void 0:t?xEA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&JEA(A,e,i),i};const fl=gA("debugtimeline");var bN;const VK=(bN=class extends FA{constructor(){super(...arguments);B(this,"playableAsset");B(this,"playOnAwake");B(this,"extrapolationMode",1);B(this,"waitForAudio",!0);B(this,"_visibilityChangeEvt");B(this,"_clonedPlayableAsset",!1);B(this,"_speed",1);B(this,"_guidsMap");B(this,"_isPlaying",!1);B(this,"_internalUpdateRoutine");B(this,"_isPaused",!1);B(this,"_isStopping",!1);B(this,"_time",0);B(this,"_duration",0);B(this,"_weight",1);B(this,"_animationTracks",[]);B(this,"_audioTracks",[]);B(this,"_signalTracks",[]);B(this,"_controlTracks",[]);B(this,"_customTracks",[]);B(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);B(this,"animationCallbackReceivers",[])}static registerCreateTrack(A,e){this.createTrackFunctions[A]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(A){typeof A=="number"&&!Number.isNaN(A)?this._time=A:(fl||co())&&console.error("INVALID TIMELINE.TIME VALUE",A,this.name)}get duration(){return this._duration}set duration(A){this._duration=A}get weight(){return this._weight}set weight(A){this._weight=A}get speed(){return this._speed}set speed(A){this._speed=A}awake(){var A,e,t;fl&&console.log(this,(A=this.playableAsset)==null?void 0:A.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 A,e,t;for(const i of this._audioTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._customTracks)(e=i.onEnable)==null||e.call(i);for(const i of this._animationTracks)(t=i.onEnable)==null||t.call(i);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 A,e,t;this.stop();for(const i of this._audioTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._customTracks)(e=i.onDisable)==null||e.call(i);for(const i of this._animationTracks)(t=i.onDisable)==null||t.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var A;for(const e of this._allTracks)for(const t of e)(A=t.onDestroy)==null||A.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const A=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,A&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const e=[];for(const t of this._audioTracks){const i=t.loadAudio(this._time,1,0);i&&e.push(i)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!zi.userInteractionRegistered&&this.waitForAudio;)await vr(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),oi.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 A=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),A&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,A&&!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 A of this._allTracks)for(const e of A)yield e}get audioTracks(){return this._audioTracks}resolveGuids(A){this._guidsMap=A}invokePauseChangedMethodsOnTracks(){var A;for(const e of this.forEachTrack())(A=e.onPauseChanged)==null||A.call(e)}invokeStateChangedMethodsOnTracks(){var A;for(const e of this.forEachTrack())(A=e.onStateChanged)==null||A.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(A=!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 i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case zo.Activation:if(!A&&!this._isPlaying)continue;for(let I=0;I<i.outputs.length;I++){const o=i.outputs[I];if(typeof o=="object"){let s=!1;if(i.clips)for(const r of i.clips)r.start<=t&&t<=r.end&&(s=!0);const n=o;n.visible!==void 0&&n.visible!==s&&(n.visible=s,fl&&console.warn(this.name,"set ActivationTrack-"+I,n.name,s,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=cD(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const A=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let i=e.outputs[t];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const I=sA.findByGuid(i,A);I===null||typeof I!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",i,e.name,e.type)):(fl&&console.log("Resolved binding",i,"to",I),e.outputs[t]=I)}else if(i===null){if(e.outputs.splice(t,1),VK.createTrackFunctions[e.type])continue;e.type!==zo.Audio&&e.type!==zo.Control&&e.type!==zo.Marker&&e.type!==zo.Signal&&console.warn("Missing binding",i,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 i=e.clips[t];let I=i.asset.sourceObject;if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=sA.findByGuid(I,A);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",I,e.name,i):(fl&&console.log("Resolved binding",I,"to",o),i.asset.sourceObject=o)}}}}findRoot(A){return A.parent?this.findRoot(A.parent):A}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const A of this.playableAsset.tracks)if(A.muted!==!0){if(A.clips)for(const e of A.clips)e.end>this._duration&&(this._duration=e.end);if(A.markers)for(const e of A.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var e,t,i;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let A=sA.findObjectOfType(MB,this.context);for(const I of this.playableAsset.tracks){const o=I.type,s=VK.createTrackFunctions[o];if(s!=null){const n=s(this,I);if(typeof n.evaluate=="function"){n.director=this,n.track=I,this._customTracks.push(n);continue}}if(I.type===zo.Animation){if(!I.clips||I.clips.length<=0){fl&&console.warn("Animation track has no clips",I);continue}for(let n=I.outputs.length-1;n>=0;n--){let r=I.outputs[n];if(r instanceof DA){const C=sA.getOrAddComponent(r,hI);C&&(r=C)}const a=(e=r==null?void 0:r.gameObject)==null?void 0:e.animations;if(a){const C=new pM;C.trackOffset=I.trackOffset,C.director=this,C.track=I;for(let Q=0;Q<I.clips.length;Q++){const c=I.clips[Q],E=c.asset;if(!E){console.error(`Timeline ${this.name}: clip #${Q} on track "${I.name}" has no animation data`);continue}const h=E.clip;let l=h;if((typeof l=="string"||typeof l=="number")&&(l=a.find(p=>p.name===h)),!l){console.warn("Could not find animationClip for model",c,I.name,this.name,(t=this.playableAsset)==null?void 0:t.name);continue}r instanceof hI&&r.runtimeAnimatorController&&(r.__internalDidAwakeAndStart||r.initializeRuntimeAnimatorController(),r.runtimeAnimatorController.mixer||r.runtimeAnimatorController.bind(r),C.mixer=r.runtimeAnimatorController.mixer),C.mixer||(C.mixer=new Uk(r.gameObject),this.context.animations.registerAnimationMixer(C.mixer)),C.clips.push(l),C.mixer.uncacheAction(l),C.createHooks(c.asset,l);const d=C.mixer.clipAction(l);C.actions.push(d),C.models.push(c)}this._animationTracks.push(C)}}}else if(I.type===zo.Audio){if(!I.clips||I.clips.length<=0)continue;const n=new wc;n.director=this,n.track=I,n.audioSource=I.outputs.find(r=>r instanceof zi),this._audioTracks.push(n),A||(A=(i=this.context.mainCameraComponent)==null?void 0:i.gameObject.addNewComponent(MB)),n.listener=A.listener;for(let r=0;r<I.clips.length;r++){const a=I.clips[r];n.addModel(a)}}else if(I.type===zo.Marker){const n=new bf;if(n.director=this,n.track=I,I.markers)for(const r of I.markers)switch(r.type){case sv.Signal:n.models.push(r),n.didTrigger.push(!1);break}if(n!==null&&n.models.length>0){const r=sA.getComponent(this.gameObject,hd);r&&(n.receivers.push(r),this._signalTracks.push(n))}}else if(I.type===zo.Signal){const n=new bf;if(n.director=this,n.track=I,I.markers)for(const r of I.markers)n.models.push(r),n.didTrigger.push(!1);for(const r of I.outputs)n.receivers.push(r);this._signalTracks.push(n)}else if(I.type===zo.Control){const n=new fM;if(n.director=this,n.track=I,I.clips)for(const r of I.clips)n.models.push(r);n.resolveSourceObjects(this.context),this._controlTracks.push(n)}}}setAudioTracksAllowPlaying(A){for(const e of this._audioTracks)e.onAllowAudioChanged(A)}registerAnimationCallback(A){this.animationCallbackReceivers.push(A)}unregisterAnimationCallback(A){const e=this.animationCallbackReceivers.indexOf(A);e!==-1&&this.animationCallbackReceivers.splice(e,1)}},B(bN,"createTrackFunctions",{}),bN);let JB=VK;aj([D()],JB.prototype,"playOnAwake",2);aj([D()],JB.prototype,"extrapolationMode",2);const S0=Symbol("objectIsAnimatedData");function D2(g,A,e){if(!g)return;if(g[S0]===void 0){if(!e)return;g[S0]=new Set}const t=g[S0];e?t.add(A):t.has(A)&&t.delete(A)}function vEA(g){if(!g)return!1;const A=g[S0];return A!==void 0&&A.size>0}Et.registerCallback(Gt.ContextCreated,g=>{const A=g.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true"||A==="1")&&g.files)for(const e of g.files)sA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof _I&&i.playAutomatically||i instanceof hI||i instanceof JB&&i.playOnAwake===!0)return!0;if(i instanceof _I)return i.playAutomatically=!0,!0;if(i instanceof JB)return i.playOnAwake=!0,!0}},!0)!==!0&&vh.assignAnimationsFromFile(e.file,{createAnimationComponent:(i,I)=>qn(i,_I)})});class qEA{constructor(){B(this,"_context")}get context(){return this._context??be.Current}get isStateMachineBehaviour(){return!0}}class sp{constructor(A,e,t,i){B(this,"name");B(this,"nameHash");B(this,"normalizedTime");B(this,"length");B(this,"speed");B(this,"action");B(this,"hasTransitions");var I;this.name=A.name,this.nameHash=A.hash,this.normalizedTime=e,this.length=t,this.speed=i,this.action=A.motion.action||null,this.hasTransitions=((I=A.transitions)==null?void 0:I.length)>0||!1}}function Cj(g,A){return{name:"Empty",isLooping:!1,guid:(A==null?void 0:A.generateUUID())??ht.generateUUID(),index:-1,clip:new Qo(g,0,[])}}var tB=(g=>(g[g.If=1]="If",g[g.IfNot=2]="IfNot",g[g.Greater=3]="Greater",g[g.Less=4]="Less",g[g.Equals=6]="Equals",g[g.NotEqual=7]="NotEqual",g))(tB||{}),nv=(g=>(g[g.Float=1]="Float",g[g.Int=3]="Int",g[g.Bool=4]="Bool",g[g.Trigger=9]="Trigger",g))(nv||{});const xg=gA("debuganimatorcontroller"),dS=gA("debugrootmotion");class Bs{constructor(A){B(this,"_speed",1);B(this,"normalizedStartOffset",0);B(this,"animator");B(this,"model");B(this,"_mixer");B(this,"_activeState");B(this,"_activeStates",[]);B(this,"_heldActions",[]);B(this,"rootMotionHandler");this.model=A,xg&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const t=[];for(let o=0;o<A.length;o++){const s=A[o],n=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,C=a/s.duration;let Q=o;(e.autoTransition===void 0||e.autoTransition===!0)&&(Q=(o+1)%A.length),n.push({exitTime:1-C,offset:0,duration:a,hasExitTime:!0,destinationState:Q,conditions:[]})}const r={name:s.name,hash:o,motion:{name:s.name,clip:s,isLooping:(e==null?void 0:e.looping)??!1},transitions:n,behaviours:[]};t.push(r)}const i={name:"AnimatorController",guid:new zg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:t}}]};return new Bs(i)}play(A,e=-1,t=Number.NEGATIVE_INFINITY,i=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const o=this.model.layers[e].stateMachine;for(const s of o.states)if(s.name===A||s.hash===A){xg&&console.log("transition to ",s),this.transitionTo(s,i,t);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var i,I;const t=typeof A=="string"?"name":"hash";return(I=(i=this.model)==null?void 0:i.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getBool(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??!1}setFloat(A,e){var I,o;const t=typeof A=="string"?"name":"hash",i=(o=(I=this.model)==null?void 0:I.parameters)==null?void 0:o.filter(s=>s[t]===A);return i.forEach(s=>s.value=e),(i==null?void 0:i.length)>0}getFloat(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??0}setInteger(A,e){var i,I;const t=typeof A=="string"?"name":"hash";return(I=(i=this.model)==null?void 0:i.parameters)==null?void 0:I.filter(o=>o[t]===A).forEach(o=>o.value=e)}getInteger(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??0}setTrigger(A){var t,i;xg&&console.log("SET TRIGGER",A);const e=typeof A=="string"?"name":"hash";return(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.filter(I=>I[e]===A).forEach(I=>I.value=!0)}resetTrigger(A){var t,i;const e=typeof A=="string"?"name":"hash";return(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.filter(I=>I[e]===A).forEach(I=>I.value=!1)}getTrigger(A){var t,i,I;const e=typeof A=="string"?"name":"hash";return((I=(i=(t=this.model)==null?void 0:t.parameters)==null?void 0:i.find(o=>o[e]===A))==null?void 0:I.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const t of e.stateMachine.states)if(t.name===A||t.hash==A)return t}return null}getCurrentStateInfo(){if(!this._activeState)return null;const A=this._activeState.motion.action;if(!A)return null;const e=this._activeState.motion.clip.duration,t=e<=0?0:Math.abs(A.time/e);return new sp(this._activeState,t,e,this._speed)}get currentAction(){if(!this._activeState)return null;const A=this._activeState.motion.action;return A||null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}dispose(){var A;if(this._mixer.stopAllAction(),this.animator){this._mixer.uncacheRoot(this.animator.gameObject);for(const e of this._activeStates)e.motion.clip&&this.mixer.uncacheAction(e.motion.clip,this.animator.gameObject)}(A=this.context)==null||A.animations.unregisterAnimationMixer(this._mixer)}bind(A){var e,t;A?this.animator!==A&&(this._mixer&&(this._mixer.stopAllAction(),(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)),this.animator=A,this._mixer=new Uk(this.animator.gameObject),(t=this.context)==null||t.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;xg&&console.warn("AnimatorController clone()",this.model);const A=cD(this.model,(t,i,I)=>I==null?!0:!(I.type==="Object3D"||I.isObject3D===!0||C3(I)||I.tracks!==void 0||I instanceof Bs));return console.assert(A!==this.model),new Bs(A)}update(A){var t,i;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const e=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((t=this.rootMotionHandler)==null||t.onBeforeUpdate(A)),this._mixer.update(e),this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const t=this._activeStates[e],i=t.motion;if(!i.action)this._activeStates.splice(e,1),e--;else{const I=i.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(xg&&console.debug("REMOVE",t.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){var A;this.model.layers.length>1&&(xg||ae())&&console.warn("Multiple layers are not supported yet "+((A=this.animator)==null?void 0:A.name));for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(xg&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const i=t.states[t.defaultState];this.transitionTo(i,0,this.normalizedStartOffset);break}}evaluateTransitions(){var I;let A=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;A=!0}const e=this._activeState,t=e.motion.action;for(const o of e.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const n of o.conditions)if(!this.evaluateCondition(n)){s=!1;break}if(s)if(t){const n=e.motion.clip.duration,r=n<=0?1:Math.abs(t.time/n);let a=o.exitTime;t.timeScale<0&&(a=1-a);let C=!1;if(o.hasExitTime?t.timeScale>0?C=r>=o.exitTime:t.timeScale<0&&(C=1-r>=o.exitTime):C=!0,C){for(const Q of o.conditions){const c=this.model.parameters.find(E=>E.name===Q.parameter);(c==null?void 0:c.type)===nv.Trigger&&c.value&&(c.value=!1)}if(t.clampWhenFinished=!0,xg){const Q=this.getState(o.destinationState,0);console.log(`Transition to ${o.destinationState} / ${Q==null?void 0:Q.name}`,o,`
|
|
5734
5734
|
Timescale: `+t.timeScale,`
|
|
5735
5735
|
Normalized time: `+r.toFixed(3),`
|
|
@@ -6212,7 +6212,7 @@ Texture:`,t),this.setLightmapDebugMaterial()):yl&&console.log("Use debuglightmap
|
|
|
6212
6212
|
}
|
|
6213
6213
|
`};class Kv extends Ke{constructor(A){super({type:"LineMaterial",uniforms:Ad.clone(CI.line.uniforms),vertexShader:CI.line.vertexShader,fragmentShader:CI.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(A)}get color(){return this.uniforms.diffuse.value}set color(A){this.uniforms.diffuse.value=A}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(A){A===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(A){this.uniforms.linewidth&&(this.uniforms.linewidth.value=A)}get dashed(){return"USE_DASH"in this.defines}set dashed(A){A===!0!==this.dashed&&(this.needsUpdate=!0),A===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(A){this.uniforms.dashScale.value=A}get dashSize(){return this.uniforms.dashSize.value}set dashSize(A){this.uniforms.dashSize.value=A}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(A){this.uniforms.dashOffset.value=A}get gapSize(){return this.uniforms.gapSize.value}set gapSize(A){this.uniforms.gapSize.value=A}get opacity(){return this.uniforms.opacity.value}set opacity(A){this.uniforms&&(this.uniforms.opacity.value=A)}get resolution(){return this.uniforms.resolution.value}set resolution(A){this.uniforms.resolution.value.copy(A)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(A){this.defines&&(A===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),A===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const L2=new y,_2=new y,eI=new Ae,tI=new Ae,ir=new Ae,gN=new y,IN=new fA,rI=new Nk,T2=new y,kS=new Nt,MS=new Zi,gr=new Ae;let fr,Mc;function H2(g,A,e){return gr.set(0,0,-A,1).applyMatrix4(g.projectionMatrix),gr.multiplyScalar(1/gr.w),gr.x=Mc/e.width,gr.y=Mc/e.height,gr.applyMatrix4(g.projectionMatrixInverse),gr.multiplyScalar(1/gr.w),Math.abs(Math.max(gr.x,gr.y))}function UdA(g,A){const e=g.matrixWorld,t=g.geometry,i=t.attributes.instanceStart,I=t.attributes.instanceEnd,o=Math.min(t.instanceCount,i.count);for(let s=0,n=o;s<n;s++){rI.start.fromBufferAttribute(i,s),rI.end.fromBufferAttribute(I,s),rI.applyMatrix4(e);const r=new y,a=new y;fr.distanceSqToSegment(rI.start,rI.end,a,r),a.distanceTo(r)<Mc*.5&&A.push({point:a,pointOnLine:r,distance:fr.origin.distanceTo(a),object:g,face:null,faceIndex:s,uv:null,uv1:null})}}function NdA(g,A,e){const t=A.projectionMatrix,I=g.material.resolution,o=g.matrixWorld,s=g.geometry,n=s.attributes.instanceStart,r=s.attributes.instanceEnd,a=Math.min(s.instanceCount,n.count),C=-A.near;fr.at(1,ir),ir.w=1,ir.applyMatrix4(A.matrixWorldInverse),ir.applyMatrix4(t),ir.multiplyScalar(1/ir.w),ir.x*=I.x/2,ir.y*=I.y/2,ir.z=0,gN.copy(ir),IN.multiplyMatrices(A.matrixWorldInverse,o);for(let Q=0,c=a;Q<c;Q++){if(eI.fromBufferAttribute(n,Q),tI.fromBufferAttribute(r,Q),eI.w=1,tI.w=1,eI.applyMatrix4(IN),tI.applyMatrix4(IN),eI.z>C&&tI.z>C)continue;if(eI.z>C){const u=eI.z-tI.z,f=(eI.z-C)/u;eI.lerp(tI,f)}else if(tI.z>C){const u=tI.z-eI.z,f=(tI.z-C)/u;tI.lerp(eI,f)}eI.applyMatrix4(t),tI.applyMatrix4(t),eI.multiplyScalar(1/eI.w),tI.multiplyScalar(1/tI.w),eI.x*=I.x/2,eI.y*=I.y/2,tI.x*=I.x/2,tI.y*=I.y/2,rI.start.copy(eI),rI.start.z=0,rI.end.copy(tI),rI.end.z=0;const h=rI.closestPointToPointParameter(gN,!0);rI.at(h,T2);const l=ht.lerp(eI.z,tI.z,h),d=l>=-1&&l<=1,p=gN.distanceTo(T2)<Mc*.5;if(d&&p){rI.start.fromBufferAttribute(n,Q),rI.end.fromBufferAttribute(r,Q),rI.start.applyMatrix4(o),rI.end.applyMatrix4(o);const u=new y,f=new y;fr.distanceSqToSegment(rI.start,rI.end,f,u),e.push({point:f,pointOnLine:u,distance:fr.origin.distanceTo(f),object:g,face:null,faceIndex:Q,uv:null,uv1:null})}}}class FdA extends hA{constructor(A=new qj,e=new Kv({color:Math.random()*16777215})){super(A,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const A=this.geometry,e=A.attributes.instanceStart,t=A.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let o=0,s=0,n=e.count;o<n;o++,s+=2)L2.fromBufferAttribute(e,o),_2.fromBufferAttribute(t,o),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+L2.distanceTo(_2);const I=new P0(i,2,1);return A.setAttribute("instanceDistanceStart",new gs(I,1,0)),A.setAttribute("instanceDistanceEnd",new gs(I,1,1)),this}raycast(A,e){const t=this.material.worldUnits,i=A.camera;i===null&&!t&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const I=A.params.Line2!==void 0&&A.params.Line2.threshold||0;fr=A.ray;const o=this.matrixWorld,s=this.geometry,n=this.material;Mc=n.linewidth+I,s.boundingSphere===null&&s.computeBoundingSphere(),MS.copy(s.boundingSphere).applyMatrix4(o);let r;if(t)r=Mc*.5;else{const C=Math.max(i.near,MS.distanceToPoint(fr.origin));r=H2(i,C,n.resolution)}if(MS.radius+=r,fr.intersectsSphere(MS)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),kS.copy(s.boundingBox).applyMatrix4(o);let a;if(t)a=Mc*.5;else{const C=Math.max(i.near,kS.distanceToPoint(fr.origin));a=H2(i,C,n.resolution)}kS.expandByScalar(a),fr.intersectsBox(kS)!==!1&&(t?UdA(this,e):NdA(this,i,e))}}class Lj extends qj{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(A){const e=A.length-3,t=new Float32Array(2*e);for(let i=0;i<e;i+=3)t[2*i]=A[i],t[2*i+1]=A[i+1],t[2*i+2]=A[i+2],t[2*i+3]=A[i+3],t[2*i+4]=A[i+4],t[2*i+5]=A[i+5];return super.setPositions(t),this}setColors(A){const e=A.length-3,t=new Float32Array(2*e);for(let i=0;i<e;i+=3)t[2*i]=A[i],t[2*i+1]=A[i+1],t[2*i+2]=A[i+2],t[2*i+3]=A[i+3],t[2*i+4]=A[i+4],t[2*i+5]=A[i+5];return super.setColors(t),this}fromLine(A){const e=A.geometry;return this.setPositions(e.attributes.position.array),this}}class KdA extends FdA{constructor(A=new Lj,e=new Kv({color:Math.random()*16777215})){super(A,e),this.isLine2=!0,this.type="Line2"}}class NM extends FA{}var bdA=Object.defineProperty,JdA=Object.getOwnPropertyDescriptor,dE=(g,A,e,t)=>{for(var i=t>1?void 0:t?JdA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&bdA(A,e,i),i};const Y2=gA("debugwebxr");class $s extends FA{constructor(){super(...arguments);B(this,"movementSpeed",1.5);B(this,"rotationStep",30);B(this,"useTeleport",!0);B(this,"useTeleportTarget",!1);B(this,"useTeleportFade",!1);B(this,"showRays",!0);B(this,"showHits",!1);B(this,"isXRMovementHandler",!0);B(this,"xrSessionMode","immersive-vr");B(this,"_didApplyRotation",!1);B(this,"_didTeleport",!1);B(this,"_plane",null);B(this,"_lines",[]);B(this,"_hitDiscs",[]);B(this,"_hitDistances",[]);B(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 i=e.xr.leftController,I=e.xr.rightController;i&&this.onHandleMovement(i,t.gameObject),I&&(this.onHandleRotation(I,t.gameObject),this.useTeleport&&this.onHandleTeleport(I,t.gameObject))}onLeaveXR(e){for(const t of this._lines)t.removeFromParent();for(const t of this._hitDiscs)t==null||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 i=e.getStick("xr-standard-thumbstick"),I=new y(i.x,0,i.y);I.multiplyScalar(this.context.time.deltaTimeUnscaled*this.movementSpeed);const o=ii(t);I.multiplyScalar(o.x),I.applyQuaternion(e.xr.poseOrientation),I.y=0,I.applyQuaternion(t.worldQuaternion),t.position.add(I),t.updateMatrixWorld()}onHandleRotation(e,t){const I=e.getStick("xr-standard-thumbstick").x;if(this._didApplyRotation)Math.abs(I)<.3&&(this._didApplyRotation=!1);else if(Math.abs(I)>.5){this._didApplyRotation=!0;const o=I>0?1:-1;t.rotateY(o*ge.toRadians(this.rotationStep))}}onHandleTeleport(e,t){var I;const i=e.getStick("xr-standard-thumbstick");if(this._didTeleport)i.y<.2&&(this._didTeleport=!1);else if(i.y>.8){this._didTeleport=!0;const o=this.context.physics.raycastFromRay(e.ray)[0];let s=o==null?void 0:o.point;if(!s){this._plane||(this._plane=new xI(new y(0,1,0),0));const n=t.worldPosition;this._plane.setFromNormalAndCoplanarPoint(new y(0,1,0),n);const r=e.ray;s=n.clone(),this._plane.intersectLine(new Nk(r.origin,dt(r.direction).multiplyScalar(1e4).add(r.origin)),s),s.distanceTo(n)>t.scale.x*10&&(s=null)}if(s){if(this.useTeleportTarget&&!sA.getComponentInParent(o.object,NM))return;Y2&&fe.DrawSphere(s,.025,16711680,5);const n=s.clone();this.useTeleportFade?(I=e.xr.fadeTransition())==null||I.then(()=>{t.worldPosition=n}):t.worldPosition=n}}}renderRays(e){for(let t=0;t<this._lines.length;t++){const i=this._lines[t];i&&(i.visible=!1)}for(let t=0;t<e.controllers.length;t++){const i=e.controllers[t];let I=this._lines[t];if(!i.connected||!i.isTracking||!i.ray||i.targetRayMode==="transient-pointer"||!i.hasSelectEvent){I&&(I.visible=!1);continue}I||(I=this.createRayLineObject(),I.scale.z=.5,this._lines[t]=I),i.updateRayWorldPosition(),i.updateRayWorldQuaternion();const o=i.rayWorldPosition,s=i.rayWorldQuaternion;I.position.copy(o),I.quaternion.copy(s);const n=e.rigScale,r=this._hitDistances[t]??n;I.scale.set(n,n,r),I.visible=!0,I.layers.disableAll(),I.layers.enable(2),I.parent!==this.context.scene&&this.context.scene.add(I)}}renderHits(e){for(const t of this._hitDiscs){if(!t)continue;const i=t.controller;if(!i||!i.connected||!i.isTracking){t.visible=!1;continue}}for(let t=0;t<e.controllers.length;t++){const i=e.controllers[t];if(!i.connected||!i.isTracking||!i.ray||!i.hasSelectEvent)continue;const I=this.context.time.smoothedFps>=59?1:10;if((this.context.time.frame+i.index)%I!==0){const n=this._hitDiscs[t];n&&n.hit&&(n.visible=!0,this.hitPointerSetPosition(i,n,n.hit.distance));continue}const o=this.context.physics.raycastFromRay(i.ray,{testObject:this.hitPointRaycastFilter})[0];this._hitDistances[t]=o==null?void 0:o.distance;let s=this._hitDiscs[t];if(s&&(s.controller=i,s.hit=o),o){const n=e.rigScale??1;Y2&&(fe.DrawWireSphere(o.point,.025*n,16711680),fe.DrawLabel(dt(0,.2,0).add(o.point),o.object.name,.02,0)),s||(s=this.createHitPointObject(),this._hitDiscs[t]=s),s.visible=!0;const r=.01*(n+o.distance);if(s.scale.set(r,r,r),s.layers.disableAll(),s.layers.enable(2),s.hit=o,o.normal){this.hitPointerSetPosition(i,s,o.distance);const a=o.normal.applyQuaternion(Jt(o.object));s.quaternion.setFromUnitVectors(xdA,a)}else this.hitPointerSetPosition(i,s,o.distance);s.parent!==this.context.scene&&this.context.scene.add(s)}else this._hitDiscs[t]&&(this._hitDiscs[t].visible=!1)}}hitPointerSetPosition(e,t,i){t.position.copy(e.rayWorldPosition),t.position.add(dt(0,0,i-.01).applyQuaternion(e.rayWorldQuaternion))}createHitPointObject(){var e=new DA;const t=new hA(new gn(.3,6,6),new ot({color:15658734,opacity:.7,transparent:!0,depthTest:!1,side:kt}));return t.layers.disableAll(),t.layers.enable(2),e.add(t),e}createRayLineObject(){const e=new KdA;e.layers.disableAll(),e.layers.enable(2);const t=new Lj;e.geometry=t;const i=new Float32Array(9);i.set([0,0,.02,0,0,.4,0,0,1]),t.setPositions(i);const I=new Float32Array(9);I.set([1,1,1,.1,.1,.1,0,0,0]),t.setColors(I);const o=new Kv({color:16777215,vertexColors:!0,worldUnits:!0,linewidth:.004,transparent:!0,blending:Rc,dashed:!1,alphaToCoverage:!0});return e.material=o,e}}dE([D()],$s.prototype,"movementSpeed",2);dE([D()],$s.prototype,"rotationStep",2);dE([D()],$s.prototype,"useTeleport",2);dE([D()],$s.prototype,"useTeleportTarget",2);dE([D()],$s.prototype,"useTeleportFade",2);dE([D()],$s.prototype,"showRays",2);dE([D()],$s.prototype,"showHits",2);const xdA=new y(0,1,0);var vdA=Object.defineProperty,qdA=Object.getOwnPropertyDescriptor,Lo=(g,A,e,t)=>{for(var i=t>1?void 0:t?qdA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&vdA(A,e,i),i};const Fu=gA("debugwebxr"),LdA=gA("debugusdz");class Xg extends FA{constructor(){super(...arguments);B(this,"createVRButton",!0);B(this,"createARButton",!0);B(this,"createSendToQuestButton",!0);B(this,"createQRCode",!0);B(this,"useDefaultControls",!0);B(this,"showControllerModels",!0);B(this,"showHandModels",!0);B(this,"usePlacementReticle",!0);B(this,"usePlacementAdjustment",!0);B(this,"arSceneScale",1);B(this,"useXRAnchor",!1);B(this,"useQuicklookExport",!1);B(this,"useDepthSensing",!1);B(this,"defaultAvatar");B(this,"_playerSync");B(this,"_createdComponentsInSession",[]);B(this,"_usdzExporter");B(this,"_previousXRState",0);B(this,"onAvatarSpawned",e=>{Fu&&console.log("WebXR.onAvatarSpawned",e),sA.getComponentInChildren(e,xB)??(t=sA.addComponent(e,xB))});B(this,"_buttonFactory");B(this,"_buttons",[])}awake(){ye.getXRSync(this.context)}onEnable(){var e,t;window.location.protocol!=="https:"&&Ot('<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&&(sA.findObjectOfType(ji)||(Fu&&console.log("WebXR: Adding USDZExporter"),this._usdzExporter=sA.addComponent(this.gameObject,ji),this._usdzExporter.objectToExport=this.context.scene,this._usdzExporter.autoExportAnimations=!0,this._usdzExporter.autoExportAudioSources=!0)),this.handleCreatingHTML(),this.handleOfferSession(),this.defaultAvatar||(Fu&&console.warn("WebXR: No default avatar set, using static default avatar"),this.defaultAvatar=new et("https://cdn.needle.tools/static/avatars/DefaultAvatar.glb")),this.defaultAvatar&&(this._playerSync=this.gameObject.getOrAddComponent(dd),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 ye.isVRSupported()&&this.createVRButton?ye.offerSession("immersive-vr","default",this.context):this.createARButton&&await ye.isARSupported()&&this.createARButton?ye.offerSession("immersive-ar","default",this.context):!1}get session(){return ye.active??null}get sessionMode(){return ye.activeMode??null}async enterVR(e){return ye.start("immersive-vr",e,this.context)}async enterAR(e){return ye.start("immersive-ar",e,this.context)}exitXR(){ye.stop()}onBeforeXR(e,t){e=="immersive-ar"&&this.useDepthSensing&&(t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.push("depth-sensing"))}async onEnterXR(e){Fu&&console.log("WebXR onEnterXR"),this._previousXRState=BI.Global.Mask;const t=e.xr.isVR;if(BI.Global.Set(t?pr.VR:pr.AR),this.usePlacementReticle&&e.xr.isAR){let I=sA.findObjectOfType(ho);if(I)Fu&&console.log("WebXR: WebARSessionRoot already exists, not creating a new one");else{const o=new DA;for(const s of this.context.scene.children)o.add(s);this.context.scene.add(o),I=sA.addComponent(o,ho),this._createdComponentsInSession.push(I),I.arScale=this.arSceneScale,I.arTouchTransform=this.usePlacementAdjustment,I.useXRAnchor=this.useXRAnchor}}this.useDefaultControls&&this.setDefaultMovementEnabled(!0),(this.showControllerModels||this.showHandModels)&&this.setDefaultControllerRenderingEnabled(!0);let i=sA.findObjectOfType(Ff);i||(i=this.gameObject.addNewComponent(Ff)),this.createLocalAvatar(e.xr)}onLeaveXR(e){var t;BI.Global.Set(this._previousXRState),(t=this._playerSync)==null||t.destroyInstance();for(const i of this._createdComponentsInSession)i.destroy();this._createdComponentsInSession.length=0,this.handleOfferSession()}setDefaultMovementEnabled(e){let t=this.gameObject.getComponent($s);return!t&&e&&(t=this.gameObject.addComponent($s),this._createdComponentsInSession.push(t)),t&&(t.enabled=e),t}setDefaultControllerRenderingEnabled(e){let t=this.gameObject.getComponent(Lr);return!t&&e&&(t=this.gameObject.addComponent(Lr),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=$a.getOrCreate()),this._buttonFactory}handleCreatingHTML(){if(this.createARButton||this.createVRButton||this.useQuicklookExport){if((Lc()&&Ch()||LdA)&&this.useQuicklookExport){const t=sA.findObjectOfType(ji);if(!t||t&&t.allowCreateQuicklookButton){const i=this.getButtonsFactory().createQuicklookButton();this.addButton(i,50)}}if(this.createARButton){const t=this.getButtonsFactory().createARButton();this.addButton(t,50)}if(this.createVRButton){const t=this.getButtonsFactory().createVRButton();this.addButton(t,50)}}if(this.createSendToQuestButton&&!bk()&&ye.isVRSupported().then(t=>{if(!t){const i=this.getButtonsFactory().createSendToQuestButton();this.addButton(i,50)}}),this.createQRCode&&!In()){const t=QM(zr);t&&t.createQRCodeButton===!1?ae()&&console.warn("WebXR: QRCode button is disabled in the Needle Menu component"):ye.isXRSupported().then(i=>{if(qc()||!i){const I=bn.getOrCreate().createQRCode();this.addButton(I,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}}Lo([D()],Xg.prototype,"createVRButton",2);Lo([D()],Xg.prototype,"createARButton",2);Lo([D()],Xg.prototype,"createSendToQuestButton",2);Lo([D()],Xg.prototype,"createQRCode",2);Lo([D()],Xg.prototype,"useDefaultControls",2);Lo([D()],Xg.prototype,"showControllerModels",2);Lo([D()],Xg.prototype,"showHandModels",2);Lo([D()],Xg.prototype,"usePlacementReticle",2);Lo([D()],Xg.prototype,"usePlacementAdjustment",2);Lo([D()],Xg.prototype,"arSceneScale",2);Lo([D()],Xg.prototype,"useXRAnchor",2);Lo([D()],Xg.prototype,"useQuicklookExport",2);Lo([D()],Xg.prototype,"useDepthSensing",2);Lo([D(et)],Xg.prototype,"defaultAvatar",2);class FM{get extensionName(){return"Physics"}onExportObject(A,e,t){const i=sA.getComponents(A,Pt).filter(n=>n.enabled),I=sA.getComponents(A,ls).filter(n=>n.enabled&&!n.isTrigger);let o=i.length>0?i[0]:null;const s=I.length>0?I[0]:null;s&&!o&&(o=new Pt,o.isKinematic=!0),o&&e.addEventListener("serialize",(n,r)=>{var a,C,Q;if(o){if(n.appendLine(),n.beginBlock('def RealityKitComponent "RigidBody"',"{",!0),o.useGravity||n.appendLine("bool gravityEnabled = 0"),n.appendLine('uniform token info:id = "RealityKit.RigidBody"'),o.isKinematic&&n.appendLine('token motionType = "Kinematic"'),n.beginBlock('def RealityKitStruct "massFrame"',"{",!0),n.appendLine(`float m_mass = ${o.mass}`),n.beginBlock('def RealityKitStruct "m_pose"',"{",!0),n.appendLine(`float3 position = (${o.centerOfMass.x}, ${o.centerOfMass.y}, ${o.centerOfMass.z})`),n.closeBlock("}"),n.closeBlock("}"),I.length>0){const c=I[0];n.beginBlock('def RealityKitStruct "material"',"{",!0);const E=c.sharedMaterial;E&&E.dynamicFriction!==void 0&&n.appendLine(`double dynamicFriction = ${(a=c.sharedMaterial)==null?void 0:a.dynamicFriction}`),E&&E.bounciness!==void 0&&n.appendLine(`double restitution = ${(C=c.sharedMaterial)==null?void 0:C.bounciness}`),E&&E.staticFriction!==void 0&&n.appendLine(`double staticFriction = ${(Q=c.sharedMaterial)==null?void 0:Q.staticFriction}`),n.closeBlock("}")}n.closeBlock("}")}}),s&&(e.addEventListener("serialize",(n,r)=>{var Q;n.beginBlock('def RealityKitComponent "Collider"',"{",!0),n.appendLine("uint group = 1"),n.appendLine('uniform token info:id = "RealityKit.Collider"'),n.appendLine("uint mask = 4294967295");const C=s.isTrigger?"Trigger":"Default";if(n.appendLine(`token type = "${C}"`),n.beginBlock('def RealityKitStruct "Shape"',"{",!0),s instanceof fd){const c=s;n.appendLine('token shapeType = "Sphere"'),n.appendLine(`float radius = ${c.radius}`)}else if(s instanceof Dd){const c=s;n.appendLine('token shapeType = "Box"'),n.appendLine(`float3 extent = (${c.size.x}, ${c.size.y}, ${c.size.z})`)}else if(s instanceof iC){const c=s;n.appendLine('token shapeType = "Capsule"'),n.appendLine(`float radius = ${c.radius}`),n.appendLine(`float height = ${c.height}`)}else if(s instanceof CE&&((Q=s.sharedMesh)!=null&&Q.geometry)){const c=s.sharedMesh.geometry;c.boundingBox||c.computeBoundingBox();const E=s.sharedMesh.geometry.boundingBox;E&&(n.appendLine('token shapeType = "Box"'),n.appendLine(`float3 extent = (${E.max.x-E.min.x}, ${E.max.y-E.min.y}, ${E.max.z-E.min.z})`),console.log("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. MeshCollider will be exported as Box",s))}else console.warn("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. Ignoring collider:",s);n.beginBlock('def RealityKitStruct "pose"',"{",!0),n.closeBlock("}"),n.closeBlock("}"),n.closeBlock("}")}),I.length>1&&console.log("WARNING: Multiple colliders detected. visionOS / iOS can only support objects with a single collider, only exporting the first collider: ",s))}}var _dA=Object.defineProperty,TdA=Object.getOwnPropertyDescriptor,EC=(g,A,e,t)=>{for(var i=t>1?void 0:t?TdA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&_dA(A,e,i),i};const bQ=gA("debugtext");var yg=(g=>(g[g.UpperLeft=0]="UpperLeft",g[g.UpperCenter=1]="UpperCenter",g[g.UpperRight=2]="UpperRight",g[g.MiddleLeft=3]="MiddleLeft",g[g.MiddleCenter=4]="MiddleCenter",g[g.MiddleRight=5]="MiddleRight",g[g.LowerLeft=6]="LowerLeft",g[g.LowerCenter=7]="LowerCenter",g[g.LowerRight=8]="LowerRight",g))(yg||{}),_j=(g=>(g[g.Normal=0]="Normal",g[g.Bold=1]="Bold",g[g.Italic=2]="Italic",g[g.BoldAndItalic=3]="BoldAndItalic",g))(_j||{});class WI extends QE{constructor(){super(...arguments);B(this,"alignment",0);B(this,"verticalOverflow",0);B(this,"horizontalOverflow",0);B(this,"lineSpacing",1);B(this,"supportRichText",!1);B(this,"font");B(this,"fontStyle",0);B(this,"sRGBTextColor",new yA(1,0,1));B(this,"_text","");B(this,"_fontSize",12);B(this,"_textMeshUi",null);B(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 t;const e=(t=this.uiObject)==null?void 0:t._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(e){bQ&&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,bQ&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),bQ&&(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 i,I,o;if(bQ&&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 s=this.getNextTag(e);if(s){if(s.startIndex>0){for(let a=this.uiObject.children.length-1;a>=0;a--){const C=this.uiObject.children[a];C.isUI&&(this.uiObject.remove(C),C.clear())}const r=new i0({textContent:e.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(r)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const n=[];for(;s;){const r=this.getNextTag(e,s.endIndex),a={fontFamily:(i=this.uiObject)==null?void 0:i.get("fontFamily"),color:"inherit",textContent:""};if(r){a.textContent=this.getText(e,s,r),this.handleTag(s,a,n);const C=new i0(a);(I=this.uiObject)==null||I.add(C)}else{a.textContent=e.substring(s.endIndex),this.handleTag(s,a,n);const C=new i0(a);(o=this.uiObject)==null||o.add(C)}s=r}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,i={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(e[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(ym(s,i),e[o]=!0)}if(!I)break;yield}}handleTag(e,t,i){if(!e.isEndTag){if(e.type.includes("color")){const I=new oN(e,{color:t.color});if(i.push(I),e.type.length>6){const o=parseInt("0x"+e.type.substring(7));t.color=o}else t.color=new yA(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const I=new oN(e,{fontWeight:700});i.push(I)}else if(e.type=="i"){this.setFont(t,2);const I=new oN(e,{fontStyle:"italic"});i.push(I)}}}getText(e,t,i){return e.substring(t.endIndex,i.startIndex)}getNextTag(e,t=0){const i=e.indexOf("<",t),I=e.indexOf(">",i);if(i>=0&&I>=0){const o=e.substring(i+1,I);return{type:o,startIndex:i,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const i=this.font,I=this.getFamilyNameWithCorrectSuffix(i,t);bQ&&console.log("Selected font family:"+I);let o=_F.getFontFamily(I);switch(o||(o=_F.addFontFamily(I)),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 s=o.getVariant(e.fontWeight,e.fontStyle);if(!s){let n=I;n!=null&&n.endsWith("-msdf.json")||(n+="-msdf.json");let r=I;r!=null&&r.endsWith(".png")||(r+=".png"),s=o.addVariant(e.fontWeight,e.fontStyle,n,r),s==null||s.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var a;const i=e.lastIndexOf("-");if(i<0)return e;const I=(a=e.substring(i+1))==null?void 0:a.toLowerCase();if(HdA.includes(I))return bQ&&console.warn("Unsupported font style: "+I),e;const o=e.lastIndexOf("/");let s=e;o>=0&&(s=s.substring(o+1));const n=s[0]===s[0].toUpperCase(),r=e.substring(0,i);switch(bQ&&console.log("Select font: ",e,_j[t],s,n,r),t){case 0:return n?r+"-Regular":r+"-regular";case 1:return n?r+"-Bold":r+"-bold";case 2:return n?r+"-Italic":r+"-italic";case 3:return n?r+"-BoldItalic":r+"-bolditalic";default:return e}}}EC([D()],WI.prototype,"alignment",2);EC([D()],WI.prototype,"verticalOverflow",2);EC([D()],WI.prototype,"horizontalOverflow",2);EC([D()],WI.prototype,"lineSpacing",2);EC([D()],WI.prototype,"supportRichText",2);EC([D(URL)],WI.prototype,"font",2);EC([D()],WI.prototype,"fontStyle",2);EC([D()],WI.prototype,"text",1);EC([D()],WI.prototype,"fontSize",1);class oN{constructor(A,e){B(this,"tag");B(this,"previousValues");this.tag=A,this.previousValues=e}}const HdA=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class EB{constructor(A){B(this,"id");B(this,"content","");B(this,"font",[]);B(this,"pointSize",144);B(this,"width");B(this,"height");B(this,"depth");B(this,"wrapMode");B(this,"horizontalAlignment");B(this,"verticalAlignment");B(this,"material");this.id=A}static getId(){return this.global_id++}setDepth(A){return this.depth=A,this}setPointSize(A){return this.pointSize=A,this}setHorizontalAlignment(A){return this.horizontalAlignment=A,this}setVerticalAlignment(A){return this.verticalAlignment=A,this}writeTo(A,e){var i;e.beginBlock(`def Preliminary_Text "${this.id}"`,"(",!1),e.appendLine('prepend apiSchemas = ["MaterialBindingAPI"]'),e.closeBlock(")"),e.beginBlock(),this.content&&e.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(i=this.font)==null||i.push("sans-serif"));const t=this.font.map(I=>`"${I}"`).join(", ");e.appendLine(`string[] font = [ ${t} ]`),e.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&e.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&e.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&e.appendLine(`double depth = ${this.depth}`),this.wrapMode&&e.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&e.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&e.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&e.appendLine(`rel material:binding = </StageRoot/Materials/${wx(this.material)}>`),e.closeBlock()}}B(EB,"global_id",0);class KM{static singleLine(A,e,t){const i=new EB("text_"+EB.getId());return i.content=A,e&&(i.pointSize=e),t&&(i.depth=t),i}static multiLine(A,e,t,i,I,o){const s=new EB("text_"+EB.getId());return s.content=A,s.width=e,s.height=t,s.horizontalAlignment=i,s.verticalAlignment=I,o!==void 0&&(s.wrapMode=o),s}}const YdA=new fA().makeRotationY(Math.PI),OdA=new fA().makeScale(-1,1,-1);class Ay{get extensionName(){return"text"}exportText(A,e,t){const i=sA.getComponent(A,WI);if(!i)return;const I=sA.getComponent(A,OI);let o=100,s=100;I&&(o=I.width,s=I.height),e.matrix=YdA.clone(),I&&e.matrix.premultiply(OdA);const n=i.color.clone();e.material=new LI({color:n,emissive:n}),e.addEventListener("serialize",(r,a)=>{let C=i.text;C=C.replace(/\r/g,""),C=C.replace(/\n/g,"\\n");const Q=KM.multiLine(C,o,s,"center","bottom","flowing");this.setTextAlignment(Q,i.alignment),this.setOverflow(Q,i),e.material&&(Q.material=e.material),Q.pointSize=this.convertToTextSize(i.fontSize),Q.depth=.001,Q.writeTo(void 0,r)})}convertToTextSize(A){return 1/.0502*144*A}setOverflow(A,e){e.horizontalOverflow?A.wrapMode="singleLine":A.wrapMode="flowing"}setTextAlignment(A,e){switch(e){case yg.LowerLeft:case yg.MiddleLeft:case yg.UpperLeft:A.horizontalAlignment="left";break;case yg.LowerCenter:case yg.MiddleCenter:case yg.UpperCenter:A.horizontalAlignment="center";break;case yg.LowerRight:case yg.MiddleRight:case yg.UpperRight:A.horizontalAlignment="right";break}switch(e){case yg.LowerLeft:case yg.LowerCenter:case yg.LowerRight:A.verticalAlignment="bottom";break;case yg.MiddleLeft:case yg.MiddleCenter:case yg.MiddleRight:A.verticalAlignment="middle";break;case yg.UpperLeft:case yg.UpperCenter:case yg.UpperRight:A.verticalAlignment="top";break}}}class bM{get extensionName(){return"tmui"}onExportObject(A,e,t){const i=sA.getComponent(A,dI);if(i&&i.enabled&&i.renderMode===kj.WorldSpace){const I=new Ay,o=sA.getComponent(A,OI),s=sA.getComponent(A,vB),n=new Array;if(o){if(!sA.isActiveSelf(A)){const C=sA.isActiveSelf(A);sA.setActive(A,!0),o.onEnable(),o.updateTransform(),n.push(()=>{o.onDisable(),sA.setActive(A,C)})}A.traverse(C=>{if(!sA.isActiveInHierarchy(C)){const Q=sA.isActiveSelf(C);sA.setActive(C,!0);const c=sA.getComponent(C,Xs);c&&(c.onEnable(),n.push(()=>{c.onDisable()}));const E=sA.getComponent(C,OI);E&&(E.onEnable(),E.updateTransform(),E.onApplyTransform(),n.push(()=>{E.onDisable()}));const h=sA.getComponent(C,WI);h&&(h.onEnable(),n.push(()=>{h.onDisable()})),n.push(()=>{sA.setActive(C,Q)})}}),o.width,o.height;const r=cI.createEmpty(),a=o.shadowComponent;if(e.add(r),a){const C=a.matrix;r.matrix.copy(C);const Q=new Map,c=new Map;Q.set(a,r),c.set(a,s?s.alpha:1),a.traverse(E=>{if(E===a)return;const h=cI.createEmpty();h.matrix.copy(E.matrix);const l=E.parent,d=!!l&&typeof l.textContent=="string"&&l.textContent.length>0;let p=c.get(l)||1;const u=sA.getComponent(E,vB);if(u&&(p*=u.alpha),E instanceof hA&&d){const w=E[Hs];w?I.exportText(w.gameObject,h,t):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",E)}if(E instanceof hA&&!d){const w=E.geometry.clone();w.scale(1,1,-1),this.flipWindingOrder(w),h.geometry=w;const m=new yA,M=E.material.opacity;m.copy(E.material.color),h.material=new ot({color:m,opacity:M*p,map:E.material.map,transparent:!0})}Q.set(E,h),c.set(E,p);const f=Q.get(l);if(!f){console.error("Error when exporting UI: shadow component parent not found!",E,E.parent);return}f.add(h)})}}for(const r of n)r()}}flipWindingOrder(A){const e=A.index.array;for(let t=0,i=e.length/3;t<i;t++){const I=e[t*3];e[t*3]=e[t*3+2],e[t*3+2]=I}A.index.needsUpdate=!0}}const Cp=gA("debugusdz");function PdA(g,A){var s;const e=[],t=sA.getComponentsInChildren(g,hI),i=sA.getComponentsInChildren(g,_I),I=new Array,o=new Array;if(A.injectImplicitBehaviours)for(const n of t){if(!n||!n.runtimeAnimatorController||!n.enabled)continue;const r=n.runtimeAnimatorController.activeState;if(!r||!r.motion||!r.motion.clip||((s=r.motion.clip.tracks)==null?void 0:s.length)<1||I.includes(n))continue;const a=new Pc;a.animator=n,a.stateName=r.name,a.trigger="start",a.name="PlayAnimationOnClick_implicitAtStart_"+a.stateName;const C=new DA;sA.addComponent(C,a),o.push(C),I.push(n),g.add(C)}else for(const n of t){if(!n||!n.runtimeAnimatorController||!n.enabled)continue;Cp&&console.log(n);const r=[];for(const a of n.runtimeAnimatorController.enumerateActions()){Cp&&console.log(a);const C=a.getClip();r.includes(C)||r.push(C)}e.push({root:n.gameObject,clips:r})}if(A.injectImplicitBehaviours)for(const n of i){if(!n||!n.clip||!n.enabled||!n.playAutomatically||I.includes(n))continue;const r=new Pc;r.animation=n,r.stateName=n.clip.name,r.trigger="start",r.name="PlayAnimationOnClick_implicitAtStart_"+r.stateName;const a=new DA;sA.addComponent(a,r),o.push(a),I.push(n),g.add(a)}else for(const n of i){Cp&&console.log(n);const r=[];for(const a of n.animations)r.includes(a)||r.push(a);e.push({root:n.gameObject,clips:r})}Cp&&(e==null?void 0:e.length)>0&&console.log("USDZ Animation Clips without behaviours",e);for(const n of e)for(const r of n.clips)A.registerAnimation(n.root,r);return o}function WdA(g,A){const e=sA.getComponentsInChildren(g,zi),t=sA.getComponentsInChildren(g,qB),i=new Array,I=new Array;Cp&&console.log({audioSources:e,playAudioOnClicks:t});for(const o of t){if(!o.target)continue;const s=e.indexOf(o.target);s>-1&&e.splice(s,1)}for(const o of e){if(!o||!o.clip||o.volume<=0||i.includes(o))continue;const s=new qB;s.target=o,s.name="PlayAudioOnClick_implicitAtStart_",s.trigger="start";const n=new DA;sA.addComponent(n,s),console.log("implicit PlayAudioOnStart",n,s),I.push(n),i.push(o),g.add(n)}return I}function ZdA(g){return new cg("DisableAtStart",jg.sceneStartTrigger(),ft.fadeAction(g,0,!1))}function O2(g){const A=g.domElement.shadowRoot.querySelector("link[rel='ar']");if(A)return A;const e=document.createElement("div");e.classList.add("menu"),e.classList.add("quicklook-menu"),e.style.display="none",e.style.visibility="hidden";const t=document.createElement("button");t.id="open-in-ar",t.innerText="Open in QuickLook",e.appendChild(t);const i=document.createElement("a");i.id="needle-usdz-link",i.style.display="none",i.rel="ar",i.href="",e.appendChild(i);const I=document.createElement("img");return I.id="button",i.appendChild(I),g.domElement.shadowRoot.appendChild(e),i}var jdA=Object.defineProperty,zdA=Object.getOwnPropertyDescriptor,ZI=(g,A,e,t)=>{for(var i=t>1?void 0:t?zdA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&jdA(A,e,i),i};const ks=gA("debugusdz");class oQ{constructor(){B(this,"callToAction");B(this,"checkoutTitle");B(this,"checkoutSubtitle");B(this,"callToActionURL")}}ZI([D()],oQ.prototype,"callToAction",2);ZI([D()],oQ.prototype,"checkoutTitle",2);ZI([D()],oQ.prototype,"checkoutSubtitle",2);ZI([D()],oQ.prototype,"callToActionURL",2);var OS;const tb=(OS=class extends FA{constructor(){super(...arguments);B(this,"objectToExport");B(this,"autoExportAnimations",!0);B(this,"autoExportAudioSources",!0);B(this,"exportFileName");B(this,"customUsdzFile");B(this,"customBranding");B(this,"anchoringType","plane");B(this,"maxTextureSize",2048);B(this,"planeAnchoringAlignment","horizontal");B(this,"interactive",!0);B(this,"allowCreateQuicklookButton",!0);B(this,"quickLookCompatible",!0);B(this,"extensions",[]);B(this,"link");B(this,"button");B(this,"onClickedOpenInARElement",A=>{A.preventDefault(),this.exportAndOpen()});B(this,"_currentExportTasks",new Map);B(this,"_previousTimeScale",1);B(this,"lastCallback");B(this,"_rootSessionRootWasAppliedTo",null);B(this,"_rootPositionBeforeExport",new y);B(this,"_rootRotationBeforeExport",new GA);B(this,"_rootScaleBeforeExport",new y)}start(){var A,e,t;ks&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",i=>{switch(i.key){case"t":this.exportAsync();break}}),In()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((e=(A=this.objectToExport)==null?void 0:A.children)!=null&&e.length)&&!((t=this.objectToExport)!=null&&t.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new kM),this.extensions.push(new XB),this.extensions.push(new FM),this.extensions.push(new Ay),this.extensions.push(new bM))}onEnable(){var t;const A=Lc(),e=Ch();(ks||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=O2(this.context),this.link.addEventListener("message",this.lastCallback)),ks&&fi("USDZ Exporter enabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var A,e,t;(A=this.button)==null||A.remove(),(e=this.link)==null||e.removeEventListener("message",this.lastCallback),ks&&fi("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 t;let A=this.exportFileName??((t=this.objectToExport)==null?void 0:t.name)??this.name;if(A+="-"+u8(),fB()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=O2(this.context)),this.customUsdzFile)return ks&&console.log("Exporting custom usdz",this.customUsdzFile),this.openInQuickLook(this.customUsdzFile,A),null;if(!this.objectToExport)return console.warn("No object to export",this),null;const e=await this.export(this.objectToExport);return e?(ks&&console.log("USDZ generation done. Downloading as "+A),this.openInQuickLook(e,A),e):(console.error("USDZ generation failed. Please report a bug",this),null)}async export(A){if(!A)return console.warn("No object to export"),null;const e=this._currentExportTasks.get(A);if(e)return e;const t=this.internalExport(A);return t instanceof Promise?(this._currentExportTasks.set(A,t),t.then(i=>(this._currentExportTasks.delete(A),i)).catch(i=>(this._currentExportTasks.delete(A),console.error("Error during USDZ export – please report a bug!",i),null))):t}async internalExport(A){nt.start("export-usdz",{onProgress:p=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:p}}))}}),nt.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),nt.report("export-usdz",{message:"Load progressive textures",autoStep:5}),nt.start("export-usdz-textures","export-usdz");const e=sA.getComponentsInChildren(A,an);for(const p of e)p&&p.enabled&&p.start&&p.start();const t=sA.getComponentsInChildren(A,Vi),i=new Array;let I=0;for(const p of t){for(const u of p.sharedMeshes)if(u){const f=Dt.assignMeshLOD(u,0);f instanceof Promise&&i.push(new Promise((w,m)=>{f.then(()=>{I++,nt.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:I,totalSteps:i.length}),w()}).catch(M=>m(M))}))}for(const u of p.sharedMaterials)if(u){const f=Dt.assignTextureLOD(u,0);f instanceof Promise&&i.push(new Promise((w,m)=>{f.then(()=>{I++,nt.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:I,totalSteps:i.length}),w()}).catch(M=>m(M))}))}}ks&&fi("Progressive Loading: "+i.length),await Promise.all(i),ks&&fi("Progressive Loading: done"),nt.end("export-usdz-textures");const o=BI.Global.Mask;BI.Global.Set(pr.AR);const s=new w8,n=new LD(this.quickLookCompatible),r=[n,...this.extensions],a={self:this,exporter:s,extensions:r,object:A};nt.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:a})),this.applyWebARSessionRoot(),this._previousTimeScale=this.context.time.timeScale,this.context.time.timeScale=0,nt.report("export-usdz","auto export animations and audio sources");const C=new Array;this.autoExportAnimations&&C.push(...PdA(A,n)),this.extensions.find(p=>p.extensionName==="Audio")&&this.autoExportAudioSources&&C.push(...WdA(A)),s.debug=ks,s.keepObject=p=>{const u=sA.getComponent(p,Vi);return!(u&&!u.enabled)};const c=new Array;this.objectToExport&&this.quickLookCompatible&&this.interactive&&this.objectToExport.traverse(p=>{p.visible||c.push(p)});const E=this.extensions.find(p=>p.extensionName==="Behaviour");this.interactive&&E&&c.length>0&&E.addBehavior(ZdA(c));let h=!0;this.quickLookCompatible&&!this.interactive&&(h=!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"),nt.report("export-usdz","Invoking exporter.parse");const l=await s.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:r,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize,exportInvisible:h}),d=new Blob([l],{type:"model/vnd.usdz+zip"});this.revertWebARSessionRoot(),this.context.time.timeScale=this._previousTimeScale,nt.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:a}));for(const p of C)sA.destroy(p);return BI.Global.Set(o),nt.end("export-usdz"),d}openInQuickLook(A,e){const t=A instanceof Blob?URL.createObjectURL(A):A,i=this.buildQuicklookOverlay();ks&&console.log("QuickLook Overlay",i);const I=i.callToAction?encodeURIComponent(i.callToAction):"",o=i.checkoutTitle?encodeURIComponent(i.checkoutTitle):"",s=i.checkoutSubtitle?encodeURIComponent(i.checkoutSubtitle):"";this.link.href=t+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${i.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=e+".usdz",this.link.click()}download(A,e){tb.save(A,e)}static save(A,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),typeof A=="string"?t.href=A:t.href=URL.createObjectURL(A),t.download=e,t.click(),t.remove()}quicklookCallback(A){if((A==null?void 0:A.data)=="_apple_ar_quicklook_button_tapped"){ks&&Ot("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 i=t.get("callToActionURL");ks&&fi("Quicklook url: "+i),i&&(fB()?globalThis.open(i,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",i))}}}}buildQuicklookOverlay(){var t,i,I,o,s,n;const A={};return this.customBranding&&Object.assign(A,this.customBranding),fB()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),A.callToAction="Close",A.checkoutTitle="🌵 Made with Needle",A.checkoutSubtitle="_"),(((t=A.callToAction)==null?void 0:t.length)||((i=A.checkoutTitle)==null?void 0:i.length)||((I=A.checkoutSubtitle)==null?void 0:I.length))&&((o=A.callToAction)!=null&&o.length||(A.callToAction="\0"),(s=A.checkoutTitle)!=null&&s.length||(A.checkoutTitle="\0"),(n=A.checkoutSubtitle)!=null&&n.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 A=sA.getComponentInParent(this.objectToExport,ho);A||(A=sA.getComponentInChildren(this.objectToExport,ho));let e=1,t=!1;const i=this.objectToExport;if(A)e=A.arScale,t=A.invertForward;else{const s=sA.findObjectOfType(Xg);s&&(e=s.arSceneScale)}return{scale:1/e,_invertForward:t,target:i,sessionRoot:(A==null?void 0:A.gameObject)??null}}applyWebARSessionRoot(){if(!this.objectToExport)return;const{scale:A,_invertForward:e,target:t,sessionRoot:i}=this.getARScaleAndTarget(),I=i==null?void 0:i.matrixWorld.clone().invert();this._rootSessionRootWasAppliedTo=t,this._rootPositionBeforeExport.copy(t.position),this._rootRotationBeforeExport.copy(t.quaternion),this._rootScaleBeforeExport.copy(t.scale),t.scale.multiplyScalar(A),e&&t.quaternion.multiply(tb.invertForwardQuaternion),t.updateMatrix(),t.updateMatrixWorld(!0),i&&I&&t.matrix.premultiply(I)}revertWebARSessionRoot(){if(!this.objectToExport||!this._rootSessionRootWasAppliedTo)return;const A=this._rootSessionRootWasAppliedTo;A.position.copy(this._rootPositionBeforeExport),A.quaternion.copy(this._rootRotationBeforeExport),A.scale.copy(this._rootScaleBeforeExport),A.updateMatrix(),A.updateMatrixWorld(!0),this._rootSessionRootWasAppliedTo=null}createQuicklookButton(){const e=$a.getOrCreate().createQuicklookButton();return e.parentNode||this.context.menu.appendChild(e),e}},B(OS,"invertForwardMatrix",new fA().makeRotationY(Math.PI)),B(OS,"invertForwardQuaternion",new GA().setFromEuler(new rt(0,Math.PI,0))),OS);let ji=tb;ZI([D(DA)],ji.prototype,"objectToExport",2);ZI([D()],ji.prototype,"autoExportAnimations",2);ZI([D()],ji.prototype,"autoExportAudioSources",2);ZI([D()],ji.prototype,"exportFileName",2);ZI([D(URL)],ji.prototype,"customUsdzFile",2);ZI([D(oQ)],ji.prototype,"customBranding",2);ZI([D()],ji.prototype,"anchoringType",2);ZI([D()],ji.prototype,"maxTextureSize",2);ZI([D()],ji.prototype,"planeAnchoringAlignment",2);ZI([D()],ji.prototype,"interactive",2);ZI([D()],ji.prototype,"allowCreateQuicklookButton",2);ZI([D()],ji.prototype,"quickLookCompatible",2);class ey extends FA{constructor(){super(...arguments);B(this,"isUsed",!0);B(this,"usedBy",null)}}class bv extends FA{}const P2=gA("debugdeletable");class JM extends Ys{}class Jv extends FA{constructor(){super(...arguments);B(this,"deleteBoxes",[])}awake(){this.deleteBoxes=sA.findObjectsOfType(JM,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const I=sA.getComponentInParent(this.gameObject,ey);I?P2&&console.warn("Can not delete object with usage marker",this.guid,I):(P2&&console.log("DESTROY",this.gameObject),RD(this.gameObject,this.context.connection))}}}}var VdA=Object.defineProperty,XdA=Object.getOwnPropertyDescriptor,uE=(g,A,e,t)=>{for(var i=t>1?void 0:t?XdA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&VdA(A,e,i),i};const $dA=gA("debugpost");class Zn extends yI{constructor(){super(...arguments);B(this,"mode");B(this,"focusDistance",new XA(1));B(this,"focalLength",new XA(.2));B(this,"aperture",new XA(20));B(this,"gaussianMaxRadius",new XA);B(this,"resolutionScale",new XA(1*1/window.devicePixelRatio));B(this,"bokehScale",new XA)}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const i=t/300,I=2;return ge.lerp(I,.01,i)};const e=20;this.aperture.valueProcessor=t=>{const i=1-t/32;return ge.lerp(1,e,i)}}onCreateEffect(){if(this.mode===0){$dA&&console.warn("DepthOfField: Mode is set to Off");return}const e=new X8(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(){}}uE([D()],Zn.prototype,"mode",2);uE([D(XA)],Zn.prototype,"focusDistance",2);uE([D(XA)],Zn.prototype,"focalLength",2);uE([D(XA)],Zn.prototype,"aperture",2);uE([D(XA)],Zn.prototype,"gaussianMaxRadius",2);uE([D(XA)],Zn.prototype,"resolutionScale",2);uE([D(XA)],Zn.prototype,"bokehScale",2);nn("DepthOfField",Zn);var AuA=Object.defineProperty,euA=Object.getOwnPropertyDescriptor,tuA=(g,A,e,t)=>{for(var i=t>1?void 0:t?euA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&AuA(A,e,i),i};class xM extends FA{constructor(){super(...arguments);B(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||sA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:In()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}tuA([D()],xM.prototype,"visibleOn",2);class xv{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var iuA=Object.defineProperty,guA=Object.getOwnPropertyDescriptor,pE=(g,A,e,t)=>{for(var i=t>1?void 0:t?guA(A,e):A,I=g.length-1,o;I>=0;I--)(o=g[I])&&(i=(t?o(A,e,i):o(i))||i);return t&&i&&iuA(A,e,i),i};const Gr=gA("debugdrag");var Tj=(g=>(g[g.XZPlane=0]="XZPlane",g[g.Attached=1]="Attached",g[g.HitNormal=2]="HitNormal",g[g.DynamicViewAngle=3]="DynamicViewAngle",g[g.SnapToSurfaces=4]="SnapToSurfaces",g[g.None=5]="None",g))(Tj||{}),PS;const rr=(PS=class extends FA{constructor(){super(...arguments);B(this,"dragMode",3);B(this,"snapGridResolution",0);B(this,"keepRotation",!0);B(this,"xrDragMode",1);B(this,"xrKeepRotation",!1);B(this,"xrDistanceDragFactor",1);B(this,"showGizmo",!1);B(this,"targetObject",null);B(this,"orbit",null);B(this,"_dragHelper",null);B(this,"_draggingRigidbodies",[]);B(this,"_potentialDragStartEvt",null);B(this,"_dragHandlers",new Map);B(this,"_totalMovement",new y);B(this,"_marker",null);B(this,"_isDragging",!1);B(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(A){this.targetObject=A;for(const e of this._dragHandlers.values())e.setTargetObject(A)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new y,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=sA.findObjectOfType(Mt,this.context),this.gameObject.getComponentInParent(cs)||this.gameObject.addComponent(cs)}allowEdit(A=null){return this.context.connection.allowEditing}onPointerEnter(A){if(!this.allowEdit(this.gameObject)||A.mode!=="screen"||(A.event.mode==="tracked-pointer"||A.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const i=sA.getComponentInParent(A.object,rr);!i||i!==this||(rr.lastHovered=A.object,this.context.domElement.style.cursor="pointer")}onPointerExit(A){this.allowEdit(this.gameObject)&&A.mode==="screen"&&rr.lastHovered===A.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(A){if(!(!this.allowEdit(this.gameObject)||A.used||(A.mode==="tracked-pointer"||A.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(rr.lastHovered=A.object,A.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=A),rr._active+=1;const i=new ouA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(A.event.space,i),this.orbit&&(this.orbit.enabled=!1),i.onDragStart(A),this._dragHandlers.size===2){const I=this._dragHandlers.values(),o=I.next().value,s=I.next().value,n=new IuA(this,this.targetObject||this.gameObject,o,s);this._dragHandlers.set(this.gameObject,n),n.onDragStart(A)}A.use()}}onPointerMove(A){(this._isDragging||this._potentialDragStartEvt!==null)&&A.use()}onPointerUp(A){if(Gr&&fe.DrawLabel(A.point??this.gameObject.worldPosition,"POINTERUP:"+A.pointerId+", "+A.button,.03,3),!this.allowEdit(this.gameObject)||A.button!==0)return;this._potentialDragStartEvt=null;const e=this._dragHandlers.get(A.event.space),t=this._dragHandlers.get(this.gameObject);t&&(t.handlerA===e||t.handlerB===e)&&(this._dragHandlers.delete(this.gameObject),t.onDragEnd(A)),e&&(rr._active>0&&(rr._active-=1),e.onDragEnd&&e.onDragEnd(A),this._dragHandlers.delete(A.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(A),A.use()),rr._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const A of this._dragHandlers.values())A.collectMovementInfo&&A.collectMovementInfo(),A.getTotalMovement&&this._totalMovement.add(A.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const A=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(A)}for(const A of this._dragHandlers.values())A.onDragUpdate&&A.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(A){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new M0(this.context.mainCamera);else return;if(!A||!A.object)return;const e=sA.getComponentInParent(A.object,rr);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 i=sA.getComponentInChildren(t,bB);Gr&&console.log("DRAG START",i,t),i&&(i.fastMode=!0,i==null||i.requestOwnership()),this._marker=sA.addComponent(t,ey),this._draggingRigidbodies.length=0;const I=sA.getComponentsInChildren(t,Pt);I&&this._draggingRigidbodies.push(...I)}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 A=this.targetObject||this.gameObject;Ws.markDirty(A)}onLastDragEnd(A){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(Gr&&console.log("DRAG END",e,e==null?void 0:e.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),A!=null&&A.object){const t=sA.getComponentInChildren(A.object,bB);t&&(t.fastMode=!1)}this._marker&&this._marker.destroy()}},B(PS,"_active",0),B(PS,"lastHovered"),PS);let An=rr;pE([D()],An.prototype,"dragMode",2);pE([D()],An.prototype,"snapGridResolution",2);pE([D()],An.prototype,"keepRotation",2);pE([D()],An.prototype,"xrDragMode",2);pE([D()],An.prototype,"xrKeepRotation",2);pE([D()],An.prototype,"xrDistanceDragFactor",2);pE([D()],An.prototype,"showGizmo",2);class IuA{constructor(A,e,t,i){B(this,"handlerA");B(this,"handlerB");B(this,"context");B(this,"settings");B(this,"gameObject");B(this,"_handlerAAttachmentPoint",new y);B(this,"_handlerBAttachmentPoint",new y);B(this,"_followObject");B(this,"_manipulatorObject");B(this,"_deviceMode");B(this,"_followObjectStartWorldQuaternion",new GA);B(this,"_manipulatorPosOffset",new y);B(this,"_manipulatorRotOffset",new GA);B(this,"_manipulatorScaleOffset",new y);B(this,"_tempVec1",new y);B(this,"_tempVec2",new y);B(this,"_tempVec3",new y);B(this,"tempLookMatrix",new fA);B(this,"_initialScale",new y);B(this,"_initialDistance",0);var o,s;this.context=A.context,this.settings=A,this.gameObject=e,this.handlerA=t,this.handlerB=i,this._followObject=new DA,this._manipulatorObject=new DA,this.context.scene.add(this._manipulatorObject);const I=(s=(o=ye.active)==null?void 0:o.rig)==null?void 0:s.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),I&&(I.worldToLocal(this._tempVec1),I.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(Gr&&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 – 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(e.scale),Gr){this._followObject.add(new Qs(2)),this._manipulatorObject.add(new Qs(5));const n=r=>`${r.x.toFixed(2)}, ${r.y.toFixed(2)}, ${r.z.toFixed(2)}`;fe.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),fe.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6214
6214
|
`+n(this._tempVec1)+`
|
|
6215
|
-
`+n(this._tempVec2),.03,5)}}onDragStart(A){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=A.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(A){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 A=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,A.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const e=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(e/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),Gr&&(fe.DrawLabel(this._tempVec3.clone().add(new y(0,.2,0)),"A:B "+e.toFixed(2),.03),fe.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const A=30,e=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const t=this.gameObject,i=this._followObject;i.updateMatrix(),i.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const C=this._followObject.worldPosition,Q=this.settings.snapGridResolution;C.x=Math.round(C.x/Q)*Q,C.y=Math.round(C.y/Q)*Q,C.z=Math.round(C.z/Q)*Q,this._followObject.worldPosition=C,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const s=ge.clamp01(this.context.time.deltaTime*A*e),n=t.worldPosition;n.lerp(i.worldPosition,s),t.worldPosition=n;const r=t.worldQuaternion;r.slerp(i.worldQuaternion,s),t.worldQuaternion=r;const a=t.worldScale;a.lerp(i.worldScale,s),t.worldScale=a}setTargetObject(A){this.gameObject=A}}class ouA{constructor(A,e){B(this,"context");B(this,"gameObject");B(this,"settings");B(this,"_lastRig");B(this,"_followObject");B(this,"_totalMovement",new y);B(this,"_totalMovementAlongRayDirection",0);B(this,"_grabStartDistance",0);B(this,"_deviceMode");B(this,"_followObjectStartPosition",new y);B(this,"_followObjectStartQuaternion",new GA);B(this,"_followObjectStartWorldQuaternion",new GA);B(this,"_lastDragPosRigSpace");B(this,"_tempVec",new y);B(this,"_tempMat",new fA);B(this,"_hitPointInLocalSpace",new y);B(this,"_hitNormalInLocalSpace",new y);B(this,"_bottomCenter",new y);B(this,"_backCenter",new y);B(this,"_backBottomCenter",new y);B(this,"_bounds",new Nt);B(this,"_dragPlane",new xI(new y(0,1,0)));B(this,"_draggedOverObject",null);B(this,"_draggedOverObjectLastSetUp",null);B(this,"_draggedOverObjectLastNormal",new y);B(this,"_draggedOverObjectDuration",0);this.settings=A,this.context=A.context,this.gameObject=e,this._followObject=new DA}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(A){this.gameObject=A}recenter(){var I,o;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 A=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),A.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 e=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(e),this._grabStartDistance=e.distanceTo(A.worldPosition);const t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject,i=(t==null?void 0:t.worldScale.x)||1;this._grabStartDistance/=i,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,Gr&&(fe.DrawLine(e,A.worldPosition,65280,.5,!1),fe.DrawLabel(A.worldPosition.add(new y(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(A){if(A.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,A.point&&A.normal)this._hitPointInLocalSpace.copy(A.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(A.normal);else if(A){const h=A.event.space,l=h.worldPosition;this.gameObject.worldToLocal(l),this._hitPointInLocalSpace.copy(l);const d=h.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),d.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(d)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const t=this._followObject.parent.worldForward,I=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),I){case 0:const h=new y(0,1,0);this.gameObject.parent&&h.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(h,o);break;case 2:const l=this._hitNormalInLocalSpace.clone();l.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(l,o);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break;case 3:const d=new y(0,1,0),p=t,u=d.angleTo(p),f=.5;u>Math.PI/2+f||u<Math.PI/2-f?this._dragPlane.setFromNormalAndCoplanarPoint(new y(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break}const s=this.gameObject.parent,n=this.gameObject.position.clone(),r=this.gameObject.quaternion.clone(),a=this.gameObject.scale.clone(),C=this.gameObject.matrixWorld.clone();s&&s.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 Q=qr([this.gameObject]);Q.expandByPoint(this.gameObject.worldPosition);const c=new y;Q.getCenter(c);const E=new y;Q.getSize(E),this._bottomCenter.copy(c.clone().add(new y(0,-E.y/2,0))),this._backCenter.copy(c.clone().add(new y(0,0,E.z/2))),this._backBottomCenter.copy(c.clone().add(new y(0,-E.y/2,E.z/2))),this._bounds.copy(Q),s&&s.add(this.gameObject),this.gameObject.position.copy(n),this.gameObject.quaternion.copy(r),this.gameObject.scale.copy(a),this.gameObject.matrixWorld.copy(C),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var I,o;if(!this._followObject.parent)return;const A=this._followObject.parent;this._followObject.updateMatrix();const e=A.worldPosition,t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject;t&&t.worldToLocal(e),(this._lastDragPosRigSpace===void 0||t!=this._lastRig)&&(this._lastDragPosRigSpace=e.clone(),this._lastRig=t),this._tempVec.copy(e).sub(this._lastDragPosRigSpace);const i=A.worldForward;if(t&&(this._tempMat.copy(t.matrixWorld).invert(),i.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=i.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(e),Gr){let s=e;t&&(s=s.clone(),s.transformDirection(t.matrixWorld)),fe.DrawRay(s,i,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,t=this._followObject.parent;this._followObject.updateMatrix();const i=t.worldPosition,I=t.worldForward,o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",s=o?this.settings.xrKeepRotation:this.settings.keepRotation,n=o?this.settings.xrDragMode:this.settings.dragMode;if(n===5)return;const r=10;s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let a=1,C=2;if(o&&this._grabStartDistance>.5){const l=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);a=Math.max(0,l),a=a*a*a}else this._grabStartDistance<=.5&&(C=3);this._followObject.position.copy(this._followObjectStartPosition),s||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(a),this._followObject.updateMatrix();const Q=new xo(i,I);if(n==4){const l=new Yn;l.testObject=p=>p!==this.followObject&&p!==t&&p!==e;const d=this.context.physics.raycastFromRay(Q,l);if(d.length>0){const p=d[0];if(this._draggedOverObject===p.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=p.object,this._draggedOverObjectDuration=0),p.face){const f=this._draggedOverObjectDuration>=.15,w=.001,m=this._totalMovement.length()>=w;if((f||m)&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(p.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(p.face.normal);const M=dt(),G=dt();this._bounds.getCenter(M),this._bounds.getSize(G),M.sub(G.multiplyScalar(.5).multiply(p.face.normal)),this._hitPointInLocalSpace.copy(M),this._hitNormalInLocalSpace.copy(p.face.normal),this._bounds.getCenter(M),this._bounds.getSize(G),M.add(G.multiplyScalar(.5).multiply(p.face.normal));const U=dt(this._hitPointInLocalSpace).add(M);this._followObject.localToWorld(U);const S=p.point;this._dragPlane.setFromNormalAndCoplanarPoint(p.face.normal,S)}else if(!(f||m))return}}}if(n!==1&&Q.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const l=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(l),Gr&&fe.DrawLine(l,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(l),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const l=this._followObject.worldPosition,d=this.settings.snapGridResolution;l.x=Math.round(l.x/d)*d,l.y=Math.round(l.y/d)*d,l.z=Math.round(l.z/d)*d,this._followObject.worldPosition=l,this._followObject.updateMatrix()}s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const c=ge.clamp01(this.context.time.deltaTime*r*C),E=e.worldPosition;E.lerp(this._followObject.worldPosition,c),e.worldPosition=E;const h=e.worldQuaternion;if(h.slerp(this._followObject.worldQuaternion,c),e.worldQuaternion=h,Gr){const l=this._hitPointInLocalSpace.clone();e.localToWorld(l),fe.DrawSphere(l,.02,16711680);const d=this._hitNormalInLocalSpace.clone();d.applyQuaternion(h),fe.DrawRay(l,d,16711680),fe.DrawLabel(E.add(new y(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6215
|
+
`+n(this._tempVec2),.03,5)}}onDragStart(A){this.gameObject.add(this._followObject),this._followObject.matrixAutoUpdate=!1,this._followObject.matrix.identity(),this._deviceMode=A.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(A){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 A=this.context.mainCamera;this.tempLookMatrix.lookAt(this._tempVec3,this._tempVec2,A.worldUp),this._manipulatorObject.quaternion.setFromRotationMatrix(this.tempLookMatrix);const e=this._tempVec1.distanceTo(this._tempVec2);this._manipulatorObject.scale.copy(this._initialScale).multiplyScalar(e/this._initialDistance),this._manipulatorObject.updateMatrix(),this._manipulatorObject.updateMatrixWorld(!0),Gr&&(fe.DrawLabel(this._tempVec3.clone().add(new y(0,.2,0)),"A:B "+e.toFixed(2),.03),fe.DrawLine(this._tempVec1,this._tempVec2,65280,0,!1))}onDragUpdate(){this.alignManipulator();const A=30,e=1;this._followObject.position.copy(this._manipulatorPosOffset),this._followObject.quaternion.copy(this._manipulatorRotOffset),this._followObject.scale.copy(this._manipulatorScaleOffset);const t=this.gameObject,i=this._followObject;i.updateMatrix(),i.updateMatrixWorld(!0);const o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrKeepRotation:this.settings.keepRotation;if(this.settings.snapGridResolution>0){const C=this._followObject.worldPosition,Q=this.settings.snapGridResolution;C.x=Math.round(C.x/Q)*Q,C.y=Math.round(C.y/Q)*Q,C.z=Math.round(C.z/Q)*Q,this._followObject.worldPosition=C,this._followObject.updateMatrix()}o&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const s=ge.clamp01(this.context.time.deltaTime*A*e),n=t.worldPosition;n.lerp(i.worldPosition,s),t.worldPosition=n;const r=t.worldQuaternion;r.slerp(i.worldQuaternion,s),t.worldQuaternion=r;const a=t.worldScale;a.lerp(i.worldScale,s),t.worldScale=a}setTargetObject(A){this.gameObject=A}}class ouA{constructor(A,e){B(this,"context");B(this,"gameObject");B(this,"settings");B(this,"_lastRig");B(this,"_followObject");B(this,"_totalMovement",new y);B(this,"_totalMovementAlongRayDirection",0);B(this,"_grabStartDistance",0);B(this,"_deviceMode");B(this,"_followObjectStartPosition",new y);B(this,"_followObjectStartQuaternion",new GA);B(this,"_followObjectStartWorldQuaternion",new GA);B(this,"_lastDragPosRigSpace");B(this,"_tempVec",new y);B(this,"_tempMat",new fA);B(this,"_hitPointInLocalSpace",new y);B(this,"_hitNormalInLocalSpace",new y);B(this,"_bottomCenter",new y);B(this,"_backCenter",new y);B(this,"_backBottomCenter",new y);B(this,"_bounds",new Nt);B(this,"_dragPlane",new xI(new y(0,1,0)));B(this,"_draggedOverObject",null);B(this,"_draggedOverObjectLastSetUp",null);B(this,"_draggedOverObjectLastNormal",new y);B(this,"_draggedOverObjectDuration",0);this.settings=A,this.context=A.context,this.gameObject=e,this._followObject=new DA}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(A){this.gameObject=A}recenter(){var I,o;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 A=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),A.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 e=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(e),this._grabStartDistance=e.distanceTo(A.worldPosition);const t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject,i=(t==null?void 0:t.worldScale.x)||1;this._grabStartDistance/=i,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,Gr&&(fe.DrawLine(e,A.worldPosition,65280,.5,!1),fe.DrawLabel(A.worldPosition.add(new y(0,.1,0)),this._grabStartDistance.toFixed(2),.03,.5))}onDragStart(A){if(A.event.space.add(this._followObject),this._lastDragPosRigSpace=void 0,A.point&&A.normal)this._hitPointInLocalSpace.copy(A.point),this.gameObject.worldToLocal(this._hitPointInLocalSpace),this._hitNormalInLocalSpace.copy(A.normal);else if(A){const h=A.event.space,l=h.worldPosition;this.gameObject.worldToLocal(l),this._hitPointInLocalSpace.copy(l);const d=h.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),d.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(d)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const t=this._followObject.parent.worldForward,I=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,o=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(o),I){case 0:const h=new y(0,1,0);this.gameObject.parent&&h.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(h,o);break;case 2:const l=this._hitNormalInLocalSpace.clone();l.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(l,o);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break;case 4:case 3:const d=new y(0,1,0),p=t,u=d.angleTo(p),f=.5;u>Math.PI/2+f||u<Math.PI/2-f?this._dragPlane.setFromNormalAndCoplanarPoint(new y(0,1,0),o):this._dragPlane.setFromNormalAndCoplanarPoint(t,o);break}const s=this.gameObject.parent,n=this.gameObject.position.clone(),r=this.gameObject.quaternion.clone(),a=this.gameObject.scale.clone(),C=this.gameObject.matrixWorld.clone();s&&s.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 Q=qr([this.gameObject]);Q.expandByPoint(this.gameObject.worldPosition);const c=new y;Q.getCenter(c);const E=new y;Q.getSize(E),this._bottomCenter.copy(c.clone().add(new y(0,-E.y/2,0))),this._backCenter.copy(c.clone().add(new y(0,0,E.z/2))),this._backBottomCenter.copy(c.clone().add(new y(0,-E.y/2,E.z/2))),this._bounds.copy(Q),s&&s.add(this.gameObject),this.gameObject.position.copy(n),this.gameObject.quaternion.copy(r),this.gameObject.scale.copy(a),this.gameObject.matrixWorld.copy(C),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var I,o;if(!this._followObject.parent)return;const A=this._followObject.parent;this._followObject.updateMatrix();const e=A.worldPosition,t=(o=(I=ye.active)==null?void 0:I.rig)==null?void 0:o.gameObject;t&&t.worldToLocal(e),(this._lastDragPosRigSpace===void 0||t!=this._lastRig)&&(this._lastDragPosRigSpace=e.clone(),this._lastRig=t),this._tempVec.copy(e).sub(this._lastDragPosRigSpace);const i=A.worldForward;if(t&&(this._tempMat.copy(t.matrixWorld).invert(),i.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=i.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(e),Gr){let s=e;t&&(s=s.clone(),s.transformDirection(t.matrixWorld)),fe.DrawRay(s,i,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,t=this._followObject.parent;this._followObject.updateMatrix();const i=t.worldPosition,I=t.worldForward,o=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",s=o?this.settings.xrKeepRotation:this.settings.keepRotation,n=o?this.settings.xrDragMode:this.settings.dragMode;if(n===5)return;const r=10;s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let a=1,C=2;if(o&&this._grabStartDistance>.5){const l=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);a=Math.max(0,l),a=a*a*a}else this._grabStartDistance<=.5&&(C=3);this._followObject.position.copy(this._followObjectStartPosition),s||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(a),this._followObject.updateMatrix();const Q=new xo(i,I);if(n==4){const l=new Yn;l.testObject=p=>p!==this.followObject&&p!==t&&p!==e;const d=this.context.physics.raycastFromRay(Q,l);if(d.length>0){const p=d[0];if(this._draggedOverObject===p.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=p.object,this._draggedOverObjectDuration=0),p.face){const f=this._draggedOverObjectDuration>=.15,w=.001,m=this._totalMovement.length()>=w;if((f||m)&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(p.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(p.face.normal);const M=dt(),G=dt();this._bounds.getCenter(M),this._bounds.getSize(G),M.sub(G.multiplyScalar(.5).multiply(p.face.normal)),this._hitPointInLocalSpace.copy(M),this._hitNormalInLocalSpace.copy(p.face.normal),this._bounds.getCenter(M),this._bounds.getSize(G),M.add(G.multiplyScalar(.5).multiply(p.face.normal));const U=dt(this._hitPointInLocalSpace).add(M);this._followObject.localToWorld(U);const S=p.point;this._dragPlane.setFromNormalAndCoplanarPoint(p.face.normal,S)}else if(!(f||m))return}}}if(n!==1&&Q.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const l=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(l),Gr&&fe.DrawLine(l,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(l),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const l=this._followObject.worldPosition,d=this.settings.snapGridResolution;l.x=Math.round(l.x/d)*d,l.y=Math.round(l.y/d)*d,l.z=Math.round(l.z/d)*d,this._followObject.worldPosition=l,this._followObject.updateMatrix()}s&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const c=ge.clamp01(this.context.time.deltaTime*r*C),E=e.worldPosition;E.lerp(this._followObject.worldPosition,c),e.worldPosition=E;const h=e.worldQuaternion;if(h.slerp(this._followObject.worldQuaternion,c),e.worldQuaternion=h,Gr){const l=this._hitPointInLocalSpace.clone();e.localToWorld(l),fe.DrawSphere(l,.02,16711680);const d=this._hitNormalInLocalSpace.clone();d.applyQuaternion(h),fe.DrawRay(l,d,16711680),fe.DrawLabel(E.add(new y(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6216
6216
|
|
|
6217
6217
|
Along Ray: ${this._totalMovementAlongRayDirection.toFixed(2)}
|
|
6218
6218
|
|