hytopia 0.1.55 → 0.1.57

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.
Files changed (109) hide show
  1. package/boilerplate/index.ts +1 -1
  2. package/docs/server.baseentitycontroller.attach.md +53 -0
  3. package/docs/server.baseentitycontroller.despawn.md +53 -0
  4. package/docs/server.baseentitycontroller.detach.md +53 -0
  5. package/docs/server.baseentitycontroller.md +260 -0
  6. package/docs/server.baseentitycontroller.onattach.md +13 -0
  7. package/docs/server.baseentitycontroller.ondespawn.md +13 -0
  8. package/docs/server.baseentitycontroller.ondetach.md +13 -0
  9. package/docs/server.baseentitycontroller.onspawn.md +13 -0
  10. package/docs/server.baseentitycontroller.ontick.md +13 -0
  11. package/docs/server.baseentitycontroller.ontickwithplayerinput.md +13 -0
  12. package/docs/server.baseentitycontroller.spawn.md +53 -0
  13. package/docs/server.baseentitycontroller.tick.md +67 -0
  14. package/docs/{server.basecharactercontroller.tickwithplayerinput.md → server.baseentitycontroller.tickwithplayerinput.md} +20 -4
  15. package/docs/server.entity.controller.md +13 -0
  16. package/docs/server.entity.md +34 -18
  17. package/docs/server.entity.modelanimationsplaybackrate.md +13 -0
  18. package/docs/server.entity.setcontroller.md +53 -0
  19. package/docs/server.entity.setmodelanimationsplaybackrate.md +57 -0
  20. package/docs/server.entityeventpayload.md +9 -0
  21. package/docs/server.entityeventpayload.setmodelanimationsplaybackrate.entity.md +11 -0
  22. package/docs/server.entityeventpayload.setmodelanimationsplaybackrate.md +70 -0
  23. package/docs/server.entityeventpayload.setmodelanimationsplaybackrate.playbackrate.md +11 -0
  24. package/docs/server.entityeventtype.md +14 -0
  25. package/docs/server.entityoptions.controller.md +13 -0
  26. package/docs/server.entityoptions.md +22 -3
  27. package/docs/server.entityoptions.modelanimationsplaybackrate.md +13 -0
  28. package/docs/server.facecallback.md +1 -1
  29. package/docs/server.facecompletecallback.md +1 -1
  30. package/docs/server.faceoptions.md +1 -1
  31. package/docs/server.md +27 -27
  32. package/docs/server.movecallback.md +1 -1
  33. package/docs/server.movecompletecallback.md +1 -1
  34. package/docs/server.moveoptions.md +1 -1
  35. package/docs/server.playerentity.md +1 -1
  36. package/docs/server.playerentitycontroller._constructor_.md +49 -0
  37. package/docs/server.playerentitycontroller.attach.md +53 -0
  38. package/docs/server.playerentitycontroller.canjump.md +13 -0
  39. package/docs/server.playerentitycontroller.canrun.md +13 -0
  40. package/docs/server.playerentitycontroller.canwalk.md +13 -0
  41. package/docs/server.playerentitycontroller.isgrounded.md +13 -0
  42. package/docs/server.playerentitycontroller.isonplatform.md +13 -0
  43. package/docs/server.playerentitycontroller.jumpvelocity.md +13 -0
  44. package/docs/server.playerentitycontroller.md +331 -0
  45. package/docs/server.playerentitycontroller.platform.md +13 -0
  46. package/docs/server.playerentitycontroller.runvelocity.md +13 -0
  47. package/docs/server.playerentitycontroller.spawn.md +53 -0
  48. package/docs/{server.defaultcharactercontroller.tickwithplayerinput.md → server.playerentitycontroller.tickwithplayerinput.md} +20 -4
  49. package/docs/server.playerentitycontroller.walkvelocity.md +13 -0
  50. package/docs/server.playerentitycontrolleroptions.canjump.md +13 -0
  51. package/docs/server.playerentitycontrolleroptions.canrun.md +13 -0
  52. package/docs/server.playerentitycontrolleroptions.canwalk.md +13 -0
  53. package/docs/server.playerentitycontrolleroptions.jumpvelocity.md +13 -0
  54. package/docs/{server.defaultcharactercontrolleroptions.md → server.playerentitycontrolleroptions.md} +10 -10
  55. package/docs/server.playerentitycontrolleroptions.runvelocity.md +13 -0
  56. package/docs/server.playerentitycontrolleroptions.walkvelocity.md +13 -0
  57. package/docs/server.playerui.lockpointer.md +53 -0
  58. package/docs/server.playerui.md +14 -0
  59. package/docs/server.playeruieventpayload.lockpointer.lock.md +11 -0
  60. package/docs/server.playeruieventpayload.lockpointer.md +70 -0
  61. package/docs/server.playeruieventpayload.lockpointer.playerui.md +11 -0
  62. package/docs/server.playeruieventpayload.md +9 -0
  63. package/docs/server.playeruieventtype.md +14 -0
  64. package/docs/{server.simplecharactercontroller.face.md → server.simpleentitycontroller.face.md} +2 -2
  65. package/docs/{server.simplecharactercontroller.md → server.simpleentitycontroller.md} +11 -13
  66. package/docs/{server.simplecharactercontroller.move.md → server.simpleentitycontroller.move.md} +2 -2
  67. package/examples/block-entity/index.ts +7 -7
  68. package/examples/custom-ui/index.ts +1 -1
  69. package/examples/entity-controller/MyEntityController.ts +321 -0
  70. package/examples/entity-controller/README.md +4 -0
  71. package/examples/{character-controller → entity-controller}/index.ts +6 -11
  72. package/examples/{character-controller → entity-controller}/package.json +1 -1
  73. package/examples/payload-game/index.ts +18 -19
  74. package/package.json +1 -1
  75. package/server.api.json +4129 -3498
  76. package/server.d.ts +229 -167
  77. package/server.js +85 -85
  78. package/docs/server.basecharactercontroller._constructor_.md +0 -65
  79. package/docs/server.basecharactercontroller.createcolliders.md +0 -19
  80. package/docs/server.basecharactercontroller.entity.md +0 -13
  81. package/docs/server.basecharactercontroller.md +0 -197
  82. package/docs/server.basecharactercontroller.ontick.md +0 -13
  83. package/docs/server.basecharactercontroller.ontickwithplayerinput.md +0 -13
  84. package/docs/server.basecharactercontroller.tick.md +0 -53
  85. package/docs/server.defaultcharactercontroller._constructor_.md +0 -65
  86. package/docs/server.defaultcharactercontroller.canjump.md +0 -13
  87. package/docs/server.defaultcharactercontroller.canrun.md +0 -13
  88. package/docs/server.defaultcharactercontroller.canwalk.md +0 -13
  89. package/docs/server.defaultcharactercontroller.createcolliders.md +0 -19
  90. package/docs/server.defaultcharactercontroller.isgrounded.md +0 -13
  91. package/docs/server.defaultcharactercontroller.isonplatform.md +0 -13
  92. package/docs/server.defaultcharactercontroller.jumpvelocity.md +0 -13
  93. package/docs/server.defaultcharactercontroller.md +0 -319
  94. package/docs/server.defaultcharactercontroller.platform.md +0 -13
  95. package/docs/server.defaultcharactercontroller.runvelocity.md +0 -13
  96. package/docs/server.defaultcharactercontroller.walkvelocity.md +0 -13
  97. package/docs/server.defaultcharactercontrolleroptions.canjump.md +0 -13
  98. package/docs/server.defaultcharactercontrolleroptions.canrun.md +0 -13
  99. package/docs/server.defaultcharactercontrolleroptions.canwalk.md +0 -13
  100. package/docs/server.defaultcharactercontrolleroptions.jumpvelocity.md +0 -13
  101. package/docs/server.defaultcharactercontrolleroptions.runvelocity.md +0 -13
  102. package/docs/server.defaultcharactercontrolleroptions.walkvelocity.md +0 -13
  103. package/docs/server.entity.charactercontroller.md +0 -13
  104. package/docs/server.entity.createcustomcharactercontroller.md +0 -13
  105. package/docs/server.entity.setcharactercontroller.md +0 -53
  106. package/docs/server.entityoptions.createcustomcharactercontroller.md +0 -13
  107. package/examples/character-controller/MyCharacterController.ts +0 -250
  108. package/examples/character-controller/README.md +0 -4
  109. /package/examples/{character-controller → entity-controller}/assets/map.json +0 -0
