WebXRDOMOverlay.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import type { Nullable } from "../../types";
  2. import type { WebXRSessionManager } from "../webXRSessionManager";
  3. import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
  4. /**
  5. * Options for DOM Overlay feature
  6. */
  7. export interface IWebXRDomOverlayOptions {
  8. /**
  9. * DOM Element or document query selector string for overlay.
  10. *
  11. * NOTE: UA may make this element background transparent in XR.
  12. */
  13. element: Element | string;
  14. /**
  15. * Supress XR Select events on container element (DOM blocks interaction to scene).
  16. */
  17. supressXRSelectEvents?: boolean;
  18. }
  19. /**
  20. * Type of DOM overlay provided by UA.
  21. */
  22. type WebXRDomOverlayType =
  23. /**
  24. * Covers the entire physical screen for a screen-based device, for example handheld AR
  25. */
  26. "screen"
  27. /**
  28. * Appears as a floating rectangle in space
  29. */
  30. | "floating"
  31. /**
  32. * Follows the user’s head movement consistently, appearing similar to a HUD
  33. */
  34. | "head-locked";
  35. /**
  36. * DOM Overlay Feature
  37. *
  38. * @since 5.0.0
  39. */
  40. export declare class WebXRDomOverlay extends WebXRAbstractFeature {
  41. /**
  42. * options to use when constructing this feature
  43. */
  44. readonly options: IWebXRDomOverlayOptions;
  45. /**
  46. * Type of overlay - non-null when available
  47. */
  48. private _domOverlayType;
  49. /**
  50. * Event Listener to supress "beforexrselect" events.
  51. */
  52. private _beforeXRSelectListener;
  53. /**
  54. * Element used for overlay
  55. */
  56. private _element;
  57. /**
  58. * The module's name
  59. */
  60. static readonly Name = "xr-dom-overlay";
  61. /**
  62. * The (Babylon) version of this module.
  63. * This is an integer representing the implementation version.
  64. * This number does not correspond to the WebXR specs version
  65. */
  66. static readonly Version = 1;
  67. /**
  68. * Creates a new instance of the dom-overlay feature
  69. * @param _xrSessionManager an instance of WebXRSessionManager
  70. * @param options options to use when constructing this feature
  71. */
  72. constructor(_xrSessionManager: WebXRSessionManager,
  73. /**
  74. * options to use when constructing this feature
  75. */
  76. options: IWebXRDomOverlayOptions);
  77. /**
  78. * attach this feature
  79. * Will usually be called by the features manager
  80. *
  81. * @returns true if successful.
  82. */
  83. attach(): boolean;
  84. /**
  85. * The type of DOM overlay (null when not supported). Provided by UA and remains unchanged for duration of session.
  86. */
  87. get domOverlayType(): Nullable<WebXRDomOverlayType>;
  88. /**
  89. * Dispose this feature and all of the resources attached
  90. */
  91. dispose(): void;
  92. protected _onXRFrame(_xrFrame: XRFrame): void;
  93. /**
  94. * Extends the session init object if needed
  95. * @returns augmentation object for the xr session init object.
  96. */
  97. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  98. }
  99. export {};