htmlElementTexture.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import type { Nullable } from "../../types";
  2. import { BaseTexture } from "../../Materials/Textures/baseTexture";
  3. import { Matrix } from "../../Maths/math.vector";
  4. import { Observable } from "../../Misc/observable";
  5. import "../../Engines/Extensions/engine.dynamicTexture";
  6. import "../../Engines/Extensions/engine.videoTexture";
  7. import "../../Engines/Extensions/engine.externalTexture";
  8. import type { AbstractEngine } from "../../Engines/abstractEngine";
  9. import type { Scene } from "../../scene";
  10. /**
  11. * Defines the options related to the creation of an HtmlElementTexture
  12. */
  13. export interface IHtmlElementTextureOptions {
  14. /**
  15. * Defines whether mip maps should be created or not.
  16. */
  17. generateMipMaps?: boolean;
  18. /**
  19. * Defines the sampling mode of the texture.
  20. */
  21. samplingMode?: number;
  22. /**
  23. * Defines the associated texture format.
  24. */
  25. format?: number;
  26. /**
  27. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  28. */
  29. engine: Nullable<AbstractEngine>;
  30. /**
  31. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  32. */
  33. scene: Nullable<Scene>;
  34. }
  35. /**
  36. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  37. * To be as efficient as possible depending on your constraints nothing aside the first upload
  38. * is automatically managed.
  39. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  40. * in your application.
  41. *
  42. * As the update is not automatic, you need to call them manually.
  43. */
  44. export declare class HtmlElementTexture extends BaseTexture {
  45. /**
  46. * The texture URL.
  47. */
  48. element: HTMLVideoElement | HTMLCanvasElement;
  49. /**
  50. * Observable triggered once the texture has been loaded.
  51. */
  52. onLoadObservable: Observable<HtmlElementTexture>;
  53. private static readonly _DefaultOptions;
  54. private readonly _format;
  55. private _textureMatrix;
  56. private _isVideo;
  57. private _generateMipMaps;
  58. private _samplingMode;
  59. private _externalTexture;
  60. /**
  61. * Instantiates a HtmlElementTexture from the following parameters.
  62. *
  63. * @param name Defines the name of the texture
  64. * @param element Defines the video or canvas the texture is filled with
  65. * @param options Defines the other none mandatory texture creation options
  66. */
  67. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  68. private _createInternalTexture;
  69. /**
  70. * @returns the texture matrix used in most of the material.
  71. */
  72. getTextureMatrix(): Matrix;
  73. /**
  74. * Updates the content of the texture.
  75. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  76. */
  77. update(invertY?: Nullable<boolean>): void;
  78. /**
  79. * Dispose the texture and release its associated resources.
  80. */
  81. dispose(): void;
  82. }