@needle-tools/engine 3.21.2 → 3.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/needle-engine.js +28 -11
- package/dist/needle-engine.light.js +1397 -1380
- package/dist/needle-engine.light.min.js +93 -93
- package/dist/needle-engine.light.umd.cjs +5 -5
- package/dist/needle-engine.min.js +5 -5
- package/dist/needle-engine.umd.cjs +5 -5
- package/lib/engine/engine_gameobject.js +5 -0
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_input.js +10 -3
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_physics_rapier.js +3 -3
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +5 -0
- package/lib/engine-components/EventList.js +5 -0
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/ui/Button.js +2 -0
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +5 -0
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/engine_gameobject.ts +5 -0
- package/src/engine/engine_input.ts +12 -3
- package/src/engine/engine_physics_rapier.ts +3 -3
- package/src/engine-components/EventList.ts +6 -0
- package/src/engine-components/ui/Button.ts +2 -0
- package/src/engine-components/ui/EventSystem.ts +6 -0
|
@@ -3653,7 +3653,7 @@ Open this page console: `+e.toString())}const n=cl();if(n&&(K2(),J2(!0),n)){cons
|
|
|
3653
3653
|
transform: scale(1, 1);
|
|
3654
3654
|
}
|
|
3655
3655
|
}
|
|
3656
|
-
`,Nr==null||Nr.prepend(t),n===!0&&Tj(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function Dj(){const n=document.querySelector("#__vconsole .vc-switch");return n||null}function Oj(){const n=document.querySelector("#__vconsole");return n||null}function pn(n,e=Bo.Log){Xc(e,n)}function Ls(n){pn(n,Bo.Warn)}function kj(n){pn(n,Bo.Error)}let mE;function ci(){return mE!==void 0?mE:nr()}function Lj(n){mE=n}const uo=re("debuginput");class wc extends PointerEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class h0 extends KeyboardEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class Fj{constructor(e){h(this,"key");h(this,"keyType");h(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var Sn=(n=>(n.PointerDown="pointerdown",n.PointerUp="pointerup",n.PointerMove="pointermove",n.KeyDown="keydown",n.KeyUp="keyup",n.KeyPressed="keypress",n))(Sn||{}),zf=(n=>(n.Mouse="mouse",n.Touch="touch",n))(zf||{});class Z2 extends EventTarget{constructor(t){super();h(this,"_doubleClickTimeThreshold",.2);h(this,"_longPressTimeThreshold",1);h(this,"_specialCursorTrigger",0);h(this,"context");h(this,"_pointerDown",[!1]);h(this,"_pointerUp",[!1]);h(this,"_pointerClick",[!1]);h(this,"_pointerDoubleClick",[!1]);h(this,"_pointerPressed",[!1]);h(this,"_pointerPositions",[new te]);h(this,"_pointerPositionsLastFrame",[new te]);h(this,"_pointerPositionsDelta",[new te]);h(this,"_pointerPositionsRC",[new te]);h(this,"_pointerPositionDown",[new te]);h(this,"_pointerDownTime",[]);h(this,"_pointerUpTime",[]);h(this,"_pointerUpTimestamp",[]);h(this,"_pointerIds",[]);h(this,"_pointerTypes",[""]);h(this,"_mouseWheelChanged",[!1]);h(this,"_mouseWheelDeltaY",[0]);h(this,"_pointerEvent",[]);h(this,"_pointerUsed",[]);h(this,"onLostFocus",()=>{for(const t in this.keysPressed)this.keysPressed[t].pressed=!1});h(this,"onEndOfFrame",()=>{for(let t=0;t<this._pointerUp.length;t++)this._pointerUp[t]=!1;for(let t=0;t<this._pointerDown.length;t++)this._pointerDown[t]=!1;for(let t=0;t<this._pointerClick.length;t++)this._pointerClick[t]=!1;for(let t=0;t<this._pointerDoubleClick.length;t++)this._pointerDoubleClick[t]=!1;for(const t of this._pointerPositionsDelta)t.set(0,0);for(let t=0;t<this._mouseWheelChanged.length;t++)this._mouseWheelChanged[t]=!1;for(let t=0;t<this._mouseWheelDeltaY.length;t++)this._mouseWheelDeltaY[t]=0});h(this,"keysPressed",{});h(this,"onKeyDown",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(i&&i.pressed)return;this.keysPressed[t.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:t.key,code:t.code};const s=new h0("keydown",t,t);this.onDispatchEvent(s)});h(this,"onKeyPressed",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(!i)return;i.pressed=!0,i.frame=this.context.time.frameCount+1;const s=new h0("keypress",t,t);this.onDispatchEvent(s)});h(this,"onKeyUp",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(!i)return;i.pressed=!1,i.frame=this.context.time.frameCount+1;const s=new h0("keyup",t,t);this.onDispatchEvent(s)});h(this,"onMouseWheel",t=>{if(this.canReceiveInput(t)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const i=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=i+t.deltaY});h(this,"onTouchStart",t=>{if(!(t.changedTouches.length<=0)&&this.canReceiveInput(t)!==!1)for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier);uo&&pn(`touch start #${r}, identifier:${s.identifier}`);const o=new wc("pointerdown",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onDown(o)}});h(this,"onTouchMove",t=>{if(!(t.changedTouches.length<=0))for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier),o=new wc("pointermove",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onMove(o)}});h(this,"onTouchUp",t=>{if(!(t.changedTouches.length<=0))for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier);if(!this.isNewEvent(t.timeStamp,r,this._pointerUpTimestamp))continue;uo&&pn(`touch up #${r}, identifier:${s.identifier}`);const o=new wc("pointerup",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onUp(o)}});h(this,"onMouseDown",t=>{if(t.defaultPrevented||this.canReceiveInput(t)===!1)return;const i=t.button,s=new wc("pointerdown",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onDown(s)});h(this,"onMouseMove",t=>{if(t.defaultPrevented)return;const i=t.button,s=new wc("pointermove",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onMove(s)});h(this,"onMouseUp",t=>{if(t.defaultPrevented)return;const i=t.button;if(!this.isNewEvent(t.timeStamp,i,this._pointerUpTimestamp))return;const s=new wc("pointerup",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onUp(s)});this.context=t,this.context.post_render_callbacks.push(this.onEndOfFrame),window.addEventListener("touchstart",this.onTouchStart,!1),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchUp,!1),window.addEventListener("mousedown",this.onMouseDown,!1),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),window.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(t,i=!0){if(t>=this._pointerUsed.length){if(t>=this._pointerIds.length)return;for(;this._pointerUsed.length<=t;)this._pointerUsed.push(!1)}this._pointerUsed[t]=i}getPointerUsed(t){return t>=this._pointerUsed.length?!1:this._pointerUsed[t]}getPointerPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&t++;return t}getPointerPosition(t){return t>=this._pointerPositions.length?null:this._pointerPositions[t]}getPointerPositionLastFrame(t){return t>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[t]}getPointerPositionDelta(t){return t>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[t]}getPointerPositionRC(t){return t>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[t]}getPointerDown(t){return t>=this._pointerDown.length?!1:this._pointerDown[t]}getPointerUp(t){return t>=this._pointerUp.length?!1:this._pointerUp[t]}getPointerPressed(t){return t>=this._pointerPressed.length?!1:this._pointerPressed[t]}getPointerClicked(t){return t>=this._pointerClick.length?!1:this._pointerClick[t]}getPointerDoubleClicked(t){return t>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[t]}getPointerDownTime(t){return t>=this._pointerDownTime.length?-1:this._pointerDownTime[t]}getPointerUpTime(t){return t>=this._pointerUpTime.length?-1:this._pointerUpTime[t]}getPointerLongPress(t){return t>=this._pointerDownTime.length?!1:this.getPointerPressed(t)&&this.context.time.time-this._pointerDownTime[t]>this._longPressTimeThreshold}getIsMouse(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="mouse"}getIsTouch(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="touch"}getTouchesPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&this.getIsTouch(i)&&t++;return t}getMouseWheelChanged(t=0){return t>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[t]}getMouseWheelDeltaY(t=0){return t>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[t]}getPointerEvent(t){if(!(t>=this._pointerEvent.length))return this._pointerEvent[t]??void 0}*foreachPointerId(t){for(let i=0;i<this._pointerTypes.length;i++)if(this._pointerIsActive(i)){if(t!==void 0){const s=this._pointerTypes[i];if(Array.isArray(t)){let r=!1;for(const o of t)if(s===o){r=!0;break}if(!r)continue}else if(t!==s)continue}yield i}}*foreachTouchId(){for(let t=0;t<this._pointerTypes.length;t++)this._pointerTypes[t]==="touch"&&this._pointerIsActive[t]&&(yield t)}_pointerIsActive(t){return t<0?!1:this._pointerPressed[t]||this._pointerDown[t]||this._pointerUp[t]}getKeyDown(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}isKeyDown(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyDown(r))return!0;return!1}return((s=this.keysPressed[t])==null?void 0:s.startFrame)===this.context.time.frameCount&&this.keysPressed[t].pressed}isKeyUp(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyUp(r))return!0;return!1}return((s=this.keysPressed[t])==null?void 0:s.frame)===this.context.time.frameCount&&!this.keysPressed[t].pressed}isKeyPressed(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyPressed(r))return!0;return!1}return(s=this.keysPressed[t])==null?void 0:s.pressed}getCodeForCommonKeyName(t){if(t.length===1){if(t>="0"&&t<="9")return["Digit"+t];if(t>="a"&&t<="z")return["Key"+t.toUpperCase()];if(t==" ")return["Space"]}switch(t){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createPointerDown(t){uo&&pn("Create Pointer down"),this.onDown(t)}createPointerMove(t){uo&&pn("Create Pointer move"),this.onMove(t)}createPointerUp(t){uo&&pn("Create Pointer up"),this.onUp(t)}convertScreenspaceToRaycastSpace(t){t.x=(t.x-this.context.domX)/this.context.domWidth*2-1,t.y=-((t.y-this.context.domY)/this.context.domHeight)*2+1}dispose(){const t=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);t>=0&&this.context.post_render_callbacks.splice(t,1),window.removeEventListener("touchstart",this.onTouchStart,!1),window.removeEventListener("touchmove",this.onTouchMove,!1),window.removeEventListener("touchend",this.onTouchUp,!1),window.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),window.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}canReceiveInput(t){var i;return t.target===((i=this.context.renderer)==null?void 0:i.domElement)||t.target===this.context.domElement}isNewEvent(t,i,s){for(;s.length<=i;)s.push(-1);return t===s[i]?!1:(s[i]=t,!0)}isInRect(t){if(this.context.isInXR)return!0;const i=this.context.domElement.getBoundingClientRect(),s=t.clientX,r=t.clientY,o=s>=i.x&&s<=i.right&&r>=i.y&&r<=i.bottom;return uo&&!o&&console.log("Not in rect",i,s,r),o}onDown(t){var i;if(uo&&console.log(t.pointerType,"DOWN",t.button),!!this.isInRect(t)){if(t.pointerType==="mouse"){const s=this._pointerUpTimestamp[t.button];if(s>0&&((i=t.source)==null?void 0:i.timeStamp)!==void 0){const r=t.source.timeStamp-s;if(r<60&&r>=0){uo&&console.log("Ignoring mouse.down for touch.up");return}}}for(this.setPointerState(t.button,this._pointerPressed,!0),this.setPointerState(t.button,this._pointerDown,!0),this.setPointerStateT(t.button,this._pointerEvent,t.source);t.button>=this._pointerTypes.length;)this._pointerTypes.push(t.pointerType);for(this._pointerTypes[t.button]=t.pointerType;t.button>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new te);for(this._pointerPositionDown[t.button].set(t.clientX,t.clientY);t.button>=this._pointerPositions.length;)this._pointerPositions.push(new te);this._pointerPositions[t.button].set(t.clientX,t.clientY),t.button>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t.button]=this.context.time.time,this.updatePointerPosition(t),this.onDispatchEvent(t)}}onMove(t){const i=this.getPointerPressed(t.button);i===!1&&!this.isInRect(t)||t.pointerType==="touch"&&!i||(uo&&console.log(t.pointerType,"MOVE",t.button),this.updatePointerPosition(t),this.setPointerStateT(t.button,this._pointerEvent,t.source),this.onDispatchEvent(t))}onUp(t){var o;if(((o=this._pointerIds)==null?void 0:o.length)>=t.button&&(this._pointerIds[t.button]=-1),!this._pointerPressed[t.button]){uo&&console.log(t.pointerType,"UP",t.button,"was not down");return}for(uo&&console.log(t.pointerType,"UP",t.button),this.setPointerState(t.button,this._pointerPressed,!1),this.setPointerStateT(t.button,this._pointerEvent,t.source),this.setPointerState(t.button,this._pointerUp,!0);t.button>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t.button,this._pointerUsed,!1),this.updatePointerPosition(t),!this._pointerPositionDown[t.button]){uo&&Ls("Received pointer up event without matching down event for button: "+t.button),console.warn("Received pointer up event without matching down event for button: "+t.button);return}const s=t.clientX-this._pointerPositionDown[t.button].x,r=t.clientY-this._pointerPositionDown[t.button].y;if(t.button>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(s)<5&&Math.abs(r)<5){this.setPointerState(t.button,this._pointerClick,!0);const a=this._pointerUpTime[t.button],c=this.context.time.time-a;c<this._doubleClickTimeThreshold&&c>0&&this.setPointerState(t.button,this._pointerDoubleClick,!0)}this._pointerUpTime[t.button]=this.context.time.time,this.onDispatchEvent(t)}updatePointerPosition(t){for(;t.button>=this._pointerPositions.length;)this._pointerPositions.push(new te);for(;t.button>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new te);for(;t.button>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new te);const i=this._pointerPositionsLastFrame[t.button];i.copy(this._pointerPositions[t.button]);const s=this._pointerPositionsDelta[t.button];let r=t.clientX-i.x,o=t.clientY-i.y;r===0&&t.movementX!==0&&(r=t.movementX||0),o===0&&t.movementY!==0&&(o=t.movementY||0),s.x+=r,s.y+=o,this._pointerPositions[t.button].x=t.clientX,this._pointerPositions[t.button].y=t.clientY;const a=t.clientX,c=t.clientY;for(;t.button>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new te);const l=this._pointerPositionsRC[t.button];l.set(a,c),this.convertScreenspaceToRaycastSpace(l)}getPointerIndex(t){const i=this._pointerIds;let s=-1;for(let r=0;r<i.length;r++){if(i[r]===t)return r;s===-1&&i[r]===-1&&(s=r)}return s!==-1?(i[s]=t,s):(i.push(t),i.length-1)}setPointerState(t,i,s){for(;i.length<=t;)i.push(!1);i[t]=s}setPointerStateT(t,i,s){for(;i.length<=t;)i.push(null);i[t]=s}onDispatchEvent(t){const i=Ft.Current;try{Ft.Current=this.context,this.dispatchEvent(t)}finally{Ft.Current=i}}}class Uj{constructor(){h(this,"Rad2Deg",180/Math.PI);h(this,"Deg2Rad",Math.PI/180);h(this,"Epsilon",1e-5)}random(){return Math.random()}clamp(e,t,i){return e<t?t:e>i?i:e}clamp01(e){return this.clamp(e,0,1)}lerp(e,t,i){return i=i<0?0:i,i=i>1?1:i,e+(t-e)*i}inverseLerp(e,t,i){return(i-e)/(t-e)}remap(e,t,i,s,r){return s+(r-s)*(e-t)/(i-t)}moveTowards(e,t,i){return e+=i,(i<0&&e<t||i>0&&e>t)&&(e=t),e}toDegrees(e){return e*180/Math.PI}toRadians(e){return e*Math.PI/180}tan(e){return Math.tan(e)}gammaToLinear(e){return Math.pow(e,2.2)}linearToGamma(e){return Math.pow(e,1/2.2)}approximately(e,t,i=Number.EPSILON){for(const s of Nj){const r=e[s],o=t[s];if(r===void 0||o===void 0)break;if(Math.abs(r-o)>i)return!1}return!0}}const Nj=["x","y","z","w"],tt=new Uj;function $2(n,e,t){const i=n.length(),s=e.length(),r=tt.lerp(i,s,t);return n.lerp(e,t).normalize().multiplyScalar(r)}const zj=new we().setFromAxisAngle(new w(0,1,0),Math.PI);function Gj(n,e){n.lookAt(e),n.quaternion.multiply(zj)}const H1=new Xa(()=>new w,100);function Ct(n,e=null,t=!0){const i=e??H1.get();return n?n.parent?(t&&n.updateWorldMatrix(!0,!1),n.matrixWorldNeedsUpdate&&n.updateMatrixWorld(),i.setFromMatrixPosition(n.matrixWorld),i):i.copy(n.position):i.set(0,0,0)}function Mn(n,e){if(!n)return;const t=H1.get();e!==t&&t.copy(e),((n==null?void 0:n.parent)??n).worldToLocal(t),n.position.set(t.x,t.y,t.z)}function Gf(n,e,t,i){const s=H1.get();s.set(e,t,i),Mn(n,s)}const nb=new Xa(()=>new we,100),yu=new we,Zw=new we;function zn(n,e=null){if(!n)return nb.get().identity();const t=e??nb.get();return n.parent?(n.getWorldQuaternion(t),t):t.copy(n.quaternion)}function Mr(n,e){if(!n)return;e!==yu&&yu.copy(e);const t=yu,i=n==null?void 0:n.parent;i==null||i.getWorldQuaternion(Zw),Zw.invert();const s=Zw.multiply(t);n.quaternion.set(s.x,s.y,s.z,s.w)}function eF(n,e,t,i,s){yu.set(e,t,i,s),Mr(n,yu)}const Hj=new Xa(()=>new w,100),Vj=new w;function ls(n,e=null){return e||(e=Hj.get()),n?n.parent?(n.getWorldScale(e),e):e.copy(n.scale):e.set(0,0,0)}function AE(n,e){if(!n)return;if(!n.parent){n.scale.copy(e);return}const t=Vj;n.parent.getWorldScale(t),n.scale.copy(e),n.scale.divide(t)}const Qj=new w,rB=new we;function Wj(n){return zn(n,rB),Qj.set(0,0,1).applyQuaternion(rB)}const jj=new Xa(()=>new w,100),oB=new we;function Xj(n,e){return e||(e=jj.get().set(0,0,1)),zn(n,oB),e.applyQuaternion(oB)}const aB=new mn,cB=new mn,qj=new w;function tF(n){const e=nb.get();return n.getWorldQuaternion(e),cB.setFromQuaternion(e),cB}function iF(n,e){const t=nb.get();Mr(n,t.setFromEuler(e))}function O_(n){const e=tF(n),t=qj;return t.set(e.x,e.y,e.z),t.x=tt.toDegrees(t.x),t.y=tt.toDegrees(t.y),t.z=tt.toDegrees(t.z),t}function nF(n,e){k_(n,e.x,e.y,e.z,!0)}function k_(n,e,t,i,s=!0){s&&(e=tt.toRadians(e),t=tt.toRadians(t),i=tt.toRadians(i)),aB.set(e,t,i),yu.setFromEuler(aB),Mr(n,yu)}function sb(n,e=!0){n&&(e?function t(i){console.groupCollapsed((i.name?i.name:"(no name : "+i.type+")")+" %o",i),i.children.forEach(t),console.groupEnd()}(n):n.traverse(function(t){for(var i="|___",s=t;s.parent!==null;)i=" "+i,s=s.parent;console.log(i+t.name+" <"+t.type+">")}))}function sF(n){if(n){const e=n;return e.blendMode!==void 0&&e.clampWhenFinished!==void 0&&e.enabled!==void 0&&e.fadeIn!==void 0&&e.getClip!==void 0}return!1}class Zo{static createBlitMaterial(e){return new Lt({uniforms:{map:new xe(null)},vertexShader:this.vertex,fragmentShader:e})}static copyTexture(e,t){const i=t??this.blipMaterial;i.uniforms.map.value=e,i.needsUpdate=!0,i.uniformsNeedUpdate=!0,this.blipMaterial||(this.blipMaterial=new Lt({uniforms:{map:new xe(null)},vertexShader:this.vertex,fragmentShader:this.fragment})),this.mesh||(this.mesh=new ye(this.planeGeometry,this.blipMaterial));const s=this.mesh;s.material=i,s.frustumCulled=!1,this.scene.children.length=0,this.scene.add(s),this.renderer||(this.renderer=new Ou({antialias:!1})),this.renderer.setSize(e.image.width,e.image.height),this.renderer.clear(),this.renderer.render(this.scene,this.perspectiveCam);const r=new Ot(this.renderer.domElement);return r.name="Copy",r.needsUpdate=!0,r}static textureToCanvas(e,t){if(!e)return null;(t===!0||e.isCompressedTexture===!0)&&(e=rF(e));const i=e.image;if(Kj(i)){const s=document.createElement("canvas");s.width=i.width,s.height=i.height;const r=s.getContext("2d");return r?(r.drawImage(i,0,0,i.width,i.height,0,0,s.width,s.height),s):(console.error("Failed getting canvas 2d context"),null)}return null}}h(Zo,"planeGeometry",new gs(2,2,1,1)),h(Zo,"renderer"),h(Zo,"perspectiveCam",new qt),h(Zo,"scene",new Er),h(Zo,"vertex",`
|
|
3656
|
+
`,Nr==null||Nr.prepend(t),n===!0&&Tj(),console.log("🌵 Debug console has loaded")}},e.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(e)}function Dj(){const n=document.querySelector("#__vconsole .vc-switch");return n||null}function Oj(){const n=document.querySelector("#__vconsole");return n||null}function pn(n,e=Bo.Log){Xc(e,n)}function Ls(n){pn(n,Bo.Warn)}function kj(n){pn(n,Bo.Error)}let mE;function ci(){return mE!==void 0?mE:nr()}function Lj(n){mE=n}const uo=re("debuginput");class wc extends PointerEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class h0 extends KeyboardEvent{constructor(t,i,s){super(t,s);h(this,"source");this.source=i}stopImmediatePropagation(){var t;super.stopImmediatePropagation(),(t=this.source)==null||t.stopImmediatePropagation()}}class Fj{constructor(e){h(this,"key");h(this,"keyType");h(this,"source");this.key=e.key,this.keyType=e.type,this.source=e}}var Sn=(n=>(n.PointerDown="pointerdown",n.PointerUp="pointerup",n.PointerMove="pointermove",n.KeyDown="keydown",n.KeyUp="keyup",n.KeyPressed="keypress",n))(Sn||{}),zf=(n=>(n.Mouse="mouse",n.Touch="touch",n))(zf||{});class Z2 extends EventTarget{constructor(t){super();h(this,"_doubleClickTimeThreshold",.2);h(this,"_longPressTimeThreshold",1);h(this,"_specialCursorTrigger",0);h(this,"context");h(this,"_pointerDown",[!1]);h(this,"_pointerUp",[!1]);h(this,"_pointerClick",[!1]);h(this,"_pointerDoubleClick",[!1]);h(this,"_pointerPressed",[!1]);h(this,"_pointerPositions",[new te]);h(this,"_pointerPositionsLastFrame",[new te]);h(this,"_pointerPositionsDelta",[new te]);h(this,"_pointerPositionsRC",[new te]);h(this,"_pointerPositionDown",[new te]);h(this,"_pointerDownTime",[]);h(this,"_pointerUpTime",[]);h(this,"_pointerUpTimestamp",[]);h(this,"_pointerIds",[]);h(this,"_pointerTypes",[""]);h(this,"_mouseWheelChanged",[!1]);h(this,"_mouseWheelDeltaY",[0]);h(this,"_pointerEvent",[]);h(this,"_pointerUsed",[]);h(this,"onLostFocus",()=>{for(const t in this.keysPressed)this.keysPressed[t].pressed=!1});h(this,"onEndOfFrame",()=>{for(let t=0;t<this._pointerUp.length;t++)this._pointerUp[t]=!1;for(let t=0;t<this._pointerDown.length;t++)this._pointerDown[t]=!1;for(let t=0;t<this._pointerClick.length;t++)this._pointerClick[t]=!1;for(let t=0;t<this._pointerDoubleClick.length;t++)this._pointerDoubleClick[t]=!1;for(const t of this._pointerPositionsDelta)t.set(0,0);for(let t=0;t<this._mouseWheelChanged.length;t++)this._mouseWheelChanged[t]=!1;for(let t=0;t<this._mouseWheelDeltaY.length;t++)this._mouseWheelDeltaY[t]=0});h(this,"keysPressed",{});h(this,"onKeyDown",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(i&&i.pressed)return;this.keysPressed[t.code]={pressed:!0,frame:this.context.time.frameCount+1,startFrame:this.context.time.frameCount+1,key:t.key,code:t.code};const s=new h0("keydown",t,t);this.onDispatchEvent(s)});h(this,"onKeyPressed",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(!i)return;i.pressed=!0,i.frame=this.context.time.frameCount+1;const s=new h0("keypress",t,t);this.onDispatchEvent(s)});h(this,"onKeyUp",t=>{if(!this.context.application.hasFocus)return;const i=this.keysPressed[t.code];if(!i)return;i.pressed=!1,i.frame=this.context.time.frameCount+1;const s=new h0("keyup",t,t);this.onDispatchEvent(s)});h(this,"onMouseWheel",t=>{if(this.canReceiveInput(t)===!1)return;this._mouseWheelDeltaY.length<=0&&this._mouseWheelDeltaY.push(0),this._mouseWheelChanged.length<=0&&this._mouseWheelChanged.push(!1),this._mouseWheelChanged[0]=!0;const i=this._mouseWheelDeltaY[0];this._mouseWheelDeltaY[0]=i+t.deltaY});h(this,"onTouchStart",t=>{if(!(t.changedTouches.length<=0)&&this.canReceiveInput(t)!==!1)for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier);uo&&pn(`touch start #${r}, identifier:${s.identifier}`);const o=new wc("pointerdown",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onDown(o)}});h(this,"onTouchMove",t=>{if(!(t.changedTouches.length<=0))for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier),o=new wc("pointermove",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onMove(o)}});h(this,"onTouchUp",t=>{if(!(t.changedTouches.length<=0))for(let i=0;i<t.changedTouches.length;i++){const s=t.changedTouches[i],r=this.getPointerIndex(s.identifier);if(!this.isNewEvent(t.timeStamp,r,this._pointerUpTimestamp))continue;uo&&pn(`touch up #${r}, identifier:${s.identifier}`);const o=new wc("pointerup",t,{button:r,clientX:s.clientX,clientY:s.clientY,pointerType:"touch"});this.onUp(o)}});h(this,"onMouseDown",t=>{if(t.defaultPrevented||this.canReceiveInput(t)===!1)return;const i=t.button,s=new wc("pointerdown",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onDown(s)});h(this,"onMouseMove",t=>{if(t.defaultPrevented)return;const i=t.button,s=new wc("pointermove",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onMove(s)});h(this,"onMouseUp",t=>{if(t.defaultPrevented)return;const i=t.button;if(!this.isNewEvent(t.timeStamp,i,this._pointerUpTimestamp))return;const s=new wc("pointerup",t,{button:i,clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"});this.onUp(s)});this.context=t,this.context.post_render_callbacks.push(this.onEndOfFrame),window.addEventListener("touchstart",this.onTouchStart,!1),window.addEventListener("touchmove",this.onTouchMove,{passive:!0}),window.addEventListener("touchend",this.onTouchUp,!1),window.addEventListener("mousedown",this.onMouseDown,!1),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),window.addEventListener("wheel",this.onMouseWheel,{passive:!0}),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keypress",this.onKeyPressed,!1),window.addEventListener("keyup",this.onKeyUp,!1),window.addEventListener("blur",this.onLostFocus)}get mousePosition(){return this._pointerPositions[0]}get mousePositionRC(){return this._pointerPositionsRC[0]}get mouseDown(){return this._pointerDown[0]}get mouseUp(){return this._pointerUp[0]}get mouseClick(){return this._pointerClick[0]}get mouseDoubleClick(){return this._pointerDoubleClick[0]}get mousePressed(){return this._pointerPressed[0]}get mouseWheelChanged(){return this.getMouseWheelChanged(0)}setCursorPointer(){this._specialCursorTrigger+=1,this.context.domElement.style.cursor="pointer"}setCursorNormal(){this._specialCursorTrigger-=1,this._specialCursorTrigger=Math.max(0,this._specialCursorTrigger),this._specialCursorTrigger===0&&(this.context.domElement.style.cursor="default")}setPointerUsed(t,i=!0){if(t>=this._pointerUsed.length){if(t>=this._pointerIds.length)return;for(;this._pointerUsed.length<=t;)this._pointerUsed.push(!1)}this._pointerUsed[t]=i}getPointerUsed(t){return t>=this._pointerUsed.length?!1:this._pointerUsed[t]}getPointerPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&t++;return t}getPointerPosition(t){return t>=this._pointerPositions.length?null:this._pointerPositions[t]}getPointerPositionLastFrame(t){return t>=this._pointerPositionsLastFrame.length?null:this._pointerPositionsLastFrame[t]}getPointerPositionDelta(t){return t>=this._pointerPositionsDelta.length?null:this._pointerPositionsDelta[t]}getPointerPositionRC(t){return t>=this._pointerPositionsRC.length?null:this._pointerPositionsRC[t]}getPointerDown(t){return t>=this._pointerDown.length?!1:this._pointerDown[t]}getPointerUp(t){return t>=this._pointerUp.length?!1:this._pointerUp[t]}getPointerPressed(t){return t>=this._pointerPressed.length?!1:this._pointerPressed[t]}getPointerClicked(t){return t>=this._pointerClick.length?!1:this._pointerClick[t]}getPointerDoubleClicked(t){return t>=this._pointerDoubleClick.length?!1:this._pointerDoubleClick[t]}getPointerDownTime(t){return t>=this._pointerDownTime.length?-1:this._pointerDownTime[t]}getPointerUpTime(t){return t>=this._pointerUpTime.length?-1:this._pointerUpTime[t]}getPointerLongPress(t){return t>=this._pointerDownTime.length?!1:this.getPointerPressed(t)&&this.context.time.time-this._pointerDownTime[t]>this._longPressTimeThreshold}getIsMouse(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="mouse"}getIsTouch(t){return t<0||t>=this._pointerTypes.length?!1:this._pointerTypes[t]==="touch"}getTouchesPressedCount(){let t=0;for(let i=0;i<this._pointerPressed.length;i++)this._pointerPressed[i]&&this.getIsTouch(i)&&t++;return t}getMouseWheelChanged(t=0){return t>=this._mouseWheelChanged.length?!1:this._mouseWheelChanged[t]}getMouseWheelDeltaY(t=0){return t>=this._mouseWheelDeltaY.length?0:this._mouseWheelDeltaY[t]}getPointerEvent(t){if(!(t>=this._pointerEvent.length))return this._pointerEvent[t]??void 0}*foreachPointerId(t){for(let i=0;i<this._pointerTypes.length;i++)if(this._pointerIsActive(i)){if(t!==void 0){const s=this._pointerTypes[i];if(Array.isArray(t)){let r=!1;for(const o of t)if(s===o){r=!0;break}if(!r)continue}else if(t!==s)continue}yield i}}*foreachTouchId(){for(let t=0;t<this._pointerTypes.length;t++)this._pointerTypes[t]==="touch"&&this._pointerIsActive[t]&&(yield t)}_pointerIsActive(t){return t<0?!1:this._pointerPressed[t]||this._pointerDown[t]||this._pointerUp[t]}getKeyDown(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.startFrame===this.context.time.frameCount)return i.key}return null}getKeyPressed(){for(const t in this.keysPressed){const i=this.keysPressed[t];if(i.pressed)return i.key}return null}isKeyDown(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyDown(r))return!0;return!1}return((s=this.keysPressed[t])==null?void 0:s.startFrame)===this.context.time.frameCount&&this.keysPressed[t].pressed}isKeyUp(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyUp(r))return!0;return!1}return((s=this.keysPressed[t])==null?void 0:s.frame)===this.context.time.frameCount&&!this.keysPressed[t].pressed}isKeyPressed(t){var s;if(!this.context.application.isVisible||!this.context.application.hasFocus)return!1;const i=this.getCodeForCommonKeyName(t);if(i!==null){for(const r of i)if(this.isKeyPressed(r))return!0;return!1}return(s=this.keysPressed[t])==null?void 0:s.pressed}getCodeForCommonKeyName(t){if(t.length===1){if(t>="0"&&t<="9")return["Digit"+t];if(t>="a"&&t<="z")return["Key"+t.toUpperCase()];if(t==" ")return["Space"]}switch(t){case"shift":case"Shift":return["ShiftLeft","ShiftRight"];case"control":case"Control":return["ControlLeft","ControlRight"];case"alt":case"Alt":return["AltLeft","AltRight"]}return null}createPointerDown(t){uo&&pn("Create Pointer down"),this.onDown(t)}createPointerMove(t){uo&&pn("Create Pointer move"),this.onMove(t)}createPointerUp(t){uo&&pn("Create Pointer up"),this.onUp(t)}convertScreenspaceToRaycastSpace(t){t.x=(t.x-this.context.domX)/this.context.domWidth*2-1,t.y=-((t.y-this.context.domY)/this.context.domHeight)*2+1}dispose(){const t=this.context.post_render_callbacks.indexOf(this.onEndOfFrame);t>=0&&this.context.post_render_callbacks.splice(t,1),window.removeEventListener("touchstart",this.onTouchStart,!1),window.removeEventListener("touchmove",this.onTouchMove,!1),window.removeEventListener("touchend",this.onTouchUp,!1),window.removeEventListener("mousedown",this.onMouseDown,!1),window.removeEventListener("mousemove",this.onMouseMove,!1),window.removeEventListener("mouseup",this.onMouseUp,!1),window.removeEventListener("wheel",this.onMouseWheel,!1),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keypress",this.onKeyPressed,!1),window.removeEventListener("keyup",this.onKeyUp,!1),window.removeEventListener("blur",this.onLostFocus)}canReceiveInput(t){var i;return t.target===((i=this.context.renderer)==null?void 0:i.domElement)||t.target===this.context.domElement}isNewEvent(t,i,s){for(;s.length<=i;)s.push(-1);return t===s[i]?!1:(s[i]=t,!0)}isInRect(t){if(this.context.isInXR)return!0;const i=this.context.domElement.getBoundingClientRect(),s=t.clientX,r=t.clientY,o=s>=i.x&&s<=i.right&&r>=i.y&&r<=i.bottom;return uo&&!o&&console.log("Not in rect",i,s,r),o}onDown(t){var i;if(uo&&console.log(t.pointerType,"DOWN",t.button),!!this.isInRect(t)){if(t.pointerType==="mouse"){const s=this._pointerUpTimestamp[t.button];if(s>0&&((i=t.source)==null?void 0:i.timeStamp)!==void 0){const r=t.source.timeStamp-s;if(r<60&&r>=0){uo&&console.log("Ignoring mouse.down for touch.up");return}}}for(this.setPointerState(t.button,this._pointerPressed,!0),this.setPointerState(t.button,this._pointerDown,!0),this.setPointerStateT(t.button,this._pointerEvent,t.source);t.button>=this._pointerTypes.length;)this._pointerTypes.push(t.pointerType);for(this._pointerTypes[t.button]=t.pointerType;t.button>=this._pointerPositionDown.length;)this._pointerPositionDown.push(new te);for(this._pointerPositionDown[t.button].set(t.clientX,t.clientY);t.button>=this._pointerPositions.length;)this._pointerPositions.push(new te);this._pointerPositions[t.button].set(t.clientX,t.clientY),t.button>=this._pointerDownTime.length&&this._pointerDownTime.push(0),this._pointerDownTime[t.button]=this.context.time.time,this.updatePointerPosition(t),this.onDispatchEvent(t)}}onMove(t){const i=t.button;this._pointerClick[i]=!1,this._pointerDoubleClick[i]=!1;const s=this.getPointerPressed(i);s===!1&&!this.isInRect(t)||t.pointerType==="touch"&&!s||(uo&&console.log(t.pointerType,"MOVE",i),this.updatePointerPosition(t),this.setPointerStateT(i,this._pointerEvent,t.source),this.onDispatchEvent(t))}onUp(t){var o;if(((o=this._pointerIds)==null?void 0:o.length)>=t.button&&(this._pointerIds[t.button]=-1),!this._pointerPressed[t.button]){uo&&console.log(t.pointerType,"UP",t.button,"was not down");return}for(uo&&console.log(t.pointerType,"UP",t.button),this.setPointerState(t.button,this._pointerPressed,!1),this.setPointerStateT(t.button,this._pointerEvent,t.source),this.setPointerState(t.button,this._pointerUp,!0);t.button>=this._pointerUsed.length;)this._pointerUsed.push(!1);if(this.setPointerState(t.button,this._pointerUsed,!1),this.updatePointerPosition(t),!this._pointerPositionDown[t.button]){uo&&Ls("Received pointer up event without matching down event for button: "+t.button),console.warn("Received pointer up event without matching down event for button: "+t.button);return}const s=t.clientX-this._pointerPositionDown[t.button].x,r=t.clientY-this._pointerPositionDown[t.button].y;if(t.button>=this._pointerUpTime.length&&this._pointerUpTime.push(-99),Math.abs(s)<5&&Math.abs(r)<5){this.setPointerState(t.button,this._pointerClick,!0);const a=this._pointerUpTime[t.button],c=this.context.time.time-a;c<this._doubleClickTimeThreshold&&c>0&&this.setPointerState(t.button,this._pointerDoubleClick,!0)}this._pointerUpTime[t.button]=this.context.time.time,this.onDispatchEvent(t)}updatePointerPosition(t){for(;t.button>=this._pointerPositions.length;)this._pointerPositions.push(new te);for(;t.button>=this._pointerPositionsLastFrame.length;)this._pointerPositionsLastFrame.push(new te);for(;t.button>=this._pointerPositionsDelta.length;)this._pointerPositionsDelta.push(new te);const i=this._pointerPositionsLastFrame[t.button];i.copy(this._pointerPositions[t.button]);const s=this._pointerPositionsDelta[t.button];let r=t.clientX-i.x,o=t.clientY-i.y;r===0&&t.movementX!==0&&(r=t.movementX||0),o===0&&t.movementY!==0&&(o=t.movementY||0),s.x+=r,s.y+=o,this._pointerPositions[t.button].x=t.clientX,this._pointerPositions[t.button].y=t.clientY;const a=t.clientX,c=t.clientY;for(;t.button>=this._pointerPositionsRC.length;)this._pointerPositionsRC.push(new te);const l=this._pointerPositionsRC[t.button];l.set(a,c),this.convertScreenspaceToRaycastSpace(l)}getPointerIndex(t){const i=this._pointerIds;let s=-1;for(let r=0;r<i.length;r++){if(i[r]===t)return r;s===-1&&i[r]===-1&&(s=r)}return s!==-1?(i[s]=t,s):(i.push(t),i.length-1)}setPointerState(t,i,s){for(;i.length<=t;)i.push(!1);i[t]=s}setPointerStateT(t,i,s){for(;i.length<=t;)i.push(null);i[t]=s}onDispatchEvent(t){const i=Ft.Current;try{Ft.Current=this.context,this.dispatchEvent(t)}finally{Ft.Current=i}}}class Uj{constructor(){h(this,"Rad2Deg",180/Math.PI);h(this,"Deg2Rad",Math.PI/180);h(this,"Epsilon",1e-5)}random(){return Math.random()}clamp(e,t,i){return e<t?t:e>i?i:e}clamp01(e){return this.clamp(e,0,1)}lerp(e,t,i){return i=i<0?0:i,i=i>1?1:i,e+(t-e)*i}inverseLerp(e,t,i){return(i-e)/(t-e)}remap(e,t,i,s,r){return s+(r-s)*(e-t)/(i-t)}moveTowards(e,t,i){return e+=i,(i<0&&e<t||i>0&&e>t)&&(e=t),e}toDegrees(e){return e*180/Math.PI}toRadians(e){return e*Math.PI/180}tan(e){return Math.tan(e)}gammaToLinear(e){return Math.pow(e,2.2)}linearToGamma(e){return Math.pow(e,1/2.2)}approximately(e,t,i=Number.EPSILON){for(const s of Nj){const r=e[s],o=t[s];if(r===void 0||o===void 0)break;if(Math.abs(r-o)>i)return!1}return!0}}const Nj=["x","y","z","w"],tt=new Uj;function $2(n,e,t){const i=n.length(),s=e.length(),r=tt.lerp(i,s,t);return n.lerp(e,t).normalize().multiplyScalar(r)}const zj=new we().setFromAxisAngle(new w(0,1,0),Math.PI);function Gj(n,e){n.lookAt(e),n.quaternion.multiply(zj)}const H1=new Xa(()=>new w,100);function Ct(n,e=null,t=!0){const i=e??H1.get();return n?n.parent?(t&&n.updateWorldMatrix(!0,!1),n.matrixWorldNeedsUpdate&&n.updateMatrixWorld(),i.setFromMatrixPosition(n.matrixWorld),i):i.copy(n.position):i.set(0,0,0)}function Mn(n,e){if(!n)return;const t=H1.get();e!==t&&t.copy(e),((n==null?void 0:n.parent)??n).worldToLocal(t),n.position.set(t.x,t.y,t.z)}function Gf(n,e,t,i){const s=H1.get();s.set(e,t,i),Mn(n,s)}const nb=new Xa(()=>new we,100),yu=new we,Zw=new we;function zn(n,e=null){if(!n)return nb.get().identity();const t=e??nb.get();return n.parent?(n.getWorldQuaternion(t),t):t.copy(n.quaternion)}function Mr(n,e){if(!n)return;e!==yu&&yu.copy(e);const t=yu,i=n==null?void 0:n.parent;i==null||i.getWorldQuaternion(Zw),Zw.invert();const s=Zw.multiply(t);n.quaternion.set(s.x,s.y,s.z,s.w)}function eF(n,e,t,i,s){yu.set(e,t,i,s),Mr(n,yu)}const Hj=new Xa(()=>new w,100),Vj=new w;function ls(n,e=null){return e||(e=Hj.get()),n?n.parent?(n.getWorldScale(e),e):e.copy(n.scale):e.set(0,0,0)}function AE(n,e){if(!n)return;if(!n.parent){n.scale.copy(e);return}const t=Vj;n.parent.getWorldScale(t),n.scale.copy(e),n.scale.divide(t)}const Qj=new w,rB=new we;function Wj(n){return zn(n,rB),Qj.set(0,0,1).applyQuaternion(rB)}const jj=new Xa(()=>new w,100),oB=new we;function Xj(n,e){return e||(e=jj.get().set(0,0,1)),zn(n,oB),e.applyQuaternion(oB)}const aB=new mn,cB=new mn,qj=new w;function tF(n){const e=nb.get();return n.getWorldQuaternion(e),cB.setFromQuaternion(e),cB}function iF(n,e){const t=nb.get();Mr(n,t.setFromEuler(e))}function O_(n){const e=tF(n),t=qj;return t.set(e.x,e.y,e.z),t.x=tt.toDegrees(t.x),t.y=tt.toDegrees(t.y),t.z=tt.toDegrees(t.z),t}function nF(n,e){k_(n,e.x,e.y,e.z,!0)}function k_(n,e,t,i,s=!0){s&&(e=tt.toRadians(e),t=tt.toRadians(t),i=tt.toRadians(i)),aB.set(e,t,i),yu.setFromEuler(aB),Mr(n,yu)}function sb(n,e=!0){n&&(e?function t(i){console.groupCollapsed((i.name?i.name:"(no name : "+i.type+")")+" %o",i),i.children.forEach(t),console.groupEnd()}(n):n.traverse(function(t){for(var i="|___",s=t;s.parent!==null;)i=" "+i,s=s.parent;console.log(i+t.name+" <"+t.type+">")}))}function sF(n){if(n){const e=n;return e.blendMode!==void 0&&e.clampWhenFinished!==void 0&&e.enabled!==void 0&&e.fadeIn!==void 0&&e.getClip!==void 0}return!1}class Zo{static createBlitMaterial(e){return new Lt({uniforms:{map:new xe(null)},vertexShader:this.vertex,fragmentShader:e})}static copyTexture(e,t){const i=t??this.blipMaterial;i.uniforms.map.value=e,i.needsUpdate=!0,i.uniformsNeedUpdate=!0,this.blipMaterial||(this.blipMaterial=new Lt({uniforms:{map:new xe(null)},vertexShader:this.vertex,fragmentShader:this.fragment})),this.mesh||(this.mesh=new ye(this.planeGeometry,this.blipMaterial));const s=this.mesh;s.material=i,s.frustumCulled=!1,this.scene.children.length=0,this.scene.add(s),this.renderer||(this.renderer=new Ou({antialias:!1})),this.renderer.setSize(e.image.width,e.image.height),this.renderer.clear(),this.renderer.render(this.scene,this.perspectiveCam);const r=new Ot(this.renderer.domElement);return r.name="Copy",r.needsUpdate=!0,r}static textureToCanvas(e,t){if(!e)return null;(t===!0||e.isCompressedTexture===!0)&&(e=rF(e));const i=e.image;if(Kj(i)){const s=document.createElement("canvas");s.width=i.width,s.height=i.height;const r=s.getContext("2d");return r?(r.drawImage(i,0,0,i.width,i.height,0,0,s.width,s.height),s):(console.error("Failed getting canvas 2d context"),null)}return null}}h(Zo,"planeGeometry",new gs(2,2,1,1)),h(Zo,"renderer"),h(Zo,"perspectiveCam",new qt),h(Zo,"scene",new Er),h(Zo,"vertex",`
|
|
3657
3657
|
varying vec2 vUv;
|
|
3658
3658
|
void main(){
|
|
3659
3659
|
vUv = uv;
|
|
@@ -3765,7 +3765,7 @@ ${o}? : AssetReference;
|
|
|
3765
3765
|
|
|
3766
3766
|
in script ${i}.ts
|
|
3767
3767
|
<a href="https://docs.needle.tools/serializable" target="_blank">documentation</a>`),console.warn(i,o,n[o],n);continue}}}}function v6(n,e){for(const t of Object.keys(e)){const i=e[t];if(typeof i=="object"&&i!==null&&i!==void 0){const s=n[t];if(!s){Sc&&console.log(t,"is undefined on",n);continue}for(const r of Object.keys(i))if(s[r]===void 0&&QB(i[r])&&!QB(s)){const a=y6(s,r);if(a&&((a==null?void 0:a.writable)===void 0||(a==null?void 0:a.writable)===!1)&&a.set===void 0){Sc&&console.warn('Property is not writable "'+r+'"',s,a,i[r],s[r]);continue}s[r]=i[r]}}}}function y6(n,e){for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return t;n=Object.getPrototypeOf(n)}}function QB(n){switch(typeof n){case"number":case"string":case"boolean":return!0}return!1}function BE(n,e,t,i,s){let r=typeof e=="function"&&e.prototype===void 0,o=e;if(r)try{if(o=e==null?void 0:e.call(e,s),r=!1,o==null)return}catch(u){console.error("Error in callback",u,n)}if(t.type=o,!r&&s instanceof o)return s;if(s&&typeof s=="object"&&d6(s)){if(s.__concreteInstance)return s.__concreteInstance;const u=s;if(!u.$serializedTypes&&o.prototype.$serializedTypes&&(u.$serializedTypes=o.prototype.$serializedTypes),u.$serializedTypes&&hb(u,n,t),s&&o!==void 0)try{const d=new o;Rs&&console.log("Create concrete instance for persistent asset",s,"instance:",d),Hf(d,s),s.__concreteInstance=d,s=d}catch(d){console.error("Error creating instance or creating values on instance",d,s,o)}return s}if(i||(i={serializer:lb.getSerializerForConstructor(o)}),Array.isArray(n)){const u=[];for(let d=0;d<n.length;d++){const f=n[d],p=BE(f,e,t,i,f);u.push(p)}return u}const a=i.serializer;if(a)return a.onDeserialize(n,t);let c;if(n&&(n.isMaterial||n.isTexture||n.isObject3D))c=n;else{if(n===void 0)return;if(n===null&&(o===kt||o===Ot||o===ye||o===tr))return null;c=new o(...b6(n))}const l=c;return l.$serializedTypes&&hb(l,n,t),c}function b6(n){if(g0.length=0,typeof n=="object"&&n!==null&&n!==void 0)for(const e of Object.keys(n))g0.push(n[e]);return g0}const DE=Symbol("assigned component properties");function Hf(n,e,t){var s;if(e==null||n==null)return;n[DE]=!0;const i=((s=n.constructor)==null?void 0:s.name)??"unknown";t==null||t.registerDefinedKeys(i,n);for(const r of Object.keys(e)){const o=_6(n,r);typeof(o==null?void 0:o.value)!="function"&&(!o||o.writable===!0||(o==null?void 0:o.set)!==void 0)&&(n[r]=e[r])}delete n[DE]}function _6(n,e){let t;do t=Object.getOwnPropertyDescriptor(n,e);while(!t&&(n=Object.getPrototypeOf(n)));return t}const WB=Symbol("gltf-loader-internal-usage-tracker"),x6=re("debugusers"),fm=class{constructor(e){h(this,"parser");h(this,"_getDependency");h(this,"_loadingId");h(this,"_loadedObjects",new Set);this.parser=e,this._getDependency=this.parser.getDependency,this._loadingId=Date.now().toString()}get name(){return"NEEDLE_internal_usage_tracker"}static isLoading(e){return fm._loadingProcesses>0}beforeRoot(){fm._loadingProcesses++;const e=this,t=this._getDependency;return this.parser.getDependency=function(i,s){const r=t.call(this,i,s);return r.then(o=>(o&&(e._loadedObjects.add(o),o[WB]=e._loadingId),o)),r},null}afterRoot(e){fm._loadingProcesses--,this.parser.getDependency=this._getDependency;for(const t of this._loadedObjects)delete t[WB],t instanceof Te&&(t.parent||t instanceof ye&&(x6&&console.warn("> GLTF LOADER: Mesh not used in scene!",t),t.material=null,t.geometry=null));return null}};let Jg=fm;h(Jg,"_loadingProcesses",0);const w6=re("debugpatch");function X_(n,e,t,i){const s=w6===e;if(!t&&!i)return;const r=e+"___needle";C6(n,e,t,i);const o=Object.getOwnPropertyDescriptor(n,e),a=n[e];s&&console.log("Patch",n.constructor.name,e,o,a),o?(s&&console.log("Apply patch with existing descriptor",n.constructor.name,e,o),typeof o.value=="function"&&(n[e]=XB(o.value,n,e))):(s&&console.log("Create patch with new property",n.constructor.name,e,o),Object.defineProperty(n,e,{set:function(c){if(typeof c=="function")this[r]=XB(c,n,e);else{const l=this[r];wU(n,e,this,l,c),this[r]=c,SU(n,e,this,l,c)}},get:function(){const c=this[r];return typeof c=="function"&&c[r]?c[r]:c}}))}function S6(n,e,t){const i=eT(n,e);if(i)for(let s=i.length-1;s>=0;s--){const r=i[s];r.prefix===t&&(r.prefix=null),r.postfix===t&&(r.postfix=null),!r.prefix&&!r.postfix&&i.splice(s,1)}}const jB=Symbol("Needle:Patches:WrappedFunction");function XB(n,e,t){if(n[jB])return n;const i=function(...s){wU(e,t,this,...s);const r=n.apply(this,s);return SU(e,t,this,r,...s),r};return i[jB]=!0,i}const m0="Needle:Patches";function OE(){return globalThis[m0]||(globalThis[m0]=new WeakMap),globalThis[m0]}function eT(n,e){const t=OE().get(n);return t?t.get(e):null}function C6(n,e,t,i){let s=OE().get(n);s||(s=new Map,OE().set(n,s));let r=s.get(e);r||(r=[],s.set(e,r)),r.push({prefix:t,postfix:i})}function wU(n,e,t,...i){var r;if(!t)return;const s=eT(n,e);if(s)for(const o of s)(r=o.prefix)==null||r.call(t,...i)}function SU(n,e,t,i,...s){var o;if(!t)return;const r=eT(n,e);if(r)for(const a of r)(o=a.postfix)==null||o.call(t,i,...s)}class CU{constructor(){window.addEventListener("unhandledrejection",e=>{var i;if(e.defaultPrevented)return;const t=(i=e==null?void 0:e.reason)==null?void 0:i.path;if(t){const s=t[0];s&&s.tagName==="IMG"&&(console.warn(`Could not load image:
|
|
3768
|
-
`+s.src),e.preventDefault())}})}}const q_=re("trackresources");function EU(){return q_==="dispose"}let Nu=!0;q_===0&&(Nu=!1);function E6(n){Nu=n}function MU(){return Nu}const TU=Symbol("disposable");function tT(n,e){n&&(n[TU]=e,bu&&console.warn("Set disposable",e,n))}const IU=Symbol("disposed");function M6(n){return n[IU]===!0}function Si(n){var e;if(n){if(n[TU]===!1){bu&&console.warn("Object is marked as not disposable",n);return}if(n[IU]=!0,n instanceof Er)Si(n.environment),Si(n.background),Si(n.customDepthMaterial),Si(n.customDistanceMaterial);else if(n instanceof ku)Si(n.geometry),Si(n.material),Si(n.skeleton),Si(n.bindMatrix),Si(n.bindMatrixInverse),Si(n.customDepthMaterial),Si(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof ye)Si(n.geometry),Si(n.material),Si(n.customDepthMaterial),Si(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof mt){Bd(n);for(const t of Object.keys(n.attributes)){const i=n.attributes[t];Si(i)}}else if(n instanceof $e||n instanceof $c)bu&&console.warn("BufferAttribute dispose not supported",n.count);else if(n instanceof Array)for(const t of n)t instanceof kt&&Si(t);else if(n instanceof kt){Bd(n);for(const i of Object.keys(n)){const s=n[i];s instanceof Ot&&(Si(s),n[i]=null)}const t=n.uniforms;if(t)for(const i of Object.keys(t)){const s=t[i];s instanceof Ot?(Si(s),t[i]=null):s instanceof xe&&(Si(s.value),s.value=null)}}else n instanceof Ot?(Bd(n),Bd(n.source),((e=n.source)==null?void 0:e.data)instanceof ImageBitmap&&Bd(n.source.data)):n instanceof $f?(Bd(n.boneTexture),n.boneTexture=null):n instanceof mA||!(n instanceof Te)&&bu&&console.warn("Unknown object type",n)}}function Bd(n){n&&((bu||EU()||q_)&&console.warn("🧨 FREE",n),n instanceof ImageBitmap?n.close():n instanceof Lc?n.data=null:n.dispose())}function RU(n){(n instanceof ye||n instanceof ku)&&(n.material=null,n.geometry=null)}const T6=new Set;function iT(n,e,t=null,i){if(i||(i=T6,i.clear()),!n)return i;const s=n[Um];if(s)for(const r of s)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&iT(r,!0,t,i));return i}function I6(n){return n[Ig]}const bu=re("debugresourceusers")||re("debugmemory"),Um=Symbol("needle-resource-users"),Ig=Symbol("needle-resource-users-count");function Gs(n,e){X_(n,e,function(t,i){Nu&&(ub(Um,this,t,!1),ub(Um,this,i,!0))})}Nu&&(Gs(ye.prototype,"material"),Gs(ye.prototype,"geometry"),Gs(kt.prototype,"map"),Gs(kt.prototype,"bumpMap"),Gs(kt.prototype,"alphaMap"),Gs(kt.prototype,"normalMap"),Gs(kt.prototype,"displacementMap"),Gs(kt.prototype,"roughnessMap"),Gs(kt.prototype,"metalnessMap"),Gs(kt.prototype,"emissiveMap"),Gs(kt.prototype,"specularMap"),Gs(kt.prototype,"envMap"),Gs(kt.prototype,"lightMap"),Gs(kt.prototype,"aoMap"),Gs(kt.prototype,"gradientMap"));function R6(n){if(Nu===!1)return;const e=n[Um];if(e)for(const t of e)ub(Um,t,n,!1)}Nu&&X_(kt.prototype,"dispose",function(){R6(this)});let kE=0;function ub(n,e,t,i){if(kE>0)return;if(Array.isArray(t)){for(const r of t)ub(n,e,r,i);return}if(!t)return;let s=t[n];if(s||(s=new Set),i){if(e&&!s.has(e)){s.add(e);let r=t[Ig]||0;r+=1,t[Ig]=r,bu&&console.warn(`🟢 Added user of "${t.type}"`,e,t,r,"users:",s)}}else if(e&&s.has(e)){s.delete(e);let r=t[Ig]||0;r>0&&(r-=1,t[Ig]=r),bu&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,r,"users:",s),r<=0&&(Jg.isLoading(t)||(q_&&console.warn(`🔴 Removed all user of "${t.type}"`,t),EU()&&Si(t)))}t[n]=s}try{X_(Ou.prototype,"render",function(){kE++},function(){kE--})}catch(n){console.warn("Could not wrap WebGLRenderer.render",n)}const A0=re("debuggetcomponent"),v0=re("debuginstantiate");var PU=(n=>(n[n.None=0]="None",n[n.HideInHierarchy=1]="HideInHierarchy",n[n.HideInInspector=2]="HideInInspector",n[n.DontSaveInEditor=4]="DontSaveInEditor",n[n.NotEditable=8]="NotEditable",n[n.DontSaveInBuild=16]="DontSaveInBuild",n[n.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",n[n.DontSave=52]="DontSave",n[n.HideAndDontSave=61]="HideAndDontSave",n))(PU||{});class qa{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}}function rp(n){return n.visible}function Zg(n,e){return typeof e=="number"&&(e=e>.5),n.visible=e,n.visible}function BU(n){return n[Yc]||Y_(n)}function DU(n,e){n[yU]=e}function Y_(n){return Sr.isUsingInstancing(n)}function RA(n,e){return Nf(n,e,!0,!0)}const OU=Symbol("isDestroyed");function nT(n){return n[OU]}function kU(n,e){n[OU]=e}function tl(n,e=!0,t=!1){const i=[];LU(n,e,t,!0,i);for(const s of i)s.gameObject=null,s.context=null}function LU(n,e=!0,t=!1,i=!0,s){if(n==null)return;const r=n;if(r.isComponent){s.push(r);const c=r.gameObject;r.__internalDisable(),r.__internalDestroy(),r.gameObject=c;return}const o=n;if(kU(o,!0),t&&Si(o),RU(o),A0&&console.log(o),e&&o.children)for(const c of o.children)LU(c,e,t,!1,s);const a=o.userData.components;if(a){let c=a.length;for(let l=0;l<a.length;l++){const u=a[l];s.push(u);const d=u.gameObject;u.__internalDisable(),u.__internalDestroy(),u.gameObject=d,a.length<c&&(c=a.length,l--)}}i&&o.removeFromParent()}function Ru(n,e,t=!0){return FU(n,e,t)}function*sT(n,e,t=!1,i=999,s=0){if(n!=null&&n.userData.components&&!(s>i)){for(const r of n.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of n.children)yield*sT(r,e,!0,i,s+1)}}function FU(n,e,t,i=0){var s;if(n){if(n.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((s=n.userData)!=null&&s.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&n.children){const r=i+1;for(let o=0;o<n.children.length;o++){const a=n.children[o];if(!a)continue;const c=FU(a,e,t,r);if(c!==void 0)return c}}}}function PA(n,e=null){if(n===null)return null;let t=null;e!==null&&(e.x!==void 0?(t=new qa,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),A0&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new Bs(Date.now()));const s=[],r={},o={},a=UU(i,n,t,s,r,o);a&&(B6(r),P6(o,r)),A0&&(sb(n,!0),sb(a,!0));const c={};for(const l in s){const u=s[l],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),c[d]=u.guid,A0&&console.log(u.name,u.guid)),tx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const l in s){const u=s[l];u.resolveGuids&&u.resolveGuids(c),u.enabled!==!1&&(u.enabled=!0)}return db(i),a}function UU(n,e,t,i,s,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const c=e.clone(!1);if(j_(c),e.userData=o,e.children=a,s[e.uuid]={original:e,clone:c},v0&&console.log("ADD",e,c),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:c}),(t==null?void 0:t.visible)!==void 0&&(c.visible=t.visible),t!=null&&t.idProvider){c.uuid=t.idProvider.generateUUID();const d=c;d&&(d.guid=c.uuid)}e.animations&&e.animations.length>0&&(c.animations=[...e.animations]);const l=e.parent;if(l&&l.add(c),t!=null&&t.position?Mn(c,t.position):c.position.copy(e.position),t!=null&&t.rotation?Mr(c,t.rotation):c.quaternion.copy(e.quaternion),t!=null&&t.scale?c.scale.copy(t.scale):c.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=Nf(t.parent,n.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,c):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(c.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];c.userData.components=f;for(let p=0;p<d.length;p++){const g=d[p],A=new g.constructor;Hf(A,g),g[Kg]!==void 0&&(A[Kg]=g[Kg]),f.push(A),A.gameObject=c,i.push(A),CA.dispatchComponentLifecycleEvent(SA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=UU(n,f,t,i,s,r);p&&c.add(p)}return c}function P6(n,e){for(const t in n){const i=n[t],s=i.original,r=s.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,c=o.skeleton.clone();o.skeleton=c,o.bindMatrix.clone().copy(s.bindMatrix),o.bindMatrixInverse.copy(s.bindMatrixInverse);const l=[];c.bones=l;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;l.push(p)}}for(const t in n){const i=n[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function B6(n){var e;for(const t in n){const s=n[t].clone;if((e=s.userData)!=null&&e.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r],a=Object.entries(o);for(const[c,l]of a)if(Array.isArray(l)){const u=[];o[c]=u;for(let d=0;d<l.length;d++){const f=l[d];if(typeof f!="object"){u.push(f);continue}const p=qB(o,c,f,n);p!==void 0?u.push(p):u.push(f)}}else if(typeof l=="object"){const u=qB(o,c,l,n);u!==void 0&&(o[c]=u)}}}}function qB(n,e,t,i){var s,r;if(t!=null){if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,c=(s=i[a])==null?void 0:s.clone;if(!c){v0&&console.log("reference did not change",e,n,t);return}const l=o.userData.components.indexOf(t);if(l>=0)return v0&&console.log(e,a),c.userData.components[l];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,c=(r=i[a])==null?void 0:r.clone;if(c)return v0&&console.log(e,"old",t,"new",c),c}}else if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone()}}const LE=re("debugnewscripts"),D6=re("debughierarchy"),Ni=[];function O6(){return Ni.length>0}function db(n){if(!(n.new_scripts.length<=0)){if(LE&&console.log("Register new components",n.new_scripts.length,[...n.new_scripts],n.alias?"element: "+n.alias:n.hash,n),n.new_scripts_pre_setup_callbacks.length>0){for(const e of n.new_scripts_pre_setup_callbacks)e&&e();n.new_scripts_pre_setup_callbacks.length=0}Ni.length=0,n.new_scripts.length>0&&Ni.push(...n.new_scripts),n.new_scripts.length=0;for(let e=0;e<Ni.length;e++)try{const t=Ni[e];if(t.isComponent!==!0){(ci()||LE)&&console.error(`Registered script is not a Needle Engine component.
|
|
3768
|
+
`+s.src),e.preventDefault())}})}}const q_=re("trackresources");function EU(){return q_==="dispose"}let Nu=!0;q_===0&&(Nu=!1);function E6(n){Nu=n}function MU(){return Nu}const TU=Symbol("disposable");function tT(n,e){n&&(n[TU]=e,bu&&console.warn("Set disposable",e,n))}const IU=Symbol("disposed");function M6(n){return n[IU]===!0}function Si(n){var e;if(n){if(n[TU]===!1){bu&&console.warn("Object is marked as not disposable",n);return}if(n[IU]=!0,n instanceof Er)Si(n.environment),Si(n.background),Si(n.customDepthMaterial),Si(n.customDistanceMaterial);else if(n instanceof ku)Si(n.geometry),Si(n.material),Si(n.skeleton),Si(n.bindMatrix),Si(n.bindMatrixInverse),Si(n.customDepthMaterial),Si(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof ye)Si(n.geometry),Si(n.material),Si(n.customDepthMaterial),Si(n.customDistanceMaterial),n.geometry=null,n.material=null;else if(n instanceof mt){Bd(n);for(const t of Object.keys(n.attributes)){const i=n.attributes[t];Si(i)}}else if(n instanceof $e||n instanceof $c)bu&&console.warn("BufferAttribute dispose not supported",n.count);else if(n instanceof Array)for(const t of n)t instanceof kt&&Si(t);else if(n instanceof kt){Bd(n);for(const i of Object.keys(n)){const s=n[i];s instanceof Ot&&(Si(s),n[i]=null)}const t=n.uniforms;if(t)for(const i of Object.keys(t)){const s=t[i];s instanceof Ot?(Si(s),t[i]=null):s instanceof xe&&(Si(s.value),s.value=null)}}else n instanceof Ot?(Bd(n),Bd(n.source),((e=n.source)==null?void 0:e.data)instanceof ImageBitmap&&Bd(n.source.data)):n instanceof $f?(Bd(n.boneTexture),n.boneTexture=null):n instanceof mA||!(n instanceof Te)&&bu&&console.warn("Unknown object type",n)}}function Bd(n){n&&((bu||EU()||q_)&&console.warn("🧨 FREE",n),n instanceof ImageBitmap?n.close():n instanceof Lc?n.data=null:n.dispose())}function RU(n){(n instanceof ye||n instanceof ku)&&(n.material=null,n.geometry=null)}const T6=new Set;function iT(n,e,t=null,i){if(i||(i=T6,i.clear()),!n)return i;const s=n[Um];if(s)for(const r of s)i.has(r)||(t==null?void 0:t.call(null,r))!==!1&&(i.add(r),e&&iT(r,!0,t,i));return i}function I6(n){return n[Ig]}const bu=re("debugresourceusers")||re("debugmemory"),Um=Symbol("needle-resource-users"),Ig=Symbol("needle-resource-users-count");function Gs(n,e){X_(n,e,function(t,i){Nu&&(ub(Um,this,t,!1),ub(Um,this,i,!0))})}Nu&&(Gs(ye.prototype,"material"),Gs(ye.prototype,"geometry"),Gs(kt.prototype,"map"),Gs(kt.prototype,"bumpMap"),Gs(kt.prototype,"alphaMap"),Gs(kt.prototype,"normalMap"),Gs(kt.prototype,"displacementMap"),Gs(kt.prototype,"roughnessMap"),Gs(kt.prototype,"metalnessMap"),Gs(kt.prototype,"emissiveMap"),Gs(kt.prototype,"specularMap"),Gs(kt.prototype,"envMap"),Gs(kt.prototype,"lightMap"),Gs(kt.prototype,"aoMap"),Gs(kt.prototype,"gradientMap"));function R6(n){if(Nu===!1)return;const e=n[Um];if(e)for(const t of e)ub(Um,t,n,!1)}Nu&&X_(kt.prototype,"dispose",function(){R6(this)});let kE=0;function ub(n,e,t,i){if(kE>0)return;if(Array.isArray(t)){for(const r of t)ub(n,e,r,i);return}if(!t)return;let s=t[n];if(s||(s=new Set),i){if(e&&!s.has(e)){s.add(e);let r=t[Ig]||0;r+=1,t[Ig]=r,bu&&console.warn(`🟢 Added user of "${t.type}"`,e,t,r,"users:",s)}}else if(e&&s.has(e)){s.delete(e);let r=t[Ig]||0;r>0&&(r-=1,t[Ig]=r),bu&&console.warn(`🔴 Removed user of "${t.type}"`,e,t,r,"users:",s),r<=0&&(Jg.isLoading(t)||(q_&&console.warn(`🔴 Removed all user of "${t.type}"`,t),EU()&&Si(t)))}t[n]=s}try{X_(Ou.prototype,"render",function(){kE++},function(){kE--})}catch(n){console.warn("Could not wrap WebGLRenderer.render",n)}const A0=re("debuggetcomponent"),v0=re("debuginstantiate");var PU=(n=>(n[n.None=0]="None",n[n.HideInHierarchy=1]="HideInHierarchy",n[n.HideInInspector=2]="HideInInspector",n[n.DontSaveInEditor=4]="DontSaveInEditor",n[n.NotEditable=8]="NotEditable",n[n.DontSaveInBuild=16]="DontSaveInBuild",n[n.DontUnloadUnusedAsset=32]="DontUnloadUnusedAsset",n[n.DontSave=52]="DontSave",n[n.HideAndDontSave=61]="HideAndDontSave",n))(PU||{});class qa{constructor(){h(this,"idProvider");h(this,"parent");h(this,"keepWorldPosition");h(this,"position");h(this,"rotation");h(this,"scale");h(this,"visible");h(this,"context")}}function rp(n){return n.visible}function Zg(n,e){return typeof e=="number"&&(e=e>.5),n.visible=e,n.visible}function BU(n){return n[Yc]||Y_(n)}function DU(n,e){n[yU]=e}function Y_(n){return Sr.isUsingInstancing(n)}function RA(n,e){return Nf(n,e,!0,!0)}const OU=Symbol("isDestroyed");function nT(n){return n[OU]}function kU(n,e){n[OU]=e}function tl(n,e=!0,t=!1){const i=[];LU(n,e,t,!0,i);for(const s of i)s.gameObject=null,s.context=null}function LU(n,e=!0,t=!1,i=!0,s){if(n==null)return;const r=n;if(r.isComponent){s.push(r);const c=r.gameObject;r.__internalDisable(),r.__internalDestroy(),r.gameObject=c;return}const o=n;if(kU(o,!0),t&&Si(o),RU(o),A0&&console.log(o),e&&o.children)for(const c of o.children)LU(c,e,t,!1,s);const a=o.userData.components;if(a){let c=a.length;for(let l=0;l<a.length;l++){const u=a[l];s.push(u);const d=u.gameObject;u.__internalDisable(),u.__internalDestroy(),u.gameObject=d,a.length<c&&(c=a.length,l--)}}i&&o.removeFromParent()}function Ru(n,e,t=!0){return FU(n,e,t)}function*sT(n,e,t=!1,i=999,s=0){if(n!=null&&n.userData.components&&!(s>i)){for(const r of n.userData.components)e&&(r==null?void 0:r.isComponent)===!0&&r instanceof e?yield r:yield r;if(t===!0)for(const r of n.children)yield*sT(r,e,!0,i,s+1)}}function FU(n,e,t,i=0){var s;if(n){if(n.isObject3D,i>1e3){console.warn("Failed to iterate components: too many levels");return}if((s=n.userData)!=null&&s.components)for(let r=0;r<n.userData.components.length;r++){const o=n.userData.components[r];if((o==null?void 0:o.isComponent)===!0){const a=e(o);if(a!==void 0)return a}}if(t&&n.children){const r=i+1;for(let o=0;o<n.children.length;o++){const a=n.children[o];if(!a)continue;const c=FU(a,e,t,r);if(c!==void 0)return c}}}}function PA(n,e=null){if(n===null)return null;let t=null;e!==null&&(e.x!==void 0?(t=new qa,t.position=e):t=e);let i=Ft.Current;t!=null&&t.context&&(i=t.context),A0&&i.alias&&console.log("context",i.alias),t&&!t.idProvider&&(t.idProvider=new Bs(Date.now()));const s=[],r={},o={},a=UU(i,n,t,s,r,o);a&&(B6(r),P6(o,r)),A0&&(sb(n,!0),sb(a,!0));const c={};for(const l in s){const u=s[l],d=u.guid;t&&t.idProvider&&(u.guid=t.idProvider.generateUUID(),c[d]=u.guid,A0&&console.log(u.name,u.guid)),tx(u,i),u.__internalNewInstanceCreated&&u.__internalNewInstanceCreated()}for(const l in s){const u=s[l];u.resolveGuids&&u.resolveGuids(c),u.enabled!==!1&&(u.enabled=!0)}return db(i),a}function UU(n,e,t,i,s,r){var u;if(!e)return null;const o=e.userData;e.userData={};const a=e.children;e.children=[];const c=e.clone(!1);if(j_(c),e.userData=o,e.children=a,s[e.uuid]={original:e,clone:c},v0&&console.log("ADD",e,c),e.type==="SkinnedMesh"&&(r[e.uuid]={original:e,clone:c}),(t==null?void 0:t.visible)!==void 0&&(c.visible=t.visible),t!=null&&t.idProvider){c.uuid=t.idProvider.generateUUID();const d=c;d&&(d.guid=c.uuid)}e.animations&&e.animations.length>0&&(c.animations=[...e.animations]);const l=e.parent;if(l&&l.add(c),t!=null&&t.position?Mn(c,t.position):c.position.copy(e.position),t!=null&&t.rotation?Mr(c,t.rotation):c.quaternion.copy(e.quaternion),t!=null&&t.scale?c.scale.copy(t.scale):c.scale.copy(e.scale),t!=null&&t.parent&&t.parent!=="scene"){let d=null;if(typeof t.parent=="string"?d=Nf(t.parent,n.scene,!0):d=t.parent,d){const f=t.keepWorldPosition===!0?d.attach:d.add;f?f.call(d,c):console.error("Invalid parent object",d,"received when instantiating:",e)}else console.warn("could not find parent:",t.parent)}for(const[d,f]of Object.entries(e.userData))d!=="components"&&(c.userData[d]=f);if((u=e.userData)!=null&&u.components){const d=e.userData.components,f=[];c.userData.components=f;for(let p=0;p<d.length;p++){const g=d[p],A=new g.constructor;Hf(A,g),g[Kg]!==void 0&&(A[Kg]=g[Kg]),f.push(A),A.gameObject=c,i.push(A),CA.dispatchComponentLifecycleEvent(SA.Added,A)}}t&&(t.position=void 0,t.rotation=void 0,t.scale=void 0,t.parent=void 0);for(const d in e.children){const f=e.children[d],p=UU(n,f,t,i,s,r);p&&c.add(p)}return c}function P6(n,e){for(const t in n){const i=n[t],s=i.original,r=s.skeleton,o=i.clone;if(!r){console.warn("Skinned mesh has no skeleton?",i);continue}const a=r.bones,c=o.skeleton.clone();o.skeleton=c,o.bindMatrix.clone().copy(s.bindMatrix),o.bindMatrixInverse.copy(s.bindMatrixInverse);const l=[];c.bones=l;for(let u=0;u<a.length;u++){const d=a[u],p=e[d.uuid].clone;l.push(p)}}for(const t in n){const i=n[t].clone;i.skeleton.update(),i.bind(i.skeleton,i.bindMatrix),i.updateMatrixWorld(!0)}}function B6(n){var e;for(const t in n){const s=n[t].clone;if((e=s.userData)!=null&&e.components)for(let r=0;r<s.userData.components.length;r++){const o=s.userData.components[r],a=Object.entries(o);for(const[c,l]of a)if(Array.isArray(l)){const u=[];o[c]=u;for(let d=0;d<l.length;d++){const f=l[d];if(typeof f!="object"){u.push(f);continue}const p=qB(o,c,f,n);p!==void 0?u.push(p):u.push(f)}}else if(typeof l=="object"){const u=qB(o,c,l,n);u!==void 0&&(o[c]=u)}}}}function qB(n,e,t,i){var s,r;if(t!=null)if(t.isComponent===!0){const o=t.gameObject;if(o){const a=o.uuid,c=(s=i[a])==null?void 0:s.clone;if(!c){v0&&console.log("reference did not change",e,n,t);return}const l=o.userData.components.indexOf(t);if(l>=0)return v0&&console.log(e,a),c.userData.components[l];console.warn("could not find component",e,t)}}else if(t.isObject3D===!0){if(e==="gameObject")return;const o=t;if(o){const a=o.uuid,c=(r=i[a])==null?void 0:r.clone;if(c)return v0&&console.log(e,"old",t,"new",c),c}}else{if(t.isVector4||t.isVector3||t.isVector2||t.isQuaternion||t.isEuler)return t.clone();if(t.isEventList===!0)return new t.constructor}}const LE=re("debugnewscripts"),D6=re("debughierarchy"),Ni=[];function O6(){return Ni.length>0}function db(n){if(!(n.new_scripts.length<=0)){if(LE&&console.log("Register new components",n.new_scripts.length,[...n.new_scripts],n.alias?"element: "+n.alias:n.hash,n),n.new_scripts_pre_setup_callbacks.length>0){for(const e of n.new_scripts_pre_setup_callbacks)e&&e();n.new_scripts_pre_setup_callbacks.length=0}Ni.length=0,n.new_scripts.length>0&&Ni.push(...n.new_scripts),n.new_scripts.length=0;for(let e=0;e<Ni.length;e++)try{const t=Ni[e];if(t.isComponent!==!0){(ci()||LE)&&console.error(`Registered script is not a Needle Engine component.
|
|
3769
3769
|
The script will be ignored. Please make sure your component extends "Behaviour" imported from "@needle-tools/engine"
|
|
3770
3770
|
`,t),Ni.splice(e,1),e--;continue}if(t.destroyed)continue;if(!t.gameObject){console.error("MISSING GAMEOBJECT - will ignore",t),Ni.splice(e,1),e--;continue}t.context=n,$g(t.gameObject),rT(t,n)}catch(t){console.error(t),Bc(Ni[e],n),Ni.splice(e,1),e--}for(let e=0;e<Ni.length;e++)try{const t=Ni[e];if(t.destroyed){Bc(Ni[e],n),Ni.splice(e,1),e--;continue}if(t.registering)try{t.registering()}catch(i){console.error(i)}t.__internalAwake!==void 0&&(t.gameObject||console.error("MISSING GAMEOBJECT",t,t.gameObject),$g(t.gameObject),t.activeAndEnabled&&bf(t.__internalAwake.bind(t)))}catch(t){console.error(t),Bc(Ni[e],n),Ni.splice(e,1),e--}for(let e=0;e<Ni.length;e++)try{const t=Ni[e];if(t.destroyed||t.enabled===!1||($g(t.gameObject),t.activeAndEnabled===!1))continue;t.__internalEnable!==void 0&&(t.enabled=!0,bf(t.__internalEnable.bind(t)))}catch(t){console.error(t),Bc(Ni[e],n),Ni.splice(e,1),e--}for(let e=0;e<Ni.length;e++)try{const t=Ni[e];if(t.destroyed||!t.gameObject)continue;n.new_script_start.push(t)}catch(t){console.error(t),Bc(Ni[e],n),Ni.splice(e,1),e--}Ni.length=0;for(const e of n.new_scripts_post_setup_callbacks)e&&e();n.new_scripts_post_setup_callbacks.length=0}}function k6(n){n&&(n.__internalDisable(!0),Bc(n,n.context))}function NU(n,e){for(let t=0;t<n.new_script_start.length;t++)try{const i=n.new_script_start[t];if(e!==void 0&&i.gameObject!==e||i.destroyed||i.activeAndEnabled===!1)continue;bf(i.__internalAwake.bind(i)),i.enabled&&(bf(i.__internalEnable.bind(i)),bf(i.__internalStart.bind(i)),n.new_script_start.splice(t,1),t--)}catch(i){console.error(i),Bc(n.new_script_start[t],n),n.new_script_start.splice(t,1),t--}}function rT(n,e){e.scripts.indexOf(n)===-1&&(e.scripts.push(n),n.earlyUpdate&&e.scripts_earlyUpdate.push(n),n.update&&e.scripts_update.push(n),n.lateUpdate&&e.scripts_lateUpdate.push(n),n.onBeforeRender&&e.scripts_onBeforeRender.push(n),n.onAfterRender&&e.scripts_onAfterRender.push(n),n.onPausedChanged&&e.scripts_pausedChanged.push(n))}function Bc(n,e){dc(n,e.new_scripts),dc(n,e.new_script_start),dc(n,e.scripts),dc(n,e.scripts_earlyUpdate),dc(n,e.scripts_update),dc(n,e.scripts_lateUpdate),dc(n,e.scripts_onBeforeRender),dc(n,e.scripts_onAfterRender),dc(n,e.scripts_pausedChanged),e.stopAllCoroutinesFrom(n)}function dc(n,e){const t=e.indexOf(n);t>=0&&e.splice(t,1)}function y0(n){if(n||(n=Oi.Current.scene),!n){console.trace("Invalid call - no current context.");return}const e=rp(n);zU(n,e,!0)||(LE||ci()?console.error(`Error updating hierarchy
|
|
3771
3771
|
Do you have circular references in your project? <a target="_blank" href="https://docs.needle.tools/circular-reference"> Click here for more information.`,n):console.error('Failed to update active state in hierarchy of "'+n.name+'"',n),console.warn(" ↑ this error might be caused by circular references. Please make sure you don't have files with circular references (e.g. one GLB 1 is loading GLB 2 which is then loading GLB 1 again)."))}function zU(n,e,t,i=0){if(i>1e3)return console.warn("Hierarchy is too deep (> 1000 level) - will abort updating active state"),!1;const s=rp(n);if(e&&(e=s,e&&n.parent)){const c=n.parent;e=c[Yc],e===void 0&&(c instanceof Er||(e=!0))}const o=n[Yc]!==e;n[Yc]=e,o&&(D6&&console.warn("ACTIVE CHANGE",n.name,s,n.visible,e,"changed?"+o,n),t&&L6(n,c=>{e?c.enabled&&(bf(c.__internalAwake.bind(c)),c.enabled&&(c.__didEnable=!0,c.onEnable())):c.__didAwake&&c.enabled&&(c.__didEnable=!1,c.onDisable())}));let a=!0;if(n.children){const c=i+1;for(const l of n.children)zU(l,e,t,c)===!1&&(a=!1)}return a}function $g(n){let e=!0,t=n,i=!1;for(;t&&t;){if(t.type==="Scene"&&(i=!0),!rp(t)){e=!1;break}t=t.parent}if(!n){console.error("GO is null");return}n[Yc]=e&&i}function L6(n,e){var t;if((t=n.userData)!=null&&t.components)for(const i of n.userData.components)e(i)}const b0=new Map,GU=Symbol("prewarmFlag"),FE=Symbol("waitingForPrewarm"),UE=re("debugprewarm");function HU(n,e){if(!n||n[GU]===!0||n[FE]===!0)return;b0.has(e)||b0.set(e,[]),n[FE]=!0,b0.get(e).push(n),UE&&console.debug("register prewarm",n.name)}let YB=null,KB=null;function F6(n){if(!n)return;const e=b0.get(n);if(!(e!=null&&e.length))return;const t=n.mainCamera;if(t){UE&&console.log("prewarm",e.length,"objects",[...e]);const i=n.renderer;if(i.compile){const s=n.scene;i.compile(s,t),YB??(YB=new t_(64)),KB??(KB=new c1(.001,9999999,YB)),KB.update(i,s);for(const r of e)r[GU]=!0,r[FE]=!1;e.length=0,UE&&console.log("prewarm done")}}}/**
|
|
@@ -4489,7 +4489,7 @@ Texture:`,i),this.setLightmapDebugMaterial()),this.applyLightmap())}updateLightm
|
|
|
4489
4489
|
gl_FragColor = lightMapTexel;
|
|
4490
4490
|
gl_FragColor.a = 1.;
|
|
4491
4491
|
}
|
|
4492
|
-
`,defines:{USE_LIGHTMAP:""}})}}const lp=function(n){return x(n)},x=function(n){if(n===void 0&&(n=null),!Array.isArray(n))n=LD(n);else for(let e=0;e<n.length;e++){const t=n[e];n[e]=LD(t)}return function(e,t){typeof t!="string"&&(t=t.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const i=e.$serializedTypes=e.$serializedTypes||{};i[t]=n}};function LD(n){var e,t;switch((t=(e=n==null?void 0:n.prototype)==null?void 0:e.constructor)==null?void 0:t.name){case"Number":case"String":case"Boolean":return null}return n}class bi extends _e{constructor(t,i,s,r){super(t,i,s);h(this,"alpha",1);this.alpha=r}get isRGBAColor(){return!0}set a(t){this.alpha=t}get a(){return this.alpha}clone(){const t=super.clone();return t.alpha=this.alpha,t}copy(t){return super.copy(t),"alpha"in t&&typeof t.alpha=="number"?this.alpha=t.alpha:typeof t.a=="number"&&(this.alpha=t.a),this}lerp(t,i){const s=t;return s.alpha&&(this.alpha=tt.lerp(this.alpha,s.alpha,i)),super.lerp(t,i)}lerpColors(t,i,s){const r=t,o=i;return r.alpha&&o.alpha&&(this.alpha=tt.lerp(r.alpha,o.alpha,s)),super.lerpColors(t,i,s)}multiply(t){const i=t;return i.alpha&&(this.alpha=this.alpha*i.alpha),super.multiply(t)}fromArray(t,i=0){return this.alpha=t[i+3],super.fromArray(t,i)}}class Wf{constructor(e,t){h(this,"method");h(this,"enabled");this.method=e,this.enabled=t!==void 0?t:!0}invoke(...e){if(this.enabled!==!1){if(!this.method){console.warn("No function. Please check you assigned a method to invoke on export",this);return}this.method(...e)}}}const Q7=n=>/^[A-Z]*$/.test(n);class ix extends Event{constructor(){super(...arguments);h(this,"args")}}class us{constructor(e){h(this,"target");h(this,"key");h(this,"_isInvoking",!1);h(this,"methods",[]);this.methods=e??[]}setEventTarget(e,t){if(this.key=e,this.target=t,this.key!==void 0){let i="",s=!1;for(const r of this.key)s&&Q7(r)&&(i+="-"),s=!0,i+=r.toLowerCase();this.key=i}}get listenerCount(){var e;return((e=this.methods)==null?void 0:e.length)??0}invoke(...e){var t;if(this._isInvoking)return console.warn("Circular event invocation detected. Please check your event listeners for circular references.",this),!1;if(((t=this.methods)==null?void 0:t.length)<=0)return!1;this._isInvoking=!0;try{for(const i of this.methods)i.invoke(...e);if(typeof this.target=="object"&&typeof this.key=="string"){const i=this.target.dispatchEvent;if(typeof i=="function"){const s=new ix(this.key);s.args=e,i.call(this.target,s)}}}finally{this._isInvoking=!1}return!0}addEventListener(e){return this.methods.push(new Wf(e,!0)),e}removeEventListener(e){if(e)for(let t=this.methods.length-1;t>=0;t--)this.methods[t].method===e&&(this.methods[t].enabled=!1,this.methods.splice(t,1))}removeAllEventListeners(){this.methods.length=0}}const FD=Symbol("previous-visibility"),pf=class extends ai{render(e,t,i){if(i instanceof lT)this._unsupported_effectcomposer_warning||(console.warn("RenderTexture.render() does not yet support EffectComposer"),this._unsupported_effectcomposer_warning=!0);else{this.onBeforeRender();const s=i.getRenderTarget(),r=i.xr.enabled;i.xr.enabled=!1,i.setRenderTarget(this),i.clear(!0,!0,!0),i.render(e,t),i.setRenderTarget(s),i.xr.enabled=r,this.onAfterRender()}}onBeforeRender(){pf._userSet.clear();const e=iT(this.texture,!0,null,pf._userSet);for(const t of e)t instanceof ye&&(t[FD]=t.visible,t.visible=!1)}onAfterRender(){for(const e of pf._userSet)e instanceof ye&&(e.visible=e[FD]);pf._userSet.clear()}};let Jl=pf;h(Jl,"_userSet",new Set);class W7 extends mh{constructor(){super([_e,bi])}onDeserialize(e){if(e!=null)return e.a!==void 0?new bi(e.r,e.g,e.b,e.a):e.alpha!==void 0?new bi(e.r,e.g,e.b,e.alpha):new _e(e.r,e.g,e.b)}onSerialize(e){if(e!=null)return e.a!==void 0?{r:e.r,g:e.g,b:e.b,a:e.a}:{r:e.r,g:e.g,b:e.b}}}const j7=new W7;class X7 extends mh{constructor(){super(Te)}onSerialize(e,t){if(t.objectToNode!==void 0&&e.uuid){const i=t.objectToNode[e.uuid];return Rs&&console.log(i,e.name,e.uuid),{node:i}}}onDeserialize(e,t){var i,s,r;if(typeof e=="string"){(e.endsWith(".glb")||e.endsWith(".gltf"))&&(ci()&&Ls("Detected wrong usage of @serializable with Object3D or GameObject. Instead you should use AssetReference here! Please see the console for details."),console.warn(`Wrong usage of @serializable detected:
|
|
4492
|
+
`,defines:{USE_LIGHTMAP:""}})}}const lp=function(n){return x(n)},x=function(n){if(n===void 0&&(n=null),!Array.isArray(n))n=LD(n);else for(let e=0;e<n.length;e++){const t=n[e];n[e]=LD(t)}return function(e,t){typeof t!="string"&&(t=t.name),Object.getOwnPropertyDescriptor(e,"$serializedTypes")||(e.$serializedTypes={});const i=e.$serializedTypes=e.$serializedTypes||{};i[t]=n}};function LD(n){var e,t;switch((t=(e=n==null?void 0:n.prototype)==null?void 0:e.constructor)==null?void 0:t.name){case"Number":case"String":case"Boolean":return null}return n}class bi extends _e{constructor(t,i,s,r){super(t,i,s);h(this,"alpha",1);this.alpha=r}get isRGBAColor(){return!0}set a(t){this.alpha=t}get a(){return this.alpha}clone(){const t=super.clone();return t.alpha=this.alpha,t}copy(t){return super.copy(t),"alpha"in t&&typeof t.alpha=="number"?this.alpha=t.alpha:typeof t.a=="number"&&(this.alpha=t.a),this}lerp(t,i){const s=t;return s.alpha&&(this.alpha=tt.lerp(this.alpha,s.alpha,i)),super.lerp(t,i)}lerpColors(t,i,s){const r=t,o=i;return r.alpha&&o.alpha&&(this.alpha=tt.lerp(r.alpha,o.alpha,s)),super.lerpColors(t,i,s)}multiply(t){const i=t;return i.alpha&&(this.alpha=this.alpha*i.alpha),super.multiply(t)}fromArray(t,i=0){return this.alpha=t[i+3],super.fromArray(t,i)}}class Wf{constructor(e,t){h(this,"method");h(this,"enabled");this.method=e,this.enabled=t!==void 0?t:!0}invoke(...e){if(this.enabled!==!1){if(!this.method){console.warn("No function. Please check you assigned a method to invoke on export",this);return}this.method(...e)}}}const Q7=n=>/^[A-Z]*$/.test(n);class ix extends Event{constructor(){super(...arguments);h(this,"args")}}class us{constructor(e){h(this,"isEventList",!0);h(this,"target");h(this,"key");h(this,"_isInvoking",!1);h(this,"methods",[]);this.methods=e??[]}setEventTarget(e,t){if(this.key=e,this.target=t,this.key!==void 0){let i="",s=!1;for(const r of this.key)s&&Q7(r)&&(i+="-"),s=!0,i+=r.toLowerCase();this.key=i}}get listenerCount(){var e;return((e=this.methods)==null?void 0:e.length)??0}get isInvoking(){return this._isInvoking}invoke(...e){var t;if(this._isInvoking)return console.warn("Circular event invocation detected. Please check your event listeners for circular references.",this),!1;if(((t=this.methods)==null?void 0:t.length)<=0)return!1;this._isInvoking=!0;try{for(const i of this.methods)i.invoke(...e);if(typeof this.target=="object"&&typeof this.key=="string"){const i=this.target.dispatchEvent;if(typeof i=="function"){const s=new ix(this.key);s.args=e,i.call(this.target,s)}}}finally{this._isInvoking=!1}return!0}addEventListener(e){return this.methods.push(new Wf(e,!0)),e}removeEventListener(e){if(e)for(let t=this.methods.length-1;t>=0;t--)this.methods[t].method===e&&(this.methods[t].enabled=!1,this.methods.splice(t,1))}removeAllEventListeners(){this.methods.length=0}}const FD=Symbol("previous-visibility"),pf=class extends ai{render(e,t,i){if(i instanceof lT)this._unsupported_effectcomposer_warning||(console.warn("RenderTexture.render() does not yet support EffectComposer"),this._unsupported_effectcomposer_warning=!0);else{this.onBeforeRender();const s=i.getRenderTarget(),r=i.xr.enabled;i.xr.enabled=!1,i.setRenderTarget(this),i.clear(!0,!0,!0),i.render(e,t),i.setRenderTarget(s),i.xr.enabled=r,this.onAfterRender()}}onBeforeRender(){pf._userSet.clear();const e=iT(this.texture,!0,null,pf._userSet);for(const t of e)t instanceof ye&&(t[FD]=t.visible,t.visible=!1)}onAfterRender(){for(const e of pf._userSet)e instanceof ye&&(e.visible=e[FD]);pf._userSet.clear()}};let Jl=pf;h(Jl,"_userSet",new Set);class W7 extends mh{constructor(){super([_e,bi])}onDeserialize(e){if(e!=null)return e.a!==void 0?new bi(e.r,e.g,e.b,e.a):e.alpha!==void 0?new bi(e.r,e.g,e.b,e.alpha):new _e(e.r,e.g,e.b)}onSerialize(e){if(e!=null)return e.a!==void 0?{r:e.r,g:e.g,b:e.b,a:e.a}:{r:e.r,g:e.g,b:e.b}}}const j7=new W7;class X7 extends mh{constructor(){super(Te)}onSerialize(e,t){if(t.objectToNode!==void 0&&e.uuid){const i=t.objectToNode[e.uuid];return Rs&&console.log(i,e.name,e.uuid),{node:i}}}onDeserialize(e,t){var i,s,r;if(typeof e=="string"){(e.endsWith(".glb")||e.endsWith(".gltf"))&&(ci()&&Ls("Detected wrong usage of @serializable with Object3D or GameObject. Instead you should use AssetReference here! Please see the console for details."),console.warn(`Wrong usage of @serializable detected:
|
|
4493
4493
|
|
|
4494
4494
|
It looks like you used @serializable(Object3D) or @serializable(GameObject) for a prefab or scene reference named "`+t.path+'" in your script "'+((s=(i=t.target)==null?void 0:i.constructor)==null?void 0:s.name)+`".
|
|
4495
4495
|
To fix this replace it with @serializable(AssetReference). Make sure to replace the type with AssetReference too.
|
|
@@ -5069,7 +5069,7 @@ void main() {
|
|
|
5069
5069
|
`){super("lineBreak",e,!0),this._newLineBreakability=null}update(e,t){this._needsProcess=!0}process(e){const t=e._whiteSpace._newLineBreakability;if(e._inlines._value)for(let i=0;i<e._inlines._value.length;i++){const s=e._inlines._value[i],r=s.char;let o=null;r!==void 0&&(t!=="nowrap"&&(this._value.includes(r)||r.match(/\s/g))&&(o="possible"),r.match(/\n/g)&&(o=t)),s.lineBreak=o}}get value(){return this._value}}class vz extends Ai{constructor(){super("layouter",null,!1),this._value=null}update(e,t){this._value=e._parent.find(i=>i.isUI&&i.isText),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}}class Vee extends Wm{constructor(e){super("backgroundColor",e,!1),this._allowsInherit=!1,this._input=0}computeOutputValue(e){this._input==="inherit"?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}}class yz extends b3{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class bz extends _3{constructor(){super()}computeOutputValue(e){this._value=DT(this.getInheritedInput(e))}}class _z extends T3{constructor(){super("fontFamily","inherit",!0),this._input="inherit",this._needsUpdate=!0,this._allowsInherit=!1}computeOutputValue(e){let t=this._inheritedInput;if(t==="inherit"&&(t=this.getInheritedInput(e)),t instanceof dx)this._value=t,e._font._needsUpdate=!0;else if(typeof t=="string"){const i=Pu.getFontFamily(t);i?(this._value=i,e._font._needsUpdate=!0):console.warn(`(.style) fontFamily, the font '${t}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}}class oI extends R3{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited,this._whiteSpacedContent="",this._stringCollapser=this.emptyStrategyLogic,this._inlineCollapser=this.emptyStrategyLogic,this._inlineWrapper=this.emptyStrategyLogic}_computeFromInherited(e){switch(super._computeFromInherited(e),this._newLineBreakability=Qee(this._value),this._value){case"nowrap":case"normal":this._stringCollapser=Wee;break;case"pre-line":this._stringCollapser=xz;break;default:this._stringCollapser=jee}switch(this._value){case"pre-line":case"nowrap":case"normal":this._inlineCollapser=Jee;break;case"pre-wrap":this._inlineCollapser=Kee;break;default:this._inlineCollapser=Zee}switch(this._value){case"pre-line":case"pre-wrap":case"normal":this._inlineWrapper=Xee;break;case"pre":this._inlineWrapper=qee;break;default:this._inlineWrapper=Yee}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}}const gO={" ":" ","\n":`
|
|
5070
5070
|
`,"\r":"\r"," ":" "},Qee=function(n){switch(n){case"pre":case"pre-wrap":case"pre-line":return"mandatory"}return null};function Wee(n){return xz(n.replace(/\n/g," "))}function xz(n){return n.replace(/[ ]{2,}/g," ")}function jee(n){return n}function Xee(n,e,t,i){const s=n[e];if(s.lineBreak==="mandatory"||t+s.xadvance+s.xoffset+s.kerning>i.INNER_WIDTH)return!0;const r=Cz(n,e,i);return $ee(n[e-1],t,r,i)}function qee(n,e,t,i){return n[e].lineBreak==="mandatory"}function Yee(){return!1}function Kee(n){if(!n[0])return 0;const e=n[0],t=n[n.length-1];return e.char&&e.char===`
|
|
5071
5071
|
`&&n.length>1&&Sz([e],n[1]),t.char&&t.char===`
|
|
5072
|
-
`&&n.length>1&&wz([t],n[n.length-2]),e.offsetX}function Jee(n){if(!n[0])return 0;let e=[],t;for(let i=0;i<n.length;i++){const s=n[i];if(s.char&&gO[s.char]&&n.length>i){e.push(s),t=n[i+1];continue}break}Sz(e,t),e=[],t=null;for(let i=n.length-1;i>0;i--){const s=n[i];if(s.char&&gO[s.char]&&i>0){e.push(s),t=n[i-1];continue}break}return wz(e,t),n[0].offsetX}function Zee(n){return n[0]?n[0].offsetX:0}function wz(n,e){if(e)for(let t=0;t<n.length;t++){const i=n[t];i.fontFactor=0,i.offsetX=e.offsetX+e.cumulativeWidth,i.cumulativeWidth=0}}function Sz(n,e){if(e)for(let t=0;t<n.length;t++){const i=n[t];i.fontFactor=0,i.offsetX=e.offsetX,i.cumulativeWidth=0}}function Cz(n,e,t,i){if(i=i||0,!n[e])return i;const s=n[e];return s.lineBreak?i+s.xadvance:Cz(n,e+1,t,i+s.xadvance+s.xoffset+s.kerning+t.LETTERSPACING)}function $ee(n,e,t,i){return!n||!n.char||e+t<i.INNER_WIDTH?!1:i.BREAKON.indexOf(n.char)>-1}class Ez extends P3{constructor(){super(),this._input="inherit",this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}}class Mz extends Wi{constructor(){super("fontSize","inherit",!0),this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._font._fontVariant&&(e._bounds._needsProcess=!0,e._layouter._needsProcess=!0)}process(e){if(!e._font._fontVariant||!e._font._fontVariant.isReady)return;const t=this._value/e._font._fontVariant.typographic.size,i=e._inlines._value;for(let s=0;s<i.length;s++){const r=i[s];r.resetOffsets(),r.fontSize=this._value,r.fontFactor=t}}get value(){return this._value}}class Tz extends B3{constructor(){super("segments",1,!1),this._notInheritedValue=void 0}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"&&(this._notInheritedValue=this.getInheritedInput(e)),e._layouter._needsUpdate=!0}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value==="inherit"?this._notInheritedValue:this._value}}class ete extends Tz{constructor(){super(),this._value="inherit"}}class tte extends fx{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value._layouter._needsProcess=!1}process(e){if(this._value!=="none"){const t=e._whiteSpace._whiteSpacedContent,i=e._inlines._value;for(let s=1;s<i.length;s++){const r=t[s-1]+t[s];i[s].kerning=e._font._fontVariant.getKerningAmount(r)}}}}class Iz extends Ai{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function ite(n,e=!1){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,c=new He.BufferGeometry;let l=0;for(let u=0;u<n.length;++u){const d=n[u];let f=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.attributes[p]),f++}if(f!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(d.morphAttributes[p])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(d.userData),e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(t){let u=0;const d=[];for(let f=0;f<n.length;++f){const p=n[f].index;for(let g=0;g<p.count;++g)d.push(p.getX(g)+u);u+=n[f].attributes.position.count}c.setIndex(d)}for(const u in r){const d=mO(r[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,d)}for(const u in o){const d=o[u][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<d;++f){const p=[];for(let A=0;A<o[u].length;++A)p.push(o[u][A][f]);const g=mO(p);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(g)}}return c}function mO(n){let e,t,i,s=0;for(let a=0;a<n.length;++a){const c=n[a];if(c.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=c.normalized),i!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=c.array.length}const r=new e(s);let o=0;for(let a=0;a<n.length;++a)r.set(n[a].array,o),o+=n[a].array.length;return new He.BufferAttribute(r,t,i)}class nte extends Ai{constructor(){super("renderer")}render(e){if(!e._inlines._value||!e._inlines._value.length)return;const t=e._inlines._value.map(s=>e._font._fontVariant.getGeometricGlyph(s,e).translate(s.offsetX,s.offsetY,0)),i=ite(t);e.setFontMesh(new He.Mesh(i,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class ste extends kT{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class qf extends GA{constructor(t={}){const i={};qf.definePropertiesValues(i,t);super(i,t);h(this,"_rebuildParentUI",()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0});qf.init(this)}add(t){const i=[];for(let s=0;s<arguments.length;s++){const r=arguments[s];!r.isUI||r.isInline?(i.push(r),r.position.z=.005):console.warn("Block element can only contain Box elements.",r)}return super.add(...i)}set textContent(t){this._textContent.value=t}get textContent(){return this._textContent._value}set invertAlpha(t){this._invertAlpha.value=t}get invertAlpha(){return this._invertAlpha._value}static definePropertiesValues(t,i){t.children||(t.children=Iz),t.textContent||(t.textContent=Nee),t.glyphs||(t.glyphs=Gee),t.inlines||(t.inlines=zee),t.layouter||(t.layouter=vz),t.renderer||(t.renderer=nte),t.fontFamily||(t.fontFamily=_z),t.fontWeight||(t.fontWeight=bz),t.fontStyle||(t.fontStyle=yz),t.fontSize||(t.fontSize=Mz),t.color||(t.color=Hee),t.backgroundColor||(t.backgroundColor=Vee),t.lineBreak||(t.lineBreak=Az),t.letterSpacing||(t.letterSpacing=Ez),t.whiteSpace||(t.whiteSpace=oI),t.segments||(t.segments=ete),t.textAlign||(t.textAlign=ste),t.fontKerning||(t.fontKerning=tte)}static init(t){Object.defineProperties(t,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class rte extends y3{constructor(){super("textContent",null,!1),this._needsUpdate=!1}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this._needsUpdate=!1;for(let i=e.children.length-1;i>=0;i--){const s=e.children[i];s.isUI&&(e.remove(s),s.clear())}e._children._uis=[],this._value&&e.add(new qf({name:"anonymousInline",textContent:this._value}))}}class ote extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class ate extends Ai{constructor(){super("layouter",null,!1),this._value=null}update(e,t){}process(e){let t=e._width._value;e._width._auto?t=1/0:t=e._bounds._innerWidth;const i=e._lineHeight._value,s=new ote(new pO);let r=0;e._children._inlines.forEach(d=>{if(!d._inlines.value)return;this._resetInlines(d);const f=d._fontSize._value,p=d._letterSpacing._value*f,g=d._whiteSpace._value,A=d._lineBreak._value,v={WHITESPACE:g,LETTERSPACING:p,BREAKON:A,INNER_WIDTH:t},m=d._whiteSpace._inlineWrapper;r+=d._margin._value.w+d._padding._value.w,d._inlines.value.forEach((b,y,_)=>{const C=s[s.length-1];if(m(_,y,r,v)){if(s.push(new pO(b)),b.offsetX=b.xoffset,b.width===0){r=0;return}b.cumulativeWidth=b.xadvance+p,r=b.cumulativeWidth;return}s[s.length-1].push(b),b.offsetX=r+b.xoffset+b.kerning,b.cumulativeWidth=b.xadvance+b.kerning+p,r+=b.cumulativeWidth,C.length-1===1&&C[C.length-2].width===0&&(b.offsetX-=b.xoffset,r-=b.xoffset)}),r+=d._margin._value.y+d._padding._value.y});const o=e._whiteSpace._inlineCollapser;let a=0,c=0,l=0;s.forEach((d,f)=>{const p=o(d);let g=0,A=0;if(d.forEach(v=>{g=Math.max(g,v.lineHeight),A=Math.max(A,v.lineBase),v.offsetX-=p}),d.lineHeight=g,d.lineBase=A,f===0?l=-(g*i-g)*.5:l-=s[f-1].lineHeight*i,d.y=l,d.x=0,d.forEach(v=>{v.offsetY=l-v.anchor,v.lineHeight<d.lineHeight&&(v.offsetY-=d.lineBase-v.lineBase)}),c+=d.lineHeight*i,d.width=0,d[0]){const v=d[d.length-1];d.width=v.offsetX+v.cumulativeWidth+v.paddingRight+v.marginRight+d[0].offsetX,a=Math.max(a,d.width)}}),s.height=c,s.width=a,this._value=s,t===1/0&&e._bounds.setChildrenWidth(e,s.width),e._height._auto&&e._bounds.setChildrenHeight(e,s.height);const u=e._parent._value;u&&(u._autoSize._needsProcess=!0,u._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}}class cte extends kT{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){lte(e),e._renderer._needsRender=!0}}function lte(n){const e=n._layouter._value,t=n._textAlign._value,i=n._bounds._innerWidth;for(let s=0;s<e.length;s++){const r=e[s],o=hte(n,r,s===e.length-1),a=n._padding._value,c=n._borderWidth._value,l=(-a.w+a.y)/2+(-c.w+c.y)/2;r.x+=o;for(let u=0;u<r.length;u++)r[u].offsetX+=o-l}if(t.indexOf("justify")===0)for(let s=0;s<e.length;s++){const r=e[s];if(t.indexOf("-")!==-1&&s===e.length-1)return;const o=i-r.width;if(o<=0)return;let a=0;for(let d=1;d<r.length-1;d++)a+=r[d].char===" "?1:0;const c=o/a;let l=1;t==="justify-right"&&(r.reverse(),l=-1);let u=0;for(let d=1;d<=r.length-1;d++){const f=r[d];f.offsetX+=u*l,u+=f.char===" "?c:0}t==="justify-right"&&r.reverse()}}function hte(n,e,t){switch(n._textAlign._value){case"justify-left":case"justify":case"left":return-n._bounds._innerWidth/2;case"justify-right":case"right":return-e.width+n._bounds._innerWidth/2;case"center":return-e.width/2;case"justify-center":return t?-e.width/2:-n._bounds._innerWidth/2;default:console.warn(`textAlign: '${n._textAlign._value}' is not valid`)}}class ute extends LT{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class dte extends I3{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class fte extends fx{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class pte extends pz{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class gte extends Ai{constructor(){super("children",null,!1);h(this,"_sortOrder",(t,i)=>t._order._value<i._order._value?-1:t._order._value>i._order._value?1:this._uis.indexOf(t)<this._uis.indexOf(i)?-1:1);this._uis=[],this._inlines=[],this._boxes=[]}update(t,i){this._compute(t),this._needsProcess=!0}process(t){this._compute(t),t._overflow._needsRender=!0}_compute(t){this._uis=t.children.filter(i=>i.visible&&i.isUI),this._inlines=this._uis.filter(i=>i.isInline).sort(this._sortOrder)}dispose(){this._inlines=null}}class mte extends Ai{constructor(){super("autosize")}process(e){if(e._layouter._value&&e._layouter._value.length){const t=e._layouter._value,i=e._padding._value,s=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+i.w+i.y+s.w+s.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+i.x+i.z+s.x+s.z)}}}class Ate extends mz{constructor(){super("renderer"),this._needsUpdate=!1}render(e){super.render(e);for(const t of e._children._inlines)t._renderer.render(t);e.performAfterUpdate()}}class Km extends qm{constructor(e={},t={}){Km.definePropertiesValues(t,e),super(t,e),Km.init(this)}add(e){const t=[];let i=!1;for(let s=0;s<arguments.length;s++){const r=arguments[s];!r.isUI||r.isInline?(r.isInline&&(i=!0),t.push(r)):console.warn("Block element can only contain Box elements.",r)}return t.length>0&&super.add(...t),i&&(this._children._needsUpdate=!0,this._layouter._needsProcess=!0),this}set textContent(e){this._textContent.value=e}get textContent(){return super.textContent}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}get lines(){return this._layouter._value}static definePropertiesValues(e,t){e.flexDirection=ute,e.justifyContent=FT,e.alignItems=OT,e.bounds=pte,e.autoSize=mte,e.renderer=Ate,e.children||(e.children=gte),e.textContent||(e.textContent=rte),e.layouter||(e.layouter=ate),e.lineHeight||(e.lineHeight=dte),e.textAlign||(e.textAlign=cte),e.whiteSpace||(e.whiteSpace=oI),e.fontKerning||(e.fontKerning=fte),e.segments||(e.segments=Tz),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class vte extends Ai{constructor(){super("inlines",null,!1),this._value=[]}process(e){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}}class yte extends Ai{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new gz(e)),e._backgroundMesh.position.x=e._inlines._value[0].offsetX+e._inlines._value[0].width/2,e._backgroundMesh.position.y=e._inlines._value[0].offsetY+e._inlines._value[0].lineBase/2,e._bounds.render(e)}}class bte extends Ai{constructor(){super("bounds",null,!1),this._size=new He.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0}update(e,t){this.output(t),this._needsProcess=!0}process(e){this._offsetWidth=this._innerWidth=e._inlines._value[0].width,this._offsetHeight=this._innerHeight=e._inlines._value[0].height,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight}output(e){e.size=this._size}}class Jm extends GA{constructor(e={}){const t={};Jm.definePropertiesValues(t,e),super(t,e),Jm.init(this)}clear(){for(const e of this._inlines._value)e.clear();return super.clear()}bindBackgroundMeshProperties(){this._backgroundMesh.raycast=()=>{},this._bounds._size=this._backgroundMesh.scale,this._bounds._needsUpdate=!0}unbindBackgroundMeshProperties(){this._bounds._size=new He.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){const t=[];for(let i=0;i<arguments.length;i++){const s=arguments[i];s.isUI?console.warn("ThreeMeshUI::InlineBlockElement cannot contains UI Elements.",s):(t.push(s),s.position.z=.005)}return super.add(...t)}static definePropertiesValues(e,t){e.children||(e.children=Iz),e.bounds||(e.bounds=bte),e.inlines||(e.inlines=vte),e.layouter||(e.layouter=vz),e.renderer||(e.renderer=yte),e.fontFamily||(e.fontFamily=_z),e.fontWeight||(e.fontWeight=bz),e.fontStyle||(e.fontStyle=yz),e.fontSize||(e.fontSize=Mz),e.backgroundColor||(e.backgroundColor=m3),e.lineBreak||(e.lineBreak=Az),e.letterSpacing||(e.letterSpacing=Ez),e.whiteSpace||(e.whiteSpace=oI),e.fontKerning||(e.fontKerning=fx),t.backgroundSize||(t.backgroundSize="cover"),t.width||(t.width="100%"),t.height||(t.height="100%"),t.boxSizing||(t.boxSizing="border-box")}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0},isInlineBlock:{configurable:!1,enumerable:!0,value:!0}}),e._inlines._value=[new _te(e)],e.backgroundMaterial=new fz,e._renderer.render(e)}}class _te extends S3{constructor(e){super(),this._uiElement=e}get xadvance(){const e=this._uiElement._padding._value,t=this._uiElement._width;return t._relative?t._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.w+e.y+t.value}get width(){const e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}}class Rz{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw new Error(`Behavior::act() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}detach(){console.error(`Behavior::detach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}clear(){}}const Pz=()=>Cb.update(),Bz={BaseProperty:Ai,Block:Ym,Text:Km,Inline:qf,InlineBlock:Jm,MeshUIBaseElement:GA,FontLibrary:Pu,update:Pz,MSDFFontMaterialUtils:Co,ShaderChunkUI:dz,Behavior:Rz,FontVariant:FA};typeof global<"u"&&(global.ThreeMeshUI=Bz);const xte=Bz;var wte=Rn.w8,Dz=Rn.cg,aI=Rn.gO,Ste=Rn.wb,hM=Rn.zV,Cte=Rn.HS,Ete=Rn.Ec,P0=Rn.gF,Mte=Rn.ol,Tte=Rn.pz,Ite=Rn.tx,Rte=Rn.hj,Pte=Rn.FV,Bte=Rn.sV,Oz=Rn.xv,Dte=Rn.mx,Ote=Rn.gE,kte=Rn.ZP,kz=Rn.Vx;const GS=Object.freeze(Object.defineProperty({__proto__:null,BaseProperty:wte,Behavior:Dz,Block:aI,DefaultValues:Ste,FontLibrary:hM,FontVariant:Cte,InheritableProperty:Ete,Inline:P0,InlineBlock:Mte,InlineGlyph:Tte,MSDFFontMaterialUtils:Ite,MaterialTransformers:Rte,MeshUIBaseElement:Pte,ShaderChunkUI:Bte,Text:Oz,TypographicFont:Dte,TypographicGlyph:Ote,default:kte,update:kz},Symbol.toStringTag,{value:"Module"})),Lte=re("debugshadowcomponents");aI.prototype.interactable={get(){return this.interactive},set(n){this.interactable=n}};const Ba=Symbol("shadowDomOwner");class aa extends Ie{constructor(){super(...arguments);h(this,"shadowComponent",null);h(this,"_controlsChildLayout",!0);h(this,"_root");h(this,"_parentComponent")}isRoot(){var t;return((t=this.Root)==null?void 0:t.gameObject)===this.gameObject}get canvas(){const t=this.Root;return t!=null&&t.isCanvas?t:null}markDirty(){$s.markUIDirty(this.context)}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(t){this._controlsChildLayout=t,this.shadowComponent&&(this.shadowComponent.autoLayout=t)}get Root(){return this._root===void 0&&(this._root=ne.getComponentInParent(this.gameObject,HA)),this._root}get Canvas(){return this.canvas}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0}onEnable(){super.onEnable()}addShadowComponent(t,i){var o;this.removeShadowComponent();const s=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=ne.getComponentInParent(s,aa),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`,this);return}t.name=this.name+" ("+(this.constructor.name??"UI")+")",t.autoLayout=this._parentComponent.controlsChildLayout,t[Ba]=this,this.setShadowComponentOwner(t);let r=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(t);else{const a=this._parentComponent.shadowComponent;a&&(a==null||a.add(t),r=!0)}this.shadowComponent=t,i&&i.shadowComponent&&this.shadowComponent&&i.shadowComponent.add(this.shadowComponent),IA&&t.add(new tp(.5)),this.onAfterAddedToScene(),r&&kz(),Lte&&console.log(this.shadowComponent)}set(t){}setShadowComponentOwner(t){if(t&&(t[Ba]===void 0||t[Ba]===this)&&(t[Ba]=this,t.children))for(const i of t.children)this.setShadowComponentOwner(i)}traverseOwnedShadowComponents(t,i,s){if(t&&t[Ba]===i){s(t);for(const r of t.children)this.traverseOwnedShadowComponents(r,i,s)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(t){this.shadowComponent&&(this.shadowComponent.interactable=t)}}class HA extends aa{awake(){super.awake()}}class Yf{static getObject(e){const t=e[Ba];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const s=Ru(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(s==null?void 0:s.isGraphic)===!0&&(t.graphic=s),!((s==null?void 0:s.raycastTarget)===!1||(s==null?void 0:s.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=Ru(e,i=>{const s=i;if(s.blocksRaycasts!==void 0&&s.interactable!==void 0)return s},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}const Pg=re("debugwebxrcontroller");var Ef=(n=>(n[n.PhysicalDevice=0]="PhysicalDevice",n[n.Touch=1]="Touch",n))(Ef||{}),Cc=(n=>(n.SelectStart="select-start",n.SelectEnd="select-end",n.Update="update",n))(Cc||{});class vx extends Ie{}const Xn=class extends Ie{constructor(){super(...arguments);h(this,"webXR");h(this,"index",-1);h(this,"controllerModel");h(this,"controller");h(this,"controllerGrip");h(this,"hand");h(this,"handPointerModel");h(this,"grabbed",null);h(this,"input",null);h(this,"type",0);h(this,"showRaycastLine",!0);h(this,"_wristQuaternion",null);h(this,"movementVector",new w);h(this,"worldRot",new we);h(this,"joystick",new te);h(this,"didRotate",!1);h(this,"didTeleport",!1);h(this,"didChangeScale",!1);h(this,"lastHit",null);h(this,"raycastLine",null);h(this,"_raycastHitPoint",null);h(this,"_connnectedCallback",null);h(this,"_disconnectedCallback",null);h(this,"_selectStartEvt",null);h(this,"_selectEndEvt",null);h(this,"_selectionPressed",!1);h(this,"_selectionPressedLastFrame",!1);h(this,"_selectionStartTime",0);h(this,"_selectionEndTime",0);h(this,"_useSmoothing",!0);h(this,"_isConnected",!1);h(this,"rayRotation",new we);h(this,"_pinchStartTime");h(this,"selectStartCallback",null);h(this,"lastSelectStartObject",null);h(this,"_didNotEndSelection",!1);h(this,"closeGrabBoundingBoxHelper")}static CreateRaycastLine(){const t=new dn(this.geometry),i=t.material;return i.color=this.raycastColor,t.layers.set(2),t.name="line",t.scale.z=1,t}static CreateRaycastHitPoint(){const t=new Lo(.5,22,22),i=new ui({color:this.raycastColor}),s=new ye(t,i);return s.visible=!1,s.layers.set(2),s}static Create(t,i,s,r){const o=s?ne.addNewComponent(s,Xn,!1):new Xn;o.webXR=t,o.index=i,o.type=r;const a=t.context;o.controller=a.renderer.xr.getController(i),o.controllerGrip=a.renderer.xr.getControllerGrip(i),o.controllerModel=this.Factory.createControllerModel(o.controller),o.controllerGrip.add(o.controllerModel),o.hand=a.renderer.xr.getHand(i);const c=new cp;DA(c,a),o.webXR.handModelPath&&o.webXR.handModelPath!==""?c.setPath(al(t.sourceId,o.webXR.handModelPath)):c.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/");const l=new iJ(o.hand,c);return o.hand.add(l),o.hand.traverse(u=>u.layers.set(2)),o.handPointerModel=new lJ(o.hand,o.controller),o.controller.addEventListener("connected",u=>{o.setControllerLayers(o.controllerModel,2),o.setControllerLayers(o.controllerGrip,2),o.setControllerLayers(o.hand,2),setTimeout(()=>{o.setControllerLayers(o.controllerModel,2),o.setControllerLayers(o.controllerGrip,2),o.setControllerLayers(o.hand,2)},1e3)}),o.hand.addEventListener("connected",u=>{var f;if(u.data.hand){t.Rig&&t.Rig.add(o.hand),o.type=0,o.handPointerModel.traverse(g=>g.layers.set(2)),(f=o.handPointerModel.pointerObject)==null||f.traverse(g=>g.layers.set(2));const p=o.hand.joints;if(p)for(const g of Object.keys(p)){const A=p[g];A.parent||o.hand.add(A)}}}),o}static addEventListener(t,i){const s=this.eventSubs[t]??[];s.push(i),this.eventSubs[t]=s}static removeEventListener(t,i){if(!i)return;const s=this.eventSubs[t]??[],r=s.indexOf(i);r>=0&&s.splice(r,1),this.eventSubs[t]=s}get isUsingHands(){var i;const t=(i=this.input)==null?void 0:i.hand;return t!=null}get wrist(){if(!this.hand)return null;const t=this.hand.joints;return t?t.wrist:null}getWristQuaternion(){const t=this.wrist;return t?(this._wristQuaternion||(this._wristQuaternion=new we),zn(t).multiply(this._wristQuaternion.setFromEuler(new mn(-Math.PI/4,0,0)))):null}get selectionDown(){return this._selectionPressed&&!this._selectionPressedLastFrame}get selectionUp(){return!this._selectionPressed&&this._selectionPressedLastFrame}get selectionPressed(){return this._selectionPressed}get selectionClick(){return this._selectionEndTime-this._selectionStartTime<.3}get raycastHitPoint(){return this._raycastHitPoint}get useSmoothing(){return this._useSmoothing}awake(){if(!this.controller){console.warn("WebXRController: Missing controller object.",this);return}this._connnectedCallback=this.onSourceConnected.bind(this),this._disconnectedCallback=this.onSourceDisconnected.bind(this),this._selectStartEvt=this.onSelectStart.bind(this),this._selectEndEvt=this.onSelectEnd.bind(this),this.type===1&&(this.controllerGrip.addEventListener("connected",this._connnectedCallback),this.controllerGrip.addEventListener("disconnected",this._disconnectedCallback),this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt))}onDestroy(){var t,i,s;this.type===1&&(this.controllerGrip.removeEventListener("connected",this._connnectedCallback),this.controllerGrip.removeEventListener("disconnected",this._disconnectedCallback),this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),(t=this.hand)==null||t.clear(),(i=this.controllerGrip)==null||i.clear(),(s=this.controller)==null||s.clear()}onEnable(){var t,i,s,r,o;if(!this.webXR){console.warn("No WebXR component assigned to WebXRController.");return}this.hand&&(this.hand.name="Hand"),this.controllerGrip&&(this.controllerGrip.name="ControllerGrip"),this.controller&&(this.controller.name="Controller"),this.raycastLine&&(this.raycastLine.name="RaycastLine;"),this.webXR.Controllers.indexOf(this)<0&&this.webXR.Controllers.push(this),this.raycastLine||(this.raycastLine=Xn.CreateRaycastLine()),this._raycastHitPoint||(this._raycastHitPoint=Xn.CreateRaycastHitPoint()),(t=this.webXR.Rig)==null||t.add(this.hand),(i=this.webXR.Rig)==null||i.add(this.controllerGrip),(s=this.webXR.Rig)==null||s.add(this.controller),(r=this.webXR.Rig)==null||r.add(this.raycastLine),(o=this.raycastLine)==null||o.add(this._raycastHitPoint),this._raycastHitPoint.visible=!1,this.hand.add(this.handPointerModel),Pg&&console.log("ADDED TO RIG",this.webXR.Rig)}onDisable(){var t,i,s,r,o;if((t=this.hand)==null||t.removeFromParent(),(i=this.controllerGrip)==null||i.removeFromParent(),(s=this.controller)==null||s.removeFromParent(),(r=this.raycastLine)==null||r.removeFromParent(),(o=this._raycastHitPoint)==null||o.removeFromParent(),this.webXR){const a=this.webXR.Controllers.indexOf(this);a>=0&&this.webXR.Controllers.splice(a,1)}}onSourceConnected(t){if(this._isConnected){console.warn("Received connected event for controller that is already connected",this.index,t);return}this._isConnected=!0,this.input=t.data,this.type===1&&this.onSelectStart()}onSourceDisconnected(t){if(!this._isConnected){console.warn("Received discnnected event for controller that is not connected",t);return}this._isConnected=!1,this.type===1&&this.onSelectEnd(),this.input=null}createPointerEvent(t){switch(t){case"down":this.context.input.createPointerDown(new wc(Sn.PointerDown,null,{clientX:0,clientY:0,button:this.index,pointerType:zf.Touch}));break;case"move":break;case"up":this.context.input.createPointerUp(new wc(Sn.PointerUp,null,{clientX:0,clientY:0,button:this.index,pointerType:zf.Touch}));break}}raycastUpdate(t,i){const s=this.showRaycastLine&&this.type!==1;if(this.type===1)t.visible=!1;else if(this.isUsingHands){t.visible=!this.grabbed&&s,Mn(t,i);const r=this.hand.joints;if(r&&r.wrist&&this.grabbed&&this.grabbed.isCloseGrab){const a=this.getWristQuaternion();a&&this.rayRotation.copy(a)}Mr(t,this.rayRotation)}else t.visible=s,Mr(t,this.rayRotation),Mn(t,i)}update(){if(!this.webXR)return;this.context.time.frameCount%60===0&&(this.setControllerLayers(this.controller,2),this.setControllerLayers(this.controllerGrip,2),this.setControllerLayers(this.hand,2));const t=Xn.eventSubs.update;if(t&&t.length>0)for(const r of t)r(this);let i=1;this.type===0?i=this.context.time.deltaTime/.1:this.isUsingHands&&this.handPointerModel.pinched&&(i=this.context.time.deltaTime/.3),this.rayRotation.slerp(zn(this.controller),this.useSmoothing?i:1);const s=Ct(this.controller);this.isUsingHands&&this.handPointerModel.cursorObject&&(this.handPointerModel.cursorObject.visible=!1),this.raycastLine&&this.raycastUpdate(this.raycastLine,s),this.lastHit=this.updateLastHit(),this.grabbed&&this.grabbed.update(),this._selectionPressedLastFrame=this._selectionPressed,this.selectStartCallback&&this.selectStartCallback()}onUpdate(t){var r,o;if(this.lastHit=null,!t||t.inputSources.length<=this.index){this.input=null;return}if(this.type===0&&(this.input=t.inputSources[this.index]),!this.input)return;const i=this.webXR.Rig;if(!i)return;this._didNotEndSelection&&!this.handPointerModel.pinched&&(this._didNotEndSelection=!1,this.onSelectEnd()),this.updateStick(this.input);const s=(o=(r=this.input)==null?void 0:r.gamepad)==null?void 0:o.buttons;switch(this.input.handedness){case"left":this.movementUpdate(i,s);break;case"right":this.rotationUpdate(i,s);break}}movementUpdate(t,i){const s=3*Xn.MovementSpeedFactor,r=2,o=tt.clamp01(this.joystick.length()*2),a=this.joystick.x>0?1:-1;let c=Math.pow(this.joystick.x,r);c*=a,c*=o;const l=this.joystick.y>0?1:-1;let u=Math.pow(this.joystick.y,r);u*=l,c*=o,t.getWorldQuaternion(this.worldRot),this.movementVector.set(c,0,u),this.movementVector.applyQuaternion(this.webXR.TransformOrientation),this.movementVector.y=0,this.movementVector.applyQuaternion(this.worldRot),this.movementVector.multiplyScalar(s*this.context.time.deltaTime),t.position.add(this.movementVector),this.isUsingHands&&this.runTeleport(t,i)}rotationUpdate(t,i){const s=this.joystick.x,r=Math.abs(s);if(r<.4)this.didRotate=!1;else if(r>.5&&!this.didRotate){const o=s>0?-1:1;t.rotateY(tt.toRadians(30*o)),this.didRotate=!0}this.runTeleport(t,i)}runTeleport(t,i){var u,d;let s=-this.joystick.y;if((u=this.hand)!=null&&u.visible&&!this.grabbed){const f=this.handPointerModel.isPinched();f&&this._pinchStartTime===void 0&&(this._pinchStartTime=this.context.time.time),f&&this._pinchStartTime&&this.context.time.time-this._pinchStartTime>.8&&(s=this.handPointerModel.isPinched()?1:0),f||(this._pinchStartTime=void 0)}else this._pinchStartTime=void 0;const r=this.webXR.IsInVR,o=this.webXR.Rig;let a=s>.5&&r,c=o?((d=o==null?void 0:o.scale)==null?void 0:d.x)<.999:!1,l=null;if(i&&this.input&&!this.input.hand)for(let f=0;f<i.length;f++){const p=i[f];if(f===4)if(p.pressed&&!this.didChangeScale&&r){this.didChangeScale=!0;const g=o;if(g){const A=this.switchScale(g,a,c,l);a=A.doTeleport,c=A.isInMiniatureMode,l=A.newRigScale}}else p.pressed||(this.didChangeScale=!1)}if(a){if(!this.didTeleport){const f=this.raycast();if(this.didTeleport=!0,f&&f.length>0){const p=f[0];if(c||this.isValidTeleportTarget(p.object)){const g=p.point;Mn(t,g)}}}}else s<.1&&(this.didTeleport=!1);l!==null&&(t.scale.set(l,l,l),t.updateMatrixWorld())}isValidTeleportTarget(t){return ne.getComponentInParent(t,vx)!=null}switchScale(t,i,s,r){if(s){s=!1,t.scale.set(1,1,1),r=1,Xn.MovementSpeedFactor=1;const o=this.context.mainCamera;Xn.PreviousCameraFarDistance&&(o.far=Xn.PreviousCameraFarDistance)}else{s=!0,i=!0,r=.1,Xn.MovementSpeedFactor=r*2;const o=this.context.mainCamera;Xn.PreviousCameraFarDistance=o.far,o.far/=r}return{doTeleport:i,isInMiniatureMode:s,newRigScale:r}}updateStick(t){var i;!t||!t.gamepad||((i=t.gamepad.axes)==null?void 0:i.length)<4||(this.joystick.x=t.gamepad.axes[2],this.joystick.y=t.gamepad.axes[3])}updateLastHit(){var r;const t=this.raycast(),i=t?t[0]:null;this.lastHit=i;let s=1;if(this.webXR.Rig&&(s/=this.webXR.Rig.scale.x),this.raycastLine){this.raycastLine.scale.z=s*(((r=this.lastHit)==null?void 0:r.distance)??9999);const o=this.raycastLine.material;i!=null?o.color=Xn.raycastColor:o.color=Xn.raycastNoHitColor}if(this._raycastHitPoint){if(this.lastHit!=null){this._raycastHitPoint.position.z=-1;const o=tt.clamp(this.lastHit.distance*.01*s,.015,.1);this._raycastHitPoint.scale.set(o,o,o)}this._raycastHitPoint.visible=this.lastHit!==null&&this.lastHit!==void 0}return i}onSelectStart(){this.context.connection.allowEditing&&(this.selectStartCallback=()=>this.onHandleSelectStart())}onHandleSelectStart(){this.selectStartCallback=null,this._selectionPressed=!0,this._selectionStartTime=this.context.time.time,this._selectionEndTime=1e3;let t=null,i=!1;if(this.isUsingHands?(t=this.overlap(),t.length<=0?(t=this.raycast(),i=!1):i=!0):t=this.raycast(),Pg&&console.log("onHandleSelectStart","close grab? "+i,"intersections",t),t&&t.length>0)for(const s of t){const r=s.object;this.lastSelectStartObject=r;const o={selected:r,grab:r},a=Xn.eventSubs["select-start"];if(a&&a.length>0)for(const c of a)c(this,o);o.grab!==r&&Pg&&console.log("Grabbed object changed","original",r,"new",o.grab),o.grab&&(this.grabbed=Io.TryTake(this,o.grab,s,i));break}else{const s=Xn.eventSubs["select-start"],r={selected:null,grab:null};if(s&&s.length>0)for(const o of s)o(this,r)}}onSelectEnd(){var s;if(this.isUsingHands&&this.handPointerModel.pinched){this._didNotEndSelection=!0;return}if(!this._selectionPressed)return;this.selectStartCallback=null,this._selectionPressed=!1,this._selectionEndTime=this.context.time.time;const t={grab:((s=this.grabbed)==null?void 0:s.selected)??this.lastSelectStartObject},i=Xn.eventSubs["select-end"];if(i&&i.length>0)for(const r of i)r(this,t);this.grabbed&&(this.grabbed.free(),this.grabbed=null)}testIsVisible(t){return!(!t||ne.isActiveInHierarchy(t)===!1||Yf.isInteractable(t)===!1)}setControllerLayers(t,i){var s,r;if(t&&(t.layers.set(i),t.children))for(const o of t.children)((s=this.grabbed)==null?void 0:s.selected)===o||((r=this.grabbed)==null?void 0:r.selectedMesh)===o||this.setControllerLayers(o,i)}getRay(){const t=new Ya;return t.origin.copy(Ct(this.controller)),t.direction.set(0,0,-1).applyQuaternion(this.rayRotation),t}overlap(){const t=this.isUsingHands&&this.handPointerModel?this.handPointerModel.pointerObject:this.controllerGrip;if(Pg&&(!this.closeGrabBoundingBoxHelper&&t&&(this.closeGrabBoundingBoxHelper=new P_(t,16776960),this.scene.add(this.closeGrabBoundingBoxHelper)),this.closeGrabBoundingBoxHelper&&t&&this.closeGrabBoundingBoxHelper.setFromObject(t)),!t)return new Array;const i=Ct(t).clone();return this.context.physics.sphereOverlap(i,.02)}raycast(){const t=new ko;t.layerMask=new Ps,t.layerMask.enableAll(),t.layerMask.disable(2),t.ray=this.getRay();const i=this.context.physics.raycast(t);for(let s=0;s<i.length;s++){const r=i[s],o=r.object;if(!this.testIsVisible(o)){i.splice(s,1),s--;continue}r.object=Yf.getObject(o);break}return i}};let sn=Xn;h(sn,"Factory",new _J),h(sn,"raycastColor",new _e(.9,.3,.3)),h(sn,"raycastNoHitColor",new _e(.6,.6,.6)),h(sn,"geometry",new mt().setFromPoints([new w(0,0,0),new w(0,0,-1)])),h(sn,"handModels",{}),h(sn,"eventSubs",{}),h(sn,"PreviousCameraFarDistance"),h(sn,"MovementSpeedFactor",1);var Mb=(n=>(n.WillTake="WillTake",n.DidTake="DidTake",n.WillFree="WillFree",n.DidFree="DidFree",n))(Mb||{});const Xs=class{constructor(){h(this,"sync",null);h(this,"selected",null);h(this,"selectedParent",null);h(this,"selectedMesh",null);h(this,"controller",null);h(this,"grabTime",0);h(this,"grabUUID","");h(this,"isCloseGrab",!1);h(this,"originalMaterial",null);h(this,"usageMarker",null);h(this,"rigidbodies",null);h(this,"didReparent",!1);h(this,"grabDistance",0);h(this,"interactable",null);h(this,"positionSource",null);h(this,"grabPoint",new w);h(this,"localPositionOffsetToGrab",null);h(this,"localPositionOffsetToGrab_worldSpace",new w);h(this,"localQuaternionToGrab",new we(0,0,0,1));h(this,"targetDir",null);h(this,"quaternionLerp",null);h(this,"controllerDir",new w);h(this,"controllerWorldPos",new w);h(this,"lastControllerWorldPos",new w);h(this,"controllerPosDelta",new w);h(this,"totalChangeAlongDirection",0);h(this,"rigPositionLastFrame",new w)}static AddEventListener(e,t){return Xs.Events[e]||(Xs.Events[e]=[]),Xs.Events[e].push(t),t}static RemoveEventListener(e,t){if(!t||!Xs.Events[e])return;const i=Xs.Events[e].indexOf(t);i>=0&&Xs.Events[e].splice(i,1)}static Register(e){this.Current.find(t=>t===e)||this.Current.push(e)}static Remove(e){const t=this.Current.indexOf(e);t>=0&&this.Current.splice(t,1)}static TryTake(e,t,i,s){const r=ne.getComponentInParent(t,up);if(r)t=r.gameObject;else return Pg&&console.warn("Prevented taking object that is not interactable",t),null;let o=t;const a=ne.getComponentInParent(t,ah);a&&(a.requestOwnership(),o=a.gameObject);for(const l of this.Current)if(l.selected===o)return l.controller===e||(l.free(),l.Take(e,o,t,a,r,i,s)),l;const c=new Xs;return c.Take(e,o,t,a,r,i,s),c}Take(e,t,i,s,r,o,a){var p,g;if(console.assert(t!==null,"Expected object to be taken but was",t),e.isUsingHands?this.positionSource=a?e.wrist:e.controller:this.positionSource=e.controller,!this.positionSource)return console.warn("No position source"),this;const c={controller:e,take:t,hit:i,sync:s,interactable:r};(p=Xs.Events.WillTake)==null||p.forEach(A=>A(this,c));const l=i;l!=null&&l.material&&(this.originalMaterial=l.material,Array.isArray(l.material)||(l.material=l.material.clone(),l.material&&l.material.emissive&&(l.material.emissive.b=.2))),this.selected=t,this.selectedParent||(this.selectedParent=t.parent),this.selectedMesh=l,this.controller=e,this.interactable=r,this.isCloseGrab=a,this.didReparent=!1,this.sync=s,this.grabTime=e.context.time.time,this.grabUUID=Date.now().toString(),this.usageMarker=ne.addNewComponent(this.selected,dp),this.rigidbodies=ne.getComponentsInChildren(this.selected,Ii),Ct(this.positionSource,this.lastControllerWorldPos);const u=()=>a?this.lastControllerWorldPos.clone():o.point.clone();this.grabDistance=u().distanceTo(this.lastControllerWorldPos),this.totalChangeAlongDirection=0,this.localPositionOffsetToGrab=this.selected.worldToLocal(u());const d=e.isUsingHands&&a?this.controller.getWristQuaternion().clone():e.rayRotation.clone();zn(this.selected,this.localQuaternionToGrab).premultiply(d.invert());const f=this.controller.webXR.Rig;return f&&this.rigPositionLastFrame.copy(Ct(f)),ir.Add(e.context,this.selected),Xs.Register(this),this.sync&&(this.sync.fastMode=!0),(g=Xs.Events.DidTake)==null||g.forEach(A=>A(this,c)),this}free(){var s,r,o,a;if(!this.selected)return;const e={controller:this.controller,take:this.selected,hit:this.selected,sync:this.sync,interactable:null};(s=Xs.Events.WillFree)==null||s.forEach(c=>c(this,e)),ir.Remove(this.controller.context,this.selected),Xs.Remove(this),this.sync&&(this.sync.fastMode=!1);const t=this.selectedMesh;t&&this.originalMaterial&&t.material&&(t.material=this.originalMaterial);const i=this.selected;if(this.didReparent&&i.parent){const c=this.selectedParent;c?c.attach(i):(r=this.controller)==null||r.context.scene.attach(i)}if((o=this.usageMarker)==null||o.destroy(),this.controller&&(this.controller.grabbed=null),this.selected=null,this.selectedParent=null,this.selectedMesh=null,this.sync=null,this.rigidbodies)for(const c of this.rigidbodies)c.wakeUp(),c.setVelocity(c.smoothedVelocity);this.rigidbodies=null,this.localPositionOffsetToGrab=null,this.quaternionLerp=null,(a=Xs.Events.DidFree)==null||a.forEach(c=>c(this,e))}controllerMovementSinceLastFrame(){if(!this.positionSource||!this.controller)return 0;this.controllerDir.set(0,0,-1),this.controllerDir.applyQuaternion(this.controller.rayRotation),Ct(this.positionSource,this.controllerWorldPos),this.controllerPosDelta.copy(this.controllerWorldPos),this.controllerPosDelta.sub(this.lastControllerWorldPos),this.lastControllerWorldPos.copy(this.controllerWorldPos);const e=this.controller.webXR.Rig;if(e){const i=Ct(e),s=this.rigPositionLastFrame.sub(i);this.controllerPosDelta.add(s),this.rigPositionLastFrame.copy(i)}return this.controllerDir.dot(this.controllerPosDelta)}update(){var e;if(this.rigidbodies)for(const t of this.rigidbodies)t.resetVelocities();if(this.sync&&this.controller&&this.controller.context.connection.isInRoom&&this.controller.context.time.time-this.grabTime>3&&this.sync.hasOwnership()===!1&&(console.log("no ownership, will leave",this.sync.guid),this.free()),!(this.interactable&&!this.interactable.canGrab)){if(!this.didReparent&&this.selected&&this.controller){const t=((e=this.controller.webXR.Rig)==null?void 0:e.scale.x)??1;this.totalChangeAlongDirection+=this.controllerMovementSinceLastFrame();let i=1;this.controller.type===0&&(i=Math.max(0,1+this.totalChangeAlongDirection*2/t),i=i*i*i),this.grabDistance/t<.8&&(i=1),this.targetDir||(this.targetDir=new w),this.targetDir.set(0,0,-this.grabDistance*i);const s=this.targetDir.applyQuaternion(this.controller.rayRotation).add(this.controllerWorldPos),r=this.controller.rayRotation.clone().multiplyQuaternions(this.controller.rayRotation,this.localQuaternionToGrab);this.quaternionLerp||(this.quaternionLerp=r.clone()),this.quaternionLerp.slerp(r,this.controller.useSmoothing?this.controller.context.time.deltaTime/.03:1),Mr(this.selected,this.quaternionLerp),this.selected.updateWorldMatrix(!1,!1),this.grabPoint.copy(s),this.localPositionOffsetToGrab&&(this.localPositionOffsetToGrab_worldSpace.copy(this.localPositionOffsetToGrab),this.selected.localToWorld(this.localPositionOffsetToGrab_worldSpace).sub(Ct(this.selected)),s.sub(this.localPositionOffsetToGrab_worldSpace)),Mn(this.selected,s)}if(this.rigidbodies!=null)for(const t of this.rigidbodies)t.wakeUp();Sr.markDirty(this.selected,!0)}}};let Io=Xs;h(Io,"Events",{}),h(Io,"Current",[]);class Gc{constructor(e,t){h(this,"used",!1);h(this,"inputSource");h(this,"object");h(this,"pointerId");h(this,"isDown");h(this,"isUp");h(this,"isPressed");h(this,"isClicked");h(this,"input");h(this,"_event");this._event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this._event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this._event)==null||e.stopImmediatePropagation()}get event(){return this._event}clone(){const e=new Gc(this.input,this._event);return Object.assign(e,this),e}}class mp extends Ie{awake(){$s.createIfNoneExists(this.context)}onEnable(){var e;(e=$s.get(this.context))==null||e.register(this)}onDisable(){var e;(e=$s.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class rl extends mp{constructor(){super(...arguments);h(this,"targets",null);h(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new ko),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class cI extends rl{}const Kd=re("debugeventsystem");var uM=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(uM||{});const Ea=class extends Ie{constructor(){super();h(this,"raycaster",[]);h(this,"_selectStartFn");h(this,"_selectEndFn");h(this,"_selectUpdateFn");h(this,"_handleEventCycleFn");h(this,"_handleInputFn");h(this,"pressedByID",new Map);h(this,"hoveredByID",new Map);h(this,"_sortedHits",[]);h(this,"_sortingBuffer",[]);h(this,"_noDepthTestingResults",[]);h(this,"out",{});h(this,"currentActiveMeshUIComponents",[]);Ea.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Ea.systems.length<=0&&Ea.systems.push(...ne.findObjectsOfType(Ea,t)));for(const s of Ea.systems)if(s.context===t)return;const i=new Te;ne.addNewComponent(i,Ea),t.scene.add(i)}static get systems(){const t=Ft.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,s=!1){Ec.update(t,i,s)}static markUIDirty(t){Ec.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Ea.systems.splice(Ea.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ne.findObjectOfType(mp,this.context)){const i=ne.addNewComponent(this.context.scene,rl);this.raycaster.push(i),(ci()||Kd)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;Ec.resetLastSelected();const o=new Gc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEventOnObject(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var c;if(!r.grab)return;const o=new Gc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEventOnObject(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(const l of this.pressedByID.keys()){const u=this.pressedByID[l];u.obj===a&&u.handler&&((c=u.handler.onPointerUp)==null||c.call(u.handler,o),this.pressedByID.delete(l))}});const i=new ko;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new Gc(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),sn.addEventListener(Cc.SelectStart,this._selectStartFn),sn.addEventListener(Cc.SelectEnd,this._selectEndFn),sn.addEventListener(Cc.Update,this._selectUpdateFn),this._handleInputFn=this.onPointerEvent.bind(this),this.context.input.addEventListener(Sn.PointerDown,this._handleInputFn),this.context.input.addEventListener(Sn.PointerUp,this._handleInputFn),this.context.input.addEventListener(Sn.PointerMove,this._handleInputFn)}onDisable(){sn.removeEventListener(Cc.SelectStart,this._selectStartFn),sn.removeEventListener(Cc.SelectEnd,this._selectEndFn),sn.removeEventListener(Cc.Update,this._selectUpdateFn),this.context.input.removeEventListener(Sn.PointerDown,this._handleInputFn),this.context.input.removeEventListener(Sn.PointerUp,this._handleInputFn),this.context.input.removeEventListener(Sn.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0)return;const i=t.pointerType==zf.Touch?t.button:0,s=new Gc(this.context.input,t);s.inputSource=this.context.input,s.pointerId=i,s.isClicked=this.context.input.getPointerClicked(i),s.isDown=t.type==Sn.PointerDown,s.isUp=t.type==Sn.PointerUp,s.isPressed=this.context.input.getPointerPressed(i),Kd&&s.isClicked&&console.log("CLICK",i);const r=new ko;r.screenPoint=this.context.input.getPointerPositionRC(i);const o=this.performRaycast(r);if(!o)return;Kd&&s.isClicked&&pn("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown);const a={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};if(this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),!this.handleIntersections(o,s)){const c=this.hoveredByID.get(i);if(c&&this.triggerOnExit(c.obj,c.data),this.hoveredByID.delete(i),s.isUp){const l=this.pressedByID.get(i);l==null||l.handlers.forEach(u=>{var d;return(d=u.onPointerUp)==null?void 0:d.call(u,s)}),this.pressedByID.delete(i)}}this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEventOnObject(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClicked&&Kd&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return!1;i.object=t;const s=t.parent;let r=!1;const o=i.isClicked??!1;let a=null;if(s&&s.isUI){const u=(i.isPressed||i.isClicked)??!1;if(s[Ba]){const d=s[Ba].gameObject;if(d){if(!Yf.isInteractable(d,this.out))return!1;a=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,u),t=d,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,u))return!0}o&&Kd&&console.log(this.context.time.frame,t);const c=this.hoveredByID.get(i.pointerId),l=(c==null?void 0:c.obj)!==t;if(l&&(c!=null&&c.obj)&&this.triggerOnExit(c.obj,c.data),this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const u=this.pressedByID.get(i.pointerId);u?(u.obj=t,u.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(a===null||a.interactable)&&this.handleMainInteraction(t,i,l),!0}propagate(t,i,s){for(;ne.foreachComponent(t,r=>{s(r)},!1),!!t.parent;)t=t.parent}handleMainInteraction(t,i,s){if(i.pointerId===void 0)return;const r=this.pressedByID.get(i.pointerId);this.propagate(t,i,o=>{var d;const a=o;if(a.interactable===!1)return;a.onPointerEnter&&s&&a.onPointerEnter(i),i.isDown&&a.onPointerDown&&(a.onPointerDown(i),r==null||r.handlers.add(a));const c=this.context.input.getPointerPositionLastFrame(i.pointerId),l=this.context.input.getPointerPosition(i.pointerId);c&&!tt.approximately(c,l)&&a.onPointerMove&&a.onPointerMove(i),i.isUp&&(a.onPointerUp&&(a.onPointerUp(i),r==null||r.handlers.delete(a)),a.onPointerExit&&((d=i.event)==null?void 0:d.pointerType)===zf.Touch&&(a.onPointerExit(i),this.hoveredByID.delete(i.pointerId))),i.isClicked&&a.onPointerClick&&a.onPointerClick(i)}),i.isUp&&(r==null||r.handlers.forEach(o=>{o.onPointerUp&&o.onPointerUp(i)}),this.pressedByID.delete(i.pointerId))}triggerOnExit(t,i){i.used=!1,this.propagate(t,i,s=>{if(!s.gameObject||s.destroyed)return;const r=s;r.onPointerExit&&r.onPointerExit(i)})}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=Ec.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ec.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];Ec.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?ne.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let $s=Ea;h($s,"_eventSystemMap",new Map),h($s,"didSearchEventSystem",!1);class Ec{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let o=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(o=!0),o&&(Kd&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(Ec,"lastSelected",null),h(Ec,"lastUpdateFrame",[]),h(Ec,"needsUpdate",!1);const B0=Symbol("cameraController");function Fte(n){return n[B0]}function AO(n,e,t){t?n[B0]=e:n[B0]===e&&(n[B0]=null)}function yx(n){const e=n[Ba];return e||(n.parent?yx(n.parent):null)}function Tb(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?wi:Ds,t.shadowSide=e.doubleSided?wi:Ds,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)Tb(i,e)}function Jd(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,c,l){const u=o[a],d=Reflect.set(o,a,c,l);return t(c,u),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const vO=Symbol("Scheduled action");function Ute(n,e,t=Tr.OnBeforeRender){let i=n[vO];i||(i=n[vO]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const c=n.startCoroutine(a(),t);r[s]=c}class Lz extends ye{constructor(e,t={}){const s=[e.isCubeTexture?"#define ENVMAP_TYPE_CUBE":""],r=`
|
|
5072
|
+
`&&n.length>1&&wz([t],n[n.length-2]),e.offsetX}function Jee(n){if(!n[0])return 0;let e=[],t;for(let i=0;i<n.length;i++){const s=n[i];if(s.char&&gO[s.char]&&n.length>i){e.push(s),t=n[i+1];continue}break}Sz(e,t),e=[],t=null;for(let i=n.length-1;i>0;i--){const s=n[i];if(s.char&&gO[s.char]&&i>0){e.push(s),t=n[i-1];continue}break}return wz(e,t),n[0].offsetX}function Zee(n){return n[0]?n[0].offsetX:0}function wz(n,e){if(e)for(let t=0;t<n.length;t++){const i=n[t];i.fontFactor=0,i.offsetX=e.offsetX+e.cumulativeWidth,i.cumulativeWidth=0}}function Sz(n,e){if(e)for(let t=0;t<n.length;t++){const i=n[t];i.fontFactor=0,i.offsetX=e.offsetX,i.cumulativeWidth=0}}function Cz(n,e,t,i){if(i=i||0,!n[e])return i;const s=n[e];return s.lineBreak?i+s.xadvance:Cz(n,e+1,t,i+s.xadvance+s.xoffset+s.kerning+t.LETTERSPACING)}function $ee(n,e,t,i){return!n||!n.char||e+t<i.INNER_WIDTH?!1:i.BREAKON.indexOf(n.char)>-1}class Ez extends P3{constructor(){super(),this._input="inherit",this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}}class Mz extends Wi{constructor(){super("fontSize","inherit",!0),this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._font._fontVariant&&(e._bounds._needsProcess=!0,e._layouter._needsProcess=!0)}process(e){if(!e._font._fontVariant||!e._font._fontVariant.isReady)return;const t=this._value/e._font._fontVariant.typographic.size,i=e._inlines._value;for(let s=0;s<i.length;s++){const r=i[s];r.resetOffsets(),r.fontSize=this._value,r.fontFactor=t}}get value(){return this._value}}class Tz extends B3{constructor(){super("segments",1,!1),this._notInheritedValue=void 0}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue==="inherit"&&(this._notInheritedValue=this.getInheritedInput(e)),e._layouter._needsUpdate=!0}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value==="inherit"?this._notInheritedValue:this._value}}class ete extends Tz{constructor(){super(),this._value="inherit"}}class tte extends fx{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value._layouter._needsProcess=!1}process(e){if(this._value!=="none"){const t=e._whiteSpace._whiteSpacedContent,i=e._inlines._value;for(let s=1;s<i.length;s++){const r=t[s-1]+t[s];i[s].kerning=e._font._fontVariant.getKerningAmount(r)}}}}class Iz extends Ai{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function ite(n,e=!1){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),s=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,c=new He.BufferGeometry;let l=0;for(let u=0;u<n.length;++u){const d=n[u];let f=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.attributes[p]),f++}if(f!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!s.has(p))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(d.morphAttributes[p])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(d.userData),e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(t){let u=0;const d=[];for(let f=0;f<n.length;++f){const p=n[f].index;for(let g=0;g<p.count;++g)d.push(p.getX(g)+u);u+=n[f].attributes.position.count}c.setIndex(d)}for(const u in r){const d=mO(r[u]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,d)}for(const u in o){const d=o[u][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<d;++f){const p=[];for(let A=0;A<o[u].length;++A)p.push(o[u][A][f]);const g=mO(p);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(g)}}return c}function mO(n){let e,t,i,s=0;for(let a=0;a<n.length;++a){const c=n[a];if(c.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=c.normalized),i!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=c.array.length}const r=new e(s);let o=0;for(let a=0;a<n.length;++a)r.set(n[a].array,o),o+=n[a].array.length;return new He.BufferAttribute(r,t,i)}class nte extends Ai{constructor(){super("renderer")}render(e){if(!e._inlines._value||!e._inlines._value.length)return;const t=e._inlines._value.map(s=>e._font._fontVariant.getGeometricGlyph(s,e).translate(s.offsetX,s.offsetY,0)),i=ite(t);e.setFontMesh(new He.Mesh(i,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class ste extends kT{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class qf extends GA{constructor(t={}){const i={};qf.definePropertiesValues(i,t);super(i,t);h(this,"_rebuildParentUI",()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0});qf.init(this)}add(t){const i=[];for(let s=0;s<arguments.length;s++){const r=arguments[s];!r.isUI||r.isInline?(i.push(r),r.position.z=.005):console.warn("Block element can only contain Box elements.",r)}return super.add(...i)}set textContent(t){this._textContent.value=t}get textContent(){return this._textContent._value}set invertAlpha(t){this._invertAlpha.value=t}get invertAlpha(){return this._invertAlpha._value}static definePropertiesValues(t,i){t.children||(t.children=Iz),t.textContent||(t.textContent=Nee),t.glyphs||(t.glyphs=Gee),t.inlines||(t.inlines=zee),t.layouter||(t.layouter=vz),t.renderer||(t.renderer=nte),t.fontFamily||(t.fontFamily=_z),t.fontWeight||(t.fontWeight=bz),t.fontStyle||(t.fontStyle=yz),t.fontSize||(t.fontSize=Mz),t.color||(t.color=Hee),t.backgroundColor||(t.backgroundColor=Vee),t.lineBreak||(t.lineBreak=Az),t.letterSpacing||(t.letterSpacing=Ez),t.whiteSpace||(t.whiteSpace=oI),t.segments||(t.segments=ete),t.textAlign||(t.textAlign=ste),t.fontKerning||(t.fontKerning=tte)}static init(t){Object.defineProperties(t,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class rte extends y3{constructor(){super("textContent",null,!1),this._needsUpdate=!1}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this._needsUpdate=!1;for(let i=e.children.length-1;i>=0;i--){const s=e.children[i];s.isUI&&(e.remove(s),s.clear())}e._children._uis=[],this._value&&e.add(new qf({name:"anonymousInline",textContent:this._value}))}}class ote extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class ate extends Ai{constructor(){super("layouter",null,!1),this._value=null}update(e,t){}process(e){let t=e._width._value;e._width._auto?t=1/0:t=e._bounds._innerWidth;const i=e._lineHeight._value,s=new ote(new pO);let r=0;e._children._inlines.forEach(d=>{if(!d._inlines.value)return;this._resetInlines(d);const f=d._fontSize._value,p=d._letterSpacing._value*f,g=d._whiteSpace._value,A=d._lineBreak._value,v={WHITESPACE:g,LETTERSPACING:p,BREAKON:A,INNER_WIDTH:t},m=d._whiteSpace._inlineWrapper;r+=d._margin._value.w+d._padding._value.w,d._inlines.value.forEach((b,y,_)=>{const C=s[s.length-1];if(m(_,y,r,v)){if(s.push(new pO(b)),b.offsetX=b.xoffset,b.width===0){r=0;return}b.cumulativeWidth=b.xadvance+p,r=b.cumulativeWidth;return}s[s.length-1].push(b),b.offsetX=r+b.xoffset+b.kerning,b.cumulativeWidth=b.xadvance+b.kerning+p,r+=b.cumulativeWidth,C.length-1===1&&C[C.length-2].width===0&&(b.offsetX-=b.xoffset,r-=b.xoffset)}),r+=d._margin._value.y+d._padding._value.y});const o=e._whiteSpace._inlineCollapser;let a=0,c=0,l=0;s.forEach((d,f)=>{const p=o(d);let g=0,A=0;if(d.forEach(v=>{g=Math.max(g,v.lineHeight),A=Math.max(A,v.lineBase),v.offsetX-=p}),d.lineHeight=g,d.lineBase=A,f===0?l=-(g*i-g)*.5:l-=s[f-1].lineHeight*i,d.y=l,d.x=0,d.forEach(v=>{v.offsetY=l-v.anchor,v.lineHeight<d.lineHeight&&(v.offsetY-=d.lineBase-v.lineBase)}),c+=d.lineHeight*i,d.width=0,d[0]){const v=d[d.length-1];d.width=v.offsetX+v.cumulativeWidth+v.paddingRight+v.marginRight+d[0].offsetX,a=Math.max(a,d.width)}}),s.height=c,s.width=a,this._value=s,t===1/0&&e._bounds.setChildrenWidth(e,s.width),e._height._auto&&e._bounds.setChildrenHeight(e,s.height);const u=e._parent._value;u&&(u._autoSize._needsProcess=!0,u._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}}class cte extends kT{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){lte(e),e._renderer._needsRender=!0}}function lte(n){const e=n._layouter._value,t=n._textAlign._value,i=n._bounds._innerWidth;for(let s=0;s<e.length;s++){const r=e[s],o=hte(n,r,s===e.length-1),a=n._padding._value,c=n._borderWidth._value,l=(-a.w+a.y)/2+(-c.w+c.y)/2;r.x+=o;for(let u=0;u<r.length;u++)r[u].offsetX+=o-l}if(t.indexOf("justify")===0)for(let s=0;s<e.length;s++){const r=e[s];if(t.indexOf("-")!==-1&&s===e.length-1)return;const o=i-r.width;if(o<=0)return;let a=0;for(let d=1;d<r.length-1;d++)a+=r[d].char===" "?1:0;const c=o/a;let l=1;t==="justify-right"&&(r.reverse(),l=-1);let u=0;for(let d=1;d<=r.length-1;d++){const f=r[d];f.offsetX+=u*l,u+=f.char===" "?c:0}t==="justify-right"&&r.reverse()}}function hte(n,e,t){switch(n._textAlign._value){case"justify-left":case"justify":case"left":return-n._bounds._innerWidth/2;case"justify-right":case"right":return-e.width+n._bounds._innerWidth/2;case"center":return-e.width/2;case"justify-center":return t?-e.width/2:-n._bounds._innerWidth/2;default:console.warn(`textAlign: '${n._textAlign._value}' is not valid`)}}class ute extends LT{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class dte extends I3{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class fte extends fx{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class pte extends pz{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class gte extends Ai{constructor(){super("children",null,!1);h(this,"_sortOrder",(t,i)=>t._order._value<i._order._value?-1:t._order._value>i._order._value?1:this._uis.indexOf(t)<this._uis.indexOf(i)?-1:1);this._uis=[],this._inlines=[],this._boxes=[]}update(t,i){this._compute(t),this._needsProcess=!0}process(t){this._compute(t),t._overflow._needsRender=!0}_compute(t){this._uis=t.children.filter(i=>i.visible&&i.isUI),this._inlines=this._uis.filter(i=>i.isInline).sort(this._sortOrder)}dispose(){this._inlines=null}}class mte extends Ai{constructor(){super("autosize")}process(e){if(e._layouter._value&&e._layouter._value.length){const t=e._layouter._value,i=e._padding._value,s=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+i.w+i.y+s.w+s.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+i.x+i.z+s.x+s.z)}}}class Ate extends mz{constructor(){super("renderer"),this._needsUpdate=!1}render(e){super.render(e);for(const t of e._children._inlines)t._renderer.render(t);e.performAfterUpdate()}}class Km extends qm{constructor(e={},t={}){Km.definePropertiesValues(t,e),super(t,e),Km.init(this)}add(e){const t=[];let i=!1;for(let s=0;s<arguments.length;s++){const r=arguments[s];!r.isUI||r.isInline?(r.isInline&&(i=!0),t.push(r)):console.warn("Block element can only contain Box elements.",r)}return t.length>0&&super.add(...t),i&&(this._children._needsUpdate=!0,this._layouter._needsProcess=!0),this}set textContent(e){this._textContent.value=e}get textContent(){return super.textContent}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}get lines(){return this._layouter._value}static definePropertiesValues(e,t){e.flexDirection=ute,e.justifyContent=FT,e.alignItems=OT,e.bounds=pte,e.autoSize=mte,e.renderer=Ate,e.children||(e.children=gte),e.textContent||(e.textContent=rte),e.layouter||(e.layouter=ate),e.lineHeight||(e.lineHeight=dte),e.textAlign||(e.textAlign=cte),e.whiteSpace||(e.whiteSpace=oI),e.fontKerning||(e.fontKerning=fte),e.segments||(e.segments=Tz),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class vte extends Ai{constructor(){super("inlines",null,!1),this._value=[]}process(e){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}}class yte extends Ai{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new gz(e)),e._backgroundMesh.position.x=e._inlines._value[0].offsetX+e._inlines._value[0].width/2,e._backgroundMesh.position.y=e._inlines._value[0].offsetY+e._inlines._value[0].lineBase/2,e._bounds.render(e)}}class bte extends Ai{constructor(){super("bounds",null,!1),this._size=new He.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0}update(e,t){this.output(t),this._needsProcess=!0}process(e){this._offsetWidth=this._innerWidth=e._inlines._value[0].width,this._offsetHeight=this._innerHeight=e._inlines._value[0].height,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight}output(e){e.size=this._size}}class Jm extends GA{constructor(e={}){const t={};Jm.definePropertiesValues(t,e),super(t,e),Jm.init(this)}clear(){for(const e of this._inlines._value)e.clear();return super.clear()}bindBackgroundMeshProperties(){this._backgroundMesh.raycast=()=>{},this._bounds._size=this._backgroundMesh.scale,this._bounds._needsUpdate=!0}unbindBackgroundMeshProperties(){this._bounds._size=new He.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){const t=[];for(let i=0;i<arguments.length;i++){const s=arguments[i];s.isUI?console.warn("ThreeMeshUI::InlineBlockElement cannot contains UI Elements.",s):(t.push(s),s.position.z=.005)}return super.add(...t)}static definePropertiesValues(e,t){e.children||(e.children=Iz),e.bounds||(e.bounds=bte),e.inlines||(e.inlines=vte),e.layouter||(e.layouter=vz),e.renderer||(e.renderer=yte),e.fontFamily||(e.fontFamily=_z),e.fontWeight||(e.fontWeight=bz),e.fontStyle||(e.fontStyle=yz),e.fontSize||(e.fontSize=Mz),e.backgroundColor||(e.backgroundColor=m3),e.lineBreak||(e.lineBreak=Az),e.letterSpacing||(e.letterSpacing=Ez),e.whiteSpace||(e.whiteSpace=oI),e.fontKerning||(e.fontKerning=fx),t.backgroundSize||(t.backgroundSize="cover"),t.width||(t.width="100%"),t.height||(t.height="100%"),t.boxSizing||(t.boxSizing="border-box")}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0},isInlineBlock:{configurable:!1,enumerable:!0,value:!0}}),e._inlines._value=[new _te(e)],e.backgroundMaterial=new fz,e._renderer.render(e)}}class _te extends S3{constructor(e){super(),this._uiElement=e}get xadvance(){const e=this._uiElement._padding._value,t=this._uiElement._width;return t._relative?t._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.w+e.y+t.value}get width(){const e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}}class Rz{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw new Error(`Behavior::act() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}detach(){console.error(`Behavior::detach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}clear(){}}const Pz=()=>Cb.update(),Bz={BaseProperty:Ai,Block:Ym,Text:Km,Inline:qf,InlineBlock:Jm,MeshUIBaseElement:GA,FontLibrary:Pu,update:Pz,MSDFFontMaterialUtils:Co,ShaderChunkUI:dz,Behavior:Rz,FontVariant:FA};typeof global<"u"&&(global.ThreeMeshUI=Bz);const xte=Bz;var wte=Rn.w8,Dz=Rn.cg,aI=Rn.gO,Ste=Rn.wb,hM=Rn.zV,Cte=Rn.HS,Ete=Rn.Ec,P0=Rn.gF,Mte=Rn.ol,Tte=Rn.pz,Ite=Rn.tx,Rte=Rn.hj,Pte=Rn.FV,Bte=Rn.sV,Oz=Rn.xv,Dte=Rn.mx,Ote=Rn.gE,kte=Rn.ZP,kz=Rn.Vx;const GS=Object.freeze(Object.defineProperty({__proto__:null,BaseProperty:wte,Behavior:Dz,Block:aI,DefaultValues:Ste,FontLibrary:hM,FontVariant:Cte,InheritableProperty:Ete,Inline:P0,InlineBlock:Mte,InlineGlyph:Tte,MSDFFontMaterialUtils:Ite,MaterialTransformers:Rte,MeshUIBaseElement:Pte,ShaderChunkUI:Bte,Text:Oz,TypographicFont:Dte,TypographicGlyph:Ote,default:kte,update:kz},Symbol.toStringTag,{value:"Module"})),Lte=re("debugshadowcomponents");aI.prototype.interactable={get(){return this.interactive},set(n){this.interactable=n}};const Ba=Symbol("shadowDomOwner");class aa extends Ie{constructor(){super(...arguments);h(this,"shadowComponent",null);h(this,"_controlsChildLayout",!0);h(this,"_root");h(this,"_parentComponent")}isRoot(){var t;return((t=this.Root)==null?void 0:t.gameObject)===this.gameObject}get canvas(){const t=this.Root;return t!=null&&t.isCanvas?t:null}markDirty(){$s.markUIDirty(this.context)}get controlsChildLayout(){return this._controlsChildLayout}set controlsChildLayout(t){this._controlsChildLayout=t,this.shadowComponent&&(this.shadowComponent.autoLayout=t)}get Root(){return this._root===void 0&&(this._root=ne.getComponentInParent(this.gameObject,HA)),this._root}get Canvas(){return this.canvas}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this.shadowComponent=null,this._root=void 0,this._parentComponent=void 0}onEnable(){super.onEnable()}addShadowComponent(t,i){var o;this.removeShadowComponent();const s=this.isRoot()?this.gameObject:this.gameObject.parent;if(this._parentComponent=ne.getComponentInParent(s,aa),!this._parentComponent){console.warn(`Component "${this.name}" doesn't have a UI parent anywhere. Do you have an UI element outside a Canvas? UI components must be a child of a Canvas component`,this);return}t.name=this.name+" ("+(this.constructor.name??"UI")+")",t.autoLayout=this._parentComponent.controlsChildLayout,t[Ba]=this,this.setShadowComponentOwner(t);let r=!1;if(((o=this.Root)==null?void 0:o.gameObject)===this.gameObject)this.gameObject.add(t);else{const a=this._parentComponent.shadowComponent;a&&(a==null||a.add(t),r=!0)}this.shadowComponent=t,i&&i.shadowComponent&&this.shadowComponent&&i.shadowComponent.add(this.shadowComponent),IA&&t.add(new tp(.5)),this.onAfterAddedToScene(),r&&kz(),Lte&&console.log(this.shadowComponent)}set(t){}setShadowComponentOwner(t){if(t&&(t[Ba]===void 0||t[Ba]===this)&&(t[Ba]=this,t.children))for(const i of t.children)this.setShadowComponentOwner(i)}traverseOwnedShadowComponents(t,i,s){if(t&&t[Ba]===i){s(t);for(const r of t.children)this.traverseOwnedShadowComponents(r,i,s)}}removeShadowComponent(){this.shadowComponent&&this.shadowComponent.removeFromParent()}onAfterAddedToScene(){}setInteractable(t){this.shadowComponent&&(this.shadowComponent.interactable=t)}}class HA extends aa{awake(){super.awake()}}class Yf{static getObject(e){const t=e[Ba];return t&&(t.isComponent===!0?e=t.gameObject:e=t),e}static isInteractable(e,t){if(t&&(t.canvasGroup=void 0,t.graphic=void 0),e==null||!e.visible||(e=this.getObject(e),!e.visible))return!1;const i=this.tryFindCanvasGroup(e);if((i==null?void 0:i.isCanvasGroup)===!0&&(t&&(t.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const s=Ru(e,r=>{if(r.isGraphic===!0)return r},!1);return t&&(s==null?void 0:s.isGraphic)===!0&&(t.graphic=s),!((s==null?void 0:s.raycastTarget)===!1||(s==null?void 0:s.layer)===2)}static tryFindCanvasGroup(e){if(!e)return null;const t=Ru(e,i=>{const s=i;if(s.blocksRaycasts!==void 0&&s.interactable!==void 0)return s},!1);return t!==void 0?t:this.tryFindCanvasGroup(e.parent)}}const Pg=re("debugwebxrcontroller");var Ef=(n=>(n[n.PhysicalDevice=0]="PhysicalDevice",n[n.Touch=1]="Touch",n))(Ef||{}),Cc=(n=>(n.SelectStart="select-start",n.SelectEnd="select-end",n.Update="update",n))(Cc||{});class vx extends Ie{}const Xn=class extends Ie{constructor(){super(...arguments);h(this,"webXR");h(this,"index",-1);h(this,"controllerModel");h(this,"controller");h(this,"controllerGrip");h(this,"hand");h(this,"handPointerModel");h(this,"grabbed",null);h(this,"input",null);h(this,"type",0);h(this,"showRaycastLine",!0);h(this,"_wristQuaternion",null);h(this,"movementVector",new w);h(this,"worldRot",new we);h(this,"joystick",new te);h(this,"didRotate",!1);h(this,"didTeleport",!1);h(this,"didChangeScale",!1);h(this,"lastHit",null);h(this,"raycastLine",null);h(this,"_raycastHitPoint",null);h(this,"_connnectedCallback",null);h(this,"_disconnectedCallback",null);h(this,"_selectStartEvt",null);h(this,"_selectEndEvt",null);h(this,"_selectionPressed",!1);h(this,"_selectionPressedLastFrame",!1);h(this,"_selectionStartTime",0);h(this,"_selectionEndTime",0);h(this,"_useSmoothing",!0);h(this,"_isConnected",!1);h(this,"rayRotation",new we);h(this,"_pinchStartTime");h(this,"selectStartCallback",null);h(this,"lastSelectStartObject",null);h(this,"_didNotEndSelection",!1);h(this,"closeGrabBoundingBoxHelper")}static CreateRaycastLine(){const t=new dn(this.geometry),i=t.material;return i.color=this.raycastColor,t.layers.set(2),t.name="line",t.scale.z=1,t}static CreateRaycastHitPoint(){const t=new Lo(.5,22,22),i=new ui({color:this.raycastColor}),s=new ye(t,i);return s.visible=!1,s.layers.set(2),s}static Create(t,i,s,r){const o=s?ne.addNewComponent(s,Xn,!1):new Xn;o.webXR=t,o.index=i,o.type=r;const a=t.context;o.controller=a.renderer.xr.getController(i),o.controllerGrip=a.renderer.xr.getControllerGrip(i),o.controllerModel=this.Factory.createControllerModel(o.controller),o.controllerGrip.add(o.controllerModel),o.hand=a.renderer.xr.getHand(i);const c=new cp;DA(c,a),o.webXR.handModelPath&&o.webXR.handModelPath!==""?c.setPath(al(t.sourceId,o.webXR.handModelPath)):c.setPath("https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/");const l=new iJ(o.hand,c);return o.hand.add(l),o.hand.traverse(u=>u.layers.set(2)),o.handPointerModel=new lJ(o.hand,o.controller),o.controller.addEventListener("connected",u=>{o.setControllerLayers(o.controllerModel,2),o.setControllerLayers(o.controllerGrip,2),o.setControllerLayers(o.hand,2),setTimeout(()=>{o.setControllerLayers(o.controllerModel,2),o.setControllerLayers(o.controllerGrip,2),o.setControllerLayers(o.hand,2)},1e3)}),o.hand.addEventListener("connected",u=>{var f;if(u.data.hand){t.Rig&&t.Rig.add(o.hand),o.type=0,o.handPointerModel.traverse(g=>g.layers.set(2)),(f=o.handPointerModel.pointerObject)==null||f.traverse(g=>g.layers.set(2));const p=o.hand.joints;if(p)for(const g of Object.keys(p)){const A=p[g];A.parent||o.hand.add(A)}}}),o}static addEventListener(t,i){const s=this.eventSubs[t]??[];s.push(i),this.eventSubs[t]=s}static removeEventListener(t,i){if(!i)return;const s=this.eventSubs[t]??[],r=s.indexOf(i);r>=0&&s.splice(r,1),this.eventSubs[t]=s}get isUsingHands(){var i;const t=(i=this.input)==null?void 0:i.hand;return t!=null}get wrist(){if(!this.hand)return null;const t=this.hand.joints;return t?t.wrist:null}getWristQuaternion(){const t=this.wrist;return t?(this._wristQuaternion||(this._wristQuaternion=new we),zn(t).multiply(this._wristQuaternion.setFromEuler(new mn(-Math.PI/4,0,0)))):null}get selectionDown(){return this._selectionPressed&&!this._selectionPressedLastFrame}get selectionUp(){return!this._selectionPressed&&this._selectionPressedLastFrame}get selectionPressed(){return this._selectionPressed}get selectionClick(){return this._selectionEndTime-this._selectionStartTime<.3}get raycastHitPoint(){return this._raycastHitPoint}get useSmoothing(){return this._useSmoothing}awake(){if(!this.controller){console.warn("WebXRController: Missing controller object.",this);return}this._connnectedCallback=this.onSourceConnected.bind(this),this._disconnectedCallback=this.onSourceDisconnected.bind(this),this._selectStartEvt=this.onSelectStart.bind(this),this._selectEndEvt=this.onSelectEnd.bind(this),this.type===1&&(this.controllerGrip.addEventListener("connected",this._connnectedCallback),this.controllerGrip.addEventListener("disconnected",this._disconnectedCallback),this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.addEventListener("selectstart",this._selectStartEvt),this.controller.addEventListener("selectend",this._selectEndEvt))}onDestroy(){var t,i,s;this.type===1&&(this.controllerGrip.removeEventListener("connected",this._connnectedCallback),this.controllerGrip.removeEventListener("disconnected",this._disconnectedCallback),this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),this.type===0&&(this.controller.removeEventListener("selectstart",this._selectStartEvt),this.controller.removeEventListener("selectend",this._selectEndEvt)),(t=this.hand)==null||t.clear(),(i=this.controllerGrip)==null||i.clear(),(s=this.controller)==null||s.clear()}onEnable(){var t,i,s,r,o;if(!this.webXR){console.warn("No WebXR component assigned to WebXRController.");return}this.hand&&(this.hand.name="Hand"),this.controllerGrip&&(this.controllerGrip.name="ControllerGrip"),this.controller&&(this.controller.name="Controller"),this.raycastLine&&(this.raycastLine.name="RaycastLine;"),this.webXR.Controllers.indexOf(this)<0&&this.webXR.Controllers.push(this),this.raycastLine||(this.raycastLine=Xn.CreateRaycastLine()),this._raycastHitPoint||(this._raycastHitPoint=Xn.CreateRaycastHitPoint()),(t=this.webXR.Rig)==null||t.add(this.hand),(i=this.webXR.Rig)==null||i.add(this.controllerGrip),(s=this.webXR.Rig)==null||s.add(this.controller),(r=this.webXR.Rig)==null||r.add(this.raycastLine),(o=this.raycastLine)==null||o.add(this._raycastHitPoint),this._raycastHitPoint.visible=!1,this.hand.add(this.handPointerModel),Pg&&console.log("ADDED TO RIG",this.webXR.Rig)}onDisable(){var t,i,s,r,o;if((t=this.hand)==null||t.removeFromParent(),(i=this.controllerGrip)==null||i.removeFromParent(),(s=this.controller)==null||s.removeFromParent(),(r=this.raycastLine)==null||r.removeFromParent(),(o=this._raycastHitPoint)==null||o.removeFromParent(),this.webXR){const a=this.webXR.Controllers.indexOf(this);a>=0&&this.webXR.Controllers.splice(a,1)}}onSourceConnected(t){if(this._isConnected){console.warn("Received connected event for controller that is already connected",this.index,t);return}this._isConnected=!0,this.input=t.data,this.type===1&&this.onSelectStart()}onSourceDisconnected(t){if(!this._isConnected){console.warn("Received discnnected event for controller that is not connected",t);return}this._isConnected=!1,this.type===1&&this.onSelectEnd(),this.input=null}createPointerEvent(t){switch(t){case"down":this.context.input.createPointerDown(new wc(Sn.PointerDown,null,{clientX:0,clientY:0,button:this.index,pointerType:zf.Touch}));break;case"move":break;case"up":this.context.input.createPointerUp(new wc(Sn.PointerUp,null,{clientX:0,clientY:0,button:this.index,pointerType:zf.Touch}));break}}raycastUpdate(t,i){const s=this.showRaycastLine&&this.type!==1;if(this.type===1)t.visible=!1;else if(this.isUsingHands){t.visible=!this.grabbed&&s,Mn(t,i);const r=this.hand.joints;if(r&&r.wrist&&this.grabbed&&this.grabbed.isCloseGrab){const a=this.getWristQuaternion();a&&this.rayRotation.copy(a)}Mr(t,this.rayRotation)}else t.visible=s,Mr(t,this.rayRotation),Mn(t,i)}update(){if(!this.webXR)return;this.context.time.frameCount%60===0&&(this.setControllerLayers(this.controller,2),this.setControllerLayers(this.controllerGrip,2),this.setControllerLayers(this.hand,2));const t=Xn.eventSubs.update;if(t&&t.length>0)for(const r of t)r(this);let i=1;this.type===0?i=this.context.time.deltaTime/.1:this.isUsingHands&&this.handPointerModel.pinched&&(i=this.context.time.deltaTime/.3),this.rayRotation.slerp(zn(this.controller),this.useSmoothing?i:1);const s=Ct(this.controller);this.isUsingHands&&this.handPointerModel.cursorObject&&(this.handPointerModel.cursorObject.visible=!1),this.raycastLine&&this.raycastUpdate(this.raycastLine,s),this.lastHit=this.updateLastHit(),this.grabbed&&this.grabbed.update(),this._selectionPressedLastFrame=this._selectionPressed,this.selectStartCallback&&this.selectStartCallback()}onUpdate(t){var r,o;if(this.lastHit=null,!t||t.inputSources.length<=this.index){this.input=null;return}if(this.type===0&&(this.input=t.inputSources[this.index]),!this.input)return;const i=this.webXR.Rig;if(!i)return;this._didNotEndSelection&&!this.handPointerModel.pinched&&(this._didNotEndSelection=!1,this.onSelectEnd()),this.updateStick(this.input);const s=(o=(r=this.input)==null?void 0:r.gamepad)==null?void 0:o.buttons;switch(this.input.handedness){case"left":this.movementUpdate(i,s);break;case"right":this.rotationUpdate(i,s);break}}movementUpdate(t,i){const s=3*Xn.MovementSpeedFactor,r=2,o=tt.clamp01(this.joystick.length()*2),a=this.joystick.x>0?1:-1;let c=Math.pow(this.joystick.x,r);c*=a,c*=o;const l=this.joystick.y>0?1:-1;let u=Math.pow(this.joystick.y,r);u*=l,c*=o,t.getWorldQuaternion(this.worldRot),this.movementVector.set(c,0,u),this.movementVector.applyQuaternion(this.webXR.TransformOrientation),this.movementVector.y=0,this.movementVector.applyQuaternion(this.worldRot),this.movementVector.multiplyScalar(s*this.context.time.deltaTime),t.position.add(this.movementVector),this.isUsingHands&&this.runTeleport(t,i)}rotationUpdate(t,i){const s=this.joystick.x,r=Math.abs(s);if(r<.4)this.didRotate=!1;else if(r>.5&&!this.didRotate){const o=s>0?-1:1;t.rotateY(tt.toRadians(30*o)),this.didRotate=!0}this.runTeleport(t,i)}runTeleport(t,i){var u,d;let s=-this.joystick.y;if((u=this.hand)!=null&&u.visible&&!this.grabbed){const f=this.handPointerModel.isPinched();f&&this._pinchStartTime===void 0&&(this._pinchStartTime=this.context.time.time),f&&this._pinchStartTime&&this.context.time.time-this._pinchStartTime>.8&&(s=this.handPointerModel.isPinched()?1:0),f||(this._pinchStartTime=void 0)}else this._pinchStartTime=void 0;const r=this.webXR.IsInVR,o=this.webXR.Rig;let a=s>.5&&r,c=o?((d=o==null?void 0:o.scale)==null?void 0:d.x)<.999:!1,l=null;if(i&&this.input&&!this.input.hand)for(let f=0;f<i.length;f++){const p=i[f];if(f===4)if(p.pressed&&!this.didChangeScale&&r){this.didChangeScale=!0;const g=o;if(g){const A=this.switchScale(g,a,c,l);a=A.doTeleport,c=A.isInMiniatureMode,l=A.newRigScale}}else p.pressed||(this.didChangeScale=!1)}if(a){if(!this.didTeleport){const f=this.raycast();if(this.didTeleport=!0,f&&f.length>0){const p=f[0];if(c||this.isValidTeleportTarget(p.object)){const g=p.point;Mn(t,g)}}}}else s<.1&&(this.didTeleport=!1);l!==null&&(t.scale.set(l,l,l),t.updateMatrixWorld())}isValidTeleportTarget(t){return ne.getComponentInParent(t,vx)!=null}switchScale(t,i,s,r){if(s){s=!1,t.scale.set(1,1,1),r=1,Xn.MovementSpeedFactor=1;const o=this.context.mainCamera;Xn.PreviousCameraFarDistance&&(o.far=Xn.PreviousCameraFarDistance)}else{s=!0,i=!0,r=.1,Xn.MovementSpeedFactor=r*2;const o=this.context.mainCamera;Xn.PreviousCameraFarDistance=o.far,o.far/=r}return{doTeleport:i,isInMiniatureMode:s,newRigScale:r}}updateStick(t){var i;!t||!t.gamepad||((i=t.gamepad.axes)==null?void 0:i.length)<4||(this.joystick.x=t.gamepad.axes[2],this.joystick.y=t.gamepad.axes[3])}updateLastHit(){var r;const t=this.raycast(),i=t?t[0]:null;this.lastHit=i;let s=1;if(this.webXR.Rig&&(s/=this.webXR.Rig.scale.x),this.raycastLine){this.raycastLine.scale.z=s*(((r=this.lastHit)==null?void 0:r.distance)??9999);const o=this.raycastLine.material;i!=null?o.color=Xn.raycastColor:o.color=Xn.raycastNoHitColor}if(this._raycastHitPoint){if(this.lastHit!=null){this._raycastHitPoint.position.z=-1;const o=tt.clamp(this.lastHit.distance*.01*s,.015,.1);this._raycastHitPoint.scale.set(o,o,o)}this._raycastHitPoint.visible=this.lastHit!==null&&this.lastHit!==void 0}return i}onSelectStart(){this.context.connection.allowEditing&&(this.selectStartCallback=()=>this.onHandleSelectStart())}onHandleSelectStart(){this.selectStartCallback=null,this._selectionPressed=!0,this._selectionStartTime=this.context.time.time,this._selectionEndTime=1e3;let t=null,i=!1;if(this.isUsingHands?(t=this.overlap(),t.length<=0?(t=this.raycast(),i=!1):i=!0):t=this.raycast(),Pg&&console.log("onHandleSelectStart","close grab? "+i,"intersections",t),t&&t.length>0)for(const s of t){const r=s.object;this.lastSelectStartObject=r;const o={selected:r,grab:r},a=Xn.eventSubs["select-start"];if(a&&a.length>0)for(const c of a)c(this,o);o.grab!==r&&Pg&&console.log("Grabbed object changed","original",r,"new",o.grab),o.grab&&(this.grabbed=Io.TryTake(this,o.grab,s,i));break}else{const s=Xn.eventSubs["select-start"],r={selected:null,grab:null};if(s&&s.length>0)for(const o of s)o(this,r)}}onSelectEnd(){var s;if(this.isUsingHands&&this.handPointerModel.pinched){this._didNotEndSelection=!0;return}if(!this._selectionPressed)return;this.selectStartCallback=null,this._selectionPressed=!1,this._selectionEndTime=this.context.time.time;const t={grab:((s=this.grabbed)==null?void 0:s.selected)??this.lastSelectStartObject},i=Xn.eventSubs["select-end"];if(i&&i.length>0)for(const r of i)r(this,t);this.grabbed&&(this.grabbed.free(),this.grabbed=null)}testIsVisible(t){return!(!t||ne.isActiveInHierarchy(t)===!1||Yf.isInteractable(t)===!1)}setControllerLayers(t,i){var s,r;if(t&&(t.layers.set(i),t.children))for(const o of t.children)((s=this.grabbed)==null?void 0:s.selected)===o||((r=this.grabbed)==null?void 0:r.selectedMesh)===o||this.setControllerLayers(o,i)}getRay(){const t=new Ya;return t.origin.copy(Ct(this.controller)),t.direction.set(0,0,-1).applyQuaternion(this.rayRotation),t}overlap(){const t=this.isUsingHands&&this.handPointerModel?this.handPointerModel.pointerObject:this.controllerGrip;if(Pg&&(!this.closeGrabBoundingBoxHelper&&t&&(this.closeGrabBoundingBoxHelper=new P_(t,16776960),this.scene.add(this.closeGrabBoundingBoxHelper)),this.closeGrabBoundingBoxHelper&&t&&this.closeGrabBoundingBoxHelper.setFromObject(t)),!t)return new Array;const i=Ct(t).clone();return this.context.physics.sphereOverlap(i,.02)}raycast(){const t=new ko;t.layerMask=new Ps,t.layerMask.enableAll(),t.layerMask.disable(2),t.ray=this.getRay();const i=this.context.physics.raycast(t);for(let s=0;s<i.length;s++){const r=i[s],o=r.object;if(!this.testIsVisible(o)){i.splice(s,1),s--;continue}r.object=Yf.getObject(o);break}return i}};let sn=Xn;h(sn,"Factory",new _J),h(sn,"raycastColor",new _e(.9,.3,.3)),h(sn,"raycastNoHitColor",new _e(.6,.6,.6)),h(sn,"geometry",new mt().setFromPoints([new w(0,0,0),new w(0,0,-1)])),h(sn,"handModels",{}),h(sn,"eventSubs",{}),h(sn,"PreviousCameraFarDistance"),h(sn,"MovementSpeedFactor",1);var Mb=(n=>(n.WillTake="WillTake",n.DidTake="DidTake",n.WillFree="WillFree",n.DidFree="DidFree",n))(Mb||{});const Xs=class{constructor(){h(this,"sync",null);h(this,"selected",null);h(this,"selectedParent",null);h(this,"selectedMesh",null);h(this,"controller",null);h(this,"grabTime",0);h(this,"grabUUID","");h(this,"isCloseGrab",!1);h(this,"originalMaterial",null);h(this,"usageMarker",null);h(this,"rigidbodies",null);h(this,"didReparent",!1);h(this,"grabDistance",0);h(this,"interactable",null);h(this,"positionSource",null);h(this,"grabPoint",new w);h(this,"localPositionOffsetToGrab",null);h(this,"localPositionOffsetToGrab_worldSpace",new w);h(this,"localQuaternionToGrab",new we(0,0,0,1));h(this,"targetDir",null);h(this,"quaternionLerp",null);h(this,"controllerDir",new w);h(this,"controllerWorldPos",new w);h(this,"lastControllerWorldPos",new w);h(this,"controllerPosDelta",new w);h(this,"totalChangeAlongDirection",0);h(this,"rigPositionLastFrame",new w)}static AddEventListener(e,t){return Xs.Events[e]||(Xs.Events[e]=[]),Xs.Events[e].push(t),t}static RemoveEventListener(e,t){if(!t||!Xs.Events[e])return;const i=Xs.Events[e].indexOf(t);i>=0&&Xs.Events[e].splice(i,1)}static Register(e){this.Current.find(t=>t===e)||this.Current.push(e)}static Remove(e){const t=this.Current.indexOf(e);t>=0&&this.Current.splice(t,1)}static TryTake(e,t,i,s){const r=ne.getComponentInParent(t,up);if(r)t=r.gameObject;else return Pg&&console.warn("Prevented taking object that is not interactable",t),null;let o=t;const a=ne.getComponentInParent(t,ah);a&&(a.requestOwnership(),o=a.gameObject);for(const l of this.Current)if(l.selected===o)return l.controller===e||(l.free(),l.Take(e,o,t,a,r,i,s)),l;const c=new Xs;return c.Take(e,o,t,a,r,i,s),c}Take(e,t,i,s,r,o,a){var p,g;if(console.assert(t!==null,"Expected object to be taken but was",t),e.isUsingHands?this.positionSource=a?e.wrist:e.controller:this.positionSource=e.controller,!this.positionSource)return console.warn("No position source"),this;const c={controller:e,take:t,hit:i,sync:s,interactable:r};(p=Xs.Events.WillTake)==null||p.forEach(A=>A(this,c));const l=i;l!=null&&l.material&&(this.originalMaterial=l.material,Array.isArray(l.material)||(l.material=l.material.clone(),l.material&&l.material.emissive&&(l.material.emissive.b=.2))),this.selected=t,this.selectedParent||(this.selectedParent=t.parent),this.selectedMesh=l,this.controller=e,this.interactable=r,this.isCloseGrab=a,this.didReparent=!1,this.sync=s,this.grabTime=e.context.time.time,this.grabUUID=Date.now().toString(),this.usageMarker=ne.addNewComponent(this.selected,dp),this.rigidbodies=ne.getComponentsInChildren(this.selected,Ii),Ct(this.positionSource,this.lastControllerWorldPos);const u=()=>a?this.lastControllerWorldPos.clone():o.point.clone();this.grabDistance=u().distanceTo(this.lastControllerWorldPos),this.totalChangeAlongDirection=0,this.localPositionOffsetToGrab=this.selected.worldToLocal(u());const d=e.isUsingHands&&a?this.controller.getWristQuaternion().clone():e.rayRotation.clone();zn(this.selected,this.localQuaternionToGrab).premultiply(d.invert());const f=this.controller.webXR.Rig;return f&&this.rigPositionLastFrame.copy(Ct(f)),ir.Add(e.context,this.selected),Xs.Register(this),this.sync&&(this.sync.fastMode=!0),(g=Xs.Events.DidTake)==null||g.forEach(A=>A(this,c)),this}free(){var s,r,o,a;if(!this.selected)return;const e={controller:this.controller,take:this.selected,hit:this.selected,sync:this.sync,interactable:null};(s=Xs.Events.WillFree)==null||s.forEach(c=>c(this,e)),ir.Remove(this.controller.context,this.selected),Xs.Remove(this),this.sync&&(this.sync.fastMode=!1);const t=this.selectedMesh;t&&this.originalMaterial&&t.material&&(t.material=this.originalMaterial);const i=this.selected;if(this.didReparent&&i.parent){const c=this.selectedParent;c?c.attach(i):(r=this.controller)==null||r.context.scene.attach(i)}if((o=this.usageMarker)==null||o.destroy(),this.controller&&(this.controller.grabbed=null),this.selected=null,this.selectedParent=null,this.selectedMesh=null,this.sync=null,this.rigidbodies)for(const c of this.rigidbodies)c.wakeUp(),c.setVelocity(c.smoothedVelocity);this.rigidbodies=null,this.localPositionOffsetToGrab=null,this.quaternionLerp=null,(a=Xs.Events.DidFree)==null||a.forEach(c=>c(this,e))}controllerMovementSinceLastFrame(){if(!this.positionSource||!this.controller)return 0;this.controllerDir.set(0,0,-1),this.controllerDir.applyQuaternion(this.controller.rayRotation),Ct(this.positionSource,this.controllerWorldPos),this.controllerPosDelta.copy(this.controllerWorldPos),this.controllerPosDelta.sub(this.lastControllerWorldPos),this.lastControllerWorldPos.copy(this.controllerWorldPos);const e=this.controller.webXR.Rig;if(e){const i=Ct(e),s=this.rigPositionLastFrame.sub(i);this.controllerPosDelta.add(s),this.rigPositionLastFrame.copy(i)}return this.controllerDir.dot(this.controllerPosDelta)}update(){var e;if(this.rigidbodies)for(const t of this.rigidbodies)t.resetVelocities();if(this.sync&&this.controller&&this.controller.context.connection.isInRoom&&this.controller.context.time.time-this.grabTime>3&&this.sync.hasOwnership()===!1&&(console.log("no ownership, will leave",this.sync.guid),this.free()),!(this.interactable&&!this.interactable.canGrab)){if(!this.didReparent&&this.selected&&this.controller){const t=((e=this.controller.webXR.Rig)==null?void 0:e.scale.x)??1;this.totalChangeAlongDirection+=this.controllerMovementSinceLastFrame();let i=1;this.controller.type===0&&(i=Math.max(0,1+this.totalChangeAlongDirection*2/t),i=i*i*i),this.grabDistance/t<.8&&(i=1),this.targetDir||(this.targetDir=new w),this.targetDir.set(0,0,-this.grabDistance*i);const s=this.targetDir.applyQuaternion(this.controller.rayRotation).add(this.controllerWorldPos),r=this.controller.rayRotation.clone().multiplyQuaternions(this.controller.rayRotation,this.localQuaternionToGrab);this.quaternionLerp||(this.quaternionLerp=r.clone()),this.quaternionLerp.slerp(r,this.controller.useSmoothing?this.controller.context.time.deltaTime/.03:1),Mr(this.selected,this.quaternionLerp),this.selected.updateWorldMatrix(!1,!1),this.grabPoint.copy(s),this.localPositionOffsetToGrab&&(this.localPositionOffsetToGrab_worldSpace.copy(this.localPositionOffsetToGrab),this.selected.localToWorld(this.localPositionOffsetToGrab_worldSpace).sub(Ct(this.selected)),s.sub(this.localPositionOffsetToGrab_worldSpace)),Mn(this.selected,s)}if(this.rigidbodies!=null)for(const t of this.rigidbodies)t.wakeUp();Sr.markDirty(this.selected,!0)}}};let Io=Xs;h(Io,"Events",{}),h(Io,"Current",[]);class Gc{constructor(e,t){h(this,"used",!1);h(this,"inputSource");h(this,"object");h(this,"pointerId");h(this,"isDown");h(this,"isUp");h(this,"isPressed");h(this,"isClicked");h(this,"input");h(this,"_event");this._event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this._event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this._event)==null||e.stopImmediatePropagation()}get event(){return this._event}clone(){const e=new Gc(this.input,this._event);return Object.assign(e,this),e}}class mp extends Ie{awake(){$s.createIfNoneExists(this.context)}onEnable(){var e;(e=$s.get(this.context))==null||e.register(this)}onDisable(){var e;(e=$s.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class rl extends mp{constructor(){super(...arguments);h(this,"targets",null);h(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(t=null){return this.targets?(t??(t=new ko),t.targets=this.targets,t.results=this.raycastHits,this.context.physics.raycast(t)):null}}class cI extends rl{}const Kd=re("debugeventsystem");var uM=(n=>(n.BeforeHandleInput="BeforeHandleInput",n.AfterHandleInput="AfterHandleInput",n))(uM||{});const Ea=class extends Ie{constructor(){super();h(this,"raycaster",[]);h(this,"_selectStartFn");h(this,"_selectEndFn");h(this,"_selectUpdateFn");h(this,"_handleEventCycleFn");h(this,"_handleInputFn");h(this,"pressedByID",new Map);h(this,"hoveredByID",new Map);h(this,"_sortedHits",[]);h(this,"_sortingBuffer",[]);h(this,"_noDepthTestingResults",[]);h(this,"out",{});h(this,"currentActiveMeshUIComponents",[]);Ea.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,Ea.systems.length<=0&&Ea.systems.push(...ne.findObjectsOfType(Ea,t)));for(const s of Ea.systems)if(s.context===t)return;const i=new Te;ne.addNewComponent(i,Ea),t.scene.add(i)}static get systems(){const t=Ft.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const i=this._eventSystemMap.get(t);return i&&i.length>0?i[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,i,s=!1){Ec.update(t,i,s)}static markUIDirty(t){Ec.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){Ea.systems.splice(Ea.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!ne.findObjectOfType(mp,this.context)){const i=ne.addNewComponent(this.context.scene,rl);this.raycaster.push(i),(ci()||Kd)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found")}}register(t){var i;t&&this.raycaster&&!this.raycaster.includes(t)&&((i=this.raycaster)==null||i.push(t))}unregister(t){var s,r;const i=(s=this.raycaster)==null?void 0:s.indexOf(t);i!==void 0&&i!==-1&&((r=this.raycaster)==null||r.splice(i,1))}onEnable(){const t=new Map;this._selectStartFn??(this._selectStartFn=(s,r)=>{if(!r.grab)return;Ec.resetLastSelected();const o=new Gc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=!1,t.set(s,r.grab),r.grab&&!this.handleEventOnObject(r.grab,o)&&(r.grab=null)}),this._selectEndFn??(this._selectEndFn=(s,r)=>{var c;if(!r.grab)return;const o=new Gc(this.context.input);o.inputSource=s,o.pointerId=0,o.isDown=s.selectionDown,o.isUp=s.selectionUp,o.isPressed=s.selectionPressed,o.isClicked=s.selectionClick,this.handleEventOnObject(r.grab,o);const a=t.get(s);if(t.set(s,null),a)for(const l of this.pressedByID.keys()){const u=this.pressedByID[l];u.obj===a&&u.handler&&((c=u.handler.onPointerUp)==null||c.call(u.handler,o),this.pressedByID.delete(l))}});const i=new ko;this._selectUpdateFn??(this._selectUpdateFn=s=>{i.ray=s.getRay();const r=this.performRaycast(i);if(!r)return;const o=new Gc(this.context.input);o.inputSource=s,this.handleIntersections(r,o)}),sn.addEventListener(Cc.SelectStart,this._selectStartFn),sn.addEventListener(Cc.SelectEnd,this._selectEndFn),sn.addEventListener(Cc.Update,this._selectUpdateFn),this._handleInputFn=this.onPointerEvent.bind(this),this.context.input.addEventListener(Sn.PointerDown,this._handleInputFn),this.context.input.addEventListener(Sn.PointerUp,this._handleInputFn),this.context.input.addEventListener(Sn.PointerMove,this._handleInputFn)}onDisable(){sn.removeEventListener(Cc.SelectStart,this._selectStartFn),sn.removeEventListener(Cc.SelectEnd,this._selectEndFn),sn.removeEventListener(Cc.Update,this._selectUpdateFn),this.context.input.removeEventListener(Sn.PointerDown,this._handleInputFn),this.context.input.removeEventListener(Sn.PointerUp,this._handleInputFn),this.context.input.removeEventListener(Sn.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0)return;const i=t.pointerType==zf.Touch?t.button:0,s=new Gc(this.context.input,t);s.inputSource=this.context.input,s.pointerId=i,s.isClicked=this.context.input.getPointerClicked(i),s.isDown=t.type==Sn.PointerDown,s.isUp=t.type==Sn.PointerUp,s.isPressed=this.context.input.getPointerPressed(i),Kd&&s.isClicked&&console.log("CLICK",i);const r=new ko;r.screenPoint=this.context.input.getPointerPositionRC(i);const o=this.performRaycast(r);if(!o)return;Kd&&s.isClicked&&pn("EventSystem: "+s.pointerId+" - "+this.context.time.frame+" - Up:"+s.isUp+", Down:"+s.isDown);const a={sender:this,args:s,hasActiveUI:this.currentActiveMeshUIComponents.length>0};if(this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:a})),!this.handleIntersections(o,s)){const c=this.hoveredByID.get(i);if(c&&this.triggerOnExit(c.obj,c.data),this.hoveredByID.delete(i),s.isUp){const l=this.pressedByID.get(i);l==null||l.handlers.forEach(u=>{var d;return(d=u.onPointerUp)==null?void 0:d.call(u,s)}),this.pressedByID.delete(i)}}this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:a}))}performRaycast(t){if(!this.raycaster)return null;this._sortedHits.length=0;for(const i of this.raycaster){if(!i.activeAndEnabled)continue;const s=i.performRaycast(t);s&&s.length>0&&this._sortedHits.push(...s)}return this._sortedHits.sort((i,s)=>i.distance-s.distance),this._sortedHits}handleIntersections(t,i){if(!t||t.length<=0)return!1;t=this.sortCandidates(t);for(const s of t){const{object:r}=s;if(this.handleEventOnObject(r,i))return!0}return!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let i=0;i<t.length;i++){const s=t[i],r=s.object;if(r.material&&r.material.depthTest===!1){this._noDepthTestingResults.push(s);continue}this._sortingBuffer.push(s)}for(const i of this._sortingBuffer)this._noDepthTestingResults.push(i);return this._noDepthTestingResults}handleEventOnObject(t,i){if(!this.testIsVisible(t))return i.isClicked&&Kd&&console.log("not allowed",t),!1;if(i.pointerId===void 0)return!1;i.object=t;const s=t.parent;let r=!1;const o=i.isClicked??!1;let a=null;if(s&&s.isUI){const u=(i.isPressed||i.isClicked)??!1;if(s[Ba]){const d=s[Ba].gameObject;if(d){if(!Yf.isInteractable(d,this.out))return!1;a=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,u),t=d,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,u))return!0}o&&Kd&&console.log(this.context.time.frame,t);const c=this.hoveredByID.get(i.pointerId),l=(c==null?void 0:c.obj)!==t;if(l&&(c!=null&&c.obj)&&this.triggerOnExit(c.obj,c.data),this.hoveredByID.set(i.pointerId,{obj:t,data:i}),i.isDown){const u=this.pressedByID.get(i.pointerId);u?(u.obj=t,u.data=i):this.pressedByID.set(i.pointerId,{obj:t,data:i,handlers:new Set})}return(a===null||a.interactable)&&this.handleMainInteraction(t,i,l),!0}propagate(t,i,s){for(;;){if(i.used)return;if(ne.foreachComponent(t,r=>{s(r)},!1),!t.parent)break;t=t.parent}}handleMainInteraction(t,i,s){if(i.pointerId===void 0)return;const r=this.pressedByID.get(i.pointerId);this.propagate(t,i,o=>{var d;const a=o;if(a.interactable===!1)return;a.onPointerEnter&&s&&a.onPointerEnter(i),i.isDown&&a.onPointerDown&&(a.onPointerDown(i),r==null||r.handlers.add(a));const c=this.context.input.getPointerPositionLastFrame(i.pointerId),l=this.context.input.getPointerPosition(i.pointerId);c&&!tt.approximately(c,l)&&a.onPointerMove&&a.onPointerMove(i),i.isUp&&(a.onPointerUp&&(a.onPointerUp(i),r==null||r.handlers.delete(a)),a.onPointerExit&&((d=i.event)==null?void 0:d.pointerType)===zf.Touch&&(a.onPointerExit(i),this.hoveredByID.delete(i.pointerId))),i.isClicked&&a.onPointerClick&&a.onPointerClick(i)}),i.isUp&&(r==null||r.handlers.forEach(o=>{o.onPointerUp&&o.onPointerUp(i)}),this.pressedByID.delete(i.pointerId))}triggerOnExit(t,i){i.used=!1,this.propagate(t,i,s=>{if(!s.gameObject||s.destroyed)return;const r=s;r.onPointerExit&&r.onPointerExit(i)})}handleMeshUiObjectWithoutShadowDom(t,i){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,i)}handleMeshUIIntersection(t,i){const s=Ec.updateState(t,i);return s&&this.currentActiveMeshUIComponents.push(s),s!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ec.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const i=this.currentActiveMeshUIComponents[t];Ec.resetState(i)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?ne.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let $s=Ea;h($s,"_eventSystemMap",new Map),h($s,"didSearchEventSystem",!1);class Ec{static markDirty(){this.needsUpdate=!0}static update(e,t,i=!1){if(i){e.update();return}const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let o=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(o=!0),o&&(Kd&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let i=null;if(e&&(i=this.findBlockInParent(e),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(Ec,"lastSelected",null),h(Ec,"lastUpdateFrame",[]),h(Ec,"needsUpdate",!1);const B0=Symbol("cameraController");function Fte(n){return n[B0]}function AO(n,e,t){t?n[B0]=e:n[B0]===e&&(n[B0]=null)}function yx(n){const e=n[Ba];return e||(n.parent?yx(n.parent):null)}function Tb(n,e){if(!n)return;const t=n.material;if((t==null?void 0:t.isMaterial)===!0){const i=n.parent;i&&i.isText,t.side=e.doubleSided??!0?wi:Ds,t.shadowSide=e.doubleSided?wi:Ds,n.castShadow=e.castShadows?e.castShadows:!1,n.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const i of n.children)Tb(i,e)}function Jd(n,e,t){n[e]===void 0&&console.warn("Field",e,"is undefined on",n);const i=Proxy.revocable(n[e],{set(o,a,c,l){const u=o[a],d=Reflect.set(o,a,c,l);return t(c,u),d}}),s=i.revoke,r=n[e];return i.revoke=()=>{n[e]=r,s()},n[e]=i.proxy,i}const vO=Symbol("Scheduled action");function Ute(n,e,t=Tr.OnBeforeRender){let i=n[vO];i||(i=n[vO]={});const s=e.name;i[t]||(i[t]={});const r=i[t];if(r[s])return;function*a(){e==null||e.call(n),r[s]=null}const c=n.startCoroutine(a(),t);r[s]=c}class Lz extends ye{constructor(e,t={}){const s=[e.isCubeTexture?"#define ENVMAP_TYPE_CUBE":""],r=`
|
|
5073
5073
|
varying vec3 vWorldPosition;
|
|
5074
5074
|
|
|
5075
5075
|
void main() {
|
|
@@ -6636,4 +6636,4 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
|
|
|
6636
6636
|
<slot class="overlay-content"></slot>
|
|
6637
6637
|
</div>
|
|
6638
6638
|
`,this.shadowRoot&&this.shadowRoot.appendChild(t.content.cloneNode(!0)),this._context=new Ft({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return Ice}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const t=this.getAttribute("camera-controls");return!(t===null||t==="False"||t==="false"||t==="0")}getContext(){return new Promise((t,i)=>{if(this._context&&this.loadingFinished)t(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&t(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(ns&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const i=globalThis["needle:codegen_files"];i&&(ns&&console.log('globalThis["needle:codegen_files"]',i),this.setAttribute("src",i))}const t=this._loadId;setTimeout(()=>{this.isConnected!==!1&&t===this._loadId&&this.onLoad()},1),Nc!=null&&Nc.length&&this.setAttribute("version",Nc)}disconnectedCallback(){var i;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");ns&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(i=this._context)==null||i.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(t,i,s){switch(ns&&console.log("attributeChangedCallback",t,i,s),t){case"src":ns&&console.warn("src changed to type:",typeof s,', from "',i,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(ns&&console.log(t+" attribute changed",s),this.registerEventFromAttribute(t,s));break;case"dracoDecoderPath":ns&&console.log("dracoDecoderPath",s),CD(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(ns&&console.log("dracoDecoderType",s),ED(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":ns&&console.log("ktx2DecoderPath",s),MD(s);break}}async onLoad(){var f,p;if(!this.isConnected)return;if(this._context||(ns&&console.warn("Create new context"),this._context=new Ft({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const t=this.getSourceFiles();if(t==null||t.length<=0)ns&&console.warn("Clear scene",t),this._context.clear();else if(!this.checkIfSourceHasChanged(t,this._lastSourceFiles))return;this._lastSourceFiles=t;const i=++this._loadId,s=this.getAttribute("alias");this.classList.add("loading");const r=Qf();this.ensureLoadStartIsRegistered();let o=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:s},cancelable:!0}));if(r){const g=this.getAttribute("hide-loading-overlay");g!=null&&g!=="0"&&(o=!1)}o===!1&&!r&&(ci()||(o=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),ci()&&Ls('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&o&&(this._loadingView=new im(this)),o&&(this._didFullyLoad!==!0?(f=this._loadingView)==null||f.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===i&&this._loadingView.onLoadingBegin("begin load")},300)),ns&&console.warn("--------------",i,"Needle Engine: Begin loading",s??"",t),this.onBeforeBeginLoading();const a=[],c={context:this._context,name:"",progress:{},index:0,count:t.length,totalProgress01:this._loadingProgress01},l=new CustomEvent("progress",{detail:c}),u={files:t,onLoadingProgress:g=>{var A;g.name=Rce(g.name),o&&((A=this._loadingView)==null||A.onLoadingUpdate(g)),c.name=g.name,c.progress=g.progress,this._loadingProgress01=vT(g),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(l)},onLoadingFinished:(g,A,v)=>{v&&a.push({src:A,file:v})}},d=this.getAttribute("hash");d!=null&&(this._context.hash=d),this._context.alias=s,await this._context.create(u),this._loadId===i&&(ns&&console.warn("--------------",i,"Needle Engine: finished loading",s??"",t),this._loadingProgress01=1,o&&((p=this._loadingView)==null||p.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:s,loadedFiles:a}})))}internalSetLoadingMessage(t){var i;(i=this._loadingView)==null||i.setMessage(t)}getSourceFiles(){const t=this.getAttribute("src");if(!t)return[];let i;Array.isArray(t)?i=t:t.startsWith("[")&&t.endsWith("]")?i=JSON.parse(t):t.includes(",")?i=t.split(","):i=[t];for(let s=i.length-1;s>=0;s--){const r=i[s];(r==="null"||r==="undefined"||(r==null?void 0:r.length)<=0)&&i.splice(s,1)}return i}checkIfSourceHasChanged(t,i){if((t==null?void 0:t.length)!==(i==null?void 0:i.length)||t==null&&i!==null||t!==null&&i==null)return!0;if(t!==null&&i!==null){for(let s=0;s<(t==null?void 0:t.length);s++)if(t[s]!==i[s])return!0}return!1}ensureLoadStartIsRegistered(){const t=this.getAttribute("loadstart");t&&this.registerEventFromAttribute("loadstart",t)}registerEventFromAttribute(t,i){const s=this._previouslyRegisteredMap.get(t);if(s&&(this._previouslyRegisteredMap.delete(t),this.removeEventListener(t,s)),typeof i=="string"&&i.length>0)try{const r=(0,eval)(i);typeof r=="function"&&(this._previouslyRegisteredMap.set(t,r),this.addEventListener(t,o=>r==null?void 0:r.call(globalThis,this._context,o)))}catch(r){console.error("Error registering event "+t+'="'+i+`" failed with the following error:
|
|
6639
|
-
`,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(mg),this.classList.remove(Ag);const t=this.getAROverlayContainer();ns&&console.warn("onSetupAR:",t),t&&(t.classList.add(mg),t.classList.remove(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,MN))}onSetupVR(){this.classList.remove(mg),this.classList.remove(Ag),this.foreachHtmlElement(t=>this.setupElementsForMode(t,DG))}onSetupDesktop(){this.classList.remove(mg),this.classList.add(Ag);const t=this.getAROverlayContainer();t&&(t.classList.remove(mg),t.classList.add(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,OG))}setupElementsForMode(t,i,s=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of Tce)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ns&&console.log("using custom draco decoder path",t),CD(t));const i=this.getAttribute("dracoDecoderType");i&&(ns&&console.log("using custom draco decoder type",i),ED(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ns&&console.log("using custom ktx2 decoder path",s),MD(s))}}typeof window<"u"&&!window.customElements.get(Rk)&&window.customElements.define(Rk,lR);function Rce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const Pce=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:lR},Symbol.toStringTag,{value:"Module"})),V0=re("debughotreload");let aA=!1;const hm=new Map;function Bce(){return aA}function Dce(n){var i;if(aA)return;const t=n.constructor.name;hm.has(t)?(i=hm.get(t))==null||i.push(n):hm.set(t,[n])}function Oce(n){if(aA)return;const t=n.constructor.name,i=hm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let Pk=!1;function kce(){if(V0||Pk)return;Pk=!0;const n=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}n.apply(console,e)}}function Lce(n){V0&&console.log("[HMR] Apply changes",n,Object.keys(n)),kce();for(const e of Object.keys(n))try{aA=!0;const t=q.get(e);if(!t){V0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=hm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,u=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Bc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&rT(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(V0)console.error(t);else return!1}finally{aA=!1,Xc(Bo.Log,"Script changes applied (HMR)")}return!0}const Fce=Symbol("object"),Bk=new Xa(()=>new w,20);class kG{constructor(e,t,i,s,r){h(this,"_point");h(this,"_normal");h(this,"distance");h(this,"impulse");h(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return Bk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Bk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class LG{constructor(e,t,i){h(this,"contacts");h(this,"me");h(this,"_collider");h(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class FG{constructor(e,t){h(this,"object");h(this,"collider");this.object=e,this.collider=t}}let Ne;const cA=new Array(32).fill(void 0);cA.push(void 0,null,!0,!1);let Dk;cA.length;function Ok(){return Dk.byteLength,Dk}const Uce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}Uce.decode();let kk,Lk,um=32;function Fk(n){if(um==1)throw new Error("out of js stack");return cA[--um]=n,um}function Nce(){return kk.byteLength,kk}function zce(){return Lk.byteLength,Lk}let Fr=0;function Xh(n,e){const t=e(4*n.length);return Nce().set(n,t/4),Fr=n.length,t}function $y(n,e){const t=e(4*n.length);return zce().set(n,t/4),Fr=n.length,t}class kb{static __wrap(e){const t=Object.create(kb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return kb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Oa{static __wrap(e){const t=Object.create(Oa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Oa.__wrap(i)}static prismatic(e,t,i,s,r,o){vt(e,ft),vt(t,ft),vt(i,ft);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Oa.__wrap(a)}static fixed(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,qn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Oa.__wrap(r)}static revolute(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Oa.__wrap(s)}}class hR{static __wrap(e){const t=Object.create(hR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=Ok()[i/4+0],t=Ok()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class qn{static __wrap(e){const t=Object.create(qn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return qn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return qn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Xh(i,Ne.__wbindgen_malloc),o=Fr;vt(s,ft);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){vt(e,ft),vt(t,ft),vt(i,ft);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Xh(e,Ne.__wbindgen_malloc),i=Fr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Xh(e,Ne.__wbindgen_malloc),r=Fr,o=$y(t,Ne.__wbindgen_malloc),a=Fr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,Gt),vt(r,ft),vt(o,qn),vt(a,ft);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:fR.__wrap(l)}intersectsShape(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,i){return vt(e,ft),vt(t,qn),vt(i,ft),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return hR.__wrap(r)}intersectsRay(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return ft.__wrap(e)}}class fR{static __wrap(e){const t=Object.create(fR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return ft.__wrap(e)}}class ft{static __wrap(e){const t=Object.create(ft.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return ft.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return ft.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return ft.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return ft.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return ft.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return ft.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return ft.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return ft.__wrap(e)}}class Gce{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Re{static new(e,t,i){return new Gce(e,t,i)}static intoRaw(e){return new ft(e.x,e.y,e.z)}static zeros(){return Re.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Re.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Uk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Di{static identity(){return new Uk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Uk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qn(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var dm,Ca,Nk,Eo,OM,Zt,Lb,uf,kM,LM,zk,Gk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(dm||(dm={}));class Hce{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Re.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Re.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Re.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Re.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,s,r){let o=Re.intoRaw(t),a=Re.intoRaw(i),c=Di.intoRaw(s);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(Ca||(Ca={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(Nk||(Nk={}));class df{constructor(){}static fixed(e,t,i,s){let r=new df;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=Ca.Fixed,r}static spherical(e,t){let i=new df;return i.anchor1=e,i.anchor2=t,i.jointType=Ca.Spherical,i}static prismatic(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Prismatic,s}static revolute(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Revolute,s}intoRaw(){let e,t,i=Re.intoRaw(this.anchor1),s=Re.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case Ca.Fixed:let c=Di.intoRaw(this.frame1),l=Di.intoRaw(this.frame2);t=Oa.fixed(i,c,s,l),c.free(),l.free();break;case Ca.Prismatic:e=Re.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Oa.prismatic(i,s,e,r,o,a),e.free();break;case Ca.Spherical:t=Oa.spherical(i,s);break;case Ca.Revolute:e=Re.intoRaw(this.axis),t=Oa.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(Eo||(Eo={}));class lA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new lA(e.distance(),Re.fromRaw(e.point1()),Re.fromRaw(e.point2()),Re.fromRaw(e.normal1()),Re.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(OM||(OM={}));class ow{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new ow(Re.fromRaw(e.point()),e.isInside());return e.free(),t}}class Vce{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class aw{constructor(e,t,i,s){this.featureType=OM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new aw(e.toi(),Re.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class _v{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new _v(t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class pR extends _v{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new pR(e.get(t.colliderHandle()),t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class xs{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case Zt.Ball:return new gR(e.coRadius(t));case Zt.Cuboid:return s=e.coHalfExtents(t),new UG(s.x,s.y,s.z);case Zt.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new NG(s.x,s.y,s.z,r);case Zt.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new zG(c,l);case Zt.Segment:return o=e.coVertices(t),new GG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new QG(o,a);case Zt.Triangle:return o=e.coVertices(t),new HG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new VG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]),r);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new WG(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new jG(f,p,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new FM(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new UM(o,a,r);case Zt.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new XG(c,l);case Zt.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new qG(c,l,r);case Zt.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new YG(c,l);case Zt.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new KG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Re.intoRaw(e),u=Di.intoRaw(t),d=Re.intoRaw(i),f=Re.intoRaw(r),p=Di.intoRaw(o),g=Re.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=_v.fromRaw(null,A.castShape(l,u,d,v,f,p,g,c));return l.free(),u.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Re.intoRaw(e),a=Di.intoRaw(t),c=Re.intoRaw(s),l=Di.intoRaw(r),u=this.intoRaw(),d=i.intoRaw(),f=u.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),u.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Di.intoRaw(t),l=Re.intoRaw(s),u=Di.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=lA.fromRaw(d.contactShape(a,c,f,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Re.intoRaw(e),r=Di.intoRaw(t),o=Re.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Re.intoRaw(e),o=Di.intoRaw(t),a=Re.intoRaw(i),c=this.intoRaw(),l=ow.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=Re.intoRaw(e.origin),c=Re.intoRaw(e.dir),l=this.intoRaw(),u=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),u}castRay(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),u.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=aw.fromRaw(u.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),u.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class gR extends xs{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class UG extends xs{constructor(e,t,i){super(),this.type=Zt.Cuboid,this.halfExtents=Re.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class NG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundCuboid,this.halfExtents=Re.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class zG extends xs{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class GG extends xs{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class HG extends xs{constructor(e,t,i){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class VG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class QG extends xs{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class WG extends xs{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class FM extends xs{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class UM extends xs{constructor(e,t,i){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class jG extends xs{constructor(e,t,i,s){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Re.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class XG extends xs{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class qG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class YG extends xs{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class KG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Lb||(Lb={}));class Qce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=xs.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Re.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,s){let r=Re.intoRaw(t),o=Re.intoRaw(i),a=Di.intoRaw(s);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Re.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Re.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Re.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Re.intoRaw(e),s=ow.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Re.intoRaw(e.origin),s=Re.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Re.intoRaw(i),l=Di.intoRaw(s),u=Re.intoRaw(r),d=t.intoRaw(),f=_v.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f}castCollider(e,t,i,s){let r=Re.intoRaw(e),o=Re.intoRaw(i),a=pR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Re.intoRaw(t),r=Di.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=e.intoRaw(),c=lA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return lA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=aw.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(uf||(uf={}));class Hi{constructor(e){this.shape=e,this.massPropsMode=uf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=Re.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Eo.Average,this.restitutionCombineRule=Eo.Average,this.activeCollisionTypes=Lb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Re.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Re.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new gR(e);return new Hi(t)}static capsule(e,t){const i=new zG(e,t);return new Hi(i)}static segment(e,t){const i=new GG(e,t);return new Hi(i)}static triangle(e,t,i){const s=new HG(e,t,i);return new Hi(s)}static roundTriangle(e,t,i,s){const r=new VG(e,t,i,s);return new Hi(r)}static polyline(e,t){const i=new QG(e,t);return new Hi(i)}static trimesh(e,t){const i=new WG(e,t);return new Hi(i)}static cuboid(e,t,i){const s=new UG(e,t,i);return new Hi(s)}static roundCuboid(e,t,i,s){const r=new NG(e,t,i,s);return new Hi(r)}static heightfield(e,t,i,s){const r=new jG(e,t,i,s);return new Hi(r)}static cylinder(e,t){const i=new XG(e,t);return new Hi(i)}static roundCylinder(e,t,i){const s=new qG(e,t,i);return new Hi(s)}static cone(e,t){const i=new YG(e,t);return new Hi(i)}static roundCone(e,t,i){const s=new KG(e,t,i);return new Hi(s)}static convexHull(e){const t=new FM(e,null);return new Hi(t)}static convexMesh(e,t){const i=new FM(e,t);return new Hi(i)}static roundConvexHull(e,t){const i=new UM(e,null,t);return new Hi(i)}static roundConvexMesh(e,t,i){const s=new UM(e,t,i);return new Hi(s)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=uf.Density,this.density=e,this}setMass(e){return this.massPropsMode=uf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=uf.MassProps,this.mass=e,Re.copy(this.centerOfMass,t),Re.copy(this.principalAngularInertia,i),Di.copy(this.angularInertiaLocalFrame,s),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(kM||(kM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LM||(LM={}));class Wce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Re.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Re.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class jce{constructor(e,t){this.raw=t||new kb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Wce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(zk||(zk={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Gk||(Gk={}));for(var Hle={byteLength:function(n){var e=Hk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=Hk(n),s=i[0],r=i[1],o=new Xce(function(l,u,d){return 3*(u+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=bo[n.charCodeAt(t)]<<18|bo[n.charCodeAt(t+1)]<<12|bo[n.charCodeAt(t+2)]<<6|bo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=bo[n.charCodeAt(t)]<<2|bo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=bo[n.charCodeAt(t)]<<10|bo[n.charCodeAt(t+1)]<<4|bo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Yce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ra[e>>2]+Ra[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ra[e>>10]+Ra[e>>4&63]+Ra[e<<2&63]+"=")),s.join("")}},Ra=[],bo=[],Xce=typeof Uint8Array<"u"?Uint8Array:Array,vC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hd=0,qce=vC.length;Hd<qce;++Hd)Ra[Hd]=vC[Hd],bo[vC.charCodeAt(Hd)]=Hd;function Hk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Yce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ra[(s=i)>>18&63]+Ra[s>>12&63]+Ra[s>>6&63]+Ra[63&s]);return r.join("")}bo["-".charCodeAt(0)]=62,bo["_".charCodeAt(0)]=63;const Qs=re("debugphysics"),yC=re("debugcolliderplacement"),bC=re("debugcollisions"),Kce=re("showcolliders"),Ur=Symbol("needle component"),Or=Symbol("physics body"),Jce=Symbol("rigidbody");let Vd;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Qs&&console.log("Use Rapier",!1,globalThis.false);const ym=class{constructor(){h(this,"debugRenderColliders",!1);h(this,"context");h(this,"_initializePromise");h(this,"_isInitialized",!1);h(this,"rapierRay",new Vce({x:0,y:0,z:0},{x:0,y:0,z:1}));h(this,"raycastVectorsBuffer",new Xa(()=>new w,10));h(this,"rapierSphere",null);h(this,"rapierColliderArray",[]);h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});h(this,"rapierForwardVector",{x:0,y:0,z:1});h(this,"enabled",!1);h(this,"_tempPosition",new w);h(this,"_tempQuaternion",new we);h(this,"_tempScale",new w);h(this,"_tempMatrix",new Me);h(this,"_isUpdatingPhysicsWorld",!1);h(this,"_world");h(this,"_hasCreatedWorld",!1);h(this,"eventQueue");h(this,"collisionHandler");h(this,"objects",[]);h(this,"bodies",[]);h(this,"_meshCache",new Map);h(this,"_gravity",{x:0,y:-9.81,z:0});h(this,"lines")}removeBody(e){var i,s,r;if(!e)return;this.validate();const t=e[Or];if(e[Or]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof Qce){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[Ur]||(s=this.world)==null||s.removeRigidBody(l))}else a instanceof Hce&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ci()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=e,r=s[Or];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[Or];i&&this.internalUpdateColliderProperties(t,i)}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Qs&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:CR&&CR.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Qs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Qs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[Ur]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,u=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return u.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:u,normal:d,collider:o.collider[Ur]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const u=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(u)t=u;else return null}if(t.z===void 0){if(!s)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const u=this.raycastVectorsBuffer.get();u.x=t.x,u.y=t.y,u.z=0,(u.x>1||u.y>1||u.y<-1||u.x<-1)&&(Qs&&console.warn("Converting screenspace to raycast space",u),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(u)),u.unproject(s),t=u}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const u=Ct(s);o.sub(u)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new gR(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[Ur],r=new FG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},kM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[Ur].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const s=e.gameObject,r=ls(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Hi.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const i=Hi.ball(.5);this.createCollider(e,i,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const r=e.gameObject,o=ls(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Hi.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,u,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Qs&&console.warn("Missing mesh geometry",t.name);return}(u=(l=r.index)==null?void 0:l.array)!=null&&u.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=qY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Qs&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Hi.convexMesh(o):Hi.trimesh(o,a);c&&this.createCollider(e,c)}getBody(e){return e?e[Or]:null}getComponent(e){return e?e[Ur]:null}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),ls(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case wa.Average:t.setRestitutionCombineRule(Eo.Average);break;case wa.Maximum:t.setRestitutionCombineRule(Eo.Max);break;case wa.Minimum:t.setRestitutionCombineRule(Eo.Min);break;case wa.Multiply:t.setRestitutionCombineRule(Eo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case wa.Average:t.setFrictionCombineRule(Eo.Average);break;case wa.Maximum:t.setFrictionCombineRule(Eo.Max);break;case wa.Minimum:t.setFrictionCombineRule(Eo.Min);break;case wa.Multiply:t.setFrictionCombineRule(Eo.Multiply);break}}o&&t.setDensity(0);const c=this.world.createCollider(t,r);return c[Ur]=e,e[Or]=c,c.setActiveEvents(LM.COLLISION_EVENTS),c.setActiveCollisionTypes(Lb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[Or],s=r.autoMass===!1,!i){const o=r.isKinematic&&!yC;Qs&&console.log("Create rigidbody",o);const a=o?Vd.RigidBodyDesc.kinematicPositionBased():Vd.RigidBodyDesc.dynamic(),c=Ct(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(zn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[Ur]=r,r[Or]=i,this.internalUpdateRigidbodyProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Vd.RigidBodyDesc.kinematicPositionBased(),o=Ct(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(zn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[Ur]=null}return e[Jce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[Or]}internalUpdateColliderProperties(e,t){const i=t.shape;switch(i.type){case Zt.Ball:{const o=i,a=e,c=o.radius!==a.radius,l=e.gameObject,u=ls(l,this._tempPosition).multiplyScalar(a.radius);o.radius=Math.abs(u.x),c&&t.setShape(o);break}case Zt.Cuboid:const s=i,r=e;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,t.setShape(s);break}}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==lx.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(0);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Vd.RigidBodyType.KinematicPositionBased):t.setBodyType(Vd.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new jce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Qs||yC||Kce||this.debugRenderColliders===!0){if(!this.lines){const o=new vn({color:2258688,fog:!1}),a=new mt;this.lines=new eo(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new $e(r.vertices,3)),this.lines.geometry.setAttribute("color",new $e(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Zce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!yC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion);r.x-=c.x,r.y-=c.y,r.z-=c.z}Gf(t.gameObject,r.x,r.y,r.z),eF(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=Ct(e,this._tempPosition),o=zn(e,this._tempQuaternion);switch(t.bodyType()){case dm.Fixed:case dm.KinematicPositionBased:case dm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=ym._matricesBuffer,s.length=0),e===t){const r=ls(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[Or],s=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=df.fixed(ym.centerConnectionPos,ym.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Qs&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[Or],o=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Vd.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Qs&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let eu=ym;h(eu,"_didLoadPhysicsEngine",!1),h(eu,"_matricesBuffer",[]),h(eu,"centerConnectionPos",{x:0,y:0,z:0}),h(eu,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zce{constructor(e,t){h(this,"world");h(this,"eventQueue");h(this,"activeCollisions",[]);h(this,"activeCollisionsStay",[]);h(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[Ur],a=r[Ur];bC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Ru(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,s,(a,c)=>{Ru(o,l=>{var d;if(l.destroyed)return;const u=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(u||bC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new kG(A,m,p,v,b);f.push(y),bC&&zc.DrawDirection(A,p,16711680,3,!0)}}r=new LG(o,i,f)}if(u){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function $ce(n,e,t,i="image/webp",s){if(!n&&(n=Oi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,n.renderer.domElement.style.width=e+"px",n.renderer.domElement.style.height=t+"px";try{const c=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),c.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let vg=null;function ele(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}vg||(vg=document.createElement("a")),vg.href=n,vg.download=e,vg.click()}}const Fb=re("debugmissingcamera");Oi.registerCallback(Ks.MissingCamera,n=>{var r,o;Fb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Li;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",n.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=1:i.clearFlags=2,i.backgroundColor=new bi(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const s=gh(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,JG(n.context,s),s});Oi.registerCallback(Ks.ContextCreated,n=>{if(!n.context.mainCamera){Fb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Fte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Fb&&console.log("Will not auto-fit because a camera controller exists");return}JG(n.context)}});function JG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Fb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Q_(t,Ji);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}_j();const mR={Context:Ft,glTF:{loadFromURL:cR}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=mR;function ZG(n){for(const e in n)mR[e]=n[e]}ZG(wY);ZG(pce);for(const n of Object.getOwnPropertyNames(ne))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:mR[n]=ne[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=oj;var AR={},$G={};Object.defineProperty($G,"__esModule",{value:!0});var cw={};Object.defineProperty(cw,"__esModule",{value:!0});cw.ConstantBackoff=void 0;var tle=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();cw.ConstantBackoff=tle;var lw={};Object.defineProperty(lw,"__esModule",{value:!0});lw.ExponentialBackoff=void 0;var ile=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();lw.ExponentialBackoff=ile;var hw={};Object.defineProperty(hw,"__esModule",{value:!0});hw.LinearBackoff=void 0;var nle=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();hw.LinearBackoff=nle;var eH={};Object.defineProperty(eH,"__esModule",{value:!0});var uw={};Object.defineProperty(uw,"__esModule",{value:!0});uw.LRUBuffer=void 0;var sle=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();uw.LRUBuffer=sle;var dw={};Object.defineProperty(dw,"__esModule",{value:!0});dw.TimeBuffer=void 0;var rle=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();dw.TimeBuffer=rle;var vR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(vR);var fw={};Object.defineProperty(fw,"__esModule",{value:!0});fw.WebsocketBuilder=void 0;var Qd=vR,ole=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Qd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();fw.WebsocketBuilder=ole;(function(n){var e=py&&py.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=py&&py.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t($G,n),t(cw,n),t(lw,n),t(hw,n),t(eH,n),t(uw,n),t(dw,n),t(vR,n),t(fw,n)})(AR);const ale=xA(AR),cle=nH({__proto__:null,default:ale},[AR]),Ao={node:"node",material:"material",camera:"camera",light:"light"},qh="KHR_animation_pointer",lle={CUBICSPLINE:void 0,LINEAR:Wa,STEP:nh},Vk=Nt.findNode;let Qk=!1;class hle{constructor(e){this.parser=e,this.name=qh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Qk||(Qk=!0,Nt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=Vk(e,i[2]);return r||console.warn(qh+": Property binding not found",t,e,e.name,i),r}return s}return Vk(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return i?this.parser.getDependency("node",i):null}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[qh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=Ao.node,o;if(i){const c=t.extensions[qh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Ao.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Ao.light:l.startsWith("/cameras/")&&(r=Ao.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Ao.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case Ao.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case Ao.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case Ao.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(l=u.resolvePath(l)),t.extensions[qh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Ao.node?a=this.parser.getDependency("node",o):r===Ao.material?a=this.parser.getDependency("material",o):r===Ao.light?a=this.parser.getDependency("light",o):r===Ao.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[qh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[qh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof ku&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=sh;break;case 2:case 3:g=el;break;case 4:a.endsWith(".quaternion")?g=ja:g=w_;break}const A=s.interpolation!==void 0?lle[s.interpolation]:Wa;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],u=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);if(y||(y=t.loadAnimationTargetFromChannel(g)),y==null){console.warn("Failed to load animation target",g,y);continue}a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let D=0;D<T.length;D++)b.push(T[D])}return new tr(o,void 0,b)})}}const ule=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hle},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=Fce;exports.ActionBuilder=fi;exports.ActionCollection=IT;exports.ActionModel=Vr;exports.Addressables=pN;exports.AlignmentConstraint=OA;exports.AmbientMode=xf;exports.Animation=$r;exports.AnimationCurve=zu;exports.AnimationExtension=rx;exports.AnimationTrackHandler=_x;exports.Animator=ks;exports.AnimatorConditionMode=Hl;exports.AnimatorController=oh;exports.AnimatorControllerParameterType=RT;exports.AnimatorStateInfo=T0;exports.Antialiasing=jA;exports.Application=vN;exports.ApplicationEvents=gb;exports.AssetDatabase=CU;exports.AssetReference=Tn;exports.AttachedObject=Io;exports.AttachedObjectEvents=Mb;exports.AudioExtension=wx;exports.AudioListener=xu;exports.AudioSource=yn;exports.AudioTrackHandler=wu;exports.AvatarBlink_Simple=Hu;exports.AvatarEyeLook_Rotation=yp;exports.AvatarLoader=cx;exports.AvatarMarker=Jn;exports.AvatarModel=ax;exports.Avatar_Brain_LookAt=Vm;exports.Avatar_MouthShapes=XA;exports.Avatar_MustacheShake=hI;exports.Avatar_POI=ir;exports.Axes=lf;exports.AxesHelper=bp;exports.BaseUIComponent=aa;exports.BasicIKConstraint=fI;exports.BehaviorExtension=Cx;exports.BehaviorModel=ds;exports.Behaviour=Ie;exports.Bloom=Vu;exports.BoxCollider=YA;exports.BoxGizmo=Qu;exports.BoxHelperComponent=To;exports.Button=fl;exports.CallInfo=Wf;exports.Camera=Li;exports.Canvas=ps;exports.CanvasGroup=hh;exports.CapsuleCollider=lh;exports.ChangeMaterialOnClick=wp;exports.ChangeTransformOnClick=Xu;exports.CharacterController=qu;exports.CharacterControllerInput=gl;exports.ChromaticAberration=tv;exports.CircularBuffer=Xa;exports.ClearFlags=Ib;exports.ClipExtrapolation=Sa;exports.Collider=Za;exports.Collision=LG;exports.CollisionDetectionMode=lx;exports.ColorAdjustments=Sh;exports.ColorBySpeedModule=Yu;exports.ColorOverLifetimeModule=iv;exports.Component=Ah;exports.ComponentEvents=SA;exports.ComponentLifecycleEvents=CA;exports.ConnectionEvents=tU;exports.ContactPoint=kG;exports.Context=Ft;exports.ContextArgs=bY;exports.ContextEvent=Ks;exports.ContextRegistry=Oi;exports.ControlTrackHandler=xx;exports.ControllerEvents=Cc;exports.ControllerType=Ef;exports.CustomBranding=Th;exports.CustomShader=kr;exports.DefaultReflectionMode=pb;exports.Deletable=MI;exports.DeleteBox=Bx;exports.DepthOfField=pa;exports.DeviceFlag=Dx;exports.DocumentExtension=TI;exports.DragControls=Ip;exports.DropListener=sv;exports.Duplicatable=Zu;exports.EXTENSION_NAME=w0;exports.EmissionModule=ec;exports.EmphasizeOnClick=Cp;exports.EngineLoadingView=im;exports.EventList=us;exports.EventListEvent=ix;exports.EventSystem=$s;exports.EventTrigger=kx;exports.FieldWithDefault=ST;exports.FileSpawnModel=Zz;exports.File_Event=Jz;exports.FixedJoint=kI;exports.FlyControls=LI;exports.Fog=Rp;exports.FrameEvent=Tr;exports.GENERATOR=z_;exports.GameObject=ne;exports.Gizmos=zc;exports.GltfExport=ov;exports.GltfExportBox=NI;exports.GltfLoadEvent=Eu;exports.GltfLoadEventType=TG;exports.Gradient=Ch;exports.Graphic=Wu;exports.GraphicRaycaster=cI;exports.Graphics=Zo;exports.GridHelper=Pp;exports.GridLayoutGroup=_I;exports.GroundProjectedEnv=$u;exports.GroupActionModel=jl;exports.HideFlags=PU;exports.HideOnStart=wI;exports.HingeJoint=rv;exports.HorizontalLayoutGroup=bI;exports.HostData=J9;exports.Image=xp;exports.ImageReference=_f;exports.ImageReferenceSerializer=gN;exports.InheritVelocityModule=Mh;exports.Input=Z2;exports.InputEvents=Sn;exports.InputField=ed;exports.InstancingUtil=Sr;exports.InstantiateEvent=rU;exports.InstantiateIdProvider=Bs;exports.InstantiateOptions=qa;exports.Interactable=up;exports.JoinedRoomResponse=F9;exports.KeyEventArgs=Fj;exports.LODGroup=cv;exports.LODModel=td;exports.LeftRoomResponse=U9;exports.Light=Rr;exports.LightData=AN;exports.LimitVelocityOverLifetimeModule=Bn;exports.LoadingElementOptions=OY;exports.LogStats=GI;exports.LogType=Bo;exports.LookAt=id;exports.LookAtConstraint=LA;exports.MainModule=bs;exports.MarkerType=lI;exports.MaskableGraphic=ZA;exports.Mathf=tt;exports.MeshCollider=KA;exports.MeshRenderer=nx;exports.MinMaxCurve=ht;exports.MinMaxGradient=Ir;exports.NEEDLE_progressive=Hr;exports.NEKeyboardEvent=h0;exports.NEPointerEvent=wc;exports.NeedleEngine=Oi;exports.NeedleEngineHTMLElement=lR;exports.NeedleGltfLoader=oR;exports.NeedlePatchesKey=m0;exports.NestedGltf=Nx;exports.NetworkConnection=nU;exports.Networking=Ju;exports.NoiseModule=vi;exports.ObjectRaycaster=rl;exports.ObjectUtils=yG;exports.OffsetConstraint=nd;exports.OpenURL=Bp;exports.OrbitControls=Ji;exports.Outline=_p;exports.OwnershipEvent=iU;exports.OwnershipModel=N_;exports.Padding=_h;exports.ParticleBurst=eA;exports.ParticleSubEmitter=Xx;exports.ParticleSystem=In;exports.ParticleSystemRenderer=Go;exports.PeerNetworking=eU;exports.Physics=aF;exports.PhysicsMaterialCombine=wa;exports.PixelationEffect=uv;exports.PlayAnimationOnClick=wh;exports.PlayAudioOnClick=Ep;exports.PlayableDirector=Zc;exports.PlayerColor=Bu;exports.PlayerState=Cu;exports.PlayerStateEvent=CG;exports.PlayerSync=rw;exports.PlayerView=CN;exports.PlayerViewManager=EN;exports.PointerEventData=Gc;exports.PointerType=zf;exports.PostProcessingEffect=Us;exports.PostProcessingHandler=qx;exports.PreliminaryAction=Mp;exports.PreliminaryTrigger=$A;exports.PrimitiveType=ZI;exports.ProgressiveLoadingInfo=QN;exports.PromiseAllWithErrors=D_;exports.PromiseErrorResult=H2;exports.RGBAColor=bi;exports.RapierPhysics=eu;exports.RawImage=Mx;exports.RaycastOptions=ko;exports.Raycaster=mp;exports.Rect=AI;exports.RectTransform=rr;exports.ReflectionProbe=hp;exports.RegisteredAnimationInfo=sx;exports.RemoteSkybox=ol;exports.RenderTexture=Jl;exports.RenderTextureSerializer=XN;exports.Renderer=Qi;exports.RendererData=mN;exports.RendererLightmap=Hm;exports.Rigidbody=Ii;exports.RigidbodyConstraints=ln;exports.RoomEvents=on;exports.RotationBySpeedModule=so;exports.RotationOverLifetimeModule=zo;exports.SceneLightSettings=vb;exports.SceneSwitcher=ur;exports.ScreenCapture=fv;exports.ScreenSpaceAmbientOcclusion=Al;exports.ScreenSpaceAmbientOcclusionN8=ma;exports.SendQueue=Ar;exports.SetActiveOnClick=Sp;exports.ShadowCatcher=gv;exports.ShapeModule=bn;exports.SignalAsset=VA;exports.SignalReceiver=vp;exports.SignalReceiverEvent=Ap;exports.SignalTrackHandler=Zm;exports.Size=mI;exports.SizeBySpeedModule=lr;exports.SizeOverLifetimeModule=Eh;exports.SkinnedMeshRenderer=CT;exports.SmoothFollow=Ih;exports.SpatialHtml=$I;exports.SpatialTrigger=Av;exports.SpatialTriggerReceiver=Qa;exports.SpectatorCamera=Jx;exports.SphereCollider=qA;exports.SphereIntersection=oF;exports.SphereOverlapResult=FG;exports.Sprite=vl;exports.SpriteData=Lp;exports.SpriteRenderer=ic;exports.SpriteSheet=vv;exports.StateMachineBehaviour=NK;exports.SubEmitterSystem=oA;exports.SyncedCamera=Zx;exports.SyncedRoom=Rh;exports.SyncedTransform=ah;exports.TapGestureTrigger=SI;exports.TeleportTarget=vx;exports.TestRunner=eR;exports.TestSimulateUserData=tR;exports.Text=hr;exports.TextBuilder=Rx;exports.TextExtension=nv;exports.TextureSheetAnimationModule=_s;exports.TiltShiftEffect=nc;exports.Time=cF;exports.ToneMapping=bv;exports.TrackHandler=QA;exports.TrackType=Lr;exports.TrailModule=ji;exports.TransformData=Zl;exports.TransformGizmo=rd;exports.TriggerBuilder=Cr;exports.TriggerModel=Kc;exports.TypeStore=q;exports.UIRaycastUtils=Yf;exports.UIRootComponent=HA;exports.USDObject=_r;exports.USDZExporter=oo;exports.USDZText=Xl;exports.USDZUIExtension=Px;exports.Upload_Result=zE;exports.UriSerializer=qN;exports.UsageMarker=dp;exports.UserJoinedOrLeftRoomModel=N9;exports.VERSION=Nc;exports.VRUserState=ta;exports.VariantAction=TT;exports.VelocityOverLifetimeModule=Zi;exports.VerticalLayoutGroup=yI;exports.VideoPlayer=Ns;exports.ViewDevice=Va;exports.Vignette=od;exports.VisibilityAction=ev;exports.Voip=dl;exports.Volume=ew;exports.VolumeParameter=Rt;exports.VolumeProfile=WA;exports.WaitForFrames=woe;exports.WaitForSeconds=pG;exports.Watch=jc;exports.WebAR=Su;exports.WebARCameraBackground=tw;exports.WebARSessionRoot=ca;exports.WebXR=It;exports.WebXRAvatar=Ua;exports.WebXRController=sn;exports.WebXREvent=Mi;exports.WebXRImageTracking=iw;exports.WebXRImageTrackingModel=yl;exports.WebXRPlaneTracking=ad;exports.WebXRSync=tA;exports.WebXRTrackedImage=Oc;exports.XRFlag=jr;exports.XRGrabModel=sw;exports.XRGrabRendering=nR;exports.XRRig=Ix;exports.XRSessionMode=zm;exports.XRState=Zs;exports.XRStateFlag=fn;exports.__Ignore=sR;exports.__internalNotifyObjectDestroyed=RU;exports.activeInHierarchyFieldName=Yc;exports.addAttributeChangeCallback=z2;exports.addCustomExtension=G7;exports.addFile=$z;exports.addFileFromUrl=eG;exports.addGltfLoadEventListener=Sce;exports.addNewComponent=gh;exports.addPatch=X_;exports.apply=j_;exports.applyHMRChanges=Lce;exports.beginListenDestroy=cU;exports.beginListenFileSpawn=tG;exports.beginListenInstantiate=lU;exports.binaryIdentifierCasts=V1;exports.build_scene_functions=yY;exports.builtinComponentKeyName=nu;exports.calculateProgress01=vT;exports.colorSerializer=j7;exports.componentSerializer=S0;exports.copyTexture=rF;exports.createGLTFLoader=aR;exports.createMotion=l3;exports.debugNet=js;exports.debugOwner=Tg;exports.deepClone=B_;exports.delay=_A;exports.deserializeObject=hb;exports.destroy=tl;exports.destroyComponentInstance=gU;exports.detectARSupport=jz;exports.detectVRSupport=Xz;exports.disposeObjectResources=Si;exports.download=dN;exports.download_file=dT;exports.editorGuidKeyName=Kg;exports.effectsOrder=TM;exports.eventListSerializer=J7;exports.findByGuid=RA;exports.findObjectOfType=AU;exports.findObjectsOfType=vU;exports.findResourceUsers=iT;exports.foreachComponent=Ru;exports.foreachComponentEnumerator=sT;exports.forward=Wj;exports.generateSeed=V_;exports.getComponent=sp;exports.getComponentInChildren=MA;exports.getComponentInParent=Lm;exports.getComponents=EA;exports.getComponentsInChildren=TA;exports.getComponentsInParent=W_;exports.getIp=Aj;exports.getIpAndLocation=vj;exports.getIpCloudflare=mj;exports.getLoader=oa;exports.getOrAddComponent=Q_;exports.getParam=re;exports.getPath=uj;exports.getPeerOptions=D9;exports.getPeerjsInstance=Y1;exports.getResourceUserCount=I6;exports.getUrlParams=bA;exports.getWorldDirection=Xj;exports.getWorldEuler=tF;exports.getWorldPosition=Ct;exports.getWorldQuaternion=zn;exports.getWorldRotation=O_;exports.getWorldScale=ls;exports.hasIndieLicense=AT;exports.hasProLicense=wf;exports.hash=uT;exports.instantiate=PA;exports.isActiveInHierarchy=BU;exports.isActiveSelf=rp;exports.isAnimationAction=sF;exports.isDebugMode=cj;exports.isDestroyed=nT;exports.isDevEnvironment=ci;exports.isDisposed=M6;exports.isHostedOnGlitch=V2;exports.isHotReloading=Bce;exports.isLocalNetwork=nr;exports.isMobileDevice=cl;exports.isMozillaXR=tb;exports.isQuest=pj;exports.isResourceTrackingEnabled=MU;exports.isSafari=Rc;exports.isUsingInstancing=Y_;exports.isiOS=Dm;exports.loadSync=cR;exports.logHierarchy=sb;exports.lookAtInverse=Gj;exports.makeId=hj;exports.makeIdFromRandomWords=L2;exports.markAsInstancedRendered=DU;exports.moveComponentInstance=Z1;exports.nameof=aj;exports.nameofFactory=eb;exports.objectSerializer=jN;exports.parseSync=RG;exports.prefix=MJ;exports.pushState=O2;exports.randomNumber=k2;exports.registerBinaryType=F_;exports.registerComponent=tx;exports.registerComponentExtension=wT;exports.registerCustomEffectType=No;exports.registerExtensions=WN;exports.registerHotReloadType=Dce;exports.registerLoader=fT;exports.registerPrefabProvider=uU;exports.registerType=u6;exports.relativePathPrefix=U2;exports.removeAttributeChangeCallback=G2;exports.removeComponent=J1;exports.removeCustomExtension=H7;exports.removeGltfLoadEventListener=Cce;exports.removePatch=S6;exports.resolveUrl=al;exports.sanitizeString=F2;exports.saveImage=ele;exports.screenshot=$ce;exports.sendDestroyed=aU;exports.serializable=x;exports.serializeObject=_U;exports.serializeable=lp;exports.setActive=Zg;exports.setAllowOverlayMessages=bj;exports.setDestroyed=kU;exports.setDevEnvironment=Lj;exports.setDisposable=tT;exports.setOrAddParamsToUrl=Bm;exports.setParam=lj;exports.setParamWithoutReload=D2;exports.setPeerOptions=O9;exports.setResourceTrackingEnabled=E6;exports.setState=N1;exports.setWorldEuler=iF;exports.setWorldPosition=Mn;exports.setWorldPositionXYZ=Gf;exports.setWorldQuaternion=Mr;exports.setWorldQuaternionXYZW=eF;exports.setWorldRotation=nF;exports.setWorldRotationXYZ=k_;exports.setWorldScale=AE;exports.showBalloonError=kj;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ls;exports.showDebugConsole=G1;exports.slerp=$2;exports.syncDestroy=H_;exports.syncField=KI;exports.syncInstantiate=K1;exports.textureToCanvas=Yj;exports.tryCastBinary=lF;exports.tryFindObject=Nf;exports.tryFindObjectByName=BG;exports.tryFindScript=Mce;exports.tryGetGuid=hF;exports.unregisterHotReloadType=Oce;exports.unwatchWrite=N2;exports.upload_file=uN;exports.validate=ys;exports.watchWrite=z1;
|
|
6639
|
+
`,r)}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let t=0;t<this.children.length;t++){const i=this.children[t];if(i.classList.contains("vr"))return i}return null}onEnterAR(t,i){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,i,t),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:t,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(t){var i;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:t,context:this._context,htmlContainer:(i=this._overlay_ar)==null?void 0:i.ARContainer}}))}onEnterVR(t){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:t,context:this._context}}))}onExitVR(t){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:t,context:this._context}}))}onSetupAR(){this.classList.add(mg),this.classList.remove(Ag);const t=this.getAROverlayContainer();ns&&console.warn("onSetupAR:",t),t&&(t.classList.add(mg),t.classList.remove(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,MN))}onSetupVR(){this.classList.remove(mg),this.classList.remove(Ag),this.foreachHtmlElement(t=>this.setupElementsForMode(t,DG))}onSetupDesktop(){this.classList.remove(mg),this.classList.add(Ag);const t=this.getAROverlayContainer();t&&(t.classList.remove(mg),t.classList.add(Ag)),this.foreachHtmlElement(i=>this.setupElementsForMode(i,OG))}setupElementsForMode(t,i,s=null){var o,a;if(t===((a=(o=this._context)==null?void 0:o.renderer)==null?void 0:a.domElement)||t.id==="VRButton"||t.id==="ARButton")return;if(t.classList.contains(i))t.style.visibility="visible",t.style.display==="none"&&(t.style.display="block");else for(const c of Tce)t.classList.contains(c)&&(t.style.visibility="hidden",t.style.display="none")}foreachHtmlElement(t){for(let i=0;i<this.children.length;i++){const s=this.children[i];s.style&&t(s)}}onBeforeBeginLoading(){const t=this.getAttribute("dracoDecoderPath");t&&(ns&&console.log("using custom draco decoder path",t),CD(t));const i=this.getAttribute("dracoDecoderType");i&&(ns&&console.log("using custom draco decoder type",i),ED(i));const s=this.getAttribute("ktx2DecoderPath");s&&(ns&&console.log("using custom ktx2 decoder path",s),MD(s))}}typeof window<"u"&&!window.customElements.get(Rk)&&window.customElements.define(Rk,lR);function Rce(n){const e=n.split("/");let t=e[e.length-1];const i=t.indexOf("?");return i>0&&(t=t.substring(0,i)),decodeURIComponent(t)}const Pce=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:lR},Symbol.toStringTag,{value:"Module"})),V0=re("debughotreload");let aA=!1;const hm=new Map;function Bce(){return aA}function Dce(n){var i;if(aA)return;const t=n.constructor.name;hm.has(t)?(i=hm.get(t))==null||i.push(n):hm.set(t,[n])}function Oce(n){if(aA)return;const t=n.constructor.name,i=hm.get(t);if(!i)return;const s=i.indexOf(n);s!==-1&&i.splice(s,1)}let Pk=!1;function kce(){if(V0||Pk)return;Pk=!0;const n=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}n.apply(console,e)}}function Lce(n){V0&&console.log("[HMR] Apply changes",n,Object.keys(n)),kce();for(const e of Object.keys(n))try{aA=!0;const t=q.get(e);if(!t){V0&&console.log("[HMR] Type not found: "+e);continue}const i=n[e],s=hm.get(i.name);let r="[Needle Engine] Updating type: "+e;const o=(s==null?void 0:s.length)??-1;o>0?r+=" x"+o:r+=" - no instances",console.log(r);const a=Object.getOwnPropertyNames(t.prototype),c=Object.getOwnPropertyDescriptors(i.prototype);for(const l in c)c[l].writable&&(t.prototype[l]=n[e].prototype[l]);for(const l of a)c[l]||delete t.prototype[l];if(s){const l=new i,u=Object.getOwnPropertyDescriptors(l);for(const d of s){const f=d,p=f.isComponent===!0,g=p?f.activeAndEnabled:!0,A=p?f.context:void 0;try{if(p&&Bc(f,A),p&&g&&(f.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=l[v];else if(typeof d[v]=="function"&&!d[v].prototype){const b=d[v],y=b.name,_="bound ";if(y===_)continue;const C=b.name.substring(_.length),M=i.prototype[C];M&&(d[v]=M.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{p&&rT(f,A),p&&g&&(f.enabled=!0)}}}}catch(t){if(V0)console.error(t);else return!1}finally{aA=!1,Xc(Bo.Log,"Script changes applied (HMR)")}return!0}const Fce=Symbol("object"),Bk=new Xa(()=>new w,20);class kG{constructor(e,t,i,s,r){h(this,"_point");h(this,"_normal");h(this,"distance");h(this,"impulse");h(this,"friction");this._point=e,this.distance=t,this._normal=i,this.impulse=s,this.friction=r}get point(){return Bk.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return Bk.get().set(this._normal.x,this._normal.y,this._normal.z)}}class LG{constructor(e,t,i){h(this,"contacts");h(this,"me");h(this,"_collider");h(this,"_gameObject");this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=i}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class FG{constructor(e,t){h(this,"object");h(this,"collider");this.object=e,this.collider=t}}let Ne;const cA=new Array(32).fill(void 0);cA.push(void 0,null,!0,!1);let Dk;cA.length;function Ok(){return Dk.byteLength,Dk}const Uce=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function vt(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`);return n.ptr}Uce.decode();let kk,Lk,um=32;function Fk(n){if(um==1)throw new Error("out of js stack");return cA[--um]=n,um}function Nce(){return kk.byteLength,kk}function zce(){return Lk.byteLength,Lk}let Fr=0;function Xh(n,e){const t=e(4*n.length);return Nce().set(n,t/4),Fr=n.length,t}function $y(n,e){const t=e(4*n.length);return zce().set(n,t/4),Fr=n.length,t}class kb{static __wrap(e){const t=Object.create(kb.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_raweventqueue_free(e)}constructor(e){const t=Ne.raweventqueue_new(e);return kb.__wrap(t)}drainCollisionEvents(e){try{Ne.raweventqueue_drainCollisionEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}drainContactForceEvents(e){try{Ne.raweventqueue_drainContactForceEvents(this.ptr,Fk(e))}finally{cA[um++]=void 0}}clear(){Ne.raweventqueue_clear(this.ptr)}}class Oa{static __wrap(e){const t=Object.create(Oa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawgenericjoint_free(e)}static spherical(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawgenericjoint_spherical(e.ptr,t.ptr);return Oa.__wrap(i)}static prismatic(e,t,i,s,r,o){vt(e,ft),vt(t,ft),vt(i,ft);const a=Ne.rawgenericjoint_prismatic(e.ptr,t.ptr,i.ptr,s,r,o);return a===0?void 0:Oa.__wrap(a)}static fixed(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,qn);const r=Ne.rawgenericjoint_fixed(e.ptr,t.ptr,i.ptr,s.ptr);return Oa.__wrap(r)}static revolute(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawgenericjoint_revolute(e.ptr,t.ptr,i.ptr);return s===0?void 0:Oa.__wrap(s)}}class hR{static __wrap(e){const t=Object.create(hR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawpointprojection_free(e)}point(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}isInside(){return Ne.rawpointprojection_isInside(this.ptr)!==0}}class uR{static __wrap(e){const t=Object.create(uR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrayintersection_free(e)}normal(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}featureType(){return Ne.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const i=Ne.__wbindgen_add_to_stack_pointer(-16);Ne.rawrayintersection_featureId(i,this.ptr);var e=Ok()[i/4+0],t=Ok()[i/4+1];return e===0?void 0:t>>>0}finally{Ne.__wbindgen_add_to_stack_pointer(16)}}}class qn{static __wrap(e){const t=Object.create(qn.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawrotation_free(e)}constructor(e,t,i,s){const r=Ne.rawrotation_new(e,t,i,s);return qn.__wrap(r)}static identity(){const e=Ne.rawrotation_identity();return qn.__wrap(e)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}get y(){return Ne.rawrotation_y(this.ptr)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}get w(){return Ne.rawrotation_w(this.ptr)}}class Gt{static __wrap(e){const t=Object.create(Gt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshape_free(e)}static cuboid(e,t,i){const s=Ne.rawshape_cuboid(e,t,i);return Gt.__wrap(s)}static roundCuboid(e,t,i,s){const r=Ne.rawshape_roundCuboid(e,t,i,s);return Gt.__wrap(r)}static ball(e){const t=Ne.rawshape_ball(e);return Gt.__wrap(t)}static capsule(e,t){const i=Ne.rawshape_capsule(e,t);return Gt.__wrap(i)}static cylinder(e,t){const i=Ne.rawshape_cylinder(e,t);return Gt.__wrap(i)}static roundCylinder(e,t,i){const s=Ne.rawshape_roundCylinder(e,t,i);return Gt.__wrap(s)}static cone(e,t){const i=Ne.rawshape_cone(e,t);return Gt.__wrap(i)}static roundCone(e,t,i){const s=Ne.rawshape_roundCone(e,t,i);return Gt.__wrap(s)}static polyline(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_polyline(i,s,r,o);return Gt.__wrap(a)}static trimesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_trimesh(i,s,r,o);return Gt.__wrap(a)}static heightfield(e,t,i,s){const r=Xh(i,Ne.__wbindgen_malloc),o=Fr;vt(s,ft);const a=Ne.rawshape_heightfield(e,t,r,o,s.ptr);return Gt.__wrap(a)}static segment(e,t){vt(e,ft),vt(t,ft);const i=Ne.rawshape_segment(e.ptr,t.ptr);return Gt.__wrap(i)}static triangle(e,t,i){vt(e,ft),vt(t,ft),vt(i,ft);const s=Ne.rawshape_triangle(e.ptr,t.ptr,i.ptr);return Gt.__wrap(s)}static roundTriangle(e,t,i,s){vt(e,ft),vt(t,ft),vt(i,ft);const r=Ne.rawshape_roundTriangle(e.ptr,t.ptr,i.ptr,s);return Gt.__wrap(r)}static convexHull(e){const t=Xh(e,Ne.__wbindgen_malloc),i=Fr,s=Ne.rawshape_convexHull(t,i);return s===0?void 0:Gt.__wrap(s)}static roundConvexHull(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=Ne.rawshape_roundConvexHull(i,s,t);return r===0?void 0:Gt.__wrap(r)}static convexMesh(e,t){const i=Xh(e,Ne.__wbindgen_malloc),s=Fr,r=$y(t,Ne.__wbindgen_malloc),o=Fr,a=Ne.rawshape_convexMesh(i,s,r,o);return a===0?void 0:Gt.__wrap(a)}static roundConvexMesh(e,t,i){const s=Xh(e,Ne.__wbindgen_malloc),r=Fr,o=$y(t,Ne.__wbindgen_malloc),a=Fr,c=Ne.rawshape_roundConvexMesh(s,r,o,a,i);return c===0?void 0:Gt.__wrap(c)}castShape(e,t,i,s,r,o,a,c){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,Gt),vt(r,ft),vt(o,qn),vt(a,ft);const l=Ne.rawshape_castShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o.ptr,a.ptr,c);return l===0?void 0:fR.__wrap(l)}intersectsShape(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn),Ne.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr)!==0}contactShape(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,Gt),vt(s,ft),vt(r,qn);const a=Ne.rawshape_contactShape(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r.ptr,o);return a===0?void 0:dR.__wrap(a)}containsPoint(e,t,i){return vt(e,ft),vt(t,qn),vt(i,ft),Ne.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,i.ptr)!==0}projectPoint(e,t,i,s){vt(e,ft),vt(t,qn),vt(i,ft);const r=Ne.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,i.ptr,s);return hR.__wrap(r)}intersectsRay(e,t,i,s,r){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r)!==0}castRay(e,t,i,s,r,o){return vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft),Ne.rawshape_castRay(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o)}castRayAndGetNormal(e,t,i,s,r,o){vt(e,ft),vt(t,qn),vt(i,ft),vt(s,ft);const a=Ne.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,i.ptr,s.ptr,r,o);return a===0?void 0:uR.__wrap(a)}}class dR{static __wrap(e){const t=Object.create(dR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapecontact_free(e)}distance(){return Ne.rawshapecontact_distance(this.ptr)}point1(){const e=Ne.rawpointprojection_point(this.ptr);return ft.__wrap(e)}point2(){const e=Ne.rawshapecontact_point2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapecontact_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapecontact_normal2(this.ptr);return ft.__wrap(e)}}class fR{static __wrap(e){const t=Object.create(fR.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawshapetoi_free(e)}toi(){return Ne.rawintegrationparameters_dt(this.ptr)}witness1(){const e=Ne.rawrayintersection_normal(this.ptr);return ft.__wrap(e)}witness2(){const e=Ne.rawshapetoi_witness2(this.ptr);return ft.__wrap(e)}normal1(){const e=Ne.rawshapetoi_normal1(this.ptr);return ft.__wrap(e)}normal2(){const e=Ne.rawshapetoi_normal2(this.ptr);return ft.__wrap(e)}}class ft{static __wrap(e){const t=Object.create(ft.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();Ne.__wbg_rawvector_free(e)}static zero(){const e=Ne.rawvector_zero();return ft.__wrap(e)}constructor(e,t,i){const s=Ne.rawvector_new(e,t,i);return ft.__wrap(s)}get x(){return Ne.rawintegrationparameters_dt(this.ptr)}set x(e){Ne.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return Ne.rawrotation_y(this.ptr)}set y(e){Ne.rawvector_set_y(this.ptr,e)}get z(){return Ne.rawintegrationparameters_erp(this.ptr)}set z(e){Ne.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=Ne.rawvector_xyz(this.ptr);return ft.__wrap(e)}yxz(){const e=Ne.rawvector_yxz(this.ptr);return ft.__wrap(e)}zxy(){const e=Ne.rawvector_zxy(this.ptr);return ft.__wrap(e)}xzy(){const e=Ne.rawvector_xzy(this.ptr);return ft.__wrap(e)}yzx(){const e=Ne.rawvector_yzx(this.ptr);return ft.__wrap(e)}zyx(){const e=Ne.rawvector_zyx(this.ptr);return ft.__wrap(e)}}class Gce{constructor(e,t,i){this.x=e,this.y=t,this.z=i}}class Re{static new(e,t,i){return new Gce(e,t,i)}static intoRaw(e){return new ft(e.x,e.y,e.z)}static zeros(){return Re.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=Re.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class Uk{constructor(e,t,i,s){this.x=e,this.y=t,this.z=i,this.w=s}}class Di{static identity(){return new Uk(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new Uk(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new qn(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var dm,Ca,Nk,Eo,OM,Zt,Lb,uf,kM,LM,zk,Gk;(function(n){n[n.Dynamic=0]="Dynamic",n[n.Fixed=1]="Fixed",n[n.KinematicPositionBased=2]="KinematicPositionBased",n[n.KinematicVelocityBased=3]="KinematicVelocityBased"})(dm||(dm={}));class Hce{constructor(e,t,i){this.rawSet=e,this.colliderSet=t,this.handle=i}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,i,s){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,i,s)}restrictTranslations(e,t,i,s){this.setEnabledTranslations(e,t,i,s)}setEnabledRotations(e,t,i,s){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,i,s)}restrictRotations(e,t,i,s){this.setEnabledRotations(e,t,i,s)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return Re.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Di.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return Re.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Di.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,i,t),i.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let i=Re.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,i,t),i.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return Re.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return Re.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,i,s,r){let o=Re.intoRaw(t),a=Re.intoRaw(i),c=Di.intoRaw(s);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,c,r),o.free(),a.free(),c.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddForce(this.handle,i,t),i.free()}applyImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,i,t),i.free()}addTorque(e,t){const i=Re.intoRaw(e);this.rawSet.rbAddTorque(this.handle,i,t),i.free()}applyTorqueImpulse(e,t){const i=Re.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,i,t),i.free()}addForceAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,s,r,i),s.free(),r.free()}applyImpulseAtPoint(e,t,i){const s=Re.intoRaw(e),r=Re.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,s,r,i),s.free(),r.free()}}(function(n){n[n.Revolute=0]="Revolute",n[n.Fixed=1]="Fixed",n[n.Prismatic=2]="Prismatic",n[n.Spherical=3]="Spherical"})(Ca||(Ca={})),function(n){n[n.AccelerationBased=0]="AccelerationBased",n[n.ForceBased=1]="ForceBased"}(Nk||(Nk={}));class df{constructor(){}static fixed(e,t,i,s){let r=new df;return r.anchor1=e,r.anchor2=i,r.frame1=t,r.frame2=s,r.jointType=Ca.Fixed,r}static spherical(e,t){let i=new df;return i.anchor1=e,i.anchor2=t,i.jointType=Ca.Spherical,i}static prismatic(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Prismatic,s}static revolute(e,t,i){let s=new df;return s.anchor1=e,s.anchor2=t,s.axis=i,s.jointType=Ca.Revolute,s}intoRaw(){let e,t,i=Re.intoRaw(this.anchor1),s=Re.intoRaw(this.anchor2),r=!1,o=0,a=0;switch(this.jointType){case Ca.Fixed:let c=Di.intoRaw(this.frame1),l=Di.intoRaw(this.frame2);t=Oa.fixed(i,c,s,l),c.free(),l.free();break;case Ca.Prismatic:e=Re.intoRaw(this.axis),this.limitsEnabled&&(r=!0,o=this.limits[0],a=this.limits[1]),t=Oa.prismatic(i,s,e,r,o,a),e.free();break;case Ca.Spherical:t=Oa.spherical(i,s);break;case Ca.Revolute:e=Re.intoRaw(this.axis),t=Oa.revolute(i,s,e),e.free()}return i.free(),s.free(),t}}(function(n){n[n.Average=0]="Average",n[n.Min=1]="Min",n[n.Multiply=2]="Multiply",n[n.Max=3]="Max"})(Eo||(Eo={}));class lA{constructor(e,t,i,s,r){this.distance=e,this.point1=t,this.point2=i,this.normal1=s,this.normal2=r}static fromRaw(e){if(!e)return null;const t=new lA(e.distance(),Re.fromRaw(e.point1()),Re.fromRaw(e.point2()),Re.fromRaw(e.normal1()),Re.fromRaw(e.normal2()));return e.free(),t}}(function(n){n[n.Vertex=0]="Vertex",n[n.Edge=1]="Edge",n[n.Face=2]="Face",n[n.Unknown=3]="Unknown"})(OM||(OM={}));class ow{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new ow(Re.fromRaw(e.point()),e.isInside());return e.free(),t}}class Vce{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class aw{constructor(e,t,i,s){this.featureType=OM.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,s!==void 0&&(this.featureId=s),i!==void 0&&(this.featureType=i)}static fromRaw(e){if(!e)return null;const t=new aw(e.toi(),Re.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class _v{constructor(e,t,i,s,r){this.toi=e,this.witness1=t,this.witness2=i,this.normal1=s,this.normal2=r}static fromRaw(e,t){if(!t)return null;const i=new _v(t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class pR extends _v{constructor(e,t,i,s,r,o){super(t,i,s,r,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const i=new pR(e.get(t.colliderHandle()),t.toi(),Re.fromRaw(t.witness1()),Re.fromRaw(t.witness2()),Re.fromRaw(t.normal1()),Re.fromRaw(t.normal2()));return t.free(),i}}class xs{static fromRaw(e,t){const i=e.coShapeType(t);let s,r,o,a,c,l;switch(i){case Zt.Ball:return new gR(e.coRadius(t));case Zt.Cuboid:return s=e.coHalfExtents(t),new UG(s.x,s.y,s.z);case Zt.RoundCuboid:return s=e.coHalfExtents(t),r=e.coRoundRadius(t),new NG(s.x,s.y,s.z,r);case Zt.Capsule:return c=e.coHalfHeight(t),l=e.coRadius(t),new zG(c,l);case Zt.Segment:return o=e.coVertices(t),new GG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]));case Zt.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new QG(o,a);case Zt.Triangle:return o=e.coVertices(t),new HG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]));case Zt.RoundTriangle:return o=e.coVertices(t),r=e.coRoundRadius(t),new VG(Re.new(o[0],o[1],o[2]),Re.new(o[3],o[4],o[5]),Re.new(o[6],o[7],o[8]),r);case Zt.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new WG(o,a);case Zt.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),f=e.coHeightfieldNRows(t),p=e.coHeightfieldNCols(t);return new jG(f,p,d,u);case Zt.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new FM(o,a);case Zt.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),r=e.coRoundRadius(t),new UM(o,a,r);case Zt.Cylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),new XG(c,l);case Zt.RoundCylinder:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new qG(c,l,r);case Zt.Cone:return c=e.coHalfHeight(t),l=e.coRadius(t),new YG(c,l);case Zt.RoundCone:return c=e.coHalfHeight(t),l=e.coRadius(t),r=e.coRoundRadius(t),new KG(c,l,r);default:throw new Error("unknown shape type: "+i)}}castShape(e,t,i,s,r,o,a,c){let l=Re.intoRaw(e),u=Di.intoRaw(t),d=Re.intoRaw(i),f=Re.intoRaw(r),p=Di.intoRaw(o),g=Re.intoRaw(a),A=this.intoRaw(),v=s.intoRaw(),m=_v.fromRaw(null,A.castShape(l,u,d,v,f,p,g,c));return l.free(),u.free(),d.free(),f.free(),p.free(),g.free(),A.free(),v.free(),m}intersectsShape(e,t,i,s,r){let o=Re.intoRaw(e),a=Di.intoRaw(t),c=Re.intoRaw(s),l=Di.intoRaw(r),u=this.intoRaw(),d=i.intoRaw(),f=u.intersectsShape(o,a,d,c,l);return o.free(),a.free(),c.free(),l.free(),u.free(),d.free(),f}contactShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Di.intoRaw(t),l=Re.intoRaw(s),u=Di.intoRaw(r),d=this.intoRaw(),f=i.intoRaw(),p=lA.fromRaw(d.contactShape(a,c,f,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f.free(),p}containsPoint(e,t,i){let s=Re.intoRaw(e),r=Di.intoRaw(t),o=Re.intoRaw(i),a=this.intoRaw(),c=a.containsPoint(s,r,o);return s.free(),r.free(),o.free(),a.free(),c}projectPoint(e,t,i,s){let r=Re.intoRaw(e),o=Di.intoRaw(t),a=Re.intoRaw(i),c=this.intoRaw(),l=ow.fromRaw(c.projectPoint(r,o,a,s));return r.free(),o.free(),a.free(),c.free(),l}intersectsRay(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=Re.intoRaw(e.origin),c=Re.intoRaw(e.dir),l=this.intoRaw(),u=l.intersectsRay(r,o,a,c,s);return r.free(),o.free(),a.free(),c.free(),l.free(),u}castRay(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,c,l,s,r);return o.free(),a.free(),c.free(),l.free(),u.free(),d}castRayAndGetNormal(e,t,i,s,r){let o=Re.intoRaw(t),a=Di.intoRaw(i),c=Re.intoRaw(e.origin),l=Re.intoRaw(e.dir),u=this.intoRaw(),d=aw.fromRaw(u.castRayAndGetNormal(o,a,c,l,s,r));return o.free(),a.free(),c.free(),l.free(),u.free(),d}}(function(n){n[n.Ball=0]="Ball",n[n.Cuboid=1]="Cuboid",n[n.Capsule=2]="Capsule",n[n.Segment=3]="Segment",n[n.Polyline=4]="Polyline",n[n.Triangle=5]="Triangle",n[n.TriMesh=6]="TriMesh",n[n.HeightField=7]="HeightField",n[n.ConvexPolyhedron=9]="ConvexPolyhedron",n[n.Cylinder=10]="Cylinder",n[n.Cone=11]="Cone",n[n.RoundCuboid=12]="RoundCuboid",n[n.RoundTriangle=13]="RoundTriangle",n[n.RoundCylinder=14]="RoundCylinder",n[n.RoundCone=15]="RoundCone",n[n.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(Zt||(Zt={}));class gR extends xs{constructor(e){super(),this.type=Zt.Ball,this.radius=e}intoRaw(){return Gt.ball(this.radius)}}class UG extends xs{constructor(e,t,i){super(),this.type=Zt.Cuboid,this.halfExtents=Re.new(e,t,i)}intoRaw(){return Gt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class NG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundCuboid,this.halfExtents=Re.new(e,t,i),this.borderRadius=s}intoRaw(){return Gt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class zG extends xs{constructor(e,t){super(),this.type=Zt.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.capsule(this.halfHeight,this.radius)}}class GG extends xs{constructor(e,t){super(),this.type=Zt.Segment,this.a=e,this.b=t}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Gt.segment(e,t);return e.free(),t.free(),i}}class HG extends xs{constructor(e,t,i){super(),this.type=Zt.Triangle,this.a=e,this.b=t,this.c=i}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.triangle(e,t,i);return e.free(),t.free(),i.free(),s}}class VG extends xs{constructor(e,t,i,s){super(),this.type=Zt.RoundTriangle,this.a=e,this.b=t,this.c=i,this.borderRadius=s}intoRaw(){let e=Re.intoRaw(this.a),t=Re.intoRaw(this.b),i=Re.intoRaw(this.c),s=Gt.roundTriangle(e,t,i,this.borderRadius);return e.free(),t.free(),i.free(),s}}class QG extends xs{constructor(e,t){super(),this.type=Zt.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Gt.polyline(this.vertices,this.indices)}}class WG extends xs{constructor(e,t){super(),this.type=Zt.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Gt.trimesh(this.vertices,this.indices)}}class FM extends xs{constructor(e,t){super(),this.type=Zt.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Gt.convexMesh(this.vertices,this.indices):Gt.convexHull(this.vertices)}}class UM extends xs{constructor(e,t,i){super(),this.type=Zt.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=i}intoRaw(){return this.indices?Gt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Gt.roundConvexHull(this.vertices,this.borderRadius)}}class jG extends xs{constructor(e,t,i,s){super(),this.type=Zt.HeightField,this.nrows=e,this.ncols=t,this.heights=i,this.scale=s}intoRaw(){let e=Re.intoRaw(this.scale),t=Gt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class XG extends xs{constructor(e,t){super(),this.type=Zt.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cylinder(this.halfHeight,this.radius)}}class qG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCylinder,this.borderRadius=i,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class YG extends xs{constructor(e,t){super(),this.type=Zt.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Gt.cone(this.halfHeight,this.radius)}}class KG extends xs{constructor(e,t,i){super(),this.type=Zt.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=i}intoRaw(){return Gt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(n){n[n.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",n[n.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",n[n.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",n[n.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",n[n.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",n[n.FIXED_FIXED=32]="FIXED_FIXED",n[n.DEFAULT=15]="DEFAULT",n[n.ALL=60943]="ALL"})(Lb||(Lb={}));class Qce{constructor(e,t,i,s){this.colliderSet=e,this.handle=t,this._parent=i,this._shape=s}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=xs.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return Re.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Di.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,i,s){let r=Re.intoRaw(t),o=Re.intoRaw(i),a=Di.intoRaw(s);this.colliderSet.raw.coSetMassProperties(this.handle,e,r,o,a),r.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return Re.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return Re.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=Re.intoRaw(e),i=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),i}projectPoint(e,t){let i=Re.intoRaw(e),s=ow.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,i,t));return i.free(),s}intersectsRay(e,t){let i=Re.intoRaw(e.origin),s=Re.intoRaw(e.dir),r=this.colliderSet.raw.coIntersectsRay(this.handle,i,s,t);return i.free(),s.free(),r}castShape(e,t,i,s,r,o){let a=Re.intoRaw(e),c=Re.intoRaw(i),l=Di.intoRaw(s),u=Re.intoRaw(r),d=t.intoRaw(),f=_v.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,c,l,u,o));return a.free(),c.free(),l.free(),u.free(),d.free(),f}castCollider(e,t,i,s){let r=Re.intoRaw(e),o=Re.intoRaw(i),a=pR.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,r,t.handle,o,s));return r.free(),o.free(),a}intersectsShape(e,t,i){let s=Re.intoRaw(t),r=Di.intoRaw(i),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,s,r);return s.free(),r.free(),o.free(),a}contactShape(e,t,i,s){let r=Re.intoRaw(t),o=Di.intoRaw(i),a=e.intoRaw(),c=lA.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,r,o,s));return r.free(),o.free(),a.free(),c}contactCollider(e,t){return lA.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,s,r,t,i);return s.free(),r.free(),o}castRayAndGetNormal(e,t,i){let s=Re.intoRaw(e.origin),r=Re.intoRaw(e.dir),o=aw.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,s,r,t,i));return s.free(),r.free(),o}}(function(n){n[n.Density=0]="Density",n[n.Mass=1]="Mass",n[n.MassProps=2]="MassProps"})(uf||(uf={}));class Hi{constructor(e){this.shape=e,this.massPropsMode=uf.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Di.identity(),this.translation=Re.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Eo.Average,this.restitutionCombineRule=Eo.Average,this.activeCollisionTypes=Lb.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=Re.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=Re.zeros(),this.angularInertiaLocalFrame=Di.identity()}static ball(e){const t=new gR(e);return new Hi(t)}static capsule(e,t){const i=new zG(e,t);return new Hi(i)}static segment(e,t){const i=new GG(e,t);return new Hi(i)}static triangle(e,t,i){const s=new HG(e,t,i);return new Hi(s)}static roundTriangle(e,t,i,s){const r=new VG(e,t,i,s);return new Hi(r)}static polyline(e,t){const i=new QG(e,t);return new Hi(i)}static trimesh(e,t){const i=new WG(e,t);return new Hi(i)}static cuboid(e,t,i){const s=new UG(e,t,i);return new Hi(s)}static roundCuboid(e,t,i,s){const r=new NG(e,t,i,s);return new Hi(r)}static heightfield(e,t,i,s){const r=new jG(e,t,i,s);return new Hi(r)}static cylinder(e,t){const i=new XG(e,t);return new Hi(i)}static roundCylinder(e,t,i){const s=new qG(e,t,i);return new Hi(s)}static cone(e,t){const i=new YG(e,t);return new Hi(i)}static roundCone(e,t,i){const s=new KG(e,t,i);return new Hi(s)}static convexHull(e){const t=new FM(e,null);return new Hi(t)}static convexMesh(e,t){const i=new FM(e,t);return new Hi(i)}static roundConvexHull(e,t){const i=new UM(e,null,t);return new Hi(i)}static roundConvexMesh(e,t,i){const s=new UM(e,t,i);return new Hi(s)}setTranslation(e,t,i){if(typeof e!="number"||typeof t!="number"||typeof i!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:i},this}setRotation(e){return Di.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=uf.Density,this.density=e,this}setMass(e){return this.massPropsMode=uf.Mass,this.mass=e,this}setMassProperties(e,t,i,s){return this.massPropsMode=uf.MassProps,this.mass=e,Re.copy(this.centerOfMass,t),Re.copy(this.principalAngularInertia,i),Di.copy(this.angularInertiaLocalFrame,s),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(n){n[n.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",n[n.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",n[n.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",n[n.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",n[n.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",n[n.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",n[n.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",n[n.ONLY_FIXED=6]="ONLY_FIXED"})(kM||(kM={}));(function(n){n[n.COLLISION_EVENTS=1]="COLLISION_EVENTS",n[n.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"})(LM||(LM={}));class Wce{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return Re.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return Re.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class jce{constructor(e,t){this.raw=t||new kb(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new Wce;this.raw.drainContactForceEvents(i=>{t.raw=i,e(t),t.free()})}clear(){this.raw.clear()}}(function(n){n[n.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",n[n.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(zk||(zk={})),function(n){n[n.EMPTY=0]="EMPTY",n[n.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(Gk||(Gk={}));for(var Hle={byteLength:function(n){var e=Hk(n),t=e[0],i=e[1];return 3*(t+i)/4-i},toByteArray:function(n){var e,t,i=Hk(n),s=i[0],r=i[1],o=new Xce(function(l,u,d){return 3*(u+d)/4-d}(0,s,r)),a=0,c=r>0?s-4:s;for(t=0;t<c;t+=4)e=bo[n.charCodeAt(t)]<<18|bo[n.charCodeAt(t+1)]<<12|bo[n.charCodeAt(t+2)]<<6|bo[n.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return r===2&&(e=bo[n.charCodeAt(t)]<<2|bo[n.charCodeAt(t+1)]>>4,o[a++]=255&e),r===1&&(e=bo[n.charCodeAt(t)]<<10|bo[n.charCodeAt(t+1)]<<4|bo[n.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(n){for(var e,t=n.length,i=t%3,s=[],r=16383,o=0,a=t-i;o<a;o+=r)s.push(Yce(n,o,o+r>a?a:o+r));return i===1?(e=n[t-1],s.push(Ra[e>>2]+Ra[e<<4&63]+"==")):i===2&&(e=(n[t-2]<<8)+n[t-1],s.push(Ra[e>>10]+Ra[e>>4&63]+Ra[e<<2&63]+"=")),s.join("")}},Ra=[],bo=[],Xce=typeof Uint8Array<"u"?Uint8Array:Array,vC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Hd=0,qce=vC.length;Hd<qce;++Hd)Ra[Hd]=vC[Hd],bo[vC.charCodeAt(Hd)]=Hd;function Hk(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Yce(n,e,t){for(var i,s,r=[],o=e;o<t;o+=3)i=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(255&n[o+2]),r.push(Ra[(s=i)>>18&63]+Ra[s>>12&63]+Ra[s>>6&63]+Ra[63&s]);return r.join("")}bo["-".charCodeAt(0)]=62,bo["_".charCodeAt(0)]=63;const Qs=re("debugphysics"),yC=re("debugcolliderplacement"),bC=re("debugcollisions"),Kce=re("showcolliders"),Ur=Symbol("needle component"),Or=Symbol("physics body"),Jce=Symbol("rigidbody");let Vd;globalThis.false=globalThis.false!==void 0?globalThis.false:!0;Qs&&console.log("Use Rapier",!1,globalThis.false);const ym=class{constructor(){h(this,"debugRenderColliders",!1);h(this,"context");h(this,"_initializePromise");h(this,"_isInitialized",!1);h(this,"rapierRay",new Vce({x:0,y:0,z:0},{x:0,y:0,z:1}));h(this,"raycastVectorsBuffer",new Xa(()=>new w,10));h(this,"rapierSphere",null);h(this,"rapierColliderArray",[]);h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1});h(this,"rapierForwardVector",{x:0,y:0,z:1});h(this,"enabled",!1);h(this,"_tempPosition",new w);h(this,"_tempQuaternion",new we);h(this,"_tempScale",new w);h(this,"_tempMatrix",new Me);h(this,"_isUpdatingPhysicsWorld",!1);h(this,"_world");h(this,"_hasCreatedWorld",!1);h(this,"eventQueue");h(this,"collisionHandler");h(this,"objects",[]);h(this,"bodies",[]);h(this,"_meshCache",new Map);h(this,"_gravity",{x:0,y:-9.81,z:0});h(this,"lines")}removeBody(e){var i,s,r;if(!e)return;this.validate();const t=e[Or];if(e[Or]=null,t&&this.world){const o=this.objects.findIndex(a=>a===e);if(o>=0){const a=this.bodies[o];if(this.bodies.splice(o,1),this.objects.splice(o,1),a instanceof Qce){const c=a;(i=this.world)==null||i.removeCollider(c,!0);const l=c.parent();l&&l.numColliders()<=0&&(l[Ur]||(s=this.world)==null||s.removeRigidBody(l))}else a instanceof Hce&&(a.numColliders()<=0?(r=this.world)==null||r.removeRigidBody(a):ci()&&(a.did_log_removing||setTimeout(()=>{a.numColliders()>0&&(a.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(e,t,i){if(this.validate(),!!this.enabled&&!(e.destroyed||!e.gameObject)&&!(!t&&!i))if(e.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=e,r=s[Or];r&&this.syncPhysicsBody(s.gameObject,r,t,i)}}updateProperties(e){if(this.validate(),e.isCollider){const t=e,i=t[Or];i&&this.internalUpdateColliderProperties(t,i)}else{const t=e,i=this.internal_getRigidbody(t);i&&this.internalUpdateRigidbodyProperties(t,i)}}addForce(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.addForce(t,i)}addImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}getLinearVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.linvel():null}getAngularVelocity(e){this.validate();const t=this.internal_getRigidbody(e);return t?t.angvel():null}resetForces(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetForces(t)}resetTorques(e,t){this.validate();const i=this.internal_getRigidbody(e);i==null||i.resetTorques(t)}applyImpulse(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.applyImpulse(t,i)}wakeup(e){this.validate();const t=this.internal_getRigidbody(e);t==null||t.wakeUp()}setAngularVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setAngvel(t,i)}setLinearVelocity(e,t,i){this.validate();const s=this.internal_getRigidbody(e);s==null||s.setLinvel(t,i)}async initialize(e){return this.context=e,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return Qs&&console.log("Initialize rapier physics engine"),"env"in{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:CR&&CR.src||new URL("dist/needle-engine.light.umd.cjs",document.baseURI).href}&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&Qs&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||Qs&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRay(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(c.x,c.y,c.z),{point:l,collider:o.collider[Ur]}}return null}raycastAndGetNormal(e,t,i,s){var a;i===void 0&&(i=1/0),s===void 0&&(s=!0);const r=this.getPhysicsRay(this.rapierRay,e,t);if(!r)return null;const o=(a=this.world)==null?void 0:a.castRayAndGetNormal(r,i,s,void 0,void 0,void 0,void 0,c=>{var l;return!((l=c[Ur])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const c=r.pointAt(o.toi),l=o.normal,u=this.raycastVectorsBuffer.get(),d=this.raycastVectorsBuffer.get();return u.set(c.x,c.y,c.z),d.set(l.x,l.y,l.z),{point:u,normal:d,collider:o.collider[Ur]}}return null}getPhysicsRay(e,t,i){var a,c,l;const s=(a=this.context)==null?void 0:a.mainCamera;if(t===void 0){const u=(c=this.context)==null?void 0:c.input.getPointerPosition(0);if(u)t=u;else return null}if(t.z===void 0){if(!s)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const u=this.raycastVectorsBuffer.get();u.x=t.x,u.y=t.y,u.z=0,(u.x>1||u.y>1||u.y<-1||u.x<-1)&&(Qs&&console.warn("Converting screenspace to raycast space",u),(l=this.context)==null||l.input.convertScreenspaceToRaycastSpace(u)),u.unproject(s),t=u}const r=t;e.origin.x=r.x,e.origin.y=r.y,e.origin.z=r.z;const o=this.raycastVectorsBuffer.get();if(i)o.set(i.x,i.y,i.z);else{if(!s)return console.error("Can not perform raycast - no camera found"),null;o.set(e.origin.x,e.origin.y,e.origin.z);const u=Ct(s);o.sub(u)}return o.normalize(),e.dir.x=o.x,e.dir.y=o.y,e.dir.z=o.z,e}sphereOverlap(e,t){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new gR(t)),this.rapierSphere.radius=t,this.world.intersectionsWithShape(e,this.rapierIdentityRotation,this.rapierSphere,i=>{const s=i[Ur],r=new FG(s.gameObject,s);return this.rapierColliderArray.push(r),!0},kM.EXCLUDE_SENSORS,void 0,void 0,void 0,i=>i[Ur].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get world(){return this._world}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var e;return((e=this.world)==null?void 0:e.gravity)??this._gravity}set gravity(e){this.world?this.world.gravity=e:this._gravity=e}clearCaches(){var e,t,i,s;this._meshCache.clear(),(e=this.eventQueue)!=null&&e.raw&&((t=this.eventQueue)==null||t.free()),(i=this.world)!=null&&i.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(e,t,i){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const s=e.gameObject,r=ls(s,this._tempPosition).multiply(i);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const o=Hi.cuboid(r.x,r.y,r.z);this.createCollider(e,o,t)}async addSphereCollider(e,t){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const i=Hi.ball(.5);this.createCollider(e,i,t),this.updateProperties(e)}async addCapsuleCollider(e,t,i,s){if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}const r=e.gameObject,o=ls(r,this._tempPosition);o.x=Math.abs(o.x),o.y=Math.abs(o.y);const a=Hi.capsule(i*.5*o.y-s,s*o.x);this.createCollider(e,a,t)}async addMeshCollider(e,t,i,s){var l,u,d;if(this._isInitialized||await this.initialize(e.context),!e.activeAndEnabled)return;if(!this.enabled){Qs&&console.warn("Physics are disabled");return}let r=t.geometry;if(!r){Qs&&console.warn("Missing mesh geometry",t.name);return}(u=(l=r.index)==null?void 0:l.array)!=null&&u.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${t.name}". Consider providing an indexed geometry.`),r=qY(r));let o=r.getAttribute("position").array;const a=(d=r.index)==null?void 0:d.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const f=r.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+i;if(this._meshCache.has(f))Qs&&console.warn("Use cached mesh collider"),o=this._meshCache.get(f);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",t.name,Object.assign({},s));const p=new Float32Array(o.length);for(let g=0;g<o.length;g+=3)p[g]=o[g]*s.x,p[g+1]=o[g+1]*s.y,p[g+2]=o[g+2]*s.z;o=p,this._meshCache.set(f,p)}}const c=i?Hi.convexMesh(o):Hi.trimesh(o,a);c&&this.createCollider(e,c)}getBody(e){return e?e[Or]:null}getComponent(e){return e?e[Ur]:null}createCollider(e,t,i){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:o}=this.getRigidbody(e,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),ls(e.gameObject,this._tempScale),i&&(i.multiply(this._tempScale),this._tempPosition.x-=i.x,this._tempPosition.y+=i.y,this._tempPosition.z+=i.z),t.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),t.setRotation(this._tempQuaternion),t.setSensor(e.isTrigger);const a=e.sharedMaterial;if(a){switch(t.setRestitution(a.bounciness),a.bounceCombine){case wa.Average:t.setRestitutionCombineRule(Eo.Average);break;case wa.Maximum:t.setRestitutionCombineRule(Eo.Max);break;case wa.Minimum:t.setRestitutionCombineRule(Eo.Min);break;case wa.Multiply:t.setRestitutionCombineRule(Eo.Multiply);break}switch(t.setFriction(a.dynamicFriction),a.frictionCombine){case wa.Average:t.setFrictionCombineRule(Eo.Average);break;case wa.Maximum:t.setFrictionCombineRule(Eo.Max);break;case wa.Minimum:t.setFrictionCombineRule(Eo.Min);break;case wa.Multiply:t.setFrictionCombineRule(Eo.Multiply);break}}o&&t.setDensity(0);const c=this.world.createCollider(t,r);return c[Ur]=e,e[Or]=c,c.setActiveEvents(LM.COLLISION_EVENTS),c.setActiveCollisionTypes(Lb.ALL),this.objects.push(e),this.bodies.push(c),c}getRigidbody(e,t){if(!this.world)throw new Error("Physics world not initialized");let i=null,s=!1;if(e.attachedRigidbody){const r=e.attachedRigidbody;if(i=r[Or],s=r.autoMass===!1,!i){const o=r.isKinematic&&!yC;Qs&&console.log("Create rigidbody",o);const a=o?Vd.RigidBodyDesc.kinematicPositionBased():Vd.RigidBodyDesc.dynamic(),c=Ct(e.attachedRigidbody.gameObject);a.setTranslation(c.x,c.y,c.z),a.setRotation(zn(e.attachedRigidbody.gameObject)),i=this.world.createRigidBody(a),this.bodies.push(i),this.objects.push(r)}i[Ur]=r,r[Or]=i,this.internalUpdateRigidbodyProperties(r,i),this.getRigidbodyRelativeMatrix(e.gameObject,r.gameObject,t)}else{const r=Vd.RigidBodyDesc.kinematicPositionBased(),o=Ct(e.gameObject);r.setTranslation(o.x,o.y,o.z),r.setRotation(zn(e.gameObject)),i=this.world.createRigidBody(r),t.identity(),i[Ur]=null}return e[Jce]=i,{rigidBody:i,useExplicitMassProperties:s}}internal_getRigidbody(e){return e[Or]}internalUpdateColliderProperties(e,t){const i=t.shape;switch(i.type){case Zt.Ball:{const o=i,a=e,c=e.gameObject,l=ls(c,this._tempPosition).multiplyScalar(a.radius),u=a.radius*Math.abs(l.x),d=o.radius!==u;o.radius=u,d&&t.setShape(o);break}case Zt.Cuboid:const s=i,r=e;s.halfExtents.x=r.size.x*.5,s.halfExtents.y=r.size.y*.5,s.halfExtents.z=r.size.z*.5,t.setShape(s);break}}internalUpdateRigidbodyProperties(e,t){if(t.enableCcd(e.collisionDetectionMode!==lx.Discrete),t.setLinearDamping(e.drag),t.setAngularDamping(e.angularDrag),t.setGravityScale(e.useGravity?e.gravityScale:0,!0),e.dominanceGroup<=127&&e.dominanceGroup>=-127?t.setDominanceGroup(Math.floor(e.dominanceGroup)):t.setDominanceGroup(0),e.autoMass){t.setAdditionalMass(0,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(1);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}else{t.setAdditionalMass(e.mass,!1);for(let i=0;i<t.numColliders();i++)t.collider(i).setDensity(0);t.recomputeMassPropertiesFromColliders(),console.log(t.mass())}t.setEnabledRotations(!e.lockRotationX,!e.lockRotationY,!e.lockRotationZ,!0),t.setEnabledTranslations(!e.lockPositionX,!e.lockPositionY,!e.lockPositionZ,!0),e.isKinematic?t.setBodyType(Vd.RigidBodyType.KinematicPositionBased):t.setBodyType(Vd.RigidBodyType.Dynamic)}step(e){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new jce(!1)),e&&(this.world.timestep=tt.lerp(this.world.timestep,e,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(e){var t,i,s;if(Qs||yC||Kce||this.debugRenderColliders===!0){if(!this.lines){const o=new vn({color:2258688,fog:!1}),a=new mt;this.lines=new eo(a,o),this.lines.layers.disableAll(),this.lines.layers.enable(2)}this.lines.parent!==((t=this.context)==null?void 0:t.scene)&&((i=this.context)==null||i.scene.add(this.lines));const r=e.debugRender();this.lines.geometry.setAttribute("position",new $e(r.vertices,3)),this.lines.geometry.setAttribute("color",new $e(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Zce(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!yC)for(let e=0;e<this.bodies.length;e++){const t=this.objects[e],i=this.bodies[e],s=t;if((s==null?void 0:s.isCollider)===!0&&!s.attachedRigidbody){const c=i.parent();c&&this.syncPhysicsBody(t.gameObject,c,!0,!0);continue}const r=i.translation(),o=i.rotation(),a=t.center;if(a&&a.isVector3){this._tempQuaternion.set(o.x,o.y,o.z,o.w);const c=this._tempPosition.copy(a).applyQuaternion(this._tempQuaternion);r.x-=c.x,r.y-=c.y,r.z-=c.z}Gf(t.gameObject,r.x,r.y,r.z),eF(t.gameObject,o.x,o.y,o.z,o.w)}}syncPhysicsBody(e,t,i,s){const r=Ct(e,this._tempPosition),o=zn(e,this._tempQuaternion);switch(t.bodyType()){case dm.Fixed:case dm.KinematicPositionBased:case dm.KinematicVelocityBased:i&&t.setNextKinematicTranslation(r),s&&t.setNextKinematicRotation(o);break;default:i&&t.setTranslation(r,!1),s&&t.setRotation(o,!1);break}t.wakeUp()}getRigidbodyRelativeMatrix(e,t,i,s){if(s===void 0&&(s=ym._matricesBuffer,s.length=0),e===t){const r=ls(e,this._tempPosition);i.makeScale(r.x,r.y,r.z);for(let o=s.length-1;o>=0;o--)i.multiply(s[o]);return i}return s.push(e.matrix),e.parent&&this.getRigidbodyRelativeMatrix(e.parent,t,i,s),i}addFixedJoint(e,t){if(!this.world){console.error("Physics world not initialized");return}const i=e[Or],s=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=df.fixed(ym.centerConnectionPos,ym.centerConnectionRot,this._tempPosition,this._tempQuaternion),o=this.world.createImpulseJoint(r,i,s,!0);Qs&&console.log("ADD FIXED JOINT",o)}addHingeJoint(e,t,i,s){if(!this.world){console.error("Physics world not initialized");return}const r=e[Or],o=t[Or];this.calculateJointRelativeMatrices(e.gameObject,t.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const a=Vd.JointData.revolute(i,this._tempPosition,s),c=this.world.createImpulseJoint(a,r,o,!0);Qs&&console.log("ADD HINGE JOINT",c)}calculateJointRelativeMatrices(e,t,i){e.updateWorldMatrix(!0,!1),t.updateWorldMatrix(!0,!1);const s=e.matrixWorld,r=t.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,i.copy(r).premultiply(s.invert()).invert()}};let eu=ym;h(eu,"_didLoadPhysicsEngine",!1),h(eu,"_matricesBuffer",[]),h(eu,"centerConnectionPos",{x:0,y:0,z:0}),h(eu,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Zce{constructor(e,t){h(this,"world");h(this,"eventQueue");h(this,"activeCollisions",[]);h(this,"activeCollisionsStay",[]);h(this,"activeTriggers",[]);this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,i)=>{const s=this.world.getCollider(e),r=this.world.getCollider(t),o=s[Ur],a=r[Ur];bC&&console.log("EVT",o.name,a.name,i,s,r),o&&a&&(i?(this.onCollisionStarted(o,s,a,r),this.onCollisionStarted(a,r,o,s)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,i,s){let r=null;if(e.isTrigger||i.isTrigger)Ru(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(i),this.activeTriggers.push({collider:e,component:o,otherCollider:i})});else{const o=e.gameObject;this.world.contactPair(t,s,(a,c)=>{Ru(o,l=>{var d;if(l.destroyed)return;const u=l.onCollisionEnter||l.onCollisionStay||l.onCollisionExit;if(u||bC){if(!r){const f=[],p=a.normal();for(let g=0;g<a.numSolverContacts();g++){const A=a.solverContactPoint(g),v=a.contactImpulse(g);if(A){const m=a.contactDist(g),b=a.solverContactFriction(g),y=new kG(A,m,p,v,b);f.push(y),bC&&zc.DrawDirection(A,p,16711680,3,!0)}}r=new LG(o,i,f)}if(u){const f={collider:e,component:l,collision:r};this.activeCollisions.push(f),l.onCollisionStay&&this.activeCollisionsStay.push(f),(d=l.onCollisionEnter)==null||d.call(l,r)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const i=e.collision;t.onCollisionStay(i)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const i=e.otherCollider;t.onTriggerStay(i)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let i=0;i<this.activeCollisions.length;i++){const s=this.activeCollisions[i],r=s.collider;if(r.destroyed){this.activeCollisions.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisions.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeCollisionsStay.length;i++){const s=this.activeCollisionsStay[i],r=s.collider;if(r.destroyed){this.activeCollisionsStay.splice(i,1),i--;continue}if(r===e&&s.collision.collider===t){const o=s.component;if(this.activeCollisionsStay.splice(i,1),i--,o.activeAndEnabled&&o.onCollisionExit){const a=s.collision;o.onCollisionExit(a)}}}for(let i=0;i<this.activeTriggers.length;i++){const s=this.activeTriggers[i],r=s.collider;if(r.destroyed){this.activeTriggers.splice(i,1),i--;continue}if(r===e&&s.otherCollider===t){const o=s.component;if(this.activeTriggers.splice(i,1),i--,o.activeAndEnabled&&o.onTriggerExit){const a=s.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(n){const e=n!==this._fov;this._fov=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(n){const e=n!==this._near;this._near=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(n){const e=n!==this._far;this._far=n,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function $ce(n,e,t,i="image/webp",s){if(!n&&(n=Oi.Current,!n))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!s&&(s=n.mainCamera,!s))return console.error("No camera found"),null;const r=n.renderer.domElement.width,o=n.renderer.domElement.height;e||(e=r),t||(t=o);const a=window.devicePixelRatio||1;e/=a,t/=a,n.renderer.domElement.style.width=e+"px",n.renderer.domElement.style.height=t+"px";try{const c=n.renderer.domElement;return n.renderer.setSize(e,t,!1),s instanceof qt&&n.updateAspect(s,e,t),n.renderNow(),c.toDataURL(i)}finally{n.renderer.setSize(r,o,!1),n.updateSize()}return null}let vg=null;function ele(n,e){if(n){if(!n.startsWith("data:image")){console.error("Can not save image: Data url is not an image",n);return}vg||(vg=document.createElement("a")),vg.href=n,vg.download=e,vg.click()}}const Fb=re("debugmissingcamera");Oi.registerCallback(Ks.MissingCamera,n=>{var r,o;Fb&&console.warn("Creating missing camera");const e=n.context.scene,t=new Te;t.name="Default Fallback Camera",e.add(t);const i=new Li;i.sourceId=((o=(r=n.files)==null?void 0:r[0])==null?void 0:o.src)??"unknown",n.context.lightmaps.tryGetSkybox(i.sourceId)?i.clearFlags=1:i.clearFlags=2,i.backgroundColor=new bi(.5,.5,.5,1),i.fieldOfView=35,i.backgroundBlurriness=.2;const s=gh(t,i,!0);return t.position.x=0,t.position.y=1,t.position.z=2,JG(n.context,s),s});Oi.registerCallback(Ks.ContextCreated,n=>{if(!n.context.mainCamera){Fb&&console.log("Will not auto-fit because a default camera exists");return}const e=n.context.domElement;if((e==null?void 0:e.cameraControls)===!0){const t=Fte(n.context.mainCamera);if((t==null?void 0:t.isCameraController)===!0){Fb&&console.log("Will not auto-fit because a camera controller exists");return}JG(n.context)}});function JG(n,e){e=e??n.mainCameraComponent;const t=e==null?void 0:e.gameObject;if(Fb&&console.log("Creating default camera controls",e==null?void 0:e.name),t){const i=Q_(t,Ji);i.sourceId=(e==null?void 0:e.sourceId)??"unknown";const s=n.domElement.getAttribute("auto-rotate");i.autoRotate=s!==void 0&&(s===""||s==="true"),i.autoRotateSpeed=.5;const r=n,o=()=>{r.pre_render_callbacks.splice(r.pre_render_callbacks.indexOf(o),1),i.fitCamera()};r.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}_j();const mR={Context:Ft,glTF:{loadFromURL:cR}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported");globalThis.Needle=mR;function ZG(n){for(const e in n)mR[e]=n[e]}ZG(wY);ZG(pce);for(const n of Object.getOwnPropertyNames(ne))switch(n){case"prototype":case"constructor":case"length":case"name":continue;default:mR[n]=ne[n];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=oj;var AR={},$G={};Object.defineProperty($G,"__esModule",{value:!0});var cw={};Object.defineProperty(cw,"__esModule",{value:!0});cw.ConstantBackoff=void 0;var tle=function(){function n(e){this.reset=function(){},this.backoff=e}return n.prototype.next=function(){return this.backoff},n}();cw.ConstantBackoff=tle;var lw={};Object.defineProperty(lw,"__esModule",{value:!0});lw.ExponentialBackoff=void 0;var ile=function(){function n(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return n.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},n.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},n}();lw.ExponentialBackoff=ile;var hw={};Object.defineProperty(hw,"__esModule",{value:!0});hw.LinearBackoff=void 0;var nle=function(){function n(e,t,i){this.initial=e,this.increment=t,this.maximum=i,this.current=this.initial}return n.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},n.prototype.reset=function(){this.current=this.initial},n}();hw.LinearBackoff=nle;var eH={};Object.defineProperty(eH,"__esModule",{value:!0});var uw={};Object.defineProperty(uw,"__esModule",{value:!0});uw.LRUBuffer=void 0;var sle=function(){function n(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return n.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},n.prototype.cap=function(){return this.buffer.length},n.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=t-1<0?this.buffer.length-1:t-1,s=0;s<e.length;s++){var r=(t+s)%this.buffer.length;if(e[s]=this.buffer[r],r===i)return s+1}return e.length},n.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,i=0;i<e.length-t;i++)this.buffer[this.writePtr]=e[t+i],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},n.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,i=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,s=this.len();e(this.buffer[t]),t!==i;)t=(t+1)%this.buffer.length;return s},n.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},n}();uw.LRUBuffer=sle;var dw={};Object.defineProperty(dw,"__esModule",{value:!0});dw.TimeBuffer=void 0;var rle=function(){function n(e){this.maxAge=e}return n.prototype.cap=function(){return Number.POSITIVE_INFINITY},n.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},n.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,i=0;t!==void 0&&(e[i++]=t.e,i!==e.length);)t=t.n;return i},n.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},n.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,i=0;t!==void 0;)e(t.e),i++,t=t.n;return i},n.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},n.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},n.prototype.clear=function(){},n}();dw.TimeBuffer=rle;var vR={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Websocket=n.WebsocketEvents=void 0;var e;(function(i){i.open="open",i.close="close",i.error="error",i.message="message",i.retry="retry"})(e=n.WebsocketEvents||(n.WebsocketEvents={}));var t=function(){function i(s,r,o,a){var c=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(l){return c.handleEvent(e.open,l)},this.handleCloseEvent=function(l){return c.handleEvent(e.close,l)},this.handleErrorEvent=function(l){return c.handleEvent(e.error,l)},this.handleMessageEvent=function(l){return c.handleEvent(e.message,l)},this.url=s,this.protocols=r,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(i.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),i.prototype.send=function(s){var r;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(r=this.buffer)===null||r===void 0||r.write([s]):this.websocket.send(s))},i.prototype.close=function(s,r){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(s,r)},i.prototype.addEventListener=function(s,r,o){var a={listener:r,options:o},c=this.eventListeners[s];c.push(a)},i.prototype.removeEventListener=function(s,r,o){this.eventListeners[s]=this.eventListeners[s].filter(function(a){return a.listener!==r&&(a.options===void 0||a.options!==o)})},i.prototype.dispatchEvent=function(s,r){var o=this,a=this.eventListeners[s],c=[];a.forEach(function(l){l.listener(o,r),l.options!==void 0&&l.options.once&&c.push(l)}),c.forEach(function(l){return o.removeEventListener(s,l.listener,l.options)})},i.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},i.prototype.handleEvent=function(s,r){var o,a,c;switch(s){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(c=this.buffer)===null||c===void 0||c.clear();break}this.dispatchEvent(s,r)},i.prototype.reconnect=function(){var s=this;if(this.backoff!==void 0){var r=this.backoff.next();setTimeout(function(){s.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++s.retries,backoff:r}})),s.tryConnect()},r)}},i}();n.Websocket=t})(vR);var fw={};Object.defineProperty(fw,"__esModule",{value:!0});fw.WebsocketBuilder=void 0;var Qd=vR,ole=function(){function n(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return n.prototype.withProtocols=function(e){return this.protocols=e,this},n.prototype.withBackoff=function(e){return this.backoff=e,this},n.prototype.withBuffer=function(e){return this.buffer=e,this},n.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},n.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},n.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},n.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},n.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},n.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new Qd.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var i;return(i=e.ws)===null||i===void 0?void 0:i.addEventListener(Qd.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},n}();fw.WebsocketBuilder=ole;(function(n){var e=py&&py.__createBinding||(Object.create?function(i,s,r,o){o===void 0&&(o=r),Object.defineProperty(i,o,{enumerable:!0,get:function(){return s[r]}})}:function(i,s,r,o){o===void 0&&(o=r),i[o]=s[r]}),t=py&&py.__exportStar||function(i,s){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(s,r)&&e(s,i,r)};Object.defineProperty(n,"__esModule",{value:!0}),t($G,n),t(cw,n),t(lw,n),t(hw,n),t(eH,n),t(uw,n),t(dw,n),t(vR,n),t(fw,n)})(AR);const ale=xA(AR),cle=nH({__proto__:null,default:ale},[AR]),Ao={node:"node",material:"material",camera:"camera",light:"light"},qh="KHR_animation_pointer",lle={CUBICSPLINE:void 0,LINEAR:Wa,STEP:nh},Vk=Nt.findNode;let Qk=!1;class hle{constructor(e){this.parser=e,this.name=qh,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Qk||(Qk=!0,Nt.findNode=function(e,t){if(t.startsWith(".materials.")){const i=t.substring(11).substring(t.indexOf(".")),s=i.indexOf("."),r=s<0?i:i.substring(0,s);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===r||a.material.name===r)&&(o=a.material,o!==null&&(i.endsWith(".map")?o=o.map:i.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const i=t.split(".");let s;for(let r=1;r<i.length;r++){const o=i[r];if(o.length==36)s=e.getObjectByProperty("uuid",o);else if(s&&s[o]){const c=Number.parseInt(o);let l=o;c>=0&&(l=c),s=s[l]}else{const c=e.getObjectByName(o);c&&(s=c)}}if(!s){const r=Vk(e,i[2]);return r||console.warn(qh+": Property binding not found",t,e,e.name,i),r}return s}return Vk(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,i=t.node!==void 0?t.node:t.id;return i?this.parser.getDependency("node",i):null}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,i=t.extensions&&t.extensions[qh]&&t.path&&t.path==="pointer";if(!i)return null;let s,r=Ao.node,o;if(i){const c=t.extensions[qh];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?r=Ao.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?r=Ao.light:l.startsWith("/cameras/")&&(r=Ao.camera),o=this._tryResolveTargetId(l,r),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,l);return}switch(r){case Ao.material:const d=("/materials/"+o.toString()+"/").length,f=l.substring(0,d);switch(s=l.substring(d),s){case"pbrMetallicRoughness/baseColorFactor":s="color";break;case"pbrMetallicRoughness/roughnessFactor":s="roughness";break;case"pbrMetallicRoughness/metallicFactor":s="metalness";break;case"emissiveFactor":s="emissive";break;case"alphaCutoff":s="alphaTest";break;case"occlusionTexture/strength":s="aoMapIntensity";break;case"normalTexture/scale":s="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":s="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":s="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":s="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":s="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":s="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":s="transmission";break;case"extensions/KHR_materials_ior/ior":s="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":s="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":s="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":s="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":s="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":s="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":s="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":s="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":s="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":s="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":s="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":s="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":s="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":s="specularColor";break}l=f+s;break;case Ao.node:const p=("/nodes/"+o.toString()+"/").length,g=l.substring(0,p);switch(s=l.substring(p),s){case"translation":s="position";break;case"rotation":s="quaternion";break;case"scale":s="scale";break;case"weights":s="morphTargetInfluences";break}l=g+s;break;case Ao.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(s=l.substring(A),s){case"color":break;case"intensity":break;case"spot/innerConeAngle":s="penumbra";break;case"spot/outerConeAngle":s="angle";break;case"range":s="distance";break}l="/lights/"+o.toString()+"/"+s;break;case Ao.camera:const v=("/cameras/"+o.toString()+"/").length,m=l.substring(0,v);switch(s=l.substring(v),s){case"perspective/yfov":s="fov";break;case"perspective/znear":case"orthographic/znear":s="near";break;case"perspective/zfar":case"orthographic/zfar":s="far";break;case"perspective/aspect":s="aspect";break;case"orthographic/xmag":s="zoom";break;case"orthographic/ymag":s="zoom";break}l=m+s;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(l=u.resolvePath(l)),t.extensions[qh].pointer=l}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return r===Ao.node?a=this.parser.getDependency("node",o):r===Ao.material?a=this.parser.getDependency("material",o):r===Ao.light?a=this.parser.getDependency("light",o):r===Ao.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",r),a}createAnimationTracksWithAnimationPointer(e,t,i,s,r){if(!(r.extensions&&r.extensions[qh]&&r.path&&r.path==="pointer"))return null;let a=r.extensions[qh].pointer;if(!a)return null;const c=[];a=a.replaceAll("/",".");const l=a.split(".");var d=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=d,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof ku&&p.morphTargetInfluences&&(l[3]=p.name,l[4]="morphTargetInfluences",f(this.parser));return c}f(this.parser);function f(p){a=l.join(".");let g;switch(i.itemSize){case 1:g=sh;break;case 2:case 3:g=el;break;case 4:a.endsWith(".quaternion")?g=ja:g=w_;break}const A=s.interpolation!==void 0?lle[s.interpolation]:Wa;let v=p._getArrayFromAccessor(i);a.endsWith(".fov")&&(v=v.map(b=>b/Math.PI*180));const m=new g(a,t.array,v,A);if(A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(m),a&&i.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const b=new Float32Array(v.length/4);for(let _=0,C=v.length/4;_<C;_+=1)b[_]=v[_*4+3];const y=new g(a.replace(".color",".opacity"),t.array,b,A);A==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(m),c.push(y)}}return c}_tryResolveTargetId(e,t){let i="";return t==="node"?i=e.substring(7):t==="material"?i=e.substring(11):t==="light"?i=e.substring(39):t==="camera"&&(i=e.substring(9)),i=i.substring(0,i.indexOf("/")),Number.parseInt(i)}loadAnimation(e){const t=this,i=this.parser.json,s=this.parser,r=i.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],l=[],u=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const g=r.channels[f],A=r.samplers[g.sampler],v=g.target,m=r.parameters!==void 0?r.parameters[A.input]:A.input,b=r.parameters!==void 0?r.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(g);if(y||(y=t.loadAnimationTargetFromChannel(g)),y==null){console.warn("Failed to load animation target",g,y);continue}a.push(y),c.push(s.getDependency("accessor",m)),l.push(s.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const p=f[0],g=f[1],A=f[2],v=f[3],m=f[4],b=[];for(let y=0,_=p.length;y<_;y++){const C=p[y],M=g[y],I=A[y],R=v[y],E=m[y];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let T=t.createAnimationTracksWithAnimationPointer(C,M,I,R,E);if(T||(T=s._createAnimationTracks(C,M,I,R,E)),T)for(let D=0;D<T.length;D++)b.push(T[D])}return new tr(o,void 0,b)})}}const ule=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:hle},Symbol.toStringTag,{value:"Module"}));exports.$physicsKey=Fce;exports.ActionBuilder=fi;exports.ActionCollection=IT;exports.ActionModel=Vr;exports.Addressables=pN;exports.AlignmentConstraint=OA;exports.AmbientMode=xf;exports.Animation=$r;exports.AnimationCurve=zu;exports.AnimationExtension=rx;exports.AnimationTrackHandler=_x;exports.Animator=ks;exports.AnimatorConditionMode=Hl;exports.AnimatorController=oh;exports.AnimatorControllerParameterType=RT;exports.AnimatorStateInfo=T0;exports.Antialiasing=jA;exports.Application=vN;exports.ApplicationEvents=gb;exports.AssetDatabase=CU;exports.AssetReference=Tn;exports.AttachedObject=Io;exports.AttachedObjectEvents=Mb;exports.AudioExtension=wx;exports.AudioListener=xu;exports.AudioSource=yn;exports.AudioTrackHandler=wu;exports.AvatarBlink_Simple=Hu;exports.AvatarEyeLook_Rotation=yp;exports.AvatarLoader=cx;exports.AvatarMarker=Jn;exports.AvatarModel=ax;exports.Avatar_Brain_LookAt=Vm;exports.Avatar_MouthShapes=XA;exports.Avatar_MustacheShake=hI;exports.Avatar_POI=ir;exports.Axes=lf;exports.AxesHelper=bp;exports.BaseUIComponent=aa;exports.BasicIKConstraint=fI;exports.BehaviorExtension=Cx;exports.BehaviorModel=ds;exports.Behaviour=Ie;exports.Bloom=Vu;exports.BoxCollider=YA;exports.BoxGizmo=Qu;exports.BoxHelperComponent=To;exports.Button=fl;exports.CallInfo=Wf;exports.Camera=Li;exports.Canvas=ps;exports.CanvasGroup=hh;exports.CapsuleCollider=lh;exports.ChangeMaterialOnClick=wp;exports.ChangeTransformOnClick=Xu;exports.CharacterController=qu;exports.CharacterControllerInput=gl;exports.ChromaticAberration=tv;exports.CircularBuffer=Xa;exports.ClearFlags=Ib;exports.ClipExtrapolation=Sa;exports.Collider=Za;exports.Collision=LG;exports.CollisionDetectionMode=lx;exports.ColorAdjustments=Sh;exports.ColorBySpeedModule=Yu;exports.ColorOverLifetimeModule=iv;exports.Component=Ah;exports.ComponentEvents=SA;exports.ComponentLifecycleEvents=CA;exports.ConnectionEvents=tU;exports.ContactPoint=kG;exports.Context=Ft;exports.ContextArgs=bY;exports.ContextEvent=Ks;exports.ContextRegistry=Oi;exports.ControlTrackHandler=xx;exports.ControllerEvents=Cc;exports.ControllerType=Ef;exports.CustomBranding=Th;exports.CustomShader=kr;exports.DefaultReflectionMode=pb;exports.Deletable=MI;exports.DeleteBox=Bx;exports.DepthOfField=pa;exports.DeviceFlag=Dx;exports.DocumentExtension=TI;exports.DragControls=Ip;exports.DropListener=sv;exports.Duplicatable=Zu;exports.EXTENSION_NAME=w0;exports.EmissionModule=ec;exports.EmphasizeOnClick=Cp;exports.EngineLoadingView=im;exports.EventList=us;exports.EventListEvent=ix;exports.EventSystem=$s;exports.EventTrigger=kx;exports.FieldWithDefault=ST;exports.FileSpawnModel=Zz;exports.File_Event=Jz;exports.FixedJoint=kI;exports.FlyControls=LI;exports.Fog=Rp;exports.FrameEvent=Tr;exports.GENERATOR=z_;exports.GameObject=ne;exports.Gizmos=zc;exports.GltfExport=ov;exports.GltfExportBox=NI;exports.GltfLoadEvent=Eu;exports.GltfLoadEventType=TG;exports.Gradient=Ch;exports.Graphic=Wu;exports.GraphicRaycaster=cI;exports.Graphics=Zo;exports.GridHelper=Pp;exports.GridLayoutGroup=_I;exports.GroundProjectedEnv=$u;exports.GroupActionModel=jl;exports.HideFlags=PU;exports.HideOnStart=wI;exports.HingeJoint=rv;exports.HorizontalLayoutGroup=bI;exports.HostData=J9;exports.Image=xp;exports.ImageReference=_f;exports.ImageReferenceSerializer=gN;exports.InheritVelocityModule=Mh;exports.Input=Z2;exports.InputEvents=Sn;exports.InputField=ed;exports.InstancingUtil=Sr;exports.InstantiateEvent=rU;exports.InstantiateIdProvider=Bs;exports.InstantiateOptions=qa;exports.Interactable=up;exports.JoinedRoomResponse=F9;exports.KeyEventArgs=Fj;exports.LODGroup=cv;exports.LODModel=td;exports.LeftRoomResponse=U9;exports.Light=Rr;exports.LightData=AN;exports.LimitVelocityOverLifetimeModule=Bn;exports.LoadingElementOptions=OY;exports.LogStats=GI;exports.LogType=Bo;exports.LookAt=id;exports.LookAtConstraint=LA;exports.MainModule=bs;exports.MarkerType=lI;exports.MaskableGraphic=ZA;exports.Mathf=tt;exports.MeshCollider=KA;exports.MeshRenderer=nx;exports.MinMaxCurve=ht;exports.MinMaxGradient=Ir;exports.NEEDLE_progressive=Hr;exports.NEKeyboardEvent=h0;exports.NEPointerEvent=wc;exports.NeedleEngine=Oi;exports.NeedleEngineHTMLElement=lR;exports.NeedleGltfLoader=oR;exports.NeedlePatchesKey=m0;exports.NestedGltf=Nx;exports.NetworkConnection=nU;exports.Networking=Ju;exports.NoiseModule=vi;exports.ObjectRaycaster=rl;exports.ObjectUtils=yG;exports.OffsetConstraint=nd;exports.OpenURL=Bp;exports.OrbitControls=Ji;exports.Outline=_p;exports.OwnershipEvent=iU;exports.OwnershipModel=N_;exports.Padding=_h;exports.ParticleBurst=eA;exports.ParticleSubEmitter=Xx;exports.ParticleSystem=In;exports.ParticleSystemRenderer=Go;exports.PeerNetworking=eU;exports.Physics=aF;exports.PhysicsMaterialCombine=wa;exports.PixelationEffect=uv;exports.PlayAnimationOnClick=wh;exports.PlayAudioOnClick=Ep;exports.PlayableDirector=Zc;exports.PlayerColor=Bu;exports.PlayerState=Cu;exports.PlayerStateEvent=CG;exports.PlayerSync=rw;exports.PlayerView=CN;exports.PlayerViewManager=EN;exports.PointerEventData=Gc;exports.PointerType=zf;exports.PostProcessingEffect=Us;exports.PostProcessingHandler=qx;exports.PreliminaryAction=Mp;exports.PreliminaryTrigger=$A;exports.PrimitiveType=ZI;exports.ProgressiveLoadingInfo=QN;exports.PromiseAllWithErrors=D_;exports.PromiseErrorResult=H2;exports.RGBAColor=bi;exports.RapierPhysics=eu;exports.RawImage=Mx;exports.RaycastOptions=ko;exports.Raycaster=mp;exports.Rect=AI;exports.RectTransform=rr;exports.ReflectionProbe=hp;exports.RegisteredAnimationInfo=sx;exports.RemoteSkybox=ol;exports.RenderTexture=Jl;exports.RenderTextureSerializer=XN;exports.Renderer=Qi;exports.RendererData=mN;exports.RendererLightmap=Hm;exports.Rigidbody=Ii;exports.RigidbodyConstraints=ln;exports.RoomEvents=on;exports.RotationBySpeedModule=so;exports.RotationOverLifetimeModule=zo;exports.SceneLightSettings=vb;exports.SceneSwitcher=ur;exports.ScreenCapture=fv;exports.ScreenSpaceAmbientOcclusion=Al;exports.ScreenSpaceAmbientOcclusionN8=ma;exports.SendQueue=Ar;exports.SetActiveOnClick=Sp;exports.ShadowCatcher=gv;exports.ShapeModule=bn;exports.SignalAsset=VA;exports.SignalReceiver=vp;exports.SignalReceiverEvent=Ap;exports.SignalTrackHandler=Zm;exports.Size=mI;exports.SizeBySpeedModule=lr;exports.SizeOverLifetimeModule=Eh;exports.SkinnedMeshRenderer=CT;exports.SmoothFollow=Ih;exports.SpatialHtml=$I;exports.SpatialTrigger=Av;exports.SpatialTriggerReceiver=Qa;exports.SpectatorCamera=Jx;exports.SphereCollider=qA;exports.SphereIntersection=oF;exports.SphereOverlapResult=FG;exports.Sprite=vl;exports.SpriteData=Lp;exports.SpriteRenderer=ic;exports.SpriteSheet=vv;exports.StateMachineBehaviour=NK;exports.SubEmitterSystem=oA;exports.SyncedCamera=Zx;exports.SyncedRoom=Rh;exports.SyncedTransform=ah;exports.TapGestureTrigger=SI;exports.TeleportTarget=vx;exports.TestRunner=eR;exports.TestSimulateUserData=tR;exports.Text=hr;exports.TextBuilder=Rx;exports.TextExtension=nv;exports.TextureSheetAnimationModule=_s;exports.TiltShiftEffect=nc;exports.Time=cF;exports.ToneMapping=bv;exports.TrackHandler=QA;exports.TrackType=Lr;exports.TrailModule=ji;exports.TransformData=Zl;exports.TransformGizmo=rd;exports.TriggerBuilder=Cr;exports.TriggerModel=Kc;exports.TypeStore=q;exports.UIRaycastUtils=Yf;exports.UIRootComponent=HA;exports.USDObject=_r;exports.USDZExporter=oo;exports.USDZText=Xl;exports.USDZUIExtension=Px;exports.Upload_Result=zE;exports.UriSerializer=qN;exports.UsageMarker=dp;exports.UserJoinedOrLeftRoomModel=N9;exports.VERSION=Nc;exports.VRUserState=ta;exports.VariantAction=TT;exports.VelocityOverLifetimeModule=Zi;exports.VerticalLayoutGroup=yI;exports.VideoPlayer=Ns;exports.ViewDevice=Va;exports.Vignette=od;exports.VisibilityAction=ev;exports.Voip=dl;exports.Volume=ew;exports.VolumeParameter=Rt;exports.VolumeProfile=WA;exports.WaitForFrames=woe;exports.WaitForSeconds=pG;exports.Watch=jc;exports.WebAR=Su;exports.WebARCameraBackground=tw;exports.WebARSessionRoot=ca;exports.WebXR=It;exports.WebXRAvatar=Ua;exports.WebXRController=sn;exports.WebXREvent=Mi;exports.WebXRImageTracking=iw;exports.WebXRImageTrackingModel=yl;exports.WebXRPlaneTracking=ad;exports.WebXRSync=tA;exports.WebXRTrackedImage=Oc;exports.XRFlag=jr;exports.XRGrabModel=sw;exports.XRGrabRendering=nR;exports.XRRig=Ix;exports.XRSessionMode=zm;exports.XRState=Zs;exports.XRStateFlag=fn;exports.__Ignore=sR;exports.__internalNotifyObjectDestroyed=RU;exports.activeInHierarchyFieldName=Yc;exports.addAttributeChangeCallback=z2;exports.addCustomExtension=G7;exports.addFile=$z;exports.addFileFromUrl=eG;exports.addGltfLoadEventListener=Sce;exports.addNewComponent=gh;exports.addPatch=X_;exports.apply=j_;exports.applyHMRChanges=Lce;exports.beginListenDestroy=cU;exports.beginListenFileSpawn=tG;exports.beginListenInstantiate=lU;exports.binaryIdentifierCasts=V1;exports.build_scene_functions=yY;exports.builtinComponentKeyName=nu;exports.calculateProgress01=vT;exports.colorSerializer=j7;exports.componentSerializer=S0;exports.copyTexture=rF;exports.createGLTFLoader=aR;exports.createMotion=l3;exports.debugNet=js;exports.debugOwner=Tg;exports.deepClone=B_;exports.delay=_A;exports.deserializeObject=hb;exports.destroy=tl;exports.destroyComponentInstance=gU;exports.detectARSupport=jz;exports.detectVRSupport=Xz;exports.disposeObjectResources=Si;exports.download=dN;exports.download_file=dT;exports.editorGuidKeyName=Kg;exports.effectsOrder=TM;exports.eventListSerializer=J7;exports.findByGuid=RA;exports.findObjectOfType=AU;exports.findObjectsOfType=vU;exports.findResourceUsers=iT;exports.foreachComponent=Ru;exports.foreachComponentEnumerator=sT;exports.forward=Wj;exports.generateSeed=V_;exports.getComponent=sp;exports.getComponentInChildren=MA;exports.getComponentInParent=Lm;exports.getComponents=EA;exports.getComponentsInChildren=TA;exports.getComponentsInParent=W_;exports.getIp=Aj;exports.getIpAndLocation=vj;exports.getIpCloudflare=mj;exports.getLoader=oa;exports.getOrAddComponent=Q_;exports.getParam=re;exports.getPath=uj;exports.getPeerOptions=D9;exports.getPeerjsInstance=Y1;exports.getResourceUserCount=I6;exports.getUrlParams=bA;exports.getWorldDirection=Xj;exports.getWorldEuler=tF;exports.getWorldPosition=Ct;exports.getWorldQuaternion=zn;exports.getWorldRotation=O_;exports.getWorldScale=ls;exports.hasIndieLicense=AT;exports.hasProLicense=wf;exports.hash=uT;exports.instantiate=PA;exports.isActiveInHierarchy=BU;exports.isActiveSelf=rp;exports.isAnimationAction=sF;exports.isDebugMode=cj;exports.isDestroyed=nT;exports.isDevEnvironment=ci;exports.isDisposed=M6;exports.isHostedOnGlitch=V2;exports.isHotReloading=Bce;exports.isLocalNetwork=nr;exports.isMobileDevice=cl;exports.isMozillaXR=tb;exports.isQuest=pj;exports.isResourceTrackingEnabled=MU;exports.isSafari=Rc;exports.isUsingInstancing=Y_;exports.isiOS=Dm;exports.loadSync=cR;exports.logHierarchy=sb;exports.lookAtInverse=Gj;exports.makeId=hj;exports.makeIdFromRandomWords=L2;exports.markAsInstancedRendered=DU;exports.moveComponentInstance=Z1;exports.nameof=aj;exports.nameofFactory=eb;exports.objectSerializer=jN;exports.parseSync=RG;exports.prefix=MJ;exports.pushState=O2;exports.randomNumber=k2;exports.registerBinaryType=F_;exports.registerComponent=tx;exports.registerComponentExtension=wT;exports.registerCustomEffectType=No;exports.registerExtensions=WN;exports.registerHotReloadType=Dce;exports.registerLoader=fT;exports.registerPrefabProvider=uU;exports.registerType=u6;exports.relativePathPrefix=U2;exports.removeAttributeChangeCallback=G2;exports.removeComponent=J1;exports.removeCustomExtension=H7;exports.removeGltfLoadEventListener=Cce;exports.removePatch=S6;exports.resolveUrl=al;exports.sanitizeString=F2;exports.saveImage=ele;exports.screenshot=$ce;exports.sendDestroyed=aU;exports.serializable=x;exports.serializeObject=_U;exports.serializeable=lp;exports.setActive=Zg;exports.setAllowOverlayMessages=bj;exports.setDestroyed=kU;exports.setDevEnvironment=Lj;exports.setDisposable=tT;exports.setOrAddParamsToUrl=Bm;exports.setParam=lj;exports.setParamWithoutReload=D2;exports.setPeerOptions=O9;exports.setResourceTrackingEnabled=E6;exports.setState=N1;exports.setWorldEuler=iF;exports.setWorldPosition=Mn;exports.setWorldPositionXYZ=Gf;exports.setWorldQuaternion=Mr;exports.setWorldQuaternionXYZW=eF;exports.setWorldRotation=nF;exports.setWorldRotationXYZ=k_;exports.setWorldScale=AE;exports.showBalloonError=kj;exports.showBalloonMessage=pn;exports.showBalloonWarning=Ls;exports.showDebugConsole=G1;exports.slerp=$2;exports.syncDestroy=H_;exports.syncField=KI;exports.syncInstantiate=K1;exports.textureToCanvas=Yj;exports.tryCastBinary=lF;exports.tryFindObject=Nf;exports.tryFindObjectByName=BG;exports.tryFindScript=Mce;exports.tryGetGuid=hF;exports.unregisterHotReloadType=Oce;exports.unwatchWrite=N2;exports.upload_file=uN;exports.validate=ys;exports.watchWrite=z1;
|