externalTexture.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { InternalTexture } from "./internalTexture.js";
  2. /**
  3. * Class used to store an external texture (like GPUExternalTexture in WebGPU)
  4. */
  5. export class ExternalTexture {
  6. /**
  7. * Checks if a texture is an external or internal texture
  8. * @param texture the external or internal texture
  9. * @returns true if the texture is an external texture, else false
  10. */
  11. static IsExternalTexture(texture) {
  12. return texture.underlyingResource !== undefined;
  13. }
  14. /**
  15. * Get the class name of the texture.
  16. * @returns "ExternalTexture"
  17. */
  18. getClassName() {
  19. return "ExternalTexture";
  20. }
  21. /**
  22. * Gets the underlying texture object
  23. */
  24. get underlyingResource() {
  25. return this._video;
  26. }
  27. /**
  28. * Constructs the texture
  29. * @param video The video the texture should be wrapped around
  30. */
  31. constructor(video) {
  32. /**
  33. * Gets a boolean indicating if the texture uses mipmaps
  34. */
  35. this.useMipMaps = false;
  36. /**
  37. * The type of the underlying texture is implementation dependent, so return "UNDEFINED" for the type
  38. */
  39. this.type = 16;
  40. /**
  41. * The format of the underlying texture is implementation dependent, so return "UNDEFINED" for the format
  42. */
  43. this.format = 4294967295;
  44. this._video = video;
  45. this.uniqueId = InternalTexture._Counter++;
  46. }
  47. /**
  48. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  49. * @returns true if fully ready
  50. */
  51. isReady() {
  52. return this._video.readyState >= this._video.HAVE_CURRENT_DATA;
  53. }
  54. /**
  55. * Dispose the texture and release its associated resources.
  56. */
  57. dispose() { }
  58. }
  59. //# sourceMappingURL=externalTexture.js.map