|
@@ -6,10 +6,10 @@
|
|
|
* var exporter = new THREE.PLYExporter();
|
|
|
*
|
|
|
* // second argument is a list of options
|
|
|
- * var data = exporter.parse( mesh, { binary: true, excludeAttributes: [ 'color' ] } );
|
|
|
+ * exporter.parse(mesh, data => console.log(data), { binary: true, excludeAttributes: [ 'color' ] });
|
|
|
*
|
|
|
* Format Definition:
|
|
|
- * http://paulbourke.net/dataformats/ply/
|
|
|
+ * http://paulbourke.net/dataformats/ply/
|
|
|
*/
|
|
|
|
|
|
THREE.PLYExporter = function () {};
|
|
@@ -18,7 +18,15 @@ THREE.PLYExporter.prototype = {
|
|
|
|
|
|
constructor: THREE.PLYExporter,
|
|
|
|
|
|
- parse: function ( object, options ) {
|
|
|
+ parse: function ( object, onDone, options ) {
|
|
|
+
|
|
|
+ if ( onDone && typeof onDone === 'object' ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.PLYExporter: The options parameter is now the third argument to the "parse" function. See the documentation for the new API.' );
|
|
|
+ options = onDone;
|
|
|
+ onDone = undefined;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// Iterate over the valid meshes in the object
|
|
|
function traverseMeshes( cb ) {
|
|
@@ -208,6 +216,7 @@ THREE.PLYExporter.prototype = {
|
|
|
// Generate attribute data
|
|
|
var vertex = new THREE.Vector3();
|
|
|
var normalMatrixWorld = new THREE.Matrix3();
|
|
|
+ var result = null;
|
|
|
|
|
|
if ( options.binary === true ) {
|
|
|
|
|
@@ -399,7 +408,7 @@ THREE.PLYExporter.prototype = {
|
|
|
|
|
|
} );
|
|
|
|
|
|
- return output;
|
|
|
+ result = output.buffer;
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -529,10 +538,13 @@ THREE.PLYExporter.prototype = {
|
|
|
|
|
|
} );
|
|
|
|
|
|
- return `${ header }${vertexList}\n${ includeIndices ? `${faceList}\n` : '' }`;
|
|
|
+ result = `${ header }${vertexList}\n${ includeIndices ? `${faceList}\n` : '' }`;
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( typeof onDone === 'function' ) requestAnimationFrame( () => onDone( result ) );
|
|
|
+ return result;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
};
|