|
@@ -13,6 +13,7 @@ THREE.OBJExporter.prototype = {
|
|
|
var indexNormals = 0;
|
|
|
|
|
|
var vertex = new THREE.Vector3();
|
|
|
+ var color = new THREE.Color();
|
|
|
var normal = new THREE.Vector3();
|
|
|
var uv = new THREE.Vector2();
|
|
|
|
|
@@ -235,6 +236,69 @@ THREE.OBJExporter.prototype = {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ var parsePoints = function ( points ) {
|
|
|
+
|
|
|
+ var nbVertex = 0;
|
|
|
+
|
|
|
+ var geometry = points.geometry;
|
|
|
+
|
|
|
+ if ( geometry instanceof THREE.Geometry ) {
|
|
|
+
|
|
|
+ geometry = new THREE.BufferGeometry().setFromObject( points );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
+
|
|
|
+ var vertices = geometry.getAttribute( 'position' );
|
|
|
+ var colors = geometry.getAttribute( 'color' );
|
|
|
+
|
|
|
+ output += 'o ' + points.name + '\n';
|
|
|
+
|
|
|
+ if ( vertices !== undefined ) {
|
|
|
+
|
|
|
+ for ( i = 0, l = vertices.count; i < l; i ++, nbVertex ++ ) {
|
|
|
+
|
|
|
+ vertex.fromBufferAttribute( vertices, i );
|
|
|
+ vertex.applyMatrix4( points.matrixWorld );
|
|
|
+
|
|
|
+ output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z;
|
|
|
+
|
|
|
+ if ( colors !== undefined ) {
|
|
|
+
|
|
|
+ color.fromBufferAttribute( colors, i );
|
|
|
+
|
|
|
+ output += ' ' + color.r + ' ' + color.g + ' ' + color.b;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ output += '\n';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ output += 'p ';
|
|
|
+
|
|
|
+ for ( j = 1, l = vertices.count; j <= l; j ++ ) {
|
|
|
+
|
|
|
+ output += ( indexVertex + j ) + ' ';
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ output += '\n';
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ console.warn( 'THREE.OBJExporter.parseLine(): geometry type unsupported', geometry );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // update index
|
|
|
+ indexVertex += nbVertex;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
object.traverse( function ( child ) {
|
|
|
|
|
|
if ( child instanceof THREE.Mesh ) {
|
|
@@ -249,6 +313,12 @@ THREE.OBJExporter.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( child instanceof THREE.Points ) {
|
|
|
+
|
|
|
+ parsePoints( child );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
} );
|
|
|
|
|
|
return output;
|