@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 i=ls()||T0()&&se();if((
|
|
|
4344
4344
|
#__vconsole .vc-mask {
|
|
4345
4345
|
overflow: hidden;
|
|
4346
4346
|
}
|
|
4347
|
-
`,ws?.prepend(g),i===!0&&WU()<=0&&gH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(e){const g=globalThis["needle:codegen_files"];if(!g||g.length===0)return;let I=globalThis["needle:codegen_files"][0];const o=I.indexOf("?");o>-1&&(I=I.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+I,n=encodeURIComponent(s);i.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),i.on("show",function(){const e=A();e&&e.src!==i.fullUrl&&(e.src=i.fullUrl)}),i.on("hide",function(){const e=A();e&&(e.src="")}),i.on("addTopBar",function(e){var g=new Array;g.push({name:"Open in new window \u2197",onClick:function(I){window.open(i.fullUrl,"_blank"),Ds?.hide()}}),g.push({name:"Reload",onClick:function(I){const o=A();o&&(o.src=i.fullUrl)}}),g.push({name:"Fullscreen",onClick:function(I){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(g)}),i}function xgA(){return document.querySelector("#__vconsole .vc-switch")||null}function qgA(){return document.querySelector("#__vconsole")||null}const nH=iA("debugdefines");rc('if(!globalThis[""3.45.2-beta.
|
|
4347
|
+
`,ws?.prepend(g),i===!0&&WU()<=0&&gH(),console.log("\u{1F335} Debug console has loaded")}},A.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(A)}function JgA(){const i=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),A=()=>document.querySelector("#__vc_plug_"+i._id+" iframe");return i.on("renderTab",function(e){const g=globalThis["needle:codegen_files"];if(!g||g.length===0)return;let I=globalThis["needle:codegen_files"][0];const o=I.indexOf("?");o>-1&&(I=I.substring(0,o));const s=location.protocol+"//"+location.host+location.pathname+"/"+I,n=encodeURIComponent(s);i.fullUrl="https://viewer.needle.tools?inspect&file="+n;var a='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';e(a)}),i.on("show",function(){const e=A();e&&e.src!==i.fullUrl&&(e.src=i.fullUrl)}),i.on("hide",function(){const e=A();e&&(e.src="")}),i.on("addTopBar",function(e){var g=new Array;g.push({name:"Open in new window \u2197",onClick:function(I){window.open(i.fullUrl,"_blank"),Ds?.hide()}}),g.push({name:"Reload",onClick:function(I){const o=A();o&&(o.src=i.fullUrl)}}),g.push({name:"Fullscreen",onClick:function(I){const o=A();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),e(g)}),i}function xgA(){return document.querySelector("#__vconsole .vc-switch")||null}function qgA(){return document.querySelector("#__vconsole")||null}const nH=iA("debugdefines");rc('if(!globalThis[""3.45.2-beta.4""]) globalThis[""3.45.2-beta.4""] = "0.0.0";'),rc('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),rc('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";'),rc('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.45.2-beta.4";'),rc('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),rc('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)";');const Bn="3.45.2-beta.4",nm="undefined",jN="Fri Jul 19 2024 19:15:04 GMT+0200 (Central European Summer Time)";nH&&console.log(`Engine version: ${Bn} (generator: ${nm})
|
|
4348
4348
|
Project built at ${jN}`);const hr="needle_isActiveInHierarchy",HQ="builtin_components",Uu="needle_editor_guid";function rc(i){try{(0,eval)(i)}catch(A){nH&&console.error(A)}}const LgA='<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>',_gA=btoa(LgA),TgA="data:image/svg+xml;base64,"+_gA,YgA=TgA,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 OgA='<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>',PgA=btoa(OgA),jgA="data:image/svg+xml;charset=utf-8;base64,"+PgA,WgA=jgA,ys=iA("debuglicense");let OQ="basic";ys&&console.log("License Type: "+OQ);function RC(){switch(OQ){case"pro":case"enterprise":return!0}return!1}function WN(){switch(OQ){case"indie":return!0}return!1}function Er(){return RC()||WN()}const aH=[];function ZgA(i){if(RC()||WN())return i(!0);aH.push(i)}function zgA(i){for(const A of aH)try{A(i)}catch{}}Qt.registerCallback(Mt.ContextRegistered,i=>{$gA(i.context),eIA(),XgA(i.context)});let PQ,ZN=!1,am="";async function VgA(){if(PQ)return PQ;if(OQ==="basic")try{const i="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+Bn+"&generator="+encodeURIComponent(nm),A=await fetch(i,{method:"GET"}).catch(e=>{ys&&console.error("License check failed",e)});A?.status===200?(ZN=!1,ys&&console.log("License check succeeded"),OQ="pro",zgA(!0)):A?.status===403?(ZN=!0,am=await A.text()):ys&&console.log("License check failed with status "+A?.status)}catch(i){ys&&console.error("License check failed",i)}else ys&&console.log('Runtime license check is skipped because license is already applied as "'+OQ+'"')}PQ=VgA();async function XgA(i){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 ${C.method} on object ${h.name}`,h,typeof h[C.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 gEA=Object.defineProperty,IEA=Object.getOwnPropertyDescriptor,pb=(i,A,e,g)=>{for(var I=g>1?void 0:g?IEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&gEA(A,e,I),I};class mh extends bA{constructor(){super(...arguments),B(this,"constraintActive",!0),B(this,"locked",!1),B(this,"sources",[])}}pb([y()],mh.prototype,"constraintActive",2),pb([y()],mh.prototype,"locked",2),pb([y(wA)],mh.prototype,"sources",2);function oEA(i,A){return gB(i,Mt.ContextCreated,A),()=>IB(i,Mt.ContextCreated)}function sEA(i,A){return gB(i,Mt.ContextClearing,A),()=>IB(i,Mt.ContextClearing)}function nEA(i,A){return gB(i,Mt.ContextDestroying,A),()=>IB(i,Mt.ContextDestroying)}function o8(i,A){return gB(i,Xt.Start,A),()=>IB(i,Xt.Start)}function s8(i,A){return gB(i,Xt.Update,A),()=>IB(i,Xt.Update)}function aEA(i,A){return gB(i,Xt.OnBeforeRender,A),()=>IB(i,Xt.OnBeforeRender)}function rEA(i,A){return gB(i,Xt.OnAfterRender,A),()=>IB(i,Xt.OnAfterRender)}class Sh{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,g,I){return A.prep(4,12),A.writeFloat32(I),A.writeFloat32(g),A.writeFloat32(e),A.offset()}}class n8{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 Sh).__init(this.bb_pos,this.bb)}rotation(A){return(A||new Sh).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new Sh).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,g,I,o,s,n,a,r,C){return A.prep(4,36),A.prep(4,12),A.writeFloat32(C),A.writeFloat32(r),A.writeFloat32(a),A.prep(4,12),A.writeFloat32(n),A.writeFloat32(s),A.writeFloat32(o),A.prep(4,12),A.writeFloat32(I),A.writeFloat32(g),A.writeFloat32(e),A.offset()}}class nC{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 nC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+FK),(e||new nC).__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 n8).__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 Jg=(i=>(i[i.Average=0]="Average",i[i.Multiply=1]="Multiply",i[i.Minimum=2]="Minimum",i[i.Maximum=3]="Maximum",i))(Jg||{}),Sf=(i=>(i[i.Discrete=0]="Discrete",i[i.Continuous=1]="Continuous",i))(Sf||{}),Vi=(i=>(i[i.None=0]="None",i[i.FreezePositionX=2]="FreezePositionX",i[i.FreezePositionY=4]="FreezePositionY",i[i.FreezePositionZ=8]="FreezePositionZ",i[i.FreezePosition=14]="FreezePosition",i[i.FreezeRotationX=16]="FreezeRotationX",i[i.FreezeRotationY=32]="FreezeRotationY",i[i.FreezeRotationZ=64]="FreezeRotationZ",i[i.FreezeRotation=112]="FreezeRotation",i[i.FreezeAll=126]="FreezeAll",i))(Vi||{}),cl=(i=>(i[i.None=0]="None",i[i.X=2]="X",i[i.Y=4]="Y",i[i.Z=8]="Z",i[i.All=-1]="All",i))(cl||{});const gI=function(i,A){return function(e,g,I){CEA(e,g,I,i,A)}};function CEA(i,A,e,g,I){if(!I&&!g&&!i.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",i,A,e),Ci("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,To.Error);return}let o="";if(typeof A=="string"?o=A:o=A.name,i.__internalAwake){const s=Symbol(o),n=i.__internalAwake;i.__internalAwake=function(){var a;if(!this.onValidate){se()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((a=i.constructor)==null?void 0:a.name)+'"');return}if(this[s]===void 0){this[s]=this[o];const r=this[o];if(r instanceof AA||r instanceof S||r instanceof VA||r instanceof GA){const C=this[o];L0(C,()=>{this.onValidate(o)})}Object.defineProperty(this,o,{set:function(C){var Q;if(this[DK]===!0)this[s]=C;else{g?.call(this,C);const h=this[s];this[s]=C,(Q=this.onValidate)==null||Q.call(this,o,h)}},get:function(){return I?.call(this),this[s]}})}n.call(this)}}}const BEA=function(i){return function(A,e,g){let I="";typeof e=="string"?I=e:I=e.name;const o=i.prototype,s=Object.getOwnPropertyDescriptor(o,I);if(!(s!=null&&s.value)){console.warn("Can not apply prefix: type does not have method named",e,i);return}const n=s.value,a=A[I];Object.defineProperty(o,I,{value:function(...r){const C=a?.call(this,...r);if(C instanceof Promise){C.then(Q=>{if(Q!==!1)return n.call(this,...r)});return}if(C!==!1)return n.call(this,...r)}})}};var QEA=Object.defineProperty,hEA=Object.getOwnPropertyDescriptor,Wo=(i,A,e,g)=>{for(var I=g>1?void 0:g?hEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&QEA(A,e,I),I};class EEA{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 eC(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((o,s)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const a=this.position[s];Math.abs(a-o)<1e-5||(this.position[s]=o,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new eC(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((o,s)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const a=this.quaternion[s];Math.abs(a-o)<1e-5||(this.quaternion[s]=o,this.rotationChanged=!0)}));const g=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),I=new DA;this.obj.matrixWorld.multiplyMatrices=(o,s)=>{var n;return(n=this.context.physics.engine)!=null&&n.isUpdating||this.mute||I.equals(o)||(this.positionChanged=!0,this.rotationChanged=!0,I.copy(o)),g(o,s)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var Db;const wb=(Db=class extends bA{constructor(){super(...arguments),B(this,"autoMass",!0),B(this,"_mass",0),B(this,"useGravity",!0),B(this,"centerOfMass",new S(0,0,0)),B(this,"constraints",Vi.None),B(this,"isKinematic",!1),B(this,"drag",0),B(this,"angularDrag",1),B(this,"detectCollisions",!0),B(this,"sleepThreshold",.01),B(this,"collisionDetectionMode",Sf.Discrete),B(this,"_gravityScale",1),B(this,"dominanceGroup",0),B(this,"_propertiesChanged",!1),B(this,"_currentVelocity",new S),B(this,"_smoothedVelocity",new S),B(this,"_smoothedVelocityGetter",new S),B(this,"_lastPosition",new S),B(this,"_watch")}set mass(i){i!==this._mass&&(this._mass=i,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var i,A;return this.autoMass?((A=(i=this.context.physics.engine)==null?void 0:i.getBody(this))==null?void 0:A.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&Vi.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&Vi.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&Vi.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&Vi.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&Vi.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&Vi.FreezeRotationZ)!==0}set lockPositionX(i){i?this.constraints|=Vi.FreezePositionX:this.constraints&=~Vi.FreezePositionX}set lockPositionY(i){i?this.constraints|=Vi.FreezePositionY:this.constraints&=~Vi.FreezePositionY}set lockPositionZ(i){i?this.constraints|=Vi.FreezePositionZ:this.constraints&=~Vi.FreezePositionZ}set lockRotationX(i){i?this.constraints|=Vi.FreezeRotationX:this.constraints&=~Vi.FreezeRotationX}set lockRotationY(i){i?this.constraints|=Vi.FreezeRotationY:this.constraints&=~Vi.FreezeRotationY}set lockRotationZ(i){i?this.constraints|=Vi.FreezeRotationZ:this.constraints&=~Vi.FreezeRotationZ}set gravityScale(i){this._gravityScale=i}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new EEA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),Xt.LateUpdate)}onDisable(){var i,A;(i=this._watch)==null||i.stop(),(A=this.context.physics.engine)==null||A.removeBody(this)}onDestroy(){var i;(i=this.context.physics.engine)==null||i.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){for(var i,A,e,g;;)this._propertiesChanged&&(this._propertiesChanged=!1,(i=this.context.physics.engine)==null||i.updateProperties(this)),(A=this._watch)!=null&&A.isDirty?(this._watch.mute=!0,this._watch.applyValues(),(e=this.context.physics.engine)==null||e.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):(g=this._watch)==null||g.syncValues(),this.captureVelocity(),yield}teleport(i,A=!0){var e;(e=this._watch)==null||e.reset(!0),A?this.gameObject.position.set(i.x,i.y,i.z):this.setWorldPosition(i.x,i.y,i.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(i=!0){var A;(A=this.context.physics.engine)==null||A.resetForces(this,i)}resetTorques(i=!0){var A;(A=this.context.physics.engine)==null||A.resetTorques(this,i)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var i;(i=this.context.physics.engine)==null||i.wakeup(this)}get isSleeping(){var i;return(i=this.context.physics.engine)==null?void 0:i.isSleeping(this)}updateProperties(){var i;return this._propertiesChanged=!1,(i=this.context.physics.engine)==null?void 0:i.updateProperties(this)}applyForce(i,A,e=!0){var g;this._propertiesChanged&&this.updateProperties(),(g=this.context.physics.engine)==null||g.addForce(this,i,e)}applyImpulse(i,A=!0){var e;this._propertiesChanged&&this.updateProperties(),(e=this.context.physics.engine)==null||e.applyImpulse(this,i,A)}setForce(i,A,e,g=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,g),typeof i=="number"?(A??(A=0),e??(e=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:i,y:A,z:e},g)):(s=this.context.physics.engine)==null||s.addForce(this,i,g)}getVelocity(){var i;const A=(i=this.context.physics.engine)==null?void 0:i.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(i,A,e,g=!0){var I,o;if(i instanceof S){const s=i;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,g);return}A===void 0||e===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:i,y:A,z:e},g)}getAngularVelocity(){var i;const A=(i=this.context.physics.engine)==null?void 0:i.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(i,A,e,g=!0){var I,o;if(i instanceof S){const s=i;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,g);return}A===void 0||e===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:i,y:A,z:e},g)}setTorque(i,A,e){this.setAngularVelocity(i,A,e)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(i=null){}captureVelocity(){const i=Fe(this.gameObject);wb.tempPosition.copy(i);const A=i.sub(this._lastPosition);this._lastPosition.copy(wb.tempPosition),this._smoothedVelocity.lerp(A,this.context.time.deltaTime/.1)}},B(Db,"tempPosition",new S),Db);let _t=wb;Wo([gI()],_t.prototype,"autoMass",2),Wo([y()],_t.prototype,"mass",1),Wo([gI(),y()],_t.prototype,"useGravity",2),Wo([y(S)],_t.prototype,"centerOfMass",2),Wo([gI(),y()],_t.prototype,"constraints",2),Wo([gI(),y()],_t.prototype,"isKinematic",2),Wo([gI(),y()],_t.prototype,"drag",2),Wo([gI(),y()],_t.prototype,"angularDrag",2),Wo([gI(),y()],_t.prototype,"detectCollisions",2),Wo([gI(),y()],_t.prototype,"sleepThreshold",2),Wo([gI(),y()],_t.prototype,"collisionDetectionMode",2),Wo([gI()],_t.prototype,"_gravityScale",2),Wo([gI()],_t.prototype,"dominanceGroup",2);const EB=iA("debugsync"),$p="STRS";bK($p,nC.getRootAsSyncedTransformModel);const Qa=new jw;function a8(i,A,e=!0){Qa.clear();const g=Qa.createString(i);nC.startSyncedTransformModel(Qa),nC.addGuid(Qa,g),nC.addFast(Qa,e);const I=A.worldPosition,o=A.worldEuler,s=A.gameObject.scale;nC.addTransform(Qa,n8.createTransform(Qa,I.x,I.y,I.z,o.x,o.y,o.z,s.x,s.y,s.z));const n=nC.endSyncedTransformModel(Qa);return Qa.finish(n,$p),Qa.asUint8Array()}let yb=0,AD=0;s8(i=>{var A;const e=(A=i.connection.currentServerUrl)!=null&&A.includes("glitch")?10:40;AD=Math.floor(yb/e),yb=0,EB&&AD>0&&console.log("Sync Transform Fast Interval",AD)});class cB extends bA{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 It),B(this,"receivedUpdate",!1),B(this,"lastWorldPos"),B(this,"lastWorldRotation")}requestOwnership(){EB&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}hasOwnership(){var A;return((A=this._model)==null?void 0:A.hasOwnership)??void 0}isOwned(){var A;return(A=this._model)==null?void 0:A.isOwned}awake(){EB&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new S,this._targetRotation=new GA,this.lastWorldPos=new S,this.lastWorldRotation=new GA,this.rb=gA.getComponentInChildren(this.gameObject,_t),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new Ab(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(Pe.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary($p,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&Bb(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(Pe.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary($p,this.receivedDataCallback)}tryGetLastState(){const A=this.context.connection.tryGetState(this.guid);A&&this.onReceivedData(A)}onReceivedData(A){var e;if(!this.destroyed&&typeof A.guid=="function"&&A.guid()===this.guid){EB&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,A),this.receivedUpdate=!0,this._receivedFastUpdate=A.fast();const g=A.transform();if(g){en.markDirty(this.gameObject,!0);const I=g.position();I&&(this.interpolatePosition&&((e=this._targetPosition)==null||e.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=g.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&qN(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){EB&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const A=this.worldPosition,e=this.worldQuaternion;if(this._model.isOwned&&!this.receivedUpdate){const o=A.distanceTo(this.lastWorldPos),s=e.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(EB&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastWorldPos),this.worldPosition=this.lastWorldPos,A.copy(this.lastWorldPos),this.worldQuaternion=this.lastWorldRotation,e.copy(this.lastWorldRotation),en.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const o=this._receivedFastUpdate||this.fastMode?.5:.3;let s=!1;if(this.interpolatePosition&&this._targetPosition){const n=this.worldPosition;n.lerp(this._targetPosition,o),this.worldPosition=n,s=!0}if(this.interpolateRotation&&this._targetRotation){const n=this.worldQuaternion;n.slerp(this._targetRotation,o),this.worldQuaternion=n,s=!0}s&&en.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastWorldPos.copy(A),this.lastWorldRotation.copy(e),!this._model||!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership)return;this.rb&&this.overridePhysics&&this._wasKinematic!==void 0&&(EB&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const g=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%g===0||I)){if(yb++,I&&AD>0&&this.context.time.frameCount%AD!==0)return;EB&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const o=a8(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const cEA=iA("debugshadowcomponents");fN.prototype.interactable={get(){return this.interactive},set(i){this.interactable=i}};const Js=Symbol("shadowDomOwner");class $s extends bA{constructor(){super(...arguments),B(this,"_shadowComponent",null),B(this,"_controlsChildLayout",!0),B(this,"_root"),B(this,"_parentComponent")}isRoot(){var A;return((A=this.Root)==null?void 0:A.gameObject)===this.gameObject}get canvas(){const A=this.Root;return A!=null&&A.isCanvas?A:null}get Canvas(){return this.canvas}markDirty(){xs.markUIDirty(this.context)}get shadowComponent(){return this._shadowComponent}set shadowComponent(A){this._shadowComponent=A}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(A){this._controlsChildLayout=A,this.shadowComponent&&(this.shadowComponent.autoLayout=A)}get Root(){return this._root===void 0&&(this._root=gA.getComponentInParent(this.gameObject,eD)),this._root}__internalNewInstanceCreated(A){return super.__internalNewInstanceCreated(A),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0,this}onEnable(){super.onEnable()}addShadowComponent(A,e){var g;if(!A)return;this.removeShadowComponent();const I=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=gA.getComponentInParent(I,$s),!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}A.name=this.name+" ("+(this.constructor.name??"UI")+")",A.autoLayout=this._parentComponent.controlsChildLayout,A[Js]=this,this.setShadowComponentOwner(A);let o=!1;if(((g=this.Root)==null?void 0:g.gameObject)===this.gameObject)this.gameObject.add(A);else{const s=this._parentComponent.shadowComponent;s&&(s?.add(A),o=!0)}this.shadowComponent=A,e&&e.shadowComponent&&this.shadowComponent&&e.shadowComponent.add(this.shadowComponent),fp&&A.add(new _o(.5)),this.onAfterAddedToScene(),o&&LY(),cEA&&console.warn("Added shadow component",this.shadowComponent)}setShadowComponentOwner(A){if(A&&(A[Js]===void 0||A[Js]===this)&&(A[Js]=this,A.children))for(const e of A.children)this.setShadowComponentOwner(e)}traverseOwnedShadowComponents(A,e,g){if(A&&A[Js]===e){g(A);for(const I of A.children)this.traverseOwnedShadowComponents(I,e,g)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(A){this.shadowComponent&&(this.shadowComponent.interactable=A)}}class eD extends $s{awake(){super.awake()}}class wd{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 wd(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function mb(i,A){return gA.foreachComponent(i,e=>{if(!e.enabled)return;const g=e;if(A)switch(A){case"pointerdown":if(g.onPointerDown)return!0;break;case"pointerup":if(g.onPointerUp||g.onPointerClick)return!0;break;case"pointermove":if(g.onPointerEnter||g.onPointerExit||g.onPointerMove)return!0;break}else if(g.onPointerDown||g.onPointerUp||g.onPointerEnter||g.onPointerExit||g.onPointerClick)return!0},!1)===!0}var lEA=Object.defineProperty,dEA=Object.getOwnPropertyDescriptor,uEA=(i,A,e,g)=>{for(var I=g>1?void 0:g?dEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&lEA(A,e,I),I};class tD extends bA{awake(){xs.createIfNoneExists(this.context)}onEnable(){var A;(A=xs.get(this.context))==null||A.register(this)}onDisable(){var A;(A=xs.get(this.context))==null||A.unregister(this)}}class Zo extends tD{constructor(){super(...arguments),B(this,"targets",null),B(this,"raycastHits",[]),B(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(A=null){if(!this.targets)return null;A??(A=new fn),A.targets=this.targets,A.results=this.raycastHits;const e=A.testObject;this.ignoreSkinnedMeshes&&(A.testObject=I=>I instanceof wo?"continue in children":e?e(I):!0);const g=this.context.physics.raycast(A);return A.testObject=e,g}}uEA([y()],Zo.prototype,"ignoreSkinnedMeshes",2);class ff extends Zo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class iD extends tD{performRaycast(A){if(!me.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,g=.01;return this.context.physics.sphereOverlap(e,g)}}class kf{static getObject(A){const e=A[Js];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 g=this.tryFindCanvasGroup(A);if(g?.isCanvasGroup===!0&&(e&&(e.canvasGroup=g),g.blocksRaycasts===!1||g.interactable===!1))return!1;const I=dh(A,o=>{if(o.isGraphic===!0)return o},!1);return e&&I?.isGraphic===!0&&(e.graphic=I),!(I?.raycastTarget===!1||I?.layer===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=dh(A,g=>{const I=g;if(I.blocksRaycasts!==void 0&&I.interactable!==void 0)return I},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function Sb(i){return i[Js]||(i.parent?Sb(i.parent):null)}function pEA(i){return i.isUI===!0||typeof i[Js]=="object"}function Mf(i,A){if(!i)return;const e=i.material;if(e?.isMaterial===!0){const g=i.parent;g&&g.isText,e.side=A.doubleSided??!0?yt:Eg,e.shadowSide=A.doubleSided?yt:Eg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const g of i.children)Mf(g,A)}function ll(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const g=Proxy.revocable(i[A],{set(s,n,a,r){const C=s[n],Q=Reflect.set(s,n,a,r);return e(a,C),Q}}),I=g.revoke,o=i[A];return g.revoke=()=>{i[A]=o,I()},i[A]=g.proxy,g}const r8=Symbol("Scheduled action");function DEA(i,A,e=Xt.OnBeforeRender){let g=i[r8];g||(g=i[r8]={});const I=A.name;g[e]||(g[e]={});const o=g[e];if(o[I])return;function*s(){A?.call(i),o[I]=null}const n=i.startCoroutine(s(),e);o[I]=n}const vr=iA("debugeventsystem");var fb=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(fb||{});const Kr=class extends bA{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",i=>{var A;let e=null;if(pEA(i)&&(e=(A=i[Js])==null?void 0:A.gameObject),this._testObjectsCache.has(i)||e&&this._testObjectsCache.has(e))return this._testObjectsCache.get(i)===!1?"continue in children":!0;{let g=mb(i,this._currentPointerEventName);if(!g&&e&&(g=mb(e,this._currentPointerEventName)),g){this._testObjectsCache.set(i,!0);for(const I of i.children)this.shouldRaycastObject_AddToYesCache(I);return!0}return this._testObjectsCache.set(i,!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",[]),Kr.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Kr.systems.length<=0&&Kr.systems.push(...gA.findObjectsOfType(Kr,i)));for(const e of Kr.systems)if(e.context===i)return;const A=new wA;gA.addNewComponent(A,Kr),i.scene.add(A)}static get systems(){const i=Ke.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const A=this._eventSystemMap.get(i);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,A,e=!1){lB.update(i,A,e)}static markUIDirty(i){lB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Kr.systems.splice(Kr.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!gA.findObjectOfType(tD,this.context)){const i=gA.addNewComponent(this.context.scene,Zo);this.raycaster.push(i),(se()||vr)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(i){var A;i&&this.raycaster&&!this.raycaster.includes(i)&&((A=this.raycaster)==null||A.push(i))}unregister(i){var A,e;const g=(A=this.raycaster)==null?void 0:A.indexOf(i);g!==void 0&&g!==-1&&((e=this.raycaster)==null||e.splice(g,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(hi.PointerDown,this._handleInputFn),this.context.input.addEventListener(hi.PointerUp,this._handleInputFn),this.context.input.addEventListener(hi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(hi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(hi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(hi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(i){if(i===void 0||i.propagationStopped)return;const A=new wd(this.context.input,i);this._currentPointerEventName=i.type,A.inputSource=this.context.input,A.isClick=i.isClick,A.isDoubleClick=i.isDoubleClick,A.isDown=i.type==hi.PointerDown,A.isUp=i.type==hi.PointerUp,A.isPressed=this.context.input.getPointerPressed(i.pointerId),vr&&(A.isDown?console.log("DOWN",A.pointerId):A.isUp&&console.log("UP",A.pointerId),A.isClick&&console.log("CLICK",A.pointerId));const e=new fn;i.hasRay?e.ray=i.ray:e.screenPoint=this.context.input.getPointerPositionRC(i.pointerId);const g=this.performRaycast(e);if(g){for(const o of g)o.event=i,i.intersections.push(o);i.origin.onPointerHits&&i.origin.onPointerHits({sender:this,event:i,hits:g})}vr&&A.isClick&&Ci("EventSystem: "+A.pointerId+" - "+this.context.time.frame+" - Up:"+A.isUp+", Down:"+A.isDown);const I={sender:this,args:A,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:I})),this.handleIntersections(g,A),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:I}))}shouldRaycastObject_AddToYesCache(i){this._testObjectsCache.set(i,!0);for(const A of i.children)this.shouldRaycastObject_AddToYesCache(A)}performRaycast(i){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,i||(i=new fn),i.testObject=this.shouldRaycastObject;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;this._currentlyActiveRaycaster=A;const e=A.performRaycast(i);this._currentlyActiveRaycaster=null,e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}assignHitInformation(i,A){A?(i.intersection=A,i.point=A.point,i.normal=A.normal,i.face=A.face,i.distance=A.distance,i.instanceId=A.instanceId):(i.intersection=void 0,i.point=void 0,i.normal=void 0,i.face=void 0,i.distance=void 0,i.instanceId=void 0)}handleIntersections(i,A){var e;if(i!=null&&i.length){i=this.sortCandidates(i);for(const I of i){if(A.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(A,I),this.handleEventOnObject(I.object,A))return!0}}this.assignHitInformation(A,i?.[0]),this.invokePointerCapture(A);const g=this.hoveredByID.get(A.pointerId);return g&&this.propagatePointerExit(g.obj,g.data,null),this.hoveredByID.delete(A.pointerId),A.isUp&&((e=this.pressedByID.get(A.pointerId))==null||e.handlers.forEach(I=>this.invokeOnPointerUp(A,I)),this.pressedByID.delete(A.pointerId)),!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<i.length;A++){const e=i[A],g=e.object;if(g.material&&g.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEventOnObject(i,A){if(!this.testIsVisible(i))return A.isClick&&vr&&console.log("not allowed",i),!1;if(A.pointerId===void 0)return vr&&console.error("Event without pointer can't be handled",A),!1;A.object=i;const e=i.parent,g=A.isClick??!1;let I=null;if(e&&e.isUI){const a=(A.isPressed||A.isClick)??!1;if(e[Js]){const r=e[Js].gameObject;if(r){if(!kf.isInteractable(r,this.out))return!1;I=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=r}}}g&&vr&&console.log(this.context.time.frame,i);const o=this.hoveredByID.get(A.pointerId),s=o?.obj;s!==i&&s&&this.propagatePointerExit(s,o.data,i);const n=this.hoveredByID.get(A.pointerId);if(n?(n.obj=i,n.data=A):this.hoveredByID.set(A.pointerId,{obj:i,data:A}),A.isDown){const a=this.pressedByID.get(A.pointerId);a?(a.obj=i,a.data=A):this.pressedByID.set(A.pointerId,{obj:i,data:A,handlers:new Set})}return(I===null||I.interactable)&&this.handleMainInteraction(i,A,s??null),!0}propagate(i,A){for(;i;)gA.foreachComponent(i,e=>{A(e)},!1),i=i.parent}handleMainInteraction(i,A,e){const g=this.pressedByID.get(A.pointerId),I=e!==i;let o=!0;switch(A.event.pointerType){case"mouse":case"touch":const s=this.context.input.getPointerPositionLastFrame(A.pointerId),n=this.context.input.getPointerPosition(A.pointerId);o=s&&!ge.approximately(s,n);break}this.propagate(i,s=>{var n;const a=s;a.interactable!==!1&&(!a.activeAndEnabled||!a.enabled||(a.onPointerEnter&&I&&this.handlePointerEnter(a,A),A.isDown&&a.onPointerDown&&(a.onPointerDown(A),g?.handlers.add(a),this.handlePointerCapture(A,a)),a.onPointerMove&&(o&&a.onPointerMove(A),this.handlePointerCapture(A,a)),A.isUp&&(a.onPointerUp&&(this.invokeOnPointerUp(A,a),g?.handlers.delete(a)),a.onPointerExit&&((n=A.event)==null?void 0:n.pointerType)===bS.Touch&&(this.handlePointerExit(a,A),this.hoveredByID.delete(A.pointerId))),A.isClick&&a.onPointerClick&&a.onPointerClick(A)))}),A.isUp&&(g?.handlers.forEach(s=>{this.invokeOnPointerUp(A,s)}),this.pressedByID.delete(A.pointerId))}propagatePointerExit(i,A,e){this.propagate(i,g=>{if(!g.gameObject||g.destroyed)return;const I=g;if(I.onPointerExit){if(e&&this.isChild(e,g.gameObject))return;this.handlePointerExit(I,A)}})}invokeOnPointerUp(i,A){var e;(e=A.onPointerUp)==null||e.call(A,i),this.releasePointerCapture(i,A)}handlePointerEnter(i,A){i.onPointerEnter&&this.updatePointerState(i,A.pointerId,this.pointerEnterSymbol,!0)&&i.onPointerEnter(A),this.updatePointerState(i,A.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(i,A){i.onPointerExit&&this.updatePointerState(i,A.pointerId,this.pointerExitSymbol,!0)&&i.onPointerExit(A),this.updatePointerState(i,A.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(i,A,e,g){let I=i[e];if(g)return I&&I.includes(A)?!1:(I=I||[],I.push(A),i[e]=I,!0);{if(!I||!I.includes(A))return!1;const o=I.indexOf(A);return o!==-1&&I.splice(o,1),!0}}handlePointerCapture(i,A){if(i.z__pointer_ctured){i.z__pointer_ctured=!1;const e=i.pointerId;if(A.onPointerMove){const g=this._capturedPointer[e]||[];g.push(A),this._capturedPointer[e]=g}else se()&&!A.z__warned_no_pointermove&&(A.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 i.z__pointer_cture_rleased&&(i.z__pointer_cture_rleased=!1,this.releasePointerCapture(i,A))}releasePointerCapture(i,A){const e=i.pointerId;if(this._capturedPointer[e]){const g=this._capturedPointer[e].indexOf(A);g!==-1&&(this._capturedPointer[e].splice(g,1),vr&&console.log("released pointer capture",e,A,this._capturedPointer))}}invokePointerCapture(i){var A;if(i.event.type===hi.PointerMove){const e=i.pointerId,g=this._capturedPointer[e];if(g){vr&&console.log("Captured",e,g);for(let I=0;I<g.length;I++){const o=g[I];if(o.destroyed){g.splice(I,1),I--;continue}(A=o.onPointerMove)==null||A.call(o,i)}}}}isChild(i,A){return!i||!A?!1:i===A?!0:i.parent?this.isChild(i.parent,A):!1}handleMeshUiObjectWithoutShadowDom(i,A){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,A)}handleMeshUIIntersection(i,A){const e=lB.updateState(i,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&lB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const A=this.currentActiveMeshUIComponents[i];lB.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?gA.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let xs=Kr;B(xs,"_eventSystemMap",new Map),B(xs,"didSearchEventSystem",!1);class lB{static markDirty(){this.needsUpdate=!0}static update(A,e,g=!1){if(g){A.update();return}const I=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(I===o.frame)return;o.frame=I;let s=this.needsUpdate||I<1;o.nextUpdate===e.time.frameCount&&(s=!0),s&&(vr&&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 g=null;if(A&&(g=this.findBlockInParent(A),g&&g!==this.lastSelected)){if(g.interactable===!1)return null;this.needsUpdate=!0}return g}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(lB,"lastSelected",null),B(lB,"lastUpdateFrame",[]),B(lB,"needsUpdate",!1);var wEA=Object.defineProperty,yEA=Object.getOwnPropertyDescriptor,Ei=(i,A,e,g)=>{for(var I=g>1?void 0:g?yEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&wEA(A,e,I),I};const kb=iA("debugorbit"),Gf=iA("freecam"),Rf=iA("debugcamerafit"),Uf=iA("smoothcam"),mEA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let Mb;class gD extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class St extends bA{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 S),B(this,"_lookTargetEndPosition",new S),B(this,"_lookTargetLerp01",0),B(this,"_lookTargetLerpDuration",0),B(this,"_cameraLerpActive",!1),B(this,"_cameraStartPosition",new S),B(this,"_cameraEndPosition",new S),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",A=>{if(this.clickBackgroundToFitScene>0&&A.isClick&&A.button===0){if(A.hasRay||A.intersections.push(...this.context.physics.raycast()),A.intersections.length<=0){const e=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||e<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}kb&&console.log(this.clickBackgroundToFitScene,A.intersections.length,this._clickOnBackgroundCount)}}),B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),B(this,"_shouldDisable",!1),B(this,"__onPreRender",()=>{const A=this.context.pre_render_callbacks.indexOf(this.__onPreRender);A>=0&&this.context.pre_render_callbacks.splice(A,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(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=xs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(fb.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(fb.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const A=gA.getComponent(this.gameObject,Tt);this._camera=A;let e=A?.cam;if(!e&&this.gameObject instanceof xe&&(e=this.gameObject),e&&RN(e,this,!0),!this._controls&&e instanceof xe){this._cameraObject=e;const g=this.targetElement??this.context.renderer.domElement,I=e?.quaternion.clone();this._controls=new g8(e,g),e?.quaternion.copy(I),Mb===void 0&&(Mb={...this._controls.keys})}this._controls&&(Gf&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,ls()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?Gf||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Gf||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=gA.getComponent(this.gameObject,cB)??void 0,this.context.input.addEventListener("pointerup",this._onPointerDown),this.context.pre_render_callbacks.push(this.__onPreRender)}onDisable(){var A;(A=this._camera)!=null&&A.cam&&RN(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(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;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)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.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=gA.getComponent(this.gameObject,Tt);if(I&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const o=Fe(I.cam),s=Math.max(.01,o.length()),n=new S(0,0,-s).applyMatrix4(I.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.setLookTargetFromConstraint()){const o=new fn;o.screenPoint=new AA(0,0),o.lineThreshold=.1;const s=this.context.physics.raycast(o);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Rf&&console.log("OrbitControls hits",...s)}}let g=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(g||(g=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),g&&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 gD(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 gD(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?Mb:mEA,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 Uf=="number"||Uf===!0){this._controls.enableDamping=!0;const I=typeof Uf=="number"?Uf:.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||(!Gf&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),kb&&pe.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(A){if(!A||!(A instanceof wA))return;const e=Fe(A),g=JN(A);this.setTargetFromRaycast(new po(e,g)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var g,I;A&&(A instanceof wA&&(A=Fe(A)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof wA&&(A=Fe(A)),this._lookTargetEndPosition.copy(A),kb&&(console.warn("OrbitControls: setLookTargetPosition",A,e),pe.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var g;if(!this._controls)return!1;const I=(g=this.lookAtConstraint)==null?void 0:g.sources;if(I&&I.length>0){const o=I[A];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){if(!this.controls)return;const e=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const g of e)if(g.distance>0&&gA.isActiveInHierarchy(g.object)){const I=Sb(g.object);if(I){const o=I.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(g.point);break}}fitCamera(A,e={fitOffset:void 0,immediate:!1}){if(this.context.isInXR)return;const{immediate:g=!1,centerCamera:I}=e;let{fitOffset:o}=e;o==null&&(o=1.1);const s=this._cameraObject,n=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.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 a=new S,r=new S,C=$n(A,void 0);s.updateMatrixWorld(),s.updateProjectionMatrix(),C.getCenter(r);const Q=new S;if(C.getSize(Q),C.applyMatrix4(s.matrixWorldInverse),C.getSize(a),C.setFromCenterAndSize(r,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",s,C,[...A]);return}if(a.length()<=1e-10){Rf&&console.warn("Camera fit size is zero",C,[...A]);return}const h=s.fov,E=2*Math.atan(Math.tan(h*Math.PI/360/2)*s.aspect)/Math.PI*360,c=a.y/(2*Math.atan(Math.PI*h/360)),l=a.x/(2*Math.atan(Math.PI*E/360)),d=o*Math.max(c,l)+a.z/2;Rf&&console.log("Fit camera to objects",c,l,"distance",d),n.maxDistance=d*10,n.minDistance=d*.01;const u=.05,D=r.clone();D.y-=a.y*u,this.setLookTargetPosition(D,g),this.autoTarget=!1;const p=gA.findObjectOfType(hB),w=p?p.radius:0,f=Math.max(Q.x,Q.y,Q.z,w);s.near=d/100,s.far=f+d*10,s.updateMatrixWorld(),s.updateProjectionMatrix();const G=Fe(s),M=r.clone();if(M.sub(G),I==="y"&&(M.y=0),M.normalize(),M.multiplyScalar(d),I==="y"&&(M.y+=-u*4*a.y),s.parent){const U=s.parent.worldToLocal(r.clone().sub(M));this.setCameraTargetPosition(U,g)}else console.error(`Can not fit camera ${s.name} because it has no parent`);if(Rf){const U=new bU(C);this.context.scene.add(U),LN(U,fu(s)),setTimeout(()=>{this.context.scene.remove(U)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",v=>{v.code==="KeyF"&&this.fitCamera(A,{fitOffset:o,immediate:g})}))}n.update()}}Ei([y()],St.prototype,"autoTarget",2),Ei([y()],St.prototype,"autoFit",2),Ei([y()],St.prototype,"enableRotate",2),Ei([y()],St.prototype,"autoRotate",2),Ei([y()],St.prototype,"autoRotateSpeed",2),Ei([y()],St.prototype,"minAzimuthAngle",2),Ei([y()],St.prototype,"maxAzimuthAngle",2),Ei([y()],St.prototype,"minPolarAngle",2),Ei([y()],St.prototype,"maxPolarAngle",2),Ei([y()],St.prototype,"enableKeys",2),Ei([y()],St.prototype,"enableDamping",2),Ei([y()],St.prototype,"dampingFactor",2),Ei([y()],St.prototype,"enableZoom",2),Ei([y()],St.prototype,"minZoom",2),Ei([y()],St.prototype,"maxZoom",2),Ei([y()],St.prototype,"zoomSpeed",2),Ei([y()],St.prototype,"enablePan",2),Ei([y(mh)],St.prototype,"lookAtConstraint",2),Ei([y()],St.prototype,"lookAtConstraint01",2),Ei([y()],St.prototype,"allowInterrupt",2),Ei([y()],St.prototype,"middleClickToFocus",2),Ei([y()],St.prototype,"doubleClickToFocus",2),Ei([y()],St.prototype,"clickBackgroundToFitScene",2),Ei([y()],St.prototype,"targetLerpDuration",2);var SEA=Object.defineProperty,fEA=Object.getOwnPropertyDescriptor,no=(i,A,e,g)=>{for(var I=g>1?void 0:g?fEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&SEA(A,e,I),I},dB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(dB||{});const br=iA("debugcam"),C8=iA("debugscreenpointtoray");var Nf;const ID=(Nf=class extends bA{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 DA)}get isCamera(){return!0}get aspect(){return this._cam instanceof xe?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(i){this._cam instanceof xe&&this._cam.aspect!==i&&(this._cam.aspect=i,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof xe?this._cam.fov:this._fov}set fieldOfView(i){const A=this.fieldOfView!=i;if(this._fov=i,A&&this._cam&&this._cam instanceof xe){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(i){const A=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&A&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const A=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&A&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(i){i!==this._backgroundRotation&&(i===void 0?this._backgroundRotation=void 0:this._backgroundRotation=i,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,A,e){const g=this.cam,I=ID._origin;I.set(i,A,-1),this.context.input.convertScreenspaceToRaycastSpace(I),C8&&console.log("screenPointToRay",i.toFixed(2),A.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=ID._direction.set(I.x,I.y,I.z),s=Fe(g);return o.sub(s),o.normalize(),e?(e.set(s,o),e):new po(s.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new cQ,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new cQ),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(i,A){return A&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),i===this._projScreenMatrix?i:i.copy(this._projScreenMatrix)}awake(){C8&&window.addEventListener("pointerdown",i=>{const A=i.clientX,e=i.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const g=this.screenPointToRay(A,e),I="#"+Math.floor(Math.random()*16777215).toString(16);pe.DrawRay(g.origin,g.direction,I,10)})}onEnable(){br&&console.log(`Camera enabled: "${this.name}". ClearFlags=${dB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),MEA(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 i=this.context.renderer;if(i){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let A=null;if(i?(A=this.gameObject,A?.layers.enableAll(),A instanceof xe&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof xe&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new xe(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new jn(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(i){this.context.mainCameraComponent===this&&this.applyClearFlags(i)}applyClearFlags(i){if(!this._cam){br&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,br){const A=`Camera "${this.name}" clear flags: ${dB[this._clearFlags]}`;console.debug(A)}switch(this._clearFlags){case 1:if(ID.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||i?.applySkybox===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:br&&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:br&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;ID.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else br&&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 kEA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(i){var A,e,g,I;const o=(A=i.renderer.xr)==null?void 0:A.getSession();if(!o)return!1;if(typeof o._transparent=="boolean")return o._transparent;const s=o.environmentBlendMode;br&&Ci("Environment blend mode: "+s+" on "+navigator.userAgent);let n=s==="additive"||s==="alpha-blend";return i.isInAR&&s==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(g=navigator.userAgent)!=null&&g.includes("Mozilla")&&(I=navigator.userAgent)!=null&&I.includes("Mobile WebXRViewer/v2"))&&(n=!0),o._transparent=n,n}},B(Nf,"_origin",new S),B(Nf,"_direction",new S),Nf);let Tt=ID;no([y()],Tt.prototype,"aspect",1),no([y()],Tt.prototype,"fieldOfView",1),no([y()],Tt.prototype,"nearClipPlane",1),no([y()],Tt.prototype,"farClipPlane",1),no([y()],Tt.prototype,"clearFlags",1),no([y()],Tt.prototype,"orthographic",2),no([y()],Tt.prototype,"orthographicSize",2),no([y()],Tt.prototype,"ARBackgroundAlpha",2),no([y()],Tt.prototype,"cullingMask",1),no([y()],Tt.prototype,"backgroundBlurriness",1),no([y()],Tt.prototype,"backgroundIntensity",1),no([y(It)],Tt.prototype,"backgroundRotation",1),no([y()],Tt.prototype,"environmentIntensity",1),no([y(Rt)],Tt.prototype,"backgroundColor",1),no([y(El)],Tt.prototype,"targetTexture",1);class kEA{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&&(br&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Eo,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)),(br||se())&&Lt(`Camera "${this._camera.name}" has no skybox texture`))}}function MEA(i){iA("freecam")&&i.context.mainCameraComponent===i&&gA.getOrAddComponent(i.gameObject,St)}class uB extends bA{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 g2),this._listener}onEnable(){aB.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){aB.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const A=this._listener;if(!A||A!=null&&A.parent)return;const e=this.context.mainCameraComponent||gA.getComponentInParent(this.gameObject,Tt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A),A.filter?(A.gain.connect(A.filter),A.filter.connect(A.context.destination)):A.gain.connect(A.context.destination)}removeListenerIfItExists(){const A=this._listener;A&&(A.removeFromParent(),A.filter&&A.filter.disconnect(),A.gain&&A.gain.disconnect())}}class GEA extends Fi{constructor(A,e=1,g=16,I=2){const o=new ue,s=g+I*2,n=new Float32Array((s*3+3)*3);o.setAttribute("position",new Ie(n,3));const a=new Zt({color:65280}),r=new Zt({color:16776960});super(o,[r,a]),this.audio=A,this.range=e,this.divisionsInnerAngle=g,this.divisionsOuterAngle=I,this.type="PositionalAudioHelper",this.update()}update(){const A=this.audio,e=this.range,g=this.divisionsInnerAngle,I=this.divisionsOuterAngle,o=ct.degToRad(A.panner.coneInnerAngle),s=ct.degToRad(A.panner.coneOuterAngle),n=o/2,a=s/2;let r=0,C=0,Q,h;const E=this.geometry,c=E.attributes.position;E.clearGroups();function l(d,u,D,p){const w=(u-d)/D;for(c.setXYZ(r,0,0,0),C++,Q=d;Q<u;Q+=w)h=r+C,c.setXYZ(h,Math.sin(Q)*e,0,Math.cos(Q)*e),c.setXYZ(h+1,Math.sin(Math.min(Q+w,u))*e,0,Math.cos(Math.min(Q+w,u))*e),c.setXYZ(h+2,0,0,0),C+=3;E.addGroup(r,C,p),r+=C,C=0}l(-a,-n,I,0),l(-n,n,g,1),l(n,a,I,0),c.needsUpdate=!0,o===s&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var REA=Object.defineProperty,UEA=Object.getOwnPropertyDescriptor,ha=(i,A,e,g)=>{for(var I=g>1?void 0:g?UEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&REA(A,e,I),I};const xI=iA("debugaudio"),pB=class extends bA{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||ls())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":xI&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,pB.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&pB.userInteractionRegistered&&this.wasPlaying&&this.play();break}}),B(this,"onApplicationMuteChanged",()=>{var i,A;this.context.application.muted?(i=this.sound)==null||i.setVolume(0):(A=this.sound)==null||A.setVolume(this.volume)}),B(this,"createAudio",i=>{xI&&console.log("AudioBuffer finished loading",i);const A=this.Sound;if(!A){xI&&console.warn("Failed getting sound?",this.name);return}A.isPlaying&&A.stop(),i&&A.setBuffer(i),A.loop=this._loop,this.context.application.muted?A.setVolume(0):A.setVolume(this.volume),A.autoplay=this.shouldPlay&&pB.userInteractionRegistered,this.applySpatialDistanceSettings(),A.isPlaying&&A.stop(),pB.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 aB.userInteractionRegistered}static registerWaitForAllowAudio(i){aB.registerWaitForAllowAudio(i)}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(i){this._loop=i,this.sound&&this.sound.setLoop(i)}get spatialBlend(){return this._spatialBlend}set spatialBlend(i){i!==this._spatialBlend&&(this._spatialBlend=i,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(i){this._minDistance!==i&&(this._minDistance=i,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(i){this._maxDistance!==i&&(this._maxDistance=i,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(i){this._volume=i,this.sound&&!this.context.application.muted&&(xI&&console.log(this.name,"audio set volume",i),this.sound.setVolume(i))}get Sound(){var i;if(!this.sound&&pB.userInteractionRegistered){let A=gA.getComponent(this.context.mainCamera,uB)??gA.findObjectOfType(uB,this.context);!A&&this.context.mainCamera&&(A=gA.addNewComponent(this.context.mainCamera,uB)),A!=null&&A.listener?(this.sound=new o2(A.listener),(i=this.gameObject)==null||i.add(this.sound)):xI&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var i;return(i=this.sound)==null?void 0:i.context}awake(){xI&&console.log(this),this.audioLoader=new k0,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),pB.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():pB.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(VS.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(VS.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const i=this.sound;if(!i)return;this._needUpdateSpatialDistanceSettings=!1;const A=ge.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(xI&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+A),i.setRefDistance(A),i.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:i.setDistanceModel("exponential");break;case 1:i.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?xI&&!this.helper&&(this.helper=new GEA(i,i.getRefDistance()),i.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(i){if(i&&(this.clip=i),typeof i=="string")if(xI&&console.log(i),i.endsWith(".mp3")||i.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new k0),this.shouldPlay=!0,this._lastClipStartedLoading===i){xI&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=i,xI&&console.log("load audio",i);const A=await this.audioLoader.loadAsync(i).catch(console.error);this._lastClipStartedLoading=null,A&&this.createAudio(A)}else console.warn("Unsupported audio clip type",i);else this.shouldPlay=!0,this.createAudio()}play(i=void 0){var A,e,g;!i&&this.clip&&(i=this.clip),i!==void 0&&typeof i!="string"&&!(i instanceof MediaStream)&&(se()&&console.warn("Called play on AudioSource with unknown argument type:",i+`
|
|
5732
|
+
`;var gEA=Object.defineProperty,IEA=Object.getOwnPropertyDescriptor,pb=(i,A,e,g)=>{for(var I=g>1?void 0:g?IEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&gEA(A,e,I),I};class mh extends bA{constructor(){super(...arguments),B(this,"constraintActive",!0),B(this,"locked",!1),B(this,"sources",[])}}pb([y()],mh.prototype,"constraintActive",2),pb([y()],mh.prototype,"locked",2),pb([y(wA)],mh.prototype,"sources",2);function oEA(i,A){return gB(i,Mt.ContextCreated,A),()=>IB(i,Mt.ContextCreated)}function sEA(i,A){return gB(i,Mt.ContextClearing,A),()=>IB(i,Mt.ContextClearing)}function nEA(i,A){return gB(i,Mt.ContextDestroying,A),()=>IB(i,Mt.ContextDestroying)}function o8(i,A){return gB(i,Xt.Start,A),()=>IB(i,Xt.Start)}function s8(i,A){return gB(i,Xt.Update,A),()=>IB(i,Xt.Update)}function aEA(i,A){return gB(i,Xt.OnBeforeRender,A),()=>IB(i,Xt.OnBeforeRender)}function rEA(i,A){return gB(i,Xt.OnAfterRender,A),()=>IB(i,Xt.OnAfterRender)}class Sh{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,g,I){return A.prep(4,12),A.writeFloat32(I),A.writeFloat32(g),A.writeFloat32(e),A.offset()}}class n8{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 Sh).__init(this.bb_pos,this.bb)}rotation(A){return(A||new Sh).__init(this.bb_pos+12,this.bb)}scale(A){return(A||new Sh).__init(this.bb_pos+24,this.bb)}static sizeOf(){return 36}static createTransform(A,e,g,I,o,s,n,a,r,C){return A.prep(4,36),A.prep(4,12),A.writeFloat32(C),A.writeFloat32(r),A.writeFloat32(a),A.prep(4,12),A.writeFloat32(n),A.writeFloat32(s),A.writeFloat32(o),A.prep(4,12),A.writeFloat32(I),A.writeFloat32(g),A.writeFloat32(e),A.offset()}}class nC{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 nC).__init(A.readInt32(A.position())+A.position(),A)}static getSizePrefixedRootAsSyncedTransformModel(A,e){return A.setPosition(A.position()+FK),(e||new nC).__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 n8).__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 Jg=(i=>(i[i.Average=0]="Average",i[i.Multiply=1]="Multiply",i[i.Minimum=2]="Minimum",i[i.Maximum=3]="Maximum",i))(Jg||{}),Sf=(i=>(i[i.Discrete=0]="Discrete",i[i.Continuous=1]="Continuous",i))(Sf||{}),Vi=(i=>(i[i.None=0]="None",i[i.FreezePositionX=2]="FreezePositionX",i[i.FreezePositionY=4]="FreezePositionY",i[i.FreezePositionZ=8]="FreezePositionZ",i[i.FreezePosition=14]="FreezePosition",i[i.FreezeRotationX=16]="FreezeRotationX",i[i.FreezeRotationY=32]="FreezeRotationY",i[i.FreezeRotationZ=64]="FreezeRotationZ",i[i.FreezeRotation=112]="FreezeRotation",i[i.FreezeAll=126]="FreezeAll",i))(Vi||{}),cl=(i=>(i[i.None=0]="None",i[i.X=2]="X",i[i.Y=4]="Y",i[i.Z=8]="Z",i[i.All=-1]="All",i))(cl||{});const gI=function(i,A){return function(e,g,I){CEA(e,g,I,i,A)}};function CEA(i,A,e,g,I){if(!I&&!g&&!i.onValidate)return;if(e!==void 0){console.error("Invalid usage of validate decorator. Only fields can be validated.",i,A,e),Ci("Invalid usage of validate decorator. Only fields can be validated. Property: "+A,To.Error);return}let o="";if(typeof A=="string"?o=A:o=A.name,i.__internalAwake){const s=Symbol(o),n=i.__internalAwake;i.__internalAwake=function(){var a;if(!this.onValidate){se()&&console.warn('Usage of @validate decorate detected but there is no onValidate method in your class: "'+((a=i.constructor)==null?void 0:a.name)+'"');return}if(this[s]===void 0){this[s]=this[o];const r=this[o];if(r instanceof AA||r instanceof S||r instanceof VA||r instanceof GA){const C=this[o];L0(C,()=>{this.onValidate(o)})}Object.defineProperty(this,o,{set:function(C){var Q;if(this[DK]===!0)this[s]=C;else{g?.call(this,C);const h=this[s];this[s]=C,(Q=this.onValidate)==null||Q.call(this,o,h)}},get:function(){return I?.call(this),this[s]}})}n.call(this)}}}const BEA=function(i){return function(A,e,g){let I="";typeof e=="string"?I=e:I=e.name;const o=i.prototype,s=Object.getOwnPropertyDescriptor(o,I);if(!(s!=null&&s.value)){console.warn("Can not apply prefix: type does not have method named",e,i);return}const n=s.value,a=A[I];Object.defineProperty(o,I,{value:function(...r){const C=a?.call(this,...r);if(C instanceof Promise){C.then(Q=>{if(Q!==!1)return n.call(this,...r)});return}if(C!==!1)return n.call(this,...r)}})}};var QEA=Object.defineProperty,hEA=Object.getOwnPropertyDescriptor,Wo=(i,A,e,g)=>{for(var I=g>1?void 0:g?hEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&QEA(A,e,I),I};class EEA{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 eC(this.obj.position,["x","y","z"])),this._positionWatch.apply(),this.position={},this._positionWatch.subscribeWrite((o,s)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const a=this.position[s];Math.abs(a-o)<1e-5||(this.position[s]=o,this.positionChanged=!0)})),e&&(this._rotationWatch||(this._rotationWatch=new eC(this.obj.quaternion,["_x","_y","_z","_w"])),this._rotationWatch.apply(),this.quaternion={},this._rotationWatch.subscribeWrite((o,s)=>{var n;if((n=this.context.physics.engine)!=null&&n.isUpdating||this.mute)return;const a=this.quaternion[s];Math.abs(a-o)<1e-5||(this.quaternion[s]=o,this.rotationChanged=!0)}));const g=this.obj.matrixWorld.multiplyMatrices.bind(this.obj.matrixWorld),I=new DA;this.obj.matrixWorld.multiplyMatrices=(o,s)=>{var n;return(n=this.context.physics.engine)!=null&&n.isUpdating||this.mute||I.equals(o)||(this.positionChanged=!0,this.rotationChanged=!0,I.copy(o)),g(o,s)}}stop(){var A,e;(A=this._positionWatch)==null||A.revoke(),(e=this._rotationWatch)==null||e.revoke()}}var Db;const wb=(Db=class extends bA{constructor(){super(...arguments),B(this,"autoMass",!0),B(this,"_mass",0),B(this,"useGravity",!0),B(this,"centerOfMass",new S(0,0,0)),B(this,"constraints",Vi.None),B(this,"isKinematic",!1),B(this,"drag",0),B(this,"angularDrag",1),B(this,"detectCollisions",!0),B(this,"sleepThreshold",.01),B(this,"collisionDetectionMode",Sf.Discrete),B(this,"_gravityScale",1),B(this,"dominanceGroup",0),B(this,"_propertiesChanged",!1),B(this,"_currentVelocity",new S),B(this,"_smoothedVelocity",new S),B(this,"_smoothedVelocityGetter",new S),B(this,"_lastPosition",new S),B(this,"_watch")}set mass(i){i!==this._mass&&(this._mass=i,this._propertiesChanged=!0,this.__didAwake&&(this.autoMass=!1))}get mass(){var i,A;return this.autoMass?((A=(i=this.context.physics.engine)==null?void 0:i.getBody(this))==null?void 0:A.mass())??-1:this._mass}get lockPositionX(){return(this.constraints&Vi.FreezePositionX)!==0}get lockPositionY(){return(this.constraints&Vi.FreezePositionY)!==0}get lockPositionZ(){return(this.constraints&Vi.FreezePositionZ)!==0}get lockRotationX(){return(this.constraints&Vi.FreezeRotationX)!==0}get lockRotationY(){return(this.constraints&Vi.FreezeRotationY)!==0}get lockRotationZ(){return(this.constraints&Vi.FreezeRotationZ)!==0}set lockPositionX(i){i?this.constraints|=Vi.FreezePositionX:this.constraints&=~Vi.FreezePositionX}set lockPositionY(i){i?this.constraints|=Vi.FreezePositionY:this.constraints&=~Vi.FreezePositionY}set lockPositionZ(i){i?this.constraints|=Vi.FreezePositionZ:this.constraints&=~Vi.FreezePositionZ}set lockRotationX(i){i?this.constraints|=Vi.FreezeRotationX:this.constraints&=~Vi.FreezeRotationX}set lockRotationY(i){i?this.constraints|=Vi.FreezeRotationY:this.constraints&=~Vi.FreezeRotationY}set lockRotationZ(i){i?this.constraints|=Vi.FreezeRotationZ:this.constraints&=~Vi.FreezeRotationZ}set gravityScale(i){this._gravityScale=i}get gravityScale(){return this._gravityScale}awake(){this._watch=void 0,this._propertiesChanged=!1}onEnable(){this._watch||(this._watch=new EEA(this.gameObject,this.context)),this._watch.start(!0,!0),this.startCoroutine(this.beforePhysics(),Xt.LateUpdate)}onDisable(){var i,A;(i=this._watch)==null||i.stop(),(A=this.context.physics.engine)==null||A.removeBody(this)}onDestroy(){var i;(i=this.context.physics.engine)==null||i.removeBody(this)}onValidate(){this._propertiesChanged=!0}*beforePhysics(){for(var i,A,e,g;;)this._propertiesChanged&&(this._propertiesChanged=!1,(i=this.context.physics.engine)==null||i.updateProperties(this)),(A=this._watch)!=null&&A.isDirty?(this._watch.mute=!0,this._watch.applyValues(),(e=this.context.physics.engine)==null||e.updateBody(this,this._watch.positionChanged,this._watch.rotationChanged),this._watch.reset()):(g=this._watch)==null||g.syncValues(),this.captureVelocity(),yield}teleport(i,A=!0){var e;(e=this._watch)==null||e.reset(!0),A?this.gameObject.position.set(i.x,i.y,i.z):this.setWorldPosition(i.x,i.y,i.z),this.resetForcesAndTorques(),this.resetVelocities()}resetForces(i=!0){var A;(A=this.context.physics.engine)==null||A.resetForces(this,i)}resetTorques(i=!0){var A;(A=this.context.physics.engine)==null||A.resetTorques(this,i)}resetVelocities(){this.setVelocity(0,0,0),this.setAngularVelocity(0,0,0)}resetForcesAndTorques(){this.resetForces(),this.resetTorques()}wakeUp(){var i;(i=this.context.physics.engine)==null||i.wakeup(this)}get isSleeping(){var i;return(i=this.context.physics.engine)==null?void 0:i.isSleeping(this)}updateProperties(){var i;return this._propertiesChanged=!1,(i=this.context.physics.engine)==null?void 0:i.updateProperties(this)}applyForce(i,A,e=!0){var g;this._propertiesChanged&&this.updateProperties(),(g=this.context.physics.engine)==null||g.addForce(this,i,e)}applyImpulse(i,A=!0){var e;this._propertiesChanged&&this.updateProperties(),(e=this.context.physics.engine)==null||e.applyImpulse(this,i,A)}setForce(i,A,e,g=!0){var I,o,s;(I=this.context.physics.engine)==null||I.resetForces(this,g),typeof i=="number"?(A??(A=0),e??(e=0),(o=this.context.physics.engine)==null||o.addForce(this,{x:i,y:A,z:e},g)):(s=this.context.physics.engine)==null||s.addForce(this,i,g)}getVelocity(){var i;const A=(i=this.context.physics.engine)==null?void 0:i.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(i,A,e,g=!0){var I,o;if(i instanceof S){const s=i;(I=this.context.physics.engine)==null||I.setLinearVelocity(this,s,g);return}A===void 0||e===void 0||(o=this.context.physics.engine)==null||o.setLinearVelocity(this,{x:i,y:A,z:e},g)}getAngularVelocity(){var i;const A=(i=this.context.physics.engine)==null?void 0:i.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(i,A,e,g=!0){var I,o;if(i instanceof S){const s=i;(I=this.context.physics.engine)==null||I.setAngularVelocity(this,s,g);return}A===void 0||e===void 0||(o=this.context.physics.engine)==null||o.setAngularVelocity(this,{x:i,y:A,z:e},g)}setTorque(i,A,e){this.setAngularVelocity(i,A,e)}get smoothedVelocity(){return this._smoothedVelocityGetter.copy(this._smoothedVelocity),this._smoothedVelocityGetter.multiplyScalar(1/this.context.time.deltaTime)}setBodyFromGameObject(i=null){}captureVelocity(){const i=Fe(this.gameObject);wb.tempPosition.copy(i);const A=i.sub(this._lastPosition);this._lastPosition.copy(wb.tempPosition),this._smoothedVelocity.lerp(A,this.context.time.deltaTime/.1)}},B(Db,"tempPosition",new S),Db);let _t=wb;Wo([gI()],_t.prototype,"autoMass",2),Wo([y()],_t.prototype,"mass",1),Wo([gI(),y()],_t.prototype,"useGravity",2),Wo([y(S)],_t.prototype,"centerOfMass",2),Wo([gI(),y()],_t.prototype,"constraints",2),Wo([gI(),y()],_t.prototype,"isKinematic",2),Wo([gI(),y()],_t.prototype,"drag",2),Wo([gI(),y()],_t.prototype,"angularDrag",2),Wo([gI(),y()],_t.prototype,"detectCollisions",2),Wo([gI(),y()],_t.prototype,"sleepThreshold",2),Wo([gI(),y()],_t.prototype,"collisionDetectionMode",2),Wo([gI()],_t.prototype,"_gravityScale",2),Wo([gI()],_t.prototype,"dominanceGroup",2);const EB=iA("debugsync"),$p="STRS";bK($p,nC.getRootAsSyncedTransformModel);const Qa=new jw;function a8(i,A,e=!0){Qa.clear();const g=Qa.createString(i);nC.startSyncedTransformModel(Qa),nC.addGuid(Qa,g),nC.addFast(Qa,e);const I=A.worldPosition,o=A.worldEuler,s=A.gameObject.scale;nC.addTransform(Qa,n8.createTransform(Qa,I.x,I.y,I.z,o.x,o.y,o.z,s.x,s.y,s.z));const n=nC.endSyncedTransformModel(Qa);return Qa.finish(n,$p),Qa.asUint8Array()}let yb=0,AD=0;s8(i=>{var A;const e=(A=i.connection.currentServerUrl)!=null&&A.includes("glitch")?10:40;AD=Math.floor(yb/e),yb=0,EB&&AD>0&&console.log("Sync Transform Fast Interval",AD)});class cB extends bA{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 It),B(this,"receivedUpdate",!1),B(this,"lastWorldPos"),B(this,"lastWorldRotation")}requestOwnership(){EB&&console.log("Request ownership"),this._model?this._model.requestOwnership():(this._shouldRequestOwnership=!0,this._needsUpdate=!0)}hasOwnership(){var A;return((A=this._model)==null?void 0:A.hasOwnership)??void 0}isOwned(){var A;return(A=this._model)==null?void 0:A.isOwned}awake(){EB&&console.log("new instance",this.guid,this),this._receivedDataBefore=!1,this._targetPosition=new S,this._targetRotation=new GA,this.lastWorldPos=new S,this.lastWorldRotation=new GA,this.rb=gA.getComponentInChildren(this.gameObject,_t),this.rb&&(this._wasKinematic=this.rb.isKinematic),this.receivedUpdate=!0,this._model=new Ab(this.context.connection,this.guid),this.context.connection.isConnected&&this.tryGetLastState(),this.joinedRoomCallback=this.tryGetLastState.bind(this),this.context.connection.beginListen(Pe.JoinedRoom,this.joinedRoomCallback),this.receivedDataCallback=this.onReceivedData.bind(this),this.context.connection.beginListenBinary($p,this.receivedDataCallback)}onDestroy(){this.syncDestroy&&Bb(this.guid,this.context.connection),this._model=null,this.context.connection.stopListen(Pe.JoinedRoom,this.joinedRoomCallback),this.context.connection.stopListenBinary($p,this.receivedDataCallback)}tryGetLastState(){const A=this.context.connection.tryGetState(this.guid);A&&this.onReceivedData(A)}onReceivedData(A){var e;if(!this.destroyed&&typeof A.guid=="function"&&A.guid()===this.guid){EB&&console.log("new data",this.context.connection.connectionId,this.context.time.frameCount,this.guid,A),this.receivedUpdate=!0,this._receivedFastUpdate=A.fast();const g=A.transform();if(g){en.markDirty(this.gameObject,!0);const I=g.position();I&&(this.interpolatePosition&&((e=this._targetPosition)==null||e.set(I.x(),I.y(),I.z())),(!this.interpolatePosition||!this._receivedDataBefore)&&this.setWorldPosition(I.x(),I.y(),I.z()));const o=g.rotation();o&&(this.tempEuler.set(o.x(),o.y(),o.z()),this.interpolateRotation&&this._targetRotation.setFromEuler(this.tempEuler),(!this.interpolateRotation||!this._receivedDataBefore)&&qN(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){EB&&console.log("no model or room",this.name,this.guid,this.context.connection.isInRoom);return}this._shouldRequestOwnership&&(this._shouldRequestOwnership=!1,this._model.requestOwnership());const A=this.worldPosition,e=this.worldQuaternion;if(this._model.isOwned&&!this.receivedUpdate){const o=A.distanceTo(this.lastWorldPos),s=e.angleTo(this.lastWorldRotation),n=this._model.hasOwnership||this.fastMode?1e-4:.001;(o>n||s>n)&&(this._model.hasOwnership?this._needsUpdate=!0:(EB&&console.log(this.guid,"reset because not owned but",this.gameObject.name,this.lastWorldPos),this.worldPosition=this.lastWorldPos,A.copy(this.lastWorldPos),this.worldQuaternion=this.lastWorldRotation,e.copy(this.lastWorldRotation),en.markDirty(this.gameObject,!0),this._needsUpdate=!1))}if(this._model&&!this._model.hasOwnership&&this._model.isOwned&&this._receivedDataBefore){const o=this._receivedFastUpdate||this.fastMode?.5:.3;let s=!1;if(this.interpolatePosition&&this._targetPosition){const n=this.worldPosition;n.lerp(this._targetPosition,o),this.worldPosition=n,s=!0}if(this.interpolateRotation&&this._targetRotation){const n=this.worldQuaternion;n.slerp(this._targetRotation,o),this.worldQuaternion=n,s=!0}s&&en.markDirty(this.gameObject,!0)}if(this.receivedUpdate=!1,this.lastWorldPos.copy(A),this.lastWorldRotation.copy(e),!this._model||!this._model||this._model.hasOwnership===void 0||!this._model.hasOwnership)return;this.rb&&this.overridePhysics&&this._wasKinematic!==void 0&&(EB&&console.log("reset kinematic",this.rb.name,this._wasKinematic),this.rb.isKinematic=this._wasKinematic);const g=10,I=this.rb||this.fastMode;if(this._needsUpdate&&(this.context.time.frameCount%g===0||I)){if(yb++,I&&AD>0&&this.context.time.frameCount%AD!==0)return;EB&&console.log("send update",this.context.connection.connectionId,this.guid,this.gameObject.name,this.gameObject.guid),this._needsUpdate=!1;const o=a8(this.guid,this,!!I);this.context.connection.sendBinary(o)}}}const cEA=iA("debugshadowcomponents");fN.prototype.interactable={get(){return this.interactive},set(i){this.interactable=i}};const Js=Symbol("shadowDomOwner");class $s extends bA{constructor(){super(...arguments),B(this,"_shadowComponent",null),B(this,"_controlsChildLayout",!0),B(this,"_root"),B(this,"_parentComponent")}isRoot(){var A;return((A=this.Root)==null?void 0:A.gameObject)===this.gameObject}get canvas(){const A=this.Root;return A!=null&&A.isCanvas?A:null}get Canvas(){return this.canvas}markDirty(){xs.markUIDirty(this.context)}get shadowComponent(){return this._shadowComponent}set shadowComponent(A){this._shadowComponent=A}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(A){this._controlsChildLayout=A,this.shadowComponent&&(this.shadowComponent.autoLayout=A)}get Root(){return this._root===void 0&&(this._root=gA.getComponentInParent(this.gameObject,eD)),this._root}__internalNewInstanceCreated(A){return super.__internalNewInstanceCreated(A),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0,this}onEnable(){super.onEnable()}addShadowComponent(A,e){var g;if(!A)return;this.removeShadowComponent();const I=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=gA.getComponentInParent(I,$s),!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}A.name=this.name+" ("+(this.constructor.name??"UI")+")",A.autoLayout=this._parentComponent.controlsChildLayout,A[Js]=this,this.setShadowComponentOwner(A);let o=!1;if(((g=this.Root)==null?void 0:g.gameObject)===this.gameObject)this.gameObject.add(A);else{const s=this._parentComponent.shadowComponent;s&&(s?.add(A),o=!0)}this.shadowComponent=A,e&&e.shadowComponent&&this.shadowComponent&&e.shadowComponent.add(this.shadowComponent),fp&&A.add(new _o(.5)),this.onAfterAddedToScene(),o&&LY(),cEA&&console.warn("Added shadow component",this.shadowComponent)}setShadowComponentOwner(A){if(A&&(A[Js]===void 0||A[Js]===this)&&(A[Js]=this,A.children))for(const e of A.children)this.setShadowComponentOwner(e)}traverseOwnedShadowComponents(A,e,g){if(A&&A[Js]===e){g(A);for(const I of A.children)this.traverseOwnedShadowComponents(I,e,g)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(A){this.shadowComponent&&(this.shadowComponent.interactable=A)}}class eD extends $s{awake(){super.awake()}}class wd{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 wd(this.input,this.event);return Object.assign(A,this),A}Use(){this.use()}StopPropagation(){this.event.stopImmediatePropagation()}}function mb(i,A){return gA.foreachComponent(i,e=>{if(!e.enabled)return;const g=e;if(A)switch(A){case"pointerdown":if(g.onPointerDown)return!0;break;case"pointerup":if(g.onPointerUp||g.onPointerClick)return!0;break;case"pointermove":if(g.onPointerEnter||g.onPointerExit||g.onPointerMove)return!0;break}else if(g.onPointerDown||g.onPointerUp||g.onPointerEnter||g.onPointerExit||g.onPointerClick)return!0},!1)===!0}var lEA=Object.defineProperty,dEA=Object.getOwnPropertyDescriptor,uEA=(i,A,e,g)=>{for(var I=g>1?void 0:g?dEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&lEA(A,e,I),I};class tD extends bA{awake(){xs.createIfNoneExists(this.context)}onEnable(){var A;(A=xs.get(this.context))==null||A.register(this)}onDisable(){var A;(A=xs.get(this.context))==null||A.unregister(this)}}class Zo extends tD{constructor(){super(...arguments),B(this,"targets",null),B(this,"raycastHits",[]),B(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(A=null){if(!this.targets)return null;A??(A=new fn),A.targets=this.targets,A.results=this.raycastHits;const e=A.testObject;this.ignoreSkinnedMeshes&&(A.testObject=I=>I instanceof wo?"continue in children":e?e(I):!0);const g=this.context.physics.raycast(A);return A.testObject=e,g}}uEA([y()],Zo.prototype,"ignoreSkinnedMeshes",2);class ff extends Zo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class iD extends tD{performRaycast(A){if(!me.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,g=.015;return this.context.physics.sphereOverlap(e,g)}}class kf{static getObject(A){const e=A[Js];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 g=this.tryFindCanvasGroup(A);if(g?.isCanvasGroup===!0&&(e&&(e.canvasGroup=g),g.blocksRaycasts===!1||g.interactable===!1))return!1;const I=dh(A,o=>{if(o.isGraphic===!0)return o},!1);return e&&I?.isGraphic===!0&&(e.graphic=I),!(I?.raycastTarget===!1||I?.layer===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=dh(A,g=>{const I=g;if(I.blocksRaycasts!==void 0&&I.interactable!==void 0)return I},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function Sb(i){return i[Js]||(i.parent?Sb(i.parent):null)}function pEA(i){return i.isUI===!0||typeof i[Js]=="object"}function Mf(i,A){if(!i)return;const e=i.material;if(e?.isMaterial===!0){const g=i.parent;g&&g.isText,e.side=A.doubleSided??!0?yt:Eg,e.shadowSide=A.doubleSided?yt:Eg,i.castShadow=A.castShadows?A.castShadows:!1,i.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const g of i.children)Mf(g,A)}function ll(i,A,e){i[A]===void 0&&console.warn("Field",A,"is undefined on",i);const g=Proxy.revocable(i[A],{set(s,n,a,r){const C=s[n],Q=Reflect.set(s,n,a,r);return e(a,C),Q}}),I=g.revoke,o=i[A];return g.revoke=()=>{i[A]=o,I()},i[A]=g.proxy,g}const r8=Symbol("Scheduled action");function DEA(i,A,e=Xt.OnBeforeRender){let g=i[r8];g||(g=i[r8]={});const I=A.name;g[e]||(g[e]={});const o=g[e];if(o[I])return;function*s(){A?.call(i),o[I]=null}const n=i.startCoroutine(s(),e);o[I]=n}const vr=iA("debugeventsystem");var fb=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(fb||{});const Kr=class extends bA{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",i=>{var A;let e=null;if(pEA(i)&&(e=(A=i[Js])==null?void 0:A.gameObject),this._testObjectsCache.has(i)||e&&this._testObjectsCache.has(e))return this._testObjectsCache.get(i)===!1?"continue in children":!0;{let g=mb(i,this._currentPointerEventName);if(!g&&e&&(g=mb(e,this._currentPointerEventName)),g){this._testObjectsCache.set(i,!0);for(const I of i.children)this.shouldRaycastObject_AddToYesCache(I);return!0}return this._testObjectsCache.set(i,!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",[]),Kr.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Kr.systems.length<=0&&Kr.systems.push(...gA.findObjectsOfType(Kr,i)));for(const e of Kr.systems)if(e.context===i)return;const A=new wA;gA.addNewComponent(A,Kr),i.scene.add(A)}static get systems(){const i=Ke.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const A=this._eventSystemMap.get(i);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,A,e=!1){lB.update(i,A,e)}static markUIDirty(i){lB.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Kr.systems.splice(Kr.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!gA.findObjectOfType(tD,this.context)){const i=gA.addNewComponent(this.context.scene,Zo);this.raycaster.push(i),(se()||vr)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(i){var A;i&&this.raycaster&&!this.raycaster.includes(i)&&((A=this.raycaster)==null||A.push(i))}unregister(i){var A,e;const g=(A=this.raycaster)==null?void 0:A.indexOf(i);g!==void 0&&g!==-1&&((e=this.raycaster)==null||e.splice(g,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(hi.PointerDown,this._handleInputFn),this.context.input.addEventListener(hi.PointerUp,this._handleInputFn),this.context.input.addEventListener(hi.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(hi.PointerDown,this._handleInputFn),this.context.input.removeEventListener(hi.PointerUp,this._handleInputFn),this.context.input.removeEventListener(hi.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(i){if(i===void 0||i.propagationStopped)return;const A=new wd(this.context.input,i);this._currentPointerEventName=i.type,A.inputSource=this.context.input,A.isClick=i.isClick,A.isDoubleClick=i.isDoubleClick,A.isDown=i.type==hi.PointerDown,A.isUp=i.type==hi.PointerUp,A.isPressed=this.context.input.getPointerPressed(i.pointerId),vr&&(A.isDown?console.log("DOWN",A.pointerId):A.isUp&&console.log("UP",A.pointerId),A.isClick&&console.log("CLICK",A.pointerId));const e=new fn;i.hasRay?e.ray=i.ray:e.screenPoint=this.context.input.getPointerPositionRC(i.pointerId);const g=this.performRaycast(e);if(g){for(const o of g)o.event=i,i.intersections.push(o);i.origin.onPointerHits&&i.origin.onPointerHits({sender:this,event:i,hits:g})}vr&&A.isClick&&Ci("EventSystem: "+A.pointerId+" - "+this.context.time.frame+" - Up:"+A.isUp+", Down:"+A.isDown);const I={sender:this,args:A,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:I})),this.handleIntersections(g,A),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:I}))}shouldRaycastObject_AddToYesCache(i){this._testObjectsCache.set(i,!0);for(const A of i.children)this.shouldRaycastObject_AddToYesCache(A)}performRaycast(i){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,i||(i=new fn),i.testObject=this.shouldRaycastObject;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;this._currentlyActiveRaycaster=A;const e=A.performRaycast(i);this._currentlyActiveRaycaster=null,e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}assignHitInformation(i,A){A?(i.intersection=A,i.point=A.point,i.normal=A.normal,i.face=A.face,i.distance=A.distance,i.instanceId=A.instanceId):(i.intersection=void 0,i.point=void 0,i.normal=void 0,i.face=void 0,i.distance=void 0,i.instanceId=void 0)}handleIntersections(i,A){var e;if(i!=null&&i.length){i=this.sortCandidates(i);for(const I of i){if(A.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(A,I),this.handleEventOnObject(I.object,A))return!0}}this.assignHitInformation(A,i?.[0]),this.invokePointerCapture(A);const g=this.hoveredByID.get(A.pointerId);return g&&this.propagatePointerExit(g.obj,g.data,null),this.hoveredByID.delete(A.pointerId),A.isUp&&((e=this.pressedByID.get(A.pointerId))==null||e.handlers.forEach(I=>this.invokeOnPointerUp(A,I)),this.pressedByID.delete(A.pointerId)),!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<i.length;A++){const e=i[A],g=e.object;if(g.material&&g.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEventOnObject(i,A){if(!this.testIsVisible(i))return A.isClick&&vr&&console.log("not allowed",i),!1;if(A.pointerId===void 0)return vr&&console.error("Event without pointer can't be handled",A),!1;A.object=i;const e=i.parent,g=A.isClick??!1;let I=null;if(e&&e.isUI){const a=(A.isPressed||A.isClick)??!1;if(e[Js]){const r=e[Js].gameObject;if(r){if(!kf.isInteractable(r,this.out))return!1;I=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=r}}}g&&vr&&console.log(this.context.time.frame,i);const o=this.hoveredByID.get(A.pointerId),s=o?.obj;s!==i&&s&&this.propagatePointerExit(s,o.data,i);const n=this.hoveredByID.get(A.pointerId);if(n?(n.obj=i,n.data=A):this.hoveredByID.set(A.pointerId,{obj:i,data:A}),A.isDown){const a=this.pressedByID.get(A.pointerId);a?(a.obj=i,a.data=A):this.pressedByID.set(A.pointerId,{obj:i,data:A,handlers:new Set})}return(I===null||I.interactable)&&this.handleMainInteraction(i,A,s??null),!0}propagate(i,A){for(;i;)gA.foreachComponent(i,e=>{A(e)},!1),i=i.parent}handleMainInteraction(i,A,e){const g=this.pressedByID.get(A.pointerId),I=e!==i;let o=!0;switch(A.event.pointerType){case"mouse":case"touch":const s=this.context.input.getPointerPositionLastFrame(A.pointerId),n=this.context.input.getPointerPosition(A.pointerId);o=s&&!ge.approximately(s,n);break}this.propagate(i,s=>{var n;const a=s;a.interactable!==!1&&(!a.activeAndEnabled||!a.enabled||(a.onPointerEnter&&I&&this.handlePointerEnter(a,A),A.isDown&&a.onPointerDown&&(a.onPointerDown(A),g?.handlers.add(a),this.handlePointerCapture(A,a)),a.onPointerMove&&(o&&a.onPointerMove(A),this.handlePointerCapture(A,a)),A.isUp&&(a.onPointerUp&&(this.invokeOnPointerUp(A,a),g?.handlers.delete(a)),a.onPointerExit&&((n=A.event)==null?void 0:n.pointerType)===bS.Touch&&(this.handlePointerExit(a,A),this.hoveredByID.delete(A.pointerId))),A.isClick&&a.onPointerClick&&a.onPointerClick(A)))}),A.isUp&&(g?.handlers.forEach(s=>{this.invokeOnPointerUp(A,s)}),this.pressedByID.delete(A.pointerId))}propagatePointerExit(i,A,e){this.propagate(i,g=>{if(!g.gameObject||g.destroyed)return;const I=g;if(I.onPointerExit){if(e&&this.isChild(e,g.gameObject))return;this.handlePointerExit(I,A)}})}invokeOnPointerUp(i,A){var e;(e=A.onPointerUp)==null||e.call(A,i),this.releasePointerCapture(i,A)}handlePointerEnter(i,A){i.onPointerEnter&&this.updatePointerState(i,A.pointerId,this.pointerEnterSymbol,!0)&&i.onPointerEnter(A),this.updatePointerState(i,A.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(i,A){i.onPointerExit&&this.updatePointerState(i,A.pointerId,this.pointerExitSymbol,!0)&&i.onPointerExit(A),this.updatePointerState(i,A.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(i,A,e,g){let I=i[e];if(g)return I&&I.includes(A)?!1:(I=I||[],I.push(A),i[e]=I,!0);{if(!I||!I.includes(A))return!1;const o=I.indexOf(A);return o!==-1&&I.splice(o,1),!0}}handlePointerCapture(i,A){if(i.z__pointer_ctured){i.z__pointer_ctured=!1;const e=i.pointerId;if(A.onPointerMove){const g=this._capturedPointer[e]||[];g.push(A),this._capturedPointer[e]=g}else se()&&!A.z__warned_no_pointermove&&(A.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 i.z__pointer_cture_rleased&&(i.z__pointer_cture_rleased=!1,this.releasePointerCapture(i,A))}releasePointerCapture(i,A){const e=i.pointerId;if(this._capturedPointer[e]){const g=this._capturedPointer[e].indexOf(A);g!==-1&&(this._capturedPointer[e].splice(g,1),vr&&console.log("released pointer capture",e,A,this._capturedPointer))}}invokePointerCapture(i){var A;if(i.event.type===hi.PointerMove){const e=i.pointerId,g=this._capturedPointer[e];if(g){vr&&console.log("Captured",e,g);for(let I=0;I<g.length;I++){const o=g[I];if(o.destroyed){g.splice(I,1),I--;continue}(A=o.onPointerMove)==null||A.call(o,i)}}}}isChild(i,A){return!i||!A?!1:i===A?!0:i.parent?this.isChild(i.parent,A):!1}handleMeshUiObjectWithoutShadowDom(i,A){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,A)}handleMeshUIIntersection(i,A){const e=lB.updateState(i,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&lB.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const A=this.currentActiveMeshUIComponents[i];lB.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?gA.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let xs=Kr;B(xs,"_eventSystemMap",new Map),B(xs,"didSearchEventSystem",!1);class lB{static markDirty(){this.needsUpdate=!0}static update(A,e,g=!1){if(g){A.update();return}const I=e.time.frameCount;for(const o of this.lastUpdateFrame)if(o.context===e){if(I===o.frame)return;o.frame=I;let s=this.needsUpdate||I<1;o.nextUpdate===e.time.frameCount&&(s=!0),s&&(vr&&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 g=null;if(A&&(g=this.findBlockInParent(A),g&&g!==this.lastSelected)){if(g.interactable===!1)return null;this.needsUpdate=!0}return g}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(lB,"lastSelected",null),B(lB,"lastUpdateFrame",[]),B(lB,"needsUpdate",!1);var wEA=Object.defineProperty,yEA=Object.getOwnPropertyDescriptor,Ei=(i,A,e,g)=>{for(var I=g>1?void 0:g?yEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&wEA(A,e,I),I};const kb=iA("debugorbit"),Gf=iA("freecam"),Rf=iA("debugcamerafit"),Uf=iA("smoothcam"),mEA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let Mb;class gD extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class St extends bA{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 S),B(this,"_lookTargetEndPosition",new S),B(this,"_lookTargetLerp01",0),B(this,"_lookTargetLerpDuration",0),B(this,"_cameraLerpActive",!1),B(this,"_cameraStartPosition",new S),B(this,"_cameraEndPosition",new S),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",A=>{if(this.clickBackgroundToFitScene>0&&A.isClick&&A.button===0){if(A.hasRay||A.intersections.push(...this.context.physics.raycast()),A.intersections.length<=0){const e=this.context.time.time-this._lastTimeClickOnBackground;this._lastTimeClickOnBackground=this.context.time.time,this.clickBackgroundToFitScene<=1||e<this.clickBackgroundToFitScene*.15?(this._clickOnBackgroundCount+=1,this._clickOnBackgroundCount>=this.clickBackgroundToFitScene-1&&this.fitCamera(this.context.scene.children,{immediate:!1})):this._clickOnBackgroundCount=0}kb&&console.log(this.clickBackgroundToFitScene,A.intersections.length,this._clickOnBackgroundCount)}}),B(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),B(this,"_shouldDisable",!1),B(this,"__onPreRender",()=>{const A=this.context.pre_render_callbacks.indexOf(this.__onPreRender);A>=0&&this.context.pre_render_callbacks.splice(A,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(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didSetTarget=0,this._startedListeningToKeyEvents=!1}start(){this._eventSystem=xs.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(fb.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(fb.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._didSetTarget=0,this._enableTime=this.context.time.time;const A=gA.getComponent(this.gameObject,Tt);this._camera=A;let e=A?.cam;if(!e&&this.gameObject instanceof xe&&(e=this.gameObject),e&&RN(e,this,!0),!this._controls&&e instanceof xe){this._cameraObject=e;const g=this.targetElement??this.context.renderer.domElement,I=e?.quaternion.clone();this._controls=new g8(e,g),e?.quaternion.copy(I),Mb===void 0&&(Mb={...this._controls.keys})}this._controls&&(Gf&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,ls()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?Gf||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Gf||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=gA.getComponent(this.gameObject,cB)??void 0,this.context.input.addEventListener("pointerup",this._onPointerDown),this.context.pre_render_callbacks.push(this.__onPreRender)}onDisable(){var A;(A=this._camera)!=null&&A.cam&&RN(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(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;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)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.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=gA.getComponent(this.gameObject,Tt);if(I&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const o=Fe(I.cam),s=Math.max(.01,o.length()),n=new S(0,0,-s).applyMatrix4(I.cam.matrixWorld);this.setLookTargetPosition(n,!0)}if(!this.setLookTargetFromConstraint()){const o=new fn;o.screenPoint=new AA(0,0),o.lineThreshold=.1;const s=this.context.physics.raycast(o);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Rf&&console.log("OrbitControls hits",...s)}}let g=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(g||(g=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),g&&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 gD(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 gD(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?Mb:mEA,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 Uf=="number"||Uf===!0){this._controls.enableDamping=!0;const I=typeof Uf=="number"?Uf:.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||(!Gf&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),kb&&pe.DrawWireSphere(this._controls.target,.1,65280))}}setCameraAndLookTarget(A){if(!A||!(A instanceof wA))return;const e=Fe(A),g=JN(A);this.setTargetFromRaycast(new po(e,g)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var g,I;A&&(A instanceof wA&&(A=Fe(A)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof wA&&(A=Fe(A)),this._lookTargetEndPosition.copy(A),kb&&(console.warn("OrbitControls: setLookTargetPosition",A,e),pe.DrawWireSphere(this._lookTargetEndPosition,.2,16711680,2)),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var g;if(!this._controls)return!1;const I=(g=this.lookAtConstraint)==null?void 0:g.sources;if(I&&I.length>0){const o=I[A];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){if(!this.controls)return;const e=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const g of e)if(g.distance>0&&gA.isActiveInHierarchy(g.object)){const I=Sb(g.object);if(I){const o=I.canvas;if(o!=null&&o.screenspace)break}this.setLookTargetPosition(g.point);break}}fitCamera(A,e={fitOffset:void 0,immediate:!1}){if(this.context.isInXR)return;const{immediate:g=!1,centerCamera:I}=e;let{fitOffset:o}=e;o==null&&(o=1.1);const s=this._cameraObject,n=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.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 a=new S,r=new S,C=$n(A,void 0);s.updateMatrixWorld(),s.updateProjectionMatrix(),C.getCenter(r);const Q=new S;if(C.getSize(Q),C.applyMatrix4(s.matrixWorldInverse),C.getSize(a),C.setFromCenterAndSize(r,a),Number.isNaN(a.x)||Number.isNaN(a.y)||Number.isNaN(a.z)){console.warn("Camera fit size resultet in NaN",s,C,[...A]);return}if(a.length()<=1e-10){Rf&&console.warn("Camera fit size is zero",C,[...A]);return}const h=s.fov,E=2*Math.atan(Math.tan(h*Math.PI/360/2)*s.aspect)/Math.PI*360,c=a.y/(2*Math.atan(Math.PI*h/360)),l=a.x/(2*Math.atan(Math.PI*E/360)),d=o*Math.max(c,l)+a.z/2;Rf&&console.log("Fit camera to objects",c,l,"distance",d),n.maxDistance=d*10,n.minDistance=d*.01;const u=.05,D=r.clone();D.y-=a.y*u,this.setLookTargetPosition(D,g),this.autoTarget=!1;const p=gA.findObjectOfType(hB),w=p?p.radius:0,f=Math.max(Q.x,Q.y,Q.z,w);s.near=d/100,s.far=f+d*10,s.updateMatrixWorld(),s.updateProjectionMatrix();const G=Fe(s),M=r.clone();if(M.sub(G),I==="y"&&(M.y=0),M.normalize(),M.multiplyScalar(d),I==="y"&&(M.y+=-u*4*a.y),s.parent){const U=s.parent.worldToLocal(r.clone().sub(M));this.setCameraTargetPosition(U,g)}else console.error(`Can not fit camera ${s.name} because it has no parent`);if(Rf){const U=new bU(C);this.context.scene.add(U),LN(U,fu(s)),setTimeout(()=>{this.context.scene.remove(U)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",v=>{v.code==="KeyF"&&this.fitCamera(A,{fitOffset:o,immediate:g})}))}n.update()}}Ei([y()],St.prototype,"autoTarget",2),Ei([y()],St.prototype,"autoFit",2),Ei([y()],St.prototype,"enableRotate",2),Ei([y()],St.prototype,"autoRotate",2),Ei([y()],St.prototype,"autoRotateSpeed",2),Ei([y()],St.prototype,"minAzimuthAngle",2),Ei([y()],St.prototype,"maxAzimuthAngle",2),Ei([y()],St.prototype,"minPolarAngle",2),Ei([y()],St.prototype,"maxPolarAngle",2),Ei([y()],St.prototype,"enableKeys",2),Ei([y()],St.prototype,"enableDamping",2),Ei([y()],St.prototype,"dampingFactor",2),Ei([y()],St.prototype,"enableZoom",2),Ei([y()],St.prototype,"minZoom",2),Ei([y()],St.prototype,"maxZoom",2),Ei([y()],St.prototype,"zoomSpeed",2),Ei([y()],St.prototype,"enablePan",2),Ei([y(mh)],St.prototype,"lookAtConstraint",2),Ei([y()],St.prototype,"lookAtConstraint01",2),Ei([y()],St.prototype,"allowInterrupt",2),Ei([y()],St.prototype,"middleClickToFocus",2),Ei([y()],St.prototype,"doubleClickToFocus",2),Ei([y()],St.prototype,"clickBackgroundToFitScene",2),Ei([y()],St.prototype,"targetLerpDuration",2);var SEA=Object.defineProperty,fEA=Object.getOwnPropertyDescriptor,no=(i,A,e,g)=>{for(var I=g>1?void 0:g?fEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&SEA(A,e,I),I},dB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(dB||{});const br=iA("debugcam"),C8=iA("debugscreenpointtoray");var Nf;const ID=(Nf=class extends bA{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 DA)}get isCamera(){return!0}get aspect(){return this._cam instanceof xe?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(i){this._cam instanceof xe&&this._cam.aspect!==i&&(this._cam.aspect=i,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof xe?this._cam.fov:this._fov}set fieldOfView(i){const A=this.fieldOfView!=i;if(this._fov=i,A&&this._cam&&this._cam instanceof xe){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(i){const A=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&A&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const A=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&A&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set backgroundRotation(i){i!==this._backgroundRotation&&(i===void 0?this._backgroundRotation=void 0:this._backgroundRotation=i,this.applyClearFlagsIfIsActiveCamera())}get backgroundRotation(){return this._backgroundRotation}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,A,e){const g=this.cam,I=ID._origin;I.set(i,A,-1),this.context.input.convertScreenspaceToRaycastSpace(I),C8&&console.log("screenPointToRay",i.toFixed(2),A.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=ID._direction.set(I.x,I.y,I.z),s=Fe(g);return o.sub(s),o.normalize(),e?(e.set(s,o),e):new po(s.clone(),o.clone())}getFrustum(){return this._frustum||(this._frustum=new cQ,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new cQ),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(i,A){return A&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),i===this._projScreenMatrix?i:i.copy(this._projScreenMatrix)}awake(){C8&&window.addEventListener("pointerdown",i=>{const A=i.clientX,e=i.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const g=this.screenPointToRay(A,e),I="#"+Math.floor(Math.random()*16777215).toString(16);pe.DrawRay(g.origin,g.direction,I,10)})}onEnable(){br&&console.log(`Camera enabled: "${this.name}". ClearFlags=${dB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),MEA(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 i=this.context.renderer;if(i){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let A=null;if(i?(A=this.gameObject,A?.layers.enableAll(),A instanceof xe&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof xe&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new xe(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new jn(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(i){this.context.mainCameraComponent===this&&this.applyClearFlags(i)}applyClearFlags(i){if(!this._cam){br&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,br){const A=`Camera "${this.name}" clear flags: ${dB[this._clearFlags]}`;console.debug(A)}switch(this._clearFlags){case 1:if(ID.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||i?.applySkybox===!0)&&this.applySceneSkybox(),this._backgroundBlurriness!==void 0?this.context.scene.backgroundBlurriness=this._backgroundBlurriness:br&&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:br&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let A=this._backgroundColor.alpha;ID.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else br&&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 kEA(this)),this._skybox.apply()}static backgroundShouldBeTransparent(i){var A,e,g,I;const o=(A=i.renderer.xr)==null?void 0:A.getSession();if(!o)return!1;if(typeof o._transparent=="boolean")return o._transparent;const s=o.environmentBlendMode;br&&Ci("Environment blend mode: "+s+" on "+navigator.userAgent);let n=s==="additive"||s==="alpha-blend";return i.isInAR&&s==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(g=navigator.userAgent)!=null&&g.includes("Mozilla")&&(I=navigator.userAgent)!=null&&I.includes("Mobile WebXRViewer/v2"))&&(n=!0),o._transparent=n,n}},B(Nf,"_origin",new S),B(Nf,"_direction",new S),Nf);let Tt=ID;no([y()],Tt.prototype,"aspect",1),no([y()],Tt.prototype,"fieldOfView",1),no([y()],Tt.prototype,"nearClipPlane",1),no([y()],Tt.prototype,"farClipPlane",1),no([y()],Tt.prototype,"clearFlags",1),no([y()],Tt.prototype,"orthographic",2),no([y()],Tt.prototype,"orthographicSize",2),no([y()],Tt.prototype,"ARBackgroundAlpha",2),no([y()],Tt.prototype,"cullingMask",1),no([y()],Tt.prototype,"backgroundBlurriness",1),no([y()],Tt.prototype,"backgroundIntensity",1),no([y(It)],Tt.prototype,"backgroundRotation",1),no([y()],Tt.prototype,"environmentIntensity",1),no([y(Rt)],Tt.prototype,"backgroundColor",1),no([y(El)],Tt.prototype,"targetTexture",1);class kEA{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&&(br&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Eo,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)),(br||se())&&Lt(`Camera "${this._camera.name}" has no skybox texture`))}}function MEA(i){iA("freecam")&&i.context.mainCameraComponent===i&&gA.getOrAddComponent(i.gameObject,St)}class uB extends bA{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 g2),this._listener}onEnable(){aB.registerWaitForInteraction(this.onInteraction),this.addListenerIfItExists()}onDisable(){aB.unregisterWaitForInteraction(this.onInteraction),this.removeListenerIfItExists()}addListenerIfItExists(){const A=this._listener;if(!A||A!=null&&A.parent)return;const e=this.context.mainCameraComponent||gA.getComponentInParent(this.gameObject,Tt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A),A.filter?(A.gain.connect(A.filter),A.filter.connect(A.context.destination)):A.gain.connect(A.context.destination)}removeListenerIfItExists(){const A=this._listener;A&&(A.removeFromParent(),A.filter&&A.filter.disconnect(),A.gain&&A.gain.disconnect())}}class GEA extends Fi{constructor(A,e=1,g=16,I=2){const o=new ue,s=g+I*2,n=new Float32Array((s*3+3)*3);o.setAttribute("position",new Ie(n,3));const a=new Zt({color:65280}),r=new Zt({color:16776960});super(o,[r,a]),this.audio=A,this.range=e,this.divisionsInnerAngle=g,this.divisionsOuterAngle=I,this.type="PositionalAudioHelper",this.update()}update(){const A=this.audio,e=this.range,g=this.divisionsInnerAngle,I=this.divisionsOuterAngle,o=ct.degToRad(A.panner.coneInnerAngle),s=ct.degToRad(A.panner.coneOuterAngle),n=o/2,a=s/2;let r=0,C=0,Q,h;const E=this.geometry,c=E.attributes.position;E.clearGroups();function l(d,u,D,p){const w=(u-d)/D;for(c.setXYZ(r,0,0,0),C++,Q=d;Q<u;Q+=w)h=r+C,c.setXYZ(h,Math.sin(Q)*e,0,Math.cos(Q)*e),c.setXYZ(h+1,Math.sin(Math.min(Q+w,u))*e,0,Math.cos(Math.min(Q+w,u))*e),c.setXYZ(h+2,0,0,0),C+=3;E.addGroup(r,C,p),r+=C,C=0}l(-a,-n,I,0),l(-n,n,g,1),l(n,a,I,0),c.needsUpdate=!0,o===s&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}var REA=Object.defineProperty,UEA=Object.getOwnPropertyDescriptor,ha=(i,A,e,g)=>{for(var I=g>1?void 0:g?UEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&REA(A,e,I),I};const xI=iA("debugaudio"),pB=class extends bA{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||ls())&&(this.wasPlaying=this.isPlaying,this.isPlaying&&this.pause());break;case"visible":xI&&console.log("visible",this.enabled,this.playOnAwake,!this.isPlaying,pB.userInteractionRegistered,this.wasPlaying),this.enabled&&this.playOnAwake&&!this.isPlaying&&pB.userInteractionRegistered&&this.wasPlaying&&this.play();break}}),B(this,"onApplicationMuteChanged",()=>{var i,A;this.context.application.muted?(i=this.sound)==null||i.setVolume(0):(A=this.sound)==null||A.setVolume(this.volume)}),B(this,"createAudio",i=>{xI&&console.log("AudioBuffer finished loading",i);const A=this.Sound;if(!A){xI&&console.warn("Failed getting sound?",this.name);return}A.isPlaying&&A.stop(),i&&A.setBuffer(i),A.loop=this._loop,this.context.application.muted?A.setVolume(0):A.setVolume(this.volume),A.autoplay=this.shouldPlay&&pB.userInteractionRegistered,this.applySpatialDistanceSettings(),A.isPlaying&&A.stop(),pB.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 aB.userInteractionRegistered}static registerWaitForAllowAudio(i){aB.registerWaitForAllowAudio(i)}get loop(){return this.sound&&(this._loop=this.sound.getLoop()),this._loop}set loop(i){this._loop=i,this.sound&&this.sound.setLoop(i)}get spatialBlend(){return this._spatialBlend}set spatialBlend(i){i!==this._spatialBlend&&(this._spatialBlend=i,this._needUpdateSpatialDistanceSettings=!0)}get minDistance(){return this._minDistance}set minDistance(i){this._minDistance!==i&&(this._minDistance=i,this._needUpdateSpatialDistanceSettings=!0)}get maxDistance(){return this._maxDistance}set maxDistance(i){this._maxDistance!==i&&(this._maxDistance=i,this._needUpdateSpatialDistanceSettings=!0)}get volume(){return this._volume}set volume(i){this._volume=i,this.sound&&!this.context.application.muted&&(xI&&console.log(this.name,"audio set volume",i),this.sound.setVolume(i))}get Sound(){var i;if(!this.sound&&pB.userInteractionRegistered){let A=gA.getComponent(this.context.mainCamera,uB)??gA.findObjectOfType(uB,this.context);!A&&this.context.mainCamera&&(A=gA.addNewComponent(this.context.mainCamera,uB)),A!=null&&A.listener?(this.sound=new o2(A.listener),(i=this.gameObject)==null||i.add(this.sound)):xI&&console.warn("No audio listener found in scene - can not play audio")}return this.sound}get ShouldPlay(){return this.shouldPlay}get audioContext(){var i;return(i=this.sound)==null?void 0:i.context}awake(){xI&&console.log(this),this.audioLoader=new k0,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),pB.userInteractionRegistered?this.playOnAwake&&this.context.application.isVisible&&this.play():pB.registerWaitForAllowAudio(()=>{this.enabled&&!this.destroyed&&this.shouldPlay&&this.onNewClip(this.clip)}),globalThis.addEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.addEventListener(VS.MuteChanged,this.onApplicationMuteChanged)}onDisable(){globalThis.removeEventListener("visibilitychange",this.onVisibilityChanged),this.context.application.removeEventListener(VS.MuteChanged,this.onApplicationMuteChanged),this.pause()}applySpatialDistanceSettings(){const i=this.sound;if(!i)return;this._needUpdateSpatialDistanceSettings=!1;const A=ge.lerp(10*this._maxDistance/Math.max(1e-4,this.spatialBlend),this._minDistance,this.spatialBlend);switch(xI&&console.log(this.name,this._minDistance,this._maxDistance,this.spatialBlend,"Ref distance="+A),i.setRefDistance(A),i.setMaxDistance(Math.max(.01,this._maxDistance)),this.rollOffMode){case 0:i.setDistanceModel("exponential");break;case 1:i.setDistanceModel("linear");break;case 2:console.warn("Custom rolloff for AudioSource is not supported: "+this.name);break}this.spatialBlend>0?xI&&!this.helper&&(this.helper=new GEA(i,i.getRefDistance()),i.add(this.helper)):this.helper&&this.helper.parent&&this.helper.removeFromParent()}async onNewClip(i){if(i&&(this.clip=i),typeof i=="string")if(xI&&console.log(i),i.endsWith(".mp3")||i.endsWith(".wav")){if(this.audioLoader||(this.audioLoader=new k0),this.shouldPlay=!0,this._lastClipStartedLoading===i){xI&&console.log("Is currently loading:",this._lastClipStartedLoading,this);return}this._lastClipStartedLoading=i,xI&&console.log("load audio",i);const A=await this.audioLoader.loadAsync(i).catch(console.error);this._lastClipStartedLoading=null,A&&this.createAudio(A)}else console.warn("Unsupported audio clip type",i);else this.shouldPlay=!0,this.createAudio()}play(i=void 0){var A,e,g;!i&&this.clip&&(i=this.clip),i!==void 0&&typeof i!="string"&&!(i instanceof MediaStream)&&(se()&&console.warn("Called play on AudioSource with unknown argument type:",i+`
|
|
5733
5733
|
Using the assigned clip instead:`,this.clip),i=this.clip);let I=!this.sound||i&&i!==this.clip;if(typeof i=="string"&&!this.audioLoader&&(I=!0),(i instanceof MediaStream||typeof i=="string")&&(this.clip=i),I){this.shouldPlay=!0,this.onNewClip(i);return}if(this.shouldPlay=!0,this._hasEnded=!1,xI&&console.log("play",(A=this.sound)==null?void 0:A.getVolume(),this.sound),this.sound&&!this.sound.isPlaying){const o=this.context.application.muted;o&&this.sound.setVolume(0),(e=this.gameObject)==null||e.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||(g=this.context.domElement.shadowRoot)==null||g.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 i,A;xI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.isPlaying&&this.sound.source&&(this._lastContextTime=(i=this.sound)==null?void 0:i.context.currentTime,this.sound.pause()),(A=this._audioElement)==null||A.remove()}stop(){var i,A;xI&&console.log("Pause",this),this._hasEnded=!0,this.shouldPlay=!1,this.sound&&this.sound.source&&(this._lastContextTime=(i=this.sound)==null?void 0:i.context.currentTime,xI&&console.log(this._lastContextTime),this.sound.stop()),(A=this._audioElement)==null||A.remove()}get isPlaying(){var i;return((i=this.sound)==null?void 0:i.isPlaying)??!1}set isPlaying(i){}get time(){var i,A;return(i=this.sound)!=null&&i.source?((A=this.sound.source)==null?void 0:A.context.currentTime)-this._lastContextTime+this.sound.offset:0}set time(i){if(this.sound){if(i===this.sound.offset)return;const A=this.isPlaying;this.stop(),this.sound.offset=i,A&&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,xI&&console.log("Audio clip ended",this.clip),this.dispatchEvent(new CustomEvent("ended",{detail:this})))}};let bi=pB;ha([y(URL)],bi.prototype,"clip",2),ha([y()],bi.prototype,"playOnAwake",2),ha([y()],bi.prototype,"preload",2),ha([y()],bi.prototype,"loop",1),ha([y()],bi.prototype,"spatialBlend",1),ha([y()],bi.prototype,"minDistance",1),ha([y()],bi.prototype,"maxDistance",1),ha([y()],bi.prototype,"volume",1),ha([y()],bi.prototype,"rollOffMode",2),ha([y()],bi.prototype,"playInBackground",2);var NEA=Object.defineProperty,FEA=Object.getOwnPropertyDescriptor,Ff=(i,A,e,g)=>{for(var I=g>1?void 0:g?FEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&NEA(A,e,I),I};const vEA=iA("debugsignals");class oD{constructor(){B(this,"guid")}}Ff([y()],oD.prototype,"guid",2);class dl{constructor(){B(this,"signal"),B(this,"reaction")}}Ff([y(oD)],dl.prototype,"signal",2),Ff([y(zi)],dl.prototype,"reaction",2);var Gb;const Jr=(Gb=class extends bA{constructor(){super(...arguments),B(this,"events")}static invoke(i){if(Jr.receivers[i]){const A=Jr.receivers[i];if(!A)return;for(const e of A)e.invoke(i)}}awake(){vEA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)Jr.receivers[i.signal.guid]||(Jr.receivers[i.signal.guid]=[]),Jr.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(Jr.receivers[i.signal.guid]){const A=Jr.receivers[i.signal.guid].indexOf(this);A>=0&&Jr.receivers[i.signal.guid].splice(A,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const A=typeof i=="object"?i.guid:i;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(g){console.error(g)}}},B(Gb,"receivers",{}),Gb);let ul=Jr;Ff([y(dl)],ul.prototype,"events",2);var zo=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(zo||{}),Ea=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ea||{}),Rb=(i=>(i.Signal="SignalEmitter",i))(Rb||{});const ca=iA("debugtimeline");class sD{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 g=this.track.clips.length-1;g>=0;g--)yield this.track.clips[g];else for(const g of this.track.clips)yield g}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,g,I=!0){if(e<0||e>=g.length)return 0;const o=g[e];if(I||A>=o.start&&A<=o.end){let s=1;const n=!1;if(o.easeInDuration>0){const a=Math.min((A-o.start)/o.easeInDuration,1);s*=a}if(o.easeOutDuration>0&&!n){const a=Math.min((o.end-A)/o.easeOutDuration,1);s*=a}return s}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 g=A.getRoot(),I=g.name+".position",o=g.name+".quaternion";ca&&console.log(e.name,e.tracks,I);for(const s of e.tracks)if(!(s.times.length<=0)){if(s.name.endsWith(I))this.rootStartPosition=new S().fromArray(s.values,0),this.rootEndPosition=new S().fromArray(s.values,s.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),ca&&console.log(this.rootPositionOffset);else if(s.name.endsWith(o)&&(this.rootStartQuaternion=new GA().fromArray(s.values,0),this.rootEndQuaternion=new GA().fromArray(s.values,s.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),ca)){const n=new It().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",n)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class vf extends sD{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 S),B(this,"_totalOffsetRotation",new GA),B(this,"_totalOffsetPosition2",new S),B(this,"_totalOffsetRotation2",new GA),B(this,"_summedPos",new S),B(this,"_tempPos",new S),B(this,"_summedRot",new GA),B(this,"_tempRot",new GA),B(this,"_clipRotQuat",new GA)}onDisable(){var A;(A=this.mixer)==null||A.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&Q8(this._animator.gameObject,this,this.director.isPlaying)}createHooks(A,e){var g,I;if(((g=e.tracks)==null?void 0:g.length)<=0){console.warn("No tracks in AnimationClip",e);return}const o=e.tracks[0].name.split("."),s=o[o.length-2],n=s+".position",a=s+".quaternion";let r=!1,C=!1;for(const Q of e.tracks)Q.name.endsWith(n)?(r=!0,this.createPositionInterpolant(e,A,Q)):Q.name.endsWith(a)&&(C=!0,this.createRotationInterpolant(e,A,Q));if(!r||!C){const Q=(I=this.mixer)==null?void 0:I.getRoot(),h=e.tracks[0],E=h.name.lastIndexOf("."),c=h.name.substring(0,E),l=c.substring(c.lastIndexOf(".")+1),d=Q.getObjectByName(l);if(d)if(r){if(!C){const u=e.tracks[0].name.substring(0,E)+".quaternion";ca&&console.warn("Create quaternion track",l,d);const D=d.quaternion,p=new Es(u,[0,e.duration],[D.x,D.y,D.z,D.w,D.x,D.y,D.z,D.w]);e.tracks.push(p),this.createRotationInterpolant(e,A,p)}}else{const u=c+".position";ca&&console.warn("Create position track",l,d);const D=d.position,p=new Wn(u,[0,e.duration],[D.x,D.y,D.z,D.x,D.y,D.z]);e.tracks.push(p),this.createPositionInterpolant(e,A,p)}}}bind(){if(!this._didBind){this._didBind=!0,ca&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new KEA(A);this._actionOffsets.push(e)}this.target&&(this._animator=gA.getComponent(this.target,II)??null,this._animator&&Q8(this._animator.gameObject,this,!0));for(const A of this.models){const e=A.asset,g=e.position,I=e.rotation;g&&g.x!==void 0&&(g.isVector3||(e.position=new S(g.x,g.y,g.z)),I.isQuaternion||(e.rotation=new GA(I.x,I.y,I.z,I.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new S(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new GA(e.x,e.y,e.z,e.w)))}}evaluate(A){var e,g,I,o,s,n,a;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 r=0,C=0,Q=!1,h=!1,E=0;for(let c=0;c<this.clips.length;c++){const l=this.models[c],d=this.actions[c],u=l.asset;d.weight=0;const D=A>=l.start&&A<=l.end,p=l.preExtrapolationMode,w=l.postExtrapolationMode,f=c<this.clips.length-1?this.models[c+1]:null;let G=D,M=!1;if(!G&&!Q&&l.end<A&&w!==Ea.None?(!f||f.start>A)&&(G=!0,Q=!0):c==0&&!G&&!h&&l.start>A&&p!==Ea.None&&(!f||f.start<A)&&(G=!0,M=!0,h=!0),G){let U=1;U*=this.evaluateWeight(A,c,this.models,G),U*=this.director.weight;let v=D;if(M)switch(p){case Ea.Hold:break;case Ea.Loop:A+=l.start,v=!0;break;default:A+=l.start,v=!0;break}let k=this.getClipTime(A,l),N=0;const _=u.duration;if(M&&p===Ea.Hold&&(k=0),v){if(u.loop)for(N+=Math.floor(k/(_+1e-6));k>_;)k-=_}else if(!D&&Q)switch(w){case Ea.Hold:k=this.getClipTime(l.end,l);break;case Ea.Loop:k%=_;break;case Ea.PingPong:const J=Math.floor(k/_)%2!==0;k%=_,J&&(k=_-k);break}l.reversed===!0?d.time=d.getClip().duration-k:d.time=k,d.timeScale=0;const H=Math.max(0,U);if(d.weight=H,E+=H,d.clampWhenFinished=!1,d.isRunning()||d.play(),this._useclipOffsets){const J=r==0?this._totalOffsetPosition:this._totalOffsetPosition2,P=r==0?this._totalOffsetRotation:this._totalOffsetRotation2;r<1&&(C=1-U),r+=1;const b=this._summedPos.set(0,0,0),x=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),X=this._tempRot.identity(),$=u.rotation;$&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp($,U));const aA=this._actionOffsets[c];if(aA.hasOffsets)for(let kA=0;kA<N;kA++)aA.rootPositionOffset?x.copy(aA.rootPositionOffset):x.set(0,0,0),x.applyQuaternion(Y),this._clipRotQuat&&x.applyQuaternion(this._clipRotQuat),aA.rootQuaternionOffset&&(X.copy(aA.rootQuaternionOffset),Y.multiply(X)),b.add(x);this._clipRotQuat&&P.multiply(this._clipRotQuat),P.multiply(Y),u.position&&b.add(u.position),J.add(b)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,C),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,C)),this.__mixerError===void 0&&(ca||se())&&(g=(e=this._animator)==null?void 0:e.runtimeAnimatorController)!=null&&g.mixer&&this.mixer!==((o=(I=this._animator)==null?void 0:I.runtimeAnimatorController)==null?void 0:o.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(s=this._animator)!=null&&s.runtimeAnimatorController){const c=Math.max(0,1-E);(a=(n=this._animator)==null?void 0:n.runtimeAnimatorController)==null||a.update(c)}else this.mixer.update(A)}createRotationInterpolant(A,e,g){var I;const o=g.createInterpolant.bind(g),s=new GA;this.ensureTrackOffsets();const n=(I=this.trackOffset)==null?void 0:I.rotation;g.createInterpolant=()=>{const a=o(),r=a.evaluate.bind(a);return a.evaluate=C=>{var Q;const h=r(C);if(s.set(h[0],h[1],h[2],h[3]),s.premultiply(this._totalOffsetRotation),n&&s.premultiply(n),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(Q=E?.onTimelineRotation)==null||Q.call(E,this.director,this.target,C,s);return h[0]=s.x,h[1]=s.y,h[2]=s.z,h[3]=s.w,h},a}}createPositionInterpolant(A,e,g){var I,o;const s=g.createInterpolant.bind(g),n=new S;this.ensureTrackOffsets();const a=(I=this.trackOffset)==null?void 0:I.rotation,r=(o=this.trackOffset)==null?void 0:o.position;let C;g.createInterpolant=()=>{const Q=s(),h=Q.evaluate.bind(Q);return Q.evaluate=E=>{var c,l,d;const u=h(E);if(n.set(u[0],u[1],u[2]),e.removeStartOffset&&(C===void 0?(C=null,C=(l=(c=this._actionOffsets.find(D=>D.clip===A))==null?void 0:c.rootStartPosition)==null?void 0:l.clone()):C!=null&&C.isVector3&&n.sub(C)),n.applyQuaternion(this._totalOffsetRotation),n.add(this._totalOffsetPosition),a&&n.applyQuaternion(a),r&&(n.x-=r.x,n.y+=r.y,n.z+=r.z),this.director.animationCallbackReceivers)for(const D of this.director.animationCallbackReceivers)(d=D?.onTimelinePosition)==null||d.call(D,this.director,this.target,E,n);return u[0]=n.x,u[1]=n.y,u[2]=n.z,u},Q}}}const bEA=iA("mutetimeline"),nD=class extends sD{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(i){const A=this.director.sourceId;return MC(A,i)}onAllowAudioChanged(i){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(i?e.asset.volume:0)}}addModel(i){const A=new GU(this.listener);this.audio.push(A);const e=i;e._didTriggerPlay=!1,this.models.push(e)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop();for(const i of this.models)i._didTriggerPlay=!1}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const A=this.audio[i];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const A=this.audio[i];A!=null&&A.isPlaying&&A.stop()}for(const i of this.models)i._didTriggerPlay=!1}onPauseChanged(){for(let i=0;i<this.audio.length;i++){const A=this.audio[i];A!=null&&A.isPlaying&&A.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(i){if(bEA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=this._playableDirectorResumed;this._playableDirectorResumed=!1;const g=A?.1:0;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.audio[I],n=o.asset;if((!s||!s.buffer)&&this.isInTimeRange(o,i-1,i+1)&&this.handleAudioLoading(o,s),bi.userInteractionRegistered!==!1&&!(s===null||!s.buffer))if(s.playbackRate=this.director.context.time.timeScale*this.director.speed,s.loop=n.loop,i>=o.start&&i<=o.end&&i<this.director.duration){if(!s.isPlaying||!this.director.isPlaying)(e||!o._didTriggerPlay&&this.lastTime<i)&&(o.duration*o.timeScale>.3?s.offset=o.clipIn+(i-o.start)*o.timeScale:s.offset=0,ca&&console.log("Timeline Audio ("+this.track.name+") play with offset "+s.offset+" - "+o.asset.clip),s.play(g),o._didTriggerPlay=!0);else{const r=o.clipIn+(i-o.start)*o.timeScale,C=s.context.currentTime-s._startedAt+s.offset;Math.abs(r-C)>.3&&(s.offset=r,s.stop(),s.play(g))}let a=n.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),A&&(a=0),o.easeInDuration>0){const r=Math.min((i-o.start)/o.easeInDuration,1);a*=r}if(o.easeOutDuration>0){const r=Math.min((o.end-i)/o.easeOutDuration,1);a*=r}s.setVolume(a*this.director.weight)}else o._didTriggerPlay=!1,this.director.isPlaying&&s.isPlaying&&s.stop()}this.lastTime=i}loadAudio(i,A=0,e=0){let g=null;const I=i-e,o=i+A;for(const s of this.models)if(this.isInTimeRange(s,I,o)){const n=this.audio[this.models.indexOf(s)],a=this.handleAudioLoading(s,n);a!==null&&(g===null&&(g=[]),g.push(a))}return g!==null?Promise.all(g):null}isInTimeRange(i,A,e){return A<=i.start&&e>=i.end||A>=i.start&&A<=i.end||e>=i.start&&e<=i.end}static dispose(){nD._audioBuffers.clear()}handleAudioLoading(i,A){this._audioLoader||(this._audioLoader=new k0);const e=this.getAudioFilePath(i.asset.clip);if(nD._audioBuffers.get(e)){const I=nD._audioBuffers.get(e);return I.then(o=>{o&&A.setBuffer(o)}),I}ca&&console.warn("LOAD audio track",e,this.director.sourceId);const g=new Promise((I,o)=>{this._audioLoader.load(e,s=>{A.setBuffer(s),I(s)},void 0,s=>{console.error("Error loading audio",s),I(null)})});return nD._audioBuffers.set(e,g),g}};let aD=nD;B(aD,"_audioBuffers",new Map);class rD extends sD{constructor(){super(...arguments),B(this,"models",[]),B(this,"didTrigger",[]),B(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const g=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-A;let a=!1;if(o.retroActive)a=n<=1e-6;else{const r=Math.abs(n);(r===0||r>=1e-5&&r<g)&&(a=!0)}if(a){if(!s)if(ca&&console.log("Trigger signal",A,o.time,o),this.didTrigger[I]=!0,((e=this.receivers)==null?void 0:e.length)<=0)ul.invoke(o.asset);else for(const r of this.receivers)r&&r.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class Kf extends sD{constructor(){super(...arguments),B(this,"models",[]),B(this,"timelines",[]),B(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const g=this.models[e].asset;if(!g.sourceObject||typeof g.sourceObject!="object"){console.log("no source object, removing model",e,g),this.models.splice(e,1);continue}else{const I=gA.getComponent(g.sourceObject,DB);this.timelines.push(I),I&&g.updateDirector&&(I.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(A>=I.start&&A<=I.end){this._previousActiveModel=I;const s=this.getClipTime(A,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[g];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(e=this._previousActiveModel)==null?void 0:e.asset;if(o.controlActivation){const n=o.sourceObject;s?.sourceObject!==n&&(n.visible=!1)}}}}}var JEA=Object.defineProperty,xEA=Object.getOwnPropertyDescriptor,B8=(i,A,e,g)=>{for(var I=g>1?void 0:g?xEA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&JEA(A,e,I),I};const pl=iA("debugtimeline");var Ub;const Nb=(Ub=class extends bA{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(i,A){this.createTrackFunctions[i]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(pl||zI())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,A,e;pl&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var i,A,e;for(const g of this._audioTracks)(i=g.onEnable)==null||i.call(g);for(const g of this._customTracks)(A=g.onEnable)==null||A.call(g);for(const g of this._animationTracks)(e=g.onEnable)==null||e.call(g);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 i,A,e;this.stop();for(const g of this._audioTracks)(i=g.onDisable)==null||i.call(g);for(const g of this._customTracks)(A=g.onDisable)==null||A.call(g);for(const g of this._animationTracks)(e=g.onDisable)==null||e.call(g);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const A of this._allTracks)for(const e of A)(i=e.onDestroy)==null||i.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,i&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const A=[];for(const e of this._audioTracks){const g=e.loadAudio(this._time,1,0);g&&A.push(g)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!bi.userInteractionRegistered&&this.waitForAudio;)await Vn(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Xt.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const e of this._audioTracks)e.stop();const i=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!A&&this.invokePauseChangedMethodsOnTracks(),A&&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 i of this._allTracks)for(const A of i)yield A}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const A of this.forEachTrack())(i=A.onPauseChanged)==null||i.call(A)}invokeStateChangedMethodsOnTracks(){var i;for(const A of this.forEachTrack())(i=A.onStateChanged)==null||i.call(A,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(i=!1){if(!this.isValid())return;let A=this._time;switch(this.extrapolationMode){case 0:this._speed>0?A=Math.min(A,this._duration):this._speed<0&&(A=Math.max(A,0)),this._time=A;break;case 1:A%=this._duration,this._time=A;break;case 2:if(A>this._duration){this.stop();return}break}const e=this._time;for(const g of this.playableAsset.tracks)if(!g.muted)switch(g.type){case zo.Activation:if(!i&&!this._isPlaying)continue;for(let I=0;I<g.outputs.length;I++){const o=g.outputs[I];if(typeof o=="object"){let s=!1;if(g.clips)for(const a of g.clips)a.start<=e&&e<=a.end&&(s=!0);const n=o;n.visible!==void 0&&n.visible!==s&&(n.visible=s,pl&&console.warn(this.name,"set ActivationTrack-"+I,n.name,s,e))}}break}if(!this._isStopping)for(const g of this._animationTracks)g.evaluate(e);for(const g of this._audioTracks)g.evaluate(e);for(const g of this._signalTracks)g.evaluate(e);for(const g of this._controlTracks)g.evaluate(e);for(const g of this._customTracks)g.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=uu(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let g=A.outputs[e];if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=gA.findByGuid(g,i);I===null||typeof I!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",g,A.name,A.type)):(pl&&console.log("Resolved binding",g,"to",I),A.outputs[e]=I)}else if(g===null){if(A.outputs.splice(e,1),Nb.createTrackFunctions[A.type])continue;A.type!==zo.Audio&&A.type!==zo.Control&&A.type!==zo.Marker&&A.type!==zo.Signal&&console.warn("Missing binding",g,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===zo.Control&&A.clips)for(let e=0;e<A.clips.length;e++){const g=A.clips[e];let I=g.asset.sourceObject;if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=gA.findByGuid(I,i);o===null||typeof o!="object"?console.warn("Failed to resolve sourceObject binding",I,A.name,g):(pl&&console.log("Resolved binding",I,"to",o),g.asset.sourceObject=o)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){if(i.clips)for(const A of i.clips)A.end>this._duration&&(this._duration=A.end);if(i.markers)for(const A of i.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var i,A,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let g=gA.findObjectOfType(uB,this.context);for(const I of this.playableAsset.tracks){const o=I.type,s=Nb.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){pl&&console.warn("Animation track has no clips",I);continue}for(let n=I.outputs.length-1;n>=0;n--){let a=I.outputs[n];if(a instanceof wA){const C=gA.getOrAddComponent(a,II);C&&(a=C)}const r=(i=a?.gameObject)==null?void 0:i.animations;if(r){const C=new vf;C.trackOffset=I.trackOffset,C.director=this,C.track=I;for(let Q=0;Q<I.clips.length;Q++){const h=I.clips[Q],E=h.asset;if(!E){console.error(`Timeline ${this.name}: clip #${Q} on track "${I.name}" has no animation data`);continue}const c=E.clip;let l=c;if((typeof l=="string"||typeof l=="number")&&(l=r.find(u=>u.name===c)),!l){console.warn("Could not find animationClip for model",h,I.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}a instanceof II&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),C.mixer=a.runtimeAnimatorController.mixer),C.mixer||(C.mixer=new M0(a.gameObject),this.context.animations.registerAnimationMixer(C.mixer)),C.clips.push(l),C.mixer.uncacheAction(l),C.createHooks(h.asset,l);const d=C.mixer.clipAction(l);C.actions.push(d),C.models.push(h)}this._animationTracks.push(C)}}}else if(I.type===zo.Audio){if(!I.clips||I.clips.length<=0)continue;const n=new aD;n.director=this,n.track=I,n.audioSource=I.outputs.find(a=>a instanceof bi),this._audioTracks.push(n),g||(g=(e=this.context.mainCameraComponent)==null?void 0:e.gameObject.addNewComponent(uB)),n.listener=g.listener;for(let a=0;a<I.clips.length;a++){const r=I.clips[a];n.addModel(r)}}else if(I.type===zo.Marker){const n=new rD;if(n.director=this,n.track=I,I.markers)for(const a of I.markers)switch(a.type){case Rb.Signal:n.models.push(a),n.didTrigger.push(!1);break}if(n!==null&&n.models.length>0){const a=gA.getComponent(this.gameObject,ul);a&&(n.receivers.push(a),this._signalTracks.push(n))}}else if(I.type===zo.Signal){const n=new rD;if(n.director=this,n.track=I,I.markers)for(const a of I.markers)n.models.push(a),n.didTrigger.push(!1);for(const a of I.outputs)n.receivers.push(a);this._signalTracks.push(n)}else if(I.type===zo.Control){const n=new Kf;if(n.director=this,n.track=I,I.clips)for(const a of I.clips)n.models.push(a);n.resolveSourceObjects(this.context),this._controlTracks.push(n)}}}setAudioTracksAllowPlaying(i){for(const A of this._audioTracks)A.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const A=this.animationCallbackReceivers.indexOf(i);A!==-1&&this.animationCallbackReceivers.splice(A,1)}},B(Ub,"createTrackFunctions",{}),Ub);let DB=Nb;B8([y()],DB.prototype,"playOnAwake",2),B8([y()],DB.prototype,"extrapolationMode",2);const bf=Symbol("objectIsAnimatedData");function Q8(i,A,e){if(!i)return;if(i[bf]===void 0){if(!e)return;i[bf]=new Set}const g=i[bf];e?g.add(A):g.has(A)&&g.delete(A)}function qEA(i){if(!i)return!1;const A=i[bf];return A!==void 0&&A.size>0}Qt.registerCallback(Mt.ContextCreated,i=>{const A=i.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true"||A==="1")&&i.files)for(const e of i.files)gA.foreachComponent(e.file.scene,g=>{if(g.enabled!==!1){if(g instanceof JI&&g.playAutomatically||g instanceof II||g instanceof DB&&g.playOnAwake===!0)return!0;if(g instanceof JI)return g.playAutomatically=!0,!0;if(g instanceof DB)return g.playOnAwake=!0,!0}},!0)!==!0&&tl.assignAnimationsFromFile(e.file,{createAnimationComponent:(g,I)=>Mn(g,JI)})});class LEA{constructor(){B(this,"_context")}get context(){return this._context??Ke.Current}get isStateMachineBehaviour(){return!0}}class CD{constructor(A,e,g,I){B(this,"name"),B(this,"nameHash"),B(this,"normalizedTime"),B(this,"length"),B(this,"speed"),B(this,"action"),B(this,"hasTransitions");var o;this.name=A.name,this.nameHash=A.hash,this.normalizedTime=e,this.length=g,this.speed=I,this.action=A.motion.action||null,this.hasTransitions=((o=A.transitions)==null?void 0:o.length)>0||!1}}function h8(i,A){return{name:"Empty",isLooping:!1,guid:A?.generateUUID()??ct.generateUUID(),index:-1,clip:new ZI(i,0,[])}}var wB=(i=>(i[i.If=1]="If",i[i.IfNot=2]="IfNot",i[i.Greater=3]="Greater",i[i.Less=4]="Less",i[i.Equals=6]="Equals",i[i.NotEqual=7]="NotEqual",i))(wB||{}),Fb=(i=>(i[i.Float=1]="Float",i[i.Int=3]="Int",i[i.Bool=4]="Bool",i[i.Trigger=9]="Trigger",i))(Fb||{});const xg=iA("debuganimatorcontroller"),Jf=iA("debugrootmotion");class rs{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 g=[];for(let o=0;o<A.length;o++){const s=A[o],n=[];if(e.autoTransition!==!1){const r=e.transitionDuration??0,C=r/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:r,hasExitTime:!0,destinationState:Q,conditions:[]})}const a={name:s.name,hash:o,motion:{name:s.name,clip:s,isLooping:e?.looping??!1},transitions:n,behaviours:[]};g.push(a)}const I={name:"AnimatorController",guid:new Pg(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:g}}]};return new rs(I)}play(A,e=-1,g=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,g);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var g,I;const o=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(s=>s[o]===A).forEach(s=>s.value=e)}getBool(A){var e,g,I;const o=typeof A=="string"?"name":"hash";return((I=(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.find(s=>s[o]===A))==null?void 0:I.value)??!1}setFloat(A,e){var g,I;const o=typeof A=="string"?"name":"hash",s=(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(n=>n[o]===A);return s.forEach(n=>n.value=e),s?.length>0}getFloat(A){var e,g,I;const o=typeof A=="string"?"name":"hash";return((I=(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.find(s=>s[o]===A))==null?void 0:I.value)??0}setInteger(A,e){var g,I;const o=typeof A=="string"?"name":"hash";return(I=(g=this.model)==null?void 0:g.parameters)==null?void 0:I.filter(s=>s[o]===A).forEach(s=>s.value=e)}getInteger(A){var e,g,I;const o=typeof A=="string"?"name":"hash";return((I=(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.find(s=>s[o]===A))==null?void 0:I.value)??0}setTrigger(A){var e,g;xg&&console.log("SET TRIGGER",A);const I=typeof A=="string"?"name":"hash";return(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=!0)}resetTrigger(A){var e,g;const I=typeof A=="string"?"name":"hash";return(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=!1)}getTrigger(A){var e,g,I;const o=typeof A=="string"?"name":"hash";return((I=(g=(e=this.model)==null?void 0:e.parameters)==null?void 0:g.find(s=>s[o]===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 g of e.stateMachine.states)if(g.name===A||g.hash==A)return g}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,g=e<=0?0:Math.abs(A.time/e);return new CD(this._activeState,g,e,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||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,g;A?this.animator!==A&&(this._mixer&&(this._mixer.stopAllAction(),(e=this.context)==null||e.animations.unregisterAnimationMixer(this._mixer)),this.animator=A,this._mixer=new M0(this.animator.gameObject),(g=this.context)==null||g.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=uu(this.model,(e,g,I)=>I==null?!0:!(I.type==="Object3D"||I.isObject3D===!0||VY(I)||I.tracks!==void 0||I instanceof rs));return console.assert(A!==this.model),new rs(A)}update(A){var e,g;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const I=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((e=this.rootMotionHandler)==null||e.onBeforeUpdate(A)),this._mixer.update(I),this.animator.applyRootMotion&&((g=this.rootMotionHandler)==null||g.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const g=this._activeStates[e],I=g.motion;if(!I.action)this._activeStates.splice(e,1),e--;else{const o=I.action;o.weight=A,o.getEffectiveWeight()<=0&&!o.isRunning()&&(xg&&console.debug("REMOVE",g.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){var A;this.model.layers.length>1&&(xg||se())&&console.warn("Multiple layers are not supported yet "+((A=this.animator)==null?void 0:A.name));for(const e of this.model.layers){const g=e.stateMachine;g.defaultState===void 0&&(xg&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),g.defaultState=0);const I=g.states[g.defaultState];this.transitionTo(I,0,this.normalizedStartOffset);break}}evaluateTransitions(){var A;let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const g=this._activeState,I=g.motion.action;for(const s of g.transitions){if(!s.hasExitTime&&s.conditions.length<=0)continue;let n=!0;for(const a of s.conditions)if(!this.evaluateCondition(a)){n=!1;break}if(n)if(I){const a=g.motion.clip.duration,r=a<=0?1:Math.abs(I.time/a);let C=s.exitTime;I.timeScale<0&&(C=1-C);let Q=!1;if(s.hasExitTime?I.timeScale>0?Q=r>=s.exitTime:I.timeScale<0&&(Q=1-r>=s.exitTime):Q=!0,Q){for(const h of s.conditions){const E=this.model.parameters.find(c=>c.name===h.parameter);E?.type===Fb.Trigger&&E.value&&(E.value=!1)}if(I.clampWhenFinished=!0,xg){const h=this.getState(s.destinationState,0);console.log(`Transition to ${s.destinationState} / ${h?.name}`,s,`
|
|
5734
5734
|
Timescale: `+I.timeScale,`
|
|
5735
5735
|
Normalized time: `+r.toFixed(3),`
|
|
@@ -6212,7 +6212,7 @@ Texture:`,g),this.setLightmapDebugMaterial()):ql&&console.log("Use debuglightmap
|
|
|
6212
6212
|
}
|
|
6213
6213
|
`};class fJ extends Ue{constructor(A){super({type:"LineMaterial",uniforms:LE.clone(Zg.line.uniforms),vertexShader:Zg.line.vertexShader,fragmentShader:Zg.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 CW=new S,BW=new S,QI=new VA,hI=new VA,Ua=new VA,kJ=new S,MJ=new DA,EI=new U0,QW=new S,ck=new kt,lk=new Ni,Na=new VA;let Fa,_h;function hW(i,A,e){return Na.set(0,0,-A,1).applyMatrix4(i.projectionMatrix),Na.multiplyScalar(1/Na.w),Na.x=_h/e.width,Na.y=_h/e.height,Na.applyMatrix4(i.projectionMatrixInverse),Na.multiplyScalar(1/Na.w),Math.abs(Math.max(Na.x,Na.y))}function NdA(i,A){const e=i.matrixWorld,g=i.geometry,I=g.attributes.instanceStart,o=g.attributes.instanceEnd,s=Math.min(g.instanceCount,I.count);for(let n=0,a=s;n<a;n++){EI.start.fromBufferAttribute(I,n),EI.end.fromBufferAttribute(o,n),EI.applyMatrix4(e);const r=new S,C=new S;Fa.distanceSqToSegment(EI.start,EI.end,C,r),C.distanceTo(r)<_h*.5&&A.push({point:C,pointOnLine:r,distance:Fa.origin.distanceTo(C),object:i,face:null,faceIndex:n,uv:null,uv1:null})}}function FdA(i,A,e){const g=A.projectionMatrix,I=i.material.resolution,o=i.matrixWorld,s=i.geometry,n=s.attributes.instanceStart,a=s.attributes.instanceEnd,r=Math.min(s.instanceCount,n.count),C=-A.near;Fa.at(1,Ua),Ua.w=1,Ua.applyMatrix4(A.matrixWorldInverse),Ua.applyMatrix4(g),Ua.multiplyScalar(1/Ua.w),Ua.x*=I.x/2,Ua.y*=I.y/2,Ua.z=0,kJ.copy(Ua),MJ.multiplyMatrices(A.matrixWorldInverse,o);for(let Q=0,h=r;Q<h;Q++){if(QI.fromBufferAttribute(n,Q),hI.fromBufferAttribute(a,Q),QI.w=1,hI.w=1,QI.applyMatrix4(MJ),hI.applyMatrix4(MJ),QI.z>C&&hI.z>C)continue;if(QI.z>C){const u=QI.z-hI.z,D=(QI.z-C)/u;QI.lerp(hI,D)}else if(hI.z>C){const u=hI.z-QI.z,D=(hI.z-C)/u;hI.lerp(QI,D)}QI.applyMatrix4(g),hI.applyMatrix4(g),QI.multiplyScalar(1/QI.w),hI.multiplyScalar(1/hI.w),QI.x*=I.x/2,QI.y*=I.y/2,hI.x*=I.x/2,hI.y*=I.y/2,EI.start.copy(QI),EI.start.z=0,EI.end.copy(hI),EI.end.z=0;const E=EI.closestPointToPointParameter(kJ,!0);EI.at(E,QW);const c=ct.lerp(QI.z,hI.z,E),l=c>=-1&&c<=1,d=kJ.distanceTo(QW)<_h*.5;if(l&&d){EI.start.fromBufferAttribute(n,Q),EI.end.fromBufferAttribute(a,Q),EI.start.applyMatrix4(o),EI.end.applyMatrix4(o);const u=new S,D=new S;Fa.distanceSqToSegment(EI.start,EI.end,D,u),e.push({point:D,pointOnLine:u,distance:Fa.origin.distanceTo(D),object:i,face:null,faceIndex:Q,uv:null,uv1:null})}}}class vdA extends dA{constructor(A=new rW,e=new fJ({color:Math.random()*16777215})){super(A,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const A=this.geometry,e=A.attributes.instanceStart,g=A.attributes.instanceEnd,I=new Float32Array(2*e.count);for(let s=0,n=0,a=e.count;s<a;s++,n+=2)CW.fromBufferAttribute(e,s),BW.fromBufferAttribute(g,s),I[n]=n===0?0:I[n-1],I[n+1]=I[n]+CW.distanceTo(BW);const o=new G0(I,2,1);return A.setAttribute("instanceDistanceStart",new qo(o,1,0)),A.setAttribute("instanceDistanceEnd",new qo(o,1,1)),this}raycast(A,e){const g=this.material.worldUnits,I=A.camera;I===null&&!g&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=A.params.Line2!==void 0&&A.params.Line2.threshold||0;Fa=A.ray;const s=this.matrixWorld,n=this.geometry,a=this.material;_h=a.linewidth+o,n.boundingSphere===null&&n.computeBoundingSphere(),lk.copy(n.boundingSphere).applyMatrix4(s);let r;if(g)r=_h*.5;else{const Q=Math.max(I.near,lk.distanceToPoint(Fa.origin));r=hW(I,Q,a.resolution)}if(lk.radius+=r,Fa.intersectsSphere(lk)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),ck.copy(n.boundingBox).applyMatrix4(s);let C;if(g)C=_h*.5;else{const Q=Math.max(I.near,ck.distanceToPoint(Fa.origin));C=hW(I,Q,a.resolution)}ck.expandByScalar(C),Fa.intersectsBox(ck)!==!1&&(g?NdA(this,e):FdA(this,I,e))}}class EW extends rW{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(A){const e=A.length-3,g=new Float32Array(2*e);for(let I=0;I<e;I+=3)g[2*I]=A[I],g[2*I+1]=A[I+1],g[2*I+2]=A[I+2],g[2*I+3]=A[I+3],g[2*I+4]=A[I+4],g[2*I+5]=A[I+5];return super.setPositions(g),this}setColors(A){const e=A.length-3,g=new Float32Array(2*e);for(let I=0;I<e;I+=3)g[2*I]=A[I],g[2*I+1]=A[I+1],g[2*I+2]=A[I+2],g[2*I+3]=A[I+3],g[2*I+4]=A[I+4],g[2*I+5]=A[I+5];return super.setColors(g),this}fromLine(A){const e=A.geometry;return this.setPositions(e.attributes.position.array),this}}class KdA extends vdA{constructor(A=new EW,e=new fJ({color:Math.random()*16777215})){super(A,e),this.isLine2=!0,this.type="Line2"}}class dk extends bA{}var bdA=Object.defineProperty,JdA=Object.getOwnPropertyDescriptor,Th=(i,A,e,g)=>{for(var I=g>1?void 0:g?JdA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&bdA(A,e,I),I};const cW=iA("debugwebxr");class Hs extends bA{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",A=>A.type==="SkinnedMesh"?"continue in children":!0)}onUpdateXR(A){const e=A.xr.rig;if(!(e!=null&&e.gameObject)||A.xr.isPassThrough)return;const g=A.xr.leftController,I=A.xr.rightController;g&&this.onHandleMovement(g,e.gameObject),I&&(this.onHandleRotation(I,e.gameObject),this.useTeleport&&this.onHandleTeleport(I,e.gameObject))}onLeaveXR(A){for(const e of this._lines)e.removeFromParent();for(const e of this._hitDiscs)e?.removeFromParent()}onBeforeRender(){var A;(A=this.context.xr)!=null&&A.running&&(this.showRays&&this.renderRays(this.context.xr),this.showHits&&this.renderHits(this.context.xr))}onHandleMovement(A,e){const g=A.getStick("xr-standard-thumbstick"),I=new S(g.x,0,g.y);I.multiplyScalar(this.context.time.deltaTimeUnscaled*this.movementSpeed);const o=zt(e);I.multiplyScalar(o.x),I.applyQuaternion(A.xr.poseOrientation),I.y=0,I.applyQuaternion(e.worldQuaternion),e.position.add(I),e.updateMatrixWorld()}onHandleRotation(A,e){const g=A.getStick("xr-standard-thumbstick").x;if(this._didApplyRotation)Math.abs(g)<.3&&(this._didApplyRotation=!1);else if(Math.abs(g)>.5){this._didApplyRotation=!0;const I=g>0?1:-1;e.rotateY(I*ge.toRadians(this.rotationStep))}}onHandleTeleport(A,e){var g;const I=A.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(A.ray)[0];let s=o?.point;if(!s){this._plane||(this._plane=new SI(new S(0,1,0),0));const n=e.worldPosition;this._plane.setFromNormalAndCoplanarPoint(new S(0,1,0),n);const a=A.ray;s=n.clone(),this._plane.intersectLine(new U0(a.origin,lt(a.direction).multiplyScalar(1e4).add(a.origin)),s),s.distanceTo(n)>e.scale.x*10&&(s=null)}if(s){if(this.useTeleportTarget&&!gA.getComponentInParent(o.object,dk))return;cW&&pe.DrawSphere(s,.025,16711680,5);const n=s.clone();this.useTeleportFade?(g=A.xr.fadeTransition())==null||g.then(()=>{e.worldPosition=n}):e.worldPosition=n}}}renderRays(A){for(let e=0;e<this._lines.length;e++){const g=this._lines[e];g&&(g.visible=!1)}for(let e=0;e<A.controllers.length;e++){const g=A.controllers[e];let I=this._lines[e];if(!g.connected||!g.isTracking||!g.ray||g.targetRayMode==="transient-pointer"||!g.hasSelectEvent){I&&(I.visible=!1);continue}I||(I=this.createRayLineObject(),I.scale.z=.5,this._lines[e]=I),g.updateRayWorldPosition(),g.updateRayWorldQuaternion();const o=g.rayWorldPosition,s=g.rayWorldQuaternion;I.position.copy(o),I.quaternion.copy(s);const n=A.rigScale,a=this._hitDistances[e]??n;I.scale.set(n,n,a),I.visible=!0,I.layers.disableAll(),I.layers.enable(2),I.parent!==this.context.scene&&this.context.scene.add(I)}}renderHits(A){for(const e of this._hitDiscs){if(!e)continue;const g=e.controller;if(!g||!g.connected||!g.isTracking){e.visible=!1;continue}}for(let e=0;e<A.controllers.length;e++){const g=A.controllers[e];if(!g.connected||!g.isTracking||!g.ray||!g.hasSelectEvent)continue;const I=this.context.time.smoothedFps>=59?1:10;if((this.context.time.frame+g.index)%I!==0){const n=this._hitDiscs[e];n&&n.hit&&(n.visible=!0,this.hitPointerSetPosition(g,n,n.hit.distance));continue}const o=this.context.physics.raycastFromRay(g.ray,{testObject:this.hitPointRaycastFilter})[0];this._hitDistances[e]=o?.distance;let s=this._hitDiscs[e];if(s&&(s.controller=g,s.hit=o),o){const n=A.rigScale??1;cW&&(pe.DrawWireSphere(o.point,.025*n,16711680),pe.DrawLabel(lt(0,.2,0).add(o.point),o.object.name,.02,0)),s||(s=this.createHitPointObject(),this._hitDiscs[e]=s),s.visible=!0;const a=.01*(n+o.distance);if(s.scale.set(a,a,a),s.layers.disableAll(),s.layers.enable(2),s.hit=o,o.normal){this.hitPointerSetPosition(g,s,o.distance);const r=o.normal.applyQuaternion(Nt(o.object));s.quaternion.setFromUnitVectors(xdA,r)}else this.hitPointerSetPosition(g,s,o.distance);s.parent!==this.context.scene&&this.context.scene.add(s)}else this._hitDiscs[e]&&(this._hitDiscs[e].visible=!1)}}hitPointerSetPosition(A,e,g){e.position.copy(A.rayWorldPosition),e.position.add(lt(0,0,g-.01).applyQuaternion(A.rayWorldQuaternion))}createHitPointObject(){var A=new wA;const e=new dA(new Vs(.3,6,6),new tt({color:15658734,opacity:.7,transparent:!0,depthTest:!1,side:yt}));return e.layers.disableAll(),e.layers.enable(2),A.add(e),A}createRayLineObject(){const A=new KdA;A.layers.disableAll(),A.layers.enable(2);const e=new EW;A.geometry=e;const g=new Float32Array(9);g.set([0,0,.02,0,0,.4,0,0,1]),e.setPositions(g);const I=new Float32Array(9);I.set([1,1,1,.1,.1,.1,0,0,0]),e.setColors(I);const o=new fJ({color:16777215,vertexColors:!0,worldUnits:!0,linewidth:.004,transparent:!0,blending:iQ,dashed:!1,alphaToCoverage:!0});return A.material=o,A}}Th([y()],Hs.prototype,"movementSpeed",2),Th([y()],Hs.prototype,"rotationStep",2),Th([y()],Hs.prototype,"useTeleport",2),Th([y()],Hs.prototype,"useTeleportTarget",2),Th([y()],Hs.prototype,"useTeleportFade",2),Th([y()],Hs.prototype,"showRays",2),Th([y()],Hs.prototype,"showHits",2);const xdA=new S(0,1,0);var qdA=Object.defineProperty,LdA=Object.getOwnPropertyDescriptor,No=(i,A,e,g)=>{for(var I=g>1?void 0:g?LdA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&qdA(A,e,I),I};const YD=iA("debugwebxr"),_dA=iA("debugusdz");class _g extends bA{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",A=>{YD&&console.log("WebXR.onAvatarSpawned",A),gA.getComponentInChildren(A,SB)??(t=gA.addComponent(A,SB))}),B(this,"_buttonFactory"),B(this,"_buttons",[])}awake(){me.getXRSync(this.context)}onEnable(){var A,e;window.location.protocol!=="https:"&&Lt('<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&&(gA.findObjectOfType(qi)||(YD&&console.log("WebXR: Adding USDZExporter"),this._usdzExporter=gA.addComponent(this.gameObject,qi),this._usdzExporter.objectToExport=this.context.scene,this._usdzExporter.autoExportAnimations=!0,this._usdzExporter.autoExportAudioSources=!0)),this.handleCreatingHTML(),this.handleOfferSession(),this.defaultAvatar||(YD&&console.warn("WebXR: No default avatar set, using static default avatar"),this.defaultAvatar=new gt("https://cdn.needle.tools/static/avatars/DefaultAvatar.glb")),this.defaultAvatar&&(this._playerSync=this.gameObject.getOrAddComponent(Dl),this._playerSync.autoSync=!1),this._playerSync&&(this._playerSync.asset=this.defaultAvatar,(A=this._playerSync.onPlayerSpawned)==null||A.removeEventListener(this.onAvatarSpawned),(e=this._playerSync.onPlayerSpawned)==null||e.addEventListener(this.onAvatarSpawned))}onDisable(){var A;(A=this._usdzExporter)==null||A.destroy(),this.removeButtons()}async handleOfferSession(){return this.createVRButton&&await me.isVRSupported()&&this.createVRButton?me.offerSession("immersive-vr","default",this.context):this.createARButton&&await me.isARSupported()&&this.createARButton?me.offerSession("immersive-ar","default",this.context):!1}get session(){return me.active??null}get sessionMode(){return me.activeMode??null}async enterVR(A){return me.start("immersive-vr",A,this.context)}async enterAR(A){return me.start("immersive-ar",A,this.context)}exitXR(){me.stop()}onBeforeXR(A,e){A=="immersive-ar"&&this.useDepthSensing&&(e.optionalFeatures=e.optionalFeatures||[],e.optionalFeatures.push("depth-sensing"))}async onEnterXR(A){YD&&console.log("WebXR onEnterXR"),this._previousXRState=ao.Global.Mask;const e=A.xr.isVR;if(ao.Global.Set(e?ua.VR:ua.AR),this.usePlacementReticle&&A.xr.isAR){let I=gA.findObjectOfType(Co);if(I)YD&&console.log("WebXR: WebARSessionRoot already exists, not creating a new one");else{const o=new wA;for(const s of this.context.scene.children)o.add(s);this.context.scene.add(o),I=gA.addComponent(o,Co),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 g=gA.findObjectOfType(iD);g||(g=this.gameObject.addNewComponent(iD)),this.createLocalAvatar(A.xr)}onLeaveXR(A){var e;ao.Global.Set(this._previousXRState),(e=this._playerSync)==null||e.destroyInstance();for(const g of this._createdComponentsInSession)g.destroy();this._createdComponentsInSession.length=0,this.handleOfferSession()}setDefaultMovementEnabled(A){let e=this.gameObject.getComponent(Hs);return!e&&A&&(e=this.gameObject.addComponent(Hs),this._createdComponentsInSession.push(e)),e&&(e.enabled=A),e}setDefaultControllerRenderingEnabled(A){let e=this.gameObject.getComponent(Ra);return!e&&A&&(e=this.gameObject.addComponent(Ra),this._createdComponentsInSession.push(e),e.createControllerModel=this.showControllerModels,e.createHandModel==this.showHandModels),e&&(e.enabled=A),e}async createLocalAvatar(A){this._playerSync&&A.running&&(this._playerSync.asset=this.defaultAvatar,await this._playerSync.getInstance())}getButtonsContainer(){return this.getButtonsFactory()}getButtonsFactory(){return this._buttonFactory||(this._buttonFactory=Lh.getOrCreate()),this._buttonFactory}handleCreatingHTML(){if(this.createARButton||this.createVRButton||this.useQuicklookExport){if((xQ()&&oc()||_dA)&&this.useQuicklookExport){const A=gA.findObjectOfType(qi);if(!A||A&&A.allowCreateQuicklookButton){const e=this.getButtonsFactory().createQuicklookButton();this.addButton(e,50)}}if(this.createARButton){const A=this.getButtonsFactory().createARButton();this.addButton(A,50)}if(this.createVRButton){const A=this.getButtonsFactory().createVRButton();this.addButton(A,50)}}if(this.createSendToQuestButton&&!T0()&&me.isVRSupported().then(A=>{if(!A){const e=this.getButtonsFactory().createSendToQuestButton();this.addButton(e,50)}}),this.createQRCode&&!ls()){const A=pf(Ma);A&&A.createQRCodeButton===!1?se()&&console.warn("WebXR: QRCode button is disabled in the Needle Menu component"):me.isXRSupported().then(e=>{if(bQ()||!e){const g=Fr.getOrCreate().createQRCode();this.addButton(g,50)}})}}addButton(A,e){this._buttons.push(A),A.setAttribute("priority",e.toString()),this.context.menu.appendChild(A)}removeButtons(){for(const A of this._buttons)A.remove();this._buttons.length=0}}No([y()],_g.prototype,"createVRButton",2),No([y()],_g.prototype,"createARButton",2),No([y()],_g.prototype,"createSendToQuestButton",2),No([y()],_g.prototype,"createQRCode",2),No([y()],_g.prototype,"useDefaultControls",2),No([y()],_g.prototype,"showControllerModels",2),No([y()],_g.prototype,"showHandModels",2),No([y()],_g.prototype,"usePlacementReticle",2),No([y()],_g.prototype,"usePlacementAdjustment",2),No([y()],_g.prototype,"arSceneScale",2),No([y()],_g.prototype,"useXRAnchor",2),No([y()],_g.prototype,"useQuicklookExport",2),No([y()],_g.prototype,"useDepthSensing",2),No([y(gt)],_g.prototype,"defaultAvatar",2);class uk{get extensionName(){return"Physics"}onExportObject(A,e,g){const I=gA.getComponents(A,_t).filter(a=>a.enabled),o=gA.getComponents(A,$o).filter(a=>a.enabled&&!a.isTrigger);let s=I.length>0?I[0]:null;const n=o.length>0?o[0]:null;n&&!s&&(s=new _t,s.isKinematic=!0),s&&e.addEventListener("serialize",(a,r)=>{var C,Q,h;if(s){if(a.appendLine(),a.beginBlock('def RealityKitComponent "RigidBody"',"{",!0),s.useGravity||a.appendLine("bool gravityEnabled = 0"),a.appendLine('uniform token info:id = "RealityKit.RigidBody"'),s.isKinematic&&a.appendLine('token motionType = "Kinematic"'),a.beginBlock('def RealityKitStruct "massFrame"',"{",!0),a.appendLine(`float m_mass = ${s.mass}`),a.beginBlock('def RealityKitStruct "m_pose"',"{",!0),a.appendLine(`float3 position = (${s.centerOfMass.x}, ${s.centerOfMass.y}, ${s.centerOfMass.z})`),a.closeBlock("}"),a.closeBlock("}"),o.length>0){const E=o[0];a.beginBlock('def RealityKitStruct "material"',"{",!0);const c=E.sharedMaterial;c&&c.dynamicFriction!==void 0&&a.appendLine(`double dynamicFriction = ${(C=E.sharedMaterial)==null?void 0:C.dynamicFriction}`),c&&c.bounciness!==void 0&&a.appendLine(`double restitution = ${(Q=E.sharedMaterial)==null?void 0:Q.bounciness}`),c&&c.staticFriction!==void 0&&a.appendLine(`double staticFriction = ${(h=E.sharedMaterial)==null?void 0:h.staticFriction}`),a.closeBlock("}")}a.closeBlock("}")}}),n&&(e.addEventListener("serialize",(a,r)=>{var C;a.beginBlock('def RealityKitComponent "Collider"',"{",!0),a.appendLine("uint group = 1"),a.appendLine('uniform token info:id = "RealityKit.Collider"'),a.appendLine("uint mask = 4294967295");const Q=n.isTrigger?"Trigger":"Default";if(a.appendLine(`token type = "${Q}"`),a.beginBlock('def RealityKitStruct "Shape"',"{",!0),n instanceof fl){const h=n;a.appendLine('token shapeType = "Sphere"'),a.appendLine(`float radius = ${h.radius}`)}else if(n instanceof kl){const h=n;a.appendLine('token shapeType = "Box"'),a.appendLine(`float3 extent = (${h.size.x}, ${h.size.y}, ${h.size.z})`)}else if(n instanceof Lr){const h=n;a.appendLine('token shapeType = "Capsule"'),a.appendLine(`float radius = ${h.radius}`),a.appendLine(`float height = ${h.height}`)}else if(n instanceof Rh&&(C=n.sharedMesh)!=null&&C.geometry){const h=n.sharedMesh.geometry;h.boundingBox||h.computeBoundingBox();const E=n.sharedMesh.geometry.boundingBox;E&&(a.appendLine('token shapeType = "Box"'),a.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",n))}else console.warn("[USDZ] Only Box, Sphere, and Capsule colliders are supported in visionOS/iOS. Ignoring collider:",n);a.beginBlock('def RealityKitStruct "pose"',"{",!0),a.closeBlock("}"),a.closeBlock("}"),a.closeBlock("}")}),o.length>1&&console.log("WARNING: Multiple colliders detected. visionOS / iOS can only support objects with a single collider, only exporting the first collider: ",n))}}var TdA=Object.defineProperty,YdA=Object.getOwnPropertyDescriptor,Zr=(i,A,e,g)=>{for(var I=g>1?void 0:g?YdA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&TdA(A,e,I),I};const Yh=iA("debugtext");var yg=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(yg||{}),lW=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(lW||{});class _I extends Nh{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 fA(1,0,1)),B(this,"_text",""),B(this,"_fontSize",12),B(this,"_textMeshUi",null),B(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(A){var e;super.setAlphaFactor(A),(e=this.uiObject)==null||e.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(A){A!==this._text&&(this._text=A,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(A){this.text=A}get fontSize(){return this._fontSize}set fontSize(A){var e;this._fontSize=A,(e=this.uiObject)==null||e.set({fontSize:A})}onColorChanged(){var A;this.sRGBTextColor.copy(this.color),this.sRGBTextColor.convertLinearToSRGB(),(A=this.uiObject)==null||A.set({color:this.sRGBTextColor,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeCanvasRender(A){this.updateOverflow()}updateOverflow(){var A;const e=(A=this.uiObject)==null?void 0:A._overflow;e&&(e._needsUpdate=!0,this.markDirty())}onCreate(A){Yh&&console.log(this),this.horizontalOverflow==1&&(A.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,A.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,A.lineHeight=this.lineSpacing,delete A.backgroundOpacity,delete A.backgroundColor,Yh&&(A.backgroundColor=16750848,A.backgroundOpacity=.5);const e=this.rectTransform;A={...A,...this.getTextOpts()},this.getAlignment(A),Yh&&(A.backgroundColor=Math.random()*16777215,A.backgroundOpacity=.1),this.uiObject=e.createNewText(A),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const A=this.fontSize,e={color:this.color,fontOpacity:this.color.alpha,fontSize:A,fontKerning:"normal"};return this.setFont(e,this.fontStyle),e}onEnable(){var A;super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10),(A=this.canvas)==null||A.registerEventReceiver(this)}onDisable(){var A;super.onDisable(),(A=this.canvas)==null||A.unregisterEventReceiver(this)}getAlignment(A){switch(A.flexDirection="column",this.alignment){case 0:case 3:case 6:A.textAlign="left";break;case 1:case 4:case 7:A.textAlign="center";break;case 2:case 5:case 8:A.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:A.alignItems="start";break;case 3:case 4:case 5:A.alignItems="center";break;case 6:case 7:case 8:A.alignItems="end";break}return A}feedText(A,e){var g,I,o;if(Yh&&console.log("feedText",this.uiObject,A,e),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!e||A.length===0)this.uiObject.textContent=A;else{let s=this.getNextTag(A);if(s){if(s.startIndex>0){for(let r=this.uiObject.children.length-1;r>=0;r--){const C=this.uiObject.children[r];C.isUI&&(this.uiObject.remove(C),C.clear())}const a=new tm({textContent:A.substring(0,s.startIndex),color:"inherit"});this.uiObject.add(a)}}else{this.uiObject.textContent="",this.setOptions({textContent:A});return}const n=[];for(;s;){const a=this.getNextTag(A,s.endIndex),r={fontFamily:(g=this.uiObject)==null?void 0:g.get("fontFamily"),color:"inherit",textContent:""};if(a){r.textContent=this.getText(A,s,a),this.handleTag(s,r,n);const C=new tm(r);(I=this.uiObject)==null||I.add(C)}else{r.textContent=A.substring(s.endIndex),this.handleTag(s,r,n);const C=new tm(r);(o=this.uiObject)==null||o.add(C)}s=a}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const A=[],e=this.canvas,g={renderOnTop:e.renderOnTop,depthWrite:e.depthWrite,doubleSided:e.doubleSided};for(;;){let I=!1;if(this._textMeshUi)for(let o=0;o<this._textMeshUi.length;o++){if(A[o]===!0)continue;I=!0;const s=this._textMeshUi[o];s.textContent&&(Mf(s,g),A[o]=!0)}if(!I)break;yield}}handleTag(A,e,g){if(!A.isEndTag){if(A.type.includes("color")){const I=new GJ(A,{color:e.color});if(g.push(I),A.type.length>6){const o=parseInt("0x"+A.type.substring(7));e.color=o}else e.color=new fA(1,1,1)}else if(A.type=="b"){this.setFont(e,1);const I=new GJ(A,{fontWeight:700});g.push(I)}else if(A.type=="i"){this.setFont(e,2);const I=new GJ(A,{fontStyle:"italic"});g.push(I)}}}getText(A,e,g){return A.substring(e.endIndex,g.startIndex)}getNextTag(A,e=0){const g=A.indexOf("<",e),I=A.indexOf(">",g);if(g>=0&&I>=0){const o=A.substring(g+1,I);return{type:o,startIndex:g,endIndex:I+1,isEndTag:o.startsWith("/")}}return null}setFont(A,e){if(!this.font)return;const g=this.font,I=this.getFamilyNameWithCorrectSuffix(g,e);Yh&&console.log("Selected font family:"+I);let o=kN.getFontFamily(I);switch(o||(o=kN.addFontFamily(I)),A.fontFamily=o,e){default:case 0:A.fontWeight=400,A.fontStyle="normal";break;case 1:A.fontWeight=700,A.fontStyle="normal";break;case 2:A.fontWeight=400,A.fontStyle="italic";break;case 3:A.fontStyle="italic",A.fontWeight=400}let s=o.getVariant(A.fontWeight,A.fontStyle);if(!s){let n=I;n!=null&&n.endsWith("-msdf.json")||(n+="-msdf.json");let a=I;a!=null&&a.endsWith(".png")||(a+=".png"),s=o.addVariant(A.fontWeight,A.fontStyle,n,a),s?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(A,e){var g;const I=A.lastIndexOf("-");if(I<0)return A;const o=(g=A.substring(I+1))==null?void 0:g.toLowerCase();if(HdA.includes(o))return Yh&&console.warn("Unsupported font style: "+o),A;const s=A.lastIndexOf("/");let n=A;s>=0&&(n=n.substring(s+1));const a=n[0]===n[0].toUpperCase(),r=A.substring(0,I);switch(Yh&&console.log("Select font: ",A,lW[e],n,a,r),e){case 0:return a?r+"-Regular":r+"-regular";case 1:return a?r+"-Bold":r+"-bold";case 2:return a?r+"-Italic":r+"-italic";case 3:return a?r+"-BoldItalic":r+"-bolditalic";default:return A}}}Zr([y()],_I.prototype,"alignment",2),Zr([y()],_I.prototype,"verticalOverflow",2),Zr([y()],_I.prototype,"horizontalOverflow",2),Zr([y()],_I.prototype,"lineSpacing",2),Zr([y()],_I.prototype,"supportRichText",2),Zr([y(URL)],_I.prototype,"font",2),Zr([y()],_I.prototype,"fontStyle",2),Zr([y()],_I.prototype,"text",1),Zr([y()],_I.prototype,"fontSize",1);class GJ{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 xB{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 g;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=[]),(g=this.font)==null||g.push("sans-serif"));const I=this.font.map(o=>`"${o}"`).join(", ");e.appendLine(`string[] font = [ ${I} ]`),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/${xv(this.material)}>`),e.closeBlock()}}B(xB,"global_id",0);class pk{static singleLine(A,e,g){const I=new xB("text_"+xB.getId());return I.content=A,e&&(I.pointSize=e),g&&(I.depth=g),I}static multiLine(A,e,g,I,o,s){const n=new xB("text_"+xB.getId());return n.content=A,n.width=e,n.height=g,n.horizontalAlignment=I,n.verticalAlignment=o,s!==void 0&&(n.wrapMode=s),n}}const OdA=new DA().makeRotationY(Math.PI),PdA=new DA().makeScale(-1,1,-1);class HD{get extensionName(){return"text"}exportText(A,e,g){const I=gA.getComponent(A,_I);if(!I)return;const o=gA.getComponent(A,qI);let s=100,n=100;o&&(s=o.width,n=o.height),e.matrix=OdA.clone(),o&&e.matrix.premultiply(PdA);const a=I.color.clone();e.material=new MI({color:a,emissive:a}),e.addEventListener("serialize",(r,C)=>{let Q=I.text;Q=Q.replace(/\r/g,""),Q=Q.replace(/\n/g,"\\n");const h=pk.multiLine(Q,s,n,"center","bottom","flowing");this.setTextAlignment(h,I.alignment),this.setOverflow(h,I),e.material&&(h.material=e.material),h.pointSize=this.convertToTextSize(I.fontSize),h.depth=.001,h.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 Dk{get extensionName(){return"tmui"}onExportObject(A,e,g){const I=gA.getComponent(A,aI);if(I&&I.enabled&&I.renderMode===b8.WorldSpace){const o=new HD,s=gA.getComponent(A,qI),n=gA.getComponent(A,GB),a=new Array;if(s){if(!gA.isActiveSelf(A)){const Q=gA.isActiveSelf(A);gA.setActive(A,!0),s.onEnable(),s.updateTransform(),a.push(()=>{s.onDisable(),gA.setActive(A,Q)})}A.traverse(Q=>{if(!gA.isActiveInHierarchy(Q)){const h=gA.isActiveSelf(Q);gA.setActive(Q,!0);const E=gA.getComponent(Q,$s);E&&(E.onEnable(),a.push(()=>{E.onDisable()}));const c=gA.getComponent(Q,qI);c&&(c.onEnable(),c.updateTransform(),c.onApplyTransform(),a.push(()=>{c.onDisable()}));const l=gA.getComponent(Q,_I);l&&(l.onEnable(),a.push(()=>{l.onDisable()})),a.push(()=>{gA.setActive(Q,h)})}}),s.width,s.height;const r=eo.createEmpty(),C=s.shadowComponent;if(e.add(r),C){const Q=C.matrix;r.matrix.copy(Q);const h=new Map,E=new Map;h.set(C,r),E.set(C,n?n.alpha:1),C.traverse(c=>{if(c===C)return;const l=eo.createEmpty();l.matrix.copy(c.matrix);const d=c.parent,u=!!d&&typeof d.textContent=="string"&&d.textContent.length>0;let D=E.get(d)||1;const p=gA.getComponent(c,GB);if(p&&(D*=p.alpha),c instanceof dA&&u){const f=c[Js];f?o.exportText(f.gameObject,l,g):console.error("Error when exporting UI: shadow component owner not found. This is likely a bug.",c)}if(c instanceof dA&&!u){const f=c.geometry.clone();f.scale(1,1,-1),this.flipWindingOrder(f),l.geometry=f;const G=new fA,M=c.material.opacity;G.copy(c.material.color),l.material=new tt({color:G,opacity:M*D,map:c.material.map,transparent:!0})}h.set(c,l),E.set(c,D);const w=h.get(d);if(!w){console.error("Error when exporting UI: shadow component parent not found!",c,c.parent);return}w.add(l)})}}for(const r of a)r()}}flipWindingOrder(A){const e=A.index.array;for(let g=0,I=e.length/3;g<I;g++){const o=e[g*3];e[g*3]=e[g*3+2],e[g*3+2]=o}A.index.needsUpdate=!0}}const OD=iA("debugusdz");function jdA(i,A){var e;const g=[],I=gA.getComponentsInChildren(i,II),o=gA.getComponentsInChildren(i,JI),s=new Array,n=new Array;if(A.injectImplicitBehaviours)for(const a of I){if(!a||!a.runtimeAnimatorController||!a.enabled)continue;const r=a.runtimeAnimatorController.activeState;if(!r||!r.motion||!r.motion.clip||((e=r.motion.clip.tracks)==null?void 0:e.length)<1||s.includes(a))continue;const C=new bh;C.animator=a,C.stateName=r.name,C.trigger="start",C.name="PlayAnimationOnClick_implicitAtStart_"+C.stateName;const Q=new wA;gA.addComponent(Q,C),n.push(Q),s.push(a),i.add(Q)}else for(const a of I){if(!a||!a.runtimeAnimatorController||!a.enabled)continue;OD&&console.log(a);const r=[];for(const C of a.runtimeAnimatorController.enumerateActions()){OD&&console.log(C);const Q=C.getClip();r.includes(Q)||r.push(Q)}g.push({root:a.gameObject,clips:r})}if(A.injectImplicitBehaviours)for(const a of o){if(!a||!a.clip||!a.enabled||!a.playAutomatically||s.includes(a))continue;const r=new bh;r.animation=a,r.stateName=a.clip.name,r.trigger="start",r.name="PlayAnimationOnClick_implicitAtStart_"+r.stateName;const C=new wA;gA.addComponent(C,r),n.push(C),s.push(a),i.add(C)}else for(const a of o){OD&&console.log(a);const r=[];for(const C of a.animations)r.includes(C)||r.push(C);g.push({root:a.gameObject,clips:r})}OD&&g?.length>0&&console.log("USDZ Animation Clips without behaviours",g);for(const a of g)for(const r of a.clips)A.registerAnimation(a.root,r);return n}function WdA(i,A){const e=gA.getComponentsInChildren(i,bi),g=gA.getComponentsInChildren(i,RB),I=new Array,o=new Array;OD&&console.log({audioSources:e,playAudioOnClicks:g});for(const s of g){if(!s.target)continue;const n=e.indexOf(s.target);n>-1&&e.splice(n,1)}for(const s of e){if(!s||!s.clip||s.volume<=0||I.includes(s))continue;const n=new RB;n.target=s,n.name="PlayAudioOnClick_implicitAtStart_",n.trigger="start";const a=new wA;gA.addComponent(a,n),console.log("implicit PlayAudioOnStart",a,n),o.push(a),I.push(s),i.add(a)}return o}function ZdA(i){return new Ug("DisableAtStart",Ng.sceneStartTrigger(),Dt.fadeAction(i,0,!1))}function dW(i){const A=i.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 g=document.createElement("button");g.id="open-in-ar",g.innerText="Open in QuickLook",e.appendChild(g);const I=document.createElement("a");I.id="needle-usdz-link",I.style.display="none",I.rel="ar",I.href="",e.appendChild(I);const o=document.createElement("img");return o.id="button",I.appendChild(o),i.domElement.shadowRoot.appendChild(e),I}var zdA=Object.defineProperty,VdA=Object.getOwnPropertyDescriptor,TI=(i,A,e,g)=>{for(var I=g>1?void 0:g?VdA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&zdA(A,e,I),I};const Os=iA("debugusdz");class qB{constructor(){B(this,"callToAction"),B(this,"checkoutTitle"),B(this,"checkoutSubtitle"),B(this,"callToActionURL")}}TI([y()],qB.prototype,"callToAction",2),TI([y()],qB.prototype,"checkoutTitle",2),TI([y()],qB.prototype,"checkoutSubtitle",2),TI([y()],qB.prototype,"callToActionURL",2);var wk;const RJ=(wk=class extends bA{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",i=>{i.preventDefault(),this.exportAndOpen()}),B(this,"_currentExportTasks",new Map),B(this,"_previousTimeScale",1),B(this,"lastCallback"),B(this,"_rootSessionRootWasAppliedTo",null),B(this,"_rootPositionBeforeExport",new S),B(this,"_rootRotationBeforeExport",new GA),B(this,"_rootScaleBeforeExport",new S)}start(){var i,A,e;Os&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",g=>{switch(g.key){case"t":this.exportAsync();break}}),ls()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((A=(i=this.objectToExport)==null?void 0:i.children)!=null&&A.length)&&!((e=this.objectToExport)!=null&&e.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Hf),this.extensions.push(new VB),this.extensions.push(new uk),this.extensions.push(new HD),this.extensions.push(new Dk))}onEnable(){var i;const A=xQ(),e=oc();(Os||A&&e)&&(this.allowCreateQuicklookButton&&(this.button=this.createQuicklookButton()),this.lastCallback=this.quicklookCallback.bind(this),this.link=dW(this.context),this.link.addEventListener("message",this.lastCallback)),Os&&Ci("USDZ Exporter enabled: "+this.name),(i=document.getElementById("open-in-ar"))==null||i.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var i,A,e;(i=this.button)==null||i.remove(),(A=this.link)==null||A.removeEventListener("message",this.lastCallback),Os&&Ci("USDZ Exporter disabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){return this.exportAndOpen()}async exportAndOpen(){var i;let A=this.exportFileName??((i=this.objectToExport)==null?void 0:i.name)??this.name;if(A+="-"+TO(),RC()||(A!==""&&(A+="-"),A+="MadeWithNeedle"),this.link||(this.link=dW(this.context)),this.customUsdzFile)return Os&&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?(Os&&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(i){if(!i)return console.warn("No object to export"),null;const A=this._currentExportTasks.get(i);if(A)return A;const e=this.internalExport(i);return e instanceof Promise?(this._currentExportTasks.set(i,e),e.then(g=>(this._currentExportTasks.delete(i),g)).catch(g=>(this._currentExportTasks.delete(i),console.error("Error during USDZ export \u2013 please report a bug!",g),null))):e}async internalExport(i){ot.start("export-usdz",{onProgress:d=>{this.dispatchEvent(new CustomEvent("export-progress",{detail:{progress:d}}))}}),ot.report("export-usdz",{message:"Starting export",totalSteps:40,currentStep:0}),ot.report("export-usdz",{message:"Load progressive textures",autoStep:5}),ot.start("export-usdz-textures","export-usdz");const A=gA.getComponentsInChildren(i,Ys);for(const d of A)d&&d.enabled&&d.start&&d.start();const e=gA.getComponentsInChildren(i,Ji),g=new Array;let I=0;for(const d of e){for(const u of d.sharedMeshes)if(u){const D=ut.assignMeshLOD(u,0);D instanceof Promise&&g.push(new Promise((p,w)=>{D.then(()=>{I++,ot.report("export-usdz-textures",{message:"Loaded progressive mesh",currentStep:I,totalSteps:g.length}),p()}).catch(f=>w(f))}))}for(const u of d.sharedMaterials)if(u){const D=ut.assignTextureLOD(u,0);D instanceof Promise&&g.push(new Promise((p,w)=>{D.then(()=>{I++,ot.report("export-usdz-textures",{message:"Loaded progressive texture",currentStep:I,totalSteps:g.length}),p()}).catch(f=>w(f))}))}}Os&&Ci("Progressive Loading: "+g.length),await Promise.all(g),Os&&Ci("Progressive Loading: done"),ot.end("export-usdz-textures");const o=ao.Global.Mask;ao.Global.Set(ua.AR);const s=new jO,n=new BD(this.quickLookCompatible),a=[n,...this.extensions],r={self:this,exporter:s,extensions:a,object:i};ot.report("export-usdz","Invoking before-export"),this.dispatchEvent(new CustomEvent("before-export",{detail:r})),this.applyWebARSessionRoot(),this._previousTimeScale=this.context.time.timeScale,this.context.time.timeScale=0,ot.report("export-usdz","auto export animations and audio sources");const C=new Array;this.autoExportAnimations&&C.push(...jdA(i,n)),this.extensions.find(d=>d.extensionName==="Audio")&&this.autoExportAudioSources&&C.push(...WdA(i)),s.debug=Os,s.keepObject=d=>{const u=gA.getComponent(d,Ji);return!(u&&!u.enabled)};const Q=new Array;this.objectToExport&&this.quickLookCompatible&&this.interactive&&this.objectToExport.traverse(d=>{d.visible||Q.push(d)});const h=this.extensions.find(d=>d.extensionName==="Behaviour");this.interactive&&h&&Q.length>0&&h.addBehavior(ZdA(Q));let E=!0;this.quickLookCompatible&&!this.interactive&&(E=!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"),ot.report("export-usdz","Invoking exporter.parse");const c=await s.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:this.quickLookCompatible,maxTextureSize:this.maxTextureSize,exportInvisible:E}),l=new Blob([c],{type:"model/vnd.usdz+zip"});this.revertWebARSessionRoot(),this.context.time.timeScale=this._previousTimeScale,ot.report("export-usdz","Invoking after-export"),this.dispatchEvent(new CustomEvent("after-export",{detail:r}));for(const d of C)gA.destroy(d);return ao.Global.Set(o),ot.end("export-usdz"),l}openInQuickLook(i,A){const e=i instanceof Blob?URL.createObjectURL(i):i,g=this.buildQuicklookOverlay();Os&&console.log("QuickLook Overlay",g);const I=g.callToAction?encodeURIComponent(g.callToAction):"",o=g.checkoutTitle?encodeURIComponent(g.checkoutTitle):"",s=g.checkoutSubtitle?encodeURIComponent(g.checkoutSubtitle):"";this.link.href=e+`#callToAction=${I}&checkoutTitle=${o}&checkoutSubtitle=${s}&callToActionURL=${g.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=A+".usdz",this.link.click()}download(i,A){RJ.save(i,A)}static save(i,A){const e=document.createElement("a");e.style.display="none",document.body.appendChild(e),typeof i=="string"?e.href=i:e.href=URL.createObjectURL(i),e.download=A,e.click(),e.remove()}quicklookCallback(i){if(i?.data=="_apple_ar_quicklook_button_tapped"){Os&&Lt("Quicklook closed via call to action button");var A=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(A),!A.defaultPrevented){const e=new URLSearchParams(this.link.href);if(e){const g=e.get("callToActionURL");Os&&Ci("Quicklook url: "+g),g&&(RC()?globalThis.open(g,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",g))}}}}buildQuicklookOverlay(){var i,A,e,g,I,o;const s={};return this.customBranding&&Object.assign(s,this.customBranding),RC()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),s.callToAction="Close",s.checkoutTitle="\u{1F335} Made with Needle",s.checkoutSubtitle="_"),(((i=s.callToAction)==null?void 0:i.length)||((A=s.checkoutTitle)==null?void 0:A.length)||((e=s.checkoutSubtitle)==null?void 0:e.length))&&((g=s.callToAction)!=null&&g.length||(s.callToAction="\0"),(I=s.checkoutTitle)!=null&&I.length||(s.checkoutTitle="\0"),(o=s.checkoutSubtitle)!=null&&o.length||(s.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:s})),s}getARScaleAndTarget(){if(!this.objectToExport)return{scale:1,_invertForward:!1,target:this.gameObject,sessionRoot:null};let i=gA.getComponentInParent(this.objectToExport,Co);i||(i=gA.getComponentInChildren(this.objectToExport,Co));let A=1,e=!1;const g=this.objectToExport;if(i)A=i.arScale,e=i.invertForward;else{const I=gA.findObjectOfType(_g);I&&(A=I.arSceneScale)}return{scale:1/A,_invertForward:e,target:g,sessionRoot:i?.gameObject??null}}applyWebARSessionRoot(){if(!this.objectToExport)return;const{scale:i,_invertForward:A,target:e,sessionRoot:g}=this.getARScaleAndTarget(),I=g?.matrixWorld.clone().invert();this._rootSessionRootWasAppliedTo=e,this._rootPositionBeforeExport.copy(e.position),this._rootRotationBeforeExport.copy(e.quaternion),this._rootScaleBeforeExport.copy(e.scale),e.scale.multiplyScalar(i),A&&e.quaternion.multiply(RJ.invertForwardQuaternion),e.updateMatrix(),e.updateMatrixWorld(!0),g&&I&&e.matrix.premultiply(I)}revertWebARSessionRoot(){if(!this.objectToExport||!this._rootSessionRootWasAppliedTo)return;const i=this._rootSessionRootWasAppliedTo;i.position.copy(this._rootPositionBeforeExport),i.quaternion.copy(this._rootRotationBeforeExport),i.scale.copy(this._rootScaleBeforeExport),i.updateMatrix(),i.updateMatrixWorld(!0),this._rootSessionRootWasAppliedTo=null}createQuicklookButton(){const i=Lh.getOrCreate().createQuicklookButton();return i.parentNode||this.context.menu.appendChild(i),i}},B(wk,"invertForwardMatrix",new DA().makeRotationY(Math.PI)),B(wk,"invertForwardQuaternion",new GA().setFromEuler(new It(0,Math.PI,0))),wk);let qi=RJ;TI([y(wA)],qi.prototype,"objectToExport",2),TI([y()],qi.prototype,"autoExportAnimations",2),TI([y()],qi.prototype,"autoExportAudioSources",2),TI([y()],qi.prototype,"exportFileName",2),TI([y(URL)],qi.prototype,"customUsdzFile",2),TI([y(qB)],qi.prototype,"customBranding",2),TI([y()],qi.prototype,"anchoringType",2),TI([y()],qi.prototype,"maxTextureSize",2),TI([y()],qi.prototype,"planeAnchoringAlignment",2),TI([y()],qi.prototype,"interactive",2),TI([y()],qi.prototype,"allowCreateQuicklookButton",2),TI([y()],qi.prototype,"quickLookCompatible",2);class PD extends bA{constructor(){super(...arguments),B(this,"isUsed",!0),B(this,"usedBy",null)}}class UJ extends bA{}const uW=iA("debugdeletable");class yk extends wa{}class NJ extends bA{constructor(){super(...arguments),B(this,"deleteBoxes",[])}awake(){this.deleteBoxes=gA.findObjectsOfType(yk,this.context)}update(){for(const A of this.deleteBoxes){const e=this.gameObject;if(A.isInBox(e)===!0){const g=gA.getComponentInParent(this.gameObject,PD);g?uW&&console.warn("Can not delete object with usage marker",this.guid,g):(uW&&console.log("DESTROY",this.gameObject),Hp(this.gameObject,this.context.connection))}}}}var XdA=Object.defineProperty,$dA=Object.getOwnPropertyDescriptor,Hh=(i,A,e,g)=>{for(var I=g>1?void 0:g?$dA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&XdA(A,e,I),I};const AuA=iA("debugpost");class vn extends oI{constructor(){super(...arguments),B(this,"mode"),B(this,"focusDistance",new zA(1)),B(this,"focalLength",new zA(.2)),B(this,"aperture",new zA(20)),B(this,"gaussianMaxRadius",new zA),B(this,"resolutionScale",new zA(1*1/window.devicePixelRatio)),B(this,"bokehScale",new zA)}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=e=>{const g=e/300,I=2;return ge.lerp(I,.01,g)};const A=20;this.aperture.valueProcessor=e=>{const g=1-e/32;return ge.lerp(1,A,g)}}onCreateEffect(){if(this.mode===0){AuA&&console.warn("DepthOfField: Mode is set to Off");return}const A=new HP(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=e=>{A.cocMaterial.worldFocusDistance=e},this.focalLength.onValueChanged=e=>A.cocMaterial.worldFocusRange=e,this.aperture.onValueChanged=e=>A.bokehScale=e,this.resolutionScale&&(this.resolutionScale.onValueChanged=e=>A.resolution.scale=e),[A]}unapply(){}}Hh([y()],vn.prototype,"mode",2),Hh([y(zA)],vn.prototype,"focusDistance",2),Hh([y(zA)],vn.prototype,"focalLength",2),Hh([y(zA)],vn.prototype,"aperture",2),Hh([y(zA)],vn.prototype,"gaussianMaxRadius",2),Hh([y(zA)],vn.prototype,"resolutionScale",2),Hh([y(zA)],vn.prototype,"bokehScale",2),Ls("DepthOfField",vn);var euA=Object.defineProperty,tuA=Object.getOwnPropertyDescriptor,iuA=(i,A,e,g)=>{for(var I=g>1?void 0:g?tuA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&euA(A,e,I),I};class mk extends bA{constructor(){super(...arguments),B(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||gA.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:ls()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}iuA([y()],mk.prototype,"visibleOn",2);class FJ{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(A){}}var guA=Object.defineProperty,IuA=Object.getOwnPropertyDescriptor,Oh=(i,A,e,g)=>{for(var I=g>1?void 0:g?IuA(A,e):A,o=i.length-1,s;o>=0;o--)(s=i[o])&&(I=(g?s(A,e,I):s(I))||I);return g&&I&&guA(A,e,I),I};const va=iA("debugdrag");var pW=(i=>(i[i.XZPlane=0]="XZPlane",i[i.Attached=1]="Attached",i[i.HitNormal=2]="HitNormal",i[i.DynamicViewAngle=3]="DynamicViewAngle",i[i.SnapToSurfaces=4]="SnapToSurfaces",i[i.None=5]="None",i))(pW||{}),Sk;const Ka=(Sk=class extends bA{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 S),B(this,"_marker",null),B(this,"_isDragging",!1),B(this,"_didDrag",!1)}static get HasAnySelected(){return this._active>0}setTargetObject(i){this.targetObject=i;for(const A of this._dragHandlers.values())A.setTargetObject(i)}awake(){this._potentialDragStartEvt=null,this._dragHandlers=new Map,this._totalMovement=new S,this._marker=null,this._isDragging=!1,this._didDrag=!1,this._dragHelper=null,this._draggingRigidbodies=[]}start(){this.orbit=gA.findObjectOfType(St,this.context),this.gameObject.getComponentInParent(Zo)||this.gameObject.addComponent(Zo)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||i.mode!=="screen"||(i.event.mode==="tracked-pointer"||i.event.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)return;const A=gA.getComponentInParent(i.object,Ka);!A||A!==this||(Ka.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&i.mode==="screen"&&Ka.lastHovered===i.object&&(this.context.domElement.style.cursor="auto")}onPointerDown(i){if(!(!this.allowEdit(this.gameObject)||i.used||(i.mode==="tracked-pointer"||i.mode==="transient-pointer"?this.xrDragMode:this.dragMode)===5)&&(Ka.lastHovered=i.object,i.button===0)){this._dragHandlers.size===0&&(this._didDrag=!1,this._totalMovement.set(0,0,0),this._potentialDragStartEvt=i),Ka._active+=1;const A=new suA(this,this.targetObject||this.gameObject);if(this._dragHandlers.set(i.event.space,A),this.orbit&&(this.orbit.enabled=!1),A.onDragStart(i),this._dragHandlers.size===2){const e=this._dragHandlers.values(),g=e.next().value,I=e.next().value,o=new ouA(this,this.targetObject||this.gameObject,g,I);this._dragHandlers.set(this.gameObject,o),o.onDragStart(i)}i.use()}}onPointerMove(i){(this._isDragging||this._potentialDragStartEvt!==null)&&i.use()}onPointerUp(i){if(va&&pe.DrawLabel(i.point??this.gameObject.worldPosition,"POINTERUP:"+i.pointerId+", "+i.button,.03,3),!this.allowEdit(this.gameObject)||i.button!==0)return;this._potentialDragStartEvt=null;const A=this._dragHandlers.get(i.event.space),e=this._dragHandlers.get(this.gameObject);e&&(e.handlerA===A||e.handlerB===A)&&(this._dragHandlers.delete(this.gameObject),e.onDragEnd(i)),A&&(Ka._active>0&&(Ka._active-=1),A.onDragEnd&&A.onDragEnd(i),this._dragHandlers.delete(i.event.space),this._dragHandlers.size===0&&this.onLastDragEnd(i),i.use()),Ka._active===0&&this.orbit&&(this.orbit.enabled=!0)}update(){for(const i of this._dragHandlers.values())i.collectMovementInfo&&i.collectMovementInfo(),i.getTotalMovement&&this._totalMovement.add(i.getTotalMovement());if(this._potentialDragStartEvt){if(!this._didDrag)if(this._totalMovement.length()>3e-4)this._didDrag=!0;else return;const i=this._potentialDragStartEvt;this._potentialDragStartEvt=null,this.onFirstDragStart(i)}for(const i of this._dragHandlers.values())i.onDragUpdate&&i.onDragUpdate(this._dragHandlers.size);this._dragHelper&&this._dragHelper.hasSelected&&this.onAnyDragUpdate()}onFirstDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new wW(this.context.mainCamera);else return;if(!i||!i.object)return;const A=gA.getComponentInParent(i.object,Ka);if(!A||A!==this&&A._isDragging)return;const e=this.targetObject||this.gameObject;if(!e)return;this._isDragging=!0,this._dragHelper.setSelected(e,this.context),this.orbit&&(this.orbit.enabled=!1);const g=gA.getComponentInChildren(e,cB);va&&console.log("DRAG START",g,e),g&&(g.fastMode=!0,g?.requestOwnership()),this._marker=gA.addComponent(e,PD),this._draggingRigidbodies.length=0;const I=gA.getComponentsInChildren(e,_t);I&&this._draggingRigidbodies.push(...I)}onAnyDragUpdate(){if(!this._dragHelper)return;this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.onUpdate(this.context);for(const A of this._draggingRigidbodies)A.wakeUp(),A.resetVelocities(),A.resetForcesAndTorques();const i=this.targetObject||this.gameObject;en.markDirty(i)}onLastDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const e of this._draggingRigidbodies)e.setVelocity(e.smoothedVelocity);this._draggingRigidbodies.length=0;const A=this._dragHelper.selected;if(va&&console.log("DRAG END",A,A?.visible),this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const e=gA.getComponentInChildren(i.object,cB);e&&(e.fastMode=!1)}this._marker&&this._marker.destroy()}},B(Sk,"_active",0),B(Sk,"lastHovered"),Sk);let Ps=Ka;Oh([y()],Ps.prototype,"dragMode",2),Oh([y()],Ps.prototype,"snapGridResolution",2),Oh([y()],Ps.prototype,"keepRotation",2),Oh([y()],Ps.prototype,"xrDragMode",2),Oh([y()],Ps.prototype,"xrKeepRotation",2),Oh([y()],Ps.prototype,"xrDistanceDragFactor",2),Oh([y()],Ps.prototype,"showGizmo",2);class ouA{constructor(A,e,g,I){B(this,"handlerA"),B(this,"handlerB"),B(this,"context"),B(this,"settings"),B(this,"gameObject"),B(this,"_handlerAAttachmentPoint",new S),B(this,"_handlerBAttachmentPoint",new S),B(this,"_followObject"),B(this,"_manipulatorObject"),B(this,"_deviceMode"),B(this,"_followObjectStartWorldQuaternion",new GA),B(this,"_manipulatorPosOffset",new S),B(this,"_manipulatorRotOffset",new GA),B(this,"_manipulatorScaleOffset",new S),B(this,"_tempVec1",new S),B(this,"_tempVec2",new S),B(this,"_tempVec3",new S),B(this,"tempLookMatrix",new DA),B(this,"_initialScale",new S),B(this,"_initialDistance",0);var o,s;this.context=A.context,this.settings=A,this.gameObject=e,this.handlerA=g,this.handlerB=I,this._followObject=new wA,this._manipulatorObject=new wA,this.context.scene.add(this._manipulatorObject);const n=(s=(o=me.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),n&&(n.worldToLocal(this._tempVec1),n.worldToLocal(this._tempVec2)),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.02?(va&&console.log("Finding alternative drag attachment points since initial distance is too low: "+this._initialDistance.toFixed(2)),this.handlerA.followObject.parent.getWorldPosition(this._tempVec1),this.handlerB.followObject.parent.getWorldPosition(this._tempVec2),this._handlerAAttachmentPoint.copy(this._tempVec1),this._handlerBAttachmentPoint.copy(this._tempVec2),this.gameObject.worldToLocal(this._handlerAAttachmentPoint),this.gameObject.worldToLocal(this._handlerBAttachmentPoint),this._initialDistance=this._tempVec1.distanceTo(this._tempVec2),this._initialDistance<.001&&(console.warn("Not supported right now \u2013 controller drag points for multitouch are too close!"),this._initialDistance=1)):(this._handlerAAttachmentPoint.copy(this.handlerA.hitPointInLocalSpace),this._handlerBAttachmentPoint.copy(this.handlerB.hitPointInLocalSpace)),this._tempVec3.lerpVectors(this._tempVec1,this._tempVec2,.5),this._initialScale.copy(e.scale),va){this._followObject.add(new _o(2)),this._manipulatorObject.add(new _o(5));const a=r=>`${r.x.toFixed(2)}, ${r.y.toFixed(2)}, ${r.z.toFixed(2)}`;pe.DrawLine(this._tempVec1,this._tempVec2,65535,0,!1),pe.DrawLabel(this._tempVec3,"A:B "+this._initialDistance.toFixed(2)+`
|
|
6214
6214
|
`+a(this._tempVec1)+`
|
|
6215
|
-
`+a(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),va&&(pe.DrawLabel(this._tempVec3.clone().add(new S(0,.2,0)),"A:B "+e.toFixed(2),.03),pe.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 g=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=g.worldPosition;n.lerp(I.worldPosition,s),g.worldPosition=n;const a=g.worldQuaternion;a.slerp(I.worldQuaternion,s),g.worldQuaternion=a;const r=g.worldScale;r.lerp(I.worldScale,s),g.worldScale=r}setTargetObject(A){this.gameObject=A}}class suA{constructor(A,e){B(this,"context"),B(this,"gameObject"),B(this,"settings"),B(this,"_lastRig"),B(this,"_followObject"),B(this,"_totalMovement",new S),B(this,"_totalMovementAlongRayDirection",0),B(this,"_grabStartDistance",0),B(this,"_deviceMode"),B(this,"_followObjectStartPosition",new S),B(this,"_followObjectStartQuaternion",new GA),B(this,"_followObjectStartWorldQuaternion",new GA),B(this,"_lastDragPosRigSpace"),B(this,"_tempVec",new S),B(this,"_tempMat",new DA),B(this,"_hitPointInLocalSpace",new S),B(this,"_hitNormalInLocalSpace",new S),B(this,"_bottomCenter",new S),B(this,"_backCenter",new S),B(this,"_backBottomCenter",new S),B(this,"_bounds",new kt),B(this,"_dragPlane",new SI(new S(0,1,0))),B(this,"_draggedOverObject",null),B(this,"_draggedOverObjectLastSetUp",null),B(this,"_draggedOverObjectLastNormal",new S),B(this,"_draggedOverObjectDuration",0),this.settings=A,this.context=A.context,this.gameObject=e,this._followObject=new wA}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(A){this.gameObject=A}recenter(){var A,e;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 g=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),g.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 I=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(I),this._grabStartDistance=I.distanceTo(g.worldPosition);const o=(e=(A=me.active)==null?void 0:A.rig)==null?void 0:e.gameObject,s=o?.worldScale.x||1;this._grabStartDistance/=s,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,va&&(pe.DrawLine(I,g.worldPosition,65280,.5,!1),pe.DrawLabel(g.worldPosition.add(new S(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 E=A.event.space,c=E.worldPosition;this.gameObject.worldToLocal(c),this._hitPointInLocalSpace.copy(c);const l=E.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),l.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(l)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const e=this._followObject.parent.worldForward,g=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,I=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(I),g){case 0:const E=new S(0,1,0);this.gameObject.parent&&E.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(E,I);break;case 2:const c=this._hitNormalInLocalSpace.clone();c.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(c,I);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(e,I);break;case 3:const l=new S(0,1,0),d=e,u=l.angleTo(d),D=.5;u>Math.PI/2+D||u<Math.PI/2-D?this._dragPlane.setFromNormalAndCoplanarPoint(new S(0,1,0),I):this._dragPlane.setFromNormalAndCoplanarPoint(e,I);break}const o=this.gameObject.parent,s=this.gameObject.position.clone(),n=this.gameObject.quaternion.clone(),a=this.gameObject.scale.clone(),r=this.gameObject.matrixWorld.clone();o&&o.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1);const C=$n([this.gameObject]);C.expandByPoint(this.gameObject.worldPosition);const Q=new S;C.getCenter(Q);const h=new S;C.getSize(h),this._bottomCenter.copy(Q.clone().add(new S(0,-h.y/2,0))),this._backCenter.copy(Q.clone().add(new S(0,0,h.z/2))),this._backBottomCenter.copy(Q.clone().add(new S(0,-h.y/2,h.z/2))),this._bounds.copy(C),o&&o.add(this.gameObject),this.gameObject.position.copy(s),this.gameObject.quaternion.copy(n),this.gameObject.scale.copy(a),this.gameObject.matrixWorld.copy(r),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var A,e;if(!this._followObject.parent)return;const g=this._followObject.parent;this._followObject.updateMatrix();const I=g.worldPosition,o=(e=(A=me.active)==null?void 0:A.rig)==null?void 0:e.gameObject;o&&o.worldToLocal(I),(this._lastDragPosRigSpace===void 0||o!=this._lastRig)&&(this._lastDragPosRigSpace=I.clone(),this._lastRig=o),this._tempVec.copy(I).sub(this._lastDragPosRigSpace);const s=g.worldForward;if(o&&(this._tempMat.copy(o.matrixWorld).invert(),s.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=s.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(I),va){let n=I;o&&(n=n.clone(),n.transformDirection(o.matrixWorld)),pe.DrawRay(n,s,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,g=this._followObject.parent;this._followObject.updateMatrix();const I=g.worldPosition,o=g.worldForward,s=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",n=s?this.settings.xrKeepRotation:this.settings.keepRotation,a=s?this.settings.xrDragMode:this.settings.dragMode;if(a===5)return;const r=10;n&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let C=1,Q=2;if(s&&this._grabStartDistance>.5){const d=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);C=Math.max(0,d),C=C*C*C}else this._grabStartDistance<=.5&&(Q=3);this._followObject.position.copy(this._followObjectStartPosition),n||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(C),this._followObject.updateMatrix();const h=new po(I,o);if(a==4){const d=new fn;d.testObject=D=>D!==this.followObject&&D!==g&&D!==e;const u=this.context.physics.raycastFromRay(h,d);if(u.length>0){const D=u[0];if(this._draggedOverObject===D.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=D.object,this._draggedOverObjectDuration=0),D.face){const p=this._draggedOverObjectDuration>=.15,w=.001,f=this._totalMovement.length()>=w;if((p||f)&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(D.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(D.face.normal);const G=lt(),M=lt();this._bounds.getCenter(G),this._bounds.getSize(M),G.sub(M.multiplyScalar(.5).multiply(D.face.normal)),this._hitPointInLocalSpace.copy(G),this._hitNormalInLocalSpace.copy(D.face.normal),this._bounds.getCenter(G),this._bounds.getSize(M),G.add(M.multiplyScalar(.5).multiply(D.face.normal));const U=lt(this._hitPointInLocalSpace).add(G);this._followObject.localToWorld(U);const v=D.point;this._dragPlane.setFromNormalAndCoplanarPoint(D.face.normal,v)}else if(!(p||f))return}}}if(a!==1&&h.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const d=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(d),va&&pe.DrawLine(d,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(d),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const d=this._followObject.worldPosition,u=this.settings.snapGridResolution;d.x=Math.round(d.x/u)*u,d.y=Math.round(d.y/u)*u,d.z=Math.round(d.z/u)*u,this._followObject.worldPosition=d,this._followObject.updateMatrix()}n&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const E=ge.clamp01(this.context.time.deltaTime*r*Q),c=e.worldPosition;c.lerp(this._followObject.worldPosition,E),e.worldPosition=c;const l=e.worldQuaternion;if(l.slerp(this._followObject.worldQuaternion,E),e.worldQuaternion=l,va){const d=this._hitPointInLocalSpace.clone();e.localToWorld(d),pe.DrawSphere(d,.02,16711680);const u=this._hitNormalInLocalSpace.clone();u.applyQuaternion(l),pe.DrawRay(d,u,16711680),pe.DrawLabel(c.add(new S(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6215
|
+
`+a(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),va&&(pe.DrawLabel(this._tempVec3.clone().add(new S(0,.2,0)),"A:B "+e.toFixed(2),.03),pe.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 g=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=g.worldPosition;n.lerp(I.worldPosition,s),g.worldPosition=n;const a=g.worldQuaternion;a.slerp(I.worldQuaternion,s),g.worldQuaternion=a;const r=g.worldScale;r.lerp(I.worldScale,s),g.worldScale=r}setTargetObject(A){this.gameObject=A}}class suA{constructor(A,e){B(this,"context"),B(this,"gameObject"),B(this,"settings"),B(this,"_lastRig"),B(this,"_followObject"),B(this,"_totalMovement",new S),B(this,"_totalMovementAlongRayDirection",0),B(this,"_grabStartDistance",0),B(this,"_deviceMode"),B(this,"_followObjectStartPosition",new S),B(this,"_followObjectStartQuaternion",new GA),B(this,"_followObjectStartWorldQuaternion",new GA),B(this,"_lastDragPosRigSpace"),B(this,"_tempVec",new S),B(this,"_tempMat",new DA),B(this,"_hitPointInLocalSpace",new S),B(this,"_hitNormalInLocalSpace",new S),B(this,"_bottomCenter",new S),B(this,"_backCenter",new S),B(this,"_backBottomCenter",new S),B(this,"_bounds",new kt),B(this,"_dragPlane",new SI(new S(0,1,0))),B(this,"_draggedOverObject",null),B(this,"_draggedOverObjectLastSetUp",null),B(this,"_draggedOverObjectLastNormal",new S),B(this,"_draggedOverObjectDuration",0),this.settings=A,this.context=A.context,this.gameObject=e,this._followObject=new wA}getTotalMovement(){return this._totalMovement}get followObject(){return this._followObject}get hitPointInLocalSpace(){return this._hitPointInLocalSpace}setTargetObject(A){this.gameObject=A}recenter(){var A,e;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 g=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),g.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 I=this._hitPointInLocalSpace.clone();this.gameObject.localToWorld(I),this._grabStartDistance=I.distanceTo(g.worldPosition);const o=(e=(A=me.active)==null?void 0:A.rig)==null?void 0:e.gameObject,s=o?.worldScale.x||1;this._grabStartDistance/=s,this._totalMovementAlongRayDirection=0,this._lastDragPosRigSpace=void 0,va&&(pe.DrawLine(I,g.worldPosition,65280,.5,!1),pe.DrawLabel(g.worldPosition.add(new S(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 E=A.event.space,c=E.worldPosition;this.gameObject.worldToLocal(c),this._hitPointInLocalSpace.copy(c);const l=E.worldUp;this._tempMat.copy(this.gameObject.matrixWorld).invert(),l.transformDirection(this._tempMat),this._hitNormalInLocalSpace.copy(l)}this.recenter(),this._totalMovement.set(0,0,0),this._deviceMode=A.mode;const e=this._followObject.parent.worldForward,g=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer"?this.settings.xrDragMode:this.settings.dragMode,I=this._hitPointInLocalSpace.clone();switch(this.gameObject.localToWorld(I),g){case 0:const E=new S(0,1,0);this.gameObject.parent&&E.transformDirection(this.gameObject.parent.matrixWorld.clone().invert()),this._dragPlane.setFromNormalAndCoplanarPoint(E,I);break;case 2:const c=this._hitNormalInLocalSpace.clone();c.transformDirection(this.gameObject.matrixWorld),this._dragPlane.setFromNormalAndCoplanarPoint(c,I);break;case 1:this._dragPlane.setFromNormalAndCoplanarPoint(e,I);break;case 4:case 3:const l=new S(0,1,0),d=e,u=l.angleTo(d),D=.5;u>Math.PI/2+D||u<Math.PI/2-D?this._dragPlane.setFromNormalAndCoplanarPoint(new S(0,1,0),I):this._dragPlane.setFromNormalAndCoplanarPoint(e,I);break}const o=this.gameObject.parent,s=this.gameObject.position.clone(),n=this.gameObject.quaternion.clone(),a=this.gameObject.scale.clone(),r=this.gameObject.matrixWorld.clone();o&&o.remove(this.gameObject),this.gameObject.position.set(0,0,0),this.gameObject.quaternion.set(0,0,0,1),this.gameObject.scale.set(1,1,1);const C=$n([this.gameObject]);C.expandByPoint(this.gameObject.worldPosition);const Q=new S;C.getCenter(Q);const h=new S;C.getSize(h),this._bottomCenter.copy(Q.clone().add(new S(0,-h.y/2,0))),this._backCenter.copy(Q.clone().add(new S(0,0,h.z/2))),this._backBottomCenter.copy(Q.clone().add(new S(0,-h.y/2,h.z/2))),this._bounds.copy(C),o&&o.add(this.gameObject),this.gameObject.position.copy(s),this.gameObject.quaternion.copy(n),this.gameObject.scale.copy(a),this.gameObject.matrixWorld.copy(r),this._draggedOverObject=null,this._draggedOverObjectLastSetUp=null,this._draggedOverObjectLastNormal.set(0,1,0),this._draggedOverObjectDuration=0}collectMovementInfo(){var A,e;if(!this._followObject.parent)return;const g=this._followObject.parent;this._followObject.updateMatrix();const I=g.worldPosition,o=(e=(A=me.active)==null?void 0:A.rig)==null?void 0:e.gameObject;o&&o.worldToLocal(I),(this._lastDragPosRigSpace===void 0||o!=this._lastRig)&&(this._lastDragPosRigSpace=I.clone(),this._lastRig=o),this._tempVec.copy(I).sub(this._lastDragPosRigSpace);const s=g.worldForward;if(o&&(this._tempMat.copy(o.matrixWorld).invert(),s.transformDirection(this._tempMat)),this._totalMovementAlongRayDirection+=s.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(I),va){let n=I;o&&(n=n.clone(),n.transformDirection(o.matrixWorld)),pe.DrawRay(n,s,255)}}onDragUpdate(A){if(A>1)return;const e=this.gameObject,g=this._followObject.parent;this._followObject.updateMatrix();const I=g.worldPosition,o=g.worldForward,s=this._deviceMode==="tracked-pointer"||this._deviceMode==="transient-pointer",n=s?this.settings.xrKeepRotation:this.settings.keepRotation,a=s?this.settings.xrDragMode:this.settings.dragMode;if(a===5)return;const r=10;n&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion),this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);let C=1,Q=2;if(s&&this._grabStartDistance>.5){const d=1+this._totalMovementAlongRayDirection*(2*this.settings.xrDistanceDragFactor);C=Math.max(0,d),C=C*C*C}else this._grabStartDistance<=.5&&(Q=3);this._followObject.position.copy(this._followObjectStartPosition),n||this._followObject.quaternion.copy(this._followObjectStartQuaternion),this._followObject.position.multiplyScalar(C),this._followObject.updateMatrix();const h=new po(I,o);if(a==4){const d=new fn;d.testObject=D=>D!==this.followObject&&D!==g&&D!==e;const u=this.context.physics.raycastFromRay(h,d);if(u.length>0){const D=u[0];if(this._draggedOverObject===D.object?this._draggedOverObjectDuration+=this.context.time.deltaTime:(this._draggedOverObject=D.object,this._draggedOverObjectDuration=0),D.face){const p=this._draggedOverObjectDuration>=.15,w=.001,f=this._totalMovement.length()>=w;if((p||f)&&(this._draggedOverObjectLastSetUp!==this._draggedOverObject||this._draggedOverObjectLastNormal.dot(D.face.normal)<.999999||this.context.time.frame%60===0)){this._draggedOverObjectLastSetUp=this._draggedOverObject,this._draggedOverObjectLastNormal.copy(D.face.normal);const G=lt(),M=lt();this._bounds.getCenter(G),this._bounds.getSize(M),G.sub(M.multiplyScalar(.5).multiply(D.face.normal)),this._hitPointInLocalSpace.copy(G),this._hitNormalInLocalSpace.copy(D.face.normal),this._bounds.getCenter(G),this._bounds.getSize(M),G.add(M.multiplyScalar(.5).multiply(D.face.normal));const U=lt(this._hitPointInLocalSpace).add(G);this._followObject.localToWorld(U);const v=D.point;this._dragPlane.setFromNormalAndCoplanarPoint(D.face.normal,v)}else if(!(p||f))return}}}if(a!==1&&h.intersectPlane(this._dragPlane,this._tempVec)){this._followObject.worldPosition=this._tempVec,this._followObject.updateMatrix(),this._followObject.updateMatrixWorld(!0);const d=this._hitPointInLocalSpace.clone();this._followObject.localToWorld(d),va&&pe.DrawLine(d,this._tempVec,65535,0,!1),this._followObject.worldPosition=this._tempVec.multiplyScalar(2).sub(d),this._followObject.updateMatrix(),this._followObject.updateMatrix()}if(this.settings.snapGridResolution>0){const d=this._followObject.worldPosition,u=this.settings.snapGridResolution;d.x=Math.round(d.x/u)*u,d.y=Math.round(d.y/u)*u,d.z=Math.round(d.z/u)*u,this._followObject.worldPosition=d,this._followObject.updateMatrix()}n&&(this._followObject.worldQuaternion=this._followObjectStartWorldQuaternion,this._followObject.updateMatrix());const E=ge.clamp01(this.context.time.deltaTime*r*Q),c=e.worldPosition;c.lerp(this._followObject.worldPosition,E),e.worldPosition=c;const l=e.worldQuaternion;if(l.slerp(this._followObject.worldQuaternion,E),e.worldQuaternion=l,va){const d=this._hitPointInLocalSpace.clone();e.localToWorld(d),pe.DrawSphere(d,.02,16711680);const u=this._hitNormalInLocalSpace.clone();u.applyQuaternion(l),pe.DrawRay(d,u,16711680),pe.DrawLabel(c.add(new S(0,.25,0)),`Distance: ${this._totalMovement.length().toFixed(2)}
|
|
6216
6216
|
|
|
6217
6217
|
Along Ray: ${this._totalMovementAlongRayDirection.toFixed(2)}
|
|
6218
6218
|
|