InterleavedBufferAttribute.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * @author benaadams / https://twitter.com/ben_a_adams
  3. */
  4. THREE.InterleavedBufferAttribute = function ( interleavedBuffer, itemSize, offset ) {
  5. this.uuid = THREE.Math.generateUUID();
  6. this.data = interleavedBuffer;
  7. this.itemSize = itemSize;
  8. this.offset = offset;
  9. };
  10. THREE.InterleavedBufferAttribute.prototype = {
  11. constructor: THREE.InterleavedBufferAttribute,
  12. get length() {
  13. console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' );
  14. return this.array.length;
  15. },
  16. get count() {
  17. return this.data.array.length / this.data.stride;
  18. },
  19. setX: function ( index, x ) {
  20. this.data.array[ index * this.data.stride + this.offset ] = x;
  21. return this;
  22. },
  23. setY: function ( index, y ) {
  24. this.data.array[ index * this.data.stride + this.offset + 1 ] = y;
  25. return this;
  26. },
  27. setZ: function ( index, z ) {
  28. this.data.array[ index * this.data.stride + this.offset + 2 ] = z;
  29. return this;
  30. },
  31. setW: function ( index, w ) {
  32. this.data.array[ index * this.data.stride + this.offset + 3 ] = w;
  33. return this;
  34. },
  35. getX: function ( index ) {
  36. return this.data.array[ index * this.data.stride + this.offset ];
  37. },
  38. getY: function ( index ) {
  39. return this.data.array[ index * this.data.stride + this.offset + 1 ];
  40. },
  41. getZ: function ( index ) {
  42. return this.data.array[ index * this.data.stride + this.offset + 2 ];
  43. },
  44. getW: function ( index ) {
  45. return this.data.array[ index * this.data.stride + this.offset + 3 ];
  46. },
  47. setXY: function ( index, x, y ) {
  48. index = index * this.data.stride + this.offset;
  49. this.data.array[ index + 0 ] = x;
  50. this.data.array[ index + 1 ] = y;
  51. return this;
  52. },
  53. setXYZ: function ( index, x, y, z ) {
  54. index = index * this.data.stride + this.offset;
  55. this.data.array[ index + 0 ] = x;
  56. this.data.array[ index + 1 ] = y;
  57. this.data.array[ index + 2 ] = z;
  58. return this;
  59. },
  60. setXYZW: function ( index, x, y, z, w ) {
  61. index = index * this.data.stride + this.offset;
  62. this.data.array[ index + 0 ] = x;
  63. this.data.array[ index + 1 ] = y;
  64. this.data.array[ index + 2 ] = z;
  65. this.data.array[ index + 3 ] = w;
  66. return this;
  67. }
  68. };
粤ICP备19079148号