webXRManagedOutputCanvas.d.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import type { Nullable } from "../types";
  2. import type { AbstractEngine } from "../Engines/abstractEngine";
  3. import type { WebXRRenderTarget } from "./webXRTypes";
  4. import type { WebXRSessionManager } from "./webXRSessionManager";
  5. import { Observable } from "../Misc/observable";
  6. /**
  7. * Configuration object for WebXR output canvas
  8. */
  9. export declare class WebXRManagedOutputCanvasOptions {
  10. /**
  11. * An optional canvas in case you wish to create it yourself and provide it here.
  12. * If not provided, a new canvas will be created
  13. */
  14. canvasElement?: HTMLCanvasElement;
  15. /**
  16. * Options for this XR Layer output
  17. */
  18. canvasOptions?: XRWebGLLayerInit;
  19. /**
  20. * CSS styling for a newly created canvas (if not provided)
  21. */
  22. newCanvasCssStyle?: string;
  23. /**
  24. * Get the default values of the configuration object
  25. * @param engine defines the engine to use (can be null)
  26. * @returns default values of this configuration object
  27. */
  28. static GetDefaults(engine?: AbstractEngine): WebXRManagedOutputCanvasOptions;
  29. }
  30. /**
  31. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  32. */
  33. export declare class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  34. private _options;
  35. private _canvas;
  36. private _engine;
  37. private _originalCanvasSize;
  38. /**
  39. * Rendering context of the canvas which can be used to display/mirror xr content
  40. */
  41. canvasContext: WebGLRenderingContext;
  42. /**
  43. * xr layer for the canvas
  44. */
  45. xrLayer: Nullable<XRWebGLLayer>;
  46. private _xrLayerWrapper;
  47. /**
  48. * Observers registered here will be triggered when the xr layer was initialized
  49. */
  50. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  51. /**
  52. * Initializes the canvas to be added/removed upon entering/exiting xr
  53. * @param _xrSessionManager The XR Session manager
  54. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  55. */
  56. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  57. /**
  58. * Disposes of the object
  59. */
  60. dispose(): void;
  61. /**
  62. * Initializes a XRWebGLLayer to be used as the session's baseLayer.
  63. * @param xrSession xr session
  64. * @returns a promise that will resolve once the XR Layer has been created
  65. */
  66. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  67. private _addCanvas;
  68. private _removeCanvas;
  69. private _setCanvasSize;
  70. private _setManagedOutputCanvas;
  71. }