@needle-tools/engine 4.10.0-beta.5 → 4.10.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/README.md +2 -1
- package/dist/{needle-engine.bundle-DcvMQ1Nq.js → needle-engine.bundle-B_wUQWD9.js} +19 -18
- package/dist/{needle-engine.bundle-DzVytSSo.umd.cjs → needle-engine.bundle-CrO5PE4u.umd.cjs} +11 -11
- package/dist/{needle-engine.bundle-BGVvfSfQ.min.js → needle-engine.bundle-DjiUOI9O.min.js} +11 -11
- package/dist/needle-engine.js +331 -332
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/vendor-CPuBPspY.umd.cjs +1121 -0
- package/dist/vendor-DPCU8cUF.min.js +1121 -0
- package/dist/vendor-MBoqSyFm.js +16240 -0
- package/lib/engine/codegen/register_types.js +1 -1
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_license.js +1 -1
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -1
- package/lib/engine-components/codegen/components.js +1 -1
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.js +2 -4
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.d.ts +1 -0
- package/lib/engine-components/web/ScrollFollow.js +2 -0
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/web/ViewBox.js +1 -1
- package/lib/engine-components/web/ViewBox.js.map +1 -1
- package/package.json +2 -1
- package/src/engine/codegen/register_types.ts +1 -1
- package/src/engine/engine_license.ts +1 -1
- package/src/engine-components/codegen/components.ts +1 -1
- package/src/engine-components/timeline/TimelineTracks.ts +2 -4
- package/src/engine-components/web/ScrollFollow.ts +3 -2
- package/src/engine-components/web/ViewBox.ts +1 -1
- package/dist/vendor-D0Yvltn9.umd.cjs +0 -1121
- package/dist/vendor-DU8tJyl_.js +0 -14366
- package/dist/vendor-JyrX4DVM.min.js +0 -1121
package/dist/{needle-engine.bundle-DzVytSSo.umd.cjs → needle-engine.bundle-CrO5PE4u.umd.cjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const c=require("./three-B-jwTHao.umd.cjs"),ne=require("./gltf-progressive-Iy7aSAPk.umd.cjs"),q=require("./three-examples-Deqc1bNw.umd.cjs"),se=require("./vendor-D0Yvltn9.umd.cjs"),J=require("./three-mesh-ui-CsHwj9cJ.umd.cjs"),rx=require("./postprocessing-BsnRNRRS.umd.cjs");var Zu=typeof document<"u"?document.currentScript:null;const Ju=new Map;function Ii(s=globalThis.location?.hostname){if(Ju.has(s))return Ju.get(s);const e=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(s);return Ju.set(s,e),e===!0}function gb(){return window.location.hostname.includes("glitch.me")}const ax='<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>',lx=btoa(ax),cx="data:image/svg+xml;base64,"+lx,im=cx,hx=`<?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(hx);const dx='<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>',ux=btoa(dx),fx="data:image/svg+xml;charset=utf-8;base64,"+ux,gy=fx,yy=typeof window!==void 0?window.location.search.includes("debugcontext"):!1;var re=(s=>(s.ContextRegistered="ContextRegistered",s.ContextCreationStart="ContextCreationStart",s.ContextCreated="ContextCreated",s.ContextFirstFrameRendered="ContextFirstFrameRendered",s.ContextDestroying="ContextDestroying",s.ContextDestroyed="ContextDestroyed",s.MissingCamera="MissingCamera",s.ContextClearing="ContextClearing",s.ContextCleared="ContextCleared",s))(re||{});class ae{static get Current(){return globalThis["NeedleEngine.Context.Current"]}static set Current(e){globalThis["NeedleEngine.Context.Current"]=e}static get All(){return this.Registered}static Registered=[];static register(e){this.Registered.indexOf(e)===-1&&(yy&&console.warn("Registering context"),this.Registered.push(e),this.dispatchCallback("ContextRegistered",e))}static unregister(e){const t=this.Registered.indexOf(e);t!==-1&&(yy&&console.warn("Unregistering context"),this.Registered.splice(t,1))}static _callbacks={};static registerCallback(e,t){this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t)}static unregisterCallback(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i!==-1&&this._callbacks[e].splice(i,1)}static dispatchCallback(e,t,i){if(!this._callbacks[e])return!0;const n={event:e,context:t};if(i)for(const r in i)n[r]=i[r];const o=new Array;return this._callbacks[e].forEach(r=>{const a=r(n);a instanceof Promise&&o.push(a)}),Promise.all(o)}static addContextCreatedCallback(e){this.registerCallback("ContextCreated",e)}static addContextDestroyedCallback(e){this.registerCallback("ContextDestroyed",e)}}const yb=()=>s=>s;function px(s){return yb()(s)}function mx(){return!!w("debug")}class di{_factory;_cache=[];_maxSize;_index=0;constructor(e,t){this._factory=e,this._maxSize=t}get(){const e=this._index%this._maxSize;return this._index++,this._cache.length<=e&&(this._cache[e]=this._factory()),this._cache[e]}}let Eo=!1;const ap=new Array;typeof window<"u"&&setTimeout(()=>{if(Eo){const s={},e=new URL(window.location.href),t=new URL(e);t.searchParams.append("console","");const i=t.toString().replace(/=$|=(?=&)/g,"");for(const o of ap){const r=new URL(e);r.searchParams.append(o,""),s[o]=r.toString().replace(/=$|=(?=&)/g,"")}console.log(`🌵 ?help: Debug Options for Needle Engine.
|
|
1
|
+
"use strict";const c=require("./three-B-jwTHao.umd.cjs"),ne=require("./gltf-progressive-Iy7aSAPk.umd.cjs"),q=require("./three-examples-Deqc1bNw.umd.cjs"),se=require("./vendor-CPuBPspY.umd.cjs"),J=require("./three-mesh-ui-CsHwj9cJ.umd.cjs"),rx=require("./postprocessing-BsnRNRRS.umd.cjs");var Zu=typeof document<"u"?document.currentScript:null;const Ju=new Map;function Ii(s=globalThis.location?.hostname){if(Ju.has(s))return Ju.get(s);const e=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(s);return Ju.set(s,e),e===!0}function gb(){return window.location.hostname.includes("glitch.me")}const ax='<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>',lx=btoa(ax),cx="data:image/svg+xml;base64,"+lx,im=cx,hx=`<?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(hx);const dx='<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>',ux=btoa(dx),fx="data:image/svg+xml;charset=utf-8;base64,"+ux,gy=fx,yy=typeof window!==void 0?window.location.search.includes("debugcontext"):!1;var re=(s=>(s.ContextRegistered="ContextRegistered",s.ContextCreationStart="ContextCreationStart",s.ContextCreated="ContextCreated",s.ContextFirstFrameRendered="ContextFirstFrameRendered",s.ContextDestroying="ContextDestroying",s.ContextDestroyed="ContextDestroyed",s.MissingCamera="MissingCamera",s.ContextClearing="ContextClearing",s.ContextCleared="ContextCleared",s))(re||{});class ae{static get Current(){return globalThis["NeedleEngine.Context.Current"]}static set Current(e){globalThis["NeedleEngine.Context.Current"]=e}static get All(){return this.Registered}static Registered=[];static register(e){this.Registered.indexOf(e)===-1&&(yy&&console.warn("Registering context"),this.Registered.push(e),this.dispatchCallback("ContextRegistered",e))}static unregister(e){const t=this.Registered.indexOf(e);t!==-1&&(yy&&console.warn("Unregistering context"),this.Registered.splice(t,1))}static _callbacks={};static registerCallback(e,t){this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t)}static unregisterCallback(e,t){if(!this._callbacks[e])return;const i=this._callbacks[e].indexOf(t);i!==-1&&this._callbacks[e].splice(i,1)}static dispatchCallback(e,t,i){if(!this._callbacks[e])return!0;const n={event:e,context:t};if(i)for(const r in i)n[r]=i[r];const o=new Array;return this._callbacks[e].forEach(r=>{const a=r(n);a instanceof Promise&&o.push(a)}),Promise.all(o)}static addContextCreatedCallback(e){this.registerCallback("ContextCreated",e)}static addContextDestroyedCallback(e){this.registerCallback("ContextDestroyed",e)}}const yb=()=>s=>s;function px(s){return yb()(s)}function mx(){return!!w("debug")}class di{_factory;_cache=[];_maxSize;_index=0;constructor(e,t){this._factory=e,this._maxSize=t}get(){const e=this._index%this._maxSize;return this._index++,this._cache.length<=e&&(this._cache[e]=this._factory()),this._cache[e]}}let Eo=!1;const ap=new Array;typeof window<"u"&&setTimeout(()=>{if(Eo){const s={},e=new URL(window.location.href),t=new URL(e);t.searchParams.append("console","");const i=t.toString().replace(/=$|=(?=&)/g,"");for(const o of ap){const r=new URL(e);r.searchParams.append(o,""),s[o]=r.toString().replace(/=$|=(?=&)/g,"")}console.log(`🌵 ?help: Debug Options for Needle Engine.
|
|
2
2
|
Append any of these parameters to the URL to enable specific debug options.
|
|
3
3
|
Example: ${i} will show an onscreen console window.`);const n=Eo===!0?"":` (containing "${Eo}")`;console.group("Available URL parameters:"+n);for(const o of Object.keys(s).sort())typeof Eo=="string"&&!o.toLowerCase().includes(Eo.toLowerCase())||(console.groupCollapsed(o),console.log("Reload with this flag enabled:"),console.log(s[o]),console.groupEnd());console.groupEnd()}},100);function fc(){return new URLSearchParams(globalThis.location?.search)}function w(s){Eo&&!ap.includes(s)&&ap.push(s);const e=fc();if(e.has(s)){const t=e.get(s);if(t){const i=Number(t);return isNaN(i)?t:i}else return!0}return!1}Eo=w("help");function gx(s,e){const t=fc();t.has(s)?t.set(s,e):t.append(s,e),document.location.search=t.toString()}function Ql(s,e,t=!0){const i=fc();i.has(s)?e===null?i.delete(s):i.set(s,e):e!==null&&i.append(s,e),t?_b(s,i):nm(s,i)}function lp(s,e,t){s.has(e)?s.set(e,t.toString()):s.append(e,t.toString())}function _b(s,e,t){window.history.pushState(t,s,"?"+e.toString())}function nm(s,e,t){window.history.replaceState(t,s,"?"+e.toString())}function yx(s){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length,n=0;n<s;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function _x(s,e){return Math.floor(Math.random()*(e-s+1))+s}const _y=["smol","tiny","giant","interesting","smart","bright","dull","extreme","beautiful","pretty","dark","epic","salty","silly","funny","lame","lazy","loud","lucky","mad","mean","mighty","mysterious","nasty","odd","old","powerful","quiet","rapid","scary","shiny","shy","silly","smooth","sour","spicy","stupid","sweet","tasty","terrible","ugly","unusual","vast","wet","wild","witty","wrong","zany","zealous","zippy","zombie","zorro"],by=["cat","dog","mouse","pig","cow","horse","sheep","chicken","duck","goat","panda","tiger","lion","elephant","monkey","bird","fish","snake","frog","turtle","hamster","penguin","kangaroo","whale","dolphin","crocodile","snail","ant","bee","beetle","butterfly","dragon","eagle","fish","giraffe","lizard","panda","penguin","rabbit","snake","spider","tiger","zebra"];function bb(){const s=_y[Math.floor(Math.random()*_y.length)],e=by[Math.floor(Math.random()*by.length)];return s+"_"+e}function vb(s){return s=s.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""),s.trim()}function da(s,e,t=!0,i=!1){if(e==null)return null;if(e.userData&&e.userData.guid===s)return e;if(e.guid==s)return e;if(i&&e.userData?.components){for(const n of e.userData.components)if(n.guid===s)return n}if(t){if(e.scenes)for(const n in e.scenes){const o=e.scenes[n],r=da(s,o,t,i);if(r)return r}if(e.children)for(const n in e.children){const o=e.children[n],r=da(s,o,t,i);if(r)return r}}}function pc(s,e){if(s!=null&&typeof s=="object"){let t;Array.isArray(s)?t=[]:(t=Object.create(s),Object.assign(t,s));for(const i of Object.keys(s)){const n=s[i];e&&!e(s,i,n)?t[i]=n:n?.clone!==void 0&&typeof n.clone=="function"?t[i]=n.clone():t[i]=pc(n,e)}return t}return s}function In(s){return new Promise((e,t)=>{setTimeout(e,s)})}function mc(s,e){if(s<=0)return Promise.resolve();if(e||(e=ae.Current),!e)return Promise.reject("No context");const t=e.time.frameCount+s;return new Promise((i,n)=>{if(!e)return n("No context");const o=()=>{e.time.frameCount>=t&&(e.pre_update_callbacks.splice(e.pre_update_callbacks.indexOf(o),1),i())};e.pre_update_callbacks.push(o)})}const fh=w("debugresolveurl"),wb="rel:";function bx(s,e){return no(s,e)}function no(s,e){if(e===void 0)return fh&&console.warn("getPath: uri is undefined, returning uri",e),e;if(e.startsWith("./"))return e;if(e.startsWith("http"))return fh&&console.warn("getPath: uri is absolute, returning uri",e),e;if(s===void 0)return fh&&console.warn("getPath: source is undefined, returning uri",e),e;e.startsWith(wb)&&(e=e.substring(4));const t=s.lastIndexOf("/");if(t>=0){const i=s.substring(0,t+1);for(;i.endsWith("/")&&e.startsWith("/");)e=e.substring(1);const n=i+e;return fh&&console.log("source:",s,`changed uri
|
|
4
4
|
from`,e,`
|
|
@@ -141,7 +141,7 @@ void main(){
|
|
|
141
141
|
#__vconsole .vc-mask {
|
|
142
142
|
overflow: hidden;
|
|
143
143
|
}
|
|
144
|
-
`,wo?.prepend(i),s===!0&&Cb()<=0&&Vb(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),Ja=!1,Ri=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function PS(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const o=n.indexOf("?");o>-1&&(n=n.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(h)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ri?.hide()}}),i.push({name:"Reload",onClick:function(n){const o=e();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(i)}),s}function OS(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function MS(){const s=document.querySelector("#__vconsole");return s||null}const $b=w("debugdefines");so('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";');so('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";');so('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";');so('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');so('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.10.0-beta.
|
|
144
|
+
`,wo?.prepend(i),s===!0&&Cb()<=0&&Vb(),console.log("🌵 Debug console has loaded")}},e.onerror=()=>{console.warn("🌵 Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),Ja=!1,Ri=null},e.src="https://cdn.jsdelivr.net/npm/vconsole@3.15.1/dist/vconsole.min.js",document.body.appendChild(e)}function PS(){if(!globalThis.VConsole)return;const s=new VConsole.VConsolePlugin("needle-console","🌵 Inspect glTF"),e=()=>document.querySelector("#__vc_plug_"+s._id+" iframe");return s.on("renderTab",function(t){const i=globalThis["needle:codegen_files"];if(!i||i.length===0)return;let n=globalThis["needle:codegen_files"][0];const o=n.indexOf("?");o>-1&&(n=n.substring(0,o));const a=location.protocol+"//"+location.host+location.pathname+"/"+n,l=encodeURIComponent(a);s.fullUrl="https://viewer.needle.tools?inspect&file="+l;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';t(h)}),s.on("show",function(){const t=e();t&&t.src!==s.fullUrl&&(t.src=s.fullUrl)}),s.on("hide",function(){const t=e();t&&(t.src="")}),s.on("addTopBar",function(t){var i=new Array;i.push({name:"Open in new window ↗",onClick:function(n){window.open(s.fullUrl,"_blank"),Ri?.hide()}}),i.push({name:"Reload",onClick:function(n){const o=e();o&&(o.src=s.fullUrl)}}),i.push({name:"Fullscreen",onClick:function(n){const o=e();o.requestFullscreen?o.requestFullscreen():o.webkitRequestFullscreen instanceof Function&&o.webkitRequestFullscreen()}}),t(i)}),s}function OS(){const s=document.querySelector("#__vconsole .vc-switch");return s||null}function MS(){const s=document.querySelector("#__vconsole");return s||null}const $b=w("debugdefines");so('if(!globalThis["NEEDLE_ENGINE_VERSION"]) globalThis["NEEDLE_ENGINE_VERSION"] = "0.0.0";');so('if(!globalThis["NEEDLE_ENGINE_GENERATOR"]) globalThis["NEEDLE_ENGINE_GENERATOR"] = "unknown";');so('if(!globalThis["NEEDLE_PROJECT_BUILD_TIME"]) globalThis["NEEDLE_PROJECT_BUILD_TIME"] = "unknown";');so('if(!globalThis["NEEDLE_PUBLIC_KEY"]) globalThis["NEEDLE_PUBLIC_KEY"] = "unknown";');so('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.10.0-beta.9";');so('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');so('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Sep 29 2025 12:36:40 GMT+0000 (Coordinated Universal Time)";');so('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const Ji="4.10.0-beta.9",Xd="undefined",ym="Mon Sep 29 2025 12:36:40 GMT+0000 (Coordinated Universal Time)";$b&&console.log(`Engine version: ${Ji} (generator: ${Xd})
|
|
145
145
|
Project built at ${ym}`);const Yr=NEEDLE_PUBLIC_KEY,ls="needle_isActiveInHierarchy",Ro="builtin_components",Il="needle_editor_guid";function so(s){try{(0,eval)(s)}catch(e){$b&&console.error(e)}}let Wb,Ey=null;function nn(){return Wb}function _m(s){if(s==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}Ey!==s&&(Ey=s,Wb=new s)}const ri=Symbol("shadowDomOwner"),kS=w("debugpatch");function Qd(s,e,t,i){const n=kS===e;if(!t&&!i)return;const o=e+"___needle";RS(s,e,t,i);const r=Object.getOwnPropertyDescriptor(s,e),a=s[e];n&&console.log("Patch",s.constructor.name,e,r,a),r?(n&&console.log("Apply patch with existing descriptor",s.constructor.name,e,r),typeof r.value=="function"&&(s[e]=Ty(r.value,s,e))):(n&&console.log("Create patch with new property",s.constructor.name,e,r),Object.defineProperty(s,e,{set:function(l){if(typeof l=="function")this[o]=Ty(l,s,e);else{const h=this[o];Hb(s,e,this,h,l),this[o]=l,Gb(s,e,this,h,l)}},get:function(){const l=this[o];return typeof l=="function"&&l[o]?l[o]:l}}))}function ES(s,e,t){const i=bm(s,e);if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];o.prefix===t&&(o.prefix=null),o.postfix===t&&(o.postfix=null),!o.prefix&&!o.postfix&&i.splice(n,1)}}const Ry=Symbol("Needle:Patches:WrappedFunction");function Ty(s,e,t){if(s[Ry])return s;const i=function(...n){Hb(e,t,this,...n);const o=s.apply(this,n);return Gb(e,t,this,o,...n),o};return i[Ry]=!0,i}const Yh="Needle:Patches";function pp(){return globalThis[Yh]||(globalThis[Yh]=new WeakMap),globalThis[Yh]}function bm(s,e){const t=pp().get(s);return t?t.get(e):null}function RS(s,e,t,i){let n=pp().get(s);n||(n=new Map,pp().set(s,n));let o=n.get(e);o||(o=[],n.set(e,o)),o.push({prefix:t,postfix:i})}function Hb(s,e,t,...i){if(!t)return;const n=bm(s,e);if(n)for(const o of n)o.prefix?.call(t,...i)}function Gb(s,e,t,i,...n){if(!t)return;const o=bm(s,e);if(o)for(const r of o)r.postfix?.call(t,i,...n)}const fa=[];function Yd(s){fa.indexOf(s)===-1&&fa.push(s)}function TS(s){const e=fa.indexOf(s);e!==-1&&fa.splice(e,1)}const pa=[];function vm(s){pa.indexOf(s)===-1&&pa.push(s)}function AS(s){const e=pa.indexOf(s);e!==-1&&pa.splice(e,1)}function qb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-start",{detail:s}));for(let e=0;e<fa.length;e++)fa[e](s)}function Xb(s){globalThis.dispatchEvent(new CustomEvent("needle-xrsession-end",{detail:s}));for(let e=0;e<pa.length;e++)pa[e](s)}const Xe=w("debuginput");var Kd=(s=>(s.Mouse="mouse",s.Touch="touch",s.Controller="controller",s.Hand="hand",s))(Kd||{}),we=(s=>(s.PointerDown="pointerdown",s.PointerUp="pointerup",s.PointerMove="pointermove",s.KeyDown="keydown",s.KeyUp="keyup",s.KeyPressed="keypress",s))(we||{});class Zn extends PointerEvent{clientZ;deviceIndex;origin;source;mode;get isSpatial(){return this.mode!="screen"}get ray(){return this._ray||(this._ray=new c.Ray(this.space.worldPosition.clone(),this.space.worldForward.clone())),this._ray}set ray(e){this._ray=e}get hasRay(){return this._ray!==void 0}_ray;space;isClick=!1;isDoubleClick=!1;get used(){return this._used}_used=!1;use(){this._used=!0}get pointerId(){return this._pointerid}_pointerid;get pointerType(){return this._pointerType}_pointerType;get type(){return this._type}_type;metadata={};intersections=new Array;constructor(e,t,i){super(e,i),this.clientZ=i.clientZ,this._pointerid=i.pointerId,this._pointerType=i.pointerType,this._type=e,this.deviceIndex=i.deviceIndex,this.origin=i.origin,this.source=t,this.mode=i.mode,this._ray=i.ray,this.space=i.device}_immediatePropagationStopped=!1;get immediatePropagationStopped(){return this._immediatePropagationStopped}_propagationStopped=!1;get propagationStopped(){return this._immediatePropagationStopped||this._propagationStopped}stopImmediatePropagation(){this._immediatePropagationStopped=!0,super.stopImmediatePropagation(),this.source?.stopImmediatePropagation()}stopPropagation(){this._propagationStopped=!0,super.stopPropagation(),this.source?.stopPropagation(),Xe&&console.warn("Stop propagation...",this.pointerId,this.pointerType)}}class yl extends KeyboardEvent{source;constructor(e,t,i){super(e,i),this.source=t}stopImmediatePropagation(){super.stopImmediatePropagation(),this.source?.stopImmediatePropagation()}}class LS{key;keyType;source;constructor(e){this.key=e.key,this.keyType=e.type,this.source=e}}var Gt=(s=>(s[s.Early=-100]="Early",s[s.Default=0]="Default",s[s.Late=100]="Late",s))(Gt||{});class Qb{_eventListeners={};addEventListener(e,t,i){if(this._eventListeners[e]||(this._eventListeners[e]=[]),!t||typeof t!="function"){console.error("Invalid call to addEventListener: callback is required and must be a function!");return}i?i={...i}:i={};let n=0;i?.queue!=null&&(n=i.queue);const o=this._eventListeners[e],r=o.find(a=>a.priority===n);r?r.listeners.push({callback:t,options:i}):(o.push({priority:n,listeners:[{callback:t,options:i}]}),o.sort((a,l)=>a.priority-l.priority))}removeEventListener(e,t,i){if(!this._eventListeners[e]||!t)return;const n=this._eventListeners[e];if(i?.queue!=null){const o=n.find(a=>a.priority===i.queue);if(!o)return;const r=o.listeners.findIndex(a=>a.callback===t);r>=0&&o.listeners.splice(r,1)}else for(const o of n){const r=o.listeners.findIndex(a=>a.callback===t);r>=0&&o.listeners.splice(r,1)}}dispatchEvent(e){let t=!1;if(e instanceof yl){const i=this._eventListeners[e.type];if(i)for(const n of i)for(let o=0;o<n.listeners.length;o++){const r=n.listeners[o];if(r.options?.signal?.aborted){n.listeners.splice(o,1),o--;continue}r.options.once&&(n.listeners.splice(o,1),o--),r.callback(e)}}if(e instanceof Zn){const i=this._eventListeners[e.type];if(i)for(const n of i){if(t)break;for(let o=0;o<n.listeners.length;o++){const r=n.listeners[o];if(r.options?.signal?.aborted){n.listeners.splice(o,1),o--;continue}if(e.immediatePropagationStopped){t=!0,Xe&&console.log("immediatePropagationStopped",e.type);break}else e.propagationStopped&&(t=!0,Xe&&console.log("propagationStopped",e.type));r.options.once&&(n.listeners.splice(o,1),o--),r.callback(e)}}}}_doubleClickTimeThreshold=.2;_longPressTimeThreshold=1;get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}get click(){return this._pointerClick[0]}get doubleClick(){return this._pointerDoubleClick[0]}getGamepad(e=0){return typeof navigator<"u"&&"getGamepads"in navigator&&navigator.getGamepads()[e]||null}_setCursorTypes=[];setCursorPointer(){this.setCursor("pointer")}setCursorNormal(){this.unsetCursor("pointer")}setCursor(e){this._setCursorTypes.push(e),this._setCursorTypes.length>10&&this._setCursorTypes.shift(),this.updateCursor()}unsetCursor(e){for(let t=this._setCursorTypes.length-1;t>=0;t--)if(this._setCursorTypes[t]===e){this._setCursorTypes.splice(t,1),this.updateCursor();break}}updateCursor(){this._setCursorTypes?.length==0?this.context.domElement.style.cursor="default":this.context.domElement.style.cursor=this._setCursorTypes[this._setCursorTypes.length-1]}getIsPointerIdInUse(e){for(const t of this._pointerEventsPressed)if(t.pointerId===e&&t.used)return!0;return!1}getPointerPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&e++;return e}getPointerPosition(e){return e>=this._pointerPositions.length?null:this._pointerPositions[e]}getPointerPositionLastFrame(e){return e>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[e]}getPointerPositionDelta(e){return e>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[e]}getPointerPositionRC(e){return e>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[e]}getPointerDown(e){return e>=this._pointerDown.length?!1:this._pointerDown[e]}getPointerUp(e){return e>=this._pointerUp.length?!1:this._pointerUp[e]}getPointerPressed(e){return e>=this._pointerPressed.length?!1:this._pointerPressed[e]}getPointerClicked(e){return e>=this._pointerClick.length?!1:this._pointerClick[e]}getPointerDoubleClicked(e){return e>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[e]}getPointerDownTime(e){return e>=this._pointerDownTime.length?-1:this._pointerDownTime[e]}getPointerUpTime(e){return e>=this._pointerUpTime.length?-1:this._pointerUpTime[e]}getPointerLongPress(e){return e>=this._pointerDownTime.length?!1:this.getPointerPressed(e)&&this.context.time.time-this._pointerDownTime[e]>this._longPressTimeThreshold}getIsMouse(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="mouse"}getIsTouch(e){return e<0||e>=this._pointerTypes.length?!1:this._pointerTypes[e]==="touch"}getTouchesPressedCount(){let e=0;for(let t=0;t<this._pointerPressed.length;t++)this._pointerPressed[t]&&this.getIsTouch(t)&&e++;return e}getMouseWheelChanged(e=0){return e>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[e]}getMouseWheelDeltaY(e=0){return e>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[e]}getPointerEvent(e){if(!(e>=this._pointerEvent.length))return this._pointerEvent[e]??void 0}*foreachPointerId(e){for(let t=0;t<this._pointerTypes.length;t++)if(this._pointerIsActive(t)){if(e!==void 0){const i=this._pointerTypes[t];if(Array.isArray(e)){let n=!1;for(const o of e)if(i===o){n=!0;break}if(!n)continue}else if(e!==i)continue}yield t}}*foreachTouchId(){for(let e=0;e<this._pointerTypes.length;e++)this._pointerTypes[e]==="touch"&&this._pointerIsActive[e]&&(yield e)}_pointerIsActive(e){return e<0?!1:this._pointerPressed[e]||this._pointerDown[e]||this._pointerUp[e]}context;_pointerDown=[!1];_pointerUp=[!1];_pointerClick=[!1];_pointerDoubleClick=[!1];_pointerPressed=[!1];_pointerPositions=[new c.Vector2];_pointerPositionsLastFrame=[new c.Vector2];_pointerPositionsDelta=[new c.Vector2];_pointerPositionsRC=[new c.Vector2];_pointerPositionDown=[new c.Vector3];_pointerDownTime=[];_pointerUpTime=[];_pointerUpTimestamp=[];_pointerIds=[];_pointerTypes=[""];_mouseWheelChanged=[!1];_mouseWheelDeltaY=[0];_pointerEvent=[];_pointerEventsPressed=[];_pointerSpace=[];_pressedStack=new Map;onDownButton(e,t){let i=this._pressedStack.get(e);i||(i=[],this._pressedStack.set(e,i)),i.push(t)}onReleaseButton(e,t){const i=this._pressedStack.get(e);if(!i)return;const n=i.indexOf(t);n>=0&&i.splice(n,1)}getFirstPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[0]}getLatestPressedButtonForPointer(e){const t=this._pressedStack.get(e);if(t)return t[t.length-1]}getKeyDown(e){if(e!==void 0)return this.isKeyDown(e);for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(e){if(e!==void 0)return this.isKeyPressed(e);for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}getKeyUp(e){if(e!==void 0)return this.isKeyUp(e);for(const t in this.keysPressed){const i=this.keysPressed[t];return i.pressed===!1&&i.frame===this.context.time.frameCount}return null}isKeyDown(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyDown(n))return!0;return!1}const i=this.keysPressed[e];return i?i.startFrame===this.context.time.frameCount&&i.pressed:!1}isKeyUp(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyUp(n))return!0;return!1}const i=this.keysPressed[e];return i?i.frame===this.context.time.frameCount&&i.pressed===!1:!1}isKeyPressed(e){if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const t=this.getCodeForCommonKeyName(e);if(t!==null){for(const n of t)if(this.isKeyPressed(n))return!0;return!1}const i=this.keysPressed[e];return i&&i.pressed||!1}getCodeForCommonKeyName(e){if(e.length===1){if(e>="0"&&e<="9")return["Digit"+e];if(e>="a"&&e<="z")return["Key"+e.toUpperCase()];if(e==" ")return["Space"]}switch(e){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createInputEvent(e){switch(e.type){case"pointerdown":Xe&&Se("Create Pointer down"),this.onDownButton(e.deviceIndex,e.button),this.onDown(e);break;case"pointermove":Xe&&Se("Create Pointer move"),this.onMove(e);break;case"pointerup":Xe&&Se("Create Pointer up"),this.onUp(e),this.onReleaseButton(e.deviceIndex,e.button);break}}convertScreenspaceToRaycastSpace(e){return e.x=(e.x-this.context.domX)/this.context.domWidth*2-1,e.y=-((e.y-this.context.domY)/this.context.domHeight)*2+1,e}constructor(e){this.context=e,this.context.post_render_callbacks.push(this.onEndOfFrame)}_htmlEventSource;bindEvents(){this.unbindEvents(),this._htmlEventSource=this.context.renderer.domElement,window.addEventListener("contextmenu",this.onContextMenu),this._htmlEventSource.addEventListener("pointerdown",this.onPointerDown,{passive:!0}),window.addEventListener("pointermove",this.onPointerMove,{passive:!0,capture:!0}),window.addEventListener("pointerup",this.onPointerUp,{passive:!0}),window.addEventListener("pointercancel",this.onPointerCancel,{passive:!0}),window.addEventListener("touchstart",this.onTouchStart,{passive:!0}),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._htmlEventSource.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("wheel",this.onWheelWindow,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}unbindEvents(){for(const e in this._eventListeners)this._eventListeners[e].length=0;window.removeEventListener("contextmenu",this.onContextMenu),this._htmlEventSource?.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),window.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd),this._htmlEventSource?.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("wheel",this.onWheelWindow,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}dispose(){const e=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);e>=0&&this.context.post_render_callbacks.splice(e,1),this.unbindEvents()}onLostFocus=()=>{for(const e in this.keysPressed)this.keysPressed[e].pressed=!1};_receivedPointerMoveEventsThisFrame=new Array;onEndOfFrame=()=>{this._receivedPointerMoveEventsThisFrame.length=0;for(let e=0;e<this._pointerUp.length;e++)this._pointerUp[e]=!1;for(let e=0;e<this._pointerDown.length;e++)this._pointerDown[e]=!1;for(let e=0;e<this._pointerClick.length;e++)this._pointerClick[e]=!1;for(let e=0;e<this._pointerDoubleClick.length;e++)this._pointerDoubleClick[e]=!1;for(const e of this._pointerPositionsDelta)e.set(0,0);for(let e=0;e<this._mouseWheelChanged.length;e++)this._mouseWheelChanged[e]=!1;for(let e=0;e<this._mouseWheelDeltaY.length;e++)this._mouseWheelDeltaY[e]=0};canReceiveInput(e){return e.target===this.context.renderer?.domElement||e.target===this.context.domElement||this.context.isInAR||this.context.isInAR&&e.target===document.body&&exports.DeviceUtilities.isMozillaXR()?!0:(Xe&&console.warn("CanReceiveInput:False for",e.target),!1)}onContextMenu=e=>{this.canReceiveInput(e)!==!1&&e instanceof PointerEvent&&e.pointerType};keysPressed={};onKeyDown=e=>{if(Xe&&console.log(`key down ${e.code}, ${this.context.application.hasFocus}`,e),!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(t&&t.pressed)return;this.keysPressed[e.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:e.key,code:e.code};const i=new yl("keydown",e,e);this.onDispatchEvent(i)};onKeyPressed=e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!0,t.frame=this.context.time.frameCount+1;const i=new yl("keypress",e,e);this.onDispatchEvent(i)};onKeyUp=e=>{if(!this.context.application.hasFocus)return;const t=this.keysPressed[e.code];if(!t)return;t.pressed=!1,t.frame=this.context.time.frameCount+1;const i=new yl("keyup",e,e);this.onDispatchEvent(i)};onWheelWindow=e=>{document.pointerLockElement&&this.onMouseWheel(e)};onMouseWheel=e=>{if(this.canReceiveInput(e)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const t=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=t+e.deltaY};onPointerDown=e=>{if(this.context.isInAR||this.canReceiveInput(e)===!1)return;e.target instanceof HTMLElement&&e.target.setPointerCapture(e.pointerId);const t=this.getPointerId(e);Xe&&Se(`pointer down #${t}, identifier:${e.pointerId}`);const i=this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),n=new Zn("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:i,pressure:e.pressure});this.onDown(n)};onPointerMove=e=>{if(this.context.isInAR||this._receivedPointerMoveEventsThisFrame.includes(e.pointerId))return;this._receivedPointerMoveEventsThisFrame.push(e.pointerId);let t=e.button;e.pointerType==="mouse"&&(t=this.getFirstPressedButtonForPointer(0)??0);const i=this.getPointerId(e,t);t===-1&&(t=i);const n=this.getAndUpdateSpatialObjectForScreenPosition(i,e.clientX,e.clientY),o=new Zn("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:i,button:t,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:n,pressure:e.pressure});this.onMove(o)};onPointerCancel=e=>{this.context.isInAR||(Xe&&console.log("Pointer cancel",e),this.onPointerUp(e))};onPointerUp=e=>{if(this.context.isInAR)return;e.target instanceof HTMLElement&&e.target.releasePointerCapture(e.pointerId);const t=this.getPointerId(e),i=new Zn("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:t,button:e.button,clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,buttonName:this.getButtonName(e),device:this.getAndUpdateSpatialObjectForScreenPosition(t,e.clientX,e.clientY),pressure:e.pressure});this.onUp(i),this._pointerIds[t]=-1,Xe&&console.log("ID="+t,"PointerId="+e.pointerId,"ALL:",[...this._pointerIds])};getPointerId(e,t){return e.pointerType==="mouse"?0+(t??e.button):this.getPointerIndex(e.pointerId)}getButtonName(e){const t=e.button;if(e.pointerType==="mouse")switch(t){case 0:return"left";case 1:return"middle";case 2:return"right"}return"unknown"}onTouchStart=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Zn("pointerdown",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:o,pressure:i.force});this.onDown(r)}};onTouchMove=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),o=this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),r=new Zn("pointermove",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:o,pressure:i.force});this.onMove(r)}};onTouchEnd=e=>{if(this.context.isInAR)for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t],n=this.getPointerIndex(i.identifier),o=new Zn("pointerup",e,{origin:this,mode:"screen",deviceIndex:0,pointerId:n,button:0,clientX:i.clientX,clientY:i.clientY,pointerType:"touch",buttonName:"unknown",device:this.getAndUpdateSpatialObjectForScreenPosition(n,i.clientX,i.clientY),pressure:i.force});this.onUp(o),this._pointerIds[n]=-1}};tempNearPlaneVector=new c.Vector3;tempFarPlaneVector=new c.Vector3;tempLookMatrix=new c.Matrix4;getAndUpdateSpatialObjectForScreenPosition(e,t,i){let n=this._pointerSpace[e];n||(n=new c.Object3D,this._pointerSpace[e]=n),this._pointerSpace[e]=n;const o=this.context.mainCamera;if(o){const r=this.tempNearPlaneVector.set(t,i,-1);this.convertScreenspaceToRaycastSpace(r);const a=this.tempFarPlaneVector.set(r.x,r.y,1);r.unproject(o),a.unproject(o);const l=o.worldUp||F(0,1,0).applyQuaternion(ue(o));this.tempLookMatrix.lookAt(a,r,l),n.position.set(r.x,r.y,r.z),n.quaternion.setFromRotationMatrix(this.tempLookMatrix)}return n}isInRect(e){if(this.context.isInXR)return!0;const t=this.context.domElement.getBoundingClientRect(),i=e.clientX,n=e.clientY,o=i>=t.x&&i<=t.right&&n>=t.y&&n<=t.bottom;return Xe&&!o&&console.log("Not in rect",t,i,n),o}onDown(e){const t=e.pointerId;if(this.getPointerPressed(t)&&console.warn(`Received pointerDown for pointerId that is already pressed: ${t}`,Xe?e:""),Xe&&console.log(e.pointerType,"DOWN",t),!!this.isInRect(e)){for(this.setPointerState(t,this._pointerPressed,!0),this.setPointerState(t,this._pointerDown,!0),this.setPointerStateT(t,this._pointerEvent,e.source);t>=this._pointerTypes.length;)this._pointerTypes.push(e.pointerType);for(this._pointerTypes[t]=e.pointerType;t>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new c.Vector3);for(this._pointerPositionDown[t].set(e.clientX,e.clientY,e.clientZ??0);t>=this._pointerPositions.length;)this._pointerPositions.push(new c.Vector2);this._pointerPositions[t].set(e.clientX,e.clientY),t>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t]=this.context.time.realtimeSinceStartup,this.updatePointerPosition(e),this._pointerEventsPressed.push(e),this.onDispatchEvent(e)}}onMove(e){const t=e.pointerId,i=this.getPointerPressed(t);i===!1&&!this.isInRect(e)||e.pointerType==="touch"&&!i||(this.updatePointerPosition(e),this.setPointerStateT(t,this._pointerEvent,e.source),this.onDispatchEvent(e))}onUp(e){const t=e.pointerId;if(!this.getPointerPressed(t)){Xe&&console.log(e.pointerType,"UP",t,"was not down");return}Xe&&console.log(e.pointerType,"UP",t),this.setPointerState(t,this._pointerPressed,!1),this.setPointerStateT(t,this._pointerEvent,e.source),this.setPointerState(t,this._pointerUp,!0),this.updatePointerPosition(e);for(let l=this._pointerEventsPressed.length-1;l>=0;l--)if(this._pointerEventsPressed[l].pointerId===t){this._pointerEventsPressed.splice(l,1);break}if(!this._pointerPositionDown[t]){Xe&&he("Received pointer up event without matching down event for button: "+t),console.warn("Received pointer up event without matching down event for button: "+t);return}const n=this._pointerUpTime[t],o=this._pointerDownTime[t],r=this.context.time.realtimeSinceStartup,a=r-o;if(t>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),this._pointerUpTime[t]=r,a<1){let l=e.clientX-this._pointerPositionDown[t].x,h=e.clientY-this._pointerPositionDown[t].y,d=0;if(e.isSpatial&&e.clientZ!=null&&(d=e.clientZ-this._pointerPositionDown[t].z,l*=200,h*=200,d*=200),Math.abs(l)<5&&Math.abs(h)<5&&Math.abs(d)<5){this.setPointerState(t,this._pointerClick,!0),e.isClick=!0;const u=r-n;Xe&&console.log("CLICK",t,l,h,d,u),u<this._doubleClickTimeThreshold&&u>0&&(this.setPointerState(t,this._pointerDoubleClick,!0),e.isDoubleClick=!0)}}this.onDispatchEvent(e)}updatePointerPosition(e){const t=e.pointerId;for(;t>=this._pointerPositions.length;)this._pointerPositions.push(new c.Vector2);for(;t>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new c.Vector2);for(;t>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new c.Vector2);const i=this._pointerPositionsLastFrame[t];i.copy(this._pointerPositions[t]);const n=this._pointerPositionsDelta[t];let o=e.clientX-i.x,r=e.clientY-i.y;if(e.source instanceof MouseEvent||e.source instanceof TouchEvent){const d=e.source;o===0&&d.movementX!==0&&(o=d.movementX||0),r===0&&d.movementY!==0&&(r=d.movementY||0)}n.x+=o,n.y+=r,this._pointerPositions[t].x=e.clientX,this._pointerPositions[t].y=e.clientY;const a=e.clientX,l=e.clientY;for(;t>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new c.Vector2);const h=this._pointerPositionsRC[t];h.set(a,l),this.convertScreenspaceToRaycastSpace(h)}getPointerIndex(e){let t=-1;for(let i=0;i<this._pointerIds.length;i++){if(this._pointerIds[i]===e)return i;t===-1&&this._pointerIds[i]===-1&&(t=i)}return t!==-1?(this._pointerIds[t]=e,t):(Xe&&console.log("PUSH pointerId:",e),this._pointerIds.push(e),this._pointerIds.length-1)}setPointerState(e,t,i){t[e]=i}setPointerStateT(e,t,i){return t[e]=i,i}onDispatchEvent(e){const t=z.Current;try{z.Current=this.context,this.dispatchEvent(e)}finally{z.Current=t}}}const na=new c.Matrix4().makeRotationY(Math.PI),ki=new c.Quaternion().setFromAxisAngle(new c.Vector3(0,1,0),Math.PI),DS=w("debugwebxr");class IS{priority=-1e5;gameObject;isXRRig(){return!0}get isActive(){return this.gameObject.visible}constructor(){if(this.gameObject=new c.Object3D,this.gameObject.name="Implicit XR Rig",DS){const e=Mm(16733661);e.position.y+=.5,this.gameObject.add(e)}}}const $n=w("debugwebxr"),mh=w("debugcustomgesture"),jS="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",BS="generic-trigger",FS=new c.Quaternion().setFromEuler(new c.Euler(c.MathUtils.degToRad(0),c.MathUtils.degToRad(-90),c.MathUtils.degToRad(-90))),US=new c.Vector3(.04,-.04,0);class wm{xr;get context(){return this.xr.context}inputSource;index=0;emitEvents=!0;get connected(){return this._connected}_connected=!0;get isTracking(){return this._isTracking}_isTracking=!1;get gamepad(){return this.__gamepad??=this.inputSource.gamepad}__gamepad;get isHand(){return this.hand!=null}get hand(){return this.__hand??=this.inputSource.hand}__hand;get handObject(){return this.context.renderer.xr.getHand(this.index)}get profiles(){return this.inputSource.profiles}get layout(){return this._layout}get targetRayMode(){return this.inputSource.targetRayMode}get targetRaySpace(){return this.inputSource.targetRaySpace}get gripSpace(){return this.inputSource.gripSpace}get side(){return this.__side??=this.inputSource.handedness}__side=void 0;get isRight(){return this.side==="right"}get isLeft(){return this.side==="left"}get isStylus(){return this._isMxInk}getHitTestSource(){return this._hitTestSource||this._requestHitTestSource(),this._hitTestSource}get hasHitTestSource(){return this._hitTestSource}cancelHitTestSource(){this._hitTestSource&&(this._hitTestSource.cancel(),this._hitTestSource=void 0)}_hitTestSource=void 0;_hasSelectEvent=!1;get hasSelectEvent(){return this._hasSelectEvent}_isMxInk=!1;_isMetaQuestTouchController=!1;getHitTest(){return this.xr.getHitTest(this)}_handJointPoses=new Map;getHandJointPose(e,t){if(t=t||this.xr.frame,!this.hand||!t?.getJointPose||!this.xr.referenceSpace)return null;let i=this._handJointPoses?.get(e);return i||(i=t.getJointPose(e,this.xr.referenceSpace),i&&this._handJointPoses.set(e,i),i)}_gripMatrix=new c.Matrix4;_gripPosition=new c.Vector3;_gripQuaternion=new c.Quaternion;_linearVelocity=new c.Vector3;_rayPositionRaw=new c.Vector3;_rayRotationRaw=new c.Quaternion;_rayMatrix=new c.Matrix4;_rayPosition=new c.Vector3;_rayQuaternion=new c.Quaternion;get gripPosition(){return F(this._gripPosition)}get gripQuaternion(){return Ht(this._gripQuaternion)}get gripMatrix(){return this._gripMatrix}get gripLinearVelocity(){return F(this._linearVelocity).applyQuaternion(ki)}get rayPosition(){return F(this._rayPosition)}get rayQuaternion(){return Ht(this._rayQuaternion)}get gripWorldPosition(){return F(this._gripWorldPosition)}_gripWorldPosition=new c.Vector3;get gripWorldQuaternion(){return Ht(this._gripWorldQuaternion)}_gripWorldQuaternion=new c.Quaternion;get rayWorldPosition(){return F(this._rayWorldPosition)}_rayWorldPosition=new c.Vector3;updateRayWorldPosition(){const e=this.xr.context.mainCamera?.parent;this._rayWorldPosition.copy(this._rayPositionRaw),e&&this._rayWorldPosition.applyMatrix4(e.matrixWorld)}get rayWorldQuaternion(){return Ht(this._rayWorldQuaternion)}_rayWorldQuaternion=new c.Quaternion;get pinchPosition(){return F(this._pinchPosition)}_pinchPosition=new c.Vector3;updateRayWorldQuaternion(){const e=this.xr.context.mainCamera?.parent,t=e?ue(e):void 0;this._rayWorldQuaternion.copy(this._rayRotationRaw).multiply(ki),t&&this._rayWorldQuaternion.premultiply(t)}get ray(){return this._ray.origin.copy(this.rayWorldPosition),this._ray.direction.copy(F(0,0,1).applyQuaternion(this.rayWorldQuaternion)),this._ray}_ray;_hand_wristDotUp=void 0;get handWristDotUp(){if(this._hand_wristDotUp!==void 0)return this._hand_wristDotUp;const e=this.handObject?.joints.wrist;if(e){const t=F(0,1,0).applyQuaternion(e.quaternion),i=F(0,1,0).dot(t);return this._hand_wristDotUp=i}}get isHandUpsideDown(){return this.handWristDotUp!==void 0?this.handWristDotUp<-.7:!1}get isTeleportGesture(){return this.isHandUpsideDown&&this.getGesture("pinch")?.isDown}get object(){return this._object}_object;_gripSpaceObject;_raySpaceObject;model=null;_debugAxesHelper=new c.AxesHelper(.15);_debugGripAxesHelper=new c.AxesHelper(.07);_debugRayAxesHelper=new c.AxesHelper(.07);async getModelUrl(){return this.getMotionController?.then(e=>e?.assetUrl||null)}constructor(e,t,i){this.xr=e,this.inputSource=t,this.index=i,this._object=new c.Object3D,this._object.name=`NeedleXRController_${i}`,$n&&(this._object.add(this._debugAxesHelper),this._gripSpaceObject=new c.Object3D,this._raySpaceObject=new c.Object3D,this._gripSpaceObject.name=`NeedleXRController_${i}_gripSpace`,this._raySpaceObject.name=`NeedleXRController_${i}_raySpace`,this._gripSpaceObject.add(this._debugGripAxesHelper),this._raySpaceObject.add(this._debugRayAxesHelper),this.xr.context.scene.add(this._gripSpaceObject),this.xr.context.scene.add(this._raySpaceObject)),this.xr.context.scene.add(this._object),this._ray=new c.Ray,this.pointerInit={origin:this,pointerType:this.hand?"hand":"controller",deviceIndex:this.index,pointerId:-1,mode:this.inputSource.targetRayMode,ray:this._ray,device:this._object,buttonName:"none"},this.initialize(),this.subscribeEvents()}_hitTestSourcePromise=null;_requestHitTestSource(){return this._hitTestSourcePromise?this._hitTestSourcePromise:this.xr.mode==="immersive-ar"&&this.inputSource.targetRayMode==="tracked-pointer"&&this.xr.session.requestHitTestSourceForTransientInput?this._hitTestSourcePromise=this.xr.session.requestHitTestSourceForTransientInput({profile:this.inputSource.profiles[0],offsetRay:new XRRay})?.then(e=>(this._hitTestSourcePromise=null,this.connected?this._hitTestSource=e:(e.cancel(),null)))??null:null}onPointerHits=e=>{};onUpdate(e){this.onUpdateFrame(e),this.updateInputEvents(),this.onUpdateMove()}onRenderDebug(){I.DrawSphere(this.rayWorldPosition,.003),I.DrawDirection(this.rayWorldPosition,F(0,0,10).applyQuaternion(this.rayWorldQuaternion));const t=(this.inputSource.gripSpace?this.gripWorldPosition:this.object.worldPosition).sub(this.object.worldForward.multiplyScalar(.1)),i=this.inputSource.profiles.join(`
|
|
146
146
|
`);let n=`Controller[${this.index}] (${this.inputSource.targetRayMode}, ${this.side})
|
|
147
147
|
C:${this.connected?"x":"-"} T:${this.isTracking?"x":"-"} Hand:${this.inputSource.hand?"x":"-"} Pen: ${this._isMxInk?"x":"-"}`;if(this.inputSource.hand&&(n+=`
|
|
@@ -160,11 +160,11 @@ To unregister you can call the function returned by your event hook (e.g.const u
|
|
|
160
160
|
|
|
161
161
|
or by using the once option like onStart(()=>{}, { once:true }).
|
|
162
162
|
|
|
163
|
-
See https://engine.needle.tools/docs/scripting.html#special-lifecycle-hooks for more information.`))}}function oo(s,e){const t=Zr.get(e);if(t){for(let n=0;n<t.length;n++)if(t[n].method===s){t.splice(n,1);return}}const i=sa.get(e);if(i){for(let n=0;n<i.length;n++)if(i[n].method===s){i.splice(n,1);return}}}function pn(s,e){e===re.ContextCreated&&gp.delete(s),Yb(s,e)}function Yb(s,e){e===pe.Start&&sa.get(re.ContextCreated)&&Yb(s,re.ContextCreated);const t=e===pe.Start||e===re.ContextCreated,i=Zr.get(e);i&&i.length>0&&jy(s,i,t);const n=sa.get(e);if(n&&n.length>0){const o=[...n];n.length=0,jy(s,o,t),o.length>0&&(Zr.has(e)||Zr.set(e,new Array),Zr.get(e).push(...o))}}const gh=new Array,Iy={context:null};function jy(s,e,t){gh.length=0;for(let n=0;n<e.length;n++)gh.push(e[n]);let i=gp.get(s);for(let n=0;n<gh.length;n++){const o=gh[n];let r=!0;if(i&&i.has(o)&&(r=!1),r)try{Iy.context=s,o.method?.call(Iy,s)}catch(a){console.error("Error in lifecycle method",a)}if(o.options?.once){for(let a=0;a<e.length;a++)if(e[a]===o){e.splice(a,1);break}}else t&&(i||(i=new Set,gp.set(s,i)),i.add(o))}}const gp=new WeakMap,xm={};function Sm(s,e){xm[s]=e}function Kb(s){const e=s.getBufferIdentifier(),t=xm[e];return t(s)}function Zb(s){return typeof s.guid=="function"?s.guid():null}let Cm;function zS(){return Cm}function NS(s){Cm=s}function Jb(s,e){return e||(e={}),e={...Cm,...e},s?new se.$70d766613f57b014$export$2e2bcd8739ae039(s,e):new se.$70d766613f57b014$export$2e2bcd8739ae039(e)}async function By(){const s=await Promise.resolve().then(()=>require("./vendor-D0Yvltn9.umd.cjs")).then(e=>e.bundler);return console.log(s),s.default===void 0?s:s.default}class e0{get isHost(){return this._host!==void 0}_host;_client;_clientData;constructor(){this.onEnable()}onEnable(){this.trySetupHost("HOST-5980e65c-8438-453e-8b35-f13c736dcd81")}async trySetupHost(e){const t=await By(),i=new t(e);i.on("error",n=>{console.error(n),this._host=void 0,this.trySetupClient(e)}),i.on("open",n=>{this._host=new $S(i)})}async trySetupClient(e){const t=await By();this._client=new t,this._client.on("error",i=>{console.error("Client error",i)}),this._client.on("open",i=>{console.log("client connected",i),this._clientData=this._client.connect(e,{metadata:{id:i}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",n=>{console.log("<<",n)})})}}class VS{_peer;constructor(e){this._peer=e}}class $S extends VS{get isHost(){return!0}_connections=[];constructor(e){super(e),console.log("I AM THE HOST"),this._peer?.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}onConnection(e){console.log("host connection",e),e.on("open",()=>{this._connections.push(e),this.broadcastConnection(e)})}broadcastConnection(e){const t=this._connections.map(i=>i.metadata?.id).filter(i=>i!==void 0);this.broadcast({type:"connection-list",connections:t})}broadcast(e){if(e!=null){console.log(">>",e);for(const t in this._peer.connections){const i=this._peer.connections[t];if(i)if(Array.isArray(i))for(const n of i)n&&n.send(e);else console.warn(i)}}}}var Yi=(s=>(s[s.OnConnection=0]="OnConnection",s[s.OnRoomJoin=1]="OnRoomJoin",s[s.Queued=2]="Queued",s[s.Immediate=3]="Immediate",s))(Yi||{});const Fy="https://urls.needle.tools/default-networking-backend/index";let xi="wss://networking.needle.tools/socket";const zt=!!w("debugnet"),_l=!!(zt||w("debugowner")),yh=w("debugnetbin");var t0=(s=>(s.ConnectionInfo="connection-start-info",s))(t0||{}),Q=(s=>(s.Join="join-room",s.Leave="leave-room",s.JoinedRoom="joined-room",s.LeftRoom="left-room",s.UserJoinedRoom="user-joined-room",s.UserLeftRoom="user-left-room",s.RoomStateSent="room-state-sent",s))(Q||{});class WS{room;viewId;allowEditing;inRoom}class HS{room}class GS{userId}var i0=(s=>(s.RequestHasOwner="request-has-owner",s.ResponseHasOwner="response-has-owner",s.RequestIsOwner="request-is-owner",s.ResponseIsOwner="response-is-owner",s.RequestOwnership="request-ownership",s.GainedOwnership="gained-ownership",s.RemoveOwnership="remove-ownership",s.LostOwnership="lost-ownership",s.GainedOwnershipBroadcast="gained-ownership-broadcast",s.LostOwnershipBroadcast="lost-ownership-broadcast",s))(i0||{});class Pm{guid;connection;get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}_hasOwnership=!1;_isOwned=void 0;_gainSubscription;_lostSubscription;_hasOwnerResponse;constructor(e,t){this.connection=e,this.guid=t,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),e.beginListen("lost-ownership",this._lostSubscription),e.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),e.beginListen("response-has-owner",this._hasOwnerResponse)}_isWaitingForOwnershipResponseCallback=null;updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(e){e.guid===this.guid&&(this._isOwned=e.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(e){e.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=e.value,e.value||(_l&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((e,t)=>{this.requestOwnership();let i=0;const n=()=>{if(i++>10)return t("Timeout");setTimeout(()=>{this.hasOwnership?e(this):n()},100)};n()})}requestOwnership(){return _l&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(e){e.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===e.owner?(_l&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(e){e===this.guid&&(_l&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class n0{context;_peer=null;constructor(e){this.context=e}get peer(){return this._peer||(this._peer=new e0),this._peer}tryGetState(e){return e==="invalid"?null:this._state[e]}get connectionId(){return this._connectionId}get isDebugEnabled(){return zt}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const e=new URL(window.location.href);return e.searchParams.set("view",this.currentRoomViewId),e.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){return this._ws?.url??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(e){return this._currentInRoom.indexOf(e)!==-1}_usersInRoomCopy=[];usersInRoom(e=null){e||(e=this._usersInRoomCopy),e.length=0;for(const t of this._currentInRoom)e.push(t);return e}joinRoom(e,t=!1){return e?e.length>1024?(console.error('Room name too long, can not join: "'+e+'". Max length is 1024 characters.'),!1):(this.isInRoom&&this.currentRoomName!==e&&console.warn("Needle Engine is already connected to a networking room. Connecting to multiple rooms is not supported"),this.connect(),zt&&console.log("join: "+e),this.send("join-room",{room:e,viewOnly:t},Yi.OnConnection),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}leaveRoom(e=null){return e||(e=this.currentRoomName),e?(this.send("leave-room",{room:e}),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}send(e,t=null,i=Yi.Queued){if(t===null&&(t={}),i===Yi.Queued){this._defaultMessagesBuffer.push({key:e,value:t});return}return this.sendWithWebsocket(e,t,i)}sendDeleteRemoteState(e){this.send("delete-state",{guid:e,dontSave:!0}),delete this._state[e]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(e){yh&&console.log("<< send binary",this.context.time.frame,e.length/1024+" KB"),this._ws?.send(e)}_defaultMessagesBuffer=[];_defaultMessagesBufferArray=[];sendBufferedMessagesNow(){if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const e=Object.keys(this._defaultMessagesBuffer).length;for(const i in this._defaultMessagesBuffer){const n=this._defaultMessagesBuffer[i];if(e<=1){this.sendWithWebsocket(n.key,n.value,Yi.Immediate);break}const o=this.toMessage(n.key,n.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&zt&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const t=JSON.stringify(this._defaultMessagesBufferArray);this._ws?.send(t)}beginListen(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),t}stopListening(e,t){return this.stopListen(e,t)}stopListen(e,t){if(!t||!this._listeners[e])return;const i=this._listeners[e].indexOf(t);i>=0&&this._listeners[e].splice(i,1)}beginListenBinary(e,t){return this._listenersBinary[e]||(this._listenersBinary[e]=[]),this._listenersBinary[e].push(t),t}stopListenBinary(e,t){if(!this._listenersBinary[e])return;const i=this._listenersBinary[e].indexOf(t);i>=0&&this._listenersBinary[e].splice(i,1)}netWebSocketUrlProvider;registerProvider(e){this.netWebSocketUrlProvider=e}async connect(e){if(this.connected&&e&&e!==xi)return Promise.reject("Can not connect to different server url. Please disconnect first.");if(this.connected)return Promise.resolve(!0);e&&console.debug("Connecting to user provided url "+e);const t=e||this.netWebSocketUrlProvider?.getWebsocketUrl();return t?xi=t:gb()&&(xi="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){this._ws?.close(),this._ws=void 0,xi=void 0,this._currentRoomAllowEditing=!0,this._currentRoomName=null,this._currentRoomViewId=null,this._isInRoom=!1,this._currentInRoom.length=0,this._state={},this._currentDelay=-1}_listeners={};_listenersBinary={};connected=!1;channelId;_connectionId=null;_ws;_waitingForSocket={};_isInRoom=!1;_currentRoomName=null;_currentRoomViewId=null;_currentRoomAllowEditing=!0;_currentInRoom=[];_state={};_currentDelay=-1;_connectingToWebsocketPromise=null;connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(e,t)=>{let i=!1;const n=h=>{i||(i=!0,e(h))};if(xi===void 0&&(console.log("Fetch default backend url: "+Fy),xi=await(await fetch(Fy)).text()),xi===void 0){n(!1);return}console.debug(`⊡ Connecting to networking backend on
|
|
164
|
-
`+xi);const o=await Promise.resolve().then(()=>require("./vendor-
|
|
163
|
+
See https://engine.needle.tools/docs/scripting.html#special-lifecycle-hooks for more information.`))}}function oo(s,e){const t=Zr.get(e);if(t){for(let n=0;n<t.length;n++)if(t[n].method===s){t.splice(n,1);return}}const i=sa.get(e);if(i){for(let n=0;n<i.length;n++)if(i[n].method===s){i.splice(n,1);return}}}function pn(s,e){e===re.ContextCreated&&gp.delete(s),Yb(s,e)}function Yb(s,e){e===pe.Start&&sa.get(re.ContextCreated)&&Yb(s,re.ContextCreated);const t=e===pe.Start||e===re.ContextCreated,i=Zr.get(e);i&&i.length>0&&jy(s,i,t);const n=sa.get(e);if(n&&n.length>0){const o=[...n];n.length=0,jy(s,o,t),o.length>0&&(Zr.has(e)||Zr.set(e,new Array),Zr.get(e).push(...o))}}const gh=new Array,Iy={context:null};function jy(s,e,t){gh.length=0;for(let n=0;n<e.length;n++)gh.push(e[n]);let i=gp.get(s);for(let n=0;n<gh.length;n++){const o=gh[n];let r=!0;if(i&&i.has(o)&&(r=!1),r)try{Iy.context=s,o.method?.call(Iy,s)}catch(a){console.error("Error in lifecycle method",a)}if(o.options?.once){for(let a=0;a<e.length;a++)if(e[a]===o){e.splice(a,1);break}}else t&&(i||(i=new Set,gp.set(s,i)),i.add(o))}}const gp=new WeakMap,xm={};function Sm(s,e){xm[s]=e}function Kb(s){const e=s.getBufferIdentifier(),t=xm[e];return t(s)}function Zb(s){return typeof s.guid=="function"?s.guid():null}let Cm;function zS(){return Cm}function NS(s){Cm=s}function Jb(s,e){return e||(e={}),e={...Cm,...e},s?new se.$70d766613f57b014$export$2e2bcd8739ae039(s,e):new se.$70d766613f57b014$export$2e2bcd8739ae039(e)}async function By(){const s=await Promise.resolve().then(()=>require("./vendor-CPuBPspY.umd.cjs")).then(e=>e.bundler);return console.log(s),s.default===void 0?s:s.default}class e0{get isHost(){return this._host!==void 0}_host;_client;_clientData;constructor(){this.onEnable()}onEnable(){this.trySetupHost("HOST-5980e65c-8438-453e-8b35-f13c736dcd81")}async trySetupHost(e){const t=await By(),i=new t(e);i.on("error",n=>{console.error(n),this._host=void 0,this.trySetupClient(e)}),i.on("open",n=>{this._host=new $S(i)})}async trySetupClient(e){const t=await By();this._client=new t,this._client.on("error",i=>{console.error("Client error",i)}),this._client.on("open",i=>{console.log("client connected",i),this._clientData=this._client.connect(e,{metadata:{id:i}}),this._clientData.on("open",()=>{console.log("Connected to host")}),this._clientData.on("data",n=>{console.log("<<",n)})})}}class VS{_peer;constructor(e){this._peer=e}}class $S extends VS{get isHost(){return!0}_connections=[];constructor(e){super(e),console.log("I AM THE HOST"),this._peer?.on("connection",this.onConnection.bind(this)),this._peer.on("close",()=>{this.broadcast("BYE")}),setInterval(()=>{this.broadcast("HELLO")},2e3)}onConnection(e){console.log("host connection",e),e.on("open",()=>{this._connections.push(e),this.broadcastConnection(e)})}broadcastConnection(e){const t=this._connections.map(i=>i.metadata?.id).filter(i=>i!==void 0);this.broadcast({type:"connection-list",connections:t})}broadcast(e){if(e!=null){console.log(">>",e);for(const t in this._peer.connections){const i=this._peer.connections[t];if(i)if(Array.isArray(i))for(const n of i)n&&n.send(e);else console.warn(i)}}}}var Yi=(s=>(s[s.OnConnection=0]="OnConnection",s[s.OnRoomJoin=1]="OnRoomJoin",s[s.Queued=2]="Queued",s[s.Immediate=3]="Immediate",s))(Yi||{});const Fy="https://urls.needle.tools/default-networking-backend/index";let xi="wss://networking.needle.tools/socket";const zt=!!w("debugnet"),_l=!!(zt||w("debugowner")),yh=w("debugnetbin");var t0=(s=>(s.ConnectionInfo="connection-start-info",s))(t0||{}),Q=(s=>(s.Join="join-room",s.Leave="leave-room",s.JoinedRoom="joined-room",s.LeftRoom="left-room",s.UserJoinedRoom="user-joined-room",s.UserLeftRoom="user-left-room",s.RoomStateSent="room-state-sent",s))(Q||{});class WS{room;viewId;allowEditing;inRoom}class HS{room}class GS{userId}var i0=(s=>(s.RequestHasOwner="request-has-owner",s.ResponseHasOwner="response-has-owner",s.RequestIsOwner="request-is-owner",s.ResponseIsOwner="response-is-owner",s.RequestOwnership="request-ownership",s.GainedOwnership="gained-ownership",s.RemoveOwnership="remove-ownership",s.LostOwnership="lost-ownership",s.GainedOwnershipBroadcast="gained-ownership-broadcast",s.LostOwnershipBroadcast="lost-ownership-broadcast",s))(i0||{});class Pm{guid;connection;get hasOwnership(){return this._hasOwnership}get isOwned(){return this._isOwned}get isConnected(){return this.connection.isConnected}_hasOwnership=!1;_isOwned=void 0;_gainSubscription;_lostSubscription;_hasOwnerResponse;constructor(e,t){this.connection=e,this.guid=t,this._gainSubscription=this.onGainedOwnership.bind(this),this._lostSubscription=this.onLostOwnership.bind(this),e.beginListen("lost-ownership",this._lostSubscription),e.beginListen("gained-ownership-broadcast",this._gainSubscription),this._hasOwnerResponse=this.onHasOwnerResponse.bind(this),e.beginListen("response-has-owner",this._hasOwnerResponse)}_isWaitingForOwnershipResponseCallback=null;updateIsOwned(){this.connection.send("request-has-owner",{guid:this.guid})}onHasOwnerResponse(e){e.guid===this.guid&&(this._isOwned=e.value)}requestOwnershipIfNotOwned(){return this._isWaitingForOwnershipResponseCallback!==null?this:(this._isWaitingForOwnershipResponseCallback=this.waitForHasOwnershipRequestResponse.bind(this),this.connection.beginListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this.connection.send("request-has-owner",{guid:this.guid}),this)}waitForHasOwnershipRequestResponse(e){e.guid===this.guid&&(this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this._isOwned=e.value,e.value||(_l&&console.log("request ownership",this.guid),this.requestOwnership()))}requestOwnershipAsync(){return new Promise((e,t)=>{this.requestOwnership();let i=0;const n=()=>{if(i++>10)return t("Timeout");setTimeout(()=>{this.hasOwnership?e(this):n()},100)};n()})}requestOwnership(){return _l&&console.log("Request ownership",this.guid),this.connection.send("request-ownership",{guid:this.guid}),this}freeOwnership(){return this.connection.send("remove-ownership",{guid:this.guid}),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null),this}destroy(){this.connection.stopListen("gained-ownership",this._gainSubscription),this.connection.stopListen("lost-ownership",this._lostSubscription),this.connection.stopListen("response-has-owner",this._hasOwnerResponse),this._isWaitingForOwnershipResponseCallback&&(this.connection.stopListen("response-has-owner",this._isWaitingForOwnershipResponseCallback),this._isWaitingForOwnershipResponseCallback=null)}onGainedOwnership(e){e.guid===this.guid&&(this._isOwned=!0,this.connection.connectionId===e.owner?(_l&&console.log("GAINED OWNERSHIP",this.guid),this._hasOwnership=!0):this._hasOwnership=!1)}onLostOwnership(e){e===this.guid&&(_l&&console.log("LOST OWNERSHIP",this.guid),this._hasOwnership=!1,this._isOwned=!1)}}class n0{context;_peer=null;constructor(e){this.context=e}get peer(){return this._peer||(this._peer=new e0),this._peer}tryGetState(e){return e==="invalid"?null:this._state[e]}get connectionId(){return this._connectionId}get isDebugEnabled(){return zt}get isConnected(){return this.connected}get currentRoomName(){return this._currentRoomName}get allowEditing(){return this._currentRoomAllowEditing}get currentRoomViewId(){return this._currentRoomViewId}getViewOnlyUrl(){if(this.currentRoomViewId===null)return null;const e=new URL(window.location.href);return e.searchParams.set("view",this.currentRoomViewId),e.href}get isInRoom(){return this._isInRoom}get currentLatency(){return this._currentDelay}get currentServerUrl(){return this._ws?.url??null}sendPing(){this.send("ping",{time:this.context.time.time})}userIsInRoom(e){return this._currentInRoom.indexOf(e)!==-1}_usersInRoomCopy=[];usersInRoom(e=null){e||(e=this._usersInRoomCopy),e.length=0;for(const t of this._currentInRoom)e.push(t);return e}joinRoom(e,t=!1){return e?e.length>1024?(console.error('Room name too long, can not join: "'+e+'". Max length is 1024 characters.'),!1):(this.isInRoom&&this.currentRoomName!==e&&console.warn("Needle Engine is already connected to a networking room. Connecting to multiple rooms is not supported"),this.connect(),zt&&console.log("join: "+e),this.send("join-room",{room:e,viewOnly:t},Yi.OnConnection),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}leaveRoom(e=null){return e||(e=this.currentRoomName),e?(this.send("leave-room",{room:e}),!0):(console.error('Missing room name, can not join: "'+e+'"'),!1)}send(e,t=null,i=Yi.Queued){if(t===null&&(t={}),i===Yi.Queued){this._defaultMessagesBuffer.push({key:e,value:t});return}return this.sendWithWebsocket(e,t,i)}sendDeleteRemoteState(e){this.send("delete-state",{guid:e,dontSave:!0}),delete this._state[e]}sendDeleteRemoteStateAll(){this.send("delete-all-state"),this._state={}}sendBinary(e){yh&&console.log("<< send binary",this.context.time.frame,e.length/1024+" KB"),this._ws?.send(e)}_defaultMessagesBuffer=[];_defaultMessagesBufferArray=[];sendBufferedMessagesNow(){if(!this._ws)return;this._defaultMessagesBufferArray.length=0;const e=Object.keys(this._defaultMessagesBuffer).length;for(const i in this._defaultMessagesBuffer){const n=this._defaultMessagesBuffer[i];if(e<=1){this.sendWithWebsocket(n.key,n.value,Yi.Immediate);break}const o=this.toMessage(n.key,n.value);this._defaultMessagesBufferArray.push(o)}if(this._defaultMessagesBuffer.length=0,this._defaultMessagesBufferArray.length>0&&zt&&console.log("SEND BUFFERED",this._defaultMessagesBufferArray.length),this._defaultMessagesBufferArray.length<=0)return;const t=JSON.stringify(this._defaultMessagesBufferArray);this._ws?.send(t)}beginListen(e,t){return this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t),t}stopListening(e,t){return this.stopListen(e,t)}stopListen(e,t){if(!t||!this._listeners[e])return;const i=this._listeners[e].indexOf(t);i>=0&&this._listeners[e].splice(i,1)}beginListenBinary(e,t){return this._listenersBinary[e]||(this._listenersBinary[e]=[]),this._listenersBinary[e].push(t),t}stopListenBinary(e,t){if(!this._listenersBinary[e])return;const i=this._listenersBinary[e].indexOf(t);i>=0&&this._listenersBinary[e].splice(i,1)}netWebSocketUrlProvider;registerProvider(e){this.netWebSocketUrlProvider=e}async connect(e){if(this.connected&&e&&e!==xi)return Promise.reject("Can not connect to different server url. Please disconnect first.");if(this.connected)return Promise.resolve(!0);e&&console.debug("Connecting to user provided url "+e);const t=e||this.netWebSocketUrlProvider?.getWebsocketUrl();return t?xi=t:gb()&&(xi="wss://"+window.location.host+"/socket"),this.connectWebsocket()}disconnect(){this._ws?.close(),this._ws=void 0,xi=void 0,this._currentRoomAllowEditing=!0,this._currentRoomName=null,this._currentRoomViewId=null,this._isInRoom=!1,this._currentInRoom.length=0,this._state={},this._currentDelay=-1}_listeners={};_listenersBinary={};connected=!1;channelId;_connectionId=null;_ws;_waitingForSocket={};_isInRoom=!1;_currentRoomName=null;_currentRoomViewId=null;_currentRoomAllowEditing=!0;_currentInRoom=[];_state={};_currentDelay=-1;_connectingToWebsocketPromise=null;connectWebsocket(){return this._connectingToWebsocketPromise?this._connectingToWebsocketPromise:this._connectingToWebsocketPromise=new Promise(async(e,t)=>{let i=!1;const n=h=>{i||(i=!0,e(h))};if(xi===void 0&&(console.log("Fetch default backend url: "+Fy),xi=await(await fetch(Fy)).text()),xi===void 0){n(!1);return}console.debug(`⊡ Connecting to networking backend on
|
|
164
|
+
`+xi);const o=await Promise.resolve().then(()=>require("./vendor-CPuBPspY.umd.cjs")).then(h=>h.index),r=o.default?.WebsocketBuilder??o.WebsocketBuilder,a=o.default?.ExponentialBackoff??o.ExponentialBackoff,l=new r(xi).withMaxRetries(10).withBackoff(new a(2e3,4)).onOpen(()=>{this._connectingToWebsocketPromise=null,this._ws=l,this.connected=!0,A()||zt?console.log(`⊞ Connected to networking backend
|
|
165
165
|
`+xi):console.debug("⊞ Connected to networking backend",xi),n(!0),this.onSendQueued(Yi.OnConnection)}).onClose(h=>{this._connectingToWebsocketPromise=null,this.connected=!1,this._isInRoom=!1,n(!1);let d="Websocket connection closed...";xi?.includes("/socket")||(d+=' Do you perhaps mean to connect to "/socket"?'),console.error(d)}).onError(h=>{console.error("⊠ Websocket connection failed..."),n(!1)}).onRetry(()=>{console.log("→ Retry connecting to networking websocket")}).build();l.addEventListener(o.WebsocketEvent.message,(h,d)=>{this.onMessage(h,d)})})}onMessage(e,t){const i=t.data;try{if(typeof i!="string"){i.size&&this.handleIncomingBinaryMessage(i);return}const n=JSON.parse(i);if(Array.isArray(n))for(const o of n)this.handleIncomingStringMessage(o);else this.handleIncomingStringMessage(n);return}catch(n){zt&&i==="pong"?console.log("<<",i):A()&&console.error("Failed to parse message",n)}}async handleIncomingBinaryMessage(e){yh&&console.log("<< bin",this.context.time.frame);const t=await e.arrayBuffer();var i=new Uint8Array(t);const n=new se.ByteBuffer(i),o=n.getBufferIdentifier(),r=this._listenersBinary[o],a=Kb(n),l=Zb(a);if(l&&typeof l=="string"&&(this._state[l]=a),!r)return;const h=a??n;for(const d of r)d(h)}handleIncomingStringMessage(e){if(zt&&console.log("<<",e.key??e),e.key)switch(e.key){case"connection-start-info":if(e.data){const r=e.data;r&&(console.assert(r.id!==void 0&&r.id!==null&&r.id.length>0,"server did not send connection id",r.id),console.debug("Your id is: "+r.id,this.context.alias??""),this._connectionId=r.id)}else console.warn("Expected connection id in "+e.key);break;case"joined-room":if(zt&&console.log(e),e){this._isInRoom=!0;const r=e;this._currentRoomName=r.room,this._currentRoomViewId=r.viewId,this._currentRoomAllowEditing=r.allowEditing??!0,this._currentInRoom.length=0,this._currentInRoom.push(...r.inRoom),(yh||A())&&console.debug("Joined Needle Engine Room: "+r.room);const a=new URL(window.location.href);a.searchParams.has("room")&&a.searchParams.delete("room"),a.searchParams.set("view",this._currentRoomViewId),console.debug(`Room view id: ${this._currentRoomViewId}
|
|
166
166
|
${a.href}`)}this.onSendQueued(Yi.OnRoomJoin);break;case"left-room":const n=e;n.room===this.currentRoomName&&(this._isInRoom=!1,this._currentRoomName=null,this._currentRoomAllowEditing=!0,this._currentInRoom.length=0,(yh||A())&&console.debug("Left Needle Engine Room: "+n.room));break;case"user-joined-room":if(e.data){const r=e.data;this._currentInRoom.push(r.userId),zt&&console.log(r.userId+" joined","now in room:",this._currentInRoom)}break;case"user-left-room":if(e.data){const r=e.data,a=this._currentInRoom.indexOf(r.userId);a>=0&&(zt&&console.log(r.userId+" left","now in room:",this._currentInRoom),this._currentInRoom.splice(a,1)),r.userId===this.connectionId&&console.log("you left the room")}break;case"all-room-state-deleted":zt&&console.log("RECEIVED all-room-state-deleted"),this._state={};break;case"ping":case"pong":const o=e.data?.time;o&&(this._currentDelay=this.context.time.time-o),zt&&console.log(`Current latency: ${(this._currentDelay*1e3).toFixed()} ms`,"Clients in room: "+this._currentInRoom?.length);break}const t=e.data;t&&(this._state[t.guid]=t);let i=this._listeners[e.key];if(i){i=[...i];for(const n of i)try{n(e.data)}catch(o){console.error('Error invoking callback for "'+e.key+'"',o)}}}toMessage(e,t){return{key:e,data:t}}sendWithWebsocket(e,t,i=Yi.OnRoomJoin){if(!this._ws){const o=this._waitingForSocket[i]||[];o.push(()=>this.sendWithWebsocket(e,t,i)),this._waitingForSocket[i]=o;return}const n=JSON.stringify(this.toMessage(e,t));zt&&console.log(">>",e),this._ws.send(n)}onSendQueued(e){const t=this._waitingForSocket[e];if(t){for(const i of t)i();t.length=0}}}const jl=w("debugwebxr");class rf{controllerStates=[];userId;context;userStateEvtName;constructor(e,t){this.userId=e,this.context=t,this.userStateEvtName="xr-sync-user-state-"+e,this.context.connection.beginListen(this.userStateEvtName,this.onReceivedControllerState)}dispose(){this.context.connection.stopListen(this.userStateEvtName,this.onReceivedControllerState)}onReceivedControllerState=e=>{jl&&console.log(`XRSync: Received change for ${this.userId}: ${e.type} ${e.handedness}; tracked=${e.isTracking}`);let t=!1;for(let i=0;i<this.controllerStates.length;i++)if(this.controllerStates[i].index===e.index){this.controllerStates[i]=e,t=!0;break}t||this.controllerStates.push(e)};update(e){if(this.context.connection.isConnected!=!1){for(let t=this.controllerStates.length-1;t>=0;t--){const i=this.controllerStates[t];let n=!1;for(let o=0;o<e.controllers.length;o++)e.controllers[o].index===i.index&&(n=!0);n||(jl&&console.log(`XRSync: ${i.type} ${i.handedness} removed`,i.index),this.controllerStates.splice(t,1),this.sendControllerRemoved(i))}for(const t of e.controllers)this.updateControllerStates(t)}}onExitXR(e){for(const t of this.controllerStates)this.sendControllerRemoved(t);this.controllerStates.length=0}sendControllerRemoved(e){e.isTracking=!1,e.guid="",this.context.connection.send(this.userStateEvtName,e),this.context.connection.sendDeleteRemoteState(e.guid)}updateControllerStates(e){const t=this.controllerStates.find(i=>i.index===e.index);if(t){let i=!1;i||=t.isTracking!=e.isTracking,i&&(t.isTracking=e.isTracking,this.context.connection.send(this.userStateEvtName,t))}else{const i={guid:this.userId+"-"+e.index,isTracking:e.isTracking,handedness:e.side,index:e.index,type:e.hand?"hand":"controller"};this.controllerStates.push(i),this.context.connection.send(this.userStateEvtName,i),jl&&console.log(`XRSync: ${i.type} ${i.handedness} added`,i.index)}}}class s0{hasState(e){return e?this._states.has(e):!1}isTracking(e,t){if(!e)return;const i=this._states.get(e);return i?i.controllerStates.find(o=>o.handedness===t)?.isTracking||!1:void 0}getDeviceType(e,t){if(!e)return;const i=this._states.get(e);return i?i.controllerStates.find(o=>o.handedness===t)?.type||"unknown":void 0}context;constructor(e){this.context=e,this.context.connection.beginListen(Q.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Q.LeftRoom,this.onLeftRoom),this.context.connection.beginListen(Q.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.beginListen(Q.UserLeftRoom,this.onOtherUserLeftRoom)}destroy(){this.context.connection.stopListen(Q.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Q.LeftRoom,this.onLeftRoom),this.context.connection.stopListen(Q.UserJoinedRoom,this.onOtherUserJoinedRoom),this.context.connection.stopListen(Q.UserLeftRoom,this.onOtherUserLeftRoom)}onJoinedRoom=()=>{if(this.context.connection.connectionId){this._states.has(this.context.connection.connectionId)||(jl&&console.log("XRSync: Local user joined room",this.context.connection.connectionId),this._states.set(this.context.connection.connectionId,new rf(this.context.connection.connectionId,this.context)));for(const e of this.context.connection.usersInRoom())this._states.has(e)||this._states.set(e,new rf(e,this.context))}};onLeftRoom=()=>{this.context.connection.connectionId&&(this._states.has(this.context.connection.connectionId)||(this._states.get(this.context.connection.connectionId)?.dispose(),this._states.delete(this.context.connection.connectionId)))};onOtherUserJoinedRoom=e=>{const t=e.userId;this._states.has(t)||(jl&&console.log("XRSync: Remote user joined room",t),this._states.set(t,new rf(t,this.context)))};onOtherUserLeftRoom=e=>{const t=e.userId;this._states.has(t)||(this._states.get(t)?.dispose(),this._states.delete(t))};_states=new Map;onUpdate(e){this.context.connection.isConnected&&this.context.connection.connectionId&&this._states.get(this.context.connection.connectionId)?.update(e)}onExitXR(e){this.context.connection.isConnected&&this.context.connection.connectionId&&this._states.get(this.context.connection.connectionId)?.onExitXR(e)}}class Uy{_fadeToColorQuad;_fadeToColorMaterial;constructor(){this._fadeToColorMaterial=new c.MeshBasicMaterial({color:0,transparent:!0,depthTest:!1,fog:!1,side:c.DoubleSide}),this._fadeToColorQuad=new c.Mesh(new c.PlaneGeometry(10,10),this._fadeToColorMaterial)}dispose(){this._fadeToColorQuad.geometry.dispose(),this._fadeToColorMaterial.dispose()}update(e,t){const i=this._fadeToColorQuad,n=this._fadeToColorMaterial;i.parent!==e&&n.opacity>0?e.add(i):n.opacity===0&&i.removeFromParent(),i.layers.set(2),i.material=this._fadeToColorMaterial,i.position.z=-1,i.renderOrder=1/0;const o=this._requestedFadeValue;n.opacity=D.lerp(n.opacity,o,t/.03),Math.abs(n.opacity-o)<=.01&&this._transitionResolve&&(this._transitionResolve(),this._transitionResolve=null,this._transitionPromise=null,this._requestedFadeValue=0)}remove(){this._fadeToColorQuad.removeFromParent()}fadeTransition(){if(this._transitionPromise)return this._transitionPromise;this._requestedFadeValue=1;const e=new Promise(t=>{this._transitionResolve=t});return this._transitionPromise=e,e}_requestedFadeValue=0;_transitionPromise=null;_transitionResolve=null}var Yo=(s=>(s[s.Quad=0]="Quad",s[s.Cube=1]="Cube",s[s.Sphere=2]="Sphere",s[s.Cylinder=3]="Cylinder",s[s.RoundedCube=10]="RoundedCube",s))(Yo||{});class ar{static createText(e,t){let i=null;const n=t?.font||XS(t?.familyFamily||null);n instanceof q.Font?i=this.#t(e,n,t):i==null&&(i=new c.BufferGeometry);const o=t?.color||16777215,r=new c.Mesh(i,t?.material??new c.MeshStandardMaterial({color:o}));return this.applyDefaultObjectOptions(r,t),n instanceof Promise?n.then(a=>{r.geometry=this.#t(e,a,t),t?.onGeometry&&t.onGeometry(r)}):t?.onGeometry&&t.onGeometry(r),r}static#t(e,t,i){const n=i?.depth||.1;return new q.TextGeometry(e,{font:t,size:1,depth:n,height:n,bevelEnabled:i?.bevel||!1,bevelThickness:.01,bevelOffset:.01,bevelSize:.01})}static createOccluder(e){const t=new c.MeshBasicMaterial({colorWrite:!1,depthWrite:!0,side:c.DoubleSide});return this.createPrimitive(e,{material:t})}static createPrimitive(e,t){let i;const n=t?.color||16777215;switch(e){case"Quad":case 0:{const o=new c.PlaneGeometry(1,1,1,1),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Quad"}break;case"Cube":case 1:{const o=new c.BoxGeometry(1,1,1),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Cube"}break;case 10:case"RoundedCube":{const o=qS(1,1,1,.1,2),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="RoundedCube"}break;case"Sphere":case 2:{const o=new c.SphereGeometry(.5,16,16),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Sphere"}break;case"Cylinder":case 3:{const o=new c.CylinderGeometry(.5,.5,1,32),r=t?.material??new c.MeshStandardMaterial({color:n});t?.texture&&"map"in r&&(r.map=t.texture),i=new c.Mesh(o,r),i.name="Cylinder"}break;case"ShaderBall":i=new c.Group,i.name="ShaderBall",QS(i,t);break}return this.applyDefaultObjectOptions(i,t),i}static createSprite(e){const i=new c.SpriteMaterial({color:16777215});e?.texture&&"map"in i&&(i.map=e.texture);const n=new c.Sprite(i);return this.applyDefaultObjectOptions(n,e),n}static applyDefaultObjectOptions(e,t){e.receiveShadow=!0,e.castShadow=!0,t?.name&&(e.name=t.name),t?.position&&(Array.isArray(t.position)?e.position.set(t.position[0],t.position[1],t.position[2]):e.position.set(t.position.x||0,t.position.y||0,t.position.z||0)),t?.rotation&&(Array.isArray(t.rotation)?e.rotation.set(t.rotation[0],t.rotation[1],t.rotation[2]):e.rotation.set(t.rotation.x||0,t.rotation.y||0,t.rotation.z||0)),t?.scale&&(typeof t.scale=="number"?e.scale.set(t.scale,t.scale,t.scale):Array.isArray(t.scale)?e.scale.set(t.scale[0],t.scale[1],t.scale[2]):e.scale.set(t.scale.x||1,t.scale.y||1,t.scale.z||1)),t?.receiveShadow!=null&&(e.receiveShadow=t.receiveShadow),t?.castShadow!=null&&(e.castShadow=t.castShadow),t?.parent&&t.parent.add(e)}}function qS(s,e,t,i,n){const o=new c.Shape,r=1e-5,a=i-r;o.absarc(r,r,r,-Math.PI/2,-Math.PI,!0),o.absarc(r,e-a*2,r,Math.PI,Math.PI/2,!0),o.absarc(s-a*2,e-a*2,r,Math.PI/2,0,!0),o.absarc(s-a*2,r,r,0,-Math.PI/2,!0);const l=new c.ExtrudeGeometry(o,{bevelEnabled:!0,bevelSegments:n*2,steps:1,bevelSize:a,bevelThickness:i,curveSegments:n,UVGenerator:{generateTopUV:(h,d)=>{const u=[];for(let p=0;p<d.length;p+=3)u.push(new c.Vector2(d[p]/s,d[p+1]/e));return u},generateSideWallUV:(h,d,u,p,m,y)=>{const _=[];return _.push(new c.Vector2(d[u]/s,d[u+1]/e)),_.push(new c.Vector2(d[p]/s,d[p+1]/e)),_.push(new c.Vector2(d[m]/s,d[m+1]/e)),_.push(new c.Vector2(d[y]/s,d[y+1]/e)),_}}});return l.scale(1,1,1-i),l.center(),l.index||l.setIndex(Array.from({length:l.attributes.position.count},(h,d)=>d)),l.computeVertexNormals(),l}const _h=new Map;function XS(s){let e="";switch(s){default:case"OpenSans":e="https://cdn.needle.tools/static/fonts/facetype/Open Sans_Regular_ascii.json";break;case"Helvetiker":e="https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/helvetiker_regular.typeface.json";break}if(_h.has(e)){const n=_h.get(e);if(n)return n}const t=new q.FontLoader,i=new Promise((n,o)=>{t.load(e,r=>{_h.set(e,r),n(r)},void 0,o)});return _h.set(e,i),i}let af=!1,lf=null;function QS(s,e){if(lf===null){const t="https://cdn.needle.tools/static/models/shaderball.glb",i=new q.GLTFLoader,n=ne.createLoaders(null);i.setDRACOLoader(n.dracoLoader),i.setKTX2Loader(n.ktx2Loader),af=!0,lf=i.loadAsync(t).then(o=>{const r=o.scene;return r.position.y-=.5,r}).catch(o=>(console.warn("Failed to load shaderball mesh: "+o.message),Ny())).finally(()=>{af=!1})}if(af){const t=Ny();t.name="ShaderBall-Placeholder";const i=t.children[0];i?.type==="Mesh"&&zy(i,e),s.add(t)}lf.then(t=>{s.children.forEach(o=>{o.name==="ShaderBall-Placeholder"&&s.remove(o)});const i=t.clone(),n=i.children[0];n?.type==="Mesh"&&(n.geometry.attributes.tangent||n.geometry.computeTangents(),zy(n,e)),s.add(i)})}function zy(s,e){if(e?.color||e?.material||e?.texture){const i=e?.material??s.material?.clone()??new c.MeshStandardMaterial;e.color&&"color"in i&&i.color instanceof c.Color&&i.color.set(e.color),e?.texture&&"map"in i&&(i.map=e.texture),s.material=i}}function Ny(){return new c.Group().add(ar.createPrimitive("Sphere",{material:new c.MeshBasicMaterial({transparent:!0,opacity:.1})}))}class ma{static _active=null;static get active(){return this._active}static _requestInFlight=!1;static async start(e,t){if(this._active)return console.error("Cannot start a new XR session while one is already active"),null;if(this._requestInFlight)return console.error("Cannot start a new XR session while a request is already in flight"),null;if("xr"in navigator&&navigator.xr){if(!t)return console.error("XRSessionInit must be provided"),null;this._requestInFlight=!0;const i=await navigator.xr.requestSession(e,t);return i.addEventListener("end",()=>{this._active=null}),this._requestInFlight?(this._requestInFlight=!1,this._active=new ma(e,t,i),this._active):(i.end(),null)}return null}static async handoff(){return this._active?this._active.handoff():null}static async stop(){this._requestInFlight=!1,this._active&&(await this._active.end(),await In(100)),this._active=null}_session;_mode;_init;get isAR(){return this._mode==="immersive-ar"}_renderer;_camera;_scene;constructor(e,t,i){this._mode=e,this._init=t,this._session=i,this._session.addEventListener("end",this.onEnd),this._renderer=new c.WebGLRenderer({alpha:!0}),this._renderer.setAnimationLoop(this.onFrame),this._renderer.xr.setSession(i),this._renderer.xr.enabled=!0,this._camera=new c.PerspectiveCamera,this._scene=new c.Scene,this._scene.fog=new c.Fog(4473924,10,250),this._scene.add(this._camera),this.setupScene()}end(){return this._session?this._session.end():Promise.resolve()}async handoff(){if(!this._session)throw new Error("Cannot handoff a session that has already ended");const e={session:this._session,mode:this._mode,init:this._init};return await this.onBeforeHandoff(),this.onEnd(),this._session=null,e}onEnd=()=>{this._session?.removeEventListener("end",this.onEnd),this._renderer.setAnimationLoop(null),this._renderer.dispose(),this._scene.clear()};_lastTime=0;onFrame=(e,t)=>{const i=e-this._lastTime;this.update(e,i),this._camera.parent!==this._scene&&this._scene.add(this._camera),this._renderer.render(this._scene,this._camera)};async onBeforeHandoff(){await In(1e3),this._scene.clear()}_objects=[];setupScene(){this._scene.background=new c.Color(0),this._scene.add(new c.GridHelper(5,10,1118481,1118481));const e=new c.DirectionalLight(16777215,1);e.position.set(0,20,0),e.castShadow=!1,this._scene.add(e);const t=new c.DirectionalLight(16777215,1);t.position.set(0,-1,0),t.castShadow=!1,this._scene.add(t);const i=new c.PointLight(16777215,1,100,1);i.position.set(0,2,0),i.castShadow=!1,i.distance=200,this._scene.add(i);const n=50;for(let o=0;o<100;o++){const r=new c.MeshStandardMaterial({color:2236962,metalness:1,roughness:.8});this.isAR&&(r.emissive=new c.Color(Math.random(),Math.random(),Math.random()),r.emissiveIntensity=Math.random());const a=D.random(0,1)>.5?Yo.Sphere:Yo.Cube,l=ar.createPrimitive(a,{material:r});l.position.x=D.random(-n,n),l.position.y=D.random(-2,n),l.position.z=D.random(-n,n),l.rotation.x=D.random(0,Math.PI*2),l.rotation.y=D.random(0,Math.PI*2),l.rotation.z=D.random(0,Math.PI*2),l.scale.multiplyScalar(.5+Math.random()*10);const h=l.position.distanceTo(this._camera.position)-l.scale.x;h<1&&l.position.multiplyScalar(1+1/h),this._objects.push(l),this._scene.add(l)}}update(e,t){const i=e*4e-4;for(let n=0;n<this._objects.length;n++){const o=this._objects[n];o.position.y+=Math.sin(i+n*.5)*.005,o.rotateY(.002)}}}var Yl;(s=>{const e=[];function t(){if(!e?.length)return!1;for(const o of e)o.exportAndOpen();return!0}s.exportAndOpen=t;function i(o){e.push(o)}s.registerExporter=i;function n(o){if(!e)return;const r=e.indexOf(o);r>=0&&e.splice(r,1)}s.unregisterExporter=n})(Yl||(Yl={}));const De=w("debugwebxr"),Vy=w("stats");let cf=0;function YS(s){let e=null;const t=s;return t.getAROverlayContainer?e=t.getAROverlayContainer():e=s,e}KS();async function KS(){if(w("debugasap")){let s=globalThis["needle:XRSession"];if(s instanceof Promise){delete globalThis["needle:XRSession"],ae.addContextCreatedCallback(async e=>{if(!s)return;Fo(!0);const t=await s;if(t){const i=G.getDefaultSessionInit("immersive-vr");G.setSession("immersive-vr",t,i,e.context)}else console.error("NeedleXRSession: ASAP session was rejected");s=void 0});return}}if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent)){console.warn("WebXRViewer does not support addEventListener");return}navigator.xr?.addEventListener("sessiongranted",async()=>{Fo(!0),console.log("Received Session Granted..."),await In(100);const s=sessionStorage.getItem("needle_xr_session_mode"),e=sessionStorage.getItem("needle_xr_session_init")??null,t=e?JSON.parse(e):null;let i=null;if(o0()&&(await ma.start(s||"immersive-vr",t||G.getDefaultSessionInit("immersive-vr")),await eC(),i=await ma.handoff()),i)G.setSession(i.mode,i.session,i.init,z.Current);else if(s&&e){console.log("Session Granted: Restore last session");const n=JSON.parse(e);G.start(s,n).catch(o=>console.warn(o))}else G.start("immersive-vr").catch(n=>console.warn("Session Granted failed:",n))},{once:!0})}}function ZS(s,e){sessionStorage.setItem("needle_xr_session_mode",s),sessionStorage.setItem("needle_xr_session_init",JSON.stringify(e))}function JS(){sessionStorage.removeItem("needle_xr_session_mode"),sessionStorage.removeItem("needle_xr_session_init")}const Om=new Set;ae.registerCallback(re.ContextCreationStart,async s=>{Om.add(s.context)});ae.registerCallback(re.ContextCreated,async s=>{Om.delete(s.context);const e=s.context?.domElement.getAttribute("autostart")||null;tC(e)});function o0(){return Om.size>0}function eC(){return new Promise(s=>{const e=Date.now(),t=setInterval(()=>{(!o0()||Date.now()-e>6e4)&&(clearInterval(t),s())},100)})}exports.DeviceUtilities.isDesktop()&&A()&&window.addEventListener("keydown",s=>{(s.key==="x"||s.key==="Escape")&&G.active&&G.stop()});function tC(s){if(s)switch(s?.toLowerCase()){case"ar":sn.registerWaitForInteraction(()=>{G.start("ar")});break}}const bh=Symbol("initial-fov");class G{static _sync=null;static getXRSync(e){return this._sync||(this._sync=new s0(e)),this._sync}static get currentSessionRequest(){return this._currentSessionRequestMode}static _currentSessionRequestMode=null;static get active(){return this._activeSession}static get activeMode(){return this._activeSession?.mode??null}static get xrSystem(){return"xr"in navigator?navigator.xr:void 0}static isXRSupported(){return Promise.all([this.isVRSupported(),this.isARSupported()]).then(e=>e.some(t=>t)).catch(()=>!1)}static isVRSupported(){return this.isSessionSupported("immersive-vr")}static isARSupported(){return this.isSessionSupported("immersive-ar")}static isSessionSupported(e){return this.xrSystem?.isSessionSupported(e).catch(t=>(De&&console.error(t),!1))??Promise.resolve(!1)}static _currentSessionRequest;static _activeSession;static onSessionRequestStart(e){this._sessionRequestStartListeners.push(e)}static offSessionRequestStart(e){const t=this._sessionRequestStartListeners.indexOf(e);t>=0&&this._sessionRequestStartListeners.splice(t,1)}static _sessionRequestStartListeners=[];static onSessionRequestEnd(e){this._sessionRequestEndListeners.push(e)}static offSessionRequestEnd(e){const t=this._sessionRequestEndListeners.indexOf(e);t>=0&&this._sessionRequestEndListeners.splice(t,1)}static _sessionRequestEndListeners=[];static onXRSessionStart(e){this._xrStartListeners.push(e)}static offXRSessionStart(e){const t=this._xrStartListeners.indexOf(e);t>=0&&this._xrStartListeners.splice(t,1)}static _xrStartListeners=[];static onXRSessionEnd(e){this._xrEndListeners.push(e)}static offXRSessionEnd(e){const t=this._xrEndListeners.indexOf(e);t>=0&&this._xrEndListeners.splice(t,1)}static _xrEndListeners=[];static onControllerAdded(e){this._controllerAddedListeners.push(e)}static offControllerAdded(e){const t=this._controllerAddedListeners.indexOf(e);t>=0&&this._controllerAddedListeners.splice(t,1)}static _controllerAddedListeners=[];static onControllerRemoved(e){this._controllerRemovedListeners.push(e)}static offControllerRemoved(e){const t=this._controllerRemovedListeners.indexOf(e);t>=0&&this._controllerRemovedListeners.splice(t,1)}static _controllerRemovedListeners=[];static offerSession(e,t,i){return"xr"in navigator&&navigator.xr&&"offerSession"in navigator.xr?(typeof navigator.xr.offerSession=="function"&&(console.log("WebXR offerSession is available - requesting mode: "+e),t=="default"&&(t=this.getDefaultSessionInit(e)),navigator.xr.offerSession(e,{...t}).then(n=>G.setSession(e,n,t,i)).catch(n=>{console.log("XRSession offer rejected (perhaps because another call to offerSession was made or a call to requestSession was made)")})),!0):!1}static getDefaultSessionInit(e){switch(e){case"immersive-ar":const t=["anchors","local-floor","layers","dom-overlay","hit-test","unbounded"];return exports.DeviceUtilities.isVisionOS()||t.push("hand-tracking"),{optionalFeatures:t};case"immersive-vr":const i=["local-floor","bounded-floor","high-fixed-foveation-level","layers"];return exports.DeviceUtilities.isVisionOS()||i.push("hand-tracking"),{optionalFeatures:i};default:return console.warn("No default session init for mode",e),{}}}static async start(e,t,i){if(exports.DeviceUtilities.isiOS()){if(e==="ar")if(await this.isARSupported())e="immersive-ar";else return Yl.exportAndOpen(),null}else e=="ar"&&(e="immersive-ar");if(A()&&w("debugxrpreroom"))return console.warn("Debug: Starting temporary XR session"),await ma.start(e,t||G.getDefaultSessionInit(e)),null;if(this._currentSessionRequest)return console.warn("A XRSession is already being requested"),(De||A())&&he("A XRSession is already being requested"),this._currentSessionRequest.then(()=>this._activeSession);if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;if(i||(i=z.Current),i||(i=ae.All[0]),!i)throw new Error("No Needle Engine Context found");switch(t||(t={}),e){case"immersive-ar":{if(await this.xrSystem?.isSessionSupported("immersive-ar")!==!0)return console.error(e+" is not supported by this browser."),null;const l=this.getDefaultSessionInit(e),h=YS(i.domElement);h&&!exports.DeviceUtilities.isQuest()&&(l.domOverlay={root:h},l.optionalFeatures.push("dom-overlay")),t={...l,...t}}break;case"immersive-vr":{if(await this.xrSystem?.isSessionSupported("immersive-vr")!==!0)return console.error(e+" is not supported by this browser."),null;t={...this.getDefaultSessionInit(e),...t}}break;default:console.warn("No default session init for mode",e);break}t.optionalFeatures??=[],t.requiredFeatures??=[],await ma.stop();const n=e=="immersive-ar"?i.scripts_immersive_ar:i.scripts_immersive_vr;De?console.log(`%cRequesting ${e} session`,"font-weight:bold;",t,n):console.log(`%cRequesting ${e} session`,"font-weight:bold;");for(const a of n)a.onBeforeXR&&a.onBeforeXR(e,t);for(const a of this._sessionRequestStartListeners)a({mode:e,init:t});De&&Se("Requesting "+e+" session ("+Date.now()+")"),this._currentSessionRequest=navigator?.xr?.requestSession(e,t),this._currentSessionRequestMode=e;const o=await this._currentSessionRequest?.catch(a=>{console.error(a,"Code: "+a.code),a.code===9&&he("Make sure your device has the required permissions (e.g. camera access)"),console.log("If the specified XR configuration is not supported (e.g. entering AR doesnt work) - make sure you access the website on a secure connection (HTTPS) and your device has the required permissions (e.g. camera access)"),location.protocol==="http:"&&he("XR requires a secure connection (HTTPS)")});this._currentSessionRequest=void 0,this._currentSessionRequestMode=null;for(const a of this._sessionRequestEndListeners)a({mode:e,init:t,newSession:o||null});return o?this.setSession(e,o,t,i):(console.warn("XR Session request was rejected"),null)}static setSession(e,t,i,n){if(this._activeSession)return console.error("A XRSession is already running"),this._activeSession;const o=e=="immersive-ar"?n.scripts_immersive_ar:n.scripts_immersive_vr;return this._activeSession=new G(e,t,n,{scripts:o,controller_added:this._controllerAddedListeners,controller_removed:this._controllerRemovedListeners,init:i}),t.addEventListener("end",this.onEnd),De?console.log(`%cStarted ${e} session`,"font-weight:bold;",o):console.log(`%cStarted ${e} session`,"font-weight:bold;"),this._activeSession}static $_stop_request=Symbol();static stop(){const e=this._activeSession;e&&(e[this.$_stop_request]===void 0?(De&&console.log("[NeedleXRSession] Stopping XR Session... (new)"),e[this.$_stop_request]=setTimeout(()=>{e.end()})):De&&console.warn("[NeedleXRSession] XR Session stop already requested"))}static onEnd=()=>{De&&console.log("XR Session ended"),this._activeSession=null};context;get sync(){return G._sync}get running(){return!this._ended&&this.session!=null}session;mode;get interactionMode(){return this.session.interactionMode}get visibilityState(){return this.session.visibilityState}get isVisibleBlurred(){return this.session.visibilityState==="visible-blurred"}get isSystemKeyboardSupported(){return this.session.isSystemKeyboardSupported}get environmentBlendMode(){return this.session.environmentBlendMode}get frame(){return this.context.xrFrame}controllers=[];get leftController(){return this.controllers.find(e=>e.side==="left")}get rightController(){return this.controllers.find(e=>e.side==="right")}getController(e){return typeof e=="number"?this.controllers[e]||null:this.controllers.find(t=>t.side===e)||null}get isPassThrough(){return!!(this.environmentBlendMode!=="opaque"&&this.interactionMode==="world-space"||this.mode==="immersive-ar"&&this.environmentBlendMode!=="opaque"&&this.controllers.some(e=>e.inputSource.targetRayMode==="tracked-pointer")||A()&&exports.DeviceUtilities.isDesktop()&&this.mode==="immersive-ar")}get isAR(){return this.mode==="immersive-ar"}get isVR(){return this.mode==="immersive-vr"}get isScreenBasedAR(){return this.isAR&&!this.isPassThrough}get posePosition(){return this._transformPosition}get poseOrientation(){return this._transformOrientation}get referenceSpace(){return this.context.renderer.xr.getReferenceSpace()}get viewerPose(){return this._viewerPose}get isTrackingImages(){if(this.frame&&"getImageTrackingResults"in this.frame&&typeof this.frame.getImageTrackingResults=="function")try{const e=this.frame.getImageTrackingResults();for(const t of e)if(t.trackingState==="tracked")return!0}catch{return!1}return!1}get rig(){const e=this._rigs[0]??null;return e?.gameObject&&Ko(e.gameObject)||e?.isActive===!1?(this.updateActiveXRRig(),this._rigs[0]??null):e}_rigScale=1;_lastRigScaleUpdate=-1;get rigScale(){return this._rigs[0]?(this._lastRigScaleUpdate!==this.context.time.frame&&(this._lastRigScaleUpdate=this.context.time.frame,this._rigScale=this._rigs[0].gameObject.worldScale.x),this._rigScale):1}addRig(e){this._rigs.indexOf(e)>=0||(e.priority===void 0&&(e.priority=0),this._rigs.push(e),this.updateActiveXRRig())}removeRig(e){const t=this._rigs.indexOf(e);t!==-1&&(this._rigs.splice(t,1),this.updateActiveXRRig())}setRigActive(e){const t=this._rigs.indexOf(e),i=this._rigs[0];this._rigs.splice(t,1),this._rigs.unshift(e),e.priority=i?.priority??0,this.updateActiveXRRig()}getUserOffsetInRig(){const e=this.context.mainCamera?.position;if(!e||!this.rig)return F(0,0,0);const t=F(e);return t.x*=-1,t.z*=-1,t.applyQuaternion(Ht(this.rig.gameObject.quaternion)),t}updateActiveXRRig(){const e=this._rigs[0]??null;this._defaultRig.gameObject.parent!==this.context.scene&&this.context.scene.add(this._defaultRig.gameObject),this._defaultRig.gameObject.visible=!0,this._rigs.includes(this._defaultRig)||this._rigs.push(this._defaultRig);let t=this._rigs[0];t&&t.priority===void 0&&(t.priority=0);for(let i=1;i<this._rigs.length;i++){const n=this._rigs[i];if(n.isActive){if(Ko(n.gameObject)){this._rigs.splice(i,1),i--;continue}(!t||t.isActive===!1||n.priority!==void 0&&n.priority>t.priority)&&(t=n)}}if(e!==t){const i=this._rigs.indexOf(t);i>=0&&this._rigs.splice(i,1),this._rigs.unshift(t)}De&&(e===t?console.log("Updated Active XR Rig:",t,"prev:",e):console.log("Updated Active XRRig:",t," (the same as before)"))}_rigs=[];_viewerHitTestSource=null;getHitTest(e){if(e)return this.getControllerHitTest(e);if(!this._viewerHitTestSource)return null;const t=this._viewerHitTestSource,i=this.frame.getHitTestResults(t);if(i.length>0){const n=i[0];return this.convertHitTestResult(n)}return null}getControllerHitTest(e){const t=e.getHitTestSource();if(!t)return null;const i=this.frame.getHitTestResultsForTransientInput(t);for(const n of i)if(n.inputSource===e.inputSource)for(const o of n.results)return this.convertHitTestResult(o);return null}convertHitTestResult(e){const t=this.context.renderer.xr.getReferenceSpace(),i=t&&e.getPose(t);if(i){const n=F(i.transform.position),o=Ht(i.transform.orientation),r=this.context.mainCamera;if(r?.parent!==this._cameraRenderParent&&n.applyMatrix4(na),r?.parent){n.applyMatrix4(r.parent.matrixWorld),o.multiply(ki);const a=ue(r.parent);a.premultiply(ki),o.premultiply(a)}return{hit:e,position:n,quaternion:o}}return null}convertSpace(e){const t=F(e.position);t.applyMatrix4(na);const i=Ht(e.orientation);return i.premultiply(ki),{position:t,quaternion:i}}_defaultRig;_xr_scripts;_xr_update_scripts=[];_inactive_scripts=[];_controllerAdded;_controllerRemoved;_originalCameraWorldPosition;_originalCameraWorldRotation;_originalCameraWorldScale;_originalCameraParent;_mainCamera=null;constructor(e,t,i,n){ZS(e,n.init),this.session=t,this.mode=e,this.context=i,(De||w("console"))&&Fo(!0),this._xr_scripts=[...n.scripts],this._xr_update_scripts=this._xr_scripts.filter(o=>typeof o.onUpdateXR=="function"),this._controllerAdded=n.controller_added,this._controllerRemoved=n.controller_removed,ds(this.onBefore,pe.LateUpdate),this.context.pre_render_callbacks.push(this.onBeforeRender),this.context.post_render_callbacks.push(this.onAfterRender),(n.init.optionalFeatures?.includes("hit-test")||n.init.requiredFeatures?.includes("hit-test"))&&t.requestReferenceSpace("viewer").then(o=>t.requestHitTestSource?.call(t,{space:o})?.then(r=>this._viewerHitTestSource=r).catch(r=>console.error(r))).catch(o=>console.error(o)),this.context.mainCamera&&(this._originalCameraWorldPosition=X(this.context.mainCamera,new c.Vector3),this._originalCameraWorldRotation=ue(this.context.mainCamera,new c.Quaternion),this._originalCameraWorldScale=je(this.context.mainCamera,new c.Vector3),this._originalCameraParent=this.context.mainCamera.parent,this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera[bh]=this.context.mainCamera.fov)),this._defaultRig=new IS,this.context.scene.add(this._defaultRig.gameObject),this.addRig(this._defaultRig);for(let o=0;o<t.inputSources.length;o++){const r=t.inputSources[o];if(!r.handedness){console.warn("Input source in xr session has no handedness - ignoring",o);continue}this.onInputSourceAdded(r)}this.session.addEventListener("end",this.onEnd),this.session.addEventListener("inputsourceschange",o=>{for(const r of o.removed)this.disconnectInputSource(r);for(const r of o.added)this.onInputSourceAdded(r)}),this.context.xr=this,this.context.renderer.xr.setSession(this.session).then(this.onRendererSessionSet),"controllerAutoUpdate"in this.context.renderer.xr?(console.debug("Disabling three.js controllerAutoUpdate"),this.context.renderer.xr.controllerAutoUpdate=!1):De&&console.warn("controllerAutoUpdate is not available in three.js - cannot disable it")}onRendererSessionSet=()=>{this.running&&(this.context.renderer.xr.enabled=!0,this.context.renderer.xr.updateCamera(this.context.mainCamera),this.context.mainCameraComponent?.applyClearFlags())};onInputSourceAdded=e=>{if(e.targetRayMode==="screen")return;let t=0;for(let n=0;n<this.session.inputSources.length;n++)if(this.session.inputSources[n]===e){t=n;break}if(this.controllers.find(n=>n.inputSource===e)){console.debug("Controller already exists for input source",t);return}else if(this._newControllers.find(n=>n.inputSource===e)){console.debug("Controller already registered for input source",t);return}const i=new wm(this,e,t);this._newControllers.push(i)};disconnectInputSource(e){const t=(o,r)=>{if(o.inputSource===e){De&&console.log("Disconnecting controller",o.index);const a=r.indexOf(o);a>=0&&r.splice(a,1),this.invokeControllerEvent(o,this._controllerRemoved,"removed");const l={xr:this,controller:o,change:"removed"};for(const h of this._xr_scripts)h.onXRControllerRemoved&&h.onXRControllerRemoved(l);o.onDisconnected()}},i=[...this.controllers];for(let o=i.length-1;o>=0;o--){const r=i[o];t(r,this.controllers)}const n=[...this._newControllers];for(let o=n.length-1;o>=0;o--){const r=n[o];t(r,this._newControllers)}}end(){this._ended||this.session.end().catch(e=>console.warn(e))}_ended=!1;_newControllers=[];onEnd=e=>{if(this._ended)return;this._ended=!0,console.debug("XR Session ended"),JS(),this.onAfterRender(),this.revertCustomForward(),this._didStart=!1,this._previousCameraParent=null,this.requestedCameraNearPlane=null,oo(this.onBefore,pe.LateUpdate);const t=this.context.pre_render_callbacks.indexOf(this.onBeforeRender);t>=0&&this.context.pre_render_callbacks.splice(t,1);const i=this.context.post_render_callbacks.indexOf(this.onAfterRender);i>=0&&this.context.post_render_callbacks.splice(i,1),this.context.xr=null,this.context.renderer.xr.enabled=!1,this.context.pre_update_oneshot_callbacks.push(()=>{this.context.mainCameraComponent?.applyClearFlags(),this.context.mainCameraComponent?.applyClippingPlane()}),Xb({session:this});for(const o of G._xrEndListeners)o({xr:this});const n=[...this.controllers];for(let o=0;o<n.length;o++)this.disconnectInputSource(n[o].inputSource);this.controllers.length=0,this._newControllers.length=0;for(const o of this._xr_scripts)o?.onLeaveXR?.({xr:this});this.sync?.onExitXR(this),this.context.mainCamera&&(this._originalCameraParent?.add(this.context.mainCamera),this._originalCameraWorldPosition&&ot(this.context.mainCamera,this._originalCameraWorldPosition),this._originalCameraWorldRotation&&tn(this.context.mainCamera,this._originalCameraWorldRotation),this._originalCameraWorldScale&&ua(this.context.mainCamera,this._originalCameraWorldScale),this.context.mainCamera instanceof c.PerspectiveCamera&&this.context.mainCamera[bh]&&(this.context.mainCamera.fov=this.context.mainCamera[bh],this.context.mainCamera[bh]=0)),this.context.requestSizeUpdate(),this._defaultRig.gameObject.removeFromParent(),Fo(!1)};_didStart=!1;onBefore=e=>{const t=e.xrFrame;if(!t)return;this.context.xr=this,this.context.mainCameraComponent&&this.context.mainCameraComponent!==this._mainCamera&&(this._mainCamera=this.context.mainCameraComponent),this.rig?.isActive==!1&&(De&&console.warn("Latest rig is not active - trying to activate a different rig",this.rig),this.updateActiveXRRig()),this.rig&&this._mainCamera?.gameObject&&this._mainCamera?.gameObject?.parent!==this.rig.gameObject&&this.rig.gameObject.add(this._mainCamera?.gameObject),this.internalUpdateState(),this.applyCustomForward();const i={xr:this};if(this._didStart){if(this.context.new_scripts_xr.length>0){const n=[...this.context.new_scripts_xr];for(let o=0;o<n.length;o++){const r=this.context.new_scripts_xr[o];if(!r||r.destroyed||r.supportsXR?.(this.mode)==!1){this.context.new_scripts_xr.splice(o,1);continue}if(!r.activeAndEnabled){this.context.new_scripts_xr.splice(o,1),this.markInactive(r);continue}if(this.addScript(r)){this.invokeCallback_EnterXR(r);for(const a of this.controllers)this.invokeCallback_ControllerAdded(r,a)}}}}else{if(this._didStart=!0,this.mode==="immersive-vr"){const o=Ft(this.context.scene.children);if(o){const r=o.getSize(F());if(r.length()>0){const a=this._defaultRig.gameObject;a.position.set(o.min.x+r.x*.5,o.min.y,o.max.z+r.z*.5+1.5);const l=o.getCenter(F());l.y=a.position.y,a.lookAt(l)}}}qb({session:this}),rr();for(const o of G._xrStartListeners)o(i);const n=[...this._xr_scripts];De&&console.log("NeedleXRSession start, handle scripts:",n);for(const o of n){if(o.destroyed){this._script_to_remove.push(o);continue}if(!o.activeAndEnabled){this.markInactive(o);continue}this.invokeCallback_EnterXR(o);for(const r of this.controllers)this.invokeCallback_ControllerAdded(o,r)}}this.syncCameraCullingMask();for(const n of this.controllers)n.onUpdate(t);if(this._newControllers.length>0){const n=[...this._newControllers];this._newControllers.length=0;for(const o of n){if(!o.connected){console.warn("New controller is not connected",o);continue}this.controllers.push(o);for(const r of this._xr_scripts){if(r.destroyed){this._script_to_remove.push(r);continue}r.activeAndEnabled!==!1&&this.invokeCallback_ControllerAdded(r,o)}}this.controllers.sort((o,r)=>o.index-r.index)}De&&this.context.time.frame%30===0&&this.controllers.length<=0&&this.session.inputSources.length>0&&(Fo(!0),console.error("XRControllers are not added but inputSources are present"));for(const n of this._xr_update_scripts){if(n.destroyed===!0){this._script_to_remove.push(n);continue}if(n.activeAndEnabled===!1){this.markInactive(n);continue}n.onUpdateXR&&n.onUpdateXR(i)}if(this.handleInactiveScripts(),this._script_to_remove.length>0){const n=[...new Set(this._script_to_remove)];this._script_to_remove.length=0;for(const o of n)!o.destroyed&&this.running&&o.onLeaveXR?.(i),this.removeScript(o)}this.sync?.onUpdate(this),this.onRenderDebug()};onRenderDebug(){if(De)for(const e of this.controllers)e.onRenderDebug();if((De||Vy)&&this.rig&&(cf++,cf>=20)){const e=this.rig.gameObject.worldPosition,t=this.rig.gameObject.worldForward;e.add(t.multiplyScalar(1.5));const i=this.rig.gameObject.worldUp;e.add(i.multiplyScalar(2.5));let n="";if(n+=`${this.context.time.smoothedFps.toFixed(0)} FPS`,n+=`, calls: ${this.context.renderer.info.render.calls}, tris: ${this.context.renderer.info.render.triangles.toLocaleString()}`,De||Vy)for(const o of this.controllers)n+=`
|
|
167
|
-
${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;cf=0,I.DrawLabel(e,n,void 0,1/60*20)}}onBeforeRender=()=>{this.context.mainCamera&&(this.updateFade(this.context.mainCamera),this.requestedCameraNearPlane!==null&&this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera.near=this.requestedCameraNearPlane,this.requestedCameraNearPlane=null))};onAfterRender=()=>{if(this.onUpdateFade_PostRender(),exports.DeviceUtilities.isDesktop()||!this._renderOnceOnDevice){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const t=e.xr.enabled,i=e.getRenderTarget(),n=this.context.scene.background;e.xr.enabled=!1,e.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i),this.context.scene.background=n}}};addScript(e){return this._xr_scripts.includes(e)?!1:(De&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}_script_to_remove=[];removeScript(e,t=!0){De&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(e);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){const e=this.context.xrCamera,t=this.context.mainCameraComponent?.cullingMask;if(e&&t!==void 0){for(const i of e.cameras)i.layers.mask=t;e.layers.mask=t}else if(e){for(const i of e.cameras)i.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:e,change:i})}catch(r){console.error(r)}}}_camera;_cameraRenderParent=new c.Object3D().rotateY(Math.PI);_previousCameraParent;_customforward=!0;originalCameraNearPlane;requestedCameraNearPlane=null;applyCustomForward(){if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,this._previousCameraParent?.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);{let e=.02;const t=.001;if(this.rig){const i=je(this.rig.gameObject);e*=i.x}this._camera instanceof c.PerspectiveCamera&&Math.abs(this._camera.near-e)>t&&(this.isAR?this.originalCameraNearPlane=this._camera.near:this._camera.near=e,De&&console.debug(`Setting camera near plane to ${e} (was ${this.originalCameraNearPlane}) to account for XR rendering scale`))}}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof c.PerspectiveCamera&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane,this.originalCameraNearPlane=void 0)}_viewerPose;_transformOrientation=new c.Quaternion;_transformPosition=new c.Vector3;internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}_transition;get transition(){return this._transition||(this._transition=new Uy),this._transition}fadeTransition(){return this._transition||(this._transition=new Uy),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof c.PerspectiveCamera&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){this._transition?.remove()}}const hf=w("debugwebxr");class r0{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(hf&&console.log("FOUND AVATAR HEAD",e.name),i.head=new Y("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(hf&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new Y("",t,e)),!i.rightHand&&n.includes("right")&&(hf&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new Y("",t,e)));for(let o=0;o<e.children.length;o++){if(i.head&&i.leftHand&&i.rightHand)return;const r=e.children[o];this.tryFindAvatarObjects(r,t,i)}}}class Z extends c.Color{alpha=1;get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}constructor(e,t,i,n){super(),typeof e=="number"&&typeof t=="number"&&typeof i=="number"?(this.set(e,t,i),this.alpha=typeof n=="number"?n:1):e!==void 0&&(this.set(e),this.alpha=1)}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const i=e;return i.alpha!=null&&(this.alpha=D.lerp(this.alpha,i.alpha,t)),super.lerp(e,t)}lerpColors(e,t,i){const n=e,o=t;return n.alpha!=null&&o.alpha!=null&&(this.alpha=D.lerp(n.alpha,o.alpha,i)),super.lerpColors(e,t,i)}multiply(e){const t=e;return t.alpha!=null&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}static fromColorRepresentation(e){if(typeof e=="string"){if(e.trim()==="transparent")return new Z(0,0,0,0);if(e.startsWith("#")&&e.length===9){const t=parseInt(e.slice(1,9),16),i=t>>24&255,n=t>>16&255,o=t>>8&255,r=t>>0&255;return new Z(i/255,n/255,o/255,r/255)}else if(e.startsWith("#")){const t=parseInt(e.slice(1),16),i=t>>16&255,n=t>>8&255,o=t>>0&255;return new Z(i/255,n/255,o/255,1)}else if(e.startsWith("rgba")){const t=e.slice(5,-1).split(",").map(Number);return new Z(t[0]/255,t[1]/255,t[2]/255,t[3])}else if(e.startsWith("rgb")){const t=e.slice(4,-1).split(",").map(Number);return new Z(t[0]/255,t[1]/255,t[2]/255,1)}}else if(Array.isArray(e)){if(e.length===4)return new Z(e[0],e[1],e[2],e[3]);if(e.length===3)return new Z(e[0],e[1],e[2],1);console.error("Invalid color array length. Expected 3 or 4, got "+e.length)}return new Z(e)}}const bt=new c.Vector3,$y=new c.Vector3,Wy=new c.Quaternion,iC=w("debuggizmos"),Gi=8947848,df=32;class I{constructor(){}static enabled=!0;static isGizmo(e){return e[yp]!==void 0}static setVisible(e){for(const t of Si.timedObjectsBuffer)t.visible=e}static DrawLabel(e,t,i=.05,n=0,o,r,a){if(!I.enabled)return null;o||(o=Gi);const l=G.active?.rigScale??1,h=Si.getTextLabel(n,t,i*l,o,r);return a instanceof c.Object3D&&a.add(h),h.position.x=e.x,h.position.y=e.y,h.position.z=e.z,h}static DrawRay(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),bt.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+bt.x,e.y+bt.y,e.z+bt.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawDirection(e,t,i=Gi,n=0,o=!0,r=1){if(!I.enabled)return;const a=Si.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(bt.set(0,0,-r),Wy.set(t.x,t.y,t.z,t.w),bt.applyQuaternion(Wy)):(bt.set(t.x,t.y,t.z),bt.multiplyScalar(r)),l.setXYZ(1,e.x+bt.x,e.y+bt.y,e.z+bt.z),l.needsUpdate=!0,a.material.depthTest=o,a.material.depthWrite=!1,Qi(a.material,i)}static DrawLine(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawCircle(e,t,i,n=Gi,o=0,r=!0){if(!I.enabled)return;const a=Si.getCircle(o);a.position.set(e.x,e.y,e.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,bt.set(t.x,t.y,t.z).normalize()),a.material.depthTest=r,a.material.depthWrite=!1,a.material.fog=!1,Qi(a.material,n)}static DrawWireSphere(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getSphere(t,n,!0);Qo(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawSphere(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getSphere(t,n,!1);Qo(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,Qi(r.material,i)}static DrawWireBox(e,t,i=Gi,n=0,o=!0,r=void 0){if(!I.enabled)return;const a=Si.getBox(n);a.position.set(e.x,e.y,e.z),a.scale.set(t.x,t.y,t.z),r?a.quaternion.copy(r):a.quaternion.identity(),a.material.depthTest=o,a.material.wireframe=!0,a.material.depthWrite=!1,a.material.fog=!1,Qi(a.material,i)}static DrawWireBox3(e,t=Gi,i=0,n=!0){if(!I.enabled)return;const o=Si.getBox(i);o.position.copy(e.getCenter(bt)),o.scale.copy(e.getSize(bt)),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1,Qi(o.material,t)}static _up=new c.Vector3(0,1,0);static DrawArrow(e,t,i=Gi,n=0,o=!0,r=!1){if(!I.enabled)return;const a=Si.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),bt.set(t.x,t.y,t.z).sub($y.set(e.x,e.y,e.z)).normalize());const h=bt.set(t.x,t.y,t.z).sub($y.set(e.x,e.y,e.z)).length()*.1;a.scale.set(h,h,h),a.material.depthTest=o,a.material.wireframe=r,Qi(a.material,i),this.DrawLine(e,t,i,n,o)}static DrawWireMesh(e){const t=Si.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrix.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrix.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0,Qi(t.material,e.color??Gi)}}const nC=new c.BoxGeometry(1,1,1);function Mm(s=null){const e=new c.Color(s??14540253),t=new c.EdgesGeometry(nC);return new c.LineSegments(t,new c.LineBasicMaterial({color:e}))}function Qi(s,e){if(Array.isArray(s)){for(const i of s)Qi(i,e);return}const t=e instanceof Z?e.a:1;s.color.set(e),s.opacity=t,s.transparent=t<1}const yp=Symbol("GizmoCache");class Si{static familyName="needle-gizmos";static ensureFont(){let e=J.__webpack_exports__default.FontLibrary.getFontFamily(this.familyName);e||(e=J.__webpack_exports__default.FontLibrary.addFontFamily(this.familyName),e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png")?.addEventListener("ready",()=>{J.__webpack_exports__default.update()}))}static getTextLabel(e,t,i,n,o){this.ensureFont();let r=this.textLabelCache.pop(),a=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(a=parseInt(o.substring(7),16)/255,o=o.substring(0,7),iC&&console.log(o,a)):typeof o=="object"&&o.a!==void 0&&(a=o.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre",offset:.05*i};if(r)r.set(l);else{r=new J.__webpack_exports__Text(l);const h=this,d=r;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(z.Current,r,e,this.textLabelCache),r}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new c.BoxGeometry(1,1,1);t=new c.Mesh(i)}return this.registerTimedObject(z.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");i||(i=new c.BufferAttribute(new Float32Array(6),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(z.Current,t,e,this.linesCache),t}static getCircle(e){let t=this.circlesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");if(!i){i=new c.BufferAttribute(new Float32Array(df*3),3),t.geometry.setAttribute("position",i);const n=F(0,1,0),o=F(0,0,1),r=F(o);r.cross(n).normalize();const a=F(r),l=Math.PI*2/(df-1);for(let h=0;h<df+1;h++){const d=l*h;n.copy(a).multiplyScalar(Math.cos(d)*1),r.copy(o).multiplyScalar(Math.sin(d)*1);const u=n.add(r);i.setXYZ(h,u.x,u.y,u.z)}}}return t.frustumCulled=!1,this.registerTimedObject(z.Current,t,e,this.circlesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new c.Mesh(new c.SphereGeometry(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(z.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new c.Mesh(new c.CylinderGeometry(0,.5,1,8))),this.registerTimedObject(z.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new c.Mesh,t.material=new c.MeshBasicMaterial),this.registerTimedObject(z.Current,t,e,this.mesh),t}static linesCache=[];static circlesCache=[];static spheresCache=[];static boxesCache=[];static arrowHeadsCache=[];static mesh=[];static textLabelCache=[];static registerTimedObject(e,t,i,n){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),r=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const a=e.pre_render_callbacks.indexOf(o);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(o)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(r){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==r){const a=e.post_render_callbacks.indexOf(r);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(r)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[yp]=n,t.castShadow=!1,t.receiveShadow=!1,t.isGizmo=!0,this.timedObjectsBuffer.push(t),this.timesBuffer.push(z.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static timedObjectsBuffer=new Array;static timesBuffer=new Array;static contextPostRenderCallbacks=new Map;static contextBeforeRenderCallbacks=new Map;static tmuiNeedsUpdate=!1;static onBeforeRender(e,t){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,J.__webpack_exports__default.update());for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof J.__webpack_exports__default.MeshUIBaseElement){if(Ko(n))continue;const o=e.isInVR,r=!1,a=!o;gc(n,e.mainCamera,r,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let o=t.length-1;o>=0;o--){const r=t[o];n>=i[o]-1e-6&&(t.splice(o,1),i.splice(o,1),r.removeFromParent(),Ko(r)!=!0&&r[yp].push(r))}}}const It=w("debugphysics"),Hy=new c.Layers;class ro{static AllLayers=4294967295;ray;cam;screenPoint;raycaster;results;targets;recursive=!0;minDistance;maxDistance;lineThreshold;layerMask;ignore;testObject;useAcceleratedRaycast;allowSlowRaycastFallback=!0;screenPointFromOffset(e,t){this.screenPoint===void 0&&(this.screenPoint=new c.Vector2),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(t/window.innerHeight)*2+1}setLayer(e){Hy.set(e),this.layerMask=Hy}setMask(e){this.layerMask||(this.layerMask=new c.Layers);const t=this.layerMask;t?t.mask=e:this.layerMask=e}}class km{distance;point;object;constructor(e,t,i){this.object=e,this.distance=t,this.point=i}}class ga{static _raycasting=0;static get raycasting(){return this._raycasting>0}raycastPhysicsFast(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycast(e,t,{maxDistance:i,solid:n})??null}raycastPhysicsFastAndGetNormal(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycastAndGetNormal(e,t,{maxDistance:i,solid:n})??null}sphereOverlapPhysics(e,t){return this.context.physics.engine?.sphereOverlap(e,t)??null}context;engine;constructor(e){this.context=e}raycaster=new c.Raycaster;defaultRaycastOptions=new ro;targetBuffer=new Array(1);defaultThresholds={Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}};sphereResults=new Array;sphereMask=new c.Layers;sphere=new c.Sphere;sphereOverlap(e,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,e,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(e,t=null){const i=t??this.defaultRaycastOptions;i.ray=e;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(e=null){It&&performance.mark("raycast.start"),e||(e=this.defaultRaycastOptions);const t=e.screenPoint??this.context.input.mousePositionRC,i=e.raycaster??this.raycaster;if(i.near=e.minDistance??0,i.far=e.maxDistance??1/0,i.params=this.defaultThresholds,e.lineThreshold===void 0&&(e.lineThreshold=-1),i.params.Line={threshold:e.lineThreshold},e.ray)i.ray.copy(e.ray);else{const a=e.cam??this.context.mainCamera;if(!a)return It&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof c.ArrayCamera&&l.cameras.length>0?i.setFromCamera(t,l.cameras[0]):i.setFromCamera(t,a)}let n=e.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=e.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),e.layerMask!==void 0?e.layerMask instanceof c.Layers?i.layers.mask=e.layerMask.mask:i.layers.mask=e.layerMask:(i.layers.enableAll(),i.layers.disable(2)),It&&console.time("raycast"),o.length=0,ga._raycasting++,this.intersect(this.raycaster,n,o,e),o.sort((a,l)=>a.distance-l.distance);const r=e.ignore;return r!==void 0&&r.length>0&&(o=o.filter(a=>!r.includes(a.object))),ga._raycasting--,It&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o?.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(e,t,i,n){for(const o of t){if(!o||o.visible===!1||I.isGizmo(o)||n.lineThreshold!==void 0&&n.lineThreshold<0&&o instanceof c.Line)continue;let r=!0;const a=o,l=a.geometry;if(n.testObject){const h=n.testObject?.(o);if(h===!1)continue;h==="continue in children"&&(r=!1)}if(r&&(l&&Gy(l)||(r=!1)),r){const h=ne.getRaycastMesh(o);h&&(a.geometry=h);const d=i.length;let u=!0;if(n.precise===!1&&(u=!1),u||=l.getAttribute("position")?.array?.length<64,a instanceof q.GroundedSkybox&&(u=!1),!u&&oC(a,e,i)||(n.useAcceleratedRaycast!==!1?vd.runMeshBVHRaycast(e,a,i,this.context,n):e.intersectObject(a,!1,i)),It&&i.length!=d){const p=i[i.length-1],m=h?8969557:7798784;I.DrawWireSphere(p.point,.1,m,1,!1),I.DrawWireMesh({mesh:o,depthTest:!1,duration:.2,color:m})}a.geometry=l}n.recursive!==!1&&this.intersect(e,o.children,i,n)}return i}tempBoundingBox=new c.Box3;intersectSphere(e,t,i,n,o,r,a,l){let h=e&&e.isMesh&&e.layers.test(n)&&!I.isGizmo(e);h&&=e.visible,h&&=!(e instanceof c.Line),h&&=!(e instanceof q.GroundedSkybox);const d=e,u=d.geometry;if(h&&l){const p=l(e);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&Gy(u)||(h=!1),h){if(a){const p=this.sphere;p.center.copy(t),p.radius=i;const m=o.length;if(vd.runMeshBVHRaycast(this.sphere,d,o,this.context,{}),m!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),m=this.sphere;if(m.center.copy(t),m.radius=i,m.intersectsBox(p)){const y=X(e),_=y.distanceTo(m.center),g=new km(e,_,y);if(o.push(g),!r)return}}}if(e.children)for(const p of e.children){const m=o.length;if(this.intersectSphere(p,t,i,n,o,r,a,l),m!=o.length&&!r)return}}}function Gy(s){return!(s.index&&s.index.array.length<3)}const xo=new c.Sphere,vh=new c.Plane,sC=new c.Matrix3;function oC(s,e,t){const i=s._computeIntersections;if(!i)return!1;let n=s["_computeIntersections:Needle"];return n||(n=s["_computeIntersections:Needle"]=function(o,r,a){const l=this,h=l.geometry.boundingSphere;if(h){if(l instanceof q.GroundedSkybox){vh.setFromNormalAndCoplanarPoint(F(0,1,0),F(0,-l.position.y,0)),vh.applyMatrix4(l.matrixWorld,sC);const u=o.ray.intersectPlane(vh,F());if(u){xo.copy(h),xo.applyMatrix4(l.matrixWorld);const m=F(u).sub(o.ray.origin).length(),y=xo.radius*.5;m<y&&r.push({distance:m,point:u,object:l,normal:vh.normal.clone()})}return}xo.copy(h),xo.applyMatrix4(l.matrixWorld);const d=o.ray.intersectSphere(xo,F());if(d){const u=F(d).sub(o.ray.origin),p=u.length();if(p>xo.radius){const m=u.clone().normalize();r.push({distance:p,point:d,object:l,normal:m})}}}}),s._computeIntersections=n,e.intersectObject(s,!1,t),s._computeIntersections=i,!0}var vd;(s=>{function e(v,b,x,R,O){if(!b.geometry||!b.geometry.hasAttribute("position"))return!1;const M=b.geometry;if(b?.isSkinnedMesh){const E=b,B=E.bvhNeedsUpdate;if(!E.staticGenerator)a(),o&&(E.staticGenerator=new o(b),E.staticGenerator.applyWorldTransforms=!1,E.staticGeometry=E.staticGenerator.generate(),M.boundsTree=r?.call(E.staticGeometry),E.staticGeometryLastUpdate=performance.now()+Math.random()*200,E.bvhNeedsUpdate=!0);else if(M.boundsTree&&(E.autoUpdateMeshBvhInterval!==void 0&&E.autoUpdateMeshBvhInterval>=0||B===!0)){const L=performance.now(),V=L-E.staticGeometryLastUpdate,$=E.autoUpdateMeshBvhInterval??100;(B||V>$)&&(It&&console.warn(`Physics: updating skinned mesh bvh for ${b.name} after ${V.toFixed(2)}ms`),E.bvhNeedsUpdate=!1,E.staticGeometryLastUpdate=L,E.staticGenerator?.generate(E.staticGeometry),M.boundsTree.refit())}}else if(!M.boundsTree){h||g();let E=!0;if((R.xr||M[m]===!1||M.getAttribute("position")?.isInterleavedBufferAttribute||M.index&&M.index?.isInterleavedBufferAttribute)&&(E=!1),E&&u){if(M[p]===void 0){let B=null;if(_.length>0){const L=_.shift();L&&!L.running&&(B=L)}if(!B&&y.length<3&&(B=new u,y.push(B)),B!=null&&!B.running){const L=b.name;It&&console.log("<<<< worker start",L,B),M[p]="queued",performance.mark("bvh.create.start");const V=M.clone();try{B.generate(V).then($=>{M[p]="done",M.boundsTree=$}).catch($=>{M[p]="failed - "+$?.message,M[m]=!1,It&&console.error("Failed to generate mesh bvh on worker",$)}).finally(()=>{It&&console.log(">>>>> worker done",L,{hasBoundsTre:M.boundsTree!=null}),_.push(B),V.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch($){console.error("Failed to generate mesh bvh on worker",$)}}else It&&console.warn("No worker available")}}else(!d||!E)&&(a(),n&&(performance.mark("bvh.create.start"),M.boundsTree=new n(M),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(v instanceof c.Raycaster){const E=v,B=b.raycast;if(M.boundsTree)a(),i&&(b.acceleratedRaycast||(b.acceleratedRaycast=i.bind(b),It&&console.debug(`Physics: bind acceleratedRaycast fn to "${b.name}"`)),b.raycast=b.acceleratedRaycast);else if(It&&console.warn("No bounds tree found for mesh",b.name,{workerTask:M[p],hasAcceleratedRaycast:i!=null}),O.allowSlowRaycastFallback===!1&&(M.getAttribute("position")?.array?.length??0)>2e3)return It&&console.warn("Skipping raycast because no bounds tree is available and allowSlowRaycastFallback is false"),!1;const L=E.firstHitOnly;return E.firstHitOnly=!1,E.intersectObject(b,!1,x),E.firstHitOnly=L,b.raycast=B,!0}else if(v instanceof c.Sphere){const E=M.boundsTree;if(E){const B=v;if(l.copy(b.matrixWorld).invert(),B.applyMatrix4(l),E.intersectsSphere(B)){const V=X(b),$=V.distanceTo(B.center),T=new km(b,$,V);x.push(T)}}return!0}return!1}s.runMeshBVHRaycast=e;let t=!1,i=null,n=null,o=null,r=null;function a(){t||(t=!0,Promise.resolve().then(()=>require("./vendor-D0Yvltn9.umd.cjs")).then(v=>v.index$1).then(v=>{i=v.acceleratedRaycast,n=v.MeshBVH,o=v.StaticGeometryGenerator,r=v.computeBoundsTree}).catch(v=>{(It||A())&&console.error("Failed to load BVH library...",v.message)}))}const l=new c.Matrix4;let h=!1,d=!1,u=null;const p=Symbol("Needle:MeshBVH-Worker"),m=Symbol("Needle:MeshBVH-CanUseWorker"),y=[],_=[];function g(){h=!0,d=!0,Promise.resolve().then(()=>YR).then(v=>{u=v.GenerateMeshBVHWorker}).catch(v=>{(It||A())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{d=!1})}})(vd||(vd={}));const qy=Symbol("gltf-loader-internal-usage-tracker"),rC=w("debugusers");class oa{get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return oa._loadingProcesses>0}static _loadingProcesses=0;parser;_getDependency;_loadingId;_loadedObjects=new Set;constructor(e){this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}beforeRoot(){oa._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(e._loadedObjects.add(r),r[qy]=e._loadingId),r)),o},null}afterRoot(e){oa._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[qy],t instanceof c.Object3D&&(t.parent||t instanceof c.Mesh&&setTimeout(()=>{rC&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}}class a0{constructor(){window.addEventListener("unhandledrejection",e=>{if(e.defaultPrevented)return;const t=e?.reason?.path;if(t){const i=t[0];i&&i.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
167
|
+
${o.hand?"hand":"ctrl"} ${o.inputSource.handedness}[${o.index}] con:${o.connected} tr:${o.isTracking} hts:${o.hasHitTestSource?"yes":"no"}`;cf=0,I.DrawLabel(e,n,void 0,1/60*20)}}onBeforeRender=()=>{this.context.mainCamera&&(this.updateFade(this.context.mainCamera),this.requestedCameraNearPlane!==null&&this.context.mainCamera instanceof c.PerspectiveCamera&&(this.context.mainCamera.near=this.requestedCameraNearPlane,this.requestedCameraNearPlane=null))};onAfterRender=()=>{if(this.onUpdateFade_PostRender(),exports.DeviceUtilities.isDesktop()||!this._renderOnceOnDevice){const e=this.context.renderer;if(e.xr.isPresenting&&this.context.mainCamera){this._renderOnceOnDevice=!0;const t=e.xr.enabled,i=e.getRenderTarget(),n=this.context.scene.background;e.xr.enabled=!1,e.setRenderTarget(null),this.isPassThrough&&(this.context.scene.background=null),this.context.composer?this.context.composer.render(this.context.time.deltaTime):e.render(this.context.scene,this.context.mainCamera),e.xr.enabled=t,e.setRenderTarget(i),this.context.scene.background=n}}};addScript(e){return this._xr_scripts.includes(e)?!1:(De&&console.log("Register new XRScript",e),this._xr_scripts.push(e),typeof e.onUpdateXR=="function"&&this._xr_update_scripts.push(e),!0)}markInactive(e){if(!(this._inactive_scripts.indexOf(e)>=0)){this.removeScript(e,!1),this._inactive_scripts.push(e);for(const t of this.controllers)this.invokeCallback_ControllerRemoved(e,t);this.invokeCallback_LeaveXR(e)}}handleInactiveScripts(){if(this._inactive_scripts.length>0)for(let e=this._inactive_scripts.length-1;e>=0;e--){const t=this._inactive_scripts[e];if(t.activeAndEnabled){this._inactive_scripts.splice(e,1),this.addScript(t),this.invokeCallback_EnterXR(t);for(const i of this.controllers)this.invokeCallback_ControllerAdded(t,i)}}}_script_to_remove=[];removeScript(e,t=!0){De&&console.log("Remove XRScript",e);const i=this._xr_scripts.indexOf(e);i>=0&&this._xr_scripts.splice(i,1);const n=this._xr_update_scripts.indexOf(e);if(n>=0&&this._xr_update_scripts.splice(n,1),t){const o=this._inactive_scripts.indexOf(e);o>=0&&this._inactive_scripts.splice(o,1)}}invokeCallback_EnterXR(e){e.onEnterXR&&e.onEnterXR({xr:this})}invokeCallback_ControllerAdded(e,t){e.onXRControllerAdded&&e.onXRControllerAdded({xr:this,controller:t,change:"added"})}invokeCallback_ControllerRemoved(e,t){e.onXRControllerRemoved&&e.onXRControllerRemoved({xr:this,controller:t,change:"removed"})}invokeCallback_LeaveXR(e){e.onLeaveXR&&!e.destroyed&&e.onLeaveXR({xr:this})}syncCameraCullingMask(){const e=this.context.xrCamera,t=this.context.mainCameraComponent?.cullingMask;if(e&&t!==void 0){for(const i of e.cameras)i.layers.mask=t;e.layers.mask=t}else if(e){for(const i of e.cameras)i.layers.enableAll();e.layers.enableAll()}}invokeControllerEvent(e,t,i){for(let n=t.length-1;n>=0;n--){const o=t[n];if(o)try{o({xr:this,controller:e,change:i})}catch(r){console.error(r)}}}_camera;_cameraRenderParent=new c.Object3D().rotateY(Math.PI);_previousCameraParent;_customforward=!0;originalCameraNearPlane;requestedCameraNearPlane=null;applyCustomForward(){if(this.context.mainCamera&&this._customforward){this._camera=this.context.mainCamera,this._camera.parent!==this._cameraRenderParent&&(this._previousCameraParent=this._camera.parent,this._previousCameraParent?.add(this._cameraRenderParent)),this._cameraRenderParent.name="XR Camera Render Parent",this._cameraRenderParent.add(this._camera);{let e=.02;const t=.001;if(this.rig){const i=je(this.rig.gameObject);e*=i.x}this._camera instanceof c.PerspectiveCamera&&Math.abs(this._camera.near-e)>t&&(this.isAR?this.originalCameraNearPlane=this._camera.near:this._camera.near=e,De&&console.debug(`Setting camera near plane to ${e} (was ${this.originalCameraNearPlane}) to account for XR rendering scale`))}}}revertCustomForward(){this._camera&&this._previousCameraParent&&this._previousCameraParent.add(this._camera),this._previousCameraParent=null,this._camera instanceof c.PerspectiveCamera&&this.originalCameraNearPlane!=null&&(this._camera.near=this.originalCameraNearPlane,this.originalCameraNearPlane=void 0)}_viewerPose;_transformOrientation=new c.Quaternion;_transformPosition=new c.Vector3;internalUpdateState(){const e=this.context.renderer.xr.getReferenceSpace();if(!e){this._viewerPose=void 0;return}if(this._viewerPose=this.frame.getViewerPose(e),this._viewerPose){const t=this._viewerPose.transform;this._transformPosition.set(t.position.x,t.position.y,t.position.z),this._transformOrientation.set(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)}}_transition;get transition(){return this._transition||(this._transition=new Uy),this._transition}fadeTransition(){return this._transition||(this._transition=new Uy),this._transition.fadeTransition()}updateFade(e){this._transition&&e instanceof c.PerspectiveCamera&&this._transition.update(e,this.context.time.deltaTime)}onUpdateFade_PostRender(){this._transition?.remove()}}const hf=w("debugwebxr");class r0{static tryFindAvatarObjects(e,t,i){if(i.head&&i.leftHand&&i.rightHand)return;const n=e.name.toLocaleLowerCase();!i.head&&n.includes("head")&&(hf&&console.log("FOUND AVATAR HEAD",e.name),i.head=new Y("",t,e)),n.includes("hand")&&(!i.leftHand&&n.includes("left")&&(hf&&console.log("FOUND AVATAR LEFT HAND",e.name),i.leftHand=new Y("",t,e)),!i.rightHand&&n.includes("right")&&(hf&&console.log("FOUND AVATAR RIGHT HAND",e.name),i.rightHand=new Y("",t,e)));for(let o=0;o<e.children.length;o++){if(i.head&&i.leftHand&&i.rightHand)return;const r=e.children[o];this.tryFindAvatarObjects(r,t,i)}}}class Z extends c.Color{alpha=1;get isRGBAColor(){return!0}set a(e){this.alpha=e}get a(){return this.alpha}constructor(e,t,i,n){super(),typeof e=="number"&&typeof t=="number"&&typeof i=="number"?(this.set(e,t,i),this.alpha=typeof n=="number"?n:1):e!==void 0&&(this.set(e),this.alpha=1)}clone(){const e=super.clone();return e.alpha=this.alpha,e}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,"alpha"in e&&typeof e.alpha=="number"?this.alpha=e.alpha:typeof e.a=="number"&&(this.alpha=e.a),this}lerp(e,t){const i=e;return i.alpha!=null&&(this.alpha=D.lerp(this.alpha,i.alpha,t)),super.lerp(e,t)}lerpColors(e,t,i){const n=e,o=t;return n.alpha!=null&&o.alpha!=null&&(this.alpha=D.lerp(n.alpha,o.alpha,i)),super.lerpColors(e,t,i)}multiply(e){const t=e;return t.alpha!=null&&(this.alpha=this.alpha*t.alpha),super.multiply(e)}fromArray(e,t=0){return this.alpha=e[t+3],super.fromArray(e,t)}static fromColorRepresentation(e){if(typeof e=="string"){if(e.trim()==="transparent")return new Z(0,0,0,0);if(e.startsWith("#")&&e.length===9){const t=parseInt(e.slice(1,9),16),i=t>>24&255,n=t>>16&255,o=t>>8&255,r=t>>0&255;return new Z(i/255,n/255,o/255,r/255)}else if(e.startsWith("#")){const t=parseInt(e.slice(1),16),i=t>>16&255,n=t>>8&255,o=t>>0&255;return new Z(i/255,n/255,o/255,1)}else if(e.startsWith("rgba")){const t=e.slice(5,-1).split(",").map(Number);return new Z(t[0]/255,t[1]/255,t[2]/255,t[3])}else if(e.startsWith("rgb")){const t=e.slice(4,-1).split(",").map(Number);return new Z(t[0]/255,t[1]/255,t[2]/255,1)}}else if(Array.isArray(e)){if(e.length===4)return new Z(e[0],e[1],e[2],e[3]);if(e.length===3)return new Z(e[0],e[1],e[2],1);console.error("Invalid color array length. Expected 3 or 4, got "+e.length)}return new Z(e)}}const bt=new c.Vector3,$y=new c.Vector3,Wy=new c.Quaternion,iC=w("debuggizmos"),Gi=8947848,df=32;class I{constructor(){}static enabled=!0;static isGizmo(e){return e[yp]!==void 0}static setVisible(e){for(const t of Si.timedObjectsBuffer)t.visible=e}static DrawLabel(e,t,i=.05,n=0,o,r,a){if(!I.enabled)return null;o||(o=Gi);const l=G.active?.rigScale??1,h=Si.getTextLabel(n,t,i*l,o,r);return a instanceof c.Object3D&&a.add(h),h.position.x=e.x,h.position.y=e.y,h.position.z=e.z,h}static DrawRay(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),bt.set(t.x,t.y,t.z).multiplyScalar(999999999),a.setXYZ(1,e.x+bt.x,e.y+bt.y,e.z+bt.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawDirection(e,t,i=Gi,n=0,o=!0,r=1){if(!I.enabled)return;const a=Si.getLine(n),l=a.geometry.getAttribute("position");l.setXYZ(0,e.x,e.y,e.z),t.w!==void 0?(bt.set(0,0,-r),Wy.set(t.x,t.y,t.z,t.w),bt.applyQuaternion(Wy)):(bt.set(t.x,t.y,t.z),bt.multiplyScalar(r)),l.setXYZ(1,e.x+bt.x,e.y+bt.y,e.z+bt.z),l.needsUpdate=!0,a.material.depthTest=o,a.material.depthWrite=!1,Qi(a.material,i)}static DrawLine(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getLine(n),a=r.geometry.getAttribute("position");a.setXYZ(0,e.x,e.y,e.z),a.setXYZ(1,t.x,t.y,t.z),a.needsUpdate=!0,r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawCircle(e,t,i,n=Gi,o=0,r=!0){if(!I.enabled)return;const a=Si.getCircle(o);a.position.set(e.x,e.y,e.z),a.scale.set(i,i,i),a.quaternion.setFromUnitVectors(this._up,bt.set(t.x,t.y,t.z).normalize()),a.material.depthTest=r,a.material.depthWrite=!1,a.material.fog=!1,Qi(a.material,n)}static DrawWireSphere(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getSphere(t,n,!0);Qo(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,r.material.fog=!1,Qi(r.material,i)}static DrawSphere(e,t,i=Gi,n=0,o=!0){if(!I.enabled)return;const r=Si.getSphere(t,n,!1);Qo(r,e.x,e.y,e.z),r.material.depthTest=o,r.material.depthWrite=!1,Qi(r.material,i)}static DrawWireBox(e,t,i=Gi,n=0,o=!0,r=void 0){if(!I.enabled)return;const a=Si.getBox(n);a.position.set(e.x,e.y,e.z),a.scale.set(t.x,t.y,t.z),r?a.quaternion.copy(r):a.quaternion.identity(),a.material.depthTest=o,a.material.wireframe=!0,a.material.depthWrite=!1,a.material.fog=!1,Qi(a.material,i)}static DrawWireBox3(e,t=Gi,i=0,n=!0){if(!I.enabled)return;const o=Si.getBox(i);o.position.copy(e.getCenter(bt)),o.scale.copy(e.getSize(bt)),o.material.depthTest=n,o.material.wireframe=!0,o.material.depthWrite=!1,o.material.fog=!1,Qi(o.material,t)}static _up=new c.Vector3(0,1,0);static DrawArrow(e,t,i=Gi,n=0,o=!0,r=!1){if(!I.enabled)return;const a=Si.getArrowHead(n);a.position.set(t.x,t.y,t.z),a.quaternion.setFromUnitVectors(this._up.set(0,1,0),bt.set(t.x,t.y,t.z).sub($y.set(e.x,e.y,e.z)).normalize());const h=bt.set(t.x,t.y,t.z).sub($y.set(e.x,e.y,e.z)).length()*.1;a.scale.set(h,h,h),a.material.depthTest=o,a.material.wireframe=r,Qi(a.material,i),this.DrawLine(e,t,i,n,o)}static DrawWireMesh(e){const t=Si.getMesh(e.duration??0);"mesh"in e?(t.geometry=e.mesh.geometry,t.matrix.copy(e.mesh.matrixWorld)):(t.geometry=e.geometry,t.matrix.copy(e.matrix)),t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,t.material.depthTest=e.depthTest??!0,t.material.wireframe=!0,Qi(t.material,e.color??Gi)}}const nC=new c.BoxGeometry(1,1,1);function Mm(s=null){const e=new c.Color(s??14540253),t=new c.EdgesGeometry(nC);return new c.LineSegments(t,new c.LineBasicMaterial({color:e}))}function Qi(s,e){if(Array.isArray(s)){for(const i of s)Qi(i,e);return}const t=e instanceof Z?e.a:1;s.color.set(e),s.opacity=t,s.transparent=t<1}const yp=Symbol("GizmoCache");class Si{static familyName="needle-gizmos";static ensureFont(){let e=J.__webpack_exports__default.FontLibrary.getFontFamily(this.familyName);e||(e=J.__webpack_exports__default.FontLibrary.addFontFamily(this.familyName),e.addVariant("normal","normal","https://uploads.needle.tools/include/font-msdf.json","https://uploads.needle.tools/include/font.png")?.addEventListener("ready",()=>{J.__webpack_exports__default.update()}))}static getTextLabel(e,t,i,n,o){this.ensureFont();let r=this.textLabelCache.pop(),a=1;o&&typeof o=="string"&&o?.length>=8&&o.startsWith("#")?(a=parseInt(o.substring(7),16)/255,o=o.substring(0,7),iC&&console.log(o,a)):typeof o=="object"&&o.a!==void 0&&(a=o.a);const l={boxSizing:"border-box",fontFamily:this.familyName,width:"auto",fontSize:i,color:n,lineHeight:1,backgroundColor:o??void 0,backgroundOpacity:a,textContent:t,borderRadius:.5*i,padding:.8*i,whiteSpace:"pre",offset:.05*i};if(r)r.set(l);else{r=new J.__webpack_exports__Text(l);const h=this,d=r;d.setText=function(u){this.set({textContent:u}),h.tmuiNeedsUpdate=!0}}return this.tmuiNeedsUpdate=!0,this.registerTimedObject(z.Current,r,e,this.textLabelCache),r}static getBox(e){let t=this.boxesCache.pop();if(!t){const i=new c.BoxGeometry(1,1,1);t=new c.Mesh(i)}return this.registerTimedObject(z.Current,t,e,this.boxesCache),t}static getLine(e){let t=this.linesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");i||(i=new c.BufferAttribute(new Float32Array(6),3),t.geometry.setAttribute("position",i))}return t.frustumCulled=!1,this.registerTimedObject(z.Current,t,e,this.linesCache),t}static getCircle(e){let t=this.circlesCache.pop();if(!t){t=new c.Line;let i=t.geometry.getAttribute("position");if(!i){i=new c.BufferAttribute(new Float32Array(df*3),3),t.geometry.setAttribute("position",i);const n=F(0,1,0),o=F(0,0,1),r=F(o);r.cross(n).normalize();const a=F(r),l=Math.PI*2/(df-1);for(let h=0;h<df+1;h++){const d=l*h;n.copy(a).multiplyScalar(Math.cos(d)*1),r.copy(o).multiplyScalar(Math.sin(d)*1);const u=n.add(r);i.setXYZ(h,u.x,u.y,u.z)}}}return t.frustumCulled=!1,this.registerTimedObject(z.Current,t,e,this.circlesCache),t}static getSphere(e,t,i){let n=this.spheresCache.pop();return n||(n=new c.Mesh(new c.SphereGeometry(1,8,8))),n.scale.set(e,e,e),n.material.wireframe=i,this.registerTimedObject(z.Current,n,t,this.spheresCache),n}static getArrowHead(e){let t=this.arrowHeadsCache.pop();return t||(t=new c.Mesh(new c.CylinderGeometry(0,.5,1,8))),this.registerTimedObject(z.Current,t,e,this.arrowHeadsCache),t}static getMesh(e){let t=this.mesh.pop();return t||(t=new c.Mesh,t.material=new c.MeshBasicMaterial),this.registerTimedObject(z.Current,t,e,this.mesh),t}static linesCache=[];static circlesCache=[];static spheresCache=[];static boxesCache=[];static arrowHeadsCache=[];static mesh=[];static textLabelCache=[];static registerTimedObject(e,t,i,n){if(!e){console.error("No Needle Engine context available. Did you call a Gizmos function in global scope?");return}const o=this.contextBeforeRenderCallbacks.get(e),r=this.contextPostRenderCallbacks.get(e);if(o){if(e.pre_render_callbacks[e.pre_render_callbacks.length-1]!==o){const a=e.pre_render_callbacks.indexOf(o);a>=0&&e.pre_render_callbacks.splice(a,1),e.pre_render_callbacks.push(o)}}else{const a=()=>{this.onBeforeRender(e,this.timedObjectsBuffer)};this.contextBeforeRenderCallbacks.set(e,a),e.pre_render_callbacks.push(a)}if(r){if(e.post_render_callbacks[e.post_render_callbacks.length-1]!==r){const a=e.post_render_callbacks.indexOf(r);a>=0&&e.post_render_callbacks.splice(a,1),e.post_render_callbacks.push(r)}}else{const a=()=>{this.onPostRender(e,this.timedObjectsBuffer,this.timesBuffer)};this.contextPostRenderCallbacks.set(e,a),e.post_render_callbacks.push(a)}t.traverse(a=>{a.layers.disableAll(),a.layers.enable(2)}),t.renderOrder=999999,t[yp]=n,t.castShadow=!1,t.receiveShadow=!1,t.isGizmo=!0,this.timedObjectsBuffer.push(t),this.timesBuffer.push(z.Current.time.realtimeSinceStartup+i),e.scene.add(t)}static timedObjectsBuffer=new Array;static timesBuffer=new Array;static contextPostRenderCallbacks=new Map;static contextBeforeRenderCallbacks=new Map;static tmuiNeedsUpdate=!1;static onBeforeRender(e,t){this.tmuiNeedsUpdate&&(this.tmuiNeedsUpdate=!1,J.__webpack_exports__default.update());for(let i=0;i<t.length;i++){const n=t[i];if(e.mainCamera&&n instanceof J.__webpack_exports__default.MeshUIBaseElement){if(Ko(n))continue;const o=e.isInVR,r=!1,a=!o;gc(n,e.mainCamera,r,a)}}}static onPostRender(e,t,i){const n=e.time.realtimeSinceStartup;for(let o=t.length-1;o>=0;o--){const r=t[o];n>=i[o]-1e-6&&(t.splice(o,1),i.splice(o,1),r.removeFromParent(),Ko(r)!=!0&&r[yp].push(r))}}}const It=w("debugphysics"),Hy=new c.Layers;class ro{static AllLayers=4294967295;ray;cam;screenPoint;raycaster;results;targets;recursive=!0;minDistance;maxDistance;lineThreshold;layerMask;ignore;testObject;useAcceleratedRaycast;allowSlowRaycastFallback=!0;screenPointFromOffset(e,t){this.screenPoint===void 0&&(this.screenPoint=new c.Vector2),this.screenPoint.x=e/window.innerWidth*2-1,this.screenPoint.y=-(t/window.innerHeight)*2+1}setLayer(e){Hy.set(e),this.layerMask=Hy}setMask(e){this.layerMask||(this.layerMask=new c.Layers);const t=this.layerMask;t?t.mask=e:this.layerMask=e}}class km{distance;point;object;constructor(e,t,i){this.object=e,this.distance=t,this.point=i}}class ga{static _raycasting=0;static get raycasting(){return this._raycasting>0}raycastPhysicsFast(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycast(e,t,{maxDistance:i,solid:n})??null}raycastPhysicsFastAndGetNormal(e,t=void 0,i=1/0,n=!0){return this.context.physics.engine?.raycastAndGetNormal(e,t,{maxDistance:i,solid:n})??null}sphereOverlapPhysics(e,t){return this.context.physics.engine?.sphereOverlap(e,t)??null}context;engine;constructor(e){this.context=e}raycaster=new c.Raycaster;defaultRaycastOptions=new ro;targetBuffer=new Array(1);defaultThresholds={Mesh:{},Line:{threshold:-1},LOD:{},Points:{threshold:0},Sprite:{}};sphereResults=new Array;sphereMask=new c.Layers;sphere=new c.Sphere;sphereOverlap(e,t,i=!0,n=!1,o=null){if(this.sphereResults.length=0,!this.context.scene)return this.sphereResults;const r=this.sphereMask;r.enableAll(),r.disable(2);for(const a of this.context.scene.children)this.intersectSphere(a,e,t,r,this.sphereResults,i,n,o);return this.sphereResults.sort((a,l)=>a.distance-l.distance)}raycastFromRay(e,t=null){const i=t??this.defaultRaycastOptions;i.ray=e;const n=this.raycast(i);return i===this.defaultRaycastOptions&&(i.ray=void 0),n}raycast(e=null){It&&performance.mark("raycast.start"),e||(e=this.defaultRaycastOptions);const t=e.screenPoint??this.context.input.mousePositionRC,i=e.raycaster??this.raycaster;if(i.near=e.minDistance??0,i.far=e.maxDistance??1/0,i.params=this.defaultThresholds,e.lineThreshold===void 0&&(e.lineThreshold=-1),i.params.Line={threshold:e.lineThreshold},e.ray)i.ray.copy(e.ray);else{const a=e.cam??this.context.mainCamera;if(!a)return It&&console.error("Can not perform raycast - no main camera found"),this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),this.defaultRaycastOptions.results??[];const l=this.context.xrCamera;this.context.isInXR&&l instanceof c.ArrayCamera&&l.cameras.length>0?i.setFromCamera(t,l.cameras[0]):i.setFromCamera(t,a)}let n=e.targets;n||(n=this.targetBuffer,n.length=1,n[0]=this.context.scene);let o=e.results;this.defaultRaycastOptions.results&&(this.defaultRaycastOptions.results.length=0),o||(this.defaultRaycastOptions.results||(this.defaultRaycastOptions.results=new Array),o=this.defaultRaycastOptions.results),e.layerMask!==void 0?e.layerMask instanceof c.Layers?i.layers.mask=e.layerMask.mask:i.layers.mask=e.layerMask:(i.layers.enableAll(),i.layers.disable(2)),It&&console.time("raycast"),o.length=0,ga._raycasting++,this.intersect(this.raycaster,n,o,e),o.sort((a,l)=>a.distance-l.distance);const r=e.ignore;return r!==void 0&&r.length>0&&(o=o.filter(a=>!r.includes(a.object))),ga._raycasting--,It&&(console.timeEnd("raycast"),console.warn("#"+this.context.time.frame+", hits:",o?.length?[...o]:"nothing"),performance.mark("raycast.end"),performance.measure("raycast","raycast.start","raycast.end")),o}intersect(e,t,i,n){for(const o of t){if(!o||o.visible===!1||I.isGizmo(o)||n.lineThreshold!==void 0&&n.lineThreshold<0&&o instanceof c.Line)continue;let r=!0;const a=o,l=a.geometry;if(n.testObject){const h=n.testObject?.(o);if(h===!1)continue;h==="continue in children"&&(r=!1)}if(r&&(l&&Gy(l)||(r=!1)),r){const h=ne.getRaycastMesh(o);h&&(a.geometry=h);const d=i.length;let u=!0;if(n.precise===!1&&(u=!1),u||=l.getAttribute("position")?.array?.length<64,a instanceof q.GroundedSkybox&&(u=!1),!u&&oC(a,e,i)||(n.useAcceleratedRaycast!==!1?vd.runMeshBVHRaycast(e,a,i,this.context,n):e.intersectObject(a,!1,i)),It&&i.length!=d){const p=i[i.length-1],m=h?8969557:7798784;I.DrawWireSphere(p.point,.1,m,1,!1),I.DrawWireMesh({mesh:o,depthTest:!1,duration:.2,color:m})}a.geometry=l}n.recursive!==!1&&this.intersect(e,o.children,i,n)}return i}tempBoundingBox=new c.Box3;intersectSphere(e,t,i,n,o,r,a,l){let h=e&&e.isMesh&&e.layers.test(n)&&!I.isGizmo(e);h&&=e.visible,h&&=!(e instanceof c.Line),h&&=!(e instanceof q.GroundedSkybox);const d=e,u=d.geometry;if(h&&l){const p=l(e);if(p===!1)return;p==="continue in children"&&(h=!1)}if(u&&Gy(u)||(h=!1),h){if(a){const p=this.sphere;p.center.copy(t),p.radius=i;const m=o.length;if(vd.runMeshBVHRaycast(this.sphere,d,o,this.context,{}),m!=o.length&&!r)return}else if(u.boundingBox||u.computeBoundingBox(),u.boundingBox){d.matrixWorldNeedsUpdate&&d.updateWorldMatrix(!1,!1);const p=this.tempBoundingBox.copy(u.boundingBox).applyMatrix4(d.matrixWorld),m=this.sphere;if(m.center.copy(t),m.radius=i,m.intersectsBox(p)){const y=X(e),_=y.distanceTo(m.center),g=new km(e,_,y);if(o.push(g),!r)return}}}if(e.children)for(const p of e.children){const m=o.length;if(this.intersectSphere(p,t,i,n,o,r,a,l),m!=o.length&&!r)return}}}function Gy(s){return!(s.index&&s.index.array.length<3)}const xo=new c.Sphere,vh=new c.Plane,sC=new c.Matrix3;function oC(s,e,t){const i=s._computeIntersections;if(!i)return!1;let n=s["_computeIntersections:Needle"];return n||(n=s["_computeIntersections:Needle"]=function(o,r,a){const l=this,h=l.geometry.boundingSphere;if(h){if(l instanceof q.GroundedSkybox){vh.setFromNormalAndCoplanarPoint(F(0,1,0),F(0,-l.position.y,0)),vh.applyMatrix4(l.matrixWorld,sC);const u=o.ray.intersectPlane(vh,F());if(u){xo.copy(h),xo.applyMatrix4(l.matrixWorld);const m=F(u).sub(o.ray.origin).length(),y=xo.radius*.5;m<y&&r.push({distance:m,point:u,object:l,normal:vh.normal.clone()})}return}xo.copy(h),xo.applyMatrix4(l.matrixWorld);const d=o.ray.intersectSphere(xo,F());if(d){const u=F(d).sub(o.ray.origin),p=u.length();if(p>xo.radius){const m=u.clone().normalize();r.push({distance:p,point:d,object:l,normal:m})}}}}),s._computeIntersections=n,e.intersectObject(s,!1,t),s._computeIntersections=i,!0}var vd;(s=>{function e(v,b,x,R,O){if(!b.geometry||!b.geometry.hasAttribute("position"))return!1;const M=b.geometry;if(b?.isSkinnedMesh){const E=b,B=E.bvhNeedsUpdate;if(!E.staticGenerator)a(),o&&(E.staticGenerator=new o(b),E.staticGenerator.applyWorldTransforms=!1,E.staticGeometry=E.staticGenerator.generate(),M.boundsTree=r?.call(E.staticGeometry),E.staticGeometryLastUpdate=performance.now()+Math.random()*200,E.bvhNeedsUpdate=!0);else if(M.boundsTree&&(E.autoUpdateMeshBvhInterval!==void 0&&E.autoUpdateMeshBvhInterval>=0||B===!0)){const L=performance.now(),V=L-E.staticGeometryLastUpdate,$=E.autoUpdateMeshBvhInterval??100;(B||V>$)&&(It&&console.warn(`Physics: updating skinned mesh bvh for ${b.name} after ${V.toFixed(2)}ms`),E.bvhNeedsUpdate=!1,E.staticGeometryLastUpdate=L,E.staticGenerator?.generate(E.staticGeometry),M.boundsTree.refit())}}else if(!M.boundsTree){h||g();let E=!0;if((R.xr||M[m]===!1||M.getAttribute("position")?.isInterleavedBufferAttribute||M.index&&M.index?.isInterleavedBufferAttribute)&&(E=!1),E&&u){if(M[p]===void 0){let B=null;if(_.length>0){const L=_.shift();L&&!L.running&&(B=L)}if(!B&&y.length<3&&(B=new u,y.push(B)),B!=null&&!B.running){const L=b.name;It&&console.log("<<<< worker start",L,B),M[p]="queued",performance.mark("bvh.create.start");const V=M.clone();try{B.generate(V).then($=>{M[p]="done",M.boundsTree=$}).catch($=>{M[p]="failed - "+$?.message,M[m]=!1,It&&console.error("Failed to generate mesh bvh on worker",$)}).finally(()=>{It&&console.log(">>>>> worker done",L,{hasBoundsTre:M.boundsTree!=null}),_.push(B),V.dispose(),performance.mark("bvh.create.end"),performance.measure("bvh.create (worker)","bvh.create.start","bvh.create.end")})}catch($){console.error("Failed to generate mesh bvh on worker",$)}}else It&&console.warn("No worker available")}}else(!d||!E)&&(a(),n&&(performance.mark("bvh.create.start"),M.boundsTree=new n(M),performance.mark("bvh.create.end"),performance.measure("bvh.create","bvh.create.start","bvh.create.end")))}if(v instanceof c.Raycaster){const E=v,B=b.raycast;if(M.boundsTree)a(),i&&(b.acceleratedRaycast||(b.acceleratedRaycast=i.bind(b),It&&console.debug(`Physics: bind acceleratedRaycast fn to "${b.name}"`)),b.raycast=b.acceleratedRaycast);else if(It&&console.warn("No bounds tree found for mesh",b.name,{workerTask:M[p],hasAcceleratedRaycast:i!=null}),O.allowSlowRaycastFallback===!1&&(M.getAttribute("position")?.array?.length??0)>2e3)return It&&console.warn("Skipping raycast because no bounds tree is available and allowSlowRaycastFallback is false"),!1;const L=E.firstHitOnly;return E.firstHitOnly=!1,E.intersectObject(b,!1,x),E.firstHitOnly=L,b.raycast=B,!0}else if(v instanceof c.Sphere){const E=M.boundsTree;if(E){const B=v;if(l.copy(b.matrixWorld).invert(),B.applyMatrix4(l),E.intersectsSphere(B)){const V=X(b),$=V.distanceTo(B.center),T=new km(b,$,V);x.push(T)}}return!0}return!1}s.runMeshBVHRaycast=e;let t=!1,i=null,n=null,o=null,r=null;function a(){t||(t=!0,Promise.resolve().then(()=>require("./vendor-CPuBPspY.umd.cjs")).then(v=>v.index$1).then(v=>{i=v.acceleratedRaycast,n=v.MeshBVH,o=v.StaticGeometryGenerator,r=v.computeBoundsTree}).catch(v=>{(It||A())&&console.error("Failed to load BVH library...",v.message)}))}const l=new c.Matrix4;let h=!1,d=!1,u=null;const p=Symbol("Needle:MeshBVH-Worker"),m=Symbol("Needle:MeshBVH-CanUseWorker"),y=[],_=[];function g(){h=!0,d=!0,Promise.resolve().then(()=>YR).then(v=>{u=v.GenerateMeshBVHWorker}).catch(v=>{(It||A())&&console.warn("Failed to setup mesh bvh worker")}).finally(()=>{d=!1})}})(vd||(vd={}));const qy=Symbol("gltf-loader-internal-usage-tracker"),rC=w("debugusers");class oa{get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return oa._loadingProcesses>0}static _loadingProcesses=0;parser;_getDependency;_loadingId;_loadedObjects=new Set;constructor(e){this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}beforeRoot(){oa._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,n){const o=t.call(this,i,n);return o.then(r=>(r&&(e._loadedObjects.add(r),r[qy]=e._loadingId),r)),o},null}afterRoot(e){oa._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[qy],t instanceof c.Object3D&&(t.parent||t instanceof c.Mesh&&setTimeout(()=>{rC&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null},1e3));return null}}class a0{constructor(){window.addEventListener("unhandledrejection",e=>{if(e.defaultPrevented)return;const t=e?.reason?.path;if(t){const i=t[0];i&&i.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
168
168
|
`+i.src),e.preventDefault())}})}}const Zd=w("trackresources");function l0(){return Zd==="dispose"}let lr=!0;Zd===0&&(lr=!1);function aC(s){lr=s}function c0(){return lr}const h0=Symbol("disposable");function d0(s,e){s&&(s[h0]=e,zo&&console.warn("Set disposable",e,s))}const u0=Symbol("disposed");function lC(s){return s[u0]===!0}function _e(s){if(s){if(s[h0]===!1){zo&&console.warn("Object is marked as not disposable",s);return}if(typeof s=="object"&&(s[u0]=!0),s instanceof c.Scene)_e(s.environment),_e(s.background),_e(s.customDepthMaterial),_e(s.customDistanceMaterial);else if(s instanceof c.SkinnedMesh)_e(s.geometry),_e(s.material),_e(s.skeleton),_e(s.bindMatrix),_e(s.bindMatrixInverse),_e(s.customDepthMaterial),_e(s.customDistanceMaterial),s.visible=!1;else if(s instanceof c.Mesh)_e(s.geometry),_e(s.material),_e(s.customDepthMaterial),_e(s.customDistanceMaterial),s.visible=!1;else if(s instanceof c.Object3D)s.visible=!1;else if(s instanceof c.BufferGeometry){Ar(s);for(const e of Object.keys(s.attributes)){const t=s.attributes[e];_e(t)}}else if(s instanceof c.BufferAttribute||s instanceof c.InterleavedBufferAttribute)zo&&console.warn("BufferAttribute dispose not supported",s.count);else if(s instanceof Array)for(const e of s)e instanceof c.Material&&_e(e);else if(s instanceof c.Material){Ar(s);for(const t of Object.keys(s)){const i=s[t];i instanceof c.Texture&&_e(i)}const e=s.uniforms;if(e)for(const t of Object.keys(e)){const i=e[t];i instanceof c.Texture?_e(i):i instanceof c.Uniform$1&&_e(i.value)}}else s instanceof c.Texture?(Ar(s),Ar(s.source),s.source?.data instanceof ImageBitmap&&Ar(s.source.data)):s instanceof c.Skeleton?(Ar(s.boneTexture),s.boneTexture=null):s instanceof c.Bone||!(s instanceof c.Object3D)&&zo&&console.warn("Unknown object type",s)}}function Ar(s){s&&((zo||l0()||Zd)&&console.warn("🧨 FREE",s),s instanceof ImageBitmap||"dispose"in s&&typeof s.dispose=="function"&&s.dispose())}function cC(s){}const hC=new Set;function Em(s,e,t=null,i){if(i||(i=hC,i.clear()),!s)return i;const n=s[Kl];if(n)for(const o of n)i.has(o)||t?.call(null,o)!==!1&&(i.add(o),e&&Em(o,!0,t,i));return i}function dC(s){return s[bl]}const zo=w("debugresourceusers")||w("debugmemory"),Kl=Symbol("needle-resource-users"),bl=Symbol("needle-resource-users-count");function Et(s,e){Qd(s,e,function(t,i){lr&&!ga.raycasting&&(wd(Kl,this,t,!1),wd(Kl,this,i,!0))})}lr&&(Et(c.Mesh.prototype,"material"),Et(c.Mesh.prototype,"geometry"),Et(c.Material.prototype,"map"),Et(c.Material.prototype,"bumpMap"),Et(c.Material.prototype,"alphaMap"),Et(c.Material.prototype,"normalMap"),Et(c.Material.prototype,"displacementMap"),Et(c.Material.prototype,"roughnessMap"),Et(c.Material.prototype,"metalnessMap"),Et(c.Material.prototype,"emissiveMap"),Et(c.Material.prototype,"specularMap"),Et(c.Material.prototype,"envMap"),Et(c.Material.prototype,"lightMap"),Et(c.Material.prototype,"aoMap"),Et(c.Material.prototype,"gradientMap"));function uC(s){if(lr===!1)return;const e=s[Kl];if(e)for(const t of e)wd(Kl,t,s,!1)}lr&&Qd(c.Material.prototype,"dispose",function(){uC(this)});let _p=0;function wd(s,e,t,i){if(_p>0)return;if(Array.isArray(t)){for(const o of t)wd(s,e,o,i);return}if(!t)return;let n=t[s];if(n||(n=new Set),i){if(e&&!n.has(e)){n.add(e);let o=t[bl]||0;o+=1,t[bl]=o,zo&&console.warn(`🟢 Added user of "${t.type}"`,e,t,o,"users:",n)}}else if(e&&n.has(e)){n.delete(e);let o=t[bl]||0;o>0&&(o-=1,t[bl]=o),zo&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,o,"users:",n),o<=0&&(oa.isLoading(t)||(Zd&&console.warn(`🔴 Removed all user of "${t.type}"`,t),l0()&&_e(t)))}t[s]=n}try{Qd(c.WebGLRenderer.prototype,"render",function(){_p++},function(){_p--})}catch(s){console.warn("Could not wrap WebGLRenderer.render",s)}const Xy=w("debugcomponentevents");class Jd{static eventListeners=new Map;static addComponentLifecylceEventListener(e,t){this.eventListeners.has(e)&&this.eventListeners.set(e,[]);let i=this.eventListeners.get(e);i||(i=[]),i.push(t),this.eventListeners.set(e,i),Xy&&console.log("Added event listener for "+e,this.eventListeners)}static removeComponentLifecylceEventListener(e,t){const i=this.eventListeners.get(e);if(!i)return;const n=i.indexOf(t);n<0||i.splice(n,1)}static dispatchComponentLifecycleEvent(e,t){const i=this.eventListeners.get(e);if(Xy&&console.log("Dispatching event "+e,i),!!i)for(const n of i)n(t)}}const Zl=Symbol("NEEDLE_NEED_UPDATE_INSTANCE"),f0=Symbol("isUsingInstancing"),p0=Symbol("instancingRenderer"),vl=Symbol("instancingAutoUpdateBounds");class Li{static isUsingInstancing(e){return e[f0]===!0}static getRenderer(e){return e[p0]||null}setAutoUpdateBounds(e,t){const i=Li.getRenderer(e);i&&(i[vl]=t)}static markDirty(e,t=!0){if(e&&(this.isUsingInstancing(e)&&(e[Zl]=!0,e.matrixWorldNeedsUpdate=!0),t))for(const i of e.children)Li.markDirty(i,!0)}}exports.NEEDLE_ENGINE_FEATURE_FLAGS=void 0;(s=>{s.experimentalSmartHierarchyUpdate=!1})(exports.NEEDLE_ENGINE_FEATURE_FLAGS||(exports.NEEDLE_ENGINE_FEATURE_FLAGS={}));function ra(s,e){try{e||s()}catch(t){return console.error(t),!1}return!0}const bp=w("debugnewscripts"),fC=w("debughierarchy"),ve=[];function pC(){return ve.length>0}function xd(s){if(bp&&console.log("Register new components",s.new_scripts.length,[...s.new_scripts],s.alias?"element: "+s.alias:s.hash,s),s.new_scripts_pre_setup_callbacks.length>0){for(const e of s.new_scripts_pre_setup_callbacks)e&&e();s.new_scripts_pre_setup_callbacks.length=0}if(!(s.new_scripts.length<=0)){ve.length=0,s.new_scripts.length>0&&ve.push(...s.new_scripts),s.new_scripts.length=0;for(let e=0;e<ve.length;e++)try{const t=ve[e];if(t.isComponent!==!0){(A()||bp)&&console.error(`Registered script is not a Needle Engine component.
|
|
169
169
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
170
170
|
`,t),ve.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.warn(`Component can not be initialized: no GameObject assigned.
|
|
@@ -876,7 +876,7 @@ Target Framerate: `+this.targetFrameRate)),this._dispatchReadyAfterFrame&&(this.
|
|
|
876
876
|
padding-left: 25px;
|
|
877
877
|
border-radius: .5em;
|
|
878
878
|
border: 2px solid rgba(160,160,160,.3);
|
|
879
|
-
`,n=`Needle Engine — No license active, commercial use is not allowed. Visit https://needle.tools/pricing for more information and licensing options! v${Ji}`;z.Current?.xr?console.log(n):console.log("%c "+n,t)}async function P1(s){if(window.crossOriginIsolated)return;if(Tn==="pro"){const t=s?.domElement?.getAttribute("no-telemetry");if(t===""||t==="true"||t==="1"){ai&&console.debug("Telemetry is disabled");return}ai&&console.debug("Telemetry attribute: "+t)}try{const t="https://needle-engine-analytics-v2-r26roub2hq-lz.a.run.app";if(t){const i=window.location.href.split("?")[0];let n="api/v2/new/request";t.endsWith("/")||(n="/"+n);const o=Tn,r=`${t}${n}`;ai&&console.debug("Sending beacon");const a={license:o,url:i,hostname:window.location.hostname,pathname:window.location.pathname,version:Ji,generator:Xd,build_time:ym,public_key:Yr},l=navigator.sendBeacon?.(r,JSON.stringify(a));ai&&console.debug("Sent beacon: "+l)}}catch(t){ai&&console.log("Failed to send non-commercial usage message to analytics backend",t)}}function rv(s,e){return ds(s,re.ContextCreated,e),()=>oo(s,re.ContextCreated)}function O1(s,e){return ds(s,re.ContextClearing,e),()=>oo(s,re.ContextClearing)}function M1(s,e){return ds(s,re.ContextDestroying,e),()=>oo(s,re.ContextDestroying)}function ru(s,e){return ds(s,pe.Start,e),()=>oo(s,pe.Start)}function av(s,e){return ds(s,pe.Update,e),()=>oo(s,pe.Update)}function k1(s,e){return ds(s,pe.OnBeforeRender,e),()=>oo(s,pe.OnBeforeRender)}function E1(s,e){return ds(s,pe.OnAfterRender,e),()=>oo(s,pe.OnAfterRender)}const R1=w("debugdecoders");let wf=null;function lv(){if(!wf){const s=ne.createLoaders(null);wf={dracoLoader:s.dracoLoader,ktx2Loader:s.ktx2Loader,meshoptDecoder:s.meshoptDecoder}}return wf}function f_(s){s!==void 0&&typeof s=="string"&&ne.setDracoDecoderLocation(s)}function p_(s){if(s!==void 0&&typeof s=="string"&&s!=="js"){const e=lv();R1&&console.log("Setting draco decoder type to",s),e.dracoLoader.setDecoderConfig({type:s})}}function m_(s){s!==void 0&&typeof s=="string"&&ne.setKTX2TranscoderLocation(s)}function Vm(s,e){const t=lv();return e.renderer?t.ktx2Loader.detectSupport(e.renderer):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail"),ne.addDracoAndKTX2Loaders(s),s.dracoLoader||s.setDRACOLoader(t.dracoLoader),s.ktx2Loader||s.setKTX2Loader(t.ktx2Loader),s.meshoptDecoder||s.setMeshoptDecoder(t.meshoptDecoder),ne.configureLoader(s,{progressive:!0}),s}const $e=function(s){return f(s)},f=function(s){if(s===void 0&&(s=null),!Array.isArray(s))s=g_(s);else for(let e=0;e<s.length;e++){const t=s[e];s[e]=g_(t)}return function(e,t){if(!e){const n=typeof t=="string"?t:t.name;console.warn(`@serializable without a target at '${n}'.`);return}typeof t!="string"&&(t=t.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const i=e.$serializedTypes=e.$serializedTypes||{};i[t]=s}};function g_(s){switch(s?.prototype?.constructor?.name){case"Number":case"String":case"Boolean":return null}return s}const qs=w("debughotreload");let ec=!1;const zl=new Map;function T1(){return ec}function Dp(){return globalThis.NEEDLE_HOT_RELOAD_ENABLED===!0}function cv(s){if(ec){qs&&console.warn("[Needle Engine] Hot reloading is in progress, not registering instance",s);return}qs&&console.log("[Needle Engine] Registering hot reload instance",s);const t=s.constructor.name;zl.has(t)?zl.get(t)?.push(s):zl.set(t,[s])}function hv(s){if(ec){qs&&console.warn("[Needle Engine] Hot reloading is in progress, not unregistering instance",s);return}qs&&console.log("[Needle Engine] Unregistering hot reload instance",s);const t=s.constructor.name,i=zl.get(t);if(!i)return;const n=i.indexOf(s);n!==-1&&i.splice(n,1)}let y_=!1;function A1(){if(qs||y_)return;y_=!0;const s=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}s.apply(console,e)}}function L1(s){qs&&console.log("[HMR] Apply changes",s,Object.keys(s)),A1();for(const e of Object.keys(s))try{ec=!0;const t=P.get(e);if(!t){qs&&console.log("[HMR] Type not found: "+e);continue}const i=s[e],n=zl.get(i.name);let o="[Needle Engine] Updating type: "+e;const r=n?.length??-1;r>0?o+=" x"+r:o+=" (No instances registered)",console.log(o);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(i.prototype);for(const h in l)l[h].writable&&(t.prototype[h]=s[e].prototype[h]);for(const h of a)l[h]||delete t.prototype[h];if(n){const h=new i,d=Object.getOwnPropertyDescriptors(h);for(const u of n){const p=u,m=p.isComponent===!0,y=m?p.activeAndEnabled:!0,_=m?p.context:void 0;try{if(m&&_&&es(p,_),m&&y&&(p.enabled=!1),u.onBeforeHotReloadFields&&u.onBeforeHotReloadFields()===!1)continue;for(const g in d)if(d[g].writable){if(u[g]===void 0)u[g]=h[g];else if(typeof u[g]=="function"&&!u[g].prototype){const b=u[g],x=b.name,R="bound ";if(x===R)continue;const O=b.name.substring(R.length),M=i.prototype[O];M&&(u[g]=M.bind(u))}}u.onAfterHotReloadFields&&u.onAfterHotReloadFields()}finally{m&&_&&Rm(p,_),m&&y&&(p.enabled=!0)}}}}catch(t){if(qs)console.error(t);else return!1}finally{ec=!1,Do(ci.Log,"Script changes applied (HMR)")}return!0}class S extends c.Object3D{guid;static isDestroyed(e){return Ko(e)}static setActive(e,t,i=!0){e&&(Fl(e,t),Kh(e),t&&i&&m0(z.Current,e))}static isActiveSelf(e){return Pa(e)}static isActiveInHierarchy(e){return F0(e)}static markAsInstancedRendered(e,t){U0(e,t)}static isUsingInstancing(e){return iu(e)}static foreachComponent(e,t,i=!0){return Zo(e,t,i)}static instantiateSynced(e,t){return e?Am(e,t):null}static instantiate(e,t=null){return"isAssetReference"in e,Jo(e,t)}static destroySynced(e,t,i=!0){if(!e)return;const n=e;t=t??z.Current,bc(n,t.connection,i)}static destroy(e,t=!0){return ui(e,t)}static add(e,t,i){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}i||(i=z.Current),t.add(e),Fl(e,!0),Kh(e),i?S.foreachComponent(e,n=>{Rm(n,i),!n.__internalDidAwakeAndStart&&i.new_script_start.includes(n)===!1&&i.new_script_start.push(n)},!0):console.warn("Missing context")}}static remove(e){e&&(e.parent?.remove(e),Fl(e,!1),Kh(e),S.foreachComponent(e,t=>{mC(t)},!0))}static invokeOnChildren(e,t,...i){this.invoke(e,t,!0,i)}static invoke(e,t,i=!1,...n){e&&this.foreachComponent(e,o=>{const r=o[t];r&&typeof r=="function"&&r?.call(o,...n)},i)}static addNewComponent(e,t,i,n=!0){return en(e,t,i,{callAwake:n})}static addComponent(e,t,i,n){return en(e,t,i,n)}static moveComponent(e,t){return en(e,t)}static removeComponent(e){return Bm(e.gameObject,e),e}static getOrAddComponent(e,t){return wc(e,t)}static getComponent(e,t){return e===null?null:cr(e,t)}static getComponents(e,t,i=null){return e===null?i??[]:xc(e,t,i)}static findByGuid(e,t){return Fm(e,t)}static findObjectOfType(e,t,i=!0){return Ca(e,t??z.Current,i)}static findObjectsOfType(e,t){const i=[];return B0(e,i,t),i}static getComponentInChildren(e,t){return Sc(e,t)}static getComponentsInChildren(e,t,i=null){return Sa(e,t,i??void 0)}static getComponentInParent(e,t){return Jl(e,t)}static getComponentsInParent(e,t,i=null){return eu(e,t,i)}static getAllComponents(e){const t=e.userData?.components;return t?[...t]:[]}static*iterateComponents(e){const t=e?.userData?.components;if(t&&Array.isArray(t))for(let i=0;i<t.length;i++)yield t[i]}}class k{get isComponent(){return!0}__context;get context(){return this.__context??z.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){return this.gameObject?.userData?.layer}get name(){return this.gameObject?.name?this.gameObject.name:this.gameObject?.userData.name}__name;set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){return this.gameObject?.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){return this.gameObject?.userData.static}set static(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.static=e)}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[ls];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[ls]=e)}gameObject;guid="invalid";sourceId;awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=pe.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=pe.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}__didAwake=!1;__didStart=!1;__didEnable=!1;__isEnabled=void 0;__destroyed=!1;get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}constructor(e){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),Dp()&&cv(this)}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(A()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){this.__destroyed||(this.__destroyed=!0,this.__didAwake&&(this.onDestroy?.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),I0(this),Dp()&&hv(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){A()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return X(this.gameObject)}set worldPosition(e){ot(this.gameObject,e)}setWorldPosition(e,t,i){Qo(this.gameObject,e,t,i)}get worldQuaternion(){return ue(this.gameObject)}set worldQuaternion(e){tn(this.gameObject,e)}setWorldQuaternion(e,t,i,n){dm(this.gameObject,e,t,i,n)}get worldEuler(){return um(this.gameObject)}set worldEuler(e){fm(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){yc(this.gameObject,e,t,i,n)}static _forward=new c.Vector3;get forward(){return k._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}static _right=new c.Vector3;get right(){return k._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}static _up=new c.Vector3;get up(){return k._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}_eventListeners=new Map;addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}}const D1=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:k,Component:k,GameObject:S},Symbol.toStringTag,{value:"Module"}));var I1=Object.defineProperty,dv=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&I1(e,t,n),n};class Oc extends k{from;to;width=0;centered=!0;_centerPos;awake(){this._centerPos=new c.Vector3}update(){if(!this.from||!this.to)return;const e=X(this.from).clone(),t=X(this.to).clone(),i=e.distanceTo(t);this._centerPos.copy(e),this._centerPos.add(t),this._centerPos.multiplyScalar(.5),ot(this.gameObject,this.centered?this._centerPos:e),this.gameObject.lookAt(X(this.to).clone()),this.gameObject.scale.set(this.width,this.width,i)}}dv([f(S)],Oc.prototype,"from");dv([f(S)],Oc.prototype,"to");var j1=Object.defineProperty,B1=Object.getOwnPropertyDescriptor,hr=(s,e,t,i)=>{for(var n=i>1?void 0:i?B1(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&j1(e,t,n),n};const ks=w("debuganimation");let uv=class{x;y};class St extends k{get isAnimationComponent(){return!0}addClip(e){this.animations||(this.animations=[]),this.animations.includes(e)||this.animations.push(e)}playAutomatically=!0;randomStartTime=!0;minMaxSpeed;minMaxOffsetNormalized;loop=!0;clampWhenFinished=!1;get time(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.time}return 0}set time(e){if(this.actions)for(const t of this.actions)t.time=e}get duration(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.getClip().duration}return 0}_tempAnimationClipBeforeGameObjectExisted=null;get clip(){return this.animations?.length?this.animations[0]:null}set clip(e){if(!this.__didAwake){ks&&console.warn("Assign clip during serialization",e),this._tempAnimationClipBeforeGameObjectExisted=e;return}e&&(this.gameObject.animations||(this.gameObject.animations=[]),!this.animations.includes(e)&&(this.animations.length>0?this.animations.splice(0,0,e):this.animations.push(e)))}set clips(e){this.animations=e}_tempAnimationsArray;set animations(e){e==null||!Array.isArray(e)||(this.gameObject?this.gameObject.animations=e:this._tempAnimationsArray=e)}get animations(){return this.gameObject?.animations||this._tempAnimationsArray||[]}mixer=void 0;get actions(){return this._actions}set actions(e){this._actions=e}_actions;_handles;awake(){this.mixer=void 0,ks&&console.log("Animation Awake",this.name,this),this._tempAnimationsArray&&(this.animations=this._tempAnimationsArray,this._tempAnimationsArray=void 0),this._tempAnimationClipBeforeGameObjectExisted&&(this.clip=this._tempAnimationClipBeforeGameObjectExisted,this._tempAnimationClipBeforeGameObjectExisted=null),this.actions=[],this._handles=[]}onEnable(){if(this.playAutomatically&&this.animations?.length>0){const e=Math.floor(Math.random()*this.animations.length),t=this.animations[e];this.play(e,{exclusive:!0,fadeDuration:0,startTime:this.randomStartTime?Math.random()*t.duration:0,loop:this.loop,clampWhenFinished:this.clampWhenFinished})}}update(){this.mixer&&(this.mixer.update(this.context.time.deltaTime),this._handles.forEach(e=>e.update()))}onDisable(){this.mixer&&this.mixer.stopAllAction()}onDestroy(){this.context.animations.unregisterAnimationMixer(this.mixer)}getAction(e){return this.actions?.find(t=>t.getClip().name===e)||null}get isPlaying(){if(this.actions){for(let e=0;e<this.actions.length;e++)if(this.actions[e].isRunning())return!0}return!1}stopAll(e){if(this.actions)for(const t of this.actions)e?.fadeDuration?t.fadeOut(e.fadeDuration):t.stop()}stop(e,t){if(e===void 0){this.stopAll();return}else if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(n=>n.name===e));if(!e){console.error("Could not find clip",e);return}const i=this.actions.find(n=>n.getClip()===e);if(!i){console.error("Could not find action",e);return}t?.fadeDuration?i.fadeOut(t.fadeDuration):i.stop()}pause(e,t=!1){if(e===void 0){for(const n of this.actions)n.paused=!t;return}else if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(n=>n.name===e));if(!e){console.error("Could not find clip",e);return}const i=this.actions.find(n=>n.getClip()===e);if(!i){console.error("Could not find action",e);return}i.paused=!t}resume(){for(const e of this.actions)e.paused=!1}play(e=0,t){if(ks&&console.log("PLAY",e),this.ensureMixer(),!this.mixer){ks&&console.warn("Missing mixer",this);return}e===void 0&&(e=0);let i=e;if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}i=this.animations[e]}else typeof e=="string"&&(i=this.animations.find(o=>o.name===e));if(!i){console.error("Could not find clip",e);return}t||(t={});for(const o of this.actions)if(o.getClip()===i)return this.internalOnPlay(o,t);if(!i.tracks){console.warn("Clip is no AnimationClip",i);return}const n=this.mixer.clipAction(i);return this.actions.push(n),this.internalOnPlay(n,t)}internalOnPlay(e,t){var i=this.actions.find(r=>r===e);if(i===e&&i.isRunning()&&i.time<i.getClip().duration){const r=this.tryFindHandle(e);if(i.paused&&(i.paused=!1),r)return r.waitForFinish()}if(t.loop===void 0&&(t.loop=this.loop),t.clampWhenFinished===void 0&&(t.clampWhenFinished=this.clampWhenFinished),t.minMaxOffsetNormalized===void 0&&this.randomStartTime&&(t.minMaxOffsetNormalized=this.minMaxOffsetNormalized),t.minMaxSpeed===void 0&&(t.minMaxSpeed=this.minMaxSpeed),t?.exclusive??!0)for(const r of this.actions)r!=i&&(t.fadeDuration?r.fadeOut(t.fadeDuration):r.stop());if(t?.fadeDuration&&e.fadeIn(t.fadeDuration),e.enabled=!0,t?.startTime!=null)e.time=t.startTime;else if(t?.minMaxOffsetNormalized&&t.minMaxOffsetNormalized.x!=0&&t.minMaxOffsetNormalized.y!=0){const r=e.getClip();e.time=D.lerp(t.minMaxOffsetNormalized.x,t.minMaxOffsetNormalized.y,Math.random())*r.duration}else e.time>=e.getClip().duration&&(e.time=0);t?.minMaxSpeed?e.timeScale=D.lerp(t.minMaxSpeed.x,t.minMaxSpeed.y,Math.random()):e.timeScale=t?.speed??1,t?.loop!=null?e.loop=t.loop?c.LoopRepeat:c.LoopOnce:e.loop=c.LoopOnce,t?.clampWhenFinished&&(e.clampWhenFinished=!0),e.paused=!1,e.play(),ks&&console.log("PLAY",e.getClip().name,e);const o=new F1(e,this.mixer,t,r=>{this._handles.splice(this._handles.indexOf(o),1)});return this._handles.push(o),o.waitForFinish()}tryFindHandle(e){for(const t of this._handles)if(t.action===e)return t}ensureMixer(){if(!this.mixer){const e="animationMixer";this.gameObject[e]&&(this.mixer=this.gameObject[e]),(!this.mixer||!this.mixer.clipAction)&&(this.mixer=new c.AnimationMixer(this.gameObject),this.gameObject[e]=this.mixer)}this.context.animations.registerAnimationMixer(this.mixer)}}hr([f()],St.prototype,"playAutomatically",2);hr([f()],St.prototype,"randomStartTime",2);hr([f(uv)],St.prototype,"minMaxSpeed",2);hr([f(uv)],St.prototype,"minMaxOffsetNormalized",2);hr([f()],St.prototype,"loop",2);hr([f()],St.prototype,"clampWhenFinished",2);hr([f(c.AnimationClip)],St.prototype,"clips",1);class F1{mixer;action;promise=null;_options;_resolveCallback=null;_resolvedOrRejectedCallback;constructor(e,t,i,n){this.action=e,this.mixer=t,this._resolvedOrRejectedCallback=n,this._options=i}waitForFinish(){return this.promise?this.promise:(this.promise=new Promise(e=>{this._resolveCallback=e}),this.mixer.addEventListener("finished",this.onFinished),this.promise)}update(){this._options&&this._options.endTime!==void 0&&this.action.time>this._options.endTime&&(this._options.loop===!0?this.action.time=this._options.startTime??0:(this.action.time=this._options.endTime,this.action.timeScale=0,this.onResolve()))}onResolve(){this.dispose(),this._resolvedOrRejectedCallback?.call(this,this),this._resolveCallback?.call(this,this.action)}onFinished=e=>{e.action===this.action&&this.onResolve()};dispose(){this.mixer.removeEventListener("finished",this.onFinished)}}const nd=Symbol("objectIsAnimatedData");function __(s,e,t){if(!s)return;if(s[nd]===void 0){if(!t)return;s[nd]=new Set}const i=s[nd];t?i.add(e):i.has(e)&&i.delete(e)}function U1(s){if(!s)return!1;const e=s[nd];return e!==void 0&&e.size>0}class z1{_context;get context(){return this._context??z.Current}get isStateMachineBehaviour(){return!0}}class wl{name;nameHash;normalizedTime;length;speed;action;hasTransitions;constructor(e,t,i,n){this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=i,this.speed=n,this.action=e.motion.action||null,this.hasTransitions=e.transitions?.length>0||!1}}function fv(s,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??c.MathUtils.generateUUID(),index:-1,clip:new c.AnimationClip(s,0,[])}}var Us=(s=>(s[s.If=1]="If",s[s.IfNot=2]="IfNot",s[s.Greater=3]="Greater",s[s.Less=4]="Less",s[s.Equals=6]="Equals",s[s.NotEqual=7]="NotEqual",s))(Us||{}),$m=(s=>(s[s.Float=1]="Float",s[s.Int=3]="Int",s[s.Bool=4]="Bool",s[s.Trigger=9]="Trigger",s))($m||{});const qe=w("debuganimatorcontroller"),Ph=w("debugrootmotion");class Di{static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let r=0;r<e.length;r++){const a=e[r],l=[];if(t.autoTransition!==!1){const d=t.transitionDuration??0,u=d/a.duration;let p=r;(t.autoTransition===void 0||t.autoTransition===!0)&&(p=(r+1)%e.length),l.push({exitTime:1-u,offset:0,duration:d,hasExitTime:!0,destinationState:p,conditions:[]})}const h={name:a.name,hash:r,motion:{name:a.name,clip:a,isLooping:t?.looping??!1},transitions:l,behaviours:[]};i.push(h)}const n={name:"AnimatorController",guid:new mt(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new Di(n)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const r=this.model.layers[t].stateMachine;for(const a of r.states)if(a.name===e||a.hash===e){qe&&console.log("transition to ",a),this.transitionTo(a,n,i);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){const i=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(n=>n[i]===e).forEach(n=>n.value=t)}getBool(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??!1}setFloat(e,t){const i=typeof e=="string"?"name":"hash",n=this.model?.parameters?.filter(o=>o[i]===e);return n.forEach(o=>o.value=t),n?.length>0}getFloat(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??0}setInteger(e,t){const i=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(n=>n[i]===e).forEach(n=>n.value=t)}getInteger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??0}setTrigger(e){qe&&console.log("SET TRIGGER",e);const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(i=>i[t]===e).forEach(i=>i.value=!0)}resetTrigger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(i=>i[t]===e).forEach(i=>i.value=!1)}getTrigger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}_speed=1;FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const t of this.model.layers)for(const i of t.stateMachine.states)if(i.name===e||i.hash==e)return i}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,i=t<=0?0:Math.abs(e.time/t);return new wl(this._activeState,i,t,this._speed)}get currentAction(){if(!this._activeState)return null;const e=this._activeState.motion.action;return e||null}normalizedStartOffset=0;animator;model;get context(){return this.animator?.context}get mixer(){return this._mixer}dispose(){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)}this.context?.animations.unregisterAnimationMixer(this._mixer)}bind(e){e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),this.context?.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new c.AnimationMixer(this.animator.gameObject),this.context?.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;qe&&console.warn("AnimatorController clone()",this.model);const e=pc(this.model,(i,n,o)=>o==null?!0:!(o.type==="Object3D"||o.isObject3D===!0||Ib(o)||o.tracks!==void 0||o instanceof Di));return console.assert(e!==this.model),new Di(e)}update(e){if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const t=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&this.rootMotionHandler?.onBeforeUpdate(e),this._mixer.update(t),this.animator.applyRootMotion&&this.rootMotionHandler?.onAfterUpdate(e)}_mixer;_activeState;get activeState(){return this._activeState}constructor(e){this.model=e,qe&&console.log(this)}_activeStates=[];updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const i=this._activeStates[t],n=i.motion;if(!n.action)this._activeStates.splice(t,1),t--;else{const o=n.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(qe&&console.debug("REMOVE",i.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){this.model.layers.length>1&&(qe||A())&&console.warn("Multiple layers are not supported yet "+this.animator?.name);for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(qe&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const i=t.states[t.defaultState];this.transitionTo(i,0,this.normalizedStartOffset);break}}evaluateTransitions(){let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const t=this._activeState,i=t.motion.action;for(const o of t.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let r=!0;for(const a of o.conditions)if(!this.evaluateCondition(a)){r=!1;break}if(r)if(i){const a=t.motion.clip.duration,l=a<=0?1:Math.abs(i.time/a);let h=o.exitTime;i.timeScale<0&&(h=1-h);let d=!1;if(o.hasExitTime?i.timeScale>0?d=l>=o.exitTime:i.timeScale<0&&(d=1-l>=o.exitTime):d=!0,d){for(const u of o.conditions){const p=this.model.parameters.find(m=>m.name===u.parameter);p?.type===$m.Trigger&&p.value&&(p.value=!1)}if(i.clampWhenFinished=!0,qe){const u=this.getState(o.destinationState,0);console.log(`Transition to ${o.destinationState} / ${u?.name}`,o,`
|
|
879
|
+
`,n=`Needle Engine — No license active, commercial use is not allowed. Visit https://needle.tools/pricing for more information and licensing options! v${Ji}`;z.Current?.xr?console.log(n):console.log("%c "+n,t)}async function P1(s){if(window.crossOriginIsolated)return;const e=Tn;if(e==="pro"||e==="enterprise"){const t=s?.domElement?.getAttribute("no-telemetry");if(t===""||t==="true"||t==="1"){ai&&console.debug("Telemetry is disabled");return}ai&&console.debug("Telemetry attribute: "+t)}try{const t="https://needle-engine-analytics-v2-r26roub2hq-lz.a.run.app";if(t){const i=window.location.href.split("?")[0];let n="api/v2/new/request";t.endsWith("/")||(n="/"+n);const o=Tn,r=`${t}${n}`;ai&&console.debug("Sending beacon");const a={license:o,url:i,hostname:window.location.hostname,pathname:window.location.pathname,version:Ji,generator:Xd,build_time:ym,public_key:Yr},l=navigator.sendBeacon?.(r,JSON.stringify(a));ai&&console.debug("Sent beacon: "+l)}}catch(t){ai&&console.log("Failed to send non-commercial usage message to analytics backend",t)}}function rv(s,e){return ds(s,re.ContextCreated,e),()=>oo(s,re.ContextCreated)}function O1(s,e){return ds(s,re.ContextClearing,e),()=>oo(s,re.ContextClearing)}function M1(s,e){return ds(s,re.ContextDestroying,e),()=>oo(s,re.ContextDestroying)}function ru(s,e){return ds(s,pe.Start,e),()=>oo(s,pe.Start)}function av(s,e){return ds(s,pe.Update,e),()=>oo(s,pe.Update)}function k1(s,e){return ds(s,pe.OnBeforeRender,e),()=>oo(s,pe.OnBeforeRender)}function E1(s,e){return ds(s,pe.OnAfterRender,e),()=>oo(s,pe.OnAfterRender)}const R1=w("debugdecoders");let wf=null;function lv(){if(!wf){const s=ne.createLoaders(null);wf={dracoLoader:s.dracoLoader,ktx2Loader:s.ktx2Loader,meshoptDecoder:s.meshoptDecoder}}return wf}function f_(s){s!==void 0&&typeof s=="string"&&ne.setDracoDecoderLocation(s)}function p_(s){if(s!==void 0&&typeof s=="string"&&s!=="js"){const e=lv();R1&&console.log("Setting draco decoder type to",s),e.dracoLoader.setDecoderConfig({type:s})}}function m_(s){s!==void 0&&typeof s=="string"&&ne.setKTX2TranscoderLocation(s)}function Vm(s,e){const t=lv();return e.renderer?t.ktx2Loader.detectSupport(e.renderer):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail"),ne.addDracoAndKTX2Loaders(s),s.dracoLoader||s.setDRACOLoader(t.dracoLoader),s.ktx2Loader||s.setKTX2Loader(t.ktx2Loader),s.meshoptDecoder||s.setMeshoptDecoder(t.meshoptDecoder),ne.configureLoader(s,{progressive:!0}),s}const $e=function(s){return f(s)},f=function(s){if(s===void 0&&(s=null),!Array.isArray(s))s=g_(s);else for(let e=0;e<s.length;e++){const t=s[e];s[e]=g_(t)}return function(e,t){if(!e){const n=typeof t=="string"?t:t.name;console.warn(`@serializable without a target at '${n}'.`);return}typeof t!="string"&&(t=t.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const i=e.$serializedTypes=e.$serializedTypes||{};i[t]=s}};function g_(s){switch(s?.prototype?.constructor?.name){case"Number":case"String":case"Boolean":return null}return s}const qs=w("debughotreload");let ec=!1;const zl=new Map;function T1(){return ec}function Dp(){return globalThis.NEEDLE_HOT_RELOAD_ENABLED===!0}function cv(s){if(ec){qs&&console.warn("[Needle Engine] Hot reloading is in progress, not registering instance",s);return}qs&&console.log("[Needle Engine] Registering hot reload instance",s);const t=s.constructor.name;zl.has(t)?zl.get(t)?.push(s):zl.set(t,[s])}function hv(s){if(ec){qs&&console.warn("[Needle Engine] Hot reloading is in progress, not unregistering instance",s);return}qs&&console.log("[Needle Engine] Unregistering hot reload instance",s);const t=s.constructor.name,i=zl.get(t);if(!i)return;const n=i.indexOf(s);n!==-1&&i.splice(n,1)}let y_=!1;function A1(){if(qs||y_)return;y_=!0;const s=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}s.apply(console,e)}}function L1(s){qs&&console.log("[HMR] Apply changes",s,Object.keys(s)),A1();for(const e of Object.keys(s))try{ec=!0;const t=P.get(e);if(!t){qs&&console.log("[HMR] Type not found: "+e);continue}const i=s[e],n=zl.get(i.name);let o="[Needle Engine] Updating type: "+e;const r=n?.length??-1;r>0?o+=" x"+r:o+=" (No instances registered)",console.log(o);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(i.prototype);for(const h in l)l[h].writable&&(t.prototype[h]=s[e].prototype[h]);for(const h of a)l[h]||delete t.prototype[h];if(n){const h=new i,d=Object.getOwnPropertyDescriptors(h);for(const u of n){const p=u,m=p.isComponent===!0,y=m?p.activeAndEnabled:!0,_=m?p.context:void 0;try{if(m&&_&&es(p,_),m&&y&&(p.enabled=!1),u.onBeforeHotReloadFields&&u.onBeforeHotReloadFields()===!1)continue;for(const g in d)if(d[g].writable){if(u[g]===void 0)u[g]=h[g];else if(typeof u[g]=="function"&&!u[g].prototype){const b=u[g],x=b.name,R="bound ";if(x===R)continue;const O=b.name.substring(R.length),M=i.prototype[O];M&&(u[g]=M.bind(u))}}u.onAfterHotReloadFields&&u.onAfterHotReloadFields()}finally{m&&_&&Rm(p,_),m&&y&&(p.enabled=!0)}}}}catch(t){if(qs)console.error(t);else return!1}finally{ec=!1,Do(ci.Log,"Script changes applied (HMR)")}return!0}class S extends c.Object3D{guid;static isDestroyed(e){return Ko(e)}static setActive(e,t,i=!0){e&&(Fl(e,t),Kh(e),t&&i&&m0(z.Current,e))}static isActiveSelf(e){return Pa(e)}static isActiveInHierarchy(e){return F0(e)}static markAsInstancedRendered(e,t){U0(e,t)}static isUsingInstancing(e){return iu(e)}static foreachComponent(e,t,i=!0){return Zo(e,t,i)}static instantiateSynced(e,t){return e?Am(e,t):null}static instantiate(e,t=null){return"isAssetReference"in e,Jo(e,t)}static destroySynced(e,t,i=!0){if(!e)return;const n=e;t=t??z.Current,bc(n,t.connection,i)}static destroy(e,t=!0){return ui(e,t)}static add(e,t,i){if(!(!e||!t)){if(e===t){console.warn("Can not add object to self",e);return}i||(i=z.Current),t.add(e),Fl(e,!0),Kh(e),i?S.foreachComponent(e,n=>{Rm(n,i),!n.__internalDidAwakeAndStart&&i.new_script_start.includes(n)===!1&&i.new_script_start.push(n)},!0):console.warn("Missing context")}}static remove(e){e&&(e.parent?.remove(e),Fl(e,!1),Kh(e),S.foreachComponent(e,t=>{mC(t)},!0))}static invokeOnChildren(e,t,...i){this.invoke(e,t,!0,i)}static invoke(e,t,i=!1,...n){e&&this.foreachComponent(e,o=>{const r=o[t];r&&typeof r=="function"&&r?.call(o,...n)},i)}static addNewComponent(e,t,i,n=!0){return en(e,t,i,{callAwake:n})}static addComponent(e,t,i,n){return en(e,t,i,n)}static moveComponent(e,t){return en(e,t)}static removeComponent(e){return Bm(e.gameObject,e),e}static getOrAddComponent(e,t){return wc(e,t)}static getComponent(e,t){return e===null?null:cr(e,t)}static getComponents(e,t,i=null){return e===null?i??[]:xc(e,t,i)}static findByGuid(e,t){return Fm(e,t)}static findObjectOfType(e,t,i=!0){return Ca(e,t??z.Current,i)}static findObjectsOfType(e,t){const i=[];return B0(e,i,t),i}static getComponentInChildren(e,t){return Sc(e,t)}static getComponentsInChildren(e,t,i=null){return Sa(e,t,i??void 0)}static getComponentInParent(e,t){return Jl(e,t)}static getComponentsInParent(e,t,i=null){return eu(e,t,i)}static getAllComponents(e){const t=e.userData?.components;return t?[...t]:[]}static*iterateComponents(e){const t=e?.userData?.components;if(t&&Array.isArray(t))for(let i=0;i<t.length;i++)yield t[i]}}class k{get isComponent(){return!0}__context;get context(){return this.__context??z.Current}set context(e){this.__context=e}get scene(){return this.context.scene}get layer(){return this.gameObject?.userData?.layer}get name(){return this.gameObject?.name?this.gameObject.name:this.gameObject?.userData.name}__name;set name(e){this.gameObject?(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.name=e,this.__name=e):this.__name=e}get tag(){return this.gameObject?.userData.tag}set tag(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.tag=e)}get static(){return this.gameObject?.userData.static}set static(e){this.gameObject&&(this.gameObject.userData||(this.gameObject.userData={}),this.gameObject.userData.static=e)}get activeAndEnabled(){return!(this.destroyed||this.__isEnabled===!1||!this.__isActiveInHierarchy)}get __isActive(){return this.gameObject.visible}get __isActiveInHierarchy(){if(!this.gameObject)return!1;const e=this.gameObject[ls];return e===void 0?!0:e}set __isActiveInHierarchy(e){this.gameObject&&(this.gameObject[ls]=e)}gameObject;guid="invalid";sourceId;awake(){}onEnable(){}onDisable(){}onDestroy(){this.__destroyed=!0}startCoroutine(e,t=pe.Update){return this.context.registerCoroutineUpdate(this,e,t)}stopCoroutine(e,t=pe.Update){this.context.unregisterCoroutineUpdate(e,t)}get destroyed(){return this.__destroyed}destroy(){this.__destroyed||this.__internalDestroy()}__didAwake=!1;__didStart=!1;__didEnable=!1;__isEnabled=void 0;__destroyed=!1;get __internalDidAwakeAndStart(){return this.__didAwake&&this.__didStart}constructor(e){this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),Dp()&&cv(this)}__internalNewInstanceCreated(e){return this.__didAwake=!1,this.__didStart=!1,this.__didEnable=!1,this.__isEnabled=void 0,this.__destroyed=!1,this._internalInit(e),this}_internalInit(e){if(typeof e=="object")for(const t of Object.keys(e)){const i=e[t];typeof i!="function"&&(this[t]=i)}}__internalAwake(){this.__didAwake||(this.__didAwake=!0,this.awake())}__internalStart(){this.__didStart||(this.__didStart=!0,this.start&&this.start())}__internalEnable(e){return this.__destroyed?(A()&&console.warn("[Needle Engine Dev] Trying to enable destroyed component"),!1):this.__didAwake?this.__didEnable?(e!==!0&&(this.__isEnabled=!0),!1):(this.__didEnable=!0,this.__isEnabled=!0,this.onEnable(),!0):!1}__internalDisable(e){if(this.__didAwake){if(!this.__didEnable){e!==!0&&(this.__isEnabled=!1);return}this.__didEnable=!1,this.__isEnabled=!1,this.onDisable()}}__internalDestroy(){this.__destroyed||(this.__destroyed=!0,this.__didAwake&&(this.onDestroy?.call(this),this.dispatchEvent(new CustomEvent("destroyed",{detail:this}))),I0(this),Dp()&&hv(this))}get enabled(){return typeof this.__isEnabled=="boolean"?this.__isEnabled:!0}set enabled(e){if(this.__destroyed){A()&&console.warn(`[Needle Engine Dev] Trying to ${e?"enable":"disable"} destroyed component`);return}if(typeof e=="number"&&(e>=.5?e=!0:e=!1),!this.__didAwake){this.__isEnabled=e;return}e?this.__internalEnable():this.__internalDisable()}get worldPosition(){return X(this.gameObject)}set worldPosition(e){ot(this.gameObject,e)}setWorldPosition(e,t,i){Qo(this.gameObject,e,t,i)}get worldQuaternion(){return ue(this.gameObject)}set worldQuaternion(e){tn(this.gameObject,e)}setWorldQuaternion(e,t,i,n){dm(this.gameObject,e,t,i,n)}get worldEuler(){return um(this.gameObject)}set worldEuler(e){fm(this.gameObject,e)}get worldRotation(){return this.gameObject.worldRotation}set worldRotation(e){this.setWorldRotation(e.x,e.y,e.z,!0)}setWorldRotation(e,t,i,n=!0){yc(this.gameObject,e,t,i,n)}static _forward=new c.Vector3;get forward(){return k._forward.set(0,0,-1).applyQuaternion(this.worldQuaternion)}static _right=new c.Vector3;get right(){return k._right.set(1,0,0).applyQuaternion(this.worldQuaternion)}static _up=new c.Vector3;get up(){return k._up.set(0,1,0).applyQuaternion(this.worldQuaternion)}_eventListeners=new Map;addEventListener(e,t){this._eventListeners[e]=this._eventListeners[e]||[],this._eventListeners[e].push(t)}removeEventListener(e,t){if(!this._eventListeners[e])return;const i=this._eventListeners[e].indexOf(t);i>=0&&this._eventListeners[e].splice(i,1)}dispatchEvent(e){if(!e||!this._eventListeners[e.type])return!1;const t=this._eventListeners[e.type];for(let i=0;i<t.length;i++)t[i](e);return!1}}const D1=Object.freeze(Object.defineProperty({__proto__:null,Behaviour:k,Component:k,GameObject:S},Symbol.toStringTag,{value:"Module"}));var I1=Object.defineProperty,dv=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&I1(e,t,n),n};class Oc extends k{from;to;width=0;centered=!0;_centerPos;awake(){this._centerPos=new c.Vector3}update(){if(!this.from||!this.to)return;const e=X(this.from).clone(),t=X(this.to).clone(),i=e.distanceTo(t);this._centerPos.copy(e),this._centerPos.add(t),this._centerPos.multiplyScalar(.5),ot(this.gameObject,this.centered?this._centerPos:e),this.gameObject.lookAt(X(this.to).clone()),this.gameObject.scale.set(this.width,this.width,i)}}dv([f(S)],Oc.prototype,"from");dv([f(S)],Oc.prototype,"to");var j1=Object.defineProperty,B1=Object.getOwnPropertyDescriptor,hr=(s,e,t,i)=>{for(var n=i>1?void 0:i?B1(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&j1(e,t,n),n};const ks=w("debuganimation");let uv=class{x;y};class St extends k{get isAnimationComponent(){return!0}addClip(e){this.animations||(this.animations=[]),this.animations.includes(e)||this.animations.push(e)}playAutomatically=!0;randomStartTime=!0;minMaxSpeed;minMaxOffsetNormalized;loop=!0;clampWhenFinished=!1;get time(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.time}return 0}set time(e){if(this.actions)for(const t of this.actions)t.time=e}get duration(){if(this.actions){for(const e of this.actions)if(e.isRunning())return e.getClip().duration}return 0}_tempAnimationClipBeforeGameObjectExisted=null;get clip(){return this.animations?.length?this.animations[0]:null}set clip(e){if(!this.__didAwake){ks&&console.warn("Assign clip during serialization",e),this._tempAnimationClipBeforeGameObjectExisted=e;return}e&&(this.gameObject.animations||(this.gameObject.animations=[]),!this.animations.includes(e)&&(this.animations.length>0?this.animations.splice(0,0,e):this.animations.push(e)))}set clips(e){this.animations=e}_tempAnimationsArray;set animations(e){e==null||!Array.isArray(e)||(this.gameObject?this.gameObject.animations=e:this._tempAnimationsArray=e)}get animations(){return this.gameObject?.animations||this._tempAnimationsArray||[]}mixer=void 0;get actions(){return this._actions}set actions(e){this._actions=e}_actions;_handles;awake(){this.mixer=void 0,ks&&console.log("Animation Awake",this.name,this),this._tempAnimationsArray&&(this.animations=this._tempAnimationsArray,this._tempAnimationsArray=void 0),this._tempAnimationClipBeforeGameObjectExisted&&(this.clip=this._tempAnimationClipBeforeGameObjectExisted,this._tempAnimationClipBeforeGameObjectExisted=null),this.actions=[],this._handles=[]}onEnable(){if(this.playAutomatically&&this.animations?.length>0){const e=Math.floor(Math.random()*this.animations.length),t=this.animations[e];this.play(e,{exclusive:!0,fadeDuration:0,startTime:this.randomStartTime?Math.random()*t.duration:0,loop:this.loop,clampWhenFinished:this.clampWhenFinished})}}update(){this.mixer&&(this.mixer.update(this.context.time.deltaTime),this._handles.forEach(e=>e.update()))}onDisable(){this.mixer&&this.mixer.stopAllAction()}onDestroy(){this.context.animations.unregisterAnimationMixer(this.mixer)}getAction(e){return this.actions?.find(t=>t.getClip().name===e)||null}get isPlaying(){if(this.actions){for(let e=0;e<this.actions.length;e++)if(this.actions[e].isRunning())return!0}return!1}stopAll(e){if(this.actions)for(const t of this.actions)e?.fadeDuration?t.fadeOut(e.fadeDuration):t.stop()}stop(e,t){if(e===void 0){this.stopAll();return}else if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(n=>n.name===e));if(!e){console.error("Could not find clip",e);return}const i=this.actions.find(n=>n.getClip()===e);if(!i){console.error("Could not find action",e);return}t?.fadeDuration?i.fadeOut(t.fadeDuration):i.stop()}pause(e,t=!1){if(e===void 0){for(const n of this.actions)n.paused=!t;return}else if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}e=this.animations[e]}else typeof e=="string"&&(e=this.animations.find(n=>n.name===e));if(!e){console.error("Could not find clip",e);return}const i=this.actions.find(n=>n.getClip()===e);if(!i){console.error("Could not find action",e);return}i.paused=!t}resume(){for(const e of this.actions)e.paused=!1}play(e=0,t){if(ks&&console.log("PLAY",e),this.ensureMixer(),!this.mixer){ks&&console.warn("Missing mixer",this);return}e===void 0&&(e=0);let i=e;if(typeof e=="number"){if(e>=this.animations.length){ks&&console.log("No animation at index",e);return}i=this.animations[e]}else typeof e=="string"&&(i=this.animations.find(o=>o.name===e));if(!i){console.error("Could not find clip",e);return}t||(t={});for(const o of this.actions)if(o.getClip()===i)return this.internalOnPlay(o,t);if(!i.tracks){console.warn("Clip is no AnimationClip",i);return}const n=this.mixer.clipAction(i);return this.actions.push(n),this.internalOnPlay(n,t)}internalOnPlay(e,t){var i=this.actions.find(r=>r===e);if(i===e&&i.isRunning()&&i.time<i.getClip().duration){const r=this.tryFindHandle(e);if(i.paused&&(i.paused=!1),r)return r.waitForFinish()}if(t.loop===void 0&&(t.loop=this.loop),t.clampWhenFinished===void 0&&(t.clampWhenFinished=this.clampWhenFinished),t.minMaxOffsetNormalized===void 0&&this.randomStartTime&&(t.minMaxOffsetNormalized=this.minMaxOffsetNormalized),t.minMaxSpeed===void 0&&(t.minMaxSpeed=this.minMaxSpeed),t?.exclusive??!0)for(const r of this.actions)r!=i&&(t.fadeDuration?r.fadeOut(t.fadeDuration):r.stop());if(t?.fadeDuration&&e.fadeIn(t.fadeDuration),e.enabled=!0,t?.startTime!=null)e.time=t.startTime;else if(t?.minMaxOffsetNormalized&&t.minMaxOffsetNormalized.x!=0&&t.minMaxOffsetNormalized.y!=0){const r=e.getClip();e.time=D.lerp(t.minMaxOffsetNormalized.x,t.minMaxOffsetNormalized.y,Math.random())*r.duration}else e.time>=e.getClip().duration&&(e.time=0);t?.minMaxSpeed?e.timeScale=D.lerp(t.minMaxSpeed.x,t.minMaxSpeed.y,Math.random()):e.timeScale=t?.speed??1,t?.loop!=null?e.loop=t.loop?c.LoopRepeat:c.LoopOnce:e.loop=c.LoopOnce,t?.clampWhenFinished&&(e.clampWhenFinished=!0),e.paused=!1,e.play(),ks&&console.log("PLAY",e.getClip().name,e);const o=new F1(e,this.mixer,t,r=>{this._handles.splice(this._handles.indexOf(o),1)});return this._handles.push(o),o.waitForFinish()}tryFindHandle(e){for(const t of this._handles)if(t.action===e)return t}ensureMixer(){if(!this.mixer){const e="animationMixer";this.gameObject[e]&&(this.mixer=this.gameObject[e]),(!this.mixer||!this.mixer.clipAction)&&(this.mixer=new c.AnimationMixer(this.gameObject),this.gameObject[e]=this.mixer)}this.context.animations.registerAnimationMixer(this.mixer)}}hr([f()],St.prototype,"playAutomatically",2);hr([f()],St.prototype,"randomStartTime",2);hr([f(uv)],St.prototype,"minMaxSpeed",2);hr([f(uv)],St.prototype,"minMaxOffsetNormalized",2);hr([f()],St.prototype,"loop",2);hr([f()],St.prototype,"clampWhenFinished",2);hr([f(c.AnimationClip)],St.prototype,"clips",1);class F1{mixer;action;promise=null;_options;_resolveCallback=null;_resolvedOrRejectedCallback;constructor(e,t,i,n){this.action=e,this.mixer=t,this._resolvedOrRejectedCallback=n,this._options=i}waitForFinish(){return this.promise?this.promise:(this.promise=new Promise(e=>{this._resolveCallback=e}),this.mixer.addEventListener("finished",this.onFinished),this.promise)}update(){this._options&&this._options.endTime!==void 0&&this.action.time>this._options.endTime&&(this._options.loop===!0?this.action.time=this._options.startTime??0:(this.action.time=this._options.endTime,this.action.timeScale=0,this.onResolve()))}onResolve(){this.dispose(),this._resolvedOrRejectedCallback?.call(this,this),this._resolveCallback?.call(this,this.action)}onFinished=e=>{e.action===this.action&&this.onResolve()};dispose(){this.mixer.removeEventListener("finished",this.onFinished)}}const nd=Symbol("objectIsAnimatedData");function __(s,e,t){if(!s)return;if(s[nd]===void 0){if(!t)return;s[nd]=new Set}const i=s[nd];t?i.add(e):i.has(e)&&i.delete(e)}function U1(s){if(!s)return!1;const e=s[nd];return e!==void 0&&e.size>0}class z1{_context;get context(){return this._context??z.Current}get isStateMachineBehaviour(){return!0}}class wl{name;nameHash;normalizedTime;length;speed;action;hasTransitions;constructor(e,t,i,n){this.name=e.name,this.nameHash=e.hash,this.normalizedTime=t,this.length=i,this.speed=n,this.action=e.motion.action||null,this.hasTransitions=e.transitions?.length>0||!1}}function fv(s,e){return{name:"Empty",isLooping:!1,guid:e?.generateUUID()??c.MathUtils.generateUUID(),index:-1,clip:new c.AnimationClip(s,0,[])}}var Us=(s=>(s[s.If=1]="If",s[s.IfNot=2]="IfNot",s[s.Greater=3]="Greater",s[s.Less=4]="Less",s[s.Equals=6]="Equals",s[s.NotEqual=7]="NotEqual",s))(Us||{}),$m=(s=>(s[s.Float=1]="Float",s[s.Int=3]="Int",s[s.Bool=4]="Bool",s[s.Trigger=9]="Trigger",s))($m||{});const qe=w("debuganimatorcontroller"),Ph=w("debugrootmotion");class Di{static createFromClips(e,t={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let r=0;r<e.length;r++){const a=e[r],l=[];if(t.autoTransition!==!1){const d=t.transitionDuration??0,u=d/a.duration;let p=r;(t.autoTransition===void 0||t.autoTransition===!0)&&(p=(r+1)%e.length),l.push({exitTime:1-u,offset:0,duration:d,hasExitTime:!0,destinationState:p,conditions:[]})}const h={name:a.name,hash:r,motion:{name:a.name,clip:a,isLooping:t?.looping??!1},transitions:l,behaviours:[]};i.push(h)}const n={name:"AnimatorController",guid:new mt(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new Di(n)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){if(t<0)t=0;else if(t>=this.model.layers.length){console.warn("invalid layer");return}const r=this.model.layers[t].stateMachine;for(const a of r.states)if(a.name===e||a.hash===e){qe&&console.log("transition to ",a),this.transitionTo(a,n,i);return}console.warn("Could not find "+e+" to play")}reset(){this.setStartTransition()}setBool(e,t){const i=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(n=>n[i]===e).forEach(n=>n.value=t)}getBool(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??!1}setFloat(e,t){const i=typeof e=="string"?"name":"hash",n=this.model?.parameters?.filter(o=>o[i]===e);return n.forEach(o=>o.value=t),n?.length>0}getFloat(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??0}setInteger(e,t){const i=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(n=>n[i]===e).forEach(n=>n.value=t)}getInteger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??0}setTrigger(e){qe&&console.log("SET TRIGGER",e);const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(i=>i[t]===e).forEach(i=>i.value=!0)}resetTrigger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.filter(i=>i[t]===e).forEach(i=>i.value=!1)}getTrigger(e){const t=typeof e=="string"?"name":"hash";return this.model?.parameters?.find(i=>i[t]===e)?.value??!1}isInTransition(){return this._activeStates.length>1}setSpeed(e){this._speed=e}_speed=1;FindState(e){return this.findState(e)}findState(e){if(!e)return null;if(Array.isArray(this.model.layers)){for(const t of this.model.layers)for(const i of t.stateMachine.states)if(i.name===e||i.hash==e)return i}return null}getCurrentStateInfo(){if(!this._activeState)return null;const e=this._activeState.motion.action;if(!e)return null;const t=this._activeState.motion.clip.duration,i=t<=0?0:Math.abs(e.time/t);return new wl(this._activeState,i,t,this._speed)}get currentAction(){if(!this._activeState)return null;const e=this._activeState.motion.action;return e||null}normalizedStartOffset=0;animator;model;get context(){return this.animator?.context}get mixer(){return this._mixer}dispose(){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)}this.context?.animations.unregisterAnimationMixer(this._mixer)}bind(e){e?this.animator!==e&&(this._mixer&&(this._mixer.stopAllAction(),this.context?.animations.unregisterAnimationMixer(this._mixer)),this.animator=e,this._mixer=new c.AnimationMixer(this.animator.gameObject),this.context?.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;qe&&console.warn("AnimatorController clone()",this.model);const e=pc(this.model,(i,n,o)=>o==null?!0:!(o.type==="Object3D"||o.isObject3D===!0||Ib(o)||o.tracks!==void 0||o instanceof Di));return console.assert(e!==this.model),new Di(e)}update(e){if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(e);const t=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&this.rootMotionHandler?.onBeforeUpdate(e),this._mixer.update(t),this.animator.applyRootMotion&&this.rootMotionHandler?.onAfterUpdate(e)}_mixer;_activeState;get activeState(){return this._activeState}constructor(e){this.model=e,qe&&console.log(this)}_activeStates=[];updateActiveStates(e){for(let t=0;t<this._activeStates.length;t++){const i=this._activeStates[t],n=i.motion;if(!n.action)this._activeStates.splice(t,1),t--;else{const o=n.action;o.weight=e,o.getEffectiveWeight()<=0&&!o.isRunning()&&(qe&&console.debug("REMOVE",i.name,o.getEffectiveWeight(),o.isRunning(),o.isScheduled()),this._activeStates.splice(t,1),t--)}}}setStartTransition(){this.model.layers.length>1&&(qe||A())&&console.warn("Multiple layers are not supported yet "+this.animator?.name);for(const e of this.model.layers){const t=e.stateMachine;t.defaultState===void 0&&(qe&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",e),t.defaultState=0);const i=t.states[t.defaultState];this.transitionTo(i,0,this.normalizedStartOffset);break}}evaluateTransitions(){let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const t=this._activeState,i=t.motion.action;for(const o of t.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let r=!0;for(const a of o.conditions)if(!this.evaluateCondition(a)){r=!1;break}if(r)if(i){const a=t.motion.clip.duration,l=a<=0?1:Math.abs(i.time/a);let h=o.exitTime;i.timeScale<0&&(h=1-h);let d=!1;if(o.hasExitTime?i.timeScale>0?d=l>=o.exitTime:i.timeScale<0&&(d=1-l>=o.exitTime):d=!0,d){for(const u of o.conditions){const p=this.model.parameters.find(m=>m.name===u.parameter);p?.type===$m.Trigger&&p.value&&(p.value=!1)}if(i.clampWhenFinished=!0,qe){const u=this.getState(o.destinationState,0);console.log(`Transition to ${o.destinationState} / ${u?.name}`,o,`
|
|
880
880
|
Timescale: `+i.timeScale,`
|
|
881
881
|
Normalized time: `+l.toFixed(3),`
|
|
882
882
|
Exit Time: `+h,o.hasExitTime)}this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}i&&this.setTimescale(i,t);let n=!1;if(t.motion.isLooping&&i&&(i.time>=i.getClip().duration?(n=!0,i.reset(),i.time=0,i.play()):i.time<=0&&i.timeScale<0&&(n=!0,i.reset(),i.time=i.getClip().duration,i.play())),!n&&t&&!e&&i&&this.animator&&t.behaviours){const o=i?.getClip().duration,r=i.time/o,a=new wl(this._activeState,r,o,this._speed);for(const l of t.behaviours)l.instance&&l.instance.onStateUpdate?.call(l.instance,this.animator,a,0)}}setTimescale(e,t){let i=t.speed??1;t.speedParameter&&(i*=this.getFloat(t.speedParameter)),i!==void 0&&(e.timeScale=i*this._speed)}getState(e,t){return typeof e=="number"&&(e==-1&&(e=this.model.layers[t].stateMachine.defaultState,e===void 0&&(qe&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+t),e=0)),e=this.model.layers[t].stateMachine.states[e]),e}_heldActions=[];releaseHeldActions(e){for(const t of this._heldActions)t.fadeOut(e);this._heldActions.length=0}transitionTo(e,t,i){if(!this.animator)return;const n=0;if(e=this.getState(e,n),!e?.motion||!e.motion.clip||!(e.motion.clip instanceof c.AnimationClip))return;const o=this._activeState===e;if(o){const d=e.motion;if(!d.action_loopback&&d.clip){const u=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(d.clip,this.animator.gameObject),u&&u.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),d.action_loopback=this.createAction(d.clip)}}if(this._activeState?.behaviours&&this._activeState.motion.action){const d=this._activeState?.motion.clip.duration,u=this._activeState.motion.action.time/d,p=new wl(this._activeState,u,d,this._speed);for(const m of this._activeState.behaviours)m.instance?.onStateExit?.call(m.instance,this.animator,p,n)}const r=this._activeState?.motion.action;o&&(e.motion.action=e.motion.action_loopback,e.motion.action_loopback=r);const a=this._activeState;this._activeState=e;const l=e.motion?.action,h=e.motion.clip;if(h?.duration<=0&&h.tracks.length<=0?r&&this._heldActions.push(r):r&&(r.fadeOut(t),this.releaseHeldActions(t)),l){if(i=Math.max(0,Math.min(1,i)),e.cycleOffsetParameter){let u=this.getFloat(e.cycleOffsetParameter);typeof u=="number"?(u<0&&(u+=1),i+=u,i%=1):qe&&console.warn("AnimatorController cycle offset parameter is not a number",e.cycleOffsetParameter)}else typeof e.cycleOffset=="number"&&(i+=e.cycleOffset,i%=1);l.isRunning()&&l.stop(),l.reset(),l.enabled=!0,this.setTimescale(l,e);const d=e.motion.clip.duration;if(l.time=o?0:i*d,l.timeScale<0&&(l.time=d-l.time),l.clampWhenFinished=!0,l.setLoop(c.LoopOnce,0),t>0?l.fadeIn(t):l.weight=1,l.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(l),this._activeStates.includes(e)||this._activeStates.push(e),this._activeState.behaviours){const u=new wl(e,i,d,this._speed);for(const p of this._activeState.behaviours)p.instance?.onStateEnter?.call(p.instance,this.animator,u,n)}}else qe&&(e.__warned_no_motion||(e.__warned_no_motion=!0,console.warn("No action",e.motion,this)));qe&&console.log("TRANSITION FROM "+a?.name+" TO "+e.name,t,r,l,l?.getEffectiveTimeScale(),l?.getEffectiveWeight(),l?.isRunning(),l?.isScheduled(),l?.paused)}createAction(e){if(this._mixer.existingAction(e)&&this._mixer.uncacheAction(e,this.animator?.gameObject),this.animator?.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new N1(this));const i=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,i,e)}else return this._mixer.clipAction(e)}evaluateCondition(e){const t=this.model.parameters.find(i=>i.name===e.parameter);if(!t)return!1;switch(e.mode){case Us.If:return t.value===!0;case Us.IfNot:return t.value===!1;case Us.Greater:return t.value>e.threshold;case Us.Less:return t.value<e.threshold;case Us.Equals:return t.value===e.threshold;case Us.NotEqual:return t.value!==e.threshold}return!1}createActions(e){qe&&console.log("AnimatorController createActions",this.model);for(const t of this.model.layers){const i=t.stateMachine;for(let n=0;n<i.states.length;n++){const o=i.states[n];o.transitions||(o.transitions=[]);for(const r of o.transitions)r.conditions||(r.conditions=[]);if(o.motion||(qe&&console.warn("No motion",o),o.motion=fv(o.name)),this.animator&&o.motion.clips){const r=o.motion.clips?.find(a=>a.node.name===this.animator?.gameObject?.name);r?o.motion.clip=r.clip:(qe||A())&&console.warn('Could not find clip for animator "'+this.animator?.gameObject?.name+'"',o.motion.clips.map(a=>a.node.name))}if(!o.motion.clip){qe&&console.warn("No clip assigned to state",o);const r=new c.AnimationClip(void 0,void 0,[]);o.motion.clip=r}if(o.motion?.clip){const r=o.motion.clip;if(r instanceof c.AnimationClip){const a=this.createAction(r);o.motion.action=a}else(qe||A())&&console.warn("No valid animationclip assigned",o)}if(o.behaviours&&Array.isArray(o.behaviours))for(const r of o.behaviours){if(!r?.typeName)continue;const a=P.get(r.typeName);if(a){const l=new a;l.isStateMachineBehaviour&&(l._context=this.context??void 0,ya(l,r.properties),r.instance=l),qe&&console.log("Created animator controller behaviour",o.name,r.typeName,r.properties,l)}else(qe||A())&&console.warn("Could not find AnimatorBehaviour type: "+r.typeName)}}}}*enumerateActions(){if(this.model.layers)for(const e of this.model.layers){const t=e.stateMachine;for(let i=0;i<t.states.length;i++){const n=t.states[i];n?.motion&&(n.motion.action&&(yield n.motion.action),n.motion.action_loopback&&(yield n.motion.action_loopback))}}}rootMotionHandler}class b_{track;createdInterpolant;originalEvaluate;customEvaluate;constructor(e,t){this.track=e;const i=e,n=i.createInterpolant.bind(e);i.createInterpolant=()=>(i.createInterpolant=n,this.createdInterpolant=n(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=o=>{if(!this.originalEvaluate)return;const r=this.originalEvaluate(o);return t(o,r)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}class Ye{static lastObjPosition={};static lastObjRotation={};static firstKeyframeRotation={};static spaceRotation={};static effectiveSpaceRotation={};static clipOffsetRotation={};set action(e){this._action=e}get action(){return this._action}get cacheId(){return this.root.uuid}_action;root;clip;positionWrapper=null;rotationWrapper=null;context;positionChange=new c.Vector3;rotationChange=new c.Quaternion;constructor(e,t,i,n,o){if(this.context=e,this.root=t,this.clip=i,Ye.firstKeyframeRotation[this.cacheId]||(Ye.firstKeyframeRotation[this.cacheId]=new c.Quaternion),o){const r=o.values;Ye.firstKeyframeRotation[this.cacheId].set(r[0],r[1],r[2],r[3])}Ye.spaceRotation[this.cacheId]||(Ye.spaceRotation[this.cacheId]=new c.Quaternion),Ye.effectiveSpaceRotation[this.cacheId]||(Ye.effectiveSpaceRotation[this.cacheId]=new c.Quaternion),Ye.clipOffsetRotation[this.cacheId]=new c.Quaternion,o&&Ye.clipOffsetRotation[this.cacheId].set(o.values[0],o.values[1],o.values[2],o.values[3]).invert(),this.handlePosition(i,n),this.handleRotation(i,o)}onStart(e){if(e.getClip()!==this.clip)return;Ye.lastObjRotation[this.cacheId]||(Ye.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const t=Ye.lastObjRotation[this.cacheId];if(Ye.spaceRotation[this.cacheId].copy(t),Ph){const i=new c.Euler().setFromQuaternion(t);console.log("START",this.clip.name,D.toDegrees(i.y),this.root.position.z)}}getClipRotationOffset(){return Ye.clipOffsetRotation[this.cacheId]}_prevTime=0;handlePosition(e,t){if(t){const i=this.root;Ph&&i.add(new c.AxesHelper),Ye.lastObjPosition[this.cacheId]||(Ye.lastObjPosition[this.cacheId]=this.root.position.clone());const n=new c.Vector3,o=new c.Vector3;this.positionWrapper=new b_(t,(r,a)=>{const l=this.action.getEffectiveWeight();return Ph&&i.position.length()>8&&i.position.set(0,i.position.y,0),r>this._prevTime&&(n.set(a[0],a[1],a[2]),n.sub(o),n.multiplyScalar(l),n.applyQuaternion(this.getClipRotationOffset()),n.applyQuaternion(i.quaternion),this.positionChange.copy(n)),o.fromArray(a),this._prevTime=r,a[0]=0,a[1]=0,a[2]=0,a})}}static identityQuaternion=new c.Quaternion;handleRotation(e,t){if(t){if(Ph){const r=t.values,a=new c.Euler().setFromQuaternion(new c.Quaternion(r[0],r[1],r[2],r[3]));console.log(e.name,t.name,"FIRST ROTATION IN TRACK",D.toDegrees(a.y));const l=t.values.length-4,h=new c.Quaternion().set(r[l],r[l+1],r[l+2],r[l+3]),d=new c.Euler().setFromQuaternion(h);console.log(e.name,t.name,"LAST ROTATION IN TRACK",D.toDegrees(d.y))}let i=0;const n=new c.Quaternion,o=new c.Quaternion;this.rotationWrapper=new b_(t,(r,a)=>(r>i&&(o.set(a[0],a[1],a[2],a[3]),n.invert(),o.multiply(n),this.rotationChange.copy(o)),n.fromArray(a),i=r,a[0]=0,a[1]=0,a[2]=0,a[3]=1,a))}}onBeforeUpdate(e){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(e){return!this.action||(e*=this.action.getEffectiveWeight(),e<=0)?!1:(this.positionChange.multiplyScalar(e),this.rotationChange.slerp(Ye.identityQuaternion,1-e),!0)}}class N1{controller;handler=[];root;basePosition=new c.Vector3;baseQuaternion=new c.Quaternion;baseRotation=new c.Euler;constructor(e){this.controller=e}createClip(e,t,i){this.root=t,t&&"name"in t&&t.name;const n=this.findRootTrack(i,".position"),o=this.findRootTrack(i,".quaternion"),r=new Ye(this.controller.context,t,i,n,o);this.handler.push(r);const a=e.clipAction(i);return r.action=a,a}onStart(e){for(const t of this.handler)t.onStart(e)}onBeforeUpdate(e){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const t of this.handler)t.onBeforeUpdate(e)}summedPosition=new c.Vector3;summedRotation=new c.Quaternion;onAfterUpdate(e){if(!(e<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const t of this.handler)t.onAfterUpdate(e)&&(this.summedPosition.add(t.positionChange),this.summedRotation.multiply(t.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(e,t){const i=e.tracks;if(!i)return null;for(const n of i)if(n.name.endsWith(t))return n;return null}}class V1 extends Ui{onSerialize(e,t){}onDeserialize(e,t){if(t.type===Di&&e?.__type==="AnimatorController")return new Di(e)}}new V1(Di);var $1=Object.defineProperty,W1=Object.getOwnPropertyDescriptor,au=(s,e,t,i)=>{for(var n=i>1?void 0:i?W1(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&$1(e,t,n),n};const Pi=w("debuganimator");class rt extends k{get isAnimationComponent(){return!0}applyRootMotion=!1;hasRootMotion=!1;keepAnimatorControllerStateOnDisable=!1;set runtimeAnimatorController(e){this._animatorController&&this._animatorController.model===e||(e?e instanceof Di?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",e.model?.name),e.model||console.error("AnimatorController has no model"),e=new Di(e.model)),this._animatorController=e,this._animatorController.bind(this)):(Pi&&console.log("Assign animator controller",e,this),this._animatorController=new Di(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){return this.runtimeAnimatorController?.getCurrentStateInfo()}get currentAction(){return this.runtimeAnimatorController?.currentAction||null}get parametersAreDirty(){return this._parametersAreDirty}_parametersAreDirty=!1;get isDirty(){return this._isDirty}_isDirty=!1;Play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){this.play(e,t,i,n)}play(e,t=-1,i=Number.NEGATIVE_INFINITY,n=0){this.runtimeAnimatorController?.play(e,t,i,n),this._isDirty=!0}Reset(){this.reset()}reset(){this._animatorController?.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){Pi&&console.log("setBool",e,t),this.runtimeAnimatorController?.getBool(e)!==t&&(this._parametersAreDirty=!0),this.runtimeAnimatorController?.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){const t=this.runtimeAnimatorController?.getBool(e)??!1;return Pi&&console.log("getBool",e,t),t}toggleBool(e){this.setBool(e,!this.getBool(e))}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){this.runtimeAnimatorController?.getFloat(e)!==t&&(this._parametersAreDirty=!0),Pi&&console.log("setFloat",e,t),this.runtimeAnimatorController?.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){const t=this.runtimeAnimatorController?.getFloat(e)??-1;return Pi&&console.log("getFloat",e,t),t}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){this.runtimeAnimatorController?.getInteger(e)!==t&&(this._parametersAreDirty=!0),Pi&&console.log("setInteger",e,t),this.runtimeAnimatorController?.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){const t=this.runtimeAnimatorController?.getInteger(e)??-1;return Pi&&console.log("getInteger",e,t),t}SetTrigger(e){this.setTrigger(e)}setTrigger(e){this._parametersAreDirty=!0,Pi&&console.log("setTrigger",e),this.runtimeAnimatorController?.setTrigger(e)}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){this._parametersAreDirty=!0,Pi&&console.log("resetTrigger",e),this.runtimeAnimatorController?.resetTrigger(e)}GetTrigger(e){this.getTrigger(e)}getTrigger(e){const t=this.runtimeAnimatorController?.getTrigger(e);return Pi&&console.log("getTrigger",e,t),t}IsInTransition(){return this.isInTransition()}isInTransition(){return this.runtimeAnimatorController?.isInTransition()??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){e!==this._speed&&(Pi&&console.log("setSpeed",e),this._speed=e,this._animatorController?.animator==this&&this._animatorController.setSpeed(e))}set minMaxSpeed(e){this._speed=D.lerp(e.x,e.y,Math.random()),this._animatorController?.animator==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(e){this._normalizedStartOffset=D.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController?.animator==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}_speed=1;_normalizedStartOffset=0;_animatorController=null;awake(){Pi&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}_initializeWithRuntimeAnimatorController;initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this._speed),this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){this.keepAnimatorControllerStateOnDisable||this._animatorController?.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!U1(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}au([f()],rt.prototype,"applyRootMotion",2);au([f()],rt.prototype,"hasRootMotion",2);au([f()],rt.prototype,"keepAnimatorControllerStateOnDisable",2);au([f()],rt.prototype,"runtimeAnimatorController",1);const v_=Symbol("previous-visibility");class On extends c.WebGLRenderTarget{render(e,t,i){if("addPass"in i)this._unsupported_effectcomposer_warning||(console.warn("RenderTexture.render() does not yet support EffectComposer"),this._unsupported_effectcomposer_warning=!0);else if(i instanceof c.WebGLRenderer){this.onBeforeRender();const o=i.getRenderTarget(),r=i.xr.enabled;i.xr.enabled=!1,i.setRenderTarget(this),i.clear(!0,!0,!0),i.render(e,t),i.setRenderTarget(o),i.xr.enabled=r,this.onAfterRender()}}static _userSet=new Set;onBeforeRender(){On._userSet.clear();const e=Em(this.texture,!0,null,On._userSet);for(const t of e)t instanceof c.Mesh&&(t[v_]=t.visible,t.visible=!1)}onAfterRender(){for(const e of On._userSet)e instanceof c.Mesh&&(e.visible=e[v_]);On._userSet.clear()}}var H1=Object.defineProperty,G1=Object.getOwnPropertyDescriptor,Mc=(s,e,t,i)=>{for(var n=i>1?void 0:i?G1(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&H1(e,t,n),n};const Oh=w("debuggroundprojection");class Bn extends k{applyOnAwake=!1;autoFit=!0;set radius(e){this._radius=e,this._projection&&this.updateProjection()}get radius(){return this._radius}_radius=50;set height(e){this._height=e,this._projection&&this.updateProjection()}get height(){return this._height}_height=3;set arBlending(e){this._arblending=e,this._needsTextureUpdate=!0}get arBlending(){return this._arblending}_arblending=0;_lastBackground;_lastRadius;_lastHeight;_projection;_watcher;awake(){this.applyOnAwake&&this.updateAndCreate()}onEnable(){this.context.time.frameCount>0&&this.applyOnAwake&&this.updateAndCreate(),this._watcher||(this._watcher=new as(this.context.scene,"background"),this._watcher.subscribeWrite(e=>{Oh&&console.log("Background changed",this.context.scene.background),this._needsTextureUpdate=!0}))}onDisable(){this._watcher?.revoke(),this._projection?.removeFromParent()}onEnterXR(){this.activeAndEnabled&&(this._needsTextureUpdate=!0,this.updateProjection())}async onLeaveXR(){this.activeAndEnabled&&(await mc(1),this.updateProjection())}onBeforeRender(){this._projection&&this.scene.backgroundRotation&&this._projection.rotation.copy(this.scene.backgroundRotation),this.context.scene.backgroundBlurriness!==void 0&&this._lastBlurriness!=this.context.scene.backgroundBlurriness&&this.context.scene.backgroundBlurriness>.001?this.updateProjection():this._needsTextureUpdate&&this.context.scene.background instanceof c.Texture&&this.updateBlurriness(this.context.scene.background,this.context.scene.backgroundBlurriness)}updateAndCreate(){this.updateProjection(),this._watcher?.apply()}_needsTextureUpdate=!1;updateProjection(){if(!this.context.scene.background){this._projection?.removeFromParent();return}const e=this.context.scene.background;if(!(e instanceof c.Texture)){this._projection?.removeFromParent();return}if((this.context.xr?.isPassThrough||this.context.xr?.isAR)&&this.arBlending===0){this._projection?.removeFromParent();return}if(!this.gameObject||this.destroyed)return;let t=!0;const i=0,n=e!==this._lastBackground||this._height!==this._lastHeight||this._radius!==this._lastRadius;if(!this._projection||n){Oh&&console.log("Create/Update Ground Projection",e.name),this._projection?.removeFromParent();try{this._projection=new q.GroundedSkybox(e,this._height,this._radius,64)}catch(o){console.error("Error creating three GroundProjection",o);return}this._projection.position.y=this._height-i,this._projection.name="GroundProjection",pm(this._projection,!1)}else t=!1;if(this._projection.parent||this.gameObject.add(this._projection),this.autoFit&&t){this._projection.updateWorldMatrix(!0,!0);const o=Ft(this.context.scene.children,[this._projection]),r=o.min.y;if(r<1/0){const a=F();a.x=o.min.x+(o.max.x-o.min.x)*.5;const l=je(this.gameObject).x;a.y=r+this._height*l-i,a.z=o.min.z+(o.max.z-o.min.z)*.5,ot(this._projection,a)}Oh&&I.DrawWireBox3(o,65280,5)}this.context.scene.backgroundBlurriness>.001&&this._needsTextureUpdate&&this.updateBlurriness(e,this.context.scene.backgroundBlurriness),this._lastBackground=e,this._lastHeight=this._height,this._lastRadius=this._radius,this._needsTextureUpdate=!1}_blurrynessShader=null;_lastBlurriness=-1;updateBlurriness(e,t){if(this._projection){if(!e)return}else return;this._needsTextureUpdate=!1,Oh&&console.log("Update Blurriness",t),this._blurrynessShader??=new c.ShaderMaterial({name:"GroundProjectionBlurriness",uniforms:{map:{value:e},blurriness:{value:t},blending:{value:0},alphaFactor:{value:1}},vertexShader:q1,fragmentShader:X1}),this._blurrynessShader.depthWrite=!1,this._blurrynessShader.uniforms.map.value=e,this._blurrynessShader.uniforms.blurriness.value=t,this._lastBlurriness=t,e.needsUpdate=!0;const i=this._projection.material.transparent;this._projection.material.transparent=(this.context.xr?.isAR===!0&&this.arBlending>1e-6)??!1,this._projection.material.transparent?this._blurrynessShader.uniforms.blending.value=this.arBlending:this._blurrynessShader.uniforms.blending.value=0,this.context.isInPassThrough?this._blurrynessShader.uniforms.alphaFactor.value=.95:this._blurrynessShader.uniforms.alphaFactor.value=1,i!==this._projection.material.transparent&&(this._projection.material.needsUpdate=!0),this._projection.material.map=Ks.copyTexture(e,this._blurrynessShader),this._projection.material.depthTest=!0,this._projection.material.depthWrite=!1}}Mc([f()],Bn.prototype,"applyOnAwake",2);Mc([f()],Bn.prototype,"autoFit",2);Mc([f()],Bn.prototype,"radius",1);Mc([f()],Bn.prototype,"height",1);Mc([f()],Bn.prototype,"arBlending",1);const q1=`
|
|
@@ -987,7 +987,7 @@ Consider registering a custom loader via the 'onCreateCustomModelLoader' callbac
|
|
|
987
987
|
Content-Type: "${t.headers.get("content-type")}
|
|
988
988
|
"Text: "${o}"
|
|
989
989
|
Binary:`,i)}else console.debug("Could not determine file type from binary data");return"unknown"}var YP=Object.defineProperty,Ea=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&YP(e,t,n),n};const oi=w("debugdroplistener");class KP extends CustomEvent{constructor(e){super("object-added",{detail:e})}}const ZP="blob";class ps extends k{dropArea;fitIntoVolume=!1;fitVolumeSize=new c.Vector3(1,1,1);placeAtHitPosition=!0;useNetworking=!1;onDropped=new oe;loadFromURL(e,t){return this.addFromUrl(e,{screenposition:new c.Vector2,point:t?.point,size:t?.size},!1)}forgetObjects(){this.removePreviouslyAddedObjects(!1)}onEnable(){this.context.renderer.domElement.addEventListener("dragover",this.onDrag),this.context.renderer.domElement.addEventListener("drop",this.onDrop),window.addEventListener("paste",this.handlePaste),this.context.connection.beginListen("droplistener",this.onNetworkEvent)}onDisable(){this.context.renderer.domElement.removeEventListener("dragover",this.onDrag),this.context.renderer.domElement.removeEventListener("drop",this.onDrop),window.removeEventListener("paste",this.handlePaste),this.context.connection.stopListen("droplistener",this.onNetworkEvent)}onNetworkEvent=e=>{if(!this.useNetworking){oi&&console.debug("[DropListener] Ignoring networked event because networking is disabled",e);return}if(e.guid?.startsWith(this.guid)){const t=e.url;if(console.debug("[DropListener] Received networked event",e),t)if(Array.isArray(t))for(const i of t)this.addFromUrl(i,{screenposition:new c.Vector2,point:e.point,size:e.size},!0);else this.addFromUrl(t,{screenposition:new c.Vector2,point:e.point,size:e.size},!0)}};handlePaste=e=>{if(this.context.connection.allowEditing===!1||e.defaultPrevented)return;navigator.clipboard.readText().then(i=>{if(i&&(i.startsWith("http")||i.startsWith("https")||i.startsWith("blob"))){const o={screenposition:new c.Vector2(this.context.input.mousePosition.x,this.context.input.mousePosition.y)};this.testIfIsInDropArea(o)&&this.addFromUrl(i,o,!1)}}).catch(console.warn)};onDrag=e=>{this.context.connection.allowEditing!==!1&&e.preventDefault()};onDrop=async e=>{if(this.context.connection.allowEditing===!1||(oi&&console.log(e),!e?.dataTransfer)||e["droplistener:handled"])return;e.preventDefault();const t={screenposition:new c.Vector2(e.offsetX,e.offsetY)};if(this.dropArea&&this.testIfIsInDropArea(t)===!1)return;e["droplistener:handled"]=!0;const i=e.dataTransfer.items;if(!i)return;const n=[];for(const o in i){const r=i[o];if(r.kind==="file"){const a=r.getAsFile();if(!a)continue;n.push(a)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(a=>{this.addFromUrl(a,t,!1)})}n.length>0&&await this.addFromFiles(n,t)};async addFromUrl(e,t,i){oi&&console.log("dropped url",e);try{if(e.startsWith("https://github.com/")){const r=e.split("/"),a=r[3],l=r[4],h=r[6],d=r.slice(7).join("/");e=`https://raw.githubusercontent.com/${a}/${l}/${h}/${d}`}else e.startsWith("https://polyhaven.com/a")&&(e=JP(e));if(!e)return null;const n=e.toLowerCase();if(n.endsWith(".hdr")||n.endsWith(".hdri")||n.endsWith(".exr")||n.endsWith(".png")||n.endsWith(".jpg")||n.endsWith(".jpeg"))return console.warn(`Fileformat is not supported: ${n}`),null;this.removePreviouslyAddedObjects();const o=await Dd.loadFileFromURL(new URL(e),{guid:this.guid,context:this.context,parent:this.gameObject,point:t.point,size:t.size});if(o&&this._addedObjects.length<=0)return t.url=e,this.onObjectLoaded(o,t,i)}catch{console.warn("String is not a valid URL",e)}return null}_abort=null;async addFromFiles(e,t){if(oi&&console.log("Add files",e),!!Array.isArray(e)&&e.length){this.deleteDropEvent(),this.removePreviouslyAddedObjects(),Ql(ZP,null),this._abort?.abort("New files dropped"),this._abort=new AbortController;for(const i of e){if(!i)continue;if(i.type.startsWith("image/")){oi&&console.warn("Ignoring dropped image file",i.name,i.type);continue}else if(i.name.endsWith(".bin")){oi&&console.warn("Ignoring dropped binary file",i.name,i.type);continue}console.debug("Load file "+i.name+" + "+i.type);const n=await Dd.loadFile(i,this.context,{guid:this.guid});if(n){this.dispatchEvent(new CustomEvent("file-dropped",{detail:i})),t.file=i;const o=this.onObjectLoaded(n,t,!1);o&&this.context.connection.isConnected&&this.useNetworking&&(console.debug("Uploading dropped file to blob storage"),exports.BlobStorage.upload(i,{abort:this._abort?.signal}).then(r=>{r?.download_url&&this._addedObjects.includes(o)&&this.sendDropEvent(r.download_url,o,n.contentMD5)}).catch(console.warn));break}}}}_addedObjects=new Array;_addedModels=new Array;removePreviouslyAddedObjects(e=!0){if(e)for(const t of this._addedObjects)t.parent===this.gameObject&&ui(t,!0,!0);this._addedObjects.length=0,this._addedModels.length=0}onObjectLoaded(e,t,i){const{model:n,contentMD5:o}=e;if(oi&&console.log(`Dropped ${this.gameObject.name}`,n),!n?.scene)return console.warn("No object specified to add to scene",n),null;this.removePreviouslyAddedObjects();const r=n.scene;this.gameObject.attach(r),r.position.set(0,0,0),r.quaternion.identity(),this._addedObjects.push(r),this._addedModels.push(n);const a=new c.Box3().setFromCenterAndSize(new c.Vector3(0,this.fitVolumeSize.y*.5,0).add(this.gameObject.worldPosition),this.fitVolumeSize);if(oi&&I.DrawWireBox3(a,255,5),this.fitIntoVolume&&Fb(r,a,{position:!this.placeAtHitPosition}),this.placeAtHitPosition&&t&&t.screenposition){r.visible=!1;const h=this.context.physics.raycast({screenPoint:this.context.input.convertScreenspaceToRaycastSpace(t.screenposition.clone())});if(r.visible=!0,h&&h.length>0)for(const d of h){const u=d.point.clone();oi&&console.log("Place object at hit",d),Ub(r,u);break}}Zs.autoplayAnimations(n);const l=new KP({sender:this,gltf:n,model:n,object:r,contentMD5:o,dropped:t.file||(t.url?new URL(t.url):void 0)});return this.dispatchEvent(l),this.onDropped?.invoke(l.detail),!i&&t.url?.startsWith("http")&&this.context.connection.isConnected&&r&&this.sendDropEvent(t.url,r,o),r}async sendDropEvent(e,t,i){if(!this.useNetworking){oi&&console.debug("[DropListener] Ignoring networked event because networking is disabled",e);return}if(this.context.connection.isConnected){console.debug('Sending drop event "'+t.name+'"',e);const n=Ft([t]),o={name:t.name,guid:this.guid,url:e,point:t.worldPosition.clone(),size:n.getSize(new c.Vector3),contentMD5:i};this.context.connection.send("droplistener",o)}}deleteDropEvent(){this.context.connection.sendDeleteRemoteState(this.guid)}testIfIsInDropArea(e){if(this.dropArea){const t=this.context.input.convertScreenspaceToRaycastSpace(e.screenposition.clone());if(!this.context.physics.raycast({targets:[this.dropArea],screenPoint:t,recursive:!0,testObject:n=>!this._addedObjects.includes(n)}).length)return A()&&console.log(`Dropped outside of drop area for DropListener "${this.name}".`),!1}return!0}}Ea([f(c.Object3D)],ps.prototype,"dropArea");Ea([f()],ps.prototype,"fitIntoVolume");Ea([f(c.Vector3)],ps.prototype,"fitVolumeSize");Ea([f()],ps.prototype,"placeAtHitPosition");Ea([f()],ps.prototype,"useNetworking");Ea([f(oe)],ps.prototype,"onDropped");function JP(s){if(!s.startsWith("https://polyhaven.com/"))return s;const e="https://dl.polyhaven.org/file/ph-assets/Models/gltf/4k/",n=new URL(s).pathname.split("/").pop(),o=`${e}${n}/${n}_4k.gltf`;return console.log("Resolved polyhaven asset url",s,"→",o),o}var Dd;(s=>{async function e(i,n,o){const r=o.guid,a=new mt(r),l=new Blob([i],{type:i.type||Dv(i.name)||void 0}),h=URL.createObjectURL(l),d=await nn().loadSync(n,h,i.name,a).catch(u=>(console.error(`Failed to load file "${i.name}" (${i.type}):`,u),null));return URL.revokeObjectURL(h),d?new Promise((u,p)=>{const m=new FileReader;m.readAsArrayBuffer(i),m.onloadend=async y=>{const _=m.result,g=exports.BlobStorage.hashMD5(_);return u({model:d,contentMD5:g})}}):(console.warn(`Failed to load "${i.name}" (${i.type})`),null)}s.loadFile=e;async function t(i,n){return new Promise(async(o,r)=>{const a=new mt(n.guid),l=i.toString();oi&&I.DrawWireSphere(n.point,.1,16711680,3);const h=exports.PreviewHelper.addPreview({guid:n.guid,parent:n.parent,position:n?.point,size:n?.size}),d=await nn().loadSync(n.context,l,l,a,u=>{h.onProgress(u.loaded/u.total)}).catch(console.warn);if(d){const u=await fetch(l).then(m=>m.arrayBuffer()),p=exports.BlobStorage.hashMD5(u);oi?setTimeout(()=>exports.PreviewHelper.removePreview(n.guid),3e3):exports.PreviewHelper.removePreview(n.guid),o({model:d,contentMD5:p})}else oi?setTimeout(()=>exports.PreviewHelper.removePreview(n.guid),3e3):exports.PreviewHelper.removePreview(n.guid),console.warn("Unsupported file type: "+i.toString())})}s.loadFileFromURL=t})(Dd||(Dd={}));var eO=Object.defineProperty,og=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&eO(e,t,n),n};const gu=class Bv extends k{parent=null;object=null;limitCount=60;_currentCount=0;_startPosition=null;_startQuaternion=null;start(){if(this._currentCount=0,this._startPosition=null,this._startQuaternion=null,this.object||(this.object=this.gameObject),this.object){if(this.object===this.gameObject){const t=new mt(this.guid);this.object=S.instantiate(this.object,{idProvider:t,keepWorldPosition:!1}),S.getComponent(this.object,Bv)?.destroy();let n=this.object.getComponentInChildren(Io);n||(n=this.object.addComponent(Io,{dragMode:sg.SnapToSurfaces}),n.guid=t.generateUUID());let o=S.getComponent(n.gameObject,on);o||(o=n.gameObject.addComponent(on),o.guid=t.generateUUID())}this.object.visible=!1;const e=this.gameObject.getComponent(Io);e&&(e.enabled=!1),this._startPosition=this.object.position?.clone()??new c.Vector3(0,0,0),this._startQuaternion=this.object.quaternion?.clone()??new c.Quaternion(0,0,0,1)}this.gameObject.getComponentInParent(fi)||this.gameObject.addComponent(fi)}onEnable(){this.startCoroutine(this.cloneLimitIntervalFn())}_forwardPointerEvents=new Map;onPointerEnter(e){e.used||this.object&&this.context.connection.allowEditing&&e.button===0&&this.context.input.setCursor("pointer")}onPointerExit(e){e.used||this.object&&this.context.connection.allowEditing&&e.button===0&&this.context.input.unsetCursor("pointer")}onPointerDown(e){if(e.used||!this.object||!this.context.connection.allowEditing||e.button!==0)return;const t=this.handleDuplication();if(t){const i=S.getComponent(t,Io);i?(i.onPointerDown(e),this._forwardPointerEvents.set(e.event.space,i)):A()&&console.warn(`Duplicated object (${t.name}) does not have DragControls`)}else this._currentCount>=this.limitCount?console.warn(`[Duplicatable] Limit of ${this.limitCount} objects created within a few seconds reached. Please wait a moment before creating more objects.`):console.warn("[Duplicatable] Could not duplicate object.")}onPointerUp(e){if(e.used)return;const t=this._forwardPointerEvents.get(e.event.space);t&&(t.onPointerUp(e),this._forwardPointerEvents.delete(e.event.space))}*cloneLimitIntervalFn(){for(;this.activeAndEnabled&&!this.destroyed;)this._currentCount>0?this._currentCount-=1:this._currentCount<0&&(this._currentCount=0),yield Um(1)}handleDuplication(){if(!this.object||this.limitCount>0&&this._currentCount>=this.limitCount||this.object===this.gameObject)return null;if(S.isDestroyed(this.object))return this.object=null,null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const e=new an;this.parent||(this.parent=this.gameObject.parent),this.parent&&(e.parent=this.parent.guid??this.parent.userData?.guid,e.keepWorldPosition=!0),e.position=this.worldPosition,e.rotation=this.worldQuaternion,e.context=this.context,this._currentCount+=1;const t=S.instantiateSynced(this.object,e);return console.assert(t!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),t}};og([f(c.Object3D)],gu.prototype,"parent");og([f(c.Object3D)],gu.prototype,"object");og([f()],gu.prototype,"limitCount");let rg=gu;var Qn=(s=>(s[s.PointerEnter=0]="PointerEnter",s[s.PointerExit=1]="PointerExit",s[s.PointerDown=2]="PointerDown",s[s.PointerUp=3]="PointerUp",s[s.PointerClick=4]="PointerClick",s[s.Drag=5]="Drag",s[s.Drop=6]="Drop",s[s.Scroll=7]="Scroll",s[s.UpdateSelected=8]="UpdateSelected",s[s.Select=9]="Select",s[s.Deselect=10]="Deselect",s[s.Move=11]="Move",s[s.InitializePotentialDrag=12]="InitializePotentialDrag",s[s.BeginDrag=13]="BeginDrag",s[s.EndDrag=14]="EndDrag",s[s.Submit=15]="Submit",s[s.Cancel=16]="Cancel",s))(Qn||{}),tO=Object.defineProperty,ag=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&tO(e,t,n),n};class lg{eventID;callback=new oe}ag([f()],lg.prototype,"eventID");ag([f(oe)],lg.prototype,"callback");class yu extends k{triggers=[];invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback?.invoke()}hasTrigger(e){return this.triggers?.some(t=>t.eventID===e)??!1}shouldChangeCursor(){return this.hasTrigger(Qn.PointerClick)||this.hasTrigger(Qn.PointerDown)||this.hasTrigger(Qn.PointerUp)}onPointerClick(e){this.invoke(Qn.PointerClick)}onPointerEnter(e){this.shouldChangeCursor()&&this.context.input.setCursor("pointer"),this.invoke(Qn.PointerEnter)}onPointerExit(e){this.shouldChangeCursor()&&this.context.input.unsetCursor("pointer"),this.invoke(Qn.PointerExit)}onPointerDown(e){this.invoke(Qn.PointerDown)}onPointerUp(e){this.invoke(Qn.PointerUp)}}ag([f(lg)],yu.prototype,"triggers");class Fv{writer;constructor(e){this.writer=e}writeNode(e){}}class iO extends Fv{beforeWriteNode(e,t){I.isGizmo(e)&&(t.keep=!1)}}class Uv extends Fv{beforeWriteTexture(e,t){e.isRenderTargetTexture&&(t.newTexture=zm(new Z(1,1,1,0)))}}function Bp(s){const e=du.DontExport;return!(s.hideFlags&e)}const kf=w("debugexr");class nO{get name(){return"EXT_texture_exr"}parser;constructor(e){this.parser=e,kf&&console.log(e)}loadTexture(e){const t=this.name,i=this.parser,o=i.json.textures[e];if(kf&&console.log("EXT_texture_exr.loadTexture",e,o),!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],a=new q.EXRLoader(i.options.manager);return kf&&console.log("EXT_texture_exr.loadTexture",r),i.loadTextureImage(e,r.source,a)}}typeof window<"u"&&window.addEventListener("unhandledrejection",s=>{});const Hn=st,kh="$___Export_Components",sO="NEEDLE_components";class oO{[Ro]}class rO{node;nodeIndex;nodeDef;constructor(e,t,i){this.node=e,this.nodeIndex=t,this.nodeDef=i}}class zv{get name(){return sO}parser;nodeToObjectMap={};gltf=null;exportContext;objectToNodeMap={};context;writer;registerExport(e){e.register(t=>{if("serializeUserData"in t){const i=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(n,o)=>{try{this.serializeUserData(n,o)&&(t.extensionsUsed[this.name]=!0),i(n,o)}finally{this.afterSerializeUserData(n,o)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){const i=e.userData?.components;return!i||i.length<=0?!1:(delete e.userData.components,e[kh]=i,!0)}afterSerializeUserData(e,t){if(e.type==="Scene"&&Hn&&console.log("DONE",JSON.stringify(t)),e[kh]===void 0)return;const i=e[kh];delete e[kh],i!==null&&(e.userData.components=i)}writeNode(e,t){const i=this.writer.json.nodes.length;Hn&&console.log(e.name,i,e.uuid);const n=new rO(e,i,t);this.exportContext[i]=n,this.objectToNodeMap[e.uuid]=i}afterParse(e){Hn&&console.log("AFTER",e);for(const t in this.exportContext){const i=this.exportContext[t],n=i.node,o=i.nodeDef,r=i.nodeIndex,a=n.userData?.components;if(!a||a.length<=0)continue;const l=new oO;o.extensions=o.extensions||{},o.extensions[this.name]=l,this.context.object=n,this.context.nodeId=r,this.context.objectToNode=this.objectToNodeMap;const h=[];for(const d of a){this.context.target=d;const u=nn().writeBuiltinComponentData(d,this.context);u!==null&&h.push(u)}h.length>0&&(l[Ro]=h,Hn&&console.log("DID WRITE",n,"nodeIndex",r,h))}}beforeRoot(){return Hn&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){this.gltf=e;const t=e.parser,i=t?.extensions;if(!i)return;const n=i[this.name];Hn&&console.log("After root",e,this.parser,i);const o=[];if(n===!0){const r=t.json.nodes;if(r){for(let a=0;a<r.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<r.length;a++){const l=r[a],h=a,d=l.extensions;if(!d)continue;const u=d[this.name];if(!u)continue;Hn&&console.log("NODE",l);const p=this.nodeToObjectMap[h];if(!p){console.error("Could not find object for node index: "+h,l,t);continue}tu(p),o.push(this.createComponents(p,u))}}}await Promise.all(o);for(const r of t.associations.keys()){const a=t.associations.get(r);if(a?.materials!=null){const l="/materials/"+a.materials;MC(r,l)}}}async createComponents(e,t){if(!t)return;const i=t[Ro];if(i){const n=new Array;Hn&&console.log(e.name,i);for(const o in i){const r=i[o];Hn&&console.log("Serialized data",JSON.parse(JSON.stringify(r))),r&&this.parser&&n.push(Im(this.parser,r).catch(a=>console.error(`Error while resolving references (see console for details)
|
|
990
|
-
`,a,e,r))),e.userData=e.userData||{},e.userData[Ro]=e.userData[Ro]||[],e.userData[Ro].push(r)}await Promise.all(n).catch(o=>{console.error("Error while loading components",o)})}}}const M_="NEEDLE_gameobject_data";class aO{get name(){return M_}parser;constructor(e){this.parser=e}afterRoot(e){const t=[];for(let i=0;i<this.parser.json.nodes?.length;i++){const n=this.parser.json.nodes[i];if(n&&n.extensions){const o=n.extensions[M_];if(o){const r=this.findAndApplyExtensionData(i,o);t.push(r)}}}return Promise.all(t).then(()=>null)}async findAndApplyExtensionData(e,t){const i=await this.parser.getDependency("node",e);i&&this.applyExtensionData(i,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.hideFlags=0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const k_="NEEDLE_lighting_settings",Gr=w("debugenvlight");class lO{get name(){return k_}parser;sourceId;context;constructor(e,t,i){this.parser=e,this.sourceId=t,this.context=i}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[k_];if(i){Gr&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const o=e.scene.children[0];n=S.addComponent(o,Id,{},{callAwake:!1})}else{const o=new c.Object3D;o.name="LightSettings "+this.sourceId,e.scene.add(o),n=S.addComponent(o,Id,{},{callAwake:!1})}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new c.Color().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(o=>new c.Color().fromArray(o))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}ae.registerCallback(re.ContextCreated,s=>{const e=s.context,t=S.findObjectOfType(Id,e);t?.sourceId&&(t.enabled=!0)});class Id extends k{ambientMode=aa.Skybox;ambientLight;ambientTrilight;ambientIntensity=1;environmentReflectionSource=Md.Skybox;_hasReflection=!1;_ambientLightObj;_hemisphereLightObj;awake(){if(this.sourceId){const t=this.environmentReflectionSource===Md.Skybox?wn.Skybox:wn.Reflection,i=this.context.lightmaps.tryGet(this.sourceId,t,0);this._hasReflection=i!=null,i&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,i)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),Gr&&window.addEventListener("keydown",t=>{if(!this.destroyed)switch(t.key){case"l":this.enabled=!this.enabled;break}});const e=this.gameObject.userData?.components;if(e){const t=e.indexOf(this);e.splice(t,1),e.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*D.lerp(0,1.33,t)}onEnable(){if(Gr&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==aa.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new c.AmbientLight(this.ambientLight,this.ambientIntensity*e),Gr&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===aa.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],i=this.calculateIntensityFactor(t);this._hemisphereLightObj=new c.HemisphereLight(t,e,this.ambientIntensity*i),this.gameObject.add(this._hemisphereLightObj),Gr&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,i)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&(this.context.domElement.getAttribute("environment-image")||this.context.sceneLighting.internalEnableReflection(this.sourceId))}onDisable(){Gr&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}const Ef=w("debugstencil");function cO(s,e){return(s&1<<e.layer)!=0}const hO=Symbol("stencils");class Ns{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Ef&&console.log(t,Ns.stencils),!t)return;const i=Ns.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];if(cO(o.layer,e)){Ef&&console.log(o),setTimeout(()=>{Ii()&&iu(e.gameObject)&&(he("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",e))},500);for(let r=0;r<e.sharedMaterials.length;r++){let a=e.sharedMaterials[r];a&&(a=a.clone(),a[hO]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=o.value,a.stencilFunc=o.compareFunc,a.stencilZPass=o.passOp,a.stencilFail=o.failOp,a.stencilZFail=o.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=o.event*1e3+o.index*50;break}}}parser;source;constructor(e,t){this.parser=e,this.source=t}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[uO];if(i){Ef&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const o of n){const r={...o};r.compareFunc=dO(r.compareFunc),r.passOp=Rf(r.passOp),r.failOp=Rf(r.failOp),r.zFailOp=Rf(r.zFailOp),Ns.stencils[this.source]||(Ns.stencils[this.source]=[]),Ns.stencils[this.source].push(r)}}}return null}}function Rf(s){switch(s){case 0:return c.KeepStencilOp;case 1:return c.ZeroStencilOp;case 2:return c.ReplaceStencilOp;case 3:return c.IncrementStencilOp;case 4:return c.DecrementStencilOp;case 6:return c.IncrementWrapStencilOp;case 7:return c.DecrementWrapStencilOp;case 5:return c.InvertStencilOp}return 0}function dO(s){switch(s){case 1:return c.NeverStencilFunc;case 2:return c.LessStencilFunc;case 3:return c.EqualStencilFunc;case 4:return c.LessEqualStencilFunc;case 5:return c.GreaterStencilFunc;case 6:return c.NotEqualStencilFunc;case 7:return c.GreaterEqualStencilFunc;case 8:return c.AlwaysStencilFunc}return c.NeverStencilFunc}const uO="NEEDLE_render_objects";var Nv=(s=>(s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_VEC2=35664]="FLOAT_VEC2",s[s.FLOAT_VEC3=35665]="FLOAT_VEC3",s[s.FLOAT_VEC4=35666]="FLOAT_VEC4",s[s.INT_VEC2=35667]="INT_VEC2",s[s.INT_VEC3=35668]="INT_VEC3",s[s.INT_VEC4=35669]="INT_VEC4",s[s.BOOL=35670]="BOOL",s[s.BOOL_VEC2=35671]="BOOL_VEC2",s[s.BOOL_VEC3=35672]="BOOL_VEC3",s[s.BOOL_VEC4=35673]="BOOL_VEC4",s[s.FLOAT_MAT2=35674]="FLOAT_MAT2",s[s.FLOAT_MAT3=35675]="FLOAT_MAT3",s[s.FLOAT_MAT4=35676]="FLOAT_MAT4",s[s.SAMPLER_2D=35678]="SAMPLER_2D",s[s.SAMPLER_3D=35680]="SAMPLER_3D",s[s.SAMPLER_CUBE=35681]="SAMPLER_CUBE",s[s.UNKNOWN=0]="UNKNOWN",s))(Nv||{});const _n=w("debugcustomshader"),Dr="NEEDLE_techniques_webgl";class fO{objectToWorldMatrix=new c.Matrix4;worldToObjectMatrix=new c.Matrix4;objectToWorld=new Array;worldToObject=new Array;updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),Od(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),Od(this.worldToObjectMatrix,this.worldToObject)}}class ye extends c.RawShaderMaterial{identifier;onBeforeRenderSceneCallback=this.onBeforeRenderScene.bind(this);clone(){const e=super.clone();return Vv(e),e}constructor(e,...t){super(...t),this.identifier=e,_n&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&z.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}dispose(){super.dispose();const e=z.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);e>=0&&z.Current.pre_render_callbacks.splice(e,1)}_sphericalHarmonicsName="unity_SpecCube0";_objToWorldName="hlslcc_mtx4x4unity_ObjectToWorld";_worldToObjectName="hlslcc_mtx4x4unity_WorldToObject";static viewProjection=new c.Matrix4;static _viewProjectionValues=[];_viewProjectionName="hlslcc_mtx4x4unity_MatrixVP";static viewMatrix=new c.Matrix4;static _viewMatrixValues=[];_viewMatrixName="hlslcc_mtx4x4unity_MatrixV";static _worldSpaceCameraPosName="_WorldSpaceCameraPos";static _worldSpaceCameraPos=new c.Vector3;static _mainLightColor=new c.Vector4;static _mainLightPosition=new c.Vector3;static _lightData=new c.Vector4;_rendererData=new fO;get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&z.Current.setRequireColor(!0),this.depthTextureUniform&&z.Current.setRequireDepth(!0)}onBeforeRender(e,t,i,n,o,r){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(i,o)}onUpdateUniforms(e,t){const i=z.Current;if(e&&(ye.viewProjection&&this.uniforms[this._viewProjectionName]&&(ye.viewProjection.copy(e.projectionMatrix).multiply(e.matrixWorldInverse),Od(ye.viewProjection,ye._viewProjectionValues)),ye.viewMatrix&&this.uniforms[this._viewMatrixName]&&(ye.viewMatrix.copy(e.matrixWorldInverse),Od(ye.viewMatrix,ye._viewMatrixValues)),this.uniforms[ye._worldSpaceCameraPosName]&&ye._worldSpaceCameraPos.setFromMatrixPosition(e.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=i.sceneLighting.timeVec4),this.uniforms._Time){const a=this.uniforms._Time.value;a.x=i.sceneLighting.timeVec4.x/20,a.y=i.sceneLighting.timeVec4.x,a.z=i.sceneLighting.timeVec4.x*2,a.w=i.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const a=this.uniforms._SinTime.value;a.x=Math.sin(i.sceneLighting.timeVec4.x/8),a.y=Math.sin(i.sceneLighting.timeVec4.x/4),a.z=Math.sin(i.sceneLighting.timeVec4.x/2),a.w=Math.sin(i.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const a=this.uniforms._CosTime.value;a.x=Math.cos(i.sceneLighting.timeVec4.x/8),a.y=Math.cos(i.sceneLighting.timeVec4.x/4),a.z=Math.cos(i.sceneLighting.timeVec4.x/2),a.w=Math.cos(i.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const a=this.uniforms.unity_DeltaTime.value;a.x=i.time.deltaTime,a.y=1/i.time.deltaTime,a.z=i.time.smoothedDeltaTime,a.w=1/i.time.smoothedDeltaTime}const n=i.mainLight;if(n){const a=X(n.gameObject,ye._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},ye._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:ye._mainLightColor};const l=n.intensity;ye._lightData.z=l,this.uniforms.unity_LightData={value:ye._lightData}}if(e&&(ye.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=ye._viewProjectionValues),ye.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=ye._viewMatrixValues),this.uniforms[ye._worldSpaceCameraPosName]&&(this.uniforms[ye._worldSpaceCameraPosName]={value:ye._worldSpaceCameraPos}),i.mainCameraComponent)){if(this.uniforms._ProjectionParams){const a=this.uniforms._ProjectionParams.value;a.x=1,a.y=i.mainCameraComponent.nearClipPlane,a.z=i.mainCameraComponent.farClipPlane,a.w=1/a.z,this.uniforms._ProjectionParams.value=a}if(this.uniforms._ZBufferParams){const a=this.uniforms._ZBufferParams.value,l=i.mainCameraComponent;a.x=1-l.farClipPlane/l.nearClipPlane,a.y=l.farClipPlane/l.nearClipPlane,a.z=a.x/l.farClipPlane,a.w=a.y/l.farClipPlane,this.uniforms._ZBufferParams.value=a}if(this.uniforms._ScreenParams){const a=this.uniforms._ScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScreenParams.value=a}if(this.uniforms._ScaledScreenParams){const a=this.uniforms._ScaledScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScaledScreenParams.value=a}}const o=this.depthTextureUniform;o&&(o.value=i.depthTexture);const r=this.opaqueTextureUniform;if(r&&(r.value=i.opaqueColorTexture),t){const a=this._rendererData;a.updateFrom(t),this.uniforms[this._worldToObjectName].value=a.worldToObject,this.uniforms[this._objToWorldName].value=a.objectToWorld}this.uniformsNeedUpdate=!0}}class pO{get name(){return Dr}parser;identifier;constructor(e,t){this.parser=e,this.identifier=t}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return _n&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[Dr])return _n&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;_n&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,t);const i=t.extensions[Dr].technique;if(i<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const n=this.parser.json.extensions[Dr];if(!n)return _n?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;_n&&console.log(n);const o=n.techniques[i];return o?new Promise(async(r,a)=>{const l=await a1(n,o.program),h=l?.fragmentShader,d=l?.vertexShader;if(!h||!d)return a();_n&&console.log("loadMaterial",t,l);const u={},p=o.uniforms;(d.includes("_Time")||h.includes("_Time"))&&(u._Time={value:new c.Vector4(0,0,0,0)}),(d.includes("_SinTime")||h.includes("_SinTime"))&&(u._SinTime={value:new c.Vector4(0,0,0,0)}),(d.includes("_CosTime")||h.includes("_CosTime"))&&(u._CosTime={value:new c.Vector4(0,0,0,0)}),(d.includes("unity_DeltaTime")||h.includes("unity_DeltaTime"))&&(u.unity_DeltaTime={value:new c.Vector4(0,0,0,0)});for(const v in p){const b=v;switch(b){case"_TimeParameters":const x=new c.Vector4;u[b]={value:x};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":u[b]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":u[b]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":u[b]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":u[b]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":u[b]={value:null};break}}let m=!1;if(t.extensions&&t.extensions[Dr]){const v=t.extensions[Dr];if(v.technique===i){_n&&console.log(t.name,"Material Properties",v);for(const b in v.values){const x=v.values[b];if(typeof x=="string"){if(x.startsWith("/textures/")){const R=x.substring(10),O=Number.parseInt(R);if(O>=0){const M=await this.parser.getDependency("texture",O);M instanceof c.Texture&&(M.colorSpace=c.LinearSRGBColorSpace,M.needsUpdate=!0),u[b]={value:M};continue}}switch(b){case"alphaMode":x==="BLEND"&&(m=!0);continue}}if(Array.isArray(x)&&x.length===4){u[b]={value:new c.Vector4(x[0],x[1],x[2],x[3])};continue}u[b]={value:x}}}}const y=new ye(this.identifier,{name:t.name??"",uniforms:u,vertexShader:d,fragmentShader:h,lights:!1});switch(y.glslVersion=c.GLSL3,y.vertexShader=y.vertexShader.replace("#version 300 es",""),y.fragmentShader=y.fragmentShader.replace("#version 300 es",""),u._Cull?.value){case 0:y.side=c.DoubleSide;break;case 1:y.side=c.BackSide;break;case 2:y.side=c.FrontSide;break;default:y.side=c.FrontSide;break}switch(u._ZTest?.value){case 3:y.depthTest=!0,y.depthFunc=c.EqualDepth;break;case 6:y.depthTest=!0,y.depthFunc=c.NotEqualDepth;break;case 2:y.depthTest=!0,y.depthFunc=c.LessDepth;break;case 4:y.depthTest=!0,y.depthFunc=c.LessEqualDepth;break;case 5:y.depthTest=!0,y.depthFunc=c.GreaterDepth;break;case 7:y.depthTest=!0,y.depthFunc=c.GreaterEqualDepth;break;case 8:y.depthTest=!1,y.depthFunc=c.AlwaysDepth;break}y.transparent=m,m&&(y.depthWrite=!1),o1(u),y.onUpdateUniforms();for(const v in p){const b=v,x=p[v].type;if(u[b]?.value===void 0)switch(x){case Nv.SAMPLER_2D:u[b]={value:n1},console.warn("Missing/unassigned texture, fallback to white: "+b);break;default:b==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+b,p[v]);break}}_n&&console.log(y.uuid,u),Vv(y),r(y)}):null}}function Vv(s){if(s.uniforms){_n&&console.log("Uniforms:",s.uniforms);for(const t in s.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>s.uniforms[i].value,set:n=>{s.uniforms[i].value=n,s.needsUpdate=!0}})}}const mO=w("debugextensions");let jd;const gO=Promise.resolve().then(()=>require("./vendor-D0Yvltn9.umd.cjs")).then(s=>s.index$2).then(async s=>(jd=s.GLTFAnimationPointerExtension,jd)).catch(s=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three-animationpointer for full KHR_animation support",s)}),tr=new Array;function yO(s){tr.includes(s)||tr.push(s)}function _O(s){const e=tr.indexOf(s);e>=0&&tr.splice(e,1)}function cg(s){if(s instanceof q.GLTFLoader){const e=new zv;return s.register(t=>(e.parser=t,e)),e}return null}class bO{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function Bd(s,e,t){const i=t.indexOf("?");i>=0&&(t=t.substring(0,i)),s.register(n=>new aO(n)),s.register(n=>new EC(n)),s.register(n=>new JC(n,e.lightmaps,t)),s.register(n=>new lO(n,t,e)),s.register(n=>new pO(n,t)),s.register(n=>new Ns(n,t)),s.register(n=>new ne.NEEDLE_progressive(n)),s.register(n=>new nO(n)),c0()&&s.register(n=>new oa(n)),await gO.catch(n=>{}),s.register(n=>{if(jd){const o=new jd(n);return o.setAnimationPointerResolver.bind(o)(new bO),o}else return(mO||A())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const n of tr)n.onImport&&n.onImport(s,t,e)}function hg(s,e){for(const t of tr)t.onExport&&t.onExport(s,e)}function $v(s,e,t){for(const i of tr)i.onLoaded&&i.onLoaded(s,e,t)}class Wv{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(e.constructor.name!=="InstancedMesh")return;const i=this.writer,n=i.extensionsUsed,o={};t.extensions=t.extensions||{},t.extensions[this.name]=o;let r=new c.Matrix4;const a=new Array,l=new Array,h=new Array;for(let m=0;m<e.count;m++){e.getMatrixAt(m,r);let y=new c.Vector3,_=new c.Quaternion,g=new c.Vector3;r.decompose(y,_,g),a.push(y.x,y.y,y.z),l.push(_.x,_.y,_.z,_.w),h.push(g.x,g.y,g.z)}const d=new Float32Array(a),u=new Float32Array(l),p=new Float32Array(h);o.attributes={TRANSLATION:i.processAccessor(new c.BufferAttribute(d,3)),ROTATION:i.processAccessor(new c.BufferAttribute(u,4)),SCALE:i.processAccessor(new c.BufferAttribute(p,3))},n[this.name]=!0}}var vO=Object.defineProperty,Hv=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&vO(e,t,n),n};const nl=w("debugreflectionprobe"),E_=w("noreflectionprobe"),Tf=Symbol("reflectionProbeKey"),R_=Symbol("original material"),dg=class Yn extends k{static _probes=new Map;static isUsingReflectionProbe(e){return!!(e[Tf]||e[R_]?.[Tf])}static get(e,t,i,n){if(!e||e.isObject3D!==!0||E_)return null;const o=Yn._probes.get(t);if(o){for(const r of o)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return nl&&console.log("Found reflection probe",e.name,r.name),r}}return nl&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;set texture(e){if(e&&!(e instanceof c.Texture)){console.error("ReflectionProbe.texture must be a Texture",e);return}this._texture=e,e&&(e.mapping=c.EquirectangularReflectionMapping,e.colorSpace=c.LinearSRGBColorSpace,e.needsUpdate=!0)}get texture(){return this._texture}center;size;_boxHelper;isInBox(e){return this._boxHelper?.isInBox(e)}constructor(){super(),Yn._probes.has(this.context)||Yn._probes.set(this.context,[]),Yn._probes.get(this.context)?.push(this)}awake(){this._boxHelper=this.gameObject.addComponent(nt),this._boxHelper.updateBox(!0),nl&&this._boxHelper.showHelper(5592320,!0),this._texture&&(this._texture.mapping=c.EquirectangularReflectionMapping,this._texture.colorSpace=c.LinearSRGBColorSpace,this._texture.needsUpdate=!0)}start(){!this._texture&&A()&&(console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`),he("ReflectionProbe configuration hint: See browser console for details"))}onDestroy(){const e=Yn._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}static _rendererMaterialsCache=new Map;onSet(e){if(E_||!this.enabled||e.sharedMaterials?.length<=0||!this.texture)return;let t=Yn._rendererMaterialsCache.get(e);t||(t=[],Yn._rendererMaterialsCache.set(e,t));for(let i=0;i<e.sharedMaterials.length;i++){const n=e.sharedMaterials[i];if(!n||n.envMap===void 0||n instanceof c.MeshBasicMaterial)continue;let o=t[i];const r=n===o?.copy,a=!o||o.material.uuid!==n.uuid||o.copy.version!==n.version;if(!r&&a){if(nl){let d="";o?o.material!==n?d="reference changed; cached instance?: "+r:o.copy.version!==n.version&&(d="version changed"):d="not cached",console.warn("Cloning material",n.name,n.version,"Reason:",d,`
|
|
990
|
+
`,a,e,r))),e.userData=e.userData||{},e.userData[Ro]=e.userData[Ro]||[],e.userData[Ro].push(r)}await Promise.all(n).catch(o=>{console.error("Error while loading components",o)})}}}const M_="NEEDLE_gameobject_data";class aO{get name(){return M_}parser;constructor(e){this.parser=e}afterRoot(e){const t=[];for(let i=0;i<this.parser.json.nodes?.length;i++){const n=this.parser.json.nodes[i];if(n&&n.extensions){const o=n.extensions[M_];if(o){const r=this.findAndApplyExtensionData(i,o);t.push(r)}}}return Promise.all(t).then(()=>null)}async findAndApplyExtensionData(e,t){const i=await this.parser.getDependency("node",e);i&&this.applyExtensionData(i,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.hideFlags=0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const k_="NEEDLE_lighting_settings",Gr=w("debugenvlight");class lO{get name(){return k_}parser;sourceId;context;constructor(e,t,i){this.parser=e,this.sourceId=t,this.context=i}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[k_];if(i){Gr&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',i);let n;if(e.scene.children.length===1){const o=e.scene.children[0];n=S.addComponent(o,Id,{},{callAwake:!1})}else{const o=new c.Object3D;o.name="LightSettings "+this.sourceId,e.scene.add(o),n=S.addComponent(o,Id,{},{callAwake:!1})}n.sourceId=this.sourceId,n.ambientIntensity=i.ambientIntensity,n.ambientLight=new c.Color().fromArray(i.ambientLight),Array.isArray(i.ambientTrilight)&&(n.ambientTrilight=i.ambientTrilight.map(o=>new c.Color().fromArray(o))),n.ambientMode=i.ambientMode,n.environmentReflectionSource=i.environmentReflectionSource}}return null}}ae.registerCallback(re.ContextCreated,s=>{const e=s.context,t=S.findObjectOfType(Id,e);t?.sourceId&&(t.enabled=!0)});class Id extends k{ambientMode=aa.Skybox;ambientLight;ambientTrilight;ambientIntensity=1;environmentReflectionSource=Md.Skybox;_hasReflection=!1;_ambientLightObj;_hemisphereLightObj;awake(){if(this.sourceId){const t=this.environmentReflectionSource===Md.Skybox?wn.Skybox:wn.Reflection,i=this.context.lightmaps.tryGet(this.sourceId,t,0);this._hasReflection=i!=null,i&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,i)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),Gr&&window.addEventListener("keydown",t=>{if(!this.destroyed)switch(t.key){case"l":this.enabled=!this.enabled;break}});const e=this.gameObject.userData?.components;if(e){const t=e.indexOf(this);e.splice(t,1),e.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*D.lerp(0,1.33,t)}onEnable(){if(Gr&&console.warn("💡🟡 >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==aa.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new c.AmbientLight(this.ambientLight,this.ambientIntensity*e),Gr&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj)}else if(this.ambientMode===aa.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],i=this.calculateIntensityFactor(t);this._hemisphereLightObj=new c.HemisphereLight(t,e,this.ambientIntensity*i),this.gameObject.add(this._hemisphereLightObj),Gr&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,i)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent();this.sourceId&&(this.context.domElement.getAttribute("environment-image")||this.context.sceneLighting.internalEnableReflection(this.sourceId))}onDisable(){Gr&&console.warn("💡⚫ <<< Disable lighting:",this.sourceId,this),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}const Ef=w("debugstencil");function cO(s,e){return(s&1<<e.layer)!=0}const hO=Symbol("stencils");class Ns{get name(){return"NEEDLE_render_objects"}static stencils={};static applyStencil(e){if(!e)return;const t=e.sourceId;if(Ef&&console.log(t,Ns.stencils),!t)return;const i=Ns.stencils[t];if(i)for(let n=i.length-1;n>=0;n--){const o=i[n];if(cO(o.layer,e)){Ef&&console.log(o),setTimeout(()=>{Ii()&&iu(e.gameObject)&&(he("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",e))},500);for(let r=0;r<e.sharedMaterials.length;r++){let a=e.sharedMaterials[r];a&&(a=a.clone(),a[hO]=!0,a.stencilWrite=!0,a.stencilWriteMask=255,a.stencilFuncMask=255,a.stencilRef=o.value,a.stencilFunc=o.compareFunc,a.stencilZPass=o.passOp,a.stencilFail=o.failOp,a.stencilZFail=o.zFailOp,e.sharedMaterials[r]=a)}e.gameObject.renderOrder=o.event*1e3+o.index*50;break}}}parser;source;constructor(e,t){this.parser=e,this.source=t}afterRoot(e){const t=this.parser.json.extensions;if(t){const i=t[uO];if(i){Ef&&console.log(i);const n=i.stencil;if(n&&Array.isArray(n))for(const o of n){const r={...o};r.compareFunc=dO(r.compareFunc),r.passOp=Rf(r.passOp),r.failOp=Rf(r.failOp),r.zFailOp=Rf(r.zFailOp),Ns.stencils[this.source]||(Ns.stencils[this.source]=[]),Ns.stencils[this.source].push(r)}}}return null}}function Rf(s){switch(s){case 0:return c.KeepStencilOp;case 1:return c.ZeroStencilOp;case 2:return c.ReplaceStencilOp;case 3:return c.IncrementStencilOp;case 4:return c.DecrementStencilOp;case 6:return c.IncrementWrapStencilOp;case 7:return c.DecrementWrapStencilOp;case 5:return c.InvertStencilOp}return 0}function dO(s){switch(s){case 1:return c.NeverStencilFunc;case 2:return c.LessStencilFunc;case 3:return c.EqualStencilFunc;case 4:return c.LessEqualStencilFunc;case 5:return c.GreaterStencilFunc;case 6:return c.NotEqualStencilFunc;case 7:return c.GreaterEqualStencilFunc;case 8:return c.AlwaysStencilFunc}return c.NeverStencilFunc}const uO="NEEDLE_render_objects";var Nv=(s=>(s[s.INT=5124]="INT",s[s.FLOAT=5126]="FLOAT",s[s.FLOAT_VEC2=35664]="FLOAT_VEC2",s[s.FLOAT_VEC3=35665]="FLOAT_VEC3",s[s.FLOAT_VEC4=35666]="FLOAT_VEC4",s[s.INT_VEC2=35667]="INT_VEC2",s[s.INT_VEC3=35668]="INT_VEC3",s[s.INT_VEC4=35669]="INT_VEC4",s[s.BOOL=35670]="BOOL",s[s.BOOL_VEC2=35671]="BOOL_VEC2",s[s.BOOL_VEC3=35672]="BOOL_VEC3",s[s.BOOL_VEC4=35673]="BOOL_VEC4",s[s.FLOAT_MAT2=35674]="FLOAT_MAT2",s[s.FLOAT_MAT3=35675]="FLOAT_MAT3",s[s.FLOAT_MAT4=35676]="FLOAT_MAT4",s[s.SAMPLER_2D=35678]="SAMPLER_2D",s[s.SAMPLER_3D=35680]="SAMPLER_3D",s[s.SAMPLER_CUBE=35681]="SAMPLER_CUBE",s[s.UNKNOWN=0]="UNKNOWN",s))(Nv||{});const _n=w("debugcustomshader"),Dr="NEEDLE_techniques_webgl";class fO{objectToWorldMatrix=new c.Matrix4;worldToObjectMatrix=new c.Matrix4;objectToWorld=new Array;worldToObject=new Array;updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),Od(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),Od(this.worldToObjectMatrix,this.worldToObject)}}class ye extends c.RawShaderMaterial{identifier;onBeforeRenderSceneCallback=this.onBeforeRenderScene.bind(this);clone(){const e=super.clone();return Vv(e),e}constructor(e,...t){super(...t),this.identifier=e,_n&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName],(this.depthTextureUniform||this.opaqueTextureUniform)&&z.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}dispose(){super.dispose();const e=z.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);e>=0&&z.Current.pre_render_callbacks.splice(e,1)}_sphericalHarmonicsName="unity_SpecCube0";_objToWorldName="hlslcc_mtx4x4unity_ObjectToWorld";_worldToObjectName="hlslcc_mtx4x4unity_WorldToObject";static viewProjection=new c.Matrix4;static _viewProjectionValues=[];_viewProjectionName="hlslcc_mtx4x4unity_MatrixVP";static viewMatrix=new c.Matrix4;static _viewMatrixValues=[];_viewMatrixName="hlslcc_mtx4x4unity_MatrixV";static _worldSpaceCameraPosName="_WorldSpaceCameraPos";static _worldSpaceCameraPos=new c.Vector3;static _mainLightColor=new c.Vector4;static _mainLightPosition=new c.Vector3;static _lightData=new c.Vector4;_rendererData=new fO;get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&z.Current.setRequireColor(!0),this.depthTextureUniform&&z.Current.setRequireDepth(!0)}onBeforeRender(e,t,i,n,o,r){n.attributes.tangent||n.computeTangents(),this.onUpdateUniforms(i,o)}onUpdateUniforms(e,t){const i=z.Current;if(e&&(ye.viewProjection&&this.uniforms[this._viewProjectionName]&&(ye.viewProjection.copy(e.projectionMatrix).multiply(e.matrixWorldInverse),Od(ye.viewProjection,ye._viewProjectionValues)),ye.viewMatrix&&this.uniforms[this._viewMatrixName]&&(ye.viewMatrix.copy(e.matrixWorldInverse),Od(ye.viewMatrix,ye._viewMatrixValues)),this.uniforms[ye._worldSpaceCameraPosName]&&ye._worldSpaceCameraPos.setFromMatrixPosition(e.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=i.sceneLighting.timeVec4),this.uniforms._Time){const a=this.uniforms._Time.value;a.x=i.sceneLighting.timeVec4.x/20,a.y=i.sceneLighting.timeVec4.x,a.z=i.sceneLighting.timeVec4.x*2,a.w=i.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const a=this.uniforms._SinTime.value;a.x=Math.sin(i.sceneLighting.timeVec4.x/8),a.y=Math.sin(i.sceneLighting.timeVec4.x/4),a.z=Math.sin(i.sceneLighting.timeVec4.x/2),a.w=Math.sin(i.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const a=this.uniforms._CosTime.value;a.x=Math.cos(i.sceneLighting.timeVec4.x/8),a.y=Math.cos(i.sceneLighting.timeVec4.x/4),a.z=Math.cos(i.sceneLighting.timeVec4.x/2),a.w=Math.cos(i.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const a=this.uniforms.unity_DeltaTime.value;a.x=i.time.deltaTime,a.y=1/i.time.deltaTime,a.z=i.time.smoothedDeltaTime,a.w=1/i.time.smoothedDeltaTime}const n=i.mainLight;if(n){const a=X(n.gameObject,ye._mainLightPosition);this.uniforms._MainLightPosition={value:a.normalize()},ye._mainLightColor.set(n.color.r,n.color.g,n.color.b,0),this.uniforms._MainLightColor={value:ye._mainLightColor};const l=n.intensity;ye._lightData.z=l,this.uniforms.unity_LightData={value:ye._lightData}}if(e&&(ye.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=ye._viewProjectionValues),ye.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=ye._viewMatrixValues),this.uniforms[ye._worldSpaceCameraPosName]&&(this.uniforms[ye._worldSpaceCameraPosName]={value:ye._worldSpaceCameraPos}),i.mainCameraComponent)){if(this.uniforms._ProjectionParams){const a=this.uniforms._ProjectionParams.value;a.x=1,a.y=i.mainCameraComponent.nearClipPlane,a.z=i.mainCameraComponent.farClipPlane,a.w=1/a.z,this.uniforms._ProjectionParams.value=a}if(this.uniforms._ZBufferParams){const a=this.uniforms._ZBufferParams.value,l=i.mainCameraComponent;a.x=1-l.farClipPlane/l.nearClipPlane,a.y=l.farClipPlane/l.nearClipPlane,a.z=a.x/l.farClipPlane,a.w=a.y/l.farClipPlane,this.uniforms._ZBufferParams.value=a}if(this.uniforms._ScreenParams){const a=this.uniforms._ScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScreenParams.value=a}if(this.uniforms._ScaledScreenParams){const a=this.uniforms._ScaledScreenParams.value;a.x=i.domWidth,a.y=i.domHeight,a.z=1+1/a.x,a.w=1+1/a.y,this.uniforms._ScaledScreenParams.value=a}}const o=this.depthTextureUniform;o&&(o.value=i.depthTexture);const r=this.opaqueTextureUniform;if(r&&(r.value=i.opaqueColorTexture),t){const a=this._rendererData;a.updateFrom(t),this.uniforms[this._worldToObjectName].value=a.worldToObject,this.uniforms[this._objToWorldName].value=a.objectToWorld}this.uniformsNeedUpdate=!0}}class pO{get name(){return Dr}parser;identifier;constructor(e,t){this.parser=e,this.identifier=t}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return _n&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[Dr])return _n&&console.log(`Material ${e} does not use NEEDLE_techniques_webgl`),null;_n&&console.log(`Material ${e} uses NEEDLE_techniques_webgl`,t);const i=t.extensions[Dr].technique;if(i<0)return console.debug(`Material ${e} does not have a valid technique index`),null;const n=this.parser.json.extensions[Dr];if(!n)return _n?console.error("Missing shader data",this.parser.json.extensions):console.debug("Missing custom shader data in parser.json.extensions"),null;_n&&console.log(n);const o=n.techniques[i];return o?new Promise(async(r,a)=>{const l=await a1(n,o.program),h=l?.fragmentShader,d=l?.vertexShader;if(!h||!d)return a();_n&&console.log("loadMaterial",t,l);const u={},p=o.uniforms;(d.includes("_Time")||h.includes("_Time"))&&(u._Time={value:new c.Vector4(0,0,0,0)}),(d.includes("_SinTime")||h.includes("_SinTime"))&&(u._SinTime={value:new c.Vector4(0,0,0,0)}),(d.includes("_CosTime")||h.includes("_CosTime"))&&(u._CosTime={value:new c.Vector4(0,0,0,0)}),(d.includes("unity_DeltaTime")||h.includes("unity_DeltaTime"))&&(u.unity_DeltaTime={value:new c.Vector4(0,0,0,0)});for(const v in p){const b=v;switch(b){case"_TimeParameters":const x=new c.Vector4;u[b]={value:x};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":u[b]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":u[b]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":u[b]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":u[b]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":u[b]={value:null};break}}let m=!1;if(t.extensions&&t.extensions[Dr]){const v=t.extensions[Dr];if(v.technique===i){_n&&console.log(t.name,"Material Properties",v);for(const b in v.values){const x=v.values[b];if(typeof x=="string"){if(x.startsWith("/textures/")){const R=x.substring(10),O=Number.parseInt(R);if(O>=0){const M=await this.parser.getDependency("texture",O);M instanceof c.Texture&&(M.colorSpace=c.LinearSRGBColorSpace,M.needsUpdate=!0),u[b]={value:M};continue}}switch(b){case"alphaMode":x==="BLEND"&&(m=!0);continue}}if(Array.isArray(x)&&x.length===4){u[b]={value:new c.Vector4(x[0],x[1],x[2],x[3])};continue}u[b]={value:x}}}}const y=new ye(this.identifier,{name:t.name??"",uniforms:u,vertexShader:d,fragmentShader:h,lights:!1});switch(y.glslVersion=c.GLSL3,y.vertexShader=y.vertexShader.replace("#version 300 es",""),y.fragmentShader=y.fragmentShader.replace("#version 300 es",""),u._Cull?.value){case 0:y.side=c.DoubleSide;break;case 1:y.side=c.BackSide;break;case 2:y.side=c.FrontSide;break;default:y.side=c.FrontSide;break}switch(u._ZTest?.value){case 3:y.depthTest=!0,y.depthFunc=c.EqualDepth;break;case 6:y.depthTest=!0,y.depthFunc=c.NotEqualDepth;break;case 2:y.depthTest=!0,y.depthFunc=c.LessDepth;break;case 4:y.depthTest=!0,y.depthFunc=c.LessEqualDepth;break;case 5:y.depthTest=!0,y.depthFunc=c.GreaterDepth;break;case 7:y.depthTest=!0,y.depthFunc=c.GreaterEqualDepth;break;case 8:y.depthTest=!1,y.depthFunc=c.AlwaysDepth;break}y.transparent=m,m&&(y.depthWrite=!1),o1(u),y.onUpdateUniforms();for(const v in p){const b=v,x=p[v].type;if(u[b]?.value===void 0)switch(x){case Nv.SAMPLER_2D:u[b]={value:n1},console.warn("Missing/unassigned texture, fallback to white: "+b);break;default:b==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+b,p[v]);break}}_n&&console.log(y.uuid,u),Vv(y),r(y)}):null}}function Vv(s){if(s.uniforms){_n&&console.log("Uniforms:",s.uniforms);for(const t in s.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,i){Object.getOwnPropertyDescriptor(s,t)||Object.defineProperty(s,t,{get:()=>s.uniforms[i].value,set:n=>{s.uniforms[i].value=n,s.needsUpdate=!0}})}}const mO=w("debugextensions");let jd;const gO=Promise.resolve().then(()=>require("./vendor-CPuBPspY.umd.cjs")).then(s=>s.index$2).then(async s=>(jd=s.GLTFAnimationPointerExtension,jd)).catch(s=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three-animationpointer for full KHR_animation support",s)}),tr=new Array;function yO(s){tr.includes(s)||tr.push(s)}function _O(s){const e=tr.indexOf(s);e>=0&&tr.splice(e,1)}function cg(s){if(s instanceof q.GLTFLoader){const e=new zv;return s.register(t=>(e.parser=t,e)),e}return null}class bO{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function Bd(s,e,t){const i=t.indexOf("?");i>=0&&(t=t.substring(0,i)),s.register(n=>new aO(n)),s.register(n=>new EC(n)),s.register(n=>new JC(n,e.lightmaps,t)),s.register(n=>new lO(n,t,e)),s.register(n=>new pO(n,t)),s.register(n=>new Ns(n,t)),s.register(n=>new ne.NEEDLE_progressive(n)),s.register(n=>new nO(n)),c0()&&s.register(n=>new oa(n)),await gO.catch(n=>{}),s.register(n=>{if(jd){const o=new jd(n);return o.setAnimationPointerResolver.bind(o)(new bO),o}else return(mO||A())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}});for(const n of tr)n.onImport&&n.onImport(s,t,e)}function hg(s,e){for(const t of tr)t.onExport&&t.onExport(s,e)}function $v(s,e,t){for(const i of tr)i.onLoaded&&i.onLoaded(s,e,t)}class Wv{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(e.constructor.name!=="InstancedMesh")return;const i=this.writer,n=i.extensionsUsed,o={};t.extensions=t.extensions||{},t.extensions[this.name]=o;let r=new c.Matrix4;const a=new Array,l=new Array,h=new Array;for(let m=0;m<e.count;m++){e.getMatrixAt(m,r);let y=new c.Vector3,_=new c.Quaternion,g=new c.Vector3;r.decompose(y,_,g),a.push(y.x,y.y,y.z),l.push(_.x,_.y,_.z,_.w),h.push(g.x,g.y,g.z)}const d=new Float32Array(a),u=new Float32Array(l),p=new Float32Array(h);o.attributes={TRANSLATION:i.processAccessor(new c.BufferAttribute(d,3)),ROTATION:i.processAccessor(new c.BufferAttribute(u,4)),SCALE:i.processAccessor(new c.BufferAttribute(p,3))},n[this.name]=!0}}var vO=Object.defineProperty,Hv=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&vO(e,t,n),n};const nl=w("debugreflectionprobe"),E_=w("noreflectionprobe"),Tf=Symbol("reflectionProbeKey"),R_=Symbol("original material"),dg=class Yn extends k{static _probes=new Map;static isUsingReflectionProbe(e){return!!(e[Tf]||e[R_]?.[Tf])}static get(e,t,i,n){if(!e||e.isObject3D!==!0||E_)return null;const o=Yn._probes.get(t);if(o){for(const r of o)if(r.__didAwake||r.__internalAwake(),r.activeAndEnabled){if(n){if(r.gameObject===n)return r}else if(r.isInBox(e))return nl&&console.log("Found reflection probe",e.name,r.name),r}}return nl&&console.debug("Did not find reflection probe",e.name,i,e),null}_texture;set texture(e){if(e&&!(e instanceof c.Texture)){console.error("ReflectionProbe.texture must be a Texture",e);return}this._texture=e,e&&(e.mapping=c.EquirectangularReflectionMapping,e.colorSpace=c.LinearSRGBColorSpace,e.needsUpdate=!0)}get texture(){return this._texture}center;size;_boxHelper;isInBox(e){return this._boxHelper?.isInBox(e)}constructor(){super(),Yn._probes.has(this.context)||Yn._probes.set(this.context,[]),Yn._probes.get(this.context)?.push(this)}awake(){this._boxHelper=this.gameObject.addComponent(nt),this._boxHelper.updateBox(!0),nl&&this._boxHelper.showHelper(5592320,!0),this._texture&&(this._texture.mapping=c.EquirectangularReflectionMapping,this._texture.colorSpace=c.LinearSRGBColorSpace,this._texture.needsUpdate=!0)}start(){!this._texture&&A()&&(console.warn(`[ReflectionProbe] Missing texture. Please assign a custom cubemap texture. To use reflection probes assign them to your renderer's "anchor" property.`),he("ReflectionProbe configuration hint: See browser console for details"))}onDestroy(){const e=Yn._probes.get(this.context);if(e){const t=e.indexOf(this);t>=0&&e.splice(t,1)}}static _rendererMaterialsCache=new Map;onSet(e){if(E_||!this.enabled||e.sharedMaterials?.length<=0||!this.texture)return;let t=Yn._rendererMaterialsCache.get(e);t||(t=[],Yn._rendererMaterialsCache.set(e,t));for(let i=0;i<e.sharedMaterials.length;i++){const n=e.sharedMaterials[i];if(!n||n.envMap===void 0||n instanceof c.MeshBasicMaterial)continue;let o=t[i];const r=n===o?.copy,a=!o||o.material.uuid!==n.uuid||o.copy.version!==n.version;if(!r&&a){if(nl){let d="";o?o.material!==n?d="reference changed; cached instance?: "+r:o.copy.version!==n.version&&(d="version changed"):d="not cached",console.warn("Cloning material",n.name,n.version,"Reason:",d,`
|
|
991
991
|
`,n.uuid,`
|
|
992
992
|
`,o?.copy.uuid,`
|
|
993
993
|
`,e.name)}const h=n.clone();h.version=n.version,o?(o.copy=h,o.material=n):(o={material:n,copy:h},t.push(o)),h[Tf]=this,h[R_]=n,nl&&console.log("Set reflection",e.name,e.guid)}o&&o.copy&&(o.copy.onBeforeCompile=n.onBeforeCompile);const l=o?.copy;l.envMap=this.texture,e.sharedMaterials[i]=l}}onUnset(e){const t=Yn._rendererMaterialsCache.get(e);if(t)for(let i=0;i<t.length;i++){const n=t[i];e.sharedMaterials[i]=n.material}}};Hv([f(c.Vector3)],dg.prototype,"center");Hv([f(c.Vector3)],dg.prototype,"size");let sc=dg;const Nt=w("debuginstancing");class ir{static instance=new ir;static getStartInstanceCount=e=>4;objs=[];setup(e,t,i,n,o,r=0){e.applySettings(t);const a=this.tryCreateOrAddInstance(t,i,o);if(a){n===null&&(n=[]),n.push(a),ne.NEEDLE_progressive.assignTextureLOD(a.renderer.material,0);for(let l=0;l<e.sharedMeshes.length;l++){const h=e.sharedMeshes[l],d=h.geometry;ne.NEEDLE_progressive.assignMeshLOD(h,0).then(u=>{u&&e.activeAndEnabled&&d!=u&&a.setGeometry(u)})}}else if(r<=0&&t.type!=="Mesh"){const l=r+1;for(const h of t.children)n=this.setup(e,h,i,n,o,l)}return r===0&&o.useMatrixWorldAutoUpdate&&n&&n.length>=0&&this.autoUpdateInstanceMatrix(t),n}tryCreateOrAddInstance(e,t,i){if(e.type==="Mesh"){const n=i.foundMeshes;if(i.foundMeshes+=1,!i.rend.enableInstancing)return null;if(i.rend.enableInstancing!==!0){if(n>=i.rend.enableInstancing.length)return Nt&&console.error("Something is wrong with instance setup",e,i.rend.enableInstancing,n),null;if(!i.rend.enableInstancing[n])return null}const o=e,r=o.material;for(const u of this.objs){if(!u.canAdd(o.geometry,r))continue;return u.addInstance(o)}let a=ir.getStartInstanceCount(e);(!a||a<0)&&(a=4);let l=e.name;l?.length||(l=bb());const h=new wO(l,o.geometry,r,a,t);return this.objs.push(h),h.addInstance(o)}return null}autoUpdateInstanceMatrix(e){const t=e.matrixWorld.multiplyMatrices.bind(e.matrixWorld),i=e.matrixWorld.clone(),n=(o,r)=>{const a=t(o,r);return(e[Zl]||i.equals(a)===!1)&&(i.copy(a),e[Zl]=!0),a};e.matrixWorld.multiplyMatrices=n}}class Xo{static all=[];get name(){return this.object.name}get isActive(){return this.__instanceIndex>=0}get vertexCount(){return this.object.geometry.attributes.position.count}get maxVertexCount(){return Math.max(this.meshInformation.vertexCount,this.vertexCount)}get reservedVertexCount(){return this.__reservedVertexRange}get indexCount(){return this.object.geometry.index?this.object.geometry.index.count:0}get maxIndexCount(){return Math.max(this.meshInformation.indexCount,this.indexCount)}get reservedIndexCount(){return this.__reservedIndexRange}object;renderer;__instanceIndex=-1;__reservedVertexRange=0;__reservedIndexRange=0;__geometryIndex=-1;meshInformation;constructor(e,t){this.__instanceIndex=-1,this.object=e,this.renderer=t,e[p0]=t,this.meshInformation=Ao(e.geometry),Xo.all.push(this)}updateMeshInformation(){const e=Ao(this.object.geometry),t=this.meshInformation.vertexCount,i=this.meshInformation.indexCount;return Object.assign(this.meshInformation,e),t!==this.meshInformation.vertexCount||i!==this.meshInformation.indexCount}updateInstanceMatrix(e=!1,t=!0){this.__instanceIndex<0||(t&&this.object.updateWorldMatrix(!0,e),this.renderer.updateInstance(this.object.matrixWorld,this.__instanceIndex))}setMatrix(e){this.__instanceIndex<0||this.renderer.updateInstance(e,this.__instanceIndex)}setGeometry(e){if(this.__geometryIndex<0)return!1;const t=this;if(this.vertexCount>this.__reservedVertexRange)return i(`Instancing: Can not update geometry (${this.name}), reserved vertex range is too small: ${this.__reservedVertexRange.toLocaleString()} < ${this.vertexCount.toLocaleString()} vertices for ${this.name}`);if(this.indexCount>this.__reservedIndexRange)return i(`Instancing: Can not update geometry (${this.name}), reserved index range is too small: ${this.__reservedIndexRange.toLocaleString()} < ${this.indexCount.toLocaleString()} indices for ${this.name}`);return this.renderer.updateGeometry(e,this.__geometryIndex);function i(n){return t.updateMeshInformation()&&(t.renderer.remove(t,!0),t.renderer.add(t))?!0:((A()||Nt)&&console.error(n),!1)}}add(){this.__instanceIndex>=0||(this.renderer.add(this),S.markAsInstancedRendered(this.object,!0))}remove(e){if(!(this.__instanceIndex<0)&&(this.renderer.remove(this,e),S.markAsInstancedRendered(this.object,!1),e)){const t=Xo.all.indexOf(this);t>=0&&Xo.all.splice(t,1)}}}class wO{get batchedMesh(){return this._batchedMesh}get visible(){return this._batchedMesh.visible}set visible(e){this._batchedMesh.visible=e}get castShadow(){return this._batchedMesh.castShadow}set castShadow(e){this._batchedMesh.castShadow=e}set receiveShadow(e){this._batchedMesh.receiveShadow=e}allowResize=!0;name="";geometry;material;get count(){return this._currentInstanceCount}updateBounds(e=!0,t=!0){if(this._needUpdateBounds=!1,e&&this._batchedMesh.computeBoundingBox(),t&&this._batchedMesh.computeBoundingSphere(),Nt&&this._batchedMesh.boundingSphere){const i=this._batchedMesh.boundingSphere;I.DrawWireSphere(i.center,i.radius,65280)}}_context;_batchedMesh;_handles=[];_geometryIds=new Map;_maxInstanceCount;_currentInstanceCount=0;_currentVertexCount=0;_currentIndexCount=0;_maxVertexCount;_maxIndexCount;static nullMatrix=new c.Matrix4;canAdd(e,t){return this._maxVertexCount>1e7||t!==this.material||!this.validateGeometry(e)?!1:!!(!this.mustGrow(e)||this.allowResize)}_needUpdateBounds=!1;_debugMaterial=null;constructor(e,t,i,n,o){this.name=e,this.geometry=t,this.material=i,this._context=o,this._maxInstanceCount=Math.max(2,n),Nt&&(this._debugMaterial=T_());const r=this.tryEstimateVertexCountSize(this._maxInstanceCount,[t],n);this._maxVertexCount=r.vertexCount,this._maxIndexCount=r.indexCount,this._batchedMesh=new c.BatchedMesh(this._maxInstanceCount,this._maxVertexCount,this._maxIndexCount,this._debugMaterial??this.material),this._batchedMesh[vl]=!0,this._batchedMesh.visible=!0,this._context.scene.add(this._batchedMesh),i instanceof c.RawShaderMaterial&&(i.defines.USE_INSTANCING=!0,i.needsUpdate=!0),o.pre_render_callbacks.push(this.onBeforeRender),o.post_render_callbacks.push(this.onAfterRender),Nt&&console.log(`Instanced renderer created with ${this._maxInstanceCount} instances, ${this._maxVertexCount} max vertices and ${this._maxIndexCount} max indices for "${e}"`)}dispose(){Nt&&console.warn("Dispose instanced renderer",this.name),this._context.scene.remove(this._batchedMesh),this._batchedMesh.dispose(),this._batchedMesh=null,this._handles=[]}addInstance(e){const t=new Xo(e,this);e.castShadow===!0&&this._batchedMesh.castShadow===!1&&(this._batchedMesh.castShadow=!0),e.receiveShadow===!0&&this._batchedMesh.receiveShadow===!1&&(this._batchedMesh.receiveShadow=!0);try{this.add(t)}catch(i){if(console.error(`Failed adding mesh to instancing (object name: "${e.name}", instances: ${this._currentInstanceCount.toLocaleString()}/${this._maxInstanceCount.toLocaleString()}, vertices: ${this._currentVertexCount.toLocaleString()}/${this._maxVertexCount.toLocaleString()}, indices: ${this._currentIndexCount.toLocaleString()}/${this._maxIndexCount.toLocaleString()})
|
|
@@ -1414,7 +1414,7 @@ To allow joining a room without a query parameter you can set "requireRoomParame
|
|
|
1414
1414
|
Please choose one of the following options to fix this:
|
|
1415
1415
|
A) Set a room name in the SyncedRoom component
|
|
1416
1416
|
B) Set a room name in the URL parameter "?`+this.urlParameterName+`=my_room"
|
|
1417
|
-
C) Set "joinRandomRoom" to true`),!1):(ep&&console.log("Join "+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0))}_lastPingTime=0;_lastRoomTime=-1;_userWantsToBeInARoom=!1;update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):A()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const e=window.location.search,t=new URLSearchParams(e);return t.has(this.urlParameterName)&&t.delete(this.urlParameterName),t.set(Jf,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+t.toString()}return null}setRandomRoomUrlParameter(){const e=fc(),t=this.generateRoomName();w(this.urlParameterName)?e.set(this.urlParameterName,t):e.append(this.urlParameterName,t),nm(t,e)}generateRoomName(){let e="";for(let t=0;t<6;t++)e+=Math.floor(Math.random()*10).toFixed(0);return e}_roomButton;_roomButtonIconJoin;_roomButtonIconLeave;createRoomButton(){if(this._roomButton)return this._roomButton;const e=document.createElement("button");return this._roomButton=e,e.classList.add("create-room-button"),e.setAttribute("priority","90"),e.onclick=()=>{if(this.context.connection.isInRoom)this.urlParameterName&&Ql(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1;else{if(this.urlParameterName){const t=w(this.urlParameterName);(!t||t===!0)&&(this._lastJoinedRoom?Ql(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())}this.tryJoinRoom()}},this._roomButtonIconJoin=pt("group"),this._roomButtonIconLeave=pt("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(Q.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(Q.LeftRoom,this.updateRoomButtonState),e}updateRoomButtonState=()=>{this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",this._roomButtonIconJoin?.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",this._roomButtonIconLeave?.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))};destroyRoomButton(){this.context.connection.stopListen(Q.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(Q.LeftRoom,this.updateRoomButtonState)}_viewOnlyButton;onEnableViewOnlyButton(){this.context.connection.isConnected?this.onCreateViewOnlyButton():(this.context.connection.stopListen(Q.JoinedRoom,this.onCreateViewOnlyButton),this.context.connection.beginListen(Q.JoinedRoom,this.onCreateViewOnlyButton))}onDisableViewOnlyButton(){this.context.connection.stopListen(Q.JoinedRoom,this.onCreateViewOnlyButton),this._viewOnlyButton?.remove()}onCreateViewOnlyButton=()=>{if(!this._viewOnlyButton){const e=document.createElement("button");this._viewOnlyButton=e,e.classList.add("view-only-button"),e.setAttribute("priority","90"),e.onclick=()=>{const t=this.getViewOnlyUrl();t?.length?navigator.canShare({url:t})?navigator.share({url:t})?.catch(i=>{console.warn(i)}):(navigator.clipboard.writeText(t),Se("View only URL copied to clipboard")):he("Could not create view only URL")},e.title="Copy the view only URL: A page accessed by the view only URL can not be modified by visiting users.",e.textContent="Share View URL",e.prepend(pt("visibility"))}this.context.menu.appendChild(this._viewOnlyButton)}}_o([f()],fn.prototype,"roomName",2);_o([f()],fn.prototype,"urlParameterName",2);_o([f()],fn.prototype,"joinRandomRoom",2);_o([f()],fn.prototype,"requireRoomParameter",2);_o([f()],fn.prototype,"autoRejoin",2);_o([f()],fn.prototype,"createJoinButton",2);_o([f()],fn.prototype,"createViewOnlyButton",2);_o([f()],fn.prototype,"roomPrefix",1);function LE(){const s=w("testwindowcount")||0;s&&s>0&&DE(s)}function DE(s){if(w("testwindow"))return null;const e=new URL(window.location.href);lp(e.searchParams,RP,1),lp(e.searchParams,"testwindow",1);const t=e.toString(),i=[];window.onbeforeunload=()=>{for(const l of i)l.close()};const n=.05,o=128;let r=0,a=0;for(let l=0;l<s;l++){r*o+o*.01>=window.innerWidth&&(a+=1,r=0);const h=r*(o*(1+n))+window.screenLeft,d=a*(o*(1+n))+window.screenTop+90+60*a;r+=1;const u=window.open(t,"test window "+l,`popup=yes width=${o} height=${o} top=${d} left=${h}`);if(!u){console.warn("Failed to open window");continue}i.push(u),u.onload=()=>{u.onbeforeunload=()=>{for(let p=0;p<i.length;p++){const m=i[p];m!==u&&m.close()}i.length=0}}}return i}class ty extends k{awake(){LE()}}class iy extends k{transformsPerFrame=10;interval=0;useFlatbuffers=!0;awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(tc,e=>{});else{this.models=[];for(let e=0;e<this.transformsPerFrame;e++)this.models.push(new IE(this.context.connection.connectionId+"_simulatedTransform_"+e,this))}}builder=null;models=null;update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new se.Builder(1024));const e=this.builder;for(let t=0;t<this.transformsPerFrame;t++){e.clear();const i=gv(this.context.connection.connectionId,this);this.context.connection.sendBinary(i)}}else if(this.models)for(let e=0;e<this.models.length;e++){const t=this.models[e];t.dontSave=!0,t.update(this,null),this.context.connection.send("TestSimulateUserData-"+e,t)}}}}class IE{guid;fast=!1;position;rotation;velocity=void 0;dontSave;isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}constructor(e,t){this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}static temp=new c.Vector3;update(e,t){const i=e.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const n=e.worldQuaternion;if(this.rotation.x=n.x,this.rotation.y=n.y,this.rotation.z=n.z,this.rotation.w=n.w,this.fast=!1,t){const o=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=o.x,this.velocity.y=o.y,this.velocity.z=o.z}}}var jE=Object.defineProperty,Uu=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&jE(e,t,n),n};const BE=w("debugsignals");class zu{guid}Uu([f()],zu.prototype,"guid");class sh{signal;reaction}Uu([f(zu)],sh.prototype,"signal");Uu([f(oe)],sh.prototype,"reaction");const Fw=class Kn extends k{static receivers={};static invoke(e){if(Kn.receivers[e]){const t=Kn.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}events;awake(){BE&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Kn.receivers[e.signal.guid]||(Kn.receivers[e.signal.guid]=[]),Kn.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Kn.receivers[e.signal.guid]){const t=Kn.receivers[e.signal.guid].indexOf(this);t>=0&&Kn.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(n){console.error(n)}}};Uu([f(sh)],Fw.prototype,"events");let oh=Fw;var si=(s=>(s.Activation="ActivationTrack",s.Animation="AnimationTrack",s.Audio="AudioTrack",s.Control="ControlTrack",s.Marker="MarkerTrack",s.Signal="SignalTrack",s))(si||{}),bn=(s=>(s[s.None=0]="None",s[s.Hold=1]="Hold",s[s.Loop=2]="Loop",s[s.PingPong=3]="PingPong",s[s.Continue=4]="Continue",s))(bn||{}),ny=(s=>(s.Signal="SignalEmitter",s))(ny||{});const Rn=w("debugtimeline");class $a{director;track;get muted(){return this.track.muted}set muted(e){e!==this.track.muted&&(this.track.muted=e,this.onMuteChanged?.call(this))}*forEachClip(e=!1){if(this.track?.clips)if(e)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,n=!0){if(t<0||t>=i.length)return 0;const o=i[t];if(n||e>=o.start&&e<=o.end){let r=1;if(o.easeInDuration>0){const a=Math.min((e-o.start)/o.easeInDuration,1);r*=a}if(o.easeOutDuration>0){const a=Math.min((o.end-e)/o.easeOutDuration,1);r*=a}return r}return 0}}class FE{clip;rootPositionOffset;rootQuaternionOffset;get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}rootStartPosition;rootEndPosition;rootStartQuaternion;rootEndQuaternion;constructor(e){const t=e.getClip();this.clip=t;const i=e.getRoot(),n=i.name+".position",o=i.name+".quaternion";Rn&&console.log(t.name,t.tracks,n);for(const r of t.tracks)if(!(r.times.length<=0)){if(r.name.endsWith(n))this.rootStartPosition=new c.Vector3().fromArray(r.values,0),this.rootEndPosition=new c.Vector3().fromArray(r.values,r.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Rn&&console.log(this.rootPositionOffset);else if(r.name.endsWith(o)&&(this.rootStartQuaternion=new c.Quaternion().fromArray(r.values,0),this.rootEndQuaternion=new c.Quaternion().fromArray(r.values,r.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Rn)){const a=new c.Euler().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}}class cc extends $a{models=[];trackOffset;target;mixer;clips=[];actions=[];weight=1;_actionOffsets=[];_didBind=!1;_animator=null;onDisable(){this.mixer?.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&__(this._animator.gameObject,this,this.director.enabled&&this.director.weight>0)}createHooks(e,t){if(t.tracks?.length<=0){console.warn("No tracks in AnimationClip",t);return}let i=!1,n=!1;const o=t.tracks.find(r=>r.name.includes(".position")||r.name.includes(".quaternion"))?.name.split(".");if(o){const r=o[o.length-2],a=r+".position",l=r+".quaternion";for(const h of t.tracks)!i&&h.name.endsWith(a)?(i=!0,this.createPositionInterpolant(t,e,h)):!n&&h.name.endsWith(l)&&(n=!0,this.createRotationInterpolant(t,e,h))}if(!i||!n){const r=this.mixer?.getRoot(),a=t.tracks[0],l=a.name.lastIndexOf("."),h=a.name.substring(0,l),d=h.substring(h.lastIndexOf(".")+1),u=r.getObjectByName(d);if(u)if(i){if(!n){const p=t.tracks[0].name.substring(0,l)+".quaternion";Rn&&console.warn("Create quaternion track",d,u);const m=u.quaternion,y=new c.QuaternionKeyframeTrack(p,[0,t.duration],[m.x,m.y,m.z,m.w,m.x,m.y,m.z,m.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const p=h+".position";Rn&&console.warn("Create position track",d,u);const m=u.position,y=new c.VectorKeyframeTrack(p,[0,t.duration],[m.x,m.y,m.z,m.x,m.y,m.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,Rn&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new FE(e);this._actionOffsets.push(t)}this.target&&(this._animator=S.getComponent(this.target,rt)??null,this._animator&&__(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,i=t.position,n=t.rotation;i&&i.x!==void 0&&(i.isVector3||(t.position=new c.Vector3(i.x,i.y,i.z)),n.isQuaternion||(t.rotation=new c.Quaternion(n.x,n.y,n.z,n.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new c.Vector3(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new c.Quaternion(t.x,t.y,t.z,t.w)))}}_useclipOffsets=!0;_totalOffsetPosition=new c.Vector3;_totalOffsetRotation=new c.Quaternion;_totalOffsetPosition2=new c.Vector3;_totalOffsetRotation2=new c.Quaternion;_summedPos=new c.Vector3;_tempPos=new c.Vector3;_summedRot=new c.Quaternion;_tempRot=new c.Quaternion;_clipRotQuat=new c.Quaternion;evaluate(e){if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,i=0,n=!1,o=!1,r=0;for(let a=0;a<this.clips.length;a++){const l=this.models[a],h=this.actions[a],d=l.asset;h.weight=0;const u=e>=l.start&&e<=l.end,p=l.preExtrapolationMode,m=l.postExtrapolationMode,y=a<this.clips.length-1?this.models[a+1]:null;let _=u,g=!1;if(!_&&!n&&l.end<e&&m!==bn.None?(!y||y.start>e)&&(_=!0,n=!0):a==0&&!_&&!o&&l.start>e&&p!==bn.None&&(!y||y.start<e)&&(_=!0,g=!0,o=!0),_){let v=this.weight;v*=this.evaluateWeight(e,a,this.models,_),v*=this.director.weight;let b=u;if(g)switch(p){case bn.Hold:break;case bn.Loop:e+=l.start,b=!0;break;default:e+=l.start,b=!0;break}let x=this.getClipTime(e,l),R=0;const O=d.duration;if(g&&p===bn.Hold&&(x=0),b){if(d.loop)for(R+=Math.floor(x/(O+1e-6));x>O;)x-=O}else if(!u&&n)switch(m){case bn.Hold:x=this.getClipTime(l.end,l);break;case bn.Loop:x%=O;break;case bn.PingPong:const B=Math.floor(x/O)%2!==0;x%=O,B&&(x=O-x);break}l.reversed===!0?h.time=h.getClip().duration-x:h.time=x,h.timeScale=0;const M=Math.max(0,v);if(h.weight=M,r+=M,h.clampWhenFinished=!1,h.isRunning()||h.play(),this._useclipOffsets){const E=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,B=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(i=1-v),t+=1;const L=this._summedPos.set(0,0,0),V=this._tempPos.set(0,0,0),$=this._summedRot.identity(),T=this._tempRot.identity(),U=d.rotation;U&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(U,v));const N=this._actionOffsets[a];if(N.hasOffsets)for(let K=0;K<R;K++)N.rootPositionOffset?V.copy(N.rootPositionOffset):V.set(0,0,0),V.applyQuaternion($),this._clipRotQuat&&V.applyQuaternion(this._clipRotQuat),N.rootQuaternionOffset&&(T.copy(N.rootQuaternionOffset),$.multiply(T)),L.add(V);this._clipRotQuat&&B.multiply(this._clipRotQuat),B.multiply($),d.position&&L.add(d.position),E.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.__mixerError===void 0&&(Rn||A())&&this._animator?.runtimeAnimatorController?.mixer&&this.mixer!==this._animator?.runtimeAnimatorController?.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)),this._animator?.runtimeAnimatorController){const a=Math.max(0,1-r);this._animator?.runtimeAnimatorController?.update(a)}else this.mixer.update(e)}createRotationInterpolant(e,t,i){const n=i.createInterpolant.bind(i),o=new c.Quaternion;this.ensureTrackOffsets();const r=this.trackOffset?.rotation;i.createInterpolant=()=>{const a=n(),l=a.evaluate.bind(a);return a.evaluate=h=>{const d=l(h);if(o.set(d[0],d[1],d[2],d[3]),o.premultiply(this._totalOffsetRotation),r&&o.premultiply(r),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)u?.onTimelineRotation?.call(u,this.director,this.target,h,o);return d[0]=o.x,d[1]=o.y,d[2]=o.z,d[3]=o.w,d},a}}createPositionInterpolant(e,t,i){const n=i.createInterpolant.bind(i),o=new c.Vector3;this.ensureTrackOffsets();const r=this.trackOffset?.rotation,a=this.trackOffset?.position;let l;i.createInterpolant=()=>{const h=n(),d=h.evaluate.bind(h);return h.evaluate=u=>{const p=d(u);if(o.set(p[0],p[1],p[2]),t.removeStartOffset&&(l===void 0?(l=null,l=this._actionOffsets.find(m=>m.clip===e)?.rootStartPosition?.clone()):l?.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),r&&o.applyQuaternion(r),a&&(o.x-=a.x,o.y+=a.y,o.z+=a.z),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)m?.onTimelinePosition?.call(m,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p},h}}}const UE=w("mutetimeline");class rs extends $a{models=[];listener;audio=[];audioContextTimeOffset=[];lastTime=0;audioSource;_audioLoader=null;getAudioFilePath(e){const t=this.director.sourceId;return no(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const i=this.models[t];this.audio[t].setVolume(e?i.asset.volume:0)}}addModel(e){const t=new c.Audio(this.listener);this.audio.push(t);const i=e;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&e?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}_playableDirectorResumed=!1;onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(UE||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const n=t?.1:0;for(let o=0;o<this.models.length;o++){const r=this.models[o],a=this.audio[o],l=r.asset;if((!a||!a.buffer)&&this.isInTimeRange(r,e-1,e+1)&&this.handleAudioLoading(r,a),pi.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=l.loop,e>=r.start&&e<=r.end&&e<this.director.duration){if(!a.isPlaying||!this.director.isPlaying)(i||!r._didTriggerPlay&&this.lastTime<e)&&(r.duration*r.timeScale>.3?a.offset=r.clipIn+(e-r.start)*r.timeScale:a.offset=0,Rn&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+r.asset.clip),a.play(n),r._didTriggerPlay=!0);else{const d=r.clipIn+(e-r.start)*r.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(d-u)>.3&&(a.offset=d,a.stop(),a.play(n))}let h=l.volume;if(this.track.volume!==void 0&&(h*=this.track.volume),t&&(h=0),r.easeInDuration>0){const d=Math.min((e-r.start)/r.easeInDuration,1);h*=d}if(r.easeOutDuration>0){const d=Math.min((r.end-e)/r.easeOutDuration,1);h*=d}a.setVolume(h*this.director.weight)}else r._didTriggerPlay=!1,this.director.isPlaying&&a.isPlaying&&a.stop()}this.lastTime=e}loadAudio(e,t=0,i=0){let n=null;const o=e-i,r=e+t;for(const a of this.models)if(this.isInTimeRange(a,o,r)){const l=this.audio[this.models.indexOf(a)],h=this.handleAudioLoading(a,l);h!==null&&(n===null&&(n=[]),n.push(h))}return n!==null?Promise.all(n):null}isInTimeRange(e,t,i){return t<=e.start&&i>=e.end||t>=e.start&&t<=e.end||i>=e.start&&i<=e.end}static _audioBuffers=new Map;static dispose(){rs._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new c.AudioLoader);const i=this.getAudioFilePath(e.asset.clip);if(rs._audioBuffers.get(i)){const o=rs._audioBuffers.get(i);return o.then(r=>{r&&t.setBuffer(r)}),o}Rn&&console.warn("LOAD audio track",i,this.director.sourceId);const n=new Promise((o,r)=>{this._audioLoader.load(i,a=>{t.setBuffer(a),o(a)},void 0,a=>{console.error("Error loading audio",a),o(null)})});return rs._audioBuffers.set(i,n),n}}class Nu extends $a{models=[];needsSorting=!0;*foreachMarker(e=null){this.needsSorting&&this.sort();for(const t of this.models)t&&t.type===e&&(yield t)}onEnable(){this.needsSorting=!0}evaluate(e){this.needsSorting&&this.sort()}sort(){this.needsSorting=!1,this.models.sort((e,t)=>e.time-t.time)}}class hc extends $a{models=[];didTrigger=[];receivers=[];evaluate(e){if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let i=0;i<this.models.length;i++){const n=this.models[i],o=this.didTrigger[i],r=n.time-e;let a=!1;if(n.retroActive)a=r<=1e-6;else{const l=Math.abs(r);(l===0||l>=1e-5&&l<t)&&(a=!0)}if(a){if(!o)if(Rn&&console.log("Trigger signal",e,n.time,n),this.didTrigger[i]=!0,this.receivers?.length<=0)oh.invoke(n.asset);else for(const l of this.receivers)l&&l.invoke(n.asset)}else n.emitOnce||(this.didTrigger[i]=!1)}}}class Vu extends $a{models=[];timelines=[];resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const n=this.models[t].asset;if(!n.sourceObject||typeof n.sourceObject!="object"){console.log("no source object, removing model",t,n),this.models.splice(t,1);continue}else{const o=S.getComponent(n.sourceObject,or);this.timelines.push(o),o&&n.updateDirector&&(o.playOnAwake=!1)}}}_previousActiveModel=null;evaluate(e){this._previousActiveModel=null;for(let t=0;t<this.models.length;t++){const i=this.models[t],n=i.asset;if(e>=i.start&&e<=i.end){this._previousActiveModel=i;const o=this.getClipTime(e,i);if(n.controlActivation){const r=n.sourceObject;r.visible=!0}if(n.updateDirector){const r=this.timelines[t];r&&(r.isPlaying&&r.pause(),r.time=o,r.evaluate())}}else{const o=this._previousActiveModel?.asset;if(n.controlActivation){const r=n.sourceObject;o?.sourceObject!==r&&(r.visible=!1)}}}}}var zE=Object.defineProperty,Uw=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&zE(e,t,n),n};const qn=w("debugtimeline"),sy=class Kp extends k{static createTrackFunctions={};static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}playableAsset;playOnAwake;extrapolationMode=1;get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(qn||Ii())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}waitForAudio=!0;_visibilityChangeEvt;_clonedPlayableAsset=!1;_speed=1;awake(){qn&&console.log(this,this.playableAsset),this.rebuildGraph(),!this.isValid()&&(qn||A())&&(qn?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",this.playableAsset?.tracks,"IsArray?",Array.isArray(this.playableAsset?.tracks),this):this.playableAsset?.tracks?.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){for(const e of this._audioTracks)e.onEnable?.();for(const e of this._customTracks)e.onEnable?.();for(const e of this._animationTracks)e.onEnable?.();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(){this.stop();for(const e of this._audioTracks)e.onDisable?.();for(const e of this._customTracks)e.onDisable?.();for(const e of this._animationTracks)e.onDisable?.();this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){for(const e of this._allTracks)for(const t of e)t.onDestroy?.()}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const i of this._audioTracks){const n=i.loadAudio(this._time,1,0);n&&t.push(n)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!pi.userInteractionRegistered&&this.waitForAudio;)await In(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),pe.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&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 e of this._allTracks)for(const t of e)yield t}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}get signalTracks(){return this._signalTracks}get markerTracks(){return this._markerTracks}*foreachMarker(e=null){for(const t of this._markerTracks)for(const i of t.foreachMarker(e))yield i}_guidsMap;resolveGuids(e){this._guidsMap=e}_isPlaying=!1;_internalUpdateRoutine;_isPaused=!1;_isStopping=!1;_time=0;_duration=0;_weight=1;_animationTracks=[];_audioTracks=[];_signalTracks=[];_markerTracks=[];_controlTracks=[];_customTracks=[];_allTracks=[this._animationTracks,this._audioTracks,this._signalTracks,this._markerTracks,this._controlTracks,this._customTracks];invokePauseChangedMethodsOnTracks(){for(const e of this.forEachTrack())e.onPauseChanged?.call(e)}invokeStateChangedMethodsOnTracks(){for(const e of this.forEachTrack())e.onStateChanged?.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const i=this._time;for(const n of this.playableAsset.tracks)if(!n.muted)switch(n.type){case si.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<n.outputs.length;o++){const r=n.outputs[o];if(typeof r=="object"){let a=!1;if(n.clips)for(const h of n.clips)h.start<=i&&i<=h.end&&(a=!0);const l=r;l.visible!==void 0&&l.visible!==a&&(l.visible=a,qn&&console.warn(this.name,"set ActivationTrack-"+o,l.name,a,i))}}break}for(const n of this._allTracks)for(const o of n)this._isStopping&&o instanceof cc||o.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=pc(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let i=t.outputs.length-1;i>=0;i--){let n=t.outputs[i];if(typeof n=="string"){this._guidsMap&&this._guidsMap[n]&&(n=this._guidsMap[n]);const o=S.findByGuid(n,e);o===null||typeof o!="object"?(t.outputs.splice(i,1),console.warn("Failed to resolve binding",n,t.name,t.type)):(qn&&console.log("Resolved binding",n,"to",o),t.outputs[i]=o)}else if(n===null){if(t.outputs.splice(i,1),Kp.createTrackFunctions[t.type])continue;t.type!==si.Audio&&t.type!==si.Control&&t.type!==si.Marker&&t.type!==si.Signal&&console.warn("Missing binding",n,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===si.Control&&t.clips)for(let i=0;i<t.clips.length;i++){const n=t.clips[i];let o=n.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const r=S.findByGuid(o,e);r===null||typeof r!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,n):(qn&&console.log("Resolved binding",o,"to",r),n.asset.sourceObject=r)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=S.findObjectOfType(ss,this.context);for(const t of this.playableAsset.tracks){const i=t.type,n=Kp.createTrackFunctions[i];if(n!=null){const o=n(this,t);if(typeof o.evaluate=="function"){o.director=this,o.track=t,this._customTracks.push(o);continue}}if(t.type===si.Animation){if(!t.clips||t.clips.length<=0){qn&&console.warn("Animation track has no clips",t);continue}for(let o=t.outputs.length-1;o>=0;o--){let r=t.outputs[o];if(r instanceof c.Object3D){const l=S.getOrAddComponent(r,rt);l&&(r=l)}const a=r?.gameObject?.animations;if(a){const l=new cc;l.trackOffset=t.trackOffset,l.director=this,l.track=t;for(let h=0;h<t.clips.length;h++){const d=t.clips[h],u=d.asset;if(!u){console.error(`Timeline ${this.name}: clip #${h} on track "${t.name}" has no animation data`);continue}const p=u.clip;let m=p;if((typeof m=="string"||typeof m=="number")&&(m=a.find(_=>_.name===p)),qn&&console.log(u,p,"→",m),!m){console.warn("Could not find animationClip for model",d,t.name,this.name,this.playableAsset?.name,a,r);continue}r instanceof rt&&r.runtimeAnimatorController&&(r.__internalDidAwakeAndStart||r.initializeRuntimeAnimatorController(),r.runtimeAnimatorController.mixer||r.runtimeAnimatorController.bind(r),l.mixer=r.runtimeAnimatorController.mixer),l.mixer||(l.mixer=new c.AnimationMixer(r.gameObject),this.context.animations.registerAnimationMixer(l.mixer)),l.clips.push(m),l.mixer.uncacheAction(m),l.createHooks(d.asset,m);const y=l.mixer.clipAction(m);l.actions.push(y),l.models.push(d)}this._animationTracks.push(l)}}}else if(t.type===si.Audio){if(!t.clips||t.clips.length<=0)continue;const o=new rs;o.director=this,o.track=t,o.audioSource=t.outputs.find(r=>r instanceof pi),this._audioTracks.push(o),e||(e=this.context.mainCameraComponent?.gameObject.addComponent(ss)),o.listener=e.listener;for(let r=0;r<t.clips.length;r++){const a=t.clips[r];o.addModel(a)}}else if(t.type===si.Marker){if(t.markers){const o=new hc;o.director=this,o.track=t;const r=new Nu;r.director=this,r.track=t;for(const a of t.markers)switch(a.type){case ny.Signal:o.models.push(a),o.didTrigger.push(!1);break;default:r.models.push(a);break}if(o!==null&&o.models.length>0){const a=S.getComponent(this.gameObject,oh);a&&(o.receivers.push(a),this._signalTracks.push(o))}r!==null&&r.models.length>0&&this._markerTracks.push(r)}}else if(t.type===si.Signal){const o=new hc;if(o.director=this,o.track=t,t.markers)for(const r of t.markers)o.models.push(r),o.didTrigger.push(!1);for(const r of t.outputs)o.receivers.push(r);this._signalTracks.push(o)}else if(t.type===si.Control){const o=new Vu;if(o.director=this,o.track=t,t.clips)for(const r of t.clips)o.models.push(r);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}animationCallbackReceivers=[];registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};Uw([f()],sy.prototype,"playOnAwake");Uw([f()],sy.prototype,"extrapolationMode");let or=sy;var NE=Object.defineProperty,$u=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&NE(e,t,n),n};class Rr extends k{isGizmo=!1;translationSnap=1;rotationSnapAngle=15;scaleSnap=.25;get control(){return this._control}_control;orbit;onEnable(){if(!(this.isGizmo&&!vc)&&this.context.mainCamera&&(this._control||(this._control=new q.TransformControls(this.context.mainCamera,this.context.renderer.domElement),this._control.enabled=!0,this._control.getRaycaster().layers.set(2),this._control.size=1,("_root"in this._control?this._control._root:this._control).traverse(t=>{const i=t;if(i.layers.set(2),i){const n=i.material;n&&(n.opacity=.3)}}),this.orbit=S.getComponentInParent(this.context.mainCamera,de)??void 0),this._control)){const e=this._control.getHelper();this.context.scene.add(e),this._control.attach(this.gameObject),this._control?.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)}}onDisable(){this._control?.getHelper()?.removeFromParent(),this._control?.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this._control&&(this._control.setTranslationSnap(this.translationSnap),this._control.setRotationSnap(c.MathUtils.degToRad(this.rotationSnapAngle)),this._control.setScaleSnap(this.scaleSnap))}disableSnapping(){this._control&&(this._control.setTranslationSnap(null),this._control.setRotationSnap(null),this._control.setScaleSnap(null))}onControlChangedEvent=e=>{const t=this.orbit;if(t&&(t.enabled=!e.value),e.value){const i=this.gameObject.getComponentInParent(on);i&&(i.fastMode=!0,i.requestOwnership())}else{const i=this.gameObject.getComponentInParent(on);i&&(i.fastMode=!1)}};windowKeyDownListener=e=>{if(this.enabled&&this._control)switch(e.keyCode){case 81:this._control.setSpace(this._control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this._control.setMode("translate");break;case 69:this._control.setMode("rotate");break;case 82:this._control.setMode("scale");break;case 187:case 107:this._control.setSize(this._control.size+.1);break;case 189:case 109:this._control.setSize(Math.max(this._control.size-.1,.1));break;case 88:this._control.showX=!this._control.showX;break;case 89:this._control.showY=!this._control.showY;break;case 90:this._control.showZ=!this._control.showZ;break;case 32:this._control.enabled=!this._control.enabled;break}};windowKeyUpListener=e=>{if(this.enabled)switch(e.keyCode){case 16:this.disableSnapping();break}}}$u([f()],Rr.prototype,"isGizmo");$u([f()],Rr.prototype,"translationSnap");$u([f()],Rr.prototype,"rotationSnapAngle");$u([f()],Rr.prototype,"scaleSnap");var VE=Object.defineProperty,$E=Object.getOwnPropertyDescriptor,Wu=(s,e,t,i)=>{for(var n=i>1?void 0:i?$E(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&VE(e,t,n),n};class oy{texture=null;rect}Wu([f(c.Texture)],oy.prototype,"texture",2);let Wa=class extends Nc{set image(e){this.sprite||(this.sprite=new oy),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}_sprite;pixelsPerUnitMultiplier=1;isBuiltinSprite(){const e=this.sprite;switch(e?.texture?.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!e?.texture?.name?.length&&e?.texture?.image?.width===32&&e?.texture?.image?.height===32}onBeforeCreate(e){super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,this.sprite?.texture?.name==="Knob"&&(e.borderRadius=999))}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture(this.sprite?.texture))}};Wu([f(oy)],Wa.prototype,"sprite",1);Wu([f()],Wa.prototype,"pixelsPerUnitMultiplier",2);class Hu extends Nc{get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}_mainTexture;onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Wu([f(c.Texture)],Hu.prototype,"mainTexture",1);var WE=Object.defineProperty,HE=Object.getOwnPropertyDescriptor,vi=(s,e,t,i)=>{for(var n=i>1?void 0:i?HE(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&WE(e,t,n),n};const Oo=w("debugbutton");class bo{colorMultiplier;disabledColor;fadeDuration;highlightedColor;normalColor;pressedColor;selectedColor}vi([f()],bo.prototype,"colorMultiplier",2);vi([f(Z)],bo.prototype,"disabledColor",2);vi([f()],bo.prototype,"fadeDuration",2);vi([f(Z)],bo.prototype,"highlightedColor",2);vi([f(Z)],bo.prototype,"normalColor",2);vi([f(Z)],bo.prototype,"pressedColor",2);vi([f(Z)],bo.prototype,"selectedColor",2);class GE{disabledTrigger;highlightedTrigger;normalTrigger;pressedTrigger;selectedTrigger}class ws extends k{click(){this.onClick?.invoke()}onClick=new oe;_isHovered=0;onPointerEnter(e){const t=e.event.pointerType==="mouse"&&e.button===0;t&&(this._isHovered+=1),Oo&&console.warn("Button Enter",t,this._isHovered,this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&this._image?.setState("hovered"),t&&this.context.input.setCursor("pointer"))}onPointerExit(){this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),Oo&&console.log("Button Exit",this._isHovered,this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState("normal"),this.context.input.unsetCursor("pointer")))}onPointerDown(e){Oo&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&this._image?.setState("pressed"))}onPointerUp(e){Oo&&console.warn("Button Up",this.animationTriggers?.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState(this._isHovered?"hovered":"normal"))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===Kd.Mouse)&&(Oo&&(console.warn("Button Click",this.onClick),Se("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Oo))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),I.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}colors;transition;animationTriggers;animator;set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}_interactable=!0;set_interactable(e){this.interactable=e}awake(){super.awake(),Oo&&console.log(this),this._isInit=!1,this.init()}start(){this._image?.setInteractable(this.interactable),this.gameObject.getComponentInParent(_a)||this.gameObject.addComponent(hu)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.unsetCursor("pointer")}_requestedAnimatorTrigger;*setAnimatorTriggerAtEndOfFrame(e){this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&this.animator?.setTrigger(e)}_isInit=!1;_image;init(){this._isInit||(this._isInit=!0,this._image=S.getComponent(this.gameObject,Wa),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,this.colors?.normalColor),i={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(i);const n=this.getFinalColor(e.color,this.colors?.highlightedColor),o={state:"hovered",attributes:{backgroundColor:n,backgroundOpacity:n.alpha}};e.setupState(o);const r=this.getFinalColor(e.color,this.colors?.pressedColor),a={state:"pressed",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};e.setupState(a);const l=this.getFinalColor(e.color,this.colors?.selectedColor),h={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};e.setupState(h);const d=this.getFinalColor(e.color,this.colors?.disabledColor),u={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(u)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}vi([f(oe)],ws.prototype,"onClick",2);vi([f(bo)],ws.prototype,"colors",2);vi([f()],ws.prototype,"transition",2);vi([f(GE)],ws.prototype,"animationTriggers",2);vi([f(rt)],ws.prototype,"animator",2);vi([f()],ws.prototype,"interactable",1);var qE=Object.defineProperty,Gu=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&qE(e,t,n),n};const Ds=w("debuginputfield"),rh=class W extends k{get text(){return this.textComponent?.text??""}set text(e){this.textComponent&&(this.textComponent.text=e,this.placeholder&&(e.length>0?this.placeholder.gameObject.visible=!1:this.placeholder.gameObject.visible=!0))}get isFocused(){return W.active===this}textComponent;placeholder;onValueChanged;onEndEdit;static active=null;static activeTime=-1;static htmlField=null;static htmlFieldFocused=!1;inputEventFn;_iosEventFn;start(){Ds&&console.log(this.name,this)}onEnable(){W.htmlField||(W.htmlField=document.createElement("input"),W.htmlField.style.width="0px",W.htmlField.style.height="0px",W.htmlField.style.padding="0px",W.htmlField.style.border="none",W.htmlField.style.overflow="hidden",W.htmlField.style.caretColor="transparent",W.htmlField.style.outline="none",W.htmlField.classList.add("ar"),W.htmlField.onfocus=()=>W.htmlFieldFocused=!0,W.htmlField.onblur=()=>W.htmlFieldFocused=!1,document.body.append(W.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),W.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&this.textComponent?.text.length&&S.setActive(this.placeholder.gameObject,!1),exports.DeviceUtilities.isiOS()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("click",this._iosEventFn))}onDisable(){W.htmlField?.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("click",this._iosEventFn)}clear(){W.active===this&&W.htmlField?(W.htmlField.value="",this.setTextFromInputField()):(this.textComponent&&(this.textComponent.text=""),this.placeholder&&S.setActive(this.placeholder.gameObject,!0))}select(){this.onSelected()}deselect(){this.onDeselected()}onPointerEnter(e){e.event.pointerType==="mouse"&&e.button===0&&this.context.input.setCursor("text")}onPointerExit(e){this.context.input.unsetCursor("text")}onPointerClick(e){Ds&&console.log("CLICK",e,W.active),W.activeTime=this.context.time.time,W.active!==this&&this.startCoroutine(this.activeLoop(),pe.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();W.active===this&&!(this.context.input.getPointerClicked(0)&&this.context.time.time-W.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){if(W.active!==this&&(Ds&&console.log("Select",this.name,this,W.htmlField,this.context.isInXR,this.context.arOverlayElement,this.textComponent?.text,W.htmlField?.value),W.active?.onDeselected(),W.active=this,this.placeholder&&S.setActive(this.placeholder.gameObject,!1),W.htmlField)){if(W.htmlField.value=this.textComponent?.text||"",Ds&&console.log("set input field value",W.htmlField.value),this.context.isInXR){const e=this.context.arOverlayElement;e&&e.append(W.htmlField)}this.selectInputField()}}onDeselected(){W.active===this&&(W.active=null,Ds&&console.log("Deselect",this.name,this),W.htmlField&&(W.htmlField.blur(),document.body.append(W.htmlField)),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&S.setActive(this.placeholder.gameObject,!0),W.htmlField&&this.onEndEdit?.invoke(W.htmlField.value))}update(){W.active===this&&this.textComponent?.markDirty()}onInput(e){if(W.active===this){if(Ds&&console.log(e.code,e,W.htmlField?.value,this.textComponent?.text),e.code==="Escape"||e.code==="Enter"){this.onDeselected();return}W.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&S.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){if(this.textComponent&&W.htmlField){const e=this.textComponent.text,t=W.htmlField.value,i=this.textComponent.text!==W.htmlField.value;this.textComponent.text=W.htmlField.value,i&&(Ds&&console.log("[InputField] value changed:",t,e),this.onValueChanged?.invoke(t,e))}}selectInputField(){W.htmlField&&(Ds&&console.log("Focus Inputfield",W.htmlFieldFocused),W.htmlField.setSelectionRange(W.htmlField.value.length,W.htmlField.value.length),exports.DeviceUtilities.isiOS()?W.htmlField.focus({preventScroll:!0}):setTimeout(()=>W.htmlField?.focus(),1))}processInputOniOS(){const e=this.context.physics.raycast();if(!e.length)return;const i=e[0].object,n=Gm(i);(n?.gameObject===this.gameObject||n?.gameObject.parent===this.gameObject)&&this.selectInputField()}};Gu([f(Pt)],rh.prototype,"textComponent");Gu([f(Pt)],rh.prototype,"placeholder");Gu([f(oe)],rh.prototype,"onValueChanged");Gu([f(oe)],rh.prototype,"onEndEdit");let ry=rh;var XE=Object.defineProperty,zw=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&XE(e,t,n),n};class ah extends k{id=null;keepAspect=!1;_object=null;onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const e=document.getElementById(this.id);if(!e){console.warn('Could not find element with id "'+this.id+'"');return}e.style.display="block",e.style.visibility="hidden";const t=new q.InteractiveGroup;t.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(t);const i=new q.HTMLMesh(e);t.add(i),i.visible=!1;const n=i.material;n.transparent=!0,setTimeout(()=>{i.visible=!0;const o=qd(this.gameObject).clone();yc(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const r=new c.Box3;r.setFromObject(t),this.setWorldRotation(o.x,o.y,o.z);const a=r.max.x-r.min.x,l=r.max.y-r.min.y;if(this.keepAspect){const d=a/l;a>l?i.scale.set(1/a,1/l/d,1):i.scale.set(1/a*d,1/l,1)}else i.scale.set(1/a,1/l,1);const h=this.gameObject.scale;i.scale.multiply(h)},1)}onDisable(){this._object?.removeFromParent()}}zw([f()],ah.prototype,"id");zw([f()],ah.prototype,"keepAspect");/* @license
|
|
1417
|
+
C) Set "joinRandomRoom" to true`),!1):(ep&&console.log("Join "+this.roomName),this._userWantsToBeInARoom=!0,this.context.connection.joinRoom(this.roomName),!0))}_lastPingTime=0;_lastRoomTime=-1;_userWantsToBeInARoom=!1;update(){this.context.connection.isConnected&&(this.context.time.time-this._lastPingTime>3&&(this._lastPingTime=this.context.time.time,this.context.connection.sendPing()),this.context.connection.isInRoom&&(this._lastRoomTime=this.context.time.time)),this._lastRoomTime>0&&this.context.time.time-this._lastRoomTime>.3&&(this._lastRoomTime=-1,this.autoRejoin?this._userWantsToBeInARoom&&(console.log("Disconnected from networking backend - attempt reconnecting now"),this.tryJoinRoom()):A()&&console.warn("You are not connected to a room anymore (possibly because the tab was inactive for too long and the server kicked you?)"))}getViewOnlyUrl(){if(this.context.connection.isConnected&&this.context.connection.currentRoomViewId){const e=window.location.search,t=new URLSearchParams(e);return t.has(this.urlParameterName)&&t.delete(this.urlParameterName),t.set(Jf,this.context.connection.currentRoomViewId),window.location.origin+window.location.pathname+"?"+t.toString()}return null}setRandomRoomUrlParameter(){const e=fc(),t=this.generateRoomName();w(this.urlParameterName)?e.set(this.urlParameterName,t):e.append(this.urlParameterName,t),nm(t,e)}generateRoomName(){let e="";for(let t=0;t<6;t++)e+=Math.floor(Math.random()*10).toFixed(0);return e}_roomButton;_roomButtonIconJoin;_roomButtonIconLeave;createRoomButton(){if(this._roomButton)return this._roomButton;const e=document.createElement("button");return this._roomButton=e,e.classList.add("create-room-button"),e.setAttribute("priority","90"),e.onclick=()=>{if(this.context.connection.isInRoom)this.urlParameterName&&Ql(this.urlParameterName,null),this.context.connection.leaveRoom(),this._userWantsToBeInARoom=!1;else{if(this.urlParameterName){const t=w(this.urlParameterName);(!t||t===!0)&&(this._lastJoinedRoom?Ql(this.urlParameterName,this._lastJoinedRoom):this.setRandomRoomUrlParameter())}this.tryJoinRoom()}},this._roomButtonIconJoin=pt("group"),this._roomButtonIconLeave=pt("group_off"),this.updateRoomButtonState(),this.context.connection.beginListen(Q.JoinedRoom,this.updateRoomButtonState),this.context.connection.beginListen(Q.LeftRoom,this.updateRoomButtonState),e}updateRoomButtonState=()=>{this._roomButton&&(this.context.connection.isInRoom?(this._roomButton.title="Leave the networked room",this._roomButton.textContent="Leave Room",this._roomButtonIconJoin?.remove(),this._roomButton.prepend(this._roomButtonIconLeave)):(this._roomButton.title="Create or join a networked room",this._roomButton.textContent="Join Room",this._roomButtonIconLeave?.remove(),this._roomButton.prepend(this._roomButtonIconJoin)))};destroyRoomButton(){this.context.connection.stopListen(Q.JoinedRoom,this.updateRoomButtonState),this.context.connection.stopListen(Q.LeftRoom,this.updateRoomButtonState)}_viewOnlyButton;onEnableViewOnlyButton(){this.context.connection.isConnected?this.onCreateViewOnlyButton():(this.context.connection.stopListen(Q.JoinedRoom,this.onCreateViewOnlyButton),this.context.connection.beginListen(Q.JoinedRoom,this.onCreateViewOnlyButton))}onDisableViewOnlyButton(){this.context.connection.stopListen(Q.JoinedRoom,this.onCreateViewOnlyButton),this._viewOnlyButton?.remove()}onCreateViewOnlyButton=()=>{if(!this._viewOnlyButton){const e=document.createElement("button");this._viewOnlyButton=e,e.classList.add("view-only-button"),e.setAttribute("priority","90"),e.onclick=()=>{const t=this.getViewOnlyUrl();t?.length?navigator.canShare({url:t})?navigator.share({url:t})?.catch(i=>{console.warn(i)}):(navigator.clipboard.writeText(t),Se("View only URL copied to clipboard")):he("Could not create view only URL")},e.title="Copy the view only URL: A page accessed by the view only URL can not be modified by visiting users.",e.textContent="Share View URL",e.prepend(pt("visibility"))}this.context.menu.appendChild(this._viewOnlyButton)}}_o([f()],fn.prototype,"roomName",2);_o([f()],fn.prototype,"urlParameterName",2);_o([f()],fn.prototype,"joinRandomRoom",2);_o([f()],fn.prototype,"requireRoomParameter",2);_o([f()],fn.prototype,"autoRejoin",2);_o([f()],fn.prototype,"createJoinButton",2);_o([f()],fn.prototype,"createViewOnlyButton",2);_o([f()],fn.prototype,"roomPrefix",1);function LE(){const s=w("testwindowcount")||0;s&&s>0&&DE(s)}function DE(s){if(w("testwindow"))return null;const e=new URL(window.location.href);lp(e.searchParams,RP,1),lp(e.searchParams,"testwindow",1);const t=e.toString(),i=[];window.onbeforeunload=()=>{for(const l of i)l.close()};const n=.05,o=128;let r=0,a=0;for(let l=0;l<s;l++){r*o+o*.01>=window.innerWidth&&(a+=1,r=0);const h=r*(o*(1+n))+window.screenLeft,d=a*(o*(1+n))+window.screenTop+90+60*a;r+=1;const u=window.open(t,"test window "+l,`popup=yes width=${o} height=${o} top=${d} left=${h}`);if(!u){console.warn("Failed to open window");continue}i.push(u),u.onload=()=>{u.onbeforeunload=()=>{for(let p=0;p<i.length;p++){const m=i[p];m!==u&&m.close()}i.length=0}}}return i}class ty extends k{awake(){LE()}}class iy extends k{transformsPerFrame=10;interval=0;useFlatbuffers=!0;awake(){if(this.useFlatbuffers)this.context.connection.beginListenBinary(tc,e=>{});else{this.models=[];for(let e=0;e<this.transformsPerFrame;e++)this.models.push(new IE(this.context.connection.connectionId+"_simulatedTransform_"+e,this))}}builder=null;models=null;update(){if(this.context.connection.isConnected){if(this.useFlatbuffers){if(!this.context.connection.connectionId||this.context.time.frameCount%this.interval!==0)return;this.builder===null&&(this.builder=new se.Builder(1024));const e=this.builder;for(let t=0;t<this.transformsPerFrame;t++){e.clear();const i=gv(this.context.connection.connectionId,this);this.context.connection.sendBinary(i)}}else if(this.models)for(let e=0;e<this.models.length;e++){const t=this.models[e];t.dontSave=!0,t.update(this,null),this.context.connection.send("TestSimulateUserData-"+e,t)}}}}class IE{guid;fast=!1;position;rotation;velocity=void 0;dontSave;isValid(){return this.fast!==void 0||this.position!==void 0||this.rotation!==void 0||this.velocity!==void 0}constructor(e,t){this.guid=e,this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0,w:0},this.update(t,null)}static temp=new c.Vector3;update(e,t){const i=e.worldPosition;this.position.x=i.x,this.position.y=i.y,this.position.z=i.z;const n=e.worldQuaternion;if(this.rotation.x=n.x,this.rotation.y=n.y,this.rotation.z=n.z,this.rotation.w=n.w,this.fast=!1,t){const o=t.getVelocity();this.velocity===void 0&&(this.velocity={x:0,y:0,z:0}),this.velocity.x=o.x,this.velocity.y=o.y,this.velocity.z=o.z}}}var jE=Object.defineProperty,Uu=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&jE(e,t,n),n};const BE=w("debugsignals");class zu{guid}Uu([f()],zu.prototype,"guid");class sh{signal;reaction}Uu([f(zu)],sh.prototype,"signal");Uu([f(oe)],sh.prototype,"reaction");const Fw=class Kn extends k{static receivers={};static invoke(e){if(Kn.receivers[e]){const t=Kn.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}events;awake(){BE&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)Kn.receivers[e.signal.guid]||(Kn.receivers[e.signal.guid]=[]),Kn.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(Kn.receivers[e.signal.guid]){const t=Kn.receivers[e.signal.guid].indexOf(this);t>=0&&Kn.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(n){console.error(n)}}};Uu([f(sh)],Fw.prototype,"events");let oh=Fw;var si=(s=>(s.Activation="ActivationTrack",s.Animation="AnimationTrack",s.Audio="AudioTrack",s.Control="ControlTrack",s.Marker="MarkerTrack",s.Signal="SignalTrack",s))(si||{}),bn=(s=>(s[s.None=0]="None",s[s.Hold=1]="Hold",s[s.Loop=2]="Loop",s[s.PingPong=3]="PingPong",s[s.Continue=4]="Continue",s))(bn||{}),ny=(s=>(s.Signal="SignalEmitter",s))(ny||{});const Rn=w("debugtimeline");class $a{director;track;get muted(){return this.track.muted}set muted(e){e!==this.track.muted&&(this.track.muted=e,this.onMuteChanged?.call(this))}*forEachClip(e=!1){if(this.track?.clips)if(e)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,n=!0){if(t<0||t>=i.length)return 0;const o=i[t];if(n||e>=o.start&&e<=o.end){let r=1;if(o.easeInDuration>0){const a=Math.min((e-o.start)/o.easeInDuration,1);r*=a}if(o.easeOutDuration>0){const a=Math.min((o.end-e)/o.easeOutDuration,1);r*=a}return r}return 0}}class FE{clip;rootPositionOffset;rootQuaternionOffset;get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}rootStartPosition;rootEndPosition;rootStartQuaternion;rootEndQuaternion;constructor(e){const t=e.getClip();this.clip=t;const i=e.getRoot(),n=i.name+".position",o=i.name+".quaternion";Rn&&console.log(t.name,t.tracks,n);for(const r of t.tracks)if(!(r.times.length<=0)){if(r.name.endsWith(n))this.rootStartPosition=new c.Vector3().fromArray(r.values,0),this.rootEndPosition=new c.Vector3().fromArray(r.values,r.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Rn&&console.log(this.rootPositionOffset);else if(r.name.endsWith(o)&&(this.rootStartQuaternion=new c.Quaternion().fromArray(r.values,0),this.rootEndQuaternion=new c.Quaternion().fromArray(r.values,r.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Rn)){const a=new c.Euler().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}}class cc extends $a{models=[];trackOffset;target;mixer;clips=[];actions=[];weight=1;_actionOffsets=[];_didBind=!1;_animator=null;onDisable(){this.mixer?.stopAllAction()}onDestroy(){this.director.context.animations.unregisterAnimationMixer(this.mixer)}onStateChanged(){this._animator&&__(this._animator.gameObject,this,this.director.enabled&&this.director.weight>0)}createHooks(e,t){if(t.tracks?.length<=0){console.warn("No tracks in AnimationClip",t);return}let i=!1,n=!1;const o=t.tracks.find(r=>r.name.includes(".position")||r.name.includes(".quaternion"))?.name.split(".");if(o){const r=o[o.length-2],a=r+".position",l=r+".quaternion";for(const h of t.tracks)!i&&h.name.endsWith(a)?(i=!0,this.createPositionInterpolant(t,e,h)):!n&&h.name.endsWith(l)&&(n=!0,this.createRotationInterpolant(t,e,h))}if(!i||!n){const r=this.mixer?.getRoot(),a=t.tracks[0],l=a.name.lastIndexOf("."),h=a.name.substring(0,l),d=h.substring(h.lastIndexOf(".")+1),u=r.getObjectByName(d);if(u)if(i){if(!n){const p=t.tracks[0].name.substring(0,l)+".quaternion";Rn&&console.warn("Create quaternion track",d,u);const m=new c.QuaternionKeyframeTrack(p,[0,t.duration],[0,0,0,1,0,0,0,1]);t.tracks.push(m),this.createRotationInterpolant(t,e,m)}}else{const p=h+".position";Rn&&console.warn("Create position track",d,u);const m=new c.VectorKeyframeTrack(p,[0,t.duration],[0,0,0,0,0,0]);t.tracks.push(m),this.createPositionInterpolant(t,e,m)}}}bind(){if(!this._didBind){this._didBind=!0,Rn&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new FE(e);this._actionOffsets.push(t)}this.target&&(this._animator=S.getComponent(this.target,rt)??null,this._animator&&__(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,i=t.position,n=t.rotation;i&&i.x!==void 0&&(i.isVector3||(t.position=new c.Vector3(i.x,i.y,i.z)),n.isQuaternion||(t.rotation=new c.Quaternion(n.x,n.y,n.z,n.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new c.Vector3(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new c.Quaternion(t.x,t.y,t.z,t.w)))}}_useclipOffsets=!0;_totalOffsetPosition=new c.Vector3;_totalOffsetRotation=new c.Quaternion;_totalOffsetPosition2=new c.Vector3;_totalOffsetRotation2=new c.Quaternion;_summedPos=new c.Vector3;_tempPos=new c.Vector3;_summedRot=new c.Quaternion;_tempRot=new c.Quaternion;_clipRotQuat=new c.Quaternion;evaluate(e){if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let t=0,i=0,n=!1,o=!1,r=0;for(let a=0;a<this.clips.length;a++){const l=this.models[a],h=this.actions[a],d=l.asset;h.weight=0;const u=e>=l.start&&e<=l.end,p=l.preExtrapolationMode,m=l.postExtrapolationMode,y=a<this.clips.length-1?this.models[a+1]:null;let _=u,g=!1;if(!_&&!n&&l.end<e&&m!==bn.None?(!y||y.start>e)&&(_=!0,n=!0):a==0&&!_&&!o&&l.start>e&&p!==bn.None&&(!y||y.start<e)&&(_=!0,g=!0,o=!0),_){let v=this.weight;v*=this.evaluateWeight(e,a,this.models,_),v*=this.director.weight;let b=u;if(g)switch(p){case bn.Hold:break;case bn.Loop:e+=l.start,b=!0;break;default:e+=l.start,b=!0;break}let x=this.getClipTime(e,l),R=0;const O=d.duration;if(g&&p===bn.Hold&&(x=0),b){if(d.loop)for(R+=Math.floor(x/(O+1e-6));x>O;)x-=O}else if(!u&&n)switch(m){case bn.Hold:x=this.getClipTime(l.end,l);break;case bn.Loop:x%=O;break;case bn.PingPong:const B=Math.floor(x/O)%2!==0;x%=O,B&&(x=O-x);break}l.reversed===!0?h.time=h.getClip().duration-x:h.time=x,h.timeScale=0;const M=Math.max(0,v);if(h.weight=M,r+=M,h.clampWhenFinished=!1,h.isRunning()||h.play(),this._useclipOffsets){const E=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,B=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(i=1-v),t+=1;const L=this._summedPos.set(0,0,0),V=this._tempPos.set(0,0,0),$=this._summedRot.identity(),T=this._tempRot.identity(),U=d.rotation;U&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(U,v));const N=this._actionOffsets[a];if(N.hasOffsets)for(let K=0;K<R;K++)N.rootPositionOffset?V.copy(N.rootPositionOffset):V.set(0,0,0),V.applyQuaternion($),this._clipRotQuat&&V.applyQuaternion(this._clipRotQuat),N.rootQuaternionOffset&&(T.copy(N.rootQuaternionOffset),$.multiply(T)),L.add(V);this._clipRotQuat&&B.multiply(this._clipRotQuat),B.multiply($),d.position&&L.add(d.position),E.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,i),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,i)),this.__mixerError===void 0&&(Rn||A())&&this._animator?.runtimeAnimatorController?.mixer&&this.mixer!==this._animator?.runtimeAnimatorController?.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)),this._animator?.runtimeAnimatorController){const a=Math.max(0,1-r);this._animator?.runtimeAnimatorController?.update(a)}else this.mixer.update(e)}createRotationInterpolant(e,t,i){const n=i.createInterpolant.bind(i),o=new c.Quaternion;this.ensureTrackOffsets();const r=this.trackOffset?.rotation;i.createInterpolant=()=>{const a=n(),l=a.evaluate.bind(a);return a.evaluate=h=>{const d=l(h);if(o.set(d[0],d[1],d[2],d[3]),o.premultiply(this._totalOffsetRotation),r&&o.premultiply(r),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)u?.onTimelineRotation?.call(u,this.director,this.target,h,o);return d[0]=o.x,d[1]=o.y,d[2]=o.z,d[3]=o.w,d},a}}createPositionInterpolant(e,t,i){const n=i.createInterpolant.bind(i),o=new c.Vector3;this.ensureTrackOffsets();const r=this.trackOffset?.rotation,a=this.trackOffset?.position;let l;i.createInterpolant=()=>{const h=n(),d=h.evaluate.bind(h);return h.evaluate=u=>{const p=d(u);if(o.set(p[0],p[1],p[2]),t.removeStartOffset&&(l===void 0?(l=null,l=this._actionOffsets.find(m=>m.clip===e)?.rootStartPosition?.clone()):l?.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),r&&o.applyQuaternion(r),a&&(o.x-=a.x,o.y+=a.y,o.z+=a.z),this.director.animationCallbackReceivers)for(const m of this.director.animationCallbackReceivers)m?.onTimelinePosition?.call(m,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p},h}}}const UE=w("mutetimeline");class rs extends $a{models=[];listener;audio=[];audioContextTimeOffset=[];lastTime=0;audioSource;_audioLoader=null;getAudioFilePath(e){const t=this.director.sourceId;return no(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const i=this.models[t];this.audio[t].setVolume(e?i.asset.volume:0)}}addModel(e){const t=new c.Audio(this.listener);this.audio.push(t);const i=e;i._didTriggerPlay=!1,this.models.push(i)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop();for(const e of this.models)e._didTriggerPlay=!1}onDestroy(){for(const e of this.audio)e.source&&e?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}for(const e of this.models)e._didTriggerPlay=!1}_playableDirectorResumed=!1;onPauseChanged(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t?.isPlaying&&t.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(e){if(UE||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,i=this._playableDirectorResumed;this._playableDirectorResumed=!1;const n=t?.1:0;for(let o=0;o<this.models.length;o++){const r=this.models[o],a=this.audio[o],l=r.asset;if((!a||!a.buffer)&&this.isInTimeRange(r,e-1,e+1)&&this.handleAudioLoading(r,a),pi.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale*this.director.speed,a.loop=l.loop,e>=r.start&&e<=r.end&&e<this.director.duration){if(!a.isPlaying||!this.director.isPlaying)(i||!r._didTriggerPlay&&this.lastTime<e)&&(r.duration*r.timeScale>.3?a.offset=r.clipIn+(e-r.start)*r.timeScale:a.offset=0,Rn&&console.log("Timeline Audio ("+this.track.name+") play with offset "+a.offset+" - "+r.asset.clip),a.play(n),r._didTriggerPlay=!0);else{const d=r.clipIn+(e-r.start)*r.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(d-u)>.3&&(a.offset=d,a.stop(),a.play(n))}let h=l.volume;if(this.track.volume!==void 0&&(h*=this.track.volume),t&&(h=0),r.easeInDuration>0){const d=Math.min((e-r.start)/r.easeInDuration,1);h*=d}if(r.easeOutDuration>0){const d=Math.min((r.end-e)/r.easeOutDuration,1);h*=d}a.setVolume(h*this.director.weight)}else r._didTriggerPlay=!1,this.director.isPlaying&&a.isPlaying&&a.stop()}this.lastTime=e}loadAudio(e,t=0,i=0){let n=null;const o=e-i,r=e+t;for(const a of this.models)if(this.isInTimeRange(a,o,r)){const l=this.audio[this.models.indexOf(a)],h=this.handleAudioLoading(a,l);h!==null&&(n===null&&(n=[]),n.push(h))}return n!==null?Promise.all(n):null}isInTimeRange(e,t,i){return t<=e.start&&i>=e.end||t>=e.start&&t<=e.end||i>=e.start&&i<=e.end}static _audioBuffers=new Map;static dispose(){rs._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new c.AudioLoader);const i=this.getAudioFilePath(e.asset.clip);if(rs._audioBuffers.get(i)){const o=rs._audioBuffers.get(i);return o.then(r=>{r&&t.setBuffer(r)}),o}Rn&&console.warn("LOAD audio track",i,this.director.sourceId);const n=new Promise((o,r)=>{this._audioLoader.load(i,a=>{t.setBuffer(a),o(a)},void 0,a=>{console.error("Error loading audio",a),o(null)})});return rs._audioBuffers.set(i,n),n}}class Nu extends $a{models=[];needsSorting=!0;*foreachMarker(e=null){this.needsSorting&&this.sort();for(const t of this.models)t&&t.type===e&&(yield t)}onEnable(){this.needsSorting=!0}evaluate(e){this.needsSorting&&this.sort()}sort(){this.needsSorting=!1,this.models.sort((e,t)=>e.time-t.time)}}class hc extends $a{models=[];didTrigger=[];receivers=[];evaluate(e){if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let i=0;i<this.models.length;i++){const n=this.models[i],o=this.didTrigger[i],r=n.time-e;let a=!1;if(n.retroActive)a=r<=1e-6;else{const l=Math.abs(r);(l===0||l>=1e-5&&l<t)&&(a=!0)}if(a){if(!o)if(Rn&&console.log("Trigger signal",e,n.time,n),this.didTrigger[i]=!0,this.receivers?.length<=0)oh.invoke(n.asset);else for(const l of this.receivers)l&&l.invoke(n.asset)}else n.emitOnce||(this.didTrigger[i]=!1)}}}class Vu extends $a{models=[];timelines=[];resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const n=this.models[t].asset;if(!n.sourceObject||typeof n.sourceObject!="object"){console.log("no source object, removing model",t,n),this.models.splice(t,1);continue}else{const o=S.getComponent(n.sourceObject,or);this.timelines.push(o),o&&n.updateDirector&&(o.playOnAwake=!1)}}}_previousActiveModel=null;evaluate(e){this._previousActiveModel=null;for(let t=0;t<this.models.length;t++){const i=this.models[t],n=i.asset;if(e>=i.start&&e<=i.end){this._previousActiveModel=i;const o=this.getClipTime(e,i);if(n.controlActivation){const r=n.sourceObject;r.visible=!0}if(n.updateDirector){const r=this.timelines[t];r&&(r.isPlaying&&r.pause(),r.time=o,r.evaluate())}}else{const o=this._previousActiveModel?.asset;if(n.controlActivation){const r=n.sourceObject;o?.sourceObject!==r&&(r.visible=!1)}}}}}var zE=Object.defineProperty,Uw=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&zE(e,t,n),n};const qn=w("debugtimeline"),sy=class Kp extends k{static createTrackFunctions={};static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}playableAsset;playOnAwake;extrapolationMode=1;get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(qn||Ii())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}waitForAudio=!0;_visibilityChangeEvt;_clonedPlayableAsset=!1;_speed=1;awake(){qn&&console.log(this,this.playableAsset),this.rebuildGraph(),!this.isValid()&&(qn||A())&&(qn?console.warn("PlayableDirector is not valid","Asset?",this.playableAsset,"Tracks:",this.playableAsset?.tracks,"IsArray?",Array.isArray(this.playableAsset?.tracks),this):this.playableAsset?.tracks?.length?console.warn("PlayableDirector is not valid"):console.warn("PlayableDirector has no tracks"))}onEnable(){for(const e of this._audioTracks)e.onEnable?.();for(const e of this._customTracks)e.onEnable?.();for(const e of this._animationTracks)e.onEnable?.();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(){this.stop();for(const e of this._audioTracks)e.onDisable?.();for(const e of this._customTracks)e.onDisable?.();for(const e of this._animationTracks)e.onDisable?.();this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){for(const e of this._allTracks)for(const t of e)t.onDestroy?.()}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,e&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const t=[];for(const i of this._audioTracks){const n=i.loadAudio(this._time,1,0);n&&t.push(n)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!pi.userInteractionRegistered&&this.waitForAudio;)await In(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),pe.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const i of this._audioTracks)i.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&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 e of this._allTracks)for(const t of e)yield t}get animationTracks(){return this._animationTracks}get audioTracks(){return this._audioTracks}get signalTracks(){return this._signalTracks}get markerTracks(){return this._markerTracks}*foreachMarker(e=null){for(const t of this._markerTracks)for(const i of t.foreachMarker(e))yield i}_guidsMap;resolveGuids(e){this._guidsMap=e}_isPlaying=!1;_internalUpdateRoutine;_isPaused=!1;_isStopping=!1;_time=0;_duration=0;_weight=1;_animationTracks=[];_audioTracks=[];_signalTracks=[];_markerTracks=[];_controlTracks=[];_customTracks=[];_allTracks=[this._animationTracks,this._audioTracks,this._signalTracks,this._markerTracks,this._controlTracks,this._customTracks];invokePauseChangedMethodsOnTracks(){for(const e of this.forEachTrack())e.onPauseChanged?.call(e)}invokeStateChangedMethodsOnTracks(){for(const e of this.forEachTrack())e.onStateChanged?.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const i=this._time;for(const n of this.playableAsset.tracks)if(!n.muted)switch(n.type){case si.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<n.outputs.length;o++){const r=n.outputs[o];if(typeof r=="object"){let a=!1;if(n.clips)for(const h of n.clips)h.start<=i&&i<=h.end&&(a=!0);const l=r;l.visible!==void 0&&l.visible!==a&&(l.visible=a,qn&&console.warn(this.name,"set ActivationTrack-"+o,l.name,a,i))}}break}for(const n of this._allTracks)for(const o of n)this._isStopping&&o instanceof cc||o.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=pc(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let i=t.outputs.length-1;i>=0;i--){let n=t.outputs[i];if(typeof n=="string"){this._guidsMap&&this._guidsMap[n]&&(n=this._guidsMap[n]);const o=S.findByGuid(n,e);o===null||typeof o!="object"?(t.outputs.splice(i,1),console.warn("Failed to resolve binding",n,t.name,t.type)):(qn&&console.log("Resolved binding",n,"to",o),t.outputs[i]=o)}else if(n===null){if(t.outputs.splice(i,1),Kp.createTrackFunctions[t.type])continue;t.type!==si.Audio&&t.type!==si.Control&&t.type!==si.Marker&&t.type!==si.Signal&&console.warn("Missing binding",n,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===si.Control&&t.clips)for(let i=0;i<t.clips.length;i++){const n=t.clips[i];let o=n.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const r=S.findByGuid(o,e);r===null||typeof r!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,n):(qn&&console.log("Resolved binding",o,"to",r),n.asset.sourceObject=r)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=S.findObjectOfType(ss,this.context);for(const t of this.playableAsset.tracks){const i=t.type,n=Kp.createTrackFunctions[i];if(n!=null){const o=n(this,t);if(typeof o.evaluate=="function"){o.director=this,o.track=t,this._customTracks.push(o);continue}}if(t.type===si.Animation){if(!t.clips||t.clips.length<=0){qn&&console.warn("Animation track has no clips",t);continue}for(let o=t.outputs.length-1;o>=0;o--){let r=t.outputs[o];if(r instanceof c.Object3D){const l=S.getOrAddComponent(r,rt);l&&(r=l)}const a=r?.gameObject?.animations;if(a){const l=new cc;l.trackOffset=t.trackOffset,l.director=this,l.track=t;for(let h=0;h<t.clips.length;h++){const d=t.clips[h],u=d.asset;if(!u){console.error(`Timeline ${this.name}: clip #${h} on track "${t.name}" has no animation data`);continue}const p=u.clip;let m=p;if((typeof m=="string"||typeof m=="number")&&(m=a.find(_=>_.name===p)),qn&&console.log(u,p,"→",m),!m){console.warn("Could not find animationClip for model",d,t.name,this.name,this.playableAsset?.name,a,r);continue}r instanceof rt&&r.runtimeAnimatorController&&(r.__internalDidAwakeAndStart||r.initializeRuntimeAnimatorController(),r.runtimeAnimatorController.mixer||r.runtimeAnimatorController.bind(r),l.mixer=r.runtimeAnimatorController.mixer),l.mixer||(l.mixer=new c.AnimationMixer(r.gameObject),this.context.animations.registerAnimationMixer(l.mixer)),l.clips.push(m),l.mixer.uncacheAction(m),l.createHooks(d.asset,m);const y=l.mixer.clipAction(m);l.actions.push(y),l.models.push(d)}this._animationTracks.push(l)}}}else if(t.type===si.Audio){if(!t.clips||t.clips.length<=0)continue;const o=new rs;o.director=this,o.track=t,o.audioSource=t.outputs.find(r=>r instanceof pi),this._audioTracks.push(o),e||(e=this.context.mainCameraComponent?.gameObject.addComponent(ss)),o.listener=e.listener;for(let r=0;r<t.clips.length;r++){const a=t.clips[r];o.addModel(a)}}else if(t.type===si.Marker){if(t.markers){const o=new hc;o.director=this,o.track=t;const r=new Nu;r.director=this,r.track=t;for(const a of t.markers)switch(a.type){case ny.Signal:o.models.push(a),o.didTrigger.push(!1);break;default:r.models.push(a);break}if(o!==null&&o.models.length>0){const a=S.getComponent(this.gameObject,oh);a&&(o.receivers.push(a),this._signalTracks.push(o))}r!==null&&r.models.length>0&&this._markerTracks.push(r)}}else if(t.type===si.Signal){const o=new hc;if(o.director=this,o.track=t,t.markers)for(const r of t.markers)o.models.push(r),o.didTrigger.push(!1);for(const r of t.outputs)o.receivers.push(r);this._signalTracks.push(o)}else if(t.type===si.Control){const o=new Vu;if(o.director=this,o.track=t,t.clips)for(const r of t.clips)o.models.push(r);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}animationCallbackReceivers=[];registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};Uw([f()],sy.prototype,"playOnAwake");Uw([f()],sy.prototype,"extrapolationMode");let or=sy;var NE=Object.defineProperty,$u=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&NE(e,t,n),n};class Rr extends k{isGizmo=!1;translationSnap=1;rotationSnapAngle=15;scaleSnap=.25;get control(){return this._control}_control;orbit;onEnable(){if(!(this.isGizmo&&!vc)&&this.context.mainCamera&&(this._control||(this._control=new q.TransformControls(this.context.mainCamera,this.context.renderer.domElement),this._control.enabled=!0,this._control.getRaycaster().layers.set(2),this._control.size=1,("_root"in this._control?this._control._root:this._control).traverse(t=>{const i=t;if(i.layers.set(2),i){const n=i.material;n&&(n.opacity=.3)}}),this.orbit=S.getComponentInParent(this.context.mainCamera,de)??void 0),this._control)){const e=this._control.getHelper();this.context.scene.add(e),this._control.attach(this.gameObject),this._control?.addEventListener("dragging-changed",this.onControlChangedEvent),window.addEventListener("keydown",this.windowKeyDownListener),window.addEventListener("keyup",this.windowKeyUpListener)}}onDisable(){this._control?.getHelper()?.removeFromParent(),this._control?.removeEventListener("dragging-changed",this.onControlChangedEvent),window.removeEventListener("keydown",this.windowKeyDownListener),window.removeEventListener("keyup",this.windowKeyUpListener)}enableSnapping(){this._control&&(this._control.setTranslationSnap(this.translationSnap),this._control.setRotationSnap(c.MathUtils.degToRad(this.rotationSnapAngle)),this._control.setScaleSnap(this.scaleSnap))}disableSnapping(){this._control&&(this._control.setTranslationSnap(null),this._control.setRotationSnap(null),this._control.setScaleSnap(null))}onControlChangedEvent=e=>{const t=this.orbit;if(t&&(t.enabled=!e.value),e.value){const i=this.gameObject.getComponentInParent(on);i&&(i.fastMode=!0,i.requestOwnership())}else{const i=this.gameObject.getComponentInParent(on);i&&(i.fastMode=!1)}};windowKeyDownListener=e=>{if(this.enabled&&this._control)switch(e.keyCode){case 81:this._control.setSpace(this._control.space==="local"?"world":"local");break;case 16:this.enableSnapping();break;case 87:this._control.setMode("translate");break;case 69:this._control.setMode("rotate");break;case 82:this._control.setMode("scale");break;case 187:case 107:this._control.setSize(this._control.size+.1);break;case 189:case 109:this._control.setSize(Math.max(this._control.size-.1,.1));break;case 88:this._control.showX=!this._control.showX;break;case 89:this._control.showY=!this._control.showY;break;case 90:this._control.showZ=!this._control.showZ;break;case 32:this._control.enabled=!this._control.enabled;break}};windowKeyUpListener=e=>{if(this.enabled)switch(e.keyCode){case 16:this.disableSnapping();break}}}$u([f()],Rr.prototype,"isGizmo");$u([f()],Rr.prototype,"translationSnap");$u([f()],Rr.prototype,"rotationSnapAngle");$u([f()],Rr.prototype,"scaleSnap");var VE=Object.defineProperty,$E=Object.getOwnPropertyDescriptor,Wu=(s,e,t,i)=>{for(var n=i>1?void 0:i?$E(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&VE(e,t,n),n};class oy{texture=null;rect}Wu([f(c.Texture)],oy.prototype,"texture",2);let Wa=class extends Nc{set image(e){this.sprite||(this.sprite=new oy),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}_sprite;pixelsPerUnitMultiplier=1;isBuiltinSprite(){const e=this.sprite;switch(e?.texture?.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!e?.texture?.name?.length&&e?.texture?.image?.width===32&&e?.texture?.image?.height===32}onBeforeCreate(e){super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,this.sprite?.texture?.name==="Knob"&&(e.borderRadius=999))}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture(this.sprite?.texture))}};Wu([f(oy)],Wa.prototype,"sprite",1);Wu([f()],Wa.prototype,"pixelsPerUnitMultiplier",2);class Hu extends Nc{get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}_mainTexture;onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Wu([f(c.Texture)],Hu.prototype,"mainTexture",1);var WE=Object.defineProperty,HE=Object.getOwnPropertyDescriptor,vi=(s,e,t,i)=>{for(var n=i>1?void 0:i?HE(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&WE(e,t,n),n};const Oo=w("debugbutton");class bo{colorMultiplier;disabledColor;fadeDuration;highlightedColor;normalColor;pressedColor;selectedColor}vi([f()],bo.prototype,"colorMultiplier",2);vi([f(Z)],bo.prototype,"disabledColor",2);vi([f()],bo.prototype,"fadeDuration",2);vi([f(Z)],bo.prototype,"highlightedColor",2);vi([f(Z)],bo.prototype,"normalColor",2);vi([f(Z)],bo.prototype,"pressedColor",2);vi([f(Z)],bo.prototype,"selectedColor",2);class GE{disabledTrigger;highlightedTrigger;normalTrigger;pressedTrigger;selectedTrigger}class ws extends k{click(){this.onClick?.invoke()}onClick=new oe;_isHovered=0;onPointerEnter(e){const t=e.event.pointerType==="mouse"&&e.button===0;t&&(this._isHovered+=1),Oo&&console.warn("Button Enter",t,this._isHovered,this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&this._image?.setState("hovered"),t&&this.context.input.setCursor("pointer"))}onPointerExit(){this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),Oo&&console.log("Button Exit",this._isHovered,this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState("normal"),this.context.input.unsetCursor("pointer")))}onPointerDown(e){Oo&&console.log("Button Down",this.animationTriggers?.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&this._image?.setState("pressed"))}onPointerUp(e){Oo&&console.warn("Button Up",this.animationTriggers?.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&this._image?.setState(this._isHovered?"hovered":"normal"))}onPointerClick(e){if(this.interactable&&!(e.button!==0&&e.event.pointerType===Kd.Mouse)&&(Oo&&(console.warn("Button Click",this.onClick),Se("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use(),Oo))){const t=this.gameObject.worldPosition;t.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),I.DrawLabel(t,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}colors;transition;animationTriggers;animator;set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}_interactable=!0;set_interactable(e){this.interactable=e}awake(){super.awake(),Oo&&console.log(this),this._isInit=!1,this.init()}start(){this._image?.setInteractable(this.interactable),this.gameObject.getComponentInParent(_a)||this.gameObject.addComponent(hu)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.unsetCursor("pointer")}_requestedAnimatorTrigger;*setAnimatorTriggerAtEndOfFrame(e){this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&this.animator?.setTrigger(e)}_isInit=!1;_image;init(){this._isInit||(this._isInit=!0,this._image=S.getComponent(this.gameObject,Wa),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,this.colors?.normalColor),i={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(i);const n=this.getFinalColor(e.color,this.colors?.highlightedColor),o={state:"hovered",attributes:{backgroundColor:n,backgroundOpacity:n.alpha}};e.setupState(o);const r=this.getFinalColor(e.color,this.colors?.pressedColor),a={state:"pressed",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};e.setupState(a);const l=this.getFinalColor(e.color,this.colors?.selectedColor),h={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};e.setupState(h);const d=this.getFinalColor(e.color,this.colors?.disabledColor),u={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(u)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}vi([f(oe)],ws.prototype,"onClick",2);vi([f(bo)],ws.prototype,"colors",2);vi([f()],ws.prototype,"transition",2);vi([f(GE)],ws.prototype,"animationTriggers",2);vi([f(rt)],ws.prototype,"animator",2);vi([f()],ws.prototype,"interactable",1);var qE=Object.defineProperty,Gu=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&qE(e,t,n),n};const Ds=w("debuginputfield"),rh=class W extends k{get text(){return this.textComponent?.text??""}set text(e){this.textComponent&&(this.textComponent.text=e,this.placeholder&&(e.length>0?this.placeholder.gameObject.visible=!1:this.placeholder.gameObject.visible=!0))}get isFocused(){return W.active===this}textComponent;placeholder;onValueChanged;onEndEdit;static active=null;static activeTime=-1;static htmlField=null;static htmlFieldFocused=!1;inputEventFn;_iosEventFn;start(){Ds&&console.log(this.name,this)}onEnable(){W.htmlField||(W.htmlField=document.createElement("input"),W.htmlField.style.width="0px",W.htmlField.style.height="0px",W.htmlField.style.padding="0px",W.htmlField.style.border="none",W.htmlField.style.overflow="hidden",W.htmlField.style.caretColor="transparent",W.htmlField.style.outline="none",W.htmlField.classList.add("ar"),W.htmlField.onfocus=()=>W.htmlFieldFocused=!0,W.htmlField.onblur=()=>W.htmlFieldFocused=!1,document.body.append(W.htmlField)),this.inputEventFn||(this.inputEventFn=this.onInput.bind(this)),W.htmlField.addEventListener("keyup",this.inputEventFn),this.placeholder&&this.textComponent?.text.length&&S.setActive(this.placeholder.gameObject,!1),exports.DeviceUtilities.isiOS()&&(this._iosEventFn=this.processInputOniOS.bind(this),window.addEventListener("click",this._iosEventFn))}onDisable(){W.htmlField?.removeEventListener("keyup",this.inputEventFn),this.onDeselected(),this._iosEventFn&&window.removeEventListener("click",this._iosEventFn)}clear(){W.active===this&&W.htmlField?(W.htmlField.value="",this.setTextFromInputField()):(this.textComponent&&(this.textComponent.text=""),this.placeholder&&S.setActive(this.placeholder.gameObject,!0))}select(){this.onSelected()}deselect(){this.onDeselected()}onPointerEnter(e){e.event.pointerType==="mouse"&&e.button===0&&this.context.input.setCursor("text")}onPointerExit(e){this.context.input.unsetCursor("text")}onPointerClick(e){Ds&&console.log("CLICK",e,W.active),W.activeTime=this.context.time.time,W.active!==this&&this.startCoroutine(this.activeLoop(),pe.LateUpdate),this.selectInputField()}*activeLoop(){for(this.onSelected();W.active===this&&!(this.context.input.getPointerClicked(0)&&this.context.time.time-W.activeTime>.2);)this.setTextFromInputField(),yield;this.onDeselected()}onSelected(){if(W.active!==this&&(Ds&&console.log("Select",this.name,this,W.htmlField,this.context.isInXR,this.context.arOverlayElement,this.textComponent?.text,W.htmlField?.value),W.active?.onDeselected(),W.active=this,this.placeholder&&S.setActive(this.placeholder.gameObject,!1),W.htmlField)){if(W.htmlField.value=this.textComponent?.text||"",Ds&&console.log("set input field value",W.htmlField.value),this.context.isInXR){const e=this.context.arOverlayElement;e&&e.append(W.htmlField)}this.selectInputField()}}onDeselected(){W.active===this&&(W.active=null,Ds&&console.log("Deselect",this.name,this),W.htmlField&&(W.htmlField.blur(),document.body.append(W.htmlField)),this.placeholder&&(!this.textComponent||this.textComponent.text.length<=0)&&S.setActive(this.placeholder.gameObject,!0),W.htmlField&&this.onEndEdit?.invoke(W.htmlField.value))}update(){W.active===this&&this.textComponent?.markDirty()}onInput(e){if(W.active===this){if(Ds&&console.log(e.code,e,W.htmlField?.value,this.textComponent?.text),e.code==="Escape"||e.code==="Enter"){this.onDeselected();return}W.htmlField&&(this.textComponent&&(this.setTextFromInputField(),this.placeholder&&S.setActive(this.placeholder.gameObject,this.textComponent.text.length<=0)),this.selectInputField())}}setTextFromInputField(){if(this.textComponent&&W.htmlField){const e=this.textComponent.text,t=W.htmlField.value,i=this.textComponent.text!==W.htmlField.value;this.textComponent.text=W.htmlField.value,i&&(Ds&&console.log("[InputField] value changed:",t,e),this.onValueChanged?.invoke(t,e))}}selectInputField(){W.htmlField&&(Ds&&console.log("Focus Inputfield",W.htmlFieldFocused),W.htmlField.setSelectionRange(W.htmlField.value.length,W.htmlField.value.length),exports.DeviceUtilities.isiOS()?W.htmlField.focus({preventScroll:!0}):setTimeout(()=>W.htmlField?.focus(),1))}processInputOniOS(){const e=this.context.physics.raycast();if(!e.length)return;const i=e[0].object,n=Gm(i);(n?.gameObject===this.gameObject||n?.gameObject.parent===this.gameObject)&&this.selectInputField()}};Gu([f(Pt)],rh.prototype,"textComponent");Gu([f(Pt)],rh.prototype,"placeholder");Gu([f(oe)],rh.prototype,"onValueChanged");Gu([f(oe)],rh.prototype,"onEndEdit");let ry=rh;var XE=Object.defineProperty,zw=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&XE(e,t,n),n};class ah extends k{id=null;keepAspect=!1;_object=null;onEnable(){if(this._object){this.gameObject.add(this._object);return}if(!this.id||!this.context.mainCamera)return;const e=document.getElementById(this.id);if(!e){console.warn('Could not find element with id "'+this.id+'"');return}e.style.display="block",e.style.visibility="hidden";const t=new q.InteractiveGroup;t.listenToPointerEvents(this.context.renderer,this.context.mainCamera),this.gameObject.add(t);const i=new q.HTMLMesh(e);t.add(i),i.visible=!1;const n=i.material;n.transparent=!0,setTimeout(()=>{i.visible=!0;const o=qd(this.gameObject).clone();yc(this.gameObject,0,0,0),this.gameObject.updateMatrixWorld();const r=new c.Box3;r.setFromObject(t),this.setWorldRotation(o.x,o.y,o.z);const a=r.max.x-r.min.x,l=r.max.y-r.min.y;if(this.keepAspect){const d=a/l;a>l?i.scale.set(1/a,1/l/d,1):i.scale.set(1/a*d,1/l,1)}else i.scale.set(1/a,1/l,1);const h=this.gameObject.scale;i.scale.multiply(h)},1)}onDisable(){this._object?.removeFromParent()}}zw([f()],ah.prototype,"id");zw([f()],ah.prototype,"keepAspect");/* @license
|
|
1418
1418
|
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
1419
1419
|
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
1420
1420
|
* you may not use this file except in compliance with the License.
|
|
@@ -1428,7 +1428,7 @@ C) Set "joinRandomRoom" to true`),!1):(ep&&console.log("Join "+this.roomName),th
|
|
|
1428
1428
|
* See the License for the specific language governing permissions and
|
|
1429
1429
|
* limitations under the License.
|
|
1430
1430
|
*/const QE={topLight:{intensity:500,position:[.418,16.199,.3]},room:{position:[-.757,13.219,.717],scale:[31.713,28.305,28.591]},boxes:[{position:[-10.906,2.009,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,.857,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:50,position:[-16.116,14.37,8.208],scale:[.1,2.428,2.739]},{intensity:50,position:[-16.109,18.021,-8.207],scale:[.1,2.425,2.751]},{intensity:17,position:[14.904,12.198,-1.832],scale:[.15,4.265,6.331]},{intensity:43,position:[-.462,8.89,14.52],scale:[4.38,5.441,.088]},{intensity:20,position:[3.235,11.486,-12.541],scale:[2.5,2,.1]},{intensity:100,position:[0,20,0],scale:[1,.1,1]}]},YE={topLight:{intensity:400,position:[.5,14,.5]},room:{position:[0,13.2,0],scale:[31.5,28.5,31.5]},boxes:[{position:[-10.906,-1,1.846],rotation:-.195,scale:[2.328,7.905,4.651]},{position:[-5.607,-.754,-.758],rotation:.994,scale:[1.97,1.534,3.955]},{position:[6.167,-.16,7.803],rotation:.561,scale:[3.927,6.285,3.687]},{position:[-2.017,.018,6.124],rotation:.333,scale:[2.002,4.566,2.064]},{position:[2.291,-.756,-2.621],rotation:-.286,scale:[1.546,1.552,1.496]},{position:[-2.193,-.369,-5.547],rotation:.516,scale:[3.875,3.487,2.986]}],lights:[{intensity:80,position:[-14,10,8],scale:[.1,2.5,2.5]},{intensity:80,position:[-14,14,-4],scale:[.1,2.5,2.5]},{intensity:23,position:[14,12,0],scale:[.1,5,5]},{intensity:16,position:[0,9,14],scale:[5,5,.1]},{intensity:80,position:[7,8,-14],scale:[2.5,2.5,.1]},{intensity:80,position:[-7,16,-14],scale:[2.5,2.5,.1]},{intensity:1,position:[0,20,0],scale:[.1,.1,.1]}]};class qu extends c.Scene{constructor(e){super(),this.position.y=-3.5;const t=new c.BoxGeometry;t.deleteAttribute("uv");const i=new c.MeshStandardMaterial({metalness:0,side:c.BackSide}),n=new c.MeshStandardMaterial({metalness:0}),o=e=="legacy"?QE:YE,r=new c.PointLight(16777215,o.topLight.intensity,28,2);r.position.set(...o.topLight.position),this.add(r);const a=new c.Mesh(t,i);a.position.set(...o.room.position),a.scale.set(...o.room.scale),this.add(a);for(const l of o.boxes){const h=new c.Mesh(t,n);h.position.set(...l.position),h.rotation.set(0,l.rotation,0),h.scale.set(...l.scale),this.add(h)}for(const l of o.lights){const h=new c.Mesh(t,this.createAreaLightMaterial(l.intensity));h.position.set(...l.position),h.scale.set(...l.scale),this.add(h)}}createAreaLightMaterial(e){const t=new c.MeshBasicMaterial;return t.color.setScalar(e),t}}var KE=Object.defineProperty,Xu=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&KE(e,t,n),n};const lh=class Nw extends k{target;invertForward=!1;keepUpDirection=!0;copyTargetRotation=!1;static flipYQuat=new c.Quaternion().setFromAxisAngle(new c.Vector3(0,1,0),Math.PI);onBeforeRender(){let e=this.target;if(e||(e=this.context.mainCamera,A()&&console.warn(`[LookAt] No target set on ${this.name}, using main camera as target.`)),!e)return;let t=this.copyTargetRotation;(this.context.isInVR||this.context.isInPassThrough)&&(t=!1),gc(this.gameObject,e,this.keepUpDirection,t),this.invertForward&&this.gameObject.quaternion.multiply(Nw.flipYQuat)}createBehaviours(e,t,i){if(t.uuid===this.gameObject.uuid){let n=t;if(this.keepUpDirection){const r=ze.createEmptyParent(t);n=r;const a=this.invertForward?-1:1;r.setMatrix(r.getMatrix().multiply(new c.Matrix4().makeRotationZ(Math.PI/2*a))),t.setMatrix(t.getMatrix().multiply(new c.Matrix4().makeRotationZ(-Math.PI/2*a)))}const o=new gt("lookat "+this.name,xt.sceneStartTrigger(),le.lookAtCameraAction(n,void 0,this.invertForward?Ai.back:Ai.forward,this.keepUpDirection?Ai.up:Ai.zero));e.addBehavior(o)}}};Xu([f(c.Object3D)],lh.prototype,"target");Xu([f()],lh.prototype,"invertForward");Xu([f()],lh.prototype,"keepUpDirection");Xu([f()],lh.prototype,"copyTargetRotation");let ay=lh;var ZE=Object.defineProperty,ly=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&ZE(e,t,n),n};class Ha extends k{url;mode=0;clickable=!0;async open(){if(!this.url){console.warn("OpenURL: URL is not set, can't open.",this);return}this._validateUrl();let e=this.url;switch(!e.startsWith("mailto:")&&e.includes("@")&&(e="mailto:"+e),A()&&Se("Open URL: "+e),this.mode){case 0:exports.DeviceUtilities.isSafari(),globalThis.open(e,"_blank");break;case 1:exports.DeviceUtilities.isSafari()&&exports.DeviceUtilities.isiOS()?globalThis.open(e,"_top"):globalThis.open(e,"_self");break;case 2:exports.DeviceUtilities.isSafari()?globalThis.open(e,"_top"):globalThis.open(e,"_new");break}}start(){this.gameObject.getComponentInParent(fi)||this.gameObject.addComponent(fi)}onPointerEnter(e){!e.used&&this.clickable&&this.context.input.setCursor("pointer")}onPointerExit(){this.clickable&&this.context.input.unsetCursor("pointer")}onPointerClick(e){this.clickable&&!e.used&&this.url?.length&&this.open()}_validateUrl(){this.url&&this.url.startsWith("www.")&&(A()&&console.warn("URL is not valid, adding https:// to the start of the URL",this.url),this.url="https://"+this.url)}}ly([f()],Ha.prototype,"url");ly([f()],Ha.prototype,"mode");ly([f()],Ha.prototype,"clickable");ru(s=>{const e=s.domElement.getAttribute("clickthrough");if(t(e)){const i=s.scene.addComponent(Qu);om(s.domElement,"clickthrough",()=>{const n=s.domElement.getAttribute("clickthrough");i.enabled=t(n)})}function t(i){return i!==null&&i!=="0"&&i!=="false"}});class Qu extends k{_previousPointerEvents="all";onEnable(){this.context.input.addEventListener("pointerdown",this.onPointerEvent),this.context.input.addEventListener("pointermove",this.onPointerEvent,{queue:100}),window.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this._previousPointerEvents=this.context.domElement.style.pointerEvents}onDisable(){this.context.input.removeEventListener("pointerdown",this.onPointerEvent),this.context.input.removeEventListener("pointermove",this.onPointerEvent),window.removeEventListener("touchend",this.onTouchEnd),this.context.domElement.style.pointerEvents=this._previousPointerEvents}onPointerEnter(){}onPointerEvent=e=>{if(e.pointerId>0)return;e.intersections?.length<=0?this.context.domElement.style.pointerEvents="none":this.context.domElement.style.pointerEvents="all"};onTouchEnd=e=>{setTimeout(()=>{this.context.domElement.style.pointerEvents="all"},100)}}var JE=Object.defineProperty,Vw=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&JE(e,t,n),n};class ch extends k{damping=0;keepDistance=!0;awake(){this._distance=-1}_distance=-1;updateDistance(){this.keepDistance&&this._distance!==-1||(this._distance=this.gameObject.worldPosition.distanceTo(this.context.mainCamera.worldPosition))}update(){this.updateDistance();const e=this.context.input.mousePositionRC,t=this.context.mainCamera,i=t.worldPosition,n=F(e.x,e.y,1).unproject(t);n.sub(i).normalize();const o=n.multiplyScalar(this._distance).add(i);if(this.damping>0){const r=this.gameObject.worldPosition;r.lerp(o,this.context.time.deltaTime/this.damping),this.gameObject.worldPosition=r}else this.gameObject.worldPosition=o}}Vw([f()],ch.prototype,"damping");Vw([f()],ch.prototype,"keepDistance");var eR=Object.defineProperty,tR=Object.getOwnPropertyDescriptor,Ga=(s,e,t,i)=>{for(var n=i>1?void 0:i?tR(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&eR(e,t,n),n};exports.HoverAnimation=class extends k{type="linear";duration=.1;scaleFactor=1.1;hovered=null;idle=null;animation=null;start(){this.idle||(this.idle=Zs.emptyClip()),this.hovered||(this.hovered=Zs.createScaleClip({type:"linear",duration:this.duration||.1,scale:this.gameObject.scale,scaleFactor:this.scaleFactor||1.1})),this.animation??=this.gameObject.addComponent(St),this.animation.playAutomatically=!1,this.playIdle()}onEnable(){this.animation&&(this.animation.enabled=!0),this.playIdle()}onDisable(){this.animation&&(this.animation.enabled=!1),this.playIdle()}onPointerEnter(){this.playHover()}onPointerExit(){this.playIdle()}playIdle(){this.idle&&this.animation?.play(this.idle,{exclusive:!0,fadeDuration:.1,loop:!0})}playHover(){this.hovered&&this.animation?.play(this.hovered,{exclusive:!0,fadeDuration:.1,loop:!1,clampWhenFinished:!0})}};Ga([f()],exports.HoverAnimation.prototype,"type",2);Ga([f()],exports.HoverAnimation.prototype,"duration",2);Ga([f()],exports.HoverAnimation.prototype,"scaleFactor",2);Ga([f(c.AnimationClip)],exports.HoverAnimation.prototype,"hovered",2);Ga([f(c.AnimationClip)],exports.HoverAnimation.prototype,"idle",2);exports.HoverAnimation=Ga([Lm],exports.HoverAnimation);var iR=Object.defineProperty,qa=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&iR(e,t,n),n};const Hh=w("debugscroll");class xs extends k{target=null;damping=0;invert=!1;htmlSelector=null;mode="window";changed=new oe;get currentValue(){return this._current_value}_current_value=0;_target_value=0;_appliedValue=-1;_scrollStart=0;_scrollEnd=0;_scrollValue=0;_scrollContainerHeight=0;onEnable(){window.addEventListener("wheel",this.updateCurrentScrollValue,{passive:!0}),this._appliedValue=-1}onDisable(){window.removeEventListener("wheel",this.updateCurrentScrollValue)}lateUpdate(){this.updateCurrentScrollValue(),this._target_value>=0&&(this.damping>0?(this._current_value=D.lerp(this._current_value,this._target_value,this.context.time.deltaTime/this.damping),Math.abs(this._current_value-this._target_value)<.001&&(this._current_value=this._target_value)):this._current_value=this._target_value);{this._appliedValue=this._current_value;let e=!1;if(this.changed.listenerCount>0){const t={type:"change",value:this._current_value,component:this,preventDefault:()=>{t.defaultPrevented=!0},defaultPrevented:!1};this.changed.invoke(t),e=t.defaultPrevented}if(!e){const t=this.invert?1-this._current_value:this._current_value;Array.isArray(this.target)?this.target.forEach(i=>i&&this.applyScroll(i,t)):this.target&&this.applyScroll(this.target,t),Hh&&this.context.time.frame%30===0&&console.debug(`[ScrollFollow] ${this._current_value.toFixed(5)} — ${(this._target_value*100).toFixed(0)}%, targets [${Array.isArray(this.target)?this.target.length:1}]`)}}}_lastSelectorValue=null;_lastSelectorElement=null;_rangeStartValue=0;_rangeEndValue=0;updateCurrentScrollValue=()=>{switch(this.mode){case"window":if(this.htmlSelector?.length){if(this.htmlSelector!==this._lastSelectorValue&&(this._lastSelectorElement=document.querySelector(this.htmlSelector),this._lastSelectorValue=this.htmlSelector),this._lastSelectorElement){const e=this._lastSelectorElement.getBoundingClientRect();this._scrollStart=e.top+window.scrollY,this._scrollEnd=e.height-window.innerHeight,this._scrollValue=-e.top,this._target_value=-e.top/(e.height-window.innerHeight),this._rangeStartValue=e.top+window.scrollY,this._rangeEndValue=this._rangeStartValue+e.height-window.innerHeight,this._scrollContainerHeight=e.height;break}}else this._scrollStart=0,this._scrollEnd=window.document.body.scrollHeight-window.innerHeight,this._scrollValue=window.scrollY,this._target_value=this._scrollValue/(this._scrollEnd||1),this._rangeStartValue=0,this._rangeEndValue=document.body.scrollHeight,this._scrollContainerHeight=window.innerHeight;break}(isNaN(this._target_value)||!isFinite(this._target_value))&&(this._target_value=-1)};applyScroll(e,t){if(e)if(e instanceof or)this.handleTimelineTarget(e,t),e.isPlaying&&e.pause(),e.evaluate();else if(e instanceof rt)e.setFloat("scroll",t);else if(e instanceof St)e.time=t*e.duration;else if(e instanceof pi){if(!e.duration)return;e.time=t*e.duration}else if(e instanceof un)e.position01=t;else if(e instanceof ei)e.intensity=t;else if(e instanceof c.Object3D){e["needle:scrollbounds"]===void 0&&(e["needle:scrollbounds"]=Ft(e)||null);const i=e["needle:scrollbounds"];i&&(e.position.y=-i.min.y-t*(i.max.y-i.min.y))}else"scroll"in e&&(typeof e.scroll=="number"?e.scroll=t:typeof e.scroll=="function"&&e.scroll(t))}handleTimelineTarget(e,t){const i=e.duration;Ur.length=0;let n=0;for(const h of e.foreachMarker("ScrollMarker")){const d=n++;if(h.element===void 0||h.needsUpdate===!0||h.element&&!h.element?.parentNode){h.needsUpdate=!1;try{if(h.element=$w(d,h.name),Hh&&console.debug(`ScrollMarker #${d} "${h.name}" (${h.time.toFixed(2)}) found`,h.element),h.element)h.timeline=new ViewTimeline({subject:h.element,axis:"block"});else{h.timeline=void 0,(Hh||A())&&console.warn(`No HTML element found for ScrollMarker: ${h.name} (index ${d})`);continue}}catch(u){h.element=null,console.error("ScrollMarker selector is not valid: "+h.name+`
|
|
1431
|
-
`,u)}}h.element&&(Ur.push(h),h.element.offsetTop,h.element.offsetHeight)}this._scrollValue+this._scrollContainerHeight,gn.length=0;let r=0;const a=1/60;let l=0;for(let h=0;h<Ur.length;h++){const d=Ur[h];if(!d.element)continue;const u=Ur[h+1],p=u?u.time-a:i;l+=1;const m=d.timeline;if(m){const y=nR(m),_=1-Math.abs(y-.5)*2,g=d.name||`marker${h}`;if(y>0&&y<=1){const v=d.time+(p-d.time)*y;gn.push({name:g,time:v,weight:_}),r+=_}else h===0&&y<=0?(gn.push({name:g,time:0,weight:1}),r+=1):h===Ur.length-1&&y>=1&&(gn.push({name:g,time:i,weight:1}),r+=1)}}if(gn.length<=0&&l<=0)e.time=t*i;else if(gn.length>0){let h=gn[0].time;if(gn.length>1)for(const d of gn){const u=d.weight/Math.max(1e-5,r),p=Math.abs(d.time-h);h+=p*u}this.damping<=0?e.time=h:e.time=D.lerp(e.time,h,this.context.time.deltaTime/this.damping),Hh&&this.context.time.frame%30===0&&console.log(`[ScrollFollow ] Timeline ${e.name}: ${h.toFixed(3)}`,gn.map(d=>`[${d.name} ${(d.weight*100).toFixed(0)}%]`).join(", "))}}}qa([f([k,c.Object3D])],xs.prototype,"target");qa([f()],xs.prototype,"damping");qa([f()],xs.prototype,"invert");qa([f()],xs.prototype,"htmlSelector");qa([f()],xs.prototype,"mode");qa([f(oe)],xs.prototype,"changed");const gn=[],Ur=[],tp=new Map,ob=new Map;let ip=!0;function $w(s,e,t=0){if(!ip){if(e?.length){const o=ob.get(e)||null;if(o)return o}const n=tp.get(s)||null;return n?.getAttribute("data-timeline-marker"),n}return ip=!1,tp.clear(),document.querySelectorAll("[data-timeline-marker]").forEach((n,o)=>{tp.set(o,n);const r=n.getAttribute("data-timeline-marker");r?.length&&ob.set(r,n)}),ip=!1,$w(s,e)}function nR(s){if(!s.source)return 0;const e=s.currentTime,t=s.duration;let i=1;return(t.unit==="seconds"||t.unit==="percent")&&(i=t.value),e.unit==="seconds"?e.value/i:e.value/100}var Ww=Object.defineProperty,sR=Object.getOwnPropertyDescriptor,oR=(s,e,t)=>e in s?Ww(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,cy=(s,e,t,i)=>{for(var n=i>1?void 0:i?sR(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&Ww(e,t,n),n},rR=(s,e,t)=>oR(s,e+"",t);const Mo=w("debugviewbox"),aR=new Z(.5,.5,.5,.5);exports.ViewBox=class extends k{referenceFieldOfView=void 0;debug=!1;onEnable(){(Mo||this.debug||A())&&console.debug("[ViewBox] Using camera fov:",this.referenceFieldOfView),exports.ViewBox.instances.push(this)}onDisable(){(Mo||this.debug)&&console.debug("[ViewBox] Disabled");const e=exports.ViewBox.instances.indexOf(this);e!==-1&&exports.ViewBox.instances.splice(e,1),this._projectedBoxElement?.remove()}onBeforeRender(){if(this.context.isInXR||this.destroyed)return;if(!(exports.ViewBox.instances[exports.ViewBox.instances.length-1]===this)){(Mo||this.debug)&&I.DrawWireBox(this.gameObject.worldPosition,this.gameObject.worldScale,aR);return}(Mo||this.debug)&&I.DrawWireBox(this.gameObject.worldPosition,this.gameObject.worldScale,14540032,0,!0,this.gameObject.worldQuaternion);const t=this.context.mainCamera;if(!t||!(t instanceof c.PerspectiveCamera))return;if(this.referenceFieldOfView===void 0&&(this.referenceFieldOfView=t.fov),this.referenceFieldOfView===void 0||this.referenceFieldOfView<=0){(Mo||this.debug)&&console.warn("[ViewBox] No valid referenceFieldOfView set, cannot adjust box size:",this.referenceFieldOfView);return}const i=this.context.domWidth,n=this.context.domHeight;let o=i,r=n,a=1,l=1;const h=this.context.focusRectSize;h&&(h.x,h.y,o=h.width,r=h.height,a=i/o,l=n/r);const d=t.view,u=t.zoom,p=t.aspect,m=t.fov;t.view=null,t.zoom=1,t.fov=this.referenceFieldOfView,t.updateProjectionMatrix();const y=this.gameObject.worldPosition,_=this.gameObject.worldScale,g=t.worldPosition,v=g.distanceTo(y),b=Math.max(_.x,_.y,_.z),x=F(g).sub(y);if(v<b){(this.debug||Mo)&&console.warn("[ViewBox] Moving camera out of bounds",v,"<",b);const U=F(x);U.y*=1e-8,U.normalize();const N=
|
|
1431
|
+
`,u)}}h.element&&(Ur.push(h),h.element.offsetTop,h.element.offsetHeight)}this._scrollValue+this._scrollContainerHeight,gn.length=0;let r=0;const a=1/60;let l=0;for(let h=0;h<Ur.length;h++){const d=Ur[h];if(!d.element)continue;const u=Ur[h+1],p=u?u.time-a:i;l+=1;const m=d.timeline;if(m){const y=nR(m),_=1-Math.abs(y-.5)*2,g=d.name||`marker${h}`;if(y>0&&y<=1){const v=d.time+(p-d.time)*y;gn.push({name:g,time:v,weight:_}),r+=_}else h===0&&y<=0?(gn.push({name:g,time:0,weight:1}),r+=1):h===Ur.length-1&&y>=1&&(gn.push({name:g,time:i,weight:1}),r+=1)}}if(gn.length<=0&&l<=0)e.time=t*i;else if(gn.length>0){let h=gn[0].time;if(gn.length>1)for(const d of gn){const u=d.weight/Math.max(1e-5,r),p=Math.abs(d.time-h);h+=p*u}this.damping<=0?e.time=h:e.time=D.lerp(e.time,h,this.context.time.deltaTime/this.damping),Hh&&this.context.time.frame%30===0&&console.log(`[ScrollFollow ] Timeline ${e.name}: ${h.toFixed(3)}`,gn.map(d=>`[${d.name} ${(d.weight*100).toFixed(0)}%]`).join(", "))}}}qa([f([k,c.Object3D])],xs.prototype,"target");qa([f()],xs.prototype,"damping");qa([f()],xs.prototype,"invert");qa([f()],xs.prototype,"htmlSelector");qa([f()],xs.prototype,"mode");qa([f(oe)],xs.prototype,"changed");const gn=[],Ur=[],tp=new Map,ob=new Map;let ip=!0;function $w(s,e,t=0){if(!ip){if(e?.length){const o=ob.get(e)||null;if(o)return o}const n=tp.get(s)||null;return n?.getAttribute("data-timeline-marker"),n}return ip=!1,tp.clear(),document.querySelectorAll("[data-timeline-marker]").forEach((n,o)=>{tp.set(o,n);const r=n.getAttribute("data-timeline-marker");r?.length&&ob.set(r,n)}),ip=!1,$w(s,e)}function nR(s){if(!s.source)return 0;const e=s.currentTime,t=s.duration;let i=1;return(t.unit==="seconds"||t.unit==="percent")&&(i=t.value),e.unit==="seconds"?e.value/i:e.value/100}var Ww=Object.defineProperty,sR=Object.getOwnPropertyDescriptor,oR=(s,e,t)=>e in s?Ww(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,cy=(s,e,t,i)=>{for(var n=i>1?void 0:i?sR(e,t):e,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=(i?r(e,t,n):r(n))||n);return i&&n&&Ww(e,t,n),n},rR=(s,e,t)=>oR(s,e+"",t);const Mo=w("debugviewbox"),aR=new Z(.5,.5,.5,.5);exports.ViewBox=class extends k{referenceFieldOfView=void 0;debug=!1;onEnable(){(Mo||this.debug||A())&&console.debug("[ViewBox] Using camera fov:",this.referenceFieldOfView),exports.ViewBox.instances.push(this)}onDisable(){(Mo||this.debug)&&console.debug("[ViewBox] Disabled");const e=exports.ViewBox.instances.indexOf(this);e!==-1&&exports.ViewBox.instances.splice(e,1),this._projectedBoxElement?.remove()}onBeforeRender(){if(this.context.isInXR||this.destroyed)return;if(!(exports.ViewBox.instances[exports.ViewBox.instances.length-1]===this)){(Mo||this.debug)&&I.DrawWireBox(this.gameObject.worldPosition,this.gameObject.worldScale,aR);return}(Mo||this.debug)&&I.DrawWireBox(this.gameObject.worldPosition,this.gameObject.worldScale,14540032,0,!0,this.gameObject.worldQuaternion);const t=this.context.mainCamera;if(!t||!(t instanceof c.PerspectiveCamera))return;if(this.referenceFieldOfView===void 0&&(this.referenceFieldOfView=t.fov),this.referenceFieldOfView===void 0||this.referenceFieldOfView<=0){(Mo||this.debug)&&console.warn("[ViewBox] No valid referenceFieldOfView set, cannot adjust box size:",this.referenceFieldOfView);return}const i=this.context.domWidth,n=this.context.domHeight;let o=i,r=n,a=1,l=1;const h=this.context.focusRectSize;h&&(h.x,h.y,o=h.width,r=h.height,a=i/o,l=n/r);const d=t.view,u=t.zoom,p=t.aspect,m=t.fov;t.view=null,t.zoom=1,t.fov=this.referenceFieldOfView,t.updateProjectionMatrix();const y=this.gameObject.worldPosition,_=this.gameObject.worldScale,g=t.worldPosition,v=g.distanceTo(y),b=Math.max(_.x,_.y,_.z),x=F(g).sub(y);if(v<b){(this.debug||Mo)&&console.warn("[ViewBox] Moving camera out of bounds",v,"<",b);const U=F(x);U.y*=1e-8,U.normalize();const N=b-v,K=g.add(U.multiplyScalar(N));t.worldPosition=K.lerp(g,1-this.context.time.deltaTime)}const R=F(y);t.worldToLocal(R),t.lookAt(y),t.updateMatrixWorld();const O=this.referenceFieldOfView*Math.PI/180,M=2*Math.tan(O/2)*v,E=M*t.aspect,B=this.projectBoxIntoCamera(t,1),L=B.maxX-B.minX,V=B.maxY-B.minY,$=this.fit(L*t.aspect,V,E/a,M/l),T=F(y);T.project(t),this.context.focusRectSettings.offsetX=T.x,this.context.focusRectSettings.offsetY=T.y,this.context.focusRectSettings.zoom=$/(M*.5),this.context.focusRect||this.context.setCameraFocusRect(this.context.domElement),t.view=d,t.zoom=u,t.aspect=p,t.fov=m}fit(e,t,i,n){const o=i/e,r=n/t;return Math.min(o,r)}projectBoxIntoCamera(e,t){const i=.5*t,n=[F(-i,-i,-i),F(i,-i,-i),F(-i,i,-i),F(i,i,-i),F(-i,-i,i),F(i,-i,i),F(-i,i,i),F(i,i,i)];let o=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let h=0;h<n.length;h++){const d=n[h];d.applyMatrix4(this.gameObject.matrixWorld),d.project(e),d.x<o&&(o=d.x),d.x>r&&(r=d.x),d.y<a&&(a=d.y),d.y>l&&(l=d.y)}return Mo&&(this._projectedBoxElement||(this._projectedBoxElement=document.createElement("div")),this._projectedBoxElement.parentElement!==this.context.domElement&&this.context.domElement.appendChild(this._projectedBoxElement),this._projectedBoxElement.style.position="fixed",this._projectedBoxElement.style.outline="2px dashed rgba(255,0,0,.5)",this._projectedBoxElement.style.left=(o*.5+.5)*this.context.domWidth+"px",this._projectedBoxElement.style.top=(-l*.5+.5)*this.context.domHeight+"px",this._projectedBoxElement.style.width=(r-o)*.5*this.context.domWidth+"px",this._projectedBoxElement.style.height=(l-a)*.5*this.context.domHeight+"px",this._projectedBoxElement.style.pointerEvents="none",this._projectedBoxElement.style.zIndex="1000"),{minX:o,maxX:r,minY:a,maxY:l}}_projectedBoxElement=null};rR(exports.ViewBox,"instances",[]);cy([f()],exports.ViewBox.prototype,"referenceFieldOfView",2);cy([f()],exports.ViewBox.prototype,"debug",2);exports.ViewBox=cy([Lm],exports.ViewBox);var lR=Object.defineProperty,Xa=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&lR(e,t,n),n};class Ss extends k{get activeAndEnabled(){return!0}side="none";controller=!0;hands=!1;controlVisibility=!0;useGripSpace=!1;resetTransformAfterXRSession=!0;_startPosition=new c.Vector3;_startRotation=new c.Quaternion;_startScale=new c.Vector3;onEnterXR(e){this._startPosition.copy(this.gameObject.position),this._startRotation.copy(this.gameObject.quaternion),this._startScale.copy(this.gameObject.scale)}onUpdateXR(e){if(!this.enabled)return;const t=e.xr.getController(this.side);if(t){if(t.hand&&!this.hands){this.controlVisibility&&(this.gameObject.visible=!1);return}else if(!this.controller){this.controlVisibility&&(this.gameObject.visible=!1);return}this.controlVisibility&&(this.gameObject.visible=!0),this.useGripSpace||t.targetRayMode==="transient-pointer"?(this.gameObject.worldPosition=t.gripWorldPosition,this.gameObject.worldQuaternion=t.gripWorldQuaternion,this.gameObject.worldScale=F(t.xr.rigScale,t.xr.rigScale,t.xr.rigScale).multiply(this._startScale)):(this.gameObject.worldPosition=t.rayWorldPosition,this.gameObject.worldQuaternion=t.rayWorldQuaternion,this.gameObject.worldScale=F(t.xr.rigScale,t.xr.rigScale,t.xr.rigScale).multiply(this._startScale))}}onLeaveXR(e){this.resetTransformAfterXRSession&&(this.gameObject.position.copy(this._startPosition),this.gameObject.quaternion.copy(this._startRotation),this.gameObject.scale.copy(this._startScale))}}Xa([f()],Ss.prototype,"side");Xa([f()],Ss.prototype,"controller");Xa([f()],Ss.prototype,"hands");Xa([f()],Ss.prototype,"controlVisibility");Xa([f()],Ss.prototype,"useGripSpace");Xa([f()],Ss.prototype,"resetTransformAfterXRSession");function Hw(s,e){const t=s.xr.getFrame();if(!t)return console.warn("No XRFrame available"),!1;const i=t.session.enabledFeatures;if(i&&!i.some(o=>o==="camera-access"))return console.error(`No camera feed available - please request the 'camera-access' feature before starting WebXR or add the ARCameraBackground component to your scene.
|
|
1432
1432
|
|
|
1433
1433
|
Example to request camera-access in global scope:
|
|
1434
1434
|
NeedleXRSession.onSessionRequestStart(evt => {
|
|
@@ -1474,7 +1474,7 @@ void main() {
|
|
|
1474
1474
|
#include <colorspace_fragment>
|
|
1475
1475
|
}
|
|
1476
1476
|
`;var mR=Object.defineProperty,vo=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&mR(e,t,n),n};const Hd=w("debugimagetracking");class xa{get url(){return this._trackedImage.image??""}get widthInMeters(){return this._trackedImage.widthInMeters??void 0}get bitmap(){return this._bitmap}get model(){return this._trackedImage}measuredSize;state;getPosition(e){return this.ensureTransformData(),e.copy(this._position),e}getQuaternion(e){return this.ensureTransformData(),e.copy(this._rotation),e}applyToObject(e,t=void 0){this.ensureTransformData();const i=e.position.distanceToSquared(this._position)/.05+e.quaternion.angleTo(this._rotation)/.05;t&&(t*=Math.max(1,i)),t===void 0||t>=1?(e.position.copy(this._position),e.quaternion.copy(this._rotation)):(t=Math.max(0,Math.min(1,t)),e.position.lerp(this._position,t),e.quaternion.slerp(this._rotation,t))}static _positionBuffer=new di(()=>new c.Vector3,20);static _rotationBuffer=new di(()=>new c.Quaternion,20);_position;_rotation;ensureTransformData(){if(!this._position){this._position=xa._positionBuffer.get(),this._rotation=xa._rotationBuffer.get();const e=this._pose.transform,t=G.active.convertSpace(e);this._position.copy(t?.position),this._rotation.copy(t?.quaternion)}}_trackingComponent;_trackedImage;_bitmap;_pose;constructor(e,t,i,n,o,r){this._trackingComponent=e,this._trackedImage=t,this._bitmap=i,this.measuredSize=n,this.state=o,this._pose=r}}class Cs{constructor(e){this.image=e.url,this.widthInMeters=e.widthInMeters,e.object instanceof c.Object3D?this.object=new Y({asset:e.object}):this.object=e.object,e.createObjectInstance!==void 0&&(this.createObjectInstance=e.createObjectInstance),e.imageDoesNotMove!==void 0&&(this.imageDoesNotMove=e.imageDoesNotMove),e.hideWhenTrackingIsLost!==void 0&&(this.hideWhenTrackingIsLost=e.hideWhenTrackingIsLost)}image;widthInMeters=.25;object;createObjectInstance=!1;imageDoesNotMove=!1;hideWhenTrackingIsLost=!0;getNameFromUrl(){if(this.image){const e=this.image.split("/");return e[e.length-1]}return null}}vo([f(URL)],Cs.prototype,"image");vo([f()],Cs.prototype,"widthInMeters");vo([f(Y)],Cs.prototype,"object");vo([f()],Cs.prototype,"createObjectInstance");vo([f()],Cs.prototype,"imageDoesNotMove");vo([f()],Cs.prototype,"hideWhenTrackingIsLost");class gR{constructor(e,t){this.exporter=e,this.component=t,Hd&&console.log(this),this.exporter.anchoringType="image"}isImageTrackingExtension=!0;get extensionName(){return"image-tracking"}shouldExport=!0;filename=null;imageModel=null;onBeforeBuildDocument(e){const t=this.exporter.extensions.filter(i=>{const n=i;return n.isImageTrackingExtension&&n.component.activeAndEnabled&&n.component.trackedImages?.length>0}).indexOf(this);this.shouldExport=t===0,this.shouldExport&&this.component.trackedImages?.length>1&&(Hd||A())&&(he("USDZ: Only one tracked image is supported."),console.warn("USDZ: Only one tracked image is supported. Will choose the first one in the trackedImages list"))}onAfterHierarchy(e,t){if(!this.shouldExport)return;const i=exports.DeviceUtilities.getiOSVersion(),r=(i?parseInt(i.split(".")[0]):18)>=18?1:100;t.beginBlock('def Preliminary_ReferenceImage "AnchoringReferenceImage"'),t.appendLine("uniform asset image = @image_tracking/"+this.filename+"@"),t.appendLine("uniform double physicalWidth = "+(this.imageModel.widthInMeters*r).toFixed(8)),t.closeBlock()}async onAfterSerialize(e){if(!this.shouldExport)return;const t=this.imageModel,i=Gl.get(t.image),r=await(await(await sw(i)).convertToBlob({type:"image/png"})).arrayBuffer();e.files["image_tracking/"+this.filename]=new Uint8Array(r)}onExportObject(e,t,i){if(!this.shouldExport)return;const n=this.component;if(!n||!n.trackedImages?.length||!n.activeAndEnabled)return;const o=n.trackedImages[0];if(o.object?.asset===e){this.imageModel=o,this.filename=o.getNameFromUrl()||"marker.png";const{scale:r,target:a}=this.exporter.getARScaleAndTarget();let l=e;const h=new c.Matrix4;if(e!==a)for(;l&&l.parent&&l.parent!==a;)l=l.parent,h.premultiply(l.matrix);const d=h.clone().invert();t.setMatrix(d.scale(new c.Vector3(r,r,r)))}}}class dh extends k{setPrimaryImage(e){const t=this.trackedImages.indexOf(e);if(t>=0){const i=this.trackedImages[0];i!==e&&(this.trackedImages[0]=e,this.trackedImages[t]=i)}else console.warn(`[WebXRImageTracking] Can not set primary: image not found in 'trackedImages' array ${e.image}`)}addImage(e,t=!1){this.trackedImages.includes(e)||(this.trackedImages.push(e),lb(e.image)),t&&this.setPrimaryImage(e)}trackedImages=[];smooth=!0;trackedImageIndexMap=new Map;get supported(){return this._supported}_supported=!0;awake(){if(Hd&&console.log(this),!!this.trackedImages)for(const e of this.trackedImages)e.image&&lb(e.image)}onEnable(){Ln.beforeExport.addEventListener(this.onBeforeUSDZExport)}onDisable(){Ln.beforeExport.removeEventListener(this.onBeforeUSDZExport)}onBeforeUSDZExport=e=>{this.activeAndEnabled&&this.trackedImages?.length&&e.exporter.extensions.push(new gR(e.exporter,this))};onBeforeXR(e,t){if(this.trackedImages){t.optionalFeatures=t.optionalFeatures||[],t.optionalFeatures.includes("image-tracking")||t.optionalFeatures.push("image-tracking"),t.trackedImages=[];for(const i of this.trackedImages)if(i.image?.length&&i.widthInMeters>0){const n=Gl.get(i.image);n&&(this.trackedImageIndexMap.set(t.trackedImages.length,i),t.trackedImages.push({image:n,widthInMeters:i.widthInMeters}))}}}onEnterXR(e){if(this.trackedImages){for(const t of this.trackedImages)if(t.object?.asset){const i=t.object.asset;i.userData||(i.userData={});const n={visible:i.visible,parent:i.parent,matrix:i.matrix.clone()};i.userData["image-tracking"]=n}}for(const t of this.imageToObjectMap.values())t.frames=0}onLeaveXR(e){if(!this.supported&&exports.DeviceUtilities.isAndroidDevice()&&he(this.webXRIncubationsWarning),this.trackedImages){for(const t of this.trackedImages)if(t.object?.asset){const i=t.object.asset;if(i.userData){const n=i.userData["image-tracking"];n&&(i.visible=n.visible,n.parent?.add(i),i.matrix.copy(n.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale)),delete i.userData["image-tracking"]}}}}imageToObjectMap=new Map;currentImages=[];webXRIncubationsWarning=`Image tracking is currently not supported on this device. On Chrome for Android, you can enable the <a target="_blank" href="#" onclick="() => console.log('I')">chrome://flags/#webxr-incubations</a> flag.`;onUpdateXR(e){this.currentImages.length=0;const t=e.xr.frame;if(!t)return;if("getImageTrackingResults"in t){if(e.xr.session.enabledFeatures?.includes("image-tracking")===!1)return;if(t.session&&typeof t.getImageTrackingResults=="function"){const n=t.getImageTrackingResults();if(n.length>0){const o=this.context.renderer.xr.getReferenceSpace();if(o){for(const r of n){const a=r.trackingState,l=r.index,h=this.trackedImageIndexMap.get(l);if(h){const d=t.getPose(r.imageSpace,o),u=new xa(this,h,r.image,r.measuredSize,a,d);this.currentImages.push(u)}else Hd&&console.warn("No tracked image for index",l)}if(this.currentImages.length>0)try{this.dispatchEvent(new CustomEvent("image-tracking",{detail:this.currentImages})),this.onImageTrackingUpdate(this.currentImages)}catch(r){console.error(r)}}}}}else{this.didPrintWarning||(this.didPrintWarning=!0,console.log(this.webXRIncubationsWarning)),this._supported=!1,he(this.webXRIncubationsWarning);return}const i=1e3;for(const[n,o]of this.imageToObjectMap){if(!o.object||!n||n.hideWhenTrackingIsLost===!1)continue;let r=!1;for(const a of this.currentImages)if(a.model===n){const l=Date.now()-o.lastTrackingTime;if(n.imageDoesNotMove||a.state==="tracked"||l<=i){r=!0;break}}r||S.setActive(o.object,!1)}}onImageTrackingUpdate=e=>{const t=G.active;if(t)for(const i of e){const n=i.model,o=i.state==="tracked";if(!n.object)continue;let r=this.imageToObjectMap.get(n);if(r===void 0)r={object:null,frames:0,lastTrackingTime:Date.now()},this.imageToObjectMap.set(n,r),n.object.loadAssetAsync().then(a=>{if(n.createObjectInstance&&a&&(a=S.instantiate(a)),a){r.object=a;for(const l of a.getComponentsInChildren(mi))l.setInstancingEnabled(!1);t.rig?(t.rig.gameObject.add(a),i.applyToObject(a),a.activeSelf||S.setActive(a,!0)):console.warn("XRImageTracking: missing XRRig")}});else{if(r.frames++,o&&(r.lastTrackingTime=Date.now()),n.imageDoesNotMove&&r.frames>10||!r.object)continue;t.rig&&(t.rig.gameObject.add(r.object),i.applyToObject(r.object,this.smooth?this.context.time.deltaTimeUnscaled*3:void 0),r.object.activeSelf||S.setActive(r.object,!0))}}}}vo([f(Cs)],dh.prototype,"trackedImages");vo([f()],dh.prototype,"smooth");const Gl=new Map,Gh=new Map;async function lb(s){if(Gl.has(s))return Gh.has(s)?Gh.get(s):Promise.resolve(!0);const e=new Promise(t=>{Gl.set(s,null);const i=document.createElement("img");i.src=s,i.addEventListener("load",async()=>{const n=await createImageBitmap(i);Gl.set(s,n),t(!0)})});return Gh.set(s,e),e.finally(()=>{Gh.delete(s)}),e}var yR=Object.defineProperty,Qa=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&yR(e,t,n),n};const ko=w("debugplanetracking");class Ps extends k{dataTemplate;occluder=!0;initiateRoomCaptureIfNoData=!0;usePlaneData=!0;useMeshData=!0;runInVR=!0;get trackedPlanes(){return this._allPlanes.values()}get trackedMeshes(){return this._allMeshes.values()}onBeforeXR(e,t){e==="immersive-vr"&&!this.runInVR||(t.optionalFeatures=t.optionalFeatures||[],this.usePlaneData&&!t.optionalFeatures.includes("plane-detection")&&t.optionalFeatures.push("plane-detection"),this.useMeshData&&!t.optionalFeatures.includes("mesh-detection")&&t.optionalFeatures.push("mesh-detection"))}onEnterXR(e){for(const t of this._allPlanes.keys())this.removeData(t,this._allPlanes);for(const t of this._allMeshes.keys())this.removeData(t,this._allMeshes)}onLeaveXR(e){for(const t of this._allPlanes.keys())this.removeData(t,this._allPlanes);for(const t of this._allMeshes.keys())this.removeData(t,this._allMeshes)}onUpdateXR(e){if(!this.runInVR&&e.xr.isVR)return;const t=e.xr.rig;if(!t){console.warn("No XR rig found, cannot parent tracked planes to it");return}const i=e.xr.frame;if(!this.context.renderer.xr.getReferenceSpace())return;const r=i.detectedPlanes,a=i.detectedMeshes,l=r!==void 0&&r.size>0,h=a!==void 0&&a.size>0;if(this.initiateRoomCaptureIfNoData&&(!l&&!h&&this.firstTimeNoPlanesDetected<-10&&(this.firstTimeNoPlanesDetected=Date.now()),(l||h)&&(this.firstTimeNoPlanesDetected=-1),this.firstTimeNoPlanesDetected>0&&Date.now()-this.firstTimeNoPlanesDetected>2500&&"initiateRoomCapture"in i.session&&(i.session.initiateRoomCapture(),this.firstTimeNoPlanesDetected=-1)),r!==void 0&&this.processFrameData(e.xr,t.gameObject,i,r,this._allPlanes),a!==void 0&&this.processFrameData(e.xr,t.gameObject,i,a,this._allMeshes),ko){const d=this.context.mainCameraComponent.gameObject.worldPosition;for(const u of this._allPlanes.values())!u.mesh||!u.mesh.visible||(this.bounds.makeEmpty(),u.mesh.traverse(p=>{p instanceof c.Mesh&&this.bounds.expandByObject(p)}),this.bounds.getCenter(this.center),this.labelOffset.copy(d).sub(this.center).normalize().multiplyScalar(.1),I.DrawLabel(this.center.add(this.labelOffset),(u.xrData.semanticLabel||"plane").toUpperCase()+`
|
|
1477
|
-
`+u.xrData.lastChangedTime.toFixed(2),.02))}}bounds=new c.Box3;center=new c.Vector3;labelOffset=new c.Vector3;removeData(e,t){const i=t.get(e);if(!i)return;t.delete(e),ko&&console.log("Plane no longer tracked, id="+i.id),i.mesh&&(i.mesh.removeFromParent(),i.mesh.traverse(o=>{const r=o.userData.normalsHelper;r?(r.dispose(),r.removeFromParent()):ko&&console.warn("No normals helper found for mesh",i.mesh)}),ui(i.mesh,!0,!0));const n=new CustomEvent("plane-tracking",{detail:{type:"plane-removed",context:i}});this.dispatchEvent(n)}_dataId=1;_allPlanes=new Map;_allMeshes=new Map;firstTimeNoPlanesDetected=-100;makeOccluder=(e,t,i=!1)=>{if(t){if(t instanceof Array){for(const n of t)this.makeOccluder(e,n,i);return}!i&&!t.name.toLowerCase().includes("occlu")||(t.colorWrite=!1,t.depthTest=!0,t.depthWrite=!0,t.transparent=!1,t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=.1,e.renderOrder=-1e3)}};processFrameData(e,t,i,n,o){const a=this.context.renderer.xr.getReferenceSpace();if(a){for(const l of o.keys())n.has(l)||this.removeData(l,o);for(const l of n){const h="planeSpace"in l?l.planeSpace:"meshSpace"in l?l.meshSpace:void 0;if(!h)continue;const d=i.getPose(h,a);let u;if(o.has(l)){const p=o.get(l);if(u=p.mesh,p.timestamp<l.lastChangedTime){if(p.timestamp=l.lastChangedTime,p.mesh){const y=this.createGeometry(l);if(p.mesh instanceof c.Mesh)p.mesh.geometry.dispose(),p.mesh.geometry=y,this.makeOccluder(p.mesh,p.mesh.material);else if(p.mesh instanceof c.Group)for(const _ of p.mesh.children)_ instanceof c.Mesh&&(_.geometry.dispose(),_.geometry=y,this.makeOccluder(_,_.material));if(p.collider){const _=p.mesh;p.collider.sharedMesh=_,p.collider.convex=this.checkIfContextShouldBeConvex(_,p.xrData),p.collider.onDisable(),p.collider.onEnable()}ko&&(console.log("Plane updated, id="+p.id,p),p.mesh.traverse(_=>{if(!(_ instanceof c.Mesh))return;const g=_.userData.normalsHelper;g&&g.update()}))}const m=new CustomEvent("plane-tracking",{detail:{type:"plane-updated",context:p}});this.dispatchEvent(m)}}else{if(!this.dataTemplate){const p=new c.Mesh;ko?p.material=new c.MeshNormalMaterial:this.occluder?(p.material=new c.MeshBasicMaterial,this.makeOccluder(p,p.material,!0)):p.material=new c.MeshBasicMaterial({wireframe:!0,opacity:.5,transparent:!0,color:3355443}),this.dataTemplate=new Y("","",p)}if(!this.dataTemplate.asset)this.dataTemplate.loadAssetAsync();else{const p=S.instantiate(this.dataTemplate.asset);if(p.name="xr-tracked-plane",u=p,pm(p,!1),p instanceof c.Mesh)_e(p.geometry),p.geometry=this.createGeometry(l),this.makeOccluder(p,p.material,this.occluder&&!this.dataTemplate);else if(p instanceof c.Group)for(const _ of p.children)_ instanceof c.Mesh&&(_e(_.geometry),_.geometry=this.createGeometry(l),this.makeOccluder(_,_.material,this.occluder&&!this.dataTemplate));const m=p.getComponent(lo);if(m){const _=p;m.sharedMesh=_,m.convex=this.checkIfContextShouldBeConvex(_,l),m.onDisable(),m.onEnable()}p.matrixAutoUpdate=!1,p.matrixWorldNeedsUpdate=!0,t.add(p);const y={id:this._dataId++,xrData:l,timestamp:l.lastChangedTime,mesh:p,collider:m};o.set(l,y),ko&&console.log("New plane detected, id="+y.id,y,{hasCollider:!!m,isGroup:p instanceof c.Group});try{const _=new CustomEvent("plane-tracking",{detail:{type:"plane-added",context:y}});this.dispatchEvent(_)}catch(_){console.error(_)}}}u&&(d?(u.visible=!0,u.matrix.fromArray(d.transform.matrix),u.matrix.premultiply(this._flipForwardMatrix)):u.visible=!1,ko&&u.traverse(p=>{if(p instanceof c.Mesh)if(p.userData.normalsHelper)p.userData.normalsHelper.update();else{const m=new q.VertexNormalsHelper(p,.05,255);m.layers.disableAll(),m.layers.set(2),this.context.scene.add(m),p.userData.normalsHelper=m}}))}}}_flipForwardMatrix=new c.Matrix4().makeRotationY(Math.PI);checkIfContextShouldBeConvex(e,t){if(!e)return!0;if(e){const i=new c.Box3;i.expandByObject(e);const n=new c.Vector3;i.getSize(n);let o=!0;return n.x>2&&n.y>2&&n.z>1.5&&(o=!1),o&&"semanticLabel"in t&&t.semanticLabel==="wall"&&(o=!0),o}return!0}createGeometry(e){return"polygon"in e?this.createPlaneGeometry(e.polygon):"vertices"in e&&"indices"in e?this.createMeshGeometry(e.vertices,e.indices):new c.BufferGeometry}_verticesCache=new Map;createMeshGeometry(e,t){const i=e.toString()+"_"+t.toString();if(this._verticesCache.has(i))return this._verticesCache.get(i);const n=new c.BufferGeometry;n.setIndex(new c.BufferAttribute(t,1)),n.setAttribute("position",new c.BufferAttribute(e,3));const o=Array();for(let r=0;r<e.length;r+=3)o.push(e[r],e[r+2]);return n.setAttribute("uv",new c.BufferAttribute(e,3)),n.computeVertexNormals(),this._verticesCache.set(i,n),n}createPlaneGeometry(e){const t=new c.BufferGeometry,i=[],n=[];e.forEach(p=>{i.push(p.x,p.y,p.z),n.push(p.x,p.z)});const o=new c.Vector3(i[0],i[1],i[2]),r=new c.Vector3(i[3],i[4],i[5]),a=new c.Vector3(i[6],i[7],i[8]),l=new c.Vector3,h=new c.Vector3;l.subVectors(r,o),h.subVectors(a,o),l.cross(h),l.normalize();const d=[];for(let p=0;p<i.length/3;p++)d.push(l.x,l.y,l.z);const u=[];for(let p=2;p<e.length;++p)u.push(0,p-1,p);return t.setAttribute("position",new c.BufferAttribute(new Float32Array(i),3)),t.setAttribute("uv",new c.BufferAttribute(new Float32Array(n),2)),t.setAttribute("normal",new c.BufferAttribute(new Float32Array(d),3)),t.setIndex(u),t.computeBoundingBox(),t.computeBoundingSphere(),t}}Qa([f(Y)],Ps.prototype,"dataTemplate");Qa([f()],Ps.prototype,"occluder");Qa([f()],Ps.prototype,"initiateRoomCaptureIfNoData");Qa([f()],Ps.prototype,"usePlaneData");Qa([f()],Ps.prototype,"useMeshData");Qa([f()],Ps.prototype,"runInVR");var _R=Object.defineProperty,bR=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&_R(e,t,n),n};const cb=w("debugwebxr");class Yu extends k{priority=0;get isActive(){return this.activeAndEnabled&&this.gameObject.visible}setAsActiveXRRig(){G.active?.setRigActive(this)}setPriority(e){this.priority=e}awake(){if(cb){const e=new c.Object3D;e.position.y+=.5,this.gameObject.add(e);const t=e.addNewComponent(vr);t&&(t.isGizmo=!1);const i=new c.AxesHelper(.5);this.gameObject.add(i)}}isXRRig(){return!0}supportsXR(e){return!0}_startScale;onEnterXR(e){this._startScale=this.gameObject.scale.clone(),e.xr.addRig(this),cb&&console.log("WebXR: add Rig",this.name,this.priority)}onLeaveXR(e){e.xr.removeRig(this),this._startScale&&this.gameObject&&this.gameObject.scale.copy(this._startScale)}}bR([f()],Yu.prototype,"priority");class vR extends k{toggleKey="KeyP";update(){this.context.input.isKeyDown(this.toggleKey)&&this.context.domElement.classList.toggle("presentation-mode")}}P.add("AlignmentConstraint",Oc);P.add("Animation",St);P.add("Animator",rt);P.add("AudioListener",ss);P.add("AudioSource",pi);P.add("Avatar_Brain_LookAt",nc);P.add("Avatar_MouthShapes",Rc);P.add("Avatar_MustacheShake",Qm);P.add("AvatarBlink_Simple",ur);P.add("AvatarEyeLook_Rotation",Km);P.add("AxesHelper",Oa);P.add("BasicIKConstraint",Jm);P.add("BoxHelperComponent",nt);P.add("Camera",qt);P.add("CharacterController",fr);P.add("CharacterControllerInput",fs);P.add("Collider",Kt);P.add("SphereCollider",Ma);P.add("BoxCollider",pu);P.add("MeshCollider",lo);P.add("CapsuleCollider",cs);P.add("ContactShadows",Tc);P.add("LogStats",tg);P.add("DeleteBox",Xs);P.add("Deletable",ng);P.add("DeviceFlag",mu);P.add("DragControls",Io);P.add("DropListener",ps);P.add("Duplicatable",rg);P.add("EventListEvent",cu);P.add("EventTrigger",yu);P.add("GltfExportBox",fg);P.add("GltfExport",mg);P.add("VariantAction",_g);P.add("ChangeTransformOnClick",yr);P.add("ChangeMaterialOnClick",bg);P.add("SetActiveOnClick",vg);P.add("HideOnStart",Ei);P.add("EmphasizeOnClick",Ra);P.add("PlayAudioOnClick",Js);P.add("PlayAnimationOnClick",oc);P.add("PreliminaryAction",Ta);P.add("PreliminaryTrigger",jc);P.add("VisibilityAction",Bc);P.add("TapGestureTrigger",xg);P.add("USDZExporter",Ln);P.add("Fog",Ia);P.add("BoxGizmo",vr);P.add("GridHelper",ja);P.add("GroundProjectedEnv",Bn);P.add("UsageMarker",Ac);P.add("Interactable",ig);P.add("FixedJoint",Vg);P.add("HingeJoint",Vc);P.add("Light",ei);P.add("LODGroup",Wc);P.add("LookAtConstraint",dr);P.add("NeedleMenu",Un);P.add("NestedGltf",Hc);P.add("Networking",Wg);P.add("OffsetConstraint",wr);P.add("CameraTargetReachedEvent",ic);P.add("OrbitControls",de);P.add("ParticleSystemRenderer",Vi);P.add("ParticleSystem",ac);P.add("Attractor",Ua);P.add("PlayerColor",wa);P.add("Antialiasing",Xc);P.add("BloomEffect",Au);P.add("ChromaticAberration",Qc);P.add("ColorAdjustments",go);P.add("DepthOfField",hn);P.add("EffectWrapper",lc);P.add("PixelationEffect",Yc);P.add("ScreenSpaceAmbientOcclusion",vs);P.add("ScreenSpaceAmbientOcclusionN8",dn);P.add("SharpeningEffect",Zc);P.add("TiltShiftEffect",Vn);P.add("ToneMappingEffect",io);P.add("Vignette",Mr);P.add("Volume",Na);P.add("ReflectionProbe",sc);P.add("Renderer",mi);P.add("MeshRenderer",Lc);P.add("SkinnedMeshRenderer",ug);P.add("Rigidbody",Ne);P.add("SceneSwitcher",Be);P.add("ScreenCapture",yo);P.add("ShadowCatcher",eh);P.add("RemoteSkybox",Du);P.add("SmoothFollow",ju);P.add("SpatialTriggerReceiver",Dn);P.add("SpatialTrigger",Bu);P.add("SpectatorCamera",Fu);P.add("SplineContainer",kr);P.add("SplineWalker",un);P.add("SpriteRenderer",Zt);P.add("SyncedCamera",ey);P.add("SyncedRoom",fn);P.add("SyncedTransform",on);P.add("TestRunner",ty);P.add("TestSimulateUserData",iy);P.add("PlayableDirector",or);P.add("SignalReceiver",oh);P.add("AnimationTrackHandler",cc);P.add("AudioTrackHandler",rs);P.add("MarkerTrackHandler",Nu);P.add("SignalTrackHandler",hc);P.add("ControlTrackHandler",Vu);P.add("TransformGizmo",Rr);P.add("BaseUIComponent",Bi);P.add("UIRootComponent",Fc);P.add("Button",ws);P.add("Canvas",va);P.add("CanvasGroup",to);P.add("EventSystem",Bt);P.add("Graphic",zc);P.add("MaskableGraphic",Nc);P.add("Image",Wa);P.add("RawImage",Hu);P.add("InputField",ry);P.add("VerticalLayoutGroup",Ag);P.add("HorizontalLayoutGroup",Lg);P.add("GridLayoutGroup",Dg);P.add("Outline",Da);P.add("ObjectRaycaster",fi);P.add("GraphicRaycaster",hu);P.add("SpatialGrabRaycaster",er);P.add("RectTransform",rn);P.add("SpatialHtml",ah);P.add("Text",Pt);P.add("EnvironmentScene",qu);P.add("LookAt",ay);P.add("OpenURL",Ha);P.add("VideoPlayer",Ze);P.add("Voip",ao);P.add("ClickThrough",Qu);P.add("CursorFollow",ch);P.add("HoverAnimation",exports.HoverAnimation);P.add("ScrollFollow",xs);P.add("ResponsiveBox",exports.ViewBox);P.add("Avatar",eo);P.add("XRControllerFollow",Ss);P.add("XRControllerModel",hs);P.add("XRControllerMovement",gi);P.add("TeleportTarget",Cu);P.add("WebARCameraBackground",hh);P.add("WebARSessionRoot",hi);P.add("WebXR",Pu);P.add("AvatarMarker",xe);P.add("WebXRImageTracking",dh);P.add("WebXRPlaneTracking",Ps);P.add("XRRig",Yu);P.add("XRFlag",Ti);P.add("PlayerSync",Og);P.add("PlayerState",Zi);P.add("PresentationMode",vR);const ql=st,wR=w("debugtypestore");wR&&console.log(P);function xR(s,e){const i=k0(s,e);return i!==void 0?i:null}const SR=new TC,np=Symbol("deserialize-queue");async function CR(s,e,t,i=null,n){if(!t){console.debug("Can not create component instances: gltf is null");return}const o=[];let r=i;typeof r=="number"&&(r=new mt(i));const a=e.indexOf("?");e=a===-1?e:e.substring(0,a);const l=new jm(t.scene);l.gltfId=e,l.context=s,l.gltf=t,l.nodeToObject=n?.nodeToObjectMap,l.implementationInformation=SR;let h=s[np];if(h||(h=s[np]=[]),t.scenes)for(const d of t.scenes)await em(l,d,h,o,0);if(t.children)for(const d of t.children)await em(l,d,h,o,0);s.new_scripts_pre_setup_callbacks.push(()=>{const d=s[np];if(d){for(const u of d)PR(u,l);d.length=0}if(r){const u={},p=[];Jp(t,r,u,p);for(const m of t.scenes)Jp(m,r,u,p);for(const m of p)m.resolveGuids(u)}})}const Zp=Symbol("original-component-name"),zr=new Map;function Jp(s,e,t,i){if(e===null||!s)return;const n=s.guid,o=s.guid;o?.length&&(zr.has(o)||(ql&&console.log('Creating InstanceIdProvider with key "'+o+'" for object '+s.name),zr.set(o,new mt(o))));const r=o&&zr.get(o)||e;if(s.guid=r.generateUUID(),n&&n!=="invalid"&&(t[n]=s.guid),s&&s.userData&&s.userData.components)for(const a of s.userData.components){if(a===null)continue;const l=a.guid;l?zr.has(l)||(ql&&console.log('Creating InstanceIdProvider with key "'+l+'" for component '+a[Zp]),zr.set(l,new mt(l))):ql&&console.warn("Can not create IdProvider: component "+a[Zp]+" has no guid",a.guid);const h=zr.get(l)||e,d=a.guid;a.guid=h.generateUUID(),d&&d!=="invalid"&&(t[d]=a.guid),a.resolveGuids&&i.push(a)}if(s.children)for(const a of s.children)Jp(a,e,t,i)}const hl=[];async function em(s,e,t,i,n){if(!e)return;const o=e.userData;if(o){const r=o.builtin_components;if(r&&r.length>0)for(const a of r)try{if(a===null)continue;const l=P.get(a.name);if(l!=null){const h=new l;h.sourceId=s.gltfId,ya(h,a,s.implementationInformation),h.context=s.context,"guid"in a&&(h[Il]=a.guid),h[Zp]=a.name,No(e,h,!1),t.push({instance:h,compData:a,obj:e}),h.isCamera&&s.context&&s.context.mainCamera===null&&h.tag==="MainCamera"&&s.context.setCurrentCamera(h),s.context?.physics?.engine?.isInitialized===!1&&(h.isCollider||h.isRigidbody)&&s.context?.physics.engine?.initialize()}else ql&&console.debug("unknown component: "+a.name),hl.includes(a.name)||hl.push(a.name)}catch(l){console.error(a.name+" - "+l.message,l)}}if(e.children)for(const r of e.children)await em(s,r,t,i,n+1);if(hl.length>0&&n===0){const r=hl.join(", ");console.warn(`Unknown components in scene: ${r}`),hl.length=0,Ii()&&Se(`<strong>Unknown components in scene</strong>:
|
|
1477
|
+
`+u.xrData.lastChangedTime.toFixed(2),.02))}}bounds=new c.Box3;center=new c.Vector3;labelOffset=new c.Vector3;removeData(e,t){const i=t.get(e);if(!i)return;t.delete(e),ko&&console.log("Plane no longer tracked, id="+i.id),i.mesh&&(i.mesh.removeFromParent(),i.mesh.traverse(o=>{const r=o.userData.normalsHelper;r?(r.dispose(),r.removeFromParent()):ko&&console.warn("No normals helper found for mesh",i.mesh)}),ui(i.mesh,!0,!0));const n=new CustomEvent("plane-tracking",{detail:{type:"plane-removed",context:i}});this.dispatchEvent(n)}_dataId=1;_allPlanes=new Map;_allMeshes=new Map;firstTimeNoPlanesDetected=-100;makeOccluder=(e,t,i=!1)=>{if(t){if(t instanceof Array){for(const n of t)this.makeOccluder(e,n,i);return}!i&&!t.name.toLowerCase().includes("occlu")||(t.colorWrite=!1,t.depthTest=!0,t.depthWrite=!0,t.transparent=!1,t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=.1,e.renderOrder=-1e3)}};processFrameData(e,t,i,n,o){const a=this.context.renderer.xr.getReferenceSpace();if(a){for(const l of o.keys())n.has(l)||this.removeData(l,o);for(const l of n){const h="planeSpace"in l?l.planeSpace:"meshSpace"in l?l.meshSpace:void 0;if(!h)continue;const d=i.getPose(h,a);let u;if(o.has(l)){const p=o.get(l);if(u=p.mesh,p.timestamp<l.lastChangedTime){if(p.timestamp=l.lastChangedTime,p.mesh){const y=this.createGeometry(l);if(p.mesh instanceof c.Mesh)p.mesh.geometry.dispose(),p.mesh.geometry=y,this.makeOccluder(p.mesh,p.mesh.material);else if(p.mesh instanceof c.Group)for(const _ of p.mesh.children)_ instanceof c.Mesh&&(_.geometry.dispose(),_.geometry=y,this.makeOccluder(_,_.material));if(p.collider){const _=p.mesh;p.collider.sharedMesh=_,p.collider.convex=this.checkIfContextShouldBeConvex(_,p.xrData),p.collider.onDisable(),p.collider.onEnable()}ko&&(console.log("Plane updated, id="+p.id,p),p.mesh.traverse(_=>{if(!(_ instanceof c.Mesh))return;const g=_.userData.normalsHelper;g&&g.update()}))}const m=new CustomEvent("plane-tracking",{detail:{type:"plane-updated",context:p}});this.dispatchEvent(m)}}else{if(!this.dataTemplate){const p=new c.Mesh;ko?p.material=new c.MeshNormalMaterial:this.occluder?(p.material=new c.MeshBasicMaterial,this.makeOccluder(p,p.material,!0)):p.material=new c.MeshBasicMaterial({wireframe:!0,opacity:.5,transparent:!0,color:3355443}),this.dataTemplate=new Y("","",p)}if(!this.dataTemplate.asset)this.dataTemplate.loadAssetAsync();else{const p=S.instantiate(this.dataTemplate.asset);if(p.name="xr-tracked-plane",u=p,pm(p,!1),p instanceof c.Mesh)_e(p.geometry),p.geometry=this.createGeometry(l),this.makeOccluder(p,p.material,this.occluder&&!this.dataTemplate);else if(p instanceof c.Group)for(const _ of p.children)_ instanceof c.Mesh&&(_e(_.geometry),_.geometry=this.createGeometry(l),this.makeOccluder(_,_.material,this.occluder&&!this.dataTemplate));const m=p.getComponent(lo);if(m){const _=p;m.sharedMesh=_,m.convex=this.checkIfContextShouldBeConvex(_,l),m.onDisable(),m.onEnable()}p.matrixAutoUpdate=!1,p.matrixWorldNeedsUpdate=!0,t.add(p);const y={id:this._dataId++,xrData:l,timestamp:l.lastChangedTime,mesh:p,collider:m};o.set(l,y),ko&&console.log("New plane detected, id="+y.id,y,{hasCollider:!!m,isGroup:p instanceof c.Group});try{const _=new CustomEvent("plane-tracking",{detail:{type:"plane-added",context:y}});this.dispatchEvent(_)}catch(_){console.error(_)}}}u&&(d?(u.visible=!0,u.matrix.fromArray(d.transform.matrix),u.matrix.premultiply(this._flipForwardMatrix)):u.visible=!1,ko&&u.traverse(p=>{if(p instanceof c.Mesh)if(p.userData.normalsHelper)p.userData.normalsHelper.update();else{const m=new q.VertexNormalsHelper(p,.05,255);m.layers.disableAll(),m.layers.set(2),this.context.scene.add(m),p.userData.normalsHelper=m}}))}}}_flipForwardMatrix=new c.Matrix4().makeRotationY(Math.PI);checkIfContextShouldBeConvex(e,t){if(!e)return!0;if(e){const i=new c.Box3;i.expandByObject(e);const n=new c.Vector3;i.getSize(n);let o=!0;return n.x>2&&n.y>2&&n.z>1.5&&(o=!1),o&&"semanticLabel"in t&&t.semanticLabel==="wall"&&(o=!0),o}return!0}createGeometry(e){return"polygon"in e?this.createPlaneGeometry(e.polygon):"vertices"in e&&"indices"in e?this.createMeshGeometry(e.vertices,e.indices):new c.BufferGeometry}_verticesCache=new Map;createMeshGeometry(e,t){const i=e.toString()+"_"+t.toString();if(this._verticesCache.has(i))return this._verticesCache.get(i);const n=new c.BufferGeometry;n.setIndex(new c.BufferAttribute(t,1)),n.setAttribute("position",new c.BufferAttribute(e,3));const o=Array();for(let r=0;r<e.length;r+=3)o.push(e[r],e[r+2]);return n.setAttribute("uv",new c.BufferAttribute(e,3)),n.computeVertexNormals(),this._verticesCache.set(i,n),n}createPlaneGeometry(e){const t=new c.BufferGeometry,i=[],n=[];e.forEach(p=>{i.push(p.x,p.y,p.z),n.push(p.x,p.z)});const o=new c.Vector3(i[0],i[1],i[2]),r=new c.Vector3(i[3],i[4],i[5]),a=new c.Vector3(i[6],i[7],i[8]),l=new c.Vector3,h=new c.Vector3;l.subVectors(r,o),h.subVectors(a,o),l.cross(h),l.normalize();const d=[];for(let p=0;p<i.length/3;p++)d.push(l.x,l.y,l.z);const u=[];for(let p=2;p<e.length;++p)u.push(0,p-1,p);return t.setAttribute("position",new c.BufferAttribute(new Float32Array(i),3)),t.setAttribute("uv",new c.BufferAttribute(new Float32Array(n),2)),t.setAttribute("normal",new c.BufferAttribute(new Float32Array(d),3)),t.setIndex(u),t.computeBoundingBox(),t.computeBoundingSphere(),t}}Qa([f(Y)],Ps.prototype,"dataTemplate");Qa([f()],Ps.prototype,"occluder");Qa([f()],Ps.prototype,"initiateRoomCaptureIfNoData");Qa([f()],Ps.prototype,"usePlaneData");Qa([f()],Ps.prototype,"useMeshData");Qa([f()],Ps.prototype,"runInVR");var _R=Object.defineProperty,bR=(s,e,t,i)=>{for(var n=void 0,o=s.length-1,r;o>=0;o--)(r=s[o])&&(n=r(e,t,n)||n);return n&&_R(e,t,n),n};const cb=w("debugwebxr");class Yu extends k{priority=0;get isActive(){return this.activeAndEnabled&&this.gameObject.visible}setAsActiveXRRig(){G.active?.setRigActive(this)}setPriority(e){this.priority=e}awake(){if(cb){const e=new c.Object3D;e.position.y+=.5,this.gameObject.add(e);const t=e.addNewComponent(vr);t&&(t.isGizmo=!1);const i=new c.AxesHelper(.5);this.gameObject.add(i)}}isXRRig(){return!0}supportsXR(e){return!0}_startScale;onEnterXR(e){this._startScale=this.gameObject.scale.clone(),e.xr.addRig(this),cb&&console.log("WebXR: add Rig",this.name,this.priority)}onLeaveXR(e){e.xr.removeRig(this),this._startScale&&this.gameObject&&this.gameObject.scale.copy(this._startScale)}}bR([f()],Yu.prototype,"priority");class vR extends k{toggleKey="KeyP";update(){this.context.input.isKeyDown(this.toggleKey)&&this.context.domElement.classList.toggle("presentation-mode")}}P.add("AlignmentConstraint",Oc);P.add("Animation",St);P.add("Animator",rt);P.add("AudioListener",ss);P.add("AudioSource",pi);P.add("Avatar_Brain_LookAt",nc);P.add("Avatar_MouthShapes",Rc);P.add("Avatar_MustacheShake",Qm);P.add("AvatarBlink_Simple",ur);P.add("AvatarEyeLook_Rotation",Km);P.add("AxesHelper",Oa);P.add("BasicIKConstraint",Jm);P.add("BoxHelperComponent",nt);P.add("Camera",qt);P.add("CharacterController",fr);P.add("CharacterControllerInput",fs);P.add("Collider",Kt);P.add("SphereCollider",Ma);P.add("BoxCollider",pu);P.add("MeshCollider",lo);P.add("CapsuleCollider",cs);P.add("ContactShadows",Tc);P.add("LogStats",tg);P.add("DeleteBox",Xs);P.add("Deletable",ng);P.add("DeviceFlag",mu);P.add("DragControls",Io);P.add("DropListener",ps);P.add("Duplicatable",rg);P.add("EventListEvent",cu);P.add("EventTrigger",yu);P.add("GltfExportBox",fg);P.add("GltfExport",mg);P.add("VariantAction",_g);P.add("ChangeTransformOnClick",yr);P.add("ChangeMaterialOnClick",bg);P.add("SetActiveOnClick",vg);P.add("HideOnStart",Ei);P.add("EmphasizeOnClick",Ra);P.add("PlayAudioOnClick",Js);P.add("PlayAnimationOnClick",oc);P.add("PreliminaryAction",Ta);P.add("PreliminaryTrigger",jc);P.add("VisibilityAction",Bc);P.add("TapGestureTrigger",xg);P.add("USDZExporter",Ln);P.add("Fog",Ia);P.add("BoxGizmo",vr);P.add("GridHelper",ja);P.add("GroundProjectedEnv",Bn);P.add("UsageMarker",Ac);P.add("Interactable",ig);P.add("FixedJoint",Vg);P.add("HingeJoint",Vc);P.add("Light",ei);P.add("LODGroup",Wc);P.add("LookAtConstraint",dr);P.add("NeedleMenu",Un);P.add("NestedGltf",Hc);P.add("Networking",Wg);P.add("OffsetConstraint",wr);P.add("CameraTargetReachedEvent",ic);P.add("OrbitControls",de);P.add("ParticleSystemRenderer",Vi);P.add("ParticleSystem",ac);P.add("Attractor",Ua);P.add("PlayerColor",wa);P.add("Antialiasing",Xc);P.add("BloomEffect",Au);P.add("ChromaticAberration",Qc);P.add("ColorAdjustments",go);P.add("DepthOfField",hn);P.add("EffectWrapper",lc);P.add("PixelationEffect",Yc);P.add("ScreenSpaceAmbientOcclusion",vs);P.add("ScreenSpaceAmbientOcclusionN8",dn);P.add("SharpeningEffect",Zc);P.add("TiltShiftEffect",Vn);P.add("ToneMappingEffect",io);P.add("Vignette",Mr);P.add("Volume",Na);P.add("ReflectionProbe",sc);P.add("Renderer",mi);P.add("MeshRenderer",Lc);P.add("SkinnedMeshRenderer",ug);P.add("Rigidbody",Ne);P.add("SceneSwitcher",Be);P.add("ScreenCapture",yo);P.add("ShadowCatcher",eh);P.add("RemoteSkybox",Du);P.add("SmoothFollow",ju);P.add("SpatialTriggerReceiver",Dn);P.add("SpatialTrigger",Bu);P.add("SpectatorCamera",Fu);P.add("SplineContainer",kr);P.add("SplineWalker",un);P.add("SpriteRenderer",Zt);P.add("SyncedCamera",ey);P.add("SyncedRoom",fn);P.add("SyncedTransform",on);P.add("TestRunner",ty);P.add("TestSimulateUserData",iy);P.add("PlayableDirector",or);P.add("SignalReceiver",oh);P.add("AnimationTrackHandler",cc);P.add("AudioTrackHandler",rs);P.add("MarkerTrackHandler",Nu);P.add("SignalTrackHandler",hc);P.add("ControlTrackHandler",Vu);P.add("TransformGizmo",Rr);P.add("BaseUIComponent",Bi);P.add("UIRootComponent",Fc);P.add("Button",ws);P.add("Canvas",va);P.add("CanvasGroup",to);P.add("EventSystem",Bt);P.add("Graphic",zc);P.add("MaskableGraphic",Nc);P.add("Image",Wa);P.add("RawImage",Hu);P.add("InputField",ry);P.add("VerticalLayoutGroup",Ag);P.add("HorizontalLayoutGroup",Lg);P.add("GridLayoutGroup",Dg);P.add("Outline",Da);P.add("ObjectRaycaster",fi);P.add("GraphicRaycaster",hu);P.add("SpatialGrabRaycaster",er);P.add("RectTransform",rn);P.add("SpatialHtml",ah);P.add("Text",Pt);P.add("EnvironmentScene",qu);P.add("LookAt",ay);P.add("OpenURL",Ha);P.add("VideoPlayer",Ze);P.add("Voip",ao);P.add("ClickThrough",Qu);P.add("CursorFollow",ch);P.add("HoverAnimation",exports.HoverAnimation);P.add("ScrollFollow",xs);P.add("ViewBox",exports.ViewBox);P.add("Avatar",eo);P.add("XRControllerFollow",Ss);P.add("XRControllerModel",hs);P.add("XRControllerMovement",gi);P.add("TeleportTarget",Cu);P.add("WebARCameraBackground",hh);P.add("WebARSessionRoot",hi);P.add("WebXR",Pu);P.add("AvatarMarker",xe);P.add("WebXRImageTracking",dh);P.add("WebXRPlaneTracking",Ps);P.add("XRRig",Yu);P.add("XRFlag",Ti);P.add("PlayerSync",Og);P.add("PlayerState",Zi);P.add("PresentationMode",vR);const ql=st,wR=w("debugtypestore");wR&&console.log(P);function xR(s,e){const i=k0(s,e);return i!==void 0?i:null}const SR=new TC,np=Symbol("deserialize-queue");async function CR(s,e,t,i=null,n){if(!t){console.debug("Can not create component instances: gltf is null");return}const o=[];let r=i;typeof r=="number"&&(r=new mt(i));const a=e.indexOf("?");e=a===-1?e:e.substring(0,a);const l=new jm(t.scene);l.gltfId=e,l.context=s,l.gltf=t,l.nodeToObject=n?.nodeToObjectMap,l.implementationInformation=SR;let h=s[np];if(h||(h=s[np]=[]),t.scenes)for(const d of t.scenes)await em(l,d,h,o,0);if(t.children)for(const d of t.children)await em(l,d,h,o,0);s.new_scripts_pre_setup_callbacks.push(()=>{const d=s[np];if(d){for(const u of d)PR(u,l);d.length=0}if(r){const u={},p=[];Jp(t,r,u,p);for(const m of t.scenes)Jp(m,r,u,p);for(const m of p)m.resolveGuids(u)}})}const Zp=Symbol("original-component-name"),zr=new Map;function Jp(s,e,t,i){if(e===null||!s)return;const n=s.guid,o=s.guid;o?.length&&(zr.has(o)||(ql&&console.log('Creating InstanceIdProvider with key "'+o+'" for object '+s.name),zr.set(o,new mt(o))));const r=o&&zr.get(o)||e;if(s.guid=r.generateUUID(),n&&n!=="invalid"&&(t[n]=s.guid),s&&s.userData&&s.userData.components)for(const a of s.userData.components){if(a===null)continue;const l=a.guid;l?zr.has(l)||(ql&&console.log('Creating InstanceIdProvider with key "'+l+'" for component '+a[Zp]),zr.set(l,new mt(l))):ql&&console.warn("Can not create IdProvider: component "+a[Zp]+" has no guid",a.guid);const h=zr.get(l)||e,d=a.guid;a.guid=h.generateUUID(),d&&d!=="invalid"&&(t[d]=a.guid),a.resolveGuids&&i.push(a)}if(s.children)for(const a of s.children)Jp(a,e,t,i)}const hl=[];async function em(s,e,t,i,n){if(!e)return;const o=e.userData;if(o){const r=o.builtin_components;if(r&&r.length>0)for(const a of r)try{if(a===null)continue;const l=P.get(a.name);if(l!=null){const h=new l;h.sourceId=s.gltfId,ya(h,a,s.implementationInformation),h.context=s.context,"guid"in a&&(h[Il]=a.guid),h[Zp]=a.name,No(e,h,!1),t.push({instance:h,compData:a,obj:e}),h.isCamera&&s.context&&s.context.mainCamera===null&&h.tag==="MainCamera"&&s.context.setCurrentCamera(h),s.context?.physics?.engine?.isInitialized===!1&&(h.isCollider||h.isRigidbody)&&s.context?.physics.engine?.initialize()}else ql&&console.debug("unknown component: "+a.name),hl.includes(a.name)||hl.push(a.name)}catch(l){console.error(a.name+" - "+l.message,l)}}if(e.children)for(const r of e.children)await em(s,r,t,i,n+1);if(hl.length>0&&n===0){const r=hl.join(", ");console.warn(`Unknown components in scene: ${r}`),hl.length=0,Ii()&&Se(`<strong>Unknown components in scene</strong>:
|
|
1478
1478
|
|
|
1479
1479
|
${r}
|
|
1480
1480
|
|
|
@@ -1649,4 +1649,4 @@ Error:`,r),null}}updateColliderCollisionGroups(e){const t=e[vt],i=e.membership;l
|
|
|
1649
1649
|
justify-content: center;
|
|
1650
1650
|
gap: .5rem;
|
|
1651
1651
|
}
|
|
1652
|
-
`),this.#n.innerHTML=this.#e.innerHTML,this.#n.style.cssText="display: flex; align-items: center; justify-content: center;",this.#e.innerHTML=this.#n.outerHTML,this.#t.innerHTML=this.#e.outerHTML,this.#t.prepend(this.#s),kd(Rp,{element:this.#t}),this.#o?.disconnect(),this.#o??=new MutationObserver(()=>this.#l()),this.#o.observe(this.#e,{attributes:!0}),rp&&console.log("Needle Button updated")}#l(){this.#e&&(this.#e.style.display==="none"?this.style.display="none":this.style.display==="none"&&(this.style.display=""))}#r=e=>{rp&&console.log("Needle Button clicked"),!e.defaultPrevented&&this.#e&&this.#e.click()}}typeof window<"u"&&!window.customElements.get(mb)&&window.customElements.define(mb,tx);const gl=w("debugavatar");class py{root;head;leftHand;rigthHand;get isValid(){return this.head!==null&&this.head!==void 0}constructor(e,t,i,n){this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,this.root?.traverse(o=>o.layers.set(2))}}class ix{avatarRegistryUrl=null;async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const o=new an;i=S.instantiate(da(t,e.scene),o)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(gl&&console.log("[Custom Avatar] valid config",t,gl?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,gl?n:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(gl&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let o=null;if(n.ok){const a=await n.blob();a&&(o=await a.arrayBuffer())}return o?(await nn().parseSync(e,o,null,0))?.scene??null:null}const i=new q.GLTFLoader;return Vm(i,e),new Promise((n,o)=>{const r=this.avatarRegistryUrl+"/"+t;i.load(r,async a=>{await nn().createBuiltinComponents(e,r,a,null,void 0),n(a.scene)},a=>{gl&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const o=this.findAvatarPart(i,["left","hand"]),r=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new c.Vector3;new c.Box3().setFromObject(n).getSize(l);const h=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+h+" meters! Should be < 0.3m"),h>.3&&n.scale.multiplyScalar(1/h*.3)}return new py(t,n,o,r)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const o of t){if(!n)break;i.indexOf(o)===-1&&(n=!1)}if(n)return e;if(e.children)for(const o of e.children){const r=this.findAvatarPart(o,t);if(r)return r}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}class nx{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}class sx{}const XR=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:le,ActionCollection:aw,ActionModel:Wt,AlignmentConstraint:Oc,Animation:St,AnimationCurve:Gc,AnimationExtension:bu,AnimationTrackHandler:cc,Animator:rt,AnimatorController:Di,Antialiasing:Xc,Attractor:Ua,AudioExtension:gr,AudioListener:ss,AudioSource:pi,AudioTrackHandler:rs,Avatar:eo,AvatarBlink_Simple:ur,AvatarEyeLook_Rotation:Km,AvatarLoader:ix,AvatarMarker:xe,AvatarModel:py,Avatar_Brain_LookAt:nc,Avatar_MouthShapes:Rc,Avatar_MustacheShake:Qm,Avatar_POI:qo,AxesHelper:Oa,BaseUIComponent:Bi,BasicIKConstraint:Jm,BehaviorExtension:kg,BehaviorModel:gt,BloomEffect:Au,BoxCollider:pu,BoxGizmo:vr,BoxHelperComponent:nt,Button:ws,CallInfo:ns,Camera:qt,CameraTargetReachedEvent:ic,Canvas:va,CanvasGroup:to,CapsuleCollider:cs,ChangeMaterialOnClick:bg,ChangeTransformOnClick:yr,CharacterController:fr,CharacterControllerInput:fs,ChromaticAberration:Qc,ClickThrough:Qu,Collider:Kt,ColorAdjustments:go,ColorBySpeedModule:Fa,ColorOverLifetimeModule:Eu,ContactShadows:Tc,ControlTrackHandler:Vu,CursorFollow:ch,CustomBranding:br,Deletable:ng,DeleteBox:Xs,DepthOfField:hn,DeviceFlag:mu,DocumentExtension:nx,DragControls:Io,DropListener:ps,Duplicatable:rg,EffectWrapper:lc,EmissionModule:bs,EmphasizeOnClick:Ra,EnvironmentScene:qu,EventList:oe,EventListEvent:cu,EventSystem:Bt,EventTrigger:yu,FieldWithDefault:Gv,FixedJoint:Vg,Fog:Ia,GltfExport:mg,GltfExportBox:fg,Gradient:xr,Graphic:zc,GraphicRaycaster:hu,GridHelper:ja,GridLayoutGroup:Dg,GroundProjectedEnv:Bn,GroupActionModel:jo,HideOnStart:Ei,HingeJoint:Vc,HorizontalLayoutGroup:Lg,get HoverAnimation(){return exports.HoverAnimation},Image:Wa,InheritVelocityModule:Gg,InputField:ry,InstanceHandle:Xo,InstancingHandler:ir,Interactable:ig,Keyframe:Xt,LODGroup:Wc,LODModel:Ba,Light:ei,LimitVelocityOverLifetimeModule:et,LogStats:tg,LookAt:ay,LookAtConstraint:dr,MainModule:Ot,MarkerTrackHandler:Nu,MaskableGraphic:Nc,MeshCollider:lo,MeshRenderer:Lc,MinMaxCurve:H,MinMaxGradient:Sr,NeedleMenu:Un,NestedGltf:Hc,Networking:Wg,NoiseModule:fe,ObjectRaycaster:fi,OffsetConstraint:wr,OpenURL:Ha,OrbitControls:de,Outline:Da,Padding:_r,ParticleBurst:Nd,ParticleSubEmitter:qg,ParticleSystem:ac,ParticleSystemRenderer:Vi,PhysicsExtension:Eg,PixelationEffect:Yc,PlayAnimationOnClick:oc,PlayAudioOnClick:Js,PlayableDirector:or,PlayerColor:wa,PointerEventData:kc,PostProcessingHandler:Zg,PreliminaryAction:Ta,PreliminaryTrigger:jc,RawImage:Hu,Rect:uw,RectTransform:rn,ReflectionProbe:sc,RegisteredAnimationInfo:Ws,RemoteSkybox:Du,Renderer:mi,RendererLightmap:Fd,get ResponsiveBox(){return exports.ViewBox},Rigidbody:Ne,RotationBySpeedModule:Ni,RotationOverLifetimeModule:cn,SceneSwitcher:Be,ScreenCapture:yo,ScreenSpaceAmbientOcclusion:vs,ScreenSpaceAmbientOcclusionN8:dn,ScrollFollow:xs,SetActiveOnClick:vg,ShadowCatcher:eh,ShapeModule:Hg,SharpeningEffect:Zc,SignalAsset:zu,SignalReceiver:oh,SignalReceiverEvent:sh,SignalTrackHandler:hc,Size:dw,SizeBySpeedModule:ti,SizeOverLifetimeModule:Cr,SkinnedMeshRenderer:ug,SmoothFollow:ju,SpatialGrabRaycaster:er,SpatialHtml:ah,SpatialTrigger:Bu,SpatialTriggerReceiver:Dn,SpectatorCamera:Fu,SphereCollider:Ma,SplineContainer:kr,SplineData:jn,SplineWalker:un,Sprite:gs,SpriteData:ca,SpriteRenderer:Zt,SpriteSheet:ba,SubEmitterSystem:Vd,SyncedCamera:ey,SyncedRoom:fn,SyncedTransform:on,TapGestureTrigger:xg,TeleportTarget:Cu,TestRunner:ty,TestSimulateUserData:iy,Text:Pt,TextBuilder:Tg,TextExtension:Ou,TextureSheetAnimationModule:Mt,TiltShiftEffect:Vn,ToneMappingEffect:io,TrailModule:Re,TransformData:ke,TransformGizmo:Rr,TriggerBuilder:xt,TriggerModel:Qs,UIRaycastUtils:Hm,UIRootComponent:Fc,USDZExporter:Ln,USDZText:ta,USDZUIExtension:jg,UsageMarker:Ac,VariantAction:_g,VelocityOverLifetimeModule:Le,VerticalLayoutGroup:Ag,VideoPlayer:Ze,Vignette:Mr,VisibilityAction:Bc,Voip:ao,Volume:Na,VolumeParameter:j,VolumeProfile:Ru,WebARCameraBackground:hh,WebARSessionRoot:hi,WebXR:Pu,WebXRImageTracking:dh,WebXRImageTrackingModel:Cs,WebXRPlaneTracking:Ps,WebXRTrackedImage:xa,XRControllerFollow:Ss,XRControllerModel:hs,XRControllerMovement:gi,XRFlag:Ti,XRRig:Yu,XRState:jt,__Ignore:sx},Symbol.toStringTag,{value:"Module"})),uc=w("debugmissingcamera");ae.registerCallback(re.MissingCamera,s=>{uc&&console.warn("Creating missing camera");const e=s.context.scene,t=new c.PerspectiveCamera;t.name="Default Fallback Camera",e.add(t);const i=new qt;if(i.sourceId=s.files?.[0]?.src??"unknown",i.fieldOfView=35,s.context.domElement.getAttribute("transparent")!=null)i.clearFlags=Go.Uninitialized;else if(s.context.domElement.getAttribute("background-image")?.length||s.context.lightmaps.tryGetSkybox(i.sourceId))i.clearFlags=Go.Skybox;else{if(i.clearFlags=Go.SolidColor,!s.context.domElement.getAttribute("background-color")){let a="#efefef";typeof window!==void 0&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(a="#1f1f1f"),e.background=new c.Color(a)}if(!e.environment){const a=new c.PMREMGenerator$1(s.context.renderer),l=new qu("neutral");e.environment=a.fromScene(l,.025).texture}}const o=No(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,s.context.domElement?.cameraControls!=!1&&ox(s.context,o),o});ae.registerCallback(re.ContextCreated,s=>{if(!s.context.mainCamera){uc&&console.log("Will not auto-fit because a default camera exists");return}if(s.context.domElement?.cameraControls==!0){if(Eb(s.context.mainCamera)?.isCameraController==!0){uc&&console.log("Will not auto-fit because a camera controller exists");return}ox(s.context)}});function ox(s,e){e=e??s.mainCameraComponent;const t=e?.gameObject;if(uc&&console.log("Creating default camera controls",e?.name),t){const i=wc(t,de);i.sourceId=e?.sourceId??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!="0"&&n?.toLowerCase()!="false";const o=Number.parseFloat(n||".5");i.autoRotateSpeed=isNaN(o)?.5:o,uc&&console.log("Auto-rotate",i.autoRotate,"speed:",i.autoRotateSpeed);const r=s.domElement.getAttribute("auto-fit");i.autoFit=r!=="0"&&r?.toLowerCase()!="false",i.autoTarget=!0}else console.warn("Missing camera object, can not add orbit controls")}ae.registerCallback(re.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&s.files)for(const t of s.files)S.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof St&&n.playAutomatically||n instanceof rt||n instanceof or&&n.playOnAwake===!0)return!0;if(n instanceof St)return n.playAutomatically=!0,!0;if(n instanceof or)return n.playOnAwake=!0,!0}},!0)!==!0&&Zs.autoplayAnimations(t.file)});exports.SplineUtils=void 0;(s=>{function e(t,i=!1,n=.75){const o=new kr,r=1-D.clamp(n,0,1);return t.forEach((a,l)=>{const h=new c.Vector3;l<t.length-1?h.subVectors(t[l+1],a).normalize().multiplyScalar(r):i&&t.length>1&&h.subVectors(t[0],a).normalize().multiplyScalar(r);const d=new jn;d.position.copy(a),d.tangentIn.copy(h),d.tangentOut.copy(h),o.addKnot(d)}),o.closed=i,o}s.createFromPoints=e})(exports.SplineUtils||(exports.SplineUtils={}));class QR extends se.WorkerBase{constructor(){super(new Worker(new URL("/generateMeshBVH.worker-2qGLkQjg.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:Zu&&Zu.tagName.toUpperCase()==="SCRIPT"&&Zu.src||new URL("needle-engine.bundle-DzVytSSo.umd.cjs",document.baseURI).href),{type:"module"})),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((n,o)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`[GenerateMeshBVHWorker] ${h.message||"Unknown error. Please check the server console. If you're using vite try adding 'three-mesh-bvh' to 'optimizeDeps.exclude' in your vite.config.js"}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:p}=d,m=se.MeshBVH.deserialize(u,t,{setIndex:!1}),y=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=p,u.index)if(t.index)t.index.array=u.index;else{const _=new c.BufferAttribute(u.index,1,!1);t.setIndex(_)}y.setBoundingBox&&(t.boundingBox=m.getBoundingBox(new c.Box3)),i.onProgress&&i.onProgress(d.progress),n(m),e.onmessage=null}else i.onProgress&&i.onProgress(d.progress)};const r=t.index?t.index.array:null,a=t.attributes.position.array,l=[a];r&&l.push(r),e.postMessage({index:r,position:a,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},l.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const YR=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:QR},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=OP;exports.ActionBuilder=le;exports.ActionCollection=aw;exports.ActionModel=Wt;exports.Addressables=W0;exports.AlignmentConstraint=Oc;exports.AmbientMode=aa;exports.Animation=St;exports.AnimationCurve=Gc;exports.AnimationExtension=bu;exports.AnimationTrackHandler=cc;exports.AnimationUtils=Zs;exports.Animator=rt;exports.AnimatorConditionMode=Us;exports.AnimatorController=Di;exports.AnimatorControllerParameterType=$m;exports.AnimatorStateInfo=wl;exports.Antialiasing=Xc;exports.Application=sn;exports.AssetDatabase=a0;exports.AssetReference=Y;exports.Attractor=Ua;exports.AudioExtension=gr;exports.AudioListener=ss;exports.AudioSource=pi;exports.AudioTrackHandler=rs;exports.Avatar=eo;exports.AvatarBlink_Simple=ur;exports.AvatarEyeLook_Rotation=Km;exports.AvatarLoader=ix;exports.AvatarMarker=xe;exports.AvatarModel=py;exports.Avatar_Brain_LookAt=nc;exports.Avatar_MouthShapes=Rc;exports.Avatar_MustacheShake=Qm;exports.Avatar_POI=qo;exports.Axes=Jr;exports.AxesHelper=Oa;exports.BUILD_TIME=ym;exports.BaseUIComponent=Bi;exports.BasicIKConstraint=Jm;exports.BehaviorExtension=kg;exports.BehaviorModel=gt;exports.BloomEffect=Au;exports.BoxCollider=pu;exports.BoxGizmo=vr;exports.BoxHelperComponent=nt;exports.Button=ws;exports.ButtonsFactory=Ki;exports.CallDirection=Ov;exports.CallInfo=ns;exports.Camera=qt;exports.CameraTargetReachedEvent=ic;exports.Canvas=va;exports.CanvasGroup=to;exports.CapsuleCollider=cs;exports.ChangeMaterialOnClick=bg;exports.ChangeTransformOnClick=yr;exports.CharacterController=fr;exports.CharacterControllerInput=fs;exports.ChromaticAberration=Qc;exports.CircularBuffer=di;exports.ClearFlags=Go;exports.ClickThrough=Qu;exports.ClipExtrapolation=bn;exports.Collider=Kt;exports.Collision=Sv;exports.CollisionDetectionMode=lu;exports.ColorAdjustments=go;exports.ColorBySpeedModule=Fa;exports.ColorOverLifetimeModule=Eu;exports.Component=D1;exports.Component$1=k;exports.ComponentLifecycleEvents=Jd;exports.Components=XR;exports.ConnectionEvents=t0;exports.ContactPoint=xv;exports.ContactShadows=Tc;exports.Context=z;exports.ContextArgs=b1;exports.ContextEvent=re;exports.ContextRegistry=ae;exports.ControlTrackHandler=Vu;exports.CursorFollow=ch;exports.CustomBranding=br;exports.CustomShader=ye;exports.DefaultReflectionMode=Md;exports.Deletable=ng;exports.DeleteBox=Xs;exports.DepthOfField=hn;exports.DeviceFlag=mu;exports.DocumentExtension=nx;exports.DragControls=Io;exports.DragMode=sg;exports.DropListener=ps;exports.Duplicatable=rg;exports.EffectWrapper=lc;exports.EmissionModule=bs;exports.EmphasizeOnClick=Ra;exports.EngineLoadingView=dc;exports.EnvironmentScene=qu;exports.EventList=oe;exports.EventListEvent=cu;exports.EventSystem=Bt;exports.EventTrigger=yu;exports.FieldWithDefault=Gv;exports.FileReference=Wo;exports.FileReferenceSerializer=G0;exports.FileSpawnModel=QP;exports.File_Event=Lv;exports.FixedJoint=Vg;exports.Fog=Ia;exports.FrameEvent=pe;exports.GENERATOR=Xd;exports.GameObject=S;exports.Gizmos=I;exports.GltfExport=mg;exports.GltfExportBox=fg;exports.Gradient=xr;exports.Graphic=zc;exports.GraphicRaycaster=hu;exports.Graphics=Ks;exports.GridHelper=ja;exports.GridLayoutGroup=Dg;exports.GroundProjectedEnv=Bn;exports.GroupActionModel=jo;exports.HideFlags=du;exports.HideOnStart=Ei;exports.HingeJoint=Vc;exports.HorizontalLayoutGroup=Lg;exports.HostData=vC;exports.Image=Wa;exports.ImageReference=$o;exports.ImageReferenceSerializer=H0;exports.InheritVelocityModule=Gg;exports.Input=Qb;exports.InputEventQueue=Gt;exports.InputEvents=we;exports.InputField=ry;exports.InstanceHandle=Xo;exports.InstancingHandler=ir;exports.InstancingUtil=Li;exports.InstantiateEvent=_0;exports.InstantiateIdProvider=mt;exports.InstantiateOptions=an;exports.Interactable=ig;exports.JoinedRoomResponse=WS;exports.KeyEventArgs=LS;exports.Keyframe=Xt;exports.LODGroup=Wc;exports.LODModel=Ba;exports.LeftRoomResponse=HS;exports.Light=ei;exports.LightData=K0;exports.LimitVelocityOverLifetimeModule=et;exports.LoadingElementOptions=LR;exports.LogStats=tg;exports.LogType=ci;exports.LookAt=ay;exports.LookAtConstraint=dr;exports.MainModule=Ot;exports.MarkerTrackHandler=Nu;exports.MarkerType=ny;exports.MaskableGraphic=Nc;exports.Mathf=D;exports.MeshCollider=lo;exports.MeshRenderer=Lc;exports.MinMaxCurve=H;exports.MinMaxGradient=Sr;exports.NEKeyboardEvent=yl;exports.NEPointerEvent=Zn;exports.NeedleButtonElement=tx;exports.NeedleEngineWebComponent=fy;exports.NeedleMenu=Un;exports.NeedlePatchesKey=Yh;exports.NeedleXRController=wm;exports.NeedleXRSession=G;exports.NeedleXRSync=s0;exports.NeedleXRUtils=r0;exports.NestedGltf=Hc;exports.NetworkConnection=n0;exports.NetworkedStreamEvents=Mn;exports.NetworkedStreams=Ec;exports.Networking=Wg;exports.NewInstanceModel=v0;exports.NoiseModule=fe;exports.ObjectRaycaster=fi;exports.ObjectUtils=ar;exports.OffsetConstraint=wr;exports.OneEuroFilter=Xh;exports.OneEuroFilterXYZ=cm;exports.OpenURL=Ha;exports.OrbitControls=de;exports.Outline=Da;exports.OwnershipEvent=i0;exports.OwnershipModel=Pm;exports.PUBLIC_KEY=Yr;exports.Padding=_r;exports.ParticleBurst=Nd;exports.ParticleSubEmitter=qg;exports.ParticleSystem=ac;exports.ParticleSystemBaseBehaviour=mo;exports.ParticleSystemRenderer=Vi;exports.ParticleSystemShapeType=zd;exports.PeerHandle=os;exports.PeerNetworking=e0;exports.Physics=ga;exports.PhysicsExtension=Eg;exports.PhysicsMaterialCombine=it;exports.PixelationEffect=Yc;exports.PlayAnimationOnClick=oc;exports.PlayAudioOnClick=Js;exports.PlayableDirector=or;exports.PlayerColor=wa;exports.PlayerState=Zi;exports.PlayerStateEvent=hw;exports.PlayerSync=Og;exports.PlayerView=X0;exports.PlayerViewManager=Q0;exports.PointerEventData=kc;exports.PointerType=Kd;exports.PostProcessingEffect=Ve;exports.PostProcessingEffectOrder=Ke;exports.PostProcessingHandler=Zg;exports.PreliminaryAction=Ta;exports.PreliminaryTrigger=jc;exports.PrimitiveType=Yo;exports.Progress=ie;exports.PromiseAllWithErrors=am;exports.PromiseErrorResult=cp;exports.RGBAColor=Z;exports.RapierPhysics=ha;exports.RawImage=Hu;exports.RaycastOptions=ro;exports.Rect=uw;exports.RectTransform=rn;exports.ReflectionProbe=sc;exports.RegisteredAnimationInfo=Ws;exports.RemoteSkybox=Du;exports.RenderTexture=On;exports.RenderTextureSerializer=_v;exports.Renderer=mi;exports.RendererData=Y0;exports.RendererLightmap=Fd;exports.Rigidbody=Ne;exports.RigidbodyConstraints=Ie;exports.RoomEvents=Q;exports.RotationBySpeedModule=Ni;exports.RotationOverLifetimeModule=cn;exports.SceneLightSettings=Id;exports.SceneSwitcher=Be;exports.ScreenCapture=yo;exports.ScreenSpaceAmbientOcclusion=vs;exports.ScreenSpaceAmbientOcclusionN8=dn;exports.ScrollFollow=xs;exports.SendQueue=Yi;exports.SerializationContext=jm;exports.SetActiveOnClick=vg;exports.ShadowCatcher=eh;exports.ShapeModule=Hg;exports.ShapeOverlapResult=Cv;exports.SharpeningEffect=Zc;exports.SignalAsset=zu;exports.SignalReceiver=oh;exports.SignalReceiverEvent=sh;exports.SignalTrackHandler=hc;exports.Size=dw;exports.SizeBySpeedModule=ti;exports.SizeOverLifetimeModule=Cr;exports.SkinnedMeshRenderer=ug;exports.SmoothFollow=ju;exports.SpatialGrabRaycaster=er;exports.SpatialHtml=ah;exports.SpatialTrigger=Bu;exports.SpatialTriggerReceiver=Dn;exports.SpectatorCamera=Fu;exports.SphereCollider=Ma;exports.SphereIntersection=km;exports.SplineContainer=kr;exports.SplineData=jn;exports.SplineWalker=un;exports.Sprite=gs;exports.SpriteData=ca;exports.SpriteRenderer=Zt;exports.SpriteSheet=ba;exports.StateMachineBehaviour=z1;exports.StreamEndedEvent=qm;exports.StreamReceivedEvent=Pv;exports.SubEmitterSystem=Vd;exports.SyncedCamera=ey;exports.SyncedRoom=fn;exports.SyncedTransform=on;exports.TapGestureTrigger=xg;exports.TeleportTarget=Cu;exports.TestRunner=ty;exports.TestSceneUtils=VR;exports.TestSimulateUserData=iy;exports.Text=Pt;exports.TextBuilder=Tg;exports.TextExtension=Ou;exports.TextureSheetAnimationModule=Mt;exports.TiltShiftEffect=Vn;exports.Time=Z0;exports.ToneMappingEffect=io;exports.TrackHandler=$a;exports.TrackType=si;exports.TrailModule=Re;exports.TransformData=ke;exports.TransformGizmo=Rr;exports.TriggerBuilder=xt;exports.TriggerModel=Qs;exports.TypeStore=P;exports.UIRaycastUtils=Hm;exports.UIRootComponent=Fc;exports.USDDocument=gg;exports.USDObject=ze;exports.USDWriter=Zv;exports.USDZExporter=Ln;exports.USDZExporter$1=Jv;exports.USDZText=ta;exports.USDZUIExtension=jg;exports.UriSerializer=bv;exports.UsageMarker=Ac;exports.UserJoinedOrLeftRoomModel=GS;exports.VERSION=Ji;exports.VariantAction=_g;exports.VelocityOverLifetimeModule=Le;exports.VerticalLayoutGroup=Ag;exports.VideoPlayer=Ze;exports.ViewDevice=Hs;exports.Vignette=Mr;exports.VisibilityAction=Bc;exports.Voip=ao;exports.Volume=Na;exports.VolumeParameter=j;exports.VolumeProfile=Ru;exports.WaitForFrames=ZC;exports.WaitForPromise=q0;exports.WaitForSeconds=Um;exports.Watch=as;exports.WebARCameraBackground=hh;exports.WebARSessionRoot=hi;exports.WebXR=Pu;exports.WebXRButtonFactory=Ys;exports.WebXRImageTracking=dh;exports.WebXRImageTrackingModel=Cs;exports.WebXRPlaneTracking=Ps;exports.WebXRTrackedImage=xa;exports.XRControllerFollow=Ss;exports.XRControllerModel=hs;exports.XRControllerMovement=gi;exports.XRFlag=Ti;exports.XRRig=Yu;exports.XRState=jt;exports.XRStateFlag=Cn;exports.__Ignore=sx;exports.__internalNotifyObjectDestroyed=cC;exports.activeInHierarchyFieldName=ls;exports.addAttributeChangeCallback=om;exports.addComponent=en;exports.addCustomExtensionPlugin=yO;exports.addNewComponent=No;exports.addPatch=Qd;exports.apply=tu;exports.applyHMRChanges=L1;exports.applyPrototypeExtensions=A0;exports.beginListenDestroy=b0;exports.beginListenInstantiate=x0;exports.binaryIdentifierCasts=xm;exports.build_scene_functions=_1;exports.builtinComponentKeyName=Ro;exports.calculateProgress01=uy;exports.clearMessages=Vx;exports.colorSerializer=nP;exports.compareAssociation=O0;exports.componentSerializer=od;exports.copyTexture=jb;exports.createMotion=fv;exports.debugNet=zt;exports.debugOwner=_l;exports.decompressGpuTexture=nw;exports.deepClone=pc;exports.delay=In;exports.delayForFrames=mc;exports.deserializeObject=Pd;exports.destroy=ui;exports.destroyComponentInstance=I0;exports.determineMimeTypeFromExtension=Dv;exports.disposeObjectResources=_e;exports.disposeStream=kn;exports.editorGuidKeyName=Il;exports.enableSpatialConsole=Fo;exports.euler=oP;exports.eventListSerializer=cP;exports.exportAsGLTF=HR;exports.findByGuid=Fm;exports.findObjectOfType=Ca;exports.findObjectsOfType=B0;exports.findResourceUsers=Em;exports.fitCamera=pv;exports.fitObjectIntoVolume=Fb;exports.foreachComponent=Zo;exports.foreachComponentEnumerator=nu;exports.forward=rS;exports.generateQRCode=Sb;exports.generateSeed=w0;exports.getBoundingBox=Ft;exports.getCameraController=Eb;exports.getComponent=cr;exports.getComponentInChildren=Sc;exports.getComponentInParent=Jl;exports.getComponents=xc;exports.getComponentsInChildren=Sa;exports.getComponentsInParent=eu;exports.getFormattedDate=Xv;exports.getIconElement=pt;exports.getIconTexture=Ep;exports.getLoader=nn;exports.getOrAddComponent=wc;exports.getParam=w;exports.getParentHierarchyPath=cS;exports.getPath=bx;exports.getPeerOptions=zS;exports.getPeerjsInstance=Jb;exports.getResourceUserCount=dC;exports.getTempColor=Ab;exports.getTempQuaternion=Ht;exports.getTempVector=F;exports.getUrlParams=fc;exports.getVisibleInCustomShadowRendering=Bb;exports.getWorldDirection=Lb;exports.getWorldEuler=um;exports.getWorldPosition=X;exports.getWorldQuaternion=ue;exports.getWorldRotation=qd;exports.getWorldScale=je;exports.hasCommercialLicense=Gs;exports.hasIndieLicense=Pc;exports.hasPointerEventComponent=Td;exports.hasProLicense=An;exports.hideDebugConsole=Vb;exports.imageToCanvas=sw;exports.instantiate=Jo;exports.invokeLoadedImportPluginHooks=$v;exports.invokeXRSessionEnd=Xb;exports.invokeXRSessionStart=qb;exports.isActiveInHierarchy=F0;exports.isActiveSelf=Pa;exports.isAndroidDevice=Px;exports.isAnimationAction=Ib;exports.isComponent=wv;exports.isDebugMode=mx;exports.isDesktop=wx;exports.isDestroyed=Ko;exports.isDevEnvironment=A;exports.isDisposed=lC;exports.isExporting=$R;exports.isGLTFModel=vv;exports.isHostedOnGlitch=gb;exports.isHotReloadEnabled=Dp;exports.isHotReloading=T1;exports.isIPad=Sx;exports.isIconElement=tv;exports.isLocalNetwork=Ii;exports.isMacOS=Mx;exports.isMobileDevice=xx;exports.isMozillaXR=Ox;exports.isQuest=Rx;exports.isResourceTrackingEnabled=c0;exports.isSafari=Ex;exports.isUsingInstancing=iu;exports.isiOS=kx;exports.isiPad=Cx;exports.loadAsset=MR;exports.loadPMREM=Dw;exports.loadSync=dy;exports.logHierarchy=yd;exports.lookAtInverse=Zx;exports.lookAtObject=gc;exports.lookAtScreenPoint=Jx;exports.makeId=yx;exports.makeIdFromRandomWords=bb;exports.makeNameSafe=ji;exports.markAsInstancedRendered=U0;exports.microphonePermissionsGranted=Tx;exports.nameof=px;exports.nameofFactory=yb;exports.objectSerializer=yv;exports.offXRSessionEnd=AS;exports.offXRSessionStart=TS;exports.onAfterRender=E1;exports.onBeforeRender=k1;exports.onClear=O1;exports.onDestroy=M1;exports.onInitialized=rv;exports.onStart=ru;exports.onUpdate=av;exports.onXRSessionEnd=vm;exports.onXRSessionStart=Yd;exports.parseSync=Yw;exports.placeOnSurface=Ub;exports.postprocessFBXMaterials=mm;exports.prefix=K1;exports.pushState=_b;exports.randomNumber=_x;exports.registerBinaryType=Sm;exports.registerComponent=ou;exports.registerComponentExtension=cg;exports.registerCustomEffectType=$i;exports.registerExportExtensions=hg;exports.registerExtensions=Bd;exports.registerHotReloadType=cv;exports.registerLoader=_m;exports.registerPrefabProvider=C0;exports.registerPrototypeExtensions=L0;exports.registerType=Lm;exports.relativePathPrefix=wb;exports.removeAttributeChangeCallback=rm;exports.removeComponent=Bm;exports.removeCustomImportExtensionType=_O;exports.removePatch=ES;exports.resolveUrl=no;exports.sanitizeString=vb;exports.saveImage=Gw;exports.screenshot=hR;exports.screenshot2=hy;exports.sendDestroyed=Tm;exports.serializable=f;exports.serializeObject=k0;exports.serializeable=$e;exports.setActive=Fl;exports.setAllowBalloonMessages=Ob;exports.setAllowOverlayMessages=Fx;exports.setAutoFitEnabled=md;exports.setCameraController=dp;exports.setDestroyed=N0;exports.setDevEnvironment=yS;exports.setDisposable=d0;exports.setDontDestroy=$r;exports.setOrAddParamsToUrl=lp;exports.setParam=gx;exports.setParamWithoutReload=Ql;exports.setPeerOptions=NS;exports.setResourceTrackingEnabled=aC;exports.setState=nm;exports.setVisibleInCustomShadowRendering=pm;exports.setWorldEuler=fm;exports.setWorldPosition=ot;exports.setWorldPositionXYZ=Qo;exports.setWorldQuaternion=tn;exports.setWorldQuaternionXYZW=dm;exports.setWorldRotation=Db;exports.setWorldRotationXYZ=yc;exports.setWorldScale=ua;exports.showBalloonError=_c;exports.showBalloonMessage=Se;exports.showBalloonWarning=he;exports.showDebugConsole=gm;exports.slerp=Kx;exports.syncDestroy=bc;exports.syncField=Pg;exports.syncInstantiate=Am;exports.textureToCanvas=hS;exports.toSourceId=xb;exports.tryCastBinary=Kb;exports.tryDetermineMimetypeFromBinary=jv;exports.tryDetermineMimetypeFromURL=Iv;exports.tryFindObject=da;exports.tryGetGuid=Zb;exports.unregisterHotReloadType=hv;exports.unwatchWrite=sm;exports.useForAutoFit=Rb;exports.validate=yt;exports.watchWrite=Gd;
|
|
1652
|
+
`),this.#n.innerHTML=this.#e.innerHTML,this.#n.style.cssText="display: flex; align-items: center; justify-content: center;",this.#e.innerHTML=this.#n.outerHTML,this.#t.innerHTML=this.#e.outerHTML,this.#t.prepend(this.#s),kd(Rp,{element:this.#t}),this.#o?.disconnect(),this.#o??=new MutationObserver(()=>this.#l()),this.#o.observe(this.#e,{attributes:!0}),rp&&console.log("Needle Button updated")}#l(){this.#e&&(this.#e.style.display==="none"?this.style.display="none":this.style.display==="none"&&(this.style.display=""))}#r=e=>{rp&&console.log("Needle Button clicked"),!e.defaultPrevented&&this.#e&&this.#e.click()}}typeof window<"u"&&!window.customElements.get(mb)&&window.customElements.define(mb,tx);const gl=w("debugavatar");class py{root;head;leftHand;rigthHand;get isValid(){return this.head!==null&&this.head!==void 0}constructor(e,t,i,n){this.root=e,this.head=t,this.leftHand=i,this.rigthHand=n,this.root?.traverse(o=>o.layers.set(2))}}class ix{avatarRegistryUrl=null;async getOrCreateNewAvatarInstance(e,t){if(!t)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof t=="string"){if(i=await this.loadAvatar(e,t),!i){const o=new an;i=S.instantiate(da(t,e.scene),o)}}else i=t;if(!i)return null;const n=this.findAvatar(i);return n.isValid?(gl&&console.log("[Custom Avatar] valid config",t,gl?n:""),n):(console.warn("[Custom Avatar] config isn't valid",t,gl?n:""),null)}async loadAvatar(e,t){if(console.assert(t!=null&&typeof t=="string","Avatar id must not be null"),t.length<=0||!t)return null;if(gl&&console.log("[Custom Avatar] "+t+", loading..."),t.endsWith(".glb")||(t+=".glb"),this.avatarRegistryUrl===null){const n=await fetch("./"+t);let o=null;if(n.ok){const a=await n.blob();a&&(o=await a.arrayBuffer())}return o?(await nn().parseSync(e,o,null,0))?.scene??null:null}const i=new q.GLTFLoader;return Vm(i,e),new Promise((n,o)=>{const r=this.avatarRegistryUrl+"/"+t;i.load(r,async a=>{await nn().createBuiltinComponents(e,r,a,null,void 0),n(a.scene)},a=>{gl&&console.log("[Custom Avatar] "+a.loaded/a.total*100+"% loaded of "+a.total/1024+"kB")},a=>{console.error("[Custom Avatar] Error when loading: "+a),n(null)})})}cacheModel(e,t){}findAvatar(e){const t=e;let i=t;i.children.length==1&&(i=e.children[0]);let n=this.findAvatarPart(i,["head"]);const o=this.findAvatarPart(i,["left","hand"]),r=this.findAvatarPart(i,["right","hand"]);if(!n){n=t;const l=new c.Vector3;new c.Box3().setFromObject(n).getSize(l);const h=Math.max(l.x,l.y,l.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+h+" meters! Should be < 0.3m"),h>.3&&n.scale.multiplyScalar(1/h*.3)}return new py(t,n,o,r)}findAvatarPart(e,t){const i=e.name.toLowerCase();let n=!0;for(const o of t){if(!n)break;i.indexOf(o)===-1&&(n=!1)}if(n)return e;if(e.children)for(const o of e.children){const r=this.findAvatarPart(o,t);if(r)return r}return null}handleCustomAvatarErrors(e){if(!e.ok)throw Error(e.statusText);return e}}class nx{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}class sx{}const XR=Object.freeze(Object.defineProperty({__proto__:null,ActionBuilder:le,ActionCollection:aw,ActionModel:Wt,AlignmentConstraint:Oc,Animation:St,AnimationCurve:Gc,AnimationExtension:bu,AnimationTrackHandler:cc,Animator:rt,AnimatorController:Di,Antialiasing:Xc,Attractor:Ua,AudioExtension:gr,AudioListener:ss,AudioSource:pi,AudioTrackHandler:rs,Avatar:eo,AvatarBlink_Simple:ur,AvatarEyeLook_Rotation:Km,AvatarLoader:ix,AvatarMarker:xe,AvatarModel:py,Avatar_Brain_LookAt:nc,Avatar_MouthShapes:Rc,Avatar_MustacheShake:Qm,Avatar_POI:qo,AxesHelper:Oa,BaseUIComponent:Bi,BasicIKConstraint:Jm,BehaviorExtension:kg,BehaviorModel:gt,BloomEffect:Au,BoxCollider:pu,BoxGizmo:vr,BoxHelperComponent:nt,Button:ws,CallInfo:ns,Camera:qt,CameraTargetReachedEvent:ic,Canvas:va,CanvasGroup:to,CapsuleCollider:cs,ChangeMaterialOnClick:bg,ChangeTransformOnClick:yr,CharacterController:fr,CharacterControllerInput:fs,ChromaticAberration:Qc,ClickThrough:Qu,Collider:Kt,ColorAdjustments:go,ColorBySpeedModule:Fa,ColorOverLifetimeModule:Eu,ContactShadows:Tc,ControlTrackHandler:Vu,CursorFollow:ch,CustomBranding:br,Deletable:ng,DeleteBox:Xs,DepthOfField:hn,DeviceFlag:mu,DocumentExtension:nx,DragControls:Io,DropListener:ps,Duplicatable:rg,EffectWrapper:lc,EmissionModule:bs,EmphasizeOnClick:Ra,EnvironmentScene:qu,EventList:oe,EventListEvent:cu,EventSystem:Bt,EventTrigger:yu,FieldWithDefault:Gv,FixedJoint:Vg,Fog:Ia,GltfExport:mg,GltfExportBox:fg,Gradient:xr,Graphic:zc,GraphicRaycaster:hu,GridHelper:ja,GridLayoutGroup:Dg,GroundProjectedEnv:Bn,GroupActionModel:jo,HideOnStart:Ei,HingeJoint:Vc,HorizontalLayoutGroup:Lg,get HoverAnimation(){return exports.HoverAnimation},Image:Wa,InheritVelocityModule:Gg,InputField:ry,InstanceHandle:Xo,InstancingHandler:ir,Interactable:ig,Keyframe:Xt,LODGroup:Wc,LODModel:Ba,Light:ei,LimitVelocityOverLifetimeModule:et,LogStats:tg,LookAt:ay,LookAtConstraint:dr,MainModule:Ot,MarkerTrackHandler:Nu,MaskableGraphic:Nc,MeshCollider:lo,MeshRenderer:Lc,MinMaxCurve:H,MinMaxGradient:Sr,NeedleMenu:Un,NestedGltf:Hc,Networking:Wg,NoiseModule:fe,ObjectRaycaster:fi,OffsetConstraint:wr,OpenURL:Ha,OrbitControls:de,Outline:Da,Padding:_r,ParticleBurst:Nd,ParticleSubEmitter:qg,ParticleSystem:ac,ParticleSystemRenderer:Vi,PhysicsExtension:Eg,PixelationEffect:Yc,PlayAnimationOnClick:oc,PlayAudioOnClick:Js,PlayableDirector:or,PlayerColor:wa,PointerEventData:kc,PostProcessingHandler:Zg,PreliminaryAction:Ta,PreliminaryTrigger:jc,RawImage:Hu,Rect:uw,RectTransform:rn,ReflectionProbe:sc,RegisteredAnimationInfo:Ws,RemoteSkybox:Du,Renderer:mi,RendererLightmap:Fd,Rigidbody:Ne,RotationBySpeedModule:Ni,RotationOverLifetimeModule:cn,SceneSwitcher:Be,ScreenCapture:yo,ScreenSpaceAmbientOcclusion:vs,ScreenSpaceAmbientOcclusionN8:dn,ScrollFollow:xs,SetActiveOnClick:vg,ShadowCatcher:eh,ShapeModule:Hg,SharpeningEffect:Zc,SignalAsset:zu,SignalReceiver:oh,SignalReceiverEvent:sh,SignalTrackHandler:hc,Size:dw,SizeBySpeedModule:ti,SizeOverLifetimeModule:Cr,SkinnedMeshRenderer:ug,SmoothFollow:ju,SpatialGrabRaycaster:er,SpatialHtml:ah,SpatialTrigger:Bu,SpatialTriggerReceiver:Dn,SpectatorCamera:Fu,SphereCollider:Ma,SplineContainer:kr,SplineData:jn,SplineWalker:un,Sprite:gs,SpriteData:ca,SpriteRenderer:Zt,SpriteSheet:ba,SubEmitterSystem:Vd,SyncedCamera:ey,SyncedRoom:fn,SyncedTransform:on,TapGestureTrigger:xg,TeleportTarget:Cu,TestRunner:ty,TestSimulateUserData:iy,Text:Pt,TextBuilder:Tg,TextExtension:Ou,TextureSheetAnimationModule:Mt,TiltShiftEffect:Vn,ToneMappingEffect:io,TrailModule:Re,TransformData:ke,TransformGizmo:Rr,TriggerBuilder:xt,TriggerModel:Qs,UIRaycastUtils:Hm,UIRootComponent:Fc,USDZExporter:Ln,USDZText:ta,USDZUIExtension:jg,UsageMarker:Ac,VariantAction:_g,VelocityOverLifetimeModule:Le,VerticalLayoutGroup:Ag,VideoPlayer:Ze,get ViewBox(){return exports.ViewBox},Vignette:Mr,VisibilityAction:Bc,Voip:ao,Volume:Na,VolumeParameter:j,VolumeProfile:Ru,WebARCameraBackground:hh,WebARSessionRoot:hi,WebXR:Pu,WebXRImageTracking:dh,WebXRImageTrackingModel:Cs,WebXRPlaneTracking:Ps,WebXRTrackedImage:xa,XRControllerFollow:Ss,XRControllerModel:hs,XRControllerMovement:gi,XRFlag:Ti,XRRig:Yu,XRState:jt,__Ignore:sx},Symbol.toStringTag,{value:"Module"})),uc=w("debugmissingcamera");ae.registerCallback(re.MissingCamera,s=>{uc&&console.warn("Creating missing camera");const e=s.context.scene,t=new c.PerspectiveCamera;t.name="Default Fallback Camera",e.add(t);const i=new qt;if(i.sourceId=s.files?.[0]?.src??"unknown",i.fieldOfView=35,s.context.domElement.getAttribute("transparent")!=null)i.clearFlags=Go.Uninitialized;else if(s.context.domElement.getAttribute("background-image")?.length||s.context.lightmaps.tryGetSkybox(i.sourceId))i.clearFlags=Go.Skybox;else{if(i.clearFlags=Go.SolidColor,!s.context.domElement.getAttribute("background-color")){let a="#efefef";typeof window!==void 0&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(a="#1f1f1f"),e.background=new c.Color(a)}if(!e.environment){const a=new c.PMREMGenerator$1(s.context.renderer),l=new qu("neutral");e.environment=a.fromScene(l,.025).texture}}const o=No(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,s.context.domElement?.cameraControls!=!1&&ox(s.context,o),o});ae.registerCallback(re.ContextCreated,s=>{if(!s.context.mainCamera){uc&&console.log("Will not auto-fit because a default camera exists");return}if(s.context.domElement?.cameraControls==!0){if(Eb(s.context.mainCamera)?.isCameraController==!0){uc&&console.log("Will not auto-fit because a camera controller exists");return}ox(s.context)}});function ox(s,e){e=e??s.mainCameraComponent;const t=e?.gameObject;if(uc&&console.log("Creating default camera controls",e?.name),t){const i=wc(t,de);i.sourceId=e?.sourceId??"unknown";const n=s.domElement.getAttribute("auto-rotate");i.autoRotate=n!="0"&&n?.toLowerCase()!="false";const o=Number.parseFloat(n||".5");i.autoRotateSpeed=isNaN(o)?.5:o,uc&&console.log("Auto-rotate",i.autoRotate,"speed:",i.autoRotateSpeed);const r=s.domElement.getAttribute("auto-fit");i.autoFit=r!=="0"&&r?.toLowerCase()!="false",i.autoTarget=!0}else console.warn("Missing camera object, can not add orbit controls")}ae.registerCallback(re.ContextCreated,s=>{const e=s.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true"||e==="1")&&s.files)for(const t of s.files)S.foreachComponent(t.file.scene,n=>{if(n.enabled!==!1){if(n instanceof St&&n.playAutomatically||n instanceof rt||n instanceof or&&n.playOnAwake===!0)return!0;if(n instanceof St)return n.playAutomatically=!0,!0;if(n instanceof or)return n.playOnAwake=!0,!0}},!0)!==!0&&Zs.autoplayAnimations(t.file)});exports.SplineUtils=void 0;(s=>{function e(t,i=!1,n=.75){const o=new kr,r=1-D.clamp(n,0,1);return t.forEach((a,l)=>{const h=new c.Vector3;l<t.length-1?h.subVectors(t[l+1],a).normalize().multiplyScalar(r):i&&t.length>1&&h.subVectors(t[0],a).normalize().multiplyScalar(r);const d=new jn;d.position.copy(a),d.tangentIn.copy(h),d.tangentOut.copy(h),o.addKnot(d)}),o.closed=i,o}s.createFromPoints=e})(exports.SplineUtils||(exports.SplineUtils={}));class QR extends se.WorkerBase{constructor(){super(new Worker(new URL("/generateMeshBVH.worker-2qGLkQjg.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:Zu&&Zu.tagName.toUpperCase()==="SCRIPT"&&Zu.src||new URL("needle-engine.bundle-CrO5PE4u.umd.cjs",document.baseURI).href),{type:"module"})),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((n,o)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=h=>{o(new Error(`[GenerateMeshBVHWorker] ${h.message||"Unknown error. Please check the server console. If you're using vite try adding 'three-mesh-bvh' to 'optimizeDeps.exclude' in your vite.config.js"}`))},e.onmessage=h=>{const{data:d}=h;if(d.error)o(new Error(d.error)),e.onmessage=null;else if(d.serialized){const{serialized:u,position:p}=d,m=se.MeshBVH.deserialize(u,t,{setIndex:!1}),y=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=p,u.index)if(t.index)t.index.array=u.index;else{const _=new c.BufferAttribute(u.index,1,!1);t.setIndex(_)}y.setBoundingBox&&(t.boundingBox=m.getBoundingBox(new c.Box3)),i.onProgress&&i.onProgress(d.progress),n(m),e.onmessage=null}else i.onProgress&&i.onProgress(d.progress)};const r=t.index?t.index.array:null,a=t.attributes.position.array,l=[a];r&&l.push(r),e.postMessage({index:r,position:a,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},l.map(h=>h.buffer).filter(h=>typeof SharedArrayBuffer>"u"||!(h instanceof SharedArrayBuffer)))})}}const YR=Object.freeze(Object.defineProperty({__proto__:null,GenerateMeshBVHWorker:QR},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=OP;exports.ActionBuilder=le;exports.ActionCollection=aw;exports.ActionModel=Wt;exports.Addressables=W0;exports.AlignmentConstraint=Oc;exports.AmbientMode=aa;exports.Animation=St;exports.AnimationCurve=Gc;exports.AnimationExtension=bu;exports.AnimationTrackHandler=cc;exports.AnimationUtils=Zs;exports.Animator=rt;exports.AnimatorConditionMode=Us;exports.AnimatorController=Di;exports.AnimatorControllerParameterType=$m;exports.AnimatorStateInfo=wl;exports.Antialiasing=Xc;exports.Application=sn;exports.AssetDatabase=a0;exports.AssetReference=Y;exports.Attractor=Ua;exports.AudioExtension=gr;exports.AudioListener=ss;exports.AudioSource=pi;exports.AudioTrackHandler=rs;exports.Avatar=eo;exports.AvatarBlink_Simple=ur;exports.AvatarEyeLook_Rotation=Km;exports.AvatarLoader=ix;exports.AvatarMarker=xe;exports.AvatarModel=py;exports.Avatar_Brain_LookAt=nc;exports.Avatar_MouthShapes=Rc;exports.Avatar_MustacheShake=Qm;exports.Avatar_POI=qo;exports.Axes=Jr;exports.AxesHelper=Oa;exports.BUILD_TIME=ym;exports.BaseUIComponent=Bi;exports.BasicIKConstraint=Jm;exports.BehaviorExtension=kg;exports.BehaviorModel=gt;exports.BloomEffect=Au;exports.BoxCollider=pu;exports.BoxGizmo=vr;exports.BoxHelperComponent=nt;exports.Button=ws;exports.ButtonsFactory=Ki;exports.CallDirection=Ov;exports.CallInfo=ns;exports.Camera=qt;exports.CameraTargetReachedEvent=ic;exports.Canvas=va;exports.CanvasGroup=to;exports.CapsuleCollider=cs;exports.ChangeMaterialOnClick=bg;exports.ChangeTransformOnClick=yr;exports.CharacterController=fr;exports.CharacterControllerInput=fs;exports.ChromaticAberration=Qc;exports.CircularBuffer=di;exports.ClearFlags=Go;exports.ClickThrough=Qu;exports.ClipExtrapolation=bn;exports.Collider=Kt;exports.Collision=Sv;exports.CollisionDetectionMode=lu;exports.ColorAdjustments=go;exports.ColorBySpeedModule=Fa;exports.ColorOverLifetimeModule=Eu;exports.Component=D1;exports.Component$1=k;exports.ComponentLifecycleEvents=Jd;exports.Components=XR;exports.ConnectionEvents=t0;exports.ContactPoint=xv;exports.ContactShadows=Tc;exports.Context=z;exports.ContextArgs=b1;exports.ContextEvent=re;exports.ContextRegistry=ae;exports.ControlTrackHandler=Vu;exports.CursorFollow=ch;exports.CustomBranding=br;exports.CustomShader=ye;exports.DefaultReflectionMode=Md;exports.Deletable=ng;exports.DeleteBox=Xs;exports.DepthOfField=hn;exports.DeviceFlag=mu;exports.DocumentExtension=nx;exports.DragControls=Io;exports.DragMode=sg;exports.DropListener=ps;exports.Duplicatable=rg;exports.EffectWrapper=lc;exports.EmissionModule=bs;exports.EmphasizeOnClick=Ra;exports.EngineLoadingView=dc;exports.EnvironmentScene=qu;exports.EventList=oe;exports.EventListEvent=cu;exports.EventSystem=Bt;exports.EventTrigger=yu;exports.FieldWithDefault=Gv;exports.FileReference=Wo;exports.FileReferenceSerializer=G0;exports.FileSpawnModel=QP;exports.File_Event=Lv;exports.FixedJoint=Vg;exports.Fog=Ia;exports.FrameEvent=pe;exports.GENERATOR=Xd;exports.GameObject=S;exports.Gizmos=I;exports.GltfExport=mg;exports.GltfExportBox=fg;exports.Gradient=xr;exports.Graphic=zc;exports.GraphicRaycaster=hu;exports.Graphics=Ks;exports.GridHelper=ja;exports.GridLayoutGroup=Dg;exports.GroundProjectedEnv=Bn;exports.GroupActionModel=jo;exports.HideFlags=du;exports.HideOnStart=Ei;exports.HingeJoint=Vc;exports.HorizontalLayoutGroup=Lg;exports.HostData=vC;exports.Image=Wa;exports.ImageReference=$o;exports.ImageReferenceSerializer=H0;exports.InheritVelocityModule=Gg;exports.Input=Qb;exports.InputEventQueue=Gt;exports.InputEvents=we;exports.InputField=ry;exports.InstanceHandle=Xo;exports.InstancingHandler=ir;exports.InstancingUtil=Li;exports.InstantiateEvent=_0;exports.InstantiateIdProvider=mt;exports.InstantiateOptions=an;exports.Interactable=ig;exports.JoinedRoomResponse=WS;exports.KeyEventArgs=LS;exports.Keyframe=Xt;exports.LODGroup=Wc;exports.LODModel=Ba;exports.LeftRoomResponse=HS;exports.Light=ei;exports.LightData=K0;exports.LimitVelocityOverLifetimeModule=et;exports.LoadingElementOptions=LR;exports.LogStats=tg;exports.LogType=ci;exports.LookAt=ay;exports.LookAtConstraint=dr;exports.MainModule=Ot;exports.MarkerTrackHandler=Nu;exports.MarkerType=ny;exports.MaskableGraphic=Nc;exports.Mathf=D;exports.MeshCollider=lo;exports.MeshRenderer=Lc;exports.MinMaxCurve=H;exports.MinMaxGradient=Sr;exports.NEKeyboardEvent=yl;exports.NEPointerEvent=Zn;exports.NeedleButtonElement=tx;exports.NeedleEngineWebComponent=fy;exports.NeedleMenu=Un;exports.NeedlePatchesKey=Yh;exports.NeedleXRController=wm;exports.NeedleXRSession=G;exports.NeedleXRSync=s0;exports.NeedleXRUtils=r0;exports.NestedGltf=Hc;exports.NetworkConnection=n0;exports.NetworkedStreamEvents=Mn;exports.NetworkedStreams=Ec;exports.Networking=Wg;exports.NewInstanceModel=v0;exports.NoiseModule=fe;exports.ObjectRaycaster=fi;exports.ObjectUtils=ar;exports.OffsetConstraint=wr;exports.OneEuroFilter=Xh;exports.OneEuroFilterXYZ=cm;exports.OpenURL=Ha;exports.OrbitControls=de;exports.Outline=Da;exports.OwnershipEvent=i0;exports.OwnershipModel=Pm;exports.PUBLIC_KEY=Yr;exports.Padding=_r;exports.ParticleBurst=Nd;exports.ParticleSubEmitter=qg;exports.ParticleSystem=ac;exports.ParticleSystemBaseBehaviour=mo;exports.ParticleSystemRenderer=Vi;exports.ParticleSystemShapeType=zd;exports.PeerHandle=os;exports.PeerNetworking=e0;exports.Physics=ga;exports.PhysicsExtension=Eg;exports.PhysicsMaterialCombine=it;exports.PixelationEffect=Yc;exports.PlayAnimationOnClick=oc;exports.PlayAudioOnClick=Js;exports.PlayableDirector=or;exports.PlayerColor=wa;exports.PlayerState=Zi;exports.PlayerStateEvent=hw;exports.PlayerSync=Og;exports.PlayerView=X0;exports.PlayerViewManager=Q0;exports.PointerEventData=kc;exports.PointerType=Kd;exports.PostProcessingEffect=Ve;exports.PostProcessingEffectOrder=Ke;exports.PostProcessingHandler=Zg;exports.PreliminaryAction=Ta;exports.PreliminaryTrigger=jc;exports.PrimitiveType=Yo;exports.Progress=ie;exports.PromiseAllWithErrors=am;exports.PromiseErrorResult=cp;exports.RGBAColor=Z;exports.RapierPhysics=ha;exports.RawImage=Hu;exports.RaycastOptions=ro;exports.Rect=uw;exports.RectTransform=rn;exports.ReflectionProbe=sc;exports.RegisteredAnimationInfo=Ws;exports.RemoteSkybox=Du;exports.RenderTexture=On;exports.RenderTextureSerializer=_v;exports.Renderer=mi;exports.RendererData=Y0;exports.RendererLightmap=Fd;exports.Rigidbody=Ne;exports.RigidbodyConstraints=Ie;exports.RoomEvents=Q;exports.RotationBySpeedModule=Ni;exports.RotationOverLifetimeModule=cn;exports.SceneLightSettings=Id;exports.SceneSwitcher=Be;exports.ScreenCapture=yo;exports.ScreenSpaceAmbientOcclusion=vs;exports.ScreenSpaceAmbientOcclusionN8=dn;exports.ScrollFollow=xs;exports.SendQueue=Yi;exports.SerializationContext=jm;exports.SetActiveOnClick=vg;exports.ShadowCatcher=eh;exports.ShapeModule=Hg;exports.ShapeOverlapResult=Cv;exports.SharpeningEffect=Zc;exports.SignalAsset=zu;exports.SignalReceiver=oh;exports.SignalReceiverEvent=sh;exports.SignalTrackHandler=hc;exports.Size=dw;exports.SizeBySpeedModule=ti;exports.SizeOverLifetimeModule=Cr;exports.SkinnedMeshRenderer=ug;exports.SmoothFollow=ju;exports.SpatialGrabRaycaster=er;exports.SpatialHtml=ah;exports.SpatialTrigger=Bu;exports.SpatialTriggerReceiver=Dn;exports.SpectatorCamera=Fu;exports.SphereCollider=Ma;exports.SphereIntersection=km;exports.SplineContainer=kr;exports.SplineData=jn;exports.SplineWalker=un;exports.Sprite=gs;exports.SpriteData=ca;exports.SpriteRenderer=Zt;exports.SpriteSheet=ba;exports.StateMachineBehaviour=z1;exports.StreamEndedEvent=qm;exports.StreamReceivedEvent=Pv;exports.SubEmitterSystem=Vd;exports.SyncedCamera=ey;exports.SyncedRoom=fn;exports.SyncedTransform=on;exports.TapGestureTrigger=xg;exports.TeleportTarget=Cu;exports.TestRunner=ty;exports.TestSceneUtils=VR;exports.TestSimulateUserData=iy;exports.Text=Pt;exports.TextBuilder=Tg;exports.TextExtension=Ou;exports.TextureSheetAnimationModule=Mt;exports.TiltShiftEffect=Vn;exports.Time=Z0;exports.ToneMappingEffect=io;exports.TrackHandler=$a;exports.TrackType=si;exports.TrailModule=Re;exports.TransformData=ke;exports.TransformGizmo=Rr;exports.TriggerBuilder=xt;exports.TriggerModel=Qs;exports.TypeStore=P;exports.UIRaycastUtils=Hm;exports.UIRootComponent=Fc;exports.USDDocument=gg;exports.USDObject=ze;exports.USDWriter=Zv;exports.USDZExporter=Ln;exports.USDZExporter$1=Jv;exports.USDZText=ta;exports.USDZUIExtension=jg;exports.UriSerializer=bv;exports.UsageMarker=Ac;exports.UserJoinedOrLeftRoomModel=GS;exports.VERSION=Ji;exports.VariantAction=_g;exports.VelocityOverLifetimeModule=Le;exports.VerticalLayoutGroup=Ag;exports.VideoPlayer=Ze;exports.ViewDevice=Hs;exports.Vignette=Mr;exports.VisibilityAction=Bc;exports.Voip=ao;exports.Volume=Na;exports.VolumeParameter=j;exports.VolumeProfile=Ru;exports.WaitForFrames=ZC;exports.WaitForPromise=q0;exports.WaitForSeconds=Um;exports.Watch=as;exports.WebARCameraBackground=hh;exports.WebARSessionRoot=hi;exports.WebXR=Pu;exports.WebXRButtonFactory=Ys;exports.WebXRImageTracking=dh;exports.WebXRImageTrackingModel=Cs;exports.WebXRPlaneTracking=Ps;exports.WebXRTrackedImage=xa;exports.XRControllerFollow=Ss;exports.XRControllerModel=hs;exports.XRControllerMovement=gi;exports.XRFlag=Ti;exports.XRRig=Yu;exports.XRState=jt;exports.XRStateFlag=Cn;exports.__Ignore=sx;exports.__internalNotifyObjectDestroyed=cC;exports.activeInHierarchyFieldName=ls;exports.addAttributeChangeCallback=om;exports.addComponent=en;exports.addCustomExtensionPlugin=yO;exports.addNewComponent=No;exports.addPatch=Qd;exports.apply=tu;exports.applyHMRChanges=L1;exports.applyPrototypeExtensions=A0;exports.beginListenDestroy=b0;exports.beginListenInstantiate=x0;exports.binaryIdentifierCasts=xm;exports.build_scene_functions=_1;exports.builtinComponentKeyName=Ro;exports.calculateProgress01=uy;exports.clearMessages=Vx;exports.colorSerializer=nP;exports.compareAssociation=O0;exports.componentSerializer=od;exports.copyTexture=jb;exports.createMotion=fv;exports.debugNet=zt;exports.debugOwner=_l;exports.decompressGpuTexture=nw;exports.deepClone=pc;exports.delay=In;exports.delayForFrames=mc;exports.deserializeObject=Pd;exports.destroy=ui;exports.destroyComponentInstance=I0;exports.determineMimeTypeFromExtension=Dv;exports.disposeObjectResources=_e;exports.disposeStream=kn;exports.editorGuidKeyName=Il;exports.enableSpatialConsole=Fo;exports.euler=oP;exports.eventListSerializer=cP;exports.exportAsGLTF=HR;exports.findByGuid=Fm;exports.findObjectOfType=Ca;exports.findObjectsOfType=B0;exports.findResourceUsers=Em;exports.fitCamera=pv;exports.fitObjectIntoVolume=Fb;exports.foreachComponent=Zo;exports.foreachComponentEnumerator=nu;exports.forward=rS;exports.generateQRCode=Sb;exports.generateSeed=w0;exports.getBoundingBox=Ft;exports.getCameraController=Eb;exports.getComponent=cr;exports.getComponentInChildren=Sc;exports.getComponentInParent=Jl;exports.getComponents=xc;exports.getComponentsInChildren=Sa;exports.getComponentsInParent=eu;exports.getFormattedDate=Xv;exports.getIconElement=pt;exports.getIconTexture=Ep;exports.getLoader=nn;exports.getOrAddComponent=wc;exports.getParam=w;exports.getParentHierarchyPath=cS;exports.getPath=bx;exports.getPeerOptions=zS;exports.getPeerjsInstance=Jb;exports.getResourceUserCount=dC;exports.getTempColor=Ab;exports.getTempQuaternion=Ht;exports.getTempVector=F;exports.getUrlParams=fc;exports.getVisibleInCustomShadowRendering=Bb;exports.getWorldDirection=Lb;exports.getWorldEuler=um;exports.getWorldPosition=X;exports.getWorldQuaternion=ue;exports.getWorldRotation=qd;exports.getWorldScale=je;exports.hasCommercialLicense=Gs;exports.hasIndieLicense=Pc;exports.hasPointerEventComponent=Td;exports.hasProLicense=An;exports.hideDebugConsole=Vb;exports.imageToCanvas=sw;exports.instantiate=Jo;exports.invokeLoadedImportPluginHooks=$v;exports.invokeXRSessionEnd=Xb;exports.invokeXRSessionStart=qb;exports.isActiveInHierarchy=F0;exports.isActiveSelf=Pa;exports.isAndroidDevice=Px;exports.isAnimationAction=Ib;exports.isComponent=wv;exports.isDebugMode=mx;exports.isDesktop=wx;exports.isDestroyed=Ko;exports.isDevEnvironment=A;exports.isDisposed=lC;exports.isExporting=$R;exports.isGLTFModel=vv;exports.isHostedOnGlitch=gb;exports.isHotReloadEnabled=Dp;exports.isHotReloading=T1;exports.isIPad=Sx;exports.isIconElement=tv;exports.isLocalNetwork=Ii;exports.isMacOS=Mx;exports.isMobileDevice=xx;exports.isMozillaXR=Ox;exports.isQuest=Rx;exports.isResourceTrackingEnabled=c0;exports.isSafari=Ex;exports.isUsingInstancing=iu;exports.isiOS=kx;exports.isiPad=Cx;exports.loadAsset=MR;exports.loadPMREM=Dw;exports.loadSync=dy;exports.logHierarchy=yd;exports.lookAtInverse=Zx;exports.lookAtObject=gc;exports.lookAtScreenPoint=Jx;exports.makeId=yx;exports.makeIdFromRandomWords=bb;exports.makeNameSafe=ji;exports.markAsInstancedRendered=U0;exports.microphonePermissionsGranted=Tx;exports.nameof=px;exports.nameofFactory=yb;exports.objectSerializer=yv;exports.offXRSessionEnd=AS;exports.offXRSessionStart=TS;exports.onAfterRender=E1;exports.onBeforeRender=k1;exports.onClear=O1;exports.onDestroy=M1;exports.onInitialized=rv;exports.onStart=ru;exports.onUpdate=av;exports.onXRSessionEnd=vm;exports.onXRSessionStart=Yd;exports.parseSync=Yw;exports.placeOnSurface=Ub;exports.postprocessFBXMaterials=mm;exports.prefix=K1;exports.pushState=_b;exports.randomNumber=_x;exports.registerBinaryType=Sm;exports.registerComponent=ou;exports.registerComponentExtension=cg;exports.registerCustomEffectType=$i;exports.registerExportExtensions=hg;exports.registerExtensions=Bd;exports.registerHotReloadType=cv;exports.registerLoader=_m;exports.registerPrefabProvider=C0;exports.registerPrototypeExtensions=L0;exports.registerType=Lm;exports.relativePathPrefix=wb;exports.removeAttributeChangeCallback=rm;exports.removeComponent=Bm;exports.removeCustomImportExtensionType=_O;exports.removePatch=ES;exports.resolveUrl=no;exports.sanitizeString=vb;exports.saveImage=Gw;exports.screenshot=hR;exports.screenshot2=hy;exports.sendDestroyed=Tm;exports.serializable=f;exports.serializeObject=k0;exports.serializeable=$e;exports.setActive=Fl;exports.setAllowBalloonMessages=Ob;exports.setAllowOverlayMessages=Fx;exports.setAutoFitEnabled=md;exports.setCameraController=dp;exports.setDestroyed=N0;exports.setDevEnvironment=yS;exports.setDisposable=d0;exports.setDontDestroy=$r;exports.setOrAddParamsToUrl=lp;exports.setParam=gx;exports.setParamWithoutReload=Ql;exports.setPeerOptions=NS;exports.setResourceTrackingEnabled=aC;exports.setState=nm;exports.setVisibleInCustomShadowRendering=pm;exports.setWorldEuler=fm;exports.setWorldPosition=ot;exports.setWorldPositionXYZ=Qo;exports.setWorldQuaternion=tn;exports.setWorldQuaternionXYZW=dm;exports.setWorldRotation=Db;exports.setWorldRotationXYZ=yc;exports.setWorldScale=ua;exports.showBalloonError=_c;exports.showBalloonMessage=Se;exports.showBalloonWarning=he;exports.showDebugConsole=gm;exports.slerp=Kx;exports.syncDestroy=bc;exports.syncField=Pg;exports.syncInstantiate=Am;exports.textureToCanvas=hS;exports.toSourceId=xb;exports.tryCastBinary=Kb;exports.tryDetermineMimetypeFromBinary=jv;exports.tryDetermineMimetypeFromURL=Iv;exports.tryFindObject=da;exports.tryGetGuid=Zb;exports.unregisterHotReloadType=hv;exports.unwatchWrite=sm;exports.useForAutoFit=Rb;exports.validate=yt;exports.watchWrite=Gd;
|