package/server.d.ts CHANGED
@@ -277,58 +277,96 @@ export declare interface AudioOptions {
277
277
  }
278
278
 
279
279
  /**
280
- * A base class for character controller implementations.
280
+ * A base class for entity controller implementations.
281
281
  *
282
282
  * @remarks
283
- * The BaseCharacterController should be extended
284
- * by a more specific character controller that you or a
285
- * plugin implements.
283
+ * The BaseEntityController should be extended
284
+ * by a more specific entity controller that you or a
285
+ * plugin implements. Entity controllers are intended to
286
+ * be used as one controller instance per entity, but
287
+ * are flexible enough for edge cases such as if you want to create
288
+ * niche behavior of one controller for many entities that
289
+ * behave in unison.
286
290
  *
287
291
  * @public
288
292
  */
289
- export declare abstract class BaseCharacterController {
290
- /** The entity the controller is for. */
291
- readonly entity: Entity;
293
+ export declare abstract class BaseEntityController {
292
294
  /**
293
- * A callback function for when the controller ticks.
294
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
295
+ * A function that is called every tick. Useful for implementing
296
+ * tick logic without writing a new entity controller class.
295
297
  */
296
- onTick?: (deltaTimeMs: number) => void;
298
+ onTick?: (entity: Entity, deltaTimeMs: number) => void;
297
299
  /**
298
- * A callback function for when the controller ticks
299
- * player movement.
300
- * @param input - The current input state of the player.
301
- * @param cameraOrientation - The current camera orientation state of the player.
302
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
300
+ * A function that is called every tick with player input by a
301
+ * PlayerEntity with this controller attached. Useful for implementing
302
+ * tick logic without writing a new entity controller class.
303
+ */
304
+ onTickWithPlayerInput?: (entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number) => void;
305
+ /**
306
+ * A function that is called when the controller is attached to an entity.
307
+ * Useful for implementing attach logic without writing a
308
+ * new entity controller class.
309
+ */
310
+ onAttach?: (entity: Entity) => void;
311
+ /**
312
+ * A function that is called when the controlled entity is despawned.
313
+ * Useful for implementing despawn logic without writing a
314
+ * new entity controller class.
315
+ */
316
+ onDespawn?: (entity: Entity) => void;
317
+ /**
318
+ * A function that is called when the controller is detached from an entity.
319
+ * Useful for implementing detach logic without writing a
320
+ * new entity controller class.
321
+ */
322
+ onDetach?: (entity: Entity) => void;
323
+ /**
324
+ * A function that is called when the controlled entity is spawned.
325
+ * Useful for implementing spawn logic without writing a
326
+ * new entity controller class.
327
+ */
328
+ onSpawn?: (entity: Entity) => void;
329
+ /**
330
+ * Override this method to handle the attachment of an entity
331
+ * to your entity controller.
332
+ * @param entity - The entity to attach the controller to.
333
+ */
334
+ attach(entity: Entity): void;
335
+ /**
336
+ * Override this method to handle the despawn of an entity
337
+ * from your entity controller.
338
+ * @param entity - The entity to despawn.
303
339
  */
304
- onTickWithPlayerInput?: (input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number) => void;
340
+ despawn(entity: Entity): void;
305
341
  /**
306
- * @param entity - The entity the controller is for.
307
- * @param _options - Arbitrary options you may provide or omit for your controller implementation.
342
+ * Override this method to handle the detachment of an entity
343
+ * from your entity controller.
344
+ * @param entity - The entity to detach.
308
345
  */
309
- constructor(entity: Entity, _options?: Record<string, unknown>);
346
+ detach(entity: Entity): void;
310
347
  /**
311
- * Override this method to create controller specific colliders
312
- * to be attached to the controlled entity when it spawns.
313
- * @returns An array of colliders.
348
+ * Override this method to handle the spawning of an entity
349
+ * to your entity controller.
350
+ * @param entity - The entity to spawn.
314
351
  */
315
- createColliders(): Collider[];
352
+ spawn(entity: Entity): void;
316
353
  /**
317
354
  * Override this method to handle entity movements
318
- * based on player input for your character controller.
355
+ * based on player input for your entity controller.
319
356
  * This is called every tick by a PlayerEntity with a
320
- * character controller.
357
+ * entity controller.
358
+ * @param entity - The entity to tick.
321
359
  * @param input - The current input state of the player.
322
360
  * @param cameraOrientation - The current camera orientation state of the player.
323
361
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
324
362
  */
325
- tickWithPlayerInput(input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
363
+ tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
326
364
  /**
327
365
  * Override this method to handle entity movements
328
- * based on your character controller.
366
+ * based on your entity controller.
329
367
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
330
368
  */
331
- tick(deltaTimeMs: number): void;
369
+ tick(entity: Entity, deltaTimeMs: number): void;
332
370
  }
333
371
 
334
372
  /**
@@ -1141,105 +1179,6 @@ export declare const DEFAULT_BLOCK_ENTITY_RIGID_BODY_OPTIONS: RigidBodyOptions;
1141
1179
  /** The default rigid body options for a model entity when EntityOptions.rigidBodyOptions is not provided. @public */
1142
1180
  export declare const DEFAULT_ENTITY_RIGID_BODY_OPTIONS: RigidBodyOptions;
1143
1181
 
1144
- /**
1145
- * The default character controller implementation.
1146
- *
1147
- * @remarks
1148
- * This class extends {@link BaseCharacterController}
1149
- * and implements the default movement logic for a
1150
- * character entity. This is used as the default for
1151
- * players when they join your game. This class may be extended
1152
- * if you'd like to implement additional logic on top of the
1153
- * DefaultCharacterController implementation.
1154
- *
1155
- * @example
1156
- * ```typescript
1157
- * // Create a custom character controller for myEntity, prior to spawning it.
1158
- * myEntity.createCustomCharacterController = () => {
1159
- * return new DefaultCharacterController(myEntity, {
1160
- * jumpVelocity: 10,
1161
- * runVelocity: 8,
1162
- * walkVelocity: 4,
1163
- * });
1164
- * };
1165
- *
1166
- * // Spawn the entity in the world.
1167
- * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
1168
- * ```
1169
- *
1170
- * @public
1171
- */
1172
- export declare class DefaultCharacterController extends BaseCharacterController {
1173
- /** The upward velocity applied to the entity when it jumps. */
1174
- jumpVelocity: number;
1175
- /** The normalized horizontal velocity applied to the entity when it runs. */
1176
- runVelocity: number;
1177
- /** The normalized horizontal velocity applied to the entity when it walks. */
1178
- walkVelocity: number;
1179
- /**
1180
- * A function allowing custom logic to determine if the entity can walk.
1181
- * @param defaultCharacterController - The character controller instance.
1182
- * @returns Whether the entity of the character controller can walk.
1183
- */
1184
- canWalk: (defaultCharacterController: DefaultCharacterController) => boolean;
1185
- /**
1186
- * A function allowing custom logic to determine if the entity can run.
1187
- * @param defaultCharacterController - The character controller instance.
1188
- * @returns Whether the entity of the character controller can run.
1189
- */
1190
- canRun: (defaultCharacterController: DefaultCharacterController) => boolean;
1191
- /**
1192
- * A function allowing custom logic to determine if the entity can jump.
1193
- * @param defaultCharacterController - The character controller instance.
1194
- * @returns Whether the entity of the character controller can jump.
1195
- */
1196
- canJump: (defaultCharacterController: DefaultCharacterController) => boolean;
1197
-
1198
-
1199
-
1200
- /**
1201
- * @param entity - The entity the controller is for.
1202
- * @param options - Options for the controller.
1203
- */
1204
- constructor(entity: Entity, options?: DefaultCharacterControllerOptions);
1205
- /** Whether the entity is grounded. */
1206
- get isGrounded(): boolean;
1207
- /** Whether the entity is on a platform, a platform is any entity with a kinematic rigid body. */
1208
- get isOnPlatform(): boolean;
1209
- /** The platform the entity is on, if any. */
1210
- get platform(): Entity | undefined;
1211
- /**
1212
- * Creates the colliders for the character controller,
1213
- * overriding the default implementation.
1214
- * @returns An array of colliders.
1215
- */
1216
- createColliders(): Collider[];
1217
- /**
1218
- * Ticks the player movement for the character controller,
1219
- * overriding the default implementation.
1220
- * @param input - The current input state of the player.
1221
- * @param cameraOrientation - The current camera orientation state of the player.
1222
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
1223
- */
1224
- tickWithPlayerInput(input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
1225
- }
1226
-
1227
- /** Options for creating a DefaultCharacterController instance. @public */
1228
- export declare interface DefaultCharacterControllerOptions {
1229
- /** The upward velocity applied to the entity when it jumps. */
1230
- jumpVelocity?: number;
1231
- /** The normalized horizontal velocity applied to the entity when it runs. */
1232
- runVelocity?: number;
1233
- /** The normalized horizontal velocity applied to the entity when it walks. */
1234
- walkVelocity?: number;
1235
- /** A function allowing custom logic to determine if the entity can jump. */
1236
- canJump?: () => boolean;
1237
- /** A function allowing custom logic to determine if the entity can walk. */
1238
- canWalk?: () => boolean;
1239
- /** A function allowing custom logic to determine if the entity can run. */
1240
- canRun?: () => boolean;
1241
- }
1242
-
1243
1182
  /**
1244
1183
  * Represents an entity in a world.
1245
1184
  *
@@ -1276,12 +1215,6 @@ export declare interface DefaultCharacterControllerOptions {
1276
1215
  * @public
1277
1216
  */
1278
1217
  export declare class Entity extends RigidBody implements protocol.Serializable {
1279
- /**
1280
- * A function that creates a custom character controller for the entity when it spawns.
1281
- * @param entity - The Entity instance the character controller is created for.
1282
- * @returns A character controller that extends {@link BaseCharacterController}.
1283
- */
1284
- createCustomCharacterController?: (entity: Entity) => BaseCharacterController;
1285
1218
  /**
1286
1219
  * A function that is called when the entity collides with a block.
1287
1220
  *
@@ -1357,26 +1290,29 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1357
1290
 
1358
1291
 
1359
1292
 
1293
+
1360
1294
  /**
1361
1295
  * @param options - The options for the entity.
1362
1296
  */
1363
1297
  constructor(options: EntityOptions);
1364
1298
  /** The unique identifier for the entity. */
1365
1299
  get id(): number | undefined;
1366
- /** The character controller for the entity. */
1367
- get characterController(): BaseCharacterController | undefined;
1368
1300
  /** The half extends of the visual size of the block entity when blockTextureUri is set. */
1369
1301
  get blockHalfExtents(): Vector3Like | undefined;
1370
1302
  /** The URI or path to the texture to be used, if this is set, the entity is a block entity. */
1371
1303
  get blockTextureUri(): string | undefined;
1372
- /** The URI or path to the .gltf model asset to be used for the entity. */
1373
- get modelUri(): string | undefined;
1304
+ /** The controller for the entity. */
1305
+ get controller(): BaseEntityController | undefined;
1306
+ /** The playback rate of the entity's model animations. */
1307
+ get modelAnimationsPlaybackRate(): number;
1374
1308
  /** The nodes to hide on the entity's model. */
1375
1309
  get modelHiddenNodes(): ReadonlySet<string>;
1376
1310
  /** The looped animations to start when the entity is spawned. */
1377
1311
  get modelLoopedAnimations(): ReadonlySet<string>;
1378
1312
  /** The scale of the entity's model. */
1379
1313
  get modelScale(): number | undefined;
1314
+ /** The URI or path to the .gltf model asset to be used for the entity. */
1315
+ get modelUri(): string | undefined;
1380
1316
  /** The name of the entity. */
1381
1317
  get name(): string;
1382
1318
  /** An arbitrary identifier tag of the entity. Useful for your own logic. */
@@ -1402,10 +1338,21 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1402
1338
  */
1403
1339
  despawn(): void;
1404
1340
  /**
1405
- * Sets the character controller for the entity.
1406
- * @param characterController - The character controller to set.
1341
+ * Sets the playback rate of all animations on the entity's model.
1342
+ *
1343
+ * @remarks
1344
+ * Defaults to 1. A positive value will play the animation forward,
1345
+ * a negative value will play the animation in reverse. Any value may be used.
1346
+ * You can make animations play faster by using larger values.
1347
+ *
1348
+ * @param playbackRate - The playback rate of the entity's model animations.
1349
+ */
1350
+ setModelAnimationsPlaybackRate(playbackRate: number): void;
1351
+ /**
1352
+ * Sets the controller for the entity.
1353
+ * @param controller - The controller to set.
1407
1354
  */
1408
- setCharacterController(characterController: BaseCharacterController): void;
1355
+ setController(controller: BaseEntityController | undefined): void;
1409
1356
  /**
1410
1357
  * Sets the nodes to hide on the entity's model. Matched nodes
1411
1358
  * will be hidden for all players. Uses case insensitive
@@ -1463,6 +1410,10 @@ export declare namespace EntityEventPayload {
1463
1410
  export interface Despawn {
1464
1411
  entity: Entity;
1465
1412
  }
1413
+ export interface SetModelAnimationsPlaybackRate {
1414
+ entity: Entity;
1415
+ playbackRate: number;
1416
+ }
1466
1417
  export interface SetModelHiddenNodes {
1467
1418
  entity: Entity;
1468
1419
  modelHiddenNodes: Set<string>;
@@ -1499,6 +1450,7 @@ export declare namespace EntityEventPayload {
1499
1450
  /** Event types an Entity instance can emit. @public */
1500
1451
  export declare enum EntityEventType {
1501
1452
  DESPAWN = "ENTITY.DESPAWN",
1453
+ SET_MODEL_ANIMATIONS_PLAYBACK_RATE = "ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",
1502
1454
  SET_MODEL_HIDDEN_NODES = "ENTITY.SET_MODEL_HIDDEN_NODES",
1503
1455
  SET_TINT_COLOR = "ENTITY.SET_TINT_COLOR",
1504
1456
  SPAWN = "ENTITY.SPAWN",
@@ -1575,20 +1527,18 @@ export declare interface EntityOptions {
1575
1527
  blockHalfExtents?: Vector3Like;
1576
1528
  /** The texture uri of a entity if the entity is a block entity, if set rigidBodyOptions collider shape [0] must be a block */
1577
1529
  blockTextureUri?: string;
1578
- /**
1579
- * A function that creates a custom character controller for the entity when it spawns.
1580
- * @param entity - The Entity instance.
1581
- * @returns A character controller that extends {@link BaseCharacterController}.
1582
- */
1583
- createCustomCharacterController?: (entity: Entity) => BaseCharacterController;
1584
- /** The URI or path to the .gltf model asset to be used for the entity. */
1585
- modelUri?: string;
1530
+ /** The entity controller to use for the entity. */
1531
+ controller?: BaseEntityController;
1532
+ /** The playback rate of the entity's model animations. */
1533
+ modelAnimationsPlaybackRate?: number;
1586
1534
  /** The nodes to hide on the entity's model. */
1587
1535
  modelHiddenNodes?: string[];
1588
1536
  /** The looped animations to start when the entity is spawned. */
1589
1537
  modelLoopedAnimations?: string[];
1590
1538
  /** The scale of the entity's model. */
1591
1539
  modelScale?: number;
1540
+ /** The URI or path to the .gltf model asset to be used for the entity. */
1541
+ modelUri?: string;
1592
1542
  /** The name of the entity. */
1593
1543
  name?: string;
1594
1544
  /** The rigid body options for the entity. */
@@ -1675,7 +1625,7 @@ export declare class EventRouter {
1675
1625
 
1676
1626
  /**
1677
1627
  * A callback function called when the entity associated with the
1678
- * SimpleCharacterController updates its rotation as it is
1628
+ * SimpleEntityController updates its rotation as it is
1679
1629
  * attempting to face a target coordinate.
1680
1630
  * @param currentRotation - The current rotation of the entity.
1681
1631
  * @param targetRotation - The target rotation of the entity.
@@ -1685,7 +1635,7 @@ export declare type FaceCallback = (currentRotation: QuaternionLike, targetRotat
1685
1635
 
1686
1636
  /**
1687
1637
  * A callback function called when the entity associated with the
1688
- * SimpleCharacterController finishes rotating and is now facing
1638
+ * SimpleEntityController finishes rotating and is now facing
1689
1639
  * a target coordinate.
1690
1640
  * @param endRotation - The rotation of the entity after it has finished rotating.
1691
1641
  * @public
@@ -1693,7 +1643,7 @@ export declare type FaceCallback = (currentRotation: QuaternionLike, targetRotat
1693
1643
  export declare type FaceCompleteCallback = (endRotation: QuaternionLike) => void;
1694
1644
 
1695
1645
  /**
1696
- * Options for the {@link SimpleCharacterController.face} method.
1646
+ * Options for the {@link SimpleEntityController.face} method.
1697
1647
  * @public
1698
1648
  */
1699
1649
  export declare type FaceOptions = {
@@ -1750,7 +1700,7 @@ export declare enum GameServerEventType {
1750
1700
 
1751
1701
  /**
1752
1702
  * A callback function called when the entity associated with the
1753
- * SimpleCharacterController updates its position as it is
1703
+ * SimpleEntityController updates its position as it is
1754
1704
  * attempting to move to a target coordinate.
1755
1705
  * @param currentPosition - The current position of the entity.
1756
1706
  * @param targetPosition - The target position of the entity.
@@ -1760,7 +1710,7 @@ export declare type MoveCallback = (currentPosition: Vector3Like, targetPosition
1760
1710
 
1761
1711
  /**
1762
1712
  * A callback function called when the entity associated with the
1763
- * SimpleCharacterController reaches the target coordinate. An entity
1713
+ * SimpleEntityController reaches the target coordinate. An entity
1764
1714
  * must reach the x,y,z coordinate for the callback to be called.
1765
1715
  * @param endPosition - The position of the entity after it has finished moving.
1766
1716
  * @public
@@ -1768,15 +1718,15 @@ export declare type MoveCallback = (currentPosition: Vector3Like, targetPosition
1768
1718
  export declare type MoveCompleteCallback = (endPosition: Vector3Like) => void;
1769
1719
 
1770
1720
  /**
1771
- * Options for the {@link SimpleCharacterController.move} method.
1721
+ * Options for the {@link SimpleEntityController.move} method.
1772
1722
  * @public
1773
1723
  */
1774
1724
  export declare type MoveOptions = {
1775
- /** Callback called each tick movement of the character controller's entity. */
1725
+ /** Callback called each tick movement of the entity controller's entity. */
1776
1726
  moveCallback?: MoveCallback;
1777
- /** Callback called when the character controller's entity has finished moving. */
1727
+ /** Callback called when the entity controller's entity has finished moving. */
1778
1728
  moveCompleteCallback?: MoveCompleteCallback;
1779
- /** Axes to ignore when moving the character controller's entity. Also ignored for determining completion. */
1729
+ /** Axes to ignore when moving the entity controller's entity. Also ignored for determining completion. */
1780
1730
  moveIgnoreAxes?: {
1781
1731
  x?: boolean;
1782
1732
  y?: boolean;
@@ -2071,8 +2021,8 @@ export declare type PlayerCameraOrientation = {
2071
2021
  * They can be created and assigned to a player when
2072
2022
  * a player joins a world. PlayerEntity automatically
2073
2023
  * handles mapping player inputs to the associated
2074
- * character controller of the entity, calling the
2075
- * character controller's onTickPlayerMovement method
2024
+ * entity controller of the entity, calling the
2025
+ * entity controller's onTickPlayerMovement method
2076
2026
  * when player input has changed.
2077
2027
  *
2078
2028
  * @example
@@ -2102,6 +2052,110 @@ export declare class PlayerEntity extends Entity {
2102
2052
 
2103
2053
  }
2104
2054
 
2055
+ /**
2056
+ * The player entity controller implementation.
2057
+ *
2058
+ * @remarks
2059
+ * This class extends {@link BaseEntityController}
2060
+ * and implements the default movement logic for a
2061
+ * entity. This is used as the default for
2062
+ * players when they join your game. This class may be extended
2063
+ * if you'd like to implement additional logic on top of the
2064
+ * PlayerEntityController implementation.
2065
+ *
2066
+ * @example
2067
+ * ```typescript
2068
+ * // Create a custom entity controller for myEntity, prior to spawning it.
2069
+ * myEntity.setController(new PlayerEntityController(myEntity, {
2070
+ * jumpVelocity: 10,
2071
+ * runVelocity: 8,
2072
+ * walkVelocity: 4,
2073
+ * }));
2074
+ *
2075
+ * // Spawn the entity in the world.
2076
+ * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
2077
+ * ```
2078
+ *
2079
+ * @public
2080
+ */
2081
+ export declare class PlayerEntityController extends BaseEntityController {
2082
+ /** The upward velocity applied to the entity when it jumps. */
2083
+ jumpVelocity: number;
2084
+ /** The normalized horizontal velocity applied to the entity when it runs. */
2085
+ runVelocity: number;
2086
+ /** The normalized horizontal velocity applied to the entity when it walks. */
2087
+ walkVelocity: number;
2088
+ /**
2089
+ * A function allowing custom logic to determine if the entity can walk.
2090
+ * @param playerEntityController - The entity controller instance.
2091
+ * @returns Whether the entity of the entity controller can walk.
2092
+ */
2093
+ canWalk: (playerEntityController: PlayerEntityController) => boolean;
2094
+ /**
2095
+ * A function allowing custom logic to determine if the entity can run.
2096
+ * @param playerEntityController - The entity controller instance.
2097
+ * @returns Whether the entity of the entity controller can run.
2098
+ */
2099
+ canRun: (playerEntityController: PlayerEntityController) => boolean;
2100
+ /**
2101
+ * A function allowing custom logic to determine if the entity can jump.
2102
+ * @param playerEntityController - The entity controller instance.
2103
+ * @returns Whether the entity of the entity controller can jump.
2104
+ */
2105
+ canJump: (playerEntityController: PlayerEntityController) => boolean;
2106
+
2107
+
2108
+
2109
+ /**
2110
+ * @param options - Options for the controller.
2111
+ */
2112
+ constructor(options?: PlayerEntityControllerOptions);
2113
+ /** Whether the entity is grounded. */
2114
+ get isGrounded(): boolean;
2115
+ /** Whether the entity is on a platform, a platform is any entity with a kinematic rigid body. */
2116
+ get isOnPlatform(): boolean;
2117
+ /** The platform the entity is on, if any. */
2118
+ get platform(): Entity | undefined;
2119
+ /**
2120
+ * Called when the controller is attached to an entity.
2121
+ * @param entity - The entity to attach the controller to.
2122
+ */
2123
+ attach(entity: Entity): void;
2124
+ /**
2125
+ * Called when the controlled entity is spawned.
2126
+ * In PlayerEntityController, this function is used to create
2127
+ * the colliders for the entity for wall and ground detection.
2128
+ * @param entity - The entity that is spawned.
2129
+ */
2130
+ spawn(entity: Entity): void;
2131
+ /**
2132
+ * Ticks the player movement for the entity controller,
2133
+ * overriding the default implementation.
2134
+ *
2135
+ * @param entity - The entity to tick.
2136
+ * @param input - The current input state of the player.
2137
+ * @param cameraOrientation - The current camera orientation state of the player.
2138
+ * @param deltaTimeMs - The delta time in milliseconds since the last tick.
2139
+ */
2140
+ tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
2141
+ }
2142
+
2143
+ /** Options for creating a PlayerEntityController instance. @public */
2144
+ export declare interface PlayerEntityControllerOptions {
2145
+ /** The upward velocity applied to the entity when it jumps. */
2146
+ jumpVelocity?: number;
2147
+ /** The normalized horizontal velocity applied to the entity when it runs. */
2148
+ runVelocity?: number;
2149
+ /** The normalized horizontal velocity applied to the entity when it walks. */
2150
+ walkVelocity?: number;
2151
+ /** A function allowing custom logic to determine if the entity can jump. */
2152
+ canJump?: () => boolean;
2153
+ /** A function allowing custom logic to determine if the entity can walk. */
2154
+ canWalk?: () => boolean;
2155
+ /** A function allowing custom logic to determine if the entity can run. */
2156
+ canRun?: () => boolean;
2157
+ }
2158
+
2105
2159
  /** Options for creating a PlayerEntity instance. @public */
2106
2160
  export declare interface PlayerEntityOptions extends EntityOptions {
2107
2161
  /** The player the player entity is assigned to. */
@@ -2212,6 +2266,11 @@ export declare class PlayerUI {
2212
2266
  * @param htmlUri - The ui html uri to load.
2213
2267
  */
2214
2268
  load(htmlUri: string): void;
2269
+ /**
2270
+ * Locks or unlocks the player's mouse pointer.
2271
+ * @param lock - Set true to lock the pointer, false to unlock it.
2272
+ */
2273
+ lockPointer(lock: boolean): void;
2215
2274
  /**
2216
2275
  * Sends data to the player's client UI.
2217
2276
  * @param data - The data to send to the client UI.
@@ -2225,6 +2284,10 @@ export declare namespace PlayerUIEventPayload {
2225
2284
  playerUI: PlayerUI;
2226
2285
  htmlUri: string;
2227
2286
  }
2287
+ export interface LockPointer {
2288
+ playerUI: PlayerUI;
2289
+ lock: boolean;
2290
+ }
2228
2291
  export interface SendData {
2229
2292
  playerUI: PlayerUI;
2230
2293
  data: object;
@@ -2234,6 +2297,7 @@ export declare namespace PlayerUIEventPayload {
2234
2297
  /** Event types a PlayerUI can emit. @public */
2235
2298
  export declare enum PlayerUIEventType {
2236
2299
  LOAD = "PLAYER_UI.LOAD",
2300
+ LOCK_POINTER = "PLAYER_UI.LOCK_POINTER",
2237
2301
  SEND_DATA = "PLAYER_UI.SEND_DATA"
2238
2302
  }
2239
2303
 
@@ -2824,22 +2888,20 @@ export declare enum RigidBodyType {
2824
2888
  }
2825
2889
 
2826
2890
  /**
2827
- * A simple character controller with basic movement functions.
2891
+ * A simple entity controller with basic movement functions.
2828
2892
  *
2829
2893
  * @remarks
2830
2894
  * This class implements simple movement methods that serve
2831
2895
  * as a way to add realistic movement and rotational facing
2832
2896
  * functionality to an entity. This is also a great base to
2833
- * extend for your own more complex character controller
2897
+ * extend for your own more complex entity controller
2834
2898
  * that implements things like pathfinding. Compatible with
2835
2899
  * entities that have kinematic or dynamic rigid body types.
2836
2900
  *
2837
2901
  * @example
2838
2902
  * ```typescript
2839
- * // Create a custom character controller for myEntity, prior to spawning it.
2840
- * myEntity.createCustomCharacterController = () => {
2841
- * return new SimpleCharacterController(myEntity);
2842
- * };
2903
+ * // Create a custom entity controller for myEntity, prior to spawning it.
2904
+ * myEntity.setController(new SimpleEntityController());
2843
2905
  *
2844
2906
  * // Spawn the entity in the world.
2845
2907
  * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
@@ -2847,7 +2909,7 @@ export declare enum RigidBodyType {
2847
2909
  * // Move the entity at a speed of 4 blocks
2848
2910
  * // per second to the coordinate (10, 1, 10).
2849
2911
  * // console.log when we reach the target.
2850
- * myEntity.characterController.move({ x: 10, y: 1, z: 10 }, 4, {
2912
+ * myEntity.controller.move({ x: 10, y: 1, z: 10 }, 4, {
2851
2913
  * moveCompleteCallback: endPosition => {
2852
2914
  * console.log('Finished moving to', endPosition);
2853
2915
  * },
@@ -2856,7 +2918,7 @@ export declare enum RigidBodyType {
2856
2918
  *
2857
2919
  * @public
2858
2920
  */
2859
- export declare class SimpleCharacterController extends BaseCharacterController {
2921
+ export declare class SimpleEntityController extends BaseEntityController {
2860
2922
 
2861
2923
 
2862
2924