@needle-tools/engine 3.21.0-alpha → 3.21.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.21.1-alpha] - 2023-10-20
8
+ - Add: Multitouch support on `input` events, our EventSystem implementation now handles multitouch cases and is using the browser events directly and immediately (before events via `window` where deferred and hanlded during the engine update loop)
9
+
7
10
  ## [3.21.0-alpha] - 2023-10-19
8
11
  - Add: support for translate, rotate and scale of AR scene on android devices (needs `WebXRSessionRoot.arTouchTransform` set to true right now)
9
12
  - Add: `SphereCollider.radius` and `BoxCollider.size` updates at runtime are now automatically propagated to the physics engine updating the physics shapes. Additionally the object scale for SphereCollider objects is watched and automatically applied on change
@@ -90218,7 +90218,7 @@ class NnA {
90218
90218
  /* DUPLICATE of functionality in GLTFLoader */
90219
90219
  loadAnimationTargetFromChannel(A) {
90220
90220
  const e = A.target, t = e.node !== void 0 ? e.node : e.id;
90221
- return this.parser.getDependency("node", t);
90221
+ return t ? this.parser.getDependency("node", t) : null;
90222
90222
  }
90223
90223
  loadAnimationTargetFromChannelWithAnimationPointer(A) {
90224
90224
  this._havePatchedPropertyBindings || this._patchPropertyBindingFindNode();
@@ -90469,7 +90469,11 @@ class NnA {
90469
90469
  for (let Q = 0, E = I.channels.length; Q < E; Q++) {
90470
90470
  const c = I.channels[Q], l = I.samplers[c.sampler], d = c.target, h = I.parameters !== void 0 ? I.parameters[l.input] : l.input, p = I.parameters !== void 0 ? I.parameters[l.output] : l.output;
90471
90471
  let u = e.loadAnimationTargetFromChannelWithAnimationPointer(c);
90472
- u || (u = e.loadAnimationTargetFromChannel(c)), s.push(u), C.push(g.getDependency("accessor", h)), n.push(g.getDependency("accessor", p)), a.push(l), B.push(d);
90472
+ if (u || (u = e.loadAnimationTargetFromChannel(c)), u == null) {
90473
+ console.warn("Failed to load animation target", c, u);
90474
+ continue;
90475
+ }
90476
+ s.push(u), C.push(g.getDependency("accessor", h)), n.push(g.getDependency("accessor", p)), a.push(l), B.push(d);
90473
90477
  }
90474
90478
  return Promise.all([
90475
90479
  Promise.all(s),
@@ -87668,7 +87668,7 @@ class fce {
87668
87668
  /* DUPLICATE of functionality in GLTFLoader */
87669
87669
  loadAnimationTargetFromChannel(e) {
87670
87670
  const t = e.target, i = t.node !== void 0 ? t.node : t.id;
87671
- return this.parser.getDependency("node", i);
87671
+ return i ? this.parser.getDependency("node", i) : null;
87672
87672
  }
87673
87673
  loadAnimationTargetFromChannelWithAnimationPointer(e) {
87674
87674
  this._havePatchedPropertyBindings || this._patchPropertyBindingFindNode();
@@ -87919,7 +87919,11 @@ class fce {
87919
87919
  for (let f = 0, p = r.channels.length; f < p; f++) {
87920
87920
  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;
87921
87921
  let y = t.loadAnimationTargetFromChannelWithAnimationPointer(g);
87922
- y || (y = t.loadAnimationTargetFromChannel(g)), a.push(y), c.push(s.getDependency("accessor", m)), l.push(s.getDependency("accessor", b)), u.push(A), d.push(v);
87922
+ if (y || (y = t.loadAnimationTargetFromChannel(g)), y == null) {
87923
+ console.warn("Failed to load animation target", g, y);
87924
+ continue;
87925
+ }
87926
+ a.push(y), c.push(s.getDependency("accessor", m)), l.push(s.getDependency("accessor", b)), u.push(A), d.push(v);
87923
87927
  }
87924
87928
  return Promise.all([
87925
87929
  Promise.all(a),
@@ -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(e.content.cloneNode(!0)),this._context=new Ft({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return Ele}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const e=this.getAttribute("camera-controls");return!(e===null||e==="False"||e==="false"||e==="0")}getContext(){return new Promise((e,t)=>{if(this._context&&this.loadingFinished)e(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&e(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(fr&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];t&&(fr&&console.log('globalThis["needle:codegen_files"]',t),this.setAttribute("src",t))}const e=this._loadId;setTimeout(()=>{this.isConnected!==!1&&e===this._loadId&&this.onLoad()},1),Ic!=null&&Ic.length&&this.setAttribute("version",Ic)}disconnectedCallback(){var e;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");fr&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(e=this._context)==null||e.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(e,t,s){switch(fr&&console.log("attributeChangedCallback",e,t,s),e){case"src":fr&&console.warn("src changed to type:",typeof s,', from "',t,'" 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&&(fr&&console.log(e+" attribute changed",s),this.registerEventFromAttribute(e,s));break;case"dracoDecoderPath":fr&&console.log("dracoDecoderPath",s),nU(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(fr&&console.log("dracoDecoderType",s),oU(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":fr&&console.log("ktx2DecoderPath",s),aU(s);break}}async onLoad(){var e,t;if(!this.isConnected)return;if(this._context||(fr&&console.warn("Create new context"),this._context=new Ft({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const s=this.getSourceFiles();if(s==null||s.length<=0)fr&&console.warn("Clear scene",s),this._context.clear();else if(!this.checkIfSourceHasChanged(s,this._lastSourceFiles))return;this._lastSourceFiles=s;const r=++this._loadId,n=this.getAttribute("alias");this.classList.add("loading");const o=tp();this.ensureLoadStartIsRegistered();let a=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:n},cancelable:!0}));if(o){const f=this.getAttribute("hide-loading-overlay");f!=null&&f!=="0"&&(a=!1)}a===!1&&!o&&(oi()||(a=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),oi()&&wr('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&&a&&(this._loadingView=new KC(this)),a&&(this._didFullyLoad!==!0?(e=this._loadingView)==null||e.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===r&&this._loadingView.onLoadingBegin("begin load")},300)),fr&&console.warn("--------------",r,"Needle Engine: Begin loading",n??"",s),this.onBeforeBeginLoading();const l=[],c={context:this._context,name:"",progress:{},index:0,count:s.length,totalProgress01:this._loadingProgress01},u=new CustomEvent("progress",{detail:c}),d={files:s,onLoadingProgress:f=>{var m;f.name=Mle(f.name),a&&((m=this._loadingView)==null||m.onLoadingUpdate(f)),c.name=f.name,c.progress=f.progress,this._loadingProgress01=qC(f),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(u)},onLoadingFinished:(f,m,A)=>{A&&l.push({src:m,file:A})}},p=this.getAttribute("hash");p!=null&&(this._context.hash=p),this._context.alias=n,await this._context.create(d),this._loadId===r&&(fr&&console.warn("--------------",r,"Needle Engine: finished loading",n??"",s),this._loadingProgress01=1,a&&((t=this._loadingView)==null||t.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:n,loadedFiles:l}})))}internalSetLoadingMessage(e){var t;(t=this._loadingView)==null||t.setMessage(e)}getSourceFiles(){const e=this.getAttribute("src");if(!e)return[];let t;Array.isArray(e)?t=e:e.startsWith("[")&&e.endsWith("]")?t=JSON.parse(e):e.includes(",")?t=e.split(","):t=[e];for(let s=t.length-1;s>=0;s--){const r=t[s];(r==="null"||r==="undefined"||r?.length<=0)&&t.splice(s,1)}return t}checkIfSourceHasChanged(e,t){if(e?.length!==t?.length||e==null&&t!==null||e!==null&&t==null)return!0;if(e!==null&&t!==null){for(let s=0;s<e?.length;s++)if(e[s]!==t[s])return!0}return!1}ensureLoadStartIsRegistered(){const e=this.getAttribute("loadstart");e&&this.registerEventFromAttribute("loadstart",e)}registerEventFromAttribute(e,t){const s=this._previouslyRegisteredMap.get(e);if(s&&(this._previouslyRegisteredMap.delete(e),this.removeEventListener(e,s)),typeof t=="string"&&t.length>0)try{const r=(0,eval)(t);typeof r=="function"&&(this._previouslyRegisteredMap.set(e,r),this.addEventListener(e,n=>r?.call(globalThis,this._context,n)))}catch(r){console.error("Error registering event "+e+'="'+t+`" failed with the following error:
6639
- `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e,t){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,t,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Lv),this.classList.remove(Uv);const e=this.getAROverlayContainer();fr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Lv),e.classList.remove(Uv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,NL))}onSetupVR(){this.classList.remove(Lv),this.classList.remove(Uv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,mj))}onSetupDesktop(){this.classList.remove(Lv),this.classList.add(Uv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Lv),e.classList.add(Uv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,gj))}setupElementsForMode(e,t,s=null){var r,n;if(!(e===((n=(r=this._context)==null?void 0:r.renderer)==null?void 0:n.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const o of Cle)e.classList.contains(o)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const s=this.children[t];s.style&&e(s)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(fr&&console.log("using custom draco decoder path",e),nU(e));const t=this.getAttribute("dracoDecoderType");t&&(fr&&console.log("using custom draco decoder type",t),oU(t));const s=this.getAttribute("ktx2DecoderPath");s&&(fr&&console.log("using custom ktx2 decoder path",s),aU(s))}}typeof window<"u"&&!window.customElements.get(fj)&&window.customElements.define(fj,qI);function Mle(i){const e=i.split("/");let t=e[e.length-1];const s=t.indexOf("?");return s>0&&(t=t.substring(0,s)),decodeURIComponent(t)}const Tle=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:qI},Symbol.toStringTag,{value:"Module"})),Ax=oe("debughotreload");let Fv=!1;const Nv=new Map;function Ile(){return Fv}function Rle(i){var e;if(Fv)return;const t=i.constructor.name;Nv.has(t)?(e=Nv.get(t))==null||e.push(i):Nv.set(t,[i])}function Ple(i){if(Fv)return;const e=i.constructor.name,t=Nv.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let vj=!1;function Ble(){if(Ax||vj)return;vj=!0;const i=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}}i.apply(console,e)}}function Dle(i){Ax&&console.log("[HMR] Apply changes",i,Object.keys(i)),Ble();for(const e of Object.keys(i))try{Fv=!0;const t=Y.get(e);if(!t){Ax&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=Nv.get(s.name);let n="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?n+=" x"+o:n+=" - no instances",console.log(n);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(s.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new s,u=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&wl(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],b=g.name,y="bound ";if(b===y)continue;const _=g.name.substring(y.length),S=s.prototype[_];S&&(d[v]=S.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&dC(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(Ax)console.error(t);else return!1}finally{Fv=!1,ml(lo.Log,"Script changes applied (HMR)")}return!0}const kle=Symbol("object"),Aj=new va(()=>new w,20);class yj{constructor(e,t,s,r,n){h(this,"_point"),h(this,"_normal"),h(this,"distance"),h(this,"impulse"),h(this,"friction"),this._point=e,this.distance=t,this._normal=s,this.impulse=r,this.friction=n}get point(){return Aj.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Aj.get().set(this._normal.x,this._normal.y,this._normal.z)}}class bj{constructor(e,t,s){h(this,"contacts"),h(this,"me"),h(this,"_collider"),h(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class _j{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const zv=new Array(32).fill(void 0);zv.push(void 0,null,!0,!1);let xj;zv.length;function wj(){return xj.byteLength,xj}const Ole=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}Ole.decode();let Sj,Cj,jv=32;function Ej(i){if(jv==1)throw new Error("out of js stack");return zv[--jv]=i,jv}function Lle(){return Sj.byteLength,Sj}function Ule(){return Cj.byteLength,Cj}let Zn=0;function Yu(i,e){const t=e(4*i.length);return Lle().set(i,t/4),Zn=i.length,t}function yx(i,e){const t=e(4*i.length);return Ule().set(i,t/4),Zn=i.length,t}class Qx{static __wrap(e){const t=Object.create(Qx.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();ze.__wbg_raweventqueue_free(e)}constructor(e){const t=ze.raweventqueue_new(e);return Qx.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,Ej(e))}finally{zv[jv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,Ej(e))}finally{zv[jv++]=void 0}}clear(){ze.raweventqueue_clear(this.ptr)}}class Ka{static __wrap(e){const t=Object.create(Ka.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();ze.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,dt),vt(t,dt);const s=ze.rawgenericjoint_spherical(e.ptr,t.ptr);return Ka.__wrap(s)}static prismatic(e,t,s,r,n,o){vt(e,dt),vt(t,dt),vt(s,dt);const a=ze.rawgenericjoint_prismatic(e.ptr,t.ptr,s.ptr,r,n,o);return a===0?void 0:Ka.__wrap(a)}static fixed(e,t,s,r){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,Xs);const n=ze.rawgenericjoint_fixed(e.ptr,t.ptr,s.ptr,r.ptr);return Ka.__wrap(n)}static revolute(e,t,s){vt(e,dt),vt(t,dt),vt(s,dt);const r=ze.rawgenericjoint_revolute(e.ptr,t.ptr,s.ptr);return r===0?void 0:Ka.__wrap(r)}}class lR{static __wrap(e){const t=Object.create(lR.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();ze.__wbg_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class cR{static __wrap(e){const t=Object.create(cR.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();ze.__wbg_rawrayintersection_free(e)}normal(){const e=ze.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}featureType(){return ze.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const s=ze.__wbindgen_add_to_stack_pointer(-16);ze.rawrayintersection_featureId(s,this.ptr);var e=wj()[s/4+0],t=wj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class Xs{static __wrap(e){const t=Object.create(Xs.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();ze.__wbg_rawrotation_free(e)}constructor(e,t,s,r){const n=ze.rawrotation_new(e,t,s,r);return Xs.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return Xs.__wrap(e)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}get y(){return ze.rawrotation_y(this.ptr)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}get w(){return ze.rawrotation_w(this.ptr)}}class Qt{static __wrap(e){const t=Object.create(Qt.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();ze.__wbg_rawshape_free(e)}static cuboid(e,t,s){const r=ze.rawshape_cuboid(e,t,s);return Qt.__wrap(r)}static roundCuboid(e,t,s,r){const n=ze.rawshape_roundCuboid(e,t,s,r);return Qt.__wrap(n)}static ball(e){const t=ze.rawshape_ball(e);return Qt.__wrap(t)}static capsule(e,t){const s=ze.rawshape_capsule(e,t);return Qt.__wrap(s)}static cylinder(e,t){const s=ze.rawshape_cylinder(e,t);return Qt.__wrap(s)}static roundCylinder(e,t,s){const r=ze.rawshape_roundCylinder(e,t,s);return Qt.__wrap(r)}static cone(e,t){const s=ze.rawshape_cone(e,t);return Qt.__wrap(s)}static roundCone(e,t,s){const r=ze.rawshape_roundCone(e,t,s);return Qt.__wrap(r)}static polyline(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_trimesh(s,r,n,o);return Qt.__wrap(a)}static heightfield(e,t,s,r){const n=Yu(s,ze.__wbindgen_malloc),o=Zn;vt(r,dt);const a=ze.rawshape_heightfield(e,t,n,o,r.ptr);return Qt.__wrap(a)}static segment(e,t){vt(e,dt),vt(t,dt);const s=ze.rawshape_segment(e.ptr,t.ptr);return Qt.__wrap(s)}static triangle(e,t,s){vt(e,dt),vt(t,dt),vt(s,dt);const r=ze.rawshape_triangle(e.ptr,t.ptr,s.ptr);return Qt.__wrap(r)}static roundTriangle(e,t,s,r){vt(e,dt),vt(t,dt),vt(s,dt);const n=ze.rawshape_roundTriangle(e.ptr,t.ptr,s.ptr,r);return Qt.__wrap(n)}static convexHull(e){const t=Yu(e,ze.__wbindgen_malloc),s=Zn,r=ze.rawshape_convexHull(t,s);return r===0?void 0:Qt.__wrap(r)}static roundConvexHull(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=ze.rawshape_roundConvexHull(s,r,t);return n===0?void 0:Qt.__wrap(n)}static convexMesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_convexMesh(s,r,n,o);return a===0?void 0:Qt.__wrap(a)}static roundConvexMesh(e,t,s){const r=Yu(e,ze.__wbindgen_malloc),n=Zn,o=yx(t,ze.__wbindgen_malloc),a=Zn,l=ze.rawshape_roundConvexMesh(r,n,o,a,s);return l===0?void 0:Qt.__wrap(l)}castShape(e,t,s,r,n,o,a,l){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,Qt),vt(n,dt),vt(o,Xs),vt(a,dt);const c=ze.rawshape_castShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o.ptr,a.ptr,l);return c===0?void 0:uR.__wrap(c)}intersectsShape(e,t,s,r,n){return vt(e,dt),vt(t,Xs),vt(s,Qt),vt(r,dt),vt(n,Xs),ze.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr)!==0}contactShape(e,t,s,r,n,o){vt(e,dt),vt(t,Xs),vt(s,Qt),vt(r,dt),vt(n,Xs);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:hR.__wrap(a)}containsPoint(e,t,s){return vt(e,dt),vt(t,Xs),vt(s,dt),ze.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,s.ptr)!==0}projectPoint(e,t,s,r){vt(e,dt),vt(t,Xs),vt(s,dt);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return lR.__wrap(n)}intersectsRay(e,t,s,r,n){return vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt),ze.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n)!==0}castRay(e,t,s,r,n,o){return vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt),ze.rawshape_castRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o)}castRayAndGetNormal(e,t,s,r,n,o){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt);const a=ze.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o);return a===0?void 0:cR.__wrap(a)}}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();ze.__wbg_rawshapecontact_free(e)}distance(){return ze.rawshapecontact_distance(this.ptr)}point1(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}point2(){const e=ze.rawshapecontact_point2(this.ptr);return dt.__wrap(e)}normal1(){const e=ze.rawshapecontact_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=ze.rawshapecontact_normal2(this.ptr);return dt.__wrap(e)}}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();ze.__wbg_rawshapetoi_free(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}witness1(){const e=ze.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}witness2(){const e=ze.rawshapetoi_witness2(this.ptr);return dt.__wrap(e)}normal1(){const e=ze.rawshapetoi_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=ze.rawshapetoi_normal2(this.ptr);return dt.__wrap(e)}}class dt{static __wrap(e){const t=Object.create(dt.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();ze.__wbg_rawvector_free(e)}static zero(){const e=ze.rawvector_zero();return dt.__wrap(e)}constructor(e,t,s){const r=ze.rawvector_new(e,t,s);return dt.__wrap(r)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}set x(e){ze.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return ze.rawrotation_y(this.ptr)}set y(e){ze.rawvector_set_y(this.ptr,e)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}set z(e){ze.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=ze.rawvector_xyz(this.ptr);return dt.__wrap(e)}yxz(){const e=ze.rawvector_yxz(this.ptr);return dt.__wrap(e)}zxy(){const e=ze.rawvector_zxy(this.ptr);return dt.__wrap(e)}xzy(){const e=ze.rawvector_xzy(this.ptr);return dt.__wrap(e)}yzx(){const e=ze.rawvector_yzx(this.ptr);return dt.__wrap(e)}zyx(){const e=ze.rawvector_zyx(this.ptr);return dt.__wrap(e)}}class Fle{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class De{static new(e,t,s){return new Fle(e,t,s)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return De.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=De.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 Mj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class ki{static identity(){return new Mj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Mj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Xs(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 Qv,Va,Tj,Mo,YI,Zt,bx,pf,KI,JI,Ij,Rj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Qv||(Qv={}));class Nle{constructor(e,t,s){this.rawSet=e,this.colliderSet=t,this.handle=s}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,s,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,s,r)}restrictTranslations(e,t,s,r){this.setEnabledTranslations(e,t,s,r)}setEnabledRotations(e,t,s,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,s,r)}restrictRotations(e,t,s,r){this.setEnabledRotations(e,t,s,r)}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 De.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return ki.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return De.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return ki.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=De.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,s,t),s.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 s=De.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,s,t),s.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 De.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return De.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,s,r,n){let o=De.intoRaw(t),a=De.intoRaw(s),l=ki.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,n),o.free(),a.free(),l.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 s=De.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=De.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=De.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=De.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=De.intoRaw(e),n=De.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=De.intoRaw(e),n=De.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,n,s),r.free(),n.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Spherical=3]="Spherical"})(Va||(Va={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(Tj||(Tj={}));class bf{constructor(){}static fixed(e,t,s,r){let n=new bf;return n.anchor1=e,n.anchor2=s,n.frame1=t,n.frame2=r,n.jointType=Va.Fixed,n}static spherical(e,t){let s=new bf;return s.anchor1=e,s.anchor2=t,s.jointType=Va.Spherical,s}static prismatic(e,t,s){let r=new bf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Prismatic,r}static revolute(e,t,s){let r=new bf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Revolute,r}intoRaw(){let e,t,s=De.intoRaw(this.anchor1),r=De.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Va.Fixed:let l=ki.intoRaw(this.frame1),c=ki.intoRaw(this.frame2);t=Ka.fixed(s,l,r,c),l.free(),c.free();break;case Va.Prismatic:e=De.intoRaw(this.axis),this.limitsEnabled&&(n=!0,o=this.limits[0],a=this.limits[1]),t=Ka.prismatic(s,r,e,n,o,a),e.free();break;case Va.Spherical:t=Ka.spherical(s,r);break;case Va.Revolute:e=De.intoRaw(this.axis),t=Ka.revolute(s,r,e),e.free()}return s.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(Mo||(Mo={}));class Yv{constructor(e,t,s,r,n){this.distance=e,this.point1=t,this.point2=s,this.normal1=r,this.normal2=n}static fromRaw(e){if(!e)return null;const t=new Yv(e.distance(),De.fromRaw(e.point1()),De.fromRaw(e.point2()),De.fromRaw(e.normal1()),De.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(YI||(YI={}));class Gx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Gx(De.fromRaw(e.point()),e.isInside());return e.free(),t}}class zle{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 Hx{constructor(e,t,s,r){this.featureType=YI.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),s!==void 0&&(this.featureType=s)}static fromRaw(e){if(!e)return null;const t=new Hx(e.toi(),De.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Kv{constructor(e,t,s,r,n){this.toi=e,this.witness1=t,this.witness2=s,this.normal1=r,this.normal2=n}static fromRaw(e,t){if(!t)return null;const s=new Kv(t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),s}}class dR extends Kv{constructor(e,t,s,r,n,o){super(t,s,r,n,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const s=new dR(e.get(t.colliderHandle()),t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),s}}class mr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case Zt.Ball:return new ZI(e.coRadius(t));case Zt.Cuboid:return r=e.coHalfExtents(t),new Pj(r.x,r.y,r.z);case Zt.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new Bj(r.x,r.y,r.z,n);case Zt.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new Dj(l,c);case Zt.Segment:return o=e.coVertices(t),new kj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Uj(o,a);case Zt.Triangle:return o=e.coVertices(t),new Oj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new Lj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]),n);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new Fj(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new Nj(p,f,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new $I(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new eR(o,a,n);case Zt.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new zj(l,c);case Zt.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new jj(l,c,n);case Zt.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new Qj(l,c);case Zt.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Gj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=De.intoRaw(e),u=ki.intoRaw(t),d=De.intoRaw(s),p=De.intoRaw(n),f=ki.intoRaw(o),m=De.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Kv.fromRaw(null,A.castShape(c,u,d,v,p,f,m,l));return c.free(),u.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g}intersectsShape(e,t,s,r,n){let o=De.intoRaw(e),a=ki.intoRaw(t),l=De.intoRaw(r),c=ki.intoRaw(n),u=this.intoRaw(),d=s.intoRaw(),p=u.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),u.free(),d.free(),p}contactShape(e,t,s,r,n,o){let a=De.intoRaw(e),l=ki.intoRaw(t),c=De.intoRaw(r),u=ki.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Yv.fromRaw(d.contactShape(a,l,p,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p.free(),f}containsPoint(e,t,s){let r=De.intoRaw(e),n=ki.intoRaw(t),o=De.intoRaw(s),a=this.intoRaw(),l=a.containsPoint(r,n,o);return r.free(),n.free(),o.free(),a.free(),l}projectPoint(e,t,s,r){let n=De.intoRaw(e),o=ki.intoRaw(t),a=De.intoRaw(s),l=this.intoRaw(),c=Gx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=De.intoRaw(t),o=ki.intoRaw(s),a=De.intoRaw(e.origin),l=De.intoRaw(e.dir),c=this.intoRaw(),u=c.intersectsRay(n,o,a,l,r);return n.free(),o.free(),a.free(),l.free(),c.free(),u}castRay(e,t,s,r,n){let o=De.intoRaw(t),a=ki.intoRaw(s),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,l,c,r,n);return o.free(),a.free(),l.free(),c.free(),u.free(),d}castRayAndGetNormal(e,t,s,r,n){let o=De.intoRaw(t),a=ki.intoRaw(s),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),u=this.intoRaw(),d=Hx.fromRaw(u.castRayAndGetNormal(o,a,l,c,r,n));return o.free(),a.free(),l.free(),c.free(),u.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class ZI extends mr{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class Pj extends mr{constructor(e,t,s){super(),this.type=Zt.Cuboid,this.halfExtents=De.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class Bj extends mr{constructor(e,t,s,r){super(),this.type=Zt.RoundCuboid,this.halfExtents=De.new(e,t,s),this.borderRadius=r}intoRaw(){return Qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class Dj extends mr{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class kj extends mr{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class Oj extends mr{constructor(e,t,s){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=De.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class Lj extends mr{constructor(e,t,s,r){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=s,this.borderRadius=r}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=De.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Uj extends mr{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Qt.polyline(this.vertices,this.indices)}}class Fj extends mr{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class $I extends mr{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Qt.convexMesh(this.vertices,this.indices):Qt.convexHull(this.vertices)}}class eR extends mr{constructor(e,t,s){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=s}intoRaw(){return this.indices?Qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Qt.roundConvexHull(this.vertices,this.borderRadius)}}class Nj extends mr{constructor(e,t,s,r){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=s,this.scale=r}intoRaw(){let e=De.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class zj extends mr{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class jj extends mr{constructor(e,t,s){super(),this.type=Zt.RoundCylinder,this.borderRadius=s,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class Qj extends mr{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Gj extends mr{constructor(e,t,s){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=s}intoRaw(){return Qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"})(bx||(bx={}));class jle{constructor(e,t,s,r){this.colliderSet=e,this.handle=t,this._parent=s,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=mr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return De.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return ki.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,s,r){let n=De.intoRaw(t),o=De.intoRaw(s),a=ki.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,n,o,a),n.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 De.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 De.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=De.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=De.intoRaw(e),r=Gx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=De.intoRaw(e.origin),r=De.intoRaw(e.dir),n=this.colliderSet.raw.coIntersectsRay(this.handle,s,r,t);return s.free(),r.free(),n}castShape(e,t,s,r,n,o){let a=De.intoRaw(e),l=De.intoRaw(s),c=ki.intoRaw(r),u=De.intoRaw(n),d=t.intoRaw(),p=Kv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,l,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p}castCollider(e,t,s,r){let n=De.intoRaw(e),o=De.intoRaw(s),a=dR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,n,t.handle,o,r));return n.free(),o.free(),a}intersectsShape(e,t,s){let r=De.intoRaw(t),n=ki.intoRaw(s),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,n);return r.free(),n.free(),o.free(),a}contactShape(e,t,s,r){let n=De.intoRaw(t),o=ki.intoRaw(s),a=e.intoRaw(),l=Yv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Yv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=De.intoRaw(e.origin),n=De.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,n,t,s);return r.free(),n.free(),o}castRayAndGetNormal(e,t,s){let r=De.intoRaw(e.origin),n=De.intoRaw(e.dir),o=Hx.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,n,t,s));return r.free(),n.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(pf||(pf={}));class Qi{constructor(e){this.shape=e,this.massPropsMode=pf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=ki.identity(),this.translation=De.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Mo.Average,this.restitutionCombineRule=Mo.Average,this.activeCollisionTypes=bx.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=De.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=De.zeros(),this.angularInertiaLocalFrame=ki.identity()}static ball(e){const t=new ZI(e);return new Qi(t)}static capsule(e,t){const s=new Dj(e,t);return new Qi(s)}static segment(e,t){const s=new kj(e,t);return new Qi(s)}static triangle(e,t,s){const r=new Oj(e,t,s);return new Qi(r)}static roundTriangle(e,t,s,r){const n=new Lj(e,t,s,r);return new Qi(n)}static polyline(e,t){const s=new Uj(e,t);return new Qi(s)}static trimesh(e,t){const s=new Fj(e,t);return new Qi(s)}static cuboid(e,t,s){const r=new Pj(e,t,s);return new Qi(r)}static roundCuboid(e,t,s,r){const n=new Bj(e,t,s,r);return new Qi(n)}static heightfield(e,t,s,r){const n=new Nj(e,t,s,r);return new Qi(n)}static cylinder(e,t){const s=new zj(e,t);return new Qi(s)}static roundCylinder(e,t,s){const r=new jj(e,t,s);return new Qi(r)}static cone(e,t){const s=new Qj(e,t);return new Qi(s)}static roundCone(e,t,s){const r=new Gj(e,t,s);return new Qi(r)}static convexHull(e){const t=new $I(e,null);return new Qi(t)}static convexMesh(e,t){const s=new $I(e,t);return new Qi(s)}static roundConvexHull(e,t){const s=new eR(e,null,t);return new Qi(s)}static roundConvexMesh(e,t,s){const r=new eR(e,t,s);return new Qi(r)}setTranslation(e,t,s){if(typeof e!="number"||typeof t!="number"||typeof s!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:s},this}setRotation(e){return ki.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=pf.Density,this.density=e,this}setMass(e){return this.massPropsMode=pf.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=pf.MassProps,this.mass=e,De.copy(this.centerOfMass,t),De.copy(this.principalAngularInertia,s),ki.copy(this.angularInertiaLocalFrame,r),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(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(KI||(KI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(JI||(JI={}));class Qle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return De.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return De.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Gle{constructor(e,t){this.raw=t||new Qx(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Qle;this.raw.drainContactForceEvents(s=>{t.raw=s,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(Ij||(Ij={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Rj||(Rj={}));for(var cce={byteLength:function(i){var e=Hj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Hj(i),r=s[0],n=s[1],o=new Hle(function(c,u,d){return 3*(u+d)/4-d}(0,r,n)),a=0,l=n>0?r-4:r;for(t=0;t<l;t+=4)e=To[i.charCodeAt(t)]<<18|To[i.charCodeAt(t+1)]<<12|To[i.charCodeAt(t+2)]<<6|To[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=To[i.charCodeAt(t)]<<2|To[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=To[i.charCodeAt(t)]<<10|To[i.charCodeAt(t+1)]<<4|To[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,s=t%3,r=[],n=16383,o=0,a=t-s;o<a;o+=n)r.push(Wle(i,o,o+n>a?a:o+n));return s===1?(e=i[t-1],r.push(Wa[e>>2]+Wa[e<<4&63]+"==")):s===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Wa[e>>10]+Wa[e>>4&63]+Wa[e<<2&63]+"=")),r.join("")}},Wa=[],To=[],Hle=typeof Uint8Array<"u"?Uint8Array:Array,tR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ff=0,Vle=tR.length;ff<Vle;++ff)Wa[ff]=tR[ff],To[tR.charCodeAt(ff)]=ff;function Hj(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Wle(i,e,t){for(var s,r,n=[],o=e;o<t;o+=3)s=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),n.push(Wa[(r=s)>>18&63]+Wa[r>>12&63]+Wa[r>>6&63]+Wa[63&r]);return n.join("")}To["-".charCodeAt(0)]=62,To["_".charCodeAt(0)]=63;const on=oe("debugphysics"),iR=oe("debugcolliderplacement"),sR=oe("debugcollisions"),Xle=oe("showcolliders"),$n=Symbol("needle component"),eo=Symbol("physics body"),qle=Symbol("rigidbody");let mf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,on&&console.log("Use Rapier",!1,globalThis.false);const _x=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new zle({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new va(()=>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 Ee),h(this,"_tempScale",new w),h(this,"_tempMatrix",new Re),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(i){var e,t,s;if(!i)return;this.validate();const r=i[eo];if(i[eo]=null,r&&this.world){const n=this.objects.findIndex(o=>o===i);if(n>=0){const o=this.bodies[n];if(this.bodies.splice(n,1),this.objects.splice(n,1),o instanceof jle){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[$n]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof Nle&&(o.numColliders()<=0?(s=this.world)==null||s.removeRigidBody(o):oi()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.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(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=i,r=s[eo];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[eo];t&&this.internalUpdateColliderProperties(e,t)}else{const e=i,t=this.internal_getRigidbody(e);t&&this.internalUpdateRigidbodyProperties(e,t)}}addForce(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.addForce(e,t)}addImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?.wakeUp()}setAngularVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setAngvel(e,t)}setLinearVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setLinvel(e,t)}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return on&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&on&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||on&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRay(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[$n])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(a.x,a.y,a.z),{point:l,collider:o.collider[$n]}}return null}raycastAndGetNormal(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRayAndGetNormal(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[$n])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=o.normal,c=this.raycastVectorsBuffer.get(),u=this.raycastVectorsBuffer.get();return c.set(a.x,a.y,a.z),u.set(l.x,l.y,l.z),{point:c,normal:u,collider:o.collider[$n]}}return null}getPhysicsRay(i,e,t){var s,r,n;const o=(s=this.context)==null?void 0:s.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(on&&console.warn("Converting screenspace to raycast space",c),(n=this.context)==null||n.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=_t(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new ZI(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[$n],r=new _j(s.gameObject,s);return this.rapierColliderArray.push(r),!0},KI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[$n].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,s;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const s=i.gameObject,r=Js(s,this._tempPosition).multiply(t);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 n=Qi.cuboid(r.x,r.y,r.z);this.createCollider(i,n,e)}async addSphereCollider(i,e){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const t=Qi.ball(.5);this.createCollider(i,t,e),this.updateProperties(i)}async addCapsuleCollider(i,e,t,s){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const r=i.gameObject,n=Js(r,this._tempPosition);n.x=Math.abs(n.x),n.y=Math.abs(n.y);const o=Qi.capsule(t*.5*n.y-s,s*n.x);this.createCollider(i,o,e)}async addMeshCollider(i,e,t,s){var r,n,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){on&&console.warn("Missing mesh geometry",e.name);return}(n=(r=a.index)==null?void 0:r.array)!=null&&n.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=VY(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const d=a.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+t;if(this._meshCache.has(d))on&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",e.name,Object.assign({},s));const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*s.x,p[f+1]=l[f+1]*s.y,p[f+2]=l[f+2]*s.z;l=p,this._meshCache.set(d,p)}}const u=t?Qi.convexMesh(l):Qi.trimesh(l,c);u&&this.createCollider(i,u)}getBody(i){return i?i[eo]:null}getComponent(i){return i?i[$n]:null}createCollider(i,e,t){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:n}=this.getRigidbody(i,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),Js(i.gameObject,this._tempScale),t&&(t.multiply(this._tempScale),this._tempPosition.x-=t.x,this._tempPosition.y+=t.y,this._tempPosition.z+=t.z),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const o=i.sharedMaterial;if(o){switch(e.setRestitution(o.bounciness),o.bounceCombine){case Ia.Average:e.setRestitutionCombineRule(Mo.Average);break;case Ia.Maximum:e.setRestitutionCombineRule(Mo.Max);break;case Ia.Minimum:e.setRestitutionCombineRule(Mo.Min);break;case Ia.Multiply:e.setRestitutionCombineRule(Mo.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Ia.Average:e.setFrictionCombineRule(Mo.Average);break;case Ia.Maximum:e.setFrictionCombineRule(Mo.Max);break;case Ia.Minimum:e.setFrictionCombineRule(Mo.Min);break;case Ia.Multiply:e.setFrictionCombineRule(Mo.Multiply);break}}n&&e.setDensity(0);const a=this.world.createCollider(e,r);return a[$n]=i,i[eo]=a,a.setActiveEvents(JI.COLLISION_EVENTS),a.setActiveCollisionTypes(bx.ALL),this.objects.push(i),this.bodies.push(a),a}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null,s=!1;if(i.attachedRigidbody){const r=i.attachedRigidbody;if(t=r[eo],s=r.autoMass===!1,!t){const n=r.isKinematic&&!iR;on&&console.log("Create rigidbody",n);const o=n?mf.RigidBodyDesc.kinematicPositionBased():mf.RigidBodyDesc.dynamic(),a=_t(i.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Ds(i.attachedRigidbody.gameObject)),t=this.world.createRigidBody(o),this.bodies.push(t),this.objects.push(r)}t[$n]=r,r[eo]=t,this.internalUpdateRigidbodyProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=mf.RigidBodyDesc.kinematicPositionBased(),n=_t(i.gameObject);r.setTranslation(n.x,n.y,n.z),r.setRotation(Ds(i.gameObject)),t=this.world.createRigidBody(r),e.identity(),t[$n]=null}return i[qle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[eo]}internalUpdateColliderProperties(i,e){const t=e.shape;switch(t.type){case Zt.Ball:{const n=t,o=i,a=n.radius!==o.radius,l=i.gameObject,c=Js(l,this._tempPosition).multiplyScalar(o.radius);n.radius=Math.abs(c.x),a&&e.setShape(n);break}case Zt.Cuboid:const s=t,r=i;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,e.setShape(s);break}}internalUpdateRigidbodyProperties(i,e){if(e.enableCcd(i.collisionDetectionMode!==bb.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),i.dominanceGroup<=127&&i.dominanceGroup>=-127?e.setDominanceGroup(Math.floor(i.dominanceGroup)):e.setDominanceGroup(0),i.autoMass){e.setAdditionalMass(0,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1);e.recomputeMassPropertiesFromColliders(),console.log(e.mass())}else{e.setAdditionalMass(i.mass,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(0);e.recomputeMassPropertiesFromColliders(),console.log(e.mass())}e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!0),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!0),i.isKinematic?e.setBodyType(mf.RigidBodyType.KinematicPositionBased):e.setBodyType(mf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Gle(!1)),i&&(this.world.timestep=st.lerp(this.world.timestep,i,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,s;if(on||iR||Xle||this.debugRenderColliders===!0){if(!this.lines){const n=new ns({color:2258688,fog:!1}),o=new mt;this.lines=new kn(o,n),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const r=i.debugRender();this.lines.geometry.setAttribute("position",new tt(r.vertices,3)),this.lines.geometry.setAttribute("color",new tt(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 Yle(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!iR)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],s=e;if(s?.isCollider===!0&&!s.attachedRigidbody){const a=t.parent();a&&this.syncPhysicsBody(e.gameObject,a,!0,!0);continue}const r=t.translation(),n=t.rotation(),o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(n.x,n.y,n.z,n.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion);r.x-=a.x,r.y-=a.y,r.z-=a.z}Qd(e.gameObject,r.x,r.y,r.z),c2(e.gameObject,n.x,n.y,n.z,n.w)}}syncPhysicsBody(i,e,t,s){const r=_t(i,this._tempPosition),n=Ds(i,this._tempQuaternion);switch(e.bodyType()){case Qv.Fixed:case Qv.KinematicPositionBased:case Qv.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),s&&e.setNextKinematicRotation(n);break;default:t&&e.setTranslation(r,!1),s&&e.setRotation(n,!1);break}e.wakeUp()}getRigidbodyRelativeMatrix(i,e,t,s){if(s===void 0&&(s=_x._matricesBuffer,s.length=0),i===e){const r=Js(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let n=s.length-1;n>=0;n--)t.multiply(s[n]);return t}return s.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,s),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[eo],s=e[eo];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=bf.fixed(_x.centerConnectionPos,_x.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);on&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[eo],n=e[eo];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=mf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);on&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const s=i.matrixWorld,r=e.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,t.copy(r).premultiply(s.invert()).invert()}};let Gv=_x;h(Gv,"_didLoadPhysicsEngine",!1),h(Gv,"_matricesBuffer",[]),h(Gv,"centerConnectionPos",{x:0,y:0,z:0}),h(Gv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Yle{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,s)=>{const r=this.world.getCollider(e),n=this.world.getCollider(t),o=r[$n],a=n[$n];sR&&console.log("EVT",o.name,a.name,s,r,n),o&&a&&(s?(this.onCollisionStarted(o,r,a,n),this.onCollisionStarted(a,n,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,s,r){let n=null;if(e.isTrigger||s.isTrigger)ou(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(s),this.activeTriggers.push({collider:e,component:o,otherCollider:s})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{ou(o,c=>{var u;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||sR){if(!n){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),b=a.solverContactFriction(m),y=new yj(A,g,f,v,b);p.push(y),sR&&Rl.DrawDirection(A,f,16711680,3,!0)}}n=new bj(o,s,p)}if(d){const p={collider:e,component:c,collision:n};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(u=c.onCollisionEnter)==null||u.call(c,n)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const s=e.collision;t.onCollisionStay(s)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const s=e.otherCollider;t.onTriggerStay(s)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let s=0;s<this.activeCollisions.length;s++){const r=this.activeCollisions[s],n=r.collider;if(n.destroyed){this.activeCollisions.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeCollisionsStay.length;s++){const r=this.activeCollisionsStay[s],n=r.collider;if(n.destroyed){this.activeCollisionsStay.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeTriggers.length;s++){const r=this.activeTriggers[s],n=r.collider;if(n.destroyed){this.activeTriggers.splice(s,1),s--;continue}if(n===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(s,1),s--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Kle(i,e,t,s="image/webp",r){if(!i&&(i=Pi.Current,!i))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=i.mainCamera,!r))return console.error("No camera found"),null;const n=i.renderer.domElement.width,o=i.renderer.domElement.height;e||(e=n),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,i.renderer.domElement.style.width=e+"px",i.renderer.domElement.style.height=t+"px";try{const l=i.renderer.domElement;return i.renderer.setSize(e,t,!1),r instanceof qt&&i.updateAspect(r,e,t),i.renderNow(),l.toDataURL(s)}finally{i.renderer.setSize(n,o,!1),i.updateSize()}return null}let Hv=null;function Jle(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Hv||(Hv=document.createElement("a")),Hv.href=i,Hv.download=e,Hv.click()}}const xx=oe("debugmissingcamera");Pi.registerCallback(Qr.MissingCamera,i=>{var e,t;xx&&console.warn("Creating missing camera");const s=i.context.scene,r=new Pe;r.name="Default Fallback Camera",s.add(r);const n=new Bi;n.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",i.context.lightmaps.tryGetSkybox(n.sourceId)?n.clearFlags=1:n.clearFlags=2,n.backgroundColor=new Ai(.5,.5,.5,1),n.fieldOfView=35,n.backgroundBlurriness=.2;const o=Rc(r,n,!0);return r.position.x=0,r.position.y=1,r.position.z=2,Vj(i.context,o),o}),Pi.registerCallback(Qr.ContextCreated,i=>{if(!i.context.mainCamera){xx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Yte(i.context.mainCamera);if(t?.isCameraController===!0){xx&&console.log("Will not auto-fit because a camera controller exists");return}Vj(i.context)}});function Vj(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(xx&&console.log("Creating default camera controls",e?.name),t){const s=f0(t,Wi);s.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");s.autoRotate=r!==void 0&&(r===""||r==="true"),s.autoRotateSpeed=.5;const n=i,o=()=>{n.pre_render_callbacks.splice(n.pre_render_callbacks.indexOf(o),1),s.fitCamera()};n.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}b6();const rR={Context:Ft,glTF:{loadFromURL:XI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=rR;function Wj(i){for(const e in i)rR[e]=i[e]}Wj(bY),Wj(ule);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:rR[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=n6;var nR={},Xj={};Object.defineProperty(Xj,"__esModule",{value:!0});var wx={};Object.defineProperty(wx,"__esModule",{value:!0}),wx.ConstantBackoff=void 0;var Zle=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();wx.ConstantBackoff=Zle;var Sx={};Object.defineProperty(Sx,"__esModule",{value:!0}),Sx.ExponentialBackoff=void 0;var $le=function(){function i(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return i.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},i.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},i}();Sx.ExponentialBackoff=$le;var Cx={};Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.LinearBackoff=void 0;var ece=function(){function i(e,t,s){this.initial=e,this.increment=t,this.maximum=s,this.current=this.initial}return i.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},i.prototype.reset=function(){this.current=this.initial},i}();Cx.LinearBackoff=ece;var qj={};Object.defineProperty(qj,"__esModule",{value:!0});var Ex={};Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.LRUBuffer=void 0;var tce=function(){function i(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return i.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},i.prototype.cap=function(){return this.buffer.length},i.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,s=t-1<0?this.buffer.length-1:t-1,r=0;r<e.length;r++){var n=(t+r)%this.buffer.length;if(e[r]=this.buffer[n],n===s)return r+1}return e.length},i.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,s=0;s<e.length-t;s++)this.buffer[this.writePtr]=e[t+s],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},i.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,r=this.len();e(this.buffer[t]),t!==s;)t=(t+1)%this.buffer.length;return r},i.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},i}();Ex.LRUBuffer=tce;var Mx={};Object.defineProperty(Mx,"__esModule",{value:!0}),Mx.TimeBuffer=void 0;var ice=function(){function i(e){this.maxAge=e}return i.prototype.cap=function(){return Number.POSITIVE_INFINITY},i.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},i.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,s=0;t!==void 0&&(e[s++]=t.e,s!==e.length);)t=t.n;return s},i.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},i.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,s=0;t!==void 0;)e(t.e),s++,t=t.n;return s},i.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)},i.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););},i.prototype.clear=function(){},i}();Mx.TimeBuffer=ice;var oR={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Websocket=i.WebsocketEvents=void 0;var e;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry"})(e=i.WebsocketEvents||(i.WebsocketEvents={}));var t=function(){function s(r,n,o,a){var l=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(c){return l.handleEvent(e.open,c)},this.handleCloseEvent=function(c){return l.handleEvent(e.close,c)},this.handleErrorEvent=function(c){return l.handleEvent(e.error,c)},this.handleMessageEvent=function(c){return l.handleEvent(e.message,c)},this.url=r,this.protocols=n,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(s.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),s.prototype.send=function(r){var n;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(n=this.buffer)===null||n===void 0||n.write([r]):this.websocket.send(r))},s.prototype.close=function(r,n){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(r,n)},s.prototype.addEventListener=function(r,n,o){var a={listener:n,options:o},l=this.eventListeners[r];l.push(a)},s.prototype.removeEventListener=function(r,n,o){this.eventListeners[r]=this.eventListeners[r].filter(function(a){return a.listener!==n&&(a.options===void 0||a.options!==o)})},s.prototype.dispatchEvent=function(r,n){var o=this,a=this.eventListeners[r],l=[];a.forEach(function(c){c.listener(o,n),c.options!==void 0&&c.options.once&&l.push(c)}),l.forEach(function(c){return o.removeEventListener(r,c.listener,c.options)})},s.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)},s.prototype.handleEvent=function(r,n){var o,a,l;switch(r){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)),(l=this.buffer)===null||l===void 0||l.clear();break}this.dispatchEvent(r,n)},s.prototype.reconnect=function(){var r=this;if(this.backoff!==void 0){var n=this.backoff.next();setTimeout(function(){r.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++r.retries,backoff:n}})),r.tryConnect()},n)}},s}();i.Websocket=t})(oR);var Tx={};Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.WebsocketBuilder=void 0;var gf=oR,sce=function(){function i(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return i.prototype.withProtocols=function(e){return this.protocols=e,this},i.prototype.withBackoff=function(e){return this.backoff=e,this},i.prototype.withBuffer=function(e){return this.buffer=e,this},i.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},i.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},i.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},i.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},i.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},i.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new gf.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();Tx.WebsocketBuilder=sce,function(i){var e=Jy&&Jy.__createBinding||(Object.create?function(s,r,n,o){o===void 0&&(o=n),Object.defineProperty(s,o,{enumerable:!0,get:function(){return r[n]}})}:function(s,r,n,o){o===void 0&&(o=n),s[o]=r[n]}),t=Jy&&Jy.__exportStar||function(s,r){for(var n in s)n!=="default"&&!Object.prototype.hasOwnProperty.call(r,n)&&e(r,s,n)};Object.defineProperty(i,"__esModule",{value:!0}),t(Xj,i),t(wx,i),t(Sx,i),t(Cx,i),t(qj,i),t(Ex,i),t(Mx,i),t(oR,i),t(Tx,i)}(nR);const rce=pm(nR),nce=iQ({__proto__:null,default:rce},[nR]),Io={node:"node",material:"material",camera:"camera",light:"light"},Ku="KHR_animation_pointer",oce={CUBICSPLINE:void 0,LINEAR:da,STEP:gc},Yj=Ot.findNode;let Kj=!1;class ace{constructor(e){this.parser=e,this.name=Ku,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Kj||(Kj=!0,Ot.findNode=function(e,t){if(t.startsWith(".materials.")){const s=t.substring(11).substring(t.indexOf(".")),r=s.indexOf("."),n=r<0?s:s.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===n||a.material.name===n)&&(o=a.material,o!==null&&(s.endsWith(".map")?o=o.map:s.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const s=t.split(".");let r;for(let n=1;n<s.length;n++){const o=s[n];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const n=Yj(e,s[2]);return n||console.warn(Ku+": Property binding not found",t,e,e.name,s),n}return r}return Yj(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,s=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",s)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,s=t.extensions&&t.extensions[Ku]&&t.path&&t.path==="pointer";if(!s)return null;let r,n=Io.node,o;if(s){const l=t.extensions[Ku];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?n=Io.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=Io.light:c.startsWith("/cameras/")&&(n=Io.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case Io.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case Io.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case Io.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case Io.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(c=u.resolvePath(c)),t.extensions[Ku].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return n===Io.node?a=this.parser.getDependency("node",o):n===Io.material?a=this.parser.getDependency("material",o):n===Io.light?a=this.parser.getDependency("light",o):n===Io.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",n),a}createAnimationTracksWithAnimationPointer(e,t,s,r,n){if(!(n.extensions&&n.extensions[Ku]&&n.path&&n.path==="pointer"))return null;let o=n.extensions[Ku].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof zh&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",u(this.parser));return a}u(this.parser);function u(d){o=l.join(".");let p;switch(s.itemSize){case 1:p=xc;break;case 2:case 3:p=cl;break;case 4:o.endsWith(".quaternion")?p=ga:p=vy;break}const f=r.interpolation!==void 0?oce[r.interpolation]:da;let m=d._getArrayFromAccessor(s);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&s.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let b=0,y=m.length/4;b<y;b+=1)v[b]=m[b*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let s="";return t==="node"?s=e.substring(7):t==="material"?s=e.substring(11):t==="light"?s=e.substring(39):t==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const t=this,s=this.parser.json,r=this.parser,n=s.animations[e],o=n.name?n.name:"animation_"+e,a=[],l=[],c=[],u=[],d=[];for(let p=0,f=n.channels.length;p<f;p++){const m=n.channels[p],A=n.samplers[m.sampler],v=m.target,g=n.parameters!==void 0?n.parameters[A.input]:A.input,b=n.parameters!==void 0?n.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(m);y||(y=t.loadAnimationTargetFromChannel(m)),a.push(y),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],b=[];for(let y=0,_=f.length;y<_;y++){const S=f[y],M=m[y],I=A[y],R=v[y],E=g[y];if(S===void 0)continue;S.updateMatrix&&(S.updateMatrix(),S.matrixAutoUpdate=!0);let C=t.createAnimationTracksWithAnimationPointer(S,M,I,R,E);if(C||(C=r._createAnimationTracks(S,M,I,R,E)),C)for(let z=0;z<C.length;z++)b.push(C[z])}return new zr(o,void 0,b)})}}const lce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:ace},Symbol.toStringTag,{value:"Module"}));export{kle as $physicsKey,di as ActionBuilder,kE as ActionCollection,Ko as ActionModel,AL as Addressables,ig as AlignmentConstraint,Zd as AmbientMode,Ln as Animation,fu as AnimationCurve,lb as AnimationExtension,Zb as AnimationTrackHandler,Tr as Animator,Wc as AnimatorConditionMode,yh as AnimatorController,LE as AnimatorControllerParameterType,cb as AnimatorStateInfo,Lg as Antialiasing,xL as Application,U0 as ApplicationEvents,vO as AssetDatabase,js as AssetReference,Da as AttachedObject,jb as AttachedObjectEvents,e_ as AudioExtension,_u as AudioListener,hs as AudioSource,Dg as AudioTrackHandler,wu as AvatarBlink_Simple,Up as AvatarEyeLook_Rotation,Ab as AvatarLoader,Ir as AvatarMarker,vb as AvatarModel,cg as Avatar_Brain_LookAt,Ug as Avatar_MouthShapes,XM as Avatar_MustacheShake,Jr as Avatar_POI,bp as Axes,Fp as AxesHelper,la as BaseUIComponent,JM as BasicIKConstraint,i_ as BehaviorExtension,Kr as BehaviorModel,Ie as Behaviour,Su as Bloom,Ng as BoxCollider,yu as BoxGizmo,Ma as BoxHelperComponent,Xl as Button,lp as CallInfo,Bi as Camera,lr as Canvas,sh as CanvasGroup,eh as CapsuleCollider,Qp as ChangeMaterialOnClick,Mu as ChangeTransformOnClick,Tu as CharacterController,Kl as CharacterControllerInput,Wg as ChromaticAberration,va as CircularBuffer,Yb as ClearFlags,ka as ClipExtrapolation,Oa as Collider,bj as Collision,bb as CollisionDetectionMode,nh as ColorAdjustments,Iu as ColorBySpeedModule,Yg as ColorOverLifetimeModule,Fc as Component,Sm as ComponentEvents,Cm as ComponentLifecycleEvents,Gk as ConnectionEvents,yj as ContactPoint,Ft as Context,vY as ContextArgs,Qr as ContextEvent,Pi as ContextRegistry,$b as ControlTrackHandler,zl as ControllerEvents,Mp as ControllerType,hh as CustomBranding,Xo as CustomShader,L0 as DefaultReflectionMode,mT as Deletable,A_ as DeleteBox,na as DepthOfField,y_ as DeviceFlag,gT as DocumentExtension,qp as DragControls,Zg as DropListener,Du as Duplicatable,Y0 as EXTENSION_NAME,Ua as EmissionModule,Hp as EmphasizeOnClick,KC as EngineLoadingView,sr as EventList,Z0 as EventListEvent,zn as EventSystem,x_ as EventTrigger,CE as FieldWithDefault,M3 as FileSpawnModel,E3 as File_Event,CT as FixedJoint,ET as FlyControls,Jp as Fog,vn as FrameEvent,c0 as GENERATOR,te as GameObject,Rl as Gizmos,tv as GltfExport,kT as GltfExportBox,qu as GltfLoadEvent,cj as GltfLoadEventType,oh as Gradient,Cu as Graphic,zM as GraphicRaycaster,No as Graphics,ef as GridHelper,aT as GridLayoutGroup,ku as GroundProjectedEnv,Gc as GroupActionModel,wO as HideFlags,hT as HideOnStart,$g as HingeJoint,oT as HorizontalLayoutGroup,h9 as HostData,zp as Image,O0 as ImageReference,yL as ImageReferenceSerializer,lh as InheritVelocityModule,a2 as Input,ya as InputEvents,Lu as InputField,Cn as InstancingUtil,Yk as InstantiateEvent,kr as InstantiateIdProvider,xa as InstantiateOptions,Ap as Interactable,K8 as JoinedRoomResponse,Gy as KeyEventArgs,rv as LODGroup,Uu as LODModel,J8 as LeftRoomResponse,wn as Light,_L as LightData,Cs as LimitVelocityOverLifetimeModule,PY as LoadingElementOptions,FT as LogStats,lo as LogType,Fu as LookAt,ng as LookAtConstraint,hr as MainModule,HM as MarkerType,Gg as MaskableGraphic,st as Mathf,zg as MeshCollider,ib as MeshRenderer,ht as MinMaxCurve,xn as MinMaxGradient,qo as NEEDLE_progressive,Pi as NeedleEngine,qI as NeedleEngineHTMLElement,VI as NeedleGltfLoader,y0 as NeedlePatchesKey,I_ as NestedGltf,Vk as NetworkConnection,Bu as Networking,gi as NoiseModule,Ql as ObjectRaycaster,jz as ObjectUtils,Nu as OffsetConstraint,tf as OpenURL,Wi as OrbitControls,Np as Outline,Hk as OwnershipEvent,l0 as OwnershipModel,th as Padding,qg as ParticleBurst,V_ as ParticleSubEmitter,Ms as ParticleSystem,So as ParticleSystemRenderer,jk as PeerNetworking,_2 as Physics,Ia as PhysicsMaterialCombine,fv as PixelationEffect,rh as PlayAnimationOnClick,Vp as PlayAudioOnClick,xu as PlayableDirector,Ju as PlayerColor,Xu as PlayerState,oj as PlayerStateEvent,vx as PlayerSync,UL as PlayerView,FL as PlayerViewManager,lc as PointerEventData,o2 as PointerType,Rr as PostProcessingEffect,X_ as PostProcessingHandler,Xp as PreliminaryAction,Hg as PreliminaryTrigger,yI as PrimitiveType,_U as ProgressiveLoadingInfo,Uy as PromiseAllWithErrors,zD as PromiseErrorResult,Ai as RGBAColor,Gv as RapierPhysics,a_ as RawImage,zo as RaycastOptions,Pp as Raycaster,iT as Rect,en as RectTransform,hp as ReflectionProbe,ab as RegisteredAnimationInfo,$l as RemoteSkybox,cp as RenderTexture,MU as RenderTextureSerializer,Ui as Renderer,bL as RendererData,$m as RendererLightmap,Ei as Rigidbody,ds as RigidbodyConstraints,Zi as RoomEvents,Vn as RotationBySpeedModule,wo as RotationOverLifetimeModule,q0 as SceneLightSettings,rn as SceneSwitcher,yv as ScreenCapture,ec as ScreenSpaceAmbientOcclusion,aa as ScreenSpaceAmbientOcclusionN8,mn as SendQueue,Gp as SetActiveOnClick,xv as ShadowCatcher,ps as ShapeModule,Rg as SignalAsset,Op as SignalReceiver,kp as SignalReceiverEvent,kg as SignalTrackHandler,tT as Size,tn as SizeBySpeedModule,ah as SizeOverLifetimeModule,EE as SkinnedMeshRenderer,fh as SmoothFollow,wI as SpatialHtml,Cv as SpatialTrigger,ja as SpatialTriggerReceiver,ex as SpectatorCamera,Fg as SphereCollider,b2 as SphereIntersection,_j as SphereOverlapResult,tc as Sprite,cf as SpriteData,Qa as SpriteRenderer,Ev as SpriteSheet,LK as StateMachineBehaviour,pv as SubEmitterSystem,sx as SyncedCamera,mh as SyncedRoom,Jc as SyncedTransform,dT as TapGestureTrigger,zb as TeleportTarget,BI as TestRunner,DI as TestSimulateUserData,sn as Text,g_ as TextBuilder,Jg as TextExtension,ur as TextureSheetAnimationModule,Ga as TiltShiftEffect,w2 as Time,Tv as ToneMapping,Pg as TrackHandler,Qn as TrackType,zi as TrailModule,mp as TransformData,Gu as TransformGizmo,An as TriggerBuilder,pu as TriggerModel,Y as TypeStore,Ep as UIRaycastUtils,bg as UIRootComponent,fo as USDObject,Xn as USDZExporter,ch as USDZText,v_ as USDZUIExtension,EC as Upload_Result,TU as UriSerializer,yp as UsageMarker,Z8 as UserJoinedOrLeftRoomModel,Ic as VERSION,jl as VRUserState,DE as VariantAction,Xi as VelocityOverLifetimeModule,nT as VerticalLayoutGroup,Br as VideoPlayer,Ca as ViewDevice,Hu as Vignette,Vg as VisibilityAction,ac as Voip,cx as Volume,Tt as VolumeParameter,Og as VolumeProfile,boe as WaitForFrames,kz as WaitForSeconds,oc as Watch,Mg as WebAR,ux as WebARCameraBackground,Zo as WebARSessionRoot,Ct as WebXR,Yc as WebXRAvatar,ws as WebXRController,Mi as WebXREvent,px as WebXRImageTracking,ic as WebXRImageTrackingModel,Wu as WebXRPlaneTracking,wg as WebXRSync,Vu as WebXRTrackedImage,Fn as XRFlag,mx as XRGrabModel,NI as XRGrabRendering,Qb as XRRig,Vm as XRSessionMode,Un as XRState,us as XRStateFlag,zI as __Ignore,xO as __internalNotifyObjectDestroyed,_l as activeInHierarchyFieldName,FD as addAttributeChangeCallback,F7 as addCustomExtension,T3 as addFile,I3 as addFileFromUrl,_le as addGltfLoadEventListener,Rc as addNewComponent,A0 as addPatch,g0 as apply,Dle as applyHMRChanges,Zk as beginListenDestroy,R3 as beginListenFileSpawn,$k as beginListenInstantiate,DS as binaryIdentifierCasts,gY as build_scene_functions,su as builtinComponentKeyName,qC as calculateProgress01,G7 as colorSerializer,$0 as componentSerializer,A2 as copyTexture,WI as createGLTFLoader,nF as createMotion,Hr as debugNet,xm as debugOwner,ky as deepClone,hm as delay,Qy as deserializeObject,xl as destroy,oO as destroyComponentInstance,i3 as detectARSupport,s3 as detectVRSupport,Ci as disposeObjectResources,mL as download,TC as download_file,wm as editorGuidKeyName,fI as effectsOrder,q7 as eventListSerializer,km as findByGuid,cO as findObjectOfType,hO as findObjectsOfType,aC as findResourceUsers,ou as foreachComponent,hC as foreachComponentEnumerator,r8 as forward,p0 as generateSeed,Vd as getComponent,Mm as getComponentInChildren,Im as getComponentInParent,Em as getComponents,Tm as getComponentsInChildren,m0 as getComponentsInParent,g6 as getIp,v6 as getIpAndLocation,m6 as getIpCloudflare,Go as getLoader,f0 as getOrAddComponent,oe as getParam,h6 as getPath,W8 as getPeerOptions,JS as getPeerjsInstance,E9 as getResourceUserCount,lm as getUrlParams,o8 as getWorldDirection,f2 as getWorldEuler,_t as getWorldPosition,Ds as getWorldQuaternion,Vy as getWorldRotation,Js as getWorldScale,GC as hasIndieLicense,ep as hasProLicense,MC as hash,Om as instantiate,SO as isActiveInHierarchy,Xd as isActiveSelf,v2 as isAnimationAction,a6 as isDebugMode,cC as isDestroyed,oi as isDevEnvironment,S9 as isDisposed,jD as isHostedOnGlitch,Ile as isHotReloading,jr as isLocalNetwork,pl as isMobileDevice,Ly as isMozillaXR,p6 as isQuest,yO as isResourceTrackingEnabled,fl as isSafari,S0 as isUsingInstancing,um as isiOS,XI as loadSync,Xy as logHierarchy,e8 as lookAtInverse,c6 as makeId,kD as makeIdFromRandomWords,CO as markAsInstancedRendered,iC as moveComponentInstance,o6 as nameof,Dy as nameofFactory,EU as objectSerializer,uj as parseSync,BJ as prefix,RD as pushState,PD as randomNumber,Ky as registerBinaryType,H0 as registerComponent,xE as registerComponentExtension,xo as registerCustomEffectType,wU as registerExtensions,Rle as registerHotReloadType,IC as registerLoader,tO as registerPrefabProvider,j6 as registerType,LD as relativePathPrefix,ND as removeAttributeChangeCallback,tC as removeComponent,N7 as removeCustomExtension,xle as removeGltfLoadEventListener,_9 as removePatch,dl as resolveUrl,OD as sanitizeString,Jle as saveImage,Kle as screenshot,Jk as sendDestroyed,x as serializable,s2 as serializeObject,ap as serializeable,Dm as setActive,y6 as setAllowOverlayMessages,MO as setDestroyed,O6 as setDevEnvironment,oC as setDisposable,cm as setOrAddParamsToUrl,l6 as setParam,ID as setParamWithoutReload,X8 as setPeerOptions,w9 as setResourceTrackingEnabled,hS as setState,m2 as setWorldEuler,ys as setWorldPosition,Qd as setWorldPositionXYZ,pn as setWorldQuaternion,c2 as setWorldQuaternionXYZW,g2 as setWorldRotation,Wy as setWorldRotationXYZ,IS as setWorldScale,k6 as showBalloonError,ls as showBalloonMessage,wr as showBalloonWarning,yS as showDebugConsole,l2 as slerp,d0 as syncDestroy,vI as syncField,$S as syncInstantiate,l8 as textureToCanvas,E2 as tryCastBinary,Nd as tryFindObject,pj as tryFindObjectByName,Sle as tryFindScript,M2 as tryGetGuid,Ple as unregisterHotReloadType,UD as unwatchWrite,fL as upload_file,or as validate,uS as watchWrite};
6639
+ `,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e,t){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,t,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Lv),this.classList.remove(Uv);const e=this.getAROverlayContainer();fr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Lv),e.classList.remove(Uv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,NL))}onSetupVR(){this.classList.remove(Lv),this.classList.remove(Uv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,mj))}onSetupDesktop(){this.classList.remove(Lv),this.classList.add(Uv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Lv),e.classList.add(Uv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,gj))}setupElementsForMode(e,t,s=null){var r,n;if(!(e===((n=(r=this._context)==null?void 0:r.renderer)==null?void 0:n.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const o of Cle)e.classList.contains(o)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const s=this.children[t];s.style&&e(s)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(fr&&console.log("using custom draco decoder path",e),nU(e));const t=this.getAttribute("dracoDecoderType");t&&(fr&&console.log("using custom draco decoder type",t),oU(t));const s=this.getAttribute("ktx2DecoderPath");s&&(fr&&console.log("using custom ktx2 decoder path",s),aU(s))}}typeof window<"u"&&!window.customElements.get(fj)&&window.customElements.define(fj,qI);function Mle(i){const e=i.split("/");let t=e[e.length-1];const s=t.indexOf("?");return s>0&&(t=t.substring(0,s)),decodeURIComponent(t)}const Tle=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:qI},Symbol.toStringTag,{value:"Module"})),Ax=oe("debughotreload");let Fv=!1;const Nv=new Map;function Ile(){return Fv}function Rle(i){var e;if(Fv)return;const t=i.constructor.name;Nv.has(t)?(e=Nv.get(t))==null||e.push(i):Nv.set(t,[i])}function Ple(i){if(Fv)return;const e=i.constructor.name,t=Nv.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let vj=!1;function Ble(){if(Ax||vj)return;vj=!0;const i=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}}i.apply(console,e)}}function Dle(i){Ax&&console.log("[HMR] Apply changes",i,Object.keys(i)),Ble();for(const e of Object.keys(i))try{Fv=!0;const t=Y.get(e);if(!t){Ax&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=Nv.get(s.name);let n="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?n+=" x"+o:n+=" - no instances",console.log(n);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(s.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new s,u=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&wl(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],b=g.name,y="bound ";if(b===y)continue;const _=g.name.substring(y.length),S=s.prototype[_];S&&(d[v]=S.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&dC(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(Ax)console.error(t);else return!1}finally{Fv=!1,ml(lo.Log,"Script changes applied (HMR)")}return!0}const kle=Symbol("object"),Aj=new va(()=>new w,20);class yj{constructor(e,t,s,r,n){h(this,"_point"),h(this,"_normal"),h(this,"distance"),h(this,"impulse"),h(this,"friction"),this._point=e,this.distance=t,this._normal=s,this.impulse=r,this.friction=n}get point(){return Aj.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Aj.get().set(this._normal.x,this._normal.y,this._normal.z)}}class bj{constructor(e,t,s){h(this,"contacts"),h(this,"me"),h(this,"_collider"),h(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class _j{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const zv=new Array(32).fill(void 0);zv.push(void 0,null,!0,!1);let xj;zv.length;function wj(){return xj.byteLength,xj}const Ole=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}Ole.decode();let Sj,Cj,jv=32;function Ej(i){if(jv==1)throw new Error("out of js stack");return zv[--jv]=i,jv}function Lle(){return Sj.byteLength,Sj}function Ule(){return Cj.byteLength,Cj}let Zn=0;function Yu(i,e){const t=e(4*i.length);return Lle().set(i,t/4),Zn=i.length,t}function yx(i,e){const t=e(4*i.length);return Ule().set(i,t/4),Zn=i.length,t}class Qx{static __wrap(e){const t=Object.create(Qx.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();ze.__wbg_raweventqueue_free(e)}constructor(e){const t=ze.raweventqueue_new(e);return Qx.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,Ej(e))}finally{zv[jv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,Ej(e))}finally{zv[jv++]=void 0}}clear(){ze.raweventqueue_clear(this.ptr)}}class Ka{static __wrap(e){const t=Object.create(Ka.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();ze.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,dt),vt(t,dt);const s=ze.rawgenericjoint_spherical(e.ptr,t.ptr);return Ka.__wrap(s)}static prismatic(e,t,s,r,n,o){vt(e,dt),vt(t,dt),vt(s,dt);const a=ze.rawgenericjoint_prismatic(e.ptr,t.ptr,s.ptr,r,n,o);return a===0?void 0:Ka.__wrap(a)}static fixed(e,t,s,r){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,Xs);const n=ze.rawgenericjoint_fixed(e.ptr,t.ptr,s.ptr,r.ptr);return Ka.__wrap(n)}static revolute(e,t,s){vt(e,dt),vt(t,dt),vt(s,dt);const r=ze.rawgenericjoint_revolute(e.ptr,t.ptr,s.ptr);return r===0?void 0:Ka.__wrap(r)}}class lR{static __wrap(e){const t=Object.create(lR.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();ze.__wbg_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class cR{static __wrap(e){const t=Object.create(cR.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();ze.__wbg_rawrayintersection_free(e)}normal(){const e=ze.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}featureType(){return ze.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const s=ze.__wbindgen_add_to_stack_pointer(-16);ze.rawrayintersection_featureId(s,this.ptr);var e=wj()[s/4+0],t=wj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class Xs{static __wrap(e){const t=Object.create(Xs.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();ze.__wbg_rawrotation_free(e)}constructor(e,t,s,r){const n=ze.rawrotation_new(e,t,s,r);return Xs.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return Xs.__wrap(e)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}get y(){return ze.rawrotation_y(this.ptr)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}get w(){return ze.rawrotation_w(this.ptr)}}class Qt{static __wrap(e){const t=Object.create(Qt.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();ze.__wbg_rawshape_free(e)}static cuboid(e,t,s){const r=ze.rawshape_cuboid(e,t,s);return Qt.__wrap(r)}static roundCuboid(e,t,s,r){const n=ze.rawshape_roundCuboid(e,t,s,r);return Qt.__wrap(n)}static ball(e){const t=ze.rawshape_ball(e);return Qt.__wrap(t)}static capsule(e,t){const s=ze.rawshape_capsule(e,t);return Qt.__wrap(s)}static cylinder(e,t){const s=ze.rawshape_cylinder(e,t);return Qt.__wrap(s)}static roundCylinder(e,t,s){const r=ze.rawshape_roundCylinder(e,t,s);return Qt.__wrap(r)}static cone(e,t){const s=ze.rawshape_cone(e,t);return Qt.__wrap(s)}static roundCone(e,t,s){const r=ze.rawshape_roundCone(e,t,s);return Qt.__wrap(r)}static polyline(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_trimesh(s,r,n,o);return Qt.__wrap(a)}static heightfield(e,t,s,r){const n=Yu(s,ze.__wbindgen_malloc),o=Zn;vt(r,dt);const a=ze.rawshape_heightfield(e,t,n,o,r.ptr);return Qt.__wrap(a)}static segment(e,t){vt(e,dt),vt(t,dt);const s=ze.rawshape_segment(e.ptr,t.ptr);return Qt.__wrap(s)}static triangle(e,t,s){vt(e,dt),vt(t,dt),vt(s,dt);const r=ze.rawshape_triangle(e.ptr,t.ptr,s.ptr);return Qt.__wrap(r)}static roundTriangle(e,t,s,r){vt(e,dt),vt(t,dt),vt(s,dt);const n=ze.rawshape_roundTriangle(e.ptr,t.ptr,s.ptr,r);return Qt.__wrap(n)}static convexHull(e){const t=Yu(e,ze.__wbindgen_malloc),s=Zn,r=ze.rawshape_convexHull(t,s);return r===0?void 0:Qt.__wrap(r)}static roundConvexHull(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=ze.rawshape_roundConvexHull(s,r,t);return n===0?void 0:Qt.__wrap(n)}static convexMesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=Zn,n=yx(t,ze.__wbindgen_malloc),o=Zn,a=ze.rawshape_convexMesh(s,r,n,o);return a===0?void 0:Qt.__wrap(a)}static roundConvexMesh(e,t,s){const r=Yu(e,ze.__wbindgen_malloc),n=Zn,o=yx(t,ze.__wbindgen_malloc),a=Zn,l=ze.rawshape_roundConvexMesh(r,n,o,a,s);return l===0?void 0:Qt.__wrap(l)}castShape(e,t,s,r,n,o,a,l){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,Qt),vt(n,dt),vt(o,Xs),vt(a,dt);const c=ze.rawshape_castShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o.ptr,a.ptr,l);return c===0?void 0:uR.__wrap(c)}intersectsShape(e,t,s,r,n){return vt(e,dt),vt(t,Xs),vt(s,Qt),vt(r,dt),vt(n,Xs),ze.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr)!==0}contactShape(e,t,s,r,n,o){vt(e,dt),vt(t,Xs),vt(s,Qt),vt(r,dt),vt(n,Xs);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:hR.__wrap(a)}containsPoint(e,t,s){return vt(e,dt),vt(t,Xs),vt(s,dt),ze.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,s.ptr)!==0}projectPoint(e,t,s,r){vt(e,dt),vt(t,Xs),vt(s,dt);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return lR.__wrap(n)}intersectsRay(e,t,s,r,n){return vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt),ze.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n)!==0}castRay(e,t,s,r,n,o){return vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt),ze.rawshape_castRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o)}castRayAndGetNormal(e,t,s,r,n,o){vt(e,dt),vt(t,Xs),vt(s,dt),vt(r,dt);const a=ze.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o);return a===0?void 0:cR.__wrap(a)}}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();ze.__wbg_rawshapecontact_free(e)}distance(){return ze.rawshapecontact_distance(this.ptr)}point1(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}point2(){const e=ze.rawshapecontact_point2(this.ptr);return dt.__wrap(e)}normal1(){const e=ze.rawshapecontact_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=ze.rawshapecontact_normal2(this.ptr);return dt.__wrap(e)}}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();ze.__wbg_rawshapetoi_free(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}witness1(){const e=ze.rawrayintersection_normal(this.ptr);return dt.__wrap(e)}witness2(){const e=ze.rawshapetoi_witness2(this.ptr);return dt.__wrap(e)}normal1(){const e=ze.rawshapetoi_normal1(this.ptr);return dt.__wrap(e)}normal2(){const e=ze.rawshapetoi_normal2(this.ptr);return dt.__wrap(e)}}class dt{static __wrap(e){const t=Object.create(dt.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();ze.__wbg_rawvector_free(e)}static zero(){const e=ze.rawvector_zero();return dt.__wrap(e)}constructor(e,t,s){const r=ze.rawvector_new(e,t,s);return dt.__wrap(r)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}set x(e){ze.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return ze.rawrotation_y(this.ptr)}set y(e){ze.rawvector_set_y(this.ptr,e)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}set z(e){ze.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=ze.rawvector_xyz(this.ptr);return dt.__wrap(e)}yxz(){const e=ze.rawvector_yxz(this.ptr);return dt.__wrap(e)}zxy(){const e=ze.rawvector_zxy(this.ptr);return dt.__wrap(e)}xzy(){const e=ze.rawvector_xzy(this.ptr);return dt.__wrap(e)}yzx(){const e=ze.rawvector_yzx(this.ptr);return dt.__wrap(e)}zyx(){const e=ze.rawvector_zyx(this.ptr);return dt.__wrap(e)}}class Fle{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class De{static new(e,t,s){return new Fle(e,t,s)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return De.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=De.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 Mj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class ki{static identity(){return new Mj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Mj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Xs(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 Qv,Va,Tj,Mo,YI,Zt,bx,pf,KI,JI,Ij,Rj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Qv||(Qv={}));class Nle{constructor(e,t,s){this.rawSet=e,this.colliderSet=t,this.handle=s}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,s,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,s,r)}restrictTranslations(e,t,s,r){this.setEnabledTranslations(e,t,s,r)}setEnabledRotations(e,t,s,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,s,r)}restrictRotations(e,t,s,r){this.setEnabledRotations(e,t,s,r)}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 De.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return ki.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return De.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return ki.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=De.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,s,t),s.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 s=De.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,s,t),s.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 De.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return De.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,s,r,n){let o=De.intoRaw(t),a=De.intoRaw(s),l=ki.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,n),o.free(),a.free(),l.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 s=De.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=De.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=De.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=De.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=De.intoRaw(e),n=De.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=De.intoRaw(e),n=De.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,n,s),r.free(),n.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Spherical=3]="Spherical"})(Va||(Va={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(Tj||(Tj={}));class bf{constructor(){}static fixed(e,t,s,r){let n=new bf;return n.anchor1=e,n.anchor2=s,n.frame1=t,n.frame2=r,n.jointType=Va.Fixed,n}static spherical(e,t){let s=new bf;return s.anchor1=e,s.anchor2=t,s.jointType=Va.Spherical,s}static prismatic(e,t,s){let r=new bf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Prismatic,r}static revolute(e,t,s){let r=new bf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Revolute,r}intoRaw(){let e,t,s=De.intoRaw(this.anchor1),r=De.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Va.Fixed:let l=ki.intoRaw(this.frame1),c=ki.intoRaw(this.frame2);t=Ka.fixed(s,l,r,c),l.free(),c.free();break;case Va.Prismatic:e=De.intoRaw(this.axis),this.limitsEnabled&&(n=!0,o=this.limits[0],a=this.limits[1]),t=Ka.prismatic(s,r,e,n,o,a),e.free();break;case Va.Spherical:t=Ka.spherical(s,r);break;case Va.Revolute:e=De.intoRaw(this.axis),t=Ka.revolute(s,r,e),e.free()}return s.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(Mo||(Mo={}));class Yv{constructor(e,t,s,r,n){this.distance=e,this.point1=t,this.point2=s,this.normal1=r,this.normal2=n}static fromRaw(e){if(!e)return null;const t=new Yv(e.distance(),De.fromRaw(e.point1()),De.fromRaw(e.point2()),De.fromRaw(e.normal1()),De.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(YI||(YI={}));class Gx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Gx(De.fromRaw(e.point()),e.isInside());return e.free(),t}}class zle{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 Hx{constructor(e,t,s,r){this.featureType=YI.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),s!==void 0&&(this.featureType=s)}static fromRaw(e){if(!e)return null;const t=new Hx(e.toi(),De.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Kv{constructor(e,t,s,r,n){this.toi=e,this.witness1=t,this.witness2=s,this.normal1=r,this.normal2=n}static fromRaw(e,t){if(!t)return null;const s=new Kv(t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),s}}class dR extends Kv{constructor(e,t,s,r,n,o){super(t,s,r,n,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const s=new dR(e.get(t.colliderHandle()),t.toi(),De.fromRaw(t.witness1()),De.fromRaw(t.witness2()),De.fromRaw(t.normal1()),De.fromRaw(t.normal2()));return t.free(),s}}class mr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case Zt.Ball:return new ZI(e.coRadius(t));case Zt.Cuboid:return r=e.coHalfExtents(t),new Pj(r.x,r.y,r.z);case Zt.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new Bj(r.x,r.y,r.z,n);case Zt.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new Dj(l,c);case Zt.Segment:return o=e.coVertices(t),new kj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Uj(o,a);case Zt.Triangle:return o=e.coVertices(t),new Oj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new Lj(De.new(o[0],o[1],o[2]),De.new(o[3],o[4],o[5]),De.new(o[6],o[7],o[8]),n);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new Fj(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new Nj(p,f,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new $I(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new eR(o,a,n);case Zt.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new zj(l,c);case Zt.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new jj(l,c,n);case Zt.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new Qj(l,c);case Zt.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Gj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=De.intoRaw(e),u=ki.intoRaw(t),d=De.intoRaw(s),p=De.intoRaw(n),f=ki.intoRaw(o),m=De.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Kv.fromRaw(null,A.castShape(c,u,d,v,p,f,m,l));return c.free(),u.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g}intersectsShape(e,t,s,r,n){let o=De.intoRaw(e),a=ki.intoRaw(t),l=De.intoRaw(r),c=ki.intoRaw(n),u=this.intoRaw(),d=s.intoRaw(),p=u.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),u.free(),d.free(),p}contactShape(e,t,s,r,n,o){let a=De.intoRaw(e),l=ki.intoRaw(t),c=De.intoRaw(r),u=ki.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Yv.fromRaw(d.contactShape(a,l,p,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p.free(),f}containsPoint(e,t,s){let r=De.intoRaw(e),n=ki.intoRaw(t),o=De.intoRaw(s),a=this.intoRaw(),l=a.containsPoint(r,n,o);return r.free(),n.free(),o.free(),a.free(),l}projectPoint(e,t,s,r){let n=De.intoRaw(e),o=ki.intoRaw(t),a=De.intoRaw(s),l=this.intoRaw(),c=Gx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=De.intoRaw(t),o=ki.intoRaw(s),a=De.intoRaw(e.origin),l=De.intoRaw(e.dir),c=this.intoRaw(),u=c.intersectsRay(n,o,a,l,r);return n.free(),o.free(),a.free(),l.free(),c.free(),u}castRay(e,t,s,r,n){let o=De.intoRaw(t),a=ki.intoRaw(s),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,l,c,r,n);return o.free(),a.free(),l.free(),c.free(),u.free(),d}castRayAndGetNormal(e,t,s,r,n){let o=De.intoRaw(t),a=ki.intoRaw(s),l=De.intoRaw(e.origin),c=De.intoRaw(e.dir),u=this.intoRaw(),d=Hx.fromRaw(u.castRayAndGetNormal(o,a,l,c,r,n));return o.free(),a.free(),l.free(),c.free(),u.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class ZI extends mr{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class Pj extends mr{constructor(e,t,s){super(),this.type=Zt.Cuboid,this.halfExtents=De.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class Bj extends mr{constructor(e,t,s,r){super(),this.type=Zt.RoundCuboid,this.halfExtents=De.new(e,t,s),this.borderRadius=r}intoRaw(){return Qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class Dj extends mr{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class kj extends mr{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class Oj extends mr{constructor(e,t,s){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=De.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class Lj extends mr{constructor(e,t,s,r){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=s,this.borderRadius=r}intoRaw(){let e=De.intoRaw(this.a),t=De.intoRaw(this.b),s=De.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Uj extends mr{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Qt.polyline(this.vertices,this.indices)}}class Fj extends mr{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class $I extends mr{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Qt.convexMesh(this.vertices,this.indices):Qt.convexHull(this.vertices)}}class eR extends mr{constructor(e,t,s){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=s}intoRaw(){return this.indices?Qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Qt.roundConvexHull(this.vertices,this.borderRadius)}}class Nj extends mr{constructor(e,t,s,r){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=s,this.scale=r}intoRaw(){let e=De.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class zj extends mr{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class jj extends mr{constructor(e,t,s){super(),this.type=Zt.RoundCylinder,this.borderRadius=s,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class Qj extends mr{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Gj extends mr{constructor(e,t,s){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=s}intoRaw(){return Qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"})(bx||(bx={}));class jle{constructor(e,t,s,r){this.colliderSet=e,this.handle=t,this._parent=s,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=mr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return De.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return ki.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,s,r){let n=De.intoRaw(t),o=De.intoRaw(s),a=ki.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,n,o,a),n.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 De.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 De.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=De.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=De.intoRaw(e),r=Gx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=De.intoRaw(e.origin),r=De.intoRaw(e.dir),n=this.colliderSet.raw.coIntersectsRay(this.handle,s,r,t);return s.free(),r.free(),n}castShape(e,t,s,r,n,o){let a=De.intoRaw(e),l=De.intoRaw(s),c=ki.intoRaw(r),u=De.intoRaw(n),d=t.intoRaw(),p=Kv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,l,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p}castCollider(e,t,s,r){let n=De.intoRaw(e),o=De.intoRaw(s),a=dR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,n,t.handle,o,r));return n.free(),o.free(),a}intersectsShape(e,t,s){let r=De.intoRaw(t),n=ki.intoRaw(s),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,n);return r.free(),n.free(),o.free(),a}contactShape(e,t,s,r){let n=De.intoRaw(t),o=ki.intoRaw(s),a=e.intoRaw(),l=Yv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Yv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=De.intoRaw(e.origin),n=De.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,n,t,s);return r.free(),n.free(),o}castRayAndGetNormal(e,t,s){let r=De.intoRaw(e.origin),n=De.intoRaw(e.dir),o=Hx.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,n,t,s));return r.free(),n.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(pf||(pf={}));class Qi{constructor(e){this.shape=e,this.massPropsMode=pf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=ki.identity(),this.translation=De.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Mo.Average,this.restitutionCombineRule=Mo.Average,this.activeCollisionTypes=bx.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=De.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=De.zeros(),this.angularInertiaLocalFrame=ki.identity()}static ball(e){const t=new ZI(e);return new Qi(t)}static capsule(e,t){const s=new Dj(e,t);return new Qi(s)}static segment(e,t){const s=new kj(e,t);return new Qi(s)}static triangle(e,t,s){const r=new Oj(e,t,s);return new Qi(r)}static roundTriangle(e,t,s,r){const n=new Lj(e,t,s,r);return new Qi(n)}static polyline(e,t){const s=new Uj(e,t);return new Qi(s)}static trimesh(e,t){const s=new Fj(e,t);return new Qi(s)}static cuboid(e,t,s){const r=new Pj(e,t,s);return new Qi(r)}static roundCuboid(e,t,s,r){const n=new Bj(e,t,s,r);return new Qi(n)}static heightfield(e,t,s,r){const n=new Nj(e,t,s,r);return new Qi(n)}static cylinder(e,t){const s=new zj(e,t);return new Qi(s)}static roundCylinder(e,t,s){const r=new jj(e,t,s);return new Qi(r)}static cone(e,t){const s=new Qj(e,t);return new Qi(s)}static roundCone(e,t,s){const r=new Gj(e,t,s);return new Qi(r)}static convexHull(e){const t=new $I(e,null);return new Qi(t)}static convexMesh(e,t){const s=new $I(e,t);return new Qi(s)}static roundConvexHull(e,t){const s=new eR(e,null,t);return new Qi(s)}static roundConvexMesh(e,t,s){const r=new eR(e,t,s);return new Qi(r)}setTranslation(e,t,s){if(typeof e!="number"||typeof t!="number"||typeof s!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:s},this}setRotation(e){return ki.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=pf.Density,this.density=e,this}setMass(e){return this.massPropsMode=pf.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=pf.MassProps,this.mass=e,De.copy(this.centerOfMass,t),De.copy(this.principalAngularInertia,s),ki.copy(this.angularInertiaLocalFrame,r),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(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(KI||(KI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(JI||(JI={}));class Qle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return De.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return De.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Gle{constructor(e,t){this.raw=t||new Qx(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Qle;this.raw.drainContactForceEvents(s=>{t.raw=s,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(Ij||(Ij={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Rj||(Rj={}));for(var cce={byteLength:function(i){var e=Hj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Hj(i),r=s[0],n=s[1],o=new Hle(function(c,u,d){return 3*(u+d)/4-d}(0,r,n)),a=0,l=n>0?r-4:r;for(t=0;t<l;t+=4)e=To[i.charCodeAt(t)]<<18|To[i.charCodeAt(t+1)]<<12|To[i.charCodeAt(t+2)]<<6|To[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=To[i.charCodeAt(t)]<<2|To[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=To[i.charCodeAt(t)]<<10|To[i.charCodeAt(t+1)]<<4|To[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,s=t%3,r=[],n=16383,o=0,a=t-s;o<a;o+=n)r.push(Wle(i,o,o+n>a?a:o+n));return s===1?(e=i[t-1],r.push(Wa[e>>2]+Wa[e<<4&63]+"==")):s===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Wa[e>>10]+Wa[e>>4&63]+Wa[e<<2&63]+"=")),r.join("")}},Wa=[],To=[],Hle=typeof Uint8Array<"u"?Uint8Array:Array,tR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ff=0,Vle=tR.length;ff<Vle;++ff)Wa[ff]=tR[ff],To[tR.charCodeAt(ff)]=ff;function Hj(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Wle(i,e,t){for(var s,r,n=[],o=e;o<t;o+=3)s=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),n.push(Wa[(r=s)>>18&63]+Wa[r>>12&63]+Wa[r>>6&63]+Wa[63&r]);return n.join("")}To["-".charCodeAt(0)]=62,To["_".charCodeAt(0)]=63;const on=oe("debugphysics"),iR=oe("debugcolliderplacement"),sR=oe("debugcollisions"),Xle=oe("showcolliders"),$n=Symbol("needle component"),eo=Symbol("physics body"),qle=Symbol("rigidbody");let mf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,on&&console.log("Use Rapier",!1,globalThis.false);const _x=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new zle({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new va(()=>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 Ee),h(this,"_tempScale",new w),h(this,"_tempMatrix",new Re),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(i){var e,t,s;if(!i)return;this.validate();const r=i[eo];if(i[eo]=null,r&&this.world){const n=this.objects.findIndex(o=>o===i);if(n>=0){const o=this.bodies[n];if(this.bodies.splice(n,1),this.objects.splice(n,1),o instanceof jle){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[$n]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof Nle&&(o.numColliders()<=0?(s=this.world)==null||s.removeRigidBody(o):oi()&&(o.did_log_removing||setTimeout(()=>{o.numColliders()>0&&(o.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(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=i,r=s[eo];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[eo];t&&this.internalUpdateColliderProperties(e,t)}else{const e=i,t=this.internal_getRigidbody(e);t&&this.internalUpdateRigidbodyProperties(e,t)}}addForce(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.addForce(e,t)}addImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?.wakeUp()}setAngularVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setAngvel(e,t)}setLinearVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setLinvel(e,t)}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return on&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&on&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||on&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRay(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[$n])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(a.x,a.y,a.z),{point:l,collider:o.collider[$n]}}return null}raycastAndGetNormal(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRayAndGetNormal(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[$n])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=o.normal,c=this.raycastVectorsBuffer.get(),u=this.raycastVectorsBuffer.get();return c.set(a.x,a.y,a.z),u.set(l.x,l.y,l.z),{point:c,normal:u,collider:o.collider[$n]}}return null}getPhysicsRay(i,e,t){var s,r,n;const o=(s=this.context)==null?void 0:s.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(on&&console.warn("Converting screenspace to raycast space",c),(n=this.context)==null||n.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=_t(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new ZI(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[$n],r=new _j(s.gameObject,s);return this.rapierColliderArray.push(r),!0},KI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[$n].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,s;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const s=i.gameObject,r=Js(s,this._tempPosition).multiply(t);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 n=Qi.cuboid(r.x,r.y,r.z);this.createCollider(i,n,e)}async addSphereCollider(i,e){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const t=Qi.ball(.5);this.createCollider(i,t,e),this.updateProperties(i)}async addCapsuleCollider(i,e,t,s){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}const r=i.gameObject,n=Js(r,this._tempPosition);n.x=Math.abs(n.x),n.y=Math.abs(n.y);const o=Qi.capsule(t*.5*n.y-s,s*n.x);this.createCollider(i,o,e)}async addMeshCollider(i,e,t,s){var r,n,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){on&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){on&&console.warn("Missing mesh geometry",e.name);return}(n=(r=a.index)==null?void 0:r.array)!=null&&n.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=VY(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const d=a.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+t;if(this._meshCache.has(d))on&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",e.name,Object.assign({},s));const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*s.x,p[f+1]=l[f+1]*s.y,p[f+2]=l[f+2]*s.z;l=p,this._meshCache.set(d,p)}}const u=t?Qi.convexMesh(l):Qi.trimesh(l,c);u&&this.createCollider(i,u)}getBody(i){return i?i[eo]:null}getComponent(i){return i?i[$n]:null}createCollider(i,e,t){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:n}=this.getRigidbody(i,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),Js(i.gameObject,this._tempScale),t&&(t.multiply(this._tempScale),this._tempPosition.x-=t.x,this._tempPosition.y+=t.y,this._tempPosition.z+=t.z),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const o=i.sharedMaterial;if(o){switch(e.setRestitution(o.bounciness),o.bounceCombine){case Ia.Average:e.setRestitutionCombineRule(Mo.Average);break;case Ia.Maximum:e.setRestitutionCombineRule(Mo.Max);break;case Ia.Minimum:e.setRestitutionCombineRule(Mo.Min);break;case Ia.Multiply:e.setRestitutionCombineRule(Mo.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Ia.Average:e.setFrictionCombineRule(Mo.Average);break;case Ia.Maximum:e.setFrictionCombineRule(Mo.Max);break;case Ia.Minimum:e.setFrictionCombineRule(Mo.Min);break;case Ia.Multiply:e.setFrictionCombineRule(Mo.Multiply);break}}n&&e.setDensity(0);const a=this.world.createCollider(e,r);return a[$n]=i,i[eo]=a,a.setActiveEvents(JI.COLLISION_EVENTS),a.setActiveCollisionTypes(bx.ALL),this.objects.push(i),this.bodies.push(a),a}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null,s=!1;if(i.attachedRigidbody){const r=i.attachedRigidbody;if(t=r[eo],s=r.autoMass===!1,!t){const n=r.isKinematic&&!iR;on&&console.log("Create rigidbody",n);const o=n?mf.RigidBodyDesc.kinematicPositionBased():mf.RigidBodyDesc.dynamic(),a=_t(i.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Ds(i.attachedRigidbody.gameObject)),t=this.world.createRigidBody(o),this.bodies.push(t),this.objects.push(r)}t[$n]=r,r[eo]=t,this.internalUpdateRigidbodyProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=mf.RigidBodyDesc.kinematicPositionBased(),n=_t(i.gameObject);r.setTranslation(n.x,n.y,n.z),r.setRotation(Ds(i.gameObject)),t=this.world.createRigidBody(r),e.identity(),t[$n]=null}return i[qle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[eo]}internalUpdateColliderProperties(i,e){const t=e.shape;switch(t.type){case Zt.Ball:{const n=t,o=i,a=n.radius!==o.radius,l=i.gameObject,c=Js(l,this._tempPosition).multiplyScalar(o.radius);n.radius=Math.abs(c.x),a&&e.setShape(n);break}case Zt.Cuboid:const s=t,r=i;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,e.setShape(s);break}}internalUpdateRigidbodyProperties(i,e){if(e.enableCcd(i.collisionDetectionMode!==bb.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),i.dominanceGroup<=127&&i.dominanceGroup>=-127?e.setDominanceGroup(Math.floor(i.dominanceGroup)):e.setDominanceGroup(0),i.autoMass){e.setAdditionalMass(0,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(1);e.recomputeMassPropertiesFromColliders(),console.log(e.mass())}else{e.setAdditionalMass(i.mass,!1);for(let t=0;t<e.numColliders();t++)e.collider(t).setDensity(0);e.recomputeMassPropertiesFromColliders(),console.log(e.mass())}e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!0),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!0),i.isKinematic?e.setBodyType(mf.RigidBodyType.KinematicPositionBased):e.setBodyType(mf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Gle(!1)),i&&(this.world.timestep=st.lerp(this.world.timestep,i,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,s;if(on||iR||Xle||this.debugRenderColliders===!0){if(!this.lines){const n=new ns({color:2258688,fog:!1}),o=new mt;this.lines=new kn(o,n),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const r=i.debugRender();this.lines.geometry.setAttribute("position",new tt(r.vertices,3)),this.lines.geometry.setAttribute("color",new tt(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 Yle(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!iR)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],s=e;if(s?.isCollider===!0&&!s.attachedRigidbody){const a=t.parent();a&&this.syncPhysicsBody(e.gameObject,a,!0,!0);continue}const r=t.translation(),n=t.rotation(),o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(n.x,n.y,n.z,n.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion);r.x-=a.x,r.y-=a.y,r.z-=a.z}Qd(e.gameObject,r.x,r.y,r.z),c2(e.gameObject,n.x,n.y,n.z,n.w)}}syncPhysicsBody(i,e,t,s){const r=_t(i,this._tempPosition),n=Ds(i,this._tempQuaternion);switch(e.bodyType()){case Qv.Fixed:case Qv.KinematicPositionBased:case Qv.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),s&&e.setNextKinematicRotation(n);break;default:t&&e.setTranslation(r,!1),s&&e.setRotation(n,!1);break}e.wakeUp()}getRigidbodyRelativeMatrix(i,e,t,s){if(s===void 0&&(s=_x._matricesBuffer,s.length=0),i===e){const r=Js(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let n=s.length-1;n>=0;n--)t.multiply(s[n]);return t}return s.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,s),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[eo],s=e[eo];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=bf.fixed(_x.centerConnectionPos,_x.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);on&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[eo],n=e[eo];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=mf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);on&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const s=i.matrixWorld,r=e.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,t.copy(r).premultiply(s.invert()).invert()}};let Gv=_x;h(Gv,"_didLoadPhysicsEngine",!1),h(Gv,"_matricesBuffer",[]),h(Gv,"centerConnectionPos",{x:0,y:0,z:0}),h(Gv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Yle{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,s)=>{const r=this.world.getCollider(e),n=this.world.getCollider(t),o=r[$n],a=n[$n];sR&&console.log("EVT",o.name,a.name,s,r,n),o&&a&&(s?(this.onCollisionStarted(o,r,a,n),this.onCollisionStarted(a,n,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,s,r){let n=null;if(e.isTrigger||s.isTrigger)ou(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(s),this.activeTriggers.push({collider:e,component:o,otherCollider:s})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{ou(o,c=>{var u;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||sR){if(!n){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),b=a.solverContactFriction(m),y=new yj(A,g,f,v,b);p.push(y),sR&&Rl.DrawDirection(A,f,16711680,3,!0)}}n=new bj(o,s,p)}if(d){const p={collider:e,component:c,collision:n};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(u=c.onCollisionEnter)==null||u.call(c,n)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const s=e.collision;t.onCollisionStay(s)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const s=e.otherCollider;t.onTriggerStay(s)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let s=0;s<this.activeCollisions.length;s++){const r=this.activeCollisions[s],n=r.collider;if(n.destroyed){this.activeCollisions.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeCollisionsStay.length;s++){const r=this.activeCollisionsStay[s],n=r.collider;if(n.destroyed){this.activeCollisionsStay.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeTriggers.length;s++){const r=this.activeTriggers[s],n=r.collider;if(n.destroyed){this.activeTriggers.splice(s,1),s--;continue}if(n===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(s,1),s--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Kle(i,e,t,s="image/webp",r){if(!i&&(i=Pi.Current,!i))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=i.mainCamera,!r))return console.error("No camera found"),null;const n=i.renderer.domElement.width,o=i.renderer.domElement.height;e||(e=n),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,i.renderer.domElement.style.width=e+"px",i.renderer.domElement.style.height=t+"px";try{const l=i.renderer.domElement;return i.renderer.setSize(e,t,!1),r instanceof qt&&i.updateAspect(r,e,t),i.renderNow(),l.toDataURL(s)}finally{i.renderer.setSize(n,o,!1),i.updateSize()}return null}let Hv=null;function Jle(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Hv||(Hv=document.createElement("a")),Hv.href=i,Hv.download=e,Hv.click()}}const xx=oe("debugmissingcamera");Pi.registerCallback(Qr.MissingCamera,i=>{var e,t;xx&&console.warn("Creating missing camera");const s=i.context.scene,r=new Pe;r.name="Default Fallback Camera",s.add(r);const n=new Bi;n.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",i.context.lightmaps.tryGetSkybox(n.sourceId)?n.clearFlags=1:n.clearFlags=2,n.backgroundColor=new Ai(.5,.5,.5,1),n.fieldOfView=35,n.backgroundBlurriness=.2;const o=Rc(r,n,!0);return r.position.x=0,r.position.y=1,r.position.z=2,Vj(i.context,o),o}),Pi.registerCallback(Qr.ContextCreated,i=>{if(!i.context.mainCamera){xx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Yte(i.context.mainCamera);if(t?.isCameraController===!0){xx&&console.log("Will not auto-fit because a camera controller exists");return}Vj(i.context)}});function Vj(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(xx&&console.log("Creating default camera controls",e?.name),t){const s=f0(t,Wi);s.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");s.autoRotate=r!==void 0&&(r===""||r==="true"),s.autoRotateSpeed=.5;const n=i,o=()=>{n.pre_render_callbacks.splice(n.pre_render_callbacks.indexOf(o),1),s.fitCamera()};n.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}b6();const rR={Context:Ft,glTF:{loadFromURL:XI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=rR;function Wj(i){for(const e in i)rR[e]=i[e]}Wj(bY),Wj(ule);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:rR[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=n6;var nR={},Xj={};Object.defineProperty(Xj,"__esModule",{value:!0});var wx={};Object.defineProperty(wx,"__esModule",{value:!0}),wx.ConstantBackoff=void 0;var Zle=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();wx.ConstantBackoff=Zle;var Sx={};Object.defineProperty(Sx,"__esModule",{value:!0}),Sx.ExponentialBackoff=void 0;var $le=function(){function i(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return i.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},i.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},i}();Sx.ExponentialBackoff=$le;var Cx={};Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.LinearBackoff=void 0;var ece=function(){function i(e,t,s){this.initial=e,this.increment=t,this.maximum=s,this.current=this.initial}return i.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},i.prototype.reset=function(){this.current=this.initial},i}();Cx.LinearBackoff=ece;var qj={};Object.defineProperty(qj,"__esModule",{value:!0});var Ex={};Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.LRUBuffer=void 0;var tce=function(){function i(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return i.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},i.prototype.cap=function(){return this.buffer.length},i.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,s=t-1<0?this.buffer.length-1:t-1,r=0;r<e.length;r++){var n=(t+r)%this.buffer.length;if(e[r]=this.buffer[n],n===s)return r+1}return e.length},i.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,s=0;s<e.length-t;s++)this.buffer[this.writePtr]=e[t+s],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},i.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,r=this.len();e(this.buffer[t]),t!==s;)t=(t+1)%this.buffer.length;return r},i.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},i}();Ex.LRUBuffer=tce;var Mx={};Object.defineProperty(Mx,"__esModule",{value:!0}),Mx.TimeBuffer=void 0;var ice=function(){function i(e){this.maxAge=e}return i.prototype.cap=function(){return Number.POSITIVE_INFINITY},i.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},i.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,s=0;t!==void 0&&(e[s++]=t.e,s!==e.length);)t=t.n;return s},i.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},i.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,s=0;t!==void 0;)e(t.e),s++,t=t.n;return s},i.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)},i.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););},i.prototype.clear=function(){},i}();Mx.TimeBuffer=ice;var oR={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Websocket=i.WebsocketEvents=void 0;var e;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry"})(e=i.WebsocketEvents||(i.WebsocketEvents={}));var t=function(){function s(r,n,o,a){var l=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(c){return l.handleEvent(e.open,c)},this.handleCloseEvent=function(c){return l.handleEvent(e.close,c)},this.handleErrorEvent=function(c){return l.handleEvent(e.error,c)},this.handleMessageEvent=function(c){return l.handleEvent(e.message,c)},this.url=r,this.protocols=n,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(s.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),s.prototype.send=function(r){var n;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(n=this.buffer)===null||n===void 0||n.write([r]):this.websocket.send(r))},s.prototype.close=function(r,n){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(r,n)},s.prototype.addEventListener=function(r,n,o){var a={listener:n,options:o},l=this.eventListeners[r];l.push(a)},s.prototype.removeEventListener=function(r,n,o){this.eventListeners[r]=this.eventListeners[r].filter(function(a){return a.listener!==n&&(a.options===void 0||a.options!==o)})},s.prototype.dispatchEvent=function(r,n){var o=this,a=this.eventListeners[r],l=[];a.forEach(function(c){c.listener(o,n),c.options!==void 0&&c.options.once&&l.push(c)}),l.forEach(function(c){return o.removeEventListener(r,c.listener,c.options)})},s.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)},s.prototype.handleEvent=function(r,n){var o,a,l;switch(r){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)),(l=this.buffer)===null||l===void 0||l.clear();break}this.dispatchEvent(r,n)},s.prototype.reconnect=function(){var r=this;if(this.backoff!==void 0){var n=this.backoff.next();setTimeout(function(){r.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++r.retries,backoff:n}})),r.tryConnect()},n)}},s}();i.Websocket=t})(oR);var Tx={};Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.WebsocketBuilder=void 0;var gf=oR,sce=function(){function i(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return i.prototype.withProtocols=function(e){return this.protocols=e,this},i.prototype.withBackoff=function(e){return this.backoff=e,this},i.prototype.withBuffer=function(e){return this.buffer=e,this},i.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},i.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},i.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},i.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},i.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},i.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new gf.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(gf.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();Tx.WebsocketBuilder=sce,function(i){var e=Jy&&Jy.__createBinding||(Object.create?function(s,r,n,o){o===void 0&&(o=n),Object.defineProperty(s,o,{enumerable:!0,get:function(){return r[n]}})}:function(s,r,n,o){o===void 0&&(o=n),s[o]=r[n]}),t=Jy&&Jy.__exportStar||function(s,r){for(var n in s)n!=="default"&&!Object.prototype.hasOwnProperty.call(r,n)&&e(r,s,n)};Object.defineProperty(i,"__esModule",{value:!0}),t(Xj,i),t(wx,i),t(Sx,i),t(Cx,i),t(qj,i),t(Ex,i),t(Mx,i),t(oR,i),t(Tx,i)}(nR);const rce=pm(nR),nce=iQ({__proto__:null,default:rce},[nR]),Io={node:"node",material:"material",camera:"camera",light:"light"},Ku="KHR_animation_pointer",oce={CUBICSPLINE:void 0,LINEAR:da,STEP:gc},Yj=Ot.findNode;let Kj=!1;class ace{constructor(e){this.parser=e,this.name=Ku,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Kj||(Kj=!0,Ot.findNode=function(e,t){if(t.startsWith(".materials.")){const s=t.substring(11).substring(t.indexOf(".")),r=s.indexOf("."),n=r<0?s:s.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===n||a.material.name===n)&&(o=a.material,o!==null&&(s.endsWith(".map")?o=o.map:s.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const s=t.split(".");let r;for(let n=1;n<s.length;n++){const o=s[n];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const n=Yj(e,s[2]);return n||console.warn(Ku+": Property binding not found",t,e,e.name,s),n}return r}return Yj(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,s=t.node!==void 0?t.node:t.id;return s?this.parser.getDependency("node",s):null}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,s=t.extensions&&t.extensions[Ku]&&t.path&&t.path==="pointer";if(!s)return null;let r,n=Io.node,o;if(s){const l=t.extensions[Ku];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?n=Io.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=Io.light:c.startsWith("/cameras/")&&(n=Io.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case Io.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case Io.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case Io.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case Io.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(c=u.resolvePath(c)),t.extensions[Ku].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return n===Io.node?a=this.parser.getDependency("node",o):n===Io.material?a=this.parser.getDependency("material",o):n===Io.light?a=this.parser.getDependency("light",o):n===Io.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",n),a}createAnimationTracksWithAnimationPointer(e,t,s,r,n){if(!(n.extensions&&n.extensions[Ku]&&n.path&&n.path==="pointer"))return null;let o=n.extensions[Ku].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof zh&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",u(this.parser));return a}u(this.parser);function u(d){o=l.join(".");let p;switch(s.itemSize){case 1:p=xc;break;case 2:case 3:p=cl;break;case 4:o.endsWith(".quaternion")?p=ga:p=vy;break}const f=r.interpolation!==void 0?oce[r.interpolation]:da;let m=d._getArrayFromAccessor(s);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&s.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let b=0,y=m.length/4;b<y;b+=1)v[b]=m[b*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let s="";return t==="node"?s=e.substring(7):t==="material"?s=e.substring(11):t==="light"?s=e.substring(39):t==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const t=this,s=this.parser.json,r=this.parser,n=s.animations[e],o=n.name?n.name:"animation_"+e,a=[],l=[],c=[],u=[],d=[];for(let p=0,f=n.channels.length;p<f;p++){const m=n.channels[p],A=n.samplers[m.sampler],v=m.target,g=n.parameters!==void 0?n.parameters[A.input]:A.input,b=n.parameters!==void 0?n.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(m);if(y||(y=t.loadAnimationTargetFromChannel(m)),y==null){console.warn("Failed to load animation target",m,y);continue}a.push(y),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],b=[];for(let y=0,_=f.length;y<_;y++){const S=f[y],M=m[y],I=A[y],R=v[y],E=g[y];if(S===void 0)continue;S.updateMatrix&&(S.updateMatrix(),S.matrixAutoUpdate=!0);let C=t.createAnimationTracksWithAnimationPointer(S,M,I,R,E);if(C||(C=r._createAnimationTracks(S,M,I,R,E)),C)for(let z=0;z<C.length;z++)b.push(C[z])}return new zr(o,void 0,b)})}}const lce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:ace},Symbol.toStringTag,{value:"Module"}));export{kle as $physicsKey,di as ActionBuilder,kE as ActionCollection,Ko as ActionModel,AL as Addressables,ig as AlignmentConstraint,Zd as AmbientMode,Ln as Animation,fu as AnimationCurve,lb as AnimationExtension,Zb as AnimationTrackHandler,Tr as Animator,Wc as AnimatorConditionMode,yh as AnimatorController,LE as AnimatorControllerParameterType,cb as AnimatorStateInfo,Lg as Antialiasing,xL as Application,U0 as ApplicationEvents,vO as AssetDatabase,js as AssetReference,Da as AttachedObject,jb as AttachedObjectEvents,e_ as AudioExtension,_u as AudioListener,hs as AudioSource,Dg as AudioTrackHandler,wu as AvatarBlink_Simple,Up as AvatarEyeLook_Rotation,Ab as AvatarLoader,Ir as AvatarMarker,vb as AvatarModel,cg as Avatar_Brain_LookAt,Ug as Avatar_MouthShapes,XM as Avatar_MustacheShake,Jr as Avatar_POI,bp as Axes,Fp as AxesHelper,la as BaseUIComponent,JM as BasicIKConstraint,i_ as BehaviorExtension,Kr as BehaviorModel,Ie as Behaviour,Su as Bloom,Ng as BoxCollider,yu as BoxGizmo,Ma as BoxHelperComponent,Xl as Button,lp as CallInfo,Bi as Camera,lr as Canvas,sh as CanvasGroup,eh as CapsuleCollider,Qp as ChangeMaterialOnClick,Mu as ChangeTransformOnClick,Tu as CharacterController,Kl as CharacterControllerInput,Wg as ChromaticAberration,va as CircularBuffer,Yb as ClearFlags,ka as ClipExtrapolation,Oa as Collider,bj as Collision,bb as CollisionDetectionMode,nh as ColorAdjustments,Iu as ColorBySpeedModule,Yg as ColorOverLifetimeModule,Fc as Component,Sm as ComponentEvents,Cm as ComponentLifecycleEvents,Gk as ConnectionEvents,yj as ContactPoint,Ft as Context,vY as ContextArgs,Qr as ContextEvent,Pi as ContextRegistry,$b as ControlTrackHandler,zl as ControllerEvents,Mp as ControllerType,hh as CustomBranding,Xo as CustomShader,L0 as DefaultReflectionMode,mT as Deletable,A_ as DeleteBox,na as DepthOfField,y_ as DeviceFlag,gT as DocumentExtension,qp as DragControls,Zg as DropListener,Du as Duplicatable,Y0 as EXTENSION_NAME,Ua as EmissionModule,Hp as EmphasizeOnClick,KC as EngineLoadingView,sr as EventList,Z0 as EventListEvent,zn as EventSystem,x_ as EventTrigger,CE as FieldWithDefault,M3 as FileSpawnModel,E3 as File_Event,CT as FixedJoint,ET as FlyControls,Jp as Fog,vn as FrameEvent,c0 as GENERATOR,te as GameObject,Rl as Gizmos,tv as GltfExport,kT as GltfExportBox,qu as GltfLoadEvent,cj as GltfLoadEventType,oh as Gradient,Cu as Graphic,zM as GraphicRaycaster,No as Graphics,ef as GridHelper,aT as GridLayoutGroup,ku as GroundProjectedEnv,Gc as GroupActionModel,wO as HideFlags,hT as HideOnStart,$g as HingeJoint,oT as HorizontalLayoutGroup,h9 as HostData,zp as Image,O0 as ImageReference,yL as ImageReferenceSerializer,lh as InheritVelocityModule,a2 as Input,ya as InputEvents,Lu as InputField,Cn as InstancingUtil,Yk as InstantiateEvent,kr as InstantiateIdProvider,xa as InstantiateOptions,Ap as Interactable,K8 as JoinedRoomResponse,Gy as KeyEventArgs,rv as LODGroup,Uu as LODModel,J8 as LeftRoomResponse,wn as Light,_L as LightData,Cs as LimitVelocityOverLifetimeModule,PY as LoadingElementOptions,FT as LogStats,lo as LogType,Fu as LookAt,ng as LookAtConstraint,hr as MainModule,HM as MarkerType,Gg as MaskableGraphic,st as Mathf,zg as MeshCollider,ib as MeshRenderer,ht as MinMaxCurve,xn as MinMaxGradient,qo as NEEDLE_progressive,Pi as NeedleEngine,qI as NeedleEngineHTMLElement,VI as NeedleGltfLoader,y0 as NeedlePatchesKey,I_ as NestedGltf,Vk as NetworkConnection,Bu as Networking,gi as NoiseModule,Ql as ObjectRaycaster,jz as ObjectUtils,Nu as OffsetConstraint,tf as OpenURL,Wi as OrbitControls,Np as Outline,Hk as OwnershipEvent,l0 as OwnershipModel,th as Padding,qg as ParticleBurst,V_ as ParticleSubEmitter,Ms as ParticleSystem,So as ParticleSystemRenderer,jk as PeerNetworking,_2 as Physics,Ia as PhysicsMaterialCombine,fv as PixelationEffect,rh as PlayAnimationOnClick,Vp as PlayAudioOnClick,xu as PlayableDirector,Ju as PlayerColor,Xu as PlayerState,oj as PlayerStateEvent,vx as PlayerSync,UL as PlayerView,FL as PlayerViewManager,lc as PointerEventData,o2 as PointerType,Rr as PostProcessingEffect,X_ as PostProcessingHandler,Xp as PreliminaryAction,Hg as PreliminaryTrigger,yI as PrimitiveType,_U as ProgressiveLoadingInfo,Uy as PromiseAllWithErrors,zD as PromiseErrorResult,Ai as RGBAColor,Gv as RapierPhysics,a_ as RawImage,zo as RaycastOptions,Pp as Raycaster,iT as Rect,en as RectTransform,hp as ReflectionProbe,ab as RegisteredAnimationInfo,$l as RemoteSkybox,cp as RenderTexture,MU as RenderTextureSerializer,Ui as Renderer,bL as RendererData,$m as RendererLightmap,Ei as Rigidbody,ds as RigidbodyConstraints,Zi as RoomEvents,Vn as RotationBySpeedModule,wo as RotationOverLifetimeModule,q0 as SceneLightSettings,rn as SceneSwitcher,yv as ScreenCapture,ec as ScreenSpaceAmbientOcclusion,aa as ScreenSpaceAmbientOcclusionN8,mn as SendQueue,Gp as SetActiveOnClick,xv as ShadowCatcher,ps as ShapeModule,Rg as SignalAsset,Op as SignalReceiver,kp as SignalReceiverEvent,kg as SignalTrackHandler,tT as Size,tn as SizeBySpeedModule,ah as SizeOverLifetimeModule,EE as SkinnedMeshRenderer,fh as SmoothFollow,wI as SpatialHtml,Cv as SpatialTrigger,ja as SpatialTriggerReceiver,ex as SpectatorCamera,Fg as SphereCollider,b2 as SphereIntersection,_j as SphereOverlapResult,tc as Sprite,cf as SpriteData,Qa as SpriteRenderer,Ev as SpriteSheet,LK as StateMachineBehaviour,pv as SubEmitterSystem,sx as SyncedCamera,mh as SyncedRoom,Jc as SyncedTransform,dT as TapGestureTrigger,zb as TeleportTarget,BI as TestRunner,DI as TestSimulateUserData,sn as Text,g_ as TextBuilder,Jg as TextExtension,ur as TextureSheetAnimationModule,Ga as TiltShiftEffect,w2 as Time,Tv as ToneMapping,Pg as TrackHandler,Qn as TrackType,zi as TrailModule,mp as TransformData,Gu as TransformGizmo,An as TriggerBuilder,pu as TriggerModel,Y as TypeStore,Ep as UIRaycastUtils,bg as UIRootComponent,fo as USDObject,Xn as USDZExporter,ch as USDZText,v_ as USDZUIExtension,EC as Upload_Result,TU as UriSerializer,yp as UsageMarker,Z8 as UserJoinedOrLeftRoomModel,Ic as VERSION,jl as VRUserState,DE as VariantAction,Xi as VelocityOverLifetimeModule,nT as VerticalLayoutGroup,Br as VideoPlayer,Ca as ViewDevice,Hu as Vignette,Vg as VisibilityAction,ac as Voip,cx as Volume,Tt as VolumeParameter,Og as VolumeProfile,boe as WaitForFrames,kz as WaitForSeconds,oc as Watch,Mg as WebAR,ux as WebARCameraBackground,Zo as WebARSessionRoot,Ct as WebXR,Yc as WebXRAvatar,ws as WebXRController,Mi as WebXREvent,px as WebXRImageTracking,ic as WebXRImageTrackingModel,Wu as WebXRPlaneTracking,wg as WebXRSync,Vu as WebXRTrackedImage,Fn as XRFlag,mx as XRGrabModel,NI as XRGrabRendering,Qb as XRRig,Vm as XRSessionMode,Un as XRState,us as XRStateFlag,zI as __Ignore,xO as __internalNotifyObjectDestroyed,_l as activeInHierarchyFieldName,FD as addAttributeChangeCallback,F7 as addCustomExtension,T3 as addFile,I3 as addFileFromUrl,_le as addGltfLoadEventListener,Rc as addNewComponent,A0 as addPatch,g0 as apply,Dle as applyHMRChanges,Zk as beginListenDestroy,R3 as beginListenFileSpawn,$k as beginListenInstantiate,DS as binaryIdentifierCasts,gY as build_scene_functions,su as builtinComponentKeyName,qC as calculateProgress01,G7 as colorSerializer,$0 as componentSerializer,A2 as copyTexture,WI as createGLTFLoader,nF as createMotion,Hr as debugNet,xm as debugOwner,ky as deepClone,hm as delay,Qy as deserializeObject,xl as destroy,oO as destroyComponentInstance,i3 as detectARSupport,s3 as detectVRSupport,Ci as disposeObjectResources,mL as download,TC as download_file,wm as editorGuidKeyName,fI as effectsOrder,q7 as eventListSerializer,km as findByGuid,cO as findObjectOfType,hO as findObjectsOfType,aC as findResourceUsers,ou as foreachComponent,hC as foreachComponentEnumerator,r8 as forward,p0 as generateSeed,Vd as getComponent,Mm as getComponentInChildren,Im as getComponentInParent,Em as getComponents,Tm as getComponentsInChildren,m0 as getComponentsInParent,g6 as getIp,v6 as getIpAndLocation,m6 as getIpCloudflare,Go as getLoader,f0 as getOrAddComponent,oe as getParam,h6 as getPath,W8 as getPeerOptions,JS as getPeerjsInstance,E9 as getResourceUserCount,lm as getUrlParams,o8 as getWorldDirection,f2 as getWorldEuler,_t as getWorldPosition,Ds as getWorldQuaternion,Vy as getWorldRotation,Js as getWorldScale,GC as hasIndieLicense,ep as hasProLicense,MC as hash,Om as instantiate,SO as isActiveInHierarchy,Xd as isActiveSelf,v2 as isAnimationAction,a6 as isDebugMode,cC as isDestroyed,oi as isDevEnvironment,S9 as isDisposed,jD as isHostedOnGlitch,Ile as isHotReloading,jr as isLocalNetwork,pl as isMobileDevice,Ly as isMozillaXR,p6 as isQuest,yO as isResourceTrackingEnabled,fl as isSafari,S0 as isUsingInstancing,um as isiOS,XI as loadSync,Xy as logHierarchy,e8 as lookAtInverse,c6 as makeId,kD as makeIdFromRandomWords,CO as markAsInstancedRendered,iC as moveComponentInstance,o6 as nameof,Dy as nameofFactory,EU as objectSerializer,uj as parseSync,BJ as prefix,RD as pushState,PD as randomNumber,Ky as registerBinaryType,H0 as registerComponent,xE as registerComponentExtension,xo as registerCustomEffectType,wU as registerExtensions,Rle as registerHotReloadType,IC as registerLoader,tO as registerPrefabProvider,j6 as registerType,LD as relativePathPrefix,ND as removeAttributeChangeCallback,tC as removeComponent,N7 as removeCustomExtension,xle as removeGltfLoadEventListener,_9 as removePatch,dl as resolveUrl,OD as sanitizeString,Jle as saveImage,Kle as screenshot,Jk as sendDestroyed,x as serializable,s2 as serializeObject,ap as serializeable,Dm as setActive,y6 as setAllowOverlayMessages,MO as setDestroyed,O6 as setDevEnvironment,oC as setDisposable,cm as setOrAddParamsToUrl,l6 as setParam,ID as setParamWithoutReload,X8 as setPeerOptions,w9 as setResourceTrackingEnabled,hS as setState,m2 as setWorldEuler,ys as setWorldPosition,Qd as setWorldPositionXYZ,pn as setWorldQuaternion,c2 as setWorldQuaternionXYZW,g2 as setWorldRotation,Wy as setWorldRotationXYZ,IS as setWorldScale,k6 as showBalloonError,ls as showBalloonMessage,wr as showBalloonWarning,yS as showDebugConsole,l2 as slerp,d0 as syncDestroy,vI as syncField,$S as syncInstantiate,l8 as textureToCanvas,E2 as tryCastBinary,Nd as tryFindObject,pj as tryFindObjectByName,Sle as tryFindScript,M2 as tryGetGuid,Ple as unregisterHotReloadType,UD as unwatchWrite,fL as upload_file,or as validate,uS as watchWrite};