getModelAccessor.js 880 B

12345678910111213141516171819202122232425262728293031323334
  1. /*global define*/
  2. define([
  3. '../Core/ComponentDatatype'
  4. ], function(
  5. ComponentDatatype) {
  6. "use strict";
  7. var ComponentsPerAttribute = {
  8. 'SCALAR' : 1,
  9. 'VEC2' : 2,
  10. 'VEC3' : 3,
  11. 'VEC4' : 4,
  12. 'MAT2' : 4,
  13. 'MAT3' : 9,
  14. 'MAT4' : 16
  15. };
  16. /**
  17. * @private
  18. */
  19. var getModelAccessor = function(accessor) {
  20. var componentDatatype = accessor.componentType;
  21. var componentsPerAttribute = ComponentsPerAttribute[accessor.type];
  22. return {
  23. componentsPerAttribute : componentsPerAttribute,
  24. createArrayBufferView : function(buffer, byteOffset, length) {
  25. return ComponentDatatype.createArrayBufferView(componentDatatype, buffer, byteOffset, componentsPerAttribute * length);
  26. }
  27. };
  28. };
  29. return getModelAccessor;
  30. });