InterleavedBuffer.js 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @author benaadams / https://twitter.com/ben_a_adams
  3. */
  4. THREE.InterleavedBuffer = function ( array, stride, dynamic ) {
  5. this.uuid = THREE.Math.generateUUID();
  6. this.array = array;
  7. this.stride = stride;
  8. this.needsUpdate = false;
  9. this.dynamic = dynamic || false;
  10. this.updateRange = { offset: 0, count: -1 };
  11. };
  12. THREE.InterleavedBuffer.prototype = {
  13. constructor: THREE.InterleavedBuffer,
  14. get length () {
  15. return this.array.length;
  16. },
  17. copyAt: function ( index1, attribute, index2 ) {
  18. index1 *= this.stride;
  19. index2 *= attribute.stride;
  20. for ( var i = 0, l = this.stride; i < l; i++ ) {
  21. this.array[ index1 + i ] = attribute.array[ index2 + i ];
  22. }
  23. return this;
  24. },
  25. set: function ( value, offset ) {
  26. if ( offset === undefined ) offset = 0;
  27. this.array.set( value, offset );
  28. return this;
  29. },
  30. clone: function () {
  31. return new THREE.InterleavedBuffer( new this.array.constructor( this.array ), this.stride, this.dynamic );
  32. }
  33. };
粤ICP备19079148号