freeCamera.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import { Vector3 } from "../Maths/math.vector";
  2. import type { AbstractMesh } from "../Meshes/abstractMesh";
  3. import type { Scene } from "../scene";
  4. import { TargetCamera } from "./targetCamera";
  5. import { FreeCameraInputsManager } from "./freeCameraInputsManager";
  6. /**
  7. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  9. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#universal-camera
  10. */
  11. export declare class FreeCamera extends TargetCamera {
  12. /**
  13. * Define the collision ellipsoid of the camera.
  14. * This is helpful to simulate a camera body like the player body around the camera
  15. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions#arcrotatecamera
  16. */
  17. ellipsoid: Vector3;
  18. /**
  19. * Define an offset for the position of the ellipsoid around the camera.
  20. * This can be helpful to determine the center of the body near the gravity center of the body
  21. * instead of its head.
  22. */
  23. ellipsoidOffset: Vector3;
  24. /**
  25. * Enable or disable collisions of the camera with the rest of the scene objects.
  26. */
  27. checkCollisions: boolean;
  28. /**
  29. * Enable or disable gravity on the camera.
  30. */
  31. applyGravity: boolean;
  32. /**
  33. * Define the input manager associated to the camera.
  34. */
  35. inputs: FreeCameraInputsManager;
  36. /**
  37. * Gets the input sensibility for a mouse input. (default is 2000.0)
  38. * Higher values reduce sensitivity.
  39. */
  40. get angularSensibility(): number;
  41. /**
  42. * Sets the input sensibility for a mouse input. (default is 2000.0)
  43. * Higher values reduce sensitivity.
  44. */
  45. set angularSensibility(value: number);
  46. /**
  47. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  48. */
  49. get keysUp(): number[];
  50. set keysUp(value: number[]);
  51. /**
  52. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  53. */
  54. get keysUpward(): number[];
  55. set keysUpward(value: number[]);
  56. /**
  57. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  58. */
  59. get keysDown(): number[];
  60. set keysDown(value: number[]);
  61. /**
  62. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  63. */
  64. get keysDownward(): number[];
  65. set keysDownward(value: number[]);
  66. /**
  67. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68. */
  69. get keysLeft(): number[];
  70. set keysLeft(value: number[]);
  71. /**
  72. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  73. */
  74. get keysRight(): number[];
  75. set keysRight(value: number[]);
  76. /**
  77. * Gets or Set the list of keyboard keys used to control the left rotation move of the camera.
  78. */
  79. get keysRotateLeft(): number[];
  80. set keysRotateLeft(value: number[]);
  81. /**
  82. * Gets or Set the list of keyboard keys used to control the right rotation move of the camera.
  83. */
  84. get keysRotateRight(): number[];
  85. set keysRotateRight(value: number[]);
  86. /**
  87. * Gets or Set the list of keyboard keys used to control the up rotation move of the camera.
  88. */
  89. get keysRotateUp(): number[];
  90. set keysRotateUp(value: number[]);
  91. /**
  92. * Gets or Set the list of keyboard keys used to control the down rotation move of the camera.
  93. */
  94. get keysRotateDown(): number[];
  95. set keysRotateDown(value: number[]);
  96. /**
  97. * Event raised when the camera collide with a mesh in the scene.
  98. */
  99. onCollide: (collidedMesh: AbstractMesh) => void;
  100. private _collider;
  101. private _needMoveForGravity;
  102. private _oldPosition;
  103. private _diffPosition;
  104. private _newPosition;
  105. /** @internal */
  106. _localDirection: Vector3;
  107. /** @internal */
  108. _transformedDirection: Vector3;
  109. /**
  110. * Instantiates a Free Camera.
  111. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  113. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#universal-camera
  114. * @param name Define the name of the camera in the scene
  115. * @param position Define the start position of the camera in the scene
  116. * @param scene Define the scene the camera belongs to
  117. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  118. */
  119. constructor(name: string, position: Vector3, scene?: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120. /**
  121. * Attach the input controls to a specific dom element to get the input from.
  122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123. */
  124. attachControl(noPreventDefault?: boolean): void;
  125. /**
  126. * Attach the input controls to a specific dom element to get the input from.
  127. * @param ignored defines an ignored parameter kept for backward compatibility.
  128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129. * BACK COMPAT SIGNATURE ONLY.
  130. */
  131. attachControl(ignored: any, noPreventDefault?: boolean): void;
  132. /**
  133. * Detach the current controls from the specified dom element.
  134. */
  135. detachControl(): void;
  136. private _collisionMask;
  137. /**
  138. * Define a collision mask to limit the list of object the camera can collide with
  139. */
  140. get collisionMask(): number;
  141. set collisionMask(mask: number);
  142. /**
  143. * @internal
  144. */
  145. _collideWithWorld(displacement: Vector3): void;
  146. private _onCollisionPositionChange;
  147. /** @internal */
  148. _checkInputs(): void;
  149. /**
  150. * Enable movement without a user input. This allows gravity to always be applied.
  151. */
  152. set needMoveForGravity(value: boolean);
  153. /**
  154. * When true, gravity is applied whether there is user input or not.
  155. */
  156. get needMoveForGravity(): boolean;
  157. /** @internal */
  158. _decideIfNeedsToMove(): boolean;
  159. /** @internal */
  160. _updatePosition(): void;
  161. /**
  162. * Destroy the camera and release the current resources hold by it.
  163. */
  164. dispose(): void;
  165. /**
  166. * Gets the current object class name.
  167. * @returns the class name
  168. */
  169. getClassName(): string;
  170. }