WebXRLayers.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import type { WebXRSessionManager } from "../webXRSessionManager";
  2. import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
  3. import type { WebXRLayerWrapper } from "../webXRLayerWrapper";
  4. import { WebXRWebGLLayerWrapper } from "../webXRWebGLLayer";
  5. import { WebXRProjectionLayerWrapper } from "./Layers/WebXRProjectionLayer";
  6. import { WebXRCompositionLayerWrapper } from "./Layers/WebXRCompositionLayer";
  7. import type { DynamicTexture } from "../../Materials/Textures/dynamicTexture";
  8. import type { LensFlareSystem } from "../../LensFlares/lensFlareSystem";
  9. /**
  10. * Configuration options of the layers feature
  11. */
  12. export interface IWebXRLayersOptions {
  13. /**
  14. * Whether to try initializing the base projection layer as a multiview render target, if multiview is supported.
  15. * Defaults to false.
  16. */
  17. preferMultiviewOnInit?: boolean;
  18. /**
  19. * Optional configuration for the base projection layer.
  20. */
  21. projectionLayerInit?: Partial<XRProjectionLayerInit>;
  22. }
  23. /**
  24. * Exposes the WebXR Layers API.
  25. */
  26. export declare class WebXRLayers extends WebXRAbstractFeature {
  27. private readonly _options;
  28. /**
  29. * The module's name
  30. */
  31. static readonly Name = "xr-layers";
  32. /**
  33. * The (Babylon) version of this module.
  34. * This is an integer representing the implementation version.
  35. * This number does not correspond to the WebXR specs version
  36. */
  37. static readonly Version = 1;
  38. /**
  39. * Already-created layers
  40. */
  41. private _existingLayers;
  42. private _glContext;
  43. private _xrWebGLBinding;
  44. private _isMultiviewEnabled;
  45. private _projectionLayerInitialized;
  46. private _compositionLayerTextureMapping;
  47. private _layerToRTTProviderMapping;
  48. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRLayersOptions);
  49. /**
  50. * Attach this feature.
  51. * Will usually be called by the features manager.
  52. *
  53. * @returns true if successful.
  54. */
  55. attach(): boolean;
  56. detach(): boolean;
  57. /**
  58. * Creates a new XRWebGLLayer.
  59. * @param params an object providing configuration options for the new XRWebGLLayer
  60. * @returns the XRWebGLLayer
  61. */
  62. createXRWebGLLayer(params?: XRWebGLLayerInit): WebXRWebGLLayerWrapper;
  63. private _validateLayerInit;
  64. private _extendXRLayerInit;
  65. /**
  66. * Creates a new XRProjectionLayer.
  67. * @param params an object providing configuration options for the new XRProjectionLayer.
  68. * @param multiview whether the projection layer should render with multiview. Will be tru automatically if the extension initialized with multiview.
  69. * @returns the projection layer
  70. */
  71. createProjectionLayer(params?: XRProjectionLayerInit, multiview?: boolean): WebXRProjectionLayerWrapper;
  72. /**
  73. * Note about making it private - this function will be exposed once I decide on a proper API to support all of the XR layers' options
  74. * @param options an object providing configuration options for the new XRQuadLayer.
  75. * @param babylonTexture the texture to display in the layer
  76. * @returns the quad layer
  77. */
  78. private _createQuadLayer;
  79. /**
  80. * @experimental
  81. * This will support full screen ADT when used with WebXR Layers. This API might change in the future.
  82. * Note that no interaction will be available with the ADT when using this method
  83. * @param texture the texture to display in the layer
  84. * @param options optional parameters for the layer
  85. * @returns a composition layer containing the texture
  86. */
  87. addFullscreenAdvancedDynamicTexture(texture: DynamicTexture, options?: {
  88. distanceFromHeadset: number;
  89. }): WebXRCompositionLayerWrapper;
  90. /**
  91. * @experimental
  92. * This functions allows you to add a lens flare system to the XR scene.
  93. * Note - this will remove the lens flare system from the scene and add it to the XR scene.
  94. * This feature is experimental and might change in the future.
  95. * @param flareSystem the flare system to add
  96. * @returns a composition layer containing the flare system
  97. */
  98. protected _addLensFlareSystem(flareSystem: LensFlareSystem): WebXRCompositionLayerWrapper;
  99. /**
  100. * Add a new layer to the already-existing list of layers
  101. * @param wrappedLayer the new layer to add to the existing ones
  102. */
  103. addXRSessionLayer(wrappedLayer: WebXRLayerWrapper): void;
  104. /**
  105. * Sets the layers to be used by the XR session.
  106. * Note that you must call this function with any layers you wish to render to
  107. * since it adds them to the XR session's render state
  108. * (replacing any layers that were added in a previous call to setXRSessionLayers or updateRenderState).
  109. * This method also sets up the session manager's render target texture provider
  110. * as the first layer in the array, which feeds the WebXR camera(s) attached to the session.
  111. * @param wrappedLayers An array of WebXRLayerWrapper, usually returned from the WebXRLayers createLayer functions.
  112. */
  113. setXRSessionLayers(wrappedLayers?: Array<WebXRLayerWrapper>): void;
  114. isCompatible(): boolean;
  115. /**
  116. * Dispose this feature and all of the resources attached.
  117. */
  118. dispose(): void;
  119. protected _onXRFrame(_xrFrame: XRFrame): void;
  120. }