BufferGeometryExporter.js 766 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.BufferGeometryExporter = function () {};
  5. THREE.BufferGeometryExporter.prototype = {
  6. constructor: THREE.BufferGeometryExporter,
  7. parse: function ( geometry ) {
  8. var output = {
  9. metadata: {
  10. version: 4.0,
  11. type: 'BufferGeometry',
  12. generator: 'BufferGeometryExporter'
  13. },
  14. attributes: {}
  15. };
  16. for ( var key in geometry.attributes ) {
  17. var attribute = geometry.attributes[ key ];
  18. output.attributes[ key ] = {
  19. itemSize: attribute.itemSize,
  20. type: attribute.array.constructor.name,
  21. array: Array.apply( [], attribute.array )
  22. }
  23. }
  24. if ( geometry.offsets.length > 0 ) {
  25. output.offsets = JSON.parse( JSON.stringify( geometry.offsets ) );
  26. }
  27. return output;
  28. }
  29. };