BufferAttribute.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.BufferAttribute = function () {};
  5. THREE.BufferAttribute.prototype = {
  6. constructor: THREE.BufferAttribute,
  7. get length () {
  8. return this.array.length;
  9. },
  10. set: function ( value ) {
  11. this.array.set( value );
  12. return this;
  13. },
  14. setX: function ( index, x ) {
  15. this.array[ index * this.itemSize ] = x;
  16. return this;
  17. },
  18. setY: function ( index, y ) {
  19. this.array[ index * this.itemSize + 1 ] = y;
  20. return this;
  21. },
  22. setZ: function ( index, z ) {
  23. this.array[ index * this.itemSize + 2 ] = z;
  24. return this;
  25. },
  26. setXY: function ( index, x, y ) {
  27. index *= this.itemSize;
  28. this.array[ index ] = x;
  29. this.array[ index + 1 ] = y;
  30. return this;
  31. },
  32. setXYZ: function ( index, x, y, z ) {
  33. index *= this.itemSize;
  34. this.array[ index ] = x;
  35. this.array[ index + 1 ] = y;
  36. this.array[ index + 2 ] = z;
  37. return this;
  38. },
  39. setXYZW: function ( index, x, y, z, w ) {
  40. index *= this.itemSize;
  41. this.array[ index ] = x;
  42. this.array[ index + 1 ] = y;
  43. this.array[ index + 2 ] = z;
  44. this.array[ index + 3 ] = w;
  45. return this;
  46. }
  47. };
  48. //
  49. THREE.Int8Attribute = function ( size, itemSize ) {
  50. this.array = new Int8Array( size * itemSize );
  51. this.itemSize = itemSize;
  52. };
  53. THREE.Int8Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  54. THREE.Uint8Attribute = function ( size, itemSize ) {
  55. this.array = new Uint8Array( size * itemSize );
  56. this.itemSize = itemSize;
  57. };
  58. THREE.Uint8Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  59. THREE.Uint8ClampedAttribute = function ( size, itemSize ) {
  60. this.array = new Uint8ClampedArray( size * itemSize );
  61. this.itemSize = itemSize;
  62. };
  63. THREE.Uint8ClampedAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  64. THREE.Int16Attribute = function ( size, itemSize ) {
  65. this.array = new Int16Array( size * itemSize );
  66. this.itemSize = itemSize;
  67. };
  68. THREE.Int16Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  69. THREE.Uint16Attribute = function ( size, itemSize ) {
  70. this.array = new Uint16Array( size * itemSize );
  71. this.itemSize = itemSize;
  72. };
  73. THREE.Uint16Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  74. THREE.Int32Attribute = function ( size, itemSize ) {
  75. this.array = new Int32Array( size * itemSize );
  76. this.itemSize = itemSize;
  77. };
  78. THREE.Int32Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  79. THREE.Uint32Attribute = function ( size, itemSize ) {
  80. this.array = new Uint32Array( size * itemSize );
  81. this.itemSize = itemSize;
  82. };
  83. THREE.Uint32Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  84. THREE.Float32Attribute = function ( size, itemSize ) {
  85. this.array = new Float32Array( size * itemSize );
  86. this.itemSize = itemSize;
  87. };
  88. THREE.Float32Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
  89. THREE.Float64Attribute = function ( size, itemSize ) {
  90. this.array = new Float64Array( size * itemSize );
  91. this.itemSize = itemSize;
  92. };
  93. THREE.Float64Attribute.prototype = Object.create( THREE.BufferAttribute.prototype );
粤ICP备19079148号