@needle-tools/engine 4.10.0-beta.7 → 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.
@@ -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.7";');so('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";');so('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Thu Sep 25 2025 12:21:09 GMT+0000 (Coordinated Universal Time)";');so('globalThis["__NEEDLE_PUBLIC_KEY__"] = "'+NEEDLE_PUBLIC_KEY+'";');const Ji="4.10.0-beta.7",Xd="undefined",ym="Thu Sep 25 2025 12:21:09 GMT+0000 (Coordinated Universal Time)";$b&&console.log(`Engine version: ${Ji} (generator: ${Xd})
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-D0Yvltn9.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
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.
@@ -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()})
@@ -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=(b-v)*10,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.
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 => {
@@ -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,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-DktO3ijZ.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;