hytopia 0.1.56 → 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 (102) hide show
  1. package/boilerplate/index.ts +1 -1
  2. package/docs/{server.basecharactercontroller.attach.md → server.baseentitycontroller.attach.md} +3 -3
  3. package/docs/{server.basecharactercontroller.despawn.md → server.baseentitycontroller.despawn.md} +3 -3
  4. package/docs/{server.basecharactercontroller.detach.md → server.baseentitycontroller.detach.md} +3 -3
  5. package/docs/{server.basecharactercontroller.md → server.baseentitycontroller.md} +29 -29
  6. package/docs/{server.basecharactercontroller.onattach.md → server.baseentitycontroller.onattach.md} +3 -3
  7. package/docs/server.baseentitycontroller.ondespawn.md +13 -0
  8. package/docs/{server.basecharactercontroller.ondetach.md → server.baseentitycontroller.ondetach.md} +3 -3
  9. package/docs/server.baseentitycontroller.onspawn.md +13 -0
  10. package/docs/server.baseentitycontroller.ontick.md +13 -0
  11. package/docs/{server.basecharactercontroller.ontickwithplayerinput.md → server.baseentitycontroller.ontickwithplayerinput.md} +3 -3
  12. package/docs/{server.basecharactercontroller.spawn.md → server.baseentitycontroller.spawn.md} +3 -3
  13. package/docs/{server.basecharactercontroller.tick.md → server.baseentitycontroller.tick.md} +3 -3
  14. package/docs/{server.basecharactercontroller.tickwithplayerinput.md → server.baseentitycontroller.tickwithplayerinput.md} +3 -3
  15. package/docs/server.entity.controller.md +13 -0
  16. package/docs/server.entity.md +40 -5
  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.defaultcharactercontroller.attach.md → server.playerentitycontroller.attach.md} +2 -2
  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} +3 -3
  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/{character-controller/MyCharacterController.ts → entity-controller/MyEntityController.ts} +20 -20
  69. package/examples/entity-controller/README.md +4 -0
  70. package/examples/{character-controller → entity-controller}/index.ts +3 -3
  71. package/examples/{character-controller → entity-controller}/package.json +1 -1
  72. package/examples/payload-game/index.ts +15 -15
  73. package/package.json +1 -1
  74. package/server.api.json +4678 -4339
  75. package/server.d.ts +185 -154
  76. package/server.js +76 -76
  77. package/docs/server.basecharactercontroller.ondespawn.md +0 -13
  78. package/docs/server.basecharactercontroller.onspawn.md +0 -13
  79. package/docs/server.basecharactercontroller.ontick.md +0 -13
  80. package/docs/server.defaultcharactercontroller._constructor_.md +0 -49
  81. package/docs/server.defaultcharactercontroller.canjump.md +0 -13
  82. package/docs/server.defaultcharactercontroller.canrun.md +0 -13
  83. package/docs/server.defaultcharactercontroller.canwalk.md +0 -13
  84. package/docs/server.defaultcharactercontroller.isgrounded.md +0 -13
  85. package/docs/server.defaultcharactercontroller.isonplatform.md +0 -13
  86. package/docs/server.defaultcharactercontroller.jumpvelocity.md +0 -13
  87. package/docs/server.defaultcharactercontroller.md +0 -333
  88. package/docs/server.defaultcharactercontroller.platform.md +0 -13
  89. package/docs/server.defaultcharactercontroller.runvelocity.md +0 -13
  90. package/docs/server.defaultcharactercontroller.spawn.md +0 -53
  91. package/docs/server.defaultcharactercontroller.walkvelocity.md +0 -13
  92. package/docs/server.defaultcharactercontrolleroptions.canjump.md +0 -13
  93. package/docs/server.defaultcharactercontrolleroptions.canrun.md +0 -13
  94. package/docs/server.defaultcharactercontrolleroptions.canwalk.md +0 -13
  95. package/docs/server.defaultcharactercontrolleroptions.jumpvelocity.md +0 -13
  96. package/docs/server.defaultcharactercontrolleroptions.runvelocity.md +0 -13
  97. package/docs/server.defaultcharactercontrolleroptions.walkvelocity.md +0 -13
  98. package/docs/server.entity.charactercontroller.md +0 -13
  99. package/docs/server.entity.setcharactercontroller.md +0 -53
  100. package/docs/server.entityoptions.charactercontroller.md +0 -13
  101. package/examples/character-controller/README.md +0 -4
  102. /package/examples/{character-controller → entity-controller}/assets/map.json +0 -0
