followCamera.d.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import type { Nullable } from "../types";
  2. import { TargetCamera } from "./targetCamera";
  3. import type { Scene } from "../scene";
  4. import { Vector3 } from "../Maths/math.vector";
  5. import type { AbstractMesh } from "../Meshes/abstractMesh";
  6. import { FollowCameraInputsManager } from "./followCameraInputsManager";
  7. /**
  8. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  9. * an arc rotate version arcFollowCamera are available.
  10. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#followcamera
  11. */
  12. export declare class FollowCamera extends TargetCamera {
  13. /**
  14. * Distance the follow camera should follow an object at
  15. */
  16. radius: number;
  17. /**
  18. * Minimum allowed distance of the camera to the axis of rotation
  19. * (The camera can not get closer).
  20. * This can help limiting how the Camera is able to move in the scene.
  21. */
  22. lowerRadiusLimit: Nullable<number>;
  23. /**
  24. * Maximum allowed distance of the camera to the axis of rotation
  25. * (The camera can not get further).
  26. * This can help limiting how the Camera is able to move in the scene.
  27. */
  28. upperRadiusLimit: Nullable<number>;
  29. /**
  30. * Define a rotation offset between the camera and the object it follows
  31. */
  32. rotationOffset: number;
  33. /**
  34. * Minimum allowed angle to camera position relative to target object.
  35. * This can help limiting how the Camera is able to move in the scene.
  36. */
  37. lowerRotationOffsetLimit: Nullable<number>;
  38. /**
  39. * Maximum allowed angle to camera position relative to target object.
  40. * This can help limiting how the Camera is able to move in the scene.
  41. */
  42. upperRotationOffsetLimit: Nullable<number>;
  43. /**
  44. * Define a height offset between the camera and the object it follows.
  45. * It can help following an object from the top (like a car chasing a plane)
  46. */
  47. heightOffset: number;
  48. /**
  49. * Minimum allowed height of camera position relative to target object.
  50. * This can help limiting how the Camera is able to move in the scene.
  51. */
  52. lowerHeightOffsetLimit: Nullable<number>;
  53. /**
  54. * Maximum allowed height of camera position relative to target object.
  55. * This can help limiting how the Camera is able to move in the scene.
  56. */
  57. upperHeightOffsetLimit: Nullable<number>;
  58. /**
  59. * Define how fast the camera can accelerate to follow it s target.
  60. */
  61. cameraAcceleration: number;
  62. /**
  63. * Define the speed limit of the camera following an object.
  64. */
  65. maxCameraSpeed: number;
  66. /**
  67. * Define the target of the camera.
  68. */
  69. lockedTarget: Nullable<AbstractMesh>;
  70. /**
  71. * Defines the input associated with the camera.
  72. */
  73. inputs: FollowCameraInputsManager;
  74. /**
  75. * Instantiates the follow camera.
  76. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#followcamera
  77. * @param name Define the name of the camera in the scene
  78. * @param position Define the position of the camera
  79. * @param scene Define the scene the camera belong to
  80. * @param lockedTarget Define the target of the camera
  81. */
  82. constructor(name: string, position: Vector3, scene?: Scene, lockedTarget?: Nullable<AbstractMesh>);
  83. private _follow;
  84. /**
  85. * Attach the input controls to a specific dom element to get the input from.
  86. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87. */
  88. attachControl(noPreventDefault?: boolean): void;
  89. /**
  90. * Detach the current controls from the specified dom element.
  91. */
  92. detachControl(): void;
  93. /** @internal */
  94. _checkInputs(): void;
  95. private _checkLimits;
  96. /**
  97. * Gets the camera class name.
  98. * @returns the class name
  99. */
  100. getClassName(): string;
  101. }
  102. /**
  103. * Arc Rotate version of the follow camera.
  104. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#followcamera
  106. */
  107. export declare class ArcFollowCamera extends TargetCamera {
  108. /** The longitudinal angle of the camera */
  109. alpha: number;
  110. /** The latitudinal angle of the camera */
  111. beta: number;
  112. /** The radius of the camera from its target */
  113. radius: number;
  114. private _cartesianCoordinates;
  115. /** Define the camera target (the mesh it should follow) */
  116. private _meshTarget;
  117. /**
  118. * Instantiates a new ArcFollowCamera
  119. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_introduction#followcamera
  120. * @param name Define the name of the camera
  121. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  122. * @param beta Define the rotation angle of the camera around the elevation axis
  123. * @param radius Define the radius of the camera from its target point
  124. * @param target Define the target of the camera
  125. * @param scene Define the scene the camera belongs to
  126. */
  127. constructor(name: string,
  128. /** The longitudinal angle of the camera */
  129. alpha: number,
  130. /** The latitudinal angle of the camera */
  131. beta: number,
  132. /** The radius of the camera from its target */
  133. radius: number,
  134. /** Define the camera target (the mesh it should follow) */
  135. target: Nullable<AbstractMesh>, scene: Scene);
  136. /**
  137. * Sets the mesh to follow with this camera.
  138. * @param target the target to follow
  139. */
  140. setMeshTarget(target: Nullable<AbstractMesh>): void;
  141. private _follow;
  142. /** @internal */
  143. _checkInputs(): void;
  144. /**
  145. * Returns the class name of the object.
  146. * It is mostly used internally for serialization purposes.
  147. * @returns the class name
  148. */
  149. getClassName(): string;
  150. }