CanvasTexture.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Texture } from './Texture.js';
  2. /**
  3. * Creates a texture from a canvas element.
  4. *
  5. * This is almost the same as the base texture class, except that it sets {@link Texture#needsUpdate}
  6. * to `true` immediately since a canvas can directly be used for rendering.
  7. *
  8. * @augments Texture
  9. */
  10. class CanvasTexture extends Texture {
  11. /**
  12. * Constructs a new texture.
  13. *
  14. * @param {HTMLCanvasElement} [canvas] - The HTML canvas element.
  15. * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
  16. * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
  17. * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
  18. * @param {number} [magFilter=LinearFilter] - The mag filter value.
  19. * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
  20. * @param {number} [format=RGBAFormat] - The texture format.
  21. * @param {number} [type=UnsignedByteType] - The texture type.
  22. * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
  23. */
  24. constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
  25. super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
  26. /**
  27. * This flag can be used for type testing.
  28. *
  29. * @type {boolean}
  30. * @readonly
  31. * @default true
  32. */
  33. this.isCanvasTexture = true;
  34. this.needsUpdate = true;
  35. }
  36. }
  37. export { CanvasTexture };
粤ICP备19079148号