CanvasTexture.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. * @param {string} [colorSpace=NoColorSpace] - The color space value.
  24. */
  25. constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
  26. super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
  27. /**
  28. * This flag can be used for type testing.
  29. *
  30. * @type {boolean}
  31. * @readonly
  32. * @default true
  33. */
  34. this.isCanvasTexture = true;
  35. this.needsUpdate = true;
  36. }
  37. }
  38. export { CanvasTexture };
粤ICP备19079148号