CompressedTextureBuffer.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import defined from './defined.js';
  2. import defineProperties from './defineProperties.js';
  3. /**
  4. * Describes a compressed texture and contains a compressed texture buffer.
  5. * @alias CompressedTextureBuffer
  6. * @constructor
  7. *
  8. * @param {PixelFormat} internalFormat The pixel format of the compressed texture.
  9. * @param {Number} width The width of the texture.
  10. * @param {Number} height The height of the texture.
  11. * @param {Uint8Array} buffer The compressed texture buffer.
  12. */
  13. function CompressedTextureBuffer(internalFormat, width, height, buffer) {
  14. this._format = internalFormat;
  15. this._width = width;
  16. this._height = height;
  17. this._buffer = buffer;
  18. }
  19. defineProperties(CompressedTextureBuffer.prototype, {
  20. /**
  21. * The format of the compressed texture.
  22. * @type PixelFormat
  23. * @readonly
  24. * @memberof CompressedTextureBuffer.prototype
  25. */
  26. internalFormat : {
  27. get : function() {
  28. return this._format;
  29. }
  30. },
  31. /**
  32. * The width of the texture.
  33. * @type Number
  34. * @readonly
  35. * @memberof CompressedTextureBuffer.prototype
  36. */
  37. width : {
  38. get : function() {
  39. return this._width;
  40. }
  41. },
  42. /**
  43. * The height of the texture.
  44. * @type Number
  45. * @readonly
  46. * @memberof CompressedTextureBuffer.prototype
  47. */
  48. height : {
  49. get : function() {
  50. return this._height;
  51. }
  52. },
  53. /**
  54. * The compressed texture buffer.
  55. * @type Uint8Array
  56. * @readonly
  57. * @memberof CompressedTextureBuffer.prototype
  58. */
  59. bufferView : {
  60. get : function() {
  61. return this._buffer;
  62. }
  63. }
  64. });
  65. /**
  66. * Creates a shallow clone of a compressed texture buffer.
  67. *
  68. * @param {CompressedTextureBuffer} object The compressed texture buffer to be cloned.
  69. * @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.
  70. */
  71. CompressedTextureBuffer.clone = function(object) {
  72. if (!defined(object)) {
  73. return undefined;
  74. }
  75. return new CompressedTextureBuffer(object._format, object._width, object._height, object._buffer);
  76. };
  77. /**
  78. * Creates a shallow clone of this compressed texture buffer.
  79. *
  80. * @return {CompressedTextureBuffer} A shallow clone of the compressed texture buffer.
  81. */
  82. CompressedTextureBuffer.prototype.clone = function() {
  83. return CompressedTextureBuffer.clone(this);
  84. };
  85. export default CompressedTextureBuffer;