@needle-tools/engine 3.21.3 → 3.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/needle-engine.js +1 -1
- package/dist/needle-engine.light.js +1 -1
- package/dist/needle-engine.light.min.js +1 -1
- package/dist/needle-engine.light.umd.cjs +1 -1
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_physics_rapier.js +2 -2
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_physics_rapier.ts +2 -2
package/dist/needle-engine.js
CHANGED
|
@@ -89642,7 +89642,7 @@ const lh = class {
|
|
|
89642
89642
|
const t = e.shape;
|
|
89643
89643
|
switch (t.type) {
|
|
89644
89644
|
case Ve.Ball: {
|
|
89645
|
-
const o = t, s = A, C = A.gameObject, n = Ng(C, this._tempPosition)
|
|
89645
|
+
const o = t, s = A, C = A.gameObject, n = Ng(C, this._tempPosition), a = Math.abs(s.radius * n.x), B = o.radius !== a;
|
|
89646
89646
|
o.radius = a, B && e.setShape(o);
|
|
89647
89647
|
break;
|
|
89648
89648
|
}
|
|
@@ -87092,7 +87092,7 @@ const Gg = class {
|
|
|
87092
87092
|
const i = t.shape;
|
|
87093
87093
|
switch (i.type) {
|
|
87094
87094
|
case Zt.Ball: {
|
|
87095
|
-
const o = i, a = e, c = e.gameObject, l = ws(c, this._tempPosition)
|
|
87095
|
+
const o = i, a = e, c = e.gameObject, l = ws(c, this._tempPosition), u = Math.abs(a.radius * l.x), d = o.radius !== u;
|
|
87096
87096
|
o.radius = u, d && t.setShape(o);
|
|
87097
87097
|
break;
|
|
87098
87098
|
}
|
|
@@ -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 Ile}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(mr&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];t&&(mr&&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");mr&&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(mr&&console.log("attributeChangedCallback",e,t,s),e){case"src":mr&&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&&(mr&&console.log(e+" attribute changed",s),this.registerEventFromAttribute(e,s));break;case"dracoDecoderPath":mr&&console.log("dracoDecoderPath",s),oU(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(mr&&console.log("dracoDecoderType",s),aU(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":mr&&console.log("ktx2DecoderPath",s),lU(s);break}}async onLoad(){var e,t;if(!this.isConnected)return;if(this._context||(mr&&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)mr&&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=sp();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()&&Sr('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 ZC(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)),mr&&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=Rle(f.name),a&&((m=this._loadingView)==null||m.onLoadingUpdate(f)),c.name=f.name,c.progress=f.progress,this._loadingProgress01=KC(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&&(mr&&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(Fv),this.classList.remove(Nv);const e=this.getAROverlayContainer();mr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Fv),e.classList.remove(Nv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,zL))}onSetupVR(){this.classList.remove(Fv),this.classList.remove(Nv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,gj))}onSetupDesktop(){this.classList.remove(Fv),this.classList.add(Nv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Fv),e.classList.add(Nv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,vj))}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 Tle)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&&(mr&&console.log("using custom draco decoder path",e),oU(e));const t=this.getAttribute("dracoDecoderType");t&&(mr&&console.log("using custom draco decoder type",t),aU(t));const s=this.getAttribute("ktx2DecoderPath");s&&(mr&&console.log("using custom ktx2 decoder path",s),lU(s))}}typeof window<"u"&&!window.customElements.get(mj)&&window.customElements.define(mj,KI);function Rle(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 Ple=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:KI},Symbol.toStringTag,{value:"Module"})),bx=oe("debughotreload");let zv=!1;const jv=new Map;function Ble(){return zv}function kle(i){var e;if(zv)return;const t=i.constructor.name;jv.has(t)?(e=jv.get(t))==null||e.push(i):jv.set(t,[i])}function Dle(i){if(zv)return;const e=i.constructor.name,t=jv.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let Aj=!1;function Ole(){if(bx||Aj)return;Aj=!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 Lle(i){bx&&console.log("[HMR] Apply changes",i,Object.keys(i)),Ole();for(const e of Object.keys(i))try{zv=!0;const t=Y.get(e);if(!t){bx&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=jv.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&&Sl(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&&fC(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(bx)console.error(t);else return!1}finally{zv=!1,ml(co.Log,"Script changes applied (HMR)")}return!0}const Ule=Symbol("object"),yj=new Aa(()=>new w,20);class bj{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 yj.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return yj.get().set(this._normal.x,this._normal.y,this._normal.z)}}class _j{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 xj{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const Qv=new Array(32).fill(void 0);Qv.push(void 0,null,!0,!1);let wj;Qv.length;function Sj(){return wj.byteLength,wj}const Fle=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}Fle.decode();let Cj,Ej,Gv=32;function Mj(i){if(Gv==1)throw new Error("out of js stack");return Qv[--Gv]=i,Gv}function Nle(){return Cj.byteLength,Cj}function zle(){return Ej.byteLength,Ej}let $n=0;function Yu(i,e){const t=e(4*i.length);return Nle().set(i,t/4),$n=i.length,t}function _x(i,e){const t=e(4*i.length);return zle().set(i,t/4),$n=i.length,t}class Hx{static __wrap(e){const t=Object.create(Hx.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 Hx.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,Mj(e))}finally{Qv[Gv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,Mj(e))}finally{Qv[Gv++]=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,qs),vt(s,dt),vt(r,qs);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 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_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();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=Sj()[s/4+0],t=Sj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class qs{static __wrap(e){const t=Object.create(qs.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 qs.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return qs.__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=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,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=$n;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=$n,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=$n,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=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,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=$n,o=_x(t,ze.__wbindgen_malloc),a=$n,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,qs),vt(s,dt),vt(r,Qt),vt(n,dt),vt(o,qs),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:pR.__wrap(c)}intersectsShape(e,t,s,r,n){return vt(e,dt),vt(t,qs),vt(s,Qt),vt(r,dt),vt(n,qs),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,qs),vt(s,Qt),vt(r,dt),vt(n,qs);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,s){return vt(e,dt),vt(t,qs),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,qs),vt(s,dt);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return hR.__wrap(n)}intersectsRay(e,t,s,r,n){return vt(e,dt),vt(t,qs),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,qs),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,qs),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:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();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 pR{static __wrap(e){const t=Object.create(pR.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 jle{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class ke{static new(e,t,s){return new jle(e,t,s)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return ke.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=ke.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 Tj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class Di{static identity(){return new Tj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Tj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qs(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 Hv,Va,Ij,Io,JI,Zt,xx,mf,ZI,$I,Rj,Pj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Hv||(Hv={}));class Qle{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 ke.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return ke.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=ke.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=ke.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 ke.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return ke.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=ke.intoRaw(t),a=ke.intoRaw(s),l=Di.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=ke.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.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"}(Ij||(Ij={}));class xf{constructor(){}static fixed(e,t,s,r){let n=new xf;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 xf;return s.anchor1=e,s.anchor2=t,s.jointType=Va.Spherical,s}static prismatic(e,t,s){let r=new xf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Prismatic,r}static revolute(e,t,s){let r=new xf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Revolute,r}intoRaw(){let e,t,s=ke.intoRaw(this.anchor1),r=ke.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Va.Fixed:let l=Di.intoRaw(this.frame1),c=Di.intoRaw(this.frame2);t=Ka.fixed(s,l,r,c),l.free(),c.free();break;case Va.Prismatic:e=ke.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=ke.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"})(Io||(Io={}));class Jv{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 Jv(e.distance(),ke.fromRaw(e.point1()),ke.fromRaw(e.point2()),ke.fromRaw(e.normal1()),ke.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"})(JI||(JI={}));class Vx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Vx(ke.fromRaw(e.point()),e.isInside());return e.free(),t}}class Gle{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 Wx{constructor(e,t,s,r){this.featureType=JI.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 Wx(e.toi(),ke.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Zv{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 Zv(t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class fR extends Zv{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 fR(e.get(t.colliderHandle()),t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class gr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case Zt.Ball:return new eR(e.coRadius(t));case Zt.Cuboid:return r=e.coHalfExtents(t),new Bj(r.x,r.y,r.z);case Zt.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new kj(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 Oj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Fj(o,a);case Zt.Triangle:return o=e.coVertices(t),new Lj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new Uj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]),n);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new Nj(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new zj(p,f,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new tR(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new iR(o,a,n);case Zt.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new jj(l,c);case Zt.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Qj(l,c,n);case Zt.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new Gj(l,c);case Zt.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Hj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=ke.intoRaw(e),u=Di.intoRaw(t),d=ke.intoRaw(s),p=ke.intoRaw(n),f=Di.intoRaw(o),m=ke.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Zv.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=ke.intoRaw(e),a=Di.intoRaw(t),l=ke.intoRaw(r),c=Di.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=ke.intoRaw(e),l=Di.intoRaw(t),c=ke.intoRaw(r),u=Di.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Jv.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=ke.intoRaw(e),n=Di.intoRaw(t),o=ke.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=ke.intoRaw(e),o=Di.intoRaw(t),a=ke.intoRaw(s),l=this.intoRaw(),c=Vx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=ke.intoRaw(t),o=Di.intoRaw(s),a=ke.intoRaw(e.origin),l=ke.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=ke.intoRaw(t),a=Di.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.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=ke.intoRaw(t),a=Di.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=Wx.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 eR extends gr{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class Bj extends gr{constructor(e,t,s){super(),this.type=Zt.Cuboid,this.halfExtents=ke.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class kj extends gr{constructor(e,t,s,r){super(),this.type=Zt.RoundCuboid,this.halfExtents=ke.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 gr{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class Oj extends gr{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class Lj extends gr{constructor(e,t,s){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class Uj extends gr{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=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Fj extends gr{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 Nj extends gr{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class tR extends gr{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 iR extends gr{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 zj extends gr{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=ke.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class jj extends gr{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class Qj extends gr{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 Gj extends gr{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Hj extends gr{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"})(xx||(xx={}));class Hle{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=gr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return ke.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,s,r){let n=ke.intoRaw(t),o=ke.intoRaw(s),a=Di.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 ke.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 ke.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=ke.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=ke.intoRaw(e),r=Vx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=ke.intoRaw(e.origin),r=ke.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=ke.intoRaw(e),l=ke.intoRaw(s),c=Di.intoRaw(r),u=ke.intoRaw(n),d=t.intoRaw(),p=Zv.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=ke.intoRaw(e),o=ke.intoRaw(s),a=fR.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=ke.intoRaw(t),n=Di.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=ke.intoRaw(t),o=Di.intoRaw(s),a=e.intoRaw(),l=Jv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Jv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=ke.intoRaw(e.origin),n=ke.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=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=Wx.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"})(mf||(mf={}));class Qi{constructor(e){this.shape=e,this.massPropsMode=mf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=ke.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Io.Average,this.restitutionCombineRule=Io.Average,this.activeCollisionTypes=xx.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=ke.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=ke.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new eR(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 Oj(e,t);return new Qi(s)}static triangle(e,t,s){const r=new Lj(e,t,s);return new Qi(r)}static roundTriangle(e,t,s,r){const n=new Uj(e,t,s,r);return new Qi(n)}static polyline(e,t){const s=new Fj(e,t);return new Qi(s)}static trimesh(e,t){const s=new Nj(e,t);return new Qi(s)}static cuboid(e,t,s){const r=new Bj(e,t,s);return new Qi(r)}static roundCuboid(e,t,s,r){const n=new kj(e,t,s,r);return new Qi(n)}static heightfield(e,t,s,r){const n=new zj(e,t,s,r);return new Qi(n)}static cylinder(e,t){const s=new jj(e,t);return new Qi(s)}static roundCylinder(e,t,s){const r=new Qj(e,t,s);return new Qi(r)}static cone(e,t){const s=new Gj(e,t);return new Qi(s)}static roundCone(e,t,s){const r=new Hj(e,t,s);return new Qi(r)}static convexHull(e){const t=new tR(e,null);return new Qi(t)}static convexMesh(e,t){const s=new tR(e,t);return new Qi(s)}static roundConvexHull(e,t){const s=new iR(e,null,t);return new Qi(s)}static roundConvexMesh(e,t,s){const r=new iR(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 Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=mf.Density,this.density=e,this}setMass(e){return this.massPropsMode=mf.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=mf.MassProps,this.mass=e,ke.copy(this.centerOfMass,t),ke.copy(this.principalAngularInertia,s),Di.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"})(ZI||(ZI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}($I||($I={}));class Vle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return ke.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return ke.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Wle{constructor(e,t){this.raw=t||new Hx(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Vle;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"})(Rj||(Rj={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Pj||(Pj={}));for(var dce={byteLength:function(i){var e=Vj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Vj(i),r=s[0],n=s[1],o=new Xle(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=Ro[i.charCodeAt(t)]<<18|Ro[i.charCodeAt(t+1)]<<12|Ro[i.charCodeAt(t+2)]<<6|Ro[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=Ro[i.charCodeAt(t)]<<2|Ro[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=Ro[i.charCodeAt(t)]<<10|Ro[i.charCodeAt(t+1)]<<4|Ro[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(Yle(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=[],Ro=[],Xle=typeof Uint8Array<"u"?Uint8Array:Array,sR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gf=0,qle=sR.length;gf<qle;++gf)Wa[gf]=sR[gf],Ro[sR.charCodeAt(gf)]=gf;function Vj(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 Yle(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("")}Ro["-".charCodeAt(0)]=62,Ro["_".charCodeAt(0)]=63;const an=oe("debugphysics"),rR=oe("debugcolliderplacement"),nR=oe("debugcollisions"),Kle=oe("showcolliders"),eo=Symbol("needle component"),to=Symbol("physics body"),Jle=Symbol("rigidbody");let vf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,an&&console.log("Use Rapier",!1,globalThis.false);const wx=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new Gle({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new Aa(()=>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 Ie),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[to];if(i[to]=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 Hle){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[eo]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof Qle&&(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[to];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[to];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 an&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&an&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||an&&(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[eo])!=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[eo]}}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[eo])!=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[eo]}}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)&&(an&&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 eR(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[eo],r=new xj(s.gameObject,s);return this.rapierColliderArray.push(r),!0},ZI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[eo].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){an&&console.warn("Physics are disabled");return}const s=i.gameObject,r=Zs(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){an&&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){an&&console.warn("Physics are disabled");return}const r=i.gameObject,n=Zs(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){an&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){an&&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=qY(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))an&&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[to]:null}getComponent(i){return i?i[eo]: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),Zs(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(Io.Average);break;case Ia.Maximum:e.setRestitutionCombineRule(Io.Max);break;case Ia.Minimum:e.setRestitutionCombineRule(Io.Min);break;case Ia.Multiply:e.setRestitutionCombineRule(Io.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Ia.Average:e.setFrictionCombineRule(Io.Average);break;case Ia.Maximum:e.setFrictionCombineRule(Io.Max);break;case Ia.Minimum:e.setFrictionCombineRule(Io.Min);break;case Ia.Multiply:e.setFrictionCombineRule(Io.Multiply);break}}n&&e.setDensity(0);const a=this.world.createCollider(e,r);return a[eo]=i,i[to]=a,a.setActiveEvents($I.COLLISION_EVENTS),a.setActiveCollisionTypes(xx.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[to],s=r.autoMass===!1,!t){const n=r.isKinematic&&!rR;an&&console.log("Create rigidbody",n);const o=n?vf.RigidBodyDesc.kinematicPositionBased():vf.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[eo]=r,r[to]=t,this.internalUpdateRigidbodyProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=vf.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[eo]=null}return i[Jle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[to]}internalUpdateColliderProperties(i,e){const t=e.shape;switch(t.type){case Zt.Ball:{const n=t,o=i,a=i.gameObject,l=Zs(a,this._tempPosition).multiplyScalar(o.radius),c=o.radius*Math.abs(l.x),u=n.radius!==c;n.radius=c,u&&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(vf.RigidBodyType.KinematicPositionBased):e.setBodyType(vf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Wle(!1)),i&&(this.world.timestep=it.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(an||rR||Kle||this.debugRenderColliders===!0){if(!this.lines){const n=new ns({color:2258688,fog:!1}),o=new mt;this.lines=new On(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 Zle(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!rR)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}Gd(e.gameObject,r.x,r.y,r.z),rD(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 Hv.Fixed:case Hv.KinematicPositionBased:case Hv.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=wx._matricesBuffer,s.length=0),i===e){const r=Zs(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[to],s=e[to];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=xf.fixed(wx.centerConnectionPos,wx.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);an&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[to],n=e[to];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=vf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);an&&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 Vv=wx;h(Vv,"_didLoadPhysicsEngine",!1),h(Vv,"_matricesBuffer",[]),h(Vv,"centerConnectionPos",{x:0,y:0,z:0}),h(Vv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zle{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[eo],a=n[eo];nR&&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||nR){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 bj(A,g,f,v,b);p.push(y),nR&&Pl.DrawDirection(A,f,16711680,3,!0)}}n=new _j(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 $le(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 Wv=null;function ece(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Wv||(Wv=document.createElement("a")),Wv.href=i,Wv.download=e,Wv.click()}}const Sx=oe("debugmissingcamera");Pi.registerCallback(Gr.MissingCamera,i=>{var e,t;Sx&&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,Wj(i.context,o),o}),Pi.registerCallback(Gr.ContextCreated,i=>{if(!i.context.mainCamera){Sx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Ute(i.context.mainCamera);if(t?.isCameraController===!0){Sx&&console.log("Will not auto-fit because a camera controller exists");return}Wj(i.context)}});function Wj(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(Sx&&console.log("Creating default camera controls",e?.name),t){const s=d0(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")}_6();const oR={Context:Ft,glTF:{loadFromURL:YI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=oR;function Xj(i){for(const e in i)oR[e]=i[e]}Xj(wY),Xj(fle);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:oR[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=o6;var aR={},qj={};Object.defineProperty(qj,"__esModule",{value:!0});var Cx={};Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.ConstantBackoff=void 0;var tce=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();Cx.ConstantBackoff=tce;var Ex={};Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.ExponentialBackoff=void 0;var ice=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}();Ex.ExponentialBackoff=ice;var Mx={};Object.defineProperty(Mx,"__esModule",{value:!0}),Mx.LinearBackoff=void 0;var sce=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}();Mx.LinearBackoff=sce;var Yj={};Object.defineProperty(Yj,"__esModule",{value:!0});var Tx={};Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.LRUBuffer=void 0;var rce=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}();Tx.LRUBuffer=rce;var Ix={};Object.defineProperty(Ix,"__esModule",{value:!0}),Ix.TimeBuffer=void 0;var nce=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}();Ix.TimeBuffer=nce;var lR={};(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})(lR);var Rx={};Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.WebsocketBuilder=void 0;var Af=lR,oce=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 Af.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(Af.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(Af.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(Af.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(Af.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(Af.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();Rx.WebsocketBuilder=oce,function(i){var e=Yy&&Yy.__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=Yy&&Yy.__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(qj,i),t(Cx,i),t(Ex,i),t(Mx,i),t(Yj,i),t(Tx,i),t(Ix,i),t(lR,i),t(Rx,i)}(aR);const ace=fm(aR),lce=sQ({__proto__:null,default:ace},[aR]),Po={node:"node",material:"material",camera:"camera",light:"light"},Ku="KHR_animation_pointer",cce={CUBICSPLINE:void 0,LINEAR:pa,STEP:vc},Kj=Ot.findNode;let Jj=!1;class hce{constructor(e){this.parser=e,this.name=Ku,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Jj||(Jj=!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=Kj(e,s[2]);return n||console.warn(Ku+": Property binding not found",t,e,e.name,s),n}return r}return Kj(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=Po.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=Po.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=Po.light:c.startsWith("/cameras/")&&(n=Po.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case Po.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 Po.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 Po.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 Po.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===Po.node?a=this.parser.getDependency("node",o):n===Po.material?a=this.parser.getDependency("material",o):n===Po.light?a=this.parser.getDependency("light",o):n===Po.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 jh&&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=wc;break;case 2:case 3:p=cl;break;case 4:o.endsWith(".quaternion")?p=va:p=yy;break}const f=r.interpolation!==void 0?cce[r.interpolation]:pa;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 jr(o,void 0,b)})}}const uce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hce},Symbol.toStringTag,{value:"Module"}));export{Ule as $physicsKey,di as ActionBuilder,LE as ActionCollection,Jo as ActionModel,yL as Addressables,rg as AlignmentConstraint,ep as AmbientMode,Un as Animation,fu as AnimationCurve,hb as AnimationExtension,Kb as AnimationTrackHandler,Ir as Animator,Xc as AnimatorConditionMode,bh as AnimatorController,FE as AnimatorControllerParameterType,ub as AnimatorStateInfo,Bg as Antialiasing,wL as Application,N0 as ApplicationEvents,AO as AssetDatabase,Qs as AssetReference,ka as AttachedObject,jb as AttachedObjectEvents,Zb as AudioExtension,bu as AudioListener,hs as AudioSource,Ig as AudioTrackHandler,xu as AvatarBlink_Simple,Lp as AvatarEyeLook_Rotation,Ab as AvatarLoader,Rr as AvatarMarker,vb as AvatarModel,ug as Avatar_Brain_LookAt,kg as Avatar_MouthShapes,jM as Avatar_MustacheShake,Zr as Avatar_POI,xp as Axes,Up as AxesHelper,ca as BaseUIComponent,VM as BasicIKConstraint,t_ as BehaviorExtension,Jr as BehaviorModel,Re as Behaviour,wu as Bloom,Og as BoxCollider,Su as BoxGizmo,Ma as BoxHelperComponent,Xl as Button,hp as CallInfo,Bi as Camera,cr as Canvas,rh as CanvasGroup,th as CapsuleCollider,jp as ChangeMaterialOnClick,Mu as ChangeTransformOnClick,Tu as CharacterController,Kl as CharacterControllerInput,Qg as ChromaticAberration,Aa as CircularBuffer,Xb as ClearFlags,Da as ClipExtrapolation,Oa as Collider,_j as Collision,bb as CollisionDetectionMode,oh as ColorAdjustments,Iu as ColorBySpeedModule,Vg as ColorOverLifetimeModule,Nc as Component,Cm as ComponentEvents,Em as ComponentLifecycleEvents,F2 as ConnectionEvents,bj as ContactPoint,Ft as Context,bY as ContextArgs,Gr as ContextEvent,Pi as ContextRegistry,Jb as ControlTrackHandler,jl as ControllerEvents,Ip as ControllerType,uh as CustomBranding,qo as CustomShader,F0 as DefaultReflectionMode,vT as Deletable,b_ as DeleteBox,oa as DepthOfField,__ as DeviceFlag,AT as DocumentExtension,Kp as DragControls,ev as DropListener,ku as Duplicatable,J0 as EXTENSION_NAME,Ua as EmissionModule,Gp as EmphasizeOnClick,ZC as EngineLoadingView,rr as EventList,eb as EventListEvent,jn as EventSystem,S_ as EventTrigger,ME as FieldWithDefault,T3 as FileSpawnModel,M3 as File_Event,MT as FixedJoint,TT as FlyControls,$p as Fog,An as FrameEvent,a0 as GENERATOR,te as GameObject,Pl as Gizmos,sv as GltfExport,LT as GltfExportBox,qu as GltfLoadEvent,hj as GltfLoadEventType,ah as Gradient,Cu as Graphic,DM as GraphicRaycaster,jo as Graphics,sf as GridHelper,iT as GridLayoutGroup,Du as GroundProjectedEnv,Hc as GroupActionModel,SO as HideFlags,nT as HideOnStart,tv as HingeJoint,tT as HorizontalLayoutGroup,J8 as HostData,Np as Image,U0 as ImageReference,bL as ImageReferenceSerializer,ch as InheritVelocityModule,iD as Input,ys as InputEvents,Lu as InputField,En as InstancingUtil,H2 as InstantiateEvent,Or as InstantiateIdProvider,xa as InstantiateOptions,bp as Interactable,U8 as JoinedRoomResponse,U6 as KeyEventArgs,ov as LODGroup,Uu as LODModel,F8 as LeftRoomResponse,Sn as Light,xL as LightData,Es as LimitVelocityOverLifetimeModule,DY as LoadingElementOptions,zT as LogStats,co as LogType,Fu as LookAt,ag as LookAtConstraint,ur as MainModule,FM as MarkerType,Ng as MaskableGraphic,it as Mathf,Lg as MeshCollider,rb as MeshRenderer,ht as MinMaxCurve,wn as MinMaxGradient,Yo as NEEDLE_progressive,jy as NEKeyboardEvent,vl as NEPointerEvent,Pi as NeedleEngine,KI as NeedleEngineHTMLElement,XI as NeedleGltfLoader,_0 as NeedlePatchesKey,P_ as NestedGltf,z2 as NetworkConnection,Bu as Networking,gi as NoiseModule,Ql as ObjectRaycaster,Qz as ObjectUtils,Nu as OffsetConstraint,rf as OpenURL,Wi as OrbitControls,Fp as Outline,N2 as OwnershipEvent,o0 as OwnershipModel,ih as Padding,Hg as ParticleBurst,X_ as ParticleSubEmitter,Ts as ParticleSystem,Eo as ParticleSystemRenderer,L2 as PeerNetworking,gD as Physics,Ia as PhysicsMaterialCombine,gv as PixelationEffect,nh as PlayAnimationOnClick,Hp as PlayAudioOnClick,_u as PlayableDirector,Ju as PlayerColor,Xu as PlayerState,aj as PlayerStateEvent,yx as PlayerSync,FL as PlayerView,NL as PlayerViewManager,lc as PointerEventData,Qd as PointerType,Pr as PostProcessingEffect,Y_ as PostProcessingHandler,Wp as PreliminaryAction,zg as PreliminaryTrigger,_I as PrimitiveType,xU as ProgressiveLoadingInfo,Ny as PromiseAllWithErrors,Qk as PromiseErrorResult,Ai as RGBAColor,Vv as RapierPhysics,o_ as RawImage,po as RaycastOptions,Rp as Raycaster,JM as Rect,tn as RectTransform,dp as ReflectionProbe,cb as RegisteredAnimationInfo,ec as RemoteSkybox,up as RenderTexture,TU as RenderTextureSerializer,Ui as Renderer,_L as RendererData,tg as RendererLightmap,Ei as Rigidbody,ds as RigidbodyConstraints,Zi as RoomEvents,Wn as RotationBySpeedModule,Co as RotationOverLifetimeModule,K0 as SceneLightSettings,nn as SceneSwitcher,_v as ScreenCapture,tc as ScreenSpaceAmbientOcclusion,la as ScreenSpaceAmbientOcclusionN8,gn as SendQueue,Qp as SetActiveOnClick,Sv as ShadowCatcher,ps as ShapeModule,Eg as SignalAsset,Dp as SignalReceiver,kp as SignalReceiverEvent,Rg as SignalTrackHandler,KM as Size,sn as SizeBySpeedModule,lh as SizeOverLifetimeModule,TE as SkinnedMeshRenderer,mh as SmoothFollow,CI as SpatialHtml,Mv as SpatialTrigger,ja as SpatialTriggerReceiver,ix as SpectatorCamera,Dg as SphereCollider,mD as SphereIntersection,xj as SphereOverlapResult,ic as Sprite,uf as SpriteData,Qa as SpriteRenderer,Tv as SpriteSheet,NK as StateMachineBehaviour,mv as SubEmitterSystem,nx as SyncedCamera,gh as SyncedRoom,Zc as SyncedTransform,aT as TapGestureTrigger,zb as TeleportTarget,DI as TestRunner,OI as TestSimulateUserData,rn as Text,A_ as TextBuilder,$g as TextExtension,dr as TextureSheetAnimationModule,Ga as TiltShiftEffect,AD as Time,Rv as ToneMapping,Mg as TrackHandler,Gn as TrackType,zi as TrailModule,vp as TransformData,Gu as TransformGizmo,yn as TriggerBuilder,pu as TriggerModel,Y as TypeStore,Tp as UIRaycastUtils,xg as UIRootComponent,go as USDObject,qn as USDZExporter,hh as USDZText,y_ as USDZUIExtension,TC as Upload_Result,IU as UriSerializer,_p as UsageMarker,N8 as UserJoinedOrLeftRoomModel,Ic as VERSION,Zl as VRUserState,OE as VariantAction,Xi as VelocityOverLifetimeModule,eT as VerticalLayoutGroup,kr as VideoPlayer,Ca as ViewDevice,Hu as Vignette,jg as VisibilityAction,cc as Voip,ux as Volume,Mt as VolumeParameter,Pg as VolumeProfile,woe as WaitForFrames,Oz as WaitForSeconds,ac as Watch,Zg as WebAR,px as WebARCameraBackground,na as WebARSessionRoot,Tt as WebXR,Kc as WebXRAvatar,Ss as WebXRController,Mi as WebXREvent,mx as WebXRImageTracking,sc as WebXRImageTrackingModel,Wu as WebXRPlaneTracking,qg as WebXRSync,Vu as WebXRTrackedImage,Nn as XRFlag,vx as XRGrabModel,jI as XRGrabRendering,g_ as XRRig,Xm as XRSessionMode,Fn as XRState,us as XRStateFlag,QI as __Ignore,wO as __internalNotifyObjectDestroyed,_l as activeInHierarchyFieldName,zk as addAttributeChangeCallback,j7 as addCustomExtension,I3 as addFile,R3 as addFileFromUrl,Sle as addGltfLoadEventListener,Rc as addNewComponent,b0 as addPatch,f0 as apply,Lle as applyHMRChanges,X2 as beginListenDestroy,P3 as beginListenFileSpawn,q2 as beginListenInstantiate,IS as binaryIdentifierCasts,yY as build_scene_functions,su as builtinComponentKeyName,KC as calculateProgress01,W7 as colorSerializer,tb as componentSerializer,pD as copyTexture,qI as createGLTFLoader,oF as createMotion,Vr as debugNet,wm as debugOwner,Ly as deepClone,dm as delay,A0 as deserializeObject,wl as destroy,tO as destroyComponentInstance,y3 as detectARSupport,b3 as detectVRSupport,Ci as disposeObjectResources,gL as download,RC as download_file,Sm as editorGuidKeyName,gI as effectsOrder,J7 as eventListSerializer,Lm as findByGuid,rO as findObjectOfType,nO as findObjectsOfType,cC as findResourceUsers,ou as foreachComponent,dC as foreachComponentEnumerator,V6 as forward,u0 as generateSeed,Wd as getComponent,Tm as getComponentInChildren,Rm as getComponentInParent,Mm as getComponents,Im as getComponentsInChildren,p0 as getComponentsInParent,v6 as getIp,A6 as getIpAndLocation,g6 as getIpCloudflare,Ho as getLoader,d0 as getOrAddComponent,oe as getParam,u6 as getPath,k8 as getPeerOptions,XS as getPeerjsInstance,I9 as getResourceUserCount,hm as getUrlParams,X6 as getWorldDirection,cD as getWorldEuler,_t as getWorldPosition,Ds as getWorldQuaternion,Gy as getWorldRotation,Zs as getWorldScale,VC as hasIndieLicense,ip as hasProLicense,IC as hash,Um as instantiate,CO as isActiveInHierarchy,Yd as isActiveSelf,dD as isAnimationAction,l6 as isDebugMode,uC as isDestroyed,oi as isDevEnvironment,M9 as isDisposed,Gk as isHostedOnGlitch,Ble as isHotReloading,Qr as isLocalNetwork,pl as isMobileDevice,Fy as isMozillaXR,f6 as isQuest,bO as isResourceTrackingEnabled,fl as isSafari,E0 as isUsingInstancing,pm as isiOS,YI as loadSync,Vy as logHierarchy,j6 as lookAtInverse,h6 as makeId,Lk as makeIdFromRandomWords,EO as markAsInstancedRendered,ZS as moveComponentInstance,a6 as nameof,Oy as nameofFactory,MU as objectSerializer,dj as parseSync,MJ as prefix,Bk as pushState,kk as randomNumber,qy as registerBinaryType,W0 as registerComponent,SE as registerComponentExtension,So as registerCustomEffectType,SU as registerExtensions,kle as registerHotReloadType,PC as registerLoader,K2 as registerPrefabProvider,u9 as registerType,Fk as relativePathPrefix,jk as removeAttributeChangeCallback,JS as removeComponent,Q7 as removeCustomExtension,Cle as removeGltfLoadEventListener,S9 as removePatch,dl as resolveUrl,Uk as sanitizeString,ece as saveImage,$le as screenshot,W2 as sendDestroyed,x as serializable,hO as serializeObject,cp as serializeable,Om as setActive,b6 as setAllowOverlayMessages,TO as setDestroyed,L6 as setDevEnvironment,lC as setDisposable,um as setOrAddParamsToUrl,c6 as setParam,Pk as setParamWithoutReload,D8 as setPeerOptions,E9 as setResourceTrackingEnabled,dS as setState,hD as setWorldEuler,bs as setWorldPosition,Gd as setWorldPositionXYZ,fn as setWorldQuaternion,rD as setWorldQuaternionXYZW,uD as setWorldRotation,Hy as setWorldRotationXYZ,CS as setWorldScale,O6 as showBalloonError,ls as showBalloonMessage,Sr as showBalloonWarning,_S as showDebugConsole,sD as slerp,h0 as syncDestroy,yI as syncField,YS as syncInstantiate,Y6 as textureToCanvas,_D as tryCastBinary,Nd as tryFindObject,fj as tryFindObjectByName,Mle as tryFindScript,xD as tryGetGuid,Dle as unregisterHotReloadType,Nk as unwatchWrite,mL as upload_file,ar as validate,pS 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(Fv),this.classList.remove(Nv);const e=this.getAROverlayContainer();mr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Fv),e.classList.remove(Nv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,zL))}onSetupVR(){this.classList.remove(Fv),this.classList.remove(Nv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,gj))}onSetupDesktop(){this.classList.remove(Fv),this.classList.add(Nv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Fv),e.classList.add(Nv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,vj))}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 Tle)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&&(mr&&console.log("using custom draco decoder path",e),oU(e));const t=this.getAttribute("dracoDecoderType");t&&(mr&&console.log("using custom draco decoder type",t),aU(t));const s=this.getAttribute("ktx2DecoderPath");s&&(mr&&console.log("using custom ktx2 decoder path",s),lU(s))}}typeof window<"u"&&!window.customElements.get(mj)&&window.customElements.define(mj,KI);function Rle(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 Ple=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:KI},Symbol.toStringTag,{value:"Module"})),bx=oe("debughotreload");let zv=!1;const jv=new Map;function Ble(){return zv}function kle(i){var e;if(zv)return;const t=i.constructor.name;jv.has(t)?(e=jv.get(t))==null||e.push(i):jv.set(t,[i])}function Dle(i){if(zv)return;const e=i.constructor.name,t=jv.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let Aj=!1;function Ole(){if(bx||Aj)return;Aj=!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 Lle(i){bx&&console.log("[HMR] Apply changes",i,Object.keys(i)),Ole();for(const e of Object.keys(i))try{zv=!0;const t=Y.get(e);if(!t){bx&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=jv.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&&Sl(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&&fC(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(bx)console.error(t);else return!1}finally{zv=!1,ml(co.Log,"Script changes applied (HMR)")}return!0}const Ule=Symbol("object"),yj=new Aa(()=>new w,20);class bj{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 yj.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return yj.get().set(this._normal.x,this._normal.y,this._normal.z)}}class _j{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 xj{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const Qv=new Array(32).fill(void 0);Qv.push(void 0,null,!0,!1);let wj;Qv.length;function Sj(){return wj.byteLength,wj}const Fle=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}Fle.decode();let Cj,Ej,Gv=32;function Mj(i){if(Gv==1)throw new Error("out of js stack");return Qv[--Gv]=i,Gv}function Nle(){return Cj.byteLength,Cj}function zle(){return Ej.byteLength,Ej}let $n=0;function Yu(i,e){const t=e(4*i.length);return Nle().set(i,t/4),$n=i.length,t}function _x(i,e){const t=e(4*i.length);return zle().set(i,t/4),$n=i.length,t}class Hx{static __wrap(e){const t=Object.create(Hx.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 Hx.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,Mj(e))}finally{Qv[Gv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,Mj(e))}finally{Qv[Gv++]=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,qs),vt(s,dt),vt(r,qs);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 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_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return dt.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();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=Sj()[s/4+0],t=Sj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class qs{static __wrap(e){const t=Object.create(qs.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 qs.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return qs.__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=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Yu(e,ze.__wbindgen_malloc),r=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,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=$n;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=$n,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=$n,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=$n,n=_x(t,ze.__wbindgen_malloc),o=$n,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=$n,o=_x(t,ze.__wbindgen_malloc),a=$n,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,qs),vt(s,dt),vt(r,Qt),vt(n,dt),vt(o,qs),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:pR.__wrap(c)}intersectsShape(e,t,s,r,n){return vt(e,dt),vt(t,qs),vt(s,Qt),vt(r,dt),vt(n,qs),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,qs),vt(s,Qt),vt(r,dt),vt(n,qs);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,s){return vt(e,dt),vt(t,qs),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,qs),vt(s,dt);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return hR.__wrap(n)}intersectsRay(e,t,s,r,n){return vt(e,dt),vt(t,qs),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,qs),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,qs),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:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();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 pR{static __wrap(e){const t=Object.create(pR.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 jle{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class ke{static new(e,t,s){return new jle(e,t,s)}static intoRaw(e){return new dt(e.x,e.y,e.z)}static zeros(){return ke.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=ke.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 Tj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class Di{static identity(){return new Tj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Tj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qs(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 Hv,Va,Ij,Io,JI,Zt,xx,mf,ZI,$I,Rj,Pj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Hv||(Hv={}));class Qle{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 ke.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return ke.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=ke.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=ke.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 ke.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return ke.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=ke.intoRaw(t),a=ke.intoRaw(s),l=Di.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=ke.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.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"}(Ij||(Ij={}));class xf{constructor(){}static fixed(e,t,s,r){let n=new xf;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 xf;return s.anchor1=e,s.anchor2=t,s.jointType=Va.Spherical,s}static prismatic(e,t,s){let r=new xf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Prismatic,r}static revolute(e,t,s){let r=new xf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Va.Revolute,r}intoRaw(){let e,t,s=ke.intoRaw(this.anchor1),r=ke.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Va.Fixed:let l=Di.intoRaw(this.frame1),c=Di.intoRaw(this.frame2);t=Ka.fixed(s,l,r,c),l.free(),c.free();break;case Va.Prismatic:e=ke.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=ke.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"})(Io||(Io={}));class Jv{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 Jv(e.distance(),ke.fromRaw(e.point1()),ke.fromRaw(e.point2()),ke.fromRaw(e.normal1()),ke.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"})(JI||(JI={}));class Vx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Vx(ke.fromRaw(e.point()),e.isInside());return e.free(),t}}class Gle{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 Wx{constructor(e,t,s,r){this.featureType=JI.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 Wx(e.toi(),ke.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Zv{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 Zv(t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class fR extends Zv{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 fR(e.get(t.colliderHandle()),t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class gr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case Zt.Ball:return new eR(e.coRadius(t));case Zt.Cuboid:return r=e.coHalfExtents(t),new Bj(r.x,r.y,r.z);case Zt.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new kj(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 Oj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Fj(o,a);case Zt.Triangle:return o=e.coVertices(t),new Lj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new Uj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]),n);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new Nj(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new zj(p,f,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new tR(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new iR(o,a,n);case Zt.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new jj(l,c);case Zt.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Qj(l,c,n);case Zt.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new Gj(l,c);case Zt.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Hj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=ke.intoRaw(e),u=Di.intoRaw(t),d=ke.intoRaw(s),p=ke.intoRaw(n),f=Di.intoRaw(o),m=ke.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Zv.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=ke.intoRaw(e),a=Di.intoRaw(t),l=ke.intoRaw(r),c=Di.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=ke.intoRaw(e),l=Di.intoRaw(t),c=ke.intoRaw(r),u=Di.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Jv.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=ke.intoRaw(e),n=Di.intoRaw(t),o=ke.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=ke.intoRaw(e),o=Di.intoRaw(t),a=ke.intoRaw(s),l=this.intoRaw(),c=Vx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=ke.intoRaw(t),o=Di.intoRaw(s),a=ke.intoRaw(e.origin),l=ke.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=ke.intoRaw(t),a=Di.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.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=ke.intoRaw(t),a=Di.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=Wx.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 eR extends gr{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class Bj extends gr{constructor(e,t,s){super(),this.type=Zt.Cuboid,this.halfExtents=ke.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class kj extends gr{constructor(e,t,s,r){super(),this.type=Zt.RoundCuboid,this.halfExtents=ke.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 gr{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class Oj extends gr{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class Lj extends gr{constructor(e,t,s){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class Uj extends gr{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=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Fj extends gr{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 Nj extends gr{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class tR extends gr{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 iR extends gr{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 zj extends gr{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=ke.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class jj extends gr{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class Qj extends gr{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 Gj extends gr{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Hj extends gr{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"})(xx||(xx={}));class Hle{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=gr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return ke.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,s,r){let n=ke.intoRaw(t),o=ke.intoRaw(s),a=Di.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 ke.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 ke.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=ke.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=ke.intoRaw(e),r=Vx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=ke.intoRaw(e.origin),r=ke.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=ke.intoRaw(e),l=ke.intoRaw(s),c=Di.intoRaw(r),u=ke.intoRaw(n),d=t.intoRaw(),p=Zv.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=ke.intoRaw(e),o=ke.intoRaw(s),a=fR.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=ke.intoRaw(t),n=Di.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=ke.intoRaw(t),o=Di.intoRaw(s),a=e.intoRaw(),l=Jv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Jv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=ke.intoRaw(e.origin),n=ke.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=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=Wx.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"})(mf||(mf={}));class Qi{constructor(e){this.shape=e,this.massPropsMode=mf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=ke.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Io.Average,this.restitutionCombineRule=Io.Average,this.activeCollisionTypes=xx.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=ke.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=ke.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new eR(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 Oj(e,t);return new Qi(s)}static triangle(e,t,s){const r=new Lj(e,t,s);return new Qi(r)}static roundTriangle(e,t,s,r){const n=new Uj(e,t,s,r);return new Qi(n)}static polyline(e,t){const s=new Fj(e,t);return new Qi(s)}static trimesh(e,t){const s=new Nj(e,t);return new Qi(s)}static cuboid(e,t,s){const r=new Bj(e,t,s);return new Qi(r)}static roundCuboid(e,t,s,r){const n=new kj(e,t,s,r);return new Qi(n)}static heightfield(e,t,s,r){const n=new zj(e,t,s,r);return new Qi(n)}static cylinder(e,t){const s=new jj(e,t);return new Qi(s)}static roundCylinder(e,t,s){const r=new Qj(e,t,s);return new Qi(r)}static cone(e,t){const s=new Gj(e,t);return new Qi(s)}static roundCone(e,t,s){const r=new Hj(e,t,s);return new Qi(r)}static convexHull(e){const t=new tR(e,null);return new Qi(t)}static convexMesh(e,t){const s=new tR(e,t);return new Qi(s)}static roundConvexHull(e,t){const s=new iR(e,null,t);return new Qi(s)}static roundConvexMesh(e,t,s){const r=new iR(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 Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=mf.Density,this.density=e,this}setMass(e){return this.massPropsMode=mf.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=mf.MassProps,this.mass=e,ke.copy(this.centerOfMass,t),ke.copy(this.principalAngularInertia,s),Di.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"})(ZI||(ZI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}($I||($I={}));class Vle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return ke.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return ke.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class Wle{constructor(e,t){this.raw=t||new Hx(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Vle;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"})(Rj||(Rj={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Pj||(Pj={}));for(var dce={byteLength:function(i){var e=Vj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Vj(i),r=s[0],n=s[1],o=new Xle(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=Ro[i.charCodeAt(t)]<<18|Ro[i.charCodeAt(t+1)]<<12|Ro[i.charCodeAt(t+2)]<<6|Ro[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=Ro[i.charCodeAt(t)]<<2|Ro[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=Ro[i.charCodeAt(t)]<<10|Ro[i.charCodeAt(t+1)]<<4|Ro[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(Yle(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=[],Ro=[],Xle=typeof Uint8Array<"u"?Uint8Array:Array,sR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gf=0,qle=sR.length;gf<qle;++gf)Wa[gf]=sR[gf],Ro[sR.charCodeAt(gf)]=gf;function Vj(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 Yle(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("")}Ro["-".charCodeAt(0)]=62,Ro["_".charCodeAt(0)]=63;const an=oe("debugphysics"),rR=oe("debugcolliderplacement"),nR=oe("debugcollisions"),Kle=oe("showcolliders"),eo=Symbol("needle component"),to=Symbol("physics body"),Jle=Symbol("rigidbody");let vf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,an&&console.log("Use Rapier",!1,globalThis.false);const wx=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new Gle({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new Aa(()=>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 Ie),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[to];if(i[to]=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 Hle){const a=o;(e=this.world)==null||e.removeCollider(a,!0);const l=a.parent();l&&l.numColliders()<=0&&(l[eo]||(t=this.world)==null||t.removeRigidBody(l))}else o instanceof Qle&&(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[to];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){if(this.validate(),i.isCollider){const e=i,t=e[to];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 an&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&an&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||an&&(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[eo])!=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[eo]}}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[eo])!=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[eo]}}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)&&(an&&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 eR(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[eo],r=new xj(s.gameObject,s);return this.rapierColliderArray.push(r),!0},ZI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[eo].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){an&&console.warn("Physics are disabled");return}const s=i.gameObject,r=Zs(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){an&&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){an&&console.warn("Physics are disabled");return}const r=i.gameObject,n=Zs(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){an&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){an&&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=qY(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))an&&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[to]:null}getComponent(i){return i?i[eo]: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),Zs(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(Io.Average);break;case Ia.Maximum:e.setRestitutionCombineRule(Io.Max);break;case Ia.Minimum:e.setRestitutionCombineRule(Io.Min);break;case Ia.Multiply:e.setRestitutionCombineRule(Io.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Ia.Average:e.setFrictionCombineRule(Io.Average);break;case Ia.Maximum:e.setFrictionCombineRule(Io.Max);break;case Ia.Minimum:e.setFrictionCombineRule(Io.Min);break;case Ia.Multiply:e.setFrictionCombineRule(Io.Multiply);break}}n&&e.setDensity(0);const a=this.world.createCollider(e,r);return a[eo]=i,i[to]=a,a.setActiveEvents($I.COLLISION_EVENTS),a.setActiveCollisionTypes(xx.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[to],s=r.autoMass===!1,!t){const n=r.isKinematic&&!rR;an&&console.log("Create rigidbody",n);const o=n?vf.RigidBodyDesc.kinematicPositionBased():vf.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[eo]=r,r[to]=t,this.internalUpdateRigidbodyProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=vf.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[eo]=null}return i[Jle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[to]}internalUpdateColliderProperties(i,e){const t=e.shape;switch(t.type){case Zt.Ball:{const n=t,o=i,a=i.gameObject,l=Zs(a,this._tempPosition),c=Math.abs(o.radius*l.x),u=n.radius!==c;n.radius=c,u&&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(vf.RigidBodyType.KinematicPositionBased):e.setBodyType(vf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new Wle(!1)),i&&(this.world.timestep=it.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(an||rR||Kle||this.debugRenderColliders===!0){if(!this.lines){const n=new ns({color:2258688,fog:!1}),o=new mt;this.lines=new On(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 Zle(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!rR)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}Gd(e.gameObject,r.x,r.y,r.z),rD(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 Hv.Fixed:case Hv.KinematicPositionBased:case Hv.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=wx._matricesBuffer,s.length=0),i===e){const r=Zs(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[to],s=e[to];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=xf.fixed(wx.centerConnectionPos,wx.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);an&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[to],n=e[to];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=vf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);an&&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 Vv=wx;h(Vv,"_didLoadPhysicsEngine",!1),h(Vv,"_matricesBuffer",[]),h(Vv,"centerConnectionPos",{x:0,y:0,z:0}),h(Vv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zle{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[eo],a=n[eo];nR&&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||nR){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 bj(A,g,f,v,b);p.push(y),nR&&Pl.DrawDirection(A,f,16711680,3,!0)}}n=new _j(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 $le(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 Wv=null;function ece(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}Wv||(Wv=document.createElement("a")),Wv.href=i,Wv.download=e,Wv.click()}}const Sx=oe("debugmissingcamera");Pi.registerCallback(Gr.MissingCamera,i=>{var e,t;Sx&&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,Wj(i.context,o),o}),Pi.registerCallback(Gr.ContextCreated,i=>{if(!i.context.mainCamera){Sx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Ute(i.context.mainCamera);if(t?.isCameraController===!0){Sx&&console.log("Will not auto-fit because a camera controller exists");return}Wj(i.context)}});function Wj(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(Sx&&console.log("Creating default camera controls",e?.name),t){const s=d0(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")}_6();const oR={Context:Ft,glTF:{loadFromURL:YI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=oR;function Xj(i){for(const e in i)oR[e]=i[e]}Xj(wY),Xj(fle);for(const i of Object.getOwnPropertyNames(te))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:oR[i]=te[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=o6;var aR={},qj={};Object.defineProperty(qj,"__esModule",{value:!0});var Cx={};Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.ConstantBackoff=void 0;var tce=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();Cx.ConstantBackoff=tce;var Ex={};Object.defineProperty(Ex,"__esModule",{value:!0}),Ex.ExponentialBackoff=void 0;var ice=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}();Ex.ExponentialBackoff=ice;var Mx={};Object.defineProperty(Mx,"__esModule",{value:!0}),Mx.LinearBackoff=void 0;var sce=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}();Mx.LinearBackoff=sce;var Yj={};Object.defineProperty(Yj,"__esModule",{value:!0});var Tx={};Object.defineProperty(Tx,"__esModule",{value:!0}),Tx.LRUBuffer=void 0;var rce=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}();Tx.LRUBuffer=rce;var Ix={};Object.defineProperty(Ix,"__esModule",{value:!0}),Ix.TimeBuffer=void 0;var nce=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}();Ix.TimeBuffer=nce;var lR={};(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})(lR);var Rx={};Object.defineProperty(Rx,"__esModule",{value:!0}),Rx.WebsocketBuilder=void 0;var Af=lR,oce=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 Af.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(Af.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(Af.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(Af.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(Af.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(Af.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();Rx.WebsocketBuilder=oce,function(i){var e=Yy&&Yy.__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=Yy&&Yy.__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(qj,i),t(Cx,i),t(Ex,i),t(Mx,i),t(Yj,i),t(Tx,i),t(Ix,i),t(lR,i),t(Rx,i)}(aR);const ace=fm(aR),lce=sQ({__proto__:null,default:ace},[aR]),Po={node:"node",material:"material",camera:"camera",light:"light"},Ku="KHR_animation_pointer",cce={CUBICSPLINE:void 0,LINEAR:pa,STEP:vc},Kj=Ot.findNode;let Jj=!1;class hce{constructor(e){this.parser=e,this.name=Ku,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Jj||(Jj=!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=Kj(e,s[2]);return n||console.warn(Ku+": Property binding not found",t,e,e.name,s),n}return r}return Kj(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=Po.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=Po.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=Po.light:c.startsWith("/cameras/")&&(n=Po.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case Po.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 Po.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 Po.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 Po.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===Po.node?a=this.parser.getDependency("node",o):n===Po.material?a=this.parser.getDependency("material",o):n===Po.light?a=this.parser.getDependency("light",o):n===Po.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 jh&&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=wc;break;case 2:case 3:p=cl;break;case 4:o.endsWith(".quaternion")?p=va:p=yy;break}const f=r.interpolation!==void 0?cce[r.interpolation]:pa;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 jr(o,void 0,b)})}}const uce=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hce},Symbol.toStringTag,{value:"Module"}));export{Ule as $physicsKey,di as ActionBuilder,LE as ActionCollection,Jo as ActionModel,yL as Addressables,rg as AlignmentConstraint,ep as AmbientMode,Un as Animation,fu as AnimationCurve,hb as AnimationExtension,Kb as AnimationTrackHandler,Ir as Animator,Xc as AnimatorConditionMode,bh as AnimatorController,FE as AnimatorControllerParameterType,ub as AnimatorStateInfo,Bg as Antialiasing,wL as Application,N0 as ApplicationEvents,AO as AssetDatabase,Qs as AssetReference,ka as AttachedObject,jb as AttachedObjectEvents,Zb as AudioExtension,bu as AudioListener,hs as AudioSource,Ig as AudioTrackHandler,xu as AvatarBlink_Simple,Lp as AvatarEyeLook_Rotation,Ab as AvatarLoader,Rr as AvatarMarker,vb as AvatarModel,ug as Avatar_Brain_LookAt,kg as Avatar_MouthShapes,jM as Avatar_MustacheShake,Zr as Avatar_POI,xp as Axes,Up as AxesHelper,ca as BaseUIComponent,VM as BasicIKConstraint,t_ as BehaviorExtension,Jr as BehaviorModel,Re as Behaviour,wu as Bloom,Og as BoxCollider,Su as BoxGizmo,Ma as BoxHelperComponent,Xl as Button,hp as CallInfo,Bi as Camera,cr as Canvas,rh as CanvasGroup,th as CapsuleCollider,jp as ChangeMaterialOnClick,Mu as ChangeTransformOnClick,Tu as CharacterController,Kl as CharacterControllerInput,Qg as ChromaticAberration,Aa as CircularBuffer,Xb as ClearFlags,Da as ClipExtrapolation,Oa as Collider,_j as Collision,bb as CollisionDetectionMode,oh as ColorAdjustments,Iu as ColorBySpeedModule,Vg as ColorOverLifetimeModule,Nc as Component,Cm as ComponentEvents,Em as ComponentLifecycleEvents,F2 as ConnectionEvents,bj as ContactPoint,Ft as Context,bY as ContextArgs,Gr as ContextEvent,Pi as ContextRegistry,Jb as ControlTrackHandler,jl as ControllerEvents,Ip as ControllerType,uh as CustomBranding,qo as CustomShader,F0 as DefaultReflectionMode,vT as Deletable,b_ as DeleteBox,oa as DepthOfField,__ as DeviceFlag,AT as DocumentExtension,Kp as DragControls,ev as DropListener,ku as Duplicatable,J0 as EXTENSION_NAME,Ua as EmissionModule,Gp as EmphasizeOnClick,ZC as EngineLoadingView,rr as EventList,eb as EventListEvent,jn as EventSystem,S_ as EventTrigger,ME as FieldWithDefault,T3 as FileSpawnModel,M3 as File_Event,MT as FixedJoint,TT as FlyControls,$p as Fog,An as FrameEvent,a0 as GENERATOR,te as GameObject,Pl as Gizmos,sv as GltfExport,LT as GltfExportBox,qu as GltfLoadEvent,hj as GltfLoadEventType,ah as Gradient,Cu as Graphic,DM as GraphicRaycaster,jo as Graphics,sf as GridHelper,iT as GridLayoutGroup,Du as GroundProjectedEnv,Hc as GroupActionModel,SO as HideFlags,nT as HideOnStart,tv as HingeJoint,tT as HorizontalLayoutGroup,J8 as HostData,Np as Image,U0 as ImageReference,bL as ImageReferenceSerializer,ch as InheritVelocityModule,iD as Input,ys as InputEvents,Lu as InputField,En as InstancingUtil,H2 as InstantiateEvent,Or as InstantiateIdProvider,xa as InstantiateOptions,bp as Interactable,U8 as JoinedRoomResponse,U6 as KeyEventArgs,ov as LODGroup,Uu as LODModel,F8 as LeftRoomResponse,Sn as Light,xL as LightData,Es as LimitVelocityOverLifetimeModule,DY as LoadingElementOptions,zT as LogStats,co as LogType,Fu as LookAt,ag as LookAtConstraint,ur as MainModule,FM as MarkerType,Ng as MaskableGraphic,it as Mathf,Lg as MeshCollider,rb as MeshRenderer,ht as MinMaxCurve,wn as MinMaxGradient,Yo as NEEDLE_progressive,jy as NEKeyboardEvent,vl as NEPointerEvent,Pi as NeedleEngine,KI as NeedleEngineHTMLElement,XI as NeedleGltfLoader,_0 as NeedlePatchesKey,P_ as NestedGltf,z2 as NetworkConnection,Bu as Networking,gi as NoiseModule,Ql as ObjectRaycaster,Qz as ObjectUtils,Nu as OffsetConstraint,rf as OpenURL,Wi as OrbitControls,Fp as Outline,N2 as OwnershipEvent,o0 as OwnershipModel,ih as Padding,Hg as ParticleBurst,X_ as ParticleSubEmitter,Ts as ParticleSystem,Eo as ParticleSystemRenderer,L2 as PeerNetworking,gD as Physics,Ia as PhysicsMaterialCombine,gv as PixelationEffect,nh as PlayAnimationOnClick,Hp as PlayAudioOnClick,_u as PlayableDirector,Ju as PlayerColor,Xu as PlayerState,aj as PlayerStateEvent,yx as PlayerSync,FL as PlayerView,NL as PlayerViewManager,lc as PointerEventData,Qd as PointerType,Pr as PostProcessingEffect,Y_ as PostProcessingHandler,Wp as PreliminaryAction,zg as PreliminaryTrigger,_I as PrimitiveType,xU as ProgressiveLoadingInfo,Ny as PromiseAllWithErrors,Qk as PromiseErrorResult,Ai as RGBAColor,Vv as RapierPhysics,o_ as RawImage,po as RaycastOptions,Rp as Raycaster,JM as Rect,tn as RectTransform,dp as ReflectionProbe,cb as RegisteredAnimationInfo,ec as RemoteSkybox,up as RenderTexture,TU as RenderTextureSerializer,Ui as Renderer,_L as RendererData,tg as RendererLightmap,Ei as Rigidbody,ds as RigidbodyConstraints,Zi as RoomEvents,Wn as RotationBySpeedModule,Co as RotationOverLifetimeModule,K0 as SceneLightSettings,nn as SceneSwitcher,_v as ScreenCapture,tc as ScreenSpaceAmbientOcclusion,la as ScreenSpaceAmbientOcclusionN8,gn as SendQueue,Qp as SetActiveOnClick,Sv as ShadowCatcher,ps as ShapeModule,Eg as SignalAsset,Dp as SignalReceiver,kp as SignalReceiverEvent,Rg as SignalTrackHandler,KM as Size,sn as SizeBySpeedModule,lh as SizeOverLifetimeModule,TE as SkinnedMeshRenderer,mh as SmoothFollow,CI as SpatialHtml,Mv as SpatialTrigger,ja as SpatialTriggerReceiver,ix as SpectatorCamera,Dg as SphereCollider,mD as SphereIntersection,xj as SphereOverlapResult,ic as Sprite,uf as SpriteData,Qa as SpriteRenderer,Tv as SpriteSheet,NK as StateMachineBehaviour,mv as SubEmitterSystem,nx as SyncedCamera,gh as SyncedRoom,Zc as SyncedTransform,aT as TapGestureTrigger,zb as TeleportTarget,DI as TestRunner,OI as TestSimulateUserData,rn as Text,A_ as TextBuilder,$g as TextExtension,dr as TextureSheetAnimationModule,Ga as TiltShiftEffect,AD as Time,Rv as ToneMapping,Mg as TrackHandler,Gn as TrackType,zi as TrailModule,vp as TransformData,Gu as TransformGizmo,yn as TriggerBuilder,pu as TriggerModel,Y as TypeStore,Tp as UIRaycastUtils,xg as UIRootComponent,go as USDObject,qn as USDZExporter,hh as USDZText,y_ as USDZUIExtension,TC as Upload_Result,IU as UriSerializer,_p as UsageMarker,N8 as UserJoinedOrLeftRoomModel,Ic as VERSION,Zl as VRUserState,OE as VariantAction,Xi as VelocityOverLifetimeModule,eT as VerticalLayoutGroup,kr as VideoPlayer,Ca as ViewDevice,Hu as Vignette,jg as VisibilityAction,cc as Voip,ux as Volume,Mt as VolumeParameter,Pg as VolumeProfile,woe as WaitForFrames,Oz as WaitForSeconds,ac as Watch,Zg as WebAR,px as WebARCameraBackground,na as WebARSessionRoot,Tt as WebXR,Kc as WebXRAvatar,Ss as WebXRController,Mi as WebXREvent,mx as WebXRImageTracking,sc as WebXRImageTrackingModel,Wu as WebXRPlaneTracking,qg as WebXRSync,Vu as WebXRTrackedImage,Nn as XRFlag,vx as XRGrabModel,jI as XRGrabRendering,g_ as XRRig,Xm as XRSessionMode,Fn as XRState,us as XRStateFlag,QI as __Ignore,wO as __internalNotifyObjectDestroyed,_l as activeInHierarchyFieldName,zk as addAttributeChangeCallback,j7 as addCustomExtension,I3 as addFile,R3 as addFileFromUrl,Sle as addGltfLoadEventListener,Rc as addNewComponent,b0 as addPatch,f0 as apply,Lle as applyHMRChanges,X2 as beginListenDestroy,P3 as beginListenFileSpawn,q2 as beginListenInstantiate,IS as binaryIdentifierCasts,yY as build_scene_functions,su as builtinComponentKeyName,KC as calculateProgress01,W7 as colorSerializer,tb as componentSerializer,pD as copyTexture,qI as createGLTFLoader,oF as createMotion,Vr as debugNet,wm as debugOwner,Ly as deepClone,dm as delay,A0 as deserializeObject,wl as destroy,tO as destroyComponentInstance,y3 as detectARSupport,b3 as detectVRSupport,Ci as disposeObjectResources,gL as download,RC as download_file,Sm as editorGuidKeyName,gI as effectsOrder,J7 as eventListSerializer,Lm as findByGuid,rO as findObjectOfType,nO as findObjectsOfType,cC as findResourceUsers,ou as foreachComponent,dC as foreachComponentEnumerator,V6 as forward,u0 as generateSeed,Wd as getComponent,Tm as getComponentInChildren,Rm as getComponentInParent,Mm as getComponents,Im as getComponentsInChildren,p0 as getComponentsInParent,v6 as getIp,A6 as getIpAndLocation,g6 as getIpCloudflare,Ho as getLoader,d0 as getOrAddComponent,oe as getParam,u6 as getPath,k8 as getPeerOptions,XS as getPeerjsInstance,I9 as getResourceUserCount,hm as getUrlParams,X6 as getWorldDirection,cD as getWorldEuler,_t as getWorldPosition,Ds as getWorldQuaternion,Gy as getWorldRotation,Zs as getWorldScale,VC as hasIndieLicense,ip as hasProLicense,IC as hash,Um as instantiate,CO as isActiveInHierarchy,Yd as isActiveSelf,dD as isAnimationAction,l6 as isDebugMode,uC as isDestroyed,oi as isDevEnvironment,M9 as isDisposed,Gk as isHostedOnGlitch,Ble as isHotReloading,Qr as isLocalNetwork,pl as isMobileDevice,Fy as isMozillaXR,f6 as isQuest,bO as isResourceTrackingEnabled,fl as isSafari,E0 as isUsingInstancing,pm as isiOS,YI as loadSync,Vy as logHierarchy,j6 as lookAtInverse,h6 as makeId,Lk as makeIdFromRandomWords,EO as markAsInstancedRendered,ZS as moveComponentInstance,a6 as nameof,Oy as nameofFactory,MU as objectSerializer,dj as parseSync,MJ as prefix,Bk as pushState,kk as randomNumber,qy as registerBinaryType,W0 as registerComponent,SE as registerComponentExtension,So as registerCustomEffectType,SU as registerExtensions,kle as registerHotReloadType,PC as registerLoader,K2 as registerPrefabProvider,u9 as registerType,Fk as relativePathPrefix,jk as removeAttributeChangeCallback,JS as removeComponent,Q7 as removeCustomExtension,Cle as removeGltfLoadEventListener,S9 as removePatch,dl as resolveUrl,Uk as sanitizeString,ece as saveImage,$le as screenshot,W2 as sendDestroyed,x as serializable,hO as serializeObject,cp as serializeable,Om as setActive,b6 as setAllowOverlayMessages,TO as setDestroyed,L6 as setDevEnvironment,lC as setDisposable,um as setOrAddParamsToUrl,c6 as setParam,Pk as setParamWithoutReload,D8 as setPeerOptions,E9 as setResourceTrackingEnabled,dS as setState,hD as setWorldEuler,bs as setWorldPosition,Gd as setWorldPositionXYZ,fn as setWorldQuaternion,rD as setWorldQuaternionXYZW,uD as setWorldRotation,Hy as setWorldRotationXYZ,CS as setWorldScale,O6 as showBalloonError,ls as showBalloonMessage,Sr as showBalloonWarning,_S as showDebugConsole,sD as slerp,h0 as syncDestroy,yI as syncField,YS as syncInstantiate,Y6 as textureToCanvas,_D as tryCastBinary,Nd as tryFindObject,fj as tryFindObjectByName,Mle as tryFindScript,xD as tryGetGuid,Dle as unregisterHotReloadType,Nk as unwatchWrite,mL as upload_file,ar as validate,pS as watchWrite};
|