Source: texture/Texture3D.js

  1. import { TextureBase } from './TextureBase.js';
  2. import { WEBGL_TEXTURE_TYPE, WEBGL_PIXEL_FORMAT, WEBGL_PIXEL_TYPE } from '../const.js';
  3. /**
  4. * Creates a 3D texture. (WebGL 2.0)
  5. * @constructor
  6. * @memberof zen3d
  7. * @extends zen3d.TextureBase
  8. */
  9. function Texture3D() {
  10. TextureBase.call(this);
  11. this.textureType = WEBGL_TEXTURE_TYPE.TEXTURE_3D;
  12. /**
  13. * Image data for this texture.
  14. * @member {Object}
  15. * @default null
  16. */
  17. this.image = { data: new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255]), width: 2, height: 2, depth: 2 };
  18. /**
  19. * WebGLTexture texel data format.
  20. * @type {zen3d.WEBGL_PIXEL_FORMAT}
  21. * @default zen3d.WEBGL_PIXEL_FORMAT.RED
  22. */
  23. this.format = WEBGL_PIXEL_FORMAT.RED;
  24. /**
  25. * WebGLTexture texel data internal format.
  26. * If null, internalformat is set to be same as format.
  27. * This must be null in WebGL 1.0.
  28. * @type {null|zen3d.WEBGL_PIXEL_FORMAT}
  29. * @default zen3d.WEBGL_PIXEL_FORMAT.R8
  30. */
  31. this.internalformat = WEBGL_PIXEL_FORMAT.R8;
  32. /**
  33. * WebGLTexture texel data type.
  34. * @type {zen3d.WEBGL_PIXEL_TYPE}
  35. * @default zen3d.WEBGL_PIXEL_TYPE.UNSIGNED_BYTE
  36. */
  37. this.type = WEBGL_PIXEL_TYPE.UNSIGNED_BYTE;
  38. /**
  39. * @default false
  40. */
  41. this.flipY = false;
  42. }
  43. Texture3D.prototype = Object.assign(Object.create(TextureBase.prototype), /** @lends zen3d.TextureCube.prototype */{
  44. constructor: Texture3D
  45. });
  46. export { Texture3D };