engine.views.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { Engine } from "../engine";
  2. import type { Camera } from "../../Cameras/camera";
  3. import type { Nullable } from "../../types";
  4. import { Observable } from "../../Misc/observable";
  5. /**
  6. * Class used to define an additional view for the engine
  7. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/multiCanvas
  8. */
  9. export declare class EngineView {
  10. /**
  11. * A randomly generated unique id
  12. */
  13. readonly id: string;
  14. /** Defines the canvas where to render the view */
  15. target: HTMLCanvasElement;
  16. /**
  17. * Defines an optional camera or array of cameras used to render the view (will use active camera / cameras else)
  18. * Support for array of cameras @since
  19. */
  20. camera?: Camera | Camera[];
  21. /** Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha < 1 */
  22. clearBeforeCopy?: boolean;
  23. /** Indicates if the view is enabled (true by default) */
  24. enabled: boolean;
  25. /** Defines a custom function to handle canvas size changes. (the canvas to render into is provided to the callback) */
  26. customResize?: (canvas: HTMLCanvasElement) => void;
  27. }
  28. declare module "../../Engines/abstractEngine" {
  29. interface AbstractEngine {
  30. /** @internal */
  31. _inputElement: Nullable<HTMLElement>;
  32. /**
  33. * Gets or sets the HTML element to use for attaching events
  34. */
  35. inputElement: Nullable<HTMLElement>;
  36. /**
  37. * Observable to handle when a change to inputElement occurs
  38. * @internal
  39. */
  40. _onEngineViewChanged?: () => void;
  41. /**
  42. * Will be triggered before the view renders
  43. */
  44. readonly onBeforeViewRenderObservable: Observable<EngineView>;
  45. /**
  46. * Will be triggered after the view rendered
  47. */
  48. readonly onAfterViewRenderObservable: Observable<EngineView>;
  49. /**
  50. * Gets the current engine view
  51. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/multiCanvas
  52. */
  53. activeView: Nullable<EngineView>;
  54. /** Gets or sets the list of views */
  55. views: EngineView[];
  56. /**
  57. * Register a new child canvas
  58. * @param canvas defines the canvas to register
  59. * @param camera defines an optional camera or array of cameras to use with this canvas (it will overwrite the scene.activeCamera / scene.activeCameras for this view). Support for array of cameras @since
  60. * @param clearBeforeCopy Indicates if the destination view canvas should be cleared before copying the parent canvas. Can help if the scene clear color has alpha \< 1
  61. * @returns the associated view
  62. */
  63. registerView(canvas: HTMLCanvasElement, camera?: Camera | Camera[], clearBeforeCopy?: boolean): EngineView;
  64. /**
  65. * Remove a registered child canvas
  66. * @param canvas defines the canvas to remove
  67. * @returns the current engine
  68. */
  69. unRegisterView(canvas: HTMLCanvasElement): Engine;
  70. /**
  71. * @internal
  72. */
  73. _renderViewStep(view: EngineView): boolean;
  74. }
  75. }