@needle-tools/engine 3.21.3 → 3.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6636,4 +6636,4 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
6636
6636
  <slot class="overlay-content"></slot>
6637
6637
  </div>
6638
6638
  `,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Ft({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return Ice}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(ns&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];i&&(ns&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),Nc!=null&&Nc.length&&this.setAttribute("version",Nc)}disconnectedCallback(){var i;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");ns&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(i=this._context)==null||i.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(t,i,s){switch(ns&&console.log("attributeChangedCallback",t,i,s),t){case"src":ns&&console.warn("src changed to type:",typeof s,', from "',i,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(ns&&console.log(t+" attribute changed",s),this.registerEventFromAttribute(t,s));break;case"dracoDecoderPath":ns&&console.log("dracoDecoderPath",s),CD(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(ns&&console.log("dracoDecoderType",s),ED(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":ns&&console.log("ktx2DecoderPath",s),MD(s);break}}async onLoad(){var f,p;if(!this.isConnected)return;if(this._context||(ns&&console.warn("Create new context"),this._context=new Ft({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const t=this.getSourceFiles();if(t==null||t.length<=0)ns&&console.warn("Clear scene",t),this._context.clear();else if(!this.checkIfSourceHasChanged(t,this._lastSourceFiles))return;this._lastSourceFiles=t;const i=++this._loadId,s=this.getAttribute("alias");this.classList.add("loading");const r=Qf();this.ensureLoadStartIsRegistered();let o=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:s},cancelable:!0}));if(r){const g=this.getAttribute("hide-loading-overlay");g!=null&&g!=="0"&&(o=!1)}o===!1&&!r&&(ci()||(o=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),ci()&&Ls('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&o&&(this._loadingView=new im(this)),o&&(this._didFullyLoad!==!0?(f=this._loadingView)==null||f.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===i&&this._loadingView.onLoadingBegin("begin load")},300)),ns&&console.warn("--------------",i,"Needle Engine: Begin loading",s??"",t),this.onBeforeBeginLoading();const a=[],c={context:this._context,name:"",progress:{},index:0,count:t.length,totalProgress01:this._loadingProgress01},l=new CustomEvent("progress",{detail:c}),u={files:t,onLoadingProgress:g=>{var A;g.name=Rce(g.name),o&&((A=this._loadingView)==null||A.onLoadingUpdate(g)),c.name=g.name,c.progress=g.progress,this._loadingProgress01=vT(g),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(g,A,v)=>{v&&a.push({src:A,file:v})}},d=this.getAttribute("hash");d!=null&&(this._context.hash=d),this._context.alias=s,await this._context.create(u),this._loadId===i&&(ns&&console.warn("--------------",i,"Needle Engine: finished loading",s??"",t),this._loadingProgress01=1,o&&((p=this._loadingView)==null||p.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:s,loadedFiles:a}})))}internalSetLoadingMessage(t){var i;(i=this._loadingView)==null||i.setMessage(t)}getSourceFiles(){const t=this.getAttribute("src");if(!t)return[];let i;Array.isArray(t)?i=t:t.startsWith("[")&&t.endsWith("]")?i=JSON.parse(t):t.includes(",")?i=t.split(","):i=[t];for(let s=i.length-1;s>=0;s--){const r=i[s];(r==="null"||r==="undefined"||(r==null?void 0:r.length)<=0)&&i.splice(s,1)}return i}checkIfSourceHasChanged(t,i){if((t==null?void 0:t.length)!==(i==null?void 0:i.length)||t==null&&i!==null||t!==null&&i==null)return!0;if(t!==null&&i!==null){for(let s=0;s<(t==null?void 0:t.length);s++)if(t[s]!==i[s])return!0}return!1}ensureLoadStartIsRegistered(){const t=this.getAttribute("loadstart");t&&this.registerEventFromAttribute("loadstart",t)}registerEventFromAttribute(t,i){const s=this._previouslyRegisteredMap.get(t);if(s&&(this._previouslyRegisteredMap.delete(t),this.removeEventListener(t,s)),typeof i=="string"&&i.length>0)try{const r=(0,eval)(i);typeof r=="function"&&(this._previouslyRegisteredMap.set(t,r),this.addEventListener(t,o=>r==null?void 0:r.call(globalThis,this._context,o)))}catch(r){console.error("Error registering event "+t+'="'+i+`" failed with the following error:
