hytopia 0.3.31 → 0.3.32
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/examples/hygrounds/gameConfig.ts +2 -2
- package/package.json +1 -1
- package/server.js +1 -1
@@ -100,7 +100,7 @@ export const CHEST_DROP_ITEMS = [
|
|
100
100
|
},
|
101
101
|
{
|
102
102
|
itemId: 'rocket-launcher',
|
103
|
-
pickWeight: 0.
|
103
|
+
pickWeight: 0.5,
|
104
104
|
},
|
105
105
|
{
|
106
106
|
itemId: 'shotgun',
|
@@ -404,7 +404,7 @@ export const ITEM_SPAWN_ITEMS = [
|
|
404
404
|
},
|
405
405
|
{
|
406
406
|
itemId: 'rocket-launcher',
|
407
|
-
pickWeight: 0.
|
407
|
+
pickWeight: 0.5,
|
408
408
|
},
|
409
409
|
{
|
410
410
|
itemId: 'shotgun',
|
package/package.json
CHANGED
package/server.js
CHANGED
@@ -382,6 +382,6 @@ Instead, \`yield\` should either be called with a value, or not be called at all
|
|
382
382
|
`),Z.write(`Content-Length: ${$.length}\r
|
383
383
|
`),Z.write(`Connection: close\r
|
384
384
|
`),Z.write(`\r
|
385
|
-
`),Z.write($),Z.end();return}this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:X})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class wJ extends s{static instance=new wJ;_wss;constructor(){super();this._wss=new TZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),c8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:X})=>this._onUpgrade(J,Z,X))}_onConnection=(J,Z)=>{new L9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,X)=>{this._wss.handleUpgrade(J,Z,X,(Y)=>{this._wss.emit("connection",Y,J)})}}var Y$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(Y$||={});var WV=0.001,ME="dynamic";class f9 extends s{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(J){super();J.type??=ME,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:J,y:Z,z:X,w:Y}=this.rotation;return{x:2*(J*X+Y*Z),y:2*(Z*X-Y*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(J){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(J,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(J)}setAdditionalMassProperties(J){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:Z,centerOfMass:X,principalAngularInertia:Y,principalAngularInertiaLocalFrame:K}=J;this._rigidBody?this._rigidBody.setAdditionalMassProperties(Z,X,Y,K,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(Z,X,Y,K)}setAdditionalSolverIterations(J){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(J):this._rigidBodyDesc.setAdditionalSolverIterations(J)}setAngularDamping(J){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(J):this._rigidBodyDesc.setAngularDamping(J)}setAngularVelocity(J){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(J,!this._explicitSleep):this._rigidBodyDesc.setAngvel(J)}setCcdEnabled(J){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(J):this._rigidBodyDesc.setCcdEnabled(J)}setDominanceGroup(J){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(J):this._rigidBodyDesc.setDominanceGroup(J)}setEnabled(J){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(J):this._rigidBodyDesc.setEnabled(J)}setEnabledPositions(J){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z),this._enabledPositions=J}setEnabledRotations(J){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z),this._enabledRotations=J}setGravityScale(J){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(J,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(J)}setLinearDamping(J){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(J):this._rigidBodyDesc.setLinearDamping(J)}setLinearVelocity(J){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(J,!this._explicitSleep):this._rigidBodyDesc.setLinvel(J.x,J.y,J.z)}setNextKinematicRotation(J){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(J):this._rigidBodyDesc.setRotation(J)}setNextKinematicPosition(J){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(J):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setPosition(J){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(J,!this._explicitSleep):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setRotation(J){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(J,!this._explicitSleep):this._rigidBodyDesc.setRotation(J)}setSleeping(J){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?J?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=J,this._explicitSleep=J}setSoftCcdPrediction(J){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(J):this._rigidBodyDesc.setSoftCcdPrediction(J)}setCollisionGroupsForSolidColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:z0.RigidBodyType.Dynamic,["fixed"]:z0.RigidBodyType.Fixed,["kinematic_position"]:z0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:z0.RigidBodyType.KinematicVelocityBased}[J];if(X===void 0)return _.error(`Invalid RigidBodyType: ${J}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=J}addForce(J){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;J.addToSimulation(this._simulation,this)}addToSimulation(J){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return _.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=J,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((Z)=>{if(!Z.isSimulated)Z.addToSimulation(J,this)})}applyImpulse(J){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new d8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)Z.push(Y)}),Z}getCollidersByTag(J){let Z=[];for(let X of this._colliders)if(X.tag===J)Z.push(X);return Z}linkCollider(J){if(!this._requireNotRemoved("linkCollider"))return;if(J.parentRigidBody!==this)return _.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return _.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((J)=>{J.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(J){if(!this._requireNotRemoved("unlinkCollider"))return;if(!J.isRemoved)return _.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(J){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,Y])=>{if(X in J)Y(J[X])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let Z=new d8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)Z.push(Y)}),Z}_createRigidBodyDesc(J){let Z=J.type??ME;return{["dynamic"]:()=>z0.RigidBodyDesc.dynamic(),["fixed"]:()=>z0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>z0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>z0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(J){if(!this._rigidBody||!this._simulation)_.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(J){if(!this.isDynamic)_.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${J}()`);return this.isDynamic}_requireKinematic(J){if(!this.isKinematic)_.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${J}()`);return this.isKinematic}_requireNotKinematicPositionBased(J){if(this.isKinematicPositionBased)_.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${J}()`);return!this.isKinematicPositionBased}_requireNotRemoved(J){if(!this._rigidBody&&!this._rigidBodyDesc)_.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(J){if(this.isSimulated)_.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${J}()`);return!this.isSimulated}_isNegligibleVector(J){return Math.abs(J.x)<WV&&Math.abs(J.y)<WV&&Math.abs(J.z)<WV}}var u0=16,r5=u0-1,wE=u0**3,DZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+0,Z+0,X+1,J+0,Z+1,X+0,J+0,Z+1,X+0,J+0,Z+0,X+1,J+0,Z+1,X+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,X)=>[J+1,Z+0,X+0,J+1,Z+1,X+0,J+1,Z+0,X+1,J+1,Z+1,X+0,J+1,Z+1,X+1,J+1,Z+0,X+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+1,Z+0,X+0,J+0,Z+0,X+1,J+1,Z+0,X+0,J+1,Z+0,X+1,J+0,Z+0,X+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,X)=>[J+0,Z+1,X+0,J+0,Z+1,X+1,J+1,Z+1,X+0,J+1,Z+1,X+0,J+0,Z+1,X+1,J+1,Z+1,X+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+0,Z+1,X+0,J+1,Z+0,X+0,J+0,Z+1,X+0,J+1,Z+1,X+0,J+1,Z+0,X+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,X)=>[J+0,Z+0,X+1,J+1,Z+0,X+1,J+0,Z+1,X+1,J+0,Z+1,X+1,J+1,Z+0,X+1,J+1,Z+1,X+1]}],qV;((Y)=>{Y.DESPAWN="CHUNK.DESPAWN";Y.SET_BLOCK="CHUNK.SET_BLOCK";Y.SPAWN="CHUNK.SPAWN"})(qV||={});class w8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(wE)}get blocks(){return this._blocks}get requiresUpdate(){return this._requiresUpdate}get isSimulated(){return!!this._rigidBody}get isSpawned(){return!!this._originCoordinate&&!!this._world}get originCoordinate(){return this._originCoordinate}get world(){return this._world}static blockIndexToLocalCoordinate(J){return{x:J%u0,y:(J/u0|0)%u0,z:J/(u0*u0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&u0-1,y:J.y&u0-1,z:J.z&u0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(u0-1),y:J.y&~(u0-1),z:J.z&~(u0-1)}}static isValidOriginCoordinate(J){return J.x%u0===0&&J.y%u0===0&&J.z%u0===0}spawn(J,Z){if(this.isSpawned){let{x:X,y:Y,z:K}=this.originCoordinate;return _.error(`Chunk.spawn(): Chunk is already spawned at origin ${X}, ${Y}, ${K}!`)}if(!w8.isValidOriginCoordinate(Z))return _.error(`Chunk.spawn(): Chunk coordinates must be divisible by ${u0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)return _.error("Chunk.despawn(): Chunk has not been spawned and cannot be despawned!");this.emitWithWorld(this._world,"CHUNK.DESPAWN",{chunk:this}),this._removeFromSimulation(),this._world.chunkLattice.unregisterChunk(this),this._originCoordinate=void 0,this._world=void 0}getBlockId(J){return this._blocks[this._getIndex(J)]}hasBlock(J){return this._blocks[this._getIndex(J)]!==0}setBlock(J,Z){if(!this._isValidLocalCoordinate(J))return _.error("Chunk.setBlock(): Block local coordinate is out of bounds");if(this._blocks[this._getIndex(J)]===Z)return;if(this._blocks[this._getIndex(J)]=Z,this.isSpawned&&this.isSimulated){this.emitWithWorld(this._world,"CHUNK.SET_BLOCK",{chunk:this,globalCoordinate:this._getGlobalCoordinate(J),localCoordinate:J,blockTypeId:Z});let X=this._getGlobalCoordinate(J),Y=[];if(J.x===0)Y.push({x:-1,y:0,z:0});if(J.y===0)Y.push({x:0,y:-1,z:0});if(J.z===0)Y.push({x:0,y:0,z:-1});if(J.x===r5)Y.push({x:1,y:0,z:0});if(J.y===r5)Y.push({x:0,y:1,z:0});if(J.z===r5)Y.push({x:0,y:0,z:1});for(let K of Y){let $={x:X.x+K.x,y:X.y+K.y,z:X.z+K.z},Q=w8.globalCoordinateToOriginCoordinate($),G=this._world?.chunkLattice.getChunk(Q);if(!G?.hasBlock(w8.globalCoordinateToLocalCoordinate($)))continue;G.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)return _.error("Chunk.update(): Chunk is not spawned and cannot be updated.");let J=!this._rigidBody,Z=this._world.simulation;if(this._removeFromSimulation(),this._rigidBody=new f9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([X,Y])=>{if(!X.isSimulated)X.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(X,Y)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return t.serializeChunk(this)}_meshColliders(){if(!this._world)return _.error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed."),[];let J=new Map,Z=[];for(let Y=0;Y<wE;Y++){if(this._blocks[Y]===0)continue;let K=this._blocks[Y],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:G,z:F}=w8.blockIndexToLocalCoordinate(Y);if(!$.isMeshable){let q=$.createCollider();q.setRelativePosition({x:Q,y:G,z:F}),Z.push([q,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let q of DZ0){let[V,z,L]=q.neighborOffset,R={x:Q+V,y:G+z,z:F+L},M=this._getGlobalCoordinate(R),H=this._world.chunkLattice.getBlockType(M);if(H&&!H.isLiquid)continue;let O=W.indices.length;W.indices.push(O,O+1,O+2,O+3,O+4,O+5),W.vertices.push(...q.generateVertices(Q,G,F))}}let X=[];return J.forEach((Y,K)=>{if(!Y.indices.length)return;let $=K.createCollider(new Uint32Array(Y.indices),new Float32Array(Y.vertices));X.push([$,K])}),[...Z,...X]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)_.fatalError("Chunk._getGlobalCoordinate(): Chunk is not spawned, calculating global coordinate is impossible.");return{x:this.originCoordinate.x+J.x,y:this.originCoordinate.y+J.y,z:this.originCoordinate.z+J.z}}_getIndex(J){return J.x+u0*(J.y+u0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=r5&&J.y>=0&&J.y<=r5&&J.z>=0&&J.z<=r5}}class OJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:X,z:Y}=J.originCoordinate;return _.error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${X}, ${Y}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)return _.error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)return _.error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(w8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(w8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!w8.isValidOriginCoordinate(J)){_.error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${u0})`);return}return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(w8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(w8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let X=w8.globalCoordinateToLocalCoordinate(J),Y=w8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(Y);if(!K)K=new w8,K.spawn(this._world,Y);K.setBlock(X,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var OE={type:"dynamic",softCcdPrediction:1},xE=0.0025000000000000005,PE=Math.cos(0.005),K$;((O)=>{O.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";O.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";O.DESPAWN="ENTITY.DESPAWN";O.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";O.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";O.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";O.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";O.SET_OPACITY="ENTITY.SET_OPACITY";O.SET_PARENT="ENTITY.SET_PARENT";O.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";O.SPAWN="ENTITY.SPAWN";O.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";O.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";O.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";O.TICK="ENTITY.TICK";O.UPDATE_POSITION="ENTITY.UPDATE_POSITION";O.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(K$||={});class Z8 extends f9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelScale;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;constructor(J){let Z="blockTextureUri"in J,X="modelUri"in J;if(!Z===!X)_.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(Z&&!J.blockHalfExtents)_.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)_.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!U6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))_.fatalError(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??OE);if(Z)this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelScale=J.modelScale,this._modelUri=J.modelUri,J.modelHiddenNodes?.forEach((Y)=>this._modelHiddenNodes.add(Y.toLowerCase())),J.modelLoopedAnimations?.forEach((Y)=>this._modelLoopedAnimations.add(Y));if(this._name=J.name??"Nameless",this._opacity=J.opacity??1,this._parent=J.parent,this._parentNodeName=J.parentNodeName,this._tag=J.tag,this._tintColor=J.tintColor,J.controller)this.setController(J.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get height(){return this.isModelEntity?U6.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelScale(){return this._modelScale}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get world(){return this._world}spawn(J,Z,X){if(this.isSpawned)return _.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(J.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new d8(d8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new d8(d8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((Y)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))Y.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Y.enableContactForceEvents(!0);if(q6.isDefaultCollisionGroups(Y.collisionGroups))Y.setCollisionGroups({belongsTo:[Y.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),X)this.setRotation(X);if(this._id=J.entityManager.registerEntity(this),this._world=J,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,Z,X);this.colliders.forEach((Y)=>{J.simulation.colliderMap.setColliderEntity(Y,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((J)=>{J.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setModelAnimationsPlaybackRate(J){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===J)return;this._modelAnimationsPlaybackRate=J,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:J})}setController(J){if(this._controller===J)return;if(this._controller)this._controller.detach(this);if(this._controller=J,this._controller)this._controller.attach(this)}setModelHiddenNodes(J){if(!this._requireSpawned("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setOpacity(J){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,X,Y){if(!this._requireSpawned("setParent"))return;if(J&&!J.isSpawned)return _.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&J)this._lastParentlessType=this.type;if(this._parent=J,this._parentNodeName=Z,this.colliders.forEach((K)=>K.setEnabled(!J)),this.setType(!J?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation(Y??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:J,parentNodeName:Z})}setTintColor(J){if(!this._requireSpawned("setTintColor"))return;if(!J&&!this._tintColor||J&&this._tintColor&&J.r===this._tintColor.r&&J.g===this._tintColor.g&&J.b===this._tintColor.b)return;this._tintColor=J,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:J})}startModelLoopedAnimations(J){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>!this._modelLoopedAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(J)})}startModelOneshotAnimations(J){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!J.length)return;J.forEach((Z)=>{this._modelOneshotAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(J)})}stopModelAnimations(J){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>this._modelLoopedAnimations.has(Z))&&!J.some((Z)=>this._modelOneshotAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.delete(Z),this._modelOneshotAnimations.delete(Z)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(J)})}serialize(){return t.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let J=this.position,Z=this.rotation;if(this._rotationExceedsThreshold(Z,this._lastUpdatedRotation))this._lastUpdatedRotation=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:Z});if(this._positionExceedsThreshold(J,this._lastUpdatedPosition))this._lastUpdatedPosition=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:J})}_requireSpawned(J){if(!this.isSpawned)_.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${J}()!`);return this.isSpawned}_positionExceedsThreshold(J,Z){let X=J.x-Z.x,Y=J.y-Z.y,K=J.z-Z.z;return X*X+Y*Y+K*K>xE}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<PE}}class xJ extends i1{autoCancelMouseLeftClick=!0;canWalk=()=>!0;canRun=()=>!0;canJump=()=>!0;idleLoopedAnimations=["idle_upper","idle_lower"];interactOneshotAnimations=["simple_interact"];jumpOneshotAnimations=["jump_loop"];jumpVelocity=10;runLoopedAnimations=["run_upper","run_lower"];runVelocity=8;sticksToPlatforms=!0;walkLoopedAnimations=["walk_upper","walk_lower"];walkVelocity=4;_stepAudio;_groundContactCount=0;_platform;constructor(J={}){super();this.autoCancelMouseLeftClick=J.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.jumpVelocity=J.jumpVelocity??this.jumpVelocity,this.runVelocity=J.runVelocity??this.runVelocity,this.walkVelocity=J.walkVelocity??this.walkVelocity,this.canWalk=J.canWalk??this.canWalk,this.canRun=J.canRun??this.canRun,this.canJump=J.canJump??this.canJump,this.sticksToPlatforms=J.sticksToPlatforms??this.sticksToPlatforms}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get platform(){return this._platform}attach(J){this._stepAudio=new K4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)return _.error("PlayerEntityController.createColliders(): Entity is not spawned!");J.createAndAddChildCollider({shape:"cylinder",radius:0.23,halfHeight:0.125,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},isSensor:!0,relativePosition:{x:0,y:-0.75,z:0},tag:"groundSensor",onCollision:(Z,X)=>{if(!J.isSpawned)return;if(this._groundContactCount+=X?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof Z8)||!Z.isKinematic)return;if(X&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!X)this._platform=void 0}}),J.createAndAddChildCollider({shape:"capsule",halfHeight:0.33,radius:0.4,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(J,Z,X,Y){if(!J.isSpawned||!J.world)return;if(super.tickWithPlayerInput(J,Z,X,Y),J.parent)return;let{w:K,a:$,s:Q,d:G,sp:F,sh:W,ml:q}=Z,{yaw:V}=X,z=J.linearVelocity,L={x:0,y:0,z:0},R=W;if(this.isGrounded&&(K||$||Q||G)){if(R)J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.runLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.runLoopedAnimations),this._stepAudio?.setPlaybackRate(0.75);else J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.walkLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.walkLoopedAnimations),this._stepAudio?.setPlaybackRate(0.51);this._stepAudio?.play(J.world,!this._stepAudio?.isPlaying)}else this._stepAudio?.pause(),J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.idleLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.idleLoopedAnimations);if(q)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(R&&this.canRun(this)||!R&&this.canWalk(this)){let P=R?this.runVelocity:this.walkVelocity;if(K)L.x-=P*Math.sin(V),L.z-=P*Math.cos(V);if(Q)L.x+=P*Math.sin(V),L.z+=P*Math.cos(V);if($)L.x-=P*Math.cos(V),L.z+=P*Math.sin(V);if(G)L.x+=P*Math.cos(V),L.z-=P*Math.sin(V);let N=Math.sqrt(L.x*L.x+L.z*L.z);if(N>P){let B=P/N;L.x*=B,L.z*=B}}if(F&&this.canJump(this)){if(this.isGrounded&&z.y>-0.001&&z.y<=3)L.y=this.jumpVelocity}let M=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},H={x:L.x-z.x+M.x,y:L.y+M.y,z:L.z-z.z+M.z};if(!(this.runVelocity>0&&Math.abs(z.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(z.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(z.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(H).some((P)=>P!==0)){let P=J.mass;J.applyImpulse({x:H.x*P,y:H.y*P,z:H.z*P})}}if(V!==void 0){let P=V/2;J.setRotation({x:0,y:Math.fround(Math.sin(P)),z:0,w:Math.fround(Math.cos(P))})}}}var VV;((G)=>{G.LOAD="SCENE_UI.LOAD";G.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";G.SET_OFFSET="SCENE_UI.SET_OFFSET";G.SET_POSITION="SCENE_UI.SET_POSITION";G.SET_STATE="SCENE_UI.SET_STATE";G.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";G.UNLOAD="SCENE_UI.UNLOAD"})(VV||={});class PJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=J.attachedToEntity,this._offset=J.offset,this._position=J.position,this._state=J.state??{},this._templateId=J.templateId,this._viewDistance=J.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(J){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`SceneUI.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:J})}setPosition(J){if(this._position===J)return;if(this._attachedToEntity=void 0,this._position=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:J})}setState(J){if(this._state={...this._state,...J},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(J){if(this._viewDistance=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:J})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return t.serializeSceneUI(this)}}class d1 extends Z8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new PJ({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}}),!J.controller)this.setController(new xJ)}spawn(J,Z,X){super.spawn(J,Z,X),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:Y})=>{this.nametagSceneUI.setState({chat:Y})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:X}=this.player;this.controller.tickWithPlayerInput(this,Z,X.orientation,J),super.tick(J)}}class BJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)_.fatalError(`EntityManager.registerEntity(): Entity ${J.name} is already assigned the id ${J.id}!`);let Z=this._nextEntityId;return this._entities.set(Z,J),this._nextEntityId++,Z}unregisterEntity(J){if(J.id===void 0)return _.error(`EntityManager.unregisterEntity(): Entity ${J.name} is not assigned an id!`);this._entities.delete(J.id)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let J=[];return this._entities.forEach((Z)=>{if(Z instanceof d1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((X)=>{if(X instanceof d1&&X.player===J)Z.push(X)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((X)=>{if(X.tag===J)Z.push(X)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((X)=>{if(X.tag?.includes(J))Z.push(X)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((X)=>{if(X.parent===J)Z.push(X)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class vJ{_lights=new Map;_nextLightId=1;_world;constructor(J){this._world=J}get world(){return this._world}despawnEntityAttachedLights(J){this.getAllEntityAttachedLights(J).forEach((Z)=>{Z.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(J){return this.getAllLights().filter((Z)=>Z.attachedToEntity===J)}registerLight(J){if(J.id!==void 0)return J.id;let Z=this._nextLightId;return this._lights.set(Z,J),this._nextLightId++,Z}unregisterLight(J){if(J.id===void 0)return;this._lights.delete(J.id)}}var NE;((X)=>{X[X.POINTLIGHT=0]="POINTLIGHT";X[X.SPOTLIGHT=1]="SPOTLIGHT"})(NE||={});var zV;((z)=>{z.DESPAWN="LIGHT.DESPAWN";z.SET_ANGLE="LIGHT.SET_ANGLE";z.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";z.SET_COLOR="LIGHT.SET_COLOR";z.SET_DISTANCE="LIGHT.SET_DISTANCE";z.SET_INTENSITY="LIGHT.SET_INTENSITY";z.SET_OFFSET="LIGHT.SET_OFFSET";z.SET_PENUMBRA="LIGHT.SET_PENUMBRA";z.SET_POSITION="LIGHT.SET_POSITION";z.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";z.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";z.SPAWN="LIGHT.SPAWN"})(zV||={});class HV extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();_.warning("WARNING: Lights are poorly optimized at this time. Using more than a few lights in your game can cause extremely bad performance (FPS) issues. Use lights sparingly!"),this._angle=J.angle,this._attachedToEntity=J.attachedToEntity,this._color=J.color??{r:255,g:255,b:255},this._distance=J.distance,this._intensity=J.intensity??1,this._offset=J.offset,this._penumbra=J.penumbra,this._position=J.position,this._trackedEntity=J.trackedEntity,this._trackedPosition=J.trackedPosition,this._type=J.type??0}get id(){return this._id}get angle(){return this._angle}get attachedToEntity(){return this._attachedToEntity}get color(){return this._color}get distance(){return this._distance}get intensity(){return this._intensity}get isSpawned(){return this._id!==void 0}get offset(){return this._offset}get penumbra(){return this._penumbra}get position(){return this._position}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get type(){return this._type}get world(){return this._world}setAngle(J){if(this._angle===J)return;if(this._angle=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:J})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`Light.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:J})}setColor(J){if(this._color.r===J.r&&this._color.g===J.g&&this._color.b===J.b)return;if(this._color=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:J})}setDistance(J){if(this._distance===J)return;if(this._distance=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:J})}setIntensity(J){if(this._intensity===J)return;if(this._intensity=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:J})}setPenumbra(J){if(this._penumbra===J)return;if(this._penumbra=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:J})}setPosition(J){if(this._position===J)return;if(this._position=J,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:J})}setTrackedEntity(J){if(!J.isSpawned)return _.error(`Light.setTrackedEntity(): Entity ${J.id} is not spawned!`);if(this._trackedEntity===J)return;if(this._trackedEntity=J,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:J})}setTrackedPosition(J){if(this._trackedPosition===J)return;if(this._trackedPosition=J,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:J})}despawn(){if(!this.isSpawned||!this._world)return;this._world.lightManager.unregisterLight(this),this.emitWithWorld(this._world,"LIGHT.DESPAWN",{light:this}),this._id=void 0,this._world=void 0}spawn(J){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return t.serializeLight(this)}}var BE;((Y)=>{Y[Y.FIRST_PERSON=0]="FIRST_PERSON";Y[Y.THIRD_PERSON=1]="THIRD_PERSON";Y[Y.SPECTATOR=2]="SPECTATOR"})(BE||={});var UV;((L)=>{L.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";L.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";L.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";L.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";L.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";L.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";L.SET_FOV="PLAYER_CAMERA.SET_FOV";L.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";L.SET_MODE="PLAYER_CAMERA.SET_MODE";L.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";L.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";L.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";L.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(UV||={});class jJ extends s{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_trackedEntity;_trackedPosition;_zoom=1;constructor(J){super();this.player=J}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(!this._requirePlayerWorld())return;if(!J.isSpawned)return _.error(`PlayerCamera.setAttachedToEntity(): Entity ${J.id} is not spawned!`);this._attachedToEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:J})}setAttachedToPosition(J){if(!this._requirePlayerWorld())return;this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){if(!this._requirePlayerWorld())return;this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){if(!this._requirePlayerWorld())return;this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){if(!this._requirePlayerWorld())return;this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){if(!this._requirePlayerWorld())return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setMode(J){if(!this._requirePlayerWorld())return;this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){if(!this._requirePlayerWorld())return;this._offset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:J})}setOrientationPitch(J){this._orientation.pitch=J}setOrientationYaw(J){this._orientation.yaw=J}setTrackedEntity(J){if(!this._requirePlayerWorld())return;this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){if(!this._requirePlayerWorld())return;this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){if(!this._requirePlayerWorld())return;this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return t.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)_.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`);return!!this.player.world}}var $$;((K)=>{K.DATA="PLAYER_UI.DATA";K.LOAD="PLAYER_UI.LOAD";K.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";K.SEND_DATA="PLAYER_UI.SEND_DATA"})($$||={});class TJ extends s{player;constructor(J){super();this.player=J}load(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:J})}lockPointer(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:J})}sendData(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:J})}}class DJ{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleEntityMap.get(J.rawCollider.handle)}getColliderHandleBlockType(J){return this._colliderHandleBlockTypeMap.get(J)}getColliderHandleCollisionCallback(J){return this._colliderHandleCollisionCallbackMap.get(J)}getColliderHandleEntity(J){return this._colliderHandleEntityMap.get(J)}removeColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleEntity(J.rawCollider.handle)}removeColliderHandleBlockType(J){this._colliderHandleBlockTypeMap.delete(J)}removeColliderHandleCollisionCallback(J){this._colliderHandleCollisionCallbackMap.delete(J)}removeColliderHandleEntity(J){this._colliderHandleEntityMap.delete(J)}setColliderBlockType(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleEntity(J.rawCollider.handle,Z)}setColliderHandleBlockType(J,Z){this._colliderHandleBlockTypeMap.set(J,Z),this._cleanupBlockTypeColliderHandles.delete(J),this._pendingCleanupBlockTypeColliderHandles.delete(J)}setColliderHandleCollisionCallback(J,Z){this._colliderHandleCollisionCallbackMap.set(J,Z),this._cleanupCollisionCallbackColliderHandles.delete(J),this._pendingCleanupCollisionCallbackColliderHandles.delete(J)}setColliderHandleEntity(J,Z){this._colliderHandleEntityMap.set(J,Z),this._cleanupEntityColliderHandles.delete(J),this._pendingCleanupEntityColliderHandles.delete(J)}queueColliderHandleForCleanup(J){if(this._colliderHandleBlockTypeMap.has(J))this._pendingCleanupBlockTypeColliderHandles.add(J);if(this._colliderHandleCollisionCallbackMap.has(J))this._pendingCleanupCollisionCallbackColliderHandles.add(J);if(this._colliderHandleEntityMap.has(J))this._pendingCleanupEntityColliderHandles.add(J)}cleanup(){for(let J of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(J);this._cleanupBlockTypeColliderHandles.clear();for(let J of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(J);this._cleanupCollisionCallbackColliderHandles.clear();for(let J of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(J);this._cleanupEntityColliderHandles.clear(),[[this._pendingCleanupBlockTypeColliderHandles,this._cleanupBlockTypeColliderHandles],[this._pendingCleanupCollisionCallbackColliderHandles,this._cleanupCollisionCallbackColliderHandles],[this._pendingCleanupEntityColliderHandles,this._cleanupEntityColliderHandles]].forEach(([J,Z])=>{for(let X of J.keys())Z.add(X);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)_.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!J.rawCollider}}var kZ0={x:0,y:-32,z:0},LV=60,RV;((K)=>{K.STEP_START="SIMULATION.STEP_START";K.STEP_END="SIMULATION.STEP_END";K.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";K.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(RV||={});class kJ extends s{_colliderMap=new DJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=LV,X=kZ0){super();this._rapierEventQueue=new z0.EventQueue(!0),this._rapierSimulation=new z0.World(X),this._rapierSimulation.timestep=Math.fround(1/Z),this._world=J}get colliderMap(){return this._colliderMap}get isDebugRaycastingEnabled(){return this._debugRaycastingEnabled}get isDebugRenderingEnabled(){return this._debugRenderingEnabled}get gravity(){return this._rapierSimulation.gravity}get timestepS(){return this._rapierSimulation.timestep}get world(){return this._world}raycast(J,Z,X,Y={}){let K=new z0.Ray(J,Z),$=this._rapierSimulation.castRay(K,X,Y.ignoresSensors??!0,Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:X,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),G=$.timeOfImpact,F=$.collider,W=this._colliderMap.getColliderHandleBlockType(F.handle);if(W)return{hitBlock:p9.fromGlobalCoordinate({x:Math.floor(Q.x-(K.dir.x<0?0.0001:-0.0001)),y:Math.floor(Q.y-(K.dir.y<0?0.0001:-0.0001)),z:Math.floor(Q.z-(K.dir.z<0?0.0001:-0.0001))},W),hitPoint:Q,hitDistance:G};let q=this._colliderMap.getColliderHandleEntity(F.handle);if(q)return{hitEntity:q,hitPoint:Q,hitDistance:G};return null}createRawCollider(J,Z){return this._rapierSimulation.createCollider(J,Z)}createRawRigidBody(J){return this._rapierSimulation.createRigidBody(J)}enableDebugRaycasting(J){this._debugRaycastingEnabled=J}enableDebugRendering(J){this._debugRenderingEnabled=J}getContactManifolds(J,Z){let X=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(Y,K)=>{if(Y.numContacts()===0)return;let $=Y.normal(),Q=[];for(let G=0;G<Y.numSolverContacts();G++)Q.push(Y.solverContactPoint(G));X.push({contactPoints:Q,localNormalA:!K?Y.localNormal1():Y.localNormal2(),localNormalB:!K?Y.localNormal2():Y.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),X}removeRawCollider(J){this._colliderMap.queueColliderHandleForCleanup(J.handle),this._rapierSimulation.removeCollider(J,!1)}removeRawRigidBody(J){this._rapierSimulation.removeRigidBody(J)}setGravity(J){this._rapierSimulation.gravity=J}step=(J)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:J});let Z=performance.now();if(this._rapierSimulation.step(this._rapierEventQueue),this._rapierEventQueue.drainContactForceEvents(this._onContactForceEvent),this._rapierEventQueue.drainCollisionEvents(this._onCollisionEvent),this._colliderMap.cleanup(),this.emitWithWorld(this._world,"SIMULATION.STEP_END",{simulation:this,stepDurationMs:performance.now()-Z}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender()})};_onCollisionEvent=(J,Z,X)=>{let[Y,K]=this._getCollisionObjects(J,Z);if(!Y||!K)return;let $=(Q,G)=>{if(Q instanceof L6&&G instanceof Z8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof Z8&&G instanceof L6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof Z8&&G instanceof Z8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(G instanceof Z8||G instanceof L6))Q(G,X,J,Z)};$(Y,K),$(K,Y)};_onContactForceEvent=(J)=>{let[Z,X]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!X||typeof X==="function")return;let Y={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof L6&&Q instanceof Z8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:Y});else if($ instanceof Z8&&Q instanceof L6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:Y});else if($ instanceof Z8&&Q instanceof Z8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:Y})};K(Z,X),K(X,Z)};_getCollisionObjects(J,Z){let X=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),Y=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[X,Y]}}class Q${_synchronizedPlayerPackets=new Map;_queuedBroadcasts=[];_queuedAudioSynchronizations={};_queuedBlockSynchronizations={};_queuedBlockTypeSynchronizations={};_queuedChunkSynchronizations={};_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations={};_queuedLightSynchronizations={};_queuedPerPlayerSynchronizations=new Map;_queuedPerPlayerCameraSynchronizations=new Map;_queuedPerPlayerUISynchronizations=new Map;_queuedPerPlayerUIDatasSynchronizations=new Map;_queuedPlayerSynchronizations={};_queuedSceneUISynchronizations={};_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(J){this._world=J,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){let J=[],Z=this._world.loop.currentTick;this._queuedPerPlayerSynchronizations.forEach((V,z)=>{this._createOrGetSynchronizedPlayerPackets(z,J).push(...V)});let X=Object.values(this._queuedEntitySynchronizations);if(X.length>0){let V=y.createPacket(y.outboundPackets.entitiesPacketDefinition,X,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let Y=Object.values(this._queuedAudioSynchronizations);if(Y.length>0){let V=y.createPacket(y.outboundPackets.audiosPacketDefinition,Y,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let K=Object.values(this._queuedBlockTypeSynchronizations);if(K.length>0){let V=y.createPacket(y.outboundPackets.blockTypesPacketDefinition,K,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let $=Object.values(this._queuedBlockSynchronizations);if($.length>0){let V=y.createPacket(y.outboundPackets.blocksPacketDefinition,$,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let Q=Object.values(this._queuedChunkSynchronizations);if(Q.length>0){let V=y.createPacket(y.outboundPackets.chunksPacketDefinition,Q,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let G=Object.values(this._queuedLightSynchronizations);if(G.length>0){let V=y.createPacket(y.outboundPackets.lightsPacketDefinition,G,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedPerPlayerUISynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.uiPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)}),this._queuedPerPlayerUIDatasSynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.uiDatasPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)});let F=Object.values(this._queuedSceneUISynchronizations);if(F.length>0){let V=y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,F,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}if(this._queuedWorldSynchronization){let V=y.createPacket(y.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedPerPlayerCameraSynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.cameraPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)});let W=Object.values(this._queuedPlayerSynchronizations);if(W.length>0){let V=y.createPacket(y.outboundPackets.playersPacketDefinition,W,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedBroadcasts.forEach((V)=>{J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))});let q=this._queuedDebugRaycastSynchronizations;if(q.length>0){let V=y.createPacket(y.outboundPackets.physicsDebugRaycastsPacketDefinition,q,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}U1.instance.getConnectedPlayersByWorld(this._world).forEach((V)=>{let z=this._synchronizedPlayerPackets.get(V)??J;if(z.length>0)V.connection.send(z)}),this._queuedBroadcasts=[],this._queuedAudioSynchronizations={},this._queuedBlockSynchronizations={},this._queuedBlockTypeSynchronizations={},this._queuedChunkSynchronizations={},this._queuedDebugRaycastSynchronizations=[],this._queuedEntitySynchronizations={},this._queuedLightSynchronizations={},this._queuedPerPlayerSynchronizations.clear(),this._queuedPerPlayerCameraSynchronizations.clear(),this._queuedPerPlayerUISynchronizations.clear(),this._queuedPerPlayerUIDatasSynchronizations.clear(),this._queuedPlayerSynchronizations={},this._queuedSceneUISynchronizations={},this._queuedWorldSynchronization=void 0,this._loadedSceneUIs.clear(),this._spawnedChunks.clear(),this._spawnedEntities.clear(),this._synchronizedPlayerPackets.clear()}_subscribeToAudioEvents(){this._world.final("AUDIO.PAUSE",this._onAudioPause),this._world.final("AUDIO.PLAY",this._onAudioPlay),this._world.final("AUDIO.PLAY_RESTART",this._onAudioPlayRestart),this._world.final("AUDIO.SET_ATTACHED_TO_ENTITY",this._onAudioSetAttachedToEntity),this._world.final("AUDIO.SET_CUTOFF_DISTANCE",this._onAudioSetCutoffDistance),this._world.final("AUDIO.SET_DETUNE",this._onAudioSetDetune),this._world.final("AUDIO.SET_DISTORTION",this._onAudioSetDistortion),this._world.final("AUDIO.SET_POSITION",this._onAudioSetPosition),this._world.final("AUDIO.SET_PLAYBACK_RATE",this._onAudioSetPlaybackRate),this._world.final("AUDIO.SET_REFERENCE_DISTANCE",this._onAudioSetReferenceDistance),this._world.final("AUDIO.SET_VOLUME",this._onAudioSetVolume)}_subscribeToBlockTypeRegistryEvents(){this._world.final("BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",this._onBlockTypeRegistryRegisterBlockType)}_subscribeToChatEvents(){this._world.final("CHAT.BROADCAST_MESSAGE",this._onChatSendBroadcastMessage),this._world.final("CHAT.PLAYER_MESSAGE",this._onChatSendPlayerMessage)}_subscribeToChunkEvents(){this._world.final("CHUNK.SPAWN",this._onChunkSpawn),this._world.final("CHUNK.DESPAWN",this._onChunkDespawn),this._world.final("CHUNK.SET_BLOCK",this._onChunkSetBlock)}_subscribeToEntityEvents(){this._world.final("ENTITY.SPAWN",this._onEntitySpawn),this._world.final("ENTITY.DESPAWN",this._onEntityDespawn),this._world.final("ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",this._onEntitySetModelAnimationsPlaybackRate),this._world.final("ENTITY.SET_MODEL_HIDDEN_NODES",this._onEntitySetModelHiddenNodes),this._world.final("ENTITY.SET_OPACITY",this._onEntitySetOpacity),this._world.final("ENTITY.SET_PARENT",this._onEntitySetParent),this._world.final("ENTITY.SET_TINT_COLOR",this._onEntitySetTintColor),this._world.final("ENTITY.START_MODEL_LOOPED_ANIMATIONS",this._onEntityStartModelLoopedAnimations),this._world.final("ENTITY.START_MODEL_ONESHOT_ANIMATIONS",this._onEntityStartModelOneshotAnimations),this._world.final("ENTITY.STOP_MODEL_ANIMATIONS",this._onEntityStopModelAnimations),this._world.final("ENTITY.UPDATE_POSITION",this._onEntityUpdatePosition),this._world.final("ENTITY.UPDATE_ROTATION",this._onEntityUpdateRotation)}_subscribeToLightEvents(){this._world.final("LIGHT.DESPAWN",this._onLightDespawn),this._world.final("LIGHT.SET_ANGLE",this._onLightSetAngle),this._world.final("LIGHT.SET_ATTACHED_TO_ENTITY",this._onLightSetAttachedToEntity),this._world.final("LIGHT.SET_COLOR",this._onLightSetColor),this._world.final("LIGHT.SET_DISTANCE",this._onLightSetDistance),this._world.final("LIGHT.SET_INTENSITY",this._onLightSetIntensity),this._world.final("LIGHT.SET_OFFSET",this._onLightSetOffset),this._world.final("LIGHT.SET_PENUMBRA",this._onLightSetPenumbra),this._world.final("LIGHT.SET_POSITION",this._onLightSetPosition),this._world.final("LIGHT.SET_TRACKED_ENTITY",this._onLightSetTrackedEntity),this._world.final("LIGHT.SET_TRACKED_POSITION",this._onLightSetTrackedPosition),this._world.final("LIGHT.SPAWN",this._onLightSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.REQUEST_SYNC",this._onPlayerRequestSync)}_subscribeToPlayerCameraEvents(){this._world.final("PLAYER_CAMERA.LOOK_AT_ENTITY",this._onPlayerCameraLookAtEntity),this._world.final("PLAYER_CAMERA.LOOK_AT_POSITION",this._onPlayerCameraLookAtPosition),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",this._onPlayerCameraSetAttachedToEntity),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",this._onPlayerCameraSetAttachedToPosition),this._world.final("PLAYER_CAMERA.SET_FILM_OFFSET",this._onPlayerCameraSetFilmOffset),this._world.final("PLAYER_CAMERA.SET_FORWARD_OFFSET",this._onPlayerCameraSetForwardOffset),this._world.final("PLAYER_CAMERA.SET_FOV",this._onPlayerCameraSetFov),this._world.final("PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",this._onPlayerCameraSetModelHiddenNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_TRACKED_ENTITY",this._onPlayerCameraSetTrackedEntity),this._world.final("PLAYER_CAMERA.SET_TRACKED_POSITION",this._onPlayerCameraSetTrackedPosition),this._world.final("PLAYER_CAMERA.SET_ZOOM",this._onPlayerCameraSetZoom)}_subscribeToPlayerUIEvents(){this._world.final("PLAYER_UI.LOAD",this._onPlayerUILoad),this._world.final("PLAYER_UI.LOCK_POINTER",this._onPlayerUILockPointer),this._world.final("PLAYER_UI.SEND_DATA",this._onPlayerUISendData)}_subscribeToSceneUIEvents(){this._world.final("SCENE_UI.LOAD",this._onSceneUILoad),this._world.final("SCENE_UI.SET_ATTACHED_TO_ENTITY",this._onSceneUISetAttachedToEntity),this._world.final("SCENE_UI.SET_OFFSET",this._onSceneUISetOffset),this._world.final("SCENE_UI.SET_POSITION",this._onSceneUISetPosition),this._world.final("SCENE_UI.SET_STATE",this._onSceneUISetState),this._world.final("SCENE_UI.SET_VIEW_DISTANCE",this._onSceneUISetViewDistance),this._world.final("SCENE_UI.UNLOAD",this._onSceneUIUnload)}_subscribeToSimulationEvents(){this._world.final("SIMULATION.DEBUG_RAYCAST",this._onSimulationDebugRaycast),this._world.final("SIMULATION.DEBUG_RENDER",this._onSimulationDebugRender)}_subscribeToWorldEvents(){this._world.final("WORLD.SET_AMBIENT_LIGHT_COLOR",this._onWorldSetAmbientLightColor),this._world.final("WORLD.SET_AMBIENT_LIGHT_INTENSITY",this._onWorldSetAmbientLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",this._onWorldSetDirectionalLightColor),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",this._onWorldSetDirectionalLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",this._onWorldSetDirectionalLightPosition)}_onAudioPause=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pa=!0,delete Z.pl,delete Z.r};_onAudioPlay=(J)=>{let Z=J.audio.serialize();Z.pl=!0,delete Z.pa,delete Z.r,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioPlayRestart=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.r=!0,delete Z.pa,delete Z.pl,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onAudioSetCutoffDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.cd=J.cutoffDistance};_onAudioSetDetune=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.de=J.detune};_onAudioSetDistortion=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.di=J.distortion};_onAudioSetPosition=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.position?void 0:Z.e,Z.p=J.position?t.serializeVector(J.position):void 0};_onAudioSetPlaybackRate=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pr=J.playbackRate};_onAudioSetReferenceDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.rd=J.referenceDistance};_onAudioSetVolume=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.v=J.volume};_onBlockTypeRegistryRegisterBlockType=(J)=>{let Z=J.blockType.serialize();this._queuedBlockTypeSynchronizations[J.blockType.id]=Z};_onChatSendBroadcastMessage=(J)=>{let{player:Z,message:X,color:Y}=J;this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:X,color:Y}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(Z,K)};_onChunkSpawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk);Z.b=Array.from(J.chunk.blocks),Z.rm=void 0,this._spawnedChunks.add(Z.c.join(","))};_onChunkDespawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk),X=Z.c.join(",");if(this._spawnedChunks.has(X))delete this._queuedChunkSynchronizations[X],this._spawnedChunks.delete(X);else Z.rm=!0};_onChunkSetBlock=(J)=>{let Z=this._createOrGetQueuedBlockSync(J.globalCoordinate);Z.i=J.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.ap=J.playbackRate};_onEntitySpawn=(J)=>{let Z=J.entity.serialize();this._queuedEntitySynchronizations[Z.i]=Z,this._spawnedEntities.add(Z.i)};_onEntityDespawn=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(this._spawnedEntities.has(Z.i))delete this._queuedEntitySynchronizations[Z.i],this._spawnedEntities.delete(Z.i);else Z.rm=!0};_onEntitySetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.h=Array.from(J.modelHiddenNodes)};_onEntitySetOpacity=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.o=J.opacity};_onEntitySetParent=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.pe=J.parent?J.parent.id:void 0,Z.pn=J.parentNodeName};_onEntitySetTintColor=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.t=J.tintColor?t.serializeRgbColor(J.tintColor):void 0};_onEntityStartModelLoopedAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al=Array.from(new Set([...Z.al??[],...J.animations])),Z.as)Z.as=Z.as.filter((X)=>!J.animations.has(X)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.ao=Array.from(new Set([...Z.ao??[],...J.animations])),Z.as)Z.as=Z.as.filter((X)=>!J.animations.has(X)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((X)=>!J.animations.has(X)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((X)=>!J.animations.has(X)).filter(Boolean);Z.as=Array.from(new Set([...Z.as??[],...J.animations]))};_onEntityUpdateRotation=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.r=[J.rotation.x,J.rotation.y,J.rotation.z,J.rotation.w]};_onEntityUpdatePosition=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.p=[J.position.x,J.position.y,J.position.z]};_onLightDespawn=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.rm=!0};_onLightSetAngle=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.a=J.angle};_onLightSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onLightSetColor=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.c=t.serializeRgbColor(J.color)};_onLightSetDistance=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.d=J.distance};_onLightSetIntensity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.n=J.intensity};_onLightSetOffset=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onLightSetPenumbra=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.pe=J.penumbra};_onLightSetPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.p=J.position?t.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onLightSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.te=J.entity?J.entity.id:void 0,Z.tp=J.entity?void 0:Z.tp};_onLightSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.tp=J.position?t.serializeVector(J.position):void 0,Z.te=J.position?void 0:Z.te};_onLightSpawn=(J)=>{let Z=J.light.serialize();this._queuedLightSynchronizations[Z.i]=Z};_onPlayerCameraLookAtEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=t.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?t.serializeVector(J.position):void 0,delete Z.et,delete Z.pt};_onPlayerCameraSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.e=J.entity.id,delete Z.p};_onPlayerCameraSetAttachedToPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.p=J.position?t.serializeVector(J.position):void 0,delete Z.e};_onPlayerCameraSetFilmOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fo=J.filmOffset};_onPlayerCameraSetForwardOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.ffo=J.forwardOffset};_onPlayerCameraSetFov=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fv=J.fov};_onPlayerCameraSetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.h=Array.from(J.modelHiddenNodes)};_onPlayerCameraSetMode=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.m=J.mode};_onPlayerCameraSetOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onPlayerCameraSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.et=J.entity?J.entity.id:void 0,delete Z.pl,delete Z.pt};_onPlayerCameraSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pt=J.position?t.serializeVector(J.position):void 0,delete Z.et,delete Z.pl};_onPlayerCameraSetZoom=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.z=J.zoom};_onPlayerJoinedWorld=(J)=>{let{player:Z}=J,X=this._queuedPerPlayerSynchronizations.get(Z)??[];X.push(y.createPacket(y.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof d1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.playersPacketDefinition,U1.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let Y=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...Y}),this._queuedPerPlayerSynchronizations.set(Z,X),this._queuedPlayerSynchronizations[Z.id]=Z.serialize()};_onPlayerLeftWorld=(J)=>{let Z=this._createOrGetQueuedPlayerSync(J.player);Z.rm=!0};_onPlayerRequestSync=(J)=>{J.player.connection.send([y.createPacket(y.outboundPackets.syncResponsePacketDefinition,{r:J.receivedAt,s:Date.now(),p:performance.now()-J.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick)])};_onPlayerUILoad=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.u=J.htmlUri};_onPlayerUILockPointer=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.p=J.lock};_onPlayerUISendData=(J)=>{this._createOrGetQueuedPlayerUIDatasSync(J.playerUI).push(J.data)};_onSceneUILoad=(J)=>{let Z=J.sceneUI.serialize();this._queuedSceneUISynchronizations[Z.i]=Z,this._loadedSceneUIs.add(Z.i)};_onSceneUISetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onSceneUISetOffset=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?t.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onSceneUISetState=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.s=J.state};_onSceneUISetViewDistance=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.v=J.viewDistance};_onSceneUIUnload=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);if(this._loadedSceneUIs.has(Z.i))delete this._queuedSceneUISynchronizations[Z.i],this._loadedSceneUIs.delete(Z.i);else Z.rm=!0};_onSimulationDebugRaycast=(J)=>{this._queuedDebugRaycastSynchronizations.push(t.serializePhysicsDebugRaycast(J))};_onSimulationDebugRender=(J)=>{this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(J.vertices),c:Array.from(J.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ac=t.serializeRgbColor(J.color)};_onWorldSetAmbientLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ai=J.intensity};_onWorldSetDirectionalLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dc=t.serializeRgbColor(J.color)};_onWorldSetDirectionalLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.di=J.intensity};_onWorldSetDirectionalLightPosition=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dp=t.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:X,z:Y}=J;return this._queuedBlockSynchronizations[`${Z},${X},${Y}`]??={i:0,c:[Z,X,Y]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)_.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:X,z:Y}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${X},${Y}`]??={c:[Z,X,Y]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");return this._queuedPlayerSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerCameraSync(J){let Z=this._queuedPerPlayerCameraSynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerCameraSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUISync(J){let Z=this._queuedPerPlayerUISynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerUISynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUIDatasSync(J){let Z=this._queuedPerPlayerUIDatasSynchronizations.get(J.player);if(!Z)Z=[],this._queuedPerPlayerUIDatasSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedSceneUISync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)_.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}_createOrGetSynchronizedPlayerPackets(J,Z){let X=this._synchronizedPlayerPackets.get(J);if(!X)X=[...Z],this._synchronizedPlayerPackets.set(J,X);return X}}class _J{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(J){this._world=J}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(J){return this.getAllSceneUIs().filter((Z)=>Z.attachedToEntity===J)}getSceneUIById(J){return this._sceneUIs.get(J)}registerSceneUI(J){if(J.id!==void 0)return J.id;let Z=this._nextSceneUIId;return this._sceneUIs.set(Z,J),this._nextSceneUIId++,Z}unloadEntityAttachedSceneUIs(J){this.getAllEntityAttachedSceneUIs(J).forEach((Z)=>{Z.unload()})}unregisterSceneUI(J){if(J.id===void 0)return;this._sceneUIs.delete(J.id)}}class CJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,X){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=X}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return _.warning("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),X=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,X>250)X=250;this._accumulatorMs+=X;while(this._accumulatorMs>=this._fixedTimestepMs)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs;this._nextTickMs=this._fixedTimestepMs-this._accumulatorMs,this._tickHandle=setTimeout(J,0)};J()}stop(){if(!this._tickHandle)return _.warning("Ticker.stop(): ticker not running.");clearTimeout(this._tickHandle),this._tickHandle=null}_tick(J){try{this._tickFunction(J)}catch(Z){if(Z instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(Z);else _.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${Z}`)}}}var vE;(($)=>{$.START="WORLD_LOOP.START";$.STOP="WORLD_LOOP.STOP";$.TICK_START="WORLD_LOOP.TICK_START";$.TICK_END="WORLD_LOOP.TICK_END";$.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(vE||={});class EJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=LV){super();this._ticker=new CJ(Z,this._tick,this._onTickError),this._world=J}get currentTick(){return this._currentTick}get nextTickMs(){return this._ticker.nextTickMs}get timestepS(){return this._ticker.fixedTimestepS}get world(){return this._world}start(){this._ticker.start(),this.emitWithWorld(this._world,"WORLD_LOOP.START",{worldLoop:this})}stop(){this._ticker.stop(),this.emitWithWorld(this._world,"WORLD_LOOP.STOP",{worldLoop:this})}_tick=(J)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:J});let Z=performance.now();this._world.chunkLattice.updateChunks(),this._world.entityManager.tickEntities(J),this._world.simulation.step(J),this._world.entityManager.checkAndEmitUpdates(),this._world.networkSynchronizer.synchronize(),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-Z})};_onTickError=(J)=>{_.error(`WorldLoop._onTickError(): Error: ${J}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var MV;((G)=>{G.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";G.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";G.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";G.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";G.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";G.START="WORLD.START";G.STOP="WORLD.STOP"})(MV||={});class SJ extends s{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_name;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_sceneUIManager;_simulation;constructor(J){super();this._id=J.id,this._ambientLightColor=J.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=J.ambientLightIntensity??1,this._directionalLightColor=J.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=J.directionalLightIntensity??3,this._directionalLightPosition=J.directionalLightPosition??{x:100,y:150,z:100},this._name=J.name,this._skyboxUri=J.skyboxUri,this._audioManager=new $4(this),this._blockTypeRegistry=new m4(this),this._chatManager=new IJ(this),this._chunkLattice=new OJ(this),this._entityManager=new BJ(this),this._lightManager=new vJ(this),this._loop=new EJ(this,J.tickRate),this._networkSynchronizer=new Q$(this),this._sceneUIManager=new _J(this),this._simulation=new kJ(this,J.tickRate,J.gravity)}get id(){return this._id}get ambientLightColor(){return this._ambientLightColor}get ambientLightIntensity(){return this._ambientLightIntensity}get directionalLightColor(){return this._directionalLightColor}get directionalLightIntensity(){return this._directionalLightIntensity}get directionalLightPosition(){return this._directionalLightPosition}get name(){return this._name}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get blockTypeRegistry(){return this._blockTypeRegistry}get chatManager(){return this._chatManager}get chunkLattice(){return this._chunkLattice}get entityManager(){return this._entityManager}get lightManager(){return this._lightManager}get loop(){return this._loop}get networkSynchronizer(){return this._networkSynchronizer}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(J){if(J.blockTypes)for(let Z of J.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:Z.id,isLiquid:Z.isLiquid,name:Z.name,textureUri:Z.textureUri});if(J.blocks)for(let[Z,X]of Object.entries(J.blocks)){let[Y,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:Y,y:K,z:$},X)}if(J.entities)for(let[Z,X]of Object.entries(J.entities)){let[Y,K,$]=Z.split(",").map(Number);new Z8(X).spawn(this,{x:Y,y:K,z:$})}}setAmbientLightColor(J){this._ambientLightColor=J,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:J})}setAmbientLightIntensity(J){this._ambientLightIntensity=J,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightColor(J){this._directionalLightColor=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:J})}setDirectionalLightIntensity(J){this._directionalLightIntensity=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightPosition(J){this._directionalLightPosition=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:J})}start(){this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return t.serializeWorld(this)}}var jE;((X)=>{X.START="GAMESERVER.START";X.STOP="GAMESERVER.STOP"})(jE||={});function _Z0(J){z0.init().then(()=>{return M1.instance.modelRegistry.preloadModels()}).then(()=>{J(M1.instance.worlds[0]),M1.instance.start()}).catch((Z)=>{_.fatalError(`Failed to initialize the game engine, exiting. Error: ${Z}`)})}class M1{static _instance;_modelRegistry=U6.instance;_playerManager=U1.instance;_socket=wJ.instance;_webServer=o5.instance;_worlds={};constructor(){let J=new SJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new M1;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worlds(){return this._worlds}start(){c8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){c8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class h9{static instance=new h9;constructor(){}async getGlobalData(J){let Z=await m6.instance.getData(J);if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await m6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let X=await m6.instance.setData(J,Z);if(!X||X.error){if(X?.error)_.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(J,Z){let X=await m6.instance.setData(this._getPlayerKey(J),Z);if(!X||X.error){if(X?.error)_.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(J){return`player-${J.id}`}}var TE=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","1","2","3","4","5","6","7","8","9","0"],NJ;((K)=>{K.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";K.JOINED_WORLD="PLAYER.JOINED_WORLD";K.LEFT_WORLD="PLAYER.LEFT_WORLD";K.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(NJ||={});class w5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${w5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new jJ(this),this.connection=J,this.ui=new TJ(this),J.onPacket(y.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),J.onPacket(y.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),J.onPacket(y.PacketId.INPUT,this._onInputPacket),J.onPacket(y.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),J.onPacket(y.PacketId.UI_DATA_SEND,this._onUIDataSendPacket),this.joinWorld(M1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return h9.instance.getPlayerData(this)}joinWorld(J){this.leaveWorld(),this._world=J,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}async setPersistedData(J){return h9.instance.setPlayerData(this,J)}serialize(){return t.serializePlayer(this)}_onChatMessageSendPacket=(J)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:J[1].m})};_onDebugConfigPacket=(J)=>{console.log(J)};_onInputPacket=(J)=>{let Z=J[1];if(TE.forEach((X)=>{let Y=X;if(Z[Y]!==void 0)this._input[Y]=Boolean(Z[Y])}),Z.cp!==void 0)this.camera.setOrientationPitch(Z.cp);if(Z.cy!==void 0)this.camera.setOrientationYaw(Z.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(J)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:J[1]})}}var wV;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(wV||={});class IJ extends s{_commandCallbacks={};_world;constructor(J){super();this._world=J,this._subscribeToPlayerEvents()}registerCommand(J,Z){this._commandCallbacks[J]=Z}unregisterCommand(J){delete this._commandCallbacks[J]}sendBroadcastMessage(J,Z){this._sendBroadcastMessage(void 0,J,Z)}sendPlayerMessage(J,Z,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:X}=J,[Y,...K]=X.split(" "),$=this._commandCallbacks[Y];if($){$(Z,K,X);return}this._sendBroadcastMessage(Z,X)})}_sendBroadcastMessage(J,Z,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:X})}}var m=0.000001,Q0=typeof Float32Array!=="undefined"?Float32Array:Array,l6=Math.random;var fk0=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var J=0,Z=arguments.length;while(Z--)J+=arguments[Z]*arguments[Z];return Math.sqrt(J)};var t0={};n6(t0,{transpose:()=>bZ0,subtract:()=>kE,sub:()=>eZ0,str:()=>uZ0,set:()=>hZ0,scale:()=>cZ0,rotate:()=>gZ0,multiplyScalarAndAdd:()=>rZ0,multiplyScalar:()=>oZ0,multiply:()=>DE,mul:()=>tZ0,invert:()=>AZ0,identity:()=>IZ0,fromValues:()=>fZ0,fromScaling:()=>lZ0,fromRotation:()=>mZ0,frob:()=>dZ0,exactEquals:()=>aZ0,equals:()=>sZ0,determinant:()=>yZ0,create:()=>CZ0,copy:()=>SZ0,clone:()=>EZ0,adjoint:()=>pZ0,add:()=>nZ0,LDU:()=>iZ0});function CZ0(){var J=new Q0(4);if(Q0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function EZ0(J){var Z=new Q0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function SZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function IZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function fZ0(J,Z,X,Y){var K=new Q0(4);return K[0]=J,K[1]=Z,K[2]=X,K[3]=Y,K}function hZ0(J,Z,X,Y,K){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J}function bZ0(J,Z){if(J===Z){var X=Z[1];J[1]=Z[2],J[2]=X}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function AZ0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*$-K*Y;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-Y*Q,J[2]=-K*Q,J[3]=X*Q,J}function pZ0(J,Z){var X=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=X,J}function yZ0(J){return J[0]*J[3]-J[2]*J[1]}function DE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1],W=X[2],q=X[3];return J[0]=Y*G+$*F,J[1]=K*G+Q*F,J[2]=Y*W+$*q,J[3]=K*W+Q*q,J}function gZ0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+$*G,J[1]=K*F+Q*G,J[2]=Y*-G+$*F,J[3]=K*-G+Q*F,J}function cZ0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1];return J[0]=Y*G,J[1]=K*G,J[2]=$*F,J[3]=Q*F,J}function mZ0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=-X,J[3]=Y,J}function lZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function uZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function dZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function iZ0(J,Z,X,Y){return J[2]=Y[2]/Y[0],X[0]=Y[0],X[1]=Y[1],X[3]=Y[3]-J[2]*X[1],[J,Z,X]}function nZ0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J}function kE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J}function aZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function sZ0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=Z[0],G=Z[1],F=Z[2],W=Z[3];return Math.abs(X-Q)<=m*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-G)<=m*Math.max(1,Math.abs(Y),Math.abs(G))&&Math.abs(K-F)<=m*Math.max(1,Math.abs(K),Math.abs(F))&&Math.abs($-W)<=m*Math.max(1,Math.abs($),Math.abs(W))}function oZ0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J}function rZ0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J}var tZ0=DE,eZ0=kE;var I0={};n6(I0,{transpose:()=>QX0,translate:()=>qX0,subtract:()=>CE,sub:()=>kX0,str:()=>xX0,set:()=>KX0,scale:()=>zX0,rotate:()=>VX0,projection:()=>OX0,normalFromMat4:()=>wX0,multiplyScalarAndAdd:()=>vX0,multiplyScalar:()=>BX0,multiply:()=>_E,mul:()=>DX0,invert:()=>GX0,identity:()=>$X0,fromValues:()=>YX0,fromTranslation:()=>HX0,fromScaling:()=>LX0,fromRotation:()=>UX0,fromQuat:()=>MX0,fromMat4:()=>JX0,fromMat2d:()=>RX0,frob:()=>PX0,exactEquals:()=>jX0,equals:()=>TX0,determinant:()=>WX0,create:()=>OV,copy:()=>XX0,clone:()=>ZX0,adjoint:()=>FX0,add:()=>NX0});function OV(){var J=new Q0(9);if(Q0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[5]=0,J[6]=0,J[7]=0;return J[0]=1,J[4]=1,J[8]=1,J}function JX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[4],J[4]=Z[5],J[5]=Z[6],J[6]=Z[8],J[7]=Z[9],J[8]=Z[10],J}function ZX0(J){var Z=new Q0(9);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z}function XX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function YX0(J,Z,X,Y,K,$,Q,G,F){var W=new Q0(9);return W[0]=J,W[1]=Z,W[2]=X,W[3]=Y,W[4]=K,W[5]=$,W[6]=Q,W[7]=G,W[8]=F,W}function KX0(J,Z,X,Y,K,$,Q,G,F,W){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J[4]=$,J[5]=Q,J[6]=G,J[7]=F,J[8]=W,J}function $X0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function QX0(J,Z){if(J===Z){var X=Z[1],Y=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=X,J[5]=Z[7],J[6]=Y,J[7]=K}else J[0]=Z[0],J[1]=Z[3],J[2]=Z[6],J[3]=Z[1],J[4]=Z[4],J[5]=Z[7],J[6]=Z[2],J[7]=Z[5],J[8]=Z[8];return J}function GX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=q*Q-G*W,z=-q*$+G*F,L=W*$-Q*F,R=X*V+Y*z+K*L;if(!R)return null;return R=1/R,J[0]=V*R,J[1]=(-q*Y+K*W)*R,J[2]=(G*Y-K*Q)*R,J[3]=z*R,J[4]=(q*X-K*F)*R,J[5]=(-G*X+K*$)*R,J[6]=L*R,J[7]=(-W*X+Y*F)*R,J[8]=(Q*X-Y*$)*R,J}function FX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8];return J[0]=Q*q-G*W,J[1]=K*W-Y*q,J[2]=Y*G-K*Q,J[3]=G*F-$*q,J[4]=X*q-K*F,J[5]=K*$-X*G,J[6]=$*W-Q*F,J[7]=Y*F-X*W,J[8]=X*Q-Y*$,J}function WX0(J){var Z=J[0],X=J[1],Y=J[2],K=J[3],$=J[4],Q=J[5],G=J[6],F=J[7],W=J[8];return Z*(W*$-Q*F)+X*(-W*K+Q*G)+Y*(F*K-$*G)}function _E(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=X[0],L=X[1],R=X[2],M=X[3],H=X[4],O=X[5],P=X[6],N=X[7],B=X[8];return J[0]=z*Y+L*Q+R*W,J[1]=z*K+L*G+R*q,J[2]=z*$+L*F+R*V,J[3]=M*Y+H*Q+O*W,J[4]=M*K+H*G+O*q,J[5]=M*$+H*F+O*V,J[6]=P*Y+N*Q+B*W,J[7]=P*K+N*G+B*q,J[8]=P*$+N*F+B*V,J}function qX0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=X[0],L=X[1];return J[0]=Y,J[1]=K,J[2]=$,J[3]=Q,J[4]=G,J[5]=F,J[6]=z*Y+L*Q+W,J[7]=z*K+L*G+q,J[8]=z*$+L*F+V,J}function VX0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=Math.sin(X),L=Math.cos(X);return J[0]=L*Y+z*Q,J[1]=L*K+z*G,J[2]=L*$+z*F,J[3]=L*Q-z*Y,J[4]=L*G-z*K,J[5]=L*F-z*$,J[6]=W,J[7]=q,J[8]=V,J}function zX0(J,Z,X){var Y=X[0],K=X[1];return J[0]=Y*Z[0],J[1]=Y*Z[1],J[2]=Y*Z[2],J[3]=K*Z[3],J[4]=K*Z[4],J[5]=K*Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function HX0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=Z[0],J[7]=Z[1],J[8]=1,J}function UX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=0,J[3]=-X,J[4]=Y,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function LX0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=Z[1],J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function RX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=0,J[3]=Z[2],J[4]=Z[3],J[5]=0,J[6]=Z[4],J[7]=Z[5],J[8]=1,J}function MX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X+X,G=Y+Y,F=K+K,W=X*Q,q=Y*Q,V=Y*G,z=K*Q,L=K*G,R=K*F,M=$*Q,H=$*G,O=$*F;return J[0]=1-V-R,J[3]=q-O,J[6]=z+H,J[1]=q+O,J[4]=1-W-R,J[7]=L-M,J[2]=z-H,J[5]=L+M,J[8]=1-W-V,J}function wX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15],P=X*G-Y*Q,N=X*F-K*Q,B=X*W-$*Q,j=Y*F-K*G,w=Y*W-$*G,k=K*W-$*F,C=q*M-V*R,E=q*H-z*R,S=q*O-L*R,I=V*H-z*M,h=V*O-L*M,p=z*O-L*H,f=P*p-N*h+B*I+j*S-w*E+k*C;if(!f)return null;return f=1/f,J[0]=(G*p-F*h+W*I)*f,J[1]=(F*S-Q*p-W*E)*f,J[2]=(Q*h-G*S+W*C)*f,J[3]=(K*h-Y*p-$*I)*f,J[4]=(X*p-K*S+$*E)*f,J[5]=(Y*S-X*h-$*C)*f,J[6]=(M*k-H*w+O*j)*f,J[7]=(H*B-R*k-O*N)*f,J[8]=(R*w-M*B+O*P)*f,J}function OX0(J,Z,X){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/X,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function xX0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function PX0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function NX0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J[4]=Z[4]+X[4],J[5]=Z[5]+X[5],J[6]=Z[6]+X[6],J[7]=Z[7]+X[7],J[8]=Z[8]+X[8],J}function CE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J[4]=Z[4]-X[4],J[5]=Z[5]-X[5],J[6]=Z[6]-X[6],J[7]=Z[7]-X[7],J[8]=Z[8]-X[8],J}function BX0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*X,J[5]=Z[5]*X,J[6]=Z[6]*X,J[7]=Z[7]*X,J[8]=Z[8]*X,J}function vX0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J[4]=Z[4]+X[4]*Y,J[5]=Z[5]+X[5]*Y,J[6]=Z[6]+X[6]*Y,J[7]=Z[7]+X[7]*Y,J[8]=Z[8]+X[8]*Y,J}function jX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]}function TX0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=J[4],G=J[5],F=J[6],W=J[7],q=J[8],V=Z[0],z=Z[1],L=Z[2],R=Z[3],M=Z[4],H=Z[5],O=Z[6],P=Z[7],N=Z[8];return Math.abs(X-V)<=m*Math.max(1,Math.abs(X),Math.abs(V))&&Math.abs(Y-z)<=m*Math.max(1,Math.abs(Y),Math.abs(z))&&Math.abs(K-L)<=m*Math.max(1,Math.abs(K),Math.abs(L))&&Math.abs($-R)<=m*Math.max(1,Math.abs($),Math.abs(R))&&Math.abs(Q-M)<=m*Math.max(1,Math.abs(Q),Math.abs(M))&&Math.abs(G-H)<=m*Math.max(1,Math.abs(G),Math.abs(H))&&Math.abs(F-O)<=m*Math.max(1,Math.abs(F),Math.abs(O))&&Math.abs(W-P)<=m*Math.max(1,Math.abs(W),Math.abs(P))&&Math.abs(q-N)<=m*Math.max(1,Math.abs(q),Math.abs(N))}var DX0=_E,kX0=CE;var X0={};n6(X0,{transpose:()=>fX0,translate:()=>pX0,targetTo:()=>WY0,subtract:()=>AE,sub:()=>wY0,str:()=>qY0,set:()=>IX0,scale:()=>yX0,rotateZ:()=>lX0,rotateY:()=>mX0,rotateX:()=>cX0,rotate:()=>gX0,perspectiveZO:()=>KY0,perspectiveNO:()=>hE,perspectiveFromFieldOfView:()=>$Y0,perspective:()=>YY0,orthoZO:()=>GY0,orthoNO:()=>bE,ortho:()=>QY0,multiplyScalarAndAdd:()=>UY0,multiplyScalar:()=>HY0,multiply:()=>SE,mul:()=>MY0,lookAt:()=>FY0,invert:()=>hX0,identity:()=>EE,getTranslation:()=>rX0,getScaling:()=>fE,getRotation:()=>tX0,frustum:()=>XY0,fromZRotation:()=>sX0,fromYRotation:()=>aX0,fromXRotation:()=>nX0,fromValues:()=>SX0,fromTranslation:()=>uX0,fromScaling:()=>dX0,fromRotationTranslationScaleOrigin:()=>JY0,fromRotationTranslationScale:()=>eX0,fromRotationTranslation:()=>IE,fromRotation:()=>iX0,fromQuat2:()=>oX0,fromQuat:()=>ZY0,frob:()=>VY0,exactEquals:()=>LY0,equals:()=>RY0,determinant:()=>AX0,create:()=>_X0,copy:()=>EX0,clone:()=>CX0,adjoint:()=>bX0,add:()=>zY0});function _X0(){var J=new Q0(16);if(Q0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=0,J[12]=0,J[13]=0,J[14]=0;return J[0]=1,J[5]=1,J[10]=1,J[15]=1,J}function CX0(J){var Z=new Q0(16);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z[9]=J[9],Z[10]=J[10],Z[11]=J[11],Z[12]=J[12],Z[13]=J[13],Z[14]=J[14],Z[15]=J[15],Z}function EX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function SX0(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M){var H=new Q0(16);return H[0]=J,H[1]=Z,H[2]=X,H[3]=Y,H[4]=K,H[5]=$,H[6]=Q,H[7]=G,H[8]=F,H[9]=W,H[10]=q,H[11]=V,H[12]=z,H[13]=L,H[14]=R,H[15]=M,H}function IX0(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M,H){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J[4]=$,J[5]=Q,J[6]=G,J[7]=F,J[8]=W,J[9]=q,J[10]=V,J[11]=z,J[12]=L,J[13]=R,J[14]=M,J[15]=H,J}function EE(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function fX0(J,Z){if(J===Z){var X=Z[1],Y=Z[2],K=Z[3],$=Z[6],Q=Z[7],G=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=X,J[6]=Z[9],J[7]=Z[13],J[8]=Y,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=G}else J[0]=Z[0],J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Z[1],J[5]=Z[5],J[6]=Z[9],J[7]=Z[13],J[8]=Z[2],J[9]=Z[6],J[10]=Z[10],J[11]=Z[14],J[12]=Z[3],J[13]=Z[7],J[14]=Z[11],J[15]=Z[15];return J}function hX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15],P=X*G-Y*Q,N=X*F-K*Q,B=X*W-$*Q,j=Y*F-K*G,w=Y*W-$*G,k=K*W-$*F,C=q*M-V*R,E=q*H-z*R,S=q*O-L*R,I=V*H-z*M,h=V*O-L*M,p=z*O-L*H,f=P*p-N*h+B*I+j*S-w*E+k*C;if(!f)return null;return f=1/f,J[0]=(G*p-F*h+W*I)*f,J[1]=(K*h-Y*p-$*I)*f,J[2]=(M*k-H*w+O*j)*f,J[3]=(z*w-V*k-L*j)*f,J[4]=(F*S-Q*p-W*E)*f,J[5]=(X*p-K*S+$*E)*f,J[6]=(H*B-R*k-O*N)*f,J[7]=(q*k-z*B+L*N)*f,J[8]=(Q*h-G*S+W*C)*f,J[9]=(Y*S-X*h-$*C)*f,J[10]=(R*w-M*B+O*P)*f,J[11]=(V*B-q*w-L*P)*f,J[12]=(G*E-Q*I-F*C)*f,J[13]=(X*I-Y*E+K*C)*f,J[14]=(M*N-R*j-H*P)*f,J[15]=(q*j-V*N+z*P)*f,J}function bX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15];return J[0]=G*(z*O-L*H)-V*(F*O-W*H)+M*(F*L-W*z),J[1]=-(Y*(z*O-L*H)-V*(K*O-$*H)+M*(K*L-$*z)),J[2]=Y*(F*O-W*H)-G*(K*O-$*H)+M*(K*W-$*F),J[3]=-(Y*(F*L-W*z)-G*(K*L-$*z)+V*(K*W-$*F)),J[4]=-(Q*(z*O-L*H)-q*(F*O-W*H)+R*(F*L-W*z)),J[5]=X*(z*O-L*H)-q*(K*O-$*H)+R*(K*L-$*z),J[6]=-(X*(F*O-W*H)-Q*(K*O-$*H)+R*(K*W-$*F)),J[7]=X*(F*L-W*z)-Q*(K*L-$*z)+q*(K*W-$*F),J[8]=Q*(V*O-L*M)-q*(G*O-W*M)+R*(G*L-W*V),J[9]=-(X*(V*O-L*M)-q*(Y*O-$*M)+R*(Y*L-$*V)),J[10]=X*(G*O-W*M)-Q*(Y*O-$*M)+R*(Y*W-$*G),J[11]=-(X*(G*L-W*V)-Q*(Y*L-$*V)+q*(Y*W-$*G)),J[12]=-(Q*(V*H-z*M)-q*(G*H-F*M)+R*(G*z-F*V)),J[13]=X*(V*H-z*M)-q*(Y*H-K*M)+R*(Y*z-K*V),J[14]=-(X*(G*H-F*M)-Q*(Y*H-K*M)+R*(Y*F-K*G)),J[15]=X*(G*z-F*V)-Q*(Y*z-K*V)+q*(Y*F-K*G),J}function AX0(J){var Z=J[0],X=J[1],Y=J[2],K=J[3],$=J[4],Q=J[5],G=J[6],F=J[7],W=J[8],q=J[9],V=J[10],z=J[11],L=J[12],R=J[13],M=J[14],H=J[15],O=Z*Q-X*$,P=Z*G-Y*$,N=Z*F-K*$,B=X*G-Y*Q,j=X*F-K*Q,w=Y*F-K*G,k=W*R-q*L,C=W*M-V*L,E=W*H-z*L,S=q*M-V*R,I=q*H-z*R,h=V*H-z*M;return O*h-P*I+N*S+B*E-j*C+w*k}function SE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=Z[9],L=Z[10],R=Z[11],M=Z[12],H=Z[13],O=Z[14],P=Z[15],N=X[0],B=X[1],j=X[2],w=X[3];return J[0]=N*Y+B*G+j*V+w*M,J[1]=N*K+B*F+j*z+w*H,J[2]=N*$+B*W+j*L+w*O,J[3]=N*Q+B*q+j*R+w*P,N=X[4],B=X[5],j=X[6],w=X[7],J[4]=N*Y+B*G+j*V+w*M,J[5]=N*K+B*F+j*z+w*H,J[6]=N*$+B*W+j*L+w*O,J[7]=N*Q+B*q+j*R+w*P,N=X[8],B=X[9],j=X[10],w=X[11],J[8]=N*Y+B*G+j*V+w*M,J[9]=N*K+B*F+j*z+w*H,J[10]=N*$+B*W+j*L+w*O,J[11]=N*Q+B*q+j*R+w*P,N=X[12],B=X[13],j=X[14],w=X[15],J[12]=N*Y+B*G+j*V+w*M,J[13]=N*K+B*F+j*z+w*H,J[14]=N*$+B*W+j*L+w*O,J[15]=N*Q+B*q+j*R+w*P,J}function pX0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q,G,F,W,q,V,z,L,R,M,H,O;if(Z===J)J[12]=Z[0]*Y+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*Y+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*Y+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*Y+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],G=Z[1],F=Z[2],W=Z[3],q=Z[4],V=Z[5],z=Z[6],L=Z[7],R=Z[8],M=Z[9],H=Z[10],O=Z[11],J[0]=Q,J[1]=G,J[2]=F,J[3]=W,J[4]=q,J[5]=V,J[6]=z,J[7]=L,J[8]=R,J[9]=M,J[10]=H,J[11]=O,J[12]=Q*Y+q*K+R*$+Z[12],J[13]=G*Y+V*K+M*$+Z[13],J[14]=F*Y+z*K+H*$+Z[14],J[15]=W*Y+L*K+O*$+Z[15];return J}function yX0(J,Z,X){var Y=X[0],K=X[1],$=X[2];return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*K,J[5]=Z[5]*K,J[6]=Z[6]*K,J[7]=Z[7]*K,J[8]=Z[8]*$,J[9]=Z[9]*$,J[10]=Z[10]*$,J[11]=Z[11]*$,J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function gX0(J,Z,X,Y){var K=Y[0],$=Y[1],Q=Y[2],G=Math.hypot(K,$,Q),F,W,q,V,z,L,R,M,H,O,P,N,B,j,w,k,C,E,S,I,h,p,f,g;if(G<m)return null;if(G=1/G,K*=G,$*=G,Q*=G,F=Math.sin(X),W=Math.cos(X),q=1-W,V=Z[0],z=Z[1],L=Z[2],R=Z[3],M=Z[4],H=Z[5],O=Z[6],P=Z[7],N=Z[8],B=Z[9],j=Z[10],w=Z[11],k=K*K*q+W,C=$*K*q+Q*F,E=Q*K*q-$*F,S=K*$*q-Q*F,I=$*$*q+W,h=Q*$*q+K*F,p=K*Q*q+$*F,f=$*Q*q-K*F,g=Q*Q*q+W,J[0]=V*k+M*C+N*E,J[1]=z*k+H*C+B*E,J[2]=L*k+O*C+j*E,J[3]=R*k+P*C+w*E,J[4]=V*S+M*I+N*h,J[5]=z*S+H*I+B*h,J[6]=L*S+O*I+j*h,J[7]=R*S+P*I+w*h,J[8]=V*p+M*f+N*g,J[9]=z*p+H*f+B*g,J[10]=L*p+O*f+j*g,J[11]=R*p+P*f+w*g,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function cX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[4],Q=Z[5],G=Z[6],F=Z[7],W=Z[8],q=Z[9],V=Z[10],z=Z[11];if(Z!==J)J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[4]=$*K+W*Y,J[5]=Q*K+q*Y,J[6]=G*K+V*Y,J[7]=F*K+z*Y,J[8]=W*K-$*Y,J[9]=q*K-Q*Y,J[10]=V*K-G*Y,J[11]=z*K-F*Y,J}function mX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=Z[8],q=Z[9],V=Z[10],z=Z[11];if(Z!==J)J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K-W*Y,J[1]=Q*K-q*Y,J[2]=G*K-V*Y,J[3]=F*K-z*Y,J[8]=$*Y+W*K,J[9]=Q*Y+q*K,J[10]=G*Y+V*K,J[11]=F*Y+z*K,J}function lX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=Z[4],q=Z[5],V=Z[6],z=Z[7];if(Z!==J)J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K+W*Y,J[1]=Q*K+q*Y,J[2]=G*K+V*Y,J[3]=F*K+z*Y,J[4]=W*K-$*Y,J[5]=q*K-Q*Y,J[6]=V*K-G*Y,J[7]=z*K-F*Y,J}function uX0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=Z[0],J[13]=Z[1],J[14]=Z[2],J[15]=1,J}function dX0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Z[1],J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=Z[2],J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iX0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q=Math.hypot(Y,K,$),G,F,W;if(Q<m)return null;return Q=1/Q,Y*=Q,K*=Q,$*=Q,G=Math.sin(Z),F=Math.cos(Z),W=1-F,J[0]=Y*Y*W+F,J[1]=K*Y*W+$*G,J[2]=$*Y*W-K*G,J[3]=0,J[4]=Y*K*W-$*G,J[5]=K*K*W+F,J[6]=$*K*W+Y*G,J[7]=0,J[8]=Y*$*W+K*G,J[9]=K*$*W-Y*G,J[10]=$*$*W+F,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function nX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Y,J[6]=X,J[7]=0,J[8]=0,J[9]=-X,J[10]=Y,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function aX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=0,J[2]=-X,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=X,J[9]=0,J[10]=Y,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function sX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=0,J[3]=0,J[4]=-X,J[5]=Y,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function IE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Y+Y,F=K+K,W=$+$,q=Y*G,V=Y*F,z=Y*W,L=K*F,R=K*W,M=$*W,H=Q*G,O=Q*F,P=Q*W;return J[0]=1-(L+M),J[1]=V+P,J[2]=z-O,J[3]=0,J[4]=V-P,J[5]=1-(q+M),J[6]=R+H,J[7]=0,J[8]=z+O,J[9]=R-H,J[10]=1-(q+L),J[11]=0,J[12]=X[0],J[13]=X[1],J[14]=X[2],J[15]=1,J}function oX0(J,Z){var X=new Q0(3),Y=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Y*Y+K*K+$*$+Q*Q;if(V>0)X[0]=(G*Q+q*Y+F*$-W*K)*2/V,X[1]=(F*Q+q*K+W*Y-G*$)*2/V,X[2]=(W*Q+q*$+G*K-F*Y)*2/V;else X[0]=(G*Q+q*Y+F*$-W*K)*2,X[1]=(F*Q+q*K+W*Y-G*$)*2,X[2]=(W*Q+q*$+G*K-F*Y)*2;return IE(J,Z,X),J}function rX0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function fE(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[4],Q=Z[5],G=Z[6],F=Z[8],W=Z[9],q=Z[10];return J[0]=Math.hypot(X,Y,K),J[1]=Math.hypot($,Q,G),J[2]=Math.hypot(F,W,q),J}function tX0(J,Z){var X=new Q0(3);fE(X,Z);var Y=1/X[0],K=1/X[1],$=1/X[2],Q=Z[0]*Y,G=Z[1]*K,F=Z[2]*$,W=Z[4]*Y,q=Z[5]*K,V=Z[6]*$,z=Z[8]*Y,L=Z[9]*K,R=Z[10]*$,M=Q+q+R,H=0;if(M>0)H=Math.sqrt(M+1)*2,J[3]=0.25*H,J[0]=(V-L)/H,J[1]=(z-F)/H,J[2]=(G-W)/H;else if(Q>q&&Q>R)H=Math.sqrt(1+Q-q-R)*2,J[3]=(V-L)/H,J[0]=0.25*H,J[1]=(G+W)/H,J[2]=(z+F)/H;else if(q>R)H=Math.sqrt(1+q-Q-R)*2,J[3]=(z-F)/H,J[0]=(G+W)/H,J[1]=0.25*H,J[2]=(V+L)/H;else H=Math.sqrt(1+R-Q-q)*2,J[3]=(G-W)/H,J[0]=(z+F)/H,J[1]=(V+L)/H,J[2]=0.25*H;return J}function eX0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3],F=K+K,W=$+$,q=Q+Q,V=K*F,z=K*W,L=K*q,R=$*W,M=$*q,H=Q*q,O=G*F,P=G*W,N=G*q,B=Y[0],j=Y[1],w=Y[2];return J[0]=(1-(R+H))*B,J[1]=(z+N)*B,J[2]=(L-P)*B,J[3]=0,J[4]=(z-N)*j,J[5]=(1-(V+H))*j,J[6]=(M+O)*j,J[7]=0,J[8]=(L+P)*w,J[9]=(M-O)*w,J[10]=(1-(V+R))*w,J[11]=0,J[12]=X[0],J[13]=X[1],J[14]=X[2],J[15]=1,J}function JY0(J,Z,X,Y,K){var $=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=$+$,q=Q+Q,V=G+G,z=$*W,L=$*q,R=$*V,M=Q*q,H=Q*V,O=G*V,P=F*W,N=F*q,B=F*V,j=Y[0],w=Y[1],k=Y[2],C=K[0],E=K[1],S=K[2],I=(1-(M+O))*j,h=(L+B)*j,p=(R-N)*j,f=(L-B)*w,g=(1-(z+O))*w,J0=(H+P)*w,A0=(R+N)*k,d0=(H-P)*k,Q6=(1-(z+M))*k;return J[0]=I,J[1]=h,J[2]=p,J[3]=0,J[4]=f,J[5]=g,J[6]=J0,J[7]=0,J[8]=A0,J[9]=d0,J[10]=Q6,J[11]=0,J[12]=X[0]+C-(I*C+f*E+A0*S),J[13]=X[1]+E-(h*C+g*E+d0*S),J[14]=X[2]+S-(p*C+J0*E+Q6*S),J[15]=1,J}function ZY0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X+X,G=Y+Y,F=K+K,W=X*Q,q=Y*Q,V=Y*G,z=K*Q,L=K*G,R=K*F,M=$*Q,H=$*G,O=$*F;return J[0]=1-V-R,J[1]=q+O,J[2]=z-H,J[3]=0,J[4]=q-O,J[5]=1-W-R,J[6]=L+M,J[7]=0,J[8]=z+H,J[9]=L-M,J[10]=1-W-V,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function XY0(J,Z,X,Y,K,$,Q){var G=1/(X-Z),F=1/(K-Y),W=1/($-Q);return J[0]=$*2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*F,J[6]=0,J[7]=0,J[8]=(X+Z)*G,J[9]=(K+Y)*F,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function hE(J,Z,X,Y,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/X,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(Y-K),J[10]=(K+Y)*Q,J[14]=2*K*Y*Q;else J[10]=-1,J[14]=-2*Y;return J}var YY0=hE;function KY0(J,Z,X,Y,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/X,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(Y-K),J[10]=K*Q,J[14]=K*Y*Q;else J[10]=-1,J[14]=-Y;return J}function $Y0(J,Z,X,Y){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),G=Math.tan(Z.rightDegrees*Math.PI/180),F=2/(Q+G),W=2/(K+$);return J[0]=F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-G)*F*0.5),J[9]=(K-$)*W*0.5,J[10]=Y/(X-Y),J[11]=-1,J[12]=0,J[13]=0,J[14]=Y*X/(X-Y),J[15]=0,J}function bE(J,Z,X,Y,K,$,Q){var G=1/(Z-X),F=1/(Y-K),W=1/($-Q);return J[0]=-2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*F,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+X)*G,J[13]=(K+Y)*F,J[14]=(Q+$)*W,J[15]=1,J}var QY0=bE;function GY0(J,Z,X,Y,K,$,Q){var G=1/(Z-X),F=1/(Y-K),W=1/($-Q);return J[0]=-2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*F,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+X)*G,J[13]=(K+Y)*F,J[14]=$*W,J[15]=1,J}function FY0(J,Z,X,Y){var K,$,Q,G,F,W,q,V,z,L,R=Z[0],M=Z[1],H=Z[2],O=Y[0],P=Y[1],N=Y[2],B=X[0],j=X[1],w=X[2];if(Math.abs(R-B)<m&&Math.abs(M-j)<m&&Math.abs(H-w)<m)return EE(J);if(q=R-B,V=M-j,z=H-w,L=1/Math.hypot(q,V,z),q*=L,V*=L,z*=L,K=P*z-N*V,$=N*q-O*z,Q=O*V-P*q,L=Math.hypot(K,$,Q),!L)K=0,$=0,Q=0;else L=1/L,K*=L,$*=L,Q*=L;if(G=V*Q-z*$,F=z*K-q*Q,W=q*$-V*K,L=Math.hypot(G,F,W),!L)G=0,F=0,W=0;else L=1/L,G*=L,F*=L,W*=L;return J[0]=K,J[1]=G,J[2]=q,J[3]=0,J[4]=$,J[5]=F,J[6]=V,J[7]=0,J[8]=Q,J[9]=W,J[10]=z,J[11]=0,J[12]=-(K*R+$*M+Q*H),J[13]=-(G*R+F*M+W*H),J[14]=-(q*R+V*M+z*H),J[15]=1,J}function WY0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Y[0],F=Y[1],W=Y[2],q=K-X[0],V=$-X[1],z=Q-X[2],L=q*q+V*V+z*z;if(L>0)L=1/Math.sqrt(L),q*=L,V*=L,z*=L;var R=F*z-W*V,M=W*q-G*z,H=G*V-F*q;if(L=R*R+M*M+H*H,L>0)L=1/Math.sqrt(L),R*=L,M*=L,H*=L;return J[0]=R,J[1]=M,J[2]=H,J[3]=0,J[4]=V*H-z*M,J[5]=z*R-q*H,J[6]=q*M-V*R,J[7]=0,J[8]=q,J[9]=V,J[10]=z,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function qY0(J){return"mat4("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+", "+J[9]+", "+J[10]+", "+J[11]+", "+J[12]+", "+J[13]+", "+J[14]+", "+J[15]+")"}function VY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8],J[9],J[10],J[11],J[12],J[13],J[14],J[15])}function zY0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J[4]=Z[4]+X[4],J[5]=Z[5]+X[5],J[6]=Z[6]+X[6],J[7]=Z[7]+X[7],J[8]=Z[8]+X[8],J[9]=Z[9]+X[9],J[10]=Z[10]+X[10],J[11]=Z[11]+X[11],J[12]=Z[12]+X[12],J[13]=Z[13]+X[13],J[14]=Z[14]+X[14],J[15]=Z[15]+X[15],J}function AE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J[4]=Z[4]-X[4],J[5]=Z[5]-X[5],J[6]=Z[6]-X[6],J[7]=Z[7]-X[7],J[8]=Z[8]-X[8],J[9]=Z[9]-X[9],J[10]=Z[10]-X[10],J[11]=Z[11]-X[11],J[12]=Z[12]-X[12],J[13]=Z[13]-X[13],J[14]=Z[14]-X[14],J[15]=Z[15]-X[15],J}function HY0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*X,J[5]=Z[5]*X,J[6]=Z[6]*X,J[7]=Z[7]*X,J[8]=Z[8]*X,J[9]=Z[9]*X,J[10]=Z[10]*X,J[11]=Z[11]*X,J[12]=Z[12]*X,J[13]=Z[13]*X,J[14]=Z[14]*X,J[15]=Z[15]*X,J}function UY0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J[4]=Z[4]+X[4]*Y,J[5]=Z[5]+X[5]*Y,J[6]=Z[6]+X[6]*Y,J[7]=Z[7]+X[7]*Y,J[8]=Z[8]+X[8]*Y,J[9]=Z[9]+X[9]*Y,J[10]=Z[10]+X[10]*Y,J[11]=Z[11]+X[11]*Y,J[12]=Z[12]+X[12]*Y,J[13]=Z[13]+X[13]*Y,J[14]=Z[14]+X[14]*Y,J[15]=Z[15]+X[15]*Y,J}function LY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]&&J[9]===Z[9]&&J[10]===Z[10]&&J[11]===Z[11]&&J[12]===Z[12]&&J[13]===Z[13]&&J[14]===Z[14]&&J[15]===Z[15]}function RY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=J[4],G=J[5],F=J[6],W=J[7],q=J[8],V=J[9],z=J[10],L=J[11],R=J[12],M=J[13],H=J[14],O=J[15],P=Z[0],N=Z[1],B=Z[2],j=Z[3],w=Z[4],k=Z[5],C=Z[6],E=Z[7],S=Z[8],I=Z[9],h=Z[10],p=Z[11],f=Z[12],g=Z[13],J0=Z[14],A0=Z[15];return Math.abs(X-P)<=m*Math.max(1,Math.abs(X),Math.abs(P))&&Math.abs(Y-N)<=m*Math.max(1,Math.abs(Y),Math.abs(N))&&Math.abs(K-B)<=m*Math.max(1,Math.abs(K),Math.abs(B))&&Math.abs($-j)<=m*Math.max(1,Math.abs($),Math.abs(j))&&Math.abs(Q-w)<=m*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(G-k)<=m*Math.max(1,Math.abs(G),Math.abs(k))&&Math.abs(F-C)<=m*Math.max(1,Math.abs(F),Math.abs(C))&&Math.abs(W-E)<=m*Math.max(1,Math.abs(W),Math.abs(E))&&Math.abs(q-S)<=m*Math.max(1,Math.abs(q),Math.abs(S))&&Math.abs(V-I)<=m*Math.max(1,Math.abs(V),Math.abs(I))&&Math.abs(z-h)<=m*Math.max(1,Math.abs(z),Math.abs(h))&&Math.abs(L-p)<=m*Math.max(1,Math.abs(L),Math.abs(p))&&Math.abs(R-f)<=m*Math.max(1,Math.abs(R),Math.abs(f))&&Math.abs(M-g)<=m*Math.max(1,Math.abs(M),Math.abs(g))&&Math.abs(H-J0)<=m*Math.max(1,Math.abs(H),Math.abs(J0))&&Math.abs(O-A0)<=m*Math.max(1,Math.abs(O),Math.abs(A0))}var MY0=SE,wY0=AE;var N0={};n6(N0,{str:()=>UK0,squaredLength:()=>zS,sqrLen:()=>BK0,sqlerp:()=>DK0,slerp:()=>q$,setAxisAngle:()=>KS,setAxes:()=>kK0,set:()=>wK0,scale:()=>WS,rotationTo:()=>TK0,rotateZ:()=>GK0,rotateY:()=>QK0,rotateX:()=>$K0,random:()=>qK0,pow:()=>WK0,normalize:()=>BV,multiply:()=>$S,mul:()=>xK0,ln:()=>GS,lerp:()=>PK0,length:()=>VS,len:()=>NK0,invert:()=>VK0,identity:()=>XK0,getAxisAngle:()=>YK0,getAngle:()=>KK0,fromValues:()=>RK0,fromMat3:()=>FS,fromEuler:()=>HK0,exp:()=>QS,exactEquals:()=>vK0,equals:()=>jK0,dot:()=>qS,create:()=>NV,copy:()=>MK0,conjugate:()=>zK0,clone:()=>LK0,calculateW:()=>FK0,add:()=>OK0});var K0={};n6(K0,{zero:()=>lY0,transformQuat:()=>pY0,transformMat4:()=>bY0,transformMat3:()=>AY0,subtract:()=>yE,sub:()=>nY0,str:()=>uY0,squaredLength:()=>uE,squaredDistance:()=>lE,sqrLen:()=>tY0,sqrDist:()=>rY0,set:()=>PY0,scaleAndAdd:()=>_Y0,scale:()=>kY0,round:()=>DY0,rotateZ:()=>cY0,rotateY:()=>gY0,rotateX:()=>yY0,random:()=>hY0,normalize:()=>xV,negate:()=>CY0,multiply:()=>gE,mul:()=>aY0,min:()=>jY0,max:()=>TY0,lerp:()=>SY0,length:()=>pE,len:()=>PV,inverse:()=>EY0,hermite:()=>IY0,fromValues:()=>F$,forEach:()=>eY0,floor:()=>vY0,exactEquals:()=>dY0,equals:()=>iY0,dot:()=>W$,divide:()=>cE,div:()=>sY0,distance:()=>mE,dist:()=>oY0,cross:()=>fJ,create:()=>G$,copy:()=>xY0,clone:()=>OY0,ceil:()=>BY0,bezier:()=>fY0,angle:()=>mY0,add:()=>NY0});function G$(){var J=new Q0(3);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function OY0(J){var Z=new Q0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function pE(J){var Z=J[0],X=J[1],Y=J[2];return Math.hypot(Z,X,Y)}function F$(J,Z,X){var Y=new Q0(3);return Y[0]=J,Y[1]=Z,Y[2]=X,Y}function xY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function PY0(J,Z,X,Y){return J[0]=Z,J[1]=X,J[2]=Y,J}function NY0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J}function yE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J}function gE(J,Z,X){return J[0]=Z[0]*X[0],J[1]=Z[1]*X[1],J[2]=Z[2]*X[2],J}function cE(J,Z,X){return J[0]=Z[0]/X[0],J[1]=Z[1]/X[1],J[2]=Z[2]/X[2],J}function BY0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function vY0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function jY0(J,Z,X){return J[0]=Math.min(Z[0],X[0]),J[1]=Math.min(Z[1],X[1]),J[2]=Math.min(Z[2],X[2]),J}function TY0(J,Z,X){return J[0]=Math.max(Z[0],X[0]),J[1]=Math.max(Z[1],X[1]),J[2]=Math.max(Z[2],X[2]),J}function DY0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kY0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J}function _Y0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J}function mE(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(X,Y,K)}function lE(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1],K=Z[2]-J[2];return X*X+Y*Y+K*K}function uE(J){var Z=J[0],X=J[1],Y=J[2];return Z*Z+X*X+Y*Y}function CY0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function EY0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function xV(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=X*X+Y*Y+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function W$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function fJ(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=X[0],G=X[1],F=X[2];return J[0]=K*F-$*G,J[1]=$*Q-Y*F,J[2]=Y*G-K*Q,J}function SY0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J[2]=Q+Y*(X[2]-Q),J}function IY0(J,Z,X,Y,K,$){var Q=$*$,G=Q*(2*$-3)+1,F=Q*($-2)+$,W=Q*($-1),q=Q*(3-2*$);return J[0]=Z[0]*G+X[0]*F+Y[0]*W+K[0]*q,J[1]=Z[1]*G+X[1]*F+Y[1]*W+K[1]*q,J[2]=Z[2]*G+X[2]*F+Y[2]*W+K[2]*q,J}function fY0(J,Z,X,Y,K,$){var Q=1-$,G=Q*Q,F=$*$,W=G*Q,q=3*$*G,V=3*F*Q,z=F*$;return J[0]=Z[0]*W+X[0]*q+Y[0]*V+K[0]*z,J[1]=Z[1]*W+X[1]*q+Y[1]*V+K[1]*z,J[2]=Z[2]*W+X[2]*q+Y[2]*V+K[2]*z,J}function hY0(J,Z){Z=Z||1;var X=l6()*2*Math.PI,Y=l6()*2-1,K=Math.sqrt(1-Y*Y)*Z;return J[0]=Math.cos(X)*K,J[1]=Math.sin(X)*K,J[2]=Y*Z,J}function bY0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=X[3]*Y+X[7]*K+X[11]*$+X[15];return Q=Q||1,J[0]=(X[0]*Y+X[4]*K+X[8]*$+X[12])/Q,J[1]=(X[1]*Y+X[5]*K+X[9]*$+X[13])/Q,J[2]=(X[2]*Y+X[6]*K+X[10]*$+X[14])/Q,J}function AY0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2];return J[0]=Y*X[0]+K*X[3]+$*X[6],J[1]=Y*X[1]+K*X[4]+$*X[7],J[2]=Y*X[2]+K*X[5]+$*X[8],J}function pY0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q=X[3],G=Z[0],F=Z[1],W=Z[2],q=K*W-$*F,V=$*G-Y*W,z=Y*F-K*G,L=K*z-$*V,R=$*q-Y*z,M=Y*V-K*q,H=Q*2;return q*=H,V*=H,z*=H,L*=2,R*=2,M*=2,J[0]=G+q+L,J[1]=F+V+R,J[2]=W+z+M,J}function yY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[0],$[1]=K[1]*Math.cos(Y)-K[2]*Math.sin(Y),$[2]=K[1]*Math.sin(Y)+K[2]*Math.cos(Y),J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function gY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[2]*Math.sin(Y)+K[0]*Math.cos(Y),$[1]=K[1],$[2]=K[2]*Math.cos(Y)-K[0]*Math.sin(Y),J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function cY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[0]*Math.cos(Y)-K[1]*Math.sin(Y),$[1]=K[0]*Math.sin(Y)+K[1]*Math.cos(Y),$[2]=K[2],J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function mY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=Z[0],Q=Z[1],G=Z[2],F=Math.sqrt(X*X+Y*Y+K*K),W=Math.sqrt($*$+Q*Q+G*G),q=F*W,V=q&&W$(J,Z)/q;return Math.acos(Math.min(Math.max(V,-1),1))}function lY0(J){return J[0]=0,J[1]=0,J[2]=0,J}function uY0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function dY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function iY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=Z[0],Q=Z[1],G=Z[2];return Math.abs(X-$)<=m*Math.max(1,Math.abs(X),Math.abs($))&&Math.abs(Y-Q)<=m*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(K-G)<=m*Math.max(1,Math.abs(K),Math.abs(G))}var nY0=yE,aY0=gE,sY0=cE,oY0=mE,rY0=lE,PV=pE,tY0=uE,eY0=function(){var J=G$();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=3;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],J[2]=Z[G+2],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1],Z[G+2]=J[2];return Z}}();function JK0(){var J=new Q0(4);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function dE(J){var Z=new Q0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function iE(J,Z,X,Y){var K=new Q0(4);return K[0]=J,K[1]=Z,K[2]=X,K[3]=Y,K}function nE(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function aE(J,Z,X,Y,K){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J}function sE(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J}function oE(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J}function rE(J){var Z=J[0],X=J[1],Y=J[2],K=J[3];return Math.hypot(Z,X,Y,K)}function tE(J){var Z=J[0],X=J[1],Y=J[2],K=J[3];return Z*Z+X*X+Y*Y+K*K}function eE(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*X+Y*Y+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=X*Q,J[1]=Y*Q,J[2]=K*Q,J[3]=$*Q,J}function JS(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function ZS(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J[2]=Q+Y*(X[2]-Q),J[3]=G+Y*(X[3]-G),J}function XS(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function YS(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=Z[0],G=Z[1],F=Z[2],W=Z[3];return Math.abs(X-Q)<=m*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-G)<=m*Math.max(1,Math.abs(Y),Math.abs(G))&&Math.abs(K-F)<=m*Math.max(1,Math.abs(K),Math.abs(F))&&Math.abs($-W)<=m*Math.max(1,Math.abs($),Math.abs(W))}var hk0=function(){var J=JK0();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=4;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],J[2]=Z[G+2],J[3]=Z[G+3],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1],Z[G+2]=J[2],Z[G+3]=J[3];return Z}}();function NV(){var J=new Q0(4);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function XK0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function KS(J,Z,X){X=X*0.5;var Y=Math.sin(X);return J[0]=Y*Z[0],J[1]=Y*Z[1],J[2]=Y*Z[2],J[3]=Math.cos(X),J}function YK0(J,Z){var X=Math.acos(Z[3])*2,Y=Math.sin(X/2);if(Y>m)J[0]=Z[0]/Y,J[1]=Z[1]/Y,J[2]=Z[2]/Y;else J[0]=1,J[1]=0,J[2]=0;return X}function KK0(J,Z){var X=qS(J,Z);return Math.acos(2*X*X-1)}function $S(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1],W=X[2],q=X[3];return J[0]=Y*q+Q*G+K*W-$*F,J[1]=K*q+Q*F+$*G-Y*W,J[2]=$*q+Q*W+Y*F-K*G,J[3]=Q*q-Y*G-K*F-$*W,J}function $K0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+Q*G,J[1]=K*F+$*G,J[2]=$*F-K*G,J[3]=Q*F-Y*G,J}function QK0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F-$*G,J[1]=K*F+Q*G,J[2]=$*F+Y*G,J[3]=Q*F-K*G,J}function GK0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+K*G,J[1]=K*F-Y*G,J[2]=$*F+Q*G,J[3]=Q*F-$*G,J}function FK0(J,Z){var X=Z[0],Y=Z[1],K=Z[2];return J[0]=X,J[1]=Y,J[2]=K,J[3]=Math.sqrt(Math.abs(1-X*X-Y*Y-K*K)),J}function QS(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(X*X+Y*Y+K*K),G=Math.exp($),F=Q>0?G*Math.sin(Q)/Q:0;return J[0]=X*F,J[1]=Y*F,J[2]=K*F,J[3]=G*Math.cos(Q),J}function GS(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(X*X+Y*Y+K*K),G=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=X*G,J[1]=Y*G,J[2]=K*G,J[3]=0.5*Math.log(X*X+Y*Y+K*K+$*$),J}function WK0(J,Z,X){return GS(J,Z),WS(J,J,X),QS(J,J),J}function q$(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3],F=X[0],W=X[1],q=X[2],V=X[3],z,L,R,M,H;if(L=K*F+$*W+Q*q+G*V,L<0)L=-L,F=-F,W=-W,q=-q,V=-V;if(1-L>m)z=Math.acos(L),R=Math.sin(z),M=Math.sin((1-Y)*z)/R,H=Math.sin(Y*z)/R;else M=1-Y,H=Y;return J[0]=M*K+H*F,J[1]=M*$+H*W,J[2]=M*Q+H*q,J[3]=M*G+H*V,J}function qK0(J){var Z=l6(),X=l6(),Y=l6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*X),J[1]=K*Math.cos(2*Math.PI*X),J[2]=$*Math.sin(2*Math.PI*Y),J[3]=$*Math.cos(2*Math.PI*Y),J}function VK0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*X+Y*Y+K*K+$*$,G=Q?1/Q:0;return J[0]=-X*G,J[1]=-Y*G,J[2]=-K*G,J[3]=$*G,J}function zK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function FS(J,Z){var X=Z[0]+Z[4]+Z[8],Y;if(X>0)Y=Math.sqrt(X+1),J[3]=0.5*Y,Y=0.5/Y,J[0]=(Z[5]-Z[7])*Y,J[1]=(Z[6]-Z[2])*Y,J[2]=(Z[1]-Z[3])*Y;else{var K=0;if(Z[4]>Z[0])K=1;if(Z[8]>Z[K*3+K])K=2;var $=(K+1)%3,Q=(K+2)%3;Y=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*Y,Y=0.5/Y,J[3]=(Z[$*3+Q]-Z[Q*3+$])*Y,J[$]=(Z[$*3+K]+Z[K*3+$])*Y,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*Y}return J}function HK0(J,Z,X,Y){var K=0.5*Math.PI/180;Z*=K,X*=K,Y*=K;var $=Math.sin(Z),Q=Math.cos(Z),G=Math.sin(X),F=Math.cos(X),W=Math.sin(Y),q=Math.cos(Y);return J[0]=$*F*q-Q*G*W,J[1]=Q*G*q+$*F*W,J[2]=Q*F*W-$*G*q,J[3]=Q*F*q+$*G*W,J}function UK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var LK0=dE,RK0=iE,MK0=nE,wK0=aE,OK0=sE,xK0=$S,WS=oE,qS=JS,PK0=ZS,VS=rE,NK0=VS,zS=tE,BK0=zS,BV=eE,vK0=XS,jK0=YS,TK0=function(){var J=G$(),Z=F$(1,0,0),X=F$(0,1,0);return function(Y,K,$){var Q=W$(K,$);if(Q<-0.999999){if(fJ(J,Z,K),PV(J)<0.000001)fJ(J,X,K);return xV(J,J),KS(Y,J,Math.PI),Y}else if(Q>0.999999)return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y;else return fJ(J,K,$),Y[0]=J[0],Y[1]=J[1],Y[2]=J[2],Y[3]=1+Q,BV(Y,Y)}}(),DK0=function(){var J=NV(),Z=NV();return function(X,Y,K,$,Q,G){return q$(J,Y,Q,G),q$(Z,K,$,G),q$(X,J,Z,2*G*(1-G)),X}}(),kK0=function(){var J=OV();return function(Z,X,Y,K){return J[0]=Y[0],J[3]=Y[1],J[6]=Y[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-X[0],J[5]=-X[1],J[8]=-X[2],BV(Z,FS(Z,J))}}();var q0={};n6(q0,{zero:()=>J$0,transformMat4:()=>rK0,transformMat3:()=>oK0,transformMat2d:()=>sK0,transformMat2:()=>aK0,subtract:()=>US,sub:()=>$$0,str:()=>Z$0,squaredLength:()=>xS,squaredDistance:()=>wS,sqrLen:()=>q$0,sqrDist:()=>W$0,set:()=>SK0,scaleAndAdd:()=>gK0,scale:()=>yK0,round:()=>pK0,rotate:()=>tK0,random:()=>nK0,normalize:()=>lK0,negate:()=>cK0,multiply:()=>LS,mul:()=>Q$0,min:()=>bK0,max:()=>AK0,lerp:()=>iK0,length:()=>OS,len:()=>K$0,inverse:()=>mK0,fromValues:()=>CK0,forEach:()=>V$0,floor:()=>hK0,exactEquals:()=>X$0,equals:()=>Y$0,dot:()=>uK0,divide:()=>RS,div:()=>G$0,distance:()=>MS,dist:()=>F$0,cross:()=>dK0,create:()=>HS,copy:()=>EK0,clone:()=>_K0,ceil:()=>fK0,angle:()=>eK0,add:()=>IK0});function HS(){var J=new Q0(2);if(Q0!=Float32Array)J[0]=0,J[1]=0;return J}function _K0(J){var Z=new Q0(2);return Z[0]=J[0],Z[1]=J[1],Z}function CK0(J,Z){var X=new Q0(2);return X[0]=J,X[1]=Z,X}function EK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function SK0(J,Z,X){return J[0]=Z,J[1]=X,J}function IK0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J}function US(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J}function LS(J,Z,X){return J[0]=Z[0]*X[0],J[1]=Z[1]*X[1],J}function RS(J,Z,X){return J[0]=Z[0]/X[0],J[1]=Z[1]/X[1],J}function fK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function hK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function bK0(J,Z,X){return J[0]=Math.min(Z[0],X[0]),J[1]=Math.min(Z[1],X[1]),J}function AK0(J,Z,X){return J[0]=Math.max(Z[0],X[0]),J[1]=Math.max(Z[1],X[1]),J}function pK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function yK0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J}function gK0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J}function MS(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1];return Math.hypot(X,Y)}function wS(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1];return X*X+Y*Y}function OS(J){var Z=J[0],X=J[1];return Math.hypot(Z,X)}function xS(J){var Z=J[0],X=J[1];return Z*Z+X*X}function cK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function mK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function lK0(J,Z){var X=Z[0],Y=Z[1],K=X*X+Y*Y;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function uK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function dK0(J,Z,X){var Y=Z[0]*X[1]-Z[1]*X[0];return J[0]=J[1]=0,J[2]=Y,J}function iK0(J,Z,X,Y){var K=Z[0],$=Z[1];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J}function nK0(J,Z){Z=Z||1;var X=l6()*2*Math.PI;return J[0]=Math.cos(X)*Z,J[1]=Math.sin(X)*Z,J}function aK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[2]*K,J[1]=X[1]*Y+X[3]*K,J}function sK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[2]*K+X[4],J[1]=X[1]*Y+X[3]*K+X[5],J}function oK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[3]*K+X[6],J[1]=X[1]*Y+X[4]*K+X[7],J}function rK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[4]*K+X[12],J[1]=X[1]*Y+X[5]*K+X[13],J}function tK0(J,Z,X,Y){var K=Z[0]-X[0],$=Z[1]-X[1],Q=Math.sin(Y),G=Math.cos(Y);return J[0]=K*G-$*Q+X[0],J[1]=K*Q+$*G+X[1],J}function eK0(J,Z){var X=J[0],Y=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(X*X+Y*Y)*Math.sqrt(K*K+$*$),G=Q&&(X*K+Y*$)/Q;return Math.acos(Math.min(Math.max(G,-1),1))}function J$0(J){return J[0]=0,J[1]=0,J}function Z$0(J){return"vec2("+J[0]+", "+J[1]+")"}function X$0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function Y$0(J,Z){var X=J[0],Y=J[1],K=Z[0],$=Z[1];return Math.abs(X-K)<=m*Math.max(1,Math.abs(X),Math.abs(K))&&Math.abs(Y-$)<=m*Math.max(1,Math.abs(Y),Math.abs($))}var K$0=OS,$$0=US,Q$0=LS,G$0=RS,F$0=MS,W$0=wS,q$0=xS,V$0=function(){var J=HS();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=2;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1];return Z}}();class A9 extends Float32Array{constructor(J,Z,X,Y){super([J,Z,X,Y])}get determinant(){return t0.determinant(this)}get frobeniusNorm(){return t0.frob(this)}static create(){let J=new A9(0,0,0,0);return t0.identity(J),J}static fromRotation(J){let Z=A9.create();return t0.fromRotation(Z,J),Z}static fromScaling(J){let Z=A9.create();return t0.fromScaling(Z,J),Z}add(J){return t0.add(this,this,J),this}adjoint(){return t0.adjoint(this,this),this}clone(){return new A9(this[0],this[1],this[2],this[3])}copy(J){return t0.copy(this,J),this}equals(J){return t0.equals(this,J)}exactEquals(J){return t0.exactEquals(this,J)}identity(){return t0.identity(this),this}invert(){return t0.invert(this,this),this}multiply(J){return t0.mul(this,this,J),this}multiplyScalar(J){return t0.multiplyScalar(this,this,J),this}rotate(J){return t0.rotate(this,this,J),this}subtract(J){return t0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return t0.transpose(this,this),this}}class u6 extends Float32Array{constructor(J,Z,X,Y,K,$,Q,G,F){super([J,Z,X,Y,K,$,Q,G,F])}get determinant(){return I0.determinant(this)}get frobeniusNorm(){return I0.frob(this)}static create(){let J=new u6(0,0,0,0,0,0,0,0,0);return I0.identity(J),J}static fromMatrix4(J){let Z=u6.create();return I0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=u6.create();return I0.fromQuat(Z,J),Z}static fromRotation(J){let Z=u6.create();return I0.fromRotation(Z,J),Z}static fromScaling(J){let Z=u6.create();return I0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=u6.create();return I0.fromTranslation(Z,J),Z}add(J){return I0.add(this,this,J),this}adjoint(){return I0.adjoint(this,this),this}clone(){return new u6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return I0.copy(this,J),this}equals(J){return I0.equals(this,J)}exactEquals(J){return I0.exactEquals(this,J)}identity(){return I0.identity(this),this}invert(){return I0.invert(this,this),this}multiply(J){return I0.mul(this,this,J),this}multiplyScalar(J){return I0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return I0.projection(this,J,Z),this}rotate(J){return I0.rotate(this,this,J),this}subtract(J){return I0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return I0.transpose(this,this),this}}class _8 extends Float32Array{constructor(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M){super([J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M])}get determinant(){return X0.determinant(this)}get frobeniusNorm(){return X0.frob(this)}static create(){let J=new _8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return X0.identity(J),J}static fromQuaternion(J){let Z=_8.create();return X0.fromQuat(Z,J),Z}static fromRotation(J,Z){let X=_8.create();return X0.fromRotation(X,J,Z),X}static fromRotationTranslation(J,Z){let X=_8.create();return X0.fromRotationTranslation(X,J,Z),X}static fromRotationTranslationScale(J,Z,X){let Y=_8.create();return X0.fromRotationTranslationScale(Y,J,Z,X),Y}static fromRotationTranslationScaleOrigin(J,Z,X,Y){let K=_8.create();return X0.fromRotationTranslationScaleOrigin(K,J,Z,X,Y),K}static fromScaling(J){let Z=_8.create();return X0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=_8.create();return X0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=_8.create();return X0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=_8.create();return X0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=_8.create();return X0.fromZRotation(Z,J),Z}add(J){return X0.add(this,this,J),this}adjoint(){return X0.adjoint(this,this),this}clone(){return new _8(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}copy(J){return X0.copy(this,J),this}equals(J){return X0.equals(this,J)}exactEquals(J){return X0.exactEquals(this,J)}frustrum(J,Z,X,Y,K,$){return X0.frustum(this,J,Z,X,Y,K,$),this}identity(){return X0.identity(this),this}invert(){return X0.invert(this,this),this}lookAt(J,Z,X){return X0.lookAt(this,J,Z,X),this}multiply(J){return X0.mul(this,this,J),this}multiplyScalar(J){return X0.multiplyScalar(this,this,J),this}orthographic(J,Z,X,Y,K,$){return X0.ortho(this,J,Z,X,Y,K,$),this}perspective(J,Z,X,Y){return X0.perspective(this,J,Z,X,Y),this}rotate(J,Z){return X0.rotate(this,this,J,Z),this}rotateX(J){return X0.rotateX(this,this,J),this}rotateY(J){return X0.rotateY(this,this,J),this}rotateZ(J){return X0.rotateZ(this,this,J),this}scale(J){return X0.scale(this,this,J),this}subtract(J){return X0.sub(this,this,J),this}targetTo(J,Z,X){return X0.targetTo(this,J,Z,X),this}toString(){return`[${this[0]},${this[1]},${this[2]},${this[3]}][${this[4]},${this[5]},${this[6]},${this[7]}][${this[8]},${this[9]},${this[10]},${this[11]}][${this[12]},${this[13]},${this[14]},${this[15]}]`}translate(J){return X0.translate(this,this,J),this}transpose(){return X0.transpose(this,this),this}}class e5 extends Float32Array{constructor(J,Z,X,Y){super([J,Z,X,Y])}get length(){return N0.length(this)}get squaredLength(){return N0.squaredLength(this)}get magnitude(){return N0.length(this)}get squaredMagnitude(){return N0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}get w(){return this[3]}set w(J){this[3]=J}static fromEuler(J,Z,X){let Y=N0.fromEuler(new Float32Array(4),J,Z,X);return new e5(Y[0],Y[1],Y[2],Y[3])}static fromQuaternionLike(J){return new e5(J.x,J.y,J.z,J.w)}clone(){return new e5(this.x,this.y,this.z,this.w)}conjugate(){return N0.conjugate(this,this),this}copy(J){return N0.copy(this,J),this}dot(J){return N0.dot(this,J)}exponential(){return N0.exp(this,this),this}equals(J){return N0.equals(this,J)}exactEquals(J){return N0.exactEquals(this,J)}getAngle(J){return N0.getAngle(this,J)}identity(){return N0.identity(this),this}invert(){return N0.invert(this,this),this}lerp(J,Z){return N0.lerp(this,this,J,Z),this}logarithm(){return N0.ln(this,this),this}multiply(J){return N0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return N0.normalize(this,this),this}power(J){return N0.pow(this,this,J),this}randomize(){return N0.random(this),this}rotateX(J){return N0.rotateX(this,this,J),this}rotateY(J){return N0.rotateY(this,this,J),this}rotateZ(J){return N0.rotateZ(this,this,J),this}scale(J){return N0.scale(this,this,J),this}setAxisAngle(J,Z){return N0.setAxisAngle(this,J,Z),this}slerp(J,Z){return N0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class hJ extends Float32Array{constructor(J,Z){super([J,Z])}get length(){return q0.length(this)}get squaredLength(){return q0.squaredLength(this)}get magnitude(){return q0.length(this)}get squaredMagnitude(){return q0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}static create(){return new hJ(0,0)}add(J){return q0.add(this,this,J),this}angle(J){return q0.angle(this,J)}ceil(){return q0.ceil(this,this),this}clone(){return new hJ(this.x,this.y)}copy(J){return q0.copy(this,J),this}distance(J){return q0.distance(this,J)}divide(J){return q0.divide(this,this,J),this}dot(J){return q0.dot(this,J)}equals(J){return q0.equals(this,J)}exactEquals(J){return q0.exactEquals(this,J)}floor(){return q0.floor(this,this),this}invert(){return q0.inverse(this,this),this}lerp(J,Z){return q0.lerp(this,this,J,Z),this}max(J){return q0.max(this,this,J),this}min(J){return q0.min(this,this,J),this}multiply(J){return q0.mul(this,this,J),this}negate(){return q0.negate(this,this),this}normalize(){return q0.normalize(this,this),this}randomize(J){return q0.random(this,J),this}rotate(J,Z){return q0.rotate(this,this,J,Z),this}round(){return q0.round(this,this),this}scale(J){return q0.scale(this,this,J),this}scaleAndAdd(J,Z){return q0.scaleAndAdd(this,this,J,Z),this}subtract(J){return q0.sub(this,this,J),this}toString(){return`${this.x},${this.y}`}transformMatrix2(J){return q0.transformMat2(this,this,J),this}transformMatrix3(J){return q0.transformMat3(this,this,J),this}transformMatrix4(J){return q0.transformMat4(this,this,J),this}zero(){return q0.zero(this),this}}class J4 extends Float32Array{constructor(J,Z,X){super([J,Z,X])}get length(){return K0.length(this)}get squaredLength(){return K0.squaredLength(this)}get magnitude(){return K0.length(this)}get squaredMagnitude(){return K0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}static create(){return new J4(0,0,0)}static fromVector3Like(J){return new J4(J.x,J.y,J.z)}add(J){return K0.add(this,this,J),this}ceil(){return K0.ceil(this,this),this}clone(){return new J4(this.x,this.y,this.z)}copy(J){return K0.copy(this,J),this}cross(J){return K0.cross(this,this,J),this}distance(J){return K0.distance(this,J)}divide(J){return K0.div(this,this,J),this}dot(J){return K0.dot(this,J)}equals(J){return K0.equals(this,J)}exactEquals(J){return K0.exactEquals(this,J)}floor(){return K0.floor(this,this),this}invert(){return K0.inverse(this,this),this}lerp(J,Z){return K0.lerp(this,this,J,Z),this}max(J){return K0.max(this,this,J),this}min(J){return K0.min(this,this,J),this}multiply(J){return K0.mul(this,this,J),this}negate(){return K0.negate(this,this),this}normalize(){return K0.normalize(this,this),this}randomize(J){return K0.random(this,J),this}rotateX(J,Z){return K0.rotateX(this,this,J,Z),this}rotateY(J,Z){return K0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return K0.rotateZ(this,this,J,Z),this}round(){return K0.round(this,this),this}scale(J){return K0.scale(this,this,J),this}scaleAndAdd(J,Z){return K0.scaleAndAdd(this,this,J,Z),this}subtract(J){return K0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return K0.transformMat3(this,this,J),this}transformMatrix4(J){return K0.transformMat4(this,this,J),this}transformQuaternion(J){return K0.transformQuat(this,this,J),this}zero(){return K0.zero(this),this}}var B0=function(J,Z,X,Y){function K($){return $ instanceof X?$:new X(function(Q){Q($)})}return new(X||(X=Promise))(function($,Q){function G(q){try{W(Y.next(q))}catch(V){Q(V)}}function F(q){try{W(Y.throw(q))}catch(V){Q(V)}}function W(q){q.done?$(q.value):K(q.value).then(G,F)}W((Y=Y.apply(J,Z||[])).next())})},P0=function(J,Z){var X={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},Y,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=G(0),Q.throw=G(1),Q.return=G(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function G(W){return function(q){return F([W,q])}}function F(W){if(Y)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(X=0)),X)try{if(Y=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return X.label++,{value:W[1],done:!1};case 5:X.label++,K=W[1],W=[0];continue;case 7:W=X.ops.pop(),X.trys.pop();continue;default:if(($=X.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){X=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){X.label=W[1];break}if(W[0]===6&&X.label<$[1]){X.label=$[1],$=W;break}if($&&X.label<$[2]){X.label=$[2],X.ops.push(W);break}if($[2])X.ops.pop();X.trys.pop();continue}W=Z.call(J,X)}catch(q){W=[6,q],K=0}finally{Y=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},g8=function(J,Z){var X=typeof Symbol==="function"&&J[Symbol.iterator];if(!X)return J;var Y=X.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=Y.next()).done)$.push(K.value)}catch(G){Q={error:G}}finally{try{if(K&&!K.done&&(X=Y.return))X.call(Y)}finally{if(Q)throw Q.error}}return $},$6=function(J,Z,X){if(X||arguments.length===2){for(var Y=0,K=Z.length,$;Y<K;Y++)if($||!(Y in Z)){if(!$)$=Array.prototype.slice.call(Z,0,Y);$[Y]=Z[Y]}}return J.concat($||Array.prototype.slice.call(Z))},PS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,X=Z&&J[Z],Y=0;if(X)return X.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&Y>=J.length)J=void 0;return{value:J&&J[Y++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},mk0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var X=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(Y,K){return X.compare(Y,K).then(function($){return-1*$})}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:2;return Math.floor((Z-X)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:-1;return Z+X},J.minComparator=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){if(Z>X)return[2,1];else if(Z<X)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){if(X>Z)return[2,1];else if(X<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,Z-X]})})},J.maxComparatorNumber=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,X-Z]})})},J.defaultIsEqual=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,Z===X]})})},J.print=function(Z){function X(q){var V=J.getParentIndexOf(q);return Math.floor(Math.log2(V+1))}function Y(q,V){var z="";for(;V>0;--V)z+=q;return z}var K=0,$=[],Q=X(Z.length-1)+2,G=0;while(K<Z.length){var F=X(K)+1;if(K===0)F=0;var W=String(Z.get(K));if(W.length>G)G=W.length;$[F]=$[F]||[],$[F].push(W),K+=1}return $.map(function(q,V){var z=Math.pow(2,Q-V)-1;return Y(" ",Math.floor(z/2)*G)+q.map(function(L){var R=(G-L.length)/2;return Y(" ",Math.ceil(R))+L+Y(" ",Math.floor(R))}).join(Y(" ",z*G))}).join(`
|
385
|
+
`),Z.write($),Z.end();return}Z.setNoDelay(!0),this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:X})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class wJ extends s{static instance=new wJ;_wss;constructor(){super();this._wss=new TZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),c8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:X})=>this._onUpgrade(J,Z,X))}_onConnection=(J,Z)=>{new L9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,X)=>{this._wss.handleUpgrade(J,Z,X,(Y)=>{this._wss.emit("connection",Y,J)})}}var Y$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(Y$||={});var WV=0.001,ME="dynamic";class f9 extends s{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(J){super();J.type??=ME,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:J,y:Z,z:X,w:Y}=this.rotation;return{x:2*(J*X+Y*Z),y:2*(Z*X-Y*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(J){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(J,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(J)}setAdditionalMassProperties(J){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:Z,centerOfMass:X,principalAngularInertia:Y,principalAngularInertiaLocalFrame:K}=J;this._rigidBody?this._rigidBody.setAdditionalMassProperties(Z,X,Y,K,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(Z,X,Y,K)}setAdditionalSolverIterations(J){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(J):this._rigidBodyDesc.setAdditionalSolverIterations(J)}setAngularDamping(J){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(J):this._rigidBodyDesc.setAngularDamping(J)}setAngularVelocity(J){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(J,!this._explicitSleep):this._rigidBodyDesc.setAngvel(J)}setCcdEnabled(J){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(J):this._rigidBodyDesc.setCcdEnabled(J)}setDominanceGroup(J){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(J):this._rigidBodyDesc.setDominanceGroup(J)}setEnabled(J){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(J):this._rigidBodyDesc.setEnabled(J)}setEnabledPositions(J){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z),this._enabledPositions=J}setEnabledRotations(J){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z),this._enabledRotations=J}setGravityScale(J){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(J,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(J)}setLinearDamping(J){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(J):this._rigidBodyDesc.setLinearDamping(J)}setLinearVelocity(J){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(J,!this._explicitSleep):this._rigidBodyDesc.setLinvel(J.x,J.y,J.z)}setNextKinematicRotation(J){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(J):this._rigidBodyDesc.setRotation(J)}setNextKinematicPosition(J){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(J):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setPosition(J){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(J,!this._explicitSleep):this._rigidBodyDesc.setTranslation(J.x,J.y,J.z)}setRotation(J){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(J,!this._explicitSleep):this._rigidBodyDesc.setRotation(J)}setSleeping(J){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?J?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=J,this._explicitSleep=J}setSoftCcdPrediction(J){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(J):this._rigidBodyDesc.setSoftCcdPrediction(J)}setCollisionGroupsForSolidColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:z0.RigidBodyType.Dynamic,["fixed"]:z0.RigidBodyType.Fixed,["kinematic_position"]:z0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:z0.RigidBodyType.KinematicVelocityBased}[J];if(X===void 0)return _.error(`Invalid RigidBodyType: ${J}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=J}addForce(J){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;J.addToSimulation(this._simulation,this)}addToSimulation(J){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return _.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=J,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((Z)=>{if(!Z.isSimulated)Z.addToSimulation(J,this)})}applyImpulse(J){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new d8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)Z.push(Y)}),Z}getCollidersByTag(J){let Z=[];for(let X of this._colliders)if(X.tag===J)Z.push(X);return Z}linkCollider(J){if(!this._requireNotRemoved("linkCollider"))return;if(J.parentRigidBody!==this)return _.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return _.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((J)=>{J.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(J){if(!this._requireNotRemoved("unlinkCollider"))return;if(!J.isRemoved)return _.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(J){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,Y])=>{if(X in J)Y(J[X])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let Z=new d8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)Z.push(Y)}),Z}_createRigidBodyDesc(J){let Z=J.type??ME;return{["dynamic"]:()=>z0.RigidBodyDesc.dynamic(),["fixed"]:()=>z0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>z0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>z0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(J){if(!this._rigidBody||!this._simulation)_.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(J){if(!this.isDynamic)_.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${J}()`);return this.isDynamic}_requireKinematic(J){if(!this.isKinematic)_.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${J}()`);return this.isKinematic}_requireNotKinematicPositionBased(J){if(this.isKinematicPositionBased)_.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${J}()`);return!this.isKinematicPositionBased}_requireNotRemoved(J){if(!this._rigidBody&&!this._rigidBodyDesc)_.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${J}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(J){if(this.isSimulated)_.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${J}()`);return!this.isSimulated}_isNegligibleVector(J){return Math.abs(J.x)<WV&&Math.abs(J.y)<WV&&Math.abs(J.z)<WV}}var u0=16,r5=u0-1,wE=u0**3,DZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+0,Z+0,X+1,J+0,Z+1,X+0,J+0,Z+1,X+0,J+0,Z+0,X+1,J+0,Z+1,X+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,X)=>[J+1,Z+0,X+0,J+1,Z+1,X+0,J+1,Z+0,X+1,J+1,Z+1,X+0,J+1,Z+1,X+1,J+1,Z+0,X+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+1,Z+0,X+0,J+0,Z+0,X+1,J+1,Z+0,X+0,J+1,Z+0,X+1,J+0,Z+0,X+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,X)=>[J+0,Z+1,X+0,J+0,Z+1,X+1,J+1,Z+1,X+0,J+1,Z+1,X+0,J+0,Z+1,X+1,J+1,Z+1,X+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,X)=>[J+0,Z+0,X+0,J+0,Z+1,X+0,J+1,Z+0,X+0,J+0,Z+1,X+0,J+1,Z+1,X+0,J+1,Z+0,X+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,X)=>[J+0,Z+0,X+1,J+1,Z+0,X+1,J+0,Z+1,X+1,J+0,Z+1,X+1,J+1,Z+0,X+1,J+1,Z+1,X+1]}],qV;((Y)=>{Y.DESPAWN="CHUNK.DESPAWN";Y.SET_BLOCK="CHUNK.SET_BLOCK";Y.SPAWN="CHUNK.SPAWN"})(qV||={});class w8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(wE)}get blocks(){return this._blocks}get requiresUpdate(){return this._requiresUpdate}get isSimulated(){return!!this._rigidBody}get isSpawned(){return!!this._originCoordinate&&!!this._world}get originCoordinate(){return this._originCoordinate}get world(){return this._world}static blockIndexToLocalCoordinate(J){return{x:J%u0,y:(J/u0|0)%u0,z:J/(u0*u0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&u0-1,y:J.y&u0-1,z:J.z&u0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(u0-1),y:J.y&~(u0-1),z:J.z&~(u0-1)}}static isValidOriginCoordinate(J){return J.x%u0===0&&J.y%u0===0&&J.z%u0===0}spawn(J,Z){if(this.isSpawned){let{x:X,y:Y,z:K}=this.originCoordinate;return _.error(`Chunk.spawn(): Chunk is already spawned at origin ${X}, ${Y}, ${K}!`)}if(!w8.isValidOriginCoordinate(Z))return _.error(`Chunk.spawn(): Chunk coordinates must be divisible by ${u0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)return _.error("Chunk.despawn(): Chunk has not been spawned and cannot be despawned!");this.emitWithWorld(this._world,"CHUNK.DESPAWN",{chunk:this}),this._removeFromSimulation(),this._world.chunkLattice.unregisterChunk(this),this._originCoordinate=void 0,this._world=void 0}getBlockId(J){return this._blocks[this._getIndex(J)]}hasBlock(J){return this._blocks[this._getIndex(J)]!==0}setBlock(J,Z){if(!this._isValidLocalCoordinate(J))return _.error("Chunk.setBlock(): Block local coordinate is out of bounds");if(this._blocks[this._getIndex(J)]===Z)return;if(this._blocks[this._getIndex(J)]=Z,this.isSpawned&&this.isSimulated){this.emitWithWorld(this._world,"CHUNK.SET_BLOCK",{chunk:this,globalCoordinate:this._getGlobalCoordinate(J),localCoordinate:J,blockTypeId:Z});let X=this._getGlobalCoordinate(J),Y=[];if(J.x===0)Y.push({x:-1,y:0,z:0});if(J.y===0)Y.push({x:0,y:-1,z:0});if(J.z===0)Y.push({x:0,y:0,z:-1});if(J.x===r5)Y.push({x:1,y:0,z:0});if(J.y===r5)Y.push({x:0,y:1,z:0});if(J.z===r5)Y.push({x:0,y:0,z:1});for(let K of Y){let $={x:X.x+K.x,y:X.y+K.y,z:X.z+K.z},Q=w8.globalCoordinateToOriginCoordinate($),G=this._world?.chunkLattice.getChunk(Q);if(!G?.hasBlock(w8.globalCoordinateToLocalCoordinate($)))continue;G.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)return _.error("Chunk.update(): Chunk is not spawned and cannot be updated.");let J=!this._rigidBody,Z=this._world.simulation;if(this._removeFromSimulation(),this._rigidBody=new f9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([X,Y])=>{if(!X.isSimulated)X.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(X,Y)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return t.serializeChunk(this)}_meshColliders(){if(!this._world)return _.error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed."),[];let J=new Map,Z=[];for(let Y=0;Y<wE;Y++){if(this._blocks[Y]===0)continue;let K=this._blocks[Y],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:G,z:F}=w8.blockIndexToLocalCoordinate(Y);if(!$.isMeshable){let q=$.createCollider();q.setRelativePosition({x:Q,y:G,z:F}),Z.push([q,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let q of DZ0){let[V,z,L]=q.neighborOffset,R={x:Q+V,y:G+z,z:F+L},M=this._getGlobalCoordinate(R),H=this._world.chunkLattice.getBlockType(M);if(H&&!H.isLiquid)continue;let O=W.indices.length;W.indices.push(O,O+1,O+2,O+3,O+4,O+5),W.vertices.push(...q.generateVertices(Q,G,F))}}let X=[];return J.forEach((Y,K)=>{if(!Y.indices.length)return;let $=K.createCollider(new Uint32Array(Y.indices),new Float32Array(Y.vertices));X.push([$,K])}),[...Z,...X]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)_.fatalError("Chunk._getGlobalCoordinate(): Chunk is not spawned, calculating global coordinate is impossible.");return{x:this.originCoordinate.x+J.x,y:this.originCoordinate.y+J.y,z:this.originCoordinate.z+J.z}}_getIndex(J){return J.x+u0*(J.y+u0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=r5&&J.y>=0&&J.y<=r5&&J.z>=0&&J.z<=r5}}class OJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:X,z:Y}=J.originCoordinate;return _.error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${X}, ${Y}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)return _.error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)return _.error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)return _.error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(w8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(w8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!w8.isValidOriginCoordinate(J)){_.error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${u0})`);return}return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(w8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(w8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let X=w8.globalCoordinateToLocalCoordinate(J),Y=w8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(Y);if(!K)K=new w8,K.spawn(this._world,Y);K.setBlock(X,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var OE={type:"dynamic",softCcdPrediction:1},xE=0.0025000000000000005,PE=Math.cos(0.005),K$;((O)=>{O.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";O.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";O.DESPAWN="ENTITY.DESPAWN";O.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";O.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";O.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";O.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";O.SET_OPACITY="ENTITY.SET_OPACITY";O.SET_PARENT="ENTITY.SET_PARENT";O.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";O.SPAWN="ENTITY.SPAWN";O.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";O.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";O.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";O.TICK="ENTITY.TICK";O.UPDATE_POSITION="ENTITY.UPDATE_POSITION";O.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(K$||={});class Z8 extends f9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelScale;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;constructor(J){let Z="blockTextureUri"in J,X="modelUri"in J;if(!Z===!X)_.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(Z&&!J.blockHalfExtents)_.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)_.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!U6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))_.fatalError(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??OE);if(Z)this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelScale=J.modelScale,this._modelUri=J.modelUri,J.modelHiddenNodes?.forEach((Y)=>this._modelHiddenNodes.add(Y.toLowerCase())),J.modelLoopedAnimations?.forEach((Y)=>this._modelLoopedAnimations.add(Y));if(this._name=J.name??"Nameless",this._opacity=J.opacity??1,this._parent=J.parent,this._parentNodeName=J.parentNodeName,this._tag=J.tag,this._tintColor=J.tintColor,J.controller)this.setController(J.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get height(){return this.isModelEntity?U6.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelScale(){return this._modelScale}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get world(){return this._world}spawn(J,Z,X){if(this.isSpawned)return _.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(J.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new d8(d8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new d8(d8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((Y)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))Y.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Y.enableContactForceEvents(!0);if(q6.isDefaultCollisionGroups(Y.collisionGroups))Y.setCollisionGroups({belongsTo:[Y.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),X)this.setRotation(X);if(this._id=J.entityManager.registerEntity(this),this._world=J,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,Z,X);this.colliders.forEach((Y)=>{J.simulation.colliderMap.setColliderEntity(Y,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((J)=>{J.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setModelAnimationsPlaybackRate(J){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===J)return;this._modelAnimationsPlaybackRate=J,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:J})}setController(J){if(this._controller===J)return;if(this._controller)this._controller.detach(this);if(this._controller=J,this._controller)this._controller.attach(this)}setModelHiddenNodes(J){if(!this._requireSpawned("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setOpacity(J){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,X,Y){if(!this._requireSpawned("setParent"))return;if(J&&!J.isSpawned)return _.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&J)this._lastParentlessType=this.type;if(this._parent=J,this._parentNodeName=Z,this.colliders.forEach((K)=>K.setEnabled(!J)),this.setType(!J?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation(Y??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:J,parentNodeName:Z})}setTintColor(J){if(!this._requireSpawned("setTintColor"))return;if(!J&&!this._tintColor||J&&this._tintColor&&J.r===this._tintColor.r&&J.g===this._tintColor.g&&J.b===this._tintColor.b)return;this._tintColor=J,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:J})}startModelLoopedAnimations(J){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>!this._modelLoopedAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(J)})}startModelOneshotAnimations(J){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!J.length)return;J.forEach((Z)=>{this._modelOneshotAnimations.add(Z)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(J)})}stopModelAnimations(J){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!J.length)return;if(!J.some((Z)=>this._modelLoopedAnimations.has(Z))&&!J.some((Z)=>this._modelOneshotAnimations.has(Z)))return;J.forEach((Z)=>{this._modelLoopedAnimations.delete(Z),this._modelOneshotAnimations.delete(Z)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(J)})}serialize(){return t.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let J=this.position,Z=this.rotation;if(this._rotationExceedsThreshold(Z,this._lastUpdatedRotation))this._lastUpdatedRotation=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:Z});if(this._positionExceedsThreshold(J,this._lastUpdatedPosition))this._lastUpdatedPosition=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:J})}_requireSpawned(J){if(!this.isSpawned)_.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${J}()!`);return this.isSpawned}_positionExceedsThreshold(J,Z){let X=J.x-Z.x,Y=J.y-Z.y,K=J.z-Z.z;return X*X+Y*Y+K*K>xE}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<PE}}class xJ extends i1{autoCancelMouseLeftClick=!0;canWalk=()=>!0;canRun=()=>!0;canJump=()=>!0;idleLoopedAnimations=["idle_upper","idle_lower"];interactOneshotAnimations=["simple_interact"];jumpOneshotAnimations=["jump_loop"];jumpVelocity=10;runLoopedAnimations=["run_upper","run_lower"];runVelocity=8;sticksToPlatforms=!0;walkLoopedAnimations=["walk_upper","walk_lower"];walkVelocity=4;_stepAudio;_groundContactCount=0;_platform;constructor(J={}){super();this.autoCancelMouseLeftClick=J.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.jumpVelocity=J.jumpVelocity??this.jumpVelocity,this.runVelocity=J.runVelocity??this.runVelocity,this.walkVelocity=J.walkVelocity??this.walkVelocity,this.canWalk=J.canWalk??this.canWalk,this.canRun=J.canRun??this.canRun,this.canJump=J.canJump??this.canJump,this.sticksToPlatforms=J.sticksToPlatforms??this.sticksToPlatforms}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get platform(){return this._platform}attach(J){this._stepAudio=new K4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)return _.error("PlayerEntityController.createColliders(): Entity is not spawned!");J.createAndAddChildCollider({shape:"cylinder",radius:0.23,halfHeight:0.125,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},isSensor:!0,relativePosition:{x:0,y:-0.75,z:0},tag:"groundSensor",onCollision:(Z,X)=>{if(!J.isSpawned)return;if(this._groundContactCount+=X?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof Z8)||!Z.isKinematic)return;if(X&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!X)this._platform=void 0}}),J.createAndAddChildCollider({shape:"capsule",halfHeight:0.33,radius:0.4,collisionGroups:{belongsTo:[4],collidesWith:[1,2]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(J,Z,X,Y){if(!J.isSpawned||!J.world)return;if(super.tickWithPlayerInput(J,Z,X,Y),J.parent)return;let{w:K,a:$,s:Q,d:G,sp:F,sh:W,ml:q}=Z,{yaw:V}=X,z=J.linearVelocity,L={x:0,y:0,z:0},R=W;if(this.isGrounded&&(K||$||Q||G)){if(R)J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.runLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.runLoopedAnimations),this._stepAudio?.setPlaybackRate(0.75);else J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.walkLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.walkLoopedAnimations),this._stepAudio?.setPlaybackRate(0.51);this._stepAudio?.play(J.world,!this._stepAudio?.isPlaying)}else this._stepAudio?.pause(),J.stopModelAnimations(Array.from(J.modelLoopedAnimations).filter((P)=>!this.idleLoopedAnimations.includes(P))),J.startModelLoopedAnimations(this.idleLoopedAnimations);if(q)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(R&&this.canRun(this)||!R&&this.canWalk(this)){let P=R?this.runVelocity:this.walkVelocity;if(K)L.x-=P*Math.sin(V),L.z-=P*Math.cos(V);if(Q)L.x+=P*Math.sin(V),L.z+=P*Math.cos(V);if($)L.x-=P*Math.cos(V),L.z+=P*Math.sin(V);if(G)L.x+=P*Math.cos(V),L.z-=P*Math.sin(V);let N=Math.sqrt(L.x*L.x+L.z*L.z);if(N>P){let B=P/N;L.x*=B,L.z*=B}}if(F&&this.canJump(this)){if(this.isGrounded&&z.y>-0.001&&z.y<=3)L.y=this.jumpVelocity}let M=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},H={x:L.x-z.x+M.x,y:L.y+M.y,z:L.z-z.z+M.z};if(!(this.runVelocity>0&&Math.abs(z.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(z.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(z.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(H).some((P)=>P!==0)){let P=J.mass;J.applyImpulse({x:H.x*P,y:H.y*P,z:H.z*P})}}if(V!==void 0){let P=V/2;J.setRotation({x:0,y:Math.fround(Math.sin(P)),z:0,w:Math.fround(Math.cos(P))})}}}var VV;((G)=>{G.LOAD="SCENE_UI.LOAD";G.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";G.SET_OFFSET="SCENE_UI.SET_OFFSET";G.SET_POSITION="SCENE_UI.SET_POSITION";G.SET_STATE="SCENE_UI.SET_STATE";G.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";G.UNLOAD="SCENE_UI.UNLOAD"})(VV||={});class PJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=J.attachedToEntity,this._offset=J.offset,this._position=J.position,this._state=J.state??{},this._templateId=J.templateId,this._viewDistance=J.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(J){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`SceneUI.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:J})}setPosition(J){if(this._position===J)return;if(this._attachedToEntity=void 0,this._position=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:J})}setState(J){if(this._state={...this._state,...J},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(J){if(this._viewDistance=J,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:J})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return t.serializeSceneUI(this)}}class d1 extends Z8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new PJ({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}}),!J.controller)this.setController(new xJ)}spawn(J,Z,X){super.spawn(J,Z,X),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:Y})=>{this.nametagSceneUI.setState({chat:Y})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:X}=this.player;this.controller.tickWithPlayerInput(this,Z,X.orientation,J),super.tick(J)}}class BJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)_.fatalError(`EntityManager.registerEntity(): Entity ${J.name} is already assigned the id ${J.id}!`);let Z=this._nextEntityId;return this._entities.set(Z,J),this._nextEntityId++,Z}unregisterEntity(J){if(J.id===void 0)return _.error(`EntityManager.unregisterEntity(): Entity ${J.name} is not assigned an id!`);this._entities.delete(J.id)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let J=[];return this._entities.forEach((Z)=>{if(Z instanceof d1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((X)=>{if(X instanceof d1&&X.player===J)Z.push(X)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((X)=>{if(X.tag===J)Z.push(X)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((X)=>{if(X.tag?.includes(J))Z.push(X)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((X)=>{if(X.parent===J)Z.push(X)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class vJ{_lights=new Map;_nextLightId=1;_world;constructor(J){this._world=J}get world(){return this._world}despawnEntityAttachedLights(J){this.getAllEntityAttachedLights(J).forEach((Z)=>{Z.despawn()})}getAllLights(){return Array.from(this._lights.values())}getAllEntityAttachedLights(J){return this.getAllLights().filter((Z)=>Z.attachedToEntity===J)}registerLight(J){if(J.id!==void 0)return J.id;let Z=this._nextLightId;return this._lights.set(Z,J),this._nextLightId++,Z}unregisterLight(J){if(J.id===void 0)return;this._lights.delete(J.id)}}var NE;((X)=>{X[X.POINTLIGHT=0]="POINTLIGHT";X[X.SPOTLIGHT=1]="SPOTLIGHT"})(NE||={});var zV;((z)=>{z.DESPAWN="LIGHT.DESPAWN";z.SET_ANGLE="LIGHT.SET_ANGLE";z.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";z.SET_COLOR="LIGHT.SET_COLOR";z.SET_DISTANCE="LIGHT.SET_DISTANCE";z.SET_INTENSITY="LIGHT.SET_INTENSITY";z.SET_OFFSET="LIGHT.SET_OFFSET";z.SET_PENUMBRA="LIGHT.SET_PENUMBRA";z.SET_POSITION="LIGHT.SET_POSITION";z.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";z.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";z.SPAWN="LIGHT.SPAWN"})(zV||={});class HV extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)_.fatalError("Either attachedToEntity or position must be set, but not both");super();_.warning("WARNING: Lights are poorly optimized at this time. Using more than a few lights in your game can cause extremely bad performance (FPS) issues. Use lights sparingly!"),this._angle=J.angle,this._attachedToEntity=J.attachedToEntity,this._color=J.color??{r:255,g:255,b:255},this._distance=J.distance,this._intensity=J.intensity??1,this._offset=J.offset,this._penumbra=J.penumbra,this._position=J.position,this._trackedEntity=J.trackedEntity,this._trackedPosition=J.trackedPosition,this._type=J.type??0}get id(){return this._id}get angle(){return this._angle}get attachedToEntity(){return this._attachedToEntity}get color(){return this._color}get distance(){return this._distance}get intensity(){return this._intensity}get isSpawned(){return this._id!==void 0}get offset(){return this._offset}get penumbra(){return this._penumbra}get position(){return this._position}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get type(){return this._type}get world(){return this._world}setAngle(J){if(this._angle===J)return;if(this._angle=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ANGLE",{light:this,angle:J})}setAttachedToEntity(J){if(!J.isSpawned)return _.error(`Light.setAttachedToEntity(): Entity ${J.id} is not spawned!`);if(this._attachedToEntity===J)return;if(this._attachedToEntity=J,this._position=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_ATTACHED_TO_ENTITY",{light:this,entity:J})}setColor(J){if(this._color.r===J.r&&this._color.g===J.g&&this._color.b===J.b)return;if(this._color=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_COLOR",{light:this,color:J})}setDistance(J){if(this._distance===J)return;if(this._distance=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_DISTANCE",{light:this,distance:J})}setIntensity(J){if(this._intensity===J)return;if(this._intensity=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_INTENSITY",{light:this,intensity:J})}setOffset(J){if(this._offset===J)return;if(this._offset=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_OFFSET",{light:this,offset:J})}setPenumbra(J){if(this._penumbra===J)return;if(this._penumbra=J,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_PENUMBRA",{light:this,penumbra:J})}setPosition(J){if(this._position===J)return;if(this._position=J,this._attachedToEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_POSITION",{light:this,position:J})}setTrackedEntity(J){if(!J.isSpawned)return _.error(`Light.setTrackedEntity(): Entity ${J.id} is not spawned!`);if(this._trackedEntity===J)return;if(this._trackedEntity=J,this._trackedPosition=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_ENTITY",{light:this,entity:J})}setTrackedPosition(J){if(this._trackedPosition===J)return;if(this._trackedPosition=J,this._trackedEntity=void 0,this.isSpawned)this.emitWithWorld(this._world,"LIGHT.SET_TRACKED_POSITION",{light:this,position:J})}despawn(){if(!this.isSpawned||!this._world)return;this._world.lightManager.unregisterLight(this),this.emitWithWorld(this._world,"LIGHT.DESPAWN",{light:this}),this._id=void 0,this._world=void 0}spawn(J){if(this.isSpawned)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return _.error(`Light.spawn(): Attached entity ${this._attachedToEntity.id} must be spawned before spawning Light!`);this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return t.serializeLight(this)}}var BE;((Y)=>{Y[Y.FIRST_PERSON=0]="FIRST_PERSON";Y[Y.THIRD_PERSON=1]="THIRD_PERSON";Y[Y.SPECTATOR=2]="SPECTATOR"})(BE||={});var UV;((L)=>{L.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";L.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";L.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";L.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";L.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";L.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";L.SET_FOV="PLAYER_CAMERA.SET_FOV";L.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";L.SET_MODE="PLAYER_CAMERA.SET_MODE";L.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";L.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";L.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";L.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(UV||={});class jJ extends s{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_trackedEntity;_trackedPosition;_zoom=1;constructor(J){super();this.player=J}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){if(!this._requirePlayerWorld())return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(!this._requirePlayerWorld())return;if(!J.isSpawned)return _.error(`PlayerCamera.setAttachedToEntity(): Entity ${J.id} is not spawned!`);this._attachedToEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:J})}setAttachedToPosition(J){if(!this._requirePlayerWorld())return;this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){if(!this._requirePlayerWorld())return;this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){if(!this._requirePlayerWorld())return;this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){if(!this._requirePlayerWorld())return;this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){if(!this._requirePlayerWorld())return;this._modelHiddenNodes=new Set(J.map((Z)=>Z.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setMode(J){if(!this._requirePlayerWorld())return;this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){if(!this._requirePlayerWorld())return;this._offset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:J})}setOrientationPitch(J){this._orientation.pitch=J}setOrientationYaw(J){this._orientation.yaw=J}setTrackedEntity(J){if(!this._requirePlayerWorld())return;this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){if(!this._requirePlayerWorld())return;this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){if(!this._requirePlayerWorld())return;this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return t.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)_.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`);return!!this.player.world}}var $$;((K)=>{K.DATA="PLAYER_UI.DATA";K.LOAD="PLAYER_UI.LOAD";K.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";K.SEND_DATA="PLAYER_UI.SEND_DATA"})($$||={});class TJ extends s{player;constructor(J){super();this.player=J}load(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:J})}lockPointer(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:J})}sendData(J){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:J})}}class DJ{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){if(!this._requireSimulatedCollider(J))return;return this._colliderHandleEntityMap.get(J.rawCollider.handle)}getColliderHandleBlockType(J){return this._colliderHandleBlockTypeMap.get(J)}getColliderHandleCollisionCallback(J){return this._colliderHandleCollisionCallbackMap.get(J)}getColliderHandleEntity(J){return this._colliderHandleEntityMap.get(J)}removeColliderBlockType(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){if(!this._requireSimulatedCollider(J))return;this.removeColliderHandleEntity(J.rawCollider.handle)}removeColliderHandleBlockType(J){this._colliderHandleBlockTypeMap.delete(J)}removeColliderHandleCollisionCallback(J){this._colliderHandleCollisionCallbackMap.delete(J)}removeColliderHandleEntity(J){this._colliderHandleEntityMap.delete(J)}setColliderBlockType(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){if(!this._requireSimulatedCollider(J))return;this.setColliderHandleEntity(J.rawCollider.handle,Z)}setColliderHandleBlockType(J,Z){this._colliderHandleBlockTypeMap.set(J,Z),this._cleanupBlockTypeColliderHandles.delete(J),this._pendingCleanupBlockTypeColliderHandles.delete(J)}setColliderHandleCollisionCallback(J,Z){this._colliderHandleCollisionCallbackMap.set(J,Z),this._cleanupCollisionCallbackColliderHandles.delete(J),this._pendingCleanupCollisionCallbackColliderHandles.delete(J)}setColliderHandleEntity(J,Z){this._colliderHandleEntityMap.set(J,Z),this._cleanupEntityColliderHandles.delete(J),this._pendingCleanupEntityColliderHandles.delete(J)}queueColliderHandleForCleanup(J){if(this._colliderHandleBlockTypeMap.has(J))this._pendingCleanupBlockTypeColliderHandles.add(J);if(this._colliderHandleCollisionCallbackMap.has(J))this._pendingCleanupCollisionCallbackColliderHandles.add(J);if(this._colliderHandleEntityMap.has(J))this._pendingCleanupEntityColliderHandles.add(J)}cleanup(){for(let J of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(J);this._cleanupBlockTypeColliderHandles.clear();for(let J of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(J);this._cleanupCollisionCallbackColliderHandles.clear();for(let J of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(J);this._cleanupEntityColliderHandles.clear(),[[this._pendingCleanupBlockTypeColliderHandles,this._cleanupBlockTypeColliderHandles],[this._pendingCleanupCollisionCallbackColliderHandles,this._cleanupCollisionCallbackColliderHandles],[this._pendingCleanupEntityColliderHandles,this._cleanupEntityColliderHandles]].forEach(([J,Z])=>{for(let X of J.keys())Z.add(X);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)_.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!J.rawCollider}}var kZ0={x:0,y:-32,z:0},LV=60,RV;((K)=>{K.STEP_START="SIMULATION.STEP_START";K.STEP_END="SIMULATION.STEP_END";K.DEBUG_RAYCAST="SIMULATION.DEBUG_RAYCAST";K.DEBUG_RENDER="SIMULATION.DEBUG_RENDER"})(RV||={});class kJ extends s{_colliderMap=new DJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=LV,X=kZ0){super();this._rapierEventQueue=new z0.EventQueue(!0),this._rapierSimulation=new z0.World(X),this._rapierSimulation.timestep=Math.fround(1/Z),this._world=J}get colliderMap(){return this._colliderMap}get isDebugRaycastingEnabled(){return this._debugRaycastingEnabled}get isDebugRenderingEnabled(){return this._debugRenderingEnabled}get gravity(){return this._rapierSimulation.gravity}get timestepS(){return this._rapierSimulation.timestep}get world(){return this._world}raycast(J,Z,X,Y={}){let K=new z0.Ray(J,Z),$=this._rapierSimulation.castRay(K,X,Y.ignoresSensors??!0,Y.filterFlags,Y.filterGroups,Y.filterExcludeCollider,Y.filterExcludeRigidBody,Y.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:X,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),G=$.timeOfImpact,F=$.collider,W=this._colliderMap.getColliderHandleBlockType(F.handle);if(W)return{hitBlock:p9.fromGlobalCoordinate({x:Math.floor(Q.x-(K.dir.x<0?0.0001:-0.0001)),y:Math.floor(Q.y-(K.dir.y<0?0.0001:-0.0001)),z:Math.floor(Q.z-(K.dir.z<0?0.0001:-0.0001))},W),hitPoint:Q,hitDistance:G};let q=this._colliderMap.getColliderHandleEntity(F.handle);if(q)return{hitEntity:q,hitPoint:Q,hitDistance:G};return null}createRawCollider(J,Z){return this._rapierSimulation.createCollider(J,Z)}createRawRigidBody(J){return this._rapierSimulation.createRigidBody(J)}enableDebugRaycasting(J){this._debugRaycastingEnabled=J}enableDebugRendering(J){this._debugRenderingEnabled=J}getContactManifolds(J,Z){let X=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(Y,K)=>{if(Y.numContacts()===0)return;let $=Y.normal(),Q=[];for(let G=0;G<Y.numSolverContacts();G++)Q.push(Y.solverContactPoint(G));X.push({contactPoints:Q,localNormalA:!K?Y.localNormal1():Y.localNormal2(),localNormalB:!K?Y.localNormal2():Y.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),X}removeRawCollider(J){this._colliderMap.queueColliderHandleForCleanup(J.handle),this._rapierSimulation.removeCollider(J,!1)}removeRawRigidBody(J){this._rapierSimulation.removeRigidBody(J)}setGravity(J){this._rapierSimulation.gravity=J}step=(J)=>{this.emitWithWorld(this._world,"SIMULATION.STEP_START",{simulation:this,tickDeltaMs:J});let Z=performance.now();if(this._rapierSimulation.step(this._rapierEventQueue),this._rapierEventQueue.drainContactForceEvents(this._onContactForceEvent),this._rapierEventQueue.drainCollisionEvents(this._onCollisionEvent),this._colliderMap.cleanup(),this.emitWithWorld(this._world,"SIMULATION.STEP_END",{simulation:this,stepDurationMs:performance.now()-Z}),this._debugRenderingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RENDER",{simulation:this,...this._rapierSimulation.debugRender()})};_onCollisionEvent=(J,Z,X)=>{let[Y,K]=this._getCollisionObjects(J,Z);if(!Y||!K)return;let $=(Q,G)=>{if(Q instanceof L6&&G instanceof Z8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof Z8&&G instanceof L6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof Z8&&G instanceof Z8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:G,started:X,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(G instanceof Z8||G instanceof L6))Q(G,X,J,Z)};$(Y,K),$(K,Y)};_onContactForceEvent=(J)=>{let[Z,X]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!X||typeof X==="function")return;let Y={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof L6&&Q instanceof Z8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:Y});else if($ instanceof Z8&&Q instanceof L6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:Y});else if($ instanceof Z8&&Q instanceof Z8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:Y})};K(Z,X),K(X,Z)};_getCollisionObjects(J,Z){let X=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),Y=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[X,Y]}}class Q${_synchronizedPlayerPackets=new Map;_queuedBroadcasts=[];_queuedAudioSynchronizations={};_queuedBlockSynchronizations={};_queuedBlockTypeSynchronizations={};_queuedChunkSynchronizations={};_queuedDebugRaycastSynchronizations=[];_queuedEntitySynchronizations={};_queuedLightSynchronizations={};_queuedPerPlayerSynchronizations=new Map;_queuedPerPlayerCameraSynchronizations=new Map;_queuedPerPlayerUISynchronizations=new Map;_queuedPerPlayerUIDatasSynchronizations=new Map;_queuedPlayerSynchronizations={};_queuedSceneUISynchronizations={};_queuedWorldSynchronization;_loadedSceneUIs=new Set;_spawnedChunks=new Set;_spawnedEntities=new Set;_world;constructor(J){this._world=J,this._subscribeToAudioEvents(),this._subscribeToBlockTypeRegistryEvents(),this._subscribeToChatEvents(),this._subscribeToChunkEvents(),this._subscribeToEntityEvents(),this._subscribeToLightEvents(),this._subscribeToPlayerEvents(),this._subscribeToPlayerCameraEvents(),this._subscribeToPlayerUIEvents(),this._subscribeToSceneUIEvents(),this._subscribeToSimulationEvents(),this._subscribeToWorldEvents()}synchronize(){let J=[],Z=this._world.loop.currentTick;this._queuedPerPlayerSynchronizations.forEach((V,z)=>{this._createOrGetSynchronizedPlayerPackets(z,J).push(...V)});let X=Object.values(this._queuedEntitySynchronizations);if(X.length>0){let V=y.createPacket(y.outboundPackets.entitiesPacketDefinition,X,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let Y=Object.values(this._queuedAudioSynchronizations);if(Y.length>0){let V=y.createPacket(y.outboundPackets.audiosPacketDefinition,Y,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let K=Object.values(this._queuedBlockTypeSynchronizations);if(K.length>0){let V=y.createPacket(y.outboundPackets.blockTypesPacketDefinition,K,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let $=Object.values(this._queuedBlockSynchronizations);if($.length>0){let V=y.createPacket(y.outboundPackets.blocksPacketDefinition,$,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let Q=Object.values(this._queuedChunkSynchronizations);if(Q.length>0){let V=y.createPacket(y.outboundPackets.chunksPacketDefinition,Q,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}let G=Object.values(this._queuedLightSynchronizations);if(G.length>0){let V=y.createPacket(y.outboundPackets.lightsPacketDefinition,G,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedPerPlayerUISynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.uiPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)}),this._queuedPerPlayerUIDatasSynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.uiDatasPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)});let F=Object.values(this._queuedSceneUISynchronizations);if(F.length>0){let V=y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,F,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}if(this._queuedWorldSynchronization){let V=y.createPacket(y.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedPerPlayerCameraSynchronizations.forEach((V,z)=>{let L=y.createPacket(y.outboundPackets.cameraPacketDefinition,V,Z);this._createOrGetSynchronizedPlayerPackets(z,J).push(L)});let W=Object.values(this._queuedPlayerSynchronizations);if(W.length>0){let V=y.createPacket(y.outboundPackets.playersPacketDefinition,W,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}this._queuedBroadcasts.forEach((V)=>{J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))});let q=this._queuedDebugRaycastSynchronizations;if(q.length>0){let V=y.createPacket(y.outboundPackets.physicsDebugRaycastsPacketDefinition,q,Z);J.push(V),this._synchronizedPlayerPackets.forEach((z)=>z.push(V))}U1.instance.getConnectedPlayersByWorld(this._world).forEach((V)=>{let z=this._synchronizedPlayerPackets.get(V)??J;if(z.length>0)V.connection.send(z)}),this._queuedBroadcasts=[],this._queuedAudioSynchronizations={},this._queuedBlockSynchronizations={},this._queuedBlockTypeSynchronizations={},this._queuedChunkSynchronizations={},this._queuedDebugRaycastSynchronizations=[],this._queuedEntitySynchronizations={},this._queuedLightSynchronizations={},this._queuedPerPlayerSynchronizations.clear(),this._queuedPerPlayerCameraSynchronizations.clear(),this._queuedPerPlayerUISynchronizations.clear(),this._queuedPerPlayerUIDatasSynchronizations.clear(),this._queuedPlayerSynchronizations={},this._queuedSceneUISynchronizations={},this._queuedWorldSynchronization=void 0,this._loadedSceneUIs.clear(),this._spawnedChunks.clear(),this._spawnedEntities.clear(),this._synchronizedPlayerPackets.clear()}_subscribeToAudioEvents(){this._world.final("AUDIO.PAUSE",this._onAudioPause),this._world.final("AUDIO.PLAY",this._onAudioPlay),this._world.final("AUDIO.PLAY_RESTART",this._onAudioPlayRestart),this._world.final("AUDIO.SET_ATTACHED_TO_ENTITY",this._onAudioSetAttachedToEntity),this._world.final("AUDIO.SET_CUTOFF_DISTANCE",this._onAudioSetCutoffDistance),this._world.final("AUDIO.SET_DETUNE",this._onAudioSetDetune),this._world.final("AUDIO.SET_DISTORTION",this._onAudioSetDistortion),this._world.final("AUDIO.SET_POSITION",this._onAudioSetPosition),this._world.final("AUDIO.SET_PLAYBACK_RATE",this._onAudioSetPlaybackRate),this._world.final("AUDIO.SET_REFERENCE_DISTANCE",this._onAudioSetReferenceDistance),this._world.final("AUDIO.SET_VOLUME",this._onAudioSetVolume)}_subscribeToBlockTypeRegistryEvents(){this._world.final("BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",this._onBlockTypeRegistryRegisterBlockType)}_subscribeToChatEvents(){this._world.final("CHAT.BROADCAST_MESSAGE",this._onChatSendBroadcastMessage),this._world.final("CHAT.PLAYER_MESSAGE",this._onChatSendPlayerMessage)}_subscribeToChunkEvents(){this._world.final("CHUNK.SPAWN",this._onChunkSpawn),this._world.final("CHUNK.DESPAWN",this._onChunkDespawn),this._world.final("CHUNK.SET_BLOCK",this._onChunkSetBlock)}_subscribeToEntityEvents(){this._world.final("ENTITY.SPAWN",this._onEntitySpawn),this._world.final("ENTITY.DESPAWN",this._onEntityDespawn),this._world.final("ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",this._onEntitySetModelAnimationsPlaybackRate),this._world.final("ENTITY.SET_MODEL_HIDDEN_NODES",this._onEntitySetModelHiddenNodes),this._world.final("ENTITY.SET_OPACITY",this._onEntitySetOpacity),this._world.final("ENTITY.SET_PARENT",this._onEntitySetParent),this._world.final("ENTITY.SET_TINT_COLOR",this._onEntitySetTintColor),this._world.final("ENTITY.START_MODEL_LOOPED_ANIMATIONS",this._onEntityStartModelLoopedAnimations),this._world.final("ENTITY.START_MODEL_ONESHOT_ANIMATIONS",this._onEntityStartModelOneshotAnimations),this._world.final("ENTITY.STOP_MODEL_ANIMATIONS",this._onEntityStopModelAnimations),this._world.final("ENTITY.UPDATE_POSITION",this._onEntityUpdatePosition),this._world.final("ENTITY.UPDATE_ROTATION",this._onEntityUpdateRotation)}_subscribeToLightEvents(){this._world.final("LIGHT.DESPAWN",this._onLightDespawn),this._world.final("LIGHT.SET_ANGLE",this._onLightSetAngle),this._world.final("LIGHT.SET_ATTACHED_TO_ENTITY",this._onLightSetAttachedToEntity),this._world.final("LIGHT.SET_COLOR",this._onLightSetColor),this._world.final("LIGHT.SET_DISTANCE",this._onLightSetDistance),this._world.final("LIGHT.SET_INTENSITY",this._onLightSetIntensity),this._world.final("LIGHT.SET_OFFSET",this._onLightSetOffset),this._world.final("LIGHT.SET_PENUMBRA",this._onLightSetPenumbra),this._world.final("LIGHT.SET_POSITION",this._onLightSetPosition),this._world.final("LIGHT.SET_TRACKED_ENTITY",this._onLightSetTrackedEntity),this._world.final("LIGHT.SET_TRACKED_POSITION",this._onLightSetTrackedPosition),this._world.final("LIGHT.SPAWN",this._onLightSpawn)}_subscribeToPlayerEvents(){this._world.final("PLAYER.JOINED_WORLD",this._onPlayerJoinedWorld),this._world.final("PLAYER.LEFT_WORLD",this._onPlayerLeftWorld),this._world.final("PLAYER.REQUEST_SYNC",this._onPlayerRequestSync)}_subscribeToPlayerCameraEvents(){this._world.final("PLAYER_CAMERA.LOOK_AT_ENTITY",this._onPlayerCameraLookAtEntity),this._world.final("PLAYER_CAMERA.LOOK_AT_POSITION",this._onPlayerCameraLookAtPosition),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",this._onPlayerCameraSetAttachedToEntity),this._world.final("PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",this._onPlayerCameraSetAttachedToPosition),this._world.final("PLAYER_CAMERA.SET_FILM_OFFSET",this._onPlayerCameraSetFilmOffset),this._world.final("PLAYER_CAMERA.SET_FORWARD_OFFSET",this._onPlayerCameraSetForwardOffset),this._world.final("PLAYER_CAMERA.SET_FOV",this._onPlayerCameraSetFov),this._world.final("PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",this._onPlayerCameraSetModelHiddenNodes),this._world.final("PLAYER_CAMERA.SET_MODE",this._onPlayerCameraSetMode),this._world.final("PLAYER_CAMERA.SET_OFFSET",this._onPlayerCameraSetOffset),this._world.final("PLAYER_CAMERA.SET_TRACKED_ENTITY",this._onPlayerCameraSetTrackedEntity),this._world.final("PLAYER_CAMERA.SET_TRACKED_POSITION",this._onPlayerCameraSetTrackedPosition),this._world.final("PLAYER_CAMERA.SET_ZOOM",this._onPlayerCameraSetZoom)}_subscribeToPlayerUIEvents(){this._world.final("PLAYER_UI.LOAD",this._onPlayerUILoad),this._world.final("PLAYER_UI.LOCK_POINTER",this._onPlayerUILockPointer),this._world.final("PLAYER_UI.SEND_DATA",this._onPlayerUISendData)}_subscribeToSceneUIEvents(){this._world.final("SCENE_UI.LOAD",this._onSceneUILoad),this._world.final("SCENE_UI.SET_ATTACHED_TO_ENTITY",this._onSceneUISetAttachedToEntity),this._world.final("SCENE_UI.SET_OFFSET",this._onSceneUISetOffset),this._world.final("SCENE_UI.SET_POSITION",this._onSceneUISetPosition),this._world.final("SCENE_UI.SET_STATE",this._onSceneUISetState),this._world.final("SCENE_UI.SET_VIEW_DISTANCE",this._onSceneUISetViewDistance),this._world.final("SCENE_UI.UNLOAD",this._onSceneUIUnload)}_subscribeToSimulationEvents(){this._world.final("SIMULATION.DEBUG_RAYCAST",this._onSimulationDebugRaycast),this._world.final("SIMULATION.DEBUG_RENDER",this._onSimulationDebugRender)}_subscribeToWorldEvents(){this._world.final("WORLD.SET_AMBIENT_LIGHT_COLOR",this._onWorldSetAmbientLightColor),this._world.final("WORLD.SET_AMBIENT_LIGHT_INTENSITY",this._onWorldSetAmbientLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",this._onWorldSetDirectionalLightColor),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",this._onWorldSetDirectionalLightIntensity),this._world.final("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",this._onWorldSetDirectionalLightPosition)}_onAudioPause=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pa=!0,delete Z.pl,delete Z.r};_onAudioPlay=(J)=>{let Z=J.audio.serialize();Z.pl=!0,delete Z.pa,delete Z.r,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioPlayRestart=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.r=!0,delete Z.pa,delete Z.pl,this._queuedAudioSynchronizations[Z.i]=Z};_onAudioSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onAudioSetCutoffDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.cd=J.cutoffDistance};_onAudioSetDetune=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.de=J.detune};_onAudioSetDistortion=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.di=J.distortion};_onAudioSetPosition=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.e=J.position?void 0:Z.e,Z.p=J.position?t.serializeVector(J.position):void 0};_onAudioSetPlaybackRate=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.pr=J.playbackRate};_onAudioSetReferenceDistance=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.rd=J.referenceDistance};_onAudioSetVolume=(J)=>{let Z=this._createOrGetQueuedAudioSync(J.audio);Z.v=J.volume};_onBlockTypeRegistryRegisterBlockType=(J)=>{let Z=J.blockType.serialize();this._queuedBlockTypeSynchronizations[J.blockType.id]=Z};_onChatSendBroadcastMessage=(J)=>{let{player:Z,message:X,color:Y}=J;this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:X,color:Y}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:X,c:Y}],this._world.loop.currentTick)),this._queuedPerPlayerSynchronizations.set(Z,K)};_onChunkSpawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk);Z.b=Array.from(J.chunk.blocks),Z.rm=void 0,this._spawnedChunks.add(Z.c.join(","))};_onChunkDespawn=(J)=>{let Z=this._createOrGetQueuedChunkSync(J.chunk),X=Z.c.join(",");if(this._spawnedChunks.has(X))delete this._queuedChunkSynchronizations[X],this._spawnedChunks.delete(X);else Z.rm=!0};_onChunkSetBlock=(J)=>{let Z=this._createOrGetQueuedBlockSync(J.globalCoordinate);Z.i=J.blockTypeId};_onEntitySetModelAnimationsPlaybackRate=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.ap=J.playbackRate};_onEntitySpawn=(J)=>{let Z=J.entity.serialize();this._queuedEntitySynchronizations[Z.i]=Z,this._spawnedEntities.add(Z.i)};_onEntityDespawn=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(this._spawnedEntities.has(Z.i))delete this._queuedEntitySynchronizations[Z.i],this._spawnedEntities.delete(Z.i);else Z.rm=!0};_onEntitySetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.h=Array.from(J.modelHiddenNodes)};_onEntitySetOpacity=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.o=J.opacity};_onEntitySetParent=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.pe=J.parent?J.parent.id:void 0,Z.pn=J.parentNodeName};_onEntitySetTintColor=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.t=J.tintColor?t.serializeRgbColor(J.tintColor):void 0};_onEntityStartModelLoopedAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al=Array.from(new Set([...Z.al??[],...J.animations])),Z.as)Z.as=Z.as.filter((X)=>!J.animations.has(X)).filter(Boolean)};_onEntityStartModelOneshotAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.ao=Array.from(new Set([...Z.ao??[],...J.animations])),Z.as)Z.as=Z.as.filter((X)=>!J.animations.has(X)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((X)=>!J.animations.has(X)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((X)=>!J.animations.has(X)).filter(Boolean);Z.as=Array.from(new Set([...Z.as??[],...J.animations]))};_onEntityUpdateRotation=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.r=[J.rotation.x,J.rotation.y,J.rotation.z,J.rotation.w]};_onEntityUpdatePosition=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);Z.p=[J.position.x,J.position.y,J.position.z]};_onLightDespawn=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.rm=!0};_onLightSetAngle=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.a=J.angle};_onLightSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onLightSetColor=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.c=t.serializeRgbColor(J.color)};_onLightSetDistance=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.d=J.distance};_onLightSetIntensity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.n=J.intensity};_onLightSetOffset=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onLightSetPenumbra=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.pe=J.penumbra};_onLightSetPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.p=J.position?t.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onLightSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.te=J.entity?J.entity.id:void 0,Z.tp=J.entity?void 0:Z.tp};_onLightSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedLightSync(J.light);Z.tp=J.position?t.serializeVector(J.position):void 0,Z.te=J.position?void 0:Z.te};_onLightSpawn=(J)=>{let Z=J.light.serialize();this._queuedLightSynchronizations[Z.i]=Z};_onPlayerCameraLookAtEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=t.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?t.serializeVector(J.position):void 0,delete Z.et,delete Z.pt};_onPlayerCameraSetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.e=J.entity.id,delete Z.p};_onPlayerCameraSetAttachedToPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.p=J.position?t.serializeVector(J.position):void 0,delete Z.e};_onPlayerCameraSetFilmOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fo=J.filmOffset};_onPlayerCameraSetForwardOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.ffo=J.forwardOffset};_onPlayerCameraSetFov=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.fv=J.fov};_onPlayerCameraSetModelHiddenNodes=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.h=Array.from(J.modelHiddenNodes)};_onPlayerCameraSetMode=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.m=J.mode};_onPlayerCameraSetOffset=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onPlayerCameraSetTrackedEntity=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.et=J.entity?J.entity.id:void 0,delete Z.pl,delete Z.pt};_onPlayerCameraSetTrackedPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pt=J.position?t.serializeVector(J.position):void 0,delete Z.et,delete Z.pl};_onPlayerCameraSetZoom=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.z=J.zoom};_onPlayerJoinedWorld=(J)=>{let{player:Z}=J,X=this._queuedPerPlayerSynchronizations.get(Z)??[];X.push(y.createPacket(y.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof d1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),X.push(y.createPacket(y.outboundPackets.playersPacketDefinition,U1.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let Y=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...Y}),this._queuedPerPlayerSynchronizations.set(Z,X),this._queuedPlayerSynchronizations[Z.id]=Z.serialize()};_onPlayerLeftWorld=(J)=>{let Z=this._createOrGetQueuedPlayerSync(J.player);Z.rm=!0};_onPlayerRequestSync=(J)=>{J.player.connection.send([y.createPacket(y.outboundPackets.syncResponsePacketDefinition,{r:J.receivedAt,s:Date.now(),p:performance.now()-J.receivedAtMs,n:this._world.loop.nextTickMs},this._world.loop.currentTick)])};_onPlayerUILoad=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.u=J.htmlUri};_onPlayerUILockPointer=(J)=>{let Z=this._createOrGetQueuedPlayerUISync(J.playerUI);Z.p=J.lock};_onPlayerUISendData=(J)=>{this._createOrGetQueuedPlayerUIDatasSync(J.playerUI).push(J.data)};_onSceneUILoad=(J)=>{let Z=J.sceneUI.serialize();this._queuedSceneUISynchronizations[Z.i]=Z,this._loadedSceneUIs.add(Z.i)};_onSceneUISetAttachedToEntity=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.e=J.entity?J.entity.id:void 0,Z.p=J.entity?void 0:Z.p};_onSceneUISetOffset=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.o=J.offset?t.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?t.serializeVector(J.position):void 0,Z.e=J.position?void 0:Z.e};_onSceneUISetState=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.s=J.state};_onSceneUISetViewDistance=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.v=J.viewDistance};_onSceneUIUnload=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);if(this._loadedSceneUIs.has(Z.i))delete this._queuedSceneUISynchronizations[Z.i],this._loadedSceneUIs.delete(Z.i);else Z.rm=!0};_onSimulationDebugRaycast=(J)=>{this._queuedDebugRaycastSynchronizations.push(t.serializePhysicsDebugRaycast(J))};_onSimulationDebugRender=(J)=>{this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.physicsDebugRenderPacketDefinition,{v:Array.from(J.vertices),c:Array.from(J.colors)},this._world.loop.currentTick))};_onWorldSetAmbientLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ac=t.serializeRgbColor(J.color)};_onWorldSetAmbientLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.ai=J.intensity};_onWorldSetDirectionalLightColor=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dc=t.serializeRgbColor(J.color)};_onWorldSetDirectionalLightIntensity=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.di=J.intensity};_onWorldSetDirectionalLightPosition=(J)=>{let Z=this._createOrGetQueuedWorldSync(J.world);Z.dp=t.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:X,z:Y}=J;return this._queuedBlockSynchronizations[`${Z},${X},${Y}`]??={i:0,c:[Z,X,Y]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)_.fatalError("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:X,z:Y}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${X},${Y}`]??={c:[Z,X,Y]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedPlayerSync(): Player has no id!");return this._queuedPlayerSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerCameraSync(J){let Z=this._queuedPerPlayerCameraSynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerCameraSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUISync(J){let Z=this._queuedPerPlayerUISynchronizations.get(J.player);if(!Z)Z={},this._queuedPerPlayerUISynchronizations.set(J.player,Z);return Z}_createOrGetQueuedPlayerUIDatasSync(J){let Z=this._queuedPerPlayerUIDatasSynchronizations.get(J.player);if(!Z)Z=[],this._queuedPerPlayerUIDatasSynchronizations.set(J.player,Z);return Z}_createOrGetQueuedSceneUISync(J){if(J.id===void 0)_.fatalError("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)_.fatalError("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}_createOrGetSynchronizedPlayerPackets(J,Z){let X=this._synchronizedPlayerPackets.get(J);if(!X)X=[...Z],this._synchronizedPlayerPackets.set(J,X);return X}}class _J{_sceneUIs=new Map;_nextSceneUIId=1;_world;constructor(J){this._world=J}get world(){return this._world}getAllSceneUIs(){return Array.from(this._sceneUIs.values())}getAllEntityAttachedSceneUIs(J){return this.getAllSceneUIs().filter((Z)=>Z.attachedToEntity===J)}getSceneUIById(J){return this._sceneUIs.get(J)}registerSceneUI(J){if(J.id!==void 0)return J.id;let Z=this._nextSceneUIId;return this._sceneUIs.set(Z,J),this._nextSceneUIId++,Z}unloadEntityAttachedSceneUIs(J){this.getAllEntityAttachedSceneUIs(J).forEach((Z)=>{Z.unload()})}unregisterSceneUI(J){if(J.id===void 0)return;this._sceneUIs.delete(J.id)}}class CJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,X){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=X}get targetTicksPerSecond(){return this._targetTicksPerSecond}get fixedTimestepMs(){return this._fixedTimestepMs}get fixedTimestepS(){return this._fixedTimestepS}get nextTickMs(){return this._nextTickMs}start(){if(this._tickHandle)return _.warning("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),X=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,X>250)X=250;this._accumulatorMs+=X;while(this._accumulatorMs>=this._fixedTimestepMs)this._tick(this._fixedTimestepMs),this._accumulatorMs-=this._fixedTimestepMs;this._nextTickMs=this._fixedTimestepMs-this._accumulatorMs,this._tickHandle=setTimeout(J,0)};J()}stop(){if(!this._tickHandle)return _.warning("Ticker.stop(): ticker not running.");clearTimeout(this._tickHandle),this._tickHandle=null}_tick(J){try{this._tickFunction(J)}catch(Z){if(Z instanceof Error&&this._tickErrorCallback)this._tickErrorCallback(Z);else _.warning(`Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error: ${Z}`)}}}var vE;(($)=>{$.START="WORLD_LOOP.START";$.STOP="WORLD_LOOP.STOP";$.TICK_START="WORLD_LOOP.TICK_START";$.TICK_END="WORLD_LOOP.TICK_END";$.TICK_ERROR="WORLD_LOOP.TICK_ERROR"})(vE||={});class EJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=LV){super();this._ticker=new CJ(Z,this._tick,this._onTickError),this._world=J}get currentTick(){return this._currentTick}get nextTickMs(){return this._ticker.nextTickMs}get timestepS(){return this._ticker.fixedTimestepS}get world(){return this._world}start(){this._ticker.start(),this.emitWithWorld(this._world,"WORLD_LOOP.START",{worldLoop:this})}stop(){this._ticker.stop(),this.emitWithWorld(this._world,"WORLD_LOOP.STOP",{worldLoop:this})}_tick=(J)=>{this.emitWithWorld(this._world,"WORLD_LOOP.TICK_START",{worldLoop:this,tickDeltaMs:J});let Z=performance.now();this._world.chunkLattice.updateChunks(),this._world.entityManager.tickEntities(J),this._world.simulation.step(J),this._world.entityManager.checkAndEmitUpdates(),this._world.networkSynchronizer.synchronize(),this._currentTick++,this.emitWithWorld(this._world,"WORLD_LOOP.TICK_END",{worldLoop:this,tickDurationMs:performance.now()-Z})};_onTickError=(J)=>{_.error(`WorldLoop._onTickError(): Error: ${J}`),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var MV;((G)=>{G.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";G.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";G.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";G.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";G.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";G.START="WORLD.START";G.STOP="WORLD.STOP"})(MV||={});class SJ extends s{_id;_ambientLightColor;_ambientLightIntensity;_directionalLightColor;_directionalLightIntensity;_directionalLightPosition;_name;_skyboxUri;_audioManager;_blockTypeRegistry;_chatManager;_chunkLattice;_entityManager;_lightManager;_loop;_networkSynchronizer;_sceneUIManager;_simulation;constructor(J){super();this._id=J.id,this._ambientLightColor=J.ambientLightColor??{r:255,g:255,b:255},this._ambientLightIntensity=J.ambientLightIntensity??1,this._directionalLightColor=J.directionalLightColor??{r:255,g:255,b:255},this._directionalLightIntensity=J.directionalLightIntensity??3,this._directionalLightPosition=J.directionalLightPosition??{x:100,y:150,z:100},this._name=J.name,this._skyboxUri=J.skyboxUri,this._audioManager=new $4(this),this._blockTypeRegistry=new m4(this),this._chatManager=new IJ(this),this._chunkLattice=new OJ(this),this._entityManager=new BJ(this),this._lightManager=new vJ(this),this._loop=new EJ(this,J.tickRate),this._networkSynchronizer=new Q$(this),this._sceneUIManager=new _J(this),this._simulation=new kJ(this,J.tickRate,J.gravity)}get id(){return this._id}get ambientLightColor(){return this._ambientLightColor}get ambientLightIntensity(){return this._ambientLightIntensity}get directionalLightColor(){return this._directionalLightColor}get directionalLightIntensity(){return this._directionalLightIntensity}get directionalLightPosition(){return this._directionalLightPosition}get name(){return this._name}get skyboxUri(){return this._skyboxUri}get audioManager(){return this._audioManager}get blockTypeRegistry(){return this._blockTypeRegistry}get chatManager(){return this._chatManager}get chunkLattice(){return this._chunkLattice}get entityManager(){return this._entityManager}get lightManager(){return this._lightManager}get loop(){return this._loop}get networkSynchronizer(){return this._networkSynchronizer}get sceneUIManager(){return this._sceneUIManager}get simulation(){return this._simulation}loadMap(J){if(J.blockTypes)for(let Z of J.blockTypes)this.blockTypeRegistry.registerGenericBlockType({id:Z.id,isLiquid:Z.isLiquid,name:Z.name,textureUri:Z.textureUri});if(J.blocks)for(let[Z,X]of Object.entries(J.blocks)){let[Y,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:Y,y:K,z:$},X)}if(J.entities)for(let[Z,X]of Object.entries(J.entities)){let[Y,K,$]=Z.split(",").map(Number);new Z8(X).spawn(this,{x:Y,y:K,z:$})}}setAmbientLightColor(J){this._ambientLightColor=J,this.emit("WORLD.SET_AMBIENT_LIGHT_COLOR",{world:this,color:J})}setAmbientLightIntensity(J){this._ambientLightIntensity=J,this.emit("WORLD.SET_AMBIENT_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightColor(J){this._directionalLightColor=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_COLOR",{world:this,color:J})}setDirectionalLightIntensity(J){this._directionalLightIntensity=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY",{world:this,intensity:J})}setDirectionalLightPosition(J){this._directionalLightPosition=J,this.emit("WORLD.SET_DIRECTIONAL_LIGHT_POSITION",{world:this,position:J})}start(){this._loop.start(),this.emit("WORLD.START",{world:this,startedAtMs:Date.now()})}stop(){this._loop.stop(),this.emit("WORLD.STOP",{world:this,stoppedAtMs:Date.now()})}serialize(){return t.serializeWorld(this)}}var jE;((X)=>{X.START="GAMESERVER.START";X.STOP="GAMESERVER.STOP"})(jE||={});function _Z0(J){z0.init().then(()=>{return M1.instance.modelRegistry.preloadModels()}).then(()=>{J(M1.instance.worlds[0]),M1.instance.start()}).catch((Z)=>{_.fatalError(`Failed to initialize the game engine, exiting. Error: ${Z}`)})}class M1{static _instance;_modelRegistry=U6.instance;_playerManager=U1.instance;_socket=wJ.instance;_webServer=o5.instance;_worlds={};constructor(){let J=new SJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new M1;return this._instance}get modelRegistry(){return this._modelRegistry}get playerManager(){return this._playerManager}get socket(){return this._socket}get webServer(){return this._webServer}get worlds(){return this._worlds}start(){c8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){c8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class h9{static instance=new h9;constructor(){}async getGlobalData(J){let Z=await m6.instance.getData(J);if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await m6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)_.warning(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let X=await m6.instance.setData(J,Z);if(!X||X.error){if(X?.error)_.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(J,Z){let X=await m6.instance.setData(this._getPlayerKey(J),Z);if(!X||X.error){if(X?.error)_.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(J){return`player-${J.id}`}}var TE=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","1","2","3","4","5","6","7","8","9","0"],NJ;((K)=>{K.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";K.JOINED_WORLD="PLAYER.JOINED_WORLD";K.LEFT_WORLD="PLAYER.LEFT_WORLD";K.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(NJ||={});class w5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${w5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new jJ(this),this.connection=J,this.ui=new TJ(this),J.onPacket(y.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),J.onPacket(y.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),J.onPacket(y.PacketId.INPUT,this._onInputPacket),J.onPacket(y.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),J.onPacket(y.PacketId.UI_DATA_SEND,this._onUIDataSendPacket),this.joinWorld(M1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return h9.instance.getPlayerData(this)}joinWorld(J){this.leaveWorld(),this._world=J,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}async setPersistedData(J){return h9.instance.setPlayerData(this,J)}serialize(){return t.serializePlayer(this)}_onChatMessageSendPacket=(J)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:J[1].m})};_onDebugConfigPacket=(J)=>{console.log(J)};_onInputPacket=(J)=>{let Z=J[1];if(TE.forEach((X)=>{let Y=X;if(Z[Y]!==void 0)this._input[Y]=Boolean(Z[Y])}),Z.cp!==void 0)this.camera.setOrientationPitch(Z.cp);if(Z.cy!==void 0)this.camera.setOrientationYaw(Z.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(J)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:J[1]})}}var wV;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(wV||={});class IJ extends s{_commandCallbacks={};_world;constructor(J){super();this._world=J,this._subscribeToPlayerEvents()}registerCommand(J,Z){this._commandCallbacks[J]=Z}unregisterCommand(J){delete this._commandCallbacks[J]}sendBroadcastMessage(J,Z){this._sendBroadcastMessage(void 0,J,Z)}sendPlayerMessage(J,Z,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:X}=J,[Y,...K]=X.split(" "),$=this._commandCallbacks[Y];if($){$(Z,K,X);return}this._sendBroadcastMessage(Z,X)})}_sendBroadcastMessage(J,Z,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:X})}}var m=0.000001,Q0=typeof Float32Array!=="undefined"?Float32Array:Array,l6=Math.random;var fk0=Math.PI/180;if(!Math.hypot)Math.hypot=function(){var J=0,Z=arguments.length;while(Z--)J+=arguments[Z]*arguments[Z];return Math.sqrt(J)};var t0={};n6(t0,{transpose:()=>bZ0,subtract:()=>kE,sub:()=>eZ0,str:()=>uZ0,set:()=>hZ0,scale:()=>cZ0,rotate:()=>gZ0,multiplyScalarAndAdd:()=>rZ0,multiplyScalar:()=>oZ0,multiply:()=>DE,mul:()=>tZ0,invert:()=>AZ0,identity:()=>IZ0,fromValues:()=>fZ0,fromScaling:()=>lZ0,fromRotation:()=>mZ0,frob:()=>dZ0,exactEquals:()=>aZ0,equals:()=>sZ0,determinant:()=>yZ0,create:()=>CZ0,copy:()=>SZ0,clone:()=>EZ0,adjoint:()=>pZ0,add:()=>nZ0,LDU:()=>iZ0});function CZ0(){var J=new Q0(4);if(Q0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function EZ0(J){var Z=new Q0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function SZ0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function IZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function fZ0(J,Z,X,Y){var K=new Q0(4);return K[0]=J,K[1]=Z,K[2]=X,K[3]=Y,K}function hZ0(J,Z,X,Y,K){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J}function bZ0(J,Z){if(J===Z){var X=Z[1];J[1]=Z[2],J[2]=X}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function AZ0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*$-K*Y;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-Y*Q,J[2]=-K*Q,J[3]=X*Q,J}function pZ0(J,Z){var X=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=X,J}function yZ0(J){return J[0]*J[3]-J[2]*J[1]}function DE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1],W=X[2],q=X[3];return J[0]=Y*G+$*F,J[1]=K*G+Q*F,J[2]=Y*W+$*q,J[3]=K*W+Q*q,J}function gZ0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+$*G,J[1]=K*F+Q*G,J[2]=Y*-G+$*F,J[3]=K*-G+Q*F,J}function cZ0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1];return J[0]=Y*G,J[1]=K*G,J[2]=$*F,J[3]=Q*F,J}function mZ0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=-X,J[3]=Y,J}function lZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function uZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function dZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function iZ0(J,Z,X,Y){return J[2]=Y[2]/Y[0],X[0]=Y[0],X[1]=Y[1],X[3]=Y[3]-J[2]*X[1],[J,Z,X]}function nZ0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J}function kE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J}function aZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function sZ0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=Z[0],G=Z[1],F=Z[2],W=Z[3];return Math.abs(X-Q)<=m*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-G)<=m*Math.max(1,Math.abs(Y),Math.abs(G))&&Math.abs(K-F)<=m*Math.max(1,Math.abs(K),Math.abs(F))&&Math.abs($-W)<=m*Math.max(1,Math.abs($),Math.abs(W))}function oZ0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J}function rZ0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J}var tZ0=DE,eZ0=kE;var I0={};n6(I0,{transpose:()=>QX0,translate:()=>qX0,subtract:()=>CE,sub:()=>kX0,str:()=>xX0,set:()=>KX0,scale:()=>zX0,rotate:()=>VX0,projection:()=>OX0,normalFromMat4:()=>wX0,multiplyScalarAndAdd:()=>vX0,multiplyScalar:()=>BX0,multiply:()=>_E,mul:()=>DX0,invert:()=>GX0,identity:()=>$X0,fromValues:()=>YX0,fromTranslation:()=>HX0,fromScaling:()=>LX0,fromRotation:()=>UX0,fromQuat:()=>MX0,fromMat4:()=>JX0,fromMat2d:()=>RX0,frob:()=>PX0,exactEquals:()=>jX0,equals:()=>TX0,determinant:()=>WX0,create:()=>OV,copy:()=>XX0,clone:()=>ZX0,adjoint:()=>FX0,add:()=>NX0});function OV(){var J=new Q0(9);if(Q0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[5]=0,J[6]=0,J[7]=0;return J[0]=1,J[4]=1,J[8]=1,J}function JX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[4],J[4]=Z[5],J[5]=Z[6],J[6]=Z[8],J[7]=Z[9],J[8]=Z[10],J}function ZX0(J){var Z=new Q0(9);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z}function XX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function YX0(J,Z,X,Y,K,$,Q,G,F){var W=new Q0(9);return W[0]=J,W[1]=Z,W[2]=X,W[3]=Y,W[4]=K,W[5]=$,W[6]=Q,W[7]=G,W[8]=F,W}function KX0(J,Z,X,Y,K,$,Q,G,F,W){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J[4]=$,J[5]=Q,J[6]=G,J[7]=F,J[8]=W,J}function $X0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function QX0(J,Z){if(J===Z){var X=Z[1],Y=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=X,J[5]=Z[7],J[6]=Y,J[7]=K}else J[0]=Z[0],J[1]=Z[3],J[2]=Z[6],J[3]=Z[1],J[4]=Z[4],J[5]=Z[7],J[6]=Z[2],J[7]=Z[5],J[8]=Z[8];return J}function GX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=q*Q-G*W,z=-q*$+G*F,L=W*$-Q*F,R=X*V+Y*z+K*L;if(!R)return null;return R=1/R,J[0]=V*R,J[1]=(-q*Y+K*W)*R,J[2]=(G*Y-K*Q)*R,J[3]=z*R,J[4]=(q*X-K*F)*R,J[5]=(-G*X+K*$)*R,J[6]=L*R,J[7]=(-W*X+Y*F)*R,J[8]=(Q*X-Y*$)*R,J}function FX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8];return J[0]=Q*q-G*W,J[1]=K*W-Y*q,J[2]=Y*G-K*Q,J[3]=G*F-$*q,J[4]=X*q-K*F,J[5]=K*$-X*G,J[6]=$*W-Q*F,J[7]=Y*F-X*W,J[8]=X*Q-Y*$,J}function WX0(J){var Z=J[0],X=J[1],Y=J[2],K=J[3],$=J[4],Q=J[5],G=J[6],F=J[7],W=J[8];return Z*(W*$-Q*F)+X*(-W*K+Q*G)+Y*(F*K-$*G)}function _E(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=X[0],L=X[1],R=X[2],M=X[3],H=X[4],O=X[5],P=X[6],N=X[7],B=X[8];return J[0]=z*Y+L*Q+R*W,J[1]=z*K+L*G+R*q,J[2]=z*$+L*F+R*V,J[3]=M*Y+H*Q+O*W,J[4]=M*K+H*G+O*q,J[5]=M*$+H*F+O*V,J[6]=P*Y+N*Q+B*W,J[7]=P*K+N*G+B*q,J[8]=P*$+N*F+B*V,J}function qX0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=X[0],L=X[1];return J[0]=Y,J[1]=K,J[2]=$,J[3]=Q,J[4]=G,J[5]=F,J[6]=z*Y+L*Q+W,J[7]=z*K+L*G+q,J[8]=z*$+L*F+V,J}function VX0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=Math.sin(X),L=Math.cos(X);return J[0]=L*Y+z*Q,J[1]=L*K+z*G,J[2]=L*$+z*F,J[3]=L*Q-z*Y,J[4]=L*G-z*K,J[5]=L*F-z*$,J[6]=W,J[7]=q,J[8]=V,J}function zX0(J,Z,X){var Y=X[0],K=X[1];return J[0]=Y*Z[0],J[1]=Y*Z[1],J[2]=Y*Z[2],J[3]=K*Z[3],J[4]=K*Z[4],J[5]=K*Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J}function HX0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=1,J[5]=0,J[6]=Z[0],J[7]=Z[1],J[8]=1,J}function UX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=0,J[3]=-X,J[4]=Y,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function LX0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=Z[1],J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function RX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=0,J[3]=Z[2],J[4]=Z[3],J[5]=0,J[6]=Z[4],J[7]=Z[5],J[8]=1,J}function MX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X+X,G=Y+Y,F=K+K,W=X*Q,q=Y*Q,V=Y*G,z=K*Q,L=K*G,R=K*F,M=$*Q,H=$*G,O=$*F;return J[0]=1-V-R,J[3]=q-O,J[6]=z+H,J[1]=q+O,J[4]=1-W-R,J[7]=L-M,J[2]=z-H,J[5]=L+M,J[8]=1-W-V,J}function wX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15],P=X*G-Y*Q,N=X*F-K*Q,B=X*W-$*Q,j=Y*F-K*G,w=Y*W-$*G,k=K*W-$*F,C=q*M-V*R,E=q*H-z*R,S=q*O-L*R,I=V*H-z*M,h=V*O-L*M,p=z*O-L*H,f=P*p-N*h+B*I+j*S-w*E+k*C;if(!f)return null;return f=1/f,J[0]=(G*p-F*h+W*I)*f,J[1]=(F*S-Q*p-W*E)*f,J[2]=(Q*h-G*S+W*C)*f,J[3]=(K*h-Y*p-$*I)*f,J[4]=(X*p-K*S+$*E)*f,J[5]=(Y*S-X*h-$*C)*f,J[6]=(M*k-H*w+O*j)*f,J[7]=(H*B-R*k-O*N)*f,J[8]=(R*w-M*B+O*P)*f,J}function OX0(J,Z,X){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/X,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function xX0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function PX0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function NX0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J[4]=Z[4]+X[4],J[5]=Z[5]+X[5],J[6]=Z[6]+X[6],J[7]=Z[7]+X[7],J[8]=Z[8]+X[8],J}function CE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J[4]=Z[4]-X[4],J[5]=Z[5]-X[5],J[6]=Z[6]-X[6],J[7]=Z[7]-X[7],J[8]=Z[8]-X[8],J}function BX0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*X,J[5]=Z[5]*X,J[6]=Z[6]*X,J[7]=Z[7]*X,J[8]=Z[8]*X,J}function vX0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J[4]=Z[4]+X[4]*Y,J[5]=Z[5]+X[5]*Y,J[6]=Z[6]+X[6]*Y,J[7]=Z[7]+X[7]*Y,J[8]=Z[8]+X[8]*Y,J}function jX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]}function TX0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=J[4],G=J[5],F=J[6],W=J[7],q=J[8],V=Z[0],z=Z[1],L=Z[2],R=Z[3],M=Z[4],H=Z[5],O=Z[6],P=Z[7],N=Z[8];return Math.abs(X-V)<=m*Math.max(1,Math.abs(X),Math.abs(V))&&Math.abs(Y-z)<=m*Math.max(1,Math.abs(Y),Math.abs(z))&&Math.abs(K-L)<=m*Math.max(1,Math.abs(K),Math.abs(L))&&Math.abs($-R)<=m*Math.max(1,Math.abs($),Math.abs(R))&&Math.abs(Q-M)<=m*Math.max(1,Math.abs(Q),Math.abs(M))&&Math.abs(G-H)<=m*Math.max(1,Math.abs(G),Math.abs(H))&&Math.abs(F-O)<=m*Math.max(1,Math.abs(F),Math.abs(O))&&Math.abs(W-P)<=m*Math.max(1,Math.abs(W),Math.abs(P))&&Math.abs(q-N)<=m*Math.max(1,Math.abs(q),Math.abs(N))}var DX0=_E,kX0=CE;var X0={};n6(X0,{transpose:()=>fX0,translate:()=>pX0,targetTo:()=>WY0,subtract:()=>AE,sub:()=>wY0,str:()=>qY0,set:()=>IX0,scale:()=>yX0,rotateZ:()=>lX0,rotateY:()=>mX0,rotateX:()=>cX0,rotate:()=>gX0,perspectiveZO:()=>KY0,perspectiveNO:()=>hE,perspectiveFromFieldOfView:()=>$Y0,perspective:()=>YY0,orthoZO:()=>GY0,orthoNO:()=>bE,ortho:()=>QY0,multiplyScalarAndAdd:()=>UY0,multiplyScalar:()=>HY0,multiply:()=>SE,mul:()=>MY0,lookAt:()=>FY0,invert:()=>hX0,identity:()=>EE,getTranslation:()=>rX0,getScaling:()=>fE,getRotation:()=>tX0,frustum:()=>XY0,fromZRotation:()=>sX0,fromYRotation:()=>aX0,fromXRotation:()=>nX0,fromValues:()=>SX0,fromTranslation:()=>uX0,fromScaling:()=>dX0,fromRotationTranslationScaleOrigin:()=>JY0,fromRotationTranslationScale:()=>eX0,fromRotationTranslation:()=>IE,fromRotation:()=>iX0,fromQuat2:()=>oX0,fromQuat:()=>ZY0,frob:()=>VY0,exactEquals:()=>LY0,equals:()=>RY0,determinant:()=>AX0,create:()=>_X0,copy:()=>EX0,clone:()=>CX0,adjoint:()=>bX0,add:()=>zY0});function _X0(){var J=new Q0(16);if(Q0!=Float32Array)J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=0,J[12]=0,J[13]=0,J[14]=0;return J[0]=1,J[5]=1,J[10]=1,J[15]=1,J}function CX0(J){var Z=new Q0(16);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z[4]=J[4],Z[5]=J[5],Z[6]=J[6],Z[7]=J[7],Z[8]=J[8],Z[9]=J[9],Z[10]=J[10],Z[11]=J[11],Z[12]=J[12],Z[13]=J[13],Z[14]=J[14],Z[15]=J[15],Z}function EX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function SX0(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M){var H=new Q0(16);return H[0]=J,H[1]=Z,H[2]=X,H[3]=Y,H[4]=K,H[5]=$,H[6]=Q,H[7]=G,H[8]=F,H[9]=W,H[10]=q,H[11]=V,H[12]=z,H[13]=L,H[14]=R,H[15]=M,H}function IX0(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M,H){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J[4]=$,J[5]=Q,J[6]=G,J[7]=F,J[8]=W,J[9]=q,J[10]=V,J[11]=z,J[12]=L,J[13]=R,J[14]=M,J[15]=H,J}function EE(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function fX0(J,Z){if(J===Z){var X=Z[1],Y=Z[2],K=Z[3],$=Z[6],Q=Z[7],G=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=X,J[6]=Z[9],J[7]=Z[13],J[8]=Y,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=G}else J[0]=Z[0],J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Z[1],J[5]=Z[5],J[6]=Z[9],J[7]=Z[13],J[8]=Z[2],J[9]=Z[6],J[10]=Z[10],J[11]=Z[14],J[12]=Z[3],J[13]=Z[7],J[14]=Z[11],J[15]=Z[15];return J}function hX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15],P=X*G-Y*Q,N=X*F-K*Q,B=X*W-$*Q,j=Y*F-K*G,w=Y*W-$*G,k=K*W-$*F,C=q*M-V*R,E=q*H-z*R,S=q*O-L*R,I=V*H-z*M,h=V*O-L*M,p=z*O-L*H,f=P*p-N*h+B*I+j*S-w*E+k*C;if(!f)return null;return f=1/f,J[0]=(G*p-F*h+W*I)*f,J[1]=(K*h-Y*p-$*I)*f,J[2]=(M*k-H*w+O*j)*f,J[3]=(z*w-V*k-L*j)*f,J[4]=(F*S-Q*p-W*E)*f,J[5]=(X*p-K*S+$*E)*f,J[6]=(H*B-R*k-O*N)*f,J[7]=(q*k-z*B+L*N)*f,J[8]=(Q*h-G*S+W*C)*f,J[9]=(Y*S-X*h-$*C)*f,J[10]=(R*w-M*B+O*P)*f,J[11]=(V*B-q*w-L*P)*f,J[12]=(G*E-Q*I-F*C)*f,J[13]=(X*I-Y*E+K*C)*f,J[14]=(M*N-R*j-H*P)*f,J[15]=(q*j-V*N+z*P)*f,J}function bX0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Z[4],G=Z[5],F=Z[6],W=Z[7],q=Z[8],V=Z[9],z=Z[10],L=Z[11],R=Z[12],M=Z[13],H=Z[14],O=Z[15];return J[0]=G*(z*O-L*H)-V*(F*O-W*H)+M*(F*L-W*z),J[1]=-(Y*(z*O-L*H)-V*(K*O-$*H)+M*(K*L-$*z)),J[2]=Y*(F*O-W*H)-G*(K*O-$*H)+M*(K*W-$*F),J[3]=-(Y*(F*L-W*z)-G*(K*L-$*z)+V*(K*W-$*F)),J[4]=-(Q*(z*O-L*H)-q*(F*O-W*H)+R*(F*L-W*z)),J[5]=X*(z*O-L*H)-q*(K*O-$*H)+R*(K*L-$*z),J[6]=-(X*(F*O-W*H)-Q*(K*O-$*H)+R*(K*W-$*F)),J[7]=X*(F*L-W*z)-Q*(K*L-$*z)+q*(K*W-$*F),J[8]=Q*(V*O-L*M)-q*(G*O-W*M)+R*(G*L-W*V),J[9]=-(X*(V*O-L*M)-q*(Y*O-$*M)+R*(Y*L-$*V)),J[10]=X*(G*O-W*M)-Q*(Y*O-$*M)+R*(Y*W-$*G),J[11]=-(X*(G*L-W*V)-Q*(Y*L-$*V)+q*(Y*W-$*G)),J[12]=-(Q*(V*H-z*M)-q*(G*H-F*M)+R*(G*z-F*V)),J[13]=X*(V*H-z*M)-q*(Y*H-K*M)+R*(Y*z-K*V),J[14]=-(X*(G*H-F*M)-Q*(Y*H-K*M)+R*(Y*F-K*G)),J[15]=X*(G*z-F*V)-Q*(Y*z-K*V)+q*(Y*F-K*G),J}function AX0(J){var Z=J[0],X=J[1],Y=J[2],K=J[3],$=J[4],Q=J[5],G=J[6],F=J[7],W=J[8],q=J[9],V=J[10],z=J[11],L=J[12],R=J[13],M=J[14],H=J[15],O=Z*Q-X*$,P=Z*G-Y*$,N=Z*F-K*$,B=X*G-Y*Q,j=X*F-K*Q,w=Y*F-K*G,k=W*R-q*L,C=W*M-V*L,E=W*H-z*L,S=q*M-V*R,I=q*H-z*R,h=V*H-z*M;return O*h-P*I+N*S+B*E-j*C+w*k}function SE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Z[8],z=Z[9],L=Z[10],R=Z[11],M=Z[12],H=Z[13],O=Z[14],P=Z[15],N=X[0],B=X[1],j=X[2],w=X[3];return J[0]=N*Y+B*G+j*V+w*M,J[1]=N*K+B*F+j*z+w*H,J[2]=N*$+B*W+j*L+w*O,J[3]=N*Q+B*q+j*R+w*P,N=X[4],B=X[5],j=X[6],w=X[7],J[4]=N*Y+B*G+j*V+w*M,J[5]=N*K+B*F+j*z+w*H,J[6]=N*$+B*W+j*L+w*O,J[7]=N*Q+B*q+j*R+w*P,N=X[8],B=X[9],j=X[10],w=X[11],J[8]=N*Y+B*G+j*V+w*M,J[9]=N*K+B*F+j*z+w*H,J[10]=N*$+B*W+j*L+w*O,J[11]=N*Q+B*q+j*R+w*P,N=X[12],B=X[13],j=X[14],w=X[15],J[12]=N*Y+B*G+j*V+w*M,J[13]=N*K+B*F+j*z+w*H,J[14]=N*$+B*W+j*L+w*O,J[15]=N*Q+B*q+j*R+w*P,J}function pX0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q,G,F,W,q,V,z,L,R,M,H,O;if(Z===J)J[12]=Z[0]*Y+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*Y+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*Y+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*Y+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],G=Z[1],F=Z[2],W=Z[3],q=Z[4],V=Z[5],z=Z[6],L=Z[7],R=Z[8],M=Z[9],H=Z[10],O=Z[11],J[0]=Q,J[1]=G,J[2]=F,J[3]=W,J[4]=q,J[5]=V,J[6]=z,J[7]=L,J[8]=R,J[9]=M,J[10]=H,J[11]=O,J[12]=Q*Y+q*K+R*$+Z[12],J[13]=G*Y+V*K+M*$+Z[13],J[14]=F*Y+z*K+H*$+Z[14],J[15]=W*Y+L*K+O*$+Z[15];return J}function yX0(J,Z,X){var Y=X[0],K=X[1],$=X[2];return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J[4]=Z[4]*K,J[5]=Z[5]*K,J[6]=Z[6]*K,J[7]=Z[7]*K,J[8]=Z[8]*$,J[9]=Z[9]*$,J[10]=Z[10]*$,J[11]=Z[11]*$,J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15],J}function gX0(J,Z,X,Y){var K=Y[0],$=Y[1],Q=Y[2],G=Math.hypot(K,$,Q),F,W,q,V,z,L,R,M,H,O,P,N,B,j,w,k,C,E,S,I,h,p,f,g;if(G<m)return null;if(G=1/G,K*=G,$*=G,Q*=G,F=Math.sin(X),W=Math.cos(X),q=1-W,V=Z[0],z=Z[1],L=Z[2],R=Z[3],M=Z[4],H=Z[5],O=Z[6],P=Z[7],N=Z[8],B=Z[9],j=Z[10],w=Z[11],k=K*K*q+W,C=$*K*q+Q*F,E=Q*K*q-$*F,S=K*$*q-Q*F,I=$*$*q+W,h=Q*$*q+K*F,p=K*Q*q+$*F,f=$*Q*q-K*F,g=Q*Q*q+W,J[0]=V*k+M*C+N*E,J[1]=z*k+H*C+B*E,J[2]=L*k+O*C+j*E,J[3]=R*k+P*C+w*E,J[4]=V*S+M*I+N*h,J[5]=z*S+H*I+B*h,J[6]=L*S+O*I+j*h,J[7]=R*S+P*I+w*h,J[8]=V*p+M*f+N*g,J[9]=z*p+H*f+B*g,J[10]=L*p+O*f+j*g,J[11]=R*p+P*f+w*g,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function cX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[4],Q=Z[5],G=Z[6],F=Z[7],W=Z[8],q=Z[9],V=Z[10],z=Z[11];if(Z!==J)J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[4]=$*K+W*Y,J[5]=Q*K+q*Y,J[6]=G*K+V*Y,J[7]=F*K+z*Y,J[8]=W*K-$*Y,J[9]=q*K-Q*Y,J[10]=V*K-G*Y,J[11]=z*K-F*Y,J}function mX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=Z[8],q=Z[9],V=Z[10],z=Z[11];if(Z!==J)J[4]=Z[4],J[5]=Z[5],J[6]=Z[6],J[7]=Z[7],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K-W*Y,J[1]=Q*K-q*Y,J[2]=G*K-V*Y,J[3]=F*K-z*Y,J[8]=$*Y+W*K,J[9]=Q*Y+q*K,J[10]=G*Y+V*K,J[11]=F*Y+z*K,J}function lX0(J,Z,X){var Y=Math.sin(X),K=Math.cos(X),$=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=Z[4],q=Z[5],V=Z[6],z=Z[7];if(Z!==J)J[8]=Z[8],J[9]=Z[9],J[10]=Z[10],J[11]=Z[11],J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J[0]=$*K+W*Y,J[1]=Q*K+q*Y,J[2]=G*K+V*Y,J[3]=F*K+z*Y,J[4]=W*K-$*Y,J[5]=q*K-Q*Y,J[6]=V*K-G*Y,J[7]=z*K-F*Y,J}function uX0(J,Z){return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=Z[0],J[13]=Z[1],J[14]=Z[2],J[15]=1,J}function dX0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Z[1],J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=Z[2],J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iX0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q=Math.hypot(Y,K,$),G,F,W;if(Q<m)return null;return Q=1/Q,Y*=Q,K*=Q,$*=Q,G=Math.sin(Z),F=Math.cos(Z),W=1-F,J[0]=Y*Y*W+F,J[1]=K*Y*W+$*G,J[2]=$*Y*W-K*G,J[3]=0,J[4]=Y*K*W-$*G,J[5]=K*K*W+F,J[6]=$*K*W+Y*G,J[7]=0,J[8]=Y*$*W+K*G,J[9]=K*$*W-Y*G,J[10]=$*$*W+F,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function nX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=Y,J[6]=X,J[7]=0,J[8]=0,J[9]=-X,J[10]=Y,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function aX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=0,J[2]=-X,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=X,J[9]=0,J[10]=Y,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function sX0(J,Z){var X=Math.sin(Z),Y=Math.cos(Z);return J[0]=Y,J[1]=X,J[2]=0,J[3]=0,J[4]=-X,J[5]=Y,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=1,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function IE(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Y+Y,F=K+K,W=$+$,q=Y*G,V=Y*F,z=Y*W,L=K*F,R=K*W,M=$*W,H=Q*G,O=Q*F,P=Q*W;return J[0]=1-(L+M),J[1]=V+P,J[2]=z-O,J[3]=0,J[4]=V-P,J[5]=1-(q+M),J[6]=R+H,J[7]=0,J[8]=z+O,J[9]=R-H,J[10]=1-(q+L),J[11]=0,J[12]=X[0],J[13]=X[1],J[14]=X[2],J[15]=1,J}function oX0(J,Z){var X=new Q0(3),Y=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],G=Z[4],F=Z[5],W=Z[6],q=Z[7],V=Y*Y+K*K+$*$+Q*Q;if(V>0)X[0]=(G*Q+q*Y+F*$-W*K)*2/V,X[1]=(F*Q+q*K+W*Y-G*$)*2/V,X[2]=(W*Q+q*$+G*K-F*Y)*2/V;else X[0]=(G*Q+q*Y+F*$-W*K)*2,X[1]=(F*Q+q*K+W*Y-G*$)*2,X[2]=(W*Q+q*$+G*K-F*Y)*2;return IE(J,Z,X),J}function rX0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function fE(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[4],Q=Z[5],G=Z[6],F=Z[8],W=Z[9],q=Z[10];return J[0]=Math.hypot(X,Y,K),J[1]=Math.hypot($,Q,G),J[2]=Math.hypot(F,W,q),J}function tX0(J,Z){var X=new Q0(3);fE(X,Z);var Y=1/X[0],K=1/X[1],$=1/X[2],Q=Z[0]*Y,G=Z[1]*K,F=Z[2]*$,W=Z[4]*Y,q=Z[5]*K,V=Z[6]*$,z=Z[8]*Y,L=Z[9]*K,R=Z[10]*$,M=Q+q+R,H=0;if(M>0)H=Math.sqrt(M+1)*2,J[3]=0.25*H,J[0]=(V-L)/H,J[1]=(z-F)/H,J[2]=(G-W)/H;else if(Q>q&&Q>R)H=Math.sqrt(1+Q-q-R)*2,J[3]=(V-L)/H,J[0]=0.25*H,J[1]=(G+W)/H,J[2]=(z+F)/H;else if(q>R)H=Math.sqrt(1+q-Q-R)*2,J[3]=(z-F)/H,J[0]=(G+W)/H,J[1]=0.25*H,J[2]=(V+L)/H;else H=Math.sqrt(1+R-Q-q)*2,J[3]=(G-W)/H,J[0]=(z+F)/H,J[1]=(V+L)/H,J[2]=0.25*H;return J}function eX0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3],F=K+K,W=$+$,q=Q+Q,V=K*F,z=K*W,L=K*q,R=$*W,M=$*q,H=Q*q,O=G*F,P=G*W,N=G*q,B=Y[0],j=Y[1],w=Y[2];return J[0]=(1-(R+H))*B,J[1]=(z+N)*B,J[2]=(L-P)*B,J[3]=0,J[4]=(z-N)*j,J[5]=(1-(V+H))*j,J[6]=(M+O)*j,J[7]=0,J[8]=(L+P)*w,J[9]=(M-O)*w,J[10]=(1-(V+R))*w,J[11]=0,J[12]=X[0],J[13]=X[1],J[14]=X[2],J[15]=1,J}function JY0(J,Z,X,Y,K){var $=Z[0],Q=Z[1],G=Z[2],F=Z[3],W=$+$,q=Q+Q,V=G+G,z=$*W,L=$*q,R=$*V,M=Q*q,H=Q*V,O=G*V,P=F*W,N=F*q,B=F*V,j=Y[0],w=Y[1],k=Y[2],C=K[0],E=K[1],S=K[2],I=(1-(M+O))*j,h=(L+B)*j,p=(R-N)*j,f=(L-B)*w,g=(1-(z+O))*w,J0=(H+P)*w,A0=(R+N)*k,d0=(H-P)*k,Q6=(1-(z+M))*k;return J[0]=I,J[1]=h,J[2]=p,J[3]=0,J[4]=f,J[5]=g,J[6]=J0,J[7]=0,J[8]=A0,J[9]=d0,J[10]=Q6,J[11]=0,J[12]=X[0]+C-(I*C+f*E+A0*S),J[13]=X[1]+E-(h*C+g*E+d0*S),J[14]=X[2]+S-(p*C+J0*E+Q6*S),J[15]=1,J}function ZY0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X+X,G=Y+Y,F=K+K,W=X*Q,q=Y*Q,V=Y*G,z=K*Q,L=K*G,R=K*F,M=$*Q,H=$*G,O=$*F;return J[0]=1-V-R,J[1]=q+O,J[2]=z-H,J[3]=0,J[4]=q-O,J[5]=1-W-R,J[6]=L+M,J[7]=0,J[8]=z+H,J[9]=L-M,J[10]=1-W-V,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function XY0(J,Z,X,Y,K,$,Q){var G=1/(X-Z),F=1/(K-Y),W=1/($-Q);return J[0]=$*2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*F,J[6]=0,J[7]=0,J[8]=(X+Z)*G,J[9]=(K+Y)*F,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function hE(J,Z,X,Y,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/X,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(Y-K),J[10]=(K+Y)*Q,J[14]=2*K*Y*Q;else J[10]=-1,J[14]=-2*Y;return J}var YY0=hE;function KY0(J,Z,X,Y,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/X,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[11]=-1,J[12]=0,J[13]=0,J[15]=0,K!=null&&K!==1/0)Q=1/(Y-K),J[10]=K*Q,J[14]=K*Y*Q;else J[10]=-1,J[14]=-Y;return J}function $Y0(J,Z,X,Y){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),G=Math.tan(Z.rightDegrees*Math.PI/180),F=2/(Q+G),W=2/(K+$);return J[0]=F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-G)*F*0.5),J[9]=(K-$)*W*0.5,J[10]=Y/(X-Y),J[11]=-1,J[12]=0,J[13]=0,J[14]=Y*X/(X-Y),J[15]=0,J}function bE(J,Z,X,Y,K,$,Q){var G=1/(Z-X),F=1/(Y-K),W=1/($-Q);return J[0]=-2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*F,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+X)*G,J[13]=(K+Y)*F,J[14]=(Q+$)*W,J[15]=1,J}var QY0=bE;function GY0(J,Z,X,Y,K,$,Q){var G=1/(Z-X),F=1/(Y-K),W=1/($-Q);return J[0]=-2*G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*F,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+X)*G,J[13]=(K+Y)*F,J[14]=$*W,J[15]=1,J}function FY0(J,Z,X,Y){var K,$,Q,G,F,W,q,V,z,L,R=Z[0],M=Z[1],H=Z[2],O=Y[0],P=Y[1],N=Y[2],B=X[0],j=X[1],w=X[2];if(Math.abs(R-B)<m&&Math.abs(M-j)<m&&Math.abs(H-w)<m)return EE(J);if(q=R-B,V=M-j,z=H-w,L=1/Math.hypot(q,V,z),q*=L,V*=L,z*=L,K=P*z-N*V,$=N*q-O*z,Q=O*V-P*q,L=Math.hypot(K,$,Q),!L)K=0,$=0,Q=0;else L=1/L,K*=L,$*=L,Q*=L;if(G=V*Q-z*$,F=z*K-q*Q,W=q*$-V*K,L=Math.hypot(G,F,W),!L)G=0,F=0,W=0;else L=1/L,G*=L,F*=L,W*=L;return J[0]=K,J[1]=G,J[2]=q,J[3]=0,J[4]=$,J[5]=F,J[6]=V,J[7]=0,J[8]=Q,J[9]=W,J[10]=z,J[11]=0,J[12]=-(K*R+$*M+Q*H),J[13]=-(G*R+F*M+W*H),J[14]=-(q*R+V*M+z*H),J[15]=1,J}function WY0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Y[0],F=Y[1],W=Y[2],q=K-X[0],V=$-X[1],z=Q-X[2],L=q*q+V*V+z*z;if(L>0)L=1/Math.sqrt(L),q*=L,V*=L,z*=L;var R=F*z-W*V,M=W*q-G*z,H=G*V-F*q;if(L=R*R+M*M+H*H,L>0)L=1/Math.sqrt(L),R*=L,M*=L,H*=L;return J[0]=R,J[1]=M,J[2]=H,J[3]=0,J[4]=V*H-z*M,J[5]=z*R-q*H,J[6]=q*M-V*R,J[7]=0,J[8]=q,J[9]=V,J[10]=z,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function qY0(J){return"mat4("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+", "+J[9]+", "+J[10]+", "+J[11]+", "+J[12]+", "+J[13]+", "+J[14]+", "+J[15]+")"}function VY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8],J[9],J[10],J[11],J[12],J[13],J[14],J[15])}function zY0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J[4]=Z[4]+X[4],J[5]=Z[5]+X[5],J[6]=Z[6]+X[6],J[7]=Z[7]+X[7],J[8]=Z[8]+X[8],J[9]=Z[9]+X[9],J[10]=Z[10]+X[10],J[11]=Z[11]+X[11],J[12]=Z[12]+X[12],J[13]=Z[13]+X[13],J[14]=Z[14]+X[14],J[15]=Z[15]+X[15],J}function AE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J[3]=Z[3]-X[3],J[4]=Z[4]-X[4],J[5]=Z[5]-X[5],J[6]=Z[6]-X[6],J[7]=Z[7]-X[7],J[8]=Z[8]-X[8],J[9]=Z[9]-X[9],J[10]=Z[10]-X[10],J[11]=Z[11]-X[11],J[12]=Z[12]-X[12],J[13]=Z[13]-X[13],J[14]=Z[14]-X[14],J[15]=Z[15]-X[15],J}function HY0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J[4]=Z[4]*X,J[5]=Z[5]*X,J[6]=Z[6]*X,J[7]=Z[7]*X,J[8]=Z[8]*X,J[9]=Z[9]*X,J[10]=Z[10]*X,J[11]=Z[11]*X,J[12]=Z[12]*X,J[13]=Z[13]*X,J[14]=Z[14]*X,J[15]=Z[15]*X,J}function UY0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J[3]=Z[3]+X[3]*Y,J[4]=Z[4]+X[4]*Y,J[5]=Z[5]+X[5]*Y,J[6]=Z[6]+X[6]*Y,J[7]=Z[7]+X[7]*Y,J[8]=Z[8]+X[8]*Y,J[9]=Z[9]+X[9]*Y,J[10]=Z[10]+X[10]*Y,J[11]=Z[11]+X[11]*Y,J[12]=Z[12]+X[12]*Y,J[13]=Z[13]+X[13]*Y,J[14]=Z[14]+X[14]*Y,J[15]=Z[15]+X[15]*Y,J}function LY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]&&J[4]===Z[4]&&J[5]===Z[5]&&J[6]===Z[6]&&J[7]===Z[7]&&J[8]===Z[8]&&J[9]===Z[9]&&J[10]===Z[10]&&J[11]===Z[11]&&J[12]===Z[12]&&J[13]===Z[13]&&J[14]===Z[14]&&J[15]===Z[15]}function RY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=J[4],G=J[5],F=J[6],W=J[7],q=J[8],V=J[9],z=J[10],L=J[11],R=J[12],M=J[13],H=J[14],O=J[15],P=Z[0],N=Z[1],B=Z[2],j=Z[3],w=Z[4],k=Z[5],C=Z[6],E=Z[7],S=Z[8],I=Z[9],h=Z[10],p=Z[11],f=Z[12],g=Z[13],J0=Z[14],A0=Z[15];return Math.abs(X-P)<=m*Math.max(1,Math.abs(X),Math.abs(P))&&Math.abs(Y-N)<=m*Math.max(1,Math.abs(Y),Math.abs(N))&&Math.abs(K-B)<=m*Math.max(1,Math.abs(K),Math.abs(B))&&Math.abs($-j)<=m*Math.max(1,Math.abs($),Math.abs(j))&&Math.abs(Q-w)<=m*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(G-k)<=m*Math.max(1,Math.abs(G),Math.abs(k))&&Math.abs(F-C)<=m*Math.max(1,Math.abs(F),Math.abs(C))&&Math.abs(W-E)<=m*Math.max(1,Math.abs(W),Math.abs(E))&&Math.abs(q-S)<=m*Math.max(1,Math.abs(q),Math.abs(S))&&Math.abs(V-I)<=m*Math.max(1,Math.abs(V),Math.abs(I))&&Math.abs(z-h)<=m*Math.max(1,Math.abs(z),Math.abs(h))&&Math.abs(L-p)<=m*Math.max(1,Math.abs(L),Math.abs(p))&&Math.abs(R-f)<=m*Math.max(1,Math.abs(R),Math.abs(f))&&Math.abs(M-g)<=m*Math.max(1,Math.abs(M),Math.abs(g))&&Math.abs(H-J0)<=m*Math.max(1,Math.abs(H),Math.abs(J0))&&Math.abs(O-A0)<=m*Math.max(1,Math.abs(O),Math.abs(A0))}var MY0=SE,wY0=AE;var N0={};n6(N0,{str:()=>UK0,squaredLength:()=>zS,sqrLen:()=>BK0,sqlerp:()=>DK0,slerp:()=>q$,setAxisAngle:()=>KS,setAxes:()=>kK0,set:()=>wK0,scale:()=>WS,rotationTo:()=>TK0,rotateZ:()=>GK0,rotateY:()=>QK0,rotateX:()=>$K0,random:()=>qK0,pow:()=>WK0,normalize:()=>BV,multiply:()=>$S,mul:()=>xK0,ln:()=>GS,lerp:()=>PK0,length:()=>VS,len:()=>NK0,invert:()=>VK0,identity:()=>XK0,getAxisAngle:()=>YK0,getAngle:()=>KK0,fromValues:()=>RK0,fromMat3:()=>FS,fromEuler:()=>HK0,exp:()=>QS,exactEquals:()=>vK0,equals:()=>jK0,dot:()=>qS,create:()=>NV,copy:()=>MK0,conjugate:()=>zK0,clone:()=>LK0,calculateW:()=>FK0,add:()=>OK0});var K0={};n6(K0,{zero:()=>lY0,transformQuat:()=>pY0,transformMat4:()=>bY0,transformMat3:()=>AY0,subtract:()=>yE,sub:()=>nY0,str:()=>uY0,squaredLength:()=>uE,squaredDistance:()=>lE,sqrLen:()=>tY0,sqrDist:()=>rY0,set:()=>PY0,scaleAndAdd:()=>_Y0,scale:()=>kY0,round:()=>DY0,rotateZ:()=>cY0,rotateY:()=>gY0,rotateX:()=>yY0,random:()=>hY0,normalize:()=>xV,negate:()=>CY0,multiply:()=>gE,mul:()=>aY0,min:()=>jY0,max:()=>TY0,lerp:()=>SY0,length:()=>pE,len:()=>PV,inverse:()=>EY0,hermite:()=>IY0,fromValues:()=>F$,forEach:()=>eY0,floor:()=>vY0,exactEquals:()=>dY0,equals:()=>iY0,dot:()=>W$,divide:()=>cE,div:()=>sY0,distance:()=>mE,dist:()=>oY0,cross:()=>fJ,create:()=>G$,copy:()=>xY0,clone:()=>OY0,ceil:()=>BY0,bezier:()=>fY0,angle:()=>mY0,add:()=>NY0});function G$(){var J=new Q0(3);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function OY0(J){var Z=new Q0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function pE(J){var Z=J[0],X=J[1],Y=J[2];return Math.hypot(Z,X,Y)}function F$(J,Z,X){var Y=new Q0(3);return Y[0]=J,Y[1]=Z,Y[2]=X,Y}function xY0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function PY0(J,Z,X,Y){return J[0]=Z,J[1]=X,J[2]=Y,J}function NY0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J}function yE(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J[2]=Z[2]-X[2],J}function gE(J,Z,X){return J[0]=Z[0]*X[0],J[1]=Z[1]*X[1],J[2]=Z[2]*X[2],J}function cE(J,Z,X){return J[0]=Z[0]/X[0],J[1]=Z[1]/X[1],J[2]=Z[2]/X[2],J}function BY0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function vY0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function jY0(J,Z,X){return J[0]=Math.min(Z[0],X[0]),J[1]=Math.min(Z[1],X[1]),J[2]=Math.min(Z[2],X[2]),J}function TY0(J,Z,X){return J[0]=Math.max(Z[0],X[0]),J[1]=Math.max(Z[1],X[1]),J[2]=Math.max(Z[2],X[2]),J}function DY0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kY0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J}function _Y0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J[2]=Z[2]+X[2]*Y,J}function mE(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(X,Y,K)}function lE(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1],K=Z[2]-J[2];return X*X+Y*Y+K*K}function uE(J){var Z=J[0],X=J[1],Y=J[2];return Z*Z+X*X+Y*Y}function CY0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function EY0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function xV(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=X*X+Y*Y+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function W$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function fJ(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=X[0],G=X[1],F=X[2];return J[0]=K*F-$*G,J[1]=$*Q-Y*F,J[2]=Y*G-K*Q,J}function SY0(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J[2]=Q+Y*(X[2]-Q),J}function IY0(J,Z,X,Y,K,$){var Q=$*$,G=Q*(2*$-3)+1,F=Q*($-2)+$,W=Q*($-1),q=Q*(3-2*$);return J[0]=Z[0]*G+X[0]*F+Y[0]*W+K[0]*q,J[1]=Z[1]*G+X[1]*F+Y[1]*W+K[1]*q,J[2]=Z[2]*G+X[2]*F+Y[2]*W+K[2]*q,J}function fY0(J,Z,X,Y,K,$){var Q=1-$,G=Q*Q,F=$*$,W=G*Q,q=3*$*G,V=3*F*Q,z=F*$;return J[0]=Z[0]*W+X[0]*q+Y[0]*V+K[0]*z,J[1]=Z[1]*W+X[1]*q+Y[1]*V+K[1]*z,J[2]=Z[2]*W+X[2]*q+Y[2]*V+K[2]*z,J}function hY0(J,Z){Z=Z||1;var X=l6()*2*Math.PI,Y=l6()*2-1,K=Math.sqrt(1-Y*Y)*Z;return J[0]=Math.cos(X)*K,J[1]=Math.sin(X)*K,J[2]=Y*Z,J}function bY0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=X[3]*Y+X[7]*K+X[11]*$+X[15];return Q=Q||1,J[0]=(X[0]*Y+X[4]*K+X[8]*$+X[12])/Q,J[1]=(X[1]*Y+X[5]*K+X[9]*$+X[13])/Q,J[2]=(X[2]*Y+X[6]*K+X[10]*$+X[14])/Q,J}function AY0(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2];return J[0]=Y*X[0]+K*X[3]+$*X[6],J[1]=Y*X[1]+K*X[4]+$*X[7],J[2]=Y*X[2]+K*X[5]+$*X[8],J}function pY0(J,Z,X){var Y=X[0],K=X[1],$=X[2],Q=X[3],G=Z[0],F=Z[1],W=Z[2],q=K*W-$*F,V=$*G-Y*W,z=Y*F-K*G,L=K*z-$*V,R=$*q-Y*z,M=Y*V-K*q,H=Q*2;return q*=H,V*=H,z*=H,L*=2,R*=2,M*=2,J[0]=G+q+L,J[1]=F+V+R,J[2]=W+z+M,J}function yY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[0],$[1]=K[1]*Math.cos(Y)-K[2]*Math.sin(Y),$[2]=K[1]*Math.sin(Y)+K[2]*Math.cos(Y),J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function gY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[2]*Math.sin(Y)+K[0]*Math.cos(Y),$[1]=K[1],$[2]=K[2]*Math.cos(Y)-K[0]*Math.sin(Y),J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function cY0(J,Z,X,Y){var K=[],$=[];return K[0]=Z[0]-X[0],K[1]=Z[1]-X[1],K[2]=Z[2]-X[2],$[0]=K[0]*Math.cos(Y)-K[1]*Math.sin(Y),$[1]=K[0]*Math.sin(Y)+K[1]*Math.cos(Y),$[2]=K[2],J[0]=$[0]+X[0],J[1]=$[1]+X[1],J[2]=$[2]+X[2],J}function mY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=Z[0],Q=Z[1],G=Z[2],F=Math.sqrt(X*X+Y*Y+K*K),W=Math.sqrt($*$+Q*Q+G*G),q=F*W,V=q&&W$(J,Z)/q;return Math.acos(Math.min(Math.max(V,-1),1))}function lY0(J){return J[0]=0,J[1]=0,J[2]=0,J}function uY0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function dY0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function iY0(J,Z){var X=J[0],Y=J[1],K=J[2],$=Z[0],Q=Z[1],G=Z[2];return Math.abs(X-$)<=m*Math.max(1,Math.abs(X),Math.abs($))&&Math.abs(Y-Q)<=m*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(K-G)<=m*Math.max(1,Math.abs(K),Math.abs(G))}var nY0=yE,aY0=gE,sY0=cE,oY0=mE,rY0=lE,PV=pE,tY0=uE,eY0=function(){var J=G$();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=3;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],J[2]=Z[G+2],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1],Z[G+2]=J[2];return Z}}();function JK0(){var J=new Q0(4);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function dE(J){var Z=new Q0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function iE(J,Z,X,Y){var K=new Q0(4);return K[0]=J,K[1]=Z,K[2]=X,K[3]=Y,K}function nE(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function aE(J,Z,X,Y,K){return J[0]=Z,J[1]=X,J[2]=Y,J[3]=K,J}function sE(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J[2]=Z[2]+X[2],J[3]=Z[3]+X[3],J}function oE(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J[2]=Z[2]*X,J[3]=Z[3]*X,J}function rE(J){var Z=J[0],X=J[1],Y=J[2],K=J[3];return Math.hypot(Z,X,Y,K)}function tE(J){var Z=J[0],X=J[1],Y=J[2],K=J[3];return Z*Z+X*X+Y*Y+K*K}function eE(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*X+Y*Y+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=X*Q,J[1]=Y*Q,J[2]=K*Q,J[3]=$*Q,J}function JS(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function ZS(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J[2]=Q+Y*(X[2]-Q),J[3]=G+Y*(X[3]-G),J}function XS(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function YS(J,Z){var X=J[0],Y=J[1],K=J[2],$=J[3],Q=Z[0],G=Z[1],F=Z[2],W=Z[3];return Math.abs(X-Q)<=m*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(Y-G)<=m*Math.max(1,Math.abs(Y),Math.abs(G))&&Math.abs(K-F)<=m*Math.max(1,Math.abs(K),Math.abs(F))&&Math.abs($-W)<=m*Math.max(1,Math.abs($),Math.abs(W))}var hk0=function(){var J=JK0();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=4;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],J[2]=Z[G+2],J[3]=Z[G+3],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1],Z[G+2]=J[2],Z[G+3]=J[3];return Z}}();function NV(){var J=new Q0(4);if(Q0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function XK0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function KS(J,Z,X){X=X*0.5;var Y=Math.sin(X);return J[0]=Y*Z[0],J[1]=Y*Z[1],J[2]=Y*Z[2],J[3]=Math.cos(X),J}function YK0(J,Z){var X=Math.acos(Z[3])*2,Y=Math.sin(X/2);if(Y>m)J[0]=Z[0]/Y,J[1]=Z[1]/Y,J[2]=Z[2]/Y;else J[0]=1,J[1]=0,J[2]=0;return X}function KK0(J,Z){var X=qS(J,Z);return Math.acos(2*X*X-1)}function $S(J,Z,X){var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=X[0],F=X[1],W=X[2],q=X[3];return J[0]=Y*q+Q*G+K*W-$*F,J[1]=K*q+Q*F+$*G-Y*W,J[2]=$*q+Q*W+Y*F-K*G,J[3]=Q*q-Y*G-K*F-$*W,J}function $K0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+Q*G,J[1]=K*F+$*G,J[2]=$*F-K*G,J[3]=Q*F-Y*G,J}function QK0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F-$*G,J[1]=K*F+Q*G,J[2]=$*F+Y*G,J[3]=Q*F-K*G,J}function GK0(J,Z,X){X*=0.5;var Y=Z[0],K=Z[1],$=Z[2],Q=Z[3],G=Math.sin(X),F=Math.cos(X);return J[0]=Y*F+K*G,J[1]=K*F-Y*G,J[2]=$*F+Q*G,J[3]=Q*F-$*G,J}function FK0(J,Z){var X=Z[0],Y=Z[1],K=Z[2];return J[0]=X,J[1]=Y,J[2]=K,J[3]=Math.sqrt(Math.abs(1-X*X-Y*Y-K*K)),J}function QS(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(X*X+Y*Y+K*K),G=Math.exp($),F=Q>0?G*Math.sin(Q)/Q:0;return J[0]=X*F,J[1]=Y*F,J[2]=K*F,J[3]=G*Math.cos(Q),J}function GS(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(X*X+Y*Y+K*K),G=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=X*G,J[1]=Y*G,J[2]=K*G,J[3]=0.5*Math.log(X*X+Y*Y+K*K+$*$),J}function WK0(J,Z,X){return GS(J,Z),WS(J,J,X),QS(J,J),J}function q$(J,Z,X,Y){var K=Z[0],$=Z[1],Q=Z[2],G=Z[3],F=X[0],W=X[1],q=X[2],V=X[3],z,L,R,M,H;if(L=K*F+$*W+Q*q+G*V,L<0)L=-L,F=-F,W=-W,q=-q,V=-V;if(1-L>m)z=Math.acos(L),R=Math.sin(z),M=Math.sin((1-Y)*z)/R,H=Math.sin(Y*z)/R;else M=1-Y,H=Y;return J[0]=M*K+H*F,J[1]=M*$+H*W,J[2]=M*Q+H*q,J[3]=M*G+H*V,J}function qK0(J){var Z=l6(),X=l6(),Y=l6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*X),J[1]=K*Math.cos(2*Math.PI*X),J[2]=$*Math.sin(2*Math.PI*Y),J[3]=$*Math.cos(2*Math.PI*Y),J}function VK0(J,Z){var X=Z[0],Y=Z[1],K=Z[2],$=Z[3],Q=X*X+Y*Y+K*K+$*$,G=Q?1/Q:0;return J[0]=-X*G,J[1]=-Y*G,J[2]=-K*G,J[3]=$*G,J}function zK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function FS(J,Z){var X=Z[0]+Z[4]+Z[8],Y;if(X>0)Y=Math.sqrt(X+1),J[3]=0.5*Y,Y=0.5/Y,J[0]=(Z[5]-Z[7])*Y,J[1]=(Z[6]-Z[2])*Y,J[2]=(Z[1]-Z[3])*Y;else{var K=0;if(Z[4]>Z[0])K=1;if(Z[8]>Z[K*3+K])K=2;var $=(K+1)%3,Q=(K+2)%3;Y=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*Y,Y=0.5/Y,J[3]=(Z[$*3+Q]-Z[Q*3+$])*Y,J[$]=(Z[$*3+K]+Z[K*3+$])*Y,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*Y}return J}function HK0(J,Z,X,Y){var K=0.5*Math.PI/180;Z*=K,X*=K,Y*=K;var $=Math.sin(Z),Q=Math.cos(Z),G=Math.sin(X),F=Math.cos(X),W=Math.sin(Y),q=Math.cos(Y);return J[0]=$*F*q-Q*G*W,J[1]=Q*G*q+$*F*W,J[2]=Q*F*W-$*G*q,J[3]=Q*F*q+$*G*W,J}function UK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var LK0=dE,RK0=iE,MK0=nE,wK0=aE,OK0=sE,xK0=$S,WS=oE,qS=JS,PK0=ZS,VS=rE,NK0=VS,zS=tE,BK0=zS,BV=eE,vK0=XS,jK0=YS,TK0=function(){var J=G$(),Z=F$(1,0,0),X=F$(0,1,0);return function(Y,K,$){var Q=W$(K,$);if(Q<-0.999999){if(fJ(J,Z,K),PV(J)<0.000001)fJ(J,X,K);return xV(J,J),KS(Y,J,Math.PI),Y}else if(Q>0.999999)return Y[0]=0,Y[1]=0,Y[2]=0,Y[3]=1,Y;else return fJ(J,K,$),Y[0]=J[0],Y[1]=J[1],Y[2]=J[2],Y[3]=1+Q,BV(Y,Y)}}(),DK0=function(){var J=NV(),Z=NV();return function(X,Y,K,$,Q,G){return q$(J,Y,Q,G),q$(Z,K,$,G),q$(X,J,Z,2*G*(1-G)),X}}(),kK0=function(){var J=OV();return function(Z,X,Y,K){return J[0]=Y[0],J[3]=Y[1],J[6]=Y[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-X[0],J[5]=-X[1],J[8]=-X[2],BV(Z,FS(Z,J))}}();var q0={};n6(q0,{zero:()=>J$0,transformMat4:()=>rK0,transformMat3:()=>oK0,transformMat2d:()=>sK0,transformMat2:()=>aK0,subtract:()=>US,sub:()=>$$0,str:()=>Z$0,squaredLength:()=>xS,squaredDistance:()=>wS,sqrLen:()=>q$0,sqrDist:()=>W$0,set:()=>SK0,scaleAndAdd:()=>gK0,scale:()=>yK0,round:()=>pK0,rotate:()=>tK0,random:()=>nK0,normalize:()=>lK0,negate:()=>cK0,multiply:()=>LS,mul:()=>Q$0,min:()=>bK0,max:()=>AK0,lerp:()=>iK0,length:()=>OS,len:()=>K$0,inverse:()=>mK0,fromValues:()=>CK0,forEach:()=>V$0,floor:()=>hK0,exactEquals:()=>X$0,equals:()=>Y$0,dot:()=>uK0,divide:()=>RS,div:()=>G$0,distance:()=>MS,dist:()=>F$0,cross:()=>dK0,create:()=>HS,copy:()=>EK0,clone:()=>_K0,ceil:()=>fK0,angle:()=>eK0,add:()=>IK0});function HS(){var J=new Q0(2);if(Q0!=Float32Array)J[0]=0,J[1]=0;return J}function _K0(J){var Z=new Q0(2);return Z[0]=J[0],Z[1]=J[1],Z}function CK0(J,Z){var X=new Q0(2);return X[0]=J,X[1]=Z,X}function EK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function SK0(J,Z,X){return J[0]=Z,J[1]=X,J}function IK0(J,Z,X){return J[0]=Z[0]+X[0],J[1]=Z[1]+X[1],J}function US(J,Z,X){return J[0]=Z[0]-X[0],J[1]=Z[1]-X[1],J}function LS(J,Z,X){return J[0]=Z[0]*X[0],J[1]=Z[1]*X[1],J}function RS(J,Z,X){return J[0]=Z[0]/X[0],J[1]=Z[1]/X[1],J}function fK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function hK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function bK0(J,Z,X){return J[0]=Math.min(Z[0],X[0]),J[1]=Math.min(Z[1],X[1]),J}function AK0(J,Z,X){return J[0]=Math.max(Z[0],X[0]),J[1]=Math.max(Z[1],X[1]),J}function pK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function yK0(J,Z,X){return J[0]=Z[0]*X,J[1]=Z[1]*X,J}function gK0(J,Z,X,Y){return J[0]=Z[0]+X[0]*Y,J[1]=Z[1]+X[1]*Y,J}function MS(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1];return Math.hypot(X,Y)}function wS(J,Z){var X=Z[0]-J[0],Y=Z[1]-J[1];return X*X+Y*Y}function OS(J){var Z=J[0],X=J[1];return Math.hypot(Z,X)}function xS(J){var Z=J[0],X=J[1];return Z*Z+X*X}function cK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function mK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function lK0(J,Z){var X=Z[0],Y=Z[1],K=X*X+Y*Y;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function uK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function dK0(J,Z,X){var Y=Z[0]*X[1]-Z[1]*X[0];return J[0]=J[1]=0,J[2]=Y,J}function iK0(J,Z,X,Y){var K=Z[0],$=Z[1];return J[0]=K+Y*(X[0]-K),J[1]=$+Y*(X[1]-$),J}function nK0(J,Z){Z=Z||1;var X=l6()*2*Math.PI;return J[0]=Math.cos(X)*Z,J[1]=Math.sin(X)*Z,J}function aK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[2]*K,J[1]=X[1]*Y+X[3]*K,J}function sK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[2]*K+X[4],J[1]=X[1]*Y+X[3]*K+X[5],J}function oK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[3]*K+X[6],J[1]=X[1]*Y+X[4]*K+X[7],J}function rK0(J,Z,X){var Y=Z[0],K=Z[1];return J[0]=X[0]*Y+X[4]*K+X[12],J[1]=X[1]*Y+X[5]*K+X[13],J}function tK0(J,Z,X,Y){var K=Z[0]-X[0],$=Z[1]-X[1],Q=Math.sin(Y),G=Math.cos(Y);return J[0]=K*G-$*Q+X[0],J[1]=K*Q+$*G+X[1],J}function eK0(J,Z){var X=J[0],Y=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(X*X+Y*Y)*Math.sqrt(K*K+$*$),G=Q&&(X*K+Y*$)/Q;return Math.acos(Math.min(Math.max(G,-1),1))}function J$0(J){return J[0]=0,J[1]=0,J}function Z$0(J){return"vec2("+J[0]+", "+J[1]+")"}function X$0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function Y$0(J,Z){var X=J[0],Y=J[1],K=Z[0],$=Z[1];return Math.abs(X-K)<=m*Math.max(1,Math.abs(X),Math.abs(K))&&Math.abs(Y-$)<=m*Math.max(1,Math.abs(Y),Math.abs($))}var K$0=OS,$$0=US,Q$0=LS,G$0=RS,F$0=MS,W$0=wS,q$0=xS,V$0=function(){var J=HS();return function(Z,X,Y,K,$,Q){var G,F;if(!X)X=2;if(!Y)Y=0;if(K)F=Math.min(K*X+Y,Z.length);else F=Z.length;for(G=Y;G<F;G+=X)J[0]=Z[G],J[1]=Z[G+1],$(J,J,Q),Z[G]=J[0],Z[G+1]=J[1];return Z}}();class A9 extends Float32Array{constructor(J,Z,X,Y){super([J,Z,X,Y])}get determinant(){return t0.determinant(this)}get frobeniusNorm(){return t0.frob(this)}static create(){let J=new A9(0,0,0,0);return t0.identity(J),J}static fromRotation(J){let Z=A9.create();return t0.fromRotation(Z,J),Z}static fromScaling(J){let Z=A9.create();return t0.fromScaling(Z,J),Z}add(J){return t0.add(this,this,J),this}adjoint(){return t0.adjoint(this,this),this}clone(){return new A9(this[0],this[1],this[2],this[3])}copy(J){return t0.copy(this,J),this}equals(J){return t0.equals(this,J)}exactEquals(J){return t0.exactEquals(this,J)}identity(){return t0.identity(this),this}invert(){return t0.invert(this,this),this}multiply(J){return t0.mul(this,this,J),this}multiplyScalar(J){return t0.multiplyScalar(this,this,J),this}rotate(J){return t0.rotate(this,this,J),this}subtract(J){return t0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return t0.transpose(this,this),this}}class u6 extends Float32Array{constructor(J,Z,X,Y,K,$,Q,G,F){super([J,Z,X,Y,K,$,Q,G,F])}get determinant(){return I0.determinant(this)}get frobeniusNorm(){return I0.frob(this)}static create(){let J=new u6(0,0,0,0,0,0,0,0,0);return I0.identity(J),J}static fromMatrix4(J){let Z=u6.create();return I0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=u6.create();return I0.fromQuat(Z,J),Z}static fromRotation(J){let Z=u6.create();return I0.fromRotation(Z,J),Z}static fromScaling(J){let Z=u6.create();return I0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=u6.create();return I0.fromTranslation(Z,J),Z}add(J){return I0.add(this,this,J),this}adjoint(){return I0.adjoint(this,this),this}clone(){return new u6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return I0.copy(this,J),this}equals(J){return I0.equals(this,J)}exactEquals(J){return I0.exactEquals(this,J)}identity(){return I0.identity(this),this}invert(){return I0.invert(this,this),this}multiply(J){return I0.mul(this,this,J),this}multiplyScalar(J){return I0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return I0.projection(this,J,Z),this}rotate(J){return I0.rotate(this,this,J),this}subtract(J){return I0.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]},${this[2]}][${this[3]},${this[4]},${this[5]}][${this[6]},${this[7]},${this[8]}]`}transpose(){return I0.transpose(this,this),this}}class _8 extends Float32Array{constructor(J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M){super([J,Z,X,Y,K,$,Q,G,F,W,q,V,z,L,R,M])}get determinant(){return X0.determinant(this)}get frobeniusNorm(){return X0.frob(this)}static create(){let J=new _8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return X0.identity(J),J}static fromQuaternion(J){let Z=_8.create();return X0.fromQuat(Z,J),Z}static fromRotation(J,Z){let X=_8.create();return X0.fromRotation(X,J,Z),X}static fromRotationTranslation(J,Z){let X=_8.create();return X0.fromRotationTranslation(X,J,Z),X}static fromRotationTranslationScale(J,Z,X){let Y=_8.create();return X0.fromRotationTranslationScale(Y,J,Z,X),Y}static fromRotationTranslationScaleOrigin(J,Z,X,Y){let K=_8.create();return X0.fromRotationTranslationScaleOrigin(K,J,Z,X,Y),K}static fromScaling(J){let Z=_8.create();return X0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=_8.create();return X0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=_8.create();return X0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=_8.create();return X0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=_8.create();return X0.fromZRotation(Z,J),Z}add(J){return X0.add(this,this,J),this}adjoint(){return X0.adjoint(this,this),this}clone(){return new _8(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}copy(J){return X0.copy(this,J),this}equals(J){return X0.equals(this,J)}exactEquals(J){return X0.exactEquals(this,J)}frustrum(J,Z,X,Y,K,$){return X0.frustum(this,J,Z,X,Y,K,$),this}identity(){return X0.identity(this),this}invert(){return X0.invert(this,this),this}lookAt(J,Z,X){return X0.lookAt(this,J,Z,X),this}multiply(J){return X0.mul(this,this,J),this}multiplyScalar(J){return X0.multiplyScalar(this,this,J),this}orthographic(J,Z,X,Y,K,$){return X0.ortho(this,J,Z,X,Y,K,$),this}perspective(J,Z,X,Y){return X0.perspective(this,J,Z,X,Y),this}rotate(J,Z){return X0.rotate(this,this,J,Z),this}rotateX(J){return X0.rotateX(this,this,J),this}rotateY(J){return X0.rotateY(this,this,J),this}rotateZ(J){return X0.rotateZ(this,this,J),this}scale(J){return X0.scale(this,this,J),this}subtract(J){return X0.sub(this,this,J),this}targetTo(J,Z,X){return X0.targetTo(this,J,Z,X),this}toString(){return`[${this[0]},${this[1]},${this[2]},${this[3]}][${this[4]},${this[5]},${this[6]},${this[7]}][${this[8]},${this[9]},${this[10]},${this[11]}][${this[12]},${this[13]},${this[14]},${this[15]}]`}translate(J){return X0.translate(this,this,J),this}transpose(){return X0.transpose(this,this),this}}class e5 extends Float32Array{constructor(J,Z,X,Y){super([J,Z,X,Y])}get length(){return N0.length(this)}get squaredLength(){return N0.squaredLength(this)}get magnitude(){return N0.length(this)}get squaredMagnitude(){return N0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}get w(){return this[3]}set w(J){this[3]=J}static fromEuler(J,Z,X){let Y=N0.fromEuler(new Float32Array(4),J,Z,X);return new e5(Y[0],Y[1],Y[2],Y[3])}static fromQuaternionLike(J){return new e5(J.x,J.y,J.z,J.w)}clone(){return new e5(this.x,this.y,this.z,this.w)}conjugate(){return N0.conjugate(this,this),this}copy(J){return N0.copy(this,J),this}dot(J){return N0.dot(this,J)}exponential(){return N0.exp(this,this),this}equals(J){return N0.equals(this,J)}exactEquals(J){return N0.exactEquals(this,J)}getAngle(J){return N0.getAngle(this,J)}identity(){return N0.identity(this),this}invert(){return N0.invert(this,this),this}lerp(J,Z){return N0.lerp(this,this,J,Z),this}logarithm(){return N0.ln(this,this),this}multiply(J){return N0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return N0.normalize(this,this),this}power(J){return N0.pow(this,this,J),this}randomize(){return N0.random(this),this}rotateX(J){return N0.rotateX(this,this,J),this}rotateY(J){return N0.rotateY(this,this,J),this}rotateZ(J){return N0.rotateZ(this,this,J),this}scale(J){return N0.scale(this,this,J),this}setAxisAngle(J,Z){return N0.setAxisAngle(this,J,Z),this}slerp(J,Z){return N0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class hJ extends Float32Array{constructor(J,Z){super([J,Z])}get length(){return q0.length(this)}get squaredLength(){return q0.squaredLength(this)}get magnitude(){return q0.length(this)}get squaredMagnitude(){return q0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}static create(){return new hJ(0,0)}add(J){return q0.add(this,this,J),this}angle(J){return q0.angle(this,J)}ceil(){return q0.ceil(this,this),this}clone(){return new hJ(this.x,this.y)}copy(J){return q0.copy(this,J),this}distance(J){return q0.distance(this,J)}divide(J){return q0.divide(this,this,J),this}dot(J){return q0.dot(this,J)}equals(J){return q0.equals(this,J)}exactEquals(J){return q0.exactEquals(this,J)}floor(){return q0.floor(this,this),this}invert(){return q0.inverse(this,this),this}lerp(J,Z){return q0.lerp(this,this,J,Z),this}max(J){return q0.max(this,this,J),this}min(J){return q0.min(this,this,J),this}multiply(J){return q0.mul(this,this,J),this}negate(){return q0.negate(this,this),this}normalize(){return q0.normalize(this,this),this}randomize(J){return q0.random(this,J),this}rotate(J,Z){return q0.rotate(this,this,J,Z),this}round(){return q0.round(this,this),this}scale(J){return q0.scale(this,this,J),this}scaleAndAdd(J,Z){return q0.scaleAndAdd(this,this,J,Z),this}subtract(J){return q0.sub(this,this,J),this}toString(){return`${this.x},${this.y}`}transformMatrix2(J){return q0.transformMat2(this,this,J),this}transformMatrix3(J){return q0.transformMat3(this,this,J),this}transformMatrix4(J){return q0.transformMat4(this,this,J),this}zero(){return q0.zero(this),this}}class J4 extends Float32Array{constructor(J,Z,X){super([J,Z,X])}get length(){return K0.length(this)}get squaredLength(){return K0.squaredLength(this)}get magnitude(){return K0.length(this)}get squaredMagnitude(){return K0.squaredLength(this)}get x(){return this[0]}set x(J){this[0]=J}get y(){return this[1]}set y(J){this[1]=J}get z(){return this[2]}set z(J){this[2]=J}static create(){return new J4(0,0,0)}static fromVector3Like(J){return new J4(J.x,J.y,J.z)}add(J){return K0.add(this,this,J),this}ceil(){return K0.ceil(this,this),this}clone(){return new J4(this.x,this.y,this.z)}copy(J){return K0.copy(this,J),this}cross(J){return K0.cross(this,this,J),this}distance(J){return K0.distance(this,J)}divide(J){return K0.div(this,this,J),this}dot(J){return K0.dot(this,J)}equals(J){return K0.equals(this,J)}exactEquals(J){return K0.exactEquals(this,J)}floor(){return K0.floor(this,this),this}invert(){return K0.inverse(this,this),this}lerp(J,Z){return K0.lerp(this,this,J,Z),this}max(J){return K0.max(this,this,J),this}min(J){return K0.min(this,this,J),this}multiply(J){return K0.mul(this,this,J),this}negate(){return K0.negate(this,this),this}normalize(){return K0.normalize(this,this),this}randomize(J){return K0.random(this,J),this}rotateX(J,Z){return K0.rotateX(this,this,J,Z),this}rotateY(J,Z){return K0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return K0.rotateZ(this,this,J,Z),this}round(){return K0.round(this,this),this}scale(J){return K0.scale(this,this,J),this}scaleAndAdd(J,Z){return K0.scaleAndAdd(this,this,J,Z),this}subtract(J){return K0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return K0.transformMat3(this,this,J),this}transformMatrix4(J){return K0.transformMat4(this,this,J),this}transformQuaternion(J){return K0.transformQuat(this,this,J),this}zero(){return K0.zero(this),this}}var B0=function(J,Z,X,Y){function K($){return $ instanceof X?$:new X(function(Q){Q($)})}return new(X||(X=Promise))(function($,Q){function G(q){try{W(Y.next(q))}catch(V){Q(V)}}function F(q){try{W(Y.throw(q))}catch(V){Q(V)}}function W(q){q.done?$(q.value):K(q.value).then(G,F)}W((Y=Y.apply(J,Z||[])).next())})},P0=function(J,Z){var X={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},Y,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=G(0),Q.throw=G(1),Q.return=G(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function G(W){return function(q){return F([W,q])}}function F(W){if(Y)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(X=0)),X)try{if(Y=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return X.label++,{value:W[1],done:!1};case 5:X.label++,K=W[1],W=[0];continue;case 7:W=X.ops.pop(),X.trys.pop();continue;default:if(($=X.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){X=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){X.label=W[1];break}if(W[0]===6&&X.label<$[1]){X.label=$[1],$=W;break}if($&&X.label<$[2]){X.label=$[2],X.ops.push(W);break}if($[2])X.ops.pop();X.trys.pop();continue}W=Z.call(J,X)}catch(q){W=[6,q],K=0}finally{Y=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},g8=function(J,Z){var X=typeof Symbol==="function"&&J[Symbol.iterator];if(!X)return J;var Y=X.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=Y.next()).done)$.push(K.value)}catch(G){Q={error:G}}finally{try{if(K&&!K.done&&(X=Y.return))X.call(Y)}finally{if(Q)throw Q.error}}return $},$6=function(J,Z,X){if(X||arguments.length===2){for(var Y=0,K=Z.length,$;Y<K;Y++)if($||!(Y in Z)){if(!$)$=Array.prototype.slice.call(Z,0,Y);$[Y]=Z[Y]}}return J.concat($||Array.prototype.slice.call(Z))},PS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,X=Z&&J[Z],Y=0;if(X)return X.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&Y>=J.length)J=void 0;return{value:J&&J[Y++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},mk0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var X=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(Y,K){return X.compare(Y,K).then(function($){return-1*$})}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:2;return Math.floor((Z-X)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:-1;return Z+X},J.minComparator=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){if(Z>X)return[2,1];else if(Z<X)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){if(X>Z)return[2,1];else if(X<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,Z-X]})})},J.maxComparatorNumber=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,X-Z]})})},J.defaultIsEqual=function(Z,X){return B0(this,void 0,void 0,function(){return P0(this,function(Y){return[2,Z===X]})})},J.print=function(Z){function X(q){var V=J.getParentIndexOf(q);return Math.floor(Math.log2(V+1))}function Y(q,V){var z="";for(;V>0;--V)z+=q;return z}var K=0,$=[],Q=X(Z.length-1)+2,G=0;while(K<Z.length){var F=X(K)+1;if(K===0)F=0;var W=String(Z.get(K));if(W.length>G)G=W.length;$[F]=$[F]||[],$[F].push(W),K+=1}return $.map(function(q,V){var z=Math.pow(2,Q-V)-1;return Y(" ",Math.floor(z/2)*G)+q.map(function(L){var R=(G-L.length)/2;return Y(" ",Math.ceil(R))+L+Y(" ",Math.floor(R))}).join(Y(" ",z*G))}).join(`
|
386
386
|
`)},J.heapify=function(Z,X){return B0(this,void 0,void 0,function(){var Y;return P0(this,function(K){switch(K.label){case 0:return Y=new J(X),Y.heapArray=Z,[4,Y.init()];case 1:return K.sent(),[2,Y]}})})},J.heappop=function(Z,X){var Y=new J(X);return Y.heapArray=Z,Y.pop()},J.heappush=function(Z,X,Y){return B0(this,void 0,void 0,function(){var K;return P0(this,function($){switch($.label){case 0:return K=new J(Y),K.heapArray=Z,[4,K.push(X)];case 1:return $.sent(),[2]}})})},J.heappushpop=function(Z,X,Y){var K=new J(Y);return K.heapArray=Z,K.pushpop(X)},J.heapreplace=function(Z,X,Y){var K=new J(Y);return K.heapArray=Z,K.replace(X)},J.heaptop=function(Z,X,Y){if(X===void 0)X=1;var K=new J(Y);return K.heapArray=Z,K.top(X)},J.heapbottom=function(Z,X,Y){if(X===void 0)X=1;var K=new J(Y);return K.heapArray=Z,K.bottom(X)},J.nlargest=function(Z,X,Y){return B0(this,void 0,void 0,function(){var K;return P0(this,function($){switch($.label){case 0:return K=new J(Y),K.heapArray=$6([],g8(X),!1),[4,K.init()];case 1:return $.sent(),[2,K.top(Z)]}})})},J.nsmallest=function(Z,X,Y){return B0(this,void 0,void 0,function(){var K;return P0(this,function($){switch($.label){case 0:return K=new J(Y),K.heapArray=$6([],g8(X),!1),[4,K.init()];case 1:return $.sent(),[2,K.bottom(Z)]}})})},J.prototype.add=function(Z){return B0(this,void 0,void 0,function(){return P0(this,function(X){switch(X.label){case 0:return[4,this._sortNodeUp(this.heapArray.push(Z)-1)];case 1:return X.sent(),this._applyLimit(),[2,!0]}})})},J.prototype.addAll=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K;return P0(this,function($){switch($.label){case 0:X=this.length,(K=this.heapArray).push.apply(K,$6([],g8(Z),!1)),Y=this.length,$.label=1;case 1:if(!(X<Y))return[3,4];return[4,this._sortNodeUp(X)];case 2:$.sent(),$.label=3;case 3:return++X,[3,1];case 4:return this._applyLimit(),[2,!0]}})})},J.prototype.bottom=function(){return B0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return P0(this,function(X){if(this.heapArray.length===0||Z<=0)return[2,[]];else if(this.heapArray.length===1)return[2,[this.heapArray[0]]];else if(Z>=this.heapArray.length)return[2,$6([],g8(this.heapArray),!1)];else return[2,this._bottomN_push(~~Z)]})})},J.prototype.check=function(){return B0(this,void 0,void 0,function(){var Z,X,Y,K,$,Q,G,F,W;return P0(this,function(q){switch(q.label){case 0:Z=0,q.label=1;case 1:if(!(Z<this.heapArray.length))return[3,10];X=this.heapArray[Z],Y=this.getChildrenOf(Z),q.label=2;case 2:q.trys.push([2,7,8,9]),K=(F=void 0,PS(Y)),$=K.next(),q.label=3;case 3:if($.done)return[3,6];return Q=$.value,[4,this.compare(X,Q)];case 4:if(q.sent()>0)return[2,X];q.label=5;case 5:return $=K.next(),[3,3];case 6:return[3,9];case 7:return G=q.sent(),F={error:G},[3,9];case 8:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(F)throw F.error}return[7];case 9:return++Z,[3,1];case 10:return[2]}})})},J.prototype.clear=function(){this.heapArray=[]},J.prototype.clone=function(){var Z=new J(this.comparator());return Z.heapArray=this.toArray(),Z._limit=this._limit,Z},J.prototype.comparator=function(){return this.compare},J.prototype.contains=function(Z){return B0(this,arguments,void 0,function(X,Y){var K,$,Q,G,F,W;if(Y===void 0)Y=J.defaultIsEqual;return P0(this,function(q){switch(q.label){case 0:q.trys.push([0,5,6,7]),K=PS(this.heapArray),$=K.next(),q.label=1;case 1:if($.done)return[3,4];return Q=$.value,[4,Y(Q,X)];case 2:if(q.sent())return[2,!0];q.label=3;case 3:return $=K.next(),[3,1];case 4:return[3,7];case 5:return G=q.sent(),F={error:G},[3,7];case 6:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(F)throw F.error}return[7];case 7:return[2,!1]}})})},J.prototype.init=function(Z){return B0(this,void 0,void 0,function(){var X;return P0(this,function(Y){switch(Y.label){case 0:if(Z)this.heapArray=$6([],g8(Z),!1);X=Math.floor(this.heapArray.length),Y.label=1;case 1:if(!(X>=0))return[3,4];return[4,this._sortNodeDown(X)];case 2:Y.sent(),Y.label=3;case 3:return--X,[3,1];case 4:return this._applyLimit(),[2]}})})},J.prototype.isEmpty=function(){return this.length===0},J.prototype.leafs=function(){if(this.heapArray.length===0)return[];var Z=J.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(Z+1)},Object.defineProperty(J.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"limit",{get:function(){return this._limit},set:function(Z){this._limit=~~Z,this._applyLimit()},enumerable:!1,configurable:!0}),J.prototype.peek=function(){return this.heapArray[0]},J.prototype.pop=function(){return B0(this,void 0,void 0,function(){var Z;return P0(this,function(X){if(Z=this.heapArray.pop(),this.length>0&&Z!==void 0)return[2,this.replace(Z)];return[2,Z]})})},J.prototype.push=function(){var Z=[];for(var X=0;X<arguments.length;X++)Z[X]=arguments[X];return B0(this,void 0,void 0,function(){return P0(this,function(Y){if(Z.length<1)return[2,!1];else if(Z.length===1)return[2,this.add(Z[0])];else return[2,this.addAll(Z)]})})},J.prototype.pushpop=function(Z){return B0(this,void 0,void 0,function(){var X;return P0(this,function(Y){switch(Y.label){case 0:return[4,this.compare(this.heapArray[0],Z)];case 1:if(!(Y.sent()<0))return[3,3];return X=g8([this.heapArray[0],Z],2),Z=X[0],this.heapArray[0]=X[1],[4,this._sortNodeDown(0)];case 2:Y.sent(),Y.label=3;case 3:return[2,Z]}})})},J.prototype.remove=function(Z){return B0(this,arguments,void 0,function(X,Y){var K,$,Q,G=this;if(Y===void 0)Y=J.defaultIsEqual;return P0(this,function(F){switch(F.label){case 0:if(!this.heapArray.length)return[2,!1];if(X!==void 0)return[3,2];return[4,this.pop()];case 1:return F.sent(),[2,!0];case 2:K=[0],F.label=3;case 3:if(!K.length)return[3,13];return $=K.shift(),[4,Y(this.heapArray[$],X)];case 4:if(!F.sent())return[3,11];if($!==0)return[3,6];return[4,this.pop()];case 5:return F.sent(),[3,10];case 6:if($!==this.heapArray.length-1)return[3,7];return this.heapArray.pop(),[3,10];case 7:return this.heapArray.splice($,1,this.heapArray.pop()),[4,this._sortNodeUp($)];case 8:return F.sent(),[4,this._sortNodeDown($)];case 9:F.sent(),F.label=10;case 10:return[2,!0];case 11:Q=J.getChildrenIndexOf($).filter(function(W){return W<G.heapArray.length}),K.push.apply(K,$6([],g8(Q),!1)),F.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},J.prototype.replace=function(Z){return B0(this,void 0,void 0,function(){var X;return P0(this,function(Y){switch(Y.label){case 0:return X=this.heapArray[0],this.heapArray[0]=Z,[4,this._sortNodeDown(0)];case 1:return Y.sent(),[2,X]}})})},J.prototype.size=function(){return this.length},J.prototype.top=function(){return B0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return P0(this,function(X){if(this.heapArray.length===0||Z<=0)return[2,[]];else if(this.heapArray.length===1||Z===1)return[2,[this.heapArray[0]]];else if(Z>=this.heapArray.length)return[2,$6([],g8(this.heapArray),!1)];else return[2,this._topN_push(~~Z)]})})},J.prototype.toArray=function(){return $6([],g8(this.heapArray),!1)},J.prototype.toString=function(){return this.heapArray.toString()},J.prototype.get=function(Z){return this.heapArray[Z]},J.prototype.getChildrenOf=function(Z){var X=this;return J.getChildrenIndexOf(Z).map(function(Y){return X.heapArray[Y]}).filter(function(Y){return Y!==void 0})},J.prototype.getParentOf=function(Z){var X=J.getParentIndexOf(Z);return this.heapArray[X]},J.prototype[Symbol.iterator]=function(){return P0(this,function(Z){switch(Z.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return Z.sent(),[3,0];case 2:return[2]}})},J.prototype.iterator=function(){return this},J.prototype._applyLimit=function(){if(this._limit&&this._limit<this.heapArray.length){var Z=this.heapArray.length-this._limit;while(Z)this.heapArray.pop(),--Z}},J.prototype._bottomN_push=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$,G,Q,G;return P0(this,function(F){switch(F.label){case 0:return X=new J(this.compare),X.limit=Z,X.heapArray=this.heapArray.slice(-Z),[4,X.init()];case 1:F.sent(),Y=this.heapArray.length-1-Z,K=J.getParentIndexOf(Y),$=[];for(G=Y;G>K;--G)$.push(G);Q=this.heapArray,F.label=2;case 2:if(!$.length)return[3,6];return G=$.shift(),[4,this.compare(Q[G],X.peek())];case 3:if(!(F.sent()>0))return[3,5];return[4,X.replace(Q[G])];case 4:if(F.sent(),G%2)$.push(J.getParentIndexOf(G));F.label=5;case 5:return[3,2];case 6:return[2,X.toArray()]}})})},J.prototype._moveNode=function(Z,X){var Y;Y=g8([this.heapArray[X],this.heapArray[Z]],2),this.heapArray[Z]=Y[0],this.heapArray[X]=Y[1]},J.prototype._sortNodeDown=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$,Q,G;return P0(this,function(F){switch(F.label){case 0:X=this.heapArray.length,F.label=1;case 1:if(Y=2*Z+1,K=Y+1,$=Z,Q=Y<X,!Q)return[3,3];return[4,this.compare(this.heapArray[Y],this.heapArray[$])];case 2:Q=F.sent()<0,F.label=3;case 3:if(Q)$=Y;if(G=K<X,!G)return[3,5];return[4,this.compare(this.heapArray[K],this.heapArray[$])];case 4:G=F.sent()<0,F.label=5;case 5:if(G)$=K;if($===Z)return[3,7];this._moveNode(Z,$),Z=$,F.label=6;case 6:return[3,1];case 7:return[2]}})})},J.prototype._sortNodeUp=function(Z){return B0(this,void 0,void 0,function(){var X;return P0(this,function(Y){switch(Y.label){case 0:if(!(Z>0))return[3,2];return X=J.getParentIndexOf(Z),[4,this.compare(this.heapArray[Z],this.heapArray[X])];case 1:if(Y.sent()<0)this._moveNode(Z,X),Z=X;else return[3,2];return[3,0];case 2:return[2]}})})},J.prototype._topN_push=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$;return P0(this,function(Q){switch(Q.label){case 0:X=new J(this._invertedCompare),X.limit=Z,Y=[0],K=this.heapArray,Q.label=1;case 1:if(!Y.length)return[3,7];if($=Y.shift(),!($<K.length))return[3,6];if(!(X.length<Z))return[3,3];return[4,X.push(K[$])];case 2:return Q.sent(),Y.push.apply(Y,$6([],g8(J.getChildrenIndexOf($)),!1)),[3,6];case 3:return[4,this.compare(K[$],X.peek())];case 4:if(!(Q.sent()<0))return[3,6];return[4,X.replace(K[$])];case 5:Q.sent(),Y.push.apply(Y,$6([],g8(J.getChildrenIndexOf($)),!1)),Q.label=6;case 6:return[3,1];case 7:return[2,X.toArray()]}})})},J.prototype._topN_fill=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$,Q,Q;return P0(this,function(G){switch(G.label){case 0:return X=this.heapArray,Y=new J(this._invertedCompare),Y.limit=Z,Y.heapArray=X.slice(0,Z),[4,Y.init()];case 1:G.sent(),K=J.getParentIndexOf(Z-1)+1,$=[];for(Q=K;Q<Z;++Q)$.push.apply($,$6([],g8(J.getChildrenIndexOf(Q).filter(function(F){return F<X.length})),!1));if((Z-1)%2)$.push(Z);G.label=2;case 2:if(!$.length)return[3,6];if(Q=$.shift(),!(Q<X.length))return[3,5];return[4,this.compare(X[Q],Y.peek())];case 3:if(!(G.sent()<0))return[3,5];return[4,Y.replace(X[Q])];case 4:G.sent(),$.push.apply($,$6([],g8(J.getChildrenIndexOf(Q)),!1)),G.label=5;case 5:return[3,2];case 6:return[2,Y.toArray()]}})})},J.prototype._topN_heap=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$,Q;return P0(this,function(G){switch(G.label){case 0:X=this.clone(),Y=[],K=0,G.label=1;case 1:if(!(K<Z))return[3,4];return Q=($=Y).push,[4,X.pop()];case 2:Q.apply($,[G.sent()]),G.label=3;case 3:return++K,[3,1];case 4:return[2,Y]}})})},J.prototype._topIdxOf=function(Z){return B0(this,void 0,void 0,function(){var X,Y,K,$;return P0(this,function(Q){switch(Q.label){case 0:if(!Z.length)return[2,-1];X=0,Y=Z[X],K=1,Q.label=1;case 1:if(!(K<Z.length))return[3,4];return[4,this.compare(Z[K],Y)];case 2:if($=Q.sent(),$<0)X=K,Y=Z[K];Q.label=3;case 3:return++K,[3,1];case 4:return[2,X]}})})},J.prototype._topOf=function(){var Z=[];for(var X=0;X<arguments.length;X++)Z[X]=arguments[X];return B0(this,void 0,void 0,function(){var Y;return P0(this,function(K){switch(K.label){case 0:return Y=new J(this.compare),[4,Y.init(Z)];case 1:return K.sent(),[2,Y.peek()]}})})},J}(),z$0=function(J,Z){var X={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},Y,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=G(0),Q.throw=G(1),Q.return=G(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function G(W){return function(q){return F([W,q])}}function F(W){if(Y)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(X=0)),X)try{if(Y=1,K&&($=W[0]&2?K.return:W[0]?K.throw||(($=K.return)&&$.call(K),0):K.next)&&!($=$.call(K,W[1])).done)return $;if(K=0,$)W=[W[0]&2,$.value];switch(W[0]){case 0:case 1:$=W;break;case 4:return X.label++,{value:W[1],done:!1};case 5:X.label++,K=W[1],W=[0];continue;case 7:W=X.ops.pop(),X.trys.pop();continue;default:if(($=X.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){X=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){X.label=W[1];break}if(W[0]===6&&X.label<$[1]){X.label=$[1],$=W;break}if($&&X.label<$[2]){X.label=$[2],X.ops.push(W);break}if($[2])X.ops.pop();X.trys.pop();continue}W=Z.call(J,X)}catch(q){W=[6,q],K=0}finally{Y=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},H8=function(J,Z){var X=typeof Symbol==="function"&&J[Symbol.iterator];if(!X)return J;var Y=X.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=Y.next()).done)$.push(K.value)}catch(G){Q={error:G}}finally{try{if(K&&!K.done&&(X=Y.return))X.call(Y)}finally{if(Q)throw Q.error}}return $},C8=function(J,Z,X){if(X||arguments.length===2){for(var Y=0,K=Z.length,$;Y<K;Y++)if($||!(Y in Z)){if(!$)$=Array.prototype.slice.call(Z,0,Y);$[Y]=Z[Y]}}return J.concat($||Array.prototype.slice.call(Z))};var NS=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var X=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this.removeAll=this.clear,this._invertedCompare=function(Y,K){return-1*X.compare(Y,K)}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:2;return Math.floor((Z-X)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var X=Z%2?1:-1;return Z+X},J.minComparator=function(Z,X){if(Z>X)return 1;else if(Z<X)return-1;else return 0},J.maxComparator=function(Z,X){if(X>Z)return 1;else if(X<Z)return-1;else return 0},J.minComparatorNumber=function(Z,X){return Z-X},J.maxComparatorNumber=function(Z,X){return X-Z},J.defaultIsEqual=function(Z,X){return Z===X},J.print=function(Z){function X(q){var V=J.getParentIndexOf(q);return Math.floor(Math.log2(V+1))}function Y(q,V){var z="";for(;V>0;--V)z+=q;return z}var K=0,$=[],Q=X(Z.length-1)+2,G=0;while(K<Z.length){var F=X(K)+1;if(K===0)F=0;var W=String(Z.get(K));if(W.length>G)G=W.length;$[F]=$[F]||[],$[F].push(W),K+=1}return $.map(function(q,V){var z=Math.pow(2,Q-V)-1;return Y(" ",Math.floor(z/2)*G)+q.map(function(L){var R=(G-L.length)/2;return Y(" ",Math.ceil(R))+L+Y(" ",Math.floor(R))}).join(Y(" ",z*G))}).join(`
|
387
387
|
`)},J.heapify=function(Z,X){var Y=new J(X);return Y.heapArray=Z,Y.init(),Y},J.heappop=function(Z,X){var Y=new J(X);return Y.heapArray=Z,Y.pop()},J.heappush=function(Z,X,Y){var K=new J(Y);K.heapArray=Z,K.push(X)},J.heappushpop=function(Z,X,Y){var K=new J(Y);return K.heapArray=Z,K.pushpop(X)},J.heapreplace=function(Z,X,Y){var K=new J(Y);return K.heapArray=Z,K.replace(X)},J.heaptop=function(Z,X,Y){if(X===void 0)X=1;var K=new J(Y);return K.heapArray=Z,K.top(X)},J.heapbottom=function(Z,X,Y){if(X===void 0)X=1;var K=new J(Y);return K.heapArray=Z,K.bottom(X)},J.nlargest=function(Z,X,Y){var K=new J(Y);return K.heapArray=C8([],H8(X),!1),K.init(),K.top(Z)},J.nsmallest=function(Z,X,Y){var K=new J(Y);return K.heapArray=C8([],H8(X),!1),K.init(),K.bottom(Z)},J.prototype.add=function(Z){return this._sortNodeUp(this.heapArray.push(Z)-1),this._applyLimit(),!0},J.prototype.addAll=function(Z){var X,Y=this.length;(X=this.heapArray).push.apply(X,C8([],H8(Z),!1));for(var K=this.length;Y<K;++Y)this._sortNodeUp(Y);return this._applyLimit(),!0},J.prototype.bottom=function(Z){if(Z===void 0)Z=1;if(this.heapArray.length===0||Z<=0)return[];else if(this.heapArray.length===1)return[this.heapArray[0]];else if(Z>=this.heapArray.length)return C8([],H8(this.heapArray),!1);else return this._bottomN_push(~~Z)},J.prototype.check=function(){var Z=this;return this.heapArray.find(function(X,Y){return!!Z.getChildrenOf(Y).find(function(K){return Z.compare(X,K)>0})})},J.prototype.clear=function(){this.heapArray=[]},J.prototype.clone=function(){var Z=new J(this.comparator());return Z.heapArray=this.toArray(),Z._limit=this._limit,Z},J.prototype.comparator=function(){return this.compare},J.prototype.contains=function(Z,X){if(X===void 0)X=J.defaultIsEqual;return this.indexOf(Z,X)!==-1},J.prototype.init=function(Z){if(Z)this.heapArray=C8([],H8(Z),!1);for(var X=Math.floor(this.heapArray.length);X>=0;--X)this._sortNodeDown(X);this._applyLimit()},J.prototype.isEmpty=function(){return this.length===0},J.prototype.indexOf=function(Z,X){if(X===void 0)X=J.defaultIsEqual;if(this.heapArray.length===0)return-1;var Y=[],K=0;while(K<this.heapArray.length){var $=this.heapArray[K];if(X($,Z))return K;else if(this.compare($,Z)<=0)Y.push.apply(Y,C8([],H8(J.getChildrenIndexOf(K)),!1));K=Y.shift()||this.heapArray.length}return-1},J.prototype.indexOfEvery=function(Z,X){if(X===void 0)X=J.defaultIsEqual;if(this.heapArray.length===0)return[];var Y=[],K=[],$=0;while($<this.heapArray.length){var Q=this.heapArray[$];if(X(Q,Z))K.push($),Y.push.apply(Y,C8([],H8(J.getChildrenIndexOf($)),!1));else if(this.compare(Q,Z)<=0)Y.push.apply(Y,C8([],H8(J.getChildrenIndexOf($)),!1));$=Y.shift()||this.heapArray.length}return K},J.prototype.leafs=function(){if(this.heapArray.length===0)return[];var Z=J.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(Z+1)},Object.defineProperty(J.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(J.prototype,"limit",{get:function(){return this._limit},set:function(Z){if(Z<0||isNaN(Z))this._limit=0;else this._limit=~~Z;this._applyLimit()},enumerable:!1,configurable:!0}),J.prototype.setLimit=function(Z){if(this.limit=Z,Z<0||isNaN(Z))return NaN;else return this._limit},J.prototype.peek=function(){return this.heapArray[0]},J.prototype.pop=function(){var Z=this.heapArray.pop();if(this.length>0&&Z!==void 0)return this.replace(Z);return Z},J.prototype.push=function(){var Z=[];for(var X=0;X<arguments.length;X++)Z[X]=arguments[X];if(Z.length<1)return!1;else if(Z.length===1)return this.add(Z[0]);else return this.addAll(Z)},J.prototype.pushpop=function(Z){var X;if(this.compare(this.heapArray[0],Z)<0)X=H8([this.heapArray[0],Z],2),Z=X[0],this.heapArray[0]=X[1],this._sortNodeDown(0);return Z},J.prototype.remove=function(Z,X){var Y=this;if(X===void 0)X=J.defaultIsEqual;if(!this.heapArray.length)return!1;if(Z===void 0)return this.pop(),!0;var K=[0];while(K.length){var $=K.shift();if(X(this.heapArray[$],Z)){if($===0)this.pop();else if($===this.heapArray.length-1)this.heapArray.pop();else this.heapArray.splice($,1,this.heapArray.pop()),this._sortNodeUp($),this._sortNodeDown($);return!0}else if(this.compare(this.heapArray[$],Z)<=0){var Q=J.getChildrenIndexOf($).filter(function(G){return G<Y.heapArray.length});K.push.apply(K,C8([],H8(Q),!1))}}return!1},J.prototype.replace=function(Z){var X=this.heapArray[0];return this.heapArray[0]=Z,this._sortNodeDown(0),X},J.prototype.size=function(){return this.length},J.prototype.top=function(Z){if(Z===void 0)Z=1;if(this.heapArray.length===0||Z<=0)return[];else if(this.heapArray.length===1||Z===1)return[this.heapArray[0]];else if(Z>=this.heapArray.length)return C8([],H8(this.heapArray),!1);else return this._topN_push(~~Z)},J.prototype.toArray=function(){return C8([],H8(this.heapArray),!1)},J.prototype.toString=function(){return this.heapArray.toString()},J.prototype.get=function(Z){return this.heapArray[Z]},J.prototype.getChildrenOf=function(Z){var X=this;return J.getChildrenIndexOf(Z).map(function(Y){return X.heapArray[Y]}).filter(function(Y){return Y!==void 0})},J.prototype.getParentOf=function(Z){var X=J.getParentIndexOf(Z);return this.heapArray[X]},J.prototype[Symbol.iterator]=function(){return z$0(this,function(Z){switch(Z.label){case 0:if(!this.length)return[3,2];return[4,this.pop()];case 1:return Z.sent(),[3,0];case 2:return[2]}})},J.prototype.iterator=function(){return this.toArray()},J.prototype._applyLimit=function(){if(this._limit>0&&this._limit<this.heapArray.length){var Z=this.heapArray.length-this._limit;while(Z)this.heapArray.pop(),--Z}},J.prototype._bottomN_push=function(Z){var X=new J(this.compare);X.limit=Z,X.heapArray=this.heapArray.slice(-Z),X.init();var Y=this.heapArray.length-1-Z,K=J.getParentIndexOf(Y),$=[];for(var Q=Y;Q>K;--Q)$.push(Q);var G=this.heapArray;while($.length){var Q=$.shift();if(this.compare(G[Q],X.peek())>0){if(X.replace(G[Q]),Q%2)$.push(J.getParentIndexOf(Q))}}return X.toArray()},J.prototype._moveNode=function(Z,X){var Y;Y=H8([this.heapArray[X],this.heapArray[Z]],2),this.heapArray[Z]=Y[0],this.heapArray[X]=Y[1]},J.prototype._sortNodeDown=function(Z){var X=this.heapArray.length;while(!0){var Y=2*Z+1,K=Y+1,$=Z;if(Y<X&&this.compare(this.heapArray[Y],this.heapArray[$])<0)$=Y;if(K<X&&this.compare(this.heapArray[K],this.heapArray[$])<0)$=K;if($===Z)break;this._moveNode(Z,$),Z=$}},J.prototype._sortNodeUp=function(Z){while(Z>0){var X=J.getParentIndexOf(Z);if(this.compare(this.heapArray[Z],this.heapArray[X])<0)this._moveNode(Z,X),Z=X;else break}},J.prototype._topN_push=function(Z){var X=new J(this._invertedCompare);X.limit=Z;var Y=[0],K=this.heapArray;while(Y.length){var $=Y.shift();if($<K.length){if(X.length<Z)X.push(K[$]),Y.push.apply(Y,C8([],H8(J.getChildrenIndexOf($)),!1));else if(this.compare(K[$],X.peek())<0)X.replace(K[$]),Y.push.apply(Y,C8([],H8(J.getChildrenIndexOf($)),!1))}}return X.toArray()},J.prototype._topN_fill=function(Z){var X=this.heapArray,Y=new J(this._invertedCompare);Y.limit=Z,Y.heapArray=X.slice(0,Z),Y.init();var K=J.getParentIndexOf(Z-1)+1,$=[];for(var Q=K;Q<Z;++Q)$.push.apply($,C8([],H8(J.getChildrenIndexOf(Q).filter(function(G){return G<X.length})),!1));if((Z-1)%2)$.push(Z);while($.length){var Q=$.shift();if(Q<X.length){if(this.compare(X[Q],Y.peek())<0)Y.replace(X[Q]),$.push.apply($,C8([],H8(J.getChildrenIndexOf(Q)),!1))}}return Y.toArray()},J.prototype._topN_heap=function(Z){var X=this.clone(),Y=[];for(var K=0;K<Z;++K)Y.push(X.pop());return Y},J.prototype._topIdxOf=function(Z){if(!Z.length)return-1;var X=0,Y=Z[X];for(var K=1;K<Z.length;++K){var $=this.compare(Z[K],Y);if($<0)X=K,Y=Z[K]}return X},J.prototype._topOf=function(){var Z=[];for(var X=0;X<arguments.length;X++)Z[X]=arguments[X];var Y=new J(this.compare);return Y.init(Z),Y.peek()},J}();class bJ extends i1{_faceSpeed=0;_faceTarget;_jumpHeight=0;_moveSpeed=0;_moveTarget;_moveIgnoreAxes={};_onFace;_onFaceComplete;_onMove;_onMoveComplete;face(J,Z,X){this._faceTarget=J,this._faceSpeed=Z,this._onFace=X?.faceCallback,this._onFaceComplete=X?.faceCompleteCallback}jump(J){this._jumpHeight=J}move(J,Z,X){this._moveTarget=J,this._moveSpeed=Z,this._moveIgnoreAxes=X?.moveIgnoreAxes??{},this._onMove=X?.moveCallback,this._onMoveComplete=X?.moveCompleteCallback}tick(J,Z){if(super.tick(J,Z),!this._moveTarget&&!this._faceTarget&&!this._jumpHeight)return;let X=Z/1000,Y=J.position;if(J.isDynamic&&this._jumpHeight>0){let K=Math.abs(J.world.simulation.gravity.y),$=Math.sqrt(2*K*this._jumpHeight);J.applyImpulse({x:0,y:$*J.mass,z:0}),this._jumpHeight=0}if(this._moveTarget){let K={x:this._moveIgnoreAxes.x?0:this._moveTarget.x-Y.x,y:this._moveIgnoreAxes.y?0:this._moveTarget.y-Y.y,z:this._moveIgnoreAxes.z?0:this._moveTarget.z-Y.z},$=K.x*K.x+K.y*K.y+K.z*K.z;if($>0.1){let Q=Math.sqrt($),G=this._moveSpeed*X,W=Math.min(Q,G)/Q,q={x:Y.x+K.x*W,y:Y.y+K.y*W,z:Y.z+K.z*W};if(J.setPosition(q),this._onMove)this._onMove(q,this._moveTarget)}else if(this._moveTarget=void 0,this._onMoveComplete){let Q=this._onMoveComplete;this._onMove=void 0,this._onMoveComplete=void 0,Q(Y)}}if(this._faceTarget){let K={x:this._faceTarget.x-Y.x,z:this._faceTarget.z-Y.z},$=Math.atan2(-K.x,-K.z),Q=J.rotation,G=Math.atan2(2*(Q.w*Q.y),1-2*(Q.y*Q.y)),F=$-G;while(F>Math.PI)F-=2*Math.PI;while(F<-Math.PI)F+=2*Math.PI;if(Math.abs(F)>0.01){let W=this._faceSpeed*X,q=Math.abs(F)<W?F:Math.sign(F)*W,z=(G+q)/2,L={x:0,y:Math.fround(Math.sin(z)),z:0,w:Math.fround(Math.cos(z))};if(J.setRotation(L),this._onFace)this._onFace(Q,L)}else if(this._faceTarget=void 0,this._onFaceComplete){let W=this._onFaceComplete;this._onFaceComplete=void 0,W(J.rotation)}}}}class vV extends bJ{_debug=!1;_entity;_maxFall=0;_maxJump=0;_maxOpenSetIterations=200;_onPathfindAbort;_onPathfindComplete;_onWaypointMoveComplete;_onWaypointMoveSkipped;_speed=0;_target;_verticalPenalty=0;_waypoints=[];_waypointNextIndex=0;_waypointTimeoutMs=2000;get debug(){return this._debug}get maxFall(){return this._maxFall}get maxJump(){return this._maxJump}get maxOpenSetIterations(){return this._maxOpenSetIterations}get speed(){return this._speed}get target(){return this._target}get verticalPenalty(){return this._verticalPenalty}get waypoints(){return this._waypoints}get waypointNextIndex(){return this._waypointNextIndex}get waypointTimeoutMs(){return this._waypointTimeoutMs}pathfind(J,Z,X){if(this._target=J,this._speed=Z,this._debug=X?.debug??!1,this._maxFall=X?.maxFall?-Math.abs(X.maxFall):0,this._maxJump=X?.maxJump?Math.abs(X.maxJump):0,this._maxOpenSetIterations=X?.maxOpenSetIterations??200,this._onPathfindAbort=X?.pathfindAbortCallback,this._onPathfindComplete=X?.pathfindCompleteCallback,this._onWaypointMoveComplete=X?.waypointMoveCompleteCallback,this._onWaypointMoveSkipped=X?.waypointMoveSkippedCallback,this._verticalPenalty=X?.verticalPenalty??0,this._waypoints=[],this._waypointNextIndex=0,this._waypointTimeoutMs=X?.waypointTimeoutMs??2000/Z,!this._calculatePath())return!1;return this._moveToNextWaypoint(),!0}attach(J){super.attach(J),this._entity=J}detach(J){super.detach(J),this._entity=void 0}tick(J,Z){super.tick(J,Z)}_calculatePath(){if(!this._target||!this._entity?.world)return _.error("PathfindingEntityController._calculatePath: No target or world"),!1;let J=this._entity.height,Z=this._findGroundedStart();if(!Z){if(this._debug)_.warning(`PathfindingEntityController._calculatePath: No valid grounded start found within maxFall distance, path search aborted. Start: ${this._coordinateToKey(this._target)}, Target: ${this._coordinateToKey(this._target)}`);return!1}let X={x:Math.floor(this._target.x),y:Math.floor(this._target.y),z:Math.floor(this._target.z)},Y=Math.abs(X.x-Z.x),K=Math.abs(X.y-Z.y),$=Math.abs(X.z-Z.z);if(Y<=2&&K<=2&&$<=2&&!this._isNeighborCoordinateBlocked(Z,X,this._entity.height))return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5},{x:X.x+0.5,y:X.y+J/2,z:X.z+0.5}],!0;if(Z.x===X.x&&Z.y===X.y&&Z.z===X.z)return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5}],!0;let G=this._coordinateToKey(Z),F=new Map,W=new Map([[G,0]]),q=new Map([[G,this._pathfindingHeuristic(Z,X)]]),V=new Set,z=new NS((N,B)=>{let j=q.get(N[0])??1/0,w=q.get(B[0])??1/0;return j-w});z.push([G,Z]);let L=[{x:0,y:0,z:1},{x:1,y:0,z:0},{x:0,y:0,z:-1},{x:-1,y:0,z:0},{x:1,y:0,z:1},{x:1,y:0,z:-1},{x:-1,y:0,z:1},{x:-1,y:0,z:-1}],R=[];for(let N=this._maxJump;N>=this._maxFall;N--){if(N===0)continue;let B=Math.abs(Z.y+N-X.y);R.push({y:N,distanceToTargetY:B})}R.sort((N,B)=>N.distanceToTargetY-B.distanceToTargetY);let M=[...L,...R.flatMap(({y:N})=>L.map((B)=>({...B,y:N})))],H=0,O=Math.abs(X.x-Z.x)+Math.abs(X.y-Z.y)+Math.abs(X.z-Z.z),P=Math.min(this._maxOpenSetIterations,O*20);while(!z.isEmpty()&&H<P){H++;let[N,B]=z.pop();if(B.x===X.x&&B.y===X.y&&B.z===X.z){let k=this._reconstructPath(F,B);if(this._waypoints=k.map((C)=>({x:C.x+0.5,y:C.y+J/2,z:C.z+0.5})),this._debug)console.log(`PathfindingEntityController._calculatePath: Path found after ${H} open set iterations. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`);return!0}V.add(N);let j=W.get(N),w=new Map;for(let k of M){let C=`${k.x},${k.z}`,E=k.y<0;if(E&&w.has(C))continue;let S={x:B.x+k.x,y:B.y+k.y,z:B.z+k.z};if(Math.abs(X.x-S.x)+Math.abs(X.y-S.y)+Math.abs(X.z-S.z)>O*1.5)continue;let h=this._coordinateToKey(S);if(V.has(h))continue;let p=this._isNeighborCoordinateBlocked(B,S,this._entity.height);if(E&&p){w.set(C,!0);continue}if(p)continue;let f=Math.abs(k.x),g=Math.abs(k.y),J0=Math.abs(k.z),A0=g===0?0:this._verticalPenalty,d0=(Math.max(f,g,J0)===1&&f+g+J0>1?1.4:1)+A0,Q6=j+d0,d6=W.get(h)??1/0;if(Q6>=d6)continue;F.set(h,B),W.set(h,Q6);let Z4=Q6+this._pathfindingHeuristic(S,X);q.set(h,Z4),z.push([h,S])}}if(H>=P){if(this._onPathfindAbort?.(),this._debug)_.warning(`PathfindingEntityController._calculatePath: Maximum open set iterations reached (${P}), path search aborted. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`)}else if(this._debug)_.warning(`PathfindingEntityController._calculatePath: No valid path found. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`);return this._target=void 0,this._waypoints=[],!1}_reconstructPath(J,Z){let X=[Z],Y=Z;while(J.has(this._coordinateToKey(Y)))Y=J.get(this._coordinateToKey(Y)),X.unshift(Y);return X}_coordinateToKey(J){return`${J.x},${J.y},${J.z}`}_moveToNextWaypoint(){let J=this._waypointNextIndex>0?this._waypoints[this._waypointNextIndex-1]:void 0,Z=this._waypoints[this._waypointNextIndex];if(!Z||!this._entity)return;let X=0;if(this._entity.isDynamic&&J&&Z.y>J.y){let Y=Z.y-J.y,K=Math.min(Y,this._maxJump)+0.75;this.jump(K);let $=Math.abs(this._entity.world.simulation.gravity.y),Q=Math.sqrt(2*$*K),G=J.x+0.5,F=J.z+0.5,W=Z.x+0.5,q=Z.z+0.5,V=W-G,z=q-F,L=Math.sqrt(V*V+z*z),R=Q/$,M=L/this._speed;X=Math.min(R*0.8,M)*1000}setTimeout(()=>{if(!this._entity)return;let Y=Date.now();this.face(Z,this._speed),this.move(Z,this._speed,{moveIgnoreAxes:{y:this._entity.isDynamic},moveCallback:()=>{if(Date.now()-Y>this._waypointTimeoutMs&&this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveSkipped?.(Z,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint()},moveCompleteCallback:()=>{if(this._waypointNextIndex<this._waypoints.length-1)this._onWaypointMoveComplete?.(Z,this._waypointNextIndex),this._waypointNextIndex++,this._moveToNextWaypoint();else this._onPathfindComplete?.()}})},X)}_pathfindingHeuristic(J,Z){return Math.abs(J.x-Z.x)+Math.abs(J.y-Z.y)+Math.abs(J.z-Z.z)}_isNeighborCoordinateBlocked(J,Z,X){if(!this._entity?.world)return!1;let Y=this._entity.world,K=Math.floor(Z.x),$=Math.floor(Z.y),Q=Math.floor(Z.z),G=Math.floor(J.x),F=Math.floor(J.z);if(!Y.chunkLattice.hasBlock({x:K,y:$-1,z:Q}))return!0;for(let W=0;W<X;W++)if(Y.chunkLattice.hasBlock({x:K,y:$+W,z:Q}))return!0;if(K!==G&&Q!==F)for(let W=0;W<X;W++){let q=Y.chunkLattice.hasBlock({x:K,y:$+W,z:F}),V=Y.chunkLattice.hasBlock({x:G,y:$+W,z:Q});if(q||V)return!0}return!1}_findGroundedStart(){if(!this._entity?.world)return;let{x:J,y:Z,z:X}=this._entity.position,Y={x:Math.floor(J),y:Math.floor(Z),z:Math.floor(X)};for(let K=0;K<=Math.abs(this._maxFall);K++)if(this._entity.world.chunkLattice.hasBlock({...Y,y:Y.y-K-1}))return{...Y,y:Y.y-K};return}}export{_Z0 as startServer,vE as WorldLoopEvent,EJ as WorldLoop,MV as WorldEvent,SJ as World,FV as WebServerEvent,o5 as WebServer,J4 as Vector3,hJ as Vector2,CJ as Ticker,RV as SimulationEvent,kJ as Simulation,bJ as SimpleEntityController,_J as SceneUIManager,VV as SceneUIEvent,PJ as SceneUI,TE as SUPPORTED_INPUT_KEYS,Y$ as RigidBodyType,f9 as RigidBody,PE as ROTATION_UPDATE_THRESHOLD,e5 as Quaternion,$$ as PlayerUIEvent,TJ as PlayerUI,FB as PlayerManagerEvent,U1 as PlayerManager,NJ as PlayerEvent,xJ as PlayerEntityController,d1 as PlayerEntity,BE as PlayerCameraMode,UV as PlayerCameraEvent,jJ as PlayerCamera,w5 as Player,h9 as PersistenceManager,vV as PathfindingEntityController,xE as POSITION_UPDATE_THRESHOLD_SQ,GV as PORT,U6 as ModelRegistry,_8 as Matrix4,u6 as Matrix3,A9 as Matrix2,NE as LightType,vJ as LightManager,zV as LightEvent,HV as Light,jE as GameServerEvent,M1 as GameServer,s as EventRouter,_ as ErrorHandler,BJ as EntityManager,K$ as EntityEvent,Z8 as Entity,OE as DEFAULT_ENTITY_RIGID_BODY_OPTIONS,q6 as CollisionGroupsBuilder,t1 as CollisionGroup,eX as ColliderShape,DJ as ColliderMap,d8 as Collider,VF as CoefficientCombineRule,OJ as ChunkLattice,qV as ChunkEvent,w8 as Chunk,IJ as ChatManager,wV as ChatEvent,HF as BlockTypeRegistryEvent,m4 as BlockTypeRegistry,zF as BlockTypeEvent,L6 as BlockType,p9 as Block,CV as BaseEntityControllerEvent,i1 as BaseEntityController,$4 as AudioManager,U$ as AudioEvent,K4 as Audio};
|