freeCameraDeviceOrientationInput.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import type { Nullable } from "../../types";
  2. import type { ICameraInput } from "../../Cameras/cameraInputsManager";
  3. import type { FreeCamera } from "../../Cameras/freeCamera";
  4. import { Observable } from "../../Misc/observable";
  5. declare module "../../Cameras/freeCameraInputsManager" {
  6. interface FreeCameraInputsManager {
  7. /**
  8. * @internal
  9. */
  10. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  11. /**
  12. * Add orientation input support to the input manager.
  13. * @param smoothFactor deviceOrientation smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing
  14. * @returns the current input manager
  15. */
  16. addDeviceOrientation(smoothFactor?: number): FreeCameraInputsManager;
  17. }
  18. }
  19. /**
  20. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  21. * Screen rotation is taken into account.
  22. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
  23. */
  24. export declare class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  25. private _camera;
  26. private _screenOrientationAngle;
  27. private _constantTranform;
  28. private _screenQuaternion;
  29. private _alpha;
  30. private _beta;
  31. private _gamma;
  32. /** alpha+beta+gamma smoothing. 0: no smoothing, 1: new data ignored, 0.9 recommended for smoothing */
  33. smoothFactor: number;
  34. /**
  35. * Can be used to detect if a device orientation sensor is available on a device
  36. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37. * @returns a promise that will resolve on orientation change
  38. */
  39. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  40. /**
  41. * @internal
  42. */
  43. _onDeviceOrientationChangedObservable: Observable<void>;
  44. /**
  45. * Instantiates a new input
  46. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/customizingCameraInputs
  47. */
  48. constructor();
  49. /**
  50. * Define the camera controlled by the input.
  51. */
  52. get camera(): FreeCamera;
  53. set camera(camera: FreeCamera);
  54. /**
  55. * Attach the input controls to a specific dom element to get the input from.
  56. */
  57. attachControl(): void;
  58. private _orientationChanged;
  59. private _deviceOrientation;
  60. /**
  61. * Detach the current controls from the specified dom element.
  62. */
  63. detachControl(): void;
  64. /**
  65. * Update the current camera state depending on the inputs that have been used this frame.
  66. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67. */
  68. checkInputs(): void;
  69. /**
  70. * Gets the class name of the current input.
  71. * @returns the class name
  72. */
  73. getClassName(): string;
  74. /**
  75. * Get the friendly name associated with the input class.
  76. * @returns the input friendly name
  77. */
  78. getSimpleName(): string;
  79. }