6639
- `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(mg),this.classList.remove(Ag);const t=this.getAROverlayContainer();ns&&console.warn("onSetupAR:",t),t&&(t.classList.add(mg),t.classList.remove(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,MN))}onSetupVR(){this.classList.remove(mg),this.classList.remove(Ag),this.foreachHtmlElement(t=>this.setupElementsForMode(t,DG))}onSetupDesktop(){this.classList.remove(mg),this.classList.add(Ag);const t=this.getAROverlayContainer();t&&(t.classList.remove(mg),t.classList.add(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,OG))}setupElementsForMode(t,i,s=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of Tce)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ns&&console.log("using custom draco decoder path",t),CD(t));const i=this.getAttribute("dracoDecoderType");i&&(ns&&console.log("using custom draco decoder type",i),ED(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ns&&console.log("using custom ktx2 decoder path",s),MD(s))}}typeof window<"u"&&!window.customElements.get(Rk)&&window.customElements.define(Rk,lR);function Rce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const Pce=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:lR},Symbol.toStringTag,{value:"Module"})),V0=re("debughotreload");let aA=!1;const hm=new Map;function Bce(){return aA}function Dce(n){var i;if(aA)return;const t=n.constructor.name;hm.has(t)?(i=hm.get(t))==null||i.push(n):hm.set(t,[n])}function Oce(n){if(aA)return;const t=n.constructor.name,i=hm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let Pk=!1;function kce(){if(V0||Pk)return;Pk=!0;const n=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}n.apply(console,e)}}function Lce(n){V0&&console.log("[HMR] Apply changes",n,Object.keys(n)),kce();for(const e of Object.keys(n))try{aA=!0;const t=q.get(e);if(!t){V0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=hm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,u=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Bc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&rT(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(V0)console.error(t);else return!1}finally{aA=!1,Xc(Bo.Log,"Script changes applied (HMR)")}return!0}const Fce=Symbol("object"),Bk=new Xa(()=>new w,20);class kG{constructor(e,t,i,s,r){h(this,"_point");h(this,"_normal");h(this,"distance");h(this,"impulse");h(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return Bk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Bk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class LG{constructor(e,t,i){h(this,"contacts");h(this,"me");h(this,"_collider");h(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class FG{constructor(e,t){h(this,"object");h(this,"collider");this.object=e,this.collider=t}}let Ne;const cA=new Array(32).fill(void 0);cA.push(void 0,null,!0,!1);let Dk;cA.length;function Ok(){return Dk.byteLength,Dk}const Uce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}Uce.decode();let kk,Lk,um=32;function Fk(n){if(um==1)throw new Error("out of js stack");return cA[--um]=n,um}function Nce(){return kk.byteLength,kk}function zce(){return Lk.byteLength,Lk}let Fr=0;function Xh(n,e){const t=e(4*n.length);return Nce().set(n,t/4),Fr=n.length,t}function $y(n,e){const t=e(4*n.length);return zce().set(n,t/4),Fr=n.length,t}class kb{static __wrap(e){const t=Object.create(kb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return kb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Oa{static __wrap(e){const t=Object.create(Oa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Oa.__wrap(i)}static prismatic(e,t,i,s,r,o){vt(e,ft),vt(t,ft),vt(i,ft);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Oa.__wrap(a)}static fixed(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,qn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Oa.__wrap(r)}static revolute(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Oa.__wrap(s)}}class hR{static __wrap(e){const t=Object.create(hR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=Ok()[i/4+0],t=Ok()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class qn{static __wrap(e){const t=Object.create(qn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return qn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return qn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Xh(i,Ne.__wbindgen_malloc),o=Fr;vt(s,ft);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){vt(e,ft),vt(t,ft),vt(i,ft);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Xh(e,Ne.__wbindgen_malloc),i=Fr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Xh(e,Ne.__wbindgen_malloc),r=Fr,o=$y(t,Ne.__wbindgen_malloc),a=Fr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,Gt),vt(r,ft),vt(o,qn),vt(a,ft);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:fR.__wrap(l)}intersectsShape(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,i){return vt(e,ft),vt(t,qn),vt(i,ft),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return hR.__wrap(r)}intersectsRay(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return ft.__wrap(e)}}class fR{static __wrap(e){const t=Object.create(fR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return ft.__wrap(e)}}class ft{static __wrap(e){const t=Object.create(ft.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return ft.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return ft.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return ft.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return ft.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return ft.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return ft.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return ft.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return ft.__wrap(e)}}class Gce{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Re{static new(e,t,i){return new Gce(e,t,i)}static intoRaw(e){return new ft(e.x,e.y,e.z)}static zeros(){return Re.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Re.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Uk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Di{static identity(){return new Uk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Uk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qn(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var dm,Ca,Nk,Eo,OM,Zt,Lb,uf,kM,LM,zk,Gk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(dm||(dm={}));class Hce{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Re.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Re.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Re.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Re.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,s,r){let o=Re.intoRaw(t),a=Re.intoRaw(i),c=Di.intoRaw(s);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(Ca||(Ca={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(Nk||(Nk={}));class df{constructor(){}static fixed(e,t,i,s){let r=new df;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=Ca.Fixed,r}static spherical(e,t){let i=new df;return i.anchor1=e,i.anchor2=t,i.jointType=Ca.Spherical,i}static prismatic(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Prismatic,s}static revolute(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Revolute,s}intoRaw(){let e,t,i=Re.intoRaw(this.anchor1),s=Re.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case Ca.Fixed:let c=Di.intoRaw(this.frame1),l=Di.intoRaw(this.frame2);t=Oa.fixed(i,c,s,l),c.free(),l.free();break;case Ca.Prismatic:e=Re.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Oa.prismatic(i,s,e,r,o,a),e.free();break;case Ca.Spherical:t=Oa.spherical(i,s);break;case Ca.Revolute:e=Re.intoRaw(this.axis),t=Oa.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(Eo||(Eo={}));class lA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new lA(e.distance(),Re.fromRaw(e.point1()),Re.fromRaw(e.point2()),Re.fromRaw(e.normal1()),Re.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(OM||(OM={}));class ow{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new ow(Re.fromRaw(e.point()),e.isInside());return e.free(),t}}class Vce{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class aw{constructor(e,t,i,s){this.featureType=OM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new aw(e.toi(),Re.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class _v{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new _v(t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class pR extends _v{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new pR(e.get(t.colliderHandle()),t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class xs{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case Zt.Ball:return new gR(e.coRadius(t));case Zt.Cuboid:return s=e.coHalfExtents(t),new UG(s.x,s.y,s.z);case Zt.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new NG(s.x,s.y,s.z,r);case Zt.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new zG(c,l);case Zt.Segment:return o=e.coVertices(t),new GG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new QG(o,a);case Zt.Triangle:return o=e.coVertices(t),new HG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new VG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]),r);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new WG(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new jG(f,p,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new FM(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new UM(o,a,r);case Zt.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new XG(c,l);case Zt.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new qG(c,l,r);case Zt.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new YG(c,l);case Zt.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new KG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Re.intoRaw(e),u=Di.intoRaw(t),d=Re.intoRaw(i),f=Re.intoRaw(r),p=Di.intoRaw(o),g=Re.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=_v.fromRaw(null,A.castShape(l,u,d,v,f,p,g,c));return l.free(),u.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Re.intoRaw(e),a=Di.intoRaw(t),c=Re.intoRaw(s),l=Di.intoRaw(r),u=this.intoRaw(),d=i.intoRaw(),f=u.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),u.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Di.intoRaw(t),l=Re.intoRaw(s),u=Di.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=lA.fromRaw(d.contactShape(a,c,f,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Re.intoRaw(e),r=Di.intoRaw(t),o=Re.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Re.intoRaw(e),o=Di.intoRaw(t),a=Re.intoRaw(i),c=this.intoRaw(),l=ow.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=Re.intoRaw(e.origin),c=Re.intoRaw(e.dir),l=this.intoRaw(),u=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),u}castRay(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),u.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=aw.fromRaw(u.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),u.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class gR extends xs{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class UG extends xs{constructor(e,t,i){super(),this.type=Zt.Cuboid,this.halfExtents=Re.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class NG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundCuboid,this.halfExtents=Re.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class zG extends xs{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class GG extends xs{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class HG extends xs{constructor(e,t,i){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class VG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class QG extends xs{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class WG extends xs{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class FM extends xs{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class UM extends xs{constructor(e,t,i){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class jG extends xs{constructor(e,t,i,s){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Re.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class XG extends xs{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class qG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class YG extends xs{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class KG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Lb||(Lb={}));class Qce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=xs.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Re.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,s){let r=Re.intoRaw(t),o=Re.intoRaw(i),a=Di.intoRaw(s);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Re.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Re.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Re.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Re.intoRaw(e),s=ow.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Re.intoRaw(e.origin),s=Re.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Re.intoRaw(i),l=Di.intoRaw(s),u=Re.intoRaw(r),d=t.intoRaw(),f=_v.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f}castCollider(e,t,i,s){let r=Re.intoRaw(e),o=Re.intoRaw(i),a=pR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Re.intoRaw(t),r=Di.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=e.intoRaw(),c=lA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return lA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=aw.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(uf||(uf={}));class Hi{constructor(e){this.shape=e,this.massPropsMode=uf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=Re.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Eo.Average,this.restitutionCombineRule=Eo.Average,this.activeCollisionTypes=Lb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Re.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Re.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new gR(e);return new Hi(t)}static capsule(e,t){const i=new zG(e,t);return new Hi(i)}static segment(e,t){const i=new GG(e,t);return new Hi(i)}static triangle(e,t,i){const s=new HG(e,t,i);return new Hi(s)}static roundTriangle(e,t,i,s){const r=new VG(e,t,i,s);return new Hi(r)}static polyline(e,t){const i=new QG(e,t);return new Hi(i)}static trimesh(e,t){const i=new WG(e,t);return new Hi(i)}static cuboid(e,t,i){const s=new UG(e,t,i);return new Hi(s)}static roundCuboid(e,t,i,s){const r=new NG(e,t,i,s);return new Hi(r)}static heightfield(e,t,i,s){const r=new jG(e,t,i,s);return new Hi(r)}static cylinder(e,t){const i=new XG(e,t);return new Hi(i)}static roundCylinder(e,t,i){const s=new qG(e,t,i);return new Hi(s)}static cone(e,t){const i=new YG(e,t);return new Hi(i)}static roundCone(e,t,i){const s=new KG(e,t,i);return new Hi(s)}static convexHull(e){const t=new FM(e,null);return new Hi(t)}static convexMesh(e,t){const i=new FM(e,t);return new Hi(i)}static roundConvexHull(e,t){const i=new UM(e,null,t);return new Hi(i)}static roundConvexMesh(e,t,i){const s=new UM(e,t,i);return new Hi(s)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=uf.Density,this.density=e,this}setMass(e){return this.massPropsMode=uf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=uf.MassProps,this.mass=e,Re.copy(this.centerOfMass,t),Re.copy(this.principalAngularInertia,i),Di.copy(this.angularInertiaLocalFrame,s),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(kM||(kM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LM||(LM={}));class Wce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Re.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Re.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class jce{constructor(e,t){this.raw=t||new kb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Wce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(zk||(zk={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Gk||(Gk={}));for(var Hle={byteLength:function(n){var e=Hk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=Hk(n),s=i[0],r=i[1],o=new Xce(function(l,u,d){return 3*(u+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=bo[n.charCodeAt(t)]<<18|bo[n.charCodeAt(t+1)]<<12|bo[n.charCodeAt(t+2)]<<6|bo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=bo[n.charCodeAt(t)]<<2|bo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=bo[n.charCodeAt(t)]<<10|bo[n.charCodeAt(t+1)]<<4|bo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Yce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ra[e>>2]+Ra[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ra[e>>10]+Ra[e>>4&63]+Ra[e<<2&63]+"=")),s.join("")}},Ra=[],bo=[],Xce=typeof Uint8Array<"u"?Uint8Array:Array,vC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hd=0,qce=vC.length;Hd<qce;++Hd)Ra[Hd]=vC[Hd],bo[vC.charCodeAt(Hd)]=Hd;function Hk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Yce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ra[(s=i)>>18&63]+Ra[s>>12&63]+Ra[s>>6&63]+Ra[63&s]);return r.join("")}bo["-".charCodeAt(0)]=62,bo["_".charCodeAt(0)]=63;const Qs=re("debugphysics"),yC=re("debugcolliderplacement"),bC=re("debugcollisions"),Kce=re("showcolliders"),Ur=Symbol("needle component"),Or=Symbol("physics body"),Jce=Symbol("rigidbody");let Vd;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Qs&&console.log("Use Rapier",!1,globalThis.false);const ym=class{constructor(){h(this,"debugRenderColliders",!1);h(this,"context");h(this,"_initializePromise");h(this,"_isInitialized",!1);h(this,"rapierRay",new Vce({x:0,y:0,z:0},{x:0,y:0,z:1}));h(this,"raycastVectorsBuffer",new Xa(()=>new w,10));h(this,"rapierSphere",null);h(this,"rapierColliderArray",[]);h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});h(this,"rapierForwardVector",{x:0,y:0,z:1});h(this,"enabled",!1);h(this,"_tempPosition",new w);h(this,"_tempQuaternion",new we);h(this,"_tempScale",new w);h(this,"_tempMatrix",new Me);h(this,"_isUpdatingPhysicsWorld",!1);h(this,"_world");h(this,"_hasCreatedWorld",!1);h(this,"eventQueue");h(this,"collisionHandler");h(this,"objects",[]);h(this,"bodies",[]);h(this,"_meshCache",new Map);h(this,"_gravity",{x:0,y:-9.81,z:0});h(this,"lines")}removeBody(e){var i,s,r;if(!e)return;this.validate();const t=e[Or];if(e[Or]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof Qce){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[Ur]||(s=this.world)==null||s.removeRigidBody(l))}else a instanceof Hce&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ci()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=e,r=s[Or];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[Or];i&&this.internalUpdateColliderProperties(t,i)}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Qs&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:CR&&CR.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Qs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Qs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[Ur]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,u=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return u.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:u,normal:d,collider:o.collider[Ur]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const u=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(u)t=u;else return null}if(t.z===void 0){if(!s)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const u=this.raycastVectorsBuffer.get();u.x=t.x,u.y=t.y,u.z=0,(u.x>1||u.y>1||u.y<-1||u.x<-1)&&(Qs&&console.warn("Converting screenspace to raycast space",u),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(u)),u.unproject(s),t=u}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const u=Ct(s);o.sub(u)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new gR(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[Ur],r=new FG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},kM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[Ur].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const s=e.gameObject,r=ls(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Hi.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const i=Hi.ball(.5);this.createCollider(e,i,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const r=e.gameObject,o=ls(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Hi.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,u,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Qs&&console.warn("Missing mesh geometry",t.name);return}(u=(l=r.index)==null?void 0:l.array)!=null&&u.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=qY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Qs&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Hi.convexMesh(o):Hi.trimesh(o,a);c&&this.createCollider(e,c)}getBody(e){return e?e[Or]:null}getComponent(e){return e?e[Ur]:null}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),ls(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case wa.Average:t.setRestitutionCombineRule(Eo.Average);break;case wa.Maximum:t.setRestitutionCombineRule(Eo.Max);break;case wa.Minimum:t.setRestitutionCombineRule(Eo.Min);break;case wa.Multiply:t.setRestitutionCombineRule(Eo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case wa.Average:t.setFrictionCombineRule(Eo.Average);break;case wa.Maximum:t.setFrictionCombineRule(Eo.Max);break;case wa.Minimum:t.setFrictionCombineRule(Eo.Min);break;case wa.Multiply:t.setFrictionCombineRule(Eo.Multiply);break}}o&&t.setDensity(0);const c=this.world.createCollider(t,r);return c[Ur]=e,e[Or]=c,c.setActiveEvents(LM.COLLISION_EVENTS),c.setActiveCollisionTypes(Lb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[Or],s=r.autoMass===!1,!i){const o=r.isKinematic&&!yC;Qs&&console.log("Create rigidbody",o);const a=o?Vd.RigidBodyDesc.kinematicPositionBased():Vd.RigidBodyDesc.dynamic(),c=Ct(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(zn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[Ur]=r,r[Or]=i,this.internalUpdateRigidbodyProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Vd.RigidBodyDesc.kinematicPositionBased(),o=Ct(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(zn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[Ur]=null}return e[Jce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[Or]}internalUpdateColliderProperties(e,t){const i=t.shape;switch(i.type){case Zt.Ball:{const o=i,a=e,c=e.gameObject,l=ls(c,this._tempPosition).multiplyScalar(a.radius),u=a.radius*Math.abs(l.x),d=o.radius!==u;o.radius=u,d&&t.setShape(o);break}case Zt.Cuboid:const s=i,r=e;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,t.setShape(s);break}}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==lx.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(0);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Vd.RigidBodyType.KinematicPositionBased):t.setBodyType(Vd.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new jce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Qs||yC||Kce||this.debugRenderColliders===!0){if(!this.lines){const o=new vn({color:2258688,fog:!1}),a=new mt;this.lines=new eo(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new $e(r.vertices,3)),this.lines.geometry.setAttribute("color",new $e(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Zce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!yC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion);r.x-=c.x,r.y-=c.y,r.z-=c.z}Gf(t.gameObject,r.x,r.y,r.z),eF(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=Ct(e,this._tempPosition),o=zn(e,this._tempQuaternion);switch(t.bodyType()){case dm.Fixed:case dm.KinematicPositionBased:case dm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=ym._matricesBuffer,s.length=0),e===t){const r=ls(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[Or],s=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=df.fixed(ym.centerConnectionPos,ym.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Qs&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[Or],o=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Vd.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Qs&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let eu=ym;h(eu,"_didLoadPhysicsEngine",!1),h(eu,"_matricesBuffer",[]),h(eu,"centerConnectionPos",{x:0,y:0,z:0}),h(eu,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zce{constructor(e,t){h(this,"world");h(this,"eventQueue");h(this,"activeCollisions",[]);h(this,"activeCollisionsStay",[]);h(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[Ur],a=r[Ur];bC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Ru(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,s,(a,c)=>{Ru(o,l=>{var d;if(l.destroyed)return;const u=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(u||bC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new kG(A,m,p,v,b);f.push(y),bC&&zc.DrawDirection(A,p,16711680,3,!0)}}r=new LG(o,i,f)}if(u){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function $ce(n,e,t,i="image/webp",s){if(!n&&(n=Oi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,n.renderer.domElement.style.width=e+"px",n.renderer.domElement.style.height=t+"px";try{const c=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),c.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let vg=null;function ele(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}vg||(vg=document.createElement("a")),vg.href=n,vg.download=e,vg.click()}}const Fb=re("debugmissingcamera");Oi.registerCallback(Ks.MissingCamera,n=>{var r,o;Fb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Li;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",n.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=1:i.clearFlags=2,i.backgroundColor=new bi(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const s=gh(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,JG(n.context,s),s});Oi.registerCallback(Ks.ContextCreated,n=>{if(!n.context.mainCamera){Fb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Fte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Fb&&console.log("Will not auto-fit because a camera controller exists");return}JG(n.context)}});function JG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Fb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Q_(t,Ji);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}_j();const mR={Context:Ft,glTF:{loadFromURL:cR}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=mR;function ZG(n){for(const e in n)mR[e]=n[e]}ZG(wY);ZG(pce);for(const n of Object.getOwnPropertyNames(ne))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:mR[n]=ne[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=oj;var AR={},$G={};Object.defineProperty($G,"__esModule",{value:!0});var cw={};Object.defineProperty(cw,"__esModule",{value:!0});cw.ConstantBackoff=void 0;var tle=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();cw.ConstantBackoff=tle;var lw={};Object.defineProperty(lw,"__esModule",{value:!0});lw.ExponentialBackoff=void 0;var ile=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();lw.ExponentialBackoff=ile;var hw={};Object.defineProperty(hw,"__esModule",{value:!0});hw.LinearBackoff=void 0;var nle=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();hw.LinearBackoff=nle;var eH={};Object.defineProperty(eH,"__esModule",{value:!0});var uw={};Object.defineProperty(uw,"__esModule",{value:!0});uw.LRUBuffer=void 0;var sle=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();uw.LRUBuffer=sle;var dw={};Object.defineProperty(dw,"__esModule",{value:!0});dw.TimeBuffer=void 0;var rle=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();dw.TimeBuffer=rle;var vR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(vR);var fw={};Object.defineProperty(fw,"__esModule",{value:!0});fw.WebsocketBuilder=void 0;var Qd=vR,ole=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Qd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();fw.WebsocketBuilder=ole;(function(n){var e=py&&py.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=py&&py.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t($G,n),t(cw,n),t(lw,n),t(hw,n),t(eH,n),t(uw,n),t(dw,n),t(vR,n),t(fw,n)})(AR);const ale=xA(AR),cle=nH({__proto__:null,default:ale},[AR]),Ao={node:"node",material:"material",camera:"camera",light:"light"},qh="KHR_animation_pointer",lle={CUBICSPLINE:void 0,LINEAR:Wa,STEP:nh},Vk=Nt.findNode;let Qk=!1;class hle{constructor(e){this.parser=e,this.name=qh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Qk||(Qk=!0,Nt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=Vk(e,i[2]);return r||console.warn(qh+": Property binding not found",t,e,e.name,i),r}return s}return Vk(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return i?this.parser.getDependency("node",i):null}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[qh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=Ao.node,o;if(i){const c=t.extensions[qh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Ao.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Ao.light:l.startsWith("/cameras/")&&(r=Ao.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Ao.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case Ao.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case Ao.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case Ao.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(l=u.resolvePath(l)),t.extensions[qh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Ao.node?a=this.parser.getDependency("node",o):r===Ao.material?a=this.parser.getDependency("material",o):r===Ao.light?a=this.parser.getDependency("light",o):r===Ao.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[qh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[qh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof ku&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=sh;break;case 2:case 3:g=el;break;case 4:a.endsWith(".quaternion")?g=ja:g=w_;break}const A=s.interpolation!==void 0?lle[s.interpolation]:Wa;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],u=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);if(y||(y=t.loadAnimationTargetFromChannel(g)),y==null){console.warn("Failed to load animation target",g,y);continue}a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let D=0;D<T.length;D++)b.push(T[D])}return new tr(o,void 0,b)})}}const ule=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hle},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=Fce;exports.ActionBuilder=fi;exports.ActionCollection=IT;exports.ActionModel=Vr;exports.Addressables=pN;exports.AlignmentConstraint=OA;exports.AmbientMode=xf;exports.Animation=$r;exports.AnimationCurve=zu;exports.AnimationExtension=rx;exports.AnimationTrackHandler=_x;exports.Animator=ks;exports.AnimatorConditionMode=Hl;exports.AnimatorController=oh;exports.AnimatorControllerParameterType=RT;exports.AnimatorStateInfo=T0;exports.Antialiasing=jA;exports.Application=vN;exports.ApplicationEvents=gb;exports.AssetDatabase=CU;exports.AssetReference=Tn;exports.AttachedObject=Io;exports.AttachedObjectEvents=Mb;exports.AudioExtension=wx;exports.AudioListener=xu;exports.AudioSource=yn;exports.AudioTrackHandler=wu;exports.AvatarBlink_Simple=Hu;exports.AvatarEyeLook_Rotation=yp;exports.AvatarLoader=cx;exports.AvatarMarker=Jn;exports.AvatarModel=ax;exports.Avatar_Brain_LookAt=Vm;exports.Avatar_MouthShapes=XA;exports.Avatar_MustacheShake=hI;exports.Avatar_POI=ir;exports.Axes=lf;exports.AxesHelper=bp;exports.BaseUIComponent=aa;exports.BasicIKConstraint=fI;exports.BehaviorExtension=Cx;exports.BehaviorModel=ds;exports.Behaviour=Ie;exports.Bloom=Vu;exports.BoxCollider=YA;exports.BoxGizmo=Qu;exports.BoxHelperComponent=To;exports.Button=fl;exports.CallInfo=Wf;exports.Camera=Li;exports.Canvas=ps;exports.CanvasGroup=hh;exports.CapsuleCollider=lh;exports.ChangeMaterialOnClick=wp;exports.ChangeTransformOnClick=Xu;exports.CharacterController=qu;exports.CharacterControllerInput=gl;exports.ChromaticAberration=tv;exports.CircularBuffer=Xa;exports.ClearFlags=Ib;exports.ClipExtrapolation=Sa;exports.Collider=Za;exports.Collision=LG;exports.CollisionDetectionMode=lx;exports.ColorAdjustments=Sh;exports.ColorBySpeedModule=Yu;exports.ColorOverLifetimeModule=iv;exports.Component=Ah;exports.ComponentEvents=SA;exports.ComponentLifecycleEvents=CA;exports.ConnectionEvents=tU;exports.ContactPoint=kG;exports.Context=Ft;exports.ContextArgs=bY;exports.ContextEvent=Ks;exports.ContextRegistry=Oi;exports.ControlTrackHandler=xx;exports.ControllerEvents=Cc;exports.ControllerType=Ef;exports.CustomBranding=Th;exports.CustomShader=kr;exports.DefaultReflectionMode=pb;exports.Deletable=MI;exports.DeleteBox=Bx;exports.DepthOfField=pa;exports.DeviceFlag=Dx;exports.DocumentExtension=TI;exports.DragControls=Ip;exports.DropListener=sv;exports.Duplicatable=Zu;exports.EXTENSION_NAME=w0;exports.EmissionModule=ec;exports.EmphasizeOnClick=Cp;exports.EngineLoadingView=im;exports.EventList=us;exports.EventListEvent=ix;exports.EventSystem=$s;exports.EventTrigger=kx;exports.FieldWithDefault=ST;exports.FileSpawnModel=Zz;exports.File_Event=Jz;exports.FixedJoint=kI;exports.FlyControls=LI;exports.Fog=Rp;exports.FrameEvent=Tr;exports.GENERATOR=z_;exports.GameObject=ne;exports.Gizmos=zc;exports.GltfExport=ov;exports.GltfExportBox=NI;exports.GltfLoadEvent=Eu;exports.GltfLoadEventType=TG;exports.Gradient=Ch;exports.Graphic=Wu;exports.GraphicRaycaster=cI;exports.Graphics=Zo;exports.GridHelper=Pp;exports.GridLayoutGroup=_I;exports.GroundProjectedEnv=$u;exports.GroupActionModel=jl;exports.HideFlags=PU;exports.HideOnStart=wI;exports.HingeJoint=rv;exports.HorizontalLayoutGroup=bI;exports.HostData=J9;exports.Image=xp;exports.ImageReference=_f;exports.ImageReferenceSerializer=gN;exports.InheritVelocityModule=Mh;exports.Input=Z2;exports.InputEvents=Sn;exports.InputField=ed;exports.InstancingUtil=Sr;exports.InstantiateEvent=rU;exports.InstantiateIdProvider=Bs;exports.InstantiateOptions=qa;exports.Interactable=up;exports.JoinedRoomResponse=F9;exports.KeyEventArgs=Fj;exports.LODGroup=cv;exports.LODModel=td;exports.LeftRoomResponse=U9;exports.Light=Rr;exports.LightData=AN;exports.LimitVelocityOverLifetimeModule=Bn;exports.LoadingElementOptions=OY;exports.LogStats=GI;exports.LogType=Bo;exports.LookAt=id;exports.LookAtConstraint=LA;exports.MainModule=bs;exports.MarkerType=lI;exports.MaskableGraphic=ZA;exports.Mathf=tt;exports.MeshCollider=KA;exports.MeshRenderer=nx;exports.MinMaxCurve=ht;exports.MinMaxGradient=Ir;exports.NEEDLE_progressive=Hr;exports.NEKeyboardEvent=h0;exports.NEPointerEvent=wc;exports.NeedleEngine=Oi;exports.NeedleEngineHTMLElement=lR;exports.NeedleGltfLoader=oR;exports.NeedlePatchesKey=m0;exports.NestedGltf=Nx;exports.NetworkConnection=nU;exports.Networking=Ju;exports.NoiseModule=vi;exports.ObjectRaycaster=rl;exports.ObjectUtils=yG;exports.OffsetConstraint=nd;exports.OpenURL=Bp;exports.OrbitControls=Ji;exports.Outline=_p;exports.OwnershipEvent=iU;exports.OwnershipModel=N_;exports.Padding=_h;exports.ParticleBurst=eA;exports.ParticleSubEmitter=Xx;exports.ParticleSystem=In;exports.ParticleSystemRenderer=Go;exports.PeerNetworking=eU;exports.Physics=aF;exports.PhysicsMaterialCombine=wa;exports.PixelationEffect=uv;exports.PlayAnimationOnClick=wh;exports.PlayAudioOnClick=Ep;exports.PlayableDirector=Zc;exports.PlayerColor=Bu;exports.PlayerState=Cu;exports.PlayerStateEvent=CG;exports.PlayerSync=rw;exports.PlayerView=CN;exports.PlayerViewManager=EN;exports.PointerEventData=Gc;exports.PointerType=zf;exports.PostProcessingEffect=Us;exports.PostProcessingHandler=qx;exports.PreliminaryAction=Mp;exports.PreliminaryTrigger=$A;exports.PrimitiveType=ZI;exports.ProgressiveLoadingInfo=QN;exports.PromiseAllWithErrors=D_;exports.PromiseErrorResult=H2;exports.RGBAColor=bi;exports.RapierPhysics=eu;exports.RawImage=Mx;exports.RaycastOptions=ko;exports.Raycaster=mp;exports.Rect=AI;exports.RectTransform=rr;exports.ReflectionProbe=hp;exports.RegisteredAnimationInfo=sx;exports.RemoteSkybox=ol;exports.RenderTexture=Jl;exports.RenderTextureSerializer=XN;exports.Renderer=Qi;exports.RendererData=mN;exports.RendererLightmap=Hm;exports.Rigidbody=Ii;exports.RigidbodyConstraints=ln;exports.RoomEvents=on;exports.RotationBySpeedModule=so;exports.RotationOverLifetimeModule=zo;exports.SceneLightSettings=vb;exports.SceneSwitcher=ur;exports.ScreenCapture=fv;exports.ScreenSpaceAmbientOcclusion=Al;exports.ScreenSpaceAmbientOcclusionN8=ma;exports.SendQueue=Ar;exports.SetActiveOnClick=Sp;exports.ShadowCatcher=gv;exports.ShapeModule=bn;exports.SignalAsset=VA;exports.SignalReceiver=vp;exports.SignalReceiverEvent=Ap;exports.SignalTrackHandler=Zm;exports.Size=mI;exports.SizeBySpeedModule=lr;exports.SizeOverLifetimeModule=Eh;exports.SkinnedMeshRenderer=CT;exports.SmoothFollow=Ih;exports.SpatialHtml=$I;exports.SpatialTrigger=Av;exports.SpatialTriggerReceiver=Qa;exports.SpectatorCamera=Jx;exports.SphereCollider=qA;exports.SphereIntersection=oF;exports.SphereOverlapResult=FG;exports.Sprite=vl;exports.SpriteData=Lp;exports.SpriteRenderer=ic;exports.SpriteSheet=vv;exports.StateMachineBehaviour=NK;exports.SubEmitterSystem=oA;exports.SyncedCamera=Zx;exports.SyncedRoom=Rh;exports.SyncedTransform=ah;exports.TapGestureTrigger=SI;exports.TeleportTarget=vx;exports.TestRunner=eR;exports.TestSimulateUserData=tR;exports.Text=hr;exports.TextBuilder=Rx;exports.TextExtension=nv;exports.TextureSheetAnimationModule=_s;exports.TiltShiftEffect=nc;exports.Time=cF;exports.ToneMapping=bv;exports.TrackHandler=QA;exports.TrackType=Lr;exports.TrailModule=ji;exports.TransformData=Zl;exports.TransformGizmo=rd;exports.TriggerBuilder=Cr;exports.TriggerModel=Kc;exports.TypeStore=q;exports.UIRaycastUtils=Yf;exports.UIRootComponent=HA;exports.USDObject=_r;exports.USDZExporter=oo;exports.USDZText=Xl;exports.USDZUIExtension=Px;exports.Upload_Result=zE;exports.UriSerializer=qN;exports.UsageMarker=dp;exports.UserJoinedOrLeftRoomModel=N9;exports.VERSION=Nc;exports.VRUserState=ta;exports.VariantAction=TT;exports.VelocityOverLifetimeModule=Zi;exports.VerticalLayoutGroup=yI;exports.VideoPlayer=Ns;exports.ViewDevice=Va;exports.Vignette=od;exports.VisibilityAction=ev;exports.Voip=dl;exports.Volume=ew;exports.VolumeParameter=Rt;exports.VolumeProfile=WA;exports.WaitForFrames=woe;exports.WaitForSeconds=pG;exports.Watch=jc;exports.WebAR=Su;exports.WebARCameraBackground=tw;exports.WebARSessionRoot=ca;exports.WebXR=It;exports.WebXRAvatar=Ua;exports.WebXRController=sn;exports.WebXREvent=Mi;exports.WebXRImageTracking=iw;exports.WebXRImageTrackingModel=yl;exports.WebXRPlaneTracking=ad;exports.WebXRSync=tA;exports.WebXRTrackedImage=Oc;exports.XRFlag=jr;exports.XRGrabModel=sw;exports.XRGrabRendering=nR;exports.XRRig=Ix;exports.XRSessionMode=zm;exports.XRState=Zs;exports.XRStateFlag=fn;exports.__Ignore=sR;exports.__internalNotifyObjectDestroyed=RU;exports.activeInHierarchyFieldName=Yc;exports.addAttributeChangeCallback=z2;exports.addCustomExtension=G7;exports.addFile=$z;exports.addFileFromUrl=eG;exports.addGltfLoadEventListener=Sce;exports.addNewComponent=gh;exports.addPatch=X_;exports.apply=j_;exports.applyHMRChanges=Lce;exports.beginListenDestroy=cU;exports.beginListenFileSpawn=tG;exports.beginListenInstantiate=lU;exports.binaryIdentifierCasts=V1;exports.build_scene_functions=yY;exports.builtinComponentKeyName=nu;exports.calculateProgress01=vT;exports.colorSerializer=j7;exports.componentSerializer=S0;exports.copyTexture=rF;exports.createGLTFLoader=aR;exports.createMotion=l3;exports.debugNet=js;exports.debugOwner=Tg;exports.deepClone=B_;exports.delay=_A;exports.deserializeObject=hb;exports.destroy=tl;exports.destroyComponentInstance=gU;exports.detectARSupport=jz;exports.detectVRSupport=Xz;exports.disposeObjectResources=Si;exports.download=dN;exports.download_file=dT;exports.editorGuidKeyName=Kg;exports.effectsOrder=TM;exports.eventListSerializer=J7;exports.findByGuid=RA;exports.findObjectOfType=AU;exports.findObjectsOfType=vU;exports.findResourceUsers=iT;exports.foreachComponent=Ru;exports.foreachComponentEnumerator=sT;exports.forward=Wj;exports.generateSeed=V_;exports.getComponent=sp;exports.getComponentInChildren=MA;exports.getComponentInParent=Lm;exports.getComponents=EA;exports.getComponentsInChildren=TA;exports.getComponentsInParent=W_;exports.getIp=Aj;exports.getIpAndLocation=vj;exports.getIpCloudflare=mj;exports.getLoader=oa;exports.getOrAddComponent=Q_;exports.getParam=re;exports.getPath=uj;exports.getPeerOptions=D9;exports.getPeerjsInstance=Y1;exports.getResourceUserCount=I6;exports.getUrlParams=bA;exports.getWorldDirection=Xj;exports.getWorldEuler=tF;exports.getWorldPosition=Ct;exports.getWorldQuaternion=zn;exports.getWorldRotation=O_;exports.getWorldScale=ls;exports.hasIndieLicense=AT;exports.hasProLicense=wf;exports.hash=uT;exports.instantiate=PA;exports.isActiveInHierarchy=BU;exports.isActiveSelf=rp;exports.isAnimationAction=sF;exports.isDebugMode=cj;exports.isDestroyed=nT;exports.isDevEnvironment=ci;exports.isDisposed=M6;exports.isHostedOnGlitch=V2;exports.isHotReloading=Bce;exports.isLocalNetwork=nr;exports.isMobileDevice=cl;exports.isMozillaXR=tb;exports.isQuest=pj;exports.isResourceTrackingEnabled=MU;exports.isSafari=Rc;exports.isUsingInstancing=Y_;exports.isiOS=Dm;exports.loadSync=cR;exports.logHierarchy=sb;exports.lookAtInverse=Gj;exports.makeId=hj;exports.makeIdFromRandomWords=L2;exports.markAsInstancedRendered=DU;exports.moveComponentInstance=Z1;exports.nameof=aj;exports.nameofFactory=eb;exports.objectSerializer=jN;exports.parseSync=RG;exports.prefix=MJ;exports.pushState=O2;exports.randomNumber=k2;exports.registerBinaryType=F_;exports.registerComponent=tx;exports.registerComponentExtension=wT;exports.registerCustomEffectType=No;exports.registerExtensions=WN;exports.registerHotReloadType=Dce;exports.registerLoader=fT;exports.registerPrefabProvider=uU;exports.registerType=u6;exports.relativePathPrefix=U2;exports.removeAttributeChangeCallback=G2;exports.removeComponent=J1;exports.removeCustomExtension=H7;exports.removeGltfLoadEventListener=Cce;exports.removePatch=S6;exports.resolveUrl=al;exports.sanitizeString=F2;exports.saveImage=ele;exports.screenshot=$ce;exports.sendDestroyed=aU;exports.serializable=x;exports.serializeObject=_U;exports.serializeable=lp;exports.setActive=Zg;exports.setAllowOverlayMessages=bj;exports.setDestroyed=kU;exports.setDevEnvironment=Lj;exports.setDisposable=tT;exports.setOrAddParamsToUrl=Bm;exports.setParam=lj;exports.setParamWithoutReload=D2;exports.setPeerOptions=O9;exports.setResourceTrackingEnabled=E6;exports.setState=N1;exports.setWorldEuler=iF;exports.setWorldPosition=Mn;exports.setWorldPositionXYZ=Gf;exports.setWorldQuaternion=Mr;exports.setWorldQuaternionXYZW=eF;exports.setWorldRotation=nF;exports.setWorldRotationXYZ=k_;exports.setWorldScale=AE;exports.showBalloonError=kj;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ls;exports.showDebugConsole=G1;exports.slerp=$2;exports.syncDestroy=H_;exports.syncField=KI;exports.syncInstantiate=K1;exports.textureToCanvas=Yj;exports.tryCastBinary=lF;exports.tryFindObject=Nf;exports.tryFindObjectByName=BG;exports.tryFindScript=Mce;exports.tryGetGuid=hF;exports.unregisterHotReloadType=Oce;exports.unwatchWrite=N2;exports.upload_file=uN;exports.validate=ys;exports.watchWrite=z1;
6639
+ `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(mg),this.classList.remove(Ag);const t=this.getAROverlayContainer();ns&&console.warn("onSetupAR:",t),t&&(t.classList.add(mg),t.classList.remove(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,MN))}onSetupVR(){this.classList.remove(mg),this.classList.remove(Ag),this.foreachHtmlElement(t=>this.setupElementsForMode(t,DG))}onSetupDesktop(){this.classList.remove(mg),this.classList.add(Ag);const t=this.getAROverlayContainer();t&&(t.classList.remove(mg),t.classList.add(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,OG))}setupElementsForMode(t,i,s=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of Tce)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ns&&console.log("using custom draco decoder path",t),CD(t));const i=this.getAttribute("dracoDecoderType");i&&(ns&&console.log("using custom draco decoder type",i),ED(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ns&&console.log("using custom ktx2 decoder path",s),MD(s))}}typeof window<"u"&&!window.customElements.get(Rk)&&window.customElements.define(Rk,lR);function Rce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const Pce=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:lR},Symbol.toStringTag,{value:"Module"})),V0=re("debughotreload");let aA=!1;const hm=new Map;function Bce(){return aA}function Dce(n){var i;if(aA)return;const t=n.constructor.name;hm.has(t)?(i=hm.get(t))==null||i.push(n):hm.set(t,[n])}function Oce(n){if(aA)return;const t=n.constructor.name,i=hm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let Pk=!1;function kce(){if(V0||Pk)return;Pk=!0;const n=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}n.apply(console,e)}}function Lce(n){V0&&console.log("[HMR] Apply changes",n,Object.keys(n)),kce();for(const e of Object.keys(n))try{aA=!0;const t=q.get(e);if(!t){V0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=hm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,u=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Bc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&rT(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(V0)console.error(t);else return!1}finally{aA=!1,Xc(Bo.Log,"Script changes applied (HMR)")}return!0}const Fce=Symbol("object"),Bk=new Xa(()=>new w,20);class kG{constructor(e,t,i,s,r){h(this,"_point");h(this,"_normal");h(this,"distance");h(this,"impulse");h(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return Bk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Bk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class LG{constructor(e,t,i){h(this,"contacts");h(this,"me");h(this,"_collider");h(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class FG{constructor(e,t){h(this,"object");h(this,"collider");this.object=e,this.collider=t}}let Ne;const cA=new Array(32).fill(void 0);cA.push(void 0,null,!0,!1);let Dk;cA.length;function Ok(){return Dk.byteLength,Dk}const Uce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}Uce.decode();let kk,Lk,um=32;function Fk(n){if(um==1)throw new Error("out of js stack");return cA[--um]=n,um}function Nce(){return kk.byteLength,kk}function zce(){return Lk.byteLength,Lk}let Fr=0;function Xh(n,e){const t=e(4*n.length);return Nce().set(n,t/4),Fr=n.length,t}function $y(n,e){const t=e(4*n.length);return zce().set(n,t/4),Fr=n.length,t}class kb{static __wrap(e){const t=Object.create(kb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return kb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Oa{static __wrap(e){const t=Object.create(Oa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Oa.__wrap(i)}static prismatic(e,t,i,s,r,o){vt(e,ft),vt(t,ft),vt(i,ft);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Oa.__wrap(a)}static fixed(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,qn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Oa.__wrap(r)}static revolute(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Oa.__wrap(s)}}class hR{static __wrap(e){const t=Object.create(hR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=Ok()[i/4+0],t=Ok()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class qn{static __wrap(e){const t=Object.create(qn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return qn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return qn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Xh(i,Ne.__wbindgen_malloc),o=Fr;vt(s,ft);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){vt(e,ft),vt(t,ft),vt(i,ft);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Xh(e,Ne.__wbindgen_malloc),i=Fr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Xh(e,Ne.__wbindgen_malloc),r=Fr,o=$y(t,Ne.__wbindgen_malloc),a=Fr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,Gt),vt(r,ft),vt(o,qn),vt(a,ft);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:fR.__wrap(l)}intersectsShape(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,i){return vt(e,ft),vt(t,qn),vt(i,ft),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return hR.__wrap(r)}intersectsRay(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return ft.__wrap(e)}}class fR{static __wrap(e){const t=Object.create(fR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return ft.__wrap(e)}}class ft{static __wrap(e){const t=Object.create(ft.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return ft.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return ft.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return ft.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return ft.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return ft.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return ft.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return ft.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return ft.__wrap(e)}}class Gce{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Re{static new(e,t,i){return new Gce(e,t,i)}static intoRaw(e){return new ft(e.x,e.y,e.z)}static zeros(){return Re.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Re.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Uk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Di{static identity(){return new Uk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Uk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qn(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var dm,Ca,Nk,Eo,OM,Zt,Lb,uf,kM,LM,zk,Gk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(dm||(dm={}));class Hce{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Re.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Re.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Re.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Re.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,s,r){let o=Re.intoRaw(t),a=Re.intoRaw(i),c=Di.intoRaw(s);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(Ca||(Ca={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(Nk||(Nk={}));class df{constructor(){}static fixed(e,t,i,s){let r=new df;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=Ca.Fixed,r}static spherical(e,t){let i=new df;return i.anchor1=e,i.anchor2=t,i.jointType=Ca.Spherical,i}static prismatic(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Prismatic,s}static revolute(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Revolute,s}intoRaw(){let e,t,i=Re.intoRaw(this.anchor1),s=Re.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case Ca.Fixed:let c=Di.intoRaw(this.frame1),l=Di.intoRaw(this.frame2);t=Oa.fixed(i,c,s,l),c.free(),l.free();break;case Ca.Prismatic:e=Re.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Oa.prismatic(i,s,e,r,o,a),e.free();break;case Ca.Spherical:t=Oa.spherical(i,s);break;case Ca.Revolute:e=Re.intoRaw(this.axis),t=Oa.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(Eo||(Eo={}));class lA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new lA(e.distance(),Re.fromRaw(e.point1()),Re.fromRaw(e.point2()),Re.fromRaw(e.normal1()),Re.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(OM||(OM={}));class ow{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new ow(Re.fromRaw(e.point()),e.isInside());return e.free(),t}}class Vce{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class aw{constructor(e,t,i,s){this.featureType=OM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new aw(e.toi(),Re.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class _v{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new _v(t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class pR extends _v{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new pR(e.get(t.colliderHandle()),t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class xs{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case Zt.Ball:return new gR(e.coRadius(t));case Zt.Cuboid:return s=e.coHalfExtents(t),new UG(s.x,s.y,s.z);case Zt.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new NG(s.x,s.y,s.z,r);case Zt.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new zG(c,l);case Zt.Segment:return o=e.coVertices(t),new GG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new QG(o,a);case Zt.Triangle:return o=e.coVertices(t),new HG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new VG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]),r);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new WG(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new jG(f,p,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new FM(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new UM(o,a,r);case Zt.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new XG(c,l);case Zt.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new qG(c,l,r);case Zt.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new YG(c,l);case Zt.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new KG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Re.intoRaw(e),u=Di.intoRaw(t),d=Re.intoRaw(i),f=Re.intoRaw(r),p=Di.intoRaw(o),g=Re.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=_v.fromRaw(null,A.castShape(l,u,d,v,f,p,g,c));return l.free(),u.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Re.intoRaw(e),a=Di.intoRaw(t),c=Re.intoRaw(s),l=Di.intoRaw(r),u=this.intoRaw(),d=i.intoRaw(),f=u.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),u.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Di.intoRaw(t),l=Re.intoRaw(s),u=Di.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=lA.fromRaw(d.contactShape(a,c,f,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Re.intoRaw(e),r=Di.intoRaw(t),o=Re.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Re.intoRaw(e),o=Di.intoRaw(t),a=Re.intoRaw(i),c=this.intoRaw(),l=ow.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=Re.intoRaw(e.origin),c=Re.intoRaw(e.dir),l=this.intoRaw(),u=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),u}castRay(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),u.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=aw.fromRaw(u.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),u.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class gR extends xs{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class UG extends xs{constructor(e,t,i){super(),this.type=Zt.Cuboid,this.halfExtents=Re.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class NG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundCuboid,this.halfExtents=Re.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class zG extends xs{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class GG extends xs{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class HG extends xs{constructor(e,t,i){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class VG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class QG extends xs{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class WG extends xs{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class FM extends xs{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class UM extends xs{constructor(e,t,i){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class jG extends xs{constructor(e,t,i,s){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Re.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class XG extends xs{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class qG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class YG extends xs{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class KG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Lb||(Lb={}));class Qce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=xs.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Re.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,s){let r=Re.intoRaw(t),o=Re.intoRaw(i),a=Di.intoRaw(s);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Re.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Re.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Re.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Re.intoRaw(e),s=ow.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Re.intoRaw(e.origin),s=Re.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Re.intoRaw(i),l=Di.intoRaw(s),u=Re.intoRaw(r),d=t.intoRaw(),f=_v.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f}castCollider(e,t,i,s){let r=Re.intoRaw(e),o=Re.intoRaw(i),a=pR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Re.intoRaw(t),r=Di.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=e.intoRaw(),c=lA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return lA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=aw.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(uf||(uf={}));class Hi{constructor(e){this.shape=e,this.massPropsMode=uf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=Re.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Eo.Average,this.restitutionCombineRule=Eo.Average,this.activeCollisionTypes=Lb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Re.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Re.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new gR(e);return new Hi(t)}static capsule(e,t){const i=new zG(e,t);return new Hi(i)}static segment(e,t){const i=new GG(e,t);return new Hi(i)}static triangle(e,t,i){const s=new HG(e,t,i);return new Hi(s)}static roundTriangle(e,t,i,s){const r=new VG(e,t,i,s);return new Hi(r)}static polyline(e,t){const i=new QG(e,t);return new Hi(i)}static trimesh(e,t){const i=new WG(e,t);return new Hi(i)}static cuboid(e,t,i){const s=new UG(e,t,i);return new Hi(s)}static roundCuboid(e,t,i,s){const r=new NG(e,t,i,s);return new Hi(r)}static heightfield(e,t,i,s){const r=new jG(e,t,i,s);return new Hi(r)}static cylinder(e,t){const i=new XG(e,t);return new Hi(i)}static roundCylinder(e,t,i){const s=new qG(e,t,i);return new Hi(s)}static cone(e,t){const i=new YG(e,t);return new Hi(i)}static roundCone(e,t,i){const s=new KG(e,t,i);return new Hi(s)}static convexHull(e){const t=new FM(e,null);return new Hi(t)}static convexMesh(e,t){const i=new FM(e,t);return new Hi(i)}static roundConvexHull(e,t){const i=new UM(e,null,t);return new Hi(i)}static roundConvexMesh(e,t,i){const s=new UM(e,t,i);return new Hi(s)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=uf.Density,this.density=e,this}setMass(e){return this.massPropsMode=uf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=uf.MassProps,this.mass=e,Re.copy(this.centerOfMass,t),Re.copy(this.principalAngularInertia,i),Di.copy(this.angularInertiaLocalFrame,s),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(kM||(kM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LM||(LM={}));class Wce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Re.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Re.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class jce{constructor(e,t){this.raw=t||new kb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Wce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(zk||(zk={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Gk||(Gk={}));for(var Hle={byteLength:function(n){var e=Hk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=Hk(n),s=i[0],r=i[1],o=new Xce(function(l,u,d){return 3*(u+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=bo[n.charCodeAt(t)]<<18|bo[n.charCodeAt(t+1)]<<12|bo[n.charCodeAt(t+2)]<<6|bo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=bo[n.charCodeAt(t)]<<2|bo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=bo[n.charCodeAt(t)]<<10|bo[n.charCodeAt(t+1)]<<4|bo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Yce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ra[e>>2]+Ra[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ra[e>>10]+Ra[e>>4&63]+Ra[e<<2&63]+"=")),s.join("")}},Ra=[],bo=[],Xce=typeof Uint8Array<"u"?Uint8Array:Array,vC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hd=0,qce=vC.length;Hd<qce;++Hd)Ra[Hd]=vC[Hd],bo[vC.charCodeAt(Hd)]=Hd;function Hk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Yce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ra[(s=i)>>18&63]+Ra[s>>12&63]+Ra[s>>6&63]+Ra[63&s]);return r.join("")}bo["-".charCodeAt(0)]=62,bo["_".charCodeAt(0)]=63;const Qs=re("debugphysics"),yC=re("debugcolliderplacement"),bC=re("debugcollisions"),Kce=re("showcolliders"),Ur=Symbol("needle component"),Or=Symbol("physics body"),Jce=Symbol("rigidbody");let Vd;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Qs&&console.log("Use Rapier",!1,globalThis.false);const ym=class{constructor(){h(this,"debugRenderColliders",!1);h(this,"context");h(this,"_initializePromise");h(this,"_isInitialized",!1);h(this,"rapierRay",new Vce({x:0,y:0,z:0},{x:0,y:0,z:1}));h(this,"raycastVectorsBuffer",new Xa(()=>new w,10));h(this,"rapierSphere",null);h(this,"rapierColliderArray",[]);h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});h(this,"rapierForwardVector",{x:0,y:0,z:1});h(this,"enabled",!1);h(this,"_tempPosition",new w);h(this,"_tempQuaternion",new we);h(this,"_tempScale",new w);h(this,"_tempMatrix",new Me);h(this,"_isUpdatingPhysicsWorld",!1);h(this,"_world");h(this,"_hasCreatedWorld",!1);h(this,"eventQueue");h(this,"collisionHandler");h(this,"objects",[]);h(this,"bodies",[]);h(this,"_meshCache",new Map);h(this,"_gravity",{x:0,y:-9.81,z:0});h(this,"lines")}removeBody(e){var i,s,r;if(!e)return;this.validate();const t=e[Or];if(e[Or]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof Qce){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[Ur]||(s=this.world)==null||s.removeRigidBody(l))}else a instanceof Hce&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ci()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=e,r=s[Or];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[Or];i&&this.internalUpdateColliderProperties(t,i)}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Qs&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:CR&&CR.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Qs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Qs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[Ur]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,u=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return u.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:u,normal:d,collider:o.collider[Ur]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const u=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(u)t=u;else return null}if(t.z===void 0){if(!s)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const u=this.raycastVectorsBuffer.get();u.x=t.x,u.y=t.y,u.z=0,(u.x>1||u.y>1||u.y<-1||u.x<-1)&&(Qs&&console.warn("Converting screenspace to raycast space",u),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(u)),u.unproject(s),t=u}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const u=Ct(s);o.sub(u)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new gR(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[Ur],r=new FG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},kM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[Ur].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const s=e.gameObject,r=ls(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Hi.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const i=Hi.ball(.5);this.createCollider(e,i,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const r=e.gameObject,o=ls(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Hi.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,u,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Qs&&console.warn("Missing mesh geometry",t.name);return}(u=(l=r.index)==null?void 0:l.array)!=null&&u.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=qY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Qs&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Hi.convexMesh(o):Hi.trimesh(o,a);c&&this.createCollider(e,c)}getBody(e){return e?e[Or]:null}getComponent(e){return e?e[Ur]:null}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),ls(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case wa.Average:t.setRestitutionCombineRule(Eo.Average);break;case wa.Maximum:t.setRestitutionCombineRule(Eo.Max);break;case wa.Minimum:t.setRestitutionCombineRule(Eo.Min);break;case wa.Multiply:t.setRestitutionCombineRule(Eo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case wa.Average:t.setFrictionCombineRule(Eo.Average);break;case wa.Maximum:t.setFrictionCombineRule(Eo.Max);break;case wa.Minimum:t.setFrictionCombineRule(Eo.Min);break;case wa.Multiply:t.setFrictionCombineRule(Eo.Multiply);break}}o&&t.setDensity(0);const c=this.world.createCollider(t,r);return c[Ur]=e,e[Or]=c,c.setActiveEvents(LM.COLLISION_EVENTS),c.setActiveCollisionTypes(Lb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[Or],s=r.autoMass===!1,!i){const o=r.isKinematic&&!yC;Qs&&console.log("Create rigidbody",o);const a=o?Vd.RigidBodyDesc.kinematicPositionBased():Vd.RigidBodyDesc.dynamic(),c=Ct(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(zn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[Ur]=r,r[Or]=i,this.internalUpdateRigidbodyProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Vd.RigidBodyDesc.kinematicPositionBased(),o=Ct(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(zn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[Ur]=null}return e[Jce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[Or]}internalUpdateColliderProperties(e,t){const i=t.shape;switch(i.type){case Zt.Ball:{const o=i,a=e,c=e.gameObject,l=ls(c,this._tempPosition),u=Math.abs(a.radius*l.x),d=o.radius!==u;o.radius=u,d&&t.setShape(o);break}case Zt.Cuboid:const s=i,r=e;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,t.setShape(s);break}}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==lx.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(0);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Vd.RigidBodyType.KinematicPositionBased):t.setBodyType(Vd.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new jce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Qs||yC||Kce||this.debugRenderColliders===!0){if(!this.lines){const o=new vn({color:2258688,fog:!1}),a=new mt;this.lines=new eo(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new $e(r.vertices,3)),this.lines.geometry.setAttribute("color",new $e(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Zce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!yC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion);r.x-=c.x,r.y-=c.y,r.z-=c.z}Gf(t.gameObject,r.x,r.y,r.z),eF(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=Ct(e,this._tempPosition),o=zn(e,this._tempQuaternion);switch(t.bodyType()){case dm.Fixed:case dm.KinematicPositionBased:case dm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=ym._matricesBuffer,s.length=0),e===t){const r=ls(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[Or],s=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=df.fixed(ym.centerConnectionPos,ym.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Qs&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[Or],o=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Vd.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Qs&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let eu=ym;h(eu,"_didLoadPhysicsEngine",!1),h(eu,"_matricesBuffer",[]),h(eu,"centerConnectionPos",{x:0,y:0,z:0}),h(eu,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zce{constructor(e,t){h(this,"world");h(this,"eventQueue");h(this,"activeCollisions",[]);h(this,"activeCollisionsStay",[]);h(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[Ur],a=r[Ur];bC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Ru(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,s,(a,c)=>{Ru(o,l=>{var d;if(l.destroyed)return;const u=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(u||bC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new kG(A,m,p,v,b);f.push(y),bC&&zc.DrawDirection(A,p,16711680,3,!0)}}r=new LG(o,i,f)}if(u){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function $ce(n,e,t,i="image/webp",s){if(!n&&(n=Oi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,n.renderer.domElement.style.width=e+"px",n.renderer.domElement.style.height=t+"px";try{const c=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),c.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let vg=null;function ele(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}vg||(vg=document.createElement("a")),vg.href=n,vg.download=e,vg.click()}}const Fb=re("debugmissingcamera");Oi.registerCallback(Ks.MissingCamera,n=>{var r,o;Fb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Li;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",n.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=1:i.clearFlags=2,i.backgroundColor=new bi(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const s=gh(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,JG(n.context,s),s});Oi.registerCallback(Ks.ContextCreated,n=>{if(!n.context.mainCamera){Fb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Fte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Fb&&console.log("Will not auto-fit because a camera controller exists");return}JG(n.context)}});function JG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Fb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Q_(t,Ji);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}_j();const mR={Context:Ft,glTF:{loadFromURL:cR}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=mR;function ZG(n){for(const e in n)mR[e]=n[e]}ZG(wY);ZG(pce);for(const n of Object.getOwnPropertyNames(ne))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:mR[n]=ne[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=oj;var AR={},$G={};Object.defineProperty($G,"__esModule",{value:!0});var cw={};Object.defineProperty(cw,"__esModule",{value:!0});cw.ConstantBackoff=void 0;var tle=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();cw.ConstantBackoff=tle;var lw={};Object.defineProperty(lw,"__esModule",{value:!0});lw.ExponentialBackoff=void 0;var ile=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();lw.ExponentialBackoff=ile;var hw={};Object.defineProperty(hw,"__esModule",{value:!0});hw.LinearBackoff=void 0;var nle=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();hw.LinearBackoff=nle;var eH={};Object.defineProperty(eH,"__esModule",{value:!0});var uw={};Object.defineProperty(uw,"__esModule",{value:!0});uw.LRUBuffer=void 0;var sle=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();uw.LRUBuffer=sle;var dw={};Object.defineProperty(dw,"__esModule",{value:!0});dw.TimeBuffer=void 0;var rle=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();dw.TimeBuffer=rle;var vR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(vR);var fw={};Object.defineProperty(fw,"__esModule",{value:!0});fw.WebsocketBuilder=void 0;var Qd=vR,ole=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Qd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();fw.WebsocketBuilder=ole;(function(n){var e=py&&py.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=py&&py.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t($G,n),t(cw,n),t(lw,n),t(hw,n),t(eH,n),t(uw,n),t(dw,n),t(vR,n),t(fw,n)})(AR);const ale=xA(AR),cle=nH({__proto__:null,default:ale},[AR]),Ao={node:"node",material:"material",camera:"camera",light:"light"},qh="KHR_animation_pointer",lle={CUBICSPLINE:void 0,LINEAR:Wa,STEP:nh},Vk=Nt.findNode;let Qk=!1;class hle{constructor(e){this.parser=e,this.name=qh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Qk||(Qk=!0,Nt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=Vk(e,i[2]);return r||console.warn(qh+": Property binding not found",t,e,e.name,i),r}return s}return Vk(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return i?this.parser.getDependency("node",i):null}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[qh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=Ao.node,o;if(i){const c=t.extensions[qh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Ao.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Ao.light:l.startsWith("/cameras/")&&(r=Ao.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Ao.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case Ao.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case Ao.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case Ao.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(l=u.resolvePath(l)),t.extensions[qh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Ao.node?a=this.parser.getDependency("node",o):r===Ao.material?a=this.parser.getDependency("material",o):r===Ao.light?a=this.parser.getDependency("light",o):r===Ao.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[qh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[qh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof ku&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=sh;break;case 2:case 3:g=el;break;case 4:a.endsWith(".quaternion")?g=ja:g=w_;break}const A=s.interpolation!==void 0?lle[s.interpolation]:Wa;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],u=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);if(y||(y=t.loadAnimationTargetFromChannel(g)),y==null){console.warn("Failed to load animation target",g,y);continue}a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let D=0;D<T.length;D++)b.push(T[D])}return new tr(o,void 0,b)})}}const ule=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hle},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=Fce;exports.ActionBuilder=fi;exports.ActionCollection=IT;exports.ActionModel=Vr;exports.Addressables=pN;exports.AlignmentConstraint=OA;exports.AmbientMode=xf;exports.Animation=$r;exports.AnimationCurve=zu;exports.AnimationExtension=rx;exports.AnimationTrackHandler=_x;exports.Animator=ks;exports.AnimatorConditionMode=Hl;exports.AnimatorController=oh;exports.AnimatorControllerParameterType=RT;exports.AnimatorStateInfo=T0;exports.Antialiasing=jA;exports.Application=vN;exports.ApplicationEvents=gb;exports.AssetDatabase=CU;exports.AssetReference=Tn;exports.AttachedObject=Io;exports.AttachedObjectEvents=Mb;exports.AudioExtension=wx;exports.AudioListener=xu;exports.AudioSource=yn;exports.AudioTrackHandler=wu;exports.AvatarBlink_Simple=Hu;exports.AvatarEyeLook_Rotation=yp;exports.AvatarLoader=cx;exports.AvatarMarker=Jn;exports.AvatarModel=ax;exports.Avatar_Brain_LookAt=Vm;exports.Avatar_MouthShapes=XA;exports.Avatar_MustacheShake=hI;exports.Avatar_POI=ir;exports.Axes=lf;exports.AxesHelper=bp;exports.BaseUIComponent=aa;exports.BasicIKConstraint=fI;exports.BehaviorExtension=Cx;exports.BehaviorModel=ds;exports.Behaviour=Ie;exports.Bloom=Vu;exports.BoxCollider=YA;exports.BoxGizmo=Qu;exports.BoxHelperComponent=To;exports.Button=fl;exports.CallInfo=Wf;exports.Camera=Li;exports.Canvas=ps;exports.CanvasGroup=hh;exports.CapsuleCollider=lh;exports.ChangeMaterialOnClick=wp;exports.ChangeTransformOnClick=Xu;exports.CharacterController=qu;exports.CharacterControllerInput=gl;exports.ChromaticAberration=tv;exports.CircularBuffer=Xa;exports.ClearFlags=Ib;exports.ClipExtrapolation=Sa;exports.Collider=Za;exports.Collision=LG;exports.CollisionDetectionMode=lx;exports.ColorAdjustments=Sh;exports.ColorBySpeedModule=Yu;exports.ColorOverLifetimeModule=iv;exports.Component=Ah;exports.ComponentEvents=SA;exports.ComponentLifecycleEvents=CA;exports.ConnectionEvents=tU;exports.ContactPoint=kG;exports.Context=Ft;exports.ContextArgs=bY;exports.ContextEvent=Ks;exports.ContextRegistry=Oi;exports.ControlTrackHandler=xx;exports.ControllerEvents=Cc;exports.ControllerType=Ef;exports.CustomBranding=Th;exports.CustomShader=kr;exports.DefaultReflectionMode=pb;exports.Deletable=MI;exports.DeleteBox=Bx;exports.DepthOfField=pa;exports.DeviceFlag=Dx;exports.DocumentExtension=TI;exports.DragControls=Ip;exports.DropListener=sv;exports.Duplicatable=Zu;exports.EXTENSION_NAME=w0;exports.EmissionModule=ec;exports.EmphasizeOnClick=Cp;exports.EngineLoadingView=im;exports.EventList=us;exports.EventListEvent=ix;exports.EventSystem=$s;exports.EventTrigger=kx;exports.FieldWithDefault=ST;exports.FileSpawnModel=Zz;exports.File_Event=Jz;exports.FixedJoint=kI;exports.FlyControls=LI;exports.Fog=Rp;exports.FrameEvent=Tr;exports.GENERATOR=z_;exports.GameObject=ne;exports.Gizmos=zc;exports.GltfExport=ov;exports.GltfExportBox=NI;exports.GltfLoadEvent=Eu;exports.GltfLoadEventType=TG;exports.Gradient=Ch;exports.Graphic=Wu;exports.GraphicRaycaster=cI;exports.Graphics=Zo;exports.GridHelper=Pp;exports.GridLayoutGroup=_I;exports.GroundProjectedEnv=$u;exports.GroupActionModel=jl;exports.HideFlags=PU;exports.HideOnStart=wI;exports.HingeJoint=rv;exports.HorizontalLayoutGroup=bI;exports.HostData=J9;exports.Image=xp;exports.ImageReference=_f;exports.ImageReferenceSerializer=gN;exports.InheritVelocityModule=Mh;exports.Input=Z2;exports.InputEvents=Sn;exports.InputField=ed;exports.InstancingUtil=Sr;exports.InstantiateEvent=rU;exports.InstantiateIdProvider=Bs;exports.InstantiateOptions=qa;exports.Interactable=up;exports.JoinedRoomResponse=F9;exports.KeyEventArgs=Fj;exports.LODGroup=cv;exports.LODModel=td;exports.LeftRoomResponse=U9;exports.Light=Rr;exports.LightData=AN;exports.LimitVelocityOverLifetimeModule=Bn;exports.LoadingElementOptions=OY;exports.LogStats=GI;exports.LogType=Bo;exports.LookAt=id;exports.LookAtConstraint=LA;exports.MainModule=bs;exports.MarkerType=lI;exports.MaskableGraphic=ZA;exports.Mathf=tt;exports.MeshCollider=KA;exports.MeshRenderer=nx;exports.MinMaxCurve=ht;exports.MinMaxGradient=Ir;exports.NEEDLE_progressive=Hr;exports.NEKeyboardEvent=h0;exports.NEPointerEvent=wc;exports.NeedleEngine=Oi;exports.NeedleEngineHTMLElement=lR;exports.NeedleGltfLoader=oR;exports.NeedlePatchesKey=m0;exports.NestedGltf=Nx;exports.NetworkConnection=nU;exports.Networking=Ju;exports.NoiseModule=vi;exports.ObjectRaycaster=rl;exports.ObjectUtils=yG;exports.OffsetConstraint=nd;exports.OpenURL=Bp;exports.OrbitControls=Ji;exports.Outline=_p;exports.OwnershipEvent=iU;exports.OwnershipModel=N_;exports.Padding=_h;exports.ParticleBurst=eA;exports.ParticleSubEmitter=Xx;exports.ParticleSystem=In;exports.ParticleSystemRenderer=Go;exports.PeerNetworking=eU;exports.Physics=aF;exports.PhysicsMaterialCombine=wa;exports.PixelationEffect=uv;exports.PlayAnimationOnClick=wh;exports.PlayAudioOnClick=Ep;exports.PlayableDirector=Zc;exports.PlayerColor=Bu;exports.PlayerState=Cu;exports.PlayerStateEvent=CG;exports.PlayerSync=rw;exports.PlayerView=CN;exports.PlayerViewManager=EN;exports.PointerEventData=Gc;exports.PointerType=zf;exports.PostProcessingEffect=Us;exports.PostProcessingHandler=qx;exports.PreliminaryAction=Mp;exports.PreliminaryTrigger=$A;exports.PrimitiveType=ZI;exports.ProgressiveLoadingInfo=QN;exports.PromiseAllWithErrors=D_;exports.PromiseErrorResult=H2;exports.RGBAColor=bi;exports.RapierPhysics=eu;exports.RawImage=Mx;exports.RaycastOptions=ko;exports.Raycaster=mp;exports.Rect=AI;exports.RectTransform=rr;exports.ReflectionProbe=hp;exports.RegisteredAnimationInfo=sx;exports.RemoteSkybox=ol;exports.RenderTexture=Jl;exports.RenderTextureSerializer=XN;exports.Renderer=Qi;exports.RendererData=mN;exports.RendererLightmap=Hm;exports.Rigidbody=Ii;exports.RigidbodyConstraints=ln;exports.RoomEvents=on;exports.RotationBySpeedModule=so;exports.RotationOverLifetimeModule=zo;exports.SceneLightSettings=vb;exports.SceneSwitcher=ur;exports.ScreenCapture=fv;exports.ScreenSpaceAmbientOcclusion=Al;exports.ScreenSpaceAmbientOcclusionN8=ma;exports.SendQueue=Ar;exports.SetActiveOnClick=Sp;exports.ShadowCatcher=gv;exports.ShapeModule=bn;exports.SignalAsset=VA;exports.SignalReceiver=vp;exports.SignalReceiverEvent=Ap;exports.SignalTrackHandler=Zm;exports.Size=mI;exports.SizeBySpeedModule=lr;exports.SizeOverLifetimeModule=Eh;exports.SkinnedMeshRenderer=CT;exports.SmoothFollow=Ih;exports.SpatialHtml=$I;exports.SpatialTrigger=Av;exports.SpatialTriggerReceiver=Qa;exports.SpectatorCamera=Jx;exports.SphereCollider=qA;exports.SphereIntersection=oF;exports.SphereOverlapResult=FG;exports.Sprite=vl;exports.SpriteData=Lp;exports.SpriteRenderer=ic;exports.SpriteSheet=vv;exports.StateMachineBehaviour=NK;exports.SubEmitterSystem=oA;exports.SyncedCamera=Zx;exports.SyncedRoom=Rh;exports.SyncedTransform=ah;exports.TapGestureTrigger=SI;exports.TeleportTarget=vx;exports.TestRunner=eR;exports.TestSimulateUserData=tR;exports.Text=hr;exports.TextBuilder=Rx;exports.TextExtension=nv;exports.TextureSheetAnimationModule=_s;exports.TiltShiftEffect=nc;exports.Time=cF;exports.ToneMapping=bv;exports.TrackHandler=QA;exports.TrackType=Lr;exports.TrailModule=ji;exports.TransformData=Zl;exports.TransformGizmo=rd;exports.TriggerBuilder=Cr;exports.TriggerModel=Kc;exports.TypeStore=q;exports.UIRaycastUtils=Yf;exports.UIRootComponent=HA;exports.USDObject=_r;exports.USDZExporter=oo;exports.USDZText=Xl;exports.USDZUIExtension=Px;exports.Upload_Result=zE;exports.UriSerializer=qN;exports.UsageMarker=dp;exports.UserJoinedOrLeftRoomModel=N9;exports.VERSION=Nc;exports.VRUserState=ta;exports.VariantAction=TT;exports.VelocityOverLifetimeModule=Zi;exports.VerticalLayoutGroup=yI;exports.VideoPlayer=Ns;exports.ViewDevice=Va;exports.Vignette=od;exports.VisibilityAction=ev;exports.Voip=dl;exports.Volume=ew;exports.VolumeParameter=Rt;exports.VolumeProfile=WA;exports.WaitForFrames=woe;exports.WaitForSeconds=pG;exports.Watch=jc;exports.WebAR=Su;exports.WebARCameraBackground=tw;exports.WebARSessionRoot=ca;exports.WebXR=It;exports.WebXRAvatar=Ua;exports.WebXRController=sn;exports.WebXREvent=Mi;exports.WebXRImageTracking=iw;exports.WebXRImageTrackingModel=yl;exports.WebXRPlaneTracking=ad;exports.WebXRSync=tA;exports.WebXRTrackedImage=Oc;exports.XRFlag=jr;exports.XRGrabModel=sw;exports.XRGrabRendering=nR;exports.XRRig=Ix;exports.XRSessionMode=zm;exports.XRState=Zs;exports.XRStateFlag=fn;exports.__Ignore=sR;exports.__internalNotifyObjectDestroyed=RU;exports.activeInHierarchyFieldName=Yc;exports.addAttributeChangeCallback=z2;exports.addCustomExtension=G7;exports.addFile=$z;exports.addFileFromUrl=eG;exports.addGltfLoadEventListener=Sce;exports.addNewComponent=gh;exports.addPatch=X_;exports.apply=j_;exports.applyHMRChanges=Lce;exports.beginListenDestroy=cU;exports.beginListenFileSpawn=tG;exports.beginListenInstantiate=lU;exports.binaryIdentifierCasts=V1;exports.build_scene_functions=yY;exports.builtinComponentKeyName=nu;exports.calculateProgress01=vT;exports.colorSerializer=j7;exports.componentSerializer=S0;exports.copyTexture=rF;exports.createGLTFLoader=aR;exports.createMotion=l3;exports.debugNet=js;exports.debugOwner=Tg;exports.deepClone=B_;exports.delay=_A;exports.deserializeObject=hb;exports.destroy=tl;exports.destroyComponentInstance=gU;exports.detectARSupport=jz;exports.detectVRSupport=Xz;exports.disposeObjectResources=Si;exports.download=dN;exports.download_file=dT;exports.editorGuidKeyName=Kg;exports.effectsOrder=TM;exports.eventListSerializer=J7;exports.findByGuid=RA;exports.findObjectOfType=AU;exports.findObjectsOfType=vU;exports.findResourceUsers=iT;exports.foreachComponent=Ru;exports.foreachComponentEnumerator=sT;exports.forward=Wj;exports.generateSeed=V_;exports.getComponent=sp;exports.getComponentInChildren=MA;exports.getComponentInParent=Lm;exports.getComponents=EA;exports.getComponentsInChildren=TA;exports.getComponentsInParent=W_;exports.getIp=Aj;exports.getIpAndLocation=vj;exports.getIpCloudflare=mj;exports.getLoader=oa;exports.getOrAddComponent=Q_;exports.getParam=re;exports.getPath=uj;exports.getPeerOptions=D9;exports.getPeerjsInstance=Y1;exports.getResourceUserCount=I6;exports.getUrlParams=bA;exports.getWorldDirection=Xj;exports.getWorldEuler=tF;exports.getWorldPosition=Ct;exports.getWorldQuaternion=zn;exports.getWorldRotation=O_;exports.getWorldScale=ls;exports.hasIndieLicense=AT;exports.hasProLicense=wf;exports.hash=uT;exports.instantiate=PA;exports.isActiveInHierarchy=BU;exports.isActiveSelf=rp;exports.isAnimationAction=sF;exports.isDebugMode=cj;exports.isDestroyed=nT;exports.isDevEnvironment=ci;exports.isDisposed=M6;exports.isHostedOnGlitch=V2;exports.isHotReloading=Bce;exports.isLocalNetwork=nr;exports.isMobileDevice=cl;exports.isMozillaXR=tb;exports.isQuest=pj;exports.isResourceTrackingEnabled=MU;exports.isSafari=Rc;exports.isUsingInstancing=Y_;exports.isiOS=Dm;exports.loadSync=cR;exports.logHierarchy=sb;exports.lookAtInverse=Gj;exports.makeId=hj;exports.makeIdFromRandomWords=L2;exports.markAsInstancedRendered=DU;exports.moveComponentInstance=Z1;exports.nameof=aj;exports.nameofFactory=eb;exports.objectSerializer=jN;exports.parseSync=RG;exports.prefix=MJ;exports.pushState=O2;exports.randomNumber=k2;exports.registerBinaryType=F_;exports.registerComponent=tx;exports.registerComponentExtension=wT;exports.registerCustomEffectType=No;exports.registerExtensions=WN;exports.registerHotReloadType=Dce;exports.registerLoader=fT;exports.registerPrefabProvider=uU;exports.registerType=u6;exports.relativePathPrefix=U2;exports.removeAttributeChangeCallback=G2;exports.removeComponent=J1;exports.removeCustomExtension=H7;exports.removeGltfLoadEventListener=Cce;exports.removePatch=S6;exports.resolveUrl=al;exports.sanitizeString=F2;exports.saveImage=ele;exports.screenshot=$ce;exports.sendDestroyed=aU;exports.serializable=x;exports.serializeObject=_U;exports.serializeable=lp;exports.setActive=Zg;exports.setAllowOverlayMessages=bj;exports.setDestroyed=kU;exports.setDevEnvironment=Lj;exports.setDisposable=tT;exports.setOrAddParamsToUrl=Bm;exports.setParam=lj;exports.setParamWithoutReload=D2;exports.setPeerOptions=O9;exports.setResourceTrackingEnabled=E6;exports.setState=N1;exports.setWorldEuler=iF;exports.setWorldPosition=Mn;exports.setWorldPositionXYZ=Gf;exports.setWorldQuaternion=Mr;exports.setWorldQuaternionXYZW=eF;exports.setWorldRotation=nF;exports.setWorldRotationXYZ=k_;exports.setWorldScale=AE;exports.showBalloonError=kj;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ls;exports.showDebugConsole=G1;exports.slerp=$2;exports.syncDestroy=H_;exports.syncField=KI;exports.syncInstantiate=K1;exports.textureToCanvas=Yj;exports.tryCastBinary=lF;exports.tryFindObject=Nf;exports.tryFindObjectByName=BG;exports.tryFindScript=Mce;exports.tryGetGuid=hF;exports.unregisterHotReloadType=Oce;exports.unwatchWrite=N2;exports.upload_file=uN;exports.validate=ys;exports.watchWrite=z1;