@needle-tools/engine 3.21.1-alpha.1 → 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 +9 -0
- package/dist/needle-engine.js +45 -23
- package/dist/needle-engine.light.js +1414 -1392
- package/dist/needle-engine.light.min.js +93 -93
- package/dist/needle-engine.light.umd.cjs +6 -6
- package/dist/needle-engine.min.js +6 -6
- package/dist/needle-engine.umd.cjs +6 -6
- 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 +7 -1
- package/lib/engine-components/EventList.js +10 -1
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/ui/Button.js +6 -2
- package/lib/engine-components/ui/Button.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +6 -3
- 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 +11 -1
- package/src/engine-components/ui/Button.ts +7 -3
- package/src/engine-components/ui/EventSystem.ts +7 -2
|
@@ -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}}invoke(...e){if(this._isInvoking)
|
|
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(;!(i.used||(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() {
|
|
@@ -5178,7 +5178,7 @@ void main() {
|
|
|
5178
5178
|
#include <colorspace_fragment>
|
|
5179
5179
|
|
|
5180
5180
|
}
|
|
5181
|
-
`,a={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},c=new vA(1,16),l=new Lt({uniforms:a,fragmentShader:o,vertexShader:r,side:wi});super(c,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var Nte=Object.defineProperty,zte=Object.getOwnPropertyDescriptor,cr=(n,e,t,i)=>{for(var s=i>1?void 0:i?zte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nte(e,t,s),s};const By=re("freecam"),cg=re("debugcamerafit"),Dy=re("smoothcam"),Gte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let HS;class Ji extends Ie{constructor(){super(...arguments);h(this,"enableRotate",!0);h(this,"autoRotate",!1);h(this,"autoRotateSpeed",1);h(this,"autoFit",!1);h(this,"enableKeys",!0);h(this,"enableDamping",!0);h(this,"dampingFactor",.1);h(this,"enableZoom",!0);h(this,"minZoom",0);h(this,"maxZoom",1/0);h(this,"enablePan",!0);h(this,"lookAtConstraint",null);h(this,"lookAtConstraint01",1);h(this,"middleClickToFocus",!0);h(this,"doubleClickToFocus",!0);h(this,"useSlerp",!0);h(this,"debugLog",!1);h(this,"targetLerpSpeed",5);h(this,"autoTarget",!0);h(this,"_lookTargetPosition");h(this,"_controls",null);h(this,"_cameraObject",null);h(this,"_lerpToTargetPosition",!1);h(this,"_lerpCameraToTarget",!1);h(this,"_cameraTargetPosition",null);h(this,"_inputs",0);h(this,"_enableTime",0);h(this,"_startedListeningToKeyEvents",!1);h(this,"_eventSystem");h(this,"_afterHandleInputFn");h(this,"_camera",null);h(this,"_syncedTransform");h(this,"_didStart",!1);h(this,"targetElement",null);h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});h(this,"_shouldDisable",!1);h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._didStart=!1,this._lookTargetPosition=new w,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const t=ne.getComponent(this.gameObject,Li);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=Ct(t.cam).length(),r=new w(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}if(this.autoTarget&&!this.setFromTargetPosition()){const i=new ko;i.screenPoint=new te(0,0),i.lineThreshold=.1;const s=this.context.physics.raycast(i);s.length>0&&this.setTarget(s[0].point,!0),cg&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=$s.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(uM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(uM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Li);this._camera=t;const i=t==null?void 0:t.cam;if(i&&AO(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new JK(i,s),i==null||i.quaternion.copy(r),HS===void 0&&(HS={...this._controls.keys})}this._controls&&(By&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,cl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?By||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):By||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ne.getComponent(this.gameObject,ah)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&AO(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,s,r;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.enableRotate&&(this.autoRotate=!1),this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;$2(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}if(!By&&((r=this.lookAtConstraint)!=null&&r.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?HS:Gte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof Dy=="number"||Dy===!0){this._controls.enableDamping=!0;const o=typeof Dy=="number"?Dy:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,o))}this.context.isInXR||this._controls.update()}}setCameraTarget(t,i=!1){return this.setCameraTargetPosition(t,i)}setCameraTargetPosition(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&ne.isActiveInHierarchy(r.object)){const o=yx(r.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const a=Ct(this.context.mainCamera);this._cameraTargetPosition=a.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1,s=!0){const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!r||!o)return;const a=new w,c=new w,l=new Un;l.makeEmpty();const u=[];function d(y){let _=!0;if(y.visible&&(y instanceof uE&&(_=!1),y instanceof F1&&(_=!1),y instanceof Lz&&(_=!1),y.material instanceof __&&(_=!1),y instanceof ye||(_=!1),y!==r&&y.isUI!==!0)){if(_){cg&&console.log(y.name,y.type,y);const C=y.children;y.children=u,l.expandByObject(y,!0),y.children=C}for(const C of y.children)d(C)}}for(const y of t)y.updateMatrixWorld(),d(y);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(c),l.applyMatrix4(r.matrixWorldInverse),l.getSize(a),l.setFromCenterAndSize(c,a),a.length()<=1e-10){cg&&console.warn("Camera fit size is zero",l,[...t]);return}const f=r.fov,p=2*Math.atan(Math.tan(f*Math.PI/360/2)*r.aspect)/Math.PI*360,g=a.y/(2*Math.atan(Math.PI*f/360)),A=a.x/(2*Math.atan(Math.PI*p/360)),v=i*Math.max(g,A)+a.z/2;cg&&console.log("Fit camera to objects",g,A,"distance",v);const m=Ct(r),b=o.target.clone().sub(m).normalize().multiplyScalar(v);if(o.maxDistance=v*10,o.minDistance=v*.01,this.setTarget(c,s),this.autoTarget=!1,r.near=v/100,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const y=r.parent.worldToLocal(o.target.clone().sub(b));this.setCameraTarget(y,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(cg){const y=new uE(l);this.context.scene.add(y),nF(y,O_(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{_.code==="KeyF"&&this.fitCamera(t)}))}o.update()}}cr([x()],Ji.prototype,"enableRotate",2);cr([x()],Ji.prototype,"autoRotate",2);cr([x()],Ji.prototype,"autoRotateSpeed",2);cr([x()],Ji.prototype,"autoFit",2);cr([x()],Ji.prototype,"enableKeys",2);cr([x()],Ji.prototype,"enableDamping",2);cr([x()],Ji.prototype,"dampingFactor",2);cr([x()],Ji.prototype,"enableZoom",2);cr([x()],Ji.prototype,"minZoom",2);cr([x()],Ji.prototype,"maxZoom",2);cr([x()],Ji.prototype,"enablePan",2);cr([x(LA)],Ji.prototype,"lookAtConstraint",2);cr([x()],Ji.prototype,"lookAtConstraint01",2);cr([x()],Ji.prototype,"middleClickToFocus",2);cr([x()],Ji.prototype,"doubleClickToFocus",2);var Hte=Object.defineProperty,Vte=Object.getOwnPropertyDescriptor,to=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hte(e,t,s),s},Ib=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Ib||{});const ru=re("debugcam"),yO=re("debugscreenpointtoray");var t0;const Bg=(t0=class extends Ie{constructor(){super(...arguments);h(this,"_nearClipPlane",.1);h(this,"_farClipPlane",1e3);h(this,"orthographic",!1);h(this,"orthographicSize",5);h(this,"ARBackgroundAlpha",0);h(this,"_cullingMask",4294967295);h(this,"_backgroundBlurriness");h(this,"_backgroundIntensity");h(this,"_environmentIntensity");h(this,"_targetTexture",null);h(this,"_backgroundColor");h(this,"_fov");h(this,"_cam",null);h(this,"_clearFlags",2);h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const s=this.cam,r=Bg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),yO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=Bg._direction.set(r.x,r.y,r.z),a=Ct(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new Ya(a.clone(),o.clone())}awake(){yO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);zc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){ru&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ib[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Wte(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Du(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){ru&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,ru){const e=`Camera "${this.name}" clear flags: ${Ib[this._clearFlags]}`;console.log(e)}switch(this._clearFlags){case 1:if(Bg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Bg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else ru&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new Qte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;ru&&pn("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===zm.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))return!0}return s}},h(t0,"_origin",new w),h(t0,"_direction",new w),t0);let Li=Bg;to([x()],Li.prototype,"fieldOfView",1);to([x()],Li.prototype,"nearClipPlane",1);to([x()],Li.prototype,"farClipPlane",1);to([x()],Li.prototype,"clearFlags",1);to([x()],Li.prototype,"orthographic",2);to([x()],Li.prototype,"orthographicSize",2);to([x()],Li.prototype,"ARBackgroundAlpha",2);to([x()],Li.prototype,"cullingMask",1);to([x()],Li.prototype,"backgroundBlurriness",1);to([x()],Li.prototype,"backgroundIntensity",1);to([x()],Li.prototype,"environmentIntensity",1);to([x(bi)],Li.prototype,"backgroundColor",1);to([x(Jl)],Li.prototype,"targetTexture",1);class Qte{constructor(e){h(this,"_camera");h(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(ru&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ze,this._skybox.mapping=Ro,this.context.scene.background=this._skybox):(console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background),(ru||ci())&&Ls(`Camera "${this._camera.name}" has no skybox texture`))}}function Wte(n){re("freecam")&&n.context.mainCameraComponent===n&&ne.getOrAddComponent(n.gameObject,Ji)}class xu extends Ie{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new O1),this._listener}awake(){yn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Li);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var jte=Object.defineProperty,Xte=Object.getOwnPropertyDescriptor,bx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&jte(e,t,s),s};const qte=re("debugsignals");class VA{constructor(){h(this,"guid")}}bx([x()],VA.prototype,"guid",2);class Ap{constructor(){h(this,"signal");h(this,"reaction")}}bx([x(VA)],Ap.prototype,"signal",2);bx([x(us)],Ap.prototype,"reaction",2);var xC;const bc=(xC=class extends Ie{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(bc.receivers[e]){const t=bc.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){qte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)bc.receivers[e.signal.guid]||(bc.receivers[e.signal.guid]=[]),bc.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(bc.receivers[e.signal.guid]){const t=bc.receivers[e.signal.guid].indexOf(this);t>=0&&bc.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},h(xC,"receivers",{}),xC);let vp=bc;bx([x(Ap)],vp.prototype,"events",2);var Lr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Lr||{}),Sa=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Sa||{}),lI=(n=>(n.Signal="SignalEmitter",n))(lI||{});const Fd=re("debugtimeline"),zb=class extends Ie{constructor(){super(...arguments);h(this,"playableAsset");h(this,"playOnAwake");h(this,"extrapolationMode",1);h(this,"waitForAudio",!0);h(this,"_visibilityChangeEvt");h(this,"_clonedPlayableAsset",!1);h(this,"_speed",1);h(this,"_guidsMap");h(this,"_isPlaying",!1);h(this,"_internalUpdateRoutine");h(this,"_isPaused",!1);h(this,"_isStopping",!1);h(this,"_time",0);h(this,"_duration",0);h(this,"_weight",1);h(this,"_animationTracks",[]);h(this,"_audioTracks",[]);h(this,"_signalTracks",[]);h(this,"_controlTracks",[]);h(this,"_customTracks",[]);h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);h(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Fd||nr())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Fd&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yn.userInteractionRegistered&&this.waitForAudio;)await _A(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Tr.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Lr.Activation:if(!this._isPlaying)continue;for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;if(i.clips)for(const c of i.clips)c.start<=t&&t<=c.end&&(o=!0);const a=r;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Fd&&console.warn(this.name,"set ActivationTrack-"+s,a.name,o,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=B_(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=ne.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Fd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),zb.createTrackFunctions[i.type])continue;i.type!==Lr.Audio&&i.type!==Lr.Control&&i.type!==Lr.Marker&&i.type!==Lr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Lr.Control&&i.clips)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=ne.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Fd&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=ne.findObjectOfType(xu,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=zb.createTrackFunctions[o];if(a!=null){const c=a(this,r);if(typeof c.evaluate=="function"){c.director=this,c.track=r,this._customTracks.push(c);continue}}if(r.type===Lr.Animation){if(!r.clips||r.clips.length<=0){Fd&&console.warn("Animation track has no clips",r);continue}for(let c=r.outputs.length-1;c>=0;c--){let l=r.outputs[c];if(l instanceof Te){const d=ne.getOrAddComponent(l,ks);d&&(l=d)}const u=(i=l==null?void 0:l.gameObject)==null?void 0:i.animations;if(u){const d=new _x;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],g=p.asset;if(!g){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=g.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=u.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}l instanceof ks&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),d.mixer=l.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new R_(l.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const m=d.mixer.clipAction(v);d.actions.push(m),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===Lr.Audio){if(!r.clips||r.clips.length<=0)continue;const c=new wu;if(c.director=this,c.track=r,this._audioTracks.push(c),!t)continue;c.listener=t.listener;for(let l=0;l<r.clips.length;l++){const u=r.clips[l];c.addModel(u)}}else if(r.type===Lr.Marker){const c=new Zm;if(c.director=this,c.track=r,r.markers)for(const l of r.markers)switch(l.type){case lI.Signal:c.models.push(l),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const l=ne.getComponent(this.gameObject,vp);l&&(c.receivers.push(l),this._signalTracks.push(c))}}else if(r.type===Lr.Signal){const c=new Zm;if(c.director=this,c.track=r,r.markers)for(const l of r.markers)c.models.push(l),c.didTrigger.push(!1);for(const l of r.outputs)c.receivers.push(l);this._signalTracks.push(c)}else if(r.type===Lr.Control){const c=new xx;if(c.director=this,c.track=r,r.clips)for(const l of r.clips)c.models.push(l);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let Zc=zb;h(Zc,"createTrackFunctions",{});const Hc=re("debugtimeline");class QA{constructor(){h(this,"director");h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class Yte{constructor(e){h(this,"clip");h(this,"rootPositionOffset");h(this,"rootQuaternionOffset");h(this,"rootStartPosition");h(this,"rootEndPosition");h(this,"rootStartQuaternion");h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Hc&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Hc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new we().fromArray(o.values,0),this.rootEndQuaternion=new we().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Hc)){const a=new mn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class _x extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"trackOffset");h(this,"target");h(this,"mixer");h(this,"clips",[]);h(this,"actions",[]);h(this,"_actionOffsets",[]);h(this,"_didBind",!1);h(this,"_animator",null);h(this,"_useclipOffsets",!0);h(this,"_totalOffsetPosition",new w);h(this,"_totalOffsetRotation",new we);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new we);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new we);h(this,"_tempRot",new we);h(this,"_clipRotQuat",new we)}onStateChanged(){this._animator&&KD(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],g=p.name.lastIndexOf("."),A=p.name.substring(0,g),v=A.substring(A.lastIndexOf(".")+1),m=f.getObjectByName(v);if(m)if(c){if(!l){const b=i.tracks[0].name.substring(0,g)+".quaternion";Hc&&console.warn("Create quaternion track",v,m);const y=m.quaternion,_=new ja(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Hc&&console.warn("Create position track",v,m);const y=m.position,_=new el(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}bind(){if(!this._didBind){this._didBind=!0,Hc&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new Yte(t);this._actionOffsets.push(i)}this.target&&(this._animator=ne.getComponent(this.target,ks)??null,this._animator&&KD(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new w(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new we(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new we(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,u,d,f,p,g;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let i=0,s=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],m=this.actions[A],b=v.asset;m.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,C=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let I=y,R=!1;if(!I&&!r&&v.end<t&&C!==Sa.None?(!M||M.start>t)&&(I=!0,r=!0):A==0&&!I&&!o&&v.start>t&&_!==Sa.None&&(!M||M.start<t)&&(I=!0,R=!0,o=!0),I){let E=1;E*=this.evaluateWeight(t,A,this.models,I),E*=this.director.weight;let T=y;if(R)switch(_){case Sa.Hold:break;case Sa.Loop:t+=v.start,T=!0;break;default:t+=v.start,T=!0;break}let D=this.getClipTime(t,v),K=0;const H=b.duration;if(R&&_===Sa.Hold&&(D=0),T){if(b.loop)for(K+=Math.floor(D/(H+1e-6));D>H;)D-=H}else if(!y&&r)switch(C){case Sa.Hold:D=this.getClipTime(v.end,v);break;case Sa.Loop:D%=H;break;case Sa.PingPong:const N=Math.floor(D/H)%2!==0;D%=H,N&&(D=H-D);break}v.reversed===!0?m.time=m.getClip().duration-D:m.time=D,m.timeScale=0;const V=Math.max(0,E);if(m.weight=V,a+=V,m.clampWhenFinished=!1,m.isRunning()||m.play(),this._useclipOffsets){const Y=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,N=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-E),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),ee=this._summedRot.identity(),$=this._tempRot.identity(),j=b.rotation;j&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(j,E));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let Ae=0;Ae<K;Ae++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(ee),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&($.copy(ie.rootQuaternionOffset),ee.multiply($)),L.add(G);this._clipRotQuat&&N.multiply(this._clipRotQuat),N.multiply(ee),b.position&&L.add(b.position),Y.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Hc||ci())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(g=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||g.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new we;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),u=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const g of this.director.animationCallbackReceivers)(p=g==null?void 0:g.onTimelineRotation)==null||p.call(g,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var u,d;const r=s.createInterpolant.bind(s),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=g=>{var v,m,b;const A=p(g);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(m=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:m.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,g,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Kte=re("mutetimeline"),gf=class extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"listener");h(this,"audio",[]);h(this,"audioContextTimeOffset",[]);h(this,"lastTime",0);h(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return al(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new I_(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(Kte||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),yn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const l=o.clipIn+(t-o.start)*o.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(l-u)>.3&&(a.offset=l,a.stop(),a.play(s))}let c=o.asset.volume;if(i&&(c=0),o.easeInDuration>0){const l=Math.min((t-o.start)/o.easeInDuration,1);c*=l}if(o.easeOutDuration>0){const l=Math.min((o.end-t)/o.easeOutDuration,1);c*=l}a.setVolume(c*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],u=this.handleAudioLoading(c,l);u!==null&&(r===null&&(r=[]),r.push(u))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){gf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new $0);const s=this.getAudioFilePath(t.asset.clip);if(gf._audioBuffers.get(s)){const o=gf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Hc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return gf._audioBuffers.set(s,r),r}};let wu=gf;h(wu,"_audioBuffers",new Map);class Zm extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const u=Math.abs(c);(u===0||u>=1e-5&&u<i)&&(l=!0)}if(l){if(!a)if(Hc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)vp.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class xx extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=ne.getComponent(r.sourceObject,Zc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}var Jte=Object.defineProperty,Zte=Object.getOwnPropertyDescriptor,Fz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jte(e,t,s),s};class Rt{constructor(e){h(this,"_active",!0);h(this,"_value");h(this,"_valueRaw");h(this,"_defaultValue");h(this,"valueProcessor");h(this,"onValueChanged");this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}Fz([x()],Rt.prototype,"overrideState",1);Fz([x()],Rt.prototype,"value",1);var $te=Object.defineProperty,eie=Object.getOwnPropertyDescriptor,tie=(n,e,t,i)=>{for(var s=i>1?void 0:i?eie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$te(e,t,s),s};const iie=re("debugpost");class Us extends Ah{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Rt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){iie&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Rt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Rt){const a=t[r];if(a!==void 0){const c=this[r];c.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Rt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Rt&&(this[i]||(this[i]=new Rt))}}tie([x()],Us.prototype,"active",2);var nie=Object.defineProperty,sie=Object.getOwnPropertyDescriptor,rie=(n,e,t,i)=>{for(var s=i>1?void 0:i?sie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nie(e,t,s),s};const oie=re("debugpost"),dM={};function No(n,e){dM[n]=e}function aie(n){return n.__type in dM?dM[n.__type]:(oie&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Us)}class WA{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}rie([lp([n=>aie(n),Us])],WA.prototype,"components",2);var cie=Object.defineProperty,lie=Object.getOwnPropertyDescriptor,hie=(n,e,t,i)=>{for(var s=i>1?void 0:i?lie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cie(e,t,s),s};class jA extends Us{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new Iq({preset:Xd.HIGH,edgeDetectionMode:oT.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}hie([x(Rt)],jA.prototype,"preset",2);No("Antialiasing",jA);class wx{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=ne.getComponents(e,yn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.clip),t.addEventListener("serialize",(a,c)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}const Rb="noVoip",vr=re("debugvoip"),uie=re("voip");class die{constructor(e){h(this,"id");this.id=e}}class fie{constructor(e,t,i,s){h(this,"peer");h(this,"voip");h(this,"userId");h(this,"peerId");h(this,"call",null);h(this,"callErrorListener",null);h(this,"stream",null);this.voip=e,this.peer=t,this.userId=i,this.peerId=s}close(){var e;vr&&console.log("close voip call"),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.open&&this.call.close(),(e=this.stream)==null||e.getTracks().forEach(function(t){t.stop()})}updateMute(e){var i;if(!this.stream)return;const t=(i=this.stream)==null?void 0:i.getAudioTracks();for(const s of t)s.enabled=!e}async startVoipCall(){if(!await dl.HasMicrophonePermissions()){console.warn("no permission to use microphone, can not start call");return}vr&&console.log("start voip call");try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}catch(t){console.error(t);return}this.updateMute(this.voip.muteOutput),vr&&console.log(this.stream),this.call=this.peer.call(this.peerId,this.stream,{metadata:{userId:this.userId}}),this.call.on("error",t=>{console.error(t)}),this.call.on("stream",t=>{vr&&console.log("received stream from remote again",t)}),this.peer.on("close",this.onCallClose.bind(this)),this.callErrorListener=t=>{var i;t.message.includes(this.peerId)?(console.log("Could not connect to "+this.peerId),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.close(),(i=this.stream)==null||i.getTracks().forEach(function(s){s.stop()}),this.stream=null):console.error(t)},this.peer.on("error",this.callErrorListener)}onCallClose(e){vr&&console.log("call closed",e)}}class pie{constructor(e,t,i){h(this,"voip");h(this,"call");h(this,"audio",null);h(this,"stream",null);h(this,"obj");h(this,"analyzer",null);h(this,"waitingForStart",!1);h(this,"closed",!1);h(this,"audioElement",null);this.voip=e,this.obj=t,this.call=i}get currentStream(){return this.stream}get currentAudio(){return this.audio}get currentAnalyzer(){return this.analyzer}openAudioStream(e){const t=e.getAudioTracks();for(const i of t)if(i.kind==="audio"&&i.readyState==="live"){this.open(i);return}console.warn("failed finding valid audio stream to begin call")}open(e){console.assert(e.kind==="audio","invalid track kind, expected audio but received "+e.kind),!this.waitingForStart&&(this.waitingForStart=!0,yn.userInteractionRegistered||vr&&console.log("Incoming call, waiting for user interaction before opening audio"),yn.registerWaitForAllowAudio(async()=>{if(this.call.open&&!this.closed){vr&&console.log("Setup audio and begin listening"),this.stream=new MediaStream([e]);const t=new O1;this.audio=new I_(t),this.audio.setVolume(this.voip.muteInput?0:1),this.audio.setMediaStreamSource(this.stream);const i=document.createElement("audio");this.audioElement=i,i.style.display="none",document.body.appendChild(i),i.srcObject=this.stream,i.sinkId!==void 0&&navigator.mediaDevices.enumerateDevices().then(s=>{if(i){console.log(s);for(const r of s)if(r.label==="Speakerphone"){i.sinkId=r.deviceId;break}}}),vr&&console.log("call is setup, you should hear something now"),this.analyzer=new E2(this.audio,32)}}))}close(){var e,t,i;this.closed=!0,(e=this.call)!=null&&e.open&&this.call.close(),(t=this.audio)==null||t.disconnect(),(i=this.stream)==null||i.getTracks().forEach(s=>{s.stop()}),this.stream=null,this.audioElement&&this.audioElement.remove()}}class dl extends Ie{constructor(){super(...arguments);h(this,"requireParam",!1);h(this,"peer",null);h(this,"model",null);h(this,"connections",{});h(this,"currentIncomingCalls",{});h(this,"_inputMuted",!1);h(this,"_outputMuted",!1)}set muteInput(t){var s;if(t===this._inputMuted||(this._inputMuted=t,!this.currentIncomingCalls))return;const i=this._inputMuted?0:1;for(const r in this.currentIncomingCalls){const o=this.currentIncomingCalls[r];(s=o==null?void 0:o.currentAudio)==null||s.setVolume(i)}}get muteInput(){return this._inputMuted}set muteOutput(t){if(t!==this._outputMuted&&(this._outputMuted=t,!!this.connections))for(const i in this.connections){const s=this.connections[i];s==null||s.updateMute(t)}}get muteOutput(){return this._outputMuted}getFrequency(t){if(t===null){for(const s in this.currentIncomingCalls){const r=this.currentIncomingCalls[s];if(r&&r.currentAnalyzer)return r.currentAnalyzer.getAverageFrequency()}return null}const i=this.currentIncomingCalls[t];return i&&i.currentAnalyzer?i.currentAnalyzer.getAverageFrequency():null}awake(){if(re(Rb)){console.log("VOIP is disabled by url parameter: "+Rb);return}if(this.requireParam&&!uie){console.debug("VOIP must be enabled explicitly by url parameter");return}if(Dm()&&Rc()){console.log("VOIP is currently not supported on Safari iOS");return}this.peer=Y1(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,this.context.connection.beginListen(on.JoinedRoom,t=>{navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).catch(i=>{console.error("Error initializing VoIP connection.",i)})}),this.context.connection.beginListen("peer-update-id",t=>{if(t.id!==this.context.connection.connectionId){const i=this.connections[t.id];if(i&&i.close(),this.peer&&this.context.connection.connectionId){const s=new fie(this,this.peer,this.context.connection.connectionId,t.peerId);this.connections[t.id]=s,s.startVoipCall()}}}),this.context.connection.beginListen(on.UserLeftRoom,t=>{const{userId:i}=t,s=this.connections[i];this.connections[i]=null,s&&s.close();const r=this.currentIncomingCalls[i];vr&&console.log("UserLeftRoom",t,i,r),r&&(r.close(),this.currentIncomingCalls[i]=null)}),this.peer.on("open",this.onOpenPeerConnection.bind(this))}onEnable(){}onDisable(){console.log("TODO: close all");for(const t in this.currentIncomingCalls)try{const i=this.currentIncomingCalls[t];i==null||i.close();const s=this.connections[t];s==null||s.close()}catch(i){console.error(i)}}async onOpenPeerConnection(t){vr&&console.log("Peer connection established and received id"),this.model=new die(t),this.context.connection.send("peer-update-id",this.model,Ar.OnRoomJoin),this.peer&&(this.peer.on("call",this.onReceiveCall.bind(this)),this.peer.on("connection",function(i){vr&&console.log("CONNECTION",i),i.on("data",function(s){vr&&console.log("Received",s)})}))}async onReceiveCall(t){if(!t)return;const{metadata:i}=t;console.assert(i.userId);const{userId:s}=i,r=this.currentIncomingCalls[s];if(r&&r.close(),vr&&console.log("received call"),await dl.HasMicrophonePermissions())try{const o=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});t.answer(o)}catch(o){console.error("Error initializing VoIP connection.",o)}else t.answer(null);this.currentIncomingCalls[s]=new pie(this,this.gameObject,t),t.on("stream",o=>{var a;vr&&console.log("receive caller stream, will setup audio now"),(a=this.currentIncomingCalls[s])==null||a.openAudioStream(o)}),t.on("error",console.error)}static async HasMicrophonePermissions(){try{return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}catch(t){return console.error("Error querying `microphone` permissions.",t),!1}}}var gie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,Uz=(n,e,t,i)=>{for(var s=i>1?void 0:i?mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gie(e,t,s),s};const Aie=re("debugmouth");class XA extends Ie{constructor(){super(...arguments);h(this,"idle",[]);h(this,"talking",[]);h(this,"marker",null);h(this,"voip",null);h(this,"lastMouthChangeTime",0);h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=ne.findObjectOfType(dl,this.context),this.marker||(this.marker=ne.getComponentInParent(this.gameObject,Jn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){Aie&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}Uz([x(Te)],XA.prototype,"idle",2);Uz([x(Te)],XA.prototype,"talking",2);class hI extends Ie{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=ne.findObjectOfType(dl,this.context),this.marker=ne.getComponentInParent(this.gameObject,Jn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var vie=Object.defineProperty,yie=Object.getOwnPropertyDescriptor,Sx=(n,e,t,i)=>{for(var s=i>1?void 0:i?yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vie(e,t,s),s};class Hu extends Ie{constructor(){super(...arguments);h(this,"eyes",[]);h(this,"lastBlinkTime",0);h(this,"blinkLength",0);h(this,"eyesOpen",!0);h(this,"state",null)}awake(){this.state=ne.getComponentInParent(this.gameObject,jr)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const i of this.eyes)i&&(i.visible=this.eyesOpen)}}}Sx([x(Te)],Hu.prototype,"eyes",2);Sx([x()],Hu.prototype,"lastBlinkTime",2);Sx([x()],Hu.prototype,"blinkLength",2);Sx([x()],Hu.prototype,"eyesOpen",2);var bie=Object.defineProperty,_ie=Object.getOwnPropertyDescriptor,uI=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bie(e,t,s),s},wC;const Nz=(wC=class extends Ie{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=ne.getComponentInParent(this.gameObject,Vm)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=ne.addNewComponent(this.gameObject,Vm)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=Ct(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=Ct(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=Nz.forward;if(o.set(0,0,1),o.applyQuaternion(zn(this.head)),o.dot(r)>.45)for(let c=0;c<t.length;c++)t[c].lookAt(this.currentTargetPoint)}}}},h(wC,"forward",new w(0,0,1)),wC);let yp=Nz;uI([x(Te)],yp.prototype,"head",2);uI([x(Te)],yp.prototype,"eyes",2);uI([x(Te)],yp.prototype,"target",2);var xie=Object.defineProperty,wie=Object.getOwnPropertyDescriptor,dI=(n,e,t,i)=>{for(var s=i>1?void 0:i?wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xie(e,t,s),s};class bp extends Ie{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!IA)return;this._axes||(this._axes=new tp(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}dI([x()],bp.prototype,"length",2);dI([x()],bp.prototype,"depthTest",2);dI([x()],bp.prototype,"isGizmo",2);class fI extends Ie{constructor(){super(...arguments);h(this,"from");h(this,"to");h(this,"hint");h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=Ct(this.to).clone(),i=Ct(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=Ct(this.hint).clone();a.sub(o);const c=new w;c.crossVectors(a,r),c.crossVectors(r,c),c.normalize();const l=s*.5,u=Math.max(this.desiredDistance,l),d=Math.sqrt(u*u-l*l),f=c.clone();f.multiplyScalar(d),f.add(o),Mn(this.gameObject,f);const p=o.clone();p.sub(c),this.gameObject.lookAt(p)}}const bO=re("debugusdz");class Cx{constructor(){h(this,"behaviours",[]);h(this,"behaviourComponents",[]);h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{ne.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){bO&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(bO&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var Sie=Object.defineProperty,Cie=Object.getOwnPropertyDescriptor,pI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sie(e,t,s),s};class Vu extends Us{constructor(){super(...arguments);h(this,"threshold");h(this,"intensity");h(this,"scatter");h(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new nN(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new hT;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}pI([x(Rt)],Vu.prototype,"threshold",2);pI([x(Rt)],Vu.prototype,"intensity",2);pI([x(Rt)],Vu.prototype,"scatter",2);No("Bloom",Vu);var Eie=Object.defineProperty,Mie=Object.getOwnPropertyDescriptor,fa=(n,e,t,i)=>{for(var s=i>1?void 0:i?Mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Eie(e,t,s),s};class Za extends Ie{constructor(){super(...arguments);h(this,"attachedRigidbody",null);h(this,"isTrigger",!1);h(this,"sharedMaterial");h(this,"updateProperties",()=>{var t;(t=this.context.physics.engine)==null||t.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}get body(){var t;return(t=this.context.physics.engine)==null?void 0:t.getBody(this)}}fa([x(Ii)],Za.prototype,"attachedRigidbody",2);fa([x()],Za.prototype,"isTrigger",2);fa([x()],Za.prototype,"sharedMaterial",2);class qA extends Za{constructor(){super(...arguments);h(this,"radius",.5);h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center),z1(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),N2(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}fa([ys(),x()],qA.prototype,"radius",2);fa([x(w)],qA.prototype,"center",2);class YA extends Za{constructor(){super(...arguments);h(this,"size",new w(1,1,1));h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}onValidate(){this.updateProperties()}}fa([ys(),x(w)],YA.prototype,"size",2);fa([x(w)],YA.prototype,"center",2);class KA extends Za{constructor(){super(...arguments);h(this,"sharedMesh");h(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,ls(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const c in a.children){const l=a.children[c];l.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,l,this.convex,ls(this.gameObject)))}}}}}fa([x()],KA.prototype,"convex",2);class lh extends Za{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}fa([x(w)],lh.prototype,"center",2);fa([x()],lh.prototype,"radius",2);fa([x()],lh.prototype,"height",2);var Tie=Object.defineProperty,Iie=Object.getOwnPropertyDescriptor,gI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Iie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tie(e,t,s),s};class Qu extends Ie{constructor(){super(...arguments);h(this,"objectBounds",!1);h(this,"color");h(this,"isGizmo",!0);h(this,"_gizmoObject",null);h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!IA||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new P_(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=YN(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Tr.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var t;for(;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}gI([x()],Qu.prototype,"objectBounds",2);gI([x(_e)],Qu.prototype,"color",2);gI([x()],Qu.prototype,"isGizmo",2);var Rie=Object.defineProperty,Pie=Object.getOwnPropertyDescriptor,JA=(n,e,t,i)=>{for(var s=i>1?void 0:i?Pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Rie(e,t,s),s};const VS=re("debugui"),QS=re("debuguilayout");class mI{constructor(){h(this,"width");h(this,"height")}}class AI{constructor(){h(this,"x");h(this,"y");h(this,"width");h(this,"height")}}const qo=new w,lg=new Me,Oy=new we,zz=class extends aa{constructor(){super(...arguments);h(this,"_anchoredPosition");h(this,"sizeDelta",new te(100,100));h(this,"pivot",new te(.5,.5));h(this,"anchorMin",new te(0,0));h(this,"anchorMax",new te(1,1));h(this,"lastMatrix");h(this,"rectBlock");h(this,"_transformNeedsUpdate",!1);h(this,"_initialPosition");h(this,"_parentRectTransform");h(this,"_lastUpdateFrame",-1);h(this,"_lastAnchoring");h(this,"_createdBlocks",[]);h(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new Me,this.rectBlock=new Te,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Jd(this,"_anchoredPosition",()=>{this.markDirty()}),Jd(this,"sizeDelta",()=>{this.markDirty()}),Jd(this,"pivot",()=>{this.markDirty()}),Jd(this,"anchorMin",()=>{this.markDirty()}),Jd(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(QS?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(QS&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(e){var s;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=ne.getComponentInParent(this.gameObject.parent,zz):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,QS&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,qo.set(0,0,0),this.applyPivot(qo),t.matrix.setPosition(qo.x,qo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Oy.copy(this.gameObject.quaternion),Oy.x*=-1,Oy.z*=-1,lg.makeRotationFromQuaternion(Oy),t.matrix.premultiply(lg)),qo.set(0,0,0),this.applyAnchoring(qo),(s=this.Canvas)!=null&&s.screenspace?qo.z+=.1:qo.z+=.01,lg.identity(),lg.setPosition(qo.x,qo.y,qo.z),t.matrix.premultiply(lg),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of sT(this.gameObject,aa,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},VS&&console.log(this.name,e);const t=new aI(e);return this._createdBlocks.push(t),t}createNewText(e){VS&&console.log(e),e={...this.getBasicOptions(),...e},VS&&console.log(this.name,e);const t=new Oz(e);return this._createdTextBlocks.push(t),t}};let rr=zz;JA([x(te)],rr.prototype,"anchoredPosition",1);JA([x(te)],rr.prototype,"sizeDelta",2);JA([x(te)],rr.prototype,"pivot",2);JA([x(te)],rr.prototype,"anchorMin",2);JA([x(te)],rr.prototype,"anchorMax",2);class Bie extends Dz{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var Die=Object.defineProperty,Oie=Object.getOwnPropertyDescriptor,Gz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Oie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Die(e,t,s),s};class _p extends Ie{constructor(){super(...arguments);h(this,"effectColor");h(this,"effectDistance")}}Gz([x(bi)],_p.prototype,"effectColor",2);Gz([x(te)],_p.prototype,"effectDistance",2);var kie=Object.defineProperty,Lie=Object.getOwnPropertyDescriptor,Hz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&kie(e,t,s),s};const ky={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var SC;const D0=(SC=class extends aa{constructor(){super(...arguments);h(this,"_alphaFactor",1);h(this,"raycastTarget",!0);h(this,"uiObject",null);h(this,"_color",null);h(this,"_rect",null);h(this,"_stateManager",null);h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new bi(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new bi(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ky.backgroundColor=this._color,ky.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ky,this._alphaFactor),this.uiObject.set(ky),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=ne.getComponent(this.gameObject,rr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Bie(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Jd(this,"_color",()=>Ute(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(_p);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===Ze){if(D0.textureCache.has(e))e=D0.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=An,D0.textureCache.set(e,t),e=t}}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(SC,"textureCache",new Map),SC);let Wu=D0;Hz([x(bi)],Wu.prototype,"color",1);Hz([x()],Wu.prototype,"raycastTarget",2);class ZA extends Wu{constructor(){super(...arguments);h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Fie=Object.defineProperty,Uie=Object.getOwnPropertyDescriptor,Ex=(n,e,t,i)=>{for(var s=i>1?void 0:i?Uie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fie(e,t,s),s};let vI=class{constructor(){h(this,"texture",null);h(this,"rect")}};Ex([x(Ot)],vI.prototype,"texture",2);let xp=class extends ZA{constructor(){super(...arguments);h(this,"_sprite");h(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new vI),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,c,l;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((l=(c=(a=this.sprite)==null?void 0:a.texture)==null?void 0:c.image)==null?void 0:l.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Ex([x(vI)],xp.prototype,"sprite",1);Ex([x()],xp.prototype,"pixelsPerUnitMultiplier",2);class Mx extends ZA{constructor(){super(...arguments);h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Ex([x(Ot)],Mx.prototype,"mainTexture",1);var Nie=Object.defineProperty,zie=Object.getOwnPropertyDescriptor,io=(n,e,t,i)=>{for(var s=i>1?void 0:i?zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nie(e,t,s),s};const Ud=re("debugbutton");class ju{constructor(){h(this,"colorMultiplier");h(this,"disabledColor");h(this,"fadeDuration");h(this,"highlightedColor");h(this,"normalColor");h(this,"pressedColor");h(this,"selectedColor")}}io([x()],ju.prototype,"colorMultiplier",2);io([x(bi)],ju.prototype,"disabledColor",2);io([x()],ju.prototype,"fadeDuration",2);io([x(bi)],ju.prototype,"highlightedColor",2);io([x(bi)],ju.prototype,"normalColor",2);io([x(bi)],ju.prototype,"pressedColor",2);io([x(bi)],ju.prototype,"selectedColor",2);class fl extends Ie{constructor(){super(...arguments);h(this,"onClick");h(this,"_isHovered",!1);h(this,"colors");h(this,"transition");h(this,"animationTriggers");h(this,"animator");h(this,"_interactable",!0);h(this,"_requestedAnimatorTrigger");h(this,"_isInit",!1);h(this,"_image")}onPointerEnter(t){var i,s;Ud&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var t,i;Ud&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;Ud&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(t){var i,s;Ud&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(t){var i;!this.interactable||t.pointerId===void 0||t.pointerId!==0&&this.context.input.getIsMouse(t.pointerId)||(Ud&&(console.warn("Button Click",this.onClick),pn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(i=this.onClick)==null||i.invoke(),t.use())}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),Ud&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=ne.getComponent(this.gameObject,xp),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,g,A,v,m;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),c={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(c);const l=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),u={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};t.setupState(u);const d=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}io([x(us)],fl.prototype,"onClick",2);io([x()],fl.prototype,"colors",2);io([x()],fl.prototype,"transition",2);io([x()],fl.prototype,"animationTriggers",2);io([x(ks)],fl.prototype,"animator",2);io([x()],fl.prototype,"interactable",1);var Gie=Object.defineProperty,Hie=Object.getOwnPropertyDescriptor,Pn=(n,e,t,i)=>{for(var s=i>1?void 0:i?Hie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Gie(e,t,s),s};const _O=re("debuguilayout");class _h{constructor(){h(this,"left",0);h(this,"right",0);h(this,"top",0);h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Pn([x()],_h.prototype,"left",2);Pn([x()],_h.prototype,"right",2);Pn([x()],_h.prototype,"top",2);Pn([x()],_h.prototype,"bottom",2);class no extends Ie{constructor(){super(...arguments);h(this,"_rectTransform",null);h(this,"_needsUpdate",!1);h(this,"childAlignment",0);h(this,"reverseArrangement",!1);h(this,"spacing",0);h(this,"padding");h(this,"minWidth",0);h(this,"minHeight",0);h(this,"flexibleHeight",0);h(this,"flexibleWidth",0);h(this,"preferredHeight",0);h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(_O&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){_O&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(rr);const t=this.gameObject.getComponentInParent(ps);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(ps);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Pn([x()],no.prototype,"childAlignment",2);Pn([x()],no.prototype,"reverseArrangement",2);Pn([x()],no.prototype,"spacing",2);Pn([x(_h)],no.prototype,"padding",2);Pn([x()],no.prototype,"minWidth",2);Pn([x()],no.prototype,"minHeight",2);Pn([x()],no.prototype,"flexibleHeight",2);Pn([x()],no.prototype,"flexibleWidth",2);Pn([x()],no.prototype,"preferredHeight",2);Pn([x()],no.prototype,"preferredWidth",2);class xh extends no{constructor(){super(...arguments);h(this,"childControlHeight",!0);h(this,"childControlWidth",!0);h(this,"childForceExpandHeight",!1);h(this,"childForceExpandWidth",!1);h(this,"childScaleHeight",!1);h(this,"childScaleWidth",!1)}onCalculateLayout(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const c=i==="x",l=c?"y":"x",u=c?this.childControlWidth:this.childControlHeight,d=c?this.childControlHeight:this.childControlWidth,f=c?this.childForceExpandWidth:this.childForceExpandHeight,p=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?a:r,A=c?s:o,v=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let m=0;c?m+=this.padding.left:m+=this.padding.top;let b=0,y=0;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],D=ne.getComponent(T,rr);D!=null&&D.activeAndEnabled&&(y+=1,c?b+=D.width:b+=D.height)}let _=0;const C=this.spacing*(y-1);if(f||u){let E=0;c?E=r-=C:E=a-=C,y>0&&(_=E/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(m=A-b,m*=v,m-=C*v,c?(m-=this.padding.right*v,m+=this.padding.left*(1-v),m<this.padding.left&&(m=this.padding.left)):(m-=this.padding.bottom*v,m+=this.padding.top*(1-v),m<this.padding.top&&(m=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],D=ne.getComponent(T,rr);if(D!=null&&D.activeAndEnabled){(R=D.pivot)==null||R.set(.5,.5),D.anchorMin.set(0,1),D.anchorMax.set(0,1);const K=s*.5+M*.5;D.anchoredPosition.x!==K&&(D.anchoredPosition.x=K);const H=o*-.5;D.anchoredPosition.y!==H&&(D.anchoredPosition.y=H),p&&d&&D.sizeDelta[l]!==g&&(D.sizeDelta[l]=g),f&&u&&D.sizeDelta[i]!==_&&(D.sizeDelta[i]=_);const V=c?D.width:D.height,Y=V*.5;if(m+=Y,f){const L=_*I-_*.5;L>m&&(m=L-_*.5+V+this.padding.left,m-=Y)}let N=m;i==="y"&&(N=-N),D.anchoredPosition[i]!==N&&(D.anchoredPosition[i]=N),m+=Y,m+=this.spacing,I+=1}}}}Pn([x()],xh.prototype,"childControlHeight",2);Pn([x()],xh.prototype,"childControlWidth",2);Pn([x()],xh.prototype,"childForceExpandHeight",2);Pn([x()],xh.prototype,"childForceExpandWidth",2);Pn([x()],xh.prototype,"childScaleHeight",2);Pn([x()],xh.prototype,"childScaleWidth",2);class yI extends xh{get primaryAxis(){return"y"}}class bI extends xh{get primaryAxis(){return"x"}}class _I extends no{onCalculateLayout(){}}var Vie=Object.defineProperty,Qie=Object.getOwnPropertyDescriptor,$a=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Vie(e,t,s),s},Vz=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(Vz||{});const WS=re("debuguilayout"),Qz=class extends HA{constructor(){super(...arguments);h(this,"_renderOnTop");h(this,"_depthWrite",!1);h(this,"_doubleSided",!0);h(this,"_castShadows",!1);h(this,"_receiveShadows",!1);h(this,"_renderMode",-1);h(this,"_rootCanvas");h(this,"_scaleFactor",1);h(this,"worldCamera");h(this,"planeDistance",-1);h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));h(this,"previousParent",null);h(this,"_lastMatrixWorld",null);h(this,"_rectTransforms",[]);h(this,"_layoutGroups",new Map);h(this,"_receivers",[]);h(this,"onBeforeRenderRoutine",()=>{var e,t,i,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context,!0);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context))});h(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.copy(this.gameObject.matrixWorld)}});h(this,"_updateRenderSettingsRoutine");h(this,"_activeRenderMode",-1);h(this,"_lastWidth",-1);h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof Qz||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,WS&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Me,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(e){this._receivers.push(e)}unregisterEventReceiver(e){const t=this._receivers.indexOf(e);t!==-1&&this._receivers.splice(t,1)}invokeBeforeRenderEvents(){var e;for(const t of this._receivers)(e=t.onBeforeCanvasRender)==null||e.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Me);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);WS&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(no)),(i.isDirty||s!=null&&s.isDirty)&&(WS&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Tr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Tb(this.shadowComponent,this);for(const e of ne.getComponentsInChildren(this.gameObject,aa))Tb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=tt.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(rr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,c=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let ps=Qz;$a([x()],ps.prototype,"renderOnTop",1);$a([x()],ps.prototype,"depthWrite",1);$a([x()],ps.prototype,"doubleSided",1);$a([x()],ps.prototype,"castShadows",1);$a([x()],ps.prototype,"receiveShadows",1);$a([x()],ps.prototype,"renderMode",1);$a([x(ps)],ps.prototype,"rootCanvas",1);$a([x()],ps.prototype,"scaleFactor",1);$a([x(Li)],ps.prototype,"worldCamera",2);$a([x()],ps.prototype,"planeDistance",2);var Wie=Object.defineProperty,jie=Object.getOwnPropertyDescriptor,xI=(n,e,t,i)=>{for(var s=i>1?void 0:i?jie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wie(e,t,s),s};class hh extends Ie{constructor(){super(...arguments);h(this,"_alpha",1);h(this,"interactable",!0);h(this,"blocksRaycasts",!0);h(this,"_isDirty",!1);h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Tr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of ne.getComponentsInChildren(this.gameObject,aa,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}xI([x()],hh.prototype,"alpha",1);xI([x()],hh.prototype,"interactable",2);xI([x()],hh.prototype,"blocksRaycasts",2);var Xie=Object.defineProperty,qie=Object.getOwnPropertyDescriptor,Fi=(n,e,t,i)=>{for(var s=i>1?void 0:i?qie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xie(e,t,s),s};class Xu extends Ie{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new we);h(this,"targetScale",new w)}*moveToTarget(){if(!this.target||!this.object)return;const t=Ct(this.object).clone(),i=Ct(this.target).clone(),s=zn(this.object).clone(),r=zn(this.target).clone(),o=ls(this.object).clone(),a=ls(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),u=o.distanceTo(a);if(c<.01&&l<.01&&u<.01){Mn(this.object,i),Mr(this.object,r),AE(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),Mn(this.object,this.targetPos),Mr(this.object,this.targetRot),AE(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new ds("Move to "+((i=this.target)==null?void 0:i.name),Cr.tapTrigger(this.gameObject),fi.transformAction(this.object,this.target,this.duration,this.relativeMotion?tM.Relative:tM.Absolute));t.addBehavior(s)}}}Fi([x(Te)],Xu.prototype,"object",2);Fi([x(Te)],Xu.prototype,"target",2);Fi([x()],Xu.prototype,"duration",2);Fi([x()],Xu.prototype,"relativeMotion",2);var i0;const _c=(i0=class extends Ie{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",[]);h(this,"selfModel");h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=ne.findObjectsOfType(Qi);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof ye)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof yr)for(const r of t.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this._objectsWithThisMaterial.length;t++){const i=this._objectsWithThisMaterial[t];i.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],_c._materialTriggersPerId={},_c.variantSwitchIndex=0,this.materialToSwitch&&await Hr.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Hr.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(_c._materialTriggersPerId[this.materialToSwitch.uuid]||(_c._materialTriggersPerId[this.materialToSwitch.uuid]=[]),_c._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=_c._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete _c._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const c=fi.fadeAction(a,o,!1);r.push(c)}for(const a of i)r.push(fi.fadeAction(a,o,!1));for(const a of t)s.push(fi.fadeAction(a,o,!1)),r.push(fi.fadeAction(a,o,!0));e.addBehavior(new ds("Select "+this.selfModel.name,Cr.tapTrigger(this.selfModel),fi.parallel(...r))),e.addBehavior(new ds("Start hidden "+this.selfModel.name,Cr.sceneStartTrigger(),fi.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+_c.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&_r.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(i0,"_materialTriggersPerId",{}),h(i0,"variantSwitchIndex",0),i0);let wp=_c;Fi([x(kt)],wp.prototype,"materialToSwitch",2);Fi([x(kt)],wp.prototype,"variantMaterial",2);Fi([x()],wp.prototype,"fadeDuration",2);class Sp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"otherModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1)}onPointerClick(t){t.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&e3.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(fi.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(fi.fadeAction(this.toggleModel,0,!0)),r.push(fi.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new ds("Toggle_"+this.selfModel.name+"_hideSelf",Cr.tapTrigger(this.selfModel),fi.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(fi.fadeAction(this.toggleModel,0,!1)),o.push(fi.fadeAction(this.selfModel,0,!0)),o.push(fi.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new ds("Toggle_"+this.selfModel.name+"_toggleSelf",Cr.tapTrigger(this.toggleModel),fi.sequence(...o))),t.addBehavior(new ds("HideOnStart_"+this.gameObject.name,Cr.sceneStartTrigger(),fi.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Fi([x(Te)],Sp.prototype,"target",2);Fi([x()],Sp.prototype,"targetState",2);Fi([x()],Sp.prototype,"hideSelf",2);class wI extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new ds("HideOnStart_"+this.gameObject.name,Cr.sceneStartTrigger(),fi.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Cp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType",MT.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new ds("emphasize "+this.name,Cr.tapTrigger(this.gameObject),fi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}Fi([x()],Cp.prototype,"target",2);Fi([x()],Cp.prototype,"duration",2);Fi([x()],Cp.prototype,"motionType",2);class Ep extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}onPointerClick(t){if(t.use(),!(!this.target&&!this.clip)){if(!this.target){const i=this.gameObject.addNewComponent(yn);i&&(i.spatialBlend=1,i.volume=1,i.loop=!1,this.target=i)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?iM.NonSpatial:iM.Spatial,u=new ds("playAudio "+this.name,Cr.tapTrigger(this.gameObject),fi.playAudioAction(o,"audio/"+a,o3.Play,c,l));t.addBehavior(u)}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),c=await(await(await fetch(this.clip)).blob()).arrayBuffer(),l=new Uint8Array(c);i.files["audio/"+r]=l}}Fi([x(yn)],Ep.prototype,"target",2);Fi([x(URL)],Ep.prototype,"clip",2);Fi([x()],Ep.prototype,"toggleOnClick",2);var CC;const Zd=(CC=class extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"animator");h(this,"stateName");h(this,"stateNameAfterPlaying");h(this,"loopAfterPlaying",!1);h(this,"selfModel");h(this,"stateAnimationModel");h(this,"stateAnimation");h(this,"stateAfterPlayingAnimationModel");h(this,"stateAfterPlayingAnimation")}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Zd.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let c=Zd.animationActions.find(u=>u.affectedObjects==s&&u.start==this.stateAnimation.start&&u.duration==this.stateAnimation.duration);if(c||(c=fi.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Zd.animationActions.push(c)),a.push(c),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let u=Zd.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);u||(u=fi.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Zd.animationActions.push(u));const d=fi.sequence(u);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const l=new ds("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),Cr.tapTrigger(this.selfModel),fi.sequence(...a));e.addBehavior(l)}})}createAnimation(e,t,i){var s,r,o,a,c;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((o=l==null?void 0:l.motion)!=null&&o.clip)){ci()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const u=(c=(a=this.animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:c.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,u==null?void 0:u.motion.clip)}}},h(CC,"animationActions",[]),CC);let wh=Zd;Fi([x(Te)],wh.prototype,"target",2);Fi([x(ks)],wh.prototype,"animator",2);Fi([x()],wh.prototype,"stateName",2);Fi([x()],wh.prototype,"stateNameAfterPlaying",2);Fi([x()],wh.prototype,"loopAfterPlaying",2);class Mp extends Ie{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}Fi([x(Te)],Mp.prototype,"target",2);class $A extends Ie{constructor(){super(...arguments);h(this,"target")}}Fi([x(Mp)],$A.prototype,"target",2);class ev extends Mp{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Fi([x()],ev.prototype,"type",2);Fi([x()],ev.prototype,"duration",2);class SI extends $A{}var Yie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,pl=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yie(e,t,s),s};class qu extends Ie{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ii),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Ii)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(lh);i||(i=this.gameObject.addNewComponent(lh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const c=r.dot(a)<0?-1:1,l=s.angleTo(a)*c;this.gameObject.setRotationFromAxisAngle(o,l),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}pl([x(w)],qu.prototype,"center",2);pl([x()],qu.prototype,"radius",2);pl([x()],qu.prototype,"height",2);class gl extends Ie{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new te(0,0));h(this,"moveInput",new te(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new ko)}awake(){this._currentRotation=new we}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,s){var r,o,a,c,l,u,d,f,p,g,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),v){this._jumpCount+=1;const m=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;m.applyImpulse(new w(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Ya),this._raycastOptions.ray.origin.copy(Ct(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const m=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(m),(b.length&&b[0].distance>2||v<-10)&&((g=this.animator)==null||g.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}pl([x(qu)],gl.prototype,"controller",2);pl([x()],gl.prototype,"movementSpeed",2);pl([x()],gl.prototype,"rotationSpeed",2);pl([x()],gl.prototype,"jumpForce",2);pl([x()],gl.prototype,"doubleJumpForce",2);pl([x(ks)],gl.prototype,"animator",2);var Jie=Object.defineProperty,Zie=Object.getOwnPropertyDescriptor,$ie=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jie(e,t,s),s};class tv extends Us{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new $U;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}$ie([x(Rt)],tv.prototype,"intensity",2);No("ChromaticAberration",tv);var ene=Object.defineProperty,tne=Object.getOwnPropertyDescriptor,Tx=(n,e,t,i)=>{for(var s=i>1?void 0:i?tne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ene(e,t,s),s};class Sh extends Us{constructor(){super(...arguments);h(this,"postExposure");h(this,"contrast");h(this,"hueShift");h(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.postExposure.defaultValue=0,this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===er&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=_m);const t=new ZU;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===er&&(this.context.renderer.toneMapping=_m),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new tN;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}Tx([x(Rt)],Sh.prototype,"postExposure",2);Tx([x(Rt)],Sh.prototype,"contrast",2);Tx([x(Rt)],Sh.prototype,"hueShift",2);Tx([x(Rt)],Sh.prototype,"saturation",2);No("ColorAdjustments",Sh);const ine=(Math.sqrt(5)-1)/4,ts=(5-Math.sqrt(5))/20,Ly=n=>Math.floor(n)|0,Fy=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function nne(n=Math.random){const e=sne(n),t=new Float64Array(e).map(o=>Fy[o%32*4]),i=new Float64Array(e).map(o=>Fy[o%32*4+1]),s=new Float64Array(e).map(o=>Fy[o%32*4+2]),r=new Float64Array(e).map(o=>Fy[o%32*4+3]);return function(a,c,l,u){let d,f,p,g,A;const v=(a+c+l+u)*ine,m=Ly(a+v),b=Ly(c+v),y=Ly(l+v),_=Ly(u+v),C=(m+b+y+_)*ts,M=m-C,I=b-C,R=y-C,E=_-C,T=a-M,D=c-I,K=l-R,H=u-E;let V=0,Y=0,N=0,L=0;T>D?V++:Y++,T>K?V++:N++,T>H?V++:L++,D>K?Y++:N++,D>H?Y++:L++,K>H?N++:L++;const G=V>=3?1:0,ee=Y>=3?1:0,$=N>=3?1:0,j=L>=3?1:0,ie=V>=2?1:0,Ae=Y>=2?1:0,ge=N>=2?1:0,Ce=L>=2?1:0,Ee=V>=1?1:0,Ge=Y>=1?1:0,Qe=N>=1?1:0,ut=L>=1?1:0,Et=T-G+ts,st=D-ee+ts,W=K-$+ts,Fe=H-j+ts,me=T-ie+2*ts,Le=D-Ae+2*ts,Se=K-ge+2*ts,it=H-Ce+2*ts,Xe=T-Ee+3*ts,Ye=D-Ge+3*ts,At=K-Qe+3*ts,Mt=H-ut+3*ts,Yt=T-1+4*ts,z=D-1+4*ts,k=K-1+4*ts,he=H-1+4*ts,Pe=m&255,Be=b&255,Ue=y&255,X=_&255;let de=.6-T*T-D*D-K*K-H*H;if(de<0)d=0;else{const ke=Pe+e[Be+e[Ue+e[X]]];de*=de,d=de*de*(t[ke]*T+i[ke]*D+s[ke]*K+r[ke]*H)}let ce=.6-Et*Et-st*st-W*W-Fe*Fe;if(ce<0)f=0;else{const ke=Pe+G+e[Be+ee+e[Ue+$+e[X+j]]];ce*=ce,f=ce*ce*(t[ke]*Et+i[ke]*st+s[ke]*W+r[ke]*Fe)}let je=.6-me*me-Le*Le-Se*Se-it*it;if(je<0)p=0;else{const ke=Pe+ie+e[Be+Ae+e[Ue+ge+e[X+Ce]]];je*=je,p=je*je*(t[ke]*me+i[ke]*Le+s[ke]*Se+r[ke]*it)}let qe=.6-Xe*Xe-Ye*Ye-At*At-Mt*Mt;if(qe<0)g=0;else{const ke=Pe+Ee+e[Be+Ge+e[Ue+Qe+e[X+ut]]];qe*=qe,g=qe*qe*(t[ke]*Xe+i[ke]*Ye+s[ke]*At+r[ke]*Mt)}let Ve=.6-Yt*Yt-z*z-k*k-he*he;if(Ve<0)A=0;else{const ke=Pe+1+e[Be+1+e[Ue+1+e[X+1]]];Ve*=Ve,A=Ve*Ve*(t[ke]*Yt+i[ke]*z+s[ke]*k+r[ke]*he)}return 27*(d+f+p+g+A)}}function sne(n){const t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var rne=Object.defineProperty,one=Object.getOwnPropertyDescriptor,se=(n,e,t,i)=>{for(var s=i>1?void 0:i?one(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rne(e,t,s),s};const Uy=re("debugparticles");var Mc=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Mc||{});let Ch=class{constructor(){h(this,"alphaKeys");h(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const c=this.alphaKeys[a];(c.time<e||!i)&&(i=c,s=a)}for(let a=0;a<this.colorKeys.length;a++){const c=this.colorKeys[a];(c.time<e||!r)&&(r=c,o=a)}if(r)if(o+1<this.colorKeys.length){const c=this.colorKeys[o+1],l=tt.remap(e,r.time,c.time,0,1);t.r=tt.lerp(r.color.r,c.color.r,l),t.g=tt.lerp(r.color.g,c.color.g,l),t.b=tt.lerp(r.color.b,c.color.b,l)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const c=this.alphaKeys[s+1],l=tt.remap(e,i.time,c.time,0,1);t.alpha=tt.lerp(i.alpha,c.alpha,l)}else t.alpha=i.alpha;return t}};se([x()],Ch.prototype,"alphaKeys",2);se([x()],Ch.prototype,"colorKeys",2);var $m=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))($m||{}),Wz=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(Wz||{});class ht{constructor(){h(this,"mode");h(this,"constant");h(this,"constantMin");h(this,"constantMax");h(this,"curve");h(this,"curveMin");h(this,"curveMax");h(this,"curveMultiplier")}evaluate(e,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const s=e*this.curveMin.duration,r=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}se([x()],ht.prototype,"mode",2);se([x()],ht.prototype,"constant",2);se([x()],ht.prototype,"constantMin",2);se([x()],ht.prototype,"constantMax",2);se([x(zu)],ht.prototype,"curve",2);se([x(zu)],ht.prototype,"curveMin",2);se([x(zu)],ht.prototype,"curveMax",2);se([x()],ht.prototype,"curveMultiplier",2);var n0;const Ko=(n0=class{constructor(){h(this,"mode");h(this,"color");h(this,"colorMin");h(this,"colorMax");h(this,"gradient");h(this,"gradientMin");h(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,Ko._temp),Ko._temp;case 2:return Ko._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,Ko._temp),this.gradientMax.evaluate(n,Ko._temp2),Ko._temp.lerp(Ko._temp2,t)}return Ko._temp.set(16711935),Ko._temp.alpha=1,Ko._temp}},h(n0,"_temp",new bi(0,0,0,1)),h(n0,"_temp2",new bi(0,0,0,1)),n0);let Ir=Ko;se([x(bi)],Ir.prototype,"color",2);se([x(bi)],Ir.prototype,"colorMin",2);se([x(bi)],Ir.prototype,"colorMax",2);se([x(Ch)],Ir.prototype,"gradient",2);se([x(Ch)],Ir.prototype,"gradientMin",2);se([x(Ch)],Ir.prototype,"gradientMax",2);var fM=(n=>(n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.Shape=2]="Shape",n))(fM||{});class bs{constructor(){h(this,"cullingMode");h(this,"duration");h(this,"emitterVelocityMode");h(this,"flipRotation");h(this,"gravityModifier");h(this,"gravityModifierMultiplier");h(this,"loop");h(this,"maxParticles");h(this,"playOnAwake");h(this,"prewarm");h(this,"ringBufferLoopRange");h(this,"ringBufferMode");h(this,"scalingMode");h(this,"simulationSpace");h(this,"simulationSpeed");h(this,"startColor");h(this,"startDelay");h(this,"startDelayMultiplier");h(this,"startLifetime");h(this,"startLifetimeMultiplier");h(this,"startRotation");h(this,"startRotationMultiplier");h(this,"startRotation3D");h(this,"startRotationX");h(this,"startRotationXMultiplier");h(this,"startRotationY");h(this,"startRotationYMultiplier");h(this,"startRotationZ");h(this,"startRotationZMultiplier");h(this,"startSize");h(this,"startSize3D");h(this,"startSizeMultiplier");h(this,"startSizeX");h(this,"startSizeXMultiplier");h(this,"startSizeY");h(this,"startSizeYMultiplier");h(this,"startSizeZ");h(this,"startSizeZMultiplier");h(this,"startSpeed");h(this,"startSpeedMultiplier");h(this,"stopAction");h(this,"useUnscaledTime")}}se([x(ht)],bs.prototype,"gravityModifier",2);se([x(Ir)],bs.prototype,"startColor",2);se([x(ht)],bs.prototype,"startDelay",2);se([x(ht)],bs.prototype,"startLifetime",2);se([x(ht)],bs.prototype,"startRotation",2);se([x(ht)],bs.prototype,"startRotationX",2);se([x(ht)],bs.prototype,"startRotationY",2);se([x(ht)],bs.prototype,"startRotationZ",2);se([x(ht)],bs.prototype,"startSize",2);se([x(ht)],bs.prototype,"startSizeX",2);se([x(ht)],bs.prototype,"startSizeY",2);se([x(ht)],bs.prototype,"startSizeZ",2);se([x(ht)],bs.prototype,"startSpeed",2);class eA{constructor(){h(this,"cycleCount");h(this,"maxCount");h(this,"minCount");h(this,"probability");h(this,"repeatInterval");h(this,"time");h(this,"count");h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(e>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const s=Math.random();t=tt.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class ec{constructor(){h(this,"enabled");h(this,"bursts");h(this,"rateOverTime");h(this,"rateOverTimeMultiplier");h(this,"rateOverDistance");h(this,"rateOverDistanceMultiplier");h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}se([x()],ec.prototype,"enabled",2);se([x()],ec.prototype,"bursts",2);se([x(ht)],ec.prototype,"rateOverTime",2);se([x()],ec.prototype,"rateOverTimeMultiplier",2);se([x(ht)],ec.prototype,"rateOverDistance",2);se([x()],ec.prototype,"rateOverDistanceMultiplier",2);class iv{constructor(){h(this,"enabled");h(this,"color")}}se([x(Ir)],iv.prototype,"color",2);class Eh{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_time",0);h(this,"_temp",new w)}evaluate(e,t,i){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}se([x(ht)],Eh.prototype,"size",2);se([x(ht)],Eh.prototype,"x",2);se([x(ht)],Eh.prototype,"y",2);se([x(ht)],Eh.prototype,"z",2);var s0;const Dg=(s0=class{constructor(){h(this,"shapeType",5);h(this,"enabled",!0);h(this,"alignToDirection",!1);h(this,"angle",0);h(this,"arc",360);h(this,"arcSpread");h(this,"arcSpeedMultiplier");h(this,"arcMode");h(this,"boxThickness");h(this,"position");h(this,"rotation");h(this,"_rotation",new mn);h(this,"scale");h(this,"radius");h(this,"radiusThickness");h(this,"sphericalDirectionAmount");h(this,"randomDirectionAmount");h(this,"randomPositionAmount");h(this,"system");h(this,"_space");h(this,"_worldSpaceMatrix",new Me);h(this,"_worldSpaceMatrixInverse",new Me);h(this,"_vector",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_dir",new w);h(this,"_loopTime",0);h(this,"_loopDirection",1);Uy&&console.log(this)}get type(){return Wz[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new Dg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Uy&&zc.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(n);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Uy&&zc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Uy&&(zc.DrawSphere(n,.01,8925952,.5,!0),zc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=Dg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=Dg._randomQuat,i=Dg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new w(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),c=Math.acos(2*o-1),l=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=n.x+this.scale.x*(-l*Math.sin(c)*Math.cos(a)),d=n.y+this.scale.y*(l*Math.sin(c)*Math.sin(a)),f=n.z+this.scale.z*(l*Math.cos(c));s.x=u,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,c=n.x+this.scale.x*a*Math.cos(o),l=n.y+this.scale.y*a*Math.sin(o),u=n.z;s.x=c,s.y=l,s.z=u}randomConePoint(n,e,t,i,s,r,o){let a=0,c=0;switch(r){case 0:a=Math.random(),c=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,c=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let l=2*Math.PI*a*(s/360);switch(r){case 2:case 1:l+=Math.PI+.5,l+=this._loopTime*Math.PI*2,l%=tt.toRadians(s);break}const u=Math.acos(2*c-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(u)*Math.cos(l),p=n.y+d*Math.sin(u)*Math.sin(l),g=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=g*this.scale.z}},h(s0,"_randomQuat",new we),h(s0,"_tempVec",new w),s0);let bn=Dg;se([x()],bn.prototype,"shapeType",2);se([x()],bn.prototype,"enabled",2);se([x()],bn.prototype,"alignToDirection",2);se([x()],bn.prototype,"angle",2);se([x()],bn.prototype,"arc",2);se([x()],bn.prototype,"arcSpread",2);se([x()],bn.prototype,"arcSpeedMultiplier",2);se([x()],bn.prototype,"arcMode",2);se([x(w)],bn.prototype,"boxThickness",2);se([x(w)],bn.prototype,"position",2);se([x(w)],bn.prototype,"rotation",2);se([x(w)],bn.prototype,"scale",2);se([x()],bn.prototype,"radius",2);se([x()],bn.prototype,"radiusThickness",2);se([x()],bn.prototype,"sphericalDirectionAmount",2);se([x()],bn.prototype,"randomDirectionAmount",2);se([x()],bn.prototype,"randomPositionAmount",2);class vi{constructor(){h(this,"damping");h(this,"enabled");h(this,"frequency");h(this,"octaveCount");h(this,"octaveMultiplier");h(this,"octaveScale");h(this,"positionAmount");h(this,"quality");h(this,"remap");h(this,"remapEnabled");h(this,"remapMultiplier");h(this,"remapX");h(this,"remapXMultiplier");h(this,"remapY");h(this,"remapYMultiplier");h(this,"remapZ");h(this,"remapZMultiplier");h(this,"scrollSpeedMultiplier");h(this,"separateAxes");h(this,"strengthMultiplier");h(this,"strengthX");h(this,"strengthXMultiplier");h(this,"strengthY");h(this,"strengthYMultiplier");h(this,"strengthZ");h(this,"strengthZMultiplier");h(this,"_noise");h(this,"_time",0);h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=nne(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),c=this._noise(a.x,a.y,a.z,this._time),l=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(c,l,u).normalize();const d=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}se([x()],vi.prototype,"damping",2);se([x()],vi.prototype,"enabled",2);se([x()],vi.prototype,"frequency",2);se([x()],vi.prototype,"octaveCount",2);se([x()],vi.prototype,"octaveMultiplier",2);se([x()],vi.prototype,"octaveScale",2);se([x(ht)],vi.prototype,"positionAmount",2);se([x()],vi.prototype,"quality",2);se([x(ht)],vi.prototype,"remap",2);se([x()],vi.prototype,"remapEnabled",2);se([x()],vi.prototype,"remapMultiplier",2);se([x(ht)],vi.prototype,"remapX",2);se([x()],vi.prototype,"remapXMultiplier",2);se([x(ht)],vi.prototype,"remapY",2);se([x()],vi.prototype,"remapYMultiplier",2);se([x(ht)],vi.prototype,"remapZ",2);se([x()],vi.prototype,"remapZMultiplier",2);se([x()],vi.prototype,"scrollSpeedMultiplier",2);se([x()],vi.prototype,"separateAxes",2);se([x()],vi.prototype,"strengthMultiplier",2);se([x(ht)],vi.prototype,"strengthX",2);se([x()],vi.prototype,"strengthXMultiplier",2);se([x(ht)],vi.prototype,"strengthY",2);se([x()],vi.prototype,"strengthYMultiplier",2);se([x(ht)],vi.prototype,"strengthZ",2);se([x()],vi.prototype,"strengthZMultiplier",2);class ji{constructor(){h(this,"enabled");h(this,"attachRibbonToTransform",!1);h(this,"colorOverLifetime");h(this,"colorOverTrail");h(this,"dieWithParticles",!0);h(this,"inheritParticleColor",!0);h(this,"lifetime");h(this,"lifetimeMultiplier");h(this,"minVertexDistance",.2);h(this,"mode",0);h(this,"ratio",1);h(this,"ribbonCount",1);h(this,"shadowBias",0);h(this,"sizeAffectsLifetime",!1);h(this,"sizeAffectsWidth",!1);h(this,"splitSubEmitterRibbons",!1);h(this,"textureMode",0);h(this,"widthOverTrail");h(this,"widthOverTrailMultiplier");h(this,"worldSpace",!1)}getWidth(e,t,i,s){const r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}se([x()],ji.prototype,"enabled",2);se([x()],ji.prototype,"attachRibbonToTransform",2);se([x(Ir)],ji.prototype,"colorOverLifetime",2);se([x(Ir)],ji.prototype,"colorOverTrail",2);se([x()],ji.prototype,"dieWithParticles",2);se([x()],ji.prototype,"inheritParticleColor",2);se([x(ht)],ji.prototype,"lifetime",2);se([x()],ji.prototype,"lifetimeMultiplier",2);se([x()],ji.prototype,"minVertexDistance",2);se([x()],ji.prototype,"mode",2);se([x()],ji.prototype,"ratio",2);se([x()],ji.prototype,"ribbonCount",2);se([x()],ji.prototype,"shadowBias",2);se([x()],ji.prototype,"sizeAffectsLifetime",2);se([x()],ji.prototype,"sizeAffectsWidth",2);se([x()],ji.prototype,"splitSubEmitterRibbons",2);se([x()],ji.prototype,"textureMode",2);se([x(ht)],ji.prototype,"widthOverTrail",2);se([x()],ji.prototype,"widthOverTrailMultiplier",2);se([x()],ji.prototype,"worldSpace",2);class Zi{constructor(){h(this,"enabled");h(this,"space",0);h(this,"orbitalX");h(this,"orbitalY");h(this,"orbitalZ");h(this,"orbitalXMultiplier");h(this,"orbitalYMultiplier");h(this,"orbitalZMultiplier");h(this,"orbitalOffsetX");h(this,"orbitalOffsetY");h(this,"orbitalOffsetZ");h(this,"speedModifier");h(this,"speedModifierMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_system");h(this,"_temp",new w);h(this,"_temp2",new w);h(this,"_temp3",new w);h(this,"_hasOrbital",!1);h(this,"_index",0);h(this,"_orbitalMatrix",new Me)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,i,s,r,o,a){var p;if(!this.enabled)return;const c=o/a,l=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,u=this.x.evaluate(c),d=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-u,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,m=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=l*Math.PI*2*10,_=Math.cos(y*v),C=Math.sin(y*v),M=Math.cos(y*m),I=Math.sin(y*m),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(M*R)+A.y*(M*E)+A.z*-I,D=A.x*(C*I*R-_*E)+A.y*(C*I*E+_*R)+A.z*(C*M),K=A.x*(_*I*R+C*E)+A.y*(_*I*E-C*R)+A.z*(_*M),H=this._temp3.set(A.x-T,A.y-D,A.z-K);H.normalize(),H.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=H.x,s.y+=H.y,s.z+=H.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=l,s.y*=l,s.z*=l}}se([x()],Zi.prototype,"enabled",2);se([x()],Zi.prototype,"space",2);se([x(ht)],Zi.prototype,"orbitalX",2);se([x(ht)],Zi.prototype,"orbitalY",2);se([x(ht)],Zi.prototype,"orbitalZ",2);se([x()],Zi.prototype,"orbitalXMultiplier",2);se([x()],Zi.prototype,"orbitalYMultiplier",2);se([x()],Zi.prototype,"orbitalZMultiplier",2);se([x()],Zi.prototype,"orbitalOffsetX",2);se([x()],Zi.prototype,"orbitalOffsetY",2);se([x()],Zi.prototype,"orbitalOffsetZ",2);se([x(ht)],Zi.prototype,"speedModifier",2);se([x()],Zi.prototype,"speedModifierMultiplier",2);se([x(ht)],Zi.prototype,"x",2);se([x()],Zi.prototype,"xMultiplier",2);se([x(ht)],Zi.prototype,"y",2);se([x()],Zi.prototype,"yMultiplier",2);se([x(ht)],Zi.prototype,"z",2);se([x()],Zi.prototype,"zMultiplier",2);class _s{constructor(){h(this,"animation");h(this,"enabled");h(this,"cycleCount");h(this,"frameOverTime");h(this,"frameOverTimeMultiplier");h(this,"numTilesX");h(this,"numTilesY");h(this,"startFrame");h(this,"startFrameMultiplier");h(this,"rowMode");h(this,"rowIndex");h(this,"spriteCount");h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}se([x()],_s.prototype,"animation",2);se([x()],_s.prototype,"enabled",2);se([x()],_s.prototype,"cycleCount",2);se([x(ht)],_s.prototype,"frameOverTime",2);se([x()],_s.prototype,"frameOverTimeMultiplier",2);se([x()],_s.prototype,"numTilesX",2);se([x()],_s.prototype,"numTilesY",2);se([x(ht)],_s.prototype,"startFrame",2);se([x()],_s.prototype,"startFrameMultiplier",2);se([x()],_s.prototype,"rowMode",2);se([x()],_s.prototype,"rowIndex",2);se([x()],_s.prototype,"spriteCount",2);se([x()],_s.prototype,"timeMode",2);class zo{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}se([x()],zo.prototype,"enabled",2);se([x()],zo.prototype,"separateAxes",2);se([x(ht)],zo.prototype,"x",2);se([x()],zo.prototype,"xMultiplier",2);se([x(ht)],zo.prototype,"y",2);se([x()],zo.prototype,"yMultiplier",2);se([x(ht)],zo.prototype,"z",2);se([x()],zo.prototype,"zMultiplier",2);class so{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}se([x()],so.prototype,"enabled",2);se([x()],so.prototype,"range",2);se([x()],so.prototype,"separateAxes",2);se([x(ht)],so.prototype,"x",2);se([x()],so.prototype,"xMultiplier",2);se([x(ht)],so.prototype,"y",2);se([x()],so.prototype,"yMultiplier",2);se([x(ht)],so.prototype,"z",2);se([x()],so.prototype,"zMultiplier",2);class Bn{constructor(){h(this,"enabled");h(this,"dampen");h(this,"drag");h(this,"dragMultiplier");h(this,"limit");h(this,"limitMultiplier");h(this,"separateAxes");h(this,"limitX");h(this,"limitXMultiplier");h(this,"limitY");h(this,"limitYMultiplier");h(this,"limitZ");h(this,"limitZMultiplier");h(this,"multiplyDragByParticleSize",!1);h(this,"multiplyDragByParticleVelocity",!1);h(this,"space");h(this,"_temp",new w);h(this,"_temp2",new w)}apply(e,t,i,s,r,o,a){if(this.enabled){const c=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>c){this._temp.copy(t).normalize().multiplyScalar(c);const u=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,u),t.y=tt.lerp(t.y,this._temp.y,u),t.z=tt.lerp(t.z,this._temp.z,u),i.x=tt.lerp(i.x,this._temp.x,u),i.y=tt.lerp(i.y,this._temp.y,u),i.z=tt.lerp(i.z,this._temp.z,u)}}}}se([x()],Bn.prototype,"enabled",2);se([x()],Bn.prototype,"dampen",2);se([x(ht)],Bn.prototype,"drag",2);se([x()],Bn.prototype,"dragMultiplier",2);se([x(ht)],Bn.prototype,"limit",2);se([x()],Bn.prototype,"limitMultiplier",2);se([x()],Bn.prototype,"separateAxes",2);se([x(ht)],Bn.prototype,"limitX",2);se([x()],Bn.prototype,"limitXMultiplier",2);se([x(ht)],Bn.prototype,"limitY",2);se([x()],Bn.prototype,"limitYMultiplier",2);se([x(ht)],Bn.prototype,"limitZ",2);se([x()],Bn.prototype,"limitZMultiplier",2);se([x()],Bn.prototype,"multiplyDragByParticleSize",2);se([x()],Bn.prototype,"multiplyDragByParticleVelocity",2);se([x()],Bn.prototype,"space",2);class Mh{constructor(){h(this,"enabled");h(this,"curve");h(this,"curveMultiplier");h(this,"mode");h(this,"system");h(this,"_lastWorldPosition");h(this,"_velocity",new w);h(this,"_temp",new w)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}se([x()],Mh.prototype,"enabled",2);se([x(ht)],Mh.prototype,"curve",2);se([x()],Mh.prototype,"curveMultiplier",2);se([x()],Mh.prototype,"mode",2);class lr{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t,i,s){const r=e.length(),o=tt.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}se([x()],lr.prototype,"enabled",2);se([x(te)],lr.prototype,"range",2);se([x()],lr.prototype,"separateAxes",2);se([x(ht)],lr.prototype,"size",2);se([x()],lr.prototype,"sizeMultiplier",2);se([x(ht)],lr.prototype,"x",2);se([x()],lr.prototype,"xMultiplier",2);se([x(ht)],lr.prototype,"y",2);se([x()],lr.prototype,"yMultiplier",2);se([x(ht)],lr.prototype,"z",2);se([x()],lr.prototype,"zMultiplier",2);class Yu{constructor(){h(this,"enabled");h(this,"range");h(this,"color")}evaluate(e,t,i){const s=e.length(),r=tt.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}se([x()],Yu.prototype,"enabled",2);se([x(te)],Yu.prototype,"range",2);se([x(Ir)],Yu.prototype,"color",2);function xO(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}function ane(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,c=(i<10?"0":"")+i,l=(s<10?"0":"")+s,u=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+c+l+u}const Ny=re("debugusdz");function cne(n,e){const t=[],i=ne.getComponentsInChildren(n,ks),s=ne.getComponentsInChildren(n,$r);let r=!1;const o=new tr("rest",.01,[]),a=new Map,c=(l,u)=>{if(!r&&u.tracks.length>0&&(r=!0,l.push(o)),u.tracks.length>0)for(const d of u.tracks){const f=Nt.parseTrackName(d.name),p=Nt.findNode(n,f.nodeName);if(p){a.has(p)||a.set(p,[]);const g=a.get(p);switch(f.propertyName){case"position":{if(g.includes("position"))continue;const A=p.position,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("position"),o.tracks.push(v);break}case"quaternion":{if(g.includes("quaternion"))continue;const A=p.quaternion,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);g.push("quaternion"),o.tracks.push(v);break}case"scale":{if(g.includes("scale"))continue;const A=p.scale,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("scale"),o.tracks.push(v);break}}}}};for(const l of i){if(!l||!l.runtimeAnimatorController)continue;Ny&&console.log(l);const u=[];for(const d of l.runtimeAnimatorController.enumerateActions()){Ny&&console.log(d);const f=d.getClip();c(u,f),u.includes(f)||u.push(f)}t.push({root:l.gameObject,clips:u})}for(const l of s){Ny&&console.log(l);const u=[];for(const d of l.animations)c(u,d),u.includes(d)||u.push(d);t.push({root:l.gameObject,clips:u})}Ny&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const l of t)for(const u of l.clips)e.registerAnimation(l.root,u)}class lne{static createButton(e,t={},i){const s=document.createElement("button");let r=!1;function o(){if(t.optionalFeatures=t.optionalFeatures||[],t.domOverlay===void 0){var u=document.createElement("div");u.style.display="none",document.body.appendChild(u);var d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width",38),d.setAttribute("height",38),d.style.position="absolute",d.style.right="20px",d.style.top="20px",d.addEventListener("click",function(){p.end()}),u.appendChild(d);var f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),f.setAttribute("stroke","#fff"),f.setAttribute("stroke-width",2),d.appendChild(f),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:u},r=!0}let p=null,g=null;async function A(m){var _;const b=/WebXRViewer\//i.test(navigator.userAgent),y=t.domOverlay.root;b&&((_=t.domOverlay)!=null&&_.root?(g=y.parentNode,g&&(console.log("Reparent DOM Overlay to body",y,y.style.display),y.style.display="",y.style.visibility="",document.body.appendChild(y))):console.warn("WebXRViewer: No DOM Overlay found")),m.addEventListener("end",v),await e.xr.setSession(m),s.textContent="STOP AR",r&&(t.domOverlay.root.style.display=""),p=m}function v(){p.removeEventListener("end",v),s.textContent="START AR";const m=t.domOverlay.root;g&&g.appendChild(m),r&&(m.style.display="none"),p=null}s.style.display="",s.style.cursor="pointer",s.style.left="calc(50% - 50px)",s.style.width="100px",s.textContent="START AR",s.onmouseenter=function(){s.style.opacity="1.0"},s.onmouseleave=function(){s.style.opacity="0.5"},s.onclick=function(){p===null?(i==null||i.call(this,t),navigator.xr.requestSession("immersive-ar",t).then(A)):p.end()}}function a(){s.disabled=!0,s.style.display="",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function c(){a(),s.textContent="AR NOT SUPPORTED"}function l(u){u.style.position="absolute",u.style.bottom="20px",u.style.padding="12px 6px",u.style.border="1px solid #fff",u.style.borderRadius="4px",u.style.background="rgba(0,0,0,0.1)",u.style.color="#fff",u.style.font="normal 13px sans-serif",u.style.textAlign="center",u.style.opacity="0.5",u.style.outline="none",u.style.zIndex="999"}if("xr"in navigator)return s.id="ARButton",s.style.display="none",l(s),navigator.xr.isSessionSupported("immersive-ar").then(function(u){u?o():c()}).catch(c),s;{const u=document.createElement("a");return window.isSecureContext===!1?(u.href=document.location.href.replace(/^http:/,"https:"),u.innerHTML="WEBXR NEEDS HTTPS"):(u.href="https://immersiveweb.dev/",u.innerHTML="WEBXR NOT AVAILABLE"),u.style.left="calc(50% - 90px)",u.style.width="180px",u.style.textDecoration="none",l(u),u}}}const Gb=class{static createButton(e,t){const i=document.createElement("button");function s(){let c=null;async function l(d){d.addEventListener("end",u),await e.xr.setSession(d),i.textContent="EXIT VR",c=d}function u(){c.removeEventListener("end",u),i.textContent="ENTER VR",c=null}i.style.display="",i.style.cursor="pointer",i.style.left="calc(50% - 50px)",i.style.width="100px",i.textContent="ENTER VR",i.onmouseenter=function(){i.style.opacity="1.0"},i.onmouseleave=function(){i.style.opacity="0.5"},i.onclick=function(){if(c===null){const d={optionalFeatures:t.optionalFeatures};navigator.xr.requestSession("immersive-vr",d).then(l)}else c.end()}}function r(){i.disabled=!0,i.style.display="",i.style.cursor="auto",i.style.left="calc(50% - 75px)",i.style.width="150px",i.onmouseenter=null,i.onmouseleave=null,i.onclick=null}function o(){r(),i.textContent="VR NOT SUPPORTED"}function a(c){c.style.position="absolute",c.style.bottom="20px",c.style.padding="12px 6px",c.style.border="1px solid #fff",c.style.borderRadius="4px",c.style.background="rgba(0,0,0,0.1)",c.style.color="#fff",c.style.font="normal 13px sans-serif",c.style.textAlign="center",c.style.opacity="0.5",c.style.outline="none",c.style.zIndex="999"}if("xr"in navigator)return i.id="VRButton",i.style.display="none",a(i),navigator.xr.isSessionSupported("immersive-vr").then(function(c){c?s():o(),Gb.xrSessionIsGranted&&(console.log("XR session is granted - will enter immersive web now"),i.click())}),i;{const c=document.createElement("a");return window.isSecureContext===!1?(c.href=document.location.href.replace(/^http:/,"https:"),c.innerHTML="WEBXR NEEDS HTTPS"):(c.href="https://immersiveweb.dev/",c.innerHTML="WEBXR NOT AVAILABLE"),c.style.left="calc(50% - 90px)",c.style.width="180px",c.style.textDecoration="none",a(c),c}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Gb.xrSessionIsGranted=!0})}}};let rm=Gb;h(rm,"xrSessionIsGranted",!1);rm.registerSessionGrantedListener();var hne=Object.defineProperty,une=Object.getOwnPropertyDescriptor,CI=(n,e,t,i)=>{for(var s=i>1?void 0:i?une(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&hne(e,t,s),s};const dne=new Me;class ca extends Ie{constructor(){super(...arguments);h(this,"webAR",null);h(this,"invertForward",!1);h(this,"arTouchTransform",!1);h(this,"_initalMatrix",new Me);h(this,"_selectStartFn",this.onSelectStart.bind(this));h(this,"_selectEndFn",this.onSelectEnd.bind(this));h(this,"userInput");h(this,"_arScale",1);h(this,"_rig",null);h(this,"_startPose",null);h(this,"_placementPose",null);h(this,"_isTouching",!1);h(this,"_rigStartPose",null);h(this,"_gotFirstHitTestResult",!1);h(this,"_anchor",null);h(this,"_anchorMatrix",new Me);h(this,"_invertedSessionRootMatrix",new Me);h(this,"_invertForwardMatrix",new Me().makeRotationY(Math.PI))}get rig(){var t;return(t=this.webAR)==null?void 0:t.webxr.Rig}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.setScale(t))}start(){const t=ne.findObjectOfType(It);t&&(t.Rig.updateMatrix(),this._initalMatrix.copy(t.Rig.matrix))}onBegin(t){var i;this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose=this.gameObject.matrix.clone(),this._rigStartPose=(i=this.rig)==null?void 0:i.matrix.clone(),this._gotFirstHitTestResult=!1,this._anchor=null,t.addEventListener("selectstart",this._selectStartFn),t.addEventListener("selectend",this._selectEndFn),this.gameObject.visible=!1,this.rig&&(this.rig.matrixAutoUpdate=!0,this._initalMatrix.decompose(this.rig.position,this.rig.quaternion,this.rig.scale)),this.dispatchEvent(new CustomEvent("onBeginSession"))}onUpdate(t,i,s,r){if(r&&!this._placementPose&&(this._gotFirstHitTestResult||(this._gotFirstHitTestResult=!0,this.dispatchEvent(new CustomEvent("canPlaceSession",{detail:{pose:r}}))),this._isTouching)){const o=new Me().fromArray(r.transform.matrix).invert();return this.dispatchEvent(new CustomEvent("placedSession",{detail:{pose:r,poseMatrix:o}})),this.webAR&&this.webAR.setReticleActive(!1),this.placeAt(t,o),s&&r&&this.onCreatePlacementAnchor(s,r),!0}return!1}onCreatePlacementAnchor(t,i){var s,r;this._anchor=null,(r=(s=t==null?void 0:t.createAnchor)==null?void 0:s.call(t,i.transform))==null||r.then(o=>{this.context.isInAR&&(this._anchor=o)})}onBeforeRender(t){if(t&&this._rig)if(this._anchor){const i=this.context.renderer.xr.getReferenceSpace();if(i){const s=t.getPose(this._anchor.anchorSpace,i);if(s){const r=this._anchorMatrix.fromArray(s.transform.matrix).invert();this.placeAt(this._rig,r);return}}}else this._placementPose&&this.placeAt(this._rig,this._placementPose)}placeAt(t,i){this._placementPose||(this._placementPose=new Me),this._placementPose.copy(i);const s=this._invertedSessionRootMatrix.copy(this.gameObject.matrixWorld).invert();this._placementPose.premultiply(s),t?(this.invertForward&&this._placementPose.premultiply(this._invertForwardMatrix),this.userInput||(this.userInput=new $d(this.context)),this.userInput.enable(),this._rig=t,this.setScale(this.arScale)):this._rig=null,this.gameObject.visible=!0}onEnd(t,i){var s,r;(s=this.userInput)==null||s.disable(),(r=this.userInput)==null||r.reset(),this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._anchor=null,this._startPose&&this.gameObject.matrix.copy(this._startPose),t&&(t.matrixAutoUpdate=!0,this._rigStartPose&&this._rigStartPose.decompose(t.position,t.quaternion,t.scale)),Sr.markDirty(this.gameObject,!0),setTimeout(()=>{this.gameObject&&(this.gameObject.matrixAutoUpdate=!0,this.gameObject.visible=!0)},100)}onSelectStart(){this._isTouching=!0}onSelectEnd(){this._isTouching=!1}setScale(t){const i=this._rig;!i||!this._placementPose||(this._rigStartPose||(this._rigStartPose=i.matrix.clone()),i.matrixAutoUpdate=!1,this.arTouchTransform&&this.userInput&&this.userInput.applyMatrixTo(this._placementPose),i.matrix.multiplyMatrices(dne.makeScale(t,t,t),this._placementPose),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld())}}CI([x()],ca.prototype,"invertForward",2);CI([x()],ca.prototype,"arTouchTransform",2);CI([x()],ca.prototype,"arScale",1);const Hb=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_enabled",!1);h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.has(i.identifier)||this.prev.set(i.identifier,{x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(i.identifier);if(s){const r=this.getPositionOnPlane(i.clientX,i.clientY);s.x=r.x,s.z=r.z,s.screenx=i.clientX,s.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1)});h(this,"touchMove",e=>{if(!e.defaultPrevented){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i)return;const s=this.getPositionOnPlane(t.clientX,t.clientY),r=s.x-i.x,o=s.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=s.x,i.z=s.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],s=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!s||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(s.screeny-r.screeny,s.screenx-r.screenx),c=o-a;Math.abs(c)>.001&&this.addRotation(c)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,c=Math.sqrt(o*o+a*a),l=s.screenx-r.screenx,u=s.screeny-r.screeny,d=Math.sqrt(l*l+u*u),f=c-d;Math.abs(f)>2&&this.addScale(f)}s.screenx=t.clientX,s.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new Uu);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new Me);this.context=e,this.offset=new Me,this.plane=new Qr,this.plane.setFromNormalAndCoplanarPoint(Hb.up,Hb.zero)}enable(){this._enabled||(this._enabled=!0,window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}reset(){this._scale=1,this.offset.identity()}applyMatrixTo(e){e.premultiply(this.offset)}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e*=.75,t*=.75,e/=this._scale,t/=this._scale,this.offset.elements[12]-=e,this.offset.elements[14]-=t}addScale(e){e/=window.innerWidth,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix)}addRotation(e){this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix)}};let $d=Hb;h($d,"up",new w(0,1,0)),h($d,"zero",new w(0,0,0)),h($d,"one",new w(1,1,1));const fne=re("debugrig");class Ix extends Ie{awake(){if(fne){const e=new Te;e.position.y+=.5,this.gameObject.add(e);const t=e.addNewComponent(Qu);t&&(t.isGizmo=!1)}}}class Mf{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}w(){return this.bb.readFloat32(this.bb_pos+12)}static sizeOf(){return 16}static createVec4(e,t,i,s,r){return e.prep(4,16),e.writeFloat32(r),e.writeFloat32(s),e.writeFloat32(i),e.writeFloat32(t),e.offset()}}class Ms{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsVrUserStateBuffer(e,t){return(t||new Ms).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsVrUserStateBuffer(e,t){return e.setPosition(e.position()+L_),(t||new Ms).__init(e.readInt32(e.position())+e.position(),e)}guid(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}time(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}avatarId(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}position(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}rotation(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}scale(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readFloat32(this.bb_pos+e):0}posLeftHand(e){const t=this.bb.__offset(this.bb_pos,16);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}posRightHand(e){const t=this.bb.__offset(this.bb_pos,18);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}rotLeftHand(e){const t=this.bb.__offset(this.bb_pos,20);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}rotRightHand(e){const t=this.bb.__offset(this.bb_pos,22);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}static startVrUserStateBuffer(e){e.startObject(10)}static addGuid(e,t){e.addFieldOffset(0,t,0)}static addTime(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static addAvatarId(e,t){e.addFieldOffset(2,t,0)}static addPosition(e,t){e.addFieldStruct(3,t,0)}static addRotation(e,t){e.addFieldStruct(4,t,0)}static addScale(e,t){e.addFieldFloat32(5,t,0)}static addPosLeftHand(e,t){e.addFieldStruct(6,t,0)}static addPosRightHand(e,t){e.addFieldStruct(7,t,0)}static addRotLeftHand(e,t){e.addFieldStruct(8,t,0)}static addRotRightHand(e,t){e.addFieldStruct(9,t,0)}static endVrUserStateBuffer(e){return e.endObject()}static finishVrUserStateBufferBuffer(e,t){e.finish(t)}static finishSizePrefixedVrUserStateBufferBuffer(e,t){e.finish(t,void 0,!0)}}const wO=re("debugxr"),hg=re("debugavatar"),EI="VRUS";F_(EI,Ms.getRootAsVrUserStateBuffer);function pM(){return new Date().getTime()}function pne(n){const e=n&4294967295,t=n/Math.pow(2,32)&1048575;return Ga.create(e,t)}const Am=class{constructor(e){h(this,"guid");h(this,"time");h(this,"avatarId");h(this,"position",new w);h(this,"rotation",new et);h(this,"scale",1);h(this,"posLeftHand",new w);h(this,"posRightHand",new w);h(this,"rotLeftHand",new we);h(this,"rotRightHand",new we);this.guid=e}update(e,t,i,s,r){var u,d,f,p,g,A;this.time=pM(),this.avatarId=r,this.position.set(t.x,t.y,t.z),e&&this.position.applyMatrix4(e.matrixWorld);let o=Am.quat0;const a=Am.quat1;o.set(i.x,i.y,i.z,i.w),o=o.multiplyQuaternions(o,Am.invertRotation),e&&(e.getWorldQuaternion(a),o.multiplyQuaternions(a,o)),this.rotation.set(o.x,o.y,o.z,o.w),this.scale=e.scale.x;const c=(u=s.LeftController)==null?void 0:u.controllerGrip;c&&(c.getWorldPosition(this.posLeftHand),c.getWorldQuaternion(this.rotLeftHand));const l=(d=s.RightController)==null?void 0:d.controllerGrip;if(l&&(l.getWorldPosition(this.posRightHand),l.getWorldQuaternion(this.rotRightHand)),(p=(f=s.LeftController)==null?void 0:f.hand)!=null&&p.visible){const v=s.LeftController.wrist;v&&(v.getWorldPosition(this.posLeftHand),v.getWorldQuaternion(this.rotLeftHand))}if((A=(g=s.RightController)==null?void 0:g.hand)!=null&&A.visible){const v=s.RightController.wrist;v&&(v.getWorldPosition(this.posRightHand),v.getWorldQuaternion(this.rotRightHand))}}sendAsBuffer(e,t){e.clear();const i=e.createString(this.guid),s=e.createString(this.avatarId);Ms.startVrUserStateBuffer(e),Ms.addGuid(e,i),Ms.addTime(e,pne(this.time)),Ms.addAvatarId(e,s),Ms.addPosition(e,Zr.createVec3(e,this.position.x,this.position.y,this.position.z)),Ms.addRotation(e,Mf.createVec4(e,this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)),Ms.addScale(e,this.scale),Ms.addPosLeftHand(e,Zr.createVec3(e,this.posLeftHand.x,this.posLeftHand.y,this.posLeftHand.z)),Ms.addPosRightHand(e,Zr.createVec3(e,this.posRightHand.x,this.posRightHand.y,this.posRightHand.z)),Ms.addRotLeftHand(e,Mf.createVec4(e,this.rotLeftHand.x,this.rotLeftHand.y,this.rotLeftHand.z,this.rotLeftHand.w)),Ms.addRotRightHand(e,Mf.createVec4(e,this.rotRightHand.x,this.rotRightHand.y,this.rotRightHand.z,this.rotRightHand.w));const r=Ms.endVrUserStateBuffer(e);e.finish(r,EI);const o=e.asUint8Array();t.sendBinary(o)}setFromBuffer(e,t){if(!e)return;this.guid=e,this.time=t.time().toFloat64();const i=t.avatarId();i&&(this.avatarId=i);const s=t.position();s&&this.position.set(s.x(),s.y(),s.z());const r=t.rotation();r&&this.rotation.set(r.x(),r.y(),r.z(),r.w());const o=t.posLeftHand();o&&this.posLeftHand.set(o.x(),o.y(),o.z());const a=t.posRightHand();a&&this.posRightHand.set(a.x(),a.y(),a.z());const c=t.rotLeftHand();c&&this.rotLeftHand.set(c.x(),c.y(),c.z(),c.w());const l=t.rotRightHand();l&&this.rotRightHand.set(l.x(),l.y(),l.z(),l.w()),this.scale=t.scale()}};let ta=Am;h(ta,"invertRotation",new we().setFromAxisAngle(new w(0,1,0),Math.PI)),h(ta,"quat0",new we),h(ta,"quat1",new we);class tA extends Ie{constructor(){super(...arguments);h(this,"webXR",null);h(this,"debugAvatarUser",null);h(this,"voip",null);h(this,"tempState",new ta(""));h(this,"_removeAvatarsList",[]);h(this,"eventSub_ConnectionEvent",null);h(this,"eventSub_WebXRStartEvent",null);h(this,"eventSub_WebXREndEvent",null);h(this,"eventSub_WebXRUpdateEvent",null);h(this,"avatars",{});h(this,"localAvatar",null);h(this,"k_LocalAvatarNoNetworkingGuid","local");h(this,"ownership",null);h(this,"xrState",null);h(this,"builder",new ip(1024))}async awake(){if(this.webXR||(this.webXR=ne.getComponent(this.gameObject,It)),this.webXR||(this.webXR=ne.findObjectOfType(It,this.context)),!this.webXR&&(this.webXR=ne.findObjectOfType(It,this.context),!this.webXR)){console.warn("WebXRSync: Could not find WebXR component, won't sync.");return}if(this.voip||(this.voip=ne.findObjectOfType(dl,this.context)),hg){const t="debug-avatar-"+hg,i=new Ua(this.context,t,this.webXR);if(this.debugAvatarUser=i,typeof hg=="string"&&hg.length>0)if(await i.setAvatarOverride(hg)){const s=new ta(t);s.position.y+=1;const r=.5;s.posLeftHand.y+=r,s.posLeftHand.x+=r,s.posRightHand.y+=r,s.posRightHand.x-=r,i.tryUpdate(s,0)}else i.destroy()}}onEnable(){if(!this.webXR&&(this.webXR=ne.getComponent(this.gameObject,It),!this.webXR)){console.warn("Missing webxr component on "+this.gameObject.name);return}this.eventSub_WebXRStartEvent=this.onXRSessionStart.bind(this),It.addEventListener(Mi.XRStarted,this.eventSub_WebXRStartEvent),this.eventSub_WebXRUpdateEvent=this.onXRSessionUpdate.bind(this),It.addEventListener(Mi.XRUpdate,this.eventSub_WebXRUpdateEvent),this.eventSub_WebXREndEvent=this.onXRSessionEnded.bind(this),It.addEventListener(Mi.XRStopped,this.eventSub_WebXREndEvent),this.eventSub_ConnectionEvent=this.onConnected.bind(this),this.context.connection.beginListen(on.JoinedRoom,this.eventSub_ConnectionEvent),this.context.connection.beginListen("webxr-user-joined",t=>{console.log("webxr user joined evt")}),this.context.connection.beginListen("webxr-user-left",t=>{const i=t.id!==null&&t.id!==void 0;if(i&&(console.log("webxr user left evt"),i)){const s=this.avatars[t.id];s==null||s.destroy(),this.avatars[t.id]=void 0}}),this.context.connection.beginListenBinary(EI,t=>{const i=t.guid();if(!i)return;const s=t.time().toFloat64(),r=this.tempState;r.setFromBuffer(i,t);const o=this.onTryGetAvatar(i,s);o==null||o.tryUpdate(r,s)}),this.context.connection.beginListen("vr-session-update",t=>{const i=t.guid,s=t.time,r=this.onTryGetAvatar(i,s);r==null||r.tryUpdate(t,s)})}onTryGetAvatar(t,i){if(t===this.context.connection.connectionId)return null;const s=new Date().getTime()-i;if(s>5e3)return wO&&console.log("old data",s,t),null;if(!this.webXR)return null;let r=this.avatars[t];if(r===void 0)try{console.log("create new avatar");const o=new Ua(this.context,t,this.webXR);r=o,this.avatars[t]=o}catch(o){this.avatars[t]=null,console.error(o)}return r}onDisable(){this.eventSub_ConnectionEvent&&this.context.connection.stopListen(on.JoinedRoom,this.eventSub_ConnectionEvent),It.removeEventListener(Mi.XRStarted,this.eventSub_WebXRStartEvent),It.removeEventListener(Mi.XRUpdate,this.eventSub_WebXRUpdateEvent),It.removeEventListener(Mi.XRStopped,this.eventSub_WebXREndEvent)}update(){const t=pM();this.debugAvatarUser&&(this.debugAvatarUser.lastUpdate=t),this.detectPotentiallyDisconnectedAvatarsAndRemove();for(const i in this.avatars){const s=this.avatars[i];s&&s.update()}}detectPotentiallyDisconnectedAvatarsAndRemove(){const t=pM();for(const i in this.avatars){const s=this.avatars[i];if(!s){this._removeAvatarsList.push(i);continue}t-s.lastUpdate>1e4&&(console.log("avatar timed out (didnt receive any updates in a while) - destroying it now"),s.destroy(),this.avatars[i]=void 0)}for(const i of this._removeAvatarsList)delete this.avatars[i];this._removeAvatarsList.length=0}buildLocalAvatar(){var i;if(this.localAvatar)return;const t=((i=this.context.connection)==null?void 0:i.connectionId)??this.k_LocalAvatarNoNetworkingGuid;this.localAvatar=new Ua(this.context,t,this.webXR),this.localAvatar.isLocalAvatar=!0,this.localAvatar.setAvatarOverride(this.getAvatarId()),this.avatars[this.localAvatar.guid]=this.localAvatar}onConnected(){var t,i,s;wO&&console.log("Hey you are connected as "+this.context.connection.connectionId),((t=this.localAvatar)==null?void 0:t.guid)===this.k_LocalAvatarNoNetworkingGuid&&(this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0),this.localAvatar=null,this.xrState=null,(s=this.ownership)==null||s.freeOwnership(),this.ownership=null)}onXRSessionStart(t){var i,s,r;if(console.log("XR session started"),this.context.connection.send("webxr-user-joined",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null),this.xrState=null,(s=this.ownership)==null||s.freeOwnership(),this.ownership=null,this.avatars)for(const o in this.avatars)(r=this.avatars[o])==null||r.updateFlags()}onXRSessionEnded(t){var i;console.log("XR session ended"),this.context.connection.send("webxr-user-left",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null)}onXRSessionUpdate(t){this.xrState??(this.xrState=new ta(this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid)),this.ownership??(this.ownership=new N_(this.context.connection,this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid)),this.ownership.guid=this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid,this.buildLocalAvatar();const{frame:i,xr:s,rig:r}=t,o=i.getViewerPose(s.getReferenceSpace());if(!o)return;const a=o==null?void 0:o.transform,c=a.position,l=a.orientation;this.xrState.update(r,c,l,this.webXR,this.getAvatarId()),this.localAvatar&&(this.context.connection.connectionId&&(this.localAvatar.guid=this.context.connection.connectionId),this.localAvatar.tryUpdate(this.xrState,0)),!(this.ownership&&!this.ownership.hasOwnership&&this.context.connection.isConnected&&(this.context.time.frameCount%120===0&&this.ownership.requestOwnership(),!this.ownership.hasOwnership))&&(!this.context.connection.isConnected||!this.context.connection.connectionId||this.xrState.sendAsBuffer(this.builder,this.context.connection))}getAvatarId(){return re("avatar")??null}}var gne=Object.defineProperty,mne=Object.getOwnPropertyDescriptor,Tp=(n,e,t,i)=>{for(var s=i>1?void 0:i?mne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gne(e,t,s),s};const jS=re("debugwebxr");async function jz(){return tb()?!0:"xr"in navigator?await navigator.xr.isSessionSupported("immersive-ar")===!0:!1}async function Xz(){return"xr"in navigator?await navigator.xr.isSessionSupported("immersive-vr")===!0:!1}let Og=!1,kg=!1;jz().then(n=>Og=n);Xz().then(n=>kg=n);var Mi=(n=>(n.XRStarted="xrStarted",n.XRStopped="xrStopped",n.XRUpdate="xrUpdate",n.RequestVRSession="requestVRSession",n.ModifyAROptions="modify-ar-options",n))(Mi||{}),Wd;const kn=(Wd=class extends Ie{constructor(){super(...arguments);h(this,"enableVR",!0);h(this,"enableAR",!0);h(this,"defaultAvatar");h(this,"handModelPath","");h(this,"createVRButton",!0);h(this,"createARButton",!0);h(this,"controllers",[]);h(this,"rig");h(this,"isInit",!1);h(this,"_requestedAR",!1);h(this,"_requestedVR",!1);h(this,"_isInAR",!1);h(this,"_isInVR",!1);h(this,"_arButton");h(this,"_vrButton");h(this,"webAR",null);h(this,"_transformOrientation",new we);h(this,"_currentHeadPose",null);h(this,"_originalCameraParent",null);h(this,"_originalCameraPosition",new w);h(this,"_originalCameraRotation",new we);h(this,"_originalXRRigParent",null);h(this,"_originalXRRigPosition",new w);h(this,"_originalXRRigRotation",new we);h(this,"xrMirrorWindow",null)}static get IsInWebXR(){return this._isInXr}static get XRSupported(){return"xr"in navigator&&(Og||kg)}static get IsARSupported(){return Og}static get IsVRSupported(){return kg}static get OptionalFeatures_VR(){return this._optionalFeatures_VR}static get OptionalFeatures_AR(){return this._optionalFeatures_AR}static addEventListener(e,t){return this.events.addEventListener(e,t),t}static removeEventListener(e,t){return this.events.removeEventListener(e,t),t}static dispatchEvent(e,t){this.events.dispatchEvent({type:e,detail:t})}static createVRButton(e,t){kn.XRSupported?e.__internalAwake():console.warn("WebXR is not supported on this device");const i={optionalFeatures:kn.OptionalFeatures_VR},s=rm.createButton(e.context.renderer,i);return s.classList.add("webxr-ar-button"),s.classList.add("webxr-button"),this.resetButtonStyles(s),((t==null?void 0:t.registerClick)??!0)&&s.addEventListener("click",e.onClickedVRButton.bind(e)),s}static createARButton(e,t){var o;e.__internalAwake();const i=(o=e.webAR)==null?void 0:o.getAROverlayContainer(),s={optionalFeatures:[...this.OptionalFeatures_AR]};i?(s.domOverlay={root:i},s.optionalFeatures.push("dom-overlay"),s.optionalFeatures.push("hit-test"),s.optionalFeatures.push("anchors")):console.warn("No dom overlay root found, HTML overlays on top of screen-based AR will not work.");const r=lne.createButton(e.context.renderer,s,this.onModifyAROptions.bind(this));return r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),kn.resetButtonStyles(r),((t==null?void 0:t.registerClick)??!0)&&r.addEventListener("click",e.onClickedARButton.bind(e)),r}static onModifyAROptions(e){kn.dispatchEvent("modify-ar-options",e)}static resetButtonStyles(e){e&&(e.style.position="",e.style.bottom="",e.style.left="")}endSession(){const e=this.context.renderer.xr.getSession();e&&e.end()}get Rig(){return this.rig||this.ensureRig(),this.rig}get Controllers(){return this.controllers}get LeftController(){var e,t;return this.controllers.length>0&&((e=this.controllers[0].input)==null?void 0:e.handedness)==="left"?this.controllers[0]:this.controllers.length>1&&((t=this.controllers[1].input)==null?void 0:t.handedness)==="left"?this.controllers[1]:null}get RightController(){var e,t;return this.controllers.length>0&&((e=this.controllers[0].input)==null?void 0:e.handedness)==="right"?this.controllers[0]:this.controllers.length>1&&((t=this.controllers[1].input)==null?void 0:t.handedness)==="right"?this.controllers[1]:null}get ARButton(){return this._arButton}get VRButton(){return this._vrButton}get IsInVR(){return this._isInVR}get IsInAR(){return this._isInAR}awake(){if(this.defaultAvatar&&typeof this.defaultAvatar=="string"&&(this.defaultAvatar=Tn.getOrCreate(this.sourceId??"/",this.defaultAvatar,this.context)),!ne.findObjectOfType(tA,this.context)){const e=ne.addNewComponent(this.gameObject,tA,!1);e.webXR=this}this.webAR=new Su(this)}start(){location.protocol=="http:"&&location.host.indexOf("localhost")<0&&(Ls("WebXR only works on https"),console.warn("WebXR only works on https. https://engine.needle.tools/docs/xr.html"))}onEnable(){if(this.isInit||!this.enableAR&&!this.enableVR)return;this.isInit=!0,this.context.renderer.xr.enabled=!0,kn.XRSupported;let e,t;const i=document.createElement("div");i.classList.add("webxr-buttons"),i.style.cssText=`
|
|
5181
|
+
`,a={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},c=new vA(1,16),l=new Lt({uniforms:a,fragmentShader:o,vertexShader:r,side:wi});super(c,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var Nte=Object.defineProperty,zte=Object.getOwnPropertyDescriptor,cr=(n,e,t,i)=>{for(var s=i>1?void 0:i?zte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nte(e,t,s),s};const By=re("freecam"),cg=re("debugcamerafit"),Dy=re("smoothcam"),Gte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let HS;class Ji extends Ie{constructor(){super(...arguments);h(this,"enableRotate",!0);h(this,"autoRotate",!1);h(this,"autoRotateSpeed",1);h(this,"autoFit",!1);h(this,"enableKeys",!0);h(this,"enableDamping",!0);h(this,"dampingFactor",.1);h(this,"enableZoom",!0);h(this,"minZoom",0);h(this,"maxZoom",1/0);h(this,"enablePan",!0);h(this,"lookAtConstraint",null);h(this,"lookAtConstraint01",1);h(this,"middleClickToFocus",!0);h(this,"doubleClickToFocus",!0);h(this,"useSlerp",!0);h(this,"debugLog",!1);h(this,"targetLerpSpeed",5);h(this,"autoTarget",!0);h(this,"_lookTargetPosition");h(this,"_controls",null);h(this,"_cameraObject",null);h(this,"_lerpToTargetPosition",!1);h(this,"_lerpCameraToTarget",!1);h(this,"_cameraTargetPosition",null);h(this,"_inputs",0);h(this,"_enableTime",0);h(this,"_startedListeningToKeyEvents",!1);h(this,"_eventSystem");h(this,"_afterHandleInputFn");h(this,"_camera",null);h(this,"_syncedTransform");h(this,"_didStart",!1);h(this,"targetElement",null);h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});h(this,"_shouldDisable",!1);h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(t){var i;(i=this.controls)==null||i.addEventListener("start",t)}awake(){this._didStart=!1,this._lookTargetPosition=new w,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const t=ne.getComponent(this.gameObject,Li);if(t&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const s=Ct(t.cam).length(),r=new w(0,0,-s).applyMatrix4(t.cam.matrixWorld);this.setTarget(r,!0)}if(this.autoTarget&&!this.setFromTargetPosition()){const i=new ko;i.screenPoint=new te(0,0),i.lineThreshold=.1;const s=this.context.physics.raycast(i);s.length>0&&this.setTarget(s[0].point,!0),cg&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=$s.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(uM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var t,i;(t=this._controls)==null||t.dispose(),(i=this._eventSystem)==null||i.removeEventListener(uM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const t=ne.getComponent(this.gameObject,Li);this._camera=t;const i=t==null?void 0:t.cam;if(i&&AO(i,this,!0),!this._controls){if(!i){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}i&&(this._cameraObject=i);const s=this.targetElement??this.context.domElement,r=i==null?void 0:i.quaternion.clone();this._controls=new JK(i,s),i==null||i.quaternion.copy(r),HS===void 0&&(HS={...this._controls.keys})}this._controls&&(By&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,cl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(i==null?void 0:i.type)==="PerspectiveCamera"?By||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):By||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=ne.getComponent(this.gameObject,ah)??void 0}onDisable(){var t;(t=this._camera)!=null&&t.cam&&AO(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(t){t.detail.args.pointerId===0&&(t.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!t.detail.args.isPressed||t.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var i,s,r;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.enableRotate&&(this.autoRotate=!1),this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let t=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(t||(t=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),t?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const o=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const a=(i=this._cameraObject)==null?void 0:i.position;$2(a,this._cameraTargetPosition,o)}else(s=this._cameraObject)==null||s.position.lerp(this._cameraTargetPosition,o);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,o),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}if(!By&&((r=this.lookAtConstraint)!=null&&r.locked)&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?HS:Gte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof Dy=="number"||Dy===!0){this._controls.enableDamping=!0;const o=typeof Dy=="number"?Dy:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,o))}this.context.isInXR||this._controls.update()}}setCameraTarget(t,i=!1){return this.setCameraTargetPosition(t,i)}setCameraTargetPosition(t,i=!1){var s;t?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=t.clone(),i&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(t=0,i=1){var r;if(!this._controls)return!1;const s=(r=this.lookAtConstraint)==null?void 0:r.sources;if(s&&s.length>0){const o=s[t];if(o)return o.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,i),!0}return!1}setTarget(t=null,i=!1){this._controls&&(t!==null&&this._lookTargetPosition.copy(t),i?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(t,i){this._controls&&this._controls.target.lerp(t,i)}distanceToTarget(t){return this._controls?this._controls.target.distanceTo(t):-1}setTargetFromRaycast(){var i,s;if(!this.controls)return;const t=this.context.physics.raycast();for(const r of t)if(r.distance>0&&ne.isActiveInHierarchy(r.object)){const o=yx(r.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const a=Ct(this.context.mainCamera);this._cameraTargetPosition=a.clone().sub(this.controls.target).add(this._lookTargetPosition),(s=(i=this._cameraObject)==null?void 0:i.parent)==null||s.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(t,i=1.1,s=!0){const r=this._cameraObject,o=this._controls;if(t!=null&&t.length||(t=this.context.scene.children),t.length<=0||!r||!o)return;const a=new w,c=new w,l=new Un;l.makeEmpty();const u=[];function d(y){let _=!0;if(y.visible&&(y instanceof uE&&(_=!1),y instanceof F1&&(_=!1),y instanceof Lz&&(_=!1),y.material instanceof __&&(_=!1),y instanceof ye||(_=!1),y!==r&&y.isUI!==!0)){if(_){cg&&console.log(y.name,y.type,y);const C=y.children;y.children=u,l.expandByObject(y,!0),y.children=C}for(const C of y.children)d(C)}}for(const y of t)y.updateMatrixWorld(),d(y);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(c),l.applyMatrix4(r.matrixWorldInverse),l.getSize(a),l.setFromCenterAndSize(c,a),a.length()<=1e-10){cg&&console.warn("Camera fit size is zero",l,[...t]);return}const f=r.fov,p=2*Math.atan(Math.tan(f*Math.PI/360/2)*r.aspect)/Math.PI*360,g=a.y/(2*Math.atan(Math.PI*f/360)),A=a.x/(2*Math.atan(Math.PI*p/360)),v=i*Math.max(g,A)+a.z/2;cg&&console.log("Fit camera to objects",g,A,"distance",v);const m=Ct(r),b=o.target.clone().sub(m).normalize().multiplyScalar(v);if(o.maxDistance=v*10,o.minDistance=v*.01,this.setTarget(c,s),this.autoTarget=!1,r.near=v/100,r.far=v*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const y=r.parent.worldToLocal(o.target.clone().sub(b));this.setCameraTarget(y,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(cg){const y=new uE(l);this.context.scene.add(y),nF(y,O_(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",_=>{_.code==="KeyF"&&this.fitCamera(t)}))}o.update()}}cr([x()],Ji.prototype,"enableRotate",2);cr([x()],Ji.prototype,"autoRotate",2);cr([x()],Ji.prototype,"autoRotateSpeed",2);cr([x()],Ji.prototype,"autoFit",2);cr([x()],Ji.prototype,"enableKeys",2);cr([x()],Ji.prototype,"enableDamping",2);cr([x()],Ji.prototype,"dampingFactor",2);cr([x()],Ji.prototype,"enableZoom",2);cr([x()],Ji.prototype,"minZoom",2);cr([x()],Ji.prototype,"maxZoom",2);cr([x()],Ji.prototype,"enablePan",2);cr([x(LA)],Ji.prototype,"lookAtConstraint",2);cr([x()],Ji.prototype,"lookAtConstraint01",2);cr([x()],Ji.prototype,"middleClickToFocus",2);cr([x()],Ji.prototype,"doubleClickToFocus",2);var Hte=Object.defineProperty,Vte=Object.getOwnPropertyDescriptor,to=(n,e,t,i)=>{for(var s=i>1?void 0:i?Vte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Hte(e,t,s),s},Ib=(n=>(n[n.Skybox=1]="Skybox",n[n.SolidColor=2]="SolidColor",n[n.Uninitialized=4]="Uninitialized",n))(Ib||{});const ru=re("debugcam"),yO=re("debugscreenpointtoray");var t0;const Bg=(t0=class extends Ie{constructor(){super(...arguments);h(this,"_nearClipPlane",.1);h(this,"_farClipPlane",1e3);h(this,"orthographic",!1);h(this,"orthographicSize",5);h(this,"ARBackgroundAlpha",0);h(this,"_cullingMask",4294967295);h(this,"_backgroundBlurriness");h(this,"_backgroundIntensity");h(this,"_environmentIntensity");h(this,"_targetTexture",null);h(this,"_backgroundColor");h(this,"_fov");h(this,"_cam",null);h(this,"_clearFlags",2);h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(e){const t=this.fieldOfView!=e;if(this._fov=e,t&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(e){const t=this._nearClipPlane!=e;this._nearClipPlane=e,this._cam&&t&&(this._cam.near=e,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(e){const t=this._farClipPlane!=e;this._farClipPlane=e,this._cam&&t&&(this._cam.far=e,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(e){e!==this._clearFlags&&(this._clearFlags=e,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(e){this._cullingMask=e,this._cam&&(this._cam.layers.mask=e)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(e){e!==this._backgroundBlurriness&&(e===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(e,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(e){e!==this._backgroundIntensity&&(e===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(e,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(e){this._environmentIntensity=e}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(e){if(e){if(this._backgroundColor)this._backgroundColor.copy(e);else{if(!e.clone)return;this._backgroundColor=e.clone()}e.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(e){this._targetTexture=e}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(e,t,i){const s=this.cam,r=Bg._origin;r.set(e,t,-1),this.context.input.convertScreenspaceToRaycastSpace(r),yO&&console.log("screenPointToRay",e.toFixed(2),t.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const o=Bg._direction.set(r.x,r.y,r.z),a=Ct(s);return o.sub(a),o.normalize(),i?(i.set(a,o),i):new Ya(a.clone(),o.clone())}awake(){yO&&window.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY;console.log("touch",t.toFixed(2),i.toFixed(2));const s=this.screenPointToRay(t,i),r="#"+Math.floor(Math.random()*16777215).toString(16);zc.DrawRay(s.origin,s.direction,r,10)})}onEnable(){ru&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Ib[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Wte(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const e=this.context.renderer;if(e){const t=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,e),t==null||t.applyClearFlags()}}}buildCamera(){if(this._cam)return;const e=this.gameObject.isCamera;let t=null;if(e?(t=this.gameObject,t==null||t.layers.enableAll(),t instanceof qt&&(this._fov=t.fov)):t=this.gameObject.children[0],t&&t.isCamera)t instanceof qt&&(this._fov&&(t.fov=this._fov),t.near=this._nearClipPlane,t.far=this._farClipPlane,t.updateProjectionMatrix());else if(!this.orthographic)t=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(t.fov=this.fieldOfView),this.gameObject.add(t);else{const i=this.orthographicSize*100;t=new Du(window.innerWidth/-i,window.innerWidth/i,window.innerHeight/i,window.innerHeight/-i,this._nearClipPlane,this._farClipPlane),this.gameObject.add(t)}this._cam=t,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){ru&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,ru){const e=`Camera "${this.name}" clear flags: ${Ib[this._clearFlags]}`;console.log(e)}switch(this._clearFlags){case 1:if(Bg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let e=this._backgroundColor.alpha;Bg.backgroundShouldBeTransparent(this.context)&&(e=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,e)}else ru&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new Qte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(e){var r,o,a,c;const t=(r=e.renderer.xr)==null?void 0:r.getSession();if(!t)return!1;const i=t.environmentBlendMode;ru&&pn("Environment blend mode: "+i+" on "+navigator.userAgent);const s=i==="additive"||i==="alpha-blend";if(e.xrSessionMode===zm.ImmersiveAR&&i==="opaque"){if((o=navigator.userAgent)!=null&&o.includes("OculusBrowser"))return!0;if((a=navigator.userAgent)!=null&&a.includes("Mozilla")&&((c=navigator.userAgent)!=null&&c.includes("Mobile WebXRViewer/v2")))return!0}return s}},h(t0,"_origin",new w),h(t0,"_direction",new w),t0);let Li=Bg;to([x()],Li.prototype,"fieldOfView",1);to([x()],Li.prototype,"nearClipPlane",1);to([x()],Li.prototype,"farClipPlane",1);to([x()],Li.prototype,"clearFlags",1);to([x()],Li.prototype,"orthographic",2);to([x()],Li.prototype,"orthographicSize",2);to([x()],Li.prototype,"ARBackgroundAlpha",2);to([x()],Li.prototype,"cullingMask",1);to([x()],Li.prototype,"backgroundBlurriness",1);to([x()],Li.prototype,"backgroundIntensity",1);to([x()],Li.prototype,"environmentIntensity",1);to([x(bi)],Li.prototype,"backgroundColor",1);to([x(Jl)],Li.prototype,"targetTexture",1);class Qte{constructor(e){h(this,"_camera");h(this,"_skybox");this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(ru&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ze,this._skybox.mapping=Ro,this.context.scene.background=this._skybox):(console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background),(ru||ci())&&Ls(`Camera "${this._camera.name}" has no skybox texture`))}}function Wte(n){re("freecam")&&n.context.mainCameraComponent===n&&ne.getOrAddComponent(n.gameObject,Ji)}class xu extends Ie{constructor(){super(...arguments);h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new O1),this._listener}awake(){yn.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const t=this.listener;if(t==null||t.parent)return;const i=this.context.mainCameraComponent||ne.getComponentInParent(this.gameObject,Li);i!=null&&i.cam?i.cam.add(t):this.gameObject.add(t)})}}var jte=Object.defineProperty,Xte=Object.getOwnPropertyDescriptor,bx=(n,e,t,i)=>{for(var s=i>1?void 0:i?Xte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&jte(e,t,s),s};const qte=re("debugsignals");class VA{constructor(){h(this,"guid")}}bx([x()],VA.prototype,"guid",2);class Ap{constructor(){h(this,"signal");h(this,"reaction")}}bx([x(VA)],Ap.prototype,"signal",2);bx([x(us)],Ap.prototype,"reaction",2);var xC;const bc=(xC=class extends Ie{constructor(){super(...arguments);h(this,"events")}static invoke(e){if(bc.receivers[e]){const t=bc.receivers[e];if(!t)return;for(const i of t)i.invoke(e)}}awake(){qte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const e of this.events)bc.receivers[e.signal.guid]||(bc.receivers[e.signal.guid]=[]),bc.receivers[e.signal.guid].push(this)}onDisable(){if(this.events){for(const e of this.events)if(bc.receivers[e.signal.guid]){const t=bc.receivers[e.signal.guid].indexOf(this);t>=0&&bc.receivers[e.signal.guid].splice(t,1)}}}invoke(e){if(!this.events||!Array.isArray(this.events))return;const t=typeof e=="object"?e.guid:e;for(const i of this.events)if(i.signal.guid===t)try{if(i.reaction){if(!i.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",i,this);continue}}else{console.warn("Missing reaction for signal",i,this);continue}i.reaction.invoke()}catch(s){console.error(s)}}},h(xC,"receivers",{}),xC);let vp=bc;bx([x(Ap)],vp.prototype,"events",2);var Lr=(n=>(n.Activation="ActivationTrack",n.Animation="AnimationTrack",n.Audio="AudioTrack",n.Control="ControlTrack",n.Marker="MarkerTrack",n.Signal="SignalTrack",n))(Lr||{}),Sa=(n=>(n[n.None=0]="None",n[n.Hold=1]="Hold",n[n.Loop=2]="Loop",n[n.PingPong=3]="PingPong",n[n.Continue=4]="Continue",n))(Sa||{}),lI=(n=>(n.Signal="SignalEmitter",n))(lI||{});const Fd=re("debugtimeline"),zb=class extends Ie{constructor(){super(...arguments);h(this,"playableAsset");h(this,"playOnAwake");h(this,"extrapolationMode",1);h(this,"waitForAudio",!0);h(this,"_visibilityChangeEvt");h(this,"_clonedPlayableAsset",!1);h(this,"_speed",1);h(this,"_guidsMap");h(this,"_isPlaying",!1);h(this,"_internalUpdateRoutine");h(this,"_isPaused",!1);h(this,"_isStopping",!1);h(this,"_time",0);h(this,"_duration",0);h(this,"_weight",1);h(this,"_animationTracks",[]);h(this,"_audioTracks",[]);h(this,"_signalTracks",[]);h(this,"_controlTracks",[]);h(this,"_customTracks",[]);h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);h(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,i){this.createTrackFunctions[t]=i}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(Fd||nr())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,i,s;Fd&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(i=this.playableAsset)==null?void 0:i.tracks,Array.isArray((s=this.playableAsset)==null?void 0:s.tracks),this)}onEnable(){var t,i,s;for(const r of this._audioTracks)(t=r.onEnable)==null||t.call(r);for(const r of this._customTracks)(i=r.onEnable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onEnable)==null||s.call(r);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,i,s;this.stop();for(const r of this._audioTracks)(t=r.onDisable)==null||t.call(r);for(const r of this._customTracks)(i=r.onDisable)==null||i.call(r);for(const r of this._animationTracks)(s=r.onDisable)==null||s.call(r);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const i of this._allTracks)for(const s of i)(t=s.onDestroy)==null||t.call(s)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,t&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const i=[];for(const s of this._audioTracks){const r=s.loadAudio(this._time,1,0);r&&i.push(r)}if(i.length>0&&(await Promise.all(i),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!yn.userInteractionRegistered&&this.waitForAudio;)await _A(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Tr.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const s of this._audioTracks)s.stop();const t=this._isPaused==!0,i=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!i&&this.invokePauseChangedMethodsOnTracks(),i&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}this.internalEvaluate(t)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const t of this._allTracks)for(const i of t)yield i}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onPauseChanged)==null||t.call(i)}invokeStateChangedMethodsOnTracks(){var t;for(const i of this.forEachTrack())(t=i.onStateChanged)==null||t.call(i,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(t){for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Lr.Activation:if(!this._isPlaying)continue;for(let s=0;s<i.outputs.length;s++){const r=i.outputs[s];if(typeof r=="object"){let o=!1;if(i.clips)for(const c of i.clips)c.start<=t&&t<=c.end&&(o=!0);const a=r;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Fd&&console.warn(this.name,"set ActivationTrack-"+s,a.name,o,t))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(t);for(const i of this._audioTracks)i.evaluate(t);for(const i of this._signalTracks)i.evaluate(t);for(const i of this._controlTracks)i.evaluate(t);for(const i of this._customTracks)i.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=B_(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const i of this.playableAsset.tracks){for(let s=i.outputs.length-1;s>=0;s--){let r=i.outputs[s];if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const o=ne.findByGuid(r,t);o===null||typeof o!="object"?(i.outputs.splice(s,1),console.warn("Failed to resolve binding",r,i.name,i.type)):(Fd&&console.log("Resolved binding",r,"to",o),i.outputs[s]=o)}else if(r===null){if(i.outputs.splice(s,1),zb.createTrackFunctions[i.type])continue;i.type!==Lr.Audio&&i.type!==Lr.Control&&i.type!==Lr.Marker&&i.type!==Lr.Signal&&console.warn("Missing binding",r,i.name,i.type,this.name,this.playableAsset.name)}}if(i.type===Lr.Control&&i.clips)for(let s=0;s<i.clips.length;s++){const r=i.clips[s];let o=r.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const a=ne.findByGuid(o,t);a===null||typeof a!="object"?console.warn("Failed to resolve sourceObject binding",o,i.name,r):(Fd&&console.log("Resolved binding",o,"to",a),r.asset.sourceObject=a)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const i of t.clips)i.end>this._duration&&(this._duration=i.end);if(t.markers)for(const i of t.markers)i.time>this._duration&&(this._duration=i.time+.001)}}}setupAndCreateTrackHandlers(){var i,s;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=ne.findObjectOfType(xu,this.context);for(const r of this.playableAsset.tracks){const o=r.type,a=zb.createTrackFunctions[o];if(a!=null){const c=a(this,r);if(typeof c.evaluate=="function"){c.director=this,c.track=r,this._customTracks.push(c);continue}}if(r.type===Lr.Animation){if(!r.clips||r.clips.length<=0){Fd&&console.warn("Animation track has no clips",r);continue}for(let c=r.outputs.length-1;c>=0;c--){let l=r.outputs[c];if(l instanceof Te){const d=ne.getOrAddComponent(l,ks);d&&(l=d)}const u=(i=l==null?void 0:l.gameObject)==null?void 0:i.animations;if(u){const d=new _x;d.trackOffset=r.trackOffset,d.director=this,d.track=r;for(let f=0;f<r.clips.length;f++){const p=r.clips[f],g=p.asset;if(!g){console.error("MISSING anim model?","clip#"+f,p,r,this.playableAsset,this.name);continue}const A=g.clip;let v=A;if((typeof v=="string"||typeof v=="number")&&(v=u.find(b=>b.name===A)),!v){console.warn("Could not find animationClip for model",p,r.name,this.name,(s=this.playableAsset)==null?void 0:s.name);continue}l instanceof ks&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),d.mixer=l.runtimeAnimatorController.mixer),d.mixer||(d.mixer=new R_(l.gameObject)),d.clips.push(v),d.mixer.uncacheAction(v),d.createHooks(p.asset,v);const m=d.mixer.clipAction(v);d.actions.push(m),d.models.push(p)}this._animationTracks.push(d)}}}else if(r.type===Lr.Audio){if(!r.clips||r.clips.length<=0)continue;const c=new wu;if(c.director=this,c.track=r,this._audioTracks.push(c),!t)continue;c.listener=t.listener;for(let l=0;l<r.clips.length;l++){const u=r.clips[l];c.addModel(u)}}else if(r.type===Lr.Marker){const c=new Zm;if(c.director=this,c.track=r,r.markers)for(const l of r.markers)switch(l.type){case lI.Signal:c.models.push(l),c.didTrigger.push(!1);break}if(c!==null&&c.models.length>0){const l=ne.getComponent(this.gameObject,vp);l&&(c.receivers.push(l),this._signalTracks.push(c))}}else if(r.type===Lr.Signal){const c=new Zm;if(c.director=this,c.track=r,r.markers)for(const l of r.markers)c.models.push(l),c.didTrigger.push(!1);for(const l of r.outputs)c.receivers.push(l);this._signalTracks.push(c)}else if(r.type===Lr.Control){const c=new xx;if(c.director=this,c.track=r,r.clips)for(const l of r.clips)c.models.push(l);c.resolveSourceObjects(this.context),this._controlTracks.push(c)}}}setAudioTracksAllowPlaying(t){for(const i of this._audioTracks)i.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const i=this.animationCallbackReceivers.indexOf(t);i!==-1&&this.animationCallbackReceivers.splice(i,1)}};let Zc=zb;h(Zc,"createTrackFunctions",{});const Hc=re("debugtimeline");class QA{constructor(){h(this,"director");h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,i,s=!0){if(t<0||t>=i.length)return 0;const r=i[t];if(s||e>=r.start&&e<=r.end){let o=1;const a=!1;if(r.easeInDuration>0){const c=Math.min((e-r.start)/r.easeInDuration,1);o*=c}if(r.easeOutDuration>0&&!a){const c=Math.min((r.end-e)/r.easeOutDuration,1);o*=c}return o}return 0}}class Yte{constructor(e){h(this,"clip");h(this,"rootPositionOffset");h(this,"rootQuaternionOffset");h(this,"rootStartPosition");h(this,"rootEndPosition");h(this,"rootStartQuaternion");h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const i=e.getRoot(),s=i.name+".position",r=i.name+".quaternion";Hc&&console.log(t.name,t.tracks,s);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(s))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Hc&&console.log(this.rootPositionOffset);else if(o.name.endsWith(r)&&(this.rootStartQuaternion=new we().fromArray(o.values,0),this.rootEndQuaternion=new we().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Hc)){const a=new mn().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class _x extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"trackOffset");h(this,"target");h(this,"mixer");h(this,"clips",[]);h(this,"actions",[]);h(this,"_actionOffsets",[]);h(this,"_didBind",!1);h(this,"_animator",null);h(this,"_useclipOffsets",!0);h(this,"_totalOffsetPosition",new w);h(this,"_totalOffsetRotation",new we);h(this,"_totalOffsetPosition2",new w);h(this,"_totalOffsetRotation2",new we);h(this,"_summedPos",new w);h(this,"_tempPos",new w);h(this,"_summedRot",new we);h(this,"_tempRot",new we);h(this,"_clipRotQuat",new we)}onStateChanged(){this._animator&&KD(this._animator.gameObject,this,this.director.isPlaying)}createHooks(t,i){var u,d;if(((u=i.tracks)==null?void 0:u.length)<=0){console.warn("No tracks in AnimationClip",i);return}const s=i.tracks[0].name.split("."),r=s[s.length-2],o=r+".position",a=r+".quaternion";let c=!1,l=!1;for(const f of i.tracks)f.name.endsWith(o)?(c=!0,this.createPositionInterpolant(i,t,f)):f.name.endsWith(a)&&(l=!0,this.createRotationInterpolant(i,t,f));if(!c||!l){const f=(d=this.mixer)==null?void 0:d.getRoot(),p=i.tracks[0],g=p.name.lastIndexOf("."),A=p.name.substring(0,g),v=A.substring(A.lastIndexOf(".")+1),m=f.getObjectByName(v);if(m)if(c){if(!l){const b=i.tracks[0].name.substring(0,g)+".quaternion";Hc&&console.warn("Create quaternion track",v,m);const y=m.quaternion,_=new ja(b,[0,i.duration],[y.x,y.y,y.z,y.w,y.x,y.y,y.z,y.w]);i.tracks.push(_),this.createRotationInterpolant(i,t,_)}}else{const b=A+".position";Hc&&console.warn("Create position track",v,m);const y=m.position,_=new el(b,[0,i.duration],[y.x,y.y,y.z,y.x,y.y,y.z]);i.tracks.push(_),this.createPositionInterpolant(i,t,_)}}}bind(){if(!this._didBind){this._didBind=!0,Hc&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const t of this.actions){const i=new Yte(t);this._actionOffsets.push(i)}this.target&&(this._animator=ne.getComponent(this.target,ks)??null,this._animator&&KD(this._animator.gameObject,this,!0));for(const t of this.models){const i=t.asset,s=i.position,r=i.rotation;s&&s.x!==void 0&&(s.isVector3||(i.position=new w(s.x,s.y,s.z)),r.isQuaternion||(i.rotation=new we(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const t=this.trackOffset.position;t&&(t.isVector3||(this.trackOffset.position=new w(t.x,t.y,t.z)));const i=this.trackOffset.rotation;i&&(i.isQuaternion||(this.trackOffset.rotation=new we(i.x,i.y,i.z,i.w)))}}evaluate(t){var c,l,u,d,f,p,g;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let i=0,s=0,r=!1,o=!1,a=0;for(let A=0;A<this.clips.length;A++){const v=this.models[A],m=this.actions[A],b=v.asset;m.weight=0;const y=t>=v.start&&t<=v.end,_=v.preExtrapolationMode,C=v.postExtrapolationMode,M=A<this.clips.length-1?this.models[A+1]:null;let I=y,R=!1;if(!I&&!r&&v.end<t&&C!==Sa.None?(!M||M.start>t)&&(I=!0,r=!0):A==0&&!I&&!o&&v.start>t&&_!==Sa.None&&(!M||M.start<t)&&(I=!0,R=!0,o=!0),I){let E=1;E*=this.evaluateWeight(t,A,this.models,I),E*=this.director.weight;let T=y;if(R)switch(_){case Sa.Hold:break;case Sa.Loop:t+=v.start,T=!0;break;default:t+=v.start,T=!0;break}let D=this.getClipTime(t,v),K=0;const H=b.duration;if(R&&_===Sa.Hold&&(D=0),T){if(b.loop)for(K+=Math.floor(D/(H+1e-6));D>H;)D-=H}else if(!y&&r)switch(C){case Sa.Hold:D=this.getClipTime(v.end,v);break;case Sa.Loop:D%=H;break;case Sa.PingPong:const N=Math.floor(D/H)%2!==0;D%=H,N&&(D=H-D);break}v.reversed===!0?m.time=m.getClip().duration-D:m.time=D,m.timeScale=0;const V=Math.max(0,E);if(m.weight=V,a+=V,m.clampWhenFinished=!1,m.isRunning()||m.play(),this._useclipOffsets){const Y=i==0?this._totalOffsetPosition:this._totalOffsetPosition2,N=i==0?this._totalOffsetRotation:this._totalOffsetRotation2;i<1&&(s=1-E),i+=1;const L=this._summedPos.set(0,0,0),G=this._tempPos.set(0,0,0),ee=this._summedRot.identity(),$=this._tempRot.identity(),j=b.rotation;j&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(j,E));const ie=this._actionOffsets[A];if(ie.hasOffsets)for(let Ae=0;Ae<K;Ae++)ie.rootPositionOffset?G.copy(ie.rootPositionOffset):G.set(0,0,0),G.applyQuaternion(ee),this._clipRotQuat&&G.applyQuaternion(this._clipRotQuat),ie.rootQuaternionOffset&&($.copy(ie.rootQuaternionOffset),ee.multiply($)),L.add(G);this._clipRotQuat&&N.multiply(this._clipRotQuat),N.multiply(ee),b.position&&L.add(b.position),Y.add(L)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,s),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,s)),this.__mixerError===void 0&&(Hc||ci())&&((l=(c=this._animator)==null?void 0:c.runtimeAnimatorController)!=null&&l.mixer)&&this.mixer!==((d=(u=this._animator)==null?void 0:u.runtimeAnimatorController)==null?void 0:d.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(f=this._animator)!=null&&f.runtimeAnimatorController){const A=Math.max(0,1-a);(g=(p=this._animator)==null?void 0:p.runtimeAnimatorController)==null||g.update(A)}else this.mixer.update(t)}createRotationInterpolant(t,i,s){var c;const r=s.createInterpolant.bind(s),o=new we;this.ensureTrackOffsets();const a=(c=this.trackOffset)==null?void 0:c.rotation;s.createInterpolant=()=>{const l=r(),u=l.evaluate.bind(l);return l.evaluate=d=>{var p;const f=u(d);if(o.set(f[0],f[1],f[2],f[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const g of this.director.animationCallbackReceivers)(p=g==null?void 0:g.onTimelineRotation)==null||p.call(g,this.director,this.target,d,o);return f[0]=o.x,f[1]=o.y,f[2]=o.z,f[3]=o.w,f},l}}createPositionInterpolant(t,i,s){var u,d;const r=s.createInterpolant.bind(s),o=new w;this.ensureTrackOffsets();const a=(u=this.trackOffset)==null?void 0:u.rotation,c=(d=this.trackOffset)==null?void 0:d.position;let l;s.createInterpolant=()=>{const f=r(),p=f.evaluate.bind(f);return f.evaluate=g=>{var v,m,b;const A=p(g);if(o.set(A[0],A[1],A[2]),i.removeStartOffset&&(l===void 0?(l=null,l=(m=(v=this._actionOffsets.find(y=>y.clip===t))==null?void 0:v.rootStartPosition)==null?void 0:m.clone()):l!=null&&l.isVector3&&o.sub(l)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),a&&o.applyQuaternion(a),c&&(o.x-=c.x,o.y+=c.y,o.z+=c.z),this.director.animationCallbackReceivers)for(const y of this.director.animationCallbackReceivers)(b=y==null?void 0:y.onTimelinePosition)==null||b.call(y,this.director,this.target,g,o);return A[0]=o.x,A[1]=o.y,A[2]=o.z,A},f}}}const Kte=re("mutetimeline"),gf=class extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"listener");h(this,"audio",[]);h(this,"audioContextTimeOffset",[]);h(this,"lastTime",0);h(this,"_audioLoader",null)}getAudioFilePath(t){const i=this.director.sourceId;return al(i,t)}onAllowAudioChanged(t){for(let i=0;i<this.models.length;i++){const s=this.models[i];this.audio[i].setVolume(t?s.asset.volume:0)}}addModel(t){const i=new I_(this.listener);this.audio.push(i),this.models.push(t)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop()}onDestroy(){for(const t of this.audio)t.source&&(t==null||t.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const i=this.audio[t];i!=null&&i.isPlaying&&i.stop()}}evaluate(t){if(Kte||this.track.muted||this.director.speed<0)return;const i=this.director.context.application.muted,s=i?.1:0;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.audio[r];if((!a||!a.buffer)&&this.isInTimeRange(o,t-1,t+1)&&this.handleAudioLoading(o,a),yn.userInteractionRegistered!==!1&&!(a===null||!a.buffer))if(a.playbackRate=this.director.context.time.timeScale,a.loop=o.asset.loop,t>=o.start&&t<=o.end&&t<this.director.duration){if(this.director.isPlaying==!1){if(a.isPlaying&&a.stop(),this.lastTime===t)continue}else if(!a.isPlaying)a.offset=o.clipIn+(t-o.start)*o.timeScale,a.play(s);else{const l=o.clipIn+(t-o.start)*o.timeScale,u=a.context.currentTime-a._startedAt+a.offset;Math.abs(l-u)>.3&&(a.offset=l,a.stop(),a.play(s))}let c=o.asset.volume;if(i&&(c=0),o.easeInDuration>0){const l=Math.min((t-o.start)/o.easeInDuration,1);c*=l}if(o.easeOutDuration>0){const l=Math.min((o.end-t)/o.easeOutDuration,1);c*=l}a.setVolume(c*this.director.weight)}else a.isPlaying&&a.stop()}this.lastTime=t}loadAudio(t,i=0,s=0){let r=null;const o=t-s,a=t+i;for(const c of this.models)if(this.isInTimeRange(c,o,a)){const l=this.audio[this.models.indexOf(c)],u=this.handleAudioLoading(c,l);u!==null&&(r===null&&(r=[]),r.push(u))}return r!==null?Promise.all(r):null}isInTimeRange(t,i,s){return i<=t.start&&s>=t.end||i>=t.start&&i<=t.end||s>=t.start&&s<=t.end}static dispose(){gf._audioBuffers.clear()}handleAudioLoading(t,i){this._audioLoader||(this._audioLoader=new $0);const s=this.getAudioFilePath(t.asset.clip);if(gf._audioBuffers.get(s)){const o=gf._audioBuffers.get(s);return o.then(a=>{a&&i.setBuffer(a)}),o}Hc&&console.warn("LOAD audio track",s,this.director.sourceId);const r=new Promise((o,a)=>{this._audioLoader.load(s,c=>{i.setBuffer(c),o(c)},void 0,c=>{console.error("Error loading audio",c),o(null)})});return gf._audioBuffers.set(s,r),r}};let wu=gf;h(wu,"_audioBuffers",new Map);class Zm extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"didTrigger",[]);h(this,"receivers",[])}evaluate(t){var s;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const o=this.models[r],a=this.didTrigger[r],c=o.time-t;let l=!1;if(o.retroActive)l=c<=1e-6;else{const u=Math.abs(c);(u===0||u>=1e-5&&u<i)&&(l=!0)}if(l){if(!a)if(Hc&&console.log("Trigger signal",t,o.time,o),this.didTrigger[r]=!0,((s=this.receivers)==null?void 0:s.length)<=0)vp.invoke(o.asset);else for(const u of this.receivers)u&&u.invoke(o.asset)}else o.emitOnce||(this.didTrigger[r]=!1)}}}class xx extends QA{constructor(){super(...arguments);h(this,"models",[]);h(this,"timelines",[]);h(this,"_previousActiveModel",null)}resolveSourceObjects(t){for(let i=this.models.length-1;i>=0;i--){const r=this.models[i].asset;if(!r.sourceObject||typeof r.sourceObject!="object"){console.log("no source object, removing model",i,r),this.models.splice(i,1);continue}else{const o=ne.getComponent(r.sourceObject,Zc);this.timelines.push(o),o&&r.updateDirector&&(o.playOnAwake=!1)}}}evaluate(t){var i;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],o=r.asset;if(t>=r.start&&t<=r.end){this._previousActiveModel=r;const a=this.getClipTime(t,r);if(o.controlActivation){const c=o.sourceObject;c.visible=!0}if(o.updateDirector){const c=this.timelines[s];c&&(c.isPlaying&&c.pause(),c.time=a,c.evaluate())}}else{const a=(i=this._previousActiveModel)==null?void 0:i.asset;if(o.controlActivation){const c=o.sourceObject;(a==null?void 0:a.sourceObject)!==c&&(c.visible=!1)}}}}}var Jte=Object.defineProperty,Zte=Object.getOwnPropertyDescriptor,Fz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zte(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jte(e,t,s),s};class Rt{constructor(e){h(this,"_active",!0);h(this,"_value");h(this,"_valueRaw");h(this,"_defaultValue");h(this,"valueProcessor");h(this,"onValueChanged");this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const i=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,i,this)}testIfValueChanged(e){return this._valueRaw!==e}}Fz([x()],Rt.prototype,"overrideState",1);Fz([x()],Rt.prototype,"value",1);var $te=Object.defineProperty,eie=Object.getOwnPropertyDescriptor,tie=(n,e,t,i)=>{for(var s=i>1?void 0:i?eie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&$te(e,t,s),s};const iie=re("debugpost");class Us extends Ah{constructor(t=void 0){super();h(this,"active",!0);h(this,"_result");h(this,"_didCreateVolumeParameters",!1);if(t){this.ensureVolumeParameters();for(const i of Object.keys(t)){const s=t[i],r=this[i];r instanceof Rt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var t;return this.ensureVolumeParameters(),this._result||(this._result=(t=this.onCreateEffect)==null?void 0:t.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){iie&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(t=>t.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const t=Object.keys(this);for(const i of t){const s=this[i];s instanceof Rt&&s.__init()}}onAfterDeserialize(t,i){if(typeof t=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Rt){const a=t[r];if(a!==void 0){const c=this[r];c.value=a}}}}}onEditorModification(t){const i=t.propertyName;if(this[i]instanceof Rt){const s=t.value;return this[i].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const t=this.$serializedTypes;if(t)for(const i of Object.keys(t))t[i]===Rt&&(this[i]||(this[i]=new Rt))}}tie([x()],Us.prototype,"active",2);var nie=Object.defineProperty,sie=Object.getOwnPropertyDescriptor,rie=(n,e,t,i)=>{for(var s=i>1?void 0:i?sie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&nie(e,t,s),s};const oie=re("debugpost"),dM={};function No(n,e){dM[n]=e}function aie(n){return n.__type in dM?dM[n.__type]:(oie&&n.__type&&console.warn("Unknown postprocessing type",n.__type,n),Us)}class WA{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}rie([lp([n=>aie(n),Us])],WA.prototype,"components",2);var cie=Object.defineProperty,lie=Object.getOwnPropertyDescriptor,hie=(n,e,t,i)=>{for(var s=i>1?void 0:i?lie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&cie(e,t,s),s};class jA extends Us{constructor(){super(...arguments);h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const t=new Iq({preset:Xd.HIGH,edgeDetectionMode:oT.DEPTH});return this.preset.onValueChanged=i=>{t.applyPreset(i)},t}}hie([x(Rt)],jA.prototype,"preset",2);No("Antialiasing",jA);class wx{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,i){const s=ne.getComponents(e,yn);if(s.length)for(const r of s){if(!r.clip||!r.playOnAwake)continue;const o=r.clip.split("/").pop();this.files.includes(r.clip)||this.files.push(r.clip),t.addEventListener("serialize",(a,c)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${r.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${r.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${r.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const i=t.split("/").pop(),o=await(await(await fetch(t)).blob()).arrayBuffer(),a=new Uint8Array(o);e.files["audio/"+i]=a}}}const Rb="noVoip",vr=re("debugvoip"),uie=re("voip");class die{constructor(e){h(this,"id");this.id=e}}class fie{constructor(e,t,i,s){h(this,"peer");h(this,"voip");h(this,"userId");h(this,"peerId");h(this,"call",null);h(this,"callErrorListener",null);h(this,"stream",null);this.voip=e,this.peer=t,this.userId=i,this.peerId=s}close(){var e;vr&&console.log("close voip call"),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.open&&this.call.close(),(e=this.stream)==null||e.getTracks().forEach(function(t){t.stop()})}updateMute(e){var i;if(!this.stream)return;const t=(i=this.stream)==null?void 0:i.getAudioTracks();for(const s of t)s.enabled=!e}async startVoipCall(){if(!await dl.HasMicrophonePermissions()){console.warn("no permission to use microphone, can not start call");return}vr&&console.log("start voip call");try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1})}catch(t){console.error(t);return}this.updateMute(this.voip.muteOutput),vr&&console.log(this.stream),this.call=this.peer.call(this.peerId,this.stream,{metadata:{userId:this.userId}}),this.call.on("error",t=>{console.error(t)}),this.call.on("stream",t=>{vr&&console.log("received stream from remote again",t)}),this.peer.on("close",this.onCallClose.bind(this)),this.callErrorListener=t=>{var i;t.message.includes(this.peerId)?(console.log("Could not connect to "+this.peerId),this.callErrorListener&&this.peer.off("error",this.callErrorListener),this.call&&this.call.close(),(i=this.stream)==null||i.getTracks().forEach(function(s){s.stop()}),this.stream=null):console.error(t)},this.peer.on("error",this.callErrorListener)}onCallClose(e){vr&&console.log("call closed",e)}}class pie{constructor(e,t,i){h(this,"voip");h(this,"call");h(this,"audio",null);h(this,"stream",null);h(this,"obj");h(this,"analyzer",null);h(this,"waitingForStart",!1);h(this,"closed",!1);h(this,"audioElement",null);this.voip=e,this.obj=t,this.call=i}get currentStream(){return this.stream}get currentAudio(){return this.audio}get currentAnalyzer(){return this.analyzer}openAudioStream(e){const t=e.getAudioTracks();for(const i of t)if(i.kind==="audio"&&i.readyState==="live"){this.open(i);return}console.warn("failed finding valid audio stream to begin call")}open(e){console.assert(e.kind==="audio","invalid track kind, expected audio but received "+e.kind),!this.waitingForStart&&(this.waitingForStart=!0,yn.userInteractionRegistered||vr&&console.log("Incoming call, waiting for user interaction before opening audio"),yn.registerWaitForAllowAudio(async()=>{if(this.call.open&&!this.closed){vr&&console.log("Setup audio and begin listening"),this.stream=new MediaStream([e]);const t=new O1;this.audio=new I_(t),this.audio.setVolume(this.voip.muteInput?0:1),this.audio.setMediaStreamSource(this.stream);const i=document.createElement("audio");this.audioElement=i,i.style.display="none",document.body.appendChild(i),i.srcObject=this.stream,i.sinkId!==void 0&&navigator.mediaDevices.enumerateDevices().then(s=>{if(i){console.log(s);for(const r of s)if(r.label==="Speakerphone"){i.sinkId=r.deviceId;break}}}),vr&&console.log("call is setup, you should hear something now"),this.analyzer=new E2(this.audio,32)}}))}close(){var e,t,i;this.closed=!0,(e=this.call)!=null&&e.open&&this.call.close(),(t=this.audio)==null||t.disconnect(),(i=this.stream)==null||i.getTracks().forEach(s=>{s.stop()}),this.stream=null,this.audioElement&&this.audioElement.remove()}}class dl extends Ie{constructor(){super(...arguments);h(this,"requireParam",!1);h(this,"peer",null);h(this,"model",null);h(this,"connections",{});h(this,"currentIncomingCalls",{});h(this,"_inputMuted",!1);h(this,"_outputMuted",!1)}set muteInput(t){var s;if(t===this._inputMuted||(this._inputMuted=t,!this.currentIncomingCalls))return;const i=this._inputMuted?0:1;for(const r in this.currentIncomingCalls){const o=this.currentIncomingCalls[r];(s=o==null?void 0:o.currentAudio)==null||s.setVolume(i)}}get muteInput(){return this._inputMuted}set muteOutput(t){if(t!==this._outputMuted&&(this._outputMuted=t,!!this.connections))for(const i in this.connections){const s=this.connections[i];s==null||s.updateMute(t)}}get muteOutput(){return this._outputMuted}getFrequency(t){if(t===null){for(const s in this.currentIncomingCalls){const r=this.currentIncomingCalls[s];if(r&&r.currentAnalyzer)return r.currentAnalyzer.getAverageFrequency()}return null}const i=this.currentIncomingCalls[t];return i&&i.currentAnalyzer?i.currentAnalyzer.getAverageFrequency():null}awake(){if(re(Rb)){console.log("VOIP is disabled by url parameter: "+Rb);return}if(this.requireParam&&!uie){console.debug("VOIP must be enabled explicitly by url parameter");return}if(Dm()&&Rc()){console.log("VOIP is currently not supported on Safari iOS");return}this.peer=Y1(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,this.context.connection.beginListen(on.JoinedRoom,t=>{navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).catch(i=>{console.error("Error initializing VoIP connection.",i)})}),this.context.connection.beginListen("peer-update-id",t=>{if(t.id!==this.context.connection.connectionId){const i=this.connections[t.id];if(i&&i.close(),this.peer&&this.context.connection.connectionId){const s=new fie(this,this.peer,this.context.connection.connectionId,t.peerId);this.connections[t.id]=s,s.startVoipCall()}}}),this.context.connection.beginListen(on.UserLeftRoom,t=>{const{userId:i}=t,s=this.connections[i];this.connections[i]=null,s&&s.close();const r=this.currentIncomingCalls[i];vr&&console.log("UserLeftRoom",t,i,r),r&&(r.close(),this.currentIncomingCalls[i]=null)}),this.peer.on("open",this.onOpenPeerConnection.bind(this))}onEnable(){}onDisable(){console.log("TODO: close all");for(const t in this.currentIncomingCalls)try{const i=this.currentIncomingCalls[t];i==null||i.close();const s=this.connections[t];s==null||s.close()}catch(i){console.error(i)}}async onOpenPeerConnection(t){vr&&console.log("Peer connection established and received id"),this.model=new die(t),this.context.connection.send("peer-update-id",this.model,Ar.OnRoomJoin),this.peer&&(this.peer.on("call",this.onReceiveCall.bind(this)),this.peer.on("connection",function(i){vr&&console.log("CONNECTION",i),i.on("data",function(s){vr&&console.log("Received",s)})}))}async onReceiveCall(t){if(!t)return;const{metadata:i}=t;console.assert(i.userId);const{userId:s}=i,r=this.currentIncomingCalls[s];if(r&&r.close(),vr&&console.log("received call"),await dl.HasMicrophonePermissions())try{const o=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});t.answer(o)}catch(o){console.error("Error initializing VoIP connection.",o)}else t.answer(null);this.currentIncomingCalls[s]=new pie(this,this.gameObject,t),t.on("stream",o=>{var a;vr&&console.log("receive caller stream, will setup audio now"),(a=this.currentIncomingCalls[s])==null||a.openAudioStream(o)}),t.on("error",console.error)}static async HasMicrophonePermissions(){try{return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}catch(t){return console.error("Error querying `microphone` permissions.",t),!1}}}var gie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,Uz=(n,e,t,i)=>{for(var s=i>1?void 0:i?mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gie(e,t,s),s};const Aie=re("debugmouth");class XA extends Ie{constructor(){super(...arguments);h(this,"idle",[]);h(this,"talking",[]);h(this,"marker",null);h(this,"voip",null);h(this,"lastMouthChangeTime",0);h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=ne.findObjectOfType(dl,this.context),this.marker||(this.marker=ne.getComponentInParent(this.gameObject,Jn))},3e3)}update(){var s;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((s=this.marker)==null?void 0:s.connectionId)??null;if(!t){Aie&&(t=null);return}const i=this.voip.getFrequency(t)??0;this.updateLips(i)}updateLips(t){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&t>30){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,i)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const i=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,i)}}}setMouthShapeActive(t,i){if(t){t!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<t.length;s++){const r=t[s];r&&(r.visible=s===i)}}}}Uz([x(Te)],XA.prototype,"idle",2);Uz([x(Te)],XA.prototype,"talking",2);class hI extends Ie{constructor(){super(...arguments);h(this,"voip",null);h(this,"marker",null);h(this,"_startPosition",null)}awake(){this.voip=ne.findObjectOfType(dl,this.context),this.marker=ne.getComponentInParent(this.gameObject,Jn)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const t=this.marker.connectionId,i=this.voip.getFrequency(t);if(i==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=i/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var vie=Object.defineProperty,yie=Object.getOwnPropertyDescriptor,Sx=(n,e,t,i)=>{for(var s=i>1?void 0:i?yie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&vie(e,t,s),s};class Hu extends Ie{constructor(){super(...arguments);h(this,"eyes",[]);h(this,"lastBlinkTime",0);h(this,"blinkLength",0);h(this,"eyesOpen",!0);h(this,"state",null)}awake(){this.state=ne.getComponentInParent(this.gameObject,jr)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const i of this.eyes)i&&(i.visible=this.eyesOpen)}}}Sx([x(Te)],Hu.prototype,"eyes",2);Sx([x()],Hu.prototype,"lastBlinkTime",2);Sx([x()],Hu.prototype,"blinkLength",2);Sx([x()],Hu.prototype,"eyesOpen",2);var bie=Object.defineProperty,_ie=Object.getOwnPropertyDescriptor,uI=(n,e,t,i)=>{for(var s=i>1?void 0:i?_ie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&bie(e,t,s),s},wC;const Nz=(wC=class extends Ie{constructor(){super(...arguments);h(this,"head",null);h(this,"eyes",null);h(this,"target",null);h(this,"brain",null);h(this,"vec",new w);h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=ne.getComponentInParent(this.gameObject,Vm)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=ne.addNewComponent(this.gameObject,Vm)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const e=this.target;if(e&&this.head){const t=this.eyes;if(t){const i=Ct(e);this.currentTargetPoint.lerp(i,this.context.time.deltaTime/.1);const s=Ct(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const o=Nz.forward;if(o.set(0,0,1),o.applyQuaternion(zn(this.head)),o.dot(r)>.45)for(let c=0;c<t.length;c++)t[c].lookAt(this.currentTargetPoint)}}}},h(wC,"forward",new w(0,0,1)),wC);let yp=Nz;uI([x(Te)],yp.prototype,"head",2);uI([x(Te)],yp.prototype,"eyes",2);uI([x(Te)],yp.prototype,"target",2);var xie=Object.defineProperty,wie=Object.getOwnPropertyDescriptor,dI=(n,e,t,i)=>{for(var s=i>1?void 0:i?wie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&xie(e,t,s),s};class bp extends Ie{constructor(){super(...arguments);h(this,"length",1);h(this,"depthTest",!0);h(this,"isGizmo",!0);h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!IA)return;this._axes||(this._axes=new tp(this.length)),this.gameObject.add(this._axes);const t=this._axes.material;t&&t.depthTest!==void 0&&(t.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}dI([x()],bp.prototype,"length",2);dI([x()],bp.prototype,"depthTest",2);dI([x()],bp.prototype,"isGizmo",2);class fI extends Ie{constructor(){super(...arguments);h(this,"from");h(this,"to");h(this,"hint");h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const t=Ct(this.to).clone(),i=Ct(this.from).clone(),s=t.distanceTo(i),r=t.clone();r.sub(i);const o=i.clone();o.add(t),o.multiplyScalar(.5);const a=Ct(this.hint).clone();a.sub(o);const c=new w;c.crossVectors(a,r),c.crossVectors(r,c),c.normalize();const l=s*.5,u=Math.max(this.desiredDistance,l),d=Math.sqrt(u*u-l*l),f=c.clone();f.multiplyScalar(d),f.add(o),Mn(this.gameObject,f);const p=o.clone();p.sub(c),this.gameObject.lookAt(p)}}const bO=re("debugusdz");class Cx{constructor(){h(this,"behaviours",[]);h(this,"behaviourComponents",[]);h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(i=>{ne.foreachComponent(i,s=>{var o;const r=s;if(typeof r.createBehaviours=="function"||typeof r.beforeCreateDocument=="function"||typeof r.afterCreateDocument=="function"||typeof r.afterSerialize=="function"){this.behaviourComponents.push(r);const a=(o=r.beforeCreateDocument)==null?void 0:o.call(r,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,i){var s;for(const r of this.behaviourComponents)(s=r.createBehaviours)==null||s.call(r,this,t,i)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var i;if((i=this.behaviours)!=null&&i.length){t.beginBlock('def Scope "Behaviors"');for(const s of this.behaviours)s.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){bO&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(bO&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var Sie=Object.defineProperty,Cie=Object.getOwnPropertyDescriptor,pI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Cie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Sie(e,t,s),s};class Vu extends Us{constructor(){super(...arguments);h(this,"threshold");h(this,"intensity");h(this,"scatter");h(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom){const i=t=new nN(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});i.inverted=!0}else t=new hT;return this.intensity.onValueChanged=i=>{t.intensity=i},this.threshold.onValueChanged=i=>{t.luminanceMaterial.threshold=i},this.scatter.onValueChanged=i=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=i},t}}pI([x(Rt)],Vu.prototype,"threshold",2);pI([x(Rt)],Vu.prototype,"intensity",2);pI([x(Rt)],Vu.prototype,"scatter",2);No("Bloom",Vu);var Eie=Object.defineProperty,Mie=Object.getOwnPropertyDescriptor,fa=(n,e,t,i)=>{for(var s=i>1?void 0:i?Mie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Eie(e,t,s),s};class Za extends Ie{constructor(){super(...arguments);h(this,"attachedRigidbody",null);h(this,"isTrigger",!1);h(this,"sharedMaterial");h(this,"updateProperties",()=>{var t;(t=this.context.physics.engine)==null||t.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}onDisable(){var t;(t=this.context.physics.engine)==null||t.removeBody(this)}get body(){var t;return(t=this.context.physics.engine)==null?void 0:t.getBody(this)}}fa([x(Ii)],Za.prototype,"attachedRigidbody",2);fa([x()],Za.prototype,"isTrigger",2);fa([x()],Za.prototype,"sharedMaterial",2);class qA extends Za{constructor(){super(...arguments);h(this,"radius",.5);h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addSphereCollider(this,this.center),z1(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),N2(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}fa([ys(),x()],qA.prototype,"radius",2);fa([x(w)],qA.prototype,"center",2);class YA extends Za{constructor(){super(...arguments);h(this,"size",new w(1,1,1));h(this,"center",new w(0,0,0))}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addBoxCollider(this,this.center,this.size)}onValidate(){this.updateProperties()}}fa([ys(),x(w)],YA.prototype,"size",2);fa([x(w)],YA.prototype,"center",2);class KA extends Za{constructor(){super(...arguments);h(this,"sharedMesh");h(this,"convex",!1)}onEnable(){var t,i,s,r,o;if(super.onEnable(),(t=this.sharedMesh)!=null&&t.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(i=this.sharedMesh)!=null&&i.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,ls(this.gameObject));else{const a=this.sharedMesh;if(a!=null&&a.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const c in a.children){const l=a.children[c];l.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,l,this.convex,ls(this.gameObject)))}}}}}fa([x()],KA.prototype,"convex",2);class lh extends Za{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2)}onEnable(){var t;super.onEnable(),(t=this.context.physics.engine)==null||t.addCapsuleCollider(this,this.center,this.height,this.radius)}}fa([x(w)],lh.prototype,"center",2);fa([x()],lh.prototype,"radius",2);fa([x()],lh.prototype,"height",2);var Tie=Object.defineProperty,Iie=Object.getOwnPropertyDescriptor,gI=(n,e,t,i)=>{for(var s=i>1?void 0:i?Iie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Tie(e,t,s),s};class Qu extends Ie{constructor(){super(...arguments);h(this,"objectBounds",!1);h(this,"color");h(this,"isGizmo",!0);h(this,"_gizmoObject",null);h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!IA||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new P_(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=YN(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Tr.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var t;for(;this._boxHelper;)(t=this._boxHelper)==null||t.update(),yield}}gI([x()],Qu.prototype,"objectBounds",2);gI([x(_e)],Qu.prototype,"color",2);gI([x()],Qu.prototype,"isGizmo",2);var Rie=Object.defineProperty,Pie=Object.getOwnPropertyDescriptor,JA=(n,e,t,i)=>{for(var s=i>1?void 0:i?Pie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Rie(e,t,s),s};const VS=re("debugui"),QS=re("debuguilayout");class mI{constructor(){h(this,"width");h(this,"height")}}class AI{constructor(){h(this,"x");h(this,"y");h(this,"width");h(this,"height")}}const qo=new w,lg=new Me,Oy=new we,zz=class extends aa{constructor(){super(...arguments);h(this,"_anchoredPosition");h(this,"sizeDelta",new te(100,100));h(this,"pivot",new te(.5,.5));h(this,"anchorMin",new te(0,0));h(this,"anchorMax",new te(1,1));h(this,"lastMatrix");h(this,"rectBlock");h(this,"_transformNeedsUpdate",!1);h(this,"_initialPosition");h(this,"_parentRectTransform");h(this,"_lastUpdateFrame",-1);h(this,"_lastAnchoring");h(this,"_createdBlocks",[]);h(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new te),this._anchoredPosition}set anchoredPosition(e){this._anchoredPosition=e}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;let i=e*t;return i+=this.sizeDelta.x,i}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;let i=e*t;return i+=this.sizeDelta.y,i}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new te),this.lastMatrix=new Me,this.rectBlock=new Te,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Jd(this,"_anchoredPosition",()=>{this.markDirty()}),Jd(this,"sizeDelta",()=>{this.markDirty()}),Jd(this,"pivot",()=>{this.markDirty()}),Jd(this,"anchorMin",()=>{this.markDirty()}),Jd(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var e;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(e=this.Canvas)==null||e.registerTransform(this)}onDisable(){var e;super.onDisable(),this.removeShadowComponent(),(e=this.Canvas)==null||e.unregisterTransform(this)}onParentRectTransformChanged(e){this._transformNeedsUpdate||this.onApplyTransform(QS?`${e.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(QS&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(e){var s;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=ne.getComponentInParent(this.gameObject.parent,zz):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,QS&&console.warn("RectTransform → ApplyTransform",this.name+" because "+e),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,qo.set(0,0,0),this.applyPivot(qo),t.matrix.setPosition(qo.x,qo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Oy.copy(this.gameObject.quaternion),Oy.x*=-1,Oy.z*=-1,lg.makeRotationFromQuaternion(Oy),t.matrix.premultiply(lg)),qo.set(0,0,0),this.applyAnchoring(qo),(s=this.Canvas)!=null&&s.screenspace?qo.z+=.1:qo.z+=.01,lg.identity(),lg.setPosition(qo.x,qo.y,qo.z),t.matrix.premultiply(lg),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const r of sT(this.gameObject,aa,i,1)){if(r===this||!r.activeAndEnabled)continue;const o=r;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(e){this._lastAnchoring||(this._lastAnchoring=new te);const t=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=t.x,this.gameObject.position.y+=t.y,this._lastAnchoring.copy(this._anchoredPosition),e.x+=this._initialPosition.x-this.gameObject.position.x,e.y+=this._initialPosition.y-this.gameObject.position.y,e.z+=this._initialPosition.z-this.gameObject.position.z;const i=this._parentRectTransform;if(i){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=i.height*.5*r,e.y+=s;let o=0;const a=1-this.anchorMax.x-this.anchorMin.x;o-=i.width*.5*a,e.x+=o}}applyPivot(e){if(this.pivot&&!this.isRoot()){const t=this.pivot.x-.5;e.x-=t*this.sizeDelta.x*this.gameObject.scale.x;const i=this.pivot.y-.5;e.y-=i*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const e={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(e),e}ensureValidSize(e,t=1e-4){return e.width<=0&&(e.width=t),e.height<=0&&(e.height=1e-4),e}createNewBlock(e){e={...this.getBasicOptions(),...e},VS&&console.log(this.name,e);const t=new aI(e);return this._createdBlocks.push(t),t}createNewText(e){VS&&console.log(e),e={...this.getBasicOptions(),...e},VS&&console.log(this.name,e);const t=new Oz(e);return this._createdTextBlocks.push(t),t}};let rr=zz;JA([x(te)],rr.prototype,"anchoredPosition",1);JA([x(te)],rr.prototype,"sizeDelta",2);JA([x(te)],rr.prototype,"pivot",2);JA([x(te)],rr.prototype,"anchorMin",2);JA([x(te)],rr.prototype,"anchorMax",2);class Bie extends Dz{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const i in t)for(const s in t[i])e._simpleState__statesProperties[s]||(e._simpleState__statesProperties[s]=[]),e._simpleState__statesProperties[s].push(i);for(const i of e._components)e._simpleState__statesProperties[i.id]&&(e._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const i=[];for(const s in t)this._simpleState__statesProperties[s]||(this._simpleState__statesProperties[s]=[],i.push(s)),this._simpleState__statesProperties[s].push(e);for(const s of this._components)i.indexOf(s.id)>-1&&(this._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const i in e)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=e[i]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var Die=Object.defineProperty,Oie=Object.getOwnPropertyDescriptor,Gz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Oie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Die(e,t,s),s};class _p extends Ie{constructor(){super(...arguments);h(this,"effectColor");h(this,"effectDistance")}}Gz([x(bi)],_p.prototype,"effectColor",2);Gz([x(te)],_p.prototype,"effectDistance",2);var kie=Object.defineProperty,Lie=Object.getOwnPropertyDescriptor,Hz=(n,e,t,i)=>{for(var s=i>1?void 0:i?Lie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&kie(e,t,s),s};const ky={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var SC;const D0=(SC=class extends aa{constructor(){super(...arguments);h(this,"_alphaFactor",1);h(this,"raycastTarget",!0);h(this,"uiObject",null);h(this,"_color",null);h(this,"_rect",null);h(this,"_stateManager",null);h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new bi(1,1,1,1)),this._color}set color(e){(!this._color||this._color.r!==e.r||this._color.g!==e.g||this._color.b!==e.b||this._color.alpha!==e.alpha)&&(this._color||(this._color=new bi(1,1,1,1)),this._color.copy(e))}setAlphaFactor(e){this._alphaFactor=e,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(ky.backgroundColor=this._color,ky.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(ky,this._alphaFactor),this.uiObject.set(ky),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=ne.getComponent(this.gameObject,rr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var e;(e=this.uiObject)==null||e.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(e){this.makePanel(),this.uiObject&&(this.uiObject.setState(e),this==null||this.markDirty())}setupState(e){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Bie(this.uiObject)),this.uiObject.setupState(e.state,e.attributes))}setOptions(e){this.makePanel(),this.uiObject&&this.uiObject.set(e)}awake(){super.awake(),this.makePanel(),Jd(this,"_color",()=>Ute(this,this.onColorChanged))}onEnable(){var e;super.onEnable(),this.uiObject&&((e=this.rectTransform.shadowComponent)==null||e.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const e=.015,t={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:e};this.onBeforeCreate(t),this.applyEffects(t),this.onCreate(t),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(e){}onCreate(e){this.uiObject=this.rectTransform.createNewBlock(e),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(e,t=1){var s;const i=(s=this.gameObject)==null?void 0:s.getComponent(_p);i&&(i.effectDistance&&(e.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(e.borderColor=i.effectColor,e.borderOpacity=i.effectColor.alpha*t))}async setTexture(e){if(this.setOptions({backgroundOpacity:0}),e){if(e.colorSpace===Ze){if(D0.textureCache.has(e))e=D0.textureCache.get(e);else if(!e.isRenderTargetTexture){const t=e.clone();t.colorSpace=An,D0.textureCache.set(e,t),e=t}}this.setOptions({backgroundImage:e,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(SC,"textureCache",new Map),SC);let Wu=D0;Hz([x(bi)],Wu.prototype,"color",1);Hz([x()],Wu.prototype,"raycastTarget",2);class ZA extends Wu{constructor(){super(...arguments);h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Fie=Object.defineProperty,Uie=Object.getOwnPropertyDescriptor,Ex=(n,e,t,i)=>{for(var s=i>1?void 0:i?Uie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Fie(e,t,s),s};let vI=class{constructor(){h(this,"texture",null);h(this,"rect")}};Ex([x(Ot)],vI.prototype,"texture",2);let xp=class extends ZA{constructor(){super(...arguments);h(this,"_sprite");h(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new vI),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,i,s,r,o,a,c,l;switch((i=(t=this.sprite)==null?void 0:t.texture)==null?void 0:i.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(r=(s=this.sprite)==null?void 0:s.texture)==null?void 0:r.image)==null?void 0:o.width)===32&&((l=(c=(a=this.sprite)==null?void 0:a.texture)==null?void 0:c.image)==null?void 0:l.height)===32}onBeforeCreate(t){var i,s;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((s=(i=this.sprite)==null?void 0:i.texture)==null?void 0:s.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};Ex([x(vI)],xp.prototype,"sprite",1);Ex([x()],xp.prototype,"pixelsPerUnitMultiplier",2);class Mx extends ZA{constructor(){super(...arguments);h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(t){this._mainTexture!==t&&(this._mainTexture=t,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Ex([x(Ot)],Mx.prototype,"mainTexture",1);var Nie=Object.defineProperty,zie=Object.getOwnPropertyDescriptor,io=(n,e,t,i)=>{for(var s=i>1?void 0:i?zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Nie(e,t,s),s};const Ud=re("debugbutton");class ju{constructor(){h(this,"colorMultiplier");h(this,"disabledColor");h(this,"fadeDuration");h(this,"highlightedColor");h(this,"normalColor");h(this,"pressedColor");h(this,"selectedColor")}}io([x()],ju.prototype,"colorMultiplier",2);io([x(bi)],ju.prototype,"disabledColor",2);io([x()],ju.prototype,"fadeDuration",2);io([x(bi)],ju.prototype,"highlightedColor",2);io([x(bi)],ju.prototype,"normalColor",2);io([x(bi)],ju.prototype,"pressedColor",2);io([x(bi)],ju.prototype,"selectedColor",2);class fl extends Ie{constructor(){super(...arguments);h(this,"onClick");h(this,"_isHovered",!1);h(this,"colors");h(this,"transition");h(this,"animationTriggers");h(this,"animator");h(this,"_interactable",!0);h(this,"_requestedAnimatorTrigger");h(this,"_isInit",!1);h(this,"_image")}onPointerEnter(t){var i,s;Ud&&console.log("Button Enter",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var t,i;Ud&&console.log("Button Exit",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(t){var i,s;Ud&&console.log("Button Down",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(t){var i,s;Ud&&console.warn("Button Up",(i=this.animationTriggers)==null?void 0:i.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(t){!this.interactable||t.pointerId===void 0||t.pointerId!==0&&this.context.input.getIsMouse(t.pointerId)||(Ud&&(console.warn("Button Click",this.onClick),pn("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),t.use()))}set interactable(t){this._interactable=t,this._image&&(this._image.setInteractable(t),t?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(t){this.interactable=t}awake(){super.awake(),Ud&&console.log(this),this._isInit=!1,this.init()}start(){var t;(t=this._image)==null||t.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(t){var i;this._requestedAnimatorTrigger=t,yield,yield,this._requestedAnimatorTrigger==t&&((i=this.animator)==null||i.SetTrigger(t))}init(){this._isInit||(this._isInit=!0,this._image=ne.getComponent(this.gameObject,xp),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(t){var p,g,A,v,m;t.setInteractable(this.interactable);const i=this.getFinalColor(t.color,(p=this.colors)==null?void 0:p.normalColor),s={state:"normal",attributes:{backgroundColor:i,backgroundOpacity:i.alpha}};t.setupState(s);const r=this.getFinalColor(t.color,(g=this.colors)==null?void 0:g.highlightedColor),o={state:"hovered",attributes:{backgroundColor:r,backgroundOpacity:r.alpha}};t.setupState(o);const a=this.getFinalColor(t.color,(A=this.colors)==null?void 0:A.pressedColor),c={state:"pressed",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};t.setupState(c);const l=this.getFinalColor(t.color,(v=this.colors)==null?void 0:v.selectedColor),u={state:"selected",attributes:{backgroundColor:l,backgroundOpacity:l.alpha}};t.setupState(u);const d=this.getFinalColor(t.color,(m=this.colors)==null?void 0:m.disabledColor),f={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};t.setupState(f)}getFinalColor(t,i){return i?t.clone().multiply(i):t.clone()}}io([x(us)],fl.prototype,"onClick",2);io([x()],fl.prototype,"colors",2);io([x()],fl.prototype,"transition",2);io([x()],fl.prototype,"animationTriggers",2);io([x(ks)],fl.prototype,"animator",2);io([x()],fl.prototype,"interactable",1);var Gie=Object.defineProperty,Hie=Object.getOwnPropertyDescriptor,Pn=(n,e,t,i)=>{for(var s=i>1?void 0:i?Hie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Gie(e,t,s),s};const _O=re("debuguilayout");class _h{constructor(){h(this,"left",0);h(this,"right",0);h(this,"top",0);h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Pn([x()],_h.prototype,"left",2);Pn([x()],_h.prototype,"right",2);Pn([x()],_h.prototype,"top",2);Pn([x()],_h.prototype,"bottom",2);class no extends Ie{constructor(){super(...arguments);h(this,"_rectTransform",null);h(this,"_needsUpdate",!1);h(this,"childAlignment",0);h(this,"reverseArrangement",!1);h(this,"spacing",0);h(this,"padding");h(this,"minWidth",0);h(this,"minHeight",0);h(this,"flexibleHeight",0);h(this,"flexibleWidth",0);h(this,"preferredHeight",0);h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(t){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(_O&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){_O&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(rr);const t=this.gameObject.getComponentInParent(ps);t&&t.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const t=this.gameObject.getComponentInParent(ps);t&&t.unregisterLayoutGroup(this)}set m_Spacing(t){t!==this.spacing&&(this._needsUpdate=!0,this.spacing=t)}get m_Spacing(){return this.spacing}}Pn([x()],no.prototype,"childAlignment",2);Pn([x()],no.prototype,"reverseArrangement",2);Pn([x()],no.prototype,"spacing",2);Pn([x(_h)],no.prototype,"padding",2);Pn([x()],no.prototype,"minWidth",2);Pn([x()],no.prototype,"minHeight",2);Pn([x()],no.prototype,"flexibleHeight",2);Pn([x()],no.prototype,"flexibleWidth",2);Pn([x()],no.prototype,"preferredHeight",2);Pn([x()],no.prototype,"preferredWidth",2);class xh extends no{constructor(){super(...arguments);h(this,"childControlHeight",!0);h(this,"childControlWidth",!0);h(this,"childForceExpandHeight",!1);h(this,"childForceExpandWidth",!1);h(this,"childScaleHeight",!1);h(this,"childScaleWidth",!1)}onCalculateLayout(t){var R;const i=this.primaryAxis,s=t.width;let r=s;const o=t.height;let a=o;r-=this.padding.horizontal,a-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const c=i==="x",l=c?"y":"x",u=c?this.childControlWidth:this.childControlHeight,d=c?this.childControlHeight:this.childControlWidth,f=c?this.childForceExpandWidth:this.childForceExpandHeight,p=c?this.childForceExpandHeight:this.childForceExpandWidth,g=c?a:r,A=c?s:o,v=.5*(c?this.childAlignment%3:Math.floor(this.childAlignment/3));let m=0;c?m+=this.padding.left:m+=this.padding.top;let b=0,y=0;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],D=ne.getComponent(T,rr);D!=null&&D.activeAndEnabled&&(y+=1,c?b+=D.width:b+=D.height)}let _=0;const C=this.spacing*(y-1);if(f||u){let E=0;c?E=r-=C:E=a-=C,y>0&&(_=E/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(m=A-b,m*=v,m-=C*v,c?(m-=this.padding.right*v,m+=this.padding.left*(1-v),m<this.padding.left&&(m=this.padding.left)):(m-=this.padding.bottom*v,m+=this.padding.top*(1-v),m<this.padding.top&&(m=this.padding.top)));let I=1;for(let E=0;E<this.gameObject.children.length;E++){const T=this.gameObject.children[E],D=ne.getComponent(T,rr);if(D!=null&&D.activeAndEnabled){(R=D.pivot)==null||R.set(.5,.5),D.anchorMin.set(0,1),D.anchorMax.set(0,1);const K=s*.5+M*.5;D.anchoredPosition.x!==K&&(D.anchoredPosition.x=K);const H=o*-.5;D.anchoredPosition.y!==H&&(D.anchoredPosition.y=H),p&&d&&D.sizeDelta[l]!==g&&(D.sizeDelta[l]=g),f&&u&&D.sizeDelta[i]!==_&&(D.sizeDelta[i]=_);const V=c?D.width:D.height,Y=V*.5;if(m+=Y,f){const L=_*I-_*.5;L>m&&(m=L-_*.5+V+this.padding.left,m-=Y)}let N=m;i==="y"&&(N=-N),D.anchoredPosition[i]!==N&&(D.anchoredPosition[i]=N),m+=Y,m+=this.spacing,I+=1}}}}Pn([x()],xh.prototype,"childControlHeight",2);Pn([x()],xh.prototype,"childControlWidth",2);Pn([x()],xh.prototype,"childForceExpandHeight",2);Pn([x()],xh.prototype,"childForceExpandWidth",2);Pn([x()],xh.prototype,"childScaleHeight",2);Pn([x()],xh.prototype,"childScaleWidth",2);class yI extends xh{get primaryAxis(){return"y"}}class bI extends xh{get primaryAxis(){return"x"}}class _I extends no{onCalculateLayout(){}}var Vie=Object.defineProperty,Qie=Object.getOwnPropertyDescriptor,$a=(n,e,t,i)=>{for(var s=i>1?void 0:i?Qie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Vie(e,t,s),s},Vz=(n=>(n[n.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",n[n.ScreenSpaceCamera=1]="ScreenSpaceCamera",n[n.WorldSpace=2]="WorldSpace",n[n.Undefined=-1]="Undefined",n))(Vz||{});const WS=re("debuguilayout"),Qz=class extends HA{constructor(){super(...arguments);h(this,"_renderOnTop");h(this,"_depthWrite",!1);h(this,"_doubleSided",!0);h(this,"_castShadows",!1);h(this,"_receiveShadows",!1);h(this,"_renderMode",-1);h(this,"_rootCanvas");h(this,"_scaleFactor",1);h(this,"worldCamera");h(this,"planeDistance",-1);h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));h(this,"previousParent",null);h(this,"_lastMatrixWorld",null);h(this,"_rectTransforms",[]);h(this,"_layoutGroups",new Map);h(this,"_receivers",[]);h(this,"onBeforeRenderRoutine",()=>{var e,t,i,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(t=this.shadowComponent)==null||t.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context,!0);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context))});h(this,"onAfterRenderRoutine",()=>{var e,t;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r==null||r.add(this.gameObject)}else this.previousParent.add(this.gameObject);const i=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),$s.ensureUpdateMeshUI(GS,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=i,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(t=this._lastMatrixWorld)==null||t.copy(this.gameObject.matrixWorld)}});h(this,"_updateRenderSettingsRoutine");h(this,"_activeRenderMode",-1);h(this,"_lastWidth",-1);h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(e){e!==this._renderOnTop&&(this._renderOnTop=e,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(e){this._depthWrite!==e&&(this._depthWrite=e,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(e){this._doubleSided!==e&&(this._doubleSided=e,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(e){this._castShadows!==e&&(this._castShadows=e,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(e){this._renderMode!==e&&(this._renderMode=e,this.onRenderSettingsChanged())}set rootCanvas(e){this._rootCanvas instanceof Qz||(this._rootCanvas=e)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(e){this._scaleFactor=e}awake(){var e;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,WS&&console.log("Canvas.Awake()",((e=this.previousParent)==null?void 0:e.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Me,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const e=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);e!==-1&&this.context.pre_render_callbacks.splice(e,1);const t=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);t!==-1&&this.context.post_render_callbacks.splice(t,1)}registerTransform(e){this._rectTransforms.push(e)}unregisterTransform(e){const t=this._rectTransforms.indexOf(e);t!==-1&&this._rectTransforms.splice(t,1)}registerLayoutGroup(e){const t=e.gameObject;this._layoutGroups.set(t,e)}unregisterLayoutGroup(e){const t=e.gameObject;this._layoutGroups.delete(t)}registerEventReceiver(e){this._receivers.push(e)}unregisterEventReceiver(e){const t=this._receivers.indexOf(e);t!==-1&&this._receivers.splice(t,1)}invokeBeforeRenderEvents(){var e;for(const t of this._receivers)(e=t.onBeforeCanvasRender)==null||e.call(t,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Me);const e=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);WS&&e&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const t=!1;for(const i of this._rectTransforms){e&&i.markDirty();let s=this._layoutGroups.get(i.gameObject);i.isDirty&&!s&&(s=i.gameObject.getComponentInParent(no)),(i.isDirty||s!=null&&s.isDirty)&&(WS&&!t&&console.log("CANVAS UPDATE ### "+i.name+" ##################################### "+this.context.time.frame),s==null||s.updateLayout(),i.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Tr.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Tb(this.shadowComponent,this);for(const e of ne.getComponentsInChildren(this.gameObject,aa))Tb(e.shadowComponent,this)}}onUpdateRenderMode(e=!1){if(!e&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let t=this.context.mainCameraComponent,i=10;switch(t&&t.nearClipPlane>0&&t.farClipPlane>0&&(i=tt.lerp(t.nearClipPlane,t.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(t=this.worldCamera),this.planeDistance>0&&(i=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!t)return;const s=i+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(rr);let o=!1;r.sizeDelta.x!==this.context.domWidth&&(o=!0),r.sizeDelta.y!==this.context.domHeight&&(o=!0);const a=t.fieldOfView*Math.PI/180,c=2*Math.tan(a/2)*Math.abs(s);this.gameObject.scale.x=c/this.context.domHeight,this.gameObject.scale.y=c/this.context.domHeight,this.gameObject.scale.z=.01,o&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r==null||r.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let ps=Qz;$a([x()],ps.prototype,"renderOnTop",1);$a([x()],ps.prototype,"depthWrite",1);$a([x()],ps.prototype,"doubleSided",1);$a([x()],ps.prototype,"castShadows",1);$a([x()],ps.prototype,"receiveShadows",1);$a([x()],ps.prototype,"renderMode",1);$a([x(ps)],ps.prototype,"rootCanvas",1);$a([x()],ps.prototype,"scaleFactor",1);$a([x(Li)],ps.prototype,"worldCamera",2);$a([x()],ps.prototype,"planeDistance",2);var Wie=Object.defineProperty,jie=Object.getOwnPropertyDescriptor,xI=(n,e,t,i)=>{for(var s=i>1?void 0:i?jie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Wie(e,t,s),s};class hh extends Ie{constructor(){super(...arguments);h(this,"_alpha",1);h(this,"interactable",!0);h(this,"blocksRaycasts",!0);h(this,"_isDirty",!1);h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(t){t!==this._alpha&&(this._alpha=t,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Tr.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const t of ne.getComponentsInChildren(this.gameObject,aa,this._buffer)){const i=t;i.setAlphaFactor&&i.setAlphaFactor(this._alpha)}}}xI([x()],hh.prototype,"alpha",1);xI([x()],hh.prototype,"interactable",2);xI([x()],hh.prototype,"blocksRaycasts",2);var Xie=Object.defineProperty,qie=Object.getOwnPropertyDescriptor,Fi=(n,e,t,i)=>{for(var s=i>1?void 0:i?qie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Xie(e,t,s),s};class Xu extends Ie{constructor(){super(...arguments);h(this,"object");h(this,"target");h(this,"duration",1);h(this,"relativeMotion",!1);h(this,"coroutine",null);h(this,"targetPos",new w);h(this,"targetRot",new we);h(this,"targetScale",new w)}*moveToTarget(){if(!this.target||!this.object)return;const t=Ct(this.object).clone(),i=Ct(this.target).clone(),s=zn(this.object).clone(),r=zn(this.target).clone(),o=ls(this.object).clone(),a=ls(this.target).clone(),c=t.distanceTo(i),l=s.angleTo(r),u=o.distanceTo(a);if(c<.01&&l<.01&&u<.01){Mn(this.object,i),Mr(this.object,r),AE(this.object,a),this.coroutine=null;return}let d=0,f=0;for(;d<1;)d+=this.context.time.deltaTime/this.duration,d>1&&(d=1),f=d<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2,this.targetPos.lerpVectors(t,i,f),this.targetRot.slerpQuaternions(s,r,f),this.targetScale.lerpVectors(o,a,f),Mn(this.object,this.targetPos),Mr(this.object,this.targetRot),AE(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const t=this.object.position.clone(),i=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),o=this.target.quaternion.clone(),a=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(a);let c=0,l=0;for(;c<1;)c+=this.context.time.deltaTime/this.duration,c>1&&(c=1),l=c<.5?4*c*c*c:1-Math.pow(-2*c+2,3)/2,this.object.position.lerpVectors(t,this.targetPos,l),this.object.quaternion.slerpQuaternions(i,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(t){t.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(t){var i;if(this.target&&this.object&&this.gameObject){const s=new ds("Move to "+((i=this.target)==null?void 0:i.name),Cr.tapTrigger(this.gameObject),fi.transformAction(this.object,this.target,this.duration,this.relativeMotion?tM.Relative:tM.Absolute));t.addBehavior(s)}}}Fi([x(Te)],Xu.prototype,"object",2);Fi([x(Te)],Xu.prototype,"target",2);Fi([x()],Xu.prototype,"duration",2);Fi([x()],Xu.prototype,"relativeMotion",2);var i0;const _c=(i0=class extends Ie{constructor(){super(...arguments);h(this,"materialToSwitch");h(this,"variantMaterial");h(this,"fadeDuration",0);h(this,"_objectsWithThisMaterial",[]);h(this,"selfModel");h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const e=ne.findObjectsOfType(Qi);for(const t of e)for(let i=0;i<t.sharedMaterials.length;i++){const s=t.sharedMaterials[i];if(s===this.materialToSwitch){if(t.gameObject instanceof ye)this._objectsWithThisMaterial.push(t.gameObject);else if(t.gameObject instanceof yr)for(const r of t.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(e){if(e.use(),!!this.variantMaterial)for(let t=0;t<this._objectsWithThisMaterial.length;t++){const i=this._objectsWithThisMaterial[t];i.material=this.variantMaterial}}async beforeCreateDocument(e,t){this.targetModels=[],_c._materialTriggersPerId={},_c.variantSwitchIndex=0,this.materialToSwitch&&await Hr.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Hr.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(e,t,i){this._objectsWithThisMaterial.find(r=>r.uuid===t.uuid)&&this.targetModels.push(t),this.gameObject.uuid===t.uuid&&(this.selfModel=t,this.materialToSwitch&&(_c._materialTriggersPerId[this.materialToSwitch.uuid]||(_c._materialTriggersPerId[this.materialToSwitch.uuid]=[]),_c._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(e,t){if(!this.materialToSwitch)return;const i=_c._materialTriggersPerId[this.materialToSwitch.uuid];if(i){const s={};for(const o of i){const a=o.createVariants();a&&a.length>0&&(s[o.selfModel.uuid]=a)}const r=[];for(const o of i){for(const a in s)a!==o.selfModel.uuid&&r.push(s[a]);o.createAndAttachBehaviors(e,s[o.selfModel.uuid],r)}}delete _c._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(e,t,i){const s=[],r=[],o=Math.max(0,this.fadeDuration);for(const a of this.targetModels){const c=fi.fadeAction(a,o,!1);r.push(c)}for(const a of i)r.push(fi.fadeAction(a,o,!1));for(const a of t)s.push(fi.fadeAction(a,o,!1)),r.push(fi.fadeAction(a,o,!0));e.addBehavior(new ds("Select "+this.selfModel.name,Cr.tapTrigger(this.selfModel),fi.parallel(...r))),e.addBehavior(new ds("Start hidden "+this.selfModel.name,Cr.sceneStartTrigger(),fi.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const e=[];for(const t of this.targetModels){const i=t.clone();i.name+=" variant_"+this.variantMaterial.name+"_"+_c.variantSwitchIndex++,i.name=i.name.replace(/\s/g,"_"),i.material=this.variantMaterial,i.geometry=t.geometry,i.matrix=t.matrix,(!t.parent||!t.parent.isEmpty())&&_r.createEmptyParent(t),t.parent&&t.parent.add(i),e.push(i)}return e}},h(i0,"_materialTriggersPerId",{}),h(i0,"variantSwitchIndex",0),i0);let wp=_c;Fi([x(kt)],wp.prototype,"materialToSwitch",2);Fi([x(kt)],wp.prototype,"variantMaterial",2);Fi([x()],wp.prototype,"fadeDuration",2);class Sp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"toggleOnClick",!1);h(this,"targetState",!0);h(this,"hideSelf",!0);h(this,"selfModel");h(this,"otherModel");h(this,"toggleModel");h(this,"stateBeforeCreatingDocument",!1)}onPointerClick(t){t.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,i,s){i.uuid===this.gameObject.uuid&&(this.selfModel=i)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(t,i){if(this.target){if(this.otherModel=i.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&e3.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(fi.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(fi.fadeAction(this.toggleModel,0,!0)),r.push(fi.fadeAction(this.otherModel,0,this.targetState)),t.addBehavior(new ds("Toggle_"+this.selfModel.name+"_hideSelf",Cr.tapTrigger(this.selfModel),fi.sequence(...r))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(fi.fadeAction(this.toggleModel,0,!1)),o.push(fi.fadeAction(this.selfModel,0,!0)),o.push(fi.fadeAction(this.otherModel,0,!this.targetState)),t.addBehavior(new ds("Toggle_"+this.selfModel.name+"_toggleSelf",Cr.tapTrigger(this.toggleModel),fi.sequence(...o))),t.addBehavior(new ds("HideOnStart_"+this.gameObject.name,Cr.sceneStartTrigger(),fi.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Fi([x(Te)],Sp.prototype,"target",2);Fi([x()],Sp.prototype,"targetState",2);Fi([x()],Sp.prototype,"hideSelf",2);class wI extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&e.addBehavior(new ds("HideOnStart_"+this.gameObject.name,Cr.sceneStartTrigger(),fi.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Cp extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"duration",.5);h(this,"motionType",MT.bounce)}beforeCreateDocument(){}createBehaviours(t,i,s){if(this.target&&i.uuid===this.gameObject.uuid){const r=new ds("emphasize "+this.name,Cr.tapTrigger(this.gameObject),fi.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));t.addBehavior(r)}}afterCreateDocument(t,i){}}Fi([x()],Cp.prototype,"target",2);Fi([x()],Cp.prototype,"duration",2);Fi([x()],Cp.prototype,"motionType",2);class Ep extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"clip","");h(this,"toggleOnClick",!1)}onPointerClick(t){if(t.use(),!(!this.target&&!this.clip)){if(!this.target){const i=this.gameObject.addNewComponent(yn);i&&(i.spatialBlend=1,i.volume=1,i.loop=!1,this.target=i)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(t,i,s){if(!(!this.target&&!this.clip)&&i.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const o=this.target?this.target.gameObject:this.gameObject,a=r.split("/").pop(),c=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?iM.NonSpatial:iM.Spatial,u=new ds("playAudio "+this.name,Cr.tapTrigger(this.gameObject),fi.playAudioAction(o,"audio/"+a,o3.Play,c,l));t.addBehavior(u)}}async afterSerialize(t,i){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),c=await(await(await fetch(this.clip)).blob()).arrayBuffer(),l=new Uint8Array(c);i.files["audio/"+r]=l}}Fi([x(yn)],Ep.prototype,"target",2);Fi([x(URL)],Ep.prototype,"clip",2);Fi([x()],Ep.prototype,"toggleOnClick",2);var CC;const Zd=(CC=class extends Ie{constructor(){super(...arguments);h(this,"target");h(this,"animator");h(this,"stateName");h(this,"stateNameAfterPlaying");h(this,"loopAfterPlaying",!1);h(this,"selfModel");h(this,"stateAnimationModel");h(this,"stateAnimation");h(this,"stateAfterPlayingAnimationModel");h(this,"stateAfterPlayingAnimation")}onPointerClick(e){var t;e.use(),this.target&&this.stateName&&((t=this.animator)==null||t.play(this.stateName,0,0,.1))}createBehaviours(e,t,i){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}onAfterHierarchy(){Zd.animationActions=[]}afterCreateDocument(e,t){if(!this.stateAnimation||!this.stateAnimationModel)return;t.document.traverse(s=>{var r,o;if(s.uuid===((r=this.target)==null?void 0:r.uuid)&&this.stateAnimation){const a=[];let c=Zd.animationActions.find(u=>u.affectedObjects==s&&u.start==this.stateAnimation.start&&u.duration==this.stateAnimation.duration);if(c||(c=fi.startAnimationAction(s,this.stateAnimation.start,this.stateAnimation.duration),Zd.animationActions.push(c)),a.push(c),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let u=Zd.animationActions.find(f=>f.affectedObjects==s&&f.start==this.stateAfterPlayingAnimation.start&&f.duration==this.stateAfterPlayingAnimation.duration);u||(u=fi.startAnimationAction(s,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),Zd.animationActions.push(u));const d=fi.sequence(u);this.loopAfterPlaying&&d.makeLooping(),a.push(d)}const l=new ds("tap "+this.name+" for "+this.stateName+" on "+((o=this.target)==null?void 0:o.name),Cr.tapTrigger(this.selfModel),fi.sequence(...a));e.addBehavior(l)}})}createAnimation(e,t,i){var s,r,o,a,c;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((o=l==null?void 0:l.motion)!=null&&o.clip)){ci()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=t,this.stateAnimation=e.registerAnimation(this.target,l==null?void 0:l.motion.clip);const u=(c=(a=this.animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:c.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=t,this.stateAfterPlayingAnimation=e.registerAnimation(this.target,u==null?void 0:u.motion.clip)}}},h(CC,"animationActions",[]),CC);let wh=Zd;Fi([x(Te)],wh.prototype,"target",2);Fi([x(ks)],wh.prototype,"animator",2);Fi([x()],wh.prototype,"stateName",2);Fi([x()],wh.prototype,"stateNameAfterPlaying",2);Fi([x()],wh.prototype,"loopAfterPlaying",2);class Mp extends Ie{constructor(){super(...arguments);h(this,"target")}getType(){}getDuration(){}}Fi([x(Te)],Mp.prototype,"target",2);class $A extends Ie{constructor(){super(...arguments);h(this,"target")}}Fi([x(Mp)],$A.prototype,"target",2);class ev extends Mp{constructor(){super(...arguments);h(this,"type",1);h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Fi([x()],ev.prototype,"type",2);Fi([x()],ev.prototype,"duration",2);class SI extends $A{}var Yie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,pl=(n,e,t,i)=>{for(var s=i>1?void 0:i?Kie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Yie(e,t,s),s};class qu extends Ie{constructor(){super(...arguments);h(this,"center",new w(0,0,0));h(this,"radius",.5);h(this,"height",2);h(this,"_rigidbody",null);h(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ii),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Ii)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const t=this.rigidbody;let i=this.gameObject.getComponent(lh);i||(i=this.gameObject.addNewComponent(lh)),i.center.copy(this.center),i.radius=this.radius,i.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),o=new w(0,1,0),a=this.gameObject.getWorldDirection(new w);a.y=0;const c=r.dot(a)<0?-1:1,l=s.angleTo(a)*c;this.gameObject.setRotationFromAxisAngle(o,l),t.lockRotationX=!0,t.lockRotationY=!0,t.lockRotationZ=!0}move(t){this.gameObject.position.add(t)}onCollisionEnter(t){for(const i of t.contacts)if(i.normal.y>.1){this._activeGroundCollisions.add(t);break}}onCollisionExit(t){this._activeGroundCollisions.delete(t)}get isGrounded(){return this._activeGroundCollisions.size>0}}pl([x(w)],qu.prototype,"center",2);pl([x()],qu.prototype,"radius",2);pl([x()],qu.prototype,"height",2);class gl extends Ie{constructor(){super(...arguments);h(this,"controller");h(this,"movementSpeed",2);h(this,"rotationSpeed",2);h(this,"jumpForce",1);h(this,"doubleJumpForce",2);h(this,"animator");h(this,"lookForward",!0);h(this,"lookInput",new te(0,0));h(this,"moveInput",new te(0,0));h(this,"jumpInput",!1);h(this,"_currentSpeed",new w(0,0,0));h(this,"_currentAngularSpeed",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_jumpCount",0);h(this,"_currentRotation");h(this,"_raycastOptions",new ko)}awake(){this._currentRotation=new we}update(){const t=this.context.input;t.isKeyPressed("KeyW")?this.moveInput.y+=1:t.isKeyPressed("KeyS")&&(this.moveInput.y-=1),t.isKeyPressed("KeyD")?this.lookInput.x+=1:t.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=t.isKeyDown("Space"))}move(t){this.moveInput.add(t)}look(t){this.lookInput.add(t)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(t,i,s){var r,o,a,c,l,u,d,f,p,g,A;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=t.y*this.movementSpeed*this.context.time.deltaTime,(a=this.animator)==null||a.setBool("running",t.length()>.01),(l=this.animator)==null||l.setBool("jumping",((c=this.controller)==null?void 0:c.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-i.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const v=this.context.mainCameraComponent.forward;v.y=0,v.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),v),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let v=(u=this.controller)==null?void 0:u.isGrounded;if(this.doubleJumpForce>0&&!((d=this.controller)!=null&&d.isGrounded)&&this._jumpCount===1&&(v=!0,(f=this.animator)==null||f.setBool("doubleJump",!0)),v){this._jumpCount+=1;const m=this.controller.rigidbody,b=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;m.applyImpulse(new w(0,1,0).multiplyScalar(b))}}if(this.controller){const v=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(v<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Ya),this._raycastOptions.ray.origin.copy(Ct(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const m=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const b=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(m),(b.length&&b[0].distance>2||v<-10)&&((g=this.animator)==null||g.setBool("falling",!0))}else(A=this.animator)==null||A.setBool("falling",!1)}}}pl([x(qu)],gl.prototype,"controller",2);pl([x()],gl.prototype,"movementSpeed",2);pl([x()],gl.prototype,"rotationSpeed",2);pl([x()],gl.prototype,"jumpForce",2);pl([x()],gl.prototype,"doubleJumpForce",2);pl([x(ks)],gl.prototype,"animator",2);var Jie=Object.defineProperty,Zie=Object.getOwnPropertyDescriptor,$ie=(n,e,t,i)=>{for(var s=i>1?void 0:i?Zie(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Jie(e,t,s),s};class tv extends Us{constructor(){super(...arguments);h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const t=new $U;return t.offset=new te(0,0),t.radialModulation=!0,t.modulationOffset=.15,this.intensity.valueProcessor=i=>i*.02,this.intensity.onValueChanged=i=>{t.offset.x=-i,t.offset.y=i},t}}$ie([x(Rt)],tv.prototype,"intensity",2);No("ChromaticAberration",tv);var ene=Object.defineProperty,tne=Object.getOwnPropertyDescriptor,Tx=(n,e,t,i)=>{for(var s=i>1?void 0:i?tne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&ene(e,t,s),s};class Sh extends Us{constructor(){super(...arguments);h(this,"postExposure");h(this,"contrast");h(this,"hueShift");h(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=t=>(t=Math.pow(2,t),t),this.postExposure.defaultValue=0,this.contrast.valueProcessor=t=>{let i=1;return t>0?i=200:t<0&&(i=100),t/i},this.contrast.defaultValue=0,this.hueShift.valueProcessor=t=>Math.PI*t/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=t=>t<0?t/100:t/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===er&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=_m);const t=new ZU;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===er&&(this.context.renderer.toneMapping=_m),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{t.contrast=s};const i=new tN;return this.hueShift.onValueChanged=s=>i.hue=s,this.saturation.onValueChanged=s=>i.saturation=s,[i,t]}}Tx([x(Rt)],Sh.prototype,"postExposure",2);Tx([x(Rt)],Sh.prototype,"contrast",2);Tx([x(Rt)],Sh.prototype,"hueShift",2);Tx([x(Rt)],Sh.prototype,"saturation",2);No("ColorAdjustments",Sh);const ine=(Math.sqrt(5)-1)/4,ts=(5-Math.sqrt(5))/20,Ly=n=>Math.floor(n)|0,Fy=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function nne(n=Math.random){const e=sne(n),t=new Float64Array(e).map(o=>Fy[o%32*4]),i=new Float64Array(e).map(o=>Fy[o%32*4+1]),s=new Float64Array(e).map(o=>Fy[o%32*4+2]),r=new Float64Array(e).map(o=>Fy[o%32*4+3]);return function(a,c,l,u){let d,f,p,g,A;const v=(a+c+l+u)*ine,m=Ly(a+v),b=Ly(c+v),y=Ly(l+v),_=Ly(u+v),C=(m+b+y+_)*ts,M=m-C,I=b-C,R=y-C,E=_-C,T=a-M,D=c-I,K=l-R,H=u-E;let V=0,Y=0,N=0,L=0;T>D?V++:Y++,T>K?V++:N++,T>H?V++:L++,D>K?Y++:N++,D>H?Y++:L++,K>H?N++:L++;const G=V>=3?1:0,ee=Y>=3?1:0,$=N>=3?1:0,j=L>=3?1:0,ie=V>=2?1:0,Ae=Y>=2?1:0,ge=N>=2?1:0,Ce=L>=2?1:0,Ee=V>=1?1:0,Ge=Y>=1?1:0,Qe=N>=1?1:0,ut=L>=1?1:0,Et=T-G+ts,st=D-ee+ts,W=K-$+ts,Fe=H-j+ts,me=T-ie+2*ts,Le=D-Ae+2*ts,Se=K-ge+2*ts,it=H-Ce+2*ts,Xe=T-Ee+3*ts,Ye=D-Ge+3*ts,At=K-Qe+3*ts,Mt=H-ut+3*ts,Yt=T-1+4*ts,z=D-1+4*ts,k=K-1+4*ts,he=H-1+4*ts,Pe=m&255,Be=b&255,Ue=y&255,X=_&255;let de=.6-T*T-D*D-K*K-H*H;if(de<0)d=0;else{const ke=Pe+e[Be+e[Ue+e[X]]];de*=de,d=de*de*(t[ke]*T+i[ke]*D+s[ke]*K+r[ke]*H)}let ce=.6-Et*Et-st*st-W*W-Fe*Fe;if(ce<0)f=0;else{const ke=Pe+G+e[Be+ee+e[Ue+$+e[X+j]]];ce*=ce,f=ce*ce*(t[ke]*Et+i[ke]*st+s[ke]*W+r[ke]*Fe)}let je=.6-me*me-Le*Le-Se*Se-it*it;if(je<0)p=0;else{const ke=Pe+ie+e[Be+Ae+e[Ue+ge+e[X+Ce]]];je*=je,p=je*je*(t[ke]*me+i[ke]*Le+s[ke]*Se+r[ke]*it)}let qe=.6-Xe*Xe-Ye*Ye-At*At-Mt*Mt;if(qe<0)g=0;else{const ke=Pe+Ee+e[Be+Ge+e[Ue+Qe+e[X+ut]]];qe*=qe,g=qe*qe*(t[ke]*Xe+i[ke]*Ye+s[ke]*At+r[ke]*Mt)}let Ve=.6-Yt*Yt-z*z-k*k-he*he;if(Ve<0)A=0;else{const ke=Pe+1+e[Be+1+e[Ue+1+e[X+1]]];Ve*=Ve,A=Ve*Ve*(t[ke]*Yt+i[ke]*z+s[ke]*k+r[ke]*he)}return 27*(d+f+p+g+A)}}function sne(n){const t=new Uint8Array(512);for(let i=0;i<512/2;i++)t[i]=i;for(let i=0;i<512/2-1;i++){const s=i+~~(n()*(256-i)),r=t[i];t[i]=t[s],t[s]=r}for(let i=256;i<512;i++)t[i]=t[i-256];return t}var rne=Object.defineProperty,one=Object.getOwnPropertyDescriptor,se=(n,e,t,i)=>{for(var s=i>1?void 0:i?one(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&rne(e,t,s),s};const Uy=re("debugparticles");var Mc=(n=>(n[n.Billboard=0]="Billboard",n[n.Stretch=1]="Stretch",n[n.HorizontalBillboard=2]="HorizontalBillboard",n[n.VerticalBillboard=3]="VerticalBillboard",n[n.Mesh=4]="Mesh",n))(Mc||{});let Ch=class{constructor(){h(this,"alphaKeys");h(this,"colorKeys")}get duration(){return 1}evaluate(e,t){let i,s=0,r=null,o=0;for(let a=0;a<this.alphaKeys.length;a++){const c=this.alphaKeys[a];(c.time<e||!i)&&(i=c,s=a)}for(let a=0;a<this.colorKeys.length;a++){const c=this.colorKeys[a];(c.time<e||!r)&&(r=c,o=a)}if(r)if(o+1<this.colorKeys.length){const c=this.colorKeys[o+1],l=tt.remap(e,r.time,c.time,0,1);t.r=tt.lerp(r.color.r,c.color.r,l),t.g=tt.lerp(r.color.g,c.color.g,l),t.b=tt.lerp(r.color.b,c.color.b,l)}else t.r=r.color.r,t.g=r.color.g,t.b=r.color.b;if(i)if(s+1<this.alphaKeys.length){const c=this.alphaKeys[s+1],l=tt.remap(e,i.time,c.time,0,1);t.alpha=tt.lerp(i.alpha,c.alpha,l)}else t.alpha=i.alpha;return t}};se([x()],Ch.prototype,"alphaKeys",2);se([x()],Ch.prototype,"colorKeys",2);var $m=(n=>(n[n.Local=0]="Local",n[n.World=1]="World",n[n.Custom=2]="Custom",n))($m||{}),Wz=(n=>(n[n.Sphere=0]="Sphere",n[n.SphereShell=1]="SphereShell",n[n.Hemisphere=2]="Hemisphere",n[n.HemisphereShell=3]="HemisphereShell",n[n.Cone=4]="Cone",n[n.Box=5]="Box",n[n.Mesh=6]="Mesh",n[n.ConeShell=7]="ConeShell",n[n.ConeVolume=8]="ConeVolume",n[n.ConeVolumeShell=9]="ConeVolumeShell",n[n.Circle=10]="Circle",n[n.CircleEdge=11]="CircleEdge",n[n.SingleSidedEdge=12]="SingleSidedEdge",n[n.MeshRenderer=13]="MeshRenderer",n[n.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",n[n.BoxShell=15]="BoxShell",n[n.BoxEdge=16]="BoxEdge",n[n.Donut=17]="Donut",n[n.Rectangle=18]="Rectangle",n[n.Sprite=19]="Sprite",n[n.SpriteRenderer=20]="SpriteRenderer",n))(Wz||{});class ht{constructor(){h(this,"mode");h(this,"constant");h(this,"constantMin");h(this,"constantMax");h(this,"curve");h(this,"curveMin");h(this,"curveMax");h(this,"curveMultiplier")}evaluate(e,t){const i=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const s=e*this.curveMin.duration,r=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(s),this.curveMax.evaluate(r),i%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,i%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let i=0;i<e.keys.length;i++){const s=e.keys[i];s.value>t&&(t=s.value)}return t}}se([x()],ht.prototype,"mode",2);se([x()],ht.prototype,"constant",2);se([x()],ht.prototype,"constantMin",2);se([x()],ht.prototype,"constantMax",2);se([x(zu)],ht.prototype,"curve",2);se([x(zu)],ht.prototype,"curveMin",2);se([x(zu)],ht.prototype,"curveMax",2);se([x()],ht.prototype,"curveMultiplier",2);var n0;const Ko=(n0=class{constructor(){h(this,"mode");h(this,"color");h(this,"colorMin");h(this,"colorMax");h(this,"gradient");h(this,"gradientMin");h(this,"gradientMax")}evaluate(n,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(n,Ko._temp),Ko._temp;case 2:return Ko._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(n,Ko._temp),this.gradientMax.evaluate(n,Ko._temp2),Ko._temp.lerp(Ko._temp2,t)}return Ko._temp.set(16711935),Ko._temp.alpha=1,Ko._temp}},h(n0,"_temp",new bi(0,0,0,1)),h(n0,"_temp2",new bi(0,0,0,1)),n0);let Ir=Ko;se([x(bi)],Ir.prototype,"color",2);se([x(bi)],Ir.prototype,"colorMin",2);se([x(bi)],Ir.prototype,"colorMax",2);se([x(Ch)],Ir.prototype,"gradient",2);se([x(Ch)],Ir.prototype,"gradientMin",2);se([x(Ch)],Ir.prototype,"gradientMax",2);var fM=(n=>(n[n.Hierarchy=0]="Hierarchy",n[n.Local=1]="Local",n[n.Shape=2]="Shape",n))(fM||{});class bs{constructor(){h(this,"cullingMode");h(this,"duration");h(this,"emitterVelocityMode");h(this,"flipRotation");h(this,"gravityModifier");h(this,"gravityModifierMultiplier");h(this,"loop");h(this,"maxParticles");h(this,"playOnAwake");h(this,"prewarm");h(this,"ringBufferLoopRange");h(this,"ringBufferMode");h(this,"scalingMode");h(this,"simulationSpace");h(this,"simulationSpeed");h(this,"startColor");h(this,"startDelay");h(this,"startDelayMultiplier");h(this,"startLifetime");h(this,"startLifetimeMultiplier");h(this,"startRotation");h(this,"startRotationMultiplier");h(this,"startRotation3D");h(this,"startRotationX");h(this,"startRotationXMultiplier");h(this,"startRotationY");h(this,"startRotationYMultiplier");h(this,"startRotationZ");h(this,"startRotationZMultiplier");h(this,"startSize");h(this,"startSize3D");h(this,"startSizeMultiplier");h(this,"startSizeX");h(this,"startSizeXMultiplier");h(this,"startSizeY");h(this,"startSizeYMultiplier");h(this,"startSizeZ");h(this,"startSizeZMultiplier");h(this,"startSpeed");h(this,"startSpeedMultiplier");h(this,"stopAction");h(this,"useUnscaledTime")}}se([x(ht)],bs.prototype,"gravityModifier",2);se([x(Ir)],bs.prototype,"startColor",2);se([x(ht)],bs.prototype,"startDelay",2);se([x(ht)],bs.prototype,"startLifetime",2);se([x(ht)],bs.prototype,"startRotation",2);se([x(ht)],bs.prototype,"startRotationX",2);se([x(ht)],bs.prototype,"startRotationY",2);se([x(ht)],bs.prototype,"startRotationZ",2);se([x(ht)],bs.prototype,"startSize",2);se([x(ht)],bs.prototype,"startSizeX",2);se([x(ht)],bs.prototype,"startSizeY",2);se([x(ht)],bs.prototype,"startSizeZ",2);se([x(ht)],bs.prototype,"startSpeed",2);class eA{constructor(){h(this,"cycleCount");h(this,"maxCount");h(this,"minCount");h(this,"probability");h(this,"repeatInterval");h(this,"time");h(this,"count");h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const i=this.time+this.repeatInterval*this._performed;if(e>=i&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const s=Math.random();t=tt.lerp(this.count.curveMin.evaluate(s),this.count.curveMax.evaluate(s),Math.random());break}}return t}}class ec{constructor(){h(this,"enabled");h(this,"bursts");h(this,"rateOverTime");h(this,"rateOverTimeMultiplier");h(this,"rateOverDistance");h(this,"rateOverDistanceMultiplier");h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const i=this.bursts[t];this.system.main.loop&&i.time>=this.system.time&&i.reset(),e+=Math.round(i.run(this.system.time))}return e}}se([x()],ec.prototype,"enabled",2);se([x()],ec.prototype,"bursts",2);se([x(ht)],ec.prototype,"rateOverTime",2);se([x()],ec.prototype,"rateOverTimeMultiplier",2);se([x(ht)],ec.prototype,"rateOverDistance",2);se([x()],ec.prototype,"rateOverDistanceMultiplier",2);class iv{constructor(){h(this,"enabled");h(this,"color")}}se([x(Ir)],iv.prototype,"color",2);class Eh{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_time",0);h(this,"_temp",new w)}evaluate(e,t,i){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,i)*this.xMultiplier,t.y=this.y.evaluate(e,i)*this.yMultiplier,t.z=this.z.evaluate(e,i)*this.zMultiplier;else{const s=this.size.evaluate(e,i)*this.sizeMultiplier;t.x=s}return t}}se([x(ht)],Eh.prototype,"size",2);se([x(ht)],Eh.prototype,"x",2);se([x(ht)],Eh.prototype,"y",2);se([x(ht)],Eh.prototype,"z",2);var s0;const Dg=(s0=class{constructor(){h(this,"shapeType",5);h(this,"enabled",!0);h(this,"alignToDirection",!1);h(this,"angle",0);h(this,"arc",360);h(this,"arcSpread");h(this,"arcSpeedMultiplier");h(this,"arcMode");h(this,"boxThickness");h(this,"position");h(this,"rotation");h(this,"_rotation",new mn);h(this,"scale");h(this,"radius");h(this,"radiusThickness");h(this,"sphericalDirectionAmount");h(this,"randomDirectionAmount");h(this,"randomPositionAmount");h(this,"system");h(this,"_space");h(this,"_worldSpaceMatrix",new Me);h(this,"_worldSpaceMatrixInverse",new Me);h(this,"_vector",new w(0,0,0));h(this,"_temp",new w(0,0,0));h(this,"_dir",new w);h(this,"_loopTime",0);h(this,"_loopDirection",1);Uy&&console.log(this)}get type(){return Wz[this.shapeType]}initialize(n){this.getPosition(),n.position.copy(this._vector)}toJSON(){return this}clone(){return new Dg}update(n,e,t,i){this.system=n,this._space=t,t===1&&(this._worldSpaceMatrix.copy(i.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(n){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",n.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const n=this._temp.copy(this.position),e=this._space===1;e&&n.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Uy&&zc.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(n);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Uy&&zc.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(n){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=n.x,i=n.y,s=n.z;this._dir.set(t,i,s),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),Uy&&(zc.DrawSphere(n,.01,8925952,.5,!0),zc.DrawDirection(n,this._dir,8925952,.5,!0)),this._dir}randomizePosition(n,e){if(e<=0)return;const t=Dg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,n.add(t)}randomizeDirection(n,e){if(e===0)return;const t=Dg._randomQuat,i=Dg._tempVec;i.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(i,e*Math.random()*Math.PI),n.applyQuaternion(t)}spherizeDirection(n,e){if(e===0)return;const t=Math.random()*Math.PI*2,i=Math.acos(1-Math.random()*2),s=Math.sin(i)*Math.cos(t),r=Math.sin(i)*Math.sin(t),o=Math.cos(i),a=new w(s,r,o);n.lerp(a,e)}randomSpherePoint(n,e,t,i,s){const r=Math.random(),o=Math.random(),a=2*Math.PI*r*(i/360),c=Math.acos(2*o-1),l=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=n.x+this.scale.x*(-l*Math.sin(c)*Math.cos(a)),d=n.y+this.scale.y*(l*Math.sin(c)*Math.sin(a)),f=n.z+this.scale.z*(l*Math.cos(c));s.x=u,s.y=d,s.z=f}randomCirclePoint(n,e,t,i,s){const r=Math.random(),o=2*Math.PI*r*(i/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,c=n.x+this.scale.x*a*Math.cos(o),l=n.y+this.scale.y*a*Math.sin(o),u=n.z;s.x=c,s.y=l,s.z=u}randomConePoint(n,e,t,i,s,r,o){let a=0,c=0;switch(r){case 0:a=Math.random(),c=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,c=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let l=2*Math.PI*a*(s/360);switch(r){case 2:case 1:l+=Math.PI+.5,l+=this._loopTime*Math.PI*2,l%=tt.toRadians(s);break}const u=Math.acos(2*c-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),i)*t,f=n.x+-d*Math.sin(u)*Math.cos(l),p=n.y+d*Math.sin(u)*Math.sin(l),g=n.z;o.x=f*this.scale.x,o.y=p*this.scale.y,o.z=g*this.scale.z}},h(s0,"_randomQuat",new we),h(s0,"_tempVec",new w),s0);let bn=Dg;se([x()],bn.prototype,"shapeType",2);se([x()],bn.prototype,"enabled",2);se([x()],bn.prototype,"alignToDirection",2);se([x()],bn.prototype,"angle",2);se([x()],bn.prototype,"arc",2);se([x()],bn.prototype,"arcSpread",2);se([x()],bn.prototype,"arcSpeedMultiplier",2);se([x()],bn.prototype,"arcMode",2);se([x(w)],bn.prototype,"boxThickness",2);se([x(w)],bn.prototype,"position",2);se([x(w)],bn.prototype,"rotation",2);se([x(w)],bn.prototype,"scale",2);se([x()],bn.prototype,"radius",2);se([x()],bn.prototype,"radiusThickness",2);se([x()],bn.prototype,"sphericalDirectionAmount",2);se([x()],bn.prototype,"randomDirectionAmount",2);se([x()],bn.prototype,"randomPositionAmount",2);class vi{constructor(){h(this,"damping");h(this,"enabled");h(this,"frequency");h(this,"octaveCount");h(this,"octaveMultiplier");h(this,"octaveScale");h(this,"positionAmount");h(this,"quality");h(this,"remap");h(this,"remapEnabled");h(this,"remapMultiplier");h(this,"remapX");h(this,"remapXMultiplier");h(this,"remapY");h(this,"remapYMultiplier");h(this,"remapZ");h(this,"remapZMultiplier");h(this,"scrollSpeedMultiplier");h(this,"separateAxes");h(this,"strengthMultiplier");h(this,"strengthX");h(this,"strengthXMultiplier");h(this,"strengthY");h(this,"strengthYMultiplier");h(this,"strengthZ");h(this,"strengthZMultiplier");h(this,"_noise");h(this,"_time",0);h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,i,s,r,o){if(!this.enabled)return;this._noise||(this._noise=nne(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),c=this._noise(a.x,a.y,a.z,this._time),l=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(c,l,u).normalize();const d=r/o;let f=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=f*this.strengthXMultiplier,this._temp.y*=f*this.strengthYMultiplier,this._temp.z*=f*this.strengthZMultiplier):(this.strengthX&&(f*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(f)),i.x+=this._temp.x,i.y+=this._temp.y,i.z+=this._temp.z}}se([x()],vi.prototype,"damping",2);se([x()],vi.prototype,"enabled",2);se([x()],vi.prototype,"frequency",2);se([x()],vi.prototype,"octaveCount",2);se([x()],vi.prototype,"octaveMultiplier",2);se([x()],vi.prototype,"octaveScale",2);se([x(ht)],vi.prototype,"positionAmount",2);se([x()],vi.prototype,"quality",2);se([x(ht)],vi.prototype,"remap",2);se([x()],vi.prototype,"remapEnabled",2);se([x()],vi.prototype,"remapMultiplier",2);se([x(ht)],vi.prototype,"remapX",2);se([x()],vi.prototype,"remapXMultiplier",2);se([x(ht)],vi.prototype,"remapY",2);se([x()],vi.prototype,"remapYMultiplier",2);se([x(ht)],vi.prototype,"remapZ",2);se([x()],vi.prototype,"remapZMultiplier",2);se([x()],vi.prototype,"scrollSpeedMultiplier",2);se([x()],vi.prototype,"separateAxes",2);se([x()],vi.prototype,"strengthMultiplier",2);se([x(ht)],vi.prototype,"strengthX",2);se([x()],vi.prototype,"strengthXMultiplier",2);se([x(ht)],vi.prototype,"strengthY",2);se([x()],vi.prototype,"strengthYMultiplier",2);se([x(ht)],vi.prototype,"strengthZ",2);se([x()],vi.prototype,"strengthZMultiplier",2);class ji{constructor(){h(this,"enabled");h(this,"attachRibbonToTransform",!1);h(this,"colorOverLifetime");h(this,"colorOverTrail");h(this,"dieWithParticles",!0);h(this,"inheritParticleColor",!0);h(this,"lifetime");h(this,"lifetimeMultiplier");h(this,"minVertexDistance",.2);h(this,"mode",0);h(this,"ratio",1);h(this,"ribbonCount",1);h(this,"shadowBias",0);h(this,"sizeAffectsLifetime",!1);h(this,"sizeAffectsWidth",!1);h(this,"splitSubEmitterRibbons",!1);h(this,"textureMode",0);h(this,"widthOverTrail");h(this,"widthOverTrailMultiplier");h(this,"worldSpace",!1)}getWidth(e,t,i,s){const r=this.widthOverTrail.evaluate(i,s);return e*=r,e}getColor(e,t,i){const s=this.colorOverTrail.evaluate(i),r=this.colorOverLifetime.evaluate(t);e.x*=s.r*r.r,e.y*=s.g*r.g,e.z*=s.b*r.b,e.w*=s.alpha*r.alpha}}se([x()],ji.prototype,"enabled",2);se([x()],ji.prototype,"attachRibbonToTransform",2);se([x(Ir)],ji.prototype,"colorOverLifetime",2);se([x(Ir)],ji.prototype,"colorOverTrail",2);se([x()],ji.prototype,"dieWithParticles",2);se([x()],ji.prototype,"inheritParticleColor",2);se([x(ht)],ji.prototype,"lifetime",2);se([x()],ji.prototype,"lifetimeMultiplier",2);se([x()],ji.prototype,"minVertexDistance",2);se([x()],ji.prototype,"mode",2);se([x()],ji.prototype,"ratio",2);se([x()],ji.prototype,"ribbonCount",2);se([x()],ji.prototype,"shadowBias",2);se([x()],ji.prototype,"sizeAffectsLifetime",2);se([x()],ji.prototype,"sizeAffectsWidth",2);se([x()],ji.prototype,"splitSubEmitterRibbons",2);se([x()],ji.prototype,"textureMode",2);se([x(ht)],ji.prototype,"widthOverTrail",2);se([x()],ji.prototype,"widthOverTrailMultiplier",2);se([x()],ji.prototype,"worldSpace",2);class Zi{constructor(){h(this,"enabled");h(this,"space",0);h(this,"orbitalX");h(this,"orbitalY");h(this,"orbitalZ");h(this,"orbitalXMultiplier");h(this,"orbitalYMultiplier");h(this,"orbitalZMultiplier");h(this,"orbitalOffsetX");h(this,"orbitalOffsetY");h(this,"orbitalOffsetZ");h(this,"speedModifier");h(this,"speedModifierMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier");h(this,"_system");h(this,"_temp",new w);h(this,"_temp2",new w);h(this,"_temp3",new w);h(this,"_hasOrbital",!1);h(this,"_index",0);h(this,"_orbitalMatrix",new Me)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,i,s,r,o,a){var p;if(!this.enabled)return;const c=o/a,l=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,u=this.x.evaluate(c),d=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-u,d,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((p=this._system)==null?void 0:p.worldPos)){const A=this._temp2.set(i.x,i.y,i.z),v=this.orbitalXMultiplier,m=this.orbitalYMultiplier,b=this.orbitalZMultiplier,y=l*Math.PI*2*10,_=Math.cos(y*v),C=Math.sin(y*v),M=Math.cos(y*m),I=Math.sin(y*m),R=Math.cos(y*b),E=Math.sin(y*b),T=A.x*(M*R)+A.y*(M*E)+A.z*-I,D=A.x*(C*I*R-_*E)+A.y*(C*I*E+_*R)+A.z*(C*M),K=A.x*(_*I*R+C*E)+A.y*(_*I*E-C*R)+A.z*(_*M),H=this._temp3.set(A.x-T,A.y-D,A.z-K);H.normalize(),H.multiplyScalar(.2/r*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),s.x+=H.x,s.y+=H.y,s.z+=H.z}s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z,s.x*=l,s.y*=l,s.z*=l}}se([x()],Zi.prototype,"enabled",2);se([x()],Zi.prototype,"space",2);se([x(ht)],Zi.prototype,"orbitalX",2);se([x(ht)],Zi.prototype,"orbitalY",2);se([x(ht)],Zi.prototype,"orbitalZ",2);se([x()],Zi.prototype,"orbitalXMultiplier",2);se([x()],Zi.prototype,"orbitalYMultiplier",2);se([x()],Zi.prototype,"orbitalZMultiplier",2);se([x()],Zi.prototype,"orbitalOffsetX",2);se([x()],Zi.prototype,"orbitalOffsetY",2);se([x()],Zi.prototype,"orbitalOffsetZ",2);se([x(ht)],Zi.prototype,"speedModifier",2);se([x()],Zi.prototype,"speedModifierMultiplier",2);se([x(ht)],Zi.prototype,"x",2);se([x()],Zi.prototype,"xMultiplier",2);se([x(ht)],Zi.prototype,"y",2);se([x()],Zi.prototype,"yMultiplier",2);se([x(ht)],Zi.prototype,"z",2);se([x()],Zi.prototype,"zMultiplier",2);class _s{constructor(){h(this,"animation");h(this,"enabled");h(this,"cycleCount");h(this,"frameOverTime");h(this,"frameOverTimeMultiplier");h(this,"numTilesX");h(this,"numTilesY");h(this,"startFrame");h(this,"startFrameMultiplier");h(this,"rowMode");h(this,"rowIndex");h(this,"spriteCount");h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let i=this.frameOverTime.evaluate(e%1);return i*=this.frameOverTimeMultiplier,i*=t,i=i%t,i=Math.floor(i),i}}se([x()],_s.prototype,"animation",2);se([x()],_s.prototype,"enabled",2);se([x()],_s.prototype,"cycleCount",2);se([x(ht)],_s.prototype,"frameOverTime",2);se([x()],_s.prototype,"frameOverTimeMultiplier",2);se([x()],_s.prototype,"numTilesX",2);se([x()],_s.prototype,"numTilesY",2);se([x(ht)],_s.prototype,"startFrame",2);se([x()],_s.prototype,"startFrameMultiplier",2);se([x()],_s.prototype,"rowMode",2);se([x()],_s.prototype,"rowIndex",2);se([x()],_s.prototype,"spriteCount",2);se([x()],_s.prototype,"timeMode",2);class zo{constructor(){h(this,"enabled");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}se([x()],zo.prototype,"enabled",2);se([x()],zo.prototype,"separateAxes",2);se([x(ht)],zo.prototype,"x",2);se([x()],zo.prototype,"xMultiplier",2);se([x(ht)],zo.prototype,"y",2);se([x()],zo.prototype,"yMultiplier",2);se([x(ht)],zo.prototype,"z",2);se([x()],zo.prototype,"zMultiplier",2);class so{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const i=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(i)*-1}return 0}}se([x()],so.prototype,"enabled",2);se([x()],so.prototype,"range",2);se([x()],so.prototype,"separateAxes",2);se([x(ht)],so.prototype,"x",2);se([x()],so.prototype,"xMultiplier",2);se([x(ht)],so.prototype,"y",2);se([x()],so.prototype,"yMultiplier",2);se([x(ht)],so.prototype,"z",2);se([x()],so.prototype,"zMultiplier",2);class Bn{constructor(){h(this,"enabled");h(this,"dampen");h(this,"drag");h(this,"dragMultiplier");h(this,"limit");h(this,"limitMultiplier");h(this,"separateAxes");h(this,"limitX");h(this,"limitXMultiplier");h(this,"limitY");h(this,"limitYMultiplier");h(this,"limitZ");h(this,"limitZMultiplier");h(this,"multiplyDragByParticleSize",!1);h(this,"multiplyDragByParticleVelocity",!1);h(this,"space");h(this,"_temp",new w);h(this,"_temp2",new w)}apply(e,t,i,s,r,o,a){if(this.enabled){const c=this.limit.evaluate(r)*this.limitMultiplier;if(t.length()>c){this._temp.copy(t).normalize().multiplyScalar(c);const u=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,u),t.y=tt.lerp(t.y,this._temp.y,u),t.z=tt.lerp(t.z,this._temp.z,u),i.x=tt.lerp(i.x,this._temp.x,u),i.y=tt.lerp(i.y,this._temp.y,u),i.z=tt.lerp(i.z,this._temp.z,u)}}}}se([x()],Bn.prototype,"enabled",2);se([x()],Bn.prototype,"dampen",2);se([x(ht)],Bn.prototype,"drag",2);se([x()],Bn.prototype,"dragMultiplier",2);se([x(ht)],Bn.prototype,"limit",2);se([x()],Bn.prototype,"limitMultiplier",2);se([x()],Bn.prototype,"separateAxes",2);se([x(ht)],Bn.prototype,"limitX",2);se([x()],Bn.prototype,"limitXMultiplier",2);se([x(ht)],Bn.prototype,"limitY",2);se([x()],Bn.prototype,"limitYMultiplier",2);se([x(ht)],Bn.prototype,"limitZ",2);se([x()],Bn.prototype,"limitZMultiplier",2);se([x()],Bn.prototype,"multiplyDragByParticleSize",2);se([x()],Bn.prototype,"multiplyDragByParticleVelocity",2);se([x()],Bn.prototype,"space",2);class Mh{constructor(){h(this,"enabled");h(this,"curve");h(this,"curveMultiplier");h(this,"mode");h(this,"system");h(this,"_lastWorldPosition");h(this,"_velocity",new w);h(this,"_temp",new w)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,i){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const s=this.curve.evaluate(t,i);this._temp.copy(this._velocity).multiplyScalar(s),e.add(this._temp)}}}se([x()],Mh.prototype,"enabled",2);se([x(ht)],Mh.prototype,"curve",2);se([x()],Mh.prototype,"curveMultiplier",2);se([x()],Mh.prototype,"mode",2);class lr{constructor(){h(this,"enabled");h(this,"range");h(this,"separateAxes");h(this,"size");h(this,"sizeMultiplier");h(this,"x");h(this,"xMultiplier");h(this,"y");h(this,"yMultiplier");h(this,"z");h(this,"zMultiplier")}evaluate(e,t,i,s){const r=e.length(),o=tt.remap(r,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,i);return s*a}}se([x()],lr.prototype,"enabled",2);se([x(te)],lr.prototype,"range",2);se([x()],lr.prototype,"separateAxes",2);se([x(ht)],lr.prototype,"size",2);se([x()],lr.prototype,"sizeMultiplier",2);se([x(ht)],lr.prototype,"x",2);se([x()],lr.prototype,"xMultiplier",2);se([x(ht)],lr.prototype,"y",2);se([x()],lr.prototype,"yMultiplier",2);se([x(ht)],lr.prototype,"z",2);se([x()],lr.prototype,"zMultiplier",2);class Yu{constructor(){h(this,"enabled");h(this,"range");h(this,"color")}evaluate(e,t,i){const s=e.length(),r=tt.remap(s,this.range.x,this.range.y,0,1),o=this.color.evaluate(r,t);i.x*=o.r,i.y*=o.g,i.z*=o.b,i.w*=o.alpha}}se([x()],Yu.prototype,"enabled",2);se([x(te)],Yu.prototype,"range",2);se([x(Ir)],Yu.prototype,"color",2);function xO(n){const e=n.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const i=document.createElement("button");i.id="open-in-ar",i.innerText="Open in QuickLook",t.appendChild(i);const s=document.createElement("a");s.id="needle-usdz-link",s.style.display="none",s.rel="ar",s.href="",t.appendChild(s);const r=document.createElement("img");return r.id="button",s.appendChild(r),n.domElement.shadowRoot.appendChild(t),s}function ane(){var n=new Date;const e=n.getMonth()+1,t=n.getDate(),i=n.getHours(),s=n.getMinutes(),r=n.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,c=(i<10?"0":"")+i,l=(s<10?"0":"")+s,u=(r<10?"0":"")+r;return n.getFullYear()+o+a+"-"+c+l+u}const Ny=re("debugusdz");function cne(n,e){const t=[],i=ne.getComponentsInChildren(n,ks),s=ne.getComponentsInChildren(n,$r);let r=!1;const o=new tr("rest",.01,[]),a=new Map,c=(l,u)=>{if(!r&&u.tracks.length>0&&(r=!0,l.push(o)),u.tracks.length>0)for(const d of u.tracks){const f=Nt.parseTrackName(d.name),p=Nt.findNode(n,f.nodeName);if(p){a.has(p)||a.set(p,[]);const g=a.get(p);switch(f.propertyName){case"position":{if(g.includes("position"))continue;const A=p.position,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("position"),o.tracks.push(v);break}case"quaternion":{if(g.includes("quaternion"))continue;const A=p.quaternion,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);g.push("quaternion"),o.tracks.push(v);break}case"scale":{if(g.includes("scale"))continue;const A=p.scale,v=new wr(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);g.push("scale"),o.tracks.push(v);break}}}}};for(const l of i){if(!l||!l.runtimeAnimatorController)continue;Ny&&console.log(l);const u=[];for(const d of l.runtimeAnimatorController.enumerateActions()){Ny&&console.log(d);const f=d.getClip();c(u,f),u.includes(f)||u.push(f)}t.push({root:l.gameObject,clips:u})}for(const l of s){Ny&&console.log(l);const u=[];for(const d of l.animations)c(u,d),u.includes(d)||u.push(d);t.push({root:l.gameObject,clips:u})}Ny&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const l of t)for(const u of l.clips)e.registerAnimation(l.root,u)}class lne{static createButton(e,t={},i){const s=document.createElement("button");let r=!1;function o(){if(t.optionalFeatures=t.optionalFeatures||[],t.domOverlay===void 0){var u=document.createElement("div");u.style.display="none",document.body.appendChild(u);var d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("width",38),d.setAttribute("height",38),d.style.position="absolute",d.style.right="20px",d.style.top="20px",d.addEventListener("click",function(){p.end()}),u.appendChild(d);var f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttribute("d","M 12,12 L 28,28 M 28,12 12,28"),f.setAttribute("stroke","#fff"),f.setAttribute("stroke-width",2),d.appendChild(f),t.optionalFeatures.push("dom-overlay"),t.domOverlay={root:u},r=!0}let p=null,g=null;async function A(m){var _;const b=/WebXRViewer\//i.test(navigator.userAgent),y=t.domOverlay.root;b&&((_=t.domOverlay)!=null&&_.root?(g=y.parentNode,g&&(console.log("Reparent DOM Overlay to body",y,y.style.display),y.style.display="",y.style.visibility="",document.body.appendChild(y))):console.warn("WebXRViewer: No DOM Overlay found")),m.addEventListener("end",v),await e.xr.setSession(m),s.textContent="STOP AR",r&&(t.domOverlay.root.style.display=""),p=m}function v(){p.removeEventListener("end",v),s.textContent="START AR";const m=t.domOverlay.root;g&&g.appendChild(m),r&&(m.style.display="none"),p=null}s.style.display="",s.style.cursor="pointer",s.style.left="calc(50% - 50px)",s.style.width="100px",s.textContent="START AR",s.onmouseenter=function(){s.style.opacity="1.0"},s.onmouseleave=function(){s.style.opacity="0.5"},s.onclick=function(){p===null?(i==null||i.call(this,t),navigator.xr.requestSession("immersive-ar",t).then(A)):p.end()}}function a(){s.disabled=!0,s.style.display="",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function c(){a(),s.textContent="AR NOT SUPPORTED"}function l(u){u.style.position="absolute",u.style.bottom="20px",u.style.padding="12px 6px",u.style.border="1px solid #fff",u.style.borderRadius="4px",u.style.background="rgba(0,0,0,0.1)",u.style.color="#fff",u.style.font="normal 13px sans-serif",u.style.textAlign="center",u.style.opacity="0.5",u.style.outline="none",u.style.zIndex="999"}if("xr"in navigator)return s.id="ARButton",s.style.display="none",l(s),navigator.xr.isSessionSupported("immersive-ar").then(function(u){u?o():c()}).catch(c),s;{const u=document.createElement("a");return window.isSecureContext===!1?(u.href=document.location.href.replace(/^http:/,"https:"),u.innerHTML="WEBXR NEEDS HTTPS"):(u.href="https://immersiveweb.dev/",u.innerHTML="WEBXR NOT AVAILABLE"),u.style.left="calc(50% - 90px)",u.style.width="180px",u.style.textDecoration="none",l(u),u}}}const Gb=class{static createButton(e,t){const i=document.createElement("button");function s(){let c=null;async function l(d){d.addEventListener("end",u),await e.xr.setSession(d),i.textContent="EXIT VR",c=d}function u(){c.removeEventListener("end",u),i.textContent="ENTER VR",c=null}i.style.display="",i.style.cursor="pointer",i.style.left="calc(50% - 50px)",i.style.width="100px",i.textContent="ENTER VR",i.onmouseenter=function(){i.style.opacity="1.0"},i.onmouseleave=function(){i.style.opacity="0.5"},i.onclick=function(){if(c===null){const d={optionalFeatures:t.optionalFeatures};navigator.xr.requestSession("immersive-vr",d).then(l)}else c.end()}}function r(){i.disabled=!0,i.style.display="",i.style.cursor="auto",i.style.left="calc(50% - 75px)",i.style.width="150px",i.onmouseenter=null,i.onmouseleave=null,i.onclick=null}function o(){r(),i.textContent="VR NOT SUPPORTED"}function a(c){c.style.position="absolute",c.style.bottom="20px",c.style.padding="12px 6px",c.style.border="1px solid #fff",c.style.borderRadius="4px",c.style.background="rgba(0,0,0,0.1)",c.style.color="#fff",c.style.font="normal 13px sans-serif",c.style.textAlign="center",c.style.opacity="0.5",c.style.outline="none",c.style.zIndex="999"}if("xr"in navigator)return i.id="VRButton",i.style.display="none",a(i),navigator.xr.isSessionSupported("immersive-vr").then(function(c){c?s():o(),Gb.xrSessionIsGranted&&(console.log("XR session is granted - will enter immersive web now"),i.click())}),i;{const c=document.createElement("a");return window.isSecureContext===!1?(c.href=document.location.href.replace(/^http:/,"https:"),c.innerHTML="WEBXR NEEDS HTTPS"):(c.href="https://immersiveweb.dev/",c.innerHTML="WEBXR NOT AVAILABLE"),c.style.left="calc(50% - 90px)",c.style.width="180px",c.style.textDecoration="none",a(c),c}}static registerSessionGrantedListener(){if("xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{Gb.xrSessionIsGranted=!0})}}};let rm=Gb;h(rm,"xrSessionIsGranted",!1);rm.registerSessionGrantedListener();var hne=Object.defineProperty,une=Object.getOwnPropertyDescriptor,CI=(n,e,t,i)=>{for(var s=i>1?void 0:i?une(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&hne(e,t,s),s};const dne=new Me;class ca extends Ie{constructor(){super(...arguments);h(this,"webAR",null);h(this,"invertForward",!1);h(this,"arTouchTransform",!1);h(this,"_initalMatrix",new Me);h(this,"_selectStartFn",this.onSelectStart.bind(this));h(this,"_selectEndFn",this.onSelectEnd.bind(this));h(this,"userInput");h(this,"_arScale",1);h(this,"_rig",null);h(this,"_startPose",null);h(this,"_placementPose",null);h(this,"_isTouching",!1);h(this,"_rigStartPose",null);h(this,"_gotFirstHitTestResult",!1);h(this,"_anchor",null);h(this,"_anchorMatrix",new Me);h(this,"_invertedSessionRootMatrix",new Me);h(this,"_invertForwardMatrix",new Me().makeRotationY(Math.PI))}get rig(){var t;return(t=this.webAR)==null?void 0:t.webxr.Rig}get arScale(){return this._arScale}set arScale(t){t!==this._arScale&&(this._arScale=t,this.setScale(t))}start(){const t=ne.findObjectOfType(It);t&&(t.Rig.updateMatrix(),this._initalMatrix.copy(t.Rig.matrix))}onBegin(t){var i;this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._startPose=this.gameObject.matrix.clone(),this._rigStartPose=(i=this.rig)==null?void 0:i.matrix.clone(),this._gotFirstHitTestResult=!1,this._anchor=null,t.addEventListener("selectstart",this._selectStartFn),t.addEventListener("selectend",this._selectEndFn),this.gameObject.visible=!1,this.rig&&(this.rig.matrixAutoUpdate=!0,this._initalMatrix.decompose(this.rig.position,this.rig.quaternion,this.rig.scale)),this.dispatchEvent(new CustomEvent("onBeginSession"))}onUpdate(t,i,s,r){if(r&&!this._placementPose&&(this._gotFirstHitTestResult||(this._gotFirstHitTestResult=!0,this.dispatchEvent(new CustomEvent("canPlaceSession",{detail:{pose:r}}))),this._isTouching)){const o=new Me().fromArray(r.transform.matrix).invert();return this.dispatchEvent(new CustomEvent("placedSession",{detail:{pose:r,poseMatrix:o}})),this.webAR&&this.webAR.setReticleActive(!1),this.placeAt(t,o),s&&r&&this.onCreatePlacementAnchor(s,r),!0}return!1}onCreatePlacementAnchor(t,i){var s,r;this._anchor=null,(r=(s=t==null?void 0:t.createAnchor)==null?void 0:s.call(t,i.transform))==null||r.then(o=>{this.context.isInAR&&(this._anchor=o)})}onBeforeRender(t){if(t&&this._rig)if(this._anchor){const i=this.context.renderer.xr.getReferenceSpace();if(i){const s=t.getPose(this._anchor.anchorSpace,i);if(s){const r=this._anchorMatrix.fromArray(s.transform.matrix).invert();this.placeAt(this._rig,r);return}}}else this._placementPose&&this.placeAt(this._rig,this._placementPose)}placeAt(t,i){this._placementPose||(this._placementPose=new Me),this._placementPose.copy(i);const s=this._invertedSessionRootMatrix.copy(this.gameObject.matrixWorld).invert();this._placementPose.premultiply(s),t?(this.invertForward&&this._placementPose.premultiply(this._invertForwardMatrix),this.userInput||(this.userInput=new $d(this.context)),this.userInput.enable(),this._rig=t,this.setScale(this.arScale)):this._rig=null,this.gameObject.visible=!0}onEnd(t,i){var s,r;(s=this.userInput)==null||s.disable(),(r=this.userInput)==null||r.reset(),this._placementPose=null,this.gameObject.visible=!1,this.gameObject.matrixAutoUpdate=!1,this._anchor=null,this._startPose&&this.gameObject.matrix.copy(this._startPose),t&&(t.matrixAutoUpdate=!0,this._rigStartPose&&this._rigStartPose.decompose(t.position,t.quaternion,t.scale)),Sr.markDirty(this.gameObject,!0),setTimeout(()=>{this.gameObject&&(this.gameObject.matrixAutoUpdate=!0,this.gameObject.visible=!0)},100)}onSelectStart(){this._isTouching=!0}onSelectEnd(){this._isTouching=!1}setScale(t){const i=this._rig;!i||!this._placementPose||(this._rigStartPose||(this._rigStartPose=i.matrix.clone()),i.matrixAutoUpdate=!1,this.arTouchTransform&&this.userInput&&this.userInput.applyMatrixTo(this._placementPose),i.matrix.multiplyMatrices(dne.makeScale(t,t,t),this._placementPose),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld())}}CI([x()],ca.prototype,"invertForward",2);CI([x()],ca.prototype,"arTouchTransform",2);CI([x()],ca.prototype,"arScale",1);const Hb=class{constructor(e){h(this,"oneFingerDrag",!0);h(this,"twoFingerRotate",!0);h(this,"twoFingerScale",!0);h(this,"context");h(this,"offset");h(this,"plane");h(this,"_scale",1);h(this,"_enabled",!1);h(this,"prev",new Map);h(this,"_didMultitouch",!1);h(this,"touchStart",e=>{for(let t=0;t<e.changedTouches.length;t++){const i=e.changedTouches[t];this.prev.has(i.identifier)||this.prev.set(i.identifier,{x:0,z:0,screenx:0,screeny:0});const s=this.prev.get(i.identifier);if(s){const r=this.getPositionOnPlane(i.clientX,i.clientY);s.x=r.x,s.z=r.z,s.screenx=i.clientX,s.screeny=i.clientY}}});h(this,"touchEnd",e=>{e.touches.length<=0&&(this._didMultitouch=!1)});h(this,"touchMove",e=>{if(!e.defaultPrevented){if(e.touches.length===1){if(this._didMultitouch)return;const t=e.touches[0],i=this.prev.get(t.identifier);if(!i)return;const s=this.getPositionOnPlane(t.clientX,t.clientY),r=s.x-i.x,o=s.z-i.z;if(r===0&&o===0)return;this.oneFingerDrag&&this.addMovement(r,o),i.x=s.x,i.z=s.z,i.screenx=t.clientX,i.screeny=t.clientY;return}else if(e.touches.length===2){this._didMultitouch=!0;const t=e.touches[0],i=e.touches[1],s=this.prev.get(t.identifier),r=this.prev.get(i.identifier);if(!s||!r)return;if(this.twoFingerRotate){const o=Math.atan2(t.clientY-i.clientY,t.clientX-i.clientX),a=Math.atan2(s.screeny-r.screeny,s.screenx-r.screenx),c=o-a;Math.abs(c)>.001&&this.addRotation(c)}if(this.twoFingerScale){const o=t.clientX-i.clientX,a=t.clientY-i.clientY,c=Math.sqrt(o*o+a*a),l=s.screenx-r.screenx,u=s.screeny-r.screeny,d=Math.sqrt(l*l+u*u),f=c-d;Math.abs(f)>2&&this.addScale(f)}s.screenx=t.clientX,s.screeny=t.clientY,r.screenx=i.clientX,r.screeny=i.clientY}}});h(this,"_raycaster",new Uu);h(this,"_intersection",new w);h(this,"_screenPos",new w);h(this,"_tempMatrix",new Me);this.context=e,this.offset=new Me,this.plane=new Qr,this.plane.setFromNormalAndCoplanarPoint(Hb.up,Hb.zero)}enable(){this._enabled||(this._enabled=!0,window.addEventListener("touchstart",this.touchStart,{passive:!1}),window.addEventListener("touchmove",this.touchMove,{passive:!1}),window.addEventListener("touchend",this.touchEnd,{passive:!1}))}disable(){this._enabled&&(this._enabled=!1,window.removeEventListener("touchstart",this.touchStart),window.removeEventListener("touchmove",this.touchMove),window.removeEventListener("touchend",this.touchEnd))}reset(){this._scale=1,this.offset.identity()}applyMatrixTo(e){e.premultiply(this.offset)}getPositionOnPlane(e,t){const i=this.context.mainCamera;return this._screenPos.x=e/window.innerWidth*2-1,this._screenPos.y=-(t/window.innerHeight)*2+1,this._screenPos.z=1,this._screenPos.unproject(i),this._raycaster.set(i.position,this._screenPos.sub(i.position)),this._raycaster.ray.intersectPlane(this.plane,this._intersection),this._intersection}addMovement(e,t){e*=.75,t*=.75,e/=this._scale,t/=this._scale,this.offset.elements[12]-=e,this.offset.elements[14]-=t}addScale(e){e/=window.innerWidth,this._scale*=1+e,this._tempMatrix.makeScale(1-e,1-e,1-e),this.offset.premultiply(this._tempMatrix)}addRotation(e){this._tempMatrix.makeRotationY(e),this.offset.premultiply(this._tempMatrix)}};let $d=Hb;h($d,"up",new w(0,1,0)),h($d,"zero",new w(0,0,0)),h($d,"one",new w(1,1,1));const fne=re("debugrig");class Ix extends Ie{awake(){if(fne){const e=new Te;e.position.y+=.5,this.gameObject.add(e);const t=e.addNewComponent(Qu);t&&(t.isGizmo=!1)}}}class Mf{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}x(){return this.bb.readFloat32(this.bb_pos)}y(){return this.bb.readFloat32(this.bb_pos+4)}z(){return this.bb.readFloat32(this.bb_pos+8)}w(){return this.bb.readFloat32(this.bb_pos+12)}static sizeOf(){return 16}static createVec4(e,t,i,s,r){return e.prep(4,16),e.writeFloat32(r),e.writeFloat32(s),e.writeFloat32(i),e.writeFloat32(t),e.offset()}}class Ms{constructor(){h(this,"bb",null);h(this,"bb_pos",0)}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsVrUserStateBuffer(e,t){return(t||new Ms).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsVrUserStateBuffer(e,t){return e.setPosition(e.position()+L_),(t||new Ms).__init(e.readInt32(e.position())+e.position(),e)}guid(e){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}time(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}avatarId(e){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}position(e){const t=this.bb.__offset(this.bb_pos,10);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}rotation(e){const t=this.bb.__offset(this.bb_pos,12);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}scale(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readFloat32(this.bb_pos+e):0}posLeftHand(e){const t=this.bb.__offset(this.bb_pos,16);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}posRightHand(e){const t=this.bb.__offset(this.bb_pos,18);return t?(e||new Zr).__init(this.bb_pos+t,this.bb):null}rotLeftHand(e){const t=this.bb.__offset(this.bb_pos,20);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}rotRightHand(e){const t=this.bb.__offset(this.bb_pos,22);return t?(e||new Mf).__init(this.bb_pos+t,this.bb):null}static startVrUserStateBuffer(e){e.startObject(10)}static addGuid(e,t){e.addFieldOffset(0,t,0)}static addTime(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static addAvatarId(e,t){e.addFieldOffset(2,t,0)}static addPosition(e,t){e.addFieldStruct(3,t,0)}static addRotation(e,t){e.addFieldStruct(4,t,0)}static addScale(e,t){e.addFieldFloat32(5,t,0)}static addPosLeftHand(e,t){e.addFieldStruct(6,t,0)}static addPosRightHand(e,t){e.addFieldStruct(7,t,0)}static addRotLeftHand(e,t){e.addFieldStruct(8,t,0)}static addRotRightHand(e,t){e.addFieldStruct(9,t,0)}static endVrUserStateBuffer(e){return e.endObject()}static finishVrUserStateBufferBuffer(e,t){e.finish(t)}static finishSizePrefixedVrUserStateBufferBuffer(e,t){e.finish(t,void 0,!0)}}const wO=re("debugxr"),hg=re("debugavatar"),EI="VRUS";F_(EI,Ms.getRootAsVrUserStateBuffer);function pM(){return new Date().getTime()}function pne(n){const e=n&4294967295,t=n/Math.pow(2,32)&1048575;return Ga.create(e,t)}const Am=class{constructor(e){h(this,"guid");h(this,"time");h(this,"avatarId");h(this,"position",new w);h(this,"rotation",new et);h(this,"scale",1);h(this,"posLeftHand",new w);h(this,"posRightHand",new w);h(this,"rotLeftHand",new we);h(this,"rotRightHand",new we);this.guid=e}update(e,t,i,s,r){var u,d,f,p,g,A;this.time=pM(),this.avatarId=r,this.position.set(t.x,t.y,t.z),e&&this.position.applyMatrix4(e.matrixWorld);let o=Am.quat0;const a=Am.quat1;o.set(i.x,i.y,i.z,i.w),o=o.multiplyQuaternions(o,Am.invertRotation),e&&(e.getWorldQuaternion(a),o.multiplyQuaternions(a,o)),this.rotation.set(o.x,o.y,o.z,o.w),this.scale=e.scale.x;const c=(u=s.LeftController)==null?void 0:u.controllerGrip;c&&(c.getWorldPosition(this.posLeftHand),c.getWorldQuaternion(this.rotLeftHand));const l=(d=s.RightController)==null?void 0:d.controllerGrip;if(l&&(l.getWorldPosition(this.posRightHand),l.getWorldQuaternion(this.rotRightHand)),(p=(f=s.LeftController)==null?void 0:f.hand)!=null&&p.visible){const v=s.LeftController.wrist;v&&(v.getWorldPosition(this.posLeftHand),v.getWorldQuaternion(this.rotLeftHand))}if((A=(g=s.RightController)==null?void 0:g.hand)!=null&&A.visible){const v=s.RightController.wrist;v&&(v.getWorldPosition(this.posRightHand),v.getWorldQuaternion(this.rotRightHand))}}sendAsBuffer(e,t){e.clear();const i=e.createString(this.guid),s=e.createString(this.avatarId);Ms.startVrUserStateBuffer(e),Ms.addGuid(e,i),Ms.addTime(e,pne(this.time)),Ms.addAvatarId(e,s),Ms.addPosition(e,Zr.createVec3(e,this.position.x,this.position.y,this.position.z)),Ms.addRotation(e,Mf.createVec4(e,this.rotation.x,this.rotation.y,this.rotation.z,this.rotation.w)),Ms.addScale(e,this.scale),Ms.addPosLeftHand(e,Zr.createVec3(e,this.posLeftHand.x,this.posLeftHand.y,this.posLeftHand.z)),Ms.addPosRightHand(e,Zr.createVec3(e,this.posRightHand.x,this.posRightHand.y,this.posRightHand.z)),Ms.addRotLeftHand(e,Mf.createVec4(e,this.rotLeftHand.x,this.rotLeftHand.y,this.rotLeftHand.z,this.rotLeftHand.w)),Ms.addRotRightHand(e,Mf.createVec4(e,this.rotRightHand.x,this.rotRightHand.y,this.rotRightHand.z,this.rotRightHand.w));const r=Ms.endVrUserStateBuffer(e);e.finish(r,EI);const o=e.asUint8Array();t.sendBinary(o)}setFromBuffer(e,t){if(!e)return;this.guid=e,this.time=t.time().toFloat64();const i=t.avatarId();i&&(this.avatarId=i);const s=t.position();s&&this.position.set(s.x(),s.y(),s.z());const r=t.rotation();r&&this.rotation.set(r.x(),r.y(),r.z(),r.w());const o=t.posLeftHand();o&&this.posLeftHand.set(o.x(),o.y(),o.z());const a=t.posRightHand();a&&this.posRightHand.set(a.x(),a.y(),a.z());const c=t.rotLeftHand();c&&this.rotLeftHand.set(c.x(),c.y(),c.z(),c.w());const l=t.rotRightHand();l&&this.rotRightHand.set(l.x(),l.y(),l.z(),l.w()),this.scale=t.scale()}};let ta=Am;h(ta,"invertRotation",new we().setFromAxisAngle(new w(0,1,0),Math.PI)),h(ta,"quat0",new we),h(ta,"quat1",new we);class tA extends Ie{constructor(){super(...arguments);h(this,"webXR",null);h(this,"debugAvatarUser",null);h(this,"voip",null);h(this,"tempState",new ta(""));h(this,"_removeAvatarsList",[]);h(this,"eventSub_ConnectionEvent",null);h(this,"eventSub_WebXRStartEvent",null);h(this,"eventSub_WebXREndEvent",null);h(this,"eventSub_WebXRUpdateEvent",null);h(this,"avatars",{});h(this,"localAvatar",null);h(this,"k_LocalAvatarNoNetworkingGuid","local");h(this,"ownership",null);h(this,"xrState",null);h(this,"builder",new ip(1024))}async awake(){if(this.webXR||(this.webXR=ne.getComponent(this.gameObject,It)),this.webXR||(this.webXR=ne.findObjectOfType(It,this.context)),!this.webXR&&(this.webXR=ne.findObjectOfType(It,this.context),!this.webXR)){console.warn("WebXRSync: Could not find WebXR component, won't sync.");return}if(this.voip||(this.voip=ne.findObjectOfType(dl,this.context)),hg){const t="debug-avatar-"+hg,i=new Ua(this.context,t,this.webXR);if(this.debugAvatarUser=i,typeof hg=="string"&&hg.length>0)if(await i.setAvatarOverride(hg)){const s=new ta(t);s.position.y+=1;const r=.5;s.posLeftHand.y+=r,s.posLeftHand.x+=r,s.posRightHand.y+=r,s.posRightHand.x-=r,i.tryUpdate(s,0)}else i.destroy()}}onEnable(){if(!this.webXR&&(this.webXR=ne.getComponent(this.gameObject,It),!this.webXR)){console.warn("Missing webxr component on "+this.gameObject.name);return}this.eventSub_WebXRStartEvent=this.onXRSessionStart.bind(this),It.addEventListener(Mi.XRStarted,this.eventSub_WebXRStartEvent),this.eventSub_WebXRUpdateEvent=this.onXRSessionUpdate.bind(this),It.addEventListener(Mi.XRUpdate,this.eventSub_WebXRUpdateEvent),this.eventSub_WebXREndEvent=this.onXRSessionEnded.bind(this),It.addEventListener(Mi.XRStopped,this.eventSub_WebXREndEvent),this.eventSub_ConnectionEvent=this.onConnected.bind(this),this.context.connection.beginListen(on.JoinedRoom,this.eventSub_ConnectionEvent),this.context.connection.beginListen("webxr-user-joined",t=>{console.log("webxr user joined evt")}),this.context.connection.beginListen("webxr-user-left",t=>{const i=t.id!==null&&t.id!==void 0;if(i&&(console.log("webxr user left evt"),i)){const s=this.avatars[t.id];s==null||s.destroy(),this.avatars[t.id]=void 0}}),this.context.connection.beginListenBinary(EI,t=>{const i=t.guid();if(!i)return;const s=t.time().toFloat64(),r=this.tempState;r.setFromBuffer(i,t);const o=this.onTryGetAvatar(i,s);o==null||o.tryUpdate(r,s)}),this.context.connection.beginListen("vr-session-update",t=>{const i=t.guid,s=t.time,r=this.onTryGetAvatar(i,s);r==null||r.tryUpdate(t,s)})}onTryGetAvatar(t,i){if(t===this.context.connection.connectionId)return null;const s=new Date().getTime()-i;if(s>5e3)return wO&&console.log("old data",s,t),null;if(!this.webXR)return null;let r=this.avatars[t];if(r===void 0)try{console.log("create new avatar");const o=new Ua(this.context,t,this.webXR);r=o,this.avatars[t]=o}catch(o){this.avatars[t]=null,console.error(o)}return r}onDisable(){this.eventSub_ConnectionEvent&&this.context.connection.stopListen(on.JoinedRoom,this.eventSub_ConnectionEvent),It.removeEventListener(Mi.XRStarted,this.eventSub_WebXRStartEvent),It.removeEventListener(Mi.XRUpdate,this.eventSub_WebXRUpdateEvent),It.removeEventListener(Mi.XRStopped,this.eventSub_WebXREndEvent)}update(){const t=pM();this.debugAvatarUser&&(this.debugAvatarUser.lastUpdate=t),this.detectPotentiallyDisconnectedAvatarsAndRemove();for(const i in this.avatars){const s=this.avatars[i];s&&s.update()}}detectPotentiallyDisconnectedAvatarsAndRemove(){const t=pM();for(const i in this.avatars){const s=this.avatars[i];if(!s){this._removeAvatarsList.push(i);continue}t-s.lastUpdate>1e4&&(console.log("avatar timed out (didnt receive any updates in a while) - destroying it now"),s.destroy(),this.avatars[i]=void 0)}for(const i of this._removeAvatarsList)delete this.avatars[i];this._removeAvatarsList.length=0}buildLocalAvatar(){var i;if(this.localAvatar)return;const t=((i=this.context.connection)==null?void 0:i.connectionId)??this.k_LocalAvatarNoNetworkingGuid;this.localAvatar=new Ua(this.context,t,this.webXR),this.localAvatar.isLocalAvatar=!0,this.localAvatar.setAvatarOverride(this.getAvatarId()),this.avatars[this.localAvatar.guid]=this.localAvatar}onConnected(){var t,i,s;wO&&console.log("Hey you are connected as "+this.context.connection.connectionId),((t=this.localAvatar)==null?void 0:t.guid)===this.k_LocalAvatarNoNetworkingGuid&&(this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0),this.localAvatar=null,this.xrState=null,(s=this.ownership)==null||s.freeOwnership(),this.ownership=null)}onXRSessionStart(t){var i,s,r;if(console.log("XR session started"),this.context.connection.send("webxr-user-joined",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null),this.xrState=null,(s=this.ownership)==null||s.freeOwnership(),this.ownership=null,this.avatars)for(const o in this.avatars)(r=this.avatars[o])==null||r.updateFlags()}onXRSessionEnded(t){var i;console.log("XR session ended"),this.context.connection.send("webxr-user-left",{id:this.context.connection.connectionId,mode:"vr"}),this.localAvatar&&((i=this.localAvatar)==null||i.destroy(),this.avatars[this.localAvatar.guid]=void 0,this.localAvatar=null)}onXRSessionUpdate(t){this.xrState??(this.xrState=new ta(this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid)),this.ownership??(this.ownership=new N_(this.context.connection,this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid)),this.ownership.guid=this.context.connection.connectionId??this.k_LocalAvatarNoNetworkingGuid,this.buildLocalAvatar();const{frame:i,xr:s,rig:r}=t,o=i.getViewerPose(s.getReferenceSpace());if(!o)return;const a=o==null?void 0:o.transform,c=a.position,l=a.orientation;this.xrState.update(r,c,l,this.webXR,this.getAvatarId()),this.localAvatar&&(this.context.connection.connectionId&&(this.localAvatar.guid=this.context.connection.connectionId),this.localAvatar.tryUpdate(this.xrState,0)),!(this.ownership&&!this.ownership.hasOwnership&&this.context.connection.isConnected&&(this.context.time.frameCount%120===0&&this.ownership.requestOwnership(),!this.ownership.hasOwnership))&&(!this.context.connection.isConnected||!this.context.connection.connectionId||this.xrState.sendAsBuffer(this.builder,this.context.connection))}getAvatarId(){return re("avatar")??null}}var gne=Object.defineProperty,mne=Object.getOwnPropertyDescriptor,Tp=(n,e,t,i)=>{for(var s=i>1?void 0:i?mne(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&gne(e,t,s),s};const jS=re("debugwebxr");async function jz(){return tb()?!0:"xr"in navigator?await navigator.xr.isSessionSupported("immersive-ar")===!0:!1}async function Xz(){return"xr"in navigator?await navigator.xr.isSessionSupported("immersive-vr")===!0:!1}let Og=!1,kg=!1;jz().then(n=>Og=n);Xz().then(n=>kg=n);var Mi=(n=>(n.XRStarted="xrStarted",n.XRStopped="xrStopped",n.XRUpdate="xrUpdate",n.RequestVRSession="requestVRSession",n.ModifyAROptions="modify-ar-options",n))(Mi||{}),Wd;const kn=(Wd=class extends Ie{constructor(){super(...arguments);h(this,"enableVR",!0);h(this,"enableAR",!0);h(this,"defaultAvatar");h(this,"handModelPath","");h(this,"createVRButton",!0);h(this,"createARButton",!0);h(this,"controllers",[]);h(this,"rig");h(this,"isInit",!1);h(this,"_requestedAR",!1);h(this,"_requestedVR",!1);h(this,"_isInAR",!1);h(this,"_isInVR",!1);h(this,"_arButton");h(this,"_vrButton");h(this,"webAR",null);h(this,"_transformOrientation",new we);h(this,"_currentHeadPose",null);h(this,"_originalCameraParent",null);h(this,"_originalCameraPosition",new w);h(this,"_originalCameraRotation",new we);h(this,"_originalXRRigParent",null);h(this,"_originalXRRigPosition",new w);h(this,"_originalXRRigRotation",new we);h(this,"xrMirrorWindow",null)}static get IsInWebXR(){return this._isInXr}static get XRSupported(){return"xr"in navigator&&(Og||kg)}static get IsARSupported(){return Og}static get IsVRSupported(){return kg}static get OptionalFeatures_VR(){return this._optionalFeatures_VR}static get OptionalFeatures_AR(){return this._optionalFeatures_AR}static addEventListener(e,t){return this.events.addEventListener(e,t),t}static removeEventListener(e,t){return this.events.removeEventListener(e,t),t}static dispatchEvent(e,t){this.events.dispatchEvent({type:e,detail:t})}static createVRButton(e,t){kn.XRSupported?e.__internalAwake():console.warn("WebXR is not supported on this device");const i={optionalFeatures:kn.OptionalFeatures_VR},s=rm.createButton(e.context.renderer,i);return s.classList.add("webxr-ar-button"),s.classList.add("webxr-button"),this.resetButtonStyles(s),((t==null?void 0:t.registerClick)??!0)&&s.addEventListener("click",e.onClickedVRButton.bind(e)),s}static createARButton(e,t){var o;e.__internalAwake();const i=(o=e.webAR)==null?void 0:o.getAROverlayContainer(),s={optionalFeatures:[...this.OptionalFeatures_AR]};i?(s.domOverlay={root:i},s.optionalFeatures.push("dom-overlay"),s.optionalFeatures.push("hit-test"),s.optionalFeatures.push("anchors")):console.warn("No dom overlay root found, HTML overlays on top of screen-based AR will not work.");const r=lne.createButton(e.context.renderer,s,this.onModifyAROptions.bind(this));return r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),kn.resetButtonStyles(r),((t==null?void 0:t.registerClick)??!0)&&r.addEventListener("click",e.onClickedARButton.bind(e)),r}static onModifyAROptions(e){kn.dispatchEvent("modify-ar-options",e)}static resetButtonStyles(e){e&&(e.style.position="",e.style.bottom="",e.style.left="")}endSession(){const e=this.context.renderer.xr.getSession();e&&e.end()}get Rig(){return this.rig||this.ensureRig(),this.rig}get Controllers(){return this.controllers}get LeftController(){var e,t;return this.controllers.length>0&&((e=this.controllers[0].input)==null?void 0:e.handedness)==="left"?this.controllers[0]:this.controllers.length>1&&((t=this.controllers[1].input)==null?void 0:t.handedness)==="left"?this.controllers[1]:null}get RightController(){var e,t;return this.controllers.length>0&&((e=this.controllers[0].input)==null?void 0:e.handedness)==="right"?this.controllers[0]:this.controllers.length>1&&((t=this.controllers[1].input)==null?void 0:t.handedness)==="right"?this.controllers[1]:null}get ARButton(){return this._arButton}get VRButton(){return this._vrButton}get IsInVR(){return this._isInVR}get IsInAR(){return this._isInAR}awake(){if(this.defaultAvatar&&typeof this.defaultAvatar=="string"&&(this.defaultAvatar=Tn.getOrCreate(this.sourceId??"/",this.defaultAvatar,this.context)),!ne.findObjectOfType(tA,this.context)){const e=ne.addNewComponent(this.gameObject,tA,!1);e.webXR=this}this.webAR=new Su(this)}start(){location.protocol=="http:"&&location.host.indexOf("localhost")<0&&(Ls("WebXR only works on https"),console.warn("WebXR only works on https. https://engine.needle.tools/docs/xr.html"))}onEnable(){if(this.isInit||!this.enableAR&&!this.enableVR)return;this.isInit=!0,this.context.renderer.xr.enabled=!0,kn.XRSupported;let e,t;const i=document.createElement("div");i.classList.add("webxr-buttons"),i.style.cssText=`
|
|
5182
5182
|
position: absolute;
|
|
5183
5183
|
bottom: 21px;
|
|
5184
5184
|
left: 50%;
|
|
@@ -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;
|