targetCamera.d.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import type { Nullable } from "../types";
  2. import { Camera } from "./camera";
  3. import type { Scene } from "../scene";
  4. import { Quaternion, Matrix, Vector3, Vector2 } from "../Maths/math.vector";
  5. /**
  6. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7. * This is the base of the follow, arc rotate cameras and Free camera
  8. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras
  9. */
  10. export declare class TargetCamera extends Camera {
  11. private static _RigCamTransformMatrix;
  12. private static _TargetTransformMatrix;
  13. private static _TargetFocalPoint;
  14. private _tmpUpVector;
  15. private _tmpTargetVector;
  16. /**
  17. * Define the current direction the camera is moving to
  18. */
  19. cameraDirection: Vector3;
  20. /**
  21. * Define the current rotation the camera is rotating to
  22. */
  23. cameraRotation: Vector2;
  24. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  25. ignoreParentScaling: boolean;
  26. /**
  27. * When set, the up vector of the camera will be updated by the rotation of the camera
  28. */
  29. updateUpVectorFromRotation: boolean;
  30. private _tmpQuaternion;
  31. /**
  32. * Define the current rotation of the camera
  33. */
  34. rotation: Vector3;
  35. /**
  36. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  37. */
  38. rotationQuaternion: Quaternion;
  39. /**
  40. * Define the current speed of the camera
  41. */
  42. speed: number;
  43. /**
  44. * Add constraint to the camera to prevent it to move freely in all directions and
  45. * around all axis.
  46. */
  47. noRotationConstraint: boolean;
  48. /**
  49. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  50. * panning
  51. */
  52. invertRotation: boolean;
  53. /**
  54. * Speed multiplier for inverse camera panning
  55. */
  56. inverseRotationSpeed: number;
  57. /**
  58. * Define the current target of the camera as an object or a position.
  59. * Please note that locking a target will disable panning.
  60. */
  61. lockedTarget: any;
  62. /** @internal */
  63. _currentTarget: Vector3;
  64. /** @internal */
  65. _initialFocalDistance: number;
  66. /** @internal */
  67. _viewMatrix: Matrix;
  68. /** @internal */
  69. _camMatrix: Matrix;
  70. /** @internal */
  71. _cameraTransformMatrix: Matrix;
  72. /** @internal */
  73. _cameraRotationMatrix: Matrix;
  74. /** @internal */
  75. _referencePoint: Vector3;
  76. /** @internal */
  77. _transformedReferencePoint: Vector3;
  78. protected _deferredPositionUpdate: Vector3;
  79. protected _deferredRotationQuaternionUpdate: Quaternion;
  80. protected _deferredRotationUpdate: Vector3;
  81. protected _deferredUpdated: boolean;
  82. protected _deferOnly: boolean;
  83. /** @internal */
  84. _reset: () => void;
  85. private _defaultUp;
  86. /**
  87. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  88. * This is the base of the follow, arc rotate cameras and Free camera
  89. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras
  90. * @param name Defines the name of the camera in the scene
  91. * @param position Defines the start position of the camera in the scene
  92. * @param scene Defines the scene the camera belongs to
  93. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  94. */
  95. constructor(name: string, position: Vector3, scene?: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96. /**
  97. * Gets the position in front of the camera at a given distance.
  98. * @param distance The distance from the camera we want the position to be
  99. * @returns the position
  100. */
  101. getFrontPosition(distance: number): Vector3;
  102. /** @internal */
  103. _getLockedTargetPosition(): Nullable<Vector3>;
  104. private _storedPosition;
  105. private _storedRotation;
  106. private _storedRotationQuaternion;
  107. /**
  108. * Store current camera state of the camera (fov, position, rotation, etc..)
  109. * @returns the camera
  110. */
  111. storeState(): Camera;
  112. /**
  113. * Restored camera state. You must call storeState() first
  114. * @returns whether it was successful or not
  115. * @internal
  116. */
  117. _restoreStateValues(): boolean;
  118. /** @internal */
  119. _initCache(): void;
  120. /**
  121. * @internal
  122. */
  123. _updateCache(ignoreParentClass?: boolean): void;
  124. /** @internal */
  125. _isSynchronizedViewMatrix(): boolean;
  126. /** @internal */
  127. _computeLocalCameraSpeed(): number;
  128. /**
  129. * Defines the target the camera should look at.
  130. * @param target Defines the new target as a Vector
  131. */
  132. setTarget(target: Vector3): void;
  133. /**
  134. * Defines the target point of the camera.
  135. * The camera looks towards it form the radius distance.
  136. */
  137. get target(): Vector3;
  138. set target(value: Vector3);
  139. /**
  140. * Return the current target position of the camera. This value is expressed in local space.
  141. * @returns the target position
  142. */
  143. getTarget(): Vector3;
  144. /** @internal */
  145. _decideIfNeedsToMove(): boolean;
  146. /** @internal */
  147. _updatePosition(): void;
  148. /** @internal */
  149. _checkInputs(): void;
  150. protected _updateCameraRotationMatrix(): void;
  151. /**
  152. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  153. * @returns the current camera
  154. */
  155. private _rotateUpVectorWithCameraRotationMatrix;
  156. private _cachedRotationZ;
  157. private _cachedQuaternionRotationZ;
  158. /** @internal */
  159. _getViewMatrix(): Matrix;
  160. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  161. /**
  162. * @internal
  163. */
  164. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  165. /**
  166. * @internal
  167. */
  168. _updateRigCameras(): void;
  169. private _getRigCamPositionAndTarget;
  170. /**
  171. * Gets the current object class name.
  172. * @returns the class name
  173. */
  174. getClassName(): string;
  175. }