12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.BufferGeometryExporter = function () {};
- THREE.BufferGeometryExporter.prototype = {
- constructor: THREE.BufferGeometryExporter,
- parse: function ( geometry ) {
- var output = {
- metadata: {
- version: 4.0,
- type: 'BufferGeometry',
- generator: 'BufferGeometryExporter'
- },
- attributes: {
- }
- };
- var attributes = geometry.attributes;
- var offsets = geometry.offsets;
- var boundingSphere = geometry.boundingSphere;
- for ( var key in attributes ) {
- var attribute = attributes[ key ];
- output.attributes[ key ] = {
- itemSize: attribute.itemSize,
- type: attribute.array.constructor.name,
- array: Array.apply( [], attribute.array )
- }
- }
- if ( offsets.length > 0 ) {
- output.offsets = JSON.parse( JSON.stringify( offsets ) );
- }
- if ( boundingSphere !== null ) {
- output.boundingSphere = {
- center: boundingSphere.center.toArray(),
- radius: boundingSphere.radius
- }
- }
- return output;
- }
- };
|