hytopia 0.3.8 → 0.3.9
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/docs/server.playerentitycontroller.md +1 -1
- package/docs/server.playerentitycontroller.tickwithplayerinput.md +1 -1
- package/examples/hygrounds/classes/weapons/AK47Entity.ts +1 -1
- package/examples/hygrounds/classes/weapons/AutoShotgunEntity.ts +1 -1
- package/examples/hygrounds/classes/weapons/AutoSniperEntity.ts +2 -2
- package/examples/hygrounds/classes/weapons/LightMachineGunEntity.ts +1 -1
- package/examples/hygrounds/classes/weapons/SubmachineGunEntity.ts +1 -1
- package/package.json +1 -1
- package/server.api.json +1 -1
- package/server.d.ts +3 -1
- package/server.js +1 -1
@@ -457,7 +457,7 @@ Called when the controlled entity is spawned. In PlayerEntityController, this fu
|
|
457
457
|
|
458
458
|
</td><td>
|
459
459
|
|
460
|
-
Ticks the player movement for the entity controller, overriding the default implementation.
|
460
|
+
Ticks the player movement for the entity controller, overriding the default implementation. If the entity to tick is a child entity, only the event will be emitted but the default movement logic will not be applied.
|
461
461
|
|
462
462
|
|
463
463
|
</td></tr>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## PlayerEntityController.tickWithPlayerInput() method
|
6
6
|
|
7
|
-
Ticks the player movement for the entity controller, overriding the default implementation.
|
7
|
+
Ticks the player movement for the entity controller, overriding the default implementation. If the entity to tick is a child entity, only the event will be emitted but the default movement logic will not be applied.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
@@ -16,7 +16,7 @@ const DEFAULT_AK47_OPTIONS: GunEntityOptions = {
|
|
16
16
|
scopeZoom: 2,
|
17
17
|
modelUri: 'models/items/ak-47.glb',
|
18
18
|
modelScale: 1.3,
|
19
|
-
range:
|
19
|
+
range: 80,
|
20
20
|
reloadAudioUri: 'audio/sfx/rifle-reload.mp3',
|
21
21
|
reloadTimeMs: 2200,
|
22
22
|
shootAudioUri: 'audio/sfx/rifle-shoot.mp3',
|
@@ -15,7 +15,7 @@ const DEFAULT_AUTO_SHOTGUN_OPTIONS: GunEntityOptions = {
|
|
15
15
|
totalAmmo: 30,
|
16
16
|
modelUri: 'models/items/auto-shotgun.glb',
|
17
17
|
modelScale: 1.2,
|
18
|
-
range:
|
18
|
+
range: 10,
|
19
19
|
reloadAudioUri: 'audio/sfx/shotgun-reload.mp3',
|
20
20
|
reloadTimeMs: 3500,
|
21
21
|
shootAudioUri: 'audio/sfx/shotgun-shoot.mp3',
|
@@ -11,8 +11,8 @@ const DEFAULT_AUTO_SNIPER_OPTIONS: GunEntityOptions = {
|
|
11
11
|
idleAnimation: 'idle_gun_both',
|
12
12
|
mlAnimation: 'shoot_gun_both',
|
13
13
|
name: 'Auto Sniper',
|
14
|
-
maxAmmo:
|
15
|
-
totalAmmo:
|
14
|
+
maxAmmo: 10,
|
15
|
+
totalAmmo: 20,
|
16
16
|
scopeZoom: 5,
|
17
17
|
modelUri: 'models/items/auto-sniper.glb',
|
18
18
|
modelScale: 1.3,
|
@@ -16,7 +16,7 @@ const DEFAULT_LIGHT_MACHINE_GUN_OPTIONS: GunEntityOptions = {
|
|
16
16
|
scopeZoom: 1.35,
|
17
17
|
modelUri: 'models/items/light-machine-gun.glb',
|
18
18
|
modelScale: 1.3,
|
19
|
-
range:
|
19
|
+
range: 60,
|
20
20
|
reloadAudioUri: 'audio/sfx/machine-gun-reload.mp3',
|
21
21
|
reloadTimeMs: 4200,
|
22
22
|
shootAudioUri: 'audio/sfx/machine-gun-shoot.mp3',
|
@@ -16,7 +16,7 @@ const DEFAULT_SUBMACHINE_GUN_OPTIONS: GunEntityOptions = {
|
|
16
16
|
scopeZoom: 1.35,
|
17
17
|
modelUri: 'models/items/submachine-gun.glb',
|
18
18
|
modelScale: 1.3,
|
19
|
-
range:
|
19
|
+
range: 40,
|
20
20
|
reloadAudioUri: 'audio/sfx/rifle-reload.mp3',
|
21
21
|
reloadTimeMs: 1500,
|
22
22
|
shootAudioUri: 'audio/sfx/pistol-shoot.mp3',
|
package/package.json
CHANGED
package/server.api.json
CHANGED
@@ -27166,7 +27166,7 @@
|
|
27166
27166
|
{
|
27167
27167
|
"kind": "Method",
|
27168
27168
|
"canonicalReference": "server!PlayerEntityController#tickWithPlayerInput:member(1)",
|
27169
|
-
"docComment": "/**\n * Ticks the player movement for the entity controller, overriding the default implementation.\n *\n * @param entity - The entity to tick.\n *\n * @param input - The current input state of the player.\n *\n * @param cameraOrientation - The current camera orientation state of the player.\n *\n * @param deltaTimeMs - The delta time in milliseconds since the last tick.\n */\n",
|
27169
|
+
"docComment": "/**\n * Ticks the player movement for the entity controller, overriding the default implementation. If the entity to tick is a child entity, only the event will be emitted but the default movement logic will not be applied.\n *\n * @param entity - The entity to tick.\n *\n * @param input - The current input state of the player.\n *\n * @param cameraOrientation - The current camera orientation state of the player.\n *\n * @param deltaTimeMs - The delta time in milliseconds since the last tick.\n */\n",
|
27170
27170
|
"excerptTokens": [
|
27171
27171
|
{
|
27172
27172
|
"kind": "Content",
|
package/server.d.ts
CHANGED
@@ -3511,7 +3511,9 @@ export declare class PlayerEntityController extends BaseEntityController {
|
|
3511
3511
|
spawn(entity: Entity): void;
|
3512
3512
|
/**
|
3513
3513
|
* Ticks the player movement for the entity controller,
|
3514
|
-
* overriding the default implementation.
|
3514
|
+
* overriding the default implementation. If the entity to tick
|
3515
|
+
* is a child entity, only the event will be emitted but the default
|
3516
|
+
* movement logic will not be applied.
|
3515
3517
|
*
|
3516
3518
|
* @param entity - The entity to tick.
|
3517
3519
|
* @param input - The current input state of the player.
|
package/server.js
CHANGED
@@ -377,6 +377,6 @@ Instead, \`yield\` should either be called with a value, or not be called at all
|
|
377
377
|
`),Z.write(`Content-Length: ${$.length}\r
|
378
378
|
`),Z.write(`Connection: close\r
|
379
379
|
`),Z.write(`\r
|
380
|
-
`),Z.write($),Z.end();return}this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:Y})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class BJ extends s{static instance=new BJ;_wss;constructor(){super();this._wss=new vZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),l8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:Y})=>this._onUpgrade(J,Z,Y))}_onConnection=(J,Z)=>{new O9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,Y)=>{this._wss.handleUpgrade(J,Z,Y,(X)=>{this._wss.emit("connection",X,J)})}}var m=new Error("RigidBody has been removed from the simulation and is therefore inaccessible."),F$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(F$||={});var d6=0.001,$C="dynamic";class h9 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??=$C,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(this._rigidBody||this._rigidBodyDesc)return this._additionalMass;throw m}get additionalSolverIterations(){if(this._rigidBody)return this._rigidBody.additionalSolverIterations();if(this._rigidBodyDesc)return this._rigidBodyDesc.additionalSolverIterations;throw m}get angularDamping(){if(this._rigidBody)return this._rigidBody.angularDamping();if(this._rigidBodyDesc)return this._rigidBodyDesc.angularDamping;throw m}get angularVelocity(){if(this._rigidBody)return this._rigidBody.angvel();if(this._rigidBodyDesc)return this._rigidBodyDesc.angvel;throw m}get colliders(){return this._colliders}get dominanceGroup(){if(this._rigidBody)return this._rigidBody.dominanceGroup();if(this._rigidBodyDesc)return this._rigidBodyDesc.dominanceGroup;throw m}get directionFromRotation(){let{x:J,y:Z,z:Y,w:X}=this.rotation;return{x:2*(J*Y+X*Z),y:2*(Z*Y-X*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(this._rigidBody)return this._rigidBody.effectiveAngularInertia();if(this._rigidBodyDesc)return;throw m}get effectiveInverseMass(){if(this._rigidBody)return this._rigidBody.effectiveInvMass();if(this._rigidBodyDesc)return;throw m}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(this._rigidBody)return this._rigidBody.effectiveWorldInvInertiaSqrt();if(this._rigidBodyDesc)return;throw m}get enabledRotations(){if(this._rigidBody||this._rigidBodyDesc)return this._enabledRotations;throw m}get enabledPositions(){if(this._rigidBody||this._rigidBodyDesc)return this._enabledPositions;throw m}get gravityScale(){if(this._rigidBody)return this._rigidBody.gravityScale();if(this._rigidBodyDesc)return this._rigidBodyDesc.gravityScale;throw m}get inverseMass(){if(this._rigidBody)return this._rigidBody.invMass();if(this._rigidBodyDesc)return;throw m}get inversePrincipalAngularInertiaSqrt(){if(this._rigidBody)return this._rigidBody.invPrincipalInertiaSqrt();if(this._rigidBodyDesc)return;throw m}get isCcdEnabled(){if(this._rigidBody)return this._rigidBody.isCcdEnabled();if(this._rigidBodyDesc)return this._rigidBodyDesc.ccdEnabled;throw m}get isDynamic(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="dynamic";throw m}get isEnabled(){if(this._rigidBody)return this._rigidBody.isEnabled();if(this._rigidBodyDesc)return this._rigidBodyDesc.enabled;throw m}get isFixed(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="fixed";throw m}get isKinematic(){if(this._rigidBody||this._rigidBodyDesc)return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType);throw m}get isKinematicPositionBased(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="kinematic_position";throw m}get isKinematicVelocityBased(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="kinematic_velocity";throw m}get isMoving(){if(this._rigidBody)return this._rigidBody.isMoving();if(this._rigidBodyDesc)return!1;throw m}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(this._rigidBody)return!0;if(this._rigidBodyDesc)return!1;throw m}get isSleeping(){if(this._rigidBody)return this._rigidBody.isSleeping();if(this._rigidBodyDesc)return this._rigidBodyDesc.sleeping;throw m}get linearDamping(){if(this._rigidBody)return this._rigidBody.linearDamping();if(this._rigidBodyDesc)return this._rigidBodyDesc.linearDamping;throw m}get linearVelocity(){if(this._rigidBody)return this._rigidBody.linvel();if(this._rigidBodyDesc)return this._rigidBodyDesc.linvel;throw m}get localCenterOfMass(){if(this._rigidBody)return this._rigidBody.localCom();if(this._rigidBodyDesc)return this._rigidBodyDesc.centerOfMass;throw m}get mass(){if(this._rigidBody)return this._rigidBody.mass();if(this._rigidBodyDesc)return this._rigidBodyDesc.mass;throw m}get nextKinematicRotation(){if(this._rigidBody)return this._rigidBody.nextRotation();if(this._rigidBodyDesc)return this._rigidBodyDesc.rotation;throw m}get nextKinematicPosition(){if(this._rigidBody)return this._rigidBody.nextTranslation();if(this._rigidBodyDesc)return this._rigidBodyDesc.translation;throw m}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(this._rigidBody)return this._rigidBody.principalInertia();if(this._rigidBodyDesc)return this._rigidBodyDesc.principalAngularInertia;throw m}get principalAngularInertiaLocalFrame(){if(this._rigidBody)return this._rigidBody.principalInertiaLocalFrame();if(this._rigidBodyDesc)return;throw m}get position(){if(this._rigidBody)return this._rigidBody.translation();if(this._rigidBodyDesc)return this._rigidBodyDesc.translation;throw m}get rawRigidBody(){if(this._rigidBody)return this._rigidBody;if(this._rigidBodyDesc)return;throw m}get rotation(){if(this._rigidBody)return this._rigidBody.rotation();if(this._rigidBodyDesc)return this._rigidBodyDesc.rotation;throw m}get softCcdPrediction(){if(this._rigidBody)return this._rigidBody.softCcdPrediction();if(this._rigidBodyDesc)return this._rigidBodyDesc.softCcdPrediction;throw m}get type(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType;throw m}get worldCenterOfMass(){if(this._rigidBody)return this._rigidBody.worldCom();if(this._rigidBodyDesc)return;throw m}setAdditionalMass(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAdditionalMass(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalMass(J);else throw m}setAdditionalMassProperties(J){this._requireDynamic();let{additionalMass:Z,centerOfMass:Y,principalAngularInertia:X,principalAngularInertiaLocalFrame:K}=J;if(this._rigidBody)this._rigidBody.setAdditionalMassProperties(Z,Y,X,K,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalMassProperties(Z,Y,X,K);else throw m;this._additionalMass=Z}setAdditionalSolverIterations(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAdditionalSolverIterations(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalSolverIterations(J);else throw m}setAngularDamping(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAngularDamping(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAngularDamping(J);else throw m}setAngularVelocity(J){if(this._requireNotKinematicPositionBased(),this._rigidBody)this._rigidBody.setAngvel(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAngvel(J);else throw m}setCcdEnabled(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.enableCcd(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setCcdEnabled(J);else throw m}setDominanceGroup(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setDominanceGroup(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setDominanceGroup(J);else throw m}setEnabled(J){if(this._rigidBody)this._rigidBody.setEnabled(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setEnabled(J);else throw m}setEnabledPositions(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z);else throw m;this._enabledPositions=J}setEnabledRotations(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z);else throw m;this._enabledRotations=J}setGravityScale(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setGravityScale(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setGravityScale(J);else throw m}setLinearDamping(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setLinearDamping(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setLinearDamping(J);else throw m}setLinearVelocity(J){if(this._requireNotKinematicPositionBased(),this._rigidBody)this._rigidBody.setLinvel(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setLinvel(J.x,J.y,J.z);else throw m}setNextKinematicRotation(J){if(this._requireKinematic(),this._rigidBody)this._rigidBody.setNextKinematicRotation(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setRotation(J);else throw m}setNextKinematicPosition(J){if(this._requireKinematic(),this._rigidBody)this._rigidBody.setNextKinematicTranslation(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setTranslation(J.x,J.y,J.z);else throw m}setPosition(J){if(this._rigidBody)this._rigidBody.setTranslation(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setTranslation(J.x,J.y,J.z);else throw m}setRotation(J){if(this._rigidBody)this._rigidBody.setRotation(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setRotation(J);else throw m}setSleeping(J){if(this._requireDynamic(),this._rigidBody)J?this._rigidBody.sleep():this._rigidBody.wakeUp();else if(this._rigidBodyDesc)this._rigidBodyDesc.sleeping=J;else throw m;this._explicitSleep=J}setSoftCcdPrediction(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setSoftCcdPrediction(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setSoftCcdPrediction(J);else throw m}setCollisionGroupsForSolidColliders(J){this._requireNotRemoved(),this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){this._requireNotRemoved(),this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){let Y={["dynamic"]:z0.RigidBodyType.Dynamic,["fixed"]:z0.RigidBodyType.Fixed,["kinematic_position"]:z0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:z0.RigidBodyType.KinematicVelocityBased}[J];if(Y===void 0)throw new Error(`Invalid RigidBodyType: ${J}`);if(this._rigidBody)this._rigidBody.setBodyType(Y,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.status=Y;else throw m;this._rigidBodyType=J}addForce(J){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){this._requireNotRemoved(),this._requireCreated(),J.addToSimulation(this._simulation,this)}addToSimulation(J){if(this._requireNotRemoved(),this._rigidBody)throw new Error("RigidBody.create(): 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(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){return this._requireNotRemoved(),this._simulation?new n8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((Y)=>{Z.push(this.createAndAddChildCollider(Y))}),Z}getCollidersByTag(J){let Z=[];for(let Y of this._colliders)if(Y.tag===J)Z.push(Y);return Z}linkCollider(J){if(this._requireNotRemoved(),J.parentRigidBody!==this)throw new Error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){this._requireNotRemoved(),this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){this._requireNotRemoved(),this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(this._requireNotRemoved(),!this._rigidBody)throw new 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(),!J.isRemoved)throw new Error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){this._requireNotRemoved(),this._requireCreated(),this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){this._requireNotRemoved(),this._requireCreated(),this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){this._requireNotRemoved(),this._requireCreated(),this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){this._requireNotRemoved(),this._requireCreated(),this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){this._requireNotRemoved(),this.setSleeping(!0)}wakeUp(){this._requireNotRemoved(),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(([Y,X])=>{if(J[Y]!==void 0)X.call(this,J[Y])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){this._requireNotRemoved(),this._requireNotSimulated();let Z=new n8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((Y)=>{Z.push(this._createAndAddPendingChildCollider(Y))}),Z}_createRigidBodyDesc(J){let Z=J.type??$C;return{["dynamic"]:()=>z0.RigidBodyDesc.dynamic(),["fixed"]:()=>z0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>z0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>z0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(){if(!this._rigidBody||!this._simulation)throw new Error("RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method.")}_requireDynamic(){if(!this.isDynamic)throw new Error("RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method.")}_requireKinematic(){if(!this.isKinematic)throw new Error("RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method.")}_requireNotKinematicPositionBased(){if(this.isKinematicPositionBased)throw new Error("RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method.")}_requireNotRemoved(){if(!this._rigidBody&&!this._rigidBodyDesc)throw m}_requireNotSimulated(){if(this.isSimulated)throw new Error("RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method.")}_isEqualVectors(J,Z){return Math.abs(J.x-Z.x)<d6&&Math.abs(J.y-Z.y)<d6&&Math.abs(J.z-Z.z)<d6}_isEqualRotations(J,Z){return Math.abs(J.x-Z.x)<d6&&Math.abs(J.y-Z.y)<d6&&Math.abs(J.z-Z.z)<d6&&Math.abs(J.w-Z.w)<d6}_isNegligibleVector(J){return Math.abs(J.x)<d6&&Math.abs(J.y)<d6&&Math.abs(J.z)<d6}}var n0=16,t5=n0-1,QC=n0**3,jZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+0,J+0,Z+1,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,Y)=>[J+1,Z+0,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+1,J+1,Z+0,Y+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+1,Z+0,Y+0,J+0,Z+0,Y+1,J+1,Z+0,Y+0,J+1,Z+0,Y+1,J+0,Z+0,Y+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,Y)=>[J+0,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+1,J+1,Z+0,Y+1,J+0,Z+1,Y+1,J+0,Z+1,Y+1,J+1,Z+0,Y+1,J+1,Z+1,Y+1]}],Zq;((X)=>{X.DESPAWN="CHUNK.DESPAWN";X.SET_BLOCK="CHUNK.SET_BLOCK";X.SPAWN="CHUNK.SPAWN"})(Zq||={});class N8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(QC)}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%n0,y:(J/n0|0)%n0,z:J/(n0*n0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&n0-1,y:J.y&n0-1,z:J.z&n0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(n0-1),y:J.y&~(n0-1),z:J.z&~(n0-1)}}static isValidOriginCoordinate(J){return J.x%n0===0&&J.y%n0===0&&J.z%n0===0}spawn(J,Z){if(this.isSpawned){let{x:Y,y:X,z:K}=this.originCoordinate;throw new Error(`Chunk.spawn(): Chunk is already spawned at origin ${Y}, ${X}, ${K}!`)}if(!N8.isValidOriginCoordinate(Z))throw new Error(`Chunk.spawn(): Chunk coordinates must be divisible by ${n0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)throw new 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))throw new 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 Y=this._getGlobalCoordinate(J),X=[];if(J.x===0)X.push({x:-1,y:0,z:0});if(J.y===0)X.push({x:0,y:-1,z:0});if(J.z===0)X.push({x:0,y:0,z:-1});if(J.x===t5)X.push({x:1,y:0,z:0});if(J.y===t5)X.push({x:0,y:1,z:0});if(J.z===t5)X.push({x:0,y:0,z:1});for(let K of X){let $={x:Y.x+K.x,y:Y.y+K.y,z:Y.z+K.z},Q=N8.globalCoordinateToOriginCoordinate($),F=this._world?.chunkLattice.getChunk(Q);if(!F?.hasBlock(N8.globalCoordinateToLocalCoordinate($)))continue;F.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)throw new 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 h9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([Y,X])=>{if(!Y.isSimulated)Y.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(Y,X)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return e.serializeChunk(this)}_meshColliders(){if(!this._world)throw new Error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed.");let J=new Map,Z=[];for(let X=0;X<QC;X++){if(this._blocks[X]===0)continue;let K=this._blocks[X],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:F,z:G}=N8.blockIndexToLocalCoordinate(X);if(!$.isMeshable){let V=$.createCollider();V.setRelativePosition({x:Q,y:F,z:G}),Z.push([V,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let V of jZ0){let[q,H,U]=V.neighborOffset,O={x:Q+q,y:F+H,z:G+U},M=this._getGlobalCoordinate(O),L=this._world.chunkLattice.getBlockType(M);if(L&&!L.isLiquid)continue;let R=W.indices.length;W.indices.push(R,R+1,R+2,R+3,R+4,R+5),W.vertices.push(...V.generateVertices(Q,F,G))}}let Y=[];return J.forEach((X,K)=>{if(!X.indices.length)return;let $=K.createCollider(new Uint32Array(X.indices),new Float32Array(X.vertices));Y.push([$,K])}),[...Z,...Y]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)throw new Error("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+n0*(J.y+n0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=t5&&J.y>=0&&J.y<=t5&&J.z>=0&&J.z<=t5}}class vJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)throw new Error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:Y,z:X}=J.originCoordinate;throw new Error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${Y}, ${X}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)throw new Error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)throw new Error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)throw new Error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(N8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(N8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!N8.isValidOriginCoordinate(J))throw new Error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${n0})`);return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(N8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(N8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let Y=N8.globalCoordinateToLocalCoordinate(J),X=N8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(X);if(!K)K=new N8,K.spawn(this._world,X);K.setBlock(Y,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var FC={type:"dynamic",softCcdPrediction:1},GC=0.0025000000000000005,WC=Math.cos(0.005),G$;((R)=>{R.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";R.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";R.DESPAWN="ENTITY.DESPAWN";R.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";R.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";R.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";R.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";R.SET_OPACITY="ENTITY.SET_OPACITY";R.SET_PARENT="ENTITY.SET_PARENT";R.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";R.SPAWN="ENTITY.SPAWN";R.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";R.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";R.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";R.TICK="ENTITY.TICK";R.UPDATE_POSITION="ENTITY.UPDATE_POSITION";R.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(G$||={});class K8 extends h9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes;_modelLoopedAnimations;_modelOneshotAnimations;_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){if(!J.blockTextureUri===!J.modelUri)throw new Error("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J.blockTextureUri&&!J.blockHalfExtents)throw new Error("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)throw new Error("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!O6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))throw new Error(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??FC);if(this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri,this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelHiddenNodes=new Set(J.modelHiddenNodes??[]),this._modelLoopedAnimations=new Set(J.modelLoopedAnimations??[]),this._modelOneshotAnimations=new Set,this._modelScale=J.modelScale,this._modelUri=J.modelUri,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?O6.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,Y){if(this.isSpawned)return console.warn(`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 n8(n8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((X)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))X.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(H6.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[X.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),Y)this.setRotation(Y);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,Y);this.colliders.forEach((X)=>{J.simulation.colliderMap.setColliderEntity(X,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this.isSpawned)return console.warn(`Entity.despawn(): Entity ${this._name} is not been spawned and cannot be despawned!`);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(),!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){this._requireSpawned(),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(),this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,Y,X){if(this._requireSpawned(),J&&!J.isSpawned)throw new 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(Y??{x:0,y:0,z:0}),this.setRotation(X??{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(),!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(),!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(),!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(),!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 e.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){this._requireSpawned();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(){if(!this.isSpawned)throw new Error(`Entity._requireSpawned(): Entity ${this._name} is not spawned!`)}_positionExceedsThreshold(J,Z){let Y=J.x-Z.x,X=J.y-Z.y,K=J.z-Z.z;return Y*Y+X*X+K*K>GC}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<WC}}class jJ extends a1{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 $4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)throw new 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,Y)=>{if(this._groundContactCount+=Y?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof K8)||!Z.isKinematic)return;if(Y&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!Y)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,Y,X){if(!J.isSpawned||!J.world)return;super.tickWithPlayerInput(J,Z,Y,X);let{w:K,a:$,s:Q,d:F,sp:G,sh:W,ml:V}=Z,{yaw:q}=Y,H=J.linearVelocity,U={x:0,y:0,z:0},O=W;if(this.isGrounded&&(K||$||Q||F)){if(O)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(V)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(O&&this.canRun(this)||!O&&this.canWalk(this)){let P=O?this.runVelocity:this.walkVelocity;if(K)U.x-=P*Math.sin(q),U.z-=P*Math.cos(q);if(Q)U.x+=P*Math.sin(q),U.z+=P*Math.cos(q);if($)U.x-=P*Math.cos(q),U.z+=P*Math.sin(q);if(F)U.x+=P*Math.cos(q),U.z-=P*Math.sin(q);let B=Math.sqrt(U.x*U.x+U.z*U.z);if(B>P){let v=P/B;U.x*=v,U.z*=v}}if(G&&this.canJump(this)){if(this.isGrounded&&H.y>-0.001&&H.y<=3)U.y=this.jumpVelocity}let M=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},L={x:U.x-H.x+M.x,y:U.y+M.y,z:U.z-H.z+M.z};if(!(this.runVelocity>0&&Math.abs(H.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(H.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(H.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(L).some((P)=>P!==0)){let P=J.mass;J.applyImpulse({x:L.x*P,y:L.y*P,z:L.z*P})}}if(q!==void 0){let P=q/2;J.setRotation({x:0,y:Math.fround(Math.sin(P)),z:0,w:Math.fround(Math.cos(P))})}}}var Yq;((F)=>{F.LOAD="SCENE_UI.LOAD";F.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";F.SET_OFFSET="SCENE_UI.SET_OFFSET";F.SET_POSITION="SCENE_UI.SET_POSITION";F.SET_STATE="SCENE_UI.SET_STATE";F.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";F.UNLOAD="SCENE_UI.UNLOAD"})(Yq||={});class kJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)throw new Error("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;this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)throw new 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 e.serializeSceneUI(this)}}class n1 extends K8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new kJ({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 jJ)}spawn(J,Z,Y){super.spawn(J,Z,Y),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:X})=>{this.nametagSceneUI.setState({chat:X})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:Y}=this.player;this.controller.tickWithPlayerInput(this,Z,Y.orientation,J),super.tick(J)}}class TJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)throw new Error(`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)throw new 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 n1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((Y)=>{if(Y instanceof n1&&Y.player===J)Z.push(Y)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag===J)Z.push(Y)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag?.includes(J))Z.push(Y)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.parent===J)Z.push(Y)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class DJ{_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 VC;((Y)=>{Y[Y.POINTLIGHT=0]="POINTLIGHT";Y[Y.SPOTLIGHT=1]="SPOTLIGHT"})(VC||={});var Xq;((H)=>{H.DESPAWN="LIGHT.DESPAWN";H.SET_ANGLE="LIGHT.SET_ANGLE";H.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";H.SET_COLOR="LIGHT.SET_COLOR";H.SET_DISTANCE="LIGHT.SET_DISTANCE";H.SET_INTENSITY="LIGHT.SET_INTENSITY";H.SET_OFFSET="LIGHT.SET_OFFSET";H.SET_PENUMBRA="LIGHT.SET_PENUMBRA";H.SET_POSITION="LIGHT.SET_POSITION";H.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";H.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";H.SPAWN="LIGHT.SPAWN"})(Xq||={});class Kq extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)throw new Error("Either attachedToEntity or position must be set, but not both");super();console.warn("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)throw new 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)throw new 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;this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return e.serializeLight(this)}}var qC;((X)=>{X[X.FIRST_PERSON=0]="FIRST_PERSON";X[X.THIRD_PERSON=1]="THIRD_PERSON";X[X.SPECTATOR=2]="SPECTATOR"})(qC||={});var $q;((U)=>{U.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";U.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";U.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";U.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";U.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";U.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";U.SET_FOV="PLAYER_CAMERA.SET_FOV";U.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";U.SET_MODE="PLAYER_CAMERA.SET_MODE";U.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";U.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";U.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";U.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})($q||={});class _J 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){this._requirePlayerWorld(),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){this._requirePlayerWorld(),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(this._requirePlayerWorld(),!J.isSpawned)throw new 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){this._requirePlayerWorld(),this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){this._requirePlayerWorld(),this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){this._requirePlayerWorld(),this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){this._requirePlayerWorld(),this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){this._requirePlayerWorld(),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){this._requirePlayerWorld(),this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){this._requirePlayerWorld(),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){this._requirePlayerWorld(),this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){this._requirePlayerWorld(),this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){this._requirePlayerWorld(),this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return e.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)throw new Error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`)}}var W$;((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"})(W$||={});class EJ 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 CJ{_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){return this._requireSimulatedCollider(J),this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){return this._requireSimulatedCollider(J),this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){return this._requireSimulatedCollider(J),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){this._requireSimulatedCollider(J),this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){this._requireSimulatedCollider(J),this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){this._requireSimulatedCollider(J),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){this._requireSimulatedCollider(J),this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){this._requireSimulatedCollider(J),this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){this._requireSimulatedCollider(J),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 Y of J.keys())Z.add(Y);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)throw new Error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.")}}var kZ0={x:0,y:-32,z:0},Qq=60,Fq;((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"})(Fq||={});class SJ extends s{_colliderMap=new CJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=Qq,Y=kZ0){super();this._rapierEventQueue=new z0.EventQueue(!0),this._rapierSimulation=new z0.World(Y),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,Y,X={}){let K=new z0.Ray(J,Z),$=this._rapierSimulation.castRay(K,Y,X.ignoresSensors??!0,X.filterFlags,X.filterGroups,X.filterExcludeCollider,X.filterExcludeRigidBody,X.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:Y,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),F=$.timeOfImpact,G=$.collider,W=this._colliderMap.getColliderHandleBlockType(G.handle);if(W)return{hitBlock:y9.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:F};let V=this._colliderMap.getColliderHandleEntity(G.handle);if(V)return{hitEntity:V,hitPoint:Q,hitDistance:F};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 Y=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(X,K)=>{if(X.numContacts()===0)return;let $=X.normal(),Q=[];for(let F=0;F<X.numSolverContacts();F++)Q.push(X.solverContactPoint(F));Y.push({contactPoints:Q,localNormalA:!K?X.localNormal1():X.localNormal2(),localNormalB:!K?X.localNormal2():X.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),Y}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,Y)=>{let[X,K]=this._getCollisionObjects(J,Z);if(!X||!K)return;let $=(Q,F)=>{if(Q instanceof M6&&F instanceof K8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof M6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof K8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(F instanceof K8||F instanceof M6))Q(F,Y,J,Z)};$(X,K),$(K,X)};_onContactForceEvent=(J)=>{let[Z,Y]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!Y||typeof Y==="function")return;let X={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof M6&&Q instanceof K8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof M6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof K8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:X})};K(Z,Y),K(Y,Z)};_getCollisionObjects(J,Z){let Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[Y,X]}}class V${_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(){for(let[W,V]of this._queuedPerPlayerSynchronizations)for(let q of V)W.connection.send(q);let J=Object.values(this._queuedEntitySynchronizations);if(J.length>0){let W=y.createPacket(y.outboundPackets.entitiesPacketDefinition,J,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Z=Object.values(this._queuedAudioSynchronizations);if(Z.length>0){let W=y.createPacket(y.outboundPackets.audiosPacketDefinition,Z,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Y=Object.values(this._queuedBlockTypeSynchronizations);if(Y.length>0){let W=y.createPacket(y.outboundPackets.blockTypesPacketDefinition,Y,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let X=Object.values(this._queuedBlockSynchronizations);if(X.length>0){let W=y.createPacket(y.outboundPackets.blocksPacketDefinition,X,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let K=Object.values(this._queuedChunkSynchronizations);if(K.length>0){let W=y.createPacket(y.outboundPackets.chunksPacketDefinition,K,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let $=Object.values(this._queuedLightSynchronizations);if($.length>0){let W=y.createPacket(y.outboundPackets.lightsPacketDefinition,$,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerUISynchronizations){let q=y.createPacket(y.outboundPackets.uiPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}for(let[W,V]of this._queuedPerPlayerUIDatasSynchronizations){let q=y.createPacket(y.outboundPackets.uiDatasPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let Q=Object.values(this._queuedSceneUISynchronizations);if(Q.length>0){let W=y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,Q,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}if(this._queuedWorldSynchronization){let W=y.createPacket(y.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerCameraSynchronizations){let q=y.createPacket(y.outboundPackets.cameraPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let F=Object.values(this._queuedPlayerSynchronizations);if(F.length>0){let W=y.createPacket(y.outboundPackets.playersPacketDefinition,F,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let W of this._queuedBroadcasts)Y8.instance.broadcastToWorld(this._world.id,W);let G=this._queuedDebugRaycastSynchronizations;if(G.length>0){let W=y.createPacket(y.outboundPackets.physicsDebugRaycastsPacketDefinition,G,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}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()}_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_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};_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?e.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:Y,color:X}=J;this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:Y,color:X}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X}],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),Y=Z.c.join(",");if(this._spawnedChunks.has(Y))delete this._queuedChunkSynchronizations[Y],this._spawnedChunks.delete(Y);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?e.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((Y)=>!J.animations.has(Y)).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((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((Y)=>!J.animations.has(Y)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((Y)=>!J.animations.has(Y)).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=e.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?e.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?e.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?e.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=e.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?e.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?e.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?e.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?e.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,Y=this._queuedPerPlayerSynchronizations.get(Z)??[];Y.push(y.createPacket(y.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof n1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllLoopedAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.playersPacketDefinition,Y8.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let X=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...X}),this._queuedPerPlayerSynchronizations.set(Z,Y),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?e.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?e.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(e.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=e.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=e.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=e.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:Y,z:X}=J;return this._queuedBlockSynchronizations[`${Z},${Y},${X}`]??={i:0,c:[Z,Y,X]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)throw new Error("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:Y,z:X}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${Y},${X}`]??={c:[Z,Y,X]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)throw new Error("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)throw new Error("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)throw new Error("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}}class IJ{_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 fJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,Y){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=Y}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 console.warn("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),Y=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,Y>250)Y=250;this._accumulatorMs+=Y;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 console.warn("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 console.warn("Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error:",Z)}}}var HC;(($)=>{$.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"})(HC||={});class hJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=Qq){super();this._ticker=new fJ(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)=>{console.error(J),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var Gq;((F)=>{F.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";F.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";F.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";F.START="WORLD.START";F.STOP="WORLD.STOP"})(Gq||={});class bJ 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 Q4(this),this._blockTypeRegistry=new i4(this),this._chatManager=new pJ(this),this._chunkLattice=new vJ(this),this._entityManager=new TJ(this),this._lightManager=new DJ(this),this._loop=new hJ(this,J.tickRate),this._networkSynchronizer=new V$(this),this._sceneUIManager=new IJ(this),this._simulation=new SJ(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,Y]of Object.entries(J.blocks)){let[X,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:X,y:K,z:$},Y)}if(J.entities)for(let[Z,Y]of Object.entries(J.entities)){let[X,K,$]=Z.split(",").map(Number);new K8(Y).spawn(this,{x:X,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 e.serializeWorld(this)}}var zC;((Y)=>{Y.START="GAMESERVER.START";Y.STOP="GAMESERVER.STOP"})(zC||={});function xZ0(J){z0.init().then(()=>{return R1.instance.modelRegistry.preloadModels()}).then(()=>{J(R1.instance.worlds[0]),R1.instance.start()}).catch((Z)=>{console.error("Failed to initialize the game engine, exiting. Error:",Z),process.exit(1)})}class R1{static _instance;_modelRegistry=O6.instance;_playerManager=Y8.instance;_socket=BJ.instance;_webServer=r5.instance;_worlds={};constructor(){let J=new bJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new R1;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(){l8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){l8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class b9{static instance=new b9;constructor(){}async getGlobalData(J){let Z=await u6.instance.getData(J);if(!Z||Z.error){if(Z?.error)console.warn(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await u6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)console.warn(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let Y=await u6.instance.setData(J,Z);if(!Y||Y.error){if(Y?.error)console.warn(`PersistenceManager.setGlobalData(): ${Y.error.message}`);return}return Y}async setPlayerData(J,Z){let Y=await u6.instance.setData(this._getPlayerKey(J),Z);if(!Y||Y.error){if(Y?.error)console.warn(`PersistenceManager.setPlayerData(): ${Y.error.message}`);return}return Y}_getPlayerKey(J){return`player-${J.id}`}}var LC=["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"],xJ;((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"})(xJ||={});class R5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${R5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new _J(this),this.connection=J,this.ui=new EJ(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(R1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return b9.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 b9.instance.setPlayerData(this,J)}serialize(){return e.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(LC.forEach((Y)=>{let X=Y;if(Z[X]!==void 0)this._input[X]=Boolean(Z[X])}),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 Wq;((Y)=>{Y.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";Y.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(Wq||={});class pJ 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,Y){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:Y})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:Y}=J,[X,...K]=Y.split(" "),$=this._commandCallbacks[X];if($){$(Z,K,Y);return}this._sendBroadcastMessage(Z,`${Z.username}: ${Y}`)})}_sendBroadcastMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:Y})}}var l=0.000001,F0=typeof Float32Array!=="undefined"?Float32Array:Array,i6=Math.random;var YD0=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 J8={};o6(J8,{transpose:()=>IZ0,subtract:()=>OC,sub:()=>oZ0,str:()=>cZ0,set:()=>SZ0,scale:()=>AZ0,rotate:()=>pZ0,multiplyScalarAndAdd:()=>aZ0,multiplyScalar:()=>nZ0,multiply:()=>UC,mul:()=>sZ0,invert:()=>fZ0,identity:()=>EZ0,fromValues:()=>CZ0,fromScaling:()=>gZ0,fromRotation:()=>yZ0,frob:()=>mZ0,exactEquals:()=>dZ0,equals:()=>iZ0,determinant:()=>bZ0,create:()=>TZ0,copy:()=>_Z0,clone:()=>DZ0,adjoint:()=>hZ0,add:()=>uZ0,LDU:()=>lZ0});function TZ0(){var J=new F0(4);if(F0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function DZ0(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function _Z0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function EZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function CZ0(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function SZ0(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function IZ0(J,Z){if(J===Z){var Y=Z[1];J[1]=Z[2],J[2]=Y}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function fZ0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*$-K*X;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-X*Q,J[2]=-K*Q,J[3]=Y*Q,J}function hZ0(J,Z){var Y=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=Y,J}function bZ0(J){return J[0]*J[3]-J[2]*J[1]}function UC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*F+$*G,J[1]=K*F+Q*G,J[2]=X*W+$*V,J[3]=K*W+Q*V,J}function pZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+$*F,J[1]=K*G+Q*F,J[2]=X*-F+$*G,J[3]=K*-F+Q*G,J}function AZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1];return J[0]=X*F,J[1]=K*F,J[2]=$*G,J[3]=Q*G,J}function yZ0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=-Y,J[3]=X,J}function gZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function cZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function mZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function lZ0(J,Z,Y,X){return J[2]=X[2]/X[0],Y[0]=X[0],Y[1]=X[1],Y[3]=X[3]-J[2]*Y[1],[J,Z,Y]}function uZ0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function OC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J}function dZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function iZ0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}function nZ0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function aZ0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J}var sZ0=UC,oZ0=OC;var h0={};o6(h0,{transpose:()=>XY0,translate:()=>FY0,subtract:()=>wC,sub:()=>kY0,str:()=>MY0,set:()=>ZY0,scale:()=>WY0,rotate:()=>GY0,projection:()=>OY0,normalFromMat4:()=>UY0,multiplyScalarAndAdd:()=>PY0,multiplyScalar:()=>NY0,multiply:()=>MC,mul:()=>jY0,invert:()=>KY0,identity:()=>YY0,fromValues:()=>JY0,fromTranslation:()=>VY0,fromScaling:()=>HY0,fromRotation:()=>qY0,fromQuat:()=>LY0,fromMat4:()=>rZ0,fromMat2d:()=>zY0,frob:()=>wY0,exactEquals:()=>BY0,equals:()=>vY0,determinant:()=>QY0,create:()=>Vq,copy:()=>eZ0,clone:()=>tZ0,adjoint:()=>$Y0,add:()=>RY0});function Vq(){var J=new F0(9);if(F0!=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 rZ0(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 tZ0(J){var Z=new F0(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 eZ0(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 JY0(J,Z,Y,X,K,$,Q,F,G){var W=new F0(9);return W[0]=J,W[1]=Z,W[2]=Y,W[3]=X,W[4]=K,W[5]=$,W[6]=Q,W[7]=F,W[8]=G,W}function ZY0(J,Z,Y,X,K,$,Q,F,G,W){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J}function YY0(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 XY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=Y,J[5]=Z[7],J[6]=X,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 KY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=V*Q-F*W,H=-V*$+F*G,U=W*$-Q*G,O=Y*q+X*H+K*U;if(!O)return null;return O=1/O,J[0]=q*O,J[1]=(-V*X+K*W)*O,J[2]=(F*X-K*Q)*O,J[3]=H*O,J[4]=(V*Y-K*G)*O,J[5]=(-F*Y+K*$)*O,J[6]=U*O,J[7]=(-W*Y+X*G)*O,J[8]=(Q*Y-X*$)*O,J}function $Y0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8];return J[0]=Q*V-F*W,J[1]=K*W-X*V,J[2]=X*F-K*Q,J[3]=F*G-$*V,J[4]=Y*V-K*G,J[5]=K*$-Y*F,J[6]=$*W-Q*G,J[7]=X*G-Y*W,J[8]=Y*Q-X*$,J}function QY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8];return Z*(W*$-Q*G)+Y*(-W*K+Q*F)+X*(G*K-$*F)}function MC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Y[0],U=Y[1],O=Y[2],M=Y[3],L=Y[4],R=Y[5],P=Y[6],B=Y[7],v=Y[8];return J[0]=H*X+U*Q+O*W,J[1]=H*K+U*F+O*V,J[2]=H*$+U*G+O*q,J[3]=M*X+L*Q+R*W,J[4]=M*K+L*F+R*V,J[5]=M*$+L*G+R*q,J[6]=P*X+B*Q+v*W,J[7]=P*K+B*F+v*V,J[8]=P*$+B*G+v*q,J}function FY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Y[0],U=Y[1];return J[0]=X,J[1]=K,J[2]=$,J[3]=Q,J[4]=F,J[5]=G,J[6]=H*X+U*Q+W,J[7]=H*K+U*F+V,J[8]=H*$+U*G+q,J}function GY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Math.sin(Y),U=Math.cos(Y);return J[0]=U*X+H*Q,J[1]=U*K+H*F,J[2]=U*$+H*G,J[3]=U*Q-H*X,J[4]=U*F-H*K,J[5]=U*G-H*$,J[6]=W,J[7]=V,J[8]=q,J}function WY0(J,Z,Y){var X=Y[0],K=Y[1];return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*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 VY0(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 qY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=-Y,J[4]=X,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function HY0(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 zY0(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 LY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,H=K*Q,U=K*F,O=K*G,M=$*Q,L=$*F,R=$*G;return J[0]=1-q-O,J[3]=V-R,J[6]=H+L,J[1]=V+R,J[4]=1-W-O,J[7]=U-M,J[2]=H-L,J[5]=U+M,J[8]=1-W-q,J}function UY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15],P=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,_=V*M-q*O,E=V*L-H*O,C=V*R-U*O,S=q*L-H*M,f=q*R-U*M,p=H*R-U*L,I=P*p-B*f+v*S+k*C-w*E+x*_;if(!I)return null;return I=1/I,J[0]=(F*p-G*f+W*S)*I,J[1]=(G*C-Q*p-W*E)*I,J[2]=(Q*f-F*C+W*_)*I,J[3]=(K*f-X*p-$*S)*I,J[4]=(Y*p-K*C+$*E)*I,J[5]=(X*C-Y*f-$*_)*I,J[6]=(M*x-L*w+R*k)*I,J[7]=(L*v-O*x-R*B)*I,J[8]=(O*w-M*v+R*P)*I,J}function OY0(J,Z,Y){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/Y,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function MY0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function wY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function RY0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J}function wC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J}function NY0(J,Z,Y){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]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J}function PY0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J}function BY0(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 vY0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=Z[0],H=Z[1],U=Z[2],O=Z[3],M=Z[4],L=Z[5],R=Z[6],P=Z[7],B=Z[8];return Math.abs(Y-q)<=l*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs(X-H)<=l*Math.max(1,Math.abs(X),Math.abs(H))&&Math.abs(K-U)<=l*Math.max(1,Math.abs(K),Math.abs(U))&&Math.abs($-O)<=l*Math.max(1,Math.abs($),Math.abs(O))&&Math.abs(Q-M)<=l*Math.max(1,Math.abs(Q),Math.abs(M))&&Math.abs(F-L)<=l*Math.max(1,Math.abs(F),Math.abs(L))&&Math.abs(G-R)<=l*Math.max(1,Math.abs(G),Math.abs(R))&&Math.abs(W-P)<=l*Math.max(1,Math.abs(W),Math.abs(P))&&Math.abs(V-B)<=l*Math.max(1,Math.abs(V),Math.abs(B))}var jY0=MC,kY0=wC;var Y0={};o6(Y0,{transpose:()=>CY0,translate:()=>hY0,targetTo:()=>QX0,subtract:()=>kC,sub:()=>UX0,str:()=>FX0,set:()=>EY0,scale:()=>bY0,rotateZ:()=>gY0,rotateY:()=>yY0,rotateX:()=>AY0,rotate:()=>pY0,perspectiveZO:()=>ZX0,perspectiveNO:()=>vC,perspectiveFromFieldOfView:()=>YX0,perspective:()=>JX0,orthoZO:()=>KX0,orthoNO:()=>jC,ortho:()=>XX0,multiplyScalarAndAdd:()=>qX0,multiplyScalar:()=>VX0,multiply:()=>NC,mul:()=>LX0,lookAt:()=>$X0,invert:()=>SY0,identity:()=>RC,getTranslation:()=>aY0,getScaling:()=>BC,getRotation:()=>sY0,frustum:()=>eY0,fromZRotation:()=>iY0,fromYRotation:()=>dY0,fromXRotation:()=>uY0,fromValues:()=>_Y0,fromTranslation:()=>cY0,fromScaling:()=>mY0,fromRotationTranslationScaleOrigin:()=>rY0,fromRotationTranslationScale:()=>oY0,fromRotationTranslation:()=>PC,fromRotation:()=>lY0,fromQuat2:()=>nY0,fromQuat:()=>tY0,frob:()=>GX0,exactEquals:()=>HX0,equals:()=>zX0,determinant:()=>fY0,create:()=>xY0,copy:()=>DY0,clone:()=>TY0,adjoint:()=>IY0,add:()=>WX0});function xY0(){var J=new F0(16);if(F0!=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 TY0(J){var Z=new F0(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 DY0(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 _Y0(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M){var L=new F0(16);return L[0]=J,L[1]=Z,L[2]=Y,L[3]=X,L[4]=K,L[5]=$,L[6]=Q,L[7]=F,L[8]=G,L[9]=W,L[10]=V,L[11]=q,L[12]=H,L[13]=U,L[14]=O,L[15]=M,L}function EY0(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M,L){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J[9]=V,J[10]=q,J[11]=H,J[12]=U,J[13]=O,J[14]=M,J[15]=L,J}function RC(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 CY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[3],$=Z[6],Q=Z[7],F=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Y,J[6]=Z[9],J[7]=Z[13],J[8]=X,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=F}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 SY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15],P=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,_=V*M-q*O,E=V*L-H*O,C=V*R-U*O,S=q*L-H*M,f=q*R-U*M,p=H*R-U*L,I=P*p-B*f+v*S+k*C-w*E+x*_;if(!I)return null;return I=1/I,J[0]=(F*p-G*f+W*S)*I,J[1]=(K*f-X*p-$*S)*I,J[2]=(M*x-L*w+R*k)*I,J[3]=(H*w-q*x-U*k)*I,J[4]=(G*C-Q*p-W*E)*I,J[5]=(Y*p-K*C+$*E)*I,J[6]=(L*v-O*x-R*B)*I,J[7]=(V*x-H*v+U*B)*I,J[8]=(Q*f-F*C+W*_)*I,J[9]=(X*C-Y*f-$*_)*I,J[10]=(O*w-M*v+R*P)*I,J[11]=(q*v-V*w-U*P)*I,J[12]=(F*E-Q*S-G*_)*I,J[13]=(Y*S-X*E+K*_)*I,J[14]=(M*B-O*k-L*P)*I,J[15]=(V*k-q*B+H*P)*I,J}function IY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15];return J[0]=F*(H*R-U*L)-q*(G*R-W*L)+M*(G*U-W*H),J[1]=-(X*(H*R-U*L)-q*(K*R-$*L)+M*(K*U-$*H)),J[2]=X*(G*R-W*L)-F*(K*R-$*L)+M*(K*W-$*G),J[3]=-(X*(G*U-W*H)-F*(K*U-$*H)+q*(K*W-$*G)),J[4]=-(Q*(H*R-U*L)-V*(G*R-W*L)+O*(G*U-W*H)),J[5]=Y*(H*R-U*L)-V*(K*R-$*L)+O*(K*U-$*H),J[6]=-(Y*(G*R-W*L)-Q*(K*R-$*L)+O*(K*W-$*G)),J[7]=Y*(G*U-W*H)-Q*(K*U-$*H)+V*(K*W-$*G),J[8]=Q*(q*R-U*M)-V*(F*R-W*M)+O*(F*U-W*q),J[9]=-(Y*(q*R-U*M)-V*(X*R-$*M)+O*(X*U-$*q)),J[10]=Y*(F*R-W*M)-Q*(X*R-$*M)+O*(X*W-$*F),J[11]=-(Y*(F*U-W*q)-Q*(X*U-$*q)+V*(X*W-$*F)),J[12]=-(Q*(q*L-H*M)-V*(F*L-G*M)+O*(F*H-G*q)),J[13]=Y*(q*L-H*M)-V*(X*L-K*M)+O*(X*H-K*q),J[14]=-(Y*(F*L-G*M)-Q*(X*L-K*M)+O*(X*G-K*F)),J[15]=Y*(F*H-G*q)-Q*(X*H-K*q)+V*(X*G-K*F),J}function fY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8],V=J[9],q=J[10],H=J[11],U=J[12],O=J[13],M=J[14],L=J[15],R=Z*Q-Y*$,P=Z*F-X*$,B=Z*G-K*$,v=Y*F-X*Q,k=Y*G-K*Q,w=X*G-K*F,x=W*O-V*U,_=W*M-q*U,E=W*L-H*U,C=V*M-q*O,S=V*L-H*O,f=q*L-H*M;return R*f-P*S+B*C+v*E-k*_+w*x}function NC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Z[9],U=Z[10],O=Z[11],M=Z[12],L=Z[13],R=Z[14],P=Z[15],B=Y[0],v=Y[1],k=Y[2],w=Y[3];return J[0]=B*X+v*F+k*q+w*M,J[1]=B*K+v*G+k*H+w*L,J[2]=B*$+v*W+k*U+w*R,J[3]=B*Q+v*V+k*O+w*P,B=Y[4],v=Y[5],k=Y[6],w=Y[7],J[4]=B*X+v*F+k*q+w*M,J[5]=B*K+v*G+k*H+w*L,J[6]=B*$+v*W+k*U+w*R,J[7]=B*Q+v*V+k*O+w*P,B=Y[8],v=Y[9],k=Y[10],w=Y[11],J[8]=B*X+v*F+k*q+w*M,J[9]=B*K+v*G+k*H+w*L,J[10]=B*$+v*W+k*U+w*R,J[11]=B*Q+v*V+k*O+w*P,B=Y[12],v=Y[13],k=Y[14],w=Y[15],J[12]=B*X+v*F+k*q+w*M,J[13]=B*K+v*G+k*H+w*L,J[14]=B*$+v*W+k*U+w*R,J[15]=B*Q+v*V+k*O+w*P,J}function hY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q,F,G,W,V,q,H,U,O,M,L,R;if(Z===J)J[12]=Z[0]*X+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*X+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*X+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*X+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],F=Z[1],G=Z[2],W=Z[3],V=Z[4],q=Z[5],H=Z[6],U=Z[7],O=Z[8],M=Z[9],L=Z[10],R=Z[11],J[0]=Q,J[1]=F,J[2]=G,J[3]=W,J[4]=V,J[5]=q,J[6]=H,J[7]=U,J[8]=O,J[9]=M,J[10]=L,J[11]=R,J[12]=Q*X+V*K+O*$+Z[12],J[13]=F*X+q*K+M*$+Z[13],J[14]=G*X+H*K+L*$+Z[14],J[15]=W*X+U*K+R*$+Z[15];return J}function bY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2];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]*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 pY0(J,Z,Y,X){var K=X[0],$=X[1],Q=X[2],F=Math.hypot(K,$,Q),G,W,V,q,H,U,O,M,L,R,P,B,v,k,w,x,_,E,C,S,f,p,I,g;if(F<l)return null;if(F=1/F,K*=F,$*=F,Q*=F,G=Math.sin(Y),W=Math.cos(Y),V=1-W,q=Z[0],H=Z[1],U=Z[2],O=Z[3],M=Z[4],L=Z[5],R=Z[6],P=Z[7],B=Z[8],v=Z[9],k=Z[10],w=Z[11],x=K*K*V+W,_=$*K*V+Q*G,E=Q*K*V-$*G,C=K*$*V-Q*G,S=$*$*V+W,f=Q*$*V+K*G,p=K*Q*V+$*G,I=$*Q*V-K*G,g=Q*Q*V+W,J[0]=q*x+M*_+B*E,J[1]=H*x+L*_+v*E,J[2]=U*x+R*_+k*E,J[3]=O*x+P*_+w*E,J[4]=q*C+M*S+B*f,J[5]=H*C+L*S+v*f,J[6]=U*C+R*S+k*f,J[7]=O*C+P*S+w*f,J[8]=q*p+M*I+B*g,J[9]=H*p+L*I+v*g,J[10]=U*p+R*I+k*g,J[11]=O*p+P*I+w*g,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function AY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[4],Q=Z[5],F=Z[6],G=Z[7],W=Z[8],V=Z[9],q=Z[10],H=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*X,J[5]=Q*K+V*X,J[6]=F*K+q*X,J[7]=G*K+H*X,J[8]=W*K-$*X,J[9]=V*K-Q*X,J[10]=q*K-F*X,J[11]=H*K-G*X,J}function yY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[8],V=Z[9],q=Z[10],H=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*X,J[1]=Q*K-V*X,J[2]=F*K-q*X,J[3]=G*K-H*X,J[8]=$*X+W*K,J[9]=Q*X+V*K,J[10]=F*X+q*K,J[11]=G*X+H*K,J}function gY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[4],V=Z[5],q=Z[6],H=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*X,J[1]=Q*K+V*X,J[2]=F*K+q*X,J[3]=G*K+H*X,J[4]=W*K-$*X,J[5]=V*K-Q*X,J[6]=q*K-F*X,J[7]=H*K-G*X,J}function cY0(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 mY0(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 lY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Math.hypot(X,K,$),F,G,W;if(Q<l)return null;return Q=1/Q,X*=Q,K*=Q,$*=Q,F=Math.sin(Z),G=Math.cos(Z),W=1-G,J[0]=X*X*W+G,J[1]=K*X*W+$*F,J[2]=$*X*W-K*F,J[3]=0,J[4]=X*K*W-$*F,J[5]=K*K*W+G,J[6]=$*K*W+X*F,J[7]=0,J[8]=X*$*W+K*F,J[9]=K*$*W-X*F,J[10]=$*$*W+G,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function uY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=X,J[6]=Y,J[7]=0,J[8]=0,J[9]=-Y,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function dY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=0,J[2]=-Y,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=Y,J[9]=0,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=0,J[4]=-Y,J[5]=X,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 PC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=X+X,G=K+K,W=$+$,V=X*F,q=X*G,H=X*W,U=K*G,O=K*W,M=$*W,L=Q*F,R=Q*G,P=Q*W;return J[0]=1-(U+M),J[1]=q+P,J[2]=H-R,J[3]=0,J[4]=q-P,J[5]=1-(V+M),J[6]=O+L,J[7]=0,J[8]=H+R,J[9]=O-L,J[10]=1-(V+U),J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function nY0(J,Z){var Y=new F0(3),X=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=X*X+K*K+$*$+Q*Q;if(q>0)Y[0]=(F*Q+V*X+G*$-W*K)*2/q,Y[1]=(G*Q+V*K+W*X-F*$)*2/q,Y[2]=(W*Q+V*$+F*K-G*X)*2/q;else Y[0]=(F*Q+V*X+G*$-W*K)*2,Y[1]=(G*Q+V*K+W*X-F*$)*2,Y[2]=(W*Q+V*$+F*K-G*X)*2;return PC(J,Z,Y),J}function aY0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function BC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[4],Q=Z[5],F=Z[6],G=Z[8],W=Z[9],V=Z[10];return J[0]=Math.hypot(Y,X,K),J[1]=Math.hypot($,Q,F),J[2]=Math.hypot(G,W,V),J}function sY0(J,Z){var Y=new F0(3);BC(Y,Z);var X=1/Y[0],K=1/Y[1],$=1/Y[2],Q=Z[0]*X,F=Z[1]*K,G=Z[2]*$,W=Z[4]*X,V=Z[5]*K,q=Z[6]*$,H=Z[8]*X,U=Z[9]*K,O=Z[10]*$,M=Q+V+O,L=0;if(M>0)L=Math.sqrt(M+1)*2,J[3]=0.25*L,J[0]=(q-U)/L,J[1]=(H-G)/L,J[2]=(F-W)/L;else if(Q>V&&Q>O)L=Math.sqrt(1+Q-V-O)*2,J[3]=(q-U)/L,J[0]=0.25*L,J[1]=(F+W)/L,J[2]=(H+G)/L;else if(V>O)L=Math.sqrt(1+V-Q-O)*2,J[3]=(H-G)/L,J[0]=(F+W)/L,J[1]=0.25*L,J[2]=(q+U)/L;else L=Math.sqrt(1+O-Q-V)*2,J[3]=(F-W)/L,J[0]=(H+G)/L,J[1]=(q+U)/L,J[2]=0.25*L;return J}function oY0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=K+K,W=$+$,V=Q+Q,q=K*G,H=K*W,U=K*V,O=$*W,M=$*V,L=Q*V,R=F*G,P=F*W,B=F*V,v=X[0],k=X[1],w=X[2];return J[0]=(1-(O+L))*v,J[1]=(H+B)*v,J[2]=(U-P)*v,J[3]=0,J[4]=(H-B)*k,J[5]=(1-(q+L))*k,J[6]=(M+R)*k,J[7]=0,J[8]=(U+P)*w,J[9]=(M-R)*w,J[10]=(1-(q+O))*w,J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function rY0(J,Z,Y,X,K){var $=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=$+$,V=Q+Q,q=F+F,H=$*W,U=$*V,O=$*q,M=Q*V,L=Q*q,R=F*q,P=G*W,B=G*V,v=G*q,k=X[0],w=X[1],x=X[2],_=K[0],E=K[1],C=K[2],S=(1-(M+R))*k,f=(U+v)*k,p=(O-B)*k,I=(U-v)*w,g=(1-(H+R))*w,J0=(L+P)*w,y0=(O+B)*x,a0=(L-P)*x,G6=(1-(H+M))*x;return J[0]=S,J[1]=f,J[2]=p,J[3]=0,J[4]=I,J[5]=g,J[6]=J0,J[7]=0,J[8]=y0,J[9]=a0,J[10]=G6,J[11]=0,J[12]=Y[0]+_-(S*_+I*E+y0*C),J[13]=Y[1]+E-(f*_+g*E+a0*C),J[14]=Y[2]+C-(p*_+J0*E+G6*C),J[15]=1,J}function tY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,H=K*Q,U=K*F,O=K*G,M=$*Q,L=$*F,R=$*G;return J[0]=1-q-O,J[1]=V+R,J[2]=H-L,J[3]=0,J[4]=V-R,J[5]=1-W-O,J[6]=U+M,J[7]=0,J[8]=H+L,J[9]=U-M,J[10]=1-W-q,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function eY0(J,Z,Y,X,K,$,Q){var F=1/(Y-Z),G=1/(K-X),W=1/($-Q);return J[0]=$*2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*G,J[6]=0,J[7]=0,J[8]=(Y+Z)*F,J[9]=(K+X)*G,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function vC(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,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/(X-K),J[10]=(K+X)*Q,J[14]=2*K*X*Q;else J[10]=-1,J[14]=-2*X;return J}var JX0=vC;function ZX0(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,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/(X-K),J[10]=K*Q,J[14]=K*X*Q;else J[10]=-1,J[14]=-X;return J}function YX0(J,Z,Y,X){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),F=Math.tan(Z.rightDegrees*Math.PI/180),G=2/(Q+F),W=2/(K+$);return J[0]=G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-F)*G*0.5),J[9]=(K-$)*W*0.5,J[10]=X/(Y-X),J[11]=-1,J[12]=0,J[13]=0,J[14]=X*Y/(Y-X),J[15]=0,J}function jC(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=(Q+$)*W,J[15]=1,J}var XX0=jC;function KX0(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=$*W,J[15]=1,J}function $X0(J,Z,Y,X){var K,$,Q,F,G,W,V,q,H,U,O=Z[0],M=Z[1],L=Z[2],R=X[0],P=X[1],B=X[2],v=Y[0],k=Y[1],w=Y[2];if(Math.abs(O-v)<l&&Math.abs(M-k)<l&&Math.abs(L-w)<l)return RC(J);if(V=O-v,q=M-k,H=L-w,U=1/Math.hypot(V,q,H),V*=U,q*=U,H*=U,K=P*H-B*q,$=B*V-R*H,Q=R*q-P*V,U=Math.hypot(K,$,Q),!U)K=0,$=0,Q=0;else U=1/U,K*=U,$*=U,Q*=U;if(F=q*Q-H*$,G=H*K-V*Q,W=V*$-q*K,U=Math.hypot(F,G,W),!U)F=0,G=0,W=0;else U=1/U,F*=U,G*=U,W*=U;return J[0]=K,J[1]=F,J[2]=V,J[3]=0,J[4]=$,J[5]=G,J[6]=q,J[7]=0,J[8]=Q,J[9]=W,J[10]=H,J[11]=0,J[12]=-(K*O+$*M+Q*L),J[13]=-(F*O+G*M+W*L),J[14]=-(V*O+q*M+H*L),J[15]=1,J}function QX0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=X[0],G=X[1],W=X[2],V=K-Y[0],q=$-Y[1],H=Q-Y[2],U=V*V+q*q+H*H;if(U>0)U=1/Math.sqrt(U),V*=U,q*=U,H*=U;var O=G*H-W*q,M=W*V-F*H,L=F*q-G*V;if(U=O*O+M*M+L*L,U>0)U=1/Math.sqrt(U),O*=U,M*=U,L*=U;return J[0]=O,J[1]=M,J[2]=L,J[3]=0,J[4]=q*L-H*M,J[5]=H*O-V*L,J[6]=V*M-q*O,J[7]=0,J[8]=V,J[9]=q,J[10]=H,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function FX0(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 GX0(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 WX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J[9]=Z[9]+Y[9],J[10]=Z[10]+Y[10],J[11]=Z[11]+Y[11],J[12]=Z[12]+Y[12],J[13]=Z[13]+Y[13],J[14]=Z[14]+Y[14],J[15]=Z[15]+Y[15],J}function kC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J[9]=Z[9]-Y[9],J[10]=Z[10]-Y[10],J[11]=Z[11]-Y[11],J[12]=Z[12]-Y[12],J[13]=Z[13]-Y[13],J[14]=Z[14]-Y[14],J[15]=Z[15]-Y[15],J}function VX0(J,Z,Y){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]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J[9]=Z[9]*Y,J[10]=Z[10]*Y,J[11]=Z[11]*Y,J[12]=Z[12]*Y,J[13]=Z[13]*Y,J[14]=Z[14]*Y,J[15]=Z[15]*Y,J}function qX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J[9]=Z[9]+Y[9]*X,J[10]=Z[10]+Y[10]*X,J[11]=Z[11]+Y[11]*X,J[12]=Z[12]+Y[12]*X,J[13]=Z[13]+Y[13]*X,J[14]=Z[14]+Y[14]*X,J[15]=Z[15]+Y[15]*X,J}function HX0(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 zX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=J[9],H=J[10],U=J[11],O=J[12],M=J[13],L=J[14],R=J[15],P=Z[0],B=Z[1],v=Z[2],k=Z[3],w=Z[4],x=Z[5],_=Z[6],E=Z[7],C=Z[8],S=Z[9],f=Z[10],p=Z[11],I=Z[12],g=Z[13],J0=Z[14],y0=Z[15];return Math.abs(Y-P)<=l*Math.max(1,Math.abs(Y),Math.abs(P))&&Math.abs(X-B)<=l*Math.max(1,Math.abs(X),Math.abs(B))&&Math.abs(K-v)<=l*Math.max(1,Math.abs(K),Math.abs(v))&&Math.abs($-k)<=l*Math.max(1,Math.abs($),Math.abs(k))&&Math.abs(Q-w)<=l*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(F-x)<=l*Math.max(1,Math.abs(F),Math.abs(x))&&Math.abs(G-_)<=l*Math.max(1,Math.abs(G),Math.abs(_))&&Math.abs(W-E)<=l*Math.max(1,Math.abs(W),Math.abs(E))&&Math.abs(V-C)<=l*Math.max(1,Math.abs(V),Math.abs(C))&&Math.abs(q-S)<=l*Math.max(1,Math.abs(q),Math.abs(S))&&Math.abs(H-f)<=l*Math.max(1,Math.abs(H),Math.abs(f))&&Math.abs(U-p)<=l*Math.max(1,Math.abs(U),Math.abs(p))&&Math.abs(O-I)<=l*Math.max(1,Math.abs(O),Math.abs(I))&&Math.abs(M-g)<=l*Math.max(1,Math.abs(M),Math.abs(g))&&Math.abs(L-J0)<=l*Math.max(1,Math.abs(L),Math.abs(J0))&&Math.abs(R-y0)<=l*Math.max(1,Math.abs(R),Math.abs(y0))}var LX0=NC,UX0=kC;var v0={};o6(v0,{str:()=>qK0,squaredLength:()=>JS,sqrLen:()=>NK0,sqlerp:()=>jK0,slerp:()=>L$,setAxisAngle:()=>iC,setAxes:()=>kK0,set:()=>UK0,scale:()=>rC,rotationTo:()=>vK0,rotateZ:()=>KK0,rotateY:()=>XK0,rotateX:()=>YK0,random:()=>FK0,pow:()=>QK0,normalize:()=>Lq,multiply:()=>nC,mul:()=>MK0,ln:()=>sC,lerp:()=>wK0,length:()=>eC,len:()=>RK0,invert:()=>GK0,identity:()=>eX0,getAxisAngle:()=>JK0,getAngle:()=>ZK0,fromValues:()=>zK0,fromMat3:()=>oC,fromEuler:()=>VK0,exp:()=>aC,exactEquals:()=>PK0,equals:()=>BK0,dot:()=>tC,create:()=>zq,copy:()=>LK0,conjugate:()=>WK0,clone:()=>HK0,calculateW:()=>$K0,add:()=>OK0});var $0={};o6($0,{zero:()=>gX0,transformQuat:()=>hX0,transformMat4:()=>IX0,transformMat3:()=>fX0,subtract:()=>TC,sub:()=>uX0,str:()=>cX0,squaredLength:()=>SC,squaredDistance:()=>CC,sqrLen:()=>sX0,sqrDist:()=>aX0,set:()=>wX0,scaleAndAdd:()=>xX0,scale:()=>kX0,round:()=>jX0,rotateZ:()=>AX0,rotateY:()=>pX0,rotateX:()=>bX0,random:()=>SX0,normalize:()=>qq,negate:()=>TX0,multiply:()=>DC,mul:()=>dX0,min:()=>BX0,max:()=>vX0,lerp:()=>_X0,length:()=>xC,len:()=>Hq,inverse:()=>DX0,hermite:()=>EX0,fromValues:()=>H$,forEach:()=>oX0,floor:()=>PX0,exactEquals:()=>mX0,equals:()=>lX0,dot:()=>z$,divide:()=>_C,div:()=>iX0,distance:()=>EC,dist:()=>nX0,cross:()=>AJ,create:()=>q$,copy:()=>MX0,clone:()=>OX0,ceil:()=>NX0,bezier:()=>CX0,angle:()=>yX0,add:()=>RX0});function q$(){var J=new F0(3);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function OX0(J){var Z=new F0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function xC(J){var Z=J[0],Y=J[1],X=J[2];return Math.hypot(Z,Y,X)}function H$(J,Z,Y){var X=new F0(3);return X[0]=J,X[1]=Z,X[2]=Y,X}function MX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function wX0(J,Z,Y,X){return J[0]=Z,J[1]=Y,J[2]=X,J}function RX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J}function TC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J}function DC(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J[2]=Z[2]*Y[2],J}function _C(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J[2]=Z[2]/Y[2],J}function NX0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function PX0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function BX0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J[2]=Math.min(Z[2],Y[2]),J}function vX0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J[2]=Math.max(Z[2],Y[2]),J}function jX0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J}function xX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J}function EC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(Y,X,K)}function CC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Y*Y+X*X+K*K}function SC(J){var Z=J[0],Y=J[1],X=J[2];return Z*Z+Y*Y+X*X}function TX0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function DX0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function qq(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Y*Y+X*X+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function z$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function AJ(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[0],F=Y[1],G=Y[2];return J[0]=K*G-$*F,J[1]=$*Q-X*G,J[2]=X*F-K*Q,J}function _X0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J}function EX0(J,Z,Y,X,K,$){var Q=$*$,F=Q*(2*$-3)+1,G=Q*($-2)+$,W=Q*($-1),V=Q*(3-2*$);return J[0]=Z[0]*F+Y[0]*G+X[0]*W+K[0]*V,J[1]=Z[1]*F+Y[1]*G+X[1]*W+K[1]*V,J[2]=Z[2]*F+Y[2]*G+X[2]*W+K[2]*V,J}function CX0(J,Z,Y,X,K,$){var Q=1-$,F=Q*Q,G=$*$,W=F*Q,V=3*$*F,q=3*G*Q,H=G*$;return J[0]=Z[0]*W+Y[0]*V+X[0]*q+K[0]*H,J[1]=Z[1]*W+Y[1]*V+X[1]*q+K[1]*H,J[2]=Z[2]*W+Y[2]*V+X[2]*q+K[2]*H,J}function SX0(J,Z){Z=Z||1;var Y=i6()*2*Math.PI,X=i6()*2-1,K=Math.sqrt(1-X*X)*Z;return J[0]=Math.cos(Y)*K,J[1]=Math.sin(Y)*K,J[2]=X*Z,J}function IX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[3]*X+Y[7]*K+Y[11]*$+Y[15];return Q=Q||1,J[0]=(Y[0]*X+Y[4]*K+Y[8]*$+Y[12])/Q,J[1]=(Y[1]*X+Y[5]*K+Y[9]*$+Y[13])/Q,J[2]=(Y[2]*X+Y[6]*K+Y[10]*$+Y[14])/Q,J}function fX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2];return J[0]=X*Y[0]+K*Y[3]+$*Y[6],J[1]=X*Y[1]+K*Y[4]+$*Y[7],J[2]=X*Y[2]+K*Y[5]+$*Y[8],J}function hX0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Y[3],F=Z[0],G=Z[1],W=Z[2],V=K*W-$*G,q=$*F-X*W,H=X*G-K*F,U=K*H-$*q,O=$*V-X*H,M=X*q-K*V,L=Q*2;return V*=L,q*=L,H*=L,U*=2,O*=2,M*=2,J[0]=F+V+U,J[1]=G+q+O,J[2]=W+H+M,J}function bX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0],$[1]=K[1]*Math.cos(X)-K[2]*Math.sin(X),$[2]=K[1]*Math.sin(X)+K[2]*Math.cos(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function pX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[2]*Math.sin(X)+K[0]*Math.cos(X),$[1]=K[1],$[2]=K[2]*Math.cos(X)-K[0]*Math.sin(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function AX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0]*Math.cos(X)-K[1]*Math.sin(X),$[1]=K[0]*Math.sin(X)+K[1]*Math.cos(X),$[2]=K[2],J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function yX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2],G=Math.sqrt(Y*Y+X*X+K*K),W=Math.sqrt($*$+Q*Q+F*F),V=G*W,q=V&&z$(J,Z)/V;return Math.acos(Math.min(Math.max(q,-1),1))}function gX0(J){return J[0]=0,J[1]=0,J[2]=0,J}function cX0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function mX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function lX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2];return Math.abs(Y-$)<=l*Math.max(1,Math.abs(Y),Math.abs($))&&Math.abs(X-Q)<=l*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(K-F)<=l*Math.max(1,Math.abs(K),Math.abs(F))}var uX0=TC,dX0=DC,iX0=_C,nX0=EC,aX0=CC,Hq=xC,sX0=SC,oX0=function(){var J=q$();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=3;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2];return Z}}();function rX0(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function IC(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function fC(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function hC(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function bC(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function pC(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function AC(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function yC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Math.hypot(Z,Y,X,K)}function gC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Z*Z+Y*Y+X*X+K*K}function cC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=Y*Q,J[1]=X*Q,J[2]=K*Q,J[3]=$*Q,J}function mC(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function lC(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J[3]=F+X*(Y[3]-F),J}function uC(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function dC(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}var XD0=function(){var J=rX0();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=4;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],J[3]=Z[F+3],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2],Z[F+3]=J[3];return Z}}();function zq(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function eX0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function iC(J,Z,Y){Y=Y*0.5;var X=Math.sin(Y);return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=Math.cos(Y),J}function JK0(J,Z){var Y=Math.acos(Z[3])*2,X=Math.sin(Y/2);if(X>l)J[0]=Z[0]/X,J[1]=Z[1]/X,J[2]=Z[2]/X;else J[0]=1,J[1]=0,J[2]=0;return Y}function ZK0(J,Z){var Y=tC(J,Z);return Math.acos(2*Y*Y-1)}function nC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*V+Q*F+K*W-$*G,J[1]=K*V+Q*G+$*F-X*W,J[2]=$*V+Q*W+X*G-K*F,J[3]=Q*V-X*F-K*G-$*W,J}function YK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+Q*F,J[1]=K*G+$*F,J[2]=$*G-K*F,J[3]=Q*G-X*F,J}function XK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G-$*F,J[1]=K*G+Q*F,J[2]=$*G+X*F,J[3]=Q*G-K*F,J}function KK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+K*F,J[1]=K*G-X*F,J[2]=$*G+Q*F,J[3]=Q*G-$*F,J}function $K0(J,Z){var Y=Z[0],X=Z[1],K=Z[2];return J[0]=Y,J[1]=X,J[2]=K,J[3]=Math.sqrt(Math.abs(1-Y*Y-X*X-K*K)),J}function aC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Math.exp($),G=Q>0?F*Math.sin(Q)/Q:0;return J[0]=Y*G,J[1]=X*G,J[2]=K*G,J[3]=F*Math.cos(Q),J}function sC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=Y*F,J[1]=X*F,J[2]=K*F,J[3]=0.5*Math.log(Y*Y+X*X+K*K+$*$),J}function QK0(J,Z,Y){return sC(J,Z),rC(J,J,Y),aC(J,J),J}function L$(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=Y[0],W=Y[1],V=Y[2],q=Y[3],H,U,O,M,L;if(U=K*G+$*W+Q*V+F*q,U<0)U=-U,G=-G,W=-W,V=-V,q=-q;if(1-U>l)H=Math.acos(U),O=Math.sin(H),M=Math.sin((1-X)*H)/O,L=Math.sin(X*H)/O;else M=1-X,L=X;return J[0]=M*K+L*G,J[1]=M*$+L*W,J[2]=M*Q+L*V,J[3]=M*F+L*q,J}function FK0(J){var Z=i6(),Y=i6(),X=i6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*Y),J[1]=K*Math.cos(2*Math.PI*Y),J[2]=$*Math.sin(2*Math.PI*X),J[3]=$*Math.cos(2*Math.PI*X),J}function GK0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$,F=Q?1/Q:0;return J[0]=-Y*F,J[1]=-X*F,J[2]=-K*F,J[3]=$*F,J}function WK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function oC(J,Z){var Y=Z[0]+Z[4]+Z[8],X;if(Y>0)X=Math.sqrt(Y+1),J[3]=0.5*X,X=0.5/X,J[0]=(Z[5]-Z[7])*X,J[1]=(Z[6]-Z[2])*X,J[2]=(Z[1]-Z[3])*X;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;X=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*X,X=0.5/X,J[3]=(Z[$*3+Q]-Z[Q*3+$])*X,J[$]=(Z[$*3+K]+Z[K*3+$])*X,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*X}return J}function VK0(J,Z,Y,X){var K=0.5*Math.PI/180;Z*=K,Y*=K,X*=K;var $=Math.sin(Z),Q=Math.cos(Z),F=Math.sin(Y),G=Math.cos(Y),W=Math.sin(X),V=Math.cos(X);return J[0]=$*G*V-Q*F*W,J[1]=Q*F*V+$*G*W,J[2]=Q*G*W-$*F*V,J[3]=Q*G*V+$*F*W,J}function qK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var HK0=IC,zK0=fC,LK0=hC,UK0=bC,OK0=pC,MK0=nC,rC=AC,tC=mC,wK0=lC,eC=yC,RK0=eC,JS=gC,NK0=JS,Lq=cC,PK0=uC,BK0=dC,vK0=function(){var J=q$(),Z=H$(1,0,0),Y=H$(0,1,0);return function(X,K,$){var Q=z$(K,$);if(Q<-0.999999){if(AJ(J,Z,K),Hq(J)<0.000001)AJ(J,Y,K);return qq(J,J),iC(X,J,Math.PI),X}else if(Q>0.999999)return X[0]=0,X[1]=0,X[2]=0,X[3]=1,X;else return AJ(J,K,$),X[0]=J[0],X[1]=J[1],X[2]=J[2],X[3]=1+Q,Lq(X,X)}}(),jK0=function(){var J=zq(),Z=zq();return function(Y,X,K,$,Q,F){return L$(J,X,Q,F),L$(Z,K,$,F),L$(Y,J,Z,2*F*(1-F)),Y}}(),kK0=function(){var J=Vq();return function(Z,Y,X,K){return J[0]=X[0],J[3]=X[1],J[6]=X[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-Y[0],J[5]=-Y[1],J[8]=-Y[2],Lq(Z,oC(Z,J))}}();var q0={};o6(q0,{zero:()=>rK0,transformMat4:()=>aK0,transformMat3:()=>nK0,transformMat2d:()=>iK0,transformMat2:()=>dK0,subtract:()=>YS,sub:()=>Y$0,str:()=>tK0,squaredLength:()=>GS,squaredDistance:()=>QS,sqrLen:()=>F$0,sqrDist:()=>Q$0,set:()=>_K0,scaleAndAdd:()=>pK0,scale:()=>bK0,round:()=>hK0,rotate:()=>sK0,random:()=>uK0,normalize:()=>gK0,negate:()=>AK0,multiply:()=>XS,mul:()=>X$0,min:()=>IK0,max:()=>fK0,lerp:()=>lK0,length:()=>FS,len:()=>Z$0,inverse:()=>yK0,fromValues:()=>TK0,forEach:()=>G$0,floor:()=>SK0,exactEquals:()=>eK0,equals:()=>J$0,dot:()=>cK0,divide:()=>KS,div:()=>K$0,distance:()=>$S,dist:()=>$$0,cross:()=>mK0,create:()=>ZS,copy:()=>DK0,clone:()=>xK0,ceil:()=>CK0,angle:()=>oK0,add:()=>EK0});function ZS(){var J=new F0(2);if(F0!=Float32Array)J[0]=0,J[1]=0;return J}function xK0(J){var Z=new F0(2);return Z[0]=J[0],Z[1]=J[1],Z}function TK0(J,Z){var Y=new F0(2);return Y[0]=J,Y[1]=Z,Y}function DK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function _K0(J,Z,Y){return J[0]=Z,J[1]=Y,J}function EK0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J}function YS(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J}function XS(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J}function KS(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J}function CK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function SK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function IK0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J}function fK0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J}function hK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function bK0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J}function pK0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J}function $S(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Math.hypot(Y,X)}function QS(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Y*Y+X*X}function FS(J){var Z=J[0],Y=J[1];return Math.hypot(Z,Y)}function GS(J){var Z=J[0],Y=J[1];return Z*Z+Y*Y}function AK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function yK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function gK0(J,Z){var Y=Z[0],X=Z[1],K=Y*Y+X*X;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function cK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function mK0(J,Z,Y){var X=Z[0]*Y[1]-Z[1]*Y[0];return J[0]=J[1]=0,J[2]=X,J}function lK0(J,Z,Y,X){var K=Z[0],$=Z[1];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J}function uK0(J,Z){Z=Z||1;var Y=i6()*2*Math.PI;return J[0]=Math.cos(Y)*Z,J[1]=Math.sin(Y)*Z,J}function dK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K,J[1]=Y[1]*X+Y[3]*K,J}function iK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K+Y[4],J[1]=Y[1]*X+Y[3]*K+Y[5],J}function nK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[3]*K+Y[6],J[1]=Y[1]*X+Y[4]*K+Y[7],J}function aK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[4]*K+Y[12],J[1]=Y[1]*X+Y[5]*K+Y[13],J}function sK0(J,Z,Y,X){var K=Z[0]-Y[0],$=Z[1]-Y[1],Q=Math.sin(X),F=Math.cos(X);return J[0]=K*F-$*Q+Y[0],J[1]=K*Q+$*F+Y[1],J}function oK0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(Y*Y+X*X)*Math.sqrt(K*K+$*$),F=Q&&(Y*K+X*$)/Q;return Math.acos(Math.min(Math.max(F,-1),1))}function rK0(J){return J[0]=0,J[1]=0,J}function tK0(J){return"vec2("+J[0]+", "+J[1]+")"}function eK0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function J$0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1];return Math.abs(Y-K)<=l*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs(X-$)<=l*Math.max(1,Math.abs(X),Math.abs($))}var Z$0=FS,Y$0=YS,X$0=XS,K$0=KS,$$0=$S,Q$0=QS,F$0=GS,G$0=function(){var J=ZS();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=2;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1];return Z}}();class A9 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get determinant(){return J8.determinant(this)}get frobeniusNorm(){return J8.frob(this)}static create(){let J=new A9(0,0,0,0);return J8.identity(J),J}static fromRotation(J){let Z=A9.create();return J8.fromRotation(Z,J),Z}static fromScaling(J){let Z=A9.create();return J8.fromScaling(Z,J),Z}add(J){return J8.add(this,this,J),this}adjoint(){return J8.adjoint(this,this),this}clone(){return new A9(this[0],this[1],this[2],this[3])}copy(J){return J8.copy(this,J),this}equals(J){return J8.equals(this,J)}exactEquals(J){return J8.exactEquals(this,J)}identity(){return J8.identity(this),this}invert(){return J8.invert(this,this),this}multiply(J){return J8.mul(this,this,J),this}multiplyScalar(J){return J8.multiplyScalar(this,this,J),this}rotate(J){return J8.rotate(this,this,J),this}subtract(J){return J8.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return J8.transpose(this,this),this}}class n6 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G){super([J,Z,Y,X,K,$,Q,F,G])}get determinant(){return h0.determinant(this)}get frobeniusNorm(){return h0.frob(this)}static create(){let J=new n6(0,0,0,0,0,0,0,0,0);return h0.identity(J),J}static fromMatrix4(J){let Z=n6.create();return h0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=n6.create();return h0.fromQuat(Z,J),Z}static fromRotation(J){let Z=n6.create();return h0.fromRotation(Z,J),Z}static fromScaling(J){let Z=n6.create();return h0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=n6.create();return h0.fromTranslation(Z,J),Z}add(J){return h0.add(this,this,J),this}adjoint(){return h0.adjoint(this,this),this}clone(){return new n6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return h0.copy(this,J),this}equals(J){return h0.equals(this,J)}exactEquals(J){return h0.exactEquals(this,J)}identity(){return h0.identity(this),this}invert(){return h0.invert(this,this),this}multiply(J){return h0.mul(this,this,J),this}multiplyScalar(J){return h0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return h0.projection(this,J,Z),this}rotate(J){return h0.rotate(this,this,J),this}subtract(J){return h0.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 h0.transpose(this,this),this}}class C8 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M){super([J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M])}get determinant(){return Y0.determinant(this)}get frobeniusNorm(){return Y0.frob(this)}static create(){let J=new C8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return Y0.identity(J),J}static fromQuaternion(J){let Z=C8.create();return Y0.fromQuat(Z,J),Z}static fromRotation(J,Z){let Y=C8.create();return Y0.fromRotation(Y,J,Z),Y}static fromRotationTranslation(J,Z){let Y=C8.create();return Y0.fromRotationTranslation(Y,J,Z),Y}static fromRotationTranslationScale(J,Z,Y){let X=C8.create();return Y0.fromRotationTranslationScale(X,J,Z,Y),X}static fromRotationTranslationScaleOrigin(J,Z,Y,X){let K=C8.create();return Y0.fromRotationTranslationScaleOrigin(K,J,Z,Y,X),K}static fromScaling(J){let Z=C8.create();return Y0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=C8.create();return Y0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=C8.create();return Y0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=C8.create();return Y0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=C8.create();return Y0.fromZRotation(Z,J),Z}add(J){return Y0.add(this,this,J),this}adjoint(){return Y0.adjoint(this,this),this}clone(){return new C8(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 Y0.copy(this,J),this}equals(J){return Y0.equals(this,J)}exactEquals(J){return Y0.exactEquals(this,J)}frustrum(J,Z,Y,X,K,$){return Y0.frustum(this,J,Z,Y,X,K,$),this}identity(){return Y0.identity(this),this}invert(){return Y0.invert(this,this),this}lookAt(J,Z,Y){return Y0.lookAt(this,J,Z,Y),this}multiply(J){return Y0.mul(this,this,J),this}multiplyScalar(J){return Y0.multiplyScalar(this,this,J),this}orthographic(J,Z,Y,X,K,$){return Y0.ortho(this,J,Z,Y,X,K,$),this}perspective(J,Z,Y,X){return Y0.perspective(this,J,Z,Y,X),this}rotate(J,Z){return Y0.rotate(this,this,J,Z),this}rotateX(J){return Y0.rotateX(this,this,J),this}rotateY(J){return Y0.rotateY(this,this,J),this}rotateZ(J){return Y0.rotateZ(this,this,J),this}scale(J){return Y0.scale(this,this,J),this}subtract(J){return Y0.sub(this,this,J),this}targetTo(J,Z,Y){return Y0.targetTo(this,J,Z,Y),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 Y0.translate(this,this,J),this}transpose(){return Y0.transpose(this,this),this}}class J4 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get length(){return v0.length(this)}get squaredLength(){return v0.squaredLength(this)}get magnitude(){return v0.length(this)}get squaredMagnitude(){return v0.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,Y){let X=v0.fromEuler(new Float32Array(4),J,Z,Y);return new J4(X[0],X[1],X[2],X[3])}static fromQuaternionLike(J){return new J4(J.x,J.y,J.z,J.w)}clone(){return new J4(this.x,this.y,this.z,this.w)}conjugate(){return v0.conjugate(this,this),this}copy(J){return v0.copy(this,J),this}dot(J){return v0.dot(this,J)}exponential(){return v0.exp(this,this),this}equals(J){return v0.equals(this,J)}exactEquals(J){return v0.exactEquals(this,J)}getAngle(J){return v0.getAngle(this,J)}identity(){return v0.identity(this),this}invert(){return v0.invert(this,this),this}lerp(J,Z){return v0.lerp(this,this,J,Z),this}logarithm(){return v0.ln(this,this),this}multiply(J){return v0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return v0.normalize(this,this),this}power(J){return v0.pow(this,this,J),this}randomize(){return v0.random(this),this}rotateX(J){return v0.rotateX(this,this,J),this}rotateY(J){return v0.rotateY(this,this,J),this}rotateZ(J){return v0.rotateZ(this,this,J),this}scale(J){return v0.scale(this,this,J),this}setAxisAngle(J,Z){return v0.setAxisAngle(this,J,Z),this}slerp(J,Z){return v0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class yJ 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 yJ(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 yJ(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 Z4 extends Float32Array{constructor(J,Z,Y){super([J,Z,Y])}get length(){return $0.length(this)}get squaredLength(){return $0.squaredLength(this)}get magnitude(){return $0.length(this)}get squaredMagnitude(){return $0.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 Z4(0,0,0)}static fromVector3Like(J){return new Z4(J.x,J.y,J.z)}add(J){return $0.add(this,this,J),this}ceil(){return $0.ceil(this,this),this}clone(){return new Z4(this.x,this.y,this.z)}copy(J){return $0.copy(this,J),this}cross(J){return $0.cross(this,this,J),this}distance(J){return $0.distance(this,J)}divide(J){return $0.div(this,this,J),this}dot(J){return $0.dot(this,J)}equals(J){return $0.equals(this,J)}exactEquals(J){return $0.exactEquals(this,J)}floor(){return $0.floor(this,this),this}invert(){return $0.inverse(this,this),this}lerp(J,Z){return $0.lerp(this,this,J,Z),this}max(J){return $0.max(this,this,J),this}min(J){return $0.min(this,this,J),this}multiply(J){return $0.mul(this,this,J),this}negate(){return $0.negate(this,this),this}normalize(){return $0.normalize(this,this),this}randomize(J){return $0.random(this,J),this}rotateX(J,Z){return $0.rotateX(this,this,J,Z),this}rotateY(J,Z){return $0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return $0.rotateZ(this,this,J,Z),this}round(){return $0.round(this,this),this}scale(J){return $0.scale(this,this,J),this}scaleAndAdd(J,Z){return $0.scaleAndAdd(this,this,J,Z),this}subtract(J){return $0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return $0.transformMat3(this,this,J),this}transformMatrix4(J){return $0.transformMat4(this,this,J),this}transformQuaternion(J){return $0.transformQuat(this,this,J),this}zero(){return $0.zero(this),this}}var j0=function(J,Z,Y,X){function K($){return $ instanceof Y?$:new Y(function(Q){Q($)})}return new(Y||(Y=Promise))(function($,Q){function F(V){try{W(X.next(V))}catch(q){Q(q)}}function G(V){try{W(X.throw(V))}catch(q){Q(q)}}function W(V){V.done?$(V.value):K(V.value).then(F,G)}W((X=X.apply(J,Z||[])).next())})},B0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=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 Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},m8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},F6=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))},WS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,Y=Z&&J[Z],X=0;if(Y)return Y.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&X>=J.length)J=void 0;return{value:J&&J[X++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},VD0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(X,K){return Y.compare(X,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 Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Z>Y)return[2,1];else if(Z<Y)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Y>Z)return[2,1];else if(Y<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z-Y]})})},J.maxComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Y-Z]})})},J.defaultIsEqual=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z===Y]})})},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var H="";for(;q>0;--q)H+=V;return H}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var H=Math.pow(2,Q-q)-1;return X(" ",Math.floor(H/2)*F)+V.map(function(U){var O=(F-U.length)/2;return X(" ",Math.ceil(O))+U+X(" ",Math.floor(O))}).join(X(" ",H*F))}).join(`
|
380
|
+
`),Z.write($),Z.end();return}this.emitWithGlobal("WEBSERVER.UPGRADE",{req:J,socket:Z,head:Y})};_onError=(J)=>{this.emitWithGlobal("WEBSERVER.ERROR",{error:J})};_onStopped=()=>{this.emitWithGlobal("WEBSERVER.STOPPED",{})}}class BJ extends s{static instance=new BJ;_wss;constructor(){super();this._wss=new vZ0({noServer:!0}),this._wss.on("connection",this._onConnection),this._wss.on("error",this._onError),l8.on("WEBSERVER.UPGRADE",({req:J,socket:Z,head:Y})=>this._onUpgrade(J,Z,Y))}_onConnection=(J,Z)=>{new O9(J,Z)};_onError=(J,Z)=>{this.emitWithGlobal("SOCKET.ERROR",{ws:J,error:Z})};_onUpgrade=(J,Z,Y)=>{this._wss.handleUpgrade(J,Z,Y,(X)=>{this._wss.emit("connection",X,J)})}}var m=new Error("RigidBody has been removed from the simulation and is therefore inaccessible."),F$;((K)=>{K.DYNAMIC="dynamic";K.FIXED="fixed";K.KINEMATIC_POSITION="kinematic_position";K.KINEMATIC_VELOCITY="kinematic_velocity"})(F$||={});var d6=0.001,$C="dynamic";class h9 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??=$C,this._rigidBodyDesc=this._createRigidBodyDesc(J),this._rigidBodyType=J.type,this._applyRigidBodyOptions(J),this._autoAddToSimulation(J)}get additionalMass(){if(this._rigidBody||this._rigidBodyDesc)return this._additionalMass;throw m}get additionalSolverIterations(){if(this._rigidBody)return this._rigidBody.additionalSolverIterations();if(this._rigidBodyDesc)return this._rigidBodyDesc.additionalSolverIterations;throw m}get angularDamping(){if(this._rigidBody)return this._rigidBody.angularDamping();if(this._rigidBodyDesc)return this._rigidBodyDesc.angularDamping;throw m}get angularVelocity(){if(this._rigidBody)return this._rigidBody.angvel();if(this._rigidBodyDesc)return this._rigidBodyDesc.angvel;throw m}get colliders(){return this._colliders}get dominanceGroup(){if(this._rigidBody)return this._rigidBody.dominanceGroup();if(this._rigidBodyDesc)return this._rigidBodyDesc.dominanceGroup;throw m}get directionFromRotation(){let{x:J,y:Z,z:Y,w:X}=this.rotation;return{x:2*(J*Y+X*Z),y:2*(Z*Y-X*J),z:1-2*(J*J+Z*Z)}}get effectiveAngularInertia(){if(this._rigidBody)return this._rigidBody.effectiveAngularInertia();if(this._rigidBodyDesc)return;throw m}get effectiveInverseMass(){if(this._rigidBody)return this._rigidBody.effectiveInvMass();if(this._rigidBodyDesc)return;throw m}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(this._rigidBody)return this._rigidBody.effectiveWorldInvInertiaSqrt();if(this._rigidBodyDesc)return;throw m}get enabledRotations(){if(this._rigidBody||this._rigidBodyDesc)return this._enabledRotations;throw m}get enabledPositions(){if(this._rigidBody||this._rigidBodyDesc)return this._enabledPositions;throw m}get gravityScale(){if(this._rigidBody)return this._rigidBody.gravityScale();if(this._rigidBodyDesc)return this._rigidBodyDesc.gravityScale;throw m}get inverseMass(){if(this._rigidBody)return this._rigidBody.invMass();if(this._rigidBodyDesc)return;throw m}get inversePrincipalAngularInertiaSqrt(){if(this._rigidBody)return this._rigidBody.invPrincipalInertiaSqrt();if(this._rigidBodyDesc)return;throw m}get isCcdEnabled(){if(this._rigidBody)return this._rigidBody.isCcdEnabled();if(this._rigidBodyDesc)return this._rigidBodyDesc.ccdEnabled;throw m}get isDynamic(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="dynamic";throw m}get isEnabled(){if(this._rigidBody)return this._rigidBody.isEnabled();if(this._rigidBodyDesc)return this._rigidBodyDesc.enabled;throw m}get isFixed(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="fixed";throw m}get isKinematic(){if(this._rigidBody||this._rigidBodyDesc)return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType);throw m}get isKinematicPositionBased(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="kinematic_position";throw m}get isKinematicVelocityBased(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType==="kinematic_velocity";throw m}get isMoving(){if(this._rigidBody)return this._rigidBody.isMoving();if(this._rigidBodyDesc)return!1;throw m}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(this._rigidBody)return!0;if(this._rigidBodyDesc)return!1;throw m}get isSleeping(){if(this._rigidBody)return this._rigidBody.isSleeping();if(this._rigidBodyDesc)return this._rigidBodyDesc.sleeping;throw m}get linearDamping(){if(this._rigidBody)return this._rigidBody.linearDamping();if(this._rigidBodyDesc)return this._rigidBodyDesc.linearDamping;throw m}get linearVelocity(){if(this._rigidBody)return this._rigidBody.linvel();if(this._rigidBodyDesc)return this._rigidBodyDesc.linvel;throw m}get localCenterOfMass(){if(this._rigidBody)return this._rigidBody.localCom();if(this._rigidBodyDesc)return this._rigidBodyDesc.centerOfMass;throw m}get mass(){if(this._rigidBody)return this._rigidBody.mass();if(this._rigidBodyDesc)return this._rigidBodyDesc.mass;throw m}get nextKinematicRotation(){if(this._rigidBody)return this._rigidBody.nextRotation();if(this._rigidBodyDesc)return this._rigidBodyDesc.rotation;throw m}get nextKinematicPosition(){if(this._rigidBody)return this._rigidBody.nextTranslation();if(this._rigidBodyDesc)return this._rigidBodyDesc.translation;throw m}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(this._rigidBody)return this._rigidBody.principalInertia();if(this._rigidBodyDesc)return this._rigidBodyDesc.principalAngularInertia;throw m}get principalAngularInertiaLocalFrame(){if(this._rigidBody)return this._rigidBody.principalInertiaLocalFrame();if(this._rigidBodyDesc)return;throw m}get position(){if(this._rigidBody)return this._rigidBody.translation();if(this._rigidBodyDesc)return this._rigidBodyDesc.translation;throw m}get rawRigidBody(){if(this._rigidBody)return this._rigidBody;if(this._rigidBodyDesc)return;throw m}get rotation(){if(this._rigidBody)return this._rigidBody.rotation();if(this._rigidBodyDesc)return this._rigidBodyDesc.rotation;throw m}get softCcdPrediction(){if(this._rigidBody)return this._rigidBody.softCcdPrediction();if(this._rigidBodyDesc)return this._rigidBodyDesc.softCcdPrediction;throw m}get type(){if(this._rigidBody||this._rigidBodyDesc)return this._rigidBodyType;throw m}get worldCenterOfMass(){if(this._rigidBody)return this._rigidBody.worldCom();if(this._rigidBodyDesc)return;throw m}setAdditionalMass(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAdditionalMass(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalMass(J);else throw m}setAdditionalMassProperties(J){this._requireDynamic();let{additionalMass:Z,centerOfMass:Y,principalAngularInertia:X,principalAngularInertiaLocalFrame:K}=J;if(this._rigidBody)this._rigidBody.setAdditionalMassProperties(Z,Y,X,K,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalMassProperties(Z,Y,X,K);else throw m;this._additionalMass=Z}setAdditionalSolverIterations(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAdditionalSolverIterations(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAdditionalSolverIterations(J);else throw m}setAngularDamping(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setAngularDamping(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAngularDamping(J);else throw m}setAngularVelocity(J){if(this._requireNotKinematicPositionBased(),this._rigidBody)this._rigidBody.setAngvel(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setAngvel(J);else throw m}setCcdEnabled(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.enableCcd(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setCcdEnabled(J);else throw m}setDominanceGroup(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setDominanceGroup(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setDominanceGroup(J);else throw m}setEnabled(J){if(this._rigidBody)this._rigidBody.setEnabled(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setEnabled(J);else throw m}setEnabledPositions(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setEnabledTranslations(J.x,J.y,J.z,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.enabledTranslations(J.x,J.y,J.z);else throw m;this._enabledPositions=J}setEnabledRotations(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setEnabledRotations(J.x,J.y,J.z,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.enabledRotations(J.x,J.y,J.z);else throw m;this._enabledRotations=J}setGravityScale(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setGravityScale(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setGravityScale(J);else throw m}setLinearDamping(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setLinearDamping(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setLinearDamping(J);else throw m}setLinearVelocity(J){if(this._requireNotKinematicPositionBased(),this._rigidBody)this._rigidBody.setLinvel(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setLinvel(J.x,J.y,J.z);else throw m}setNextKinematicRotation(J){if(this._requireKinematic(),this._rigidBody)this._rigidBody.setNextKinematicRotation(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setRotation(J);else throw m}setNextKinematicPosition(J){if(this._requireKinematic(),this._rigidBody)this._rigidBody.setNextKinematicTranslation(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setTranslation(J.x,J.y,J.z);else throw m}setPosition(J){if(this._rigidBody)this._rigidBody.setTranslation(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setTranslation(J.x,J.y,J.z);else throw m}setRotation(J){if(this._rigidBody)this._rigidBody.setRotation(J,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.setRotation(J);else throw m}setSleeping(J){if(this._requireDynamic(),this._rigidBody)J?this._rigidBody.sleep():this._rigidBody.wakeUp();else if(this._rigidBodyDesc)this._rigidBodyDesc.sleeping=J;else throw m;this._explicitSleep=J}setSoftCcdPrediction(J){if(this._requireDynamic(),this._rigidBody)this._rigidBody.setSoftCcdPrediction(J);else if(this._rigidBodyDesc)this._rigidBodyDesc.setSoftCcdPrediction(J);else throw m}setCollisionGroupsForSolidColliders(J){this._requireNotRemoved(),this._colliders.forEach((Z)=>{if(Z.isSensor)return;Z.setCollisionGroups(J)})}setCollisionGroupsForSensorColliders(J){this._requireNotRemoved(),this._colliders.forEach((Z)=>{if(!Z.isSensor)return;Z.setCollisionGroups(J)})}setType(J){let Y={["dynamic"]:z0.RigidBodyType.Dynamic,["fixed"]:z0.RigidBodyType.Fixed,["kinematic_position"]:z0.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:z0.RigidBodyType.KinematicVelocityBased}[J];if(Y===void 0)throw new Error(`Invalid RigidBodyType: ${J}`);if(this._rigidBody)this._rigidBody.setBodyType(Y,!this._explicitSleep);else if(this._rigidBodyDesc)this._rigidBodyDesc.status=Y;else throw m;this._rigidBodyType=J}addForce(J){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.addForce(J,!this._explicitSleep)}addTorque(J){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.addTorque(J,!this._explicitSleep)}addChildColliderToSimulation(J){this._requireNotRemoved(),this._requireCreated(),J.addToSimulation(this._simulation,this)}addToSimulation(J){if(this._requireNotRemoved(),this._rigidBody)throw new Error("RigidBody.create(): 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(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.applyImpulse(J,!this._explicitSleep)}applyImpulseAtPoint(J,Z){if(this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._isNegligibleVector(J))return;this._rigidBody.applyImpulseAtPoint(J,Z,!this._explicitSleep)}applyTorqueImpulse(J){this._requireNotRemoved(),this._requireCreated(),this._requireDynamic(),this._rigidBody.applyTorqueImpulse(J,!this._explicitSleep)}createAndAddChildCollider(J){return this._requireNotRemoved(),this._simulation?new n8({...J,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(J)}createAndAddChildCollidersToSimulation(J){let Z=[];return J.forEach((Y)=>{Z.push(this.createAndAddChildCollider(Y))}),Z}getCollidersByTag(J){let Z=[];for(let Y of this._colliders)if(Y.tag===J)Z.push(Y);return Z}linkCollider(J){if(this._requireNotRemoved(),J.parentRigidBody!==this)throw new Error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(J)}lockAllRotations(){this._requireNotRemoved(),this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){this._requireNotRemoved(),this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(this._requireNotRemoved(),!this._rigidBody)throw new 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(),!J.isRemoved)throw new Error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(J)}resetAngularVelocity(){this._requireNotRemoved(),this._requireCreated(),this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){this._requireNotRemoved(),this._requireCreated(),this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){this._requireNotRemoved(),this._requireCreated(),this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){this._requireNotRemoved(),this._requireCreated(),this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){this._requireNotRemoved(),this.setSleeping(!0)}wakeUp(){this._requireNotRemoved(),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(([Y,X])=>{if(J[Y]!==void 0)X.call(this,J[Y])})}_autoAddToSimulation(J){if(J.colliders)this._createAndAddPendingChildColliders(J.colliders);if(J.simulation)this.addToSimulation(J.simulation)}_createAndAddPendingChildCollider(J){this._requireNotRemoved(),this._requireNotSimulated();let Z=new n8(J);return this._colliders.add(Z),Z}_createAndAddPendingChildColliders(J){let Z=[];return J.forEach((Y)=>{Z.push(this._createAndAddPendingChildCollider(Y))}),Z}_createRigidBodyDesc(J){let Z=J.type??$C;return{["dynamic"]:()=>z0.RigidBodyDesc.dynamic(),["fixed"]:()=>z0.RigidBodyDesc.fixed(),["kinematic_position"]:()=>z0.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>z0.RigidBodyDesc.kinematicVelocityBased()}[Z]()}_requireCreated(){if(!this._rigidBody||!this._simulation)throw new Error("RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method.")}_requireDynamic(){if(!this.isDynamic)throw new Error("RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method.")}_requireKinematic(){if(!this.isKinematic)throw new Error("RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method.")}_requireNotKinematicPositionBased(){if(this.isKinematicPositionBased)throw new Error("RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method.")}_requireNotRemoved(){if(!this._rigidBody&&!this._rigidBodyDesc)throw m}_requireNotSimulated(){if(this.isSimulated)throw new Error("RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method.")}_isEqualVectors(J,Z){return Math.abs(J.x-Z.x)<d6&&Math.abs(J.y-Z.y)<d6&&Math.abs(J.z-Z.z)<d6}_isEqualRotations(J,Z){return Math.abs(J.x-Z.x)<d6&&Math.abs(J.y-Z.y)<d6&&Math.abs(J.z-Z.z)<d6&&Math.abs(J.w-Z.w)<d6}_isNegligibleVector(J){return Math.abs(J.x)<d6&&Math.abs(J.y)<d6&&Math.abs(J.z)<d6}}var n0=16,t5=n0-1,QC=n0**3,jZ0=[{neighborOffset:[-1,0,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+0,J+0,Z+1,Y+0,J+0,Z+0,Y+1,J+0,Z+1,Y+1]},{neighborOffset:[1,0,0],generateVertices:(J,Z,Y)=>[J+1,Z+0,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+1,J+1,Z+0,Y+1]},{neighborOffset:[0,-1,0],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+1,Z+0,Y+0,J+0,Z+0,Y+1,J+1,Z+0,Y+0,J+1,Z+0,Y+1,J+0,Z+0,Y+1]},{neighborOffset:[0,1,0],generateVertices:(J,Z,Y)=>[J+0,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+0,J+1,Z+1,Y+0,J+0,Z+1,Y+1,J+1,Z+1,Y+1]},{neighborOffset:[0,0,-1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+0,Y+0,J+0,Z+1,Y+0,J+1,Z+1,Y+0,J+1,Z+0,Y+0]},{neighborOffset:[0,0,1],generateVertices:(J,Z,Y)=>[J+0,Z+0,Y+1,J+1,Z+0,Y+1,J+0,Z+1,Y+1,J+0,Z+1,Y+1,J+1,Z+0,Y+1,J+1,Z+1,Y+1]}],Zq;((X)=>{X.DESPAWN="CHUNK.DESPAWN";X.SET_BLOCK="CHUNK.SET_BLOCK";X.SPAWN="CHUNK.SPAWN"})(Zq||={});class N8 extends s{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(QC)}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%n0,y:(J/n0|0)%n0,z:J/(n0*n0)|0}}static globalCoordinateToLocalCoordinate(J){return{x:J.x&n0-1,y:J.y&n0-1,z:J.z&n0-1}}static globalCoordinateToOriginCoordinate(J){return{x:J.x&~(n0-1),y:J.y&~(n0-1),z:J.z&~(n0-1)}}static isValidOriginCoordinate(J){return J.x%n0===0&&J.y%n0===0&&J.z%n0===0}spawn(J,Z){if(this.isSpawned){let{x:Y,y:X,z:K}=this.originCoordinate;throw new Error(`Chunk.spawn(): Chunk is already spawned at origin ${Y}, ${X}, ${K}!`)}if(!N8.isValidOriginCoordinate(Z))throw new Error(`Chunk.spawn(): Chunk coordinates must be divisible by ${n0}`);this._originCoordinate=Z,this._world=J,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)throw new 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))throw new 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 Y=this._getGlobalCoordinate(J),X=[];if(J.x===0)X.push({x:-1,y:0,z:0});if(J.y===0)X.push({x:0,y:-1,z:0});if(J.z===0)X.push({x:0,y:0,z:-1});if(J.x===t5)X.push({x:1,y:0,z:0});if(J.y===t5)X.push({x:0,y:1,z:0});if(J.z===t5)X.push({x:0,y:0,z:1});for(let K of X){let $={x:Y.x+K.x,y:Y.y+K.y,z:Y.z+K.z},Q=N8.globalCoordinateToOriginCoordinate($),F=this._world?.chunkLattice.getChunk(Q);if(!F?.hasBlock(N8.globalCoordinateToLocalCoordinate($)))continue;F.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(J){this._requiresUpdate=J}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)throw new 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 h9({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([Y,X])=>{if(!Y.isSimulated)Y.addToSimulation(Z,this._rigidBody);Z.colliderMap.setColliderBlockType(Y,X)}),this._requiresUpdate=!1,J)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return e.serializeChunk(this)}_meshColliders(){if(!this._world)throw new Error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed.");let J=new Map,Z=[];for(let X=0;X<QC;X++){if(this._blocks[X]===0)continue;let K=this._blocks[X],$=this._world.blockTypeRegistry.getBlockType(K),{x:Q,y:F,z:G}=N8.blockIndexToLocalCoordinate(X);if(!$.isMeshable){let V=$.createCollider();V.setRelativePosition({x:Q,y:F,z:G}),Z.push([V,$]);continue}let W=J.get($)??{indices:[],vertices:[]};J.set($,W);for(let V of jZ0){let[q,H,U]=V.neighborOffset,O={x:Q+q,y:F+H,z:G+U},M=this._getGlobalCoordinate(O),L=this._world.chunkLattice.getBlockType(M);if(L&&!L.isLiquid)continue;let R=W.indices.length;W.indices.push(R,R+1,R+2,R+3,R+4,R+5),W.vertices.push(...V.generateVertices(Q,F,G))}}let Y=[];return J.forEach((X,K)=>{if(!X.indices.length)return;let $=K.createCollider(new Uint32Array(X.indices),new Float32Array(X.vertices));Y.push([$,K])}),[...Z,...Y]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(J){if(!this.originCoordinate)throw new Error("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+n0*(J.y+n0*J.z)}_isValidLocalCoordinate(J){return J.x>=0&&J.x<=t5&&J.y>=0&&J.y<=t5&&J.z>=0&&J.z<=t5}}class vJ{_chunks=new Map;_world;constructor(J){this._world=J}registerChunk(J){if(!J.isSpawned)throw new Error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(J.originCoordinate)){let{x:Z,y:Y,z:X}=J.originCoordinate;throw new Error(`ChunkLattice.registerChunk(): Chunk exists at origin (${Z}, ${Y}, ${X}), despawn the current chunk before registering another at the same origin.`)}if(J.world.id!==this._world.id)throw new Error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(J.originCoordinate),J)}unregisterChunk(J){if(!J.isSpawned)throw new Error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(J.world.id!==this._world.id)throw new Error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(J.originCoordinate))}getBlockId(J){let Z=this.getChunk(N8.globalCoordinateToOriginCoordinate(J));if(!Z)return 0;return Z.getBlockId(N8.globalCoordinateToLocalCoordinate(J))}getBlockType(J){let Z=this.getBlockId(J);return Z?this._world.blockTypeRegistry.getBlockType(Z):null}getChunk(J){if(!N8.isValidOriginCoordinate(J))throw new Error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${n0})`);return this._chunks.get(this._getChunkKey(J))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(J){let Z=this.getChunk(N8.globalCoordinateToOriginCoordinate(J));if(!Z)return!1;return Z.hasBlock(N8.globalCoordinateToLocalCoordinate(J))}hasChunk(J){return this._chunks.has(this._getChunkKey(J))}setBlock(J,Z){let Y=N8.globalCoordinateToLocalCoordinate(J),X=N8.globalCoordinateToOriginCoordinate(J),K=this.getChunk(X);if(!K)K=new N8,K.spawn(this._world,X);K.setBlock(Y,Z)}updateChunks(){this._chunks.forEach((J)=>{if(J.requiresUpdate)J.update()})}_getChunkKey(J){return`${J.x},${J.y},${J.z}`}}var FC={type:"dynamic",softCcdPrediction:1},GC=0.0025000000000000005,WC=Math.cos(0.005),G$;((R)=>{R.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";R.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";R.DESPAWN="ENTITY.DESPAWN";R.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";R.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";R.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";R.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";R.SET_OPACITY="ENTITY.SET_OPACITY";R.SET_PARENT="ENTITY.SET_PARENT";R.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";R.SPAWN="ENTITY.SPAWN";R.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";R.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";R.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";R.TICK="ENTITY.TICK";R.UPDATE_POSITION="ENTITY.UPDATE_POSITION";R.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(G$||={});class K8 extends h9{_id;_blockHalfExtents;_blockTextureUri;_controller;_modelAnimationsPlaybackRate=1;_modelHiddenNodes;_modelLoopedAnimations;_modelOneshotAnimations;_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){if(!J.blockTextureUri===!J.modelUri)throw new Error("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J.blockTextureUri&&!J.blockHalfExtents)throw new Error("Entity.constructor(): Block entity must have blockHalfExtents!");if(J.parent&&!J.parent.isSpawned)throw new Error("Entity.constructor(): Parent entity must be spawned before child entity!");if(J.parent?.modelUri&&J.parentNodeName&&!O6.instance.modelHasNode(J.parent.modelUri,J.parentNodeName))throw new Error(`Entity.constructor(): Parent node name ${J.parentNodeName} not found in parent model ${J.parent.modelUri}!`);super(J.rigidBodyOptions??FC);if(this._blockHalfExtents=J.blockHalfExtents,this._blockTextureUri=J.blockTextureUri,this._modelAnimationsPlaybackRate=J.modelAnimationsPlaybackRate??1,this._modelHiddenNodes=new Set(J.modelHiddenNodes??[]),this._modelLoopedAnimations=new Set(J.modelLoopedAnimations??[]),this._modelOneshotAnimations=new Set,this._modelScale=J.modelScale,this._modelUri=J.modelUri,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?O6.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,Y){if(this.isSpawned)return console.warn(`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 n8(n8.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0)this.addChildColliderToSimulation(new n8(n8.optionsFromModelUri(this._modelUri,this._modelScale)));if(this.colliders.forEach((X)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))X.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(H6.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[X.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(Z),Y)this.setRotation(Y);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,Y);this.colliders.forEach((X)=>{J.simulation.colliderMap.setColliderEntity(X,this)}),this.emitWithWorld(J,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this.isSpawned)return console.warn(`Entity.despawn(): Entity ${this._name} is not been spawned and cannot be despawned!`);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(),!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){this._requireSpawned(),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(),this._opacity===J)return;this._opacity=J,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:J})}setParent(J,Z,Y,X){if(this._requireSpawned(),J&&!J.isSpawned)throw new 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(Y??{x:0,y:0,z:0}),this.setRotation(X??{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(),!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(),!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(),!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(),!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 e.serializeEntity(this)}tick(J){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:J}),this._controller)this._controller.tick(this,J)}checkAndEmitUpdates(){this._requireSpawned();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(){if(!this.isSpawned)throw new Error(`Entity._requireSpawned(): Entity ${this._name} is not spawned!`)}_positionExceedsThreshold(J,Z){let Y=J.x-Z.x,X=J.y-Z.y,K=J.z-Z.z;return Y*Y+X*X+K*K>GC}_rotationExceedsThreshold(J,Z){return Math.abs(J.x*Z.x+J.y*Z.y+J.z*Z.z+J.w*Z.w)<WC}}class jJ extends a1{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 $4({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,attachedToEntity:J}),J.setCcdEnabled(!0),J.lockAllRotations()}spawn(J){if(!J.isSpawned)throw new 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,Y)=>{if(this._groundContactCount+=Y?1:-1,!this._groundContactCount)J.startModelOneshotAnimations(this.jumpOneshotAnimations);else J.stopModelAnimations(this.jumpOneshotAnimations);if(!(Z instanceof K8)||!Z.isKinematic)return;if(Y&&this.sticksToPlatforms)this._platform=Z;else if(Z===this._platform&&!Y)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,Y,X){if(!J.isSpawned||!J.world)return;if(super.tickWithPlayerInput(J,Z,Y,X),J.parent)return;let{w:K,a:$,s:Q,d:F,sp:G,sh:W,ml:V}=Z,{yaw:q}=Y,H=J.linearVelocity,U={x:0,y:0,z:0},O=W;if(this.isGrounded&&(K||$||Q||F)){if(O)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(V)J.startModelOneshotAnimations(this.interactOneshotAnimations),Z.ml=!this.autoCancelMouseLeftClick;if(O&&this.canRun(this)||!O&&this.canWalk(this)){let P=O?this.runVelocity:this.walkVelocity;if(K)U.x-=P*Math.sin(q),U.z-=P*Math.cos(q);if(Q)U.x+=P*Math.sin(q),U.z+=P*Math.cos(q);if($)U.x-=P*Math.cos(q),U.z+=P*Math.sin(q);if(F)U.x+=P*Math.cos(q),U.z-=P*Math.sin(q);let B=Math.sqrt(U.x*U.x+U.z*U.z);if(B>P){let v=P/B;U.x*=v,U.z*=v}}if(G&&this.canJump(this)){if(this.isGrounded&&H.y>-0.001&&H.y<=3)U.y=this.jumpVelocity}let M=this._platform?this._platform.linearVelocity:{x:0,y:0,z:0},L={x:U.x-H.x+M.x,y:U.y+M.y,z:U.z-H.z+M.z};if(!(this.runVelocity>0&&Math.abs(H.x)>this.runVelocity||this.jumpVelocity>0&&Math.abs(H.y)>this.jumpVelocity||this.runVelocity>0&&Math.abs(H.z)>this.runVelocity)||this.isOnPlatform){if(Object.values(L).some((P)=>P!==0)){let P=J.mass;J.applyImpulse({x:L.x*P,y:L.y*P,z:L.z*P})}}if(q!==void 0){let P=q/2;J.setRotation({x:0,y:Math.fround(Math.sin(P)),z:0,w:Math.fround(Math.cos(P))})}}}var Yq;((F)=>{F.LOAD="SCENE_UI.LOAD";F.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";F.SET_OFFSET="SCENE_UI.SET_OFFSET";F.SET_POSITION="SCENE_UI.SET_POSITION";F.SET_STATE="SCENE_UI.SET_STATE";F.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";F.UNLOAD="SCENE_UI.UNLOAD"})(Yq||={});class kJ extends s{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)throw new Error("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;this._id=J.sceneUIManager.registerSceneUI(this),this._world=J,this.emitWithWorld(J,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(J){if(!J.isSpawned)throw new 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 e.serializeSceneUI(this)}}class n1 extends K8{player;nametagSceneUI;constructor(J){super(J);if(this.player=J.player,this.nametagSceneUI=new kJ({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 jJ)}spawn(J,Z,Y){super.spawn(J,Z,Y),this.nametagSceneUI.load(J),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:X})=>{this.nametagSceneUI.setState({chat:X})})}tick(J){if(!this.isSpawned||!this.world||!this.controller)return;let{input:Z,camera:Y}=this.player;this.controller.tickWithPlayerInput(this,Z,Y.orientation,J),super.tick(J)}}class TJ{_entities=new Map;_nextEntityId=1;_world;constructor(J){this._world=J}get world(){return this._world}registerEntity(J){if(J.id!==void 0)throw new Error(`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)throw new 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 n1)J.push(Z)}),J}getPlayerEntitiesByPlayer(J){let Z=[];return this._entities.forEach((Y)=>{if(Y instanceof n1&&Y.player===J)Z.push(Y)}),Z}getEntity(J){return this._entities.get(J)}getEntitiesByTag(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag===J)Z.push(Y)}),Z}getEntitiesByTagSubstring(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.tag?.includes(J))Z.push(Y)}),Z}getEntityChildren(J){let Z=[];return this._entities.forEach((Y)=>{if(Y.parent===J)Z.push(Y)}),Z}tickEntities(J){this._entities.forEach((Z)=>{Z.tick(J)})}checkAndEmitUpdates(){this._entities.forEach((J)=>{if(!J.isSpawned)return;J.checkAndEmitUpdates()})}}class DJ{_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 VC;((Y)=>{Y[Y.POINTLIGHT=0]="POINTLIGHT";Y[Y.SPOTLIGHT=1]="SPOTLIGHT"})(VC||={});var Xq;((H)=>{H.DESPAWN="LIGHT.DESPAWN";H.SET_ANGLE="LIGHT.SET_ANGLE";H.SET_ATTACHED_TO_ENTITY="LIGHT.SET_ATTACHED_TO_ENTITY";H.SET_COLOR="LIGHT.SET_COLOR";H.SET_DISTANCE="LIGHT.SET_DISTANCE";H.SET_INTENSITY="LIGHT.SET_INTENSITY";H.SET_OFFSET="LIGHT.SET_OFFSET";H.SET_PENUMBRA="LIGHT.SET_PENUMBRA";H.SET_POSITION="LIGHT.SET_POSITION";H.SET_TRACKED_ENTITY="LIGHT.SET_TRACKED_ENTITY";H.SET_TRACKED_POSITION="LIGHT.SET_TRACKED_POSITION";H.SPAWN="LIGHT.SPAWN"})(Xq||={});class Kq extends s{_id;_angle;_attachedToEntity;_color;_distance;_intensity;_offset;_penumbra;_position;_trackedEntity;_trackedPosition;_type;_world;constructor(J){if(!!J.attachedToEntity===!!J.position)throw new Error("Either attachedToEntity or position must be set, but not both");super();console.warn("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)throw new 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)throw new 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;this._id=J.lightManager.registerLight(this),this._world=J,this.emitWithWorld(J,"LIGHT.SPAWN",{light:this})}serialize(){return e.serializeLight(this)}}var qC;((X)=>{X[X.FIRST_PERSON=0]="FIRST_PERSON";X[X.THIRD_PERSON=1]="THIRD_PERSON";X[X.SPECTATOR=2]="SPECTATOR"})(qC||={});var $q;((U)=>{U.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";U.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";U.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";U.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";U.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";U.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";U.SET_FOV="PLAYER_CAMERA.SET_FOV";U.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";U.SET_MODE="PLAYER_CAMERA.SET_MODE";U.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";U.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";U.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";U.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})($q||={});class _J 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){this._requirePlayerWorld(),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:J})}lookAtPosition(J){this._requirePlayerWorld(),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:J})}setAttachedToEntity(J){if(this._requirePlayerWorld(),!J.isSpawned)throw new 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){this._requirePlayerWorld(),this._attachedToPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:J})}setFilmOffset(J){this._requirePlayerWorld(),this._filmOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:J})}setForwardOffset(J){this._requirePlayerWorld(),this._forwardOffset=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:J})}setFov(J){this._requirePlayerWorld(),this._fov=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:J})}setModelHiddenNodes(J){this._requirePlayerWorld(),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){this._requirePlayerWorld(),this._mode=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:J})}setOffset(J){this._requirePlayerWorld(),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){this._requirePlayerWorld(),this._trackedEntity=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:J})}setTrackedPosition(J){this._requirePlayerWorld(),this._trackedPosition=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:J})}setZoom(J){this._requirePlayerWorld(),this._zoom=J,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:J})}serialize(){return e.serializePlayerCamera(this)}_requirePlayerWorld(){if(!this.player.world)throw new Error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world!`)}}var W$;((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"})(W$||={});class EJ 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 CJ{_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){return this._requireSimulatedCollider(J),this._colliderHandleBlockTypeMap.get(J.rawCollider.handle)}getColliderCollisionCallback(J){return this._requireSimulatedCollider(J),this._colliderHandleCollisionCallbackMap.get(J.rawCollider.handle)}getColliderEntity(J){return this._requireSimulatedCollider(J),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){this._requireSimulatedCollider(J),this.removeColliderHandleBlockType(J.rawCollider.handle)}removeColliderCollisionCallback(J){this._requireSimulatedCollider(J),this.removeColliderHandleCollisionCallback(J.rawCollider.handle)}removeColliderEntity(J){this._requireSimulatedCollider(J),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){this._requireSimulatedCollider(J),this.setColliderHandleBlockType(J.rawCollider.handle,Z)}setColliderCollisionCallback(J,Z){this._requireSimulatedCollider(J),this.setColliderHandleCollisionCallback(J.rawCollider.handle,Z)}setColliderEntity(J,Z){this._requireSimulatedCollider(J),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 Y of J.keys())Z.add(Y);J.clear()})}_requireSimulatedCollider(J){if(!J.rawCollider)throw new Error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.")}}var kZ0={x:0,y:-32,z:0},Qq=60,Fq;((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"})(Fq||={});class SJ extends s{_colliderMap=new CJ;_debugRaycastingEnabled=!1;_debugRenderingEnabled=!1;_rapierEventQueue;_rapierSimulation;_world;constructor(J,Z=Qq,Y=kZ0){super();this._rapierEventQueue=new z0.EventQueue(!0),this._rapierSimulation=new z0.World(Y),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,Y,X={}){let K=new z0.Ray(J,Z),$=this._rapierSimulation.castRay(K,Y,X.ignoresSensors??!0,X.filterFlags,X.filterGroups,X.filterExcludeCollider,X.filterExcludeRigidBody,X.filterPredicate);if(this._debugRaycastingEnabled)this.emitWithWorld(this._world,"SIMULATION.DEBUG_RAYCAST",{simulation:this,origin:J,direction:Z,length:Y,hit:!!$});if(!$)return null;let Q=K.pointAt($.timeOfImpact),F=$.timeOfImpact,G=$.collider,W=this._colliderMap.getColliderHandleBlockType(G.handle);if(W)return{hitBlock:y9.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:F};let V=this._colliderMap.getColliderHandleEntity(G.handle);if(V)return{hitEntity:V,hitPoint:Q,hitDistance:F};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 Y=[];return this._rapierSimulation.narrowPhase.contactPair(J,Z,(X,K)=>{if(X.numContacts()===0)return;let $=X.normal(),Q=[];for(let F=0;F<X.numSolverContacts();F++)Q.push(X.solverContactPoint(F));Y.push({contactPoints:Q,localNormalA:!K?X.localNormal1():X.localNormal2(),localNormalB:!K?X.localNormal2():X.localNormal1(),normal:!K?$:{x:-$.x,y:-$.y,z:-$.z}})}),Y}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,Y)=>{let[X,K]=this._getCollisionObjects(J,Z);if(!X||!K)return;let $=(Q,F)=>{if(Q instanceof M6&&F instanceof K8&&Q.hasListeners("BLOCK_TYPE.ENTITY_COLLISION"))Q.emit("BLOCK_TYPE.ENTITY_COLLISION",{blockType:Q,entity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof M6&&Q.hasListeners("ENTITY.BLOCK_COLLISION"))Q.emit("ENTITY.BLOCK_COLLISION",{entity:Q,blockType:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(Q instanceof K8&&F instanceof K8&&Q.hasListeners("ENTITY.ENTITY_COLLISION"))Q.emit("ENTITY.ENTITY_COLLISION",{entity:Q,otherEntity:F,started:Y,colliderHandleA:J,colliderHandleB:Z});else if(typeof Q==="function"&&(F instanceof K8||F instanceof M6))Q(F,Y,J,Z)};$(X,K),$(K,X)};_onContactForceEvent=(J)=>{let[Z,Y]=this._getCollisionObjects(J.collider1(),J.collider2());if(!Z||typeof Z==="function"||!Y||typeof Y==="function")return;let X={totalForce:J.totalForce(),totalForceMagnitude:J.totalForceMagnitude(),maxForceDirection:J.maxForceDirection(),maxForceMagnitude:J.maxForceMagnitude()},K=($,Q)=>{if($ instanceof M6&&Q instanceof K8&&$.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))$.emit("BLOCK_TYPE.ENTITY_CONTACT_FORCE",{blockType:$,entity:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof M6&&$.hasListeners("ENTITY.BLOCK_CONTACT_FORCE"))$.emit("ENTITY.BLOCK_CONTACT_FORCE",{entity:$,blockType:Q,contactForceData:X});else if($ instanceof K8&&Q instanceof K8&&$.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))$.emit("ENTITY.ENTITY_CONTACT_FORCE",{entity:$,otherEntity:Q,contactForceData:X})};K(Z,Y),K(Y,Z)};_getCollisionObjects(J,Z){let Y=this._colliderMap.getColliderHandleBlockType(J)??this._colliderMap.getColliderHandleCollisionCallback(J)??this._colliderMap.getColliderHandleEntity(J),X=this._colliderMap.getColliderHandleBlockType(Z)??this._colliderMap.getColliderHandleCollisionCallback(Z)??this._colliderMap.getColliderHandleEntity(Z);return[Y,X]}}class V${_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(){for(let[W,V]of this._queuedPerPlayerSynchronizations)for(let q of V)W.connection.send(q);let J=Object.values(this._queuedEntitySynchronizations);if(J.length>0){let W=y.createPacket(y.outboundPackets.entitiesPacketDefinition,J,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Z=Object.values(this._queuedAudioSynchronizations);if(Z.length>0){let W=y.createPacket(y.outboundPackets.audiosPacketDefinition,Z,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let Y=Object.values(this._queuedBlockTypeSynchronizations);if(Y.length>0){let W=y.createPacket(y.outboundPackets.blockTypesPacketDefinition,Y,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let X=Object.values(this._queuedBlockSynchronizations);if(X.length>0){let W=y.createPacket(y.outboundPackets.blocksPacketDefinition,X,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let K=Object.values(this._queuedChunkSynchronizations);if(K.length>0){let W=y.createPacket(y.outboundPackets.chunksPacketDefinition,K,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}let $=Object.values(this._queuedLightSynchronizations);if($.length>0){let W=y.createPacket(y.outboundPackets.lightsPacketDefinition,$,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerUISynchronizations){let q=y.createPacket(y.outboundPackets.uiPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}for(let[W,V]of this._queuedPerPlayerUIDatasSynchronizations){let q=y.createPacket(y.outboundPackets.uiDatasPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let Q=Object.values(this._queuedSceneUISynchronizations);if(Q.length>0){let W=y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,Q,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}if(this._queuedWorldSynchronization){let W=y.createPacket(y.outboundPackets.worldPacketDefinition,this._queuedWorldSynchronization,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let[W,V]of this._queuedPerPlayerCameraSynchronizations){let q=y.createPacket(y.outboundPackets.cameraPacketDefinition,V,this._world.loop.currentTick);W.connection.send(q)}let F=Object.values(this._queuedPlayerSynchronizations);if(F.length>0){let W=y.createPacket(y.outboundPackets.playersPacketDefinition,F,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}for(let W of this._queuedBroadcasts)Y8.instance.broadcastToWorld(this._world.id,W);let G=this._queuedDebugRaycastSynchronizations;if(G.length>0){let W=y.createPacket(y.outboundPackets.physicsDebugRaycastsPacketDefinition,G,this._world.loop.currentTick);Y8.instance.broadcastToWorld(this._world.id,W)}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()}_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_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};_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?e.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:Y,color:X}=J;this._queuedBroadcasts.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X,p:Z?.id}],this._world.loop.currentTick))};_onChatSendPlayerMessage=(J)=>{let{player:Z,message:Y,color:X}=J,K=this._queuedPerPlayerSynchronizations.get(Z)??[];K.push(y.createPacket(y.outboundPackets.chatMessagesPacketDefinition,[{m:Y,c:X}],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),Y=Z.c.join(",");if(this._spawnedChunks.has(Y))delete this._queuedChunkSynchronizations[Y],this._spawnedChunks.delete(Y);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?e.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((Y)=>!J.animations.has(Y)).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((Y)=>!J.animations.has(Y)).filter(Boolean)};_onEntityStopModelAnimations=(J)=>{let Z=this._createOrGetQueuedEntitySync(J.entity);if(Z.al)Z.al=Z.al.filter((Y)=>!J.animations.has(Y)).filter(Boolean);if(Z.ao)Z.ao=Z.ao.filter((Y)=>!J.animations.has(Y)).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=e.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?e.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?e.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?e.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=e.serializeVector(J.entity.position),delete Z.et,delete Z.pt};_onPlayerCameraLookAtPosition=(J)=>{let Z=this._createOrGetQueuedPlayerCameraSync(J.playerCamera);Z.pl=J.position?e.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?e.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?e.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?e.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,Y=this._queuedPerPlayerSynchronizations.get(Z)??[];Y.push(y.createPacket(y.outboundPackets.worldPacketDefinition,this._world.serialize(),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.blockTypesPacketDefinition,this._world.blockTypeRegistry.serialize(),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.chunksPacketDefinition,this._world.chunkLattice.getAllChunks().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.entitiesPacketDefinition,this._world.entityManager.getAllEntities().map((K)=>{if(Z.camera.attachedToEntity===void 0&&K instanceof n1&&K.player===Z)Z.camera.setAttachedToEntity(K);return K.serialize()}),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.audiosPacketDefinition,this._world.audioManager.getAllLoopedAudios().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.lightsPacketDefinition,this._world.lightManager.getAllLights().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.sceneUIsPacketDefinition,this._world.sceneUIManager.getAllSceneUIs().map((K)=>K.serialize()),this._world.loop.currentTick)),Y.push(y.createPacket(y.outboundPackets.playersPacketDefinition,Y8.instance.getConnectedPlayers().map((K)=>K.serialize()),this._world.loop.currentTick));let X=this._createOrGetQueuedPlayerCameraSync(Z.camera);this._queuedPerPlayerCameraSynchronizations.set(Z,{...Z.camera.serialize(),...X}),this._queuedPerPlayerSynchronizations.set(Z,Y),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?e.serializeVector(J.offset):void 0};_onSceneUISetPosition=(J)=>{let Z=this._createOrGetQueuedSceneUISync(J.sceneUI);Z.p=J.position?e.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(e.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=e.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=e.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=e.serializeVector(J.position)};_createOrGetQueuedAudioSync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedAudioSync(): Audio has no id!");return this._queuedAudioSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedBlockSync(J){let{x:Z,y:Y,z:X}=J;return this._queuedBlockSynchronizations[`${Z},${Y},${X}`]??={i:0,c:[Z,Y,X]}}_createOrGetQueuedChunkSync(J){if(!J.originCoordinate)throw new Error("NetworkSynchronizer._createOrGetQueuedChunkSync(): Chunk has no origin coordinate!");let{x:Z,y:Y,z:X}=J.originCoordinate;return this._queuedChunkSynchronizations[`${Z},${Y},${X}`]??={c:[Z,Y,X]}}_createOrGetQueuedEntitySync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedEntitySync(): Entity has no id!");return this._queuedEntitySynchronizations[J.id]??={i:J.id}}_createOrGetQueuedLightSync(J){if(J.id===void 0)throw new Error("NetworkSynchronizer._createOrGetQueuedLightSync(): Light has no id!");return this._queuedLightSynchronizations[J.id]??={i:J.id}}_createOrGetQueuedPlayerSync(J){if(J.id===void 0)throw new Error("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)throw new Error("NetworkSynchronizer._createOrGetQueuedSceneUISync(): SceneUI has no id!");return this._queuedSceneUISynchronizations[J.id]??={i:J.id}}_createOrGetQueuedWorldSync(J){if(J.id!==this._world.id)throw new Error("NetworkSynchronizer._createOrGetQueuedWorldSync(): World does not match this network synchronizer world!");return this._queuedWorldSynchronization??={i:J.id}}}class IJ{_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 fJ{_accumulatorMs=0;_targetTicksPerSecond;_fixedTimestepMs;_fixedTimestepS;_nextTickMs=0;_lastLoopTimeMs=0;_tickFunction;_tickErrorCallback;_tickHandle=null;constructor(J,Z,Y){this._targetTicksPerSecond=J,this._fixedTimestepS=Math.fround(1/J),this._fixedTimestepMs=Math.fround(this._fixedTimestepS*1000),this._tickFunction=Z,this._tickErrorCallback=Y}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 console.warn("Ticker.start(): ticker already running.");this._lastLoopTimeMs=performance.now();let J=()=>{let Z=performance.now(),Y=Z-this._lastLoopTimeMs;if(this._lastLoopTimeMs=Z,Y>250)Y=250;this._accumulatorMs+=Y;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 console.warn("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 console.warn("Ticker._tick(): tick callback threw an error, but it was not an instance of Error. Error:",Z)}}}var HC;(($)=>{$.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"})(HC||={});class hJ extends s{_currentTick=0;_ticker;_world;constructor(J,Z=Qq){super();this._ticker=new fJ(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)=>{console.error(J),this.emitWithWorld(this._world,"WORLD_LOOP.TICK_ERROR",{worldLoop:this,error:J})}}var Gq;((F)=>{F.SET_AMBIENT_LIGHT_COLOR="WORLD.SET_AMBIENT_LIGHT_COLOR";F.SET_AMBIENT_LIGHT_INTENSITY="WORLD.SET_AMBIENT_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_COLOR="WORLD.SET_DIRECTIONAL_LIGHT_COLOR";F.SET_DIRECTIONAL_LIGHT_INTENSITY="WORLD.SET_DIRECTIONAL_LIGHT_INTENSITY";F.SET_DIRECTIONAL_LIGHT_POSITION="WORLD.SET_DIRECTIONAL_LIGHT_POSITION";F.START="WORLD.START";F.STOP="WORLD.STOP"})(Gq||={});class bJ 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 Q4(this),this._blockTypeRegistry=new i4(this),this._chatManager=new pJ(this),this._chunkLattice=new vJ(this),this._entityManager=new TJ(this),this._lightManager=new DJ(this),this._loop=new hJ(this,J.tickRate),this._networkSynchronizer=new V$(this),this._sceneUIManager=new IJ(this),this._simulation=new SJ(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,Y]of Object.entries(J.blocks)){let[X,K,$]=Z.split(",").map(Number);this.chunkLattice.setBlock({x:X,y:K,z:$},Y)}if(J.entities)for(let[Z,Y]of Object.entries(J.entities)){let[X,K,$]=Z.split(",").map(Number);new K8(Y).spawn(this,{x:X,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 e.serializeWorld(this)}}var zC;((Y)=>{Y.START="GAMESERVER.START";Y.STOP="GAMESERVER.STOP"})(zC||={});function xZ0(J){z0.init().then(()=>{return R1.instance.modelRegistry.preloadModels()}).then(()=>{J(R1.instance.worlds[0]),R1.instance.start()}).catch((Z)=>{console.error("Failed to initialize the game engine, exiting. Error:",Z),process.exit(1)})}class R1{static _instance;_modelRegistry=O6.instance;_playerManager=Y8.instance;_socket=BJ.instance;_webServer=r5.instance;_worlds={};constructor(){let J=new bJ({id:0,name:"Default World",skyboxUri:"skyboxes/partly-cloudy"});this._worlds[J.id]=J}static get instance(){if(!this._instance)this._instance=new R1;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(){l8.emit("GAMESERVER.START",{startedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.start()),this._webServer.start()}stop(){l8.emit("GAMESERVER.STOP",{stoppedAtMs:performance.now()}),Object.values(this._worlds).forEach((J)=>J.stop())}}class b9{static instance=new b9;constructor(){}async getGlobalData(J){let Z=await u6.instance.getData(J);if(!Z||Z.error){if(Z?.error)console.warn(`PersistenceManager.getGlobalData(): ${Z.error.message}`);return}return Z}async getPlayerData(J){let Z=await u6.instance.getData(this._getPlayerKey(J));if(!Z||Z.error){if(Z?.error)console.warn(`PersistenceManager.getPlayerData(): ${Z.error.message}`);return}return Z}async setGlobalData(J,Z){let Y=await u6.instance.setData(J,Z);if(!Y||Y.error){if(Y?.error)console.warn(`PersistenceManager.setGlobalData(): ${Y.error.message}`);return}return Y}async setPlayerData(J,Z){let Y=await u6.instance.setData(this._getPlayerKey(J),Z);if(!Y||Y.error){if(Y?.error)console.warn(`PersistenceManager.setPlayerData(): ${Y.error.message}`);return}return Y}_getPlayerKey(J){return`player-${J.id}`}}var LC=["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"],xJ;((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"})(xJ||={});class R5 extends s{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_world;constructor(J,Z){super();this.id=Z?.user.id??`player-${R5._devNextPlayerId++}`,this.username=Z?.user.username??this.id,this.profilePictureUrl=Z?.user.profilePictureURL??void 0,this.camera=new _J(this),this.connection=J,this.ui=new EJ(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(R1.instance.worlds[0])}get input(){return this._input}get world(){return this._world}disconnect(){this.leaveWorld(),this.connection.close()}async getPersistedData(){return b9.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 b9.instance.setPlayerData(this,J)}serialize(){return e.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(LC.forEach((Y)=>{let X=Y;if(Z[X]!==void 0)this._input[X]=Boolean(Z[X])}),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 Wq;((Y)=>{Y.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";Y.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(Wq||={});class pJ 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,Y){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:J,message:Z,color:Y})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(J)=>{let{player:Z,message:Y}=J,[X,...K]=Y.split(" "),$=this._commandCallbacks[X];if($){$(Z,K,Y);return}this._sendBroadcastMessage(Z,`${Z.username}: ${Y}`)})}_sendBroadcastMessage(J,Z,Y){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:J,message:Z,color:Y})}}var l=0.000001,F0=typeof Float32Array!=="undefined"?Float32Array:Array,i6=Math.random;var YD0=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 J8={};o6(J8,{transpose:()=>IZ0,subtract:()=>OC,sub:()=>oZ0,str:()=>cZ0,set:()=>SZ0,scale:()=>AZ0,rotate:()=>pZ0,multiplyScalarAndAdd:()=>aZ0,multiplyScalar:()=>nZ0,multiply:()=>UC,mul:()=>sZ0,invert:()=>fZ0,identity:()=>EZ0,fromValues:()=>CZ0,fromScaling:()=>gZ0,fromRotation:()=>yZ0,frob:()=>mZ0,exactEquals:()=>dZ0,equals:()=>iZ0,determinant:()=>bZ0,create:()=>TZ0,copy:()=>_Z0,clone:()=>DZ0,adjoint:()=>hZ0,add:()=>uZ0,LDU:()=>lZ0});function TZ0(){var J=new F0(4);if(F0!=Float32Array)J[1]=0,J[2]=0;return J[0]=1,J[3]=1,J}function DZ0(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function _Z0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function EZ0(J){return J[0]=1,J[1]=0,J[2]=0,J[3]=1,J}function CZ0(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function SZ0(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function IZ0(J,Z){if(J===Z){var Y=Z[1];J[1]=Z[2],J[2]=Y}else J[0]=Z[0],J[1]=Z[2],J[2]=Z[1],J[3]=Z[3];return J}function fZ0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*$-K*X;if(!Q)return null;return Q=1/Q,J[0]=$*Q,J[1]=-X*Q,J[2]=-K*Q,J[3]=Y*Q,J}function hZ0(J,Z){var Y=Z[0];return J[0]=Z[3],J[1]=-Z[1],J[2]=-Z[2],J[3]=Y,J}function bZ0(J){return J[0]*J[3]-J[2]*J[1]}function UC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*F+$*G,J[1]=K*F+Q*G,J[2]=X*W+$*V,J[3]=K*W+Q*V,J}function pZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+$*F,J[1]=K*G+Q*F,J[2]=X*-F+$*G,J[3]=K*-F+Q*G,J}function AZ0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1];return J[0]=X*F,J[1]=K*F,J[2]=$*G,J[3]=Q*G,J}function yZ0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=-Y,J[3]=X,J}function gZ0(J,Z){return J[0]=Z[0],J[1]=0,J[2]=0,J[3]=Z[1],J}function cZ0(J){return"mat2("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}function mZ0(J){return Math.hypot(J[0],J[1],J[2],J[3])}function lZ0(J,Z,Y,X){return J[2]=X[2]/X[0],Y[0]=X[0],Y[1]=X[1],Y[3]=X[3]-J[2]*Y[1],[J,Z,Y]}function uZ0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function OC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J}function dZ0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function iZ0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}function nZ0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function aZ0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J}var sZ0=UC,oZ0=OC;var h0={};o6(h0,{transpose:()=>XY0,translate:()=>FY0,subtract:()=>wC,sub:()=>kY0,str:()=>MY0,set:()=>ZY0,scale:()=>WY0,rotate:()=>GY0,projection:()=>OY0,normalFromMat4:()=>UY0,multiplyScalarAndAdd:()=>PY0,multiplyScalar:()=>NY0,multiply:()=>MC,mul:()=>jY0,invert:()=>KY0,identity:()=>YY0,fromValues:()=>JY0,fromTranslation:()=>VY0,fromScaling:()=>HY0,fromRotation:()=>qY0,fromQuat:()=>LY0,fromMat4:()=>rZ0,fromMat2d:()=>zY0,frob:()=>wY0,exactEquals:()=>BY0,equals:()=>vY0,determinant:()=>QY0,create:()=>Vq,copy:()=>eZ0,clone:()=>tZ0,adjoint:()=>$Y0,add:()=>RY0});function Vq(){var J=new F0(9);if(F0!=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 rZ0(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 tZ0(J){var Z=new F0(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 eZ0(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 JY0(J,Z,Y,X,K,$,Q,F,G){var W=new F0(9);return W[0]=J,W[1]=Z,W[2]=Y,W[3]=X,W[4]=K,W[5]=$,W[6]=Q,W[7]=F,W[8]=G,W}function ZY0(J,Z,Y,X,K,$,Q,F,G,W){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J}function YY0(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 XY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[5];J[1]=Z[3],J[2]=Z[6],J[3]=Y,J[5]=Z[7],J[6]=X,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 KY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=V*Q-F*W,H=-V*$+F*G,U=W*$-Q*G,O=Y*q+X*H+K*U;if(!O)return null;return O=1/O,J[0]=q*O,J[1]=(-V*X+K*W)*O,J[2]=(F*X-K*Q)*O,J[3]=H*O,J[4]=(V*Y-K*G)*O,J[5]=(-F*Y+K*$)*O,J[6]=U*O,J[7]=(-W*Y+X*G)*O,J[8]=(Q*Y-X*$)*O,J}function $Y0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8];return J[0]=Q*V-F*W,J[1]=K*W-X*V,J[2]=X*F-K*Q,J[3]=F*G-$*V,J[4]=Y*V-K*G,J[5]=K*$-Y*F,J[6]=$*W-Q*G,J[7]=X*G-Y*W,J[8]=Y*Q-X*$,J}function QY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8];return Z*(W*$-Q*G)+Y*(-W*K+Q*F)+X*(G*K-$*F)}function MC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Y[0],U=Y[1],O=Y[2],M=Y[3],L=Y[4],R=Y[5],P=Y[6],B=Y[7],v=Y[8];return J[0]=H*X+U*Q+O*W,J[1]=H*K+U*F+O*V,J[2]=H*$+U*G+O*q,J[3]=M*X+L*Q+R*W,J[4]=M*K+L*F+R*V,J[5]=M*$+L*G+R*q,J[6]=P*X+B*Q+v*W,J[7]=P*K+B*F+v*V,J[8]=P*$+B*G+v*q,J}function FY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Y[0],U=Y[1];return J[0]=X,J[1]=K,J[2]=$,J[3]=Q,J[4]=F,J[5]=G,J[6]=H*X+U*Q+W,J[7]=H*K+U*F+V,J[8]=H*$+U*G+q,J}function GY0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Math.sin(Y),U=Math.cos(Y);return J[0]=U*X+H*Q,J[1]=U*K+H*F,J[2]=U*$+H*G,J[3]=U*Q-H*X,J[4]=U*F-H*K,J[5]=U*G-H*$,J[6]=W,J[7]=V,J[8]=q,J}function WY0(J,Z,Y){var X=Y[0],K=Y[1];return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*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 VY0(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 qY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=-Y,J[4]=X,J[5]=0,J[6]=0,J[7]=0,J[8]=1,J}function HY0(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 zY0(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 LY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,H=K*Q,U=K*F,O=K*G,M=$*Q,L=$*F,R=$*G;return J[0]=1-q-O,J[3]=V-R,J[6]=H+L,J[1]=V+R,J[4]=1-W-O,J[7]=U-M,J[2]=H-L,J[5]=U+M,J[8]=1-W-q,J}function UY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15],P=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,_=V*M-q*O,E=V*L-H*O,C=V*R-U*O,S=q*L-H*M,f=q*R-U*M,p=H*R-U*L,I=P*p-B*f+v*S+k*C-w*E+x*_;if(!I)return null;return I=1/I,J[0]=(F*p-G*f+W*S)*I,J[1]=(G*C-Q*p-W*E)*I,J[2]=(Q*f-F*C+W*_)*I,J[3]=(K*f-X*p-$*S)*I,J[4]=(Y*p-K*C+$*E)*I,J[5]=(X*C-Y*f-$*_)*I,J[6]=(M*x-L*w+R*k)*I,J[7]=(L*v-O*x-R*B)*I,J[8]=(O*w-M*v+R*P)*I,J}function OY0(J,Z,Y){return J[0]=2/Z,J[1]=0,J[2]=0,J[3]=0,J[4]=-2/Y,J[5]=0,J[6]=-1,J[7]=1,J[8]=1,J}function MY0(J){return"mat3("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+", "+J[4]+", "+J[5]+", "+J[6]+", "+J[7]+", "+J[8]+")"}function wY0(J){return Math.hypot(J[0],J[1],J[2],J[3],J[4],J[5],J[6],J[7],J[8])}function RY0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J}function wC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J}function NY0(J,Z,Y){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]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J}function PY0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J}function BY0(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 vY0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=Z[0],H=Z[1],U=Z[2],O=Z[3],M=Z[4],L=Z[5],R=Z[6],P=Z[7],B=Z[8];return Math.abs(Y-q)<=l*Math.max(1,Math.abs(Y),Math.abs(q))&&Math.abs(X-H)<=l*Math.max(1,Math.abs(X),Math.abs(H))&&Math.abs(K-U)<=l*Math.max(1,Math.abs(K),Math.abs(U))&&Math.abs($-O)<=l*Math.max(1,Math.abs($),Math.abs(O))&&Math.abs(Q-M)<=l*Math.max(1,Math.abs(Q),Math.abs(M))&&Math.abs(F-L)<=l*Math.max(1,Math.abs(F),Math.abs(L))&&Math.abs(G-R)<=l*Math.max(1,Math.abs(G),Math.abs(R))&&Math.abs(W-P)<=l*Math.max(1,Math.abs(W),Math.abs(P))&&Math.abs(V-B)<=l*Math.max(1,Math.abs(V),Math.abs(B))}var jY0=MC,kY0=wC;var Y0={};o6(Y0,{transpose:()=>CY0,translate:()=>hY0,targetTo:()=>QX0,subtract:()=>kC,sub:()=>UX0,str:()=>FX0,set:()=>EY0,scale:()=>bY0,rotateZ:()=>gY0,rotateY:()=>yY0,rotateX:()=>AY0,rotate:()=>pY0,perspectiveZO:()=>ZX0,perspectiveNO:()=>vC,perspectiveFromFieldOfView:()=>YX0,perspective:()=>JX0,orthoZO:()=>KX0,orthoNO:()=>jC,ortho:()=>XX0,multiplyScalarAndAdd:()=>qX0,multiplyScalar:()=>VX0,multiply:()=>NC,mul:()=>LX0,lookAt:()=>$X0,invert:()=>SY0,identity:()=>RC,getTranslation:()=>aY0,getScaling:()=>BC,getRotation:()=>sY0,frustum:()=>eY0,fromZRotation:()=>iY0,fromYRotation:()=>dY0,fromXRotation:()=>uY0,fromValues:()=>_Y0,fromTranslation:()=>cY0,fromScaling:()=>mY0,fromRotationTranslationScaleOrigin:()=>rY0,fromRotationTranslationScale:()=>oY0,fromRotationTranslation:()=>PC,fromRotation:()=>lY0,fromQuat2:()=>nY0,fromQuat:()=>tY0,frob:()=>GX0,exactEquals:()=>HX0,equals:()=>zX0,determinant:()=>fY0,create:()=>xY0,copy:()=>DY0,clone:()=>TY0,adjoint:()=>IY0,add:()=>WX0});function xY0(){var J=new F0(16);if(F0!=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 TY0(J){var Z=new F0(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 DY0(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 _Y0(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M){var L=new F0(16);return L[0]=J,L[1]=Z,L[2]=Y,L[3]=X,L[4]=K,L[5]=$,L[6]=Q,L[7]=F,L[8]=G,L[9]=W,L[10]=V,L[11]=q,L[12]=H,L[13]=U,L[14]=O,L[15]=M,L}function EY0(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M,L){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J[4]=$,J[5]=Q,J[6]=F,J[7]=G,J[8]=W,J[9]=V,J[10]=q,J[11]=H,J[12]=U,J[13]=O,J[14]=M,J[15]=L,J}function RC(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 CY0(J,Z){if(J===Z){var Y=Z[1],X=Z[2],K=Z[3],$=Z[6],Q=Z[7],F=Z[11];J[1]=Z[4],J[2]=Z[8],J[3]=Z[12],J[4]=Y,J[6]=Z[9],J[7]=Z[13],J[8]=X,J[9]=$,J[11]=Z[14],J[12]=K,J[13]=Q,J[14]=F}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 SY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15],P=Y*F-X*Q,B=Y*G-K*Q,v=Y*W-$*Q,k=X*G-K*F,w=X*W-$*F,x=K*W-$*G,_=V*M-q*O,E=V*L-H*O,C=V*R-U*O,S=q*L-H*M,f=q*R-U*M,p=H*R-U*L,I=P*p-B*f+v*S+k*C-w*E+x*_;if(!I)return null;return I=1/I,J[0]=(F*p-G*f+W*S)*I,J[1]=(K*f-X*p-$*S)*I,J[2]=(M*x-L*w+R*k)*I,J[3]=(H*w-q*x-U*k)*I,J[4]=(G*C-Q*p-W*E)*I,J[5]=(Y*p-K*C+$*E)*I,J[6]=(L*v-O*x-R*B)*I,J[7]=(V*x-H*v+U*B)*I,J[8]=(Q*f-F*C+W*_)*I,J[9]=(X*C-Y*f-$*_)*I,J[10]=(O*w-M*v+R*P)*I,J[11]=(q*v-V*w-U*P)*I,J[12]=(F*E-Q*S-G*_)*I,J[13]=(Y*S-X*E+K*_)*I,J[14]=(M*B-O*k-L*P)*I,J[15]=(V*k-q*B+H*P)*I,J}function IY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Z[4],F=Z[5],G=Z[6],W=Z[7],V=Z[8],q=Z[9],H=Z[10],U=Z[11],O=Z[12],M=Z[13],L=Z[14],R=Z[15];return J[0]=F*(H*R-U*L)-q*(G*R-W*L)+M*(G*U-W*H),J[1]=-(X*(H*R-U*L)-q*(K*R-$*L)+M*(K*U-$*H)),J[2]=X*(G*R-W*L)-F*(K*R-$*L)+M*(K*W-$*G),J[3]=-(X*(G*U-W*H)-F*(K*U-$*H)+q*(K*W-$*G)),J[4]=-(Q*(H*R-U*L)-V*(G*R-W*L)+O*(G*U-W*H)),J[5]=Y*(H*R-U*L)-V*(K*R-$*L)+O*(K*U-$*H),J[6]=-(Y*(G*R-W*L)-Q*(K*R-$*L)+O*(K*W-$*G)),J[7]=Y*(G*U-W*H)-Q*(K*U-$*H)+V*(K*W-$*G),J[8]=Q*(q*R-U*M)-V*(F*R-W*M)+O*(F*U-W*q),J[9]=-(Y*(q*R-U*M)-V*(X*R-$*M)+O*(X*U-$*q)),J[10]=Y*(F*R-W*M)-Q*(X*R-$*M)+O*(X*W-$*F),J[11]=-(Y*(F*U-W*q)-Q*(X*U-$*q)+V*(X*W-$*F)),J[12]=-(Q*(q*L-H*M)-V*(F*L-G*M)+O*(F*H-G*q)),J[13]=Y*(q*L-H*M)-V*(X*L-K*M)+O*(X*H-K*q),J[14]=-(Y*(F*L-G*M)-Q*(X*L-K*M)+O*(X*G-K*F)),J[15]=Y*(F*H-G*q)-Q*(X*H-K*q)+V*(X*G-K*F),J}function fY0(J){var Z=J[0],Y=J[1],X=J[2],K=J[3],$=J[4],Q=J[5],F=J[6],G=J[7],W=J[8],V=J[9],q=J[10],H=J[11],U=J[12],O=J[13],M=J[14],L=J[15],R=Z*Q-Y*$,P=Z*F-X*$,B=Z*G-K*$,v=Y*F-X*Q,k=Y*G-K*Q,w=X*G-K*F,x=W*O-V*U,_=W*M-q*U,E=W*L-H*U,C=V*M-q*O,S=V*L-H*O,f=q*L-H*M;return R*f-P*S+B*C+v*E-k*_+w*x}function NC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=Z[8],H=Z[9],U=Z[10],O=Z[11],M=Z[12],L=Z[13],R=Z[14],P=Z[15],B=Y[0],v=Y[1],k=Y[2],w=Y[3];return J[0]=B*X+v*F+k*q+w*M,J[1]=B*K+v*G+k*H+w*L,J[2]=B*$+v*W+k*U+w*R,J[3]=B*Q+v*V+k*O+w*P,B=Y[4],v=Y[5],k=Y[6],w=Y[7],J[4]=B*X+v*F+k*q+w*M,J[5]=B*K+v*G+k*H+w*L,J[6]=B*$+v*W+k*U+w*R,J[7]=B*Q+v*V+k*O+w*P,B=Y[8],v=Y[9],k=Y[10],w=Y[11],J[8]=B*X+v*F+k*q+w*M,J[9]=B*K+v*G+k*H+w*L,J[10]=B*$+v*W+k*U+w*R,J[11]=B*Q+v*V+k*O+w*P,B=Y[12],v=Y[13],k=Y[14],w=Y[15],J[12]=B*X+v*F+k*q+w*M,J[13]=B*K+v*G+k*H+w*L,J[14]=B*$+v*W+k*U+w*R,J[15]=B*Q+v*V+k*O+w*P,J}function hY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q,F,G,W,V,q,H,U,O,M,L,R;if(Z===J)J[12]=Z[0]*X+Z[4]*K+Z[8]*$+Z[12],J[13]=Z[1]*X+Z[5]*K+Z[9]*$+Z[13],J[14]=Z[2]*X+Z[6]*K+Z[10]*$+Z[14],J[15]=Z[3]*X+Z[7]*K+Z[11]*$+Z[15];else Q=Z[0],F=Z[1],G=Z[2],W=Z[3],V=Z[4],q=Z[5],H=Z[6],U=Z[7],O=Z[8],M=Z[9],L=Z[10],R=Z[11],J[0]=Q,J[1]=F,J[2]=G,J[3]=W,J[4]=V,J[5]=q,J[6]=H,J[7]=U,J[8]=O,J[9]=M,J[10]=L,J[11]=R,J[12]=Q*X+V*K+O*$+Z[12],J[13]=F*X+q*K+M*$+Z[13],J[14]=G*X+H*K+L*$+Z[14],J[15]=W*X+U*K+R*$+Z[15];return J}function bY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2];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]*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 pY0(J,Z,Y,X){var K=X[0],$=X[1],Q=X[2],F=Math.hypot(K,$,Q),G,W,V,q,H,U,O,M,L,R,P,B,v,k,w,x,_,E,C,S,f,p,I,g;if(F<l)return null;if(F=1/F,K*=F,$*=F,Q*=F,G=Math.sin(Y),W=Math.cos(Y),V=1-W,q=Z[0],H=Z[1],U=Z[2],O=Z[3],M=Z[4],L=Z[5],R=Z[6],P=Z[7],B=Z[8],v=Z[9],k=Z[10],w=Z[11],x=K*K*V+W,_=$*K*V+Q*G,E=Q*K*V-$*G,C=K*$*V-Q*G,S=$*$*V+W,f=Q*$*V+K*G,p=K*Q*V+$*G,I=$*Q*V-K*G,g=Q*Q*V+W,J[0]=q*x+M*_+B*E,J[1]=H*x+L*_+v*E,J[2]=U*x+R*_+k*E,J[3]=O*x+P*_+w*E,J[4]=q*C+M*S+B*f,J[5]=H*C+L*S+v*f,J[6]=U*C+R*S+k*f,J[7]=O*C+P*S+w*f,J[8]=q*p+M*I+B*g,J[9]=H*p+L*I+v*g,J[10]=U*p+R*I+k*g,J[11]=O*p+P*I+w*g,Z!==J)J[12]=Z[12],J[13]=Z[13],J[14]=Z[14],J[15]=Z[15];return J}function AY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[4],Q=Z[5],F=Z[6],G=Z[7],W=Z[8],V=Z[9],q=Z[10],H=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*X,J[5]=Q*K+V*X,J[6]=F*K+q*X,J[7]=G*K+H*X,J[8]=W*K-$*X,J[9]=V*K-Q*X,J[10]=q*K-F*X,J[11]=H*K-G*X,J}function yY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[8],V=Z[9],q=Z[10],H=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*X,J[1]=Q*K-V*X,J[2]=F*K-q*X,J[3]=G*K-H*X,J[8]=$*X+W*K,J[9]=Q*X+V*K,J[10]=F*X+q*K,J[11]=G*X+H*K,J}function gY0(J,Z,Y){var X=Math.sin(Y),K=Math.cos(Y),$=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=Z[4],V=Z[5],q=Z[6],H=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*X,J[1]=Q*K+V*X,J[2]=F*K+q*X,J[3]=G*K+H*X,J[4]=W*K-$*X,J[5]=V*K-Q*X,J[6]=q*K-F*X,J[7]=H*K-G*X,J}function cY0(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 mY0(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 lY0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Math.hypot(X,K,$),F,G,W;if(Q<l)return null;return Q=1/Q,X*=Q,K*=Q,$*=Q,F=Math.sin(Z),G=Math.cos(Z),W=1-G,J[0]=X*X*W+G,J[1]=K*X*W+$*F,J[2]=$*X*W-K*F,J[3]=0,J[4]=X*K*W-$*F,J[5]=K*K*W+G,J[6]=$*K*W+X*F,J[7]=0,J[8]=X*$*W+K*F,J[9]=K*$*W-X*F,J[10]=$*$*W+G,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function uY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=1,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=X,J[6]=Y,J[7]=0,J[8]=0,J[9]=-Y,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function dY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=0,J[2]=-Y,J[3]=0,J[4]=0,J[5]=1,J[6]=0,J[7]=0,J[8]=Y,J[9]=0,J[10]=X,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function iY0(J,Z){var Y=Math.sin(Z),X=Math.cos(Z);return J[0]=X,J[1]=Y,J[2]=0,J[3]=0,J[4]=-Y,J[5]=X,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 PC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=X+X,G=K+K,W=$+$,V=X*F,q=X*G,H=X*W,U=K*G,O=K*W,M=$*W,L=Q*F,R=Q*G,P=Q*W;return J[0]=1-(U+M),J[1]=q+P,J[2]=H-R,J[3]=0,J[4]=q-P,J[5]=1-(V+M),J[6]=O+L,J[7]=0,J[8]=H+R,J[9]=O-L,J[10]=1-(V+U),J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function nY0(J,Z){var Y=new F0(3),X=-Z[0],K=-Z[1],$=-Z[2],Q=Z[3],F=Z[4],G=Z[5],W=Z[6],V=Z[7],q=X*X+K*K+$*$+Q*Q;if(q>0)Y[0]=(F*Q+V*X+G*$-W*K)*2/q,Y[1]=(G*Q+V*K+W*X-F*$)*2/q,Y[2]=(W*Q+V*$+F*K-G*X)*2/q;else Y[0]=(F*Q+V*X+G*$-W*K)*2,Y[1]=(G*Q+V*K+W*X-F*$)*2,Y[2]=(W*Q+V*$+F*K-G*X)*2;return PC(J,Z,Y),J}function aY0(J,Z){return J[0]=Z[12],J[1]=Z[13],J[2]=Z[14],J}function BC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[4],Q=Z[5],F=Z[6],G=Z[8],W=Z[9],V=Z[10];return J[0]=Math.hypot(Y,X,K),J[1]=Math.hypot($,Q,F),J[2]=Math.hypot(G,W,V),J}function sY0(J,Z){var Y=new F0(3);BC(Y,Z);var X=1/Y[0],K=1/Y[1],$=1/Y[2],Q=Z[0]*X,F=Z[1]*K,G=Z[2]*$,W=Z[4]*X,V=Z[5]*K,q=Z[6]*$,H=Z[8]*X,U=Z[9]*K,O=Z[10]*$,M=Q+V+O,L=0;if(M>0)L=Math.sqrt(M+1)*2,J[3]=0.25*L,J[0]=(q-U)/L,J[1]=(H-G)/L,J[2]=(F-W)/L;else if(Q>V&&Q>O)L=Math.sqrt(1+Q-V-O)*2,J[3]=(q-U)/L,J[0]=0.25*L,J[1]=(F+W)/L,J[2]=(H+G)/L;else if(V>O)L=Math.sqrt(1+V-Q-O)*2,J[3]=(H-G)/L,J[0]=(F+W)/L,J[1]=0.25*L,J[2]=(q+U)/L;else L=Math.sqrt(1+O-Q-V)*2,J[3]=(F-W)/L,J[0]=(H+G)/L,J[1]=(q+U)/L,J[2]=0.25*L;return J}function oY0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=K+K,W=$+$,V=Q+Q,q=K*G,H=K*W,U=K*V,O=$*W,M=$*V,L=Q*V,R=F*G,P=F*W,B=F*V,v=X[0],k=X[1],w=X[2];return J[0]=(1-(O+L))*v,J[1]=(H+B)*v,J[2]=(U-P)*v,J[3]=0,J[4]=(H-B)*k,J[5]=(1-(q+L))*k,J[6]=(M+R)*k,J[7]=0,J[8]=(U+P)*w,J[9]=(M-R)*w,J[10]=(1-(q+O))*w,J[11]=0,J[12]=Y[0],J[13]=Y[1],J[14]=Y[2],J[15]=1,J}function rY0(J,Z,Y,X,K){var $=Z[0],Q=Z[1],F=Z[2],G=Z[3],W=$+$,V=Q+Q,q=F+F,H=$*W,U=$*V,O=$*q,M=Q*V,L=Q*q,R=F*q,P=G*W,B=G*V,v=G*q,k=X[0],w=X[1],x=X[2],_=K[0],E=K[1],C=K[2],S=(1-(M+R))*k,f=(U+v)*k,p=(O-B)*k,I=(U-v)*w,g=(1-(H+R))*w,J0=(L+P)*w,y0=(O+B)*x,a0=(L-P)*x,G6=(1-(H+M))*x;return J[0]=S,J[1]=f,J[2]=p,J[3]=0,J[4]=I,J[5]=g,J[6]=J0,J[7]=0,J[8]=y0,J[9]=a0,J[10]=G6,J[11]=0,J[12]=Y[0]+_-(S*_+I*E+y0*C),J[13]=Y[1]+E-(f*_+g*E+a0*C),J[14]=Y[2]+C-(p*_+J0*E+G6*C),J[15]=1,J}function tY0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y+Y,F=X+X,G=K+K,W=Y*Q,V=X*Q,q=X*F,H=K*Q,U=K*F,O=K*G,M=$*Q,L=$*F,R=$*G;return J[0]=1-q-O,J[1]=V+R,J[2]=H-L,J[3]=0,J[4]=V-R,J[5]=1-W-O,J[6]=U+M,J[7]=0,J[8]=H+L,J[9]=U-M,J[10]=1-W-q,J[11]=0,J[12]=0,J[13]=0,J[14]=0,J[15]=1,J}function eY0(J,Z,Y,X,K,$,Q){var F=1/(Y-Z),G=1/(K-X),W=1/($-Q);return J[0]=$*2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=$*2*G,J[6]=0,J[7]=0,J[8]=(Y+Z)*F,J[9]=(K+X)*G,J[10]=(Q+$)*W,J[11]=-1,J[12]=0,J[13]=0,J[14]=Q*$*2*W,J[15]=0,J}function vC(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,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/(X-K),J[10]=(K+X)*Q,J[14]=2*K*X*Q;else J[10]=-1,J[14]=-2*X;return J}var JX0=vC;function ZX0(J,Z,Y,X,K){var $=1/Math.tan(Z/2),Q;if(J[0]=$/Y,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/(X-K),J[10]=K*Q,J[14]=K*X*Q;else J[10]=-1,J[14]=-X;return J}function YX0(J,Z,Y,X){var K=Math.tan(Z.upDegrees*Math.PI/180),$=Math.tan(Z.downDegrees*Math.PI/180),Q=Math.tan(Z.leftDegrees*Math.PI/180),F=Math.tan(Z.rightDegrees*Math.PI/180),G=2/(Q+F),W=2/(K+$);return J[0]=G,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=W,J[6]=0,J[7]=0,J[8]=-((Q-F)*G*0.5),J[9]=(K-$)*W*0.5,J[10]=X/(Y-X),J[11]=-1,J[12]=0,J[13]=0,J[14]=X*Y/(Y-X),J[15]=0,J}function jC(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=2*W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=(Q+$)*W,J[15]=1,J}var XX0=jC;function KX0(J,Z,Y,X,K,$,Q){var F=1/(Z-Y),G=1/(X-K),W=1/($-Q);return J[0]=-2*F,J[1]=0,J[2]=0,J[3]=0,J[4]=0,J[5]=-2*G,J[6]=0,J[7]=0,J[8]=0,J[9]=0,J[10]=W,J[11]=0,J[12]=(Z+Y)*F,J[13]=(K+X)*G,J[14]=$*W,J[15]=1,J}function $X0(J,Z,Y,X){var K,$,Q,F,G,W,V,q,H,U,O=Z[0],M=Z[1],L=Z[2],R=X[0],P=X[1],B=X[2],v=Y[0],k=Y[1],w=Y[2];if(Math.abs(O-v)<l&&Math.abs(M-k)<l&&Math.abs(L-w)<l)return RC(J);if(V=O-v,q=M-k,H=L-w,U=1/Math.hypot(V,q,H),V*=U,q*=U,H*=U,K=P*H-B*q,$=B*V-R*H,Q=R*q-P*V,U=Math.hypot(K,$,Q),!U)K=0,$=0,Q=0;else U=1/U,K*=U,$*=U,Q*=U;if(F=q*Q-H*$,G=H*K-V*Q,W=V*$-q*K,U=Math.hypot(F,G,W),!U)F=0,G=0,W=0;else U=1/U,F*=U,G*=U,W*=U;return J[0]=K,J[1]=F,J[2]=V,J[3]=0,J[4]=$,J[5]=G,J[6]=q,J[7]=0,J[8]=Q,J[9]=W,J[10]=H,J[11]=0,J[12]=-(K*O+$*M+Q*L),J[13]=-(F*O+G*M+W*L),J[14]=-(V*O+q*M+H*L),J[15]=1,J}function QX0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=X[0],G=X[1],W=X[2],V=K-Y[0],q=$-Y[1],H=Q-Y[2],U=V*V+q*q+H*H;if(U>0)U=1/Math.sqrt(U),V*=U,q*=U,H*=U;var O=G*H-W*q,M=W*V-F*H,L=F*q-G*V;if(U=O*O+M*M+L*L,U>0)U=1/Math.sqrt(U),O*=U,M*=U,L*=U;return J[0]=O,J[1]=M,J[2]=L,J[3]=0,J[4]=q*L-H*M,J[5]=H*O-V*L,J[6]=V*M-q*O,J[7]=0,J[8]=V,J[9]=q,J[10]=H,J[11]=0,J[12]=K,J[13]=$,J[14]=Q,J[15]=1,J}function FX0(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 GX0(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 WX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J[4]=Z[4]+Y[4],J[5]=Z[5]+Y[5],J[6]=Z[6]+Y[6],J[7]=Z[7]+Y[7],J[8]=Z[8]+Y[8],J[9]=Z[9]+Y[9],J[10]=Z[10]+Y[10],J[11]=Z[11]+Y[11],J[12]=Z[12]+Y[12],J[13]=Z[13]+Y[13],J[14]=Z[14]+Y[14],J[15]=Z[15]+Y[15],J}function kC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J[3]=Z[3]-Y[3],J[4]=Z[4]-Y[4],J[5]=Z[5]-Y[5],J[6]=Z[6]-Y[6],J[7]=Z[7]-Y[7],J[8]=Z[8]-Y[8],J[9]=Z[9]-Y[9],J[10]=Z[10]-Y[10],J[11]=Z[11]-Y[11],J[12]=Z[12]-Y[12],J[13]=Z[13]-Y[13],J[14]=Z[14]-Y[14],J[15]=Z[15]-Y[15],J}function VX0(J,Z,Y){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]*Y,J[5]=Z[5]*Y,J[6]=Z[6]*Y,J[7]=Z[7]*Y,J[8]=Z[8]*Y,J[9]=Z[9]*Y,J[10]=Z[10]*Y,J[11]=Z[11]*Y,J[12]=Z[12]*Y,J[13]=Z[13]*Y,J[14]=Z[14]*Y,J[15]=Z[15]*Y,J}function qX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J[3]=Z[3]+Y[3]*X,J[4]=Z[4]+Y[4]*X,J[5]=Z[5]+Y[5]*X,J[6]=Z[6]+Y[6]*X,J[7]=Z[7]+Y[7]*X,J[8]=Z[8]+Y[8]*X,J[9]=Z[9]+Y[9]*X,J[10]=Z[10]+Y[10]*X,J[11]=Z[11]+Y[11]*X,J[12]=Z[12]+Y[12]*X,J[13]=Z[13]+Y[13]*X,J[14]=Z[14]+Y[14]*X,J[15]=Z[15]+Y[15]*X,J}function HX0(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 zX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=J[4],F=J[5],G=J[6],W=J[7],V=J[8],q=J[9],H=J[10],U=J[11],O=J[12],M=J[13],L=J[14],R=J[15],P=Z[0],B=Z[1],v=Z[2],k=Z[3],w=Z[4],x=Z[5],_=Z[6],E=Z[7],C=Z[8],S=Z[9],f=Z[10],p=Z[11],I=Z[12],g=Z[13],J0=Z[14],y0=Z[15];return Math.abs(Y-P)<=l*Math.max(1,Math.abs(Y),Math.abs(P))&&Math.abs(X-B)<=l*Math.max(1,Math.abs(X),Math.abs(B))&&Math.abs(K-v)<=l*Math.max(1,Math.abs(K),Math.abs(v))&&Math.abs($-k)<=l*Math.max(1,Math.abs($),Math.abs(k))&&Math.abs(Q-w)<=l*Math.max(1,Math.abs(Q),Math.abs(w))&&Math.abs(F-x)<=l*Math.max(1,Math.abs(F),Math.abs(x))&&Math.abs(G-_)<=l*Math.max(1,Math.abs(G),Math.abs(_))&&Math.abs(W-E)<=l*Math.max(1,Math.abs(W),Math.abs(E))&&Math.abs(V-C)<=l*Math.max(1,Math.abs(V),Math.abs(C))&&Math.abs(q-S)<=l*Math.max(1,Math.abs(q),Math.abs(S))&&Math.abs(H-f)<=l*Math.max(1,Math.abs(H),Math.abs(f))&&Math.abs(U-p)<=l*Math.max(1,Math.abs(U),Math.abs(p))&&Math.abs(O-I)<=l*Math.max(1,Math.abs(O),Math.abs(I))&&Math.abs(M-g)<=l*Math.max(1,Math.abs(M),Math.abs(g))&&Math.abs(L-J0)<=l*Math.max(1,Math.abs(L),Math.abs(J0))&&Math.abs(R-y0)<=l*Math.max(1,Math.abs(R),Math.abs(y0))}var LX0=NC,UX0=kC;var v0={};o6(v0,{str:()=>qK0,squaredLength:()=>JS,sqrLen:()=>NK0,sqlerp:()=>jK0,slerp:()=>L$,setAxisAngle:()=>iC,setAxes:()=>kK0,set:()=>UK0,scale:()=>rC,rotationTo:()=>vK0,rotateZ:()=>KK0,rotateY:()=>XK0,rotateX:()=>YK0,random:()=>FK0,pow:()=>QK0,normalize:()=>Lq,multiply:()=>nC,mul:()=>MK0,ln:()=>sC,lerp:()=>wK0,length:()=>eC,len:()=>RK0,invert:()=>GK0,identity:()=>eX0,getAxisAngle:()=>JK0,getAngle:()=>ZK0,fromValues:()=>zK0,fromMat3:()=>oC,fromEuler:()=>VK0,exp:()=>aC,exactEquals:()=>PK0,equals:()=>BK0,dot:()=>tC,create:()=>zq,copy:()=>LK0,conjugate:()=>WK0,clone:()=>HK0,calculateW:()=>$K0,add:()=>OK0});var $0={};o6($0,{zero:()=>gX0,transformQuat:()=>hX0,transformMat4:()=>IX0,transformMat3:()=>fX0,subtract:()=>TC,sub:()=>uX0,str:()=>cX0,squaredLength:()=>SC,squaredDistance:()=>CC,sqrLen:()=>sX0,sqrDist:()=>aX0,set:()=>wX0,scaleAndAdd:()=>xX0,scale:()=>kX0,round:()=>jX0,rotateZ:()=>AX0,rotateY:()=>pX0,rotateX:()=>bX0,random:()=>SX0,normalize:()=>qq,negate:()=>TX0,multiply:()=>DC,mul:()=>dX0,min:()=>BX0,max:()=>vX0,lerp:()=>_X0,length:()=>xC,len:()=>Hq,inverse:()=>DX0,hermite:()=>EX0,fromValues:()=>H$,forEach:()=>oX0,floor:()=>PX0,exactEquals:()=>mX0,equals:()=>lX0,dot:()=>z$,divide:()=>_C,div:()=>iX0,distance:()=>EC,dist:()=>nX0,cross:()=>AJ,create:()=>q$,copy:()=>MX0,clone:()=>OX0,ceil:()=>NX0,bezier:()=>CX0,angle:()=>yX0,add:()=>RX0});function q$(){var J=new F0(3);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J}function OX0(J){var Z=new F0(3);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z}function xC(J){var Z=J[0],Y=J[1],X=J[2];return Math.hypot(Z,Y,X)}function H$(J,Z,Y){var X=new F0(3);return X[0]=J,X[1]=Z,X[2]=Y,X}function MX0(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J}function wX0(J,Z,Y,X){return J[0]=Z,J[1]=Y,J[2]=X,J}function RX0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J}function TC(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J[2]=Z[2]-Y[2],J}function DC(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J[2]=Z[2]*Y[2],J}function _C(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J[2]=Z[2]/Y[2],J}function NX0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J[2]=Math.ceil(Z[2]),J}function PX0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J[2]=Math.floor(Z[2]),J}function BX0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J[2]=Math.min(Z[2],Y[2]),J}function vX0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J[2]=Math.max(Z[2],Y[2]),J}function jX0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J[2]=Math.round(Z[2]),J}function kX0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J}function xX0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J[2]=Z[2]+Y[2]*X,J}function EC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Math.hypot(Y,X,K)}function CC(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1],K=Z[2]-J[2];return Y*Y+X*X+K*K}function SC(J){var Z=J[0],Y=J[1],X=J[2];return Z*Z+Y*Y+X*X}function TX0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J}function DX0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J[2]=1/Z[2],J}function qq(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Y*Y+X*X+K*K;if($>0)$=1/Math.sqrt($);return J[0]=Z[0]*$,J[1]=Z[1]*$,J[2]=Z[2]*$,J}function z$(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]}function AJ(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[0],F=Y[1],G=Y[2];return J[0]=K*G-$*F,J[1]=$*Q-X*G,J[2]=X*F-K*Q,J}function _X0(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J}function EX0(J,Z,Y,X,K,$){var Q=$*$,F=Q*(2*$-3)+1,G=Q*($-2)+$,W=Q*($-1),V=Q*(3-2*$);return J[0]=Z[0]*F+Y[0]*G+X[0]*W+K[0]*V,J[1]=Z[1]*F+Y[1]*G+X[1]*W+K[1]*V,J[2]=Z[2]*F+Y[2]*G+X[2]*W+K[2]*V,J}function CX0(J,Z,Y,X,K,$){var Q=1-$,F=Q*Q,G=$*$,W=F*Q,V=3*$*F,q=3*G*Q,H=G*$;return J[0]=Z[0]*W+Y[0]*V+X[0]*q+K[0]*H,J[1]=Z[1]*W+Y[1]*V+X[1]*q+K[1]*H,J[2]=Z[2]*W+Y[2]*V+X[2]*q+K[2]*H,J}function SX0(J,Z){Z=Z||1;var Y=i6()*2*Math.PI,X=i6()*2-1,K=Math.sqrt(1-X*X)*Z;return J[0]=Math.cos(Y)*K,J[1]=Math.sin(Y)*K,J[2]=X*Z,J}function IX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Y[3]*X+Y[7]*K+Y[11]*$+Y[15];return Q=Q||1,J[0]=(Y[0]*X+Y[4]*K+Y[8]*$+Y[12])/Q,J[1]=(Y[1]*X+Y[5]*K+Y[9]*$+Y[13])/Q,J[2]=(Y[2]*X+Y[6]*K+Y[10]*$+Y[14])/Q,J}function fX0(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2];return J[0]=X*Y[0]+K*Y[3]+$*Y[6],J[1]=X*Y[1]+K*Y[4]+$*Y[7],J[2]=X*Y[2]+K*Y[5]+$*Y[8],J}function hX0(J,Z,Y){var X=Y[0],K=Y[1],$=Y[2],Q=Y[3],F=Z[0],G=Z[1],W=Z[2],V=K*W-$*G,q=$*F-X*W,H=X*G-K*F,U=K*H-$*q,O=$*V-X*H,M=X*q-K*V,L=Q*2;return V*=L,q*=L,H*=L,U*=2,O*=2,M*=2,J[0]=F+V+U,J[1]=G+q+O,J[2]=W+H+M,J}function bX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0],$[1]=K[1]*Math.cos(X)-K[2]*Math.sin(X),$[2]=K[1]*Math.sin(X)+K[2]*Math.cos(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function pX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[2]*Math.sin(X)+K[0]*Math.cos(X),$[1]=K[1],$[2]=K[2]*Math.cos(X)-K[0]*Math.sin(X),J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function AX0(J,Z,Y,X){var K=[],$=[];return K[0]=Z[0]-Y[0],K[1]=Z[1]-Y[1],K[2]=Z[2]-Y[2],$[0]=K[0]*Math.cos(X)-K[1]*Math.sin(X),$[1]=K[0]*Math.sin(X)+K[1]*Math.cos(X),$[2]=K[2],J[0]=$[0]+Y[0],J[1]=$[1]+Y[1],J[2]=$[2]+Y[2],J}function yX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2],G=Math.sqrt(Y*Y+X*X+K*K),W=Math.sqrt($*$+Q*Q+F*F),V=G*W,q=V&&z$(J,Z)/V;return Math.acos(Math.min(Math.max(q,-1),1))}function gX0(J){return J[0]=0,J[1]=0,J[2]=0,J}function cX0(J){return"vec3("+J[0]+", "+J[1]+", "+J[2]+")"}function mX0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]}function lX0(J,Z){var Y=J[0],X=J[1],K=J[2],$=Z[0],Q=Z[1],F=Z[2];return Math.abs(Y-$)<=l*Math.max(1,Math.abs(Y),Math.abs($))&&Math.abs(X-Q)<=l*Math.max(1,Math.abs(X),Math.abs(Q))&&Math.abs(K-F)<=l*Math.max(1,Math.abs(K),Math.abs(F))}var uX0=TC,dX0=DC,iX0=_C,nX0=EC,aX0=CC,Hq=xC,sX0=SC,oX0=function(){var J=q$();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=3;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2];return Z}}();function rX0(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0,J[3]=0;return J}function IC(J){var Z=new F0(4);return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[3],Z}function fC(J,Z,Y,X){var K=new F0(4);return K[0]=J,K[1]=Z,K[2]=Y,K[3]=X,K}function hC(J,Z){return J[0]=Z[0],J[1]=Z[1],J[2]=Z[2],J[3]=Z[3],J}function bC(J,Z,Y,X,K){return J[0]=Z,J[1]=Y,J[2]=X,J[3]=K,J}function pC(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J[2]=Z[2]+Y[2],J[3]=Z[3]+Y[3],J}function AC(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J[2]=Z[2]*Y,J[3]=Z[3]*Y,J}function yC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Math.hypot(Z,Y,X,K)}function gC(J){var Z=J[0],Y=J[1],X=J[2],K=J[3];return Z*Z+Y*Y+X*X+K*K}function cC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$;if(Q>0)Q=1/Math.sqrt(Q);return J[0]=Y*Q,J[1]=X*Q,J[2]=K*Q,J[3]=$*Q,J}function mC(J,Z){return J[0]*Z[0]+J[1]*Z[1]+J[2]*Z[2]+J[3]*Z[3]}function lC(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J[2]=Q+X*(Y[2]-Q),J[3]=F+X*(Y[3]-F),J}function uC(J,Z){return J[0]===Z[0]&&J[1]===Z[1]&&J[2]===Z[2]&&J[3]===Z[3]}function dC(J,Z){var Y=J[0],X=J[1],K=J[2],$=J[3],Q=Z[0],F=Z[1],G=Z[2],W=Z[3];return Math.abs(Y-Q)<=l*Math.max(1,Math.abs(Y),Math.abs(Q))&&Math.abs(X-F)<=l*Math.max(1,Math.abs(X),Math.abs(F))&&Math.abs(K-G)<=l*Math.max(1,Math.abs(K),Math.abs(G))&&Math.abs($-W)<=l*Math.max(1,Math.abs($),Math.abs(W))}var XD0=function(){var J=rX0();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=4;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],J[2]=Z[F+2],J[3]=Z[F+3],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1],Z[F+2]=J[2],Z[F+3]=J[3];return Z}}();function zq(){var J=new F0(4);if(F0!=Float32Array)J[0]=0,J[1]=0,J[2]=0;return J[3]=1,J}function eX0(J){return J[0]=0,J[1]=0,J[2]=0,J[3]=1,J}function iC(J,Z,Y){Y=Y*0.5;var X=Math.sin(Y);return J[0]=X*Z[0],J[1]=X*Z[1],J[2]=X*Z[2],J[3]=Math.cos(Y),J}function JK0(J,Z){var Y=Math.acos(Z[3])*2,X=Math.sin(Y/2);if(X>l)J[0]=Z[0]/X,J[1]=Z[1]/X,J[2]=Z[2]/X;else J[0]=1,J[1]=0,J[2]=0;return Y}function ZK0(J,Z){var Y=tC(J,Z);return Math.acos(2*Y*Y-1)}function nC(J,Z,Y){var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Y[0],G=Y[1],W=Y[2],V=Y[3];return J[0]=X*V+Q*F+K*W-$*G,J[1]=K*V+Q*G+$*F-X*W,J[2]=$*V+Q*W+X*G-K*F,J[3]=Q*V-X*F-K*G-$*W,J}function YK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+Q*F,J[1]=K*G+$*F,J[2]=$*G-K*F,J[3]=Q*G-X*F,J}function XK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G-$*F,J[1]=K*G+Q*F,J[2]=$*G+X*F,J[3]=Q*G-K*F,J}function KK0(J,Z,Y){Y*=0.5;var X=Z[0],K=Z[1],$=Z[2],Q=Z[3],F=Math.sin(Y),G=Math.cos(Y);return J[0]=X*G+K*F,J[1]=K*G-X*F,J[2]=$*G+Q*F,J[3]=Q*G-$*F,J}function $K0(J,Z){var Y=Z[0],X=Z[1],K=Z[2];return J[0]=Y,J[1]=X,J[2]=K,J[3]=Math.sqrt(Math.abs(1-Y*Y-X*X-K*K)),J}function aC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Math.exp($),G=Q>0?F*Math.sin(Q)/Q:0;return J[0]=Y*G,J[1]=X*G,J[2]=K*G,J[3]=F*Math.cos(Q),J}function sC(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Math.sqrt(Y*Y+X*X+K*K),F=Q>0?Math.atan2(Q,$)/Q:0;return J[0]=Y*F,J[1]=X*F,J[2]=K*F,J[3]=0.5*Math.log(Y*Y+X*X+K*K+$*$),J}function QK0(J,Z,Y){return sC(J,Z),rC(J,J,Y),aC(J,J),J}function L$(J,Z,Y,X){var K=Z[0],$=Z[1],Q=Z[2],F=Z[3],G=Y[0],W=Y[1],V=Y[2],q=Y[3],H,U,O,M,L;if(U=K*G+$*W+Q*V+F*q,U<0)U=-U,G=-G,W=-W,V=-V,q=-q;if(1-U>l)H=Math.acos(U),O=Math.sin(H),M=Math.sin((1-X)*H)/O,L=Math.sin(X*H)/O;else M=1-X,L=X;return J[0]=M*K+L*G,J[1]=M*$+L*W,J[2]=M*Q+L*V,J[3]=M*F+L*q,J}function FK0(J){var Z=i6(),Y=i6(),X=i6(),K=Math.sqrt(1-Z),$=Math.sqrt(Z);return J[0]=K*Math.sin(2*Math.PI*Y),J[1]=K*Math.cos(2*Math.PI*Y),J[2]=$*Math.sin(2*Math.PI*X),J[3]=$*Math.cos(2*Math.PI*X),J}function GK0(J,Z){var Y=Z[0],X=Z[1],K=Z[2],$=Z[3],Q=Y*Y+X*X+K*K+$*$,F=Q?1/Q:0;return J[0]=-Y*F,J[1]=-X*F,J[2]=-K*F,J[3]=$*F,J}function WK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J[2]=-Z[2],J[3]=Z[3],J}function oC(J,Z){var Y=Z[0]+Z[4]+Z[8],X;if(Y>0)X=Math.sqrt(Y+1),J[3]=0.5*X,X=0.5/X,J[0]=(Z[5]-Z[7])*X,J[1]=(Z[6]-Z[2])*X,J[2]=(Z[1]-Z[3])*X;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;X=Math.sqrt(Z[K*3+K]-Z[$*3+$]-Z[Q*3+Q]+1),J[K]=0.5*X,X=0.5/X,J[3]=(Z[$*3+Q]-Z[Q*3+$])*X,J[$]=(Z[$*3+K]+Z[K*3+$])*X,J[Q]=(Z[Q*3+K]+Z[K*3+Q])*X}return J}function VK0(J,Z,Y,X){var K=0.5*Math.PI/180;Z*=K,Y*=K,X*=K;var $=Math.sin(Z),Q=Math.cos(Z),F=Math.sin(Y),G=Math.cos(Y),W=Math.sin(X),V=Math.cos(X);return J[0]=$*G*V-Q*F*W,J[1]=Q*F*V+$*G*W,J[2]=Q*G*W-$*F*V,J[3]=Q*G*V+$*F*W,J}function qK0(J){return"quat("+J[0]+", "+J[1]+", "+J[2]+", "+J[3]+")"}var HK0=IC,zK0=fC,LK0=hC,UK0=bC,OK0=pC,MK0=nC,rC=AC,tC=mC,wK0=lC,eC=yC,RK0=eC,JS=gC,NK0=JS,Lq=cC,PK0=uC,BK0=dC,vK0=function(){var J=q$(),Z=H$(1,0,0),Y=H$(0,1,0);return function(X,K,$){var Q=z$(K,$);if(Q<-0.999999){if(AJ(J,Z,K),Hq(J)<0.000001)AJ(J,Y,K);return qq(J,J),iC(X,J,Math.PI),X}else if(Q>0.999999)return X[0]=0,X[1]=0,X[2]=0,X[3]=1,X;else return AJ(J,K,$),X[0]=J[0],X[1]=J[1],X[2]=J[2],X[3]=1+Q,Lq(X,X)}}(),jK0=function(){var J=zq(),Z=zq();return function(Y,X,K,$,Q,F){return L$(J,X,Q,F),L$(Z,K,$,F),L$(Y,J,Z,2*F*(1-F)),Y}}(),kK0=function(){var J=Vq();return function(Z,Y,X,K){return J[0]=X[0],J[3]=X[1],J[6]=X[2],J[1]=K[0],J[4]=K[1],J[7]=K[2],J[2]=-Y[0],J[5]=-Y[1],J[8]=-Y[2],Lq(Z,oC(Z,J))}}();var q0={};o6(q0,{zero:()=>rK0,transformMat4:()=>aK0,transformMat3:()=>nK0,transformMat2d:()=>iK0,transformMat2:()=>dK0,subtract:()=>YS,sub:()=>Y$0,str:()=>tK0,squaredLength:()=>GS,squaredDistance:()=>QS,sqrLen:()=>F$0,sqrDist:()=>Q$0,set:()=>_K0,scaleAndAdd:()=>pK0,scale:()=>bK0,round:()=>hK0,rotate:()=>sK0,random:()=>uK0,normalize:()=>gK0,negate:()=>AK0,multiply:()=>XS,mul:()=>X$0,min:()=>IK0,max:()=>fK0,lerp:()=>lK0,length:()=>FS,len:()=>Z$0,inverse:()=>yK0,fromValues:()=>TK0,forEach:()=>G$0,floor:()=>SK0,exactEquals:()=>eK0,equals:()=>J$0,dot:()=>cK0,divide:()=>KS,div:()=>K$0,distance:()=>$S,dist:()=>$$0,cross:()=>mK0,create:()=>ZS,copy:()=>DK0,clone:()=>xK0,ceil:()=>CK0,angle:()=>oK0,add:()=>EK0});function ZS(){var J=new F0(2);if(F0!=Float32Array)J[0]=0,J[1]=0;return J}function xK0(J){var Z=new F0(2);return Z[0]=J[0],Z[1]=J[1],Z}function TK0(J,Z){var Y=new F0(2);return Y[0]=J,Y[1]=Z,Y}function DK0(J,Z){return J[0]=Z[0],J[1]=Z[1],J}function _K0(J,Z,Y){return J[0]=Z,J[1]=Y,J}function EK0(J,Z,Y){return J[0]=Z[0]+Y[0],J[1]=Z[1]+Y[1],J}function YS(J,Z,Y){return J[0]=Z[0]-Y[0],J[1]=Z[1]-Y[1],J}function XS(J,Z,Y){return J[0]=Z[0]*Y[0],J[1]=Z[1]*Y[1],J}function KS(J,Z,Y){return J[0]=Z[0]/Y[0],J[1]=Z[1]/Y[1],J}function CK0(J,Z){return J[0]=Math.ceil(Z[0]),J[1]=Math.ceil(Z[1]),J}function SK0(J,Z){return J[0]=Math.floor(Z[0]),J[1]=Math.floor(Z[1]),J}function IK0(J,Z,Y){return J[0]=Math.min(Z[0],Y[0]),J[1]=Math.min(Z[1],Y[1]),J}function fK0(J,Z,Y){return J[0]=Math.max(Z[0],Y[0]),J[1]=Math.max(Z[1],Y[1]),J}function hK0(J,Z){return J[0]=Math.round(Z[0]),J[1]=Math.round(Z[1]),J}function bK0(J,Z,Y){return J[0]=Z[0]*Y,J[1]=Z[1]*Y,J}function pK0(J,Z,Y,X){return J[0]=Z[0]+Y[0]*X,J[1]=Z[1]+Y[1]*X,J}function $S(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Math.hypot(Y,X)}function QS(J,Z){var Y=Z[0]-J[0],X=Z[1]-J[1];return Y*Y+X*X}function FS(J){var Z=J[0],Y=J[1];return Math.hypot(Z,Y)}function GS(J){var Z=J[0],Y=J[1];return Z*Z+Y*Y}function AK0(J,Z){return J[0]=-Z[0],J[1]=-Z[1],J}function yK0(J,Z){return J[0]=1/Z[0],J[1]=1/Z[1],J}function gK0(J,Z){var Y=Z[0],X=Z[1],K=Y*Y+X*X;if(K>0)K=1/Math.sqrt(K);return J[0]=Z[0]*K,J[1]=Z[1]*K,J}function cK0(J,Z){return J[0]*Z[0]+J[1]*Z[1]}function mK0(J,Z,Y){var X=Z[0]*Y[1]-Z[1]*Y[0];return J[0]=J[1]=0,J[2]=X,J}function lK0(J,Z,Y,X){var K=Z[0],$=Z[1];return J[0]=K+X*(Y[0]-K),J[1]=$+X*(Y[1]-$),J}function uK0(J,Z){Z=Z||1;var Y=i6()*2*Math.PI;return J[0]=Math.cos(Y)*Z,J[1]=Math.sin(Y)*Z,J}function dK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K,J[1]=Y[1]*X+Y[3]*K,J}function iK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[2]*K+Y[4],J[1]=Y[1]*X+Y[3]*K+Y[5],J}function nK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[3]*K+Y[6],J[1]=Y[1]*X+Y[4]*K+Y[7],J}function aK0(J,Z,Y){var X=Z[0],K=Z[1];return J[0]=Y[0]*X+Y[4]*K+Y[12],J[1]=Y[1]*X+Y[5]*K+Y[13],J}function sK0(J,Z,Y,X){var K=Z[0]-Y[0],$=Z[1]-Y[1],Q=Math.sin(X),F=Math.cos(X);return J[0]=K*F-$*Q+Y[0],J[1]=K*Q+$*F+Y[1],J}function oK0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1],Q=Math.sqrt(Y*Y+X*X)*Math.sqrt(K*K+$*$),F=Q&&(Y*K+X*$)/Q;return Math.acos(Math.min(Math.max(F,-1),1))}function rK0(J){return J[0]=0,J[1]=0,J}function tK0(J){return"vec2("+J[0]+", "+J[1]+")"}function eK0(J,Z){return J[0]===Z[0]&&J[1]===Z[1]}function J$0(J,Z){var Y=J[0],X=J[1],K=Z[0],$=Z[1];return Math.abs(Y-K)<=l*Math.max(1,Math.abs(Y),Math.abs(K))&&Math.abs(X-$)<=l*Math.max(1,Math.abs(X),Math.abs($))}var Z$0=FS,Y$0=YS,X$0=XS,K$0=KS,$$0=$S,Q$0=QS,F$0=GS,G$0=function(){var J=ZS();return function(Z,Y,X,K,$,Q){var F,G;if(!Y)Y=2;if(!X)X=0;if(K)G=Math.min(K*Y+X,Z.length);else G=Z.length;for(F=X;F<G;F+=Y)J[0]=Z[F],J[1]=Z[F+1],$(J,J,Q),Z[F]=J[0],Z[F+1]=J[1];return Z}}();class A9 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get determinant(){return J8.determinant(this)}get frobeniusNorm(){return J8.frob(this)}static create(){let J=new A9(0,0,0,0);return J8.identity(J),J}static fromRotation(J){let Z=A9.create();return J8.fromRotation(Z,J),Z}static fromScaling(J){let Z=A9.create();return J8.fromScaling(Z,J),Z}add(J){return J8.add(this,this,J),this}adjoint(){return J8.adjoint(this,this),this}clone(){return new A9(this[0],this[1],this[2],this[3])}copy(J){return J8.copy(this,J),this}equals(J){return J8.equals(this,J)}exactEquals(J){return J8.exactEquals(this,J)}identity(){return J8.identity(this),this}invert(){return J8.invert(this,this),this}multiply(J){return J8.mul(this,this,J),this}multiplyScalar(J){return J8.multiplyScalar(this,this,J),this}rotate(J){return J8.rotate(this,this,J),this}subtract(J){return J8.sub(this,this,J),this}toString(){return`[${this[0]},${this[1]}][${this[2]},${this[3]}]`}transpose(){return J8.transpose(this,this),this}}class n6 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G){super([J,Z,Y,X,K,$,Q,F,G])}get determinant(){return h0.determinant(this)}get frobeniusNorm(){return h0.frob(this)}static create(){let J=new n6(0,0,0,0,0,0,0,0,0);return h0.identity(J),J}static fromMatrix4(J){let Z=n6.create();return h0.fromMat4(Z,J),Z}static fromQuaternion(J){let Z=n6.create();return h0.fromQuat(Z,J),Z}static fromRotation(J){let Z=n6.create();return h0.fromRotation(Z,J),Z}static fromScaling(J){let Z=n6.create();return h0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=n6.create();return h0.fromTranslation(Z,J),Z}add(J){return h0.add(this,this,J),this}adjoint(){return h0.adjoint(this,this),this}clone(){return new n6(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}copy(J){return h0.copy(this,J),this}equals(J){return h0.equals(this,J)}exactEquals(J){return h0.exactEquals(this,J)}identity(){return h0.identity(this),this}invert(){return h0.invert(this,this),this}multiply(J){return h0.mul(this,this,J),this}multiplyScalar(J){return h0.multiplyScalar(this,this,J),this}transformVector(J){return J.transformMatrix3(this)}projection(J,Z){return h0.projection(this,J,Z),this}rotate(J){return h0.rotate(this,this,J),this}subtract(J){return h0.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 h0.transpose(this,this),this}}class C8 extends Float32Array{constructor(J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M){super([J,Z,Y,X,K,$,Q,F,G,W,V,q,H,U,O,M])}get determinant(){return Y0.determinant(this)}get frobeniusNorm(){return Y0.frob(this)}static create(){let J=new C8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return Y0.identity(J),J}static fromQuaternion(J){let Z=C8.create();return Y0.fromQuat(Z,J),Z}static fromRotation(J,Z){let Y=C8.create();return Y0.fromRotation(Y,J,Z),Y}static fromRotationTranslation(J,Z){let Y=C8.create();return Y0.fromRotationTranslation(Y,J,Z),Y}static fromRotationTranslationScale(J,Z,Y){let X=C8.create();return Y0.fromRotationTranslationScale(X,J,Z,Y),X}static fromRotationTranslationScaleOrigin(J,Z,Y,X){let K=C8.create();return Y0.fromRotationTranslationScaleOrigin(K,J,Z,Y,X),K}static fromScaling(J){let Z=C8.create();return Y0.fromScaling(Z,J),Z}static fromTranslation(J){let Z=C8.create();return Y0.fromTranslation(Z,J),Z}static fromXRotation(J){let Z=C8.create();return Y0.fromXRotation(Z,J),Z}static fromYRotation(J){let Z=C8.create();return Y0.fromYRotation(Z,J),Z}static fromZRotation(J){let Z=C8.create();return Y0.fromZRotation(Z,J),Z}add(J){return Y0.add(this,this,J),this}adjoint(){return Y0.adjoint(this,this),this}clone(){return new C8(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 Y0.copy(this,J),this}equals(J){return Y0.equals(this,J)}exactEquals(J){return Y0.exactEquals(this,J)}frustrum(J,Z,Y,X,K,$){return Y0.frustum(this,J,Z,Y,X,K,$),this}identity(){return Y0.identity(this),this}invert(){return Y0.invert(this,this),this}lookAt(J,Z,Y){return Y0.lookAt(this,J,Z,Y),this}multiply(J){return Y0.mul(this,this,J),this}multiplyScalar(J){return Y0.multiplyScalar(this,this,J),this}orthographic(J,Z,Y,X,K,$){return Y0.ortho(this,J,Z,Y,X,K,$),this}perspective(J,Z,Y,X){return Y0.perspective(this,J,Z,Y,X),this}rotate(J,Z){return Y0.rotate(this,this,J,Z),this}rotateX(J){return Y0.rotateX(this,this,J),this}rotateY(J){return Y0.rotateY(this,this,J),this}rotateZ(J){return Y0.rotateZ(this,this,J),this}scale(J){return Y0.scale(this,this,J),this}subtract(J){return Y0.sub(this,this,J),this}targetTo(J,Z,Y){return Y0.targetTo(this,J,Z,Y),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 Y0.translate(this,this,J),this}transpose(){return Y0.transpose(this,this),this}}class J4 extends Float32Array{constructor(J,Z,Y,X){super([J,Z,Y,X])}get length(){return v0.length(this)}get squaredLength(){return v0.squaredLength(this)}get magnitude(){return v0.length(this)}get squaredMagnitude(){return v0.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,Y){let X=v0.fromEuler(new Float32Array(4),J,Z,Y);return new J4(X[0],X[1],X[2],X[3])}static fromQuaternionLike(J){return new J4(J.x,J.y,J.z,J.w)}clone(){return new J4(this.x,this.y,this.z,this.w)}conjugate(){return v0.conjugate(this,this),this}copy(J){return v0.copy(this,J),this}dot(J){return v0.dot(this,J)}exponential(){return v0.exp(this,this),this}equals(J){return v0.equals(this,J)}exactEquals(J){return v0.exactEquals(this,J)}getAngle(J){return v0.getAngle(this,J)}identity(){return v0.identity(this),this}invert(){return v0.invert(this,this),this}lerp(J,Z){return v0.lerp(this,this,J,Z),this}logarithm(){return v0.ln(this,this),this}multiply(J){return v0.multiply(this,this,J),this}transformVector(J){return J.transformQuaternion(this)}normalize(){return v0.normalize(this,this),this}power(J){return v0.pow(this,this,J),this}randomize(){return v0.random(this),this}rotateX(J){return v0.rotateX(this,this,J),this}rotateY(J){return v0.rotateY(this,this,J),this}rotateZ(J){return v0.rotateZ(this,this,J),this}scale(J){return v0.scale(this,this,J),this}setAxisAngle(J,Z){return v0.setAxisAngle(this,J,Z),this}slerp(J,Z){return v0.slerp(this,this,J,Z),this}toString(){return`${this.x},${this.y},${this.z},${this.w}`}}class yJ 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 yJ(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 yJ(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 Z4 extends Float32Array{constructor(J,Z,Y){super([J,Z,Y])}get length(){return $0.length(this)}get squaredLength(){return $0.squaredLength(this)}get magnitude(){return $0.length(this)}get squaredMagnitude(){return $0.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 Z4(0,0,0)}static fromVector3Like(J){return new Z4(J.x,J.y,J.z)}add(J){return $0.add(this,this,J),this}ceil(){return $0.ceil(this,this),this}clone(){return new Z4(this.x,this.y,this.z)}copy(J){return $0.copy(this,J),this}cross(J){return $0.cross(this,this,J),this}distance(J){return $0.distance(this,J)}divide(J){return $0.div(this,this,J),this}dot(J){return $0.dot(this,J)}equals(J){return $0.equals(this,J)}exactEquals(J){return $0.exactEquals(this,J)}floor(){return $0.floor(this,this),this}invert(){return $0.inverse(this,this),this}lerp(J,Z){return $0.lerp(this,this,J,Z),this}max(J){return $0.max(this,this,J),this}min(J){return $0.min(this,this,J),this}multiply(J){return $0.mul(this,this,J),this}negate(){return $0.negate(this,this),this}normalize(){return $0.normalize(this,this),this}randomize(J){return $0.random(this,J),this}rotateX(J,Z){return $0.rotateX(this,this,J,Z),this}rotateY(J,Z){return $0.rotateY(this,this,J,Z),this}rotateZ(J,Z){return $0.rotateZ(this,this,J,Z),this}round(){return $0.round(this,this),this}scale(J){return $0.scale(this,this,J),this}scaleAndAdd(J,Z){return $0.scaleAndAdd(this,this,J,Z),this}subtract(J){return $0.sub(this,this,J),this}toString(){return`${this.x},${this.y},${this.z}`}transformMatrix3(J){return $0.transformMat3(this,this,J),this}transformMatrix4(J){return $0.transformMat4(this,this,J),this}transformQuaternion(J){return $0.transformQuat(this,this,J),this}zero(){return $0.zero(this),this}}var j0=function(J,Z,Y,X){function K($){return $ instanceof Y?$:new Y(function(Q){Q($)})}return new(Y||(Y=Promise))(function($,Q){function F(V){try{W(X.next(V))}catch(q){Q(q)}}function G(V){try{W(X.throw(V))}catch(q){Q(q)}}function W(V){V.done?$(V.value):K(V.value).then(F,G)}W((X=X.apply(J,Z||[])).next())})},B0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=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 Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},m8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},F6=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))},WS=function(J){var Z=typeof Symbol==="function"&&Symbol.iterator,Y=Z&&J[Z],X=0;if(Y)return Y.call(J);if(J&&typeof J.length==="number")return{next:function(){if(J&&X>=J.length)J=void 0;return{value:J&&J[X++],done:!J}}};throw new TypeError(Z?"Object is not iterable.":"Symbol.iterator is not defined.")},VD0=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=this;this.compare=Z,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(X,K){return Y.compare(X,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 Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Z>Y)return[2,1];else if(Z<Y)return[2,-1];else return[2,0]})})},J.maxComparator=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){if(Y>Z)return[2,1];else if(Y<Z)return[2,-1];else return[2,0]})})},J.minComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z-Y]})})},J.maxComparatorNumber=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Y-Z]})})},J.defaultIsEqual=function(Z,Y){return j0(this,void 0,void 0,function(){return B0(this,function(X){return[2,Z===Y]})})},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var H="";for(;q>0;--q)H+=V;return H}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var H=Math.pow(2,Q-q)-1;return X(" ",Math.floor(H/2)*F)+V.map(function(U){var O=(F-U.length)/2;return X(" ",Math.ceil(O))+U+X(" ",Math.floor(O))}).join(X(" ",H*F))}).join(`
|
381
381
|
`)},J.heapify=function(Z,Y){return j0(this,void 0,void 0,function(){var X;return B0(this,function(K){switch(K.label){case 0:return X=new J(Y),X.heapArray=Z,[4,X.init()];case 1:return K.sent(),[2,X]}})})},J.heappop=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.pop()},J.heappush=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=Z,[4,K.push(Y)];case 1:return $.sent(),[2]}})})},J.heappushpop=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.pushpop(Y)},J.heapreplace=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.replace(Y)},J.heaptop=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.top(Y)},J.heapbottom=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.bottom(Y)},J.nlargest=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=F6([],m8(Y),!1),[4,K.init()];case 1:return $.sent(),[2,K.top(Z)]}})})},J.nsmallest=function(Z,Y,X){return j0(this,void 0,void 0,function(){var K;return B0(this,function($){switch($.label){case 0:return K=new J(X),K.heapArray=F6([],m8(Y),!1),[4,K.init()];case 1:return $.sent(),[2,K.bottom(Z)]}})})},J.prototype.add=function(Z){return j0(this,void 0,void 0,function(){return B0(this,function(Y){switch(Y.label){case 0:return[4,this._sortNodeUp(this.heapArray.push(Z)-1)];case 1:return Y.sent(),this._applyLimit(),[2,!0]}})})},J.prototype.addAll=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K;return B0(this,function($){switch($.label){case 0:Y=this.length,(K=this.heapArray).push.apply(K,F6([],m8(Z),!1)),X=this.length,$.label=1;case 1:if(!(Y<X))return[3,4];return[4,this._sortNodeUp(Y)];case 2:$.sent(),$.label=3;case 3:return++Y,[3,1];case 4:return this._applyLimit(),[2,!0]}})})},J.prototype.bottom=function(){return j0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return B0(this,function(Y){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,F6([],m8(this.heapArray),!1)];else return[2,this._bottomN_push(~~Z)]})})},J.prototype.check=function(){return j0(this,void 0,void 0,function(){var Z,Y,X,K,$,Q,F,G,W;return B0(this,function(V){switch(V.label){case 0:Z=0,V.label=1;case 1:if(!(Z<this.heapArray.length))return[3,10];Y=this.heapArray[Z],X=this.getChildrenOf(Z),V.label=2;case 2:V.trys.push([2,7,8,9]),K=(G=void 0,WS(X)),$=K.next(),V.label=3;case 3:if($.done)return[3,6];return Q=$.value,[4,this.compare(Y,Q)];case 4:if(V.sent()>0)return[2,Y];V.label=5;case 5:return $=K.next(),[3,3];case 6:return[3,9];case 7:return F=V.sent(),G={error:F},[3,9];case 8:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(G)throw G.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 j0(this,arguments,void 0,function(Y,X){var K,$,Q,F,G,W;if(X===void 0)X=J.defaultIsEqual;return B0(this,function(V){switch(V.label){case 0:V.trys.push([0,5,6,7]),K=WS(this.heapArray),$=K.next(),V.label=1;case 1:if($.done)return[3,4];return Q=$.value,[4,X(Q,Y)];case 2:if(V.sent())return[2,!0];V.label=3;case 3:return $=K.next(),[3,1];case 4:return[3,7];case 5:return F=V.sent(),G={error:F},[3,7];case 6:try{if($&&!$.done&&(W=K.return))W.call(K)}finally{if(G)throw G.error}return[7];case 7:return[2,!1]}})})},J.prototype.init=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:if(Z)this.heapArray=F6([],m8(Z),!1);Y=Math.floor(this.heapArray.length),X.label=1;case 1:if(!(Y>=0))return[3,4];return[4,this._sortNodeDown(Y)];case 2:X.sent(),X.label=3;case 3:return--Y,[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 j0(this,void 0,void 0,function(){var Z;return B0(this,function(Y){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 Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];return j0(this,void 0,void 0,function(){return B0(this,function(X){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 j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:return[4,this.compare(this.heapArray[0],Z)];case 1:if(!(X.sent()<0))return[3,3];return Y=m8([this.heapArray[0],Z],2),Z=Y[0],this.heapArray[0]=Y[1],[4,this._sortNodeDown(0)];case 2:X.sent(),X.label=3;case 3:return[2,Z]}})})},J.prototype.remove=function(Z){return j0(this,arguments,void 0,function(Y,X){var K,$,Q,F=this;if(X===void 0)X=J.defaultIsEqual;return B0(this,function(G){switch(G.label){case 0:if(!this.heapArray.length)return[2,!1];if(Y!==void 0)return[3,2];return[4,this.pop()];case 1:return G.sent(),[2,!0];case 2:K=[0],G.label=3;case 3:if(!K.length)return[3,13];return $=K.shift(),[4,X(this.heapArray[$],Y)];case 4:if(!G.sent())return[3,11];if($!==0)return[3,6];return[4,this.pop()];case 5:return G.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 G.sent(),[4,this._sortNodeDown($)];case 9:G.sent(),G.label=10;case 10:return[2,!0];case 11:Q=J.getChildrenIndexOf($).filter(function(W){return W<F.heapArray.length}),K.push.apply(K,F6([],m8(Q),!1)),G.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},J.prototype.replace=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:return Y=this.heapArray[0],this.heapArray[0]=Z,[4,this._sortNodeDown(0)];case 1:return X.sent(),[2,Y]}})})},J.prototype.size=function(){return this.length},J.prototype.top=function(){return j0(this,arguments,void 0,function(Z){if(Z===void 0)Z=1;return B0(this,function(Y){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,F6([],m8(this.heapArray),!1)];else return[2,this._topN_push(~~Z)]})})},J.prototype.toArray=function(){return F6([],m8(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 Y=this;return J.getChildrenIndexOf(Z).map(function(X){return Y.heapArray[X]}).filter(function(X){return X!==void 0})},J.prototype.getParentOf=function(Z){var Y=J.getParentIndexOf(Z);return this.heapArray[Y]},J.prototype[Symbol.iterator]=function(){return B0(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 j0(this,void 0,void 0,function(){var Y,X,K,$,F,Q,F;return B0(this,function(G){switch(G.label){case 0:return Y=new J(this.compare),Y.limit=Z,Y.heapArray=this.heapArray.slice(-Z),[4,Y.init()];case 1:G.sent(),X=this.heapArray.length-1-Z,K=J.getParentIndexOf(X),$=[];for(F=X;F>K;--F)$.push(F);Q=this.heapArray,G.label=2;case 2:if(!$.length)return[3,6];return F=$.shift(),[4,this.compare(Q[F],Y.peek())];case 3:if(!(G.sent()>0))return[3,5];return[4,Y.replace(Q[F])];case 4:if(G.sent(),F%2)$.push(J.getParentIndexOf(F));G.label=5;case 5:return[3,2];case 6:return[2,Y.toArray()]}})})},J.prototype._moveNode=function(Z,Y){var X;X=m8([this.heapArray[Y],this.heapArray[Z]],2),this.heapArray[Z]=X[0],this.heapArray[Y]=X[1]},J.prototype._sortNodeDown=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q,F;return B0(this,function(G){switch(G.label){case 0:Y=this.heapArray.length,G.label=1;case 1:if(X=2*Z+1,K=X+1,$=Z,Q=X<Y,!Q)return[3,3];return[4,this.compare(this.heapArray[X],this.heapArray[$])];case 2:Q=G.sent()<0,G.label=3;case 3:if(Q)$=X;if(F=K<Y,!F)return[3,5];return[4,this.compare(this.heapArray[K],this.heapArray[$])];case 4:F=G.sent()<0,G.label=5;case 5:if(F)$=K;if($===Z)return[3,7];this._moveNode(Z,$),Z=$,G.label=6;case 6:return[3,1];case 7:return[2]}})})},J.prototype._sortNodeUp=function(Z){return j0(this,void 0,void 0,function(){var Y;return B0(this,function(X){switch(X.label){case 0:if(!(Z>0))return[3,2];return Y=J.getParentIndexOf(Z),[4,this.compare(this.heapArray[Z],this.heapArray[Y])];case 1:if(X.sent()<0)this._moveNode(Z,Y),Z=Y;else return[3,2];return[3,0];case 2:return[2]}})})},J.prototype._topN_push=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$;return B0(this,function(Q){switch(Q.label){case 0:Y=new J(this._invertedCompare),Y.limit=Z,X=[0],K=this.heapArray,Q.label=1;case 1:if(!X.length)return[3,7];if($=X.shift(),!($<K.length))return[3,6];if(!(Y.length<Z))return[3,3];return[4,Y.push(K[$])];case 2:return Q.sent(),X.push.apply(X,F6([],m8(J.getChildrenIndexOf($)),!1)),[3,6];case 3:return[4,this.compare(K[$],Y.peek())];case 4:if(!(Q.sent()<0))return[3,6];return[4,Y.replace(K[$])];case 5:Q.sent(),X.push.apply(X,F6([],m8(J.getChildrenIndexOf($)),!1)),Q.label=6;case 6:return[3,1];case 7:return[2,Y.toArray()]}})})},J.prototype._topN_fill=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q,Q;return B0(this,function(F){switch(F.label){case 0:return Y=this.heapArray,X=new J(this._invertedCompare),X.limit=Z,X.heapArray=Y.slice(0,Z),[4,X.init()];case 1:F.sent(),K=J.getParentIndexOf(Z-1)+1,$=[];for(Q=K;Q<Z;++Q)$.push.apply($,F6([],m8(J.getChildrenIndexOf(Q).filter(function(G){return G<Y.length})),!1));if((Z-1)%2)$.push(Z);F.label=2;case 2:if(!$.length)return[3,6];if(Q=$.shift(),!(Q<Y.length))return[3,5];return[4,this.compare(Y[Q],X.peek())];case 3:if(!(F.sent()<0))return[3,5];return[4,X.replace(Y[Q])];case 4:F.sent(),$.push.apply($,F6([],m8(J.getChildrenIndexOf(Q)),!1)),F.label=5;case 5:return[3,2];case 6:return[2,X.toArray()]}})})},J.prototype._topN_heap=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$,Q;return B0(this,function(F){switch(F.label){case 0:Y=this.clone(),X=[],K=0,F.label=1;case 1:if(!(K<Z))return[3,4];return Q=($=X).push,[4,Y.pop()];case 2:Q.apply($,[F.sent()]),F.label=3;case 3:return++K,[3,1];case 4:return[2,X]}})})},J.prototype._topIdxOf=function(Z){return j0(this,void 0,void 0,function(){var Y,X,K,$;return B0(this,function(Q){switch(Q.label){case 0:if(!Z.length)return[2,-1];Y=0,X=Z[Y],K=1,Q.label=1;case 1:if(!(K<Z.length))return[3,4];return[4,this.compare(Z[K],X)];case 2:if($=Q.sent(),$<0)Y=K,X=Z[K];Q.label=3;case 3:return++K,[3,1];case 4:return[2,Y]}})})},J.prototype._topOf=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];return j0(this,void 0,void 0,function(){var X;return B0(this,function(K){switch(K.label){case 0:return X=new J(this.compare),[4,X.init(Z)];case 1:return K.sent(),[2,X.peek()]}})})},J}(),W$0=function(J,Z){var Y={label:0,sent:function(){if($[0]&1)throw $[1];return $[1]},trys:[],ops:[]},X,K,$,Q=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return Q.next=F(0),Q.throw=F(1),Q.return=F(2),typeof Symbol==="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function F(W){return function(V){return G([W,V])}}function G(W){if(X)throw new TypeError("Generator is already executing.");while(Q&&(Q=0,W[0]&&(Y=0)),Y)try{if(X=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 Y.label++,{value:W[1],done:!1};case 5:Y.label++,K=W[1],W=[0];continue;case 7:W=Y.ops.pop(),Y.trys.pop();continue;default:if(($=Y.trys,!($=$.length>0&&$[$.length-1]))&&(W[0]===6||W[0]===2)){Y=0;continue}if(W[0]===3&&(!$||W[1]>$[0]&&W[1]<$[3])){Y.label=W[1];break}if(W[0]===6&&Y.label<$[1]){Y.label=$[1],$=W;break}if($&&Y.label<$[2]){Y.label=$[2],Y.ops.push(W);break}if($[2])Y.ops.pop();Y.trys.pop();continue}W=Z.call(J,Y)}catch(V){W=[6,V],K=0}finally{X=$=0}if(W[0]&5)throw W[1];return{value:W[0]?W[1]:void 0,done:!0}}},U8=function(J,Z){var Y=typeof Symbol==="function"&&J[Symbol.iterator];if(!Y)return J;var X=Y.call(J),K,$=[],Q;try{while((Z===void 0||Z-- >0)&&!(K=X.next()).done)$.push(K.value)}catch(F){Q={error:F}}finally{try{if(K&&!K.done&&(Y=X.return))Y.call(X)}finally{if(Q)throw Q.error}}return $},S8=function(J,Z,Y){if(Y||arguments.length===2){for(var X=0,K=Z.length,$;X<K;X++)if($||!(X in Z)){if(!$)$=Array.prototype.slice.call(Z,0,X);$[X]=Z[X]}}return J.concat($||Array.prototype.slice.call(Z))};var VS=function(){function J(Z){if(Z===void 0)Z=J.minComparator;var Y=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(X,K){return-1*Y.compare(X,K)}}return J.getChildrenIndexOf=function(Z){return[Z*2+1,Z*2+2]},J.getParentIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:2;return Math.floor((Z-Y)/2)},J.getSiblingIndexOf=function(Z){if(Z<=0)return-1;var Y=Z%2?1:-1;return Z+Y},J.minComparator=function(Z,Y){if(Z>Y)return 1;else if(Z<Y)return-1;else return 0},J.maxComparator=function(Z,Y){if(Y>Z)return 1;else if(Y<Z)return-1;else return 0},J.minComparatorNumber=function(Z,Y){return Z-Y},J.maxComparatorNumber=function(Z,Y){return Y-Z},J.defaultIsEqual=function(Z,Y){return Z===Y},J.print=function(Z){function Y(V){var q=J.getParentIndexOf(V);return Math.floor(Math.log2(q+1))}function X(V,q){var H="";for(;q>0;--q)H+=V;return H}var K=0,$=[],Q=Y(Z.length-1)+2,F=0;while(K<Z.length){var G=Y(K)+1;if(K===0)G=0;var W=String(Z.get(K));if(W.length>F)F=W.length;$[G]=$[G]||[],$[G].push(W),K+=1}return $.map(function(V,q){var H=Math.pow(2,Q-q)-1;return X(" ",Math.floor(H/2)*F)+V.map(function(U){var O=(F-U.length)/2;return X(" ",Math.ceil(O))+U+X(" ",Math.floor(O))}).join(X(" ",H*F))}).join(`
|
382
382
|
`)},J.heapify=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.init(),X},J.heappop=function(Z,Y){var X=new J(Y);return X.heapArray=Z,X.pop()},J.heappush=function(Z,Y,X){var K=new J(X);K.heapArray=Z,K.push(Y)},J.heappushpop=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.pushpop(Y)},J.heapreplace=function(Z,Y,X){var K=new J(X);return K.heapArray=Z,K.replace(Y)},J.heaptop=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.top(Y)},J.heapbottom=function(Z,Y,X){if(Y===void 0)Y=1;var K=new J(X);return K.heapArray=Z,K.bottom(Y)},J.nlargest=function(Z,Y,X){var K=new J(X);return K.heapArray=S8([],U8(Y),!1),K.init(),K.top(Z)},J.nsmallest=function(Z,Y,X){var K=new J(X);return K.heapArray=S8([],U8(Y),!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 Y,X=this.length;(Y=this.heapArray).push.apply(Y,S8([],U8(Z),!1));for(var K=this.length;X<K;++X)this._sortNodeUp(X);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 S8([],U8(this.heapArray),!1);else return this._bottomN_push(~~Z)},J.prototype.check=function(){var Z=this;return this.heapArray.find(function(Y,X){return!!Z.getChildrenOf(X).find(function(K){return Z.compare(Y,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,Y){if(Y===void 0)Y=J.defaultIsEqual;return this.indexOf(Z,Y)!==-1},J.prototype.init=function(Z){if(Z)this.heapArray=S8([],U8(Z),!1);for(var Y=Math.floor(this.heapArray.length);Y>=0;--Y)this._sortNodeDown(Y);this._applyLimit()},J.prototype.isEmpty=function(){return this.length===0},J.prototype.indexOf=function(Z,Y){if(Y===void 0)Y=J.defaultIsEqual;if(this.heapArray.length===0)return-1;var X=[],K=0;while(K<this.heapArray.length){var $=this.heapArray[K];if(Y($,Z))return K;else if(this.compare($,Z)<=0)X.push.apply(X,S8([],U8(J.getChildrenIndexOf(K)),!1));K=X.shift()||this.heapArray.length}return-1},J.prototype.indexOfEvery=function(Z,Y){if(Y===void 0)Y=J.defaultIsEqual;if(this.heapArray.length===0)return[];var X=[],K=[],$=0;while($<this.heapArray.length){var Q=this.heapArray[$];if(Y(Q,Z))K.push($),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));else if(this.compare(Q,Z)<=0)X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));$=X.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 Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];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 Y;if(this.compare(this.heapArray[0],Z)<0)Y=U8([this.heapArray[0],Z],2),Z=Y[0],this.heapArray[0]=Y[1],this._sortNodeDown(0);return Z},J.prototype.remove=function(Z,Y){var X=this;if(Y===void 0)Y=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(Y(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(F){return F<X.heapArray.length});K.push.apply(K,S8([],U8(Q),!1))}}return!1},J.prototype.replace=function(Z){var Y=this.heapArray[0];return this.heapArray[0]=Z,this._sortNodeDown(0),Y},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 S8([],U8(this.heapArray),!1);else return this._topN_push(~~Z)},J.prototype.toArray=function(){return S8([],U8(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 Y=this;return J.getChildrenIndexOf(Z).map(function(X){return Y.heapArray[X]}).filter(function(X){return X!==void 0})},J.prototype.getParentOf=function(Z){var Y=J.getParentIndexOf(Z);return this.heapArray[Y]},J.prototype[Symbol.iterator]=function(){return W$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 Y=new J(this.compare);Y.limit=Z,Y.heapArray=this.heapArray.slice(-Z),Y.init();var X=this.heapArray.length-1-Z,K=J.getParentIndexOf(X),$=[];for(var Q=X;Q>K;--Q)$.push(Q);var F=this.heapArray;while($.length){var Q=$.shift();if(this.compare(F[Q],Y.peek())>0){if(Y.replace(F[Q]),Q%2)$.push(J.getParentIndexOf(Q))}}return Y.toArray()},J.prototype._moveNode=function(Z,Y){var X;X=U8([this.heapArray[Y],this.heapArray[Z]],2),this.heapArray[Z]=X[0],this.heapArray[Y]=X[1]},J.prototype._sortNodeDown=function(Z){var Y=this.heapArray.length;while(!0){var X=2*Z+1,K=X+1,$=Z;if(X<Y&&this.compare(this.heapArray[X],this.heapArray[$])<0)$=X;if(K<Y&&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 Y=J.getParentIndexOf(Z);if(this.compare(this.heapArray[Z],this.heapArray[Y])<0)this._moveNode(Z,Y),Z=Y;else break}},J.prototype._topN_push=function(Z){var Y=new J(this._invertedCompare);Y.limit=Z;var X=[0],K=this.heapArray;while(X.length){var $=X.shift();if($<K.length){if(Y.length<Z)Y.push(K[$]),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1));else if(this.compare(K[$],Y.peek())<0)Y.replace(K[$]),X.push.apply(X,S8([],U8(J.getChildrenIndexOf($)),!1))}}return Y.toArray()},J.prototype._topN_fill=function(Z){var Y=this.heapArray,X=new J(this._invertedCompare);X.limit=Z,X.heapArray=Y.slice(0,Z),X.init();var K=J.getParentIndexOf(Z-1)+1,$=[];for(var Q=K;Q<Z;++Q)$.push.apply($,S8([],U8(J.getChildrenIndexOf(Q).filter(function(F){return F<Y.length})),!1));if((Z-1)%2)$.push(Z);while($.length){var Q=$.shift();if(Q<Y.length){if(this.compare(Y[Q],X.peek())<0)X.replace(Y[Q]),$.push.apply($,S8([],U8(J.getChildrenIndexOf(Q)),!1))}}return X.toArray()},J.prototype._topN_heap=function(Z){var Y=this.clone(),X=[];for(var K=0;K<Z;++K)X.push(Y.pop());return X},J.prototype._topIdxOf=function(Z){if(!Z.length)return-1;var Y=0,X=Z[Y];for(var K=1;K<Z.length;++K){var $=this.compare(Z[K],X);if($<0)Y=K,X=Z[K]}return Y},J.prototype._topOf=function(){var Z=[];for(var Y=0;Y<arguments.length;Y++)Z[Y]=arguments[Y];var X=new J(this.compare);return X.init(Z),X.peek()},J}();class gJ extends a1{_faceSpeed=0;_faceTarget;_jumpHeight=0;_moveSpeed=0;_moveTarget;_moveIgnoreAxes={};_onFace;_onFaceComplete;_onMove;_onMoveComplete;face(J,Z,Y){this._faceTarget=J,this._faceSpeed=Z,this._onFace=Y?.faceCallback,this._onFaceComplete=Y?.faceCompleteCallback}jump(J){this._jumpHeight=J}move(J,Z,Y){this._moveTarget=J,this._moveSpeed=Z,this._moveIgnoreAxes=Y?.moveIgnoreAxes??{},this._onMove=Y?.moveCallback,this._onMoveComplete=Y?.moveCompleteCallback}tick(J,Z){if(super.tick(J,Z),!this._moveTarget&&!this._faceTarget&&!this._jumpHeight)return;let Y=Z/1000,X=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-X.x,y:this._moveIgnoreAxes.y?0:this._moveTarget.y-X.y,z:this._moveIgnoreAxes.z?0:this._moveTarget.z-X.z},$=K.x*K.x+K.y*K.y+K.z*K.z;if($>0.1){let Q=Math.sqrt($),F=this._moveSpeed*Y,W=Math.min(Q,F)/Q,V={x:X.x+K.x*W,y:X.y+K.y*W,z:X.z+K.z*W};if(J.setPosition(V),this._onMove)this._onMove(V,this._moveTarget)}else if(this._moveTarget=void 0,this._onMoveComplete){let Q=this._onMoveComplete;this._onMove=void 0,this._onMoveComplete=void 0,Q(X)}}if(this._faceTarget){let K={x:this._faceTarget.x-X.x,z:this._faceTarget.z-X.z},$=Math.atan2(-K.x,-K.z),Q=J.rotation,F=Math.atan2(2*(Q.w*Q.y),1-2*(Q.y*Q.y)),G=$-F;while(G>Math.PI)G-=2*Math.PI;while(G<-Math.PI)G+=2*Math.PI;if(Math.abs(G)>0.01){let W=this._faceSpeed*Y,V=Math.abs(G)<W?G:Math.sign(G)*W,H=(F+V)/2,U={x:0,y:Math.fround(Math.sin(H)),z:0,w:Math.fround(Math.cos(H))};if(J.setRotation(U),this._onFace)this._onFace(Q,U)}else if(this._faceTarget=void 0,this._onFaceComplete){let W=this._onFaceComplete;this._onFaceComplete=void 0,W(J.rotation)}}}}class Uq extends gJ{_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,Y){if(this._target=J,this._speed=Z,this._debug=Y?.debug??!1,this._maxFall=Y?.maxFall?-Math.abs(Y.maxFall):0,this._maxJump=Y?.maxJump?Math.abs(Y.maxJump):0,this._maxOpenSetIterations=Y?.maxOpenSetIterations??200,this._onPathfindAbort=Y?.pathfindAbortCallback,this._onPathfindComplete=Y?.pathfindCompleteCallback,this._onWaypointMoveComplete=Y?.waypointMoveCompleteCallback,this._onWaypointMoveSkipped=Y?.waypointMoveSkippedCallback,this._verticalPenalty=Y?.verticalPenalty??0,this._waypoints=[],this._waypointNextIndex=0,this._waypointTimeoutMs=Y?.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)throw new Error("PathfindingEntityController._calculatePath: No target or world");let J=this._entity.height,Z=this._findGroundedStart();if(!Z){if(this._debug)console.warn(`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 Y={x:Math.floor(this._target.x),y:Math.floor(this._target.y),z:Math.floor(this._target.z)},X=Math.abs(Y.x-Z.x),K=Math.abs(Y.y-Z.y),$=Math.abs(Y.z-Z.z);if(X<=2&&K<=2&&$<=2&&!this._isNeighborCoordinateBlocked(Z,Y,this._entity.height))return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5},{x:Y.x+0.5,y:Y.y+J/2,z:Y.z+0.5}],!0;if(Z.x===Y.x&&Z.y===Y.y&&Z.z===Y.z)return this._waypoints=[{x:Z.x+0.5,y:Z.y+J/2,z:Z.z+0.5}],!0;let F=this._coordinateToKey(Z),G=new Map,W=new Map([[F,0]]),V=new Map([[F,this._pathfindingHeuristic(Z,Y)]]),q=new Set,H=new VS((B,v)=>{let k=V.get(B[0])??1/0,w=V.get(v[0])??1/0;return k-w});H.push([F,Z]);let U=[{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}],O=[];for(let B=this._maxJump;B>=this._maxFall;B--){if(B===0)continue;let v=Math.abs(Z.y+B-Y.y);O.push({y:B,distanceToTargetY:v})}O.sort((B,v)=>B.distanceToTargetY-v.distanceToTargetY);let M=[...U,...O.flatMap(({y:B})=>U.map((v)=>({...v,y:B})))],L=0,R=Math.abs(Y.x-Z.x)+Math.abs(Y.y-Z.y)+Math.abs(Y.z-Z.z),P=Math.min(this._maxOpenSetIterations,R*20);while(!H.isEmpty()&&L<P){L++;let[B,v]=H.pop();if(v.x===Y.x&&v.y===Y.y&&v.z===Y.z){let x=this._reconstructPath(G,v);if(this._waypoints=x.map((_)=>({x:_.x+0.5,y:_.y+J/2,z:_.z+0.5})),this._debug)console.log(`PathfindingEntityController._calculatePath: Path found after ${L} open set iterations. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`);return!0}q.add(B);let k=W.get(B),w=new Map;for(let x of M){let _=`${x.x},${x.z}`,E=x.y<0;if(E&&w.has(_))continue;let C={x:v.x+x.x,y:v.y+x.y,z:v.z+x.z};if(Math.abs(Y.x-C.x)+Math.abs(Y.y-C.y)+Math.abs(Y.z-C.z)>R*1.5)continue;let f=this._coordinateToKey(C);if(q.has(f))continue;let p=this._isNeighborCoordinateBlocked(v,C,this._entity.height);if(E&&p){w.set(_,!0);continue}if(p)continue;let I=Math.abs(x.x),g=Math.abs(x.y),J0=Math.abs(x.z),y0=g===0?0:this._verticalPenalty,a0=(Math.max(I,g,J0)===1&&I+g+J0>1?1.4:1)+y0,G6=k+a0,a6=W.get(f)??1/0;if(G6>=a6)continue;G.set(f,v),W.set(f,G6);let Y4=G6+this._pathfindingHeuristic(C,Y);V.set(f,Y4),H.push([f,C])}}if(L>=P){if(this._onPathfindAbort?.(),this._debug)console.warn(`PathfindingEntityController._calculatePath: Maximum open set iterations reached (${P}), path search aborted. Start: ${this._coordinateToKey(Z)}, Target: ${this._coordinateToKey(this._target)}`)}else if(this._debug)console.warn(`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 Y=[Z],X=Z;while(J.has(this._coordinateToKey(X)))X=J.get(this._coordinateToKey(X)),Y.unshift(X);return Y}_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 Y=0;if(this._entity.isDynamic&&J&&Z.y>J.y){let X=Z.y-J.y,K=Math.min(X,this._maxJump)+0.75;this.jump(K);let $=Math.abs(this._entity.world.simulation.gravity.y),Q=Math.sqrt(2*$*K),F=J.x+0.5,G=J.z+0.5,W=Z.x+0.5,V=Z.z+0.5,q=W-F,H=V-G,U=Math.sqrt(q*q+H*H),O=Q/$,M=U/this._speed;Y=Math.min(O*0.8,M)*1000}setTimeout(()=>{if(!this._entity)return;let X=Date.now();this.face(Z,this._speed),this.move(Z,this._speed,{moveIgnoreAxes:{y:this._entity.isDynamic},moveCallback:()=>{if(Date.now()-X>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?.()}})},Y)}_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,Y){if(!this._entity?.world)return!1;let X=this._entity.world,K=Math.floor(Z.x),$=Math.floor(Z.y),Q=Math.floor(Z.z),F=Math.floor(J.x),G=Math.floor(J.z);if(!X.chunkLattice.hasBlock({x:K,y:$-1,z:Q}))return!0;for(let W=0;W<Y;W++)if(X.chunkLattice.hasBlock({x:K,y:$+W,z:Q}))return!0;if(K!==F&&Q!==G)for(let W=0;W<Y;W++){let V=X.chunkLattice.hasBlock({x:K,y:$+W,z:G}),q=X.chunkLattice.hasBlock({x:F,y:$+W,z:Q});if(V||q)return!0}return!1}_findGroundedStart(){if(!this._entity?.world)return;let{x:J,y:Z,z:Y}=this._entity.position,X={x:Math.floor(J),y:Math.floor(Z),z:Math.floor(Y)};for(let K=0;K<=Math.abs(this._maxFall);K++)if(this._entity.world.chunkLattice.hasBlock({...X,y:X.y-K-1}))return{...X,y:X.y-K};return}}export{xZ0 as startServer,HC as WorldLoopEvent,hJ as WorldLoop,Gq as WorldEvent,bJ as World,Jq as WebServerEvent,r5 as WebServer,Z4 as Vector3,yJ as Vector2,fJ as Ticker,Fq as SimulationEvent,SJ as Simulation,gJ as SimpleEntityController,IJ as SceneUIManager,Yq as SceneUIEvent,kJ as SceneUI,LC as SUPPORTED_INPUT_KEYS,F$ as RigidBodyType,h9 as RigidBody,WC as ROTATION_UPDATE_THRESHOLD,J4 as Quaternion,W$ as PlayerUIEvent,EJ as PlayerUI,oB as PlayerManagerEvent,Y8 as PlayerManager,xJ as PlayerEvent,jJ as PlayerEntityController,n1 as PlayerEntity,qC as PlayerCameraMode,$q as PlayerCameraEvent,_J as PlayerCamera,R5 as Player,b9 as PersistenceManager,Uq as PathfindingEntityController,GC as POSITION_UPDATE_THRESHOLD_SQ,eV as PORT,O6 as ModelRegistry,C8 as Matrix4,n6 as Matrix3,A9 as Matrix2,VC as LightType,DJ as LightManager,Xq as LightEvent,Kq as Light,zC as GameServerEvent,R1 as GameServer,s as EventRouter,TJ as EntityManager,G$ as EntityEvent,K8 as Entity,FC as DEFAULT_ENTITY_RIGID_BODY_OPTIONS,H6 as CollisionGroupsBuilder,e1 as CollisionGroup,XX as ColliderShape,CJ as ColliderMap,n8 as Collider,XG as CoefficientCombineRule,vJ as ChunkLattice,Zq as ChunkEvent,N8 as Chunk,pJ as ChatManager,Wq as ChatEvent,$G as BlockTypeRegistryEvent,i4 as BlockTypeRegistry,KG as BlockTypeEvent,M6 as BlockType,y9 as Block,Nq as BaseEntityControllerEvent,a1 as BaseEntityController,Q4 as AudioManager,w$ as AudioEvent,$4 as Audio};
|