package/server.d.ts CHANGED
@@ -277,80 +277,84 @@ 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 {
293
+ export declare abstract class BaseEntityController {
290
294
  /**
291
295
  * A function that is called every tick. Useful for implementing
292
- * tick logic without writing a new character controller class.
296
+ * tick logic without writing a new entity controller class.
293
297
  */
294
298
  onTick?: (entity: Entity, deltaTimeMs: number) => void;
295
299
  /**
296
300
  * A function that is called every tick with player input by a
297
301
  * PlayerEntity with this controller attached. Useful for implementing
298
- * tick logic without writing a new character controller class.
302
+ * tick logic without writing a new entity controller class.
299
303
  */
300
304
  onTickWithPlayerInput?: (entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number) => void;
301
305
  /**
302
306
  * A function that is called when the controller is attached to an entity.
303
307
  * Useful for implementing attach logic without writing a
304
- * new character controller class.
308
+ * new entity controller class.
305
309
  */
306
310
  onAttach?: (entity: Entity) => void;
307
311
  /**
308
312
  * A function that is called when the controlled entity is despawned.
309
313
  * Useful for implementing despawn logic without writing a
310
- * new character controller class.
314
+ * new entity controller class.
311
315
  */
312
316
  onDespawn?: (entity: Entity) => void;
313
317
  /**
314
318
  * A function that is called when the controller is detached from an entity.
315
319
  * Useful for implementing detach logic without writing a
316
- * new character controller class.
320
+ * new entity controller class.
317
321
  */
318
322
  onDetach?: (entity: Entity) => void;
319
323
  /**
320
324
  * A function that is called when the controlled entity is spawned.
321
325
  * Useful for implementing spawn logic without writing a
322
- * new character controller class.
326
+ * new entity controller class.
323
327
  */
324
328
  onSpawn?: (entity: Entity) => void;
325
329
  /**
326
330
  * Override this method to handle the attachment of an entity
327
- * to your character controller.
331
+ * to your entity controller.
328
332
  * @param entity - The entity to attach the controller to.
329
333
  */
330
334
  attach(entity: Entity): void;
331
335
  /**
332
336
  * Override this method to handle the despawn of an entity
333
- * from your character controller.
337
+ * from your entity controller.
334
338
  * @param entity - The entity to despawn.
335
339
  */
336
340
  despawn(entity: Entity): void;
337
341
  /**
338
342
  * Override this method to handle the detachment of an entity
339
- * from your character controller.
343
+ * from your entity controller.
340
344
  * @param entity - The entity to detach.
341
345
  */
342
346
  detach(entity: Entity): void;
343
347
  /**
344
348
  * Override this method to handle the spawning of an entity
345
- * to your character controller.
349
+ * to your entity controller.
346
350
  * @param entity - The entity to spawn.
347
351
  */
348
352
  spawn(entity: Entity): void;
349
353
  /**
350
354
  * Override this method to handle entity movements
351
- * based on player input for your character controller.
355
+ * based on player input for your entity controller.
352
356
  * This is called every tick by a PlayerEntity with a
353
- * character controller.
357
+ * entity controller.
354
358
  * @param entity - The entity to tick.
355
359
  * @param input - The current input state of the player.
356
360
  * @param cameraOrientation - The current camera orientation state of the player.
@@ -359,7 +363,7 @@ export declare abstract class BaseCharacterController {
359
363
  tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
360
364
  /**
361
365
  * Override this method to handle entity movements
362
- * based on your character controller.
366
+ * based on your entity controller.
363
367
  * @param deltaTimeMs - The delta time in milliseconds since the last tick.
364
368
  */
365
369
  tick(entity: Entity, deltaTimeMs: number): void;
@@ -1175,112 +1179,6 @@ export declare const DEFAULT_BLOCK_ENTITY_RIGID_BODY_OPTIONS: RigidBodyOptions;
1175
1179
  /** The default rigid body options for a model entity when EntityOptions.rigidBodyOptions is not provided. @public */
1176
1180
  export declare const DEFAULT_ENTITY_RIGID_BODY_OPTIONS: RigidBodyOptions;
1177
1181
 
1178
- /**
1179
- * The default character controller implementation.
1180
- *
1181
- * @remarks
1182
- * This class extends {@link BaseCharacterController}
1183
- * and implements the default movement logic for a
1184
- * character entity. This is used as the default for
1185
- * players when they join your game. This class may be extended
1186
- * if you'd like to implement additional logic on top of the
1187
- * DefaultCharacterController implementation.
1188
- *
1189
- * @example
1190
- * ```typescript
1191
- * // Create a custom character controller for myEntity, prior to spawning it.
1192
- * myEntity.createCustomCharacterController = () => {
1193
- * return new DefaultCharacterController(myEntity, {
1194
- * jumpVelocity: 10,
1195
- * runVelocity: 8,
1196
- * walkVelocity: 4,
1197
- * });
1198
- * };
1199
- *
1200
- * // Spawn the entity in the world.
1201
- * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
1202
- * ```
1203
- *
1204
- * @public
1205
- */
1206
- export declare class DefaultCharacterController extends BaseCharacterController {
1207
- /** The upward velocity applied to the entity when it jumps. */
1208
- jumpVelocity: number;
1209
- /** The normalized horizontal velocity applied to the entity when it runs. */
1210
- runVelocity: number;
1211
- /** The normalized horizontal velocity applied to the entity when it walks. */
1212
- walkVelocity: number;
1213
- /**
1214
- * A function allowing custom logic to determine if the entity can walk.
1215
- * @param defaultCharacterController - The character controller instance.
1216
- * @returns Whether the entity of the character controller can walk.
1217
- */
1218
- canWalk: (defaultCharacterController: DefaultCharacterController) => boolean;
1219
- /**
1220
- * A function allowing custom logic to determine if the entity can run.
1221
- * @param defaultCharacterController - The character controller instance.
1222
- * @returns Whether the entity of the character controller can run.
1223
- */
1224
- canRun: (defaultCharacterController: DefaultCharacterController) => boolean;
1225
- /**
1226
- * A function allowing custom logic to determine if the entity can jump.
1227
- * @param defaultCharacterController - The character controller instance.
1228
- * @returns Whether the entity of the character controller can jump.
1229
- */
1230
- canJump: (defaultCharacterController: DefaultCharacterController) => boolean;
1231
-
1232
-
1233
-
1234
- /**
1235
- * @param options - Options for the controller.
1236
- */
1237
- constructor(options?: DefaultCharacterControllerOptions);
1238
- /** Whether the entity is grounded. */
1239
- get isGrounded(): boolean;
1240
- /** Whether the entity is on a platform, a platform is any entity with a kinematic rigid body. */
1241
- get isOnPlatform(): boolean;
1242
- /** The platform the entity is on, if any. */
1243
- get platform(): Entity | undefined;
1244
- /**
1245
- * Called when the controller is attached to an entity.
1246
- * @param entity - The entity to attach the controller to.
1247
- */
1248
- attach(entity: Entity): void;
1249
- /**
1250
- * Called when the controlled entity is spawned.
1251
- * In DefaultCharacterController, this function is used to create
1252
- * the colliders for the entity for wall and ground detection.
1253
- * @param entity - The entity that is spawned.
1254
- */
1255
- spawn(entity: Entity): void;
1256
- /**
1257
- * Ticks the player movement for the character controller,
1258
- * overriding the default implementation.
1259
- *
1260
- * @param entity - The entity to tick.
1261
- * @param input - The current input state of the player.
1262
- * @param cameraOrientation - The current camera orientation state of the player.
1263
- * @param deltaTimeMs - The delta time in milliseconds since the last tick.
1264
- */
1265
- tickWithPlayerInput(entity: PlayerEntity, input: PlayerInput, cameraOrientation: PlayerCameraOrientation, deltaTimeMs: number): void;
1266
- }
1267
-
1268
- /** Options for creating a DefaultCharacterController instance. @public */
1269
- export declare interface DefaultCharacterControllerOptions {
1270
- /** The upward velocity applied to the entity when it jumps. */
1271
- jumpVelocity?: number;
1272
- /** The normalized horizontal velocity applied to the entity when it runs. */
1273
- runVelocity?: number;
1274
- /** The normalized horizontal velocity applied to the entity when it walks. */
1275
- walkVelocity?: number;
1276
- /** A function allowing custom logic to determine if the entity can jump. */
1277
- canJump?: () => boolean;
1278
- /** A function allowing custom logic to determine if the entity can walk. */
1279
- canWalk?: () => boolean;
1280
- /** A function allowing custom logic to determine if the entity can run. */
1281
- canRun?: () => boolean;
1282
- }
1283
-
1284
1182
  /**
1285
1183
  * Represents an entity in a world.
1286
1184
  *
@@ -1392,26 +1290,29 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1392
1290
 
1393
1291
 
1394
1292
 
1293
+
1395
1294
  /**
1396
1295
  * @param options - The options for the entity.
1397
1296
  */
1398
1297
  constructor(options: EntityOptions);
1399
1298
  /** The unique identifier for the entity. */
1400
1299
  get id(): number | undefined;
1401
- /** The character controller for the entity. */
1402
- get characterController(): BaseCharacterController | undefined;
1403
1300
  /** The half extends of the visual size of the block entity when blockTextureUri is set. */
1404
1301
  get blockHalfExtents(): Vector3Like | undefined;
1405
1302
  /** The URI or path to the texture to be used, if this is set, the entity is a block entity. */
1406
1303
  get blockTextureUri(): string | undefined;
1407
- /** The URI or path to the .gltf model asset to be used for the entity. */
1408
- 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;
1409
1308
  /** The nodes to hide on the entity's model. */
1410
1309
  get modelHiddenNodes(): ReadonlySet<string>;
1411
1310
  /** The looped animations to start when the entity is spawned. */
1412
1311
  get modelLoopedAnimations(): ReadonlySet<string>;
1413
1312
  /** The scale of the entity's model. */
1414
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;
1415
1316
  /** The name of the entity. */
1416
1317
  get name(): string;
1417
1318
  /** An arbitrary identifier tag of the entity. Useful for your own logic. */
@@ -1437,10 +1338,21 @@ export declare class Entity extends RigidBody implements protocol.Serializable {
1437
1338
  */
1438
1339
  despawn(): void;
1439
1340
  /**
1440
- * Sets the character controller for the entity.
1441
- * @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.
1442
1349
  */
1443
- setCharacterController(characterController: BaseCharacterController | undefined): void;
1350
+ setModelAnimationsPlaybackRate(playbackRate: number): void;
1351
+ /**
1352
+ * Sets the controller for the entity.
1353
+ * @param controller - The controller to set.
1354
+ */
1355
+ setController(controller: BaseEntityController | undefined): void;
1444
1356
  /**
1445
1357
  * Sets the nodes to hide on the entity's model. Matched nodes
1446
1358
  * will be hidden for all players. Uses case insensitive
@@ -1498,6 +1410,10 @@ export declare namespace EntityEventPayload {
1498
1410
  export interface Despawn {
1499
1411
  entity: Entity;
1500
1412
  }
1413
+ export interface SetModelAnimationsPlaybackRate {
1414
+ entity: Entity;
1415
+ playbackRate: number;
1416
+ }
1501
1417
  export interface SetModelHiddenNodes {
1502
1418
  entity: Entity;
1503
1419
  modelHiddenNodes: Set<string>;
@@ -1534,6 +1450,7 @@ export declare namespace EntityEventPayload {
1534
1450
  /** Event types an Entity instance can emit. @public */
1535
1451
  export declare enum EntityEventType {
1536
1452
  DESPAWN = "ENTITY.DESPAWN",
1453
+ SET_MODEL_ANIMATIONS_PLAYBACK_RATE = "ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",
1537
1454
  SET_MODEL_HIDDEN_NODES = "ENTITY.SET_MODEL_HIDDEN_NODES",
1538
1455
  SET_TINT_COLOR = "ENTITY.SET_TINT_COLOR",
1539
1456
  SPAWN = "ENTITY.SPAWN",
@@ -1610,16 +1527,18 @@ export declare interface EntityOptions {
1610
1527
  blockHalfExtents?: Vector3Like;
1611
1528
  /** The texture uri of a entity if the entity is a block entity, if set rigidBodyOptions collider shape [0] must be a block */
1612
1529
  blockTextureUri?: string;
1613
- /** The character controller to use for the entity. */
1614
- characterController?: BaseCharacterController;
1615
- /** The URI or path to the .gltf model asset to be used for the entity. */
1616
- 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;
1617
1534
  /** The nodes to hide on the entity's model. */
1618
1535
  modelHiddenNodes?: string[];
1619
1536
  /** The looped animations to start when the entity is spawned. */
1620
1537
  modelLoopedAnimations?: string[];
1621
1538
  /** The scale of the entity's model. */
1622
1539
  modelScale?: number;
1540
+ /** The URI or path to the .gltf model asset to be used for the entity. */
1541
+ modelUri?: string;
1623
1542
  /** The name of the entity. */
1624
1543
  name?: string;
1625
1544
  /** The rigid body options for the entity. */
@@ -1706,7 +1625,7 @@ export declare class EventRouter {
1706
1625
 
1707
1626
  /**
1708
1627
  * A callback function called when the entity associated with the
1709
- * SimpleCharacterController updates its rotation as it is
1628
+ * SimpleEntityController updates its rotation as it is
1710
1629
  * attempting to face a target coordinate.
1711
1630
  * @param currentRotation - The current rotation of the entity.
1712
1631
  * @param targetRotation - The target rotation of the entity.
@@ -1716,7 +1635,7 @@ export declare type FaceCallback = (currentRotation: QuaternionLike, targetRotat
1716
1635
 
1717
1636
  /**
1718
1637
  * A callback function called when the entity associated with the
1719
- * SimpleCharacterController finishes rotating and is now facing
1638
+ * SimpleEntityController finishes rotating and is now facing
1720
1639
  * a target coordinate.
1721
1640
  * @param endRotation - The rotation of the entity after it has finished rotating.
1722
1641
  * @public
@@ -1724,7 +1643,7 @@ export declare type FaceCallback = (currentRotation: QuaternionLike, targetRotat
1724
1643
  export declare type FaceCompleteCallback = (endRotation: QuaternionLike) => void;
1725
1644
 
1726
1645
  /**
1727
- * Options for the {@link SimpleCharacterController.face} method.
1646
+ * Options for the {@link SimpleEntityController.face} method.
1728
1647
  * @public
1729
1648
  */
1730
1649
  export declare type FaceOptions = {
@@ -1781,7 +1700,7 @@ export declare enum GameServerEventType {
1781
1700
 
1782
1701
  /**
1783
1702
  * A callback function called when the entity associated with the
1784
- * SimpleCharacterController updates its position as it is
1703
+ * SimpleEntityController updates its position as it is
1785
1704
  * attempting to move to a target coordinate.
1786
1705
  * @param currentPosition - The current position of the entity.
1787
1706
  * @param targetPosition - The target position of the entity.
@@ -1791,7 +1710,7 @@ export declare type MoveCallback = (currentPosition: Vector3Like, targetPosition
1791
1710
 
1792
1711
  /**
1793
1712
  * A callback function called when the entity associated with the
1794
- * SimpleCharacterController reaches the target coordinate. An entity
1713
+ * SimpleEntityController reaches the target coordinate. An entity
1795
1714
  * must reach the x,y,z coordinate for the callback to be called.
1796
1715
  * @param endPosition - The position of the entity after it has finished moving.
1797
1716
  * @public
@@ -1799,15 +1718,15 @@ export declare type MoveCallback = (currentPosition: Vector3Like, targetPosition
1799
1718
  export declare type MoveCompleteCallback = (endPosition: Vector3Like) => void;
1800
1719
 
1801
1720
  /**
1802
- * Options for the {@link SimpleCharacterController.move} method.
1721
+ * Options for the {@link SimpleEntityController.move} method.
1803
1722
  * @public
1804
1723
  */
1805
1724
  export declare type MoveOptions = {
1806
- /** Callback called each tick movement of the character controller's entity. */
1725
+ /** Callback called each tick movement of the entity controller's entity. */
1807
1726
  moveCallback?: MoveCallback;
1808
- /** Callback called when the character controller's entity has finished moving. */
1727
+ /** Callback called when the entity controller's entity has finished moving. */
1809
1728
  moveCompleteCallback?: MoveCompleteCallback;
1810
- /** 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. */
1811
1730
  moveIgnoreAxes?: {
1812
1731
  x?: boolean;
1813
1732
  y?: boolean;
@@ -2102,8 +2021,8 @@ export declare type PlayerCameraOrientation = {
2102
2021
  * They can be created and assigned to a player when
2103
2022
  * a player joins a world. PlayerEntity automatically
2104
2023
  * handles mapping player inputs to the associated
2105
- * character controller of the entity, calling the
2106
- * character controller's onTickPlayerMovement method
2024
+ * entity controller of the entity, calling the
2025
+ * entity controller's onTickPlayerMovement method
2107
2026
  * when player input has changed.
2108
2027
  *
2109
2028
  * @example
@@ -2133,6 +2052,110 @@ export declare class PlayerEntity extends Entity {
2133
2052
 
2134
2053
  }
2135
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
+
2136
2159
  /** Options for creating a PlayerEntity instance. @public */
2137
2160
  export declare interface PlayerEntityOptions extends EntityOptions {
2138
2161
  /** The player the player entity is assigned to. */
@@ -2243,6 +2266,11 @@ export declare class PlayerUI {
2243
2266
  * @param htmlUri - The ui html uri to load.
2244
2267
  */
2245
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;
2246
2274
  /**
2247
2275
  * Sends data to the player's client UI.
2248
2276
  * @param data - The data to send to the client UI.
@@ -2256,6 +2284,10 @@ export declare namespace PlayerUIEventPayload {
2256
2284
  playerUI: PlayerUI;
2257
2285
  htmlUri: string;
2258
2286
  }
2287
+ export interface LockPointer {
2288
+ playerUI: PlayerUI;
2289
+ lock: boolean;
2290
+ }
2259
2291
  export interface SendData {
2260
2292
  playerUI: PlayerUI;
2261
2293
  data: object;
@@ -2265,6 +2297,7 @@ export declare namespace PlayerUIEventPayload {
2265
2297
  /** Event types a PlayerUI can emit. @public */
2266
2298
  export declare enum PlayerUIEventType {
2267
2299
  LOAD = "PLAYER_UI.LOAD",
2300
+ LOCK_POINTER = "PLAYER_UI.LOCK_POINTER",
2268
2301
  SEND_DATA = "PLAYER_UI.SEND_DATA"
2269
2302
  }
2270
2303
 
@@ -2855,22 +2888,20 @@ export declare enum RigidBodyType {
2855
2888
  }
2856
2889
 
2857
2890
  /**
2858
- * A simple character controller with basic movement functions.
2891
+ * A simple entity controller with basic movement functions.
2859
2892
  *
2860
2893
  * @remarks
2861
2894
  * This class implements simple movement methods that serve
2862
2895
  * as a way to add realistic movement and rotational facing
2863
2896
  * functionality to an entity. This is also a great base to
2864
- * extend for your own more complex character controller
2897
+ * extend for your own more complex entity controller
2865
2898
  * that implements things like pathfinding. Compatible with
2866
2899
  * entities that have kinematic or dynamic rigid body types.
2867
2900
  *
2868
2901
  * @example
2869
2902
  * ```typescript
2870
- * // Create a custom character controller for myEntity, prior to spawning it.
2871
- * myEntity.createCustomCharacterController = () => {
2872
- * return new SimpleCharacterController(myEntity);
2873
- * };
2903
+ * // Create a custom entity controller for myEntity, prior to spawning it.
2904
+ * myEntity.setController(new SimpleEntityController());
2874
2905
  *
2875
2906
  * // Spawn the entity in the world.
2876
2907
  * myEntity.spawn(world, { x: 53, y: 10, z: 23 });
@@ -2878,7 +2909,7 @@ export declare enum RigidBodyType {
2878
2909
  * // Move the entity at a speed of 4 blocks
2879
2910
  * // per second to the coordinate (10, 1, 10).
2880
2911
  * // console.log when we reach the target.
2881
- * myEntity.characterController.move({ x: 10, y: 1, z: 10 }, 4, {
2912
+ * myEntity.controller.move({ x: 10, y: 1, z: 10 }, 4, {
2882
2913
  * moveCompleteCallback: endPosition => {
2883
2914
  * console.log('Finished moving to', endPosition);
2884
2915
  * },
@@ -2887,7 +2918,7 @@ export declare enum RigidBodyType {
2887
2918
  *
2888
2919
  * @public
2889
2920
  */
2890
- export declare class SimpleCharacterController extends BaseCharacterController {
2921
+ export declare class SimpleEntityController extends BaseEntityController {
2891
2922
 
2892
2923
 
2893
2924