mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-08-23 05:40:44 +02:00
56 lines
904 B
JavaScript
56 lines
904 B
JavaScript
|
/**
|
||
|
* @author mrdoob / http://mrdoob.com/
|
||
|
*/
|
||
|
|
||
|
THREE.TypedGeometryExporter = function () {};
|
||
|
|
||
|
THREE.TypedGeometryExporter.prototype = {
|
||
|
|
||
|
constructor: THREE.TypedGeometryExporter,
|
||
|
|
||
|
parse: function ( geometry ) {
|
||
|
|
||
|
var output = {
|
||
|
metadata: {
|
||
|
version: 4.0,
|
||
|
type: 'TypedGeometry',
|
||
|
generator: 'TypedGeometryExporter'
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var attributes = [ 'vertices', 'normals', 'uvs' ];
|
||
|
|
||
|
for ( var key in attributes ) {
|
||
|
|
||
|
var attribute = attributes[ key ];
|
||
|
|
||
|
var typedArray = geometry[ attribute ];
|
||
|
var array = [];
|
||
|
|
||
|
for ( var i = 0, l = typedArray.length; i < l; i ++ ) {
|
||
|
|
||
|
array[ i ] = typedArray[ i ];
|
||
|
|
||
|
}
|
||
|
|
||
|
output[ attribute ] = array;
|
||
|
|
||
|
}
|
||
|
|
||
|
var boundingSphere = geometry.boundingSphere;
|
||
|
|
||
|
if ( boundingSphere !== null ) {
|
||
|
|
||
|
output.boundingSphere = {
|
||
|
center: boundingSphere.center.toArray(),
|
||
|
radius: boundingSphere.radius
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
return output;
|
||
|
|
||
|
}
|
||
|
|
||
|
};
|