webXRCamera.d.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { Vector3 } from "../Maths/math.vector";
  2. import type { Scene } from "../scene";
  3. import { Camera } from "../Cameras/camera";
  4. import { FreeCamera } from "../Cameras/freeCamera";
  5. import type { WebXRSessionManager } from "./webXRSessionManager";
  6. import { Observable } from "../Misc/observable";
  7. import { WebXRTrackingState } from "./webXRTypes";
  8. /**
  9. * WebXR Camera which holds the views for the xrSession
  10. * @see https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRCamera
  11. */
  12. export declare class WebXRCamera extends FreeCamera {
  13. private _xrSessionManager;
  14. private static _ScaleReadOnly;
  15. private _firstFrame;
  16. private _referenceQuaternion;
  17. private _referencedPosition;
  18. private _trackingState;
  19. /**
  20. * This will be triggered after the first XR Frame initialized the camera,
  21. * including the right number of views and their rendering parameters
  22. */
  23. onXRCameraInitializedObservable: Observable<WebXRCamera>;
  24. /**
  25. * Observable raised before camera teleportation
  26. * @deprecated use onBeforeCameraTeleport of the teleportation feature instead
  27. */
  28. onBeforeCameraTeleport: Observable<Vector3>;
  29. /**
  30. * Observable raised after camera teleportation
  31. * @deprecated use onAfterCameraTeleport of the teleportation feature instead
  32. */
  33. onAfterCameraTeleport: Observable<Vector3>;
  34. /**
  35. * Notifies when the camera's tracking state has changed.
  36. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  37. */
  38. onTrackingStateChanged: Observable<WebXRTrackingState>;
  39. /**
  40. * Should position compensation execute on first frame.
  41. * This is used when copying the position from a native (non XR) camera
  42. */
  43. compensateOnFirstFrame: boolean;
  44. /**
  45. * The last XRViewerPose from the current XRFrame
  46. * @internal
  47. */
  48. _lastXRViewerPose?: XRViewerPose;
  49. /**
  50. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  51. * @param name the name of the camera
  52. * @param scene the scene to add the camera to
  53. * @param _xrSessionManager a constructed xr session manager
  54. */
  55. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  56. /**
  57. * Get the current XR tracking state of the camera
  58. */
  59. get trackingState(): WebXRTrackingState;
  60. private _setTrackingState;
  61. /**
  62. * Return the user's height, unrelated to the current ground.
  63. * This will be the y position of this camera, when ground level is 0.
  64. *
  65. * Note - this value is multiplied by the worldScalingFactor (if set), so it will be in the same units as the scene.
  66. */
  67. get realWorldHeight(): number;
  68. /** @internal */
  69. _updateForDualEyeDebugging(): void;
  70. /**
  71. * Sets this camera's transformation based on a non-vr camera
  72. * @param otherCamera the non-vr camera to copy the transformation from
  73. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  74. */
  75. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  76. /**
  77. * Gets the current instance class name ("WebXRCamera").
  78. * @returns the class name
  79. */
  80. getClassName(): string;
  81. /**
  82. * Set the target for the camera to look at.
  83. * Note that this only rotates around the Y axis, as opposed to the default behavior of other cameras
  84. * @param target the target to set the camera to look at
  85. */
  86. setTarget(target: Vector3): void;
  87. dispose(): void;
  88. private _updateDepthNearFar;
  89. private _rotate180;
  90. private _updateFromXRSession;
  91. private _updateNumberOfRigCameras;
  92. private _updateReferenceSpace;
  93. }