GLBufferAttribute.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @author raub / https://github.com/raub
  3. */
  4. /**
  5. * Element size is one of:
  6. * gl.FLOAT: 4
  7. * gl.UNSIGNED_SHORT: 2
  8. * gl.SHORT: 2
  9. * gl.UNSIGNED_INT: 4
  10. * gl.INT: 4
  11. * gl.BYTE: 1
  12. * gl.UNSIGNED_BYTE: 1
  13. */
  14. function GLBufferAttribute( buffer, type, itemSize, elementSize, count ) {
  15. this.buffer = buffer;
  16. this.type = type;
  17. this.itemSize = itemSize;
  18. this.elementSize = elementSize;
  19. this.count = count;
  20. this.version = 0;
  21. }
  22. Object.defineProperty( GLBufferAttribute.prototype, 'needsUpdate', {
  23. set: function ( value ) {
  24. if ( value === true ) this.version ++;
  25. }
  26. } );
  27. Object.assign( GLBufferAttribute.prototype, {
  28. isGLBufferAttribute: true,
  29. setBuffer: function ( buffer ) {
  30. this.buffer = buffer;
  31. return this;
  32. },
  33. setType: function ( type, elementSize ) {
  34. this.type = type;
  35. this.elementSize = elementSize;
  36. return this;
  37. },
  38. setItemSize: function ( itemSize ) {
  39. this.itemSize = itemSize;
  40. return this;
  41. },
  42. setCount: function ( count ) {
  43. this.count = count;
  44. return this;
  45. },
  46. } );
  47. export { GLBufferAttribute };
粤ICP备19079148号